@open-mercato/cezar 0.19.0 → 0.20.0-pr1372.4752
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contract/index.js +4 -1
- package/dist/contract/repo.d.ts +3 -1
- package/dist/git-worktree.d.ts +2 -1
- package/dist/git-worktree.js +7 -2
- package/dist/git-worktree.js.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/runs/retention.d.ts +9 -2
- package/dist/runs/retention.js +23 -4
- package/dist/runs/retention.js.map +1 -1
- package/dist/server/server.d.ts +12 -10
- package/dist/server/server.js +27 -2
- package/dist/server/server.js.map +1 -1
- package/dist/worktree-in-use.d.ts +25 -0
- package/dist/worktree-in-use.js +274 -0
- package/dist/worktree-in-use.js.map +1 -0
- package/dist/worktree-lifecycle/coordinator.js +4 -0
- package/dist/worktree-lifecycle/coordinator.js.map +1 -1
- package/package.json +3 -3
- package/web/dist/assets/{agent-task-pickers-C6pdeuHJ.js → agent-task-pickers-C0lbPIio.js} +1 -1
- package/web/dist/assets/{alert-dialog-DsAKVB9U.js → alert-dialog-D7_6EawW.js} +1 -1
- package/web/dist/assets/arrow-left-Ci5OwIMH.js +1 -0
- package/web/dist/assets/{arrow-up-DerG9eQK.js → arrow-up-Pd8kIuRY.js} +1 -1
- package/web/dist/assets/{assets-view-COAZvPqm.js → assets-view-Dig8Ow0W.js} +1 -1
- package/web/dist/assets/{automation-format-DmmN5Z7N.js → automation-format-MLNn8qnY.js} +1 -1
- package/web/dist/assets/{automations-route-C9h3Pe23.js → automations-route-B_hyZJ2Q.js} +1 -1
- package/web/dist/assets/{bot-tf6AC27f.js → bot-TU5OTE8D.js} +1 -1
- package/web/dist/assets/{button-DhBNRPDb.js → button-jcXhXi-5.js} +1 -1
- package/web/dist/assets/{centered-state-DWZ57Ha1.js → centered-state-zjxxQcEb.js} +1 -1
- package/web/dist/assets/check-CNVywZ6B.js +1 -0
- package/web/dist/assets/chevron-left-D94sZNQc.js +1 -0
- package/web/dist/assets/chevron-right-D2EqYt_O.js +1 -0
- package/web/dist/assets/circle-check-C09e7mFj.js +1 -0
- package/web/dist/assets/{collapsible-BXlCnxCU.js → collapsible-BGyXLTVv.js} +1 -1
- package/web/dist/assets/{commit-list-Inz2UHlC.js → commit-list-DxiIebKF.js} +1 -1
- package/web/dist/assets/{compare-variants-B66gT_Lp.js → compare-variants-RfJUgKZi.js} +1 -1
- package/web/dist/assets/{dashboard-DQ2EsruE.js → dashboard-CPnDqmbf.js} +1 -1
- package/web/dist/assets/{diff-NBMGWe9I.js → diff-DpElozOH.js} +2 -2
- package/web/dist/assets/{diff-stat-CgvKmRgV.js → diff-stat-YT7Licr1.js} +1 -1
- package/web/dist/assets/{diff-view-t0WQPrPT.js → diff-view-mNp6Fo84.js} +1 -1
- package/web/dist/assets/{dist-BJiHofth.js → dist-C2IyLYZs.js} +1 -1
- package/web/dist/assets/{download-CEvQNLNA.js → download-Cu9ySzL2.js} +1 -1
- package/web/dist/assets/{dropdown-menu-R7qzKuR5.js → dropdown-menu-Da8iP-nI.js} +1 -1
- package/web/dist/assets/{external-link-OzBGW2PE.js → external-link-CTJbUN9h.js} +1 -1
- package/web/dist/assets/{facet-filter-Qbx1pf2T.js → facet-filter-Be0XFoHu.js} +1 -1
- package/web/dist/assets/{file-fM0ty7CG.js → file-D9jm2sJ3.js} +1 -1
- package/web/dist/assets/{file-preview-vKAohITF.js → file-preview-BIAcYezC.js} +1 -1
- package/web/dist/assets/{file-tree-DZ2eXzpR.js → file-tree-hpaNl9qS.js} +1 -1
- package/web/dist/assets/{folder-DdjIxY7B.js → folder-Ctd1Xvqx.js} +1 -1
- package/web/dist/assets/{follow-up-engine-BSEbPKpI.js → follow-up-engine-WsUFV3Ry.js} +1 -1
- package/web/dist/assets/{git-pull-request-D2gvtstb.js → git-pull-request-BAfSEvVb.js} +1 -1
- package/web/dist/assets/{git-pull-request-draft-CLy0NzfX.js → git-pull-request-draft-BIgZJsu-.js} +1 -1
- package/web/dist/assets/{git-tab-loading-BfHswOkO.js → git-tab-loading-BnU4U-BA.js} +1 -1
- package/web/dist/assets/{github-3riSQ6Lm.js → github-DnDrPPfz.js} +1 -1
- package/web/dist/assets/{host-usage-7ZdPz-XK.js → host-usage-BeX2ZFmV.js} +1 -1
- package/web/dist/assets/{icon-tooltip-DWp0bFCr.js → icon-tooltip-BfI1AC00.js} +1 -1
- package/web/dist/assets/{impact-control-C6qnPF32.js → impact-control-Ba9XW3tV.js} +1 -1
- package/web/dist/assets/{impact-model-BXkk-8LD.js → impact-model-Bo4KSZmi.js} +1 -1
- package/web/dist/assets/{index-BJPVto-W.js → index-Crs_dvXc.js} +5 -5
- package/web/dist/assets/{input-Cv2-g500.js → input-vswZUfsf.js} +1 -1
- package/web/dist/assets/{layout-cards-rvwV0uTN.js → layout-cards-BxB9Sv6Z.js} +1 -1
- package/web/dist/assets/loader-circle-BuBcxAH7.js +1 -0
- package/web/dist/assets/{markdown-DpThfUoB.js → markdown--qN61YgZ.js} +1 -1
- package/web/dist/assets/{markdown-ugFgDUM5.js → markdown-BiRiR9OM.js} +1 -1
- package/web/dist/assets/{message-square-k8K2YFw2.js → message-square-Jt8U2gAH.js} +1 -1
- package/web/dist/assets/{picker-pill-DjKsq5S1.js → picker-pill-BFprBA9h.js} +1 -1
- package/web/dist/assets/plus-nGmv0BVG.js +1 -0
- package/web/dist/assets/{project-router-DXcbRXxc.js → project-router-ByYpf5zi.js} +1 -1
- package/web/dist/assets/{queries-DvnoUOE1.js → queries-DbDUaheq.js} +1 -1
- package/web/dist/assets/{reasoning-effort-pill-BtWN6FBA.js → reasoning-effort-pill-BMAjcAKk.js} +1 -1
- package/web/dist/assets/{repo-git-DQHghYiX.js → repo-git-CpbhUvyL.js} +1 -1
- package/web/dist/assets/{run-diff-CymNF6XN.js → run-diff-DTbhZHQE.js} +1 -1
- package/web/dist/assets/{save-A5Be1rcj.js → save-DGJET0jv.js} +1 -1
- package/web/dist/assets/{scroll-within-DIDO40Ps.js → scroll-within-sbc5xXAl.js} +1 -1
- package/web/dist/assets/search-P545ZVzc.js +1 -0
- package/web/dist/assets/{search-x-DHAJ1hHA.js → search-x-BI_L6x3P.js} +1 -1
- package/web/dist/assets/{settings-2-CT4CHpD0.js → settings-2-CcipoS54.js} +1 -1
- package/web/dist/assets/{sheet-D8vk1p4X.js → sheet-DJ7Q8rRA.js} +1 -1
- package/web/dist/assets/{skills-BAzH59kW.js → skills-DwnXdnzS.js} +1 -1
- package/web/dist/assets/{square-dKpVPAsQ.js → square-CuNOgYBC.js} +1 -1
- package/web/dist/assets/{tabs-B_vUNwk9.js → tabs-BCUQqEYa.js} +1 -1
- package/web/dist/assets/{tag-BWgO0bkB.js → tag-DHjatodA.js} +1 -1
- package/web/dist/assets/{task-commits-rj991QXb.js → task-commits-x21u_XE-.js} +1 -1
- package/web/dist/assets/{task-graph-VKJ_lfXL.js → task-graph-DdCE5G3r.js} +1 -1
- package/web/dist/assets/{task-notes-CyXwM1jJ.js → task-notes-C6RP3maE.js} +1 -1
- package/web/dist/assets/task-workspace-xnZHXFXk.js +29 -0
- package/web/dist/assets/terminal-ZT2Z_ALj.js +1 -0
- package/web/dist/assets/{terminal-drawer-BZItdxn-.js → terminal-drawer-Dm0kyMmF.js} +1 -1
- package/web/dist/assets/{terminal-pane-D4ZoQdKv.js → terminal-pane-CRjYeI78.js} +1 -1
- package/web/dist/assets/{textarea-DGt1COuN.js → textarea-Ckx3d0hV.js} +1 -1
- package/web/dist/assets/{toaster-DkOynrTr.js → toaster-CejrnYvv.js} +1 -1
- package/web/dist/assets/{token-metrics-CH6yTO0m.js → token-metrics-BINGXGrg.js} +1 -1
- package/web/dist/assets/{tooltip-DZFNJfGV.js → tooltip-26XdOGj8.js} +1 -1
- package/web/dist/assets/{tracker-CfV4FaME.js → tracker-BzXE6yLf.js} +1 -1
- package/web/dist/assets/{triangle-alert-DPgo0TAM.js → triangle-alert-CBrg6nYB.js} +1 -1
- package/web/dist/assets/{upload-CyWxzeww.js → upload-Cu6NRABh.js} +1 -1
- package/web/dist/assets/{use-now-p7SRpNs9.js → use-now-CdtIyF-0.js} +1 -1
- package/web/dist/assets/{use-submit-shortcut-DbaZm8p1.js → use-submit-shortcut-B3TJ3HBP.js} +1 -1
- package/web/dist/assets/{utils-DujIMO-J.js → utils-Bl_tQdVw.js} +1 -1
- package/web/dist/assets/{workflow-graph-Bi8UYX1n.js → workflow-graph-CkCPBwhB.js} +1 -1
- package/web/dist/assets/{worktree-lifecycle-operation-D7uIWIl_.js → worktree-lifecycle-operation-UpV9MAuk.js} +1 -1
- package/web/dist/assets/x-Qhn_uE86.js +1 -0
- package/web/dist/index.html +50 -50
- package/dist/telemetry-service.json +0 -1
- package/web/dist/assets/arrow-left-D773GDAV.js +0 -1
- package/web/dist/assets/check--JMF5pzG.js +0 -1
- package/web/dist/assets/chevron-left-BiwkBjqr.js +0 -1
- package/web/dist/assets/chevron-right-QEoLhwFQ.js +0 -1
- package/web/dist/assets/circle-check-C7cRTvGo.js +0 -1
- package/web/dist/assets/loader-circle-wWXhd3lT.js +0 -1
- package/web/dist/assets/plus-BCu7YC-w.js +0 -1
- package/web/dist/assets/search-_XntIRWA.js +0 -1
- package/web/dist/assets/task-workspace-BsOvp8_P.js +0 -29
- package/web/dist/assets/terminal-De3oF9fR.js +0 -1
- package/web/dist/assets/x-BzTqCf_Q.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/terminal-pane-
|
|
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{$ as a,$n as o,$r as s,$t as c,A as l,Aa as u,Ar as d,B as f,Bn as p,Bt as m,C as h,Ca as g,Cn as _,Co as v,Da as y,Dn as b,E as x,Eo as S,F as C,Fn as w,Fr as T,Ft as E,G as D,Gn as O,Gt as k,Hn as A,Ht as j,Ia as M,In as N,It as P,J as F,Ja as ee,Ji as te,Jn as I,Jt as ne,K as L,Kn as re,Kt as ie,Li as ae,Ln as oe,Lt as se,Mn as ce,Na as le,Nn as R,Nr as ue,Nt as de,On as fe,Or as pe,Pa as z,Pi as me,Pn as he,Pt as ge,Q as _e,Qi as ve,Qt as ye,Ra as be,Rn as xe,Rt as Se,S as Ce,Sn as we,So as Te,St as Ee,T as De,Ta as Oe,To as ke,Tr as Ae,Ua as je,Ui as Me,Un as Ne,Ut as Pe,V as Fe,Va as Ie,Vn as Le,Vt as Re,W as ze,Wa as Be,Wn as Ve,Wr as He,Xn as Ue,Y as We,Ya as Ge,Yi as Ke,Yn as qe,Yt as Je,Z as Ye,Za as Xe,Zt as Ze,_ as Qe,_a as $e,_n as et,_o as tt,_t as nt,aa as rt,an as it,ao as at,bn as ot,bo as st,c as ct,ca as lt,cn as ut,co as dt,ct as ft,d as pt,da as mt,dn as ht,do as gt,dt as _t,ei as vt,en as yt,eo as bt,er as xt,et as St,f as Ct,fa as wt,fn as Tt,fo as Et,g as Dt,gn as Ot,go as kt,h as At,ha as jt,ho as Mt,i as Nt,ia as Pt,in as Ft,io as It,it as Lt,j as Rt,jn as zt,ka as Bt,l as Vt,ln as Ht,lo as Ut,lt as Wt,m as Gt,ma as Kt,mn as qt,mo as Jt,na as Yt,no as Xt,nr as Zt,nt as Qt,o as $t,oi as en,on as tn,oo as nn,ot as rn,p as an,pa as on,pn as B,po as sn,pr as cn,pt as ln,q as un,qa as dn,qn as fn,qt as pn,r as V,ra as mn,ro as hn,rt as gn,s as _n,si as vn,so as H,st as yn,ta as bn,tn as xn,tt as Sn,u as Cn,un as wn,uo as U,ut as Tn,v as En,vo as Dn,vr as On,wa as kn,wn as An,wo as jn,x as Mn,xa as Nn,xi as Pn,xn as Fn,xo as In,xr as Ln,xt as Rn,y as zn,yn as Bn,yo as Vn,yr as Hn,z as Un,za as Wn,zr as Gn,zt as Kn}from"./queries-DvnoUOE1.js";import{J as qn,St as Jn,T as Yn,_t as Xn,a as Zn,bt as Qn,c as $n,f as er,ft as tr,g as nr,i as rr,m as ir,n as ar,nt as or,o as sr,p as cr,pt as lr,r as ur,t as W,u as dr,y as fr,yt as pr}from"./utils-DujIMO-J.js";import{t as mr}from"./preload-helper-Czpn1I53.js";import{S as hr,_ as gr,a as _r,c as vr,d as yr,f as br,g as xr,h as G,i as Sr,l as Cr,m as wr,n as Tr,o as Er,p as Dr,r as Or,s as kr,t as K,u as Ar,v as jr,x as Mr,y as Nr}from"./project-router-DXcbRXxc.js";import{C as Pr,O as Fr,S as Ir,_ as Lr,a as Rr,b as zr,g as Br,h as Vr,i as Hr,l as Ur,m as Wr,n as Gr,o as Kr,p as qr,s as Jr,t as Yr,u as Xr,v as Zr}from"./use-now-p7SRpNs9.js";import{A as Qr,C as $r,D as ei,E as ti,F as ni,I as ri,L as ii,M as ai,N as oi,O as si,P as ci,S as li,T as ui,_ as di,a as fi,b as pi,c as mi,g as hi,h as gi,i as _i,j as vi,k as yi,l as bi,m as xi,n as Si,p as Ci,r as wi,t as Ti,v as Ei,w as Di,x as Oi,y as ki}from"./facet-filter-Qbx1pf2T.js";import{c as Ai,d as ji,f as Mi,g as Ni,h as Pi,i as Fi,l as Ii,m as Li,n as Ri,o as zi,p as Bi,r as Vi,s as Hi,t as Ui,u as Wi}from"./sheet-D8vk1p4X.js";import{a as Gi,c as Ki,d as qi,f as Ji,i as Yi,l as Xi,n as Zi,o as Qi,r as $i,s as ea,t as ta,u as na}from"./host-usage-7ZdPz-XK.js";import{t as ra}from"./use-desktop-BNN3U2y9.js";import{C as ia,D as aa,M as oa,N as q,O as sa,S as ca,T as la,_ as ua,b as da,f as fa,g as pa,h as ma,j as ha,m as ga,p as _a,t as J,v as va,w as ya,x as ba,y as xa}from"./button-DhBNRPDb.js";import{Ct as Sa,Et as Ca,Lt as wa,Nt as Ta,Ot as Ea,Pt as Da,St as Oa,Tt as ka,_ as Aa,_t as ja,a as Ma,b as Na,bt as Pa,c as Fa,dt as Ia,ft as La,gt as Ra,ht as za,i as Ba,jt as Va,mt as Ha,n as Ua,o as Wa,pt as Ga,s as Ka,ut as qa,vt as Ja,wt as Ya,x as Xa,xt as Za,y as Qa,yt as $a}from"./git-tab-loading-BfHswOkO.js";import{n as eo,t as to}from"./arrow-up-DerG9eQK.js";import{t as no}from"./arrow-left-D773GDAV.js";import{A as ro,B as io,C as ao,E as oo,F as so,H as co,I as lo,L as uo,M as fo,N as po,P as mo,S as ho,T as go,V as _o,_ as vo,a as yo,b as bo,c as xo,d as So,f as Co,h as wo,i as To,j as Eo,k as Do,l as Oo,o as ko,p as Ao,r as jo,s as Mo,t as No,u as Po,w as Fo,y as Io}from"./worktree-lifecycle-operation-D7uIWIl_.js";import{t as Lo}from"./bot-tf6AC27f.js";import{$ as Ro,A as zo,C as Bo,Ct as Vo,D as Ho,Et as Uo,J as Wo,O as Go,Ot as Ko,Q as qo,S as Jo,T as Yo,Tt as Xo,X as Zo,Y as Qo,Z as $o,_ as es,_t as ts,a as ns,at as rs,b as is,bt as as,c as os,d as ss,dt as cs,et as ls,f as us,g as ds,gt as fs,h as ps,i as ms,it as hs,j as gs,jt as _s,k as vs,kt as ys,m as bs,n as xs,o as Ss,ot as Cs,p as ws,q as Ts,s as Es,st as Ds,t as Os,u as ks,ut as As,v as js,vt as Ms,w as Ns,wt as Ps,x as Fs,y as Is,yt as Ls}from"./picker-pill-DjKsq5S1.js";import{t as Rs}from"./check--JMF5pzG.js";import{a as zs,i as Bs,n as Vs,o as Hs,r as Us,s as Ws,t as Gs}from"./dist-BJiHofth.js";import{t as Ks}from"./chevron-right-QEoLhwFQ.js";import{t as qs}from"./circle-check-C7cRTvGo.js";import{i as Js,l as Ys,m as Xs,n as Zs,p as Qs,r as $s,s as ec,t as tc}from"./dropdown-menu-R7qzKuR5.js";import{i as nc,r as rc}from"./use-submit-shortcut-DbaZm8p1.js";import{t as ic}from"./external-link-OzBGW2PE.js";import{_ as ac,b as oc,h as sc,v as cc,x as lc}from"./impact-model-BXkk-8LD.js";import{t as uc}from"./file-fM0ty7CG.js";import{t as dc}from"./folder-DdjIxY7B.js";import{n as fc,t as pc}from"./upload-CyWxzeww.js";import{n as mc,r as hc,t as gc}from"./textarea-DGt1COuN.js";import{t as _c}from"./loader-circle-wWXhd3lT.js";import{t as vc}from"./message-square-k8K2YFw2.js";import{n as yc,t as bc}from"./square-dKpVPAsQ.js";import{t as xc}from"./plus-BCu7YC-w.js";import{t as Sc}from"./search-x-DHAJ1hHA.js";import{t as Cc}from"./search-_XntIRWA.js";import{t as wc}from"./triangle-alert-DPgo0TAM.js";import{t as Tc}from"./x-BzTqCf_Q.js";import{a as Ec,i as Dc,n as Oc,r as kc,t as Ac}from"./tooltip-DZFNJfGV.js";import{a as jc,i as Mc,o as Nc}from"./collapsible-BXlCnxCU.js";import{a as Pc,c as Fc,i as Ic,n as Lc,o as Rc,r as zc,s as Bc,t as Vc}from"./alert-dialog-DsAKVB9U.js";import{i as Hc,n as Uc,r as Wc,t as Gc}from"./tabs-B_vUNwk9.js";import{t as Kc}from"./input-Cv2-g500.js";import{r as Y,t as qc}from"./toaster-DkOynrTr.js";import{n as Jc,t as Yc}from"./token-metrics-CH6yTO0m.js";import{n as Xc}from"./format-DHK74MwW.js";import{t as Zc}from"./diff-stat-CgvKmRgV.js";import{t as Qc}from"./icon-tooltip-DWp0bFCr.js";import{t as $c}from"./lib-BQXq3kEf.js";import{t as el}from"./clipboard-DvCUPLwM.js";import{n as tl,t as X}from"./centered-state-DWZ57Ha1.js";import{t as nl}from"./reasoning-effort-pill-BtWN6FBA.js";import{a as rl,i as il,n as al,t as ol}from"./markdown-DpThfUoB.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 sl=class extends S{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 gt({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=cl(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=cl(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=cl(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=cl(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){Jt.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=>Vn(t,e))}findAll(e={}){return this.getAll().filter(t=>Vn(e,t))}notify(e){Jt.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return Jt.batch(()=>Promise.all(e.map(e=>e.continue().catch(In))))}};function cl(e){return e.options.scope?.id}var ll=class extends S{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??tt(r,t),a=this.get(i);return a||(a=new Et({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(){Jt.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=>st(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>st(e,t)):t}notify(e){Jt.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Jt.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Jt.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},ul=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new ll,this.#t=e.mutationCache||new sl,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=ke.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=sn.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(v(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=Mt(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return Jt.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;Jt.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return Jt.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=Jt.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(In).catch(In)}invalidateQueries(e,t={}){return Jt.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=Jt.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(In)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(In)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(v(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(In).catch(In)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(In).catch(In)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return sn.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(kt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Te(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(kt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Te(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||=tt(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===jn&&(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),dl=n();function fl(){return new ul({defaultOptions:{queries:{refetchInterval:!1,staleTime:5*6e4,gcTime:30*6e4,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:(e,t)=>t instanceof cn&&t.status>=400&&t.status<500?!1:t instanceof cn&&t.status===0?e<3:e<1,retryDelay:(e,t)=>t instanceof cn&&t.status===0?Math.min(250*2**e,1e3):Math.min(1e3*2**e,3e4)},mutations:{retry:!1}}})}var pl=q(`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`}]]),ml=q(`arrow-left-right`,[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]),hl=q(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),gl=q(`blocks`,[[`path`,{d:`M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2`,key:`1ah6g2`}],[`rect`,{x:`14`,y:`2`,width:`8`,height:`8`,rx:`1`,key:`88lufb`}]]),_l=q(`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`}]]),vl=q(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),yl=q(`chevrons-left`,[[`path`,{d:`m11 17-5-5 5-5`,key:`13zhaf`}],[`path`,{d:`m18 17-5-5 5-5`,key:`h8a8et`}]]),bl=q(`chevrons-right`,[[`path`,{d:`m6 17 5-5-5-5`,key:`xnjwq`}],[`path`,{d:`m13 17 5-5-5-5`,key:`17xmmf`}]]),xl=q(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),Sl=q(`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`}]]),Cl=q(`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`}]]),wl=q(`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`}]]),Tl=q(`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`}]]),El=q(`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`}]]),Dl=q(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),Ol=q(`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`}]]),kl=q(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 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.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Al=q(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`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`}]]),jl=q(`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`}]]),Ml=q(`folders`,[[`path`,{d:`M20 5a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h2.5a1.5 1.5 0 0 1 1.2.6l.6.8a1.5 1.5 0 0 0 1.2.6z`,key:`a4852j`}],[`path`,{d:`M3 8.268a2 2 0 0 0-1 1.738V19a2 2 0 0 0 2 2h11a2 2 0 0 0 1.732-1`,key:`yxbcw3`}]]),Nl=q(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),Pl=q(`gift`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M20 11v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8`,key:`1sqzm4`}],[`path`,{d:`M7.5 7a1 1 0 0 1 0-5A4.8 8 0 0 1 12 7a4.8 8 0 0 1 4.5-5 1 1 0 0 1 0 5`,key:`kc0143`}],[`rect`,{x:`3`,y:`7`,width:`18`,height:`4`,rx:`1`,key:`1hberx`}]]),Fl=q(`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`}]]),Il=q(`inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]),Ll=q(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Rl=q(`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`}]]),zl=q(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),Bl=q(`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`}]]),Vl=q(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),Hl=q(`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`}]]),Ul=q(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),Wl=q(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Gl=q(`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`}]]),Kl=q(`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`}]]),ql=q(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]),Jl=q(`package-check`,[[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`path`,{d:`m16 17 2 2 4-4`,key:`uh5qu3`}],[`path`,{d:`M21 11.127V8a2 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.729l7 4a2 2 0 0 0 2 .001l1.32-.753`,key:`kpkbpo`}],[`path`,{d:`M3.29 7 12 12l8.71-5`,key:`19ckod`}],[`path`,{d:`m7.5 4.27 8.997 5.148`,key:`9yrvtv`}]]),Yl=q(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 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.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),Xl=q(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),Zl=q(`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`}]]),Ql=q(`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`}]]),$l=q(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),eu=q(`scale`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`m19 8 3 8a5 5 0 0 1-6 0zV7`,key:`zcdpyk`}],[`path`,{d:`M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1`,key:`1yorad`}],[`path`,{d:`m5 8 3 8a5 5 0 0 1-6 0zV7`,key:`eua70x`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}]]),tu=q(`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`}]]),nu=q(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),ru=q(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),iu=q(`split`,[[`path`,{d:`M16 3h5v5`,key:`1806ms`}],[`path`,{d:`M8 3H3v5`,key:`15dfkv`}],[`path`,{d:`M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3`,key:`1qrqzj`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}]]),au=q(`star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),ou=q(`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`}]]),su=q(`ticket`,[[`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`,key:`qn84l0`}],[`path`,{d:`M13 5v2`,key:`dyzc3o`}],[`path`,{d:`M13 17v2`,key:`1ont0d`}],[`path`,{d:`M13 11v2`,key:`1wjjxi`}]]),cu=q(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),lu=q(`webhook`,[[`path`,{d:`M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2`,key:`q3hayz`}],[`path`,{d:`m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06`,key:`1go1hn`}],[`path`,{d:`m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8`,key:`qlwsc0`}]]),uu={jira:{label:`Jira`,scopeLabel:`Jira projects`},linear:{label:`Linear`,scopeLabel:`Linear teams`}},du=Jn.options.map(e=>({kind:e,...uu[e]}));function fu(e){let t=Z.useRef({value:e,previous:e});return Z.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Q=i(),pu=`Label`,mu=Z.forwardRef((e,t)=>(0,Q.jsx)(la.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));mu.displayName=pu;var hu=mu;function gu(e,[t,n]){return Math.min(n,Math.max(t,e))}var _u=e(r(),1),vu=[` `,`Enter`,`ArrowUp`,`ArrowDown`],yu=[` `,`Enter`],bu=`Select`,[xu,Su,Cu]=Xs(bu),[wu,Tu]=ya(bu,[Cu,zs]),Eu=zs(),[Du,Ou]=wu(bu),[ku,Au]=wu(bu),ju=`SelectProvider`;function Mu(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=Eu(t),[_,v]=Z.useState(null),[y,b]=Z.useState(null),[x,S]=Z.useState(!1),C=Qs(l),[w,T]=ba({prop:r,defaultProp:i??!1,onChange:a,caller:bu}),[E,D]=ba({prop:o,defaultProp:s,onChange:c,caller:bu}),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=xa(),P=Array.from(j).map(e=>e.props.value).join(`;`),F=Z.useCallback(e=>{M(t=>new Set(t).add(e))},[]),ee=Z.useCallback(e=>{M(t=>{let n=new Set(t);return n.delete(e),n})},[]),te={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)(Bs,{...g,children:(0,Q.jsx)(Du,{scope:t,...te,children:(0,Q.jsx)(xu.Provider,{scope:t,children:(0,Q.jsx)(ku,{scope:t,onNativeOptionAdd:F,onNativeOptionRemove:ee,children:Md(h)?h(te):n})})})})}Mu.displayName=ju;var Nu=e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,Q.jsx)(Mu,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,Q.jsxs)(Q.Fragment,{children:[n,e?(0,Q.jsx)(jd,{__scopeSelect:t}):null]})})};Nu.displayName=bu;var Pu=`SelectTrigger`,Fu=Z.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Eu(n),o=Ou(Pu,n),s=o.disabled||r,c=ha(t,o.onTriggerChange),l=Su(n),u=Z.useRef(`touch`),[d,f,p]=Pd(e=>{let t=l().filter(e=>!e.disabled),n=Fd(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)(Gs,{asChild:!0,...a,children:(0,Q.jsx)(la.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":Nd(o.value)?``:void 0,...i,ref:c,onClick:ia(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:ia(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:ia(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&vu.includes(e.key)&&(m(),e.preventDefault())})})})});Fu.displayName=Pu;var Iu=`SelectValue`,Lu=Z.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=Ou(Iu,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=ha(t,c.onValueNodeChange);ca(()=>{l(u)},[l,u]);let f=Nd(c.value);return(0,Q.jsx)(la.span,{...s,asChild:!f&&s.asChild,ref:d,style:{pointerEvents:`none`},children:(0,Q.jsx)(Z.Fragment,{children:f?o:a},f?`placeholder`:`value`)})});Lu.displayName=Iu;var Ru=`SelectIcon`,zu=Z.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,Q.jsx)(la.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});zu.displayName=Ru;var Bu=`SelectPortal`,[Vu,Hu]=wu(Bu,{forceMount:void 0}),Uu=e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,Q.jsx)(Vu,{scope:e.__scopeSelect,forceMount:n,children:(0,Q.jsx)(ma,{asChild:!0,...r})})};Uu.displayName=Bu;var Wu=`SelectContent`,Gu=Z.forwardRef((e,t)=>{let n=Hu(Wu,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=Ou(Wu,e.__scopeSelect),[o,s]=Z.useState();return ca(()=>{s(new DocumentFragment)},[]),(0,Q.jsx)(da,{present:r||a.open,children:({present:e})=>e?(0,Q.jsx)(Qu,{...i,ref:t}):(0,Q.jsx)(Ku,{...i,fragment:o})})});Gu.displayName=Wu;var Ku=Z.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,fragment:i}=e;return i?_u.createPortal((0,Q.jsx)(Ju,{scope:n,children:(0,Q.jsx)(xu.Slot,{scope:n,children:(0,Q.jsx)(`div`,{ref:t,children:r})})}),i):null});Ku.displayName=`SelectContentFragment`;var qu=10,[Ju,Yu]=wu(Wu),Xu=`SelectContentImpl`,Zu=sa(`SelectContent.RemoveScroll`),Qu=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=Ou(Wu,n),[y,b]=Z.useState(null),[x,S]=Z.useState(null),C=ha(t,b),[w,T]=Z.useState(null),[E,D]=Z.useState(null),O=Su(n),[k,A]=Z.useState(!1),j=Z.useRef(!1);Z.useEffect(()=>{if(y)return fa(y)},[y]),ga();let M=Z.useCallback(e=>{let[t,...n]=O().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},[O,x]),N=Z.useCallback(()=>M([w,y]),[M,w,y]);Z.useEffect(()=>{k&&N()},[k,N]);let{onOpenChange:P,triggerPointerDownPosRef:F}=v;Z.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(F.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(F.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(y)||P(!1),document.removeEventListener(`pointermove`,t),F.current=null};return F.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,P,F]),Z.useEffect(()=>{let e=()=>P(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[P]);let[ee,te]=Pd(e=>{let t=O().filter(e=>!e.disabled),n=Fd(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),I=Z.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(j.current=!0))},[v.value]),ne=Z.useCallback(()=>y?.focus(),[y]),L=Z.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),re=r===`popper`?nd:ed,ie=re===nd?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,Q.jsx)(Ju,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:I,selectedItem:w,onItemLeave:ne,itemTextRefCallback:L,focusSelectedItem:N,selectedItemText:E,position:r,isPositioned:k,searchRef:ee,children:(0,Q.jsx)(_a,{as:Zu,allowPinchZoom:!0,children:(0,Q.jsx)(pa,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:ia(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,Q.jsx)(ua,{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:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:ia(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&te(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=O().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(()=>M(t)),e.preventDefault()}})})})})})})});Qu.displayName=Xu;var $u=`SelectItemAlignedPosition`,ed=Z.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=Ou(Wu,n),o=Yu(Wu,n),[s,c]=Z.useState(null),[l,u]=Z.useState(null),d=ha(t,u),f=Su(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-qu,d=gu(a,[qu,Math.max(qu,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-qu,d=gu(a,[qu,Math.max(qu,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-qu*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-qu,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=`${qu}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]);ca(()=>y(),[y]);let[b,x]=Z.useState();return ca(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,Q.jsx)(rd,{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)(la.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});ed.displayName=$u;var td=`SelectPopperPosition`,nd=Z.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=qu,...a}=e,o=Eu(n);return(0,Q.jsx)(Us,{...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)`}})});nd.displayName=td;var[rd,id]=wu(Wu,{}),ad=`SelectViewport`,od=Z.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=Yu(ad,n),o=id(ad,n),s=ha(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)(xu.Slot,{scope:n,children:(0,Q.jsx)(la.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:ia(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-qu*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})})})]})});od.displayName=ad;var sd=`SelectGroup`,[cd,ld]=wu(sd),ud=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=xa();return(0,Q.jsx)(cd,{scope:n,id:i,children:(0,Q.jsx)(la.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});ud.displayName=sd;var dd=`SelectLabel`,fd=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=ld(dd,n);return(0,Q.jsx)(la.div,{id:i.id,...r,ref:t})});fd.displayName=dd;var pd=`SelectItem`,[md,hd]=wu(pd),gd=Z.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=Ou(pd,n),c=Yu(pd,n),l=s.value===r,[u,d]=Z.useState(a??``),[f,p]=Z.useState(!1),m=ha(t,va(e=>c.itemRefCallback?.(e,r,i))),h=xa(),g=Z.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};return(0,Q.jsx)(md,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:Z.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,Q.jsx)(xu.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,Q.jsx)(la.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:ia(o.onFocus,()=>p(!0)),onBlur:ia(o.onBlur,()=>p(!1)),onClick:ia(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:ia(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:ia(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:ia(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ia(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:ia(o.onKeyDown,e=>{i||e.target!==e.currentTarget||c.searchRef?.current!==``&&e.key===` `||(yu.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});gd.displayName=pd;var _d=`SelectItemText`,vd=Z.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=Ou(_d,n),s=Yu(_d,n),c=hd(_d,n),l=Au(_d,n),[u,d]=Z.useState(null),f=va(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=ha(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 ca(()=>(g(h),()=>_(h)),[g,_,h]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(la.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!Nd(o.value)?_u.createPortal(a.children,o.valueNode):null]})});vd.displayName=_d;var yd=`SelectItemIndicator`,bd=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return hd(yd,n).isSelected?(0,Q.jsx)(la.span,{"aria-hidden":!0,...r,ref:t}):null});bd.displayName=yd;var xd=`SelectScrollUpButton`,Sd=Z.forwardRef((e,t)=>{let n=Yu(xd,e.__scopeSelect),r=id(xd,e.__scopeSelect),[i,a]=Z.useState(!1),o=ha(t,r.onScrollButtonChange);return ca(()=>{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)(Td,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});Sd.displayName=xd;var Cd=`SelectScrollDownButton`,wd=Z.forwardRef((e,t)=>{let n=Yu(Cd,e.__scopeSelect),r=id(Cd,e.__scopeSelect),[i,a]=Z.useState(!1),o=ha(t,r.onScrollButtonChange);return ca(()=>{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)(Td,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});wd.displayName=Cd;var Td=Z.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Yu(`SelectScrollButton`,n),o=Z.useRef(null),s=Su(n),c=Z.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return Z.useEffect(()=>()=>c(),[c]),ca(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,Q.jsx)(la.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:ia(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:ia(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:ia(i.onPointerLeave,()=>{c()})})}),Ed=`SelectSeparator`,Dd=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,Q.jsx)(la.div,{"aria-hidden":!0,...r,ref:t})});Dd.displayName=Ed;var Od=`SelectArrow`,kd=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Eu(n);return Yu(Od,n).position===`popper`?(0,Q.jsx)(Vs,{...i,...r,ref:t}):null});kd.displayName=Od;var Ad=`SelectBubbleInput`,jd=Z.forwardRef(({__scopeSelect:e,...t},n)=>{let r=Ou(Ad,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=ha(n,p),h=i??``,g=fu(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)(la.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:u,onChange:e=>a(e.target.value),...t,style:{...Ec,...t.style},ref:m,defaultValue:h,children:[Nd(i)&&!_?(0,Q.jsx)(`option`,{value:``}):null,Array.from(d)]},f)});jd.displayName=Ad;function Md(e){return typeof e==`function`}function Nd(e){return e===``||e===void 0}function Pd(e){let t=va(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 Fd(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=Id(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 Id(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ld=`Switch`,[Rd,zd]=ya(Ld),[Bd,Vd]=Rd(Ld);function Hd(e){let{__scopeSwitch:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=ba({prop:n,defaultProp:i??!1,onChange:c,caller:Ld}),[m,h]=Z.useState(null),[g,_]=Z.useState(null),v={checked:f,setChecked:p,disabled:a,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:Z.useRef(!1),required:l,defaultChecked:i,isFormControl:!m||!!o||!!m.closest(`form`),bubbleInput:g,setBubbleInput:_};return(0,Q.jsx)(Bd,{scope:t,...v,children:Xd(d)?d(v):r})}var Ud=`SwitchTrigger`,Wd=Z.forwardRef(({__scopeSwitch:e,onClick:t,...n},r)=>{let{control:i,form:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,isFormControl:p,bubbleInput:m}=Vd(Ud,e),h=ha(r,u),g=Z.useRef(c);return Z.useEffect(()=>{let e=a?i?.ownerDocument.getElementById(a):i?.form;if(e instanceof HTMLFormElement){let t=()=>d(g.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[i,a,d]),(0,Q.jsx)(la.button,{type:`button`,role:`switch`,"aria-checked":c,"aria-required":l,"data-state":Zd(c),"data-disabled":s?``:void 0,disabled:s,value:o,...n,ref:h,onClick:ia(t,e=>{d(e=>!e),m&&p&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})});Wd.displayName=Ud;var Gd=Z.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,Q.jsx)(Hd,{__scopeSwitch:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Wd,{...d,ref:t,__scopeSwitch:n}),e&&(0,Q.jsx)(Yd,{__scopeSwitch:n})]})})});Gd.displayName=Ld;var Kd=`SwitchThumb`,qd=Z.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=Vd(Kd,n);return(0,Q.jsx)(la.span,{"data-state":Zd(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});qd.displayName=Kd;var Jd=`SwitchBubbleInput`,Yd=Z.forwardRef(({__scopeSwitch:e,...t},n)=>{let{control:r,hasConsumerStoppedPropagationRef:i,checked:a,defaultChecked:o,required:s,disabled:c,name:l,value:u,form:d,bubbleInput:f,setBubbleInput:p}=Vd(Jd,e),m=ha(n,p),h=fu(a),g=Hs(r);Z.useEffect(()=>{let e=f;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=!i.current;if(h!==a&&n){let t=new Event(`click`,{bubbles:r});n.call(e,a),e.dispatchEvent(t)}},[f,h,a,i]);let _=Z.useRef(a);return(0,Q.jsx)(la.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:o??_.current,required:s,disabled:c,name:l,value:u,form:d,...t,tabIndex:-1,ref:m,style:{...t.style,...g,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})});Yd.displayName=Jd;function Xd(e){return typeof e==`function`}function Zd(e){return e?`checked`:`unchecked`}var Qd=oa(`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-primary text-primary-foreground [a&]:hover:bg-primary/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-primary underline-offset-4 [a&]:hover:underline`}},defaultVariants:{variant:`default`}});function $d({className:e,variant:t=`default`,asChild:n=!1,...r}){return(0,Q.jsx)(n?aa:`span`,{"data-slot":`badge`,"data-variant":t,className:W(Qd({variant:t}),e),...r})}var ef=/^(?:\\\\\?\\)?[A-Za-z]:$/,tf=/^(?:[\\/]{2}(?!\?[\\/])|\\\\\?\\UNC\\)[^\\/]+[\\/][^\\/]+$/i;function nf(e){let t=e.replace(/[\\/]+$/,``);if(ef.test(t)||tf.test(t))return null;let n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));if(n<0)return null;if(n===0)return t.slice(0,1);let r=t.slice(0,n);return ef.test(r)?t.slice(0,n+1):r}var rf=`x-apple.systempreferences:com.apple.preference.security?Privacy_FilesAndFolders`,af=`inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-foreground hover:bg-muted`;function of({path:e,selected:t,onSelect:n,onEnter:r,decorate:i,emptyHint:a,showHidden:o=!1}){let s=De(e,o),c=s.data?.parent??null,l=e===null?null:nf(e);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{"data-slot":`fs-breadcrumb`,className:`truncate font-mono text-meta text-soft-foreground`,title:s.data?.path??void 0,children:s.data?.path??(s.isError?``:`Loading…`)}),!s.isError&&s.data?.parent===null?(0,Q.jsxs)(`p`,{"data-slot":`fs-root-hint`,className:`text-label text-soft-foreground`,children:[`This is the browse root. To browse elsewhere, change`,` `,(0,Q.jsx)(`a`,{href:`/settings/global/projects`,className:`text-foreground underline underline-offset-4 hover:text-muted-foreground`,children:`Default browse folder in Settings → Projects`}),`.`]}):null,s.isError?(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-ui text-danger`,children:s.error instanceof Error?s.error.message:`could not list that folder`}),s.error instanceof cn&&s.error.status===403?(0,Q.jsx)(`p`,{"data-slot":`fs-privacy-hint`,className:`text-label 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-label`,children:[l===null?null:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`fs-error-back`,onClick:()=>r(l),className:af,children:[(0,Q.jsx)(wl,{className:`size-3.5`,"aria-hidden":!0}),`Back`]}),s.error instanceof cn&&s.error.status===403?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`a`,{"data-slot":`fs-privacy-settings`,href:rf,target:`_blank`,rel:`noreferrer`,className:af,children:`Open Privacy Settings`}),(0,Q.jsx)(`button`,{type:`button`,"data-slot":`fs-retry`,onClick:()=>void s.refetch(),className:af,children:`Try again`})]}):null]})]}):(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-ui hover:bg-muted`,children:[(0,Q.jsx)(wl,{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:W(`flex min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left text-ui hover:bg-muted`,t?.path===e.path&&`bg-muted`),children:[(0,Q.jsx)(dc,{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)(Ks,{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-ui text-muted-foreground`,children:a}):null]}),s.data?.truncated?(0,Q.jsx)(`p`,{"data-slot":`fs-truncated`,className:`text-meta text-muted-foreground`,children:`Too many folders to list — only the first ones are shown.`}):null]})}function sf(e,t,n=!1){let r=De(e,n);return t?.path??r.data?.path??null}function cf({open:e,onOpenChange:t}){let[n,r]=(0,Z.useState)(null),[i,o]=(0,Z.useState)(null),s=a(),c=Wt(),l=Nr(),u=new Set((s.data?.projects??[]).filter(e=>!e.unregistered).map(e=>e.root)),d=e=>{r(e),o(null),c.reset()},f=sf(n,i);return(0,Q.jsx)(qr,{open:e,onOpenChange:t,children:(0,Q.jsxs)(Wr,{"data-slot":`add-project-dialog`,className:`sm:max-w-lg`,children:[(0,Q.jsxs)(Lr,{children:[(0,Q.jsx)(Zr,{children:`Open local folder`}),(0,Q.jsx)(Vr,{children:`Pick the folder cezar should run in. Git repos are marked; any folder works.`})]}),(0,Q.jsx)(of,{path:n,selected:i,onSelect:o,onEnter:d,emptyHint:`No subfolders here — “Add project” registers this folder.`,decorate:e=>(0,Q.jsxs)(Q.Fragment,{children:[e.isRepo?(0,Q.jsx)($d,{variant:`outline`,className:`shrink-0 text-micro`,children:`git`}):null,u.has(e.path)?(0,Q.jsx)($d,{variant:`ghost`,className:`shrink-0 text-micro text-muted-foreground`,children:`already added`}):null]})}),c.isError?(0,Q.jsx)(`p`,{"data-slot":`add-project-error`,className:`min-w-0 break-words text-ui text-danger`,children:c.error instanceof Error?c.error.message:`could not add that folder`}):null,(0,Q.jsxs)(Br,{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-meta text-muted-foreground`,title:f??void 0,children:f??``}),(0,Q.jsxs)(`span`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsx)(J,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(J,{"data-slot":`add-project-confirm`,disabled:f===null||c.isPending,onClick:()=>{f===null||c.isPending||c.mutate(f,{onSuccess:({project:e})=>{t(!1),l(`/p/${encodeURIComponent(e.id)}/`)}})},children:c.isPending?`Adding…`:`Add project`})]})]})]})})}function lf({className:e,...t}){return(0,Q.jsx)(hu,{"data-slot":`label`,className:W(`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})}function uf(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 df({open:e,onOpenChange:t}){let[n,r]=(0,Z.useState)(``),[i,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(!1),f=a(),p=Qe(),{mutate:m,isPending:h}=p,g=Nr(),_=uf(p.error),v=(0,Z.useMemo)(()=>`co-${Math.random().toString(36).slice(2)}-${Date.now().toString(36)}`,[]),y=(0,Z.useRef)(v);y.current=v,(0,Z.useEffect)(()=>vi((e,t)=>{if(e!==`checkout-progress`)return;let n=t;n?.checkoutId===y.current&&(n.phase===`cloning`&&n.line?c(n.line):n.phase!==`cloning`&&c(null))}),[]);let b=(0,Z.useMemo)(()=>{let e=n.trim().replace(/\/+$/,``).replace(/\.git$/,``).split(`/`).pop()??``;return e.includes(`:`)?e.split(`:`).pop()??``:e},[n]),x=i.trim()===``?b:i.trim(),S=f.data?.projectsDir??``,C=x===``?``:`${S.replace(/\/+$/,``)}/${x}`,w=(0,Z.useCallback)(()=>{n.trim()===``||h||(d.current=!1,u(!1),c(null),m({url:n.trim(),checkoutId:v,...i.trim()===``?{}:{name:i.trim()}},{onSuccess:({project:e})=>{t(!1),g(`/p/${encodeURIComponent(e.id)}/`)}}))},[m,h,v,i,g,t,n]);return(0,Z.useEffect)(()=>{if(!l)return;let e=()=>{d.current&&(d.current=!1,u(!1),w())},t=()=>{document.visibilityState===`visible`&&e()};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,t)}},[l,w]),(0,Q.jsx)(qr,{open:e,onOpenChange:e=>p.isPending?void 0:t(e),children:(0,Q.jsxs)(Wr,{"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)(Lr,{children:[(0,Q.jsx)(Zr,{children:`Clone from GitHub`}),(0,Q.jsxs)(Vr,{children:[`The service 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)(lf,{htmlFor:`clone-url`,children:`Repository`}),(0,Q.jsx)(Kc,{id:`clone-url`,"data-slot":`clone-url`,autoFocus:!0,placeholder:`owner/repo or https://github.com/owner/repo`,value:n,disabled:p.isPending,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&w()}})]}),(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsx)(lf,{htmlFor:`clone-name`,children:`Folder name`}),(0,Q.jsx)(Kc,{id:`clone-name`,"data-slot":`clone-name`,placeholder:b===``?`repo`:b,value:i,disabled:p.isPending,onChange:e=>o(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-meta text-soft-foreground`,title:C,children:C}),p.isPending?(0,Q.jsx)(J,{"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)(tu,{className:`size-3.5`,"aria-hidden":`true`})}):(0,Q.jsx)(J,{asChild:!0,variant:`ghost`,size:`icon-sm`,className:`size-7`,children:(0,Q.jsx)(yr,{to:`/settings/global/projects`,"data-slot":`clone-root-settings`,"aria-label":`Edit checkout root`,title:`Edit checkout root`,children:(0,Q.jsx)(tu,{className:`size-3.5`,"aria-hidden":`true`})})})]})]}),p.isPending?(0,Q.jsx)(`p`,{"data-slot":`clone-progress`,className:`truncate font-mono text-meta text-muted-foreground`,children:s??`Starting the clone…`}):null,p.isError?(0,Q.jsx)(`div`,{"data-slot":`clone-error`,className:`grid min-w-0 gap-1.5 text-ui text-danger`,children:_?(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:`font-medium underline underline-offset-2`,href:_,target:`_blank`,rel:`noreferrer`,onClick:()=>{d.current=!0,u(!0)},children:`Authorize this GitHub organization`}),l?` — 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`,{children:`Error details`}),(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap break-all`,children:p.error instanceof Error?p.error.message:null})]})]}):(0,Q.jsx)(`p`,{className:`min-w-0 whitespace-pre-wrap break-all`,children:p.error instanceof Error?p.error.message:`could not clone that repository`})}):null,(0,Q.jsxs)(Br,{children:[(0,Q.jsx)(J,{variant:`outline`,disabled:p.isPending,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(J,{"data-slot":`clone-confirm`,disabled:n.trim()===``||x===``||p.isPending,onClick:w,children:p.isPending?`Cloning…`:p.isError?`Retry clone`:`Clone`})]})]})})}function ff({className:e,size:t=`default`,...n}){return(0,Q.jsx)(Gd,{"data-slot":`switch`,"data-size":t,className:W(`peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,e),...n,children:(0,Q.jsx)(qd,{"data-slot":`switch-thumb`,className:W(`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0`)})})}var pf=[{slug:`github/codespaces-nextjs`,label:`Next.js`,description:`Minimal Next.js app (GitHub)`},{slug:`vercel/ai-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 mf(e){let t=e.trim().toLowerCase();return t===``||pf.some(e=>e.slug.toLowerCase()===t)?pf:pf.filter(e=>[e.label,e.slug,e.description].some(e=>e.toLowerCase().includes(t)))}function hf({value:e,onChange:t,disabled:n,id:r}){let[i,a]=(0,Z.useState)(-1),o=(0,Z.useId)(),s=mf(e),c=(0,Z.useRef)(null),l=e.trim();(0,Z.useEffect)(()=>{i<0||c.current?.querySelector(`[data-index="${i}"]`)?.scrollIntoView?.({block:`nearest`})},[i]),(0,Z.useEffect)(()=>{c.current?.querySelector(`[aria-selected="true"]`)?.scrollIntoView?.({block:`nearest`})},[l]);let u=e=>{n||(t(e),a(-1))};return(0,Q.jsxs)(`div`,{className:`grid gap-2 md:flex md:min-h-0 md:flex-1 md:flex-col`,children:[(0,Q.jsx)(Kc,{id:r,"data-slot":`create-template`,role:`combobox`,"aria-expanded":s.length>0,"aria-controls":o,"aria-autocomplete":`list`,"aria-activedescendant":i>=0?`${o}-${i}`:void 0,autoComplete:`off`,placeholder:`Search, or paste owner/repo or a URL`,value:e,disabled:n,onBlur:()=>a(-1),onChange:e=>{t(e.target.value),a(-1)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;a(e=>s.length===0?-1:(e+t+s.length)%s.length)}else if(e.key===`Enter`&&i>=0){e.preventDefault();let t=s[i];t&&u(t.slug)}}}),s.length>0?(0,Q.jsx)(`ul`,{ref:c,id:o,role:`listbox`,"aria-label":`Suggested templates`,"aria-disabled":n||void 0,"data-slot":`create-template-suggestions`,className:W(`max-h-56 overflow-y-auto overscroll-contain rounded-md border border-border p-1`,`md:max-h-none md:min-h-36 md:flex-1`,n?`pointer-events-none opacity-50`:void 0),children:s.map((e,t)=>{let n=e.slug===l;return(0,Q.jsxs)(`li`,{id:`${o}-${t}`,role:`option`,"aria-selected":n,"data-index":t,"data-slot":`create-template-suggestion`,"data-template":e.slug,onMouseDown:e=>e.preventDefault(),onClick:()=>u(e.slug),onMouseEnter:()=>a(t),onMouseLeave:()=>a(-1),className:W(`grid cursor-pointer gap-0.5 rounded-sm border px-2 py-1.5`,n?`border-primary bg-primary/5`:`border-transparent`,t===i&&!n?`bg-accent text-accent-foreground`:void 0),children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-baseline justify-between gap-2`,children:[(0,Q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-sm font-medium`,children:[e.label,n?(0,Q.jsx)(qs,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":`true`}):null]}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-meta text-muted-foreground`,children:e.description})]}),(0,Q.jsx)(`span`,{className:`truncate font-mono text-meta text-soft-foreground`,children:e.slug})]},e.slug)})}):(0,Q.jsxs)(`p`,{"data-slot":`create-template-no-match`,className:`px-1 text-label text-muted-foreground`,children:[`No suggested template matches — any `,(0,Q.jsx)(`span`,{className:`font-mono`,children:`owner/repo`}),` or GitHub URL works.`]})]})}function gf(e){return e.trimStart().replace(/\s+/g,`-`)}function _f({open:e,onOpenChange:t}){let[n,r]=(0,Z.useState)(``),[i,o]=(0,Z.useState)(!0),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(`empty`),[p,m]=(0,Z.useState)(null),h=a(),g=Rt(),_=Ce(),v=Nr(),y=(0,Z.useMemo)(()=>`np-${Math.random().toString(36).slice(2)}-${Date.now().toString(36)}`,[]),b=(0,Z.useRef)(y);b.current=y,(0,Z.useEffect)(()=>vi((e,t)=>{if(e!==`checkout-progress`)return;let n=t;n?.checkoutId===b.current&&(n.phase===`cloning`&&n.line?m(n.line):n.phase!==`cloning`&&m(null))}),[]);let x=g.data,S=x?.available===!0&&Array.isArray(x.owners)&&x.owners.length>0,C=(0,Z.useMemo)(()=>x?.available&&Array.isArray(x.owners)?x.owners:[],[x]),w=C.some(e=>e.login===s)?s:C[0]?.login??``,T=i&&S,E=n.trim(),D=or.test(E),O=E===``||D?null:E.length>100?`At most 100 characters.`:`Use letters, digits, “.”, “-” and “_” only.`,k=h.data?.projectsDir??``,A=D?`${k.replace(/\/+$/,``)}/${E}`:``,j=T&&d===`template`,M=j&&l.trim()===``,N=()=>{if(!D||_.isPending||i&&g.isPending||M)return;m(null);let e=l.trim();_.mutate({name:E,checkoutId:y,...T?{github:{owner:w,...j&&e!==``?{template:e}:{}}}:{}},{onSuccess:({project:e})=>{t(!1),v(`/p/${encodeURIComponent(e.id)}/`)}})},P=_.isPending,F=g.isPending||S;return(0,Q.jsx)(qr,{open:e,onOpenChange:e=>P?void 0:t(e),children:(0,Q.jsxs)(Wr,{"data-slot":`create-project-dialog`,className:W(`max-h-[calc(100dvh-2rem)] overflow-y-auto`,F?`md:h-[min(50rem,calc(100dvh-4rem))] md:max-w-3xl md:grid-rows-[auto_minmax(0,1fr)_auto] md:overflow-hidden`:void 0),children:[(0,Q.jsxs)(Lr,{children:[(0,Q.jsx)(Zr,{children:`New project`}),(0,Q.jsx)(Vr,{children:`cezar creates a new git repository in your checkout root and adds it as a project.`})]}),(0,Q.jsxs)(`div`,{"data-slot":`create-layout`,className:W(`grid gap-6`,F?`md:min-h-0 md:grid-cols-[minmax(0,5fr)_minmax(0,6fr)]`:void 0),children:[F?(0,Q.jsx)(`div`,{"data-slot":`create-owners-column`,className:`min-w-0 md:flex md:min-h-0 md:flex-col md:border-r md:border-border md:pr-6`,children:S?(0,Q.jsx)(vf,{owners:C,value:w,disabled:P||!T,onChange:c}):(0,Q.jsx)(bf,{})}):null,(0,Q.jsxs)(`div`,{"data-slot":`create-form-column`,className:W(`grid min-w-0 content-start gap-4`,F?`md:-m-1 md:flex md:min-h-0 md:flex-col md:overflow-y-auto md:p-1`:void 0),children:[(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsx)(lf,{htmlFor:`create-name`,children:`Name`}),(0,Q.jsx)(Kc,{id:`create-name`,"data-slot":`create-name`,autoFocus:!0,placeholder:`my-project`,value:n,disabled:P,"aria-invalid":O!==null,"aria-describedby":`create-name-hint`,onChange:e=>r(gf(e.target.value)),onKeyDown:e=>{e.key===`Enter`&&N()}}),O?(0,Q.jsx)(`p`,{id:`create-name-hint`,"data-slot":`create-name-error`,className:`text-label text-danger`,children:O}):(0,Q.jsx)(`p`,{id:`create-name-hint`,"data-slot":`create-target`,className:`min-w-0 truncate font-mono text-meta text-soft-foreground`,title:A,children:A})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-border p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(lf,{htmlFor:`create-github`,className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(Vl,{className:`size-3.5`,"aria-hidden":`true`}),`Create a private GitHub repository`]}),(0,Q.jsx)(ff,{id:`create-github`,"data-slot":`create-github`,checked:T,disabled:P||!S,onCheckedChange:o})]}),g.isPending?(0,Q.jsx)(`p`,{className:`text-label text-muted-foreground`,children:`Checking GitHub…`}):S?null:(0,Q.jsx)(`p`,{"data-slot":`create-github-unavailable`,className:`text-label text-muted-foreground`,children:x&&!x.available?x.reason:`Could not read your GitHub accounts — the project will be created locally only.`}),T?(0,Q.jsxs)(`p`,{className:`text-label text-muted-foreground`,children:[`Created as `,(0,Q.jsx)(`strong`,{children:`private`}),` under `,(0,Q.jsx)(`strong`,{children:w}),` — you can change its visibility on GitHub.`]}):null]}),(0,Q.jsxs)(`div`,{"data-slot":`create-start`,className:`grid gap-3 rounded-md border border-border p-3 md:flex md:min-h-0 md:flex-1 md:flex-col`,children:[(0,Q.jsx)(`span`,{id:`create-start-label`,className:`text-sm font-medium`,children:`Start with`}),(0,Q.jsxs)(`div`,{role:`radiogroup`,"aria-labelledby":`create-start-label`,className:`grid gap-2 sm:grid-cols-2`,children:[(0,Q.jsx)(yf,{slot:`create-start-empty`,checked:!j,disabled:P,title:`Empty repository`,hint:`One empty commit, no files.`,onSelect:()=>f(`empty`)}),(0,Q.jsx)(yf,{slot:`create-start-template`,checked:j,disabled:P||!T,title:`From a template`,hint:T?`Copy a GitHub template.`:`Needs a GitHub repository.`,onSelect:()=>f(`template`)})]}),j?(0,Q.jsxs)(`div`,{className:`grid gap-1.5 md:flex md:min-h-0 md:flex-1 md:flex-col`,children:[(0,Q.jsx)(lf,{htmlFor:`create-template`,children:`Template`}),(0,Q.jsx)(hf,{id:`create-template`,value:l,disabled:P,onChange:u})]}):null]}),P?(0,Q.jsx)(`p`,{"data-slot":`create-progress`,className:`truncate font-mono text-meta text-muted-foreground`,children:p??`Starting…`}):null,_.isError?(0,Q.jsx)(`p`,{"data-slot":`create-error`,className:`whitespace-pre-line text-ui text-danger`,children:_.error instanceof Error?_.error.message:`could not create the project`}):null]})]}),(0,Q.jsxs)(Br,{children:[(0,Q.jsx)(J,{variant:`outline`,disabled:P,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(J,{"data-slot":`create-confirm`,disabled:!D||P||M||i&&g.isPending,onClick:N,children:P?`Creating…`:`Create`})]})]})})}function vf({owners:e,value:t,disabled:n,onChange:r}){let i=(0,Z.useRef)([]),a=(t,n)=>{if(e.length===0)return;let a=(t+n+e.length)%e.length,o=e[a]?.login;o!==void 0&&(r(o),i.current[a]?.focus())};return(0,Q.jsxs)(`div`,{className:`grid gap-3 md:flex md:min-h-0 md:flex-1 md:flex-col`,children:[(0,Q.jsx)(`span`,{id:`create-owner-label`,className:`eyebrow text-muted-foreground`,children:`Select organization`}),(0,Q.jsx)(`div`,{role:`radiogroup`,"aria-labelledby":`create-owner-label`,"data-slot":`create-owner`,className:`-mx-1 grid max-h-64 content-start gap-2 overflow-y-auto px-1 py-0.5 md:max-h-none md:min-h-0 md:flex-1`,children:e.map((e,o)=>{let s=e.login===t;return(0,Q.jsxs)(`button`,{ref:e=>{i.current[o]=e},type:`button`,role:`radio`,"aria-checked":s,tabIndex:s?0:-1,disabled:n,"data-slot":`create-owner-option`,"data-owner":e.login,onClick:()=>r(e.login),onKeyDown:e=>{e.key===`ArrowDown`||e.key===`ArrowRight`?(e.preventDefault(),a(o,1)):(e.key===`ArrowUp`||e.key===`ArrowLeft`)&&(e.preventDefault(),a(o,-1))},className:W(`flex w-full items-center gap-3 rounded-lg border bg-card px-3 py-2.5 text-left outline-none transition-colors`,`focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,s?`border-primary bg-primary/5`:`border-border hover:bg-muted/50`),children:[(0,Q.jsx)(xf,{owner:e}),(0,Q.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 truncate text-sm font-semibold`,children:[e.login,s?(0,Q.jsx)(qs,{className:`size-4 shrink-0 text-primary`,"aria-hidden":`true`}):null]}),e.personal?(0,Q.jsx)(`span`,{className:`text-label text-muted-foreground`,children:`Personal account`}):e.description?(0,Q.jsx)(`span`,{className:`line-clamp-2 text-label text-muted-foreground`,children:e.description}):null]})]},e.login)})})]})}function yf({slot:e,checked:t,disabled:n,title:r,hint:i,onSelect:a}){return(0,Q.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,disabled:n,"data-slot":e,onClick:a,className:W(`grid gap-0.5 rounded-md border px-3 py-2 text-left outline-none transition-colors`,`focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50`,t?`border-primary bg-primary/5`:`border-border hover:bg-muted/50`),children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:r}),(0,Q.jsx)(`span`,{className:`text-label text-muted-foreground`,children:i})]})}function bf(){return(0,Q.jsxs)(`div`,{className:`grid gap-3`,"data-slot":`create-owners-loading`,"aria-hidden":`true`,children:[(0,Q.jsx)(`span`,{className:`eyebrow text-muted-foreground`,children:`Select organization`}),[0,1].map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-border px-3 py-2.5`,children:[(0,Q.jsx)(`span`,{className:`size-9 shrink-0 animate-pulse rounded-full bg-muted`}),(0,Q.jsx)(`span`,{className:`h-3 w-24 animate-pulse rounded bg-muted`})]},e))]})}function xf({owner:e}){let[t,n]=(0,Z.useState)(!1),r=e.personal?`rounded-full`:`rounded-md`;return e.avatarUrl&&!t?(0,Q.jsx)(`img`,{src:e.avatarUrl,alt:``,width:36,height:36,loading:`lazy`,onError:()=>n(!0),"data-slot":`create-owner-avatar`,className:W(`size-9 shrink-0 bg-muted`,r)}):(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:W(`flex size-9 shrink-0 items-center justify-center bg-muted text-sm font-semibold text-muted-foreground uppercase`,r),children:e.login.slice(0,1)})}var Sf=class extends Z.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e){console.error(`[cezar] ${this.props.label} failed to render`,e),Y(`${this.props.label} failed to open: ${e instanceof Error?e.message:String(e)}`,{tone:`danger`}),this.props.onError()}render(){return this.state.failed?null:this.props.children}};function Cf(e){return(0,Q.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,...e,children:(0,Q.jsx)(`path`,{d:`M12 1.9a10.1 10.1 0 0 0-3.2 19.7c.5.1.7-.2.7-.5v-1.8c-2.8.6-3.4-1.2-3.4-1.2-.5-1.2-1.1-1.5-1.1-1.5-.9-.6.1-.6.1-.6 1 .1 1.5 1 1.5 1 .9 1.6 2.4 1.1 3 .9.1-.7.4-1.1.6-1.4-2.2-.3-4.6-1.1-4.6-5 0-1.1.4-2 1-2.7-.1-.3-.4-1.3.1-2.7 0 0 .9-.3 2.8 1a9.6 9.6 0 0 1 5 0c1.9-1.3 2.8-1 2.8-1 .5 1.4.2 2.4.1 2.7.6.7 1 1.6 1 2.7 0 3.9-2.4 4.7-4.6 5 .4.3.7.9.7 1.9v2.8c0 .3.2.6.7.5A10.1 10.1 0 0 0 12 1.9z`})})}var wf=[{to:`/`,label:`Tasks`,icon:Bl,match:[`/`,`/tasks`,`/compare`],badge:`tasks-unread`},{to:`/inbox`,label:`Inbox`,icon:Il,match:[`/inbox`],badge:`inbox-count`,inbox:!0},{to:`/git`,label:`Git`,icon:cc,match:[`/git`]},{to:`/github`,label:`GitHub`,icon:Cf,match:[`/github`],forge:!0},{to:`/tracker`,label:`Tracker`,icon:su,match:[`/tracker`],tracker:!0},{to:`/assets`,label:`Assets`,icon:ys,match:[`/assets`]},{to:`/automations`,label:`Automations`,icon:Uo,match:[`/automations`],automations:!0},{to:`/skills`,label:`Skills`,icon:Ko,match:[`/skills`],badge:`skills-update`},{to:`/workflows`,label:`Workflows`,icon:mc,match:[`/workflows`]},{to:`/settings`,label:`Settings`,icon:tu,match:[`/settings`]}];function Tf({forge:e=!1,inbox:t=!1,automations:n=!1,tracker:r}={}){return wf.filter(i=>(!i.forge||e)&&(!i.inbox||t)&&(!i.automations||n)&&(!i.tracker||r!==void 0)).map(e=>e.tracker?{...e,label:r?uu[r].label:e.label}:e)}function Ef(e,t){return t===`/`?e===`/`:e===t||e.startsWith(t+`/`)}function Df(e){let t=null;for(let n of wf)for(let r of n.match)Ef(e,r)&&(t===null||r.length>t.length)&&(t={to:n.to,length:r.length});return t?.to??null}function Of(e){let t=Df(e);return wf.find(e=>e.to===t)??null}var kf=`cez-theme`,Af=`(prefers-color-scheme: light)`,jf=`dark`;function Mf(e){return e===`light`||e===`dark`||e===`system`?e:jf}function Nf(e,t){return e===`light`||e===`system`&&t?`light`:`dark`}function Pf(){try{return Mf(localStorage.getItem(kf))}catch{return jf}}function Ff(e){try{localStorage.setItem(kf,e)}catch{}}function If(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(Af).matches}function Lf(e,t){e.classList.toggle(`light`,t===`light`),e.style.colorScheme=t}var Rf=Z.createContext(null);function zf({children:e}){let[t,n]=Z.useState(Pf),[r,i]=Z.useState(If);Z.useEffect(()=>{let e=window.matchMedia?.(Af);if(!e)return;i(e.matches);let t=e=>i(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let a=Nf(t,r);Z.useLayoutEffect(()=>{Lf(document.documentElement,a)},[a]);let o=Z.useCallback(e=>{n(e),Ff(e)},[]),s=Z.useMemo(()=>({theme:t,resolvedTheme:a,setTheme:o}),[t,a,o]);return(0,Q.jsx)(Rf.Provider,{value:s,children:e})}function Bf(){return Z.useContext(Rf)?.resolvedTheme??Nf(Pf(),If())}function Vf(){let e=Z.useContext(Rf);if(!e)throw Error(`cezar: useTheme() must be called inside <ThemeProvider>`);return e}var Hf={light:`dark`,dark:`system`,system:`light`},Uf={light:ou,dark:Kl,system:Gl},Wf={light:`light`,dark:`dark`,system:`system`};function Gf({className:e}){let{theme:t,setTheme:n}=Vf(),r=Hf[t],i=Uf[t];return(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,className:e,"data-slot":`theme-toggle`,"data-theme-pref":t,title:`Theme: ${Wf[t]}`,"aria-label":`Theme: ${Wf[t]}. Switch to ${Wf[r]}.`,onClick:()=>n(r),children:(0,Q.jsx)(i,{"aria-hidden":`true`})})}function Kf(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 qf(e){return[...e].sort((e,t)=>t.lastOpenedAt.localeCompare(e.lastOpenedAt))}function Jf(e,t){let n=Kf(t);if(n.length===0)return qf(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)),[...qf(a),...i]}function Yf(e,t,n){return t===n||t<0||n<0||t>=e.length||n>=e.length?[...e]:xi([...e],t,n)}var Xf=`regular`,Zf=[{value:`regular`,label:`Regular`},{value:`automation`,label:`Automations`},{value:`all`,label:`All`}],Qf=`cez-task-origin`;function $f(e){if(!e.deferredBinding)return e.automationId??e.automation?.automationId??e.automationTrigger?.automationId??e.automationTracker?.automationId}function ep(e,t){let n=$f(e);if(n!==void 0)return n;let r=e.dispatch?.rootRunId;if(r===void 0||r===e.id)return;let i=t(r);return i===void 0?void 0:$f(i)}function tp(e,t){return t===`all`?!0:t===`automation`?e!==void 0:e===void 0}function np(e){return e===`regular`||e===`automation`||e===`all`?e:Xf}function rp(){try{return np(localStorage.getItem(Qf))}catch{return Xf}}var ip=new Set,ap;function op(e){try{localStorage.setItem(Qf,e)}catch{ap=e}for(let e of ip)e()}function sp(){return ap??rp()}function cp(e){ip.add(e);let t=t=>{(t.key===null||t.key===`cez-task-origin`)&&e()};return window.addEventListener(`storage`,t),()=>{ip.delete(e),window.removeEventListener(`storage`,t)}}function lp(){return[Z.useSyncExternalStore(cp,sp,()=>Xf),op]}var up=`cezar:open-task-palette`;function dp(e){window.dispatchEvent(new CustomEvent(up,{detail:e}))}function fp(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function pp(){let e=U(),t=ht(),n=Z.useRef(0),r=Z.useRef(Promise.resolve()),i=Z.useMemo(()=>Kf(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}=fp(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 Pt({sidebar:s},{keepalive:!0});c===n.current&&e.setQueryData(B.uiState,t)});r.current=l.catch(t=>{Y(t instanceof Error?t.message:String(t),{tone:`danger`}),c===n.current&&e.invalidateQueries({queryKey:B.uiState})})},[e]),o=Z.useCallback(e=>{let t=Kf(e);t.length!==0&&a(t.slice(0,200))},[a]),s=Z.useCallback(()=>a(null),[a]);return{order:i,canReorder:t.data!==void 0,setOrder:o,reset:s}}var mp=`cezar:open-command-palette`;function hp(){window.dispatchEvent(new Event(mp))}function gp(e){return[...e].sort((e,t)=>Date.parse(t.createdAt)-Date.parse(e.createdAt))}function _p(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,t]of a.entries()){let n=e=>e!==void 0&&/^#?\d+$/.test(e),r=n(t)||/^(pr|issue)$/.test(t)&&n(a[e+1]),s=0;for(let e=i.indexOf(t);e!==-1;e=i.indexOf(t,e+1)){let n=e===0||!/[a-z0-9]/.test(i[e-1]??``),a=!/[a-z0-9]/.test(i[e+t.length]??``);s=Math.max(s,r&&n&&a?1:(n?1:.5)*(a?1:.8)/(1+e/48))}if(s===0)return 0;o+=s}return o/a.length}var vp=e=>({pullRequestUrl:e.pullRequestUrl,referencedPullRequestUrl:e.referencedPullRequestUrl,referencedPrCandidates:e.referencedPrCandidates,prNumber:e.prNumber,prRefs:e.prRefs,issueNumber:e.issueNumber,referencedIssueUrl:e.referencedIssueUrl,referencedIssueCandidates:e.referencedIssueCandidates,markerRefs:e.markerRefs});function yp(e,t,n){let r=gp(e).map(e=>({projectId:t,id:e.id,title:e.title,titleSummary:e.titleSummary,titleOrigin:e.titleOrigin,status:e.status,activity:e.activity,createdAt:e.createdAt,finishedAt:e.finishedAt,seenAt:e.seenAt,archived:e.archived,autoResumeAt:e.autoResumeAt,awaitingAnswerSince:e.awaitingAnswerSince,idleClosedAt:e.idleClosedAt,workflow:e.workflow,branch:e.branch,startedAt:e.startedAt,lastActivityAt:p(e),...jp(vp(e)),...jp({automationId:$f(e),dispatch:e.dispatch&&{rootRunId:e.dispatch.rootRunId,parentRunId:e.dispatch.parentRunId,kind:e.dispatch.kind}})})),i=new Set(r.map(Mp)),a=(n??[]).filter(e=>!i.has(Mp(e))).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),o=[...r,...a],s=new Map(o.map(e=>[e.id,e]));return o.map(e=>{if(e.automationId!==void 0)return e;let t=ep(e,e=>s.get(e));return t===void 0?e:{...e,automationId:t}})}var bp=`w-12 text-right`;function xp({label:e}){return(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,Q.jsxs)(`span`,{"aria-hidden":`true`,className:`flex shrink-0 gap-1 text-meta font-normal`,children:[(0,Q.jsx)(`span`,{className:W(bp,`after:content-['Updated']`)}),(0,Q.jsx)(`span`,{className:W(bp,`after:content-['Created']`)})]})]})}function Sp(e){return e.status===`running`&&e.activity!==`monitoring`}function Cp(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:Tp().format(t)}var wp,Tp=()=>wp??=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`});function Ep(e,t,n=new Map){return e.map(e=>{let r=Ve(e),i=ce(e,e.projectId===null?void 0:n.get(e.projectId)),a=i.map(e=>`${e.kind} #${e.number}`).join(` `),o=e.projectId===null?null:t.get(e.projectId)??null;return{task:e,key:Mp(e),label:r,references:a,refList:i,value:`task ${r} ${a} ${e.id}`,keywords:[...o?[o]:[],...e.automationId?[`automation`,`automatic`]:[]],projectName:o,title:`${Sp(e)?`Working now`:`Updated ${Cp(e.lastActivityAt)}`} · created ${Cp(e.createdAt)}`}})}function Dp(e,t,n=50){if(t.trim()===``)return{shown:e.slice(0,n),total:e.length};let r=[];return e.forEach((e,n)=>{let i=_p(e.value,t,e.keywords);i>0&&r.push({entry:e,score:i,index:n})}),r.sort((e,t)=>t.score-e.score||e.index-t.index),{shown:r.slice(0,n).map(e=>e.entry),total:r.length}}function Op({entries:e,children:t}){let n=Lt(),r=Z.useMemo(()=>e.flatMap(e=>e.refList.map(t=>({projectId:e.task.projectId??n??``,kind:t.kind,number:t.number}))).filter(e=>e.projectId!==``),[e,n]),i=r.map(e=>`${e.projectId} ${e.kind}#${e.number}`).join(`|`),a=Z.useRef(r);a.current=r;let[o,s]=Z.useState(r);return Z.useEffect(()=>{let e=setTimeout(()=>s(a.current),250);return()=>clearTimeout(e)},[i]),(0,Q.jsx)(Ur,{projectId:n,requests:o,children:t})}var kp=`[&_[cmdk-group-items]]:flex [&_[cmdk-group-items]]:flex-col`;function Ap({hidden:e}){return e<=0?null:(0,Q.jsxs)(Bi,{forceMount:!0,disabled:!0,value:`__more-tasks`,"data-slot":`palette-more-tasks`,className:`order-last py-1.5! text-xs text-soft-foreground data-[disabled=true]:opacity-100`,children:[e,` more — keep typing to narrow`]})}function jp(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}var Mp=e=>`${e.projectId??``}/${e.id}`;function Np(e){let t=e.filter(e=>$o(e)).sort((e,t)=>(t.finishedAt??``).localeCompare(e.finishedAt??``)),n=new Set(t.map(Mp));return{recentlyFinished:t,otherTasks:e.filter(e=>!n.has(Mp(e)))}}function Pp(e,t,n=[]){let r=Jf(e,n);return[...r.filter(e=>e.id!==t),...r.filter(e=>e.id===t)]}function Fp(){let e=kr(),t=a(),n=C(),r=t.data,i=r?.bootProject??n.data?.bootProject??null,o=se(e,i),s=r!==void 0&&r.projects.length>1,c=Se(s),l=c.data?.referenceStatuses;Z.useEffect(()=>{l&&Nt(l)},[l]);let u=Z.useMemo(()=>new Map((r?.projects??[]).map(e=>[e.id,e.name])),[r]),d=(e==="default"?null:e)??i,f=Z.useMemo(()=>yp(o.data??[],d,c.data?.runs),[o.data,d,c.data]),p=We();return{activeProjectId:e,registry:r,health:n,multiProject:s,projectNames:u,repoBases:Z.useMemo(()=>{let e=new Map;for(let t of r?.projects??[])t.repoUrl&&e.set(t.id,t.repoUrl);return d&&p&&!e.has(d)&&e.set(d,p),e},[r,d,p]),runsProjectId:d,tasks:f}}function Ip(e,t=``){let n=`/tasks/${e.id}${t}`;return e.projectId===null?n:_r(e.projectId,n)}var Lp=`cezar:palette-opened`;function Rp(e){window.dispatchEvent(new CustomEvent(Lp,{detail:e}))}function zp(e,t,n){Z.useEffect(()=>{t&&Rp(e)},[t,e]),Z.useEffect(()=>{let t=t=>{t.detail!==e&&n()};return window.addEventListener(Lp,t),()=>window.removeEventListener(Lp,t)},[e,n])}function Bp(){let[e,t]=Z.useState(!1),n=vr();Fo(`k`,()=>t(e=>!e));let r=Z.useCallback(()=>{t(!1),n(`/new`)},[n]);Fo(`n`,r),go(`c`,r),Z.useEffect(()=>{let e=()=>t(!0);return window.addEventListener(mp,e),()=>window.removeEventListener(mp,e)},[]);let i=Z.useCallback(()=>t(!1),[]);return zp(`command`,e,i),Z.useEffect(()=>{e&&Ls(`command`)},[e]),(0,Q.jsx)(Ii,{open:e,onOpenChange:e=>{e||ts(`command`),t(e)},title:`Command palette`,description:`Search projects, tasks, views, actions, and skills`,showCloseButton:!1,filter:_p,commandProps:{onKeyDown:Z.useCallback(e=>{if(e.key!==`Tab`||e.shiftKey||e.altKey||e.metaKey||e.ctrlKey)return;let n=e.currentTarget.querySelector(`[cmdk-item][data-selected="true"][data-slot="palette-task"]`),r=n?.dataset.runId;r&&(e.preventDefault(),Xo(`cmdk_tab`),t(!1),dp({runId:r,projectId:n.dataset.projectId??null}))},[])},className:`top-[10vh] translate-y-0 sm:max-w-2xl lg:max-w-3xl xl:max-w-4xl`,children:(0,Q.jsx)(Hp,{close:i})})}var Vp=Z.memo(function({entry:e,showProject:t,now:n,onSelect:r,slot:i=`palette-task`,current:a=!1}){let{task:s,label:c,projectName:l}=e,u=o(s),d=s.projectId?e.refList[0]:void 0;return(0,Q.jsxs)(Bi,{value:e.value,keywords:e.keywords,"data-slot":i,"data-run-id":s.id,"data-project-id":s.projectId??void 0,onSelect:()=>r(s),children:[(0,Q.jsx)(Jc,{tone:u.tone,pulse:u.pulse,"aria-label":u.label,role:`img`}),d&&s.projectId?(0,Q.jsx)(`span`,{"data-slot":`palette-task-refs`,className:`flex shrink-0 items-center gap-1 [&_svg]:size-3!`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,Q.jsx)(Ca,{run:s,projectId:s.projectId,reference:d,compact:!0,className:`h-auto shrink-0 gap-[2px] px-1.5 py-px text-micro`})}):null,(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:c,children:Ne(c,d?.number)?qe(c).rest:c}),s.automationId?(0,Q.jsxs)(`span`,{"data-slot":`palette-task-automation`,title:`Started by an automation`,className:`flex shrink-0 items-center gap-0.5 text-xs text-soft-foreground`,children:[(0,Q.jsx)(Uo,{"aria-hidden":`true`,className:`size-3!`}),`auto`]}):null,t&&l?(0,Q.jsx)(`span`,{"data-slot":`palette-task-project`,className:`shrink-0 truncate text-xs text-soft-foreground`,children:l}):null,a?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-primary`,children:`open`}):null,(0,Q.jsxs)(`span`,{"data-slot":`palette-task-age`,title:e.title,className:`flex shrink-0 gap-1 text-xs tabular-nums`,children:[(0,Q.jsx)(`span`,{"data-slot":`palette-task-updated`,className:W(bp,`text-muted-foreground`),children:Sp(s)?`now`:Xc(s.lastActivityAt,n)}),(0,Q.jsx)(`span`,{"data-slot":`palette-task-created`,className:W(bp,`text-soft-foreground`),children:Xc(s.createdAt,n)})]})]})});function Hp({close:e}){let t=vr(),n=Nr(),[r,i]=Z.useState(``),a=r.trim()!==``,o=Z.useRef(new Set);Z.useEffect(()=>{for(let e of As(r))o.current.add(e)},[r]),Z.useEffect(()=>()=>Ms(o.current),[]);let{theme:s,setTheme:c}=Vf(),{activeProjectId:l,registry:u,health:d,multiProject:f,projectNames:p,repoBases:m,tasks:h}=Fp(),g=sc(),_=ie(),v=Ft(),[y]=Z.useState(Date.now),{order:b}=pp(),x=Z.useMemo(()=>f&&u?Pp(u.projects,l,b):[],[f,u,l,b]),S=Z.useMemo(()=>{let{recentlyFinished:e,otherTasks:t}=Np(h);return{all:Ep(h,p,m),recentlyFinished:Ep(e,p,m),otherTasks:Ep(t,p,m)}},[h,p,m]),C=a?{shown:[],total:0}:Dp(S.recentlyFinished,``,20),w=Dp(a?S.all:S.otherTasks,r),T=f,E=v.data?.skillUsage,D=Z.useMemo(()=>fo(_.data??[],E),[_.data,E]),O=n=>{e(),t(n)},k=t=>{e(),n(t)},A=n=>{e(),t(_r(n,`/`))},j=Z.useCallback(n=>{Xo(`cmdk`),e(),t(Ip(n))},[e,t]),M=Hf[s];return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Mi,{placeholder:`Search projects, tasks, views, actions, skills…`,value:r,onValueChange:i}),(0,Q.jsxs)(Li,{className:`max-h-[55vh] min-h-[14rem] sm:max-h-[60vh] lg:max-h-[68vh]`,children:[(0,Q.jsx)(Wi,{children:`Nothing matches.`}),(0,Q.jsx)(ji,{children:(0,Q.jsxs)(Bi,{value:`new task`,"data-slot":`palette-view`,"data-nav-to":`/new`,onSelect:()=>O(`/new`),children:[(0,Q.jsx)(xc,{"aria-hidden":`true`}),`New task`,(0,Q.jsx)(Ni,{children:`C`})]})}),(0,Q.jsxs)(Op,{entries:[...C.shown,...w.shown],children:[!a&&C.shown.length>0?(0,Q.jsxs)(ji,{heading:(0,Q.jsx)(xp,{label:`Recently finished`}),className:kp,children:[C.shown.map(e=>(0,Q.jsx)(Vp,{entry:e,showProject:T,now:y,onSelect:j},e.key)),(0,Q.jsx)(Ap,{hidden:C.total-C.shown.length})]}):null,(0,Q.jsxs)(ji,{heading:`Views`,children:[f?(0,Q.jsxs)(Bi,{value:`view All tasks`,"data-slot":`palette-view`,"data-nav-to":`/tasks`,onSelect:()=>k(`/tasks`),children:[(0,Q.jsx)(ys,{"aria-hidden":`true`}),`All tasks`]}):null,Tf({forge:g!=null,inbox:d.data?.capabilities.followups===!0,automations:d.data?.capabilities.automations===!0,tracker:u?.projects.find(e=>e.id===(l??u.bootProject))?.tracker}).map(e=>{let t=e.icon;return(0,Q.jsxs)(Bi,{value:`view ${e.label}`,"data-slot":`palette-view`,"data-nav-to":e.to,onSelect:()=>O(e.to),children:[(0,Q.jsx)(t,{"aria-hidden":`true`}),e.label]},e.to)}),(0,Q.jsxs)(Bi,{value:`view global settings`,"data-slot":`palette-view`,"data-nav-to":`/settings/global`,onSelect:()=>k(`/settings/global`),children:[(0,Q.jsx)(tu,{"aria-hidden":`true`}),`Global settings`]})]}),x.length>0?(0,Q.jsx)(ji,{heading:`Projects`,children:x.map(e=>{let t=e.id===l,n=e.status===`missing`;return(0,Q.jsxs)(Bi,{value:`project ${e.name} ${e.id}`,keywords:[e.root],"data-slot":`palette-project`,"data-project-id":e.id,disabled:n,onSelect:()=>A(e.id),children:[(0,Q.jsx)(kl,{"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)(Rs,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},e.id)})}):null,w.shown.length>0?(0,Q.jsxs)(ji,{heading:(0,Q.jsx)(xp,{label:`Tasks`}),className:kp,children:[w.shown.map(e=>(0,Q.jsx)(Vp,{entry:e,showProject:T,now:y,onSelect:j},e.key)),(0,Q.jsx)(Ap,{hidden:w.total-w.shown.length})]}):null]}),(0,Q.jsx)(ji,{heading:`Actions`,children:(0,Q.jsxs)(Bi,{value:`action toggle theme`,"data-slot":`palette-action`,"data-action":`toggle-theme`,onSelect:()=>{c(M),e()},children:[(0,Q.jsx)(Kl,{"aria-hidden":`true`}),`Toggle theme`,(0,Q.jsxs)(Ni,{className:`tracking-normal`,children:[s,` → `,M]})]})}),D.length>0?(0,Q.jsx)(ji,{heading:`Skills`,children:D.map(e=>(0,Q.jsxs)(Bi,{value:`skill ${e.name} ${e.path}`,keywords:e.description?[e.description]:void 0,"data-slot":`palette-skill`,"data-skill":e.name,onSelect:()=>O(`/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))}):null]})]})}function Up({className:e}){return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`command-palette-hint`,title:`Search — command palette (⌘K / Ctrl+K)`,onClick:()=>hp(),className:W(`flex w-full items-center gap-1.5 rounded-md border border-border bg-muted/30 px-2 py-1 text-left text-xs font-medium text-soft-foreground transition-colors hover:bg-muted hover:text-foreground`,e),children:[(0,Q.jsx)(Cc,{className:`size-3.5 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 rounded-[5px] border border-b-2 border-border bg-card px-[5px] py-px font-mono text-micro font-medium text-muted-foreground`,children:ho(`k`)})]})}function Wp(e){let t=Er(e);return t===`/settings`||t.startsWith(`/settings/`)}var Gp=`https://github.com/open-mercato/cezar`,Kp=`cez:star-toast-seen`;function qp(e){if(!Number.isFinite(e)||e<0)return`0`;let t=Math.floor(e);if(t<1e3)return String(t);let n=t/1e3,r=Math.floor(n*10)/10;return r<100?`${r.toFixed(1).replace(/\.0$/,``)}k`:`${Math.floor(n)}k`}var Jp=`cez:star-ask`,Yp=1500;function Xp(e=tm()){if(!e)return null;try{let t=e.getItem(Jp);if(t!==null){let e=JSON.parse(t);return{asks:Number.isInteger(e.asks)&&e.asks>=0?e.asks:3,...typeof e.lastAskedAt==`string`?{lastAskedAt:e.lastAskedAt}:{},...e.outcome===`starred`||e.outcome===`never`?{outcome:e.outcome}:{}}}let n=e.getItem(Kp);return n===null?{asks:0}:{asks:1,lastAskedAt:n}}catch{return null}}function Zp(e,t=tm()){try{t?.setItem(Jp,JSON.stringify(e))}catch{}}function Qp(e,t){if(!e||e.outcome||e.asks>=3)return!1;if(!e.lastAskedAt)return!0;let n=Date.parse(e.lastAskedAt);return!Number.isFinite(n)||t-n>=12096e5}function $p(e){return(e??[]).filter(e=>nm.has(e.status)).length}function em(e){return e.visible&&e.focused&&!e.typing&&!e.dialogOpen&&e.now-e.lastInteractionAt>=0&&e.now-e.lastInteractionAt<=6e4}function tm(){try{return globalThis.localStorage??null}catch{return null}}var nm=new Set([`done`,`review`]);function rm(e,t){let n=new Map,r=!1,i=!1;for(let a of t??[]){n.set(a.id,a.status);let t=e.get(a.id);t===void 0||t===a.status||nm.has(a.status)&&(r=!0,a.pullRequestUrl&&(i=!0))}return{succeeded:r,withPullRequest:i,statuses:n}}var im=[`354.6,217.3 511.0,307.6 421.0,359.6 354.6,321.2 267.9,371.2 267.9,471.3 444.6,573.3 354.6,625.3 177.9,523.3 177.9,319.3`,`177.9,284.6 354.6,182.6 354.6,78.7 177.9,180.7`,`354.6,372.3 397.0,396.8 397.0,445.8 354.6,470.3 312.1,445.8 312.1,396.8`,`483.7,372.3 526.1,396.8 526.1,445.8 483.7,470.3 441.2,445.8 441.2,396.8`],am={x:177.9,y:78.7,width:348.2,height:546.6},om={mark:26,name:19,gap:11.4};function sm({height:e=om.mark,className:t}){return(0,Q.jsx)(`svg`,{"data-slot":`brand-mark`,"aria-hidden":`true`,focusable:`false`,viewBox:`${am.x} ${am.y} ${am.width} ${am.height}`,height:e,width:e*am.width/am.height,fill:`currentColor`,className:W(`shrink-0`,t),children:im.map(e=>(0,Q.jsx)(`polygon`,{points:e},e))})}function cm({className:e,name:t=`cezar`,logoUrl:n=null}){return(0,Q.jsxs)(`span`,{"data-slot":`brand-lockup`,className:W(`flex min-w-0 items-center text-foreground`,e),style:{gap:om.gap},children:[n?(0,Q.jsx)(`img`,{"data-slot":`brand-logo`,src:n,alt:``,className:`size-[26px] shrink-0 object-contain`}):(0,Q.jsx)(sm,{}),(0,Q.jsx)(`span`,{"data-slot":`brand-name`,className:W(`max-w-full truncate leading-none font-semibold tracking-normal`,t===`cezar`&&`lowercase`),style:{fontFamily:`var(--brand)`,fontSize:om.name},children:t})]})}function lm({...e}){return(0,Q.jsx)(Nu,{"data-slot":`select`,...e})}function um({...e}){return(0,Q.jsx)(Lu,{"data-slot":`select-value`,...e})}function dm({className:e,size:t=`default`,children:n,...r}){return(0,Q.jsxs)(Fu,{"data-slot":`select-trigger`,"data-size":t,className:W(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-card px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none 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-9 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 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)(zu,{asChild:!0,children:(0,Q.jsx)(Ws,{className:`size-4 opacity-50`})})]})}function fm({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,Q.jsx)(Uu,{children:(0,Q.jsxs)(Gu,{"data-slot":`select-content`,className:W(`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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 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)(mm,{}),(0,Q.jsx)(od,{className:W(`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)(hm,{})]})})}function pm({className:e,children:t,...n}){return(0,Q.jsxs)(gd,{"data-slot":`select-item`,className:W(`relative flex w-full cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-8 pl-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 right-2 flex size-3.5 items-center justify-center`,children:(0,Q.jsx)(bd,{children:(0,Q.jsx)(Rs,{className:`size-4`})})}),(0,Q.jsx)(vd,{children:t})]})}function mm({className:e,...t}){return(0,Q.jsx)(Sd,{"data-slot":`select-scroll-up-button`,className:W(`flex cursor-pointer items-center justify-center py-1`,e),...t,children:(0,Q.jsx)(vl,{className:`size-4`})})}function hm({className:e,...t}){return(0,Q.jsx)(wd,{"data-slot":`select-scroll-down-button`,className:W(`flex cursor-pointer items-center justify-center py-1`,e),...t,children:(0,Q.jsx)(Ws,{className:`size-4`})})}function gm(e){return/^\d/.test(e)&&!e.includes(`+`)?`v${e}`:e}function _m(e,t){return!!t&&e.activeRuns>0&&e.scheduled?.target!==t}function vm({label:e=`Update when idle`,doing:t,onClick:n,disabled:r}){return(0,Q.jsx)(kc,{delayDuration:300,children:(0,Q.jsxs)(Ac,{children:[(0,Q.jsx)(Dc,{asChild:!0,children:(0,Q.jsx)(J,{variant:`outline`,size:`sm`,onClick:n,disabled:r,children:e})}),(0,Q.jsxs)(Oc,{"data-slot":`update-when-idle-tooltip`,side:`bottom`,className:`max-w-64`,children:[`Waits until no task is running or queued, then `,t,` and restarts. Tasks waiting on your reply don't hold it up. You can close this window and keep working.`]})]})})}function ym(e){let t=/-pr(\d+)\./.exec(e);return t?Number(t[1]):null}function bm({data:e,onApply:t,onSchedule:n,applying:r}){let i=Pe(),a=ft(),[o,s]=(0,Z.useState)(`worktrees`),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(!1),m=e.job?.status===`running`||e.job?.status===`restarting`,h=e.installed.find(e=>e.active),g=i.data?.checkouts??[],_=i.data?.pulls,v=!i.data||g.length>0,y=v?o:`pulls`,b=c.trim().toLowerCase(),x=(0,Z.useMemo)(()=>g.filter(e=>!b||[e.branch,e.task?.title,e.task?.id,e.commit?.subject,e.worktree,e.pr?`#${e.pr}`:``].filter(Boolean).some(e=>e.toLowerCase().includes(b))),[g,b]),S=(0,Z.useMemo)(()=>(_?.items??[]).filter(e=>!e.version&&!f?!1:!b||[`#${e.number}`,String(e.number),e.title,e.branch,e.author??``].some(e=>e.toLowerCase().includes(b))),[_,b,f]),C=(_?.items??[]).filter(e=>!e.version).length,w=y===`worktrees`?g.find(e=>e.id===u):void 0,T=y===`pulls`?_?.items.find(e=>e.version&&e.version===u):void 0,E=w?.id??T?.version??null,D=!!w&&(!w.built||w.stale),O=!!E&&E===h?.id&&!D,k=T&&!T.installed?`Install & restart`:D?`${w.built?`Rebuild`:`Build`} & ${w.id===h?.id?`restart`:`switch`}`:`Switch & restart`;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)(`div`,{role:`tablist`,"aria-label":`Development builds`,className:`flex rounded-md border border-border bg-muted/40 p-0.5`,children:[...v?[{value:`worktrees`,label:`Worktrees`,count:g.length}]:[],{value:`pulls`,label:`Pull requests`,count:(_?.items.length??0)-C}].map(e=>(0,Q.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":y===e.value,onClick:()=>{s(e.value),d(null)},className:W(`rounded-[5px] px-3 py-1 text-label font-semibold transition-colors`,y===e.value?`bg-card text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:[e.label,i.data?(0,Q.jsx)(`span`,{className:`ml-1.5 font-normal text-muted-foreground`,children:e.count}):null]},e.value))}),(0,Q.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>a.mutate(),disabled:a.isPending||i.isFetching,children:a.isPending?`Refreshing…`:`Refresh`})]}),(0,Q.jsx)(Kc,{"aria-label":`Filter`,value:c,onChange:e=>l(e.target.value),placeholder:y===`worktrees`?`Filter by task, branch, commit or #PR`:`Filter by #number, title, branch or author`,className:`h-8 text-ui`}),(0,Q.jsx)(`div`,{className:`max-h-72 min-h-24 overflow-y-auto rounded-md border border-border`,children:i.isPending?(0,Q.jsx)(`p`,{className:`px-3 py-3 text-label text-muted-foreground`,children:`Looking for worktrees and pull requests…`}):i.error?(0,Q.jsx)(`p`,{className:`px-3 py-3 text-label text-danger`,children:i.error.message}):y===`worktrees`?(0,Q.jsxs)(Q.Fragment,{children:[x.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-3 text-label text-muted-foreground`,children:`Nothing matches.`}):null,(0,Q.jsx)(`div`,{role:`listbox`,"aria-label":`Worktrees`,children:x.map(e=>(0,Q.jsx)(Sm,{checkout:e,active:e.id===h?.id,selected:u===e.id,onSelect:()=>d(e.id)},e.worktree))})]}):(0,Q.jsxs)(Q.Fragment,{children:[_&&!_.available?(0,Q.jsx)(`p`,{className:`px-3 py-2 text-label text-muted-foreground`,children:_.reason}):null,_?.available&&S.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-3 text-label text-muted-foreground`,children:_.items.length===0?`No open pull requests on ${_.repo}.`:b?`Nothing matches.`:`No open pull request has a preview build.`}):null,(0,Q.jsx)(`div`,{role:`listbox`,"aria-label":`Pull requests`,children:S.map(e=>(0,Q.jsx)(Cm,{pull:e,active:!!e.version&&e.version===h?.id,selected:!!e.version&&u===e.version,onSelect:()=>e.version&&d(e.version)},e.number))}),C>0?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>p(e=>!e),className:`w-full border-t border-border px-3 py-2 text-left text-label text-muted-foreground hover:text-foreground`,children:f?`Hide the ${C} without a preview build`:`${C} more without a preview build (forks, CI not green yet) — show`}):null]})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-meta text-muted-foreground`,title:w?.worktree,children:w?D?`${w.built?`Built before its last commit`:`Not built yet`} — runs npm run build in ${w.worktree} first (about a minute).`:w.worktree:T?`Installs ${T.version} from npm.`:y===`worktrees`?`Linked, not copied: a worktree that is not built, or built before its last commit, is built before the switch.`:`Preview builds CI publishes for green same-repo pull requests.`}),!O&&_m(e,E)?(0,Q.jsx)(vm,{label:`When idle`,doing:T?`${T.installed?`switches to`:`installs`} PR #${T.number}'s build`:`${D?`builds and switches to`:`switches to`} ${w.branch}`,onClick:()=>n(E),disabled:!e.canSelfUpdate||r||m}):null,(0,Q.jsx)(J,{size:`sm`,variant:`contrast`,onClick:()=>E&&t(E),disabled:!E||O||!e.canSelfUpdate||r||m,children:k})]})]})}function xm({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:W(`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-primary/10 hover:bg-primary/10`),children:i})}function Sm({checkout:e,active:t,selected:n,onSelect:r}){let i=e.task?.title??e.commit?.subject??e.branch;return(0,Q.jsxs)(xm,{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-ui font-medium`,children:i}),e.pr?(0,Q.jsxs)($d,{variant:`outline`,children:[`#`,e.pr]}):null,t?(0,Q.jsx)($d,{variant:`secondary`,children:`current`}):null,e.built?e.stale?(0,Q.jsx)($d,{variant:`outline`,children:`needs rebuild`}):null:(0,Q.jsx)($d,{variant:`outline`,children:`not built`})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-meta 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:``,` · `,Xc(e.commit.at),` ago`]}):null,e.builtAt?(0,Q.jsxs)(`span`,{className:`shrink-0`,children:[`· built `,Xc(e.builtAt),` ago`]}):null]})]})}function Cm({pull:e,active:t,selected:n,onSelect:r}){return(0,Q.jsxs)(xm,{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-ui text-muted-foreground`,children:[`#`,e.number]}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-ui font-medium`,children:e.title}),e.draft?(0,Q.jsx)($d,{variant:`outline`,children:`draft`}):null,t?(0,Q.jsx)($d,{variant:`secondary`,children:`current`}):e.version?e.installed?(0,Q.jsx)($d,{variant:`outline`,children:`installed`}):null:(0,Q.jsx)($d,{variant:`outline`,children:`no build`})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-meta 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 `,Xc(e.updatedAt),` ago`]}),e.version?(0,Q.jsxs)(`span`,{className:`shrink-0`,children:[`· build `,e.publishedAt?`${Xc(e.publishedAt)} ago`:e.version]}):null]})]})}function wm({open:e,onOpenChange:t,autoApply:n,brandName:r=`cezar`}){let i=j(e),a=yn(),o=k(),s=an(),c=m(),l=Dt(),[u,d]=(0,Z.useState)(``),f=i.data,p=(0,Z.useRef)(null),h=(0,Z.useRef)(!1);return(0,Z.useEffect)(()=>{!n||h.current||!f||!f.canSelfUpdate||f.job||(h.current=!0,!(f.activeRuns>0)&&s.mutate(n))},[n,f,s]),(0,Q.jsx)(qr,{open:e,onOpenChange:e=>{!e&&f?.job?.status===`running`||t(e)},children:(0,Q.jsxs)(Wr,{"data-slot":`self-update-dialog`,className:`sm:max-w-xl`,ref:p,onOpenAutoFocus:e=>{e.preventDefault(),p.current?.focus()},children:[(0,Q.jsxs)(Lr,{children:[(0,Q.jsxs)(Zr,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`span`,{children:[r,` `,f?`v${f.version}`:``]}),(0,Q.jsx)(Am,{data:f})]}),(0,Q.jsxs)(Vr,{className:`sr-only`,children:[`Update `,r,`, pick a release channel or switch versions.`]})]}),f?(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-5`,children:[(0,Q.jsx)(Dm,{data:f,busy:o.isPending,onChange:e=>{d(``),o.mutate(e)}}),(0,Q.jsx)(Om,{data:f,checking:a.isPending,onCheck:()=>a.mutate(),onApply:e=>s.mutate(e),onSchedule:e=>c.mutate(e),applying:s.isPending||c.isPending}),f.channel===`development`?(0,Q.jsx)(bm,{data:f,onApply:e=>s.mutate(e),onSchedule:e=>c.mutate(e),applying:s.isPending||c.isPending}):(0,Q.jsx)(km,{data:f,picked:u,onPick:d,onApply:e=>s.mutate(e),onSchedule:e=>c.mutate(e),applying:s.isPending||c.isPending}),f.canSelfUpdate?null:(0,Q.jsx)(jm,{data:f}),f.scheduled?(0,Q.jsxs)(`div`,{"data-slot":`self-update-scheduled`,className:`flex items-center justify-between gap-3 rounded-md border border-primary/40 bg-primary/5 px-3 py-2 text-label`,children:[(0,Q.jsxs)(`p`,{className:`min-w-0`,children:[r,` switches to `,(0,Q.jsx)(`span`,{className:`font-semibold`,children:gm(f.scheduled.target)}),` as soon as no task is running. You can close this window and keep working.`]}),(0,Q.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>l.mutate(),disabled:l.isPending,children:`Cancel`})]}):f.activeRuns>0&&f.canSelfUpdate?(0,Q.jsxs)(`p`,{className:`rounded-md border border-pending/50 bg-pending/10 px-3 py-2 text-label text-foreground`,children:[f.activeRuns,` task`,f.activeRuns===1?` is`:`s are`,` running. A restart interrupts them; `,r,` re-queues or resumes them on the way back up.`,` `,`The “when idle” buttons wait for them to finish instead.`]}):null,o.error?(0,Q.jsxs)(`p`,{className:`text-label text-danger`,children:[`Could not switch the channel: `,o.error.message,o.variables===`development`?` The running ${r} server predates the Development channel — restart ${r} to load it.`:null]}):null,s.error?(0,Q.jsx)(`p`,{className:`text-label text-danger`,children:s.error.message}):null,c.error?(0,Q.jsx)(`p`,{className:`text-label text-danger`,children:c.error.message}):null,l.error?(0,Q.jsx)(`p`,{className:`text-label text-danger`,children:l.error.message}):null,f.job?(0,Q.jsx)(Mm,{data:f}):null]}):i.error?(0,Q.jsx)(`p`,{className:`text-ui text-danger`,children:i.error.message}):null]})})}var Tm=[{value:`stable`,label:`Stable`},{value:`nightly`,label:`Nightly`},{value:`development`,label:`Development`}],Em={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 Dm({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-ui font-semibold`,children:`Release channel`}),(0,Q.jsx)(`div`,{className:`text-label text-muted-foreground`,children:Em[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:Tm.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:W(`rounded-[5px] px-3 py-1 text-label font-semibold transition-colors`,i?`bg-card text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:r.label},r.value)})})]})}function Om({data:e,checking:t,onCheck:n,onApply:r,onSchedule:i,applying:a}){let o=e.job?.status===`running`||e.job?.status===`restarting`,s=e.installed.find(e=>e.active),c=s?.source===`registry`?ym(s.version):null,l=s&&(s.source===`link`||s.source===`local`||c!==null)?s:null;if(l||e.channel===`development`){let i=e.channel===`development`?null:e.latest[e.channel],s=i!==null&&e.installed.some(e=>e.source===`registry`&&e.id===i);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-ui break-words`,children:l?.source===`link`?(0,Q.jsxs)(Q.Fragment,{children:[`Running worktree `,(0,Q.jsx)(`span`,{className:`font-mono text-label font-semibold`,children:l.branch??l.id}),`, not a release.`]}):l?.source===`local`?(0,Q.jsx)(Q.Fragment,{children:`Running a local build, not a release.`}):c===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 #`,c]}),`, not a release.`]})}),(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-meta break-words text-muted-foreground`,children:e.channel===`development`?`Switch the channel back to Stable or Nightly to follow releases again.`:e.checkedAt?(0,Q.jsxs)(Q.Fragment,{children:[i?(0,Q.jsxs)(Q.Fragment,{children:[`Newest `,e.channel,`: `,(0,Q.jsxs)(`span`,{className:`font-mono text-foreground`,children:[`v`,i]}),` ·`,` `]}):null,`checked `,new Date(e.checkedAt).toLocaleTimeString()]}):`The npm registry has not answered yet.`}),e.channel===`development`?null:(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,Q.jsx)(J,{variant:`ghost`,size:`sm`,onClick:n,disabled:t||o,children:t?`Checking…`:`Check again`}),i?(0,Q.jsx)(J,{size:`sm`,"aria-label":s?`Back to v${i}`:`Install v${i} & restart`,onClick:()=>r(i),disabled:!e.canSelfUpdate||a||o,children:s?`Switch back`:`Install & restart`}):null]})]})]})}let u=e.updateAvailable;return(0,Q.jsxs)(`div`,{"data-slot":`self-update-latest`,className:W(`flex flex-wrap items-center justify-between gap-x-3 gap-y-2 rounded-md border px-3 py-2.5`,u?`border-primary/40 bg-primary/5`:`border-border bg-card`),children:[(0,Q.jsxs)(`div`,{className:`min-w-[14rem] flex-1 text-ui break-words`,children:[e.checkedAt?u?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`font-semibold`,children:[`v`,u]}),` 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.`}),e.checkedAt?(0,Q.jsxs)(`div`,{className:`text-meta text-muted-foreground`,children:[`checked `,new Date(e.checkedAt).toLocaleTimeString()]}):null]}),(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,Q.jsx)(J,{variant:`ghost`,size:`sm`,onClick:n,disabled:t||o,children:t?`Checking…`:`Check again`}),_m(e,u)?(0,Q.jsx)(vm,{doing:`installs ${gm(u)}`,onClick:()=>i(u),disabled:!e.canSelfUpdate||a||o}):null,u?(0,Q.jsx)(J,{size:`sm`,onClick:()=>r(u),disabled:!e.canSelfUpdate||a||o,children:`Update & restart`}):null]})]})}function km({data:e,picked:t,onPick:n,onApply:r,onSchedule:i,applying:a}){let o=e.job?.status===`running`||e.job?.status===`restarting`,s=(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]),c=s.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-ui 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)(lm,{value:t,onValueChange:n,disabled:s.length===0||o,children:[(0,Q.jsx)(dm,{size:`sm`,"aria-label":`Version`,className:`w-0 min-w-0 flex-1 text-ui`,children:(0,Q.jsx)(um,{placeholder:s.length===0?`No versions known`:`Choose a version to install`})}),(0,Q.jsx)(fm,{className:`max-h-72`,children:s.map(e=>(0,Q.jsx)(pm,{value:e.value,children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e.label,e.active?(0,Q.jsx)($d,{variant:`secondary`,children:`current`}):e.installed?(0,Q.jsx)($d,{variant:`outline`,children:`installed`}):null]})},e.value))})]}),c&&!c.active&&_m(e,c.value)?(0,Q.jsx)(vm,{label:`When idle`,doing:`${c.installed?`switches to`:`installs`} ${gm(c.value)}`,onClick:()=>i(c.value),disabled:!e.canSelfUpdate||a||o}):null,(0,Q.jsx)(J,{size:`sm`,variant:`contrast`,onClick:()=>c&&r(c.value),disabled:!c||c.active||!e.canSelfUpdate||a||o,children:c?.installed?`Switch & restart`:`Install & restart`})]}),(0,Q.jsx)(`p`,{className:`text-meta text-muted-foreground`,children:`Any version, older ones included. Installed versions stay on disk, so switching back is instant.`})]})}function Am({data:e}){let t=e?.installed.find(e=>e.active);if(t?.source===`local`)return(0,Q.jsx)($d,{variant:`outline`,children:`local build`});if(t?.source===`link`)return(0,Q.jsxs)($d,{variant:`outline`,children:[`worktree · `,t.branch??t.id]});let n=t?ym(t.version):null;return n===null?null:(0,Q.jsxs)($d,{variant:`outline`,children:[`PR #`,n,` build`]})}function jm({data:e}){let t=e.installKind===`checkout`?`node packages/cezar/dist/index.js install`:e.installKind===`global-npm`?`cezar install`:`npx cezar-cli 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-label`,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-label`,children:t})]})}function Mm({data:e}){let t=e.job,n=U(),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:B.selfUpdate}),window.setTimeout(()=>window.location.reload(),400)},s=async()=>{if(!r){try{if((await en()).version!==e.version)return o();let t=await Pn().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-label`,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-meta leading-[1.5] break-all whitespace-pre-wrap text-muted-foreground`,children:t.log.join(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/terminal-pane-CRjYeI78.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-runtime-CCIEwYL0.js","assets/queries-DbDUaheq.js","assets/utils-Bl_tQdVw.js","assets/bundle-mjs-rHxsej31.js","assets/preload-helper-Czpn1I53.js","assets/host-usage-BeX2ZFmV.js","assets/use-desktop-BNN3U2y9.js","assets/clipboard-DvCUPLwM.js","assets/terminal-pane-BrP-ENHg.css","assets/dashboard-CPnDqmbf.js","assets/project-router-ByYpf5zi.js","assets/use-now-CdtIyF-0.js","assets/button-jcXhXi-5.js","assets/dist-C2IyLYZs.js","assets/circle-check-C09e7mFj.js","assets/git-pull-request-BAfSEvVb.js","assets/git-pull-request-draft-BIgZJsu-.js","assets/triangle-alert-CBrg6nYB.js","assets/x-Qhn_uE86.js","assets/token-metrics-BINGXGrg.js","assets/facet-filter-Be0XFoHu.js","assets/sheet-DJ7Q8rRA.js","assets/search-P545ZVzc.js","assets/check-CNVywZ6B.js","assets/toaster-CejrnYvv.js","assets/automation-format-MLNn8qnY.js","assets/chevron-right-D2EqYt_O.js","assets/download-Cu9ySzL2.js","assets/tooltip-26XdOGj8.js","assets/format-DHK74MwW.js","assets/compare-variants-RfJUgKZi.js","assets/search-x-BI_L6x3P.js","assets/collapsible-BGyXLTVv.js","assets/alert-dialog-D7_6EawW.js","assets/centered-state-zjxxQcEb.js","assets/markdown--qN61YgZ.js","assets/chunk-BO2N2NFS-Bde6epwZ.js","assets/lib-BxQXEXDF.js","assets/run-diff-DTbhZHQE.js","assets/task-commits-x21u_XE-.js","assets/git-tab-loading-BnU4U-BA.js","assets/bot-TU5OTE8D.js","assets/picker-pill-BFprBA9h.js","assets/dropdown-menu-Da8iP-nI.js","assets/external-link-CTJbUN9h.js","assets/folder-Ctd1Xvqx.js","assets/lib-BQXq3kEf.js","assets/use-submit-shortcut-B3TJ3HBP.js","assets/impact-model-Bo4KSZmi.js","assets/upload-Cu6NRABh.js","assets/loader-circle-BuBcxAH7.js","assets/diff-stat-YT7Licr1.js","assets/icon-tooltip-BfI1AC00.js","assets/textarea-Ckx3d0hV.js","assets/terminal-ZT2Z_ALj.js","assets/arrow-left-Ci5OwIMH.js","assets/diff-DpElozOH.js","assets/scroll-within-sbc5xXAl.js","assets/commit-list-DxiIebKF.js","assets/task-notes-C6RP3maE.js","assets/layout-cards-BxB9Sv6Z.js","assets/save-DGJET0jv.js","assets/input-vswZUfsf.js","assets/task-workspace-xnZHXFXk.js","assets/arrow-up-Pd8kIuRY.js","assets/worktree-lifecycle-operation-UpV9MAuk.js","assets/square-CuNOgYBC.js","assets/file-preview-BIAcYezC.js","assets/file-D9jm2sJ3.js","assets/file-tree-hpaNl9qS.js","assets/markdown-BiRiR9OM.js","assets/message-square-Jt8U2gAH.js","assets/plus-nGmv0BVG.js","assets/follow-up-engine-WsUFV3Ry.js","assets/reasoning-effort-pill-BMAjcAKk.js","assets/tabs-BCUQqEYa.js","assets/drawer-state-DasOAIpO.js","assets/types-BTlmexWF.js","assets/repo-git-CpbhUvyL.js","assets/impact-control-Ba9XW3tV.js","assets/github-DnDrPPfz.js","assets/chevron-left-D94sZNQc.js","assets/tag-DHjatodA.js","assets/agent-task-pickers-C0lbPIio.js","assets/tracker-BzXE6yLf.js","assets/workflow-graph-CkCPBwhB.js","assets/settings-2-CcipoS54.js","assets/workflow-graph-DLioOiRN.css","assets/skills-DwnXdnzS.js","assets/automations-route-B_hyZJ2Q.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{$ as a,$n as o,$r as s,$t as c,A as l,Aa as u,Ar as d,B as f,Bn as p,Bt as m,C as h,Ca as g,Cn as _,Co as v,Da as y,Dn as b,E as x,Eo as S,F as C,Fn as w,Fr as T,Ft as E,G as D,Gn as O,Gt as k,Hn as A,Ht as j,Ia as M,In as N,It as P,J as F,Ja as ee,Ji as te,Jn as I,Jt as ne,K as L,Kn as re,Kt as ie,Li as ae,Ln as oe,Lt as se,Mn as ce,Na as le,Nn as R,Nr as ue,Nt as de,On as fe,Or as pe,Pa as z,Pi as me,Pn as he,Pt as ge,Q as _e,Qi as ve,Qt as ye,Ra as be,Rn as xe,Rt as Se,S as Ce,Sn as we,So as Te,St as Ee,T as De,Ta as Oe,To as ke,Tr as Ae,Ua as je,Ui as Me,Un as Ne,Ut as Pe,V as Fe,Va as Ie,Vn as Le,Vt as Re,W as ze,Wa as Be,Wn as Ve,Wr as He,Xn as Ue,Y as We,Ya as Ge,Yi as Ke,Yn as qe,Yt as Je,Z as Ye,Za as Xe,Zt as Ze,_ as Qe,_a as $e,_n as et,_o as tt,_t as nt,aa as rt,an as it,ao as at,bn as ot,bo as st,c as ct,ca as lt,cn as ut,co as dt,ct as ft,d as pt,da as mt,dn as ht,do as gt,dt as _t,ei as vt,en as yt,eo as bt,er as xt,et as St,f as Ct,fa as wt,fn as Tt,fo as Et,g as Dt,gn as Ot,go as kt,h as At,ha as jt,ho as Mt,i as Nt,ia as Pt,in as Ft,io as It,it as Lt,j as Rt,jn as zt,ka as Bt,l as Vt,ln as Ht,lo as Ut,lt as Wt,m as Gt,ma as Kt,mn as qt,mo as Jt,na as Yt,no as Xt,nr as Zt,nt as Qt,o as $t,oi as en,on as tn,oo as nn,ot as rn,p as an,pa as on,pn as B,po as sn,pr as cn,pt as ln,q as un,qa as dn,qn as fn,qt as pn,r as V,ra as mn,ro as hn,rt as gn,s as _n,si as vn,so as H,st as yn,ta as bn,tn as xn,tt as Sn,u as Cn,un as wn,uo as U,ut as Tn,v as En,vo as Dn,vr as On,wa as kn,wn as An,wo as jn,x as Mn,xa as Nn,xi as Pn,xn as Fn,xo as In,xr as Ln,xt as Rn,y as zn,yn as Bn,yo as Vn,yr as Hn,z as Un,za as Wn,zr as Gn,zt as Kn}from"./queries-DbDUaheq.js";import{J as qn,St as Jn,T as Yn,_t as Xn,a as Zn,bt as Qn,c as $n,f as er,ft as tr,g as nr,i as rr,m as ir,n as ar,nt as or,o as sr,p as cr,pt as lr,r as ur,t as W,u as dr,y as fr,yt as pr}from"./utils-Bl_tQdVw.js";import{t as mr}from"./preload-helper-Czpn1I53.js";import{S as hr,_ as gr,a as _r,c as vr,d as yr,f as br,g as xr,h as G,i as Sr,l as Cr,m as wr,n as Tr,o as Er,p as Dr,r as Or,s as kr,t as K,u as Ar,v as jr,x as Mr,y as Nr}from"./project-router-ByYpf5zi.js";import{C as Pr,O as Fr,S as Ir,_ as Lr,a as Rr,b as zr,g as Br,h as Vr,i as Hr,l as Ur,m as Wr,n as Gr,o as Kr,p as qr,s as Jr,t as Yr,u as Xr,v as Zr}from"./use-now-CdtIyF-0.js";import{A as Qr,C as $r,D as ei,E as ti,F as ni,I as ri,L as ii,M as ai,N as oi,O as si,P as ci,S as li,T as ui,_ as di,a as fi,b as pi,c as mi,g as hi,h as gi,i as _i,j as vi,k as yi,l as bi,m as xi,n as Si,p as Ci,r as wi,t as Ti,v as Ei,w as Di,x as Oi,y as ki}from"./facet-filter-Be0XFoHu.js";import{c as Ai,d as ji,f as Mi,g as Ni,h as Pi,i as Fi,l as Ii,m as Li,n as Ri,o as zi,p as Bi,r as Vi,s as Hi,t as Ui,u as Wi}from"./sheet-DJ7Q8rRA.js";import{a as Gi,c as Ki,d as qi,f as Ji,i as Yi,l as Xi,n as Zi,o as Qi,r as $i,s as ea,t as ta,u as na}from"./host-usage-BeX2ZFmV.js";import{t as ra}from"./use-desktop-BNN3U2y9.js";import{C as ia,D as aa,M as oa,N as q,O as sa,S as ca,T as la,_ as ua,b as da,f as fa,g as pa,h as ma,j as ha,m as ga,p as _a,t as J,v as va,w as ya,x as ba,y as xa}from"./button-jcXhXi-5.js";import{Ct as Sa,Et as Ca,Lt as wa,Nt as Ta,Ot as Ea,Pt as Da,St as Oa,Tt as ka,_ as Aa,_t as ja,a as Ma,b as Na,bt as Pa,c as Fa,dt as Ia,ft as La,gt as Ra,ht as za,i as Ba,jt as Va,mt as Ha,n as Ua,o as Wa,pt as Ga,s as Ka,ut as qa,vt as Ja,wt as Ya,x as Xa,xt as Za,y as Qa,yt as $a}from"./git-tab-loading-BnU4U-BA.js";import{n as eo,t as to}from"./arrow-up-Pd8kIuRY.js";import{t as no}from"./arrow-left-Ci5OwIMH.js";import{A as ro,B as io,C as ao,E as oo,F as so,H as co,I as lo,L as uo,M as fo,N as po,P as mo,S as ho,T as go,V as _o,_ as vo,a as yo,b as bo,c as xo,d as So,f as Co,h as wo,i as To,j as Eo,k as Do,l as Oo,o as ko,p as Ao,r as jo,s as Mo,t as No,u as Po,w as Fo,y as Io}from"./worktree-lifecycle-operation-UpV9MAuk.js";import{t as Lo}from"./bot-TU5OTE8D.js";import{$ as Ro,A as zo,C as Bo,Ct as Vo,D as Ho,Et as Uo,J as Wo,O as Go,Ot as Ko,Q as qo,S as Jo,T as Yo,Tt as Xo,X as Zo,Y as Qo,Z as $o,_ as es,_t as ts,a as ns,at as rs,b as is,bt as as,c as os,d as ss,dt as cs,et as ls,f as us,g as ds,gt as fs,h as ps,i as ms,it as hs,j as gs,jt as _s,k as vs,kt as ys,m as bs,n as xs,o as Ss,ot as Cs,p as ws,q as Ts,s as Es,st as Ds,t as Os,u as ks,ut as As,v as js,vt as Ms,w as Ns,wt as Ps,x as Fs,y as Is,yt as Ls}from"./picker-pill-BFprBA9h.js";import{t as Rs}from"./check-CNVywZ6B.js";import{a as zs,i as Bs,n as Vs,o as Hs,r as Us,s as Ws,t as Gs}from"./dist-C2IyLYZs.js";import{t as Ks}from"./chevron-right-D2EqYt_O.js";import{t as qs}from"./circle-check-C09e7mFj.js";import{i as Js,l as Ys,m as Xs,n as Zs,p as Qs,r as $s,s as ec,t as tc}from"./dropdown-menu-Da8iP-nI.js";import{i as nc,r as rc}from"./use-submit-shortcut-B3TJ3HBP.js";import{t as ic}from"./external-link-CTJbUN9h.js";import{_ as ac,b as oc,h as sc,v as cc,x as lc}from"./impact-model-Bo4KSZmi.js";import{t as uc}from"./file-D9jm2sJ3.js";import{t as dc}from"./folder-Ctd1Xvqx.js";import{n as fc,t as pc}from"./upload-Cu6NRABh.js";import{n as mc,r as hc,t as gc}from"./textarea-Ckx3d0hV.js";import{t as _c}from"./loader-circle-BuBcxAH7.js";import{t as vc}from"./message-square-Jt8U2gAH.js";import{n as yc,t as bc}from"./square-CuNOgYBC.js";import{t as xc}from"./plus-nGmv0BVG.js";import{t as Sc}from"./search-x-BI_L6x3P.js";import{t as Cc}from"./search-P545ZVzc.js";import{t as wc}from"./triangle-alert-CBrg6nYB.js";import{t as Tc}from"./x-Qhn_uE86.js";import{a as Ec,i as Dc,n as Oc,r as kc,t as Ac}from"./tooltip-26XdOGj8.js";import{a as jc,i as Mc,o as Nc}from"./collapsible-BGyXLTVv.js";import{a as Pc,c as Fc,i as Ic,n as Lc,o as Rc,r as zc,s as Bc,t as Vc}from"./alert-dialog-D7_6EawW.js";import{i as Hc,n as Uc,r as Wc,t as Gc}from"./tabs-BCUQqEYa.js";import{t as Kc}from"./input-vswZUfsf.js";import{r as Y,t as qc}from"./toaster-CejrnYvv.js";import{n as Jc,t as Yc}from"./token-metrics-BINGXGrg.js";import{n as Xc}from"./format-DHK74MwW.js";import{t as Zc}from"./diff-stat-YT7Licr1.js";import{t as Qc}from"./icon-tooltip-BfI1AC00.js";import{t as $c}from"./lib-BQXq3kEf.js";import{t as el}from"./clipboard-DvCUPLwM.js";import{n as tl,t as X}from"./centered-state-zjxxQcEb.js";import{t as nl}from"./reasoning-effort-pill-BMAjcAKk.js";import{a as rl,i as il,n as al,t as ol}from"./markdown--qN61YgZ.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 sl=class extends S{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 gt({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=cl(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=cl(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=cl(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=cl(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){Jt.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=>Vn(t,e))}findAll(e={}){return this.getAll().filter(t=>Vn(e,t))}notify(e){Jt.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return Jt.batch(()=>Promise.all(e.map(e=>e.continue().catch(In))))}};function cl(e){return e.options.scope?.id}var ll=class extends S{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??tt(r,t),a=this.get(i);return a||(a=new Et({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(){Jt.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=>st(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>st(e,t)):t}notify(e){Jt.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Jt.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Jt.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},ul=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new ll,this.#t=e.mutationCache||new sl,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=ke.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=sn.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(v(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=Mt(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return Jt.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;Jt.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return Jt.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=Jt.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(In).catch(In)}invalidateQueries(e,t={}){return Jt.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=Jt.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(In)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(In)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(v(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(In).catch(In)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(In).catch(In)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return sn.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(kt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Te(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(kt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Te(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||=tt(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===jn&&(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),dl=n();function fl(){return new ul({defaultOptions:{queries:{refetchInterval:!1,staleTime:5*6e4,gcTime:30*6e4,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:(e,t)=>t instanceof cn&&t.status>=400&&t.status<500?!1:t instanceof cn&&t.status===0?e<3:e<1,retryDelay:(e,t)=>t instanceof cn&&t.status===0?Math.min(250*2**e,1e3):Math.min(1e3*2**e,3e4)},mutations:{retry:!1}}})}var pl=q(`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`}]]),ml=q(`arrow-left-right`,[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]),hl=q(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),gl=q(`blocks`,[[`path`,{d:`M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2`,key:`1ah6g2`}],[`rect`,{x:`14`,y:`2`,width:`8`,height:`8`,rx:`1`,key:`88lufb`}]]),_l=q(`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`}]]),vl=q(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),yl=q(`chevrons-left`,[[`path`,{d:`m11 17-5-5 5-5`,key:`13zhaf`}],[`path`,{d:`m18 17-5-5 5-5`,key:`h8a8et`}]]),bl=q(`chevrons-right`,[[`path`,{d:`m6 17 5-5-5-5`,key:`xnjwq`}],[`path`,{d:`m13 17 5-5-5-5`,key:`17xmmf`}]]),xl=q(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),Sl=q(`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`}]]),Cl=q(`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`}]]),wl=q(`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`}]]),Tl=q(`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`}]]),El=q(`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`}]]),Dl=q(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),Ol=q(`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`}]]),kl=q(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 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.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Al=q(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`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`}]]),jl=q(`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`}]]),Ml=q(`folders`,[[`path`,{d:`M20 5a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h2.5a1.5 1.5 0 0 1 1.2.6l.6.8a1.5 1.5 0 0 0 1.2.6z`,key:`a4852j`}],[`path`,{d:`M3 8.268a2 2 0 0 0-1 1.738V19a2 2 0 0 0 2 2h11a2 2 0 0 0 1.732-1`,key:`yxbcw3`}]]),Nl=q(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),Pl=q(`gift`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M20 11v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8`,key:`1sqzm4`}],[`path`,{d:`M7.5 7a1 1 0 0 1 0-5A4.8 8 0 0 1 12 7a4.8 8 0 0 1 4.5-5 1 1 0 0 1 0 5`,key:`kc0143`}],[`rect`,{x:`3`,y:`7`,width:`18`,height:`4`,rx:`1`,key:`1hberx`}]]),Fl=q(`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`}]]),Il=q(`inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]),Ll=q(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Rl=q(`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`}]]),zl=q(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),Bl=q(`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`}]]),Vl=q(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),Hl=q(`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`}]]),Ul=q(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),Wl=q(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Gl=q(`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`}]]),Kl=q(`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`}]]),ql=q(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]),Jl=q(`package-check`,[[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`path`,{d:`m16 17 2 2 4-4`,key:`uh5qu3`}],[`path`,{d:`M21 11.127V8a2 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.729l7 4a2 2 0 0 0 2 .001l1.32-.753`,key:`kpkbpo`}],[`path`,{d:`M3.29 7 12 12l8.71-5`,key:`19ckod`}],[`path`,{d:`m7.5 4.27 8.997 5.148`,key:`9yrvtv`}]]),Yl=q(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 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.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),Xl=q(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),Zl=q(`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`}]]),Ql=q(`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`}]]),$l=q(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),eu=q(`scale`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`m19 8 3 8a5 5 0 0 1-6 0zV7`,key:`zcdpyk`}],[`path`,{d:`M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1`,key:`1yorad`}],[`path`,{d:`m5 8 3 8a5 5 0 0 1-6 0zV7`,key:`eua70x`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}]]),tu=q(`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`}]]),nu=q(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),ru=q(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),iu=q(`split`,[[`path`,{d:`M16 3h5v5`,key:`1806ms`}],[`path`,{d:`M8 3H3v5`,key:`15dfkv`}],[`path`,{d:`M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3`,key:`1qrqzj`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}]]),au=q(`star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),ou=q(`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`}]]),su=q(`ticket`,[[`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`,key:`qn84l0`}],[`path`,{d:`M13 5v2`,key:`dyzc3o`}],[`path`,{d:`M13 17v2`,key:`1ont0d`}],[`path`,{d:`M13 11v2`,key:`1wjjxi`}]]),cu=q(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),lu=q(`webhook`,[[`path`,{d:`M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2`,key:`q3hayz`}],[`path`,{d:`m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06`,key:`1go1hn`}],[`path`,{d:`m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8`,key:`qlwsc0`}]]),uu={jira:{label:`Jira`,scopeLabel:`Jira projects`},linear:{label:`Linear`,scopeLabel:`Linear teams`}},du=Jn.options.map(e=>({kind:e,...uu[e]}));function fu(e){let t=Z.useRef({value:e,previous:e});return Z.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Q=i(),pu=`Label`,mu=Z.forwardRef((e,t)=>(0,Q.jsx)(la.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));mu.displayName=pu;var hu=mu;function gu(e,[t,n]){return Math.min(n,Math.max(t,e))}var _u=e(r(),1),vu=[` `,`Enter`,`ArrowUp`,`ArrowDown`],yu=[` `,`Enter`],bu=`Select`,[xu,Su,Cu]=Xs(bu),[wu,Tu]=ya(bu,[Cu,zs]),Eu=zs(),[Du,Ou]=wu(bu),[ku,Au]=wu(bu),ju=`SelectProvider`;function Mu(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=Eu(t),[_,v]=Z.useState(null),[y,b]=Z.useState(null),[x,S]=Z.useState(!1),C=Qs(l),[w,T]=ba({prop:r,defaultProp:i??!1,onChange:a,caller:bu}),[E,D]=ba({prop:o,defaultProp:s,onChange:c,caller:bu}),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=xa(),P=Array.from(j).map(e=>e.props.value).join(`;`),F=Z.useCallback(e=>{M(t=>new Set(t).add(e))},[]),ee=Z.useCallback(e=>{M(t=>{let n=new Set(t);return n.delete(e),n})},[]),te={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)(Bs,{...g,children:(0,Q.jsx)(Du,{scope:t,...te,children:(0,Q.jsx)(xu.Provider,{scope:t,children:(0,Q.jsx)(ku,{scope:t,onNativeOptionAdd:F,onNativeOptionRemove:ee,children:Md(h)?h(te):n})})})})}Mu.displayName=ju;var Nu=e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,Q.jsx)(Mu,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,Q.jsxs)(Q.Fragment,{children:[n,e?(0,Q.jsx)(jd,{__scopeSelect:t}):null]})})};Nu.displayName=bu;var Pu=`SelectTrigger`,Fu=Z.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Eu(n),o=Ou(Pu,n),s=o.disabled||r,c=ha(t,o.onTriggerChange),l=Su(n),u=Z.useRef(`touch`),[d,f,p]=Pd(e=>{let t=l().filter(e=>!e.disabled),n=Fd(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)(Gs,{asChild:!0,...a,children:(0,Q.jsx)(la.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":Nd(o.value)?``:void 0,...i,ref:c,onClick:ia(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:ia(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:ia(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&vu.includes(e.key)&&(m(),e.preventDefault())})})})});Fu.displayName=Pu;var Iu=`SelectValue`,Lu=Z.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=Ou(Iu,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=ha(t,c.onValueNodeChange);ca(()=>{l(u)},[l,u]);let f=Nd(c.value);return(0,Q.jsx)(la.span,{...s,asChild:!f&&s.asChild,ref:d,style:{pointerEvents:`none`},children:(0,Q.jsx)(Z.Fragment,{children:f?o:a},f?`placeholder`:`value`)})});Lu.displayName=Iu;var Ru=`SelectIcon`,zu=Z.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,Q.jsx)(la.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});zu.displayName=Ru;var Bu=`SelectPortal`,[Vu,Hu]=wu(Bu,{forceMount:void 0}),Uu=e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,Q.jsx)(Vu,{scope:e.__scopeSelect,forceMount:n,children:(0,Q.jsx)(ma,{asChild:!0,...r})})};Uu.displayName=Bu;var Wu=`SelectContent`,Gu=Z.forwardRef((e,t)=>{let n=Hu(Wu,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=Ou(Wu,e.__scopeSelect),[o,s]=Z.useState();return ca(()=>{s(new DocumentFragment)},[]),(0,Q.jsx)(da,{present:r||a.open,children:({present:e})=>e?(0,Q.jsx)(Qu,{...i,ref:t}):(0,Q.jsx)(Ku,{...i,fragment:o})})});Gu.displayName=Wu;var Ku=Z.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,fragment:i}=e;return i?_u.createPortal((0,Q.jsx)(Ju,{scope:n,children:(0,Q.jsx)(xu.Slot,{scope:n,children:(0,Q.jsx)(`div`,{ref:t,children:r})})}),i):null});Ku.displayName=`SelectContentFragment`;var qu=10,[Ju,Yu]=wu(Wu),Xu=`SelectContentImpl`,Zu=sa(`SelectContent.RemoveScroll`),Qu=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=Ou(Wu,n),[y,b]=Z.useState(null),[x,S]=Z.useState(null),C=ha(t,b),[w,T]=Z.useState(null),[E,D]=Z.useState(null),O=Su(n),[k,A]=Z.useState(!1),j=Z.useRef(!1);Z.useEffect(()=>{if(y)return fa(y)},[y]),ga();let M=Z.useCallback(e=>{let[t,...n]=O().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},[O,x]),N=Z.useCallback(()=>M([w,y]),[M,w,y]);Z.useEffect(()=>{k&&N()},[k,N]);let{onOpenChange:P,triggerPointerDownPosRef:F}=v;Z.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(F.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(F.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(y)||P(!1),document.removeEventListener(`pointermove`,t),F.current=null};return F.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,P,F]),Z.useEffect(()=>{let e=()=>P(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[P]);let[ee,te]=Pd(e=>{let t=O().filter(e=>!e.disabled),n=Fd(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),I=Z.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(j.current=!0))},[v.value]),ne=Z.useCallback(()=>y?.focus(),[y]),L=Z.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),re=r===`popper`?nd:ed,ie=re===nd?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,Q.jsx)(Ju,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:I,selectedItem:w,onItemLeave:ne,itemTextRefCallback:L,focusSelectedItem:N,selectedItemText:E,position:r,isPositioned:k,searchRef:ee,children:(0,Q.jsx)(_a,{as:Zu,allowPinchZoom:!0,children:(0,Q.jsx)(pa,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:ia(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,Q.jsx)(ua,{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:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:ia(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&te(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=O().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(()=>M(t)),e.preventDefault()}})})})})})})});Qu.displayName=Xu;var $u=`SelectItemAlignedPosition`,ed=Z.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=Ou(Wu,n),o=Yu(Wu,n),[s,c]=Z.useState(null),[l,u]=Z.useState(null),d=ha(t,u),f=Su(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-qu,d=gu(a,[qu,Math.max(qu,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-qu,d=gu(a,[qu,Math.max(qu,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-qu*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-qu,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=`${qu}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]);ca(()=>y(),[y]);let[b,x]=Z.useState();return ca(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,Q.jsx)(rd,{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)(la.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});ed.displayName=$u;var td=`SelectPopperPosition`,nd=Z.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=qu,...a}=e,o=Eu(n);return(0,Q.jsx)(Us,{...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)`}})});nd.displayName=td;var[rd,id]=wu(Wu,{}),ad=`SelectViewport`,od=Z.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=Yu(ad,n),o=id(ad,n),s=ha(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)(xu.Slot,{scope:n,children:(0,Q.jsx)(la.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:ia(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-qu*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})})})]})});od.displayName=ad;var sd=`SelectGroup`,[cd,ld]=wu(sd),ud=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=xa();return(0,Q.jsx)(cd,{scope:n,id:i,children:(0,Q.jsx)(la.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});ud.displayName=sd;var dd=`SelectLabel`,fd=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=ld(dd,n);return(0,Q.jsx)(la.div,{id:i.id,...r,ref:t})});fd.displayName=dd;var pd=`SelectItem`,[md,hd]=wu(pd),gd=Z.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=Ou(pd,n),c=Yu(pd,n),l=s.value===r,[u,d]=Z.useState(a??``),[f,p]=Z.useState(!1),m=ha(t,va(e=>c.itemRefCallback?.(e,r,i))),h=xa(),g=Z.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};return(0,Q.jsx)(md,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:Z.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,Q.jsx)(xu.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,Q.jsx)(la.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:ia(o.onFocus,()=>p(!0)),onBlur:ia(o.onBlur,()=>p(!1)),onClick:ia(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:ia(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:ia(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:ia(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ia(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:ia(o.onKeyDown,e=>{i||e.target!==e.currentTarget||c.searchRef?.current!==``&&e.key===` `||(yu.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});gd.displayName=pd;var _d=`SelectItemText`,vd=Z.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=Ou(_d,n),s=Yu(_d,n),c=hd(_d,n),l=Au(_d,n),[u,d]=Z.useState(null),f=va(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=ha(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 ca(()=>(g(h),()=>_(h)),[g,_,h]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(la.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!Nd(o.value)?_u.createPortal(a.children,o.valueNode):null]})});vd.displayName=_d;var yd=`SelectItemIndicator`,bd=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return hd(yd,n).isSelected?(0,Q.jsx)(la.span,{"aria-hidden":!0,...r,ref:t}):null});bd.displayName=yd;var xd=`SelectScrollUpButton`,Sd=Z.forwardRef((e,t)=>{let n=Yu(xd,e.__scopeSelect),r=id(xd,e.__scopeSelect),[i,a]=Z.useState(!1),o=ha(t,r.onScrollButtonChange);return ca(()=>{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)(Td,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});Sd.displayName=xd;var Cd=`SelectScrollDownButton`,wd=Z.forwardRef((e,t)=>{let n=Yu(Cd,e.__scopeSelect),r=id(Cd,e.__scopeSelect),[i,a]=Z.useState(!1),o=ha(t,r.onScrollButtonChange);return ca(()=>{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)(Td,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});wd.displayName=Cd;var Td=Z.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Yu(`SelectScrollButton`,n),o=Z.useRef(null),s=Su(n),c=Z.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return Z.useEffect(()=>()=>c(),[c]),ca(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,Q.jsx)(la.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:ia(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:ia(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:ia(i.onPointerLeave,()=>{c()})})}),Ed=`SelectSeparator`,Dd=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,Q.jsx)(la.div,{"aria-hidden":!0,...r,ref:t})});Dd.displayName=Ed;var Od=`SelectArrow`,kd=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Eu(n);return Yu(Od,n).position===`popper`?(0,Q.jsx)(Vs,{...i,...r,ref:t}):null});kd.displayName=Od;var Ad=`SelectBubbleInput`,jd=Z.forwardRef(({__scopeSelect:e,...t},n)=>{let r=Ou(Ad,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=ha(n,p),h=i??``,g=fu(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)(la.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:u,onChange:e=>a(e.target.value),...t,style:{...Ec,...t.style},ref:m,defaultValue:h,children:[Nd(i)&&!_?(0,Q.jsx)(`option`,{value:``}):null,Array.from(d)]},f)});jd.displayName=Ad;function Md(e){return typeof e==`function`}function Nd(e){return e===``||e===void 0}function Pd(e){let t=va(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 Fd(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=Id(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 Id(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ld=`Switch`,[Rd,zd]=ya(Ld),[Bd,Vd]=Rd(Ld);function Hd(e){let{__scopeSwitch:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=ba({prop:n,defaultProp:i??!1,onChange:c,caller:Ld}),[m,h]=Z.useState(null),[g,_]=Z.useState(null),v={checked:f,setChecked:p,disabled:a,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:Z.useRef(!1),required:l,defaultChecked:i,isFormControl:!m||!!o||!!m.closest(`form`),bubbleInput:g,setBubbleInput:_};return(0,Q.jsx)(Bd,{scope:t,...v,children:Xd(d)?d(v):r})}var Ud=`SwitchTrigger`,Wd=Z.forwardRef(({__scopeSwitch:e,onClick:t,...n},r)=>{let{control:i,form:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,isFormControl:p,bubbleInput:m}=Vd(Ud,e),h=ha(r,u),g=Z.useRef(c);return Z.useEffect(()=>{let e=a?i?.ownerDocument.getElementById(a):i?.form;if(e instanceof HTMLFormElement){let t=()=>d(g.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[i,a,d]),(0,Q.jsx)(la.button,{type:`button`,role:`switch`,"aria-checked":c,"aria-required":l,"data-state":Zd(c),"data-disabled":s?``:void 0,disabled:s,value:o,...n,ref:h,onClick:ia(t,e=>{d(e=>!e),m&&p&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})});Wd.displayName=Ud;var Gd=Z.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,Q.jsx)(Hd,{__scopeSwitch:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Wd,{...d,ref:t,__scopeSwitch:n}),e&&(0,Q.jsx)(Yd,{__scopeSwitch:n})]})})});Gd.displayName=Ld;var Kd=`SwitchThumb`,qd=Z.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=Vd(Kd,n);return(0,Q.jsx)(la.span,{"data-state":Zd(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});qd.displayName=Kd;var Jd=`SwitchBubbleInput`,Yd=Z.forwardRef(({__scopeSwitch:e,...t},n)=>{let{control:r,hasConsumerStoppedPropagationRef:i,checked:a,defaultChecked:o,required:s,disabled:c,name:l,value:u,form:d,bubbleInput:f,setBubbleInput:p}=Vd(Jd,e),m=ha(n,p),h=fu(a),g=Hs(r);Z.useEffect(()=>{let e=f;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=!i.current;if(h!==a&&n){let t=new Event(`click`,{bubbles:r});n.call(e,a),e.dispatchEvent(t)}},[f,h,a,i]);let _=Z.useRef(a);return(0,Q.jsx)(la.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:o??_.current,required:s,disabled:c,name:l,value:u,form:d,...t,tabIndex:-1,ref:m,style:{...t.style,...g,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})});Yd.displayName=Jd;function Xd(e){return typeof e==`function`}function Zd(e){return e?`checked`:`unchecked`}var Qd=oa(`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-primary text-primary-foreground [a&]:hover:bg-primary/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-primary underline-offset-4 [a&]:hover:underline`}},defaultVariants:{variant:`default`}});function $d({className:e,variant:t=`default`,asChild:n=!1,...r}){return(0,Q.jsx)(n?aa:`span`,{"data-slot":`badge`,"data-variant":t,className:W(Qd({variant:t}),e),...r})}var ef=/^(?:\\\\\?\\)?[A-Za-z]:$/,tf=/^(?:[\\/]{2}(?!\?[\\/])|\\\\\?\\UNC\\)[^\\/]+[\\/][^\\/]+$/i;function nf(e){let t=e.replace(/[\\/]+$/,``);if(ef.test(t)||tf.test(t))return null;let n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));if(n<0)return null;if(n===0)return t.slice(0,1);let r=t.slice(0,n);return ef.test(r)?t.slice(0,n+1):r}var rf=`x-apple.systempreferences:com.apple.preference.security?Privacy_FilesAndFolders`,af=`inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-foreground hover:bg-muted`;function of({path:e,selected:t,onSelect:n,onEnter:r,decorate:i,emptyHint:a,showHidden:o=!1}){let s=De(e,o),c=s.data?.parent??null,l=e===null?null:nf(e);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{"data-slot":`fs-breadcrumb`,className:`truncate font-mono text-meta text-soft-foreground`,title:s.data?.path??void 0,children:s.data?.path??(s.isError?``:`Loading…`)}),!s.isError&&s.data?.parent===null?(0,Q.jsxs)(`p`,{"data-slot":`fs-root-hint`,className:`text-label text-soft-foreground`,children:[`This is the browse root. To browse elsewhere, change`,` `,(0,Q.jsx)(`a`,{href:`/settings/global/projects`,className:`text-foreground underline underline-offset-4 hover:text-muted-foreground`,children:`Default browse folder in Settings → Projects`}),`.`]}):null,s.isError?(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-ui text-danger`,children:s.error instanceof Error?s.error.message:`could not list that folder`}),s.error instanceof cn&&s.error.status===403?(0,Q.jsx)(`p`,{"data-slot":`fs-privacy-hint`,className:`text-label 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-label`,children:[l===null?null:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`fs-error-back`,onClick:()=>r(l),className:af,children:[(0,Q.jsx)(wl,{className:`size-3.5`,"aria-hidden":!0}),`Back`]}),s.error instanceof cn&&s.error.status===403?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`a`,{"data-slot":`fs-privacy-settings`,href:rf,target:`_blank`,rel:`noreferrer`,className:af,children:`Open Privacy Settings`}),(0,Q.jsx)(`button`,{type:`button`,"data-slot":`fs-retry`,onClick:()=>void s.refetch(),className:af,children:`Try again`})]}):null]})]}):(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-ui hover:bg-muted`,children:[(0,Q.jsx)(wl,{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:W(`flex min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left text-ui hover:bg-muted`,t?.path===e.path&&`bg-muted`),children:[(0,Q.jsx)(dc,{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)(Ks,{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-ui text-muted-foreground`,children:a}):null]}),s.data?.truncated?(0,Q.jsx)(`p`,{"data-slot":`fs-truncated`,className:`text-meta text-muted-foreground`,children:`Too many folders to list — only the first ones are shown.`}):null]})}function sf(e,t,n=!1){let r=De(e,n);return t?.path??r.data?.path??null}function cf({open:e,onOpenChange:t}){let[n,r]=(0,Z.useState)(null),[i,o]=(0,Z.useState)(null),s=a(),c=Wt(),l=Nr(),u=new Set((s.data?.projects??[]).filter(e=>!e.unregistered).map(e=>e.root)),d=e=>{r(e),o(null),c.reset()},f=sf(n,i);return(0,Q.jsx)(qr,{open:e,onOpenChange:t,children:(0,Q.jsxs)(Wr,{"data-slot":`add-project-dialog`,className:`sm:max-w-lg`,children:[(0,Q.jsxs)(Lr,{children:[(0,Q.jsx)(Zr,{children:`Open local folder`}),(0,Q.jsx)(Vr,{children:`Pick the folder cezar should run in. Git repos are marked; any folder works.`})]}),(0,Q.jsx)(of,{path:n,selected:i,onSelect:o,onEnter:d,emptyHint:`No subfolders here — “Add project” registers this folder.`,decorate:e=>(0,Q.jsxs)(Q.Fragment,{children:[e.isRepo?(0,Q.jsx)($d,{variant:`outline`,className:`shrink-0 text-micro`,children:`git`}):null,u.has(e.path)?(0,Q.jsx)($d,{variant:`ghost`,className:`shrink-0 text-micro text-muted-foreground`,children:`already added`}):null]})}),c.isError?(0,Q.jsx)(`p`,{"data-slot":`add-project-error`,className:`min-w-0 break-words text-ui text-danger`,children:c.error instanceof Error?c.error.message:`could not add that folder`}):null,(0,Q.jsxs)(Br,{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-meta text-muted-foreground`,title:f??void 0,children:f??``}),(0,Q.jsxs)(`span`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsx)(J,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(J,{"data-slot":`add-project-confirm`,disabled:f===null||c.isPending,onClick:()=>{f===null||c.isPending||c.mutate(f,{onSuccess:({project:e})=>{t(!1),l(`/p/${encodeURIComponent(e.id)}/`)}})},children:c.isPending?`Adding…`:`Add project`})]})]})]})})}function lf({className:e,...t}){return(0,Q.jsx)(hu,{"data-slot":`label`,className:W(`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})}function uf(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 df({open:e,onOpenChange:t}){let[n,r]=(0,Z.useState)(``),[i,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(!1),f=a(),p=Qe(),{mutate:m,isPending:h}=p,g=Nr(),_=uf(p.error),v=(0,Z.useMemo)(()=>`co-${Math.random().toString(36).slice(2)}-${Date.now().toString(36)}`,[]),y=(0,Z.useRef)(v);y.current=v,(0,Z.useEffect)(()=>vi((e,t)=>{if(e!==`checkout-progress`)return;let n=t;n?.checkoutId===y.current&&(n.phase===`cloning`&&n.line?c(n.line):n.phase!==`cloning`&&c(null))}),[]);let b=(0,Z.useMemo)(()=>{let e=n.trim().replace(/\/+$/,``).replace(/\.git$/,``).split(`/`).pop()??``;return e.includes(`:`)?e.split(`:`).pop()??``:e},[n]),x=i.trim()===``?b:i.trim(),S=f.data?.projectsDir??``,C=x===``?``:`${S.replace(/\/+$/,``)}/${x}`,w=(0,Z.useCallback)(()=>{n.trim()===``||h||(d.current=!1,u(!1),c(null),m({url:n.trim(),checkoutId:v,...i.trim()===``?{}:{name:i.trim()}},{onSuccess:({project:e})=>{t(!1),g(`/p/${encodeURIComponent(e.id)}/`)}}))},[m,h,v,i,g,t,n]);return(0,Z.useEffect)(()=>{if(!l)return;let e=()=>{d.current&&(d.current=!1,u(!1),w())},t=()=>{document.visibilityState===`visible`&&e()};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,t)}},[l,w]),(0,Q.jsx)(qr,{open:e,onOpenChange:e=>p.isPending?void 0:t(e),children:(0,Q.jsxs)(Wr,{"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)(Lr,{children:[(0,Q.jsx)(Zr,{children:`Clone from GitHub`}),(0,Q.jsxs)(Vr,{children:[`The service 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)(lf,{htmlFor:`clone-url`,children:`Repository`}),(0,Q.jsx)(Kc,{id:`clone-url`,"data-slot":`clone-url`,autoFocus:!0,placeholder:`owner/repo or https://github.com/owner/repo`,value:n,disabled:p.isPending,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&w()}})]}),(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsx)(lf,{htmlFor:`clone-name`,children:`Folder name`}),(0,Q.jsx)(Kc,{id:`clone-name`,"data-slot":`clone-name`,placeholder:b===``?`repo`:b,value:i,disabled:p.isPending,onChange:e=>o(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-meta text-soft-foreground`,title:C,children:C}),p.isPending?(0,Q.jsx)(J,{"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)(tu,{className:`size-3.5`,"aria-hidden":`true`})}):(0,Q.jsx)(J,{asChild:!0,variant:`ghost`,size:`icon-sm`,className:`size-7`,children:(0,Q.jsx)(yr,{to:`/settings/global/projects`,"data-slot":`clone-root-settings`,"aria-label":`Edit checkout root`,title:`Edit checkout root`,children:(0,Q.jsx)(tu,{className:`size-3.5`,"aria-hidden":`true`})})})]})]}),p.isPending?(0,Q.jsx)(`p`,{"data-slot":`clone-progress`,className:`truncate font-mono text-meta text-muted-foreground`,children:s??`Starting the clone…`}):null,p.isError?(0,Q.jsx)(`div`,{"data-slot":`clone-error`,className:`grid min-w-0 gap-1.5 text-ui text-danger`,children:_?(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:`font-medium underline underline-offset-2`,href:_,target:`_blank`,rel:`noreferrer`,onClick:()=>{d.current=!0,u(!0)},children:`Authorize this GitHub organization`}),l?` — 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`,{children:`Error details`}),(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap break-all`,children:p.error instanceof Error?p.error.message:null})]})]}):(0,Q.jsx)(`p`,{className:`min-w-0 whitespace-pre-wrap break-all`,children:p.error instanceof Error?p.error.message:`could not clone that repository`})}):null,(0,Q.jsxs)(Br,{children:[(0,Q.jsx)(J,{variant:`outline`,disabled:p.isPending,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(J,{"data-slot":`clone-confirm`,disabled:n.trim()===``||x===``||p.isPending,onClick:w,children:p.isPending?`Cloning…`:p.isError?`Retry clone`:`Clone`})]})]})})}function ff({className:e,size:t=`default`,...n}){return(0,Q.jsx)(Gd,{"data-slot":`switch`,"data-size":t,className:W(`peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,e),...n,children:(0,Q.jsx)(qd,{"data-slot":`switch-thumb`,className:W(`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0`)})})}var pf=[{slug:`github/codespaces-nextjs`,label:`Next.js`,description:`Minimal Next.js app (GitHub)`},{slug:`vercel/ai-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 mf(e){let t=e.trim().toLowerCase();return t===``||pf.some(e=>e.slug.toLowerCase()===t)?pf:pf.filter(e=>[e.label,e.slug,e.description].some(e=>e.toLowerCase().includes(t)))}function hf({value:e,onChange:t,disabled:n,id:r}){let[i,a]=(0,Z.useState)(-1),o=(0,Z.useId)(),s=mf(e),c=(0,Z.useRef)(null),l=e.trim();(0,Z.useEffect)(()=>{i<0||c.current?.querySelector(`[data-index="${i}"]`)?.scrollIntoView?.({block:`nearest`})},[i]),(0,Z.useEffect)(()=>{c.current?.querySelector(`[aria-selected="true"]`)?.scrollIntoView?.({block:`nearest`})},[l]);let u=e=>{n||(t(e),a(-1))};return(0,Q.jsxs)(`div`,{className:`grid gap-2 md:flex md:min-h-0 md:flex-1 md:flex-col`,children:[(0,Q.jsx)(Kc,{id:r,"data-slot":`create-template`,role:`combobox`,"aria-expanded":s.length>0,"aria-controls":o,"aria-autocomplete":`list`,"aria-activedescendant":i>=0?`${o}-${i}`:void 0,autoComplete:`off`,placeholder:`Search, or paste owner/repo or a URL`,value:e,disabled:n,onBlur:()=>a(-1),onChange:e=>{t(e.target.value),a(-1)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;a(e=>s.length===0?-1:(e+t+s.length)%s.length)}else if(e.key===`Enter`&&i>=0){e.preventDefault();let t=s[i];t&&u(t.slug)}}}),s.length>0?(0,Q.jsx)(`ul`,{ref:c,id:o,role:`listbox`,"aria-label":`Suggested templates`,"aria-disabled":n||void 0,"data-slot":`create-template-suggestions`,className:W(`max-h-56 overflow-y-auto overscroll-contain rounded-md border border-border p-1`,`md:max-h-none md:min-h-36 md:flex-1`,n?`pointer-events-none opacity-50`:void 0),children:s.map((e,t)=>{let n=e.slug===l;return(0,Q.jsxs)(`li`,{id:`${o}-${t}`,role:`option`,"aria-selected":n,"data-index":t,"data-slot":`create-template-suggestion`,"data-template":e.slug,onMouseDown:e=>e.preventDefault(),onClick:()=>u(e.slug),onMouseEnter:()=>a(t),onMouseLeave:()=>a(-1),className:W(`grid cursor-pointer gap-0.5 rounded-sm border px-2 py-1.5`,n?`border-primary bg-primary/5`:`border-transparent`,t===i&&!n?`bg-accent text-accent-foreground`:void 0),children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-baseline justify-between gap-2`,children:[(0,Q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-sm font-medium`,children:[e.label,n?(0,Q.jsx)(qs,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":`true`}):null]}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-meta text-muted-foreground`,children:e.description})]}),(0,Q.jsx)(`span`,{className:`truncate font-mono text-meta text-soft-foreground`,children:e.slug})]},e.slug)})}):(0,Q.jsxs)(`p`,{"data-slot":`create-template-no-match`,className:`px-1 text-label text-muted-foreground`,children:[`No suggested template matches — any `,(0,Q.jsx)(`span`,{className:`font-mono`,children:`owner/repo`}),` or GitHub URL works.`]})]})}function gf(e){return e.trimStart().replace(/\s+/g,`-`)}function _f({open:e,onOpenChange:t}){let[n,r]=(0,Z.useState)(``),[i,o]=(0,Z.useState)(!0),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(`empty`),[p,m]=(0,Z.useState)(null),h=a(),g=Rt(),_=Ce(),v=Nr(),y=(0,Z.useMemo)(()=>`np-${Math.random().toString(36).slice(2)}-${Date.now().toString(36)}`,[]),b=(0,Z.useRef)(y);b.current=y,(0,Z.useEffect)(()=>vi((e,t)=>{if(e!==`checkout-progress`)return;let n=t;n?.checkoutId===b.current&&(n.phase===`cloning`&&n.line?m(n.line):n.phase!==`cloning`&&m(null))}),[]);let x=g.data,S=x?.available===!0&&Array.isArray(x.owners)&&x.owners.length>0,C=(0,Z.useMemo)(()=>x?.available&&Array.isArray(x.owners)?x.owners:[],[x]),w=C.some(e=>e.login===s)?s:C[0]?.login??``,T=i&&S,E=n.trim(),D=or.test(E),O=E===``||D?null:E.length>100?`At most 100 characters.`:`Use letters, digits, “.”, “-” and “_” only.`,k=h.data?.projectsDir??``,A=D?`${k.replace(/\/+$/,``)}/${E}`:``,j=T&&d===`template`,M=j&&l.trim()===``,N=()=>{if(!D||_.isPending||i&&g.isPending||M)return;m(null);let e=l.trim();_.mutate({name:E,checkoutId:y,...T?{github:{owner:w,...j&&e!==``?{template:e}:{}}}:{}},{onSuccess:({project:e})=>{t(!1),v(`/p/${encodeURIComponent(e.id)}/`)}})},P=_.isPending,F=g.isPending||S;return(0,Q.jsx)(qr,{open:e,onOpenChange:e=>P?void 0:t(e),children:(0,Q.jsxs)(Wr,{"data-slot":`create-project-dialog`,className:W(`max-h-[calc(100dvh-2rem)] overflow-y-auto`,F?`md:h-[min(50rem,calc(100dvh-4rem))] md:max-w-3xl md:grid-rows-[auto_minmax(0,1fr)_auto] md:overflow-hidden`:void 0),children:[(0,Q.jsxs)(Lr,{children:[(0,Q.jsx)(Zr,{children:`New project`}),(0,Q.jsx)(Vr,{children:`cezar creates a new git repository in your checkout root and adds it as a project.`})]}),(0,Q.jsxs)(`div`,{"data-slot":`create-layout`,className:W(`grid gap-6`,F?`md:min-h-0 md:grid-cols-[minmax(0,5fr)_minmax(0,6fr)]`:void 0),children:[F?(0,Q.jsx)(`div`,{"data-slot":`create-owners-column`,className:`min-w-0 md:flex md:min-h-0 md:flex-col md:border-r md:border-border md:pr-6`,children:S?(0,Q.jsx)(vf,{owners:C,value:w,disabled:P||!T,onChange:c}):(0,Q.jsx)(bf,{})}):null,(0,Q.jsxs)(`div`,{"data-slot":`create-form-column`,className:W(`grid min-w-0 content-start gap-4`,F?`md:-m-1 md:flex md:min-h-0 md:flex-col md:overflow-y-auto md:p-1`:void 0),children:[(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsx)(lf,{htmlFor:`create-name`,children:`Name`}),(0,Q.jsx)(Kc,{id:`create-name`,"data-slot":`create-name`,autoFocus:!0,placeholder:`my-project`,value:n,disabled:P,"aria-invalid":O!==null,"aria-describedby":`create-name-hint`,onChange:e=>r(gf(e.target.value)),onKeyDown:e=>{e.key===`Enter`&&N()}}),O?(0,Q.jsx)(`p`,{id:`create-name-hint`,"data-slot":`create-name-error`,className:`text-label text-danger`,children:O}):(0,Q.jsx)(`p`,{id:`create-name-hint`,"data-slot":`create-target`,className:`min-w-0 truncate font-mono text-meta text-soft-foreground`,title:A,children:A})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-border p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(lf,{htmlFor:`create-github`,className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(Vl,{className:`size-3.5`,"aria-hidden":`true`}),`Create a private GitHub repository`]}),(0,Q.jsx)(ff,{id:`create-github`,"data-slot":`create-github`,checked:T,disabled:P||!S,onCheckedChange:o})]}),g.isPending?(0,Q.jsx)(`p`,{className:`text-label text-muted-foreground`,children:`Checking GitHub…`}):S?null:(0,Q.jsx)(`p`,{"data-slot":`create-github-unavailable`,className:`text-label text-muted-foreground`,children:x&&!x.available?x.reason:`Could not read your GitHub accounts — the project will be created locally only.`}),T?(0,Q.jsxs)(`p`,{className:`text-label text-muted-foreground`,children:[`Created as `,(0,Q.jsx)(`strong`,{children:`private`}),` under `,(0,Q.jsx)(`strong`,{children:w}),` — you can change its visibility on GitHub.`]}):null]}),(0,Q.jsxs)(`div`,{"data-slot":`create-start`,className:`grid gap-3 rounded-md border border-border p-3 md:flex md:min-h-0 md:flex-1 md:flex-col`,children:[(0,Q.jsx)(`span`,{id:`create-start-label`,className:`text-sm font-medium`,children:`Start with`}),(0,Q.jsxs)(`div`,{role:`radiogroup`,"aria-labelledby":`create-start-label`,className:`grid gap-2 sm:grid-cols-2`,children:[(0,Q.jsx)(yf,{slot:`create-start-empty`,checked:!j,disabled:P,title:`Empty repository`,hint:`One empty commit, no files.`,onSelect:()=>f(`empty`)}),(0,Q.jsx)(yf,{slot:`create-start-template`,checked:j,disabled:P||!T,title:`From a template`,hint:T?`Copy a GitHub template.`:`Needs a GitHub repository.`,onSelect:()=>f(`template`)})]}),j?(0,Q.jsxs)(`div`,{className:`grid gap-1.5 md:flex md:min-h-0 md:flex-1 md:flex-col`,children:[(0,Q.jsx)(lf,{htmlFor:`create-template`,children:`Template`}),(0,Q.jsx)(hf,{id:`create-template`,value:l,disabled:P,onChange:u})]}):null]}),P?(0,Q.jsx)(`p`,{"data-slot":`create-progress`,className:`truncate font-mono text-meta text-muted-foreground`,children:p??`Starting…`}):null,_.isError?(0,Q.jsx)(`p`,{"data-slot":`create-error`,className:`whitespace-pre-line text-ui text-danger`,children:_.error instanceof Error?_.error.message:`could not create the project`}):null]})]}),(0,Q.jsxs)(Br,{children:[(0,Q.jsx)(J,{variant:`outline`,disabled:P,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(J,{"data-slot":`create-confirm`,disabled:!D||P||M||i&&g.isPending,onClick:N,children:P?`Creating…`:`Create`})]})]})})}function vf({owners:e,value:t,disabled:n,onChange:r}){let i=(0,Z.useRef)([]),a=(t,n)=>{if(e.length===0)return;let a=(t+n+e.length)%e.length,o=e[a]?.login;o!==void 0&&(r(o),i.current[a]?.focus())};return(0,Q.jsxs)(`div`,{className:`grid gap-3 md:flex md:min-h-0 md:flex-1 md:flex-col`,children:[(0,Q.jsx)(`span`,{id:`create-owner-label`,className:`eyebrow text-muted-foreground`,children:`Select organization`}),(0,Q.jsx)(`div`,{role:`radiogroup`,"aria-labelledby":`create-owner-label`,"data-slot":`create-owner`,className:`-mx-1 grid max-h-64 content-start gap-2 overflow-y-auto px-1 py-0.5 md:max-h-none md:min-h-0 md:flex-1`,children:e.map((e,o)=>{let s=e.login===t;return(0,Q.jsxs)(`button`,{ref:e=>{i.current[o]=e},type:`button`,role:`radio`,"aria-checked":s,tabIndex:s?0:-1,disabled:n,"data-slot":`create-owner-option`,"data-owner":e.login,onClick:()=>r(e.login),onKeyDown:e=>{e.key===`ArrowDown`||e.key===`ArrowRight`?(e.preventDefault(),a(o,1)):(e.key===`ArrowUp`||e.key===`ArrowLeft`)&&(e.preventDefault(),a(o,-1))},className:W(`flex w-full items-center gap-3 rounded-lg border bg-card px-3 py-2.5 text-left outline-none transition-colors`,`focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,s?`border-primary bg-primary/5`:`border-border hover:bg-muted/50`),children:[(0,Q.jsx)(xf,{owner:e}),(0,Q.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 truncate text-sm font-semibold`,children:[e.login,s?(0,Q.jsx)(qs,{className:`size-4 shrink-0 text-primary`,"aria-hidden":`true`}):null]}),e.personal?(0,Q.jsx)(`span`,{className:`text-label text-muted-foreground`,children:`Personal account`}):e.description?(0,Q.jsx)(`span`,{className:`line-clamp-2 text-label text-muted-foreground`,children:e.description}):null]})]},e.login)})})]})}function yf({slot:e,checked:t,disabled:n,title:r,hint:i,onSelect:a}){return(0,Q.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,disabled:n,"data-slot":e,onClick:a,className:W(`grid gap-0.5 rounded-md border px-3 py-2 text-left outline-none transition-colors`,`focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50`,t?`border-primary bg-primary/5`:`border-border hover:bg-muted/50`),children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:r}),(0,Q.jsx)(`span`,{className:`text-label text-muted-foreground`,children:i})]})}function bf(){return(0,Q.jsxs)(`div`,{className:`grid gap-3`,"data-slot":`create-owners-loading`,"aria-hidden":`true`,children:[(0,Q.jsx)(`span`,{className:`eyebrow text-muted-foreground`,children:`Select organization`}),[0,1].map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-border px-3 py-2.5`,children:[(0,Q.jsx)(`span`,{className:`size-9 shrink-0 animate-pulse rounded-full bg-muted`}),(0,Q.jsx)(`span`,{className:`h-3 w-24 animate-pulse rounded bg-muted`})]},e))]})}function xf({owner:e}){let[t,n]=(0,Z.useState)(!1),r=e.personal?`rounded-full`:`rounded-md`;return e.avatarUrl&&!t?(0,Q.jsx)(`img`,{src:e.avatarUrl,alt:``,width:36,height:36,loading:`lazy`,onError:()=>n(!0),"data-slot":`create-owner-avatar`,className:W(`size-9 shrink-0 bg-muted`,r)}):(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:W(`flex size-9 shrink-0 items-center justify-center bg-muted text-sm font-semibold text-muted-foreground uppercase`,r),children:e.login.slice(0,1)})}var Sf=class extends Z.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e){console.error(`[cezar] ${this.props.label} failed to render`,e),Y(`${this.props.label} failed to open: ${e instanceof Error?e.message:String(e)}`,{tone:`danger`}),this.props.onError()}render(){return this.state.failed?null:this.props.children}};function Cf(e){return(0,Q.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,...e,children:(0,Q.jsx)(`path`,{d:`M12 1.9a10.1 10.1 0 0 0-3.2 19.7c.5.1.7-.2.7-.5v-1.8c-2.8.6-3.4-1.2-3.4-1.2-.5-1.2-1.1-1.5-1.1-1.5-.9-.6.1-.6.1-.6 1 .1 1.5 1 1.5 1 .9 1.6 2.4 1.1 3 .9.1-.7.4-1.1.6-1.4-2.2-.3-4.6-1.1-4.6-5 0-1.1.4-2 1-2.7-.1-.3-.4-1.3.1-2.7 0 0 .9-.3 2.8 1a9.6 9.6 0 0 1 5 0c1.9-1.3 2.8-1 2.8-1 .5 1.4.2 2.4.1 2.7.6.7 1 1.6 1 2.7 0 3.9-2.4 4.7-4.6 5 .4.3.7.9.7 1.9v2.8c0 .3.2.6.7.5A10.1 10.1 0 0 0 12 1.9z`})})}var wf=[{to:`/`,label:`Tasks`,icon:Bl,match:[`/`,`/tasks`,`/compare`],badge:`tasks-unread`},{to:`/inbox`,label:`Inbox`,icon:Il,match:[`/inbox`],badge:`inbox-count`,inbox:!0},{to:`/git`,label:`Git`,icon:cc,match:[`/git`]},{to:`/github`,label:`GitHub`,icon:Cf,match:[`/github`],forge:!0},{to:`/tracker`,label:`Tracker`,icon:su,match:[`/tracker`],tracker:!0},{to:`/assets`,label:`Assets`,icon:ys,match:[`/assets`]},{to:`/automations`,label:`Automations`,icon:Uo,match:[`/automations`],automations:!0},{to:`/skills`,label:`Skills`,icon:Ko,match:[`/skills`],badge:`skills-update`},{to:`/workflows`,label:`Workflows`,icon:mc,match:[`/workflows`]},{to:`/settings`,label:`Settings`,icon:tu,match:[`/settings`]}];function Tf({forge:e=!1,inbox:t=!1,automations:n=!1,tracker:r}={}){return wf.filter(i=>(!i.forge||e)&&(!i.inbox||t)&&(!i.automations||n)&&(!i.tracker||r!==void 0)).map(e=>e.tracker?{...e,label:r?uu[r].label:e.label}:e)}function Ef(e,t){return t===`/`?e===`/`:e===t||e.startsWith(t+`/`)}function Df(e){let t=null;for(let n of wf)for(let r of n.match)Ef(e,r)&&(t===null||r.length>t.length)&&(t={to:n.to,length:r.length});return t?.to??null}function Of(e){let t=Df(e);return wf.find(e=>e.to===t)??null}var kf=`cez-theme`,Af=`(prefers-color-scheme: light)`,jf=`dark`;function Mf(e){return e===`light`||e===`dark`||e===`system`?e:jf}function Nf(e,t){return e===`light`||e===`system`&&t?`light`:`dark`}function Pf(){try{return Mf(localStorage.getItem(kf))}catch{return jf}}function Ff(e){try{localStorage.setItem(kf,e)}catch{}}function If(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(Af).matches}function Lf(e,t){e.classList.toggle(`light`,t===`light`),e.style.colorScheme=t}var Rf=Z.createContext(null);function zf({children:e}){let[t,n]=Z.useState(Pf),[r,i]=Z.useState(If);Z.useEffect(()=>{let e=window.matchMedia?.(Af);if(!e)return;i(e.matches);let t=e=>i(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let a=Nf(t,r);Z.useLayoutEffect(()=>{Lf(document.documentElement,a)},[a]);let o=Z.useCallback(e=>{n(e),Ff(e)},[]),s=Z.useMemo(()=>({theme:t,resolvedTheme:a,setTheme:o}),[t,a,o]);return(0,Q.jsx)(Rf.Provider,{value:s,children:e})}function Bf(){return Z.useContext(Rf)?.resolvedTheme??Nf(Pf(),If())}function Vf(){let e=Z.useContext(Rf);if(!e)throw Error(`cezar: useTheme() must be called inside <ThemeProvider>`);return e}var Hf={light:`dark`,dark:`system`,system:`light`},Uf={light:ou,dark:Kl,system:Gl},Wf={light:`light`,dark:`dark`,system:`system`};function Gf({className:e}){let{theme:t,setTheme:n}=Vf(),r=Hf[t],i=Uf[t];return(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,className:e,"data-slot":`theme-toggle`,"data-theme-pref":t,title:`Theme: ${Wf[t]}`,"aria-label":`Theme: ${Wf[t]}. Switch to ${Wf[r]}.`,onClick:()=>n(r),children:(0,Q.jsx)(i,{"aria-hidden":`true`})})}function Kf(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 qf(e){return[...e].sort((e,t)=>t.lastOpenedAt.localeCompare(e.lastOpenedAt))}function Jf(e,t){let n=Kf(t);if(n.length===0)return qf(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)),[...qf(a),...i]}function Yf(e,t,n){return t===n||t<0||n<0||t>=e.length||n>=e.length?[...e]:xi([...e],t,n)}var Xf=`regular`,Zf=[{value:`regular`,label:`Regular`},{value:`automation`,label:`Automations`},{value:`all`,label:`All`}],Qf=`cez-task-origin`;function $f(e){if(!e.deferredBinding)return e.automationId??e.automation?.automationId??e.automationTrigger?.automationId??e.automationTracker?.automationId}function ep(e,t){let n=$f(e);if(n!==void 0)return n;let r=e.dispatch?.rootRunId;if(r===void 0||r===e.id)return;let i=t(r);return i===void 0?void 0:$f(i)}function tp(e,t){return t===`all`?!0:t===`automation`?e!==void 0:e===void 0}function np(e){return e===`regular`||e===`automation`||e===`all`?e:Xf}function rp(){try{return np(localStorage.getItem(Qf))}catch{return Xf}}var ip=new Set,ap;function op(e){try{localStorage.setItem(Qf,e)}catch{ap=e}for(let e of ip)e()}function sp(){return ap??rp()}function cp(e){ip.add(e);let t=t=>{(t.key===null||t.key===`cez-task-origin`)&&e()};return window.addEventListener(`storage`,t),()=>{ip.delete(e),window.removeEventListener(`storage`,t)}}function lp(){return[Z.useSyncExternalStore(cp,sp,()=>Xf),op]}var up=`cezar:open-task-palette`;function dp(e){window.dispatchEvent(new CustomEvent(up,{detail:e}))}function fp(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function pp(){let e=U(),t=ht(),n=Z.useRef(0),r=Z.useRef(Promise.resolve()),i=Z.useMemo(()=>Kf(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}=fp(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 Pt({sidebar:s},{keepalive:!0});c===n.current&&e.setQueryData(B.uiState,t)});r.current=l.catch(t=>{Y(t instanceof Error?t.message:String(t),{tone:`danger`}),c===n.current&&e.invalidateQueries({queryKey:B.uiState})})},[e]),o=Z.useCallback(e=>{let t=Kf(e);t.length!==0&&a(t.slice(0,200))},[a]),s=Z.useCallback(()=>a(null),[a]);return{order:i,canReorder:t.data!==void 0,setOrder:o,reset:s}}var mp=`cezar:open-command-palette`;function hp(){window.dispatchEvent(new Event(mp))}function gp(e){return[...e].sort((e,t)=>Date.parse(t.createdAt)-Date.parse(e.createdAt))}function _p(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,t]of a.entries()){let n=e=>e!==void 0&&/^#?\d+$/.test(e),r=n(t)||/^(pr|issue)$/.test(t)&&n(a[e+1]),s=0;for(let e=i.indexOf(t);e!==-1;e=i.indexOf(t,e+1)){let n=e===0||!/[a-z0-9]/.test(i[e-1]??``),a=!/[a-z0-9]/.test(i[e+t.length]??``);s=Math.max(s,r&&n&&a?1:(n?1:.5)*(a?1:.8)/(1+e/48))}if(s===0)return 0;o+=s}return o/a.length}var vp=e=>({pullRequestUrl:e.pullRequestUrl,referencedPullRequestUrl:e.referencedPullRequestUrl,referencedPrCandidates:e.referencedPrCandidates,prNumber:e.prNumber,prRefs:e.prRefs,issueNumber:e.issueNumber,referencedIssueUrl:e.referencedIssueUrl,referencedIssueCandidates:e.referencedIssueCandidates,markerRefs:e.markerRefs});function yp(e,t,n){let r=gp(e).map(e=>({projectId:t,id:e.id,title:e.title,titleSummary:e.titleSummary,titleOrigin:e.titleOrigin,status:e.status,activity:e.activity,createdAt:e.createdAt,finishedAt:e.finishedAt,seenAt:e.seenAt,archived:e.archived,autoResumeAt:e.autoResumeAt,awaitingAnswerSince:e.awaitingAnswerSince,idleClosedAt:e.idleClosedAt,workflow:e.workflow,branch:e.branch,startedAt:e.startedAt,lastActivityAt:p(e),...jp(vp(e)),...jp({automationId:$f(e),dispatch:e.dispatch&&{rootRunId:e.dispatch.rootRunId,parentRunId:e.dispatch.parentRunId,kind:e.dispatch.kind}})})),i=new Set(r.map(Mp)),a=(n??[]).filter(e=>!i.has(Mp(e))).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),o=[...r,...a],s=new Map(o.map(e=>[e.id,e]));return o.map(e=>{if(e.automationId!==void 0)return e;let t=ep(e,e=>s.get(e));return t===void 0?e:{...e,automationId:t}})}var bp=`w-12 text-right`;function xp({label:e}){return(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,Q.jsxs)(`span`,{"aria-hidden":`true`,className:`flex shrink-0 gap-1 text-meta font-normal`,children:[(0,Q.jsx)(`span`,{className:W(bp,`after:content-['Updated']`)}),(0,Q.jsx)(`span`,{className:W(bp,`after:content-['Created']`)})]})]})}function Sp(e){return e.status===`running`&&e.activity!==`monitoring`}function Cp(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:Tp().format(t)}var wp,Tp=()=>wp??=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`});function Ep(e,t,n=new Map){return e.map(e=>{let r=Ve(e),i=ce(e,e.projectId===null?void 0:n.get(e.projectId)),a=i.map(e=>`${e.kind} #${e.number}`).join(` `),o=e.projectId===null?null:t.get(e.projectId)??null;return{task:e,key:Mp(e),label:r,references:a,refList:i,value:`task ${r} ${a} ${e.id}`,keywords:[...o?[o]:[],...e.automationId?[`automation`,`automatic`]:[]],projectName:o,title:`${Sp(e)?`Working now`:`Updated ${Cp(e.lastActivityAt)}`} · created ${Cp(e.createdAt)}`}})}function Dp(e,t,n=50){if(t.trim()===``)return{shown:e.slice(0,n),total:e.length};let r=[];return e.forEach((e,n)=>{let i=_p(e.value,t,e.keywords);i>0&&r.push({entry:e,score:i,index:n})}),r.sort((e,t)=>t.score-e.score||e.index-t.index),{shown:r.slice(0,n).map(e=>e.entry),total:r.length}}function Op({entries:e,children:t}){let n=Lt(),r=Z.useMemo(()=>e.flatMap(e=>e.refList.map(t=>({projectId:e.task.projectId??n??``,kind:t.kind,number:t.number}))).filter(e=>e.projectId!==``),[e,n]),i=r.map(e=>`${e.projectId} ${e.kind}#${e.number}`).join(`|`),a=Z.useRef(r);a.current=r;let[o,s]=Z.useState(r);return Z.useEffect(()=>{let e=setTimeout(()=>s(a.current),250);return()=>clearTimeout(e)},[i]),(0,Q.jsx)(Ur,{projectId:n,requests:o,children:t})}var kp=`[&_[cmdk-group-items]]:flex [&_[cmdk-group-items]]:flex-col`;function Ap({hidden:e}){return e<=0?null:(0,Q.jsxs)(Bi,{forceMount:!0,disabled:!0,value:`__more-tasks`,"data-slot":`palette-more-tasks`,className:`order-last py-1.5! text-xs text-soft-foreground data-[disabled=true]:opacity-100`,children:[e,` more — keep typing to narrow`]})}function jp(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}var Mp=e=>`${e.projectId??``}/${e.id}`;function Np(e){let t=e.filter(e=>$o(e)).sort((e,t)=>(t.finishedAt??``).localeCompare(e.finishedAt??``)),n=new Set(t.map(Mp));return{recentlyFinished:t,otherTasks:e.filter(e=>!n.has(Mp(e)))}}function Pp(e,t,n=[]){let r=Jf(e,n);return[...r.filter(e=>e.id!==t),...r.filter(e=>e.id===t)]}function Fp(){let e=kr(),t=a(),n=C(),r=t.data,i=r?.bootProject??n.data?.bootProject??null,o=se(e,i),s=r!==void 0&&r.projects.length>1,c=Se(s),l=c.data?.referenceStatuses;Z.useEffect(()=>{l&&Nt(l)},[l]);let u=Z.useMemo(()=>new Map((r?.projects??[]).map(e=>[e.id,e.name])),[r]),d=(e==="default"?null:e)??i,f=Z.useMemo(()=>yp(o.data??[],d,c.data?.runs),[o.data,d,c.data]),p=We();return{activeProjectId:e,registry:r,health:n,multiProject:s,projectNames:u,repoBases:Z.useMemo(()=>{let e=new Map;for(let t of r?.projects??[])t.repoUrl&&e.set(t.id,t.repoUrl);return d&&p&&!e.has(d)&&e.set(d,p),e},[r,d,p]),runsProjectId:d,tasks:f}}function Ip(e,t=``){let n=`/tasks/${e.id}${t}`;return e.projectId===null?n:_r(e.projectId,n)}var Lp=`cezar:palette-opened`;function Rp(e){window.dispatchEvent(new CustomEvent(Lp,{detail:e}))}function zp(e,t,n){Z.useEffect(()=>{t&&Rp(e)},[t,e]),Z.useEffect(()=>{let t=t=>{t.detail!==e&&n()};return window.addEventListener(Lp,t),()=>window.removeEventListener(Lp,t)},[e,n])}function Bp(){let[e,t]=Z.useState(!1),n=vr();Fo(`k`,()=>t(e=>!e));let r=Z.useCallback(()=>{t(!1),n(`/new`)},[n]);Fo(`n`,r),go(`c`,r),Z.useEffect(()=>{let e=()=>t(!0);return window.addEventListener(mp,e),()=>window.removeEventListener(mp,e)},[]);let i=Z.useCallback(()=>t(!1),[]);return zp(`command`,e,i),Z.useEffect(()=>{e&&Ls(`command`)},[e]),(0,Q.jsx)(Ii,{open:e,onOpenChange:e=>{e||ts(`command`),t(e)},title:`Command palette`,description:`Search projects, tasks, views, actions, and skills`,showCloseButton:!1,filter:_p,commandProps:{onKeyDown:Z.useCallback(e=>{if(e.key!==`Tab`||e.shiftKey||e.altKey||e.metaKey||e.ctrlKey)return;let n=e.currentTarget.querySelector(`[cmdk-item][data-selected="true"][data-slot="palette-task"]`),r=n?.dataset.runId;r&&(e.preventDefault(),Xo(`cmdk_tab`),t(!1),dp({runId:r,projectId:n.dataset.projectId??null}))},[])},className:`top-[10vh] translate-y-0 sm:max-w-2xl lg:max-w-3xl xl:max-w-4xl`,children:(0,Q.jsx)(Hp,{close:i})})}var Vp=Z.memo(function({entry:e,showProject:t,now:n,onSelect:r,slot:i=`palette-task`,current:a=!1}){let{task:s,label:c,projectName:l}=e,u=o(s),d=s.projectId?e.refList[0]:void 0;return(0,Q.jsxs)(Bi,{value:e.value,keywords:e.keywords,"data-slot":i,"data-run-id":s.id,"data-project-id":s.projectId??void 0,onSelect:()=>r(s),children:[(0,Q.jsx)(Jc,{tone:u.tone,pulse:u.pulse,"aria-label":u.label,role:`img`}),d&&s.projectId?(0,Q.jsx)(`span`,{"data-slot":`palette-task-refs`,className:`flex shrink-0 items-center gap-1 [&_svg]:size-3!`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,Q.jsx)(Ca,{run:s,projectId:s.projectId,reference:d,compact:!0,className:`h-auto shrink-0 gap-[2px] px-1.5 py-px text-micro`})}):null,(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:c,children:Ne(c,d?.number)?qe(c).rest:c}),s.automationId?(0,Q.jsxs)(`span`,{"data-slot":`palette-task-automation`,title:`Started by an automation`,className:`flex shrink-0 items-center gap-0.5 text-xs text-soft-foreground`,children:[(0,Q.jsx)(Uo,{"aria-hidden":`true`,className:`size-3!`}),`auto`]}):null,t&&l?(0,Q.jsx)(`span`,{"data-slot":`palette-task-project`,className:`shrink-0 truncate text-xs text-soft-foreground`,children:l}):null,a?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-primary`,children:`open`}):null,(0,Q.jsxs)(`span`,{"data-slot":`palette-task-age`,title:e.title,className:`flex shrink-0 gap-1 text-xs tabular-nums`,children:[(0,Q.jsx)(`span`,{"data-slot":`palette-task-updated`,className:W(bp,`text-muted-foreground`),children:Sp(s)?`now`:Xc(s.lastActivityAt,n)}),(0,Q.jsx)(`span`,{"data-slot":`palette-task-created`,className:W(bp,`text-soft-foreground`),children:Xc(s.createdAt,n)})]})]})});function Hp({close:e}){let t=vr(),n=Nr(),[r,i]=Z.useState(``),a=r.trim()!==``,o=Z.useRef(new Set);Z.useEffect(()=>{for(let e of As(r))o.current.add(e)},[r]),Z.useEffect(()=>()=>Ms(o.current),[]);let{theme:s,setTheme:c}=Vf(),{activeProjectId:l,registry:u,health:d,multiProject:f,projectNames:p,repoBases:m,tasks:h}=Fp(),g=sc(),_=ie(),v=Ft(),[y]=Z.useState(Date.now),{order:b}=pp(),x=Z.useMemo(()=>f&&u?Pp(u.projects,l,b):[],[f,u,l,b]),S=Z.useMemo(()=>{let{recentlyFinished:e,otherTasks:t}=Np(h);return{all:Ep(h,p,m),recentlyFinished:Ep(e,p,m),otherTasks:Ep(t,p,m)}},[h,p,m]),C=a?{shown:[],total:0}:Dp(S.recentlyFinished,``,20),w=Dp(a?S.all:S.otherTasks,r),T=f,E=v.data?.skillUsage,D=Z.useMemo(()=>fo(_.data??[],E),[_.data,E]),O=n=>{e(),t(n)},k=t=>{e(),n(t)},A=n=>{e(),t(_r(n,`/`))},j=Z.useCallback(n=>{Xo(`cmdk`),e(),t(Ip(n))},[e,t]),M=Hf[s];return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Mi,{placeholder:`Search projects, tasks, views, actions, skills…`,value:r,onValueChange:i}),(0,Q.jsxs)(Li,{className:`max-h-[55vh] min-h-[14rem] sm:max-h-[60vh] lg:max-h-[68vh]`,children:[(0,Q.jsx)(Wi,{children:`Nothing matches.`}),(0,Q.jsx)(ji,{children:(0,Q.jsxs)(Bi,{value:`new task`,"data-slot":`palette-view`,"data-nav-to":`/new`,onSelect:()=>O(`/new`),children:[(0,Q.jsx)(xc,{"aria-hidden":`true`}),`New task`,(0,Q.jsx)(Ni,{children:`C`})]})}),(0,Q.jsxs)(Op,{entries:[...C.shown,...w.shown],children:[!a&&C.shown.length>0?(0,Q.jsxs)(ji,{heading:(0,Q.jsx)(xp,{label:`Recently finished`}),className:kp,children:[C.shown.map(e=>(0,Q.jsx)(Vp,{entry:e,showProject:T,now:y,onSelect:j},e.key)),(0,Q.jsx)(Ap,{hidden:C.total-C.shown.length})]}):null,(0,Q.jsxs)(ji,{heading:`Views`,children:[f?(0,Q.jsxs)(Bi,{value:`view All tasks`,"data-slot":`palette-view`,"data-nav-to":`/tasks`,onSelect:()=>k(`/tasks`),children:[(0,Q.jsx)(ys,{"aria-hidden":`true`}),`All tasks`]}):null,Tf({forge:g!=null,inbox:d.data?.capabilities.followups===!0,automations:d.data?.capabilities.automations===!0,tracker:u?.projects.find(e=>e.id===(l??u.bootProject))?.tracker}).map(e=>{let t=e.icon;return(0,Q.jsxs)(Bi,{value:`view ${e.label}`,"data-slot":`palette-view`,"data-nav-to":e.to,onSelect:()=>O(e.to),children:[(0,Q.jsx)(t,{"aria-hidden":`true`}),e.label]},e.to)}),(0,Q.jsxs)(Bi,{value:`view global settings`,"data-slot":`palette-view`,"data-nav-to":`/settings/global`,onSelect:()=>k(`/settings/global`),children:[(0,Q.jsx)(tu,{"aria-hidden":`true`}),`Global settings`]})]}),x.length>0?(0,Q.jsx)(ji,{heading:`Projects`,children:x.map(e=>{let t=e.id===l,n=e.status===`missing`;return(0,Q.jsxs)(Bi,{value:`project ${e.name} ${e.id}`,keywords:[e.root],"data-slot":`palette-project`,"data-project-id":e.id,disabled:n,onSelect:()=>A(e.id),children:[(0,Q.jsx)(kl,{"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)(Rs,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},e.id)})}):null,w.shown.length>0?(0,Q.jsxs)(ji,{heading:(0,Q.jsx)(xp,{label:`Tasks`}),className:kp,children:[w.shown.map(e=>(0,Q.jsx)(Vp,{entry:e,showProject:T,now:y,onSelect:j},e.key)),(0,Q.jsx)(Ap,{hidden:w.total-w.shown.length})]}):null]}),(0,Q.jsx)(ji,{heading:`Actions`,children:(0,Q.jsxs)(Bi,{value:`action toggle theme`,"data-slot":`palette-action`,"data-action":`toggle-theme`,onSelect:()=>{c(M),e()},children:[(0,Q.jsx)(Kl,{"aria-hidden":`true`}),`Toggle theme`,(0,Q.jsxs)(Ni,{className:`tracking-normal`,children:[s,` → `,M]})]})}),D.length>0?(0,Q.jsx)(ji,{heading:`Skills`,children:D.map(e=>(0,Q.jsxs)(Bi,{value:`skill ${e.name} ${e.path}`,keywords:e.description?[e.description]:void 0,"data-slot":`palette-skill`,"data-skill":e.name,onSelect:()=>O(`/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))}):null]})]})}function Up({className:e}){return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`command-palette-hint`,title:`Search — command palette (⌘K / Ctrl+K)`,onClick:()=>hp(),className:W(`flex w-full items-center gap-1.5 rounded-md border border-border bg-muted/30 px-2 py-1 text-left text-xs font-medium text-soft-foreground transition-colors hover:bg-muted hover:text-foreground`,e),children:[(0,Q.jsx)(Cc,{className:`size-3.5 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 rounded-[5px] border border-b-2 border-border bg-card px-[5px] py-px font-mono text-micro font-medium text-muted-foreground`,children:ho(`k`)})]})}function Wp(e){let t=Er(e);return t===`/settings`||t.startsWith(`/settings/`)}var Gp=`https://github.com/open-mercato/cezar`,Kp=`cez:star-toast-seen`;function qp(e){if(!Number.isFinite(e)||e<0)return`0`;let t=Math.floor(e);if(t<1e3)return String(t);let n=t/1e3,r=Math.floor(n*10)/10;return r<100?`${r.toFixed(1).replace(/\.0$/,``)}k`:`${Math.floor(n)}k`}var Jp=`cez:star-ask`,Yp=1500;function Xp(e=tm()){if(!e)return null;try{let t=e.getItem(Jp);if(t!==null){let e=JSON.parse(t);return{asks:Number.isInteger(e.asks)&&e.asks>=0?e.asks:3,...typeof e.lastAskedAt==`string`?{lastAskedAt:e.lastAskedAt}:{},...e.outcome===`starred`||e.outcome===`never`?{outcome:e.outcome}:{}}}let n=e.getItem(Kp);return n===null?{asks:0}:{asks:1,lastAskedAt:n}}catch{return null}}function Zp(e,t=tm()){try{t?.setItem(Jp,JSON.stringify(e))}catch{}}function Qp(e,t){if(!e||e.outcome||e.asks>=3)return!1;if(!e.lastAskedAt)return!0;let n=Date.parse(e.lastAskedAt);return!Number.isFinite(n)||t-n>=12096e5}function $p(e){return(e??[]).filter(e=>nm.has(e.status)).length}function em(e){return e.visible&&e.focused&&!e.typing&&!e.dialogOpen&&e.now-e.lastInteractionAt>=0&&e.now-e.lastInteractionAt<=6e4}function tm(){try{return globalThis.localStorage??null}catch{return null}}var nm=new Set([`done`,`review`]);function rm(e,t){let n=new Map,r=!1,i=!1;for(let a of t??[]){n.set(a.id,a.status);let t=e.get(a.id);t===void 0||t===a.status||nm.has(a.status)&&(r=!0,a.pullRequestUrl&&(i=!0))}return{succeeded:r,withPullRequest:i,statuses:n}}var im=[`354.6,217.3 511.0,307.6 421.0,359.6 354.6,321.2 267.9,371.2 267.9,471.3 444.6,573.3 354.6,625.3 177.9,523.3 177.9,319.3`,`177.9,284.6 354.6,182.6 354.6,78.7 177.9,180.7`,`354.6,372.3 397.0,396.8 397.0,445.8 354.6,470.3 312.1,445.8 312.1,396.8`,`483.7,372.3 526.1,396.8 526.1,445.8 483.7,470.3 441.2,445.8 441.2,396.8`],am={x:177.9,y:78.7,width:348.2,height:546.6},om={mark:26,name:19,gap:11.4};function sm({height:e=om.mark,className:t}){return(0,Q.jsx)(`svg`,{"data-slot":`brand-mark`,"aria-hidden":`true`,focusable:`false`,viewBox:`${am.x} ${am.y} ${am.width} ${am.height}`,height:e,width:e*am.width/am.height,fill:`currentColor`,className:W(`shrink-0`,t),children:im.map(e=>(0,Q.jsx)(`polygon`,{points:e},e))})}function cm({className:e,name:t=`cezar`,logoUrl:n=null}){return(0,Q.jsxs)(`span`,{"data-slot":`brand-lockup`,className:W(`flex min-w-0 items-center text-foreground`,e),style:{gap:om.gap},children:[n?(0,Q.jsx)(`img`,{"data-slot":`brand-logo`,src:n,alt:``,className:`size-[26px] shrink-0 object-contain`}):(0,Q.jsx)(sm,{}),(0,Q.jsx)(`span`,{"data-slot":`brand-name`,className:W(`max-w-full truncate leading-none font-semibold tracking-normal`,t===`cezar`&&`lowercase`),style:{fontFamily:`var(--brand)`,fontSize:om.name},children:t})]})}function lm({...e}){return(0,Q.jsx)(Nu,{"data-slot":`select`,...e})}function um({...e}){return(0,Q.jsx)(Lu,{"data-slot":`select-value`,...e})}function dm({className:e,size:t=`default`,children:n,...r}){return(0,Q.jsxs)(Fu,{"data-slot":`select-trigger`,"data-size":t,className:W(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-card px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none 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-9 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 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)(zu,{asChild:!0,children:(0,Q.jsx)(Ws,{className:`size-4 opacity-50`})})]})}function fm({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,Q.jsx)(Uu,{children:(0,Q.jsxs)(Gu,{"data-slot":`select-content`,className:W(`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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 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)(mm,{}),(0,Q.jsx)(od,{className:W(`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)(hm,{})]})})}function pm({className:e,children:t,...n}){return(0,Q.jsxs)(gd,{"data-slot":`select-item`,className:W(`relative flex w-full cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-8 pl-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 right-2 flex size-3.5 items-center justify-center`,children:(0,Q.jsx)(bd,{children:(0,Q.jsx)(Rs,{className:`size-4`})})}),(0,Q.jsx)(vd,{children:t})]})}function mm({className:e,...t}){return(0,Q.jsx)(Sd,{"data-slot":`select-scroll-up-button`,className:W(`flex cursor-pointer items-center justify-center py-1`,e),...t,children:(0,Q.jsx)(vl,{className:`size-4`})})}function hm({className:e,...t}){return(0,Q.jsx)(wd,{"data-slot":`select-scroll-down-button`,className:W(`flex cursor-pointer items-center justify-center py-1`,e),...t,children:(0,Q.jsx)(Ws,{className:`size-4`})})}function gm(e){return/^\d/.test(e)&&!e.includes(`+`)?`v${e}`:e}function _m(e,t){return!!t&&e.activeRuns>0&&e.scheduled?.target!==t}function vm({label:e=`Update when idle`,doing:t,onClick:n,disabled:r}){return(0,Q.jsx)(kc,{delayDuration:300,children:(0,Q.jsxs)(Ac,{children:[(0,Q.jsx)(Dc,{asChild:!0,children:(0,Q.jsx)(J,{variant:`outline`,size:`sm`,onClick:n,disabled:r,children:e})}),(0,Q.jsxs)(Oc,{"data-slot":`update-when-idle-tooltip`,side:`bottom`,className:`max-w-64`,children:[`Waits until no task is running or queued, then `,t,` and restarts. Tasks waiting on your reply don't hold it up. You can close this window and keep working.`]})]})})}function ym(e){let t=/-pr(\d+)\./.exec(e);return t?Number(t[1]):null}function bm({data:e,onApply:t,onSchedule:n,applying:r}){let i=Pe(),a=ft(),[o,s]=(0,Z.useState)(`worktrees`),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(!1),m=e.job?.status===`running`||e.job?.status===`restarting`,h=e.installed.find(e=>e.active),g=i.data?.checkouts??[],_=i.data?.pulls,v=!i.data||g.length>0,y=v?o:`pulls`,b=c.trim().toLowerCase(),x=(0,Z.useMemo)(()=>g.filter(e=>!b||[e.branch,e.task?.title,e.task?.id,e.commit?.subject,e.worktree,e.pr?`#${e.pr}`:``].filter(Boolean).some(e=>e.toLowerCase().includes(b))),[g,b]),S=(0,Z.useMemo)(()=>(_?.items??[]).filter(e=>!e.version&&!f?!1:!b||[`#${e.number}`,String(e.number),e.title,e.branch,e.author??``].some(e=>e.toLowerCase().includes(b))),[_,b,f]),C=(_?.items??[]).filter(e=>!e.version).length,w=y===`worktrees`?g.find(e=>e.id===u):void 0,T=y===`pulls`?_?.items.find(e=>e.version&&e.version===u):void 0,E=w?.id??T?.version??null,D=!!w&&(!w.built||w.stale),O=!!E&&E===h?.id&&!D,k=T&&!T.installed?`Install & restart`:D?`${w.built?`Rebuild`:`Build`} & ${w.id===h?.id?`restart`:`switch`}`:`Switch & restart`;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)(`div`,{role:`tablist`,"aria-label":`Development builds`,className:`flex rounded-md border border-border bg-muted/40 p-0.5`,children:[...v?[{value:`worktrees`,label:`Worktrees`,count:g.length}]:[],{value:`pulls`,label:`Pull requests`,count:(_?.items.length??0)-C}].map(e=>(0,Q.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":y===e.value,onClick:()=>{s(e.value),d(null)},className:W(`rounded-[5px] px-3 py-1 text-label font-semibold transition-colors`,y===e.value?`bg-card text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:[e.label,i.data?(0,Q.jsx)(`span`,{className:`ml-1.5 font-normal text-muted-foreground`,children:e.count}):null]},e.value))}),(0,Q.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>a.mutate(),disabled:a.isPending||i.isFetching,children:a.isPending?`Refreshing…`:`Refresh`})]}),(0,Q.jsx)(Kc,{"aria-label":`Filter`,value:c,onChange:e=>l(e.target.value),placeholder:y===`worktrees`?`Filter by task, branch, commit or #PR`:`Filter by #number, title, branch or author`,className:`h-8 text-ui`}),(0,Q.jsx)(`div`,{className:`max-h-72 min-h-24 overflow-y-auto rounded-md border border-border`,children:i.isPending?(0,Q.jsx)(`p`,{className:`px-3 py-3 text-label text-muted-foreground`,children:`Looking for worktrees and pull requests…`}):i.error?(0,Q.jsx)(`p`,{className:`px-3 py-3 text-label text-danger`,children:i.error.message}):y===`worktrees`?(0,Q.jsxs)(Q.Fragment,{children:[x.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-3 text-label text-muted-foreground`,children:`Nothing matches.`}):null,(0,Q.jsx)(`div`,{role:`listbox`,"aria-label":`Worktrees`,children:x.map(e=>(0,Q.jsx)(Sm,{checkout:e,active:e.id===h?.id,selected:u===e.id,onSelect:()=>d(e.id)},e.worktree))})]}):(0,Q.jsxs)(Q.Fragment,{children:[_&&!_.available?(0,Q.jsx)(`p`,{className:`px-3 py-2 text-label text-muted-foreground`,children:_.reason}):null,_?.available&&S.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-3 text-label text-muted-foreground`,children:_.items.length===0?`No open pull requests on ${_.repo}.`:b?`Nothing matches.`:`No open pull request has a preview build.`}):null,(0,Q.jsx)(`div`,{role:`listbox`,"aria-label":`Pull requests`,children:S.map(e=>(0,Q.jsx)(Cm,{pull:e,active:!!e.version&&e.version===h?.id,selected:!!e.version&&u===e.version,onSelect:()=>e.version&&d(e.version)},e.number))}),C>0?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>p(e=>!e),className:`w-full border-t border-border px-3 py-2 text-left text-label text-muted-foreground hover:text-foreground`,children:f?`Hide the ${C} without a preview build`:`${C} more without a preview build (forks, CI not green yet) — show`}):null]})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-meta text-muted-foreground`,title:w?.worktree,children:w?D?`${w.built?`Built before its last commit`:`Not built yet`} — runs npm run build in ${w.worktree} first (about a minute).`:w.worktree:T?`Installs ${T.version} from npm.`:y===`worktrees`?`Linked, not copied: a worktree that is not built, or built before its last commit, is built before the switch.`:`Preview builds CI publishes for green same-repo pull requests.`}),!O&&_m(e,E)?(0,Q.jsx)(vm,{label:`When idle`,doing:T?`${T.installed?`switches to`:`installs`} PR #${T.number}'s build`:`${D?`builds and switches to`:`switches to`} ${w.branch}`,onClick:()=>n(E),disabled:!e.canSelfUpdate||r||m}):null,(0,Q.jsx)(J,{size:`sm`,variant:`contrast`,onClick:()=>E&&t(E),disabled:!E||O||!e.canSelfUpdate||r||m,children:k})]})]})}function xm({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:W(`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-primary/10 hover:bg-primary/10`),children:i})}function Sm({checkout:e,active:t,selected:n,onSelect:r}){let i=e.task?.title??e.commit?.subject??e.branch;return(0,Q.jsxs)(xm,{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-ui font-medium`,children:i}),e.pr?(0,Q.jsxs)($d,{variant:`outline`,children:[`#`,e.pr]}):null,t?(0,Q.jsx)($d,{variant:`secondary`,children:`current`}):null,e.built?e.stale?(0,Q.jsx)($d,{variant:`outline`,children:`needs rebuild`}):null:(0,Q.jsx)($d,{variant:`outline`,children:`not built`})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-meta 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:``,` · `,Xc(e.commit.at),` ago`]}):null,e.builtAt?(0,Q.jsxs)(`span`,{className:`shrink-0`,children:[`· built `,Xc(e.builtAt),` ago`]}):null]})]})}function Cm({pull:e,active:t,selected:n,onSelect:r}){return(0,Q.jsxs)(xm,{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-ui text-muted-foreground`,children:[`#`,e.number]}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-ui font-medium`,children:e.title}),e.draft?(0,Q.jsx)($d,{variant:`outline`,children:`draft`}):null,t?(0,Q.jsx)($d,{variant:`secondary`,children:`current`}):e.version?e.installed?(0,Q.jsx)($d,{variant:`outline`,children:`installed`}):null:(0,Q.jsx)($d,{variant:`outline`,children:`no build`})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-meta 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 `,Xc(e.updatedAt),` ago`]}),e.version?(0,Q.jsxs)(`span`,{className:`shrink-0`,children:[`· build `,e.publishedAt?`${Xc(e.publishedAt)} ago`:e.version]}):null]})]})}function wm({open:e,onOpenChange:t,autoApply:n,brandName:r=`cezar`}){let i=j(e),a=yn(),o=k(),s=an(),c=m(),l=Dt(),[u,d]=(0,Z.useState)(``),f=i.data,p=(0,Z.useRef)(null),h=(0,Z.useRef)(!1);return(0,Z.useEffect)(()=>{!n||h.current||!f||!f.canSelfUpdate||f.job||(h.current=!0,!(f.activeRuns>0)&&s.mutate(n))},[n,f,s]),(0,Q.jsx)(qr,{open:e,onOpenChange:e=>{!e&&f?.job?.status===`running`||t(e)},children:(0,Q.jsxs)(Wr,{"data-slot":`self-update-dialog`,className:`sm:max-w-xl`,ref:p,onOpenAutoFocus:e=>{e.preventDefault(),p.current?.focus()},children:[(0,Q.jsxs)(Lr,{children:[(0,Q.jsxs)(Zr,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`span`,{children:[r,` `,f?`v${f.version}`:``]}),(0,Q.jsx)(Am,{data:f})]}),(0,Q.jsxs)(Vr,{className:`sr-only`,children:[`Update `,r,`, pick a release channel or switch versions.`]})]}),f?(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-5`,children:[(0,Q.jsx)(Dm,{data:f,busy:o.isPending,onChange:e=>{d(``),o.mutate(e)}}),(0,Q.jsx)(Om,{data:f,checking:a.isPending,onCheck:()=>a.mutate(),onApply:e=>s.mutate(e),onSchedule:e=>c.mutate(e),applying:s.isPending||c.isPending}),f.channel===`development`?(0,Q.jsx)(bm,{data:f,onApply:e=>s.mutate(e),onSchedule:e=>c.mutate(e),applying:s.isPending||c.isPending}):(0,Q.jsx)(km,{data:f,picked:u,onPick:d,onApply:e=>s.mutate(e),onSchedule:e=>c.mutate(e),applying:s.isPending||c.isPending}),f.canSelfUpdate?null:(0,Q.jsx)(jm,{data:f}),f.scheduled?(0,Q.jsxs)(`div`,{"data-slot":`self-update-scheduled`,className:`flex items-center justify-between gap-3 rounded-md border border-primary/40 bg-primary/5 px-3 py-2 text-label`,children:[(0,Q.jsxs)(`p`,{className:`min-w-0`,children:[r,` switches to `,(0,Q.jsx)(`span`,{className:`font-semibold`,children:gm(f.scheduled.target)}),` as soon as no task is running. You can close this window and keep working.`]}),(0,Q.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>l.mutate(),disabled:l.isPending,children:`Cancel`})]}):f.activeRuns>0&&f.canSelfUpdate?(0,Q.jsxs)(`p`,{className:`rounded-md border border-pending/50 bg-pending/10 px-3 py-2 text-label text-foreground`,children:[f.activeRuns,` task`,f.activeRuns===1?` is`:`s are`,` running. A restart interrupts them; `,r,` re-queues or resumes them on the way back up.`,` `,`The “when idle” buttons wait for them to finish instead.`]}):null,o.error?(0,Q.jsxs)(`p`,{className:`text-label text-danger`,children:[`Could not switch the channel: `,o.error.message,o.variables===`development`?` The running ${r} server predates the Development channel — restart ${r} to load it.`:null]}):null,s.error?(0,Q.jsx)(`p`,{className:`text-label text-danger`,children:s.error.message}):null,c.error?(0,Q.jsx)(`p`,{className:`text-label text-danger`,children:c.error.message}):null,l.error?(0,Q.jsx)(`p`,{className:`text-label text-danger`,children:l.error.message}):null,f.job?(0,Q.jsx)(Mm,{data:f}):null]}):i.error?(0,Q.jsx)(`p`,{className:`text-ui text-danger`,children:i.error.message}):null]})})}var Tm=[{value:`stable`,label:`Stable`},{value:`nightly`,label:`Nightly`},{value:`development`,label:`Development`}],Em={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 Dm({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-ui font-semibold`,children:`Release channel`}),(0,Q.jsx)(`div`,{className:`text-label text-muted-foreground`,children:Em[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:Tm.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:W(`rounded-[5px] px-3 py-1 text-label font-semibold transition-colors`,i?`bg-card text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:r.label},r.value)})})]})}function Om({data:e,checking:t,onCheck:n,onApply:r,onSchedule:i,applying:a}){let o=e.job?.status===`running`||e.job?.status===`restarting`,s=e.installed.find(e=>e.active),c=s?.source===`registry`?ym(s.version):null,l=s&&(s.source===`link`||s.source===`local`||c!==null)?s:null;if(l||e.channel===`development`){let i=e.channel===`development`?null:e.latest[e.channel],s=i!==null&&e.installed.some(e=>e.source===`registry`&&e.id===i);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-ui break-words`,children:l?.source===`link`?(0,Q.jsxs)(Q.Fragment,{children:[`Running worktree `,(0,Q.jsx)(`span`,{className:`font-mono text-label font-semibold`,children:l.branch??l.id}),`, not a release.`]}):l?.source===`local`?(0,Q.jsx)(Q.Fragment,{children:`Running a local build, not a release.`}):c===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 #`,c]}),`, not a release.`]})}),(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-meta break-words text-muted-foreground`,children:e.channel===`development`?`Switch the channel back to Stable or Nightly to follow releases again.`:e.checkedAt?(0,Q.jsxs)(Q.Fragment,{children:[i?(0,Q.jsxs)(Q.Fragment,{children:[`Newest `,e.channel,`: `,(0,Q.jsxs)(`span`,{className:`font-mono text-foreground`,children:[`v`,i]}),` ·`,` `]}):null,`checked `,new Date(e.checkedAt).toLocaleTimeString()]}):`The npm registry has not answered yet.`}),e.channel===`development`?null:(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,Q.jsx)(J,{variant:`ghost`,size:`sm`,onClick:n,disabled:t||o,children:t?`Checking…`:`Check again`}),i?(0,Q.jsx)(J,{size:`sm`,"aria-label":s?`Back to v${i}`:`Install v${i} & restart`,onClick:()=>r(i),disabled:!e.canSelfUpdate||a||o,children:s?`Switch back`:`Install & restart`}):null]})]})]})}let u=e.updateAvailable;return(0,Q.jsxs)(`div`,{"data-slot":`self-update-latest`,className:W(`flex flex-wrap items-center justify-between gap-x-3 gap-y-2 rounded-md border px-3 py-2.5`,u?`border-primary/40 bg-primary/5`:`border-border bg-card`),children:[(0,Q.jsxs)(`div`,{className:`min-w-[14rem] flex-1 text-ui break-words`,children:[e.checkedAt?u?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`font-semibold`,children:[`v`,u]}),` 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.`}),e.checkedAt?(0,Q.jsxs)(`div`,{className:`text-meta text-muted-foreground`,children:[`checked `,new Date(e.checkedAt).toLocaleTimeString()]}):null]}),(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,Q.jsx)(J,{variant:`ghost`,size:`sm`,onClick:n,disabled:t||o,children:t?`Checking…`:`Check again`}),_m(e,u)?(0,Q.jsx)(vm,{doing:`installs ${gm(u)}`,onClick:()=>i(u),disabled:!e.canSelfUpdate||a||o}):null,u?(0,Q.jsx)(J,{size:`sm`,onClick:()=>r(u),disabled:!e.canSelfUpdate||a||o,children:`Update & restart`}):null]})]})}function km({data:e,picked:t,onPick:n,onApply:r,onSchedule:i,applying:a}){let o=e.job?.status===`running`||e.job?.status===`restarting`,s=(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]),c=s.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-ui 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)(lm,{value:t,onValueChange:n,disabled:s.length===0||o,children:[(0,Q.jsx)(dm,{size:`sm`,"aria-label":`Version`,className:`w-0 min-w-0 flex-1 text-ui`,children:(0,Q.jsx)(um,{placeholder:s.length===0?`No versions known`:`Choose a version to install`})}),(0,Q.jsx)(fm,{className:`max-h-72`,children:s.map(e=>(0,Q.jsx)(pm,{value:e.value,children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e.label,e.active?(0,Q.jsx)($d,{variant:`secondary`,children:`current`}):e.installed?(0,Q.jsx)($d,{variant:`outline`,children:`installed`}):null]})},e.value))})]}),c&&!c.active&&_m(e,c.value)?(0,Q.jsx)(vm,{label:`When idle`,doing:`${c.installed?`switches to`:`installs`} ${gm(c.value)}`,onClick:()=>i(c.value),disabled:!e.canSelfUpdate||a||o}):null,(0,Q.jsx)(J,{size:`sm`,variant:`contrast`,onClick:()=>c&&r(c.value),disabled:!c||c.active||!e.canSelfUpdate||a||o,children:c?.installed?`Switch & restart`:`Install & restart`})]}),(0,Q.jsx)(`p`,{className:`text-meta text-muted-foreground`,children:`Any version, older ones included. Installed versions stay on disk, so switching back is instant.`})]})}function Am({data:e}){let t=e?.installed.find(e=>e.active);if(t?.source===`local`)return(0,Q.jsx)($d,{variant:`outline`,children:`local build`});if(t?.source===`link`)return(0,Q.jsxs)($d,{variant:`outline`,children:[`worktree · `,t.branch??t.id]});let n=t?ym(t.version):null;return n===null?null:(0,Q.jsxs)($d,{variant:`outline`,children:[`PR #`,n,` build`]})}function jm({data:e}){let t=e.installKind===`checkout`?`node packages/cezar/dist/index.js install`:e.installKind===`global-npm`?`cezar install`:`npx cezar-cli 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-label`,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-label`,children:t})]})}function Mm({data:e}){let t=e.job,n=U(),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:B.selfUpdate}),window.setTimeout(()=>window.location.reload(),400)},s=async()=>{if(!r){try{if((await en()).version!==e.version)return o();let t=await Pn().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-label`,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-meta leading-[1.5] break-all whitespace-pre-wrap text-muted-foreground`,children:t.log.join(`
|
|
3
3
|
`)}),t.error?(0,Q.jsx)(`p`,{className:`text-label text-danger`,children:t.error}):null]})}var Nm=`cez-sidebar-width`;function Pm(e){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?Math.min(420,Math.max(264,Math.round(t))):264}function Fm(){try{let e=localStorage.getItem(Nm);return e===null?264:Pm(e)}catch{return 264}}function Im(e){try{localStorage.setItem(Nm,String(Pm(e)))}catch{}}function Lm(){let[e]=Z.useState(()=>{if(typeof document>`u`)return null;let e=document.documentElement.dataset.cezDesktop;return e===`macos`||e===`windows`||e===`linux`?e:null});return e}var Rm=new Set;function zm(e){Rm.add(e);let t=t=>{t.key!==null&&t.key!==`cez-sidebar-width`||(Bm=null,e())};return window.addEventListener(`storage`,t),()=>{Rm.delete(e),window.removeEventListener(`storage`,t)}}var Bm=null;function Vm(){return Bm??Fm()}function Hm(e){let t=Pm(e);Im(t),Bm=Fm()===t?null:t;for(let e of Rm)e()}function Um(){return[Z.useSyncExternalStore(zm,Vm,Vm),Hm]}var Wm=`cez-sidebar-folded`,Gm=new Set,Km=null;function qm(){try{return localStorage.getItem(Wm)===`1`}catch{return!1}}function Jm(){return Km??qm()}function Ym(e){Gm.add(e);let t=t=>{t.key!==null&&t.key!==`cez-sidebar-folded`||(Km=null,e())};return window.addEventListener(`storage`,t),()=>{Gm.delete(e),window.removeEventListener(`storage`,t)}}function Xm(e){try{e?localStorage.setItem(Wm,`1`):localStorage.removeItem(Wm)}catch{}Km=qm()===e?null:e;for(let e of Gm)e()}function Zm(){return[Z.useSyncExternalStore(Ym,Jm,Jm),Xm]}var Qm=Sa()?`Meta+B`:`Control+B`;function $m({onFold:e,ref:t}){return(0,Q.jsx)(J,{ref:t,variant:`ghost`,size:`icon-sm`,"data-slot":`sidebar-fold`,"aria-label":`Hide sidebar`,"aria-keyshortcuts":Qm,title:`Hide sidebar (${Oa(`Mod+B`)})`,onClick:e,className:`-mr-1.5 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,Q.jsx)(Zl,{className:`size-4`,"aria-hidden":`true`})})}function eh({slot:e=`sidebar`,width:t,onWidthChange:n,titlebarInset:r=!1,children:i}){return(0,Q.jsxs)(`aside`,{"data-slot":e,style:{width:t},className:W(`relative hidden shrink-0 flex-col border-r border-border bg-sidebar md:flex`,r&&`pt-[28px]`),children:[i,(0,Q.jsx)(th,{width:t,onWidthChange:n})]})}function th({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(Pm(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(Pm(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-violet/40 focus-visible:bg-violet/60 focus-visible:outline-none`})}function nh({slot:e,title:t,children:n}){return(0,Q.jsxs)(Vi,{side:`left`,"data-slot":e,showCloseButton:!1,className:`w-[264px] gap-0 border-border bg-sidebar p-0 sm:max-w-none md:hidden`,"aria-describedby":void 0,children:[(0,Q.jsx)(zi,{className:`sr-only`,children:t}),n((0,Q.jsx)(Ri,{asChild:!0,children:(0,Q.jsx)(J,{variant:`ghost`,size:`icon`,"aria-label":`Close menu`,className:`-mr-2 size-11`,children:(0,Q.jsx)(Tc,{className:`size-[17px]`,"aria-hidden":`true`})})}))]})}var rh=[],ih=new Set;function ah(){for(let e of ih)e()}function oh(e){return ih.add(e),()=>{ih.delete(e)}}function sh(){return rh.length>0}function ch(e){let t={onExit:e};return rh.push(t),ah(),()=>{let e=rh.indexOf(t);e<0||(rh.splice(e,1),ah())}}function lh(){for(let e of[...rh])e.onExit()}function uh(){return(0,Z.useSyncExternalStore)(oh,sh,sh)}var dh=`(min-width: 768px)`,fh=Z.createContext(void 0),ph=Z.memo(function({children:e,mainRef:t}){return(0,Q.jsx)(`main`,{ref:t,"data-slot":`main`,className:`row-start-3 min-h-0 overflow-y-auto overscroll-contain`,children:e})});function mh(){return Z.useContext(fh)}var hh=new Set;function gh(e){return gr({path:`/tasks/:id`,end:!0},Er(e))!==null}var _h=Z.memo(function({children:e,repo:t=null,inboxCount:n=null,unreadCount:r=null,skillsUpdateAvailable:i=!1,newNavItems:a=hh,version:o=null,latestVersion:s=null,starCount:c=null,taskQuickList:l,hostWidget:u,whatsNew:d,toolsMenu:f,forgeAvailable:p=!0,inboxAvailable:m=!0,automationsAvailable:h=!0,tracker:g,singleProject:_=!1,banner:v,footerBanner:y,projectGroups:b,brandName:x=`cezar`,brandLogoUrl:S=null,projectSwitcher:C=null}){let{pathname:w}=jr(),T=Er(w),E=Df(T),D=Of(T),O=D?.to===`/tracker`&&g?{...D,label:uu[g].label}:D,k=Wp(w),[A,j]=Z.useState(!1),M=Z.useCallback(()=>j(!1),[]),N=Z.useRef(null),P=gh(w),[F,ee]=Um();Z.useLayoutEffect(()=>{if(P)return;let e=N.current;e&&(e.scrollTop=0)},[w,P]),Z.useEffect(()=>{j(!1)},[w]),Z.useEffect(()=>{let e=window.matchMedia?.(dh);if(!e)return;e.matches&&j(!1);let t=e=>{e.matches&&j(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let te={activeTo:E,items:Z.useMemo(()=>Tf({forge:p,inbox:m,automations:h,tracker:g}),[p,m,h,g]),repo:t,inboxCount:m?n:null,unreadCount:r,skillsUpdateAvailable:i,newNavItems:a,version:o,latestVersion:s,starCount:c,taskQuickList:l,hostWidget:u,whatsNew:d,toolsMenu:f,projectGroups:b,singleProject:_,brandName:x,brandLogoUrl:S},I=Lm(),ne=uh(),[L]=Zm(),re=!k&&(ne||L);return(0,Q.jsxs)(`div`,{"data-slot":`app-shell`,"data-desktop":I??void 0,"data-chromeless":k?``: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:[I===`macos`?(0,Q.jsx)(`div`,{"data-slot":`desktop-titlebar`,"data-tauri-drag-region":``,className:`fixed inset-x-0 top-0 z-[60] flex h-[28px] select-none items-center pl-[80px]`,children:o&&s&&s!==o?(0,Q.jsx)(vh,{latestVersion:s,brandName:x}):null}):null,k?null:ne?(0,Q.jsx)(bh,{...te,desktop:I}):(0,Q.jsx)(yh,{...te,width:F,onWidthChange:ee,desktop:I}),(0,Q.jsxs)(`div`,{className:W(`grid min-w-0 flex-1 grid-rows-[auto_auto_1fr_auto] overflow-hidden`,I===`macos`&&`pt-[28px]`),children:[k?null:(0,Q.jsxs)(Ui,{open:A,onOpenChange:j,children:[(0,Q.jsx)(Nh,{title:O?.label??x}),(0,Q.jsx)(Ch,{...te,onNavigate:M})]}),re?(0,Q.jsx)(Sh,{switcher:C,fallbackName:t?.name??x,activeTo:E}):null,v?(0,Q.jsx)(`div`,{"data-slot":`banner-slot`,className:`row-start-2`,children:v}):null,(0,Q.jsx)(ph,{mainRef:N,children:e}),(0,Q.jsx)(`div`,{"data-slot":`composer`,className:`row-start-4 pb-[env(safe-area-inset-bottom)]`,children:y})]})]})});function vh({latestVersion:e,brandName:t}){let[n,r]=Z.useState(!1);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`titlebar-update`,onClick:()=>r(!0),title:`Update ${t} to v${e} and restart`,className:`inline-flex h-[18px] items-center gap-1 rounded-full border border-primary/40 bg-primary/15 px-2 text-meta font-semibold text-foreground transition-colors hover:bg-primary/30`,children:[(0,Q.jsx)(Jc,{tone:`pending`,pulse:!0,className:`size-[5px] shrink-0`}),`Update `,t,(0,Q.jsxs)(`span`,{className:`font-mono font-medium text-muted-foreground`,children:[`v`,e]})]}),n?(0,Q.jsx)(wm,{open:n,onOpenChange:r,autoApply:e,brandName:t}):null]})}var yh=Z.memo(function({width:e,onWidthChange:t,desktop:n=null,...r}){let[i,a]=Zm(),[o,s]=Z.useState(!1),c=Z.useRef(null);Z.useEffect(()=>{o&&!i&&c.current?.focus()},[o,i]);let l=e=>{s(!0),a(e)};return Fo(`b`,()=>{if(Ya())return;let e=document.activeElement;s(!e||e===document.body||e.closest(`[data-slot="sidebar"], [data-slot="sidebar-rail"]`)!==null),a(!i)},{inEditable:!0}),i?(0,Q.jsx)(xh,{...r,slot:`sidebar-rail`,onExpand:()=>l(!1),expandTitle:`Show sidebar (${Oa(`Mod+B`)})`,expandShortcut:Qm,autoFocus:o,desktop:n}):(0,Q.jsx)(eh,{width:e,onWidthChange:t,titlebarInset:n===`macos`,children:(0,Q.jsx)(wh,{...r,compactHeader:n===`macos`,headerAction:(0,Q.jsx)($m,{ref:c,onFold:()=>l(!0)})})})});function bh({desktop:e,...t}){return Fo(`b`,()=>{Ya()||lh()},{inEditable:!0}),(0,Q.jsx)(xh,{...t,slot:`focus-sidebar-rail`,onExpand:lh,expandTitle:`Show sidebar (${Oa(`Mod+B`)}, turns Focus off)`,expandShortcut:Qm,desktop:e})}function xh({slot:e,items:t,activeTo:n,inboxCount:r,unreadCount:i,skillsUpdateAvailable:a,newNavItems:o,brandName:s,brandLogoUrl:c,onExpand:l,expandTitle:u,expandShortcut:d,autoFocus:f=!1,desktop:p}){return(0,Q.jsxs)(`aside`,{"data-slot":e,className:W(`hidden w-12 shrink-0 flex-col items-center gap-1 border-r border-border bg-sidebar pt-[max(env(safe-area-inset-top),0.75rem)] pb-[max(env(safe-area-inset-bottom),0.5rem)] md:flex`,p===`macos`&&`pt-[36px]`),children:[(0,Q.jsx)(`span`,{"data-slot":`rail-brand`,role:`img`,"aria-label":s,title:s,className:`flex h-8 items-center text-foreground`,children:c?(0,Q.jsx)(`img`,{src:c,alt:``,className:`size-[22px] object-contain`}):(0,Q.jsx)(sm,{height:22})}),(0,Q.jsx)(J,{asChild:!0,variant:`contrast`,size:`icon-sm`,className:`mt-1`,children:(0,Q.jsx)(K,{to:`/new`,"data-slot":`rail-new-task`,"aria-label":`New task`,title:`New task (C)`,children:(0,Q.jsx)(xc,{className:`size-4`,"aria-hidden":`true`})})}),(0,Q.jsx)(`nav`,{"aria-label":`Main`,className:`flex min-h-0 flex-col items-center gap-1 overflow-y-auto pt-2`,children:t.map(e=>{let t=e.icon,s=e.to===n,c=e.badge===`inbox-count`&&!!r||e.badge===`tasks-unread`&&!!i||e.badge===`skills-update`&&a||o.has(e.to);return(0,Q.jsxs)(K,{to:e.to,"aria-label":e.label,title:e.label,"aria-current":s?`page`:void 0,className:W(`relative flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,s&&`bg-muted text-foreground`),children:[(0,Q.jsx)(t,{className:`size-4`,"aria-hidden":`true`}),c?(0,Q.jsx)(`span`,{"data-slot":`rail-marker`,"aria-hidden":`true`,className:`absolute top-1 right-1 size-1.5 rounded-full bg-violet`}):null]},e.to)})}),(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":e===`sidebar-rail`?`sidebar-unfold`:void 0,"data-action":e===`focus-sidebar-rail`?`expand-sidebar`:void 0,"aria-label":`Show sidebar`,"aria-keyshortcuts":d,title:u,autoFocus:f,onClick:l,className:`mt-auto shrink-0 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,Q.jsx)(Ql,{className:`size-4`,"aria-hidden":`true`})})]})}function Sh({switcher:e,fallbackName:t,activeTo:n}){let r=e?.activeName??t,i=e?.projects??[];return(0,Q.jsx)(`header`,{"data-slot":`project-header`,className:`row-start-1 hidden h-11 shrink-0 items-center border-b border-border bg-card px-3 md:flex`,children:i.length===0?(0,Q.jsx)(`span`,{"data-slot":`project-header-name`,className:`truncate px-2 text-body font-semibold`,children:r}):(0,Q.jsxs)(tc,{children:[(0,Q.jsx)(Ys,{asChild:!0,children:(0,Q.jsxs)(J,{variant:`ghost`,size:`sm`,"data-slot":`project-switcher`,"aria-label":`Project: ${r} — switch project`,className:`min-w-0 gap-1.5 px-2 text-body font-semibold`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:r}),(0,Q.jsx)(Ws,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Q.jsxs)(Zs,{align:`start`,className:`w-60`,children:[(0,Q.jsx)(Js,{className:`text-xs text-soft-foreground`,children:`Projects`}),(0,Q.jsx)(ec,{}),i.map(t=>{let r=t.id===e?.activeId;return(0,Q.jsx)($s,{asChild:!0,children:(0,Q.jsxs)(yr,{to:`/p/${encodeURIComponent(t.id)}${n&&n!==`/`?n:`/`}`,"data-slot":`project-switcher-item`,"aria-current":r?`true`:void 0,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.name}),r?(0,Q.jsx)(Rs,{className:`size-4`,"aria-hidden":`true`}):null]})},t.id)})]})]})})}var Ch=Z.memo(function({onNavigate:e,...t}){return(0,Q.jsx)(nh,{slot:`mobile-nav-drawer`,title:`Navigation`,children:n=>(0,Q.jsx)(wh,{...t,onNavigate:e,headerAction:n})})});function wh({activeTo:e,items:t,repo:n,inboxCount:r,unreadCount:i,skillsUpdateAvailable:a,newNavItems:o,version:s,latestVersion:c,starCount:l,taskQuickList:u,hostWidget:d,whatsNew:f,toolsMenu:p,projectGroups:m,singleProject:h,brandName:g,brandLogoUrl:_,onNavigate:v,headerAction:y,compactHeader:b=!1}){return(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.jsxs)(`div`,{className:W(`flex items-center gap-[9px] px-3.5 pb-2.5`,b?`pt-1.5`:`pt-3.5`),children:[(0,Q.jsx)(cm,{name:g,logoUrl:_}),n&&!m?(0,Q.jsxs)(`span`,{"data-slot":`repo-chip`,className:`ml-auto truncate font-mono text-meta font-medium text-soft-foreground`,children:[n.name,` / `,n.branch]}):null,y?(0,Q.jsx)(`div`,{className:W(`shrink-0`,(!n||m)&&`ml-auto`),children:y}):null]}),(0,Q.jsxs)(`div`,{className:`flex gap-1.5 px-2.5 pt-1 pb-2`,children:[(0,Q.jsx)(J,{asChild:!0,variant:`contrast`,className:`relative min-w-0 flex-1 justify-center`,children:(0,Q.jsxs)(K,{to:`/new`,onClick:v,children:[(0,Q.jsx)(xc,{className:`size-[15px]`,"aria-hidden":`true`}),`New task`,(0,Q.jsx)(`kbd`,{"aria-hidden":`true`,className:`absolute right-2.5 rounded-[5px] border border-b-2 border-contrast-foreground/25 bg-transparent px-[5px] py-px font-mono text-micro font-medium text-contrast-foreground/60`,children:`C`})]})}),h?null:(0,Q.jsx)(Ah,{})]}),(0,Q.jsx)(`div`,{className:`shrink-0 px-1.5`,children:(0,Q.jsx)(Dh,{onNavigate:v})}),m?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`shrink-0 border-b border-border px-1.5 pt-0.5 pb-2`,children:(0,Q.jsx)(Oh,{onNavigate:v})}),(0,Q.jsx)(`div`,{"data-slot":`project-groups`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-1.5 pt-1.5 pb-2`,children:(0,Q.jsx)(fh.Provider,{value:v,children:m})})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`nav`,{"aria-label":`Main`,className:`px-2.5 py-1.5`,children:t.map(t=>{let n=t.to===e,s=t.icon;return(0,Q.jsxs)(K,{to:t.to,onClick:v,"aria-current":n?`page`:void 0,className:W(`flex h-11 w-full items-center gap-2.5 rounded-md px-2.5 text-ui font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground md:h-[34px]`,n&&`bg-muted font-semibold text-foreground`),children:[(0,Q.jsx)(s,{className:`size-4 shrink-0`,"aria-hidden":`true`}),t.label,t.badge===`inbox-count`&&r?(0,Q.jsx)(`span`,{"data-slot":`nav-badge`,className:`ml-auto rounded-full bg-violet px-1.5 py-px text-micro font-semibold text-violet-foreground`,children:r}):null,t.badge===`tasks-unread`&&i?(0,Q.jsx)(`span`,{"data-slot":`nav-unread-badge`,title:`${i} unread finished ${i===1?`task`:`tasks`}`,className:`ml-auto rounded-full bg-violet px-1.5 py-px text-micro font-semibold text-violet-foreground`,children:i}):null,t.badge===`skills-update`&&a?(0,Q.jsxs)(`span`,{"data-slot":`nav-update-marker`,className:`ml-auto flex items-center`,children:[(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-violet`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Skills update available`})]}):null,o.has(t.to)?(0,Q.jsxs)(`span`,{"data-slot":`nav-new-marker`,className:`ml-auto flex items-center`,children:[(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-violet`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`New`})]}):null]},t.to)})}),(0,Q.jsx)(`div`,{"data-slot":`task-quick-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-2.5 pb-2`,children:u})]}),(0,Q.jsxs)(`div`,{"data-slot":`sidebar-footer`,className:`flex flex-col gap-1.5 border-t border-border px-3.5 py-2.5`,children:[f,d,(0,Q.jsx)(Up,{}),(0,Q.jsxs)(`div`,{"data-slot":`sidebar-footer-controls`,className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{"data-slot":`tools-menu`,className:`shrink-0`,children:p}),s?(0,Q.jsx)(jh,{version:s,latestVersion:c,brandName:g}):null,l===null?null:(0,Q.jsx)(Mh,{count:l}),(0,Q.jsx)(kh,{onNavigate:v,className:`ml-auto`}),(0,Q.jsx)(Gf,{})]})]})]})}var Th=`flex h-11 w-full items-center gap-2.5 rounded-md px-2.5 text-ui font-semibold text-foreground transition-colors hover:bg-muted md:h-9`;function Eh(e){return W(`size-4 shrink-0`,e?`text-violet`:`text-violet/70`)}function Dh({onNavigate:e}){return(0,Q.jsx)(br,{to:`/dashboard`,"data-slot":`dashboard-link`,onClick:e,className:({isActive:e})=>W(Th,e&&`bg-muted`),children:({isActive:e})=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ei,{className:Eh(e),"aria-hidden":`true`}),`Dashboard`]})})}function Oh({onNavigate:e}){let{pathname:t}=jr(),n=t===`/tasks`;return(0,Q.jsxs)(yr,{to:`/tasks`,"data-slot":`all-tasks-link`,onClick:e,"aria-current":n?`page`:void 0,className:W(Th,n&&`bg-muted`),children:[(0,Q.jsx)(ys,{className:Eh(n),"aria-hidden":`true`}),`All tasks`]})}function kh({className:e,onNavigate:t}){return(0,Q.jsx)(J,{asChild:!0,variant:`ghost`,size:`icon`,className:W(`size-7`,e),children:(0,Q.jsx)(yr,{to:`/settings/global`,"data-slot":`global-settings-link`,"aria-label":`Global settings`,title:`Global settings`,onClick:t,children:(0,Q.jsx)(tu,{className:`size-4`,"aria-hidden":`true`})})})}function Ah(){let[e,t]=Z.useState(!1),[n,r]=Z.useState(!1),[i,a]=Z.useState(!1);return(0,Q.jsxs)(tc,{children:[(0,Q.jsx)(Ys,{asChild:!0,children:(0,Q.jsx)(J,{variant:`outline`,size:`icon`,"aria-label":`Add project`,title:`Add project`,className:`size-11 shrink-0 md:size-9`,children:(0,Q.jsx)(kl,{className:`size-4`,"aria-hidden":`true`})})}),(0,Q.jsxs)(Zs,{align:`start`,className:`w-56`,children:[(0,Q.jsx)(Js,{className:`text-xs text-soft-foreground`,children:`Add project`}),(0,Q.jsxs)($s,{"data-slot":`add-project-local`,onSelect:()=>{t(!0),cs(`folder`)},children:[(0,Q.jsx)(dc,{"aria-hidden":`true`}),`Open local folder…`]}),(0,Q.jsxs)($s,{"data-slot":`add-project-clone`,onSelect:()=>{r(!0),cs(`clone`)},children:[(0,Q.jsx)(Cf,{"aria-hidden":`true`}),`Clone from GitHub…`]}),(0,Q.jsxs)($s,{"data-slot":`add-project-create`,onSelect:()=>{a(!0),cs(`new`)},children:[(0,Q.jsx)(Al,{"aria-hidden":`true`}),`New project…`]})]}),e?(0,Q.jsx)(Sf,{label:`Open local folder`,onError:()=>t(!1),children:(0,Q.jsx)(cf,{open:!0,onOpenChange:t})}):null,n?(0,Q.jsx)(Sf,{label:`Clone from GitHub`,onError:()=>r(!1),children:(0,Q.jsx)(df,{open:!0,onOpenChange:r})}):null,i?(0,Q.jsx)(Sf,{label:`New project`,onError:()=>a(!1),children:(0,Q.jsx)(_f,{open:!0,onOpenChange:a})}):null]})}function jh({version:e,latestVersion:t,brandName:n}){let r=!!(t&&t!==e),[i,a]=Z.useState(!1);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`version-chip`,"data-update-available":r?`true`:void 0,title:r?`v${e} — update available: v${t}`:`v${e}`,"aria-label":r?`${n} v${e}, update to v${t} available — open updater`:`${n} v${e} — open updater`,onClick:()=>a(!0),className:`flex min-w-0 cursor-pointer items-center gap-1 rounded-full border border-border px-1.5 py-px font-mono text-micro font-medium text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:[r?(0,Q.jsx)(Jc,{tone:`pending`,pulse:!0,className:`size-[5px] shrink-0`}):null,(0,Q.jsxs)(`span`,{className:`truncate`,children:[`v`,e]})]}),i?(0,Q.jsx)(wm,{open:i,onOpenChange:a,brandName:n}):null]})}function Mh({count:e}){let t=qp(e);return(0,Q.jsxs)(`a`,{"data-slot":`star-chip`,href:Gp,target:`_blank`,rel:`noopener noreferrer`,title:`Star cezar on GitHub — ${e.toLocaleString()} stars`,"aria-label":`Star cezar on GitHub — ${e.toLocaleString()} stars`,className:`flex shrink-0 items-center gap-1 rounded-full border border-border px-1.5 py-px font-mono text-micro font-medium text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`⭐`}),(0,Q.jsx)(`span`,{children:t})]})}function Nh({title:e}){return(0,Q.jsx)(`header`,{"data-slot":`mobile-top-bar`,className:`row-start-1 border-b border-border bg-card pt-[env(safe-area-inset-top)] md:hidden`,children:(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-2.5 px-3`,children:[(0,Q.jsx)(Hi,{asChild:!0,children:(0,Q.jsx)(J,{variant:`ghost`,size:`icon`,"aria-label":`Open menu`,className:`-ml-1.5 size-11`,children:(0,Q.jsx)(Ul,{className:`size-[17px]`,"aria-hidden":`true`})})}),(0,Q.jsx)(`span`,{className:`truncate text-body font-semibold`,children:e}),(0,Q.jsx)(`div`,{"data-slot":`mobile-status`,className:`ml-auto flex items-center gap-2`})]})})}function Ph(e,t){return e.startsWith(`@`)?{mode:`tasks`,query:e.slice(1)}:e.startsWith(`>`)?{mode:t?`commands`:`tasks`,query:e.slice(1)}:e.startsWith(`#`)?{mode:t?`files`:`tasks`,query:e.slice(1)}:{mode:t?`all`:`tasks`,query:e}}var Fh=e=>e.replace(/^[@>#]/,``),Ih=(e,t,n)=>_p(e,Fh(t),n);function Lh(e){return(gr(`/p/:projectId/tasks/:id/*`,e)??gr(`/tasks/:id/*`,e))?.params.id}function Rh(e,t,n=50){let r=t.trim();if(r===``)return e.slice(0,n);let i=[];for(let t of e){let e=t.slice(t.lastIndexOf(`/`)+1),n=_p(t,r)+_p(e,r);n>0&&i.push({path:t,score:n})}return i.sort((e,t)=>t.score-e.score||e.path.length-t.path.length),i.slice(0,n).map(e=>e.path)}var zh=6,Bh=`task-palette-task`;function Vh(){let e=jr(),t=Lh(e.pathname),n=vr(),r=Uh(),[i,a]=Z.useState(!1),[o,s]=Z.useState(null),[c,l]=Z.useState(``),[u,d]=Z.useState(``),[f,p]=Z.useState(!1),[m,h]=Z.useState(null),[g,_]=Z.useState(null),[v,y]=Z.useState(null),b=Z.useRef(null),x=Z.useRef(null),S=Z.useRef(!1),C=Z.useRef(!1),w=Z.useRef(null),T=Ra();zp(`task`,i,Z.useCallback(()=>a(!1),[]));let E=Z.useRef(new Set),D=Z.useRef(!1),O=Z.useRef(i);O.current=i;let k=Z.useCallback((e,t,{reopen:n=!1}={})=>{!O.current&&!n&&Ls(e?`task`:`task_switch`),D.current=!1,s(e),l(t),d(``),p(!1),y(null),h(null),S.current=!1,C.current=!1,a(!0)},[]),A=()=>[...x.current?.querySelectorAll(`[cmdk-item][data-slot="${Bh}"]`)??[]];Fo(`p`,()=>{if(v)return;if(!i){t?k(t,``):k(null,`@`);return}if(p(!1),(f||!c.startsWith(`@`))&&o){l(`@`),D.current=!0,h({step:1});return}let e=A(),n=e.findIndex(e=>e.dataset.value===u);D.current=!0,h({step:n+1>=e.length?0:n+1})},{inEditable:!0}),Z.useEffect(()=>{if(!m)return;let e=setTimeout(()=>{let e=A(),t=e[Math.min(m.step,e.length-1)];t?.dataset.value&&d(t.dataset.value),h(null)},0);return()=>clearTimeout(e)},[m,c]);let j=Z.useCallback(e=>{if(e.projectId===null||e.projectId===r){k(e.runId,``);return}w.current=e.runId,a(!1),n(Ip({id:e.runId,projectId:e.projectId}))},[r,n,k]);Z.useEffect(()=>{let e=e=>{let n=e.detail;n?j(n):t?k(t,``):k(null,`@`)};return window.addEventListener(up,e),()=>window.removeEventListener(up,e)},[j,t,k]),Z.useEffect(()=>{i||s(null)},[e.pathname]),Z.useEffect(()=>{!i&&!C.current&&s(null)},[i]),Z.useEffect(()=>{w.current&&w.current===t&&(w.current=null,k(t,``,{reopen:!0}))},[t,k]);let M=Z.useCallback(()=>{C.current&&(C.current=!1,I.current.open||s(null))},[]),N=(e,t=!1)=>{let n=b.current?.build().find(t=>t.id===e);if(!n||n.unavailable)return;if(Cs(n.id,`palette`),n.id===`rename`){n.perform();return}S.current=!0,C.current=Jh(n.id),a(!1);let r=t&&n.performBeside?n.performBeside:n.perform;if(Yh(n.id))return r();setTimeout(r,0)},P=Z.useCallback(e=>{S.current=!0,Xo(D.current?`cycle`:`enter`),a(!1),n(Ip(e))},[n]),F=Z.useCallback(()=>{let e=b.current?.run;e&&(p(!0),l(Ve(e)),setTimeout(()=>x.current?.querySelector(`[cmdk-input]`)?.select(),0))},[]),ee=()=>{let e=c.trim();e&&b.current&&b.current.rename(e),S.current=!0,a(!1)},te=e=>{T.ready&&y({id:e,label:Zh(e,b.current?.commands)})},I=Z.useRef({open:i,recording:v,pageTaskId:t,byChord:new Map,show:k,beginRename:F});I.current={open:i,recording:v,pageTaskId:t,byChord:new Map([...T.bindings].map(([e,t])=>[t,e])),show:k,beginRename:F},Z.useEffect(()=>{let e=e=>{if(e.repeat||e.defaultPrevented)return;let t=I.current;if(t.open||t.recording||!t.pageTaskId)return;let n=Pa(e),r=n?t.byChord.get(n):void 0;if(!n||!r||!Qh(e.target,n)||Ya())return;let i=b.current;if(!i||i.run.id!==t.pageTaskId)return;let a=i.build().find(e=>e.id===r);if(a){if(e.preventDefault(),a.unavailable)return void Y(a.unavailable);if(Cs(a.id,`shortcut`),a.id===`rename`){t.show(t.pageTaskId,``,{reopen:!0}),setTimeout(t.beginRename,0);return}a.perform(`shortcut`)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let ne=e=>{if(v){if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`)return y(null);if(!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&(e.key===`Backspace`||e.key===`Delete`))return T.assign(v.id,null),Y(`Removed the shortcut for ${v.label}`),y(null);let t=Pa(e.nativeEvent);if(!t){let t=$a(e.nativeEvent);t&&y({...v,problem:t});return}let n=Za(t);if(n)return y({...v,problem:`${Oa(t)} — ${n}`});let r=[...T.bindings].find(([e,n])=>n===t&&e!==v.id)?.[0];return T.assign(v.id,t),Y(`${Oa(t)} → ${v.label}${r?` (was ${Zh(r,b.current?.commands)})`:``}`),y(null)}if(e.nativeEvent.isComposing||e.keyCode===229)return;if(f){e.key===`Enter`&&(e.preventDefault(),ee());return}let n=x.current?.querySelector(`[cmdk-item][data-selected="true"]`);if(e.key===`Tab`&&!e.shiftKey&&!e.altKey&&!e.metaKey&&!e.ctrlKey){let t=n?.dataset.slot===Bh?n.dataset.runId:void 0;if(!t)return;e.preventDefault(),Xo(`tab`),j({runId:t,projectId:n?.dataset.projectId??null});return}if(e.key===`Enter`&&e.altKey&&n?.dataset.commandId){e.preventDefault(),N(n.dataset.commandId,!0);return}if(e.key===`Enter`&&e.shiftKey&&n?.dataset.commandId&&Xh(n.dataset.commandId)){e.preventDefault(),te(n.dataset.commandId);return}e.key===`Backspace`&&c===``&&o!==null&&o!==t&&(e.preventDefault(),k(t??null,`@`))},{mode:L,query:re}=f?{mode:`all`,query:``}:Ph(c,o!==null);return Z.useEffect(()=>{if(!(!i||f||v))for(let e of As(re,L===`all`?void 0:L))E.current.add(e)},[i,f,v,re,L]),Z.useEffect(()=>{i||E.current.size===0||(Ms(E.current),E.current=new Set)},[i]),(0,Q.jsxs)(Q.Fragment,{children:[o??t?(0,Q.jsx)(ng,{runId:o??t,apiRef:b,onCommands:_,onRename:F,onDialogDone:M,open:i},o??t):null,(0,Q.jsx)(Ii,{open:i,onOpenChange:e=>{e||ts(L===`tasks`?`tasks`:L===`files`?`files`:`actions`),a(e)},title:`Task palette`,description:`Act on a task, switch tasks, or open one of its files`,showCloseButton:!1,filter:Ih,commandProps:{value:u,onValueChange:d,onKeyDown:ne,shouldFilter:!f&&!v&&L!==`files`},onOpenAutoFocus:e=>{let t=e.currentTarget?.querySelector(`[cmdk-input]`);t&&(e.preventDefault(),t.focus(),t.setSelectionRange(t.value.length,t.value.length))},onCloseAutoFocus:e=>{S.current&&e.preventDefault()},onEscapeKeyDown:e=>{if(v)return e.preventDefault(),y(null);f&&(e.preventDefault(),p(!1),l(``))},className:`top-[10vh] translate-y-0 sm:max-w-2xl lg:max-w-3xl xl:max-w-4xl`,children:(0,Q.jsxs)(`div`,{ref:x,"data-slot":`task-palette`,"data-mode":v?`record`:f?`rename`:L,className:`contents`,children:[(0,Q.jsx)(Mi,{placeholder:v?`Press a shortcut — ⌫ removes it, esc cancels`:Hh(f?`rename`:L),value:c,onValueChange:l}),o&&!f&&L!==`tasks`?(0,Q.jsx)(Wh,{runId:o,picked:o!==t}):null,(0,Q.jsx)(Li,{className:`max-h-[55vh] min-h-[14rem] sm:max-h-[60vh] lg:max-h-[68vh]`,children:v?(0,Q.jsx)(ji,{heading:`Shortcut for ${v.label}`,children:(0,Q.jsxs)(Bi,{value:`record`,"data-slot":`task-palette-recorder`,onSelect:()=>{},children:[(0,Q.jsx)(Rl,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:v.problem??`Press the keys for this command…`}),T.bindings.get(v.id)?(0,Q.jsx)(Ni,{children:Oa(T.bindings.get(v.id))}):null]})}):f?(0,Q.jsx)(ji,{heading:`Rename`,children:(0,Q.jsxs)(Bi,{value:`rename`,"data-slot":`task-palette-rename`,onSelect:ee,children:[(0,Q.jsx)(rc,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:c.trim()?`Rename to “${c.trim()}”`:`Type the new name`}),(0,Q.jsx)(Ni,{children:`↵`})]})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Wi,{children:`Nothing matches.`}),L===`all`||L===`commands`?(0,Q.jsx)(Gh,{commands:g?.runId===o?g.commands:[],bindings:T.bindings,onPerform:N,onRecord:te}):null,L===`files`&&o?(0,Q.jsx)(eg,{runId:o,query:re,onPick:e=>{S.current=!0,a(!1);let t=vo(o);t?setTimeout(()=>t.openFile(e),0):(wo(o,e),n(`/tasks/${o}`))}}):null,L===`all`||L===`tasks`?(0,Q.jsx)($h,{recentOnly:L===`all`,exclude:L===`all`?o:null,current:t,query:re,onPick:P}):null]})}),(0,Q.jsx)(tg,{mode:v?`record`:f?`rename`:L})]})})]})}function Hh(e){switch(e){case`rename`:return`New name…`;case`tasks`:return`Switch to a task…`;case`files`:return`Open a file in this task…`;case`commands`:return`Run a command on this task…`;default:return`Act on this task — @ tasks · > commands · # files`}}function Uh(){let e=kr(),t=a(),n=C(),r=t.data?.bootProject??n.data?.bootProject??null;return(e==="default"?null:e)??r}function Wh({runId:e,picked:t}){let n=Ee(e).data;if(!n)return null;let r=o(n);return(0,Q.jsxs)(`div`,{"data-slot":`task-palette-subject`,className:`flex min-w-0 items-center gap-2 border-b border-border px-3 py-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`shrink-0`,children:`Task`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:Ve(n)}),(0,Q.jsx)(Nc,{className:`shrink-0`,dot:r.tone,pulse:r.pulse,children:r.label}),t?(0,Q.jsx)(`span`,{className:`shrink-0 text-soft-foreground`,children:`⌫ back to tasks`}):null]})}function Gh({commands:e,bindings:t,onPerform:n,onRecord:r}){return(0,Q.jsx)(Q.Fragment,{children:Na.map(i=>{let a=e.filter(e=>e.group===i.id&&!e.hidden);return a.length===0?null:(0,Q.jsx)(ji,{heading:i.heading,children:a.map(e=>{let a=Kh(e,t);return(0,Q.jsxs)(Bi,{value:`${i.heading} ${e.label} ${e.id}`,keywords:e.keywords,disabled:e.unavailable!==void 0,"data-slot":`task-palette-command`,"data-command-id":e.id,"aria-checked":e.pressed,onSelect:()=>n(e.id),className:W(`group/command`,e.danger&&`data-[selected=true]:text-danger`),children:[e.icon,(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.unavailable?(0,Q.jsx)(`span`,{className:`shrink-0 truncate text-xs text-soft-foreground`,children:e.unavailable}):e.pressed?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-primary`,children:`on`}):null,Xh(e.id)?(0,Q.jsx)(`button`,{type:`button`,"data-slot":`task-palette-record`,"aria-label":`Set a shortcut for ${e.label}`,title:`Set a shortcut (⇧↵)`,className:`hidden shrink-0 rounded p-0.5 text-soft-foreground group-hover/command:inline-flex hover:text-foreground`,onPointerDown:e=>e.preventDefault(),onClick:t=>{t.stopPropagation(),r(e.id)},children:(0,Q.jsx)(Rl,{"aria-hidden":`true`,className:`size-3.5!`})}):null,a?(0,Q.jsx)(Ni,{children:a}):null]},e.id)})},i.id)})})}function Kh(e,t){let n=t.get(e.id);if(n)return Oa(n);let r=e.shortcut&&/^[1-9]$/.test(e.shortcut)?t.get(`tab:${e.shortcut}`):void 0;return r?Oa(r):e.shortcut}var qh=new Set([`stop`,`delete`]),Jh=e=>qh.has(e)||e.startsWith(`git:`),Yh=e=>e.startsWith(`copy:`)||e===`open-pr`,Xh=e=>!e.startsWith(`layout:`);function Zh(e,t=[]){return ja.find(t=>t.id===e)?.label??t.find(t=>t.id===e)?.label??e}function Qh(e,t){let n=t.split(`+`).includes(`Mod`);return e instanceof HTMLElement&&e.closest(`.xterm`)?n&&Sa():ao(e)&&!(e instanceof HTMLElement&&e.closest(`[cmdk-input]`))?n:!0}function $h({recentOnly:e,exclude:t,current:n,query:r,onPick:i}){let{tasks:a,multiProject:o,projectNames:s,repoBases:c}=Fp(),l=bo(),u=Z.useMemo(()=>{let n=Io(a,e=>e.id,l),r=new Set(l);return Ep(e?n.filter(e=>r.has(e.id)&&e.id!==t).slice(0,zh):n,s,c)},[a,l,e,t,s,c]),{shown:d,total:f}=Z.useMemo(()=>Dp(u,r),[u,r]),[p]=Z.useState(Date.now);return d.length===0?null:(0,Q.jsx)(Op,{entries:d,children:(0,Q.jsxs)(ji,{heading:(0,Q.jsx)(xp,{label:e?`Recent tasks`:`Tasks`}),className:kp,children:[d.map(e=>(0,Q.jsx)(Vp,{entry:e,slot:Bh,showProject:o,now:p,onSelect:i,current:e.task.id===n},e.key)),(0,Q.jsx)(Ap,{hidden:f-d.length})]})})}function eg({runId:e,query:t,onPick:n}){let r=de(e),i=Z.useMemo(()=>Rh(r.data?.paths??[],t),[r.data,t]);return r.isPending?(0,Q.jsx)(`p`,{className:`px-3 py-6 text-center text-xs text-soft-foreground`,children:`Loading files…`}):r.isError?(0,Q.jsx)(`p`,{className:`px-3 py-6 text-center text-xs text-soft-foreground`,children:r.error.message}):(0,Q.jsx)(ji,{heading:`Files`,children:i.map(e=>{let t=e.lastIndexOf(`/`);return(0,Q.jsxs)(Bi,{value:`file ${e}`,"data-slot":`task-palette-file`,onSelect:()=>n(e),children:[(0,Q.jsx)(uc,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`shrink-0 font-medium`,children:e.slice(t+1)}),t>0?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.slice(0,t)}):null]},e)})})}function tg({mode:e}){return(0,Q.jsx)(`div`,{"data-slot":`task-palette-footer`,className:`flex flex-wrap gap-x-3 gap-y-1 border-t border-border px-3 py-1.5 text-meta text-soft-foreground`,children:(e===`record`?[`⌫ remove`,`esc cancel`]:e===`rename`?[`↵ save`,`esc cancel`]:e===`tasks`?[`↵ open`,`tab act on it`,`${ho(`p`)} next`]:e===`files`?[`↵ open in Code`]:[`↵ run`,`⌥↵ open beside`,`⇧↵ set shortcut`,`@ tasks`,`> commands`,`# files`]).map(e=>(0,Q.jsx)(`span`,{children:e},e))})}var ng=Z.memo(function(e){let t=Ee(e.runId).data;return t?(0,Q.jsx)(rg,{run:t,...e}):null});function rg(e){let t=Ba(e.run);return(0,Q.jsx)(Ur,{projectId:t.projectId,requests:t.requests,children:(0,Q.jsx)(ig,{...e})})}function ig({run:e,apiRef:t,onCommands:n,onRename:r,onDialogDone:i}){let a=vo(e.id),o=Lh(jr().pathname)===e.id,s=Ka(e,{surface:`palette`,onMarkedUnread:a?.markedUnread,onScreen:o}),c=za(e),l=Fa(e,Wa(e)),u=C().data?.capabilities?.terminal===!0,d=L(e.id),f=vr(),p=Uh(),m=An(e),h=()=>Xa({run:e,canResume:l.canResumeHere,git:c.action,gitPending:c.pending,workspace:vo(e.id),terminalAvailable:u,openChoices:l.choices,prUrl:m?.url,taskUrl:`${window.location.origin}${p?_r(p,`/tasks/${e.id}`):`/tasks/${e.id}`}`},{markRead:()=>s.markRead.mutate(),markUnread:()=>s.markUnread.mutate(),pin:e=>s.pin.mutate(e===`shortcut`?`shortcut`:void 0),archive:e=>s.archive.mutate(e===`shortcut`?`shortcut`:void 0),rename:r,finish:()=>s.finish.mutate(),confirmStop:()=>s.setConfirming(`cancel`),confirmDelete:()=>s.setConfirming(`delete`),resumeInTerminal:()=>s.terminal.mutate(),gitAction:c.onAction,openIn:l.open,navigate:e=>f(e),openUrl:e=>window.open(e,`_blank`,`noopener,noreferrer`),copy:(e,t)=>void Ma(e,`${t} copied`)}),g=h();t.current={run:e,commands:g,build:h,rename:e=>d.mutate({title:e},{onError:e=>Y(e.message,{tone:`danger`})})};let _=g.map(e=>`${e.id}|${e.label}|${e.unavailable??``}|${+!!e.pressed}|${e.shortcut??``}`).join(`
|
|
4
|
-
`),v=Z.useRef(g);v.current=g,Z.useEffect(()=>n({runId:e.id,commands:v.current}),[_,n,e.id]);let y=s.confirming!==null||c.commitOpen||c.pending!==null||s.delete.isPending||s.cancel.isPending,b=Z.useRef(y);return Z.useEffect(()=>{b.current&&!y&&i(),b.current=y},[y,i]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Aa,{run:e,confirming:s.confirming,lifecycleDelete:s.lifecycleDelete,onOpenChange:e=>!e&&s.setConfirming(null),onConfirm:e=>e===`delete`?s.delete.mutate():s.cancel.mutate()}),c.dialogs]})}var ag=Z.createContext(null);function og({children:e}){let[t,n]=Z.useState(`active`),r=Z.useMemo(()=>[t,n],[t]);return(0,Q.jsx)(ag.Provider,{value:r,children:e})}function sg(){let e=Z.useContext(ag);if(!e)throw Error(`useListView must be used inside a <ListViewProvider>`);return e}var cg=1e4,lg=e=>Math.min(100,Math.max(0,e)),ug=e=>e===void 0||e<80?`ok`:e<90?`warn`:`critical`;function dg(){let e=ra(),t=Qi();return!e||t!==`local`?null:(0,Q.jsx)(fg,{})}function fg(){let e=ea(),t=Zi(),n=$i(),[r,i]=(0,Z.useState)(void 0),a=n!==void 0&&r===n;(0,Z.useEffect)(()=>{if(n===void 0)return;let e=Math.max(0,n+cg-Date.now()),t=setTimeout(()=>i(n),e);return()=>clearTimeout(t)},[n]);let o=e===void 0?void 0:na(e),s=o?.cpuPct,c=a?`stale`:o!==void 0&&o.cpuLimited&&s===void 0?`—`:s===void 0?t.length===0?`sampling…`:`—`:`${Math.round(s)}%`,l=o===void 0||o.memUsedBytes===void 0||o.memTotalBytes<=0?void 0:o.memUsedBytes/o.memTotalBytes*100,u=a?`stale`:l===void 0?`—`:`${Math.round(l)}%`,d=o===void 0?`—`:Ji(o.memUsedBytes,o.memTotalBytes),f=o?.cpuLimited===!0?`${o.cpuLimitKind===`cpuset`?`cpuset `:``}${qi(o.cpuCores)}`:void 0,p=`CPU ${c}${f===void 0?``:` of ${f}`}, RAM ${u} (${d})`;return(0,Q.jsxs)(K,{to:`/settings/resources`,"data-slot":`host-usage-widget`,"data-state":a?`stale`:`live`,"data-frames":t.length,"aria-label":`Machine usage: ${p}. Open Settings, Resources.`,title:p,className:W(`grid grid-cols-[auto_minmax(0,1fr)_auto_auto_minmax(0,1fr)_auto] items-center gap-x-1.5 rounded-md border border-border px-2 py-1 text-meta leading-[14px] text-soft-foreground transition-colors hover:bg-muted hover:text-foreground`,a?`opacity-70`:null),children:[(0,Q.jsx)(pg,{label:`CPU`,pct:a?void 0:s,valueSlot:`host-usage-widget-cpu`,value:c}),(0,Q.jsx)(pg,{label:`RAM`,pct:a?void 0:l,valueSlot:`host-usage-widget-mem-pct`,value:u,gutter:!0})]})}function pg({label:e,pct:t,valueSlot:n,value:r,gutter:i}){let a=ug(t);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:W(`font-medium tracking-wide text-muted-foreground`,i===!0?`ml-1`:null),children:e}),(0,Q.jsx)(`span`,{"data-slot":`host-usage-widget-${e.toLowerCase()}-bar`,"data-level":a,role:`meter`,"aria-label":e,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t===void 0?void 0:Math.round(lg(t)),className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,Q.jsx)(`span`,{className:W(`block h-full rounded-full transition-[width] duration-500`,a===`critical`?`bg-destructive`:a===`warn`?`bg-pending`:`bg-primary`),style:{width:`${t===void 0?0:lg(t)}%`}})}),(0,Q.jsx)(`span`,{"data-slot":n,className:W(`text-right font-medium tabular-nums`,a===`critical`?`text-destructive`:a===`warn`?`text-pending-strong`:`text-foreground`),children:r})]})}function mg({status:e,pending:t,error:n,dismissals:r,onDismissAuthFailures:i}){if(t||!e)return null;let a;try{a=bt(e)}catch{return null}let o=gs(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)(Jc,{tone:`danger`}),(0,Q.jsxs)(`span`,{children:[`Provider authentication failed during a task:`,` `,o.map(({label:e})=>e).join(`, `),`.`]}),(0,Q.jsx)(K,{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)(Tc,{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)(Jc,{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)(K,{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 hg(e){if(!(typeof e!=`object`||!e||Array.isArray(e)))return e}function gg(){let e=St(),t=ht(),n=U(),r=(0,Z.useRef)(Promise.resolve()),i=(0,Z.useRef)(0),a=(0,Z.useRef)(0),o=(0,Z.useRef)(hg(t.data));(0,Z.useEffect)(()=>{a.current===0&&(o.current=hg(t.data))},[t.data]);let s=(0,Z.useCallback)(e=>{let t=B.uiState,s=hg(n.getQueryData(t)),c=vs(zo(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 Pt({dismissedProviderAuthFailures:c});o.current=hg(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}),Y(e instanceof Error?e.message:String(e),{tone:`danger`}))}finally{--a.current}})},[n]);return(0,Q.jsx)(mg,{status:e.data,pending:e.isPending,error:e.isError,dismissals:zo(hg(t.data)?.dismissedProviderAuthFailures),onDismissAuthFailures:s})}var _g=`https://github.com/open-mercato/cezar/blob/main/docs/telemetry.md`,vg=`https://github.com/open-mercato/cezar/blob/main/packages/cezar/src/telemetry.ts`;function yg(e){return e!==void 0&&e.consent===`unknown`&&e.blockedBy===null}var bg=[`How many tasks you start (agent, model)`,`How many messages you send`,`Which pages you open`,`Errors, with your paths removed`,`Version, OS, app or CLI`,`A random install id`],xg=[`Prompts, messages, code, diffs`,`File paths`,`Repo, branch or project names`,`Keys or credentials`,`Your IP, in any payload`];function Sg(){let e=U();return(0,Z.useCallback)(async t=>{try{let n=await bn({consent:t});return e.setQueryData(B.telemetryConsent,n),t===`denied`&&ee(),!0}catch(e){return Y(e instanceof Error?e.message:String(e),{tone:`danger`}),!1}},[e])}function Cg({busy:e,onAnswer:t,size:n}){let r=n===`lg`?`min-h-11`:`h-9`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{variant:`outline`,className:r,disabled:e,"data-slot":`telemetry-deny`,onClick:()=>t(`denied`),children:`Don’t share`}),(0,Q.jsx)(J,{className:r,disabled:e,"data-slot":`telemetry-grant`,onClick:()=>t(`granted`),children:`Share usage data`})]})}function wg(){let e=Ze(),t=Sg(),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(!1);if(!yg(e.data))return null;let o=async e=>{r(!0);let n=await t(e);r(!1),n&&a(!1)};return(0,Q.jsxs)(`div`,{"data-slot":`telemetry-consent-banner`,className:`px-4 pb-3 md:px-5 md:pb-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3 rounded-lg border bg-card px-4 py-3 shadow-lg`,children:[(0,Q.jsx)(nu,{className:`hidden size-[18px] shrink-0 text-violet sm:block`,"aria-hidden":`true`}),(0,Q.jsxs)(`p`,{className:`min-w-0 flex-1 basis-[280px] text-ui leading-relaxed text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Help improve cezar?`}),` With your OK we send task counts and crash reports to the maintainers — never prompts, code, paths or repo names. Change it anytime in Settings → Privacy.`,` `,(0,Q.jsx)(`button`,{type:`button`,"data-slot":`telemetry-details`,className:`underline underline-offset-2 hover:text-foreground`,onClick:()=>a(!0),children:`Details`})]}),(0,Q.jsx)(`div`,{className:`flex gap-2`,children:(0,Q.jsx)(Cg,{busy:n,onAnswer:e=>void o(e),size:`sm`})})]}),(0,Q.jsx)(Eg,{open:i,onOpenChange:a,busy:n,onAnswer:e=>void o(e)})]})}function Tg({title:e,tone:t,items:n}){let r=t===`ok`?Rs:Tc;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`block text-ui font-medium text-foreground`,children:e}),(0,Q.jsx)(`ul`,{className:`mt-2 space-y-1.5`,children:n.map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-2 text-ui leading-snug text-muted-foreground`,children:[(0,Q.jsx)(r,{className:`mt-0.5 size-3.5 shrink-0 ${t===`ok`?`text-success`:`text-soft-foreground`}`,"aria-hidden":`true`}),e]},e))})]})}function Eg({open:e,onOpenChange:t,busy:n,onAnswer:r}){return(0,Q.jsx)(qr,{open:e,onOpenChange:t,children:(0,Q.jsx)(Wr,{"data-slot":`telemetry-details-dialog`,className:`max-h-[calc(100dvh-2rem)] gap-0 overflow-y-auto p-0 sm:max-w-[480px]`,onOpenAutoFocus:e=>{e.preventDefault(),e.currentTarget.focus()},children:(0,Q.jsxs)(`div`,{className:`space-y-5 p-6`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`span`,{className:`block eyebrow text-muted-foreground`,children:`What is sent`}),(0,Q.jsx)(Zr,{className:`text-xl font-semibold tracking-tight`,children:`Usage data, in full`}),(0,Q.jsx)(Vr,{className:`text-sm leading-relaxed text-muted-foreground`,children:`Counts of what you use and reports of what broke, so cezar’s maintainers at Open Mercato can fix bugs without you filing them. Off until you say yes.`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsx)(Tg,{title:`Shared`,tone:`ok`,items:bg}),(0,Q.jsx)(Tg,{title:`Never shared`,tone:`no`,items:xg})]}),(0,Q.jsxs)(`p`,{className:`text-xs leading-relaxed text-soft-foreground`,children:[`Every label is a closed list the server enforces. Withdraw anytime in Settings → Privacy or with `,(0,Q.jsx)(`code`,{className:`font-mono`,children:`cezar telemetry disable`}),` — the install id is deleted.`,` `,(0,Q.jsx)(`a`,{href:vg,target:`_blank`,rel:`noopener noreferrer`,className:`underline underline-offset-2 hover:text-foreground`,children:`Read the code`}),` · `,(0,Q.jsx)(`a`,{href:_g,target:`_blank`,rel:`noopener noreferrer`,className:`underline underline-offset-2 hover:text-foreground`,children:`Privacy notice`})]}),(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:(0,Q.jsx)(Cg,{busy:n,onAnswer:r,size:`lg`})})]})})})}function Dg({compact:e=!1,enabled:t=!0}){let[n,r]=(0,Z.useState)([]),i=mi(),a=bi(t&&i.known&&!i.off).data?.automations.filter(e=>e.deferredStart)??[];return!a.length&&!n.length?null:(0,Q.jsxs)(`section`,{"aria-label":`Scheduled tasks`,className:e?`px-2 py-3`:`border-b p-4 md:px-5`,children:[(0,Q.jsxs)(`h2`,{className:`mb-2 eyebrow text-muted-foreground`,children:[`Scheduled · `,a.length]}),n.length>0&&(0,Q.jsxs)(`p`,{role:`status`,children:[`This scheduled task already started. `,n.map((e,t)=>(0,Q.jsxs)(K,{to:`/tasks/${e}`,className:`mr-3 underline`,children:[`View run `,t+1]},e))]}),e?a.map(e=>(0,Q.jsxs)(K,{to:`/#scheduled-${e.id}`,className:`block truncate rounded px-2 py-1.5 text-sm`,children:[`◷ `,e.name]},e.id)):(0,Q.jsx)(`div`,{className:`grid gap-3`,children:a.map(e=>(0,Q.jsx)(Og,{item:e,onAlreadyStarted:r},e.id))})]})}function Og({item:e,onAlreadyStarted:t}){let n=jr(),r=e.deferredStart,i=vr(),a=U(),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(``),g=()=>{if(u){d(null);return}p(e.schedule?.date??``),h(`${String(e.schedule?.hour??0).padStart(2,`0`)}:${String(e.schedule?.minute??0).padStart(2,`0`)}`),d(e),l(``)},_=async e=>{s(!0),l(``);try{await e()}catch(e){e instanceof cn&&e.runIds?.length?t(e.runIds):l(e instanceof Error?e.message:String(e))}finally{await a.invalidateQueries({queryKey:fi()}),s(!1)}},v=r.runIds.length>0,y=v&&r.status===`failed`&&r.failureKind===`ambiguous`,b=r.failureKind===`binding-invalid`,x=`scheduled-${e.id}`,[S,C]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{n.hash===`#${x}`&&(C(!0),document.getElementById(x)?.scrollIntoView?.({block:`nearest`}))},[x,n.hash,n.key]);let w=e.task.steps?.flatMap(e=>e.skill?[e.skill]:[])??[],T=e.task.workflow??(w.length?`Skills: ${w.join(`, `)}`:`Inline steps`),E=r.binding.models?.map(e=>`${e.step?`${e.step}: `:``}${e.runner} / ${e.model??`Provider default`}`).join(`; `)??e.task.model??`Resolved step models unavailable`,D=r.status===`failed`?`Couldn't start`:r.status===`missed`?`Missed`:r.status===`launching`?`Starting…`:r.holdUntil?`Waiting for reset`:`Scheduled`;return(0,Q.jsxs)(`details`,{id:x,open:S,onToggle:e=>C(e.currentTarget.open),className:`rounded-lg border p-3`,children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,Q.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[D,` · `,new Date(r.notBefore).toLocaleString(`en-GB`,{timeZone:r.timeZone}),` · `,r.timeZone]})]}),(0,Q.jsxs)(`div`,{className:`mt-3 space-y-3 text-sm`,children:[(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap break-words`,children:e.task.prompt}),(0,Q.jsxs)(`p`,{className:`text-muted-foreground`,children:[T,` · `,E,` · `,r.binding.accounts.map(e=>`${e.runner} / ${e.id}`).join(`, `)]}),(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:`The server must be running. This is the earliest start; account holds and queue limits still apply.`}),r.holdUntil&&(0,Q.jsxs)(`p`,{children:[`Waiting until `,new Date(r.holdUntil).toLocaleString(`en-GB`,{timeZone:r.timeZone}),` for a newer observed reset.`]}),r.error&&(0,Q.jsx)(`p`,{role:`status`,children:r.error}),y&&(0,Q.jsx)(`p`,{children:`Check the runs below. Start missing runs creates only the ones that do not exist yet — a run you deleted starts again. Dismiss removes this entry and starts nothing.`}),r.runIds.map((e,t)=>(0,Q.jsxs)(K,{to:`/tasks/${e}`,className:`mr-3 underline`,children:[`Check run `,t+1]},e)),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(J,{size:`sm`,variant:`ghost`,disabled:o,onClick:()=>void _(()=>el(e.task.prompt)),children:`Copy prompt`}),(0,Q.jsx)(J,{size:`sm`,variant:`outline`,disabled:o||v&&!y,onClick:()=>void _(async()=>{let t=await Nn(e.id,e.revision);i(`/tasks/${t.runId}`)}),children:y?`Start missing runs`:r.status===`failed`?`Retry`:`Run now`}),(0,Q.jsx)(J,{size:`sm`,variant:`ghost`,disabled:o||v||b,onClick:g,children:`Change time`}),(0,Q.jsx)(J,{size:`sm`,variant:`ghost`,disabled:o||v&&!y,onClick:()=>void _(()=>Gn(e.id,e.revision)),children:y?`Dismiss`:`Cancel`})]}),u&&!b&&(0,Q.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:t=>{t.preventDefault(),_(async()=>{let[t,n]=m.split(`:`).map(Number);await Wn(e.id,{expectedRevision:u.revision,name:u.name,kind:`schedule`,task:u.task,schedule:{type:`once`,date:f,hour:t??0,minute:n??0},enabled:!0}),d(null)})},children:[(0,Q.jsxs)(`label`,{children:[`Date`,(0,Q.jsx)(Kc,{type:`date`,required:!0,value:f,onChange:e=>p(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[`Time (server time zone)`,(0,Q.jsx)(Kc,{type:`time`,required:!0,value:m,onChange:e=>h(e.target.value)})]}),(0,Q.jsx)(J,{type:`submit`,disabled:o,children:`Save time`})]}),c&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:c})]})]})}var kg=new Map,Ag=new Set,jg=()=>{for(let e of Ag)e()},Mg=e=>(Ag.add(e),()=>{Ag.delete(e)});function Ng(e=$n()){kg.delete(e),jg()}function Pg(){let e=mi(),t=kr(),n=t??$n(),r=(0,Z.useSyncExternalStore)(Mg,()=>kg.has(n)),i=bi(!1),a=i.data?.automations.some(e=>e.deferredStart)??!1;return(0,Z.useEffect)(()=>vi((e,r)=>{e===`automation-change`&&(t===null||r.project===t)&&Ng(n)}),[t,n]),(0,Z.useEffect)(()=>{i.data&&!a&&!kg.has(n)&&(kg.set(n,i.dataUpdatedAt),jg())},[i.data,i.dataUpdatedAt,a,n]),e.known&&!e.off&&(!r||a)}function Fg({archived:e,onToggle:t,className:n}){let r=e?pl:wa;return(0,Q.jsx)(Qc,{label:e?`Move back to the active list`:`Move to the archived list`,children:(0,Q.jsx)(`button`,{type:`button`,"data-slot":`archive-toggle`,"aria-label":e?`Unarchive task`:`Archive task`,onClick:n=>{n.stopPropagation(),t(!e)},className:W(`inline-flex size-5 shrink-0 items-center justify-center rounded-sm text-soft-foreground transition-colors hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,n),children:(0,Q.jsx)(r,{className:`size-3`,"aria-hidden":`true`})})})}function Ig(){return(0,Q.jsx)(`span`,{"data-slot":`unread-marker`,className:`sr-only`,children:`, unread`})}var Lg={statuses:[],workflows:[],automations:[]};function Rg(e){return e.statuses.length+e.workflows.length+e.automations.length}function zg(e){let t=new Map(e.map(e=>[e.id,e]));return new Map(e.map(e=>[e.id,ep(e,e=>t.get(e))]))}var Bg=(e,t)=>e.length===0||t!==void 0&&e.includes(t);function Vg(e,t,n,r){return e.filter(e=>{let i=r.get(e.id);return!(!tp(i,t)||!Bg(n.statuses,e.status)||!Bg(n.workflows,he(e))||t!==`regular`&&!Bg(n.automations,i))})}function Hg(e,t){return t===`all`?[...e]:Vg(e,t,Lg,zg(e))}function Ug(e,t,n,r,i){let a=new Map;for(let o of Vg(e,t,{...n,[i]:[]},r)){let e=i===`statuses`?o.status:i===`workflows`?he(o):r.get(o.id);e!==void 0&&a.set(e,(a.get(e)??0)+1)}return a}function Wg(e,t,n){return{regular:Vg(e,`regular`,t,n).length,automation:Vg(e,`automation`,t,n).length,all:Vg(e,`all`,t,n).length}}function Gg(e){let t=new Set;for(let n of e)n!==void 0&&t.add(n);return[...t].sort((e,t)=>e.localeCompare(t))}function Kg(e){let t=new Map;for(let n of e)t.has(n.id)||t.set(n.id,{run:n,depth:0,children:[],childCount:0,descendantCount:0});let n=e=>{let n=e.dispatch?.parentRunId;if(n===void 0||n===e.id)return null;let r=t.get(n);if(r===void 0)return null;let i=new Set([e.id]),a=r;for(;a!==void 0;){if(i.has(a.run.id))return null;i.add(a.run.id);let e=a.run.dispatch?.parentRunId;a=e===void 0?void 0:t.get(e)}return r},r=[];for(let i of e){let e=t.get(i.id);if(e===void 0||e.run!==i)continue;let a=n(i);a===null?r.push(e):a.children.push(e)}let i=(e,t)=>{e.depth=t,e.childCount=e.children.length;let n=0;for(let r of e.children)n+=1+i(r,t+1);return e.descendantCount=n,n};for(let e of r)i(e,0);return r}function qg(e,t){let n=[],r=e=>{for(let i of e)n.push(i),(i.children.length===0||t===void 0||t(i.run.id))&&r(i.children)};return r(e),n}function Jg(e,t){return qg(Kg(e),t)}function Yg(e){return e<=0?null:`${e} subtask${e===1?``:`s`}`}function Xg(e){return e.dispatch?.parentRunId===void 0?null:e.dispatch.kind??`implement`}var Zg=Z.createContext(void 0);function Qg({runs:e,view:t,onViewChange:n,currentRunId:r=null,now:i=Date.now(),showTokens:a=!0,showCost:o=!0,onTogglePin:s,onToggleArchive:c}){let l=Le(e),u=xe(e,t),d=t===`archived`?void 0:s;return(0,Q.jsxs)(`div`,{"data-slot":`quick-list`,children:[(0,Q.jsx)(`div`,{className:`sticky top-0 z-10 bg-sidebar pt-2 pb-1`,children:(0,Q.jsxs)(`div`,{className:`inline-flex w-full gap-0.5 rounded-md bg-muted p-[3px]`,children:[(0,Q.jsxs)(t_,{view:`active`,current:t,onSelect:n,count:l.active,children:[`Active`,l.waiting>0&&t!==`active`?(0,Q.jsx)(Jc,{tone:`pending`,pulse:!0,"data-slot":`waiting-dot`,"aria-label":`needs you`}):null]}),(0,Q.jsx)(t_,{view:`archived`,current:t,onSelect:n,count:l.archived,children:`Archived`})]})}),u.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-3.5 text-xs text-soft-foreground`,children:t===`archived`?`Nothing archived yet.`:`No tasks yet — describe one.`}):(0,Q.jsx)($g,{buckets:u,currentRunId:r,now:i,showTokens:a,showCost:o,onTogglePin:d,onToggleArchive:c})]})}function $g({buckets:e,currentRunId:t=null,now:n=Date.now(),scope:r=null,showTokens:i=!0,showCost:a=!0,onTogglePin:o,onToggleArchive:s}){let[c,l]=Z.useState(()=>new Set),u=e=>l(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});return(0,Q.jsx)(Q.Fragment,{children:e.map(e=>(0,Q.jsxs)(`div`,{"data-slot":`quick-list-bucket`,"data-bucket":e.label,children:[(0,Q.jsx)(`h2`,{className:`px-3 pt-2.5 pb-1 eyebrow text-soft-foreground`,children:e.label}),e_(e.rows).map(e=>(0,Q.jsx)(n_,{row:e.run.row,depth:e.depth,childCount:e.childCount,currentRunId:t,now:n,scope:r,showTokens:i,showCost:a,expanded:e.run.row.kind===`group`&&c.has(e.run.row.groupId),onToggle:u,onTogglePin:o,onToggleArchive:s},e.run.id))]},e.label))})}function e_(e){return Jg(e.map(e=>e.kind===`group`?{id:`group:${e.groupId}`,row:e}:{id:e.run.id,dispatch:e.run.dispatch,row:e}))}function t_({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:W(`flex h-7 flex-1 items-center justify-center gap-1.5 rounded-[7px] text-label font-medium text-muted-foreground`,a&&`bg-card font-semibold text-foreground shadow-xs`),children:[i,r>0?(0,Q.jsx)(`span`,{className:`font-mono text-meta tabular-nums`,children:r}):null]})}function n_({row:e,depth:t,childCount:n,currentRunId:r,now:i,scope:a,expanded:o,onToggle:s,showTokens:c,showCost:l,onTogglePin:u,onToggleArchive:d}){return e.kind===`run`?(0,Q.jsx)(c_,{run:e.run,depth:t,childCount:n,queuePosition:e.queuePosition,currentRunId:r,now:i,scope:a,showTokens:c,showCost:l,onTogglePin:u,onToggleArchive:d}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center rounded-sm hover:bg-muted`,children:[(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`group-tile`,"data-group-id":e.groupId,"aria-expanded":o,onClick:()=>s(e.groupId),className:`flex min-w-0 flex-1 items-center gap-2 px-2.5 py-[7px] text-left`,children:[(0,Q.jsx)(Ws,{className:W(`size-3 shrink-0 text-soft-foreground transition-transform`,!o&&`-rotate-90`),"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-[7rem] flex-1 truncate text-ui font-medium`,children:e.title}),(0,Q.jsxs)(`span`,{className:`shrink-0 rounded-full bg-muted px-1.5 py-px font-mono text-micro font-semibold text-muted-foreground`,children:[`×`,e.members.length]})]}),(0,Q.jsx)(K,{to:_r(a,`/compare/${e.groupId}`),"data-slot":`group-compare`,title:`Compare the variants`,"aria-label":`Compare the variants of ${e.title}`,className:`mr-1.5 inline-flex size-6 shrink-0 items-center justify-center rounded-sm text-soft-foreground hover:bg-violet/10 hover:text-violet`,children:(0,Q.jsx)(eu,{className:`size-3.5`,"aria-hidden":`true`})})]}),o?e.members.map(e=>(0,Q.jsx)(c_,{run:e,queuePosition:null,currentRunId:r,now:i,scope:a,variant:!0,showTokens:c,showCost:l,onTogglePin:u,onToggleArchive:d},e.id)):null]})}var r_=`flex w-0 shrink-0 items-center gap-0.5 overflow-hidden opacity-0 group-hover/task-row:mr-1.5 group-hover/task-row:w-auto group-hover/task-row:opacity-100 group-focus-within/task-row:mr-1.5 group-focus-within/task-row:w-auto group-focus-within/task-row:opacity-100 no-hover:mr-1.5 no-hover:w-auto no-hover:opacity-100`,i_=`no-hover:size-7`,a_=`group-hover/task-row:hidden group-focus-within/task-row:hidden`,o_=`no-hover:hidden`,s_=`group-hover/task-row:min-w-0 group-focus-within/task-row:min-w-0 no-hover:min-w-0`,c_=Z.memo(function({run:e,depth:t=0,childCount:n=0,queuePosition:r,currentRunId:i,now:a,scope:s,variant:c=!1,showTokens:l,showCost:u,onTogglePin:d,onToggleArchive:f}){let m=!!f&&(!!e.archived||!Ts(e.status)),h=!!d||m,g=o(e),_=Z.useId(),v=e.id===i,y=zt(e,Z.useContext(Zg)),b=Ve(e),x=Ne(b,y?.number)?qe(b).rest:b,S=$o(e),C=Zo(e),w=c?``:r===null?Xc(p(e),a):`#${r}`,T=Yg(n),E=Xg(e);return(0,Q.jsxs)(`div`,{"data-slot":`task-row`,"data-run-id":e.id,"data-active":v?`true`:void 0,"data-depth":t,style:t>0?{paddingLeft:`${10+t*14}px`}:void 0,className:W(`group/task-row flex items-center gap-2 rounded-sm pl-2.5 hover:bg-muted`,v&&`bg-muted`,c&&`pl-[26px]`),children:[(0,Q.jsx)(K,{to:_r(s,`/tasks/${e.id}`),tabIndex:-1,"aria-hidden":`true`,"data-slot":`task-row-dot-link`,className:`-ml-2.5 flex shrink-0 items-center self-stretch pl-2.5`,children:(0,Q.jsx)(Jc,{id:_,tone:g.tone,pulse:g.pulse,"aria-label":g.label,role:`img`})}),y?(0,Q.jsx)(Ca,{run:e,reference:y,compact:!0,className:`h-auto shrink-0 gap-[2px] px-1.5 py-px text-micro`}):null,(0,Q.jsxs)(K,{to:_r(s,`/tasks/${e.id}`),title:b,"aria-current":v?`page`:void 0,"aria-describedby":_,"data-slot":`task-row-link`,className:W(`flex min-w-0 flex-1 items-center gap-2 py-[7px]`,h?`pr-0.5`:`pr-2.5`),children:[c?(0,Q.jsx)(`span`,{className:`inline-flex size-[15px] shrink-0 items-center justify-center rounded-full bg-violet/15 font-mono text-[9.5px] font-semibold text-violet`,children:e.variant??`?`}):null,(0,Q.jsxs)(`span`,{"data-slot":`task-row-title`,className:W(`min-w-[7rem] flex-1 truncate text-ui`,h&&s_,S?`font-semibold text-foreground`:C?`font-medium text-muted-foreground`:`font-medium`),children:[c?l_(e,l,u):x,e.queueWaitReason&&(0,Q.jsx)(`span`,{className:`block truncate text-meta font-normal text-muted-foreground`,children:Ao(e.queueWaitReason)})]}),(0,Q.jsxs)(`span`,{"data-slot":`task-row-meta`,className:W(`contents`,h&&a_),children:[(0,Q.jsxs)(`span`,{"data-slot":`task-row-meta-droppable`,className:W(`contents`,h&&o_),children:[E?(0,Q.jsx)(`span`,{"data-slot":`dispatch-kind`,className:`shrink-0 rounded-full bg-muted px-1.5 py-px text-micro font-medium text-muted-foreground`,children:E}):null,e.diffStat?(0,Q.jsx)(Zc,{stat:e.diffStat,className:`hidden shrink-0 text-micro @min-[23rem]/sidebar:inline`}):null,T?(0,Q.jsx)(`span`,{"data-slot":`subtask-count`,title:T,className:`hidden shrink-0 rounded-full bg-muted px-1.5 py-px text-micro font-medium text-muted-foreground @min-[19rem]/sidebar:inline`,children:n}):null]}),w&&(r!==null||!y)?(0,Q.jsx)(`span`,{"data-slot":`task-row-age`,className:W(`shrink-0 text-meta text-soft-foreground tabular-nums`,E&&t>0&&r===null&&`hidden @min-[19rem]/sidebar:inline`),children:w}):null]}),S?(0,Q.jsx)(Ig,{}):null]}),s===null&&e.subject?(0,Q.jsx)(Qa,{run:e,className:h?`mr-0.5`:`mr-2.5`}):null,h?(0,Q.jsxs)(`div`,{"data-slot":`task-row-actions`,className:r_,children:[d?(0,Q.jsx)(La,{pinned:!!e.pinned,onToggle:t=>d(e,t),className:i_}):null,m&&f?(0,Q.jsx)(Fg,{archived:!!e.archived,onToggle:t=>f(e,t),className:i_}):null]}):null]})});function l_(e,t,n){let r=[e.runner??`claude`];t&&(e.inputTokens!==void 0||e.outputTokens!==void 0)&&r.push(jc(e.inputTokens,e.outputTokens));let i=we(e.costUsd);return n&&i&&r.push(i),r.join(` · `)}function u_(){let e=C(),t=se(kr(),e.data?.bootProject??null),n=un(`sidebar`),r=Yc(e.data),[i,a]=sg(),o=Pg(),[s]=lp(),c=Z.useMemo(()=>t.data?Hg(t.data,s):void 0,[t.data,s]),l=Cr(`/tasks/:id/*`),u=Cr(`/tasks/:id`),d=Yr(3e4),f=Z.useCallback((e,t)=>n.mutate({id:e.id,pinned:t},{onError:e=>Y(e.message,{tone:`danger`})}),[n.mutate]),p=Gt(`sidebar`),m=Z.useCallback((e,t)=>p.mutate({id:e.id,archived:t},{onError:e=>Y(e.message,{tone:`danger`})}),[p.mutate]),h=Lt(),g=We(),_=Z.useMemo(()=>h===void 0?[]:(c??[]).flatMap(e=>ce(e).map(e=>({projectId:h,kind:e.kind,number:e.number}))),[c,h]);return c?(0,Q.jsx)(Ur,{projectId:h,requests:_,children:(0,Q.jsxs)(Zg.Provider,{value:g,children:[i===`active`&&o&&(0,Q.jsx)(Dg,{compact:!0}),(0,Q.jsx)(Qg,{runs:c,view:i,onViewChange:a,currentRunId:l?.params.id??u?.params.id??null,now:d,showTokens:r.tokens,showCost:r.cost,onTogglePin:f,onToggleArchive:m})]})}):null}function d_({projects:e,folder:t,onClose:n,onSave:r}){let[i,a]=Z.useState(t?.name??``),[o,s]=Z.useState(t?.projectIds??[]),[c,l]=Z.useState(!1);return(0,Q.jsx)(qr,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(Wr,{"data-slot":`project-folder-dialog`,children:[(0,Q.jsxs)(Lr,{children:[(0,Q.jsx)(Zr,{children:t?`Organise folder`:`Create project folder`}),(0,Q.jsx)(Vr,{children:`Group projects for a client or any other part of your work.`})]}),(0,Q.jsxs)(`label`,{className:`grid gap-2 text-sm font-medium`,children:[`Folder name`,(0,Q.jsx)(Kc,{autoFocus:!0,value:i,onChange:e=>a(e.target.value),placeholder:`Client name`})]}),(0,Q.jsxs)(`fieldset`,{role:`group`,"aria-label":`Select projects`,className:`grid max-h-60 gap-1 overflow-y-auto`,children:[(0,Q.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:`Projects`}),e.map(e=>(0,Q.jsxs)(`label`,{className:`flex min-h-9 items-center gap-2 rounded px-2 text-sm hover:bg-muted`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:o.includes(e.id),onChange:t=>s(n=>t.target.checked?[...n,e.id]:n.filter(t=>t!==e.id))}),(0,Q.jsx)(dc,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),e.name]},e.id))]}),(0,Q.jsxs)(Br,{className:`sm:justify-between`,children:[t?c?(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(J,{type:`button`,variant:`danger-ghost`,onClick:()=>r(null,t.id),children:`Confirm delete`}),(0,Q.jsx)(J,{type:`button`,variant:`ghost`,onClick:()=>l(!1),children:`Keep folder`})]}):(0,Q.jsx)(J,{type:`button`,variant:`danger-ghost`,onClick:()=>l(!0),children:`Delete folder`}):(0,Q.jsx)(`span`,{}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(J,{type:`button`,variant:`outline`,onClick:n,children:`Cancel`}),(0,Q.jsx)(J,{type:`button`,disabled:!i.trim(),onClick:()=>r({id:t?.id??crypto.randomUUID(),name:i.trim(),projectIds:o},t?.id),children:`Save folder`})]})]})]})})}var f_=`cez-project-folders`;function p_(e){if(!Array.isArray(e))return[];let t=new Set,n=new Set;return e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let r=e,i=typeof r.id==`string`?r.id.trim():``;if(!i||t.has(i)||typeof r.name!=`string`||!r.name.trim())return[];t.add(i);let a=Array.isArray(r.projectIds)?[...new Set(r.projectIds.filter(e=>typeof e==`string`&&!n.has(e)))]:[];return a.forEach(e=>n.add(e)),[{id:i,name:r.name.trim(),projectIds:a}]})}function m_(){try{let e=localStorage.getItem(f_);return e===null?[]:p_(JSON.parse(e))}catch{return[]}}function h_(e){try{localStorage.setItem(f_,JSON.stringify(e))}catch{}}function g_(e,t,n){let r=e.filter(e=>e.id!==n&&e.id!==t?.id);return t&&(r=r.map(e=>({...e,projectIds:e.projectIds.filter(e=>!t.projectIds.includes(e))})),r.push(t)),r}function __(e,t,n){return e.map(e=>e.id===n?e.projectIds.includes(t)?e:{...e,projectIds:[...e.projectIds,t]}:e.projectIds.includes(t)?{...e,projectIds:e.projectIds.filter(e=>e!==t)}:e)}var v_=`cez-sidebar-collapsed`;function y_(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 b_(){try{let e=localStorage.getItem(v_);return e===null?{}:y_(JSON.parse(e))}catch{return{}}}function x_(e){try{localStorage.setItem(v_,JSON.stringify(e))}catch{}}function S_(e,t,n){let r=e?.[t];return r===void 0?t!==n:r}function C_(e,t,n,r){let i=e?.[`folder:${t}`];return i===void 0?!(r!==null&&n.includes(r)):i}var w_=10;function T_(e){let[t,n]=Z.useState(b_),r=Z.useRef(t),i=Z.useCallback(e=>{r.current=e,x_(e),n(e)},[]);return{collapsed:t,toggle:Z.useCallback(t=>{i({...r.current,[t]:!S_(r.current,t,e)})},[e,i]),expand:Z.useCallback(e=>{if(!(e in r.current))return;let t={...r.current};delete t[e],i(t)},[i])}}var E_=new Set;function D_({projects:e,bootProjectId:t,inboxAvailable:n=!1,automationsAvailable:r=!1,inboxCount:i=null,skillsUpdateAvailable:a=!1,newNavItems:o=E_}){let{pathname:s}=jr(),c=Sr(s),l=c??t,{collapsed:u,toggle:d,expand:f}=T_(l),[p,m]=Z.useState(m_),h=Z.useCallback(e=>{f(e);for(let t of p)t.projectIds.includes(e)&&f(`folder:${t.id}`)},[f,p]),[g,_]=Z.useState(void 0),v=Z.useCallback((e,t)=>{let n=g_(p,e,t);m(n),h_(n),_(void 0)},[p]),[y]=sg(),b=Df(Er(s)),x=Cr(`/tasks/:id/*`),S=Cr(`/tasks/:id`),w=x?.params.id??S?.params.id??null,T=Yr(3e4),E=Yc(C().data),{order:D,canReorder:O,setOrder:k}=pp(),A=Z.useMemo(()=>{let t=Jf(e,D),n=t.filter(e=>e.unregistered);return n.length===0?t:[...n,...t.filter(e=>!e.unregistered)]},[e,D]),j=Z.useMemo(()=>A.map(e=>e.id),[A]),M=Di($r(Oi,{activationConstraint:{distance:4}}),$r(pi,{coordinateGetter:hi})),N=O&&A.length>1,P=Z.useCallback(e=>{let{active:t,over:n}=e;if(n===null||n.id===t.id)return;let r=String(t.id),i=String(n.id),a=j.indexOf(r),o=j.indexOf(i);if(a===-1||o===-1)return;let s=p.find(e=>e.projectIds.includes(r)),c=p.find(e=>e.projectIds.includes(i));if(s?.id!==c?.id){let e=__(p,r,c?.id??null);m(e),h_(e)}k(Yf(j,a,o))},[p,j,k]),F=Z.useMemo(()=>{let e=e=>{let t=j.indexOf(String(e));return{name:A[t]?.name??String(e),position:`position ${t+1} of ${j.length}`}};return{onDragStart:({active:t})=>{let{name:n,position:r}=e(t.id);return`Picked up ${n}, ${r}.`},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,j]),ee=A.map(e=>(0,Q.jsx)(k_,{project:e,boot:e.id===t,active:e.id===c,collapsed:S_(u,e.id,l),onToggle:d,onSelect:h,view:y,activeTo:b,currentRunId:w,now:T,inboxAvailable:n,automationsAvailable:r,inboxCount:i,skillsUpdateAvailable:a,newNavItems:o,showTokens:E.tokens,showCost:E.cost,sortable:N,position:j.indexOf(e.id)+1,total:j.length},e.id)),te=new Map(A.map((e,t)=>[e.id,ee[t]])),I=Z.useMemo(()=>[...p.map(e=>({folder:e,projects:A.filter(t=>e.projectIds.includes(t.id))})),{folder:null,projects:A.filter(e=>!p.some(t=>t.projectIds.includes(e.id)))}].filter(({folder:e,projects:t})=>e!==null||t.length>0||p.length===0),[p,A]),ne=Z.useMemo(()=>I.flatMap(({folder:e,projects:t})=>{let n=t.map(e=>e.id);return e&&C_(u,e.id,n,c)?[]:n}),[I,u,c]);return(0,Q.jsxs)(`div`,{"data-slot":`project-group-list`,children:[(0,Q.jsx)(`div`,{className:`mb-1 flex justify-end`,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`project-folder-create`,onClick:()=>_(null),className:`flex h-7 items-center gap-1 rounded px-2 text-xs text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,Q.jsx)(Al,{className:`size-3.5`,"aria-hidden":`true`}),` New folder`]})}),(0,Q.jsx)(ki,{sensors:M,collisionDetection:li,accessibility:{announcements:F},onDragEnd:P,children:(0,Q.jsx)(Ci,{items:ne,strategy:gi,children:I.map(({folder:e,projects:t})=>{let n=t.map(e=>e.id),r=e&&C_(u,e.id,n,c);return(0,Q.jsx)(Z.Fragment,{children:e?(0,Q.jsxs)(`div`,{"data-slot":`project-folder`,"data-folder":e.id,className:`mb-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-expanded":!r,onClick:()=>d(`folder:${e.id}`),className:`flex h-8 min-w-0 flex-1 items-center gap-2 rounded px-2 text-xs font-semibold text-muted-foreground hover:bg-muted`,children:[(0,Q.jsx)(Ws,{className:W(`size-3 transition-transform`,r&&`-rotate-90`),"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Q.jsx)(`span`,{className:`ml-auto`,"aria-label":`${t.length} project${t.length===1?``:`s`}`,children:t.length})]}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Edit ${e.name}`,onClick:()=>_(e),className:`size-8 rounded text-xs text-muted-foreground hover:bg-muted`,children:`…`})]}),r?null:(0,Q.jsx)(`div`,{className:`ml-2 border-l border-border pl-1`,children:t.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-1 text-xs text-muted-foreground`,children:`No projects`}):t.map(e=>te.get(e.id))})]}):t.map(e=>te.get(e.id))},e?.id??`ungrouped`)})})}),g!==void 0&&(0,Q.jsx)(d_,{projects:e,folder:g,onClose:()=>_(void 0),onSave:v})]})}function O_({name:e,position:t,total:n,disabled:r,handleProps:i}){return(0,Q.jsx)(`button`,{type:`button`,"data-slot":`project-group-grip`,disabled:r,"aria-label":`Reorder ${e}, position ${t} of ${n}`,className:W(`flex h-11 w-6 shrink-0 cursor-grab items-center justify-center rounded text-muted-foreground opacity-0 outline-none transition-opacity md:h-[34px] md:w-4`,`touch-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`,r&&`cursor-default group-hover/row:opacity-0 group-focus-within/row:opacity-0 [@media(hover:none)]:opacity-0`),...i,children:(0,Q.jsx)(io,{"aria-hidden":`true`,className:`size-3.5`})})}function k_({project:e,boot:t,active:n,collapsed:r,onToggle:i,onSelect:a,view:o,activeTo:s,currentRunId:c,now:l,inboxAvailable:u,automationsAvailable:d,inboxCount:f,skillsUpdateAvailable:p,newNavItems:m,showTokens:h,showCost:g,sortable:_,position:v,total:y}){let b=e.status===`missing`,x=_&&!b&&!e.unregistered,{attributes:S,listeners:C,setNodeRef:w,transform:T,transition:E,isDragging:D}=di({id:e.id,disabled:!x}),O={transform:ui.Translate.toString(T),transition:E},k=(0,Q.jsx)(O_,{name:e.name,position:v,total:y,disabled:!x,handleProps:{...S,...C}}),A=Ye(e.id,!r&&!b,t),j=We(),M=e.repoUrl??(n?j:void 0),P=mh(),F=un(`sidebar`,e.id,t?`default`:e.id),ee=Z.useCallback((e,t)=>F.mutate({id:e.id,pinned:t},{onError:e=>Y(e.message,{tone:`danger`})}),[F.mutate]),te=Gt(`sidebar`,e.id,t?`default`:e.id),I=Z.useCallback((e,t)=>te.mutate({id:e.id,archived:t},{onError:e=>Y(e.message,{tone:`danger`})}),[te.mutate]),[ne]=lp(),L=A.data?Le(A.data).waiting:0,re=A.data?N(xe(Hg(A.data,ne),o),w_):[],ie=re.flatMap(t=>t.rows.flatMap(t=>ce(t.kind===`run`?t.run:t.members[0]).map(t=>({projectId:e.id,kind:t.kind,number:t.number}))));if(b)return(0,Q.jsx)(`div`,{ref:w,style:O,"data-slot":`project-group`,"data-project":e.id,"data-status":`missing`,className:W(`mb-1`,D&&`relative z-10 opacity-40`),children:(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`w-6 shrink-0 md:w-4`}),(0,Q.jsxs)(`div`,{"data-slot":`project-group-header`,title:`${e.root} is gone — remove it in Global settings → Projects`,className:`flex h-11 min-w-0 flex-1 items-center gap-[7px] rounded-lg px-2 text-ui font-semibold opacity-55 md:h-[34px]`,children:[(0,Q.jsx)(`span`,{className:`w-3 shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Q.jsx)(`span`,{"data-slot":`project-missing`,className:`ml-auto shrink-0 rounded-full bg-danger/15 px-[7px] py-px text-micro font-medium text-danger`,children:`folder not found`})]})]})});let ae=`project-group-${e.id}`;return(0,Q.jsxs)(`div`,{ref:w,style:O,"data-slot":`project-group`,"data-project":e.id,"data-status":e.status,"data-collapsed":r?``:void 0,"data-dragging":D?``:void 0,"data-active":n?``:void 0,className:W(`mb-1`,D&&`relative z-10 opacity-40`),children:[(0,Q.jsxs)(`div`,{className:`group/row flex items-center`,children:[k,(0,Q.jsxs)(`div`,{"data-slot":`project-group-row`,className:W(`flex min-w-0 flex-1 items-center rounded-lg transition-colors hover:bg-muted`,n&&`bg-muted`),children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),"aria-expanded":!r,"aria-controls":ae,"aria-label":`${r?`Expand`:`Collapse`} ${e.name}`,"data-slot":`project-group-disclosure`,className:W(`flex h-11 w-[27px] shrink-0 items-center justify-center rounded-lg md:h-[34px]`),children:(0,Q.jsx)(Ws,{className:W(`size-3 shrink-0 text-muted-foreground transition-transform`,r&&`-rotate-90`),"aria-hidden":`true`})}),(0,Q.jsxs)(K,{to:_r(e.id,`/`),onClick:()=>{a(e.id),P?.()},"aria-current":n?`true`:void 0,"data-slot":`project-group-header`,className:W(`flex h-11 min-w-0 flex-1 items-center gap-[7px] rounded-lg pr-2 text-left text-ui font-semibold md:h-[34px]`,n&&`text-foreground`),children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),e.unregistered?(0,Q.jsx)(`span`,{"data-slot":`project-unregistered`,title:`cezar is serving this folder — it is not in your saved projects. Add it from this project's Settings.`,className:`shrink-0 rounded-full bg-muted px-[7px] py-px text-micro font-medium text-soft-foreground`,children:`not saved`}):null,L?(0,Q.jsx)(`span`,{"data-slot":`project-attention`,title:`${L} task${L===1?``:`s`} need${L===1?`s`:``} you`,className:`shrink-0 rounded-full bg-violet px-1.5 py-px text-micro font-semibold text-violet-foreground`,children:L}):null,e.branch?(0,Q.jsx)(`span`,{"data-slot":`project-branch`,className:`ml-auto max-w-[92px] truncate font-mono text-micro font-medium text-soft-foreground`,children:e.branch}):null]})]})]}),r?null:(0,Q.jsxs)(`div`,{id:ae,"data-slot":`project-group-body`,className:`mt-1 ml-[14px] border-l border-border pl-2`,children:[(0,Q.jsx)(`nav`,{"aria-label":`${e.name} navigation`,children:Tf({forge:e.forge===`github`,inbox:u,automations:d,tracker:e.tracker}).map(t=>{let r=n&&t.to===s,i=t.icon;return(0,Q.jsxs)(K,{to:_r(e.id,t.to),onClick:P,"aria-current":r?`page`:void 0,className:W(`flex h-11 w-full items-center gap-2.5 rounded-md px-2.5 text-ui font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground md:h-[30px]`,r&&`bg-muted font-semibold text-foreground`),children:[(0,Q.jsx)(i,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t.label,t.badge===`inbox-count`&&n&&f?(0,Q.jsx)(`span`,{"data-slot":`nav-badge`,className:`ml-auto rounded-full bg-violet px-1.5 py-px text-micro font-semibold text-violet-foreground`,children:f}):null,t.badge===`skills-update`&&n&&p?(0,Q.jsxs)(`span`,{"data-slot":`nav-update-marker`,className:`ml-auto flex items-center`,children:[(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-violet`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Skills update available`})]}):null,n&&m.has(t.to)?(0,Q.jsxs)(`span`,{"data-slot":`nav-new-marker`,className:`ml-auto flex items-center`,children:[(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-violet`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`New`})]}):null]},t.to)})}),(0,Q.jsx)(Ur,{projectId:e.id,requests:ie,children:(0,Q.jsx)(Zg.Provider,{value:M,children:(0,Q.jsx)($g,{buckets:re,currentRunId:n?c:null,now:l,scope:e.id,showTokens:h,showCost:g,onTogglePin:o===`archived`?void 0:ee,onToggleArchive:I})})}),(0,Q.jsx)(K,{to:_r(e.id,`/`),onClick:P,"data-slot":`project-group-more`,className:`flex h-9 items-center rounded-md px-3 text-label text-muted-foreground transition-colors hover:text-foreground md:h-7`,children:`More…`})]})]})}var A_={claude:!0,codex:!0,junie:!0,opencode:!0,cursor:!0,pi:!0,copilot:!0,omp:!0,antigravity:!0,gemini:!0,kimi:!0},j_=e=>Object.hasOwn(A_,e.name);function M_(e){let t=e.checks.filter(j_);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`:e.disk?.level===`critical`?`disk almost full — ${N_(e.disk.freeBytes)} free`:null}function N_(e){return _(e)||`under 100 MB`}function P_(e){let t=e.disk;if(!t||t.level===`ok`)return null;let n=t.worktreesBytes?` Task worktrees use ${_(t.worktreesBytes)}.`:``,r=t.level===`critical`?` New agents will not start until space is freed.`:``;return`Only ${N_(t.freeBytes)} free on the disk holding task worktrees.${n}${r} Reclaim finished tasks' worktrees (branches are kept) or delete old tasks.`}function F_(e){let t=`cezar v${e.version}`,n=M_(e);if(n)return`${t} · ${n}`;let r=e.disk?.level===`low`?` · low disk space (${N_(e.disk.freeBytes)} free)`:``,i=e.checks.filter(e=>!e.available).map(e=>e.name);return r?`${t}${r}`:i.length?`${t} · optional: ${i.join(`, `)} not installed`:t}function I_(e){return e===void 0||e?.available?null:e?e.available===void 0?null:`GitHub is unreachable — ${e.reason??`unknown reason`}. The GitHub tab can retry.`:`No GitHub remote detected — the GitHub tab is hidden. Every plain-git feature still works.`}function L_({health:e,forge:t}){if(!e)return null;let n=I_(t),r=M_(e),i=P_(e);return(0,Q.jsxs)(tc,{children:[(0,Q.jsx)(Ys,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`tools-menu-trigger`,title:F_(e),className:`flex items-center gap-1.5 rounded-full border border-border px-2 py-0.5 text-meta font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,Q.jsx)(Jc,{tone:r||i?`pending`:`success`}),`Tools`,(0,Q.jsx)(Ws,{className:`size-[11px]`,"aria-hidden":`true`})]})}),(0,Q.jsxs)(Zs,{side:`top`,align:`start`,"data-slot":`tools-menu-content`,className:`w-[240px]`,children:[(0,Q.jsx)(Js,{className:`eyebrow text-soft-foreground`,children:`Installed tools`}),e.checks.map(e=>e.available?(0,Q.jsx)(R_,{check:e},e.name):(0,Q.jsx)(B_,{check:e},e.name)),n?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ec,{}),(0,Q.jsx)(`p`,{"data-slot":`forge-note`,className:`px-2 py-1.5 text-meta leading-snug text-muted-foreground`,children:n})]}):null,i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ec,{}),(0,Q.jsx)(`p`,{"data-slot":`disk-note`,className:`px-2 pt-1.5 text-meta leading-snug text-muted-foreground`,children:i}),(0,Q.jsx)($s,{asChild:!0,children:(0,Q.jsx)(K,{to:`/settings/worktrees`,"data-slot":`disk-reclaim`,className:`text-meta font-semibold text-violet`,children:`Manage worktrees →`})})]}):null,(0,Q.jsx)(ec,{}),(0,Q.jsx)($s,{asChild:!0,children:(0,Q.jsxs)(yr,{to:z_,"data-slot":`tools-settings`,className:`gap-2 text-label text-muted-foreground`,children:[(0,Q.jsx)(tu,{className:`size-3.5`,"aria-hidden":`true`}),`Agent accounts`]})})]})]})}function R_({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)(Jc,{tone:`success`}),(0,Q.jsx)(`span`,{className:`font-mono text-label font-medium`,children:e.name}),(0,Q.jsx)(`span`,{"data-slot":`tool-version`,className:`ml-auto font-mono text-meta font-medium text-muted-foreground tabular-nums`,children:e.version??`not found`})]})}var z_=`/settings/global/accounts`;function B_({check:e}){let t=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Jc,{tone:`danger`}),(0,Q.jsx)(`span`,{className:`font-mono text-label font-medium`,children:e.name}),(0,Q.jsx)(`span`,{"data-slot":`tool-version`,className:`ml-auto font-mono text-meta font-medium text-muted-foreground`,children:`not found`})]}),e.hint||j_(e)?(0,Q.jsxs)(`span`,{className:`flex items-end justify-between gap-3 pl-[15px]`,children:[e.hint?(0,Q.jsx)(`span`,{"data-slot":`tool-hint`,className:`min-w-0 text-meta leading-snug text-muted-foreground`,children:e.hint}):null,j_(e)?(0,Q.jsx)(`span`,{"data-slot":`tool-setup`,className:`ml-auto shrink-0 text-meta font-semibold text-violet`,children:`Set up →`}):null]}):null]});return j_(e)?(0,Q.jsx)($s,{asChild:!0,children:(0,Q.jsx)(yr,{to:`${z_}?agent=${encodeURIComponent(e.name)}`,"data-slot":`tool-row`,"data-tool":e.name,"data-available":`false`,className:`flex-col items-stretch gap-1`,children:t})}):(0,Q.jsx)(`div`,{"data-slot":`tool-row`,"data-tool":e.name,"data-available":`false`,className:`flex flex-col items-stretch gap-1 rounded-sm px-2 py-1.5`,children:t})}function V_(e){return e?.trim()||null}function H_({projectName:e,pageLabel:t,brandName:n}){let r=V_(e),i=V_(t),a=V_(n??null)??`cezar`;return r&&i?`${r} — ${i} · ${a}`:r?`${r} · ${a}`:i?`${i} · ${a}`:a}function U_(e){let t=H_(e);(0,Z.useEffect)(()=>{document.title=t},[t]),(0,Z.useEffect)(()=>{let t=document.querySelector(`link[rel="icon"]`);t||(t=document.createElement(`link`),t.rel=`icon`,document.head.append(t)),t.href=e.brandLogoUrl??`/icon.svg`,t.type=e.brandLogoUrl?.includes(`.svg?`)?`image/svg+xml`:``},[e.brandLogoUrl])}function W_(e,t,n){if(e===void 0||n===void 0||t===null||t!==e.bootProject||n.bootProject!==t||n.capabilities?.localHandoff!==!0||e.projects.some(e=>e.id===t))return e;let r=n.repoRoot,i=r?.replace(/[\\/]+$/,``).split(/[\\/]/).pop();return i?{...e,projects:[{id:t,root:r,name:i,addedAt:``,lastOpenedAt:``,source:`local`,status:n.repo?`ok`:`not-git`,unregistered:!0,...n.repo?{branch:n.repo.branch}:{}},...e.projects]}:e}var G_={claude:`Anthropic’s coding agent. Uses your Claude account.`,codex:`OpenAI’s coding agent. Uses your ChatGPT account.`,opencode:`Open-source agent. Works with many model providers.`,cursor:`Cursor’s agent, without the editor. Uses your Cursor account.`,copilot:`GitHub’s coding agent. Uses your Copilot plan.`};function K_(e,t){let n=new Map((t?.providers??[]).map(e=>[e.provider,e])),r=e.agents.flatMap(e=>{let t=n.get(e.provider);if(t?.status===`connected`||t?.enabled===!1)return[];let r=t===void 0||t.status===`not-installed`?`missing`:`signed-out`;return[{...e,label:Go[e.provider],description:G_[e.provider],state:r}]});return[...r.filter(e=>e.state===`signed-out`),...r.filter(e=>e.state===`missing`)]}var q_=/\u001B\][^\u0007\u001B]*(?:\u0007|\u001B\\)|\u001B\[[0-?]*[ -/]*[@-~]/g,J_=/https?:\/\/[^\s"'<>\u0007\u001B]+/g;function Y_(e){let t=e.replace(q_,` `).match(J_)??[];for(let e of t.reverse()){let t=X_(e.replace(/[.,;:)\]]+$/,``));if(t&&![`localhost`,`127.0.0.1`,`[::1]`].includes(t.hostname))return t.href}return null}function X_(e){try{return new URL(e)}catch{return null}}var Z_=Z.lazy(()=>mr(()=>import(`./terminal-pane-D4ZoQdKv.js`).then(e=>({default:e.TerminalPane})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))),Q_=3e3,$_=60,ev=4,tv=1e4;function nv(e,t){return K_(e,t).some(e=>e.state===`signed-out`)?`Sign in to an agent`:`Pick your agent`}function rv({setup:e,status:t}){let n=f(),r=Je(),i=At(),a=rn(),o=a.mutateAsync,s=a.mutate,c=K_(e,t),[l,u]=Z.useState(e.session),[d,p]=Z.useState(null),m=e.session;Z.useEffect(()=>{m&&(u(m),m.exitCode===null&&p(null))},[m]);let h=r.mutate,g=Z.useCallback((e,t)=>{p(null),h({provider:e,action:t},{onSuccess:e=>u(e),onError:n=>{p({provider:e,action:t,message:n.message}),s()}})},[s,h]),_=Z.useRef(null),v=Z.useCallback((e,t)=>{if(_.current===e.id)return;_.current=e.id;let{provider:r,action:i}=e,a=Go[r];i===`install`&&n(),o().then(e=>{let n=e.providers.find(e=>e.provider===r);if(n?.status===`connected`)return;let o=n!==void 0&&n.status!==`not-installed`;i===`install`&&o?g(r,`login`):p(i===`login`||t?{provider:r,action:i,message:t||`The sign-in to ${a} did not finish.`}:{provider:r,action:i,message:`${a} installed, but cezar cannot find it. Restart cezar from a new terminal, or check that npm’s global folder is on your PATH.`})},()=>p({provider:r,action:i,message:`cezar could not check the agent. Try again.`}))},[g,n,o]),y=m?.exitCode??null;Z.useEffect(()=>{if(!(!m||y===null)){if(m.action===`install`&&y!==0){if(_.current===m.id)return;_.current=m.id,n(),p({provider:m.provider,action:m.action,message:`${Go[m.provider]} did not install. The terminal says why.`});return}v(m,``)}},[y,n,m,v]);let b=Z.useRef(null);m&&(b.current=m.id),Z.useEffect(()=>{m||!l||l.exitCode!==null||b.current!==l.id||(u(null),v(l,`The terminal closed before it finished.`))},[m,v,l]);let x=l!==null&&l.exitCode===null,S=x&&l?.action===`install`,C=x&&l?.action===`login`;Z.useEffect(()=>{if(!C)return;let e=0,t=window.setInterval(()=>{e+=1,(e<=$_||e%ev===0)&&s()},Q_);return()=>window.clearInterval(t)},[s,C]),Z.useEffect(()=>{if(x)return;let e=window.setInterval(()=>s(),tv);return()=>window.clearInterval(e)},[s,x]);let w=Z.useRef(null);w.current=C&&l?l.id:null;let T=Z.useRef(!1);Z.useEffect(()=>(T.current=!0,()=>{T.current=!1;let e=w.current;window.setTimeout(()=>{!T.current&&e&&Ln(e).catch(()=>{})},0)}),[]);let E=()=>{l&&i.mutate(l.id),u(null)},D=()=>{p(null),x||u(null)};return(0,Q.jsx)(`div`,{className:`mt-7 flex w-full flex-col gap-3 text-left`,children:c.map(e=>{let t=l?.provider===e.provider,n=d?.provider===e.provider?d:null,i=x||r.isPending;return(0,Q.jsxs)(`div`,{"data-slot":`agent-row`,"data-state":e.state,"data-provider":e.provider,className:`rounded-xl border border-border bg-card p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`text-lead text-foreground`,children:e.label}),(0,Q.jsx)(`div`,{className:`text-ui text-muted-foreground`,children:e.state===`missing`?e.description:`Installed, not signed in`})]}),(0,Q.jsx)(iv,{row:e,open:t,busy:i,onStart:g})]}),!t&&!n&&e.state===`missing`&&e.installCommand===null?(0,Q.jsx)(`p`,{className:`mt-3 text-ui text-soft-foreground`,children:e.installHint}):null,!t&&!n&&e.state===`missing`&&e.installCommand?(0,Q.jsx)(av,{command:e.installCommand}):null,t&&l?(0,Q.jsx)(ov,{session:l,running:x,installing:S},l.id):null,n&&!t?(0,Q.jsx)(av,{command:(n.action===`install`?e.installCommand:e.loginCommand)??``}):null,n?(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,Q.jsx)(`p`,{role:`alert`,className:`min-w-0 flex-1 text-ui text-danger`,children:n.message}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(J,{size:`sm`,variant:`outline`,className:`font-normal`,onClick:D,children:`Close`}),(0,Q.jsx)(J,{size:`sm`,className:`font-normal`,disabled:r.isPending,onClick:()=>g(n.provider,n.action),children:`Try again`})]})]}):null,t&&x?(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:S?`Sign-in comes next.`:`This page continues by itself.`}),(0,Q.jsx)(J,{size:`sm`,variant:`outline`,className:`font-normal`,onClick:E,children:`Cancel`})]}):null]},e.provider)})})}function iv({row:e,open:t,busy:n,onStart:r}){return t?null:e.state===`signed-out`?(0,Q.jsx)(J,{className:`font-normal`,disabled:n||e.loginCommand===null,onClick:()=>r(e.provider,`login`),children:`Sign in`}):e.installCommand===null?null:(0,Q.jsx)(J,{className:`font-normal`,disabled:n,onClick:()=>r(e.provider,`install`),children:`Install`})}function av({command:e}){return(0,Q.jsxs)(`code`,{className:`mt-3 block truncate font-mono text-meta text-soft-foreground`,title:e,children:[(0,Q.jsx)(`span`,{className:`select-none`,children:`$ `}),e]})}function ov({session:e,running:t,installing:n}){let[r,i]=Z.useState(null),a=e.id,o=Z.useRef(``),s=e.action===`login`,c=Z.useMemo(()=>({read:async e=>{let t=await rt(a,e);return s&&t.data&&(o.current=(o.current+t.data).slice(-16384),i(Y_(o.current))),t},write:e=>Be(a,e),resize:(e,t)=>$e(a,e,t)}),[a,s]),l=Z.useMemo(()=>({id:a,exitCode:t?null:e.exitCode,topic:t?e.topic:null}),[a,t,e.exitCode,e.topic]),u=Go[e.provider];return(0,Q.jsxs)(`div`,{"data-slot":`agent-setup-terminal`,className:`mt-3 flex flex-col gap-2`,children:[t?(0,Q.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-ui text-muted-foreground`,children:[(0,Q.jsx)(_c,{className:`size-3.5 shrink-0 motion-safe:animate-spin`,"aria-hidden":`true`}),n?e.command.startsWith(`sudo `)?`Installing ${u}. Click the terminal and type your computer password if it asks.`:`Installing ${u}…`:`Sign in to ${u}. Click the terminal to answer its questions.`]}):null,(0,Q.jsx)(av,{command:e.command}),(0,Q.jsx)(`div`,{className:`relative h-72 overflow-hidden rounded-lg border border-border bg-card-2`,children:(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(Z_,{runId:e.runId,session:l,active:!0,io:c})})}),s&&r&&t?(0,Q.jsx)(J,{asChild:!0,size:`sm`,variant:`outline`,className:`self-start font-normal`,children:(0,Q.jsxs)(`a`,{href:r,target:`_blank`,rel:`noopener noreferrer`,children:[`Open sign-in page`,(0,Q.jsx)(ic,{"aria-hidden":`true`})]})}):null]})}function sv(){let e=U();return Z.useCallback(t=>{let n=B.uiState,r=e.getQueryData(n),i={...r?.onboarding,...typeof t==`function`?t(r?.onboarding):t};e.setQueryData(n,{...r,onboarding:i}),Pt({onboarding:i}).then(t=>e.setQueryData(n,t)).catch(t=>{e.setQueryData(n,r),Y(t instanceof Error?t.message:String(t),{tone:`danger`})})},[e])}function cv({title:e,slot:t,rail:n,why:r,subtitle:i,banner:a,wide:o=!1,children:s}){return(0,Q.jsxs)(`section`,{"data-onboarding":``,"data-slot":`first-run`,"data-first-run":t,className:W(`mx-auto flex w-full flex-1 flex-col items-center px-1 pt-6 pb-12 text-center md:pt-12`,o?`max-w-3xl`:`max-w-2xl`),children:[a,n,(0,Q.jsx)(`h2`,{className:W(`text-4xl font-light tracking-tight text-balance text-foreground`,n&&`mt-8`),children:e}),r?(0,Q.jsx)(`p`,{className:`mt-3 max-w-md text-lead text-muted-foreground`,children:r}):null,i?(0,Q.jsx)(`p`,{className:`mt-2 text-body text-muted-foreground`,children:i}):null,s]})}var lv=`inline-flex items-center gap-1.5 text-ui text-muted-foreground transition-colors hover:text-foreground`,uv=`inline-flex h-[30px] items-center gap-1.5 rounded-full border border-border px-3 text-label text-muted-foreground transition-colors hover:border-muted-foreground hover:text-foreground`,dv=`inline-flex h-8 items-center gap-2 rounded-full px-3 text-ui text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`;function fv(){let[e,t]=Z.useState(0);return Z.useLayoutEffect(()=>{let e=()=>{let e=document.querySelector(`aside[data-slot="sidebar"]`);t(e?Math.max(0,e.getBoundingClientRect().right)/2:0)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),e}function pv({title:e,description:t,onOpenChange:n,onSubmit:r,footer:i,wide:a=!1,children:o}){let s=fv();return(0,Q.jsx)(qr,{open:!0,onOpenChange:n,children:(0,Q.jsxs)(Wr,{"data-onboarding":``,className:W(`gap-0 p-0`,a?`sm:max-w-lg`:`sm:max-w-md`),style:s?{left:`calc(50% + ${s}px)`}:void 0,onKeyDown:e=>{r&&e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),r())},children:[(0,Q.jsxs)(Lr,{className:`border-b border-border px-6 py-5 text-left`,children:[(0,Q.jsx)(Zr,{className:`text-xl font-light tracking-tight`,children:e}),(0,Q.jsx)(Vr,{children:t})]}),(0,Q.jsx)(`div`,{className:`px-6 py-5 text-left`,children:o}),(0,Q.jsx)(Br,{className:`border-t border-border px-6 py-4`,children:i})]})})}function mv({title:e,description:t,pages:n,slot:r,onOpenChange:i}){let[a,o]=Z.useState(0),s=n[Math.min(a,n.length-1)];if(!s)return null;let c=a>=n.length-1,l=()=>c?i(!1):o(a+1);return(0,Q.jsx)(pv,{wide:!0,title:e,description:t,onOpenChange:i,onSubmit:l,footer:(0,Q.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`mr-auto flex items-center gap-1.5`,"aria-label":`${a+1} of ${n.length}`,children:n.map((e,t)=>(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:W(`h-1.5 rounded-full transition-all`,t===a?`w-4 bg-violet`:`w-1.5 bg-border`)},e.id))}),a>0?(0,Q.jsx)(J,{variant:`outline`,className:`font-normal`,onClick:()=>o(a-1),children:`Back`}):null,(0,Q.jsx)(J,{className:`font-normal`,onClick:l,children:c?`Done`:`Next`})]}),children:(0,Q.jsxs)(`div`,{"data-slot":r,"data-page":s.id,onKeyDown:e=>{e.key===`ArrowRight`&&!c&&o(a+1),e.key===`ArrowLeft`&&a>0&&o(a-1)},children:[(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:`onboarding-preview flex h-44 items-end justify-center overflow-hidden rounded-lg border border-border px-8 pt-6`,children:s.picture}),(0,Q.jsxs)(`div`,{className:`mt-5 flex min-h-28 flex-col`,children:[(0,Q.jsx)(`h3`,{className:`text-lg font-light tracking-tight text-foreground`,children:s.title}),(0,Q.jsx)(`p`,{className:`mt-1 text-ui text-muted-foreground`,children:s.body}),s.action?(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{i(!1),s.action?.onClick()},className:`mt-3 inline-flex items-center gap-1 self-start text-ui text-violet hover:underline`,children:[s.action.label,(0,Q.jsx)(co,{className:`size-3.5`,"aria-hidden":`true`})]}):null]})]})})}function hv({title:e,description:t,picture:n,recommended:r=!1,badge:i=`Start here`,onClick:a}){return(0,Q.jsxs)(`button`,{type:`button`,onClick:a,"data-recommended":r||void 0,className:W(`group relative flex flex-col items-center gap-4 rounded-xl border px-4 pt-7 pb-5 text-center transition-colors`,r?`onboarding-announcement`:`border-border bg-card hover:border-muted-foreground`),children:[r?(0,Q.jsx)(`span`,{className:`absolute top-3 right-3 eyebrow text-violet`,children:i}):null,(0,Q.jsx)(`span`,{className:`grid h-16 place-items-center`,"aria-hidden":`true`,children:n}),(0,Q.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-lg font-light text-foreground`,children:e}),(0,Q.jsx)(`span`,{className:`text-label text-muted-foreground`,children:t})]})]})}function gv({title:e,description:t,picture:n,value:r,selected:i,disabled:a=!1,reason:o,onClick:s}){return(0,Q.jsxs)(`button`,{type:`button`,"data-value":r,"aria-pressed":i,"aria-label":e,disabled:a,title:o,onClick:s,className:W(`flex items-center gap-3 rounded-xl border px-4 py-3 text-left transition-colors disabled:opacity-50`,i?`onboarding-announcement border-violet/60`:`border-border bg-card hover:border-muted-foreground`),children:[(0,Q.jsx)(`span`,{className:`grid size-12 shrink-0 place-items-center`,"aria-hidden":`true`,children:n}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-lead text-foreground`,children:e}),(0,Q.jsx)(`span`,{className:`text-label text-muted-foreground`,children:t})]})]})}function _v({steps:e}){return(0,Q.jsx)(`ol`,{"data-slot":`step-rail`,className:`flex items-center gap-2 text-label`,children:e.map((e,t)=>(0,Q.jsxs)(`li`,{"data-step":e.id,"data-state":e.state,className:`flex items-center gap-2`,children:[t>0?(0,Q.jsx)(`span`,{className:W(`h-px w-6`,e.state===`next`?`bg-border`:`bg-violet/60`),"aria-hidden":`true`}):null,(0,Q.jsxs)(`span`,{className:W(`inline-flex items-center gap-1.5`,e.state===`current`?`text-foreground`:e.state===`done`?`text-muted-foreground`:`text-soft-foreground`),children:[(0,Q.jsx)(`span`,{className:W(`grid size-5 place-items-center rounded-full border font-mono text-micro`,e.state===`done`&&`border-violet/60 bg-violet/15 text-violet`,e.state===`current`&&`border-violet text-foreground`,e.state===`next`&&`border-border text-soft-foreground`),"aria-hidden":`true`,children:e.state===`done`?(0,Q.jsx)(Rs,{className:`size-3`}):t+1}),e.label,e.state===`current`?(0,Q.jsx)(`span`,{className:`sr-only`,children:`(current step)`}):null]})]},e.id))})}function vv({bar:e,children:t,className:n}){return(0,Q.jsxs)(`div`,{className:W(`w-full max-w-xs rounded-t-lg border border-b-0 border-border bg-background shadow-[0_-12px_40px_-20px_var(--violet)]`,n),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),e]}),(0,Q.jsx)(`div`,{className:`p-3`,children:t})]})}var yv=`h-2 rounded bg-muted`;function bv(e){return(e?.providers??[]).filter(e=>e.status===`connected`&&e.enabled!==!1).map(e=>e.provider)}function xv(e){if(e!==void 0)return bv(e).length>0}function Sv(e){let t=[];return e.worktreeSetupConfigured===!1&&t.push({id:`worktrees`,label:`Prepare worktrees`,description:`Install dependencies and copy env files into every task worktree.`,action:`Set up`,to:`/settings/worktrees`}),e.forge?.available===!1&&t.push({id:`github`,label:`Connect GitHub`,description:`Pull requests and issues need the GitHub CLI.`,action:`Connect`,to:`/github`}),t}var Cv={claude:{install:`npm i -g @anthropic-ai/claude-code`,login:`claude`},codex:{install:`npm i -g @openai/codex`,login:`codex login`}};function wv(e){let t=new Map((e?.providers??[]).map(e=>[e.provider,e]));return Object.keys(Cv).flatMap(e=>{let n=Cv[e];if(!n)return[];let r=t.get(e);if(r?.status===`connected`||r?.enabled===!1)return[];let i=r?.status===`disconnected`;return[{provider:e,label:Go[e],state:i?`signed-out`:`missing`,command:i?n.login:n.install,login:n.login}]})}var Tv=[{id:`task-tabs-2026-10`,preview:`tabs`,title:`Task tabs and layouts`,description:`Chat, Changes, Preview and Terminal as tabs in every task. Save a layout by name.`,releasedAt:`2026-10-19`},{id:`task-palette-2026-10`,preview:`palette`,title:`Task palette`,description:`Press ⌘P in a task to act on it or jump to another one.`,releasedAt:`2026-10-18`},{id:`design-mode-2026-10`,preview:`design`,title:`Design Mode`,description:`Point at any element of your running app and tell the agent what to change.`,releasedAt:`2026-10-17`,hero:{action:`Try it`,task:`Start the app’s dev server so I can review it in Preview.`},needs:`designMode`},{id:`worktree-scripts-2026-10`,preview:`scripts`,action:`Set up scripts`,title:`Worktree scripts`,description:`Install dependencies and copy env files into every new task worktree.`,releasedAt:`2026-10-17`,to:`/settings/worktrees`},{id:`workflow-editor-2026-10`,preview:`workflow`,action:`Open Workflows`,title:`Workflow editor`,description:`Build a workflow as a graph of steps and run it on a task.`,releasedAt:`2026-10-08`,to:`/workflows`},{id:`automations-2026-09`,preview:`automations`,action:`Open Automations`,title:`Automations`,description:`Start tasks on a schedule or from GitHub events, written as a prompt.`,releasedAt:`2026-09-15`,to:`/automations`,needs:`automations`}];function Ev(e,t){return e.needs===`designMode`?t.designMode===!0:e.needs!==`automations`||t.automations===!0}function Dv(e){let t=new Set(e.dismissed??[]),n=Tv.find(n=>n.hero&&!t.has(n.id)&&Ev(n,e));return n?.hero?{...n,hero:n.hero}:null}var Ov=864e5,kv=3,Av=36e5,jv=60;function Mv(e){if(!e)return null;let t=new Date(e).getTime();return Number.isNaN(t)?null:t}function Nv(e,t){let n=new Date(t).toISOString(),r=Mv(e?.lastVisitAt);return r===null?{firstVisitAt:e?.firstVisitAt??n,lastVisitAt:n}:t-r<Av?null:t-r<14*Ov?{lastVisitAt:n}:{lastVisitAt:n,returnedFrom:e?.lastVisitAt,returnedAt:n}}function Pv(e,t){let n=Mv(e?.returnedAt),r=e?.returnedFrom;if(n===null||Mv(r)===null||!r||t-n>kv*Ov)return null;let i=Mv(e?.welcomeBackClosedAt);return i!==null&&i>=n?null:r}function Fv(e,t){let n=Mv(e)??1/0;return Tv.filter(e=>(Mv(e.releasedAt)??0)>n&&Ev(e,t))}function Iv(e,t,n){let r=Mv(e?.firstVisitAt),i=new Map;if(r===null)return i;let a=new Set(e?.dismissedAnnouncements??[]);for(let e of Tv){let o=Mv(e.releasedAt);!e.to||o===null||a.has(e.id)||!Ev(e,t)||o<=r||n-o>jv*Ov||i.has(e.to)||i.set(e.to,e.id)}return i}function Lv(e,t){return e!==`/`&&(t===e||t.startsWith(`${e}/`))}function Rv(e){let t=e=>Mv(e.finishedAt)??Mv(e.startedAt)??Mv(e.createdAt)??0;return e.filter(e=>!e.archived&&Zt(e)).sort((e,n)=>t(n)-t(e))}function zv(e,t){let n=e[0],r=n?e.length>1?`${e.length} tasks are waiting for you`:n.status===`review`?`One task is ready for your review`:n.status===`waiting`||xt(n)?`One task is waiting for your answer`:`One task needs a look`:null,i=t===0?null:t===1?`there is a new feature to try`:`there are ${t} new features to try`;return r&&i?`${r}, and ${i}.`:r?`${r}.`:i?`${i.charAt(0).toUpperCase()}${i.slice(1)}.`:null}var Bv=90;function Vv(e,t){return Tv.filter(n=>{let r=Mv(n.releasedAt);return r!==null&&t-r<=Bv*Ov&&Ev(n,e)})}function Hv(e,t,n){let r=Mv(e?.firstVisitAt);if(r===null)return!1;let i=Math.max(r,Mv(e?.whatsNewSeenAt)??0);return Vv(t,n).some(e=>(Mv(e.releasedAt)??0)>i)}function Uv(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`)??``,todo:(t.get(`todo`)??``).trim()}}function Wv(e){let t=new URLSearchParams;e.skill&&t.set(`skill`,e.skill),e.ref&&t.set(`ref`,e.ref),e.todo&&t.set(`todo`,e.todo);let n=t.toString();return n?`/new?${n}`:`/new`}function Gv(e){return`${e.kind===`pr`?`Address GitHub pull request`:`Fix GitHub issue`} #${e.number}: ${e.title}\n\n${e.url}`}function Kv(e,t=[]){let n=Gv(e);return e.body?.trim()&&(n+=`\n\n---\n\n${e.body.trim()}`),t.length&&(n+=qv(t)),n}function qv(e){return`\n\nUse these skills where relevant: ${e.join(`, `)}.`}function Jv(e,t){return e.replace(/\{\{\s*number\s*\}\}/gi,()=>`#${t.number}`).replace(/\{\{\s*title\s*\}\}/gi,()=>t.title).replace(/\{\{\s*url\s*\}\}/gi,()=>t.url)}function Yv(e,t){if(e.includes(t.url))return!0;let n=t.kind===`pr`?String.raw`(?:pull\s+request|pr)`:String.raw`issue`;return new RegExp(String.raw`\b${n}\s*#?\s*${t.number}\b`,`i`).test(e)}function Xv(e,t,n){let r=(n??``).trim();if(!r)return Kv(e,t);let i=Gv(e),a=r.startsWith(i)?i+Jv(r.slice(i.length),e):Jv(r,e),o=Yv(a,e)?a:`${i}\n\n${a}`;return t.length?o+qv(t):o}function Zv(e){let t=[];for(let n of e.slice(0,8)){let e=new Set(t.map(e=>e.id)),r=n;for(let t=2;e.has(r);t++)r=`${n}-${t}`;t.push({id:r,name:n,skill:n,prompt:`{{task}}`})}return t}function Qv(e,t,n,r,i={}){return t?{...i,workflow:t,task:Xv(e,n,r)}:n.length?{...i,steps:Zv(n),task:Xv(e,[],r)}:{...i,workflow:`quick-task`,task:Xv(e,[],r)}}function $v(e){let t=new Set;for(let n of e)for(let e of n.labels)t.add(e);return[...t].sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()))}function ey(e,t={}){let n=(t.query??``).trim().toLowerCase(),r=t.labels??[],i=n.replace(/^#/,``),a=i!==``&&/^\d+$/.test(i);return e.filter(e=>r.length>0&&!r.every(t=>e.labels.includes(t))?!1:n===``?!0:a?String(e.number).includes(i):`#${e.number} ${e.title} ${e.author} ${e.body??``}`.toLowerCase().includes(n))}function ty(e,t){let n=t===`oldest`?1:-1;return[...e].sort((e,t)=>e.createdAt===t.createdAt?(e.number-t.number)*n:e.createdAt<t.createdAt?-n:n)}function ny(e,t){return e.trim()!==``&&t===0}function ry(e){if(!e||!/^[0-9a-fA-F]{6}$/.test(e))return{borderColor:`var(--border)`,color:`var(--muted-foreground)`};let t=`#${e}`;return{backgroundColor:`${t}22`,borderColor:`${t}66`,color:`color-mix(in srgb, ${t} 50%, var(--foreground))`}}function iy({gitRepo:e}){let t=St(),n=ht().data?.onboarding?.agentCheckSkipped===!0;return t.data===void 0&&!n?null:xv(t.data)===!1&&!n?(0,Q.jsx)(Iy,{}):e===void 0?null:e?(0,Q.jsx)(Cy,{}):(0,Q.jsx)(Uy,{})}function ay({step:e,...t}){return(0,Q.jsx)(cv,{...t,rail:e?(0,Q.jsx)(sy,{current:e}):void 0})}var oy=[{id:`agent`,label:`Agent`},{id:`project`,label:`Project`},{id:`task`,label:`First task`}];function sy({current:e}){let t=oy.findIndex(t=>t.id===e);return(0,Q.jsx)(`ol`,{"data-slot":`step-rail`,className:`flex items-center gap-2 text-label`,children:oy.map((e,n)=>{let r=n<t?`done`:n===t?`current`:`next`;return(0,Q.jsxs)(`li`,{"data-step":e.id,"data-state":r,className:`flex items-center gap-2`,children:[n>0?(0,Q.jsx)(`span`,{className:W(`h-px w-6`,n<=t?`bg-violet/60`:`bg-border`),"aria-hidden":`true`}):null,(0,Q.jsxs)(`span`,{className:W(`inline-flex items-center gap-1.5`,r===`current`?`text-foreground`:r===`done`?`text-muted-foreground`:`text-soft-foreground`),children:[(0,Q.jsx)(`span`,{className:W(`grid size-5 place-items-center rounded-full border font-mono text-micro`,r===`done`&&`border-violet/60 bg-violet/15 text-violet`,r===`current`&&`border-violet text-foreground`,r===`next`&&`border-border text-soft-foreground`),"aria-hidden":`true`,children:r===`done`?(0,Q.jsx)(Rs,{className:`size-3`}):n+1}),e.label,r===`current`?(0,Q.jsx)(`span`,{className:`sr-only`,children:`(current step)`}):null]})]},e.id)})})}var cy=lv,ly=uv;function uy({children:e}){return(0,Q.jsx)(`ol`,{className:`flex list-decimal flex-col gap-2.5 pl-5 text-ui text-muted-foreground marker:text-soft-foreground`,children:e})}var dy=`https://cli.github.com`;function fy(e,t){let n=l(t),r=n.start.mutate;return Z.useEffect(()=>{e&&r()},[e,r]),n}function py(e){let t=e.state;return e.start.error?my(e.start.error)?`The GitHub CLI is not installed.`:`Sign-in did not finish.`:t?.status===`pending`?`Enter this code on GitHub. It opened in your browser.`:t?.status===`failed`?`Sign-in did not finish.`:t?.status===`done`?`Signed in.`:`Signing in through your browser.`}function my(e){return e instanceof cn&&e.status===503}function hy(e,t){let n=navigator.clipboard?.writeText(e);if(!n){Y(t);return}n.then(()=>Y(`Copied`),()=>Y(t))}function gy({children:e}){return(0,Q.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-ui text-muted-foreground`,children:[(0,Q.jsx)(_c,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}),e]})}function _y({signIn:e}){let t=e.state;return e.start.error?my(e.start.error)?(0,Q.jsxs)(uy,{children:[(0,Q.jsx)(`li`,{children:(0,Q.jsx)(`a`,{href:dy,target:`_blank`,rel:`noopener noreferrer`,className:`text-violet hover:underline`,children:`Install the GitHub CLI`})}),(0,Q.jsx)(`li`,{children:`Come back and press Try again.`})]}):(0,Q.jsx)(`p`,{role:`alert`,className:`text-ui whitespace-pre-line text-danger`,children:e.start.error.message}):t?.status===`failed`?(0,Q.jsx)(`p`,{role:`alert`,className:`text-ui whitespace-pre-line text-danger`,children:t.error}):t?.status===`done`?(0,Q.jsx)(gy,{children:t.login?`Signed in as ${t.login}.`:`Signed in.`}):t?.status===`pending`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border bg-background py-3 pr-2 pl-5`,children:[(0,Q.jsx)(`span`,{"data-testid":`github-login-code`,"aria-label":`One-time code`,className:`font-mono text-2xl tracking-widest text-foreground select-all`,children:t.code}),(0,Q.jsx)(J,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,"aria-label":`Copy code`,onClick:()=>hy(t.code,`Select the code and copy it`),children:(0,Q.jsx)(nc,{"aria-hidden":`true`})})]}),(0,Q.jsx)(gy,{children:`Waiting for GitHub…`})]}):(0,Q.jsx)(gy,{children:`Starting…`})}function vy({signIn:e,onClose:t}){let n=e.state;return e.start.error!==null||n?.status===`failed`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{variant:`outline`,className:`font-normal`,onClick:t,children:`Close`}),(0,Q.jsx)(J,{className:`font-normal`,onClick:()=>e.start.mutate(),disabled:e.start.isPending,children:`Try again`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{variant:`outline`,className:`font-normal`,onClick:()=>{n?.status!==`done`&&e.cancel.mutate(),t()},children:n?.status===`done`?`Close`:`Cancel`}),n?.status===`pending`?(0,Q.jsx)(J,{asChild:!0,className:`font-normal`,children:(0,Q.jsx)(`a`,{href:n.url,target:`_blank`,rel:`noopener noreferrer`,children:`Open GitHub`})}):null]})}function yy({command:e}){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-border bg-background px-3 py-2.5`,children:[(0,Q.jsxs)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-ui text-foreground select-all`,children:[(0,Q.jsx)(`span`,{className:`text-soft-foreground select-none`,children:`$ `}),e]}),(0,Q.jsx)(J,{variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,"aria-label":`Copy ${e}`,onClick:()=>hy(e,`Select the command and copy it`),children:(0,Q.jsx)(nc,{"aria-hidden":`true`})})]})}var by=`flex h-14 w-full items-center gap-3 rounded-xl border border-border bg-card px-5 transition-colors focus-within:border-primary focus-within:shadow-[0_0_0_4px_color-mix(in_srgb,var(--violet)_14%,transparent)]`,xy=[{icon:Dl,label:`Fix a failing test`,task:`Find a failing or flaky test and fix it.`},{icon:fc,label:`Summarize recent commits`,task:`Summarize the recent commits on this branch.`},{icon:_o,label:`Update the README`,task:`Update the README for the recent changes.`}],Sy=[{icon:_o,label:`Write a README`,task:`Write a README that explains what this project is for and how to run it.`},{icon:Dl,label:`Set up tests`,task:`Set up a test runner with one passing example test.`},{icon:fc,label:`Add a CI workflow`,task:`Add a CI workflow that installs dependencies and runs the tests on every push.`}];function Cy(){let e=vr(),t=C(),n=ln(),r=t.data?.forge,i=x({limit:3},r?.kind===`github`&&r.available!==!1),a=i.data?.available?i.data.issues.filter(e=>e.kind===`issue`).slice(0,3):[],[o,s]=Z.useState(``),c=t=>e(Wv({ref:t.trim()})),l=n.data?.info!==void 0&&n.data.info!==null&&n.data.log.length<=1&&a.length===0&&!i.isFetching,u=l?Sy:xy;return(0,Q.jsxs)(ay,{title:`What should we build?`,slot:`welcome`,banner:(0,Q.jsx)(wy,{}),children:[(0,Q.jsxs)(`form`,{className:W(by,`mt-7`),onSubmit:e=>{e.preventDefault(),c(o)},children:[(0,Q.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`Describe a task for the agent…`,"aria-label":`Describe a task for the agent`,className:`h-full min-w-0 flex-1 bg-transparent text-lead text-foreground outline-none placeholder:text-soft-foreground`}),(0,Q.jsx)(J,{type:`submit`,size:`icon`,variant:`ghost`,"aria-label":`Continue to the composer`,className:`size-9 shrink-0`,children:(0,Q.jsx)(co,{"aria-hidden":`true`})})]}),(0,Q.jsx)(`div`,{className:`mt-3 flex flex-wrap justify-center gap-2`,children:u.map(({icon:e,label:t,task:n})=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>c(n),className:`inline-flex h-8 items-center gap-2 rounded-full px-3 text-ui text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,Q.jsx)(e,{className:`size-3.5`,"aria-hidden":`true`}),t]},t))}),(0,Q.jsx)(Ay,{}),(0,Q.jsx)(jy,{fresh:l,issues:a,colors:i.data?.labelColors??{}})]})}function wy(){let e=C(),t=ht(),n=sv(),r=vr(),i=t.data?.onboarding?.dismissedAnnouncements,a=t.data?Dv({dismissed:i,designMode:e.data?.capabilities.designMode}):null;if(!a)return null;let o=()=>n({dismissedAnnouncements:[...i??[],a.id]});return(0,Q.jsxs)(`div`,{"data-slot":`announcement`,className:`onboarding-announcement relative mb-14 flex w-full items-stretch overflow-hidden rounded-xl border text-left`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col justify-center p-6`,children:[(0,Q.jsx)(`span`,{className:`eyebrow text-violet`,children:`New`}),(0,Q.jsx)(`span`,{className:`mt-1 text-2xl font-light tracking-tight text-foreground`,children:a.title}),(0,Q.jsx)(`p`,{className:`mt-2 max-w-sm text-ui text-muted-foreground`,children:a.description}),(0,Q.jsxs)(J,{size:`sm`,className:`mt-5 self-start font-normal`,onClick:()=>{o(),r(Wv({ref:a.hero.task}))},children:[a.hero.action,(0,Q.jsx)(co,{"aria-hidden":`true`})]})]}),(0,Q.jsx)(Ty,{}),(0,Q.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`Close ${a.title} announcement`,className:`absolute top-3 right-3 grid size-7 place-items-center rounded-full text-soft-foreground hover:text-foreground`,children:(0,Q.jsx)(Tc,{className:`size-3.5`,"aria-hidden":`true`})})]})}function Ty(){return(0,Q.jsx)(`div`,{className:`onboarding-picture hidden w-64 shrink-0 items-end justify-center pt-6 pr-6 sm:flex`,"aria-hidden":`true`,children:(0,Q.jsxs)(`div`,{className:`w-full rounded-t-lg border border-b-0 border-border bg-background p-3 shadow-[0_-12px_40px_-20px_var(--violet)]`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`})]}),(0,Q.jsx)(`div`,{className:`mt-3 h-2 w-2/3 rounded bg-muted`}),(0,Q.jsx)(`div`,{className:`mt-2 h-2 w-1/2 rounded bg-muted`}),(0,Q.jsxs)(`div`,{className:`relative mt-4 flex items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`relative h-6 w-16 rounded-md border border-violet bg-violet/15 outline-2 outline-offset-2 outline-violet/40`,children:[(0,Q.jsx)(`span`,{className:`absolute -top-1 -left-1 size-1.5 rounded-[2px] bg-violet`}),(0,Q.jsx)(`span`,{className:`absolute -top-1 -right-1 size-1.5 rounded-[2px] bg-violet`}),(0,Q.jsx)(`span`,{className:`absolute -bottom-1 -left-1 size-1.5 rounded-[2px] bg-violet`}),(0,Q.jsx)(`span`,{className:`absolute -right-1 -bottom-1 size-1.5 rounded-[2px] bg-violet`})]}),(0,Q.jsx)(`span`,{className:`h-6 w-10 rounded-md bg-muted`}),(0,Q.jsx)(`span`,{className:`absolute top-7 left-6 rounded-md rounded-tl-sm border border-border bg-card px-2 py-1 text-micro whitespace-nowrap text-foreground shadow-md`,children:`Make this button larger`})]}),(0,Q.jsx)(`div`,{className:`mt-9 h-2 w-3/4 rounded bg-muted`})]})})}function Ey(){let e=En(),t=C(),n=ln(),r=ht(),i=sv(),a=e.data?.worktreeLifecycle,o=Sv({worktreeSetupConfigured:e.data?(a?.afterCreate.length??0)>0:void 0,forge:t.data?.forge}),s=n.data?.info,c=s!=null&&!s.remote&&t.data?.capabilities.singleProject!==!0,l=r.data?.onboarding?.setupDismissed===!0,u=Z.useCallback(()=>i({setupDismissed:!0}),[i]);return{steps:o,unpublished:c,folder:s?qy(s.root):``,dismissed:l||!r.data,dismiss:u}}var Dy={worktrees:Yl,github:Cf},Oy=30,ky=6;function Ay(){let e=P(),t=Z.useMemo(()=>{let t=new Date;t.setHours(0,0,0,0);let n=Array.from({length:Oy},(e,n)=>{let r=new Date(t);return r.setDate(t.getDate()-(Oy-1-n)),{date:r,count:0}}),r=n[0]?.date.getTime()??0;for(let t of e.data??[]){let e=new Date(t.createdAt);e.setHours(0,0,0,0);let i=n[Math.round((e.getTime()-r)/864e5)];i&&(i.count+=1)}return n},[e.data]),n=t.reduce((e,t)=>e+t.count,0);if(n===0)return null;let r=Math.max(1,...t.map(e=>e.count)),i=e=>e===0?0:Math.max(1,Math.round(e/r*Math.min(r,ky))),a=e=>e.toLocaleDateString(void 0,{month:`short`,day:`numeric`});return(0,Q.jsxs)(`div`,{"data-slot":`activity-strip`,className:`mt-12 w-full`,children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex items-baseline justify-between text-ui`,children:[(0,Q.jsx)(`span`,{className:`text-soft-foreground`,children:`Activity`}),(0,Q.jsxs)(`span`,{className:`text-soft-foreground`,children:[n,` `,n===1?`task`:`tasks`,` in the last `,Oy,` days`]})]}),(0,Q.jsx)(kc,{delayDuration:100,children:(0,Q.jsx)(`div`,{className:`flex items-end justify-between`,role:`img`,"aria-label":`${n} tasks in the last ${Oy} days`,children:t.map(e=>(0,Q.jsxs)(Ac,{children:[(0,Q.jsx)(Dc,{asChild:!0,children:(0,Q.jsx)(`span`,{className:`flex flex-col-reverse gap-1 py-1`,children:Array.from({length:Math.max(1,i(e.count))},(t,n)=>(0,Q.jsx)(`span`,{className:W(`size-2.5 rounded-[3px]`,e.count>0?`bg-violet`:`bg-muted`)},n))})}),(0,Q.jsx)(Oc,{children:`${a(e.date)}: ${e.count} ${e.count===1?`task`:`tasks`}`})]},e.date.toISOString()))})}),(0,Q.jsx)(`div`,{className:`mt-2 flex justify-between font-mono text-micro text-soft-foreground`,children:t.filter((e,t)=>t%7==1||t===Oy-1).map(e=>(0,Q.jsx)(`span`,{children:a(e.date)},e.date.toISOString()))})]})}function jy({fresh:e,issues:t,colors:n}){let r=ln(),i=r.data?.info&&!e?r.data.log.slice(0,3):[],a=Ny(ie(t.length===0&&i.length===0).data??[]);return t.length>0?(0,Q.jsx)(My,{label:`Or pick up an issue`,slot:`issues`,children:(0,Q.jsx)(`ul`,{className:`w-full divide-y divide-border rounded-xl border border-border bg-card p-1.5 text-left`,children:t.map(e=>(0,Q.jsx)(`li`,{className:`first:[&>a]:rounded-t-lg last:[&>a]:rounded-b-lg`,children:(0,Q.jsxs)(K,{to:Wv({ref:Gv(e)}),className:`group flex flex-col gap-1.5 px-3 py-2.5 transition-colors hover:bg-muted`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-body text-foreground`,children:e.title}),(0,Q.jsx)(co,{className:`ml-auto size-3.5 shrink-0 text-soft-foreground opacity-0 transition-opacity group-hover:opacity-100`,"aria-hidden":`true`})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-meta text-soft-foreground`,children:[(0,Q.jsxs)(`span`,{className:`font-mono`,children:[`#`,e.number]}),(0,Q.jsx)(`span`,{children:e.author}),(0,Q.jsxs)(`span`,{children:[Xc(e.createdAt),` ago`]}),e.comments>0?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(vc,{className:`size-3`,"aria-hidden":`true`}),e.comments]}):null,e.labels.map(e=>(0,Q.jsx)(`span`,{style:ry(n[e]),className:`rounded-full border px-1.5 py-px text-micro`,children:e},e))]})]})},e.number))})}):i.length>0?(0,Q.jsx)(My,{label:`Or continue recent work`,slot:`commits`,children:(0,Q.jsx)(`ul`,{className:`w-full divide-y divide-border rounded-xl border border-border bg-card p-1.5 text-left`,children:i.map(e=>(0,Q.jsx)(`li`,{className:`first:[&>a]:rounded-t-lg last:[&>a]:rounded-b-lg`,children:(0,Q.jsxs)(K,{to:Wv({ref:`Continue the work from commit ${e.hash} (${e.subject}).`}),className:`group flex flex-col gap-1 px-3 py-2.5 transition-colors hover:bg-muted`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-body text-foreground`,children:e.subject}),(0,Q.jsx)(co,{className:`ml-auto size-3.5 shrink-0 text-soft-foreground opacity-0 transition-opacity group-hover:opacity-100`,"aria-hidden":`true`})]}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 text-meta text-soft-foreground`,children:[(0,Q.jsx)(`span`,{className:`font-mono`,children:e.hash}),(0,Q.jsx)(`span`,{children:e.author}),(0,Q.jsx)(`span`,{children:e.when})]})]})},e.hash))})}):a.length>0?(0,Q.jsx)(My,{label:`Or start with a skill`,slot:`skills`,children:(0,Q.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:a.map(e=>(0,Q.jsx)(K,{to:Wv({skill:e.name}),className:ly,title:e.description,children:e.name},e.name))})}):null}function My({label:e,slot:t,children:n}){return(0,Q.jsxs)(`div`,{"data-slot":`start-from`,"data-start-from":t,className:`mt-14 flex w-full flex-col items-center gap-3`,children:[(0,Q.jsx)(`div`,{className:`text-ui text-soft-foreground`,children:e}),n]})}function Ny(e){let t=e.filter(e=>e.source!==`global`&&e.source!==`builtin`),n=e.filter(e=>e.source===`global`);return[...t,...n].slice(0,4)}function Py({folder:e,onOpenChange:t}){let{projectId:n}=at(),r=Rt(),i=Sn(),a=r.data?.available===!0?r.data.owners:null,[o,s]=Z.useState(null),[c,l]=Z.useState(()=>Jy(e)),u=o??a?.[0]?.login??``,d=()=>{i.isPending||!u||!c.trim()||i.mutate({projectId:n??`default`,owner:u,name:c.trim()},{onSuccess:({slug:e})=>{t(!1),Y(`Published to ${e}`)}})},f=a!==null,p=fy(!r.isPending&&!f,()=>void r.refetch()),m=p.state?.status===`done`&&!r.isFetching&&r.data?.available===!1?r.data.reason:null;return(0,Q.jsxs)(pv,{title:`Publish to GitHub`,description:f?`A new private repository. You can make it public on GitHub later.`:m?`Signed in, but GitHub listed no accounts.`:py(p),onOpenChange:t,onSubmit:f?d:void 0,footer:m?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{variant:`outline`,className:`font-normal`,onClick:()=>t(!1),children:`Close`}),(0,Q.jsx)(J,{className:`font-normal`,onClick:()=>void r.refetch(),children:`Check again`})]}):f?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{variant:`outline`,className:`font-normal`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(J,{className:`font-normal`,onClick:d,disabled:i.isPending||!u||!c.trim(),children:i.isPending?`Publishing…`:`Publish`})]}):(0,Q.jsx)(vy,{signIn:p,onClose:()=>t(!1)}),children:[r.isPending?(0,Q.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:`Checking GitHub…`}):m?(0,Q.jsx)(`p`,{role:`alert`,className:`text-ui text-danger`,children:m}):f?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`radiogroup`,"aria-label":`Owner`,children:a.map(e=>(0,Q.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e.login===u,onClick:()=>s(e.login),className:W(`inline-flex h-8 items-center gap-2 rounded-full border px-3 text-ui transition-colors`,e.login===u?`border-primary text-foreground`:`border-border text-muted-foreground hover:text-foreground`),children:e.login},e.login))}),(0,Q.jsxs)(`label`,{className:`flex items-center gap-1 rounded-lg border border-input bg-background px-3 font-mono text-ui focus-within:border-ring`,children:[(0,Q.jsxs)(`span`,{className:`text-soft-foreground`,children:[u,`/`]}),(0,Q.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),"aria-label":`Repository name`,className:`h-9 min-w-0 flex-1 bg-transparent text-foreground outline-none`})]})]}):(0,Q.jsx)(_y,{signIn:p}),i.error?(0,Q.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs whitespace-pre-line text-danger`,children:i.error.message}):null]})}function Fy(){let{steps:e,unpublished:t,folder:n,dismissed:r,dismiss:i}=Ey(),[a,o]=Z.useState(!1),s=e[0];if(r||s===void 0&&!t)return null;let c=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(s?Dy[s.id]:Cf,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),s?s.label:`Publish to GitHub`,(0,Q.jsx)(co,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]}),l=`inline-flex h-7 items-center gap-1.5 rounded-full bg-muted px-3 text-foreground`;return(0,Q.jsxs)(`div`,{"data-onboarding":``,"data-slot":`setup-pill`,className:`mb-3 inline-flex items-center gap-2 self-start rounded-full border border-border bg-card py-1 pr-1 pl-3 text-ui`,children:[(0,Q.jsx)(`span`,{className:`text-soft-foreground`,children:`Setup`}),s?(0,Q.jsx)(K,{to:s.to,className:l,children:c}):(0,Q.jsx)(`button`,{type:`button`,className:l,onClick:()=>o(!0),"data-setup-step":`publish`,children:c}),(0,Q.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`Hide setup`,className:`grid size-7 place-items-center rounded-full text-soft-foreground hover:text-foreground`,children:(0,Q.jsx)(Tc,{className:`size-3.5`,"aria-hidden":`true`})}),a?(0,Q.jsx)(Py,{folder:n,onOpenChange:o}):null]})}function Iy(){let e=Ct();return e.isPending?null:e.data?.available?(0,Q.jsx)(Ly,{setup:e.data}):(0,Q.jsx)(Ry,{})}function Ly({setup:e}){let t=St(),n=rn(),r=sv(),i=K_(e,t.data).length===0;return(0,Q.jsxs)(ay,{title:nv(e,t.data),slot:`sign-in`,step:`agent`,why:`cezar installs the coding agent and signs you in, right here. No API key needed.`,children:[i?(0,Q.jsxs)(`div`,{"data-slot":`agents-off`,className:`mt-7 flex w-full flex-col gap-3 rounded-xl border border-border bg-card p-4 text-left sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-body text-foreground`,children:`All agents are turned off.`}),(0,Q.jsx)(J,{asChild:!0,size:`sm`,className:`font-normal`,children:(0,Q.jsx)(K,{to:`/settings/agents#providers`,children:`Turn one on`})})]}):(0,Q.jsx)(rv,{setup:e,status:t.data}),(0,Q.jsxs)(`div`,{className:`mt-7 flex flex-wrap justify-center gap-5`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>n.mutate(),disabled:n.isPending,className:cy,children:n.isPending?`Checking…`:`Check again`}),(0,Q.jsx)(K,{to:`/settings/agents`,className:cy,children:`Other agents`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>r({agentCheckSkipped:!0}),className:cy,children:`Continue anyway`})]})]})}function Ry(){let e=St(),t=rn(),n=zn(),r=sv(),i=wv(e.data),[a,o]=Z.useState(null),[s,c]=Z.useState(null),l=t.mutate;Z.useEffect(()=>{let e=window.setInterval(()=>l(),By);return()=>window.clearInterval(e)},[l]),Z.useEffect(()=>{if(!a)return;let e=0,t=window.setInterval(()=>{if(e+=1,e>Vy){window.clearInterval(t),o(null);return}l()},zy);return()=>window.clearInterval(t)},[a,l]);let u=e=>{c(null),n.mutate({provider:e},{onSuccess:t=>{t.opened?o(e):l()},onError:t=>c({provider:e,message:t.message})})};return(0,Q.jsxs)(ay,{title:`Sign in to an agent`,slot:`sign-in`,step:`agent`,why:`cezar runs the coding agent you already use. No API key needed.`,children:[(0,Q.jsxs)(`div`,{className:`mt-7 flex w-full flex-col gap-3 text-left`,children:[i.length===0?(0,Q.jsxs)(`div`,{"data-slot":`agents-off`,className:`flex flex-col gap-3 rounded-xl border border-border bg-card p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-body text-foreground`,children:`All agents are turned off.`}),(0,Q.jsx)(J,{asChild:!0,size:`sm`,className:`font-normal`,children:(0,Q.jsx)(K,{to:`/settings/agents#providers`,children:`Turn one on`})})]}):null,i.map(e=>{let t=a===e.provider,r=s?.provider===e.provider?s.message:null;return(0,Q.jsxs)(`div`,{"data-slot":`agent-row`,"data-state":e.state,className:`rounded-xl border border-border bg-card p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`text-lead text-foreground`,children:e.label}),(0,Q.jsx)(`div`,{className:`text-ui text-muted-foreground`,children:t?`Finish in Terminal`:e.state===`missing`?`Not installed`:`Installed, not signed in`})]}),e.state===`signed-out`?t?(0,Q.jsx)(_c,{className:`size-4 shrink-0 text-violet motion-safe:animate-spin`,"aria-label":`Waiting for sign-in`}):(0,Q.jsx)(J,{className:`font-normal`,onClick:()=>u(e.provider),disabled:n.isPending,children:`Sign in`}):null]}),e.state===`signed-out`&&!t&&!r?(0,Q.jsx)(`p`,{className:`mt-3 text-ui text-soft-foreground`,children:`Opens the login in Terminal.`}):null,t?(0,Q.jsx)(`p`,{className:`mt-3 text-ui text-soft-foreground`,children:`This page continues by itself.`}):null,r?(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-3`,children:[(0,Q.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:r}),(0,Q.jsxs)(uy,{children:[(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`span`,{className:`text-foreground`,children:`Open Terminal and paste:`}),(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(yy,{command:e.command})})]}),(0,Q.jsx)(`li`,{children:`Come back. cezar checks by itself.`})]})]}):null,e.state===`missing`?(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-3`,children:[(0,Q.jsxs)(uy,{children:[(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`span`,{className:`text-foreground`,children:`Open Terminal and paste:`}),(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(yy,{command:e.command})})]}),(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`span`,{className:`text-foreground`,children:`Then sign in:`}),(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(yy,{command:e.login})})]}),(0,Q.jsx)(`li`,{children:`Come back. cezar checks by itself.`})]}),(0,Q.jsxs)(`p`,{className:`text-label text-soft-foreground`,children:[`Needs Node.js.`,` `,(0,Q.jsx)(`a`,{href:`https://nodejs.org`,target:`_blank`,rel:`noopener noreferrer`,className:`text-violet hover:underline`,children:`Get it`})]})]}):null]},e.provider)})]}),(0,Q.jsxs)(`div`,{className:`mt-7 flex flex-wrap justify-center gap-5`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>l(),disabled:t.isPending,className:cy,children:t.isPending?`Checking…`:`Check again`}),(0,Q.jsx)(K,{to:`/settings/agents`,className:cy,children:`Other agents`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>r({agentCheckSkipped:!0}),className:cy,children:`Continue anyway`})]})]})}var zy=3e3,By=1e4,Vy=60;function Hy(){let{projectId:e}=at(),t=a(),n=C(),r=e??t.data?.bootProject,i=t.data?.projects.find(e=>e.id===r);return i?i.root:e===null||e===n.data?.bootProject?n.data?.repoRoot:void 0}function Uy(){let e=C().data?.capabilities.singleProject===!0,t=Hy(),n=t?qy(t):`This folder`,[r,i]=Z.useState(!1);return(0,Q.jsxs)(ay,{title:`Pick a project`,slot:`pick-project`,step:`project`,why:`Tasks run inside a git repository, each in its own worktree.`,subtitle:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`font-mono`,children:n}),` isn’t a git repository.`,e?null:(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(`button`,{type:`button`,onClick:()=>i(!0),className:`text-violet hover:underline`,children:`Initialize git here`})]})]}),children:[e?null:(0,Q.jsx)(Wy,{}),r?(0,Q.jsx)(Ky,{folder:n,onOpenChange:i}):null]})}function Wy(){let e=nt(),t=Rt(),n=Wt(),r=Nr(),[i,a]=Z.useState(``),[o,s]=Z.useState(0),[c,l]=Z.useState(null),u=(e.data?.repos??[]).filter(e=>e.name.toLowerCase().includes(i.trim().toLowerCase())).slice(0,6),d=t.data!==void 0&&!t.data.available,f=!e.isPending&&(e.data?.repos.length??0)===0,p=e=>{if(e.projectId){r(`/p/${encodeURIComponent(e.projectId)}/`);return}n.mutate(e.path,{onSuccess:({project:e})=>r(`/p/${encodeURIComponent(e.id)}/`),onError:e=>Y(e.message,{tone:`danger`})})},m=e=>{l(e),cs(e)};return(0,Q.jsxs)(Q.Fragment,{children:[f?(0,Q.jsxs)(`div`,{"data-slot":`no-repos`,className:`mt-8 grid w-full gap-3 sm:grid-cols-3`,children:[(0,Q.jsx)(hv,{title:`New project`,description:`An empty repository here, or a new private one on GitHub.`,recommended:d,onClick:()=>m(`new`),picture:(0,Q.jsx)(`span`,{className:`grid size-12 place-items-center rounded-lg border border-dashed border-muted-foreground/60`,children:(0,Q.jsxs)(`span`,{className:`relative size-4`,children:[(0,Q.jsx)(`span`,{className:`absolute top-1/2 left-0 h-0.5 w-full -translate-y-1/2 rounded bg-muted-foreground`}),(0,Q.jsx)(`span`,{className:`absolute top-0 left-1/2 h-full w-0.5 -translate-x-1/2 rounded bg-muted-foreground`})]})})}),d?(0,Q.jsx)(hv,{title:`Connect GitHub`,description:`Sign in to the GitHub CLI to clone and publish.`,onClick:()=>l(`connect`),picture:(0,Q.jsx)(Cf,{className:`size-9 text-muted-foreground`,"aria-hidden":!0})}):(0,Q.jsx)(hv,{title:`Clone from GitHub`,description:`Any repository you can read, by URL or owner/name.`,recommended:!0,onClick:()=>m(`clone`),picture:(0,Q.jsxs)(`span`,{className:`flex w-16 flex-col gap-1.5`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-md border border-violet bg-violet/15 px-1.5 py-1`,children:[(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-violet`}),(0,Q.jsx)(`span`,{className:`h-1 flex-1 rounded bg-violet/60`})]}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-md border border-border px-1.5 py-1`,children:[(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/50`}),(0,Q.jsx)(`span`,{className:`h-1 w-3/4 rounded bg-muted`})]}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-md border border-border px-1.5 py-1`,children:[(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/50`}),(0,Q.jsx)(`span`,{className:`h-1 w-1/2 rounded bg-muted`})]})]})}),(0,Q.jsx)(hv,{title:`Open a folder`,description:`A repository that already lives on this disk.`,onClick:()=>m(`folder`),picture:(0,Q.jsxs)(`span`,{className:`flex w-16 flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`h-2 w-10 rounded-sm bg-muted-foreground/70`}),(0,Q.jsx)(`span`,{className:`ml-3 h-1.5 w-9 rounded bg-muted`}),(0,Q.jsx)(`span`,{className:`ml-3 h-1.5 w-7 rounded bg-muted`}),(0,Q.jsx)(`span`,{className:`ml-3 h-1.5 w-8 rounded bg-muted`})]})})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mt-7 w-full rounded-xl border border-border bg-card p-1.5 text-left`,children:[(0,Q.jsxs)(`label`,{className:`flex h-11 items-center gap-2 rounded-lg border border-input bg-background px-3 focus-within:border-ring`,children:[(0,Q.jsx)(Cc,{className:`size-4 text-soft-foreground`,"aria-hidden":`true`}),(0,Q.jsx)(`input`,{value:i,onChange:e=>{a(e.target.value),s(0)},onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),s(e=>Math.min(e+1,u.length-1));else if(e.key===`ArrowUp`)e.preventDefault(),s(e=>Math.max(e-1,0));else if(e.key===`Enter`){let e=u[o];e&&p(e)}},placeholder:`Search repositories`,"aria-label":`Search repositories`,className:`min-w-0 flex-1 bg-transparent text-lead text-foreground outline-none placeholder:text-soft-foreground`})]}),(0,Q.jsx)(`ul`,{role:`listbox`,"aria-label":`Repositories`,className:`mt-1`,children:e.isPending?(0,Q.jsx)(`li`,{className:`px-3 py-2.5 text-ui text-soft-foreground`,children:`Looking for repositories…`}):u.length===0?(0,Q.jsx)(`li`,{className:`px-3 py-2.5 text-ui text-soft-foreground`,children:`No repositories found`}):u.map((e,t)=>(0,Q.jsx)(`li`,{role:`option`,"aria-selected":t===o,children:(0,Q.jsxs)(`button`,{type:`button`,onMouseEnter:()=>s(t),onClick:()=>p(e),disabled:n.isPending,className:W(`flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left`,t===o&&`bg-muted`),children:[(0,Q.jsx)(`span`,{className:`truncate text-lead text-foreground`,children:e.name}),(0,Q.jsx)(`span`,{className:`ml-auto truncate font-mono text-meta text-soft-foreground`,children:Yy(e.path)})]})},e.path))})]}),(0,Q.jsxs)(`div`,{className:`mt-5 flex flex-wrap justify-center gap-6`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:cy,onClick:()=>m(`new`),children:[(0,Q.jsx)(xc,{className:`size-3.5`,"aria-hidden":`true`}),`New project`]}),d?(0,Q.jsxs)(`button`,{type:`button`,className:cy,onClick:()=>l(`connect`),"data-slot":`connect-github`,children:[(0,Q.jsx)(Cf,{className:`size-3.5`,"aria-hidden":!0}),`Connect GitHub`]}):(0,Q.jsxs)(`button`,{type:`button`,className:cy,onClick:()=>m(`clone`),children:[(0,Q.jsx)(Cf,{className:`size-3.5`,"aria-hidden":!0}),`Clone from GitHub`]}),(0,Q.jsxs)(`button`,{type:`button`,className:cy,onClick:()=>m(`folder`),children:[(0,Q.jsx)(dc,{className:`size-3.5`,"aria-hidden":`true`}),`Browse…`]})]})]}),c===`new`?(0,Q.jsx)(Sf,{label:`New project`,onError:()=>l(null),children:(0,Q.jsx)(_f,{open:!0,onOpenChange:e=>!e&&l(null)})}):null,c===`clone`?(0,Q.jsx)(Sf,{label:`Clone from GitHub`,onError:()=>l(null),children:(0,Q.jsx)(df,{open:!0,onOpenChange:e=>!e&&l(null)})}):null,c===`folder`?(0,Q.jsx)(Sf,{label:`Open local folder`,onError:()=>l(null),children:(0,Q.jsx)(cf,{open:!0,onOpenChange:e=>!e&&l(null)})}):null,c===`connect`?(0,Q.jsx)(Gy,{onOpenChange:e=>!e&&l(null)}):null]})}function Gy({onOpenChange:e}){let t=Z.useCallback(()=>e(!1),[e]),n=fy(!0,e=>{Y(e?`GitHub connected as ${e}`:`GitHub connected`),t()});return(0,Q.jsx)(pv,{title:`Connect GitHub`,description:py(n),onOpenChange:e,footer:(0,Q.jsx)(vy,{signIn:n,onClose:t}),children:(0,Q.jsx)(_y,{signIn:n})})}function Ky({folder:e,onOpenChange:t}){let{projectId:n}=at(),r=Un(),i=()=>{r.isPending||r.mutate(n??`default`,{onSuccess:()=>{t(!1),Y(`Initialized git in ${e}`)}})};return(0,Q.jsxs)(pv,{title:`Initialize git in ${e}`,description:`Git keeps a history of your files. cezar runs this for you and uploads nothing. node_modules and .env files stay out.`,onOpenChange:t,onSubmit:i,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{variant:`outline`,onClick:()=>t(!1),className:`font-normal`,children:`Cancel`}),(0,Q.jsx)(J,{onClick:i,disabled:r.isPending,className:`font-normal`,children:r.isPending?`Initializing…`:`Initialize`})]}),children:[(0,Q.jsx)(`pre`,{className:`rounded-lg border border-border bg-background px-3 py-2.5 font-mono text-xs leading-relaxed text-foreground`,children:`$ git init -b main
|
|
4
|
+
`),v=Z.useRef(g);v.current=g,Z.useEffect(()=>n({runId:e.id,commands:v.current}),[_,n,e.id]);let y=s.confirming!==null||c.commitOpen||c.pending!==null||s.delete.isPending||s.cancel.isPending,b=Z.useRef(y);return Z.useEffect(()=>{b.current&&!y&&i(),b.current=y},[y,i]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Aa,{run:e,confirming:s.confirming,lifecycleDelete:s.lifecycleDelete,onOpenChange:e=>!e&&s.setConfirming(null),onConfirm:e=>e===`delete`?s.delete.mutate():s.cancel.mutate()}),c.dialogs]})}var ag=Z.createContext(null);function og({children:e}){let[t,n]=Z.useState(`active`),r=Z.useMemo(()=>[t,n],[t]);return(0,Q.jsx)(ag.Provider,{value:r,children:e})}function sg(){let e=Z.useContext(ag);if(!e)throw Error(`useListView must be used inside a <ListViewProvider>`);return e}var cg=1e4,lg=e=>Math.min(100,Math.max(0,e)),ug=e=>e===void 0||e<80?`ok`:e<90?`warn`:`critical`;function dg(){let e=ra(),t=Qi();return!e||t!==`local`?null:(0,Q.jsx)(fg,{})}function fg(){let e=ea(),t=Zi(),n=$i(),[r,i]=(0,Z.useState)(void 0),a=n!==void 0&&r===n;(0,Z.useEffect)(()=>{if(n===void 0)return;let e=Math.max(0,n+cg-Date.now()),t=setTimeout(()=>i(n),e);return()=>clearTimeout(t)},[n]);let o=e===void 0?void 0:na(e),s=o?.cpuPct,c=a?`stale`:o!==void 0&&o.cpuLimited&&s===void 0?`—`:s===void 0?t.length===0?`sampling…`:`—`:`${Math.round(s)}%`,l=o===void 0||o.memUsedBytes===void 0||o.memTotalBytes<=0?void 0:o.memUsedBytes/o.memTotalBytes*100,u=a?`stale`:l===void 0?`—`:`${Math.round(l)}%`,d=o===void 0?`—`:Ji(o.memUsedBytes,o.memTotalBytes),f=o?.cpuLimited===!0?`${o.cpuLimitKind===`cpuset`?`cpuset `:``}${qi(o.cpuCores)}`:void 0,p=`CPU ${c}${f===void 0?``:` of ${f}`}, RAM ${u} (${d})`;return(0,Q.jsxs)(K,{to:`/settings/resources`,"data-slot":`host-usage-widget`,"data-state":a?`stale`:`live`,"data-frames":t.length,"aria-label":`Machine usage: ${p}. Open Settings, Resources.`,title:p,className:W(`grid grid-cols-[auto_minmax(0,1fr)_auto_auto_minmax(0,1fr)_auto] items-center gap-x-1.5 rounded-md border border-border px-2 py-1 text-meta leading-[14px] text-soft-foreground transition-colors hover:bg-muted hover:text-foreground`,a?`opacity-70`:null),children:[(0,Q.jsx)(pg,{label:`CPU`,pct:a?void 0:s,valueSlot:`host-usage-widget-cpu`,value:c}),(0,Q.jsx)(pg,{label:`RAM`,pct:a?void 0:l,valueSlot:`host-usage-widget-mem-pct`,value:u,gutter:!0})]})}function pg({label:e,pct:t,valueSlot:n,value:r,gutter:i}){let a=ug(t);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:W(`font-medium tracking-wide text-muted-foreground`,i===!0?`ml-1`:null),children:e}),(0,Q.jsx)(`span`,{"data-slot":`host-usage-widget-${e.toLowerCase()}-bar`,"data-level":a,role:`meter`,"aria-label":e,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t===void 0?void 0:Math.round(lg(t)),className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,Q.jsx)(`span`,{className:W(`block h-full rounded-full transition-[width] duration-500`,a===`critical`?`bg-destructive`:a===`warn`?`bg-pending`:`bg-primary`),style:{width:`${t===void 0?0:lg(t)}%`}})}),(0,Q.jsx)(`span`,{"data-slot":n,className:W(`text-right font-medium tabular-nums`,a===`critical`?`text-destructive`:a===`warn`?`text-pending-strong`:`text-foreground`),children:r})]})}function mg({status:e,pending:t,error:n,dismissals:r,onDismissAuthFailures:i}){if(t||!e)return null;let a;try{a=bt(e)}catch{return null}let o=gs(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)(Jc,{tone:`danger`}),(0,Q.jsxs)(`span`,{children:[`Provider authentication failed during a task:`,` `,o.map(({label:e})=>e).join(`, `),`.`]}),(0,Q.jsx)(K,{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)(Tc,{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)(Jc,{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)(K,{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 hg(e){if(!(typeof e!=`object`||!e||Array.isArray(e)))return e}function gg(){let e=St(),t=ht(),n=U(),r=(0,Z.useRef)(Promise.resolve()),i=(0,Z.useRef)(0),a=(0,Z.useRef)(0),o=(0,Z.useRef)(hg(t.data));(0,Z.useEffect)(()=>{a.current===0&&(o.current=hg(t.data))},[t.data]);let s=(0,Z.useCallback)(e=>{let t=B.uiState,s=hg(n.getQueryData(t)),c=vs(zo(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 Pt({dismissedProviderAuthFailures:c});o.current=hg(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}),Y(e instanceof Error?e.message:String(e),{tone:`danger`}))}finally{--a.current}})},[n]);return(0,Q.jsx)(mg,{status:e.data,pending:e.isPending,error:e.isError,dismissals:zo(hg(t.data)?.dismissedProviderAuthFailures),onDismissAuthFailures:s})}var _g=`https://github.com/open-mercato/cezar/blob/main/docs/telemetry.md`,vg=`https://github.com/open-mercato/cezar/blob/main/packages/cezar/src/telemetry.ts`;function yg(e){return e!==void 0&&e.consent===`unknown`&&e.blockedBy===null}var bg=[`How many tasks you start (agent, model)`,`How many messages you send`,`Which pages you open`,`Errors, with your paths removed`,`Version, OS, app or CLI`,`A random install id`],xg=[`Prompts, messages, code, diffs`,`File paths`,`Repo, branch or project names`,`Keys or credentials`,`Your IP, in any payload`];function Sg(){let e=U();return(0,Z.useCallback)(async t=>{try{let n=await bn({consent:t});return e.setQueryData(B.telemetryConsent,n),t===`denied`&&ee(),!0}catch(e){return Y(e instanceof Error?e.message:String(e),{tone:`danger`}),!1}},[e])}function Cg({busy:e,onAnswer:t,size:n}){let r=n===`lg`?`min-h-11`:`h-9`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{variant:`outline`,className:r,disabled:e,"data-slot":`telemetry-deny`,onClick:()=>t(`denied`),children:`Don’t share`}),(0,Q.jsx)(J,{className:r,disabled:e,"data-slot":`telemetry-grant`,onClick:()=>t(`granted`),children:`Share usage data`})]})}function wg(){let e=Ze(),t=Sg(),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(!1);if(!yg(e.data))return null;let o=async e=>{r(!0);let n=await t(e);r(!1),n&&a(!1)};return(0,Q.jsxs)(`div`,{"data-slot":`telemetry-consent-banner`,className:`px-4 pb-3 md:px-5 md:pb-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3 rounded-lg border bg-card px-4 py-3 shadow-lg`,children:[(0,Q.jsx)(nu,{className:`hidden size-[18px] shrink-0 text-violet sm:block`,"aria-hidden":`true`}),(0,Q.jsxs)(`p`,{className:`min-w-0 flex-1 basis-[280px] text-ui leading-relaxed text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Help improve cezar?`}),` With your OK we send task counts and crash reports to the maintainers — never prompts, code, paths or repo names. Change it anytime in Settings → Privacy.`,` `,(0,Q.jsx)(`button`,{type:`button`,"data-slot":`telemetry-details`,className:`underline underline-offset-2 hover:text-foreground`,onClick:()=>a(!0),children:`Details`})]}),(0,Q.jsx)(`div`,{className:`flex gap-2`,children:(0,Q.jsx)(Cg,{busy:n,onAnswer:e=>void o(e),size:`sm`})})]}),(0,Q.jsx)(Eg,{open:i,onOpenChange:a,busy:n,onAnswer:e=>void o(e)})]})}function Tg({title:e,tone:t,items:n}){let r=t===`ok`?Rs:Tc;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`block text-ui font-medium text-foreground`,children:e}),(0,Q.jsx)(`ul`,{className:`mt-2 space-y-1.5`,children:n.map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-2 text-ui leading-snug text-muted-foreground`,children:[(0,Q.jsx)(r,{className:`mt-0.5 size-3.5 shrink-0 ${t===`ok`?`text-success`:`text-soft-foreground`}`,"aria-hidden":`true`}),e]},e))})]})}function Eg({open:e,onOpenChange:t,busy:n,onAnswer:r}){return(0,Q.jsx)(qr,{open:e,onOpenChange:t,children:(0,Q.jsx)(Wr,{"data-slot":`telemetry-details-dialog`,className:`max-h-[calc(100dvh-2rem)] gap-0 overflow-y-auto p-0 sm:max-w-[480px]`,onOpenAutoFocus:e=>{e.preventDefault(),e.currentTarget.focus()},children:(0,Q.jsxs)(`div`,{className:`space-y-5 p-6`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`span`,{className:`block eyebrow text-muted-foreground`,children:`What is sent`}),(0,Q.jsx)(Zr,{className:`text-xl font-semibold tracking-tight`,children:`Usage data, in full`}),(0,Q.jsx)(Vr,{className:`text-sm leading-relaxed text-muted-foreground`,children:`Counts of what you use and reports of what broke, so cezar’s maintainers at Open Mercato can fix bugs without you filing them. Off until you say yes.`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsx)(Tg,{title:`Shared`,tone:`ok`,items:bg}),(0,Q.jsx)(Tg,{title:`Never shared`,tone:`no`,items:xg})]}),(0,Q.jsxs)(`p`,{className:`text-xs leading-relaxed text-soft-foreground`,children:[`Every label is a closed list the server enforces. Withdraw anytime in Settings → Privacy or with `,(0,Q.jsx)(`code`,{className:`font-mono`,children:`cezar telemetry disable`}),` — the install id is deleted.`,` `,(0,Q.jsx)(`a`,{href:vg,target:`_blank`,rel:`noopener noreferrer`,className:`underline underline-offset-2 hover:text-foreground`,children:`Read the code`}),` · `,(0,Q.jsx)(`a`,{href:_g,target:`_blank`,rel:`noopener noreferrer`,className:`underline underline-offset-2 hover:text-foreground`,children:`Privacy notice`})]}),(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:(0,Q.jsx)(Cg,{busy:n,onAnswer:r,size:`lg`})})]})})})}function Dg({compact:e=!1,enabled:t=!0}){let[n,r]=(0,Z.useState)([]),i=mi(),a=bi(t&&i.known&&!i.off).data?.automations.filter(e=>e.deferredStart)??[];return!a.length&&!n.length?null:(0,Q.jsxs)(`section`,{"aria-label":`Scheduled tasks`,className:e?`px-2 py-3`:`border-b p-4 md:px-5`,children:[(0,Q.jsxs)(`h2`,{className:`mb-2 eyebrow text-muted-foreground`,children:[`Scheduled · `,a.length]}),n.length>0&&(0,Q.jsxs)(`p`,{role:`status`,children:[`This scheduled task already started. `,n.map((e,t)=>(0,Q.jsxs)(K,{to:`/tasks/${e}`,className:`mr-3 underline`,children:[`View run `,t+1]},e))]}),e?a.map(e=>(0,Q.jsxs)(K,{to:`/#scheduled-${e.id}`,className:`block truncate rounded px-2 py-1.5 text-sm`,children:[`◷ `,e.name]},e.id)):(0,Q.jsx)(`div`,{className:`grid gap-3`,children:a.map(e=>(0,Q.jsx)(Og,{item:e,onAlreadyStarted:r},e.id))})]})}function Og({item:e,onAlreadyStarted:t}){let n=jr(),r=e.deferredStart,i=vr(),a=U(),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(``),g=()=>{if(u){d(null);return}p(e.schedule?.date??``),h(`${String(e.schedule?.hour??0).padStart(2,`0`)}:${String(e.schedule?.minute??0).padStart(2,`0`)}`),d(e),l(``)},_=async e=>{s(!0),l(``);try{await e()}catch(e){e instanceof cn&&e.runIds?.length?t(e.runIds):l(e instanceof Error?e.message:String(e))}finally{await a.invalidateQueries({queryKey:fi()}),s(!1)}},v=r.runIds.length>0,y=v&&r.status===`failed`&&r.failureKind===`ambiguous`,b=r.failureKind===`binding-invalid`,x=`scheduled-${e.id}`,[S,C]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{n.hash===`#${x}`&&(C(!0),document.getElementById(x)?.scrollIntoView?.({block:`nearest`}))},[x,n.hash,n.key]);let w=e.task.steps?.flatMap(e=>e.skill?[e.skill]:[])??[],T=e.task.workflow??(w.length?`Skills: ${w.join(`, `)}`:`Inline steps`),E=r.binding.models?.map(e=>`${e.step?`${e.step}: `:``}${e.runner} / ${e.model??`Provider default`}`).join(`; `)??e.task.model??`Resolved step models unavailable`,D=r.status===`failed`?`Couldn't start`:r.status===`missed`?`Missed`:r.status===`launching`?`Starting…`:r.holdUntil?`Waiting for reset`:`Scheduled`;return(0,Q.jsxs)(`details`,{id:x,open:S,onToggle:e=>C(e.currentTarget.open),className:`rounded-lg border p-3`,children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,Q.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[D,` · `,new Date(r.notBefore).toLocaleString(`en-GB`,{timeZone:r.timeZone}),` · `,r.timeZone]})]}),(0,Q.jsxs)(`div`,{className:`mt-3 space-y-3 text-sm`,children:[(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap break-words`,children:e.task.prompt}),(0,Q.jsxs)(`p`,{className:`text-muted-foreground`,children:[T,` · `,E,` · `,r.binding.accounts.map(e=>`${e.runner} / ${e.id}`).join(`, `)]}),(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:`The server must be running. This is the earliest start; account holds and queue limits still apply.`}),r.holdUntil&&(0,Q.jsxs)(`p`,{children:[`Waiting until `,new Date(r.holdUntil).toLocaleString(`en-GB`,{timeZone:r.timeZone}),` for a newer observed reset.`]}),r.error&&(0,Q.jsx)(`p`,{role:`status`,children:r.error}),y&&(0,Q.jsx)(`p`,{children:`Check the runs below. Start missing runs creates only the ones that do not exist yet — a run you deleted starts again. Dismiss removes this entry and starts nothing.`}),r.runIds.map((e,t)=>(0,Q.jsxs)(K,{to:`/tasks/${e}`,className:`mr-3 underline`,children:[`Check run `,t+1]},e)),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(J,{size:`sm`,variant:`ghost`,disabled:o,onClick:()=>void _(()=>el(e.task.prompt)),children:`Copy prompt`}),(0,Q.jsx)(J,{size:`sm`,variant:`outline`,disabled:o||v&&!y,onClick:()=>void _(async()=>{let t=await Nn(e.id,e.revision);i(`/tasks/${t.runId}`)}),children:y?`Start missing runs`:r.status===`failed`?`Retry`:`Run now`}),(0,Q.jsx)(J,{size:`sm`,variant:`ghost`,disabled:o||v||b,onClick:g,children:`Change time`}),(0,Q.jsx)(J,{size:`sm`,variant:`ghost`,disabled:o||v&&!y,onClick:()=>void _(()=>Gn(e.id,e.revision)),children:y?`Dismiss`:`Cancel`})]}),u&&!b&&(0,Q.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:t=>{t.preventDefault(),_(async()=>{let[t,n]=m.split(`:`).map(Number);await Wn(e.id,{expectedRevision:u.revision,name:u.name,kind:`schedule`,task:u.task,schedule:{type:`once`,date:f,hour:t??0,minute:n??0},enabled:!0}),d(null)})},children:[(0,Q.jsxs)(`label`,{children:[`Date`,(0,Q.jsx)(Kc,{type:`date`,required:!0,value:f,onChange:e=>p(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[`Time (server time zone)`,(0,Q.jsx)(Kc,{type:`time`,required:!0,value:m,onChange:e=>h(e.target.value)})]}),(0,Q.jsx)(J,{type:`submit`,disabled:o,children:`Save time`})]}),c&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:c})]})]})}var kg=new Map,Ag=new Set,jg=()=>{for(let e of Ag)e()},Mg=e=>(Ag.add(e),()=>{Ag.delete(e)});function Ng(e=$n()){kg.delete(e),jg()}function Pg(){let e=mi(),t=kr(),n=t??$n(),r=(0,Z.useSyncExternalStore)(Mg,()=>kg.has(n)),i=bi(!1),a=i.data?.automations.some(e=>e.deferredStart)??!1;return(0,Z.useEffect)(()=>vi((e,r)=>{e===`automation-change`&&(t===null||r.project===t)&&Ng(n)}),[t,n]),(0,Z.useEffect)(()=>{i.data&&!a&&!kg.has(n)&&(kg.set(n,i.dataUpdatedAt),jg())},[i.data,i.dataUpdatedAt,a,n]),e.known&&!e.off&&(!r||a)}function Fg({archived:e,onToggle:t,className:n}){let r=e?pl:wa;return(0,Q.jsx)(Qc,{label:e?`Move back to the active list`:`Move to the archived list`,children:(0,Q.jsx)(`button`,{type:`button`,"data-slot":`archive-toggle`,"aria-label":e?`Unarchive task`:`Archive task`,onClick:n=>{n.stopPropagation(),t(!e)},className:W(`inline-flex size-5 shrink-0 items-center justify-center rounded-sm text-soft-foreground transition-colors hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,n),children:(0,Q.jsx)(r,{className:`size-3`,"aria-hidden":`true`})})})}function Ig(){return(0,Q.jsx)(`span`,{"data-slot":`unread-marker`,className:`sr-only`,children:`, unread`})}var Lg={statuses:[],workflows:[],automations:[]};function Rg(e){return e.statuses.length+e.workflows.length+e.automations.length}function zg(e){let t=new Map(e.map(e=>[e.id,e]));return new Map(e.map(e=>[e.id,ep(e,e=>t.get(e))]))}var Bg=(e,t)=>e.length===0||t!==void 0&&e.includes(t);function Vg(e,t,n,r){return e.filter(e=>{let i=r.get(e.id);return!(!tp(i,t)||!Bg(n.statuses,e.status)||!Bg(n.workflows,he(e))||t!==`regular`&&!Bg(n.automations,i))})}function Hg(e,t){return t===`all`?[...e]:Vg(e,t,Lg,zg(e))}function Ug(e,t,n,r,i){let a=new Map;for(let o of Vg(e,t,{...n,[i]:[]},r)){let e=i===`statuses`?o.status:i===`workflows`?he(o):r.get(o.id);e!==void 0&&a.set(e,(a.get(e)??0)+1)}return a}function Wg(e,t,n){return{regular:Vg(e,`regular`,t,n).length,automation:Vg(e,`automation`,t,n).length,all:Vg(e,`all`,t,n).length}}function Gg(e){let t=new Set;for(let n of e)n!==void 0&&t.add(n);return[...t].sort((e,t)=>e.localeCompare(t))}function Kg(e){let t=new Map;for(let n of e)t.has(n.id)||t.set(n.id,{run:n,depth:0,children:[],childCount:0,descendantCount:0});let n=e=>{let n=e.dispatch?.parentRunId;if(n===void 0||n===e.id)return null;let r=t.get(n);if(r===void 0)return null;let i=new Set([e.id]),a=r;for(;a!==void 0;){if(i.has(a.run.id))return null;i.add(a.run.id);let e=a.run.dispatch?.parentRunId;a=e===void 0?void 0:t.get(e)}return r},r=[];for(let i of e){let e=t.get(i.id);if(e===void 0||e.run!==i)continue;let a=n(i);a===null?r.push(e):a.children.push(e)}let i=(e,t)=>{e.depth=t,e.childCount=e.children.length;let n=0;for(let r of e.children)n+=1+i(r,t+1);return e.descendantCount=n,n};for(let e of r)i(e,0);return r}function qg(e,t){let n=[],r=e=>{for(let i of e)n.push(i),(i.children.length===0||t===void 0||t(i.run.id))&&r(i.children)};return r(e),n}function Jg(e,t){return qg(Kg(e),t)}function Yg(e){return e<=0?null:`${e} subtask${e===1?``:`s`}`}function Xg(e){return e.dispatch?.parentRunId===void 0?null:e.dispatch.kind??`implement`}var Zg=Z.createContext(void 0);function Qg({runs:e,view:t,onViewChange:n,currentRunId:r=null,now:i=Date.now(),showTokens:a=!0,showCost:o=!0,onTogglePin:s,onToggleArchive:c}){let l=Le(e),u=xe(e,t),d=t===`archived`?void 0:s;return(0,Q.jsxs)(`div`,{"data-slot":`quick-list`,children:[(0,Q.jsx)(`div`,{className:`sticky top-0 z-10 bg-sidebar pt-2 pb-1`,children:(0,Q.jsxs)(`div`,{className:`inline-flex w-full gap-0.5 rounded-md bg-muted p-[3px]`,children:[(0,Q.jsxs)(t_,{view:`active`,current:t,onSelect:n,count:l.active,children:[`Active`,l.waiting>0&&t!==`active`?(0,Q.jsx)(Jc,{tone:`pending`,pulse:!0,"data-slot":`waiting-dot`,"aria-label":`needs you`}):null]}),(0,Q.jsx)(t_,{view:`archived`,current:t,onSelect:n,count:l.archived,children:`Archived`})]})}),u.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-3.5 text-xs text-soft-foreground`,children:t===`archived`?`Nothing archived yet.`:`No tasks yet — describe one.`}):(0,Q.jsx)($g,{buckets:u,currentRunId:r,now:i,showTokens:a,showCost:o,onTogglePin:d,onToggleArchive:c})]})}function $g({buckets:e,currentRunId:t=null,now:n=Date.now(),scope:r=null,showTokens:i=!0,showCost:a=!0,onTogglePin:o,onToggleArchive:s}){let[c,l]=Z.useState(()=>new Set),u=e=>l(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});return(0,Q.jsx)(Q.Fragment,{children:e.map(e=>(0,Q.jsxs)(`div`,{"data-slot":`quick-list-bucket`,"data-bucket":e.label,children:[(0,Q.jsx)(`h2`,{className:`px-3 pt-2.5 pb-1 eyebrow text-soft-foreground`,children:e.label}),e_(e.rows).map(e=>(0,Q.jsx)(n_,{row:e.run.row,depth:e.depth,childCount:e.childCount,currentRunId:t,now:n,scope:r,showTokens:i,showCost:a,expanded:e.run.row.kind===`group`&&c.has(e.run.row.groupId),onToggle:u,onTogglePin:o,onToggleArchive:s},e.run.id))]},e.label))})}function e_(e){return Jg(e.map(e=>e.kind===`group`?{id:`group:${e.groupId}`,row:e}:{id:e.run.id,dispatch:e.run.dispatch,row:e}))}function t_({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:W(`flex h-7 flex-1 items-center justify-center gap-1.5 rounded-[7px] text-label font-medium text-muted-foreground`,a&&`bg-card font-semibold text-foreground shadow-xs`),children:[i,r>0?(0,Q.jsx)(`span`,{className:`font-mono text-meta tabular-nums`,children:r}):null]})}function n_({row:e,depth:t,childCount:n,currentRunId:r,now:i,scope:a,expanded:o,onToggle:s,showTokens:c,showCost:l,onTogglePin:u,onToggleArchive:d}){return e.kind===`run`?(0,Q.jsx)(c_,{run:e.run,depth:t,childCount:n,queuePosition:e.queuePosition,currentRunId:r,now:i,scope:a,showTokens:c,showCost:l,onTogglePin:u,onToggleArchive:d}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center rounded-sm hover:bg-muted`,children:[(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`group-tile`,"data-group-id":e.groupId,"aria-expanded":o,onClick:()=>s(e.groupId),className:`flex min-w-0 flex-1 items-center gap-2 px-2.5 py-[7px] text-left`,children:[(0,Q.jsx)(Ws,{className:W(`size-3 shrink-0 text-soft-foreground transition-transform`,!o&&`-rotate-90`),"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-[7rem] flex-1 truncate text-ui font-medium`,children:e.title}),(0,Q.jsxs)(`span`,{className:`shrink-0 rounded-full bg-muted px-1.5 py-px font-mono text-micro font-semibold text-muted-foreground`,children:[`×`,e.members.length]})]}),(0,Q.jsx)(K,{to:_r(a,`/compare/${e.groupId}`),"data-slot":`group-compare`,title:`Compare the variants`,"aria-label":`Compare the variants of ${e.title}`,className:`mr-1.5 inline-flex size-6 shrink-0 items-center justify-center rounded-sm text-soft-foreground hover:bg-violet/10 hover:text-violet`,children:(0,Q.jsx)(eu,{className:`size-3.5`,"aria-hidden":`true`})})]}),o?e.members.map(e=>(0,Q.jsx)(c_,{run:e,queuePosition:null,currentRunId:r,now:i,scope:a,variant:!0,showTokens:c,showCost:l,onTogglePin:u,onToggleArchive:d},e.id)):null]})}var r_=`flex w-0 shrink-0 items-center gap-0.5 overflow-hidden opacity-0 group-hover/task-row:mr-1.5 group-hover/task-row:w-auto group-hover/task-row:opacity-100 group-focus-within/task-row:mr-1.5 group-focus-within/task-row:w-auto group-focus-within/task-row:opacity-100 no-hover:mr-1.5 no-hover:w-auto no-hover:opacity-100`,i_=`no-hover:size-7`,a_=`group-hover/task-row:hidden group-focus-within/task-row:hidden`,o_=`no-hover:hidden`,s_=`group-hover/task-row:min-w-0 group-focus-within/task-row:min-w-0 no-hover:min-w-0`,c_=Z.memo(function({run:e,depth:t=0,childCount:n=0,queuePosition:r,currentRunId:i,now:a,scope:s,variant:c=!1,showTokens:l,showCost:u,onTogglePin:d,onToggleArchive:f}){let m=!!f&&(!!e.archived||!Ts(e.status)),h=!!d||m,g=o(e),_=Z.useId(),v=e.id===i,y=zt(e,Z.useContext(Zg)),b=Ve(e),x=Ne(b,y?.number)?qe(b).rest:b,S=$o(e),C=Zo(e),w=c?``:r===null?Xc(p(e),a):`#${r}`,T=Yg(n),E=Xg(e);return(0,Q.jsxs)(`div`,{"data-slot":`task-row`,"data-run-id":e.id,"data-active":v?`true`:void 0,"data-depth":t,style:t>0?{paddingLeft:`${10+t*14}px`}:void 0,className:W(`group/task-row flex items-center gap-2 rounded-sm pl-2.5 hover:bg-muted`,v&&`bg-muted`,c&&`pl-[26px]`),children:[(0,Q.jsx)(K,{to:_r(s,`/tasks/${e.id}`),tabIndex:-1,"aria-hidden":`true`,"data-slot":`task-row-dot-link`,className:`-ml-2.5 flex shrink-0 items-center self-stretch pl-2.5`,children:(0,Q.jsx)(Jc,{id:_,tone:g.tone,pulse:g.pulse,"aria-label":g.label,role:`img`})}),y?(0,Q.jsx)(Ca,{run:e,reference:y,compact:!0,className:`h-auto shrink-0 gap-[2px] px-1.5 py-px text-micro`}):null,(0,Q.jsxs)(K,{to:_r(s,`/tasks/${e.id}`),title:b,"aria-current":v?`page`:void 0,"aria-describedby":_,"data-slot":`task-row-link`,className:W(`flex min-w-0 flex-1 items-center gap-2 py-[7px]`,h?`pr-0.5`:`pr-2.5`),children:[c?(0,Q.jsx)(`span`,{className:`inline-flex size-[15px] shrink-0 items-center justify-center rounded-full bg-violet/15 font-mono text-[9.5px] font-semibold text-violet`,children:e.variant??`?`}):null,(0,Q.jsxs)(`span`,{"data-slot":`task-row-title`,className:W(`min-w-[7rem] flex-1 truncate text-ui`,h&&s_,S?`font-semibold text-foreground`:C?`font-medium text-muted-foreground`:`font-medium`),children:[c?l_(e,l,u):x,e.queueWaitReason&&(0,Q.jsx)(`span`,{className:`block truncate text-meta font-normal text-muted-foreground`,children:Ao(e.queueWaitReason)})]}),(0,Q.jsxs)(`span`,{"data-slot":`task-row-meta`,className:W(`contents`,h&&a_),children:[(0,Q.jsxs)(`span`,{"data-slot":`task-row-meta-droppable`,className:W(`contents`,h&&o_),children:[E?(0,Q.jsx)(`span`,{"data-slot":`dispatch-kind`,className:`shrink-0 rounded-full bg-muted px-1.5 py-px text-micro font-medium text-muted-foreground`,children:E}):null,e.diffStat?(0,Q.jsx)(Zc,{stat:e.diffStat,className:`hidden shrink-0 text-micro @min-[23rem]/sidebar:inline`}):null,T?(0,Q.jsx)(`span`,{"data-slot":`subtask-count`,title:T,className:`hidden shrink-0 rounded-full bg-muted px-1.5 py-px text-micro font-medium text-muted-foreground @min-[19rem]/sidebar:inline`,children:n}):null]}),w&&(r!==null||!y)?(0,Q.jsx)(`span`,{"data-slot":`task-row-age`,className:W(`shrink-0 text-meta text-soft-foreground tabular-nums`,E&&t>0&&r===null&&`hidden @min-[19rem]/sidebar:inline`),children:w}):null]}),S?(0,Q.jsx)(Ig,{}):null]}),s===null&&e.subject?(0,Q.jsx)(Qa,{run:e,className:h?`mr-0.5`:`mr-2.5`}):null,h?(0,Q.jsxs)(`div`,{"data-slot":`task-row-actions`,className:r_,children:[d?(0,Q.jsx)(La,{pinned:!!e.pinned,onToggle:t=>d(e,t),className:i_}):null,m&&f?(0,Q.jsx)(Fg,{archived:!!e.archived,onToggle:t=>f(e,t),className:i_}):null]}):null]})});function l_(e,t,n){let r=[e.runner??`claude`];t&&(e.inputTokens!==void 0||e.outputTokens!==void 0)&&r.push(jc(e.inputTokens,e.outputTokens));let i=we(e.costUsd);return n&&i&&r.push(i),r.join(` · `)}function u_(){let e=C(),t=se(kr(),e.data?.bootProject??null),n=un(`sidebar`),r=Yc(e.data),[i,a]=sg(),o=Pg(),[s]=lp(),c=Z.useMemo(()=>t.data?Hg(t.data,s):void 0,[t.data,s]),l=Cr(`/tasks/:id/*`),u=Cr(`/tasks/:id`),d=Yr(3e4),f=Z.useCallback((e,t)=>n.mutate({id:e.id,pinned:t},{onError:e=>Y(e.message,{tone:`danger`})}),[n.mutate]),p=Gt(`sidebar`),m=Z.useCallback((e,t)=>p.mutate({id:e.id,archived:t},{onError:e=>Y(e.message,{tone:`danger`})}),[p.mutate]),h=Lt(),g=We(),_=Z.useMemo(()=>h===void 0?[]:(c??[]).flatMap(e=>ce(e).map(e=>({projectId:h,kind:e.kind,number:e.number}))),[c,h]);return c?(0,Q.jsx)(Ur,{projectId:h,requests:_,children:(0,Q.jsxs)(Zg.Provider,{value:g,children:[i===`active`&&o&&(0,Q.jsx)(Dg,{compact:!0}),(0,Q.jsx)(Qg,{runs:c,view:i,onViewChange:a,currentRunId:l?.params.id??u?.params.id??null,now:d,showTokens:r.tokens,showCost:r.cost,onTogglePin:f,onToggleArchive:m})]})}):null}function d_({projects:e,folder:t,onClose:n,onSave:r}){let[i,a]=Z.useState(t?.name??``),[o,s]=Z.useState(t?.projectIds??[]),[c,l]=Z.useState(!1);return(0,Q.jsx)(qr,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(Wr,{"data-slot":`project-folder-dialog`,children:[(0,Q.jsxs)(Lr,{children:[(0,Q.jsx)(Zr,{children:t?`Organise folder`:`Create project folder`}),(0,Q.jsx)(Vr,{children:`Group projects for a client or any other part of your work.`})]}),(0,Q.jsxs)(`label`,{className:`grid gap-2 text-sm font-medium`,children:[`Folder name`,(0,Q.jsx)(Kc,{autoFocus:!0,value:i,onChange:e=>a(e.target.value),placeholder:`Client name`})]}),(0,Q.jsxs)(`fieldset`,{role:`group`,"aria-label":`Select projects`,className:`grid max-h-60 gap-1 overflow-y-auto`,children:[(0,Q.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:`Projects`}),e.map(e=>(0,Q.jsxs)(`label`,{className:`flex min-h-9 items-center gap-2 rounded px-2 text-sm hover:bg-muted`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:o.includes(e.id),onChange:t=>s(n=>t.target.checked?[...n,e.id]:n.filter(t=>t!==e.id))}),(0,Q.jsx)(dc,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),e.name]},e.id))]}),(0,Q.jsxs)(Br,{className:`sm:justify-between`,children:[t?c?(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(J,{type:`button`,variant:`danger-ghost`,onClick:()=>r(null,t.id),children:`Confirm delete`}),(0,Q.jsx)(J,{type:`button`,variant:`ghost`,onClick:()=>l(!1),children:`Keep folder`})]}):(0,Q.jsx)(J,{type:`button`,variant:`danger-ghost`,onClick:()=>l(!0),children:`Delete folder`}):(0,Q.jsx)(`span`,{}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(J,{type:`button`,variant:`outline`,onClick:n,children:`Cancel`}),(0,Q.jsx)(J,{type:`button`,disabled:!i.trim(),onClick:()=>r({id:t?.id??crypto.randomUUID(),name:i.trim(),projectIds:o},t?.id),children:`Save folder`})]})]})]})})}var f_=`cez-project-folders`;function p_(e){if(!Array.isArray(e))return[];let t=new Set,n=new Set;return e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let r=e,i=typeof r.id==`string`?r.id.trim():``;if(!i||t.has(i)||typeof r.name!=`string`||!r.name.trim())return[];t.add(i);let a=Array.isArray(r.projectIds)?[...new Set(r.projectIds.filter(e=>typeof e==`string`&&!n.has(e)))]:[];return a.forEach(e=>n.add(e)),[{id:i,name:r.name.trim(),projectIds:a}]})}function m_(){try{let e=localStorage.getItem(f_);return e===null?[]:p_(JSON.parse(e))}catch{return[]}}function h_(e){try{localStorage.setItem(f_,JSON.stringify(e))}catch{}}function g_(e,t,n){let r=e.filter(e=>e.id!==n&&e.id!==t?.id);return t&&(r=r.map(e=>({...e,projectIds:e.projectIds.filter(e=>!t.projectIds.includes(e))})),r.push(t)),r}function __(e,t,n){return e.map(e=>e.id===n?e.projectIds.includes(t)?e:{...e,projectIds:[...e.projectIds,t]}:e.projectIds.includes(t)?{...e,projectIds:e.projectIds.filter(e=>e!==t)}:e)}var v_=`cez-sidebar-collapsed`;function y_(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 b_(){try{let e=localStorage.getItem(v_);return e===null?{}:y_(JSON.parse(e))}catch{return{}}}function x_(e){try{localStorage.setItem(v_,JSON.stringify(e))}catch{}}function S_(e,t,n){let r=e?.[t];return r===void 0?t!==n:r}function C_(e,t,n,r){let i=e?.[`folder:${t}`];return i===void 0?!(r!==null&&n.includes(r)):i}var w_=10;function T_(e){let[t,n]=Z.useState(b_),r=Z.useRef(t),i=Z.useCallback(e=>{r.current=e,x_(e),n(e)},[]);return{collapsed:t,toggle:Z.useCallback(t=>{i({...r.current,[t]:!S_(r.current,t,e)})},[e,i]),expand:Z.useCallback(e=>{if(!(e in r.current))return;let t={...r.current};delete t[e],i(t)},[i])}}var E_=new Set;function D_({projects:e,bootProjectId:t,inboxAvailable:n=!1,automationsAvailable:r=!1,inboxCount:i=null,skillsUpdateAvailable:a=!1,newNavItems:o=E_}){let{pathname:s}=jr(),c=Sr(s),l=c??t,{collapsed:u,toggle:d,expand:f}=T_(l),[p,m]=Z.useState(m_),h=Z.useCallback(e=>{f(e);for(let t of p)t.projectIds.includes(e)&&f(`folder:${t.id}`)},[f,p]),[g,_]=Z.useState(void 0),v=Z.useCallback((e,t)=>{let n=g_(p,e,t);m(n),h_(n),_(void 0)},[p]),[y]=sg(),b=Df(Er(s)),x=Cr(`/tasks/:id/*`),S=Cr(`/tasks/:id`),w=x?.params.id??S?.params.id??null,T=Yr(3e4),E=Yc(C().data),{order:D,canReorder:O,setOrder:k}=pp(),A=Z.useMemo(()=>{let t=Jf(e,D),n=t.filter(e=>e.unregistered);return n.length===0?t:[...n,...t.filter(e=>!e.unregistered)]},[e,D]),j=Z.useMemo(()=>A.map(e=>e.id),[A]),M=Di($r(Oi,{activationConstraint:{distance:4}}),$r(pi,{coordinateGetter:hi})),N=O&&A.length>1,P=Z.useCallback(e=>{let{active:t,over:n}=e;if(n===null||n.id===t.id)return;let r=String(t.id),i=String(n.id),a=j.indexOf(r),o=j.indexOf(i);if(a===-1||o===-1)return;let s=p.find(e=>e.projectIds.includes(r)),c=p.find(e=>e.projectIds.includes(i));if(s?.id!==c?.id){let e=__(p,r,c?.id??null);m(e),h_(e)}k(Yf(j,a,o))},[p,j,k]),F=Z.useMemo(()=>{let e=e=>{let t=j.indexOf(String(e));return{name:A[t]?.name??String(e),position:`position ${t+1} of ${j.length}`}};return{onDragStart:({active:t})=>{let{name:n,position:r}=e(t.id);return`Picked up ${n}, ${r}.`},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,j]),ee=A.map(e=>(0,Q.jsx)(k_,{project:e,boot:e.id===t,active:e.id===c,collapsed:S_(u,e.id,l),onToggle:d,onSelect:h,view:y,activeTo:b,currentRunId:w,now:T,inboxAvailable:n,automationsAvailable:r,inboxCount:i,skillsUpdateAvailable:a,newNavItems:o,showTokens:E.tokens,showCost:E.cost,sortable:N,position:j.indexOf(e.id)+1,total:j.length},e.id)),te=new Map(A.map((e,t)=>[e.id,ee[t]])),I=Z.useMemo(()=>[...p.map(e=>({folder:e,projects:A.filter(t=>e.projectIds.includes(t.id))})),{folder:null,projects:A.filter(e=>!p.some(t=>t.projectIds.includes(e.id)))}].filter(({folder:e,projects:t})=>e!==null||t.length>0||p.length===0),[p,A]),ne=Z.useMemo(()=>I.flatMap(({folder:e,projects:t})=>{let n=t.map(e=>e.id);return e&&C_(u,e.id,n,c)?[]:n}),[I,u,c]);return(0,Q.jsxs)(`div`,{"data-slot":`project-group-list`,children:[(0,Q.jsx)(`div`,{className:`mb-1 flex justify-end`,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`project-folder-create`,onClick:()=>_(null),className:`flex h-7 items-center gap-1 rounded px-2 text-xs text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,Q.jsx)(Al,{className:`size-3.5`,"aria-hidden":`true`}),` New folder`]})}),(0,Q.jsx)(ki,{sensors:M,collisionDetection:li,accessibility:{announcements:F},onDragEnd:P,children:(0,Q.jsx)(Ci,{items:ne,strategy:gi,children:I.map(({folder:e,projects:t})=>{let n=t.map(e=>e.id),r=e&&C_(u,e.id,n,c);return(0,Q.jsx)(Z.Fragment,{children:e?(0,Q.jsxs)(`div`,{"data-slot":`project-folder`,"data-folder":e.id,className:`mb-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-expanded":!r,onClick:()=>d(`folder:${e.id}`),className:`flex h-8 min-w-0 flex-1 items-center gap-2 rounded px-2 text-xs font-semibold text-muted-foreground hover:bg-muted`,children:[(0,Q.jsx)(Ws,{className:W(`size-3 transition-transform`,r&&`-rotate-90`),"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Q.jsx)(`span`,{className:`ml-auto`,"aria-label":`${t.length} project${t.length===1?``:`s`}`,children:t.length})]}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Edit ${e.name}`,onClick:()=>_(e),className:`size-8 rounded text-xs text-muted-foreground hover:bg-muted`,children:`…`})]}),r?null:(0,Q.jsx)(`div`,{className:`ml-2 border-l border-border pl-1`,children:t.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-1 text-xs text-muted-foreground`,children:`No projects`}):t.map(e=>te.get(e.id))})]}):t.map(e=>te.get(e.id))},e?.id??`ungrouped`)})})}),g!==void 0&&(0,Q.jsx)(d_,{projects:e,folder:g,onClose:()=>_(void 0),onSave:v})]})}function O_({name:e,position:t,total:n,disabled:r,handleProps:i}){return(0,Q.jsx)(`button`,{type:`button`,"data-slot":`project-group-grip`,disabled:r,"aria-label":`Reorder ${e}, position ${t} of ${n}`,className:W(`flex h-11 w-6 shrink-0 cursor-grab items-center justify-center rounded text-muted-foreground opacity-0 outline-none transition-opacity md:h-[34px] md:w-4`,`touch-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`,r&&`cursor-default group-hover/row:opacity-0 group-focus-within/row:opacity-0 [@media(hover:none)]:opacity-0`),...i,children:(0,Q.jsx)(io,{"aria-hidden":`true`,className:`size-3.5`})})}function k_({project:e,boot:t,active:n,collapsed:r,onToggle:i,onSelect:a,view:o,activeTo:s,currentRunId:c,now:l,inboxAvailable:u,automationsAvailable:d,inboxCount:f,skillsUpdateAvailable:p,newNavItems:m,showTokens:h,showCost:g,sortable:_,position:v,total:y}){let b=e.status===`missing`,x=_&&!b&&!e.unregistered,{attributes:S,listeners:C,setNodeRef:w,transform:T,transition:E,isDragging:D}=di({id:e.id,disabled:!x}),O={transform:ui.Translate.toString(T),transition:E},k=(0,Q.jsx)(O_,{name:e.name,position:v,total:y,disabled:!x,handleProps:{...S,...C}}),A=Ye(e.id,!r&&!b,t),j=We(),M=e.repoUrl??(n?j:void 0),P=mh(),F=un(`sidebar`,e.id,t?`default`:e.id),ee=Z.useCallback((e,t)=>F.mutate({id:e.id,pinned:t},{onError:e=>Y(e.message,{tone:`danger`})}),[F.mutate]),te=Gt(`sidebar`,e.id,t?`default`:e.id),I=Z.useCallback((e,t)=>te.mutate({id:e.id,archived:t},{onError:e=>Y(e.message,{tone:`danger`})}),[te.mutate]),[ne]=lp(),L=A.data?Le(A.data).waiting:0,re=A.data?N(xe(Hg(A.data,ne),o),w_):[],ie=re.flatMap(t=>t.rows.flatMap(t=>ce(t.kind===`run`?t.run:t.members[0]).map(t=>({projectId:e.id,kind:t.kind,number:t.number}))));if(b)return(0,Q.jsx)(`div`,{ref:w,style:O,"data-slot":`project-group`,"data-project":e.id,"data-status":`missing`,className:W(`mb-1`,D&&`relative z-10 opacity-40`),children:(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`w-6 shrink-0 md:w-4`}),(0,Q.jsxs)(`div`,{"data-slot":`project-group-header`,title:`${e.root} is gone — remove it in Global settings → Projects`,className:`flex h-11 min-w-0 flex-1 items-center gap-[7px] rounded-lg px-2 text-ui font-semibold opacity-55 md:h-[34px]`,children:[(0,Q.jsx)(`span`,{className:`w-3 shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Q.jsx)(`span`,{"data-slot":`project-missing`,className:`ml-auto shrink-0 rounded-full bg-danger/15 px-[7px] py-px text-micro font-medium text-danger`,children:`folder not found`})]})]})});let ae=`project-group-${e.id}`;return(0,Q.jsxs)(`div`,{ref:w,style:O,"data-slot":`project-group`,"data-project":e.id,"data-status":e.status,"data-collapsed":r?``:void 0,"data-dragging":D?``:void 0,"data-active":n?``:void 0,className:W(`mb-1`,D&&`relative z-10 opacity-40`),children:[(0,Q.jsxs)(`div`,{className:`group/row flex items-center`,children:[k,(0,Q.jsxs)(`div`,{"data-slot":`project-group-row`,className:W(`flex min-w-0 flex-1 items-center rounded-lg transition-colors hover:bg-muted`,n&&`bg-muted`),children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),"aria-expanded":!r,"aria-controls":ae,"aria-label":`${r?`Expand`:`Collapse`} ${e.name}`,"data-slot":`project-group-disclosure`,className:W(`flex h-11 w-[27px] shrink-0 items-center justify-center rounded-lg md:h-[34px]`),children:(0,Q.jsx)(Ws,{className:W(`size-3 shrink-0 text-muted-foreground transition-transform`,r&&`-rotate-90`),"aria-hidden":`true`})}),(0,Q.jsxs)(K,{to:_r(e.id,`/`),onClick:()=>{a(e.id),P?.()},"aria-current":n?`true`:void 0,"data-slot":`project-group-header`,className:W(`flex h-11 min-w-0 flex-1 items-center gap-[7px] rounded-lg pr-2 text-left text-ui font-semibold md:h-[34px]`,n&&`text-foreground`),children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),e.unregistered?(0,Q.jsx)(`span`,{"data-slot":`project-unregistered`,title:`cezar is serving this folder — it is not in your saved projects. Add it from this project's Settings.`,className:`shrink-0 rounded-full bg-muted px-[7px] py-px text-micro font-medium text-soft-foreground`,children:`not saved`}):null,L?(0,Q.jsx)(`span`,{"data-slot":`project-attention`,title:`${L} task${L===1?``:`s`} need${L===1?`s`:``} you`,className:`shrink-0 rounded-full bg-violet px-1.5 py-px text-micro font-semibold text-violet-foreground`,children:L}):null,e.branch?(0,Q.jsx)(`span`,{"data-slot":`project-branch`,className:`ml-auto max-w-[92px] truncate font-mono text-micro font-medium text-soft-foreground`,children:e.branch}):null]})]})]}),r?null:(0,Q.jsxs)(`div`,{id:ae,"data-slot":`project-group-body`,className:`mt-1 ml-[14px] border-l border-border pl-2`,children:[(0,Q.jsx)(`nav`,{"aria-label":`${e.name} navigation`,children:Tf({forge:e.forge===`github`,inbox:u,automations:d,tracker:e.tracker}).map(t=>{let r=n&&t.to===s,i=t.icon;return(0,Q.jsxs)(K,{to:_r(e.id,t.to),onClick:P,"aria-current":r?`page`:void 0,className:W(`flex h-11 w-full items-center gap-2.5 rounded-md px-2.5 text-ui font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground md:h-[30px]`,r&&`bg-muted font-semibold text-foreground`),children:[(0,Q.jsx)(i,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t.label,t.badge===`inbox-count`&&n&&f?(0,Q.jsx)(`span`,{"data-slot":`nav-badge`,className:`ml-auto rounded-full bg-violet px-1.5 py-px text-micro font-semibold text-violet-foreground`,children:f}):null,t.badge===`skills-update`&&n&&p?(0,Q.jsxs)(`span`,{"data-slot":`nav-update-marker`,className:`ml-auto flex items-center`,children:[(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-violet`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Skills update available`})]}):null,n&&m.has(t.to)?(0,Q.jsxs)(`span`,{"data-slot":`nav-new-marker`,className:`ml-auto flex items-center`,children:[(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-violet`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`New`})]}):null]},t.to)})}),(0,Q.jsx)(Ur,{projectId:e.id,requests:ie,children:(0,Q.jsx)(Zg.Provider,{value:M,children:(0,Q.jsx)($g,{buckets:re,currentRunId:n?c:null,now:l,scope:e.id,showTokens:h,showCost:g,onTogglePin:o===`archived`?void 0:ee,onToggleArchive:I})})}),(0,Q.jsx)(K,{to:_r(e.id,`/`),onClick:P,"data-slot":`project-group-more`,className:`flex h-9 items-center rounded-md px-3 text-label text-muted-foreground transition-colors hover:text-foreground md:h-7`,children:`More…`})]})]})}var A_={claude:!0,codex:!0,junie:!0,opencode:!0,cursor:!0,pi:!0,copilot:!0,omp:!0,antigravity:!0,gemini:!0,kimi:!0},j_=e=>Object.hasOwn(A_,e.name);function M_(e){let t=e.checks.filter(j_);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`:e.disk?.level===`critical`?`disk almost full — ${N_(e.disk.freeBytes)} free`:null}function N_(e){return _(e)||`under 100 MB`}function P_(e){let t=e.disk;if(!t||t.level===`ok`)return null;let n=t.worktreesBytes?` Task worktrees use ${_(t.worktreesBytes)}.`:``,r=t.level===`critical`?` New agents will not start until space is freed.`:``;return`Only ${N_(t.freeBytes)} free on the disk holding task worktrees.${n}${r} Reclaim finished tasks' worktrees (branches are kept) or delete old tasks.`}function F_(e){let t=`cezar v${e.version}`,n=M_(e);if(n)return`${t} · ${n}`;let r=e.disk?.level===`low`?` · low disk space (${N_(e.disk.freeBytes)} free)`:``,i=e.checks.filter(e=>!e.available).map(e=>e.name);return r?`${t}${r}`:i.length?`${t} · optional: ${i.join(`, `)} not installed`:t}function I_(e){return e===void 0||e?.available?null:e?e.available===void 0?null:`GitHub is unreachable — ${e.reason??`unknown reason`}. The GitHub tab can retry.`:`No GitHub remote detected — the GitHub tab is hidden. Every plain-git feature still works.`}function L_({health:e,forge:t}){if(!e)return null;let n=I_(t),r=M_(e),i=P_(e);return(0,Q.jsxs)(tc,{children:[(0,Q.jsx)(Ys,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`tools-menu-trigger`,title:F_(e),className:`flex items-center gap-1.5 rounded-full border border-border px-2 py-0.5 text-meta font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,Q.jsx)(Jc,{tone:r||i?`pending`:`success`}),`Tools`,(0,Q.jsx)(Ws,{className:`size-[11px]`,"aria-hidden":`true`})]})}),(0,Q.jsxs)(Zs,{side:`top`,align:`start`,"data-slot":`tools-menu-content`,className:`w-[240px]`,children:[(0,Q.jsx)(Js,{className:`eyebrow text-soft-foreground`,children:`Installed tools`}),e.checks.map(e=>e.available?(0,Q.jsx)(R_,{check:e},e.name):(0,Q.jsx)(B_,{check:e},e.name)),n?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ec,{}),(0,Q.jsx)(`p`,{"data-slot":`forge-note`,className:`px-2 py-1.5 text-meta leading-snug text-muted-foreground`,children:n})]}):null,i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ec,{}),(0,Q.jsx)(`p`,{"data-slot":`disk-note`,className:`px-2 pt-1.5 text-meta leading-snug text-muted-foreground`,children:i}),(0,Q.jsx)($s,{asChild:!0,children:(0,Q.jsx)(K,{to:`/settings/worktrees`,"data-slot":`disk-reclaim`,className:`text-meta font-semibold text-violet`,children:`Manage worktrees →`})})]}):null,(0,Q.jsx)(ec,{}),(0,Q.jsx)($s,{asChild:!0,children:(0,Q.jsxs)(yr,{to:z_,"data-slot":`tools-settings`,className:`gap-2 text-label text-muted-foreground`,children:[(0,Q.jsx)(tu,{className:`size-3.5`,"aria-hidden":`true`}),`Agent accounts`]})})]})]})}function R_({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)(Jc,{tone:`success`}),(0,Q.jsx)(`span`,{className:`font-mono text-label font-medium`,children:e.name}),(0,Q.jsx)(`span`,{"data-slot":`tool-version`,className:`ml-auto font-mono text-meta font-medium text-muted-foreground tabular-nums`,children:e.version??`not found`})]})}var z_=`/settings/global/accounts`;function B_({check:e}){let t=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Jc,{tone:`danger`}),(0,Q.jsx)(`span`,{className:`font-mono text-label font-medium`,children:e.name}),(0,Q.jsx)(`span`,{"data-slot":`tool-version`,className:`ml-auto font-mono text-meta font-medium text-muted-foreground`,children:`not found`})]}),e.hint||j_(e)?(0,Q.jsxs)(`span`,{className:`flex items-end justify-between gap-3 pl-[15px]`,children:[e.hint?(0,Q.jsx)(`span`,{"data-slot":`tool-hint`,className:`min-w-0 text-meta leading-snug text-muted-foreground`,children:e.hint}):null,j_(e)?(0,Q.jsx)(`span`,{"data-slot":`tool-setup`,className:`ml-auto shrink-0 text-meta font-semibold text-violet`,children:`Set up →`}):null]}):null]});return j_(e)?(0,Q.jsx)($s,{asChild:!0,children:(0,Q.jsx)(yr,{to:`${z_}?agent=${encodeURIComponent(e.name)}`,"data-slot":`tool-row`,"data-tool":e.name,"data-available":`false`,className:`flex-col items-stretch gap-1`,children:t})}):(0,Q.jsx)(`div`,{"data-slot":`tool-row`,"data-tool":e.name,"data-available":`false`,className:`flex flex-col items-stretch gap-1 rounded-sm px-2 py-1.5`,children:t})}function V_(e){return e?.trim()||null}function H_({projectName:e,pageLabel:t,brandName:n}){let r=V_(e),i=V_(t),a=V_(n??null)??`cezar`;return r&&i?`${r} — ${i} · ${a}`:r?`${r} · ${a}`:i?`${i} · ${a}`:a}function U_(e){let t=H_(e);(0,Z.useEffect)(()=>{document.title=t},[t]),(0,Z.useEffect)(()=>{let t=document.querySelector(`link[rel="icon"]`);t||(t=document.createElement(`link`),t.rel=`icon`,document.head.append(t)),t.href=e.brandLogoUrl??`/icon.svg`,t.type=e.brandLogoUrl?.includes(`.svg?`)?`image/svg+xml`:``},[e.brandLogoUrl])}function W_(e,t,n){if(e===void 0||n===void 0||t===null||t!==e.bootProject||n.bootProject!==t||n.capabilities?.localHandoff!==!0||e.projects.some(e=>e.id===t))return e;let r=n.repoRoot,i=r?.replace(/[\\/]+$/,``).split(/[\\/]/).pop();return i?{...e,projects:[{id:t,root:r,name:i,addedAt:``,lastOpenedAt:``,source:`local`,status:n.repo?`ok`:`not-git`,unregistered:!0,...n.repo?{branch:n.repo.branch}:{}},...e.projects]}:e}var G_={claude:`Anthropic’s coding agent. Uses your Claude account.`,codex:`OpenAI’s coding agent. Uses your ChatGPT account.`,opencode:`Open-source agent. Works with many model providers.`,cursor:`Cursor’s agent, without the editor. Uses your Cursor account.`,copilot:`GitHub’s coding agent. Uses your Copilot plan.`};function K_(e,t){let n=new Map((t?.providers??[]).map(e=>[e.provider,e])),r=e.agents.flatMap(e=>{let t=n.get(e.provider);if(t?.status===`connected`||t?.enabled===!1)return[];let r=t===void 0||t.status===`not-installed`?`missing`:`signed-out`;return[{...e,label:Go[e.provider],description:G_[e.provider],state:r}]});return[...r.filter(e=>e.state===`signed-out`),...r.filter(e=>e.state===`missing`)]}var q_=/\u001B\][^\u0007\u001B]*(?:\u0007|\u001B\\)|\u001B\[[0-?]*[ -/]*[@-~]/g,J_=/https?:\/\/[^\s"'<>\u0007\u001B]+/g;function Y_(e){let t=e.replace(q_,` `).match(J_)??[];for(let e of t.reverse()){let t=X_(e.replace(/[.,;:)\]]+$/,``));if(t&&![`localhost`,`127.0.0.1`,`[::1]`].includes(t.hostname))return t.href}return null}function X_(e){try{return new URL(e)}catch{return null}}var Z_=Z.lazy(()=>mr(()=>import(`./terminal-pane-CRjYeI78.js`).then(e=>({default:e.TerminalPane})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))),Q_=3e3,$_=60,ev=4,tv=1e4;function nv(e,t){return K_(e,t).some(e=>e.state===`signed-out`)?`Sign in to an agent`:`Pick your agent`}function rv({setup:e,status:t}){let n=f(),r=Je(),i=At(),a=rn(),o=a.mutateAsync,s=a.mutate,c=K_(e,t),[l,u]=Z.useState(e.session),[d,p]=Z.useState(null),m=e.session;Z.useEffect(()=>{m&&(u(m),m.exitCode===null&&p(null))},[m]);let h=r.mutate,g=Z.useCallback((e,t)=>{p(null),h({provider:e,action:t},{onSuccess:e=>u(e),onError:n=>{p({provider:e,action:t,message:n.message}),s()}})},[s,h]),_=Z.useRef(null),v=Z.useCallback((e,t)=>{if(_.current===e.id)return;_.current=e.id;let{provider:r,action:i}=e,a=Go[r];i===`install`&&n(),o().then(e=>{let n=e.providers.find(e=>e.provider===r);if(n?.status===`connected`)return;let o=n!==void 0&&n.status!==`not-installed`;i===`install`&&o?g(r,`login`):p(i===`login`||t?{provider:r,action:i,message:t||`The sign-in to ${a} did not finish.`}:{provider:r,action:i,message:`${a} installed, but cezar cannot find it. Restart cezar from a new terminal, or check that npm’s global folder is on your PATH.`})},()=>p({provider:r,action:i,message:`cezar could not check the agent. Try again.`}))},[g,n,o]),y=m?.exitCode??null;Z.useEffect(()=>{if(!(!m||y===null)){if(m.action===`install`&&y!==0){if(_.current===m.id)return;_.current=m.id,n(),p({provider:m.provider,action:m.action,message:`${Go[m.provider]} did not install. The terminal says why.`});return}v(m,``)}},[y,n,m,v]);let b=Z.useRef(null);m&&(b.current=m.id),Z.useEffect(()=>{m||!l||l.exitCode!==null||b.current!==l.id||(u(null),v(l,`The terminal closed before it finished.`))},[m,v,l]);let x=l!==null&&l.exitCode===null,S=x&&l?.action===`install`,C=x&&l?.action===`login`;Z.useEffect(()=>{if(!C)return;let e=0,t=window.setInterval(()=>{e+=1,(e<=$_||e%ev===0)&&s()},Q_);return()=>window.clearInterval(t)},[s,C]),Z.useEffect(()=>{if(x)return;let e=window.setInterval(()=>s(),tv);return()=>window.clearInterval(e)},[s,x]);let w=Z.useRef(null);w.current=C&&l?l.id:null;let T=Z.useRef(!1);Z.useEffect(()=>(T.current=!0,()=>{T.current=!1;let e=w.current;window.setTimeout(()=>{!T.current&&e&&Ln(e).catch(()=>{})},0)}),[]);let E=()=>{l&&i.mutate(l.id),u(null)},D=()=>{p(null),x||u(null)};return(0,Q.jsx)(`div`,{className:`mt-7 flex w-full flex-col gap-3 text-left`,children:c.map(e=>{let t=l?.provider===e.provider,n=d?.provider===e.provider?d:null,i=x||r.isPending;return(0,Q.jsxs)(`div`,{"data-slot":`agent-row`,"data-state":e.state,"data-provider":e.provider,className:`rounded-xl border border-border bg-card p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`text-lead text-foreground`,children:e.label}),(0,Q.jsx)(`div`,{className:`text-ui text-muted-foreground`,children:e.state===`missing`?e.description:`Installed, not signed in`})]}),(0,Q.jsx)(iv,{row:e,open:t,busy:i,onStart:g})]}),!t&&!n&&e.state===`missing`&&e.installCommand===null?(0,Q.jsx)(`p`,{className:`mt-3 text-ui text-soft-foreground`,children:e.installHint}):null,!t&&!n&&e.state===`missing`&&e.installCommand?(0,Q.jsx)(av,{command:e.installCommand}):null,t&&l?(0,Q.jsx)(ov,{session:l,running:x,installing:S},l.id):null,n&&!t?(0,Q.jsx)(av,{command:(n.action===`install`?e.installCommand:e.loginCommand)??``}):null,n?(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,Q.jsx)(`p`,{role:`alert`,className:`min-w-0 flex-1 text-ui text-danger`,children:n.message}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(J,{size:`sm`,variant:`outline`,className:`font-normal`,onClick:D,children:`Close`}),(0,Q.jsx)(J,{size:`sm`,className:`font-normal`,disabled:r.isPending,onClick:()=>g(n.provider,n.action),children:`Try again`})]})]}):null,t&&x?(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:S?`Sign-in comes next.`:`This page continues by itself.`}),(0,Q.jsx)(J,{size:`sm`,variant:`outline`,className:`font-normal`,onClick:E,children:`Cancel`})]}):null]},e.provider)})})}function iv({row:e,open:t,busy:n,onStart:r}){return t?null:e.state===`signed-out`?(0,Q.jsx)(J,{className:`font-normal`,disabled:n||e.loginCommand===null,onClick:()=>r(e.provider,`login`),children:`Sign in`}):e.installCommand===null?null:(0,Q.jsx)(J,{className:`font-normal`,disabled:n,onClick:()=>r(e.provider,`install`),children:`Install`})}function av({command:e}){return(0,Q.jsxs)(`code`,{className:`mt-3 block truncate font-mono text-meta text-soft-foreground`,title:e,children:[(0,Q.jsx)(`span`,{className:`select-none`,children:`$ `}),e]})}function ov({session:e,running:t,installing:n}){let[r,i]=Z.useState(null),a=e.id,o=Z.useRef(``),s=e.action===`login`,c=Z.useMemo(()=>({read:async e=>{let t=await rt(a,e);return s&&t.data&&(o.current=(o.current+t.data).slice(-16384),i(Y_(o.current))),t},write:e=>Be(a,e),resize:(e,t)=>$e(a,e,t)}),[a,s]),l=Z.useMemo(()=>({id:a,exitCode:t?null:e.exitCode,topic:t?e.topic:null}),[a,t,e.exitCode,e.topic]),u=Go[e.provider];return(0,Q.jsxs)(`div`,{"data-slot":`agent-setup-terminal`,className:`mt-3 flex flex-col gap-2`,children:[t?(0,Q.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-ui text-muted-foreground`,children:[(0,Q.jsx)(_c,{className:`size-3.5 shrink-0 motion-safe:animate-spin`,"aria-hidden":`true`}),n?e.command.startsWith(`sudo `)?`Installing ${u}. Click the terminal and type your computer password if it asks.`:`Installing ${u}…`:`Sign in to ${u}. Click the terminal to answer its questions.`]}):null,(0,Q.jsx)(av,{command:e.command}),(0,Q.jsx)(`div`,{className:`relative h-72 overflow-hidden rounded-lg border border-border bg-card-2`,children:(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(Z_,{runId:e.runId,session:l,active:!0,io:c})})}),s&&r&&t?(0,Q.jsx)(J,{asChild:!0,size:`sm`,variant:`outline`,className:`self-start font-normal`,children:(0,Q.jsxs)(`a`,{href:r,target:`_blank`,rel:`noopener noreferrer`,children:[`Open sign-in page`,(0,Q.jsx)(ic,{"aria-hidden":`true`})]})}):null]})}function sv(){let e=U();return Z.useCallback(t=>{let n=B.uiState,r=e.getQueryData(n),i={...r?.onboarding,...typeof t==`function`?t(r?.onboarding):t};e.setQueryData(n,{...r,onboarding:i}),Pt({onboarding:i}).then(t=>e.setQueryData(n,t)).catch(t=>{e.setQueryData(n,r),Y(t instanceof Error?t.message:String(t),{tone:`danger`})})},[e])}function cv({title:e,slot:t,rail:n,why:r,subtitle:i,banner:a,wide:o=!1,children:s}){return(0,Q.jsxs)(`section`,{"data-onboarding":``,"data-slot":`first-run`,"data-first-run":t,className:W(`mx-auto flex w-full flex-1 flex-col items-center px-1 pt-6 pb-12 text-center md:pt-12`,o?`max-w-3xl`:`max-w-2xl`),children:[a,n,(0,Q.jsx)(`h2`,{className:W(`text-4xl font-light tracking-tight text-balance text-foreground`,n&&`mt-8`),children:e}),r?(0,Q.jsx)(`p`,{className:`mt-3 max-w-md text-lead text-muted-foreground`,children:r}):null,i?(0,Q.jsx)(`p`,{className:`mt-2 text-body text-muted-foreground`,children:i}):null,s]})}var lv=`inline-flex items-center gap-1.5 text-ui text-muted-foreground transition-colors hover:text-foreground`,uv=`inline-flex h-[30px] items-center gap-1.5 rounded-full border border-border px-3 text-label text-muted-foreground transition-colors hover:border-muted-foreground hover:text-foreground`,dv=`inline-flex h-8 items-center gap-2 rounded-full px-3 text-ui text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`;function fv(){let[e,t]=Z.useState(0);return Z.useLayoutEffect(()=>{let e=()=>{let e=document.querySelector(`aside[data-slot="sidebar"]`);t(e?Math.max(0,e.getBoundingClientRect().right)/2:0)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),e}function pv({title:e,description:t,onOpenChange:n,onSubmit:r,footer:i,wide:a=!1,children:o}){let s=fv();return(0,Q.jsx)(qr,{open:!0,onOpenChange:n,children:(0,Q.jsxs)(Wr,{"data-onboarding":``,className:W(`gap-0 p-0`,a?`sm:max-w-lg`:`sm:max-w-md`),style:s?{left:`calc(50% + ${s}px)`}:void 0,onKeyDown:e=>{r&&e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),r())},children:[(0,Q.jsxs)(Lr,{className:`border-b border-border px-6 py-5 text-left`,children:[(0,Q.jsx)(Zr,{className:`text-xl font-light tracking-tight`,children:e}),(0,Q.jsx)(Vr,{children:t})]}),(0,Q.jsx)(`div`,{className:`px-6 py-5 text-left`,children:o}),(0,Q.jsx)(Br,{className:`border-t border-border px-6 py-4`,children:i})]})})}function mv({title:e,description:t,pages:n,slot:r,onOpenChange:i}){let[a,o]=Z.useState(0),s=n[Math.min(a,n.length-1)];if(!s)return null;let c=a>=n.length-1,l=()=>c?i(!1):o(a+1);return(0,Q.jsx)(pv,{wide:!0,title:e,description:t,onOpenChange:i,onSubmit:l,footer:(0,Q.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`mr-auto flex items-center gap-1.5`,"aria-label":`${a+1} of ${n.length}`,children:n.map((e,t)=>(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:W(`h-1.5 rounded-full transition-all`,t===a?`w-4 bg-violet`:`w-1.5 bg-border`)},e.id))}),a>0?(0,Q.jsx)(J,{variant:`outline`,className:`font-normal`,onClick:()=>o(a-1),children:`Back`}):null,(0,Q.jsx)(J,{className:`font-normal`,onClick:l,children:c?`Done`:`Next`})]}),children:(0,Q.jsxs)(`div`,{"data-slot":r,"data-page":s.id,onKeyDown:e=>{e.key===`ArrowRight`&&!c&&o(a+1),e.key===`ArrowLeft`&&a>0&&o(a-1)},children:[(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:`onboarding-preview flex h-44 items-end justify-center overflow-hidden rounded-lg border border-border px-8 pt-6`,children:s.picture}),(0,Q.jsxs)(`div`,{className:`mt-5 flex min-h-28 flex-col`,children:[(0,Q.jsx)(`h3`,{className:`text-lg font-light tracking-tight text-foreground`,children:s.title}),(0,Q.jsx)(`p`,{className:`mt-1 text-ui text-muted-foreground`,children:s.body}),s.action?(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{i(!1),s.action?.onClick()},className:`mt-3 inline-flex items-center gap-1 self-start text-ui text-violet hover:underline`,children:[s.action.label,(0,Q.jsx)(co,{className:`size-3.5`,"aria-hidden":`true`})]}):null]})]})})}function hv({title:e,description:t,picture:n,recommended:r=!1,badge:i=`Start here`,onClick:a}){return(0,Q.jsxs)(`button`,{type:`button`,onClick:a,"data-recommended":r||void 0,className:W(`group relative flex flex-col items-center gap-4 rounded-xl border px-4 pt-7 pb-5 text-center transition-colors`,r?`onboarding-announcement`:`border-border bg-card hover:border-muted-foreground`),children:[r?(0,Q.jsx)(`span`,{className:`absolute top-3 right-3 eyebrow text-violet`,children:i}):null,(0,Q.jsx)(`span`,{className:`grid h-16 place-items-center`,"aria-hidden":`true`,children:n}),(0,Q.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-lg font-light text-foreground`,children:e}),(0,Q.jsx)(`span`,{className:`text-label text-muted-foreground`,children:t})]})]})}function gv({title:e,description:t,picture:n,value:r,selected:i,disabled:a=!1,reason:o,onClick:s}){return(0,Q.jsxs)(`button`,{type:`button`,"data-value":r,"aria-pressed":i,"aria-label":e,disabled:a,title:o,onClick:s,className:W(`flex items-center gap-3 rounded-xl border px-4 py-3 text-left transition-colors disabled:opacity-50`,i?`onboarding-announcement border-violet/60`:`border-border bg-card hover:border-muted-foreground`),children:[(0,Q.jsx)(`span`,{className:`grid size-12 shrink-0 place-items-center`,"aria-hidden":`true`,children:n}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-lead text-foreground`,children:e}),(0,Q.jsx)(`span`,{className:`text-label text-muted-foreground`,children:t})]})]})}function _v({steps:e}){return(0,Q.jsx)(`ol`,{"data-slot":`step-rail`,className:`flex items-center gap-2 text-label`,children:e.map((e,t)=>(0,Q.jsxs)(`li`,{"data-step":e.id,"data-state":e.state,className:`flex items-center gap-2`,children:[t>0?(0,Q.jsx)(`span`,{className:W(`h-px w-6`,e.state===`next`?`bg-border`:`bg-violet/60`),"aria-hidden":`true`}):null,(0,Q.jsxs)(`span`,{className:W(`inline-flex items-center gap-1.5`,e.state===`current`?`text-foreground`:e.state===`done`?`text-muted-foreground`:`text-soft-foreground`),children:[(0,Q.jsx)(`span`,{className:W(`grid size-5 place-items-center rounded-full border font-mono text-micro`,e.state===`done`&&`border-violet/60 bg-violet/15 text-violet`,e.state===`current`&&`border-violet text-foreground`,e.state===`next`&&`border-border text-soft-foreground`),"aria-hidden":`true`,children:e.state===`done`?(0,Q.jsx)(Rs,{className:`size-3`}):t+1}),e.label,e.state===`current`?(0,Q.jsx)(`span`,{className:`sr-only`,children:`(current step)`}):null]})]},e.id))})}function vv({bar:e,children:t,className:n}){return(0,Q.jsxs)(`div`,{className:W(`w-full max-w-xs rounded-t-lg border border-b-0 border-border bg-background shadow-[0_-12px_40px_-20px_var(--violet)]`,n),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),e]}),(0,Q.jsx)(`div`,{className:`p-3`,children:t})]})}var yv=`h-2 rounded bg-muted`;function bv(e){return(e?.providers??[]).filter(e=>e.status===`connected`&&e.enabled!==!1).map(e=>e.provider)}function xv(e){if(e!==void 0)return bv(e).length>0}function Sv(e){let t=[];return e.worktreeSetupConfigured===!1&&t.push({id:`worktrees`,label:`Prepare worktrees`,description:`Install dependencies and copy env files into every task worktree.`,action:`Set up`,to:`/settings/worktrees`}),e.forge?.available===!1&&t.push({id:`github`,label:`Connect GitHub`,description:`Pull requests and issues need the GitHub CLI.`,action:`Connect`,to:`/github`}),t}var Cv={claude:{install:`npm i -g @anthropic-ai/claude-code`,login:`claude`},codex:{install:`npm i -g @openai/codex`,login:`codex login`}};function wv(e){let t=new Map((e?.providers??[]).map(e=>[e.provider,e]));return Object.keys(Cv).flatMap(e=>{let n=Cv[e];if(!n)return[];let r=t.get(e);if(r?.status===`connected`||r?.enabled===!1)return[];let i=r?.status===`disconnected`;return[{provider:e,label:Go[e],state:i?`signed-out`:`missing`,command:i?n.login:n.install,login:n.login}]})}var Tv=[{id:`task-tabs-2026-10`,preview:`tabs`,title:`Task tabs and layouts`,description:`Chat, Changes, Preview and Terminal as tabs in every task. Save a layout by name.`,releasedAt:`2026-10-19`},{id:`task-palette-2026-10`,preview:`palette`,title:`Task palette`,description:`Press ⌘P in a task to act on it or jump to another one.`,releasedAt:`2026-10-18`},{id:`design-mode-2026-10`,preview:`design`,title:`Design Mode`,description:`Point at any element of your running app and tell the agent what to change.`,releasedAt:`2026-10-17`,hero:{action:`Try it`,task:`Start the app’s dev server so I can review it in Preview.`},needs:`designMode`},{id:`worktree-scripts-2026-10`,preview:`scripts`,action:`Set up scripts`,title:`Worktree scripts`,description:`Install dependencies and copy env files into every new task worktree.`,releasedAt:`2026-10-17`,to:`/settings/worktrees`},{id:`workflow-editor-2026-10`,preview:`workflow`,action:`Open Workflows`,title:`Workflow editor`,description:`Build a workflow as a graph of steps and run it on a task.`,releasedAt:`2026-10-08`,to:`/workflows`},{id:`automations-2026-09`,preview:`automations`,action:`Open Automations`,title:`Automations`,description:`Start tasks on a schedule or from GitHub events, written as a prompt.`,releasedAt:`2026-09-15`,to:`/automations`,needs:`automations`}];function Ev(e,t){return e.needs===`designMode`?t.designMode===!0:e.needs!==`automations`||t.automations===!0}function Dv(e){let t=new Set(e.dismissed??[]),n=Tv.find(n=>n.hero&&!t.has(n.id)&&Ev(n,e));return n?.hero?{...n,hero:n.hero}:null}var Ov=864e5,kv=3,Av=36e5,jv=60;function Mv(e){if(!e)return null;let t=new Date(e).getTime();return Number.isNaN(t)?null:t}function Nv(e,t){let n=new Date(t).toISOString(),r=Mv(e?.lastVisitAt);return r===null?{firstVisitAt:e?.firstVisitAt??n,lastVisitAt:n}:t-r<Av?null:t-r<14*Ov?{lastVisitAt:n}:{lastVisitAt:n,returnedFrom:e?.lastVisitAt,returnedAt:n}}function Pv(e,t){let n=Mv(e?.returnedAt),r=e?.returnedFrom;if(n===null||Mv(r)===null||!r||t-n>kv*Ov)return null;let i=Mv(e?.welcomeBackClosedAt);return i!==null&&i>=n?null:r}function Fv(e,t){let n=Mv(e)??1/0;return Tv.filter(e=>(Mv(e.releasedAt)??0)>n&&Ev(e,t))}function Iv(e,t,n){let r=Mv(e?.firstVisitAt),i=new Map;if(r===null)return i;let a=new Set(e?.dismissedAnnouncements??[]);for(let e of Tv){let o=Mv(e.releasedAt);!e.to||o===null||a.has(e.id)||!Ev(e,t)||o<=r||n-o>jv*Ov||i.has(e.to)||i.set(e.to,e.id)}return i}function Lv(e,t){return e!==`/`&&(t===e||t.startsWith(`${e}/`))}function Rv(e){let t=e=>Mv(e.finishedAt)??Mv(e.startedAt)??Mv(e.createdAt)??0;return e.filter(e=>!e.archived&&Zt(e)).sort((e,n)=>t(n)-t(e))}function zv(e,t){let n=e[0],r=n?e.length>1?`${e.length} tasks are waiting for you`:n.status===`review`?`One task is ready for your review`:n.status===`waiting`||xt(n)?`One task is waiting for your answer`:`One task needs a look`:null,i=t===0?null:t===1?`there is a new feature to try`:`there are ${t} new features to try`;return r&&i?`${r}, and ${i}.`:r?`${r}.`:i?`${i.charAt(0).toUpperCase()}${i.slice(1)}.`:null}var Bv=90;function Vv(e,t){return Tv.filter(n=>{let r=Mv(n.releasedAt);return r!==null&&t-r<=Bv*Ov&&Ev(n,e)})}function Hv(e,t,n){let r=Mv(e?.firstVisitAt);if(r===null)return!1;let i=Math.max(r,Mv(e?.whatsNewSeenAt)??0);return Vv(t,n).some(e=>(Mv(e.releasedAt)??0)>i)}function Uv(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`)??``,todo:(t.get(`todo`)??``).trim()}}function Wv(e){let t=new URLSearchParams;e.skill&&t.set(`skill`,e.skill),e.ref&&t.set(`ref`,e.ref),e.todo&&t.set(`todo`,e.todo);let n=t.toString();return n?`/new?${n}`:`/new`}function Gv(e){return`${e.kind===`pr`?`Address GitHub pull request`:`Fix GitHub issue`} #${e.number}: ${e.title}\n\n${e.url}`}function Kv(e,t=[]){let n=Gv(e);return e.body?.trim()&&(n+=`\n\n---\n\n${e.body.trim()}`),t.length&&(n+=qv(t)),n}function qv(e){return`\n\nUse these skills where relevant: ${e.join(`, `)}.`}function Jv(e,t){return e.replace(/\{\{\s*number\s*\}\}/gi,()=>`#${t.number}`).replace(/\{\{\s*title\s*\}\}/gi,()=>t.title).replace(/\{\{\s*url\s*\}\}/gi,()=>t.url)}function Yv(e,t){if(e.includes(t.url))return!0;let n=t.kind===`pr`?String.raw`(?:pull\s+request|pr)`:String.raw`issue`;return new RegExp(String.raw`\b${n}\s*#?\s*${t.number}\b`,`i`).test(e)}function Xv(e,t,n){let r=(n??``).trim();if(!r)return Kv(e,t);let i=Gv(e),a=r.startsWith(i)?i+Jv(r.slice(i.length),e):Jv(r,e),o=Yv(a,e)?a:`${i}\n\n${a}`;return t.length?o+qv(t):o}function Zv(e){let t=[];for(let n of e.slice(0,8)){let e=new Set(t.map(e=>e.id)),r=n;for(let t=2;e.has(r);t++)r=`${n}-${t}`;t.push({id:r,name:n,skill:n,prompt:`{{task}}`})}return t}function Qv(e,t,n,r,i={}){return t?{...i,workflow:t,task:Xv(e,n,r)}:n.length?{...i,steps:Zv(n),task:Xv(e,[],r)}:{...i,workflow:`quick-task`,task:Xv(e,[],r)}}function $v(e){let t=new Set;for(let n of e)for(let e of n.labels)t.add(e);return[...t].sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()))}function ey(e,t={}){let n=(t.query??``).trim().toLowerCase(),r=t.labels??[],i=n.replace(/^#/,``),a=i!==``&&/^\d+$/.test(i);return e.filter(e=>r.length>0&&!r.every(t=>e.labels.includes(t))?!1:n===``?!0:a?String(e.number).includes(i):`#${e.number} ${e.title} ${e.author} ${e.body??``}`.toLowerCase().includes(n))}function ty(e,t){let n=t===`oldest`?1:-1;return[...e].sort((e,t)=>e.createdAt===t.createdAt?(e.number-t.number)*n:e.createdAt<t.createdAt?-n:n)}function ny(e,t){return e.trim()!==``&&t===0}function ry(e){if(!e||!/^[0-9a-fA-F]{6}$/.test(e))return{borderColor:`var(--border)`,color:`var(--muted-foreground)`};let t=`#${e}`;return{backgroundColor:`${t}22`,borderColor:`${t}66`,color:`color-mix(in srgb, ${t} 50%, var(--foreground))`}}function iy({gitRepo:e}){let t=St(),n=ht().data?.onboarding?.agentCheckSkipped===!0;return t.data===void 0&&!n?null:xv(t.data)===!1&&!n?(0,Q.jsx)(Iy,{}):e===void 0?null:e?(0,Q.jsx)(Cy,{}):(0,Q.jsx)(Uy,{})}function ay({step:e,...t}){return(0,Q.jsx)(cv,{...t,rail:e?(0,Q.jsx)(sy,{current:e}):void 0})}var oy=[{id:`agent`,label:`Agent`},{id:`project`,label:`Project`},{id:`task`,label:`First task`}];function sy({current:e}){let t=oy.findIndex(t=>t.id===e);return(0,Q.jsx)(`ol`,{"data-slot":`step-rail`,className:`flex items-center gap-2 text-label`,children:oy.map((e,n)=>{let r=n<t?`done`:n===t?`current`:`next`;return(0,Q.jsxs)(`li`,{"data-step":e.id,"data-state":r,className:`flex items-center gap-2`,children:[n>0?(0,Q.jsx)(`span`,{className:W(`h-px w-6`,n<=t?`bg-violet/60`:`bg-border`),"aria-hidden":`true`}):null,(0,Q.jsxs)(`span`,{className:W(`inline-flex items-center gap-1.5`,r===`current`?`text-foreground`:r===`done`?`text-muted-foreground`:`text-soft-foreground`),children:[(0,Q.jsx)(`span`,{className:W(`grid size-5 place-items-center rounded-full border font-mono text-micro`,r===`done`&&`border-violet/60 bg-violet/15 text-violet`,r===`current`&&`border-violet text-foreground`,r===`next`&&`border-border text-soft-foreground`),"aria-hidden":`true`,children:r===`done`?(0,Q.jsx)(Rs,{className:`size-3`}):n+1}),e.label,r===`current`?(0,Q.jsx)(`span`,{className:`sr-only`,children:`(current step)`}):null]})]},e.id)})})}var cy=lv,ly=uv;function uy({children:e}){return(0,Q.jsx)(`ol`,{className:`flex list-decimal flex-col gap-2.5 pl-5 text-ui text-muted-foreground marker:text-soft-foreground`,children:e})}var dy=`https://cli.github.com`;function fy(e,t){let n=l(t),r=n.start.mutate;return Z.useEffect(()=>{e&&r()},[e,r]),n}function py(e){let t=e.state;return e.start.error?my(e.start.error)?`The GitHub CLI is not installed.`:`Sign-in did not finish.`:t?.status===`pending`?`Enter this code on GitHub. It opened in your browser.`:t?.status===`failed`?`Sign-in did not finish.`:t?.status===`done`?`Signed in.`:`Signing in through your browser.`}function my(e){return e instanceof cn&&e.status===503}function hy(e,t){let n=navigator.clipboard?.writeText(e);if(!n){Y(t);return}n.then(()=>Y(`Copied`),()=>Y(t))}function gy({children:e}){return(0,Q.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-ui text-muted-foreground`,children:[(0,Q.jsx)(_c,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}),e]})}function _y({signIn:e}){let t=e.state;return e.start.error?my(e.start.error)?(0,Q.jsxs)(uy,{children:[(0,Q.jsx)(`li`,{children:(0,Q.jsx)(`a`,{href:dy,target:`_blank`,rel:`noopener noreferrer`,className:`text-violet hover:underline`,children:`Install the GitHub CLI`})}),(0,Q.jsx)(`li`,{children:`Come back and press Try again.`})]}):(0,Q.jsx)(`p`,{role:`alert`,className:`text-ui whitespace-pre-line text-danger`,children:e.start.error.message}):t?.status===`failed`?(0,Q.jsx)(`p`,{role:`alert`,className:`text-ui whitespace-pre-line text-danger`,children:t.error}):t?.status===`done`?(0,Q.jsx)(gy,{children:t.login?`Signed in as ${t.login}.`:`Signed in.`}):t?.status===`pending`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border bg-background py-3 pr-2 pl-5`,children:[(0,Q.jsx)(`span`,{"data-testid":`github-login-code`,"aria-label":`One-time code`,className:`font-mono text-2xl tracking-widest text-foreground select-all`,children:t.code}),(0,Q.jsx)(J,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,"aria-label":`Copy code`,onClick:()=>hy(t.code,`Select the code and copy it`),children:(0,Q.jsx)(nc,{"aria-hidden":`true`})})]}),(0,Q.jsx)(gy,{children:`Waiting for GitHub…`})]}):(0,Q.jsx)(gy,{children:`Starting…`})}function vy({signIn:e,onClose:t}){let n=e.state;return e.start.error!==null||n?.status===`failed`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{variant:`outline`,className:`font-normal`,onClick:t,children:`Close`}),(0,Q.jsx)(J,{className:`font-normal`,onClick:()=>e.start.mutate(),disabled:e.start.isPending,children:`Try again`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{variant:`outline`,className:`font-normal`,onClick:()=>{n?.status!==`done`&&e.cancel.mutate(),t()},children:n?.status===`done`?`Close`:`Cancel`}),n?.status===`pending`?(0,Q.jsx)(J,{asChild:!0,className:`font-normal`,children:(0,Q.jsx)(`a`,{href:n.url,target:`_blank`,rel:`noopener noreferrer`,children:`Open GitHub`})}):null]})}function yy({command:e}){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-border bg-background px-3 py-2.5`,children:[(0,Q.jsxs)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-ui text-foreground select-all`,children:[(0,Q.jsx)(`span`,{className:`text-soft-foreground select-none`,children:`$ `}),e]}),(0,Q.jsx)(J,{variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,"aria-label":`Copy ${e}`,onClick:()=>hy(e,`Select the command and copy it`),children:(0,Q.jsx)(nc,{"aria-hidden":`true`})})]})}var by=`flex h-14 w-full items-center gap-3 rounded-xl border border-border bg-card px-5 transition-colors focus-within:border-primary focus-within:shadow-[0_0_0_4px_color-mix(in_srgb,var(--violet)_14%,transparent)]`,xy=[{icon:Dl,label:`Fix a failing test`,task:`Find a failing or flaky test and fix it.`},{icon:fc,label:`Summarize recent commits`,task:`Summarize the recent commits on this branch.`},{icon:_o,label:`Update the README`,task:`Update the README for the recent changes.`}],Sy=[{icon:_o,label:`Write a README`,task:`Write a README that explains what this project is for and how to run it.`},{icon:Dl,label:`Set up tests`,task:`Set up a test runner with one passing example test.`},{icon:fc,label:`Add a CI workflow`,task:`Add a CI workflow that installs dependencies and runs the tests on every push.`}];function Cy(){let e=vr(),t=C(),n=ln(),r=t.data?.forge,i=x({limit:3},r?.kind===`github`&&r.available!==!1),a=i.data?.available?i.data.issues.filter(e=>e.kind===`issue`).slice(0,3):[],[o,s]=Z.useState(``),c=t=>e(Wv({ref:t.trim()})),l=n.data?.info!==void 0&&n.data.info!==null&&n.data.log.length<=1&&a.length===0&&!i.isFetching,u=l?Sy:xy;return(0,Q.jsxs)(ay,{title:`What should we build?`,slot:`welcome`,banner:(0,Q.jsx)(wy,{}),children:[(0,Q.jsxs)(`form`,{className:W(by,`mt-7`),onSubmit:e=>{e.preventDefault(),c(o)},children:[(0,Q.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`Describe a task for the agent…`,"aria-label":`Describe a task for the agent`,className:`h-full min-w-0 flex-1 bg-transparent text-lead text-foreground outline-none placeholder:text-soft-foreground`}),(0,Q.jsx)(J,{type:`submit`,size:`icon`,variant:`ghost`,"aria-label":`Continue to the composer`,className:`size-9 shrink-0`,children:(0,Q.jsx)(co,{"aria-hidden":`true`})})]}),(0,Q.jsx)(`div`,{className:`mt-3 flex flex-wrap justify-center gap-2`,children:u.map(({icon:e,label:t,task:n})=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>c(n),className:`inline-flex h-8 items-center gap-2 rounded-full px-3 text-ui text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,Q.jsx)(e,{className:`size-3.5`,"aria-hidden":`true`}),t]},t))}),(0,Q.jsx)(Ay,{}),(0,Q.jsx)(jy,{fresh:l,issues:a,colors:i.data?.labelColors??{}})]})}function wy(){let e=C(),t=ht(),n=sv(),r=vr(),i=t.data?.onboarding?.dismissedAnnouncements,a=t.data?Dv({dismissed:i,designMode:e.data?.capabilities.designMode}):null;if(!a)return null;let o=()=>n({dismissedAnnouncements:[...i??[],a.id]});return(0,Q.jsxs)(`div`,{"data-slot":`announcement`,className:`onboarding-announcement relative mb-14 flex w-full items-stretch overflow-hidden rounded-xl border text-left`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col justify-center p-6`,children:[(0,Q.jsx)(`span`,{className:`eyebrow text-violet`,children:`New`}),(0,Q.jsx)(`span`,{className:`mt-1 text-2xl font-light tracking-tight text-foreground`,children:a.title}),(0,Q.jsx)(`p`,{className:`mt-2 max-w-sm text-ui text-muted-foreground`,children:a.description}),(0,Q.jsxs)(J,{size:`sm`,className:`mt-5 self-start font-normal`,onClick:()=>{o(),r(Wv({ref:a.hero.task}))},children:[a.hero.action,(0,Q.jsx)(co,{"aria-hidden":`true`})]})]}),(0,Q.jsx)(Ty,{}),(0,Q.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`Close ${a.title} announcement`,className:`absolute top-3 right-3 grid size-7 place-items-center rounded-full text-soft-foreground hover:text-foreground`,children:(0,Q.jsx)(Tc,{className:`size-3.5`,"aria-hidden":`true`})})]})}function Ty(){return(0,Q.jsx)(`div`,{className:`onboarding-picture hidden w-64 shrink-0 items-end justify-center pt-6 pr-6 sm:flex`,"aria-hidden":`true`,children:(0,Q.jsxs)(`div`,{className:`w-full rounded-t-lg border border-b-0 border-border bg-background p-3 shadow-[0_-12px_40px_-20px_var(--violet)]`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`})]}),(0,Q.jsx)(`div`,{className:`mt-3 h-2 w-2/3 rounded bg-muted`}),(0,Q.jsx)(`div`,{className:`mt-2 h-2 w-1/2 rounded bg-muted`}),(0,Q.jsxs)(`div`,{className:`relative mt-4 flex items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`relative h-6 w-16 rounded-md border border-violet bg-violet/15 outline-2 outline-offset-2 outline-violet/40`,children:[(0,Q.jsx)(`span`,{className:`absolute -top-1 -left-1 size-1.5 rounded-[2px] bg-violet`}),(0,Q.jsx)(`span`,{className:`absolute -top-1 -right-1 size-1.5 rounded-[2px] bg-violet`}),(0,Q.jsx)(`span`,{className:`absolute -bottom-1 -left-1 size-1.5 rounded-[2px] bg-violet`}),(0,Q.jsx)(`span`,{className:`absolute -right-1 -bottom-1 size-1.5 rounded-[2px] bg-violet`})]}),(0,Q.jsx)(`span`,{className:`h-6 w-10 rounded-md bg-muted`}),(0,Q.jsx)(`span`,{className:`absolute top-7 left-6 rounded-md rounded-tl-sm border border-border bg-card px-2 py-1 text-micro whitespace-nowrap text-foreground shadow-md`,children:`Make this button larger`})]}),(0,Q.jsx)(`div`,{className:`mt-9 h-2 w-3/4 rounded bg-muted`})]})})}function Ey(){let e=En(),t=C(),n=ln(),r=ht(),i=sv(),a=e.data?.worktreeLifecycle,o=Sv({worktreeSetupConfigured:e.data?(a?.afterCreate.length??0)>0:void 0,forge:t.data?.forge}),s=n.data?.info,c=s!=null&&!s.remote&&t.data?.capabilities.singleProject!==!0,l=r.data?.onboarding?.setupDismissed===!0,u=Z.useCallback(()=>i({setupDismissed:!0}),[i]);return{steps:o,unpublished:c,folder:s?qy(s.root):``,dismissed:l||!r.data,dismiss:u}}var Dy={worktrees:Yl,github:Cf},Oy=30,ky=6;function Ay(){let e=P(),t=Z.useMemo(()=>{let t=new Date;t.setHours(0,0,0,0);let n=Array.from({length:Oy},(e,n)=>{let r=new Date(t);return r.setDate(t.getDate()-(Oy-1-n)),{date:r,count:0}}),r=n[0]?.date.getTime()??0;for(let t of e.data??[]){let e=new Date(t.createdAt);e.setHours(0,0,0,0);let i=n[Math.round((e.getTime()-r)/864e5)];i&&(i.count+=1)}return n},[e.data]),n=t.reduce((e,t)=>e+t.count,0);if(n===0)return null;let r=Math.max(1,...t.map(e=>e.count)),i=e=>e===0?0:Math.max(1,Math.round(e/r*Math.min(r,ky))),a=e=>e.toLocaleDateString(void 0,{month:`short`,day:`numeric`});return(0,Q.jsxs)(`div`,{"data-slot":`activity-strip`,className:`mt-12 w-full`,children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex items-baseline justify-between text-ui`,children:[(0,Q.jsx)(`span`,{className:`text-soft-foreground`,children:`Activity`}),(0,Q.jsxs)(`span`,{className:`text-soft-foreground`,children:[n,` `,n===1?`task`:`tasks`,` in the last `,Oy,` days`]})]}),(0,Q.jsx)(kc,{delayDuration:100,children:(0,Q.jsx)(`div`,{className:`flex items-end justify-between`,role:`img`,"aria-label":`${n} tasks in the last ${Oy} days`,children:t.map(e=>(0,Q.jsxs)(Ac,{children:[(0,Q.jsx)(Dc,{asChild:!0,children:(0,Q.jsx)(`span`,{className:`flex flex-col-reverse gap-1 py-1`,children:Array.from({length:Math.max(1,i(e.count))},(t,n)=>(0,Q.jsx)(`span`,{className:W(`size-2.5 rounded-[3px]`,e.count>0?`bg-violet`:`bg-muted`)},n))})}),(0,Q.jsx)(Oc,{children:`${a(e.date)}: ${e.count} ${e.count===1?`task`:`tasks`}`})]},e.date.toISOString()))})}),(0,Q.jsx)(`div`,{className:`mt-2 flex justify-between font-mono text-micro text-soft-foreground`,children:t.filter((e,t)=>t%7==1||t===Oy-1).map(e=>(0,Q.jsx)(`span`,{children:a(e.date)},e.date.toISOString()))})]})}function jy({fresh:e,issues:t,colors:n}){let r=ln(),i=r.data?.info&&!e?r.data.log.slice(0,3):[],a=Ny(ie(t.length===0&&i.length===0).data??[]);return t.length>0?(0,Q.jsx)(My,{label:`Or pick up an issue`,slot:`issues`,children:(0,Q.jsx)(`ul`,{className:`w-full divide-y divide-border rounded-xl border border-border bg-card p-1.5 text-left`,children:t.map(e=>(0,Q.jsx)(`li`,{className:`first:[&>a]:rounded-t-lg last:[&>a]:rounded-b-lg`,children:(0,Q.jsxs)(K,{to:Wv({ref:Gv(e)}),className:`group flex flex-col gap-1.5 px-3 py-2.5 transition-colors hover:bg-muted`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-body text-foreground`,children:e.title}),(0,Q.jsx)(co,{className:`ml-auto size-3.5 shrink-0 text-soft-foreground opacity-0 transition-opacity group-hover:opacity-100`,"aria-hidden":`true`})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-meta text-soft-foreground`,children:[(0,Q.jsxs)(`span`,{className:`font-mono`,children:[`#`,e.number]}),(0,Q.jsx)(`span`,{children:e.author}),(0,Q.jsxs)(`span`,{children:[Xc(e.createdAt),` ago`]}),e.comments>0?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(vc,{className:`size-3`,"aria-hidden":`true`}),e.comments]}):null,e.labels.map(e=>(0,Q.jsx)(`span`,{style:ry(n[e]),className:`rounded-full border px-1.5 py-px text-micro`,children:e},e))]})]})},e.number))})}):i.length>0?(0,Q.jsx)(My,{label:`Or continue recent work`,slot:`commits`,children:(0,Q.jsx)(`ul`,{className:`w-full divide-y divide-border rounded-xl border border-border bg-card p-1.5 text-left`,children:i.map(e=>(0,Q.jsx)(`li`,{className:`first:[&>a]:rounded-t-lg last:[&>a]:rounded-b-lg`,children:(0,Q.jsxs)(K,{to:Wv({ref:`Continue the work from commit ${e.hash} (${e.subject}).`}),className:`group flex flex-col gap-1 px-3 py-2.5 transition-colors hover:bg-muted`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-body text-foreground`,children:e.subject}),(0,Q.jsx)(co,{className:`ml-auto size-3.5 shrink-0 text-soft-foreground opacity-0 transition-opacity group-hover:opacity-100`,"aria-hidden":`true`})]}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 text-meta text-soft-foreground`,children:[(0,Q.jsx)(`span`,{className:`font-mono`,children:e.hash}),(0,Q.jsx)(`span`,{children:e.author}),(0,Q.jsx)(`span`,{children:e.when})]})]})},e.hash))})}):a.length>0?(0,Q.jsx)(My,{label:`Or start with a skill`,slot:`skills`,children:(0,Q.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:a.map(e=>(0,Q.jsx)(K,{to:Wv({skill:e.name}),className:ly,title:e.description,children:e.name},e.name))})}):null}function My({label:e,slot:t,children:n}){return(0,Q.jsxs)(`div`,{"data-slot":`start-from`,"data-start-from":t,className:`mt-14 flex w-full flex-col items-center gap-3`,children:[(0,Q.jsx)(`div`,{className:`text-ui text-soft-foreground`,children:e}),n]})}function Ny(e){let t=e.filter(e=>e.source!==`global`&&e.source!==`builtin`),n=e.filter(e=>e.source===`global`);return[...t,...n].slice(0,4)}function Py({folder:e,onOpenChange:t}){let{projectId:n}=at(),r=Rt(),i=Sn(),a=r.data?.available===!0?r.data.owners:null,[o,s]=Z.useState(null),[c,l]=Z.useState(()=>Jy(e)),u=o??a?.[0]?.login??``,d=()=>{i.isPending||!u||!c.trim()||i.mutate({projectId:n??`default`,owner:u,name:c.trim()},{onSuccess:({slug:e})=>{t(!1),Y(`Published to ${e}`)}})},f=a!==null,p=fy(!r.isPending&&!f,()=>void r.refetch()),m=p.state?.status===`done`&&!r.isFetching&&r.data?.available===!1?r.data.reason:null;return(0,Q.jsxs)(pv,{title:`Publish to GitHub`,description:f?`A new private repository. You can make it public on GitHub later.`:m?`Signed in, but GitHub listed no accounts.`:py(p),onOpenChange:t,onSubmit:f?d:void 0,footer:m?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{variant:`outline`,className:`font-normal`,onClick:()=>t(!1),children:`Close`}),(0,Q.jsx)(J,{className:`font-normal`,onClick:()=>void r.refetch(),children:`Check again`})]}):f?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{variant:`outline`,className:`font-normal`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(J,{className:`font-normal`,onClick:d,disabled:i.isPending||!u||!c.trim(),children:i.isPending?`Publishing…`:`Publish`})]}):(0,Q.jsx)(vy,{signIn:p,onClose:()=>t(!1)}),children:[r.isPending?(0,Q.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:`Checking GitHub…`}):m?(0,Q.jsx)(`p`,{role:`alert`,className:`text-ui text-danger`,children:m}):f?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`radiogroup`,"aria-label":`Owner`,children:a.map(e=>(0,Q.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e.login===u,onClick:()=>s(e.login),className:W(`inline-flex h-8 items-center gap-2 rounded-full border px-3 text-ui transition-colors`,e.login===u?`border-primary text-foreground`:`border-border text-muted-foreground hover:text-foreground`),children:e.login},e.login))}),(0,Q.jsxs)(`label`,{className:`flex items-center gap-1 rounded-lg border border-input bg-background px-3 font-mono text-ui focus-within:border-ring`,children:[(0,Q.jsxs)(`span`,{className:`text-soft-foreground`,children:[u,`/`]}),(0,Q.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),"aria-label":`Repository name`,className:`h-9 min-w-0 flex-1 bg-transparent text-foreground outline-none`})]})]}):(0,Q.jsx)(_y,{signIn:p}),i.error?(0,Q.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs whitespace-pre-line text-danger`,children:i.error.message}):null]})}function Fy(){let{steps:e,unpublished:t,folder:n,dismissed:r,dismiss:i}=Ey(),[a,o]=Z.useState(!1),s=e[0];if(r||s===void 0&&!t)return null;let c=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(s?Dy[s.id]:Cf,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),s?s.label:`Publish to GitHub`,(0,Q.jsx)(co,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]}),l=`inline-flex h-7 items-center gap-1.5 rounded-full bg-muted px-3 text-foreground`;return(0,Q.jsxs)(`div`,{"data-onboarding":``,"data-slot":`setup-pill`,className:`mb-3 inline-flex items-center gap-2 self-start rounded-full border border-border bg-card py-1 pr-1 pl-3 text-ui`,children:[(0,Q.jsx)(`span`,{className:`text-soft-foreground`,children:`Setup`}),s?(0,Q.jsx)(K,{to:s.to,className:l,children:c}):(0,Q.jsx)(`button`,{type:`button`,className:l,onClick:()=>o(!0),"data-setup-step":`publish`,children:c}),(0,Q.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`Hide setup`,className:`grid size-7 place-items-center rounded-full text-soft-foreground hover:text-foreground`,children:(0,Q.jsx)(Tc,{className:`size-3.5`,"aria-hidden":`true`})}),a?(0,Q.jsx)(Py,{folder:n,onOpenChange:o}):null]})}function Iy(){let e=Ct();return e.isPending?null:e.data?.available?(0,Q.jsx)(Ly,{setup:e.data}):(0,Q.jsx)(Ry,{})}function Ly({setup:e}){let t=St(),n=rn(),r=sv(),i=K_(e,t.data).length===0;return(0,Q.jsxs)(ay,{title:nv(e,t.data),slot:`sign-in`,step:`agent`,why:`cezar installs the coding agent and signs you in, right here. No API key needed.`,children:[i?(0,Q.jsxs)(`div`,{"data-slot":`agents-off`,className:`mt-7 flex w-full flex-col gap-3 rounded-xl border border-border bg-card p-4 text-left sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-body text-foreground`,children:`All agents are turned off.`}),(0,Q.jsx)(J,{asChild:!0,size:`sm`,className:`font-normal`,children:(0,Q.jsx)(K,{to:`/settings/agents#providers`,children:`Turn one on`})})]}):(0,Q.jsx)(rv,{setup:e,status:t.data}),(0,Q.jsxs)(`div`,{className:`mt-7 flex flex-wrap justify-center gap-5`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>n.mutate(),disabled:n.isPending,className:cy,children:n.isPending?`Checking…`:`Check again`}),(0,Q.jsx)(K,{to:`/settings/agents`,className:cy,children:`Other agents`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>r({agentCheckSkipped:!0}),className:cy,children:`Continue anyway`})]})]})}function Ry(){let e=St(),t=rn(),n=zn(),r=sv(),i=wv(e.data),[a,o]=Z.useState(null),[s,c]=Z.useState(null),l=t.mutate;Z.useEffect(()=>{let e=window.setInterval(()=>l(),By);return()=>window.clearInterval(e)},[l]),Z.useEffect(()=>{if(!a)return;let e=0,t=window.setInterval(()=>{if(e+=1,e>Vy){window.clearInterval(t),o(null);return}l()},zy);return()=>window.clearInterval(t)},[a,l]);let u=e=>{c(null),n.mutate({provider:e},{onSuccess:t=>{t.opened?o(e):l()},onError:t=>c({provider:e,message:t.message})})};return(0,Q.jsxs)(ay,{title:`Sign in to an agent`,slot:`sign-in`,step:`agent`,why:`cezar runs the coding agent you already use. No API key needed.`,children:[(0,Q.jsxs)(`div`,{className:`mt-7 flex w-full flex-col gap-3 text-left`,children:[i.length===0?(0,Q.jsxs)(`div`,{"data-slot":`agents-off`,className:`flex flex-col gap-3 rounded-xl border border-border bg-card p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-body text-foreground`,children:`All agents are turned off.`}),(0,Q.jsx)(J,{asChild:!0,size:`sm`,className:`font-normal`,children:(0,Q.jsx)(K,{to:`/settings/agents#providers`,children:`Turn one on`})})]}):null,i.map(e=>{let t=a===e.provider,r=s?.provider===e.provider?s.message:null;return(0,Q.jsxs)(`div`,{"data-slot":`agent-row`,"data-state":e.state,className:`rounded-xl border border-border bg-card p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`text-lead text-foreground`,children:e.label}),(0,Q.jsx)(`div`,{className:`text-ui text-muted-foreground`,children:t?`Finish in Terminal`:e.state===`missing`?`Not installed`:`Installed, not signed in`})]}),e.state===`signed-out`?t?(0,Q.jsx)(_c,{className:`size-4 shrink-0 text-violet motion-safe:animate-spin`,"aria-label":`Waiting for sign-in`}):(0,Q.jsx)(J,{className:`font-normal`,onClick:()=>u(e.provider),disabled:n.isPending,children:`Sign in`}):null]}),e.state===`signed-out`&&!t&&!r?(0,Q.jsx)(`p`,{className:`mt-3 text-ui text-soft-foreground`,children:`Opens the login in Terminal.`}):null,t?(0,Q.jsx)(`p`,{className:`mt-3 text-ui text-soft-foreground`,children:`This page continues by itself.`}):null,r?(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-3`,children:[(0,Q.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:r}),(0,Q.jsxs)(uy,{children:[(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`span`,{className:`text-foreground`,children:`Open Terminal and paste:`}),(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(yy,{command:e.command})})]}),(0,Q.jsx)(`li`,{children:`Come back. cezar checks by itself.`})]})]}):null,e.state===`missing`?(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-3`,children:[(0,Q.jsxs)(uy,{children:[(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`span`,{className:`text-foreground`,children:`Open Terminal and paste:`}),(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(yy,{command:e.command})})]}),(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`span`,{className:`text-foreground`,children:`Then sign in:`}),(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(yy,{command:e.login})})]}),(0,Q.jsx)(`li`,{children:`Come back. cezar checks by itself.`})]}),(0,Q.jsxs)(`p`,{className:`text-label text-soft-foreground`,children:[`Needs Node.js.`,` `,(0,Q.jsx)(`a`,{href:`https://nodejs.org`,target:`_blank`,rel:`noopener noreferrer`,className:`text-violet hover:underline`,children:`Get it`})]})]}):null]},e.provider)})]}),(0,Q.jsxs)(`div`,{className:`mt-7 flex flex-wrap justify-center gap-5`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>l(),disabled:t.isPending,className:cy,children:t.isPending?`Checking…`:`Check again`}),(0,Q.jsx)(K,{to:`/settings/agents`,className:cy,children:`Other agents`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>r({agentCheckSkipped:!0}),className:cy,children:`Continue anyway`})]})]})}var zy=3e3,By=1e4,Vy=60;function Hy(){let{projectId:e}=at(),t=a(),n=C(),r=e??t.data?.bootProject,i=t.data?.projects.find(e=>e.id===r);return i?i.root:e===null||e===n.data?.bootProject?n.data?.repoRoot:void 0}function Uy(){let e=C().data?.capabilities.singleProject===!0,t=Hy(),n=t?qy(t):`This folder`,[r,i]=Z.useState(!1);return(0,Q.jsxs)(ay,{title:`Pick a project`,slot:`pick-project`,step:`project`,why:`Tasks run inside a git repository, each in its own worktree.`,subtitle:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`font-mono`,children:n}),` isn’t a git repository.`,e?null:(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(`button`,{type:`button`,onClick:()=>i(!0),className:`text-violet hover:underline`,children:`Initialize git here`})]})]}),children:[e?null:(0,Q.jsx)(Wy,{}),r?(0,Q.jsx)(Ky,{folder:n,onOpenChange:i}):null]})}function Wy(){let e=nt(),t=Rt(),n=Wt(),r=Nr(),[i,a]=Z.useState(``),[o,s]=Z.useState(0),[c,l]=Z.useState(null),u=(e.data?.repos??[]).filter(e=>e.name.toLowerCase().includes(i.trim().toLowerCase())).slice(0,6),d=t.data!==void 0&&!t.data.available,f=!e.isPending&&(e.data?.repos.length??0)===0,p=e=>{if(e.projectId){r(`/p/${encodeURIComponent(e.projectId)}/`);return}n.mutate(e.path,{onSuccess:({project:e})=>r(`/p/${encodeURIComponent(e.id)}/`),onError:e=>Y(e.message,{tone:`danger`})})},m=e=>{l(e),cs(e)};return(0,Q.jsxs)(Q.Fragment,{children:[f?(0,Q.jsxs)(`div`,{"data-slot":`no-repos`,className:`mt-8 grid w-full gap-3 sm:grid-cols-3`,children:[(0,Q.jsx)(hv,{title:`New project`,description:`An empty repository here, or a new private one on GitHub.`,recommended:d,onClick:()=>m(`new`),picture:(0,Q.jsx)(`span`,{className:`grid size-12 place-items-center rounded-lg border border-dashed border-muted-foreground/60`,children:(0,Q.jsxs)(`span`,{className:`relative size-4`,children:[(0,Q.jsx)(`span`,{className:`absolute top-1/2 left-0 h-0.5 w-full -translate-y-1/2 rounded bg-muted-foreground`}),(0,Q.jsx)(`span`,{className:`absolute top-0 left-1/2 h-full w-0.5 -translate-x-1/2 rounded bg-muted-foreground`})]})})}),d?(0,Q.jsx)(hv,{title:`Connect GitHub`,description:`Sign in to the GitHub CLI to clone and publish.`,onClick:()=>l(`connect`),picture:(0,Q.jsx)(Cf,{className:`size-9 text-muted-foreground`,"aria-hidden":!0})}):(0,Q.jsx)(hv,{title:`Clone from GitHub`,description:`Any repository you can read, by URL or owner/name.`,recommended:!0,onClick:()=>m(`clone`),picture:(0,Q.jsxs)(`span`,{className:`flex w-16 flex-col gap-1.5`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-md border border-violet bg-violet/15 px-1.5 py-1`,children:[(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-violet`}),(0,Q.jsx)(`span`,{className:`h-1 flex-1 rounded bg-violet/60`})]}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-md border border-border px-1.5 py-1`,children:[(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/50`}),(0,Q.jsx)(`span`,{className:`h-1 w-3/4 rounded bg-muted`})]}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-md border border-border px-1.5 py-1`,children:[(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/50`}),(0,Q.jsx)(`span`,{className:`h-1 w-1/2 rounded bg-muted`})]})]})}),(0,Q.jsx)(hv,{title:`Open a folder`,description:`A repository that already lives on this disk.`,onClick:()=>m(`folder`),picture:(0,Q.jsxs)(`span`,{className:`flex w-16 flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`h-2 w-10 rounded-sm bg-muted-foreground/70`}),(0,Q.jsx)(`span`,{className:`ml-3 h-1.5 w-9 rounded bg-muted`}),(0,Q.jsx)(`span`,{className:`ml-3 h-1.5 w-7 rounded bg-muted`}),(0,Q.jsx)(`span`,{className:`ml-3 h-1.5 w-8 rounded bg-muted`})]})})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mt-7 w-full rounded-xl border border-border bg-card p-1.5 text-left`,children:[(0,Q.jsxs)(`label`,{className:`flex h-11 items-center gap-2 rounded-lg border border-input bg-background px-3 focus-within:border-ring`,children:[(0,Q.jsx)(Cc,{className:`size-4 text-soft-foreground`,"aria-hidden":`true`}),(0,Q.jsx)(`input`,{value:i,onChange:e=>{a(e.target.value),s(0)},onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),s(e=>Math.min(e+1,u.length-1));else if(e.key===`ArrowUp`)e.preventDefault(),s(e=>Math.max(e-1,0));else if(e.key===`Enter`){let e=u[o];e&&p(e)}},placeholder:`Search repositories`,"aria-label":`Search repositories`,className:`min-w-0 flex-1 bg-transparent text-lead text-foreground outline-none placeholder:text-soft-foreground`})]}),(0,Q.jsx)(`ul`,{role:`listbox`,"aria-label":`Repositories`,className:`mt-1`,children:e.isPending?(0,Q.jsx)(`li`,{className:`px-3 py-2.5 text-ui text-soft-foreground`,children:`Looking for repositories…`}):u.length===0?(0,Q.jsx)(`li`,{className:`px-3 py-2.5 text-ui text-soft-foreground`,children:`No repositories found`}):u.map((e,t)=>(0,Q.jsx)(`li`,{role:`option`,"aria-selected":t===o,children:(0,Q.jsxs)(`button`,{type:`button`,onMouseEnter:()=>s(t),onClick:()=>p(e),disabled:n.isPending,className:W(`flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left`,t===o&&`bg-muted`),children:[(0,Q.jsx)(`span`,{className:`truncate text-lead text-foreground`,children:e.name}),(0,Q.jsx)(`span`,{className:`ml-auto truncate font-mono text-meta text-soft-foreground`,children:Yy(e.path)})]})},e.path))})]}),(0,Q.jsxs)(`div`,{className:`mt-5 flex flex-wrap justify-center gap-6`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:cy,onClick:()=>m(`new`),children:[(0,Q.jsx)(xc,{className:`size-3.5`,"aria-hidden":`true`}),`New project`]}),d?(0,Q.jsxs)(`button`,{type:`button`,className:cy,onClick:()=>l(`connect`),"data-slot":`connect-github`,children:[(0,Q.jsx)(Cf,{className:`size-3.5`,"aria-hidden":!0}),`Connect GitHub`]}):(0,Q.jsxs)(`button`,{type:`button`,className:cy,onClick:()=>m(`clone`),children:[(0,Q.jsx)(Cf,{className:`size-3.5`,"aria-hidden":!0}),`Clone from GitHub`]}),(0,Q.jsxs)(`button`,{type:`button`,className:cy,onClick:()=>m(`folder`),children:[(0,Q.jsx)(dc,{className:`size-3.5`,"aria-hidden":`true`}),`Browse…`]})]})]}),c===`new`?(0,Q.jsx)(Sf,{label:`New project`,onError:()=>l(null),children:(0,Q.jsx)(_f,{open:!0,onOpenChange:e=>!e&&l(null)})}):null,c===`clone`?(0,Q.jsx)(Sf,{label:`Clone from GitHub`,onError:()=>l(null),children:(0,Q.jsx)(df,{open:!0,onOpenChange:e=>!e&&l(null)})}):null,c===`folder`?(0,Q.jsx)(Sf,{label:`Open local folder`,onError:()=>l(null),children:(0,Q.jsx)(cf,{open:!0,onOpenChange:e=>!e&&l(null)})}):null,c===`connect`?(0,Q.jsx)(Gy,{onOpenChange:e=>!e&&l(null)}):null]})}function Gy({onOpenChange:e}){let t=Z.useCallback(()=>e(!1),[e]),n=fy(!0,e=>{Y(e?`GitHub connected as ${e}`:`GitHub connected`),t()});return(0,Q.jsx)(pv,{title:`Connect GitHub`,description:py(n),onOpenChange:e,footer:(0,Q.jsx)(vy,{signIn:n,onClose:t}),children:(0,Q.jsx)(_y,{signIn:n})})}function Ky({folder:e,onOpenChange:t}){let{projectId:n}=at(),r=Un(),i=()=>{r.isPending||r.mutate(n??`default`,{onSuccess:()=>{t(!1),Y(`Initialized git in ${e}`)}})};return(0,Q.jsxs)(pv,{title:`Initialize git in ${e}`,description:`Git keeps a history of your files. cezar runs this for you and uploads nothing. node_modules and .env files stay out.`,onOpenChange:t,onSubmit:i,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{variant:`outline`,onClick:()=>t(!1),className:`font-normal`,children:`Cancel`}),(0,Q.jsx)(J,{onClick:i,disabled:r.isPending,className:`font-normal`,children:r.isPending?`Initializing…`:`Initialize`})]}),children:[(0,Q.jsx)(`pre`,{className:`rounded-lg border border-border bg-background px-3 py-2.5 font-mono text-xs leading-relaxed text-foreground`,children:`$ git init -b main
|
|
5
5
|
$ git add -A
|
|
6
6
|
$ git commit -m "Initial commit"`}),r.error?(0,Q.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs whitespace-pre-line text-danger`,children:r.error.message}):null]})}function qy(e){return e.split(/[\\/]/).filter(Boolean).pop()??e}function Jy(e){return e.trim().replace(/\s+/g,`-`).replace(/[^A-Za-z0-9._-]/g,``).slice(0,100)||`project`}function Yy(e){let t=e.split(`/`);return t.pop(),t.join(`/`).replace(/^\/Users\/[^/]+|^\/home\/[^/]+/,`~`)}function Xy(e){let t=ht(),n=C(),r=sv(),i=t.data?.onboarding,a=t.data!==void 0,o=Z.useRef(!1);Z.useEffect(()=>{if(!a||o.current)return;o.current=!0;let e=Nv(i,Date.now());e&&r(e)},[a,i,r]);let s=n.data?.capabilities.designMode,c=n.data?.capabilities.automations,l=Z.useMemo(()=>a?Iv(i,{designMode:s,automations:c},Date.now()):new Map,[a,i,s,c]);return Z.useEffect(()=>{let t=[...l].filter(([t])=>e===t||e.startsWith(`${t}/`)).map(([,e])=>e);t.length>0&&r({dismissedAnnouncements:[...i?.dismissedAnnouncements??[],...t].slice(-50)})},[e,l,i,r]),Z.useMemo(()=>new Set(wf.filter(e=>[...l.keys()].some(t=>Lv(e.to,t))).map(e=>e.to)),[l])}function Zy({runs:e}){let t=ht(),n=C(),r=sv(),[i]=Z.useState(()=>Date.now()),[a,o]=Z.useState(!1),s=Pv(t.data?.onboarding,i);if(!s)return null;let c=Rv(e),l=Fv(s,{designMode:n.data?.capabilities.designMode,automations:n.data?.capabilities.automations}),u=new Date(s).toLocaleString(`en`,{month:`long`}),d=c[0],f=zv(c,l.length);return f?(0,Q.jsxs)(`section`,{"data-onboarding":``,"data-slot":`welcome-back`,"aria-label":`Welcome back`,className:`onboarding-announcement relative mb-4 flex flex-col gap-4 rounded-xl border py-5 pr-14 pl-6 sm:flex-row sm:items-center sm:gap-8 sm:pr-20`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 sm:flex-1`,children:[(0,Q.jsx)(`h2`,{className:`text-xl font-light tracking-tight text-foreground`,children:`Welcome back`}),(0,Q.jsx)(`p`,{className:`mt-1 text-body text-muted-foreground`,children:f})]}),(0,Q.jsxs)(`div`,{className:`grid shrink-0 auto-cols-fr grid-flow-col gap-2`,children:[d?(0,Q.jsx)(J,{asChild:!0,size:`sm`,className:`w-full font-normal`,children:(0,Q.jsx)(K,{to:`/tasks/${d.id}`,"data-slot":`welcome-back-waiting`,children:c.length>1?`Open tasks`:d.status===`review`?`Review task`:`Open task`})}):null,l.length>0?(0,Q.jsx)(J,{variant:`outline`,size:`sm`,className:`w-full font-normal`,"data-slot":`welcome-back-news`,onClick:()=>{o(!0),r({whatsNewSeenAt:new Date().toISOString()})},children:`See what’s new`}):null]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>r({welcomeBackClosedAt:new Date().toISOString()}),"aria-label":`Close welcome back`,className:`absolute top-3 right-3 grid size-8 place-items-center rounded-full text-soft-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,Q.jsx)(Tc,{className:`size-4`,"aria-hidden":`true`})}),a?(0,Q.jsx)($y,{items:l,description:`${l.length} ${l.length===1?`change`:`changes`} since ${u}.`,onOpenChange:o}):null]}):null}function Qy(){let e=ht(),t=C(),n=sv(),[r,i]=Z.useState(!1),[a]=Z.useState(()=>Date.now()),o={designMode:t.data?.capabilities.designMode,automations:t.data?.capabilities.automations},s=Vv(o,a);if(!e.data||s.length===0)return null;let c=Hv(e.data.onboarding,o,a);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`whats-new`,onClick:()=>{i(!0),n({whatsNewSeenAt:new Date().toISOString()})},className:`flex h-8 w-full items-center gap-2.5 rounded-md px-2.5 text-ui text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,Q.jsx)(Pl,{className:`size-4 shrink-0`,"aria-hidden":`true`}),`What’s new`,c?(0,Q.jsxs)(`span`,{className:`ml-auto flex items-center`,children:[(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-violet`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Unread`})]}):null]}),r?(0,Q.jsx)($y,{items:s,description:`Recent changes in cezar.`,onOpenChange:i}):null]})}function $y({items:e,description:t,onOpenChange:n}){let r=vr(),[i,a]=Z.useState(0),o=e[Math.min(i,e.length-1)];if(!o)return null;let s=i>=e.length-1,c=()=>s?n(!1):a(i+1),l=o.to?o.action:o.hero?.action;return(0,Q.jsx)(pv,{wide:!0,title:`What’s new`,description:t,onOpenChange:n,onSubmit:c,footer:(0,Q.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`mr-auto flex items-center gap-1.5`,"aria-label":`${i+1} of ${e.length}`,children:e.map((e,t)=>(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:W(`h-1.5 rounded-full transition-all`,t===i?`w-4 bg-violet`:`w-1.5 bg-border`)},e.id))}),i>0?(0,Q.jsx)(J,{variant:`outline`,className:`font-normal`,onClick:()=>a(i-1),children:`Back`}):null,(0,Q.jsx)(J,{className:`font-normal`,onClick:c,children:s?`Done`:`Next`})]}),children:(0,Q.jsxs)(`div`,{"data-slot":`whats-new-item`,"data-feature":o.preview,onKeyDown:e=>{e.key===`ArrowRight`&&!s&&a(i+1),e.key===`ArrowLeft`&&i>0&&a(i-1)},children:[(0,Q.jsx)(eb,{id:o.preview}),(0,Q.jsxs)(`div`,{className:`mt-5 flex min-h-32 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-label`,children:[(0,Q.jsx)(`span`,{className:`rounded-full bg-violet/15 px-2 py-0.5 text-violet`,children:`New`}),(0,Q.jsx)(`span`,{className:`text-soft-foreground`,children:new Date(o.releasedAt).toLocaleDateString(`en`,{month:`short`,day:`numeric`})})]}),(0,Q.jsx)(`h3`,{className:`mt-2 text-lg font-light tracking-tight text-foreground`,children:o.title}),(0,Q.jsx)(`p`,{className:`mt-1 text-ui text-muted-foreground`,children:o.description}),l?(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{n(!1),o.to?r(o.to):o.hero&&r(Wv({ref:o.hero.task}))},className:`mt-3 inline-flex items-center gap-1 text-ui text-violet hover:underline`,children:[l,(0,Q.jsx)(co,{className:`size-3.5`,"aria-hidden":`true`})]}):null]})]})})}function eb({id:e}){return(0,Q.jsxs)(`div`,{"aria-hidden":`true`,className:`onboarding-preview flex h-44 items-end justify-center overflow-hidden rounded-lg border border-border px-8 pt-6`,children:[e===`tabs`?(0,Q.jsx)(tb,{}):null,e===`palette`?(0,Q.jsx)(nb,{}):null,e===`design`?(0,Q.jsx)(rb,{}):null,e===`scripts`?(0,Q.jsx)(ib,{}):null,e===`workflow`?(0,Q.jsx)(ab,{}):null,e===`automations`?(0,Q.jsx)(ob,{}):null]})}function tb(){return(0,Q.jsxs)(vv,{bar:(0,Q.jsx)(`span`,{className:`ml-3 flex gap-3 text-micro`,children:[`Chat`,`Changes`,`Preview`,`Terminal`].map(e=>(0,Q.jsx)(`span`,{className:e===`Preview`?`text-foreground underline decoration-violet decoration-2 underline-offset-[9px]`:`text-soft-foreground`,children:e},e))}),children:[(0,Q.jsx)(`div`,{className:W(yv,`w-3/4`)}),(0,Q.jsx)(`div`,{className:W(yv,`mt-2 w-1/2`)}),(0,Q.jsx)(`div`,{className:`mt-3 h-12 rounded-md border border-border bg-card`})]})}function nb(){return(0,Q.jsxs)(`div`,{className:`w-full max-w-xs self-center rounded-lg border border-border bg-background p-2 shadow-[0_18px_40px_-20px_var(--violet)]`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-1 pb-2 text-meta text-soft-foreground`,children:[(0,Q.jsx)(`span`,{className:`rounded border border-border px-1 font-mono text-micro text-muted-foreground`,children:`⌘P`}),`Jump to a task or run an action`]}),[`Fix the login redirect`,`Open Changes`,`Terminal in a column`].map((e,t)=>(0,Q.jsx)(`div`,{className:W(`mt-1 rounded px-2 py-1.5 text-meta`,t===0?`bg-violet/15 text-foreground`:`text-muted-foreground`),children:e},e))]})}function rb(){return(0,Q.jsxs)(vv,{children:[(0,Q.jsx)(`div`,{className:W(yv,`w-2/3`)}),(0,Q.jsxs)(`div`,{className:`relative mt-4 flex items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`relative h-6 w-16 rounded-md border border-violet bg-violet/15`,children:[(0,Q.jsx)(`span`,{className:`absolute -top-1 -left-1 size-1.5 rounded-[2px] bg-violet`}),(0,Q.jsx)(`span`,{className:`absolute -top-1 -right-1 size-1.5 rounded-[2px] bg-violet`}),(0,Q.jsx)(`span`,{className:`absolute -bottom-1 -left-1 size-1.5 rounded-[2px] bg-violet`}),(0,Q.jsx)(`span`,{className:`absolute -right-1 -bottom-1 size-1.5 rounded-[2px] bg-violet`})]}),(0,Q.jsx)(`span`,{className:`h-6 w-10 rounded-md bg-muted`}),(0,Q.jsx)(`span`,{className:`absolute top-7 left-6 rounded-md rounded-tl-sm border border-border bg-card px-2 py-1 text-micro whitespace-nowrap text-foreground shadow-md`,children:`Make this button larger`})]}),(0,Q.jsx)(`div`,{className:W(yv,`mt-10 w-3/4`)})]})}function ib(){return(0,Q.jsxs)(vv,{bar:(0,Q.jsx)(`span`,{className:`ml-3 text-micro text-soft-foreground`,children:`After worktree creation`}),children:[[`npm install`,`cp .env.example .env`].map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-1 font-mono text-meta`,children:[(0,Q.jsx)(`span`,{className:`text-soft-foreground`,children:`$`}),(0,Q.jsx)(`span`,{className:`flex-1 text-foreground`,children:e}),(0,Q.jsx)(`span`,{className:`text-success`,children:`done`})]},e)),(0,Q.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 font-mono text-meta text-soft-foreground`,children:[(0,Q.jsx)(`span`,{children:`$`}),(0,Q.jsx)(`span`,{className:`h-3 w-1.5 bg-violet`})]})]})}function ab(){return(0,Q.jsx)(`div`,{className:`flex w-full max-w-64 items-center self-center`,children:[`Plan`,`Build`,`Review`].map((e,t)=>(0,Q.jsxs)(Z.Fragment,{children:[t>0?(0,Q.jsx)(`span`,{className:`h-px flex-1 bg-muted-foreground/40`}):null,(0,Q.jsx)(`span`,{className:W(`rounded-md border bg-background px-3 py-2 text-meta`,t===1?`border-violet text-foreground shadow-[0_10px_30px_-14px_var(--violet)]`:`border-border text-muted-foreground`),children:e})]},e))})}function ob(){return(0,Q.jsx)(vv,{children:[`Every weekday at 9:00`,`When a pull request is merged`].map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5 text-meta text-foreground`,children:[(0,Q.jsx)(`span`,{className:`flex-1`,children:e}),(0,Q.jsx)(`span`,{className:`flex h-3.5 w-6 items-center justify-end rounded-full bg-violet px-0.5`,children:(0,Q.jsx)(`span`,{className:`size-2.5 rounded-full bg-violet-foreground`})})]},e))})}function sb(e,t){return O(e,`active`).filter(e=>!t||Zt(e)).map(e=>e.id)}function cb(e,t,n){if(e.length===0)return null;let r=t===void 0?-1:e.indexOf(t);return r===-1?n===`next`?e[0]:e[e.length-1]:e.length===1?null:e[(r+(n===`next`?1:-1)+e.length)%e.length]}function lb(e){return!e.altKey||e.metaKey||e.ctrlKey||e.repeat||e.key!==`ArrowUp`&&e.key!==`ArrowDown`?null:{direction:e.key===`ArrowUp`?`previous`:`next`,needsYouOnly:e.shiftKey}}var ub=`cezar:switch-task`;function db(){let{pathname:e}=jr(),t=vr(),n=kr(),r=a(),i=C(),o=se(n,r.data?.bootProject??i.data?.bootProject??null),s=Z.useRef({pathname:e,runs:o.data,navigate:t});s.current={pathname:e,runs:o.data,navigate:t},Z.useEffect(()=>{let e=(e,t)=>{let n=s.current,r=cb(sb(n.runs??[],t),Lh(n.pathname),e);return r===null?!1:(Xo(`arrow`),n.navigate(`/tasks/${r}`),!0)},t=t=>{let n=lb(t);!n||t.defaultPrevented||t.target instanceof HTMLElement&&t.target.closest(`.xterm`)||Ya()||(t.preventDefault(),e(n.direction,n.needsYouOnly))},n=t=>{let n=t.detail;n!==`previous`&&n!==`next`||Ya()||e(n,!0)};return window.addEventListener(`keydown`,t),window.addEventListener(ub,n),()=>{window.removeEventListener(`keydown`,t),window.removeEventListener(ub,n)}},[])}function fb(){return db(),null}var pb=e=>[e,`webhooks`];function mb(e,t){return dt({queryKey:pb(e),queryFn:({signal:t})=>je.list(e,t),enabled:t,retry:!1})}function hb(e,t){let n=U();(0,Z.useEffect)(()=>{if(!t||!globalThis.EventSource)return;let r=!1,i,a=`${sr()}${rr}/p/${encodeURIComponent(e)}/webhooks/events`,o=t=>{r||ur(t.type,t.data)&&n.invalidateQueries({queryKey:pb(e)})},s=()=>{r||i||(i=new EventSource(a,{withCredentials:!0}),i.addEventListener(`change`,o),i.addEventListener(`resync`,o))},c=()=>{i?.removeEventListener(`change`,o),i?.removeEventListener(`resync`,o),i?.close(),i=void 0},l=t=>{!t.persisted||r||i||(n.invalidateQueries({queryKey:pb(e)}),s())};return window.addEventListener(`pagehide`,c),window.addEventListener(`pageshow`,l),s(),()=>{r=!0,window.removeEventListener(`pagehide`,c),window.removeEventListener(`pageshow`,l),c()}},[n,e,t])}function gb({projectId:e}){let t=C(),n=!t.isError&&t.data?.capabilities?.webhooks===!0,r=mb(e,n);return hb(e,n),_b(e,n?r.data:void 0),null}function _b(e,t){let n=(0,Z.useRef)(void 0);(0,Z.useEffect)(()=>{if(!t){n.current=void 0;return}let r=n.current;if(n.current={projectId:e,data:t},!r||r.projectId!==e)return;let i=new Map(r.data.receivers.map(e=>[e.id,e.state]));for(let e of t.receivers)!i.has(e.id)||i.get(e.id)===e.state||(e.state===`active`||e.state===`disabled`)&&(e.state===`active`?Y(`${e.name} is now active`):Y(`${e.name} was disabled — open it to repair and test`,{tone:`danger`}));let a=t.webhookHealth.saturation?.dropped??0,o=r.data.webhookHealth.saturation?.dropped??0;a>o&&Y(`${a-o===1?`1 webhook delivery was`:`${a-o} webhook deliveries were`} dropped — webhook storage capacity was exceeded`,{tone:`danger`})},[e,t])}var vb=`cez-last-location`;function yb(){try{let e=localStorage.getItem(vb);return e===null?null:JSON.parse(e)}catch{return null}}function bb(e){try{localStorage.setItem(vb,JSON.stringify(e))}catch{}}var xb=new Set([`projectId`,`pathname`,`search`,`hash`]);function Sb(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e;if(Object.keys(t).some(e=>!xb.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/`)||Wp(t.pathname)||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(Sr(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 Cb(e,t){let n=t.projects.find(t=>t.id===e);return n!==void 0&&n.status!==`missing`}function wb(e,t){if(t===void 0)return null;let n;try{n=Sr(e.pathname)}catch{return null}return n===null||!Cb(n,t)?null:Sb({projectId:n,pathname:e.pathname,...e.search===``?{}:{search:e.search},...e.hash===``?{}:{hash:e.hash}})}function Tb(e,t,n){let r=Sb(e);return r===null||!(t===void 0?n!==void 0&&r.projectId===n:Cb(r.projectId,t))?null:`${r.pathname}${r.search??``}${r.hash??``}`}function Eb(e,t){if(e===void 0)return t;let{projects:n}=e;return n.length===0||n.some(e=>e.id===t)?t:Jf(n.filter(e=>e.status!==`missing`),[])[0]?.id??t}function Db(e,t){let n=Sb(e);return n!==null&&n.projectId===t.projectId&&n.pathname===t.pathname&&(n.search??``)===(t.search??``)&&(n.hash??``)===(t.hash??``)}function Ob(){return(0,Q.jsxs)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col`,children:[(0,Q.jsxs)(`header`,{className:`sticky top-0 z-10 hidden h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-5 md:flex`,children:[(0,Q.jsx)(`h1`,{className:`text-base font-semibold`,children:`Automations`}),(0,Q.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:`Scheduled and GitHub-triggered runs.`})]}),(0,Q.jsx)(`p`,{"data-slot":`automations-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading automations…`})]})}function kb(){return(0,Q.jsx)(`div`,{"data-route":`compare`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(_c,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading variants…`,subtitle:`Fetching every variant's status, spend and diff summary.`})})}function Ab(){return(0,Q.jsx)(`div`,{"data-route":`github`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(_c,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading GitHub…`,subtitle:`Fetching open issues and pull requests.`})})}var jb=[{id:`all`,label:`All`},{id:`impact`,label:`Impact`},{id:`html`,label:`HTML`},{id:`markdown`,label:`Markdown`},{id:`image`,label:`Images`}];function Mb(e,t){return t===`all`?[...e]:t===`impact`?e.filter(e=>e.subject!==void 0):e.filter(e=>e.kind===t)}function Nb(e,t){return t===`running`||t===`queued`?`running`:e.stale===!0?`stale`:e.stale===!1?`current`:`none`}function Pb(e){return`/tasks/${encodeURIComponent(e.runId)}/assets/${encodeURIComponent(e.name)}`}function Fb(e){return e.kind===`pr`?{to:`/github/prs/${e.number}`,label:`PR #${e.number}`,title:`Pull request #${e.number}`}:{to:`/git/files/${e.path.split(`/`).map(encodeURIComponent).join(`/`)}`,label:`spec ${e.path.split(`/`).pop()??e.path}`,title:e.path}}function Ib(){let e=F(),t=P(),[n,r]=(0,Z.useState)(`all`),i=(0,Z.useMemo)(()=>new Map((t.data??[]).map(e=>[e.id,e.status])),[t.data]),a=(0,Z.useMemo)(()=>Mb(e.data?.assets??[],n),[e.data,n]),o=e=>i.get(e.runId)??e.runStatus,s=e.data?.assets.length??0;return(0,Q.jsxs)(`div`,{"data-route":`assets`,className:`flex min-h-full flex-col`,children:[(0,Q.jsxs)(`header`,{className:`sticky top-0 z-10 hidden h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-5 md:flex`,children:[(0,Q.jsx)(`h1`,{className:`text-base font-semibold`,children:`Assets`}),(0,Q.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:`Every page and report your agents wrote, newest first.`})]}),(0,Q.jsx)(`div`,{className:`flex flex-1 flex-col gap-3 p-3 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-5 md:pb-5`,children:e.isPending?(0,Q.jsx)(`p`,{"data-slot":`assets-loading`,className:`py-6 text-center text-xs text-soft-foreground`,children:`Loading assets…`}):e.isError?(0,Q.jsxs)(`p`,{role:`alert`,className:`py-6 text-center text-xs text-destructive`,children:[`Could not load assets: `,e.error instanceof Error?e.error.message:String(e.error)]}):s===0?(0,Q.jsx)(X,{icon:(0,Q.jsx)(ys,{}),title:`No assets yet`,subtitle:`When an agent writes a page or report into its artifacts folder, it shows up here and in its task's Assets tab.`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{role:`group`,"aria-label":`Filter assets`,className:`flex w-fit max-w-full flex-wrap gap-0.5 rounded-lg bg-muted p-0.5`,children:jb.map(({id:e,label:t})=>(0,Q.jsx)(`button`,{type:`button`,"data-slot":`assets-filter`,"aria-pressed":n===e,onClick:()=>r(e),className:W(`h-7 rounded-[7px] px-3 text-label font-medium text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,n===e&&`bg-card font-semibold text-foreground shadow-xs`),children:t},e))}),a.length===0?(0,Q.jsxs)(`p`,{"data-slot":`assets-filter-empty`,className:`py-6 text-center text-xs text-soft-foreground`,children:[`No `,jb.find(e=>e.id===n)?.label.toLowerCase(),` assets.`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`hidden overflow-x-auto rounded-lg border border-border md:block`,children:(0,Q.jsxs)(`table`,{"data-slot":`assets-table`,className:`w-full border-collapse text-ui`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{className:`border-b border-border text-left text-meta font-medium text-muted-foreground`,children:[(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Asset`}),(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Subject`}),(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`State`}),(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Version`}),(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Updated`})]})}),(0,Q.jsx)(`tbody`,{children:a.map(e=>(0,Q.jsxs)(`tr`,{"data-slot":`asset-row`,className:`border-b border-border last:border-b-0 hover:bg-muted/50`,children:[(0,Q.jsx)(`td`,{className:`max-w-0 px-3 py-2`,children:(0,Q.jsx)(Lb,{row:e})}),(0,Q.jsx)(`td`,{className:`px-3 py-2`,children:(0,Q.jsx)(Rb,{row:e})}),(0,Q.jsx)(`td`,{className:`px-3 py-2`,children:(0,Q.jsx)(Bb,{state:Nb(e,o(e))})}),(0,Q.jsxs)(`td`,{className:`px-3 py-2 font-mono text-xs tabular-nums`,children:[`v`,e.versionCount]}),(0,Q.jsx)(`td`,{className:`px-3 py-2 whitespace-nowrap text-muted-foreground`,children:(0,Q.jsx)(Vb,{iso:e.updatedAt})})]},`${e.runId}/${e.name}`))})]})}),(0,Q.jsx)(`ul`,{"data-slot":`assets-cards`,className:`flex flex-col gap-2 md:hidden`,children:a.map(e=>(0,Q.jsxs)(`li`,{"data-slot":`asset-card`,className:`flex flex-col gap-1.5 rounded-lg border border-border bg-card p-3 text-ui`,children:[(0,Q.jsx)(Lb,{row:e}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,Q.jsx)(Rb,{row:e}),(0,Q.jsx)(Bb,{state:Nb(e,o(e))}),(0,Q.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[`v`,e.versionCount]}),(0,Q.jsx)(Vb,{iso:e.updatedAt})]})]},`${e.runId}/${e.name}`))})]}),e.data?.truncated?(0,Q.jsxs)(`p`,{"data-slot":`assets-truncated`,className:`text-xs text-soft-foreground`,children:[`Showing the newest `,s,` assets.`]}):null]})})]})}function Lb({row:e}){let t=Pb(e);return(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsx)(K,{"data-slot":`asset-link`,to:t,className:`truncate font-semibold text-foreground hover:underline focus-visible:underline focus-visible:outline-none`,children:e.title??e.name}),(0,Q.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`font-mono`,children:e.name}),` · `,(0,Q.jsx)(K,{"data-slot":`asset-task-link`,to:t,className:`hover:text-foreground hover:underline`,children:e.runTitle})]})]})}function Rb({row:e}){if(!e.subject)return(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let t=Fb(e.subject);return(0,Q.jsx)(K,{"data-slot":`asset-subject`,to:t.to,title:t.title,className:`whitespace-nowrap text-foreground hover:underline`,children:t.label})}var zb={running:{label:`running`,dot:`bg-pending animate-pulse`,className:`text-foreground`},stale:{label:`stale`,dot:`bg-pending`,className:`border-pending/50 text-pending-strong`},current:{label:`current`,dot:`bg-success`,className:`text-foreground`},none:{label:`—`,dot:null,className:`text-muted-foreground`}};function Bb({state:e}){let{label:t,dot:n,className:r}=zb[e];return(0,Q.jsxs)(`span`,{"data-slot":`asset-state`,"data-state":e,title:e===`none`?`No subject, or its state cannot be told`:void 0,className:W(`inline-flex items-center gap-1.5 rounded-full border border-border px-2 py-0.5 text-meta font-medium whitespace-nowrap`,r),children:[n?(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:W(`size-1.5 rounded-full`,n)}):null,t]})}function Vb({iso:e}){let t=Xc(e);return(0,Q.jsx)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:t?`${t} ago`:``})}var Hb={workflow:null,skills:[],runner:null,model:null},Ub=`cez-followup-selection`,Wb=Ss.map(e=>e.id);function Gb(e){let t=e&&typeof e==`object`?e:{};return{workflow:typeof t.workflow==`string`?t.workflow:null,skills:Array.isArray(t.skills)?t.skills.filter(e=>typeof e==`string`):[],runner:Wb.includes(t.runner)?t.runner:null,model:typeof t.model==`string`?t.model:null}}function Kb(){try{let e=localStorage.getItem(Ub);return e?Gb(JSON.parse(e)):{...Hb}}catch{return{...Hb}}}function qb(e){try{localStorage.setItem(Ub,JSON.stringify({...Kb(),...e}))}catch{}}var Jb=`cez-followup-prompt:`;function Yb(e){try{return localStorage.getItem(Jb+e)??``}catch{return``}}function Xb(e,t){try{t===``?localStorage.removeItem(Jb+e):localStorage.setItem(Jb+e,t)}catch{}}function Zb(e){let t=St(),n=En(),r=hn(t.data),i=n.data?.defaultRunner,a=Is(e.runner,r,i??r[0]??`claude`),o=E(a),s=n.data?.modelsLocked===!0,c=es(s?null:e.model,a,n.data?.defaultModels,o.data),l=ds(a,c,o.data),{accounts:u,repoAccount:d}=Yo(),f=u.some(t=>t.provider===a&&t.id===e.account)?e.account:null;return{runner:a,runnerExplicit:e.runner!==null,model:c,reasoningEffort:js(e.reasoningEffort??null,a,c,o.data),reasoningEfforts:l,runners:r,defaultRunner:i,canRun:t.isSuccess&&r.length>0,modelsLocked:s,providerPending:t.isPending,providerError:t.isError,accounts:u,account:f,repoAccount:d}}function Qb(e){let[t,n]=(0,Z.useState)($b);return(0,Z.useEffect)(()=>{e&&qb({runner:t.runner,model:t.model})},[e,t.runner,t.model]),nx(t,n),[t,n]}function $b(){let e=Kb();return{runner:e.runner,model:e.model,account:null}}function ex(){return Qb(!0)}function tx(){return Qb(!1)}function nx(e,t){let n=St(),r=En(),i=hn(n.data),a=Is(e.runner,i,r.data?.defaultRunner??i[0]??`claude`),o=n.isSuccess&&i.length>0,s=o&&e.runner!==null&&!i.includes(e.runner),c=o&&e.model!==null&&us(e.model,a);(0,Z.useEffect)(()=>{!s&&!c||t({...e,runner:s?null:e.runner,model:c?null:e.model})},[s,c,e,t])}function rx(e){return{runner:Fs(e.runner,e.defaultRunner,e.runnerExplicit),model:e.modelsLocked?void 0:e.model||void 0,reasoningEffort:e.modelsLocked?void 0:e.reasoningEffort||void 0}}function ix(e){return{...rx(e),...e.account?{agentProfile:e.account}:{}}}function ax({pick:e,onChange:t,disabled:n=!1,accounts:r=!1}){let i=Zb(e),{runner:a,model:o,reasoningEffort:s,reasoningEfforts:c,runners:l,canRun:u,modelsLocked:d}=i,f=En(),p=E(a),m=ws(a,p.data,[e.model,f.data?.defaultModels?.[a]]),h=n||!u,g=r?i.accounts:[];return(0,Q.jsxs)(Q.Fragment,{children:[l.length>1||l.some(e=>Ns(g,e))?(0,Q.jsx)(xs,{runners:l,value:a,accounts:g,account:r?i.account:null,repoAccount:r?i.repoAccount:void 0,disabled:h,onPick:(n,i)=>t(r?{runner:n,account:i,model:n===a?e.model:null,reasoningEffort:n===a?e.reasoningEffort??null:null}:{runner:n,account:null,model:null,reasoningEffort:null})}):null,(0,Q.jsx)(Os,{slot:`model-pill`,ariaLabel:`Model`,label:m.find(e=>e.id===o).label,value:o,disabled:h,readOnly:d===!0,disabledHint:d?`Model selection is locked to native coding-agent settings.`:void 0,onPick:n=>t({...e,model:n,reasoningEffort:null}),options:m.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:ss(a,p.data,p.isError)}),(0,Q.jsx)(nl,{runner:a,model:o,value:s,options:c,disabled:h,modelsLocked:d,onPick:n=>t({...e,reasoningEffort:n||null})})]})}function ox({templates:e,onInsert:t,triggerClassName:n,disabled:r,iconOnly:i=!1}){let[a,o]=(0,Z.useState)(!1),s=(0,Z.useRef)(null),c=vr();return e.length===0?null:(0,Q.jsxs)(Hr,{open:a,onOpenChange:o,children:[(0,Q.jsx)(Jr,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-trigger`,"aria-label":`Insert a prompt template`,title:`Insert a prompt template`,disabled:r,className:W(`inline-flex h-[26px] items-center gap-1.5 rounded-full border border-border bg-card text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,i?`w-[26px] justify-center px-0`:`px-2.5`,n),children:[(0,Q.jsx)(ql,{"aria-hidden":`true`,className:`size-3 shrink-0 text-violet`}),i?null:(0,Q.jsxs)(Q.Fragment,{children:[`templates`,(0,Q.jsx)(Ws,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})]})}),(0,Q.jsx)(Kr,{align:`start`,sideOffset:8,"data-slot":`prompt-template-menu`,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,onCloseAutoFocus:e=>e.preventDefault(),children:(0,Q.jsxs)(Ai,{filter:ro,children:[(0,Q.jsx)(Mi,{placeholder:`search templates…`,onInput:()=>s.current?.scrollTo(0,0)}),(0,Q.jsxs)(Li,{ref:s,"data-slot":`prompt-template-list-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[(0,Q.jsx)(Wi,{children:`Nothing matches.`}),(0,Q.jsx)(ji,{heading:`Insert a template`,children:e.map(e=>(0,Q.jsxs)(Bi,{value:`template ${e.label} ${e.id}`,keywords:[e.text,...e.skills??[]],"data-slot":`prompt-template-option`,"data-template":e.id,title:e.text,className:`flex-col items-start gap-0.5`,onSelect:()=>{t(e.text),o(!1)},children:[(0,Q.jsxs)(`span`,{className:`flex w-full items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-label font-medium text-foreground`,children:e.label}),e.skills&&e.skills.length>0?(0,Q.jsxs)(`span`,{"data-slot":`prompt-template-assigned`,title:`Applied automatically with: ${e.skills.join(`, `)}`,className:`inline-flex shrink-0 items-center gap-0.5 text-micro font-medium text-violet`,children:[(0,Q.jsx)(Ko,{"aria-hidden":`true`,className:`size-2.5`}),e.skills.length]}):null]}),(0,Q.jsx)(`span`,{className:`line-clamp-1 text-meta text-soft-foreground`,children:e.text})]},e.id))}),(0,Q.jsx)(Pi,{}),(0,Q.jsx)(ji,{children:(0,Q.jsx)(Bi,{value:`edit prompt templates settings`,"data-slot":`prompt-template-settings`,className:`text-label text-muted-foreground`,onSelect:()=>{o(!1),c(`/settings/instructions#prompt-templates`)},children:`Edit templates…`})})]})]})})]})}var sx=o({status:`waiting`});function cx(e){return e.filter(e=>!e.startedTaskId)}function lx(e){return e.runnable??!!(e.suggestedSkill||e.suggestedPrompt)}function ux(){let e=C(),t=e.data?.capabilities.followups===!0,n=e.data!==void 0&&!t,r=ye(!n),i=P(),a=r.data===void 0?void 0:cx(r.data);return(0,Q.jsxs)(`div`,{"data-route":`inbox`,className:`flex min-h-full flex-col`,children:[(0,Q.jsxs)(`header`,{className:`sticky top-0 z-10 hidden h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-5 md:flex`,children:[(0,Q.jsx)(`h1`,{className:`text-base font-semibold`,children:`Inbox`}),(0,Q.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:n?`Disabled for this server; per-task Notes still run.`:`Follow-ups agents suggested when they finished a task.`})]}),(0,Q.jsx)(`div`,{className:`flex flex-1 flex-col p-3 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-5 md:pb-5`,children:n?(0,Q.jsx)(X,{icon:(0,Q.jsx)(Il,{}),tone:`neutral`,title:`The follow-up inbox is off`,subtitle:`Agents are not asked to leave follow-ups. Set CEZ_FOLLOWUPS=1 and restart the service to turn the inbox on.`,heading:`h2`}):a===void 0?r.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(wc,{}),tone:`danger`,title:`Could not load the inbox`,subtitle:r.error.message,heading:`h2`}):null:a.length===0?e.isPending?null:(0,Q.jsx)(X,{icon:(0,Q.jsx)(Il,{}),tone:`neutral`,title:`Inbox empty`,subtitle:`Agents drop follow-up suggestions here when they finish a task.`,heading:`h2`}):(0,Q.jsx)(`ul`,{"data-slot":`todo-list`,className:`mx-auto flex w-full max-w-3xl flex-col gap-2.5`,children:a.map(e=>(0,Q.jsx)(dx,{todo:e,sourceTaskExists:e.taskId===void 0?null:i.data?.some(t=>t.id===e.taskId)??!1},e.id))})})]})}function dx({todo:e,sourceTaskExists:t}){let n=vr(),r=U(),i=Ft(),[a,o]=tx(),s=Zb(a),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(``),f=(0,Z.useRef)(null),p=C(),m=xo(So(i.data?.promptTemplates),p.data?.capabilities),h=e=>{let t=f.current?.selectionStart??u.length,n=Oo(u,t,e);d(n.text),requestAnimationFrame(()=>{f.current?.focus(),f.current?.setSelectionRange(n.caret,n.caret)})},g=H({mutationFn:async()=>s.canRun?M(e.id,{...rx(s),prompt:u.trim()||void 0}):null,onSuccess:e=>{if(e===null)return;fs(`inbox`);let{run:t}=e;r.invalidateQueries({queryKey:V.todos}),r.invalidateQueries({queryKey:V.runs.all}),n(`/tasks/${t.id}`)},onError:e=>Y(e.message,{tone:`danger`})}),_=H({mutationFn:()=>on(e.id),onSuccess:()=>{r.setQueryData(V.todos,t=>t?.filter(t=>t.id!==e.id)),r.invalidateQueries({queryKey:V.todos})},onError:e=>Y(e.message,{tone:`danger`})}),v=g.isPending||_.isPending,y=lx(e);return(0,Q.jsxs)(`li`,{"data-slot":`todo-card`,"data-id":e.id,className:`flex flex-col gap-2.5 rounded-lg border border-border bg-card p-4 shadow-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(Jc,{tone:sx.tone,pulse:sx.pulse,title:sx.label,className:`mt-[5px]`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{"data-slot":`todo-summary`,className:`text-sm leading-snug font-medium text-foreground`,children:e.summary}),(0,Q.jsxs)(`div`,{"data-slot":`todo-meta`,className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-soft-foreground`,children:[e.ts?(0,Q.jsxs)(`span`,{children:[Xc(e.ts),` ago`]}):null,e.action?(0,Q.jsx)(`span`,{children:e.action}):null,e.taskId===void 0?null:t?(0,Q.jsx)(K,{to:`/tasks/${e.taskId}`,"data-slot":`todo-source`,className:`text-muted-foreground underline decoration-border underline-offset-2 hover:text-foreground`,children:`source task`}):(0,Q.jsx)(`span`,{"data-slot":`todo-source-gone`,children:`source task deleted`}),ar(e.prUrl)?(0,Q.jsx)(`a`,{href:e.prUrl,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`todo-pr`,className:`text-muted-foreground underline decoration-border underline-offset-2 hover:text-foreground`,children:`PR`}):null,e.suggestedSkill?(0,Q.jsxs)(`span`,{"data-slot":`todo-skill`,className:`font-mono`,children:[`skill: `,e.suggestedSkill]}):null]})]}),(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-1.5 self-center`,children:y?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(J,{type:`button`,variant:`contrast`,size:`sm`,"data-action":`todo-run`,title:`Start a task from this follow-up`,disabled:v||!s.canRun,onClick:()=>g.mutate(),children:[(0,Q.jsx)(yc,{"aria-hidden":`true`,className:`size-3`}),`Run`]}),(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`todo-dismiss`,title:`Check off (remove)`,disabled:v,onClick:()=>_.mutate(),children:`Dismiss`})]}):(0,Q.jsxs)(J,{type:`button`,variant:`contrast`,size:`sm`,"data-action":`todo-acknowledge`,title:`Acknowledge and remove this note`,disabled:v,onClick:()=>_.mutate(),children:[(0,Q.jsx)(Rs,{"aria-hidden":`true`,className:`size-3`}),`Acknowledge`]})})]}),y?(0,Q.jsxs)(`div`,{"data-slot":`todo-engine`,className:`flex flex-wrap items-center gap-2 pl-5`,children:[(0,Q.jsx)(ax,{pick:a,onChange:o,disabled:v||!s.canRun}),!s.providerPending&&!s.canRun?(0,Q.jsxs)(`span`,{"data-slot":`todo-provider-gate`,className:`inline-flex flex-wrap items-center gap-1 text-xs text-muted-foreground`,children:[s.providerError?`Provider authentication could not be verified.`:`Connect an agent provider to run this follow-up.`,(0,Q.jsx)(K,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null]}):null,y?c?(0,Q.jsxs)(`div`,{"data-slot":`todo-instructions`,className:`flex flex-col gap-2 pl-5`,children:[(0,Q.jsx)(gc,{ref:f,"data-slot":`todo-instructions-input`,"aria-label":`Extra instructions for this follow-up`,value:u,onChange:e=>d(e.target.value),placeholder:`Add instructions for the agent… (appended to the suggestion above)`,maxLength:2e4,className:`min-h-16 text-ui`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(ox,{templates:m,onInsert:h}),(0,Q.jsx)(`button`,{type:`button`,"data-slot":`todo-instructions-hide`,onClick:()=>l(!1),className:`text-xs font-medium text-muted-foreground underline decoration-border underline-offset-2 hover:text-foreground`,children:`Hide`})]})]}):(0,Q.jsx)(`button`,{type:`button`,"data-slot":`todo-instructions-toggle`,onClick:()=>l(!0),className:`self-start pl-5 text-xs font-medium text-muted-foreground underline decoration-border underline-offset-2 hover:text-foreground`,children:u.trim()?`Edit instructions (added)`:`+ Add instructions`}):null]})}var fx=e=>String(e).padStart(2,`0`);function px(e){return JSON.stringify({...e,task:``})}function mx(e,t){let n=t=>new Intl.DateTimeFormat(`en-CA`,{timeZone:t,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}).formatToParts(e),r;try{r=n(t)}catch{r=n()}let i=e=>r.find(t=>t.type===e)?.value??``;return{date:`${i(`year`)}-${i(`month`)}-${i(`day`)}`,hour:Number(i(`hour`)),minute:Number(i(`minute`))}}function hx(e,t,n,r){let i=Math.round((Date.parse(`${e}T00:00:00Z`)-Date.parse(`${r}T00:00:00Z`))/864e5),a=`${fx(t)}:${fx(n)}`;return i===0?`Today, ${a}`:i===1?`Tomorrow, ${a}`:`${new Date(`${e}T00:00:00Z`).toLocaleDateString(`en-GB`,{weekday:`short`,day:`numeric`,month:`short`,...e.slice(0,4)===r.slice(0,4)?{}:{year:`numeric`},timeZone:`UTC`}).replace(`,`,``)}, ${a}`}function gx(e,t,n,r=Date.now()){if(!e)return`Now`;let i=mx(r,t?.timeZone??n).date,a=t&&mx(Date.parse(t.notBefore),t.timeZone),o=a&&hx(a.date,a.hour,a.minute,i);return e.start.kind===`usage-reset`?o?`After reset · ${o}`:`After reset`:o||(yx(e.start.date)?bx(e.start)?hx(e.start.date,e.start.hour,e.start.minute,i):`Pick a time`:`Pick a date`)}function _x(e,t,n){if(!e)return`Schedule start`;if(!t)return gx(e,t,n);let r=new Date(t.notBefore).toLocaleString(`en-GB`,{dateStyle:`full`,timeStyle:`short`,timeZone:t.timeZone});return`${e.start.kind===`usage-reset`?`After the usage limit resets: `:`Starts `}${r} (${t.timeZone})`}function vx(e,t=Date.now()){let{date:n,hour:r}=mx(t+2*36e5,e);return{kind:`at`,date:n,hour:r,minute:0}}function yx(e){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;let t=new Date(`${e}T00:00:00Z`);return Number.isFinite(t.getTime())&&t.toISOString().slice(0,10)===e}function bx(e){return Number.isInteger(e.hour)&&e.hour>=0&&e.hour<24&&Number.isInteger(e.minute)&&e.minute>=0&&e.minute<60}function xx(e){return yx(e.date)?bx(e)?Date.parse(`${e.date}T${fx(e.hour)}:${fx(e.minute)}:00Z`)+12*36e5<=Date.now()?{date:`Choose a future date and time.`}:{}:{time:`Enter a complete time.`}:{date:e.date?`Enter a complete, valid date.`:`Pick a date to schedule this task.`}}function Sx({task:e,value:t,onChange:n,disabledReason:r,onBlockedChange:i,onLabelChange:a,open:o,onOpenChange:s}){let[c,l]=(0,Z.useState)(!1),u=o??c,d=e=>{l(e),s?.(e)},f=(0,Z.useRef)(u);(0,Z.useEffect)(()=>{u&&!f.current&&as(),f.current=u},[u]);let p=(e,t)=>{Vo(e),n(t)},[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(),[w,T]=(0,Z.useState)(``),[E,D]=(0,Z.useState)(0),[O,k]=(0,Z.useState)(!1),A=t?.start.kind===`at`?xx(t.start):{},j=A.date??A.time,M=(0,Z.useRef)(0),N=(0,Z.useRef)(void 0),P=(0,Z.useRef)(null);t?.start.kind===`at`&&(P.current=t.start);let F=(0,Z.useId)(),ee=(0,Z.useId)(),I=(0,Z.useId)(),ne=px(e),L=!!e.task.trim(),re=JSON.stringify({...e,task:`Check scheduling options`}),ie=S?.key===re?S.data:void 0,ae=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let e=ie?.timeZone;if(!e||t?.start.kind!==`at`||!ae.current)return;let r=JSON.stringify(t.start)===JSON.stringify(ae.current),i=vx(e);ae.current=null,r&&JSON.stringify(i)!==JSON.stringify(t.start)&&n({start:i})},[ie?.timeZone,t?.start.kind]);let oe=r??(w||(ie?ie.usageReset.available?void 0:ie.usageReset.message:`Checking scheduling options…`)),se=t?.start.kind===`usage-reset`;(0,Z.useEffect)(()=>{if(!u&&!se)return;let e=!1;return T(``),vt({task:JSON.parse(re)}).then(t=>{e||C({key:re,data:t})}).catch(()=>{e||T(`Could not load scheduling options. Try again.`)}),()=>{e=!0}},[u,re,E,se]);let ce=JSON.stringify(t?.start);(0,Z.useLayoutEffect)(()=>(M.current++,h(!1),_(t?.invalidated??``),y(!!t?.invalidated),k(!1),t?.preview&&(t.settingsKey!==ne||r)&&n({start:t.start}),()=>{M.current++}),[ne,ce,r,t?.invalidated]),(0,Z.useLayoutEffect)(()=>{t?.start.kind!==`usage-reset`||!oe||(M.current++,h(!1),t.preview&&n({start:t.start}))},[oe,t?.start.kind]);let le=async()=>{if(clearTimeout(N.current),!t||r||t.start.kind===`usage-reset`&&oe||j||!e.task.trim())return;let i=++M.current;n({start:t.start,invalidated:t.invalidated}),h(!0),_(``),y(!1),k(!1);try{let r=await te({task:e,start:t.start});if(i!==M.current)return;r.available?n({start:t.start,preview:r,settingsKey:ne}):(_(r.message),k(r.reason===`window-over`),y(r.reason===`account-unverifiable`))}catch(e){i===M.current&&(_(t.start.kind===`at`?`Could not check the start time. Try again.`:e instanceof Error?e.message:String(e)),y(!0))}finally{i===M.current&&h(!1)}};(0,Z.useEffect)(()=>{if(!(!t||r||!e.task.trim()||j)&&!(t.start.kind===`usage-reset`&&oe)&&!(t.preview&&t.settingsKey===ne))return N.current=setTimeout(()=>void le(),600),()=>clearTimeout(N.current)},[ne,L,ce,r,t?.start.kind===`usage-reset`&&oe]),(0,Z.useEffect)(()=>{if(!t?.preview)return;let e,r=()=>{let i=Date.parse(t.preview.notBefore)-Date.now();i>0?e=setTimeout(r,Math.min(i,2147483647)):n({start:t.start,invalidated:`The previewed start time has passed. Check the start time again.`})};return r(),()=>clearTimeout(e)},[t?.preview]);let R=!(t?.start.kind===`usage-reset`&&oe)&&!m&&!j&&!r&&t?.settingsKey===ne&&t.preview&&Date.parse(t.preview.notBefore)>Date.now()?t.preview:void 0,ue=!t||R?void 0:r??(t.start.kind===`usage-reset`&&oe?oe:m?`Checking the start time…`:g||j||(e.task.trim()?t.start.kind===`at`?`Checking the start time…`:`Finding when your usage limit resets…`:`Describe the task to schedule it.`));(0,Z.useEffect)(()=>{i?.(ue)},[ue]);let de=b?j:void 0,fe=g||j?ee:void 0,pe=gx(t,R,ie?.timeZone),z=_x(t,R,ie?.timeZone);return(0,Z.useEffect)(()=>{a?.(t?{text:pe,title:z}:void 0)},[t?`${pe}\n${z}`:void 0]),(0,Q.jsxs)(Hr,{open:u,onOpenChange:d,children:[(0,Q.jsx)(Jr,{asChild:!0,children:(0,Q.jsx)(J,{type:`button`,size:`icon-sm`,"data-slot":`start-time-trigger`,className:`h-8 w-7 rounded-l-none border-l border-primary-foreground/25`,"aria-label":`Choose task start time`,title:z,children:(0,Q.jsx)(Ws,{"aria-hidden":`true`,className:W(`size-4 transition-transform`,u&&`rotate-180`)})})}),(0,Q.jsxs)(Kr,{align:`end`,className:`w-80 max-w-[calc(100vw-2rem)] max-h-(--radix-popover-content-available-height) overflow-y-auto overscroll-contain space-y-3`,children:[(0,Q.jsxs)(`fieldset`,{className:`space-y-3`,children:[(0,Q.jsx)(`legend`,{className:`font-medium`,children:`Start task`}),(0,Q.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`radio`,name:F,"aria-describedby":fe,checked:!t,onChange:()=>p(`now`,null)}),`Now`]}),(0,Q.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`radio`,name:F,"aria-describedby":fe,disabled:!!r,checked:t?.start.kind===`at`,onChange:()=>{let e=P.current??vx(ie?.timeZone);ae.current=!P.current&&!ie?e:null,p(`at`,{start:e})}}),`Pick date & time`]}),(0,Q.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`radio`,name:F,"aria-describedby":oe?I:fe,disabled:!!oe,checked:t?.start.kind===`usage-reset`,onChange:()=>p(`usage_reset`,{start:{kind:`usage-reset`}})}),`After usage limit resets`]})]}),oe&&!r&&(0,Q.jsx)(`p`,{id:I,className:`text-sm text-muted-foreground`,children:oe}),w&&(0,Q.jsx)(J,{type:`button`,variant:`outline`,onClick:()=>D(e=>e+1),children:`Retry options`}),r&&(0,Q.jsx)(`p`,{id:I,role:`status`,className:`text-sm text-muted-foreground`,children:r}),t?.start.kind===`at`&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:ie?`Server time zone: ${ie.timeZone}`:`Loading server time zone…`}),(0,Q.jsxs)(`label`,{className:`block text-sm`,children:[`Date`,(0,Q.jsx)(Kc,{"aria-describedby":fe,onBlur:()=>x(!0),"aria-invalid":b&&A.date||O?!0:void 0,type:`date`,max:`9999-12-31`,value:t.start.date,onChange:e=>n({start:{...t.start,date:e.target.value}})})]}),(0,Q.jsxs)(`label`,{className:`block text-sm`,children:[`Time (server time zone)`,(0,Q.jsx)(Kc,{"aria-describedby":fe,onBlur:()=>x(!0),"aria-invalid":b&&A.time||O?!0:void 0,type:`time`,value:bx(t.start)?`${fx(t.start.hour)}:${fx(t.start.minute)}`:``,onChange:e=>{let[r,i]=e.target.value?e.target.value.split(`:`).map(Number):[-1,-1];n({start:{...t.start,hour:r??-1,minute:i??-1}})}})]})]}),t&&!r&&(0,Q.jsxs)(Q.Fragment,{children:[t.start.kind===`usage-reset`&&ie?.usageReset.available&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:ie.usageReset.provider===`claude`?`The task waits until your Claude usage limit resets, then starts. Cezar knows the reset time from limits your earlier Claude tasks hit.`:`The task waits until your Codex usage limit resets, then starts. Cezar reads the reset time from Codex.`}),t.start.kind===`usage-reset`&&!oe&&!R&&!g&&(0,Q.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:ue}),t.start.kind===`usage-reset`&&!oe&&(R||g&&v)&&(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:m||!e.task.trim(),onClick:()=>void le(),children:g?`Try again`:`Refresh`}),t.start.kind===`at`&&v&&(0,Q.jsx)(J,{type:`button`,variant:`outline`,disabled:m||!!j||!e.task.trim(),onClick:()=>void le(),children:`Retry`}),t.start.kind===`at`&&!R&&!g&&!j&&(0,Q.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:ue}),R&&(0,Q.jsxs)(`div`,{role:`status`,className:`space-y-1 text-sm`,children:[(0,Q.jsxs)(`p`,{children:[`Earliest start: `,new Date(R.notBefore).toLocaleString(`en-GB`,{timeZone:R.timeZone}),` · `,R.timeZone]}),R.observation&&(0,Q.jsx)(`p`,{children:R.observation}),(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:`The server must be running. Scheduling does not reserve allowance; account holds and queue limits still apply.`})]})]}),!b&&j&&!g&&(0,Q.jsx)(`p`,{id:ee,className:`text-sm text-muted-foreground`,children:j}),(g||de)&&(0,Q.jsx)(`p`,{id:ee,role:`alert`,className:`text-sm text-destructive`,children:g||de})]})]})}var Cx=[{id:`slash-skills`,title:`Type / for a skill`,body:`A skill is a playbook the agent follows for one kind of job. Type / in the box to pick one as you write.`,anchor:`textarea`,picture:`slash`},{id:`source`,title:`Skills and workflows`,body:`Nothing picked runs the built-in quick task. A workflow chains steps with checks between them: plan, build, review.`,anchor:`[data-slot="source-pill"]`,picture:`source`},{id:`worktree`,title:`Each task in its own worktree`,body:`The agent works on a branch in a separate checkout, so your working tree stays yours. Uncheck to work in place.`,anchor:`[data-slot="worktree-toggle"]`,picture:`worktree`},{id:`autonomous`,title:`Autonomous runs do not wait`,body:`Checked, the agent carries on without asking you anything until it is done. Unchecked, it stops when it needs you.`,anchor:`[data-slot="autonomous-toggle"]`,picture:`autonomous`},{id:`variants`,title:`Run it twice, keep the better one`,body:`×2 or ×3 runs the same task in parallel, each in its own worktree. You compare the diffs and keep one.`,anchor:`[data-slot="variants-pill"]`,picture:`variants`},{id:`model`,title:`Pick the model`,body:`auto follows the agent’s own default. Choose a larger model for hard work and a faster one for small fixes.`,anchor:`[data-slot="model-pill"]`,picture:`model`},{id:`attachments`,title:`Paste a screenshot`,body:`Drop or paste images and files into the box. The agent sees them with the task.`,anchor:`[aria-label="Attach files"]`,picture:`attachments`},{id:`schedule`,title:`Start it later`,body:`The arrow beside Start schedules the task: tonight, tomorrow morning, or when your usage limit resets.`,anchor:`[data-slot="start-time-trigger"]`,picture:`schedule`},{id:`dispatch`,title:`Let the task fan out`,body:`With dispatch on, the agent can split the work into subtasks that run as their own tasks, and merges what it accepts.`,anchor:`[data-slot="dispatch-toggle"]`,picture:`dispatch`},{id:`ask`,title:`Just ask`,body:`Ask answers a question from the checkout and changes nothing: no branch, no worktree, nothing to review.`,anchor:`[data-slot="ask-toggle"]`,picture:`ask`},{id:`base-branch`,title:`Where it forks from`,body:`Tasks branch off the base branch and pull requests target it. Change it here for every task that follows.`,anchor:`[data-slot="base-pill"]`,picture:`base`},{id:`followups`,title:`Follow-ups land in the inbox`,body:`The agent may note work it found but did not do. Those notes land in the Inbox, ready to run later.`,anchor:`[data-slot="generate-followups-toggle"]`,picture:`followups`},{id:`templates`,title:`Prompt templates`,body:`Insert a saved piece of text at the caret. A template assigned to a skill applies itself when you pick the skill.`,anchor:`[data-slot="prompt-template-trigger"]`,picture:`templates`},{id:`project`,title:`Which project`,body:`Skills, workflows, settings and the draft all follow the project picked here.`,anchor:`[data-slot="project-pill"]`,picture:`project`}];function wx(e){let t=Cx.filter(t=>e.present.has(t.anchor));if(e.replay)return t;if(e.off)return[];let n=new Set(e.seen??[]);return t.filter(e=>!n.has(e.id)).slice(0,2)}function Tx(e,t){return[...(e??[]).filter(e=>e!==t),t].slice(-50)}function Ex(e,t){let n=new Set(e??[]);return Cx.filter(e=>t.has(e.anchor)).every(e=>n.has(e.id))}var Dx=5e3;function Ox({anchorRoot:e,ready:t,loaded:n,seen:r,off:i,onSeen:a,onOff:o}){let[s,c]=Z.useState(null),[l,u]=Z.useState(0),[d,f]=Z.useState(()=>new Set),[p,m]=Z.useState(null),[h,g]=Z.useState(null),_=Z.useRef(null),v=Z.useRef(null),y=Z.useCallback(()=>e.current?.querySelector(`[data-slot="composer"]`)??null,[e]),b=Z.useCallback(()=>{let e=y();return new Set(e?Cx.filter(t=>e.querySelector(t.anchor)!==null).map(e=>e.anchor):[])},[y]);Z.useEffect(()=>{if(!t||!n||s!==null)return;let e=b();f(e),c(wx({seen:r,off:i,present:e}))},[t,n,s,r,i,b]);let x=s&&t?s[l]:void 0,S=x?.id;Z.useLayoutEffect(()=>{if(!x){m(null),g(null);return}let t=e.current,n=()=>{let e=y()?.querySelector(x.anchor);if(!t||!e){m(null),g(null);return}let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();m({top:r.top-n.top,left:r.left-n.left,width:r.width,height:r.height});let i=_.current?.getBoundingClientRect();g(i?Math.min(Math.max(r.left+r.width/2-i.left,18),Math.max(i.width-18,18)):null)};n(),window.addEventListener(`resize`,n);let r=t&&typeof ResizeObserver<`u`?new ResizeObserver(n):null;return t&&r?.observe(t),()=>{window.removeEventListener(`resize`,n),r?.disconnect()}},[x,e,y]);let C=Z.useCallback(()=>{S&&(a(S),u(e=>e+1))},[S,a]);Z.useEffect(()=>{if(!x||x.anchor===`textarea`)return;let e=y()?.querySelector(x.anchor);if(e)return e.addEventListener(`click`,C),()=>e.removeEventListener(`click`,C)},[x,y,C]),Z.useEffect(()=>{v.current=S?Date.now():null},[S]);let w=Z.useRef({currentId:S,onSeen:a});if(w.current={currentId:S,onSeen:a},Z.useEffect(()=>()=>{let{currentId:e,onSeen:t}=w.current;e&&v.current!==null&&Date.now()-v.current>=Dx&&t(e)},[]),!n||!t||s===null)return null;if(!x){let e=Ex(r,d)||i===!0;return(0,Q.jsx)(`div`,{className:`mt-3 flex justify-center`,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`composer-tips-link`,onClick:()=>{i&&o(!1);let t=b();f(t),c(wx({seen:r,off:!1,present:t,replay:e})),u(0)},className:W(lv,`text-label text-soft-foreground`),children:[(0,Q.jsx)(zl,{className:`size-3.5`,"aria-hidden":`true`}),e?`Show me around`:`Tips`]})})}let T=l>=s.length-1,E=p!==null&&p.height>40;return(0,Q.jsxs)(Q.Fragment,{children:[p?(0,Q.jsx)(`span`,{"data-slot":`composer-tip-halo`,"aria-hidden":`true`,className:W(`composer-tip-halo pointer-events-none absolute z-10`,E?`rounded-xl`:`rounded-full`),style:{top:p.top-4,left:p.left-4,width:p.width+8,height:p.height+8}}):null,(0,Q.jsxs)(`div`,{"data-slot":`composer-tip`,"data-tip":x.id,role:`note`,"aria-label":`Tip: ${x.title}`,className:`relative mt-3`,children:[h===null?null:(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`composer-tip-arrow z-10`,style:{left:h}}),(0,Q.jsxs)(`div`,{ref:_,className:`onboarding-announcement relative flex items-stretch overflow-hidden rounded-xl border text-left`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col justify-center p-5 pr-10 sm:pr-5`,children:[(0,Q.jsxs)(`span`,{className:`eyebrow text-violet`,children:[`Tip `,l+1,` of `,s.length]}),(0,Q.jsx)(`span`,{className:`mt-1 text-lg font-light tracking-tight text-foreground`,children:x.title}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-md text-ui text-muted-foreground`,children:x.body}),(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,Q.jsx)(J,{size:`sm`,className:`font-normal`,onClick:C,children:T?`Got it`:`Next tip`}),(0,Q.jsx)(`button`,{type:`button`,className:lv,onClick:()=>{o(!0),u(s.length)},children:`Don’t show tips`})]})]}),(0,Q.jsx)(Nx,{id:x.picture}),(0,Q.jsx)(`button`,{type:`button`,onClick:C,"aria-label":`Close tip`,className:`absolute top-3 right-3 grid size-7 place-items-center rounded-full text-soft-foreground hover:text-foreground`,children:(0,Q.jsx)(Tc,{className:`size-3.5`,"aria-hidden":`true`})})]})]})]})}var kx=`h-1.5 rounded bg-muted`,Ax=`tip-rise flex items-center gap-2 rounded-md px-2 py-1 text-micro`;function jx({children:e}){return(0,Q.jsx)(`div`,{className:`onboarding-picture hidden w-60 shrink-0 items-end justify-center pt-5 pr-5 sm:flex`,"aria-hidden":`true`,children:(0,Q.jsx)(`div`,{className:`w-full rounded-t-lg border border-b-0 border-border bg-background p-3 shadow-[0_-12px_40px_-20px_var(--violet)]`,children:e})})}function Mx({rows:e,pick:t=0,start:n=0}){return(0,Q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.map((e,r)=>(0,Q.jsxs)(`div`,{style:{"--i":n+r},className:W(Ax,r===t?`bg-violet/15 text-foreground`:`text-muted-foreground`),children:[(0,Q.jsx)(`span`,{className:W(`size-1.5 rounded-full`,r===t?`bg-violet`:`bg-muted-foreground/40`)}),e]},e))})}function Nx({id:e}){switch(e){case`slash`:return(0,Q.jsxs)(jx,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-violet/60 px-2 py-1.5 font-mono text-meta text-foreground`,children:[(0,Q.jsx)(`span`,{className:`text-violet`,children:`/`}),`fix`,(0,Q.jsx)(`span`,{className:`tip-caret ml-px h-3 w-px bg-violet`})]}),(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(Mx,{rows:[`fix-issue`,`write-tests`,`review-pr`]})})]});case`source`:return(0,Q.jsx)(jx,{children:(0,Q.jsx)(`div`,{className:`flex items-center py-3`,children:[`Plan`,`Build`,`Review`].map((e,t)=>(0,Q.jsxs)(Z.Fragment,{children:[t>0?(0,Q.jsx)(`span`,{className:`h-px flex-1 bg-muted-foreground/40`}):null,(0,Q.jsx)(`span`,{style:{"--i":t},className:W(`tip-rise rounded-md border px-2 py-1 text-micro`,t===1?`border-violet text-foreground`:`border-border text-muted-foreground`),children:e})]},e))})});case`worktree`:case`base`:return(0,Q.jsxs)(jx,{children:[(0,Q.jsxs)(`svg`,{viewBox:`0 0 200 64`,className:`h-16 w-full`,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,Q.jsx)(`path`,{d:`M12 48 H188`,className:`stroke-muted-foreground/50`}),(0,Q.jsx)(`path`,{d:`M60 48 C 80 48, 84 20, 104 20 H188`,pathLength:1,className:`tip-draw stroke-violet`}),(0,Q.jsx)(`circle`,{cx:`60`,cy:`48`,r:`3.5`,className:`fill-background stroke-muted-foreground/70`}),(0,Q.jsx)(`circle`,{cx:`150`,cy:`20`,r:`3.5`,style:{"--i":2},className:`tip-rise fill-violet`})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between font-mono text-micro text-soft-foreground`,children:[(0,Q.jsx)(`span`,{children:e===`base`?`base: main`:`main`}),(0,Q.jsx)(`span`,{className:`text-violet`,children:e===`base`?`cez/1a2b`:`worktree`})]})]});case`autonomous`:return(0,Q.jsxs)(jx,{children:[(0,Q.jsx)(`div`,{className:W(kx,`w-3/4`)}),(0,Q.jsx)(`div`,{className:W(kx,`mt-1.5 w-1/2`)}),(0,Q.jsx)(`div`,{className:`mt-3 h-1.5 w-full overflow-hidden rounded bg-muted`,children:(0,Q.jsx)(`div`,{className:`tip-progress h-full rounded bg-violet`})}),(0,Q.jsxs)(`div`,{className:`mt-2 flex items-center justify-between text-micro`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`No questions asked`}),(0,Q.jsxs)(`span`,{style:{"--i":10},className:`tip-rise inline-flex items-center gap-1 text-success`,children:[(0,Q.jsx)(Rs,{className:`size-3`}),` done`]})]})]});case`variants`:return(0,Q.jsxs)(jx,{children:[(0,Q.jsx)(`div`,{className:`grid grid-cols-3 gap-1.5`,children:[0,1,2].map(e=>(0,Q.jsxs)(`div`,{style:{"--i":e},className:W(`tip-rise rounded-md border p-1.5`,e===1?`border-violet`:`border-border`),children:[(0,Q.jsx)(`div`,{className:W(kx,`w-full`)}),(0,Q.jsx)(`div`,{className:W(kx,`mt-1 w-2/3`)}),(0,Q.jsx)(`div`,{className:`mt-2 flex justify-end`,children:e===1?(0,Q.jsx)(Rs,{className:`size-3 text-violet`}):(0,Q.jsx)(`span`,{className:`size-3`})})]},e))}),(0,Q.jsx)(`div`,{className:`mt-2 text-center font-mono text-micro text-soft-foreground`,children:`×3 · keep one`})]});case`model`:return(0,Q.jsx)(jx,{children:(0,Q.jsx)(Mx,{rows:[`auto`,`opus · hard work`,`haiku · small fixes`],pick:1})});case`attachments`:return(0,Q.jsxs)(jx,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`tip-drop grid size-9 place-items-center rounded-md border border-violet/60 bg-violet/15`,children:(0,Q.jsx)(`span`,{className:`size-4 rounded-sm bg-violet/60`})}),(0,Q.jsx)(`span`,{className:`tip-drop grid h-9 items-center rounded-md border border-border px-2 text-micro text-muted-foreground`,style:{animationDelay:`900ms`},children:`design.pdf`})]}),(0,Q.jsx)(`div`,{className:W(kx,`mt-3 w-2/3`)})]});case`schedule`:return(0,Q.jsx)(jx,{children:(0,Q.jsx)(Mx,{rows:[`Now`,`Tonight at 23:00`,`When the usage limit resets`],pick:1})});case`dispatch`:return(0,Q.jsx)(jx,{children:(0,Q.jsxs)(`svg`,{viewBox:`0 0 200 72`,className:`h-[72px] w-full`,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,Q.jsx)(`rect`,{x:`12`,y:`28`,width:`44`,height:`16`,rx:`4`,className:`stroke-violet`}),[12,36,60].map((e,t)=>(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(`path`,{d:`M56 36 C 90 36, 100 ${e}, 128 ${e}`,pathLength:1,style:{"--i":t},className:`tip-draw stroke-muted-foreground/60`}),(0,Q.jsx)(`rect`,{x:`128`,y:e-7,width:`56`,height:`14`,rx:`4`,style:{"--i":t+2},className:`tip-rise stroke-border fill-card`})]},e))]})});case`ask`:return(0,Q.jsxs)(jx,{children:[(0,Q.jsx)(`div`,{className:`ml-auto w-3/4 rounded-lg rounded-br-sm bg-violet/15 px-2 py-1 text-micro text-foreground`,children:`Where is the retry logic?`}),(0,Q.jsxs)(`div`,{style:{"--i":2},className:`tip-rise mt-2 w-5/6 rounded-lg rounded-bl-sm border border-border px-2 py-1 text-micro text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-foreground`,children:`src/runs/retry.ts`}),`, nothing changed.`]})]});case`followups`:return(0,Q.jsxs)(jx,{children:[(0,Q.jsx)(`div`,{className:`mb-1 eyebrow text-soft-foreground`,children:`Inbox`}),(0,Q.jsx)(Mx,{rows:[`Add a test for the empty case`,`Document the new flag`,`Remove the old helper`],pick:0})]});case`templates`:return(0,Q.jsxs)(jx,{children:[(0,Q.jsx)(`div`,{className:W(kx,`w-3/4`)}),(0,Q.jsx)(`div`,{style:{"--i":1},className:`tip-rise mt-1.5 rounded-sm border border-violet/60 bg-violet/15 px-1.5 py-1 text-micro text-foreground`,children:`Run the tests and report what you ran.`}),(0,Q.jsx)(`div`,{className:W(kx,`mt-1.5 w-1/2`)})]});case`project`:return(0,Q.jsx)(jx,{children:(0,Q.jsx)(Mx,{rows:[`shop-web`,`billing-api`,`docs`],pick:1})})}}function Px({onLongPress:e,onClick:t,delayMs:n=450,moveTolerance:r=8}){let i=(0,Z.useRef)({onLongPress:e,onClick:t});i.current={onLongPress:e,onClick:t};let a=(0,Z.useRef)(null),o=(0,Z.useRef)({x:0,y:0}),s=(0,Z.useRef)(!1),c=(0,Z.useCallback)(()=>{a.current!==null&&(clearTimeout(a.current),a.current=null)},[]);return(0,Z.useEffect)(()=>c,[c]),{onPointerDown:(0,Z.useCallback)(e=>{s.current=!1,c(),e.button===0&&(o.current={x:e.clientX??0,y:e.clientY??0},a.current=setTimeout(()=>{a.current=null,s.current=!0,i.current.onLongPress()},n))},[c,n]),onPointerMove:(0,Z.useCallback)(e=>{if(a.current===null)return;let t=(e.clientX??0)-o.current.x,n=(e.clientY??0)-o.current.y;Math.hypot(t,n)>r&&c()},[c,r]),onPointerUp:c,onPointerCancel:c,onContextMenu:(0,Z.useCallback)(e=>{e.preventDefault(),c(),!s.current&&(s.current=!0,i.current.onLongPress())},[c]),onClick:(0,Z.useCallback)(e=>{if(s.current){s.current=!1,e.preventDefault();return}i.current.onClick?.()},[]),onKeyDown:(0,Z.useCallback)(e=>{(e.key===`ArrowDown`||e.key===`Enter`&&e.shiftKey)&&(e.preventDefault(),i.current.onLongPress())},[])}}function Fx({available:e,value:t,onChange:n,onSettingsOpenChange:r,runners:i,parentRunner:a,parentModels:o}){let[s,c]=(0,Z.useState)(!1),l=ra(),u=(0,Z.useRef)({});t!==null&&(u.current=t);let d=(t??u.current).runner??a,f=E(d,e&&d!==a),p=d===a?o:ws(d,f.data),m=e=>{c(e),r?.(e)},h=t!==null,g=Px({onLongPress:()=>m(!0),onClick:()=>n(h?null:u.current)});if(!e)return null;let _=(0,Q.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":h,"aria-label":`Dispatch`,"data-slot":`dispatch-toggle`,"data-state":h?`on`:`off`,...g,className:W(l?`inline-flex h-full w-[26px] items-center justify-center transition-colors hover:bg-muted`:W(ns,`w-[26px] justify-center px-0`),h&&(l?`hover:bg-primary/15`:`border-primary/60 bg-primary/10 text-primary hover:bg-primary/15 hover:text-primary`)),children:(0,Q.jsx)(iu,{"aria-hidden":`true`,className:W(`size-3 shrink-0`,h?`text-primary`:`text-soft-foreground`)})}),v=(0,Q.jsx)(Hx,{value:t,remembered:u.current,onChange:n,runners:i,models:p}),y=(0,Q.jsxs)(Oc,{side:`top`,sideOffset:6,className:`max-w-[260px]`,children:[(0,Q.jsx)(`div`,{className:`font-medium`,children:h?`Dispatch — on`:`Dispatch — off`}),(0,Q.jsx)(`div`,{className:`text-contrast-foreground/80`,children:h?`Splits this task into subtasks it runs as separate tasks`:`Let this task split into subtasks`}),l?(0,Q.jsx)(`div`,{className:`mt-0.5 text-contrast-foreground/60`,children:`▾ limits and subtask defaults`}):null]}),b=l?(0,Q.jsxs)(`span`,{"data-slot":`dispatch-control`,"data-state":h?`on`:`off`,className:W(`inline-flex h-[26px] items-stretch overflow-hidden rounded-full border border-border bg-card text-muted-foreground transition-colors`,h&&`border-primary/60 bg-primary/10 text-primary`),children:[(0,Q.jsx)(kc,{delayDuration:300,children:(0,Q.jsxs)(Ac,{children:[(0,Q.jsx)(Dc,{asChild:!0,children:_}),y]})}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Dispatch settings`,"aria-haspopup":`dialog`,"aria-expanded":s,"data-slot":`dispatch-settings-trigger`,onClick:()=>m(!s),className:W(`inline-flex w-[18px] items-center justify-center border-l border-border transition-colors hover:bg-muted`,h&&`border-primary/40 hover:bg-primary/15`),children:(0,Q.jsx)(Ws,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})})]}):(0,Q.jsx)(kc,{delayDuration:300,children:(0,Q.jsxs)(Ac,{children:[(0,Q.jsx)(Dc,{asChild:!0,children:_}),y]})});return l?(0,Q.jsxs)(Hr,{open:s,onOpenChange:m,children:[(0,Q.jsx)(Rr,{asChild:!0,children:b}),(0,Q.jsx)(Kr,{align:`start`,sideOffset:8,"data-slot":`dispatch-settings`,className:`w-[340px] max-w-[calc(100vw-2rem)] p-3.5`,children:v})]}):(0,Q.jsxs)(Q.Fragment,{children:[b,(0,Q.jsx)(Ui,{open:s,onOpenChange:m,children:(0,Q.jsxs)(Vi,{side:`bottom`,"data-slot":`dispatch-settings`,className:`rounded-t-xl p-4 pt-16 pb-[max(1rem,env(safe-area-inset-bottom))]`,children:[(0,Q.jsx)(zi,{className:`sr-only`,children:`Dispatch`}),(0,Q.jsx)(Fi,{className:`sr-only`,children:`Split this task into subtasks run as separate tasks`}),v]})})]})}function Ix({label:e,htmlFor:t,children:n}){return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`label`,{htmlFor:t,className:`shrink-0 text-xs text-foreground`,children:e}),n]})}var Lx=`h-7 max-w-[180px] rounded-md border border-input bg-card px-2 text-xs shadow-xs outline-none transition-[color,box-shadow] hover:bg-muted focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,Rx=[2,3,4,5,8,10,15,20,30,50],zx=.5,Bx=1e4;function Vx(e){let t={};return e.maxSubtasks!==void 0&&(t.maxSubtasks=e.maxSubtasks),e.inFlight!==void 0&&(t.inFlight=e.inFlight),e.runner!==void 0&&(t.runner=e.runner),e.model!==void 0&&(t.model=e.model),e.budgetUsd!==void 0&&(t.budgetUsd=e.budgetUsd),t}function Hx({value:e,remembered:t,onChange:n,runners:r,models:i}){let a=(0,Z.useId)(),o=e!==null,s=e??t,c=e=>n(Vx({...s,...e})),l=i.filter(e=>e.id!==``),u=Ss.filter(e=>r.includes(e.id)),d=s.maxSubtasks!==void 0&&!Rx.some(e=>e===s.maxSubtasks)?[...Rx,s.maxSubtasks].sort((e,t)=>e-t):[...Rx];return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`header`,{className:`flex items-start gap-2.5`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`flex size-7 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary`,children:(0,Q.jsx)(iu,{className:`size-3.5`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`text-ui font-semibold leading-tight text-foreground`,children:`Dispatch`}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs leading-snug text-muted-foreground`,children:`Split this task into subtasks run as separate tasks`})]}),(0,Q.jsx)(ff,{"aria-label":`Dispatch`,"data-slot":`dispatch-settings-switch`,checked:o,onCheckedChange:e=>n(e?t:null)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-border pt-3`,children:[(0,Q.jsx)(Ix,{label:`Max subtasks`,htmlFor:`${a}-max`,children:(0,Q.jsxs)(`select`,{id:`${a}-max`,"data-slot":`dispatch-max-subtasks`,className:Lx,value:s.maxSubtasks??``,onChange:e=>c({maxSubtasks:e.target.value===``?void 0:Number(e.target.value)}),children:[(0,Q.jsx)(`option`,{value:``,children:`unlimited`}),d.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))]})}),(0,Q.jsx)(Ix,{label:`In flight at once`,htmlFor:`${a}-flight`,children:(0,Q.jsx)(`select`,{id:`${a}-flight`,"data-slot":`dispatch-in-flight`,className:Lx,value:s.inFlight??4,onChange:e=>{let t=Number(e.target.value);c({inFlight:t===4?void 0:t})},children:Array.from({length:4},(e,t)=>t+1).map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))})}),(0,Q.jsx)(Ix,{label:`Subtask runner`,htmlFor:`${a}-runner`,children:(0,Q.jsxs)(`select`,{id:`${a}-runner`,"data-slot":`dispatch-runner`,className:Lx,value:s.runner??``,onChange:e=>c({runner:e.target.value===``?void 0:e.target.value,model:void 0}),children:[(0,Q.jsx)(`option`,{value:``,children:`same as parent`}),u.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.label},e.id))]})}),(0,Q.jsx)(Ix,{label:`Subtask model`,htmlFor:`${a}-model`,children:(0,Q.jsxs)(`select`,{id:`${a}-model`,"data-slot":`dispatch-model`,className:Lx,value:s.model??``,onChange:e=>c({model:e.target.value===``?void 0:e.target.value}),children:[(0,Q.jsx)(`option`,{value:``,children:`same as parent`}),l.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.label},e.id)),s.model!==void 0&&!l.some(e=>e.id===s.model)?(0,Q.jsx)(`option`,{value:s.model,children:s.model}):null]})}),(0,Q.jsx)(Ix,{label:`Budget per subtask`,htmlFor:`${a}-budget`,children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(Kc,{id:`${a}-budget`,"data-slot":`dispatch-budget`,type:`number`,inputMode:`decimal`,placeholder:`none`,step:.5,min:zx,max:Bx,className:`h-7 w-24 px-2 text-xs md:text-xs`,value:s.budgetUsd??``,onChange:e=>{let t=e.target.value,n=Number(t);c({budgetUsd:t===``||!Number.isFinite(n)||n<=0?void 0:Math.min(Bx,Math.max(zx,n))})}}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`USD`})]})})]}),(0,Q.jsxs)(`p`,{className:`text-xs leading-snug text-muted-foreground`,children:[`The engine keeps its own brakes: `,4,` in flight and budgets carved out of this task's. These only tell the agent what you want.`]})]})}function Ux({label:e,url:t,hint:n,showIcon:r=!0,copySlot:i=`bm-copy`}){let a=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{a.current?.setAttribute(`href`,t)},[t]);let o=async()=>{try{await el(t),Y(`Bookmarklet URL copied.`)}catch{Y(`Copy failed — drag the button instead.`,{tone:`danger`})}};return(0,Q.jsxs)(`div`,{"data-slot":`bm-row`,className:`flex min-w-0 items-center gap-2.5`,children:[(0,Q.jsxs)(`a`,{ref:a,draggable:!0,"data-slot":`bm-link`,title:`Drag me to your bookmarks bar`,onClick:e=>{e.preventDefault(),Y(`Drag me to your bookmarks bar`)},className:`inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border bg-card px-2.5 py-1 font-mono text-xs font-medium text-foreground shadow-xs transition-colors hover:bg-muted`,children:[r?(0,Q.jsx)(Uo,{"aria-hidden":`true`,className:`size-3 text-primary`}):null,e]}),(0,Q.jsx)(`button`,{type:`button`,"data-slot":i,title:`Copy the bookmarklet URL`,onClick:()=>void o(),className:`shrink-0 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground`,children:`Copy`}),n?(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-meta text-soft-foreground`,children:n}):null]})}var Wx=`http://localhost:4321`;function Gx(e,t,n,r=Wx,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)}`}var Kx={ai:`From this project’s .ai/skills; always enabled while present.`,cezar:`From this project’s .ai/cezar/skills; always enabled while present.`,agents:`From .agents/skills or an agent-specific folder; always enabled while present.`,global:`User-wide from ~/.agents/skills or ~/.claude/skills, shared across projects.`,team:`Shared from a team repository configured for this project; importable skills can be enabled or disabled here.`,builtin:`Built into Cezar rather than installed from a skill repository.`};function qx({source:e,className:t,teamRepo:n}){let r=Do({source:e}),i=e===`team`&&n?`Shared from ${n}, a team skills repository configured for this project.`:Kx[e];return(0,Q.jsx)(kc,{delayDuration:300,children:(0,Q.jsxs)(Ac,{children:[(0,Q.jsx)(Dc,{asChild:!0,children:(0,Q.jsx)(`span`,{"data-slot":`skill-source`,"data-source":e,"aria-label":i,className:W(`shrink-0 rounded-full border border-border px-2 py-px font-mono text-micro`,r?`font-semibold text-foreground`:`text-soft-foreground`,t),children:e})}),(0,Q.jsx)(Oc,{side:`top`,sideOffset:6,className:`max-w-[260px]`,children:i})]})})}function Jx({skill:e,usedBy:t,heading:n=`h2`,enabled:r=!0,activation:i}){return(0,Q.jsxs)(`div`,{"data-slot":`skill-detail`,className:`mx-auto w-full min-w-0 max-w-[var(--measure)]`,children:[(0,Q.jsxs)(`section`,{"data-slot":`skill-properties`,className:`rounded-lg border border-border bg-muted/20 p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2.5`,children:[(0,Q.jsx)(n,{className:`min-w-0 font-mono text-lg font-semibold break-all`,children:e.name}),(0,Q.jsx)(qx,{source:e.source,teamRepo:e.team?.repo})]}),(0,Q.jsxs)(`p`,{"data-slot":`skill-path`,className:`mt-1 font-mono text-micro break-all text-soft-foreground`,children:[e.path,e.team?` · from ${e.team.repo}`:``]}),e.description?(0,Q.jsx)(`p`,{"data-slot":`skill-description`,className:`mt-2.5 text-ui text-muted-foreground`,children:e.description}):null]}),i?(0,Q.jsx)(ff,{"data-slot":`skill-activation-detail`,"aria-label":i.ariaLabel,checked:i.checked,disabled:i.disabled,onCheckedChange:i.onCheckedChange,size:`sm`,className:`mt-1.5 shrink-0`}):null]}),r?(0,Q.jsx)(Yx,{skill:e}):null,t===void 0?null:(0,Q.jsxs)(`section`,{"data-slot":`skill-used-by`,className:`mt-4 border-t border-border pt-4`,children:[(0,Q.jsx)(`h3`,{className:`eyebrow text-soft-foreground`,children:`Used by`}),t.length>0?(0,Q.jsx)(`ul`,{className:`mt-1.5 flex flex-col gap-1`,children:t.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-1.5 font-mono text-xs text-muted-foreground`,children:[(0,Q.jsx)(co,{"aria-hidden":`true`,className:`size-3 shrink-0 text-soft-foreground`}),e]},e))}):(0,Q.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:`Not referenced by any workflow yet — quick-task picks it up when the task mentions it.`})]})]}),(0,Q.jsxs)(`section`,{"data-slot":`skill-content`,className:`mt-6 min-w-0 border-t border-border pt-5`,children:[(0,Q.jsx)(`h3`,{className:`eyebrow text-soft-foreground`,children:`Content`}),(0,Q.jsx)(`div`,{"data-slot":`skill-body`,className:`mt-3 text-sm`,children:(0,Q.jsx)(ol,{children:e.body})})]})]})}function Yx({skill:e}){let t=Fe(),n=C(),r=a(),[i,o]=(0,Z.useState)(!1),s=t.data?.key??``,c=window.location.origin,l=kr()??n.data?.bootProject??null,u=r.data?.projects.find(e=>e.id===l)?.name??nA(n.data)?.name??null,d=Gx(e.name,i,s,c,l);return(0,Q.jsxs)(`section`,{"data-slot":`skill-run-from-github`,className:`mt-5 border-t border-border pt-4`,children:[(0,Q.jsx)(`h3`,{className:`eyebrow text-soft-foreground`,children:`Run from GitHub`}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`Drag the button to your bookmarks bar, then click it on a GitHub PR or issue.`}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 text-xs font-medium`,children:[(0,Q.jsx)(ff,{"data-slot":`bookmarklet-auto`,size:`sm`,"aria-label":`Start automatically`,checked:i,onCheckedChange:o}),(0,Q.jsx)(`span`,{children:`Start automatically`})]}),(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(Ux,{label:u?`/${e.name} (${u})`:`/${e.name}`,url:d,showIcon:!1,copySlot:`skill-bookmarklet-copy`})}),(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`To update an existing bookmarklet after changing this option, drag the button to your bookmarks bar again.`}),(0,Q.jsx)(K,{to:`/settings/bookmarklets`,"data-slot":`skill-bookmarklets-settings`,className:`mt-2 inline-block text-xs font-medium text-violet hover:underline`,children:`Manage saved bookmarklets`})]})}function Xx({skill:e,onClose:t}){return(0,Q.jsx)(qr,{open:e!==null,onOpenChange:e=>e?void 0:t(),children:(0,Q.jsx)(Wr,{"data-slot":`skill-preview`,className:`block max-h-[80dvh] overflow-y-auto sm:max-w-2xl`,children:e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Zr,{className:`sr-only`,children:e.name}),(0,Q.jsx)(Vr,{className:`sr-only`,children:`Skill preview with GitHub launcher`}),(0,Q.jsx)(Jx,{skill:e,heading:`h3`}),(0,Q.jsx)(`p`,{className:`mt-5`,children:(0,Q.jsx)(K,{to:`/skills?skill=${encodeURIComponent(e.name)}`,"data-slot":`skill-preview-manage`,onClick:t,className:`text-xs font-semibold text-violet hover:underline`,children:`Open in the Skills catalog`})})]}):null})})}function Zx({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}=po(so(n,c,r),r),g=i.find(e=>e.name===Bo),_=lo(i,c).filter(e=>e.name!==Bo),v=mo(`no skill`,`none plain ${Bo} ${g?.description??``}`,c)>0,y=!v&&p.length===0&&m.length===0&&h.length===0&&_.length===0,b=e=>{a(e),s(!1)},x=t=>b(e?.source===t.source&&e.ref===t.ref?null:t),S=(t,n)=>{let r=e?.source===`skill`&&e.ref===t.name;return(0,Q.jsxs)(Bi,{value:`skill ${t.name} ${t.path}`,keywords:uo(t.name,t.description),"data-slot":`source-option`,"data-source-kind":`skill`,"data-source-ref":t.name,onSelect:()=>x({source:`skill`,ref:t.name}),children:[(0,Q.jsx)(`span`,{className:W(`shrink-0 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)(lc,{"aria-hidden":`true`,className:`size-3.5`})}),r?(0,Q.jsx)(Rs,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},t.path)},C=e===null?xc:e.source===`skill`?Ko:mc,w=(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:W(ns,`text-meta`,e===null?`border-dashed text-soft-foreground`:`rounded-r-none border-r-0 border-foreground/60 pr-1.5 text-foreground`),children:[(0,Q.jsx)(C,{"aria-hidden":`true`,className:W(`size-3 shrink-0`,e===null?`text-soft-foreground`:`text-violet`)}),(0,Q.jsx)(`span`,{className:`max-w-44 truncate`,children:t?e?.ref??`Skill`:`…`}),ms]});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Xx,{skill:u,onClose:()=>d(null)}),(0,Q.jsxs)(Hr,{open:o,onOpenChange:e=>{s(e),e||l(``)},children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center`,children:[(0,Q.jsx)(Jr,{asChild:!0,children:w}),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:W(ns,`rounded-l-none border-foreground/60 pl-1.5 pr-2 text-soft-foreground hover:text-foreground`),children:(0,Q.jsx)(Tc,{"aria-hidden":`true`,className:`size-3`})}):null]}),(0,Q.jsx)(Kr,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Q.jsxs)(Ai,{shouldFilter:!1,children:[(0,Q.jsx)(Mi,{placeholder:`search skills & workflows…`,value:c,onValueChange:l,onInput:()=>f.current?.scrollTo(0,0)}),(0,Q.jsxs)(Li,{ref:f,"data-slot":`source-menu`,className:`max-h-[min(18rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[y?(0,Q.jsx)(Wi,{children:`Nothing matches.`}):null,v?(0,Q.jsx)(ji,{children:(0,Q.jsxs)(Bi,{value:`none no-skill`,keywords:[`none`,`plain`,...uo(Bo)],"data-slot":`source-option`,"data-source-kind":`none`,onSelect:()=>b(null),children:[(0,Q.jsx)(zr,{"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:g?.description??`One agent run on your task — no ceremony.`}),e===null?(0,Q.jsx)(Rs,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-primary`}):null]})}):null,p.length>0?(0,Q.jsx)(ji,{heading:`Most used`,children:p.map(e=>S(e,Do(e)))}):null,m.length>0?(0,Q.jsx)(ji,{heading:`Project skills`,children:m.map(e=>S(e,!0))}):null,_.length>0?(0,Q.jsx)(ji,{heading:`Workflows`,children:_.map(t=>{let n=e?.source===`workflow`&&e.ref===t.name;return(0,Q.jsxs)(Bi,{value:`workflow ${t.name}`,keywords:uo(t.name,t.description),"data-slot":`source-option`,"data-source-kind":`workflow`,"data-source-ref":t.name,onSelect:()=>x({source:`workflow`,ref:t.name}),children:[(0,Q.jsx)(`span`,{className:`shrink-0 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)(Rs,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-primary`}):null]},t.name)})}):null,h.length>0?(0,Q.jsx)(ji,{heading:`Global`,children:h.map(e=>S(e,!1))}):null]})]})})]})]})}function Qx(e,t,n){let r=e.skill===``?{source:`workflow`,ref:`quick-task`}:{source:`skill`,ref:e.skill};return os({task:e.ref,source:r,model:``,runner:t,defaultRunner:n,variants:1,images:[],todoId:e.todo})}function $x(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 eS(e,t){return`Use the "${e}" skill on: ${t}`}function tS(e,t){return t&&e===`source-dependent`?!1:e}function nS(e,t){return e.worktree===null?null:(e.worktreeBasis??`default`)===(t??`default`)?e.worktree:null}function rS(e){let t=e.dispatch===!0,n=e.configuredAutonomous===`source-dependent`?e.source===`skill`:e.configuredAutonomous,r=e.interactive!==!0&&void 0;return{autonomous:e.explicitAutonomous??(t?!0:void 0)??r??n,worktree:e.hasGit?e.variants>1||t?!0:e.explicitWorktree??r??e.configuredWorktree:!1}}function iS(e){return e.readOnly===!0&&e.hasGit?`Asks a read-only question about the current checkout — no branch, nothing to clean up.`:e.dispatch===!0?e.autonomous===!0?`Runs on its own and fans work out to subtasks — it will not pause for you.`:`Fans work out to subtasks in isolated worktrees.`:e.worktree?`Runs in an isolated worktree — review everything before it lands.`:e.hasGit&&e.newBranch?`Runs in the repo working tree on a new branch from base — your checkout switches to it.`:e.hasGit&&e.autoLand?e.autonomous===!0?`Runs in the repo working tree, one write task at a time — finished work is checked and lands on the base branch.`:`Runs in the repo working tree, one write task at a time — review the changes, then Commit lands them on the base branch.`: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 aS={text:``,source:null,runner:null,agentProfile:null,model:null,reasoningEffort:null,variants:1,worktree:null,autonomous:null,generateFollowups:null,dispatch:null},oS=`cez-new-task-draft`;function sS(e){return e===null?oS:`${oS}:${e}`}function cS(e){let t=e&&typeof e==`object`?e:{};return{text:typeof t.text==`string`?t.text:``,source:uS(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,reasoningEffort:typeof t.reasoningEffort==`string`?t.reasoningEffort:null,variants:t.variants===2||t.variants===3?t.variants:1,worktree:typeof t.worktree==`boolean`?t.worktree:null,...typeof t.worktreeBasis==`string`?{worktreeBasis:t.worktreeBasis}:{},...t.newBranch===!0?{newBranch:!0}:{},...typeof t.branchName==`string`&&t.branchName?{branchName:t.branchName}:{},autonomous:typeof t.autonomous==`boolean`?t.autonomous:null,generateFollowups:typeof t.generateFollowups==`boolean`?t.generateFollowups:null,dispatch:lS(t.dispatch),...typeof t.readOnly==`boolean`?{readOnly:t.readOnly}:{}}}function lS(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n={},r=(e,t)=>typeof e==`number`&&Number.isInteger(e)&&e>=1&&e<=t?e:void 0,i=r(t.maxSubtasks,50);i!==void 0&&(n.maxSubtasks=i);let a=r(t.inFlight,4);return a!==void 0&&(n.inFlight=a),typeof t.runner==`string`&&Ss.some(e=>e.id===t.runner)&&(n.runner=t.runner),typeof t.model==`string`&&t.model!==``&&t.model.length<=120&&(n.model=t.model),typeof t.budgetUsd==`number`&&Number.isFinite(t.budgetUsd)&&t.budgetUsd>0&&t.budgetUsd<=1e4&&(n.budgetUsd=t.budgetUsd),n}function uS(e){return!!e&&typeof e==`object`&&(e.source===`skill`||e.source===`workflow`)&&typeof e.ref==`string`}var dS=new Map;function fS(e=null){let t=sS(e),n=dS.get(t);if(n)return{...n};let r;try{let e=localStorage.getItem(t);r=e?cS(JSON.parse(e)):{...aS}}catch{r={...aS}}return dS.set(t,r),{...r}}function pS(e,t=null){let n=sS(t);dS.set(n,{...e});try{localStorage.setItem(n,JSON.stringify(e))}catch{}}function mS(e=null){let{branchName:t,readOnly:n,...r}=fS(e);pS({...r,text:``,source:null},e)}var hS=new Map;function gS(e=null){return[...hS.get(sS(e))??[]]}function _S(e,t=null){let n=sS(t);e.length===0?hS.delete(n):hS.set(n,[...e])}function vS(e,t){if(e===t)return{moved:!1,reason:`same-project`};let n=fS(e),r=gS(e);if(n.text===``&&r.length===0)return{moved:!1,reason:`nothing-to-move`};let i=fS(t);return i.text!==``||gS(t).length>0?{moved:!1,reason:`destination-busy`}:(pS({...i,text:n.text},t),pS({...n,text:``},e),_S(r,t),_S([],e),{moved:!0})}var yS=new Map;function bS(e){return`cez-pending-schedule:${e??`default`}`}function xS(e){let t=yS.get(e);if(t)return t;try{let t=JSON.parse(sessionStorage.getItem(e)??`null`);if(nr.safeParse(t).success)return t}catch{}return null}function SS(e,t){t?yS.set(e,t):yS.delete(e);try{t?sessionStorage.setItem(e,JSON.stringify(t)):sessionStorage.removeItem(e)}catch{}}function CS(){let[e]=hr(),t=vr(),n=U(),{projectId:r}=Mr(),i=at().projectId,o=a(),[s]=(0,Z.useState)(()=>Uv(e)),c=C(),l=ut(),u=ie(),d=ln(),f=Ft(),p=ht(),m=sv(),h=(0,Z.useRef)(null),g=En(),_=Ht(),[v,y]=(0,Z.useState)(()=>({...fS(i),...s.ref===``?{}:{text:s.ref},...s.skill===``?{}:{source:{source:`skill`,ref:s.skill}}}));(0,Z.useEffect)(()=>{pS(v,i)},[v,i]);let b=e=>y(t=>({...t,...e})),[x,S]=(0,Z.useState)(()=>gS(i));(0,Z.useEffect)(()=>{_S(x,i)},[x,i]);let w=f.data?.recentSources,D=u.data,O=f.data?.skillUsage,k=(0,Z.useMemo)(()=>fo(D??[],O),[D,O]),A=l.data?.workflows??[],j=o.data?.projects??[],M=e=>o.data?.bootProject===e?null:e,N=u.isError&&u.data===void 0||l.isError&&l.data===void 0,P=!u.isPending&&!l.isPending&&!f.isPending,F=g.data?.taskWorkspace===`in-place`,ee=d.data?.info!=null&&(F||g.data?.profile===`trunk`),te=ee&&v.variants<=1&&v.dispatch===null&&(v.readOnly??(g.data?.profile===`trunk`&&ks(v.text))),I=(N?v.source:is(v.source,k,A))??bs(g.data,te,N?null:k),ne=I?.source===`skill`?k.find(e=>e.name===I.ref):void 0,L=(0,Z.useRef)(null),re=(0,Z.useMemo)(()=>xo(So(f.data?.promptTemplates),c.data?.capabilities),[f.data?.promptTemplates,c.data?.capabilities]),ae=Mo(re,I?.source===`skill`?[I.ref]:[]),oe=(0,Z.useRef)(v.text);oe.current=v.text;let se=(0,Z.useRef)(``);(0,Z.useEffect)(()=>{if(!P)return;let e=Co(oe.current,se.current,ae);se.current=e.applied,e.text!==oe.current&&b({text:e.text})},[ae,P]);let ce=St(),le=hn(ce.data),R=g.data?.defaultRunner,de=R??`claude`,fe=le.length>0?Is(v.runner,le,de):null,pe=fe??de,z=ce.isSuccess&&le.length>0,me=E(pe),he=g.data?.modelsLocked===!0,ge=fe===null?[]:ws(fe,me.data,[v.model,g.data?.defaultModels?.[fe]]),_e=fe===null?``:es(he?null:v.model,fe,g.data?.defaultModels,me.data),ve=fe===null?``:js(v.reasoningEffort,fe,_e,me.data),ye=fe===null?[]:ds(fe,_e,me.data),{accounts:be,repoAccount:xe}=Yo(),Se=be.some(e=>e.provider===pe&&e.id===v.agentProfile)?v.agentProfile:null,Ce=Ho(pe,Se??xe?.[pe]),we=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{let e=z&&!we.current;we.current=z,e&&document.activeElement===document.body&&document.querySelector(`textarea[aria-label="Describe a task for the agent"]`)?.focus()},[z]);let Te=d.data===void 0||d.data.info!==null,Ee=Te?v.variants:1,De=Te,Oe=c.data?.capabilities.dispatch===!0&&Te,ke=Oe?v.dispatch:null,Ae=ke!==null,[je,Me]=(0,Z.useState)(!1),[Ne,Pe]=(0,Z.useState)(!1),Fe=(0,Z.useRef)(null),Ie=e=>{b({dispatch:e}),Fe.current!==null&&clearTimeout(Fe.current),Fe.current=null,Me(e!==null),e!==null&&(Fe.current=setTimeout(()=>Me(!1),6e3))};(0,Z.useEffect)(()=>()=>{Fe.current!==null&&clearTimeout(Fe.current)},[]);let Le=Ee>1||Ae,Re=rS({hasGit:Te,variants:Ee,explicitAutonomous:v.autonomous,explicitWorktree:nS(v,g.data?.taskWorkspace),interactive:ne?.interactive,configuredAutonomous:tS(_.data?.composerDefaults?.autonomous??_.data?.composerDefaults?.inheritedAutonomous??`source-dependent`,g.data?.landing===`auto`),configuredWorktree:g.data?.taskWorkspace?g.data.taskWorkspace===`worktree`:_.data?.composerDefaults?.worktree??_.data?.composerDefaults?.inheritedWorktree??!0,source:I?.source??`workflow`,dispatch:Ae}),ze=te&&!Ae&&Ee<=1,Be=Re.worktree&&!ze,Ve=Re.autonomous,He=c.data===void 0||c.data.capabilities.followups,Ue=He?v.generateFollowups??f.data?.lastGenerateFollowups??!0:!1,[We,Ge]=(0,Z.useState)(()=>s.auto&&s.ref!==``),[Ke,qe]=(0,Z.useState)(()=>!s.auto&&s.ref!==``?{kind:`prefill`}:null),Je=(0,Z.useRef)(!1),Ye=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{Je.current||(Je.current=!0,e.toString()!==``&&t(`/new`,{replace:!0}))},[]),(0,Z.useEffect)(()=>{if(!Ye.current&&!(!s.auto||s.ref===``)&&!ce.isPending){if(ct.current){Ye.current=!0,Ge(!1),qe({kind:`prefill`});return}if(!z||fe===null){Ye.current=!0,qe({kind:`prefill`}),Ge(!1);return}if(!g.isPending){if(Ye.current=!0,R===void 0){qe({kind:`prefill`}),Ge(!1);return}if(fe!==R){qe({kind:`prefill`}),Ge(!1);return}(async()=>{let e=``;try{e=(await vn()).key}catch{}if(e!==``&&s.key===e)try{let e=await T(Qx(s,fe,R));fs(`bookmarklet`),mS(i),n.invalidateQueries({queryKey:V.runs.all}),t(Jo(e));return}catch(e){qe({kind:`failed`,message:e instanceof Error?e.message:String(e)})}else qe({kind:`blocked`});Ge(!1)})()}}},[g.isPending,R,ce.isPending,z,fe]),(0,Z.useEffect)(()=>{if(Ke===null||!P)return;qe(null);let e=s.skill!==``&&!N&&!k.some(e=>e.name===s.skill)?s.skill:``;e!==``&&b({text:eS(s.skill,s.ref),source:null});let{message:t,tone:n}=$x(Ke,e);Y(t,{tone:n}),document.querySelector(`[data-slot="composer"] button[aria-label="Start task"]`)?.focus()},[Ke,P]);let[Xe,Ze]=(0,Z.useState)(null),[Qe,$e]=(0,Z.useState)(),[et,tt]=(0,Z.useState)(),[nt,rt]=(0,Z.useState)(!1),it=bS(i),[ot,st]=(0,Z.useState)(()=>xS(it)),ct=(0,Z.useRef)(ot),[lt,dt]=(0,Z.useState)(!1),[ft,pt]=(0,Z.useState)(),mt=async(e,r)=>{SS(it,null),Ng(),r||mS(i),ct.current=null,st(null),await n.invalidateQueries({queryKey:fi()}),e.outcome===`cancelled`&&Y(`The original schedule was already cancelled.`),t(e.outcome===`launched`&&e.runIds[0]?`/tasks/${e.runIds[0]}`:`/`)},gt=async(e,t=!1)=>{let n=ct.current!==null;ct.current=e,SS(it,e);let r;try{r=await ue(e)}catch(t){throw!n&&t instanceof cn&&(t.status===400||t.status===409&&(t.message===`Settings or reset time changed. Check the preview again.`||t.message===`Automations are off — this cockpit was started with CEZ_AUTOMATIONS=0`))?(SS(it,null),ct.current=null,st(null),Ze(e=>e&&{start:e.start,invalidated:t.message})):st(e),t}await mt(r.scheduled,t)},_t=async()=>{if(!(!ct.current||lt)){dt(!0),pt(void 0);try{await gt(ct.current,!0)}catch(e){pt(e instanceof Error?e.message:String(e))}finally{dt(!1)}}},vt=(e,t)=>os({task:e.trim(),source:I,model:_e,reasoningEffort:ve,modelsLocked:he,runner:fe??R??`claude`,runnerExplicit:v.runner!==null,agentProfile:Se,defaultRunner:R,variants:Ee,images:t,worktree:Be,newBranch:v.newBranch,branch:v.branchName,autonomous:Ve,generateFollowups:Ue,todoId:s.todo,dispatch:ke,readOnly:ze,inPlaceByDefault:F}),yt=x.length?`Remove attachments to schedule this task.`:s.todo?`Tasks linked to a todo can only start now.`:c.data?.capabilities?.automations===!0?void 0:`Scheduling is disabled on this server.`,bt=vt(v.text,x),xt=!yt&&!!Xe?.preview&&Date.parse(Xe.preview.notBefore)>Date.now()&&Xe.settingsKey===px(bt);return We?(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)(tl,{}),(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-ui text-muted-foreground`,children:`Launched from a bookmarklet — taking you to the run.`})]})]}):(0,Q.jsx)(`div`,{"data-route":`new`,"data-onboarding":``,className:`relative isolate flex min-h-full flex-col items-center overflow-x-clip px-6 pt-[clamp(32px,7vh,84px)] pb-16 max-md:px-3.5 max-md:pt-7`,children:(0,Q.jsxs)(`div`,{ref:h,className:`relative w-full max-w-[720px]`,children:[(0,Q.jsxs)(`header`,{className:`mb-7 text-center max-md:mb-5`,children:[(0,Q.jsx)(`h1`,{className:`text-4xl font-light tracking-tight text-balance text-foreground max-md:text-3xl`,children:`What should the agent work on?`}),(0,Q.jsx)(`p`,{"data-slot":`run-mode-note`,className:`mx-auto mt-3 max-w-md text-lead text-muted-foreground max-md:text-ui`,children:iS({worktree:Be,hasGit:Te,dispatch:Ae,autonomous:Ve,newBranch:v.newBranch,readOnly:ze,autoLand:g.data?.landing===`auto`&&g.data.landingBlocked===null})})]}),ot&&(0,Q.jsxs)(`div`,{role:`alert`,className:`mb-4 rounded-lg border p-4 text-sm`,children:[(0,Q.jsx)(`p`,{children:`The original task may already be scheduled. Recover it before starting another task.`}),(0,Q.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap`,children:ot.task.task}),(0,Q.jsx)(`p`,{className:`mt-2`,children:`Recovery uses the original prompt, settings and start time. Your current edits will not be submitted. If scheduling is disabled, restore it on the server and retry recovery; the original request is kept to prevent duplicates. Once recovered, you can manage the task in Scheduled.`}),(0,Q.jsx)(`button`,{type:`button`,className:`mt-3 underline`,disabled:lt,onClick:()=>void _t(),children:lt?`Recovering original schedule…`:`Recover original schedule`})]}),ft&&(0,Q.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm`,children:ft}),(0,Q.jsx)(To,{ref:L,onSubmit:async(e,r)=>{if(ct.current)throw Error(`Recover the original schedule before starting another task.`);if(!z||fe===null)throw Error(ce.isPending?`Checking agent providers…`:ce.isError?`Provider authentication could not be verified.`:`Connect an agent provider before starting a task.`);if(Ce.blocked!==null){let e=await Ce.verify();if(e!==null)throw Error(e)}if(!P)throw Error(`Still loading workflows and skills — try again in a second.`);let a=vt(e,r);if(Xe){if(yt||!Xe.preview||Date.parse(Xe.preview.notBefore)<=Date.now()||Xe.settingsKey!==px(a))throw Error(`Check the start time again after changing the task settings.`);await gt({task:a,start:Xe.start,previewRevision:Xe.preview.previewRevision,idempotencyKey:crypto.randomUUID()}),Ps(Xe.start.kind===`at`?`at`:`usage_reset`);return}let o=await T(a);fs(`new_task`),Yt({lastTask:I,...I?{recentSources:ps(w,I)}:{},...He?{lastGenerateFollowups:Ue}:{},...I?.source===`skill`&&f.data!==void 0?{skillUsage:oo(f.data.skillUsage,I.ref)}:{}}).then(()=>n.invalidateQueries({queryKey:V.uiState})).catch(()=>{}),mS(i),n.invalidateQueries({queryKey:V.runs.all}),t(Jo(o))},value:v.text,onValueChange:e=>b({text:e}),images:x,onImagesChange:S,autoFocus:!0,placeholder:`Describe a task for the agent — / for skills…`,ariaLabel:`Describe a task for the agent`,sendAriaLabel:Xe?`Schedule task`:`Start task`,sendLabel:Xe?`Schedule task`:void 0,submitDisabled:!!ot||lt||!P||!!Xe&&!xt,disabled:!z,disabledReason:ce.isPending?`Checking agent providers…`:ce.isError?`Provider authentication could not be verified.`:`Connect an agent provider before starting a task.`,autocompleteSkills:!0,sendShortcut:`↵`,sendMenu:(0,Q.jsx)(Sx,{task:bt,value:Xe,onChange:Ze,disabledReason:yt,onBlockedChange:$e,onLabelChange:tt,open:nt,onOpenChange:rt}),footerStart:(0,Q.jsxs)(Q.Fragment,{children:[j.length>1&&r!==void 0?(0,Q.jsx)(jS,{projects:j,projectId:r,onPick:e=>{let n=vS(i,M(e));!n.moved&&n.reason===`destination-busy`&&Y(`Kept your draft in ${j.find(e=>e.id===(i??o.data?.bootProject))?.name??r}; ${j.find(t=>t.id===e)?.name??e} already has an unsent draft.`,{tone:`danger`}),t(`/p/${encodeURIComponent(e)}/new`,{replace:!0})}}):null,(0,Q.jsx)(Zx,{source:I,ready:P,skills:k,skillUsage:O,workflows:A,onPick:e=>b({source:e})}),le.length>1||le.some(e=>Ns(be,e))?(0,Q.jsx)(xs,{runners:le,value:pe,accounts:be,account:Se,repoAccount:xe,onPick:(e,t)=>b({runner:e,agentProfile:t,...e===pe?{}:{model:null,reasoningEffort:null}}),disabled:!z}):null,(0,Q.jsx)(Os,{slot:`model-pill`,ariaLabel:`Model`,label:ge.find(e=>e.id===_e)?.label??`auto`,value:_e,disabled:!z,readOnly:he,disabledHint:he?`Model selection is locked to native coding-agent settings.`:void 0,onPick:e=>b({model:e,reasoningEffort:null}),options:ge.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:ss(pe,me.data,me.isError)}),(0,Q.jsx)(nl,{runner:pe,model:_e,value:ve,options:ye,disabled:!z,modelsLocked:he,onPick:e=>b({reasoningEffort:e||null})}),(0,Q.jsx)(Os,{slot:`variants-pill`,ariaLabel:`Parallel variants`,label:Ee>1?`×${Ee} variants`:`×1`,value:String(Ee),onPick:e=>b({variants:Number(e)}),disabled:!Te,hint:`How many times to run this task in parallel — each variant gets its own worktree, and you pick the diff you keep. ×1 runs it once.`,disabledHint:`Parallel variants need a git repository — each variant runs in its own worktree.`,options:[{value:`1`,label:`×1`,desc:`One run`},{value:`2`,label:`×2 variants`,desc:`Two competing runs — pick the diff you keep`},{value:`3`,label:`×3 variants`,desc:`Three competing runs — pick the diff you keep`}]}),(0,Q.jsx)(wS,{}),ee?(0,Q.jsx)(TS,{on:ze,auto:v.readOnly===void 0,onChange:e=>b({readOnly:e})}):null,De&&!ze?(0,Q.jsx)(ES,{on:Be,disabled:Le,disabledReason:Ae?`Dispatch forks this task's commits — subtasks need a worktree`:`Parallel variants always use isolated worktrees`,onChange:e=>b({worktree:e,worktreeBasis:g.data?.taskWorkspace??`default`})}):null,De&&!Be&&!ze?(0,Q.jsx)(DS,{on:v.newBranch===!0,name:v.branchName??``,onChange:e=>b({newBranch:e}),onNameChange:e=>b({branchName:e})}):null,(0,Q.jsx)(OS,{on:Ve,onChange:e=>b({autonomous:e})}),He?(0,Q.jsx)(kS,{on:Ue,onChange:e=>b({generateFollowups:e})}):null,re.length>0||Oe?(0,Q.jsx)(wS,{}):null,(0,Q.jsx)(ox,{templates:re,iconOnly:!0,onInsert:e=>L.current?.insertAtCaret(e)}),(0,Q.jsx)(Fx,{available:Oe,value:ke,onChange:Ie,onSettingsOpenChange:Pe,runners:le,parentRunner:pe,parentModels:ge}),d.data?.info?(0,Q.jsx)(wS,{}):null,d.data?(0,Q.jsx)(MS,{repo:d.data}):null,ne?.interactive&&(v.autonomous===null||v.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]}),footerEnd:(0,Q.jsxs)(Q.Fragment,{children:[Xe&&et&&!Qe?(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`schedule-summary`,title:et.title,onClick:()=>rt(!0),className:`flex max-w-[16rem] items-center gap-1 truncate rounded-md px-1.5 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,Q.jsx)(xl,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:et.text})]}):null,Xe&&Qe?(0,Q.jsx)(`span`,{role:`status`,"data-slot":`schedule-blocked`,title:Qe,className:`max-w-[16rem] truncate text-xs text-muted-foreground`,children:Qe}):null,!z&&!ce.isPending?(0,Q.jsx)(K,{to:`/settings/agents#providers`,className:`text-xs font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):null]})}),Ce.blocked===null?null:(0,Q.jsxs)(`p`,{"data-slot":`account-signed-out`,role:`alert`,className:`mt-2 rounded-md border border-destructive/30 bg-destructive/[0.07] px-3 py-1.5 text-xs text-muted-foreground`,children:[Ce.blocked,` `,(0,Q.jsx)(yr,{to:`/settings/global/accounts`,className:`font-medium text-foreground underline underline-offset-2`,children:`Agent accounts`})]}),Ae&&(Ne||je)?(0,Q.jsxs)(`p`,{"data-slot":`dispatch-hint`,className:`mt-2 rounded-md border border-primary/25 bg-primary/[0.07] px-3 py-1.5 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`strong`,{className:`font-semibold text-foreground`,children:`Dispatch is on.`}),` Splits this task into subtasks it runs as separate tasks. Worktree stays on. Long-press the icon for limits.`]}):null,(0,Q.jsx)(Ox,{anchorRoot:h,ready:z&&P&&!ot,loaded:p.data!==void 0,seen:p.data?.onboarding?.composerTipsSeen,off:p.data?.onboarding?.composerTipsOff,onSeen:e=>m(t=>({composerTipsSeen:Tx(t?.composerTipsSeen,e)})),onOff:e=>m({composerTipsOff:e})}),(0,Q.jsx)(PS,{onPick:e=>b({text:e})})]})})}function wS(){return(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-3.5 w-px shrink-0 bg-border max-md:hidden`})}function TS({on:e,auto:t,onChange:n}){return(0,Q.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,"data-slot":`ask-toggle`,onClick:()=>n(!e),title:e?`Read-only question — answers from the checkout, changes nothing${t?` (picked because the message is a question)`:``}`:`Check to ask a read-only question instead of filing a change`,className:W(ns,e&&`border-primary/60 text-foreground`),children:[e?(0,Q.jsx)(Rs,{"aria-hidden":`true`,className:`size-3 shrink-0 text-primary`}):(0,Q.jsx)(bc,{"aria-hidden":`true`,className:`size-3 shrink-0 text-soft-foreground`}),`Ask`]})}function ES({on:e,disabled:t,disabledReason:n,onChange:r}){return(0,Q.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,disabled:t,"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:W(ns,e&&`border-primary/60 text-foreground`),children:[e?(0,Q.jsx)(Rs,{"aria-hidden":`true`,className:`size-3 shrink-0 text-primary`}):(0,Q.jsx)(bc,{"aria-hidden":`true`,className:`size-3 shrink-0 text-soft-foreground`}),`Worktree`]})}function DS({on:e,name:t,onChange:n,onNameChange:r}){return(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,"data-slot":`new-branch-toggle`,onClick:()=>n(!e),title:e?`Switches the repo checkout to a new branch from the base before the agent starts`:`Runs on whatever branch is checked out — check to start a new branch from the base`,className:W(ns,e&&`border-primary/60 text-foreground`),children:[e?(0,Q.jsx)(Rs,{"aria-hidden":`true`,className:`size-3 shrink-0 text-primary`}):(0,Q.jsx)(bc,{"aria-hidden":`true`,className:`size-3 shrink-0 text-soft-foreground`}),`New branch`]}),e?(0,Q.jsx)(`input`,{"aria-label":`New branch name`,"data-slot":`new-branch-name`,value:t,placeholder:`feat/… (auto)`,onChange:e=>r(e.target.value),className:`h-6 w-36 rounded-md border border-input bg-card px-2 font-mono text-meta outline-none focus-visible:border-ring`}):null]})}function OS({on:e,disabled:t,onChange:n}){return(0,Q.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,disabled:t,"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:W(ns,e&&!t&&`border-primary/60 text-foreground`),children:[e?(0,Q.jsx)(Rs,{"aria-hidden":`true`,className:`size-3 shrink-0 text-primary`}):(0,Q.jsx)(bc,{"aria-hidden":`true`,className:`size-3 shrink-0 text-soft-foreground`}),`Autonomous`]})}function kS({on:e,onChange:t}){return(0,Q.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,"data-slot":`generate-followups-toggle`,onClick:()=>t(!e),title:e?`Agents can add newly discovered follow-up work to the task inbox`:`Follow-up generation is off; agents still maintain the handoff journal`,className:W(ns,e&&`border-primary/60 text-foreground`),children:[e?(0,Q.jsx)(Rs,{"aria-hidden":`true`,className:`size-3 shrink-0 text-primary`}):(0,Q.jsx)(bc,{"aria-hidden":`true`,className:`size-3 shrink-0 text-soft-foreground`}),`Follow-ups`]})}function AS(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 jS({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=AS(e,a);return(0,Q.jsxs)(Hr,{open:r,onOpenChange:e=>{i(e),e||o(``)},children:[(0,Q.jsx)(Jr,{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:W(ns,`border-foreground/60 text-foreground`),children:[(0,Q.jsx)(kl,{"aria-hidden":`true`,className:`size-3 shrink-0 text-soft-foreground`}),(0,Q.jsx)(`span`,{className:`max-w-40 truncate`,children:s?.name??t}),ms]})}),(0,Q.jsx)(Kr,{align:`start`,sideOffset:8,className:`w-[300px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Q.jsxs)(Ai,{shouldFilter:!1,children:[(0,Q.jsx)(Mi,{placeholder:`search projects…`,value:a,onValueChange:o}),(0,Q.jsxs)(Li,{"data-slot":`project-menu`,className:`max-h-[min(18rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[c.length===0?(0,Q.jsx)(Wi,{children:`Nothing matches.`}):null,c.map(e=>(0,Q.jsxs)(Bi,{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-meta text-soft-foreground`,children:`folder not found`}):e.branch===void 0?null:(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-meta text-soft-foreground`,children:e.branch}),e.id===t?(0,Q.jsx)(Rs,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},e.id))]}),(0,Q.jsx)(`p`,{className:`border-t border-border px-3 py-2 text-meta leading-snug text-soft-foreground`,children:`Skills, workflows, settings and the draft re-resolve against the selected project.`})]})})]})}function MS({repo:e}){let t=U(),n=H({mutationFn:e=>ve({baseBranch:e}),onSuccess:e=>{t.invalidateQueries({queryKey:V.repo}),Y(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=>Y(e.message,{tone:`danger`})});return e.info?(0,Q.jsx)(Os,{slot:`base-pill`,ariaLabel:`Base branch`,label:(0,Q.jsxs)(`span`,{className:`text-meta`,children:[`base: `,e.baseBranch??e.info.branch]}),value:e.baseBranch??``,onPick:e=>n.mutate(e===``?null:e),searchPlaceholder:`Search branches…`,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}var NS=[{icon:Dl,label:`Fix a failing test`,task:`Fix a failing or flaky test`},{icon:fc,label:`Summarize recent commits`,task:`Summarize recent commits on this branch`},{icon:_o,label:`Update the README`,task:`Update the README for recent changes`}];function PS({onPick:e}){return(0,Q.jsx)(`div`,{className:`mt-4 flex flex-wrap justify-center gap-2 max-md:justify-start`,children:NS.map(({icon:t,label:n,task:r})=>(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`suggested-chip`,onClick:()=>e(r),className:dv,children:[(0,Q.jsx)(t,{"aria-hidden":`true`,className:`size-3.5`}),n]},n))})}function FS(){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)(Cl,{}),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)(J,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(K,{to:`/`,children:`Back to tasks`})})})})}function IS(){return(0,Q.jsx)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(_c,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading repository…`,subtitle:`Fetching the repo's git state.`})})}function LS(){return(0,Q.jsxs)(`div`,{"data-route":`skills`,className:`flex min-h-full flex-col`,children:[(0,Q.jsxs)(`header`,{className:`sticky top-0 z-10 hidden h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-5 md:flex`,children:[(0,Q.jsx)(`h1`,{className:`text-base font-semibold`,children:`Skills`}),(0,Q.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:`Markdown playbooks agents can follow.`})]}),(0,Q.jsx)(`p`,{"data-slot":`skills-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading skills…`})]})}function RS({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)(jl,{}),tone:`neutral`,title:`“${e}” isn’t registered here`,subtitle:`This workspace doesn’t serve a project by that id. The link may come from another machine’s workspace — these are the projects this one can open:`,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)(yr,{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-meta font-normal text-soft-foreground`,children:[`/p/`,e.id]})]})},e.id))})})})}function zS(){return(0,Q.jsx)(`div`,{"data-route":`workflows`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(_c,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading workflows…`,subtitle:`Fetching the saved workflows and the node catalog.`})})}function BS(e){return Ss.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 VS=e=>e.length>Ss.length;function HS({rows:e,runner:t,accountFor:n,providerStatus:r,disabled:i=!1,accountDisabled:a=!1,onPick:o}){let s=VS(e);return(0,Q.jsx)(`div`,{role:`radiogroup`,"aria-label":`Default runner`,"data-slot":`agents-runner`,className:W(`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=Xt(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:W(`rounded-sm px-3 py-1.5 text-left font-mono text-ui 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-meta text-soft-foreground`,children:c.desc}):null]},`${c.runner.id}:${c.account??``}`)})})}function US({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=Mn(),_=f.trim();return(0,Q.jsx)(qr,{open:e,onOpenChange:t,children:(0,Q.jsxs)(Wr,{"data-slot":`add-account-dialog`,className:`sm:max-w-lg`,children:[(0,Q.jsxs)(Lr,{children:[(0,Q.jsx)(Zr,{children:`Add agent account`}),(0,Q.jsx)(Vr,{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-ui`,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-ui outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,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-ui`,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-ui 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-ui`,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:c===`codex`?`~/.codex-second`:c===`omp`?`~/.omp/agent-second`:`~/.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-label outline-none focus-visible:border-ring`}),(0,Q.jsx)(J,{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-meta text-soft-foreground`,children:[`A `,(0,Q.jsx)(`code`,{children:`~`}),` is kept as written and expanded when the agent runs.`]})]}),m?(0,Q.jsx)(of,{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-ui text-danger`,children:g.error instanceof Error?g.error.message:`could not add that folder`}):null,(0,Q.jsxs)(Br,{className:`min-w-0 sm:items-center sm:justify-end`,children:[(0,Q.jsx)(J,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(J,{"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),Y(`Account added — use Connect to sign in`)}})},children:g.isPending?`Adding…`:`Add account`})]})]})})}var WS={claude:`Claude Code`,codex:`Codex`,junie:`Junie`,opencode:`OpenCode`,cursor:`Cursor`,pi:`pi`,copilot:`GitHub Copilot CLI`,omp:`OMP`,antigravity:`Antigravity`,gemini:`Gemini CLI`,kimi:`Kimi Code`},GS={claude:`curl -fsSL https://claude.ai/install.sh | bash`,codex:`npm i -g @openai/codex`,junie:`https://www.jetbrains.com/junie/`,opencode:`https://opencode.ai`,cursor:`curl https://cursor.com/install -fsS | bash`,pi:`https://github.com/badlogic/pi-mono`,copilot:`npm i -g @github/copilot`,omp:`brew install can1357/tap/omp`,antigravity:`https://antigravity.google/docs/cli/`,gemini:`npm i -g @google/gemini-cli`,kimi:`https://moonshotai.github.io/kimi-code/`},KS={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 qS(){let e=pt();return e.isPending?(0,Q.jsx)(`p`,{"data-slot":`accounts-loading`,className:`p-4 text-ui text-soft-foreground md:p-6`,children:`Loading agent accounts…`}):e.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(Fl,{}),tone:`danger`,title:`Agent accounts did not load`,subtitle:e.error.message,heading:`h2`}):(0,Q.jsx)(JS,{data:e.data})}function JS({data:e}){let t=C(),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(null),o=Tn(),s=Xe,[c]=hr(),l=c.get(`agent`),u=s.find(e=>e===l)??`claude`;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.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Agent accounts`}),(0,Q.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:`One agent per tab: whether it is installed, and which logins you have. Add a second config folder to keep a work account beside a personal one; each project picks which it uses in its own Agents settings.`})]}),(0,Q.jsx)(XS,{profiles:e}),(0,Q.jsxs)(Gc,{defaultValue:u,children:[(0,Q.jsx)(Wc,{variant:`line`,"data-slot":`accounts-tabs`,children:s.map(e=>(0,Q.jsx)(Hc,{value:e,"data-provider":e,children:WS[e]},e))}),s.map(n=>(0,Q.jsx)(Uc,{value:n,className:`pt-4`,children:(0,Q.jsx)(YS,{provider:n,check:t.data?.checks?.find(e=>e.name===n),accounts:e.profiles.filter(e=>e.provider===n),canCarryAccounts:e.profileCapableProviders.includes(n),onAdd:()=>r(n),onRemove:a})},n))]},u),n===null?null:(0,Q.jsx)(US,{open:!0,onOpenChange:e=>!e&&r(null),providers:e.profileCapableProviders,initialProvider:n},n),(0,Q.jsx)(Vc,{open:i!==null,onOpenChange:e=>!e&&a(null),children:(0,Q.jsxs)(Ic,{"data-slot":`accounts-remove-confirm`,children:[(0,Q.jsxs)(Bc,{children:[(0,Q.jsxs)(Fc,{children:[`Remove “`,i?.label,`”?`]}),(0,Q.jsxs)(Pc,{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)(Rc,{children:[(0,Q.jsx)(zc,{children:`Cancel`}),(0,Q.jsx)(Lc,{"data-action":`accounts-remove-confirm`,disabled:o.isPending,onClick:()=>{let e=i;e&&o.mutate(e.id,{onSuccess:()=>{a(null),Y(`Removed ${e.label}`)},onError:e=>Y(e.message,{tone:`danger`})})},children:`Remove`})]})]})})]}):(0,Q.jsxs)(`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)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Agent accounts`}),(0,Q.jsx)(`p`,{"data-slot":`accounts-hosted`,className:`text-ui text-soft-foreground`,children:`Agent accounts are disabled for remote access. On a trusted, authenticated self-hosted deployment, set CEZ_REMOTE_AGENT_ACCOUNTS=1 and restart cezar.`})]})}function YS({provider:e,check:t,accounts:n,canCarryAccounts:r,onAdd:i,onRemove:a}){let o=t?.available===!0;return(0,Q.jsxs)(`div`,{"data-slot":`accounts-provider`,"data-provider":e,className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`dl`,{className:`divide-y divide-border/60 overflow-hidden rounded-md border border-border bg-card text-ui`,children:[(0,Q.jsx)(ZS,{label:`Installed`,children:t===void 0?(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Checking…`}):o?(0,Q.jsx)(`span`,{"data-slot":`agent-installed`,children:`Yes`}):(0,Q.jsxs)(`span`,{"data-slot":`agent-installed`,className:`text-muted-foreground`,children:[`No — `,(0,Q.jsx)(`code`,{className:`text-label`,children:GS[e]})]})}),o&&t?.version?(0,Q.jsx)(ZS,{label:`Version`,children:(0,Q.jsx)(`span`,{"data-slot":`agent-version`,className:`font-mono text-label`,children:t.version})}):null,(0,Q.jsx)(ZS,{label:`Accounts`,children:(0,Q.jsx)(`span`,{children:n.length===1?`the discovered one`:`${n.length} (1 discovered, ${n.length-1} added)`})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`h3`,{className:`text-ui font-semibold text-foreground`,children:`Logins`}),r?(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,"data-action":`accounts-add`,"data-provider":e,onClick:i,children:`Add account`}):null]}),(0,Q.jsx)(`ul`,{className:`divide-y divide-border/60 rounded-md border border-border bg-card`,children:n.map(e=>(0,Q.jsx)(QS,{account:e,onRemove:()=>a(e)},e.id))}),r?null:(0,Q.jsxs)(`p`,{"data-slot":`accounts-single-only`,className:`text-meta text-soft-foreground`,children:[WS[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 XS({profiles:e}){let t=U(),n=Ht(),r=St(),i=ge(),a=Re(),o=H({mutationFn:e=>mn(e),onSuccess:e=>t.setQueryData(B.config,e),onError:e=>Y(e.message,{tone:`danger`})});if(n.data===void 0)return null;let s=BS(e.profiles),c=n.data.agentDefaults.runner??`claude`,l=n.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-ui font-semibold text-foreground`,children:`Defaults for new projects`}),(0,Q.jsx)(`p`,{className:`text-ui 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)(HS,{rows:s,runner:c,accountFor:t=>e.defaults[t]??null,providerStatus:r,disabled:o.isPending,accountDisabled:a.isPending,onPick:(e,t,n)=>{e!==c&&o.mutate({agentDefaults:{runner:e}}),n&&a.mutate({projectId:null,provider:e,profileId:t},{onError:e=>Y(e.message,{tone:`danger`})})}}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Default model per agent`}),Ss.map(e=>(0,Q.jsxs)(`label`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`w-24 shrink-0 font-mono text-xs text-muted-foreground`,children:e.label}),(0,Q.jsxs)(`select`,{"aria-label":`Default model for ${e.label}`,"data-slot":`accounts-default-model`,"data-runner":e.id,value:l[e.id]??``,disabled:o.isPending,onChange:t=>o.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:[ws(e.id,i[e.id].data,[l[e.id]]).map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.id===``?`auto (default)`:e.label},e.id)),ss(e.id,i[e.id].data,i[e.id].isError)?(0,Q.jsx)(`option`,{disabled:!0,children:ss(e.id,i[e.id].data,i[e.id].isError)}):null]})]},e.id))]})]})}function ZS({label:e,children:t}){return(0,Q.jsxs)(`div`,{className:`flex items-baseline gap-3 px-3.5 py-2.5`,children:[(0,Q.jsx)(`dt`,{className:`w-28 shrink-0 text-muted-foreground`,children:e}),(0,Q.jsx)(`dd`,{className:`min-w-0 flex-1`,children:t})]})}function QS({account:e,onRemove:t}){let[n,r]=(0,Z.useState)(!1),i=qn(e),a=zn(),o=gn(),s=_n(i,e.status===void 0),c=e.status??s.data?.status,l=c?KS[c.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:`flex flex-wrap items-center justify-between gap-3`,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-ui font-medium text-foreground`,children:e.label}),e.isDefault?(0,Q.jsx)($d,{variant:`ghost`,className:`shrink-0 text-micro text-muted-foreground`,children:`discovered`}):null]}),(0,Q.jsx)(`p`,{"data-slot":`account-path`,className:`mt-0.5 truncate font-mono text-meta 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)(Jc,{tone:l?.tone??`neutral`,pulse:l===void 0}),(0,Q.jsx)(`span`,{"data-slot":`account-status`,children:l?.label??`Checking…`}),e.exists?e.looksValid?null:(0,Q.jsxs)(`span`,{"data-slot":`account-unrecognised`,children:[`— this folder does not look like `,WS[e.provider],` config yet`]}):(0,Q.jsx)(`span`,{"data-slot":`account-missing`,children:`— folder not created yet; Connect will make it`})]}),c?.status===`not-installed`&&c.hint?(0,Q.jsx)(`p`,{"data-slot":`account-install-hint`,className:`mt-1 text-xs text-soft-foreground`,children:c.hint}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[c?.status!==`connected`&&c?.status!==`not-installed`?(0,Q.jsx)(J,{type:`button`,size:`sm`,"data-action":`account-connect`,disabled:a.isPending,onClick:()=>a.mutate({provider:e.provider,...e.isDefault?{}:{profileId:e.id}},{onSuccess:e=>Y(e.opened?`Finish signing in in the terminal, then Check again.`:`This account is already connected.`),onError:e=>e instanceof cn&&e.command?Y(`${e.message} — run: ${e.command}`,{tone:`danger`,expected:!0}):Y(e.message,{tone:`danger`})}),children:`Connect`}):null,(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`account-recheck`,disabled:o.isPending,title:`Re-probe this account's login now, instead of waiting for the cached answer`,onClick:()=>o.mutate(i,{onError:e=>Y(e.message,{tone:`danger`})}),children:`Check again`}),(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`account-details-toggle`,"aria-expanded":n,onClick:()=>r(e=>!e),children:n?`Hide details`:`Show details`})]})]}),n?(0,Q.jsx)($S,{account:e,routeId:i,onRemove:t}):null]})}function $S({account:e,routeId:t,onRemove:n}){let r=C(),i=$t(t,!0),a=ze(),o=D(),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(e.label),d=it(),f=r.data?r.data.capabilities?.localHandoff??!0:!1,p=o.data?.targets??[],m=p.filter(e=>ls(e.id)===void 0&&e.id!==`terminal`&&e.id!==`finder`).map(e=>({target:e})),h=p.filter(e=>ls(e.id)===void 0).map(e=>({target:e})),g=(e,n,r)=>a.mutate({routeId:t,file:e,...r?{target:r}:{}},{onError:e=>Y(e.message,{tone:`danger`}),onSuccess:()=>Y(`Opened ${n}`)});return(0,Q.jsxs)(`div`,{"data-slot":`account-details`,className:`rounded-md border border-border/60 bg-muted/30 p-3`,children:[i.isPending?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Reading account details…`}):i.isError?(0,Q.jsx)(`p`,{"data-slot":`account-details-error`,className:`text-xs text-danger`,children:i.error.message}):i.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:i.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:i.data.reason??`No account details to show.`}),f?(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)(Ro,{slot:`account-open-file`,label:e.label,triggerVariant:`outline`,disabled:a.isPending,title:e.exists?e.path:`${e.path} — not created yet`,choices:m,onPick:t=>g(e.id,e.label,t),leading:(0,Q.jsxs)($s,{"data-target":`system`,onSelect:()=>g(e.id,e.label),children:[(0,Q.jsx)(ic,{"aria-hidden":`true`}),`System default`]})},e.id)),(0,Q.jsx)(Ro,{slot:`account-open-folder`,label:`Folder`,disabled:a.isPending,title:e.path,choices:h,onPick:e=>g(`folder`,`folder`,e),leading:(0,Q.jsxs)($s,{"data-target":`system`,onSelect:()=>g(`folder`,`folder`),children:[(0,Q.jsx)(ic,{"aria-hidden":`true`}),`System default`]})})]}):null,e.isDefault?null:(0,Q.jsxs)(`div`,{"data-slot":`account-manage`,className:`mt-3 flex flex-wrap items-center gap-2 border-t border-border/60 pt-2.5`,children:[(0,Q.jsx)(`span`,{className:`mr-1 text-xs text-muted-foreground`,children:`Account`}),s?(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:l,onChange:e=>u(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)(J,{type:`button`,size:`sm`,"data-action":`account-rename-save`,disabled:d.isPending||l.trim()===``||l.trim()===e.label,onClick:()=>d.mutate({id:e.id,label:l.trim()},{onSuccess:()=>c(!1),onError:e=>Y(e.message,{tone:`danger`})}),children:`Save`}),(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{u(e.label),c(!1)},children:`Cancel`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-rename`,onClick:()=>c(!0),children:`Rename`}),(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-remove`,onClick:n,children:`Remove`}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Renaming changes what cezar calls this account, not its folder.`})]})]})]})}var eC=1500;function tC(e,t){let n=(0,Z.useMemo)(()=>e.split(`
|
|
7
7
|
`).map(e=>[{content:e}]),[e]),r=(0,Z.useMemo)(()=>al(t),[t]),i=n.length>eC,[a,o]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{if(r===null||i)return;let t=!1;return il(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:rl(e,r)?.tokens??n}var nC=`m-0 min-h-full w-full whitespace-pre font-mono text-xs leading-[1.7] px-3 py-2 [tab-size:2]`;function rC({value:e,onChange:t,language:n,readOnly:r,className:i,...a}){let o=tC(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:W(`relative overflow-hidden rounded-md border border-input bg-card`,i),children:[(0,Q.jsx)(`pre`,{ref:s,"aria-hidden":`true`,className:W(nC,`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?`
|
|
@@ -27,5 +27,5 @@ $ git commit -m "Initial commit"`}),r.error?(0,Q.jsx)(`p`,{role:`alert`,classNam
|
|
|
27
27
|
`;function pC(e){return e.private?`Private to this project — added to every run at launch, takes effect on the next session. Never committed.`: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 mC(){let e=ct(),t=C(),n=(0,Z.useMemo)(()=>t.data?Es(t.data.checks):uC.map(e=>e.id),[t.data]);return e.isPending?(0,Q.jsx)(`p`,{"data-slot":`agent-config-loading`,className:`p-4 text-ui text-soft-foreground md:p-6`,children:`Loading agent config…`}):e.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(El,{}),tone:`danger`,title:`Agent config did not load`,subtitle:e.error.message,heading:`h2`}):(0,Q.jsx)(hC,{listing:e.data,installed:n})}function hC({listing:e,installed:t}){let[n,r]=(0,Z.useState)(`claude`),[i,a]=(0,Z.useState)(null),o=dC(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-4 p-4 md:p-6`,children:[!e.editable&&(0,Q.jsx)(`div`,{"data-slot":`agent-config-readonly`,className:`rounded-md border border-border bg-muted/40 px-3 py-2 text-ui text-soft-foreground`,children:`Read-only: agent config is edited from the machine that owns the checkout (this cockpit runs in hosted mode). You can still see every file and which one wins.`}),(0,Q.jsx)(`div`,{"data-slot":`agent-config-agents`,role:`tablist`,className:`flex flex-wrap gap-1 rounded-md bg-muted/40 p-1`,children:uC.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:W(`flex items-center gap-2 rounded-md px-3 py-1.5 text-ui 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)($d,{variant:`outline`,className:`text-micro text-soft-foreground`,children:`not installed`})]},e.id))}),o.note&&(0,Q.jsx)(`p`,{"data-slot":`agent-config-agent-note`,className:`text-label text-soft-foreground`,children:o.note}),(0,Q.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,20rem)_minmax(0,1fr)]`,children:[(0,Q.jsx)(`nav`,{"data-slot":`agent-config-nav`,className:`flex flex-col gap-5`,children:(0,Q.jsx)(gC,{agent:o,listing:e,selectedId:i,onSelect:a})}),(0,Q.jsx)(`div`,{"data-slot":`agent-config-editor-pane`,children:s?(0,Q.jsx)(vC,{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-ui text-soft-foreground`,children:`Select a config file to view or edit it.`})})]})]})}function gC({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)?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 eyebrow text-soft-foreground`,children:i.label}),i.note&&(0,Q.jsx)(`p`,{className:`mb-2 text-label text-soft-foreground`,children:i.note}),(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:W(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-ui transition-colors`,e.id===n?`bg-primary/15 text-foreground`:`hover:bg-muted/60`),children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-label`,children:e.label}),e.seeded&&(0,Q.jsx)($d,{variant:`outline`,className:`shrink-0 text-micro`,children:`seeded`}),e.private&&(0,Q.jsx)($d,{variant:`outline`,className:`shrink-0 text-micro`,children:`private`}),!e.exists&&(0,Q.jsx)(`span`,{className:`shrink-0 text-meta text-soft-foreground`,children:`absent`})]})},e.id))}),o&&t.userMcp&&(0,Q.jsx)(_C,{userMcp:t.userMcp})]},i.id)})})}function _C({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-label font-semibold`,children:`User & local scopes`}),(0,Q.jsxs)(`p`,{className:`mb-2 text-label 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)($d,{variant:`outline`,className:`font-mono text-meta`,children:e})},e))}):(0,Q.jsx)(`p`,{className:`text-label text-soft-foreground`,children:`No user-scoped MCP servers.`}):(0,Q.jsx)(`p`,{className:`text-label text-soft-foreground`,children:`Could not read the file.`})]})}function vC({file:e}){let t=Vt(e.id),n=Qt(e.id),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),l=t.data?.version??null;(0,Z.useEffect)(()=>{t.data&&(i(e.private&&!t.data.exists?fC:t.data.content),o(!1),c(null))},[t.data?.version,t.data]);let u=r??t.data?.content??``,d=t.data?u!==t.data.content:!1,f=e.writable;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-ui`,children:e.label}),(0,Q.jsx)($d,{variant:`outline`,className:`text-micro uppercase`,children:e.format}),(0,Q.jsx)(`a`,{href:e.docsUrl,target:`_blank`,rel:`noreferrer`,className:`text-label text-soft-foreground underline hover:text-foreground`,children:`docs`})]}),(0,Q.jsx)(`p`,{"data-slot":`agent-config-precedence`,className:`text-label text-soft-foreground`,children:e.precedence}),(0,Q.jsxs)(`p`,{"data-slot":`agent-config-effect`,className:`text-label text-foreground/80`,children:[pC(e),e.hotReload?` ${e.hotReload}`:``]}),t.isPending?(0,Q.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:`Loading file…`}):t.isError?(0,Q.jsx)(`p`,{className:`text-ui text-destructive`,children:t.error.message}):(0,Q.jsx)(rC,{value:u,language:e.format,readOnly:!f,onChange:e=>{i(e),c(null)},"aria-label":`${e.label} contents`,className:`h-[26rem]`}),s&&(0,Q.jsx)(`p`,{"data-slot":`agent-config-format-error`,className:`text-label text-destructive`,children:s}),a&&(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-label`,children:[(0,Q.jsx)(`span`,{children:`The file changed on disk since you opened it.`}),(0,Q.jsx)(J,{size:`sm`,variant:`outline`,onClick:()=>void t.refetch(),children:`Reload from disk`})]}),f&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(J,{size:`sm`,onClick:()=>{c(null),o(!1);let t=e.format===`json`?iC(u)??u:u;n.mutate({content:t,version:l},{onSuccess:()=>{i(null),Y(`${e.exists?`Saved`:`Created`} ${e.label}`)},onError:e=>{e instanceof cn&&e.status===409?o(!0):e instanceof cn&&e.status===400?c(e.message):Y(e.message,{tone:`danger`})}})},disabled:!d||n.isPending,children:e.exists?`Save`:`Create`}),(0,Q.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>{i(null),c(null)},disabled:!d||n.isPending,children:`Revert`}),d&&(0,Q.jsx)(`span`,{className:`text-label text-soft-foreground`,children:`Unsaved changes`})]})]})}var yC=[{id:`claude`,label:`Claude Code`,login:`claude auth login`},{id:`codex`,label:`Codex`,login:`codex login`},{id:`junie`,label:`Junie`,login:`junie login`},{id:`opencode`,label:`OpenCode`,login:`opencode auth login`},{id:`cursor`,label:`Cursor`,login:`agent login`},{id:`pi`,label:`pi`,login:`pi /login`},{id:`copilot`,label:`GitHub Copilot CLI`,login:`copilot login`},{id:`omp`,label:`OMP`,login:`omp`},{id:`antigravity`,label:`Antigravity`,login:`agy`},{id:`gemini`,label:`Gemini CLI`,login:`gemini`},{id:`kimi`,label:`Kimi Code`,login:`kimi login`}],bC=e=>({claude:e,codex:e,junie:e,opencode:e,cursor:e,pi:e,copilot:e,omp:e,antigravity:e,gemini:e,kimi:e}),xC={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 SC(e,t,n){return{providers:e.providers.map(e=>e.provider===t?{...e,enabled:n}:e)}}function CC(){let e=St(),t=rn(),n=Rn(),r=U(),[i,a]=(0,Z.useState)(null),o=(0,Z.useRef)(Promise.resolve()),s=(0,Z.useRef)(bC(0)),c=(0,Z.useRef)(bC(0)),l=(0,Z.useRef)(e.data);(0,Z.useEffect)(()=>{i&&Xt(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?Xt(l.current,e.provider)?.enabled??e.enabled:e.enabled}))}}},[e.data]);let f=(0,Z.useCallback)((e,t)=>{let n=B.providerStatus,i=r.getQueryData(n);if(!i)return;l.current||=i;let a=SC(i,e,t);c.current[e]+=1,r.setQueryData(n,a);let d=++s.current[e];o.current=o.current.then(async()=>{try{let i=await u(e,t),a=Xt(i,e)?.enabled;if(a===void 0)return;if(l.current=SC(l.current??i,e,a),d===s.current[e]){let t=r.getQueryData(n);r.setQueryData(n,t?SC(t,e,a):i)}}catch(t){if(d===s.current[e]){let i=Xt(l.current,e)?.enabled,a=r.getQueryData(n);a&&i!==void 0?r.setQueryData(n,SC(a,e,i)):l.current?r.setQueryData(n,l.current):r.removeQueries({queryKey:n,exact:!0}),Y(t instanceof Error?t.message:String(t),{tone:`danger`})}}finally{--c.current[e]}})},[r]),p=H({mutationFn:e=>d(e),onSuccess:async e=>{a(null),Y(e.opened?`Finish signing in in the terminal, then check again.`:`Provider is already connected.`),await r.invalidateQueries({queryKey:B.providerStatus})},onError:(e,t)=>{if(e instanceof cn&&e.command){let n=yC.find(e=>e.id===t)?.label??t;a({provider:t,label:n,message:e.message,command:e.command});return}Y(e.message,{tone:`danger`})}}),m=async e=>{try{await el(e),Y(`Command copied`)}catch{Y(`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-ui 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-ui 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)(J,{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:yC.map(r=>{let a=Xt(e.data,r.id),o=a?.status,s=o?xC[o]:e.isPending?{label:`Checking…`,tone:`neutral`}:xC.unknown,c=p.isPending&&p.variables===r.id,l=o===`disconnected`||o===`unknown`,u=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-ui 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)(Jc,{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:a?.hint??`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)(ff,{checked:a?.enabled??!0,"aria-label":`Use ${r.label}`,onCheckedChange:e=>f(r.id,e)}),l?(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,disabled:t.isPending,onClick:()=>t.mutate(void 0,{onError:e=>Y(e.message,{tone:`danger`})}),children:`Check again`}):null,o===`disconnected`?(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:p.isPending,onClick:()=>p.mutate(r.id),children:c?`Opening…`:`Connect`}):null,u===void 0?null:(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:n.isPending,onClick:()=>n.mutate({provider:r.id,authFailureId:u},{onSuccess:()=>Y(`${r.label} can be tried again.`),onError:e=>Y(e.message,{tone:`danger`})}),children:`Try again`})]})]}),u===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-ui 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)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void m(i.command),children:`Copy command`})]})]}):null]},r.id)})})]})}function wC(){let e=U();return H({mutationFn:e=>ve(e),onSuccess:t=>{e.setQueryData(V.config,t),e.invalidateQueries({queryKey:V.health}),e.invalidateQueries({queryKey:V.repo})},onError:e=>Y(e.message,{tone:`danger`})})}function TC(){let e=En(),t=ge(),n=St();return e.isPending?(0,Q.jsx)(`p`,{"data-slot":`agents-loading`,className:`p-4 text-ui text-soft-foreground md:p-6`,children:`Loading agent settings…`}):e.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(Lo,{}),tone:`danger`,title:`Agent settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,Q.jsx)(EC,{config:e.data,catalogs:t,providerStatus:n})}function EC({config:e,catalogs:t,providerStatus:n}){let r=wC(),i=at().projectId??`default`,a=Cn(i),o=Kn(i),s=pt(),c=ln().data?.info?.root,l=(c?s.data?.selections[c]:void 0)?.[e.defaultRunner]??s.data?.defaults[e.defaultRunner]??`default`;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)(CC,{}),(0,Q.jsx)(AC,{defaultRunner:e.defaultRunner,providerStatus:n,saving:r.isPending,onPick:e=>r.mutate({defaultRunner:e})}),(0,Q.jsx)(kC,{policy:a.data,loadError:a.isError?a.error:null,profiles:s.data?.profiles??[],providerStatus:n,catalogs:t,modelsLocked:e.modelsLocked,defaultProfileId:l,defaultRunner:e.defaultRunner,saving:o.isPending,onRetry:()=>void a.refetch(),onSave:(e,t,n)=>{a.data&&o.mutate({expectedRevision:a.data.revision,expectedIncarnation:a.data.incarnation,enabled:e,candidates:t??a.data.candidates},{onSuccess:()=>n?.(),onError:e=>{e instanceof cn&&e.status===409&&a.refetch(),Y(e instanceof cn&&e.status===409&&e.message.includes(`changed`)?`Fallback settings changed elsewhere — reloaded. Try again.`:e instanceof Error?e.message:`Could not save fallback settings`,{tone:`danger`})}})}}),(0,Q.jsx)(jC,{title:`Default models`,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 max-w-md flex-col gap-2`,children:Ss.map(i=>{let a=Xt(n.data,i.id),o=!n.isPending&&!n.isError&&a?.enabled===!0&&a.status===`connected`,s=n.isPending?`Checking provider authentication…`:n.isError?`Provider authentication could not be verified.`:a?.enabled===!1?`This provider is disabled. Enable it above or choose another provider.`:o?void 0:`Connect this provider before selecting it.`,c=t[i.id],l=ss(i.id,c.data,c.isError),u=ws(i.id,c.data,[e.defaultModels[i.id]]),d=e.defaultModels[i.id]??``,f=u.find(e=>e.id===d)?.label??d??`auto (default)`;return(0,Q.jsxs)(`label`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`w-24 shrink-0 font-mono text-xs text-muted-foreground`,children:i.label}),e.modelsLocked?(0,Q.jsx)(`output`,{"aria-label":`Default model for ${i.label}`,"data-slot":`agents-model`,"data-runner":i.id,title:`Model selection is locked to native coding-agent settings.`,className:`block w-full 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 ${i.label}`,"data-slot":`agents-model`,"data-runner":i.id,value:d,title:s??i.desc,disabled:r.isPending||!o,onChange:e=>r.mutate({defaultModels:{[i.id]:e.target.value||null},defaultModelsAuto:{[i.id]:e.target.value===``}}),className:`block w-full 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===``?`auto (default)`:e.label},e.id)),l?(0,Q.jsx)(`option`,{disabled:!0,children:l}):null]})]},i.id)})})})]})}function DC({id:e,label:t,disabled:n,children:r}){let{attributes:i,listeners:a,setNodeRef:o,setActivatorNodeRef:s,transform:c,transition:l,isDragging:u}=di({id:e,disabled:n});return(0,Q.jsxs)(`li`,{ref:o,"data-slot":`fallback-row`,style:{transform:ui.Transform.toString(c),transition:l},className:`relative flex flex-wrap items-center gap-2 rounded-md border border-border bg-card px-3 py-1.5 text-sm ${u?`z-10 shadow-md`:``}`,children:[(0,Q.jsx)(J,{ref:s,type:`button`,variant:`ghost`,size:`icon-sm`,className:`min-h-11 min-w-11 shrink-0 cursor-grab touch-none active:cursor-grabbing aria-disabled:cursor-default aria-disabled:opacity-50`,...i,...a,"aria-label":t,"aria-disabled":n||void 0,children:(0,Q.jsx)(io,{"aria-hidden":`true`})}),r]})}var OC=10;function kC({policy:e,loadError:t,profiles:n,providerStatus:r,catalogs:i,modelsLocked:a,defaultProfileId:o,defaultRunner:s,saving:c,onSave:l,onRetry:u}){let d=Di($r(Oi,{activationConstraint:{distance:4}}),$r(pi,{coordinateGetter:hi})),f=(0,Z.useRef)(null),p=`Automatic fallback`,m=`When the agent working on a task runs out of its usage allowance, the next agent below continues the same task.`,h=e=>Ss.find(t=>t.id===e)?.label??e,g=Ss.flatMap(e=>{let t=n.filter(t=>t.provider===e.id);return(t.length>0?t:[{id:`default`,provider:e.id,label:`Default`}]).map(t=>({key:`${e.id}:${t.id}`,provider:e.id,profileId:t.id,label:`${e.label} · ${t.id==="default"?`Default`:t.label||t.id}`}))}),_=e=>`${e.provider}:${e.profileId}`,v=new Set(e?.candidates.map(_)??[]),y=g.filter(e=>!v.has(e.key)),[b,x]=(0,Z.useState)(``),[S,C]=(0,Z.useState)(``),[w,T]=(0,Z.useState)(``),E=y.find(e=>e.key===b)??y[0];if(t){let e=t instanceof cn&&t.status===409&&t.message===`agent fallback is local-only`;return(0,Q.jsxs)(jC,{title:p,hint:m,children:[(0,Q.jsx)(`p`,{"data-slot":`fallback-unavailable`,className:`max-w-md text-ui text-muted-foreground`,children:e?`Automatic fallback is available on a local cockpit only.`:`Fallback settings did not load — ${t.message}`}),e?null:(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,className:`w-fit`,onClick:u,children:`Retry`})]})}if(!e)return(0,Q.jsx)(jC,{title:p,hint:m,children:(0,Q.jsx)(`p`,{"data-slot":`fallback-loading`,className:`text-ui text-soft-foreground`,children:`Loading fallback settings…`})});let D=e.candidates,O=e=>g.find(t=>t.key===_(e))?.label??`${h(e.provider)} · ${e.profileId}`,k=e=>{if(e.profileId!=="default"&&!n.some(t=>t.id===e.profileId&&t.provider===e.provider))return`Account removed — will be skipped`;if(a&&e.model)return`Model selection is locked — remove and add this agent again to use native settings.`;let t=Xt(r.data,e.provider);if(t?.enabled===!1)return`Provider disabled — will be skipped`;if(t&&t.status!==`connected`)return`Not connected — will be skipped`},A=e=>e.provider===s&&e.profileId===o?`This is the default agent — skipped for tasks that start on it`:void 0,j=()=>{if(!E||c)return;let t=E.label;l(e.enabled,[...D,{provider:E.provider,profileId:E.profileId,...!a&&S?{model:S}:{}}],()=>{x(``),C(``),T(`${t} added at position ${D.length+1}`)})},M=t=>{let n=D[t];if(!n||c)return;let r=D.filter((e,n)=>n!==t);l(e.enabled&&r.length>0,r,()=>T(`${O(n)} removed from fallback`))},N=(t,n)=>{let r=t+n,i=D[t];if(!i||c||r===t||r<0||r>=D.length)return;let a=D.filter((e,n)=>n!==t);a.splice(r,0,i),l(e.enabled,a,()=>T(`${O(i)} moved to position ${r+1}`))},P=E?.provider??s,F=i[P],ee=ss(P,F?.data,F?.isError??!1),te=D.length>=OC;return(0,Q.jsx)(jC,{title:p,hint:m,action:(0,Q.jsx)(ff,{"aria-label":`Automatic fallback`,"aria-describedby":`fallback-state fallback-disclosure`,"data-slot":`fallback-enabled`,checked:e.enabled,disabled:c||D.length===0,onCheckedChange:e=>l(e)}),children:(0,Q.jsxs)(`div`,{"data-slot":`fallback-section`,className:`flex max-w-md flex-col gap-3`,children:[(0,Q.jsx)(`p`,{id:`fallback-state`,className:`text-ui text-muted-foreground`,children:e.enabled?`On — agents take over in the order below.`:D.length===0?`Off — add an agent first.`:`Off — the list is saved but not used.`}),(0,Q.jsx)(`p`,{id:`fallback-disclosure`,className:`text-ui text-muted-foreground`,children:`The next agent’s provider receives the task and its repository context, and may bill its own plan.`}),D.length===0?(0,Q.jsx)(`p`,{"data-slot":`fallback-empty`,className:`text-ui text-muted-foreground`,children:`No fallback agents yet. Add the agent that should take over first.`}):(0,Q.jsx)(ki,{sensors:d,collisionDetection:li,accessibility:{screenReaderInstructions:{draggable:`Press Space to pick up an agent, arrow keys to move, Space to drop, or Escape to cancel.`},announcements:{onDragStart:({active:e})=>{let t=D.find(t=>_(t)===e.id);return t?`Picked up ${O(t)}.`:`Picked up agent.`},onDragOver:({over:e})=>e?`Position ${D.findIndex(t=>_(t)===e.id)+1} of ${D.length}.`:`Outside the list.`,onDragEnd:()=>`Drag ended. Changes are saved after dropping in a new position.`,onDragCancel:()=>`Reordering cancelled. Order unchanged.`}},onDragStart:()=>{f.current=e.revision},onDragCancel:()=>{f.current=null},onDragEnd:({active:t,over:n})=>{let r=f.current;if(f.current=null,!n||c||r!==e.revision)return;let i=D.findIndex(e=>_(e)===t.id),a=D.findIndex(e=>_(e)===n.id);i>=0&&a>=0&&N(i,a-i)},children:(0,Q.jsx)(Ci,{items:D.map(_),strategy:Ei,children:(0,Q.jsx)(`ol`,{"aria-label":`Fallback order`,"data-slot":`fallback-order`,className:`flex flex-col gap-1.5`,children:D.map((e,t)=>{let n=O(e),r=k(e),i=A(e);return(0,Q.jsxs)(DC,{id:_(e),label:`Reorder ${n}, position ${t+1} of ${D.length}`,disabled:c||D.length<2,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:[t+1,`.`]}),` `,n,(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,e.model??`auto model`]}),r?(0,Q.jsx)(`span`,{className:`block text-xs text-danger`,children:r}):null,i?(0,Q.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:i}):null]}),(0,Q.jsxs)(`span`,{className:`flex gap-1`,children:[(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`aria-disabled:opacity-50 aria-disabled:hover:bg-transparent`,"aria-label":`Move ${n} up`,"aria-disabled":c||t===0||void 0,onClick:()=>N(t,-1),children:(0,Q.jsx)(to,{})}),(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`aria-disabled:opacity-50 aria-disabled:hover:bg-transparent`,"aria-label":`Move ${n} down`,"aria-disabled":c||t===D.length-1||void 0,onClick:()=>N(t,1),children:(0,Q.jsx)(eo,{})}),(0,Q.jsx)(J,{type:`button`,variant:`danger-ghost`,size:`icon-xs`,className:`aria-disabled:opacity-50 aria-disabled:hover:bg-transparent`,"aria-label":`Remove ${n} from fallback`,"aria-disabled":c||void 0,onClick:()=>M(t),children:(0,Q.jsx)(Tc,{})})]})]},_(e))})})})}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`select`,{"aria-label":`Agent to add`,"data-slot":`fallback-add-agent`,value:E?.key??``,onChange:e=>{x(e.target.value),C(``)},disabled:c||te||y.length===0,className:`min-w-0 flex-1 basis-full sm:basis-0 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:[y.length===0?(0,Q.jsx)(`option`,{value:``,children:`Every agent is already listed`}):null,y.map(e=>(0,Q.jsx)(`option`,{value:e.key,children:e.label},e.key))]}),a?(0,Q.jsx)(`output`,{"aria-label":`Model for the agent to add`,title:`Model selection is locked to native coding-agent settings.`,className:`min-w-0 flex-1 rounded-md border border-input bg-muted/30 px-3 py-1.5 text-sm text-muted-foreground`,children:`Native agent settings`}):(0,Q.jsxs)(`select`,{"aria-label":`Model for the agent to add`,"data-slot":`fallback-add-model`,value:S,onChange:e=>C(e.target.value),disabled:c||te||!E,className:`min-w-0 flex-1 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:`auto model`}),ws(P,F?.data,[]).map(e=>e.id?(0,Q.jsx)(`option`,{value:e.id,children:e.label},e.id):null),ee?(0,Q.jsx)(`option`,{disabled:!0,children:ee}):null]}),(0,Q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`fallback-add`,disabled:c||te||!E,onClick:j,children:[(0,Q.jsx)(xc,{}),` Add agent`]})]}),te?(0,Q.jsxs)(`p`,{className:`text-ui text-muted-foreground`,children:[`Up to `,OC,` agents.`]}):null,(0,Q.jsxs)(`div`,{"data-slot":`fallback-terms`,className:`space-y-2 text-ui text-muted-foreground`,children:[(0,Q.jsx)(`p`,{children:`Settings changes apply to new tasks. Each agent is tried once. If no agent in the list can continue, the task stops and waits for you.`}),(0,Q.jsxs)(`details`,{children:[(0,Q.jsx)(`summary`,{className:`w-fit cursor-pointer rounded-sm outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:`Scope and permissions`}),(0,Q.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,Q.jsx)(`p`,{children:`Quick task and the final step of step-list workflows can switch agents; workflow graphs and earlier steps keep waiting for the limit to reset.`}),(0,Q.jsx)(`p`,{children:`Task budgets still apply. Tool restrictions are enforced by Claude only; other agents run with their own permissions.`})]})]})]}),(0,Q.jsx)(`p`,{role:`status`,"aria-live":`polite`,className:`sr-only`,children:w})]})})}function AC({defaultRunner:e,providerStatus:t,saving:n,onPick:r}){let i=pt(),o=a(),s=at(),c=ln(),l=Re(),u=s.projectId??`default`,d=c.data?.info?.root,f=d?i.data?.selections[d]:void 0,p=i.data?.defaults,m=BS(i.data?.profiles??[]),h=VS(m);return(0,Q.jsxs)(jC,{title:h?`Default agent`:`Default runner`,hint:h?`Preselected for new tasks in THIS repo, and used by the chain planner. Each task can still pick another agent or account. The account is stored on this machine only — it is never committed, so a teammate keeps their own.`:`Preselected for new tasks in THIS repo, and used by the chain planner. Each task can still pick another runner.`,children:[(0,Q.jsx)(HS,{rows:m,runner:e,accountFor:e=>f?.[e]??p?.[e]??null,providerStatus:t,disabled:n,accountDisabled:l.isPending||o.data===void 0,onPick:(t,n,i)=>{t!==e&&r(t),i&&l.mutate({projectId:u,provider:t,profileId:n},{onError:e=>Y(e.message,{tone:`danger`})})}}),!t.isPending&&!t.isError&&Xt(t.data,e)?.enabled===!1?(0,Q.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:`This provider is disabled. Enable it above or choose another provider.`}):null,h?(0,Q.jsx)(`p`,{className:`max-w-md text-ui text-muted-foreground`,children:`Tasks already started under another account can’t be resumed here — their sessions live in that account’s folder.`}):null]})}function jC({title:e,hint:t,children:n,action:r}){return(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:e}),(0,Q.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:t})]}),r]}),n]})}var MC=`cez-accent`,NC=`cez-density`,PC=`cez-width`,FC=`lime`,IC=`comfortable`,LC=`wide`;function RC(e){return e===`lime`||e===`violet`?e:FC}function zC(e){return e===`comfortable`||e===`compact`||e===`ultra`?e:IC}function BC(e){return e===`narrow`||e===`wide`?e:LC}function VC(e){let t=e&&typeof e==`object`?e:{};return{accent:RC(t.accent),density:zC(t.density),width:BC(t.width)}}function HC(){try{return{accent:RC(localStorage.getItem(MC)),density:zC(localStorage.getItem(NC)),width:BC(localStorage.getItem(PC))}}catch{return{accent:FC,density:IC,width:LC}}}function UC(e){try{localStorage.setItem(MC,e.accent),localStorage.setItem(NC,e.density),localStorage.setItem(PC,e.width)}catch{}}function WC(e,t){t.accent===`lime`?delete e.dataset.accent:e.dataset.accent=t.accent,t.density===`comfortable`?delete e.dataset.density:e.dataset.density=t.density,t.width===`wide`?delete e.dataset.width:e.dataset.width=t.width}var GC=Z.createContext(null);function KC({children:e}){let t=U(),n=ht(),[r,i]=Z.useState(HC),a=n.data;Z.useEffect(()=>{if(a===void 0)return;let e=VC(a.appearance);i(e),UC(e)},[a]),Z.useLayoutEffect(()=>{WC(document.documentElement,r)},[r]);let o=Z.useCallback(e=>{i(e),UC(e),Pt({appearance:e}).then(e=>t.setQueryData(B.uiState,e)).catch(e=>{Y(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)(GC.Provider,{value:u,children:e})}function qC(){let e=Z.useContext(GC);if(!e)throw Error(`cezar: useAppearance() must be called inside <AppearanceProvider>`);return e}var JC=[{value:`system`,label:`System`,icon:Gl},{value:`light`,label:`Light`,icon:ou},{value:`dark`,label:`Dark`,icon:Kl}],YC=[{value:`lime`,label:`Lime`,swatch:`var(--accent-lime)`},{value:`violet`,label:`Violet`,swatch:`var(--violet)`}],XC=[{value:`comfortable`,label:`Comfortable`},{value:`compact`,label:`Compact`},{value:`ultra`,label:`Compact for real`}],ZC=[{value:`narrow`,label:`Narrow`},{value:`wide`,label:`Full`}];function QC({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`,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:W(`flex items-center gap-2 rounded-sm px-3 py-1.5 text-ui 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 $C({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-ui text-muted-foreground`,children:t})]}),n]})}function ew(){let e=a(),{order:t,canReorder:n,reset:r}=pp();return!((e.data?.projects.length??0)>1)||t.length===0?null:(0,Q.jsx)($C,{title:`Project order`,hint:`The sidebar is in the order you dragged it into. Reset puts it back to most-recently-opened first. Shared with every browser signed in to this cezar.`,children:(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`appearance-project-order-reset`,disabled:!n,onClick:r,className:`w-fit`,children:`Reset order`})})}function tw(){let e=Ht(),t=U(),n=(0,Z.useRef)(null),[r,i]=(0,Z.useState)(null);(0,Z.useEffect)(()=>()=>{r&&URL.revokeObjectURL(r.url)},[r]);let a=H({mutationFn:e=>mn(e),onSuccess:e=>t.setQueryData(B.config,e),onError:e=>Y(e.message,{tone:`danger`})}),o=H({mutationFn:async e=>e?Ie(e):He(),onSuccess:e=>{let n=t.getQueryData(B.config);n&&t.setQueryData(B.config,{...n,branding:{...n.branding,logoUrl:e}}),i(null)},onError:e=>Y(e.message,{tone:`danger`})}),s=e.data?.branding,[c,l]=(0,Z.useState)(s?.name??`cezar`),[u,d]=(0,Z.useState)(s?.name??`cezar`);return(0,Z.useEffect)(()=>{s&&c===u&&(l(s.name),d(s.name))},[s?.name]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($C,{title:`Instance name`,hint:`Shown in the sidebar and browser tab across this workspace.`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`input`,{"data-slot":`branding-name`,"aria-label":`Instance name`,maxLength:80,value:c,onChange:e=>l(e.currentTarget.value),onBlur:()=>{let e=c.trim();if(!e){l(s?.name??`cezar`);return}e!==s?.name&&a.mutate({branding:{name:e}}),d(e)},className:`h-9 w-64 rounded-md border border-border bg-background px-3 text-sm`}),(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:!s||s.name===`cezar`||a.isPending,onClick:()=>a.mutate({branding:{name:null}}),children:`Reset name`})]})}),(0,Q.jsx)($C,{title:`Logo`,hint:`PNG, JPEG, WebP, GIF, AVIF, or safe SVG up to 2 MB. Stored on this machine and shared by its browsers.`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-lg border border-border bg-card p-3`,children:[r?(0,Q.jsx)(`img`,{src:r.url,alt:`Logo preview`,className:`size-10 rounded-md border border-border bg-background object-contain p-1`}):s?.logoUrl?(0,Q.jsx)(`img`,{src:s.logoUrl,alt:`Current instance logo`,className:`size-10 rounded-md border border-border bg-background object-contain p-1`}):(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`size-10 rounded-md border border-dashed border-border bg-background`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm font-medium text-foreground`,children:r?.file.name??(s?.logoUrl?`Current logo`:`No logo selected`)}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Choose an image to preview it before saving.`})]}),(0,Q.jsx)(`input`,{ref:n,"data-slot":`branding-logo`,"aria-label":`Upload logo`,type:`file`,accept:`image/png,image/jpeg,image/webp,image/gif,image/avif,image/svg+xml`,disabled:o.isPending,hidden:!0,onChange:e=>{let t=e.currentTarget.files?.[0];t&&i({file:t,url:URL.createObjectURL(t)}),e.currentTarget.value=``}}),(0,Q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:!s||o.isPending,onClick:()=>n.current?.click(),children:[(0,Q.jsx)(pc,{"aria-hidden":`true`,className:`size-3.5`}),`Choose logo`]}),r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{type:`button`,size:`sm`,disabled:o.isPending,onClick:()=>o.mutate(r.file),children:`Save logo`}),(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:o.isPending,onClick:()=>i(null),children:`Cancel`})]}):s?.logoUrl?(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:o.isPending,onClick:()=>o.mutate(null),children:`Remove logo`}):null]})})]})}function nw(){let{theme:e,setTheme:t}=Vf(),{accent:n,density:r,width:i,setAccent:a,setDensity:o,setWidth:s}=qC(),c=qa();return(0,Q.jsxs)(`div`,{"data-slot":`appearance-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)(tw,{}),(0,Q.jsx)($C,{title:`Theme`,hint:`System follows your OS preference. Applies to this browser.`,children:(0,Q.jsx)(QC,{slot:`appearance-theme`,label:`Theme`,value:e,options:JC,onChange:t})}),(0,Q.jsx)($C,{title:`Accent`,hint:`The primary action color. Saved with this repo's cockpit state.`,children:(0,Q.jsx)(QC,{slot:`appearance-accent`,label:`Accent`,value:n,options:YC,onChange:a})}),(0,Q.jsx)($C,{title:`Density`,hint:`Compact tightens spacing across the cockpit — text stays the same size.`,children:(0,Q.jsx)(QC,{slot:`appearance-density`,label:`Density`,value:r,options:XC,onChange:o})}),(0,Q.jsx)($C,{title:`Reading width`,hint:`Full gives task sessions, commits, and skill content the whole available area. Narrow keeps a comfortable reading column. The Changes tab is always full-width.`,children:(0,Q.jsx)(QC,{slot:`appearance-width`,label:`Reading width`,value:i,options:ZC,onChange:s})}),(0,Q.jsx)($C,{title:`Usage gauges`,hint:`Claude account, plan limits left (5h, 7d) and context fill in the task header. Applies to this browser.`,children:(0,Q.jsx)(QC,{slot:`appearance-live-usage`,label:`Usage gauges`,value:c?`on`:`off`,options:[{value:`on`,label:`Show`},{value:`off`,label:`Hide`}],onChange:e=>Ia(e===`on`)})}),(0,Q.jsx)(ew,{})]})}function $({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-ui text-muted-foreground`,children:t})]}),n]})}var rw=2e4;function iw(){let e=Ht();return e.isPending?(0,Q.jsx)(`p`,{className:`p-4 text-ui text-soft-foreground md:p-6`,children:`Loading instructions…`}):e.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(Va,{}),tone:`danger`,title:`Instructions did not load`,subtitle:e.error.message,heading:`h2`}):(0,Q.jsx)(aw,{config:e.data})}function aw({config:e}){let t=U(),n=H({mutationFn:e=>mn(e),onSuccess:e=>t.setQueryData(B.config,e),onError:e=>Y(e.message,{tone:`danger`})}),[r,i]=(0,Z.useState)(e.systemPrompt??``),a=r.trim(),o=a===(e.systemPrompt??``),s=a.length>rw;return(0,Q.jsx)(`div`,{"data-slot":`global-instructions-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)($,{title:`Global system prompt`,hint:`Read by every agent step of every new task, in every project. A project's own system prompt is added after it and takes precedence where they conflict.`,children:[(0,Q.jsx)(gc,{"aria-label":`Global system prompt`,"data-slot":`global-instructions-prompt`,value:r,onChange:e=>i(e.target.value),placeholder:`General rules for every project — conventions, tone, review requirements…`,className:`min-h-32 max-w-xl`}),(0,Q.jsxs)(`div`,{className:`flex max-w-xl items-center gap-3`,children:[(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,"data-action":`global-instructions-save`,disabled:o||s||n.isPending,onClick:()=>n.mutate({systemPrompt:a===``?null:a},{onSuccess:()=>Y(a===``?`Global instructions cleared`:`Global instructions saved`)}),children:`Save`}),s?(0,Q.jsxs)(`p`,{"data-slot":`global-instructions-limit`,className:`text-meta text-danger`,children:[a.length.toLocaleString(),` characters — the limit is `,rw.toLocaleString(),`.`]}):(0,Q.jsx)(`p`,{className:`text-meta text-soft-foreground`,children:`Leave empty and save to clear. Applied to new runs only.`})]})]})})}function ow({embedded:e=!1}={}){let t=Ft();return t.isPending?(0,Q.jsx)(`p`,{"data-slot":`prompt-templates-loading`,className:e?`text-ui text-soft-foreground`:`p-4 text-ui text-soft-foreground md:p-6`,children:`Loading prompt templates…`}):t.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(ql,{}),tone:`danger`,title:`Prompt templates did not load`,subtitle:t.error.message,heading:`h2`}):(0,Q.jsx)(sw,{initial:So(t.data.promptTemplates),embedded:e})}function sw({initial:e,embedded:t}){let n=U(),r=ie(),i=Ft(),[a,o]=(0,Z.useState)(e),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),d=H({mutationFn:e=>Yt({promptTemplates:e}),onSuccess:e=>{n.setQueryData(V.uiState,e),Y(`Prompt templates saved`)},onError:e=>Y(e.message,{tone:`danger`})}),f=JSON.stringify(a)!==JSON.stringify(e),p=a.some(e=>e.label.trim()===``||e.text.trim()===``),m=(e,t)=>o(n=>n.map(n=>n.id===e?{...n,...t}:n)),h=(e,t)=>o(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})),g=e=>o(t=>t.filter(t=>t.id!==e));return(0,Q.jsx)(`div`,{"data-slot":`prompt-templates-section`,className:t?`flex w-full flex-col gap-7`:`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)(lw,{title:`Prompt templates`,hint:`Reusable snippets you can insert into a prompt — the new-task composer, the GitHub hand-over, and the Inbox's “Add instructions” box all offer this list. Assign a template to a skill and it fills the prompt in for you when you pick that skill, as long as you have not typed anything yet.`,children:[(0,Q.jsx)(`div`,{"data-slot":`prompt-template-list`,className:`flex flex-col gap-3`,children:a.length===0?(0,Q.jsx)(`p`,{"data-slot":`prompt-templates-empty`,className:`text-ui text-soft-foreground`,children:`No templates. Add one below, or reset to the built-ins.`}):a.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 items-center gap-2`,children:[(0,Q.jsx)(Kc,{"aria-label":`Label for ${e.label||`this template`}`,"data-slot":`prompt-template-label-input`,value:e.label,maxLength:80,onChange:t=>m(e.id,{label:t.target.value}),className:`flex-1`}),(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`prompt-template-remove`,title:`Remove this template`,onClick:()=>g(e.id),children:(0,Q.jsx)(Tc,{"aria-hidden":`true`,className:`size-3.5`})})]}),(0,Q.jsx)(gc,{"aria-label":`Text for ${e.label||`this template`}`,"data-slot":`prompt-template-text-input`,value:e.text,maxLength:ko,onChange:t=>m(e.id,{text:t.target.value}),className:`min-h-14 text-ui`}),(0,Q.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5`,children:[(0,Q.jsx)(cw,{label:e.label,skills:r.data??[],skillUsage:i.data?.skillUsage,selected:e.skills??[],onToggle:t=>h(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:()=>h(e.id,t),className:`inline-flex items-center gap-1 rounded-full border border-border bg-muted px-2 py-px font-mono text-meta font-medium text-foreground transition-colors hover:bg-danger/10 hover:text-danger`,children:[t,(0,Q.jsx)(Tc,{"aria-hidden":`true`,className:`size-3`})]},t))]})]},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)(Kc,{"aria-label":`New template label`,"data-slot":`prompt-template-new-label`,placeholder:`Label (e.g. "Add tests")`,value:s,maxLength:80,onChange:e=>c(e.target.value)}),(0,Q.jsx)(gc,{"aria-label":`New template text`,"data-slot":`prompt-template-new-text`,placeholder:`The instructions to insert…`,value:l,maxLength:ko,onChange:e=>u(e.target.value),className:`min-h-14 text-ui`}),(0,Q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,"data-action":`prompt-template-add`,disabled:!s.trim()||!l.trim(),onClick:()=>{let e=s.trim(),t=l.trim();!e||!t||(o(n=>[...n,{id:Po(),label:e,text:t}]),c(``),u(``))},className:`self-start`,children:[(0,Q.jsx)(xc,{"aria-hidden":`true`,className:`size-3.5`}),`Add template`]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(J,{type:`button`,variant:`contrast`,size:`sm`,"data-action":`prompt-templates-save`,disabled:!f||p||d.isPending,onClick:()=>d.mutate(a),children:`Save`}),(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`prompt-templates-reset`,disabled:d.isPending,onClick:()=>o(yo.map(e=>({...e}))),children:`Reset to defaults`}),p?(0,Q.jsx)(`p`,{"data-slot":`prompt-templates-invalid`,className:`text-meta text-danger`,children:`Every template needs both a label and text.`}):null]})]})})}function cw({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}=po(so(t,s,n),n),p=(e,t)=>{let n=r.includes(e.name);return(0,Q.jsxs)(Bi,{value:`skill ${e.name} ${e.path}`,keywords:uo(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:W(`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)(Rs,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-primary`}):null]},e.path)};return(0,Q.jsxs)(Hr,{open:a,onOpenChange:e=>{o(e),e||c(``)},children:[(0,Q.jsx)(Jr,{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:W(`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)(Ko,{"aria-hidden":`true`,className:`size-3 shrink-0 text-violet`}),t.length===0?`no skills found`:`apply with…`,(0,Q.jsx)(Ws,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Q.jsx)(Kr,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Q.jsxs)(Ai,{shouldFilter:!1,children:[(0,Q.jsx)(Mi,{placeholder:`search skills…`,value:s,onValueChange:c,onInput:()=>l.current?.scrollTo(0,0)}),(0,Q.jsxs)(Li,{ref:l,"data-slot":`prompt-template-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[u.length===0&&d.length===0&&f.length===0?(0,Q.jsx)(Wi,{children:`Nothing matches.`}):null,u.length>0?(0,Q.jsx)(ji,{heading:`Most used`,children:u.map(e=>p(e,Do(e)))}):null,d.length>0?(0,Q.jsx)(ji,{heading:`Project skills`,children:d.map(e=>p(e,!0))}):null,f.length>0?(0,Q.jsx)(ji,{heading:`Global`,children:f.map(e=>p(e,!1))}):null]})]})})]})}function lw({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-ui text-muted-foreground`,children:t})]}),n]})}var uw=2e4,dw=4e3;function fw(){let e=En();return e.isPending?(0,Q.jsx)(`p`,{"data-slot":`instructions-loading`,className:`p-4 text-ui text-soft-foreground md:p-6`,children:`Loading instructions…`}):e.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(Va,{}),tone:`danger`,title:`Instructions did not load`,subtitle:e.error.message,heading:`h2`}):(0,Q.jsx)(pw,{config:e.data})}function pw({config:e}){let t=wC(),[n,r]=(0,Z.useState)(e.systemPrompt??``),i=n.trim(),a=i===(e.systemPrompt??``),o=i.length>uw,s=()=>t.mutate({systemPrompt:i===``?null:i},{onSuccess:()=>Y(i===``?`System prompt cleared`:`System prompt saved`)}),[c,l]=(0,Z.useState)(e.branchNaming??``),u=c.trim(),d=u===(e.branchNaming??``),f=u.length>dw;return(0,Q.jsxs)(`div`,{"data-slot":`instructions-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)($,{title:`System prompt`,hint:`Read by every agent step of every new task in this project, whichever runner executes it. Added after the global instructions (General settings → Instructions) and takes precedence over them.`,children:[(0,Q.jsx)(gc,{"aria-label":`System prompt`,"data-slot":`instructions-system-prompt`,value:n,onChange:e=>r(e.target.value),placeholder:`Extra rules for every agent run — conventions, tone, review requirements…`,className:`min-h-32 max-w-xl`}),(0,Q.jsxs)(`div`,{className:`flex max-w-xl items-center gap-3`,children:[(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,"data-action":`instructions-save-prompt`,disabled:a||o||t.isPending,onClick:s,children:`Save`}),o?(0,Q.jsxs)(`p`,{"data-slot":`instructions-prompt-limit`,className:`text-meta text-danger`,children:[i.length.toLocaleString(),` characters — the limit is `,uw.toLocaleString(),`.`]}):(0,Q.jsx)(`p`,{className:`text-meta text-soft-foreground`,children:`Leave empty and save to clear. Applied to new runs only.`})]})]}),(0,Q.jsxs)($,{title:`Branch naming`,hint:`How new task branches are named. Generated from the first prompt.`,children:[(0,Q.jsx)(gc,{"aria-label":`Branch naming`,"data-slot":`instructions-branch-naming`,value:c,onChange:e=>l(e.target.value),placeholder:`Describe your branch naming convention…`,className:`min-h-24 max-w-xl`}),(0,Q.jsxs)(`div`,{className:`flex max-w-xl items-center gap-3`,children:[(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,"data-action":`instructions-save-branch-naming`,disabled:d||f||t.isPending,onClick:()=>t.mutate({branchNaming:u===``?null:u},{onSuccess:()=>Y(u===``?`Branch naming cleared`:`Branch naming saved`)}),children:`Save`}),f?(0,Q.jsxs)(`p`,{"data-slot":`instructions-branch-naming-limit`,className:`text-meta text-danger`,children:[u.length.toLocaleString(),` characters — the limit is`,` `,dw.toLocaleString(),`.`]}):(0,Q.jsx)(`p`,{className:`text-meta text-soft-foreground`,children:`Leave empty for the default names. A new task waits for its name before it forks.`})]})]}),(0,Q.jsx)(`div`,{id:`prompt-templates`,className:`scroll-mt-20`,children:(0,Q.jsx)(ow,{embedded:!0})})]})}function mw(){let e=Ra(),[t,n]=Z.useState(null),[r,i]=Z.useState(null),a=Object.keys(e.overrides).length>0,o=Z.useMemo(()=>{let t=new Map;for(let e of ja)t.set(e.group,[...t.get(e.group)??[],e]);let n=Object.keys(e.overrides).filter(t=>!ja.some(e=>e.id===t)&&e.overrides[t]).map(e=>({id:e,label:e.replace(/^[a-z-]+:/,``),group:`Other`}));return n.length>0&&t.set(`Other`,n),[...t]},[e.overrides]);Z.useEffect(()=>{if(!t)return;let r=r=>{if(r.key===`Tab`&&!r.metaKey&&!r.ctrlKey&&!r.altKey||(r.preventDefault(),r.stopImmediatePropagation(),r.key===`Escape`))return n(null);if(!r.metaKey&&!r.ctrlKey&&!r.altKey&&!r.shiftKey&&(r.key===`Backspace`||r.key===`Delete`))return e.assign(t,null),n(null);let a=Pa(r);if(!a){let e=$a(r);e&&i(e);return}let o=Za(a);if(o)return i(`${Oa(a)} — ${o}`);let s=[...e.bindings].find(([e,n])=>n===a&&e!==t)?.[0];e.assign(t,a),s&&Y(`${Oa(a)} moved from ${hw(s)} to ${hw(t)}`),n(null)},a=e=>{(e.target instanceof Element?e.target.closest(`[data-slot="shortcut-chord"]`):null)?.closest(`[data-command-id]`)?.dataset.commandId!==t&&n(null)};return window.addEventListener(`keydown`,r,{capture:!0}),window.addEventListener(`pointerdown`,a,{capture:!0}),()=>{window.removeEventListener(`keydown`,r,{capture:!0}),window.removeEventListener(`pointerdown`,a,{capture:!0})}},[t,e]);let s=Sa();return(0,Q.jsxs)(`div`,{"data-slot":`keyboard-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)(`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:`Task shortcuts`}),(0,Q.jsxs)(`p`,{className:`text-ui text-muted-foreground`,children:[`Run a task’s commands from the keyboard while the task is open. `,Oa(`Mod+P`),` lists them all; press `,s?`⇧↵`:`Shift+Enter`,` on a row there to set its shortcut. `,s?`⌘`:`Ctrl`,` chords also work while you type. `,s?`⌥↑ / ⌥↓`:`Alt+↑ / Alt+↓`,` go to the previous / next task,`,` `,s?`⌥⇧↑ / ⌥⇧↓`:`Alt+Shift+↑ / Alt+Shift+↓`,` to the previous / next one that needs you`,rs()===`desktop`?` — and ${s?`⌃⌥↑ / ⌃⌥↓`:`Ctrl+Alt+↑ / Ctrl+Alt+↓`} do that from any application.`:`.`]})]}),(0,Q.jsxs)(J,{variant:`outline`,size:`sm`,"data-action":`reset-all-shortcuts`,disabled:!a||!e.ready,onClick:e.resetAll,children:[(0,Q.jsx)($l,{"aria-hidden":`true`}),` Reset all`]})]})}),o.map(([a,o])=>(0,Q.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`h3`,{className:`eyebrow text-soft-foreground`,children:a}),(0,Q.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-md border border-border`,children:o.map(a=>{let o=e.bindings.get(a.id),s=t===a.id,c=a.id in e.overrides;return(0,Q.jsxs)(`li`,{"data-slot":`shortcut-row`,"data-command-id":a.id,className:`flex items-center gap-2 px-3 py-1.5`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm`,children:a.label}),s?(0,Q.jsx)(`span`,{"data-slot":`shortcut-recording`,className:`text-xs text-primary`,children:r??`Press keys… (esc cancels, ⌫ removes)`}):null,(0,Q.jsx)(`button`,{type:`button`,"data-slot":`shortcut-chord`,"aria-label":o?`Change the shortcut for ${a.label} (${Oa(o)})`:`Set a shortcut for ${a.label}`,disabled:!e.ready,onClick:()=>{i(null),n(s?null:a.id)},onBlur:()=>{s&&n(null)},className:W(`min-w-16 rounded-[5px] border border-b-2 px-1.5 py-0.5 font-mono text-xs`,s?`border-primary text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:o?Oa(o):(0,Q.jsx)(Rl,{"aria-hidden":`true`,className:`mx-auto size-3.5`})}),c?(0,Q.jsx)(J,{variant:`ghost`,size:`icon-sm`,"aria-label":`Reset ${a.label} to ${Ja[a.id]?Oa(Ja[a.id]):`no shortcut`}`,title:`Reset to default`,onClick:()=>e.reset(a.id),children:(0,Q.jsx)($l,{"aria-hidden":`true`})}):o?(0,Q.jsx)(J,{variant:`ghost`,size:`icon-sm`,"aria-label":`Remove the shortcut for ${a.label}`,title:`Remove`,onClick:()=>e.assign(a.id,null),children:(0,Q.jsx)(Tc,{"aria-hidden":`true`})}):(0,Q.jsx)(`span`,{className:`size-7 shrink-0`})]},a.id)})})]},a))]})}function hw(e){return ja.find(t=>t.id===e)?.label??e}function gw(){let e=ie();return e.isPending?(0,Q.jsx)(`p`,{"data-slot":`bookmarklets-loading`,className:`p-4 text-ui text-soft-foreground md:p-6`,children:`Loading bookmarklets…`}):e.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(wc,{}),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 px-4 py-5 md:px-7`,children:(0,Q.jsx)(_w,{skills:Eo(e.data??[])})})}function _w({skills:e}){let t=Fe(),n=C(),r=a(),[i,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(``),l=t.data?.key??``,u=window.location.origin,d=kr()??n.data?.bootProject??null,f=r.data?.projects.find(e=>e.id===d)?.name??nA(n.data)?.name??null,p=s.trim().toLowerCase(),m=e.filter(e=>e.name.toLowerCase().includes(p));return(0,Q.jsxs)(`div`,{"data-slot":`bookmarklet-panel`,className:`mx-auto w-full max-w-2xl`,children:[(0,Q.jsx)(`h2`,{className:`text-base font-semibold`,children:`Run from GitHub`}),(0,Q.jsxs)(`p`,{className:`mt-2 text-ui leading-relaxed text-muted-foreground`,children:[`Drag a button below to your browser's bookmarks bar. On any GitHub PR or issue, click it to open this cockpit directly. The cockpit must be running: `,(0,Q.jsx)(`span`,{className:`font-mono`,children:`npx cezar`}),`.`]}),(0,Q.jsxs)(`label`,{className:`mt-4 flex items-center gap-2 text-ui font-medium`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"data-slot":`bm-auto`,checked:i,onChange:e=>o(e.target.checked),className:`size-3.5`}),`One-click launch (auto-submit)`,` `,(0,Q.jsx)(`span`,{className:`font-normal text-soft-foreground`,children:`— re-drag the buttons after changing this`})]}),(0,Q.jsx)(`div`,{"data-slot":`bm-generic`,className:`mt-4`,children:(0,Q.jsx)(Ux,{label:f?`cezar (${f}): this PR/issue`:`cezar: this PR/issue`,url:Gx(``,!1,l,u,d),hint:`prefills the form — nothing starts by itself`})}),(0,Q.jsx)(Kc,{"data-slot":`bm-filter`,placeholder:`Filter skills…`,"aria-label":`Filter bookmarklet skills`,value:s,onChange:e=>c(e.target.value),className:`mt-5 h-8 text-ui`}),(0,Q.jsx)(`div`,{"data-slot":`bm-list`,className:`mt-3 flex flex-col gap-2`,children:m.length>0?m.map(e=>(0,Q.jsx)(Ux,{label:f?`/${e.name} (${f})`:`/${e.name}`,url:Gx(e.name,i,l,u,d),hint:e.source},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)`})})]})}function vw(){let e=U(),t=ht(),[n,r]=Z.useState(!1),[i,a]=Z.useState(ri),o=t.data;Z.useEffect(()=>{o!==void 0&&r(ni(o.notifications).enabled)},[o]);let s=Z.useCallback(t=>{r(t),Pt({notifications:{enabled:t}}).then(t=>e.setQueryData(B.uiState,t)).catch(t=>{Y(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(ri()!=="default"){s(!0);return}s(!0),Notification.requestPermission().then(e=>a(e)).catch(()=>a(ri()))},[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-ui 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)(ff,{id:`notifications-enabled`,"data-slot":`notifications-toggle`,checked:n,disabled:l,onCheckedChange:c})]}),l?(0,Q.jsx)(`p`,{"data-slot":`notifications-unsupported`,className:`text-ui text-muted-foreground`,children:`This browser does not support notifications, so the toggle is unavailable here.`}):null,!l&&n&&i===`denied`?(0,Q.jsx)(`p`,{"data-slot":`notifications-denied`,className:`text-ui text-danger`,children:`This browser is blocking notifications for the cockpit. The preference is saved, but nothing will be delivered here until you allow notifications in the browser's site settings.`}):null]})})}function yw(){let e=Ze(),t=Sg(),[n,r]=Z.useState(!1),i=e.data,a=i?.blockedBy??null;return(0,Q.jsx)(`div`,{"data-slot":`privacy-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:`telemetry-enabled`,children:`Share usage data`})}),(0,Q.jsxs)(`p`,{className:`text-ui text-muted-foreground`,children:[`Task counts and crash reports, sent to cezar’s maintainers at Open Mercato`,i?(0,Q.jsxs)(Q.Fragment,{children:[` (`,(0,Q.jsx)(`span`,{className:`font-mono text-label`,children:i.endpoint}),`)`]}):null,`. Never prompts, code, diffs, paths or repository names. Off unless you turn it on; turning it off deletes this machine’s install id.`]})]}),(0,Q.jsx)(ff,{id:`telemetry-enabled`,"data-slot":`telemetry-toggle`,checked:i?.consent===`granted`,disabled:!i||n,onCheckedChange:e=>{r(!0),t(e?`granted`:`denied`).finally(()=>r(!1))}})]}),a===`env`?(0,Q.jsxs)(`p`,{"data-slot":`telemetry-blocked`,className:`text-ui text-muted-foreground`,children:[(0,Q.jsx)(`code`,{className:`font-mono text-label`,children:`CEZ_TELEMETRY=0`}),` or`,` `,(0,Q.jsx)(`code`,{className:`font-mono text-label`,children:`DO_NOT_TRACK=1`}),` is set for this server, so nothing is sent whatever this switch says.`]}):a===`automation`?(0,Q.jsxs)(`p`,{"data-slot":`telemetry-blocked`,className:`text-ui text-muted-foreground`,children:[`This server runs under CI, a test runner or `,(0,Q.jsx)(`code`,{className:`font-mono text-label`,children:`CEZ_DRY_RUN=1`}),`, so nothing is sent from it.`]}):null,(0,Q.jsxs)(`a`,{href:_g,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-ui text-muted-foreground underline-offset-4 hover:text-foreground hover:underline`,children:[`Exactly what is collected`,(0,Q.jsx)(Ir,{className:`size-3.5`,"aria-hidden":`true`})]})]})})}var bw=400,xw=Symbol(`none`),Sw=e=>e===null?``:String(e);function Cw({value:e,min:t,max:n,onCommit:r,allowEmpty:i=!1,emptyStepFrom:a,placeholder:o,disabled:s,"aria-label":c,"data-slot":l,className:u}){let d=(0,Z.useId)(),[f,p]=(0,Z.useState)(()=>Sw(e)),m=(0,Z.useRef)(f),h=(0,Z.useRef)(null),g=(0,Z.useRef)(xw),_=(0,Z.useRef)({value:e,onCommit:r});_.current={value:e,onCommit:r};let v=e=>{m.current=e,p(e)};(0,Z.useEffect)(()=>{g.current=xw,h.current===null&&v(Sw(e))},[e]);let y=(0,Z.useRef)(()=>{});(0,Z.useEffect)(()=>()=>{h.current!==null&&y.current()},[]);let b=e=>{let r=e.trim();if(r===``)return i?null:`invalid`;if(!/^-?\d+$/.test(r))return`invalid`;let a=Number(r);return a<t||a>n?`invalid`:a},x=b(f),S=x===`invalid`,C=()=>{h.current!==null&&(clearTimeout(h.current),h.current=null);let{value:e,onCommit:t}=_.current,n=b(m.current);if(n===`invalid`||n===e||g.current!==xw&&n===g.current)return;let r=t(n);r instanceof Promise&&(g.current=n,r.catch(()=>{g.current===n&&(g.current=xw),v(Sw(_.current.value))}))};y.current=C;let w=e=>{let r=b(m.current),i=r===null?a??t:r===`invalid`?(_.current.value??a??t)+e:r+e;v(String(Math.min(n,Math.max(t,i)))),h.current!==null&&clearTimeout(h.current),h.current=setTimeout(C,bw)},T=t=>{t.key===`ArrowUp`||t.key===`ArrowDown`?(t.preventDefault(),w(t.key===`ArrowUp`?1:-1)):t.key===`Enter`?(t.preventDefault(),C()):t.key===`Escape`&&(h.current!==null&&clearTimeout(h.current),h.current=null,v(Sw(e)))},E=typeof x==`number`?x:null,D=`flex h-1/2 w-6 items-center justify-center text-soft-foreground hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-40`;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`div`,{className:W(`flex w-28 items-stretch overflow-hidden rounded-md border border-input bg-card shadow-xs focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50`,S&&`border-danger`,s&&`opacity-50`,u),children:[(0,Q.jsx)(`input`,{type:`text`,inputMode:`numeric`,role:`spinbutton`,"aria-label":c,"aria-valuemin":t,"aria-valuemax":n,"aria-valuenow":E??void 0,"aria-invalid":S||void 0,"aria-describedby":S?d:void 0,"data-slot":l,value:f,placeholder:o,disabled:s,onChange:e=>v(e.target.value),onBlur:C,onKeyDown:T,className:`min-w-0 flex-1 bg-transparent px-3 py-1.5 text-sm outline-none placeholder:text-soft-foreground`}),(0,Q.jsxs)(`div`,{className:`flex flex-col border-l border-input`,children:[(0,Q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":`Increase ${c}`,"data-action":`stepper-increment`,disabled:s||E!==null&&E>=n,onMouseDown:e=>e.preventDefault(),onClick:()=>w(1),className:D,children:(0,Q.jsx)(vl,{className:`size-3.5`})}),(0,Q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":`Decrease ${c}`,"data-action":`stepper-decrement`,disabled:s||E!==null&&E<=t,onMouseDown:e=>e.preventDefault(),onClick:()=>w(-1),className:W(D,`border-t border-input`),children:(0,Q.jsx)(Ws,{className:`size-3.5`})})]})]}),S?(0,Q.jsxs)(`p`,{id:d,"data-slot":`stepper-invalid`,className:`text-meta text-danger`,children:[`Enter a whole number from `,t,` to `,n,i?`, or leave it empty`:``,`.`]}):null]})}var ww={inactive:`neutral`,active:`success`,paused:`neutral`,suspended:`pending`,disabled:`danger`},Tw={inactive:`Inactive`,active:`Active`,paused:`Paused`,suspended:`Failing`,disabled:`Disabled`},Ew={"cezar.json.v1":`Custom receiver`,"slack.v1":`Slack`,"discord.v1":`Discord`},Dw={minimal:`Minimal`,standard:`Standard`},Ow={main_and_questions:`Main tasks and questions from child tasks`,every_task:`Every task`},kw={attention:`Attention, review and results`,all:`All results`,custom:`Custom`},Aw={0:`Immediately`,60:`1 minute`,180:`3 minutes`,600:`10 minutes`},jw={none:`Not tested`,success:`Passed`,transient_failure:`Failed — temporary error`,permanent_failure:`Failed`},Mw={pending:`Queued`,in_flight:`Sending`,retrying:`Retrying`,blocked_policy:`Blocked by address policy`,delivered:`Delivered`,failed:`Failed`,superseded:`Superseded`,cancelled:`Cancelled`,dropped:`Dropped`},Nw={timeout:`Receiver did not respond within 10 seconds`,connection_failed:`Could not connect to the receiver`,transport_failed:`Network error`,delivery_failed:`Delivery failed`,outcome_unknown:`Result unknown — it may have arrived`,rate_limited:`Rate limited`,expired:`Retry window ended`,aborted:`Stopped`,owner_restarted:`cezar restarted during delivery`,payload_invalid:`Message could not be built`,integrity_reset:`Webhook data was reset`,retained_capacity:`History storage is full`,newer_continuation:`A newer update replaced it`,operation_superseded:`A newer action replaced it`,failure_schedule_changed:`Automatic resume changed`,denied_address:`Address is never allowed`,local_network_consent_required:`Private-network delivery not allowed`,local_consent_required:`Private-network delivery not allowed`},Pw={created:`Receiver added`,activated:`Activated`,resumed:`Resumed`,paused:`Paused`,deleted:`Deleted`,renamed:`Renamed`,configuration_changed:`Settings changed`,delivery_changed:`Delivery settings changed`,secret_rotated:`Signing key rotated`,test:`Test sent`,test_result:`Test result`,delivery_result:`Delivery result`,retry:`Retry requested`,replay:`Replay requested`,notice_acknowledged:`Change marked as reviewed`,history_pruned:`Old history removed`,integrity_reset:`Webhook data reset`},Fw={"cockpit/api":`cockpit or API`,system:`cezar`};function Iw(e){let t=e.replaceAll(`_`,` `).replace(/^http /i,`HTTP `);return t.charAt(0).toUpperCase()+t.slice(1)}var Lw=e=>Nw[e]??Iw(e),Rw=e=>Pw[e]??Iw(e);function zw(e,t,n){return`${e} ${e===1?t:n}`}function Bw(e){try{if(e)return new Intl.DateTimeFormat(void 0,{timeZone:e}),{zone:e,label:e}}catch{}return{zone:void 0,label:`your local time`}}function Vw(e,t){let n=new Date(e);return Number.isFinite(n.getTime())?n.toLocaleString(void 0,{timeZone:Bw(t).zone,month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`,timeZoneName:`short`}):`Time unavailable`}function Hw(e){return{href:`https://github.com/open-mercato/cezar/blob/main/packages/cezar/docs/webhooks.md`,note:`Webhook guide`}}function Uw(){let e=_t();return{isPending:e.isPending,confirm:(t,n)=>e.mutate(t.id,{onSuccess:e=>{e.warning&&Y(e.warning,{tone:`danger`}),Y(`${t.name} removed from the workspace — its files are untouched`),n?.()},onError:e=>Y(e.message,{tone:`danger`})})}}function Ww({project:e,onOpenChange:t,onConfirm:n}){let r=C(),i=mb(e?.id??`default`,e!==null&&r.data?.capabilities?.webhooks===!0),a=i.data?.receivers.filter(e=>[`active`,`suspended`].includes(e.state))??[],o=a.reduce((e,t)=>e+t.pendingCount,0),s=a.reduce((e,t)=>e+t.inFlightCount,0);return(0,Q.jsx)(Vc,{open:e!==null,onOpenChange:t,children:(0,Q.jsxs)(Ic,{children:[(0,Q.jsxs)(Bc,{children:[(0,Q.jsxs)(Fc,{children:[`Remove `,e?.name,` from the workspace?`]}),(0,Q.jsxs)(Pc,{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 adding it back later finds everything intact.`,a.length>0&&(0,Q.jsxs)(`span`,{className:`mt-2 block`,children:[zw(a.length,`receiver`,`receivers`),` will be paused. `,zw(o,`pending delivery`,`pending deliveries`),` will be cancelled; `,s,` in flight may still arrive.`]}),i.error&&(0,Q.jsx)(`span`,{className:`mt-2 block`,children:`Webhook state is unavailable. Removal will report whether receivers could be paused.`}),(0,Q.jsx)(`span`,{"data-testid":`remove-project-root`,className:`mt-1 block break-all font-mono text-meta text-foreground`,children:e?.root})]})]}),(0,Q.jsxs)(Rc,{children:[(0,Q.jsx)(zc,{children:`Keep it`}),(0,Q.jsx)(Lc,{"data-action":`projects-confirm-remove`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:n,children:`Remove from list`})]})]})})}var Gw=1,Kw=16,qw={ok:`ok`,"not-git":`no git repo`,missing:`folder not found`};function Jw(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Yw(){let e=Ht(),t=a();return e.isPending||t.isPending?(0,Q.jsx)(`p`,{"data-slot":`projects-loading`,className:`p-4 text-ui text-soft-foreground md:p-6`,children:`Loading projects…`}):e.isError||t.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(Ml,{}),tone:`danger`,title:`Project settings did not load`,subtitle:(e.error??t.error)?.message,heading:`h2`}):(0,Q.jsx)(Xw,{config:e.data,registry:t.data})}function Xw({config:e,registry:t}){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)(Zw,{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)(Zw,{configKey:`projectsDir`,value:e.projectsDir,title:`Default checkout folder`,hint:`Where “Clone from GitHub” and “New project” put 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)(Qw,{registry:t,workspaceMax:e.resources.maxParallel})]})}function Zw({configKey:e,value:t,title:n,hint:r,placeholder:i,slot:a,savedLabel:o,footer:s,refreshProjects:c=!1}){let l=U(),u=H({mutationFn:t=>mn(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)($,{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)(J,{type:`button`,variant:`outline`,size:`sm`,"data-action":`projects-save-${a}-root`,disabled:m||p===``||u.isPending,onClick:()=>u.mutate(p,{onSuccess:()=>Y(`${o} set to ${p}`)}),children:`Save`})]}),h===null?(0,Q.jsx)(`p`,{className:`text-meta text-soft-foreground`,children:s}):(0,Q.jsxs)(`p`,{"data-slot":`projects-${a}-root-error`,role:`alert`,className:`text-meta text-danger`,children:[h,` — setting unchanged`]})]})}function Qw({registry:e,workspaceMax:t}){let[n,r]=(0,Z.useState)(null),i=Uw(),a=(0,Z.useMemo)(()=>Ot(e.projects),[e.projects]);return(0,Q.jsxs)($,{title:`Registered projects`,hint:`The folders you have added. While this list is empty the folder cezar is serving is listed as “not registered” with an Add button; once you have projects, starting cezar somewhere new neither registers nor lists that folder — use “Add project” when you want to keep it. “Tags” group connected repositories — give the API, the web app and the design system a shared “storefront” tag and the global Tasks page can show all three as one piece of work. “Max parallel” caps how many of that project's tasks run at once (leave it empty to inherit the workspace limit); the workspace limit (${t}) still applies as an overall ceiling, so a per-project value above it has no extra effect until the workspace limit is raised. 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-ui 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 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-label 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)($w,{project:n,isBoot:n.id===e.bootProject,workspaceMax:t,vocabulary:a,disabled:i.isPending,onRemove:()=>r(n)},n.id))})]})}),(0,Q.jsx)(Ww,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{if(!n)return;let e=n;r(null),i.confirm(e)}})]})}function $w({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-meta 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-label text-danger`:`text-label text-soft-foreground`,children:qw[e.status]}),e.unregistered?(0,Q.jsx)(`span`,{"data-slot":`project-unregistered`,className:`ml-1 text-meta text-soft-foreground`,children:`· not registered`}):e.status===`missing`?null:(0,Q.jsxs)(`span`,{className:`ml-1 text-meta text-soft-foreground`,children:[`· `,e.source]})]}),(0,Q.jsx)(`td`,{className:`px-3 py-2`,children:e.unregistered?(0,Q.jsx)(`span`,{className:`text-label text-soft-foreground`,children:`—`}):(0,Q.jsx)(tT,{project:e,vocabulary:r})}),(0,Q.jsx)(`td`,{className:`px-3 py-2`,children:e.unregistered?(0,Q.jsx)(`span`,{className:`text-label text-soft-foreground`,children:`—`}):(0,Q.jsx)(nT,{project:e,workspaceMax:n})}),(0,Q.jsx)(`td`,{className:`px-3 py-2 tabular-nums text-soft-foreground`,children:e.unregistered?`—`:Jw(e.addedAt)}),(0,Q.jsxs)(`td`,{className:`px-3 py-2 text-right whitespace-nowrap`,children:[!e.unregistered&&e.status!==`missing`?(0,Q.jsx)(J,{asChild:!0,variant:`ghost`,size:`sm`,children:(0,Q.jsx)(yr,{to:`/p/${encodeURIComponent(e.id)}/settings`,"data-action":`project-settings`,"aria-label":`Settings for ${e.name}`,children:`Settings`})}):null,e.unregistered?(0,Q.jsx)(eT,{root:e.root,name:e.name,disabled:i,notAddable:e.notAddable===!0}):(0,Q.jsx)(J,{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 — stop it and use `cezar projects remove`":void 0,disabled:i||t,onClick:a,children:`Remove`})]})]})}function eT({root:e,name:t,disabled:n=!1,notAddable:r=!1}){let i=Wt();return(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,"data-action":`project-add-boot`,"aria-label":`Add ${t} to your projects`,title:r?`Your home directory or a cezar task worktree cannot be a project — start cezar in a project folder, or use Open local folder`:`cezar is serving this folder — save it to your projects`,disabled:n||r||i.isPending,onClick:()=>i.mutate(e,{onSuccess:()=>Y(`${t} added to your projects`),onError:e=>Y(e.message,{tone:`danger`})}),children:`Add project`})}function tT({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=et(t,u,r),f=a&&d.length>0,p=(t,r)=>{n.mutate({id:e.id,tags:t},{onSuccess:()=>Y(r),onError:e=>Y(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){Y(`${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-violet/15 py-px pr-1 pl-2 text-meta font-medium whitespace-nowrap text-violet`,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-violet/25 disabled:opacity-50`,children:(0,Q.jsx)(Tc,{className:`size-3`,"aria-hidden":`true`})})]},t)),(0,Q.jsxs)(Hr,{open:f,onOpenChange:o,children:[(0,Q.jsx)(Rr,{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-label outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`})}),(0,Q.jsxs)(Kr,{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-micro 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:W(`flex w-full items-center rounded-sm px-2 py-1 text-left text-label font-medium text-violet`,t===s&&`bg-muted`),children:e},e))]})]})]})}function nT({project:e,workspaceMax:t}){let n=tn();return(0,Q.jsx)(Cw,{"aria-label":`Max parallel tasks for ${e.name}`,"data-slot":`project-max-parallel`,value:e.maxParallel??null,min:Gw,max:Kw,allowEmpty:!0,emptyStepFrom:Math.min(Kw,Math.max(Gw,t)),placeholder:`Inherit (${t})`,className:`w-40`,onCommit:r=>n.mutateAsync({id:e.id,maxParallel:r},{onSuccess:()=>Y(r===null?`${e.name} inherits the workspace limit (${t})`:`${e.name} runs at most ${r} task${r===1?``:`s`} at a time`),onError:e=>Y(e.message,{tone:`danger`})})})}var rT=30,iT=100,aT=32,oT=60,sT=85,cT=e=>Math.min(100,Math.max(0,e));function lT(){Xi({enabled:!ra()});let e=Qi(),t=Gi(),{isError:n}=Ki(),r=ea(),i=Zi(),a=Yi(),o=r===void 0?void 0:na(r),s=o?.cpuPct,c=e===`local`,l=o?.memTotalBytes??0,u=o?.memUsedBytes!==void 0&&l>0?cT(o.memUsedBytes/l*100):0,d=s===void 0?void 0:s>sT?`bg-danger`:s>=oT?`bg-pending`:`bg-primary`,f=s===void 0?void 0:cT(s),p=i.length>=2?i.map((e,t)=>{let n=t/(rT-1)*iT,r=aT-cT(e.cpuPct)/100*aT;return`${n.toFixed(1)},${r.toFixed(1)}`}).join(` `):void 0,m=o===void 0||!o.cpuLimited?s===void 0?`sampling…`:`${Math.round(s)}%`:s===void 0?`—`:`${Math.round(s)}%`,h=o===void 0||!o.cpuLimited?void 0:`${o.cpuLimitKind===`cpuset`?`cpuset `:``}${qi(o.cpuCores)}`,g=o===void 0?void 0:`${o.memUsedBytes===void 0?`—`:_(o.memUsedBytes)} / ${_(o.memTotalBytes)}`;return(0,Q.jsxs)(`section`,{"data-slot":`machine-card`,"aria-labelledby":`machine-card-title`,className:`rounded-xl border border-border bg-card/60 p-4`,children:[(0,Q.jsxs)(`header`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(Jc,{tone:c?`success`:`neutral`,pulse:c}),(0,Q.jsx)(`h2`,{id:`machine-card-title`,className:`text-sm font-semibold`,children:`Machine`}),(0,Q.jsx)(`span`,{"data-slot":`machine-card-mode`,className:`text-meta text-soft-foreground`,children:c?`live`:`last known`}),(0,Q.jsx)(`span`,{"data-slot":`machine-card-freshness`,className:`ml-auto shrink-0 text-meta tabular-nums text-soft-foreground`,children:a===void 0?`waiting…`:`updated ${a} s ago`})]}),o?.hasContainer===!0?(0,Q.jsxs)(`p`,{"data-slot":`machine-card-limits`,className:`mt-2 text-meta text-soft-foreground`,children:[`cgroup limits detected · `,o.source]}):null,t?(0,Q.jsx)(`p`,{"data-slot":`machine-card-transport`,className:`mt-2 text-meta text-soft-foreground`,children:`The server refused this origin's host topic, so live values are polled from the authenticated route instead.`}):null,n&&r===void 0?(0,Q.jsx)(`p`,{"data-slot":`machine-card-error`,className:`mt-3 text-label text-soft-foreground`,children:`Host totals are unavailable right now.`}):null,(0,Q.jsxs)(`div`,{className:`mt-3 grid gap-3`,children:[(0,Q.jsxs)(`div`,{"data-slot":`machine-card-cpu`,className:`grid grid-cols-[86px_1fr] items-start gap-3`,children:[(0,Q.jsxs)(`span`,{className:`pt-0.5 text-label text-soft-foreground`,children:[`CPU`,o?.cpuIsEffective===!0?` (effective)`:``]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`span`,{"data-slot":`machine-card-cpu-value`,className:`w-32 shrink-0 text-ui tabular-nums`,children:h===void 0?m:`${h} · ${m}`}),(0,Q.jsx)(`div`,{className:`h-2 min-w-0 flex-1 overflow-hidden rounded-full bg-muted`,children:d===void 0||f===void 0?null:(0,Q.jsx)(`div`,{"data-slot":`machine-card-cpu-bar`,className:W(`h-full rounded-full`,d),style:{width:`${f}%`}})})]}),p===void 0?null:(0,Q.jsx)(`svg`,{"data-slot":`machine-card-cpu-sparkline`,className:`mt-1.5 h-8 w-full text-primary`,viewBox:`0 0 ${iT} ${aT}`,preserveAspectRatio:`none`,role:`img`,"aria-label":`CPU over the last up to ${i.length*2} seconds`,children:(0,Q.jsx)(`polyline`,{points:p,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,vectorEffect:`non-scaling-stroke`})})]})]}),o===void 0?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{"data-slot":`machine-card-memory`,className:`grid grid-cols-[86px_1fr] items-center gap-3`,children:[(0,Q.jsxs)(`span`,{className:`text-label text-soft-foreground`,children:[`Memory`,o.memIsEffective?` (effective)`:``]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(`span`,{"data-slot":`machine-card-memory-value`,className:`w-32 shrink-0 text-ui tabular-nums`,children:g}),(0,Q.jsx)(`div`,{className:`h-2 min-w-0 flex-1 overflow-hidden rounded-full bg-muted`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-primary`,style:{width:`${u}%`}})})]})]}),typeof r?.swapTotalBytes==`number`&&typeof r?.swapUsedBytes==`number`?(0,Q.jsxs)(`div`,{"data-slot":`machine-card-swap`,className:`grid grid-cols-[86px_1fr] items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-label text-soft-foreground`,children:`Swap`}),(0,Q.jsxs)(`span`,{className:`text-ui tabular-nums`,children:[_(r.swapUsedBytes),` / `,_(r.swapTotalBytes)]})]}):null,r?.loadAvg===void 0?null:(0,Q.jsxs)(`div`,{"data-slot":`machine-card-load`,className:`grid grid-cols-[86px_1fr] items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-label text-soft-foreground`,children:`Load average`}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 text-ui tabular-nums`,children:[r.loadAvg.one.toFixed(2),` · `,r.loadAvg.five.toFixed(2),` ·`,` `,r.loadAvg.fifteen.toFixed(2),(0,Q.jsx)(`span`,{"data-slot":`machine-card-load-cores`,className:`rounded-md border border-border px-1.5 py-0.5 text-meta text-soft-foreground`,children:o.hasContainer&&o.hostCpuCount!==void 0?`host ${o.hostCpuCount} cores`:`${r.cpuCount} cores`})]})]}),o.hasContainer&&o.hostCpuCount!==void 0?(0,Q.jsxs)(`p`,{"data-slot":`machine-card-host-context`,className:`text-meta tabular-nums text-soft-foreground`,children:[`host `,qi(o.hostCpuCount),` · `,_(r?.memTotalBytes??0),` RAM`]}):null]})]}),(0,Q.jsx)(`p`,{"data-slot":`machine-card-caveat`,className:`mt-3 border-t border-border pt-2 text-meta text-soft-foreground`,children:o?.hasContainer===!0?`Effective values come from this process’s own cgroup; host totals are labelled.`:o?.cgroupUnknown===!0?`No cgroup information available for this process - host totals only.`:`Host totals - no cgroup limit tighter than the host detected for this process.`})]})}var uT=1,dT=16,fT=16,pT=1440,mT=1,hT=60,gT=256;function _T(){let e=Ht();return e.isPending?(0,Q.jsx)(`p`,{"data-slot":`resources-loading`,className:`p-4 text-ui text-soft-foreground md:p-6`,children:`Loading resource settings…`}):e.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(Nl,{}),tone:`danger`,title:`Resource settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,Q.jsx)(vT,{config:e.data})}function vT({config:e}){let t=U(),n=H({mutationFn:e=>mn(e),onSuccess:e=>t.setQueryData(B.config,e),onError:e=>Y(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<mT||u>hT,f=o===`park`?a===null:!d&&a===u,p=()=>n.mutate({resources:{monitoringWakeIntervalMinutes:o===`park`?null:u}},{onSuccess:()=>Y(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:()=>Y(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<gT),v=(e.resources.memoryLimitMb??0)===(_?-1:g),y=()=>n.mutate({resources:{memoryLimitMb:g===0?null:g}},{onSuccess:()=>Y(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.jsx)(lT,{}),(0,Q.jsxs)($,{title:`Max parallel tasks`,hint:`How many tasks run at once across every project. The rest wait in the queue. A non-git directory always runs one at a time.`,children:[(0,Q.jsx)(Cw,{"aria-label":`Max parallel tasks`,"data-slot":`resources-max-parallel`,value:e.resources.maxParallel,min:uT,max:dT,onCommit:e=>n.mutateAsync({resources:{maxParallel:e??uT}})}),(0,Q.jsxs)(`p`,{className:`text-meta text-soft-foreground`,children:[`Need a different limit for one project?`,` `,(0,Q.jsx)(yr,{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)($,{title:`Waiting-session idle timeout`,hint:`How long a plain waiting session may stay open without activity before its live backend session ends. Continue resumes it; set 0 to keep it open indefinitely.`,children:[(0,Q.jsx)(Cw,{"aria-label":`Waiting-session idle timeout`,"data-slot":`resources-idle-timeout`,value:e.resources.idleTimeoutMinutes??0,min:0,max:pT,onCommit:e=>n.mutateAsync({resources:{idleTimeoutMinutes:e??0}})}),(0,Q.jsx)(`p`,{className:`text-meta text-soft-foreground`,children:`Minutes; 0 keeps plain waiting sessions alive. Monitoring sessions are already exempt.`})]}),(0,Q.jsxs)($,{title:`Extra monitoring sessions`,hint:`How many agent sessions may wait on CI, sub-agents, or monitored commands without using an active task slot. Extra sessions stay alive but pause the queue.`,children:[(0,Q.jsx)(Cw,{"aria-label":`Extra monitoring sessions`,"data-slot":`resources-max-monitoring`,value:e.resources.maxMonitoringSessions??2,min:0,max:fT,onCommit:e=>n.mutateAsync({resources:{maxMonitoringSessions:e??0}})}),(0,Q.jsxs)(`p`,{className:`text-meta 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)($,{title:`Monitoring wake-up`,hint:`Park uses no model turns. Re-check sends the same agent a follow-up on this cadence until work completes or the 40-wakeup safety cap is reached.`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`select`,{"aria-label":`Monitoring wake-up`,"data-slot":`resources-monitoring-wake-mode`,value:o,disabled:n.isPending,onChange:e=>s(e.target.value),className:`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:`park`,children:`Park until resumed`}),(0,Q.jsx)(`option`,{value:`interval`,children:`Re-check on an interval`})]}),o===`interval`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`input`,{type:`number`,min:mT,max:hT,"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)(J,{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-meta text-danger`,children:`Enter a whole number from 1 to 60 minutes.`}):(0,Q.jsx)(`p`,{className:`text-meta text-soft-foreground`,children:`Applied consistently to Claude, Codex and OpenCode.`})]}),(0,Q.jsxs)($,{title:`Auto-resume after a usage limit`,hint:`When an agent stops because its provider usage limit is reached, cezar waits for the reset the provider named and continues the task 30 seconds later — up to 12 times in a row without you. Off leaves the task failed with its Continue button.`,children:[(0,Q.jsxs)(`select`,{"aria-label":`Auto-resume after a usage limit`,"data-slot":`resources-auto-resume`,value:m?`on`:`off`,disabled:n.isPending,onChange:e=>h(e.target.value===`on`),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:[(0,Q.jsx)(`option`,{value:`on`,children:`On`}),(0,Q.jsx)(`option`,{value:`off`,children:`Off`})]}),(0,Q.jsx)(`p`,{className:`text-meta text-soft-foreground`,children:`Applies to Claude, Codex and OpenCode — whenever the provider says when the limit lifts.`})]}),(0,Q.jsxs)($,{title:`Per-task memory limit`,hint:`When a task's whole process tree crosses this, the engine pauses it with a warning and starts the next queued task. Leave empty for no limit.`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`number`,inputMode:`numeric`,min:gT,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)(J,{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-meta text-danger`,children:[`Enter a whole number of at least `,gT,` MiB, or leave empty for no limit.`]}):(0,Q.jsx)(`p`,{className:`text-meta text-soft-foreground`,children:`Applies to newly started tasks.`})]}),(0,Q.jsxs)($,{title:`New task defaults`,hint:`Set stable composer defaults across projects. Explicit choices and run-shape constraints still win.`,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-meta 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-meta text-soft-foreground`,children:[`Inherited: `,b.inheritedWorktree?`On`:`Off`]})]})]}),(0,Q.jsx)(`p`,{className:`text-meta text-soft-foreground`,children:`Interactive skills may recommend both off. Multi-step and parallel runs remain isolated.`})]})]})}function yT(){let e=Ht();return e.isPending?(0,Q.jsx)(`p`,{"data-slot":`skills-settings-loading`,className:`p-4 text-ui text-soft-foreground md:p-6`,children:`Loading skill settings…`}):e.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(Jl,{}),tone:`danger`,title:`Skill settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,Q.jsx)(bT,{config:e.data})}function bT({config:e}){let t=U(),n=H({mutationFn:e=>mn(e),onSuccess:(e,n)=>{t.setQueryData(B.config,e),n.orgSkillsRepos&&t.invalidateQueries({predicate:e=>e.queryKey.includes(`skills`)})},onError:e=>Y(e.message,{tone:`danger`})}),r=e.skillsAutoUpdate===null,[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(`main`),c=e.orgSkillsRepos,l=()=>{let e=i.trim();!e||c.some(t=>t.repo===e)||n.mutate({orgSkillsRepos:[...c,{repo:e,ref:o.trim()||`main`}]},{onSuccess:()=>a(``)})};return(0,Q.jsxs)(`div`,{"data-slot":`skills-settings-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-4 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,Q.jsxs)(`section`,{"data-slot":`org-skills-repos`,className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:(0,Q.jsx)(`label`,{htmlFor:`org-skills-repo`,children:`Organisation skills repositories`})}),(0,Q.jsxs)(`p`,{className:`text-ui text-muted-foreground`,children:[`Git repositories whose skills are available in every project, kept up to date from the remote. A project's own skills with the same name win. Use `,(0,Q.jsx)(`code`,{children:`owner/name`}),`, a git URL or a local path; access uses your existing git credentials.`]})]}),c.length>0&&(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1`,children:c.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-md border border-border px-3 py-1.5 text-ui`,children:[(0,Q.jsxs)(`span`,{className:`truncate`,children:[e.repo,` `,(0,Q.jsxs)(`span`,{className:`text-soft-foreground`,children:[`@ `,e.ref]})]}),(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":`Remove ${e.repo}`,disabled:n.isPending,onClick:()=>n.mutate({orgSkillsRepos:c.filter(t=>t.repo!==e.repo)}),children:`Remove`})]},e.repo))}),(0,Q.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,Q.jsx)(Kc,{id:`org-skills-repo`,className:`min-w-48 flex-1`,placeholder:`my-org/skills`,value:i,onChange:e=>a(e.target.value)}),(0,Q.jsx)(Kc,{"aria-label":`Branch or ref`,className:`w-28`,placeholder:`main`,value:o,onChange:e=>s(e.target.value)}),(0,Q.jsx)(J,{type:`submit`,size:`sm`,disabled:n.isPending||!i.trim(),children:`Add repository`})]})]}),(0,Q.jsxs)(`section`,{className:`flex flex-col gap-3`,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:`skills-auto-update`,children:`Update Open Mercato skills automatically`})}),(0,Q.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:`Checks installed Open Mercato skills in the background and applies available updates. Other skills and untracked folders are never changed.`})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[(0,Q.jsx)(ff,{id:`skills-auto-update`,"data-slot":`skills-auto-update`,checked:e.effectiveSkillsAutoUpdate,disabled:n.isPending,onCheckedChange:e=>n.mutate({skillsAutoUpdate:e})}),(0,Q.jsxs)(`span`,{className:`text-meta text-soft-foreground`,children:[e.effectiveSkillsAutoUpdate?`On`:`Off`,r?` (default)`:``]})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-md border border-border bg-muted/30 px-3 py-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:r?`No override is saved. CEZ_SKILLS_AUTO_UPDATE supplies the inherited default when set; otherwise it is on.`:`An explicit workspace override is saved.`}),(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`skills-use-default`,disabled:r||n.isPending,onClick:()=>n.mutate({skillsAutoUpdate:null}),children:`Use default`})]})]})]})}var xT=`block w-full max-w-md 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`,ST={profile:`trunk`,taskWorkspace:`in-place`,landing:`auto`,reviewGate:!1},CT={profile:null,taskWorkspace:null,landing:null,defaultSkill:null,askSkill:null};function wT({config:e}){let t=wC(),n=(ie().data??[]).map(e=>e.name),r=e.profile===`trunk`,i=e.taskWorkspace===`in-place`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($,{title:`Development model`,hint:`Trunk-based: tasks work directly in the checkout one at a time, and changes that pass the required checks land on the base branch without a PR. Read-only questions run beside them. Every setting below stays adjustable.`,children:(0,Q.jsxs)(`select`,{"aria-label":`Development model`,"data-slot":`tasks-profile`,value:r?`trunk`:`branches`,disabled:t.isPending,onChange:e=>{let n=e.target.value===`trunk`;t.mutate(n?ST:CT,{onSuccess:()=>Y(n?`Trunk-based defaults applied`:`Branch-per-task defaults restored`)})},className:xT,children:[(0,Q.jsx)(`option`,{value:`branches`,children:`Branch per task (default) — a worktree and branch per task, reviewed before merging`}),(0,Q.jsx)(`option`,{value:`trunk`,children:`Trunk-based — work in the checkout, land checked changes on the base branch`})]})}),(0,Q.jsx)($,{title:`Where tasks work`,hint:`In the checkout: no worktree or branch per task. Write tasks take turns on the working tree, so two tasks started together never conflict. The composer can still ask for a worktree per task.`,children:(0,Q.jsxs)(`select`,{"aria-label":`Where tasks work`,"data-slot":`tasks-workspace`,value:e.taskWorkspace??``,disabled:t.isPending,onChange:e=>t.mutate({taskWorkspace:e.target.value||null}),className:xT,children:[(0,Q.jsx)(`option`,{value:``,children:`Composer default (isolated worktree)`}),(0,Q.jsx)(`option`,{value:`worktree`,children:`Isolated worktree per task`}),(0,Q.jsx)(`option`,{value:`in-place`,children:`The repo checkout, one write task at a time`})]})}),(0,Q.jsxs)($,{title:`How changes land`,hint:i?`Auto-land: a finished task waits for your review — check Changes, send corrections, then use the task header's Commit to the base branch: it commits, rebases on the remote, runs the required checks and pushes. Autonomous tasks land on their own. A conflict or a failing check goes back to the agent. The agent is told this permission is granted.`:`Auto-land applies to tasks that work in the checkout — set "Where tasks work" first.`,children:[(0,Q.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,Q.jsx)(ff,{"aria-label":`Auto-land on the base branch`,"data-slot":`tasks-landing`,checked:e.landing===`auto`,disabled:t.isPending,onCheckedChange:e=>t.mutate({landing:e?`auto`:null},{onSuccess:()=>Y(e?`Auto-land on — finished tasks push to the base branch`:`Auto-land off`)})}),(0,Q.jsx)(`span`,{className:`text-ui text-muted-foreground`,children:e.landing===`auto`?`Auto-land on the base branch`:`Review — nothing lands by itself (default)`})]}),e.landingBlocked?(0,Q.jsx)(`p`,{"data-slot":`tasks-landing-blocked`,className:`mt-2 text-ui text-destructive`,children:e.landingBlocked}):null]}),(0,Q.jsx)(ET,{config:e}),(0,Q.jsx)($,{title:`Default skills`,hint:`Preselected in the composer when nothing is picked: one for a new task, one for a read-only question (the Ask chip). A trunk-based project picks Ask on its own when the message ends with a question mark.`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Q.jsx)(TT,{label:`New task skill`,slot:`tasks-default-skill`,value:e.defaultSkill,names:n,disabled:t.isPending,onChange:e=>t.mutate({defaultSkill:e})}),(0,Q.jsx)(TT,{label:`Ask skill`,slot:`tasks-ask-skill`,value:e.askSkill,names:n,disabled:t.isPending,onChange:e=>t.mutate({askSkill:e})})]})}),(0,Q.jsx)($,{title:`Team skill repositories`,hint:`Skills from the shared team repositories. Turn off for a project whose skills live in the repo itself. Project-wide instructions for every task are under Instructions.`,children:(0,Q.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,Q.jsx)(ff,{"aria-label":`Team skill repositories`,"data-slot":`tasks-team-skills`,checked:e.teamSkills,disabled:t.isPending,onCheckedChange:e=>t.mutate({teamSkills:e})}),(0,Q.jsx)(`span`,{className:`text-ui text-muted-foreground`,children:e.teamSkills?`On`:`Off`})]})})]})}function TT({label:e,slot:t,value:n,names:r,disabled:i,onChange:a}){let o=n&&!r.includes(n)?[n,...r]:r;return(0,Q.jsxs)(`label`,{className:`flex flex-1 flex-col gap-1 text-label text-muted-foreground`,children:[e,(0,Q.jsxs)(`select`,{"aria-label":e,"data-slot":t,value:n??``,disabled:i,onChange:e=>a(e.target.value||null),className:xT,children:[(0,Q.jsx)(`option`,{value:``,children:`None`}),o.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))]})]})}function ET({config:e}){let t=wC(),n=e.requiredChecks.join(`
|
|
28
28
|
`),[r,i]=(0,Z.useState)(n);return(0,Z.useEffect)(()=>i(n),[n]),(0,Q.jsx)($,{title:`Required checks`,hint:`Shell commands, one per line, run in the checkout before every auto-land (e.g. npm test). A failure goes back to the agent with its output.`,children:(0,Q.jsx)(`textarea`,{"aria-label":`Required checks`,"data-slot":`tasks-required-checks`,value:r,rows:3,spellCheck:!1,placeholder:`npm test`,disabled:t.isPending,onChange:e=>i(e.target.value),onBlur:()=>{let e=r.split(`
|
|
29
29
|
`).map(e=>e.trim()).filter(Boolean);e.join(`
|
|
30
|
-
`)!==n&&t.mutate({requiredChecks:e.length?e:null},{onSuccess:()=>Y(`Required checks saved`)})},className:`block w-full max-w-md rounded-md border border-input bg-card px-3 py-1.5 font-mono text-ui shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`})})}function DT(){let e=En();return e.isPending?(0,Q.jsx)(`p`,{"data-slot":`tasks-loading`,className:`p-4 text-ui text-soft-foreground md:p-6`,children:`Loading task settings…`}):e.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(Bl,{}),tone:`danger`,title:`Task settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,Q.jsx)(OT,{config:e.data})}function OT({config:e}){let t=ln(),n=wC();return(0,Q.jsxs)(`div`,{"data-slot":`tasks-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)(wT,{config:e}),(0,Q.jsx)($,{title:`Base branch`,hint:`New task worktrees branch from this and draft PRs target it. Also settable from the Git view.`,children:t.data?.info?(0,Q.jsxs)(`select`,{"aria-label":`Base branch`,"data-slot":`tasks-base-branch`,value:e.baseBranch??``,disabled:n.isPending,onChange:e=>n.mutate({baseBranch:e.target.value||null}),className:`block w-full max-w-md 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)`}),t.data.branches.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))]}):(0,Q.jsx)(`p`,{"data-slot":`tasks-base-branch-unavailable`,className:`text-ui text-soft-foreground`,children:t.isPending?`Loading branches…`:`Not a git repository — tasks run in place, no branching.`})}),(0,Q.jsx)($,{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)(ff,{"aria-label":`Review changes before finishing`,"data-slot":`tasks-review-gate`,checked:e.reviewGate??!1,disabled:n.isPending,onCheckedChange:e=>n.mutate({reviewGate:e},{onSuccess:()=>Y(e?`Review gate on`:`Review gate off`)})}),(0,Q.jsxs)(`span`,{className:`text-ui text-muted-foreground`,children:[e.reviewGate??!1?`On`:`Off`,e.reviewGate===null&&` (default)`]})]})}),(0,Q.jsx)($,{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)(ff,{"aria-label":`Live title updates`,"data-slot":`tasks-live-title-updates`,checked:e.liveTitleUpdates??!0,disabled:n.isPending,onCheckedChange:e=>n.mutate({liveTitleUpdates:e},{onSuccess:()=>Y(e?`Live title updates on`:`Live title updates off`)})}),(0,Q.jsxs)(`span`,{className:`text-ui text-muted-foreground`,children:[e.liveTitleUpdates??!0?`On`:`Off`,e.liveTitleUpdates===null&&` (default)`]})]})})]})}var kT=`/workspace/config-bundle`;async function AT(e,t={}){let n=Zn(e),r=new Headers(t.headers);r.set(dn,Ge());try{return await fetch(n,{...t,headers:r,credentials:`include`})}catch(e){throw e instanceof DOMException&&e.name===`AbortError`?e:new cn(0,`cannot reach the cezar server (${n})`,{cause:e})}}async function jT(e){let t=await e.text().catch(()=>``),n;try{let e=JSON.parse(t);typeof e?.error==`string`&&(n=e.error)}catch{}return new cn(e.status,n??`${e.status} ${e.statusText||`request failed`}`.trim())}async function MT(e,t,n){let r=await AT(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!r.ok)throw await jT(r);let i=n.safeParse(await r.json().catch(()=>void 0));if(!i.success)throw new cn(r.status,`the cezar server answered ${e} with an unexpected body`);return i.data}async function NT(e){let t=await AT(`${kT}${e===null?``:`?projects=${e.map(encodeURIComponent).join(`,`)}`}`);if(!t.ok)throw await jT(t);return{blob:await t.blob(),filename:PT(t.headers.get(`content-disposition`))}}function PT(e,t=new Date){let n=e?.match(/filename\*?=(?:UTF-8'')?"?([^";]+)"?/i);return n?.[1]?decodeURIComponent(n[1]):`cezar-config-${t.toISOString().slice(0,10)}.json`}function FT(e){return MT(`${kT}/preview`,e,cr)}function IT(e){return MT(`${kT}/import`,e,er)}function LT(e){if(e.trim()===``)return{ok:!1,error:`this file is empty`};if(e.length>5242880)return{ok:!1,error:`this file is larger than 5 MB`};let t;try{t=JSON.parse(e)}catch{return{ok:!1,error:`this file is not JSON`}}let n=ir.safeParse(t);if(n.success)return{ok:!0,bundle:n.data};let r=n.error.issues,i=r.find(e=>e.path[0]===`format`)??r.find(e=>e.path[0]===`version`)??r[0],a=i&&i.path.length>0&&i.path[0]!==`format`&&i.path[0]!==`version`?` (at ${i.path.join(`.`)})`:``;return{ok:!1,error:`${i?.message??`not a cezar configuration bundle`}${a}`}}var RT=[`secret values`,`tracker connections`,`agent accounts`,`webhooks`,`paths`],zT=`rounded-md border border-input bg-card px-2 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,BT=`__skip__`;function VT(){let e=C().data?.capabilities?.localHandoff??!0;return(0,Q.jsxs)(`div`,{"data-slot":`transfer-section`,className:`mx-auto flex w-full max-w-3xl flex-col gap-8 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,Q.jsx)(HT,{}),(0,Q.jsx)(KT,{localHandoff:e})]})}function HT(){let e=a(),t=(e.data?.projects??[]).filter(e=>e.status!==`missing`),[n,r]=(0,Z.useState)(new Set),i=t.filter(e=>!n.has(e.id)),o=H({mutationFn:()=>NT(i.length===t.length?null:i.map(e=>e.id)),onSuccess:({blob:e,filename:t})=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.append(r),r.click(),r.remove(),URL.revokeObjectURL(n),Y(`Downloaded ${t}`)},onError:e=>Y(e.message,{tone:`danger`})}),s=e=>r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,Q.jsx)($,{title:`Export`,hint:`Download this machine's portable settings — workspace preferences and, per project, its config, prompt templates and automations — as one JSON file.`,children:(0,Q.jsxs)(`div`,{"data-slot":`transfer-export`,className:`flex flex-col gap-3`,children:[e.isPending?(0,Q.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:`Loading projects…`}):t.length===0?(0,Q.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:`No projects registered — the file will carry workspace settings only.`}):(0,Q.jsxs)(`fieldset`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`legend`,{className:`mb-1 text-meta text-soft-foreground`,children:`Projects to include`}),t.map(e=>(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"data-slot":`transfer-export-project`,checked:!n.has(e.id),onChange:()=>s(e.id)}),(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name})]},e.id))]}),(0,Q.jsxs)(`p`,{"data-slot":`transfer-excluded`,className:`text-meta text-soft-foreground`,children:[`Not included: `,RT.join(`, `),`. Secret names and the tracker to reconnect travel as reminders.`]}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(J,{type:`button`,size:`sm`,"data-action":`transfer-download`,disabled:o.isPending||e.isPending,onClick:()=>o.mutate(),children:o.isPending?`Preparing…`:`Download`})})]})})}var UT={mapping:{},resolutions:{}};function WT(e,t){return{bundle:e,...t.selection?{selection:t.selection}:{},...Object.keys(t.mapping).length>0?{mapping:t.mapping}:{},...Object.keys(t.resolutions).length>0?{resolutions:t.resolutions}:{}}}function GT(){return(0,Q.jsx)($,{title:`Import`,hint:`Apply a configuration bundle exported from another cezar.`,children:(0,Q.jsx)(`p`,{"data-slot":`transfer-import-hosted`,className:`text-ui text-soft-foreground`,children:`Import is only available on a local cockpit.`})})}function KT({localHandoff:e}){let t=(0,Z.useId)(),n=(0,Z.useRef)(null),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(UT),[l,u]=(0,Z.useState)(null),d=dt({queryKey:[`transfer`,`preview`,r?.nonce,s],queryFn:()=>FT(WT(r.bundle,s)),enabled:r!==null&&e,retry:!1,gcTime:0,placeholderData:Dn}),f=H({mutationFn:e=>IT({...WT(r.bundle,s),planDigest:e.planDigest}),onSuccess:e=>{u(e.applied),Y(`Applied ${e.applied.length} section${e.applied.length===1?``:`s`}`)},onError:()=>void d.refetch()});if(!e||d.data?.importAllowed===!1)return(0,Q.jsx)(GT,{});let p=async e=>{let t=e.target.files?.[0];if(e.target.value=``,!t)return;if(u(null),f.reset(),c(UT),t.size>5242880){i(null),o(`this file is larger than 5 MB`);return}let n=LT(await t.text());if(!n.ok){i(null),o(n.error);return}o(null),i({name:t.name,bundle:n.bundle,nonce:Date.now()})},m=e=>{u(null),f.reset(),c(e)},h=r&&!d.isError?d.data:void 0,g=a??(r&&d.isError?d.error.message:null);return(0,Q.jsx)($,{title:`Import`,hint:`Apply a configuration bundle exported from another cezar. Nothing is written until you apply, and automations always land paused.`,children:(0,Q.jsxs)(`div`,{"data-slot":`transfer-import`,className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`input`,{ref:n,id:t,type:`file`,accept:`application/json,.json`,"data-slot":`transfer-import-file`,className:`sr-only`,onChange:e=>void p(e)}),(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>n.current?.click(),children:`Choose file…`}),(0,Q.jsx)(`label`,{htmlFor:t,className:`text-meta text-soft-foreground`,children:r?r.name:`A .json file from Settings → Transfer → Export`})]}),g?(0,Q.jsx)(`p`,{role:`alert`,"data-slot":`transfer-import-error`,className:`text-ui text-danger`,children:g}):null,r&&!h&&d.isFetching?(0,Q.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:`Reading the file…`}):null,h?(0,Q.jsx)(qT,{plan:h,choices:s,onChange:m,busy:d.isFetching,applying:f.isPending,applyError:f.isError?f.error.message:null,applied:l,onApply:()=>f.mutate(h)}):null]})})}function qT({plan:e,choices:t,onChange:n,busy:r,applying:i,applyError:o,applied:s,onApply:c}){let l=(a().data?.projects??[]).filter(e=>e.status!==`missing`),u=e=>t.selection?t.selection.includes(e.id):e.selected,d=e.sections.filter(u),f=d.filter(e=>e.issues.length>0),p=t=>n(n=>{let r=n.selection??e.sections.filter(e=>e.selected).map(e=>e.id),i=r.includes(t.id)?r.filter(e=>e!==t.id):[...r,t.id];return{...n,selection:i}}),m=(e,t,r)=>n(n=>{let i=n.resolutions[e]??{};return{...n,resolutions:{...n.resolutions,[e]:{...i,keys:{...i.keys,[t]:r}}}}}),h=(e,t,r)=>n(n=>{let i=n.resolutions[e]??{},a={...i.automations};return r?a[String(t)]=r:delete a[String(t)],{...n,resolutions:{...n.resolutions,[e]:{...i,automations:a}}}}),g=(e,t)=>n(n=>{let r={...n.mapping};return t===``?delete r[String(e)]:r[String(e)]=t===BT?null:t,{...n,mapping:r}}),_=t=>t===void 0?`Workspace`:e.projects.find(e=>e.index===t)?.name??`Project ${t+1}`,v=e=>l.find(t=>t.id===e)?.name??e;return(0,Q.jsxs)(`div`,{"data-slot":`transfer-preview`,"aria-busy":r,className:`flex flex-col gap-6`,children:[e.projects.length>0?(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Projects`}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:e.projects.map(e=>(0,Q.jsxs)(`li`,{"data-slot":`transfer-project`,"data-match":e.match,className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name}),e.remote?(0,Q.jsx)(`span`,{className:`text-meta text-soft-foreground`,children:e.remote}):null,(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`text-soft-foreground`,children:`→`}),(0,Q.jsx)(XT,{name:e.name,value:YT(t.mapping[String(e.index)],e.targetProjectId),registered:l,onChange:t=>g(e.index,t)}),e.match===`remote`?(0,Q.jsx)(`span`,{className:`text-meta text-soft-foreground`,children:`(same remote)`}):null]},e.index))})]}):null,(0,Q.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Sections`}),e.sections.length===0?(0,Q.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:`This file changes nothing on this machine.`}):e.sections.map(e=>(0,Q.jsx)(ZT,{section:e,title:`${_(e.projectIndex)} · ${JT[e.kind]}`,target:e.projectIndex===void 0?void 0:v(e.targetProjectId),checked:u(e),resolution:t.resolutions[e.id],onToggle:()=>p(e),onKey:(t,n)=>m(e.id,t,n),onRow:(t,n)=>h(e.id,t,n)},e.id))]}),(0,Q.jsx)(nE,{plan:e}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[f.length>0?(0,Q.jsx)(`p`,{"data-slot":`transfer-blocked`,className:`text-ui text-danger`,children:`Untick or fix the sections with problems before applying.`}):null,o?(0,Q.jsx)(`p`,{role:`alert`,"data-slot":`transfer-apply-error`,className:`text-ui text-danger`,children:o}):null,s?(0,Q.jsxs)(`p`,{"data-slot":`transfer-applied`,className:`text-ui text-foreground`,children:[`Applied `,s.length,` section`,s.length===1?``:`s`,`. Imported automations are paused — enable them on each project’s Automations page.`]}):null,(0,Q.jsx)(`div`,{children:(0,Q.jsx)(J,{type:`button`,size:`sm`,"data-action":`transfer-apply`,disabled:r||i||d.length===0||f.length>0||s!==null,onClick:c,children:i?`Applying…`:`Apply selected (${d.length})`})})]})]})}var JT={workspace:`settings`,config:`config`,promptTemplates:`prompt templates`,automations:`automations`};function YT(e,t){return e===null?BT:e??t??``}function XT({name:e,value:t,registered:n,onChange:r}){return(0,Q.jsxs)(`select`,{"aria-label":`Import ${e} into`,"data-slot":`transfer-mapping`,value:t,onChange:e=>r(e.target.value),className:zT,children:[(0,Q.jsx)(`option`,{value:``,children:`Choose a project…`}),n.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.name},e.id)),(0,Q.jsx)(`option`,{value:BT,children:`Skip`})]})}function ZT({section:e,title:t,target:n,checked:r,resolution:i,onToggle:a,onKey:o,onRow:s}){return(0,Q.jsxs)(`div`,{"data-slot":`transfer-section-card`,"data-section-id":e.id,className:`flex flex-col gap-2 rounded-lg border border-border bg-card p-3`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:r,onChange:a,"aria-label":t}),(0,Q.jsx)(`span`,{className:`font-medium`,children:t}),n?(0,Q.jsxs)(`span`,{className:`text-meta text-soft-foreground`,children:[`→ `,n]}):null,e.runsCommands?(0,Q.jsxs)($d,{variant:`outline`,"data-slot":`transfer-runs-commands`,className:`border-warning text-warning`,children:[(0,Q.jsx)(wc,{"aria-hidden":!0}),` runs shell commands`]}):null]}),e.issues.length>0?(0,Q.jsx)(`ul`,{"data-slot":`transfer-section-issues`,className:`text-meta text-danger`,children:e.issues.map(e=>(0,Q.jsx)(`li`,{children:e},e))}):null,e.changes.length>0?(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.changes.map(e=>(0,Q.jsx)($T,{change:e,value:i?.keys?.[e.key]??e.action,onChange:t=>o(e.key,t)},e.key))}):null,e.automations?.length?(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.automations.map(e=>(0,Q.jsx)(tE,{row:e,resolution:i?.automations?.[String(e.index)],onChange:t=>s(e.index,t)},e.index))}):null,e.changes.length===0&&!e.automations?.length?(0,Q.jsx)(`p`,{className:`text-meta text-soft-foreground`,children:`Nothing to change.`}):null]})}function QT(e){if(e===void 0)return`(not set)`;let t=typeof e==`string`?JSON.stringify(e):JSON.stringify(e)??String(e);return t.length>120?`${t.slice(0,119)}…`:t}function $T({change:e,value:t,onChange:n}){return(0,Q.jsxs)(`li`,{"data-slot":`transfer-change`,"data-key":e.key,className:`flex flex-wrap items-center gap-2 text-meta`,children:[(0,Q.jsx)(`code`,{className:`font-mono text-foreground`,children:e.key}),(0,Q.jsx)(`span`,{"data-slot":`transfer-change-from`,className:`font-mono text-soft-foreground`,children:QT(e.from)}),(0,Q.jsx)(`span`,{"aria-hidden":!0,children:`→`}),(0,Q.jsx)(`span`,{"data-slot":`transfer-change-to`,className:`font-mono text-foreground`,children:QT(e.to)}),e.conflict?(0,Q.jsxs)(`select`,{"aria-label":`${e.key}: keep or take`,"data-slot":`transfer-change-action`,value:t,onChange:e=>n(e.target.value),className:zT,children:[(0,Q.jsx)(`option`,{value:`keep`,children:`Keep this machine’s`}),(0,Q.jsx)(`option`,{value:`take`,children:`Take imported`})]}):(0,Q.jsxs)(`span`,{className:`text-soft-foreground`,children:[`(`,e.action===`take`?`new`:`unchanged`,`)`]})]})}var eE={create:`create`,skip:`skip`,rename:`rename`,replace:`replace`};function tE({row:e,resolution:t,onChange:n}){let r=r=>{if(!r){n(e.collision&&t?{...t,acceptCommands:void 0}:void 0);return}n(t?{...t,acceptCommands:!0}:{action:e.collision?`rename`:`create`,acceptCommands:!0})};return(0,Q.jsxs)(`li`,{"data-slot":`transfer-automation`,"data-index":e.index,className:`flex flex-col gap-1 text-meta`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:e.name}),(0,Q.jsx)(`span`,{className:`text-soft-foreground`,children:e.kind}),(0,Q.jsxs)($d,{variant:`secondary`,children:[eE[e.action],e.newName&&e.action===`rename`?` → ${e.newName}`:``]}),e.collision?(0,Q.jsxs)(`select`,{"aria-label":`${e.name}: on a name collision`,"data-slot":`transfer-automation-action`,value:t?.action??`skip`,onChange:e=>n({...t,action:e.target.value,newName:void 0}),className:zT,children:[(0,Q.jsx)(`option`,{value:`skip`,children:`Skip`}),(0,Q.jsx)(`option`,{value:`rename`,children:`Rename`}),e.collision.id?(0,Q.jsx)(`option`,{value:`replace`,children:`Replace (and pause)`}):null]}):null,e.runsCommands?(0,Q.jsxs)(`label`,{className:`flex items-center gap-1 text-warning`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"data-slot":`transfer-automation-accept`,checked:t?.acceptCommands===!0,onChange:e=>r(e.target.checked)}),(0,Q.jsx)(wc,{"aria-hidden":!0,className:`size-3`}),` runs shell commands — allow`]}):null]}),[...e.issues,...e.warnings].map(t=>(0,Q.jsx)(`span`,{className:e.issues.includes(t)?`text-danger`:`text-soft-foreground`,children:t},t))]})}function nE({plan:e}){let t=e.projects.filter(e=>e.reminders.secretNames.length>0||e.reminders.tracker);return e.reminders.workspaceSecretNames.length===0&&t.length===0?null:(0,Q.jsxs)(`section`,{"data-slot":`transfer-reminders`,className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Re-enter these secrets`}),(0,Q.jsx)(`p`,{className:`text-meta text-soft-foreground`,children:`A bundle never carries secret values or tracker credentials. Add them again on this machine after importing.`}),(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:[e.reminders.workspaceSecretNames.length>0?(0,Q.jsxs)(`li`,{"data-slot":`transfer-reminder`,"data-scope":`workspace`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:`Workspace secrets:`}),` `,e.reminders.workspaceSecretNames.join(`, `)]}):null,t.map(e=>(0,Q.jsxs)(`li`,{"data-slot":`transfer-reminder`,"data-scope":`project:${e.index}`,children:[(0,Q.jsxs)(`span`,{className:`font-medium`,children:[e.name,`:`]}),` `,e.reminders.secretNames.length>0?`secrets ${e.reminders.secretNames.join(`, `)}`:null,e.reminders.secretNames.length>0&&e.reminders.tracker?`; `:null,e.reminders.tracker?`reconnect the ${e.reminders.tracker} tracker`:null]},e.index))]})]})}function rE(){let e=Tt(),t=Fr(),n=En(),[r,i]=(0,Z.useState)(null),a=t.data?.worktrees??[],o=!!n.data?.worktreeLifecycle&&(n.data.worktreeLifecycle.afterCreate.length>0||n.data.worktreeLifecycle.beforeRemove.length>0),s=U(),[c,l]=(0,Z.useState)(null),u=async()=>{await Promise.all([s.invalidateQueries({queryKey:V.worktrees}),s.invalidateQueries({queryKey:Pr.all()})])},d=H({mutationFn:()=>lt(),onSuccess:e=>{u(),Y(e.reclaimed.length===0?o||a.some(e=>e.operation||e.autoCleanupSuppressed)?`No worktrees reclaimed yet. Pending cleanup or retained worktrees may keep usage above the limit.`:`Nothing to reclaim — all worktrees are within the limit`:`Reclaimed ${e.reclaimed.length} worktree${e.reclaimed.length===1?``:`s`} (branch kept)`)},onError:e=>Y(e.message,{tone:`danger`})}),f=H({mutationFn:async e=>o||a.some(t=>t.runId===e)?z({requestId:crypto.randomUUID(),runId:e,intent:`remove-worktree`}):wt(e),onSuccess:(t,n)=>{u(),`operation`in t?(i({id:t.operation.id,title:e.data?.worktrees.find(e=>e.runId===n)?.title??n}),Y(`Cleanup requested. The worktree remains until cleanup and removal complete.`)):Y(`Worktree removed`)},onError:e=>Y(e.message,{tone:`danger`})}),p=H({mutationFn:e=>z({requestId:crypto.randomUUID(),worktreeId:e,intent:`orphan`}),onSuccess:e=>{i({id:e.operation.id,title:`Orphan worktree`}),u(),Y(`Orphan cleanup requested. Review its progress below.`)},onError:e=>Y(e.message,{tone:`danger`})});if(e.isPending)return(0,Q.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-ui text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,Q.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-ui text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:m,totalBytes:h,keep:g}=e.data,v=d.isPending||f.isPending||p.isPending;return(0,Q.jsxs)(`div`,{"data-slot":`worktrees-panel`,className:`flex flex-col gap-3`,children:[m.length===0?(0,Q.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`text-ui text-soft-foreground`,children:`No task worktrees on disk.`}):(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:`Task worktrees currently materialized on disk`}),(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{className:`border-b border-border text-left text-label text-soft-foreground`,children:[(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Task`}),(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:`Size`}),(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Age`}),(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium text-right`,children:`Actions`})]})}),(0,Q.jsx)(`tbody`,{children:m.map(e=>(0,Q.jsx)(iE,{worktree:e,lifecycle:a.find(t=>t.runId===e.runId),disabled:v||!!a.find(t=>t.runId===e.runId)?.operation,onDelete:()=>l({kind:`delete`,runId:e.runId,title:e.title})},e.runId))})]})}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`p`,{"data-slot":`worktrees-footer`,className:`text-label text-soft-foreground`,children:[m.length,` worktree`,m.length===1?``:`s`,h===null?` · size unavailable`:` · ${_(h)||`0 kB`} on disk`,` · `,g===0?`keeping all (unlimited)`:`keeping the last ${g}`]}),(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,"data-action":`worktrees-reclaim-now`,disabled:v,onClick:()=>l({kind:`reclaim`}),children:`Reclaim now`})]}),t.isError&&(0,Q.jsxs)(`p`,{className:`text-xs text-danger`,role:`alert`,children:[`Lifecycle state could not be loaded: `,t.error.message]}),a.filter(e=>e.operation||e.autoCleanupSuppressed||e.needsAttention||!e.task).map(e=>(0,Q.jsxs)(`section`,{className:`min-w-0 rounded-md border border-border p-3`,"data-slot":`lifecycle-worktree-row`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium`,children:e.task?.title??`Orphan worktree ${e.runId.slice(0,8)}`}),(0,Q.jsx)(`p`,{className:`break-all font-mono text-meta text-muted-foreground`,children:e.worktreePath}),e.error&&(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-danger`,children:e.error}),e.needsAttention&&(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-danger`,children:[e.operation?.phase===`setup`?`Setup needs attention`:`Cleanup needs attention`,` — worktree retained.`]}),e.autoCleanupSuppressed&&(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Automatic cleanup is suppressed for this generation because it was kept or cancelled. Explicit removal is still available.`}),e.operation?(0,Q.jsx)(`div`,{id:`lifecycle-operation-${e.operation.id}`,className:`mt-3 scroll-mt-4`,children:(0,Q.jsx)(No,{operationId:e.operation.id,worktreePath:e.worktreePath,taskTitle:e.task?.title})}):!e.task&&!e.error&&e.onDisk?(0,Q.jsx)(J,{className:`mt-2`,type:`button`,variant:`outline`,size:`sm`,disabled:v,onClick:()=>l({kind:`orphan`,worktreeId:e.worktreeId,title:e.worktreePath}),children:`Remove orphan worktree`}):null]},e.worktreeId)),r&&!a.some(e=>e.operation?.id===r.id)&&(0,Q.jsx)(`div`,{id:`lifecycle-operation-${r.id}`,children:(0,Q.jsx)(No,{operationId:r.id,taskTitle:r.title})}),(0,Q.jsx)(Vc,{open:c!==null,onOpenChange:e=>!e&&l(null),children:(0,Q.jsxs)(Ic,{children:[(0,Q.jsxs)(Bc,{children:[(0,Q.jsx)(Fc,{children:c?.kind===`delete`||c?.kind===`orphan`?`Delete this worktree?`:`Reclaim old worktrees?`}),(0,Q.jsx)(Pc,{children:c?.kind===`delete`||c?.kind===`orphan`?(0,Q.jsxs)(Q.Fragment,{children:[`This removes the worktree directory and its branch — the local-only work is not recoverable afterwards. Configured cleanup scripts run first; failures retain the directory for your recovery choice.`,(0,Q.jsx)(`span`,{className:`mt-1 block truncate font-medium text-foreground`,title:c.title,children:c.title})]}):`Finished worktrees beyond the keep-limit are reclaimed now (directory only). Their branches are kept, so the work stays recoverable.`})]}),(0,Q.jsxs)(Rc,{children:[(0,Q.jsx)(zc,{children:`Keep it`}),(0,Q.jsx)(Lc,{"data-action":`worktrees-confirm`,className:c?.kind===`delete`||c?.kind===`orphan`?`bg-danger text-danger-foreground hover:brightness-[0.96]`:void 0,onClick:()=>{c?.kind===`reclaim`?d.mutate():c?.kind===`delete`?f.mutate(c.runId):c?.kind===`orphan`&&p.mutate(c.worktreeId),l(null)},children:c?.kind===`delete`||c?.kind===`orphan`?`Delete`:`Reclaim now`})]})]})})]})}function iE({worktree:e,lifecycle:t,disabled:n,onDelete:r}){return(0,Q.jsxs)(`tr`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`border-b border-border last:border-0`,children:[(0,Q.jsxs)(`th`,{scope:`row`,className:`max-w-[220px] px-3 py-2 text-left font-normal`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-foreground`,title:e.title,children:e.title}),(0,Q.jsx)(`span`,{className:`block truncate font-mono text-meta text-soft-foreground`,children:e.branch??e.runId.slice(0,8)})]}),(0,Q.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-label text-soft-foreground`,children:e.status}),t?.needsAttention&&(0,Q.jsx)(`span`,{className:`block text-meta text-danger`,children:t.operation?.phase===`setup`?`Setup needs attention`:`Cleanup needs attention`}),t?.autoCleanupSuppressed&&(0,Q.jsx)(`span`,{className:`block text-meta text-muted-foreground`,children:`Automatic cleanup suppressed`}),e.reclaimable&&!t?.autoCleanupSuppressed?(0,Q.jsx)(`span`,{"data-slot":`worktree-reclaimable`,className:`ml-1 text-meta text-soft-foreground`,children:`(reclaimable)`}):null]}),(0,Q.jsx)(`td`,{className:`px-3 py-2 tabular-nums text-soft-foreground`,children:e.sizeBytes===null?`—`:_(e.sizeBytes)||`0 kB`}),(0,Q.jsx)(`td`,{className:`px-3 py-2 tabular-nums text-soft-foreground`,children:Xc(e.finishedAt??void 0)||`—`}),(0,Q.jsx)(`td`,{className:`px-3 py-2 text-right`,children:(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`worktree-delete`,"aria-label":`Delete the worktree for ${e.title}`,disabled:n,onClick:r,children:`Delete`})})]})}var aE=()=>({afterCreate:[],beforeRemove:[]}),oE=[`afterCreate`,`beforeRemove`],sE={afterCreate:`After worktree creation`,beforeRemove:`Before worktree removal`},cE=[[`root_path`,`The selected project’s root directory`],[`worktree_path`,`The isolated worktree directory`],[`worktree_id`,`Stable cez-prefixed resource identity`],[`task_id`,`The original task ID`]],lE=`w-full rounded-md border border-input bg-card px-3 py-2 text-sm outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`;function uE({config:e}){let t=U(),n=V.config,r=(0,Z.useRef)(!0);(0,Z.useEffect)(()=>(r.current=!0,()=>{r.current=!1}),[]);let i=Fr(),[a,o]=(0,Z.useState)(e.worktreeLifecycle??aE()),[c,l]=(0,Z.useState)(e.worktreeLifecycle??aE()),[u,d]=(0,Z.useState)(e.worktreeLifecycleRevision??null),[f,p]=(0,Z.useState)({}),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)({}),[b,x]=(0,Z.useState)(null),S=(0,Z.useRef)(new Map),C=(0,Z.useRef)({draft:a,previewWorktree:g});C.current={draft:a,previewWorktree:g};let w=JSON.stringify(a)!==JSON.stringify(c);(0,Z.useEffect)(()=>{if(w)return;let t=e.worktreeLifecycle??aE();o(t),l(t),d(e.worktreeLifecycleRevision??null)},[e.worktreeLifecycle,e.worktreeLifecycleRevision,w]);let T=(e,t,n)=>{o(r=>({...r,[e]:r[e].map(e=>e.id===t?{...e,...n}:e)})),p(e=>({...e,[t]:``})),h(``),y(e=>{let n={...e};return delete n[t],n})},E=(e,t,n)=>{let r=S.current.get(t.id),i=r?.selectionStart??t.command.length,a=r?.selectionEnd??i,o=`{{ ${n} }}`;T(e,t.id,{command:t.command.slice(0,i)+o+t.command.slice(a)}),requestAnimationFrame(()=>{r?.focus(),r?.setSelectionRange(i+o.length,i+o.length)})},D=(e,t,n)=>{o(r=>{let i=[...r[e]],a=i.splice(t,1)[0];return i.splice(t+n,0,a),{...r,[e]:i}}),h(``)},O=async e=>{x(e.id);try{let t=await Ke({command:e.command,...g?{worktreeId:g}:{}}),n=oE.flatMap(e=>C.current.draft[e]).find(t=>t.id===e.id);if(!r.current||n?.command!==e.command||C.current.previewWorktree!==g)return;y(n=>({...n,[e.id]:t})),p(t=>({...t,[e.id]:``}))}catch(t){p(n=>({...n,[e.id]:t instanceof Error?t.message:`Preview failed`}))}finally{x(null)}},k=H({mutationFn:async()=>{p({}),h(``);let e=Xn.safeParse(a);if(!e.success){let t={};for(let n of e.error.issues){let e=n.path[0],r=typeof n.path[1]==`number`?a[e]?.[n.path[1]]?.id:void 0;t[r??`form`]=n.message}throw p(t),Error(`Check the highlighted commands before saving.`)}for(let t of oE)for(let n of e.data[t]){if(!r.current)throw Error(`Settings closed; saving cancelled.`);try{await Ke({command:n.command})}catch(e){throw p({[n.id]:e instanceof Error?e.message:`Invalid template`}),Error(`Check the highlighted command before saving.`)}}if(!r.current)throw Error(`Settings closed; saving cancelled.`);return ve({worktreeLifecycle:e.data,worktreeLifecycleRevision:u})},onSuccess:e=>{let r=e.worktreeLifecycle??aE();l(r),o(r),d(e.worktreeLifecycleRevision??null),t.setQueryData(n,e),h(`Saved. Retry uses these commands. Saving does not restart paused scripts.`)}}),A=async()=>{try{let e=await s();t.setQueryData(n,e);let r=e.worktreeLifecycle??aE();o(r),l(r),d(e.worktreeLifecycleRevision??null),p({}),y({}),h(`Loaded saved scripts.`),k.reset()}catch(e){p({form:e instanceof Error?e.message:`Settings could not be loaded`})}},j=i.data?.worktrees.filter(e=>e.operation&&e.needsAttention)??[];return(0,Q.jsxs)(`div`,{id:`worktree-lifecycle-scripts`,className:`flex min-w-0 flex-col gap-5`,"data-slot":`worktree-lifecycle-editor`,children:[(0,Q.jsxs)(`div`,{className:`rounded-md border border-border bg-muted/30 p-3 text-ui text-muted-foreground`,children:[(0,Q.jsx)(`p`,{children:`Scripts apply only to this project. Saving commands opts in to running them as the Cezar host user, with that user’s local privileges.`}),(0,Q.jsx)(`p`,{className:`mt-1`,children:`Runtime: noninteractive Bash, in the isolated worktree directory. Bash must be installed on the host. Commands run in order; the default timeout is 30 minutes.`}),(0,Q.jsxs)(`p`,{className:`mt-1`,id:`lifecycle-variable-help`,children:[`Values are shell-escaped; do not wrap variable tokens in quotes. Use `,(0,Q.jsx)(`code`,{children:`\\{{`}),` for literal double braces, for example `,(0,Q.jsx)(`code`,{children:`docker inspect --format '\\{{.State.Status}}' container`}),`.`]})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[`Preview context`,(0,Q.jsxs)(`select`,{value:g,className:lE,onChange:e=>{_(e.target.value),y({})},children:[(0,Q.jsx)(`option`,{value:``,children:`Example values (illustrative)`}),i.data?.worktrees.filter(e=>e.onDisk).map(e=>(0,Q.jsx)(`option`,{value:e.worktreeId,children:e.task?.title??`Orphan ${e.runId.slice(0,8)}`},e.worktreeId))]})]}),oE.map(e=>(0,Q.jsxs)($,{title:sE[e],hint:e===`afterCreate`?`Run after a worktree is created and before its agent starts, including recreation after reclamation.`:`Run while the worktree files still exist, before removal or reclamation. Failure retains the directory for recovery.`,children:[a[e].length===0&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No commands. This phase completes without running a script.`}),a[e].map((t,n)=>(0,Q.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-2 rounded-md border border-border p-3`,disabled:k.isPending,children:[(0,Q.jsxs)(`legend`,{className:`px-1 text-xs font-medium`,children:[`Command `,n+1]}),(0,Q.jsx)(`label`,{className:`text-xs`,htmlFor:`lifecycle-name-${t.id}`,children:`Display name (optional)`}),(0,Q.jsx)(`input`,{id:`lifecycle-name-${t.id}`,className:lE,value:t.name??``,maxLength:120,onChange:n=>T(e,t.id,{name:n.target.value})}),(0,Q.jsxs)(`label`,{className:`text-xs`,htmlFor:`lifecycle-command-${t.id}`,children:[sE[e],` — command `,n+1]}),(0,Q.jsx)(`textarea`,{id:`lifecycle-command-${t.id}`,ref:e=>{e?S.current.set(t.id,e):S.current.delete(t.id)},className:`${lE} min-h-24 resize-y font-mono text-xs`,value:t.command,maxLength:32*1024,spellCheck:!1,"aria-describedby":`lifecycle-variable-help${f[t.id]?` lifecycle-error-${t.id}`:``}`,"aria-invalid":!!f[t.id],onChange:n=>T(e,t.id,{command:n.target.value})}),f[t.id]&&(0,Q.jsx)(`p`,{id:`lifecycle-error-${t.id}`,className:`text-xs text-danger`,role:`alert`,children:f[t.id]}),(0,Q.jsxs)(`details`,{className:`text-xs`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer py-1`,children:`Variables`}),(0,Q.jsx)(`ul`,{className:`mt-1 space-y-2`,children:cE.map(([r,i])=>(0,Q.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,"aria-label":`Insert ${r} into ${sE[e].toLowerCase()} command ${n+1}`,onClick:()=>E(e,t,r),children:(0,Q.jsx)(`code`,{children:`{{ ${r} }}`})}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:i})]},r))})]}),(0,Q.jsxs)(`details`,{className:`text-xs`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer py-1`,children:`Advanced timeout`}),(0,Q.jsxs)(`label`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[`Timeout in seconds (1–86,400; blank uses 1,800)`,(0,Q.jsx)(`input`,{type:`number`,min:1,max:86400,step:1,className:`${lE} max-w-32`,value:t.timeoutSeconds??``,onChange:n=>T(e,t.id,{timeoutSeconds:n.target.value===``?void 0:Number(n.target.value)})})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:n===0,"aria-label":`Move ${sE[e].toLowerCase()} command ${n+1} up`,onClick:()=>D(e,n,-1),children:`Move up`}),(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:n===a[e].length-1,"aria-label":`Move ${sE[e].toLowerCase()} command ${n+1} down`,onClick:()=>D(e,n,1),children:`Move down`}),(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":`Remove ${sE[e].toLowerCase()} command ${n+1}`,onClick:()=>{o(n=>({...n,[e]:n[e].filter(e=>e.id!==t.id)})),h(``)},children:`Remove`}),(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:!t.command.trim()||b!==null,"aria-label":`Preview ${sE[e].toLowerCase()} command ${n+1}`,onClick:()=>void O(t),children:b===t.id?`Previewing…`:`Preview`})]}),v[t.id]&&(0,Q.jsxs)(`div`,{className:`min-w-0 rounded bg-muted p-2 text-xs`,children:[(0,Q.jsx)(`p`,{className:`font-medium`,children:v[t.id].illustrative?`Example preview — illustrative values`:`Selected worktree preview`}),(0,Q.jsxs)(`p`,{className:`break-all text-muted-foreground`,children:[`Working directory: `,v[t.id].cwd]}),(0,Q.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-all`,children:v[t.id].renderedCommand}),(0,Q.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:`Preview does not execute commands or expand shell expressions.`})]})]},t.id)),(0,Q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,className:`self-start`,disabled:a[e].length>=32||k.isPending,onClick:()=>{o(t=>({...t,[e]:[...t[e],{id:crypto.randomUUID(),command:``}]})),h(``)},children:[`Add `,e===`afterCreate`?`setup`:`cleanup`,` command`]})]},e)),(f.form||k.error)&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:f.form??k.error?.message}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(J,{type:`button`,disabled:!w||k.isPending,onClick:()=>k.mutate(),children:k.isPending?`Saving…`:`Save scripts`}),k.isError&&(0,Q.jsx)(J,{type:`button`,variant:`outline`,onClick:()=>void A(),children:`Reload saved scripts`})]}),m&&(0,Q.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:m}),j.length>0&&(0,Q.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,Q.jsx)(`p`,{children:`Paused scripts wait for an explicit recovery choice.`}),j.map(e=>(0,Q.jsxs)(`a`,{className:`mt-1 block text-primary underline`,href:`#lifecycle-operation-${e.operation.id}`,children:[`Return to `,e.task?.title??`orphan worktree`,` and Retry`]},e.worktreeId))]})]})}var dE=0,fE=1e3;function pE(){let e=En();return e.isPending?(0,Q.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`p-4 text-ui text-soft-foreground md:p-6`,children:`Loading worktree settings…`}):e.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(Ol,{}),tone:`danger`,title:`Worktree settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,Q.jsx)(mE,{config:e.data})}function mE({config:e}){let t=U(),n=H({mutationFn:e=>ve(e),onSuccess:e=>t.setQueryData(V.config,e),onError:e=>Y(e.message,{tone:`danger`})}),[r,i]=(0,Z.useState)(String(e.worktreeRetention)),a=Number(r),o=r.trim()===``||!Number.isInteger(a)||a<dE||a>fE,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)($,{title:`Keep last N 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:dE,max:fE,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)(J,{type:`button`,variant:`outline`,size:`sm`,"data-action":`resources-save-retention`,disabled:s||o||n.isPending,onClick:()=>n.mutate({worktreeRetention:a},{onSuccess:()=>{t.invalidateQueries({queryKey:V.worktrees}),Y(a===0?`Keeping all worktrees (unlimited)`:`Keeping the last ${a} finished worktree${a===1?``:`s`}`)}}),children:`Save`})]}),o?(0,Q.jsxs)(`p`,{"data-slot":`resources-retention-invalid`,className:`text-meta text-danger`,children:[`Enter a whole number from `,dE,` to `,fE,` (0 = unlimited).`]}):(0,Q.jsx)(`p`,{className:`text-meta text-soft-foreground`,children:a===0?`Keeping every finished worktree.`:`Keeping the last ${a} finished worktree${a===1?``:`s`} on disk.`})]}),(0,Q.jsx)(uE,{config:e}),(0,Q.jsx)($,{title:`Worktrees`,hint:`Task worktrees currently on disk. Delete one to reclaim its space now, or reclaim everything past the keep-limit at once. Reclamation keeps branches; deleting a worktree also deletes its managed branch.`,children:(0,Q.jsx)(rE,{})})]})}function hE(){let e=xn(),t=c(),n=U(),[r,i]=(0,Z.useState)(`jira`),[a,o]=(0,Z.useState)(null),[s,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(``),m=()=>{p(``),d(``),l(``),o(null)};(0,Z.useEffect)(()=>{m(),g(!1),b(null)},[$n()]);let[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(null),x=yt(r,_,h),S=x.data?.pages??[],C=S.find(e=>e.available)?.available?S.find(e=>e.available).source:void 0,w=(0,Z.useMemo)(()=>S.flatMap(e=>e.available?e.candidates:[]),[S]);(0,Z.useEffect)(()=>{g(!1),b(null),m()},[e.data?.connection?.id]);let T=S.find(e=>!e.available),E=async e=>{await n.invalidateQueries({queryKey:V.tracker.allFor(e)}),await n.invalidateQueries({queryKey:B.projects})},D=H({mutationFn:async()=>{if(!y||!C)throw Error(`Choose a tracker project first.`);let t=$n(),n=V.tracker.associationFor(t);return{...await kn({kind:r,sourceId:C.id,externalId:y.id,...e.data?.connection?{connectionId:e.data.connection.id}:{}}),projectId:t,associationKey:n}},onSuccess:async e=>{await Promise.all([n.cancelQueries({queryKey:V.tracker.allFor(e.projectId)}),n.cancelQueries({queryKey:B.projects})]),n.setQueryData(e.associationKey,{association:e.association}),g(!1),b(null),await E(e.projectId),Y(`${e.association.externalName} connected`)},onError:e=>Y(e.message,{tone:`danger`})}),O=H({mutationFn:async()=>{let e=$n(),t=V.tracker.associationFor(e);return{...await pe(),projectId:e,associationKey:t}},onSuccess:async e=>{await Promise.all([n.cancelQueries({queryKey:V.tracker.allFor(e.projectId)}),n.cancelQueries({queryKey:B.projects})]),n.setQueryData(e.associationKey,{association:null}),await E(e.projectId),Y(`Tracker disconnected`)},onError:e=>Y(e.message,{tone:`danger`})}),k=H({onMutate:()=>$n(),mutationFn:async()=>{let e=$n();if(!a)throw Error(`Choose a provider.`);return{...await Oe(a===`jira`?{kind:`jira`,origin:s.trim(),email:u.trim(),token:f}:{kind:`linear`,key:f}),projectId:e}},onSuccess:async e=>{$n()===e.projectId&&(m(),g(!1),b(null)),await n.cancelQueries({queryKey:V.tracker.allFor(e.projectId)}),n.setQueryData([`tracker`,e.projectId,`connection`],{connection:e.connection,demo:e.demo}),await E(e.projectId),Y(`Credentials saved for this project. Browse and connect a scope.`)},onError:(e,t,n)=>{$n()===n&&p(``),Y(e.message,{tone:`danger`})}}),A=H({mutationFn:async()=>{let e=$n();return await Kt(),e},onSuccess:async e=>{$n()===e&&(m(),g(!1),b(null)),await n.cancelQueries({queryKey:V.tracker.allFor(e)}),n.setQueryData([`tracker`,e,`connection`],{connection:null,demo:!1}),await E(e),Y(`Project credentials removed`)},onError:e=>Y(e.message,{tone:`danger`})}),j=k.isPending||A.isPending,M=t.data?.association,N=e.data?.connection,P=!!M&&(e.data?.demo===!0||!!N&&N.kind===M.kind&&N.id===M.connectionId);return t.isPending?(0,Q.jsx)(`p`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading tracker settings…`}):t.isError?(0,Q.jsx)(`p`,{className:`p-6 text-sm text-danger`,children:t.error.message}):(0,Q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col gap-6 p-4 md:p-6`,"data-slot":`tracker-settings`,children:[(0,Q.jsxs)(`section`,{className:`rounded-lg border border-border bg-card p-4`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Issue tracker`}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Connect a project or team from your issue tracker. Credentials belong only to this project and are stored locally outside the repository. Server-wide environment keys are not used.`}),P&&t.data.association?(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 rounded-md border border-border p-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-medium`,children:t.data.association.externalName}),(0,Q.jsxs)(`a`,{className:`inline-flex items-center gap-1 text-xs text-violet hover:underline`,href:t.data.association.source.webUrl,target:`_blank`,rel:`noreferrer`,children:[uu[t.data.association.kind].label,` `,(0,Q.jsx)(ic,{className:`size-3`})]})]}),(0,Q.jsxs)(J,{variant:`outline`,onClick:()=>O.mutate(),disabled:O.isPending,children:[(0,Q.jsx)(cu,{className:`size-3.5`}),` Disconnect`]})]}):(0,Q.jsx)(`p`,{className:`mt-4 text-sm font-medium`,children:e.isPending?`Loading connection…`:e.isError?`Connection status unavailable.`:`No tracker connected.`})]}),M&&N&&!e.isError&&!e.data?.demo&&!P?(0,Q.jsx)(`p`,{className:`text-sm text-warning`,children:`This scope needs reconnection with this project's credentials. Configure a connection, then browse and select its scope again.`}):null,e.data?.error?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:e.data.error}):null,(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`For local credential cleanup, run `,(0,Q.jsx)(`code`,{children:`cez tracker-connections list`}),`, then `,(0,Q.jsx)(`code`,{children:`cez tracker-connections remove <id>`}),`. Local deletion does not revoke the vendor token.`]}),e.isError?(0,Q.jsxs)(`p`,{className:`text-sm text-danger`,children:[`Could not load project connection. `,(0,Q.jsx)(`button`,{onClick:()=>void e.refetch(),children:`Retry`})]}):null,(0,Q.jsxs)(`section`,{className:`rounded-lg border border-border bg-card p-4`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Connect a provider`}),(0,Q.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:du.map(t=>{let n=!e.isError&&(e.data?.demo===!0||e.data?.connection?.kind===t.kind);return(0,Q.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,Q.jsx)(`p`,{className:`font-medium`,children:t.label}),e.data?.demo?null:(0,Q.jsxs)(J,{variant:`outline`,disabled:j||e.isPending||e.isError,onClick:()=>{m(),o(t.kind),g(!1),b(null)},children:[e.data?.connection?.kind===t.kind?`Replace`:`Configure`,` `,t.label,` credentials`]}),(0,Q.jsxs)(J,{className:`mt-3`,variant:`outline`,disabled:!n||j,onClick:()=>{i(t.kind),g(!0),v(``),b(null)},children:[(0,Q.jsx)(Ta,{className:`size-3.5`}),` Browse `,t.label]}),n?null:(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`Configure credentials for this project to browse.`})]},t.kind)})})]}),e.data?.connection?(0,Q.jsx)(J,{variant:`outline`,disabled:j,onClick:()=>A.mutate(),children:`Remove project credentials`}):null,a?(0,Q.jsxs)(`form`,{className:`rounded-lg border border-border bg-card p-4`,onSubmit:e=>{e.preventDefault(),k.mutate()},autoComplete:`off`,children:[(0,Q.jsxs)(`h2`,{className:`font-medium`,children:[uu[a].label,` credentials for this project`]}),(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`Saved in a private .env file for this project, without encryption. Use read-only access limited to this project's data. Saving replaces this project's connection and requires selecting its scope again.`}),a===`jira`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`label`,{className:`mt-3 block text-sm`,children:[`Jira site URL`,(0,Q.jsx)(`input`,{"aria-label":`Jira site URL`,type:`url`,required:!0,value:s,onChange:e=>l(e.target.value),placeholder:`https://your-site.atlassian.net`,className:`mt-1 block w-full rounded border bg-background p-2`})]}),(0,Q.jsxs)(`label`,{className:`mt-3 block text-sm`,children:[`Account email`,(0,Q.jsx)(`input`,{"aria-label":`Account email`,type:`email`,required:!0,value:u,onChange:e=>d(e.target.value),className:`mt-1 block w-full rounded border bg-background p-2`})]})]}):null,(0,Q.jsxs)(`label`,{className:`mt-3 block text-sm`,children:[`API token`,(0,Q.jsx)(`input`,{"aria-label":`API token`,type:`password`,autoComplete:`new-password`,required:!0,maxLength:8192,value:f,onChange:e=>p(e.target.value),className:`mt-1 block w-full rounded border bg-background p-2`})]}),(0,Q.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Q.jsx)(J,{type:`submit`,disabled:j,children:`Save project credentials`}),(0,Q.jsx)(J,{type:`button`,variant:`outline`,disabled:j,onClick:m,children:`Cancel`})]})]}):null,h?(0,Q.jsxs)(`section`,{className:`rounded-lg border border-violet/40 bg-card p-4`,"aria-label":`${uu[r].label} picker`,children:[(0,Q.jsxs)(`label`,{className:`text-xs font-medium`,htmlFor:`tracker-candidate-search`,children:[`Search `,uu[r].scopeLabel]}),(0,Q.jsx)(`input`,{id:`tracker-candidate-search`,className:`mt-2 h-9 w-full rounded-md border border-border bg-background px-3 text-sm`,value:_,onChange:e=>{v(e.target.value),b(null)},placeholder:`Search by name…`}),(0,Q.jsxs)(`div`,{className:`mt-3 max-h-64 space-y-1 overflow-auto`,children:[x.isPending?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading…`}):null,x.isError?(0,Q.jsx)(gE,{reason:x.error.message,generation:x.errorUpdatedAt,retry:()=>void x.refetch()}):null,T&&!T.available?(0,Q.jsx)(gE,{reason:T.reason,generation:x.dataUpdatedAt,retryAfterSeconds:T.code===`rate_limited`?T.retryAfterSeconds:void 0,retry:()=>void x.refetch()}):null,w.map(e=>(0,Q.jsx)(`button`,{type:`button`,className:`block w-full rounded-md border px-3 py-2 text-left text-sm ${y?.id===e.id?`border-violet bg-violet/10`:`border-border`}`,onClick:()=>b(e),children:e.name},e.id)),!x.isPending&&!x.isError&&!T&&w.length===0?(0,Q.jsx)(`p`,{className:`py-3 text-sm text-muted-foreground`,children:`No projects or teams match.`}):null,x.hasNextPage?(0,Q.jsx)(J,{variant:`ghost`,onClick:()=>void x.fetchNextPage(),disabled:x.isFetchingNextPage,children:`Load more`}):null]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex gap-2`,children:[(0,Q.jsx)(J,{variant:`contrast`,disabled:!y||D.isPending||j,onClick:()=>D.mutate(),children:`Connect`}),(0,Q.jsx)(J,{variant:`ghost`,onClick:()=>g(!1),children:`Cancel`})]})]}):null]})}function gE({reason:e,retry:t,retryAfterSeconds:n=0,generation:r}){let[i,a]=(0,Z.useState)(n);return(0,Z.useEffect)(()=>a(n),[e,n,r]),(0,Z.useEffect)(()=>{if(i<=0)return;let e=window.setInterval(()=>a(e=>Math.max(0,e-1)),1e3);return()=>window.clearInterval(e)},[i>0]),(0,Q.jsxs)(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 p-3 text-sm`,children:[(0,Q.jsx)(`p`,{className:`text-danger`,children:e}),(0,Q.jsx)(J,{className:`mt-2`,variant:`outline`,disabled:i>0,onClick:t,children:i>0?`Retry in ${i}s`:`Retry`})]})}var _E={checks:`Check steps (workflow commands)`,cezar:`cezar itself (its own features — not the agents)`};function vE(e){return e===`keychain`?`Encrypted with a data key kept in your OS keychain.`:`Encrypted with a data key in ~/.cezar/secrets/.key (0600) — no OS keychain is available on this machine, so this is a private file, not a vault.`}function yE({scope:e,list:t,save:n,remove:r,invalidate:i}){let a=U(),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)([`checks`]),[f,p]=(0,Z.useState)(null),m=o===``?null:lr(o),h=H({mutationFn:async()=>{let e=$n();return await n(o,{value:c,audiences:u}),{projectId:e,saved:o}},onSuccess:async({projectId:e,saved:t})=>{$n()===e&&(s(``),l(``),p(null)),await i(a,e),Y(`${t} saved`)},onError:e=>p(e.message)}),g=H({mutationFn:async e=>{let t=$n();return await r(e),{projectId:t,removed:e}},onSuccess:async({projectId:e,removed:t})=>{await i(a,e),Y(`${t} removed`)},onError:e=>Y(e.message,{tone:`danger`})}),_=()=>{let e=lr(o);if(e){p(e);return}if(u.length===0){p(`pick at least one audience`);return}p(null),h.mutate()},v=e=>d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),y=e===`project`?`Project secrets`:`Workspace secrets`,b=e===`project`?`Values for this project only — an e2e runner’s model key, a staging login. They reach the audiences you pick and never an agent session.`:`Values shared by every project on this machine — a key cezar’s own features use, a token every project’s checks need. A project secret of the same name wins. They never reach an agent session.`,x=t.data?.secrets??[];return(0,Q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col gap-6 p-4 md:p-6`,"data-slot":`secrets-settings`,"data-scope":e,children:[(0,Q.jsxs)(`section`,{className:`rounded-lg border border-border bg-card p-4`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:y}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:b}),t.isPending?(0,Q.jsx)(`p`,{className:`mt-4 text-sm text-muted-foreground`,children:`Loading…`}):null,t.isError?(0,Q.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:t.error?.message}):null,t.data&&x.length===0?(0,Q.jsx)(`p`,{className:`mt-4 text-sm text-muted-foreground`,children:`No secrets stored.`}):null,t.data&&x.length>0?(0,Q.jsx)(`ul`,{className:`mt-4 divide-y divide-border rounded-md border border-border`,"aria-label":`Stored ${e} secrets`,children:x.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center justify-between gap-3 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`code`,{className:`text-sm`,children:e.name}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.audiences.map(e=>_E[e].split(` (`)[0]).join(` · `)})]}),(0,Q.jsxs)(J,{variant:`outline`,"aria-label":`Delete ${e.name}`,disabled:g.isPending,onClick:()=>g.mutate(e.name),children:[(0,Q.jsx)(hc,{className:`size-3.5`}),` Delete`]})]},e.name))}):null,t.data?.skipped?(0,Q.jsxs)(`p`,{role:`alert`,className:`mt-3 text-xs text-destructive`,"data-slot":`secrets-skipped`,children:[`Stored values cannot be read: `,t.data.skipped,`.`]}):null,t.data?(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,"data-slot":`key-backend`,children:vE(t.data.keyBackend)}):null]}),(0,Q.jsxs)(`form`,{className:`rounded-lg border border-border bg-card p-4`,autoComplete:`off`,onSubmit:e=>{e.preventDefault(),_()},children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Add or replace a secret`}),(0,Q.jsxs)(`label`,{className:`mt-3 block text-sm`,children:[`Name`,(0,Q.jsx)(`input`,{"aria-label":`Name`,value:o,onChange:e=>{s(e.target.value.toUpperCase()),p(null)},autoComplete:`off`,spellCheck:!1,placeholder:`AI_GATEWAY_API_KEY`,"aria-invalid":m?!0:void 0,className:`mt-1 block w-full rounded border border-border bg-background p-2 font-mono`})]}),m?(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-danger`,children:m}):null,(0,Q.jsxs)(`label`,{className:`mt-3 block text-sm`,children:[`Value`,(0,Q.jsx)(`input`,{"aria-label":`Value`,type:`password`,autoComplete:`off`,required:!0,value:c,onChange:e=>l(e.target.value),className:`mt-1 block w-full rounded border border-border bg-background p-2`})]}),(0,Q.jsxs)(`fieldset`,{className:`mt-3`,children:[(0,Q.jsx)(`legend`,{className:`text-sm`,children:`Who may read it`}),tr.map(e=>(0,Q.jsxs)(`label`,{className:`mt-1 flex items-center gap-2 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"aria-label":_E[e],checked:u.includes(e),onChange:()=>v(e)}),_E[e]]},e)),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Agents are never an audience: a secret cannot be handed to a Claude Code, Codex or OpenCode session.`})]}),f&&f!==m?(0,Q.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:f}):null,(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(J,{type:`submit`,disabled:h.isPending||o===``||c===``||u.length===0||!!m,children:`Save secret`})})]})]})}function bE(){return(0,Q.jsx)(yE,{scope:`project`,list:_e(),save:g,remove:mt,invalidate:(e,t)=>e.invalidateQueries({queryKey:V.secrets.allFor(t??``)})})}function xE(){return(0,Q.jsx)(yE,{scope:`workspace`,list:wn(),save:y,remove:jt,invalidate:e=>e.invalidateQueries({queryKey:B.secrets})})}var SE={"task.attention_required":`Needs your input`,"task.review_ready":`Ready for review`,"task.finished":`Task finished`,"task.failed":`Task failed`,"task.cancelled":`Task cancelled`,"webhook.test":`Test message`},CE=`h-9 w-full rounded-md border border-input bg-card px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,wE=`text-ui text-muted-foreground`;function TE(e){return{format:e?.format??`cezar.json.v1`,name:e?.name??``,url:``,profile:e?.profile??`minimal`,preset:e?.preset??`attention`,events:e?.events??[],scope:e?.scope??`main_and_questions`,graceSeconds:e?.graceSeconds??180,local:e?.allowLocalNetwork??!1,scheduled:e?.includeScheduledFailures??!1}}function EE({id:e,label:t,children:n}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e?(0,Q.jsx)(`label`,{htmlFor:e,className:`text-sm font-medium`,children:t}):(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:t}),n]})}function DE({receiver:e,draft:t,setDraft:n,pending:r,blocked:i=!1,guideHref:a,save:o}){let s=(0,Z.useId)(),{format:c,name:l,url:u,profile:d,preset:f,events:p,scope:m,graceSeconds:h,local:g,scheduled:_}=t,v=(e,r)=>n({...t,[e]:r}),[y,b]=(0,Z.useState)(``),x=c!==`cezar.json.v1`,S=c===`slack.v1`?`Slack`:`Discord`,C;try{let e=new URL(u).hostname;e===`hooks.slack.com`&&(C=`slack.v1`),[`discord.com`,`discordapp.com`,`ptb.discord.com`,`canary.discord.com`].includes(e)&&(C=`discord.v1`)}catch{}let w=e=>n({...t,format:e,local:e===`cezar.json.v1`&&g});return(0,Q.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{if(t.preventDefault(),r||i)return;let n={format:c,name:l,...u||!e?{url:u}:{},profile:d,preset:f,events:p,scope:m,graceSeconds:h,allowLocalNetwork:!x&&g,includeScheduledFailures:_},a=e?Qn.safeParse({...n,expectedRevision:e.revision}):pr.safeParse(n);if(!a.success){b([...new Set(a.error.issues.map(e=>e.message.replace(/\.?$/,`.`)))].join(` `));return}b(``),o(a.data)},children:[(0,Q.jsx)(EE,{id:`${s}-destination`,label:`Destination`,children:(0,Q.jsxs)(`select`,{id:`${s}-destination`,className:CE,value:c,onChange:e=>w(e.target.value),children:[(0,Q.jsx)(`option`,{value:`cezar.json.v1`,children:`Custom receiver (signed cezar JSON)`}),(0,Q.jsx)(`option`,{value:`slack.v1`,children:`Slack channel (Incoming Webhook)`}),(0,Q.jsx)(`option`,{value:`discord.v1`,children:`Discord channel (Webhook URL)`})]})}),(0,Q.jsx)(EE,{id:`${s}-name`,label:`Name`,children:(0,Q.jsx)(Kc,{id:`${s}-name`,value:l,onChange:e=>v(`name`,e.target.value),maxLength:100,required:!0,autoComplete:`off`})}),(0,Q.jsxs)(EE,{id:`${s}-url`,label:x?`Webhook URL`:`Receiver URL`,children:[(0,Q.jsx)(Kc,{id:`${s}-url`,type:`url`,value:u,onChange:e=>v(`url`,e.target.value),required:!e,autoComplete:`off`,placeholder:e?`Leave blank to keep the current URL`:c===`slack.v1`?`https://hooks.slack.com/services/…`:c===`discord.v1`?`https://discord.com/api/webhooks/…`:`https://your-receiver.example/webhook`}),e&&(0,Q.jsxs)(`p`,{className:wE,children:[`Current: `,e.destination,` (path hidden)`]}),u.startsWith(`http:`)&&(0,Q.jsx)(`p`,{className:`text-ui text-warning`,children:`Plain HTTP is not encrypted. Use HTTPS outside a trusted local network.`}),!x&&C&&(0,Q.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-2 text-ui text-warning`,children:[(0,Q.jsxs)(`span`,{children:[`This is a `,C===`slack.v1`?`Slack`:`Discord`,` webhook. Switch the destination to post channel messages.`]}),(0,Q.jsxs)(J,{type:`button`,size:`sm`,variant:`outline`,className:`text-foreground`,onClick:()=>w(C),children:[`Use `,C===`slack.v1`?`Slack`:`Discord`]})]}),c===`slack.v1`&&(0,Q.jsxs)(`p`,{className:wE,children:[`In Slack, create an app with an Incoming Webhook, install it in your channel and paste its URL. `,(0,Q.jsx)(`a`,{className:`underline underline-offset-2 hover:text-foreground`,href:`https://docs.slack.dev/messaging/sending-messages-using-incoming-webhooks/`,target:`_blank`,rel:`noreferrer`,children:`Slack setup guide`})]}),c===`discord.v1`&&(0,Q.jsxs)(`p`,{className:wE,children:[`In Discord, open Server Settings → Integrations → Webhooks, create one and paste its URL. `,(0,Q.jsx)(`a`,{className:`underline underline-offset-2 hover:text-foreground`,href:`https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks`,target:`_blank`,rel:`noreferrer`,children:`Discord setup guide`})]}),x?(0,Q.jsxs)(`p`,{className:wE,children:[`Keep this URL secret — anyone who has it can post to the channel. `,S,` receivers need no signing key.`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:g,onChange:e=>v(`local`,e.target.checked)}),`Allow a receiver on this computer or private network`]}),g&&(0,Q.jsx)(`p`,{className:wE,children:`Tests will contact this private address. Hosted cezar sends to public HTTPS receivers only.`}),(0,Q.jsx)(`a`,{className:`text-ui text-muted-foreground underline underline-offset-2 hover:text-foreground`,href:`${a}#external-automation-receivers`,target:`_blank`,rel:`noreferrer`,children:`How to build a receiver`})]})]}),(0,Q.jsx)(EE,{id:`${s}-events`,label:`Events`,children:(0,Q.jsx)(`select`,{id:`${s}-events`,className:CE,value:f,onChange:e=>v(`preset`,e.target.value),children:[`attention`,`all`,`custom`].map(e=>(0,Q.jsx)(`option`,{value:e,children:kw[e]},e))})}),f===`custom`&&(0,Q.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`legend`,{className:`mb-1 text-sm font-medium`,children:`Choose events`}),Object.entries(SE).filter(([e])=>e!==`webhook.test`).map(([e,t])=>(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:p.includes(e),onChange:t=>v(`events`,t.target.checked?[...p,e]:p.filter(t=>t!==e))}),t]},e))]}),(0,Q.jsxs)(EE,{id:`${s}-profile`,label:`Message content`,children:[(0,Q.jsxs)(`select`,{id:`${s}-profile`,className:CE,value:d,onChange:e=>v(`profile`,e.target.value),children:[(0,Q.jsx)(`option`,{value:`minimal`,children:`Minimal — IDs, status and your own title`}),(0,Q.jsx)(`option`,{value:`standard`,children:`Standard — task titles, questions and errors`})]}),(0,Q.jsx)(`p`,{className:wE,children:`Prompts and transcripts are never sent. Redaction of other text is best effort.`}),x&&d===`standard`&&(0,Q.jsxs)(`p`,{className:`text-ui text-warning`,children:[`Standard posts task titles, questions and error text to your `,S,` channel.`]})]}),x?(0,Q.jsx)(OE,{format:c,profile:d}):(0,Q.jsxs)(`details`,{children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:[`Preview JSON · `,d===`minimal`?`Minimal`:`Standard`]}),(0,Q.jsx)(`p`,{className:`mt-2 ${wE}`,children:`Example data only — nothing is sent.`}),(0,Q.jsx)(`pre`,{"aria-label":`Synthetic JSON sample`,className:`mt-2 max-h-64 overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted p-3 text-xs`,children:JSON.stringify({id:`evt_00000000-0000-4000-8000-000000000001`,schemaVersion:1,sequence:1,occurredAt:`2026-01-01T12:00:00Z`,type:`task.attention_required`,source:{instanceId:`example-instance`,projectId:`example-project`,mode:`local`},task:{id:`example-task`,previousStatus:`running`,status:`waiting`,...d===`standard`?{title:`Example generated task title`}:{}},data:{episodeId:`example-episode`,since:`2026-01-01T12:00:00Z`,reason:`question`,requestId:`example-request`,...d===`standard`?{questions:[{question:`Which example option should be used?`,options:[{label:`Example A`},{label:`Example B`}]}]}:{}}},null,2)})]}),(0,Q.jsxs)(`details`,{children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:`Advanced`}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-4`,children:[(0,Q.jsx)(EE,{id:`${s}-scope`,label:`Tasks`,children:(0,Q.jsx)(`select`,{id:`${s}-scope`,className:CE,value:m,onChange:e=>v(`scope`,e.target.value),children:[`main_and_questions`,`every_task`].map(e=>(0,Q.jsx)(`option`,{value:e,children:Ow[e]},e))})}),(0,Q.jsxs)(EE,{id:`${s}-grace`,label:`Waiting and review delay`,children:[(0,Q.jsx)(`select`,{id:`${s}-grace`,className:CE,value:h,onChange:e=>v(`graceSeconds`,Number(e.target.value)),children:[0,60,180,600].map(e=>(0,Q.jsx)(`option`,{value:e,children:Aw[e]},e))}),(0,Q.jsx)(`p`,{className:wE,children:`Skipped if you reply, or the task stops waiting or leaves review, before the delay ends.`})]}),(0,Q.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:_,onChange:e=>v(`scheduled`,e.target.checked)}),`Include failures that will resume automatically (always included in All results)`]})]})]}),y&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:y}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(J,{type:`submit`,disabled:r||i,children:r?`Saving…`:e?`Review changes`:`Save receiver`})})]})}function OE({format:e,profile:t}){let n=e===`slack.v1`?`Slack`:`Discord`;return(0,Q.jsxs)(`details`,{children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:[`Preview `,n,` message · `,t===`minimal`?`Minimal`:`Standard`]}),(0,Q.jsx)(`p`,{className:`mt-2 ${wE}`,children:`Example data only — nothing is sent.`}),(0,Q.jsxs)(`div`,{"aria-label":`${n} message sample`,className:`mt-2 space-y-2 rounded-md border border-border bg-muted p-3 text-sm ${e===`discord.v1`?`border-l-4 border-l-pending`:``}`,children:[(0,Q.jsxs)(`p`,{className:`font-medium`,children:[`Needs your input · `,t===`standard`?`Example generated task title`:`a1b2c3d4`]}),(0,Q.jsx)(`p`,{children:`running → waiting`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`example-project · a1b2c3d4 · Jan 1, 2026, 12:00 UTC`}),t===`standard`&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{children:`Which example option should be used?`}),(0,Q.jsx)(`p`,{children:`Example A · Example B`})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`cezar`})]})]})}var kE={local_consent_required:`This address is on this computer or a private network. Edit the receiver and turn on “Allow a receiver on this computer or private network”.`,server_port:`This address points at the cezar server itself. Use your receiver's own port.`,https_required:`This server only sends to HTTPS receivers. Use an https:// URL.`,public_destination_required:`This server only sends to public receivers. Use a publicly reachable HTTPS URL.`,metadata_hostname:`Cloud metadata hostnames are never allowed as receivers.`,denied_address:`The receiver resolves to an address that is never allowed.`,mixed_dns:`The receiver hostname resolves to both public and private addresses. Use a hostname with one kind of address.`,invalid_dns:`The receiver hostname did not resolve to a usable address.`,dns_not_found:`The receiver hostname does not resolve. Check the URL.`,invalid_url:`The receiver URL is not allowed. Use a plain http(s) URL without credentials or a fragment.`};function AE({projectId:e,test:t,openHistory:n}){let r=dt({queryKey:[...pb(e),`test-result`,t.receiverId,t.deliveryId],queryFn:()=>je.deliveries(e,t.receiverId),retry:!1}),i=r.data?.items.find(e=>e.deliveryId===t.deliveryId),a=r.data?.receiver,o=t.format??(a?.kind===`live`?a.format:void 0),s=i&&[`delivered`,`failed`,`cancelled`,`superseded`,`dropped`].includes(i.status),c=(0,Z.useRef)(void 0),l=s?i.status:void 0,u=i?.reason===`outcome_unknown`;(0,Z.useEffect)(()=>{let n=`${e}:${t.deliveryId}`;!l||c.current===n||(c.current=n,l===`delivered`&&!u?Y(`Test delivered to ${t.receiverName}`):Y(u?`Test result for ${t.receiverName} is unknown`:`Test to ${t.receiverName} failed`,{tone:`danger`}))},[e,t.deliveryId,t.receiverName,l,u]);let d=s&&i.status===`delivered`&&!u,f=r.error?`Test result is unavailable. Check the history.`:r.data&&!i?`Test sent. Its result is in the history.`:s?u?`Test result unknown — it may have arrived. Check your receiver before testing again.`:d?`Test delivered.${a?.kind===`live`&&[`inactive`,`paused`].includes(a.state)?` ${a.state===`paused`?`Resume`:`Activate`} the receiver to start sending task updates.`:``}`:`Test ${i.status===`failed`?`failed`:i.status}${i.reason?`: ${Lw(i.reason)}`:``}.`:`Test sent — waiting for the result…`,p=!s||d||u?void 0:i.reason===`timeout`||i.reason===`connection_failed`?`Check that your receiver is reachable and responds within 10 seconds.`:/^http_(401|403)$/.test(i.reason??``)?o===`slack.v1`||o===`discord.v1`?`Check the webhook URL in Slack or Discord. If it was revoked or replaced, edit this receiver with the current URL and send a new test.`:`Check the receiver’s authentication and the signing key in its verifier.`:i.reason===`http_404`||i.reason===`http_410`?`Check the URL and that the endpoint still exists.`:kE[i.reason??``]?`${kE[i.reason]} Activation stays blocked until a test passes.`:`Fix the receiver, then send a new test. Tests are not retried automatically.`,m=d?`border-success/40`:s?`border-danger/30 bg-danger/5`:`border-border`;return(0,Q.jsxs)(`div`,{role:`status`,"data-test-delivery":t.deliveryId,className:`flex flex-wrap items-center justify-between gap-2 rounded-md border p-3 text-ui ${m}`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{children:f}),p&&(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:p})]}),(0,Q.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>n(t.receiverId),children:`View in history`})]})}var jE=Object.keys(Mw),ME={delivered:`text-success`,failed:`text-danger`,dropped:`text-danger`,blocked_policy:`text-warning`,retrying:`text-warning`};function NE({projectId:e,receiver:t,operation:n,tab:r,onTabChange:i}){let[a,o]=(0,Z.useState)(`deliveries`),s=r??a,c=e=>{o(e),i?.(e)},[l,u]=(0,Z.useState)(`all`),d=(0,Z.useId)(),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(),v=nn({queryKey:[...pb(e),t.id,`deliveries`,f],initialPageParam:void 0,queryFn:({pageParam:n})=>je.deliveries(e,t.id,n,f||void 0),getNextPageParam:e=>e.nextCursor,enabled:s===`deliveries`,retry:!1}),y=dt({queryKey:[...pb(e),t.id,`activity`],queryFn:()=>je.activity(e,t.id),enabled:s===`activity`,retry:!1}),b=[...new Map((v.data?.pages.flatMap(e=>e.items)??[]).map(e=>[e.deliveryId,e])).values()],x=b.filter(e=>l===`all`||e.status===l),S=v.data?.pages[0]?.timezone,C=e=>Vw(e,S);return(0,Q.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-3`,children:[t.kind===`history`&&(0,Q.jsxs)(`p`,{className:`rounded-md border border-border bg-muted p-3 text-ui text-muted-foreground`,children:[`Deleted `,Vw(t.deletedAt),` — read-only. Its settings and signing keys are gone; history is kept for up to 30 days.`]}),(0,Q.jsxs)(Gc,{value:s,onValueChange:e=>c(e),children:[(0,Q.jsxs)(Wc,{"aria-label":`Receiver history`,children:[(0,Q.jsx)(Hc,{value:`deliveries`,children:`Deliveries`}),(0,Q.jsx)(Hc,{value:`activity`,children:`Activity`})]}),(0,Q.jsxs)(Uc,{value:`activity`,className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`p`,{className:`text-ui text-muted-foreground`,children:[`Times in `,Bw(y.data?.timezone).label,`.`]}),y.isPending&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading activity…`}),y.error&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:y.error.message}),y.data?.items.map(e=>(0,Q.jsxs)(`div`,{className:`rounded-md border border-border p-3 text-sm`,children:[(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:Rw(e.action)}),` `,(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,Vw(e.at,y.data?.timezone),` · via `,Fw[e.source],e.revision!==void 0&&` · revision ${e.revision}`]})]}),e.fields.length>0&&(0,Q.jsxs)(`p`,{className:`text-ui text-muted-foreground`,children:[`Changed: `,e.fields.join(`, `)]}),e.detail&&(0,Q.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:e.detail})]},e.id)),y.data?.items.length===0&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No activity in the retained history.`}),y.data?.hasMore&&(0,Q.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:`Showing the latest 100 actions.`})]}),(0,Q.jsxs)(Uc,{value:`deliveries`,className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,Q.jsxs)(`form`,{className:`flex min-w-0 flex-1 items-end gap-2`,onSubmit:e=>{e.preventDefault(),p(m.trim())},children:[(0,Q.jsxs)(`label`,{className:`flex min-w-0 flex-1 flex-col gap-1.5 text-sm font-medium`,children:[`Task ID`,(0,Q.jsx)(Kc,{value:m,onChange:e=>h(e.target.value),placeholder:`Optional — show one task’s deliveries`})]}),(0,Q.jsx)(J,{type:`submit`,variant:`outline`,children:`Find`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{id:d,className:`text-sm font-medium`,children:`Result`}),(0,Q.jsxs)(lm,{value:l,onValueChange:u,children:[(0,Q.jsx)(dm,{"aria-labelledby":d,children:(0,Q.jsx)(um,{})}),(0,Q.jsxs)(fm,{children:[(0,Q.jsx)(pm,{value:`all`,children:`All results`}),jE.map(e=>(0,Q.jsx)(pm,{value:e,children:Mw[e]},e))]})]})]})]}),(0,Q.jsxs)(`p`,{className:`text-ui text-muted-foreground`,children:[`Showing `,b.length?`1–${b.length}`:`0`,` of `,v.data?.pages[0]?.total??0,f?` for task ${f}`:``,`. The result filter applies to loaded entries. Times in `,Bw(S).label,`.`]}),v.isPending&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading deliveries…`}),v.error&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:v.error.message}),!v.isPending&&x.length===0&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No deliveries match.`}),x.map(e=>(0,Q.jsxs)(`article`,{className:`min-w-0 rounded-md border border-border p-3 text-sm`,children:[(0,Q.jsxs)(`button`,{className:`w-full min-w-0 text-left`,type:`button`,"aria-expanded":g===e.deliveryId,onClick:()=>_(t=>t===e.deliveryId?void 0:e.deliveryId),children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:SE[e.eventType]}),` · `,(0,Q.jsx)(`span`,{className:ME[e.status],children:Mw[e.status]}),(0,Q.jsxs)(`span`,{className:`block text-ui text-muted-foreground`,children:[C(e.createdAt),` · `,zw(e.attempts,`attempt`,`attempts`),e.taskId?` · task ${e.taskId.slice(0,8)}`:``]})]}),g===e.deliveryId&&(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2 break-words border-t border-border pt-3 text-ui`,children:[(0,Q.jsxs)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 [overflow-wrap:anywhere]`,children:[e.reason&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Reason`}),(0,Q.jsx)(`dd`,{children:Lw(e.reason)})]}),e.httpStatus&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`HTTP status`}),(0,Q.jsx)(`dd`,{children:e.httpStatus})]}),e.nextAttemptAt&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Next attempt`}),(0,Q.jsx)(`dd`,{children:C(e.nextAttemptAt)})]}),(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Retries until`}),(0,Q.jsx)(`dd`,{children:C(e.expiresAt)}),e.taskId&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Task`}),(0,Q.jsxs)(`dd`,{children:[e.taskAvailability===`available`?(0,Q.jsx)(K,{className:`underline underline-offset-2`,to:`/tasks/${encodeURIComponent(e.taskId)}`,children:e.taskId}):e.taskId,e.taskAvailability===`deleted`&&` (deleted)`,e.taskAvailability===`unknown`&&` (availability unknown)`]})]}),(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Destination`}),(0,Q.jsx)(`dd`,{children:e.destination}),(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Event ID`}),(0,Q.jsx)(`dd`,{className:`font-mono text-xs`,children:e.eventId}),(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Delivery ID`}),(0,Q.jsx)(`dd`,{className:`font-mono text-xs`,children:e.deliveryId}),e.payloadRetainedUntil&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Payload kept until`}),(0,Q.jsx)(`dd`,{children:C(e.payloadRetainedUntil)})]}),e.historyRetainedUntil&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`History kept until`}),(0,Q.jsxs)(`dd`,{children:[C(e.historyRetainedUntil),` at most`]})]})]}),e.payloadAvailability===`not_created`&&(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:`No payload was created for this delivery.`}),e.payloadAvailability===`unknown`&&(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:`Payload availability is unknown.`}),e.response&&(0,Q.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-2 text-xs`,children:e.response}),t.kind===`live`&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(J,{size:`sm`,variant:`outline`,disabled:!e.retryAllowed,onClick:()=>n(`retry`,e,t),children:`Retry now`}),(0,Q.jsx)(J,{size:`sm`,variant:`outline`,disabled:!e.replayAllowed,onClick:()=>n(`replay`,e,t),children:`Replay`}),!e.replayAllowed&&(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Replay unavailable: `,e.replayUnavailableReason?PE[e.replayUnavailableReason]:`the payload or receiver is no longer eligible.`]})]})]})]},e.deliveryId)),v.hasNextPage&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(J,{variant:`outline`,disabled:v.isFetchingNextPage,onClick:()=>void v.fetchNextPage(),children:`Load older`})})]})]})]})}var PE={receiver_deleted:`the receiver was deleted.`,receiver_inactive:`activate the receiver first.`,configuration_changed:`the receiver settings changed since.`,task_unavailable:`the task is deleted or its state cannot be checked.`,not_fresh:`the event is out of date.`,not_terminal:`the delivery has not finished yet.`,synthetic_test:`send a new test instead.`,payload_expired:`the payload is no longer kept.`,payload_unavailable:`the original payload is unavailable.`};function FE(){let e=kr()??`default`,t=C();return t.isError?(0,Q.jsx)(`p`,{role:`status`,className:LE,children:`Webhook status unavailable — could not load server health.`}):t.data?(0,Q.jsx)(IE,{projectId:e,enabled:t.data?.capabilities.webhooks===!0,unsupportedPlatform:t.data?.capabilities.webhooksUnavailableReason===`unsupported_platform`},e):(0,Q.jsx)(`p`,{role:`status`,className:LE,children:`Loading webhook status…`})}function IE({projectId:e,enabled:t,unsupportedPlatform:n}){let r=U(),[i,a]=hr(),o=jr(),s=(0,Z.useRef)({mounted:!1,token:Symbol()});(0,Z.useLayoutEffect)(()=>(s.current={mounted:!0,token:Symbol()},()=>{s.current.mounted=!1}),[o]);let c=e=>s.current.mounted&&s.current.token===e,l=i.get(`endpoint`)??``,u=i.get(`tab`)??`settings`,d=/^[A-Za-z0-9_-]{1,128}$/.test(l),f=[`settings`,`deliveries`,`activity`].includes(u),p=u===`activity`?`activity`:`deliveries`,m=(0,Z.useRef)(i.toString());(0,Z.useLayoutEffect)(()=>{m.current=i.toString()},[i]);let h=(e,t=`deliveries`)=>{let n=new URLSearchParams(m.current);e?(n.set(`endpoint`,e),n.set(`tab`,t)):(n.delete(`endpoint`),n.delete(`tab`)),n.toString()!==m.current&&(m.current=n.toString(),a(n))},g=Hw(dt({queryKey:[`workspace`,`self-update`],queryFn:({signal:e})=>Pn({signal:e}),retry:!1}).data),_=mb(e,t),[v,y]=(0,Z.useState)(),[b,x]=(0,Z.useState)(()=>TE()),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(``),[E,D]=(0,Z.useState)(),[O,k]=(0,Z.useState)(),A=(0,Z.useRef)(null),j=(0,Z.useRef)(null),M=(0,Z.useRef)(null),N=(0,Z.useRef)(null),P=(e,t)=>{e.preventDefault();let n=[...document.querySelectorAll(`[role="dialog"][data-state="open"]`)];n.length&&!n.some(e=>t&&e.contains(t))||(t?.isConnected&&!t.matches(`:disabled`)?t.focus():A.current?.focus())},[F,ee]=(0,Z.useState)(!1),[te,I]=(0,Z.useState)(!1);(0,Z.useLayoutEffect)(()=>{v===`new`&&(y(void 0),x(TE()),C(!1),R(``))},[o]),(0,Z.useLayoutEffect)(()=>{k(void 0),ee(!1),I(!1)},[o]);let ne=(0,Z.useRef)(new Map),L=(0,Z.useRef)(new Map),re=(0,Z.useRef)(void 0);(0,Z.useLayoutEffect)(()=>{d&&f&&u!==`settings`&&(re.current=ne.current.get(l))},[l,d,f,u,_.data]);let ie=(0,Z.useRef)(void 0),ae=_.data?.receivers.find(e=>e.id===l)??_.data?.history.find(e=>e.id===l),oe=dt({queryKey:[...pb(e),`resolve`,l,p],queryFn:async()=>(await(p===`activity`?je.activity(e,l):je.deliveries(e,l))).receiver,enabled:t&&d&&f&&u!==`settings`&&!ae,retry:!1});(0,Z.useEffect)(()=>{if(t&&d&&u===`settings`){let e=_.data?.receivers.find(e=>e.id===l);e&&ie.current!==l&&(ie.current=l,y(e),x(TE(e)),C(!1),R(``))}else ie.current&&(ie.current=void 0,y(void 0),x(TE()),C(!1))},[t,l,d,u,_.data]);let[se,ce]=(0,Z.useState)(!1),[le,R]=(0,Z.useState)(``),[ue,de]=(0,Z.useState)();(0,Z.useLayoutEffect)(()=>{de(void 0)},[o.key]);let fe=async(t,n)=>{let r=s.current.token,i=await je.test(e,t.id,n);c(r)&&de({viewKey:o.key,deliveryId:i.deliveryId,receiverId:t.id,receiverName:t.name,initialState:t.state,deliveryRevision:t.deliveryRevision,format:t.format})},pe=nn({queryKey:[...pb(e),`history`],initialPageParam:void 0,queryFn:({pageParam:t})=>je.history(e,t),getNextPageParam:e=>e.nextCursor,enabled:t&&se,retry:!1}),z=H({onMutate:()=>({viewKey:s.current.token,form:v,confirmation:O}),mutationFn:async e=>{let t=s.current.token,n=await e();!(n&&typeof n==`object`&&`receiver`in n&&n.receiver&&typeof n.receiver==`object`&&`format`in n.receiver&&(n.receiver.format===`slack.v1`||n.receiver.format===`discord.v1`))&&c(t)&&n&&typeof n==`object`&&`secret`in n&&typeof n.secret==`string`&&n.secret.length>0&&(M.current=v?j.current:N.current,T(``),D(n.secret))},onSuccess:async(t,n,i)=>{if(!i||!c(i.viewKey)){await r.invalidateQueries({queryKey:pb(e)});return}v===i.form&&O===i.confirmation&&(v&&(N.current=j.current),O?.deletesReceiver&&(N.current=A.current),v&&l&&u===`settings`&&h(),y(void 0),x(TE()),C(!1),k(void 0),R(``)),await r.invalidateQueries({queryKey:pb(e)})},onError:(t,n,i)=>{if(!i||!c(i.viewKey)){r.invalidateQueries({queryKey:pb(e)});return}v===i.form&&O===i.confirmation?(R(t.message),`status`in t&&t.status===409&&C(!0)):Y(`Earlier webhook action failed: ${t.message}`,{tone:`danger`}),r.invalidateQueries({queryKey:pb(e)})}}),me=(e,t=document.activeElement)=>{N.current=t instanceof HTMLElement?t:null,ee(!1),I(!1),R(``),C(!1),k(e)},he=(t,n,r)=>{let i={expectedRevision:r.revision,deliveryRevision:r.deliveryRevision,operationId:crypto.randomUUID()};me(t===`replay`?{title:`Replay this event?`,text:`Sends the same event again with a new 72-hour retry window. Your receiver or channel may show it twice.`,run:()=>je.replay(e,n.deliveryId,i)}:{title:`Retry this delivery now?`,text:`Sends the same message again now. Rate limits and freshness checks still apply.`,run:()=>je.retry(e,n.deliveryId,i)})},ge=t=>({title:`Pause ${t.name}?`,text:`New events won’t be queued while it is paused.${zE(t.pendingCount)}`,run:()=>je.pause(e,t.id,t.revision)}),_e=t=>({title:`Delete ${t.name}?`,text:`${zE(t.pendingCount).trim()} Its settings${RE(t)?``:` and signing keys`} are removed; delivery history stays for up to 30 days.`.trim(),deletesReceiver:!0,run:()=>je.remove(e,t.id,t.revision)});if(n||!t)return(0,Q.jsx)(`div`,{"data-slot":`webhooks-settings`,className:LE,children:(0,Q.jsxs)(`section`,{className:`flex flex-col gap-3 rounded-lg border border-border bg-card p-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:n?`Webhooks aren’t available on this platform`:`Webhooks are off`}),(0,Q.jsx)(`p`,{className:`mt-1 text-ui text-muted-foreground`,children:n?`Delivery needs an OS-verified process identity to keep a single sender. Linux, macOS and Windows provide one; this platform does not.`:`Send task updates to Slack, Discord or your own endpoint when a task needs you, is ready for review or finishes.`})]}),!n&&(0,Q.jsxs)(`p`,{className:`text-ui`,children:[`Start cezar with `,(0,Q.jsx)(`code`,{children:`CEZ_WEBHOOKS=1`}),`, then reload this page. If someone else runs this server, ask them to turn webhooks on.`]}),(0,Q.jsx)(`a`,{className:`w-fit text-ui underline underline-offset-2 hover:text-foreground`,href:g.href,target:`_blank`,rel:`noreferrer`,children:g.note})]})});let ve=_.data?.receivers??[],ye=d&&f&&u!==`settings`?ae??oe.data:void 0,be=_.data?.notice,xe=be?.receiverId?ve.find(e=>e.id===be.receiverId):void 0,Se=v&&v!==`new`?ve.find(e=>e.id===v.id):void 0,Ce=_.data?.historyCount??0,we=S&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border border-warning/50 bg-warning/10 p-3 text-ui`,role:`alert`,children:[(0,Q.jsx)(`p`,{children:`This receiver changed in the meantime, so nothing was applied. Review its latest state and confirm again.`}),v&&v!==`new`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{children:`Your draft is kept. Saving it replaces the latest settings below; a blank URL keeps the current destination.`}),_.isFetching?(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading the latest settings…`}):_.error?(0,Q.jsx)(`p`,{className:`text-danger`,children:`Couldn’t load the latest settings.`}):Se?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`font-medium`,children:[`Latest: revision `,Se.revision,` · `,Tw[Se.state]]}),(0,Q.jsx)(BE,{receiver:Se,projectId:e})]}):(0,Q.jsx)(`p`,{children:`This receiver no longer exists. Close this dialog to return to the list.`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(J,{size:`sm`,variant:`outline`,disabled:_.isFetching,onClick:()=>void _.refetch(),children:`Refresh latest settings`}),(0,Q.jsx)(J,{size:`sm`,disabled:!Se||_.isFetching||!!_.error,onClick:()=>{Se&&(y(Se),C(!1),k(void 0),R(``))},children:`Keep draft and review again`})]})]}):(0,Q.jsx)(`p`,{children:`Cancel, check the refreshed receiver or its history, then choose the action again. Earlier consent is not reused.`})]});return(0,Q.jsxs)(`div`,{"data-slot":`webhooks-settings`,className:LE,children:[(0,Q.jsxs)(`section`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Receivers`}),(0,Q.jsxs)(`p`,{className:`text-ui text-muted-foreground`,children:[`Each receiver gets the task updates you choose while cezar is running. New receivers stay Inactive until you test and activate them. `,(0,Q.jsx)(`a`,{className:`underline underline-offset-2 hover:text-foreground`,href:g.href,target:`_blank`,rel:`noreferrer`,children:g.note})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.jsx)(J,{variant:`ghost`,size:`icon`,"aria-label":`Refresh`,title:`Refresh`,disabled:_.isFetching,onClick:()=>void _.refetch(),children:(0,Q.jsx)(ac,{})}),(0,Q.jsxs)(J,{ref:A,disabled:_.isPending||!!_.error,onClick:e=>{j.current=e.currentTarget,R(``),C(!1),x(TE()),y(`new`)},children:[(0,Q.jsx)(xc,{}),`Add receiver`]})]})]}),be&&(0,Q.jsxs)(`section`,{role:`status`,className:`flex min-w-0 flex-col gap-2 rounded-md border border-warning/50 bg-warning/10 p-3 text-sm [overflow-wrap:anywhere]`,children:[(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:Rw(be.action)}),be.receiverName?` — ${be.receiverName}`:``,(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[be.destination?` · ${be.destination}`:``,` · `,Vw(be.at),be.source?` · via ${Fw[be.source]}`:``]})]}),(0,Q.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:`Any local process, including agents, can change receivers and read signing keys. If this wasn’t you, review it.`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(J,{size:`sm`,variant:`outline`,disabled:z.isPending,onClick:()=>z.mutate(()=>je.acknowledge(e,_.data.changeSequence)),children:`Mark as reviewed`}),be.receiverId&&(0,Q.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>h(be.receiverId,`activity`),children:`View activity`}),xe&&[`active`,`suspended`].includes(xe.state)&&(0,Q.jsx)(J,{size:`sm`,variant:`ghost`,onClick:e=>me(ge(xe),e.currentTarget),children:`Pause receiver`}),xe&&(0,Q.jsx)(J,{size:`sm`,variant:`danger-ghost`,onClick:e=>me(_e(xe),e.currentTarget),children:`Delete receiver`})]})]}),l&&(!d||!f)&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:`This receiver link is invalid.`}),d&&u===`settings`&&!_.isPending&&!_.error&&!ve.some(e=>e.id===l)&&(0,Q.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,Q.jsx)(`span`,{children:`This receiver’s settings are unavailable — it may have been deleted.`}),(0,Q.jsx)(J,{size:`sm`,variant:`outline`,onClick:()=>h(l,`deliveries`),children:`View its history`})]}),d&&f&&u!==`settings`&&!ye&&(0,Q.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:oe.error?`This receiver’s history is unavailable or no longer kept.`:`Loading history…`}),(le||_.error)&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:le||_.error?.message}),_.data?.webhookHealth.status!==`ready`&&_.data?.webhookHealth.reason&&(0,Q.jsx)(`p`,{role:`status`,className:`rounded-md border border-warning/50 bg-warning/10 p-3 text-ui`,children:_.data.webhookHealth.reason}),_.isPending&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading receivers…`}),!_.isPending&&!_.error&&!ve.length&&(0,Q.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-6 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:`No receivers yet`}),(0,Q.jsx)(`p`,{className:`mt-1 text-ui text-muted-foreground`,children:`Add a Slack or Discord channel, or your own endpoint. Send a test, then activate it.`})]}),ve.map(t=>{let n=!RE(t),r=[`inactive`,`disabled`,`paused`].includes(t.state),i=t.state===`suspended`?`Test and recover`:t.state===`disabled`?`Test after repair`:`Send test`,a=[t.destination,`${Dw[t.profile]} content`,`Last test: ${jw[t.lastTest].toLowerCase()}`,t.pendingCount?zw(t.pendingCount,`pending delivery`,`pending deliveries`):``,t.inFlightCount?`${t.inFlightCount} sending`:``].filter(Boolean).join(` · `);return(0,Q.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-card p-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`h3`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold [overflow-wrap:anywhere]`,children:[t.name,(0,Q.jsx)(Nc,{dot:ww[t.state],children:Tw[t.state]}),!n&&(0,Q.jsx)(Nc,{children:Ew[t.format]})]}),(0,Q.jsx)(`p`,{className:`mt-1 break-words text-ui text-muted-foreground`,children:a}),t.consecutiveFailures>0&&(0,Q.jsxs)(`p`,{className:`mt-1 text-ui text-warning`,children:[zw(t.consecutiveFailures,`failed attempt`,`failed attempts`),` in a row.`,t.pendingCount>0?t.nextProbeAt?` Next retry ${Vw(t.nextProbeAt)}.`:``:` Nothing is queued, so nothing will be retried until the next event.`]}),t.state===`paused`&&(0,Q.jsxs)(`p`,{className:`mt-1 text-ui text-muted-foreground`,children:[t.pauseReason===`project_removal`?`Paused when this project was removed from the workspace.`:`Paused.`,` New events aren’t queued.`]}),t.activationBlocked&&(0,Q.jsx)(`p`,{className:`mt-1 text-ui text-warning`,children:`Send a passing test of these settings before activating.`}),n&&t.retiredKeyExpiresAt&&(0,Q.jsxs)(`p`,{className:`mt-1 text-ui text-muted-foreground`,children:[`The previous signing key stops working `,Vw(t.retiredKeyExpiresAt),`.`]})]}),ue&&ue.viewKey===o.key&&ue.receiverId===t.id&&(0,Q.jsx)(AE,{projectId:e,test:ue,openHistory:e=>h(e)},ue.deliveryId),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r&&(0,Q.jsx)(J,{size:`sm`,disabled:z.isPending||t.activationBlocked||t.state===`disabled`&&t.lastTest!==`success`,onClick:n=>me({title:`${t.state===`paused`?`Resume`:`Activate`} ${t.name}?`,text:`Only events from now on are sent — nothing from before ${t.state===`paused`?`resuming`:`activation`}.${t.lastTest===`transient_failure`?` The last test failed with a temporary error, so delivery may still fail.`:``}`,receiver:t,standard:t.profile===`standard`,local:t.allowLocalNetwork,run:()=>t.state===`paused`?je.resume(e,t.id,t.revision):je.activate(e,t.id,t.revision)},n.currentTarget),children:t.state===`paused`?`Resume`:`Activate`}),(0,Q.jsx)(J,{size:`sm`,variant:`outline`,disabled:z.isPending,onClick:e=>{let n={expectedRevision:t.revision,deliveryRevision:t.deliveryRevision,operationId:crypto.randomUUID()};t.state===`suspended`?me({title:`Test and recover?`,text:`If the test passes, ${t.name} becomes Active and sends its queued deliveries that are still current${t.pendingCount?` (${t.pendingCount} queued now)`:``}.`,run:()=>fe(t,n)},e.currentTarget):z.mutate(()=>fe(t,n))},children:i}),!r&&(0,Q.jsx)(J,{size:`sm`,variant:`outline`,onClick:e=>me(ge(t),e.currentTarget),children:`Pause`}),(0,Q.jsx)(J,{size:`sm`,variant:`outline`,onClick:e=>{j.current=e.currentTarget,x(TE(t)),C(!1),R(``),y(t),h(t.id,`settings`)},children:`Edit`}),(0,Q.jsx)(J,{size:`sm`,variant:`outline`,ref:e=>{e?ne.current.set(t.id,e):ne.current.delete(t.id)},onClick:()=>h(t.id),children:`History`}),(0,Q.jsxs)(tc,{children:[(0,Q.jsx)(Ys,{asChild:!0,children:(0,Q.jsx)(J,{size:`icon-sm`,variant:`ghost`,"aria-label":`More actions for ${t.name}`,ref:e=>{e?L.current.set(t.id,e):L.current.delete(t.id)},children:(0,Q.jsx)(Da,{})})}),(0,Q.jsxs)(Zs,{align:`end`,className:`w-[220px]`,children:[n&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)($s,{disabled:!!t.retiredKeyExpiresAt&&Date.parse(t.retiredKeyExpiresAt)>Date.now(),onSelect:()=>me({title:`Rotate signing key?`,text:`Old and new keys both sign deliveries for 24 hours. Install the new key in your receiver within that time.`,run:()=>je.rotate(e,t.id,t.revision,`graceful`)},L.current.get(t.id)),children:[(0,Q.jsx)(Ll,{}),`Rotate key`]}),(0,Q.jsxs)($s,{onSelect:()=>me({title:`Revoke old signing keys now?`,text:`Old keys stop signing immediately, and deliveries fail until your receiver uses the new key. Also remove old keys from your receiver — cezar can’t revoke keys it still accepts.`,run:()=>je.rotate(e,t.id,t.revision,`revoke_now`)},L.current.get(t.id)),children:[(0,Q.jsx)(ru,{}),`Revoke old keys`]}),(0,Q.jsx)(ec,{})]}),(0,Q.jsxs)($s,{variant:`destructive`,onSelect:()=>me(_e(t),L.current.get(t.id)),children:[(0,Q.jsx)(hc,{}),`Delete`]})]})]})]})]},t.id)}),(Ce>0||se)&&(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`div`,{children:(0,Q.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>ce(e=>!e),children:se?`Hide deleted receivers`:`Show deleted receivers (${Ce})`})}),se&&(0,Q.jsxs)(Q.Fragment,{children:[pe.error&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:pe.error.message}),pe.data?.pages.flatMap(e=>e.items).map(e=>(0,Q.jsxs)(J,{ref:t=>{t?ne.current.set(e.id,t):ne.current.delete(e.id)},variant:`outline`,className:`h-auto max-w-full justify-start whitespace-normal py-2 text-left font-normal [overflow-wrap:anywhere]`,onClick:()=>h(e.id),children:[e.name,` — deleted `,Vw(e.deletedAt)]},e.id)),pe.data&&!pe.data.pages.some(e=>e.items.length)&&(0,Q.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:`No deleted receivers are kept.`}),pe.hasNextPage&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(J,{size:`sm`,variant:`outline`,disabled:pe.isFetchingNextPage,onClick:()=>void pe.fetchNextPage(),children:`Load older`})})]})]}),(0,Q.jsx)(qr,{open:v!==void 0&&!O,onOpenChange:e=>{!e&&!z.isPending&&(y(void 0),x(TE()),C(!1),l&&h())},children:(0,Q.jsxs)(Wr,{onCloseAutoFocus:e=>P(e,j.current),className:`max-h-[90dvh] overflow-y-auto`,children:[(0,Q.jsxs)(Lr,{children:[(0,Q.jsx)(Zr,{children:v===`new`?`Add receiver`:`Edit receiver`}),(0,Q.jsx)(Vr,{children:`New and changed receivers stay Inactive until you test and activate them.`})]}),v&&(0,Q.jsx)(DE,{receiver:v===`new`?void 0:v,guideHref:g.href,draft:b,setDraft:x,pending:z.isPending,blocked:S,save:t=>{if(v===`new`)z.mutate(()=>je.create(e,t));else{let n=v;me({title:`Save changes?`,text:`Changing where or what ${n.name} sends makes it Inactive again${n.pendingCount?` and cancels ${zw(n.pendingCount,`pending delivery`,`pending deliveries`)}`:``}. A delivery already sending may still arrive. Renaming alone keeps it active.${n.format!==`cezar.json.v1`&&t.format===`cezar.json.v1`?` After saving, use Rotate key and copy the new signing key into your receiver before testing.`:``}`,run:()=>je.update(e,n.id,t)})}}},v===`new`?`new`:`${v.id}-${v.revision}`),we,le&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:le})]})}),(0,Q.jsx)(qr,{open:!!O,onOpenChange:e=>{!e&&!z.isPending&&k(void 0)},children:(0,Q.jsxs)(Wr,{onCloseAutoFocus:e=>P(e,N.current),className:`max-h-[90dvh] overflow-y-auto`,children:[(0,Q.jsxs)(Lr,{children:[(0,Q.jsx)(Zr,{children:O?.title}),(0,Q.jsx)(Vr,{children:O?.text})]}),O?.receiver&&(0,Q.jsx)(BE,{receiver:O.receiver,projectId:e}),O?.standard&&(0,Q.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:F,onChange:e=>ee(e.target.checked)}),`I understand Standard sends task titles, questions and error text to this receiver.`]}),O?.local&&(0,Q.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:te,onChange:e=>I(e.target.checked)}),`I allow delivery to this computer or private network.`]}),we,le&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:le}),(0,Q.jsxs)(Br,{children:[(0,Q.jsx)(J,{variant:`outline`,disabled:z.isPending,onClick:()=>k(void 0),children:`Cancel`}),(0,Q.jsx)(J,{className:O?.deletesReceiver?`bg-danger text-danger-foreground hover:brightness-[0.96]`:void 0,disabled:z.isPending||S||!!O?.standard&&!F||!!O?.local&&!te,onClick:()=>O&&z.mutate(O.run),children:z.isPending?`Working…`:O?.deletesReceiver?`Delete`:`Confirm`})]})]})}),(0,Q.jsx)(qr,{open:!!E,onOpenChange:e=>{e||D(void 0)},children:(0,Q.jsxs)(Wr,{onCloseAutoFocus:e=>P(e,M.current),className:`max-h-[90dvh] overflow-y-auto`,children:[(0,Q.jsxs)(Lr,{children:[(0,Q.jsx)(Zr,{children:`Save your signing key`}),(0,Q.jsx)(Vr,{children:`Copy it into your receiver now — it is shown only once. If you lose it, use Rotate key to get a new one (or Revoke old keys while a rotation is still overlapping).`})]}),(0,Q.jsx)(`code`,{tabIndex:0,className:`block select-text break-all rounded-md bg-muted p-3 font-mono text-sm`,children:E}),w&&(0,Q.jsx)(`p`,{role:`status`,className:`text-ui text-muted-foreground`,children:w}),(0,Q.jsxs)(Br,{children:[(0,Q.jsx)(J,{variant:`outline`,onClick:async()=>{try{if(!E||!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(E),T(`Key copied. Store it in your receiver.`)}catch{T(`Couldn’t copy — select the key and copy it manually before closing.`)}},children:`Copy key`}),(0,Q.jsx)(J,{onClick:()=>D(void 0),children:`I’ve saved the key`})]})]})}),(0,Q.jsx)(qr,{open:!!ye,onOpenChange:e=>{e||h()},children:(0,Q.jsxs)(Wr,{className:`max-h-[90dvh] overflow-y-auto sm:max-w-2xl [overflow-wrap:anywhere]`,onCloseAutoFocus:e=>{let t=re.current;t?.isConnected&&(e.preventDefault(),t.focus())},children:[(0,Q.jsxs)(Lr,{className:`min-w-0`,children:[(0,Q.jsxs)(Zr,{children:[ye?.name,` — history`]}),(0,Q.jsx)(Vr,{children:`Delivery results and setting changes for this receiver.`})]}),ye&&(0,Q.jsx)(NE,{projectId:e,receiver:ye,tab:p,onTabChange:e=>h(ye.id,e),operation:he},ye.id)]})})]})}var LE=`mx-auto flex w-full max-w-2xl min-w-0 flex-col gap-6 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,RE=e=>(e.format??`cezar.json.v1`)!==`cezar.json.v1`,zE=e=>e?` ${zw(e,`pending delivery`,`pending deliveries`)} will be cancelled; one already sending may still arrive.`:``;function BE({receiver:e,projectId:t}){let n=e.preset===`custom`?e.events:e.preset===`all`?[`task.attention_required`,`task.review_ready`,`task.finished`,`task.failed`,`task.cancelled`]:[`task.attention_required`,`task.review_ready`,`task.finished`,`task.failed`],r=`text-muted-foreground`;return(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 text-ui`,children:[(0,Q.jsxs)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1 rounded-md border border-border bg-card p-3 [overflow-wrap:anywhere]`,children:[(0,Q.jsx)(`dt`,{className:r,children:`Receiver`}),(0,Q.jsx)(`dd`,{children:e.name}),(0,Q.jsx)(`dt`,{className:r,children:`Destination`}),(0,Q.jsx)(`dd`,{children:e.format===`cezar.json.v1`?`Custom receiver (signed cezar JSON)`:`${Ew[e.format]} channel`}),(0,Q.jsx)(`dt`,{className:r,children:`URL`}),(0,Q.jsx)(`dd`,{children:e.destination}),(0,Q.jsx)(`dt`,{className:r,children:`Project`}),(0,Q.jsx)(`dd`,{children:t}),(0,Q.jsx)(`dt`,{className:r,children:`Message content`}),(0,Q.jsx)(`dd`,{children:Dw[e.profile]}),(0,Q.jsx)(`dt`,{className:r,children:`Events`}),(0,Q.jsxs)(`dd`,{children:[kw[e.preset],`: `,n.map(e=>SE[e]).join(`, `)]}),(0,Q.jsx)(`dt`,{className:r,children:`Tasks`}),(0,Q.jsx)(`dd`,{children:Ow[e.scope]}),(0,Q.jsx)(`dt`,{className:r,children:`Waiting and review delay`}),(0,Q.jsx)(`dd`,{children:Aw[e.graceSeconds]}),e.format===`cezar.json.v1`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:r,children:`Private network`}),(0,Q.jsx)(`dd`,{children:e.allowLocalNetwork?`Allowed`:`Not allowed`})]}),(0,Q.jsx)(`dt`,{className:r,children:`Failures that resume automatically`}),(0,Q.jsx)(`dd`,{children:e.preset===`all`||e.includeScheduledFailures?`Included`:`Excluded`})]}),e.destination.startsWith(`http:`)&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-warning`,children:`HTTP is unencrypted — others on the network may read these messages. Use HTTPS where possible.`})]})}var VE=`/assets/tester-army-tUUSV6JM.png`,HE=`https://github.com/tester-army/e2e`,UE={AI_GATEWAY_API_KEY:`Vercel AI Gateway`,OPENAI_API_KEY:`OpenAI`,ANTHROPIC_API_KEY:`Anthropic`,OPENROUTER_API_KEY:`OpenRouter`},WE=new Set([`queued`,`running`,`waiting`]);function GE(e,t,n,r){if(WE.has(e))return`Setting up — cezar is installing and configuring e2e in its own worktree.`;let i=r?`its draft PR is ready — merge it to finish.`:`merge ${n?`branch ${n}`:`the setup task’s branch`} to finish.`;return e===`review`?`Ready for review — ${i}`:e===`done`?t?`Setup finished.`:`Setup finished — ${i}`:e===`failed`?`The last setup failed — open the task to see why, then try again.`:`The last setup was cancelled.`}function KE({ok:e,children:t}){return(0,Q.jsxs)(`li`,{className:`flex items-center gap-2 text-sm`,"data-ok":e,children:[e?(0,Q.jsx)(Rs,{className:`size-4 text-success`,"aria-hidden":!0}):(0,Q.jsx)(Wl,{className:`size-4 text-muted-foreground`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:e?void 0:`text-muted-foreground`,children:t})]})}function qE(){let e=U(),t=Nr(),n=h(),r=Ee(n.data?.setup?.runId),[i,a]=(0,Z.useState)(void 0),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(null),u=r.data?.status??n.data?.setup?.status,d=r.data?.pullRequestUrl&&/^https?:\/\//.test(r.data.pullRequestUrl)?r.data.pullRequestUrl:void 0,f=u!==void 0&&WE.has(u),p=n.data?.credentials??[],m=i??p[0]??`AI_GATEWAY_API_KEY`,g=!!(n.data?.configFile&&n.data.workflow),_=H({mutationFn:async()=>({projectId:$n(),runId:(await le(o?{credential:{name:m,value:o}}:{})).runId}),onSuccess:async({projectId:n,runId:r})=>{s(``),l(null),await Promise.all([e.invalidateQueries({queryKey:V.e2e.allFor(n??``)}),e.invalidateQueries({queryKey:V.secrets.allFor(n??``)})]),Y(`e2e setup started`),$n()===n&&t(_r(n,`/tasks/${r}`))},onError:e=>l(e.message)});return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,"data-slot":`e2e-settings`,children:[(0,Q.jsxs)(`section`,{className:`rounded-lg border border-border bg-card p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`img`,{src:VE,alt:``,width:40,height:40,className:`size-10 shrink-0 rounded-md`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:`TesterArmy e2e`}),(0,Q.jsx)(`span`,{"data-slot":`e2e-badge`,"data-state":f?`setting-up`:g?`installed`:`none`,className:g&&!f?`rounded-full bg-success/10 px-2 py-0.5 text-xs font-medium text-success`:`rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground`,children:f?`Setting up`:g?`Installed`:`Not set up`})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Agentic browser end-to-end testing`})]}),(0,Q.jsxs)(`a`,{href:HE,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline`,children:[`tester-army/e2e `,(0,Q.jsx)(ic,{className:`size-3`,"aria-hidden":!0})]})]}),(0,Q.jsxs)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:[`cezar installs it for this project, points it at your dev server, writes a smoke test and an`,` `,(0,Q.jsx)(`code`,{children:`implement-and-e2e`}),` workflow, proves it all passes in a real browser and opens a draft PR for you to merge.`]}),n.isPending?(0,Q.jsx)(`p`,{className:`mt-4 text-sm text-muted-foreground`,children:`Loading…`}):null,n.isError?(0,Q.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:n.error.message}):null,n.data?(0,Q.jsxs)(`ul`,{className:`mt-4 flex flex-col gap-1.5`,"aria-label":`e2e status`,children:[(0,Q.jsx)(KE,{ok:!!n.data.configFile,children:n.data.configFile?(0,Q.jsxs)(Q.Fragment,{children:[`Configured (`,(0,Q.jsx)(`code`,{children:n.data.configFile}),`)`]}):`Not configured in this checkout`}),(0,Q.jsxs)(KE,{ok:n.data.workflow,children:[(0,Q.jsx)(`code`,{children:`implement-and-e2e`}),` workflow `,n.data.workflow?`available`:`not added yet`]}),(0,Q.jsx)(KE,{ok:p.length>0,children:p.length>0?(0,Q.jsxs)(Q.Fragment,{children:[`Model key: `,(0,Q.jsx)(`code`,{children:p.join(`, `)})]}):`No model key — smoke tests run without one; agent steps need one`})]}):null,n.data?.setup&&u?(0,Q.jsxs)(`p`,{className:`mt-3 text-sm`,"data-slot":`e2e-setup-run`,"data-status":u,children:[GE(u,!!n.data.configFile,r.data?.branch,d),` `,d&&!n.data.configFile?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`a`,{className:`underline`,href:d,target:`_blank`,rel:`noreferrer`,children:`Open the draft PR`}),` · `]}):null,(0,Q.jsx)(yr,{className:`underline`,to:_r($n(),`/tasks/${n.data.setup.runId}`),children:`Open the setup task`})]}):null]}),(0,Q.jsxs)(`form`,{className:`rounded-lg border border-border bg-card p-4`,autoComplete:`off`,onSubmit:e=>{e.preventDefault(),_.mutate()},children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:g?`Set up again`:`Set up e2e`}),(0,Q.jsxs)(`label`,{className:`mt-3 block text-sm`,children:[`Model provider`,(0,Q.jsx)(`select`,{"aria-label":`Model provider`,value:m,onChange:e=>a(e.target.value),className:`mt-1 block w-full rounded border border-border bg-background p-2 outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:fr.map(e=>(0,Q.jsxs)(`option`,{value:e,children:[UE[e],` (`,e,`)`,p.includes(e)?` — stored`:``]},e))})]}),(0,Q.jsxs)(`label`,{className:`mt-3 block text-sm`,children:[`API key `,(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`(optional)`}),(0,Q.jsx)(`input`,{"aria-label":`API key`,type:`password`,autoComplete:`off`,value:o,onChange:e=>s(e.target.value),placeholder:p.includes(m)?`stored — leave empty to keep it`:``,className:`mt-1 block w-full rounded border border-border bg-background p-2`})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Stored encrypted as a project secret for check steps only — never handed to an agent session.`}),c?(0,Q.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:c}):null,(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(J,{type:`submit`,disabled:_.isPending||f||!n.data,children:f?`Setup in progress…`:g?`Set up again`:`Set up e2e`})})]})]})}function JE(){return(0,Q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col gap-4 p-4 md:p-6`,"data-slot":`integrations-settings`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Tools cezar can set up in this project for you — each one as a task you review and merge.`}),(0,Q.jsxs)(Gc,{defaultValue:`test-frameworks`,children:[(0,Q.jsx)(Wc,{variant:`line`,"data-slot":`integrations-tabs`,children:(0,Q.jsx)(Hc,{value:`test-frameworks`,children:`Test frameworks`})}),(0,Q.jsx)(Uc,{value:`test-frameworks`,className:`pt-4`,children:(0,Q.jsx)(qE,{})})]})]})}var YE=[{id:`tracker`,title:`Issue tracker`,description:`Connect this project to Jira or Linear.`,icon:su,component:hE,scope:`project`},{id:`secrets`,title:`Secrets`,description:`Encrypted values for this project’s check steps and cezar — never for agents.`,icon:Ll,component:bE,scope:`project`},{id:`webhooks`,title:`Webhooks`,description:`Send task updates to Slack, Discord or your own endpoint.`,icon:lu,component:FE,scope:`project`},{id:`integrations`,title:`External integrations`,description:`Third-party tools cezar installs and wires into this project — test frameworks first.`,icon:gl,component:JE,scope:`project`},{id:`agents`,title:`Agents`,description:`Providers, default runner and models.`,icon:Lo,component:TC,scope:`project`},{id:`instructions`,title:`Instructions`,description:`What you write for the models: system prompt, branch naming, prompt templates.`,icon:Va,component:fw,scope:`project`},{id:`tasks`,title:`Tasks`,description:`Development model, landing, required checks, base branch, review, live titles.`,icon:Bl,component:DT,scope:`project`},{id:`agent-config`,title:`Agent config`,description:`Edit the coding agents’ own config files, per scope.`,icon:El,component:mC,scope:`project`},{id:`worktrees`,title:`Worktrees`,description:`How many finished task worktrees this project keeps on disk.`,icon:Ol,component:pE,scope:`project`},{id:`bookmarklets`,title:`Bookmarklets`,description:`Launch skills from a GitHub PR or issue.`,icon:_l,component:gw,scope:`project`},{id:`appearance`,title:`Appearance`,description:`Theme, accent and density.`,icon:Xl,component:nw,scope:`global`},{id:`notifications`,title:`Notifications`,description:`Browser notifications when an agent needs you.`,icon:hl,component:vw,scope:`global`},{id:`keyboard`,title:`Keyboard`,description:`Shortcuts for task commands.`,icon:Rl,component:mw,scope:`global`},{id:`resources`,title:`Resources`,description:`Parallel tasks and per-task memory limit, across every project.`,icon:Nl,component:_T,scope:`global`},{id:`skills`,title:`Skills`,description:`Updates for skills installed on this machine.`,icon:Jl,component:yT,scope:`global`},{id:`global-instructions`,title:`Instructions`,description:`A system prompt for every task in every project; a project’s own wins where they conflict.`,icon:Va,component:iw,scope:`global`},{id:`workspace-secrets`,title:`Secrets`,description:`Encrypted values shared by every project on this machine — never for agents.`,icon:Ll,component:xE,scope:`global`},{id:`accounts`,title:`Agent accounts`,description:`Second logins, and the agent and models a project uses when it has chosen none.`,icon:Fl,component:qS,scope:`global`},{id:`projects`,title:`Projects`,description:`The workspace registry and where GitHub checkouts land.`,icon:Ml,component:Yw,scope:`global`},{id:`transfer`,title:`Transfer`,description:`Export this machine’s configuration to a file, or import one from another cezar.`,icon:ml,component:VT,scope:`global`},{id:`privacy`,title:`Privacy`,description:`Whether cezar shares usage data with its maintainers. Off unless you turn it on.`,icon:nu,component:yw,scope:`global`}];function XE(e,t){return YE.filter(n=>!n.hidden&&n.scope===e&&!(t?.singleProject===!0&&n.id===`projects`))}function ZE(e){return{global:XE(`global`,e),project:XE(`project`,e)}}var QE=null;function $E(e){Wp(e.pathname)||(QE={pathname:e.pathname,search:e.search,hash:e.hash})}function eD(){return QE}function tD(){let e=C(),t=!e.isError&&e.data?.capabilities?.webhooks===!0,n=e.data?.capabilities?.webhooksUnavailableReason===`unsupported_platform`,r=mb(kr()??`default`,t),i=r.data?.receivers??[],a=i.filter(e=>[`suspended`,`disabled`].includes(e.state)).length,o=i.filter(e=>e.state===`inactive`).length,s=i.reduce((e,t)=>e+t.pendingCount,0);return(0,Q.jsx)($,{title:`Webhooks`,hint:`Task updates sent to Slack, Discord or your own endpoint.`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1 rounded-md border border-border bg-card p-3 text-ui`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[e.isError?(0,Q.jsx)(`p`,{children:`Status unavailable — could not load server health.`}):e.data?n?(0,Q.jsx)(`p`,{children:`Not available on this server’s platform.`}):t?r.isPending?(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading…`}):r.error?(0,Q.jsx)(`p`,{className:`text-danger`,children:`Status unavailable — open Webhooks for details.`}):i.length?(0,Q.jsxs)(`p`,{children:[i.filter(e=>e.state===`active`).length,` active · `,i.filter(e=>e.state===`paused`).length,` paused`,o?` · ${o} inactive`:``,a?(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsxs)(`span`,{className:`text-warning`,children:[a,` need attention`]})]}):``,s?` · ${s} pending`:``]}):(0,Q.jsx)(`p`,{children:`No receivers yet.`}):(0,Q.jsx)(`p`,{children:`Off on this server.`}):(0,Q.jsx)(`p`,{children:`Loading webhook status…`}),t&&!n&&!r.error&&r.data?.webhookHealth&&[`degraded`,`unavailable`].includes(r.data.webhookHealth.status)&&(0,Q.jsx)(`p`,{role:`status`,className:`text-warning`,children:r.data.webhookHealth.reason||`Webhook delivery needs attention. Open Webhooks for details.`})]}),(0,Q.jsx)(K,{className:`shrink-0 underline underline-offset-2 hover:text-foreground`,to:`/settings/webhooks`,children:t&&!n?`Manage webhooks`:`Open webhook settings`})]})})}function nD(){let e=kr(),t=W_(a().data,e,C().data);return e===null?null:t?.projects.find(t=>t.id===e)?.root??null}function rD(e){el(e).then(()=>Y(`Project folder copied`)).catch(()=>Y(e))}function iD(){let e=nD();return e===null?null:(0,Q.jsx)($,{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 items-start gap-3 rounded-md border border-border bg-card p-3`,children:[(0,Q.jsx)(`span`,{"data-slot":`project-location-path`,className:`min-w-0 flex-1 font-mono text-xs break-all text-foreground`,children:e}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Q.jsx)(`button`,{type:`button`,"data-action":`project-location-copy`,title:`Copy the project folder path`,onClick:()=>rD(e),className:`text-xs font-medium text-muted-foreground transition-colors hover:text-foreground`,children:`Copy`}),(0,Q.jsx)(oD,{root:e})]})]})})}function aD(){let e=nD();return e===null?null:(0,Q.jsxs)(`div`,{"data-slot":`project-location`,"data-variant":`nav`,className:`mt-auto px-2.5 pt-3`,children:[(0,Q.jsx)(`p`,{className:`text-meta text-soft-foreground`,children:`Project folder`}),(0,Q.jsx)(`button`,{type:`button`,"data-action":`project-location-copy`,title:`${e} — click to copy`,onClick:()=>rD(e),className:`block w-full truncate text-left font-mono text-meta text-muted-foreground transition-colors hover:text-foreground`,children:e})]})}function oD({root:e}){let t=D(),n=H({mutationFn:e=>ae(e),onError:e=>Y(e.message,{tone:`danger`})}),r=(t.data?.targets??[]).filter(e=>ls(e.id)===void 0).map(e=>({target:e}));return r.length===0?null:(0,Q.jsx)(Ro,{slot:`project-location-open`,label:`Open with`,triggerVariant:`outline`,title:e,disabled:n.isPending,choices:r,onPick:e=>n.mutate(e,{onSuccess:()=>Y(`Opening the project folder in ${r.find(t=>t.target.id===e)?.target.label??e}`)})})}function sD(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}function cD({capabilities:e}){let t=kr(),n=a(),r=C(),i=Ht();if(n.isPending)return(0,Q.jsx)(`p`,{"data-slot":`project-general-loading`,className:`text-ui text-soft-foreground`,children:`Loading project…`});if(n.isError)return(0,Q.jsxs)(`p`,{"data-slot":`project-general-error`,className:`text-ui text-danger`,children:[`Could not read the project registry — `,n.error.message]});let o=W_(n.data,t,r.data),s=o?.projects.find(e=>e.id===t);if(!o||!s)return null;let c=e?.singleProject!==!0&&s.unregistered!==!0;return(0,Q.jsxs)(`div`,{"data-slot":`project-general`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7`,children:[(0,Q.jsx)(iD,{}),(0,Q.jsx)(lD,{project:s,canRemove:c}),(0,Q.jsx)(tD,{}),s.unregistered?(0,Q.jsx)($,{title:`Add to your projects`,hint:`cezar is serving this folder because you started it here — starting cezar somewhere new never adds it to your project list for you. Adding it keeps it in the sidebar between runs and gives it a registry entry to hold settings like the task cap. Nothing on disk changes either way.`,children:(0,Q.jsx)(eT,{root:s.root,name:s.name,notAddable:s.notAddable===!0})}):null,c?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($,{title:`Max parallel tasks`,hint:i.data?`How many of this project's tasks may run at once — leave it empty to inherit the workspace limit. The workspace limit (${i.data.resources.maxParallel}) still applies as an overall ceiling, so a higher value here has no extra effect until that one is raised.`:`How many of this project's tasks may run at once — leave it empty to inherit the workspace limit. The workspace limit still applies as an overall ceiling.`,children:i.data?(0,Q.jsx)(nT,{project:s,workspaceMax:i.data.resources.maxParallel}):(0,Q.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:`Loading the workspace limit…`})}),(0,Q.jsx)(uD,{project:s,bootProject:o.bootProject})]}):null]})}function lD({project:e,canRemove:t}){return(0,Q.jsx)($,{title:`Project`,hint:`The registry entry for this checkout — re-probed every time the project list is read.`,children:(0,Q.jsxs)(`dl`,{"data-slot":`project-facts`,className:`grid grid-cols-[8rem_minmax(0,1fr)] gap-x-3 gap-y-1.5 rounded-md border border-border bg-card p-3 text-ui`,children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Name`}),(0,Q.jsx)(`dd`,{className:`min-w-0 truncate text-foreground`,children:e.name}),(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Status`}),(0,Q.jsxs)(`dd`,{"data-slot":`project-general-status`,className:e.status===`missing`?`text-danger`:`text-foreground`,children:[qw[e.status],e.status===`missing`?t?` — remove it below, or restore the folder`:` — restore the folder at the path above`:null]}),e.branch===void 0?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Branch`}),(0,Q.jsx)(`dd`,{className:`min-w-0 truncate font-mono text-xs text-foreground`,children:e.branch})]}),e.unregistered?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`In your projects`}),(0,Q.jsx)(`dd`,{"data-slot":`project-general-unregistered`,className:`text-foreground`,children:`No — served because cezar was started here`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Added`}),(0,Q.jsxs)(`dd`,{className:`text-foreground`,children:[sD(e.addedAt),(0,Q.jsx)(`span`,{className:`text-soft-foreground`,children:e.source===`checkout`?` · cloned from GitHub`:` · opened locally`})]}),(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Last opened`}),(0,Q.jsx)(`dd`,{className:`text-foreground`,children:sD(e.lastOpenedAt)})]})]})})}function uD({project:e,bootProject:t}){let[n,r]=(0,Z.useState)(null),i=Uw(),a=Nr(),o=e.id===t;return(0,Q.jsxs)($,{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 adding it back later finds everything intact.`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(J,{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 — stop it and use `cezar projects remove`":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-meta text-soft-foreground`,children:"cezar is serving this project — stop cezar and run `cezar projects remove` to drop it."}):null]}),(0,Q.jsx)(Ww,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{r(null),i.confirm(e,()=>void a(`/p/${encodeURIComponent(t)}`))}})]})}function dD(e,t){return e===`global`?`/settings/global/${t}`:`/settings/${t}`}var fD=`/settings/global`;function pD(e,t){let n=`/p/${encodeURIComponent(e)}/settings`;return t===void 0?n:`${n}/${t}`}function mD(e){let{pathname:t}=jr(),n=a().data,r=C().data,i=Sr(t),o=n?.bootProject??r?.bootProject??null,s=Z.useMemo(()=>{let e=[...n?.projects??[]].sort((e,t)=>t.lastOpenedAt.localeCompare(e.lastOpenedAt)).map(({id:e,name:t,status:n})=>({id:e,name:t,status:n}));if(i!==null&&!e.some(e=>e.id===i)){let t=i===o?r?.repo?.root.replace(/[\\/]+$/,``).split(/[\\/]/).pop():void 0;e.unshift({id:i,name:t||i,status:`ok`})}return e},[n,r,i,o]),c=s.find(e=>e.id===i)??null,l=c!==null&&(n?.projects??[]).some(e=>e.id===i),u=e?.singleProject===!0||s.length<=1||c!==null&&!l;return{projects:u&&c!==null&&!l?[c]:s,activeProjectId:i,activeProject:c,bootProjectId:o,flat:u}}function hD(e){let t=Nr();return Z.useCallback(()=>{let n=eD();if(n!==null){t(n);return}t(e===null?`/`:`/p/${encodeURIComponent(e)}/`)},[t,e])}function gD(e){Z.useEffect(()=>{let t=t=>{t.key!==`Escape`||t.defaultPrevented||(t.target instanceof Element?t.target:null)?.closest(`input, textarea, select, [contenteditable]`)||document.querySelector(`[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"]`)||e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}var _D=(e,t=!1)=>W(`flex h-[34px] shrink-0 items-center gap-2.5 rounded-md px-2.5 text-ui font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,t&&`h-11`,e&&`bg-muted font-semibold text-foreground`),vD=Z.createContext(!1);function yD({children:e}){return(0,Q.jsx)(`p`,{className:`shrink-0 px-2.5 pt-1 pb-1 eyebrow text-soft-foreground`,children:e})}function bD({project:e,sections:t,active:n,activeId:r,indent:i}){let a=Z.useContext(vD);return(0,Q.jsxs)(`div`,{className:W(`flex flex-col gap-0.5`,i&&`mt-0.5 ml-[14px] border-l border-border pl-2`),children:[(0,Q.jsxs)(br,{to:pD(e.id),end:!0,"data-slot":`settings-project-general`,"data-project":e.id,className:W(_D(n&&r===null,a),!a&&`h-[30px]`,`text-ui`),children:[(0,Q.jsx)(ti,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),`General`]}),t.map(t=>{let i=n&&t.id===r;return(0,Q.jsxs)(br,{to:_r(e.id,dD(`project`,t.id)),"data-project-section":t.id,"data-project":e.id,className:W(_D(i,a),!a&&`h-[30px]`,`text-ui`),children:[(0,Q.jsx)(t.icon,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),t.title]},t.id)})]})}function xD({project:e}){return(0,Q.jsx)(`span`,{className:`truncate`,children:e.name})}function SD({project:e,indent:t}){let n=`${e.name} is gone — remove it in Projects`;return(0,Q.jsxs)(`div`,{"data-slot":`settings-project`,"data-project":e.id,"data-status":`missing`,title:n,className:`flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-ui font-medium opacity-55`,children:[t?(0,Q.jsx)(`span`,{className:`w-3 shrink-0`,"aria-hidden":`true`}):null,(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Q.jsx)(`span`,{className:`sr-only`,children:n}),(0,Q.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full bg-danger/15 px-[7px] py-px text-micro font-medium text-danger`,children:`folder not found`})]})}function CD({project:e,sections:t,activeProjectId:n,activeId:r,openSectionId:i,onProjectPage:a,expanded:o,onToggle:s}){let c=e.id===n,l=Z.useContext(vD),u=`settings-project-${Z.useId()}-${e.id}`,d=!c&&a?pD(e.id,i??void 0):null;return e.status===`missing`?(0,Q.jsx)(SD,{project:e,indent:!0}):(0,Q.jsxs)(`div`,{"data-slot":`settings-project`,"data-project":e.id,"data-status":e.status,"data-expanded":o?``:void 0,children:[(0,Q.jsxs)(`div`,{className:W(`flex items-center rounded-md`,c&&r===null&&`bg-muted`),children:[(0,Q.jsx)(`button`,{type:`button`,onClick:s,"aria-expanded":o,"aria-controls":o?u:void 0,"aria-label":`${o?`Collapse`:`Expand`} ${e.name}`,className:W(`flex shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted/60 hover:text-foreground`,l?`size-11`:`size-7`),children:(0,Q.jsx)(Ws,{"aria-hidden":`true`,className:W(`size-3 transition-transform`,!o&&`-rotate-90`)})}),d===null?(0,Q.jsx)(`button`,{type:`button`,onClick:s,"aria-expanded":o,"aria-controls":o?u:void 0,"data-slot":`settings-project-toggle`,className:W(`flex min-w-0 flex-1 items-center gap-1.5 rounded-md py-1.5 pr-2 text-left text-ui font-semibold transition-colors`,l&&`min-h-11`,c?`text-foreground`:`text-muted-foreground hover:text-foreground`),children:(0,Q.jsx)(xD,{project:e})}):(0,Q.jsx)(yr,{to:d,"data-slot":`settings-project-link`,title:`Open ${e.name}'s ${t.find(e=>e.id===i)?.title??`General`}`,className:W(`flex min-w-0 flex-1 items-center gap-1.5 rounded-md py-1.5 pr-2 text-left text-ui font-semibold text-muted-foreground transition-colors hover:text-foreground`,l&&`min-h-11`),children:(0,Q.jsx)(xD,{project:e})})]}),o?(0,Q.jsx)(`div`,{id:u,children:(0,Q.jsx)(bD,{project:e,sections:t,active:c,activeId:r,indent:!0})}):null]})}function wD(e){let[t,n]=Um();return(0,Q.jsx)(eh,{slot:`settings-sidebar`,width:t,onWidthChange:n,children:(0,Q.jsx)(ED,{...e})})}function TD({onOpenChange:e,...t}){let{pathname:n}=jr();return Z.useEffect(()=>{e(!1)},[n,e]),Z.useEffect(()=>{let t=window.matchMedia?.(`(min-width: 768px)`);if(!t)return;let n=t=>{t.matches&&e(!1)};return t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[e]),(0,Q.jsx)(nh,{slot:`settings-mobile-drawer`,title:`Settings navigation`,children:e=>(0,Q.jsx)(ED,{...t,headerAction:e})})}function ED({scope:e,activeId:t,capabilities:n,tree:r,leave:i,headerAction:a}){let{global:o,project:s}=ZE(n),c=!!a,l=r.activeProjectId,[u,d]=Z.useState({project:l,map:{}}),f=u.project===l?u.map:{},p=e=>f[e]??e===l,m=e=>d(t=>{let n=t.project===l?t.map:{};return{project:l,map:{...n,[e]:!(n[e]??e===l)}}}),h=e===`global`,[g]=r.projects,_=C().data,v=_?.version??null,y=_?.latestVersion??null,b=ne().data,x=b?.available?b.count??null:null,S=Ht().data?.branding,w=S?.name??`cezar`,T=S?.logoUrl??null;return(0,Q.jsx)(vD.Provider,{value:c,children:(0,Q.jsxs)(`div`,{"data-slot":`settings-sidebar-content`,className:`flex min-h-0 flex-1 flex-col pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-[9px] px-3.5 pt-3.5 pb-2.5`,children:[(0,Q.jsx)(cm,{name:w,logoUrl:T}),(0,Q.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`settings-back`,title:`Back (Esc)`,onClick:i,className:W(`-mr-2 ml-auto shrink-0`,c?`h-11`:`h-[26px]`),children:[(0,Q.jsx)(no,{"aria-hidden":`true`,className:`size-4`}),`Back`]}),a?(0,Q.jsx)(`div`,{className:`shrink-0`,children:a}):null]}),(0,Q.jsxs)(`nav`,{"aria-label":`Settings sections`,"data-slot":`settings-nav`,"data-scope":e,className:`flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto overscroll-contain px-2.5 py-1.5`,children:[(0,Q.jsx)(yD,{children:`General settings`}),o.map(e=>{let n=h&&e.id===t;return(0,Q.jsxs)(br,{to:dD(`global`,e.id),"data-section":e.id,className:_D(n,c),children:[(0,Q.jsx)(e.icon,{"aria-hidden":`true`,className:`size-4 shrink-0`}),e.title]},e.id)}),(0,Q.jsx)(`p`,{className:`shrink-0 px-2.5 pt-1 pb-2 text-meta text-soft-foreground`,children:`Stored in ~/.cezar`}),r.projects.length>0?(0,Q.jsx)(`div`,{"data-slot":`settings-project-tree`,className:`mt-1 flex shrink-0 flex-col gap-0.5 border-t border-border pt-3`,children:r.flat&&g?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(yD,{children:g.id===l?`This project`:g.name}),g.status===`missing`?(0,Q.jsx)(SD,{project:g,indent:!1}):(0,Q.jsx)(bD,{project:g,sections:s,active:g.id===l,activeId:t,indent:!1})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(yD,{children:`Project settings`}),r.projects.map(n=>(0,Q.jsx)(CD,{project:n,sections:s,activeProjectId:r.activeProjectId,activeId:t,openSectionId:e===`project`?t:null,onProjectPage:e===`project`,expanded:p(n.id),onToggle:()=>m(n.id)},n.id))]})}):null,e===`project`?(0,Q.jsx)(aD,{}):null]}),(0,Q.jsxs)(`div`,{"data-slot":`settings-sidebar-footer`,className:`flex flex-col gap-1.5 border-t border-border px-3.5 py-2.5`,children:[(0,Q.jsx)(Up,{}),(0,Q.jsxs)(`div`,{"data-slot":`settings-sidebar-footer-controls`,className:`flex items-center gap-2`,children:[v?(0,Q.jsx)(jh,{version:v,latestVersion:y,brandName:w}):null,x===null?null:(0,Q.jsx)(Mh,{count:x}),(0,Q.jsx)(Gf,{className:`ml-auto`})]})]})]})})}function DD({scope:e,activeId:t,capabilities:n}){let r=ZE(n)[e],i=e===`global`?br:Tr,a=e=>W(`rounded-full border px-3 py-1.5 text-ui font-medium whitespace-nowrap transition-colors`,e?`border-transparent bg-contrast text-contrast-foreground`:`border-border bg-card text-muted-foreground`);return(0,Q.jsxs)(`nav`,{"aria-label":`Sections of this area`,"data-slot":`settings-nav-mobile`,className:`flex shrink-0 gap-1.5 overflow-x-auto border-b border-border px-3 py-2.5 md:hidden`,children:[e===`project`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(yr,{to:fD,"data-slot":`settings-all-pill`,className:a(!1),children:`‹ General settings`}),(0,Q.jsx)(i,{to:`/settings`,end:!0,"data-slot":`settings-nav-index`,className:a(!1),children:`General`})]}):null,r.map(n=>(0,Q.jsx)(i,{to:dD(e,n.id),"data-section":n.id,className:a(n.id===t),children:n.title},n.id))]})}function OD({title:e,projectName:t}){return(0,Q.jsx)(`div`,{"data-slot":`settings-mobile-bar`,className:`shrink-0 border-b border-border bg-card pt-[env(safe-area-inset-top)] md:hidden`,children:(0,Q.jsxs)(`div`,{className:`flex h-[52px] items-center gap-1 px-2`,children:[(0,Q.jsx)(Hi,{asChild:!0,children:(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Open settings menu`,className:`size-11`,children:(0,Q.jsx)(Ul,{"aria-hidden":`true`,className:`size-[17px]`})})}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(kD,{title:e,projectName:t,as:`span`})})]})})}function kD({title:e,projectName:t,as:n}){let r=n===`h1`?`text-base`:`text-body`;return(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[t?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"data-slot":`settings-scope-chip`,className:W(`truncate font-semibold text-muted-foreground`,r),children:t}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:W(`shrink-0 font-normal text-soft-foreground`,r),children:`/`})]}):null,(0,Q.jsx)(n,{className:W(`truncate font-semibold`,r),children:e})]})}function AD({scope:e,section:t,title:n,beside:r}){return(0,Q.jsxs)(`header`,{"data-slot":`settings-header`,className:`sticky top-0 z-10 hidden h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-5 md:flex`,children:[(0,Q.jsx)(kD,{title:n,projectName:r,as:`h1`}),t?(0,Q.jsx)(`p`,{className:`min-w-0 truncate text-ui text-soft-foreground`,children:t.description}):e===`project`?(0,Q.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:`Project settings`}):null]})}function jD({scope:e,section:t,capabilities:n,routeName:r,children:i}){let a=mD(n),o=hD(a.activeProjectId??a.bootProjectId);gD(o);let s=a.activeProject?.name??a.activeProjectId,c=t?.title??(e===`global`?`Settings`:s??`Settings`),l=e===`project`&&t!==null?s:null,[u,d]=Z.useState(!1),f={scope:e,activeId:t?.id??null,capabilities:n,tree:a,leave:o};return(0,Q.jsx)(Ui,{open:u,onOpenChange:d,children:(0,Q.jsxs)(`div`,{"data-route":r,className:`flex h-full min-h-full`,children:[(0,Q.jsx)(wD,{...f}),(0,Q.jsx)(TD,{...f,onOpenChange:d}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col overflow-y-auto overscroll-contain`,children:[(0,Q.jsx)(OD,{title:c,projectName:l}),(0,Q.jsx)(AD,{scope:e,section:t,title:c,beside:l}),t?(0,Q.jsx)(DD,{scope:e,activeId:t.id,capabilities:n}):null,(0,Q.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:i})]})]})})}function MD({section:e,scope:t,capabilities:n}){let r=e.component;return(0,Q.jsx)(jD,{scope:t,section:e,capabilities:n,routeName:t===`global`?`settings-global-${e.id}`:`settings-${e.id}`,children:(0,Q.jsx)(r,{})})}var ND=`flex items-center gap-3.5 rounded-lg border border-border bg-card p-4 shadow-xs transition-colors hover:bg-card-2`;function PD({section:e}){return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(K,{to:dD(`project`,e.id),"data-section":e.id,className:ND,children:[(0,Q.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-md border border-border bg-muted text-muted-foreground`,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)(Ks,{"aria-hidden":`true`,className:`size-4 shrink-0 text-soft-foreground`})]})})}function FD({scope:e,capabilities:t}){let n=jr(),r=ZE(t)[e];if(e===`global`){let e=r[0];return(0,Q.jsx)(Dr,{to:{pathname:dD(`global`,e.id),search:n.search,hash:n.hash},replace:!0})}return(0,Q.jsx)(jD,{scope:e,section:null,capabilities:t,routeName:`settings`,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col p-3 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-5 md:pb-5`,children:[(0,Q.jsx)(cD,{capabilities:t}),(0,Q.jsx)(`ul`,{"data-slot":`settings-index`,className:`mx-auto mt-7 flex w-full max-w-2xl flex-col gap-2.5 md:hidden`,children:r.map(e=>(0,Q.jsx)(PD,{section:e},e.id))})]})})}var ID={archive:`Archive`,restore:`Restore`,read:`Mark read`,unread:`Mark unread`};function LD(e,t){return t===`restore`?!!e.archived:t===`archive`?!e.archived&&Qo(e.status):Wo(e)&&$o(e)===(t===`read`)}function RD(e,t){let[n,r]=Z.useState(new Set),[i,a]=Z.useState(!1),[o,s]=Z.useState(``),c=Z.useRef(!1),l=e.filter(e=>n.has(e.id));return Z.useEffect(()=>{let t=new Set(e.map(e=>e.id));r(e=>{let n=new Set([...e].filter(e=>t.has(e)));return n.size===e.size?e:n})},[e]),{ids:n,selected:l,busy:i,message:o,toggle:Z.useCallback(e=>{c.current||r(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},[]),clear:()=>{c.current||r(new Set)},toggleAll:()=>{c.current||r(l.length===e.length?new Set:new Set(e.map(e=>e.id)))},apply:Z.useCallback(async(e,n)=>{if(c.current||!t)return;c.current=!0,a(!0),s(`${ID[e]} in progress…`);let i=n.filter(t=>LD(t,e)),o=new Set,l=[];for(let n of i)try{await t(n,e),o.add(n.id)}catch(e){l.push(`${Ve(n)}: ${e instanceof Error?e.message:`Request failed`}`)}r(e=>new Set([...e].filter(e=>!o.has(e)))),s(`${ID[e]}: ${o.size} succeeded, ${n.length-i.length} skipped, ${l.length} failed.${l.length?` ${l.join(`; `)}`:``}`),c.current=!1,a(!1)},[t])}}function zD({checked:e,mixed:t=!1,label:n,disabled:r,onChange:i}){let a=Z.useRef(null);return Z.useEffect(()=>{a.current&&(a.current.indeterminate=t)},[t]),(0,Q.jsx)(`input`,{ref:a,type:`checkbox`,"aria-label":n,checked:e,disabled:r,onChange:i,className:`size-4 shrink-0 cursor-pointer accent-primary focus-visible:outline-2 focus-visible:outline-ring`})}function BD({displayed:e,selection:t,archived:n}){let{selected:r,busy:i}=t,a=[n?`restore`:`archive`,`read`,`unread`];return(0,Q.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-md border border-border bg-card px-3 py-2 text-sm`,children:[(0,Q.jsx)(zD,{label:`Select displayed tasks`,checked:e.length>0&&r.length===e.length,mixed:r.length>0&&r.length<e.length,disabled:i||e.length===0,onChange:t.toggleAll}),(0,Q.jsx)(`span`,{children:r.length>0?`${r.length} selected`:`Select tasks`}),r.length>0?(0,Q.jsxs)(Q.Fragment,{children:[a.map(e=>{let n=r.filter(t=>LD(t,e)).length;return(0,Q.jsxs)(J,{type:`button`,size:`sm`,variant:`outline`,disabled:i||n===0,onClick:()=>void t.apply(e,r),children:[ID[e],` (`,n,`)`]},e)}),(0,Q.jsx)(J,{type:`button`,size:`sm`,variant:`ghost`,disabled:i,onClick:t.clear,children:`Clear selection`}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Only eligible selected tasks are changed; others are skipped.`})]}):null,(0,Q.jsx)(`p`,{role:`status`,"aria-label":`Task action status`,"aria-live":`polite`,className:`w-full empty:hidden text-xs text-muted-foreground`,children:t.message})]})}function VD({run:e,busy:t,onAction:n}){let r=[e.archived?`restore`:`archive`,$o(e)?`read`:`unread`],i={archive:wa,restore:pl,read:lc,unread:Tl};return(0,Q.jsx)(`span`,{className:`inline-flex shrink-0 items-center gap-1`,children:r.filter(t=>LD(e,t)).map(r=>{let a=i[r],o=`${ID[r]}: ${Ve(e)}`;return(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,title:o,"aria-label":o,disabled:t,onClick:()=>void n(r,[e]),children:(0,Q.jsx)(a,{className:`size-3.5`,"aria-hidden":`true`})},r)})})}function HD({label:e,expanded:t,onToggle:n,className:r,wordClassName:i}){let[a,...o]=e.split(` `);return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`subtask-toggle`,"aria-expanded":t,"aria-label":`${t?`Collapse`:`Expand`} ${e}`,onClick:n,className:W(`inline-flex shrink-0 items-center gap-0.5 rounded-full bg-muted py-px pr-1.5 pl-1 text-micro font-medium text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,r),children:[(0,Q.jsx)(Ks,{className:W(`size-3 transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),a,(0,Q.jsx)(`span`,{className:i,children:` ${o.join(` `)}`})]})}function UD({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`skeleton`,className:W(`animate-pulse rounded-md bg-accent`,e),...t})}var WD=[{id:`status`,label:`Status`,canFold:!1,defaultExpanded:!0,align:`left`,width:`116px`},{id:`task`,label:`Task`,canFold:!1,defaultExpanded:!0,align:`left`},{id:`workflow`,label:`Workflow`,canFold:!0,defaultExpanded:!0,align:`left`,width:`124px`,icon:`workflow`},{id:`branch`,label:`Branch`,canFold:!0,defaultExpanded:!1,align:`left`,width:`128px`,icon:`branch`},{id:`diff`,label:`±`,canFold:!0,defaultExpanded:!0,align:`left`,width:`78px`,icon:`diff`},{id:`reference`,label:`Ref`,canFold:!0,defaultExpanded:!0,align:`left`,width:`76px`,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:`76px`,icon:`cost`,capability:`cost`},{id:`cpu`,label:`CPU`,canFold:!0,defaultExpanded:!0,align:`right`,width:`68px`,icon:`cpu`},{id:`memory`,label:`Mem`,canFold:!0,defaultExpanded:!0,align:`right`,width:`88px`,icon:`memory`},{id:`started`,label:`Started`,canFold:!0,defaultExpanded:!0,align:`right`,width:`82px`,icon:`started`}],GD=new Map(WD.map(e=>[e.id,e]));function KD(e){return typeof e!=`object`||!e||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`boolean`))}function qD(e){let t={};for(let[n,r]of Object.entries(KD(e))){let e=GD.get(n);e?.canFold&&(t[e.id]=r)}return t}function JD(e,t){let n=GD.get(e);return!n||!n.canFold?!0:t[e]??n.defaultExpanded}function YD(e,t){let n=KD(e);return GD.get(t)?.canFold?{...n,[t]:!JD(t,qD(e))}:n}function XD(e){return WD.filter(t=>t.capability===void 0||e[t.capability])}function ZD(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function QD(){let e=U(),t=ht(),n=Z.useRef(0),r=Z.useRef(0),i=Z.useRef(Promise.resolve()),a=Z.useMemo(()=>qD(t.data?.taskTable?.expandedColumns),[t.data?.taskTable?.expandedColumns]),o=Z.useCallback(t=>{if(!WD.find(e=>e.id===t)?.canFold)return;let a=e.getQueryData(B.uiState);if(a===void 0)return;let o=ZD(a?.taskTable),s={...o,expandedColumns:YD(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 Pt({taskTable:s},{keepalive:!0});c===r.current&&e.setQueryData(B.uiState,t)});i.current=l.catch(t=>{Y(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=>JD(e,a),[a]),toggleColumn:o,isPending:t.isPending}}var $D=Z.createContext(null);function eO({intervalMs:e,now:t,children:n}){let r=Yr(e,t===void 0);return(0,Q.jsx)($D.Provider,{value:t??r,children:n})}function tO({at:e}){return(0,Q.jsx)(Q.Fragment,{children:Xc(e,Z.useContext($D)??Date.now())})}var nO=12,rO=40;function iO({height:e,colSpan:t}){return e<=0?null:(0,Q.jsx)(`tr`,{"data-row-spacer":``,"aria-hidden":`true`,children:(0,Q.jsx)(`td`,{colSpan:t,style:{height:e,padding:0,border:0}})})}function aO(e,t=45){let n=e>100,r=Z.useRef(null),[i,a]=Z.useState({start:0,end:rO,height:t});if(Z.useLayoutEffect(()=>{if(!n)return;let e=r.current;if(!e)return;let i=e.closest(`[data-slot="main"]`),o=()=>{let n=i?i.getBoundingClientRect().top:0,r=i?i.clientHeight:window.innerHeight,o=e.getBoundingClientRect().top-n,s=e.querySelector(`:scope > tr:not([data-row-spacer]):not([data-row-unsampled])`)?.getBoundingClientRect().height,c=s!==void 0&&s>0?s:t,l=Math.floor(Math.max(0,-o)/c),u=Math.ceil(Math.max(0,r-o)/c),d=Math.max(0,l-nO),f=Math.max(d,u+nO);a(e=>e.start===d&&e.end===f&&e.height===c?e:{start:d,end:f,height:c})};o();let s=0,c=()=>{s===0&&(s=requestAnimationFrame(()=>{s=0,o()}))},l=i??window;l.addEventListener(`scroll`,c,{passive:!0}),window.addEventListener(`resize`,o);let u=typeof ResizeObserver==`function`?new ResizeObserver(o):void 0;for(let e of i?Array.from(i.children):[document.body])u?.observe(e);return()=>{s!==0&&cancelAnimationFrame(s),l.removeEventListener(`scroll`,c),window.removeEventListener(`resize`,o),u?.disconnect()}},[n,e,t]),!n)return{anchorRef:r,windowed:n,start:0,end:e,padTop:0,padBottom:0,ariaRowCount:void 0,ariaRowIndex:oO};let o=Math.max(1,i.end-i.start),s=Math.max(0,Math.min(i.start,e-o)),c=Math.min(Math.max(i.end,s+o),e);return{anchorRef:r,windowed:n,start:s,end:c,padTop:s*i.height,padBottom:(e-c)*i.height,ariaRowCount:e+1,ariaRowIndex:sO}}var oO=()=>void 0,sO=e=>e+2,cO=[],lO=qD(void 0),uO=()=>void 0,dO=3e4;function fO({runs:e,view:t,onViewChange:n,onArchiveFinished:r,onMarkAllRead:i,onRename:a,onTogglePin:o,onTaskAction:s,now:c,showTokens:l=!0,showCost:u=!0,expandedColumns:d=lO,onToggleColumn:f=uO,columnsPending:p=!1,origin:m=`all`,onOriginChange:h=()=>void 0,automationNames:g,gitRepo:_=!0,scheduledTasks:v,hasScheduledTasks:y=!!v,firstRun:b,setupPill:x,welcomeBack:S}){let[C,w]=Z.useState(``),[T,E]=Z.useState(new Set),D=Z.useCallback(e=>E(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),[]),[k,j]=Z.useState(Lg),[M,N]=Z.useState(`recent`),P=e??cO,F=Z.useMemo(()=>P.some(e=>t===`archived`===e.archived),[P,t]),ee=Z.useMemo(()=>zg(P),[P]),te=Z.useMemo(()=>Vg(P,m,k,ee),[P,m,k,ee]),I=Z.useMemo(()=>Le(te),[te]),ne=Z.useMemo(()=>ot(te,C),[te,C]),L=Z.useMemo(()=>re(ne,t,M),[ne,t,M]),ie=C.trim()!==``,ae=Z.useCallback(e=>ie||T.has(e),[ie,T]),oe=Z.useMemo(()=>Ue(L,t).map(e=>({...e,rows:Jg(e.runs,ae),taskCount:Jg(e.runs,()=>!1).length})),[L,t,ae]),se=Z.useMemo(()=>oe.flatMap(e=>[...e.label?[{kind:`section`,section:e}]:[],...e.rows.map(e=>({kind:`row`,node:e}))]),[oe]),ce=Z.useMemo(()=>oe.flatMap(e=>e.rows.map(e=>e.run)),[oe]),le=RD(ce,s),R=Z.useMemo(()=>A(P),[P]),ue=Z.useMemo(()=>Bn(ne,t),[ne,t]),de=Z.useMemo(()=>Fn(P),[P]),fe=Z.useMemo(()=>XD({tokens:l,cost:u}).map(e=>e.id===`started`?{...e,label:fn(M)}:e),[l,u,M]),pe=Z.useMemo(()=>qo(P),[P]),z=aO(se.length),me=t===`archived`?void 0:o;return(0,Q.jsx)(eO,{intervalMs:dO,now:c,children:(0,Q.jsxs)(`div`,{"data-route":`tasks`,className:`flex min-h-full flex-col`,children:[(0,Q.jsxs)(`header`,{className:`sticky top-0 z-10 hidden h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-5 md:flex`,children:[(0,Q.jsx)(`h1`,{className:`text-base font-semibold`,children:`Tasks`}),(0,Q.jsxs)(`div`,{className:`inline-flex gap-0.5 rounded-md bg-muted p-[3px]`,children:[(0,Q.jsx)(gO,{view:`active`,current:t,onSelect:n,count:I.active,children:`Active`}),(0,Q.jsx)(gO,{view:`archived`,current:t,onSelect:n,count:I.archived,children:`Archived`})]}),(0,Q.jsx)(`div`,{className:`flex-1`}),pe>0?(0,Q.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`mark-all-read`,onClick:i,children:[(0,Q.jsx)(yi,{className:`size-3.5`,"aria-hidden":`true`}),`Mark all read`]}):null,t===`active`&&de>0?(0,Q.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`archive-finished`,onClick:r,children:[(0,Q.jsx)(wa,{className:`size-3.5`,"aria-hidden":`true`}),`Archive finished`]}):null,(0,Q.jsxs)(`div`,{className:`relative w-60`,children:[(0,Q.jsx)(Cc,{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:C,onChange:e=>w(e.target.value),placeholder:`Search tasks…`,"aria-label":`Search tasks`,className:`h-9 w-full rounded-md border border-input bg-card pr-3 pl-8 text-ui text-foreground outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`})]})]}),v,(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col p-3 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-5 md:pb-5`,children:[F?S:null,F?x:null,F?(0,Q.jsx)(hO,{runs:P,view:t,origin:m,onOriginChange:h,filters:k,onFiltersChange:j,automations:ee,automationNames:g,sortBy:M,onSortByChange:N}):null,s?(0,Q.jsx)(BD,{displayed:ce,selection:le,archived:t===`archived`}):null,e===void 0?null:y&&P.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No tasks have started yet.`}):L.length===0?(0,Q.jsx)(mO,{view:t,query:C,filtered:Rg(k)>0,onClearFilters:()=>j(Lg),origin:m,hiddenByOrigin:m!==`all`&&Vg(O(P,t),`all`,k,ee).length>0,onShowAll:()=>h(`all`),firstRun:b}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{"data-slot":`tasks-table`,className:`hidden overflow-x-auto rounded-lg border border-border bg-card shadow-xs md:block`,children:(0,Q.jsx)(kc,{children:(0,Q.jsxs)(`table`,{className:`w-full border-collapse`,"aria-rowcount":z.ariaRowCount,children:[(0,Q.jsxs)(`colgroup`,{children:[s?(0,Q.jsx)(`col`,{style:{width:`112px`}}):null,fe.map(e=>{let t=JD(e.id,d);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.jsxs)(`tr`,{"aria-rowindex":z.windowed?1:void 0,children:[s?(0,Q.jsx)(`th`,{scope:`col`,children:(0,Q.jsx)(`span`,{className:`sr-only`,children:`Task controls`})}):null,fe.map(e=>(0,Q.jsx)(vO,{column:e,expanded:JD(e.id,d),onToggle:f,disabled:p},e.id))]})}),(0,Q.jsxs)(`tbody`,{ref:z.anchorRef,className:`[&>tr:last-child>td]:border-b-0`,children:[(0,Q.jsx)(iO,{height:z.padTop,colSpan:fe.length+ +!!s}),se.slice(z.start,z.end).map((e,t)=>e.kind===`section`?(0,Q.jsx)(`tr`,{"data-slot":`tasks-section`,"data-section":e.section.key,"data-row-unsampled":``,"aria-rowindex":z.ariaRowIndex(z.start+t),children:(0,Q.jsxs)(`th`,{scope:`rowgroup`,colSpan:fe.length+ +!!s,className:W(bO,`border-b border-border bg-muted/40 px-3.5 py-1.5 text-left`),children:[e.section.label,` · `,e.section.taskCount]})},`section-${e.section.key}`):(0,Q.jsx)(SO,{ariaRowIndex:z.ariaRowIndex(z.start+t),gitRepo:_,run:e.node.run,depth:e.node.depth,childCount:e.node.childCount,subtasksExpanded:ae(e.node.run.id),onToggleSubtasks:D,queuePosition:e.node.run.status===`queued`?R.get(e.node.run.id)??null:null,onRename:a,onTogglePin:me,selectable:!!s,selected:le.ids.has(e.node.run.id),onSelect:le.toggle,actionsBusy:le.busy,onAction:le.apply,sortBy:M,columns:fe,expandedColumns:d},e.node.run.id)),(0,Q.jsx)(iO,{height:z.padBottom,colSpan:fe.length+ +!!s})]})]})})}),(0,Q.jsx)(pO,{cards:se.map(e=>e.kind===`section`?(0,Q.jsxs)(`h2`,{"data-slot":`tasks-section`,"data-section":e.section.key,className:W(bO,`px-1 pt-1`),children:[e.section.label,` · `,e.section.taskCount]},`section-${e.section.key}`):(0,Q.jsx)(OO,{run:e.node.run,depth:e.node.depth,childCount:e.node.childCount,subtasksExpanded:ae(e.node.run.id),onToggleSubtasks:D,queuePosition:e.node.run.status===`queued`?R.get(e.node.run.id)??null:null,sortBy:M,showTokens:l,showCost:u,onTogglePin:me,selectable:!!s,selected:le.ids.has(e.node.run.id),onSelect:le.toggle,actionsBusy:le.busy,onAction:le.apply,gitRepo:_},e.node.run.id))})]}),ue.map(e=>(0,Q.jsxs)(`div`,{"data-slot":`compare-strip`,"data-group-id":e.groupId,className:`mt-3.5 flex flex-wrap items-center gap-2.5 rounded-lg border border-border bg-card px-3.5 py-2.5 text-label text-muted-foreground shadow-xs`,children:[(0,Q.jsx)(eu,{className:`size-[15px] shrink-0 text-soft-foreground`,"aria-hidden":`true`}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e.title}),` — `,e.count,` variants finished`]}),(0,Q.jsx)(J,{asChild:!0,variant:`outline`,size:`sm`,className:`md:ml-auto`,children:(0,Q.jsx)(K,{to:`/compare/${e.groupId}`,children:`Compare`})})]},e.groupId))]}),(0,Q.jsx)(K,{to:`/new`,"data-slot":`new-task-fab`,"aria-label":`New task`,className:`fixed right-4 bottom-[calc(16px+env(safe-area-inset-bottom))] z-20 inline-flex size-14 items-center justify-center rounded-full bg-primary text-primary-foreground shadow-modal md:hidden`,children:(0,Q.jsx)(xc,{className:`size-[22px]`,"aria-hidden":`true`})})]})})}function pO({cards:e}){let t=e.length>100,n=Z.useRef(null),r=Z.useRef(null),[i,a]=Z.useState(0);return Z.useLayoutEffect(()=>{if(!t)return;let e=()=>{let e=n.current,t=r.current;!e||!t||a(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[t]),(0,Q.jsx)(`div`,{ref:e=>{n.current=e,e&&(r.current=e.closest(`[data-slot="main"]`))},"data-slot":`task-cards`,"data-virtualized":t,className:W(`flex flex-col md:hidden`,t?null:`gap-2.5`),children:t?(0,Q.jsx)($c,{scrollRef:r,startMargin:i,children:e.map(e=>(0,Q.jsx)(`div`,{className:`pb-2.5`,children:e},e.key))}):e})}function mO({view:e,query:t,filtered:n=!1,onClearFilters:r=()=>void 0,origin:i=`all`,hiddenByOrigin:a=!1,onShowAll:o=()=>void 0,firstRun:s}){let c=t.trim(),l=c?`search-miss`:n?`filtered`:a?`origin-hidden`:e===`archived`?`archive`:`no-tasks`;return(0,Q.jsx)(`div`,{"data-slot":`tasks-empty`,"data-empty-kind":l,className:`flex flex-1 flex-col`,children:l===`filtered`?(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(Sc,{}),tone:`neutral`,title:`No tasks match these filters`,actions:(0,Q.jsx)(J,{type:`button`,variant:`outline`,onClick:r,children:`Clear filters`})}):l===`origin-hidden`?(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(mc,{}),tone:`neutral`,title:i===`regular`?`No regular tasks here`:`No automation tasks here`,subtitle:i===`regular`?`Tasks started by automations are hidden.`:`Only tasks started by automations are shown.`,actions:(0,Q.jsx)(J,{type:`button`,variant:`outline`,onClick:o,children:`Show all tasks`})}):l===`search-miss`?(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(Sc,{}),tone:`neutral`,title:`No matching tasks`,subtitle:`No tasks match “${c}”.`}):l===`archive`?(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(wa,{}),tone:`neutral`,title:`Nothing archived yet`,subtitle:`Finished tasks you archive land here.`}):s||(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(Bl,{}),tone:`primary`,backdrop:!0,title:`No tasks yet`,subtitle:`Describe a task to get started.`,actions:(0,Q.jsx)(J,{asChild:!0,children:(0,Q.jsxs)(K,{to:`/new`,children:[(0,Q.jsx)(xc,{"aria-hidden":`true`}),`New task`]})})})})}function hO({runs:e,view:t,origin:n,onOriginChange:r,filters:i,onFiltersChange:a,automations:o,automationNames:s,sortBy:c,onSortByChange:l}){let u=Z.useMemo(()=>e.filter(e=>t===`archived`?e.archived:!e.archived),[e,t]),d=Wg(u,i,o),f=e=>Ug(u,n,i,o,e),p=f(`statuses`),m=f(`workflows`),h=f(`automations`),g=Gg(u.map(e=>o.get(e.id))),_=(e,t)=>a(n=>({...n,[e]:n[e].includes(t)?n[e].filter(e=>e!==t):[...n[e],t]})),v=e=>a(t=>({...t,[e]:[]})),y=Rg(i);return(0,Q.jsxs)(`div`,{"data-slot":`tasks-filters`,className:`mb-3 flex flex-wrap items-center gap-1.5`,children:[(0,Q.jsx)(_i,{slot:`task-origin`,label:`Show tasks started by`,value:n,options:Zf.map(e=>({...e,count:d[e.value]})),onChange:r}),(0,Q.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`,"aria-hidden":`true`}),(0,Q.jsx)(Ti,{slot:`status`,label:`Status`,selected:i.statuses,onToggle:e=>_(`statuses`,e),onClear:()=>v(`statuses`),options:Gg(u.map(e=>e.status)).map(e=>({value:e,label:e,count:p.get(e)??0})),emptyLabel:`No tasks to filter`}),(0,Q.jsx)(Ti,{slot:`workflow`,label:`Workflow`,selected:i.workflows,onToggle:e=>_(`workflows`,e),onClear:()=>v(`workflows`),options:Gg(u.map(e=>he(e))).map(e=>({value:e,label:e,count:m.get(e)??0})),emptyLabel:`No tasks to filter`}),n!==`regular`&&g.length>0?(0,Q.jsx)(Ti,{slot:`automation`,label:`Automation`,selected:i.automations,onToggle:e=>_(`automations`,e),onClear:()=>v(`automations`),options:g.map(e=>({value:e,label:s?.get(e)??e,count:h.get(e)??0})),emptyLabel:`No automation tasks`}):null,y>0?(0,Q.jsxs)(`button`,{type:`button`,"data-action":`clear-filters`,onClick:()=>a(()=>Lg),className:`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)(Tc,{className:`size-3`,"aria-hidden":`true`}),`Clear (`,y,`)`]}):null,(0,Q.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`text-meta font-medium text-soft-foreground`,children:`Sort by`}),(0,Q.jsx)(_i,{slot:`sort-by`,label:`Sort tasks by`,value:c,options:w,onChange:l})]})}function gO({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:W(`flex h-7 items-center justify-center gap-1.5 rounded-[7px] px-3 text-label font-medium text-muted-foreground`,a&&`bg-card font-semibold text-foreground shadow-xs`),children:[i,r>0?(0,Q.jsx)(`span`,{className:`font-mono text-meta tabular-nums`,children:r}):null]})}function _O({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:W(`h-[38px] border-b border-border px-2.5 text-left eyebrow whitespace-nowrap text-soft-foreground first:pl-4 last:pr-4`,t&&`text-right`,r&&`px-0 first:pl-0 last:pr-0`),children:e})}function vO({column:e,expanded:t,onToggle:n,disabled:r}){if(!e.canFold)return(0,Q.jsx)(_O,{columnId:e.id,right:e.align===`right`,children:e.label});let i=t?`Fold`:`Expand`;return(0,Q.jsx)(_O,{columnId:e.id,right:e.align===`right`,folded:!t,children:(0,Q.jsxs)(Ac,{children:[(0,Q.jsx)(Dc,{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:W(`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)(yl,{className:`size-3 opacity-55`,"aria-hidden":`true`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(yO,{icon:e.icon}),(0,Q.jsx)(bl,{className:`size-3 opacity-70`,"aria-hidden":`true`})]})})}),(0,Q.jsxs)(Oc,{side:`top`,children:[e.label,` · `,i,` column`]})]})})}function yO({icon:e}){let t=`size-3.5`;switch(e){case`workflow`:return(0,Q.jsx)(mc,{className:t,"aria-hidden":`true`});case`branch`:return(0,Q.jsx)(cc,{className:t,"aria-hidden":`true`});case`diff`:return(0,Q.jsx)(oc,{className:t,"aria-hidden":`true`});case`reference`:return(0,Q.jsx)(Ta,{className:t,"aria-hidden":`true`});case`tokens`:return(0,Q.jsx)(Sl,{className:t,"aria-hidden":`true`});case`cost`:return(0,Q.jsx)(si,{className:t,"aria-hidden":`true`});case`cpu`:return(0,Q.jsx)(_s,{className:t,"aria-hidden":`true`});case`memory`:return(0,Q.jsx)(Hl,{className:t,"aria-hidden":`true`});case`started`:return(0,Q.jsx)(xl,{className:t,"aria-hidden":`true`});default:return null}}var bO=`eyebrow text-soft-foreground`,xO=`h-11 border-b border-border px-2.5 whitespace-nowrap first:pl-4 last:pr-4`,SO=Z.memo(function({ariaRowIndex:e,gitRepo:t,run:n,depth:r,childCount:i,subtasksExpanded:a,onToggleSubtasks:s,queuePosition:c,onRename:l,onTogglePin:u,sortBy:d,columns:f,expandedColumns:p,selectable:m,selected:h,onSelect:g,actionsBusy:_,onAction:v}){let y=vr(),x=o(n),S=b(n),C=`/tasks/${n.id}`,w=we(n.costUsd),T=zt(n);return(0,Q.jsxs)(`tr`,{"data-slot":`task-table-row`,"data-run-id":n.id,"aria-rowindex":e,"data-depth":r,onClick:e=>{e.target.closest(`a, button, input`)||y(C)},className:`group/row cursor-pointer hover:bg-muted`,children:[m?(0,Q.jsx)(`td`,{className:`border-b border-border px-2`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(zD,{label:`Select ${Ve(n)}`,checked:h,disabled:_,onChange:()=>g(n.id)}),(0,Q.jsx)(VD,{run:n,busy:_,onAction:v})]})}):null,f.map(e=>{if(e.id===`memory`)return null;if(e.id===`cpu`){let t=JD(`cpu`,p),r=JD(`memory`,p);return c!==null&&(t||r)?(0,Q.jsxs)(`td`,{"data-slot":`queue-note`,"data-column-id":`cpu-memory`,colSpan:2,className:W(xO,`text-right font-mono text-meta text-soft-foreground`),children:[`#`,c,` in queue`]},e.id):(0,Q.jsx)(EO,{run:n,cpuExpanded:t,memoryExpanded:r},e.id)}return(0,Q.jsx)(CO,{gitRepo:t,column:e,expanded:JD(e.id,p),run:n,depth:r,childCount:i,subtasksExpanded:a,onToggleSubtasks:s,attention:x,scheduled:S,reference:T,cost:w,to:C,onRename:l,onTogglePin:u,sortBy:d},e.id)})]})});function CO({gitRepo:e,column:t,expanded:n,run:r,depth:i,childCount:a,subtasksExpanded:o,onToggleSubtasks:s,attention:c,scheduled:l,reference:u,cost:d,to:f,onRename:p,onTogglePin:m,sortBy:h}){if(!n)return(0,Q.jsx)(wO,{column:t.id});switch(t.id){case`status`:return(0,Q.jsx)(`td`,{"data-column-id":t.id,className:xO,children:(0,Q.jsxs)(Nc,{dot:c.tone,pulse:c.pulse,title:l?.title,children:[c.label,l?(0,Q.jsx)(`span`,{className:`tabular-nums`,children:l.label}):null]})});case`task`:return(0,Q.jsx)(`td`,{"data-column-id":t.id,className:W(xO,`max-w-0`),style:{minWidth:`${fe(i)}px`},children:(0,Q.jsx)(TO,{run:r,depth:i,childCount:a,subtasksExpanded:o,onToggleSubtasks:s,to:f,onRename:p,onTogglePin:m})});case`workflow`:return(0,Q.jsx)(`td`,{"data-column-id":t.id,className:W(xO,`text-label text-muted-foreground`),children:he(r)});case`branch`:return(0,Q.jsx)(`td`,{"data-column-id":t.id,className:xO,children:r.branch?(0,Q.jsx)(jO,{branch:r.branch}):MO(r,e)?(0,Q.jsx)(NO,{}):(0,Q.jsx)(kO,{})});case`diff`:return(0,Q.jsx)(`td`,{"data-column-id":t.id,className:xO,children:r.diffStat?(0,Q.jsx)(Zc,{stat:r.diffStat}):(0,Q.jsx)(kO,{})});case`reference`:return(0,Q.jsx)(`td`,{"data-column-id":t.id,className:xO,children:u?(0,Q.jsx)(Ca,{run:r,reference:u}):(0,Q.jsx)(kO,{})});case`tokens`:return(0,Q.jsx)(`td`,{"data-column-id":t.id,className:W(xO,`text-right text-xs text-muted-foreground`),children:(0,Q.jsx)(Mc,{inputTokens:r.inputTokens,outputTokens:r.outputTokens,variant:`table`,omitWhenUnknown:!1})});case`cost`:return(0,Q.jsx)(`td`,{"data-column-id":t.id,className:W(xO,`text-right font-mono text-xs text-muted-foreground tabular-nums`),children:d||(0,Q.jsx)(kO,{})});case`started`:return(0,Q.jsx)(`td`,{"data-column-id":t.id,className:W(xO,`text-right text-xs text-soft-foreground tabular-nums`),children:(0,Q.jsx)(tO,{at:I(r,h)})});case`cpu`:case`memory`:return null}}function wO({column:e}){return(0,Q.jsx)(`td`,{role:`presentation`,"aria-hidden":`true`,"data-column-id":e,"data-folded":`true`,className:W(xO,`px-0 first:pl-0 last:pr-0`)})}function TO({run:e,depth:t,childCount:n,subtasksExpanded:r,onToggleSubtasks:i,to:a,onRename:o,onTogglePin:s}){let c=Ve(e),l=Ha(c,t=>o(e.id,t)),u=$o(e),d=Zo(e),f=Yg(n),p=t>0?{paddingLeft:`${t*14}px`}:void 0;return l.editing?(0,Q.jsx)(`span`,{className:`flex min-w-0 items-center`,style:p,children:(0,Q.jsx)(Ga,{editor:l,className:`text-ui font-medium`})}):(0,Q.jsxs)(`span`,{className:`@container flex min-w-0 items-center gap-1.5`,style:p,children:[t>0?(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`subtask-tick`,className:`shrink-0 font-mono text-meta leading-none text-soft-foreground`,children:`└`}):null,(0,Q.jsxs)(K,{to:a,title:c,className:W(`min-w-0 truncate text-ui`,u?`font-semibold text-foreground`:d?`font-medium text-muted-foreground`:`font-medium`),children:[c,u?(0,Q.jsx)(Ig,{}):null]}),Xg(e)?(0,Q.jsx)(`span`,{"data-slot":`dispatch-kind`,className:`shrink-0 rounded-full bg-muted px-1.5 py-px text-micro font-medium text-muted-foreground @max-[300px]:hidden`,children:Xg(e)}):null,f?(0,Q.jsx)(HD,{label:f,expanded:r,onToggle:()=>i(e.id),wordClassName:`@max-[260px]:hidden`}):null,(0,Q.jsxs)(`span`,{"data-slot":`row-actions`,className:W(`flex shrink-0 items-center gap-1.5`,!e.pinned&&`-ml-1.5 w-0 overflow-hidden group-hover/row:ml-0 group-hover/row:w-auto group-hover/row:overflow-visible group-focus-within/row:ml-0 group-focus-within/row:w-auto group-focus-within/row:overflow-visible no-hover:ml-0 no-hover:w-auto no-hover:overflow-visible`),children:[(0,Q.jsx)(`button`,{type:`button`,"data-slot":`row-rename`,"aria-label":`Rename task`,onClick:l.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)(rc,{className:`size-3`,"aria-hidden":`true`})}),s?(0,Q.jsx)(La,{pinned:!!e.pinned,onToggle:t=>s(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 EO({run:e,cpuExpanded:t,memoryExpanded:n}){let r=R(e,ai(e.id));return(0,Q.jsxs)(Q.Fragment,{children:[t?(0,Q.jsx)(DO,{column:`cpu`,cell:r.cpu}):(0,Q.jsx)(wO,{column:`cpu`}),n?(0,Q.jsx)(DO,{column:`memory`,cell:r.mem}):(0,Q.jsx)(wO,{column:`memory`})]})}function DO({column:e,cell:t}){return(0,Q.jsx)(`td`,{"data-usage":e===`memory`?`mem`:e,"data-column-id":e,"data-usage-kind":t.kind,title:t.title,className:W(xO,`text-right font-mono tabular-nums`,t.kind===`live`&&`bg-violet/5 text-xs font-medium text-foreground`,t.kind===`peak`&&`text-meta text-soft-foreground`,t.kind===`none`&&`text-xs text-soft-foreground`),children:t.text||`—`})}var OO=Z.memo(function({run:e,depth:t,childCount:n,subtasksExpanded:r,onToggleSubtasks:i,queuePosition:a,sortBy:s,showTokens:c,showCost:l,onTogglePin:u,gitRepo:d,selectable:f,selected:p,onSelect:m,actionsBusy:h,onAction:g}){let _=vr(),v=o(e),y=b(e),x=`/tasks/${e.id}`,S=zt(e),C=$o(e),w=Zo(e),T=we(e.costUsd),E=Yg(n),D=e.inputTokens!==void 0||e.outputTokens!==void 0;return(0,Q.jsxs)(`div`,{"data-slot":`task-card`,"data-run-id":e.id,"data-depth":t,style:t>0?{marginLeft:`${t*14}px`}:void 0,onClick:e=>{e.target.closest(`a, button, input`)||_(x)},className:`cursor-pointer rounded-lg border border-border bg-card px-3.5 py-3 shadow-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[f?(0,Q.jsx)(zD,{label:`Select ${Ve(e)}`,checked:p,disabled:h,onChange:()=>m(e.id)}):null,(0,Q.jsxs)(Nc,{dot:v.tone,pulse:v.pulse,className:`mt-px shrink-0`,title:y?.title,children:[v.label,y?(0,Q.jsx)(`span`,{className:`tabular-nums`,children:y.label}):null]}),(0,Q.jsxs)(K,{to:x,className:W(`min-w-0 flex-1 text-ui leading-[1.35]`,C?`font-semibold text-foreground`:w?`font-medium text-muted-foreground`:`font-medium`),children:[Ve(e),C?(0,Q.jsx)(Ig,{}):null]}),Xg(e)?(0,Q.jsx)(`span`,{"data-slot":`dispatch-kind`,className:`mt-px shrink-0 rounded-full bg-muted px-1.5 py-px text-micro font-medium text-muted-foreground`,children:Xg(e)}):null,E?(0,Q.jsx)(HD,{label:E,expanded:r,onToggle:()=>i(e.id),className:`mt-px`}):null,(0,Q.jsx)(`span`,{className:`mt-0.5 shrink-0 text-meta text-soft-foreground tabular-nums`,children:(0,Q.jsx)(tO,{at:I(e,s)})}),u?(0,Q.jsx)(La,{pinned:!!e.pinned,onToggle:t=>u(e,t),className:`-mr-1 mt-px`}):null]}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 font-mono text-meta font-medium text-muted-foreground tabular-nums`,children:[(0,Q.jsx)(`span`,{children:he(e)}),a===null?(0,Q.jsxs)(Q.Fragment,{children:[e.branch?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(AO,{}),(0,Q.jsx)(`span`,{children:e.branch})]}):MO(e,d)?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(AO,{}),(0,Q.jsx)(NO,{})]}):null,e.diffStat?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(AO,{}),(0,Q.jsx)(Zc,{stat:e.diffStat,className:`text-meta`})]}):null,c&&D?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(AO,{}),(0,Q.jsx)(Mc,{inputTokens:e.inputTokens,outputTokens:e.outputTokens})]}):null,l&&T?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(AO,{}),(0,Q.jsx)(`span`,{children:T})]}):null]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(AO,{}),(0,Q.jsxs)(`span`,{"data-slot":`queue-note`,children:[`#`,a,` in queue`]})]}),S?(0,Q.jsx)(Ca,{run:e,reference:S,className:`h-5`}):null,f?(0,Q.jsx)(VD,{run:e,busy:h,onAction:g}):null]})]})});function kO(){return(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`})}function AO(){return(0,Q.jsx)(`span`,{className:`text-soft-foreground`,"aria-hidden":`true`,children:`·`})}function jO({branch:e}){return(0,Q.jsx)(`span`,{className:`rounded-[6px] bg-muted px-1.5 py-0.5 font-mono text-meta font-medium text-muted-foreground`,children:e})}function MO(e,t){return t&&e.status===`running`&&!e.branch&&e.worktree!==!1}function NO(){return(0,Q.jsx)(UD,{"data-slot":`branch-skeleton`,role:`status`,"aria-label":`naming branch`,className:`inline-block h-4 w-24 align-middle`})}function PO(){let e=P(),t=Yc(C().data),n=ln(),r=!n.data||n.data.info!==null,[i,a]=sg(),o=U(),s=$n(),c=Z.useCallback(async(e,t)=>{let n=t===`archive`||t===`restore`?await Hn(s,e.id,t===`archive`,`tasks_table`):await Bt(s,e.id,t===`read`);$n()===s?qt(o,n):o.invalidateQueries({queryKey:B.runsIndex}),o.invalidateQueries({queryKey:[s,`runs`]})},[s,o]),l=H({mutationFn:On,onSuccess:()=>o.invalidateQueries({queryKey:V.runs.all})}),u=H({mutationFn:me,onSuccess:()=>o.invalidateQueries({queryKey:V.runs.all}),onError:e=>Y(e.message,{tone:`danger`})}),d=H({mutationFn:({id:e,title:t})=>Me(e,{title:t}),onSuccess:e=>{qt(o,e),o.invalidateQueries({queryKey:V.runs.all})},onError:e=>Y(e.message,{tone:`danger`})}),f=un(`tasks_table`),p=d.mutate,m=Z.useCallback((e,t)=>p({id:e,title:t}),[p]),h=f.mutate,g=Z.useCallback((e,t)=>h({id:e.id,pinned:t},{onError:e=>Y(e.message,{tone:`danger`})}),[h]),_=QD(),[v,y]=lp(),b=mi(),x=Pg(),S=Z.useMemo(()=>(e.data??[]).some(e=>e.automation??e.automationTrigger??e.automationTracker),[e.data]),w=bi(b.known&&!b.off&&(S&&v!==`regular`||x&&i===`active`)),T=Z.useMemo(()=>new Map((w.data?.automations??[]).map(e=>[e.id,e.name])),[w.data]),E=Lt();return(0,Q.jsx)(Ur,{projectId:E,requests:Z.useMemo(()=>E===void 0?[]:(e.data??[]).flatMap(e=>ce(e).map(e=>({projectId:E,kind:e.kind,number:e.number}))),[e.data,E]),children:(0,Q.jsx)(fO,{scheduledTasks:i===`active`?(0,Q.jsx)(Dg,{enabled:x}):void 0,hasScheduledTasks:i===`active`&&!!w.data?.automations.some(e=>e.deferredStart),runs:e.data,view:i,onViewChange:a,onArchiveFinished:()=>l.mutate(),onMarkAllRead:()=>u.mutate(),onRename:m,onTogglePin:g,onTaskAction:c,showTokens:t.tokens,showCost:t.cost,expandedColumns:_.expandedColumns,onToggleColumn:_.toggleColumn,columnsPending:_.isPending,origin:v,onOriginChange:y,gitRepo:r,automationNames:T,firstRun:i===`active`?(0,Q.jsx)(iy,{gitRepo:n.data?n.data.info!==null:n.isError?!0:void 0}):void 0,setupPill:i===`active`?(0,Q.jsx)(Fy,{}):void 0,welcomeBack:i===`active`?(0,Q.jsx)(Zy,{runs:e.data??cO}):void 0})})}var FO=[],IO=` untagged`,LO=[{value:`project`,label:`Project`},{value:`tag`,label:`Tag`},{value:`status`,label:`Status`},{value:`workflow`,label:`Workflow`}];function RO(e,t){return e===t?`none`:t}function zO(e,t){return[...e].sort((e,n)=>oe(I(e.run,t),I(n.run,t)))}var BO={query:``,tags:[],statuses:[],workflows:[]};function VO(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function HO(e){return e.tags.length+e.statuses.length+e.workflows.length}function UO(e){return e.query.trim()!==``||HO(e)>0}function WO(e){return HO(e.filters)+(e.filters.query.trim()===``?0:1)+(e.groupBy===`none`?0:1)}function GO(e){return WO(e)>0}function KO(e,t){let n=new Map(t.map(e=>[e.id,e]));return e.map(e=>{let t=n.get(e.projectId);return{run:e,project:t,projectName:t?.name||e.projectId,tags:t?.tags??FO}})}var qO=e=>`${e.projectId}/${e.id}`;function JO(e){let t=new Map(e.map(e=>[qO(e.run),e.run]));return new Map(e.map(e=>[qO(e.run),ep(e.run,n=>t.get(`${e.run.projectId}/${n}`))]))}function YO(e,t,n){return e.filter(e=>tp(n.get(qO(e.run)),t))}function XO(e){let t=new Set;for(let n of e)t.add(n.run.workflow);return[...t].sort((e,t)=>e.localeCompare(t))}function ZO(e){let t=new Set;for(let n of e)t.add(n.run.status);return[...t].sort((e,t)=>e.localeCompare(t))}function QO(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 $O=e=>e.tags.length===0?[IO]:e.tags,ek=(e,t)=>e.length===0||t.some(t=>e.includes(t)),tk=(e,t)=>{if(t.length===0)return!0;let n=$O(e).map(e=>e.toLowerCase());return t.some(e=>n.includes(e.toLowerCase()))};function nk(e){return[Ve(e.run),e.projectName,e.run.workflow,e.run.branch??``,...e.tags].join(`
|
|
31
|
-
`).toLowerCase()}function rk(e,t,n){let r=t.query.trim().toLowerCase().split(/\s+/).filter(Boolean);return e.filter(e=>{if((n===`archived`?!e.run.archived:e.run.archived)||!ek(t.statuses,[e.run.status])||!ek(t.workflows,[e.run.workflow])||!tk(e,t.tags))return!1;if(r.length===0)return!0;let i=nk(e);return r.every(e=>i.includes(e))})}function ik(e,t,n,r){return rk(e,{...t,[r]:[]},n)}function ak(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(IO,`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 ok(e,t){let n=new Map(t.map(e=>[e.id,e.name]));return e.map(e=>n.get(e)||e)}var sk={query:`q`,tag:`tag`,untagged:`untagged`,status:`status`,workflow:`workflow`,groupBy:`group`,sort:`sort`,archived:`archived`},ck=new Set(LO.map(e=>e.value));function lk(e){let t=new URLSearchParams,n=e.filters.query.trim();n!==``&&t.set(sk.query,n);for(let n of e.filters.tags)n===` untagged`?t.set(sk.untagged,`1`):t.append(sk.tag,n);for(let n of e.filters.statuses)t.append(sk.status,n);for(let n of e.filters.workflows)t.append(sk.workflow,n);return e.groupBy!==`none`&&t.set(sk.groupBy,e.groupBy),e.sortBy!==`recent`&&t.set(sk.sort,e.sortBy),e.view===`archived`&&t.set(sk.archived,`1`),t}function uk(e){let t=e.getAll(sk.tag).filter(e=>e!==``);e.get(sk.untagged)===`1`&&t.push(IO);let n=e.get(sk.groupBy)??``;return{filters:{query:e.get(sk.query)??``,tags:t,statuses:e.getAll(sk.status).filter(e=>e!==``),workflows:e.getAll(sk.workflow).filter(e=>e!==``)},groupBy:ck.has(n)?n:`none`,sortBy:e.get(sk.sort)===`created`?`created`:`recent`,view:e.get(sk.archived)===`1`?`archived`:`active`}}var dk=15e3,fk=e=>e?.runs.some(e=>e.usage!==void 0)?dk:!1,pk=3e4,mk=250,hk=1,gk=new Set([`done`,`failed`,`cancelled`]);function _k(){return yk({request:({task:e,archived:t})=>Hn(e.run.projectId,e.run.id,t,`all_tasks`),patch:({archived:e})=>t=>({...t,archived:e})})}function vk(){return yk({request:({task:e,read:t})=>Bt(e.run.projectId,e.run.id,t),patch:({read:e})=>t=>{if(e)return{...t,seenAt:new Date().toISOString()};let{seenAt:n,...r}=t;return r}})}function yk({request:e,patch:t}){let n=U();return H({mutationFn:e,onMutate:async e=>{await n.cancelQueries({queryKey:B.runsIndex});let r=n.getQueryData(B.runsIndex),i=t(e),{task:a}=e;return n.setQueryData(B.runsIndex,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.projectId===a.run.projectId&&e.id===a.run.id?i(e):e)}),{previous:r}},onError:(e,t,r)=>{r?.previous&&n.setQueryData(B.runsIndex,r.previous),Y(e.message,{tone:`danger`})},onSettled:(e,t,{task:r})=>{n.invalidateQueries({queryKey:B.runsIndex}),n.invalidateQueries({queryKey:V.runs.all}),n.invalidateQueries({queryKey:[r.run.projectId,`runs`,`list`]})}})}function bk(){let e=a(),t=Yc(C().data),n=Se(!0,fk),[r,i]=hr(),{filters:o,groupBy:s,sortBy:c,view:l}=Z.useMemo(()=>uk(r),[r]),[u,d]=sg();Z.useEffect(()=>{u!==l&&d(l)},[l,u,d]);let f=e=>i(t=>lk(e(uk(t))),{replace:!0}),p=e=>f(t=>({...t,filters:e(t.filters)})),m=e=>f(t=>({...t,groupBy:e})),h=e=>f(t=>({...t,sortBy:e})),g=e=>f(t=>({...t,view:e})),[_,v]=Z.useState(o.query),[y,b]=Z.useState(new Set),x=Z.useCallback(e=>b(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),[]),S=o.query.trim()!==``,w=Z.useCallback(e=>S||y.has(e),[S,y]),T=Z.useRef(o.query);Z.useEffect(()=>{o.query!==T.current&&v(o.query),T.current=o.query},[o.query]),Z.useEffect(()=>{if(_===T.current)return;let e=setTimeout(()=>{T.current=_,p(e=>({...e,query:_}))},mk);return()=>clearTimeout(e)},[_]);let E=n.data?.referenceStatuses;Z.useEffect(()=>{E&&Nt(E)},[E]);let D=Z.useMemo(()=>e.data?.projects??[],[e.data]),O=Z.useMemo(()=>KO(n.data?.runs??[],D),[n.data,D]),[k,A]=lp(),j=Z.useMemo(()=>JO(O),[O]),M=Z.useMemo(()=>YO(O,k,j),[O,k,j]),N=Z.useMemo(()=>{let e=e=>rk(YO(O,e,j),o,l).length;return{regular:e(`regular`),automation:e(`automation`),all:e(`all`)}},[O,j,o,l]),P=Z.useMemo(()=>zO(rk(M,o,l),c),[M,o,l,c]),F=Z.useMemo(()=>ak(P,s),[P,s]),ee=Z.useMemo(()=>P.flatMap(e=>ce(e.run,e.project?.repoUrl).map(t=>({projectId:e.run.projectId,kind:t.kind,number:t.number}))),[P]),te=ok(n.data?.truncated??[],D),I=(e,t)=>p(n=>({...n,[e]:VO(n[e],t)})),ne=e=>p(t=>({...t,[e]:[]})),L=_k(),re=vk(),ie=L.mutate,ae=Z.useCallback((e,t)=>ie({task:e,archived:t}),[ie]),oe=re.mutate,se=Z.useCallback((e,t)=>oe({task:e,read:t}),[oe]);if(n.isError||e.isError)return(0,Q.jsx)(`div`,{"data-route":`global-tasks`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(ys,{}),tone:`danger`,title:`Tasks across projects did not load`,subtitle:(n.error??e.error)?.message})});let le=(0,Q.jsxs)(`div`,{className:`relative w-full md:w-60`,children:[(0,Q.jsx)(Cc,{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:_,onChange:e=>v(e.target.value),placeholder:`Search every project…`,"aria-label":`Search tasks across projects`,className:`h-9 w-full rounded-md border border-input bg-card pr-3 pl-8 text-ui 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`,className:`flex min-h-full flex-col`,children:[(0,Q.jsxs)(`header`,{className:`sticky top-0 z-10 hidden h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-5 md:flex`,children:[(0,Q.jsx)(`h1`,{className:`text-base font-semibold`,children:`All tasks`}),(0,Q.jsxs)(`div`,{className:`inline-flex gap-0.5 rounded-md bg-muted p-[3px]`,children:[(0,Q.jsx)(xk,{view:`active`,current:l,onSelect:g,children:`Active`}),(0,Q.jsx)(xk,{view:`archived`,current:l,onSelect:g,children:`Archived`})]}),(0,Q.jsx)(`div`,{className:`flex-1`}),(0,Q.jsxs)(`span`,{"data-slot":`global-tasks-count`,className:`text-label text-soft-foreground tabular-nums`,children:[P.length,` of `,O.length]}),le]}),(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col gap-3 p-3 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-5 md:pb-5`,children:[(0,Q.jsx)(`div`,{className:`md:hidden`,children:le}),(0,Q.jsx)(Sk,{filters:o,onToggle:I,onClearFacet:ne,onClearAll:()=>{v(``),f(e=>({...e,filters:BO,groupBy:`none`}))},groupBy:s,onGroupByChange:m,sortBy:c,onSortByChange:h,projects:D,tasks:M,view:l,origin:k,onOriginChange:A,originCounts:N}),te.length>0?(0,Q.jsxs)(`p`,{"data-slot":`global-tasks-truncated`,className:`text-meta text-soft-foreground`,children:[`Showing the `,n.data?.perProjectLimit,` most recently active tasks per project — older ones in`,` `,te.join(`, `),` are only in that project’s own Tasks page.`]}):null,n.data===void 0?null:P.length===0?(0,Q.jsx)(Fk,{view:l,filtered:UO(o),origin:k,hiddenByOrigin:k!==`all`&&N.all>0,onShowAll:()=>A(`all`)}):(0,Q.jsx)(eO,{intervalMs:pk,children:(0,Q.jsx)(Ur,{requests:ee,children:F.map(e=>(0,Q.jsxs)(`section`,{"data-slot":`task-group`,"data-group-key":e.key,children:[s===`none`?null:(0,Q.jsxs)(`h2`,{className:`mb-1.5 flex items-center gap-2 eyebrow text-soft-foreground`,children:[s===`project`?(0,Q.jsx)(yr,{to:_r(e.key,`/`),"data-slot":`group-project-link`,className:`hover:text-foreground hover:underline`,children:e.label}):e.label,(0,Q.jsx)(`span`,{className:`font-mono text-meta font-medium tabular-nums`,children:e.tasks.length})]}),(0,Q.jsx)(wk,{tasks:e.tasks,sortBy:c,isSubtasksExpanded:w,onToggleSubtasks:x,showProject:s!==`project`,onArchive:ae,onSetRead:se,busy:L.isPending||re.isPending,showCost:t.cost})]},e.key))})})]})]})}function xk({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:W(`flex h-7 items-center justify-center rounded-[7px] px-3 text-label font-medium text-muted-foreground`,i&&`bg-card font-semibold text-foreground shadow-xs`),children:r})}function Sk({filters:e,onToggle:t,onClearFacet:n,onClearAll:r,groupBy:i,onGroupByChange:a,sortBy:o,onSortByChange:s,projects:c,tasks:l,view:u,origin:d,onOriginChange:f,originCounts:p}){let m=Z.useMemo(()=>Ot(c),[c]),h=Z.useMemo(()=>{let t=(t,n)=>QO(ik(l,e,u,t),n);return{tags:t(`tags`,$O),statuses:t(`statuses`,e=>[e.run.status]),workflows:t(`workflows`,e=>[e.run.workflow])}},[l,e,u]),g=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 rounded-lg border border-border bg-card p-2.5 shadow-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,Q.jsx)(_i,{slot:`task-origin`,label:`Show tasks started by`,value:d,options:Zf.map(e=>({...e,count:p[e.value]})),onChange:f}),(0,Q.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`,"aria-hidden":`true`}),(0,Q.jsx)(Ti,{slot:`status`,label:`Status`,selected:e.statuses,onToggle:e=>t(`statuses`,e),onClear:()=>n(`statuses`),options:ZO(l).map(e=>({value:e,label:e})).map(g(h.statuses)),emptyLabel:`No tasks to filter`}),(0,Q.jsx)(Ti,{slot:`workflow`,label:`Workflow`,selected:e.workflows,onToggle:e=>t(`workflows`,e),onClear:()=>n(`workflows`),options:XO(l).map(e=>({value:e,label:e})).map(g(h.workflows)),emptyLabel:`No tasks to filter`}),(0,Q.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`text-meta font-medium text-soft-foreground`,children:`Group by`}),(0,Q.jsx)(Si,{slot:`group-by`,label:`Group tasks by`,value:i,options:LO,onChange:e=>a(RO(i,e))}),(0,Q.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`text-meta font-medium text-soft-foreground`,children:`Sort by`}),(0,Q.jsx)(_i,{slot:`sort-by`,label:`Sort tasks by`,value:o,options:w,onChange:s}),GO({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)(Tc,{className:`size-3`,"aria-hidden":`true`}),`Clear`,` (${WO({filters:e,groupBy:i})})`]}):null]}),m.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-meta font-medium text-soft-foreground`,children:`Tags`}),m.map(n=>(0,Q.jsx)(wi,{slot:`tag-filter`,tone:`tag`,label:n,count:h.tags.get(n)??0,selected:e.tags.some(e=>e.toLowerCase()===n.toLowerCase()),onToggle:()=>t(`tags`,n)},n)),(0,Q.jsx)(wi,{slot:`tag-filter`,label:`Untagged`,count:h.tags.get(` untagged`)??0,selected:e.tags.includes(IO),onToggle:()=>t(`tags`,IO)})]}):(0,Q.jsxs)(`p`,{"data-slot":`no-tags-hint`,className:`text-meta text-soft-foreground`,children:[`Tag connected repositories in`,` `,(0,Q.jsx)(yr,{to:`/settings/global/projects`,className:`font-medium text-violet hover:underline`,children:`Settings → Projects`}),` `,`to group their tasks together here.`]})]})}var Ck=e=>e.dispatch;function wk({tasks:e,sortBy:t,isSubtasksExpanded:n,onToggleSubtasks:r,showProject:i,onArchive:a,onSetRead:o,busy:s,showCost:c}){let l=Z.useMemo(()=>Jg(e.map(e=>({id:e.run.id,dispatch:Ck(e.run),task:e})),n),[e,n]),u=aO(l.length),d=[(0,Q.jsx)(Tk,{className:`w-[104px]`,children:`Status`},`status`),(0,Q.jsx)(Tk,{children:`Task`},`task`),i?(0,Q.jsx)(Tk,{className:`w-[124px]`,children:`Project`},`project`):null,(0,Q.jsx)(Tk,{className:`hidden w-[120px] xl:table-cell`,children:`Tags`},`tags`),(0,Q.jsx)(Tk,{className:`w-[84px]`,children:`Ref`},`ref`),(0,Q.jsx)(Tk,{className:`hidden w-[108px] xl:table-cell`,children:`Workflow`},`workflow`),c?(0,Q.jsx)(Tk,{className:`hidden w-[64px] text-right lg:table-cell`,children:`Cost`},`cost`):null,(0,Q.jsx)(Tk,{className:`hidden w-[56px] text-right xl:table-cell`,children:`CPU`},`cpu`),(0,Q.jsx)(Tk,{className:`hidden w-[84px] text-right xl:table-cell`,children:`Mem`},`mem`),(0,Q.jsx)(Tk,{className:`w-[72px] text-right`,children:fn(t)},`age`),(0,Q.jsx)(Tk,{className:`w-[64px] text-right`,children:(0,Q.jsx)(`span`,{className:`sr-only`,children:`Actions`})},`actions`)].filter(e=>e!==null),f=d.length;return(0,Q.jsx)(`div`,{"data-slot":`global-tasks-table`,className:`overflow-x-auto rounded-lg border border-border bg-card shadow-xs`,children:(0,Q.jsx)(kc,{children:(0,Q.jsxs)(`table`,{className:`w-full border-collapse`,"aria-rowcount":u.ariaRowCount,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsx)(`tr`,{"aria-rowindex":u.windowed?1:void 0,children:d})}),(0,Q.jsxs)(`tbody`,{ref:u.anchorRef,className:`[&>tr:last-child>td]:border-b-0`,children:[(0,Q.jsx)(iO,{height:u.padTop,colSpan:f}),l.slice(u.start,u.end).map((e,l)=>(0,Q.jsx)(Dk,{ariaRowIndex:u.ariaRowIndex(u.start+l),task:e.run.task,depth:e.depth,childCount:e.childCount,subtasksExpanded:n(e.run.id),onToggleSubtasks:r,sortBy:t,showProject:i,onArchive:a,onSetRead:o,busy:s,showCost:c},`${e.run.task.run.projectId}/${e.run.task.run.id}`)),(0,Q.jsx)(iO,{height:u.padBottom,colSpan:f})]})]})})})}function Tk({children:e,className:t}){return(0,Q.jsx)(`th`,{scope:`col`,className:W(`h-[38px] border-b border-border px-2.5 text-left eyebrow whitespace-nowrap text-soft-foreground first:pl-4 last:pr-4`,t),children:e})}var Ek=`h-11 border-b border-border px-2.5 whitespace-nowrap first:pl-4 last:pr-4`,Dk=Z.memo(function({ariaRowIndex:e,task:t,depth:n,childCount:r,subtasksExpanded:i,onToggleSubtasks:a,sortBy:s,showProject:c,onArchive:l,onSetRead:u,busy:d,showCost:f}){let{run:p}=t,m=o(p),h=_r(p.projectId,`/tasks/${p.id}`),g=$o(p),_=Zo(p),v=ce(p,t.project?.repoUrl),y=Yg(r),b=R(p,p.usage);return(0,Q.jsxs)(`tr`,{"data-slot":`global-task-row`,"data-run-id":p.id,"aria-rowindex":e,"data-project":p.projectId,"data-depth":n,className:`hover:bg-muted`,children:[(0,Q.jsx)(`td`,{className:Ek,children:(0,Q.jsx)(Nc,{dot:m.tone,pulse:m.pulse,children:m.label})}),(0,Q.jsx)(`td`,{className:W(Ek,`min-w-[320px] max-w-0`),children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,style:n>0?{paddingLeft:`${n*14}px`}:void 0,children:[n>0?(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`subtask-tick`,className:`shrink-0 font-mono text-meta leading-none text-soft-foreground`,children:`└`}):null,(0,Q.jsxs)(yr,{to:h,title:Ve(p),className:W(`min-w-0 truncate text-ui`,g?`font-semibold text-foreground`:_?`font-medium text-muted-foreground`:`font-medium`),children:[Ve(p),g?(0,Q.jsx)(Ig,{}):null]}),Xg(p)?(0,Q.jsx)(`span`,{"data-slot":`dispatch-kind`,className:`shrink-0 rounded-full bg-muted px-1.5 py-px text-micro font-medium text-muted-foreground`,children:Xg(p)}):null,y?(0,Q.jsx)(HD,{label:y,expanded:i,onToggle:()=>a(p.id)}):null]})}),c?(0,Q.jsx)(`td`,{className:W(Ek,`text-label text-muted-foreground`),children:(0,Q.jsx)(yr,{to:_r(p.projectId,`/`),className:`truncate hover:text-foreground`,children:t.projectName})}):null,(0,Q.jsx)(`td`,{className:W(Ek,`hidden xl:table-cell`),children:t.tags.length>0?(0,Q.jsx)(`span`,{className:`flex flex-wrap items-center gap-1`,children:t.tags.map(e=>(0,Q.jsx)(Mk,{tag:e},e))}):(0,Q.jsx)(Pk,{})}),(0,Q.jsx)(`td`,{className:Ek,children:v.length>0?(0,Q.jsx)(jk,{references:v,run:p}):(0,Q.jsx)(Pk,{})}),(0,Q.jsx)(`td`,{className:W(Ek,`hidden text-label text-muted-foreground xl:table-cell`),children:p.workflow}),f?(0,Q.jsx)(`td`,{className:W(Ek,`hidden text-right font-mono text-xs text-muted-foreground tabular-nums lg:table-cell`),children:we(p.costUsd)||(0,Q.jsx)(Pk,{})}):null,(0,Q.jsx)(Nk,{column:`cpu`,cell:b.cpu}),(0,Q.jsx)(Nk,{column:`memory`,cell:b.mem}),(0,Q.jsx)(`td`,{className:W(Ek,`text-right text-xs text-soft-foreground tabular-nums`),children:(0,Q.jsx)(tO,{at:I(p,s)})}),(0,Q.jsx)(`td`,{className:W(Ek,`text-right`),children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,Q.jsx)(kk,{task:t,busy:d,onSetRead:u}),(0,Q.jsx)(Ak,{task:t,busy:d,onArchive:l})]})})]})},Ok);function Ok(e,t){let{task:n,...r}=e,{task:i,...a}=t;return n.run!==i.run||n.project!==i.project||n.projectName!==i.projectName||n.tags!==i.tags?!1:Object.keys(r).every(e=>r[e]===a[e])}function kk({task:e,busy:t,onSetRead:n}){if(!Wo(e.run))return null;let r=$o(e.run),i=Ve(e.run),a=r?`Mark ${i} read`:`Mark ${i} unread`,o=r?lc:Tl;return(0,Q.jsxs)(Ac,{children:[(0,Q.jsx)(Dc,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"data-action":r?`mark-read`:`mark-unread`,"aria-label":a,disabled:t,onClick:()=>n(e,r),className:W(`inline-flex size-7 items-center justify-center 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-violet`:`text-soft-foreground`),children:(0,Q.jsx)(o,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Q.jsx)(Oc,{side:`left`,children:r?`Mark read`:`Mark unread`})]})}function Ak({task:e,busy:t,onArchive:n}){let r=e.run.archived;if(!r&&!gk.has(e.run.status))return null;let i=r?`Restore ${Ve(e.run)} to the active list`:`Archive ${Ve(e.run)}`;return(0,Q.jsxs)(Ac,{children:[(0,Q.jsx)(Dc,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"data-action":r?`unarchive-run`:`archive-run`,"aria-label":i,disabled:t,onClick:()=>n(e,!r),className:`inline-flex size-7 items-center justify-center 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?pl:wa,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Q.jsx)(Oc,{side:`left`,children:r?`Restore`:`Archive`})]})}function jk({references:e,run:t}){let n=e.slice(0,hk),r=e.length-n.length,i=Ve(t);return(0,Q.jsxs)(`span`,{className:`flex flex-nowrap items-center gap-1`,children:[n.map(e=>(0,Q.jsx)(Gr,{reference:e,taskTitle:i,projectId:t.projectId,conflictAction:(0,Q.jsx)(ka,{projectId:t.projectId,runId:t.id,prNumber:e.number}),className:`shrink-0`},`${e.kind}#${e.number}`)),r>0?(0,Q.jsx)(Ea,{references:e,taskTitle:i,hidden:r,projectId:t.projectId}):null]})}function Mk({tag:e,className:t}){return(0,Q.jsx)(`span`,{"data-slot":`project-tag`,className:W(`inline-flex max-w-full items-center truncate rounded-full bg-muted px-1.5 py-px text-micro font-medium text-muted-foreground`,t),children:e})}function Nk({column:e,cell:t}){return(0,Q.jsx)(`td`,{"data-usage":e===`memory`?`mem`:e,"data-usage-kind":t.kind,title:t.title,className:W(Ek,`hidden text-right font-mono tabular-nums xl:table-cell`,t.kind===`live`&&`bg-violet/5 text-xs font-medium text-foreground`,t.kind===`peak`&&`text-meta text-soft-foreground`,t.kind===`none`&&`text-xs text-soft-foreground`),children:t.text||`—`})}function Pk(){return(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`})}function Fk({view:e,filtered:t,origin:n=`all`,hiddenByOrigin:r=!1,onShowAll:i=()=>void 0}){return r?(0,Q.jsx)(`div`,{"data-slot":`global-tasks-empty`,"data-empty-kind":`origin-hidden`,children:(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(ys,{}),tone:`neutral`,title:n===`regular`?`No regular tasks here`:`No automation tasks here`,subtitle:n===`regular`?`Tasks started by automations are hidden.`:`Only tasks started by automations are shown.`,actions:(0,Q.jsx)(J,{type:`button`,variant:`outline`,onClick:i,children:`Show all tasks`})})}):t?(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(Sc,{}),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)(wa,{}),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)(Bl,{}),tone:`neutral`,title:`No tasks yet`,subtitle:`Start a task in any project and it shows up here.`})}var Ik=Ds(`dashboard`,()=>mr(()=>import(`./dashboard-DQ2EsruE.js`).then(e=>({default:e.DashboardRoute})),__vite__mapDeps([11,1,2,3,4,5,12,6,13,14,15,16,17,18,19,20,21,22,23,24,25,26,9,27,28,29,30,31]))),Lk=Ds(`compare`,()=>mr(()=>import(`./compare-variants-B66gT_Lp.js`).then(e=>({default:e.CompareVariantsRoute})),__vite__mapDeps([32,1,2,3,4,5,12,6,14,25,28,33,34,21,31,35,26,36,37,38,39,40]))),Rk=Ds(`task-commits`,()=>mr(()=>import(`./task-commits-rj991QXb.js`).then(e=>e.n).then(e=>({default:e.TaskCommitsRoute})),__vite__mapDeps([41,1,2,3,4,5,12,6,8,14,42,13,15,16,17,18,19,20,21,43,44,7,45,46,47,24,26,48,25,49,50,51,52,30,31,53,54,55,33,56,34,35,9,36,57,58,59,60]))),zk=(0,Z.lazy)(()=>mr(()=>import(`./task-notes-CyXwM1jJ.js`).then(e=>({default:e.TaskNotesRoute})),__vite__mapDeps([61,1,2,3,4,5,12,6,42,13,14,15,16,17,18,19,20,21,43,44,7,8,45,46,47,24,26,48,25,49,50,51,52,30,31,53,54,55,33,56,34,35,9,36,37,38,39,62,63,64]))),Bk=Ds(`task-workspace`,()=>mr(()=>import(`./task-workspace-BsOvp8_P.js`).then(e=>({default:e.TaskWorkspaceRoute})),__vite__mapDeps([65,1,2,3,4,5,6,12,13,14,15,16,17,18,19,20,21,23,24,8,42,43,44,7,45,46,47,26,48,25,49,50,51,52,30,31,53,54,55,33,56,34,35,9,36,66,57,67,68,28,69,37,38,39,70,71,72,73,74,75,76,77,64,78,59,79,40,58,41,60,62,63]))),Vk=Ds(`repo-git`,()=>mr(()=>import(`./repo-git-DQHghYiX.js`).then(e=>({default:e.RepoGitRoute})),__vite__mapDeps([80,1,2,3,4,5,12,6,8,14,66,57,25,28,50,15,45,51,17,18,52,30,31,53,54,69,19,36,37,35,38,39,70,71,47,72,73,74,33,64,26,58,59,81,60,48]))),Hk=Ds(`github`,()=>mr(()=>import(`./github-3riSQ6Lm.js`).then(e=>({default:e.GithubRoute})),__vite__mapDeps([82,1,2,3,4,5,12,6,13,14,15,16,17,18,19,20,21,22,23,24,25,26,9,57,67,42,43,44,7,8,45,46,47,48,49,50,51,52,30,31,53,54,55,33,56,34,35,36,66,68,83,28,73,84,37,38,39,85,58,59,81]))),Uk=Ds(`tracker`,()=>mr(()=>import(`./tracker-CfV4FaME.js`).then(e=>({default:e.TrackerRoute})),__vite__mapDeps([86,1,2,3,4,5,12,6,13,14,15,16,17,18,19,20,21,23,24,8,57,44,7,43,45,46,47,26,48,25,49,50,51,52,30,31,53,54,55,68,84,36,37,35,38,39,85,67,42,33,56,34,9,66]))),Wk=Ds(`workflow-graph`,()=>mr(()=>import(`./workflow-graph-Bi8UYX1n.js`).then(e=>({default:e.WorkflowGraphRoute})),__vite__mapDeps([87,1,2,3,4,5,12,6,14,43,16,29,46,51,88,17,55,73,68,74,63,84,56,19,20,35,64,26,9,36,89]))),Gk=Ds(`skills`,()=>mr(()=>import(`./skills-BAzH59kW.js`).then(e=>({default:e.SkillsRoute})),__vite__mapDeps([90,1,2,3,4,5,12,6,13,14,15,16,17,18,19,20,21,57,67,23,24,42,43,44,7,8,45,46,47,26,48,25,49,50,51,52,30,31,53,54,55,33,56,34,35,9,36,66,68,64]))),Kk=Ds(`automations`,()=>mr(()=>import(`./automations-route-C9h3Pe23.js`).then(e=>({default:e.AutomationsRoute})),__vite__mapDeps([91,1,2,3,4,5,12,6,13,14,15,16,17,18,19,20,21,22,23,24,25,26,9,42,43,44,7,8,45,46,47,48,49,50,51,52,30,31,53,54,55,33,56,34,35,36,66,57,67,68,27,83,28,29,88,74,64])));function qk(){let e=jr();return new URLSearchParams(e.search).get(`skill`)===`__bm`?(0,Q.jsx)(Or,{to:{pathname:`/settings/bookmarklets`,hash:e.hash},replace:!0}):(0,Q.jsx)(Or,{to:{pathname:`/skills`,search:e.search,hash:e.hash},replace:!0})}function Jk({sectionId:e}){let t=jr();return(0,Q.jsx)(Dr,{to:{pathname:dD(`global`,e),search:t.search,hash:t.hash},replace:!0})}function Yk(){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 Xk(){let{projectId:e=``}=Mr(),t=jr(),n=a(),r=C();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)(Dr,{to:`/p/${encodeURIComponent(e)}${n||`/`}${t.search}${t.hash}`,replace:!0})}if(!n.isError)return(0,Q.jsx)(Yk,{})}if(n.data){if(!(n.data.bootProject===e||n.data.projects.some(t=>t.id===e)))return(0,Q.jsx)(RS,{projectId:e,registry:n.data})}else if(!n.isError)return(0,Q.jsx)(Yk,{});return(0,Q.jsxs)(It,{projectId:n.data?.bootProject===e?null:e,children:[(0,Q.jsx)(gb,{projectId:e},`webhooks:${e}`),(0,Q.jsx)(wr,{},e)]})}function Zk(){let{projectId:e=``}=Mr();return(0,Q.jsx)(CS,{},e)}function Qk(){let e=jr(),t=C(),n=a(),r=t.data?.bootProject??n.data?.bootProject,i=(t.data!==void 0||t.isError)&&(n.data!==void 0||n.isError);if(r===void 0&&!i)return(0,Q.jsx)(Yk,{});let o=r??`default`;if(e.pathname===`/`&&e.search===``&&e.hash===``){if(n.data===void 0&&!n.isError)return(0,Q.jsx)(Yk,{});let e=Tb(yb(),n.data,r);if(e!==null)return(0,Q.jsx)(Dr,{to:e,replace:!0});let t=Eb(n.data,o);if(t!==o)return(0,Q.jsx)(Dr,{to:`/p/${encodeURIComponent(t)}/`,replace:!0})}let s=e.pathname===`/p`||e.pathname===`/p/`?`/`:e.pathname;return(0,Q.jsx)(Dr,{to:`/p/${encodeURIComponent(o)}${s}${e.search}${e.hash}`,replace:!0})}var $k=[{pattern:`/`,pageLabel:`Tasks`},{pattern:`/tasks`,pageLabel:`All tasks`},{pattern:`/dashboard`,pageLabel:`Dashboard`},{pattern:`/new`,pageLabel:`New task`},{pattern:`/compare/:groupId`,pageLabel:`Compare`},{pattern:`/git/*`,pageLabel:`Git`},{pattern:`/github/*`,pageLabel:`GitHub`},{pattern:`/tracker/*`,pageLabel:`Tracker`},{pattern:`/assets`,pageLabel:`Assets`},{pattern:`/automations/*`,pageLabel:`Automations`},{pattern:`/skills`,pageLabel:`Skills`},{pattern:`/inbox`,pageLabel:`Inbox`},{pattern:`/workflows/*`,pageLabel:`Workflows`},{pattern:`/settings/*`,pageLabel:`Settings`}];function eA(e){let t=Er(e),n=gr({path:`/tasks/:id/*`,end:!0},t);return n?{pageLabel:null,taskId:n.params.id??null}:{pageLabel:$k.find(({pattern:e})=>gr({path:e,end:!0},t))?.pageLabel??null,taskId:null}}var tA=(0,Z.memo)(function(){let e=C().data?.capabilities;return(0,Q.jsxs)(xr,{children:[(0,Q.jsxs)(G,{path:`/p/:projectId`,element:(0,Q.jsx)(Xk,{}),children:[(0,Q.jsx)(G,{index:!0,element:(0,Q.jsx)(PO,{})}),(0,Q.jsx)(G,{path:`new`,element:(0,Q.jsx)(Zk,{})}),(0,Q.jsx)(G,{path:`tasks/:id`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(jo,{}),children:(0,Q.jsx)(Bk,{})})}),(0,Q.jsx)(G,{path:`tasks/:id/chat`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(jo,{}),children:(0,Q.jsx)(Bk,{view:`session`})})}),(0,Q.jsx)(G,{path:`tasks/:id/changes`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ua,{tab:`changes`}),children:(0,Q.jsx)(Bk,{view:`changes`})})}),(0,Q.jsx)(G,{path:`tasks/:id/files`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ua,{tab:`files`}),children:(0,Q.jsx)(Bk,{view:`files`})})}),(0,Q.jsx)(G,{path:`tasks/:id/graph`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ua,{tab:`changes`}),children:(0,Q.jsx)(Bk,{view:`graph`})})}),(0,Q.jsx)(G,{path:`tasks/:id/commits`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ua,{tab:`changes`}),children:(0,Q.jsx)(Bk,{view:`commits`})})}),(0,Q.jsx)(G,{path:`tasks/:id/notes`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ua,{tab:`notes`}),children:(0,Q.jsx)(zk,{})})}),(0,Q.jsx)(G,{path:`tasks/:id/preview`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ua,{tab:`preview`}),children:(0,Q.jsx)(Bk,{view:`browser`})})}),(0,Q.jsx)(G,{path:`tasks/:id/assets`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ua,{tab:`preview`}),children:(0,Q.jsx)(Bk,{view:`assets`})})}),(0,Q.jsx)(G,{path:`tasks/:id/assets/:name`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ua,{tab:`preview`}),children:(0,Q.jsx)(Bk,{view:`assets`})})}),(0,Q.jsx)(G,{path:`tasks/:id/terminal`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ua,{tab:`terminal`}),children:(0,Q.jsx)(Bk,{view:`terminal`})})}),(0,Q.jsx)(G,{path:`tasks/:id/commits/:sha`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ua,{tab:`changes`}),children:(0,Q.jsx)(Rk,{})})}),(0,Q.jsx)(G,{path:`compare/:groupId`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(kb,{}),children:(0,Q.jsx)(Lk,{})})}),(0,Q.jsx)(G,{path:`git`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(IS,{}),children:(0,Q.jsx)(Vk,{tab:`changes`})})}),(0,Q.jsx)(G,{path:`git/commits`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(IS,{}),children:(0,Q.jsx)(Vk,{tab:`commits`})})}),(0,Q.jsx)(G,{path:`git/commits/:sha`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(IS,{}),children:(0,Q.jsx)(Vk,{tab:`commits`})})}),(0,Q.jsx)(G,{path:`git/branches`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(IS,{}),children:(0,Q.jsx)(Vk,{tab:`branches`})})}),(0,Q.jsx)(G,{path:`git/files`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(IS,{}),children:(0,Q.jsx)(Vk,{tab:`files`})})}),(0,Q.jsx)(G,{path:`git/files/*`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(IS,{}),children:(0,Q.jsx)(Vk,{tab:`files`})})}),(0,Q.jsx)(G,{path:`github`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ab,{}),children:(0,Q.jsx)(Hk,{view:`issues`,index:!0})})}),(0,Q.jsx)(G,{path:`tracker`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Yk,{}),children:(0,Q.jsx)(Uk,{})})}),(0,Q.jsx)(G,{path:`tracker/:id`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Yk,{}),children:(0,Q.jsx)(Uk,{})})}),(0,Q.jsx)(G,{path:`github/prs`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ab,{}),children:(0,Q.jsx)(Hk,{view:`prs`})})}),(0,Q.jsx)(G,{path:`github/issues/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ab,{}),children:(0,Q.jsx)(Hk,{view:`issues`})})}),(0,Q.jsx)(G,{path:`github/prs/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ab,{}),children:(0,Q.jsx)(Hk,{view:`prs`})})}),(0,Q.jsx)(G,{path:`github/prs/:n/changes`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ab,{}),children:(0,Q.jsx)(Hk,{view:`prs`,changes:!0})})}),(0,Q.jsx)(G,{path:`automations`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ob,{}),children:(0,Q.jsx)(Kk,{})})}),(0,Q.jsx)(G,{path:`automations/new`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ob,{}),children:(0,Q.jsx)(Kk,{mode:`new`})})}),(0,Q.jsx)(G,{path:`automations/:automationId`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ob,{}),children:(0,Q.jsx)(Kk,{mode:`edit`})})}),(0,Q.jsx)(G,{path:`automations/:automationId/log`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ob,{}),children:(0,Q.jsx)(Kk,{mode:`log`})})}),(0,Q.jsx)(G,{path:`skills`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(LS,{}),children:(0,Q.jsx)(Gk,{})})}),(0,Q.jsx)(G,{path:`inbox`,element:(0,Q.jsx)(ux,{})}),(0,Q.jsx)(G,{path:`assets`,element:(0,Q.jsx)(Ib,{})}),(0,Q.jsx)(G,{path:`workflows`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(zS,{}),children:(0,Q.jsx)(Wk,{})})}),(0,Q.jsx)(G,{path:`workflows/:name`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(zS,{}),children:(0,Q.jsx)(Wk,{})})}),(0,Q.jsx)(G,{path:`workflows-new/*`,element:(0,Q.jsx)(Or,{to:`/workflows`,replace:!0})}),(0,Q.jsx)(G,{path:`settings`,element:(0,Q.jsx)(FD,{scope:`project`,capabilities:e})}),(0,Q.jsx)(G,{path:`settings/skills`,element:(0,Q.jsx)(qk,{})}),(0,Q.jsx)(G,{path:`settings/prompt-templates`,element:(0,Q.jsx)(Or,{to:{pathname:`/settings/instructions`,hash:`#prompt-templates`},replace:!0})}),XE(`project`,e).map(t=>(0,Q.jsx)(G,{path:`settings/${t.id}`,element:(0,Q.jsx)(MD,{section:t,scope:`project`,capabilities:e})},t.id)),XE(`global`,e).map(e=>(0,Q.jsx)(G,{path:`settings/${e.id}`,element:(0,Q.jsx)(Jk,{sectionId:e.id})},e.id)),(0,Q.jsx)(G,{path:`*`,element:(0,Q.jsx)(FS,{})})]}),(0,Q.jsx)(G,{path:`/tasks`,element:(0,Q.jsx)(bk,{})}),(0,Q.jsx)(G,{path:`/dashboard`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{role:`status`,className:`p-6 text-sm text-muted-foreground`,children:`Loading dashboard…`}),children:(0,Q.jsx)(Ik,{})})}),(0,Q.jsx)(G,{path:`/settings/global`,element:(0,Q.jsx)(FD,{scope:`global`,capabilities:e})}),XE(`global`,e).map(t=>(0,Q.jsx)(G,{path:dD(`global`,t.id),element:(0,Q.jsx)(MD,{section:t,scope:`global`,capabilities:e})},t.id)),(0,Q.jsx)(G,{path:`*`,element:(0,Q.jsx)(Qk,{})})]})});function nA(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 rA(e){return e?.available===!0&&(e.status===`available`||e.status===`error`)}var iA=(0,Z.memo)(function({children:e}){let{pathname:t}=jr(),n=kr(),r=C(),i=Ht(),o=i.data?.branding,s=o!==void 0&&(o.name!==`cezar`||o.logoUrl!==null),c=ne(!s&&i.data!==void 0),l=r.data?.capabilities.followups===!0,u=r.data?.capabilities.automations===!0,d=ye(l),f=rA(pn(n??``,n!==null).data),p=Xy(Er(t)),m=a().data,h=(0,Z.useMemo)(()=>W_(m,n,r.data),[m,n,r.data]),g=eA(t),_=h?.bootProject??r.data?.bootProject??null,v=se(n,_,(0,Z.useMemo)(()=>qo,[])),y=n!==null&&n===_,b=h?.projects.find(e=>e.id===n),x=h?.projects.find(e=>e.id===_),S=n===null?x?.tracker:b?.tracker,w=g.taskId,T=Ye(n??``,b!==void 0&&w!==null,h?.bootProject===n,(0,Z.useMemo)(()=>e=>{let t=w?e.find(e=>e.id===w):void 0;return t?Ve(t):void 0},[w])).data,E=t===`/settings/global`||t.startsWith(`/settings/global/`),D=E?null:b?.name??(y?nA(r.data)?.name??null:null);U_({projectName:D,pageLabel:T??g.pageLabel,brandName:i.data?.branding.name,brandLogoUrl:i.data?.branding.logoUrl});let O=h&&h.projects.length>1?h:null,k=(0,Z.useMemo)(()=>nA(r.data),[r.data?.repo?.root,r.data?.repo?.branch]),A=(0,Z.useMemo)(()=>E?null:{activeId:n??_,activeName:D,projects:(h?.projects??[]).map(({id:e,name:t})=>({id:e,name:t}))},[E,n,_,D,h?.projects]),j=(0,Z.useMemo)(()=>(0,Q.jsx)(gg,{}),[]),M=(0,Z.useMemo)(()=>(0,Q.jsx)(wg,{}),[]),N=(0,Z.useMemo)(()=>(0,Q.jsx)(u_,{}),[]),P=(0,Z.useMemo)(()=>(0,Q.jsx)(dg,{}),[]),F=(0,Z.useMemo)(()=>(0,Q.jsx)(Qy,{}),[]),ee=(0,Z.useMemo)(()=>O?(0,Q.jsx)(D_,{projects:O.projects,bootProjectId:O.bootProject,inboxAvailable:l,automationsAvailable:u,inboxCount:d.data?.length??null,skillsUpdateAvailable:f,newNavItems:p}):void 0,[O,l,u,d.data?.length,f,p]),te=sc(),I=(0,Z.useMemo)(()=>(0,Q.jsx)(L_,{health:r.data,forge:te}),[r.data,te]);return(0,Q.jsxs)(og,{children:[(0,Q.jsx)(_h,{repo:k,brandName:i.data?.branding.name??`cezar`,brandLogoUrl:i.data?.branding.logoUrl??null,version:r.data?.version??null,latestVersion:r.data?.latestVersion??null,starCount:!s&&c.data?.available?c.data.count??null:null,inboxCount:d.data?.length??null,unreadCount:v.data??null,skillsUpdateAvailable:f,newNavItems:p,forgeAvailable:te!=null,inboxAvailable:l,automationsAvailable:u,tracker:S,banner:j,whatsNew:F,footerBanner:M,singleProject:r.data?.capabilities.singleProject===!0,taskQuickList:N,hostWidget:P,projectGroups:ee,toolsMenu:I,projectSwitcher:A,children:e}),(0,Q.jsx)(Bp,{}),(0,Q.jsx)(Vh,{}),(0,Q.jsx)(fb,{})]})});function aA(){let e=jr(),t=a();return(0,Z.useEffect)(()=>{$E(e)},[e]),(0,Z.useEffect)(()=>{let n=wb(e,t.data);n!==null&&(Db(yb(),n)||bb(n))},[e.hash,e.pathname,e.search,t.data]),null}function oA(){let e=U(),t=ni(ht().data?.notifications).enabled,n=(0,Z.useRef)(t);n.current=t;let r=(0,Z.useRef)(new Map);return(0,Z.useEffect)(()=>{let t=kt(V.runs.list()),i=e=>{let{entering:t,statuses:i}=ci(r.current,e);if(r.current=i,t.length!==0&&ii({enabled:n.current,hidden:document.visibilityState===`hidden`,permission:ri()}))for(let e of t)sA(e)};return i(e.getQueryData(V.runs.list())),e.getQueryCache().subscribe(e=>{e.query.queryHash!==t||e.type!==`updated`||i(e.query.state.data)})},[e]),null}function sA(e){let t=globalThis.Notification;if(typeof t!=`function`)return;let n=oi(e);try{new t(n.title,{body:n.body,tag:n.tag})}catch{}}function cA(e,t=!0){return dt({queryKey:[...B.dashboard,`insights`,e],enabled:t,staleTime:5e3,refetchInterval:t?15e3:!1,refetchIntervalInBackground:!1,retry:!1,queryFn:async({signal:t})=>Yn.parse(await be(await Ae.api.v1.workspace.dashboard.insights.$get({query:{period:e,tzOffsetMinutes:String(new Date().getTimezoneOffset())}},{init:{signal:t}}),`/workspace/dashboard/insights`))})}var lA=[`pointerdown`,`pointermove`,`keydown`,`wheel`,`touchstart`];function uA(){let e=document.activeElement;return e?e.isContentEditable||e.tagName===`TEXTAREA`||e.tagName===`INPUT`&&e.type!==`checkbox`:!1}var dA=()=>document.querySelector(`[role="dialog"],[role="alertdialog"]`)!==null;function fA(){let e=U(),t=Ht(),n=t.data?.branding,r=n!==void 0&&(n.name!==`cezar`||n.logoUrl!==null),i=ne(t.data!==void 0&&!r),a=!r&&i.data?.available===!0,o=!r&&i.data?.available?i.data.count??null:null,[s,c]=(0,Z.useState)(!1),l=(0,Z.useRef)(a);l.current=a;let u=(0,Z.useRef)(new Map),d=(0,Z.useRef)(null),f=(0,Z.useRef)(0);return(0,Z.useEffect)(()=>{let t=kt(V.runs.list()),n,r=()=>em({now:Date.now(),visible:document.visibilityState===`visible`,focused:document.hasFocus(),lastInteractionAt:f.current,typing:uA(),dialogOpen:dA()}),i=()=>{let e=d.current;if(!(e===null||n)){if(Date.now()-e>18e5){d.current=null;return}r()&&(n=setTimeout(()=>{n=void 0;let e=Xp();if(!(d.current===null||!r()||!l.current)){if(!Qp(e,Date.now())){d.current=null;return}d.current=null,Zp({...e,asks:e.asks+1,lastAskedAt:new Date().toISOString()}),c(!0)}},Yp))}},a=e=>{let{succeeded:t,statuses:n}=rm(u.current,e);u.current=n,!(!t||!l.current)&&($p(e)<3||Qp(Xp(),Date.now())&&(d.current=Date.now(),i()))},o=()=>{f.current=Date.now(),i()};for(let e of lA)window.addEventListener(e,o,{passive:!0});document.addEventListener(`visibilitychange`,i),window.addEventListener(`focus`,i),a(e.getQueryData(V.runs.list()));let s=e.getQueryCache().subscribe(e=>{e.query.queryHash!==t||e.type!==`updated`||a(e.query.state.data)});return()=>{s(),clearTimeout(n);for(let e of lA)window.removeEventListener(e,o);document.removeEventListener(`visibilitychange`,i),window.removeEventListener(`focus`,i)}},[e]),r?null:(0,Q.jsx)(mA,{open:s,onOpenChange:c,count:o})}function pA(e){let t=Xp();t&&Zp({...t,outcome:e})}function mA({open:e,onOpenChange:t,count:n}){let r=cA(`30d`,e).data?.delivered,i=r&&r.completedTasks>0?[{label:`Tasks done`,n:r.completedTasks,value:r.completedTasks.toLocaleString(`en-US`)},{label:`PRs opened`,n:r.prsOpened,value:r.prsOpened.toLocaleString(`en-US`)},{label:`Lines written`,n:r.additions,value:`+${r.additions.toLocaleString(`en-US`)}`}].filter(e=>e.n>0):null;return(0,Q.jsx)(qr,{open:e,onOpenChange:t,children:(0,Q.jsxs)(Wr,{"data-slot":`star-ask`,className:`gap-0 overflow-hidden p-0 sm:max-w-[440px]`,children:[(0,Q.jsxs)(`div`,{className:`relative flex h-36 items-center justify-center overflow-hidden border-b bg-card-2`,children:[(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:`absolute inset-0 bg-[radial-gradient(circle_at_22%_35%,color-mix(in_oklab,var(--accent-lime)_32%,transparent),transparent_55%),radial-gradient(circle_at_80%_70%,color-mix(in_oklab,var(--violet)_38%,transparent),transparent_55%)]`}),(0,Q.jsxs)(`div`,{"aria-hidden":`true`,className:`relative flex items-center gap-4`,children:[(0,Q.jsx)(sm,{height:52,className:`text-foreground`}),(0,Q.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-full border bg-card shadow-md`,children:(0,Q.jsx)(au,{className:`size-6 fill-current text-pending-strong`})})]}),n!==null&&(0,Q.jsxs)(`span`,{className:`absolute bottom-3 left-1/2 -translate-x-1/2 rounded-full border bg-card/80 px-2.5 py-0.5 font-mono text-meta text-muted-foreground backdrop-blur`,children:[`⭐ `,qp(n),` stars on GitHub`]})]}),(0,Q.jsxs)(`div`,{className:`space-y-4 p-6`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`span`,{className:`section-mark block eyebrow text-muted-foreground`,children:`Open source · MIT`}),(0,Q.jsx)(Zr,{className:`text-xl font-semibold tracking-tight`,children:`Is cezar pulling its weight?`}),(0,Q.jsx)(Vr,{className:`text-sm leading-relaxed text-muted-foreground`,children:`cezar is free, open source and runs on your machine, with no account to create. A GitHub star is how other developers find it, and how we know what to keep building.`})]}),i&&(0,Q.jsxs)(`div`,{className:`rounded-lg border bg-card-2 p-3`,children:[(0,Q.jsx)(`span`,{className:`block eyebrow text-soft-foreground`,children:`Your last 30 days with cezar`}),(0,Q.jsx)(`dl`,{className:`mt-2 grid gap-2`,style:{gridTemplateColumns:`repeat(${i.length}, minmax(0, 1fr))`},children:i.map(e=>(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col-reverse`,children:[(0,Q.jsx)(`dt`,{className:`text-xs text-soft-foreground`,children:e.label}),(0,Q.jsx)(`dd`,{className:`truncate text-lg font-semibold tabular-nums`,children:e.value})]},e.label))})]}),(0,Q.jsx)(J,{asChild:!0,className:`h-11 w-full text-sm font-semibold`,children:(0,Q.jsxs)(`a`,{href:Gp,target:`_blank`,rel:`noopener noreferrer`,onClick:()=>{pA(`starred`),t(!1)},children:[(0,Q.jsx)(au,{className:`size-4 fill-current`,"aria-hidden":`true`}),`Star cezar on GitHub`,(0,Q.jsx)(Ir,{className:`size-4`,"aria-hidden":`true`})]})}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(J,{variant:`ghost`,className:`min-h-11`,onClick:()=>t(!1),children:`Maybe later`}),(0,Q.jsx)(J,{variant:`ghost`,className:`min-h-11 text-soft-foreground`,onClick:()=>{pA(`never`),t(!1)},children:`Don’t ask again`})]})]})]})})}function hA(){let[e]=(0,Z.useState)(fl);return(0,Q.jsx)(Ut,{client:e,children:(0,Q.jsx)(Qr,{children:(0,Q.jsxs)(ta,{children:[(0,Q.jsx)(oA,{}),(0,Q.jsx)(fA,{}),(0,Q.jsx)(zf,{children:(0,Q.jsx)(KC,{children:(0,Q.jsxs)(Ar,{children:[(0,Q.jsx)(aA,{}),(0,Q.jsx)(hs,{}),(0,Q.jsx)(Xr,{children:(0,Q.jsx)(iA,{children:(0,Q.jsx)(tA,{})})}),(0,Q.jsx)(qc,{})]})})})]})})})}function gA(){return(document.querySelector(`meta[name="cez-api-base"]`)?.getAttribute(`content`))?.trim()||``}dr(gA());var _A=document.getElementById(`root`);if(!_A)throw Error(`cezar: #root container is missing from index.html`);(0,dl.createRoot)(_A).render((0,Q.jsx)(Z.StrictMode,{children:(0,Q.jsx)(hA,{})}));export{nu as $,hv as A,fm as B,ry as C,Kv as D,Qv as E,gv as F,Cf as G,dm as H,yv as I,$d as J,ff as K,lv as L,cv as M,_v as N,Gv as O,vv as P,iu as Q,ch as R,ey as S,ty as T,um as U,pm as V,Bf as W,lu as X,uu as Y,su as Z,Xb as _,IS as a,xl as at,kb as b,Xx as c,ax as d,tu as et,ix as f,Kb as g,Yb as h,zS as i,Zl as it,mv as j,Zv as k,qx as l,Zb as m,UD as n,$l as nt,Zx as o,ex as p,lf as q,dD as r,Ql as rt,Jx as s,cA as t,eu as tt,ox as u,qb as v,ny as w,$v as x,Ab as y,lm as z};
|
|
30
|
+
`)!==n&&t.mutate({requiredChecks:e.length?e:null},{onSuccess:()=>Y(`Required checks saved`)})},className:`block w-full max-w-md rounded-md border border-input bg-card px-3 py-1.5 font-mono text-ui shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`})})}function DT(){let e=En();return e.isPending?(0,Q.jsx)(`p`,{"data-slot":`tasks-loading`,className:`p-4 text-ui text-soft-foreground md:p-6`,children:`Loading task settings…`}):e.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(Bl,{}),tone:`danger`,title:`Task settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,Q.jsx)(OT,{config:e.data})}function OT({config:e}){let t=ln(),n=wC();return(0,Q.jsxs)(`div`,{"data-slot":`tasks-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)(wT,{config:e}),(0,Q.jsx)($,{title:`Base branch`,hint:`New task worktrees branch from this and draft PRs target it. Also settable from the Git view.`,children:t.data?.info?(0,Q.jsxs)(`select`,{"aria-label":`Base branch`,"data-slot":`tasks-base-branch`,value:e.baseBranch??``,disabled:n.isPending,onChange:e=>n.mutate({baseBranch:e.target.value||null}),className:`block w-full max-w-md 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)`}),t.data.branches.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))]}):(0,Q.jsx)(`p`,{"data-slot":`tasks-base-branch-unavailable`,className:`text-ui text-soft-foreground`,children:t.isPending?`Loading branches…`:`Not a git repository — tasks run in place, no branching.`})}),(0,Q.jsx)($,{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)(ff,{"aria-label":`Review changes before finishing`,"data-slot":`tasks-review-gate`,checked:e.reviewGate??!1,disabled:n.isPending,onCheckedChange:e=>n.mutate({reviewGate:e},{onSuccess:()=>Y(e?`Review gate on`:`Review gate off`)})}),(0,Q.jsxs)(`span`,{className:`text-ui text-muted-foreground`,children:[e.reviewGate??!1?`On`:`Off`,e.reviewGate===null&&` (default)`]})]})}),(0,Q.jsx)($,{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)(ff,{"aria-label":`Live title updates`,"data-slot":`tasks-live-title-updates`,checked:e.liveTitleUpdates??!0,disabled:n.isPending,onCheckedChange:e=>n.mutate({liveTitleUpdates:e},{onSuccess:()=>Y(e?`Live title updates on`:`Live title updates off`)})}),(0,Q.jsxs)(`span`,{className:`text-ui text-muted-foreground`,children:[e.liveTitleUpdates??!0?`On`:`Off`,e.liveTitleUpdates===null&&` (default)`]})]})})]})}var kT=`/workspace/config-bundle`;async function AT(e,t={}){let n=Zn(e),r=new Headers(t.headers);r.set(dn,Ge());try{return await fetch(n,{...t,headers:r,credentials:`include`})}catch(e){throw e instanceof DOMException&&e.name===`AbortError`?e:new cn(0,`cannot reach the cezar server (${n})`,{cause:e})}}async function jT(e){let t=await e.text().catch(()=>``),n;try{let e=JSON.parse(t);typeof e?.error==`string`&&(n=e.error)}catch{}return new cn(e.status,n??`${e.status} ${e.statusText||`request failed`}`.trim())}async function MT(e,t,n){let r=await AT(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!r.ok)throw await jT(r);let i=n.safeParse(await r.json().catch(()=>void 0));if(!i.success)throw new cn(r.status,`the cezar server answered ${e} with an unexpected body`);return i.data}async function NT(e){let t=await AT(`${kT}${e===null?``:`?projects=${e.map(encodeURIComponent).join(`,`)}`}`);if(!t.ok)throw await jT(t);return{blob:await t.blob(),filename:PT(t.headers.get(`content-disposition`))}}function PT(e,t=new Date){let n=e?.match(/filename\*?=(?:UTF-8'')?"?([^";]+)"?/i);return n?.[1]?decodeURIComponent(n[1]):`cezar-config-${t.toISOString().slice(0,10)}.json`}function FT(e){return MT(`${kT}/preview`,e,cr)}function IT(e){return MT(`${kT}/import`,e,er)}function LT(e){if(e.trim()===``)return{ok:!1,error:`this file is empty`};if(e.length>5242880)return{ok:!1,error:`this file is larger than 5 MB`};let t;try{t=JSON.parse(e)}catch{return{ok:!1,error:`this file is not JSON`}}let n=ir.safeParse(t);if(n.success)return{ok:!0,bundle:n.data};let r=n.error.issues,i=r.find(e=>e.path[0]===`format`)??r.find(e=>e.path[0]===`version`)??r[0],a=i&&i.path.length>0&&i.path[0]!==`format`&&i.path[0]!==`version`?` (at ${i.path.join(`.`)})`:``;return{ok:!1,error:`${i?.message??`not a cezar configuration bundle`}${a}`}}var RT=[`secret values`,`tracker connections`,`agent accounts`,`webhooks`,`paths`],zT=`rounded-md border border-input bg-card px-2 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,BT=`__skip__`;function VT(){let e=C().data?.capabilities?.localHandoff??!0;return(0,Q.jsxs)(`div`,{"data-slot":`transfer-section`,className:`mx-auto flex w-full max-w-3xl flex-col gap-8 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,Q.jsx)(HT,{}),(0,Q.jsx)(KT,{localHandoff:e})]})}function HT(){let e=a(),t=(e.data?.projects??[]).filter(e=>e.status!==`missing`),[n,r]=(0,Z.useState)(new Set),i=t.filter(e=>!n.has(e.id)),o=H({mutationFn:()=>NT(i.length===t.length?null:i.map(e=>e.id)),onSuccess:({blob:e,filename:t})=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.append(r),r.click(),r.remove(),URL.revokeObjectURL(n),Y(`Downloaded ${t}`)},onError:e=>Y(e.message,{tone:`danger`})}),s=e=>r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,Q.jsx)($,{title:`Export`,hint:`Download this machine's portable settings — workspace preferences and, per project, its config, prompt templates and automations — as one JSON file.`,children:(0,Q.jsxs)(`div`,{"data-slot":`transfer-export`,className:`flex flex-col gap-3`,children:[e.isPending?(0,Q.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:`Loading projects…`}):t.length===0?(0,Q.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:`No projects registered — the file will carry workspace settings only.`}):(0,Q.jsxs)(`fieldset`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`legend`,{className:`mb-1 text-meta text-soft-foreground`,children:`Projects to include`}),t.map(e=>(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"data-slot":`transfer-export-project`,checked:!n.has(e.id),onChange:()=>s(e.id)}),(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name})]},e.id))]}),(0,Q.jsxs)(`p`,{"data-slot":`transfer-excluded`,className:`text-meta text-soft-foreground`,children:[`Not included: `,RT.join(`, `),`. Secret names and the tracker to reconnect travel as reminders.`]}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(J,{type:`button`,size:`sm`,"data-action":`transfer-download`,disabled:o.isPending||e.isPending,onClick:()=>o.mutate(),children:o.isPending?`Preparing…`:`Download`})})]})})}var UT={mapping:{},resolutions:{}};function WT(e,t){return{bundle:e,...t.selection?{selection:t.selection}:{},...Object.keys(t.mapping).length>0?{mapping:t.mapping}:{},...Object.keys(t.resolutions).length>0?{resolutions:t.resolutions}:{}}}function GT(){return(0,Q.jsx)($,{title:`Import`,hint:`Apply a configuration bundle exported from another cezar.`,children:(0,Q.jsx)(`p`,{"data-slot":`transfer-import-hosted`,className:`text-ui text-soft-foreground`,children:`Import is only available on a local cockpit.`})})}function KT({localHandoff:e}){let t=(0,Z.useId)(),n=(0,Z.useRef)(null),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(UT),[l,u]=(0,Z.useState)(null),d=dt({queryKey:[`transfer`,`preview`,r?.nonce,s],queryFn:()=>FT(WT(r.bundle,s)),enabled:r!==null&&e,retry:!1,gcTime:0,placeholderData:Dn}),f=H({mutationFn:e=>IT({...WT(r.bundle,s),planDigest:e.planDigest}),onSuccess:e=>{u(e.applied),Y(`Applied ${e.applied.length} section${e.applied.length===1?``:`s`}`)},onError:()=>void d.refetch()});if(!e||d.data?.importAllowed===!1)return(0,Q.jsx)(GT,{});let p=async e=>{let t=e.target.files?.[0];if(e.target.value=``,!t)return;if(u(null),f.reset(),c(UT),t.size>5242880){i(null),o(`this file is larger than 5 MB`);return}let n=LT(await t.text());if(!n.ok){i(null),o(n.error);return}o(null),i({name:t.name,bundle:n.bundle,nonce:Date.now()})},m=e=>{u(null),f.reset(),c(e)},h=r&&!d.isError?d.data:void 0,g=a??(r&&d.isError?d.error.message:null);return(0,Q.jsx)($,{title:`Import`,hint:`Apply a configuration bundle exported from another cezar. Nothing is written until you apply, and automations always land paused.`,children:(0,Q.jsxs)(`div`,{"data-slot":`transfer-import`,className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`input`,{ref:n,id:t,type:`file`,accept:`application/json,.json`,"data-slot":`transfer-import-file`,className:`sr-only`,onChange:e=>void p(e)}),(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>n.current?.click(),children:`Choose file…`}),(0,Q.jsx)(`label`,{htmlFor:t,className:`text-meta text-soft-foreground`,children:r?r.name:`A .json file from Settings → Transfer → Export`})]}),g?(0,Q.jsx)(`p`,{role:`alert`,"data-slot":`transfer-import-error`,className:`text-ui text-danger`,children:g}):null,r&&!h&&d.isFetching?(0,Q.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:`Reading the file…`}):null,h?(0,Q.jsx)(qT,{plan:h,choices:s,onChange:m,busy:d.isFetching,applying:f.isPending,applyError:f.isError?f.error.message:null,applied:l,onApply:()=>f.mutate(h)}):null]})})}function qT({plan:e,choices:t,onChange:n,busy:r,applying:i,applyError:o,applied:s,onApply:c}){let l=(a().data?.projects??[]).filter(e=>e.status!==`missing`),u=e=>t.selection?t.selection.includes(e.id):e.selected,d=e.sections.filter(u),f=d.filter(e=>e.issues.length>0),p=t=>n(n=>{let r=n.selection??e.sections.filter(e=>e.selected).map(e=>e.id),i=r.includes(t.id)?r.filter(e=>e!==t.id):[...r,t.id];return{...n,selection:i}}),m=(e,t,r)=>n(n=>{let i=n.resolutions[e]??{};return{...n,resolutions:{...n.resolutions,[e]:{...i,keys:{...i.keys,[t]:r}}}}}),h=(e,t,r)=>n(n=>{let i=n.resolutions[e]??{},a={...i.automations};return r?a[String(t)]=r:delete a[String(t)],{...n,resolutions:{...n.resolutions,[e]:{...i,automations:a}}}}),g=(e,t)=>n(n=>{let r={...n.mapping};return t===``?delete r[String(e)]:r[String(e)]=t===BT?null:t,{...n,mapping:r}}),_=t=>t===void 0?`Workspace`:e.projects.find(e=>e.index===t)?.name??`Project ${t+1}`,v=e=>l.find(t=>t.id===e)?.name??e;return(0,Q.jsxs)(`div`,{"data-slot":`transfer-preview`,"aria-busy":r,className:`flex flex-col gap-6`,children:[e.projects.length>0?(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Projects`}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:e.projects.map(e=>(0,Q.jsxs)(`li`,{"data-slot":`transfer-project`,"data-match":e.match,className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name}),e.remote?(0,Q.jsx)(`span`,{className:`text-meta text-soft-foreground`,children:e.remote}):null,(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`text-soft-foreground`,children:`→`}),(0,Q.jsx)(XT,{name:e.name,value:YT(t.mapping[String(e.index)],e.targetProjectId),registered:l,onChange:t=>g(e.index,t)}),e.match===`remote`?(0,Q.jsx)(`span`,{className:`text-meta text-soft-foreground`,children:`(same remote)`}):null]},e.index))})]}):null,(0,Q.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Sections`}),e.sections.length===0?(0,Q.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:`This file changes nothing on this machine.`}):e.sections.map(e=>(0,Q.jsx)(ZT,{section:e,title:`${_(e.projectIndex)} · ${JT[e.kind]}`,target:e.projectIndex===void 0?void 0:v(e.targetProjectId),checked:u(e),resolution:t.resolutions[e.id],onToggle:()=>p(e),onKey:(t,n)=>m(e.id,t,n),onRow:(t,n)=>h(e.id,t,n)},e.id))]}),(0,Q.jsx)(nE,{plan:e}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[f.length>0?(0,Q.jsx)(`p`,{"data-slot":`transfer-blocked`,className:`text-ui text-danger`,children:`Untick or fix the sections with problems before applying.`}):null,o?(0,Q.jsx)(`p`,{role:`alert`,"data-slot":`transfer-apply-error`,className:`text-ui text-danger`,children:o}):null,s?(0,Q.jsxs)(`p`,{"data-slot":`transfer-applied`,className:`text-ui text-foreground`,children:[`Applied `,s.length,` section`,s.length===1?``:`s`,`. Imported automations are paused — enable them on each project’s Automations page.`]}):null,(0,Q.jsx)(`div`,{children:(0,Q.jsx)(J,{type:`button`,size:`sm`,"data-action":`transfer-apply`,disabled:r||i||d.length===0||f.length>0||s!==null,onClick:c,children:i?`Applying…`:`Apply selected (${d.length})`})})]})]})}var JT={workspace:`settings`,config:`config`,promptTemplates:`prompt templates`,automations:`automations`};function YT(e,t){return e===null?BT:e??t??``}function XT({name:e,value:t,registered:n,onChange:r}){return(0,Q.jsxs)(`select`,{"aria-label":`Import ${e} into`,"data-slot":`transfer-mapping`,value:t,onChange:e=>r(e.target.value),className:zT,children:[(0,Q.jsx)(`option`,{value:``,children:`Choose a project…`}),n.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.name},e.id)),(0,Q.jsx)(`option`,{value:BT,children:`Skip`})]})}function ZT({section:e,title:t,target:n,checked:r,resolution:i,onToggle:a,onKey:o,onRow:s}){return(0,Q.jsxs)(`div`,{"data-slot":`transfer-section-card`,"data-section-id":e.id,className:`flex flex-col gap-2 rounded-lg border border-border bg-card p-3`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:r,onChange:a,"aria-label":t}),(0,Q.jsx)(`span`,{className:`font-medium`,children:t}),n?(0,Q.jsxs)(`span`,{className:`text-meta text-soft-foreground`,children:[`→ `,n]}):null,e.runsCommands?(0,Q.jsxs)($d,{variant:`outline`,"data-slot":`transfer-runs-commands`,className:`border-warning text-warning`,children:[(0,Q.jsx)(wc,{"aria-hidden":!0}),` runs shell commands`]}):null]}),e.issues.length>0?(0,Q.jsx)(`ul`,{"data-slot":`transfer-section-issues`,className:`text-meta text-danger`,children:e.issues.map(e=>(0,Q.jsx)(`li`,{children:e},e))}):null,e.changes.length>0?(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.changes.map(e=>(0,Q.jsx)($T,{change:e,value:i?.keys?.[e.key]??e.action,onChange:t=>o(e.key,t)},e.key))}):null,e.automations?.length?(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.automations.map(e=>(0,Q.jsx)(tE,{row:e,resolution:i?.automations?.[String(e.index)],onChange:t=>s(e.index,t)},e.index))}):null,e.changes.length===0&&!e.automations?.length?(0,Q.jsx)(`p`,{className:`text-meta text-soft-foreground`,children:`Nothing to change.`}):null]})}function QT(e){if(e===void 0)return`(not set)`;let t=typeof e==`string`?JSON.stringify(e):JSON.stringify(e)??String(e);return t.length>120?`${t.slice(0,119)}…`:t}function $T({change:e,value:t,onChange:n}){return(0,Q.jsxs)(`li`,{"data-slot":`transfer-change`,"data-key":e.key,className:`flex flex-wrap items-center gap-2 text-meta`,children:[(0,Q.jsx)(`code`,{className:`font-mono text-foreground`,children:e.key}),(0,Q.jsx)(`span`,{"data-slot":`transfer-change-from`,className:`font-mono text-soft-foreground`,children:QT(e.from)}),(0,Q.jsx)(`span`,{"aria-hidden":!0,children:`→`}),(0,Q.jsx)(`span`,{"data-slot":`transfer-change-to`,className:`font-mono text-foreground`,children:QT(e.to)}),e.conflict?(0,Q.jsxs)(`select`,{"aria-label":`${e.key}: keep or take`,"data-slot":`transfer-change-action`,value:t,onChange:e=>n(e.target.value),className:zT,children:[(0,Q.jsx)(`option`,{value:`keep`,children:`Keep this machine’s`}),(0,Q.jsx)(`option`,{value:`take`,children:`Take imported`})]}):(0,Q.jsxs)(`span`,{className:`text-soft-foreground`,children:[`(`,e.action===`take`?`new`:`unchanged`,`)`]})]})}var eE={create:`create`,skip:`skip`,rename:`rename`,replace:`replace`};function tE({row:e,resolution:t,onChange:n}){let r=r=>{if(!r){n(e.collision&&t?{...t,acceptCommands:void 0}:void 0);return}n(t?{...t,acceptCommands:!0}:{action:e.collision?`rename`:`create`,acceptCommands:!0})};return(0,Q.jsxs)(`li`,{"data-slot":`transfer-automation`,"data-index":e.index,className:`flex flex-col gap-1 text-meta`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:e.name}),(0,Q.jsx)(`span`,{className:`text-soft-foreground`,children:e.kind}),(0,Q.jsxs)($d,{variant:`secondary`,children:[eE[e.action],e.newName&&e.action===`rename`?` → ${e.newName}`:``]}),e.collision?(0,Q.jsxs)(`select`,{"aria-label":`${e.name}: on a name collision`,"data-slot":`transfer-automation-action`,value:t?.action??`skip`,onChange:e=>n({...t,action:e.target.value,newName:void 0}),className:zT,children:[(0,Q.jsx)(`option`,{value:`skip`,children:`Skip`}),(0,Q.jsx)(`option`,{value:`rename`,children:`Rename`}),e.collision.id?(0,Q.jsx)(`option`,{value:`replace`,children:`Replace (and pause)`}):null]}):null,e.runsCommands?(0,Q.jsxs)(`label`,{className:`flex items-center gap-1 text-warning`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"data-slot":`transfer-automation-accept`,checked:t?.acceptCommands===!0,onChange:e=>r(e.target.checked)}),(0,Q.jsx)(wc,{"aria-hidden":!0,className:`size-3`}),` runs shell commands — allow`]}):null]}),[...e.issues,...e.warnings].map(t=>(0,Q.jsx)(`span`,{className:e.issues.includes(t)?`text-danger`:`text-soft-foreground`,children:t},t))]})}function nE({plan:e}){let t=e.projects.filter(e=>e.reminders.secretNames.length>0||e.reminders.tracker);return e.reminders.workspaceSecretNames.length===0&&t.length===0?null:(0,Q.jsxs)(`section`,{"data-slot":`transfer-reminders`,className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Re-enter these secrets`}),(0,Q.jsx)(`p`,{className:`text-meta text-soft-foreground`,children:`A bundle never carries secret values or tracker credentials. Add them again on this machine after importing.`}),(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:[e.reminders.workspaceSecretNames.length>0?(0,Q.jsxs)(`li`,{"data-slot":`transfer-reminder`,"data-scope":`workspace`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:`Workspace secrets:`}),` `,e.reminders.workspaceSecretNames.join(`, `)]}):null,t.map(e=>(0,Q.jsxs)(`li`,{"data-slot":`transfer-reminder`,"data-scope":`project:${e.index}`,children:[(0,Q.jsxs)(`span`,{className:`font-medium`,children:[e.name,`:`]}),` `,e.reminders.secretNames.length>0?`secrets ${e.reminders.secretNames.join(`, `)}`:null,e.reminders.secretNames.length>0&&e.reminders.tracker?`; `:null,e.reminders.tracker?`reconnect the ${e.reminders.tracker} tracker`:null]},e.index))]})]})}function rE(){let e=Tt(),t=Fr(),n=En(),[r,i]=(0,Z.useState)(null),a=t.data?.worktrees??[],o=!!n.data?.worktreeLifecycle&&(n.data.worktreeLifecycle.afterCreate.length>0||n.data.worktreeLifecycle.beforeRemove.length>0),s=U(),[c,l]=(0,Z.useState)(null),u=async()=>{await Promise.all([s.invalidateQueries({queryKey:V.worktrees}),s.invalidateQueries({queryKey:Pr.all()})])},d=H({mutationFn:()=>lt(),onSuccess:e=>{u(),Y(e.reclaimed.length===0?o||a.some(e=>e.operation||e.autoCleanupSuppressed)?`No worktrees reclaimed yet. Pending cleanup or retained worktrees may keep usage above the limit.`:`Nothing to reclaim — all worktrees are within the limit`:`Reclaimed ${e.reclaimed.length} worktree${e.reclaimed.length===1?``:`s`} (branch kept)`)},onError:e=>Y(e.message,{tone:`danger`})}),f=H({mutationFn:async e=>o||a.some(t=>t.runId===e)?z({requestId:crypto.randomUUID(),runId:e,intent:`remove-worktree`}):wt(e),onSuccess:(t,n)=>{u(),`operation`in t?(i({id:t.operation.id,title:e.data?.worktrees.find(e=>e.runId===n)?.title??n}),Y(`Cleanup requested. The worktree remains until cleanup and removal complete.`)):Y(`Worktree removed`)},onError:e=>Y(e.message,{tone:`danger`})}),p=H({mutationFn:e=>z({requestId:crypto.randomUUID(),worktreeId:e,intent:`orphan`}),onSuccess:e=>{i({id:e.operation.id,title:`Orphan worktree`}),u(),Y(`Orphan cleanup requested. Review its progress below.`)},onError:e=>Y(e.message,{tone:`danger`})});if(e.isPending)return(0,Q.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-ui text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,Q.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-ui text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:m,totalBytes:h,keep:g}=e.data,v=d.isPending||f.isPending||p.isPending;return(0,Q.jsxs)(`div`,{"data-slot":`worktrees-panel`,className:`flex flex-col gap-3`,children:[m.length===0?(0,Q.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`text-ui text-soft-foreground`,children:`No task worktrees on disk.`}):(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:`Task worktrees currently materialized on disk`}),(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{className:`border-b border-border text-left text-label text-soft-foreground`,children:[(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Task`}),(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:`Size`}),(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Age`}),(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium text-right`,children:`Actions`})]})}),(0,Q.jsx)(`tbody`,{children:m.map(e=>(0,Q.jsx)(iE,{worktree:e,lifecycle:a.find(t=>t.runId===e.runId),disabled:v||!!a.find(t=>t.runId===e.runId)?.operation,onDelete:()=>l({kind:`delete`,runId:e.runId,title:e.title})},e.runId))})]})}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`p`,{"data-slot":`worktrees-footer`,className:`text-label text-soft-foreground`,children:[m.length,` worktree`,m.length===1?``:`s`,h===null?` · size unavailable`:` · ${_(h)||`0 kB`} on disk`,` · `,g===0?`keeping all (unlimited)`:`keeping the last ${g}`]}),(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,"data-action":`worktrees-reclaim-now`,disabled:v,onClick:()=>l({kind:`reclaim`}),children:`Reclaim now`})]}),t.isError&&(0,Q.jsxs)(`p`,{className:`text-xs text-danger`,role:`alert`,children:[`Lifecycle state could not be loaded: `,t.error.message]}),a.filter(e=>e.operation||e.autoCleanupSuppressed||e.needsAttention||!e.task).map(e=>(0,Q.jsxs)(`section`,{className:`min-w-0 rounded-md border border-border p-3`,"data-slot":`lifecycle-worktree-row`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium`,children:e.task?.title??`Orphan worktree ${e.runId.slice(0,8)}`}),(0,Q.jsx)(`p`,{className:`break-all font-mono text-meta text-muted-foreground`,children:e.worktreePath}),e.error&&(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-danger`,children:e.error}),e.needsAttention&&(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-danger`,children:[e.operation?.phase===`setup`?`Setup needs attention`:`Cleanup needs attention`,` — worktree retained.`]}),e.autoCleanupSuppressed&&(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Automatic cleanup is suppressed for this generation because it was kept or cancelled. Explicit removal is still available.`}),e.operation?(0,Q.jsx)(`div`,{id:`lifecycle-operation-${e.operation.id}`,className:`mt-3 scroll-mt-4`,children:(0,Q.jsx)(No,{operationId:e.operation.id,worktreePath:e.worktreePath,taskTitle:e.task?.title})}):!e.task&&!e.error&&e.onDisk?(0,Q.jsx)(J,{className:`mt-2`,type:`button`,variant:`outline`,size:`sm`,disabled:v,onClick:()=>l({kind:`orphan`,worktreeId:e.worktreeId,title:e.worktreePath}),children:`Remove orphan worktree`}):null]},e.worktreeId)),r&&!a.some(e=>e.operation?.id===r.id)&&(0,Q.jsx)(`div`,{id:`lifecycle-operation-${r.id}`,children:(0,Q.jsx)(No,{operationId:r.id,taskTitle:r.title})}),(0,Q.jsx)(Vc,{open:c!==null,onOpenChange:e=>!e&&l(null),children:(0,Q.jsxs)(Ic,{children:[(0,Q.jsxs)(Bc,{children:[(0,Q.jsx)(Fc,{children:c?.kind===`delete`||c?.kind===`orphan`?`Delete this worktree?`:`Reclaim old worktrees?`}),(0,Q.jsx)(Pc,{children:c?.kind===`delete`||c?.kind===`orphan`?(0,Q.jsxs)(Q.Fragment,{children:[`This removes the worktree directory and its branch — the local-only work is not recoverable afterwards. Configured cleanup scripts run first; failures retain the directory for your recovery choice.`,(0,Q.jsx)(`span`,{className:`mt-1 block truncate font-medium text-foreground`,title:c.title,children:c.title})]}):`Finished worktrees beyond the keep-limit are reclaimed now (directory only). Their branches are kept, so the work stays recoverable.`})]}),(0,Q.jsxs)(Rc,{children:[(0,Q.jsx)(zc,{children:`Keep it`}),(0,Q.jsx)(Lc,{"data-action":`worktrees-confirm`,className:c?.kind===`delete`||c?.kind===`orphan`?`bg-danger text-danger-foreground hover:brightness-[0.96]`:void 0,onClick:()=>{c?.kind===`reclaim`?d.mutate():c?.kind===`delete`?f.mutate(c.runId):c?.kind===`orphan`&&p.mutate(c.worktreeId),l(null)},children:c?.kind===`delete`||c?.kind===`orphan`?`Delete`:`Reclaim now`})]})]})})]})}function iE({worktree:e,lifecycle:t,disabled:n,onDelete:r}){return(0,Q.jsxs)(`tr`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`border-b border-border last:border-0`,children:[(0,Q.jsxs)(`th`,{scope:`row`,className:`max-w-[220px] px-3 py-2 text-left font-normal`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-foreground`,title:e.title,children:e.title}),(0,Q.jsx)(`span`,{className:`block truncate font-mono text-meta text-soft-foreground`,children:e.branch??e.runId.slice(0,8)})]}),(0,Q.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-label text-soft-foreground`,children:e.status}),t?.needsAttention&&(0,Q.jsx)(`span`,{className:`block text-meta text-danger`,children:t.operation?.phase===`setup`?`Setup needs attention`:`Cleanup needs attention`}),t?.autoCleanupSuppressed&&(0,Q.jsx)(`span`,{className:`block text-meta text-muted-foreground`,children:`Automatic cleanup suppressed`}),e.inUse?(0,Q.jsxs)(`span`,{"data-slot":`worktree-in-use`,className:`block text-meta text-muted-foreground`,title:e.inUse,children:[`Protected — `,e.inUse]}):null,e.reclaimable&&!t?.autoCleanupSuppressed?(0,Q.jsx)(`span`,{"data-slot":`worktree-reclaimable`,className:`ml-1 text-meta text-soft-foreground`,children:`(reclaimable)`}):null]}),(0,Q.jsx)(`td`,{className:`px-3 py-2 tabular-nums text-soft-foreground`,children:e.sizeBytes===null?`—`:_(e.sizeBytes)||`0 kB`}),(0,Q.jsx)(`td`,{className:`px-3 py-2 tabular-nums text-soft-foreground`,children:Xc(e.finishedAt??void 0)||`—`}),(0,Q.jsx)(`td`,{className:`px-3 py-2 text-right`,children:(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`worktree-delete`,"aria-label":`Delete the worktree for ${e.title}`,title:e.inUse?`Protected — ${e.inUse}`:void 0,disabled:n||!!e.inUse,onClick:r,children:`Delete`})})]})}var aE=()=>({afterCreate:[],beforeRemove:[]}),oE=[`afterCreate`,`beforeRemove`],sE={afterCreate:`After worktree creation`,beforeRemove:`Before worktree removal`},cE=[[`root_path`,`The selected project’s root directory`],[`worktree_path`,`The isolated worktree directory`],[`worktree_id`,`Stable cez-prefixed resource identity`],[`task_id`,`The original task ID`]],lE=`w-full rounded-md border border-input bg-card px-3 py-2 text-sm outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`;function uE({config:e}){let t=U(),n=V.config,r=(0,Z.useRef)(!0);(0,Z.useEffect)(()=>(r.current=!0,()=>{r.current=!1}),[]);let i=Fr(),[a,o]=(0,Z.useState)(e.worktreeLifecycle??aE()),[c,l]=(0,Z.useState)(e.worktreeLifecycle??aE()),[u,d]=(0,Z.useState)(e.worktreeLifecycleRevision??null),[f,p]=(0,Z.useState)({}),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)({}),[b,x]=(0,Z.useState)(null),S=(0,Z.useRef)(new Map),C=(0,Z.useRef)({draft:a,previewWorktree:g});C.current={draft:a,previewWorktree:g};let w=JSON.stringify(a)!==JSON.stringify(c);(0,Z.useEffect)(()=>{if(w)return;let t=e.worktreeLifecycle??aE();o(t),l(t),d(e.worktreeLifecycleRevision??null)},[e.worktreeLifecycle,e.worktreeLifecycleRevision,w]);let T=(e,t,n)=>{o(r=>({...r,[e]:r[e].map(e=>e.id===t?{...e,...n}:e)})),p(e=>({...e,[t]:``})),h(``),y(e=>{let n={...e};return delete n[t],n})},E=(e,t,n)=>{let r=S.current.get(t.id),i=r?.selectionStart??t.command.length,a=r?.selectionEnd??i,o=`{{ ${n} }}`;T(e,t.id,{command:t.command.slice(0,i)+o+t.command.slice(a)}),requestAnimationFrame(()=>{r?.focus(),r?.setSelectionRange(i+o.length,i+o.length)})},D=(e,t,n)=>{o(r=>{let i=[...r[e]],a=i.splice(t,1)[0];return i.splice(t+n,0,a),{...r,[e]:i}}),h(``)},O=async e=>{x(e.id);try{let t=await Ke({command:e.command,...g?{worktreeId:g}:{}}),n=oE.flatMap(e=>C.current.draft[e]).find(t=>t.id===e.id);if(!r.current||n?.command!==e.command||C.current.previewWorktree!==g)return;y(n=>({...n,[e.id]:t})),p(t=>({...t,[e.id]:``}))}catch(t){p(n=>({...n,[e.id]:t instanceof Error?t.message:`Preview failed`}))}finally{x(null)}},k=H({mutationFn:async()=>{p({}),h(``);let e=Xn.safeParse(a);if(!e.success){let t={};for(let n of e.error.issues){let e=n.path[0],r=typeof n.path[1]==`number`?a[e]?.[n.path[1]]?.id:void 0;t[r??`form`]=n.message}throw p(t),Error(`Check the highlighted commands before saving.`)}for(let t of oE)for(let n of e.data[t]){if(!r.current)throw Error(`Settings closed; saving cancelled.`);try{await Ke({command:n.command})}catch(e){throw p({[n.id]:e instanceof Error?e.message:`Invalid template`}),Error(`Check the highlighted command before saving.`)}}if(!r.current)throw Error(`Settings closed; saving cancelled.`);return ve({worktreeLifecycle:e.data,worktreeLifecycleRevision:u})},onSuccess:e=>{let r=e.worktreeLifecycle??aE();l(r),o(r),d(e.worktreeLifecycleRevision??null),t.setQueryData(n,e),h(`Saved. Retry uses these commands. Saving does not restart paused scripts.`)}}),A=async()=>{try{let e=await s();t.setQueryData(n,e);let r=e.worktreeLifecycle??aE();o(r),l(r),d(e.worktreeLifecycleRevision??null),p({}),y({}),h(`Loaded saved scripts.`),k.reset()}catch(e){p({form:e instanceof Error?e.message:`Settings could not be loaded`})}},j=i.data?.worktrees.filter(e=>e.operation&&e.needsAttention)??[];return(0,Q.jsxs)(`div`,{id:`worktree-lifecycle-scripts`,className:`flex min-w-0 flex-col gap-5`,"data-slot":`worktree-lifecycle-editor`,children:[(0,Q.jsxs)(`div`,{className:`rounded-md border border-border bg-muted/30 p-3 text-ui text-muted-foreground`,children:[(0,Q.jsx)(`p`,{children:`Scripts apply only to this project. Saving commands opts in to running them as the Cezar host user, with that user’s local privileges.`}),(0,Q.jsx)(`p`,{className:`mt-1`,children:`Runtime: noninteractive Bash, in the isolated worktree directory. Bash must be installed on the host. Commands run in order; the default timeout is 30 minutes.`}),(0,Q.jsxs)(`p`,{className:`mt-1`,id:`lifecycle-variable-help`,children:[`Values are shell-escaped; do not wrap variable tokens in quotes. Use `,(0,Q.jsx)(`code`,{children:`\\{{`}),` for literal double braces, for example `,(0,Q.jsx)(`code`,{children:`docker inspect --format '\\{{.State.Status}}' container`}),`.`]})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[`Preview context`,(0,Q.jsxs)(`select`,{value:g,className:lE,onChange:e=>{_(e.target.value),y({})},children:[(0,Q.jsx)(`option`,{value:``,children:`Example values (illustrative)`}),i.data?.worktrees.filter(e=>e.onDisk).map(e=>(0,Q.jsx)(`option`,{value:e.worktreeId,children:e.task?.title??`Orphan ${e.runId.slice(0,8)}`},e.worktreeId))]})]}),oE.map(e=>(0,Q.jsxs)($,{title:sE[e],hint:e===`afterCreate`?`Run after a worktree is created and before its agent starts, including recreation after reclamation.`:`Run while the worktree files still exist, before removal or reclamation. Failure retains the directory for recovery.`,children:[a[e].length===0&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No commands. This phase completes without running a script.`}),a[e].map((t,n)=>(0,Q.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-2 rounded-md border border-border p-3`,disabled:k.isPending,children:[(0,Q.jsxs)(`legend`,{className:`px-1 text-xs font-medium`,children:[`Command `,n+1]}),(0,Q.jsx)(`label`,{className:`text-xs`,htmlFor:`lifecycle-name-${t.id}`,children:`Display name (optional)`}),(0,Q.jsx)(`input`,{id:`lifecycle-name-${t.id}`,className:lE,value:t.name??``,maxLength:120,onChange:n=>T(e,t.id,{name:n.target.value})}),(0,Q.jsxs)(`label`,{className:`text-xs`,htmlFor:`lifecycle-command-${t.id}`,children:[sE[e],` — command `,n+1]}),(0,Q.jsx)(`textarea`,{id:`lifecycle-command-${t.id}`,ref:e=>{e?S.current.set(t.id,e):S.current.delete(t.id)},className:`${lE} min-h-24 resize-y font-mono text-xs`,value:t.command,maxLength:32*1024,spellCheck:!1,"aria-describedby":`lifecycle-variable-help${f[t.id]?` lifecycle-error-${t.id}`:``}`,"aria-invalid":!!f[t.id],onChange:n=>T(e,t.id,{command:n.target.value})}),f[t.id]&&(0,Q.jsx)(`p`,{id:`lifecycle-error-${t.id}`,className:`text-xs text-danger`,role:`alert`,children:f[t.id]}),(0,Q.jsxs)(`details`,{className:`text-xs`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer py-1`,children:`Variables`}),(0,Q.jsx)(`ul`,{className:`mt-1 space-y-2`,children:cE.map(([r,i])=>(0,Q.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,"aria-label":`Insert ${r} into ${sE[e].toLowerCase()} command ${n+1}`,onClick:()=>E(e,t,r),children:(0,Q.jsx)(`code`,{children:`{{ ${r} }}`})}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:i})]},r))})]}),(0,Q.jsxs)(`details`,{className:`text-xs`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer py-1`,children:`Advanced timeout`}),(0,Q.jsxs)(`label`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[`Timeout in seconds (1–86,400; blank uses 1,800)`,(0,Q.jsx)(`input`,{type:`number`,min:1,max:86400,step:1,className:`${lE} max-w-32`,value:t.timeoutSeconds??``,onChange:n=>T(e,t.id,{timeoutSeconds:n.target.value===``?void 0:Number(n.target.value)})})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:n===0,"aria-label":`Move ${sE[e].toLowerCase()} command ${n+1} up`,onClick:()=>D(e,n,-1),children:`Move up`}),(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:n===a[e].length-1,"aria-label":`Move ${sE[e].toLowerCase()} command ${n+1} down`,onClick:()=>D(e,n,1),children:`Move down`}),(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":`Remove ${sE[e].toLowerCase()} command ${n+1}`,onClick:()=>{o(n=>({...n,[e]:n[e].filter(e=>e.id!==t.id)})),h(``)},children:`Remove`}),(0,Q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:!t.command.trim()||b!==null,"aria-label":`Preview ${sE[e].toLowerCase()} command ${n+1}`,onClick:()=>void O(t),children:b===t.id?`Previewing…`:`Preview`})]}),v[t.id]&&(0,Q.jsxs)(`div`,{className:`min-w-0 rounded bg-muted p-2 text-xs`,children:[(0,Q.jsx)(`p`,{className:`font-medium`,children:v[t.id].illustrative?`Example preview — illustrative values`:`Selected worktree preview`}),(0,Q.jsxs)(`p`,{className:`break-all text-muted-foreground`,children:[`Working directory: `,v[t.id].cwd]}),(0,Q.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-all`,children:v[t.id].renderedCommand}),(0,Q.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:`Preview does not execute commands or expand shell expressions.`})]})]},t.id)),(0,Q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,className:`self-start`,disabled:a[e].length>=32||k.isPending,onClick:()=>{o(t=>({...t,[e]:[...t[e],{id:crypto.randomUUID(),command:``}]})),h(``)},children:[`Add `,e===`afterCreate`?`setup`:`cleanup`,` command`]})]},e)),(f.form||k.error)&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:f.form??k.error?.message}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(J,{type:`button`,disabled:!w||k.isPending,onClick:()=>k.mutate(),children:k.isPending?`Saving…`:`Save scripts`}),k.isError&&(0,Q.jsx)(J,{type:`button`,variant:`outline`,onClick:()=>void A(),children:`Reload saved scripts`})]}),m&&(0,Q.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:m}),j.length>0&&(0,Q.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,Q.jsx)(`p`,{children:`Paused scripts wait for an explicit recovery choice.`}),j.map(e=>(0,Q.jsxs)(`a`,{className:`mt-1 block text-primary underline`,href:`#lifecycle-operation-${e.operation.id}`,children:[`Return to `,e.task?.title??`orphan worktree`,` and Retry`]},e.worktreeId))]})]})}var dE=0,fE=1e3;function pE(){let e=En();return e.isPending?(0,Q.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`p-4 text-ui text-soft-foreground md:p-6`,children:`Loading worktree settings…`}):e.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(Ol,{}),tone:`danger`,title:`Worktree settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,Q.jsx)(mE,{config:e.data})}function mE({config:e}){let t=U(),n=H({mutationFn:e=>ve(e),onSuccess:e=>t.setQueryData(V.config,e),onError:e=>Y(e.message,{tone:`danger`})}),[r,i]=(0,Z.useState)(String(e.worktreeRetention)),a=Number(r),o=r.trim()===``||!Number.isInteger(a)||a<dE||a>fE,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)($,{title:`Keep last N 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:dE,max:fE,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)(J,{type:`button`,variant:`outline`,size:`sm`,"data-action":`resources-save-retention`,disabled:s||o||n.isPending,onClick:()=>n.mutate({worktreeRetention:a},{onSuccess:()=>{t.invalidateQueries({queryKey:V.worktrees}),Y(a===0?`Keeping all worktrees (unlimited)`:`Keeping the last ${a} finished worktree${a===1?``:`s`}`)}}),children:`Save`})]}),o?(0,Q.jsxs)(`p`,{"data-slot":`resources-retention-invalid`,className:`text-meta text-danger`,children:[`Enter a whole number from `,dE,` to `,fE,` (0 = unlimited).`]}):(0,Q.jsx)(`p`,{className:`text-meta text-soft-foreground`,children:a===0?`Keeping every finished worktree.`:`Keeping the last ${a} finished worktree${a===1?``:`s`} on disk.`})]}),(0,Q.jsx)(uE,{config:e}),(0,Q.jsx)($,{title:`Worktrees`,hint:`Task worktrees currently on disk. Delete one to reclaim its space now, or reclaim everything past the keep-limit at once. Reclamation keeps branches; deleting a worktree also deletes its managed branch.`,children:(0,Q.jsx)(rE,{})})]})}function hE(){let e=xn(),t=c(),n=U(),[r,i]=(0,Z.useState)(`jira`),[a,o]=(0,Z.useState)(null),[s,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(``),m=()=>{p(``),d(``),l(``),o(null)};(0,Z.useEffect)(()=>{m(),g(!1),b(null)},[$n()]);let[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(null),x=yt(r,_,h),S=x.data?.pages??[],C=S.find(e=>e.available)?.available?S.find(e=>e.available).source:void 0,w=(0,Z.useMemo)(()=>S.flatMap(e=>e.available?e.candidates:[]),[S]);(0,Z.useEffect)(()=>{g(!1),b(null),m()},[e.data?.connection?.id]);let T=S.find(e=>!e.available),E=async e=>{await n.invalidateQueries({queryKey:V.tracker.allFor(e)}),await n.invalidateQueries({queryKey:B.projects})},D=H({mutationFn:async()=>{if(!y||!C)throw Error(`Choose a tracker project first.`);let t=$n(),n=V.tracker.associationFor(t);return{...await kn({kind:r,sourceId:C.id,externalId:y.id,...e.data?.connection?{connectionId:e.data.connection.id}:{}}),projectId:t,associationKey:n}},onSuccess:async e=>{await Promise.all([n.cancelQueries({queryKey:V.tracker.allFor(e.projectId)}),n.cancelQueries({queryKey:B.projects})]),n.setQueryData(e.associationKey,{association:e.association}),g(!1),b(null),await E(e.projectId),Y(`${e.association.externalName} connected`)},onError:e=>Y(e.message,{tone:`danger`})}),O=H({mutationFn:async()=>{let e=$n(),t=V.tracker.associationFor(e);return{...await pe(),projectId:e,associationKey:t}},onSuccess:async e=>{await Promise.all([n.cancelQueries({queryKey:V.tracker.allFor(e.projectId)}),n.cancelQueries({queryKey:B.projects})]),n.setQueryData(e.associationKey,{association:null}),await E(e.projectId),Y(`Tracker disconnected`)},onError:e=>Y(e.message,{tone:`danger`})}),k=H({onMutate:()=>$n(),mutationFn:async()=>{let e=$n();if(!a)throw Error(`Choose a provider.`);return{...await Oe(a===`jira`?{kind:`jira`,origin:s.trim(),email:u.trim(),token:f}:{kind:`linear`,key:f}),projectId:e}},onSuccess:async e=>{$n()===e.projectId&&(m(),g(!1),b(null)),await n.cancelQueries({queryKey:V.tracker.allFor(e.projectId)}),n.setQueryData([`tracker`,e.projectId,`connection`],{connection:e.connection,demo:e.demo}),await E(e.projectId),Y(`Credentials saved for this project. Browse and connect a scope.`)},onError:(e,t,n)=>{$n()===n&&p(``),Y(e.message,{tone:`danger`})}}),A=H({mutationFn:async()=>{let e=$n();return await Kt(),e},onSuccess:async e=>{$n()===e&&(m(),g(!1),b(null)),await n.cancelQueries({queryKey:V.tracker.allFor(e)}),n.setQueryData([`tracker`,e,`connection`],{connection:null,demo:!1}),await E(e),Y(`Project credentials removed`)},onError:e=>Y(e.message,{tone:`danger`})}),j=k.isPending||A.isPending,M=t.data?.association,N=e.data?.connection,P=!!M&&(e.data?.demo===!0||!!N&&N.kind===M.kind&&N.id===M.connectionId);return t.isPending?(0,Q.jsx)(`p`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading tracker settings…`}):t.isError?(0,Q.jsx)(`p`,{className:`p-6 text-sm text-danger`,children:t.error.message}):(0,Q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col gap-6 p-4 md:p-6`,"data-slot":`tracker-settings`,children:[(0,Q.jsxs)(`section`,{className:`rounded-lg border border-border bg-card p-4`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Issue tracker`}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Connect a project or team from your issue tracker. Credentials belong only to this project and are stored locally outside the repository. Server-wide environment keys are not used.`}),P&&t.data.association?(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 rounded-md border border-border p-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-medium`,children:t.data.association.externalName}),(0,Q.jsxs)(`a`,{className:`inline-flex items-center gap-1 text-xs text-violet hover:underline`,href:t.data.association.source.webUrl,target:`_blank`,rel:`noreferrer`,children:[uu[t.data.association.kind].label,` `,(0,Q.jsx)(ic,{className:`size-3`})]})]}),(0,Q.jsxs)(J,{variant:`outline`,onClick:()=>O.mutate(),disabled:O.isPending,children:[(0,Q.jsx)(cu,{className:`size-3.5`}),` Disconnect`]})]}):(0,Q.jsx)(`p`,{className:`mt-4 text-sm font-medium`,children:e.isPending?`Loading connection…`:e.isError?`Connection status unavailable.`:`No tracker connected.`})]}),M&&N&&!e.isError&&!e.data?.demo&&!P?(0,Q.jsx)(`p`,{className:`text-sm text-warning`,children:`This scope needs reconnection with this project's credentials. Configure a connection, then browse and select its scope again.`}):null,e.data?.error?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:e.data.error}):null,(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`For local credential cleanup, run `,(0,Q.jsx)(`code`,{children:`cez tracker-connections list`}),`, then `,(0,Q.jsx)(`code`,{children:`cez tracker-connections remove <id>`}),`. Local deletion does not revoke the vendor token.`]}),e.isError?(0,Q.jsxs)(`p`,{className:`text-sm text-danger`,children:[`Could not load project connection. `,(0,Q.jsx)(`button`,{onClick:()=>void e.refetch(),children:`Retry`})]}):null,(0,Q.jsxs)(`section`,{className:`rounded-lg border border-border bg-card p-4`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Connect a provider`}),(0,Q.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:du.map(t=>{let n=!e.isError&&(e.data?.demo===!0||e.data?.connection?.kind===t.kind);return(0,Q.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,Q.jsx)(`p`,{className:`font-medium`,children:t.label}),e.data?.demo?null:(0,Q.jsxs)(J,{variant:`outline`,disabled:j||e.isPending||e.isError,onClick:()=>{m(),o(t.kind),g(!1),b(null)},children:[e.data?.connection?.kind===t.kind?`Replace`:`Configure`,` `,t.label,` credentials`]}),(0,Q.jsxs)(J,{className:`mt-3`,variant:`outline`,disabled:!n||j,onClick:()=>{i(t.kind),g(!0),v(``),b(null)},children:[(0,Q.jsx)(Ta,{className:`size-3.5`}),` Browse `,t.label]}),n?null:(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`Configure credentials for this project to browse.`})]},t.kind)})})]}),e.data?.connection?(0,Q.jsx)(J,{variant:`outline`,disabled:j,onClick:()=>A.mutate(),children:`Remove project credentials`}):null,a?(0,Q.jsxs)(`form`,{className:`rounded-lg border border-border bg-card p-4`,onSubmit:e=>{e.preventDefault(),k.mutate()},autoComplete:`off`,children:[(0,Q.jsxs)(`h2`,{className:`font-medium`,children:[uu[a].label,` credentials for this project`]}),(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`Saved in a private .env file for this project, without encryption. Use read-only access limited to this project's data. Saving replaces this project's connection and requires selecting its scope again.`}),a===`jira`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`label`,{className:`mt-3 block text-sm`,children:[`Jira site URL`,(0,Q.jsx)(`input`,{"aria-label":`Jira site URL`,type:`url`,required:!0,value:s,onChange:e=>l(e.target.value),placeholder:`https://your-site.atlassian.net`,className:`mt-1 block w-full rounded border bg-background p-2`})]}),(0,Q.jsxs)(`label`,{className:`mt-3 block text-sm`,children:[`Account email`,(0,Q.jsx)(`input`,{"aria-label":`Account email`,type:`email`,required:!0,value:u,onChange:e=>d(e.target.value),className:`mt-1 block w-full rounded border bg-background p-2`})]})]}):null,(0,Q.jsxs)(`label`,{className:`mt-3 block text-sm`,children:[`API token`,(0,Q.jsx)(`input`,{"aria-label":`API token`,type:`password`,autoComplete:`new-password`,required:!0,maxLength:8192,value:f,onChange:e=>p(e.target.value),className:`mt-1 block w-full rounded border bg-background p-2`})]}),(0,Q.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Q.jsx)(J,{type:`submit`,disabled:j,children:`Save project credentials`}),(0,Q.jsx)(J,{type:`button`,variant:`outline`,disabled:j,onClick:m,children:`Cancel`})]})]}):null,h?(0,Q.jsxs)(`section`,{className:`rounded-lg border border-violet/40 bg-card p-4`,"aria-label":`${uu[r].label} picker`,children:[(0,Q.jsxs)(`label`,{className:`text-xs font-medium`,htmlFor:`tracker-candidate-search`,children:[`Search `,uu[r].scopeLabel]}),(0,Q.jsx)(`input`,{id:`tracker-candidate-search`,className:`mt-2 h-9 w-full rounded-md border border-border bg-background px-3 text-sm`,value:_,onChange:e=>{v(e.target.value),b(null)},placeholder:`Search by name…`}),(0,Q.jsxs)(`div`,{className:`mt-3 max-h-64 space-y-1 overflow-auto`,children:[x.isPending?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading…`}):null,x.isError?(0,Q.jsx)(gE,{reason:x.error.message,generation:x.errorUpdatedAt,retry:()=>void x.refetch()}):null,T&&!T.available?(0,Q.jsx)(gE,{reason:T.reason,generation:x.dataUpdatedAt,retryAfterSeconds:T.code===`rate_limited`?T.retryAfterSeconds:void 0,retry:()=>void x.refetch()}):null,w.map(e=>(0,Q.jsx)(`button`,{type:`button`,className:`block w-full rounded-md border px-3 py-2 text-left text-sm ${y?.id===e.id?`border-violet bg-violet/10`:`border-border`}`,onClick:()=>b(e),children:e.name},e.id)),!x.isPending&&!x.isError&&!T&&w.length===0?(0,Q.jsx)(`p`,{className:`py-3 text-sm text-muted-foreground`,children:`No projects or teams match.`}):null,x.hasNextPage?(0,Q.jsx)(J,{variant:`ghost`,onClick:()=>void x.fetchNextPage(),disabled:x.isFetchingNextPage,children:`Load more`}):null]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex gap-2`,children:[(0,Q.jsx)(J,{variant:`contrast`,disabled:!y||D.isPending||j,onClick:()=>D.mutate(),children:`Connect`}),(0,Q.jsx)(J,{variant:`ghost`,onClick:()=>g(!1),children:`Cancel`})]})]}):null]})}function gE({reason:e,retry:t,retryAfterSeconds:n=0,generation:r}){let[i,a]=(0,Z.useState)(n);return(0,Z.useEffect)(()=>a(n),[e,n,r]),(0,Z.useEffect)(()=>{if(i<=0)return;let e=window.setInterval(()=>a(e=>Math.max(0,e-1)),1e3);return()=>window.clearInterval(e)},[i>0]),(0,Q.jsxs)(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 p-3 text-sm`,children:[(0,Q.jsx)(`p`,{className:`text-danger`,children:e}),(0,Q.jsx)(J,{className:`mt-2`,variant:`outline`,disabled:i>0,onClick:t,children:i>0?`Retry in ${i}s`:`Retry`})]})}var _E={checks:`Check steps (workflow commands)`,cezar:`cezar itself (its own features — not the agents)`};function vE(e){return e===`keychain`?`Encrypted with a data key kept in your OS keychain.`:`Encrypted with a data key in ~/.cezar/secrets/.key (0600) — no OS keychain is available on this machine, so this is a private file, not a vault.`}function yE({scope:e,list:t,save:n,remove:r,invalidate:i}){let a=U(),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)([`checks`]),[f,p]=(0,Z.useState)(null),m=o===``?null:lr(o),h=H({mutationFn:async()=>{let e=$n();return await n(o,{value:c,audiences:u}),{projectId:e,saved:o}},onSuccess:async({projectId:e,saved:t})=>{$n()===e&&(s(``),l(``),p(null)),await i(a,e),Y(`${t} saved`)},onError:e=>p(e.message)}),g=H({mutationFn:async e=>{let t=$n();return await r(e),{projectId:t,removed:e}},onSuccess:async({projectId:e,removed:t})=>{await i(a,e),Y(`${t} removed`)},onError:e=>Y(e.message,{tone:`danger`})}),_=()=>{let e=lr(o);if(e){p(e);return}if(u.length===0){p(`pick at least one audience`);return}p(null),h.mutate()},v=e=>d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),y=e===`project`?`Project secrets`:`Workspace secrets`,b=e===`project`?`Values for this project only — an e2e runner’s model key, a staging login. They reach the audiences you pick and never an agent session.`:`Values shared by every project on this machine — a key cezar’s own features use, a token every project’s checks need. A project secret of the same name wins. They never reach an agent session.`,x=t.data?.secrets??[];return(0,Q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col gap-6 p-4 md:p-6`,"data-slot":`secrets-settings`,"data-scope":e,children:[(0,Q.jsxs)(`section`,{className:`rounded-lg border border-border bg-card p-4`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:y}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:b}),t.isPending?(0,Q.jsx)(`p`,{className:`mt-4 text-sm text-muted-foreground`,children:`Loading…`}):null,t.isError?(0,Q.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:t.error?.message}):null,t.data&&x.length===0?(0,Q.jsx)(`p`,{className:`mt-4 text-sm text-muted-foreground`,children:`No secrets stored.`}):null,t.data&&x.length>0?(0,Q.jsx)(`ul`,{className:`mt-4 divide-y divide-border rounded-md border border-border`,"aria-label":`Stored ${e} secrets`,children:x.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center justify-between gap-3 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`code`,{className:`text-sm`,children:e.name}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.audiences.map(e=>_E[e].split(` (`)[0]).join(` · `)})]}),(0,Q.jsxs)(J,{variant:`outline`,"aria-label":`Delete ${e.name}`,disabled:g.isPending,onClick:()=>g.mutate(e.name),children:[(0,Q.jsx)(hc,{className:`size-3.5`}),` Delete`]})]},e.name))}):null,t.data?.skipped?(0,Q.jsxs)(`p`,{role:`alert`,className:`mt-3 text-xs text-destructive`,"data-slot":`secrets-skipped`,children:[`Stored values cannot be read: `,t.data.skipped,`.`]}):null,t.data?(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,"data-slot":`key-backend`,children:vE(t.data.keyBackend)}):null]}),(0,Q.jsxs)(`form`,{className:`rounded-lg border border-border bg-card p-4`,autoComplete:`off`,onSubmit:e=>{e.preventDefault(),_()},children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Add or replace a secret`}),(0,Q.jsxs)(`label`,{className:`mt-3 block text-sm`,children:[`Name`,(0,Q.jsx)(`input`,{"aria-label":`Name`,value:o,onChange:e=>{s(e.target.value.toUpperCase()),p(null)},autoComplete:`off`,spellCheck:!1,placeholder:`AI_GATEWAY_API_KEY`,"aria-invalid":m?!0:void 0,className:`mt-1 block w-full rounded border border-border bg-background p-2 font-mono`})]}),m?(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-danger`,children:m}):null,(0,Q.jsxs)(`label`,{className:`mt-3 block text-sm`,children:[`Value`,(0,Q.jsx)(`input`,{"aria-label":`Value`,type:`password`,autoComplete:`off`,required:!0,value:c,onChange:e=>l(e.target.value),className:`mt-1 block w-full rounded border border-border bg-background p-2`})]}),(0,Q.jsxs)(`fieldset`,{className:`mt-3`,children:[(0,Q.jsx)(`legend`,{className:`text-sm`,children:`Who may read it`}),tr.map(e=>(0,Q.jsxs)(`label`,{className:`mt-1 flex items-center gap-2 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"aria-label":_E[e],checked:u.includes(e),onChange:()=>v(e)}),_E[e]]},e)),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Agents are never an audience: a secret cannot be handed to a Claude Code, Codex or OpenCode session.`})]}),f&&f!==m?(0,Q.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:f}):null,(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(J,{type:`submit`,disabled:h.isPending||o===``||c===``||u.length===0||!!m,children:`Save secret`})})]})]})}function bE(){return(0,Q.jsx)(yE,{scope:`project`,list:_e(),save:g,remove:mt,invalidate:(e,t)=>e.invalidateQueries({queryKey:V.secrets.allFor(t??``)})})}function xE(){return(0,Q.jsx)(yE,{scope:`workspace`,list:wn(),save:y,remove:jt,invalidate:e=>e.invalidateQueries({queryKey:B.secrets})})}var SE={"task.attention_required":`Needs your input`,"task.review_ready":`Ready for review`,"task.finished":`Task finished`,"task.failed":`Task failed`,"task.cancelled":`Task cancelled`,"webhook.test":`Test message`},CE=`h-9 w-full rounded-md border border-input bg-card px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,wE=`text-ui text-muted-foreground`;function TE(e){return{format:e?.format??`cezar.json.v1`,name:e?.name??``,url:``,profile:e?.profile??`minimal`,preset:e?.preset??`attention`,events:e?.events??[],scope:e?.scope??`main_and_questions`,graceSeconds:e?.graceSeconds??180,local:e?.allowLocalNetwork??!1,scheduled:e?.includeScheduledFailures??!1}}function EE({id:e,label:t,children:n}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e?(0,Q.jsx)(`label`,{htmlFor:e,className:`text-sm font-medium`,children:t}):(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:t}),n]})}function DE({receiver:e,draft:t,setDraft:n,pending:r,blocked:i=!1,guideHref:a,save:o}){let s=(0,Z.useId)(),{format:c,name:l,url:u,profile:d,preset:f,events:p,scope:m,graceSeconds:h,local:g,scheduled:_}=t,v=(e,r)=>n({...t,[e]:r}),[y,b]=(0,Z.useState)(``),x=c!==`cezar.json.v1`,S=c===`slack.v1`?`Slack`:`Discord`,C;try{let e=new URL(u).hostname;e===`hooks.slack.com`&&(C=`slack.v1`),[`discord.com`,`discordapp.com`,`ptb.discord.com`,`canary.discord.com`].includes(e)&&(C=`discord.v1`)}catch{}let w=e=>n({...t,format:e,local:e===`cezar.json.v1`&&g});return(0,Q.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{if(t.preventDefault(),r||i)return;let n={format:c,name:l,...u||!e?{url:u}:{},profile:d,preset:f,events:p,scope:m,graceSeconds:h,allowLocalNetwork:!x&&g,includeScheduledFailures:_},a=e?Qn.safeParse({...n,expectedRevision:e.revision}):pr.safeParse(n);if(!a.success){b([...new Set(a.error.issues.map(e=>e.message.replace(/\.?$/,`.`)))].join(` `));return}b(``),o(a.data)},children:[(0,Q.jsx)(EE,{id:`${s}-destination`,label:`Destination`,children:(0,Q.jsxs)(`select`,{id:`${s}-destination`,className:CE,value:c,onChange:e=>w(e.target.value),children:[(0,Q.jsx)(`option`,{value:`cezar.json.v1`,children:`Custom receiver (signed cezar JSON)`}),(0,Q.jsx)(`option`,{value:`slack.v1`,children:`Slack channel (Incoming Webhook)`}),(0,Q.jsx)(`option`,{value:`discord.v1`,children:`Discord channel (Webhook URL)`})]})}),(0,Q.jsx)(EE,{id:`${s}-name`,label:`Name`,children:(0,Q.jsx)(Kc,{id:`${s}-name`,value:l,onChange:e=>v(`name`,e.target.value),maxLength:100,required:!0,autoComplete:`off`})}),(0,Q.jsxs)(EE,{id:`${s}-url`,label:x?`Webhook URL`:`Receiver URL`,children:[(0,Q.jsx)(Kc,{id:`${s}-url`,type:`url`,value:u,onChange:e=>v(`url`,e.target.value),required:!e,autoComplete:`off`,placeholder:e?`Leave blank to keep the current URL`:c===`slack.v1`?`https://hooks.slack.com/services/…`:c===`discord.v1`?`https://discord.com/api/webhooks/…`:`https://your-receiver.example/webhook`}),e&&(0,Q.jsxs)(`p`,{className:wE,children:[`Current: `,e.destination,` (path hidden)`]}),u.startsWith(`http:`)&&(0,Q.jsx)(`p`,{className:`text-ui text-warning`,children:`Plain HTTP is not encrypted. Use HTTPS outside a trusted local network.`}),!x&&C&&(0,Q.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-2 text-ui text-warning`,children:[(0,Q.jsxs)(`span`,{children:[`This is a `,C===`slack.v1`?`Slack`:`Discord`,` webhook. Switch the destination to post channel messages.`]}),(0,Q.jsxs)(J,{type:`button`,size:`sm`,variant:`outline`,className:`text-foreground`,onClick:()=>w(C),children:[`Use `,C===`slack.v1`?`Slack`:`Discord`]})]}),c===`slack.v1`&&(0,Q.jsxs)(`p`,{className:wE,children:[`In Slack, create an app with an Incoming Webhook, install it in your channel and paste its URL. `,(0,Q.jsx)(`a`,{className:`underline underline-offset-2 hover:text-foreground`,href:`https://docs.slack.dev/messaging/sending-messages-using-incoming-webhooks/`,target:`_blank`,rel:`noreferrer`,children:`Slack setup guide`})]}),c===`discord.v1`&&(0,Q.jsxs)(`p`,{className:wE,children:[`In Discord, open Server Settings → Integrations → Webhooks, create one and paste its URL. `,(0,Q.jsx)(`a`,{className:`underline underline-offset-2 hover:text-foreground`,href:`https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks`,target:`_blank`,rel:`noreferrer`,children:`Discord setup guide`})]}),x?(0,Q.jsxs)(`p`,{className:wE,children:[`Keep this URL secret — anyone who has it can post to the channel. `,S,` receivers need no signing key.`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:g,onChange:e=>v(`local`,e.target.checked)}),`Allow a receiver on this computer or private network`]}),g&&(0,Q.jsx)(`p`,{className:wE,children:`Tests will contact this private address. Hosted cezar sends to public HTTPS receivers only.`}),(0,Q.jsx)(`a`,{className:`text-ui text-muted-foreground underline underline-offset-2 hover:text-foreground`,href:`${a}#external-automation-receivers`,target:`_blank`,rel:`noreferrer`,children:`How to build a receiver`})]})]}),(0,Q.jsx)(EE,{id:`${s}-events`,label:`Events`,children:(0,Q.jsx)(`select`,{id:`${s}-events`,className:CE,value:f,onChange:e=>v(`preset`,e.target.value),children:[`attention`,`all`,`custom`].map(e=>(0,Q.jsx)(`option`,{value:e,children:kw[e]},e))})}),f===`custom`&&(0,Q.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`legend`,{className:`mb-1 text-sm font-medium`,children:`Choose events`}),Object.entries(SE).filter(([e])=>e!==`webhook.test`).map(([e,t])=>(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:p.includes(e),onChange:t=>v(`events`,t.target.checked?[...p,e]:p.filter(t=>t!==e))}),t]},e))]}),(0,Q.jsxs)(EE,{id:`${s}-profile`,label:`Message content`,children:[(0,Q.jsxs)(`select`,{id:`${s}-profile`,className:CE,value:d,onChange:e=>v(`profile`,e.target.value),children:[(0,Q.jsx)(`option`,{value:`minimal`,children:`Minimal — IDs, status and your own title`}),(0,Q.jsx)(`option`,{value:`standard`,children:`Standard — task titles, questions and errors`})]}),(0,Q.jsx)(`p`,{className:wE,children:`Prompts and transcripts are never sent. Redaction of other text is best effort.`}),x&&d===`standard`&&(0,Q.jsxs)(`p`,{className:`text-ui text-warning`,children:[`Standard posts task titles, questions and error text to your `,S,` channel.`]})]}),x?(0,Q.jsx)(OE,{format:c,profile:d}):(0,Q.jsxs)(`details`,{children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:[`Preview JSON · `,d===`minimal`?`Minimal`:`Standard`]}),(0,Q.jsx)(`p`,{className:`mt-2 ${wE}`,children:`Example data only — nothing is sent.`}),(0,Q.jsx)(`pre`,{"aria-label":`Synthetic JSON sample`,className:`mt-2 max-h-64 overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted p-3 text-xs`,children:JSON.stringify({id:`evt_00000000-0000-4000-8000-000000000001`,schemaVersion:1,sequence:1,occurredAt:`2026-01-01T12:00:00Z`,type:`task.attention_required`,source:{instanceId:`example-instance`,projectId:`example-project`,mode:`local`},task:{id:`example-task`,previousStatus:`running`,status:`waiting`,...d===`standard`?{title:`Example generated task title`}:{}},data:{episodeId:`example-episode`,since:`2026-01-01T12:00:00Z`,reason:`question`,requestId:`example-request`,...d===`standard`?{questions:[{question:`Which example option should be used?`,options:[{label:`Example A`},{label:`Example B`}]}]}:{}}},null,2)})]}),(0,Q.jsxs)(`details`,{children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:`Advanced`}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-4`,children:[(0,Q.jsx)(EE,{id:`${s}-scope`,label:`Tasks`,children:(0,Q.jsx)(`select`,{id:`${s}-scope`,className:CE,value:m,onChange:e=>v(`scope`,e.target.value),children:[`main_and_questions`,`every_task`].map(e=>(0,Q.jsx)(`option`,{value:e,children:Ow[e]},e))})}),(0,Q.jsxs)(EE,{id:`${s}-grace`,label:`Waiting and review delay`,children:[(0,Q.jsx)(`select`,{id:`${s}-grace`,className:CE,value:h,onChange:e=>v(`graceSeconds`,Number(e.target.value)),children:[0,60,180,600].map(e=>(0,Q.jsx)(`option`,{value:e,children:Aw[e]},e))}),(0,Q.jsx)(`p`,{className:wE,children:`Skipped if you reply, or the task stops waiting or leaves review, before the delay ends.`})]}),(0,Q.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:_,onChange:e=>v(`scheduled`,e.target.checked)}),`Include failures that will resume automatically (always included in All results)`]})]})]}),y&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:y}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(J,{type:`submit`,disabled:r||i,children:r?`Saving…`:e?`Review changes`:`Save receiver`})})]})}function OE({format:e,profile:t}){let n=e===`slack.v1`?`Slack`:`Discord`;return(0,Q.jsxs)(`details`,{children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:[`Preview `,n,` message · `,t===`minimal`?`Minimal`:`Standard`]}),(0,Q.jsx)(`p`,{className:`mt-2 ${wE}`,children:`Example data only — nothing is sent.`}),(0,Q.jsxs)(`div`,{"aria-label":`${n} message sample`,className:`mt-2 space-y-2 rounded-md border border-border bg-muted p-3 text-sm ${e===`discord.v1`?`border-l-4 border-l-pending`:``}`,children:[(0,Q.jsxs)(`p`,{className:`font-medium`,children:[`Needs your input · `,t===`standard`?`Example generated task title`:`a1b2c3d4`]}),(0,Q.jsx)(`p`,{children:`running → waiting`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`example-project · a1b2c3d4 · Jan 1, 2026, 12:00 UTC`}),t===`standard`&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{children:`Which example option should be used?`}),(0,Q.jsx)(`p`,{children:`Example A · Example B`})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`cezar`})]})]})}var kE={local_consent_required:`This address is on this computer or a private network. Edit the receiver and turn on “Allow a receiver on this computer or private network”.`,server_port:`This address points at the cezar server itself. Use your receiver's own port.`,https_required:`This server only sends to HTTPS receivers. Use an https:// URL.`,public_destination_required:`This server only sends to public receivers. Use a publicly reachable HTTPS URL.`,metadata_hostname:`Cloud metadata hostnames are never allowed as receivers.`,denied_address:`The receiver resolves to an address that is never allowed.`,mixed_dns:`The receiver hostname resolves to both public and private addresses. Use a hostname with one kind of address.`,invalid_dns:`The receiver hostname did not resolve to a usable address.`,dns_not_found:`The receiver hostname does not resolve. Check the URL.`,invalid_url:`The receiver URL is not allowed. Use a plain http(s) URL without credentials or a fragment.`};function AE({projectId:e,test:t,openHistory:n}){let r=dt({queryKey:[...pb(e),`test-result`,t.receiverId,t.deliveryId],queryFn:()=>je.deliveries(e,t.receiverId),retry:!1}),i=r.data?.items.find(e=>e.deliveryId===t.deliveryId),a=r.data?.receiver,o=t.format??(a?.kind===`live`?a.format:void 0),s=i&&[`delivered`,`failed`,`cancelled`,`superseded`,`dropped`].includes(i.status),c=(0,Z.useRef)(void 0),l=s?i.status:void 0,u=i?.reason===`outcome_unknown`;(0,Z.useEffect)(()=>{let n=`${e}:${t.deliveryId}`;!l||c.current===n||(c.current=n,l===`delivered`&&!u?Y(`Test delivered to ${t.receiverName}`):Y(u?`Test result for ${t.receiverName} is unknown`:`Test to ${t.receiverName} failed`,{tone:`danger`}))},[e,t.deliveryId,t.receiverName,l,u]);let d=s&&i.status===`delivered`&&!u,f=r.error?`Test result is unavailable. Check the history.`:r.data&&!i?`Test sent. Its result is in the history.`:s?u?`Test result unknown — it may have arrived. Check your receiver before testing again.`:d?`Test delivered.${a?.kind===`live`&&[`inactive`,`paused`].includes(a.state)?` ${a.state===`paused`?`Resume`:`Activate`} the receiver to start sending task updates.`:``}`:`Test ${i.status===`failed`?`failed`:i.status}${i.reason?`: ${Lw(i.reason)}`:``}.`:`Test sent — waiting for the result…`,p=!s||d||u?void 0:i.reason===`timeout`||i.reason===`connection_failed`?`Check that your receiver is reachable and responds within 10 seconds.`:/^http_(401|403)$/.test(i.reason??``)?o===`slack.v1`||o===`discord.v1`?`Check the webhook URL in Slack or Discord. If it was revoked or replaced, edit this receiver with the current URL and send a new test.`:`Check the receiver’s authentication and the signing key in its verifier.`:i.reason===`http_404`||i.reason===`http_410`?`Check the URL and that the endpoint still exists.`:kE[i.reason??``]?`${kE[i.reason]} Activation stays blocked until a test passes.`:`Fix the receiver, then send a new test. Tests are not retried automatically.`,m=d?`border-success/40`:s?`border-danger/30 bg-danger/5`:`border-border`;return(0,Q.jsxs)(`div`,{role:`status`,"data-test-delivery":t.deliveryId,className:`flex flex-wrap items-center justify-between gap-2 rounded-md border p-3 text-ui ${m}`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{children:f}),p&&(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:p})]}),(0,Q.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>n(t.receiverId),children:`View in history`})]})}var jE=Object.keys(Mw),ME={delivered:`text-success`,failed:`text-danger`,dropped:`text-danger`,blocked_policy:`text-warning`,retrying:`text-warning`};function NE({projectId:e,receiver:t,operation:n,tab:r,onTabChange:i}){let[a,o]=(0,Z.useState)(`deliveries`),s=r??a,c=e=>{o(e),i?.(e)},[l,u]=(0,Z.useState)(`all`),d=(0,Z.useId)(),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(),v=nn({queryKey:[...pb(e),t.id,`deliveries`,f],initialPageParam:void 0,queryFn:({pageParam:n})=>je.deliveries(e,t.id,n,f||void 0),getNextPageParam:e=>e.nextCursor,enabled:s===`deliveries`,retry:!1}),y=dt({queryKey:[...pb(e),t.id,`activity`],queryFn:()=>je.activity(e,t.id),enabled:s===`activity`,retry:!1}),b=[...new Map((v.data?.pages.flatMap(e=>e.items)??[]).map(e=>[e.deliveryId,e])).values()],x=b.filter(e=>l===`all`||e.status===l),S=v.data?.pages[0]?.timezone,C=e=>Vw(e,S);return(0,Q.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-3`,children:[t.kind===`history`&&(0,Q.jsxs)(`p`,{className:`rounded-md border border-border bg-muted p-3 text-ui text-muted-foreground`,children:[`Deleted `,Vw(t.deletedAt),` — read-only. Its settings and signing keys are gone; history is kept for up to 30 days.`]}),(0,Q.jsxs)(Gc,{value:s,onValueChange:e=>c(e),children:[(0,Q.jsxs)(Wc,{"aria-label":`Receiver history`,children:[(0,Q.jsx)(Hc,{value:`deliveries`,children:`Deliveries`}),(0,Q.jsx)(Hc,{value:`activity`,children:`Activity`})]}),(0,Q.jsxs)(Uc,{value:`activity`,className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`p`,{className:`text-ui text-muted-foreground`,children:[`Times in `,Bw(y.data?.timezone).label,`.`]}),y.isPending&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading activity…`}),y.error&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:y.error.message}),y.data?.items.map(e=>(0,Q.jsxs)(`div`,{className:`rounded-md border border-border p-3 text-sm`,children:[(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:Rw(e.action)}),` `,(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,Vw(e.at,y.data?.timezone),` · via `,Fw[e.source],e.revision!==void 0&&` · revision ${e.revision}`]})]}),e.fields.length>0&&(0,Q.jsxs)(`p`,{className:`text-ui text-muted-foreground`,children:[`Changed: `,e.fields.join(`, `)]}),e.detail&&(0,Q.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:e.detail})]},e.id)),y.data?.items.length===0&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No activity in the retained history.`}),y.data?.hasMore&&(0,Q.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:`Showing the latest 100 actions.`})]}),(0,Q.jsxs)(Uc,{value:`deliveries`,className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,Q.jsxs)(`form`,{className:`flex min-w-0 flex-1 items-end gap-2`,onSubmit:e=>{e.preventDefault(),p(m.trim())},children:[(0,Q.jsxs)(`label`,{className:`flex min-w-0 flex-1 flex-col gap-1.5 text-sm font-medium`,children:[`Task ID`,(0,Q.jsx)(Kc,{value:m,onChange:e=>h(e.target.value),placeholder:`Optional — show one task’s deliveries`})]}),(0,Q.jsx)(J,{type:`submit`,variant:`outline`,children:`Find`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{id:d,className:`text-sm font-medium`,children:`Result`}),(0,Q.jsxs)(lm,{value:l,onValueChange:u,children:[(0,Q.jsx)(dm,{"aria-labelledby":d,children:(0,Q.jsx)(um,{})}),(0,Q.jsxs)(fm,{children:[(0,Q.jsx)(pm,{value:`all`,children:`All results`}),jE.map(e=>(0,Q.jsx)(pm,{value:e,children:Mw[e]},e))]})]})]})]}),(0,Q.jsxs)(`p`,{className:`text-ui text-muted-foreground`,children:[`Showing `,b.length?`1–${b.length}`:`0`,` of `,v.data?.pages[0]?.total??0,f?` for task ${f}`:``,`. The result filter applies to loaded entries. Times in `,Bw(S).label,`.`]}),v.isPending&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading deliveries…`}),v.error&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:v.error.message}),!v.isPending&&x.length===0&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No deliveries match.`}),x.map(e=>(0,Q.jsxs)(`article`,{className:`min-w-0 rounded-md border border-border p-3 text-sm`,children:[(0,Q.jsxs)(`button`,{className:`w-full min-w-0 text-left`,type:`button`,"aria-expanded":g===e.deliveryId,onClick:()=>_(t=>t===e.deliveryId?void 0:e.deliveryId),children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:SE[e.eventType]}),` · `,(0,Q.jsx)(`span`,{className:ME[e.status],children:Mw[e.status]}),(0,Q.jsxs)(`span`,{className:`block text-ui text-muted-foreground`,children:[C(e.createdAt),` · `,zw(e.attempts,`attempt`,`attempts`),e.taskId?` · task ${e.taskId.slice(0,8)}`:``]})]}),g===e.deliveryId&&(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2 break-words border-t border-border pt-3 text-ui`,children:[(0,Q.jsxs)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 [overflow-wrap:anywhere]`,children:[e.reason&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Reason`}),(0,Q.jsx)(`dd`,{children:Lw(e.reason)})]}),e.httpStatus&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`HTTP status`}),(0,Q.jsx)(`dd`,{children:e.httpStatus})]}),e.nextAttemptAt&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Next attempt`}),(0,Q.jsx)(`dd`,{children:C(e.nextAttemptAt)})]}),(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Retries until`}),(0,Q.jsx)(`dd`,{children:C(e.expiresAt)}),e.taskId&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Task`}),(0,Q.jsxs)(`dd`,{children:[e.taskAvailability===`available`?(0,Q.jsx)(K,{className:`underline underline-offset-2`,to:`/tasks/${encodeURIComponent(e.taskId)}`,children:e.taskId}):e.taskId,e.taskAvailability===`deleted`&&` (deleted)`,e.taskAvailability===`unknown`&&` (availability unknown)`]})]}),(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Destination`}),(0,Q.jsx)(`dd`,{children:e.destination}),(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Event ID`}),(0,Q.jsx)(`dd`,{className:`font-mono text-xs`,children:e.eventId}),(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Delivery ID`}),(0,Q.jsx)(`dd`,{className:`font-mono text-xs`,children:e.deliveryId}),e.payloadRetainedUntil&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Payload kept until`}),(0,Q.jsx)(`dd`,{children:C(e.payloadRetainedUntil)})]}),e.historyRetainedUntil&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`History kept until`}),(0,Q.jsxs)(`dd`,{children:[C(e.historyRetainedUntil),` at most`]})]})]}),e.payloadAvailability===`not_created`&&(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:`No payload was created for this delivery.`}),e.payloadAvailability===`unknown`&&(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:`Payload availability is unknown.`}),e.response&&(0,Q.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-2 text-xs`,children:e.response}),t.kind===`live`&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(J,{size:`sm`,variant:`outline`,disabled:!e.retryAllowed,onClick:()=>n(`retry`,e,t),children:`Retry now`}),(0,Q.jsx)(J,{size:`sm`,variant:`outline`,disabled:!e.replayAllowed,onClick:()=>n(`replay`,e,t),children:`Replay`}),!e.replayAllowed&&(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Replay unavailable: `,e.replayUnavailableReason?PE[e.replayUnavailableReason]:`the payload or receiver is no longer eligible.`]})]})]})]},e.deliveryId)),v.hasNextPage&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(J,{variant:`outline`,disabled:v.isFetchingNextPage,onClick:()=>void v.fetchNextPage(),children:`Load older`})})]})]})]})}var PE={receiver_deleted:`the receiver was deleted.`,receiver_inactive:`activate the receiver first.`,configuration_changed:`the receiver settings changed since.`,task_unavailable:`the task is deleted or its state cannot be checked.`,not_fresh:`the event is out of date.`,not_terminal:`the delivery has not finished yet.`,synthetic_test:`send a new test instead.`,payload_expired:`the payload is no longer kept.`,payload_unavailable:`the original payload is unavailable.`};function FE(){let e=kr()??`default`,t=C();return t.isError?(0,Q.jsx)(`p`,{role:`status`,className:LE,children:`Webhook status unavailable — could not load server health.`}):t.data?(0,Q.jsx)(IE,{projectId:e,enabled:t.data?.capabilities.webhooks===!0,unsupportedPlatform:t.data?.capabilities.webhooksUnavailableReason===`unsupported_platform`},e):(0,Q.jsx)(`p`,{role:`status`,className:LE,children:`Loading webhook status…`})}function IE({projectId:e,enabled:t,unsupportedPlatform:n}){let r=U(),[i,a]=hr(),o=jr(),s=(0,Z.useRef)({mounted:!1,token:Symbol()});(0,Z.useLayoutEffect)(()=>(s.current={mounted:!0,token:Symbol()},()=>{s.current.mounted=!1}),[o]);let c=e=>s.current.mounted&&s.current.token===e,l=i.get(`endpoint`)??``,u=i.get(`tab`)??`settings`,d=/^[A-Za-z0-9_-]{1,128}$/.test(l),f=[`settings`,`deliveries`,`activity`].includes(u),p=u===`activity`?`activity`:`deliveries`,m=(0,Z.useRef)(i.toString());(0,Z.useLayoutEffect)(()=>{m.current=i.toString()},[i]);let h=(e,t=`deliveries`)=>{let n=new URLSearchParams(m.current);e?(n.set(`endpoint`,e),n.set(`tab`,t)):(n.delete(`endpoint`),n.delete(`tab`)),n.toString()!==m.current&&(m.current=n.toString(),a(n))},g=Hw(dt({queryKey:[`workspace`,`self-update`],queryFn:({signal:e})=>Pn({signal:e}),retry:!1}).data),_=mb(e,t),[v,y]=(0,Z.useState)(),[b,x]=(0,Z.useState)(()=>TE()),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(``),[E,D]=(0,Z.useState)(),[O,k]=(0,Z.useState)(),A=(0,Z.useRef)(null),j=(0,Z.useRef)(null),M=(0,Z.useRef)(null),N=(0,Z.useRef)(null),P=(e,t)=>{e.preventDefault();let n=[...document.querySelectorAll(`[role="dialog"][data-state="open"]`)];n.length&&!n.some(e=>t&&e.contains(t))||(t?.isConnected&&!t.matches(`:disabled`)?t.focus():A.current?.focus())},[F,ee]=(0,Z.useState)(!1),[te,I]=(0,Z.useState)(!1);(0,Z.useLayoutEffect)(()=>{v===`new`&&(y(void 0),x(TE()),C(!1),R(``))},[o]),(0,Z.useLayoutEffect)(()=>{k(void 0),ee(!1),I(!1)},[o]);let ne=(0,Z.useRef)(new Map),L=(0,Z.useRef)(new Map),re=(0,Z.useRef)(void 0);(0,Z.useLayoutEffect)(()=>{d&&f&&u!==`settings`&&(re.current=ne.current.get(l))},[l,d,f,u,_.data]);let ie=(0,Z.useRef)(void 0),ae=_.data?.receivers.find(e=>e.id===l)??_.data?.history.find(e=>e.id===l),oe=dt({queryKey:[...pb(e),`resolve`,l,p],queryFn:async()=>(await(p===`activity`?je.activity(e,l):je.deliveries(e,l))).receiver,enabled:t&&d&&f&&u!==`settings`&&!ae,retry:!1});(0,Z.useEffect)(()=>{if(t&&d&&u===`settings`){let e=_.data?.receivers.find(e=>e.id===l);e&&ie.current!==l&&(ie.current=l,y(e),x(TE(e)),C(!1),R(``))}else ie.current&&(ie.current=void 0,y(void 0),x(TE()),C(!1))},[t,l,d,u,_.data]);let[se,ce]=(0,Z.useState)(!1),[le,R]=(0,Z.useState)(``),[ue,de]=(0,Z.useState)();(0,Z.useLayoutEffect)(()=>{de(void 0)},[o.key]);let fe=async(t,n)=>{let r=s.current.token,i=await je.test(e,t.id,n);c(r)&&de({viewKey:o.key,deliveryId:i.deliveryId,receiverId:t.id,receiverName:t.name,initialState:t.state,deliveryRevision:t.deliveryRevision,format:t.format})},pe=nn({queryKey:[...pb(e),`history`],initialPageParam:void 0,queryFn:({pageParam:t})=>je.history(e,t),getNextPageParam:e=>e.nextCursor,enabled:t&&se,retry:!1}),z=H({onMutate:()=>({viewKey:s.current.token,form:v,confirmation:O}),mutationFn:async e=>{let t=s.current.token,n=await e();!(n&&typeof n==`object`&&`receiver`in n&&n.receiver&&typeof n.receiver==`object`&&`format`in n.receiver&&(n.receiver.format===`slack.v1`||n.receiver.format===`discord.v1`))&&c(t)&&n&&typeof n==`object`&&`secret`in n&&typeof n.secret==`string`&&n.secret.length>0&&(M.current=v?j.current:N.current,T(``),D(n.secret))},onSuccess:async(t,n,i)=>{if(!i||!c(i.viewKey)){await r.invalidateQueries({queryKey:pb(e)});return}v===i.form&&O===i.confirmation&&(v&&(N.current=j.current),O?.deletesReceiver&&(N.current=A.current),v&&l&&u===`settings`&&h(),y(void 0),x(TE()),C(!1),k(void 0),R(``)),await r.invalidateQueries({queryKey:pb(e)})},onError:(t,n,i)=>{if(!i||!c(i.viewKey)){r.invalidateQueries({queryKey:pb(e)});return}v===i.form&&O===i.confirmation?(R(t.message),`status`in t&&t.status===409&&C(!0)):Y(`Earlier webhook action failed: ${t.message}`,{tone:`danger`}),r.invalidateQueries({queryKey:pb(e)})}}),me=(e,t=document.activeElement)=>{N.current=t instanceof HTMLElement?t:null,ee(!1),I(!1),R(``),C(!1),k(e)},he=(t,n,r)=>{let i={expectedRevision:r.revision,deliveryRevision:r.deliveryRevision,operationId:crypto.randomUUID()};me(t===`replay`?{title:`Replay this event?`,text:`Sends the same event again with a new 72-hour retry window. Your receiver or channel may show it twice.`,run:()=>je.replay(e,n.deliveryId,i)}:{title:`Retry this delivery now?`,text:`Sends the same message again now. Rate limits and freshness checks still apply.`,run:()=>je.retry(e,n.deliveryId,i)})},ge=t=>({title:`Pause ${t.name}?`,text:`New events won’t be queued while it is paused.${zE(t.pendingCount)}`,run:()=>je.pause(e,t.id,t.revision)}),_e=t=>({title:`Delete ${t.name}?`,text:`${zE(t.pendingCount).trim()} Its settings${RE(t)?``:` and signing keys`} are removed; delivery history stays for up to 30 days.`.trim(),deletesReceiver:!0,run:()=>je.remove(e,t.id,t.revision)});if(n||!t)return(0,Q.jsx)(`div`,{"data-slot":`webhooks-settings`,className:LE,children:(0,Q.jsxs)(`section`,{className:`flex flex-col gap-3 rounded-lg border border-border bg-card p-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:n?`Webhooks aren’t available on this platform`:`Webhooks are off`}),(0,Q.jsx)(`p`,{className:`mt-1 text-ui text-muted-foreground`,children:n?`Delivery needs an OS-verified process identity to keep a single sender. Linux, macOS and Windows provide one; this platform does not.`:`Send task updates to Slack, Discord or your own endpoint when a task needs you, is ready for review or finishes.`})]}),!n&&(0,Q.jsxs)(`p`,{className:`text-ui`,children:[`Start cezar with `,(0,Q.jsx)(`code`,{children:`CEZ_WEBHOOKS=1`}),`, then reload this page. If someone else runs this server, ask them to turn webhooks on.`]}),(0,Q.jsx)(`a`,{className:`w-fit text-ui underline underline-offset-2 hover:text-foreground`,href:g.href,target:`_blank`,rel:`noreferrer`,children:g.note})]})});let ve=_.data?.receivers??[],ye=d&&f&&u!==`settings`?ae??oe.data:void 0,be=_.data?.notice,xe=be?.receiverId?ve.find(e=>e.id===be.receiverId):void 0,Se=v&&v!==`new`?ve.find(e=>e.id===v.id):void 0,Ce=_.data?.historyCount??0,we=S&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border border-warning/50 bg-warning/10 p-3 text-ui`,role:`alert`,children:[(0,Q.jsx)(`p`,{children:`This receiver changed in the meantime, so nothing was applied. Review its latest state and confirm again.`}),v&&v!==`new`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{children:`Your draft is kept. Saving it replaces the latest settings below; a blank URL keeps the current destination.`}),_.isFetching?(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading the latest settings…`}):_.error?(0,Q.jsx)(`p`,{className:`text-danger`,children:`Couldn’t load the latest settings.`}):Se?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`font-medium`,children:[`Latest: revision `,Se.revision,` · `,Tw[Se.state]]}),(0,Q.jsx)(BE,{receiver:Se,projectId:e})]}):(0,Q.jsx)(`p`,{children:`This receiver no longer exists. Close this dialog to return to the list.`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(J,{size:`sm`,variant:`outline`,disabled:_.isFetching,onClick:()=>void _.refetch(),children:`Refresh latest settings`}),(0,Q.jsx)(J,{size:`sm`,disabled:!Se||_.isFetching||!!_.error,onClick:()=>{Se&&(y(Se),C(!1),k(void 0),R(``))},children:`Keep draft and review again`})]})]}):(0,Q.jsx)(`p`,{children:`Cancel, check the refreshed receiver or its history, then choose the action again. Earlier consent is not reused.`})]});return(0,Q.jsxs)(`div`,{"data-slot":`webhooks-settings`,className:LE,children:[(0,Q.jsxs)(`section`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Receivers`}),(0,Q.jsxs)(`p`,{className:`text-ui text-muted-foreground`,children:[`Each receiver gets the task updates you choose while cezar is running. New receivers stay Inactive until you test and activate them. `,(0,Q.jsx)(`a`,{className:`underline underline-offset-2 hover:text-foreground`,href:g.href,target:`_blank`,rel:`noreferrer`,children:g.note})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.jsx)(J,{variant:`ghost`,size:`icon`,"aria-label":`Refresh`,title:`Refresh`,disabled:_.isFetching,onClick:()=>void _.refetch(),children:(0,Q.jsx)(ac,{})}),(0,Q.jsxs)(J,{ref:A,disabled:_.isPending||!!_.error,onClick:e=>{j.current=e.currentTarget,R(``),C(!1),x(TE()),y(`new`)},children:[(0,Q.jsx)(xc,{}),`Add receiver`]})]})]}),be&&(0,Q.jsxs)(`section`,{role:`status`,className:`flex min-w-0 flex-col gap-2 rounded-md border border-warning/50 bg-warning/10 p-3 text-sm [overflow-wrap:anywhere]`,children:[(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:Rw(be.action)}),be.receiverName?` — ${be.receiverName}`:``,(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[be.destination?` · ${be.destination}`:``,` · `,Vw(be.at),be.source?` · via ${Fw[be.source]}`:``]})]}),(0,Q.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:`Any local process, including agents, can change receivers and read signing keys. If this wasn’t you, review it.`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(J,{size:`sm`,variant:`outline`,disabled:z.isPending,onClick:()=>z.mutate(()=>je.acknowledge(e,_.data.changeSequence)),children:`Mark as reviewed`}),be.receiverId&&(0,Q.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>h(be.receiverId,`activity`),children:`View activity`}),xe&&[`active`,`suspended`].includes(xe.state)&&(0,Q.jsx)(J,{size:`sm`,variant:`ghost`,onClick:e=>me(ge(xe),e.currentTarget),children:`Pause receiver`}),xe&&(0,Q.jsx)(J,{size:`sm`,variant:`danger-ghost`,onClick:e=>me(_e(xe),e.currentTarget),children:`Delete receiver`})]})]}),l&&(!d||!f)&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:`This receiver link is invalid.`}),d&&u===`settings`&&!_.isPending&&!_.error&&!ve.some(e=>e.id===l)&&(0,Q.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,Q.jsx)(`span`,{children:`This receiver’s settings are unavailable — it may have been deleted.`}),(0,Q.jsx)(J,{size:`sm`,variant:`outline`,onClick:()=>h(l,`deliveries`),children:`View its history`})]}),d&&f&&u!==`settings`&&!ye&&(0,Q.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:oe.error?`This receiver’s history is unavailable or no longer kept.`:`Loading history…`}),(le||_.error)&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:le||_.error?.message}),_.data?.webhookHealth.status!==`ready`&&_.data?.webhookHealth.reason&&(0,Q.jsx)(`p`,{role:`status`,className:`rounded-md border border-warning/50 bg-warning/10 p-3 text-ui`,children:_.data.webhookHealth.reason}),_.isPending&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading receivers…`}),!_.isPending&&!_.error&&!ve.length&&(0,Q.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-6 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:`No receivers yet`}),(0,Q.jsx)(`p`,{className:`mt-1 text-ui text-muted-foreground`,children:`Add a Slack or Discord channel, or your own endpoint. Send a test, then activate it.`})]}),ve.map(t=>{let n=!RE(t),r=[`inactive`,`disabled`,`paused`].includes(t.state),i=t.state===`suspended`?`Test and recover`:t.state===`disabled`?`Test after repair`:`Send test`,a=[t.destination,`${Dw[t.profile]} content`,`Last test: ${jw[t.lastTest].toLowerCase()}`,t.pendingCount?zw(t.pendingCount,`pending delivery`,`pending deliveries`):``,t.inFlightCount?`${t.inFlightCount} sending`:``].filter(Boolean).join(` · `);return(0,Q.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-card p-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`h3`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold [overflow-wrap:anywhere]`,children:[t.name,(0,Q.jsx)(Nc,{dot:ww[t.state],children:Tw[t.state]}),!n&&(0,Q.jsx)(Nc,{children:Ew[t.format]})]}),(0,Q.jsx)(`p`,{className:`mt-1 break-words text-ui text-muted-foreground`,children:a}),t.consecutiveFailures>0&&(0,Q.jsxs)(`p`,{className:`mt-1 text-ui text-warning`,children:[zw(t.consecutiveFailures,`failed attempt`,`failed attempts`),` in a row.`,t.pendingCount>0?t.nextProbeAt?` Next retry ${Vw(t.nextProbeAt)}.`:``:` Nothing is queued, so nothing will be retried until the next event.`]}),t.state===`paused`&&(0,Q.jsxs)(`p`,{className:`mt-1 text-ui text-muted-foreground`,children:[t.pauseReason===`project_removal`?`Paused when this project was removed from the workspace.`:`Paused.`,` New events aren’t queued.`]}),t.activationBlocked&&(0,Q.jsx)(`p`,{className:`mt-1 text-ui text-warning`,children:`Send a passing test of these settings before activating.`}),n&&t.retiredKeyExpiresAt&&(0,Q.jsxs)(`p`,{className:`mt-1 text-ui text-muted-foreground`,children:[`The previous signing key stops working `,Vw(t.retiredKeyExpiresAt),`.`]})]}),ue&&ue.viewKey===o.key&&ue.receiverId===t.id&&(0,Q.jsx)(AE,{projectId:e,test:ue,openHistory:e=>h(e)},ue.deliveryId),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r&&(0,Q.jsx)(J,{size:`sm`,disabled:z.isPending||t.activationBlocked||t.state===`disabled`&&t.lastTest!==`success`,onClick:n=>me({title:`${t.state===`paused`?`Resume`:`Activate`} ${t.name}?`,text:`Only events from now on are sent — nothing from before ${t.state===`paused`?`resuming`:`activation`}.${t.lastTest===`transient_failure`?` The last test failed with a temporary error, so delivery may still fail.`:``}`,receiver:t,standard:t.profile===`standard`,local:t.allowLocalNetwork,run:()=>t.state===`paused`?je.resume(e,t.id,t.revision):je.activate(e,t.id,t.revision)},n.currentTarget),children:t.state===`paused`?`Resume`:`Activate`}),(0,Q.jsx)(J,{size:`sm`,variant:`outline`,disabled:z.isPending,onClick:e=>{let n={expectedRevision:t.revision,deliveryRevision:t.deliveryRevision,operationId:crypto.randomUUID()};t.state===`suspended`?me({title:`Test and recover?`,text:`If the test passes, ${t.name} becomes Active and sends its queued deliveries that are still current${t.pendingCount?` (${t.pendingCount} queued now)`:``}.`,run:()=>fe(t,n)},e.currentTarget):z.mutate(()=>fe(t,n))},children:i}),!r&&(0,Q.jsx)(J,{size:`sm`,variant:`outline`,onClick:e=>me(ge(t),e.currentTarget),children:`Pause`}),(0,Q.jsx)(J,{size:`sm`,variant:`outline`,onClick:e=>{j.current=e.currentTarget,x(TE(t)),C(!1),R(``),y(t),h(t.id,`settings`)},children:`Edit`}),(0,Q.jsx)(J,{size:`sm`,variant:`outline`,ref:e=>{e?ne.current.set(t.id,e):ne.current.delete(t.id)},onClick:()=>h(t.id),children:`History`}),(0,Q.jsxs)(tc,{children:[(0,Q.jsx)(Ys,{asChild:!0,children:(0,Q.jsx)(J,{size:`icon-sm`,variant:`ghost`,"aria-label":`More actions for ${t.name}`,ref:e=>{e?L.current.set(t.id,e):L.current.delete(t.id)},children:(0,Q.jsx)(Da,{})})}),(0,Q.jsxs)(Zs,{align:`end`,className:`w-[220px]`,children:[n&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)($s,{disabled:!!t.retiredKeyExpiresAt&&Date.parse(t.retiredKeyExpiresAt)>Date.now(),onSelect:()=>me({title:`Rotate signing key?`,text:`Old and new keys both sign deliveries for 24 hours. Install the new key in your receiver within that time.`,run:()=>je.rotate(e,t.id,t.revision,`graceful`)},L.current.get(t.id)),children:[(0,Q.jsx)(Ll,{}),`Rotate key`]}),(0,Q.jsxs)($s,{onSelect:()=>me({title:`Revoke old signing keys now?`,text:`Old keys stop signing immediately, and deliveries fail until your receiver uses the new key. Also remove old keys from your receiver — cezar can’t revoke keys it still accepts.`,run:()=>je.rotate(e,t.id,t.revision,`revoke_now`)},L.current.get(t.id)),children:[(0,Q.jsx)(ru,{}),`Revoke old keys`]}),(0,Q.jsx)(ec,{})]}),(0,Q.jsxs)($s,{variant:`destructive`,onSelect:()=>me(_e(t),L.current.get(t.id)),children:[(0,Q.jsx)(hc,{}),`Delete`]})]})]})]})]},t.id)}),(Ce>0||se)&&(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`div`,{children:(0,Q.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>ce(e=>!e),children:se?`Hide deleted receivers`:`Show deleted receivers (${Ce})`})}),se&&(0,Q.jsxs)(Q.Fragment,{children:[pe.error&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:pe.error.message}),pe.data?.pages.flatMap(e=>e.items).map(e=>(0,Q.jsxs)(J,{ref:t=>{t?ne.current.set(e.id,t):ne.current.delete(e.id)},variant:`outline`,className:`h-auto max-w-full justify-start whitespace-normal py-2 text-left font-normal [overflow-wrap:anywhere]`,onClick:()=>h(e.id),children:[e.name,` — deleted `,Vw(e.deletedAt)]},e.id)),pe.data&&!pe.data.pages.some(e=>e.items.length)&&(0,Q.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:`No deleted receivers are kept.`}),pe.hasNextPage&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(J,{size:`sm`,variant:`outline`,disabled:pe.isFetchingNextPage,onClick:()=>void pe.fetchNextPage(),children:`Load older`})})]})]}),(0,Q.jsx)(qr,{open:v!==void 0&&!O,onOpenChange:e=>{!e&&!z.isPending&&(y(void 0),x(TE()),C(!1),l&&h())},children:(0,Q.jsxs)(Wr,{onCloseAutoFocus:e=>P(e,j.current),className:`max-h-[90dvh] overflow-y-auto`,children:[(0,Q.jsxs)(Lr,{children:[(0,Q.jsx)(Zr,{children:v===`new`?`Add receiver`:`Edit receiver`}),(0,Q.jsx)(Vr,{children:`New and changed receivers stay Inactive until you test and activate them.`})]}),v&&(0,Q.jsx)(DE,{receiver:v===`new`?void 0:v,guideHref:g.href,draft:b,setDraft:x,pending:z.isPending,blocked:S,save:t=>{if(v===`new`)z.mutate(()=>je.create(e,t));else{let n=v;me({title:`Save changes?`,text:`Changing where or what ${n.name} sends makes it Inactive again${n.pendingCount?` and cancels ${zw(n.pendingCount,`pending delivery`,`pending deliveries`)}`:``}. A delivery already sending may still arrive. Renaming alone keeps it active.${n.format!==`cezar.json.v1`&&t.format===`cezar.json.v1`?` After saving, use Rotate key and copy the new signing key into your receiver before testing.`:``}`,run:()=>je.update(e,n.id,t)})}}},v===`new`?`new`:`${v.id}-${v.revision}`),we,le&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:le})]})}),(0,Q.jsx)(qr,{open:!!O,onOpenChange:e=>{!e&&!z.isPending&&k(void 0)},children:(0,Q.jsxs)(Wr,{onCloseAutoFocus:e=>P(e,N.current),className:`max-h-[90dvh] overflow-y-auto`,children:[(0,Q.jsxs)(Lr,{children:[(0,Q.jsx)(Zr,{children:O?.title}),(0,Q.jsx)(Vr,{children:O?.text})]}),O?.receiver&&(0,Q.jsx)(BE,{receiver:O.receiver,projectId:e}),O?.standard&&(0,Q.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:F,onChange:e=>ee(e.target.checked)}),`I understand Standard sends task titles, questions and error text to this receiver.`]}),O?.local&&(0,Q.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:te,onChange:e=>I(e.target.checked)}),`I allow delivery to this computer or private network.`]}),we,le&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:le}),(0,Q.jsxs)(Br,{children:[(0,Q.jsx)(J,{variant:`outline`,disabled:z.isPending,onClick:()=>k(void 0),children:`Cancel`}),(0,Q.jsx)(J,{className:O?.deletesReceiver?`bg-danger text-danger-foreground hover:brightness-[0.96]`:void 0,disabled:z.isPending||S||!!O?.standard&&!F||!!O?.local&&!te,onClick:()=>O&&z.mutate(O.run),children:z.isPending?`Working…`:O?.deletesReceiver?`Delete`:`Confirm`})]})]})}),(0,Q.jsx)(qr,{open:!!E,onOpenChange:e=>{e||D(void 0)},children:(0,Q.jsxs)(Wr,{onCloseAutoFocus:e=>P(e,M.current),className:`max-h-[90dvh] overflow-y-auto`,children:[(0,Q.jsxs)(Lr,{children:[(0,Q.jsx)(Zr,{children:`Save your signing key`}),(0,Q.jsx)(Vr,{children:`Copy it into your receiver now — it is shown only once. If you lose it, use Rotate key to get a new one (or Revoke old keys while a rotation is still overlapping).`})]}),(0,Q.jsx)(`code`,{tabIndex:0,className:`block select-text break-all rounded-md bg-muted p-3 font-mono text-sm`,children:E}),w&&(0,Q.jsx)(`p`,{role:`status`,className:`text-ui text-muted-foreground`,children:w}),(0,Q.jsxs)(Br,{children:[(0,Q.jsx)(J,{variant:`outline`,onClick:async()=>{try{if(!E||!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(E),T(`Key copied. Store it in your receiver.`)}catch{T(`Couldn’t copy — select the key and copy it manually before closing.`)}},children:`Copy key`}),(0,Q.jsx)(J,{onClick:()=>D(void 0),children:`I’ve saved the key`})]})]})}),(0,Q.jsx)(qr,{open:!!ye,onOpenChange:e=>{e||h()},children:(0,Q.jsxs)(Wr,{className:`max-h-[90dvh] overflow-y-auto sm:max-w-2xl [overflow-wrap:anywhere]`,onCloseAutoFocus:e=>{let t=re.current;t?.isConnected&&(e.preventDefault(),t.focus())},children:[(0,Q.jsxs)(Lr,{className:`min-w-0`,children:[(0,Q.jsxs)(Zr,{children:[ye?.name,` — history`]}),(0,Q.jsx)(Vr,{children:`Delivery results and setting changes for this receiver.`})]}),ye&&(0,Q.jsx)(NE,{projectId:e,receiver:ye,tab:p,onTabChange:e=>h(ye.id,e),operation:he},ye.id)]})})]})}var LE=`mx-auto flex w-full max-w-2xl min-w-0 flex-col gap-6 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,RE=e=>(e.format??`cezar.json.v1`)!==`cezar.json.v1`,zE=e=>e?` ${zw(e,`pending delivery`,`pending deliveries`)} will be cancelled; one already sending may still arrive.`:``;function BE({receiver:e,projectId:t}){let n=e.preset===`custom`?e.events:e.preset===`all`?[`task.attention_required`,`task.review_ready`,`task.finished`,`task.failed`,`task.cancelled`]:[`task.attention_required`,`task.review_ready`,`task.finished`,`task.failed`],r=`text-muted-foreground`;return(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 text-ui`,children:[(0,Q.jsxs)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1 rounded-md border border-border bg-card p-3 [overflow-wrap:anywhere]`,children:[(0,Q.jsx)(`dt`,{className:r,children:`Receiver`}),(0,Q.jsx)(`dd`,{children:e.name}),(0,Q.jsx)(`dt`,{className:r,children:`Destination`}),(0,Q.jsx)(`dd`,{children:e.format===`cezar.json.v1`?`Custom receiver (signed cezar JSON)`:`${Ew[e.format]} channel`}),(0,Q.jsx)(`dt`,{className:r,children:`URL`}),(0,Q.jsx)(`dd`,{children:e.destination}),(0,Q.jsx)(`dt`,{className:r,children:`Project`}),(0,Q.jsx)(`dd`,{children:t}),(0,Q.jsx)(`dt`,{className:r,children:`Message content`}),(0,Q.jsx)(`dd`,{children:Dw[e.profile]}),(0,Q.jsx)(`dt`,{className:r,children:`Events`}),(0,Q.jsxs)(`dd`,{children:[kw[e.preset],`: `,n.map(e=>SE[e]).join(`, `)]}),(0,Q.jsx)(`dt`,{className:r,children:`Tasks`}),(0,Q.jsx)(`dd`,{children:Ow[e.scope]}),(0,Q.jsx)(`dt`,{className:r,children:`Waiting and review delay`}),(0,Q.jsx)(`dd`,{children:Aw[e.graceSeconds]}),e.format===`cezar.json.v1`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:r,children:`Private network`}),(0,Q.jsx)(`dd`,{children:e.allowLocalNetwork?`Allowed`:`Not allowed`})]}),(0,Q.jsx)(`dt`,{className:r,children:`Failures that resume automatically`}),(0,Q.jsx)(`dd`,{children:e.preset===`all`||e.includeScheduledFailures?`Included`:`Excluded`})]}),e.destination.startsWith(`http:`)&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-warning`,children:`HTTP is unencrypted — others on the network may read these messages. Use HTTPS where possible.`})]})}var VE=`/assets/tester-army-tUUSV6JM.png`,HE=`https://github.com/tester-army/e2e`,UE={AI_GATEWAY_API_KEY:`Vercel AI Gateway`,OPENAI_API_KEY:`OpenAI`,ANTHROPIC_API_KEY:`Anthropic`,OPENROUTER_API_KEY:`OpenRouter`},WE=new Set([`queued`,`running`,`waiting`]);function GE(e,t,n,r){if(WE.has(e))return`Setting up — cezar is installing and configuring e2e in its own worktree.`;let i=r?`its draft PR is ready — merge it to finish.`:`merge ${n?`branch ${n}`:`the setup task’s branch`} to finish.`;return e===`review`?`Ready for review — ${i}`:e===`done`?t?`Setup finished.`:`Setup finished — ${i}`:e===`failed`?`The last setup failed — open the task to see why, then try again.`:`The last setup was cancelled.`}function KE({ok:e,children:t}){return(0,Q.jsxs)(`li`,{className:`flex items-center gap-2 text-sm`,"data-ok":e,children:[e?(0,Q.jsx)(Rs,{className:`size-4 text-success`,"aria-hidden":!0}):(0,Q.jsx)(Wl,{className:`size-4 text-muted-foreground`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:e?void 0:`text-muted-foreground`,children:t})]})}function qE(){let e=U(),t=Nr(),n=h(),r=Ee(n.data?.setup?.runId),[i,a]=(0,Z.useState)(void 0),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(null),u=r.data?.status??n.data?.setup?.status,d=r.data?.pullRequestUrl&&/^https?:\/\//.test(r.data.pullRequestUrl)?r.data.pullRequestUrl:void 0,f=u!==void 0&&WE.has(u),p=n.data?.credentials??[],m=i??p[0]??`AI_GATEWAY_API_KEY`,g=!!(n.data?.configFile&&n.data.workflow),_=H({mutationFn:async()=>({projectId:$n(),runId:(await le(o?{credential:{name:m,value:o}}:{})).runId}),onSuccess:async({projectId:n,runId:r})=>{s(``),l(null),await Promise.all([e.invalidateQueries({queryKey:V.e2e.allFor(n??``)}),e.invalidateQueries({queryKey:V.secrets.allFor(n??``)})]),Y(`e2e setup started`),$n()===n&&t(_r(n,`/tasks/${r}`))},onError:e=>l(e.message)});return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,"data-slot":`e2e-settings`,children:[(0,Q.jsxs)(`section`,{className:`rounded-lg border border-border bg-card p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`img`,{src:VE,alt:``,width:40,height:40,className:`size-10 shrink-0 rounded-md`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:`TesterArmy e2e`}),(0,Q.jsx)(`span`,{"data-slot":`e2e-badge`,"data-state":f?`setting-up`:g?`installed`:`none`,className:g&&!f?`rounded-full bg-success/10 px-2 py-0.5 text-xs font-medium text-success`:`rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground`,children:f?`Setting up`:g?`Installed`:`Not set up`})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Agentic browser end-to-end testing`})]}),(0,Q.jsxs)(`a`,{href:HE,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline`,children:[`tester-army/e2e `,(0,Q.jsx)(ic,{className:`size-3`,"aria-hidden":!0})]})]}),(0,Q.jsxs)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:[`cezar installs it for this project, points it at your dev server, writes a smoke test and an`,` `,(0,Q.jsx)(`code`,{children:`implement-and-e2e`}),` workflow, proves it all passes in a real browser and opens a draft PR for you to merge.`]}),n.isPending?(0,Q.jsx)(`p`,{className:`mt-4 text-sm text-muted-foreground`,children:`Loading…`}):null,n.isError?(0,Q.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:n.error.message}):null,n.data?(0,Q.jsxs)(`ul`,{className:`mt-4 flex flex-col gap-1.5`,"aria-label":`e2e status`,children:[(0,Q.jsx)(KE,{ok:!!n.data.configFile,children:n.data.configFile?(0,Q.jsxs)(Q.Fragment,{children:[`Configured (`,(0,Q.jsx)(`code`,{children:n.data.configFile}),`)`]}):`Not configured in this checkout`}),(0,Q.jsxs)(KE,{ok:n.data.workflow,children:[(0,Q.jsx)(`code`,{children:`implement-and-e2e`}),` workflow `,n.data.workflow?`available`:`not added yet`]}),(0,Q.jsx)(KE,{ok:p.length>0,children:p.length>0?(0,Q.jsxs)(Q.Fragment,{children:[`Model key: `,(0,Q.jsx)(`code`,{children:p.join(`, `)})]}):`No model key — smoke tests run without one; agent steps need one`})]}):null,n.data?.setup&&u?(0,Q.jsxs)(`p`,{className:`mt-3 text-sm`,"data-slot":`e2e-setup-run`,"data-status":u,children:[GE(u,!!n.data.configFile,r.data?.branch,d),` `,d&&!n.data.configFile?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`a`,{className:`underline`,href:d,target:`_blank`,rel:`noreferrer`,children:`Open the draft PR`}),` · `]}):null,(0,Q.jsx)(yr,{className:`underline`,to:_r($n(),`/tasks/${n.data.setup.runId}`),children:`Open the setup task`})]}):null]}),(0,Q.jsxs)(`form`,{className:`rounded-lg border border-border bg-card p-4`,autoComplete:`off`,onSubmit:e=>{e.preventDefault(),_.mutate()},children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:g?`Set up again`:`Set up e2e`}),(0,Q.jsxs)(`label`,{className:`mt-3 block text-sm`,children:[`Model provider`,(0,Q.jsx)(`select`,{"aria-label":`Model provider`,value:m,onChange:e=>a(e.target.value),className:`mt-1 block w-full rounded border border-border bg-background p-2 outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:fr.map(e=>(0,Q.jsxs)(`option`,{value:e,children:[UE[e],` (`,e,`)`,p.includes(e)?` — stored`:``]},e))})]}),(0,Q.jsxs)(`label`,{className:`mt-3 block text-sm`,children:[`API key `,(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`(optional)`}),(0,Q.jsx)(`input`,{"aria-label":`API key`,type:`password`,autoComplete:`off`,value:o,onChange:e=>s(e.target.value),placeholder:p.includes(m)?`stored — leave empty to keep it`:``,className:`mt-1 block w-full rounded border border-border bg-background p-2`})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Stored encrypted as a project secret for check steps only — never handed to an agent session.`}),c?(0,Q.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:c}):null,(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(J,{type:`submit`,disabled:_.isPending||f||!n.data,children:f?`Setup in progress…`:g?`Set up again`:`Set up e2e`})})]})]})}function JE(){return(0,Q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col gap-4 p-4 md:p-6`,"data-slot":`integrations-settings`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Tools cezar can set up in this project for you — each one as a task you review and merge.`}),(0,Q.jsxs)(Gc,{defaultValue:`test-frameworks`,children:[(0,Q.jsx)(Wc,{variant:`line`,"data-slot":`integrations-tabs`,children:(0,Q.jsx)(Hc,{value:`test-frameworks`,children:`Test frameworks`})}),(0,Q.jsx)(Uc,{value:`test-frameworks`,className:`pt-4`,children:(0,Q.jsx)(qE,{})})]})]})}var YE=[{id:`tracker`,title:`Issue tracker`,description:`Connect this project to Jira or Linear.`,icon:su,component:hE,scope:`project`},{id:`secrets`,title:`Secrets`,description:`Encrypted values for this project’s check steps and cezar — never for agents.`,icon:Ll,component:bE,scope:`project`},{id:`webhooks`,title:`Webhooks`,description:`Send task updates to Slack, Discord or your own endpoint.`,icon:lu,component:FE,scope:`project`},{id:`integrations`,title:`External integrations`,description:`Third-party tools cezar installs and wires into this project — test frameworks first.`,icon:gl,component:JE,scope:`project`},{id:`agents`,title:`Agents`,description:`Providers, default runner and models.`,icon:Lo,component:TC,scope:`project`},{id:`instructions`,title:`Instructions`,description:`What you write for the models: system prompt, branch naming, prompt templates.`,icon:Va,component:fw,scope:`project`},{id:`tasks`,title:`Tasks`,description:`Development model, landing, required checks, base branch, review, live titles.`,icon:Bl,component:DT,scope:`project`},{id:`agent-config`,title:`Agent config`,description:`Edit the coding agents’ own config files, per scope.`,icon:El,component:mC,scope:`project`},{id:`worktrees`,title:`Worktrees`,description:`How many finished task worktrees this project keeps on disk.`,icon:Ol,component:pE,scope:`project`},{id:`bookmarklets`,title:`Bookmarklets`,description:`Launch skills from a GitHub PR or issue.`,icon:_l,component:gw,scope:`project`},{id:`appearance`,title:`Appearance`,description:`Theme, accent and density.`,icon:Xl,component:nw,scope:`global`},{id:`notifications`,title:`Notifications`,description:`Browser notifications when an agent needs you.`,icon:hl,component:vw,scope:`global`},{id:`keyboard`,title:`Keyboard`,description:`Shortcuts for task commands.`,icon:Rl,component:mw,scope:`global`},{id:`resources`,title:`Resources`,description:`Parallel tasks and per-task memory limit, across every project.`,icon:Nl,component:_T,scope:`global`},{id:`skills`,title:`Skills`,description:`Updates for skills installed on this machine.`,icon:Jl,component:yT,scope:`global`},{id:`global-instructions`,title:`Instructions`,description:`A system prompt for every task in every project; a project’s own wins where they conflict.`,icon:Va,component:iw,scope:`global`},{id:`workspace-secrets`,title:`Secrets`,description:`Encrypted values shared by every project on this machine — never for agents.`,icon:Ll,component:xE,scope:`global`},{id:`accounts`,title:`Agent accounts`,description:`Second logins, and the agent and models a project uses when it has chosen none.`,icon:Fl,component:qS,scope:`global`},{id:`projects`,title:`Projects`,description:`The workspace registry and where GitHub checkouts land.`,icon:Ml,component:Yw,scope:`global`},{id:`transfer`,title:`Transfer`,description:`Export this machine’s configuration to a file, or import one from another cezar.`,icon:ml,component:VT,scope:`global`},{id:`privacy`,title:`Privacy`,description:`Whether cezar shares usage data with its maintainers. Off unless you turn it on.`,icon:nu,component:yw,scope:`global`}];function XE(e,t){return YE.filter(n=>!n.hidden&&n.scope===e&&!(t?.singleProject===!0&&n.id===`projects`))}function ZE(e){return{global:XE(`global`,e),project:XE(`project`,e)}}var QE=null;function $E(e){Wp(e.pathname)||(QE={pathname:e.pathname,search:e.search,hash:e.hash})}function eD(){return QE}function tD(){let e=C(),t=!e.isError&&e.data?.capabilities?.webhooks===!0,n=e.data?.capabilities?.webhooksUnavailableReason===`unsupported_platform`,r=mb(kr()??`default`,t),i=r.data?.receivers??[],a=i.filter(e=>[`suspended`,`disabled`].includes(e.state)).length,o=i.filter(e=>e.state===`inactive`).length,s=i.reduce((e,t)=>e+t.pendingCount,0);return(0,Q.jsx)($,{title:`Webhooks`,hint:`Task updates sent to Slack, Discord or your own endpoint.`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1 rounded-md border border-border bg-card p-3 text-ui`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[e.isError?(0,Q.jsx)(`p`,{children:`Status unavailable — could not load server health.`}):e.data?n?(0,Q.jsx)(`p`,{children:`Not available on this server’s platform.`}):t?r.isPending?(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading…`}):r.error?(0,Q.jsx)(`p`,{className:`text-danger`,children:`Status unavailable — open Webhooks for details.`}):i.length?(0,Q.jsxs)(`p`,{children:[i.filter(e=>e.state===`active`).length,` active · `,i.filter(e=>e.state===`paused`).length,` paused`,o?` · ${o} inactive`:``,a?(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsxs)(`span`,{className:`text-warning`,children:[a,` need attention`]})]}):``,s?` · ${s} pending`:``]}):(0,Q.jsx)(`p`,{children:`No receivers yet.`}):(0,Q.jsx)(`p`,{children:`Off on this server.`}):(0,Q.jsx)(`p`,{children:`Loading webhook status…`}),t&&!n&&!r.error&&r.data?.webhookHealth&&[`degraded`,`unavailable`].includes(r.data.webhookHealth.status)&&(0,Q.jsx)(`p`,{role:`status`,className:`text-warning`,children:r.data.webhookHealth.reason||`Webhook delivery needs attention. Open Webhooks for details.`})]}),(0,Q.jsx)(K,{className:`shrink-0 underline underline-offset-2 hover:text-foreground`,to:`/settings/webhooks`,children:t&&!n?`Manage webhooks`:`Open webhook settings`})]})})}function nD(){let e=kr(),t=W_(a().data,e,C().data);return e===null?null:t?.projects.find(t=>t.id===e)?.root??null}function rD(e){el(e).then(()=>Y(`Project folder copied`)).catch(()=>Y(e))}function iD(){let e=nD();return e===null?null:(0,Q.jsx)($,{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 items-start gap-3 rounded-md border border-border bg-card p-3`,children:[(0,Q.jsx)(`span`,{"data-slot":`project-location-path`,className:`min-w-0 flex-1 font-mono text-xs break-all text-foreground`,children:e}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Q.jsx)(`button`,{type:`button`,"data-action":`project-location-copy`,title:`Copy the project folder path`,onClick:()=>rD(e),className:`text-xs font-medium text-muted-foreground transition-colors hover:text-foreground`,children:`Copy`}),(0,Q.jsx)(oD,{root:e})]})]})})}function aD(){let e=nD();return e===null?null:(0,Q.jsxs)(`div`,{"data-slot":`project-location`,"data-variant":`nav`,className:`mt-auto px-2.5 pt-3`,children:[(0,Q.jsx)(`p`,{className:`text-meta text-soft-foreground`,children:`Project folder`}),(0,Q.jsx)(`button`,{type:`button`,"data-action":`project-location-copy`,title:`${e} — click to copy`,onClick:()=>rD(e),className:`block w-full truncate text-left font-mono text-meta text-muted-foreground transition-colors hover:text-foreground`,children:e})]})}function oD({root:e}){let t=D(),n=H({mutationFn:e=>ae(e),onError:e=>Y(e.message,{tone:`danger`})}),r=(t.data?.targets??[]).filter(e=>ls(e.id)===void 0).map(e=>({target:e}));return r.length===0?null:(0,Q.jsx)(Ro,{slot:`project-location-open`,label:`Open with`,triggerVariant:`outline`,title:e,disabled:n.isPending,choices:r,onPick:e=>n.mutate(e,{onSuccess:()=>Y(`Opening the project folder in ${r.find(t=>t.target.id===e)?.target.label??e}`)})})}function sD(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}function cD({capabilities:e}){let t=kr(),n=a(),r=C(),i=Ht();if(n.isPending)return(0,Q.jsx)(`p`,{"data-slot":`project-general-loading`,className:`text-ui text-soft-foreground`,children:`Loading project…`});if(n.isError)return(0,Q.jsxs)(`p`,{"data-slot":`project-general-error`,className:`text-ui text-danger`,children:[`Could not read the project registry — `,n.error.message]});let o=W_(n.data,t,r.data),s=o?.projects.find(e=>e.id===t);if(!o||!s)return null;let c=e?.singleProject!==!0&&s.unregistered!==!0;return(0,Q.jsxs)(`div`,{"data-slot":`project-general`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7`,children:[(0,Q.jsx)(iD,{}),(0,Q.jsx)(lD,{project:s,canRemove:c}),(0,Q.jsx)(tD,{}),s.unregistered?(0,Q.jsx)($,{title:`Add to your projects`,hint:`cezar is serving this folder because you started it here — starting cezar somewhere new never adds it to your project list for you. Adding it keeps it in the sidebar between runs and gives it a registry entry to hold settings like the task cap. Nothing on disk changes either way.`,children:(0,Q.jsx)(eT,{root:s.root,name:s.name,notAddable:s.notAddable===!0})}):null,c?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($,{title:`Max parallel tasks`,hint:i.data?`How many of this project's tasks may run at once — leave it empty to inherit the workspace limit. The workspace limit (${i.data.resources.maxParallel}) still applies as an overall ceiling, so a higher value here has no extra effect until that one is raised.`:`How many of this project's tasks may run at once — leave it empty to inherit the workspace limit. The workspace limit still applies as an overall ceiling.`,children:i.data?(0,Q.jsx)(nT,{project:s,workspaceMax:i.data.resources.maxParallel}):(0,Q.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:`Loading the workspace limit…`})}),(0,Q.jsx)(uD,{project:s,bootProject:o.bootProject})]}):null]})}function lD({project:e,canRemove:t}){return(0,Q.jsx)($,{title:`Project`,hint:`The registry entry for this checkout — re-probed every time the project list is read.`,children:(0,Q.jsxs)(`dl`,{"data-slot":`project-facts`,className:`grid grid-cols-[8rem_minmax(0,1fr)] gap-x-3 gap-y-1.5 rounded-md border border-border bg-card p-3 text-ui`,children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Name`}),(0,Q.jsx)(`dd`,{className:`min-w-0 truncate text-foreground`,children:e.name}),(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Status`}),(0,Q.jsxs)(`dd`,{"data-slot":`project-general-status`,className:e.status===`missing`?`text-danger`:`text-foreground`,children:[qw[e.status],e.status===`missing`?t?` — remove it below, or restore the folder`:` — restore the folder at the path above`:null]}),e.branch===void 0?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Branch`}),(0,Q.jsx)(`dd`,{className:`min-w-0 truncate font-mono text-xs text-foreground`,children:e.branch})]}),e.unregistered?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`In your projects`}),(0,Q.jsx)(`dd`,{"data-slot":`project-general-unregistered`,className:`text-foreground`,children:`No — served because cezar was started here`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Added`}),(0,Q.jsxs)(`dd`,{className:`text-foreground`,children:[sD(e.addedAt),(0,Q.jsx)(`span`,{className:`text-soft-foreground`,children:e.source===`checkout`?` · cloned from GitHub`:` · opened locally`})]}),(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Last opened`}),(0,Q.jsx)(`dd`,{className:`text-foreground`,children:sD(e.lastOpenedAt)})]})]})})}function uD({project:e,bootProject:t}){let[n,r]=(0,Z.useState)(null),i=Uw(),a=Nr(),o=e.id===t;return(0,Q.jsxs)($,{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 adding it back later finds everything intact.`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(J,{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 — stop it and use `cezar projects remove`":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-meta text-soft-foreground`,children:"cezar is serving this project — stop cezar and run `cezar projects remove` to drop it."}):null]}),(0,Q.jsx)(Ww,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{r(null),i.confirm(e,()=>void a(`/p/${encodeURIComponent(t)}`))}})]})}function dD(e,t){return e===`global`?`/settings/global/${t}`:`/settings/${t}`}var fD=`/settings/global`;function pD(e,t){let n=`/p/${encodeURIComponent(e)}/settings`;return t===void 0?n:`${n}/${t}`}function mD(e){let{pathname:t}=jr(),n=a().data,r=C().data,i=Sr(t),o=n?.bootProject??r?.bootProject??null,s=Z.useMemo(()=>{let e=[...n?.projects??[]].sort((e,t)=>t.lastOpenedAt.localeCompare(e.lastOpenedAt)).map(({id:e,name:t,status:n})=>({id:e,name:t,status:n}));if(i!==null&&!e.some(e=>e.id===i)){let t=i===o?r?.repo?.root.replace(/[\\/]+$/,``).split(/[\\/]/).pop():void 0;e.unshift({id:i,name:t||i,status:`ok`})}return e},[n,r,i,o]),c=s.find(e=>e.id===i)??null,l=c!==null&&(n?.projects??[]).some(e=>e.id===i),u=e?.singleProject===!0||s.length<=1||c!==null&&!l;return{projects:u&&c!==null&&!l?[c]:s,activeProjectId:i,activeProject:c,bootProjectId:o,flat:u}}function hD(e){let t=Nr();return Z.useCallback(()=>{let n=eD();if(n!==null){t(n);return}t(e===null?`/`:`/p/${encodeURIComponent(e)}/`)},[t,e])}function gD(e){Z.useEffect(()=>{let t=t=>{t.key!==`Escape`||t.defaultPrevented||(t.target instanceof Element?t.target:null)?.closest(`input, textarea, select, [contenteditable]`)||document.querySelector(`[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"]`)||e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}var _D=(e,t=!1)=>W(`flex h-[34px] shrink-0 items-center gap-2.5 rounded-md px-2.5 text-ui font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,t&&`h-11`,e&&`bg-muted font-semibold text-foreground`),vD=Z.createContext(!1);function yD({children:e}){return(0,Q.jsx)(`p`,{className:`shrink-0 px-2.5 pt-1 pb-1 eyebrow text-soft-foreground`,children:e})}function bD({project:e,sections:t,active:n,activeId:r,indent:i}){let a=Z.useContext(vD);return(0,Q.jsxs)(`div`,{className:W(`flex flex-col gap-0.5`,i&&`mt-0.5 ml-[14px] border-l border-border pl-2`),children:[(0,Q.jsxs)(br,{to:pD(e.id),end:!0,"data-slot":`settings-project-general`,"data-project":e.id,className:W(_D(n&&r===null,a),!a&&`h-[30px]`,`text-ui`),children:[(0,Q.jsx)(ti,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),`General`]}),t.map(t=>{let i=n&&t.id===r;return(0,Q.jsxs)(br,{to:_r(e.id,dD(`project`,t.id)),"data-project-section":t.id,"data-project":e.id,className:W(_D(i,a),!a&&`h-[30px]`,`text-ui`),children:[(0,Q.jsx)(t.icon,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),t.title]},t.id)})]})}function xD({project:e}){return(0,Q.jsx)(`span`,{className:`truncate`,children:e.name})}function SD({project:e,indent:t}){let n=`${e.name} is gone — remove it in Projects`;return(0,Q.jsxs)(`div`,{"data-slot":`settings-project`,"data-project":e.id,"data-status":`missing`,title:n,className:`flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-ui font-medium opacity-55`,children:[t?(0,Q.jsx)(`span`,{className:`w-3 shrink-0`,"aria-hidden":`true`}):null,(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Q.jsx)(`span`,{className:`sr-only`,children:n}),(0,Q.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full bg-danger/15 px-[7px] py-px text-micro font-medium text-danger`,children:`folder not found`})]})}function CD({project:e,sections:t,activeProjectId:n,activeId:r,openSectionId:i,onProjectPage:a,expanded:o,onToggle:s}){let c=e.id===n,l=Z.useContext(vD),u=`settings-project-${Z.useId()}-${e.id}`,d=!c&&a?pD(e.id,i??void 0):null;return e.status===`missing`?(0,Q.jsx)(SD,{project:e,indent:!0}):(0,Q.jsxs)(`div`,{"data-slot":`settings-project`,"data-project":e.id,"data-status":e.status,"data-expanded":o?``:void 0,children:[(0,Q.jsxs)(`div`,{className:W(`flex items-center rounded-md`,c&&r===null&&`bg-muted`),children:[(0,Q.jsx)(`button`,{type:`button`,onClick:s,"aria-expanded":o,"aria-controls":o?u:void 0,"aria-label":`${o?`Collapse`:`Expand`} ${e.name}`,className:W(`flex shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted/60 hover:text-foreground`,l?`size-11`:`size-7`),children:(0,Q.jsx)(Ws,{"aria-hidden":`true`,className:W(`size-3 transition-transform`,!o&&`-rotate-90`)})}),d===null?(0,Q.jsx)(`button`,{type:`button`,onClick:s,"aria-expanded":o,"aria-controls":o?u:void 0,"data-slot":`settings-project-toggle`,className:W(`flex min-w-0 flex-1 items-center gap-1.5 rounded-md py-1.5 pr-2 text-left text-ui font-semibold transition-colors`,l&&`min-h-11`,c?`text-foreground`:`text-muted-foreground hover:text-foreground`),children:(0,Q.jsx)(xD,{project:e})}):(0,Q.jsx)(yr,{to:d,"data-slot":`settings-project-link`,title:`Open ${e.name}'s ${t.find(e=>e.id===i)?.title??`General`}`,className:W(`flex min-w-0 flex-1 items-center gap-1.5 rounded-md py-1.5 pr-2 text-left text-ui font-semibold text-muted-foreground transition-colors hover:text-foreground`,l&&`min-h-11`),children:(0,Q.jsx)(xD,{project:e})})]}),o?(0,Q.jsx)(`div`,{id:u,children:(0,Q.jsx)(bD,{project:e,sections:t,active:c,activeId:r,indent:!0})}):null]})}function wD(e){let[t,n]=Um();return(0,Q.jsx)(eh,{slot:`settings-sidebar`,width:t,onWidthChange:n,children:(0,Q.jsx)(ED,{...e})})}function TD({onOpenChange:e,...t}){let{pathname:n}=jr();return Z.useEffect(()=>{e(!1)},[n,e]),Z.useEffect(()=>{let t=window.matchMedia?.(`(min-width: 768px)`);if(!t)return;let n=t=>{t.matches&&e(!1)};return t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[e]),(0,Q.jsx)(nh,{slot:`settings-mobile-drawer`,title:`Settings navigation`,children:e=>(0,Q.jsx)(ED,{...t,headerAction:e})})}function ED({scope:e,activeId:t,capabilities:n,tree:r,leave:i,headerAction:a}){let{global:o,project:s}=ZE(n),c=!!a,l=r.activeProjectId,[u,d]=Z.useState({project:l,map:{}}),f=u.project===l?u.map:{},p=e=>f[e]??e===l,m=e=>d(t=>{let n=t.project===l?t.map:{};return{project:l,map:{...n,[e]:!(n[e]??e===l)}}}),h=e===`global`,[g]=r.projects,_=C().data,v=_?.version??null,y=_?.latestVersion??null,b=ne().data,x=b?.available?b.count??null:null,S=Ht().data?.branding,w=S?.name??`cezar`,T=S?.logoUrl??null;return(0,Q.jsx)(vD.Provider,{value:c,children:(0,Q.jsxs)(`div`,{"data-slot":`settings-sidebar-content`,className:`flex min-h-0 flex-1 flex-col pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-[9px] px-3.5 pt-3.5 pb-2.5`,children:[(0,Q.jsx)(cm,{name:w,logoUrl:T}),(0,Q.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`settings-back`,title:`Back (Esc)`,onClick:i,className:W(`-mr-2 ml-auto shrink-0`,c?`h-11`:`h-[26px]`),children:[(0,Q.jsx)(no,{"aria-hidden":`true`,className:`size-4`}),`Back`]}),a?(0,Q.jsx)(`div`,{className:`shrink-0`,children:a}):null]}),(0,Q.jsxs)(`nav`,{"aria-label":`Settings sections`,"data-slot":`settings-nav`,"data-scope":e,className:`flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto overscroll-contain px-2.5 py-1.5`,children:[(0,Q.jsx)(yD,{children:`General settings`}),o.map(e=>{let n=h&&e.id===t;return(0,Q.jsxs)(br,{to:dD(`global`,e.id),"data-section":e.id,className:_D(n,c),children:[(0,Q.jsx)(e.icon,{"aria-hidden":`true`,className:`size-4 shrink-0`}),e.title]},e.id)}),(0,Q.jsx)(`p`,{className:`shrink-0 px-2.5 pt-1 pb-2 text-meta text-soft-foreground`,children:`Stored in ~/.cezar`}),r.projects.length>0?(0,Q.jsx)(`div`,{"data-slot":`settings-project-tree`,className:`mt-1 flex shrink-0 flex-col gap-0.5 border-t border-border pt-3`,children:r.flat&&g?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(yD,{children:g.id===l?`This project`:g.name}),g.status===`missing`?(0,Q.jsx)(SD,{project:g,indent:!1}):(0,Q.jsx)(bD,{project:g,sections:s,active:g.id===l,activeId:t,indent:!1})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(yD,{children:`Project settings`}),r.projects.map(n=>(0,Q.jsx)(CD,{project:n,sections:s,activeProjectId:r.activeProjectId,activeId:t,openSectionId:e===`project`?t:null,onProjectPage:e===`project`,expanded:p(n.id),onToggle:()=>m(n.id)},n.id))]})}):null,e===`project`?(0,Q.jsx)(aD,{}):null]}),(0,Q.jsxs)(`div`,{"data-slot":`settings-sidebar-footer`,className:`flex flex-col gap-1.5 border-t border-border px-3.5 py-2.5`,children:[(0,Q.jsx)(Up,{}),(0,Q.jsxs)(`div`,{"data-slot":`settings-sidebar-footer-controls`,className:`flex items-center gap-2`,children:[v?(0,Q.jsx)(jh,{version:v,latestVersion:y,brandName:w}):null,x===null?null:(0,Q.jsx)(Mh,{count:x}),(0,Q.jsx)(Gf,{className:`ml-auto`})]})]})]})})}function DD({scope:e,activeId:t,capabilities:n}){let r=ZE(n)[e],i=e===`global`?br:Tr,a=e=>W(`rounded-full border px-3 py-1.5 text-ui font-medium whitespace-nowrap transition-colors`,e?`border-transparent bg-contrast text-contrast-foreground`:`border-border bg-card text-muted-foreground`);return(0,Q.jsxs)(`nav`,{"aria-label":`Sections of this area`,"data-slot":`settings-nav-mobile`,className:`flex shrink-0 gap-1.5 overflow-x-auto border-b border-border px-3 py-2.5 md:hidden`,children:[e===`project`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(yr,{to:fD,"data-slot":`settings-all-pill`,className:a(!1),children:`‹ General settings`}),(0,Q.jsx)(i,{to:`/settings`,end:!0,"data-slot":`settings-nav-index`,className:a(!1),children:`General`})]}):null,r.map(n=>(0,Q.jsx)(i,{to:dD(e,n.id),"data-section":n.id,className:a(n.id===t),children:n.title},n.id))]})}function OD({title:e,projectName:t}){return(0,Q.jsx)(`div`,{"data-slot":`settings-mobile-bar`,className:`shrink-0 border-b border-border bg-card pt-[env(safe-area-inset-top)] md:hidden`,children:(0,Q.jsxs)(`div`,{className:`flex h-[52px] items-center gap-1 px-2`,children:[(0,Q.jsx)(Hi,{asChild:!0,children:(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Open settings menu`,className:`size-11`,children:(0,Q.jsx)(Ul,{"aria-hidden":`true`,className:`size-[17px]`})})}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(kD,{title:e,projectName:t,as:`span`})})]})})}function kD({title:e,projectName:t,as:n}){let r=n===`h1`?`text-base`:`text-body`;return(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[t?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"data-slot":`settings-scope-chip`,className:W(`truncate font-semibold text-muted-foreground`,r),children:t}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:W(`shrink-0 font-normal text-soft-foreground`,r),children:`/`})]}):null,(0,Q.jsx)(n,{className:W(`truncate font-semibold`,r),children:e})]})}function AD({scope:e,section:t,title:n,beside:r}){return(0,Q.jsxs)(`header`,{"data-slot":`settings-header`,className:`sticky top-0 z-10 hidden h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-5 md:flex`,children:[(0,Q.jsx)(kD,{title:n,projectName:r,as:`h1`}),t?(0,Q.jsx)(`p`,{className:`min-w-0 truncate text-ui text-soft-foreground`,children:t.description}):e===`project`?(0,Q.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:`Project settings`}):null]})}function jD({scope:e,section:t,capabilities:n,routeName:r,children:i}){let a=mD(n),o=hD(a.activeProjectId??a.bootProjectId);gD(o);let s=a.activeProject?.name??a.activeProjectId,c=t?.title??(e===`global`?`Settings`:s??`Settings`),l=e===`project`&&t!==null?s:null,[u,d]=Z.useState(!1),f={scope:e,activeId:t?.id??null,capabilities:n,tree:a,leave:o};return(0,Q.jsx)(Ui,{open:u,onOpenChange:d,children:(0,Q.jsxs)(`div`,{"data-route":r,className:`flex h-full min-h-full`,children:[(0,Q.jsx)(wD,{...f}),(0,Q.jsx)(TD,{...f,onOpenChange:d}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col overflow-y-auto overscroll-contain`,children:[(0,Q.jsx)(OD,{title:c,projectName:l}),(0,Q.jsx)(AD,{scope:e,section:t,title:c,beside:l}),t?(0,Q.jsx)(DD,{scope:e,activeId:t.id,capabilities:n}):null,(0,Q.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:i})]})]})})}function MD({section:e,scope:t,capabilities:n}){let r=e.component;return(0,Q.jsx)(jD,{scope:t,section:e,capabilities:n,routeName:t===`global`?`settings-global-${e.id}`:`settings-${e.id}`,children:(0,Q.jsx)(r,{})})}var ND=`flex items-center gap-3.5 rounded-lg border border-border bg-card p-4 shadow-xs transition-colors hover:bg-card-2`;function PD({section:e}){return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(K,{to:dD(`project`,e.id),"data-section":e.id,className:ND,children:[(0,Q.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-md border border-border bg-muted text-muted-foreground`,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)(Ks,{"aria-hidden":`true`,className:`size-4 shrink-0 text-soft-foreground`})]})})}function FD({scope:e,capabilities:t}){let n=jr(),r=ZE(t)[e];if(e===`global`){let e=r[0];return(0,Q.jsx)(Dr,{to:{pathname:dD(`global`,e.id),search:n.search,hash:n.hash},replace:!0})}return(0,Q.jsx)(jD,{scope:e,section:null,capabilities:t,routeName:`settings`,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col p-3 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-5 md:pb-5`,children:[(0,Q.jsx)(cD,{capabilities:t}),(0,Q.jsx)(`ul`,{"data-slot":`settings-index`,className:`mx-auto mt-7 flex w-full max-w-2xl flex-col gap-2.5 md:hidden`,children:r.map(e=>(0,Q.jsx)(PD,{section:e},e.id))})]})})}var ID={archive:`Archive`,restore:`Restore`,read:`Mark read`,unread:`Mark unread`};function LD(e,t){return t===`restore`?!!e.archived:t===`archive`?!e.archived&&Qo(e.status):Wo(e)&&$o(e)===(t===`read`)}function RD(e,t){let[n,r]=Z.useState(new Set),[i,a]=Z.useState(!1),[o,s]=Z.useState(``),c=Z.useRef(!1),l=e.filter(e=>n.has(e.id));return Z.useEffect(()=>{let t=new Set(e.map(e=>e.id));r(e=>{let n=new Set([...e].filter(e=>t.has(e)));return n.size===e.size?e:n})},[e]),{ids:n,selected:l,busy:i,message:o,toggle:Z.useCallback(e=>{c.current||r(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},[]),clear:()=>{c.current||r(new Set)},toggleAll:()=>{c.current||r(l.length===e.length?new Set:new Set(e.map(e=>e.id)))},apply:Z.useCallback(async(e,n)=>{if(c.current||!t)return;c.current=!0,a(!0),s(`${ID[e]} in progress…`);let i=n.filter(t=>LD(t,e)),o=new Set,l=[];for(let n of i)try{await t(n,e),o.add(n.id)}catch(e){l.push(`${Ve(n)}: ${e instanceof Error?e.message:`Request failed`}`)}r(e=>new Set([...e].filter(e=>!o.has(e)))),s(`${ID[e]}: ${o.size} succeeded, ${n.length-i.length} skipped, ${l.length} failed.${l.length?` ${l.join(`; `)}`:``}`),c.current=!1,a(!1)},[t])}}function zD({checked:e,mixed:t=!1,label:n,disabled:r,onChange:i}){let a=Z.useRef(null);return Z.useEffect(()=>{a.current&&(a.current.indeterminate=t)},[t]),(0,Q.jsx)(`input`,{ref:a,type:`checkbox`,"aria-label":n,checked:e,disabled:r,onChange:i,className:`size-4 shrink-0 cursor-pointer accent-primary focus-visible:outline-2 focus-visible:outline-ring`})}function BD({displayed:e,selection:t,archived:n}){let{selected:r,busy:i}=t,a=[n?`restore`:`archive`,`read`,`unread`];return(0,Q.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-md border border-border bg-card px-3 py-2 text-sm`,children:[(0,Q.jsx)(zD,{label:`Select displayed tasks`,checked:e.length>0&&r.length===e.length,mixed:r.length>0&&r.length<e.length,disabled:i||e.length===0,onChange:t.toggleAll}),(0,Q.jsx)(`span`,{children:r.length>0?`${r.length} selected`:`Select tasks`}),r.length>0?(0,Q.jsxs)(Q.Fragment,{children:[a.map(e=>{let n=r.filter(t=>LD(t,e)).length;return(0,Q.jsxs)(J,{type:`button`,size:`sm`,variant:`outline`,disabled:i||n===0,onClick:()=>void t.apply(e,r),children:[ID[e],` (`,n,`)`]},e)}),(0,Q.jsx)(J,{type:`button`,size:`sm`,variant:`ghost`,disabled:i,onClick:t.clear,children:`Clear selection`}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Only eligible selected tasks are changed; others are skipped.`})]}):null,(0,Q.jsx)(`p`,{role:`status`,"aria-label":`Task action status`,"aria-live":`polite`,className:`w-full empty:hidden text-xs text-muted-foreground`,children:t.message})]})}function VD({run:e,busy:t,onAction:n}){let r=[e.archived?`restore`:`archive`,$o(e)?`read`:`unread`],i={archive:wa,restore:pl,read:lc,unread:Tl};return(0,Q.jsx)(`span`,{className:`inline-flex shrink-0 items-center gap-1`,children:r.filter(t=>LD(e,t)).map(r=>{let a=i[r],o=`${ID[r]}: ${Ve(e)}`;return(0,Q.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,title:o,"aria-label":o,disabled:t,onClick:()=>void n(r,[e]),children:(0,Q.jsx)(a,{className:`size-3.5`,"aria-hidden":`true`})},r)})})}function HD({label:e,expanded:t,onToggle:n,className:r,wordClassName:i}){let[a,...o]=e.split(` `);return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`subtask-toggle`,"aria-expanded":t,"aria-label":`${t?`Collapse`:`Expand`} ${e}`,onClick:n,className:W(`inline-flex shrink-0 items-center gap-0.5 rounded-full bg-muted py-px pr-1.5 pl-1 text-micro font-medium text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,r),children:[(0,Q.jsx)(Ks,{className:W(`size-3 transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),a,(0,Q.jsx)(`span`,{className:i,children:` ${o.join(` `)}`})]})}function UD({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`skeleton`,className:W(`animate-pulse rounded-md bg-accent`,e),...t})}var WD=[{id:`status`,label:`Status`,canFold:!1,defaultExpanded:!0,align:`left`,width:`116px`},{id:`task`,label:`Task`,canFold:!1,defaultExpanded:!0,align:`left`},{id:`workflow`,label:`Workflow`,canFold:!0,defaultExpanded:!0,align:`left`,width:`124px`,icon:`workflow`},{id:`branch`,label:`Branch`,canFold:!0,defaultExpanded:!1,align:`left`,width:`128px`,icon:`branch`},{id:`diff`,label:`±`,canFold:!0,defaultExpanded:!0,align:`left`,width:`78px`,icon:`diff`},{id:`reference`,label:`Ref`,canFold:!0,defaultExpanded:!0,align:`left`,width:`76px`,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:`76px`,icon:`cost`,capability:`cost`},{id:`cpu`,label:`CPU`,canFold:!0,defaultExpanded:!0,align:`right`,width:`68px`,icon:`cpu`},{id:`memory`,label:`Mem`,canFold:!0,defaultExpanded:!0,align:`right`,width:`88px`,icon:`memory`},{id:`started`,label:`Started`,canFold:!0,defaultExpanded:!0,align:`right`,width:`82px`,icon:`started`}],GD=new Map(WD.map(e=>[e.id,e]));function KD(e){return typeof e!=`object`||!e||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`boolean`))}function qD(e){let t={};for(let[n,r]of Object.entries(KD(e))){let e=GD.get(n);e?.canFold&&(t[e.id]=r)}return t}function JD(e,t){let n=GD.get(e);return!n||!n.canFold?!0:t[e]??n.defaultExpanded}function YD(e,t){let n=KD(e);return GD.get(t)?.canFold?{...n,[t]:!JD(t,qD(e))}:n}function XD(e){return WD.filter(t=>t.capability===void 0||e[t.capability])}function ZD(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function QD(){let e=U(),t=ht(),n=Z.useRef(0),r=Z.useRef(0),i=Z.useRef(Promise.resolve()),a=Z.useMemo(()=>qD(t.data?.taskTable?.expandedColumns),[t.data?.taskTable?.expandedColumns]),o=Z.useCallback(t=>{if(!WD.find(e=>e.id===t)?.canFold)return;let a=e.getQueryData(B.uiState);if(a===void 0)return;let o=ZD(a?.taskTable),s={...o,expandedColumns:YD(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 Pt({taskTable:s},{keepalive:!0});c===r.current&&e.setQueryData(B.uiState,t)});i.current=l.catch(t=>{Y(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=>JD(e,a),[a]),toggleColumn:o,isPending:t.isPending}}var $D=Z.createContext(null);function eO({intervalMs:e,now:t,children:n}){let r=Yr(e,t===void 0);return(0,Q.jsx)($D.Provider,{value:t??r,children:n})}function tO({at:e}){return(0,Q.jsx)(Q.Fragment,{children:Xc(e,Z.useContext($D)??Date.now())})}var nO=12,rO=40;function iO({height:e,colSpan:t}){return e<=0?null:(0,Q.jsx)(`tr`,{"data-row-spacer":``,"aria-hidden":`true`,children:(0,Q.jsx)(`td`,{colSpan:t,style:{height:e,padding:0,border:0}})})}function aO(e,t=45){let n=e>100,r=Z.useRef(null),[i,a]=Z.useState({start:0,end:rO,height:t});if(Z.useLayoutEffect(()=>{if(!n)return;let e=r.current;if(!e)return;let i=e.closest(`[data-slot="main"]`),o=()=>{let n=i?i.getBoundingClientRect().top:0,r=i?i.clientHeight:window.innerHeight,o=e.getBoundingClientRect().top-n,s=e.querySelector(`:scope > tr:not([data-row-spacer]):not([data-row-unsampled])`)?.getBoundingClientRect().height,c=s!==void 0&&s>0?s:t,l=Math.floor(Math.max(0,-o)/c),u=Math.ceil(Math.max(0,r-o)/c),d=Math.max(0,l-nO),f=Math.max(d,u+nO);a(e=>e.start===d&&e.end===f&&e.height===c?e:{start:d,end:f,height:c})};o();let s=0,c=()=>{s===0&&(s=requestAnimationFrame(()=>{s=0,o()}))},l=i??window;l.addEventListener(`scroll`,c,{passive:!0}),window.addEventListener(`resize`,o);let u=typeof ResizeObserver==`function`?new ResizeObserver(o):void 0;for(let e of i?Array.from(i.children):[document.body])u?.observe(e);return()=>{s!==0&&cancelAnimationFrame(s),l.removeEventListener(`scroll`,c),window.removeEventListener(`resize`,o),u?.disconnect()}},[n,e,t]),!n)return{anchorRef:r,windowed:n,start:0,end:e,padTop:0,padBottom:0,ariaRowCount:void 0,ariaRowIndex:oO};let o=Math.max(1,i.end-i.start),s=Math.max(0,Math.min(i.start,e-o)),c=Math.min(Math.max(i.end,s+o),e);return{anchorRef:r,windowed:n,start:s,end:c,padTop:s*i.height,padBottom:(e-c)*i.height,ariaRowCount:e+1,ariaRowIndex:sO}}var oO=()=>void 0,sO=e=>e+2,cO=[],lO=qD(void 0),uO=()=>void 0,dO=3e4;function fO({runs:e,view:t,onViewChange:n,onArchiveFinished:r,onMarkAllRead:i,onRename:a,onTogglePin:o,onTaskAction:s,now:c,showTokens:l=!0,showCost:u=!0,expandedColumns:d=lO,onToggleColumn:f=uO,columnsPending:p=!1,origin:m=`all`,onOriginChange:h=()=>void 0,automationNames:g,gitRepo:_=!0,scheduledTasks:v,hasScheduledTasks:y=!!v,firstRun:b,setupPill:x,welcomeBack:S}){let[C,w]=Z.useState(``),[T,E]=Z.useState(new Set),D=Z.useCallback(e=>E(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),[]),[k,j]=Z.useState(Lg),[M,N]=Z.useState(`recent`),P=e??cO,F=Z.useMemo(()=>P.some(e=>t===`archived`===e.archived),[P,t]),ee=Z.useMemo(()=>zg(P),[P]),te=Z.useMemo(()=>Vg(P,m,k,ee),[P,m,k,ee]),I=Z.useMemo(()=>Le(te),[te]),ne=Z.useMemo(()=>ot(te,C),[te,C]),L=Z.useMemo(()=>re(ne,t,M),[ne,t,M]),ie=C.trim()!==``,ae=Z.useCallback(e=>ie||T.has(e),[ie,T]),oe=Z.useMemo(()=>Ue(L,t).map(e=>({...e,rows:Jg(e.runs,ae),taskCount:Jg(e.runs,()=>!1).length})),[L,t,ae]),se=Z.useMemo(()=>oe.flatMap(e=>[...e.label?[{kind:`section`,section:e}]:[],...e.rows.map(e=>({kind:`row`,node:e}))]),[oe]),ce=Z.useMemo(()=>oe.flatMap(e=>e.rows.map(e=>e.run)),[oe]),le=RD(ce,s),R=Z.useMemo(()=>A(P),[P]),ue=Z.useMemo(()=>Bn(ne,t),[ne,t]),de=Z.useMemo(()=>Fn(P),[P]),fe=Z.useMemo(()=>XD({tokens:l,cost:u}).map(e=>e.id===`started`?{...e,label:fn(M)}:e),[l,u,M]),pe=Z.useMemo(()=>qo(P),[P]),z=aO(se.length),me=t===`archived`?void 0:o;return(0,Q.jsx)(eO,{intervalMs:dO,now:c,children:(0,Q.jsxs)(`div`,{"data-route":`tasks`,className:`flex min-h-full flex-col`,children:[(0,Q.jsxs)(`header`,{className:`sticky top-0 z-10 hidden h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-5 md:flex`,children:[(0,Q.jsx)(`h1`,{className:`text-base font-semibold`,children:`Tasks`}),(0,Q.jsxs)(`div`,{className:`inline-flex gap-0.5 rounded-md bg-muted p-[3px]`,children:[(0,Q.jsx)(gO,{view:`active`,current:t,onSelect:n,count:I.active,children:`Active`}),(0,Q.jsx)(gO,{view:`archived`,current:t,onSelect:n,count:I.archived,children:`Archived`})]}),(0,Q.jsx)(`div`,{className:`flex-1`}),pe>0?(0,Q.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`mark-all-read`,onClick:i,children:[(0,Q.jsx)(yi,{className:`size-3.5`,"aria-hidden":`true`}),`Mark all read`]}):null,t===`active`&&de>0?(0,Q.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`archive-finished`,onClick:r,children:[(0,Q.jsx)(wa,{className:`size-3.5`,"aria-hidden":`true`}),`Archive finished`]}):null,(0,Q.jsxs)(`div`,{className:`relative w-60`,children:[(0,Q.jsx)(Cc,{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:C,onChange:e=>w(e.target.value),placeholder:`Search tasks…`,"aria-label":`Search tasks`,className:`h-9 w-full rounded-md border border-input bg-card pr-3 pl-8 text-ui text-foreground outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`})]})]}),v,(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col p-3 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-5 md:pb-5`,children:[F?S:null,F?x:null,F?(0,Q.jsx)(hO,{runs:P,view:t,origin:m,onOriginChange:h,filters:k,onFiltersChange:j,automations:ee,automationNames:g,sortBy:M,onSortByChange:N}):null,s?(0,Q.jsx)(BD,{displayed:ce,selection:le,archived:t===`archived`}):null,e===void 0?null:y&&P.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No tasks have started yet.`}):L.length===0?(0,Q.jsx)(mO,{view:t,query:C,filtered:Rg(k)>0,onClearFilters:()=>j(Lg),origin:m,hiddenByOrigin:m!==`all`&&Vg(O(P,t),`all`,k,ee).length>0,onShowAll:()=>h(`all`),firstRun:b}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{"data-slot":`tasks-table`,className:`hidden overflow-x-auto rounded-lg border border-border bg-card shadow-xs md:block`,children:(0,Q.jsx)(kc,{children:(0,Q.jsxs)(`table`,{className:`w-full border-collapse`,"aria-rowcount":z.ariaRowCount,children:[(0,Q.jsxs)(`colgroup`,{children:[s?(0,Q.jsx)(`col`,{style:{width:`112px`}}):null,fe.map(e=>{let t=JD(e.id,d);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.jsxs)(`tr`,{"aria-rowindex":z.windowed?1:void 0,children:[s?(0,Q.jsx)(`th`,{scope:`col`,children:(0,Q.jsx)(`span`,{className:`sr-only`,children:`Task controls`})}):null,fe.map(e=>(0,Q.jsx)(vO,{column:e,expanded:JD(e.id,d),onToggle:f,disabled:p},e.id))]})}),(0,Q.jsxs)(`tbody`,{ref:z.anchorRef,className:`[&>tr:last-child>td]:border-b-0`,children:[(0,Q.jsx)(iO,{height:z.padTop,colSpan:fe.length+ +!!s}),se.slice(z.start,z.end).map((e,t)=>e.kind===`section`?(0,Q.jsx)(`tr`,{"data-slot":`tasks-section`,"data-section":e.section.key,"data-row-unsampled":``,"aria-rowindex":z.ariaRowIndex(z.start+t),children:(0,Q.jsxs)(`th`,{scope:`rowgroup`,colSpan:fe.length+ +!!s,className:W(bO,`border-b border-border bg-muted/40 px-3.5 py-1.5 text-left`),children:[e.section.label,` · `,e.section.taskCount]})},`section-${e.section.key}`):(0,Q.jsx)(SO,{ariaRowIndex:z.ariaRowIndex(z.start+t),gitRepo:_,run:e.node.run,depth:e.node.depth,childCount:e.node.childCount,subtasksExpanded:ae(e.node.run.id),onToggleSubtasks:D,queuePosition:e.node.run.status===`queued`?R.get(e.node.run.id)??null:null,onRename:a,onTogglePin:me,selectable:!!s,selected:le.ids.has(e.node.run.id),onSelect:le.toggle,actionsBusy:le.busy,onAction:le.apply,sortBy:M,columns:fe,expandedColumns:d},e.node.run.id)),(0,Q.jsx)(iO,{height:z.padBottom,colSpan:fe.length+ +!!s})]})]})})}),(0,Q.jsx)(pO,{cards:se.map(e=>e.kind===`section`?(0,Q.jsxs)(`h2`,{"data-slot":`tasks-section`,"data-section":e.section.key,className:W(bO,`px-1 pt-1`),children:[e.section.label,` · `,e.section.taskCount]},`section-${e.section.key}`):(0,Q.jsx)(OO,{run:e.node.run,depth:e.node.depth,childCount:e.node.childCount,subtasksExpanded:ae(e.node.run.id),onToggleSubtasks:D,queuePosition:e.node.run.status===`queued`?R.get(e.node.run.id)??null:null,sortBy:M,showTokens:l,showCost:u,onTogglePin:me,selectable:!!s,selected:le.ids.has(e.node.run.id),onSelect:le.toggle,actionsBusy:le.busy,onAction:le.apply,gitRepo:_},e.node.run.id))})]}),ue.map(e=>(0,Q.jsxs)(`div`,{"data-slot":`compare-strip`,"data-group-id":e.groupId,className:`mt-3.5 flex flex-wrap items-center gap-2.5 rounded-lg border border-border bg-card px-3.5 py-2.5 text-label text-muted-foreground shadow-xs`,children:[(0,Q.jsx)(eu,{className:`size-[15px] shrink-0 text-soft-foreground`,"aria-hidden":`true`}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e.title}),` — `,e.count,` variants finished`]}),(0,Q.jsx)(J,{asChild:!0,variant:`outline`,size:`sm`,className:`md:ml-auto`,children:(0,Q.jsx)(K,{to:`/compare/${e.groupId}`,children:`Compare`})})]},e.groupId))]}),(0,Q.jsx)(K,{to:`/new`,"data-slot":`new-task-fab`,"aria-label":`New task`,className:`fixed right-4 bottom-[calc(16px+env(safe-area-inset-bottom))] z-20 inline-flex size-14 items-center justify-center rounded-full bg-primary text-primary-foreground shadow-modal md:hidden`,children:(0,Q.jsx)(xc,{className:`size-[22px]`,"aria-hidden":`true`})})]})})}function pO({cards:e}){let t=e.length>100,n=Z.useRef(null),r=Z.useRef(null),[i,a]=Z.useState(0);return Z.useLayoutEffect(()=>{if(!t)return;let e=()=>{let e=n.current,t=r.current;!e||!t||a(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[t]),(0,Q.jsx)(`div`,{ref:e=>{n.current=e,e&&(r.current=e.closest(`[data-slot="main"]`))},"data-slot":`task-cards`,"data-virtualized":t,className:W(`flex flex-col md:hidden`,t?null:`gap-2.5`),children:t?(0,Q.jsx)($c,{scrollRef:r,startMargin:i,children:e.map(e=>(0,Q.jsx)(`div`,{className:`pb-2.5`,children:e},e.key))}):e})}function mO({view:e,query:t,filtered:n=!1,onClearFilters:r=()=>void 0,origin:i=`all`,hiddenByOrigin:a=!1,onShowAll:o=()=>void 0,firstRun:s}){let c=t.trim(),l=c?`search-miss`:n?`filtered`:a?`origin-hidden`:e===`archived`?`archive`:`no-tasks`;return(0,Q.jsx)(`div`,{"data-slot":`tasks-empty`,"data-empty-kind":l,className:`flex flex-1 flex-col`,children:l===`filtered`?(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(Sc,{}),tone:`neutral`,title:`No tasks match these filters`,actions:(0,Q.jsx)(J,{type:`button`,variant:`outline`,onClick:r,children:`Clear filters`})}):l===`origin-hidden`?(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(mc,{}),tone:`neutral`,title:i===`regular`?`No regular tasks here`:`No automation tasks here`,subtitle:i===`regular`?`Tasks started by automations are hidden.`:`Only tasks started by automations are shown.`,actions:(0,Q.jsx)(J,{type:`button`,variant:`outline`,onClick:o,children:`Show all tasks`})}):l===`search-miss`?(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(Sc,{}),tone:`neutral`,title:`No matching tasks`,subtitle:`No tasks match “${c}”.`}):l===`archive`?(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(wa,{}),tone:`neutral`,title:`Nothing archived yet`,subtitle:`Finished tasks you archive land here.`}):s||(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(Bl,{}),tone:`primary`,backdrop:!0,title:`No tasks yet`,subtitle:`Describe a task to get started.`,actions:(0,Q.jsx)(J,{asChild:!0,children:(0,Q.jsxs)(K,{to:`/new`,children:[(0,Q.jsx)(xc,{"aria-hidden":`true`}),`New task`]})})})})}function hO({runs:e,view:t,origin:n,onOriginChange:r,filters:i,onFiltersChange:a,automations:o,automationNames:s,sortBy:c,onSortByChange:l}){let u=Z.useMemo(()=>e.filter(e=>t===`archived`?e.archived:!e.archived),[e,t]),d=Wg(u,i,o),f=e=>Ug(u,n,i,o,e),p=f(`statuses`),m=f(`workflows`),h=f(`automations`),g=Gg(u.map(e=>o.get(e.id))),_=(e,t)=>a(n=>({...n,[e]:n[e].includes(t)?n[e].filter(e=>e!==t):[...n[e],t]})),v=e=>a(t=>({...t,[e]:[]})),y=Rg(i);return(0,Q.jsxs)(`div`,{"data-slot":`tasks-filters`,className:`mb-3 flex flex-wrap items-center gap-1.5`,children:[(0,Q.jsx)(_i,{slot:`task-origin`,label:`Show tasks started by`,value:n,options:Zf.map(e=>({...e,count:d[e.value]})),onChange:r}),(0,Q.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`,"aria-hidden":`true`}),(0,Q.jsx)(Ti,{slot:`status`,label:`Status`,selected:i.statuses,onToggle:e=>_(`statuses`,e),onClear:()=>v(`statuses`),options:Gg(u.map(e=>e.status)).map(e=>({value:e,label:e,count:p.get(e)??0})),emptyLabel:`No tasks to filter`}),(0,Q.jsx)(Ti,{slot:`workflow`,label:`Workflow`,selected:i.workflows,onToggle:e=>_(`workflows`,e),onClear:()=>v(`workflows`),options:Gg(u.map(e=>he(e))).map(e=>({value:e,label:e,count:m.get(e)??0})),emptyLabel:`No tasks to filter`}),n!==`regular`&&g.length>0?(0,Q.jsx)(Ti,{slot:`automation`,label:`Automation`,selected:i.automations,onToggle:e=>_(`automations`,e),onClear:()=>v(`automations`),options:g.map(e=>({value:e,label:s?.get(e)??e,count:h.get(e)??0})),emptyLabel:`No automation tasks`}):null,y>0?(0,Q.jsxs)(`button`,{type:`button`,"data-action":`clear-filters`,onClick:()=>a(()=>Lg),className:`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)(Tc,{className:`size-3`,"aria-hidden":`true`}),`Clear (`,y,`)`]}):null,(0,Q.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`text-meta font-medium text-soft-foreground`,children:`Sort by`}),(0,Q.jsx)(_i,{slot:`sort-by`,label:`Sort tasks by`,value:c,options:w,onChange:l})]})}function gO({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:W(`flex h-7 items-center justify-center gap-1.5 rounded-[7px] px-3 text-label font-medium text-muted-foreground`,a&&`bg-card font-semibold text-foreground shadow-xs`),children:[i,r>0?(0,Q.jsx)(`span`,{className:`font-mono text-meta tabular-nums`,children:r}):null]})}function _O({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:W(`h-[38px] border-b border-border px-2.5 text-left eyebrow whitespace-nowrap text-soft-foreground first:pl-4 last:pr-4`,t&&`text-right`,r&&`px-0 first:pl-0 last:pr-0`),children:e})}function vO({column:e,expanded:t,onToggle:n,disabled:r}){if(!e.canFold)return(0,Q.jsx)(_O,{columnId:e.id,right:e.align===`right`,children:e.label});let i=t?`Fold`:`Expand`;return(0,Q.jsx)(_O,{columnId:e.id,right:e.align===`right`,folded:!t,children:(0,Q.jsxs)(Ac,{children:[(0,Q.jsx)(Dc,{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:W(`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)(yl,{className:`size-3 opacity-55`,"aria-hidden":`true`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(yO,{icon:e.icon}),(0,Q.jsx)(bl,{className:`size-3 opacity-70`,"aria-hidden":`true`})]})})}),(0,Q.jsxs)(Oc,{side:`top`,children:[e.label,` · `,i,` column`]})]})})}function yO({icon:e}){let t=`size-3.5`;switch(e){case`workflow`:return(0,Q.jsx)(mc,{className:t,"aria-hidden":`true`});case`branch`:return(0,Q.jsx)(cc,{className:t,"aria-hidden":`true`});case`diff`:return(0,Q.jsx)(oc,{className:t,"aria-hidden":`true`});case`reference`:return(0,Q.jsx)(Ta,{className:t,"aria-hidden":`true`});case`tokens`:return(0,Q.jsx)(Sl,{className:t,"aria-hidden":`true`});case`cost`:return(0,Q.jsx)(si,{className:t,"aria-hidden":`true`});case`cpu`:return(0,Q.jsx)(_s,{className:t,"aria-hidden":`true`});case`memory`:return(0,Q.jsx)(Hl,{className:t,"aria-hidden":`true`});case`started`:return(0,Q.jsx)(xl,{className:t,"aria-hidden":`true`});default:return null}}var bO=`eyebrow text-soft-foreground`,xO=`h-11 border-b border-border px-2.5 whitespace-nowrap first:pl-4 last:pr-4`,SO=Z.memo(function({ariaRowIndex:e,gitRepo:t,run:n,depth:r,childCount:i,subtasksExpanded:a,onToggleSubtasks:s,queuePosition:c,onRename:l,onTogglePin:u,sortBy:d,columns:f,expandedColumns:p,selectable:m,selected:h,onSelect:g,actionsBusy:_,onAction:v}){let y=vr(),x=o(n),S=b(n),C=`/tasks/${n.id}`,w=we(n.costUsd),T=zt(n);return(0,Q.jsxs)(`tr`,{"data-slot":`task-table-row`,"data-run-id":n.id,"aria-rowindex":e,"data-depth":r,onClick:e=>{e.target.closest(`a, button, input`)||y(C)},className:`group/row cursor-pointer hover:bg-muted`,children:[m?(0,Q.jsx)(`td`,{className:`border-b border-border px-2`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(zD,{label:`Select ${Ve(n)}`,checked:h,disabled:_,onChange:()=>g(n.id)}),(0,Q.jsx)(VD,{run:n,busy:_,onAction:v})]})}):null,f.map(e=>{if(e.id===`memory`)return null;if(e.id===`cpu`){let t=JD(`cpu`,p),r=JD(`memory`,p);return c!==null&&(t||r)?(0,Q.jsxs)(`td`,{"data-slot":`queue-note`,"data-column-id":`cpu-memory`,colSpan:2,className:W(xO,`text-right font-mono text-meta text-soft-foreground`),children:[`#`,c,` in queue`]},e.id):(0,Q.jsx)(EO,{run:n,cpuExpanded:t,memoryExpanded:r},e.id)}return(0,Q.jsx)(CO,{gitRepo:t,column:e,expanded:JD(e.id,p),run:n,depth:r,childCount:i,subtasksExpanded:a,onToggleSubtasks:s,attention:x,scheduled:S,reference:T,cost:w,to:C,onRename:l,onTogglePin:u,sortBy:d},e.id)})]})});function CO({gitRepo:e,column:t,expanded:n,run:r,depth:i,childCount:a,subtasksExpanded:o,onToggleSubtasks:s,attention:c,scheduled:l,reference:u,cost:d,to:f,onRename:p,onTogglePin:m,sortBy:h}){if(!n)return(0,Q.jsx)(wO,{column:t.id});switch(t.id){case`status`:return(0,Q.jsx)(`td`,{"data-column-id":t.id,className:xO,children:(0,Q.jsxs)(Nc,{dot:c.tone,pulse:c.pulse,title:l?.title,children:[c.label,l?(0,Q.jsx)(`span`,{className:`tabular-nums`,children:l.label}):null]})});case`task`:return(0,Q.jsx)(`td`,{"data-column-id":t.id,className:W(xO,`max-w-0`),style:{minWidth:`${fe(i)}px`},children:(0,Q.jsx)(TO,{run:r,depth:i,childCount:a,subtasksExpanded:o,onToggleSubtasks:s,to:f,onRename:p,onTogglePin:m})});case`workflow`:return(0,Q.jsx)(`td`,{"data-column-id":t.id,className:W(xO,`text-label text-muted-foreground`),children:he(r)});case`branch`:return(0,Q.jsx)(`td`,{"data-column-id":t.id,className:xO,children:r.branch?(0,Q.jsx)(jO,{branch:r.branch}):MO(r,e)?(0,Q.jsx)(NO,{}):(0,Q.jsx)(kO,{})});case`diff`:return(0,Q.jsx)(`td`,{"data-column-id":t.id,className:xO,children:r.diffStat?(0,Q.jsx)(Zc,{stat:r.diffStat}):(0,Q.jsx)(kO,{})});case`reference`:return(0,Q.jsx)(`td`,{"data-column-id":t.id,className:xO,children:u?(0,Q.jsx)(Ca,{run:r,reference:u}):(0,Q.jsx)(kO,{})});case`tokens`:return(0,Q.jsx)(`td`,{"data-column-id":t.id,className:W(xO,`text-right text-xs text-muted-foreground`),children:(0,Q.jsx)(Mc,{inputTokens:r.inputTokens,outputTokens:r.outputTokens,variant:`table`,omitWhenUnknown:!1})});case`cost`:return(0,Q.jsx)(`td`,{"data-column-id":t.id,className:W(xO,`text-right font-mono text-xs text-muted-foreground tabular-nums`),children:d||(0,Q.jsx)(kO,{})});case`started`:return(0,Q.jsx)(`td`,{"data-column-id":t.id,className:W(xO,`text-right text-xs text-soft-foreground tabular-nums`),children:(0,Q.jsx)(tO,{at:I(r,h)})});case`cpu`:case`memory`:return null}}function wO({column:e}){return(0,Q.jsx)(`td`,{role:`presentation`,"aria-hidden":`true`,"data-column-id":e,"data-folded":`true`,className:W(xO,`px-0 first:pl-0 last:pr-0`)})}function TO({run:e,depth:t,childCount:n,subtasksExpanded:r,onToggleSubtasks:i,to:a,onRename:o,onTogglePin:s}){let c=Ve(e),l=Ha(c,t=>o(e.id,t)),u=$o(e),d=Zo(e),f=Yg(n),p=t>0?{paddingLeft:`${t*14}px`}:void 0;return l.editing?(0,Q.jsx)(`span`,{className:`flex min-w-0 items-center`,style:p,children:(0,Q.jsx)(Ga,{editor:l,className:`text-ui font-medium`})}):(0,Q.jsxs)(`span`,{className:`@container flex min-w-0 items-center gap-1.5`,style:p,children:[t>0?(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`subtask-tick`,className:`shrink-0 font-mono text-meta leading-none text-soft-foreground`,children:`└`}):null,(0,Q.jsxs)(K,{to:a,title:c,className:W(`min-w-0 truncate text-ui`,u?`font-semibold text-foreground`:d?`font-medium text-muted-foreground`:`font-medium`),children:[c,u?(0,Q.jsx)(Ig,{}):null]}),Xg(e)?(0,Q.jsx)(`span`,{"data-slot":`dispatch-kind`,className:`shrink-0 rounded-full bg-muted px-1.5 py-px text-micro font-medium text-muted-foreground @max-[300px]:hidden`,children:Xg(e)}):null,f?(0,Q.jsx)(HD,{label:f,expanded:r,onToggle:()=>i(e.id),wordClassName:`@max-[260px]:hidden`}):null,(0,Q.jsxs)(`span`,{"data-slot":`row-actions`,className:W(`flex shrink-0 items-center gap-1.5`,!e.pinned&&`-ml-1.5 w-0 overflow-hidden group-hover/row:ml-0 group-hover/row:w-auto group-hover/row:overflow-visible group-focus-within/row:ml-0 group-focus-within/row:w-auto group-focus-within/row:overflow-visible no-hover:ml-0 no-hover:w-auto no-hover:overflow-visible`),children:[(0,Q.jsx)(`button`,{type:`button`,"data-slot":`row-rename`,"aria-label":`Rename task`,onClick:l.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)(rc,{className:`size-3`,"aria-hidden":`true`})}),s?(0,Q.jsx)(La,{pinned:!!e.pinned,onToggle:t=>s(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 EO({run:e,cpuExpanded:t,memoryExpanded:n}){let r=R(e,ai(e.id));return(0,Q.jsxs)(Q.Fragment,{children:[t?(0,Q.jsx)(DO,{column:`cpu`,cell:r.cpu}):(0,Q.jsx)(wO,{column:`cpu`}),n?(0,Q.jsx)(DO,{column:`memory`,cell:r.mem}):(0,Q.jsx)(wO,{column:`memory`})]})}function DO({column:e,cell:t}){return(0,Q.jsx)(`td`,{"data-usage":e===`memory`?`mem`:e,"data-column-id":e,"data-usage-kind":t.kind,title:t.title,className:W(xO,`text-right font-mono tabular-nums`,t.kind===`live`&&`bg-violet/5 text-xs font-medium text-foreground`,t.kind===`peak`&&`text-meta text-soft-foreground`,t.kind===`none`&&`text-xs text-soft-foreground`),children:t.text||`—`})}var OO=Z.memo(function({run:e,depth:t,childCount:n,subtasksExpanded:r,onToggleSubtasks:i,queuePosition:a,sortBy:s,showTokens:c,showCost:l,onTogglePin:u,gitRepo:d,selectable:f,selected:p,onSelect:m,actionsBusy:h,onAction:g}){let _=vr(),v=o(e),y=b(e),x=`/tasks/${e.id}`,S=zt(e),C=$o(e),w=Zo(e),T=we(e.costUsd),E=Yg(n),D=e.inputTokens!==void 0||e.outputTokens!==void 0;return(0,Q.jsxs)(`div`,{"data-slot":`task-card`,"data-run-id":e.id,"data-depth":t,style:t>0?{marginLeft:`${t*14}px`}:void 0,onClick:e=>{e.target.closest(`a, button, input`)||_(x)},className:`cursor-pointer rounded-lg border border-border bg-card px-3.5 py-3 shadow-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[f?(0,Q.jsx)(zD,{label:`Select ${Ve(e)}`,checked:p,disabled:h,onChange:()=>m(e.id)}):null,(0,Q.jsxs)(Nc,{dot:v.tone,pulse:v.pulse,className:`mt-px shrink-0`,title:y?.title,children:[v.label,y?(0,Q.jsx)(`span`,{className:`tabular-nums`,children:y.label}):null]}),(0,Q.jsxs)(K,{to:x,className:W(`min-w-0 flex-1 text-ui leading-[1.35]`,C?`font-semibold text-foreground`:w?`font-medium text-muted-foreground`:`font-medium`),children:[Ve(e),C?(0,Q.jsx)(Ig,{}):null]}),Xg(e)?(0,Q.jsx)(`span`,{"data-slot":`dispatch-kind`,className:`mt-px shrink-0 rounded-full bg-muted px-1.5 py-px text-micro font-medium text-muted-foreground`,children:Xg(e)}):null,E?(0,Q.jsx)(HD,{label:E,expanded:r,onToggle:()=>i(e.id),className:`mt-px`}):null,(0,Q.jsx)(`span`,{className:`mt-0.5 shrink-0 text-meta text-soft-foreground tabular-nums`,children:(0,Q.jsx)(tO,{at:I(e,s)})}),u?(0,Q.jsx)(La,{pinned:!!e.pinned,onToggle:t=>u(e,t),className:`-mr-1 mt-px`}):null]}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 font-mono text-meta font-medium text-muted-foreground tabular-nums`,children:[(0,Q.jsx)(`span`,{children:he(e)}),a===null?(0,Q.jsxs)(Q.Fragment,{children:[e.branch?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(AO,{}),(0,Q.jsx)(`span`,{children:e.branch})]}):MO(e,d)?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(AO,{}),(0,Q.jsx)(NO,{})]}):null,e.diffStat?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(AO,{}),(0,Q.jsx)(Zc,{stat:e.diffStat,className:`text-meta`})]}):null,c&&D?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(AO,{}),(0,Q.jsx)(Mc,{inputTokens:e.inputTokens,outputTokens:e.outputTokens})]}):null,l&&T?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(AO,{}),(0,Q.jsx)(`span`,{children:T})]}):null]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(AO,{}),(0,Q.jsxs)(`span`,{"data-slot":`queue-note`,children:[`#`,a,` in queue`]})]}),S?(0,Q.jsx)(Ca,{run:e,reference:S,className:`h-5`}):null,f?(0,Q.jsx)(VD,{run:e,busy:h,onAction:g}):null]})]})});function kO(){return(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`})}function AO(){return(0,Q.jsx)(`span`,{className:`text-soft-foreground`,"aria-hidden":`true`,children:`·`})}function jO({branch:e}){return(0,Q.jsx)(`span`,{className:`rounded-[6px] bg-muted px-1.5 py-0.5 font-mono text-meta font-medium text-muted-foreground`,children:e})}function MO(e,t){return t&&e.status===`running`&&!e.branch&&e.worktree!==!1}function NO(){return(0,Q.jsx)(UD,{"data-slot":`branch-skeleton`,role:`status`,"aria-label":`naming branch`,className:`inline-block h-4 w-24 align-middle`})}function PO(){let e=P(),t=Yc(C().data),n=ln(),r=!n.data||n.data.info!==null,[i,a]=sg(),o=U(),s=$n(),c=Z.useCallback(async(e,t)=>{let n=t===`archive`||t===`restore`?await Hn(s,e.id,t===`archive`,`tasks_table`):await Bt(s,e.id,t===`read`);$n()===s?qt(o,n):o.invalidateQueries({queryKey:B.runsIndex}),o.invalidateQueries({queryKey:[s,`runs`]})},[s,o]),l=H({mutationFn:On,onSuccess:()=>o.invalidateQueries({queryKey:V.runs.all})}),u=H({mutationFn:me,onSuccess:()=>o.invalidateQueries({queryKey:V.runs.all}),onError:e=>Y(e.message,{tone:`danger`})}),d=H({mutationFn:({id:e,title:t})=>Me(e,{title:t}),onSuccess:e=>{qt(o,e),o.invalidateQueries({queryKey:V.runs.all})},onError:e=>Y(e.message,{tone:`danger`})}),f=un(`tasks_table`),p=d.mutate,m=Z.useCallback((e,t)=>p({id:e,title:t}),[p]),h=f.mutate,g=Z.useCallback((e,t)=>h({id:e.id,pinned:t},{onError:e=>Y(e.message,{tone:`danger`})}),[h]),_=QD(),[v,y]=lp(),b=mi(),x=Pg(),S=Z.useMemo(()=>(e.data??[]).some(e=>e.automation??e.automationTrigger??e.automationTracker),[e.data]),w=bi(b.known&&!b.off&&(S&&v!==`regular`||x&&i===`active`)),T=Z.useMemo(()=>new Map((w.data?.automations??[]).map(e=>[e.id,e.name])),[w.data]),E=Lt();return(0,Q.jsx)(Ur,{projectId:E,requests:Z.useMemo(()=>E===void 0?[]:(e.data??[]).flatMap(e=>ce(e).map(e=>({projectId:E,kind:e.kind,number:e.number}))),[e.data,E]),children:(0,Q.jsx)(fO,{scheduledTasks:i===`active`?(0,Q.jsx)(Dg,{enabled:x}):void 0,hasScheduledTasks:i===`active`&&!!w.data?.automations.some(e=>e.deferredStart),runs:e.data,view:i,onViewChange:a,onArchiveFinished:()=>l.mutate(),onMarkAllRead:()=>u.mutate(),onRename:m,onTogglePin:g,onTaskAction:c,showTokens:t.tokens,showCost:t.cost,expandedColumns:_.expandedColumns,onToggleColumn:_.toggleColumn,columnsPending:_.isPending,origin:v,onOriginChange:y,gitRepo:r,automationNames:T,firstRun:i===`active`?(0,Q.jsx)(iy,{gitRepo:n.data?n.data.info!==null:n.isError?!0:void 0}):void 0,setupPill:i===`active`?(0,Q.jsx)(Fy,{}):void 0,welcomeBack:i===`active`?(0,Q.jsx)(Zy,{runs:e.data??cO}):void 0})})}var FO=[],IO=` untagged`,LO=[{value:`project`,label:`Project`},{value:`tag`,label:`Tag`},{value:`status`,label:`Status`},{value:`workflow`,label:`Workflow`}];function RO(e,t){return e===t?`none`:t}function zO(e,t){return[...e].sort((e,n)=>oe(I(e.run,t),I(n.run,t)))}var BO={query:``,tags:[],statuses:[],workflows:[]};function VO(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function HO(e){return e.tags.length+e.statuses.length+e.workflows.length}function UO(e){return e.query.trim()!==``||HO(e)>0}function WO(e){return HO(e.filters)+(e.filters.query.trim()===``?0:1)+(e.groupBy===`none`?0:1)}function GO(e){return WO(e)>0}function KO(e,t){let n=new Map(t.map(e=>[e.id,e]));return e.map(e=>{let t=n.get(e.projectId);return{run:e,project:t,projectName:t?.name||e.projectId,tags:t?.tags??FO}})}var qO=e=>`${e.projectId}/${e.id}`;function JO(e){let t=new Map(e.map(e=>[qO(e.run),e.run]));return new Map(e.map(e=>[qO(e.run),ep(e.run,n=>t.get(`${e.run.projectId}/${n}`))]))}function YO(e,t,n){return e.filter(e=>tp(n.get(qO(e.run)),t))}function XO(e){let t=new Set;for(let n of e)t.add(n.run.workflow);return[...t].sort((e,t)=>e.localeCompare(t))}function ZO(e){let t=new Set;for(let n of e)t.add(n.run.status);return[...t].sort((e,t)=>e.localeCompare(t))}function QO(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 $O=e=>e.tags.length===0?[IO]:e.tags,ek=(e,t)=>e.length===0||t.some(t=>e.includes(t)),tk=(e,t)=>{if(t.length===0)return!0;let n=$O(e).map(e=>e.toLowerCase());return t.some(e=>n.includes(e.toLowerCase()))};function nk(e){return[Ve(e.run),e.projectName,e.run.workflow,e.run.branch??``,...e.tags].join(`
|
|
31
|
+
`).toLowerCase()}function rk(e,t,n){let r=t.query.trim().toLowerCase().split(/\s+/).filter(Boolean);return e.filter(e=>{if((n===`archived`?!e.run.archived:e.run.archived)||!ek(t.statuses,[e.run.status])||!ek(t.workflows,[e.run.workflow])||!tk(e,t.tags))return!1;if(r.length===0)return!0;let i=nk(e);return r.every(e=>i.includes(e))})}function ik(e,t,n,r){return rk(e,{...t,[r]:[]},n)}function ak(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(IO,`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 ok(e,t){let n=new Map(t.map(e=>[e.id,e.name]));return e.map(e=>n.get(e)||e)}var sk={query:`q`,tag:`tag`,untagged:`untagged`,status:`status`,workflow:`workflow`,groupBy:`group`,sort:`sort`,archived:`archived`},ck=new Set(LO.map(e=>e.value));function lk(e){let t=new URLSearchParams,n=e.filters.query.trim();n!==``&&t.set(sk.query,n);for(let n of e.filters.tags)n===` untagged`?t.set(sk.untagged,`1`):t.append(sk.tag,n);for(let n of e.filters.statuses)t.append(sk.status,n);for(let n of e.filters.workflows)t.append(sk.workflow,n);return e.groupBy!==`none`&&t.set(sk.groupBy,e.groupBy),e.sortBy!==`recent`&&t.set(sk.sort,e.sortBy),e.view===`archived`&&t.set(sk.archived,`1`),t}function uk(e){let t=e.getAll(sk.tag).filter(e=>e!==``);e.get(sk.untagged)===`1`&&t.push(IO);let n=e.get(sk.groupBy)??``;return{filters:{query:e.get(sk.query)??``,tags:t,statuses:e.getAll(sk.status).filter(e=>e!==``),workflows:e.getAll(sk.workflow).filter(e=>e!==``)},groupBy:ck.has(n)?n:`none`,sortBy:e.get(sk.sort)===`created`?`created`:`recent`,view:e.get(sk.archived)===`1`?`archived`:`active`}}var dk=15e3,fk=e=>e?.runs.some(e=>e.usage!==void 0)?dk:!1,pk=3e4,mk=250,hk=1,gk=new Set([`done`,`failed`,`cancelled`]);function _k(){return yk({request:({task:e,archived:t})=>Hn(e.run.projectId,e.run.id,t,`all_tasks`),patch:({archived:e})=>t=>({...t,archived:e})})}function vk(){return yk({request:({task:e,read:t})=>Bt(e.run.projectId,e.run.id,t),patch:({read:e})=>t=>{if(e)return{...t,seenAt:new Date().toISOString()};let{seenAt:n,...r}=t;return r}})}function yk({request:e,patch:t}){let n=U();return H({mutationFn:e,onMutate:async e=>{await n.cancelQueries({queryKey:B.runsIndex});let r=n.getQueryData(B.runsIndex),i=t(e),{task:a}=e;return n.setQueryData(B.runsIndex,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.projectId===a.run.projectId&&e.id===a.run.id?i(e):e)}),{previous:r}},onError:(e,t,r)=>{r?.previous&&n.setQueryData(B.runsIndex,r.previous),Y(e.message,{tone:`danger`})},onSettled:(e,t,{task:r})=>{n.invalidateQueries({queryKey:B.runsIndex}),n.invalidateQueries({queryKey:V.runs.all}),n.invalidateQueries({queryKey:[r.run.projectId,`runs`,`list`]})}})}function bk(){let e=a(),t=Yc(C().data),n=Se(!0,fk),[r,i]=hr(),{filters:o,groupBy:s,sortBy:c,view:l}=Z.useMemo(()=>uk(r),[r]),[u,d]=sg();Z.useEffect(()=>{u!==l&&d(l)},[l,u,d]);let f=e=>i(t=>lk(e(uk(t))),{replace:!0}),p=e=>f(t=>({...t,filters:e(t.filters)})),m=e=>f(t=>({...t,groupBy:e})),h=e=>f(t=>({...t,sortBy:e})),g=e=>f(t=>({...t,view:e})),[_,v]=Z.useState(o.query),[y,b]=Z.useState(new Set),x=Z.useCallback(e=>b(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),[]),S=o.query.trim()!==``,w=Z.useCallback(e=>S||y.has(e),[S,y]),T=Z.useRef(o.query);Z.useEffect(()=>{o.query!==T.current&&v(o.query),T.current=o.query},[o.query]),Z.useEffect(()=>{if(_===T.current)return;let e=setTimeout(()=>{T.current=_,p(e=>({...e,query:_}))},mk);return()=>clearTimeout(e)},[_]);let E=n.data?.referenceStatuses;Z.useEffect(()=>{E&&Nt(E)},[E]);let D=Z.useMemo(()=>e.data?.projects??[],[e.data]),O=Z.useMemo(()=>KO(n.data?.runs??[],D),[n.data,D]),[k,A]=lp(),j=Z.useMemo(()=>JO(O),[O]),M=Z.useMemo(()=>YO(O,k,j),[O,k,j]),N=Z.useMemo(()=>{let e=e=>rk(YO(O,e,j),o,l).length;return{regular:e(`regular`),automation:e(`automation`),all:e(`all`)}},[O,j,o,l]),P=Z.useMemo(()=>zO(rk(M,o,l),c),[M,o,l,c]),F=Z.useMemo(()=>ak(P,s),[P,s]),ee=Z.useMemo(()=>P.flatMap(e=>ce(e.run,e.project?.repoUrl).map(t=>({projectId:e.run.projectId,kind:t.kind,number:t.number}))),[P]),te=ok(n.data?.truncated??[],D),I=(e,t)=>p(n=>({...n,[e]:VO(n[e],t)})),ne=e=>p(t=>({...t,[e]:[]})),L=_k(),re=vk(),ie=L.mutate,ae=Z.useCallback((e,t)=>ie({task:e,archived:t}),[ie]),oe=re.mutate,se=Z.useCallback((e,t)=>oe({task:e,read:t}),[oe]);if(n.isError||e.isError)return(0,Q.jsx)(`div`,{"data-route":`global-tasks`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(ys,{}),tone:`danger`,title:`Tasks across projects did not load`,subtitle:(n.error??e.error)?.message})});let le=(0,Q.jsxs)(`div`,{className:`relative w-full md:w-60`,children:[(0,Q.jsx)(Cc,{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:_,onChange:e=>v(e.target.value),placeholder:`Search every project…`,"aria-label":`Search tasks across projects`,className:`h-9 w-full rounded-md border border-input bg-card pr-3 pl-8 text-ui 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`,className:`flex min-h-full flex-col`,children:[(0,Q.jsxs)(`header`,{className:`sticky top-0 z-10 hidden h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-5 md:flex`,children:[(0,Q.jsx)(`h1`,{className:`text-base font-semibold`,children:`All tasks`}),(0,Q.jsxs)(`div`,{className:`inline-flex gap-0.5 rounded-md bg-muted p-[3px]`,children:[(0,Q.jsx)(xk,{view:`active`,current:l,onSelect:g,children:`Active`}),(0,Q.jsx)(xk,{view:`archived`,current:l,onSelect:g,children:`Archived`})]}),(0,Q.jsx)(`div`,{className:`flex-1`}),(0,Q.jsxs)(`span`,{"data-slot":`global-tasks-count`,className:`text-label text-soft-foreground tabular-nums`,children:[P.length,` of `,O.length]}),le]}),(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col gap-3 p-3 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-5 md:pb-5`,children:[(0,Q.jsx)(`div`,{className:`md:hidden`,children:le}),(0,Q.jsx)(Sk,{filters:o,onToggle:I,onClearFacet:ne,onClearAll:()=>{v(``),f(e=>({...e,filters:BO,groupBy:`none`}))},groupBy:s,onGroupByChange:m,sortBy:c,onSortByChange:h,projects:D,tasks:M,view:l,origin:k,onOriginChange:A,originCounts:N}),te.length>0?(0,Q.jsxs)(`p`,{"data-slot":`global-tasks-truncated`,className:`text-meta text-soft-foreground`,children:[`Showing the `,n.data?.perProjectLimit,` most recently active tasks per project — older ones in`,` `,te.join(`, `),` are only in that project’s own Tasks page.`]}):null,n.data===void 0?null:P.length===0?(0,Q.jsx)(Fk,{view:l,filtered:UO(o),origin:k,hiddenByOrigin:k!==`all`&&N.all>0,onShowAll:()=>A(`all`)}):(0,Q.jsx)(eO,{intervalMs:pk,children:(0,Q.jsx)(Ur,{requests:ee,children:F.map(e=>(0,Q.jsxs)(`section`,{"data-slot":`task-group`,"data-group-key":e.key,children:[s===`none`?null:(0,Q.jsxs)(`h2`,{className:`mb-1.5 flex items-center gap-2 eyebrow text-soft-foreground`,children:[s===`project`?(0,Q.jsx)(yr,{to:_r(e.key,`/`),"data-slot":`group-project-link`,className:`hover:text-foreground hover:underline`,children:e.label}):e.label,(0,Q.jsx)(`span`,{className:`font-mono text-meta font-medium tabular-nums`,children:e.tasks.length})]}),(0,Q.jsx)(wk,{tasks:e.tasks,sortBy:c,isSubtasksExpanded:w,onToggleSubtasks:x,showProject:s!==`project`,onArchive:ae,onSetRead:se,busy:L.isPending||re.isPending,showCost:t.cost})]},e.key))})})]})]})}function xk({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:W(`flex h-7 items-center justify-center rounded-[7px] px-3 text-label font-medium text-muted-foreground`,i&&`bg-card font-semibold text-foreground shadow-xs`),children:r})}function Sk({filters:e,onToggle:t,onClearFacet:n,onClearAll:r,groupBy:i,onGroupByChange:a,sortBy:o,onSortByChange:s,projects:c,tasks:l,view:u,origin:d,onOriginChange:f,originCounts:p}){let m=Z.useMemo(()=>Ot(c),[c]),h=Z.useMemo(()=>{let t=(t,n)=>QO(ik(l,e,u,t),n);return{tags:t(`tags`,$O),statuses:t(`statuses`,e=>[e.run.status]),workflows:t(`workflows`,e=>[e.run.workflow])}},[l,e,u]),g=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 rounded-lg border border-border bg-card p-2.5 shadow-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,Q.jsx)(_i,{slot:`task-origin`,label:`Show tasks started by`,value:d,options:Zf.map(e=>({...e,count:p[e.value]})),onChange:f}),(0,Q.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`,"aria-hidden":`true`}),(0,Q.jsx)(Ti,{slot:`status`,label:`Status`,selected:e.statuses,onToggle:e=>t(`statuses`,e),onClear:()=>n(`statuses`),options:ZO(l).map(e=>({value:e,label:e})).map(g(h.statuses)),emptyLabel:`No tasks to filter`}),(0,Q.jsx)(Ti,{slot:`workflow`,label:`Workflow`,selected:e.workflows,onToggle:e=>t(`workflows`,e),onClear:()=>n(`workflows`),options:XO(l).map(e=>({value:e,label:e})).map(g(h.workflows)),emptyLabel:`No tasks to filter`}),(0,Q.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`text-meta font-medium text-soft-foreground`,children:`Group by`}),(0,Q.jsx)(Si,{slot:`group-by`,label:`Group tasks by`,value:i,options:LO,onChange:e=>a(RO(i,e))}),(0,Q.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`text-meta font-medium text-soft-foreground`,children:`Sort by`}),(0,Q.jsx)(_i,{slot:`sort-by`,label:`Sort tasks by`,value:o,options:w,onChange:s}),GO({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)(Tc,{className:`size-3`,"aria-hidden":`true`}),`Clear`,` (${WO({filters:e,groupBy:i})})`]}):null]}),m.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-meta font-medium text-soft-foreground`,children:`Tags`}),m.map(n=>(0,Q.jsx)(wi,{slot:`tag-filter`,tone:`tag`,label:n,count:h.tags.get(n)??0,selected:e.tags.some(e=>e.toLowerCase()===n.toLowerCase()),onToggle:()=>t(`tags`,n)},n)),(0,Q.jsx)(wi,{slot:`tag-filter`,label:`Untagged`,count:h.tags.get(` untagged`)??0,selected:e.tags.includes(IO),onToggle:()=>t(`tags`,IO)})]}):(0,Q.jsxs)(`p`,{"data-slot":`no-tags-hint`,className:`text-meta text-soft-foreground`,children:[`Tag connected repositories in`,` `,(0,Q.jsx)(yr,{to:`/settings/global/projects`,className:`font-medium text-violet hover:underline`,children:`Settings → Projects`}),` `,`to group their tasks together here.`]})]})}var Ck=e=>e.dispatch;function wk({tasks:e,sortBy:t,isSubtasksExpanded:n,onToggleSubtasks:r,showProject:i,onArchive:a,onSetRead:o,busy:s,showCost:c}){let l=Z.useMemo(()=>Jg(e.map(e=>({id:e.run.id,dispatch:Ck(e.run),task:e})),n),[e,n]),u=aO(l.length),d=[(0,Q.jsx)(Tk,{className:`w-[104px]`,children:`Status`},`status`),(0,Q.jsx)(Tk,{children:`Task`},`task`),i?(0,Q.jsx)(Tk,{className:`w-[124px]`,children:`Project`},`project`):null,(0,Q.jsx)(Tk,{className:`hidden w-[120px] xl:table-cell`,children:`Tags`},`tags`),(0,Q.jsx)(Tk,{className:`w-[84px]`,children:`Ref`},`ref`),(0,Q.jsx)(Tk,{className:`hidden w-[108px] xl:table-cell`,children:`Workflow`},`workflow`),c?(0,Q.jsx)(Tk,{className:`hidden w-[64px] text-right lg:table-cell`,children:`Cost`},`cost`):null,(0,Q.jsx)(Tk,{className:`hidden w-[56px] text-right xl:table-cell`,children:`CPU`},`cpu`),(0,Q.jsx)(Tk,{className:`hidden w-[84px] text-right xl:table-cell`,children:`Mem`},`mem`),(0,Q.jsx)(Tk,{className:`w-[72px] text-right`,children:fn(t)},`age`),(0,Q.jsx)(Tk,{className:`w-[64px] text-right`,children:(0,Q.jsx)(`span`,{className:`sr-only`,children:`Actions`})},`actions`)].filter(e=>e!==null),f=d.length;return(0,Q.jsx)(`div`,{"data-slot":`global-tasks-table`,className:`overflow-x-auto rounded-lg border border-border bg-card shadow-xs`,children:(0,Q.jsx)(kc,{children:(0,Q.jsxs)(`table`,{className:`w-full border-collapse`,"aria-rowcount":u.ariaRowCount,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsx)(`tr`,{"aria-rowindex":u.windowed?1:void 0,children:d})}),(0,Q.jsxs)(`tbody`,{ref:u.anchorRef,className:`[&>tr:last-child>td]:border-b-0`,children:[(0,Q.jsx)(iO,{height:u.padTop,colSpan:f}),l.slice(u.start,u.end).map((e,l)=>(0,Q.jsx)(Dk,{ariaRowIndex:u.ariaRowIndex(u.start+l),task:e.run.task,depth:e.depth,childCount:e.childCount,subtasksExpanded:n(e.run.id),onToggleSubtasks:r,sortBy:t,showProject:i,onArchive:a,onSetRead:o,busy:s,showCost:c},`${e.run.task.run.projectId}/${e.run.task.run.id}`)),(0,Q.jsx)(iO,{height:u.padBottom,colSpan:f})]})]})})})}function Tk({children:e,className:t}){return(0,Q.jsx)(`th`,{scope:`col`,className:W(`h-[38px] border-b border-border px-2.5 text-left eyebrow whitespace-nowrap text-soft-foreground first:pl-4 last:pr-4`,t),children:e})}var Ek=`h-11 border-b border-border px-2.5 whitespace-nowrap first:pl-4 last:pr-4`,Dk=Z.memo(function({ariaRowIndex:e,task:t,depth:n,childCount:r,subtasksExpanded:i,onToggleSubtasks:a,sortBy:s,showProject:c,onArchive:l,onSetRead:u,busy:d,showCost:f}){let{run:p}=t,m=o(p),h=_r(p.projectId,`/tasks/${p.id}`),g=$o(p),_=Zo(p),v=ce(p,t.project?.repoUrl),y=Yg(r),b=R(p,p.usage);return(0,Q.jsxs)(`tr`,{"data-slot":`global-task-row`,"data-run-id":p.id,"aria-rowindex":e,"data-project":p.projectId,"data-depth":n,className:`hover:bg-muted`,children:[(0,Q.jsx)(`td`,{className:Ek,children:(0,Q.jsx)(Nc,{dot:m.tone,pulse:m.pulse,children:m.label})}),(0,Q.jsx)(`td`,{className:W(Ek,`min-w-[320px] max-w-0`),children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,style:n>0?{paddingLeft:`${n*14}px`}:void 0,children:[n>0?(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`subtask-tick`,className:`shrink-0 font-mono text-meta leading-none text-soft-foreground`,children:`└`}):null,(0,Q.jsxs)(yr,{to:h,title:Ve(p),className:W(`min-w-0 truncate text-ui`,g?`font-semibold text-foreground`:_?`font-medium text-muted-foreground`:`font-medium`),children:[Ve(p),g?(0,Q.jsx)(Ig,{}):null]}),Xg(p)?(0,Q.jsx)(`span`,{"data-slot":`dispatch-kind`,className:`shrink-0 rounded-full bg-muted px-1.5 py-px text-micro font-medium text-muted-foreground`,children:Xg(p)}):null,y?(0,Q.jsx)(HD,{label:y,expanded:i,onToggle:()=>a(p.id)}):null]})}),c?(0,Q.jsx)(`td`,{className:W(Ek,`text-label text-muted-foreground`),children:(0,Q.jsx)(yr,{to:_r(p.projectId,`/`),className:`truncate hover:text-foreground`,children:t.projectName})}):null,(0,Q.jsx)(`td`,{className:W(Ek,`hidden xl:table-cell`),children:t.tags.length>0?(0,Q.jsx)(`span`,{className:`flex flex-wrap items-center gap-1`,children:t.tags.map(e=>(0,Q.jsx)(Mk,{tag:e},e))}):(0,Q.jsx)(Pk,{})}),(0,Q.jsx)(`td`,{className:Ek,children:v.length>0?(0,Q.jsx)(jk,{references:v,run:p}):(0,Q.jsx)(Pk,{})}),(0,Q.jsx)(`td`,{className:W(Ek,`hidden text-label text-muted-foreground xl:table-cell`),children:p.workflow}),f?(0,Q.jsx)(`td`,{className:W(Ek,`hidden text-right font-mono text-xs text-muted-foreground tabular-nums lg:table-cell`),children:we(p.costUsd)||(0,Q.jsx)(Pk,{})}):null,(0,Q.jsx)(Nk,{column:`cpu`,cell:b.cpu}),(0,Q.jsx)(Nk,{column:`memory`,cell:b.mem}),(0,Q.jsx)(`td`,{className:W(Ek,`text-right text-xs text-soft-foreground tabular-nums`),children:(0,Q.jsx)(tO,{at:I(p,s)})}),(0,Q.jsx)(`td`,{className:W(Ek,`text-right`),children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,Q.jsx)(kk,{task:t,busy:d,onSetRead:u}),(0,Q.jsx)(Ak,{task:t,busy:d,onArchive:l})]})})]})},Ok);function Ok(e,t){let{task:n,...r}=e,{task:i,...a}=t;return n.run!==i.run||n.project!==i.project||n.projectName!==i.projectName||n.tags!==i.tags?!1:Object.keys(r).every(e=>r[e]===a[e])}function kk({task:e,busy:t,onSetRead:n}){if(!Wo(e.run))return null;let r=$o(e.run),i=Ve(e.run),a=r?`Mark ${i} read`:`Mark ${i} unread`,o=r?lc:Tl;return(0,Q.jsxs)(Ac,{children:[(0,Q.jsx)(Dc,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"data-action":r?`mark-read`:`mark-unread`,"aria-label":a,disabled:t,onClick:()=>n(e,r),className:W(`inline-flex size-7 items-center justify-center 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-violet`:`text-soft-foreground`),children:(0,Q.jsx)(o,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Q.jsx)(Oc,{side:`left`,children:r?`Mark read`:`Mark unread`})]})}function Ak({task:e,busy:t,onArchive:n}){let r=e.run.archived;if(!r&&!gk.has(e.run.status))return null;let i=r?`Restore ${Ve(e.run)} to the active list`:`Archive ${Ve(e.run)}`;return(0,Q.jsxs)(Ac,{children:[(0,Q.jsx)(Dc,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"data-action":r?`unarchive-run`:`archive-run`,"aria-label":i,disabled:t,onClick:()=>n(e,!r),className:`inline-flex size-7 items-center justify-center 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?pl:wa,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Q.jsx)(Oc,{side:`left`,children:r?`Restore`:`Archive`})]})}function jk({references:e,run:t}){let n=e.slice(0,hk),r=e.length-n.length,i=Ve(t);return(0,Q.jsxs)(`span`,{className:`flex flex-nowrap items-center gap-1`,children:[n.map(e=>(0,Q.jsx)(Gr,{reference:e,taskTitle:i,projectId:t.projectId,conflictAction:(0,Q.jsx)(ka,{projectId:t.projectId,runId:t.id,prNumber:e.number}),className:`shrink-0`},`${e.kind}#${e.number}`)),r>0?(0,Q.jsx)(Ea,{references:e,taskTitle:i,hidden:r,projectId:t.projectId}):null]})}function Mk({tag:e,className:t}){return(0,Q.jsx)(`span`,{"data-slot":`project-tag`,className:W(`inline-flex max-w-full items-center truncate rounded-full bg-muted px-1.5 py-px text-micro font-medium text-muted-foreground`,t),children:e})}function Nk({column:e,cell:t}){return(0,Q.jsx)(`td`,{"data-usage":e===`memory`?`mem`:e,"data-usage-kind":t.kind,title:t.title,className:W(Ek,`hidden text-right font-mono tabular-nums xl:table-cell`,t.kind===`live`&&`bg-violet/5 text-xs font-medium text-foreground`,t.kind===`peak`&&`text-meta text-soft-foreground`,t.kind===`none`&&`text-xs text-soft-foreground`),children:t.text||`—`})}function Pk(){return(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`})}function Fk({view:e,filtered:t,origin:n=`all`,hiddenByOrigin:r=!1,onShowAll:i=()=>void 0}){return r?(0,Q.jsx)(`div`,{"data-slot":`global-tasks-empty`,"data-empty-kind":`origin-hidden`,children:(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(ys,{}),tone:`neutral`,title:n===`regular`?`No regular tasks here`:`No automation tasks here`,subtitle:n===`regular`?`Tasks started by automations are hidden.`:`Only tasks started by automations are shown.`,actions:(0,Q.jsx)(J,{type:`button`,variant:`outline`,onClick:i,children:`Show all tasks`})})}):t?(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(Sc,{}),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)(wa,{}),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)(Bl,{}),tone:`neutral`,title:`No tasks yet`,subtitle:`Start a task in any project and it shows up here.`})}var Ik=Ds(`dashboard`,()=>mr(()=>import(`./dashboard-CPnDqmbf.js`).then(e=>({default:e.DashboardRoute})),__vite__mapDeps([11,1,2,3,4,5,12,6,13,14,15,16,17,18,19,20,21,22,23,24,25,26,9,27,28,29,30,31]))),Lk=Ds(`compare`,()=>mr(()=>import(`./compare-variants-RfJUgKZi.js`).then(e=>({default:e.CompareVariantsRoute})),__vite__mapDeps([32,1,2,3,4,5,12,6,14,25,28,33,34,21,31,35,26,36,37,38,39,40]))),Rk=Ds(`task-commits`,()=>mr(()=>import(`./task-commits-x21u_XE-.js`).then(e=>e.n).then(e=>({default:e.TaskCommitsRoute})),__vite__mapDeps([41,1,2,3,4,5,12,6,8,14,42,13,15,16,17,18,19,20,21,43,44,7,45,46,47,24,26,48,25,49,50,51,52,30,31,53,54,55,33,56,34,35,9,36,57,58,59,60]))),zk=(0,Z.lazy)(()=>mr(()=>import(`./task-notes-C6RP3maE.js`).then(e=>({default:e.TaskNotesRoute})),__vite__mapDeps([61,1,2,3,4,5,12,6,42,13,14,15,16,17,18,19,20,21,43,44,7,8,45,46,47,24,26,48,25,49,50,51,52,30,31,53,54,55,33,56,34,35,9,36,37,38,39,62,63,64]))),Bk=Ds(`task-workspace`,()=>mr(()=>import(`./task-workspace-xnZHXFXk.js`).then(e=>({default:e.TaskWorkspaceRoute})),__vite__mapDeps([65,1,2,3,4,5,6,12,13,14,15,16,17,18,19,20,21,23,24,8,42,43,44,7,45,46,47,26,48,25,49,50,51,52,30,31,53,54,55,33,56,34,35,9,36,66,57,67,68,28,69,37,38,39,70,71,72,73,74,75,76,77,64,78,59,79,40,58,41,60,62,63]))),Vk=Ds(`repo-git`,()=>mr(()=>import(`./repo-git-CpbhUvyL.js`).then(e=>({default:e.RepoGitRoute})),__vite__mapDeps([80,1,2,3,4,5,12,6,8,14,66,57,25,28,50,15,45,51,17,18,52,30,31,53,54,69,19,36,37,35,38,39,70,71,47,72,73,74,33,64,26,58,59,81,60,48]))),Hk=Ds(`github`,()=>mr(()=>import(`./github-DnDrPPfz.js`).then(e=>({default:e.GithubRoute})),__vite__mapDeps([82,1,2,3,4,5,12,6,13,14,15,16,17,18,19,20,21,22,23,24,25,26,9,57,67,42,43,44,7,8,45,46,47,48,49,50,51,52,30,31,53,54,55,33,56,34,35,36,66,68,83,28,73,84,37,38,39,85,58,59,81]))),Uk=Ds(`tracker`,()=>mr(()=>import(`./tracker-BzXE6yLf.js`).then(e=>({default:e.TrackerRoute})),__vite__mapDeps([86,1,2,3,4,5,12,6,13,14,15,16,17,18,19,20,21,23,24,8,57,44,7,43,45,46,47,26,48,25,49,50,51,52,30,31,53,54,55,68,84,36,37,35,38,39,85,67,42,33,56,34,9,66]))),Wk=Ds(`workflow-graph`,()=>mr(()=>import(`./workflow-graph-CkCPBwhB.js`).then(e=>({default:e.WorkflowGraphRoute})),__vite__mapDeps([87,1,2,3,4,5,12,6,14,43,16,29,46,51,88,17,55,73,68,74,63,84,56,19,20,35,64,26,9,36,89]))),Gk=Ds(`skills`,()=>mr(()=>import(`./skills-DwnXdnzS.js`).then(e=>({default:e.SkillsRoute})),__vite__mapDeps([90,1,2,3,4,5,12,6,13,14,15,16,17,18,19,20,21,57,67,23,24,42,43,44,7,8,45,46,47,26,48,25,49,50,51,52,30,31,53,54,55,33,56,34,35,9,36,66,68,64]))),Kk=Ds(`automations`,()=>mr(()=>import(`./automations-route-B_hyZJ2Q.js`).then(e=>({default:e.AutomationsRoute})),__vite__mapDeps([91,1,2,3,4,5,12,6,13,14,15,16,17,18,19,20,21,22,23,24,25,26,9,42,43,44,7,8,45,46,47,48,49,50,51,52,30,31,53,54,55,33,56,34,35,36,66,57,67,68,27,83,28,29,88,74,64])));function qk(){let e=jr();return new URLSearchParams(e.search).get(`skill`)===`__bm`?(0,Q.jsx)(Or,{to:{pathname:`/settings/bookmarklets`,hash:e.hash},replace:!0}):(0,Q.jsx)(Or,{to:{pathname:`/skills`,search:e.search,hash:e.hash},replace:!0})}function Jk({sectionId:e}){let t=jr();return(0,Q.jsx)(Dr,{to:{pathname:dD(`global`,e),search:t.search,hash:t.hash},replace:!0})}function Yk(){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 Xk(){let{projectId:e=``}=Mr(),t=jr(),n=a(),r=C();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)(Dr,{to:`/p/${encodeURIComponent(e)}${n||`/`}${t.search}${t.hash}`,replace:!0})}if(!n.isError)return(0,Q.jsx)(Yk,{})}if(n.data){if(!(n.data.bootProject===e||n.data.projects.some(t=>t.id===e)))return(0,Q.jsx)(RS,{projectId:e,registry:n.data})}else if(!n.isError)return(0,Q.jsx)(Yk,{});return(0,Q.jsxs)(It,{projectId:n.data?.bootProject===e?null:e,children:[(0,Q.jsx)(gb,{projectId:e},`webhooks:${e}`),(0,Q.jsx)(wr,{},e)]})}function Zk(){let{projectId:e=``}=Mr();return(0,Q.jsx)(CS,{},e)}function Qk(){let e=jr(),t=C(),n=a(),r=t.data?.bootProject??n.data?.bootProject,i=(t.data!==void 0||t.isError)&&(n.data!==void 0||n.isError);if(r===void 0&&!i)return(0,Q.jsx)(Yk,{});let o=r??`default`;if(e.pathname===`/`&&e.search===``&&e.hash===``){if(n.data===void 0&&!n.isError)return(0,Q.jsx)(Yk,{});let e=Tb(yb(),n.data,r);if(e!==null)return(0,Q.jsx)(Dr,{to:e,replace:!0});let t=Eb(n.data,o);if(t!==o)return(0,Q.jsx)(Dr,{to:`/p/${encodeURIComponent(t)}/`,replace:!0})}let s=e.pathname===`/p`||e.pathname===`/p/`?`/`:e.pathname;return(0,Q.jsx)(Dr,{to:`/p/${encodeURIComponent(o)}${s}${e.search}${e.hash}`,replace:!0})}var $k=[{pattern:`/`,pageLabel:`Tasks`},{pattern:`/tasks`,pageLabel:`All tasks`},{pattern:`/dashboard`,pageLabel:`Dashboard`},{pattern:`/new`,pageLabel:`New task`},{pattern:`/compare/:groupId`,pageLabel:`Compare`},{pattern:`/git/*`,pageLabel:`Git`},{pattern:`/github/*`,pageLabel:`GitHub`},{pattern:`/tracker/*`,pageLabel:`Tracker`},{pattern:`/assets`,pageLabel:`Assets`},{pattern:`/automations/*`,pageLabel:`Automations`},{pattern:`/skills`,pageLabel:`Skills`},{pattern:`/inbox`,pageLabel:`Inbox`},{pattern:`/workflows/*`,pageLabel:`Workflows`},{pattern:`/settings/*`,pageLabel:`Settings`}];function eA(e){let t=Er(e),n=gr({path:`/tasks/:id/*`,end:!0},t);return n?{pageLabel:null,taskId:n.params.id??null}:{pageLabel:$k.find(({pattern:e})=>gr({path:e,end:!0},t))?.pageLabel??null,taskId:null}}var tA=(0,Z.memo)(function(){let e=C().data?.capabilities;return(0,Q.jsxs)(xr,{children:[(0,Q.jsxs)(G,{path:`/p/:projectId`,element:(0,Q.jsx)(Xk,{}),children:[(0,Q.jsx)(G,{index:!0,element:(0,Q.jsx)(PO,{})}),(0,Q.jsx)(G,{path:`new`,element:(0,Q.jsx)(Zk,{})}),(0,Q.jsx)(G,{path:`tasks/:id`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(jo,{}),children:(0,Q.jsx)(Bk,{})})}),(0,Q.jsx)(G,{path:`tasks/:id/chat`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(jo,{}),children:(0,Q.jsx)(Bk,{view:`session`})})}),(0,Q.jsx)(G,{path:`tasks/:id/changes`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ua,{tab:`changes`}),children:(0,Q.jsx)(Bk,{view:`changes`})})}),(0,Q.jsx)(G,{path:`tasks/:id/files`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ua,{tab:`files`}),children:(0,Q.jsx)(Bk,{view:`files`})})}),(0,Q.jsx)(G,{path:`tasks/:id/graph`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ua,{tab:`changes`}),children:(0,Q.jsx)(Bk,{view:`graph`})})}),(0,Q.jsx)(G,{path:`tasks/:id/commits`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ua,{tab:`changes`}),children:(0,Q.jsx)(Bk,{view:`commits`})})}),(0,Q.jsx)(G,{path:`tasks/:id/notes`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ua,{tab:`notes`}),children:(0,Q.jsx)(zk,{})})}),(0,Q.jsx)(G,{path:`tasks/:id/preview`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ua,{tab:`preview`}),children:(0,Q.jsx)(Bk,{view:`browser`})})}),(0,Q.jsx)(G,{path:`tasks/:id/assets`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ua,{tab:`preview`}),children:(0,Q.jsx)(Bk,{view:`assets`})})}),(0,Q.jsx)(G,{path:`tasks/:id/assets/:name`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ua,{tab:`preview`}),children:(0,Q.jsx)(Bk,{view:`assets`})})}),(0,Q.jsx)(G,{path:`tasks/:id/terminal`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ua,{tab:`terminal`}),children:(0,Q.jsx)(Bk,{view:`terminal`})})}),(0,Q.jsx)(G,{path:`tasks/:id/commits/:sha`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ua,{tab:`changes`}),children:(0,Q.jsx)(Rk,{})})}),(0,Q.jsx)(G,{path:`compare/:groupId`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(kb,{}),children:(0,Q.jsx)(Lk,{})})}),(0,Q.jsx)(G,{path:`git`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(IS,{}),children:(0,Q.jsx)(Vk,{tab:`changes`})})}),(0,Q.jsx)(G,{path:`git/commits`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(IS,{}),children:(0,Q.jsx)(Vk,{tab:`commits`})})}),(0,Q.jsx)(G,{path:`git/commits/:sha`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(IS,{}),children:(0,Q.jsx)(Vk,{tab:`commits`})})}),(0,Q.jsx)(G,{path:`git/branches`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(IS,{}),children:(0,Q.jsx)(Vk,{tab:`branches`})})}),(0,Q.jsx)(G,{path:`git/files`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(IS,{}),children:(0,Q.jsx)(Vk,{tab:`files`})})}),(0,Q.jsx)(G,{path:`git/files/*`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(IS,{}),children:(0,Q.jsx)(Vk,{tab:`files`})})}),(0,Q.jsx)(G,{path:`github`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ab,{}),children:(0,Q.jsx)(Hk,{view:`issues`,index:!0})})}),(0,Q.jsx)(G,{path:`tracker`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Yk,{}),children:(0,Q.jsx)(Uk,{})})}),(0,Q.jsx)(G,{path:`tracker/:id`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Yk,{}),children:(0,Q.jsx)(Uk,{})})}),(0,Q.jsx)(G,{path:`github/prs`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ab,{}),children:(0,Q.jsx)(Hk,{view:`prs`})})}),(0,Q.jsx)(G,{path:`github/issues/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ab,{}),children:(0,Q.jsx)(Hk,{view:`issues`})})}),(0,Q.jsx)(G,{path:`github/prs/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ab,{}),children:(0,Q.jsx)(Hk,{view:`prs`})})}),(0,Q.jsx)(G,{path:`github/prs/:n/changes`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ab,{}),children:(0,Q.jsx)(Hk,{view:`prs`,changes:!0})})}),(0,Q.jsx)(G,{path:`automations`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ob,{}),children:(0,Q.jsx)(Kk,{})})}),(0,Q.jsx)(G,{path:`automations/new`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ob,{}),children:(0,Q.jsx)(Kk,{mode:`new`})})}),(0,Q.jsx)(G,{path:`automations/:automationId`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ob,{}),children:(0,Q.jsx)(Kk,{mode:`edit`})})}),(0,Q.jsx)(G,{path:`automations/:automationId/log`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ob,{}),children:(0,Q.jsx)(Kk,{mode:`log`})})}),(0,Q.jsx)(G,{path:`skills`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(LS,{}),children:(0,Q.jsx)(Gk,{})})}),(0,Q.jsx)(G,{path:`inbox`,element:(0,Q.jsx)(ux,{})}),(0,Q.jsx)(G,{path:`assets`,element:(0,Q.jsx)(Ib,{})}),(0,Q.jsx)(G,{path:`workflows`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(zS,{}),children:(0,Q.jsx)(Wk,{})})}),(0,Q.jsx)(G,{path:`workflows/:name`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(zS,{}),children:(0,Q.jsx)(Wk,{})})}),(0,Q.jsx)(G,{path:`workflows-new/*`,element:(0,Q.jsx)(Or,{to:`/workflows`,replace:!0})}),(0,Q.jsx)(G,{path:`settings`,element:(0,Q.jsx)(FD,{scope:`project`,capabilities:e})}),(0,Q.jsx)(G,{path:`settings/skills`,element:(0,Q.jsx)(qk,{})}),(0,Q.jsx)(G,{path:`settings/prompt-templates`,element:(0,Q.jsx)(Or,{to:{pathname:`/settings/instructions`,hash:`#prompt-templates`},replace:!0})}),XE(`project`,e).map(t=>(0,Q.jsx)(G,{path:`settings/${t.id}`,element:(0,Q.jsx)(MD,{section:t,scope:`project`,capabilities:e})},t.id)),XE(`global`,e).map(e=>(0,Q.jsx)(G,{path:`settings/${e.id}`,element:(0,Q.jsx)(Jk,{sectionId:e.id})},e.id)),(0,Q.jsx)(G,{path:`*`,element:(0,Q.jsx)(FS,{})})]}),(0,Q.jsx)(G,{path:`/tasks`,element:(0,Q.jsx)(bk,{})}),(0,Q.jsx)(G,{path:`/dashboard`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{role:`status`,className:`p-6 text-sm text-muted-foreground`,children:`Loading dashboard…`}),children:(0,Q.jsx)(Ik,{})})}),(0,Q.jsx)(G,{path:`/settings/global`,element:(0,Q.jsx)(FD,{scope:`global`,capabilities:e})}),XE(`global`,e).map(t=>(0,Q.jsx)(G,{path:dD(`global`,t.id),element:(0,Q.jsx)(MD,{section:t,scope:`global`,capabilities:e})},t.id)),(0,Q.jsx)(G,{path:`*`,element:(0,Q.jsx)(Qk,{})})]})});function nA(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 rA(e){return e?.available===!0&&(e.status===`available`||e.status===`error`)}var iA=(0,Z.memo)(function({children:e}){let{pathname:t}=jr(),n=kr(),r=C(),i=Ht(),o=i.data?.branding,s=o!==void 0&&(o.name!==`cezar`||o.logoUrl!==null),c=ne(!s&&i.data!==void 0),l=r.data?.capabilities.followups===!0,u=r.data?.capabilities.automations===!0,d=ye(l),f=rA(pn(n??``,n!==null).data),p=Xy(Er(t)),m=a().data,h=(0,Z.useMemo)(()=>W_(m,n,r.data),[m,n,r.data]),g=eA(t),_=h?.bootProject??r.data?.bootProject??null,v=se(n,_,(0,Z.useMemo)(()=>qo,[])),y=n!==null&&n===_,b=h?.projects.find(e=>e.id===n),x=h?.projects.find(e=>e.id===_),S=n===null?x?.tracker:b?.tracker,w=g.taskId,T=Ye(n??``,b!==void 0&&w!==null,h?.bootProject===n,(0,Z.useMemo)(()=>e=>{let t=w?e.find(e=>e.id===w):void 0;return t?Ve(t):void 0},[w])).data,E=t===`/settings/global`||t.startsWith(`/settings/global/`),D=E?null:b?.name??(y?nA(r.data)?.name??null:null);U_({projectName:D,pageLabel:T??g.pageLabel,brandName:i.data?.branding.name,brandLogoUrl:i.data?.branding.logoUrl});let O=h&&h.projects.length>1?h:null,k=(0,Z.useMemo)(()=>nA(r.data),[r.data?.repo?.root,r.data?.repo?.branch]),A=(0,Z.useMemo)(()=>E?null:{activeId:n??_,activeName:D,projects:(h?.projects??[]).map(({id:e,name:t})=>({id:e,name:t}))},[E,n,_,D,h?.projects]),j=(0,Z.useMemo)(()=>(0,Q.jsx)(gg,{}),[]),M=(0,Z.useMemo)(()=>(0,Q.jsx)(wg,{}),[]),N=(0,Z.useMemo)(()=>(0,Q.jsx)(u_,{}),[]),P=(0,Z.useMemo)(()=>(0,Q.jsx)(dg,{}),[]),F=(0,Z.useMemo)(()=>(0,Q.jsx)(Qy,{}),[]),ee=(0,Z.useMemo)(()=>O?(0,Q.jsx)(D_,{projects:O.projects,bootProjectId:O.bootProject,inboxAvailable:l,automationsAvailable:u,inboxCount:d.data?.length??null,skillsUpdateAvailable:f,newNavItems:p}):void 0,[O,l,u,d.data?.length,f,p]),te=sc(),I=(0,Z.useMemo)(()=>(0,Q.jsx)(L_,{health:r.data,forge:te}),[r.data,te]);return(0,Q.jsxs)(og,{children:[(0,Q.jsx)(_h,{repo:k,brandName:i.data?.branding.name??`cezar`,brandLogoUrl:i.data?.branding.logoUrl??null,version:r.data?.version??null,latestVersion:r.data?.latestVersion??null,starCount:!s&&c.data?.available?c.data.count??null:null,inboxCount:d.data?.length??null,unreadCount:v.data??null,skillsUpdateAvailable:f,newNavItems:p,forgeAvailable:te!=null,inboxAvailable:l,automationsAvailable:u,tracker:S,banner:j,whatsNew:F,footerBanner:M,singleProject:r.data?.capabilities.singleProject===!0,taskQuickList:N,hostWidget:P,projectGroups:ee,toolsMenu:I,projectSwitcher:A,children:e}),(0,Q.jsx)(Bp,{}),(0,Q.jsx)(Vh,{}),(0,Q.jsx)(fb,{})]})});function aA(){let e=jr(),t=a();return(0,Z.useEffect)(()=>{$E(e)},[e]),(0,Z.useEffect)(()=>{let n=wb(e,t.data);n!==null&&(Db(yb(),n)||bb(n))},[e.hash,e.pathname,e.search,t.data]),null}function oA(){let e=U(),t=ni(ht().data?.notifications).enabled,n=(0,Z.useRef)(t);n.current=t;let r=(0,Z.useRef)(new Map);return(0,Z.useEffect)(()=>{let t=kt(V.runs.list()),i=e=>{let{entering:t,statuses:i}=ci(r.current,e);if(r.current=i,t.length!==0&&ii({enabled:n.current,hidden:document.visibilityState===`hidden`,permission:ri()}))for(let e of t)sA(e)};return i(e.getQueryData(V.runs.list())),e.getQueryCache().subscribe(e=>{e.query.queryHash!==t||e.type!==`updated`||i(e.query.state.data)})},[e]),null}function sA(e){let t=globalThis.Notification;if(typeof t!=`function`)return;let n=oi(e);try{new t(n.title,{body:n.body,tag:n.tag})}catch{}}function cA(e,t=!0){return dt({queryKey:[...B.dashboard,`insights`,e],enabled:t,staleTime:5e3,refetchInterval:t?15e3:!1,refetchIntervalInBackground:!1,retry:!1,queryFn:async({signal:t})=>Yn.parse(await be(await Ae.api.v1.workspace.dashboard.insights.$get({query:{period:e,tzOffsetMinutes:String(new Date().getTimezoneOffset())}},{init:{signal:t}}),`/workspace/dashboard/insights`))})}var lA=[`pointerdown`,`pointermove`,`keydown`,`wheel`,`touchstart`];function uA(){let e=document.activeElement;return e?e.isContentEditable||e.tagName===`TEXTAREA`||e.tagName===`INPUT`&&e.type!==`checkbox`:!1}var dA=()=>document.querySelector(`[role="dialog"],[role="alertdialog"]`)!==null;function fA(){let e=U(),t=Ht(),n=t.data?.branding,r=n!==void 0&&(n.name!==`cezar`||n.logoUrl!==null),i=ne(t.data!==void 0&&!r),a=!r&&i.data?.available===!0,o=!r&&i.data?.available?i.data.count??null:null,[s,c]=(0,Z.useState)(!1),l=(0,Z.useRef)(a);l.current=a;let u=(0,Z.useRef)(new Map),d=(0,Z.useRef)(null),f=(0,Z.useRef)(0);return(0,Z.useEffect)(()=>{let t=kt(V.runs.list()),n,r=()=>em({now:Date.now(),visible:document.visibilityState===`visible`,focused:document.hasFocus(),lastInteractionAt:f.current,typing:uA(),dialogOpen:dA()}),i=()=>{let e=d.current;if(!(e===null||n)){if(Date.now()-e>18e5){d.current=null;return}r()&&(n=setTimeout(()=>{n=void 0;let e=Xp();if(!(d.current===null||!r()||!l.current)){if(!Qp(e,Date.now())){d.current=null;return}d.current=null,Zp({...e,asks:e.asks+1,lastAskedAt:new Date().toISOString()}),c(!0)}},Yp))}},a=e=>{let{succeeded:t,statuses:n}=rm(u.current,e);u.current=n,!(!t||!l.current)&&($p(e)<3||Qp(Xp(),Date.now())&&(d.current=Date.now(),i()))},o=()=>{f.current=Date.now(),i()};for(let e of lA)window.addEventListener(e,o,{passive:!0});document.addEventListener(`visibilitychange`,i),window.addEventListener(`focus`,i),a(e.getQueryData(V.runs.list()));let s=e.getQueryCache().subscribe(e=>{e.query.queryHash!==t||e.type!==`updated`||a(e.query.state.data)});return()=>{s(),clearTimeout(n);for(let e of lA)window.removeEventListener(e,o);document.removeEventListener(`visibilitychange`,i),window.removeEventListener(`focus`,i)}},[e]),r?null:(0,Q.jsx)(mA,{open:s,onOpenChange:c,count:o})}function pA(e){let t=Xp();t&&Zp({...t,outcome:e})}function mA({open:e,onOpenChange:t,count:n}){let r=cA(`30d`,e).data?.delivered,i=r&&r.completedTasks>0?[{label:`Tasks done`,n:r.completedTasks,value:r.completedTasks.toLocaleString(`en-US`)},{label:`PRs opened`,n:r.prsOpened,value:r.prsOpened.toLocaleString(`en-US`)},{label:`Lines written`,n:r.additions,value:`+${r.additions.toLocaleString(`en-US`)}`}].filter(e=>e.n>0):null;return(0,Q.jsx)(qr,{open:e,onOpenChange:t,children:(0,Q.jsxs)(Wr,{"data-slot":`star-ask`,className:`gap-0 overflow-hidden p-0 sm:max-w-[440px]`,children:[(0,Q.jsxs)(`div`,{className:`relative flex h-36 items-center justify-center overflow-hidden border-b bg-card-2`,children:[(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:`absolute inset-0 bg-[radial-gradient(circle_at_22%_35%,color-mix(in_oklab,var(--accent-lime)_32%,transparent),transparent_55%),radial-gradient(circle_at_80%_70%,color-mix(in_oklab,var(--violet)_38%,transparent),transparent_55%)]`}),(0,Q.jsxs)(`div`,{"aria-hidden":`true`,className:`relative flex items-center gap-4`,children:[(0,Q.jsx)(sm,{height:52,className:`text-foreground`}),(0,Q.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-full border bg-card shadow-md`,children:(0,Q.jsx)(au,{className:`size-6 fill-current text-pending-strong`})})]}),n!==null&&(0,Q.jsxs)(`span`,{className:`absolute bottom-3 left-1/2 -translate-x-1/2 rounded-full border bg-card/80 px-2.5 py-0.5 font-mono text-meta text-muted-foreground backdrop-blur`,children:[`⭐ `,qp(n),` stars on GitHub`]})]}),(0,Q.jsxs)(`div`,{className:`space-y-4 p-6`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`span`,{className:`section-mark block eyebrow text-muted-foreground`,children:`Open source · MIT`}),(0,Q.jsx)(Zr,{className:`text-xl font-semibold tracking-tight`,children:`Is cezar pulling its weight?`}),(0,Q.jsx)(Vr,{className:`text-sm leading-relaxed text-muted-foreground`,children:`cezar is free, open source and runs on your machine, with no account to create. A GitHub star is how other developers find it, and how we know what to keep building.`})]}),i&&(0,Q.jsxs)(`div`,{className:`rounded-lg border bg-card-2 p-3`,children:[(0,Q.jsx)(`span`,{className:`block eyebrow text-soft-foreground`,children:`Your last 30 days with cezar`}),(0,Q.jsx)(`dl`,{className:`mt-2 grid gap-2`,style:{gridTemplateColumns:`repeat(${i.length}, minmax(0, 1fr))`},children:i.map(e=>(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col-reverse`,children:[(0,Q.jsx)(`dt`,{className:`text-xs text-soft-foreground`,children:e.label}),(0,Q.jsx)(`dd`,{className:`truncate text-lg font-semibold tabular-nums`,children:e.value})]},e.label))})]}),(0,Q.jsx)(J,{asChild:!0,className:`h-11 w-full text-sm font-semibold`,children:(0,Q.jsxs)(`a`,{href:Gp,target:`_blank`,rel:`noopener noreferrer`,onClick:()=>{pA(`starred`),t(!1)},children:[(0,Q.jsx)(au,{className:`size-4 fill-current`,"aria-hidden":`true`}),`Star cezar on GitHub`,(0,Q.jsx)(Ir,{className:`size-4`,"aria-hidden":`true`})]})}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(J,{variant:`ghost`,className:`min-h-11`,onClick:()=>t(!1),children:`Maybe later`}),(0,Q.jsx)(J,{variant:`ghost`,className:`min-h-11 text-soft-foreground`,onClick:()=>{pA(`never`),t(!1)},children:`Don’t ask again`})]})]})]})})}function hA(){let[e]=(0,Z.useState)(fl);return(0,Q.jsx)(Ut,{client:e,children:(0,Q.jsx)(Qr,{children:(0,Q.jsxs)(ta,{children:[(0,Q.jsx)(oA,{}),(0,Q.jsx)(fA,{}),(0,Q.jsx)(zf,{children:(0,Q.jsx)(KC,{children:(0,Q.jsxs)(Ar,{children:[(0,Q.jsx)(aA,{}),(0,Q.jsx)(hs,{}),(0,Q.jsx)(Xr,{children:(0,Q.jsx)(iA,{children:(0,Q.jsx)(tA,{})})}),(0,Q.jsx)(qc,{})]})})})]})})})}function gA(){return(document.querySelector(`meta[name="cez-api-base"]`)?.getAttribute(`content`))?.trim()||``}dr(gA());var _A=document.getElementById(`root`);if(!_A)throw Error(`cezar: #root container is missing from index.html`);(0,dl.createRoot)(_A).render((0,Q.jsx)(Z.StrictMode,{children:(0,Q.jsx)(hA,{})}));export{nu as $,hv as A,fm as B,ry as C,Kv as D,Qv as E,gv as F,Cf as G,dm as H,yv as I,$d as J,ff as K,lv as L,cv as M,_v as N,Gv as O,vv as P,iu as Q,ch as R,ey as S,ty as T,um as U,pm as V,Bf as W,lu as X,uu as Y,su as Z,Xb as _,IS as a,xl as at,kb as b,Xx as c,ax as d,tu as et,ix as f,Kb as g,Yb as h,zS as i,Zl as it,mv as j,Zv as k,qx as l,Zb as m,UD as n,$l as nt,Zx as o,ex as p,lf as q,dD as r,Ql as rt,Jx as s,cA as t,eu as tt,ox as u,qb as v,ny as w,$v as x,Ab as y,lm as z};
|