@wjarka/cezarion 0.18.0-dev.7010 → 0.18.0-dev.7015

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/package.json +2 -2
  2. package/web/dist/assets/{activity-motion-CXY7UQb8.js → activity-motion-DAjCyDzm.js} +1 -1
  3. package/web/dist/assets/{activity-route-CWdkKOcU.js → activity-route-6spKzFa-.js} +1 -1
  4. package/web/dist/assets/{commit-diff-panel-CilF4ucO.js → commit-diff-panel-uoyOydBG.js} +1 -1
  5. package/web/dist/assets/{diff-wu8MI0pe.js → diff-BefwAEc1.js} +2 -2
  6. package/web/dist/assets/{diff-view-BOeIj6fq.js → diff-view-CXtKy-02.js} +1 -1
  7. package/web/dist/assets/{file-preview-DDISrpoK.js → file-preview-TYTU1SBo.js} +1 -1
  8. package/web/dist/assets/{git-toolbar-DSFDBGUd.js → git-toolbar-BwD-ShUL.js} +1 -1
  9. package/web/dist/assets/{github-DBRyp_7V.js → github-DKC9GSOG.js} +1 -1
  10. package/web/dist/assets/{global-activity-route-8gXrkEI5.js → global-activity-route-BnUvjKgI.js} +1 -1
  11. package/web/dist/assets/{index-1Zw2w-1r.js → index-C6UoXbYK.js} +3 -3
  12. package/web/dist/assets/{preview-pane-connected-B_yXVXFs.js → preview-pane-connected-ZAr18goj.js} +3 -3
  13. package/web/dist/assets/{repo-git-cpVcsnni.js → repo-git-Y7MKcjLs.js} +1 -1
  14. package/web/dist/assets/{report-reader-BRw4X5KH.js → report-reader-CIcjK2_U.js} +1 -1
  15. package/web/dist/assets/{reports-BK0543bM.js → reports-SBr0VYKU.js} +1 -1
  16. package/web/dist/assets/{run-header-CZhtodUg.js → run-header-BSohU_tW.js} +1 -1
  17. package/web/dist/assets/{skills-0Az8jsnI.js → skills-B_NKCTPq.js} +1 -1
  18. package/web/dist/assets/{task-changes-jjPRV2ul.js → task-changes-Ozgv3HxN.js} +1 -1
  19. package/web/dist/assets/{task-commits-CxJKFd3j.js → task-commits-BxAERDIz.js} +1 -1
  20. package/web/dist/assets/{task-files-Ddk24Oe-.js → task-files-V84lmxj2.js} +1 -1
  21. package/web/dist/assets/{task-github-item-D49mwA5b.js → task-github-item-CByJ7mYg.js} +1 -1
  22. package/web/dist/assets/{task-thread-BlVvC3Mo.js → task-thread-C6v4ddX-.js} +9 -9
  23. package/web/dist/assets/thread-state-ni3Us7DE.js +4 -0
  24. package/web/dist/assets/{use-hand-to-agent-state-Cgc4s3aK.js → use-hand-to-agent-state-W5nhKd6-.js} +1 -1
  25. package/web/dist/assets/{workflows-BW6W8C0F.js → workflows-Cb0BDqy5.js} +1 -1
  26. package/web/dist/index.html +1 -1
  27. package/web/dist/assets/thread-state-DfIi2HR7.js +0 -4
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/html-BY76lXLH.js","assets/css-BsVw1vtW.js","assets/javascript-BgS3c2Ky.js","assets/core-BCsw8oQw.js","assets/lib-BxQXEXDF.js","assets/rolldown-runtime-QTnfLwEv.js","assets/preview-pane-connected-B_yXVXFs.js","assets/button-DGwhwRuD.js","assets/react-runtime-CCIEwYL0.js","assets/bundle-mjs-BT31bpU6.js","assets/project-scope-context-D8RGERU-.js","assets/live-protocol-DHEBTIRD.js","assets/toaster-CoMJoQvk.js","assets/createLucideIcon-BHp8sXmF.js","assets/arrow-right-Dh_Lx3um.js","assets/hourglass-B0lPAJvT.js","assets/info-DA1x_4bz.js","assets/format-BNCkW110.js","assets/play-CmVAj_fu.js","assets/thread-state-DfIi2HR7.js","assets/app-window-CSHwDX9N.js","assets/dropdown-menu-DPrTX-zi.js","assets/design-icons-DmYTv2r1.js","assets/es2015-DTn4s5Lh.js","assets/dist-ClnpAEgV.js","assets/project-router-znDYCNAi.js","assets/report-reader-BRw4X5KH.js","assets/queries-LH_fzdoQ.js","assets/live-refetch-CZb2VOyu.js","assets/useInfiniteQuery-DZDwRft0.js","assets/useQuery-BTWv1-sJ.js","assets/ws-ClC12aJd.js","assets/file-preview-DDISrpoK.js","assets/centered-state-B5QmAy2y.js","assets/task-thread-BlVvC3Mo.js","assets/use-desktop-CsZKGRsr.js","assets/attention-D4F-L5Pd.js","assets/run-header-CZhtodUg.js","assets/message-square-B-MD-8rD.js","assets/reference-chip-DB4j8hzM.js","assets/alert-dialog-CH4SXGfX.js","assets/dialog-B7p5oc5r.js","assets/tab-link-C5SNXkMO.js","assets/run-header-CC7VUTg9.css","assets/eye-B8okNWXU.js","assets/agent-accounts-BiXu1qX6.js","assets/runner-facts-BpvNgJqf.js","assets/zoomable-image-C7mEDZaS.js","assets/report-title-D4Mbu2Er.js","assets/task-thread-DtQ6uGfQ.css","assets/task-changes-jjPRV2ul.js","assets/git-toolbar-DSFDBGUd.js","assets/diff-controls-CeYlCm_y.js","assets/markdown-BBDDg-4t.js","assets/diff-wu8MI0pe.js","assets/image-preview-cn57tA1m.js","assets/task-files-Ddk24Oe-.js","assets/task-commits-CxJKFd3j.js","assets/commit-diff-panel-CilF4ucO.js","assets/task-github-item-D49mwA5b.js","assets/use-hand-to-agent-state-Cgc4s3aK.js","assets/prompt-template-menu-Z7WYlxLR.js","assets/skills-DFBiAuJG.js","assets/use-hand-to-agent-state-C7esPJ-N.css","assets/repo-git-cpVcsnni.js","assets/nav-row-styles-DSBuSnEE.js","assets/repo-git-DVXNOJDT.css","assets/github-DBRyp_7V.js","assets/reports-BK0543bM.js","assets/reports-B7QAzibP.css","assets/workflows-BW6W8C0F.js","assets/sortable.esm-zp_qkYGV.js","assets/skill-empty-hint-YDmkqgo-.js","assets/activity-route-CWdkKOcU.js","assets/activity-motion-CXY7UQb8.js","assets/activity-motion-0wHCeUs7.css","assets/global-activity-route-8gXrkEI5.js","assets/skills-0Az8jsnI.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/html-BY76lXLH.js","assets/css-BsVw1vtW.js","assets/javascript-BgS3c2Ky.js","assets/core-BCsw8oQw.js","assets/lib-BxQXEXDF.js","assets/rolldown-runtime-QTnfLwEv.js","assets/preview-pane-connected-ZAr18goj.js","assets/button-DGwhwRuD.js","assets/react-runtime-CCIEwYL0.js","assets/bundle-mjs-BT31bpU6.js","assets/project-scope-context-D8RGERU-.js","assets/live-protocol-DHEBTIRD.js","assets/toaster-CoMJoQvk.js","assets/createLucideIcon-BHp8sXmF.js","assets/arrow-right-Dh_Lx3um.js","assets/hourglass-B0lPAJvT.js","assets/info-DA1x_4bz.js","assets/format-BNCkW110.js","assets/play-CmVAj_fu.js","assets/thread-state-ni3Us7DE.js","assets/app-window-CSHwDX9N.js","assets/dropdown-menu-DPrTX-zi.js","assets/design-icons-DmYTv2r1.js","assets/es2015-DTn4s5Lh.js","assets/dist-ClnpAEgV.js","assets/project-router-znDYCNAi.js","assets/report-reader-CIcjK2_U.js","assets/queries-LH_fzdoQ.js","assets/live-refetch-CZb2VOyu.js","assets/useInfiniteQuery-DZDwRft0.js","assets/useQuery-BTWv1-sJ.js","assets/ws-ClC12aJd.js","assets/file-preview-TYTU1SBo.js","assets/centered-state-B5QmAy2y.js","assets/task-thread-C6v4ddX-.js","assets/use-desktop-CsZKGRsr.js","assets/attention-D4F-L5Pd.js","assets/run-header-BSohU_tW.js","assets/message-square-B-MD-8rD.js","assets/reference-chip-DB4j8hzM.js","assets/alert-dialog-CH4SXGfX.js","assets/dialog-B7p5oc5r.js","assets/tab-link-C5SNXkMO.js","assets/run-header-CC7VUTg9.css","assets/eye-B8okNWXU.js","assets/agent-accounts-BiXu1qX6.js","assets/runner-facts-BpvNgJqf.js","assets/zoomable-image-C7mEDZaS.js","assets/report-title-D4Mbu2Er.js","assets/task-thread-DtQ6uGfQ.css","assets/task-changes-Ozgv3HxN.js","assets/git-toolbar-BwD-ShUL.js","assets/diff-controls-CeYlCm_y.js","assets/markdown-BBDDg-4t.js","assets/diff-BefwAEc1.js","assets/image-preview-cn57tA1m.js","assets/task-files-V84lmxj2.js","assets/task-commits-BxAERDIz.js","assets/commit-diff-panel-uoyOydBG.js","assets/task-github-item-CByJ7mYg.js","assets/use-hand-to-agent-state-W5nhKd6-.js","assets/prompt-template-menu-Z7WYlxLR.js","assets/skills-DFBiAuJG.js","assets/use-hand-to-agent-state-C7esPJ-N.css","assets/repo-git-Y7MKcjLs.js","assets/nav-row-styles-DSBuSnEE.js","assets/repo-git-DVXNOJDT.css","assets/github-DKC9GSOG.js","assets/reports-SBr0VYKU.js","assets/reports-B7QAzibP.css","assets/workflows-Cb0BDqy5.js","assets/sortable.esm-zp_qkYGV.js","assets/skill-empty-hint-YDmkqgo-.js","assets/activity-route-6spKzFa-.js","assets/activity-motion-DAjCyDzm.js","assets/activity-motion-0wHCeUs7.css","assets/global-activity-route-BnUvjKgI.js","assets/skills-B_NKCTPq.js"])))=>i.map(i=>d[i]);
2
2
  import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,D as n,E as r,I as i,L as a,M as o,O as s,P as c,S as l,T as u,_ as d,a as f,b as p,c as m,f as h,g,h as _,i as v,j as y,k as b,l as x,m as S,p as C,r as w,s as T,t as E,u as D,v as O,w as k,x as A,y as j}from"./button-DGwhwRuD.js";import{i as M,n as ee,r as te,t as N}from"./react-runtime-CCIEwYL0.js";import{n as P,r as ne}from"./live-refetch-CZb2VOyu.js";import{$r as F,$t as I,An as re,Ar as ie,C as ae,Cr as oe,D as se,Dr as ce,Et as le,Fn as ue,G as de,Gn as fe,Gr as pe,H as me,Hn as he,Hr as ge,Ht as _e,Jt as ve,K as ye,Kn as be,Ln as xe,Lt as Se,Mr as Ce,Nt as we,On as Te,Or as Ee,Pn as De,Qr as Oe,Rn as ke,Rt as Ae,S as je,Sn as Me,T as Ne,Tr as Pe,Tt as Fe,Un as Ie,Ur as L,W as Le,Wn as Re,Wr as ze,Xn as Be,Xr as Ve,Xt as He,Yt as Ue,Zn as We,Zr as Ge,_r as Ke,_t as qe,a as Je,bn as Ye,di as Xe,dn as Ze,en as Qe,et as $e,f as et,g as tt,gr as nt,gt as rt,i as it,ii as at,jn as ot,jr as st,kn as ct,kr as lt,li as ut,lr as dt,mr as ft,n as pt,ni as mt,nn as ht,o as gt,oi as _t,or as vt,p as yt,pn as bt,q as xt,qn as St,qt as Ct,r as wt,ri as Tt,rr as Et,sr as Dt,t as Ot,ti as kt,tn as At,tr as jt,u as Mt,ui as Nt,ur as Pt,vn as Ft,vr as It,wn as Lt,wt as Rt,y as zt,yn as Bt,yr as Vt,yt as Ht}from"./project-scope-context-D8RGERU-.js";import{$ as Ut,A as Wt,F as Gt,I as Kt,M as qt,Q as Jt,Y as Yt,Z as Xt,at as Zt,dt as Qt,et as $t,ft as en,it as tn,j as nn,nt as R,ot as z,q as rn,rt as B,st as an}from"./live-protocol-DHEBTIRD.js";import{t as on}from"./useInfiniteQuery-DZDwRft0.js";import{$ as sn,$t as cn,A as ln,At as un,B as dn,Ct as fn,Dt as pn,Et as mn,F as hn,Ft as gn,G as _n,Gt as vn,It as yn,J as bn,Jt as xn,K as Sn,L as Cn,Lt as wn,Mt as Tn,Nt as En,Ot as Dn,P as On,Pt as kn,Q as An,Qt as jn,Rt as Mn,Tt as Nn,U as Pn,Ut as Fn,V as In,Vt as V,W as Ln,Wt as Rn,X as zn,Xt as Bn,Y as Vn,Yt as Hn,Z as Un,Zt as Wn,_ as Gn,a as Kn,at as qn,b as Jn,c as Yn,ct as Xn,et as Zn,g as Qn,h as $n,ht as er,i as tr,it as nr,jt as rr,kt as ir,l as ar,m as or,mt as sr,n as H,nt as cr,o as lr,ot as ur,p as dr,q as fr,r as pr,s as mr,st as hr,t as gr,tt as _r,ut as vr,v as yr,w as br,wt as xr,y as Sr,zt as Cr}from"./queries-LH_fzdoQ.js";import{t as wr}from"./useQuery-BTWv1-sJ.js";import{i as U}from"./bundle-mjs-BT31bpU6.js";import{i as Tr,r as Er,t as Dr}from"./cez-idle-D49bY6KR.js";import{A as Or,B as kr,C as Ar,D as jr,F as Mr,G as Nr,H as Pr,I as Fr,K as Ir,L as Lr,M as Rr,N as zr,O as Br,P as Vr,Q as Hr,R as Ur,S as Wr,T as Gr,U as Kr,V as qr,W as Jr,X as Yr,Y as Xr,Z as Zr,a as Qr,c as $r,d as ei,g as ti,h as ni,i as ri,j as ii,k as ai,l as oi,m as si,n as ci,o as li,p as ui,q as di,r as fi,s as pi,t as mi,tt as hi,u as gi,v as _i,w as vi,x as yi,y as bi,z as W}from"./use-desktop-CsZKGRsr.js";import{t as xi}from"./ws-ClC12aJd.js";import{n as G,t as Si}from"./toaster-CoMJoQvk.js";import{$ as Ci,A as wi,B as Ti,D as Ei,E as Di,H as Oi,I as ki,J as Ai,K as ji,L as Mi,M as Ni,O as Pi,Q as Fi,R as Ii,S as Li,V as Ri,W as zi,X as Bi,Z as Vi,_ as Hi,a as Ui,at as Wi,b as Gi,c as Ki,ct as qi,d as Ji,et as Yi,f as Xi,ft as Zi,g as Qi,ht as $i,i as ea,it as ta,j as na,k as ra,l as ia,m as aa,mt as oa,n as sa,nt as ca,ot as la,pt as ua,q as da,r as fa,rt as pa,s as ma,t as ha,tt as ga,u as _a,ut as va,w as ya,y as ba,z as xa}from"./design-icons-DmYTv2r1.js";import{t as K}from"./createLucideIcon-BHp8sXmF.js";import{_ as Sa,a as Ca,c as wa,d as Ta,f as Ea,g as Da,h as Oa,i as ka,m as Aa,o as ja,p as Ma,r as Na,s as Pa,u as Fa,y as Ia}from"./nav-row-styles-DSBuSnEE.js";import{t as La}from"./eye-B8okNWXU.js";import{a as Ra,i as za,n as Ba,r as Va,t as Ha}from"./format-BNCkW110.js";import{t as Ua}from"./play-CmVAj_fu.js";import{a as Wa,i as Ga,l as Ka,r as qa,s as Ja,t as Ya,u as Xa}from"./reference-chip-DB4j8hzM.js";import{a as Za,c as Qa,d as $a,f as eo,h as q,i as to,l as no,m as ro,n as io,o as ao,p as J,r as oo,t as so,u as co}from"./es2015-DTn4s5Lh.js";import{C as lo,S as uo,_ as fo,a as po,b as mo,c as ho,d as go,f as _o,g as vo,h as yo,i as bo,l as xo,m as So,o as Co,p as wo,r as To,s as Eo,t as Do,u as Oo,v as ko,x as Ao,y as jo}from"./dropdown-menu-DPrTX-zi.js";import{a as Mo,c as No,d as Po,f as Fo,g as Io,h as Lo,i as Ro,l as zo,m as Bo,n as Vo,o as Ho,p as Uo,r as Wo,s as Go,t as Ko,u as qo}from"./alert-dialog-CH4SXGfX.js";import{t as Jo}from"./dist-ClnpAEgV.js";import{a as Yo,i as Xo,n as Zo,o as Qo,r as $o,s as es,t as ts}from"./dialog-B7p5oc5r.js";import{a as ns,c as rs,d as is,g as as,h as os,i as ss,l as cs,o as ls,p as us,r as ds,s as fs,t as ps,u as ms,y as hs}from"./prompt-template-menu-Z7WYlxLR.js";import{a as gs,c as _s,i as vs,l as ys,n as bs,o as xs,r as Ss,s as Cs,t as Y}from"./project-router-znDYCNAi.js";import{t as ws}from"./attention-D4F-L5Pd.js";import{A as Ts,B as Es,C as Ds,D as Os,E as ks,F as As,G as js,H as Ms,I as Ns,L as Ps,N as Fs,O as Is,P as Ls,R as Rs,S as zs,T as Bs,U as Vs,W as Hs,_ as Us,a as Ws,b as Gs,c as Ks,d as qs,f as Js,g as Ys,h as Xs,i as Zs,j as Qs,k as $s,l as ec,n as tc,o as nc,p as rc,r as ic,s as ac,t as oc,u as sc,v as cc,w as lc,x as uc,y as dc,z as fc}from"./agent-accounts-BiXu1qX6.js";import{_ as pc,a as mc,c as hc,d as gc,f as _c,g as vc,i as yc,l as bc,n as xc,o as Sc,p as Cc,r as wc,t as Tc,u as Ec,v as Dc}from"./sortable.esm-zp_qkYGV.js";import{c as Oc,d as kc,f as Ac,i as jc,n as Mc,r as Nc,s as Pc,t as Fc,u as Ic}from"./skills-DFBiAuJG.js";import{n as Lc}from"./runner-facts-BpvNgJqf.js";import{t as X}from"./centered-state-B5QmAy2y.js";import{i as Rc,n as zc}from"./chunk-BO2N2NFS-DE6qKn3r.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 Bc=class extends Xe{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 cn({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=Vc(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=Vc(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=Vc(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=Vc(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){en.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=>kt(t,e))}findAll(e={}){return this.getAll().filter(t=>kt(e,t))}notify(e){en.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return en.batch(()=>Promise.all(e.map(e=>e.continue().catch(Tt))))}};function Vc(e){return e.options.scope?.id}var Hc=class extends Xe{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??F(r,t),a=this.get(i);return a||(a=new pe({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(){en.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=>mt(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>mt(e,t)):t}notify(e){en.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){en.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){en.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Uc=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Hc,this.#t=e.mutationCache||new Bc,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=Nt.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=Ve.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(_t(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=Ge(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return en.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;en.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return en.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=en.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Tt).catch(Tt)}invalidateQueries(e,t={}){return en.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=en.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(Tt)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Tt)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(_t(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Tt).catch(Tt)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Tt).catch(Tt)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return Ve.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(Oe(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{at(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(Oe(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{at(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||=F(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===ut&&(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(M(),1),Wc=ee(),Gc=class extends EventTarget{readyState=0;release;constructor(e,t){super(),this.release=this.subscribe()}subscribe(){let e=()=>queueMicrotask(()=>{this.readyState===0&&(this.readyState=1,this.dispatchEvent(new Event(`open`)))});return ce({kind:`workspace`},{ready:e,reset:()=>{this.readyState!==2&&(this.readyState=0,e())},frame:t=>{if(`data`in t&&t.event===`reconnect`){this.readyState=0,e();return}if(`data`in t&&t.event===`disconnect`){this.readyState===1&&(this.readyState=0,this.dispatchEvent(new Event(`error`)));return}`data`in t&&t.event===`ready`&&Ee(),`data`in t&&this.dispatchEvent(new MessageEvent(t.event,{data:t.data}))}})}requestReady(){return this.readyState!==2&&Pe()}close(){this.readyState=2,this.release()}};B({runs:$t(`summary`).optional()});var Kc=z().min(1),qc=R().int().positive(),Jc=B({project:Kc,seq:qc,run:St,relationships:z().min(1)}),Yc=B({project:Kc,seq:qc,id:z().min(1)}),Xc=B({generation:z().min(1),seq:R().int().nonnegative()}),Zc=B({project:Kc,usage:Zt(z(),Re)});B({runs:Xt(be),referenceStatuses:fe,perProjectLimit:R(),truncated:Xt(z()),generation:z().min(1),eventSeq:R().int().nonnegative()});function Qc(e,t){if(e===`ping`)return{project:null,event:{type:`ping`}};let n;try{n=JSON.parse(t)}catch{return null}switch(e){case`run-summary`:{let e=Jc.safeParse(n);return e.success?{project:e.data.project,event:{type:`run-summary`,summary:e.data.run,seq:e.data.seq,relationships:e.data.relationships}}:null}case`run-deleted`:{let e=Yc.safeParse(n);return e.success?{project:e.data.project,event:{type:`run-deleted`,id:e.data.id,seq:e.data.seq}}:null}case`usage`:{let e=Zc.safeParse(n);return e.success?{project:e.data.project,event:{type:`usage`,usage:e.data.usage}}:null}case`ready`:{let e=Xc.safeParse(n);return e.success?{project:null,event:{type:`ready`,generation:e.data.generation,seq:e.data.seq}}:null}default:return null}}function $c(){let e;return{ready(t){let n=e!==void 0&&t>e;return e=t,n},frame(t){let n=e!==void 0&&t!==e+1;return e=t,n},reset(){e=void 0}}}function el(e,t){if(!e)return;let n=e.findIndex(e=>e.id===t.id);if(n>=0){let r=[...e];return r[n]=t,r}let r=e.findIndex(e=>(e.createdAt??``).localeCompare(t.createdAt)<0),i=[...e];return i.splice(r<0?e.length:r,0,t),i}function tl(e,t){if(!e)return;let n=e.filter(e=>e.id!==t);return n.length===e.length?e:n}var nl=Object.freeze({});function rl(){let e=nl,t=new Set;return{subscribe(e){return t.add(e),()=>t.delete(e)},get:()=>e,set(n){e=n;for(let e of t)e()}}}function il(e,t){let n=e.getQueryData(t);if(n?.finishBlocked===void 0)return;let{finishBlocked:r,...i}=n;e.setQueryData(t,i)}function al(e){let t=new Map,n=t=>e.getQueryCache().find({queryKey:t,exact:!0}),r=t=>{if(!t.owed||t.timer!==void 0)return;let i=n(t.key);if(!i){t.owed=!1;return}if(!i.isActive()){t.owed=!1,e.invalidateQueries({queryKey:t.key,exact:!0,refetchType:`none`});return}if(i.state.fetchStatus!==`idle`)return;let a=t.lastStart+400-Date.now();if(a>0){t.timer=setTimeout(()=>{t.timer=void 0,r(t)},a);return}t.owed=!1,t.lastStart=Date.now(),e.refetchQueries({queryKey:t.key,exact:!0,type:`active`},{cancelRefetch:!1})},i=e.getQueryCache().subscribe(n=>{if(n.type!==`updated`||t.size===0)return;let i=t.get(JSON.stringify(n.query.queryKey));if(i){if(n.action.type===`success`&&!n.action.manual){let t=n.query.promise;t&&i.preEvent.has(t)&&(i.preEvent.delete(t),il(e,i.key),i.owed=!0)}n.query.state.fetchStatus===`idle`&&r(i)}});return{onEvent(i){let a=H.runs.detail(i),o=n(a);if(!o)return;let s=JSON.stringify(a),c=t.get(s);c||(c={key:a,owed:!1,lastStart:0,preEvent:new WeakSet},t.set(s,c)),o.state.fetchStatus!==`idle`&&o.promise&&c.preEvent.add(o.promise),il(e,a),c.owed=!0,r(c)},forget(e){let n=JSON.stringify(H.runs.detail(e));clearTimeout(t.get(n)?.timer),t.delete(n)},cancel(){i();for(let e of t.values())clearTimeout(e.timer);t.clear()}}}function ol(e){let t=new Map;return{refresh(n){let r=H.runs.detail(n);if(!e.getQueryState(r))return;let i=JSON.stringify(r);clearTimeout(t.get(i)),e.cancelQueries({queryKey:r}),t.set(i,setTimeout(()=>{t.delete(i),e.invalidateQueries({queryKey:r})},400))},cancel(){for(let e of t.values())clearTimeout(e);t.clear()}}}var Q=N(),sl=b(`/workspace/events?runs=summary`),cl=2,ll=3e3,ul=[`run-summary`,`run-deleted`,`usage`,`ping`,`ready`],dl=[`project-added`,`project-removed`,`checkout-progress`,`automation-change`,`project-ready`],fl=new Set;function pl(e){return fl.add(e),()=>{fl.delete(e)}}function ml(e){return e[1]===`runs`&&e[2]===`list`}function hl(e,t){return e.cancelQueries({queryKey:t}).then(()=>e.invalidateQueries({queryKey:t}))}function gl(e){return e.invalidateQueries({predicate:e=>ml(e.queryKey),refetchType:`none`}),e.getQueryCache().findAll({predicate:e=>ml(e.queryKey)&&(e.state.data!==void 0||e.state.fetchStatus!==`idle`)}).map(t=>hl(e,t.queryKey))}var _l=1e3,vl=new WeakMap;function yl(e){let t=H.repoBranches,n=vl.get(e);if(n){n.set(JSON.stringify(t),t);return}vl.set(e,new Map([[JSON.stringify(t),t]])),setTimeout(()=>{let t=vl.get(e);vl.delete(e);for(let n of t?.values()??[])e.invalidateQueries({queryKey:n})},_l)}function bl(e,t,n=!1){if(t?.aborted)return Promise.resolve();let r=[H.runs.all,V.runsIndex,V.projects,H.health,H.worktrees,H.repoBranches,V.providerStatus],i=()=>{for(let t of r)e.cancelQueries({queryKey:t})};return t?.addEventListener(`abort`,i,{once:!0}),Tr(()=>{for(let t of e.getQueryCache().findAll({predicate:e=>ml(e.queryKey)}))t.state.data===void 0&&t.state.fetchStatus!==`idle`&&e.cancelQueries({queryKey:t.queryKey,exact:!0});return[e.invalidateQueries({queryKey:H.runs.all,...n?{predicate:e=>[`list`,`detail`,`relationships`,`archived`].includes(String(e.queryKey[2]))}:{}}),e.invalidateQueries({predicate:e=>ml(e.queryKey)}),xn(e).reconcile(),e.invalidateQueries({queryKey:V.projects}),hl(e,H.health),e.invalidateQueries({queryKey:H.worktrees}),e.invalidateQueries({queryKey:H.repoBranches}),e.invalidateQueries({queryKey:V.providerStatus}),n?void 0:e.invalidateQueries({predicate:({queryKey:e})=>e.length===3&&e[1]===`github`&&(e[2]===null||typeof e[2]==`number`)})]}).finally(()=>t?.removeEventListener(`abort`,i))}function xl(e){return y()??Sl(e)}function Sl(e){let t=e.getQueryData(V.projects)?.bootProject;return typeof t==`string`&&t!==``?t:e.getQueryData(H.health)?.bootProject??e.getQueryData([`default`,`health`])?.bootProject}function Cl(e,t){return[Bn({projectId:e,boot:e===t}).cacheScope,`runs`,`list`]}function wl(e){let t=new Map,n=new Map,r=t=>{let r=n.get(JSON.stringify(t));if(!r)return;let i=e.getQueryCache().find({queryKey:t,exact:!0}),a=i?.promise;r.phase=`awaiting-fetch`,r.dirty=!1,e.invalidateQueries({queryKey:t,exact:!0}),i?.promise&&i.promise!==a&&(r.phase=`fetching`)},i=e.getQueryCache().subscribe(t=>{if(!n.size||t.type!==`updated`)return;let i=JSON.stringify(t.query.queryKey),a=n.get(i);if(a){if(t.action.type===`setState`){t.query.state.isInvalidated||e.invalidateQueries({queryKey:a.key,exact:!0,refetchType:`none`});return}if(t.action.type===`fetch`){a.phase===`awaiting-fetch`&&(a.phase=`fetching`),a.dirty=!1;return}if(t.action.type===`success`){if(!t.action.manual){a.phase===`fetching`&&!a.dirty?n.delete(i):r(a.key);return}a.phase!==`needs-start`&&(a.phase===`fetching`&&(a.dirty=!0),e.invalidateQueries({queryKey:a.key,exact:!0},{cancelRefetch:!1}))}}}),a=(t,r)=>{let i=JSON.stringify(t),a=e.getQueryCache().find({queryKey:t,exact:!0});if(!a)return;let o=n.get(i);!o&&(a.state.fetchStatus!==`idle`||a.state.isInvalidated)||o&&a.state.fetchStatus===`idle`?(n.set(i,{key:t,phase:`needs-start`,dirty:!1}),a.state.fetchStatus!==`idle`&&e.cancelQueries({queryKey:t,exact:!0}),r.some(e=>JSON.stringify(e)===i)||r.push(t)):o?.phase===`fetching`&&(o.dirty=!0)},o,s,c=(i=!1)=>{s!==void 0&&clearTimeout(s),s=void 0,o!==void 0&&cancelAnimationFrame(o),o=void 0;let c=[];for(let{key:r,baseList:i,baseQuery:o,baseUpdateCount:s,runs:l}of t.values()){let t=e.getQueryCache().find({queryKey:r,exact:!0});if(t!==o||t?.state.dataUpdateCount!==s||t?.state.data!==i){c.push(r),n.set(JSON.stringify(r),{key:r,phase:`needs-start`,dirty:!1}),e.cancelQueries({queryKey:r,exact:!0});continue}a(r,c),e.setQueryData(r,e=>{let t=e;for(let e of l.values())t=el(t,e);return t})}if(t.clear(),!i)for(let e of c)r(e);return c},l=t=>{let n=[Cl(t,Sl(e))],r=[t,`runs`,`list`];return(t===xl(e)||e.getQueryState(r))&&n.push(r),t===xl(e)&&n.push(H.runs.list()),[...new Map(n.map(e=>[JSON.stringify(e),e])).values()]};return{onEvent(i,u){let d=l(i);if(u.type===`run-summary`&&u.summary.archived&&d.every(t=>!e.getQueryData(t)?.find(e=>e.id===u.summary.id)?.archived)&&u.type===`run-summary`){for(let r of d){let i=JSON.stringify(r),a=n.get(i);a?.phase===`fetching`&&(a.dirty=!0);let o=t.get(i);if(!o){let n=e.getQueryCache().find({queryKey:r,exact:!0});o={key:r,baseList:n?.state.data,baseQuery:n,baseUpdateCount:n?.state.dataUpdateCount,runs:new Map},t.set(i,o)}o.runs.set(u.summary.id,u.summary)}s===void 0&&(s=setTimeout(()=>{c()},50),typeof requestAnimationFrame==`function`&&(o=requestAnimationFrame(()=>{c()})));return}let f=c(!0);for(let t of d)a(t,f),u.type===`run-summary`?e.setQueryData(t,e=>el(e,u.summary)):e.setQueryData(t,e=>tl(e,u.id));for(let e of f)r(e)},flush:c,cancel(){i(),n.clear()}}}var Tl=400;function El(e){let t=new Map,n=new Map,r=(t,r)=>{if(r&&!e.getQueryState(t))return;let i=JSON.stringify(t);n.has(i)||n.set(i,setTimeout(()=>{n.delete(i),e.invalidateQueries({queryKey:t})},Tl))};return{onSummary(e,n){let i=e.delegation?.role===`worker`?e.delegation.parentRunId:void 0,a=t.get(e.id);t.set(e.id,i===void 0?{shape:n}:{shape:n,parentRunId:i}),a?.shape!==n&&(r(H.runs.relationships(e.id),!0),i!==void 0&&r(H.runs.relationships(i),!0))},onDeleted(n){let i=t.get(n);t.delete(n),e.removeQueries({queryKey:H.runs.relationships(n)}),i?.parentRunId===void 0?r([...H.runs.all,`relationships`],!1):r(H.runs.relationships(i.parentRunId),!0)},cancel(){for(let e of n.values())clearTimeout(e);n.clear(),t.clear()}}}var Dl={predicate:e=>e.queryKey[1]===`runs`&&e.queryKey[2]===`archived`};function Ol(e,t){if(t.delegation?.role===`worker`)return;let n=!1;for(let r of e.getQueryCache().findAll(Dl)){let i=r.state.data;i&&(i.pages.some(e=>e.runs.some(e=>e.id===t.id))?(e.setQueryData(r.queryKey,{...i,pages:i.pages.map(e=>({...e,runs:e.runs.map(e=>e.id===t.id?t:e)}))}),(!t.archived||r.queryKey[3]!==``)&&(n=!0)):t.archived&&(n=!0))}n&&e.invalidateQueries(Dl)}function kl(e,t,n,r,i){switch(n.type){case`run-summary`:{let t=n.summary;if(Ol(e,t),i.onSummary(t,n.relationships),r.fetcher.onEvent(t.id),t.delegation?.role===`worker`){let n=t.delegation.parentRunId;il(e,H.runs.detail(n)),r.refreshParent(n)}let a=H.runs.changes(t.id);e.getQueryData(a)!==void 0&&e.invalidateQueries({queryKey:a}),e.invalidateQueries({queryKey:H.worktrees}),yl(e);return}case`run-deleted`:i.onDeleted(n.id),r.fetcher.forget(n.id),e.removeQueries({queryKey:H.runs.detail(n.id)}),e.removeQueries({queryKey:H.runs.diff(n.id)}),e.setQueriesData(Dl,e=>e&&e.pages.some(e=>e.runs.some(e=>e.id===n.id))?{...e,pages:e.pages.map(e=>({...e,runs:e.runs.filter(e=>e.id!==n.id)}))}:e),e.invalidateQueries(Dl),e.invalidateQueries({queryKey:H.worktrees}),yl(e);return;case`usage`:t.set(n.usage);return;case`ping`:case`ready`:return}}function Al(e,t=sl){let n=L();(0,Z.useEffect)(()=>{let r=Gc;if(typeof r!=`function`)return;let i=null,a=xn(n);a.setUnknownGenerationHandler(()=>{let e=i?.requestReady;return typeof e==`function`&&e.call(i)});let o=ol(n),s=al(n),c={fetcher:s,refreshParent:o.refresh},l=$c(),u=wl(n),d=El(n),f=!1,p,m=!1,h=!1,g=!1,_=!1,v=()=>{g=!0,_=!1;let e=V.providerStatus;n.cancelQueries({queryKey:e,exact:!0}).then(()=>n.invalidateQueries({queryKey:e,exact:!0,refetchType:`active`})).finally(()=>{if(h||!_){g=!1;return}v()})},y=()=>{h||p!==void 0||(p=setTimeout(()=>{p=void 0,h||b()},ll))},b=()=>{i?.close(),i=new r(t,{withCredentials:!0}),i.addEventListener(`open`,()=>{f=!0,l.reset(),a.detach(),Er(!1),m&&(u.flush(),bl(n)),m||(Tr(()=>gl(n)),n.cancelQueries({queryKey:H.health}).then(()=>{h||n.invalidateQueries({queryKey:H.health})}),a.reconcile()),m=!0});for(let t of ul)i.addEventListener(t,r=>{let i=Qc(t,r.data);if(!i)return;if(i.event.type===`ready`){let e=l.ready(i.event.seq);a.ready(i.event.generation,i.event.seq),e&&(u.flush(),bl(n));return}let o=(i.event.type===`run-summary`||i.event.type===`run-deleted`)&&l.frame(i.event.seq);i.event.type===`ping`&&f&&(f=!1,Tr(()=>gl(n)),Er(!0)),i.project!==null&&(i.event.type===`run-summary`||i.event.type===`run-deleted`?a.run(i.project,i.event,o):i.event.type===`usage`&&a.usage(i.project,i.event.usage)),i.project!==null&&(i.event.type===`run-summary`||i.event.type===`run-deleted`)&&u.onEvent(i.project,i.event),(i.project===null||i.project===xl(n))&&kl(n,e,i.event,c,d),o&&(u.flush(),bl(n))});for(let e of dl)i.addEventListener(e,t=>{let r;try{r=JSON.parse(t.data)}catch{return}if(e===`project-ready`?a.reconcile({hold:!0}):e!==`checkout-progress`&&e!==`automation-change`&&n.invalidateQueries({queryKey:V.projects}),e===`project-added`){let e=r?.project?.id;typeof e==`string`&&e!==``&&a.restoreProject(e),a.reconcile({hold:!0})}if(e===`project-removed`){let e=r?.id;typeof e==`string`&&e!==``&&a.dropProject(e)}for(let t of[...fl])t(e,r)});i.addEventListener(`health`,e=>{let t;try{t=JSON.parse(e.data)}catch{return}let r=Ce.safeParse(t);r.success&&(n.cancelQueries({queryKey:H.health}),n.setQueryData(H.health,r.data))}),i.addEventListener(`provider-status`,e=>{let t;try{t=JSON.parse(e.data)}catch{return}let r=nt(t);if(!r)return;let i=V.providerStatus,a=ft(n.getQueryData(i),r);if(a!==void 0){n.setQueryData(i,a);return}if(g){_=!0;return}v()}),i.addEventListener(`error`,()=>{Er(!1),a.detach(),i?.readyState===cl&&y()})},x=()=>{document.visibilityState===`visible`&&(u.flush(),a.flush(),(!i||i.readyState===cl)&&(clearTimeout(p),p=void 0,b()))},S=()=>{clearTimeout(p),p=void 0,u.flush()};document.addEventListener(`visibilitychange`,x),window.addEventListener(`pagehide`,S);let C=oe((e,t)=>(u.flush(),bl(n,e,t)));return b(),()=>{C(),h=!0,Er(!1),clearTimeout(p),u.flush(),u.cancel(),a.stop(),o.cancel(),s.cancel(),a.setUnknownGenerationHandler(void 0),d.cancel(),document.removeEventListener(`visibilitychange`,x),window.removeEventListener(`pagehide`,S),i?.close(),i=null}},[n,e,t])}var jl=(0,Z.createContext)(null);function Ml({children:e}){let[t]=(0,Z.useState)(rl);return Al(t),hn(),(0,Q.jsx)(jl.Provider,{value:t,children:e})}function Nl(e){let t=(0,Z.useContext)(jl),n=t?t.get:Fl;return(0,Z.useSyncExternalStore)(t?t.subscribe:Pl,()=>e?n()[e]:void 0,()=>void 0)}var Pl=()=>()=>void 0,Fl=()=>nl,Il=z().regex(/^(?:(?:config\.json(?:\.bak)?|agent-accounts\.json|ui-state\.json|server\.json|server\.install\.lock)|(?:remote-settings|server-instances)\/[a-zA-Z0-9-]+\.(?:json|install\.lock))$/),Ll=B({file:Il,detectedAt:Qt(),canRestore:Jt()}),Rl=[`reset`,`outside-write`,`legacy-change`],zl=B({files:Xt(Ut(`reason`,[Ll.extend({reason:$t(`reset`)}),Ll.extend({reason:$t(`outside-write`)}),Ll.extend({reason:$t(`legacy-change`),canImport:Jt()})]))});function Bl(e,t){return!e||typeof e!=`object`||!(`files`in e)||!Array.isArray(e.files)?e:{...e,files:e.files.filter(e=>!(e&&typeof e==`object`&&`reason`in e&&typeof e.reason==`string`&&!t.includes(e.reason)))}}var Vl=tn(e=>Bl(e,Rl),zl);B({file:Il,detectedAt:Qt()}).strict();async function Hl(e,t,n){n.throwIfAborted();let r=new ze(e,{queryKey:t.queryKey,queryFn:t.queryFn,retry:!1,enabled:!1}).subscribe(()=>void 0);n.addEventListener(`abort`,r,{once:!0});try{return await e.fetchQuery({...t,retry:!1})}finally{n.removeEventListener(`abort`,r),r()}}var Ul=[`workspace`,`home-recovery`];function Wl(e){let t=Vl.safeParse(e);if(!t.success)throw new it(200,`the ${a(`cezar`)} server answered /home/recovery with an unexpected body`);return t.data}async function Gl(e){return Wl(await Me(await et.api.v1.home.recovery.$get({},Se(e)),`/home/recovery`))}function Kl(){return wr({queryKey:Ul,queryFn:({signal:e})=>Gl({signal:e}),enabled:st(),staleTime:1/0,retry:!1})}function ql(){let e=L();(0,Z.useEffect)(()=>{let t=!0,n=new AbortController,r,i=async t=>{lt()&&await Hl(e,{queryKey:Ul,queryFn:({signal:e})=>Gl({signal:e}),staleTime:0},t?AbortSignal.any([n.signal,t]):n.signal)},a=n=>{let r;try{r=Wl(n)}catch{i().catch(()=>{});return}e.cancelQueries({queryKey:Ul,exact:!0}).then(()=>{t&&lt()&&e.setQueryData(Ul,r)})},o=()=>{let t=e.getQueryData(H.health)?.capabilities?.localHandoff===!0;t&&lt()&&!r?r=xi(`home:recovery`,a):(!t||!lt())&&r&&(r(),r=void 0)};o();let s=e.getQueryCache().subscribe(o),c=ie(t=>{o(),t?i().catch(()=>{}):e.cancelQueries({queryKey:Ul,exact:!0})}),l=oe(e=>i(e));return()=>{t=!1,n.abort(),l(),c(),s(),r?.()}},[e])}function Jl(e,t){let n=t===`config.json`?[V.projects,V.config,V.runsIndex]:t===`agent-accounts.json`?[V.agentProfiles,V.providerStatus]:t===`ui-state.json`?[V.uiState]:[];for(let t of n)e.invalidateQueries({queryKey:t})}function Yl(e){let t=L();return jn({mutationFn:async t=>Wl(await Me(await et.api.v1.home.recovery[e].$post({json:t}),`/home/recovery/${e}`)),onSuccess:async(e,n)=>{await t.cancelQueries({queryKey:Ul,exact:!0}),t.setQueryData(Ul,e),Jl(t,n.file)}})}var Xl=()=>Yl(`restore`),Zl=()=>Yl(`accept`),Ql=()=>Yl(`import`);function $l(){return ql(),null}function eu(){return new Uc({defaultOptions:{queries:{refetchInterval:!1,staleTime:5*6e4,gcTime:30*6e4,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:(e,t)=>t instanceof it&&t.status>=400&&t.status<500?!1:e<1},mutations:{retry:!1}}})}var tu=Z.createContext(null),nu=class extends Z.Component{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:Error(String(e))}}componentDidCatch(e,t){console.error(`${a(`cezar`)} cockpit: uncaught render error`,e,t.componentStack)}render(){let{error:e}=this.state;return e?(0,Q.jsxs)(`div`,{"data-slot":`app-error`,role:`alert`,style:{display:`flex`,minHeight:`100dvh`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`12px`,padding:`24px`,textAlign:`center`,font:`14px/1.5 system-ui, sans-serif`},children:[(0,Q.jsx)(`h1`,{style:{fontSize:`20px`,fontWeight:600,margin:0},children:`The cockpit hit an error`}),(0,Q.jsxs)(`p`,{style:{margin:0,maxWidth:`52ch`},children:[`Reload to carry on. Nothing on disk changed — `,a(`cezar`),`’s state lives in`,` `,(0,Q.jsx)(`code`,{children:`.ai/cezar/`}),`, and this page never wrote to it.`]}),(0,Q.jsx)(`pre`,{"data-slot":`app-error-detail`,style:{margin:0,maxWidth:`100%`,overflowX:`auto`,textAlign:`left`,opacity:.75},children:e.message}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>location.reload(),style:{padding:`6px 14px`,cursor:`pointer`},children:`Reload`})]}):this.props.children}},ru=K(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),iu=K(`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`}]]),au=K(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),ou=K(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),su=K(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),cu=K(`brush`,[[`path`,{d:`m11 10 3 3`,key:`fzmg1i`}],[`path`,{d:`M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z`,key:`p4q2r7`}],[`path`,{d:`M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031`,key:`wy6l02`}]]),lu=K(`check-check`,[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]),uu=K(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),du=K(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),fu=K(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),pu=K(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),mu=K(`chevrons-left`,[[`path`,{d:`m11 17-5-5 5-5`,key:`13zhaf`}],[`path`,{d:`m18 17-5-5 5-5`,key:`h8a8et`}]]),hu=K(`chevrons-right`,[[`path`,{d:`m6 17 5-5-5-5`,key:`xnjwq`}],[`path`,{d:`m13 17 5-5-5-5`,key:`17xmmf`}]]),gu=K(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),_u=K(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),vu=K(`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`}]]),yu=K(`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`}]]),bu=K(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),xu=K(`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`}]]),Su=K(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),Cu=K(`diamond`,[[`path`,{d:`M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z`,key:`1f1r0c`}]]),wu=K(`dollar-sign`,[[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`,key:`1b0p4s`}]]),Tu=K(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),Eu=K(`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`}]]),Du=K(`feather`,[[`path`,{d:`M12.67 19a2 2 0 0 0 1.416-.588l6.154-6.172a6 6 0 0 0-8.49-8.49L5.586 9.914A2 2 0 0 0 5 11.328V18a1 1 0 0 0 1 1z`,key:`18jl4k`}],[`path`,{d:`M16 8 2 22`,key:`vp34q`}],[`path`,{d:`M17.5 15H9`,key:`1oz8nu`}]]),Ou=K(`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`}]]),ku=K(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Au=K(`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`}]]),ju=K(`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`}]]),Mu=K(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Nu=K(`gem`,[[`path`,{d:`M10.5 3 8 9l4 13 4-13-2.5-6`,key:`b3dvk1`}],[`path`,{d:`M17 3a2 2 0 0 1 1.6.8l3 4a2 2 0 0 1 .013 2.382l-7.99 10.986a2 2 0 0 1-3.247 0l-7.99-10.986A2 2 0 0 1 2.4 7.8l2.998-3.997A2 2 0 0 1 7 3z`,key:`7w4byz`}],[`path`,{d:`M2 9h20`,key:`16fsjt`}]]),Pu=K(`git-pull-request-arrow`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M5 9v12`,key:`ih889a`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}]]),Fu=K(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),Iu=K(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),Lu=K(`hammer`,[[`path`,{d:`m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9`,key:`1hayfq`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`15ts47`}]]),Ru=K(`hexagon`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}]]),zu=K(`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`}]]),Bu=K(`link`,[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]),Vu=K(`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`}]]),Hu=K(`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`}]]),Uu=K(`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`}]]),Wu=K(`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`}]]),Gu=K(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),Ku=K(`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`}]]),qu=K(`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`}]]),Ju=K(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),Yu=K(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),Xu=K(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Zu=K(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]),Qu=K(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),$u=K(`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`}]]),ed=K(`shapes`,[[`path`,{d:`M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z`,key:`1bo67w`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}],[`circle`,{cx:`17.5`,cy:`17.5`,r:`3.5`,key:`w3z12y`}]]),td=K(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),nd=K(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),rd=K(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),id=K(`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`}]]),ad=K(`waves-horizontal`,[[`path`,{d:`M2 12q2.5 2 5 0t5 0 5 0 5 0`,key:`8ddzzs`}],[`path`,{d:`M2 19q2.5 2 5 0t5 0 5 0 5 0`,key:`1wj4st`}],[`path`,{d:`M2 5q2.5 2 5 0t5 0 5 0 5 0`,key:`69x50u`}]]),od=K(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),sd=K(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),cd=`cezar:open-command-palette`;function ld(){window.dispatchEvent(new Event(cd))}var ud=`cez-sidebar-width`;function dd(e){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?Math.min(420,Math.max(264,Math.round(t))):264}function fd(){try{let e=localStorage.getItem(ud);return e===null?264:dd(e)}catch{return 264}}function pd(e){try{localStorage.setItem(ud,String(dd(e)))}catch{}}var md=Z.createContext(264),hd=Z.createContext(void 0);function gd(){return Z.useContext(hd)}var _d=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),vd=`VisuallyHidden`,yd=Z.forwardRef((e,t)=>(0,Q.jsx)(q.span,{...e,ref:t,style:{..._d,...e.style}}));yd.displayName=vd;var bd=yd,xd=`Collapsible`,[Sd,Cd]=ro(xd),[wd,Td]=Sd(xd),Ed=Z.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=$a({prop:r,defaultProp:i??!1,onChange:o,caller:xd});return(0,Q.jsx)(wd,{scope:n,disabled:a,contentId:no(),open:c,onOpenToggle:Z.useCallback(()=>l(e=>!e),[l]),children:(0,Q.jsx)(q.div,{"data-state":Md(c),"data-disabled":a?``:void 0,...s,ref:t})})});Ed.displayName=xd;var Dd=`CollapsibleTrigger`,Od=Z.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,i=Td(Dd,n);return(0,Q.jsx)(q.button,{type:`button`,"aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":Md(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:J(e.onClick,i.onOpenToggle)})});Od.displayName=Dd;var kd=`CollapsibleContent`,Ad=Z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Td(kd,e.__scopeCollapsible);return(0,Q.jsx)(co,{present:n||i.open,children:({present:e})=>(0,Q.jsx)(jd,{...r,ref:t,present:e})})});Ad.displayName=kd;var jd=Z.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=Td(kd,n),[s,c]=Z.useState(r),l=Z.useRef(null),u=T(t,l),d=Z.useRef(0),f=d.current,p=Z.useRef(0),m=p.current,h=o.open||s,g=Z.useRef(h),_=Z.useRef(void 0);return Z.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),eo(()=>{let e=l.current;if(e){_.current=_.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=_.current.transitionDuration,e.style.animationName=_.current.animationName),c(r)}},[o.open,r]),(0,Q.jsx)(q.div,{"data-state":Md(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!h,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:h&&i})});function Md(e){return e?`open`:`closed`}var Nd=Ed;function Pd(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 Fd=`Label`,Id=Z.forwardRef((e,t)=>(0,Q.jsx)(q.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));Id.displayName=Fd;var Ld=Id;function Rd(e,[t,n]){return Math.min(n,Math.max(t,e))}var zd=e(te(),1),Bd=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Vd=[` `,`Enter`],Hd=`Select`,[Ud,Wd,Gd]=lo(Hd),[Kd,qd]=ro(Hd,[Gd,Ao]),Jd=Ao(),[Yd,Xd]=Kd(Hd),[Zd,Qd]=Kd(Hd),$d=`SelectProvider`;function ef(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=Jd(t),[_,v]=Z.useState(null),[y,b]=Z.useState(null),[x,S]=Z.useState(!1),C=uo(l),[w,T]=$a({prop:r,defaultProp:i??!1,onChange:a,caller:Hd}),[E,D]=$a({prop:o,defaultProp:s,onChange:c,caller:Hd}),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),ee=no(),te=Array.from(j).map(e=>e.props.value).join(`;`),N=Z.useCallback(e=>{M(t=>new Set(t).add(e))},[]),P=Z.useCallback(e=>{M(t=>{let n=new Set(t);return n.delete(e),n})},[]),ne={required:p,trigger:_,onTriggerChange:v,valueNode:y,onValueNodeChange:b,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:ee,value:E,onValueChange:D,open:w,onOpenChange:T,dir:C,triggerPointerDownPosRef:O,disabled:f,name:u,autoComplete:d,form:m,nativeOptions:j,nativeSelectKey:te,isFormControl:A};return(0,Q.jsx)(mo,{...g,children:(0,Q.jsx)(Yd,{scope:t,...ne,children:(0,Q.jsx)(Ud.Provider,{scope:t,children:(0,Q.jsx)(Zd,{scope:t,onNativeOptionAdd:N,onNativeOptionRemove:P,children:tp(h)?h(ne):n})})})})}ef.displayName=$d;var tf=e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,Q.jsx)(ef,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,Q.jsxs)(Q.Fragment,{children:[n,e?(0,Q.jsx)(ep,{__scopeSelect:t}):null]})})};tf.displayName=Hd;var nf=`SelectTrigger`,rf=Z.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Jd(n),o=Xd(nf,n),s=o.disabled||r,c=T(t,o.onTriggerChange),l=Wd(n),u=Z.useRef(`touch`),[d,f,p]=rp(e=>{let t=l().filter(e=>!e.disabled),n=ip(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)(fo,{asChild:!0,...a,children:(0,Q.jsx)(q.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":np(o.value)?``:void 0,...i,ref:c,onClick:J(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:J(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:J(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&Bd.includes(e.key)&&(m(),e.preventDefault())})})})});rf.displayName=nf;var af=`SelectValue`,of=Z.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=Xd(af,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=T(t,c.onValueNodeChange);eo(()=>{l(u)},[l,u]);let f=np(c.value);return(0,Q.jsx)(q.span,{...s,asChild:!f&&s.asChild,ref:d,style:{pointerEvents:`none`},children:(0,Q.jsx)(Z.Fragment,{children:f?o:a},f?`placeholder`:`value`)})});of.displayName=af;var sf=`SelectIcon`,cf=Z.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,Q.jsx)(q.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});cf.displayName=sf;var lf=`SelectPortal`,[uf,df]=Kd(lf,{forceMount:void 0}),ff=e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,Q.jsx)(uf,{scope:e.__scopeSelect,forceMount:n,children:(0,Q.jsx)(to,{asChild:!0,...r})})};ff.displayName=lf;var pf=`SelectContent`,mf=Z.forwardRef((e,t)=>{let n=df(pf,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=Xd(pf,e.__scopeSelect),[o,s]=Z.useState();return eo(()=>{s(new DocumentFragment)},[]),(0,Q.jsx)(co,{present:r||a.open,children:({present:e})=>e?(0,Q.jsx)(xf,{...i,ref:t}):(0,Q.jsx)(hf,{...i,fragment:o})})});mf.displayName=pf;var hf=Z.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,fragment:i}=e;return i?zd.createPortal((0,Q.jsx)(_f,{scope:n,children:(0,Q.jsx)(Ud.Slot,{scope:n,children:(0,Q.jsx)(`div`,{ref:t,children:r})})}),i):null});hf.displayName=`SelectContentFragment`;var gf=10,[_f,vf]=Kd(pf),yf=`SelectContentImpl`,bf=v(`SelectContent.RemoveScroll`),xf=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=Xd(pf,n),[y,b]=Z.useState(null),[x,S]=Z.useState(null),C=T(t,b),[w,E]=Z.useState(null),[D,O]=Z.useState(null),k=Wd(n),[A,j]=Z.useState(!1),M=Z.useRef(!1);Z.useEffect(()=>{if(y)return so(y)},[y]),oo();let ee=Z.useCallback(e=>{let[t,...n]=k().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[k,x]),te=Z.useCallback(()=>ee([w,y]),[ee,w,y]);Z.useEffect(()=>{A&&te()},[A,te]);let{onOpenChange:N,triggerPointerDownPosRef:P}=v;Z.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(P.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(P.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(y)||N(!1),document.removeEventListener(`pointermove`,t),P.current=null};return P.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,N,P]),Z.useEffect(()=>{let e=()=>N(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[N]);let[ne,F]=rp(e=>{let t=k().filter(e=>!e.disabled),n=ip(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),I=Z.useCallback((e,t,n)=>{let r=!M.current&&!n;(v.value!==void 0&&v.value===t||r)&&(E(e),r&&(M.current=!0))},[v.value]),re=Z.useCallback(()=>y?.focus(),[y]),ie=Z.useCallback((e,t,n)=>{let r=!M.current&&!n;(v.value!==void 0&&v.value===t||r)&&O(e)},[v.value]),ae=r===`popper`?Tf:Cf,oe=ae===Tf?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,Q.jsx)(_f,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:I,selectedItem:w,onItemLeave:re,itemTextRefCallback:ie,focusSelectedItem:te,selectedItemText:D,position:r,isPositioned:A,searchRef:ne,children:(0,Q.jsx)(io,{as:bf,allowPinchZoom:!0,children:(0,Q.jsx)(Za,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:J(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,Q.jsx)(ao,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,Q.jsx)(ae,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...oe,onPlaced:()=>j(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:J(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&F(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=k().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>ee(t)),e.preventDefault()}})})})})})})});xf.displayName=yf;var Sf=`SelectItemAlignedPosition`,Cf=Z.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=Xd(pf,n),o=vf(pf,n),[s,c]=Z.useState(null),[l,u]=Z.useState(null),d=T(t,u),f=Wd(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-gf,d=Rd(a,[gf,Math.max(gf,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-gf,d=Rd(a,[gf,Math.max(gf,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-gf*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-gf,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=`${gf}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]);eo(()=>y(),[y]);let[b,x]=Z.useState();return eo(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,Q.jsx)(Ef,{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)(q.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});Cf.displayName=Sf;var wf=`SelectPopperPosition`,Tf=Z.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=gf,...a}=e,o=Jd(n);return(0,Q.jsx)(jo,{...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)`}})});Tf.displayName=wf;var[Ef,Df]=Kd(pf,{}),Of=`SelectViewport`,kf=Z.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=vf(Of,n),o=Df(Of,n),s=T(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)(Ud.Slot,{scope:n,children:(0,Q.jsx)(q.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:J(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-gf*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})})})]})});kf.displayName=Of;var Af=`SelectGroup`,[jf,Mf]=Kd(Af),Nf=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=no();return(0,Q.jsx)(jf,{scope:n,id:i,children:(0,Q.jsx)(q.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});Nf.displayName=Af;var Pf=`SelectLabel`,Ff=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Mf(Pf,n);return(0,Q.jsx)(q.div,{id:i.id,...r,ref:t})});Ff.displayName=Pf;var If=`SelectItem`,[Lf,Rf]=Kd(If),zf=Z.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=Xd(If,n),c=vf(If,n),l=s.value===r,[u,d]=Z.useState(a??``),[f,p]=Z.useState(!1),m=T(t,Qa(e=>c.itemRefCallback?.(e,r,i))),h=no(),g=Z.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};return(0,Q.jsx)(Lf,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:Z.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,Q.jsx)(Ud.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,Q.jsx)(q.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:J(o.onFocus,()=>p(!0)),onBlur:J(o.onBlur,()=>p(!1)),onClick:J(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:J(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:J(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:J(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:J(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:J(o.onKeyDown,e=>{i||e.target!==e.currentTarget||c.searchRef?.current!==``&&e.key===` `||(Vd.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});zf.displayName=If;var Bf=`SelectItemText`,Vf=Z.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=Xd(Bf,n),s=vf(Bf,n),c=Rf(Bf,n),l=Qd(Bf,n),[u,d]=Z.useState(null),f=Qa(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=T(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 eo(()=>(g(h),()=>_(h)),[g,_,h]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!np(o.value)?zd.createPortal(a.children,o.valueNode):null]})});Vf.displayName=Bf;var Hf=`SelectItemIndicator`,Uf=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return Rf(Hf,n).isSelected?(0,Q.jsx)(q.span,{"aria-hidden":!0,...r,ref:t}):null});Uf.displayName=Hf;var Wf=`SelectScrollUpButton`,Gf=Z.forwardRef((e,t)=>{let n=vf(Wf,e.__scopeSelect),r=Df(Wf,e.__scopeSelect),[i,a]=Z.useState(!1),o=T(t,r.onScrollButtonChange);return eo(()=>{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)(Jf,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});Gf.displayName=Wf;var Kf=`SelectScrollDownButton`,qf=Z.forwardRef((e,t)=>{let n=vf(Kf,e.__scopeSelect),r=Df(Kf,e.__scopeSelect),[i,a]=Z.useState(!1),o=T(t,r.onScrollButtonChange);return eo(()=>{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)(Jf,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});qf.displayName=Kf;var Jf=Z.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=vf(`SelectScrollButton`,n),o=Z.useRef(null),s=Wd(n),c=Z.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return Z.useEffect(()=>()=>c(),[c]),eo(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,Q.jsx)(q.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:J(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:J(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:J(i.onPointerLeave,()=>{c()})})}),Yf=`SelectSeparator`,Xf=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,Q.jsx)(q.div,{"aria-hidden":!0,...r,ref:t})});Xf.displayName=Yf;var Zf=`SelectArrow`,Qf=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Jd(n);return vf(Zf,n).position===`popper`?(0,Q.jsx)(ko,{...i,...r,ref:t}):null});Qf.displayName=Zf;var $f=`SelectBubbleInput`,ep=Z.forwardRef(({__scopeSelect:e,...t},n)=>{let r=Xd($f,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=T(n,p),h=i??``,g=Pd(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)(q.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:u,onChange:e=>a(e.target.value),...t,style:{..._d,...t.style},ref:m,defaultValue:h,children:[np(i)&&!_?(0,Q.jsx)(`option`,{value:``}):null,Array.from(d)]},f)});ep.displayName=$f;function tp(e){return typeof e==`function`}function np(e){return e===``||e===void 0}function rp(e){let t=Qa(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 ip(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=ap(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 ap(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var op=`Switch`,[sp,cp]=ro(op),[lp,up]=sp(op);function dp(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]=$a({prop:n,defaultProp:i??!1,onChange:c,caller:op}),[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)(lp,{scope:t,...v,children:yp(d)?d(v):r})}var fp=`SwitchTrigger`,pp=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}=up(fp,e),h=T(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)(q.button,{type:`button`,role:`switch`,"aria-checked":c,"aria-required":l,"data-state":bp(c),"data-disabled":s?``:void 0,disabled:s,value:o,...n,ref:h,onClick:J(t,e=>{d(e=>!e),m&&p&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})});pp.displayName=fp;var mp=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)(dp,{__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)(pp,{...d,ref:t,__scopeSwitch:n}),e&&(0,Q.jsx)(vp,{__scopeSwitch:n})]})})});mp.displayName=op;var hp=`SwitchThumb`,gp=Z.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=up(hp,n);return(0,Q.jsx)(q.span,{"data-state":bp(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});gp.displayName=hp;var _p=`SwitchBubbleInput`,vp=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}=up(_p,e),m=T(n,p),h=Pd(a),g=Jo(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)(q.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%)`}})});vp.displayName=_p;function yp(e){return typeof e==`function`}function bp(e){return e?`checked`:`unchecked`}var xp=`Tabs`,[Sp,Cp]=ro(xp,[vo]),wp=vo(),[Tp,Ep]=Sp(xp),Dp=Z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=uo(s),[d,f]=$a({prop:r,onChange:i,defaultProp:a??``,caller:xp});return(0,Q.jsx)(Tp,{scope:n,baseId:no(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,Q.jsx)(q.div,{dir:u,"data-orientation":o,...l,ref:t})})});Dp.displayName=xp;var Op=`TabsList`,kp=Z.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=Ep(Op,n),o=wp(n);return(0,Q.jsx)(yo,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,Q.jsx)(q.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});kp.displayName=Op;var Ap=`TabsTrigger`,jp=Z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=Ep(Ap,n),s=wp(n),c=Pp(o.baseId,r),l=Fp(o.baseId,r),u=r===o.value;return(0,Q.jsx)(So,{asChild:!0,...s,focusable:!i,active:u,children:(0,Q.jsx)(q.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:J(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:J(e.onKeyDown,e=>{i||e.target!==e.currentTarget||[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:J(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});jp.displayName=Ap;var Mp=`TabsContent`,Np=Z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=Ep(Mp,n),c=Pp(s.baseId,r),l=Fp(s.baseId,r),u=r===s.value,d=Z.useRef(u);return Z.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,Q.jsx)(co,{present:i||u,children:({present:n})=>(0,Q.jsx)(q.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})});Np.displayName=Mp;function Pp(e,t){return`${e}-trigger-${t}`}function Fp(e,t){return`${e}-content-${t}`}var Ip=Dp,Lp=kp,Rp=jp,zp=Np,[Bp,Vp]=ro(`Tooltip`,[Ao]),Hp=Ao(),Up=`TooltipProvider`,Wp=700,Gp=`tooltip.open`,[Kp,qp]=Bp(Up),Jp=e=>{let{__scopeTooltip:t,delayDuration:n=Wp,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=Z.useRef(!0),s=Z.useRef(!1),c=Z.useRef(0);return Z.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,Q.jsx)(Kp,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:Z.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:Z.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:Z.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};Jp.displayName=Up;var Yp=`Tooltip`,[Xp,Zp]=Bp(Yp),Qp=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=qp(Yp,e.__scopeTooltip),l=Hp(t),[u,d]=Z.useState(null),f=no(),p=Z.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=Z.useRef(!1),[_,v]=$a({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(Gp))):c.onClose(),a?.(e)},caller:Yp}),y=Z.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=Z.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=Z.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=Z.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return Z.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,Q.jsx)(mo,{...l,children:(0,Q.jsx)(Xp,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:Z.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:Z.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};Qp.displayName=Yp;var $p=`TooltipTrigger`,em=Z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Zp($p,n),a=qp($p,n),o=Hp(n),s=T(t,Z.useRef(null),i.onTriggerChange),c=Z.useRef(!1),l=Z.useRef(!1),u=Z.useCallback(()=>c.current=!1,[]);return Z.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,Q.jsx)(fo,{asChild:!0,...o,children:(0,Q.jsx)(q.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:J(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:J(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:J(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:J(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:J(e.onBlur,i.onClose),onClick:J(e.onClick,i.onClose)})})});em.displayName=$p;var tm=`TooltipPortal`,[nm,rm]=Bp(tm,{forceMount:void 0}),im=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=Zp(tm,t);return(0,Q.jsx)(nm,{scope:t,forceMount:n,children:(0,Q.jsx)(co,{present:n||a.open,children:(0,Q.jsx)(to,{asChild:!0,container:i,children:r})})})};im.displayName=tm;var am=`TooltipContent`,om=Z.forwardRef((e,t)=>{let n=rm(am,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=Zp(am,e.__scopeTooltip);return(0,Q.jsx)(co,{present:r||o.open,children:o.disableHoverableContent?(0,Q.jsx)(dm,{side:i,...a,ref:t}):(0,Q.jsx)(sm,{side:i,...a,ref:t})})}),sm=Z.forwardRef((e,t)=>{let n=Zp(am,e.__scopeTooltip),r=qp(am,e.__scopeTooltip),i=Z.useRef(null),a=T(t,i),[o,s]=Z.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=Z.useCallback(()=>{s(null),d(!1)},[d]),p=Z.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=hm(r,mm(r,n.getBoundingClientRect())),a=gm(t.getBoundingClientRect()),o=vm([...i,...a]);s(o),d(!0)},[d]);return Z.useEffect(()=>()=>f(),[f]),Z.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),Z.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!_m(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,Q.jsx)(dm,{...e,ref:a})}),[cm,lm]=Bp(Yp,{isInside:!1}),um=f(`TooltipContent`),dm=Z.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=Zp(am,n),l=Hp(n),{onClose:u}=c;return Z.useEffect(()=>(document.addEventListener(Gp,u),()=>document.removeEventListener(Gp,u)),[u]),Z.useEffect(()=>{if(c.trigger){let e=e=>{e.target instanceof Node&&e.target.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,Q.jsx)(ao,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,Q.jsxs)(jo,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,Q.jsx)(um,{children:r}),(0,Q.jsx)(cm,{scope:n,isInside:!0,children:(0,Q.jsx)(bd,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});om.displayName=am;var fm=`TooltipArrow`,pm=Z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Hp(n);return lm(fm,n).isInside?null:(0,Q.jsx)(ko,{...i,...r,ref:t})});pm.displayName=fm;function mm(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function hm(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function gm(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function _m(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function vm(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),ym(t)}function ym(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var bm=Jp,xm=Qp,Sm=em,Cm=im,wm=om,Tm=pm,Em=m(`inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 [&>svg]:pointer-events-none [&>svg]:size-3`,{variants:{variant:{default:`bg-accent-strong text-accent-strong-foreground [a&]:hover:bg-accent-strong/90`,secondary:`bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`bg-destructive text-destructive-foreground focus-visible:ring-destructive/20 [a&]:hover:bg-destructive/90`,outline:`border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,ghost:`[a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,link:`text-link-foreground underline-offset-4 [a&]:hover:underline`}},defaultVariants:{variant:`default`}});function Dm({className:e,variant:t=`default`,asChild:n=!1,...r}){return(0,Q.jsx)(n?w:`span`,{"data-slot":`badge`,"data-variant":t,className:D(Em({variant:t}),e),...r})}var Om=`x-apple.systempreferences:com.apple.preference.security?Privacy_FilesAndFolders`,km=`inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-foreground hover:bg-muted`;function Am(e){let t=e.replace(/[\\/]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n<0?null:n===0?t.slice(0,1):t.slice(0,n)}function jm({path:e,selected:t,onSelect:n,onEnter:r,decorate:i,emptyHint:a,showHidden:o=!1}){let s=br(e,o),c=s.data?.parent??null;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{"data-slot":`fs-breadcrumb`,className:`truncate font-mono text-[11px] text-soft-foreground`,title:s.data?.path??void 0,children:s.data?.path??(s.isError?``:`Loading…`)}),s.isError?(0,Q.jsx)(Mm,{error:s.error,path:e,onEnter:r,onRetry:()=>void s.refetch()}):(0,Q.jsxs)(`ul`,{"data-slot":`fs-listing`,className:`max-h-64 divide-y divide-border/60 overflow-y-auto overscroll-contain rounded-md border border-border`,children:[c===null?null:(0,Q.jsx)(`li`,{className:`flex`,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`fs-up`,onClick:()=>r(c),className:`flex flex-1 items-center gap-2 px-3 py-2 text-left text-[13px] hover:bg-muted`,children:[(0,Q.jsx)(xu,{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:D(`flex min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left text-[13px] hover:bg-muted`,t?.path===e.path&&`bg-muted`),children:[(0,Q.jsx)(Mu,{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)(pu,{className:`size-3.5`,"aria-hidden":`true`})})]},e.path)),s.data&&s.data.dirs.length===0?(0,Q.jsx)(`li`,{className:`px-3 py-2 text-[13px] text-muted-foreground`,children:a}):null]}),s.data?.truncated?(0,Q.jsx)(`p`,{"data-slot":`fs-truncated`,className:`text-[11px] text-muted-foreground`,children:`Too many folders to list — only the first ones are shown.`}):null]})}function Mm({error:e,path:t,onEnter:n,onRetry:r}){let i=e instanceof it&&e.status===403,a=t===null?null:Am(t);return(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Q.jsx)(`p`,{"data-slot":`fs-error`,className:`min-w-0 break-words text-[13px] text-danger`,children:e instanceof Error?e.message:`could not list that folder`}),i?(0,Q.jsx)(`p`,{"data-slot":`fs-privacy-hint`,className:`text-[12.5px] text-soft-foreground`,children:`Allow it under Privacy & Security ▸ Files & Folders, then try again.`}):null,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[12.5px]`,children:[a===null?null:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`fs-error-back`,onClick:()=>n(a),className:km,children:[(0,Q.jsx)(xu,{className:`size-3.5`,"aria-hidden":!0}),`Back`]}),i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`a`,{"data-slot":`fs-privacy-settings`,href:Om,target:`_blank`,rel:`noreferrer`,className:km,children:`Open Privacy Settings`}),(0,Q.jsx)(`button`,{type:`button`,"data-slot":`fs-retry`,onClick:r,className:km,children:`Try again`})]}):null]})]})}function Nm(e,t,n=!1){let r=br(e,n);return t?.path??r.data?.path??null}function Pm({open:e,onOpenChange:t}){let[n,r]=(0,Z.useState)(null),[i,o]=(0,Z.useState)(null),s=An(),c=qn(),l=k(),u=new Set((s.data?.projects??[]).map(e=>e.root)),d=e=>{r(e),o(null),c.reset()},f=Nm(n,i);return(0,Q.jsx)(ts,{open:e,onOpenChange:t,children:(0,Q.jsxs)($o,{"data-slot":`add-project-dialog`,className:`sm:max-w-lg`,children:[(0,Q.jsxs)(Qo,{children:[(0,Q.jsx)(es,{children:`Open local folder`}),(0,Q.jsxs)(Xo,{children:[`Pick the folder `,a(`cezar`),` should run in. Git repos are marked; any folder works.`]})]}),(0,Q.jsxs)(Zo,{className:`space-y-4`,children:[(0,Q.jsx)(jm,{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)(Dm,{variant:`outline`,className:`shrink-0 text-[12px]`,children:`git`}):null,u.has(e.path)?(0,Q.jsx)(Dm,{variant:`ghost`,className:`shrink-0 text-[12px] 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-[13px] text-danger`,children:c.error instanceof Error?c.error.message:`could not add that folder`}):null]}),(0,Q.jsxs)(Yo,{className:`min-w-0 sm:items-center sm:justify-between`,children:[(0,Q.jsx)(`span`,{"data-slot":`add-project-target`,className:`min-w-0 truncate font-mono text-[11px] text-muted-foreground`,title:f??void 0,children:f??``}),(0,Q.jsxs)(`span`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsx)(E,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(E,{"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 Fm(e,t){let[n,r]=(0,Z.useState)(null),i=(0,Z.useMemo)(()=>`${e}${Math.random().toString(36).slice(2)}-${Date.now().toString(36)}`,[]),a=(0,Z.useRef)(i);return a.current=i,(0,Z.useEffect)(()=>pl((e,t)=>{if(e!==`checkout-progress`)return;let n=t;n?.checkoutId===a.current&&(n.phase===`cloning`&&n.line?r(n.line):n.phase!==`cloning`&&r(null))}),[]),(0,Z.useEffect)(()=>oe(async e=>{if(!t)return;let n=await xt(i,{signal:e}).catch(()=>null);if(!n)return;let{progress:o}=n;e.aborted||o?.checkoutId!==a.current||r(o?.phase===`cloning`?o.line??null:null)}),[t,i]),{checkoutId:i,progress:n,setProgress:r}}function Im({className:e,type:t,...n}){return(0,Q.jsx)(`input`,{type:t,"data-slot":`input`,className:D(`h-11 w-full min-w-0 rounded-md border border-control-border bg-[var(--task-brand-bg)] px-3 py-1 text-base shadow-none transition-[color,box-shadow] outline-hidden selection:bg-accent-strong selection:text-accent-strong-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-soft-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,`aria-invalid:border-destructive aria-invalid:ring-destructive/20`,e),...n})}function Lm({className:e,...t}){return(0,Q.jsx)(Ld,{"data-slot":`label`,className:D(`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 Rm(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 zm({open:e,onOpenChange:t}){let[n,r]=(0,Z.useState)(``),[i,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),l=(0,Z.useRef)(!1),u=An(),d=or(),{mutate:f,isPending:p}=d,m=k(),h=Rm(d.error),{checkoutId:g,progress:_,setProgress:v}=Fm(`co-`,p),y=(0,Z.useMemo)(()=>{let e=n.trim().replace(/\/+$/,``).replace(/\.git$/,``).split(`/`).pop()??``;return e.includes(`:`)?e.split(`:`).pop()??``:e},[n]),b=i.trim()===``?y:i.trim(),x=u.data?.projectsDir??``,S=b===``?``:`${x.replace(/\/+$/,``)}/${b}`,w=(0,Z.useCallback)(()=>{n.trim()===``||p||(l.current=!1,c(!1),v(null),f({url:n.trim(),checkoutId:g,...i.trim()===``?{}:{name:i.trim()}},{onSuccess:({project:e})=>{t(!1),m(`/p/${encodeURIComponent(e.id)}/`)}}))},[f,p,g,i,m,t,n]);return(0,Z.useEffect)(()=>{if(!s)return;let e=()=>{l.current&&(l.current=!1,c(!1),w())},t=()=>{document.visibilityState===`visible`&&e()};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,t)}},[s,w]),(0,Q.jsx)(ts,{open:e,onOpenChange:e=>d.isPending?void 0:t(e),children:(0,Q.jsxs)($o,{"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)(Qo,{children:[(0,Q.jsx)(es,{children:`Clone from GitHub`}),(0,Q.jsxs)(Xo,{children:[a(`cezar`),` clones with `,(0,Q.jsx)(`code`,{children:`gh`}),` into your checkout root and adds the result as a project.`]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsx)(Lm,{htmlFor:`clone-url`,children:`Repository`}),(0,Q.jsx)(Im,{id:`clone-url`,"data-slot":`clone-url`,autoFocus:!0,placeholder:`owner/repo or https://github.com/owner/repo`,value:n,disabled:d.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)(Lm,{htmlFor:`clone-name`,children:`Folder name`}),(0,Q.jsx)(Im,{id:`clone-name`,"data-slot":`clone-name`,placeholder:y===``?`repo`:y,value:i,disabled:d.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-[11px] text-soft-foreground`,title:S,children:S}),d.isPending?(0,Q.jsx)(E,{"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)(Yi,{className:`size-3.5`,"aria-hidden":`true`})}):(0,Q.jsx)(E,{asChild:!0,variant:`ghost`,size:`icon-sm`,className:`size-7`,children:(0,Q.jsx)(C,{to:`/settings/global/projects`,"data-slot":`clone-root-settings`,"aria-label":`Edit checkout root`,title:`Edit checkout root`,children:(0,Q.jsx)(Yi,{className:`size-3.5`,"aria-hidden":`true`})})})]})]}),d.isPending?(0,Q.jsx)(`p`,{"data-slot":`clone-progress`,className:`truncate font-mono text-[11px] text-muted-foreground`,children:_??`Starting the clone…`}):null,d.isError?(0,Q.jsx)(`div`,{"data-slot":`clone-error`,className:`grid min-w-0 gap-1.5 text-[13px] text-danger`,children:h?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{children:`GitHub requires SAML authorization for this organization.`}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`a`,{"data-slot":`clone-sso-link`,className:`inline-flex min-h-11 items-center font-medium underline underline-offset-2`,href:h,target:`_blank`,rel:`noreferrer`,onClick:()=>{l.current=!0,c(!0)},children:`Authorize this GitHub organization`}),s?` — return here after authorizing, or choose Retry clone.`:` — return to this tab to retry, or choose Retry clone.`]}),(0,Q.jsxs)(`details`,{className:`min-w-0`,children:[(0,Q.jsx)(`summary`,{className:`min-h-11 content-center`,children:`Error details`}),(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap break-all`,children:d.error instanceof Error?d.error.message:null})]})]}):(0,Q.jsx)(`p`,{className:`min-w-0 whitespace-pre-wrap break-all`,children:d.error instanceof Error?d.error.message:`could not clone that repository`})}):null,(0,Q.jsxs)(Yo,{children:[(0,Q.jsx)(E,{variant:`outline`,disabled:d.isPending,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(E,{"data-slot":`clone-confirm`,disabled:n.trim()===``||b===``||d.isPending,onClick:w,children:d.isPending?`Cloning…`:d.isError?`Retry clone`:`Clone`})]})]})})}var Bm=[{slug:`github/codespaces-nextjs`,label:`Next.js`,description:`Minimal Next.js app (GitHub)`},{slug:`vercel/chatbot`,label:`Next.js AI chatbot`,description:`Full-featured AI chat app (Vercel)`},{slug:`vercel/nextjs-postgres-nextauth-tailwindcss-template`,label:`Next.js admin dashboard`,description:`Postgres, Auth.js and Tailwind (Vercel)`},{slug:`github/codespaces-react`,label:`React + Vite`,description:`React single-page app (GitHub)`},{slug:`antfu-collective/vitesse`,label:`Vue + Vite`,description:`Opinionated Vue starter (Vitesse)`},{slug:`nuxt-ui-templates/starter-vue`,label:`Vue + Nuxt UI`,description:`Vue + Vite with Nuxt UI (Nuxt)`},{slug:`mugnavo/cove`,label:`Vite+`,description:`TanStack Start on Vite+ (vp), Better Auth`},{slug:`w3cj/hono-open-api-starter`,label:`Hono`,description:`Type-safe JSON API with OpenAPI docs`},{slug:`github/codespaces-express`,label:`Express`,description:`Node.js web server (GitHub)`},{slug:`andrewmcodes/obsidian-beginner-vault-template`,label:`Obsidian vault`,description:`Your own knowledge base in Markdown`},{slug:`chibat/chrome-extension-typescript-starter`,label:`Chrome extension`,description:`TypeScript extension starter`},{slug:`actions/typescript-action`,label:`GitHub Action`,description:`TypeScript action with tests (GitHub)`},{slug:`microsoft/python-package-template`,label:`Python package`,description:`Packaging, tests and CI (Microsoft)`},{slug:`github/codespaces-flask`,label:`Flask`,description:`Python web app (GitHub)`},{slug:`github/codespaces-django`,label:`Django`,description:`Python web framework (GitHub)`},{slug:`github/codespaces-rails`,label:`Ruby on Rails`,description:`Rails app (GitHub)`},{slug:`github/codespaces-jupyter`,label:`Jupyter notebooks`,description:`Data science and ML (GitHub)`}];function Vm(e){let t=e.trim().toLowerCase();return t===``||Bm.some(e=>e.slug.toLowerCase()===t)?Bm:Bm.filter(e=>[e.label,e.slug,e.description].some(e=>e.toLowerCase().includes(t)))}function Hm({value:e,onChange:t,disabled:n,id:r}){let i=(0,Z.useId)(),a=Vm(e),[o,s]=(0,Z.useState)(-1),c=(0,Z.useRef)(null);(0,Z.useEffect)(()=>s(-1),[e]),(0,Z.useEffect)(()=>{o<0||c.current?.querySelector(`[data-index="${o}"]`)?.scrollIntoView?.({block:`nearest`})},[o]);let l=e=>`${i}-option-${e}`;return(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-1.5`,children:[(0,Q.jsx)(Im,{id:r,"data-slot":`create-project-template`,role:`combobox`,"aria-expanded":`true`,"aria-controls":i,"aria-autocomplete":`list`,"aria-activedescendant":o>=0?l(o):void 0,autoComplete:`off`,spellCheck:!1,placeholder:`owner/repo or https://github.com/owner/repo`,value:e,disabled:n,onChange:e=>t(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),a.length===0)return;let t=e.key===`ArrowDown`;s(e=>e<0?t?0:a.length-1:(e+(t?1:-1)+a.length)%a.length)}else if(e.key===`Enter`&&o>=0){e.preventDefault(),e.stopPropagation();let n=a[o];n&&t(n.slug)}}}),(0,Q.jsx)(`ul`,{ref:c,id:i,role:`listbox`,"aria-label":`Suggested templates`,"data-slot":`create-project-template-list`,className:`max-h-48 min-h-0 overflow-y-auto overscroll-contain rounded-md border border-border`,children:a.length===0?(0,Q.jsx)(`li`,{className:`px-3 py-2 text-xs text-muted-foreground`,role:`presentation`,children:`No suggestion matches — any GitHub template repository works.`}):a.map((r,i)=>{let a=r.slug.toLowerCase()===e.trim().toLowerCase();return(0,Q.jsxs)(`li`,{id:l(i),role:`option`,"aria-selected":a,"data-index":i,"data-value":r.slug,"data-slot":`create-project-template-option`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n||t(r.slug)},className:D(`grid min-h-11 cursor-pointer content-center gap-0.5 px-3 py-1.5 text-start`,`pointer-hover:hover:bg-accent`,i===o&&`bg-accent`,a&&`font-medium`),children:[(0,Q.jsxs)(`span`,{className:`truncate text-[13px]`,children:[r.label,` `,(0,Q.jsx)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:r.slug})]}),(0,Q.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:r.description})]},r.slug)})})]})}function Um({className:e,size:t=`default`,...n}){return(0,Q.jsx)(mp,{"data-slot":`switch`,"data-size":t,className:D(`peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-none transition-[color,background-color,border-color,box-shadow] outline-hidden focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-6 data-[size=default]:w-10 data-[size=sm]:h-3.5 data-[size=sm]:w-6 data-[state=checked]:bg-accent-strong data-[state=unchecked]:bg-input`,e),...n,children:(0,Q.jsx)(gp,{"data-slot":`switch-thumb`,className:D(`pointer-events-none block rounded-full bg-background ring-0 motion-safe:transition-transform group-data-[size=default]/switch:size-[18px] group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-[state=checked]:translate-x-5 group-data-[size=default]/switch:data-[state=unchecked]:translate-x-0.5 group-data-[size=sm]/switch:data-[state=checked]:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-[state=unchecked]:translate-x-0`)})})}function Wm(e){return{available:e.data?.available?e.data.owners:null,unavailableReason:e.isError?`GitHub is unavailable: ${e.error instanceof Error?e.error.message:`could not ask gh`}`:e.data&&!e.data.available?e.data.reason:null}}function Gm(e,t){return e&&t!==null&&t.length>0}function Km(e,t){return e??t?.[0]?.login??null}function qm(e){return(e.data?.projectsDir??``).replace(/\/+$/,``)}function Jm({nameValid:e,isPending:t,created:n,github:r,chosenOwner:i,effectiveStart:a,template:o}){return e&&!t&&n===null&&(!r||i!==null&&(a===`empty`||o.trim()!==``))}function Ym({trimmed:e,checkoutId:t,github:n,chosenOwner:r,effectiveStart:i,template:a}){return{name:e,checkoutId:t,...n&&r?{github:{owner:r,...i===`template`?{template:a.trim()}:{}}}:{}}}function Xm({created:e}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(qi,{"aria-hidden":`true`,className:`mbs-0.5 size-5 shrink-0 text-warning`}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,Q.jsx)(`p`,{className:`font-medium`,children:`The project was created, but its GitHub repository is not finished.`}),(0,Q.jsx)(`p`,{className:`min-w-0 whitespace-pre-wrap break-words font-mono text-xs`,children:e.warning})]})]})}function Zm({fieldId:e,name:t,setName:n,trimmed:r,nameValid:i,projectsDir:a,isPending:o,create:s}){let c=`${e}-name-hint`;return(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsx)(Lm,{htmlFor:`${e}-name`,children:`Name`}),(0,Q.jsx)(Im,{id:`${e}-name`,"data-slot":`create-project-name`,autoFocus:!0,autoComplete:`off`,spellCheck:!1,placeholder:`my-project`,value:t,disabled:o,"aria-invalid":r!==``&&!i,"aria-describedby":r!==``&&!i?c:void 0,onChange:e=>n(e.target.value.replace(/\s/g,`-`)),onKeyDown:e=>{e.key===`Enter`&&s()}}),r!==``&&!i?(0,Q.jsx)(`p`,{id:c,"data-slot":`create-project-name-hint`,className:`text-xs text-danger`,children:`Use letters, digits, “.”, “-” and “_” only, starting with a letter or digit — it names the folder and the repository.`}):null,(0,Q.jsx)(`p`,{"data-slot":`create-project-path`,className:`min-w-0 truncate font-mono text-[11px] text-soft-foreground`,title:`${a}/${r}`,children:r===``?`${a}/…`:`${a}/${r}`})]})}function Qm({fieldId:e,github:t,setGithubOn:n,isPending:r,available:i}){return(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(Um,{id:`${e}-github`,"data-slot":`create-project-github`,checked:t,disabled:r||i===null||i.length===0,onCheckedChange:n,className:`mbs-0.5`}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-0.5`,children:[(0,Q.jsx)(Lm,{htmlFor:`${e}-github`,children:`Also create a private GitHub repository`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Under the account you choose. You can change its visibility on GitHub later.`})]})]})}function $m({fieldId:e,effectiveStart:t,setStart:n,isPending:r,github:i,template:a,setTemplate:o}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`fieldset`,{className:`grid gap-2`,disabled:r,children:[(0,Q.jsx)(`legend`,{className:`mbe-2 text-sm font-medium`,children:`Start with`}),(0,Q.jsx)(rh,{slot:`create-project-start-empty`,name:`${e}-start`,checked:t===`empty`,disabled:r,onChange:()=>n(`empty`),title:`Empty repository`,detail:`One empty first commit, no files.`}),(0,Q.jsx)(rh,{slot:`create-project-start-template`,name:`${e}-start`,checked:t===`template`,disabled:r||!i,onChange:()=>n(`template`),title:`From a template`,detail:i?`GitHub generates the repository from a template.`:`Needs the GitHub repository.`})]}),t===`template`?(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsx)(Lm,{htmlFor:`${e}-template`,children:`Template`}),(0,Q.jsx)(Hm,{id:`${e}-template`,value:a,onChange:o,disabled:r})]}):null]})}function eh({isPending:e,progress:t,failed:n,error:r}){return(0,Q.jsxs)(Q.Fragment,{children:[e?(0,Q.jsx)(`p`,{"data-slot":`create-project-progress`,className:`flex-none truncate font-mono text-[11px] text-muted-foreground`,children:t??`Starting…`}):null,n?(0,Q.jsx)(`p`,{"data-slot":`create-project-error`,role:`alert`,className:`flex-none min-w-0 whitespace-pre-wrap break-words text-[13px] text-danger`,children:r instanceof Error?r.message:`could not create the project`}):null]})}function th({created:e,goToProject:t,isPending:n,onCancel:r,ready:i,onCreate:a,failed:o}){return(0,Q.jsx)(Yo,{className:`flex-none`,children:e?(0,Q.jsx)(E,{"data-slot":`create-project-open`,onClick:t,children:`Go to project`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{variant:`outline`,disabled:n,onClick:r,children:`Cancel`}),(0,Q.jsx)(E,{"data-slot":`create-project-submit`,disabled:!i,onClick:a,children:n?`Creating…`:o?`Try again`:`Create project`})]})})}function nh({open:e,onOpenChange:t}){let[n,r]=(0,Z.useState)(``),[i,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(`empty`),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(null),h=An(),g=ln({enabled:e}),_=Sr(),{mutate:v,isPending:y}=_,b=k(),x=(0,Z.useId)(),S=(0,Z.useRef)(!1),{checkoutId:C,progress:w,setProgress:T}=Fm(`np-`,y),{available:E,unavailableReason:D}=Wm(g),O=Gm(i,E),A=Km(s,E),j=O?l:`empty`,M=n.trim(),ee=Te.test(M),te=qm(h),N=Jm({nameValid:ee,isPending:y,created:p,github:O,chosenOwner:A,effectiveStart:j,template:d}),P=(0,Z.useCallback)(()=>{!N||S.current||(S.current=!0,T(null),v(Ym({trimmed:M,checkoutId:C,github:O,chosenOwner:A,effectiveStart:j,template:d}),{onSettled:()=>{S.current=!1},onSuccess:({project:e,warning:n})=>{if(n){m({projectId:e.id,warning:n});return}t(!1),b(`/p/${encodeURIComponent(e.id)}/`)}}))},[N,v,M,C,O,A,j,d,t,b]);return(0,Q.jsx)(ts,{open:e,onOpenChange:e=>y?void 0:t(e),children:(0,Q.jsxs)($o,{"data-slot":`create-project-dialog`,className:`flex min-w-0 flex-col overflow-y-clip overflow-x-clip sm:max-w-2xl`,children:[(0,Q.jsxs)(Qo,{className:`flex-none`,children:[(0,Q.jsx)(es,{children:`New project`}),(0,Q.jsxs)(Xo,{children:[a(`cezar`),` creates a git repository with one empty commit in your checkout root and adds it as a project.`]})]}),p?(0,Q.jsx)(`div`,{"data-slot":`create-project-warning`,role:`status`,className:`flex min-h-0 flex-1 gap-3 overflow-y-auto overscroll-contain rounded-md border border-border bg-muted p-4 text-[13px]`,children:(0,Q.jsx)(Xm,{created:p})}):(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-wrap gap-6 overflow-y-auto overscroll-contain`,children:[(0,Q.jsxs)(`div`,{className:`grid min-w-[50%] grow-[999] basis-0 content-start gap-5`,children:[(0,Q.jsx)(Zm,{fieldId:x,name:n,setName:r,trimmed:M,nameValid:ee,projectsDir:te,isPending:y,create:P}),(0,Q.jsx)(Qm,{fieldId:x,github:O,setGithubOn:o,isPending:y,available:E}),(0,Q.jsx)($m,{fieldId:x,effectiveStart:j,setStart:u,isPending:y,github:O,template:d,setTemplate:f})]}),(0,Q.jsx)(ih,{owners:E,unavailableReason:D,enabled:O&&!y,chosen:A,onChoose:c,groupName:`${x}-owner`})]}),(0,Q.jsx)(eh,{isPending:y,progress:w,failed:_.isError,error:_.error}),(0,Q.jsx)(th,{created:p,goToProject:()=>{p&&(t(!1),b(`/p/${encodeURIComponent(p.projectId)}/`))},isPending:y,onCancel:()=>t(!1),ready:N,onCreate:P,failed:_.isError})]})})}function rh({slot:e,name:t,checked:n,disabled:r,onChange:i,title:a,detail:o}){return(0,Q.jsxs)(`label`,{className:D(`flex min-h-11 items-start gap-3 rounded-md border border-border p-3`,`has-[:checked]:border-accent-strong has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-ring`,r?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,Q.jsx)(`input`,{type:`radio`,"data-slot":e,name:t,checked:n,disabled:r,onChange:i,className:`mbs-0.5 size-4 accent-[var(--color-accent-strong)]`}),(0,Q.jsxs)(`span`,{className:`grid min-w-0 gap-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] font-medium`,children:a}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o})]})]})}function ih({owners:e,unavailableReason:t,enabled:n,chosen:r,onChoose:i,groupName:a}){return(0,Q.jsxs)(`fieldset`,{"data-slot":`create-project-owners`,disabled:!n,className:`grid min-w-0 grow basis-56 content-start gap-2`,children:[(0,Q.jsx)(`legend`,{className:`mbe-2 text-sm font-medium`,children:`Repository owner`}),t===null?e===null?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(hs,{className:`h-14 w-full`}),(0,Q.jsx)(hs,{className:`h-14 w-full`})]}):e.map(e=>(0,Q.jsxs)(`label`,{"data-slot":`create-project-owner`,className:D(`flex min-h-11 min-w-0 items-center gap-3 rounded-md border border-border p-2.5`,`has-[:checked]:border-accent-strong has-[:checked]:bg-accent`,`has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-ring`,n?`cursor-pointer pointer-hover:hover:bg-accent`:`cursor-not-allowed opacity-60`),children:[(0,Q.jsx)(`input`,{type:`radio`,name:a,value:e.login,checked:r===e.login,disabled:!n,onChange:()=>i(e.login),className:`sr-only`}),e.avatarUrl?(0,Q.jsx)(`img`,{src:e.avatarUrl,alt:``,className:`size-8 shrink-0 rounded-full object-cover`}):(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-8 shrink-0 place-items-center rounded-full bg-muted text-xs font-medium uppercase`,children:e.login.slice(0,1)}),(0,Q.jsxs)(`span`,{className:`grid min-w-0`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[13px] font-medium`,children:e.login}),(0,Q.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.personal?`Personal account`:e.description??`Organization`})]})]},e.login)):(0,Q.jsxs)(`p`,{"data-slot":`create-project-github-unavailable`,className:`rounded-md border border-border bg-muted p-3 text-xs text-muted-foreground break-words`,children:[t,`. Local projects still work.`]})]})}function ah({triggerClassName:e,icon:t=Pi,iconClassName:n=`size-4`,side:r,origin:i,label:a,iconFrameClassName:o}={}){let[s,c]=Z.useState(!1),[l,u]=Z.useState(!1),[d,f]=Z.useState(!1);return(0,Q.jsxs)(Do,{children:[(0,Q.jsx)(wo,{asChild:!0,children:(0,Q.jsxs)(E,{variant:`ghost`,"aria-label":`Add project`,title:`Add project`,"data-origin":i,className:D(`size-9 p-0 text-muted-foreground`,e),children:[o?(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:o,children:(0,Q.jsx)(t,{className:n,"aria-hidden":`true`})}):(0,Q.jsx)(t,{className:n,"aria-hidden":`true`}),a?(0,Q.jsx)(`span`,{children:a}):(0,Q.jsx)(`span`,{className:`sr-only`,children:`Add project`})]})}),(0,Q.jsxs)(To,{align:`start`,...x({side:r}),className:`w-56`,children:[(0,Q.jsx)(po,{className:`text-xs text-soft-foreground`,children:`Add project`}),(0,Q.jsxs)(bo,{"data-slot":`add-project-new`,onSelect:()=>f(!0),children:[(0,Q.jsx)(Pi,{"aria-hidden":`true`}),`New project…`]}),(0,Q.jsxs)(bo,{"data-slot":`add-project-local`,onSelect:()=>c(!0),children:[(0,Q.jsx)(Di,{"aria-hidden":`true`}),`Open local folder…`]}),(0,Q.jsxs)(bo,{"data-slot":`add-project-clone`,onSelect:()=>u(!0),children:[(0,Q.jsx)(Mi,{"aria-hidden":`true`}),`Clone from GitHub…`]})]}),s?(0,Q.jsx)(Pm,{open:!0,onOpenChange:c}):null,l?(0,Q.jsx)(zm,{open:!0,onOpenChange:u}):null,d?(0,Q.jsx)(nh,{open:!0,onOpenChange:f}):null]})}function oh(e,t){return typeof t==`string`&&Object.hasOwn(e,t)?e[t]:void 0}var sh={folder:Mu,terminal:rd,vscode:_u,cursor:Gu,zed:sd,windsurf:ad,sublime:Du,idea:Cu,pycharm:Ru,webstorm:Fu,goland:ed,rubymine:Nu,phpstorm:su,clion:Su,rider:ou,"android-studio":td,xcode:Lu,warp:Zu,claude:au,codex:nd,opencode:au,pi:au,omp:au};function ch(e){return oh(sh,e.icon)??hi}function lh(e){let t=e.startsWith(`cli:`)?e.slice(4):``;return rn.options.includes(t)?t:void 0}function uh({choices:e,onPick:t,label:n=`Open in…`,title:r,triggerVariant:i=`ghost`,disabled:a=!1,leading:o,trailing:s,slot:c,className:l}){return(0,Q.jsxs)(Do,{children:[(0,Q.jsx)(wo,{asChild:!0,children:(0,Q.jsxs)(E,{variant:i,size:`sm`,title:r,disabled:a,"data-slot":c,className:l,children:[(0,Q.jsx)(hi,{"aria-hidden":`true`}),n]})}),(0,Q.jsxs)(To,{align:`end`,children:[o,o&&e.length>0?(0,Q.jsx)(xo,{}):null,e.map(({target:e,suffix:n,title:r})=>{let i=ch(e);return(0,Q.jsxs)(bo,{"data-target":e.id,title:r,onSelect:()=>t(e.id),children:[(0,Q.jsx)(i,{"aria-hidden":`true`}),e.label,n??``]},e.id)}),s]})]})}var dh=[`done`,`failed`,`cancelled`];function fh(e){return dh.includes(e)}function ph(e){return!Et(e)&&fh(e.status)&&!Zr(e)}function mh(e){return e.reduce((e,t)=>zr(t)||!Zr(t)?e:e+1,0)}function hh(e){return e.status===`failed`?`danger`:`success`}var gh={needsYou:0,failedUnread:0,inMotion:0,finishedUnread:0};function _h(e){let t={...gh};for(let n of e)n.archived||zr(n)||(ke(n)?t.needsYou+=1:xe(n).tone===`running`?t.inMotion+=1:Zr(n)&&(n.status===`failed`?t.failedUnread+=1:n.status===`done`&&(t.finishedUnread+=1)));return t}function vh(e){let t=new Map;for(let n of e){let e=t.get(n.projectId);e?e.push(n):t.set(n.projectId,[n])}return new Map([...t].map(([e,t])=>[e,_h(t)]))}function yh(e,t,n={}){if(n.unknown)return`${e} · activity unknown`;let r=bh(t).map(e=>e.text);return[e,r.length>0?r.join(` · `):`idle`].join(` · `)}function bh(e){let{needsYou:t,failedUnread:n,inMotion:r,finishedUnread:i}=e??gh,a=[];return t>0&&a.push({tone:`amber`,text:`${t} needs you`}),n>0&&a.push({tone:`red`,text:`${n} failed`}),r>0&&a.push({tone:`violet`,text:`${r} working`}),i>0&&a.push({tone:`green`,text:`${i} finished`}),a}function xh(e){let t={...gh};for(let n of e)n&&(t.needsYou+=n.needsYou,t.failedUnread+=n.failedUnread,t.inMotion+=n.inMotion,t.finishedUnread+=n.finishedUnread);return t}function Sh(e){let t=e.split(/[-_ .]+/).filter(e=>e!==``);return(t.length>=2?[t[0],t[1]].map(e=>[...e][0]):[...t[0]??``].slice(0,2)).join(``).toLowerCase()}var Ch=`w-[228px] rounded-[10px] border-border bg-sidebar p-[5px] text-foreground shadow-[0_10px_28px_#00000047] motion-reduce:animate-none`,wh=`h-8 gap-2.5 rounded-[6px] px-[9px] py-0 text-[13px] focus:bg-sidebar-row-hover focus:text-foreground [&_svg]:size-[15px] [&_svg]:text-soft-foreground focus:[&_svg]:text-foreground max-md:min-h-11`;function Th(){let e=Cs(),t=On(),n=An(),r=n.data?.bootProject??t.data?.bootProject,i=e??r??null,a=n.data?.projects.find(e=>e.id===i),o=i===r?t.data?.repo:void 0,s=a?.root??o?.root;return{health:t,registry:n,projectId:i,project:a,root:s,name:a?.name??s?.split(/[\\/]/).filter(Boolean).at(-1),branch:o?.branch??a?.branch}}function Eh({onNavigate:e}={}){let t=(0,Z.useRef)(null),n=(0,Z.useRef)(null),[r,i]=(0,Z.useState)(0),{health:a,registry:o,projectId:s,root:c,name:l,branch:u}=Th(),d=a.data?.capabilities.localHandoff===!0,f=l??(o.isPending?`Loading project…`:`Project unavailable`),p=[d?c:void 0,u].filter(Boolean).join(` · `);return(0,Q.jsxs)(`div`,{"data-slot":`project-header`,className:`flex min-w-0 items-center gap-2.5 px-[14px] pt-[14px] pb-2.5`,children:[(0,Q.jsx)(`span`,{ref:t,"aria-hidden":`true`,"data-slot":`project-header-mark`,className:`flex size-7 shrink-0 items-center justify-center rounded-[7px] border border-soft-foreground bg-sidebar-row-selected text-[11px] leading-none font-semibold text-foreground`,children:l?Sh(l):`…`}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-px`,children:[(0,Q.jsx)(`div`,{"data-slot":`project-header-name`,className:`truncate text-[14px] font-semibold text-foreground`,title:f,children:f}),(0,Q.jsx)(`div`,{"data-slot":`project-header-detail`,dir:`rtl`,className:`truncate text-left font-mono text-[10.5px] text-soft-foreground`,title:p||void 0,children:(0,Q.jsx)(`bdi`,{dir:`ltr`,children:p||(o.isPending?`Loading…`:`Branch unavailable`)})})]}),(0,Q.jsx)(jh,{projectId:s,onNavigate:e,triggerRef:n,triggerClassName:`size-7 max-md:size-11`,align:`start`,alignOffset:r,onOpenChange:e=>{e&&t.current&&n.current&&i(t.current.getBoundingClientRect().left-n.current.getBoundingClientRect().left)}})]})}function Dh(e,t,n){let r=e.data?.bootProject??t.data?.bootProject,i=e.data?.projects.find(e=>e.id===n),a=n===r?t.data?.repo:void 0;return{bootId:r,project:i,root:i?.root??a?.root}}function Oh({marking:e,runs:t,unread:n,projectId:r}){return e||t.isError||t.data===void 0||n.length===0||r===null}function kh({marking:e,runs:t,unread:n}){return e?`Marking…`:t.isError?`Unavailable`:t.data===void 0?`Loading…`:`${n.length} unread`}function Ah(e,t){return!e||t?.status===`missing`}function jh({projectId:e,onNavigate:t,triggerRef:n,triggerClassName:r,align:i=`start`,alignOffset:a,side:o,onOpenChange:s}){let c=gd(),l=On(),u=An(),[d,f]=(0,Z.useState)(!1),{bootId:p,project:m,root:h}=Dh(u,l,e),g=Vn(e??`default`,e!==null,e===p),_=Cn(Bn({projectId:e??`default`,boot:e===p})),v=(0,Z.useRef)(e);v.current=e;let y=l.data?.capabilities.localHandoff===!0,b=(g.data??[]).filter(e=>!zr(e)&&Zr(e));async function S(){f(!0);let t=0;try{for(let n of b){if(v.current!==e)break;try{await _.mutateAsync(n.id)}catch{t+=1}}t>0&&G(`Could not mark ${t} task${t===1?``:`s`} read. Try again.`,{tone:`danger`})}finally{f(!1)}}async function C(){if(h)try{await navigator.clipboard.writeText(h),G(`Project folder copied`)}catch{G(`Could not copy path: ${h}`,{tone:`danger`})}}return(0,Q.jsxs)(Do,{...x({onOpenChange:s}),children:[(0,Q.jsx)(wo,{asChild:!0,children:(0,Q.jsx)(`button`,{"data-slot":`project-menu-trigger`,ref:n,type:`button`,"aria-label":`Project menu`,className:D(`flex shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring data-[state=open]:bg-sidebar-row-selected data-[state=open]:text-foreground`,r),children:(0,Q.jsx)(Tu,{"aria-hidden":`true`,className:`size-[15px]`})})}),(0,Q.jsxs)(To,{align:i,...x({alignOffset:a,side:o}),sideOffset:4,className:Ch,children:[(0,Q.jsxs)(bo,{className:wh,disabled:Oh({marking:d,runs:g,unread:b,projectId:e}),onSelect:()=>{S()},children:[(0,Q.jsx)(lu,{"aria-hidden":`true`}),` Mark all read`,(0,Q.jsx)(`span`,{className:`ml-auto text-[11.5px] text-soft-foreground`,children:kh({marking:d,runs:g,unread:b})})]}),(0,Q.jsx)(xo,{className:`mx-0`}),y&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Mh,{projectId:e??`default`,disabled:Ah(h,m)}),(0,Q.jsxs)(bo,{className:wh,disabled:!h,onSelect:()=>{C()},children:[(0,Q.jsx)(bu,{"aria-hidden":`true`}),` Copy path`]}),(0,Q.jsx)(xo,{className:`mx-0`})]}),(0,Q.jsx)(bo,{asChild:!0,className:wh,children:(0,Q.jsxs)(Y,{to:`/settings`,onClick:t??c,children:[(0,Q.jsx)($u,{"aria-hidden":`true`}),` Project settings`]})})]})]})}function Mh({disabled:e,projectId:t}){let n=In(),r=jn({mutationFn:e=>_e(e,t),onError:e=>G(e.message,{tone:`danger`}),onSuccess:()=>G(`Opening project folder`)}),i=(n.data?.targets??[]).filter(e=>lh(e.id)===void 0);return(0,Q.jsxs)(Oo,{children:[(0,Q.jsxs)(_o,{className:wh,disabled:e||r.isPending,children:[(0,Q.jsx)(hi,{"aria-hidden":`true`}),` Open in`]}),(0,Q.jsx)(Co,{children:(0,Q.jsxs)(go,{className:Ch,children:[i.map(e=>{let t=ch(e);return(0,Q.jsxs)(bo,{className:wh,"data-target":e.id,onSelect:()=>r.mutate(e.id),children:[(0,Q.jsx)(t,{"aria-hidden":`true`}),e.label]},e.id)}),i.length===0&&(0,Q.jsx)(bo,{className:wh,disabled:!0,children:n.isError?`Apps unavailable`:n.isPending?`Loading apps…`:`No apps available`})]})})]})}var Nh={amber:`text-signal-word-amber`,red:`text-signal-word-red`,violet:`text-status-running`,green:`text-success`};function Ph({signal:e,known:t,current:n,maxParts:r,slot:i,className:a}){let o=bh(e).slice(0,r);return(0,Q.jsx)(`span`,{"data-slot":i,className:D(`flex min-w-0 items-center font-medium`,n?`text-muted-foreground`:`text-soft-foreground`,a),children:t?o.length===0?`idle`:o.map((e,t)=>(0,Q.jsxs)(`span`,{className:`flex items-center gap-x-[inherit]`,children:[t>0?(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}):null,(0,Q.jsx)(`span`,{"data-tone":e.tone,className:Nh[e.tone],children:e.text})]},e.tone)):`activity unknown`})}var Fh=m(`inline-block shrink-0`,{variants:{tone:{success:``,pending:``,danger:``,accent:``,info:``,running:``,neutral:``},shape:{filled:`size-[7px] rounded-full`,ring:`size-[7px] rounded-full border-[1.5px] bg-transparent`,workers:`inline-flex size-[12px] items-center justify-center`},pulse:{true:`animate-pulse motion-reduce:animate-none`,false:``}},compoundVariants:[{shape:`filled`,tone:`success`,className:`bg-success`},{shape:`filled`,tone:`pending`,className:`bg-pending-strong`},{shape:`filled`,tone:`danger`,className:`bg-danger`},{shape:`filled`,tone:`accent`,className:`bg-accent-strong`},{shape:`filled`,tone:`info`,className:`bg-info`},{shape:`filled`,tone:`running`,className:`bg-status-running`},{shape:`filled`,tone:`neutral`,className:`bg-soft-foreground`},{shape:`ring`,tone:`success`,className:`border-success`},{shape:`ring`,tone:`pending`,className:`border-pending-strong`},{shape:`ring`,tone:`danger`,className:`border-danger`},{shape:`ring`,tone:`accent`,className:`border-accent-strong`},{shape:`ring`,tone:`info`,className:`border-info`},{shape:`ring`,tone:`running`,className:`border-status-running`},{shape:`ring`,tone:`neutral`,className:`border-soft-foreground`},{shape:`workers`,tone:`success`,className:`text-success`},{shape:`workers`,tone:`pending`,className:`text-pending-strong`},{shape:`workers`,tone:`danger`,className:`text-danger`},{shape:`workers`,tone:`accent`,className:`text-accent-icon`},{shape:`workers`,tone:`info`,className:`text-info`},{shape:`workers`,tone:`running`,className:`text-status-running`},{shape:`workers`,tone:`neutral`,className:`text-soft-foreground`}],defaultVariants:{tone:`neutral`,shape:`filled`,pulse:!1}});function $({className:e,tone:t=`neutral`,shape:n=`filled`,pulse:r=!1,...i}){return(0,Q.jsx)(`span`,{"data-slot":`status-dot`,"data-tone":t,"data-shape":n,"data-pulse":r?`true`:void 0,className:D(Fh({tone:t,shape:n,pulse:r,className:e})),...i,children:n===`workers`?(0,Q.jsx)(au,{className:`size-[12px]`,"aria-hidden":`true`}):null})}function Ih(e,t){let n=e=>e.split(`.`).slice(0,3).map(e=>Number.parseInt(e,10)||0),r=n(e),i=n(t);for(let e=0;e<3;e++){let t=(r[e]??0)-(i[e]??0);if(t!==0)return t>0}return!1}var Lh={amber:`bg-pending text-signal-ink-amber`,red:`bg-danger text-signal-ink`,violet:`bg-status-running text-signal-ink`,green:`bg-success text-signal-ink`};function Rh(e,t,n){return e>9&&!(n&&t>1)?22:t===1?18:14}function zh({position:e,segments:t,className:n,compact:r=!1}){let i=t.filter(e=>e.count>0);return i.length===0?null:(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`rail-pill-${e}`,className:D(`pointer-events-none absolute -right-[4px] box-border flex h-[17px] overflow-hidden rounded-[9px] border-2 border-background`,e===`top`?`-top-[6px]`:`top-[25px]`,n),children:i.map(({tone:e,count:t})=>(0,Q.jsx)(`span`,{"data-segment":e,"data-count":t,style:{width:Rh(t,i.length,r)},className:D(`flex items-center justify-center text-[10px] leading-[13px] font-bold tabular-nums`,Lh[e]),children:t>9?`9+`:t},e))})}function Bh(e){return{top:[{tone:`amber`,count:e?.needsYou??0},{tone:`red`,count:e?.failedUnread??0}],bottom:[{tone:`violet`,count:e?.inMotion??0},{tone:`green`,count:e?.finishedUnread??0}]}}var Vh=`cez-theme`,Hh=`(prefers-color-scheme: light)`,Uh=`dark`;function Wh(e){return e===`light`||e===`dark`||e===`system`?e:Uh}function Gh(e,t){return e===`light`||e===`system`&&t?`light`:`dark`}function Kh(){try{return Wh(localStorage.getItem(Vh))}catch{return Uh}}function qh(e){try{localStorage.setItem(Vh,e)}catch{}}function Jh(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(Hh).matches}function Yh(e,t){e.classList.toggle(`light`,t===`light`),e.style.colorScheme=t}function Xh(e){return`/cezarion-mark-${e}.svg`}function Zh(e){let t=document.querySelector(`link[rel="icon"]`);t&&(t.href=Xh(e))}var Qh=Z.createContext(null);function $h({children:e}){let[t,n]=Z.useState(Kh),[r,i]=Z.useState(Jh);Z.useEffect(()=>{let e=window.matchMedia?.(Hh);if(!e)return;i(e.matches);let t=e=>i(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let a=Gh(t,r);Z.useLayoutEffect(()=>{Yh(document.documentElement,a),Zh(a)},[a]);let o=Z.useCallback(e=>{n(e),qh(e)},[]),s=Z.useMemo(()=>({theme:t,resolvedTheme:a,setTheme:o}),[t,a,o]);return(0,Q.jsx)(Qh.Provider,{value:s,children:e})}function eg(){let e=Z.useContext(Qh);if(!e)throw Error(`${a(`cezar`)}: useTheme() must be called inside <ThemeProvider>`);return e}var tg={light:`dark`,dark:`system`,system:`light`},ng={light:`light`,dark:`dark`,system:`system`};function rg({className:e,showLabel:t=!1,labelClassName:n}){let{theme:r,setTheme:i}=eg(),a=tg[r],o=Wi;return(0,Q.jsxs)(E,{type:`button`,variant:`ghost`,size:`icon-sm`,className:e,"data-slot":`theme-toggle`,"data-theme-pref":r,title:`Theme: ${ng[r]}`,"aria-label":`Theme: ${ng[r]}. Switch to ${ng[a]}.`,onClick:()=>i(a),children:[(0,Q.jsx)(o,{"aria-hidden":`true`}),t?(0,Q.jsxs)(`span`,{className:n,children:[`Theme · `,r.charAt(0).toUpperCase()+r.slice(1)]}):null]})}function ig({...e}){return(0,Q.jsx)(zo,{"data-slot":`sheet`,...e})}function ag({...e}){return(0,Q.jsx)(Io,{"data-slot":`sheet-trigger`,...e})}function og({...e}){return(0,Q.jsx)(qo,{"data-slot":`sheet-close`,...e})}function sg({...e}){return(0,Q.jsx)(Bo,{"data-slot":`sheet-portal`,...e})}function cg({className:e,...t}){return(0,Q.jsx)(Uo,{"data-slot":`sheet-overlay`,className:D(`fixed inset-0 z-50 bg-black/50 motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function lg({className:e,children:t,side:n=`right`,showCloseButton:r=!0,overlayClassName:i,...a}){return(0,Q.jsxs)(sg,{children:[(0,Q.jsx)(cg,{className:i}),(0,Q.jsxs)(Po,{"data-slot":`sheet-content`,className:D(`fixed z-50 flex flex-col gap-4 bg-background shadow-modal transition-colors ease-in-out motion-safe:data-[state=closed]:animate-out data-[state=closed]:duration-300 motion-safe:data-[state=open]:animate-in data-[state=open]:duration-500`,n===`right`&&`inset-y-0 end-0 h-full w-3/4 border-s motion-safe:data-[state=closed]:slide-out-to-right motion-safe:data-[state=open]:slide-in-from-right sm:max-w-sm`,n===`left`&&`inset-y-0 start-0 h-full w-3/4 border-e motion-safe:data-[state=closed]:slide-out-to-left motion-safe:data-[state=open]:slide-in-from-left sm:max-w-sm`,n===`top`&&`inset-x-0 inset-bs-0 h-auto border-be motion-safe:data-[state=closed]:slide-out-to-top motion-safe:data-[state=open]:slide-in-from-top`,n===`bottom`&&`inset-x-0 inset-be-0 h-auto border-bs motion-safe:data-[state=closed]:slide-out-to-bottom motion-safe:data-[state=open]:slide-in-from-bottom`,e),...a,children:[t,r&&(0,Q.jsxs)(qo,{className:`absolute inset-bs-4 end-4 rounded-sm opacity-70 ring-offset-background transition-opacity pointer-hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-secondary`,children:[(0,Q.jsx)(oa,{className:`size-4`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function ug({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`sheet-header`,className:D(`flex flex-col gap-1.5 p-4`,e),...t})}function dg({className:e,...t}){return(0,Q.jsx)(Lo,{"data-slot":`sheet-title`,className:D(`font-semibold text-foreground`,e),...t})}function fg({className:e,...t}){return(0,Q.jsx)(Fo,{"data-slot":`sheet-description`,className:D(`text-sm text-muted-foreground`,e),...t})}function pg(e,t){if(!e?.signals)return null;let n=e.signals;return xh(e.projects.filter(e=>e.id!==t).map(e=>n.get(e.id)))}function mg(e){let t=bh(e??void 0).map(e=>e.text);return t.length>0?`Open projects. Elsewhere: ${t.join(`, `)}`:`Open projects`}function hg({elsewhere:e}){if(!e)return null;let{top:t,bottom:n}=Bh(e),r=`right-[2px] border-card`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(zh,{position:`top`,segments:t,compact:!0,className:D(r,`top-[3px]`)}),(0,Q.jsx)(zh,{position:`bottom`,segments:n,compact:!0,className:D(r,`top-[24px]`)})]})}function gg({version:e,latestVersion:t=null}){let{resolvedTheme:n}=eg(),r=!!(e&&t&&Ih(t,e));return(0,Q.jsxs)(`div`,{"data-slot":`drawer-identity`,className:`flex shrink-0 items-center gap-[12px] border-b border-border pt-[env(safe-area-inset-top)] pr-[14px] pb-[14px] pl-[18px]`,children:[(0,Q.jsx)(`img`,{src:`/cezarion-mark-${n}.svg`,alt:``,"aria-hidden":`true`,className:`mt-[14px] size-[32px] rounded-lg`}),(0,Q.jsx)(`span`,{"data-slot":`drawer-wordmark`,className:`mt-[14px] text-[18px] leading-none font-bold tracking-[-0.02em] text-foreground`,children:a(`Cezarion`)}),e?(0,Q.jsxs)(`span`,{"data-slot":`drawer-version`,"data-update-available":r?`true`:void 0,title:r?`v${e} — update available: v${t}`:`v${e}`,className:`mt-[14px] min-w-0 truncate text-[11px] leading-none text-soft-foreground`,children:[r?(0,Q.jsx)($,{tone:`pending`,className:`mr-1 inline-block size-[5px] align-middle`}):null,`v`,e]}):null,(0,Q.jsx)(og,{asChild:!0,children:(0,Q.jsx)(E,{variant:`ghost`,size:`icon`,"aria-label":`Close menu`,className:`mt-[14px] ml-auto size-[44px] text-foreground`,children:(0,Q.jsx)(oa,{className:`size-[19px]`,"aria-hidden":`true`})})})]})}function _g({project:e,signal:t,known:n,current:r,onNavigate:i}){let{top:a,bottom:o}=Bh(t),s=r?`border-sidebar-row-selected`:`border-sidebar`,c=`right-[-4px]`,l=(0,Q.jsxs)(C,{to:gs(e.id,`/`),onClick:i,"data-slot":`drawer-project`,"data-project-id":e.id,"aria-current":r?`page`:void 0,className:D(`flex h-[64px] min-w-0 items-center gap-[12px] rounded-[10px] px-[10px] text-foreground hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,r&&`flex-1 hover:bg-sidebar-row-selected`),children:[(0,Q.jsxs)(`span`,{"aria-hidden":`true`,className:D(`relative flex size-[40px] shrink-0 items-center justify-center rounded-[10px] border text-[13px] leading-none font-semibold`,r?`border-soft-foreground bg-sidebar text-foreground`:`border-transparent bg-muted text-muted-foreground`),children:[Sh(e.name),(0,Q.jsx)(zh,{position:`top`,segments:a,className:D(c,s)}),(0,Q.jsx)(zh,{position:`bottom`,segments:o,className:D(c,s,`top-[29px]`)})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[14.5px] leading-tight font-semibold`,children:e.name}),(0,Q.jsx)(Ph,{signal:t,known:n,current:r,slot:`drawer-project-state`,className:`flex-wrap gap-x-[6px] text-[11.5px] leading-tight`})]}),r?(0,Q.jsx)(ia,{"aria-hidden":`true`,className:`size-[16px] shrink-0 text-foreground`}):null]});return r?(0,Q.jsxs)(`div`,{"data-slot":`drawer-project-current`,className:`flex items-center rounded-[10px] bg-sidebar-row-selected pr-[4px]`,children:[l,(0,Q.jsx)(jh,{projectId:e.id,onNavigate:i,triggerClassName:`size-[44px]`,align:`end`})]}):l}var vg=`flex h-[48px] w-full items-center gap-[12px] rounded-[10px] px-[10px] text-[14.5px] font-normal text-foreground hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring [&_svg]:size-[18px] [&_svg]:shrink-0 [&_svg]:text-soft-foreground`;function yg({nav:e,currentProjectId:t,onNavigate:n}){return(0,Q.jsxs)(`div`,{"data-slot":`drawer-projects`,className:`shrink-0`,children:[(0,Q.jsx)(`div`,{className:`px-[18px] pt-[14px] pb-[6px] text-[12px] font-medium text-soft-foreground`,id:`drawer-projects-label`,children:`Projects`}),(0,Q.jsx)(`div`,{role:`group`,"data-slot":`drawer-projects-group`,"aria-labelledby":`drawer-projects-label`,className:`flex flex-col gap-[2px] px-[8px] pb-[8px]`,children:e.projects.map(r=>(0,Q.jsx)(_g,{project:r,signal:e.signals?.get(r.id),known:e.signals!==null,current:r.id===t,onNavigate:n},r.id))}),(0,Q.jsxs)(`div`,{"data-slot":`drawer-workspace`,className:`flex flex-col gap-[2px] border-t border-border px-[8px] py-[8px]`,children:[(0,Q.jsxs)(C,{to:`/tasks`,onClick:n,"data-slot":`drawer-all-projects`,className:vg,children:[(0,Q.jsx)(Ti,{"aria-hidden":`true`}),`All projects · task overview`]}),(0,Q.jsx)(ah,{origin:`mobile`,icon:Pi,iconClassName:`size-[18px]`,label:`Add project`,triggerClassName:D(vg,`h-[48px] justify-start p-0 px-[10px] text-foreground`)})]})]})}function bg({onNavigate:e,tools:t}){let{theme:n,setTheme:r}=eg(),i=tg[n],a=n.charAt(0).toUpperCase()+n.slice(1);return(0,Q.jsxs)(`div`,{"data-slot":`drawer-global`,className:`flex shrink-0 flex-col gap-[2px] border-t border-border px-[8px] pt-[8px] pb-[max(8px,env(safe-area-inset-bottom))]`,children:[t?(0,Q.jsxs)(C,{to:`/tools`,onClick:e,"data-slot":`drawer-tools`,"aria-label":t.blocked?`Tools, needs setup`:void 0,"aria-describedby":t.blocked&&t.note?`drawer-tools-note`:void 0,className:D(vg,t.note&&`h-auto min-h-[48px] py-[6px]`),children:[(0,Q.jsxs)(`span`,{className:`relative flex shrink-0`,children:[(0,Q.jsx)(ua,{"aria-hidden":`true`}),t.blocked?(0,Q.jsx)($,{tone:`pending`,"data-slot":`drawer-tools-dot`,className:`absolute -top-[2px] -right-[3px] ring-[1.5px] ring-sidebar`}):null]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsx)(`span`,{children:`Tools`}),t.note?(0,Q.jsx)(`span`,{id:`drawer-tools-note`,"data-slot":`drawer-tools-note`,className:`text-[11.5px] leading-tight text-soft-foreground`,children:t.note}):null]})]}):null,(0,Q.jsxs)(C,{to:`/settings/global/appearance`,onClick:e,"data-slot":`drawer-global-settings`,className:vg,children:[(0,Q.jsx)(Ci,{"aria-hidden":`true`}),`Global settings`]}),(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`theme-toggle`,"data-theme-pref":n,"aria-label":`Theme: ${n.toLowerCase()}. Switch to ${i}.`,onClick:()=>r(i),className:vg,children:[(0,Q.jsx)(Wi,{"aria-hidden":`true`}),`Theme · `,a]})]})}function xg(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable?!0:e.closest(`[contenteditable=""], [contenteditable="true"]`)!==null}function Sg(e){return e instanceof HTMLElement&&e.closest(`[cmdk-input]`)!==null}function Cg(e,t){return!(typeof e.key!=`string`||e.key.toLowerCase()!==t.toLowerCase()||!e.metaKey&&!e.ctrlKey||e.altKey||e.shiftKey||e.repeat||xg(e.target)&&!Sg(e.target))}function wg(e,t){let n=Z.useRef(t);Z.useLayoutEffect(()=>{n.current=t}),Z.useEffect(()=>{let t=t=>{Cg(t,e)&&(t.preventDefault(),n.current(t))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}function Tg(e,t){return!(typeof e.key!=`string`||e.key.toLowerCase()!==t.toLowerCase()||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||e.repeat||xg(e.target))}function Eg(e,t=typeof navigator>`u`?``:navigator.platform){let n=e.toUpperCase();return/mac|iphone|ipad|ipod/i.test(t)?`⌘${n}`:`Ctrl+${n}`}function Dg(e,t){let n=Z.useRef(t);Z.useLayoutEffect(()=>{n.current=t}),Z.useEffect(()=>{let t=t=>{Tg(t,e)&&n.current(t)};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}var Og=Z.createContext(null);function kg(){return Z.useContext(Og)}function Ag({slot:e,children:t}){return(0,zd.createPortal)(t,e)}var jg=`(min-width: 768px)`;function Mg(){let[e,t]=Z.useState(()=>window.matchMedia?.(jg).matches??!0);return Z.useEffect(()=>{let e=window.matchMedia?.(jg);if(!e)return;let n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function Ng({delayDuration:e=0,...t}){return(0,Q.jsx)(bm,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Pg({...e}){return(0,Q.jsx)(xm,{"data-slot":`tooltip`,...e})}function Fg({...e}){return(0,Q.jsx)(Sm,{"data-slot":`tooltip-trigger`,...e})}function Ig({className:e,sideOffset:t=0,children:n,...r}){return(0,Q.jsx)(Cm,{children:(0,Q.jsxs)(wm,{"data-slot":`tooltip-content`,sideOffset:t,className:D(`z-50 w-fit origin-(--radix-tooltip-content-transform-origin) motion-safe:animate-in rounded-md bg-contrast px-3 py-1.5 text-xs text-balance text-contrast-foreground fade-in-0 motion-safe:zoom-in-95 motion-safe:data-[side=bottom]:slide-in-from-top-2 motion-safe:data-[side=left]:slide-in-from-right-2 motion-safe:data-[side=right]:slide-in-from-left-2 motion-safe:data-[side=top]:slide-in-from-bottom-2 motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:zoom-out-95`,e),...r,children:[n,(0,Q.jsx)(Tm,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-contrast fill-contrast`})]})})}var Lg=[`/git`,`/automations`,`/workflows`,`/reports`];function Rg({items:e,activeTo:t,needsYou:n=!1,onNavigate:r}){let[i,a]=(0,Z.useState)(!1),o=(0,Z.useRef)(null),s=e.filter(e=>Lg.includes(e.to)),c=e.filter(e=>!s.includes(e)),l=s.some(e=>e.to===t);return(0,Q.jsx)(Ng,{children:(0,Q.jsxs)(`nav`,{ref:o,"aria-label":`Main`,"data-slot":`view-tabs`,onKeyDown:e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;let t=Array.from(o.current?.querySelectorAll(`[data-view-tab]`)??[]),n=t.indexOf(document.activeElement);n<0||(e.preventDefault(),t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowRight`?1:-1)+t.length)%t.length]?.focus())},className:`flex shrink-0 items-center justify-between max-md:justify-start max-md:gap-1 max-md:overflow-x-auto border-b border-border px-3 pt-2.5 pb-2`,children:[c.map(e=>{let i=e.to===t,a=e.icon,o=e.to===`/`&&n&&!i;return(0,Q.jsxs)(Pg,{children:[(0,Q.jsx)(Fg,{asChild:!0,children:(0,Q.jsxs)(Y,{to:e.to,onClick:r,"data-view-tab":!0,"aria-label":e.label,"aria-current":i?`page`:void 0,className:D(`relative flex h-[30px] min-w-0 items-center justify-center rounded-[7px] text-soft-foreground hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 max-md:min-w-11`,i?`shrink-0 gap-1.5 bg-sidebar-row-selected px-[9px] text-[12px] font-semibold text-foreground`:`w-7 shrink-0`),children:[(0,Q.jsxs)(`span`,{className:`relative`,children:[(0,Q.jsx)(a,{className:`size-[15px] shrink-0`,"aria-hidden":`true`}),o?(0,Q.jsx)(`span`,{"aria-label":`Tasks need you`,"data-slot":`nav-needs-you-dot`,className:`absolute -top-1 -right-1 size-[7px] rounded-full border-[1.5px] border-sidebar bg-pending-strong`}):null]}),i?(0,Q.jsx)(`span`,{className:`truncate`,children:e.label}):null]})}),(0,Q.jsx)(Ig,{side:`bottom`,sideOffset:6,style:{pointerEvents:`none`},children:e.label})]},e.to)}),s.length?(0,Q.jsxs)(Do,{open:i,onOpenChange:a,children:[(0,Q.jsxs)(Pg,{children:[(0,Q.jsx)(Fg,{asChild:!0,children:(0,Q.jsx)(wo,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"data-view-tab":!0,"aria-label":`More views`,"data-active":l?`true`:void 0,className:D(`relative flex h-[30px] w-7 shrink-0 items-center justify-center rounded-[7px] text-soft-foreground hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 max-md:min-w-11`,(i||l)&&`bg-sidebar-row-selected text-foreground`),children:(0,Q.jsx)(Tu,{className:`size-[15px]`,"aria-hidden":`true`})})})}),(0,Q.jsx)(Ig,{side:`bottom`,sideOffset:6,style:{pointerEvents:`none`},children:`More views`})]}),(0,Q.jsx)(To,{align:`end`,sideOffset:4,className:`w-48 rounded-[10px] border-border bg-sidebar p-[5px] shadow-[0_10px_28px_#00000047]`,children:s.map(e=>{let n=e.icon,i=e.to===t;return(0,Q.jsx)(bo,{asChild:!0,className:D(`h-8 max-md:min-h-11 gap-2.5 rounded-md px-[9px] text-[13px] text-foreground focus:bg-sidebar-row-hover`,i&&`bg-sidebar-row-selected font-medium`),children:(0,Q.jsxs)(Y,{to:e.to,onClick:r,"aria-current":i?`page`:void 0,children:[(0,Q.jsx)(n,{className:`size-[15px] text-soft-foreground`}),e.label]})},e.to)})})]}):null]})})}var zg=[{to:`/`,label:`Tasks`,icon:Ri,match:[`/`,`/tasks`],badge:`tasks-unread`},{to:`/activity`,label:`Activity`,icon:ru,match:[`/activity`]},{to:`/git`,label:`Git`,icon:na,match:[`/git`]},{to:`/github`,label:`GitHub`,icon:Mi,match:[`/github`],forge:!0},{to:`/automations`,label:`Automations`,icon:$i,match:[`/automations`],automations:!0},{to:`/skills`,label:`Skills`,icon:pa,match:[`/skills`]},{to:`/workflows`,label:`Workflows`,icon:Zi,match:[`/workflows`]},{to:`/reports`,label:`Reports`,icon:ku,match:[`/reports`]},{to:`/settings`,label:`Settings`,icon:Yi,match:[`/settings`]}];function Bg({forge:e=!1,automations:t=!1}={}){return zg.filter(n=>(!n.forge||e)&&(!n.automations||t))}function Vg(e,t){return t===`/`?e===`/`:e===t||e.startsWith(t+`/`)}function Hg(e){let t=null;for(let n of zg)for(let r of n.match)Vg(e,r)&&(t===null||r.length>t.length)&&(t={to:n.to,length:r.length});return t?.to??null}function Ug(e){let t=Hg(e);return zg.find(e=>e.to===t)??null}function Wg(e){return/^\/tasks\/[^/]+(?:\/|$)/.test(xs(e))}function Gg(e,t){let n=xs(e);return/^\/git\/?$/.test(n)?new URLSearchParams(t).get(`view`)===`repo`:n.startsWith(`/git/`)}var Kg=[`/`,`/activity`,`/github`],qg=[`/git`,`/skills`,`/workflows`,`/reports`,`/settings`,`/automations`];function Jg(e,t,n){let r=xs(e),i=r===`/new`,a=Wg(e);return{activeTo:i?`/new`:Hg(r),current:Ug(r),currentProjectId:vs(e),newTask:i,pushed:a,showTabBar:!a&&!Gg(e,t)&&!n,gitRepositoryView:r===`/git`&&new URLSearchParams(t).get(`view`)===`repo`}}var Yg=[{to:`/git`,label:`Git`},{to:`/skills`,label:`Skills`},{to:`/workflows`,label:`Workflows`},{to:`/reports`,label:`Reports`},{to:`/settings`,label:`Project settings`}],Xg=[`/automations`],Zg=`flex h-[50px] min-h-11 w-full items-center gap-[14px] rounded-[10px] px-[10px] text-[14.5px] text-foreground hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:outline-ring [&_svg]:size-[18px] [&_svg]:shrink-0 [&_svg]:text-muted-foreground`;function Qg({open:e,onOpenChange:t,onCloseAutoFocus:n,projectName:r,items:i,activeTo:a}){let o=new Map(i.map(e=>[e.to,e])),s=Yg.flatMap(({to:e,label:t})=>{let n=o.get(e);return n?[{to:e,label:t,icon:n.icon}]:[]}),c=Xg.flatMap(e=>{let t=o.get(e);return t?[{to:e,label:t.label,icon:t.icon}]:[]}),l=()=>t(!1),u=({to:e,label:t,icon:n})=>{let r=e===a;return(0,Q.jsxs)(Y,{to:e,onClick:l,"data-slot":`more-row`,"data-more-row":e,"aria-current":r?`page`:void 0,className:D(Zg,r&&`bg-sidebar-row-selected hover:bg-sidebar-row-selected`),children:[(0,Q.jsx)(n,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),(0,Q.jsx)(Ji,{"aria-hidden":`true`,className:`!size-[15px]`})]},e)};return(0,Q.jsx)(ig,{open:e,onOpenChange:t,children:(0,Q.jsxs)(lg,{side:`bottom`,"data-slot":`more-sheet`,showCloseButton:!1,onCloseAutoFocus:n,"aria-describedby":void 0,className:`gap-0 rounded-t-[20px] border-border bg-sidebar px-[14px] pt-[10px] pb-[max(14px,env(safe-area-inset-bottom))] md:hidden`,children:[(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:`mx-auto mb-[14px] h-[5px] w-[36px] rounded-[3px] bg-border`}),(0,Q.jsxs)(`div`,{className:`flex items-baseline gap-[10px] px-[10px] pb-[6px]`,children:[(0,Q.jsx)(dg,{className:`text-[17px] leading-tight font-bold`,children:`More`}),r?(0,Q.jsx)(`span`,{"data-slot":`more-project`,className:`min-w-0 truncate text-[12.5px] text-soft-foreground`,children:r}):null]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-[2px]`,children:s.map(u)}),c.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{role:`separator`,className:`mx-[10px] mt-[8px] border-t border-border`}),(0,Q.jsx)(`div`,{className:`px-[10px] pt-[12px] pb-[4px] text-[12px] font-medium text-soft-foreground`,children:`Shown when their flag is on`}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-[2px]`,children:c.map(u)})]}):null]})})}var $g=`(min-width: 768px)`;function e_({items:e,activeTo:n,signal:r,projectName:i,showNewTask:a=!0}){let[o,s]=Z.useState(!1),c=Z.useRef(null),{pathname:l}=t();Z.useEffect(()=>{s(!1)},[l]),Z.useEffect(()=>{let e=window.matchMedia?.($g);if(!e)return;e.matches&&s(!1);let t=e=>{e.matches&&s(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let u=e.filter(e=>Kg.includes(e.to)),d=n!==null&&qg.includes(n),{top:f}=Bh(r),p=f.some(e=>e.count>0),m=e=>D(`relative flex h-full min-h-11 min-w-11 flex-1 flex-col items-center justify-center gap-[3px] text-[10.5px] leading-none focus-visible:outline-2 focus-visible:outline-ring`,e?`font-semibold text-foreground`:`font-medium text-soft-foreground`);return(0,Q.jsxs)(Q.Fragment,{children:[a?(0,Q.jsxs)(Y,{to:`/new`,"data-slot":`mobile-new-task`,className:`group-has-[[data-new-task-action]]/shell:hidden absolute right-4 bottom-full z-30 mb-4 flex h-12 items-center gap-2 rounded-[24px] bg-foreground px-[18px] text-[14px] font-semibold text-background shadow-[0_8px_24px_#00000055] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:[(0,Q.jsx)(Bi,{"aria-hidden":`true`,className:`size-[18px]`}),`New task`]}):null,(0,Q.jsxs)(`nav`,{"aria-label":`Views`,"data-slot":`mobile-tab-bar`,className:`flex h-[54px] items-stretch`,children:[u.map(e=>{let t=e.to===n,r=e.icon,i=e.to===`/`&&p;return(0,Q.jsxs)(Y,{to:e.to,"data-tab":e.to,"aria-current":t?`page`:void 0,className:m(t),children:[(0,Q.jsxs)(`span`,{className:`relative`,children:[(0,Q.jsx)(r,{"aria-hidden":`true`,className:`size-[21px]`}),i?(0,Q.jsx)(zh,{position:`top`,segments:f,className:`-top-[6px] -right-[10px] border-sidebar`}):null]}),e.label]},e.to)}),(0,Q.jsxs)(`button`,{ref:c,type:`button`,"data-tab":`more`,"aria-haspopup":`dialog`,"aria-expanded":o,"data-active":d?`true`:void 0,onClick:()=>s(!0),className:m(d),children:[(0,Q.jsx)(`span`,{className:`relative`,children:(0,Q.jsx)(Li,{"aria-hidden":`true`,className:`size-[21px]`})}),`More`]})]}),(0,Q.jsx)(Qg,{open:o,onOpenChange:s,onCloseAutoFocus:e=>{c.current?.isConnected&&(e.preventDefault(),c.current.focus())},projectName:i,items:e,activeTo:n})]})}var t_=`(min-width: 768px)`;function n_(e){return p({path:`/tasks/:id`,end:!0},xs(e))!==null}function r_(e){let t=xs(e);return t===`/github`||t.startsWith(`/github/`)}function i_({children:e,breadcrumb:n,repo:r=null,version:i=null,latestVersion:o=null,sidebarList:s,taskQuickList:c,sessionScope:l,toolsMenu:d,forgeAvailable:f=!0,automationsAvailable:p=!0,banner:m,mobileProjects:h,projectHeader:g,sidebarProjectId:_,needsYou:v,projectRail:y,toolsStatus:b}){let{pathname:x,search:S}=t(),{activeTo:C,current:w,currentProjectId:T,newTask:E,pushed:O,showTabBar:k,gitRepositoryView:A}=Jg(x,S,jr()),[j,M]=Z.useState(!1),[ee,te]=Z.useState(null),N=Z.useRef(null),P=Z.useRef(null),ne=Z.useRef(null),F=n_(x);Z.useLayoutEffect(()=>{let e=ne.current;if(ne.current=x,F||e!==null&&vs(e)===vs(x)&&r_(e)&&r_(x))return;let t=P.current;t&&(t.scrollTop=0)},[x,F,A]);let I=u(),re=Z.useRef(x);Z.useEffect(()=>{let e=re.current;re.current=x,e!==x&&(I===`REPLACE`&&d_(e,x)||M(!1))},[x,I]),Z.useEffect(()=>{let e=window.matchMedia?.(t_);if(!e)return;e.matches&&M(!1);let t=e=>{e.matches&&M(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let ie=Bg({forge:f,automations:p}),ae={version:i,latestVersion:o};return(0,Q.jsx)(ig,{open:j,onOpenChange:M,children:(0,Q.jsxs)(`div`,{"data-slot":`app-shell`,className:`flex h-dvh overflow-hidden bg-background text-foreground pl-[env(safe-area-inset-left)] pr-[env(safe-area-inset-right)]`,children:[(0,Q.jsx)(s_,{projectRail:y,activeTo:C,items:ie,repo:r,release:ae,sidebarList:s,taskQuickList:c,sessionScope:l,toolsMenu:d,projectHeader:g,sidebarProjectId:_,needsYou:v}),(0,Q.jsx)(u_,{release:ae,taskQuickList:c,sidebarProjectId:_,mobileProjects:h,currentProjectId:T,toolsStatus:b,onNavigate:()=>M(!1),onCloseAutoFocus:e=>{N.current?.isConnected&&(e.preventDefault(),N.current.focus())}}),(0,Q.jsxs)(`div`,{className:`group/shell grid min-w-0 flex-1 grid-rows-[auto_auto_1fr_auto] overflow-hidden`,children:[(0,Q.jsx)(__,{title:w?.label??a(`cezar`),pushed:O?{onSlot:te}:null,repo:r,elsewhere:pg(h,T),onTrigger:e=>{N.current=e}}),(0,Q.jsx)(a_,{breadcrumb:n,repo:r,label:w?.label,newTask:E}),m?(0,Q.jsx)(`div`,{"data-slot":`banner-slot`,className:`row-start-2`,children:m}):null,(0,Q.jsx)(`main`,{ref:P,"data-slot":`main`,className:D(`row-start-3 min-h-0 overflow-y-auto overscroll-contain`,k&&!E&&`max-md:pb-20`),children:(0,Q.jsx)(Og.Provider,{value:O?ee:null,children:e})}),(0,Q.jsx)(o_,{showTabBar:k,items:ie,activeTo:C,mobileProjects:h,currentProjectId:T,repo:r,newTask:E})]})]})})}function a_({breadcrumb:e,repo:t,label:n,newTask:r}){let i=e?.project??t?.name,o=e?.branch??t?.branch;return(0,Q.jsxs)(`header`,{"data-slot":`desktop-breadcrumb`,className:D(`row-start-1 hidden min-w-0 items-center gap-3 border-b border-border text-[13px] text-muted-foreground md:flex`,r?`h-[72px] px-11`:`h-16 px-9`),children:[(0,Q.jsx)(Di,{"aria-hidden":`true`,className:`size-4 shrink-0`}),i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`truncate font-medium text-foreground`,children:i}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`/`})]}):null,(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e?.page??n??a(`Cezarion`)}),o?(0,Q.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 text-[11px]`,children:[(0,Q.jsx)(ga,{"aria-hidden":`true`,className:`size-4 text-accent-text`}),o]}):null]})}function o_({showTabBar:e,items:t,activeTo:n,mobileProjects:r,currentProjectId:i,repo:a,newTask:o}){let s=i===null?void 0:r?.signals?.get(i);return(0,Q.jsx)(`div`,{"data-slot":`composer`,className:D(`row-start-4 pb-[max(env(safe-area-inset-bottom),var(--kb,0px))]`,e&&`relative max-md:border-t max-md:border-border max-md:bg-sidebar`),children:e?(0,Q.jsx)(`div`,{className:`md:hidden`,children:(0,Q.jsx)(e_,{items:t,activeTo:n,signal:s,projectName:r?.projects.find(e=>e.id===i)?.name??a?.name??null,showNewTask:!o})}):null})}function s_({projectRail:e,...t}){let[n,r]=Z.useState(fd),i=Z.useCallback(e=>{let t=dd(e);r(t),pd(t)},[]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(md.Provider,{value:n,children:e}),(0,Q.jsx)(c_,{...t,width:n,onWidthChange:i})]})}function c_({width:e,onWidthChange:t,...n}){return(0,Q.jsxs)(`aside`,{"data-slot":`sidebar`,style:{width:e},className:`relative hidden shrink-0 flex-col border-r border-border bg-sidebar md:flex`,children:[(0,Q.jsx)(p_,{...n}),(0,Q.jsx)(l_,{width:e,onWidthChange:t})]})}function l_({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(dd(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(dd(r)))},onDoubleClick:()=>t(264),title:`Drag to resize the sidebar — double-click to reset`,className:`absolute inset-y-0 -right-[2px] z-20 w-[5px] cursor-col-resize touch-none bg-transparent transition-colors hover:bg-[var(--composer-border)] focus-visible:bg-[var(--composer-border)] focus-visible:outline-none`})}function u_({onNavigate:e,onCloseAutoFocus:t,mobileProjects:n,currentProjectId:r,toolsStatus:i,release:a,taskQuickList:o,sidebarProjectId:s}){return(0,Q.jsxs)(lg,{side:`left`,"data-slot":`mobile-nav-drawer`,onCloseAutoFocus:t,overlayClassName:`bg-[var(--nav-scrim)]`,showCloseButton:!1,className:`w-[calc(100%-68px)] max-w-[334px] gap-0 border-border bg-sidebar p-0 sm:max-w-[334px] md:hidden`,"aria-describedby":void 0,children:[(0,Q.jsx)(dg,{className:`sr-only`,children:`Navigation`}),(0,Q.jsx)(gg,{version:a.version,latestVersion:a.latestVersion}),(0,Q.jsxs)(`div`,{"data-slot":`drawer-scroll`,className:`flex min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain`,children:[n?(0,Q.jsx)(yg,{nav:n,currentProjectId:r,onNavigate:e}):null,o?(0,Q.jsx)(f_,{projectId:s,onNavigate:e,children:(0,Q.jsx)(`div`,{"data-slot":`drawer-tasks`,className:`border-t border-border px-[8px] py-[8px]`,children:o})}):null]}),(0,Q.jsx)(bg,{onNavigate:e,tools:i})]})}function d_(e,t){return vs(e)==="default"&&vs(t)!==null&&vs(t)!=="default"&&xs(e)===xs(t)}function f_({projectId:e,onNavigate:t,children:n}){let r=wt(),i=e===void 0?r:{projectId:e,apiBase:`${s}/p/${encodeURIComponent(e)}`};return(0,Q.jsx)(Ot.Provider,{value:i,children:(0,Q.jsx)(hd.Provider,{value:t,children:n})})}function p_({activeTo:e,items:t,repo:n,release:r,sidebarList:i,taskQuickList:a,sessionScope:o,toolsMenu:s,projectHeader:c,sidebarProjectId:l,needsYou:u,onNavigate:d}){return(0,Q.jsx)(f_,{projectId:l,onNavigate:d,children:(0,Q.jsxs)(`div`,{"data-slot":`sidebar-content`,className:`@container/sidebar flex min-h-0 flex-1 flex-col pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]`,children:[(0,Q.jsx)(`div`,{"data-slot":`sidebar-header`,className:`shrink-0`,children:c??(n?(0,Q.jsxs)(`div`,{className:`px-[14px] pt-[14px] pb-2.5`,children:[(0,Q.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:n.name}),(0,Q.jsx)(`div`,{className:`truncate font-mono text-[10.5px] text-soft-foreground`,children:n.branch})]}):null)}),(0,Q.jsxs)(`div`,{"data-slot":`sidebar-actions`,className:`flex flex-col gap-2 px-3`,children:[(0,Q.jsx)(h_,{}),(0,Q.jsx)(E,{asChild:!0,variant:`ghost`,className:D(`relative h-[32px] max-md:min-h-11 rounded-[7px] bg-muted w-full min-w-0 justify-start gap-2 px-2.5 text-[12.5px] font-medium text-foreground hover:bg-sidebar-row-hover hover:text-foreground`,e===`/new`&&`bg-sidebar-row-selected text-foreground font-medium hover:bg-sidebar-row-selected`),children:(0,Q.jsxs)(Y,{to:`/new`,onClick:d,"data-sidebar-item":`new-task`,"aria-current":e===`/new`?`page`:void 0,children:[(0,Q.jsx)(Bi,{className:`size-[15px]`,"aria-hidden":`true`}),`New task`,(0,Q.jsx)(`kbd`,{"aria-hidden":`true`,className:`sr-only`,children:`C`})]})})]}),o?(0,Q.jsx)(`div`,{className:`shrink-0 px-3 pt-2`,children:o}):null,(0,Q.jsx)(Rg,{items:t,activeTo:e,needsYou:u,onNavigate:d}),(0,Q.jsx)(`div`,{"data-slot":`project-task-navigation`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-3`,children:(0,Q.jsx)(hd.Provider,{value:d,children:i??(0,Q.jsx)(`div`,{"data-slot":`task-quick-list`,children:a})})}),(0,Q.jsx)(m_,{toolsMenu:s,release:r})]})})}function m_({toolsMenu:e,release:t}){return(0,Q.jsx)(`div`,{"data-slot":`sidebar-footer`,className:`shrink-0`,children:(0,Q.jsxs)(`div`,{"data-slot":`sidebar-footer-controls`,className:`flex h-11 items-center justify-between gap-1 border-t border-border px-3`,children:[(0,Q.jsx)(`div`,{"data-slot":`tools-menu`,className:`shrink-0`,children:e}),(0,Q.jsx)(`div`,{className:`flex min-w-0 items-center gap-1`,"data-slot":`version-action`,children:t.version?(0,Q.jsx)(g_,{version:t.version,latestVersion:t.latestVersion}):null})]})})}function h_(){return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`command-palette-hint`,title:`Search — command palette (⌘K / Ctrl+K)`,onClick:()=>ld(),className:`flex h-[32px] max-md:min-h-11 w-full items-center gap-2 rounded-[7px] border border-border bg-background px-2.5 text-left text-[12.5px] font-normal text-soft-foreground transition-colors hover:border-border hover:text-foreground`,children:[(0,Q.jsx)(Fi,{className:`size-[14px] shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`truncate`,children:`Search…`}),(0,Q.jsx)(`kbd`,{"aria-hidden":`true`,className:`ml-auto shrink-0 font-sans text-[11px] font-normal text-soft-foreground`,children:Eg(`k`)})]})}function g_({version:e,latestVersion:t}){let n=!!(t&&Ih(t,e));return(0,Q.jsxs)(`span`,{"data-slot":`version-chip`,"data-update-available":n?`true`:void 0,title:n?`v${e} — update available: v${t}`:`v${e}`,className:`flex min-w-0 items-center gap-1 font-mono text-[11px] text-soft-foreground`,children:[n?(0,Q.jsx)($,{tone:`pending`,className:`size-[5px] shrink-0`}):null,(0,Q.jsxs)(`span`,{className:`truncate`,children:[`v`,e]})]})}function __({title:e,pushed:t,repo:n,elsewhere:r,onTrigger:i}){return t?(0,Q.jsx)(v_,{onSlot:t.onSlot}):(0,Q.jsx)(`header`,{"data-slot":`mobile-top-bar`,className:`row-start-1 min-w-0 border-b border-border bg-card pt-[env(safe-area-inset-top)] md:hidden`,children:(0,Q.jsxs)(`div`,{className:`flex h-[56px] min-w-0 items-center gap-[8px] px-[8px]`,children:[(0,Q.jsx)(ag,{asChild:!0,children:(0,Q.jsxs)(E,{variant:`ghost`,"aria-label":mg(r),onClick:e=>i(e.currentTarget),className:`relative h-[44px] w-[64px] shrink-0 justify-start rounded-md p-0 pl-[10px] text-foreground`,children:[(0,Q.jsx)(Oi,{className:`size-[20px]`,"aria-hidden":`true`}),(0,Q.jsx)(hg,{elsewhere:r})]})}),n?(0,Q.jsx)(ag,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`mobile-project-picker`,"aria-label":`Switch project: ${n.name}`,onClick:e=>i(e.currentTarget),className:`flex h-[44px] min-w-0 flex-1 items-center justify-start gap-[10px] rounded-md text-left focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`flex size-[28px] shrink-0 items-center justify-center rounded-[8px] border border-soft-foreground bg-sidebar-row-selected text-[11px] leading-none font-semibold text-foreground`,children:Sh(n.name)}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[15px] leading-tight font-semibold text-foreground`,children:n.name}),n.branch?(0,Q.jsx)(`span`,{className:`truncate font-mono text-[10.5px] leading-tight text-soft-foreground`,children:n.branch}):null]}),(0,Q.jsx)(_a,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-soft-foreground`})]})}):null,e===a(`cezar`)?n?null:(0,Q.jsx)(`span`,{className:`flex-1`}):(0,Q.jsx)(`span`,{"data-slot":`mobile-route-title`,className:D(`truncate text-[15px] font-semibold text-foreground`,n?`sr-only`:`min-w-0 flex-1 pl-[8px]`),children:e}),(0,Q.jsx)(E,{variant:`ghost`,"aria-label":`Search`,"data-slot":`mobile-search`,onClick:()=>ld(),className:`ml-auto size-[44px] shrink-0 p-0 text-foreground`,children:(0,Q.jsx)(Fi,{className:`size-[19px]`,"aria-hidden":`true`})})]})})}function v_({onSlot:e}){let t=_s();return(0,Q.jsx)(`header`,{"data-slot":`mobile-top-bar`,"data-mode":`task`,className:`row-start-1 min-w-0 border-b border-border bg-card pt-[env(safe-area-inset-top)] md:hidden`,children:(0,Q.jsxs)(`div`,{className:`flex h-[56px] min-w-0 items-center gap-[4px] px-[8px]`,children:[(0,Q.jsx)(E,{variant:`ghost`,"aria-label":`Back`,"data-slot":`mobile-back`,onClick:()=>{let e=window.history.state?.idx;t(typeof e==`number`&&e>0?-1:`/`)},className:`size-[44px] shrink-0 p-0 text-foreground`,children:(0,Q.jsx)(du,{className:`size-[22px]`,"aria-hidden":`true`})}),(0,Q.jsx)(`div`,{"data-slot":`mobile-run-bar`,ref:e,className:`flex min-w-0 flex-1 items-center gap-[4px]`})]})})}var y_=`cez-last-location`;function b_(){try{let e=localStorage.getItem(y_);return e===null?null:JSON.parse(e)}catch{return null}}function x_(e){try{localStorage.setItem(y_,JSON.stringify(e))}catch{}}var S_=new Set([`projectId`,`pathname`,`search`,`hash`]);function C_(e){return typeof e!=`string`||e.length<1||e.length>64?null:e}function w_(e){return typeof e!=`string`||e.length<1||e.length>2048||!e.startsWith(`/p/`)?null:e}function T_(e){return e!==void 0&&(typeof e!=`string`||e.length>4096||!e.startsWith(`?`))?null:e}function E_(e){return e!==void 0&&(typeof e!=`string`||e.length>2048||!e.startsWith(`#`))?null:e}function D_(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e;if(Object.keys(t).some(e=>!S_.has(e)))return null;let n=C_(t.projectId);if(n===null)return null;let r=w_(t.pathname);if(r===null)return null;let i=T_(t.search);if(i===null)return null;let a=E_(t.hash);if(a===null)return null;try{if(vs(r)!==n)return null}catch{return null}return{projectId:n,pathname:r,...i===void 0?{}:{search:i},...a===void 0?{}:{hash:a}}}function O_(e,t){let n=t.projects.find(t=>t.id===e);return n!==void 0&&n.status!==`missing`}function k_(e,t){if(t===void 0)return null;let n;try{n=vs(e.pathname)}catch{return null}return n===null||!O_(n,t)?null:D_({projectId:n,pathname:e.pathname,...e.search===``?{}:{search:e.search},...e.hash===``?{}:{hash:e.hash}})}function A_(e,t,n){let r=D_(e);return r===null||!(t===void 0?n!==void 0&&r.projectId===n:O_(r.projectId,t))?null:`${r.pathname}${r.search??``}${r.hash??``}`}function j_(e,t){let n=D_(e);return n!==null&&n.projectId===t.projectId&&n.pathname===t.pathname&&(n.search??``)===(t.search??``)&&(n.hash??``)===(t.hash??``)}var M_=`cez-project-locations`;function N_(){try{let e=localStorage.getItem(M_),t=e===null?null:JSON.parse(e);return typeof t==`object`&&t&&!Array.isArray(t)?t:{}}catch{return{}}}function P_(e){let t=N_()[e];return t===void 0?null:t}function F_(e){try{localStorage.setItem(M_,JSON.stringify({...N_(),[e.projectId]:e}))}catch{}}function I_(e,t,n){let r=D_(t);return r===null||r.projectId!==e||n===void 0||!O_(e,n)?null:`${r.pathname}${r.search??``}${r.hash??``}`}var L_=2500,R_=e=>String(gs(e,`/`));function z_(e,t,n){let r={href:R_(e),verify:!1},i=I_(e,t,n.registry);if(i===null)return r;try{let e=i.replace(/[?#].*$/,``),t=n.matchRoute(e);return t===null?r:{href:i,verify:Object.keys(t.params).some(e=>e!==`projectId`)}}catch{return r}}var B_=e=>qe(Wn(e.params.id??``,{projectId:e.opts.projectId}),{signal:e.opts.signal});function V_(e){let t=Number(e);return Number.isSafeInteger(t)&&t>=1?t:null}async function H_(e,t,n){let r=await $e(e,t,{},n.opts);return r.available?r.item!==null:null}var U_=async e=>(await B_(e),!0),W_=async e=>(await B_(e),await Ht(e.params.id??``,e.params.sha??``,e.opts),!0);async function G_(e,t){let n=await B_(e),r=V_(e.params.n);return r===null?!1:bi(n,e.repoBase).some(e=>e.kind===t&&e.number===r)?H_(t,r,e):e.repoBase===void 0&&null}var K_=async e=>(await rt(e.params.sha??``,e.opts),!0);async function q_(e,t){let n=V_(e.params.n);return n!==null&&H_(t,n,e)}var J_=[{matches:e=>e===`/tasks/:id/commits/:sha`,check:W_},{matches:e=>e===`/tasks/:id/issue/:n`,check:e=>G_(e,`issue`)},{matches:e=>e===`/tasks/:id/pr/:n`,check:e=>G_(e,`pr`)},{matches:e=>e.startsWith(`/tasks/:id`),check:U_},{matches:e=>e===`/git/commits/:sha`,check:K_},{matches:e=>e===`/github/issues/:n`,check:e=>q_(e,`issue`)},{matches:e=>e.startsWith(`/github/prs/:n`),check:e=>q_(e,`pr`)},{matches:e=>e===`/workflows/:name`,check:async e=>{let{workflows:t,issues:n}=await we(e.opts);return t.some(t=>t.name===e.params.name)?!0:n.length>0&&null}},{matches:e=>e.startsWith(`/automations/:automationId`),check:async e=>{let t=await ye(e.opts);return t.available?t.automations.some(t=>t.id===e.params.automationId):null}}];async function Y_(e,t,n,r,i){let a=``;try{let o=i(t);if(o===null)return!1;a=o.pattern;let s=J_.find(e=>e.matches(o.pattern));return s===void 0?null:await s.check({projectId:e,pattern:a,params:o.params,repoBase:r,opts:{projectId:e,signal:n}})}catch(e){return!Z_(e,a)&&null}}var X_=/unknown revision|bad object|bad revision|unknown commit|not a commit hash|needed a single revision/i;function Z_(e,t){return e instanceof it?e.status===404||(t===`/git/commits/:sha`||t===`/tasks/:id/commits/:sha`)&&e.status===409&&X_.test(e.message):!1}async function Q_(e,t,n){let r=z_(e,t,n);if(!r.verify)return r.href;let i=new AbortController,a=setTimeout(()=>i.abort(),L_);try{return await Y_(e,r.href.replace(/[?#].*$/,``),i.signal,n.repoBaseOf?.(e),n.matchRoute)===!1?R_(e):r.href}finally{clearTimeout(a)}}var $_={key:``,navigate:null,ticket:0};function ev(e,t){e!==$_.key&&$_.ticket++,$_.key=e,$_.navigate=t}function tv(){$_.ticket++}async function nv(e,t,n){let r=++$_.ticket,i=$_.key,a=await Q_(e,t,n);r===$_.ticket&&i===$_.key&&$_.navigate?.(a)}function rv(){let e=k(),n=t();Z.useLayoutEffect(()=>{ev(`${n.key}|${n.pathname}${n.search}${n.hash}`,e)},[e,n.key,n.pathname,n.search,n.hash])}function iv(){let e=Z.useContext(tu);if(e===null)throw Error(`useProjectSwitch needs a ProjectRouteMatcherContext provider (App provides matchProjectRoute)`);let n=An().data,r=On().data,i=Z.useCallback(e=>n?.projects.find(t=>t.id===e)?.repoUrl??(e===(r?.bootProject??n?.bootProject)?vn(r?.repo?.remote):void 0),[n,r]);rv();let{pathname:a,search:o,hash:s}=t(),c=vs(a),l=`${a}${o}${s}`;return{target:Z.useCallback(t=>t===c?{href:l,verify:!1}:z_(t,P_(t),{registry:n,matchRoute:e}),[n,e,c,l]),go:Z.useCallback(async t=>{if(t===c)return tv();await nv(t,P_(t),{registry:n,repoBaseOf:i,matchRoute:e})},[n,i,e,c])}}function av(e){return e<=200}function ov(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 sv(e,t){let n=ov(t);if(n.length===0)return[...e];let r=new Map(n.map((e,t)=>[e,t])),i=[],a=[];for(let t of e)r.has(t.id)?i.push(t):a.push(t);return i.sort((e,t)=>r.get(e.id)-r.get(t.id)),[...a,...i]}function cv(e,t,n){return t===n||t<0||n<0||t>=e.length||n>=e.length?[...e]:xc([...e],t,n)}function lv(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function uv(){let e=L(),t=Cr(),n=Z.useRef(0),r=Z.useRef(Promise.resolve()),i=Z.useMemo(()=>ov(t.data?.sidebar?.projectOrder),[t.data?.sidebar?.projectOrder]),a=Z.useCallback(t=>{let i=e.getQueryData(V.uiState);if(i===void 0)return;let{projectOrder:a,...o}=lv(i.sidebar),s=t===null?o:{...o,projectOrder:t};e.setQueryData(V.uiState,{...i,sidebar:s});let c=++n.current,l=r.current.then(async()=>{let t=await ht({sidebar:s},{keepalive:!0});c===n.current&&e.setQueryData(V.uiState,t)});r.current=l.catch(t=>{G(t instanceof Error?t.message:String(t),{tone:`danger`}),c===n.current&&e.invalidateQueries({queryKey:V.uiState})})},[e]),o=Z.useCallback(e=>{let t=ov(e);t.length===0||!av(e.length)||a(t)},[a]),s=Z.useCallback(()=>a(null),[a]);return{order:i,canReorder:t.data!==void 0,setOrder:o,reset:s}}function dv(e){return[...e].sort((e,t)=>Date.parse(t.createdAt)-Date.parse(e.createdAt))}function fv(e,t,n){let r=t.trim().toLowerCase();if(r===``)return 1;let i=(n?.length?`${e} ${n.join(` `)}`:e).toLowerCase(),a=r.split(/\s+/),o=0;for(let e of a){let t=i.indexOf(e);if(t===-1)return 0;let n=t===0||!/[a-z0-9]/.test(i[t-1]??``);o+=(n?1:.5)/(1+t/48)}return o/a.length}function pv(e,t){if(t.trim()===``)return e;let n=e=>e.rows.reduce((e,n)=>Math.max(e,fv(n.value,t,n.keywords)),0);return e.map(e=>({group:e,score:n(e)})).sort((e,t)=>t.score-e.score).map(({group:e})=>e)}function mv(e,t){return{value:`task ${W(e)} ${e.id}`,keywords:[...t?[t]:[],...xv(e),...[e.branch,e.workflow,e.workflowLabel,e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl].filter(e=>!!e)]}}var hv=e=>({value:`view ${e}`}),gv=e=>({value:`project ${e.name} ${e.id}`,keywords:[e.root]}),_v=e=>({value:`skill ${e.name} ${e.path}`,...x({keywords:e.description?[e.description]:void 0})}),vv={value:`action toggle theme`},yv=150;function bv(e,t,n,r=[]){let i=dv(e.filter(e=>!zr(e))).map(e=>({...e,projectId:t})),a=new Set(i.map(Sv)),o=[...n??[],...r].filter(e=>zr(e)||a.has(Sv(e))?!1:(a.add(Sv(e)),!0)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return[...i,...o]}function xv(e){let t=new Set;for(let n of[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl]){let e=n?/\/(\d+)\/?$/.exec(n):null;e&&t.add(Number(e[1]))}for(let n of[e.prNumber,e.issueNumber,e.markerRefs?.pr,e.markerRefs?.issue])typeof n==`number`&&Number.isInteger(n)&&n>0&&t.add(n);return[...t].flatMap(e=>[String(e),`#${e}`])}var Sv=e=>`${e.projectId??``}/${e.id}`;function Cv(e){let t=e.filter(e=>Zr(e)).sort((e,t)=>(t.finishedAt??``).localeCompare(e.finishedAt??``)),n=new Set(t.map(Sv));return{recentlyFinished:t,otherTasks:e.filter(e=>!n.has(Sv(e)))}}function wv(e,t,n=[]){let r=sv(e,n);return[...r.filter(e=>e.id!==t),...r.filter(e=>e.id===t)]}function Tv(){let[e,t]=Z.useState(!1),n=_s();wg(`k`,()=>t(e=>!e));let r=Z.useCallback(()=>{t(!1),n(`/new`)},[n]);return wg(`n`,r),Dg(`c`,r),Z.useEffect(()=>{let e=()=>t(!0);return window.addEventListener(cd,e),()=>window.removeEventListener(cd,e)},[]),(0,Q.jsx)(As,{open:e,onOpenChange:t,title:`Command palette`,description:`Search projects, tasks, views, actions, and skills`,showCloseButton:!1,filter:fv,className:`top-[10vh] translate-y-0 sm:max-w-2xl lg:max-w-3xl xl:max-w-4xl`,children:(0,Q.jsx)(Nv,{close:()=>t(!1)})})}function Ev({heading:e,tasks:t,projectName:n,showProject:r,now:i,onSelect:a}){return(0,Q.jsx)(Ps,{heading:e,children:t.map(e=>(0,Q.jsx)(Dv,{task:e,projectName:n(e),showProject:r,now:i,onSelect:a},Sv(e)))})}function Dv({task:e,projectName:t,showProject:n,now:r,onSelect:i}){let a=xe(e),o=W(e);return(0,Q.jsxs)(fc,{...mv(e,t),"data-slot":`palette-task`,"data-run-id":e.id,"data-project-id":e.projectId??void 0,onSelect:()=>i(e),children:[(0,Q.jsx)($,{tone:a.tone,shape:a.shape,pulse:a.pulse,"aria-label":a.label,role:`img`}),e.delegation?.role===`worker`?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Worker`}):null,(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:o}),n&&t?(0,Q.jsx)(`span`,{"data-slot":`palette-task-project`,className:`shrink-0 truncate text-xs text-soft-foreground`,children:t}):null,(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-soft-foreground tabular-nums`,children:za(e.finishedAt??e.createdAt,r)})]})}function Ov({multiProject:e,health:t}){return[...e?[{label:`All tasks`,to:`/tasks`,icon:Ti,global:!0}]:[],...Bg({forge:t.data?.forge?.available===!0,automations:Vs(t.data)}).map(e=>({label:e.label,to:e.to,icon:e.icon,global:!1}))]}function kv({views:e,go:t,goGlobal:n,orderedProjects:r,activeProjectId:i,goProject:a,otherTasks:o,searching:s,taskProjectName:c,showProjectOnTasks:l,now:u,selectTask:d,orderedSkills:f,theme:p,nextTheme:m,setTheme:h,close:g}){let _=[{rows:e.map(e=>hv(e.label)),node:(0,Q.jsx)(Ps,{heading:`Views`,children:e.map(e=>{let r=e.icon;return(0,Q.jsxs)(fc,{...hv(e.label),"data-slot":`palette-view`,"data-nav-to":e.to,onSelect:()=>e.global?n(e.to):t(e.to),children:[(0,Q.jsx)(r,{"aria-hidden":`true`}),e.label]},e.to)})},`views`)}];return r.length>0&&_.push({rows:r.map(gv),node:(0,Q.jsx)(Ps,{heading:`Projects`,children:r.map(e=>{let t=e.id===i,n=e.status===`missing`;return(0,Q.jsxs)(fc,{...gv(e),"data-slot":`palette-project`,"data-project-id":e.id,disabled:n,onSelect:()=>a(e.id),children:[(0,Q.jsx)(Ei,{"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)(ia,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},e.id)})},`projects`)}),o.length>0&&_.push({rows:s?o.map(e=>mv(e,c(e))):[],node:(0,Q.jsx)(Ev,{heading:`Tasks`,tasks:o,projectName:c,showProject:l,now:u,onSelect:d},`tasks`)}),_.push({rows:[vv],node:(0,Q.jsx)(Ps,{heading:`Actions`,children:(0,Q.jsxs)(fc,{...vv,"data-slot":`palette-action`,"data-action":`toggle-theme`,onSelect:()=>{h(m),g()},children:[(0,Q.jsx)(Wi,{"aria-hidden":`true`}),`Toggle theme`,(0,Q.jsxs)(Ms,{className:`tracking-normal`,children:[p,` → `,m]})]})},`actions`)}),f.length>0&&_.push({rows:f.map(_v),node:(0,Q.jsx)(Ps,{heading:`Skills`,children:f.map(e=>(0,Q.jsxs)(fc,{..._v(e),"data-slot":`palette-skill`,"data-skill":e.name,onSelect:()=>t(`/new?skill=${encodeURIComponent(e.name)}`),children:[(0,Q.jsx)(`span`,{className:`shrink-0 font-medium`,children:e.name}),e.description?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null]},e.path))},`skills`)}),_}function Av({search:e,setSearch:t}){return(0,Q.jsx)(Rs,{placeholder:`Search projects, tasks, views, actions, skills…`,value:e,onValueChange:t})}function jv({search:e,searching:t,recentlyFinished:n,groups:r,taskProjectName:i,showProjectOnTasks:a,now:o,selectTask:s,go:c}){return(0,Q.jsxs)(Es,{className:`max-h-[55vh] min-h-[14rem] sm:max-h-[60vh] lg:max-h-[68vh]`,children:[(0,Q.jsx)(Ns,{children:`Nothing matches.`}),(0,Q.jsx)(Ps,{children:(0,Q.jsxs)(fc,{value:`new task`,"data-slot":`palette-view`,"data-nav-to":`/new`,onSelect:()=>c(`/new`),children:[(0,Q.jsx)(Bi,{"aria-hidden":`true`}),`New task`,(0,Q.jsx)(Ms,{children:`C`})]})}),!t&&n.length>0?(0,Q.jsx)(Ev,{heading:`Recently finished`,tasks:n,projectName:i,showProject:a,now:o,onSelect:s}):null,pv(r,e).map(e=>e.node)]})}function Mv({cappedProjects:e}){return e.length===0?null:(0,Q.jsxs)(`p`,{"data-slot":`palette-search-truncated`,role:`status`,className:`border-t border-border px-3 py-2 text-[11px] text-soft-foreground`,children:[`More matches in `,e.join(`, `),`. Type more to narrow them.`]})}function Nv({close:e}){let t=_s(),n=k(),[r,i]=Z.useState(``),a=r.trim()!==``,o=Cs(),{theme:s,setTheme:c}=eg(),l=Nn(),u=un(),d=An(),f=En(),p=On(),m=Date.now(),h=d.data,g=h!==void 0&&h.projects.length>1,_=mn(g),{order:v}=uv(),y=Z.useMemo(()=>g?wv(h.projects,o,v):[],[g,h,o,v]),b=Z.useMemo(()=>new Map((h?.projects??[]).map(e=>[e.id,e.name])),[h]),x=o??h?.bootProject??null,[S,C]=Z.useState(``);Z.useEffect(()=>{let e=setTimeout(()=>C(r),yv);return()=>clearTimeout(e)},[r]);let w=pn(S),T=a?w.data?.runs:void 0,E=a&&!w.isPlaceholderData?(w.data?.truncated??[]).map(e=>b.get(e)??e):[],D=Z.useMemo(()=>bv(l.data??[],x,_.data?.runs,T),[l.data,x,_.data,T]),O=Z.useMemo(()=>Cv(D),[D]),A=a?[]:O.recentlyFinished,j=a?D:O.otherTasks,M=g,ee=e=>e.projectId===null?null:b.get(e.projectId)??null,te=f.data?.skillUsage,N=Z.useMemo(()=>Pc(u.data??[],te),[u.data,te]),P=n=>{e(),t(n)},ne=t=>{e(),n(t)},F=iv(),I=t=>{e(),F.go(t)},re=n=>{e(),t(n.projectId===null?`/tasks/${n.id}`:gs(n.projectId,`/tasks/${n.id}`))},ie=tg[s],ae=kv({views:Ov({multiProject:g,health:p}),go:P,goGlobal:ne,orderedProjects:y,activeProjectId:o,goProject:I,otherTasks:j,searching:a,taskProjectName:ee,showProjectOnTasks:M,now:m,selectTask:re,orderedSkills:N,theme:s,nextTheme:ie,setTheme:c,close:e});return(0,Q.jsxs)(Q.Fragment,{children:[Av({search:r,setSearch:i}),jv({search:r,searching:a,recentlyFinished:A,groups:ae,taskProjectName:ee,showProjectOnTasks:M,now:m,selectTask:re,go:P}),Mv({cappedProjects:E})]})}var Pv=Z.createContext(null);function Fv({children:e}){let[t,n]=Z.useState(`active`),r=js(),i=r?t:`active`,a=Z.useMemo(()=>[i,n,r],[i,r]);return(0,Q.jsx)(Pv.Provider,{value:a,children:e})}function Iv(){let e=Z.useContext(Pv);if(!e)throw Error(`useListView must be used inside a <ListViewProvider>`);return e}var Lv=rn.options;function Rv(e){if(typeof e!=`object`||!e||Array.isArray(e))return{};let t=e,n={};for(let e of Lv){let r=t[e];typeof r==`string`&&r.length>0&&r.length<=128&&(n[e]=r)}return n}function zv(e,t){if(!e)return[];let n=new Map(e.providers.map(e=>[e.provider,e]));return Lv.flatMap(e=>{let r=n.get(e);return r?.status!==`disconnected`||!r.authFailureId||t[e]===r.authFailureId?[]:[{provider:e,label:Lc(e),authFailureId:r.authFailureId}]})}function Bv(e,t){return{...e,...Object.fromEntries(t.map(({provider:e,authFailureId:t})=>[e,t]))}}function Vv({status:e,pending:t,error:n,dismissals:r,onDismissAuthFailures:i}){if(t||!e)return null;let a;try{a=Ke(e)}catch{return null}let o=zv(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)($,{tone:`danger`}),(0,Q.jsxs)(`span`,{children:[`Provider authentication failed during a task:`,` `,o.map(({label:e})=>e).join(`, `),`.`]}),(0,Q.jsx)(Y,{to:`/settings/agents#providers`,className:`ml-auto shrink-0 font-medium underline underline-offset-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:`Open agent settings`}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Dismiss provider authentication alert`,onClick:()=>i(o),className:`shrink-0 rounded-sm p-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,Q.jsx)(od,{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)($,{tone:c?`danger`:`pending`}),(0,Q.jsx)(`span`,{children:s?`No agent provider is enabled.`:c?`No connected provider could be verified.`:`No agent provider credentials were found.`}),(0,Q.jsx)(Y,{to:`/settings/agents#providers`,className:`ml-auto shrink-0 font-medium text-foreground underline underline-offset-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:`Configure providers`})]})}function Hv(e){if(!(typeof e!=`object`||!e||Array.isArray(e)))return e}function Uv(){let e=sn(),t=Cr(),n=L(),r=(0,Z.useRef)(Promise.resolve()),i=(0,Z.useRef)(0),a=(0,Z.useRef)(0),o=(0,Z.useRef)(Hv(t.data));(0,Z.useEffect)(()=>{a.current===0&&(o.current=Hv(t.data))},[t.data]);let s=(0,Z.useCallback)(e=>{let t=V.uiState,s=Hv(n.getQueryData(t)),c=Bv(Rv(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 ht({dismissedProviderAuthFailures:c});o.current=Hv(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}),G(e instanceof Error?e.message:String(e),{tone:`danger`}))}finally{--a.current}})},[n]);return(0,Q.jsx)(Vv,{status:e.data,pending:e.isPending,error:e.isError,dismissals:Rv(Hv(t.data)?.dismissedProviderAuthFailures),onDismissAuthFailures:s})}function Wv(e){return e.reason===`legacy-change`?e.canImport?`${e.file} changed in the old home. Import keeps live-only changes. Old-home changes win when both homes changed the same key or entry.`:`${e.file} changed in the old home. Import is unavailable. Ignore keeps the live file and skips these old-home changes.`:e.reason===`outside-write`?`${e.file} changed outside ${a(`Cezar`)}. Restore the previous version or accept the file as found.`:e.file===`config.json`?`The project registry was reset. Restore the previous projects?`:`The account list was reset. Restore the previous accounts?`}function Gv({file:e,editable:t}){let n=Xl(),r=Zl(),a=Ql(),o=e.reason===`legacy-change`,s=n.isPending||r.isPending||a.isPending,c=n.error??r.error??a.error,l=t=>{n.reset(),r.reset(),a.reset();let i={file:e.file,detectedAt:e.detectedAt};t===`restore`?n.mutate(i):t===`accept`?r.mutate(i):a.mutate(i)};return(0,Q.jsxs)(`div`,{"data-slot":`home-recovery`,"data-home-file":e.file,role:`status`,"aria-live":`polite`,"aria-busy":s,className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border bg-muted/50 p-3 text-sm text-foreground`,children:[(0,Q.jsx)(`span`,{className:`flex-[1_1_24rem] [min-inline-size:0] [overflow-wrap:break-word]`,children:Wv(e)}),t?(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[o?e.canImport&&(0,Q.jsx)(E,{type:`button`,"data-action":`import`,disabled:s,onClick:()=>l(`import`),children:`Import changes from the old home`}):(0,Q.jsx)(E,{type:`button`,"data-action":`restore`,disabled:s||!e.canRestore,onClick:()=>l(`restore`),children:`Restore`}),(0,Q.jsx)(E,{type:`button`,variant:`outline`,"data-action":`accept`,disabled:s,onClick:()=>l(`accept`),children:o?`Ignore`:`Accept as found`})]}):t===!1&&(0,Q.jsxs)(`p`,{className:`basis-full`,children:[o?e.canImport?`Only the host operator can import or ignore this file.`:`Only the host operator can ignore this file.`:`Only the host operator can restore or accept this file.`,e.file.startsWith(`remote-settings/`)&&(o?(0,Q.jsxs)(Q.Fragment,{children:[` `,e.canImport&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`code`,{children:[i(),` backup import `,e.file]}),` or `]}),(0,Q.jsxs)(`code`,{children:[i(),` backup ignore `,e.file]})]}):(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsxs)(`code`,{children:[i(),` backup restore `,e.file]})]}))]}),t&&c&&(0,Q.jsx)(`p`,{role:`alert`,className:`basis-full text-danger`,children:c.message})]})}function Kv(){let e=Kl(),t=On().data?.capabilities?.localHandoff;return(0,Q.jsx)(`div`,{"data-slot":`home-recovery-state`,"data-state":e.isSuccess?`ready`:e.isError?`error`:`pending`,children:e.data?.files.map(e=>(0,Q.jsx)(Gv,{file:e,editable:!e.file.startsWith(`remote-settings/`)&&t},e.file))})}var qv=`cez-project-rail-expanded`;function Jv(e,t){return e-232-t>=640}function Yv(){try{return localStorage.getItem(qv)===`1`}catch{return!1}}function Xv(e){try{localStorage.setItem(qv,e?`1`:`0`)}catch{}}function Zv(e){if(e!==void 0)return e.isDragging?`relative z-10 opacity-40 [-webkit-touch-callout:none]`:`[-webkit-touch-callout:none]`}function Qv({project:e,signal:t,known:n,current:r,target:i,onSwitchProject:a,onSelectProject:o,sort:s}){let c=yh(e.name,t,{unknown:!n});return(0,Q.jsxs)(`div`,{ref:s?.setNodeRef,style:s?.style,...s?.listeners,"data-slot":`rail-project`,"data-project-id":e.id,"data-dragging":s?.isDragging?``:void 0,className:D(`relative flex h-[52px] w-full shrink-0 items-center justify-center`,Zv(s)),children:[r?(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`rail-current-bar`,className:`absolute top-1/2 left-0 h-5 w-[3px] -translate-y-1/2 rounded-r-[2px] bg-foreground`}):null,(0,Q.jsxs)(`div`,{className:`relative size-9`,children:[(0,Q.jsx)(C,{ref:s?.setActivatorNodeRef,"aria-describedby":s?.attributes[`aria-describedby`],to:i.href,onClick:t=>{t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(o?.(e.id),i.verify&&a&&(t.preventDefault(),a(e.id)))},"aria-label":c,title:c,"aria-current":r?`page`:void 0,className:D(`flex size-full items-center justify-center rounded-[9px] border text-[12px] leading-none font-semibold focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,r?`border-soft-foreground bg-sidebar-row-selected text-foreground`:`border-transparent bg-muted text-muted-foreground hover:text-foreground`),children:Sh(e.name)}),(0,Q.jsx)(zh,{position:`top`,segments:Bh(t).top}),(0,Q.jsx)(zh,{position:`bottom`,segments:Bh(t).bottom})]})]})}var $v=`motion-safe:rail-text-in`;function ey({project:e,signal:t,known:n,current:r,target:i,onSwitchProject:a,onSelectProject:o,sort:s}){let c=yh(e.name,t,{unknown:!n}),{top:l,bottom:u}=Bh(t),d=r?`border-sidebar-row-selected`:`border-background group-hover:border-sidebar-row-hover`;return(0,Q.jsxs)(`div`,{ref:s?.setNodeRef,style:s?.style,...s?.listeners,"data-slot":`rail-project`,"data-project-id":e.id,"data-dragging":s?.isDragging?``:void 0,className:D(`group/row relative w-full shrink-0`,Zv(s)),children:[(0,Q.jsxs)(C,{to:i.href,onClick:t=>{t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(o?.(e.id),i.verify&&a&&(t.preventDefault(),a(e.id)))},"aria-label":c,"aria-current":r?`page`:void 0,className:D(`group flex h-[52px] w-full items-center gap-[10px] rounded-[8px] px-[6px] pr-6 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,r?`bg-sidebar-row-selected`:`hover:bg-sidebar-row-hover`),children:[(0,Q.jsxs)(`span`,{"aria-hidden":`true`,"data-slot":`rail-mark`,className:D(`relative flex size-9 shrink-0 items-center justify-center rounded-[9px] border text-[12px] leading-none font-semibold`,r?`border-soft-foreground bg-sidebar text-foreground`:`border-transparent bg-muted text-muted-foreground`),children:[Sh(e.name),(0,Q.jsx)(zh,{position:`top`,segments:l,className:d}),(0,Q.jsx)(zh,{position:`bottom`,segments:u,className:d})]}),(0,Q.jsxs)(`span`,{className:D(`flex min-w-0 flex-1 flex-col gap-px`,$v),children:[(0,Q.jsx)(`span`,{"data-slot":`rail-project-name`,className:D(`truncate text-[13.5px] leading-[18px] font-semibold`,r?`text-foreground`:`text-muted-foreground`),children:e.name}),(0,Q.jsx)(Ph,{signal:t,known:n,current:r,maxParts:2,slot:`rail-project-state`,className:`h-4 gap-x-[4px] overflow-hidden text-[11px] leading-4 whitespace-nowrap`})]})]}),s?(0,Q.jsx)(ty,{name:e.name,sort:s}):null]})}function ty({name:e,sort:t}){return(0,Q.jsx)(`button`,{type:`button`,ref:t.setActivatorNodeRef,"data-slot":`rail-project-grip`,...t.attributes,"aria-label":`Reorder ${e}, position ${t.position} of ${t.total}`,className:D(`absolute top-1/2 right-0.5 flex h-10 w-5 -translate-y-1/2 cursor-grab touch-none items-center justify-center rounded text-soft-foreground opacity-0 outline-none transition-opacity hover:text-foreground motion-reduce:transition-none`,`focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50`,`group-hover/row:opacity-100 group-focus-within/row:opacity-100 [@media(hover:none)]:opacity-100`),children:(0,Q.jsx)(Iu,{"aria-hidden":`true`,className:`size-3.5`})})}function ny({expanded:e,position:t,total:n,sortable:r,...i}){let{attributes:a,listeners:o,setNodeRef:s,setActivatorNodeRef:c,transform:l,transition:u,isDragging:d}=yc({id:i.project.id,disabled:!r}),f=r?{setNodeRef:s,setActivatorNodeRef:c,style:{transform:Dc.Translate.toString(l),transition:u},listeners:o,attributes:a,isDragging:d,position:t,total:n}:void 0;return e?(0,Q.jsx)(ey,{...i,sort:f}):(0,Q.jsx)(Qv,{...i,sort:f})}var ry=({transform:e})=>({...e,x:0}),iy=class extends gc{static activators=[{eventName:`onPointerDown`,handler:({nativeEvent:e},t)=>e.pointerType!==`touch`&&gc.activators[0].handler({nativeEvent:e},t)}]},ay={delay:250,tolerance:5},oy={start:[hc.Space],cancel:[hc.Esc],end:[hc.Space,hc.Enter,hc.Tab]},sy={droppable:{strategy:Ec.Always}},cy={draggable:`To reorder projects, press Space to pick this project up. Use the up and down arrow keys to move it, Space to drop it, or Escape to cancel.`};function ly(e,t){let[n,r]=Z.useState(null),i=Z.useMemo(()=>{if(n===null||n.base!==e)return e;let t=new Map(e.map(e=>[e.id,e]));return n.ids.flatMap(e=>t.get(e)??[])},[n,e]),a=Z.useMemo(()=>i.map(e=>e.id),[i]),o=pc(vc(iy,{activationConstraint:{distance:6}}),vc(_c,{activationConstraint:ay}),vc(bc,{coordinateGetter:wc,keyboardCodes:oy})),s=Z.useRef(null),c=Z.useCallback(()=>{s.current?.();let e=e=>e.preventDefault();window.addEventListener(`click`,e,!0),s.current=()=>{window.removeEventListener(`click`,e,!0),s.current=null}},[]),l=Z.useCallback(()=>{let e=s.current;window.setTimeout(()=>e?.(),0)},[]);Z.useEffect(()=>()=>s.current?.(),[]);let u=Z.useCallback(n=>{l();let{active:i,over:o}=n;if(!t||o===null||o.id===i.id)return;let s=cv(a,a.indexOf(String(i.id)),a.indexOf(String(o.id)));s.some((e,t)=>e!==a[t])&&(r({base:e,ids:s}),t(s))},[l,e,a,t]);return{projects:i,ids:a,sensors:o,announcements:Z.useMemo(()=>{let e=e=>{let t=a.indexOf(String(e));return{name:i[t]?.name??String(e),position:`position ${t+1} of ${a.length}`}};return{onDragStart:({active:t})=>`Picked up ${e(t.id).name}, ${e(t.id).position}.`,onDragOver:({active:t,over:n})=>n?`${e(t.id).name} moved to ${e(n.id).position}.`:`${e(t.id).name} is not over a drop position.`,onDragEnd:({active:t,over:n})=>n?`${e(t.id).name} dropped at ${e(n.id).position}.`:`${e(t.id).name} dropped. The order is unchanged.`,onDragCancel:({active:t})=>`Reordering cancelled. ${e(t.id).name} returned to ${e(t.id).position}.`}},[a,i]),onDragStart:c,onDragEnd:u,onDragCancel:l}}function uy(e){return D(`flex shrink-0 items-center rounded-[8px] text-soft-foreground hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,e?`size-auto h-9 w-full justify-start gap-3 px-2.5 text-[13px] font-normal`:`size-9 justify-center`)}var dy=D(`truncate text-muted-foreground group-hover:text-foreground`,$v);function fy({to:e,label:t,slot:n,active:r,expanded:i,children:a}){return(0,Q.jsxs)(C,{to:e,"data-slot":n,"aria-label":t,title:i?void 0:t,"aria-current":r?`page`:void 0,className:D(`group`,uy(i),r&&`bg-sidebar-row-selected text-foreground hover:bg-sidebar-row-selected`),children:[a,i?(0,Q.jsx)(`span`,{className:dy,children:t}):null]})}function py(e){let[t,n]=Z.useState(()=>window.innerWidth);return Z.useEffect(()=>{let e=()=>n(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),Jv(t,e)}function my(){let e=py(Z.useContext(md));return(0,Q.jsx)(`div`,{"aria-hidden":`true`,"data-slot":`project-rail-placeholder`,style:{width:Yv()&&e?232:60},className:`hidden shrink-0 border-r border-border bg-background md:block`})}var hy=e=>({href:String(gs(e,`/`)),verify:!1});function gy({expanded:e,resolvedTheme:t,version:n}){let r=n?`${a(`Cezarion`)} v${n}`:a(`Cezarion`);return e?(0,Q.jsxs)(`div`,{"data-slot":`rail-identity`,className:`flex shrink-0 flex-col gap-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex h-[34px] items-center gap-[10px] px-0.5`,children:[(0,Q.jsx)(`img`,{src:`/cezarion-mark-${t}.svg`,alt:``,"aria-hidden":`true`,"data-slot":`rail-app-mark`,className:`size-[34px] shrink-0 rounded-[8px]`}),(0,Q.jsxs)(`span`,{className:D(`flex min-w-0 items-baseline gap-[10px] whitespace-nowrap`,$v),"aria-label":r,children:[(0,Q.jsx)(`span`,{className:`text-[15px] leading-none font-bold text-foreground`,children:a(`Cezarion`)}),n?(0,Q.jsxs)(`span`,{"data-slot":`rail-version`,title:`v${n}`,className:`min-w-0 truncate text-[11px] leading-none text-soft-foreground`,children:[`v`,n]}):null]})]}),(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:`h-px w-full bg-border`}),(0,Q.jsx)(`div`,{className:D(`px-1 pt-2.5 pb-1 text-[11px] font-medium text-soft-foreground`,$v),children:`Projects`})]}):(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center gap-0.5`,children:[(0,Q.jsx)(`img`,{src:`/cezarion-mark-${t}.svg`,alt:r,title:r,"data-slot":`rail-app-mark`,className:`size-[34px] rounded-[9px]`}),(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:`mt-0.5 mb-1.5 h-px w-6 bg-border`})]})}function _y({expanded:e}){return e?(0,Q.jsx)(ah,{origin:`rail`,icon:Bi,iconClassName:`size-[15px] text-soft-foreground`,iconFrameClassName:`flex size-9 shrink-0 items-center justify-center rounded-[9px] border border-border`,label:`Add project`,side:`right`,triggerClassName:D(`h-[44px] w-full shrink-0 justify-start gap-[10px] rounded-[8px] px-[6px] text-[13px] font-normal text-muted-foreground hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring motion-safe:[&>span:last-child]:rail-text-in`)}):(0,Q.jsx)(ah,{origin:`rail`,icon:Bi,iconClassName:`size-[15px]`,side:`right`,triggerClassName:`shrink-0 rounded-[9px] border border-border text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`})}function vy({roomToExpand:e,expanded:t,toggle:n,railId:r,allProjectsActive:i,settingsActive:a}){return(0,Q.jsxs)(`div`,{"data-slot":`rail-bottom`,className:D(`flex shrink-0 flex-col gap-0.5 pt-2`,t?`items-stretch`:`items-center`),children:[e?(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`rail-expand-toggle`,"aria-expanded":t,"aria-controls":r,"aria-label":t?`Collapse projects`:`Expand projects`,title:t?void 0:`Expand projects`,onClick:n,className:D(`group`,uy(t)),children:[t?(0,Q.jsx)(Ku,{className:`size-4 shrink-0`,"aria-hidden":`true`}):(0,Q.jsx)(qu,{className:`size-4 shrink-0`,"aria-hidden":`true`}),t?(0,Q.jsx)(`span`,{className:dy,children:`Collapse`}):null]}):null,(0,Q.jsx)(fy,{to:`/tasks`,label:`All projects`,slot:`rail-all-projects`,active:i,expanded:t,children:(0,Q.jsx)(Ti,{className:`size-4 shrink-0`,"aria-hidden":`true`})}),(0,Q.jsx)(fy,{to:`/settings/global/appearance`,label:`Global settings`,slot:`rail-global-settings`,active:a,expanded:t,children:(0,Q.jsx)(Ci,{className:`size-4 shrink-0`,"aria-hidden":`true`})}),(0,Q.jsx)(rg,{showLabel:t,labelClassName:dy,className:D(`group`,uy(t),`[&_svg]:size-4`)})]})}function yy({projects:e,signals:n,version:r,projectTarget:i=hy,onSwitchProject:a,onSelectProject:o,canReorder:s=!1,onReorder:c}){let{pathname:l}=t(),{resolvedTheme:u}=eg(),d=Z.useContext(md),[f,p]=Z.useState(Yv),m=py(d),h=f&&m,g=()=>{let e=!h;p(e),Xv(e)},_=vs(l),v=l===`/tasks`,y=l===`/settings/global`||l.startsWith(`/settings/global/`),b=Z.useId(),x=ly(e,c),S=s&&c!==void 0&&e.length>1;return(0,Q.jsxs)(`nav`,{id:b,"aria-label":`Projects`,"data-slot":`project-rail`,"data-expanded":h?`true`:`false`,style:{width:h?232:60},className:D(`hidden shrink-0 flex-col overflow-hidden border-r border-border bg-background pt-3 pb-3.5 transition-[width] duration-[160ms] ease-out motion-reduce:transition-none md:flex`,h?`items-stretch px-2.5`:`items-center`),children:[(0,Q.jsx)(gy,{expanded:h,resolvedTheme:u,version:r}),(0,Q.jsxs)(`div`,{"data-slot":`rail-projects`,className:D(`flex min-h-0 w-full flex-1 flex-col gap-0.5 overflow-y-auto overscroll-contain [scrollbar-width:none]`,h?`items-stretch`:`items-center`),children:[(0,Q.jsx)(Sc,{sensors:x.sensors,collisionDetection:Cc,measuring:sy,modifiers:[ry],accessibility:{announcements:x.announcements,screenReaderInstructions:cy},onDragStart:x.onDragStart,onDragEnd:x.onDragEnd,onDragCancel:x.onDragCancel,children:(0,Q.jsx)(Tc,{items:x.ids,strategy:mc,disabled:!S,children:x.projects.map((e,t)=>(0,Q.jsx)(ny,{expanded:h,sortable:S,position:t+1,total:x.projects.length,project:e,signal:n?.get(e.id),known:n!==null,current:e.id===_,target:i(e.id),onSwitchProject:a,onSelectProject:o},e.id))})}),(0,Q.jsx)(_y,{expanded:h})]}),(0,Q.jsx)(vy,{roomToExpand:m,expanded:h,toggle:g,railId:b,allProjectsActive:v,settingsActive:y})]})}function by(){let e=L(),t=An().data?.projects,{order:n,canReorder:r,setOrder:i}=uv(),a=r&&t!==void 0&&av(t.length),o=Z.useMemo(()=>t?sv(t,n):void 0,[t,n]),s=mn().data,c=Z.useMemo(()=>s?vh(s.runs):null,[s]),l=t?.map(e=>e.id).sort().join(`
3
3
  `),u=Z.useRef(void 0);return Z.useEffect(()=>{if(l===void 0)return;let t=u.current;if(u.current=l,t===void 0||t===l)return;let n=new Set(t.split(`
4
4
  `)),r=new Set(l.split(`
@@ -13,5 +13,5 @@ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,D as n,E as r,I
13
13
  `)}\n}`},o=document.createElement(`style`);o.setAttribute(`type`,`text/tailwindcss`),document.currentScript?.before(o);let s={};Object.defineProperty(globalThis,"tailwind",{configurable:!0,value:{get config(){return s},set config(e){s=e,o.textContent=a(e)}}})}var mD=`(${pD.toString()})()`,hD=[`@import "tailwindcss/theme.css";@import "tailwindcss/preflight.css";@import "tailwindcss/utilities.css";`,`@theme{`,`--color-slate-50:#f8fafc;--color-slate-100:#f1f5f9;--color-slate-200:#e2e8f0;--color-slate-300:#cbd5e1;--color-slate-400:#94a3b8;--color-slate-500:#64748b;--color-slate-600:#475569;--color-slate-700:#334155;--color-slate-800:#1e293b;--color-slate-900:#0f172a;--color-slate-950:#020617;`,`--color-gray-50:#f9fafb;--color-gray-100:#f3f4f6;--color-gray-200:#e5e7eb;--color-gray-300:#d1d5db;--color-gray-400:#9ca3af;--color-gray-500:#6b7280;--color-gray-600:#4b5563;--color-gray-700:#374151;--color-gray-800:#1f2937;--color-gray-900:#111827;--color-gray-950:#030712;`,`--color-zinc-50:#fafafa;--color-zinc-100:#f4f4f5;--color-zinc-200:#e4e4e7;--color-zinc-300:#d4d4d8;--color-zinc-400:#a1a1aa;--color-zinc-500:#71717a;--color-zinc-600:#52525b;--color-zinc-700:#3f3f46;--color-zinc-800:#27272a;--color-zinc-900:#18181b;--color-zinc-950:#09090b;`,`--color-neutral-50:#fafafa;--color-neutral-100:#f5f5f5;--color-neutral-200:#e5e5e5;--color-neutral-300:#d4d4d4;--color-neutral-400:#a3a3a3;--color-neutral-500:#737373;--color-neutral-600:#525252;--color-neutral-700:#404040;--color-neutral-800:#262626;--color-neutral-900:#171717;--color-neutral-950:#0a0a0a;`,`--color-stone-50:#fafaf9;--color-stone-100:#f5f5f4;--color-stone-200:#e7e5e4;--color-stone-300:#d6d3d1;--color-stone-400:#a8a29e;--color-stone-500:#78716c;--color-stone-600:#57534e;--color-stone-700:#44403c;--color-stone-800:#292524;--color-stone-900:#1c1917;--color-stone-950:#0c0a09;`,`--color-red-50:#fef2f2;--color-red-100:#fee2e2;--color-red-200:#fecaca;--color-red-300:#fca5a5;--color-red-400:#f87171;--color-red-500:#ef4444;--color-red-600:#dc2626;--color-red-700:#b91c1c;--color-red-800:#991b1b;--color-red-900:#7f1d1d;--color-red-950:#450a0a;`,`--color-orange-50:#fff7ed;--color-orange-100:#ffedd5;--color-orange-200:#fed7aa;--color-orange-300:#fdba74;--color-orange-400:#fb923c;--color-orange-500:#f97316;--color-orange-600:#ea580c;--color-orange-700:#c2410c;--color-orange-800:#9a3412;--color-orange-900:#7c2d12;--color-orange-950:#431407;`,`--color-amber-50:#fffbeb;--color-amber-100:#fef3c7;--color-amber-200:#fde68a;--color-amber-300:#fcd34d;--color-amber-400:#fbbf24;--color-amber-500:#f59e0b;--color-amber-600:#d97706;--color-amber-700:#b45309;--color-amber-800:#92400e;--color-amber-900:#78350f;--color-amber-950:#451a03;`,`--color-yellow-50:#fefce8;--color-yellow-100:#fef9c3;--color-yellow-200:#fef08a;--color-yellow-300:#fde047;--color-yellow-400:#facc15;--color-yellow-500:#eab308;--color-yellow-600:#ca8a04;--color-yellow-700:#a16207;--color-yellow-800:#854d0e;--color-yellow-900:#713f12;--color-yellow-950:#422006;`,`--color-lime-50:#f7fee7;--color-lime-100:#ecfccb;--color-lime-200:#d9f99d;--color-lime-300:#bef264;--color-lime-400:#a3e635;--color-lime-500:#84cc16;--color-lime-600:#65a30d;--color-lime-700:#4d7c0f;--color-lime-800:#3f6212;--color-lime-900:#365314;--color-lime-950:#1a2e05;`,`--color-green-50:#f0fdf4;--color-green-100:#dcfce7;--color-green-200:#bbf7d0;--color-green-300:#86efac;--color-green-400:#4ade80;--color-green-500:#22c55e;--color-green-600:#16a34a;--color-green-700:#15803d;--color-green-800:#166534;--color-green-900:#14532d;--color-green-950:#052e16;`,`--color-emerald-50:#ecfdf5;--color-emerald-100:#d1fae5;--color-emerald-200:#a7f3d0;--color-emerald-300:#6ee7b7;--color-emerald-400:#34d399;--color-emerald-500:#10b981;--color-emerald-600:#059669;--color-emerald-700:#047857;--color-emerald-800:#065f46;--color-emerald-900:#064e3b;--color-emerald-950:#022c22;`,`--color-teal-50:#f0fdfa;--color-teal-100:#ccfbf1;--color-teal-200:#99f6e4;--color-teal-300:#5eead4;--color-teal-400:#2dd4bf;--color-teal-500:#14b8a6;--color-teal-600:#0d9488;--color-teal-700:#0f766e;--color-teal-800:#115e59;--color-teal-900:#134e4a;--color-teal-950:#042f2e;`,`--color-cyan-50:#ecfeff;--color-cyan-100:#cffafe;--color-cyan-200:#a5f3fc;--color-cyan-300:#67e8f9;--color-cyan-400:#22d3ee;--color-cyan-500:#06b6d4;--color-cyan-600:#0891b2;--color-cyan-700:#0e7490;--color-cyan-800:#155e75;--color-cyan-900:#164e63;--color-cyan-950:#083344;`,`--color-sky-50:#f0f9ff;--color-sky-100:#e0f2fe;--color-sky-200:#bae6fd;--color-sky-300:#7dd3fc;--color-sky-400:#38bdf8;--color-sky-500:#0ea5e9;--color-sky-600:#0284c7;--color-sky-700:#0369a1;--color-sky-800:#075985;--color-sky-900:#0c4a6e;--color-sky-950:#082f49;`,`--color-blue-50:#eff6ff;--color-blue-100:#dbeafe;--color-blue-200:#bfdbfe;--color-blue-300:#93c5fd;--color-blue-400:#60a5fa;--color-blue-500:#3b82f6;--color-blue-600:#2563eb;--color-blue-700:#1d4ed8;--color-blue-800:#1e40af;--color-blue-900:#1e3a8a;--color-blue-950:#172554;`,`--color-indigo-50:#eef2ff;--color-indigo-100:#e0e7ff;--color-indigo-200:#c7d2fe;--color-indigo-300:#a5b4fc;--color-indigo-400:#818cf8;--color-indigo-500:#6366f1;--color-indigo-600:#4f46e5;--color-indigo-700:#4338ca;--color-indigo-800:#3730a3;--color-indigo-900:#312e81;--color-indigo-950:#1e1b4b;`,`--color-violet-50:#f5f3ff;--color-violet-100:#ede9fe;--color-violet-200:#ddd6fe;--color-violet-300:#c4b5fd;--color-violet-400:#a78bfa;--color-violet-500:#8b5cf6;--color-violet-600:#7c3aed;--color-violet-700:#6d28d9;--color-violet-800:#5b21b6;--color-violet-900:#4c1d95;--color-violet-950:#2e1065;`,`--color-purple-50:#faf5ff;--color-purple-100:#f3e8ff;--color-purple-200:#e9d5ff;--color-purple-300:#d8b4fe;--color-purple-400:#c084fc;--color-purple-500:#a855f7;--color-purple-600:#9333ea;--color-purple-700:#7e22ce;--color-purple-800:#6b21a8;--color-purple-900:#581c87;--color-purple-950:#3b0764;`,`--color-fuchsia-50:#fdf4ff;--color-fuchsia-100:#fae8ff;--color-fuchsia-200:#f5d0fe;--color-fuchsia-300:#f0abfc;--color-fuchsia-400:#e879f9;--color-fuchsia-500:#d946ef;--color-fuchsia-600:#c026d3;--color-fuchsia-700:#a21caf;--color-fuchsia-800:#86198f;--color-fuchsia-900:#701a75;--color-fuchsia-950:#4a044e;`,`--color-pink-50:#fdf2f8;--color-pink-100:#fce7f3;--color-pink-200:#fbcfe8;--color-pink-300:#f9a8d4;--color-pink-400:#f472b6;--color-pink-500:#ec4899;--color-pink-600:#db2777;--color-pink-700:#be185d;--color-pink-800:#9d174d;--color-pink-900:#831843;--color-pink-950:#500724;`,`--color-rose-50:#fff1f2;--color-rose-100:#ffe4e6;--color-rose-200:#fecdd3;--color-rose-300:#fda4af;--color-rose-400:#fb7185;--color-rose-500:#f43f5e;--color-rose-600:#e11d48;--color-rose-700:#be123c;--color-rose-800:#9f1239;--color-rose-900:#881337;--color-rose-950:#4c0519;`,`--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";`,`--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;`,`--text-xs--line-height:1rem;--text-sm--line-height:1.25rem;--text-base--line-height:1.5rem;--text-lg--line-height:1.75rem;`,`--text-xl--line-height:1.75rem;--text-2xl--line-height:2rem;--text-3xl--line-height:2.25rem;--text-4xl--line-height:2.5rem;`,`--shadow-sm:0 1px 2px 0 rgb(0 0 0 / 0.05);--radius-sm:0.125rem;--blur-sm:4px;`,`}`,`body{line-height:inherit}`,`*,::after,::before,::backdrop,::file-selector-button{border-color:var(--color-gray-200,currentColor)}`,`input::placeholder,textarea::placeholder{color:var(--color-gray-400)}`,`button:not(:disabled),[role="button"]:not(:disabled){cursor:pointer}`].join(`
14
14
  `),gD=`default-src 'none'; script-src 'unsafe-inline' data:; img-src data:; media-src data:; font-src data:; style-src 'unsafe-inline' data:; form-action 'none'; base-uri 'none'`,_D=`${gD}; frame-src 'none'`,vD=`allow-scripts allow-popups allow-popups-to-escape-sandbox`,yD=`clipboard-write`,bD=`data:text/javascript,export%20default%20globalThis.mermaid`;function xD(e){return/\.html?$/i.test(e)}var SD=/^(?:https?:|mailto:)/i,CD=/^data:/i,wD=`http://www.w3.org/1999/xlink`,TD=/^(?:[a-z][a-z\d+.-]*:|\/\/)/i,ED=/url\(\s*(['"]?)([^'")]*)\1\s*\)|@import\s+(['"])([^'"]+)\3/gi,DD=[`src`,`href`,`xlink:href`,`poster`,`background`],OD=/(?:^|,)\s*(data:\S+|[^,\s]+)/gi,kD=/\b(?:preconnect|dns-prefetch|prefetch|preload|modulepreload|prerender)\b/i;function AD(e,t){let n=e.trim();!n||n.startsWith(`#`)||CD.test(n)||(TD.test(n)?t.remote++:t.relative++)}function jD(e,t){for(let n of e.matchAll(ED))AD(n[2]??n[4]??``,t)}function MD(e,t){let n=e.createElement(`script`);return n.textContent=t.replace(/<\/script/gi,`<\\/script`),n}function ND(e,t){let n=e.createElement(`style`);return n.setAttribute(`type`,`text/tailwindcss`),n.textContent=t,n}var PD=`http://www.w3.org/2000/svg`;function FD(e){return e.namespaceURI===PD?e.getAttribute(`href`)??e.getAttributeNS(wD,`href`):e.getAttribute(`src`)}function ID(e,t,n,r){let i=r===void 0?[]:[ND(e,r),MD(e,mD)],a=MD(e,n),o=t.hasAttribute(`defer`)||t.hasAttribute(`async`)||t.getAttribute(`type`)===`module`;o&&e.body.append(a),t.replaceWith(...i,...o?[]:[a])}function LD(e,t,n){let r=new Set,i=new Set;for(let a of[...e.querySelectorAll(`script`)]){let o=FD(a);if(o!==null&&CD.test(o.trim()))continue;if(o===null){if(a.getAttribute(`type`)===`module`)for(let e of(a.textContent??``).matchAll(cD))i.add(e[2]);continue}let s=lD(o),c=s===`tailwind-v3`?`tailwind`:s,l=c?n[c]:void 0;if(!c||l===void 0||s===`tailwind-v3`&&n[`tailwind-v3`]===void 0){t.scripts++,a.remove();continue}if(r.has(c)){a.remove();continue}r.add(c),ID(e,a,l,s===`tailwind-v3`?n[`tailwind-v3`]:void 0)}if(!i.size)return;if(n.mermaid===void 0){t.scripts+=i.size;return}let a=e.createElement(`script`);a.setAttribute(`type`,`importmap`),a.textContent=JSON.stringify({imports:Object.fromEntries([...i].map(e=>[e,bD]))}),e.head.prepend(a,...r.has(`mermaid`)?[]:[MD(e,n.mermaid)])}function RD(e,t,n){let r=t=>{let n=[...e.querySelectorAll(t)];return n.forEach(e=>e.remove()),n.length};LD(e,t,n),t.embeds=r(`iframe, frame, frameset, object, embed, portal`),r(`base, meta[http-equiv]`);for(let t of e.querySelectorAll(`link`))kD.test(t.getAttribute(`rel`)??``)&&t.remove();for(let t of e.querySelectorAll(`[ping]`))t.removeAttribute(`ping`);for(let n of e.querySelectorAll(`form`))t.forms++,n.removeAttribute(`action`);for(let t of e.querySelectorAll(`[formaction]`))t.removeAttribute(`formaction`)}function zD(e,t){for(let n of e.querySelectorAll(`a, area`)){let e=n.getAttribute(`href`)??n.getAttributeNS(wD,`href`);if(e===null)continue;let r=e.trim();if(r.startsWith(`#`)){n.setAttribute(`href`,`about:srcdoc${r}`),n.removeAttributeNS(wD,`href`),n.removeAttribute(`target`);continue}if(SD.test(r)){n.setAttribute(`target`,`_blank`),n.setAttribute(`rel`,`noopener noreferrer`);continue}TD.test(r)||t.relative++,n.removeAttribute(`href`),n.removeAttributeNS(wD,`href`),n.removeAttribute(`target`)}}function BD(e,t){for(let n of e.querySelectorAll(`[style]`))jD(n.getAttribute(`style`),t);for(let n of e.querySelectorAll(`style`))/^(?:text\/css)?$/i.test(n.getAttribute(`type`)?.trim()??``)&&jD(n.textContent??``,t);for(let n of e.querySelectorAll(`link[href]`))AD(n.getAttribute(`href`),t);for(let n of e.querySelectorAll(`img, source, video, audio, track, input, image, use, body, table, td`)){for(let e of DD){let r=n.getAttribute(e);r!==null&&AD(r,t)}for(let e of(n.getAttribute(`srcset`)??``).matchAll(OD))AD(e[1],t)}}function VD(e,t={}){let n=new DOMParser().parseFromString(e,`text/html`),r={scripts:0,remote:0,relative:0,forms:0,embeds:0};RD(n,r,t),zD(n,r),BD(n,r);let i=n.createElement(`meta`);i.setAttribute(`http-equiv`,`Content-Security-Policy`),i.setAttribute(`content`,gD);let a=n.createElement(`meta`);return a.setAttribute(`name`,`referrer`),a.setAttribute(`content`,`no-referrer`),n.head.prepend(i,a),{srcdoc:`<!DOCTYPE html>${n.documentElement.outerHTML}`,blocked:r}}var HD=e=>e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`);function UD(e,t){return`<!DOCTYPE html><html><head><meta http-equiv="Content-Security-Policy" content="${_D}"><meta name="referrer" content="no-referrer"><style>html,body{margin:0;height:100%;overflow:hidden}iframe{display:block;border:0;width:100%;height:100%}</style></head><body><iframe title="${HD(t)}" sandbox="${vD}" allow="${yD}" referrerpolicy="no-referrer" srcdoc="${HD(e)}"></iframe></body></html>`}var WD=(0,Z.createContext)(null),GD=/^[0-9a-f-]{36}$/i,KD=/^(\/p\/[^/?#]+\/tasks\/[^/?#]+)\/files\?(artifact=[^&#]*)$/;function qD(e){let t=new URLSearchParams(e);return[...t.keys()].length===1&&GD.test(t.get(`artifact`)??``)}function JD(e,t,n){if(e.startsWith(`${t}?artifact=`))return qD(e.slice(t.length+1))?n+e.slice(t.length):null;let r=KD.exec(e);return r&&qD(r[2])?`${r[1]}/report?${r[2]}`:void 0}var YD=/^\/(?:api|p|tasks|new|settings|skills|workflows|git|github|inbox|automations)(?:\/|[?#]|$)/;function XD(e,t){let n=/^[a-z]:[\\/]/i.test(e),r=/^file:/i.test(e);if(!n&&/^[a-z][a-z\d+.-]*:/i.test(e)&&!r)return null;let i=r?e:decodeURIComponent(e);if(/[\u0000-\u001f]/.test(i))return null;if(!t||i.startsWith(`/`)||n||r)return i;let a=t.replaceAll(`\\`,`/`);return a.slice(0,a.lastIndexOf(`/`)+1)+i}function ZD(e,t){if(!e||/[\u0000-\u001f]/.test(e)||e.startsWith(`#`)||e.startsWith(`//`))return null;let n=e.indexOf(`#`),r=n<0?e:e.slice(0,n),i=n<0?``:e.slice(n),a=t.projectId?`/p/${encodeURIComponent(t.projectId)}`:``,o=`/tasks/${encodeURIComponent(t.runId)}/files`,s=`/tasks/${encodeURIComponent(t.runId)}/report`,c=JD(r,o,a+s);if(c!==void 0)return c===null?null:c+i;if(YD.test(r))return null;let l=XD(r,t.basePath);return l===null?null:`${a}${xD(l)?s:o}?path=${encodeURIComponent(l)}${i}`}var QD=`text-accent-text underline underline-offset-2`;function $D({href:e,children:t,internal:n,...r}){let[i,a]=(0,Z.useState)(!1),o=l();return e?n?o?(0,Q.jsx)(eO,{...r,href:e,children:t}):(0,Q.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:QD,children:t}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:`cursor-pointer ${QD}`,onClick:e=>{e.preventDefault(),a(!0)},children:t}),(0,Q.jsx)(aD,{isOpen:i,url:e,onClose:()=>a(!1),onConfirm:()=>{window.open(e,`_blank`,`noreferrer`),a(!1)}})]}):(0,Q.jsx)(`span`,{children:t})}function eO({href:e,children:n,...r}){let i=k(),a=t();return(0,Q.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:QD,onClick:t=>tO(t,i,e,a),children:n})}function tO(e,t,n,r){e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t(n,{state:{readerFrom:r.pathname+r.search,filesRestoreKey:r.key}}))}var nO={name:`shiki`,type:`code-highlighter`,getThemes:()=>[jS,jS],getSupportedLanguages:()=>LS(),supportsLanguage:e=>LS().includes(String(e).toLowerCase()),highlight:({code:e,language:t},n)=>WS(e,String(t))||(GS(e,String(t)).then(e=>n?.(e)),null)};function rO(){let e=t=>{if(!t.children)return;let n=[];for(let r of t.children)if(r.type===`text`&&r.value?.includes(`
15
15
  `)){let e=r.value.split(/\r?\n/);e.forEach((t,r)=>{r>0&&!(t===``&&r===e.length-1)&&n.push({type:`break`}),t&&n.push({type:`text`,value:t})})}else e(r),n.push(r);t.children=n};return e}var iO=[...Object.values(zc),rO],aO=[`p`,`strong`,`em`,`del`,`code`,`a`],oO={p:`span`,a:`span`},sO={enabled:!0,renderModal:e=>(0,Q.jsx)(aD,{...e})},cO=`https://refused.invalid/`,lO=0,uO=(0,Z.memo)(function({children:e,breaks:t=!1,inline:n=!1,document:r=!1,imageSrc:i}){let a=(0,Z.useContext)(WD),o=(0,Z.useMemo)(()=>{let e={instance:++lO},n=new Set;function o(){let e=t=>{if((t.type===`link`||t.type===`definition`)&&t.url&&a){let e=ZD(t.url,a);e&&(t.url=e,n.add(e))}t.children?.forEach(e)};return e}let s=new Set;function c(){let e=t=>{if(t.type===`image`&&t.url&&i){let e=i(t.url);t.url=e?new URL(e,window.location.href).href:cO,e&&s.add(t.url)}t.children?.forEach(e)};return e}let l=a?[[o,e]]:[],u=r&&i?[[c,e]]:[];return{remark:[...t?iO:Object.values(zc),...l,...u],components:{...a||r?{a:({href:e,children:t})=>r&&!a&&!/^(?:https?:|mailto:|#)/i.test(e??``)?(0,Q.jsx)(`span`,{children:t}):(0,Q.jsx)($D,{href:e,internal:n.has(e??``),children:t})}:{},...r?{img:({src:e,alt:t})=>typeof e==`string`&&s.has(e)?(0,Q.jsx)(`img`,{src:e,alt:t??``,loading:`lazy`}):(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[`[Image: `,t||`embedded image`,`]`]})}:{}}}},[a,t,r,i]);return(0,Q.jsx)(Rc,{className:n?`thread-markdown thread-markdown-inline`:`thread-markdown`,plugins:{code:nO},shikiTheme:[jS,jS],...x({remarkPlugins:a||r&&i?o.remark:t?iO:void 0,allowedElements:n?aO:void 0,unwrapDisallowed:n||void 0,components:n?oO:a||r?o.components:void 0}),linkSafety:sO,controls:{code:{copy:!0,download:!1},table:!1,mermaid:!1},lineNumbers:!1,children:e})});function dO({source:e,className:t}){return(0,Q.jsx)(`span`,{"data-slot":`skill-source`,"data-source":e,className:D(`shrink-0 rounded bg-accent-strong/10 px-2 py-1 text-[12px]`,jc({source:e})?`font-semibold text-foreground`:`text-soft-foreground`,t),children:e===`team`?`Team`:e})}function fO({skill:e,activation:t}){return(0,Q.jsx)(`span`,{className:`inline-flex min-h-11 min-w-11 shrink-0 items-center justify-center`,children:(0,Q.jsx)(Um,{"data-slot":`skill-switch`,"data-skill":e.name,"data-repo":e.team?.repo,"data-locked":t.locked||void 0,"aria-label":t.ariaLabel,checked:t.checked,disabled:t.disabled,onCheckedChange:()=>t.onCheckedChange(),className:`relative before:absolute before:-inset-x-1 before:-inset-y-2.5 before:content-[''] disabled:cursor-default`})})}function pO({skill:e,usedBy:t,activation:n,heading:r=`h2`}){return(0,Q.jsxs)(`div`,{"data-slot":`skill-detail`,className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start gap-4`,children:[(0,Q.jsxs)(`span`,{className:`sw-detail-source text-[12px]`,children:[(0,Q.jsx)(dO,{source:e.source}),` skill`]}),(0,Q.jsxs)(`div`,{className:`flex w-full min-w-0 items-start justify-between gap-3`,children:[(0,Q.jsx)(r,{className:`min-w-0 text-[19px] font-normal md:text-2xl break-words [overflow-wrap:anywhere]`,children:e.name}),n?(0,Q.jsx)(fO,{skill:e,activation:n}):null]})]}),n&&!n.checked?(0,Q.jsx)(`p`,{"data-slot":`skill-inactive-notice`,className:`mt-4 rounded-md border border-border bg-background px-3 py-2 text-[13px] text-muted-foreground`,children:`Not enabled for this project — agents can’t pick it.`}):null,(0,Q.jsxs)(`p`,{"data-slot":`skill-path`,className:`mt-4 text-[12px] 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-[13px] text-muted-foreground`,children:e.description}):null,t===void 0?null:(0,Q.jsxs)(`section`,{"data-slot":`skill-used-by`,className:`mt-5`,children:[(0,Q.jsx)(`h3`,{className:`text-[13px] font-semibold`,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)(ea,{"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 a workflow yet. quick-task can use it when the task mentions it.`})]}),(0,Q.jsx)(`section`,{className:`mt-5`,children:(0,Q.jsx)(`div`,{"data-slot":`skill-body`,className:`mt-2 text-sm`,children:(0,Q.jsx)(uO,{children:e.body})})})]})}function mO({skill:e,onClose:t}){return(0,Q.jsx)(ts,{open:e!==null,onOpenChange:e=>e?void 0:t(),children:(0,Q.jsx)($o,{"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)(es,{className:`sr-only`,children:e.name}),(0,Q.jsx)(Xo,{className:`sr-only`,children:`Read-only skill preview`}),(0,Q.jsx)(pO,{skill:e,heading:`h3`}),(0,Q.jsx)(`p`,{className:`mt-5`,children:(0,Q.jsx)(Y,{to:`/skills?skill=${encodeURIComponent(e.name)}`,"data-slot":`skill-preview-manage`,onClick:t,className:`text-xs font-semibold text-accent-text hover:underline`,children:`Open in the Skills catalog`})})]}):null})})}function hO(e){try{let t=new URL(e),n=t.pathname===`/`?``:t.pathname.replace(/\/$/,``);return`${t.host}${n}`||e}catch{return e}}function gO(e){return e?e.webhooks?e.webhooks.filter(e=>e.tasks).map(({id:e,name:t,url:n})=>({id:e,name:t,url:n})):e.webhook?[{id:`task-webhook`,name:`Task webhook`,url:e.webhook.url}]:[]:[]}function _O(e){let t=e.map(e=>e.name);return t.length<=2?t.join(` and `):t.length===3?`${t[0]}, ${t[1]} and ${t[2]}`:`${t[0]}, ${t[1]} and ${t.length-2} more`}function vO(e){return e===``?{message:`Prefilled from link — review and press Start`,tone:`default`}:{message:`Unknown skill "${e}" — prefilled for quick-task; review and press Start`,tone:`danger`}}function yO(e,t){return`Use the "${e}" skill on: ${t}`}function bO(e){let t=e.configuredAutonomous===`source-dependent`?e.source===`skill`:e.configuredAutonomous,n=e.interactive!==!0&&void 0;return{autonomous:e.planFirst?!1:e.explicitAutonomous??n??t,worktree:e.hasGit?e.explicitWorktree??n??e.configuredWorktree:!1}}function xO(e){return e.worktree?`Runs in an isolated worktree — review everything before it lands.`:e.hasGit?`Runs in the repo working tree — your checkout is modified directly.`:`Runs in place — no git repository detected, so there is no worktree to isolate in.`}var SO={text:``,source:null,runner:null,agentProfile:null,model:null,effort:null,planFirst:!1,worktree:null,autonomous:null,archiveWhenDone:!1,autoMergePr:!1,allowWorkers:!0,allowMessaging:!0},CO=`cez-new-task-draft`;function wO(e){return e===null?CO:`${CO}:${e}`}function TO(e){let t=e&&typeof e==`object`?e:{};return{text:typeof t.text==`string`?t.text:``,source:EO(t.source)?t.source:null,runner:typeof t.runner==`string`?t.runner:null,agentProfile:typeof t.agentProfile==`string`?t.agentProfile:null,model:typeof t.model==`string`?t.model:null,effort:typeof t.effort==`string`?t.effort:null,planFirst:t.planFirst===!0,worktree:typeof t.worktree==`boolean`?t.worktree:null,autonomous:typeof t.autonomous==`boolean`?t.autonomous:null,archiveWhenDone:t.archiveWhenDone===!0,autoMergePr:t.autoMergePr===!0,allowWorkers:t.allowWorkers!==!1,allowMessaging:t.allowMessaging!==!1}}function EO(e){return!!e&&typeof e==`object`&&(e.source===`skill`||e.source===`workflow`)&&typeof e.ref==`string`}var DO=new Map,OO=new Map;function kO(e=null){return OO.get(wO(e))??0}function AO(e=null){let t=wO(e),n=DO.get(t);if(n)return{...n};let r;try{let e=localStorage.getItem(t);r=e?TO(JSON.parse(e)):{...SO}}catch{r={...SO}}return DO.set(t,r),{...r}}function jO(e,t=null){let n=wO(t);OO.set(n,kO(t)+1),DO.set(n,{...e});try{localStorage.setItem(n,JSON.stringify(e))}catch{}}function MO(e=null,t){t!==void 0&&kO(e)!==t||jO({...AO(e),text:``,source:null},e)}function NO(e,t,n){return{task:e,steps:[...n.steps],rationale:n.rationale,fallback:n.fallback,images:[...t]}}function PO(e,t){return!Number.isInteger(t)||t<0||t>=e.length?[...e]:e.filter((e,n)=>n!==t)}function FO(e,t,n){let r=[...e];if(!Number.isInteger(t)||t<0||t>=r.length)return r;let i=Math.max(0,Math.min(r.length-1,n));if(i===t)return r;let[a]=r.splice(t,1);return r.splice(i,0,a),r}function IO(e){return e.command??e.prompt??``}function LO(e,t=120){let n=e.split(`
16
- `)[0]??``;return n.length>t?`${n.slice(0,t-1)}…`:n}function RO(e){let{task:t,steps:n,model:r,modelsLocked:i,effort:a,runner:o,runnerExplicit:s,defaultRunner:c,images:l,archiveWhenDone:u,autoMergePr:d,allowWorkers:f,allowMessaging:p}=e;return{task:t,steps:[...n],model:i?void 0:r||void 0,effort:i?void 0:a||void 0,runner:Is(o,c,s),images:l.length>0?[...l]:void 0,...Ts({archiveWhenDone:u,autoMergePr:d,allowWorkers:f,allowMessaging:p})}}function zO(e,t){return{...AO(e),...t.ref===``?{}:{text:t.ref},...t.skill===``?{}:{source:{source:`skill`,ref:t.skill}}}}function BO(e,t){let[n,r]=(0,Z.useState)(()=>zO(e,t)),i=(0,Z.useRef)(n);(0,Z.useEffect)(()=>{jO(i.current,e)},[e]);let a=(0,Z.useRef)(!1),o=(0,Z.useRef)(!0);return(0,Z.useEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]),{draft:n,update:t=>{if(!o.current||a.current)return;let n={...i.current,...t};i.current=n,jO(n,e),r(n)},clearStarted:t=>{if(kO(e)!==t)return;MO(e,t);let n=AO(e);i.current=n,o.current&&r(n)},submissionPending:a,mounted:o}}function VO(e,t){let n=wn(),r=un(),i=r.data,a=t.data?.skillUsage,o=(0,Z.useMemo)(()=>Pc(i??[],a),[i,a]),s=n.data?.workflows??[],c=r.data!==void 0&&n.data!==void 0&&!t.isPending,l=Os(e,o,s);return{skillList:o,skillUsage:a,workflowList:s,sourcesReady:c,source:l,selectedSkill:l?.source===`skill`?o.find(e=>e.name===l.ref):void 0}}function HO(e){let{uiState:t,source:n,sourcesReady:r,draftText:i,submissionPending:a,update:o}=e,s=js(),c=t.data?.promptTemplates,l=(0,Z.useMemo)(()=>Xs(Js(c),{automations:s}),[c,s]),u=ec(l,n?.source===`skill`?[n.ref]:[]),d=(0,Z.useRef)(i);d.current=i;let f=(0,Z.useRef)(``);return(0,Z.useEffect)(()=>{if(!r||a.current)return;let e=rc(d.current,f.current,u);f.current=e.applied,e.text!==d.current&&o({text:e.text})},[u,r]),l}function UO(e,t){let n=sn(),r=Vt(n.data),i=t.data?.defaultRunner,a=i??`claude`,o=r.length>0?ks(e.runner,r,a):null,s=o??a,c=n.isSuccess&&r.length>0,l=xr(s),u=t.data?.modelsLocked===!0,d=t.data?.defaultModels,f=o===null?[]:zs(o,l.data,[e.model,d?.[o]]),p=o===null?``:Bs(u?null:e.model,o,d,l.data),m=Gs(s,p,l.data);return{providers:n,runners:r,defaultRunner:i,runner:o,displayRunner:s,providersReady:c,catalog:l,modelsLocked:u,models:f,model:p,effortOptions:m,effort:u?``:lc(e.effort,m)}}function WO(e,t){let{accounts:n,repoAccount:r}=tc();return{accountChoices:n,repoAccount:r,agentProfile:n.some(n=>n.provider===e&&n.id===t)?t:null}}function GO(e){let t=(0,Z.useRef)(!1),n=(0,Z.useRef)(void 0);(0,Z.useEffect)(()=>{n.current===void 0&&(n.current=document.activeElement);let r=e&&!t.current;t.current=e,r&&(document.activeElement===document.body||document.activeElement===n.current)&&document.querySelector(`textarea[aria-label="Describe a task for the agent"]`)?.focus()},[e])}function KO(e){let t=e.workspaceConfig.data?.composerDefaults;return bO({hasGit:e.hasGit,planFirst:e.draft.planFirst,explicitAutonomous:e.draft.autonomous,explicitWorktree:e.draft.worktree,interactive:e.selectedSkill?.interactive,configuredAutonomous:t?.autonomous??t?.inheritedAutonomous??`source-dependent`,configuredWorktree:t?.worktree??t?.inheritedWorktree??!0,source:e.source?.source??`workflow`})}function qO(e){let t=An(),n=t.data?.projects??[],r=e??t.data?.bootProject,i=gO(n.find(e=>e.id===r)),[a,o]=(0,Z.useState)(!1);return{projectList:n,webhookTargets:i,notifyOn:i.length>0&&a,setNotifyChoice:o}}function JO(e){let[t,n]=(0,Z.useState)(()=>typeof window<`u`&&window.innerWidth<=767);return(0,Z.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=()=>n(window.innerWidth<=767||t.getBoundingClientRect().width<550);r();let i=typeof ResizeObserver>`u`?null:new ResizeObserver(r);return i?.observe(t),window.addEventListener(`resize`,r),()=>{i?.disconnect(),window.removeEventListener(`resize`,r)}},[]),t}function YO(e){let t=_s(),[n,r]=(0,Z.useState)(()=>e.deepLink.ref!==``);XO(e.search,t),ZO({pending:n,setPending:r,deepLink:e.deepLink,sourcesReady:e.sourcesReady,skillList:e.skillList,update:e.update})}function XO(e,t){let n=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{n.current||(n.current=!0,e.toString()!==``&&t(`/new`,{replace:!0}))},[])}function ZO(e){let{pending:t,sourcesReady:n,deepLink:r}=e;(0,Z.useEffect)(()=>{if(!t||!n)return;e.setPending(!1);let i=r.skill!==``&&!e.skillList.some(e=>e.name===r.skill)?r.skill:``;i!==``&&e.update({text:yO(r.skill,r.ref),source:null});let{message:a,tone:o}=vO(i);G(a,{tone:o}),document.querySelector(`[data-slot="composer"] button[aria-label="Start task"], [data-slot="composer"] button[aria-label="Plan task"]`)?.focus()},[t,n])}function QO(e){return e.isPending?`Checking agent providers…`:e.isError?`Provider authentication could not be verified.`:`Connect an agent provider before starting a task.`}function $O(e,t,n){Qe({lastTask:e,...e?{recentSources:Ds(t.data?.recentSources,e)}:{},...e?.source===`skill`&&t.data!==void 0?{skillUsage:Fc(t.data.skillUsage,e.ref)}:{}}).then(()=>n.invalidateQueries({queryKey:H.uiState})).catch(()=>{})}function ek(e){let t=_s(),n=L(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),{draft:l,draftProjectId:u,engine:d,mounted:f}=e,{providers:p,providersReady:m,runner:h}=d,g=(r,i)=>{e.clearStarted(i),n.invalidateQueries({queryKey:H.runs.all}),f.current&&t($s(r))};return{plan:r,setPlan:i,planning:a,starting:s,submit:async(t,r)=>{let a=kO(u);if(!m||h===null)throw Error(QO(p));if(!e.sourcesReady)throw Error(`Still loading workflows and skills — try again in a second.`);if(l.planFirst){o(!0);try{let e=await Ue(t);f.current&&i(NO(t,r,e))}finally{o(!1)}return}let s=await ae(Qs(dc({task:t,source:e.source,model:d.model,modelsLocked:d.modelsLocked,effort:d.effort,runner:h,runnerExplicit:l.runner!==null,agentProfile:e.agentProfile,defaultRunner:d.defaultRunner,images:r,worktree:e.runMode.worktree,autonomous:e.runMode.autonomous,archiveWhenDone:l.archiveWhenDone,autoMergePr:l.autoMergePr,allowWorkers:l.allowWorkers,allowMessaging:l.allowMessaging}),e.notifyOn));$O(e.source,e.uiState,n),g(s,a)},startPlanned:async()=>{if(r===null||r.steps.length===0||s||!m||h===null)return;let t=kO(u);c(!0);try{let n=await ae(Qs(RO({task:r.task,steps:r.steps,model:d.model,modelsLocked:d.modelsLocked,effort:d.effort,runner:h,runnerExplicit:l.runner!==null,defaultRunner:d.defaultRunner,images:r.images,archiveWhenDone:l.archiveWhenDone,autoMergePr:l.autoMergePr,allowWorkers:l.allowWorkers,allowMessaging:l.allowMessaging}),e.notifyOn));i(null),g(n,t)}catch(e){G(e instanceof Error?e.message:String(e),{tone:`danger`})}finally{c(!1)}}}}function tk(e){let t=typeof e==`string`?new URLSearchParams(e):e;return{skill:(t.get(`skill`)??``).trim(),ref:(t.get(`ref`)??t.get(`task`)??``).trim()}}function nk({archiveWhenDone:e,autoMergePr:t,onChange:n,disabled:r=!1,embedded:i=!1}){let a=(0,Z.useId)();return(0,Q.jsxs)(`fieldset`,{"data-slot":`completion-controls`,"data-embedded":i||void 0,className:`grid min-w-0 gap-3`,children:[(0,Q.jsx)(`legend`,{className:i?`sr-only`:`text-sm font-medium [margin-block-end:0.5rem]`,children:`After Done`}),(0,Q.jsxs)(`label`,{htmlFor:`${a}-archive`,className:`completion-control flex min-h-11 min-w-0 items-center justify-between gap-3 rounded-md text-sm`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,Q.jsx)(`span`,{id:`${a}-archive-label`,children:`Archive when Done`}),i?(0,Q.jsx)(`span`,{id:`${a}-archive-help`,className:`completion-control-help`,children:`Move to Archived after Done, even without a PR. You can restore it later.`}):null]}),(0,Q.jsx)(Um,{id:`${a}-archive`,className:`completion-switch`,checked:e,disabled:r,"aria-labelledby":`${a}-archive-label`,"aria-describedby":`${a}-archive-help`,onCheckedChange:e=>n({archiveWhenDone:e})})]}),i?null:(0,Q.jsx)(`p`,{id:`${a}-archive-help`,className:`text-xs break-words text-muted-foreground`,children:`Move the task to Archived after it reaches Done. You can restore it later.`}),(0,Q.jsxs)(`label`,{htmlFor:`${a}-merge`,className:`completion-control flex min-h-11 min-w-0 items-center justify-between gap-3 rounded-md text-sm`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,Q.jsx)(`span`,{id:`${a}-merge-label`,children:`Auto-merge PR`}),i?(0,Q.jsx)(`span`,{id:`${a}-merge-help`,className:`completion-control-help`,children:`After Done, mark the PR ready and merge when current-head CI and GitHub rules allow.`}):null]}),(0,Q.jsx)(Um,{id:`${a}-merge`,className:`completion-switch`,checked:t,disabled:r,"aria-labelledby":`${a}-merge-label`,"aria-describedby":`${a}-merge-help`,onCheckedChange:e=>n({autoMergePr:e})})]}),i?null:(0,Q.jsx)(`p`,{id:`${a}-merge-help`,className:`text-xs break-words text-muted-foreground`,children:`After Done, mark a draft PR ready and merge when current-head CI and GitHub rules allow it.`}),!i||e&&t?(0,Q.jsx)(`p`,{className:`completion-order-note text-xs break-words text-muted-foreground`,children:i?`Merge runs before archive when both are on.`:`When both are on, merge comes before archive. Without a PR, Archive when Done still archives the task.`}):null]})}var rk=[{key:`allowWorkers`,slot:`workers`,label:`Allow ${a(`cezar`)} workers`,help:`Agents in this task can start ${a(`Cezar`)} workers. Each worker is a separate paid agent session. Worker limits cap resources, not spending.`},{key:`allowMessaging`,slot:`messaging`,label:`Allow task messaging`,help:`Agents in this task can message other tasks in this project.`}];function ik({allowWorkers:e,allowMessaging:t,onChange:n,disabled:r=!1,embedded:i=!1}){let a=(0,Z.useId)(),o={allowWorkers:e,allowMessaging:t};return(0,Q.jsxs)(`fieldset`,{"data-slot":`task-access-controls`,"data-embedded":i||void 0,className:`grid min-w-0 gap-3`,children:[(0,Q.jsx)(`legend`,{className:i?`sr-only`:`text-sm font-medium [margin-block-end:0.5rem]`,children:`Task access`}),rk.map(e=>(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsxs)(`label`,{htmlFor:`${a}-${e.slot}`,"data-slot":`task-access-${e.slot}`,className:`completion-control flex min-h-11 min-w-0 items-center justify-between gap-3 rounded-md text-sm`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,Q.jsx)(`span`,{id:`${a}-${e.slot}-label`,children:e.label}),i?(0,Q.jsx)(`span`,{id:`${a}-${e.slot}-help`,className:`completion-control-help`,children:e.help}):null]}),(0,Q.jsx)(Um,{id:`${a}-${e.slot}`,className:`completion-switch shrink-0`,checked:o[e.key],disabled:r,"aria-labelledby":`${a}-${e.slot}-label`,"aria-describedby":`${a}-${e.slot}-help`,onCheckedChange:t=>n({[e.key]:t})})]}),i?null:(0,Q.jsx)(`p`,{id:`${a}-${e.slot}-help`,className:`text-xs break-words text-muted-foreground`,children:e.help})]},e.key))]})}function ak(){return(0,Q.jsxs)(`header`,{className:`mb-7 max-md:mb-5`,children:[(0,Q.jsx)(`p`,{"data-slot":`page-eyebrow`,className:`mb-2 text-[11px] font-semibold tracking-[0.16em] text-[var(--accent-text)] uppercase`,children:`NEW TASK`}),(0,Q.jsx)(`h1`,{className:`text-[30px] leading-[normal] font-semibold tracking-[-0.9px] max-md:text-[22px] max-md:leading-[29px] max-md:tracking-[-0.6px]`,children:`What should the agent work on?`}),(0,Q.jsx)(`p`,{"data-slot":`page-description`,className:`mt-2 hidden text-[13px] text-muted-foreground md:block`,children:`Describe the outcome. Configure the run. Review everything before it lands.`})]})}function ok({groupRef:e,compact:t,engine:n,accounts:r,draftEffort:i,update:a}){let o=n.runners.length>1||n.runners.some(e=>oc(r.accountChoices,e))?(0,Q.jsx)(sk,{engine:n,accounts:r,update:a},`runner`):null,s=(0,Q.jsx)(ck,{engine:n,draftEffort:i,update:a},`model`),c=(0,Q.jsx)(lk,{engine:n,update:a},`effort`);return(0,Q.jsx)(`div`,{ref:e,"data-slot":`agent-options`,role:`group`,"aria-label":`Agent settings`,className:`new-task-agent-options`,children:(0,Q.jsx)(Zs,{children:t?[o,c,s]:[o,s,c]})})}function sk({engine:e,accounts:t,update:n}){return(0,Q.jsx)(Ws,{icon:(0,Q.jsx)(la,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:e.runners,value:e.displayRunner,accounts:t.accountChoices,account:t.agentProfile,repoAccount:t.repoAccount,onPick:(t,r)=>n({runner:t,agentProfile:r,...t===e.displayRunner?{}:{model:null}}),disabled:!e.providersReady})}function ck({engine:e,draftEffort:t,update:n}){let{catalog:r,displayRunner:i}=e;return(0,Q.jsx)(ic,{icon:(0,Q.jsx)(Gi,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`model-pill`,ariaLabel:`Model`,label:e.models.find(t=>t.id===e.model)?.label??`auto`,value:e.model,disabled:!e.providersReady,readOnly:e.modelsLocked,disabledHint:e.modelsLocked?`Model selection is locked to native coding-agent settings.`:void 0,onPick:e=>{let a=Gs(i,e,r.data);n({model:e,effort:t===null?null:lc(t,a)})},options:e.models.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:uc(i,r.data,r.isError,r.isFetching)})}function lk({engine:e,update:t}){return(0,Q.jsx)(ic,{icon:(0,Q.jsx)(wi,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`effort-pill`,ariaLabel:`Effort`,label:e.effortOptions.find(t=>t.value===e.effort)?.label??`auto`,value:e.effort,disabled:!e.providersReady,readOnly:e.modelsLocked,disabledHint:e.modelsLocked?`Effort selection is locked to native coding-agent settings.`:void 0,onPick:e=>t({effort:e}),options:e.effortOptions.map(e=>({value:e.value,label:e.label,desc:e.desc}))})}function uk({engine:e,draft:t,update:n,repo:r,hasGit:i,runMode:a,webhook:o,interactiveSkill:s,completionDisabled:c}){let{displayRunner:l}=e;return(0,Q.jsxs)(`details`,{"data-slot":`execution-options`,open:!0,className:`group rounded-xl border border-border bg-card xl:self-start`,children:[(0,Q.jsxs)(`summary`,{className:`flex min-h-[44px] cursor-pointer list-none flex-wrap items-center gap-x-2 gap-y-1 px-3 py-2 text-xs text-muted-foreground pointer-hover:bg-muted/50 active:bg-muted/50 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-foreground [&::-webkit-details-marker]:hidden`,children:[(0,Q.jsx)(ca,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Execution settings`}),(0,Q.jsxs)(`span`,{"data-slot":`execution-summary`,hidden:!0,className:`min-w-0 basis-full truncate pl-5 xl:ml-auto xl:basis-auto xl:pl-0`,children:[Us.find(e=>e.id===l)?.label??l,` · `,e.models.find(t=>t.id===e.model)?.label??`auto`]}),(0,Q.jsx)(_a,{"aria-hidden":`true`,className:`new-task-settings-chevron size-4 shrink-0`})]}),(0,Q.jsxs)(`div`,{className:`new-task-settings-body`,children:[(0,Q.jsx)(`p`,{className:`new-task-settings-description`,children:`Control this run and what happens after Done.`}),(0,Q.jsxs)(`div`,{role:`group`,"aria-label":`Run settings`,className:`new-task-run-settings`,children:[i?(0,Q.jsx)(fk,{on:a.worktree,onChange:e=>n({worktree:e})}):null,(0,Q.jsx)(hk,{repo:r}),(0,Q.jsx)(pk,{on:a.autonomous,disabled:t.planFirst,onChange:e=>n({autonomous:e})}),o.targets.length>0?(0,Q.jsx)(mk,{on:o.on,targets:o.targets,onChange:o.onChange}):null,s&&(t.autonomous===null||t.worktree===null)?(0,Q.jsx)(`p`,{className:`basis-full text-xs text-muted-foreground`,"data-slot":`interactive-skill-hint`,children:`This skill recommends an interactive run in the current checkout. You can change either setting.`}):null]}),(0,Q.jsx)(nk,{embedded:!0,archiveWhenDone:t.archiveWhenDone,autoMergePr:t.autoMergePr,onChange:n,disabled:c}),(0,Q.jsx)(ik,{embedded:!0,allowWorkers:t.allowWorkers,allowMessaging:t.allowMessaging,onChange:n,disabled:c})]})]})}function dk({showConfigureProviders:e,planFirst:t,planning:n,onModeChange:r}){return(0,Q.jsxs)(Q.Fragment,{children:[e?(0,Q.jsx)(Y,{to:`/settings/agents#providers`,className:`text-xs font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):null,(0,Q.jsx)(_k,{planFirst:t,planning:n,onModeChange:r}),(0,Q.jsx)(`kbd`,{"aria-hidden":`true`,className:`hidden rounded-[5px] border border-b-2 border-border bg-card px-[5px] py-px font-mono text-[11px] font-medium text-muted-foreground md:inline`,children:yT()})]})}function fk({on:e,disabled:t,disabledReason:n,onChange:r}){return(0,Q.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,disabled:t,"aria-label":`Worktree`,"data-slot":`worktree-toggle`,onClick:()=>r(!e),title:t?n:e?`Runs in an isolated worktree — uncheck to run in the repo working tree`:`Runs in the repo working tree — check to isolate in a worktree`,className:`flex items-center justify-between gap-3 px-0 py-3 text-left`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`block text-[13px] font-medium`,children:`Worktree`}),(0,Q.jsx)(`span`,{className:`block text-[12px] text-muted-foreground`,children:e?`Changes stay in a separate working copy.`:`Changes are made in the current working directory.`})]}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:D(`flex h-6 w-10 shrink-0 items-center rounded-full border p-0.5`,e?`border-accent-strong bg-accent-strong`:`border-muted-foreground bg-muted`),children:(0,Q.jsx)(`span`,{className:D(`size-[18px] rounded-full`,e?`ml-auto bg-accent-strong-foreground`:`bg-foreground`)})})]})}function pk({on:e,disabled:t,onChange:n}){return(0,Q.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,disabled:t,"aria-label":`Autonomous`,"data-slot":`autonomous-toggle`,onClick:()=>n(!e),title:t?`Plan-first runs are interactive — autonomous is unavailable`:e?`Autonomous — the agent runs to completion without pausing for you`:`Runs interactively — check to let the agent finish without pausing for you`,className:`flex items-center justify-between gap-3 px-0 py-3 text-left disabled:opacity-50`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`block text-[13px] font-medium`,children:`Autonomous`}),(0,Q.jsx)(`span`,{className:`block text-[12px] text-muted-foreground`,children:`Let the agent proceed without prompts`})]}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:D(`flex h-6 w-10 shrink-0 items-center rounded-full border p-0.5`,e?`border-accent-strong bg-accent-strong`:`border-muted-foreground bg-muted`),children:(0,Q.jsx)(`span`,{className:D(`size-[18px] rounded-full`,e?`ml-auto bg-accent-strong-foreground`:`bg-foreground`)})})]})}function mk({on:e,targets:t,onChange:n}){return(0,Q.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,"aria-label":`Notify webhook`,"data-slot":`notify-webhook-toggle`,onClick:()=>n(!e),title:`${e?`Status changes go to`:`Check to send this task's status changes to`} ${_O(t)} (${t.map(e=>hO(e.url)).join(`, `)})`,className:`flex min-h-11 items-center justify-between gap-3 px-0 py-3 text-left`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block text-[13px] font-medium`,children:`Notify webhook`}),(0,Q.jsx)(`span`,{"data-slot":`notify-webhook-subtitle`,className:`block truncate text-[12px] text-muted-foreground`,children:`Send status changes`})]}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:D(`flex h-6 w-10 shrink-0 items-center rounded-full border p-0.5`,e?`border-accent-strong bg-accent-strong`:`border-muted-foreground bg-muted`),children:(0,Q.jsx)(`span`,{className:D(`size-[18px] rounded-full`,e?`ml-auto bg-accent-strong-foreground`:`bg-foreground`)})})]})}function hk({repo:e}){return(0,Q.jsxs)(`div`,{"data-slot":`base-branch-row`,className:`new-task-base-branch flex items-center justify-between gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:`Base branch`}),e?(0,Q.jsx)(gk,{repo:e}):null]})}function gk({repo:e}){let t=L(),n=jn({mutationFn:e=>I({baseBranch:e}),onSuccess:e=>{t.invalidateQueries({queryKey:H.repo}),G(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=>G(e.message,{tone:`danger`})});return e.info?(0,Q.jsx)(ic,{searchPlaceholder:`Search branches…`,slot:`base-pill`,ariaLabel:`Base branch`,label:(0,Q.jsx)(`span`,{className:`text-[11px]`,children:e.baseBranch??e.info.branch}),value:e.baseBranch??``,onPick:e=>n.mutate(e===``?null:e),options:[{value:``,label:`follow checked-out branch (${e.info.branch})`,desc:`New task worktrees fork from whatever branch is checked out`},...e.branches.map(e=>({value:e,label:e}))]}):null}function _k({planFirst:e,planning:t,onModeChange:n}){return(0,Q.jsxs)(`div`,{"data-slot":`mode-seg`,role:`radiogroup`,"aria-label":`Run mode`,className:`inline-flex items-center gap-0.5 rounded-lg bg-muted p-[3px]`,children:[(0,Q.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":!e,onClick:()=>n(!1),className:D(`h-6 rounded-md px-2 text-xs transition-colors`,e?`font-medium text-muted-foreground hover:text-foreground`:`bg-card font-semibold text-foreground shadow-xs`),children:[e?null:(0,Q.jsx)(ia,{"aria-hidden":`true`,className:`size-3.5`}),`Start`]}),(0,Q.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e,"aria-busy":t||void 0,"data-slot":`mode-plan`,onClick:()=>n(!0),className:D(`h-6 rounded-md px-2 text-xs transition-colors`,e?`bg-contrast font-semibold text-contrast-foreground ring-2 ring-ring/55`:`font-medium text-muted-foreground hover:text-foreground`,t&&`animate-pulse`),children:t?`Planning…`:`Plan first`})]})}function vk({plan:e,starting:t,startAvailable:n,startUnavailableReason:r,startUnavailableAction:i,onStepsChange:a,onStart:o,onDiscard:s}){let[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),f=(0,Z.useRef)(null),p=(0,Z.useId)();(0,Z.useEffect)(()=>{f.current?.focus({preventScroll:!0});let e=f.current?.closest(`[data-slot="main"]`);e&&(e.scrollTop=0)},[]);let m=()=>{l(null),d(null)},h=(t,n)=>{t.preventDefault(),c!==null&&c!==n&&a(FO(e.steps,c,n)),m()},g=e.steps.length===0;return(0,Q.jsxs)(`div`,{"data-slot":`plan-page`,children:[(0,Q.jsxs)(`header`,{"data-slot":`plan-page-header`,children:[(0,Q.jsx)(`h1`,{children:`New task / Plan first`}),(0,Q.jsx)(`p`,{children:`Review the proposed chain before launching.`})]}),(0,Q.jsx)(`div`,{"data-slot":`plan-canvas`,children:(0,Q.jsxs)(`section`,{ref:f,tabIndex:-1,"aria-labelledby":p,"data-slot":`plan-review`,className:`flex flex-col outline-none`,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||e.target.closest(`[role="dialog"], [role="alertdialog"]`)||(e.preventDefault(),s())},children:[(0,Q.jsxs)(`header`,{"data-slot":`dialog-header`,className:`flex flex-col gap-1 px-5 pt-4 pb-3.5 text-left`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsx)(`h2`,{id:p,"data-slot":`dialog-title`,className:`text-[11px] font-semibold tracking-[0.08em] text-muted-foreground uppercase`,children:`Proposed chain`}),(0,Q.jsx)(`button`,{type:`button`,onClick:s,"aria-label":`Discard the plan`,className:`-mt-1 -mr-1 rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,Q.jsx)(oa,{"aria-hidden":`true`,className:`size-4`})})]}),(0,Q.jsx)(`p`,{"data-slot":`plan-task`,title:e.task,className:`text-[18px] font-medium text-foreground`,children:LO(e.task)}),e.fallback?(0,Q.jsx)(`p`,{"data-slot":`plan-fallback`,className:`text-xs text-soft-foreground italic`,children:`planner unavailable — single-step plan`}):e.rationale===``?null:(0,Q.jsx)(`p`,{"data-slot":`plan-rationale`,className:`text-xs text-muted-foreground`,children:e.rationale})]}),(0,Q.jsx)(`ol`,{"data-slot":`plan-steps`,className:`flex-1 space-y-2 overflow-y-auto px-5 py-4`,children:g?(0,Q.jsx)(`li`,{className:`py-6 text-center text-sm text-muted-foreground`,children:`(no steps left — discard and plan again)`}):e.steps.map((t,n)=>(0,Q.jsxs)(`li`,{"data-slot":`plan-step`,"data-step-id":t.id,draggable:!0,onDragStart:()=>l(n),onDragOver:e=>{e.preventDefault(),d(n)},onDragLeave:()=>d(e=>e===n?null:e),onDrop:e=>h(e,n),onDragEnd:m,className:D(`flex items-center gap-2.5 rounded-lg border border-border bg-card-2 px-3 py-2.5`,c===n&&`opacity-50`,u===n&&c!==null&&c!==n&&`border-ring`),children:[(0,Q.jsx)(Ii,{"aria-hidden":`true`,className:`size-3.5 shrink-0 cursor-grab text-soft-foreground`}),(0,Q.jsx)(`span`,{className:`w-5 shrink-0 font-mono text-[11px] text-soft-foreground tabular-nums`,children:String(n+1).padStart(2,`0`)}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] font-medium`,children:t.name??t.id}),t.skill?(0,Q.jsx)(`span`,{"data-slot":`plan-badge-skill`,title:`skill`,className:`shrink-0 rounded-full bg-accent-strong/15 px-1.5 py-px font-mono text-[11px] font-medium text-accent-text`,children:t.skill}):null,t.command?(0,Q.jsx)(`span`,{"data-slot":`plan-badge-check`,className:`shrink-0 rounded-full bg-muted px-1.5 py-px text-[11px] font-medium text-muted-foreground`,children:`check`}):null]}),(0,Q.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap break-words font-mono text-[11px] text-muted-foreground`,children:IO(t)})]}),(0,Q.jsxs)(`span`,{"data-slot":`plan-step-actions`,className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(E,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`plan-step-up`,"aria-label":`Move step ${n+1} up`,disabled:n===0,className:`size-7 text-muted-foreground`,onClick:()=>a(FO(e.steps,n,n-1)),children:`Move up`}),(0,Q.jsx)(E,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`plan-step-down`,"aria-label":`Move step ${n+1} down`,disabled:n===e.steps.length-1,className:`size-7 text-muted-foreground`,onClick:()=>a(FO(e.steps,n,n+1)),children:`Move down`}),(0,Q.jsx)(E,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`plan-step-remove`,"aria-label":`Remove step ${n+1}`,className:`size-7 text-muted-foreground hover:text-danger`,onClick:()=>a(PO(e.steps,n)),children:`Remove`})]})]},t.id))}),!n&&r?(0,Q.jsxs)(`p`,{id:`plan-start-guidance`,className:`flex flex-wrap items-center gap-1.5 border-t border-border px-5 pt-3 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:r}),i]}):null,(0,Q.jsxs)(`div`,{"data-slot":`plan-actions`,className:`flex flex-wrap items-center gap-3 px-6 pt-3 pb-6`,children:[(0,Q.jsxs)(E,{type:`button`,"data-slot":`plan-start`,disabled:g||t||!n,title:n?void 0:r,"aria-describedby":!n&&r?`plan-start-guidance`:void 0,onClick:o,children:[(0,Q.jsx)(Ua,{"aria-hidden":`true`,className:`size-3.5`}),t?`Starting…`:`Start`]}),(0,Q.jsx)(yk,{steps:e.steps,disabled:g}),(0,Q.jsx)(E,{type:`button`,variant:`outline`,onClick:s,children:`Discard`})]}),(0,Q.jsx)(`p`,{className:`px-6 pb-6 text-xs text-muted-foreground`,children:`No steps left? Start is disabled. A planner failure shows a single-step fallback.`})]})})]})}function yk({steps:e,disabled:t}){let n=L(),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d=async t=>{let r=a.trim();if(!(r===``||l)){u(!0);try{let a=await Ne({name:r,steps:e,...t?{overwrite:!0}:{}});G(`Saved — ${a.path.split(`/`).pop()??a.path}`),n.invalidateQueries({queryKey:H.workflows}),c(!1),i(!1),o(``)}catch(e){e instanceof it&&e.exists===!0?c(!0):G(e instanceof Error?e.message:String(e),{tone:`danger`})}finally{u(!1)}}};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{type:`button`,variant:`outline`,"data-slot":`plan-save`,disabled:t,onClick:()=>i(!0),children:`Save as chain`}),(0,Q.jsx)(ts,{open:r,onOpenChange:e=>i(!!e),children:(0,Q.jsxs)($o,{"data-slot":`plan-save-dialog`,className:`sm:max-w-sm`,showCloseButton:!1,children:[(0,Q.jsxs)(Qo,{children:[(0,Q.jsx)(es,{children:`Save as chain`}),(0,Q.jsx)(Xo,{children:`Saves these steps as a reusable workflow — it joins the picker like any other chain.`})]}),(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),d(!1)},children:[(0,Q.jsx)(`label`,{htmlFor:`plan-chain-name`,className:`mb-2 block text-[11px] text-muted-foreground`,children:`Chain name`}),(0,Q.jsx)(Im,{id:`plan-chain-name`,value:a,onChange:e=>o(e.target.value),"aria-label":`Chain name`,placeholder:`e.g. fix-and-verify-v2`,maxLength:80,autoFocus:!0}),(0,Q.jsxs)(Yo,{className:`mt-4`,children:[(0,Q.jsx)(E,{type:`button`,variant:`outline`,onClick:()=>i(!1),children:`Cancel`}),(0,Q.jsx)(E,{type:`submit`,disabled:a.trim()===``||l,children:l?`Saving…`:`Save chain`})]})]})]})}),(0,Q.jsx)(Ko,{open:s,onOpenChange:e=>e?void 0:c(!1),children:(0,Q.jsxs)(Ro,{"data-slot":`plan-overwrite-dialog`,children:[(0,Q.jsxs)(Go,{children:[(0,Q.jsxs)(No,{children:[`Overwrite “`,a.trim(),`”?`]}),(0,Q.jsx)(Mo,{children:`A chain with this name already exists. Overwriting replaces its steps with this plan.`})]}),(0,Q.jsxs)(Ho,{children:[(0,Q.jsx)(Wo,{children:`Cancel`}),(0,Q.jsx)(Vo,{onClick:()=>void d(!0),children:`Overwrite chain`})]})]})})]})}var bk={start:{note:`Start immediately with the selected configuration.`,pendingLabel:`Starting task…`,failureHint:void 0,clearOnSuccess:!0,sendAriaLabel:`Start task`},plan:{note:`Review the plan before starting the task.`,pendingLabel:`Planning task…`,failureHint:`Could not create the plan. Your draft is kept. Please retry.`,clearOnSuccess:!1,sendAriaLabel:`Plan task`}};function xk(){let[e]=n(),t=(0,Z.useRef)(null),i=(0,Z.useRef)(null),a=(0,Z.useRef)(null),{projectId:o}=r(),s=wt().projectId,[c]=(0,Z.useState)(()=>tk(e)),l=vr(),u=En(),d=$n(),f=Mn(),{draft:p,update:m,clearStarted:h,submissionPending:g,mounted:_}=BO(s,c),v=VO(p.source,u),{source:y,sourcesReady:b,skillList:x}=v,S=qO(o),C=HO({uiState:u,source:y,sourcesReady:b,draftText:p.text,submissionPending:g,update:m}),w=UO(p,d),T=WO(w.displayRunner,p.agentProfile);GO(w.providersReady);let E=l.data===void 0||l.data.info!==null,D=KO({hasGit:E,draft:p,selectedSkill:v.selectedSkill,workspaceConfig:f,source:y}),{plan:O,setPlan:k,planning:A,starting:j,submit:M,startPlanned:ee}=ek({draft:p,draftProjectId:s,engine:w,agentProfile:T.agentProfile,sourcesReady:b,source:y,runMode:D,notifyOn:S.notifyOn,uiState:u,mounted:_,clearStarted:h});YO({deepLink:c,search:e,sourcesReady:b,skillList:x,update:m});let te=JO(t),{providers:N,providersReady:P}=w,ne=p.planFirst?bk.plan:bk.start,F=QO(N);return(0,Q.jsxs)(`div`,{"data-route":`new`,"data-plan-review":O===null?void 0:`true`,className:`relative isolate flex min-h-full flex-col overflow-x-clip pb-16`,children:[(0,Q.jsxs)(`div`,{"data-slot":`new-task-layout`,ref:a,style:O===null?void 0:{display:`none`},className:`relative z-[1] mx-auto w-full max-w-none px-11 pt-12 max-md:px-[18px] max-md:pt-[22px]`,children:[(0,Q.jsx)(ak,{}),(0,Q.jsx)(iD,{ref:i,onSubmit:M,retainDraftUntilSuccess:!0,idleFeedback:(0,Q.jsxs)(`div`,{"data-slot":`new-task-mode-note`,className:`flex items-center justify-between gap-3 text-[11px] text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:ne.note}),(0,Q.jsx)(`kbd`,{className:`hidden font-sans md:inline`,children:yT()})]}),pendingLabel:ne.pendingLabel,failureHint:ne.failureHint,clearOnSuccess:ne.clearOnSuccess,onPendingChange:e=>{g.current=e},value:p.text,onValueChange:e=>m({text:e}),autoFocus:!0,placeholder:`Describe a task for the agent — / for skills…`,ariaLabel:`Describe a task for the agent`,sendAriaLabel:ne.sendAriaLabel,disabled:!P||j,disabledReason:F,autocompleteSkills:!0,footerStart:(0,Q.jsx)(Sk,{projects:S.projectList,urlProjectId:o,templates:C,onInsertTemplate:e=>i.current?.insertAtCaret(e),sources:v,onPickSource:e=>m({source:e})}),agentOptions:(0,Q.jsx)(ok,{groupRef:t,compact:te,engine:w,accounts:T,draftEffort:p.effort,update:m}),executionOptions:(0,Q.jsx)(uk,{engine:w,draft:p,update:m,repo:l.data,hasGit:E,runMode:D,webhook:{targets:S.webhookTargets,on:S.notifyOn,onChange:S.setNotifyChoice},interactiveSkill:v.selectedSkill?.interactive===!0,completionDisabled:j||A}),footerEnd:(0,Q.jsx)(dk,{showConfigureProviders:!P&&!N.isPending,planFirst:p.planFirst,planning:A,onModeChange:e=>m({planFirst:e})})}),(0,Q.jsx)(`p`,{"data-slot":`run-mode-note`,className:`mt-2.5 text-[13px] text-muted-foreground`,children:xO({worktree:D.worktree,hasGit:E})})]}),O===null?null:(0,Q.jsx)(vk,{plan:O,starting:j,startAvailable:P,startUnavailableReason:F,startUnavailableAction:N.isPending?void 0:(0,Q.jsx)(Y,{to:`/settings/agents#providers`,children:`Configure providers`}),onStepsChange:e=>k(t=>t&&{...t,steps:e}),onStart:()=>void ee(),onDiscard:()=>{k(null),requestAnimationFrame(()=>a.current?.querySelector(`textarea`)?.focus())}})]})}function Sk({projects:e,urlProjectId:t,templates:n,onInsertTemplate:r,sources:i,onPickSource:a}){let o=_s();return(0,Q.jsxs)(Q.Fragment,{children:[e.length>1&&t!==void 0?(0,Q.jsx)(wk,{projects:e,projectId:t,onPick:e=>o(`/p/${encodeURIComponent(e)}/new`,{replace:!0})}):null,(0,Q.jsx)(ps,{label:`Template`,templates:n,onInsert:r}),(0,Q.jsx)(Mk,{source:i.source,ready:i.sourcesReady,skills:i.skillList,skillUsage:i.skillUsage,workflows:i.workflowList,onPick:a})]})}function Ck(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 wk({projects:e,projectId:t,onPick:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(``),{order:s}=uv(),c=e.find(e=>e.id===t),l=Ck(sv(e,s),a);return(0,Q.jsxs)(fi,{open:r,onOpenChange:e=>{i(e),e||o(``)},children:[(0,Q.jsx)(li,{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:D(ac,`border-foreground/60 font-semibold text-foreground`),children:[(0,Q.jsx)(Ei,{"aria-hidden":`true`,className:`size-3 shrink-0 text-soft-foreground`}),(0,Q.jsx)(`span`,{className:`max-w-40 truncate`,children:c?.name??t}),nc]})}),(0,Q.jsx)(Qr,{align:`start`,sideOffset:8,className:`w-[300px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Q.jsxs)(Ls,{shouldFilter:!1,children:[(0,Q.jsx)(Rs,{placeholder:`search projects…`,value:a,onValueChange:o}),(0,Q.jsxs)(Es,{"data-slot":`project-menu`,className:`max-h-[min(18rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[l.length===0?(0,Q.jsx)(Ns,{children:`Nothing matches.`}):null,l.map(e=>(0,Q.jsxs)(fc,{value:e.id,keywords:[e.name],"data-slot":`project-option`,"data-project-id":e.id,disabled:e.status===`missing`,onSelect:()=>{n(e.id),i(!1)},children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium`,children:e.name}),e.status===`missing`?(0,Q.jsx)(`span`,{className:`shrink-0 text-[11px] text-soft-foreground`,children:`folder not found`}):e.branch===void 0?null:(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-soft-foreground`,children:e.branch}),e.id===t?(0,Q.jsx)(ia,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},e.id))]}),(0,Q.jsx)(`p`,{className:`border-t border-border px-3 py-2 text-[11px] leading-snug text-soft-foreground`,children:`Skills, workflows, settings and the draft re-resolve against the selected project.`})]})})]})}function Tk(e,t,n){return!e&&(t.ranked?t.ranked.length===0:t.mostUsed.length===0&&t.project.length===0&&t.global.length===0)&&n.length===0}function Ek(e,t){return Oc(`no skill`,`none plain ${Ys} ${e?.description??``}`,t)>0}function Dk({source:e,ready:t,offersWorkflows:n,onPick:r}){let i=e===null||e.source===`skill`?pa:Zi;return(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(),r(null))},className:D(ac,`font-mono text-[11px]`,e===null?`text-muted-foreground`:`rounded-r-none border-r-0 border-foreground/60 pr-1.5 font-semibold text-foreground`),children:[(0,Q.jsx)(i,{"aria-hidden":`true`,className:D(`size-3 shrink-0`,e===null?`text-muted-foreground`:`text-accent-icon`)}),(0,Q.jsx)(`span`,{className:`max-w-44 truncate`,children:t?e?.ref??(n?`Skill or workflow`:`Skill`):`…`}),nc]})}function Ok({source:e,quickTask:t,onPick:n}){return(0,Q.jsx)(Ps,{children:(0,Q.jsxs)(fc,{value:`none no-skill`,keywords:[`none`,`plain`,...Ac(Ys)],"data-slot":`source-option`,"data-source-kind":`none`,onSelect:()=>n(null),children:[(0,Q.jsx)(Qi,{"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:t?.description??`One agent run on your task — no ceremony.`}),e===null?(0,Q.jsx)(ia,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]})})}function kk({ranked:e,mostUsed:t,project:n,skillItem:r}){return(0,Q.jsx)(Q.Fragment,{children:e?e.length>0?(0,Q.jsx)(Ps,{children:e.map(e=>r(e,jc(e)))}):null:(0,Q.jsxs)(Q.Fragment,{children:[t.length>0?(0,Q.jsx)(Ps,{heading:`Most used`,children:t.map(e=>r(e,jc(e)))}):null,n.length>0?(0,Q.jsx)(Ps,{heading:`Project skills`,children:n.map(e=>r(e,!0))}):null]})})}function Ak({source:e,matchedWorkflows:t,toggle:n}){return t.length>0?(0,Q.jsx)(Ps,{heading:`Workflows`,children:t.map(t=>{let r=e?.source===`workflow`&&e.ref===t.name;return(0,Q.jsxs)(fc,{value:`workflow ${t.name}`,keywords:Ac(t.name,t.description),"data-slot":`source-option`,"data-source-kind":`workflow`,"data-source-ref":t.name,onSelect:()=>n({source:`workflow`,ref:t.name}),children:[(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:t.name}),t.description?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:t.description}):null,r?(0,Q.jsx)(ia,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},t.name)})}):null}function jk({global:e,skillItem:t}){return e.length>0?(0,Q.jsx)(Ps,{heading:`Global`,children:e.map(e=>t(e,!1))}):null}function Mk({source:e,ready:t,skills:n,skillUsage:r,workflows:i,onPick:a}){let[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(null),f=(0,Z.useRef)(null),{mostUsed:p,project:m,global:h,ranked:g}=Ic(n,c,r),_=i.find(e=>e.name===Ys),v=kc(i,c).filter(e=>e.name!==Ys),y=i.some(e=>e.name!==Ys),b=Ek(_,c),x=Tk(b,{ranked:g,mostUsed:p,project:m,global:h},v),S=e=>{a(e),s(!1)},C=t=>S(e?.source===t.source&&e.ref===t.ref?null:t),w=(t,n)=>{let r=e?.source===`skill`&&e.ref===t.name;return(0,Q.jsxs)(fc,{value:`skill ${t.name} ${t.path}`,keywords:Ac(t.name,t.description),"data-slot":`source-option`,"data-source-kind":`skill`,"data-source-ref":t.name,onSelect:()=>C({source:`skill`,ref:t.name}),children:[(0,Q.jsx)(`span`,{className:D(`shrink-0 font-mono text-xs`,n&&`font-semibold`),children:t.name}),t.description?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:t.description}):null,(0,Q.jsx)(`button`,{type:`button`,"data-slot":`source-skill-view`,"aria-label":`View skill ${t.name}`,title:`View skill`,onClick:e=>{e.preventDefault(),e.stopPropagation(),d(t)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,Q.jsx)(La,{"aria-hidden":`true`,className:`size-3.5`})}),r?(0,Q.jsx)(ia,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},t.path)},T=Dk({source:e,ready:t,offersWorkflows:y,onPick:a});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(mO,{skill:u,onClose:()=>d(null)}),(0,Q.jsxs)(fi,{open:o,onOpenChange:e=>{s(e),e||l(``)},children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center`,children:[(0,Q.jsx)(li,{asChild:!0,children:T}),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:D(ac,`rounded-l-none border-foreground/60 pl-1.5 pr-2 text-soft-foreground hover:text-foreground`),children:(0,Q.jsx)(oa,{"aria-hidden":`true`,className:`size-3`})}):null]}),(0,Q.jsx)(Qr,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Q.jsxs)(Ls,{shouldFilter:!1,children:[(0,Q.jsx)(Rs,{placeholder:`search skills & workflows…`,value:c,onValueChange:l,onInput:()=>f.current?.scrollTo(0,0)}),(0,Q.jsxs)(Es,{ref:f,"data-slot":`source-menu`,className:`max-h-[min(18rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[x?(0,Q.jsx)(Ns,{children:`Nothing matches.`}):null,b?(0,Q.jsx)(Ok,{source:e,quickTask:_,onPick:S}):null,(0,Q.jsx)(kk,{ranked:g,mostUsed:p,project:m,skillItem:w}),(0,Q.jsx)(Ak,{source:e,matchedWorkflows:v,toggle:C}),(0,Q.jsx)(jk,{global:h,skillItem:w})]})]})})]})]})}function Nk(){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)(yu,{}),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)(E,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(Y,{to:`/`,children:`Back to tasks`})})})})}function Pk(){return(0,Q.jsx)(`div`,{className:`px-[18px] pt-2 md:hidden`,children:(0,Q.jsxs)(Y,{to:`/git`,"data-slot":`git-back`,className:`inline-flex min-h-11 items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground`,children:[(0,Q.jsx)(fa,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`Back to Git`]})})}function Fk(){let{pathname:e,search:n}=t();return(0,Q.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[xs(e)!==`/git`||new URLSearchParams(n).get(`view`)===`repo`?(0,Q.jsx)(Pk,{}):null,(0,Q.jsx)(X,{icon:(0,Q.jsx)(Ra,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading repository…`,subtitle:`Fetching the repo's git state.`})]})}function Ik(){return(0,Q.jsxs)(`div`,{"data-route":`skills`,"aria-busy":`true`,className:`mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:[(0,Q.jsx)(`h1`,{className:`text-[30px] font-semibold tracking-tight`,children:`Skills`}),(0,Q.jsx)(`p`,{className:`mt-1 text-[13px] text-muted-foreground`,children:`Markdown playbooks your agents can follow.`}),(0,Q.jsx)(`p`,{"data-slot":`skills-loading`,role:`status`,className:`mt-6 text-xs text-muted-foreground`,children:`Loading skills…`}),(0,Q.jsxs)(`div`,{"aria-hidden":`true`,className:`mt-4 flex flex-col gap-[22px] motion-safe:animate-pulse`,children:[(0,Q.jsx)(`div`,{className:`h-11 rounded-lg border border-border bg-card`}),(0,Q.jsx)(`div`,{className:`h-80 rounded-xl border border-border bg-card`})]})]})}function Lk({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)(ju,{}),tone:`neutral`,title:`“${e}” isn’t registered here`,subtitle:`This ${a(`cezar`)} doesn’t serve a project by that id. The link may come from another machine’s workspace — these are the projects registered on this one:`,children:(0,Q.jsx)(`ul`,{"data-slot":`registered-projects`,className:`mx-auto flex w-full max-w-xs flex-col gap-1.5 text-left`,children:n.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(C,{to:`/p/${encodeURIComponent(e.id)}/`,className:`flex items-baseline gap-2 rounded-md border border-border bg-card px-3 py-2 text-sm font-medium text-foreground shadow-xs transition-colors hover:bg-card-2`,children:[e.name||e.id,(0,Q.jsxs)(`span`,{className:`font-mono text-[11px] font-normal text-soft-foreground`,children:[`/p/`,e.id]})]})},e.id))})})})}function Rk(){return(0,Q.jsxs)(`div`,{"data-route":`workflows`,"aria-busy":`true`,className:`mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:[(0,Q.jsx)(`h1`,{className:`text-[30px] font-semibold tracking-tight`,children:`Workflows`}),(0,Q.jsx)(`p`,{className:`mt-1 text-[13px] text-muted-foreground`,children:`Portable skill chains. Steps run from top to bottom.`}),(0,Q.jsx)(`p`,{"data-slot":`workflows-loading`,role:`status`,className:`mt-6 text-xs text-muted-foreground`,children:`Loading workflows…`}),(0,Q.jsxs)(`div`,{"aria-hidden":`true`,className:`mt-4 flex flex-col gap-[22px] motion-safe:animate-pulse`,children:[(0,Q.jsx)(`div`,{className:`h-11 rounded-lg border border-border bg-card`}),(0,Q.jsx)(`div`,{className:`h-80 rounded-xl border border-border bg-card`})]})]})}function zk({tab:e}){return(0,Q.jsx)(`div`,{"data-route":`task-${e}`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(Ra,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:e===`changes`?`Loading changes…`:`Loading files…`,subtitle:`Fetching the run record.`})})}function Bk({tab:e,error:t}){let n=t instanceof it&&t.status===404;return(0,Q.jsx)(`div`,{"data-route":`task-${e}`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(X,{icon:n?(0,Q.jsx)(Xa,{}):(0,Q.jsx)(qi,{size:16}),tone:n?`neutral`:`danger`,title:n?`Task not found`:`Could not load this task`,subtitle:n?`No run has this id. It may have been deleted, or the link is from another machine.`:t.message,actions:(0,Q.jsx)(E,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(Y,{to:`/`,children:`Back to tasks`})})})})}var Vk={issue:`issue`,pr:`pull request`};function Hk({kind:e,number:t,heading:n=`h1`}){let r=(0,Q.jsx)(`div`,{"data-slot":`task-github-loading`,className:`flex min-h-full flex-1 flex-col`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(Ra,{className:`motion-safe:animate-spin`}),tone:`neutral`,heading:n,title:`Loading ${Vk[e]}${t===void 0?``:` #${t}`}…`,subtitle:t===void 0?`Fetching the run record.`:`Asking GitHub.`})});return n===`h2`?r:(0,Q.jsx)(`div`,{"data-route":`task-github-item`,className:`flex min-h-full flex-col`,children:r})}function Uk(){return(0,Q.jsx)(`div`,{"data-route":`task-thread`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(Ra,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading task…`,subtitle:`Fetching the run and its session transcript.`})})}async function Wk(e,t,n,r,i){try{return await Hl(e,{queryKey:[t,`runs`,`artifact-metadata`,n,r],queryFn:({signal:e})=>me(n,r,{signal:e})},i),!0}catch(e){if(e instanceof it&&e.status===404)return!1;throw e}}async function Gk(e,t,n,r,i,a){if(await Wk(e,t,n,r,i))return n;i.throwIfAborted();let o=await Hl(e,{queryKey:[t,`runs`,`relationships`,n],queryFn:({signal:e})=>le(n,{signal:e})},i),s=new Set(o.workers.map(e=>e.workerId));a&&s.add(a),s.delete(n);for(let n of s){if(i.aborted)throw i.reason;if(await Wk(e,t,n,r,i))return n}throw new it(404,`Report missing or deleted`)}function Kk(e,t,n){let r=L(),i=o();return wr({queryKey:[i,`runs`,`report-source`,e,t,n],queryFn:({signal:a})=>Gk(r,i,e,t,a,n),enabled:!!(e&&t),retry:!1})}function qk(){let[e]=n(),r=t(),i=k(),a=u(),o=Z.useRef(Math.random()),s=Z.useRef({renderedKey:``,next:e,seq:0,latestSeq:0});return Z.useLayoutEffect(()=>{if(s.current.renderedKey===r.key)return;let t=r.state,n=t?.__writerSession===o.current?t.__writerSeq:void 0;a===`REPLACE`&&n!==void 0&&n<=s.current.latestSeq?(s.current.renderedKey=r.key,n===s.current.latestSeq&&(s.current.next=e)):s.current={renderedKey:r.key,next:e,seq:s.current.seq,latestSeq:0}},[e,r,a]),[e,Z.useCallback(e=>{let t=e(new URLSearchParams(s.current.next));if(t.toString()===s.current.next.toString())return;let n=s.current.seq+1;s.current={...s.current,next:t,seq:n,latestSeq:n},i({search:`?${t}`},{replace:!0,state:{__writerSession:o.current,__writerSeq:n}})},[i])]}var Jk=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Yk(e){let t=e.get(`report`);return!t||!Jk.test(t)||e.getAll(`report`).length!==1||e.getAll(`card`).length>1?null:{artifactId:t,card:e.get(`card`)||null}}var Xk=(0,Z.createContext)(null);function Zk(e){let n=t(),r=k(),[i,a]=qk(),o=Yk(i),[s,c]=(0,Z.useState)(()=>({runId:e,entries:new Map}));s.runId!==e&&c({runId:e,entries:new Map});let l=(0,Z.useCallback)((t,n)=>(c(r=>{if(r.runId===e&&r.entries.get(t)===n)return r;let i=new Map(r.runId===e?r.entries:[]);return i.set(t,n),{runId:e,entries:i}}),()=>void 0),[e]),u=(0,Z.useRef)({runId:e,callbacks:new Map});u.current.runId!==e&&(u.current={runId:e,callbacks:new Map});let d=(0,Z.useCallback)((e,t)=>(u.current.callbacks.set(e,t),()=>{u.current.callbacks.get(e)===t&&u.current.callbacks.delete(e)}),[]),f=(0,Z.useMemo)(()=>({register:l,registerOpener:d}),[l,d]),p=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{i.has(`report`)&&!o&&a(e=>(e.delete(`report`),e.delete(`card`),e))},[i,o,a]),(0,Z.useEffect)(()=>{let t=p.current;!o&&t&&t.runId===e&&t.card&&u.current.callbacks.get(t.card)?.(t.artifactId,t.scrollTop),p.current=o?{...o,runId:e,scrollTop:n.state?.reportScrollTop}:null},[e,o,n.state]),{selection:o,sourceRunId:s.runId===e&&o?s.entries.get(o.artifactId)??(o.card?void 0:e):void 0,registry:f,close:()=>{let e=n.state,t=window.navigation;if(e?.reportReturnKey&&t){t.traverseTo(e.reportReturnKey);return}if(e?.reportReturnTo){r(e.reportReturnTo,{replace:!0});return}a(e=>(e.delete(`report`),e.delete(`card`),e))}}}var Qk=class extends Z.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){console.error(`${a(`cezar`)} cockpit: the preview pane crashed`,e,t.componentStack)}render(){return this.state.failed?(0,Q.jsxs)(`div`,{"data-slot":`preview-pane-error`,role:`alert`,className:`flex h-full flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,children:`The preview hit an error`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The task is unaffected. Close the preview and open it again.`}),(0,Q.jsx)(E,{variant:`outline`,onClick:this.props.onClose,children:`Close preview`})]}):this.props.children}},$k=`cez-preview-tasks`,eA=`cez.preview.pane-width`,tA=e=>Math.min(75,Math.max(30,Math.round(e)));function nA(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function rA(e){if(!nA(e))return;let{port:t,agent:n,url:r}=e;if(typeof t==`number`&&Number.isInteger(t)&&t>=1&&t<=65535)return{port:t};if(n===!0)return{agent:!0};if(typeof r==`string`&&/^https?:\/\//i.test(r))return{url:r}}function iA(e){if(!nA(e))return;let t=rA(e.target),n=typeof e.percent==`number`&&Number.isFinite(e.percent)?e.percent:void 0;return{open:e.open===!0,...t?{target:t}:{},...n===void 0?{}:{percent:n},at:typeof e.at==`number`?e.at:0}}function aA(){try{let e=localStorage.getItem($k),t=e===null?null:JSON.parse(e);return nA(t)?t:{}}catch{return{}}}function oA(e){let t=iA(aA()[e]);if(!t)return;let{at:n,...r}=t;return r}function sA(e,t,n=Date.now()){let r=aA(),i={open:!1,...iA(r[e]),...t,at:n};for(let e of Object.keys(i))i[e]===void 0&&delete i[e];r[e]=i;let a=Object.keys(r);if(a.length>100){let e=e=>iA(r[e])?.at??0;for(let t of a.sort((t,n)=>e(t)-e(n)).slice(0,a.length-100))delete r[t]}try{localStorage.setItem($k,JSON.stringify(r))}catch{}}function cA(){try{let e=Number(localStorage.getItem(eA));return e>0?e:void 0}catch{return}}function lA(e){let t=(e===void 0?void 0:oA(e)?.percent)??cA();return t===void 0?58:tA(t)}function uA(e,t){try{localStorage.setItem(eA,String(t))}catch{}e!==void 0&&sA(e,{percent:t})}var dA=`(min-width: 1180px)`,fA=`(max-width: 767px)`;function pA(e,t){let[n,r]=(0,Z.useState)(()=>window.matchMedia?.(e).matches??t);return(0,Z.useEffect)(()=>{let t=window.matchMedia?.(e);if(!t)return;let n=()=>r(t.matches);return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[e]),n}var mA=(0,Z.lazy)(()=>U(()=>import(`./preview-pane-connected-B_yXVXFs.js`).then(e=>({default:e.ConnectedPreviewPane})),__vite__mapDeps([6,5,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]))),hA=2;function gA(e){let[t,n]=(0,Z.useState)(void 0);return(0,Z.useEffect)(()=>{let t=e.current?.closest(`[data-slot="main"]`);if(!t)return;let r=()=>n(t.clientHeight||void 0);if(r(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(r);return i.observe(t),()=>i.disconnect()},[e]),t}function _A({run:e,state:t,children:n,report:r}){let i=pA(dA,!0),a=pA(fA,!1),o=(0,Z.useRef)(null),s=gA(o),{percent:c,setPercent:l}=t,u=!!r||t.open&&e!==void 0,d=u&&!i,f=!r&&t.session,p=d&&!f,m=d&&f,h=e=>{let t=o.current?.getBoundingClientRect();!t||t.width===0||l(tA((t.right-e)/t.width*100))},g=e=>{e.currentTarget.setPointerCapture?.(e.pointerId)},_=e=>{e.currentTarget.hasPointerCapture?.(e.pointerId)&&h(e.clientX)},v=e=>{if(e.key===`ArrowLeft`)l(tA(c+hA));else if(e.key===`ArrowRight`)l(tA(c-hA));else return;e.preventDefault()},y={"--preview-pane":`${c}%`,...s===void 0?{}:{"--preview-h":`${s}px`}};return(0,Q.jsxs)(`div`,{ref:o,"data-slot":`task-split`,"data-pane":u?`open`:`closed`,"data-takeover":p?``:void 0,className:`preview-split flex min-h-full`,style:y,children:[(0,Q.jsx)(`div`,{"data-slot":`task-main`,hidden:p&&a,"data-collapsed":p&&!a?``:void 0,className:`min-w-0 flex-1`,children:n}),u?(0,Q.jsxs)(Q.Fragment,{children:[i?(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize preview`,"aria-valuemin":30,"aria-valuemax":75,"aria-valuenow":c,tabIndex:0,"data-slot":`preview-divider`,className:`preview-divider`,onPointerDown:g,onPointerMove:_,onKeyDown:v}):null,(0,Q.jsxs)(`aside`,{"data-slot":`preview-pane`,"data-phone":a?``:void 0,hidden:m,className:`preview-pane`,children:[r,(0,Q.jsx)(`div`,{hidden:!!r,className:`h-full`,children:t.open&&e?(0,Q.jsx)(Qk,{onClose:t.closePane,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,className:`p-6 text-sm text-muted-foreground`,children:`Opening the preview…`}),children:(0,Q.jsx)(mA,{run:e,servers:e.previewServers??[],request:t.request,onSession:p?t.showSession:void 0,onTarget:t.setTarget,onLive:t.setLive,onClose:t.closePane},e.id)})}):null})]})]}):null]})}function vA(e){if(!e.worktreePath||e.worktreeReclaimedAt)return!0;let t=e.delegation?.role===`worker`?e.delegation.destroy:void 0;return t!==void 0&&!t.remaining.includes(`worktree`)}function yA(e){let{state:t,server:n}=e,r=za(e.stateAt);switch(t){case`registered`:return n.answeredAtRegistration?{tone:`neutral`,ring:!1,pulse:!1,text:`was running when registered`}:{tone:`neutral`,ring:!0,pulse:!1,text:`registered · not started`};case`adopted`:return{tone:`neutral`,ring:!1,pulse:!1,text:`was running when registered`};case`starting`:return{tone:`pending`,ring:!1,pulse:!0,text:`starting`};case`up`:return{tone:`success`,ring:!1,pulse:!1,text:r?`up · ${r}`:`up`};case`stalled`:return{tone:`pending`,ring:!1,pulse:!1,text:`stalled · port silent 2 min`};case`exited`:return{tone:`danger`,ring:!1,pulse:!1,text:e.exitCode===void 0?`exited`:`exited · code ${e.exitCode}`};case`stopped`:return{tone:`neutral`,ring:!0,pulse:!1,text:e.reason===`idle`?`stopped after 15 min idle`:`stopped`};case`unavailable`:return{tone:`neutral`,ring:!0,pulse:!1,text:`unavailable`}}}function bA(e){return{kind:`preview-server`,id:`preview-server:${e.port}`,server:e,state:`registered`,stateAt:e.registeredAt}}function xA(e,t){return t?.get(e.port)??bA(e)}function SA(e){return e.state===`registered`?e.server.answeredAtRegistration:e.state===`up`||e.state===`starting`||e.state===`adopted`}function CA(e){return e.split(` -- `)[0].trim()}var wA=(0,Z.createContext)(null);function TA(){return(0,Z.useContext)(wA)}var EA=e=>e&&`port`in e?e.port:void 0;function DA(){return typeof window.matchMedia!=`function`||window.matchMedia(`(min-width: 1180px)`).matches}function OA(e){let t=e===void 0?void 0:oA(e),n=t?.open===!0,r=n?t.target:void 0;return{open:n,target:r,request:n?{...r,restored:!0}:void 0,session:n&&!DA(),percent:lA(e)}}function kA(e,t=!1){let[n]=(0,Z.useState)(()=>OA(e)),[r,i]=(0,Z.useState)(n.open),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(n.target),[l,u]=(0,Z.useState)(n.session),[d,f]=(0,Z.useState)(n.request),[p,m]=(0,Z.useState)(n.percent),[h,g]=(0,Z.useState)(e),_=(0,Z.useRef)(r);if(_.current=r,h!==e){let t=OA(e);g(e),i(t.open),o(!1),c(t.target),u(t.session),f(t.request),m(t.percent)}t&&r&&d?.restored&&(i(!1),c(void 0),f(void 0),u(!1));let v=(0,Z.useCallback)(t=>{e!==void 0&&sA(e,t)},[e]),y=(0,Z.useCallback)(e=>{f({...e});let t=e.port===void 0?e.agent?{agent:!0}:void 0:{port:e.port};u(!1),i(!0),t?(c(t),v({open:!0,target:t})):_.current?v({open:!0}):(c(void 0),v({open:!0,target:void 0}))},[v]),b=(0,Z.useCallback)(()=>{i(!1),o(!1),u(!1),c(void 0),v({open:!1})},[v]),x=(0,Z.useCallback)(e=>{c(e),v({target:e})},[v]),S=(0,Z.useCallback)(t=>{m(t),uA(e,t)},[e]),C=(0,Z.useCallback)(()=>u(!0),[]),w=EA(s);return(0,Z.useMemo)(()=>({open:r,live:a,port:w,target:s,percent:p,request:d,session:l,openPane:y,closePane:b,showSession:C,setLive:o,setTarget:x,setPercent:S}),[r,a,w,s,p,d,l,y,b,C,x,S])}function AA(e,t={}){let[n,r]=(0,Z.useState)([]),{cursor:i,afterSeq:a=0,maxEvents:s,compactAt:c,onCompact:l,onReset:u}=t;return(0,Z.useEffect)(()=>{if(r([]),!e)return;let t=a,n=!1,d=!1,f=o(),p=[],m,h,g=()=>{if(m!==void 0&&globalThis.cancelAnimationFrame?.(m),clearTimeout(h),m=void 0,h=void 0,n||p.length===0)return;let e=p;p=[],r(t=>{let r=[...t,...e];return!d&&c!==void 0&&r.length>=c&&(d=!0,queueMicrotask(()=>{n||l?.()})),s===void 0||r.length<=s?r:r.slice(-s)})},_=()=>{h===void 0&&(h=setTimeout(g,50),typeof globalThis.requestAnimationFrame==`function`&&(m=globalThis.requestAnimationFrame(g)))},v=ce({kind:`run`,projectId:f,runId:e,afterSeq:a,...i?{cursor:i}:{}},{frame:e=>{!(`type`in e)||e.type!==`event`||e.event.seq<=t||(t=e.event.seq,p.push(e.event),_())},reset:async(e,n)=>{g();let r=await u?.(e,n);return r&&(t=Math.max(t,r.afterSeq)),r}});return()=>{n=!0,m!==void 0&&globalThis.cancelAnimationFrame?.(m),clearTimeout(h),v()}},[e,i,a,s,c,l,u]),n}var jA=5,MA=200,NA=5e3;function PA(...e){let t=new Map;for(let n of e)for(let e of n)t.set(e.seq,e);return[...t.values()].sort((e,t)=>e.seq-t.seq)}function FA(e,t,n){e.setQueryData(t,e=>{if(!e)return{pages:[n],pageParams:[void 0]};let t=[...e.pages],r=[...e.pageParams],i=-1;for(let e=0;e<t.length;e+=1)(i===-1||t[e].asOfSeq>t[i].asOfSeq)&&(i=e);if(i>=0&&t[i].asOfSeq>n.asOfSeq)return e;for(i>=0&&t[i].newerCursor===void 0?(t[i]=n,r[i]=void 0):(t.push(n),r.push(void 0));t.length>jA;)t.shift(),r.shift();return{pages:t,pageParams:r}})}function IA(e,t){return e!==void 0&&(t===void 0||e.asOfSeq>=t.asOfSeq)}function LA(e,t,n,r){let i=(0,Z.useRef)(void 0),a=r&&t.data!==void 0&&!t.isFetching&&!IA(t.data,n),o=e===void 0||n===void 0?void 0:`${e}:${n.asOfSeq}`;(0,Z.useEffect)(()=>{!a||o===void 0||i.current===o||(i.current=o,t.refetch())},[a,t,o])}function RA(e,t){return e!==void 0&&e.asOfSeq>t.asOfSeq?e:t}function zA(e){let t=o(),n=L(),r=[`run-history`,t,e],i=[`run-history-context`,t,e],a=on({queryKey:r,enabled:e!==void 0,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>Rt(e,t,{signal:n}),getPreviousPageParam:e=>e.olderCursor,getNextPageParam:e=>e.newerCursor,maxPages:jA,staleTime:1/0,retry:1}),s=wr({queryKey:i,enabled:e!==void 0,queryFn:async({signal:t})=>{let r=await Fe(e,{signal:t});return RA(n.getQueryData(i),r)},retry:1}),c=(0,Z.useCallback)(async r=>{let i=r?{signal:r}:void 0,a=await Rt(e,void 0,i),o=await Fe(e,i);return r?.throwIfAborted(),FA(n,[`run-history`,t,e],a),n.setQueryData([`run-history-context`,t,e],e=>RA(e,o)),a},[n,e,t]),l=(0,Z.useCallback)(async(t,n)=>{if(e===void 0)return;let r=await c(n);return{cursor:r.liveCursor,afterSeq:r.asOfSeq}},[c,e]),u=a.isError||s.isError,d=AA(u?e:void 0,{onReset:l}),f=a.data?.pages??[],p=f.reduce((e,t)=>t.newerCursor===void 0?t:e??t,void 0),m=(0,Z.useRef)(!1),h=(0,Z.useCallback)(()=>{e===void 0||m.current||(m.current=!0,c().catch(()=>{}).finally(()=>{m.current=!1}))},[c,e]),g=e=>e!==void 0&&n.getQueryData([`run-history`,t,e])!==void 0,[_,v]=(0,Z.useState)(()=>({runId:e,pending:g(e)})),y=_.pending;_.runId!==e&&(y=g(e),v({runId:e,pending:y})),(0,Z.useEffect)(()=>{if(!y||e===void 0)return;let t=!1,n=new AbortController;return c(n.signal).catch(()=>{}).finally(()=>{t||v({runId:e,pending:!1})}),()=>{t=!0,n.abort()}},[c,y,e]);let b=AA(!u&&p&&!y?e:void 0,{cursor:p?.liveCursor,afterSeq:p?.asOfSeq,maxEvents:NA,compactAt:MA,onCompact:h,onReset:l}),x=(0,Z.useRef)(0);x.current=b.length,(0,Z.useEffect)(()=>()=>{x.current>0&&h()},[h]);let S=(0,Z.useMemo)(()=>PA(...f.map(e=>e.events)),[f]),C=(0,Z.useMemo)(()=>u?d:PA(S,b),[u,d,S,b]);LA(e,s,p,!u);let w=u||IA(s.data,p),T=(0,Z.useMemo)(()=>{if(u)return d;let e=s.data?.contextEvents??[],t=s.data?.asOfSeq??0;return PA(e,C.filter(({seq:e})=>e>t))},[s.data,u,d,C]),E=(0,Z.useCallback)(async()=>{await a.fetchPreviousPage()},[a.fetchPreviousPage]),D=(0,Z.useCallback)(async()=>{u||(await n.resetQueries({queryKey:[`run-history`,t,e],exact:!0}),n.invalidateQueries({queryKey:[`run-history-context`,t,e],exact:!0}))},[u,n,e,t]);return{visibleEvents:C,currentEvents:T,currentComplete:w,isPending:!u&&a.isPending,contextPending:!u&&s.isPending,fallback:u,hasOlder:!u&&!!a.hasPreviousPage,isFetchingOlder:a.isFetchingPreviousPage,olderError:a.isFetchPreviousPageError?a.error instanceof Error?a.error.message:`Could not load earlier items`:void 0,loadOlder:E,jumpToLatest:D,retainedPages:f.length}}function BA(e){for(let t=e.length-1;t>=0;--t){let n=Pt.safeParse(e[t]);if(n.success)return n.data.state===`connected`}return!1}function VA(e){let{currentEvents:t}=zA(e);return(0,Z.useMemo)(()=>BA(t),[t])}var HA=(0,Z.lazy)(()=>U(()=>import(`./report-reader-BRw4X5KH.js`).then(e=>({default:e.ReportReader})),__vite__mapDeps([26,5,7,8,9,10,11,27,28,29,30,31,12,22,32,13,33])));function UA(){let{id:e}=r(),n=er(e),i=t(),a=On().data?.capabilities?.preview===!0,o=n.data?vA(n.data):!1,s=kA(e,o),c=Zk(e),l=Kk(e,c.selection?.artifactId,c.sourceRunId),u=c.selection?(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading report…`}),children:(0,Q.jsx)(HA,{runId:l.data??e??``,selection:{artifactId:c.selection.artifactId},fragment:i.hash,onBack:c.close,variant:`pane`,sourceLookup:l},`${e}:${c.selection.artifactId}`)}):void 0,d=a?(0,Q.jsx)(WA,{id:e,run:n.data,pane:s,removed:o,report:u,children:(0,Q.jsx)(g,{})}):(0,Q.jsx)(_A,{run:n.data,state:{...s,open:!1},report:u,children:(0,Q.jsx)(g,{})});return(0,Q.jsx)(Xk.Provider,{value:c.registry,children:d})}function WA({id:e,run:t,pane:n,removed:r,children:i,report:a}){let o=VA(e),s=(0,Z.useMemo)(()=>({...n,worktreeRemoved:r,agentLive:o}),[n,r,o]);return(0,Q.jsx)(wA.Provider,{value:s,children:(0,Q.jsx)(_A,{run:t,state:n,report:a,children:i})})}function GA({...e}){return(0,Q.jsx)(Nd,{"data-slot":`collapsible`,...e})}function KA({...e}){return(0,Q.jsx)(Od,{"data-slot":`collapsible-trigger`,...e})}function qA({...e}){return(0,Q.jsx)(Ad,{"data-slot":`collapsible-content`,...e})}var JA={"needs-you":{label:`Needs you`,hint:`Asks a question, asks for permission, or waits for review`},failed:{label:`Failed`,hint:`Failed, with no scheduled resume`},done:{label:`Done`,hint:`Finished`},cancelled:{label:`Cancelled`,hint:`Was cancelled`},running:{label:`Running`,hint:`Runs an agent turn`},"waiting-workers":{label:`Waiting for agents`,hint:`Waits on its workers or their replies`},"waiting-ci":{label:`Waiting on CI`,hint:`Waits on a pull request's checks`},"waiting-timer":{label:`Waiting`,hint:`Waits on a timer`},"waiting-other":{label:`Any other wait`,hint:`Waits on anything else, including wait types added later`}},YA=(e,t)=>e.length===t.length&&e.every(e=>t.includes(e)),XA={name:``,description:``,url:``,token:``,tasks:!0,triggers:De,agent:!1};function ZA(e){return{name:e.name,description:e.description??``,url:e.url,token:``,tasks:e.tasks,triggers:e.triggers??De,agent:e.agent}}var QA=e=>ue.filter(t=>e.includes(t));function $A(e){let t=e.description.trim();return{name:e.name.trim(),url:e.url.trim(),...t?{description:t}:{},...e.token?{token:e.token}:{},tasks:e.tasks,...YA(e.triggers,De)?{}:{triggers:QA(e.triggers)},agent:e.agent}}function ej(e,t){let n={},r=e.name.trim(),i=e.description.trim(),a=e.url.trim();return r!==t.name&&(n.name=r),i!==(t.description??``)&&(n.description=i),a!==t.url&&(n.url=a),e.token&&(n.token=e.token),e.tasks!==t.tasks&&(n.tasks=e.tasks),YA(e.triggers,t.triggers??De)||(n.triggers=QA(e.triggers)),e.agent!==t.agent&&(n.agent=e.agent),n}var tj=`flex flex-col gap-1 text-[13px]`,nj=`text-[11px] text-muted-foreground`;function rj({draft:e,onChange:t,tokenSet:n}){let r=(0,Z.useId)(),i=(0,Z.useId)(),a=(0,Z.useId)(),o=(0,Z.useId)(),s=(0,Z.useId)(),c=(0,Z.useId)(),l=(0,Z.useId)(),u=(0,Z.useId)(),d=(0,Z.useId)(),f=(0,Z.useId)();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,14rem),1fr))] gap-3`,children:[(0,Q.jsxs)(`div`,{className:tj,children:[(0,Q.jsx)(`label`,{htmlFor:r,className:nj,children:`Name`}),(0,Q.jsx)(Im,{id:r,"data-slot":`webhook-name`,autoComplete:`off`,maxLength:80,placeholder:`e.g. Team bot`,value:e.name,onChange:e=>t({name:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:tj,children:[(0,Q.jsx)(`label`,{htmlFor:o,className:nj,children:`URL`}),(0,Q.jsx)(Im,{id:o,"data-slot":`webhook-url`,type:`url`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,maxLength:ot,placeholder:`https://bot.example/hooks/cez`,value:e.url,onChange:e=>t({url:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{className:tj,children:[(0,Q.jsx)(`label`,{htmlFor:i,className:nj,children:`Description`}),(0,Q.jsx)(pC,{id:i,"data-slot":`webhook-description`,"aria-describedby":a,rows:2,maxLength:ct,placeholder:`e.g. Posts to the #releases channel. Use it for release notes.`,value:e.description,onChange:e=>t({description:e.target.value})}),(0,Q.jsx)(`span`,{id:a,className:`text-[11px] text-soft-foreground`,children:`Agents read the name and description to decide when to use this webhook.`})]}),(0,Q.jsxs)(`div`,{className:tj,children:[(0,Q.jsx)(`label`,{htmlFor:s,className:nj,children:`Token`}),(0,Q.jsx)(Im,{id:s,"data-slot":`webhook-token`,type:`password`,autoComplete:`new-password`,spellCheck:!1,maxLength:re,"aria-describedby":c,placeholder:n?`Token set — type to replace`:`Optional Bearer token`,value:e.token,onChange:e=>t({token:e.target.value})}),(0,Q.jsx)(`span`,{id:c,className:`text-[11px] text-soft-foreground`,children:n?`The token is stored in ~/.cezar and never shown again. Leave it empty to keep it.`:`The token is stored in ~/.cezar, never in the repo. It is sent as a Bearer header.`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3`,children:[(0,Q.jsx)(Um,{id:l,"aria-describedby":u,"data-slot":`webhook-tasks`,checked:e.tasks,onCheckedChange:e=>t({tasks:e})}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col text-[13px]`,children:[(0,Q.jsx)(`label`,{htmlFor:l,className:`font-medium`,children:`Task notifications`}),(0,Q.jsx)(`span`,{id:u,className:`text-[11px] text-soft-foreground`,children:`Tasks you hand off, or start with notify on, send their status here.`})]})]}),e.tasks?(0,Q.jsxs)(`fieldset`,{"data-slot":`webhook-triggers`,className:`flex flex-col gap-1 sm:ps-[3.25rem]`,children:[(0,Q.jsx)(`legend`,{className:`pbe-1 text-[11px] text-muted-foreground`,children:`Send a delivery when a task enters`}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-x-3`,children:ue.map(n=>(0,Q.jsxs)(`label`,{className:`flex min-h-11 items-start gap-2.5 pbs-2 text-[13px]`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"data-trigger":n,checked:e.triggers.includes(n),onChange:r=>t({triggers:r.target.checked?[...e.triggers,n]:e.triggers.filter(e=>e!==n)}),className:`mbs-0.5 size-[18px] shrink-0`}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:JA[n].label}),(0,Q.jsx)(`span`,{className:`text-[11px] text-soft-foreground`,children:JA[n].hint})]})]},n))}),(0,Q.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Handing a task off and Send test always deliver.`})]}):null]}),(0,Q.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3`,children:[(0,Q.jsx)(Um,{id:d,"aria-describedby":f,"data-slot":`webhook-agent`,checked:e.agent,onCheckedChange:e=>t({agent:e})}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col text-[13px]`,children:[(0,Q.jsx)(`label`,{htmlFor:d,className:`font-medium`,children:`Let agents send reports`}),(0,Q.jsx)(`span`,{id:f,className:`text-[11px] text-soft-foreground`,children:`Agents in this project may post a report here when the task calls for it.`})]})]})]})}var ij=`max-sm:h-11`,aj=(e,t)=>({tone:`alert`,text:`Not saved: ${e.message}. Fix the field and select ${t} again.`}),oj=e=>e.dryRun?{tone:`ok`,text:`Dry run: nothing was sent.`}:e.ok?{tone:`ok`,text:`Delivered (HTTP ${e.status??200}).`}:{tone:`danger`,text:`Not delivered: ${e.error??`unknown error`}.`};function sj({feedback:e}){return e?(0,Q.jsx)(`p`,{"data-slot":e.tone===`alert`?`webhook-error`:`webhook-result`,role:e.tone===`alert`?`alert`:`status`,className:e.tone===`ok`?`text-[13px] text-muted-foreground`:`text-[13px] text-danger`,children:e.text}):null}var cj=`rounded-md border border-border bg-background`,lj=`flex flex-col gap-3 border-bs border-border p-3`;function uj({projectId:e,webhook:t,defaultOpen:n=!1}){let r=yn(),i=Xn(),a=Tn(),[o,s]=(0,Z.useState)(n),[c,l]=(0,Z.useState)(()=>ZA(t)),[u,d]=(0,Z.useState)(null),f=ej(c,t),p=Object.keys(f).length>0,m=c.name.trim()!==``&&c.url.trim()!==``,h=r.isPending||i.isPending||a.isPending,g={projectId:e,webhookId:t.id},_=e=>r.mutate({...g,...f},{onSuccess:()=>{l(e=>({...e,token:``})),e?e():G(`${c.name.trim()} saved`)},onError:e=>d(aj(e,`Save`))}),v=()=>a.mutate(g,{onSuccess:e=>d(oj(e)),onError:e=>d({tone:`danger`,text:e.message})});return(0,Q.jsx)(`li`,{"data-slot":`webhook-card`,"data-webhook-id":t.id,className:cj,children:(0,Q.jsxs)(GA,{open:o,onOpenChange:s,children:[(0,Q.jsx)(KA,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-action":`webhook-toggle`,className:`group flex min-h-11 w-full items-center gap-3 rounded-md p-3 text-start focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-foreground pointer-hover:bg-muted/50 active:bg-muted/50`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Q.jsx)(`span`,{"data-slot":`webhook-card-name`,className:`min-w-0 break-words text-[13px] font-medium`,children:t.name}),t.tasks?(0,Q.jsx)(Dm,{variant:`secondary`,"data-badge":`tasks`,children:`Task notifications`}):null,t.agent?(0,Q.jsx)(Dm,{variant:`secondary`,"data-badge":`agent`,children:`Agents`}):null]}),(0,Q.jsx)(`span`,{"data-slot":`webhook-card-url`,className:`truncate text-[12px] text-muted-foreground`,children:hO(t.url)})]}),(0,Q.jsx)(_a,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground group-data-[state=open]:rotate-180`})]})}),(0,Q.jsx)(qA,{children:(0,Q.jsxs)(`form`,{"data-slot":`webhook-form`,className:lj,onSubmit:e=>{e.preventDefault(),d(null),m&&p&&_()},children:[(0,Q.jsx)(rj,{draft:c,tokenSet:t.tokenSet,onChange:e=>l(t=>({...t,...e}))}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(E,{type:`submit`,size:`sm`,className:ij,"data-action":`webhook-save`,disabled:h||!m||!p,children:`Save`}),(0,Q.jsx)(E,{type:`button`,size:`sm`,className:ij,variant:`outline`,"data-action":`webhook-test`,disabled:h||!m,onClick:()=>{d(null),p?_(v):v()},children:`Send test`}),t.tokenSet?(0,Q.jsx)(E,{type:`button`,size:`sm`,className:ij,variant:`ghost`,"data-action":`webhook-clear-token`,disabled:h,onClick:()=>r.mutate({...g,token:``},{onSuccess:()=>G(`Webhook token cleared`),onError:e=>d({tone:`danger`,text:`Token not cleared: ${e.message}.`})}),children:`Clear token`}):null,(0,Q.jsx)(E,{type:`button`,size:`sm`,className:ij,variant:`danger-ghost`,"data-action":`webhook-remove`,"aria-label":`Remove ${t.name}`,disabled:h,onClick:()=>i.mutate(g,{onSuccess:()=>G(`${t.name} removed`),onError:e=>d({tone:`danger`,text:`Not removed: ${e.message}.`})}),children:`Remove`})]}),(0,Q.jsx)(sj,{feedback:u})]})})]})})}function dj({projectId:e,onCreated:t,onCancel:n}){let r=Jn(),[i,a]=(0,Z.useState)(XA),[o,s]=(0,Z.useState)(null),c=i.name.trim()!==``&&i.url.trim()!==``;return(0,Q.jsxs)(`li`,{"data-slot":`webhook-card`,"data-draft":``,className:cj,children:[(0,Q.jsx)(`p`,{className:`p-3 text-[13px] font-medium`,children:`New webhook`}),(0,Q.jsxs)(`form`,{"data-slot":`webhook-form`,"aria-label":`New webhook`,className:lj,onSubmit:n=>{n.preventDefault(),s(null),c&&r.mutate({projectId:e,...$A(i)},{onSuccess:({webhook:e})=>{G(`${e.name} created`),t(e)},onError:e=>s(aj(e,`Create`))})},children:[(0,Q.jsx)(rj,{draft:i,tokenSet:!1,onChange:e=>a(t=>({...t,...e}))}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(E,{type:`submit`,size:`sm`,className:ij,"data-action":`webhook-create`,disabled:r.isPending||!c,children:`Create`}),(0,Q.jsx)(E,{type:`button`,size:`sm`,className:ij,variant:`ghost`,"data-action":`webhook-cancel`,disabled:r.isPending,onClick:n,children:`Cancel`})]}),(0,Q.jsx)(sj,{feedback:o})]})]})}function fj({project:e}){let t=e.webhooks??[],[n,r]=(0,Z.useState)(!1),[i,o]=(0,Z.useState)(null),s=t.length>=16;return(0,Q.jsx)(cw,{title:`Webhooks`,hint:`A webhook gets a POST from ${a(`cezar`)}. Tasks can send their status to it, and agents can send it reports.`,children:(0,Q.jsxs)(`div`,{"data-slot":`project-webhooks`,className:`flex flex-col gap-3`,children:[t.length===0&&!n?(0,Q.jsx)(`p`,{"data-slot":`webhooks-empty`,className:`text-[13px] text-soft-foreground`,children:`No webhooks yet. Add one to send task updates to a bot, or to let agents post reports.`}):null,t.length>0||n?(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-2`,children:[t.map(t=>(0,Q.jsx)(uj,{projectId:e.id,webhook:t,defaultOpen:t.id===i},t.id)),n?(0,Q.jsx)(dj,{projectId:e.id,onCancel:()=>r(!1),onCreated:e=>{o(e.id),r(!1)}}):null]}):null,n?null:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(E,{type:`button`,size:`sm`,variant:`outline`,className:`max-sm:h-11`,"data-action":`webhook-add`,disabled:s,onClick:()=>r(!0),children:[(0,Q.jsx)(Xu,{"aria-hidden":`true`}),`Add webhook`]}),s?(0,Q.jsxs)(`span`,{className:`text-[11px] text-soft-foreground`,children:[`A project holds at most `,16,` webhooks.`]}):null]})]})})}function pj(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}function mj(){let e=Cs(),t=An(),n=Mn();if(t.isPending)return(0,Q.jsx)(`p`,{"data-slot":`project-general-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading project…`});if(t.isError)return(0,Q.jsxs)(`p`,{"data-slot":`project-general-error`,className:`text-[13px] text-danger`,children:[`Could not read the project registry — `,t.error.message]});let r=t.data,i=r?.projects.find(t=>t.id===e);return!r||!i?null:(0,Q.jsxs)(`div`,{"data-slot":`project-general`,className:`flex w-full flex-col gap-5`,children:[(0,Q.jsxs)(`section`,{className:`flex flex-col gap-5 rounded-lg border border-border bg-card p-5 [&_select]:min-h-11 [&_select]:w-full`,children:[(0,Q.jsx)(`h2`,{className:`text-lg font-semibold`,children:`General`}),(0,Q.jsx)(Ww,{}),(0,Q.jsx)(hj,{project:i}),(0,Q.jsx)(cw,{title:`Max parallel tasks`,hint:n.data?`The workspace limit (${n.data.resources.maxParallel}) still applies as an overall ceiling.`:`How many of this project's tasks may run at once. The workspace limit still applies as an overall ceiling.`,children:n.data?(0,Q.jsx)(vw,{project:i,workspaceMax:n.data.resources.maxParallel}):(0,Q.jsx)(`p`,{className:`text-[13px] text-soft-foreground`,children:`Loading the workspace limit…`})}),(0,Q.jsx)(fj,{project:i},i.id)]}),(0,Q.jsx)(`section`,{className:`rounded-lg border border-border bg-card p-5`,children:(0,Q.jsx)(gj,{project:i,bootProject:r.bootProject})})]})}function hj({project:e}){return(0,Q.jsxs)(`dl`,{"data-slot":`project-facts`,className:`grid grid-cols-1 gap-4 text-[13px] sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Project`}),(0,Q.jsx)(`dd`,{className:`mt-1 font-medium`,children:e.name})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Branch`}),(0,Q.jsx)(`dd`,{className:`mt-1 break-all`,children:e.branch??`—`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Status`}),(0,Q.jsxs)(`dd`,{"data-slot":`project-general-status`,className:e.status===`missing`?`mt-1 text-danger`:`mt-1`,children:[uw[e.status],e.status===`missing`?` — remove it below, or restore the folder`:null]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Added`}),(0,Q.jsxs)(`dd`,{className:`mt-1`,children:[pj(e.addedAt),(0,Q.jsx)(`span`,{className:`text-soft-foreground`,children:e.source===`checkout`?` · cloned from GitHub`:` · opened locally`})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Last opened`}),(0,Q.jsx)(`dd`,{className:`mt-1`,children:pj(e.lastOpenedAt)})]})]})}function gj({project:e,bootProject:t}){let[n,r]=(0,Z.useState)(null),i=ow(),o=k(),s=e.id===t;return(0,Q.jsxs)(cw,{title:`Remove from workspace`,hint:`Unregisters this project so it leaves the sidebar and the project list. Nothing on disk is deleted — the folder, its git history and its task history all stay, and opening it again re-registers it.`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(E,{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:s?`${a(`cezar`)} is serving this project — it re-registers itself at every start`:void 0,disabled:s||i.isPending,onClick:()=>r(e),className:`text-danger`,children:[`Remove `,e.name]}),s?(0,Q.jsxs)(`span`,{"data-slot":`project-general-remove-boot`,className:`text-[11px] text-soft-foreground`,children:[a(`cezar`),` is serving this project — it re-registers itself at every start.`]}):null]}),(0,Q.jsx)(sw,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{r(null),i.confirm(e,()=>void o(`/p/${encodeURIComponent(t)}`))}})]})}function _j(e,t){return e===`global`?`/settings/global/${t}`:`/settings/${t}`}var vj=_j(`global`,`appearance`);function yj(e){return e===`global`?{Link:C,NavLink:S}:{Link:Y,NavLink:bs}}function bj({scope:e,title:t,mobileTitle:n}){let r=Th().name;return(0,Q.jsxs)(`header`,{"data-slot":`settings-main-header`,className:`settings-route-header flex shrink-0 flex-col gap-2`,children:[(0,Q.jsxs)(`h1`,{className:`text-[15px] font-semibold tracking-normal max-md:text-[24px] max-md:font-normal`,children:[(0,Q.jsx)(`span`,{className:`md:hidden`,children:n}),(0,Q.jsxs)(`span`,{className:`max-md:hidden`,children:[t,` · `,e===`global`?`every project`:r??`this project`]})]}),e===`global`?(0,Q.jsx)(`span`,{"data-slot":`settings-scope-chip`,className:`sr-only`,children:`Global settings`}):null]})}function xj({scope:e,activeId:t}){let{NavLink:n}=yj(e),r=Qw(e);return(0,Q.jsxs)(`details`,{className:`settings-section-picker md:hidden`,children:[(0,Q.jsxs)(`summary`,{children:[r.find(e=>e.id===t)?.title??`General`,(0,Q.jsx)(_a,{"aria-hidden":`true`,className:`size-5 text-muted-foreground`})]}),(0,Q.jsxs)(`nav`,{"aria-label":`Settings sections`,"data-slot":`settings-nav-mobile`,"data-scope":e,children:[e===`project`?(0,Q.jsx)(n,{to:`/settings`,end:!0,"data-slot":`settings-nav-index`,children:`General`}):null,r.map(t=>(0,Q.jsx)(n,{to:_j(e,t.id),"data-section":t.id,children:t.title},t.id))]})]},`${e}-${t}`)}function Sj({section:e,scope:t}){let n=e.component;return(0,Q.jsxs)(`div`,{"data-route":t===`global`?`settings-global-${e.id}`:`settings-${e.id}`,className:`settings-route mx-auto flex min-h-full w-full flex-col`,children:[(0,Q.jsx)(bj,{scope:t,title:e.title,mobileTitle:t===`global`?`Global settings`:`Project settings`}),(0,Q.jsxs)(`div`,{className:`settings-route-body flex min-w-0 flex-1 flex-col md:flex-row`,children:[(0,Q.jsx)(xj,{scope:t,activeId:e.id}),(0,Q.jsxs)(`section`,{className:`settings-panel min-w-0 self-start md:flex-1`,"aria-label":e.title,children:[(0,Q.jsx)(`h2`,{className:`settings-panel-title`,children:e.title}),(0,Q.jsx)(n,{})]})]})]})}function Cj(){return(0,Q.jsxs)(`div`,{"data-route":`settings`,className:`settings-route mx-auto flex min-h-full w-full flex-col`,children:[(0,Q.jsx)(bj,{scope:`project`,title:`General`,mobileTitle:`Project settings`}),(0,Q.jsxs)(`div`,{className:`settings-route-body flex min-w-0 flex-1 flex-col md:flex-row`,children:[(0,Q.jsx)(xj,{scope:`project`,activeId:null}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-5`,children:[(0,Q.jsx)(mj,{}),(0,Q.jsx)(`section`,{className:`rounded-lg border border-border bg-card p-5`,children:(0,Q.jsx)(oS,{})}),(0,Q.jsx)(`h2`,{className:`settings-other-title mt-6 rounded-t-lg border border-b-0 border-border bg-card px-5 pt-5 text-base font-semibold md:hidden`,children:`Other project settings`}),(0,Q.jsx)(`ul`,{"data-slot":`settings-index`,className:`mt-7 flex w-full flex-col gap-5 md:hidden`,children:Qw(`project`).map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(Y,{to:_j(`project`,e.id),"data-section":e.id,className:`flex items-center gap-3.5 rounded-lg border border-border bg-card p-4 transition-colors hover:bg-card-2`,children:[(0,Q.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center text-accent-text`,children:(0,Q.jsx)(e.icon,{"aria-hidden":`true`,className:`size-4`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:e.title}),(0,Q.jsx)(`span`,{className:`block text-xs text-soft-foreground`,children:e.description})]}),(0,Q.jsx)(Ji,{"aria-hidden":`true`,className:`size-4 shrink-0 text-soft-foreground`})]})},e.id))}),(0,Q.jsxs)(`p`,{className:`mt-5 w-full text-[12px] text-soft-foreground`,children:[`Appearance, notifications, host resources and the project registry live in`,` `,(0,Q.jsx)(C,{to:vj,"data-slot":`settings-global-link`,className:`underline underline-offset-2 hover:text-foreground`,children:`Global settings`}),`.`]})]})]})]})}function wj(){let[e,t]=(0,Z.useState)(()=>new Set);return{expandedRuns:e,toggleExpandedRun:(0,Z.useCallback)(e=>t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[])}}var Tj=[{id:`status`,label:`Status`,canFold:!1,defaultExpanded:!0,align:`left`,width:`120px`},{id:`task`,label:`Task`,canFold:!1,defaultExpanded:!0,align:`left`,width:`320px`},{id:`workflow`,label:`Workflow`,canFold:!0,defaultExpanded:!0,align:`left`,width:`84px`,icon:`workflow`},{id:`branch`,label:`Branch`,canFold:!0,defaultExpanded:!1,align:`left`,width:`120px`,icon:`branch`},{id:`diff`,label:`±`,canFold:!0,defaultExpanded:!0,align:`left`,width:`84px`,icon:`diff`},{id:`reference`,label:`Ref`,canFold:!0,defaultExpanded:!0,align:`left`,width:`104px`,icon:`reference`},{id:`tokens`,label:`IN / OUT`,canFold:!0,defaultExpanded:!0,align:`right`,width:`112px`,icon:`tokens`,capability:`tokens`},{id:`cost`,label:`Cost`,canFold:!0,defaultExpanded:!0,align:`right`,width:`64px`,icon:`cost`,capability:`cost`},{id:`cpu`,label:`CPU`,canFold:!0,defaultExpanded:!0,align:`right`,width:`60px`,icon:`cpu`},{id:`memory`,label:`Mem`,canFold:!0,defaultExpanded:!0,align:`right`,width:`80px`,icon:`memory`},{id:`started`,label:`Started`,canFold:!0,defaultExpanded:!0,align:`right`,width:`68px`,icon:`started`}],Ej=new Map(Tj.map(e=>[e.id,e]));function Dj(e){return typeof e!=`object`||!e||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`boolean`))}function Oj(e){let t={};for(let[n,r]of Object.entries(Dj(e))){let e=Ej.get(n);e?.canFold&&(t[e.id]=r)}return t}function kj(e,t){let n=Ej.get(e);return!n||!n.canFold?!0:t[e]??n.defaultExpanded}function Aj(e,t){let n=Dj(e);return Ej.get(t)?.canFold?{...n,[t]:!kj(t,Oj(e))}:n}function jj(e){return Tj.filter(t=>t.capability===void 0||e[t.capability])}function Mj(e,t){return t===`flat`?!1:t===`virtual`||e>=100}function Nj(e,t){let n=t===null?-1:e.indexOf(t);return n<0?[]:[n-1,n,n+1].filter(t=>t>=0&&t<e.length)}function Pj(e,t){let n=e.map(e=>kj(e.id,t)?e.id===`workflow`||e.id===`memory`?120:Number.parseFloat(e.width??`100`):42);return{"--task-columns":e.map((e,t)=>e.id===`task`?`minmax(${n[t]}px, 1fr)`:`${n[t]}px`).join(` `),minInlineSize:Math.max(1240,n.reduce((e,t)=>e+t,0))}}function Fj(e,t){let n=2;return{indexes:e.map(e=>{let r=n;return n+=t.has(e)?2:1,r}),rowCount:n-1}}var Ij=null,{min:Lj,max:Rj,abs:zj,floor:Bj}=Math,Vj=(e,t,n)=>Lj(n,Rj(t,e)),Hj=e=>[...e].sort((e,t)=>e-t),Uj=typeof queueMicrotask==`function`?queueMicrotask:e=>{Promise.resolve().then(e)},Wj=()=>{let e;return[new Promise(t=>{e=t}),e]},Gj=e=>{let t;return()=>(e&&=(t=e(),void 0),t)},Kj=(e,t,n)=>{let r=n?`unshift`:`push`;for(let n=0;n<t;n++)e[r](-1);return e},qj=(e,t)=>{let n=e.t[t];return n===-1?e.o:n},Jj=(e,t,n)=>{let r=e.t[t]===-1;return e.t[t]=n,e.i=Lj(t,e.i),r},Yj=(e,t)=>{if(!e.l)return 0;if(e.i>=t)return e.u[t];e.i<0&&(e.u[0]=0,e.i=0);let n=e.i,r=e.u[n];for(;n<t;)r+=qj(e,n),e.u[++n]=r;return e.i=t,r},Xj=(e,t,n=0,r=e.l-1)=>{let i=n;for(;n<=r;){let a=Bj((n+r)/2);Yj(e,a)<=t?(i=a,n=a+1):r=a-1}return Vj(i,0,e.l-1)},Zj=(e,t,n)=>{let r=t-e.l;return e.i=n?-1:Lj(t-1,e.i),e.l=t,r>0?(Kj(e.u,r),Kj(e.t,r,n),e.o*r):(e.u.splice(r),(n?e.t.splice(0,-r):e.t.splice(r)).reduce((t,n)=>t-(n===-1?e.o:n),0))},Qj=typeof window<`u`,$j=e=>e.documentElement,eM=e=>e.ownerDocument,tM=e=>e.defaultView,nM=Gj(()=>!!/iP(hone|od|ad)/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>0),rM=Gj(()=>`scrollBehavior`in $j(document).style),iM=e=>Rj(e.h(),e.p()),aM=(e,t=40,n=0,r,i=!1)=>{let a=!!n,o=1,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=Ij,g=[0,a?Rj(n-1,0):-1],_=0,v=!1,y=((e,t,n)=>({o:t,t:n?Kj(n.slice(0,Lj(e,n.length)),Rj(0,e-n.length)):Kj([],e),l:e,i:-1,u:Kj([],e+1)}))(e,r?r[1]:t,r&&r[0]),b=new Set,x=()=>l-c,S=()=>x()+d+u,C=(e,t)=>((e,t,n,r)=>{if(r=Lj(r,e.l-1),Yj(e,r)<=t){let i=Xj(e,n,r);return[Xj(e,t,r,i),i]}{let i=Xj(e,t,void 0,r);return[i,Xj(e,n,i)]}})(y,e,t,g[0]),w=()=>Yj(y,y.l),T=(e,t)=>{let n=Yj(y,e)-d;return t?w()-n-E(e):n},E=e=>qj(y,e),D=(e,t=-1)=>y.t[e]===t,O=e=>{e&&(nM()&&p!==0||h&&m===1?d+=e:u+=e)};return{v:()=>{b.clear()},m:()=>o,_:()=>(e=>[e.t.slice(),e.o])(y),S:(e=200)=>{if(!v||a)return g;let t,n;if(f)[t,n]=g;else{let r=Rj(0,S()),a=r+s;i||(e=Rj(0,e),p!==1&&(r-=e),p!==2&&(a+=e)),[t,n]=g=C(Rj(0,r),Rj(0,a)),h&&(t=Lj(t,h[0]),n=Rj(n,h[1]))}return[Rj(t,0),Lj(n,y.l-1)]},$:e=>Xj(y,e-c),I:D,k:T,R:E,T:()=>y.l,C:()=>l,M:()=>p!==0,p:()=>s,O:()=>c,h:w,H:()=>(f=u,u=0,[f,m===2]),W:(e,t)=>{let n=[e,t];return b.add(n),()=>{b.delete(n)}},B:(e,t)=>{let n,r,g=0;switch(e){case 1:{if(t===l&&m===0)break;let e=f;f=0;let n=t-l,i=zj(n);e&&i<zj(e)+1||m!==0||(p=n<0?2:1),a&&=!1,l=t,g=4;let o=x();o>=-s&&o<=w()&&(g+=1,r=i>s);break}case 2:g=8,p!==0&&(n=!0,g+=1),p=0,m=0,h=Ij;break;case 3:{let e=t.filter(([e,t])=>!D(e,t));if(!e.length)break;O(e.reduce((e,[t,n])=>{let r;if(m===2)r=!0;else if(h&&m===1)r=t<h[0];else{let e=x(),n=T(t),i=E(t);r=p!==1&&m===0?n+i<=e:n<e&&n+i<e+s}return r&&(e+=n-E(t)),e},0));for(let[t,n]of e){let e=E(t),r=Jj(y,t,n);i&&(_+=r?n:n-e)}i&&s&&_>s&&(O(((e,t)=>{let n=0,r=[];e.t.forEach((e,i)=>{e!==-1&&(r.push(e),i<t&&n++)}),e.i=-1;let i=Hj(r),a=i.length,o=a/2|0,s=a%2==0?(i[o-1]+i[o])/2:i[o],c=e.o;return((e.o=s)-c)*Rj(t-n,0)})(y,Xj(y,S()))),i=!1),g=3,r=!0;break}case 4:s!==t&&(s||(v=r=!0),s=t,g=3);break;case 5:t[1]?(O(Zj(y,t[0],!0)),m=2,g=1):(Zj(y,t[0]),g=1);break;case 6:c=t;break;case 7:m=1;break;case 8:h=C(t,t+s),g=1}g&&(o=1+(2147483647&o),n&&d&&(u+=d,d=0),b.forEach(([e,t])=>{g&e&&t(r)}))}}},oM=setTimeout,sM=(e,t)=>t?-e:e,cM=(e,t,n,r,i,a)=>{let o=Date.now,s=0,c=!1,l=!1,u=!1,d=!1,f=(()=>{let t,n=()=>{t!=Ij&&clearTimeout(t)},r=()=>{n(),t=oM(()=>{t=Ij,(()=>{if(c||l)return c=!1,void f();u=!1,e.B(2)})()},150)};return r.J=n,r})(),p=()=>{s=o(),u&&(d=!0),a&&e.B(6,a()),e.B(1,r()),f()},m=t=>{if(c||!e.M()||t.ctrlKey)return;let r=o()-s;150>r&&50<r&&(n?t.deltaX:t.deltaY)&&(c=!0)},h=()=>{l=!0,u=d=!1},g=()=>{l=!1,nM()&&(u=!0)};return t.addEventListener(`scroll`,p),t.addEventListener(`wheel`,m,{passive:!0}),t.addEventListener(`touchstart`,h,{passive:!0}),t.addEventListener(`touchend`,g,{passive:!0}),{A:()=>{t.removeEventListener(`scroll`,p),t.removeEventListener(`wheel`,m),t.removeEventListener(`touchstart`,h),t.removeEventListener(`touchend`,g),f.J()},L:()=>{let[t,n]=e.H();t&&(i(t,n,d),d=!1,n&&e.p()>e.h()&&e.B(1,r()))}}},lM=(e,t,n)=>{let r;return[async(i,a)=>{if(!await t())return;r&&r();let o=()=>{let[t,n]=Wj();return r=()=>{n(!1)},e.p()&&oM(r,150),[t,e.W(2,()=>{n(!0)})]};if(a&&rM())e.B(8,i()),Uj(async()=>{for(;;){let t=!0;for(let[n,r]=e.S();n<=r;n++)if(e.I(n)){t=!1;break}if(t)break;let[n,r]=o();try{if(!await n)return}finally{r()}}e.B(7),n(i(),a)});else for(;;){let[t,r]=o();try{if(e.B(7),n(i()),!await t)return}finally{r()}}},()=>{r&&r()}]},uM=(e,t)=>{let n,r,i=Wj(),a=!1,o=t?`scrollLeft`:`scrollTop`,s=t?`overflowX`:`overflowY`,[c,l]=lM(e,()=>i[0],(e,r)=>{e=sM(e,a),r?n.scrollTo({[t?`left`:`top`]:e,behavior:`smooth`}):n[o]=e});return{N(c,u){n=u,t&&(a=getComputedStyle(u).direction===`rtl`),r=cM(e,u,t,()=>sM(u[o],a),(t,n,r)=>{if(r){let e=u.style,t=e[s];e[s]=`hidden`,oM(()=>{e[s]=t})}u[o]=sM(e.C()+t,a),n&&l()}),i[1](!0)},v(){r&&r.A(),i[1](!1),i=Wj()},P:()=>a,V(e){c(()=>e)},X(t){t+=e.C(),c(()=>t)},Y(t,{align:n,smooth:r,offset:i=0}={}){if(t=Vj(t,0,e.T()-1),n===`nearest`){let r=e.k(t),i=e.C();if(r<i)n=`start`;else{if(!(r+e.R(t)>i+e.p()))return;n=`end`}}c(()=>i+e.O()+e.k(t)+(n===`end`?e.R(t)-e.p():n===`center`?(e.R(t)-e.p())/2:0),r)},q:()=>{r&&r.L()}}},dM=e=>{let t;return{j(n){(t||=new(tM(eM(n))).ResizeObserver(e)).observe(n)},D(e){t.unobserve(e)},A(){t&&t.disconnect()}}},fM=(e,t)=>{let n,r=t?`width`:`height`,i=new WeakMap,a=dM(t=>{let a=[];for(let{target:o,contentRect:s}of t)if(o.offsetParent)if(o===n)e.B(4,s[r]);else{let e=i.get(o);e!=Ij&&a.push([e,s[r]])}a.length&&e.B(3,a)});return{G(e){a.j(n=e)},U:(e,t)=>(i.set(e,t),a.j(e),()=>{i.delete(e),a.D(e)}),v:a.A}},pM=Qj?Z.useLayoutEffect:Z.useEffect,mM=`current`,hM=(e,t)=>{if(Array.isArray(e))for(let n of e)hM(n,t);else e==null||typeof e==`boolean`||t.push(e)},gM=(e,t)=>e.key??`_`+t,_M=e=>{let t=(0,Z.useRef)(null);return t[mM]||(t[mM]=e())},vM=e=>{let t=(0,Z.useRef)(e);return pM(()=>{t[mM]=e},[e]),t},yM=(0,Z.memo)(({Z:e,ee:t,te:n,oe:r,ne:i,re:a,se:o,ie:s})=>{let c=(0,Z.useRef)(null);pM(()=>t(c[mM],n),[n]);let l=(0,Z.useMemo)(()=>{let e={contain:`layout style`,position:i&&s?void 0:`absolute`,[o?`height`:`width`]:`100%`,[o?`top`:`left`]:0,[o?`left`:`top`]:r,visibility:!i||s?void 0:`hidden`};return o&&(e.display=`inline-flex`),e},[r,i,s,o]);return(0,Q.jsx)(a,typeof a==`string`?{ref:c,style:l,children:e}:{ref:c,style:l,index:n,children:e})}),bM=(e,t)=>(0,Z.useMemo)(()=>{if(typeof e==`function`)return[n=>e(t[n],n),t.length];let n=(e=>{let t=[];return hM(e,t),t})(e);return[e=>n[e],n.length]},[e,t]),xM=(0,Z.forwardRef)(({children:e,data:t,bufferSize:n,itemSize:r,shift:i,horizontal:a,keepMounted:o,cache:s,startMargin:c=0,ssrCount:l,as:u=`div`,item:d=`div`,scrollRef:f,onScroll:p,onScrollEnd:m},h)=>{let[g,_]=bM(e,t),v=(0,Z.useRef)(null),y=(0,Z.useRef)(!!l),b=vM(p),x=vM(m),[S,C,w,T]=_M(()=>{let e=!!a,t=aM(_,r,l,s,!r);return[t,fM(t,e),uM(t,e),e]});_!==S.T()&&S.B(5,[_,i]),c!==S.O()&&S.B(6,c);let[E,D]=(0,Z.useReducer)(S.m,void 0,S.m),O=S.M(),k=S.h(),A=w.P(),j=[],M=e=>{let t=g(e);return(0,Q.jsx)(yM,{ee:C.U,te:e,oe:S.k(e,A),ne:S.I(e),re:d,Z:t,se:T,ie:y[mM]},gM(t,e))};if(pM(()=>{y[mM]=!1,S.W(1,e=>{e?(0,zd.flushSync)(D):D()}),S.W(4,()=>{b[mM]&&b[mM](S.C())}),S.W(8,()=>{x[mM]&&x[mM]()});let e=v[mM],t=t=>{C.G(t),w.N(e,t)};return f?Uj(()=>{f[mM]&&t(f[mM])}):t(e.parentElement),()=>{S.v(),C.v(),w.v()}},[]),pM(()=>{w.q()},[E]),(0,Z.useImperativeHandle)(h,()=>({get cache(){return S._()},get scrollOffset(){return S.C()},get scrollSize(){return iM(S)},get viewportSize(){return S.p()},findItemIndex:S.$,getItemOffset:S.k,getItemSize:S.R,scrollToIndex:w.Y,scrollTo:w.V,scrollBy:w.X}),[]),o){let e=new Set(o);for(let[t,r]=S.S(n);t<=r;t++)e.add(t);Hj([...e]).forEach(e=>{j.push(M(e))})}else for(let[e,t]=S.S(n);e<=t;e++)j.push(M(e));return(0,Q.jsx)(u,{ref:v,style:{contain:`size style`,overflowAnchor:`none`,flex:`none`,position:`relative`,width:T?k:`100%`,height:T?`100%`:k,pointerEvents:O?`none`:void 0},children:j})});function SM(e,t){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(``),o=(0,Z.useRef)(!1);return{editing:n,draft:i,setDraft:a,begin:()=>{a(e),o.current=!1,r(!0)},commit:()=>{if(o.current)return;o.current=!0,r(!1);let n=i.trim();n.length===0||n===e||t(n)},cancel:()=>{o.current=!0,r(!1)}}}function CM({editor:e,className:t}){return(0,Q.jsx)(`input`,{"data-slot":`title-input`,"aria-label":`Task title`,autoFocus:!0,value:e.draft,onChange:t=>e.setDraft(t.target.value),onBlur:e.commit,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),e.commit()):t.key===`Escape`&&(t.preventDefault(),e.cancel())},className:D(`w-full min-w-0 rounded-sm border border-border bg-card px-1.5 py-0.5 outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`,t)})}function wM(e){let t=new Map,n=new Set,r;return{begin:e,editingId:()=>r?.id??null,subscribeSelection(e){return n.add(e),()=>{n.delete(e)}},snapshot:e=>r?.id===e?r.editor:null,subscribe(e,n){let r=t.get(e);return r||(r=new Set,t.set(e,r)),r.add(n),()=>{r.delete(n),r.size||t.delete(e)}},publish(e,i){let a=r?.id;if(r=e&&i.editing?{id:e,editor:i}:void 0,a!==r?.id)for(let e of n)e();for(let e of new Set([a,r?.id]))if(e)for(let n of t.get(e)??[])n()}}}var TM=(0,Z.createContext)(null),EM={editing:!1,draft:``,begin(){},setDraft(){},commit(){},cancel(){}};function DM({children:e,runs:t,onRename:n}){let[r,i]=(0,Z.useState)(),[a]=(0,Z.useState)(()=>wM(e=>i({run:e}))),o=t.find(e=>e.id===r?.run.id),s=SM(o?W(o):``,e=>{o&&n(o.id,e)});return(0,Z.useEffect)(()=>{r&&s.begin()},[r]),(0,Z.useEffect)(()=>{r&&!o&&(s.cancel(),i(void 0))},[r,o,s]),(0,Z.useLayoutEffect)(()=>{a.publish(o?.id,s)},[a,o?.id,s]),(0,Q.jsx)(TM,{value:a,children:e})}function OM(e){let t=(0,Z.useContext)(TM);if(!t)throw Error(`Task title editor needs its page provider`);return{...(0,Z.useSyncExternalStore)((0,Z.useCallback)(n=>t.subscribe(e.id,n),[t,e.id]),(0,Z.useCallback)(()=>t.snapshot(e.id),[t,e.id]))??EM,begin:()=>t.begin(e)}}var kM=()=>null;function AM(){return jM}function jM(){}function MM(){let e=(0,Z.useContext)(TM);return(0,Z.useSyncExternalStore)(e?.subscribeSelection??AM,e?.editingId??kM)}var NM=(0,Z.createContext)(null);function PM(e,t,n=!1){let[r,i]=(0,Z.useState)(null),a=(0,Z.useRef)(new Map),o=(0,Z.useCallback)((e,t)=>{t?a.current.set(e,t):a.current.delete(e)},[]),s=(0,Z.useCallback)(e=>[...a.current.values()].some(t=>t.includes(e)),[]);return{props:FM(e,t,i,n?s:void 0),value:(0,Z.useMemo)(()=>({focused:r,revision:t,registerList:n?o:void 0}),[r,t,o,n])}}function FM(e,t,n,r){let i=(0,Z.useRef)(r);(0,Z.useLayoutEffect)(()=>{i.current=r});let a=(0,Z.useRef)(null),o=(0,Z.useRef)(null);return(0,Z.useLayoutEffect)(()=>{let e=o.current;if(!e||e.element.isConnected||document.activeElement!==document.body)return;let t=()=>{o.current===e&&(o.current=null,n?.(null))},r=()=>{let n=e.project?`${e.project}/${e.runId}`:e.runId;if(i.current&&!i.current(n)||document.activeElement!==document.body||e.element.isConnected)return t(),!0;let r=[...a.current?.querySelectorAll(`[data-run-id]`)??[]].filter(t=>t.dataset.runId===e.runId&&t.dataset.project===e.project).flatMap(e=>[...e.querySelectorAll(`a,button,input`)]),o=r.find(t=>e.control?t.dataset.taskControl===e.control:t.tagName===e.tag&&t.getAttribute(`aria-label`)===e.label)??r.find(e=>e.tagName===`A`);return o?.focus({preventScroll:!0}),!!o&&document.activeElement===o};if(r()||!a.current)return;let s=()=>{l.disconnect(),document.removeEventListener(`pointerdown`,c,!0),document.removeEventListener(`keydown`,c,!0)},c=()=>{t(),s()},l=new MutationObserver(()=>{r()&&s()});return document.addEventListener(`pointerdown`,c,!0),document.addEventListener(`keydown`,c,!0),l.observe(a.current,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`]}),s},[e,t]),{ref:a,onFocusCapture:e=>{let t=e.target,r=t.closest(`[data-run-id]`);o.current=r?{element:t,runId:r.dataset.runId,project:r.dataset.project,control:t.dataset.taskControl??null,label:t.getAttribute(`aria-label`),tag:t.tagName}:null,n?.(r?r.dataset.project?`${r.dataset.project}/${r.dataset.runId}`:r.dataset.runId:null)},onBlurCapture:e=>{let t=e.target,r=e.currentTarget;queueMicrotask(()=>{o.current?.element===t&&t.isConnected&&!r.contains(document.activeElement)&&(o.current=null,n?.(null))})}}}var IM=new WeakMap;function LM({items:e,itemKey:t,children:r,itemSize:i}){let[a]=n(),o=(0,Z.useRef)(null),s=(0,Z.useRef)(null),[c,l]=(0,Z.useState)({available:null,margin:0}),[u,d]=(0,Z.useState)(null),f=MM(),p=(0,Z.useContext)(NM),m=e.map(t),h=Mj(e.length,a.get(`tasks`)),g=c.available===!0&&h,_=(0,Z.useRef)(Symbol(`task-list`)),v=(0,Z.useRef)(()=>{});(0,Z.useLayoutEffect)(()=>{p?.registerList?.(_.current,m);let e=b.current;return e&&IM.set(e,{keys:m,handle:s,measure:()=>v.current()}),()=>{p?.registerList?.(_.current,null),e&&IM.delete(e)}});let y=FM(String(g),void 0,void 0,e=>m.includes(e)),b=y.ref;return(0,Z.useLayoutEffect)(()=>{let e=b.current,t=e?.closest(`[data-slot="main"]`);if(o.current=t??null,!e||!t){l(e=>e.available===!1?e:{available:!1,margin:0});return}let n=null,r=()=>{let r=Math.max(0,e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop);r!==n&&(n=r,l(e=>e.available===!0&&e.margin===r?e:{available:!0,margin:r}))};r(),v.current=r;let i=new ResizeObserver(r);for(let n=e;n&&n!==t;n=n.parentElement){i.observe(n);for(let e of n.parentElement?.children??[])i.observe(e)}return i.observe(t),()=>i.disconnect()},[]),(0,Q.jsx)(`div`,{ref:b,"data-slot":`task-list-items`,"data-virtualized":g,onFocusCapture:e=>{y.onFocusCapture(e),d(e.target.closest(`[data-task-item]`)?.dataset.taskItem??null)},onBlurCapture:e=>{y.onBlurCapture(e),e.relatedTarget&&!e.currentTarget.contains(e.relatedTarget)&&d(null)},children:g?(0,Q.jsx)(zM,{itemSize:i,items:e,keys:m,handle:s,scroll:o,margin:c.margin,focused:p?.focused??u,editing:f,children:r}):(c.available===null&&h?[]:e).map((t,n)=>(0,Q.jsx)(`div`,{"data-task-item":m[n],"data-first":n===0,"data-last":n===e.length-1,className:`task-list-flat-item`,children:r(t,n)},m[n]))})}function RM({layout:e,revision:t,visibilityRevision:n=``,children:r,...i}){let a=PM(e,t,!0);return(0,Q.jsx)(NM,{value:a.value,children:(0,Q.jsx)(VM,{revision:t,visibilityRevision:`${e}:${n}`,children:(0,Q.jsx)(`div`,{...i,...a.props,children:r})})})}function zM({items:e,keys:t,handle:n,scroll:r,margin:i,focused:a,editing:o,children:s,itemSize:c}){let[l,u]=(0,Z.useState)(!1),d=BM(r);return(0,Z.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=new ResizeObserver(e=>{e.some(e=>e.contentRect.height>0)&&(u(!0),t.disconnect())});return t.observe(e),()=>t.disconnect()},[r]),(0,Q.jsx)(xM,{ref:n,...c===void 0?{}:{itemSize:c},scrollRef:r,startMargin:i,keepMounted:[...new Set([...!l&&e.length?[0]:[],...Nj(t,a),...Nj(t,d),...Nj(t,o)])],data:e,children:(n,r)=>(0,Q.jsx)(`div`,{"data-task-item":t[r],"data-first":r===0,"data-last":r===e.length-1,children:s(n,r)},t[r])})}function BM(e){let[t,n]=(0,Z.useState)(null),r=(0,Z.useRef)(t);return(0,Z.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let i=e=>{if(e.target!==t)return;let i=t.contains(document.activeElement)?document.activeElement.closest(`[data-task-item]`)?.dataset.taskItem??null:null;i!==r.current&&(r.current=i,(0,zd.flushSync)(()=>n(i)))};return document.addEventListener(`scroll`,i,{capture:!0,passive:!0}),()=>document.removeEventListener(`scroll`,i,{capture:!0})},[e]),t}var VM=class extends Z.Component{root={current:null};owner(){return this.root.current?.closest(`[data-slot="main"]`)??null}getSnapshotBeforeUpdate(e){if(e.revision===this.props.revision&&e.visibilityRevision===this.props.visibilityRevision)return null;let t=this.owner();if(!t||!this.root.current)return null;let n=t.getBoundingClientRect();for(let e of this.root.current.querySelectorAll(`[data-task-item]`)){let r=e.getBoundingClientRect();if(r.bottom>n.top&&r.top<n.bottom)return{key:e.dataset.taskItem,top:r.top,scrollTop:t.scrollTop}}return{key:null,top:0,scrollTop:t.scrollTop}}componentDidUpdate(e,t,n){let r=this.owner();if(!n||!r)return;let i=n.key===null?null:this.currentTop(n.key);i!==null&&Math.abs(i-n.top)>.5&&(r.scrollTop+=i-n.top),queueMicrotask(()=>{r.isConnected&&(0,zd.flushSync)(()=>{for(let e of this.root.current?.querySelectorAll(`[data-slot="task-list-items"]`)??[])IM.get(e)?.measure();r.scrollTop!==n.scrollTop&&r.dispatchEvent(new Event(`scroll`))})})}currentTop(e){for(let t of this.root.current?.querySelectorAll(`[data-task-item]`)??[])if(t.dataset.taskItem===e)return t.getBoundingClientRect().top;for(let t of this.root.current?.querySelectorAll(`[data-slot="task-list-items"]`)??[]){let n=IM.get(t),r=n?.keys.indexOf(e)??-1,i=n?.handle.current;if(r>=0&&i)return t.getBoundingClientRect().top+i.getItemOffset(r)}return null}render(){return(0,Q.jsx)(`div`,{ref:this.root,style:{display:`contents`},children:this.props.children})}};function HM(e){return e===void 0?`unknown`:new Intl.NumberFormat().format(e)}function UM(e,t){return`Input tokens: ${HM(e)}; output tokens: ${HM(t)}`}function WM(e,t,n=`compact`){let r=e===void 0?`—`:Ba(e),i=t===void 0?`—`:Ba(t);return n===`table`?`${r} / ${i}`:`IN ${r} · OUT ${i}`}function GM({inputTokens:e,outputTokens:t,variant:n=`compact`,omitWhenUnknown:r=!0,className:i,title:a}){return r&&e===void 0&&t===void 0?null:(0,Q.jsx)(`span`,{"data-slot":`directional-usage`,"aria-label":UM(e,t),title:a,className:D(`font-mono tabular-nums`,i),children:WM(e,t,n)})}function KM({className:e,dot:t,shape:n=`filled`,pulse:r=!1,children:i,...a}){return(0,Q.jsxs)(`span`,{"data-slot":`pill`,className:D(`inline-flex items-center gap-1.5 rounded-full bg-muted px-2.5 py-[3px] text-xs font-medium whitespace-nowrap text-muted-foreground`,e),...a,children:[t?(0,Q.jsx)($,{tone:t,shape:n,pulse:r}):null,i]})}var qM=[{value:`all`,label:`All`},{value:`direct`,label:`Direct tasks`},{value:`automations`,label:`Automations`}];function JM(e){return e?qM:qM.filter(e=>e.value!==`automations`)}function YM(e,t){return e===`automations`&&!t?`all`:e}function XM(e){return e===`direct`||e===`automations`?e:`all`}function ZM(e,t){return t===`all`||Ie(e)===(t===`automations`)}function QM(e){return e===`all`?void 0:e===`automations`}function $M(e,t){let n={all:0,direct:0,automations:0};for(let r of e)zr(r)||r.archived!==(t===`archived`)||(n.all+=1,Ie(r)?n.automations+=1:n.direct+=1);return n}function eN(e,t,n,r,i){let a=Vr(e).archived,o=a>=200;if(n===`all`)return i??(o?`200+`:a);let s=$M(t,`archived`)[n];return o&&r!==!1?`${s}+`:s}function tN(e){return e.rows.map(e=>e.run)}function nN(e,t){switch(e){case`Needs you`:return`pending`;case`Working`:return`running`;case`Archived`:return`neutral`;case`Finished`:return t.some(e=>xe(e).bucket===`error`)?`danger`:`success`}}function rN(e,t,n){return Rr(e,t,Lr(n))}var iN=(e,t)=>JSON.stringify([e,t]);function aN(e,t,n){let r=new Map,i=e.map(e=>{let{run:t}=e,n=iN(t.projectId,t.id);r.set(n,e);let i=t.delegation;return{...t,id:n,...i&&`parentRunId`in i?{delegation:{...i,parentRunId:iN(t.projectId,i.parentRunId)}}:{}}}),a=new Map;for(let e of n){let t=a.get(e.projectId);t?t.push(e):a.set(e.projectId,[e])}let o=new Map;for(let[e,t]of a)for(let[n,r]of Lr(t))o.set(iN(e,n),r);let s=e=>r.get(e.id);return Rr(i,t,o).map(e=>({label:e.label,rows:e.rows.map(e=>({kind:`run`,run:s(e.run),queuePosition:e.queuePosition}))}))}function oN(e){return[e.run]}var sN=/^- \S+ — (?:(?:turn complete|step ".*" complete|step ".*" ended without done|session idle-closed) — |worktree setup (?:done in|failed —|skipped —) )/;function cN(e,t=3){let n=Be(e,`## Progress log`);if(n<0)return[];let r=[];for(let i of e.slice(We(e,n)).split(`
17
- `)){if(r.length>=t||i.startsWith(`## `))break;let e=i.trim();!e||sN.test(e)||r.push(e.replace(/^[-*] /,``))}return r}function lN({origin:e,counts:t,automations:n,onChange:r}){return(0,Q.jsx)(`div`,{role:`group`,"aria-label":`Task origin`,"data-slot":`origin-filter`,className:`flex flex-wrap items-center gap-1.5`,children:JM(n).map(n=>{let i=n.value===e;return(0,Q.jsxs)(`button`,{type:`button`,"data-origin":n.value,"aria-pressed":i,onClick:()=>r(n.value),className:D(`inline-flex min-h-11 items-center gap-1.5 rounded-full border border-border px-3 text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,i&&`border-accent-strong bg-accent-strong/10 text-accent-text`),children:[n.label,` `,(0,Q.jsx)(`span`,{className:`tabular-nums`,children:t[n.value]})]},n.value)})})}function uN({onExpand:e,onCollapse:t}){return(0,Q.jsxs)(`div`,{"data-slot":`group-fold-controls`,className:`hidden flex-wrap items-center gap-2 md:ml-auto md:flex`,children:[(0,Q.jsx)(E,{type:`button`,variant:`ghost`,className:`min-h-11`,"data-action":`expand-groups`,onClick:e,children:`Expand groups`}),(0,Q.jsx)(E,{type:`button`,variant:`ghost`,className:`min-h-11`,"data-action":`collapse-groups`,onClick:t,children:`Collapse groups`})]})}function dN({origin:e,counts:t,automations:n,onChange:r,labels:i,onSetAll:a}){return(0,Q.jsxs)(`div`,{"data-slot":`task-origin-row`,className:`flex flex-wrap items-center gap-2.5`,children:[(0,Q.jsx)(lN,{origin:e,counts:t,automations:n,onChange:r}),i.length>0?(0,Q.jsx)(uN,{onExpand:()=>a(i,!1),onCollapse:()=>a(i,!0)}):null]})}var fN={pending:`needs you`,running:`working`,success:`finished`,danger:`contains failed tasks`,neutral:`archived`};function pN({id:e,label:t,count:n,tone:r,folded:i,collapsed:a,onToggle:o,children:s}){let c=a?Ji:_a;return(0,Q.jsxs)(`section`,{"data-slot":`task-status-group`,"data-bucket":t,"data-folded":i,"data-tone":r,"aria-labelledby":`${e}-heading`,className:`flex flex-col gap-2.5`,children:[(0,Q.jsx)(`h2`,{id:`${e}-heading`,className:`text-[13px] font-semibold text-foreground`,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`status-group-toggle`,"aria-expanded":!a,"aria-controls":`${e}-rows`,"aria-label":`${t} ${n}${r===`danger`?`, contains failed tasks`:``}`,onClick:o,className:`inline-flex min-h-11 items-center gap-2 rounded-md pr-2 hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,children:[(0,Q.jsx)(c,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,Q.jsx)($,{tone:r,role:`img`,"aria-label":fN[r],title:fN[r]}),(0,Q.jsx)(`span`,{children:t}),` `,(0,Q.jsx)(`span`,{className:`font-normal tabular-nums text-muted-foreground`,children:n})]})}),(0,Q.jsx)(`div`,{id:`${e}-rows`,hidden:a,children:a?null:s})]})}function mN({automationId:e,automationName:t,project:n}){let r=e===void 0?`Direct task`:t??e;return(0,Q.jsxs)(`span`,{"data-slot":`task-origin`,"data-origin":e===void 0?`direct`:`automation`,className:`flex min-w-0 flex-wrap items-center gap-x-1.5 text-xs text-muted-foreground`,children:[n?(0,Q.jsxs)(Q.Fragment,{children:[n,(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`·`})]}):null,(0,Q.jsx)(`span`,{className:`min-w-0 break-words`,title:e===void 0?void 0:`Automation ${e}`,children:r})]})}function hN({projectId:e,runId:t,status:n,error:r,open:i}){let a=rr(e,t,!0),o=a.data===void 0?[]:cN(a.data);return(0,Q.jsxs)(`div`,{"data-slot":`task-preview`,className:`flex flex-col gap-3 rounded-md bg-muted/50 p-4 text-xs`,children:[(0,Q.jsx)(`p`,{className:`font-medium text-foreground first-letter:uppercase`,children:n}),r?(0,Q.jsx)(`p`,{"data-slot":`task-preview-error`,className:`break-words text-danger`,children:r}):null,a.isPending?(0,Q.jsx)(`p`,{role:`status`,className:`text-muted-foreground`,children:`Loading latest progress…`}):a.isError?(0,Q.jsx)(`p`,{"data-slot":`task-preview-unavailable`,className:`text-muted-foreground`,children:`Latest progress is unavailable.`}):o.length===0?(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:`No progress recorded yet.`}):(0,Q.jsx)(`ul`,{"aria-label":`Latest progress`,className:`flex flex-col gap-1 text-muted-foreground`,children:o.map((e,t)=>(0,Q.jsx)(`li`,{className:`break-words`,children:e},t))}),(0,Q.jsx)(`div`,{children:i})]})}var gN=`cez-task-list-folds`,_N=`cez-task-list-folds-changed`;function vN(e,t,n=new Set){let[r,i]=(0,Z.useState)(()=>Kb(gN));(0,Z.useEffect)(()=>{let e=e=>{e instanceof StorageEvent&&e.key!==null&&e.key!==`cez-task-list-folds`||i(e instanceof CustomEvent?e.detail:Kb(gN))};return window.addEventListener(`storage`,e),window.addEventListener(_N,e),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(_N,e)}},[]);let a=(0,Z.useCallback)(n=>JSON.stringify([e,t,n]),[e,t]),o=(0,Z.useCallback)(e=>{i(t=>{let n=e(t);return qb(n,gN),queueMicrotask(()=>window.dispatchEvent(new CustomEvent(_N,{detail:n}))),n})},[]),s=e=>r[a(e)]===!0;return{isFolded:s,isCollapsed:e=>s(e)&&!n.has(e),toggle:e=>o(t=>({...t,[a(e)]:t[a(e)]!==!0})),setAll:(e,t)=>o(n=>({...n,...Object.fromEntries(e.map(e=>[a(e),t]))})),only:(0,Z.useCallback)((e,t)=>o(n=>({...n,...Object.fromEntries(t.map(t=>[a(t),t!==e]))})),[o,a])}}function yN(e,t,n,r){let i=vN(e,t,n),a=(0,Z.useRef)(r);a.current=r;let[o,s]=qk(),c=t===`active`?Fr(o.get(ai)):null,{only:l}=i;return(0,Z.useEffect)(()=>{c!==null&&(l(c,Or),a.current?.(),s(e=>(e.delete(ai),e)))},[c,l,s]),i}function bN(e){let t=e?.capabilities,n=t?.tokenMetrics!==!1;return{tokens:t?.tokenUsageMetrics??n,cost:t?.costMetrics??n}}function xN(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function SN(){let e=L(),t=Cr(),n=Z.useRef(0),r=Z.useRef(0),i=Z.useRef(Promise.resolve()),a=Z.useMemo(()=>Oj(t.data?.taskTable?.expandedColumns),[t.data?.taskTable?.expandedColumns]),o=Z.useCallback(t=>{if(!Tj.find(e=>e.id===t)?.canFold)return;let a=e.getQueryData(V.uiState);if(a===void 0)return;let o=xN(a?.taskTable),s={...o,expandedColumns:Aj(o.expandedColumns,t)};e.setQueryData(V.uiState,{...a,taskTable:s});let c=++n.current;r.current=c;let l=i.current.then(async()=>{let t=await ht({taskTable:s},{keepalive:!0});c===r.current&&e.setQueryData(V.uiState,t)});i.current=l.catch(t=>{G(t instanceof Error?t.message:String(t),{tone:`danger`}),c===r.current&&e.invalidateQueries({queryKey:V.uiState})})},[e]);return{expandedColumns:a,isExpanded:Z.useCallback(e=>kj(e,a),[a]),toggleColumn:o,isPending:t.isPending}}var CN=()=>void 0;function wN({runs:e,view:t,onViewChange:n,onArchiveFinished:r,archivePending:i=!1,onMarkAllRead:a,onRename:o,onTogglePin:s,now:c=Date.now(),showTokens:l=!0,showCost:u=!0,expandedColumns:d=Oj(void 0),onToggleColumn:f=()=>void 0,columnsPending:p=!1,projectName:m,error:h,onRetry:g,archivedPages:_,archivedTotal:v,onArchivedSearch:y,origin:b,onOriginChange:x,automations:S,urlQuery:C=``,onQueryChange:w,foldScope:T=`project`,automationName:D=CN}){let[O,k]=TN(C,w);Z.useEffect(()=>{y?.(O.trim())},[y,O]);let[A,j]=DN(b,x,S),[M,ee]=Z.useState(!1),te=ci(),{expandedRuns:N,toggleExpandedRun:P}=wj(),ne=Z.useRef(null),F=Z.useMemo(()=>e??[],[e]),I=Z.useMemo(()=>ON({all:F,view:t,query:O,origin:A,archivedPages:_,archivedTotal:v,automationName:D}),[F,t,O,A,_,v,D]),{groups:re,needle:ie}=I,ae=Z.useMemo(()=>jj({tokens:l,cost:u}),[l,u]),oe=yN(T,t,new Set(ie?re.map(e=>e.label):[]),()=>k(``)),se=t===`archived`?void 0:s;return(0,Q.jsx)(DM,{runs:_?[...F,..._.runs]:F,onRename:o,children:(0,Q.jsxs)(RM,{layout:`${te}:${M}`,revision:re,visibilityRevision:JSON.stringify([Br.map(oe.isCollapsed),[...N].sort(),t,d]),"data-route":`tasks`,"data-presentation":M?`resources`:`summary`,className:`flex min-h-full flex-col gap-[22px] px-[18px] pt-6 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-9`,children:[(0,Q.jsxs)(`header`,{ref:ne,className:`flex shrink-0 flex-col gap-[22px]`,children:[(0,Q.jsx)(EN,{projectName:m,detailedTable:M}),(0,Q.jsxs)(`div`,{className:`flex gap-6 border-b border-border`,children:[(0,Q.jsx)(BN,{view:`active`,current:t,onSelect:n,count:I.activeCount,children:`Active`}),(0,Q.jsx)(BN,{view:`archived`,current:t,onSelect:n,count:I.archivedCount,children:`Archived`})]}),(0,Q.jsxs)(`div`,{"data-slot":`tasks-toolbar`,className:`flex flex-wrap items-center gap-2.5`,children:[(0,Q.jsx)(AN,{view:t,unread:I.unread,finished:I.finished,archivePending:i,headerRef:ne,onMarkAllRead:()=>a(QM(A)),onArchiveFinished:()=>r(QM(A))}),(0,Q.jsxs)(`div`,{className:`relative order-first w-full md:w-auto md:min-w-64 md:flex-1`,children:[(0,Q.jsx)(Fi,{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:O,onChange:e=>k(e.target.value),placeholder:`Search tasks or automations…`,"aria-label":`Search tasks`,className:`h-11 w-full rounded-md border border-input bg-card pr-3 pl-8 text-[13px] text-foreground outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`})]}),(0,Q.jsx)(jN,{columns:ae,expandedColumns:d,columnsPending:p,onToggleColumn:f,detailedTable:M,onToggleDetailed:()=>ee(e=>!e)}),(0,Q.jsx)(E,{asChild:!0,"data-slot":`new-task-inline`,className:`min-h-11 inline-flex max-md:hidden`,children:(0,Q.jsxs)(Y,{to:`/new`,children:[(0,Q.jsx)(Bi,{"aria-hidden":`true`}),`New task`]})})]}),(0,Q.jsx)(dN,{origin:A,counts:I.originTotals,automations:S,onChange:j,labels:re.map(e=>e.label),onSetAll:oe.setAll})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[e===void 0?(0,Q.jsx)(NN,{error:h,onRetry:g}):(0,Q.jsx)(MN,{view:t,query:O,origin:A,onShowAll:()=>{k(``),j(`all`)},caption:kN(I.visibleCount,I.incomplete,ie),captionOnPhones:ie!==``||I.incomplete,groups:re,folds:oe,grouped:{desktop:te,expandedRuns:N,toggleExpandedRun:P,detailedTable:M,columns:ae,expandedColumns:d,onToggleColumn:f,columnsPending:p,onRename:o,onTogglePin:se,now:c,showTokens:l,showCost:u,automationName:D}}),t===`archived`&&_?(0,Q.jsx)(PN,{pages:_}):null]})]})})}function TN(e,t){let[n,r]=Z.useState(e),i=Z.useRef(e),a=Z.useRef(e),o=Z.useRef([]);return Z.useEffect(()=>{if(e===i.current)return;i.current=e;let t=o.current.indexOf(e);o.current=t===-1?[]:o.current.slice(t+1),t===-1&&e!==a.current&&r(e)},[e]),Z.useEffect(()=>{a.current=n.trim(),t?.(n,e=>{o.current.push(e)})},[t,n]),[n,r]}function EN({projectName:e,detailedTable:t}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h1`,{className:`text-[30px] font-semibold tracking-tight`,children:`Project tasks`}),(0,Q.jsxs)(`p`,{className:`text-[13px] text-muted-foreground`,children:[e?`${e} · `:``,t?`Every resource column shown. Fold columns without losing the saved view.`:`Review runs, pull requests and resource usage.`]})]})}function DN(e,t,n){let[r,i]=Z.useState(`all`);return[YM(e??r,n),t??i]}function ON({all:e,view:t,query:n,origin:r,archivedPages:i,archivedTotal:a,automationName:o}){let s=n.trim(),c=e=>e.automationId===void 0?``:o(e.automationId)??e.automationId,l=i?.query===s,u=new Set(l?i.runs.map(e=>e.id):[]),d=Nr(e,l||s===``?i?.runs??[]:[]).slice(e.length),f=pi(e,n,c),p=new Set(f.map(e=>e.id)),m=pi(e.filter(e=>u.has(e.id)&&!p.has(e.id)),``),h=e=>ZM(e,r),g=rN([...f,...m,...pi(d,``)].filter(h),t,e),_=Nr(e,i?.query===``?i.runs:[]),v=Vr(e).archived>=200,y=e.filter(h);return{groups:g,needle:s,visibleCount:g.reduce((e,t)=>e+tN(t).length,0),originTotals:$M(_,t),activeCount:$M(e,`active`)[r],archivedCount:eN(e,_,r,i?.plainHasMore,a),incomplete:t===`archived`&&v&&i?.hasMore!==!1,finished:$r(y),unread:mh(y)}}function kN(e,t,n){return`${e} ${e===1?`task`:`tasks`}${t?` loaded`:``}${n?` matching “${n}”`:``}`}function AN({view:e,unread:t,finished:n,archivePending:r,headerRef:i,onMarkAllRead:a,onArchiveFinished:o}){let s=Z.useRef(!1),[c,l]=Z.useState(!1),u=n>0||r;return Z.useEffect(()=>{let e=window.matchMedia?.(mi);if(!e)return;let t=()=>{e.matches&&l(!1)};return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,Q.jsxs)(Q.Fragment,{children:[t>0?(0,Q.jsxs)(E,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`mark-all-read`,className:`hidden md:inline-flex`,onClick:a,children:[(0,Q.jsx)(lu,{className:`size-3.5`,"aria-hidden":`true`}),`Mark all read`,` `,(0,Q.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:t})]}):null,e===`active`&&n>0?(0,Q.jsxs)(E,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`archive-finished`,className:`inline-flex`,disabled:r,"aria-busy":r,onClick:o,children:[(0,Q.jsx)(ha,{className:`size-3.5`,"aria-hidden":`true`}),`Archive finished`,` `,(0,Q.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:n})]}):null,e===`active`&&(u||t>0)?(0,Q.jsxs)(Do,{open:c,onOpenChange:l,children:[(0,Q.jsx)(wo,{asChild:!0,children:(0,Q.jsx)(E,{type:`button`,variant:`ghost`,size:`icon`,className:`md:hidden`,"aria-label":`Task actions`,"aria-busy":r,children:(0,Q.jsx)(Tu,{"aria-hidden":`true`})})}),(0,Q.jsxs)(To,{align:`end`,className:`md:hidden`,onCloseAutoFocus:e=>{(s.current||window.matchMedia?.(`(min-width: 48rem)`).matches)&&(e.preventDefault(),s.current=!1,i.current?.querySelector(`[data-view="active"]`)?.focus())},children:[u?(0,Q.jsxs)(bo,{disabled:r||n===0,onSelect:()=>{s.current=!0,o()},children:[(0,Q.jsx)(ha,{"aria-hidden":`true`}),r?`Archiving…`:`Archive finished (${n})`]}):null,t>0?(0,Q.jsxs)(bo,{onSelect:a,children:[(0,Q.jsx)(lu,{"aria-hidden":`true`}),`Mark all read (${t})`]}):null]})]}):null]})}function jN({columns:e,expandedColumns:t,columnsPending:n,onToggleColumn:r,detailedTable:i,onToggleDetailed:a}){return(0,Q.jsxs)(fi,{children:[(0,Q.jsx)(li,{asChild:!0,children:(0,Q.jsx)(E,{"data-slot":`task-columns-trigger`,variant:`outline`,className:`hidden min-h-11 md:inline-flex`,children:`Columns`})}),(0,Q.jsxs)(Qr,{align:`end`,className:`w-72`,children:[(0,Q.jsx)(`h2`,{className:`mb-2 text-base font-medium`,children:`Visible columns`}),(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-muted-foreground`,children:`Status and Task · Always visible`}),(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:e.filter(e=>e.canFold).map(e=>(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Q.jsx)(`input`,{"data-column-toggle":e.id,type:`checkbox`,checked:kj(e.id,t),disabled:n,onChange:()=>r(e.id)}),e.id===`diff`?`Diff`:e.id===`reference`?`Reference`:e.id===`memory`?`Memory`:e.label]},e.id))}),(0,Q.jsx)(`p`,{className:`mt-4 text-xs text-muted-foreground`,children:`Saved automatically. Tokens and cost appear only when supported.`}),(0,Q.jsx)(E,{variant:`outline`,className:`mt-4`,onClick:a,children:i?`Summary view`:`Resource columns`})]})]})}function MN({view:e,query:t,origin:n,onShowAll:r,caption:i,captionOnPhones:a,groups:o,folds:s,grouped:c}){return o.length===0?(0,Q.jsx)(FN,{view:e,query:t,origin:n,onShowAll:r}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{"data-slot":`tasks-result-count`,className:D(`mb-3 text-[12px] text-muted-foreground tabular-nums`,!a&&`max-md:hidden`),children:i}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-[22px]`,children:o.map(t=>{let n=tN(t);return(0,Q.jsx)(pN,{id:`tasks-group-${e}-${t.label.replaceAll(` `,`-`)}`,label:t.label,count:n.length,tone:nN(t.label,n),folded:s.isFolded(t.label),collapsed:s.isCollapsed(t.label),onToggle:()=>s.toggle(t.label),children:(0,Q.jsx)(RN,{group:t,...c})},t.label)})}),(0,Q.jsx)(`p`,{className:`mt-[22px] text-[11px] text-muted-foreground`,children:`Resource details—including tokens, cost, CPU and peak memory—are available when a task row is expanded.`})]})}function NN({error:e,onRetry:t}){return e?(0,Q.jsxs)(`div`,{role:`alert`,className:`rounded-xl border border-border bg-card p-6`,children:[(0,Q.jsx)(`h2`,{className:`text-lg`,children:`Could not load tasks`}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:e}),(0,Q.jsx)(E,{variant:`outline`,className:`mt-4`,onClick:t,children:`Retry`})]}):(0,Q.jsx)(`div`,{role:`status`,"aria-label":`Loading tasks`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:`Loading tasks…`})}function PN({pages:e}){return e.failed?(0,Q.jsxs)(`p`,{role:`alert`,"data-slot":`archived-older-error`,className:`mt-3.5 flex items-center justify-center gap-2.5 text-[13px] text-muted-foreground`,children:[`Could not load older archived tasks.`,(0,Q.jsx)(E,{variant:`outline`,className:`min-h-11`,onClick:e.onLoadMore,children:`Retry`})]}):e.hasMore?(0,Q.jsx)(E,{"data-slot":`archived-older`,variant:`outline`,className:`mt-3.5 min-h-11 self-center`,disabled:e.loading,onClick:e.onLoadMore,children:e.loading?`Loading older archived…`:`Show older archived`}):null}function FN({view:e,query:t,origin:n=`all`,onShowAll:r}){let i=t.trim(),a=i||n!==`all`?`search-miss`:e===`archived`?`archive`:`no-tasks`;return(0,Q.jsx)(`div`,{"data-slot":`tasks-empty`,"data-empty-kind":a,className:`flex flex-1 flex-col`,children:a===`search-miss`?(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(Xa,{}),tone:`neutral`,title:`No matching tasks`,subtitle:i?`No tasks match “${i}”.`:n===`automations`?`No automation started a task here.`:`No task here was started directly.`,actions:r?(0,Q.jsx)(E,{variant:`outline`,className:`min-h-11`,"data-action":`clear-task-filters`,onClick:r,children:`Show all tasks`}):void 0}):a===`archive`?(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(ha,{}),tone:`neutral`,title:`Nothing archived yet`,subtitle:`Finished tasks you archive land here.`}):(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(Vu,{}),tone:`primary`,backdrop:!0,title:`No tasks yet`,subtitle:`Describe a task to get started.`,actions:(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsxs)(Y,{to:`/new`,"data-new-task-action":!0,children:[(0,Q.jsx)(Bi,{"aria-hidden":`true`}),`New task`]})})})})}function IN({rows:e,onRename:t,onTogglePin:n,now:r,showTokens:i,showCost:a,automationName:o,expandedRuns:s,toggleExpandedRun:c}){let l=Fj(e.map(({run:e})=>e.id),s);return(0,Q.jsx)(`div`,{"data-slot":`tasks-summary`,children:(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-5`,role:`table`,"aria-rowcount":l.rowCount,children:[(0,Q.jsx)(`div`,{role:`row`,"aria-rowindex":1,className:`task-summary-grid`,children:[`Task`,`Workflow`,`Changes`,`Pull request`,`Started`].map(e=>(0,Q.jsx)(`div`,{role:`columnheader`,className:`h-8 border-b border-border text-start text-[12px] font-medium uppercase text-muted-foreground`,children:e},e))}),(0,Q.jsx)(LM,{itemSize:103,items:e,itemKey:({run:e})=>e.id,children:({run:e,queuePosition:u},d)=>(0,Q.jsx)(LN,{run:e,queuePosition:u,rowIndex:l.indexes[d],onRename:t,onTogglePin:n,now:r,showTokens:i,showCost:a,automationName:o,open:s.has(e.id),toggleExpandedRun:c})})]})})}var LN=Z.memo(function({run:e,queuePosition:t,rowIndex:n,onRename:r,onTogglePin:i,now:a,showTokens:o,showCost:s,automationName:c,open:l,toggleExpandedRun:u}){let d=xe(e),f=si(e),p=yi(e),m=`task-resources-${e.id}`;return(0,Q.jsxs)(`div`,{role:`rowgroup`,children:[(0,Q.jsxs)(`div`,{role:`row`,"aria-rowindex":n,"data-status":e.status,"data-slot":`task-summary-row`,"data-run-id":e.id,className:`task-summary-grid group/row`,children:[(0,Q.jsxs)(`div`,{role:`cell`,className:`py-5 pr-4 align-top`,children:[(0,Q.jsx)(YN,{run:e,to:`/tasks/${e.id}`,onRename:r,onTogglePin:i}),(0,Q.jsx)(`div`,{className:`mt-1`,children:(0,Q.jsx)(qN,{run:e,automationName:c})}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,"data-task-control":`resources`,"aria-label":`${l?`Hide`:`Show`} resources for ${W(e)}`,"aria-expanded":l,"aria-controls":m,"aria-describedby":`summary-status-${e.id}`,onClick:()=>u(e.id),className:`inline-flex min-h-[26px] items-center gap-1 rounded-md p-0 text-[11px] text-muted-foreground hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,children:(0,Q.jsxs)(KM,{id:`summary-status-${e.id}`,dot:d.tone,shape:d.shape,pulse:d.pulse,children:[d.label,f?` ${f.label}`:``]})}),e.status===`queued`&&t!==null?(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`#`,t,` in queue`]}):null]})]}),(0,Q.jsx)(`div`,{role:`cell`,className:`truncate pr-3 text-xs text-muted-foreground`,title:vi(e),children:vi(e)}),(0,Q.jsx)(`div`,{role:`cell`,className:`pr-2 text-xs`,children:e.diffStat?(0,Q.jsx)(Vy,{stat:e.diffStat}):(0,Q.jsx)(tP,{})}),(0,Q.jsx)(`div`,{role:`cell`,className:`pr-2`,children:p?(0,Q.jsx)(yb,{run:e,reference:p,compact:!0}):(0,Q.jsx)(tP,{})}),(0,Q.jsx)(`div`,{role:`cell`,className:`text-xs text-muted-foreground`,children:za(e.startedAt??e.createdAt,a)})]}),l?(0,Q.jsx)(`div`,{role:`row`,"aria-rowindex":n+1,"data-run-id":e.id,children:(0,Q.jsx)(`div`,{role:`cell`,"aria-colspan":5,className:`border-b border-border pb-5`,children:(0,Q.jsxs)(`div`,{id:m,className:`flex flex-col gap-3`,children:[(0,Q.jsx)(hN,{runId:e.id,status:d.label,error:e.error,open:(0,Q.jsx)(E,{asChild:!0,variant:`outline`,className:`min-h-11`,children:(0,Q.jsxs)(Y,{"data-task-control":`open`,to:`/tasks/${e.id}`,children:[`Open task`,(0,Q.jsxs)(`span`,{className:`sr-only`,children:[`: `,W(e)]})]})})}),(0,Q.jsx)(`div`,{className:`rounded-md bg-muted/50 p-4`,children:(0,Q.jsx)(zN,{run:e,showTokens:o,showCost:s})})]})})}):null]})});function RN({desktop:e,expandedRuns:t,toggleExpandedRun:n,group:r,detailedTable:i,columns:a,expandedColumns:o,onToggleColumn:s,columnsPending:c,onRename:l,onTogglePin:u,now:d,showTokens:f,showCost:p,automationName:m}){let h=r.rows.flatMap(e=>oN(e).map(t=>({run:t,queuePosition:t.status===`queued`?e.queuePosition:null})));return(0,Q.jsxs)(Q.Fragment,{children:[e&&!i?(0,Q.jsx)(IN,{expandedRuns:t,toggleExpandedRun:n,rows:h,onRename:l,onTogglePin:u,now:d,showTokens:f,showCost:p,automationName:m}):null,e&&i?(0,Q.jsx)(`div`,{"data-slot":`tasks-table`,className:`overflow-x-auto rounded-lg border border-border bg-card`,children:(0,Q.jsx)(Ng,{children:(0,Q.jsxs)(`div`,{role:`table`,"aria-rowcount":h.length+1,className:`task-resource-grid`,style:Pj(a,o),children:[(0,Q.jsx)(`div`,{role:`row`,"aria-rowindex":1,className:`task-resource-row`,children:a.map(e=>(0,Q.jsx)(HN,{column:e,expanded:kj(e.id,o),onToggle:s,disabled:c},e.id))}),(0,Q.jsx)(LM,{itemSize:50,items:h,itemKey:({run:e})=>e.id,children:({run:e,queuePosition:t},n)=>(0,Q.jsx)(GN,{rowIndex:n+2,run:e,queuePosition:t,onRename:l,onTogglePin:u,now:d,columns:a,expandedColumns:o,automationName:m})})]})})}):null,e?null:(0,Q.jsx)(`div`,{"data-slot":`task-cards`,className:`flex flex-col rounded-lg border border-border bg-card p-5`,children:(0,Q.jsx)(LM,{itemSize:178,items:h,itemKey:({run:e})=>e.id,children:({run:e,queuePosition:r})=>(0,Q.jsx)($N,{resourcesOpen:t.has(e.id),onToggleResources:n,run:e,queuePosition:r,now:d,showTokens:f,showCost:p,onTogglePin:u,automationName:m},e.id)})})]})}function zN({run:e,showTokens:t,showCost:n}){let r=Ar(e,Nl(e.id));return(0,Q.jsxs)(`dl`,{className:`grid grid-cols-2 gap-4 text-xs md:grid-cols-4`,children:[t?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Tokens in / out`}),(0,Q.jsx)(`dd`,{className:`mt-1`,children:(0,Q.jsx)(GM,{inputTokens:e.inputTokens,outputTokens:e.outputTokens,omitWhenUnknown:!1})})]}):null,n?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Cost`}),(0,Q.jsx)(`dd`,{className:`mt-1`,children:oi(e.costUsd)||`—`})]}):null,(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`CPU`}),(0,Q.jsx)(`dd`,{className:`mt-1`,title:r.cpu.title,children:r.cpu.text||`—`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Memory`}),(0,Q.jsx)(`dd`,{className:`mt-1`,title:r.mem.title,children:r.mem.text||`—`})]}),e.branch?(0,Q.jsxs)(`div`,{className:`col-span-2`,children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Branch`}),(0,Q.jsx)(`dd`,{className:`mt-1 break-all`,children:e.branch})]}):null]})}function BN({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:D(`flex min-h-11 items-center justify-center gap-1.5 border-b-2 border-transparent text-[13px] font-medium text-muted-foreground`,a&&`border-accent-strong font-semibold text-accent-text`),children:[i,r===0?null:(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[` · `,r]})]})}function VN({children:e,right:t=!1,columnId:n,folded:r=!1}){return(0,Q.jsx)(`div`,{role:`columnheader`,"data-column-id":n,"data-folded":r||void 0,className:D(`h-[38px] border-b border-border px-2.5 text-left text-[11px] font-semibold tracking-[0.05em] whitespace-nowrap text-supporting-foreground uppercase first:pl-4 last:pr-4`,t&&`text-right`,r&&`px-0 first:pl-0 last:pr-0`),children:e})}function HN({column:e,expanded:t,onToggle:n,disabled:r}){if(!e.canFold)return(0,Q.jsx)(VN,{columnId:e.id,right:e.align===`right`,children:e.label});let i=t?`Fold`:`Expand`;return(0,Q.jsx)(VN,{columnId:e.id,right:e.align===`right`,folded:!t,children:(0,Q.jsxs)(Pg,{children:[(0,Q.jsx)(Fg,{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:D(`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)(mu,{className:`size-3 opacity-55`,"aria-hidden":`true`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(UN,{icon:e.icon}),(0,Q.jsx)(hu,{className:`size-3 opacity-70`,"aria-hidden":`true`})]})})}),(0,Q.jsxs)(Ig,{side:`top`,children:[e.label,` · `,i,` column`]})]})})}function UN({icon:e}){let t=`size-3.5`;switch(e){case`workflow`:return(0,Q.jsx)(Zi,{className:t,"aria-hidden":`true`});case`branch`:return(0,Q.jsx)(na,{className:t,"aria-hidden":`true`});case`diff`:return(0,Q.jsx)(ya,{className:t,"aria-hidden":`true`});case`reference`:return(0,Q.jsx)(Bu,{className:t,"aria-hidden":`true`});case`tokens`:return(0,Q.jsx)(vu,{className:t,"aria-hidden":`true`});case`cost`:return(0,Q.jsx)(wu,{className:t,"aria-hidden":`true`});case`cpu`:return(0,Q.jsx)(Gi,{className:t,"aria-hidden":`true`});case`memory`:return(0,Q.jsx)(Hu,{className:t,"aria-hidden":`true`});case`started`:return(0,Q.jsx)(gu,{className:t,"aria-hidden":`true`});default:return null}}var WN=`h-[88px] border-b border-border px-2.5 whitespace-nowrap first:pl-4 last:pr-4`,GN=Z.memo(function({rowIndex:e,run:t,queuePosition:n,onRename:r,onTogglePin:i,now:a,columns:o,expandedColumns:s,automationName:c}){let l=_s(),u=xe(t),d=si(t),f=`/tasks/${t.id}`,p=oi(t.costUsd),m=yi(t);return(0,Q.jsx)(`div`,{role:`row`,"aria-rowindex":e,"data-slot":`task-table-row`,"data-run-id":t.id,onClick:e=>{e.target.closest(`a, button, input`)||l(f)},className:`task-resource-row group/row cursor-pointer hover:bg-muted`,children:o.map(e=>{if(e.id===`memory`)return null;if(e.id===`cpu`){let r=kj(`cpu`,s),i=kj(`memory`,s);return n!==null&&(r||i)?(0,Q.jsxs)(`div`,{role:`cell`,"data-slot":`queue-note`,"data-column-id":`cpu-memory`,"aria-colspan":2,style:{gridColumn:`span 2`},className:D(WN,`text-right font-mono text-[11px] text-supporting-foreground`),children:[`#`,n,` in queue`]},e.id):(0,Q.jsx)(XN,{run:t,cpuExpanded:r,memoryExpanded:i},e.id)}return(0,Q.jsx)(KN,{column:e,expanded:kj(e.id,s),run:t,attention:u,scheduled:d,reference:m,cost:p,to:f,onRename:r,onTogglePin:i,now:a,automationName:c},e.id)})})});function KN({column:e,expanded:t,run:n,attention:r,scheduled:i,reference:a,cost:o,to:s,onRename:c,onTogglePin:l,now:u,automationName:d}){if(!t)return(0,Q.jsx)(JN,{column:e.id});switch(e.id){case`status`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:D(WN,`overflow-hidden`),children:(0,Q.jsx)(KM,{dot:r.tone,shape:r.shape,pulse:r.pulse,title:i?.title??r.label,className:`w-full max-w-full overflow-hidden`,children:(0,Q.jsxs)(`span`,{className:`min-w-0 truncate`,children:[r.label,i?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(`span`,{className:`tabular-nums`,children:i.label})]}):null]})})});case`task`:return(0,Q.jsxs)(`div`,{role:`cell`,"data-column-id":e.id,className:D(WN,`min-w-[320px] max-w-0 whitespace-normal`),children:[(0,Q.jsx)(YN,{run:n,to:s,onRename:c,onTogglePin:l}),(0,Q.jsx)(`div`,{className:`mt-1`,children:(0,Q.jsx)(qN,{run:n,automationName:d})})]});case`workflow`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:D(WN,`max-w-0 truncate text-[13px] text-muted-foreground`),children:vi(n)});case`branch`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:D(WN,`max-w-0 overflow-hidden`),children:n.branch?(0,Q.jsx)(nP,{branch:n.branch}):(0,Q.jsx)(tP,{})});case`diff`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:D(WN,`overflow-hidden`),children:n.diffStat?(0,Q.jsx)(Vy,{stat:n.diffStat,compact:!0,className:`block max-w-full`}):(0,Q.jsx)(tP,{})});case`reference`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:D(WN,`overflow-hidden`),children:a?(0,Q.jsx)(yb,{run:n,reference:a,compact:!0,className:`max-w-full overflow-hidden`}):(0,Q.jsx)(tP,{})});case`tokens`:let t=UM(n.inputTokens,n.outputTokens);return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:D(WN,`text-right text-xs text-muted-foreground`),children:(0,Q.jsx)(GM,{inputTokens:n.inputTokens,outputTokens:n.outputTokens,variant:`table`,omitWhenUnknown:!1,title:t,className:`block max-w-full overflow-hidden text-ellipsis`})});case`cost`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:D(WN,`text-right font-mono text-xs text-muted-foreground tabular-nums`),children:o?(0,Q.jsx)(QN,{text:o,accessibleText:`$${n.costUsd}`}):(0,Q.jsx)(tP,{})});case`started`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:D(WN,`text-right text-xs text-supporting-foreground tabular-nums`),children:za(n.startedAt??n.createdAt,u)});default:return null}}function qN({run:e,automationName:t}){return(0,Q.jsx)(mN,{automationId:e.automationId,automationName:e.automationId===void 0?void 0:t(e.automationId)})}function JN({column:e}){return(0,Q.jsx)(`div`,{role:`cell`,"aria-hidden":`true`,"data-column-id":e,"data-folded":`true`,className:D(WN,`px-0 first:pl-0 last:pr-0`)})}function YN({run:e,to:t,onTogglePin:n}){let r=W(e),i=OM(e),a=Zr(e),o=ph(e);return i.editing?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-slot":`table-title-editor`,children:[(0,Q.jsx)(CM,{editor:i,className:`basis-full text-[13px] font-medium`}),(0,Q.jsx)(E,{size:`sm`,"aria-label":`Save title`,onMouseDown:e=>e.preventDefault(),onClick:i.commit,children:`Save`}),(0,Q.jsx)(E,{size:`sm`,variant:`outline`,"aria-label":`Cancel rename`,onMouseDown:e=>e.preventDefault(),onClick:i.cancel,children:`Cancel`})]}):(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.delegation?.role===`worker`?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Worker`}):null,(0,Q.jsx)(Y,{"data-task-control":`title`,to:t,title:r,className:D(`line-clamp-2 min-w-0 flex-1 whitespace-normal rounded-sm text-[13px] leading-[18px] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,a?`font-semibold text-foreground`:o?`font-normal text-foreground`:`font-medium`),children:r}),a?(0,Q.jsx)($,{tone:hh(e),role:`img`,"aria-label":`unread`,title:`Unread — not opened since it finished`,className:`shrink-0`}):null,(0,Q.jsx)(`button`,{type:`button`,"data-slot":`row-rename`,"aria-label":`Rename task`,onClick:i.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)(Ju,{className:`size-3`,"aria-hidden":`true`})}),n?(0,Q.jsx)(Cb,{pinned:!!e.pinned,onToggle:t=>n(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 XN({run:e,cpuExpanded:t,memoryExpanded:n}){let r=Ar(e,Nl(e.id));return(0,Q.jsxs)(Q.Fragment,{children:[t?(0,Q.jsx)(ZN,{column:`cpu`,cell:r.cpu}):(0,Q.jsx)(JN,{column:`cpu`}),n?(0,Q.jsx)(ZN,{column:`memory`,cell:r.mem}):(0,Q.jsx)(JN,{column:`memory`})]})}function ZN({column:e,cell:t}){let n=t.text&&t.title?`${t.text}; ${t.title}`:t.text;return(0,Q.jsx)(`div`,{role:`cell`,"data-usage":e===`memory`?`mem`:e,"data-column-id":e,"data-usage-kind":t.kind,className:D(WN,`overflow-hidden`,`text-right font-mono tabular-nums`,t.kind===`live`&&`bg-accent-strong/5 text-xs font-medium text-foreground`,t.kind===`peak`&&`text-[11px] text-supporting-foreground`,t.kind===`none`&&`text-xs text-soft-foreground`),children:(0,Q.jsx)(QN,{text:t.text||`—`,accessibleText:n||void 0})})}function QN({text:e,accessibleText:t}){return(0,Q.jsx)(`span`,{"data-slot":`bounded-metric`,...t?{"aria-label":t,title:t}:{},className:`block max-w-full overflow-hidden text-ellipsis`,children:e})}var $N=Z.memo(function({resourcesOpen:e,onToggleResources:t,run:n,queuePosition:r,now:i,showTokens:a,showCost:o,onTogglePin:s,automationName:c}){let l=_s(),u=xe(n),d=si(n),f=`/tasks/${n.id}`,p=yi(n),m=Zr(n),h=ph(n);return(0,Q.jsxs)(`div`,{"data-slot":`task-card`,"data-status":n.status,"data-run-id":n.id,onClick:e=>{e.target.closest(`a, button`)||l(f)},className:`cursor-pointer border-b border-border py-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2.5`,children:[(0,Q.jsx)(`button`,{"data-slot":`mobile-resources-toggle`,"data-task-control":`resources`,type:`button`,"aria-controls":`mobile-resources-${n.id}`,"aria-describedby":`mobile-status-${n.id}`,"aria-label":e?`Hide resources`:`Show resources`,title:e?`Hide resources`:`Show resources`,"aria-expanded":e,onClick:()=>t(n.id),children:(0,Q.jsxs)(KM,{id:`mobile-status-${n.id}`,dot:u.tone,shape:u.shape,pulse:u.pulse,className:`mt-px shrink-0`,title:d?.title,children:[u.label,d?(0,Q.jsx)(`span`,{className:`tabular-nums`,children:d.label}):null]})}),(0,Q.jsxs)(Y,{"data-task-control":`title`,to:f,className:D(`order-first w-full min-w-0 rounded-sm text-[14px] leading-[1.35] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,m?`font-semibold text-foreground`:h?`font-normal text-foreground`:`font-medium`),children:[n.delegation?.role===`worker`?(0,Q.jsx)(`span`,{className:`mr-2 text-xs text-muted-foreground`,children:`Worker`}):null,W(n)]}),m?(0,Q.jsx)($,{tone:hh(n),role:`img`,"aria-label":`unread`,title:`Unread — not opened since it finished`,className:`mt-1.5 shrink-0`}):null,(0,Q.jsx)(`div`,{className:`order-first w-full`,children:(0,Q.jsx)(qN,{run:n,automationName:c})}),s?(0,Q.jsx)(Cb,{pinned:!!n.pinned,onToggle:e=>s(n,e),className:`mt-px`}):null]}),(0,Q.jsxs)(`div`,{"data-slot":`mobile-task-meta`,className:`mt-4 grid grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-3 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:vi(n)}),r===null?n.diffStat?(0,Q.jsx)(Vy,{stat:n.diffStat}):(0,Q.jsx)(tP,{}):(0,Q.jsxs)(`span`,{"data-slot":`queue-note`,children:[`#`,r,` in queue`]}),(0,Q.jsx)(`span`,{children:za(n.startedAt??n.createdAt,i)})]}),p?(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(yb,{run:n,reference:p})}):null,e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(hN,{runId:n.id,status:u.label,error:n.error,open:(0,Q.jsx)(E,{asChild:!0,variant:`outline`,className:`min-h-11`,children:(0,Q.jsxs)(Y,{"data-task-control":`open`,to:f,children:[`Open task`,(0,Q.jsxs)(`span`,{className:`sr-only`,children:[`: `,W(n)]})]})})})}),(0,Q.jsx)(eP,{run:n,showTokens:a,showCost:o})]}):null]})});function eP({run:e,showTokens:t,showCost:n}){let r=Ar(e,Nl(e.id));return(0,Q.jsxs)(`dl`,{id:`mobile-resources-${e.id}`,className:`mt-3 grid grid-cols-2 gap-3 rounded-md bg-muted p-3 text-xs`,children:[e.branch?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`Branch`}),(0,Q.jsx)(`dd`,{children:e.branch})]}):null,(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`CPU`}),(0,Q.jsx)(`dd`,{children:r.cpu.text||`—`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`Memory`}),(0,Q.jsx)(`dd`,{children:r.mem.text||`—`})]}),t?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`IN / OUT`}),(0,Q.jsx)(`dd`,{children:(0,Q.jsx)(GM,{inputTokens:e.inputTokens,outputTokens:e.outputTokens})})]}):null,n?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`Cost`}),(0,Q.jsx)(`dd`,{children:oi(e.costUsd)||`—`})]}):null]})}function tP(){return(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`})}function nP({branch:e}){return(0,Q.jsx)(`span`,{title:e,className:`block truncate rounded-[6px] bg-muted px-1.5 py-0.5 font-mono text-[11px] font-medium text-muted-foreground`,children:e})}function rP(){let e=Nn(),t=bN(On().data),n=js(),{view:r,setView:i,origin:a,setOrigin:o,urlQuery:s,writeQuery:c}=aP(),l=Hn(),u=L(),d=cP(e.data,r),f=jn({mutationFn:e=>Je(Bn(),void 0,e),onSuccess:()=>l.invalidateAfter(`runs`,()=>Bn()),onError:e=>G(e.message,{tone:`danger`})}),p=jn({mutationFn:e=>Ae(e),onSuccess:()=>u.invalidateQueries({queryKey:H.runs.all}),onError:e=>G(e.message,{tone:`danger`})}),m=jn({mutationFn:({id:e,title:t})=>Ct(e,{title:t}),onSuccess:()=>u.invalidateQueries({queryKey:H.runs.all}),onError:e=>G(e.message,{tone:`danger`})}),h=Pn(),g=Hb(3e4),_=SN(),v=cr(),y=fr(void 0,{retryOnMount:!1}),b=An({retryOnMount:!1}).data?.projects?.find(e=>e.id===v)?.name,x=[...e.data??[],...d.pages?.runs??[]].some(e=>e.automationId!==void 0),S=dr([void 0],n&&x),C=Z.useCallback(e=>S(void 0,e),[S]),w=Z.useMemo(()=>v===void 0?[]:(e.data??[]).flatMap(e=>{let t=yi(e);return t?[{projectId:v,kind:t.kind,number:t.number}]:[]}),[e.data,v]),T=Z.useCallback((e,t)=>m.mutate({id:e,title:t}),[m.mutate]),E=Z.useCallback((e,t)=>h.mutate({id:e.id,pinned:t}),[h.mutate]);return(0,Q.jsx)(Ga,{projectId:v,repoBase:y,requests:w,children:(0,Q.jsx)(wN,{runs:e.data,projectName:b,error:e.error?.message,onRetry:()=>void e.refetch(),view:r,onViewChange:i,origin:a,onOriginChange:o,automations:n,urlQuery:s,onQueryChange:c,foldScope:`project:${v??`default`}`,automationName:C,onArchiveFinished:e=>{f.isPending||f.mutate(e)},archivePending:f.isPending,onMarkAllRead:e=>p.mutate(e),onRename:T,onTogglePin:E,now:g,showTokens:t.tokens,showCost:t.cost,expandedColumns:_.expandedColumns,onToggleColumn:_.toggleColumn,columnsPending:_.isPending,archivedPages:d.pages,archivedTotal:d.total,onArchivedSearch:d.search})})}function iP(e,t){return n=>(t===null?n.delete(e):n.set(e,t),n)}function aP(){let[e,t]=qk(),n=e.get(`archived`)===`1`?`archived`:`active`,r=XM(e.get(`origin`)),[i,a]=Z.useState(n),[o,s]=Z.useState(r);Z.useEffect(()=>a(n),[n]),Z.useEffect(()=>s(r),[r]);let c=e.get(`q`)??``,l=Z.useRef(void 0);return Z.useEffect(()=>{let e=l;return()=>clearTimeout(e.current)},[]),{view:i,setView:e=>{a(e),t(iP(`archived`,e===`archived`?`1`:null))},origin:o,setOrigin:e=>{s(e),t(iP(`origin`,e===`all`?null:e))},urlQuery:c,writeQuery:Z.useCallback((e,n)=>{clearTimeout(l.current);let r=e.trim();l.current=setTimeout(()=>t(e=>{let t=e.get(`q`),i=iP(`q`,r===``?null:r)(e);return i.get(`q`)!==t&&n(r),i}),oP)},[t])}}var oP=250,sP=150;function cP(e,t){Hn();let n=L(),[r,i]=Z.useState(``),[a,o]=Z.useState(``);Z.useEffect(()=>{let e=setTimeout(()=>o(r),sP);return()=>clearTimeout(e)},[r]);let s=e!==void 0&&Vr(e).archived>=200,{data:c,isError:l,isPlaceholderData:u,hasNextPage:d,isFetchingNextPage:f,fetchNextPage:p,refetch:m}=ar(a,t===`archived`&&(a!==``||s)),h=c?.pages,g=Z.useMemo(()=>h||l?{runs:(h??[]).flatMap(e=>e.runs),query:u?null:a,hasMore:d,loading:f,onLoadMore:()=>void(h?p():m()),failed:l}:void 0,[h,l,u,a,d,f,p,m]),_=a===``?h:n.getQueryData(H.runs.archived(``))?.pages,v=_===void 0?void 0:_.at(-1)?.nextCursor!=null;return{pages:Z.useMemo(()=>g&&{...g,plainHasMore:v},[g,v]),total:_?.[0]?.total,search:i}}function lP({projects:e,perProjectLimit:t}){return e.length===0?null:(0,Q.jsxs)(`p`,{"data-slot":`global-tasks-truncated`,className:`text-[11px] text-soft-foreground`,children:[`Showing every active task and the newest `,t,` archived tasks per project — older archived tasks in`,` `,e.join(`, `),` are in that project’s own Tasks page.`]})}function uP({registry:e}){return e.length<=1?null:(0,Q.jsxs)(`section`,{"data-slot":`other-projects`,className:`rounded-lg border border-border bg-card p-5`,children:[(0,Q.jsx)(`h2`,{className:`text-base font-semibold`,children:`Other projects`}),(0,Q.jsx)(`div`,{className:`mt-3 flex flex-col divide-y divide-border`,children:e.map(e=>(0,Q.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-[13px]`,children:e.name}),(0,Q.jsxs)(C,{to:gs(e.id,`/`),className:`inline-flex min-h-11 shrink-0 items-center rounded-md px-3 text-xs text-accent-text hover:bg-accent-strong/10`,children:[`View tasks`,(0,Q.jsxs)(`span`,{className:`sr-only`,children:[` for `,e.name]})]})]},e.id))})]})}function dP({view:e,filtered:t}){return t?(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(Xa,{}),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)(ha,{}),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)(Vu,{}),tone:`neutral`,title:`No tasks yet`,subtitle:`Start a task in any project and it shows up here.`})}function fP({groupBy:e,filterDetailsOpen:t,message:n,onRetry:r}){return(0,Q.jsx)(`div`,{"data-route":`global-tasks`,"data-presentation":e===`none`?`summary`:`cards`,"data-filter-details":t,className:`flex min-h-full flex-col gap-[22px] px-[18px] pt-6 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-9`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(Ti,{}),tone:`danger`,title:`Tasks across projects did not load`,subtitle:n,actions:(0,Q.jsx)(E,{variant:`outline`,onClick:r,children:`Retry`})})})}function pP({slot:e,label:t,options:n,selected:r,onToggle:i,onClear:a,searchPlaceholder:o,emptyLabel:s=`Nothing to filter by`}){let[c,l]=Z.useState(!1),u=r.length>0,d=r.length===1?n.find(e=>e.value===r[0])?.label??r[0]:`${r.length} selected`;return(0,Q.jsxs)(fi,{open:c,onOpenChange:l,children:[(0,Q.jsx)(li,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`facet-${e}`,"data-active":u?`true`:void 0,"aria-label":`Filter by ${t.toLowerCase()}`,className:D(`inline-flex h-7 items-center gap-1.5 rounded-full border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,u&&`border-accent-strong/40 bg-accent-strong/10 text-foreground`),children:[(0,Q.jsx)(`span`,{className:D(u&&`text-soft-foreground`),children:t}),u?(0,Q.jsx)(`span`,{className:`max-w-[140px] truncate font-semibold`,children:d}):null,(0,Q.jsx)(fu,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Q.jsxs)(Qr,{align:`start`,className:`w-64 p-0`,"data-testid":`facet-${e}-menu`,children:[(0,Q.jsxs)(Ls,{children:[(0,Q.jsx)(Rs,{placeholder:o??`Search ${t.toLowerCase()}…`}),(0,Q.jsxs)(Es,{children:[(0,Q.jsx)(Ns,{children:s}),(0,Q.jsx)(Ps,{children:n.map(e=>{let t=r.includes(e.value);return(0,Q.jsxs)(fc,{value:e.label,onSelect:()=>i(e.value),"data-slot":`facet-option`,"data-value":e.value,"aria-checked":t,role:`option`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:D(`flex size-4 shrink-0 items-center justify-center rounded-[4px] border`,t?`border-accent-strong bg-accent-strong text-accent-strong-foreground`:`border-input`),children:t?(0,Q.jsx)(uu,{className:`size-3`}):null}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.count===void 0?null:(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-soft-foreground tabular-nums`,children:e.count})]},e.value)})})]})]}),u?(0,Q.jsx)(`div`,{className:`border-t border-border p-1`,children:(0,Q.jsxs)(`button`,{type:`button`,"data-action":`facet-${e}-clear`,onClick:()=>a(),className:`w-full rounded-sm px-2 py-1.5 text-left text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[`Clear `,t.toLowerCase()]})}):null]})]})}function mP({label:e,count:t,selected:n,onToggle:r,slot:i,tone:a=`neutral`}){return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":i,"data-selected":n?`true`:void 0,"aria-pressed":n,onClick:r,className:D(`inline-flex h-7 items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium transition-colors`,a===`tag`?`border-accent-strong/25 bg-accent-strong/10 text-accent-text hover:bg-accent-strong/20`:`border-border bg-card text-muted-foreground hover:bg-muted hover:text-foreground`,n&&`border-accent-strong bg-accent-strong text-accent-strong-foreground hover:bg-accent-strong`),children:[e,t===void 0?null:(0,Q.jsx)(`span`,{className:D(`font-mono text-[11px] tabular-nums`,!n&&`text-soft-foreground`),children:t})]})}function hP({slot:e,label:t,value:n,options:r,onChange:i,size:a=`compact`}){return(0,Q.jsx)(`div`,{"data-slot":e,role:`group`,"aria-label":t,className:`inline-flex gap-0.5 rounded-md bg-muted p-[3px]`,children:r.map(e=>{let t=e.value===n;return(0,Q.jsx)(`button`,{type:`button`,"data-value":e.value,"aria-pressed":t,disabled:e.disabled,title:e.title,onClick:()=>i(e.value),className:D(`flex h-6 items-center justify-center rounded-[6px] px-2.5 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,a===`touch`&&`h-11 px-4 text-[13px]`,t&&`bg-card font-semibold text-foreground shadow-xs`),children:e.label},e.value)})})}var gP=` untagged`,_P=[{value:`project`,label:`Project`},{value:`tag`,label:`Tag`},{value:`status`,label:`Status`},{value:`workflow`,label:`Workflow`}];function vP(e,t){return e===t?`none`:t}var yP={query:``,tags:[],statuses:[],workflows:[]};function bP(e,t){let{origin:n,...r}=e;return t===`all`?r:{...r,origin:t}}function xP(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function SP(e){return(e.projects?.length??0)+e.tags.length+e.statuses.length+e.workflows.length+(e.origin===void 0||e.origin===`all`?0:1)}function CP(e){return e.query.trim()!==``||SP(e)>0}function wP(e){return SP(e.filters)+(e.filters.query.trim()===``?0:1)+(e.groupBy===`none`?0:1)}function TP(e){return wP(e)>0}function EP(e,t){let n=new Map(t.map(e=>[e.id,e]));return e.filter(e=>!zr(e)).map(e=>{let t=n.get(e.projectId);return{run:e,project:t,projectName:t?.name||e.projectId,tags:t?.tags??[]}})}function DP(e){let t=new Set;for(let n of e)t.add(n.run.workflow);return[...t].sort((e,t)=>e.localeCompare(t))}function OP(e){let t=new Set;for(let n of e)t.add(n.run.status);return[...t].sort((e,t)=>e.localeCompare(t))}function kP(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 AP=e=>e.tags.length===0?[gP]:e.tags,jP=(e,t)=>e.length===0||t.some(t=>e.includes(t)),MP=(e,t)=>{if(t.length===0)return!0;let n=AP(e).map(e=>e.toLowerCase());return t.some(e=>n.includes(e.toLowerCase()))};function NP(e,t){return{displayTitle:W(e.run),projectName:e.projectName,tags:e.tags,automation:e.run.automationId===void 0?void 0:t(e)??e.run.automationId,references:()=>ni(e.run)}}function PP(e,t,n,r=()=>void 0){let i=t.query.trim()!==``;return e.filter(e=>(n===`archived`?!e.run.archived:e.run.archived)||!ZM(e.run,t.origin??`all`)||!jP(t.projects??[],[e.run.projectId])||!jP(t.statuses,[e.run.status])||!jP(t.workflows,[e.run.workflow])||!MP(e,t.tags)?!1:!i||Gr(e.run,t.query,{scope:`shown`,extras:NP(e,r)}))}function FP(e,t,n,r,i){return PP(e,r===`origin`?{...t,origin:`all`}:{...t,[r]:[]},n,i)}function IP(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(gP,`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 LP(e,t){let n=new Map(t.map(e=>[e.id,e.name]));return e.map(e=>n.get(e)||e)}var RP={query:`q`,project:`project`,tag:`tag`,untagged:`untagged`,status:`status`,workflow:`workflow`,groupBy:`group`,archived:`archived`,origin:`origin`},zP=new Set(_P.map(e=>e.value));function BP(e){let t=new URLSearchParams,n=e.filters.query.trim();n!==``&&t.set(RP.query,n);for(let n of e.filters.tags)n===` untagged`?t.set(RP.untagged,`1`):t.append(RP.tag,n);for(let n of e.filters.projects??[])t.append(RP.project,n);for(let n of e.filters.statuses)t.append(RP.status,n);for(let n of e.filters.workflows)t.append(RP.workflow,n);return e.groupBy!==`none`&&t.set(RP.groupBy,e.groupBy),e.view===`archived`&&t.set(RP.archived,`1`),e.filters.origin!==void 0&&e.filters.origin!==`all`&&t.set(RP.origin,e.filters.origin),t}function VP(e,t){let n=e.getAll(RP.tag).filter(e=>e!==``);e.get(RP.untagged)===`1`&&n.push(gP);let r=e.get(RP.groupBy)??``,i=YM(XM(e.get(RP.origin)),t);return{filters:{query:e.get(RP.query)??``,...e.has(RP.project)?{projects:e.getAll(RP.project).filter(Boolean)}:{},tags:n,statuses:e.getAll(RP.status).filter(e=>e!==``),workflows:e.getAll(RP.workflow).filter(e=>e!==``),...i===`all`?{}:{origin:i}},groupBy:zP.has(r)?r:`none`,view:e.get(RP.archived)===`1`?`archived`:`active`}}var HP=15e3,UP=250,WP=1,GP=new Set([`done`,`failed`,`cancelled`]);function KP(){return JP({request:({task:e,archived:t})=>gt(Wn(e.run.id,{projectId:e.run.projectId}),t),patch:({archived:e})=>t=>({...t,archived:e})})}function qP(){return JP({request:({task:e,read:t})=>Ye(Wn(e.run.id,{projectId:e.run.projectId}),t),patch:({read:e})=>t=>{if(e)return{...t,seenAt:new Date().toISOString()};let{seenAt:n,...r}=t;return r}})}function JP({request:e,patch:t}){let n=Hn();return jn({mutationFn:e,onMutate:e=>n.patchIndex(Wn(e.task.run.id,{projectId:e.task.run.projectId}),()=>t(e)),onError:(e,t,n)=>{n?.rollback(),G(e.message,{tone:`danger`})},onSettled:(e,t,{task:r},i)=>{i?i.settle():n.invalidateAfter(`indexed`,Wn(r.run.id,{projectId:r.run.projectId}))}})}function YP(){let{expandedRuns:e,toggleExpandedRun:t}=wj(),n=An(),r=bN(On().data),i=mn(!0,HP),[a,o]=qk(),s=js(),{filters:c,groupBy:l,view:u}=Z.useMemo(()=>VP(a,s),[a,s]),d=Hb(3e4),f=e=>o(t=>{let n=BP(e(VP(t,!0))),r=t.get(`tasks`);return(r===`flat`||r===`virtual`)&&n.set(`tasks`,r),n}),p=e=>f(t=>({...t,filters:e(t.filters)})),m=e=>f(t=>({...t,groupBy:e})),h=e=>f(t=>({...t,view:e})),[g,_]=Z.useState(l!==`none`||c.tags.length>0),[v,y]=QP(c.query,e=>p(t=>({...t,query:e}))),b=i.data?.referenceStatuses;Z.useEffect(()=>{b&&pr(b)},[b]);let x=Z.useMemo(()=>n.data?.projects??[],[n.data]),S=Z.useMemo(()=>i.data?.runs??[],[i.data]),w=Z.useMemo(()=>EP(S,x),[S,x]),{nameOf:T,visible:D,originTotals:O,statusGroups:k,folds:A}=$P({tasks:w,filters:c,view:u,groupBy:l,index:S,automationsOn:s}),j=Z.useMemo(()=>IP(D,l),[D,l]),M=c.origin??`all`,ee=e=>p(t=>bP(t,e)),te=Z.useMemo(()=>D.flatMap(e=>Wr(e.run,e.project?.repoUrl).filter(t=>ei(t,e.project?.repoUrl)).map(t=>({projectId:e.run.projectId,kind:t.kind,number:t.number}))),[D]),N=LP(i.data?.truncated??[],x),P=(e,t)=>p(n=>({...n,[e]:xP(n[e]??[],t)})),ne=e=>p(t=>({...t,[e]:[]})),F=KP(),I=qP(),re=Z.useCallback((e,t)=>F.mutate({task:e,archived:t}),[F.mutate]),ie=Z.useCallback((e,t)=>I.mutate({task:e,read:t}),[I.mutate]),ae=i.error??n.error;if(ae)return(0,Q.jsx)(fP,{groupBy:l,filterDetailsOpen:g,message:ae.message,onRetry:()=>{i.refetch(),n.refetch()}});let oe=(0,Q.jsxs)(`div`,{className:`relative w-full`,children:[(0,Q.jsx)(Fi,{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:v,onChange:e=>y(e.target.value),placeholder:`Search every project…`,"aria-label":`Search tasks across projects`,className:`h-11 w-full rounded-md border border-input bg-card pr-3 pl-8 text-[13px] text-foreground outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`})]});return(0,Q.jsxs)(RM,{layout:l,revision:j,visibilityRevision:JSON.stringify([Br.map(A.isCollapsed),[...e].sort(),u,g]),"data-route":`global-tasks`,"data-presentation":l===`none`?`summary`:`cards`,"data-filter-details":g,className:`flex min-h-full flex-col gap-[22px] px-[18px] pt-6 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-9`,children:[(0,Q.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-[22px]`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h1`,{className:`text-[30px] font-semibold tracking-tight`,children:`All tasks`}),(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:l===`none`?`Every project. One place to review what your agents have shipped.`:`Filter across projects and act on each run without opening the session.`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-6 border-b border-border`,children:[(0,Q.jsx)(eF,{view:`active`,current:u,onSelect:h,children:`Active`}),(0,Q.jsx)(eF,{view:`archived`,current:u,onSelect:h,children:`Archived`}),(0,Q.jsxs)(`span`,{"data-slot":`global-tasks-count`,className:`ml-auto text-[13px] text-soft-foreground tabular-nums`,children:[D.length,` of `,w.length,N.length>0?` loaded`:``]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,Q.jsx)(`div`,{className:`min-w-0 basis-full md:flex-1 md:basis-auto`,children:oe}),(0,Q.jsxs)(E,{variant:`outline`,"aria-expanded":g,onClick:()=>_(e=>!e),children:[(0,Q.jsx)(ca,{"aria-hidden":`true`}),`Filters`]}),(0,Q.jsx)(E,{asChild:!0,className:`min-h-11`,children:(0,Q.jsxs)(C,{to:gs(n.data?.bootProject??`default`,`/new`),children:[(0,Q.jsx)(Bi,{"aria-hidden":`true`}),`New task`]})})]}),(0,Q.jsx)(dN,{origin:M,counts:O,automations:s,onChange:ee,labels:k.map(e=>e.label),onSetAll:A.setAll})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[22px]`,children:[(0,Q.jsx)(tF,{filters:c,onToggle:P,onClearFacet:ne,onClearAll:()=>{y(``),f(e=>({...e,filters:yP,groupBy:`none`}))},groupBy:l,onGroupByChange:m,projects:x,tasks:w,view:u,automationName:T}),(0,Q.jsx)(lP,{projects:N,perProjectLimit:i.data?.perProjectLimit}),i.data===void 0?(0,Q.jsx)(`div`,{role:`status`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:`Loading tasks…`}):(0,Q.jsx)(XP,{view:u,filtered:CP(c),visibleCount:D.length,referenceRequests:te,lists:{groupBy:l,view:u,statusGroups:k,groups:j,folds:A,row:{now:d,onArchive:re,expandedRuns:e,toggleExpandedRun:t,onSetRead:ie,busy:F.isPending||I.isPending,showCost:r.cost,automationName:T}}}),(0,Q.jsx)(uP,{registry:x})]})]})}function XP({view:e,filtered:t,visibleCount:n,referenceRequests:r,lists:i}){return n===0?(0,Q.jsx)(dP,{view:e,filtered:t}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ga,{requests:r,children:(0,Q.jsx)(ZP,{...i})}),i.groupBy===`none`?(0,Q.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Resource details—including tokens, cost, CPU and peak memory—are available when a task row is expanded.`}):null]})}function ZP({groupBy:e,view:t,statusGroups:n,groups:r,folds:i,row:a}){return(0,Q.jsx)(Q.Fragment,{children:e===`none`?n.map(e=>{let n=tN(e);return(0,Q.jsx)(pN,{id:`global-group-${t}-${e.label.replaceAll(` `,`-`)}`,label:e.label,count:n.length,tone:nN(e.label,n.map(e=>e.run)),folded:i.isFolded(e.label),collapsed:i.isCollapsed(e.label),onToggle:()=>i.toggle(e.label),children:(0,Q.jsx)(nF,{summary:!0,tasks:e.rows.flatMap(oN),showProject:!0,...a})},e.label)}):r.map(t=>(0,Q.jsxs)(`section`,{"data-slot":`task-group`,"data-group-key":t.key,children:[(0,Q.jsxs)(`h2`,{className:`mb-1.5 flex items-center gap-2 text-[12px] font-semibold tracking-[0.04em] text-soft-foreground uppercase`,children:[e===`project`?(0,Q.jsx)(C,{to:gs(t.key,`/`),"data-slot":`group-project-link`,className:`hover:text-foreground hover:underline`,children:t.label}):t.label,(0,Q.jsx)(`span`,{className:`font-mono text-[11px] font-medium tabular-nums`,children:t.tasks.length})]}),(0,Q.jsx)(nF,{tasks:t.tasks,showProject:e!==`project`,...a})]},t.key))})}function QP(e,t){let[n,r]=Z.useState(e),i=Z.useRef(e);return Z.useEffect(()=>{e!==i.current&&r(e),i.current=e},[e]),Z.useEffect(()=>{if(n===i.current)return;let e=setTimeout(()=>{i.current=n,t(n)},UP);return()=>clearTimeout(e)},[n]),[n,r]}function $P({tasks:e,filters:t,view:n,groupBy:r,index:i,automationsOn:a}){let o=Z.useMemo(()=>[...new Set(e.filter(e=>e.run.automationId!==void 0).map(e=>e.run.projectId))],[e]),s=dr(o,a&&o.length>0),c=Z.useCallback(e=>e.run.automationId===void 0?void 0:s(e.run.projectId,e.run.automationId),[s]),l=Z.useMemo(()=>PP(e,t,n,c),[e,t,n,c]),u=$M(FP(e,t,n,`origin`,c).map(e=>e.run),n),d=r===`none`?aN(l,n,i):[];return{nameOf:c,visible:l,originTotals:u,statusGroups:d,folds:vN(`global`,n,new Set(t.query.trim()===``?[]:d.map(e=>e.label)))}}function eF({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:D(`flex min-h-11 items-center justify-center border-b-2 border-transparent text-[13px] font-medium text-muted-foreground`,i&&`border-accent-strong font-semibold text-accent-text`),children:r})}function tF({filters:e,onToggle:t,onClearFacet:n,onClearAll:r,groupBy:i,onGroupByChange:a,projects:o,tasks:s,view:c,automationName:l}){let u=Z.useMemo(()=>Fn(o),[o]),d=Z.useMemo(()=>{let t=(t,n)=>kP(FP(s,e,c,t,l),n);return{projects:t(`projects`,e=>[e.run.projectId]),tags:t(`tags`,AP),statuses:t(`statuses`,e=>[e.run.status]),workflows:t(`workflows`,e=>[e.run.workflow])}},[s,e,c,l]),f=e=>t=>({...t,count:e.get(t.value)??0});return(0,Q.jsxs)(`div`,{"data-slot":`global-tasks-filters`,className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,Q.jsx)(pP,{slot:`project`,label:`Project`,selected:e.projects??[],onToggle:e=>t(`projects`,e),onClear:()=>n(`projects`),options:[...new Map(s.map(e=>[e.run.projectId,e.projectName])).entries()].map(([e,t])=>({value:e,label:t})).map(f(d.projects)),emptyLabel:`No tasks to filter`}),(0,Q.jsx)(pP,{slot:`status`,label:`Status`,selected:e.statuses,onToggle:e=>t(`statuses`,e),onClear:()=>n(`statuses`),options:OP(s).map(e=>({value:e,label:e})).map(f(d.statuses)),emptyLabel:`No tasks to filter`}),(0,Q.jsx)(pP,{slot:`workflow`,label:`Workflow`,selected:e.workflows,onToggle:e=>t(`workflows`,e),onClear:()=>n(`workflows`),options:DP(s).map(e=>({value:e,label:e})).map(f(d.workflows)),emptyLabel:`No tasks to filter`}),(0,Q.jsxs)(`div`,{"data-slot":`group-controls`,className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`text-[11px] font-medium text-soft-foreground`,children:`Group by`}),(0,Q.jsx)(hP,{slot:`group-by`,label:`Group tasks by`,value:i,options:_P,onChange:e=>a(vP(i,e))})]}),TP({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)(oa,{className:`size-3`,"aria-hidden":`true`}),`Clear`,` (${wP({filters:e,groupBy:i})})`]}):null]}),u.length>0?(0,Q.jsxs)(`div`,{"data-slot":`tag-filters`,className:`flex flex-wrap items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] font-medium text-soft-foreground`,children:`Tags`}),u.map(n=>(0,Q.jsx)(mP,{slot:`tag-filter`,tone:`tag`,label:n,count:d.tags.get(n)??0,selected:e.tags.some(e=>e.toLowerCase()===n.toLowerCase()),onToggle:()=>t(`tags`,n)},n)),(0,Q.jsx)(mP,{slot:`tag-filter`,label:`Untagged`,count:d.tags.get(` untagged`)??0,selected:e.tags.includes(gP),onToggle:()=>t(`tags`,gP)})]}):(0,Q.jsxs)(`p`,{"data-slot":`no-tags-hint`,className:`text-[11px] text-soft-foreground`,children:[`Tag connected repositories in`,` `,(0,Q.jsx)(C,{to:`/settings/global/projects`,className:`font-medium text-accent-text hover:underline`,children:Ka(`projects`)}),` `,`to group their tasks together here.`]})]})}function nF({summary:e=!1,expandedRuns:t,toggleExpandedRun:n,tasks:r,now:i,showProject:a,onArchive:o,onSetRead:s,busy:c,showCost:l,automationName:u}){let d=Fj(r.map(e=>`${e.run.projectId}/${e.run.id}`),t),f=ci();return(0,Q.jsxs)(`div`,{role:e?`table`:void 0,"aria-rowcount":e?d.rowCount:void 0,"data-slot":`global-tasks-table`,className:`overflow-x-auto rounded-lg border border-border bg-card p-5`,children:[(0,Q.jsx)(`div`,{"data-slot":`global-summary-head`,className:`text-[12px]`,role:`row`,"aria-rowindex":1,children:[`Task`,`Workflow`,`Changes`,`Pull request`,`Started`].map(e=>(0,Q.jsx)(`span`,{role:`columnheader`,children:e},e))}),(0,Q.jsx)(Ng,{children:(0,Q.jsx)(LM,{...e?{itemSize:f?115:218}:{},items:r,itemKey:e=>`${e.run.projectId}/${e.run.id}`,children:(r,f)=>(0,Q.jsx)(rF,{task:r,summary:e,rowIndex:d.indexes[f],resourcesOpen:t.has(`${r.run.projectId}/${r.run.id}`),toggleExpandedRun:n,now:i,showProject:a,onArchive:o,onSetRead:s,busy:c,showCost:l,automationName:u(r)},`${r.run.projectId}/${r.run.id}`)})})]})}var rF=Z.memo(function({rowIndex:e,resourcesOpen:t,toggleExpandedRun:n,summary:r,task:i,now:a,showProject:o,onArchive:s,onSetRead:c,busy:l,showCost:u,automationName:d}){let f=r?`row`:void 0,p=r?`cell`:void 0,{run:m}=i,h=xe(m),g=gs(m.projectId,`/tasks/${m.id}`),_=Wr(m,i.project?.repoUrl),v=Ar(m,m.usage);return(0,Q.jsxs)(`article`,{role:r?`rowgroup`:void 0,"data-status":m.status,"data-expanded":t,"data-slot":`global-task-row`,"data-run-id":m.id,"data-project":m.projectId,className:`hover:bg-muted max-md:flex max-md:flex-wrap max-md:items-center max-md:gap-x-3 max-md:gap-y-2 max-md:border-b max-md:border-border max-md:py-5 `,children:[(0,Q.jsxs)(`div`,{"data-slot":`global-task-cells`,className:`contents`,role:f,"aria-rowindex":r?e:void 0,children:[(0,Q.jsx)(iF,{summary:r,task:i,showProject:o,automationName:d,resourcesOpen:t,toggleExpandedRun:n}),(0,Q.jsx)(`div`,{role:p,"data-slot":`global-task-workflow`,className:`text-[13px] text-muted-foreground`,children:m.workflow}),(0,Q.jsx)(`div`,{role:p,"data-slot":`global-task-diff`,className:`text-xs text-muted-foreground`,children:(0,Q.jsx)(`span`,{title:`Change totals are available in the project task list`,children:`—`})}),(0,Q.jsx)(`div`,{role:p,"data-slot":`global-task-references`,children:_.length>0?(0,Q.jsx)(sF,{references:_,run:m,repoBase:i.project?.repoUrl}):(0,Q.jsx)(lF,{})}),(0,Q.jsx)(`div`,{role:p,"data-slot":`global-task-age`,className:`text-right text-xs text-soft-foreground tabular-nums`,children:za(m.startedAt??m.createdAt,a)})]}),!r||t?(0,Q.jsx)(`div`,{className:`contents`,role:f,"aria-rowindex":r?e+1:void 0,children:(0,Q.jsxs)(`div`,{"data-slot":`global-task-detail-cell`,role:p,"aria-colspan":r?5:void 0,className:r?`col-span-full flex flex-col gap-3`:`contents`,children:[(0,Q.jsx)(`div`,{"data-slot":`global-task-actions`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,Q.jsx)(aF,{task:i,busy:l,onSetRead:c}),(0,Q.jsx)(oF,{task:i,busy:l,onArchive:s}),(0,Q.jsx)(E,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(C,{to:g,children:`Open task`})})]})}),t?(0,Q.jsxs)(`div`,{"data-slot":`global-task-resources`,className:`col-span-full flex flex-col gap-3`,children:[(0,Q.jsx)(hN,{projectId:m.projectId,runId:m.id,status:h.label,error:m.error,open:(0,Q.jsx)(E,{asChild:!0,variant:`outline`,className:`min-h-11`,children:(0,Q.jsxs)(C,{to:g,children:[`Open task`,(0,Q.jsxs)(`span`,{className:`sr-only`,children:[`: `,W(m)]})]})})}),(0,Q.jsxs)(`dl`,{className:`grid grid-cols-2 gap-4 rounded-md bg-muted/50 p-4 text-xs md:grid-cols-3`,children:[u?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Cost`}),(0,Q.jsx)(`dd`,{className:`mt-1`,children:oi(m.costUsd)||`—`})]}):null,(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`CPU`}),(0,Q.jsx)(`dd`,{"data-usage":`cpu`,"data-usage-kind":v.cpu.kind,title:v.cpu.title,className:`mt-1`,children:v.cpu.text||`—`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Memory`}),(0,Q.jsx)(`dd`,{"data-usage":`mem`,"data-usage-kind":v.mem.kind,title:v.mem.title,className:`mt-1`,children:v.mem.text||`—`})]})]})]}):null]})}):null]})},(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.length===i.tags.length&&n.tags.every((e,t)=>e===i.tags[t])&&Object.keys(r).every(e=>r[e]===a[e])});function iF({summary:e,task:t,showProject:n,automationName:r,resourcesOpen:i,toggleExpandedRun:a}){let{run:o}=t,s=xe(o),c=gs(o.projectId,`/tasks/${o.id}`),l=Zr(o),u=ph(o);return(0,Q.jsxs)(`div`,{role:e?`cell`:void 0,"data-slot":`global-task-title`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[o.delegation?.role===`worker`?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Worker`}):null,(0,Q.jsx)(C,{to:c,title:W(o),"data-task-control":`title`,className:D(`min-w-0 truncate text-[14px] md:text-[13px]`,l?`font-semibold text-foreground`:u?`font-medium text-muted-foreground`:`font-medium`),children:W(o)}),l?(0,Q.jsx)($,{tone:hh(o),role:`img`,"aria-label":`unread`,title:`Unread — not opened since it finished`,className:`shrink-0`}):null]}),(0,Q.jsx)(`div`,{className:`mt-1`,children:(0,Q.jsx)(mN,{automationId:o.automationId,automationName:r,project:n?(0,Q.jsx)(C,{to:gs(o.projectId,`/`),"data-slot":`task-project`,className:`truncate hover:text-foreground`,children:t.projectName}):void 0})}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,"data-task-control":`resources`,"aria-expanded":i,"aria-label":`${i?`Hide`:`Show`} resources for ${W(o)}`,onClick:()=>a(`${o.projectId}/${o.id}`),"aria-describedby":`global-status-${o.projectId}-${o.id}`,title:`Resources and actions`,className:`min-h-[26px] rounded-md p-0 text-[11px] text-muted-foreground hover:bg-muted`,children:(0,Q.jsx)(KM,{id:`global-status-${o.projectId}-${o.id}`,dot:s.tone,shape:s.shape,pulse:s.pulse,children:s.label})}),(0,Q.jsx)(`span`,{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)(cF,{tag:e},e))}):null})]})]})}function aF({task:e,busy:t,onSetRead:n}){if(!Ir(e.run))return null;let r=Zr(e.run),i=W(e.run),a=r?`Mark ${i} read`:`Mark ${i} unread`,o=r?La:Eu;return(0,Q.jsxs)(Pg,{children:[(0,Q.jsx)(Fg,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-action":r?`mark-read`:`mark-unread`,"aria-label":a,disabled:t,onClick:()=>n(e,r),className:D(`inline-flex size-11 items-center justify-center md:size-8 rounded-md transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none disabled:cursor-wait disabled:opacity-50`,r?`text-accent-icon`:`text-soft-foreground`),children:[(0,Q.jsx)(o,{className:`size-3.5`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{children:r?`Mark read`:`Mark unread`})]})}),(0,Q.jsx)(Ig,{side:`left`,children:r?`Mark read`:`Mark unread`})]})}function oF({task:e,busy:t,onArchive:n}){let r=e.run.archived;if(!r&&!GP.has(e.run.status))return null;let i=r?`Restore ${W(e.run)} to the active list`:`Archive ${W(e.run)}`;return(0,Q.jsxs)(Pg,{children:[(0,Q.jsx)(Fg,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-action":r?`unarchive-run`:`archive-run`,"aria-label":i,disabled:t,onClick:()=>n(e,!r),className:`inline-flex size-11 items-center justify-center md:size-8 rounded-md text-soft-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none disabled:cursor-wait disabled:opacity-50`,children:[(0,Q.jsx)(r?iu:ha,{className:`size-3.5`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{children:r?`Unarchive`:`Archive`})]})}),(0,Q.jsx)(Ig,{side:`left`,children:r?`Restore`:`Archive`})]})}function sF({references:e,run:t,repoBase:n}){return(0,Q.jsx)(Sb,{references:e,maxVisible:WP,taskTitle:W(t),projectId:t.projectId,runId:t.id,repoBase:n})}function cF({tag:e,className:t}){return(0,Q.jsx)(`span`,{"data-slot":`project-tag`,className:D(`inline-flex max-w-full items-center truncate rounded-full bg-muted px-1.5 py-px text-[11px] font-medium text-muted-foreground`,t),children:e})}function lF(){return(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`})}var uF=new Map;function dF(e){let t=uF.get(e);return t||(t=new Intl.DateTimeFormat(`en-CA`,{timeZone:e,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}),uF.set(e,t)),t}function fF(e,t){try{let n=dF(t).formatToParts(new Date(e)),r=e=>Number(n.find(t=>t.type===e)?.value),i=r(`year`),a=r(`month`),o=r(`day`);return{year:i,month:a,day:o,hour:r(`hour`)%24,minute:r(`minute`),second:r(`second`),weekday:pF(i,a,o)}}catch{return null}}function pF(e,t,n){return(new Date(Date.UTC(e,t-1,n)).getUTCDay()+6)%7+1}function mF(e,t){let n=fF(t,e);return n?Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second)-t:null}function hF(e,t,n,r,i,a){let o=Date.UTC(e,t-1,n,r,i,0,0),s=o;for(let e=0;e<3;e+=1){let e=mF(a,s);if(e===null)return null;let t=o-e;if(Math.abs(t-s)<1e3)return t;s=t}return s}function gF(e){if(!e)return!1;try{return dF(e).format(new Date(0)),!0}catch{return!1}}var _F=[`daily`,`weekdays`,`weekly`,`hours`,`once`],vF=[1,2,3,4,6,8,12],yF=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],bF=[`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`,`Sunday`],xF=43200,SF=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/,CF=[`hour`,`minute`,`day`,`every`],wF=[`at`,`timeZone`,`latestStartMinutes`],TF=`the due time has passed; choose a later time or use Run now`,EF=Yt([`paused`,`waiting`,`failed`,`missed`,`archived`]);function DF(e){return`unknown time zone "${e}"; use an IANA name such as Europe/Warsaw`}var OF=B({type:Yt(_F),hour:R().int().min(0).max(23).optional(),minute:R().int().min(0).max(59).optional(),day:R().int().min(1).max(7).optional(),every:an([$t(1),$t(2),$t(3),$t(4),$t(6),$t(8),$t(12)]).optional(),at:z().regex(SF,`at must be YYYY-MM-DDTHH:MM`).optional(),timeZone:z().optional(),latestStartMinutes:R().int().min(10).max(xF).optional()}).superRefine((e,t)=>{let n=t=>e[t]!==void 0,r=(e,n)=>t.addIssue({code:`custom`,path:[e],message:n});if(e.type!==`once`){for(let e of wF)n(e)&&r(e,`${e} applies only to a once schedule`);return}for(let e of CF)n(e)&&r(e,`${e} does not apply to a once schedule`);e.at===void 0?r(`at`,`a once schedule needs at (YYYY-MM-DDTHH:MM)`):SF.test(e.at)&&!MF(e.at)&&r(`at`,`at is not a real date and time`),e.timeZone===void 0?r(`timeZone`,`a once schedule needs a timeZone`):gF(e.timeZone)||r(`timeZone`,DF(e.timeZone))});function kF(e){return{type:e.type,hour:e.hour??4,minute:e.minute??0,day:e.day??1,every:e.every??6,...e.at===void 0?{}:{at:e.at},...e.timeZone===void 0?{}:{timeZone:e.timeZone},...e.latestStartMinutes===void 0?{}:{latestStartMinutes:e.latestStartMinutes}}}function AF(e){if(e.type!==`once`||!e.at||!e.timeZone)return null;let t=jF(e.at);return t&&hF(t.year,t.month,t.day,t.hour,t.minute,e.timeZone)}function jF(e){let t=SF.exec(e);if(!t)return null;let[n,r,i,a,o]=t.slice(1).map(Number),s=new Date(Date.UTC(n,r,0)).getUTCDate();return r<1||r>12||i<1||i>s||a>23||o>59?null:{year:n,month:r,day:i,hour:a,minute:o}}var MF=e=>jF(e)!==null,NF=e=>String(e).padStart(2,`0`);function PF(e,t=0){return`${NF(e)}:${NF(t)}`}function FF(e){let t=kF(e);switch(t.type){case`once`:return IF(t);case`daily`:return`every day at ${PF(t.hour,t.minute)}`;case`weekdays`:return`weekdays at ${PF(t.hour,t.minute)}`;case`hours`:return t.every===1?`every hour`:`every ${t.every} hours`;case`weekly`:return`${bF[t.day-1]}s at ${PF(t.hour,t.minute)}`}}function IF(e){let t=e.at?jF(e.at):null;if(!t)return`once`;let{year:n,month:r,day:i,hour:a,minute:o}=t;return`once on ${yF[pF(n,r,i)-1]} ${i} ${LF[r-1]} ${n} at ${PF(a,o)} (${e.timeZone??`UTC`})`}var LF=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function RF(e){let t=kF(e);switch(t.type){case`once`:throw Error(`a once schedule has no cron form`);case`daily`:return`${t.minute} ${t.hour} * * *`;case`weekdays`:return`${t.minute} ${t.hour} * * 1-5`;case`hours`:return`0 */${t.every} * * *`;case`weekly`:return`${t.minute} ${t.hour} * * ${t.day%7}`}}function zF(e,t){switch(e.type){case`once`:return[];case`daily`:return[[e.hour,e.minute]];case`weekdays`:return t<=5?[[e.hour,e.minute]]:[];case`weekly`:return t===e.day?[[e.hour,e.minute]]:[];case`hours`:{let t=[];for(let n=0;n<24;n+=e.every)t.push([n,0]);return t}}}function BF(e,t,n,r,i=1e3){if(e.type===`once`){let r=AF(e);return r!==null&&r>=t&&r<n&&i>0?[r]:[]}let a=kF(e),o=fF(t,r);if(!o||n<=t)return[];let s=[],c=Math.ceil((n-t)/864e5)+2;for(let e=-1;e<=c;e+=1){let c=new Date(Date.UTC(o.year,o.month-1,o.day+e)),l=c.getUTCFullYear(),u=c.getUTCMonth()+1,d=c.getUTCDate();for(let[e,o]of zF(a,pF(l,u,d))){let a=hF(l,u,d,e,o,r);if(a===null||a!==s.at(-1)&&a>=t&&a<n&&(s.push(a),s.length>=i))return s}}return s}function VF(e,t){let n=t-e;if(n<=0)return`now`;let r=Math.floor(n/6e4);if(r<1)return`in <1m`;if(r<60)return`in ${r}m`;let i=Math.floor(r/60);return i<24?`in ${i}h`:`in ${Math.floor(i/24)}d`}var HF=new Map;function UF(e,t){if(!Number.isFinite(e))return null;let n=HF.get(t);try{n??=new Intl.DateTimeFormat(`en-GB`,{timeZone:t,weekday:`short`,year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`})}catch{return null}HF.set(t,n);let r={};for(let t of n.formatToParts(e))r[t.type]=t.value;let i=new Date(`${r.month} 1, ${r.year} UTC`).getUTCMonth();return{weekday:r.weekday,day:r.day,month:r.month,hour:r.hour,minute:r.minute,key:`${r.year}-${i}-${r.day}`,dayNumber:Math.floor(Date.UTC(Number(r.year),i,Number(r.day))/864e5)}}function WF(e,t){let n=UF(Date.parse(e),t);return n?`${n.weekday} ${n.hour}:${n.minute}`:e}function GF(e,t,n){let r=UF(Date.parse(e),t),i=UF(n,t);if(!r||!i)return e;let a=`${r.hour}:${r.minute}`,o=i.dayNumber-r.dayNumber;return o===0?`Today ${a}`:o===1?`Yesterday ${a}`:o>1&&o<7?`${r.weekday} ${a}`:`${r.day} ${r.month} ${a}`}var KF=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],qF=e=>String(e).padStart(2,`0`);function JF(e){let t=e?jF(e):null;if(!t)return null;let{year:n,month:r,day:i,hour:a,minute:o}=t;return{date:`${yF[pF(n,r,i)-1]} ${i} ${KF[r-1]} ${n}`,time:`${qF(a)}:${qF(o)}`}}var YF=36e5;function XF(e){let t=AF(e),n=e.timeZone,r=JF(e.at),i=t===null||!n?null:fF(t,n);if(t===null||!n||!r||!i)return null;let a={date:`${yF[pF(i.year,i.month,i.day)-1]} ${i.day} ${KF[i.month-1]} ${i.year}`,time:`${qF(i.hour)}:${qF(i.minute)}`};if(a.date!==r.date||a.time!==r.time)return{...a,note:`${r.time} does not exist on ${r.date} in ${n}.`};let o=e=>{let t=fF(e,n);return!!t&&t.day===i.day&&t.hour===i.hour&&t.minute===i.minute},s=(mF(n,t-12*YF)??0)-(mF(n,t+12*YF)??0);if(s<=0)return a;let c=o(t+s);if(!c&&!o(t-s))return a;let l=(mF(n,t)??0)/6e4,u=`UTC${l<0?`-`:`+`}${qF(Math.floor(Math.abs(l)/60))}:${qF(Math.abs(l)%60)}`;return{...a,note:`${r.time} happens twice that day; it runs at ${c?`the first`:`the second`} (${u}).`}}var ZF=Yt([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),QF=B({includeExisting:Jt().optional(),authors:Xt(z()).optional(),assignees:Xt(z()).optional(),requireCurrentLabels:Jt().optional(),allLabels:Xt(z()).optional(),anyLabels:Xt(z()).optional(),excludeLabels:Xt(z()).optional(),changedLabels:Xt(z()).optional(),lookbackDays:R(),maxRecords:R()}),$F=Yt([`github`,`schedule`]),eI=he.omit({task:!0,images:!0,systemPrompt:!0}).extend({prompt:z(),variants:an([$t(1),$t(2),$t(3)]).optional(),systemPrompt:z().optional()});function tI(e){let{variants:t,...n}=e;return n}var nI=B({at:z(),outcome:Yt([`launched`,`cancelled`]),runId:z().optional(),receiptId:z().optional(),trigger:Yt([`schedule`,`late`,`manual`,`retry`]).optional()}),rI=B({id:z(),revision:R(),name:z(),description:z().optional(),enabled:Jt(),kind:$F,events:Xt(ZF).optional(),intervalSeconds:R().optional(),filters:QF.optional(),schedule:OF.optional(),task:eI,archived:nI.optional(),createdAt:z(),updatedAt:z()}),iI=B({timestamp:z(),tieBreaker:z().optional()}),aI=B({since:z().datetime(),until:z().datetime(),source:R().int().min(0).max(2),page:R().int().min(1).max(10),item:R().int().min(0).max(100),event:R().int().min(0).max(1e3),cursor:iI.optional()}),oI={lastError:z().max(1e3).optional(),lastErrorAt:z().datetime().optional()},sI=B({revision:R().optional(),baselineAt:z().optional(),armedAt:z().optional(),historyScan:aI.optional(),cursor:iI.optional(),frozenHighWatermark:iI.extend({tieBreaker:z()}).optional(),backlogAfter:iI.extend({tieBreaker:z()}).optional(),nextCheckAt:z().optional(),lastSuccessAt:z().optional(),nextRunAt:z().optional(),lastRunAt:z().optional(),etags:Zt(z(),z()).optional(),backoffUntil:z().optional(),consecutiveFailures:R().optional(),...oI,onceOutcome:Yt([`failed`,`missed`]).optional()});function cI(e){let t=e?.consecutiveFailures??0;if(!(t<3||!e?.lastError))return{consecutiveFailures:t,lastError:e.lastError,...e.lastErrorAt?{lastErrorAt:e.lastErrorAt}:{},...e.backoffUntil?{retryAt:e.backoffUntil}:{}}}var lI=Yt([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]),uI=B({seq:R(),ts:z(),automationId:z(),revision:R(),event:ZF.optional(),result:lI,reason:z().optional(),durationMs:R().optional(),receiptId:z().optional(),runId:z().optional(),githubNumber:R().optional(),githubTitle:z().optional(),githubUrl:z().optional(),rateLimit:B({bucket:Yt([`core`,`search`]),remaining:R().optional(),resetAt:z().optional()}).optional()}),dI=B({matches:R(),launched:R(),duplicates:R(),errors:R()}),fI=rI.extend({state:sI.optional(),latestLog:uI.optional(),counts:dI,nextRunAt:z().optional(),onceStatus:EF.optional()});B({available:Jt(),reason:z().optional(),timeZone:z(),scheduler:B({state:Yt([`scheduled`,`idle`]),nextDue:z().optional()}),automations:Xt(fI)}),B({automation:rI}).extend({once:B({dueAt:z(),timeZone:z(),resolvedInstant:z(),note:z()}).optional()}),B({automation:rI,state:sI.optional(),latestLog:uI.optional(),onceStatus:EF.optional()}),B({id:z(),automationId:z(),mode:Yt([`preview`,`execute`]),status:Yt([`queued`,`running`,`complete`,`error`]),createdAt:z(),completedAt:z().optional(),matches:R().optional(),truncated:Jt().optional(),error:z().optional()}),B({checkId:z()}),B({records:Xt(uI)}),B({receiptId:z(),runId:z()}),B({runId:z()}),rI.omit({id:!0,revision:!0,createdAt:!0,updatedAt:!0,enabled:!0,kind:!0,archived:!0}).extend({kind:$F.optional(),task:eI.omit({variants:!0}).strict(),enable:Jt().optional()}).omit({enable:!0}).extend({enabled:Jt().optional(),expectedRevision:R()}),B({archived:Yt([`include`,`only`]).optional()}),B({mode:Yt([`preview`,`execute`])});function pI({...e}){return(0,Q.jsx)(tf,{"data-slot":`select`,...e})}function mI({...e}){return(0,Q.jsx)(of,{"data-slot":`select-value`,...e})}function hI({className:e,size:t=`default`,children:n,...r}){return(0,Q.jsxs)(rf,{"data-slot":`select-trigger`,"data-size":t,className:D(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-[var(--task-brand-bg)] px-3 py-2 text-sm whitespace-nowrap shadow-none transition-[color,box-shadow] outline-hidden focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-11 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 pointer-hover:bg-muted [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,Q.jsx)(cf,{asChild:!0,children:(0,Q.jsx)(_a,{className:`size-4 opacity-50`})})]})}function gI({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,Q.jsx)(ff,{children:(0,Q.jsxs)(mf,{"data-slot":`select-content`,className:D(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md motion-safe:data-[side=bottom]:slide-in-from-top-2 motion-safe:data-[side=left]:slide-in-from-right-2 motion-safe:data-[side=right]:slide-in-from-left-2 motion-safe:data-[side=top]:slide-in-from-bottom-2 motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:zoom-out-95 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0 motion-safe:data-[state=open]:zoom-in-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,Q.jsx)(vI,{}),(0,Q.jsx)(kf,{className:D(`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)(yI,{})]})})}function _I({className:e,children:t,...n}){return(0,Q.jsxs)(zf,{"data-slot":`select-item`,className:D(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pe-8 ps-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,Q.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute end-2 flex size-3.5 items-center justify-center`,children:(0,Q.jsx)(Uf,{children:(0,Q.jsx)(ia,{className:`size-4`})})}),(0,Q.jsx)(Vf,{children:t})]})}function vI({className:e,...t}){return(0,Q.jsx)(Gf,{"data-slot":`select-scroll-up-button`,className:D(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,Q.jsx)(Xi,{className:`size-4`})})}function yI({className:e,...t}){return(0,Q.jsx)(qf,{"data-slot":`select-scroll-down-button`,className:D(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,Q.jsx)(_a,{className:`size-4`})})}function bI({title:e,subtitle:t,action:n,children:r}){return(0,Q.jsxs)(`main`,{"data-route":`automations`,className:`task-flow-page w-full max-w-full min-w-0 max-md:p-4!`,children:[(0,Q.jsxs)(`header`,{className:`mb-6 flex flex-col items-start gap-5 max-md:mb-4 max-md:gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h1`,{className:`mb-2 text-[28px] font-medium max-md:text-[22px]`,children:e}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t})]}),n]}),r]})}function xI({text:e}){return(0,Q.jsx)(`div`,{role:`status`,className:`rounded-xl border bg-card p-6 text-sm text-muted-foreground`,children:e})}var SI={launched:`success`,manual:`success`,"catch-up":`success`,skipped:`neutral`,missed:`neutral`,"no-match":`neutral`,preview:`neutral`,baseline:`neutral`,duplicate:`neutral`,failed:`danger`,error:`danger`,"rate-limited":`danger`},CI={launched:`Launched`,manual:`Manual`,"catch-up":`Catch up`,skipped:`Skipped`,missed:`Missed`,"no-match":`No match`,preview:`Preview`,baseline:`Baseline`,duplicate:`Duplicate`,failed:`Failed`,error:`Error`,"rate-limited":`Rate limited`};function wI(e){let[t,n]=(0,Z.useState)(),[r,i]=(0,Z.useState)(``),a=(0,Z.useCallback)(t=>de(e,{signal:t}).then(({records:e})=>{t?.aborted||(n(e),i(``))}).catch(e=>{t?.aborted||i(String(e))}),[e]);return(0,Z.useEffect)(()=>{a()},[a]),(0,Z.useEffect)(()=>oe(a),[a]),(0,Z.useEffect)(()=>pl((t,n)=>{t===`automation-change`&&n.automationId===e&&a()}),[e,a]),{records:t,error:r,refresh:a}}function TI(e,t){return e.result!==`failed`&&e.result!==`error`||!e.receiptId||e.runId?!1:!t.some(t=>t.receiptId===e.receiptId&&(t.runId||t.seq>e.seq))}function EI({records:e,all:t,timeZone:n,onRetried:r,readOnly:i=!1}){let a=e=>!i&&TI(e,t),[o,s]=(0,Z.useState)(),[c,l]=(0,Z.useState)(),u=Date.now(),d=async e=>{s(e),l(void 0);try{await Ze(e),r()}catch(t){l({receiptId:e,message:t instanceof Error?t.message:String(t)})}finally{s(void 0)}};return(0,Q.jsx)(`ol`,{className:`grid gap-3`,"aria-label":`Automation execution log`,children:e.map(e=>(0,Q.jsxs)(`li`,{className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(KM,{dot:SI[e.result],children:CI[e.result]}),(0,Q.jsx)(`time`,{className:`text-xs text-muted-foreground`,dateTime:e.ts,title:e.ts,children:GF(e.ts,n,u)})]}),e.reason?(0,Q.jsx)(`p`,{className:`mt-2 text-sm break-words text-muted-foreground`,children:e.reason}):null,e.githubUrl||e.runId||a(e)?(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-sm`,children:[e.githubUrl?(0,Q.jsx)(`a`,{className:`inline-flex min-h-11 items-center underline underline-offset-4 break-all`,href:e.githubUrl,target:`_blank`,rel:`noreferrer`,children:e.githubTitle??`GitHub #${e.githubNumber??``}`}):null,e.runId?(0,Q.jsx)(Y,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`}):null,a(e)?(0,Q.jsx)(E,{variant:`outline`,disabled:o===e.receiptId,onClick:()=>void d(e.receiptId),children:`Retry task`}):null]}):null,c&&c.receiptId===e.receiptId?(0,Q.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm break-words text-destructive`,children:c.message}):null]},e.seq))})}var DI=`all`;function OI({label:e,value:t,onChange:n,options:r}){return(0,Q.jsxs)(pI,{value:t,onValueChange:n,children:[(0,Q.jsx)(hI,{"aria-label":e,className:`w-full sm:w-52`,children:(0,Q.jsx)(mI,{})}),(0,Q.jsx)(gI,{children:r.map(e=>(0,Q.jsx)(_I,{value:e.value,children:e.label},e.value))})]})}function kI({automationId:e,automationName:t,timeZone:n,readOnly:r=!1}){let{records:i,error:a,refresh:o}=wI(e),[s,c]=(0,Z.useState)(DI),[l,u]=(0,Z.useState)(DI),d=(0,Z.useMemo)(()=>(i??[]).filter(e=>(s===DI||e.result===s)&&(l===DI||e.event===l)),[i,s,l]),f=(i??[]).some(e=>e.event);return(0,Q.jsx)(bI,{title:`Execution log`,subtitle:t??`Automation activity`,action:(0,Q.jsx)(E,{variant:`outline`,asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations`,children:`Back to automations`})}),children:a&&!i?(0,Q.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,Q.jsx)(xI,{text:a}),(0,Q.jsx)(E,{variant:`outline`,onClick:()=>void o(),children:`Retry`})]}):i?i.length===0?(0,Q.jsx)(xI,{text:`Nothing has run yet.`}):(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(OI,{label:`Result`,value:s,onChange:c,options:[{value:DI,label:`All results`},...lI.options.map(e=>({value:e,label:CI[e]}))]}),f?(0,Q.jsx)(OI,{label:`Event`,value:l,onChange:u,options:[{value:DI,label:`All events`},...ZF.options.map(e=>({value:e,label:e}))]}):null]}),d.length===0?(0,Q.jsx)(xI,{text:`No rows match these filters.`}):(0,Q.jsx)(EI,{records:d,all:i,timeZone:n,onRetried:()=>void o(),readOnly:r})]}):(0,Q.jsx)(xI,{text:`Loading execution log…`})})}function AI({automationId:e,automationName:t,timeZone:n,showName:r=!1,readOnly:i=!1}){let{records:a,error:o,refresh:s}=wI(e);return(0,Q.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`mt-4 min-w-0 border-t pt-4`,children:[(0,Q.jsxs)(`h3`,{className:`mb-3 text-sm font-medium`,children:[`Recent activity`,r&&t?` · ${t}`:``]}),o&&!a?(0,Q.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,Q.jsx)(xI,{text:o}),(0,Q.jsx)(E,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]}):a?a.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing has run yet.`}):(0,Q.jsx)(EI,{records:a.slice(0,5),all:a,timeZone:n,onRetried:()=>void s(),readOnly:i}):(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading activity…`})]})}function jI({automation:e,timeZone:t,onDeleted:n}){let r=e.archived,i=e.schedule,a=i?XF(i):null,[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(``),f=(0,Z.useRef)(null),p=(0,Z.useRef)(null),m=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let e=m.current===`keep`?p.current:m.current===`delete`?f.current:null;m.current=null,e?.focus()},[o]);let h=async()=>{l(!0);try{await se(e.id),n()}catch(e){d(e instanceof Error?e.message:String(e)),l(!1)}},g=[[`Workflow`,e.task.workflow],[`Runner`,e.task.runner],[`Model`,e.task.model],[`Effort`,e.task.effort]];return(0,Q.jsx)(bI,{title:e.name,subtitle:`Archived one-time schedule. It cannot change; delete it when you no longer need the record.`,children:(0,Q.jsxs)(`div`,{className:`grid min-w-0 max-w-3xl gap-5`,children:[(0,Q.jsxs)(`section`,{className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,Q.jsxs)(`p`,{className:`text-sm break-words`,children:[(0,Q.jsx)(`span`,{children:r.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`}),r.runId?(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsx)(Y,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${r.runId}`,children:`Open task`})]}):null]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Archived ${WF(r.at,t)} (${t}).`}),a&&i?.timeZone?(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Was due ${a.date} ${a.time} (${i.timeZone}).`}):null]}),(0,Q.jsxs)(`section`,{"aria-labelledby":`archived-inputs`,className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,Q.jsx)(`h2`,{id:`archived-inputs`,className:`mb-3 text-[15px] font-medium`,children:`What it ran with`}),(0,Q.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-1`,children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Prompt`}),(0,Q.jsx)(`dd`,{className:`break-words whitespace-pre-wrap`,children:e.task.prompt})]}),g.filter(([,e])=>e).map(([e,t])=>(0,Q.jsxs)(`div`,{className:`grid gap-1`,children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,Q.jsx)(`dd`,{className:`break-words`,children:t})]},e))]})]}),(0,Q.jsxs)(`section`,{className:`min-w-0`,children:[(0,Q.jsx)(AI,{automationId:e.id,automationName:e.name,timeZone:t,readOnly:!0}),(0,Q.jsx)(E,{variant:`outline`,asChild:!0,className:`mt-3`,children:(0,Q.jsx)(Y,{to:`/automations/${e.id}/log`,children:`Execution log`})})]}),(0,Q.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[o?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? Its record and log are removed; the task stays.`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(E,{variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:c,onClick:()=>void h(),children:`Delete schedule`}),(0,Q.jsx)(E,{ref:p,variant:`outline`,disabled:c,onClick:()=>{m.current=`delete`,s(!1)},children:`Keep`})]})]}):(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(E,{ref:f,variant:`outline`,"data-action":`automation-delete`,onClick:()=>{m.current=`keep`,s(!0)},children:`Delete`}),(0,Q.jsx)(E,{variant:`outline`,asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations`,children:`Back to automations`})})]}),u?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:u}):null]})]})})}var MI=`quick-task`;function NI(e={}){let{prompt:t,workflow:n,runner:r,model:i,autonomous:a,archiveWhenDone:o,autoMergePr:s,allowWorkers:c,allowMessaging:l,...u}=tI(e.task??{prompt:``}),d=e.task===void 0;return{name:e.name??``,description:e.description??``,kind:e.kind??`schedule`,schedule:kF(e.schedule??{type:`daily`}),events:e.events??[`issue.opened`],intervalSeconds:e.intervalSeconds??300,filters:e.filters??{lookbackDays:7,maxRecords:25},prompt:t,...n===void 0?d?{workflow:MI}:{}:{workflow:n},...r===void 0?{}:{runner:r},...i===void 0?{}:{model:i},autonomous:a??!0,archiveWhenDone:o??!1,autoMergePr:s??!1,allowWorkers:c!==!1,allowMessaging:l!==!1,enabled:e.enabled??e.enable??!1,taskExtra:u}}function PI(e){switch(e.type){case`daily`:case`weekdays`:return{type:e.type,hour:e.hour,minute:e.minute};case`weekly`:return{type:`weekly`,hour:e.hour,minute:e.minute,day:e.day};case`hours`:return{type:`hours`,every:e.every};case`once`:return{type:`once`,at:e.at??``,timeZone:e.timeZone??``,...e.latestStartMinutes===void 0?{}:{latestStartMinutes:e.latestStartMinutes}}}}function FI(e){return{...e.taskExtra,prompt:e.prompt,...e.workflow?{workflow:e.workflow}:{},...e.runner?{runner:e.runner}:{},...e.model?{model:e.model}:{},autonomous:e.autonomous,...e.archiveWhenDone?{archiveWhenDone:!0}:{},...e.autoMergePr?{autoMergePr:!0}:{},...e.allowWorkers?{}:{allowWorkers:!1},...e.allowMessaging?{}:{allowMessaging:!1}}}function II(e){return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},kind:e.kind,...e.kind===`schedule`?{schedule:PI(e.schedule)}:{events:e.events,intervalSeconds:e.intervalSeconds,filters:e.filters},task:FI(e)}}function LI(e){return{...II(e),enable:e.enabled}}function RI(e,t){return{...II(e),task:{...FI(e),archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging},enabled:e.enabled,expectedRevision:t}}function zI(e){return`'${e.replace(/'/g,`'\\''`)}'`}var BI=new Set([`prompt`,`workflow`,`runner`,`model`,`autonomous`,`worktree`,`archiveWhenDone`,`autoMergePr`,`allowWorkers`,`allowMessaging`]),VI=new Set([`anyLabels`,`authors`,`changedLabels`]);function HI(e){if(e.description!==void 0||!e.name.trim()||!e.task.prompt.trim())return!1;let t=e.task;if(Object.keys(t).some(e=>!BI.has(e))||t.archiveWhenDone===!1||t.autoMergePr===!1||t.allowWorkers===!0||t.allowMessaging===!0||t.worktree!==!0)return!1;if(e.kind===`schedule`)return e.schedule!==void 0;let{events:n,filters:r}=e;return!n?.length||n.some(e=>e.includes(`,`))||!r||r.lookbackDays!==7||r.maxRecords!==25?!1:Object.entries(r).every(([e,t])=>e===`lookbackDays`||e===`maxRecords`||e===`includeExisting`&&t===!0||VI.has(e)&&Array.isArray(t)&&t.length>0)}function UI(e){return e%3600==0?`${e/3600}h`:e%60==0?`${e/60}m`:`${e}s`}function WI(e){return e%1440==0?`${e/1440}d`:e%60==0?`${e/60}h`:`${e}m`}function GI(e,t){return t.startsWith(`-`)?`--${e}=${zI(t)}`:`--${e} ${zI(t)}`}function KI(e){let t=[`${i()} automation add`,GI(`name`,e.name)];if(e.schedule?.type===`once`)t.push(GI(`at`,e.schedule.at),GI(`tz`,e.schedule.timeZone)),e.schedule.latestStartMinutes!==void 0&&t.push(GI(`latest-start`,WI(e.schedule.latestStartMinutes)));else if(e.kind===`schedule`)t.push(GI(`cron`,RF(e.schedule)));else{t.push(GI(`on`,e.events.join(`,`)),`--every ${UI(e.intervalSeconds??300)}`),e.filters?.includeExisting&&t.push(`--include-existing`);for(let n of e.filters?.anyLabels??[])t.push(GI(`label`,n));for(let n of e.filters?.authors??[])t.push(GI(`author`,n));for(let n of e.filters?.changedLabels??[])t.push(GI(`changed-label`,n))}return t.push(...qI(e.task)),e.enable===!0&&t.push(`--enable`),t.push(GI(`prompt`,e.task.prompt)),t.join(` `)}function qI(e){let t=[];return e.workflow&&t.push(GI(`workflow`,e.workflow)),e.runner&&t.push(GI(`runner`,e.runner)),e.model&&t.push(GI(`model`,e.model)),e.autonomous===!1&&t.push(`--no-autonomous`),e.archiveWhenDone&&t.push(`--archive-when-done`),e.autoMergePr&&t.push(`--auto-merge-pr`),e.allowWorkers===!1&&t.push(`--no-workers`),e.allowMessaging===!1&&t.push(`--no-messaging`),t}function JI(e,t){let n=LI(e),r=HI(n)?KI(n):`${i()} automation create --json ${zI(JSON.stringify(n))}`;return t?`CEZ_COCKPIT_URL=${zI(t.origin)} CEZ_PROJECT_ID=${zI(t.projectId)} HSQ_COCKPIT_URL=${zI(t.origin)} HSQ_PROJECT_ID=${zI(t.projectId)} ${r}`:r}function YI({draft:e}){let t=Cs(),n=window.location.origin,r=(0,Z.useMemo)(()=>JI(e,t?{origin:n,projectId:t}:void 0),[e,n,t]),[a,o]=(0,Z.useState)(`idle`),s=(0,Z.useRef)(void 0);(0,Z.useEffect)(()=>()=>clearTimeout(s.current),[]),(0,Z.useEffect)(()=>o(`idle`),[r]);let c=async()=>{clearTimeout(s.current);try{await navigator.clipboard.writeText(r),o(`copied`),s.current=setTimeout(()=>o(`idle`),1600)}catch{o(`failed`)}};return(0,Q.jsxs)(`section`,{"aria-labelledby":`copy-as-cli-heading`,"data-slot":`copy-as-cli`,className:`mbs-4 rounded-xl border bg-card p-4`,children:[(0,Q.jsxs)(`div`,{className:`mbe-2 flex items-center gap-2`,children:[(0,Q.jsx)(`h2`,{id:`copy-as-cli-heading`,className:`text-[15px] font-medium`,children:`Copy as CLI`}),(0,Q.jsxs)(E,{type:`button`,variant:`ghost`,size:`sm`,className:`ms-auto`,onClick:()=>void c(),children:[a===`copied`?(0,Q.jsx)(uu,{"aria-hidden":`true`}):(0,Q.jsx)(bu,{"aria-hidden":`true`}),a===`copied`?`Copied`:`Copy`]})]}),(0,Q.jsx)(`pre`,{className:`m-0 rounded-lg border bg-muted px-2.5 py-2 font-mono text-xs/relaxed break-words whitespace-pre-wrap text-muted-foreground`,children:r}),(0,Q.jsx)(`p`,{role:`status`,className:`mbs-2 text-xs break-words text-muted-foreground`,children:a===`failed`?`Could not copy — select the line and copy it by hand.`:(0,Q.jsxs)(Q.Fragment,{children:[`The definition Save would create. `,(0,Q.jsxs)(`code`,{children:[i(),` automation schema`]}),` prints its shape.`]})})]})}function XI({pressed:e,onClick:t,disabled:n,children:r}){return(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":e,disabled:n,onClick:t,className:D(ac,`h-11 px-4 text-[13px]`,e&&`border-transparent bg-accent-strong text-accent-strong-foreground hover:bg-accent-strong hover:text-accent-strong-foreground`),children:r})}var ZI=ZF.options,QI=[{seconds:60,label:`1 minute`},{seconds:300,label:`5 minutes`},{seconds:900,label:`15 minutes`},{seconds:1800,label:`30 minutes`},{seconds:3600,label:`1 hour`}],$I=[{key:`authors`,label:`Authors`},{key:`assignees`,label:`Assignees`},{key:`allLabels`,label:`Has all labels`},{key:`anyLabels`,label:`Has any label`},{key:`excludeLabels`,label:`Excludes labels`},{key:`changedLabels`,label:`Changed labels`,hint:`Required for the two label events.`}],eL=e=>(e??[]).join(`, `),tL=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean);function nL(e){return e?`Existing matches within the lookback are eligible on the next check. Previously processed matches will not run again.`:`Enabling starts from a current-time baseline. Existing matches will not launch tasks.`}function rL(e){let t=Math.max(1,Math.round(e.intervalSeconds/60));return`Polls GitHub every ${t} minute${t===1?``:`s`} for ${e.events.join(`, `)||`no events`}. ${nL(e.filters.includeExisting)}`}function iL({draft:e,onChange:t,disabledReason:n}){let r=n=>{t({events:e.events.includes(n)?e.events.filter(e=>e!==n):[...e.events,n]})},i=n=>t({filters:{...e.filters,...n}}),a=(n,r)=>{let i=tL(r),{[n]:a,...o}=e.filters;t({filters:i.length?{...o,[n]:i}:o})},o=QI.some(t=>t.seconds===e.intervalSeconds)?QI:[...QI,{seconds:e.intervalSeconds,label:`${Math.round(e.intervalSeconds/60)} minutes`}].sort((e,t)=>e.seconds-t.seconds);return(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[n?(0,Q.jsx)(`p`,{className:`text-xs text-pending-strong`,children:`GitHub unavailable · ${n}`}):null,(0,Q.jsx)(`div`,{role:`group`,"aria-label":`GitHub events`,className:`flex flex-wrap gap-2`,children:ZI.map(t=>(0,Q.jsx)(XI,{pressed:e.events.includes(t),onClick:()=>r(t),children:t},t))}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(Lm,{htmlFor:`automation-interval`,children:`Check every`}),(0,Q.jsxs)(pI,{value:String(e.intervalSeconds),onValueChange:e=>t({intervalSeconds:Number(e)}),children:[(0,Q.jsx)(hI,{id:`automation-interval`,className:`w-full sm:w-48`,"aria-label":`Check every`,children:(0,Q.jsx)(mI,{})}),(0,Q.jsx)(gI,{children:o.map(e=>(0,Q.jsx)(_I,{value:String(e.seconds),children:e.label},e.seconds))})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,Q.jsx)(Um,{"aria-label":`Include existing items`,"aria-describedby":`automation-history-hint`,checked:e.filters.includeExisting??!1,onCheckedChange:e=>i({includeExisting:e})}),(0,Q.jsx)(`span`,{children:`Include existing items`})]}),(0,Q.jsx)(`p`,{id:`automation-history-hint`,className:`text-xs text-muted-foreground`,children:nL(e.filters.includeExisting)})]}),(0,Q.jsxs)(GA,{children:[(0,Q.jsxs)(KA,{className:`group flex min-h-11 items-center gap-2 text-sm font-medium`,children:[`Filters`,(0,Q.jsx)(_a,{"aria-hidden":`true`,className:`size-4 text-soft-foreground transition-transform motion-reduce:transition-none group-data-[state=open]:rotate-180`})]}),(0,Q.jsx)(qA,{children:(0,Q.jsxs)(`div`,{className:`grid gap-4 pt-2 sm:grid-cols-2`,children:[$I.map(t=>(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,Q.jsx)(Lm,{htmlFor:`automation-filter-${t.key}`,children:t.label}),(0,Q.jsx)(Im,{id:`automation-filter-${t.key}`,placeholder:`comma separated`,value:eL(e.filters[t.key]),onChange:e=>a(t.key,e.target.value)}),t.hint?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.hint}):null]},t.key)),(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,Q.jsx)(Lm,{htmlFor:`automation-filter-lookback`,children:`Look back (days)`}),(0,Q.jsx)(Im,{id:`automation-filter-lookback`,type:`number`,min:1,value:e.filters.lookbackDays,onChange:e=>i({lookbackDays:Math.max(1,Number(e.target.value)||1)})})]}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,Q.jsx)(Lm,{htmlFor:`automation-filter-max`,children:`Max records per check`}),(0,Q.jsx)(Im,{id:`automation-filter-max`,type:`number`,min:1,value:e.filters.maxRecords,onChange:e=>i({maxRecords:Math.max(1,Number(e.target.value)||1)})})]})]})})]})]})}var aL=e=>String(e).padStart(2,`0`);function oL({label:e,value:t,max:n,onCommit:r}){let[i,a]=(0,Z.useState)(aL(t)),o=(0,Z.useRef)(null),s=!(/^\d{1,2}$/.test(i)&&Number(i)===t),c=`${e} must be 00–${aL(n)}.`,l=(0,Z.useId)();return(0,Z.useEffect)(()=>{o.current?.setCustomValidity(s?c:``)},[s,c]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Im,{ref:o,"aria-label":e,"aria-invalid":s||void 0,"aria-describedby":s?l:void 0,inputMode:`numeric`,maxLength:2,className:`w-20 text-center tabular-nums`,value:i,onChange:e=>{a(e.target.value),/^\d{1,2}$/.test(e.target.value)&&Number(e.target.value)<=n&&r(Number(e.target.value))},onBlur:()=>a(aL(t))}),s?(0,Q.jsx)(`p`,{id:l,className:`order-last basis-full text-xs text-destructive`,children:c}):null]})}var sL=[{minutes:void 0,label:`No limit`},{minutes:30,label:`30 minutes`},{minutes:120,label:`2 hours`},{minutes:360,label:`6 hours`},{minutes:1440,label:`1 day`},{minutes:10080,label:`7 days`}],cL=`none`,lL=e=>String(e).padStart(2,`0`);function uL(e,t=Date.now()){let n=fF(t,e)??fF(t,`UTC`),r=new Date(Date.UTC(n.year,n.month-1,n.day+1));return`${r.getUTCFullYear()}-${lL(r.getUTCMonth()+1)}-${lL(r.getUTCDate())}T09:00`}function dL(){let e=typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[];return e.includes(`UTC`)?e:[`UTC`,...e]}function fL({value:e,stored:t,onChange:n}){let r=t=>n({...e,...t}),i=e.at?jF(e.at):null,o=e.at?.slice(0,10)??``,s=i?.hour??9,c=i?.minute??0,l=(e,t,n)=>r({at:`${e}T${lL(t)}:${lL(n)}`}),u=(0,Z.useRef)(null),d=(0,Z.useId)(),f=AF(e),p=!(t?.type===`once`&&t.at===e.at&&t.timeZone===e.timeZone)&&f!==null&&f<=Date.now();(0,Z.useEffect)(()=>{u.current?.setCustomValidity(p?TF:``)},[p]);let m=XF(e);return(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-4 gap-y-3`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(Lm,{htmlFor:`automation-once-date`,children:`Date`}),(0,Q.jsx)(Im,{ref:u,id:`automation-once-date`,type:`date`,className:`w-44 max-w-full`,value:o,"aria-invalid":p||void 0,"aria-describedby":p?d:void 0,onChange:e=>{/^\d{4}-\d{2}-\d{2}$/.test(e.target.value)&&l(e.target.value,s,c)},required:!0})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,Q.jsx)(oL,{label:`Hour`,value:s,max:23,onCommit:e=>l(o,e,c)}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,Q.jsx)(oL,{label:`Minute`,value:c,max:59,onCommit:e=>l(o,s,e)})]})]}),p?(0,Q.jsx)(`p`,{id:d,className:`text-xs text-destructive`,children:TF}):null,(0,Q.jsx)(mL,{value:e.timeZone??``,onCommit:e=>r({timeZone:e})}),(0,Q.jsx)(hL,{value:e.latestStartMinutes,onChange:t=>n(pL(e,t))}),m?(0,Q.jsx)(`p`,{className:`text-sm break-words`,children:`Runs once at ${m.time} on ${m.date} (${e.timeZone}). ${m.note?`${m.note} `:``}${a(`Cezarion`)} must be running then.`}):null]})}function pL(e,t){let{latestStartMinutes:n,...r}=e;return t===void 0?r:{...r,latestStartMinutes:t}}function mL({value:e,onCommit:t}){let[n,r]=(0,Z.useState)(e),i=(0,Z.useRef)(null),a=(0,Z.useId)(),o=(0,Z.useId)(),[s]=(0,Z.useState)(dL),c=n!==e||!gF(n),l=DF(n);return(0,Z.useEffect)(()=>{i.current?.setCustomValidity(c?l:``)},[c,l]),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(Lm,{htmlFor:`automation-once-zone`,children:`Time zone`}),(0,Q.jsx)(Im,{ref:i,id:`automation-once-zone`,list:a,autoComplete:`off`,spellCheck:!1,className:`w-full sm:w-72`,value:n,"aria-invalid":c||void 0,"aria-describedby":c?o:void 0,onChange:e=>{r(e.target.value),gF(e.target.value)&&t(e.target.value)}}),(0,Q.jsx)(`datalist`,{id:a,children:s.map(e=>(0,Q.jsx)(`option`,{value:e},e))}),c?(0,Q.jsx)(`p`,{id:o,className:`text-xs break-words text-destructive`,children:l}):null]})}function hL({value:e,onChange:t}){let n=sL.some(t=>t.minutes===e)||e===void 0?sL:[...sL,{minutes:e,label:`${e} minutes`}];return(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(Lm,{htmlFor:`automation-once-latest`,children:`Latest start`}),(0,Q.jsxs)(pI,{value:e===void 0?cL:String(e),onValueChange:e=>t(e===cL?void 0:Number(e)),children:[(0,Q.jsx)(hI,{id:`automation-once-latest`,className:`w-full sm:w-48`,"aria-label":`Latest start`,children:(0,Q.jsx)(mI,{})}),(0,Q.jsx)(gI,{children:n.map(e=>(0,Q.jsx)(_I,{value:e.minutes===void 0?cL:String(e.minutes),children:e.label},e.label))})]}),(0,Q.jsxs)(`p`,{className:`text-xs break-words text-muted-foreground`,children:[`If `,a(`Cezarion`),` was not running at the time, it still starts the task this long afterwards; later, the schedule is marked missed.`]})]})}var gL=[{type:`daily`,label:`Every day`},{type:`weekdays`,label:`Weekdays`},{type:`weekly`,label:`Weekly`},{type:`hours`,label:`Every N hours`},{type:`once`,label:`Once`}];function _L({value:e,stored:t,onChange:n,timeZone:r}){let i=t=>n({...e,...t}),a=t=>i(t===`once`?{type:t,at:e.at??uL(r),timeZone:e.timeZone??r}:{type:t});return(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Q.jsx)(`div`,{role:`group`,"aria-label":`Repeat`,className:`flex flex-wrap gap-2`,children:gL.map(t=>(0,Q.jsx)(XI,{pressed:e.type===t.type,onClick:()=>a(t.type),children:t.label},t.type))}),e.type===`once`?(0,Q.jsx)(fL,{value:e,stored:t,onChange:n}):null,e.type===`weekly`?(0,Q.jsx)(`div`,{role:`group`,"aria-label":`Day of the week`,className:`flex flex-wrap gap-2`,children:yF.map((t,n)=>(0,Q.jsx)(XI,{pressed:e.day===n+1,onClick:()=>i({day:n+1}),children:t},t))}):null,e.type===`once`?null:e.type===`hours`?(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(Lm,{htmlFor:`automation-every`,children:`Run every`}),(0,Q.jsxs)(pI,{value:String(e.every),onValueChange:e=>i({every:Number(e)}),children:[(0,Q.jsx)(hI,{id:`automation-every`,className:`w-full sm:w-48`,"aria-label":`Run every`,children:(0,Q.jsx)(mI,{})}),(0,Q.jsx)(gI,{children:vF.map(e=>(0,Q.jsx)(_I,{value:String(e),children:e===1?`hour`:`${e} hours`},e))})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Counted from midnight, so “every 6 hours” runs at 00:00, 06:00, 12:00 and 18:00.`})]}):(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,Q.jsx)(oL,{label:`Hour`,value:e.hour,max:23,onCommit:e=>i({hour:e})}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,Q.jsx)(oL,{label:`Minute`,value:e.minute,max:59,onCommit:e=>i({minute:e})}),(0,Q.jsx)(`span`,{className:`text-sm break-all text-muted-foreground`,children:r})]}),e.type===`once`?null:(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Cron: `,(0,Q.jsx)(`code`,{className:`font-mono text-foreground`,children:RF(e)})]})]})}var vL=40*864e5,yL=5;function bL({schedule:e,timeZone:t,now:n=Date.now()}){if(e.type===`once`)return(0,Q.jsx)(xL,{schedule:e,now:n});let r=BF(e,n+1,n+vL,t,yL);return(0,Q.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,className:`rounded-xl border bg-card p-4`,children:[(0,Q.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-3 text-[15px] font-medium`,children:`Next 5 runs`}),r.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs in the next 40 days.`}):(0,Q.jsx)(`ol`,{"aria-label":`Next 5 runs`,className:`grid gap-1.5 text-sm`,children:r.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-baseline justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`font-medium tabular-nums`,children:WF(new Date(e).toISOString(),t)}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:VF(n,e)})]},e))}),(0,Q.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Times are in `,t,`, the zone this `,a(`cezar`),` runs in.`]})]})}function xL({schedule:e,now:t}){let n=AF(e),r=XF(e);return(0,Q.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,className:`rounded-xl border bg-card p-4`,children:[(0,Q.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-3 text-[15px] font-medium`,children:`Runs once`}),n===null||!r?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pick a date, a time and a time zone.`}):(0,Q.jsxs)(`p`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium tabular-nums`,children:`${r.date} ${r.time}`}),n>t?(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:VF(t,n)}):null]}),r?.note?(0,Q.jsx)(`p`,{className:`mt-2 text-sm break-words`,children:r.note}):null,n!==null&&n<=t?(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-destructive`,children:`The due time has passed.`}):null,(0,Q.jsx)(`p`,{className:`mt-3 text-xs break-words text-muted-foreground`,children:`Times are in ${e.timeZone??`UTC`}. ${a(`Cezarion`)} must be running then; afterwards the schedule is archived with its task.`})]})}var SL={schedule:`On a schedule`,github:`When GitHub changes`};function CL(e){return/time zone|due time/i.test(e)?`when`:/placeholder|prompt|workflow|runner|model|task|autonomous/i.test(e)?`run`:/\bname\b/i.test(e)?`name`:/schedule|github|event|filter|label|interval|remote|forge|lookback|records?|hour|minute|poll|kind|archived/i.test(e)?`when`:`form`}function wL({title:e,failure:t,section:n,children:r}){return(0,Q.jsxs)(`fieldset`,{className:`grid min-w-0 gap-4 rounded-xl border p-5 max-md:p-4!`,children:[(0,Q.jsx)(`legend`,{className:`px-0`,children:e}),r,t?.section===n&&!t.conflict?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:t.message}):null]})}function TL({draft:e,patch:t,forge:n,automation:r}){return(0,Q.jsx)(Q.Fragment,{children:r?(0,Q.jsxs)(`p`,{className:`text-sm`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Trigger · `}),SL[e.kind]]}):(0,Q.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,Q.jsx)(hP,{slot:`automation-kind`,label:`Trigger`,size:`touch`,value:e.kind,onChange:e=>t({kind:e}),options:[{value:`schedule`,label:SL.schedule},{value:`github`,label:SL.github,disabled:!n.available,...n.available?{}:{title:n.reason??`GitHub is unavailable`}}]}),n.available?null:(0,Q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`GitHub unavailable · ${n.reason??`no GitHub access`}`})]})})}function EL({draft:e,patch:t,forge:n,timeZone:r,automation:i}){return e.kind===`schedule`?(0,Q.jsx)(_L,{value:e.schedule,stored:i?.schedule,onChange:e=>t({schedule:e}),timeZone:r}):(0,Q.jsx)(iL,{draft:e,onChange:t,...n.available?{}:{disabledReason:n.reason??`no GitHub access`}})}function DL({draft:e,patch:t,saving:n,automation:r}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(Lm,{htmlFor:`automation-prompt`,children:`Prompt`}),(0,Q.jsx)(pC,{id:`automation-prompt`,value:e.prompt,onChange:e=>t({prompt:e.target.value}),rows:4,required:!0}),(0,Q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:e.kind===`schedule`?(0,Q.jsxs)(Q.Fragment,{children:[`Available: `,`{{date}}`,` `,`{{time}}`,` `,`{{project}}`,` `,`{{automation}}`,`. A run-context block is appended automatically.`]}):(0,Q.jsxs)(Q.Fragment,{children:[`Available: `,`{{github.number}}`,` `,`{{github.title}}`,` `,`{{github.url}}`,` `,`{{github.labels}}`,`. GitHub content is appended as untrusted context.`]})})]}),(0,Q.jsx)(AL,{draft:e,patch:t}),(0,Q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,Q.jsx)(Um,{"aria-label":`Autonomous`,checked:e.autonomous,onCheckedChange:e=>t({autonomous:e})}),(0,Q.jsxs)(`span`,{children:[`Autonomous `,(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`· runs without waiting for answers`})]})]}),(0,Q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`Each run is an ordinary task in its own worktree, queued behind the parallel cap.`}),(0,Q.jsx)(nk,{archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,onChange:t,disabled:n}),(0,Q.jsx)(ik,{allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging,onChange:t,disabled:n}),r?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`These settings apply to future tasks. Existing tasks keep their settings.`}):null]})}function OL({draft:e,patch:t,automation:n}){let r=e.kind===`schedule`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,Q.jsx)(Um,{"aria-label":n?`Enabled`:`Enable after saving`,checked:e.enabled,onCheckedChange:e=>t({enabled:e})}),(0,Q.jsx)(`span`,{children:n?`Enabled`:`Enable after saving`})]}),(0,Q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:r&&e.schedule.type===`once`?`It runs once at the time set above, then moves to Archived with its task.`:r?`The first run is the next occurrence shown beside the schedule.`:nL(e.filters.includeExisting)})]})}function kL({automation:e,forge:t,timeZone:n,onSaved:r,onReload:i}){let[a,o]=(0,Z.useState)(()=>NI(e)),[s,c]=(0,Z.useState)(e?.revision),[l,u]=(0,Z.useState)(),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(``),y=e=>o(t=>({...t,...e})),b=async t=>{if(t.preventDefault(),d)return;let n=t.currentTarget;if(n instanceof HTMLFormElement&&!n.checkValidity()){n.reportValidity();return}f(!0),u(void 0);let i=`save`;try{if(e&&s!==void 0){let{automation:t}=await Lt(e.id,RI({...a,enabled:e.enabled},s));c(t.revision),a.enabled!==e.enabled&&(i=`enable`,await Ft(e.id,a.enabled))}else await zt(LI(a));r()}catch(t){let n=t instanceof Error?t.message:String(t);i===`save`&&e&&t instanceof it&&t.status===409&&/revision conflict/i.test(n)?u({section:`form`,message:`Edited elsewhere — reload to see the latest version`,conflict:!0}):u({section:i===`enable`?`enable`:CL(n),message:n})}finally{f(!1)}},x=async()=>{if(!(!e||h)){g(!0),v(``);try{await se(e.id),r()}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}}},S=e?`Save changes`:a.enabled?`Save and enable`:`Save paused`,C=a.kind===`schedule`;return(0,Q.jsx)(bI,{title:e?`Edit automation`:`New automation`,subtitle:`Define when it runs and the ordinary task it launches.`,children:(0,Q.jsxs)(`form`,{className:`automation-editor grid min-w-0 gap-5 md:grid-cols-[minmax(0,1fr)_320px] md:items-start`,onSubmit:b,children:[(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[(0,Q.jsx)(wL,{title:`Name`,section:`name`,failure:l,children:(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(Lm,{htmlFor:`automation-name`,children:`Name`}),(0,Q.jsx)(Im,{id:`automation-name`,value:a.name,onChange:e=>y({name:e.target.value}),required:!0})]})}),(0,Q.jsxs)(wL,{title:`When`,section:`when`,failure:l,children:[(0,Q.jsx)(TL,{draft:a,patch:y,forge:t,automation:e}),(0,Q.jsx)(EL,{draft:a,patch:y,forge:t,timeZone:n,automation:e})]}),(0,Q.jsx)(wL,{title:`What to run`,section:`run`,failure:l,children:(0,Q.jsx)(DL,{draft:a,patch:y,saving:d,automation:e})}),(0,Q.jsx)(wL,{title:`Enable`,section:`enable`,failure:l,children:(0,Q.jsx)(OL,{draft:a,patch:y,automation:e})}),l?.section===`form`?(0,Q.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-3 text-sm text-destructive`,children:[(0,Q.jsx)(`span`,{className:`break-words`,children:l.message}),l.conflict&&i?(0,Q.jsx)(E,{type:`button`,variant:`outline`,onClick:i,children:`Reload`}):null]}):null,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(E,{type:`submit`,disabled:d,children:d?`Saving…`:S}),(0,Q.jsx)(E,{type:`button`,variant:`outline`,asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations`,children:`Cancel`})})]}),e?(0,Q.jsxs)(`div`,{className:`grid justify-items-start gap-2 border-t pt-4`,children:[p?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? It will stop running and cannot be restored.`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(E,{type:`button`,variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:h,onClick:()=>void x(),children:`Delete automation`}),(0,Q.jsx)(E,{type:`button`,variant:`outline`,disabled:h,onClick:()=>{m(!1),v(``)},children:`Keep`})]})]}):(0,Q.jsx)(E,{type:`button`,variant:`outline`,"data-action":`automation-delete`,onClick:()=>m(!0),children:`Delete`}),_?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:_}):null]}):null]}),(0,Q.jsxs)(`aside`,{className:`min-w-0 md:sticky md:top-4`,children:[C?(0,Q.jsx)(bL,{schedule:a.schedule,timeZone:n}):(0,Q.jsxs)(`section`,{className:`rounded-xl border bg-card p-4`,children:[(0,Q.jsx)(`h2`,{className:`mb-2 text-[15px] font-medium`,children:`How it polls`}),(0,Q.jsx)(`p`,{className:`text-sm break-words text-muted-foreground`,children:rL(a)})]}),(0,Q.jsx)(YI,{draft:a})]})]})})}function AL({draft:e,patch:t}){let n=wn(),r=sn(),i=$n(),a=e.runner??i.data?.defaultRunner??`claude`,o=xr(a),s=[...new Set([...(n.data?.workflows??[]).map(e=>e.name),...e.workflow?[e.workflow]:[]])],c=[...new Set([...Vt(r.data),...e.runner?[e.runner]:[]])],l=zs(a,o.data,[e.model]),u=l.find(t=>t.id===(e.model??``))?.label??e.model??`auto`,d=e=>(0,Q.jsx)(e,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`});return(0,Q.jsx)(Zs,{children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(ic,{slot:`automation-workflow-pill`,icon:d(Zi),fieldLabel:!0,ariaLabel:`Workflow`,label:e.workflow??`inline steps`,value:e.workflow??``,disabled:e.workflow===void 0,disabledHint:`This automation carries its own steps.`,options:s.map(e=>({value:e,label:e})),onPick:e=>t({workflow:e})}),(0,Q.jsx)(ic,{slot:`automation-runner-pill`,icon:d(la),fieldLabel:!0,ariaLabel:`Runner`,label:e.runner??`default`,value:e.runner??``,options:[{value:``,label:`default`,desc:`The project’s default runner`},...c.map(e=>({value:e,label:Us.find(t=>t.id===e)?.label??e}))],onPick:e=>{t({runner:e||void 0,model:void 0})}}),(0,Q.jsx)(ic,{slot:`automation-model-pill`,icon:d(Gi),fieldLabel:!0,ariaLabel:`Model`,label:u,value:e.model??``,options:l.map(e=>({value:e.id,label:e.label,desc:e.desc})),onPick:e=>t({model:e||void 0})})]})})}function jL({data:e,error:t,refresh:n,archived:r=!1,onArchivedChange:i}){let[o,s]=(0,Z.useState)({}),[c,l]=(0,Z.useState)({}),u=(e,t)=>s(n=>{let{[e]:r,...i}=n;return t?{...i,[e]:t}:i}),d=async(e,t)=>{l(t=>({...t,[e]:!0}));try{await t()}catch(t){u(e,{text:t instanceof Error?t.message:String(t),tone:`error`})}finally{l(t=>({...t,[e]:!1}))}},f=e=>d(e.id,async()=>{u(e.id,{text:`Starting…`,tone:`info`});let{runId:t}=await bt(e.id);u(e.id,{text:`Started task`,tone:`info`,runId:t}),n()}),p=e=>d(e.id,async()=>{u(e.id,void 0),await Ft(e.id,!e.enabled),await n()}),m=e=>d(e.id,async()=>{u(e.id,void 0),await Mt(e.id),await n()}),h=e=>d(e.id,async()=>{u(e.id,{text:`Checking…`,tone:`info`});let{checkId:t}=await yt(e.id,`preview`);for(let r=0;r<60;r+=1){let r=await Le(t);if(r.status===`complete`){u(e.id,{text:`${r.matches??0} filter match${r.matches===1?``:`es`} found; no tasks launched. Counts can include closed items and previously processed events.`,tone:`info`}),n();return}if(r.status===`error`)throw Error(r.error??`Preview failed`);await new Promise(e=>setTimeout(e,500))}throw Error(`Preview is still running`)});return(0,Q.jsx)(bI,{title:`Automations`,subtitle:`Schedules and GitHub checks run while ${a(`Cezarion`)} is open.`,action:(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations/new`,children:`New automation`})}),children:t&&!e?(0,Q.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,Q.jsx)(xI,{text:t}),(0,Q.jsx)(E,{variant:`outline`,onClick:()=>void n(),children:`Retry`})]}):e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ML,{data:e}),i?(0,Q.jsx)(`div`,{className:`mb-4 flex flex-wrap gap-2`,children:(0,Q.jsx)(XI,{pressed:r,onClick:()=>i(!r),children:`Archived`})}):null,r&&e.automations.length===0?(0,Q.jsx)(xI,{text:`No archived one-time schedules.`}):e.automations.length===0?(0,Q.jsx)(X,{icon:(0,Q.jsx)($i,{}),tone:`neutral`,title:`No automations yet`,subtitle:`Create one paused, preview it, then enable it.`,heading:`h2`,actions:(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations/new`,children:`New automation`})})}):(0,Q.jsx)(`ul`,{className:`grid gap-3`,"aria-label":`Automations`,children:e.automations.map(t=>(0,Q.jsx)(UL,{automation:t,timeZone:e.timeZone,note:o[t.id],busy:c[t.id]===!0,onRun:()=>void f(t),onToggle:()=>void p(t),onPreview:()=>void h(t),onCancel:()=>void m(t)},t.id))})]}):(0,Q.jsx)(xI,{text:`Loading automations…`})})}function ML({data:e}){return(0,Q.jsx)(`p`,{"data-slot":`automation-scheduler`,className:D(`mb-4 text-xs break-words`,e.scheduler.state===`scheduled`?`text-success`:`text-muted-foreground`),children:`Scheduler ${e.scheduler.state===`scheduled`?`running`:`idle`} · GitHub ${e.available?`available`:`unavailable`}${e.reason?` · ${e.reason}`:``} · ${e.timeZone}`})}function NL(e){return e.kind===`schedule`&&e.schedule?FF(e.schedule):`on ${(e.events??[]).join(`, `)} · every ${Math.round((e.intervalSeconds??300)/60)} min`}var PL={waiting:{label:`Waiting`,dot:`success`},paused:{label:`Paused`,dot:`neutral`},failed:{label:`Failed`,dot:`danger`},missed:{label:`Missed`,dot:`pending`},archived:{label:`Archived`,dot:`neutral`}};function FL(e){if(e.schedule?.type===`once`)return PL[e.onceStatus??(e.enabled?`waiting`:`paused`)]}function IL({automation:e,badge:t}){return(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`h2`,{className:`flex items-center gap-2 font-semibold break-words`,children:[(0,Q.jsx)(e.kind===`schedule`?Vi:Mi,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),e.name]}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[13px] break-words text-muted-foreground`,children:NL(e)})]}),t?(0,Q.jsx)(KM,{dot:t.dot,children:t.label}):(0,Q.jsx)(KM,{dot:e.enabled?`success`:`neutral`,children:e.enabled?`Enabled`:`Paused`})]})}function LL({automation:e,archive:t}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`mt-3 text-sm break-words`,children:[t.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`,t.runId?(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsx)(Y,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${t.runId}`,children:`Open task`})]}):null]}),(0,Q.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:(0,Q.jsx)(E,{variant:`outline`,asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations/${e.id}`,children:`Details`})})})]})}function RL({automation:e,timeZone:t}){let n=e.kind===`schedule`,r=e.enabled&&n?e.nextRunAt:void 0;return(0,Q.jsx)(`p`,{className:`mt-3 text-sm`,children:!n&&e.enabled?(0,Q.jsx)(`span`,{children:`continuous`}):r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{children:`Next run: ${WF(r,t)}`}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:` · ${VF(Date.now(),Date.parse(r))}`})]}):(0,Q.jsx)(`span`,{children:`Next run: —`})})}function zL({automation:e,timeZone:t}){let n=e.enabled?cI(e.state):void 0;return n?(0,Q.jsxs)(`p`,{role:`alert`,"data-slot":`automation-failing`,className:`mt-3 text-sm break-words text-destructive`,children:[`The last ${n.consecutiveFailures} checks failed: ${n.lastError}`,n.retryAt?(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:` · Next try ${WF(n.retryAt,t)}`}):null]}):null}function BL({automation:e,busy:t,confirmingCancel:n,cancelRef:r,onToggle:i,onRun:a,onPreview:o,onOpenCancel:s}){let c=e.kind===`schedule`,l=e.schedule?.type===`once`;return(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,Q.jsx)(E,{variant:`outline`,asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations/${e.id}`,children:`Edit`})}),(0,Q.jsx)(E,{variant:`outline`,asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations/${e.id}/log`,children:`Execution log`})}),(0,Q.jsx)(E,{variant:`outline`,"data-action":`automation-toggle`,disabled:t,onClick:i,children:e.enabled?`Pause`:`Enable`}),c?(0,Q.jsx)(E,{variant:`outline`,"data-action":`automation-run`,disabled:t,onClick:a,children:`Run now`}):(0,Q.jsx)(E,{variant:`outline`,"data-action":`automation-preview`,disabled:t,onClick:o,children:`Test filter`}),l&&!n?(0,Q.jsx)(E,{variant:`outline`,ref:r,"data-action":`automation-cancel`,disabled:t,onClick:s,children:`Cancel`}):null]})}function VL({automation:e,busy:t,keepRef:n,onConfirm:r,onKeep:i}){return(0,Q.jsxs)(`div`,{className:`mt-3 grid justify-items-start gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-sm break-words`,children:`Cancel “${e.name}”? It will never run, and it moves to Archived.`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(E,{variant:`danger-ghost`,"data-action":`automation-cancel-confirm`,disabled:t,onClick:r,children:`Cancel schedule`}),(0,Q.jsx)(E,{ref:n,variant:`outline`,disabled:t,onClick:i,children:`Keep`})]})]})}function HL({note:e}){return(0,Q.jsxs)(`p`,{role:e.tone===`error`?`alert`:`status`,className:D(`mt-3 text-sm break-words`,e.tone===`error`?`text-destructive`:`text-muted-foreground`),children:[e.text,e.runId?(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsx)(Y,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`})]}):null]})}function UL({automation:e,timeZone:t,note:n,busy:r,onRun:i,onToggle:a,onPreview:o,onCancel:s}){let[c,l]=(0,Z.useState)(!1),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),f=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let e=f.current===`keep`?d.current:f.current===`cancel`?u.current:null;f.current=null,e?.focus()},[c]);let p=()=>{f.current=`keep`,l(!0)},m=()=>{f.current=`cancel`,l(!1)},h=e.archived;return(0,Q.jsxs)(`li`,{"data-slot":`automation-card`,"data-kind":e.kind,className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,Q.jsx)(IL,{automation:e,badge:FL(e)}),h?(0,Q.jsx)(LL,{automation:e,archive:h}):null,h?null:(0,Q.jsx)(RL,{automation:e,timeZone:t}),h?null:(0,Q.jsx)(zL,{automation:e,timeZone:t}),h?null:(0,Q.jsx)(BL,{automation:e,busy:r,confirmingCancel:c,cancelRef:u,onToggle:a,onRun:i,onPreview:o,onOpenCancel:p}),e.schedule?.type===`once`&&!h&&c?(0,Q.jsx)(VL,{automation:e,busy:r,keepRef:d,onConfirm:()=>{l(!1),s()},onKeep:m}):null,n?(0,Q.jsx)(HL,{note:n}):null,(0,Q.jsx)(AI,{automationId:e.id,automationName:e.name,timeZone:t})]})}function WL(e){let t=Cs(),n=js(),[r,i]=(0,Z.useState)(),[a,o]=(0,Z.useState)(``),s=(0,Z.useCallback)(t=>ye({signal:t,...e?{archived:e}:{}}).then(e=>{t?.aborted||(i(e),o(``))}).catch(e=>{t?.aborted||o(String(e))}),[e]);return(0,Z.useEffect)(()=>{n&&s()},[n,s]),(0,Z.useEffect)(()=>oe(async e=>{n&&await s(e)}),[n,s]),(0,Z.useEffect)(()=>pl((e,n)=>{if(e!==`automation-change`)return;let r=n;typeof r.project==`string`&&(t===null||r.project===t)&&s()}),[t,s]),{data:r,error:a,refresh:s}}function GL({mode:e=`list`}){let{automationId:t}=r(),n=_s(),[i,o]=(0,Z.useState)(!1),{data:s,error:c,refresh:l}=WL(e===`list`?i?`only`:void 0:`include`),[u,d]=(0,Z.useState)(0),f=Hs();if(f===`unknown`)return(0,Q.jsx)(`div`,{"data-route":`automations`,className:`task-flow-page flex min-h-full flex-col`,children:(0,Q.jsx)(xI,{text:`Loading automations…`})});if(f===`unavailable`)return(0,Q.jsx)(`div`,{"data-route":`automations`,className:`task-flow-page flex min-h-full flex-col`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)($i,{}),tone:`neutral`,title:`Automations are off`,subtitle:`This server does not run schedules, poll GitHub or launch tasks from them. Unset CEZ_AUTOMATIONS or set it to 1 and restart ${a(`cezar`)} to turn automations on.`,heading:`h2`})});let p=()=>{n(`/automations`),l()},m=s?.automations.find(e=>e.id===t);if(e===`list`)return(0,Q.jsx)(jL,{data:s,error:c,refresh:l,archived:i,onArchivedChange:o});if(!s)return c?(0,Q.jsx)(bI,{title:`Automations`,subtitle:`Could not load automations.`,children:(0,Q.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,Q.jsx)(xI,{text:c}),(0,Q.jsx)(E,{variant:`outline`,onClick:()=>void l(),children:`Retry`})]})}):(0,Q.jsx)(`div`,{"data-route":`automations`,className:`task-flow-page flex min-h-full flex-col`,children:(0,Q.jsx)(xI,{text:`Loading automations…`})});let h={available:s.available,...s.reason?{reason:s.reason}:{}};return e===`new`?(0,Q.jsx)(kL,{forge:h,timeZone:s.timeZone,onSaved:p}):e===`edit`?m?m.archived?(0,Q.jsx)(jI,{automation:m,timeZone:s.timeZone,onDeleted:p}):(0,Q.jsx)(kL,{automation:m,forge:h,timeZone:s.timeZone,onSaved:p,onReload:()=>void l().then(()=>d(e=>e+1))},`${m.id}:${u}`):(0,Q.jsx)(bI,{title:`Automation not found`,subtitle:`This automation may have been removed.`,children:(0,Q.jsx)(E,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(Y,{to:`/automations`,children:`Back to automations`})})}):t?(0,Q.jsx)(kI,{automationId:t,automationName:m?.name,timeZone:s.timeZone,readOnly:!!m?.archived}):(0,Q.jsx)(xI,{text:`Automation not found.`})}function KL({health:e,projects:t,repository:n,onAction:r}){return(0,Q.jsxs)(`section`,{className:`space-y-4 rounded-xl border border-border bg-card p-6 max-md:p-4`,"aria-labelledby":`add-project-heading`,children:[(0,Q.jsx)(`h2`,{id:`add-project-heading`,className:`text-lg font-normal leading-[1.5]`,children:`Add project`}),(0,Q.jsx)(`p`,{className:`text-[13px] leading-[1.5] text-muted-foreground`,children:`Start a new repository, open an existing local folder, or clone a GitHub repository.`}),(0,Q.jsxs)(`dl`,{className:`space-y-4 text-[13px] leading-[1.5] text-muted-foreground`,children:[e.data?.repoRoot?(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-x-3`,children:[(0,Q.jsx)(`dt`,{children:`Local folder`}),(0,Q.jsx)(`dd`,{className:`min-w-0 break-all`,children:e.data.repo?.root??e.data.repoRoot})]}):null,n?(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-x-3`,children:[(0,Q.jsx)(`dt`,{children:`Repository`}),(0,Q.jsx)(`dd`,{className:`min-w-0 break-all`,children:n.replace(/^https:\/\//,``)})]}):null,t.data?.projectsDir?(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-x-3`,children:[(0,Q.jsx)(`dt`,{children:`Checkout folder`}),(0,Q.jsx)(`dd`,{className:`min-w-0 break-all`,children:t.data.projectsDir})]}):null]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Q.jsx)(E,{variant:`outline`,className:`h-10 rounded-lg px-[15px] text-xs font-normal leading-[18px]`,"data-action":`new-project`,onClick:()=>r(`new`),children:`New project`}),(0,Q.jsx)(E,{variant:`outline`,className:`h-10 rounded-lg px-[15px] text-xs font-normal leading-[18px]`,onClick:()=>r(`local`),children:`Open local folder`}),(0,Q.jsx)(E,{variant:`outline`,className:`h-10 rounded-lg px-[15px] text-xs font-normal leading-[18px]`,onClick:()=>r(`clone`),children:`Clone from GitHub`})]})]})}function qL({health:e,copying:t,onCopy:n}){return(0,Q.jsxs)(`section`,{className:`space-y-4 rounded-xl border border-border bg-card p-6 max-md:p-4`,"aria-labelledby":`tools-heading`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`h2`,{id:`tools-heading`,className:`text-lg font-normal leading-[1.5]`,children:`Tools diagnostics`}),(0,Q.jsx)(Y,{to:hx,"data-slot":`tools-settings`,className:gx,children:`Tool settings ›`})]}),(0,Q.jsx)(`p`,{className:`text-[13px] leading-[1.5] text-muted-foreground`,children:`Check the tools available to this local workspace.`}),e.isError?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:`Could not refresh tool diagnostics. Recheck to retry.`}):null,!e.data&&!e.isError?(0,Q.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Checking installed tools…`}):null,e.data?(0,Q.jsx)(`dl`,{className:`space-y-4 text-[13px] leading-[1.5] text-muted-foreground`,children:e.data.checks.map(e=>{let t=mx(e);return(0,Q.jsxs)(`div`,{"data-slot":`tool-row`,"data-tool":e.name,"data-available":e.available,className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,Q.jsxs)(`dt`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{tone:fx(e)}),(0,Q.jsx)(`span`,{className:`font-mono text-[13px] font-medium text-foreground`,children:e.name})]}),(0,Q.jsxs)(`dd`,{className:`flex min-w-0 flex-1 items-center gap-x-3 text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 break-words`,children:[px(e),e.version?` · ${e.version}`:``]}),e.available?null:(0,Q.jsx)(Y,{to:hx,"data-slot":`tool-setup`,className:`${gx} ml-auto`,children:`Set up ›`})]}),t?(0,Q.jsx)(`dd`,{"data-slot":`tool-hint`,className:`basis-full min-w-0 break-words pl-[15px] text-xs leading-snug text-muted-foreground`,children:t}):null]},e.name)})}):null,e.data?.checks.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No tool diagnostics reported by this server.`}):null,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Q.jsx)(E,{variant:`outline`,className:`h-10 rounded-lg px-[15px] text-xs font-normal leading-[18px]`,disabled:e.isFetching,onClick:()=>void e.refetch(),children:e.isFetching?`Checking tools…`:`Recheck tools`}),(0,Q.jsx)(E,{variant:`outline`,className:`h-10 rounded-lg px-[15px] text-xs font-normal leading-[18px]`,disabled:!e.data||t,onClick:()=>void n(),children:t?`Copying…`:`Copy diagnostics`})]})]})}function JL(){let e=On(),t=An(),n=vn(e.data?.repo?.remote),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{"data-route":`workspace-tools`,className:`w-full space-y-[22px] px-9 py-9 max-md:px-[18px] max-md:py-6`,children:[(0,Q.jsx)(`h1`,{className:`text-[28px] font-normal leading-[1.5] max-md:text-[24px]`,children:`Workspace tools`}),(0,Q.jsx)(KL,{health:e,projects:t,repository:n,onAction:i}),(0,Q.jsx)(qL,{health:e,copying:a,onCopy:async()=>{if(!(!e.data||a)){o(!0);try{await navigator.clipboard.writeText(JSON.stringify({version:e.data.version,checks:e.data.checks},null,2)),G(`Diagnostics copied`)}catch{G(`Could not copy diagnostics. Please try again.`,{tone:`danger`})}finally{o(!1)}}}}),r===`new`?(0,Q.jsx)(nh,{open:!0,onOpenChange:e=>{e||i(null)}}):null,r===`local`?(0,Q.jsx)(Pm,{open:!0,onOpenChange:e=>{e||i(null)}}):null,r===`clone`?(0,Q.jsx)(zm,{open:!0,onOpenChange:e=>{e||i(null)}}):null]})}var YL=(0,Z.lazy)(()=>U(()=>import(`./task-thread-BlVvC3Mo.js`).then(e=>({default:e.TaskThreadRoute})),__vite__mapDeps([34,5,7,8,9,28,10,11,27,29,30,31,12,35,13,23,21,22,24,36,37,20,16,17,38,39,40,41,25,42,43,44,19,18,45,46,33,47,48,49]))),XL=(0,Z.lazy)(()=>U(()=>import(`./task-changes-jjPRV2ul.js`).then(e=>({default:e.TaskChangesRoute})),__vite__mapDeps([50,5,7,8,9,10,11,27,28,29,30,31,12,35,13,23,21,22,24,36,37,20,16,17,38,39,40,41,25,42,43,51,52,44,33,53,54,55,47]))),ZL=(0,Z.lazy)(()=>U(()=>import(`./task-files-Ddk24Oe-.js`).then(e=>({default:e.TaskFilesRoute})),__vite__mapDeps([56,5,7,8,9,10,11,27,28,29,30,31,12,22,13,37,35,23,21,24,36,20,16,17,38,39,40,41,25,42,43,32,33]))),QL=(0,Z.lazy)(async()=>{let{TaskReportRoute:e}=await U(async()=>{let{TaskReportRoute:e}=await import(`./report-reader-BRw4X5KH.js`);return{TaskReportRoute:e}},__vite__mapDeps([26,5,7,8,9,10,11,27,28,29,30,31,12,22,32,13,33]));return{default:e}}),$L=(0,Z.lazy)(()=>U(()=>import(`./task-commits-CxJKFd3j.js`).then(e=>({default:e.TaskCommitsRoute})),__vite__mapDeps([57,5,7,8,9,10,11,27,28,29,30,31,12,35,13,23,21,22,24,36,37,20,16,17,38,39,40,41,25,42,43,33,58,52,44,54,55,47]))),eR=(0,Z.lazy)(()=>U(()=>import(`./task-github-item-D49mwA5b.js`).then(e=>({default:e.TaskGithubItemRoute})),__vite__mapDeps([59,7,5,8,9,10,11,27,28,29,30,31,12,35,13,23,21,22,24,36,37,20,16,17,38,39,40,41,25,42,43,33,60,44,18,61,45,46,62,54,55,47,63]))),tR=(0,Z.lazy)(()=>U(()=>import(`./repo-git-cpVcsnni.js`).then(e=>({default:e.RepoGitRoute})),__vite__mapDeps([64,5,7,8,9,10,11,27,28,29,30,31,12,35,13,23,21,22,24,36,65,52,44,51,16,17,39,40,25,33,53,54,55,47,58,66]))),nR=(0,Z.lazy)(()=>U(()=>import(`./github-DBRyp_7V.js`).then(e=>({default:e.GithubRoute})),__vite__mapDeps([67,5,7,8,9,10,11,27,28,29,30,31,12,35,13,23,21,22,24,36,65,17,61,25,45,40,41,46,62,33,60,44,38,18,54,55,47,42,63]))),rR=(0,Z.lazy)(()=>U(()=>import(`./reports-BK0543bM.js`).then(e=>({default:e.ReportsRoute})),__vite__mapDeps([68,5,7,8,9,10,11,29,31,25,48,69]))),iR=(0,Z.lazy)(()=>U(()=>import(`./workflows-BW6W8C0F.js`).then(e=>({default:e.WorkflowsRoute})),__vite__mapDeps([70,5,7,8,9,10,11,27,28,29,30,31,12,22,21,23,24,40,41,71,62,33,72]))),aR=(0,Z.lazy)(()=>U(()=>import(`./activity-route-CWdkKOcU.js`).then(e=>({default:e.ProjectActivityRoute})),__vite__mapDeps([73,5,7,8,9,14,13,74,28,10,11,30,31,15,44,38,25,36,75]))),oR=(0,Z.lazy)(()=>U(()=>import(`./global-activity-route-8gXrkEI5.js`).then(e=>({default:e.GlobalActivityRoute})),__vite__mapDeps([76,5,7,8,9,27,28,10,11,29,30,31,12,74,13,15,44,38,25,36,75]))),sR=(0,Z.lazy)(()=>U(()=>import(`./skills-0Az8jsnI.js`).then(e=>({default:e.SkillsRoute})),__vite__mapDeps([77,5,7,8,9,10,11,27,28,29,30,31,12,22,25,62,33,72])));function cR(){let e=t();return(0,Q.jsx)(Ss,{to:{pathname:`/skills`,search:e.search,hash:e.hash},replace:!0})}function lR({sectionId:e}){let n=t();return(0,Q.jsx)(_,{to:{pathname:_j(`global`,e),search:n.search,hash:n.hash},replace:!0})}function uR(){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 dR(){let{projectId:e=``}=r(),n=t(),i=An(),a=On();if(e==="default"){let e=i.data?.bootProject??(i.isError?a.data?.bootProject:void 0);if(e!==void 0){let t=n.pathname.replace(/^\/p\/default(?=\/|$)/,``);return(0,Q.jsx)(_,{to:`/p/${encodeURIComponent(e)}${t||`/`}${n.search}${n.hash}`,replace:!0})}if(!i.isError)return(0,Q.jsx)(uR,{})}if(i.data){if(!(i.data.bootProject===e||i.data.projects.some(t=>t.id===e)))return(0,Q.jsx)(Lk,{projectId:e,registry:i.data})}else if(!i.isError)return(0,Q.jsx)(uR,{});return(0,Q.jsx)(pt,{projectId:i.data?.bootProject===e?null:e,children:(0,Q.jsx)(g,{},e)})}function fR(){let{projectId:e=``}=r();return(0,Q.jsx)(xk,{},e)}var pR=/^\/tasks\/([0-9a-f-]{36})(?=\/|$)/i;function mR(e,t){let n=e.data?.bootProject??t.data?.bootProject;return{resolved:n,settled:(e.data!==void 0||e.isError)&&(t.data!==void 0||t.isError),boot:n??`default`}}function hR(e,t,n){if(!(e.pathname===`/`&&e.search===``&&e.hash===``))return;if(t.data===void 0&&!t.isError)return(0,Q.jsx)(uR,{});let r=A_(b_(),t.data,n);if(r!==null)return(0,Q.jsx)(_,{to:r,replace:!0})}function gR(e,t,n,r,i,a){if(!n)return null;let o=i.data?.runs.find(t=>t.id===e)?.projectId;return o===void 0?r?a.data===void 0&&!a.isError?null:a.data?.runs.find(t=>t.id===e)?.projectId??t:t:o}function _R(e,t){let n=t.pathname===`/p`||t.pathname===`/p/`?`/`:t.pathname;return(0,Q.jsx)(_,{to:`/p/${encodeURIComponent(e)}${n}${t.search}${t.hash}`,replace:!0})}function vR(){let e=t(),n=On(),r=An(),i=pR.exec(e.pathname)?.[1]??null,a=mn(i!==null),o=a.data!==void 0||a.isError,s=a.data!==void 0&&!a.data.runs.some(e=>e.id===i),c=pn(i!==null&&s?i:``),{resolved:l,settled:u,boot:d}=mR(n,r);if(l===void 0&&!u)return(0,Q.jsx)(uR,{});let f=hR(e,r,l);if(f!==void 0)return f;let p=d;if(i!==null){let e=gR(i,d,o,s,a,c);if(e===null)return(0,Q.jsx)(uR,{});p=e}return _R(p,e)}function yR(){return(0,Q.jsxs)(d,{path:`/p/:projectId`,element:(0,Q.jsx)(dR,{}),children:[(0,Q.jsx)(d,{index:!0,element:(0,Q.jsx)(rP,{})}),(0,Q.jsx)(d,{path:`new`,element:(0,Q.jsx)(fR,{})}),(0,Q.jsx)(d,{path:`activity`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(mT,{}),children:(0,Q.jsx)(aR,{})})}),(0,Q.jsxs)(d,{path:`tasks/:id`,element:(0,Q.jsx)(UA,{}),children:[(0,Q.jsx)(d,{index:!0,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Uk,{}),children:(0,Q.jsx)(YL,{})})}),(0,Q.jsx)(d,{path:`changes`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(zk,{tab:`changes`}),children:(0,Q.jsx)(XL,{})})}),(0,Q.jsx)(d,{path:`files`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(zk,{tab:`files`}),children:(0,Q.jsx)(ZL,{})})}),(0,Q.jsx)(d,{path:`report`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{"data-route":`task-report`,children:(0,Q.jsx)(`h1`,{className:`p-4 text-sm text-soft-foreground`,children:`Loading report…`})}),children:(0,Q.jsx)(QL,{})})}),(0,Q.jsx)(d,{path:`commits`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(zk,{tab:`changes`}),children:(0,Q.jsx)($L,{})})}),(0,Q.jsx)(d,{path:`commits/:sha`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(zk,{tab:`changes`}),children:(0,Q.jsx)($L,{})})}),(0,Q.jsx)(d,{path:`issue/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Hk,{kind:`issue`}),children:(0,Q.jsx)(eR,{kind:`issue`})})}),(0,Q.jsx)(d,{path:`pr/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Hk,{kind:`pr`}),children:(0,Q.jsx)(eR,{kind:`pr`})})})]}),(0,Q.jsx)(d,{path:`git`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Fk,{}),children:(0,Q.jsx)(tR,{section:`main`,index:!0})})}),(0,Q.jsx)(d,{path:`git/commits`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Fk,{}),children:(0,Q.jsx)(tR,{section:`main`})})}),(0,Q.jsx)(d,{path:`git/commits/:sha`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Fk,{}),children:(0,Q.jsx)(tR,{section:`main`})})}),(0,Q.jsx)(d,{path:`git/not-landed`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Fk,{}),children:(0,Q.jsx)(tR,{section:`not-landed`})})}),(0,Q.jsx)(d,{path:`git/cleanup`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Fk,{}),children:(0,Q.jsx)(tR,{section:`cleanup`})})}),(0,Q.jsx)(d,{path:`git/branches`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Fk,{}),children:(0,Q.jsx)(tR,{section:`branches`})})}),(0,Q.jsx)(d,{path:`git/changes`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Fk,{}),children:(0,Q.jsx)(tR,{section:`changes`})})}),(0,Q.jsx)(d,{path:`github`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(hT,{}),children:(0,Q.jsx)(nR,{view:`issues`,index:!0})})}),(0,Q.jsx)(d,{path:`github/prs`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(hT,{}),children:(0,Q.jsx)(nR,{view:`prs`})})}),(0,Q.jsx)(d,{path:`github/issues/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(hT,{}),children:(0,Q.jsx)(nR,{view:`issues`})})}),(0,Q.jsx)(d,{path:`github/prs/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(hT,{}),children:(0,Q.jsx)(nR,{view:`prs`})})}),(0,Q.jsx)(d,{path:`github/prs/:n/changes`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(hT,{}),children:(0,Q.jsx)(nR,{view:`prs`,changes:!0})})}),(0,Q.jsx)(d,{path:`automations`,element:(0,Q.jsx)(GL,{})}),(0,Q.jsx)(d,{path:`automations/new`,element:(0,Q.jsx)(GL,{mode:`new`})}),(0,Q.jsx)(d,{path:`automations/:automationId`,element:(0,Q.jsx)(GL,{mode:`edit`})}),(0,Q.jsx)(d,{path:`automations/:automationId/log`,element:(0,Q.jsx)(GL,{mode:`log`})}),(0,Q.jsx)(d,{path:`skills`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ik,{}),children:(0,Q.jsx)(sR,{})})}),(0,Q.jsx)(d,{path:`reports`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading reports…`}),children:(0,Q.jsx)(rR,{})})}),(0,Q.jsx)(d,{path:`workflows`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Rk,{}),children:(0,Q.jsx)(iR,{})})}),(0,Q.jsx)(d,{path:`workflows/:name`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Rk,{}),children:(0,Q.jsx)(iR,{})})}),(0,Q.jsx)(d,{path:`settings`,element:(0,Q.jsx)(Cj,{})}),(0,Q.jsx)(d,{path:`settings/skills`,element:(0,Q.jsx)(cR,{})}),Qw(`project`).map(e=>(0,Q.jsx)(d,{path:`settings/${e.id}`,element:(0,Q.jsx)(Sj,{section:e,scope:`project`})},e.id)),Qw(`global`).map(e=>(0,Q.jsx)(d,{path:`settings/${e.id}`,element:(0,Q.jsx)(lR,{sectionId:e.id})},e.id)),(0,Q.jsx)(d,{path:`*`,element:(0,Q.jsx)(Nk,{})})]})}function bR(e){let t=A(j(yR()),e),n=t?.at(-1);return!t||!n||n.route.path===`*`?null:{pattern:`/${t.slice(1).map(e=>e.route.path).filter(e=>e!==void 0).join(`/`)}`.replace(/\/$/,``)||`/`,params:n.params}}function xR(){return(0,Q.jsxs)(O,{children:[yR(),(0,Q.jsx)(d,{path:`/tasks`,element:(0,Q.jsx)(YP,{})}),(0,Q.jsx)(d,{path:`/tools`,element:(0,Q.jsx)(JL,{})}),(0,Q.jsx)(d,{path:`/activity`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(mT,{}),children:(0,Q.jsx)(oR,{})})}),(0,Q.jsx)(d,{path:`/settings/global`,element:(0,Q.jsx)(_,{to:vj,replace:!0})}),(0,Q.jsx)(d,{path:`/settings/global/skills`,element:(0,Q.jsx)(_,{to:`/skills`,replace:!0})}),Qw(`global`).map(e=>(0,Q.jsx)(d,{path:_j(`global`,e.id),element:(0,Q.jsx)(Sj,{section:e,scope:`global`})},e.id)),(0,Q.jsx)(d,{path:`*`,element:(0,Q.jsx)(vR,{})})]})}function SR(){let[e]=(0,Z.useState)(eu);return(0,Z.useEffect)(()=>Dr(e),[e]),(0,Q.jsx)(nu,{children:(0,Q.jsx)(ge,{client:e,children:(0,Q.jsxs)(Ml,{children:[(0,Q.jsx)($l,{}),(0,Q.jsx)(fT,{}),(0,Q.jsx)($h,{children:(0,Q.jsx)(WC,{children:(0,Q.jsxs)(h,{children:[(0,Q.jsx)(dT,{}),(0,Q.jsx)(tu.Provider,{value:bR,children:(0,Q.jsx)(Wa,{children:(0,Q.jsx)(uT,{children:(0,Q.jsx)(xR,{})})})}),(0,Q.jsx)(Si,{})]})})})]})})})}var CR=document.querySelector(`meta[name="cez-api-base"]`)?.getAttribute(`content`);c(ne(CR,void 0,void 0));var wR=document.getElementById(`root`);if(!wR)throw Error(`${a(`cezar`)}: #root container is missing from index.html`);(0,Wc.createRoot)(wR).render((0,Q.jsx)(Z.StrictMode,{children:(0,Q.jsx)(SR,{})}));export{pC as $,od as $t,Pk as A,rb as At,ZD as B,Mg as Bt,qk as C,nb as Ct,zk as D,ab as Dt,Bk as E,Yy as Et,mO as F,Pg as Ft,UD as G,ug as Gt,vD as H,ig as Ht,fO as I,Ig as It,iD as J,uh as Jt,uD as K,dg as Kt,uO as L,Ng as Lt,hO as M,Vy as Mt,_O as N,uv as Nt,Rk as O,cb as Ot,pO as P,sv as Pt,mT as Q,Im as Qt,tO as R,Fg as Rt,Xk as S,sb as St,Hk as T,Xy as Tt,xD as U,lg as Ut,yD as V,kg as Vt,VD as W,fg as Wt,yT as X,ch as Xt,vT as Y,lh as Yt,hT as Z,Um as Zt,TA as _,au as _n,Hb as _t,CM as a,Uu as an,Qx as at,pA as b,ib as bt,GA as c,Pu as cn,Ux as ct,VA as d,bu as dn,Ax as dt,rd as en,GS as et,zA as f,pu as fn,kx as ft,yA as g,cu as gn,Mx as gt,CA as h,uu as hn,Lx as ht,GM as i,Wu as in,nS as it,gO as j,qy as jt,Fk as k,Zy as kt,qA as l,ku as ln,Gx as lt,SA as m,du as mn,Bx as mt,bN as n,Qu as nn,RS as nt,SM as o,Bu as on,Yx as ot,xA as p,fu as pn,zx as pt,fD as q,$ as qt,KM as r,Ju as rn,rS as rt,xM as s,Fu as sn,qx as st,VF as t,td as tn,WS as tt,KA as u,Tu as un,Vx as ut,dA as v,iu as vn,hb as vt,Uk as w,tb as wt,Qk as x,Qy as xt,fA as y,mb as yt,WD as z,Ag as zt};
16
+ `)[0]??``;return n.length>t?`${n.slice(0,t-1)}…`:n}function RO(e){let{task:t,steps:n,model:r,modelsLocked:i,effort:a,runner:o,runnerExplicit:s,defaultRunner:c,images:l,archiveWhenDone:u,autoMergePr:d,allowWorkers:f,allowMessaging:p}=e;return{task:t,steps:[...n],model:i?void 0:r||void 0,effort:i?void 0:a||void 0,runner:Is(o,c,s),images:l.length>0?[...l]:void 0,...Ts({archiveWhenDone:u,autoMergePr:d,allowWorkers:f,allowMessaging:p})}}function zO(e,t){return{...AO(e),...t.ref===``?{}:{text:t.ref},...t.skill===``?{}:{source:{source:`skill`,ref:t.skill}}}}function BO(e,t){let[n,r]=(0,Z.useState)(()=>zO(e,t)),i=(0,Z.useRef)(n);(0,Z.useEffect)(()=>{jO(i.current,e)},[e]);let a=(0,Z.useRef)(!1),o=(0,Z.useRef)(!0);return(0,Z.useEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]),{draft:n,update:t=>{if(!o.current||a.current)return;let n={...i.current,...t};i.current=n,jO(n,e),r(n)},clearStarted:t=>{if(kO(e)!==t)return;MO(e,t);let n=AO(e);i.current=n,o.current&&r(n)},submissionPending:a,mounted:o}}function VO(e,t){let n=wn(),r=un(),i=r.data,a=t.data?.skillUsage,o=(0,Z.useMemo)(()=>Pc(i??[],a),[i,a]),s=n.data?.workflows??[],c=r.data!==void 0&&n.data!==void 0&&!t.isPending,l=Os(e,o,s);return{skillList:o,skillUsage:a,workflowList:s,sourcesReady:c,source:l,selectedSkill:l?.source===`skill`?o.find(e=>e.name===l.ref):void 0}}function HO(e){let{uiState:t,source:n,sourcesReady:r,draftText:i,submissionPending:a,update:o}=e,s=js(),c=t.data?.promptTemplates,l=(0,Z.useMemo)(()=>Xs(Js(c),{automations:s}),[c,s]),u=ec(l,n?.source===`skill`?[n.ref]:[]),d=(0,Z.useRef)(i);d.current=i;let f=(0,Z.useRef)(``);return(0,Z.useEffect)(()=>{if(!r||a.current)return;let e=rc(d.current,f.current,u);f.current=e.applied,e.text!==d.current&&o({text:e.text})},[u,r]),l}function UO(e,t){let n=sn(),r=Vt(n.data),i=t.data?.defaultRunner,a=i??`claude`,o=r.length>0?ks(e.runner,r,a):null,s=o??a,c=n.isSuccess&&r.length>0,l=xr(s),u=t.data?.modelsLocked===!0,d=t.data?.defaultModels,f=o===null?[]:zs(o,l.data,[e.model,d?.[o]]),p=o===null?``:Bs(u?null:e.model,o,d,l.data),m=Gs(s,p,l.data);return{providers:n,runners:r,defaultRunner:i,runner:o,displayRunner:s,providersReady:c,catalog:l,modelsLocked:u,models:f,model:p,effortOptions:m,effort:u?``:lc(e.effort,m)}}function WO(e,t){let{accounts:n,repoAccount:r}=tc();return{accountChoices:n,repoAccount:r,agentProfile:n.some(n=>n.provider===e&&n.id===t)?t:null}}function GO(e){let t=(0,Z.useRef)(!1),n=(0,Z.useRef)(void 0);(0,Z.useEffect)(()=>{n.current===void 0&&(n.current=document.activeElement);let r=e&&!t.current;t.current=e,r&&(document.activeElement===document.body||document.activeElement===n.current)&&document.querySelector(`textarea[aria-label="Describe a task for the agent"]`)?.focus()},[e])}function KO(e){let t=e.workspaceConfig.data?.composerDefaults;return bO({hasGit:e.hasGit,planFirst:e.draft.planFirst,explicitAutonomous:e.draft.autonomous,explicitWorktree:e.draft.worktree,interactive:e.selectedSkill?.interactive,configuredAutonomous:t?.autonomous??t?.inheritedAutonomous??`source-dependent`,configuredWorktree:t?.worktree??t?.inheritedWorktree??!0,source:e.source?.source??`workflow`})}function qO(e){let t=An(),n=t.data?.projects??[],r=e??t.data?.bootProject,i=gO(n.find(e=>e.id===r)),[a,o]=(0,Z.useState)(!1);return{projectList:n,webhookTargets:i,notifyOn:i.length>0&&a,setNotifyChoice:o}}function JO(e){let[t,n]=(0,Z.useState)(()=>typeof window<`u`&&window.innerWidth<=767);return(0,Z.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=()=>n(window.innerWidth<=767||t.getBoundingClientRect().width<550);r();let i=typeof ResizeObserver>`u`?null:new ResizeObserver(r);return i?.observe(t),window.addEventListener(`resize`,r),()=>{i?.disconnect(),window.removeEventListener(`resize`,r)}},[]),t}function YO(e){let t=_s(),[n,r]=(0,Z.useState)(()=>e.deepLink.ref!==``);XO(e.search,t),ZO({pending:n,setPending:r,deepLink:e.deepLink,sourcesReady:e.sourcesReady,skillList:e.skillList,update:e.update})}function XO(e,t){let n=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{n.current||(n.current=!0,e.toString()!==``&&t(`/new`,{replace:!0}))},[])}function ZO(e){let{pending:t,sourcesReady:n,deepLink:r}=e;(0,Z.useEffect)(()=>{if(!t||!n)return;e.setPending(!1);let i=r.skill!==``&&!e.skillList.some(e=>e.name===r.skill)?r.skill:``;i!==``&&e.update({text:yO(r.skill,r.ref),source:null});let{message:a,tone:o}=vO(i);G(a,{tone:o}),document.querySelector(`[data-slot="composer"] button[aria-label="Start task"], [data-slot="composer"] button[aria-label="Plan task"]`)?.focus()},[t,n])}function QO(e){return e.isPending?`Checking agent providers…`:e.isError?`Provider authentication could not be verified.`:`Connect an agent provider before starting a task.`}function $O(e,t,n){Qe({lastTask:e,...e?{recentSources:Ds(t.data?.recentSources,e)}:{},...e?.source===`skill`&&t.data!==void 0?{skillUsage:Fc(t.data.skillUsage,e.ref)}:{}}).then(()=>n.invalidateQueries({queryKey:H.uiState})).catch(()=>{})}function ek(e){let t=_s(),n=L(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),{draft:l,draftProjectId:u,engine:d,mounted:f}=e,{providers:p,providersReady:m,runner:h}=d,g=(r,i)=>{e.clearStarted(i),n.invalidateQueries({queryKey:H.runs.all}),f.current&&t($s(r))};return{plan:r,setPlan:i,planning:a,starting:s,submit:async(t,r)=>{let a=kO(u);if(!m||h===null)throw Error(QO(p));if(!e.sourcesReady)throw Error(`Still loading workflows and skills — try again in a second.`);if(l.planFirst){o(!0);try{let e=await Ue(t);f.current&&i(NO(t,r,e))}finally{o(!1)}return}let s=await ae(Qs(dc({task:t,source:e.source,model:d.model,modelsLocked:d.modelsLocked,effort:d.effort,runner:h,runnerExplicit:l.runner!==null,agentProfile:e.agentProfile,defaultRunner:d.defaultRunner,images:r,worktree:e.runMode.worktree,autonomous:e.runMode.autonomous,archiveWhenDone:l.archiveWhenDone,autoMergePr:l.autoMergePr,allowWorkers:l.allowWorkers,allowMessaging:l.allowMessaging}),e.notifyOn));$O(e.source,e.uiState,n),g(s,a)},startPlanned:async()=>{if(r===null||r.steps.length===0||s||!m||h===null)return;let t=kO(u);c(!0);try{let n=await ae(Qs(RO({task:r.task,steps:r.steps,model:d.model,modelsLocked:d.modelsLocked,effort:d.effort,runner:h,runnerExplicit:l.runner!==null,defaultRunner:d.defaultRunner,images:r.images,archiveWhenDone:l.archiveWhenDone,autoMergePr:l.autoMergePr,allowWorkers:l.allowWorkers,allowMessaging:l.allowMessaging}),e.notifyOn));i(null),g(n,t)}catch(e){G(e instanceof Error?e.message:String(e),{tone:`danger`})}finally{c(!1)}}}}function tk(e){let t=typeof e==`string`?new URLSearchParams(e):e;return{skill:(t.get(`skill`)??``).trim(),ref:(t.get(`ref`)??t.get(`task`)??``).trim()}}function nk({archiveWhenDone:e,autoMergePr:t,onChange:n,disabled:r=!1,embedded:i=!1}){let a=(0,Z.useId)();return(0,Q.jsxs)(`fieldset`,{"data-slot":`completion-controls`,"data-embedded":i||void 0,className:`grid min-w-0 gap-3`,children:[(0,Q.jsx)(`legend`,{className:i?`sr-only`:`text-sm font-medium [margin-block-end:0.5rem]`,children:`After Done`}),(0,Q.jsxs)(`label`,{htmlFor:`${a}-archive`,className:`completion-control flex min-h-11 min-w-0 items-center justify-between gap-3 rounded-md text-sm`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,Q.jsx)(`span`,{id:`${a}-archive-label`,children:`Archive when Done`}),i?(0,Q.jsx)(`span`,{id:`${a}-archive-help`,className:`completion-control-help`,children:`Move to Archived after Done, even without a PR. You can restore it later.`}):null]}),(0,Q.jsx)(Um,{id:`${a}-archive`,className:`completion-switch`,checked:e,disabled:r,"aria-labelledby":`${a}-archive-label`,"aria-describedby":`${a}-archive-help`,onCheckedChange:e=>n({archiveWhenDone:e})})]}),i?null:(0,Q.jsx)(`p`,{id:`${a}-archive-help`,className:`text-xs break-words text-muted-foreground`,children:`Move the task to Archived after it reaches Done. You can restore it later.`}),(0,Q.jsxs)(`label`,{htmlFor:`${a}-merge`,className:`completion-control flex min-h-11 min-w-0 items-center justify-between gap-3 rounded-md text-sm`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,Q.jsx)(`span`,{id:`${a}-merge-label`,children:`Auto-merge PR`}),i?(0,Q.jsx)(`span`,{id:`${a}-merge-help`,className:`completion-control-help`,children:`After Done, mark the PR ready and merge when current-head CI and GitHub rules allow.`}):null]}),(0,Q.jsx)(Um,{id:`${a}-merge`,className:`completion-switch`,checked:t,disabled:r,"aria-labelledby":`${a}-merge-label`,"aria-describedby":`${a}-merge-help`,onCheckedChange:e=>n({autoMergePr:e})})]}),i?null:(0,Q.jsx)(`p`,{id:`${a}-merge-help`,className:`text-xs break-words text-muted-foreground`,children:`After Done, mark a draft PR ready and merge when current-head CI and GitHub rules allow it.`}),!i||e&&t?(0,Q.jsx)(`p`,{className:`completion-order-note text-xs break-words text-muted-foreground`,children:i?`Merge runs before archive when both are on.`:`When both are on, merge comes before archive. Without a PR, Archive when Done still archives the task.`}):null]})}var rk=[{key:`allowWorkers`,slot:`workers`,label:`Allow ${a(`cezar`)} workers`,help:`Agents in this task can start ${a(`Cezar`)} workers. Each worker is a separate paid agent session. Worker limits cap resources, not spending.`},{key:`allowMessaging`,slot:`messaging`,label:`Allow task messaging`,help:`Agents in this task can message other tasks in this project.`}];function ik({allowWorkers:e,allowMessaging:t,onChange:n,disabled:r=!1,embedded:i=!1}){let a=(0,Z.useId)(),o={allowWorkers:e,allowMessaging:t};return(0,Q.jsxs)(`fieldset`,{"data-slot":`task-access-controls`,"data-embedded":i||void 0,className:`grid min-w-0 gap-3`,children:[(0,Q.jsx)(`legend`,{className:i?`sr-only`:`text-sm font-medium [margin-block-end:0.5rem]`,children:`Task access`}),rk.map(e=>(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsxs)(`label`,{htmlFor:`${a}-${e.slot}`,"data-slot":`task-access-${e.slot}`,className:`completion-control flex min-h-11 min-w-0 items-center justify-between gap-3 rounded-md text-sm`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,Q.jsx)(`span`,{id:`${a}-${e.slot}-label`,children:e.label}),i?(0,Q.jsx)(`span`,{id:`${a}-${e.slot}-help`,className:`completion-control-help`,children:e.help}):null]}),(0,Q.jsx)(Um,{id:`${a}-${e.slot}`,className:`completion-switch shrink-0`,checked:o[e.key],disabled:r,"aria-labelledby":`${a}-${e.slot}-label`,"aria-describedby":`${a}-${e.slot}-help`,onCheckedChange:t=>n({[e.key]:t})})]}),i?null:(0,Q.jsx)(`p`,{id:`${a}-${e.slot}-help`,className:`text-xs break-words text-muted-foreground`,children:e.help})]},e.key))]})}function ak(){return(0,Q.jsxs)(`header`,{className:`mb-7 max-md:mb-5`,children:[(0,Q.jsx)(`p`,{"data-slot":`page-eyebrow`,className:`mb-2 text-[11px] font-semibold tracking-[0.16em] text-[var(--accent-text)] uppercase`,children:`NEW TASK`}),(0,Q.jsx)(`h1`,{className:`text-[30px] leading-[normal] font-semibold tracking-[-0.9px] max-md:text-[22px] max-md:leading-[29px] max-md:tracking-[-0.6px]`,children:`What should the agent work on?`}),(0,Q.jsx)(`p`,{"data-slot":`page-description`,className:`mt-2 hidden text-[13px] text-muted-foreground md:block`,children:`Describe the outcome. Configure the run. Review everything before it lands.`})]})}function ok({groupRef:e,compact:t,engine:n,accounts:r,draftEffort:i,update:a}){let o=n.runners.length>1||n.runners.some(e=>oc(r.accountChoices,e))?(0,Q.jsx)(sk,{engine:n,accounts:r,update:a},`runner`):null,s=(0,Q.jsx)(ck,{engine:n,draftEffort:i,update:a},`model`),c=(0,Q.jsx)(lk,{engine:n,update:a},`effort`);return(0,Q.jsx)(`div`,{ref:e,"data-slot":`agent-options`,role:`group`,"aria-label":`Agent settings`,className:`new-task-agent-options`,children:(0,Q.jsx)(Zs,{children:t?[o,c,s]:[o,s,c]})})}function sk({engine:e,accounts:t,update:n}){return(0,Q.jsx)(Ws,{icon:(0,Q.jsx)(la,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:e.runners,value:e.displayRunner,accounts:t.accountChoices,account:t.agentProfile,repoAccount:t.repoAccount,onPick:(t,r)=>n({runner:t,agentProfile:r,...t===e.displayRunner?{}:{model:null}}),disabled:!e.providersReady})}function ck({engine:e,draftEffort:t,update:n}){let{catalog:r,displayRunner:i}=e;return(0,Q.jsx)(ic,{icon:(0,Q.jsx)(Gi,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`model-pill`,ariaLabel:`Model`,label:e.models.find(t=>t.id===e.model)?.label??`auto`,value:e.model,disabled:!e.providersReady,readOnly:e.modelsLocked,disabledHint:e.modelsLocked?`Model selection is locked to native coding-agent settings.`:void 0,onPick:e=>{let a=Gs(i,e,r.data);n({model:e,effort:t===null?null:lc(t,a)})},options:e.models.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:uc(i,r.data,r.isError,r.isFetching)})}function lk({engine:e,update:t}){return(0,Q.jsx)(ic,{icon:(0,Q.jsx)(wi,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`effort-pill`,ariaLabel:`Effort`,label:e.effortOptions.find(t=>t.value===e.effort)?.label??`auto`,value:e.effort,disabled:!e.providersReady,readOnly:e.modelsLocked,disabledHint:e.modelsLocked?`Effort selection is locked to native coding-agent settings.`:void 0,onPick:e=>t({effort:e}),options:e.effortOptions.map(e=>({value:e.value,label:e.label,desc:e.desc}))})}function uk({engine:e,draft:t,update:n,repo:r,hasGit:i,runMode:a,webhook:o,interactiveSkill:s,completionDisabled:c}){let{displayRunner:l}=e;return(0,Q.jsxs)(`details`,{"data-slot":`execution-options`,open:!0,className:`group rounded-xl border border-border bg-card xl:self-start`,children:[(0,Q.jsxs)(`summary`,{className:`flex min-h-[44px] cursor-pointer list-none flex-wrap items-center gap-x-2 gap-y-1 px-3 py-2 text-xs text-muted-foreground pointer-hover:bg-muted/50 active:bg-muted/50 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-foreground [&::-webkit-details-marker]:hidden`,children:[(0,Q.jsx)(ca,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Execution settings`}),(0,Q.jsxs)(`span`,{"data-slot":`execution-summary`,hidden:!0,className:`min-w-0 basis-full truncate pl-5 xl:ml-auto xl:basis-auto xl:pl-0`,children:[Us.find(e=>e.id===l)?.label??l,` · `,e.models.find(t=>t.id===e.model)?.label??`auto`]}),(0,Q.jsx)(_a,{"aria-hidden":`true`,className:`new-task-settings-chevron size-4 shrink-0`})]}),(0,Q.jsxs)(`div`,{className:`new-task-settings-body`,children:[(0,Q.jsx)(`p`,{className:`new-task-settings-description`,children:`Control this run and what happens after Done.`}),(0,Q.jsxs)(`div`,{role:`group`,"aria-label":`Run settings`,className:`new-task-run-settings`,children:[i?(0,Q.jsx)(fk,{on:a.worktree,onChange:e=>n({worktree:e})}):null,(0,Q.jsx)(hk,{repo:r}),(0,Q.jsx)(pk,{on:a.autonomous,disabled:t.planFirst,onChange:e=>n({autonomous:e})}),o.targets.length>0?(0,Q.jsx)(mk,{on:o.on,targets:o.targets,onChange:o.onChange}):null,s&&(t.autonomous===null||t.worktree===null)?(0,Q.jsx)(`p`,{className:`basis-full text-xs text-muted-foreground`,"data-slot":`interactive-skill-hint`,children:`This skill recommends an interactive run in the current checkout. You can change either setting.`}):null]}),(0,Q.jsx)(nk,{embedded:!0,archiveWhenDone:t.archiveWhenDone,autoMergePr:t.autoMergePr,onChange:n,disabled:c}),(0,Q.jsx)(ik,{embedded:!0,allowWorkers:t.allowWorkers,allowMessaging:t.allowMessaging,onChange:n,disabled:c})]})]})}function dk({showConfigureProviders:e,planFirst:t,planning:n,onModeChange:r}){return(0,Q.jsxs)(Q.Fragment,{children:[e?(0,Q.jsx)(Y,{to:`/settings/agents#providers`,className:`text-xs font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):null,(0,Q.jsx)(_k,{planFirst:t,planning:n,onModeChange:r}),(0,Q.jsx)(`kbd`,{"aria-hidden":`true`,className:`hidden rounded-[5px] border border-b-2 border-border bg-card px-[5px] py-px font-mono text-[11px] font-medium text-muted-foreground md:inline`,children:yT()})]})}function fk({on:e,disabled:t,disabledReason:n,onChange:r}){return(0,Q.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,disabled:t,"aria-label":`Worktree`,"data-slot":`worktree-toggle`,onClick:()=>r(!e),title:t?n:e?`Runs in an isolated worktree — uncheck to run in the repo working tree`:`Runs in the repo working tree — check to isolate in a worktree`,className:`flex items-center justify-between gap-3 px-0 py-3 text-left`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`block text-[13px] font-medium`,children:`Worktree`}),(0,Q.jsx)(`span`,{className:`block text-[12px] text-muted-foreground`,children:e?`Changes stay in a separate working copy.`:`Changes are made in the current working directory.`})]}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:D(`flex h-6 w-10 shrink-0 items-center rounded-full border p-0.5`,e?`border-accent-strong bg-accent-strong`:`border-muted-foreground bg-muted`),children:(0,Q.jsx)(`span`,{className:D(`size-[18px] rounded-full`,e?`ml-auto bg-accent-strong-foreground`:`bg-foreground`)})})]})}function pk({on:e,disabled:t,onChange:n}){return(0,Q.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,disabled:t,"aria-label":`Autonomous`,"data-slot":`autonomous-toggle`,onClick:()=>n(!e),title:t?`Plan-first runs are interactive — autonomous is unavailable`:e?`Autonomous — the agent runs to completion without pausing for you`:`Runs interactively — check to let the agent finish without pausing for you`,className:`flex items-center justify-between gap-3 px-0 py-3 text-left disabled:opacity-50`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`block text-[13px] font-medium`,children:`Autonomous`}),(0,Q.jsx)(`span`,{className:`block text-[12px] text-muted-foreground`,children:`Let the agent proceed without prompts`})]}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:D(`flex h-6 w-10 shrink-0 items-center rounded-full border p-0.5`,e?`border-accent-strong bg-accent-strong`:`border-muted-foreground bg-muted`),children:(0,Q.jsx)(`span`,{className:D(`size-[18px] rounded-full`,e?`ml-auto bg-accent-strong-foreground`:`bg-foreground`)})})]})}function mk({on:e,targets:t,onChange:n}){return(0,Q.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,"aria-label":`Notify webhook`,"data-slot":`notify-webhook-toggle`,onClick:()=>n(!e),title:`${e?`Status changes go to`:`Check to send this task's status changes to`} ${_O(t)} (${t.map(e=>hO(e.url)).join(`, `)})`,className:`flex min-h-11 items-center justify-between gap-3 px-0 py-3 text-left`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block text-[13px] font-medium`,children:`Notify webhook`}),(0,Q.jsx)(`span`,{"data-slot":`notify-webhook-subtitle`,className:`block truncate text-[12px] text-muted-foreground`,children:`Send status changes`})]}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:D(`flex h-6 w-10 shrink-0 items-center rounded-full border p-0.5`,e?`border-accent-strong bg-accent-strong`:`border-muted-foreground bg-muted`),children:(0,Q.jsx)(`span`,{className:D(`size-[18px] rounded-full`,e?`ml-auto bg-accent-strong-foreground`:`bg-foreground`)})})]})}function hk({repo:e}){return(0,Q.jsxs)(`div`,{"data-slot":`base-branch-row`,className:`new-task-base-branch flex items-center justify-between gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:`Base branch`}),e?(0,Q.jsx)(gk,{repo:e}):null]})}function gk({repo:e}){let t=L(),n=jn({mutationFn:e=>I({baseBranch:e}),onSuccess:e=>{t.invalidateQueries({queryKey:H.repo}),G(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=>G(e.message,{tone:`danger`})});return e.info?(0,Q.jsx)(ic,{searchPlaceholder:`Search branches…`,slot:`base-pill`,ariaLabel:`Base branch`,label:(0,Q.jsx)(`span`,{className:`text-[11px]`,children:e.baseBranch??e.info.branch}),value:e.baseBranch??``,onPick:e=>n.mutate(e===``?null:e),options:[{value:``,label:`follow checked-out branch (${e.info.branch})`,desc:`New task worktrees fork from whatever branch is checked out`},...e.branches.map(e=>({value:e,label:e}))]}):null}function _k({planFirst:e,planning:t,onModeChange:n}){return(0,Q.jsxs)(`div`,{"data-slot":`mode-seg`,role:`radiogroup`,"aria-label":`Run mode`,className:`inline-flex items-center gap-0.5 rounded-lg bg-muted p-[3px]`,children:[(0,Q.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":!e,onClick:()=>n(!1),className:D(`h-6 rounded-md px-2 text-xs transition-colors`,e?`font-medium text-muted-foreground hover:text-foreground`:`bg-card font-semibold text-foreground shadow-xs`),children:[e?null:(0,Q.jsx)(ia,{"aria-hidden":`true`,className:`size-3.5`}),`Start`]}),(0,Q.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e,"aria-busy":t||void 0,"data-slot":`mode-plan`,onClick:()=>n(!0),className:D(`h-6 rounded-md px-2 text-xs transition-colors`,e?`bg-contrast font-semibold text-contrast-foreground ring-2 ring-ring/55`:`font-medium text-muted-foreground hover:text-foreground`,t&&`animate-pulse`),children:t?`Planning…`:`Plan first`})]})}function vk({plan:e,starting:t,startAvailable:n,startUnavailableReason:r,startUnavailableAction:i,onStepsChange:a,onStart:o,onDiscard:s}){let[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),f=(0,Z.useRef)(null),p=(0,Z.useId)();(0,Z.useEffect)(()=>{f.current?.focus({preventScroll:!0});let e=f.current?.closest(`[data-slot="main"]`);e&&(e.scrollTop=0)},[]);let m=()=>{l(null),d(null)},h=(t,n)=>{t.preventDefault(),c!==null&&c!==n&&a(FO(e.steps,c,n)),m()},g=e.steps.length===0;return(0,Q.jsxs)(`div`,{"data-slot":`plan-page`,children:[(0,Q.jsxs)(`header`,{"data-slot":`plan-page-header`,children:[(0,Q.jsx)(`h1`,{children:`New task / Plan first`}),(0,Q.jsx)(`p`,{children:`Review the proposed chain before launching.`})]}),(0,Q.jsx)(`div`,{"data-slot":`plan-canvas`,children:(0,Q.jsxs)(`section`,{ref:f,tabIndex:-1,"aria-labelledby":p,"data-slot":`plan-review`,className:`flex flex-col outline-none`,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||e.target.closest(`[role="dialog"], [role="alertdialog"]`)||(e.preventDefault(),s())},children:[(0,Q.jsxs)(`header`,{"data-slot":`dialog-header`,className:`flex flex-col gap-1 px-5 pt-4 pb-3.5 text-left`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsx)(`h2`,{id:p,"data-slot":`dialog-title`,className:`text-[11px] font-semibold tracking-[0.08em] text-muted-foreground uppercase`,children:`Proposed chain`}),(0,Q.jsx)(`button`,{type:`button`,onClick:s,"aria-label":`Discard the plan`,className:`-mt-1 -mr-1 rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,Q.jsx)(oa,{"aria-hidden":`true`,className:`size-4`})})]}),(0,Q.jsx)(`p`,{"data-slot":`plan-task`,title:e.task,className:`text-[18px] font-medium text-foreground`,children:LO(e.task)}),e.fallback?(0,Q.jsx)(`p`,{"data-slot":`plan-fallback`,className:`text-xs text-soft-foreground italic`,children:`planner unavailable — single-step plan`}):e.rationale===``?null:(0,Q.jsx)(`p`,{"data-slot":`plan-rationale`,className:`text-xs text-muted-foreground`,children:e.rationale})]}),(0,Q.jsx)(`ol`,{"data-slot":`plan-steps`,className:`flex-1 space-y-2 overflow-y-auto px-5 py-4`,children:g?(0,Q.jsx)(`li`,{className:`py-6 text-center text-sm text-muted-foreground`,children:`(no steps left — discard and plan again)`}):e.steps.map((t,n)=>(0,Q.jsxs)(`li`,{"data-slot":`plan-step`,"data-step-id":t.id,draggable:!0,onDragStart:()=>l(n),onDragOver:e=>{e.preventDefault(),d(n)},onDragLeave:()=>d(e=>e===n?null:e),onDrop:e=>h(e,n),onDragEnd:m,className:D(`flex items-center gap-2.5 rounded-lg border border-border bg-card-2 px-3 py-2.5`,c===n&&`opacity-50`,u===n&&c!==null&&c!==n&&`border-ring`),children:[(0,Q.jsx)(Ii,{"aria-hidden":`true`,className:`size-3.5 shrink-0 cursor-grab text-soft-foreground`}),(0,Q.jsx)(`span`,{className:`w-5 shrink-0 font-mono text-[11px] text-soft-foreground tabular-nums`,children:String(n+1).padStart(2,`0`)}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] font-medium`,children:t.name??t.id}),t.skill?(0,Q.jsx)(`span`,{"data-slot":`plan-badge-skill`,title:`skill`,className:`shrink-0 rounded-full bg-accent-strong/15 px-1.5 py-px font-mono text-[11px] font-medium text-accent-text`,children:t.skill}):null,t.command?(0,Q.jsx)(`span`,{"data-slot":`plan-badge-check`,className:`shrink-0 rounded-full bg-muted px-1.5 py-px text-[11px] font-medium text-muted-foreground`,children:`check`}):null]}),(0,Q.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap break-words font-mono text-[11px] text-muted-foreground`,children:IO(t)})]}),(0,Q.jsxs)(`span`,{"data-slot":`plan-step-actions`,className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(E,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`plan-step-up`,"aria-label":`Move step ${n+1} up`,disabled:n===0,className:`size-7 text-muted-foreground`,onClick:()=>a(FO(e.steps,n,n-1)),children:`Move up`}),(0,Q.jsx)(E,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`plan-step-down`,"aria-label":`Move step ${n+1} down`,disabled:n===e.steps.length-1,className:`size-7 text-muted-foreground`,onClick:()=>a(FO(e.steps,n,n+1)),children:`Move down`}),(0,Q.jsx)(E,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`plan-step-remove`,"aria-label":`Remove step ${n+1}`,className:`size-7 text-muted-foreground hover:text-danger`,onClick:()=>a(PO(e.steps,n)),children:`Remove`})]})]},t.id))}),!n&&r?(0,Q.jsxs)(`p`,{id:`plan-start-guidance`,className:`flex flex-wrap items-center gap-1.5 border-t border-border px-5 pt-3 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:r}),i]}):null,(0,Q.jsxs)(`div`,{"data-slot":`plan-actions`,className:`flex flex-wrap items-center gap-3 px-6 pt-3 pb-6`,children:[(0,Q.jsxs)(E,{type:`button`,"data-slot":`plan-start`,disabled:g||t||!n,title:n?void 0:r,"aria-describedby":!n&&r?`plan-start-guidance`:void 0,onClick:o,children:[(0,Q.jsx)(Ua,{"aria-hidden":`true`,className:`size-3.5`}),t?`Starting…`:`Start`]}),(0,Q.jsx)(yk,{steps:e.steps,disabled:g}),(0,Q.jsx)(E,{type:`button`,variant:`outline`,onClick:s,children:`Discard`})]}),(0,Q.jsx)(`p`,{className:`px-6 pb-6 text-xs text-muted-foreground`,children:`No steps left? Start is disabled. A planner failure shows a single-step fallback.`})]})})]})}function yk({steps:e,disabled:t}){let n=L(),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d=async t=>{let r=a.trim();if(!(r===``||l)){u(!0);try{let a=await Ne({name:r,steps:e,...t?{overwrite:!0}:{}});G(`Saved — ${a.path.split(`/`).pop()??a.path}`),n.invalidateQueries({queryKey:H.workflows}),c(!1),i(!1),o(``)}catch(e){e instanceof it&&e.exists===!0?c(!0):G(e instanceof Error?e.message:String(e),{tone:`danger`})}finally{u(!1)}}};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{type:`button`,variant:`outline`,"data-slot":`plan-save`,disabled:t,onClick:()=>i(!0),children:`Save as chain`}),(0,Q.jsx)(ts,{open:r,onOpenChange:e=>i(!!e),children:(0,Q.jsxs)($o,{"data-slot":`plan-save-dialog`,className:`sm:max-w-sm`,showCloseButton:!1,children:[(0,Q.jsxs)(Qo,{children:[(0,Q.jsx)(es,{children:`Save as chain`}),(0,Q.jsx)(Xo,{children:`Saves these steps as a reusable workflow — it joins the picker like any other chain.`})]}),(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),d(!1)},children:[(0,Q.jsx)(`label`,{htmlFor:`plan-chain-name`,className:`mb-2 block text-[11px] text-muted-foreground`,children:`Chain name`}),(0,Q.jsx)(Im,{id:`plan-chain-name`,value:a,onChange:e=>o(e.target.value),"aria-label":`Chain name`,placeholder:`e.g. fix-and-verify-v2`,maxLength:80,autoFocus:!0}),(0,Q.jsxs)(Yo,{className:`mt-4`,children:[(0,Q.jsx)(E,{type:`button`,variant:`outline`,onClick:()=>i(!1),children:`Cancel`}),(0,Q.jsx)(E,{type:`submit`,disabled:a.trim()===``||l,children:l?`Saving…`:`Save chain`})]})]})]})}),(0,Q.jsx)(Ko,{open:s,onOpenChange:e=>e?void 0:c(!1),children:(0,Q.jsxs)(Ro,{"data-slot":`plan-overwrite-dialog`,children:[(0,Q.jsxs)(Go,{children:[(0,Q.jsxs)(No,{children:[`Overwrite “`,a.trim(),`”?`]}),(0,Q.jsx)(Mo,{children:`A chain with this name already exists. Overwriting replaces its steps with this plan.`})]}),(0,Q.jsxs)(Ho,{children:[(0,Q.jsx)(Wo,{children:`Cancel`}),(0,Q.jsx)(Vo,{onClick:()=>void d(!0),children:`Overwrite chain`})]})]})})]})}var bk={start:{note:`Start immediately with the selected configuration.`,pendingLabel:`Starting task…`,failureHint:void 0,clearOnSuccess:!0,sendAriaLabel:`Start task`},plan:{note:`Review the plan before starting the task.`,pendingLabel:`Planning task…`,failureHint:`Could not create the plan. Your draft is kept. Please retry.`,clearOnSuccess:!1,sendAriaLabel:`Plan task`}};function xk(){let[e]=n(),t=(0,Z.useRef)(null),i=(0,Z.useRef)(null),a=(0,Z.useRef)(null),{projectId:o}=r(),s=wt().projectId,[c]=(0,Z.useState)(()=>tk(e)),l=vr(),u=En(),d=$n(),f=Mn(),{draft:p,update:m,clearStarted:h,submissionPending:g,mounted:_}=BO(s,c),v=VO(p.source,u),{source:y,sourcesReady:b,skillList:x}=v,S=qO(o),C=HO({uiState:u,source:y,sourcesReady:b,draftText:p.text,submissionPending:g,update:m}),w=UO(p,d),T=WO(w.displayRunner,p.agentProfile);GO(w.providersReady);let E=l.data===void 0||l.data.info!==null,D=KO({hasGit:E,draft:p,selectedSkill:v.selectedSkill,workspaceConfig:f,source:y}),{plan:O,setPlan:k,planning:A,starting:j,submit:M,startPlanned:ee}=ek({draft:p,draftProjectId:s,engine:w,agentProfile:T.agentProfile,sourcesReady:b,source:y,runMode:D,notifyOn:S.notifyOn,uiState:u,mounted:_,clearStarted:h});YO({deepLink:c,search:e,sourcesReady:b,skillList:x,update:m});let te=JO(t),{providers:N,providersReady:P}=w,ne=p.planFirst?bk.plan:bk.start,F=QO(N);return(0,Q.jsxs)(`div`,{"data-route":`new`,"data-plan-review":O===null?void 0:`true`,className:`relative isolate flex min-h-full flex-col overflow-x-clip pb-16`,children:[(0,Q.jsxs)(`div`,{"data-slot":`new-task-layout`,ref:a,style:O===null?void 0:{display:`none`},className:`relative z-[1] mx-auto w-full max-w-none px-11 pt-12 max-md:px-[18px] max-md:pt-[22px]`,children:[(0,Q.jsx)(ak,{}),(0,Q.jsx)(iD,{ref:i,onSubmit:M,retainDraftUntilSuccess:!0,idleFeedback:(0,Q.jsxs)(`div`,{"data-slot":`new-task-mode-note`,className:`flex items-center justify-between gap-3 text-[11px] text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:ne.note}),(0,Q.jsx)(`kbd`,{className:`hidden font-sans md:inline`,children:yT()})]}),pendingLabel:ne.pendingLabel,failureHint:ne.failureHint,clearOnSuccess:ne.clearOnSuccess,onPendingChange:e=>{g.current=e},value:p.text,onValueChange:e=>m({text:e}),autoFocus:!0,placeholder:`Describe a task for the agent — / for skills…`,ariaLabel:`Describe a task for the agent`,sendAriaLabel:ne.sendAriaLabel,disabled:!P||j,disabledReason:F,autocompleteSkills:!0,footerStart:(0,Q.jsx)(Sk,{projects:S.projectList,urlProjectId:o,templates:C,onInsertTemplate:e=>i.current?.insertAtCaret(e),sources:v,onPickSource:e=>m({source:e})}),agentOptions:(0,Q.jsx)(ok,{groupRef:t,compact:te,engine:w,accounts:T,draftEffort:p.effort,update:m}),executionOptions:(0,Q.jsx)(uk,{engine:w,draft:p,update:m,repo:l.data,hasGit:E,runMode:D,webhook:{targets:S.webhookTargets,on:S.notifyOn,onChange:S.setNotifyChoice},interactiveSkill:v.selectedSkill?.interactive===!0,completionDisabled:j||A}),footerEnd:(0,Q.jsx)(dk,{showConfigureProviders:!P&&!N.isPending,planFirst:p.planFirst,planning:A,onModeChange:e=>m({planFirst:e})})}),(0,Q.jsx)(`p`,{"data-slot":`run-mode-note`,className:`mt-2.5 text-[13px] text-muted-foreground`,children:xO({worktree:D.worktree,hasGit:E})})]}),O===null?null:(0,Q.jsx)(vk,{plan:O,starting:j,startAvailable:P,startUnavailableReason:F,startUnavailableAction:N.isPending?void 0:(0,Q.jsx)(Y,{to:`/settings/agents#providers`,children:`Configure providers`}),onStepsChange:e=>k(t=>t&&{...t,steps:e}),onStart:()=>void ee(),onDiscard:()=>{k(null),requestAnimationFrame(()=>a.current?.querySelector(`textarea`)?.focus())}})]})}function Sk({projects:e,urlProjectId:t,templates:n,onInsertTemplate:r,sources:i,onPickSource:a}){let o=_s();return(0,Q.jsxs)(Q.Fragment,{children:[e.length>1&&t!==void 0?(0,Q.jsx)(wk,{projects:e,projectId:t,onPick:e=>o(`/p/${encodeURIComponent(e)}/new`,{replace:!0})}):null,(0,Q.jsx)(ps,{label:`Template`,templates:n,onInsert:r}),(0,Q.jsx)(Mk,{source:i.source,ready:i.sourcesReady,skills:i.skillList,skillUsage:i.skillUsage,workflows:i.workflowList,onPick:a})]})}function Ck(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 wk({projects:e,projectId:t,onPick:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(``),{order:s}=uv(),c=e.find(e=>e.id===t),l=Ck(sv(e,s),a);return(0,Q.jsxs)(fi,{open:r,onOpenChange:e=>{i(e),e||o(``)},children:[(0,Q.jsx)(li,{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:D(ac,`border-foreground/60 font-semibold text-foreground`),children:[(0,Q.jsx)(Ei,{"aria-hidden":`true`,className:`size-3 shrink-0 text-soft-foreground`}),(0,Q.jsx)(`span`,{className:`max-w-40 truncate`,children:c?.name??t}),nc]})}),(0,Q.jsx)(Qr,{align:`start`,sideOffset:8,className:`w-[300px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Q.jsxs)(Ls,{shouldFilter:!1,children:[(0,Q.jsx)(Rs,{placeholder:`search projects…`,value:a,onValueChange:o}),(0,Q.jsxs)(Es,{"data-slot":`project-menu`,className:`max-h-[min(18rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[l.length===0?(0,Q.jsx)(Ns,{children:`Nothing matches.`}):null,l.map(e=>(0,Q.jsxs)(fc,{value:e.id,keywords:[e.name],"data-slot":`project-option`,"data-project-id":e.id,disabled:e.status===`missing`,onSelect:()=>{n(e.id),i(!1)},children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium`,children:e.name}),e.status===`missing`?(0,Q.jsx)(`span`,{className:`shrink-0 text-[11px] text-soft-foreground`,children:`folder not found`}):e.branch===void 0?null:(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-soft-foreground`,children:e.branch}),e.id===t?(0,Q.jsx)(ia,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},e.id))]}),(0,Q.jsx)(`p`,{className:`border-t border-border px-3 py-2 text-[11px] leading-snug text-soft-foreground`,children:`Skills, workflows, settings and the draft re-resolve against the selected project.`})]})})]})}function Tk(e,t,n){return!e&&(t.ranked?t.ranked.length===0:t.mostUsed.length===0&&t.project.length===0&&t.global.length===0)&&n.length===0}function Ek(e,t){return Oc(`no skill`,`none plain ${Ys} ${e?.description??``}`,t)>0}function Dk({source:e,ready:t,offersWorkflows:n,onPick:r}){let i=e===null||e.source===`skill`?pa:Zi;return(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(),r(null))},className:D(ac,`font-mono text-[11px]`,e===null?`text-muted-foreground`:`rounded-r-none border-r-0 border-foreground/60 pr-1.5 font-semibold text-foreground`),children:[(0,Q.jsx)(i,{"aria-hidden":`true`,className:D(`size-3 shrink-0`,e===null?`text-muted-foreground`:`text-accent-icon`)}),(0,Q.jsx)(`span`,{className:`max-w-44 truncate`,children:t?e?.ref??(n?`Skill or workflow`:`Skill`):`…`}),nc]})}function Ok({source:e,quickTask:t,onPick:n}){return(0,Q.jsx)(Ps,{children:(0,Q.jsxs)(fc,{value:`none no-skill`,keywords:[`none`,`plain`,...Ac(Ys)],"data-slot":`source-option`,"data-source-kind":`none`,onSelect:()=>n(null),children:[(0,Q.jsx)(Qi,{"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:t?.description??`One agent run on your task — no ceremony.`}),e===null?(0,Q.jsx)(ia,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]})})}function kk({ranked:e,mostUsed:t,project:n,skillItem:r}){return(0,Q.jsx)(Q.Fragment,{children:e?e.length>0?(0,Q.jsx)(Ps,{children:e.map(e=>r(e,jc(e)))}):null:(0,Q.jsxs)(Q.Fragment,{children:[t.length>0?(0,Q.jsx)(Ps,{heading:`Most used`,children:t.map(e=>r(e,jc(e)))}):null,n.length>0?(0,Q.jsx)(Ps,{heading:`Project skills`,children:n.map(e=>r(e,!0))}):null]})})}function Ak({source:e,matchedWorkflows:t,toggle:n}){return t.length>0?(0,Q.jsx)(Ps,{heading:`Workflows`,children:t.map(t=>{let r=e?.source===`workflow`&&e.ref===t.name;return(0,Q.jsxs)(fc,{value:`workflow ${t.name}`,keywords:Ac(t.name,t.description),"data-slot":`source-option`,"data-source-kind":`workflow`,"data-source-ref":t.name,onSelect:()=>n({source:`workflow`,ref:t.name}),children:[(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:t.name}),t.description?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:t.description}):null,r?(0,Q.jsx)(ia,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},t.name)})}):null}function jk({global:e,skillItem:t}){return e.length>0?(0,Q.jsx)(Ps,{heading:`Global`,children:e.map(e=>t(e,!1))}):null}function Mk({source:e,ready:t,skills:n,skillUsage:r,workflows:i,onPick:a}){let[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(null),f=(0,Z.useRef)(null),{mostUsed:p,project:m,global:h,ranked:g}=Ic(n,c,r),_=i.find(e=>e.name===Ys),v=kc(i,c).filter(e=>e.name!==Ys),y=i.some(e=>e.name!==Ys),b=Ek(_,c),x=Tk(b,{ranked:g,mostUsed:p,project:m,global:h},v),S=e=>{a(e),s(!1)},C=t=>S(e?.source===t.source&&e.ref===t.ref?null:t),w=(t,n)=>{let r=e?.source===`skill`&&e.ref===t.name;return(0,Q.jsxs)(fc,{value:`skill ${t.name} ${t.path}`,keywords:Ac(t.name,t.description),"data-slot":`source-option`,"data-source-kind":`skill`,"data-source-ref":t.name,onSelect:()=>C({source:`skill`,ref:t.name}),children:[(0,Q.jsx)(`span`,{className:D(`shrink-0 font-mono text-xs`,n&&`font-semibold`),children:t.name}),t.description?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:t.description}):null,(0,Q.jsx)(`button`,{type:`button`,"data-slot":`source-skill-view`,"aria-label":`View skill ${t.name}`,title:`View skill`,onClick:e=>{e.preventDefault(),e.stopPropagation(),d(t)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,Q.jsx)(La,{"aria-hidden":`true`,className:`size-3.5`})}),r?(0,Q.jsx)(ia,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},t.path)},T=Dk({source:e,ready:t,offersWorkflows:y,onPick:a});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(mO,{skill:u,onClose:()=>d(null)}),(0,Q.jsxs)(fi,{open:o,onOpenChange:e=>{s(e),e||l(``)},children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center`,children:[(0,Q.jsx)(li,{asChild:!0,children:T}),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:D(ac,`rounded-l-none border-foreground/60 pl-1.5 pr-2 text-soft-foreground hover:text-foreground`),children:(0,Q.jsx)(oa,{"aria-hidden":`true`,className:`size-3`})}):null]}),(0,Q.jsx)(Qr,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Q.jsxs)(Ls,{shouldFilter:!1,children:[(0,Q.jsx)(Rs,{placeholder:`search skills & workflows…`,value:c,onValueChange:l,onInput:()=>f.current?.scrollTo(0,0)}),(0,Q.jsxs)(Es,{ref:f,"data-slot":`source-menu`,className:`max-h-[min(18rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[x?(0,Q.jsx)(Ns,{children:`Nothing matches.`}):null,b?(0,Q.jsx)(Ok,{source:e,quickTask:_,onPick:S}):null,(0,Q.jsx)(kk,{ranked:g,mostUsed:p,project:m,skillItem:w}),(0,Q.jsx)(Ak,{source:e,matchedWorkflows:v,toggle:C}),(0,Q.jsx)(jk,{global:h,skillItem:w})]})]})})]})]})}function Nk(){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)(yu,{}),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)(E,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(Y,{to:`/`,children:`Back to tasks`})})})})}function Pk(){return(0,Q.jsx)(`div`,{className:`px-[18px] pt-2 md:hidden`,children:(0,Q.jsxs)(Y,{to:`/git`,"data-slot":`git-back`,className:`inline-flex min-h-11 items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground`,children:[(0,Q.jsx)(fa,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`Back to Git`]})})}function Fk(){let{pathname:e,search:n}=t();return(0,Q.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[xs(e)!==`/git`||new URLSearchParams(n).get(`view`)===`repo`?(0,Q.jsx)(Pk,{}):null,(0,Q.jsx)(X,{icon:(0,Q.jsx)(Ra,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading repository…`,subtitle:`Fetching the repo's git state.`})]})}function Ik(){return(0,Q.jsxs)(`div`,{"data-route":`skills`,"aria-busy":`true`,className:`mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:[(0,Q.jsx)(`h1`,{className:`text-[30px] font-semibold tracking-tight`,children:`Skills`}),(0,Q.jsx)(`p`,{className:`mt-1 text-[13px] text-muted-foreground`,children:`Markdown playbooks your agents can follow.`}),(0,Q.jsx)(`p`,{"data-slot":`skills-loading`,role:`status`,className:`mt-6 text-xs text-muted-foreground`,children:`Loading skills…`}),(0,Q.jsxs)(`div`,{"aria-hidden":`true`,className:`mt-4 flex flex-col gap-[22px] motion-safe:animate-pulse`,children:[(0,Q.jsx)(`div`,{className:`h-11 rounded-lg border border-border bg-card`}),(0,Q.jsx)(`div`,{className:`h-80 rounded-xl border border-border bg-card`})]})]})}function Lk({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)(ju,{}),tone:`neutral`,title:`“${e}” isn’t registered here`,subtitle:`This ${a(`cezar`)} doesn’t serve a project by that id. The link may come from another machine’s workspace — these are the projects registered on this one:`,children:(0,Q.jsx)(`ul`,{"data-slot":`registered-projects`,className:`mx-auto flex w-full max-w-xs flex-col gap-1.5 text-left`,children:n.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(C,{to:`/p/${encodeURIComponent(e.id)}/`,className:`flex items-baseline gap-2 rounded-md border border-border bg-card px-3 py-2 text-sm font-medium text-foreground shadow-xs transition-colors hover:bg-card-2`,children:[e.name||e.id,(0,Q.jsxs)(`span`,{className:`font-mono text-[11px] font-normal text-soft-foreground`,children:[`/p/`,e.id]})]})},e.id))})})})}function Rk(){return(0,Q.jsxs)(`div`,{"data-route":`workflows`,"aria-busy":`true`,className:`mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:[(0,Q.jsx)(`h1`,{className:`text-[30px] font-semibold tracking-tight`,children:`Workflows`}),(0,Q.jsx)(`p`,{className:`mt-1 text-[13px] text-muted-foreground`,children:`Portable skill chains. Steps run from top to bottom.`}),(0,Q.jsx)(`p`,{"data-slot":`workflows-loading`,role:`status`,className:`mt-6 text-xs text-muted-foreground`,children:`Loading workflows…`}),(0,Q.jsxs)(`div`,{"aria-hidden":`true`,className:`mt-4 flex flex-col gap-[22px] motion-safe:animate-pulse`,children:[(0,Q.jsx)(`div`,{className:`h-11 rounded-lg border border-border bg-card`}),(0,Q.jsx)(`div`,{className:`h-80 rounded-xl border border-border bg-card`})]})]})}function zk({tab:e}){return(0,Q.jsx)(`div`,{"data-route":`task-${e}`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(Ra,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:e===`changes`?`Loading changes…`:`Loading files…`,subtitle:`Fetching the run record.`})})}function Bk({tab:e,error:t}){let n=t instanceof it&&t.status===404;return(0,Q.jsx)(`div`,{"data-route":`task-${e}`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(X,{icon:n?(0,Q.jsx)(Xa,{}):(0,Q.jsx)(qi,{size:16}),tone:n?`neutral`:`danger`,title:n?`Task not found`:`Could not load this task`,subtitle:n?`No run has this id. It may have been deleted, or the link is from another machine.`:t.message,actions:(0,Q.jsx)(E,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(Y,{to:`/`,children:`Back to tasks`})})})})}var Vk={issue:`issue`,pr:`pull request`};function Hk({kind:e,number:t,heading:n=`h1`}){let r=(0,Q.jsx)(`div`,{"data-slot":`task-github-loading`,className:`flex min-h-full flex-1 flex-col`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(Ra,{className:`motion-safe:animate-spin`}),tone:`neutral`,heading:n,title:`Loading ${Vk[e]}${t===void 0?``:` #${t}`}…`,subtitle:t===void 0?`Fetching the run record.`:`Asking GitHub.`})});return n===`h2`?r:(0,Q.jsx)(`div`,{"data-route":`task-github-item`,className:`flex min-h-full flex-col`,children:r})}function Uk(){return(0,Q.jsx)(`div`,{"data-route":`task-thread`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(Ra,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading task…`,subtitle:`Fetching the run and its session transcript.`})})}async function Wk(e,t,n,r,i){try{return await Hl(e,{queryKey:[t,`runs`,`artifact-metadata`,n,r],queryFn:({signal:e})=>me(n,r,{signal:e})},i),!0}catch(e){if(e instanceof it&&e.status===404)return!1;throw e}}async function Gk(e,t,n,r,i,a){if(await Wk(e,t,n,r,i))return n;i.throwIfAborted();let o=await Hl(e,{queryKey:[t,`runs`,`relationships`,n],queryFn:({signal:e})=>le(n,{signal:e})},i),s=new Set(o.workers.map(e=>e.workerId));a&&s.add(a),s.delete(n);for(let n of s){if(i.aborted)throw i.reason;if(await Wk(e,t,n,r,i))return n}throw new it(404,`Report missing or deleted`)}function Kk(e,t,n){let r=L(),i=o();return wr({queryKey:[i,`runs`,`report-source`,e,t,n],queryFn:({signal:a})=>Gk(r,i,e,t,a,n),enabled:!!(e&&t),retry:!1})}function qk(){let[e]=n(),r=t(),i=k(),a=u(),o=Z.useRef(Math.random()),s=Z.useRef({renderedKey:``,next:e,seq:0,latestSeq:0});return Z.useLayoutEffect(()=>{if(s.current.renderedKey===r.key)return;let t=r.state,n=t?.__writerSession===o.current?t.__writerSeq:void 0;a===`REPLACE`&&n!==void 0&&n<=s.current.latestSeq?(s.current.renderedKey=r.key,n===s.current.latestSeq&&(s.current.next=e)):s.current={renderedKey:r.key,next:e,seq:s.current.seq,latestSeq:0}},[e,r,a]),[e,Z.useCallback(e=>{let t=e(new URLSearchParams(s.current.next));if(t.toString()===s.current.next.toString())return;let n=s.current.seq+1;s.current={...s.current,next:t,seq:n,latestSeq:n},i({search:`?${t}`},{replace:!0,state:{__writerSession:o.current,__writerSeq:n}})},[i])]}var Jk=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Yk(e){let t=e.get(`report`);return!t||!Jk.test(t)||e.getAll(`report`).length!==1||e.getAll(`card`).length>1?null:{artifactId:t,card:e.get(`card`)||null}}var Xk=(0,Z.createContext)(null);function Zk(e){let n=t(),r=k(),[i,a]=qk(),o=Yk(i),[s,c]=(0,Z.useState)(()=>({runId:e,entries:new Map}));s.runId!==e&&c({runId:e,entries:new Map});let l=(0,Z.useCallback)((t,n)=>(c(r=>{if(r.runId===e&&r.entries.get(t)===n)return r;let i=new Map(r.runId===e?r.entries:[]);return i.set(t,n),{runId:e,entries:i}}),()=>void 0),[e]),u=(0,Z.useRef)({runId:e,callbacks:new Map});u.current.runId!==e&&(u.current={runId:e,callbacks:new Map});let d=(0,Z.useCallback)((e,t)=>(u.current.callbacks.set(e,t),()=>{u.current.callbacks.get(e)===t&&u.current.callbacks.delete(e)}),[]),f=(0,Z.useMemo)(()=>({register:l,registerOpener:d}),[l,d]),p=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{i.has(`report`)&&!o&&a(e=>(e.delete(`report`),e.delete(`card`),e))},[i,o,a]),(0,Z.useEffect)(()=>{let t=p.current;!o&&t&&t.runId===e&&t.card&&u.current.callbacks.get(t.card)?.(t.artifactId,t.scrollTop),p.current=o?{...o,runId:e,scrollTop:n.state?.reportScrollTop}:null},[e,o,n.state]),{selection:o,sourceRunId:s.runId===e&&o?s.entries.get(o.artifactId)??(o.card?void 0:e):void 0,registry:f,close:()=>{let e=n.state,t=window.navigation;if(e?.reportReturnKey&&t){t.traverseTo(e.reportReturnKey);return}if(e?.reportReturnTo){r(e.reportReturnTo,{replace:!0});return}a(e=>(e.delete(`report`),e.delete(`card`),e))}}}var Qk=class extends Z.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){console.error(`${a(`cezar`)} cockpit: the preview pane crashed`,e,t.componentStack)}render(){return this.state.failed?(0,Q.jsxs)(`div`,{"data-slot":`preview-pane-error`,role:`alert`,className:`flex h-full flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,children:`The preview hit an error`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The task is unaffected. Close the preview and open it again.`}),(0,Q.jsx)(E,{variant:`outline`,onClick:this.props.onClose,children:`Close preview`})]}):this.props.children}},$k=`cez-preview-tasks`,eA=`cez.preview.pane-width`,tA=e=>Math.min(75,Math.max(30,Math.round(e)));function nA(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function rA(e){if(!nA(e))return;let{port:t,agent:n,url:r}=e;if(typeof t==`number`&&Number.isInteger(t)&&t>=1&&t<=65535)return{port:t};if(n===!0)return{agent:!0};if(typeof r==`string`&&/^https?:\/\//i.test(r))return{url:r}}function iA(e){if(!nA(e))return;let t=rA(e.target),n=typeof e.percent==`number`&&Number.isFinite(e.percent)?e.percent:void 0;return{open:e.open===!0,...t?{target:t}:{},...n===void 0?{}:{percent:n},at:typeof e.at==`number`?e.at:0}}function aA(){try{let e=localStorage.getItem($k),t=e===null?null:JSON.parse(e);return nA(t)?t:{}}catch{return{}}}function oA(e){let t=iA(aA()[e]);if(!t)return;let{at:n,...r}=t;return r}function sA(e,t,n=Date.now()){let r=aA(),i={open:!1,...iA(r[e]),...t,at:n};for(let e of Object.keys(i))i[e]===void 0&&delete i[e];r[e]=i;let a=Object.keys(r);if(a.length>100){let e=e=>iA(r[e])?.at??0;for(let t of a.sort((t,n)=>e(t)-e(n)).slice(0,a.length-100))delete r[t]}try{localStorage.setItem($k,JSON.stringify(r))}catch{}}function cA(){try{let e=Number(localStorage.getItem(eA));return e>0?e:void 0}catch{return}}function lA(e){let t=(e===void 0?void 0:oA(e)?.percent)??cA();return t===void 0?58:tA(t)}function uA(e,t){try{localStorage.setItem(eA,String(t))}catch{}e!==void 0&&sA(e,{percent:t})}var dA=`(min-width: 1180px)`,fA=`(max-width: 767px)`;function pA(e,t){let[n,r]=(0,Z.useState)(()=>window.matchMedia?.(e).matches??t);return(0,Z.useEffect)(()=>{let t=window.matchMedia?.(e);if(!t)return;let n=()=>r(t.matches);return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[e]),n}var mA=(0,Z.lazy)(()=>U(()=>import(`./preview-pane-connected-ZAr18goj.js`).then(e=>({default:e.ConnectedPreviewPane})),__vite__mapDeps([6,5,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]))),hA=2;function gA(e){let[t,n]=(0,Z.useState)(void 0);return(0,Z.useEffect)(()=>{let t=e.current?.closest(`[data-slot="main"]`);if(!t)return;let r=()=>n(t.clientHeight||void 0);if(r(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(r);return i.observe(t),()=>i.disconnect()},[e]),t}function _A({run:e,state:t,children:n,report:r}){let i=pA(dA,!0),a=pA(fA,!1),o=(0,Z.useRef)(null),s=gA(o),{percent:c,setPercent:l}=t,u=!!r||t.open&&e!==void 0,d=u&&!i,f=!r&&t.session,p=d&&!f,m=d&&f,h=e=>{let t=o.current?.getBoundingClientRect();!t||t.width===0||l(tA((t.right-e)/t.width*100))},g=e=>{e.currentTarget.setPointerCapture?.(e.pointerId)},_=e=>{e.currentTarget.hasPointerCapture?.(e.pointerId)&&h(e.clientX)},v=e=>{if(e.key===`ArrowLeft`)l(tA(c+hA));else if(e.key===`ArrowRight`)l(tA(c-hA));else return;e.preventDefault()},y={"--preview-pane":`${c}%`,...s===void 0?{}:{"--preview-h":`${s}px`}};return(0,Q.jsxs)(`div`,{ref:o,"data-slot":`task-split`,"data-pane":u?`open`:`closed`,"data-takeover":p?``:void 0,className:`preview-split flex min-h-full`,style:y,children:[(0,Q.jsx)(`div`,{"data-slot":`task-main`,hidden:p&&a,"data-collapsed":p&&!a?``:void 0,className:`min-w-0 flex-1`,children:n}),u?(0,Q.jsxs)(Q.Fragment,{children:[i?(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize preview`,"aria-valuemin":30,"aria-valuemax":75,"aria-valuenow":c,tabIndex:0,"data-slot":`preview-divider`,className:`preview-divider`,onPointerDown:g,onPointerMove:_,onKeyDown:v}):null,(0,Q.jsxs)(`aside`,{"data-slot":`preview-pane`,"data-phone":a?``:void 0,hidden:m,className:`preview-pane`,children:[r,(0,Q.jsx)(`div`,{hidden:!!r,className:`h-full`,children:t.open&&e?(0,Q.jsx)(Qk,{onClose:t.closePane,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,className:`p-6 text-sm text-muted-foreground`,children:`Opening the preview…`}),children:(0,Q.jsx)(mA,{run:e,servers:e.previewServers??[],request:t.request,onSession:p?t.showSession:void 0,onTarget:t.setTarget,onLive:t.setLive,onClose:t.closePane},e.id)})}):null})]})]}):null]})}function vA(e){if(!e.worktreePath||e.worktreeReclaimedAt)return!0;let t=e.delegation?.role===`worker`?e.delegation.destroy:void 0;return t!==void 0&&!t.remaining.includes(`worktree`)}function yA(e){let{state:t,server:n}=e,r=za(e.stateAt);switch(t){case`registered`:return n.answeredAtRegistration?{tone:`neutral`,ring:!1,pulse:!1,text:`was running when registered`}:{tone:`neutral`,ring:!0,pulse:!1,text:`registered · not started`};case`adopted`:return{tone:`neutral`,ring:!1,pulse:!1,text:`was running when registered`};case`starting`:return{tone:`pending`,ring:!1,pulse:!0,text:`starting`};case`up`:return{tone:`success`,ring:!1,pulse:!1,text:r?`up · ${r}`:`up`};case`stalled`:return{tone:`pending`,ring:!1,pulse:!1,text:`stalled · port silent 2 min`};case`exited`:return{tone:`danger`,ring:!1,pulse:!1,text:e.exitCode===void 0?`exited`:`exited · code ${e.exitCode}`};case`stopped`:return{tone:`neutral`,ring:!0,pulse:!1,text:e.reason===`idle`?`stopped after 15 min idle`:`stopped`};case`unavailable`:return{tone:`neutral`,ring:!0,pulse:!1,text:`unavailable`}}}function bA(e){return{kind:`preview-server`,id:`preview-server:${e.port}`,server:e,state:`registered`,stateAt:e.registeredAt}}function xA(e,t){return t?.get(e.port)??bA(e)}function SA(e){return e.state===`registered`?e.server.answeredAtRegistration:e.state===`up`||e.state===`starting`||e.state===`adopted`}function CA(e){return e.split(` -- `)[0].trim()}var wA=(0,Z.createContext)(null);function TA(){return(0,Z.useContext)(wA)}var EA=e=>e&&`port`in e?e.port:void 0;function DA(){return typeof window.matchMedia!=`function`||window.matchMedia(`(min-width: 1180px)`).matches}function OA(e){let t=e===void 0?void 0:oA(e),n=t?.open===!0,r=n?t.target:void 0;return{open:n,target:r,request:n?{...r,restored:!0}:void 0,session:n&&!DA(),percent:lA(e)}}function kA(e,t=!1){let[n]=(0,Z.useState)(()=>OA(e)),[r,i]=(0,Z.useState)(n.open),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(n.target),[l,u]=(0,Z.useState)(n.session),[d,f]=(0,Z.useState)(n.request),[p,m]=(0,Z.useState)(n.percent),[h,g]=(0,Z.useState)(e),_=(0,Z.useRef)(r);if(_.current=r,h!==e){let t=OA(e);g(e),i(t.open),o(!1),c(t.target),u(t.session),f(t.request),m(t.percent)}t&&r&&d?.restored&&(i(!1),c(void 0),f(void 0),u(!1));let v=(0,Z.useCallback)(t=>{e!==void 0&&sA(e,t)},[e]),y=(0,Z.useCallback)(e=>{f({...e});let t=e.port===void 0?e.agent?{agent:!0}:void 0:{port:e.port};u(!1),i(!0),t?(c(t),v({open:!0,target:t})):_.current?v({open:!0}):(c(void 0),v({open:!0,target:void 0}))},[v]),b=(0,Z.useCallback)(()=>{i(!1),o(!1),u(!1),c(void 0),v({open:!1})},[v]),x=(0,Z.useCallback)(e=>{c(e),v({target:e})},[v]),S=(0,Z.useCallback)(t=>{m(t),uA(e,t)},[e]),C=(0,Z.useCallback)(()=>u(!0),[]),w=EA(s);return(0,Z.useMemo)(()=>({open:r,live:a,port:w,target:s,percent:p,request:d,session:l,openPane:y,closePane:b,showSession:C,setLive:o,setTarget:x,setPercent:S}),[r,a,w,s,p,d,l,y,b,C,x,S])}function AA(e,t={}){let[n,r]=(0,Z.useState)([]),{cursor:i,afterSeq:a=0,maxEvents:s,compactAt:c,onCompact:l,onReset:u}=t;return(0,Z.useEffect)(()=>{if(r([]),!e)return;let t=a,n=!1,d=!1,f=o(),p=[],m,h,g=()=>{if(m!==void 0&&globalThis.cancelAnimationFrame?.(m),clearTimeout(h),m=void 0,h=void 0,n||p.length===0)return;let e=p;p=[],r(t=>{let r=[...t,...e];return!d&&c!==void 0&&r.length>=c&&(d=!0,queueMicrotask(()=>{n||l?.()})),s===void 0||r.length<=s?r:r.slice(-s)})},_=()=>{h===void 0&&(h=setTimeout(g,50),typeof globalThis.requestAnimationFrame==`function`&&(m=globalThis.requestAnimationFrame(g)))},v=ce({kind:`run`,projectId:f,runId:e,afterSeq:a,...i?{cursor:i}:{}},{frame:e=>{!(`type`in e)||e.type!==`event`||e.event.seq<=t||(t=e.event.seq,p.push(e.event),_())},reset:async(e,n)=>{g();let r=await u?.(e,n);return r&&(t=Math.max(t,r.afterSeq)),r}});return()=>{n=!0,m!==void 0&&globalThis.cancelAnimationFrame?.(m),clearTimeout(h),v()}},[e,i,a,s,c,l,u]),n}var jA=5,MA=200,NA=5e3;function PA(...e){let t=new Map;for(let n of e)for(let e of n)t.set(e.seq,e);return[...t.values()].sort((e,t)=>e.seq-t.seq)}function FA(e,t,n){e.setQueryData(t,e=>{if(!e)return{pages:[n],pageParams:[void 0]};let t=[...e.pages],r=[...e.pageParams],i=-1;for(let e=0;e<t.length;e+=1)(i===-1||t[e].asOfSeq>t[i].asOfSeq)&&(i=e);if(i>=0&&t[i].asOfSeq>n.asOfSeq)return e;for(i>=0&&t[i].newerCursor===void 0?(t[i]=n,r[i]=void 0):(t.push(n),r.push(void 0));t.length>jA;)t.shift(),r.shift();return{pages:t,pageParams:r}})}function IA(e,t){return e!==void 0&&(t===void 0||e.asOfSeq>=t.asOfSeq)}function LA(e,t,n,r){let i=(0,Z.useRef)(void 0),a=r&&t.data!==void 0&&!t.isFetching&&!IA(t.data,n),o=e===void 0||n===void 0?void 0:`${e}:${n.asOfSeq}`;(0,Z.useEffect)(()=>{!a||o===void 0||i.current===o||(i.current=o,t.refetch())},[a,t,o])}function RA(e,t){return e!==void 0&&e.asOfSeq>t.asOfSeq?e:t}function zA(e){let t=o(),n=L(),r=[`run-history`,t,e],i=[`run-history-context`,t,e],a=on({queryKey:r,enabled:e!==void 0,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>Rt(e,t,{signal:n}),getPreviousPageParam:e=>e.olderCursor,getNextPageParam:e=>e.newerCursor,maxPages:jA,staleTime:1/0,retry:1}),s=wr({queryKey:i,enabled:e!==void 0,queryFn:async({signal:t})=>{let r=await Fe(e,{signal:t});return RA(n.getQueryData(i),r)},retry:1}),c=(0,Z.useCallback)(async r=>{let i=r?{signal:r}:void 0,a=await Rt(e,void 0,i),o=await Fe(e,i);return r?.throwIfAborted(),FA(n,[`run-history`,t,e],a),n.setQueryData([`run-history-context`,t,e],e=>RA(e,o)),a},[n,e,t]),l=(0,Z.useCallback)(async(t,n)=>{if(e===void 0)return;let r=await c(n);return{cursor:r.liveCursor,afterSeq:r.asOfSeq}},[c,e]),u=a.isError||s.isError,d=AA(u?e:void 0,{onReset:l}),f=a.data?.pages??[],p=f.reduce((e,t)=>t.newerCursor===void 0?t:e??t,void 0),m=(0,Z.useRef)(!1),h=(0,Z.useCallback)(()=>{e===void 0||m.current||(m.current=!0,c().catch(()=>{}).finally(()=>{m.current=!1}))},[c,e]),g=e=>e!==void 0&&n.getQueryData([`run-history`,t,e])!==void 0,[_,v]=(0,Z.useState)(()=>({runId:e,pending:g(e)})),y=_.pending;_.runId!==e&&(y=g(e),v({runId:e,pending:y})),(0,Z.useEffect)(()=>{if(!y||e===void 0)return;let t=!1,n=new AbortController;return c(n.signal).catch(()=>{}).finally(()=>{t||v({runId:e,pending:!1})}),()=>{t=!0,n.abort()}},[c,y,e]);let b=AA(!u&&p&&!y?e:void 0,{cursor:p?.liveCursor,afterSeq:p?.asOfSeq,maxEvents:NA,compactAt:MA,onCompact:h,onReset:l}),x=(0,Z.useRef)(0);x.current=b.length,(0,Z.useEffect)(()=>()=>{x.current>0&&h()},[h]);let S=(0,Z.useMemo)(()=>PA(...f.map(e=>e.events)),[f]),C=(0,Z.useMemo)(()=>u?d:PA(S,b),[u,d,S,b]);LA(e,s,p,!u);let w=u||IA(s.data,p),T=(0,Z.useMemo)(()=>{if(u)return d;let e=s.data?.contextEvents??[],t=s.data?.asOfSeq??0;return PA(e,C.filter(({seq:e})=>e>t))},[s.data,u,d,C]),E=(0,Z.useCallback)(async()=>{await a.fetchPreviousPage()},[a.fetchPreviousPage]),D=(0,Z.useCallback)(async()=>{u||(await n.resetQueries({queryKey:[`run-history`,t,e],exact:!0}),n.invalidateQueries({queryKey:[`run-history-context`,t,e],exact:!0}))},[u,n,e,t]);return{visibleEvents:C,currentEvents:T,currentComplete:w,isPending:!u&&a.isPending,contextPending:!u&&s.isPending,fallback:u,hasOlder:!u&&!!a.hasPreviousPage,isFetchingOlder:a.isFetchingPreviousPage,olderError:a.isFetchPreviousPageError?a.error instanceof Error?a.error.message:`Could not load earlier items`:void 0,loadOlder:E,jumpToLatest:D,retainedPages:f.length}}function BA(e){for(let t=e.length-1;t>=0;--t){let n=Pt.safeParse(e[t]);if(n.success)return n.data.state===`connected`}return!1}function VA(e){let{currentEvents:t}=zA(e);return(0,Z.useMemo)(()=>BA(t),[t])}var HA=(0,Z.lazy)(()=>U(()=>import(`./report-reader-CIcjK2_U.js`).then(e=>({default:e.ReportReader})),__vite__mapDeps([26,5,7,8,9,10,11,27,28,29,30,31,12,22,32,13,33])));function UA(){let{id:e}=r(),n=er(e),i=t(),a=On().data?.capabilities?.preview===!0,o=n.data?vA(n.data):!1,s=kA(e,o),c=Zk(e),l=Kk(e,c.selection?.artifactId,c.sourceRunId),u=c.selection?(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading report…`}),children:(0,Q.jsx)(HA,{runId:l.data??e??``,selection:{artifactId:c.selection.artifactId},fragment:i.hash,onBack:c.close,variant:`pane`,sourceLookup:l},`${e}:${c.selection.artifactId}`)}):void 0,d=a?(0,Q.jsx)(WA,{id:e,run:n.data,pane:s,removed:o,report:u,children:(0,Q.jsx)(g,{})}):(0,Q.jsx)(_A,{run:n.data,state:{...s,open:!1},report:u,children:(0,Q.jsx)(g,{})});return(0,Q.jsx)(Xk.Provider,{value:c.registry,children:d})}function WA({id:e,run:t,pane:n,removed:r,children:i,report:a}){let o=VA(e),s=(0,Z.useMemo)(()=>({...n,worktreeRemoved:r,agentLive:o}),[n,r,o]);return(0,Q.jsx)(wA.Provider,{value:s,children:(0,Q.jsx)(_A,{run:t,state:n,report:a,children:i})})}function GA({...e}){return(0,Q.jsx)(Nd,{"data-slot":`collapsible`,...e})}function KA({...e}){return(0,Q.jsx)(Od,{"data-slot":`collapsible-trigger`,...e})}function qA({...e}){return(0,Q.jsx)(Ad,{"data-slot":`collapsible-content`,...e})}var JA={"needs-you":{label:`Needs you`,hint:`Asks a question, asks for permission, or waits for review`},failed:{label:`Failed`,hint:`Failed, with no scheduled resume`},done:{label:`Done`,hint:`Finished`},cancelled:{label:`Cancelled`,hint:`Was cancelled`},running:{label:`Running`,hint:`Runs an agent turn`},"waiting-workers":{label:`Waiting for agents`,hint:`Waits on its workers or their replies`},"waiting-ci":{label:`Waiting on CI`,hint:`Waits on a pull request's checks`},"waiting-timer":{label:`Waiting`,hint:`Waits on a timer`},"waiting-other":{label:`Any other wait`,hint:`Waits on anything else, including wait types added later`}},YA=(e,t)=>e.length===t.length&&e.every(e=>t.includes(e)),XA={name:``,description:``,url:``,token:``,tasks:!0,triggers:De,agent:!1};function ZA(e){return{name:e.name,description:e.description??``,url:e.url,token:``,tasks:e.tasks,triggers:e.triggers??De,agent:e.agent}}var QA=e=>ue.filter(t=>e.includes(t));function $A(e){let t=e.description.trim();return{name:e.name.trim(),url:e.url.trim(),...t?{description:t}:{},...e.token?{token:e.token}:{},tasks:e.tasks,...YA(e.triggers,De)?{}:{triggers:QA(e.triggers)},agent:e.agent}}function ej(e,t){let n={},r=e.name.trim(),i=e.description.trim(),a=e.url.trim();return r!==t.name&&(n.name=r),i!==(t.description??``)&&(n.description=i),a!==t.url&&(n.url=a),e.token&&(n.token=e.token),e.tasks!==t.tasks&&(n.tasks=e.tasks),YA(e.triggers,t.triggers??De)||(n.triggers=QA(e.triggers)),e.agent!==t.agent&&(n.agent=e.agent),n}var tj=`flex flex-col gap-1 text-[13px]`,nj=`text-[11px] text-muted-foreground`;function rj({draft:e,onChange:t,tokenSet:n}){let r=(0,Z.useId)(),i=(0,Z.useId)(),a=(0,Z.useId)(),o=(0,Z.useId)(),s=(0,Z.useId)(),c=(0,Z.useId)(),l=(0,Z.useId)(),u=(0,Z.useId)(),d=(0,Z.useId)(),f=(0,Z.useId)();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,14rem),1fr))] gap-3`,children:[(0,Q.jsxs)(`div`,{className:tj,children:[(0,Q.jsx)(`label`,{htmlFor:r,className:nj,children:`Name`}),(0,Q.jsx)(Im,{id:r,"data-slot":`webhook-name`,autoComplete:`off`,maxLength:80,placeholder:`e.g. Team bot`,value:e.name,onChange:e=>t({name:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:tj,children:[(0,Q.jsx)(`label`,{htmlFor:o,className:nj,children:`URL`}),(0,Q.jsx)(Im,{id:o,"data-slot":`webhook-url`,type:`url`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,maxLength:ot,placeholder:`https://bot.example/hooks/cez`,value:e.url,onChange:e=>t({url:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{className:tj,children:[(0,Q.jsx)(`label`,{htmlFor:i,className:nj,children:`Description`}),(0,Q.jsx)(pC,{id:i,"data-slot":`webhook-description`,"aria-describedby":a,rows:2,maxLength:ct,placeholder:`e.g. Posts to the #releases channel. Use it for release notes.`,value:e.description,onChange:e=>t({description:e.target.value})}),(0,Q.jsx)(`span`,{id:a,className:`text-[11px] text-soft-foreground`,children:`Agents read the name and description to decide when to use this webhook.`})]}),(0,Q.jsxs)(`div`,{className:tj,children:[(0,Q.jsx)(`label`,{htmlFor:s,className:nj,children:`Token`}),(0,Q.jsx)(Im,{id:s,"data-slot":`webhook-token`,type:`password`,autoComplete:`new-password`,spellCheck:!1,maxLength:re,"aria-describedby":c,placeholder:n?`Token set — type to replace`:`Optional Bearer token`,value:e.token,onChange:e=>t({token:e.target.value})}),(0,Q.jsx)(`span`,{id:c,className:`text-[11px] text-soft-foreground`,children:n?`The token is stored in ~/.cezar and never shown again. Leave it empty to keep it.`:`The token is stored in ~/.cezar, never in the repo. It is sent as a Bearer header.`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3`,children:[(0,Q.jsx)(Um,{id:l,"aria-describedby":u,"data-slot":`webhook-tasks`,checked:e.tasks,onCheckedChange:e=>t({tasks:e})}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col text-[13px]`,children:[(0,Q.jsx)(`label`,{htmlFor:l,className:`font-medium`,children:`Task notifications`}),(0,Q.jsx)(`span`,{id:u,className:`text-[11px] text-soft-foreground`,children:`Tasks you hand off, or start with notify on, send their status here.`})]})]}),e.tasks?(0,Q.jsxs)(`fieldset`,{"data-slot":`webhook-triggers`,className:`flex flex-col gap-1 sm:ps-[3.25rem]`,children:[(0,Q.jsx)(`legend`,{className:`pbe-1 text-[11px] text-muted-foreground`,children:`Send a delivery when a task enters`}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-x-3`,children:ue.map(n=>(0,Q.jsxs)(`label`,{className:`flex min-h-11 items-start gap-2.5 pbs-2 text-[13px]`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"data-trigger":n,checked:e.triggers.includes(n),onChange:r=>t({triggers:r.target.checked?[...e.triggers,n]:e.triggers.filter(e=>e!==n)}),className:`mbs-0.5 size-[18px] shrink-0`}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:JA[n].label}),(0,Q.jsx)(`span`,{className:`text-[11px] text-soft-foreground`,children:JA[n].hint})]})]},n))}),(0,Q.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Handing a task off and Send test always deliver.`})]}):null]}),(0,Q.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3`,children:[(0,Q.jsx)(Um,{id:d,"aria-describedby":f,"data-slot":`webhook-agent`,checked:e.agent,onCheckedChange:e=>t({agent:e})}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col text-[13px]`,children:[(0,Q.jsx)(`label`,{htmlFor:d,className:`font-medium`,children:`Let agents send reports`}),(0,Q.jsx)(`span`,{id:f,className:`text-[11px] text-soft-foreground`,children:`Agents in this project may post a report here when the task calls for it.`})]})]})]})}var ij=`max-sm:h-11`,aj=(e,t)=>({tone:`alert`,text:`Not saved: ${e.message}. Fix the field and select ${t} again.`}),oj=e=>e.dryRun?{tone:`ok`,text:`Dry run: nothing was sent.`}:e.ok?{tone:`ok`,text:`Delivered (HTTP ${e.status??200}).`}:{tone:`danger`,text:`Not delivered: ${e.error??`unknown error`}.`};function sj({feedback:e}){return e?(0,Q.jsx)(`p`,{"data-slot":e.tone===`alert`?`webhook-error`:`webhook-result`,role:e.tone===`alert`?`alert`:`status`,className:e.tone===`ok`?`text-[13px] text-muted-foreground`:`text-[13px] text-danger`,children:e.text}):null}var cj=`rounded-md border border-border bg-background`,lj=`flex flex-col gap-3 border-bs border-border p-3`;function uj({projectId:e,webhook:t,defaultOpen:n=!1}){let r=yn(),i=Xn(),a=Tn(),[o,s]=(0,Z.useState)(n),[c,l]=(0,Z.useState)(()=>ZA(t)),[u,d]=(0,Z.useState)(null),f=ej(c,t),p=Object.keys(f).length>0,m=c.name.trim()!==``&&c.url.trim()!==``,h=r.isPending||i.isPending||a.isPending,g={projectId:e,webhookId:t.id},_=e=>r.mutate({...g,...f},{onSuccess:()=>{l(e=>({...e,token:``})),e?e():G(`${c.name.trim()} saved`)},onError:e=>d(aj(e,`Save`))}),v=()=>a.mutate(g,{onSuccess:e=>d(oj(e)),onError:e=>d({tone:`danger`,text:e.message})});return(0,Q.jsx)(`li`,{"data-slot":`webhook-card`,"data-webhook-id":t.id,className:cj,children:(0,Q.jsxs)(GA,{open:o,onOpenChange:s,children:[(0,Q.jsx)(KA,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-action":`webhook-toggle`,className:`group flex min-h-11 w-full items-center gap-3 rounded-md p-3 text-start focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-foreground pointer-hover:bg-muted/50 active:bg-muted/50`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Q.jsx)(`span`,{"data-slot":`webhook-card-name`,className:`min-w-0 break-words text-[13px] font-medium`,children:t.name}),t.tasks?(0,Q.jsx)(Dm,{variant:`secondary`,"data-badge":`tasks`,children:`Task notifications`}):null,t.agent?(0,Q.jsx)(Dm,{variant:`secondary`,"data-badge":`agent`,children:`Agents`}):null]}),(0,Q.jsx)(`span`,{"data-slot":`webhook-card-url`,className:`truncate text-[12px] text-muted-foreground`,children:hO(t.url)})]}),(0,Q.jsx)(_a,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground group-data-[state=open]:rotate-180`})]})}),(0,Q.jsx)(qA,{children:(0,Q.jsxs)(`form`,{"data-slot":`webhook-form`,className:lj,onSubmit:e=>{e.preventDefault(),d(null),m&&p&&_()},children:[(0,Q.jsx)(rj,{draft:c,tokenSet:t.tokenSet,onChange:e=>l(t=>({...t,...e}))}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(E,{type:`submit`,size:`sm`,className:ij,"data-action":`webhook-save`,disabled:h||!m||!p,children:`Save`}),(0,Q.jsx)(E,{type:`button`,size:`sm`,className:ij,variant:`outline`,"data-action":`webhook-test`,disabled:h||!m,onClick:()=>{d(null),p?_(v):v()},children:`Send test`}),t.tokenSet?(0,Q.jsx)(E,{type:`button`,size:`sm`,className:ij,variant:`ghost`,"data-action":`webhook-clear-token`,disabled:h,onClick:()=>r.mutate({...g,token:``},{onSuccess:()=>G(`Webhook token cleared`),onError:e=>d({tone:`danger`,text:`Token not cleared: ${e.message}.`})}),children:`Clear token`}):null,(0,Q.jsx)(E,{type:`button`,size:`sm`,className:ij,variant:`danger-ghost`,"data-action":`webhook-remove`,"aria-label":`Remove ${t.name}`,disabled:h,onClick:()=>i.mutate(g,{onSuccess:()=>G(`${t.name} removed`),onError:e=>d({tone:`danger`,text:`Not removed: ${e.message}.`})}),children:`Remove`})]}),(0,Q.jsx)(sj,{feedback:u})]})})]})})}function dj({projectId:e,onCreated:t,onCancel:n}){let r=Jn(),[i,a]=(0,Z.useState)(XA),[o,s]=(0,Z.useState)(null),c=i.name.trim()!==``&&i.url.trim()!==``;return(0,Q.jsxs)(`li`,{"data-slot":`webhook-card`,"data-draft":``,className:cj,children:[(0,Q.jsx)(`p`,{className:`p-3 text-[13px] font-medium`,children:`New webhook`}),(0,Q.jsxs)(`form`,{"data-slot":`webhook-form`,"aria-label":`New webhook`,className:lj,onSubmit:n=>{n.preventDefault(),s(null),c&&r.mutate({projectId:e,...$A(i)},{onSuccess:({webhook:e})=>{G(`${e.name} created`),t(e)},onError:e=>s(aj(e,`Create`))})},children:[(0,Q.jsx)(rj,{draft:i,tokenSet:!1,onChange:e=>a(t=>({...t,...e}))}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(E,{type:`submit`,size:`sm`,className:ij,"data-action":`webhook-create`,disabled:r.isPending||!c,children:`Create`}),(0,Q.jsx)(E,{type:`button`,size:`sm`,className:ij,variant:`ghost`,"data-action":`webhook-cancel`,disabled:r.isPending,onClick:n,children:`Cancel`})]}),(0,Q.jsx)(sj,{feedback:o})]})]})}function fj({project:e}){let t=e.webhooks??[],[n,r]=(0,Z.useState)(!1),[i,o]=(0,Z.useState)(null),s=t.length>=16;return(0,Q.jsx)(cw,{title:`Webhooks`,hint:`A webhook gets a POST from ${a(`cezar`)}. Tasks can send their status to it, and agents can send it reports.`,children:(0,Q.jsxs)(`div`,{"data-slot":`project-webhooks`,className:`flex flex-col gap-3`,children:[t.length===0&&!n?(0,Q.jsx)(`p`,{"data-slot":`webhooks-empty`,className:`text-[13px] text-soft-foreground`,children:`No webhooks yet. Add one to send task updates to a bot, or to let agents post reports.`}):null,t.length>0||n?(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-2`,children:[t.map(t=>(0,Q.jsx)(uj,{projectId:e.id,webhook:t,defaultOpen:t.id===i},t.id)),n?(0,Q.jsx)(dj,{projectId:e.id,onCancel:()=>r(!1),onCreated:e=>{o(e.id),r(!1)}}):null]}):null,n?null:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(E,{type:`button`,size:`sm`,variant:`outline`,className:`max-sm:h-11`,"data-action":`webhook-add`,disabled:s,onClick:()=>r(!0),children:[(0,Q.jsx)(Xu,{"aria-hidden":`true`}),`Add webhook`]}),s?(0,Q.jsxs)(`span`,{className:`text-[11px] text-soft-foreground`,children:[`A project holds at most `,16,` webhooks.`]}):null]})]})})}function pj(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}function mj(){let e=Cs(),t=An(),n=Mn();if(t.isPending)return(0,Q.jsx)(`p`,{"data-slot":`project-general-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading project…`});if(t.isError)return(0,Q.jsxs)(`p`,{"data-slot":`project-general-error`,className:`text-[13px] text-danger`,children:[`Could not read the project registry — `,t.error.message]});let r=t.data,i=r?.projects.find(t=>t.id===e);return!r||!i?null:(0,Q.jsxs)(`div`,{"data-slot":`project-general`,className:`flex w-full flex-col gap-5`,children:[(0,Q.jsxs)(`section`,{className:`flex flex-col gap-5 rounded-lg border border-border bg-card p-5 [&_select]:min-h-11 [&_select]:w-full`,children:[(0,Q.jsx)(`h2`,{className:`text-lg font-semibold`,children:`General`}),(0,Q.jsx)(Ww,{}),(0,Q.jsx)(hj,{project:i}),(0,Q.jsx)(cw,{title:`Max parallel tasks`,hint:n.data?`The workspace limit (${n.data.resources.maxParallel}) still applies as an overall ceiling.`:`How many of this project's tasks may run at once. The workspace limit still applies as an overall ceiling.`,children:n.data?(0,Q.jsx)(vw,{project:i,workspaceMax:n.data.resources.maxParallel}):(0,Q.jsx)(`p`,{className:`text-[13px] text-soft-foreground`,children:`Loading the workspace limit…`})}),(0,Q.jsx)(fj,{project:i},i.id)]}),(0,Q.jsx)(`section`,{className:`rounded-lg border border-border bg-card p-5`,children:(0,Q.jsx)(gj,{project:i,bootProject:r.bootProject})})]})}function hj({project:e}){return(0,Q.jsxs)(`dl`,{"data-slot":`project-facts`,className:`grid grid-cols-1 gap-4 text-[13px] sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Project`}),(0,Q.jsx)(`dd`,{className:`mt-1 font-medium`,children:e.name})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Branch`}),(0,Q.jsx)(`dd`,{className:`mt-1 break-all`,children:e.branch??`—`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Status`}),(0,Q.jsxs)(`dd`,{"data-slot":`project-general-status`,className:e.status===`missing`?`mt-1 text-danger`:`mt-1`,children:[uw[e.status],e.status===`missing`?` — remove it below, or restore the folder`:null]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Added`}),(0,Q.jsxs)(`dd`,{className:`mt-1`,children:[pj(e.addedAt),(0,Q.jsx)(`span`,{className:`text-soft-foreground`,children:e.source===`checkout`?` · cloned from GitHub`:` · opened locally`})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Last opened`}),(0,Q.jsx)(`dd`,{className:`mt-1`,children:pj(e.lastOpenedAt)})]})]})}function gj({project:e,bootProject:t}){let[n,r]=(0,Z.useState)(null),i=ow(),o=k(),s=e.id===t;return(0,Q.jsxs)(cw,{title:`Remove from workspace`,hint:`Unregisters this project so it leaves the sidebar and the project list. Nothing on disk is deleted — the folder, its git history and its task history all stay, and opening it again re-registers it.`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(E,{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:s?`${a(`cezar`)} is serving this project — it re-registers itself at every start`:void 0,disabled:s||i.isPending,onClick:()=>r(e),className:`text-danger`,children:[`Remove `,e.name]}),s?(0,Q.jsxs)(`span`,{"data-slot":`project-general-remove-boot`,className:`text-[11px] text-soft-foreground`,children:[a(`cezar`),` is serving this project — it re-registers itself at every start.`]}):null]}),(0,Q.jsx)(sw,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{r(null),i.confirm(e,()=>void o(`/p/${encodeURIComponent(t)}`))}})]})}function _j(e,t){return e===`global`?`/settings/global/${t}`:`/settings/${t}`}var vj=_j(`global`,`appearance`);function yj(e){return e===`global`?{Link:C,NavLink:S}:{Link:Y,NavLink:bs}}function bj({scope:e,title:t,mobileTitle:n}){let r=Th().name;return(0,Q.jsxs)(`header`,{"data-slot":`settings-main-header`,className:`settings-route-header flex shrink-0 flex-col gap-2`,children:[(0,Q.jsxs)(`h1`,{className:`text-[15px] font-semibold tracking-normal max-md:text-[24px] max-md:font-normal`,children:[(0,Q.jsx)(`span`,{className:`md:hidden`,children:n}),(0,Q.jsxs)(`span`,{className:`max-md:hidden`,children:[t,` · `,e===`global`?`every project`:r??`this project`]})]}),e===`global`?(0,Q.jsx)(`span`,{"data-slot":`settings-scope-chip`,className:`sr-only`,children:`Global settings`}):null]})}function xj({scope:e,activeId:t}){let{NavLink:n}=yj(e),r=Qw(e);return(0,Q.jsxs)(`details`,{className:`settings-section-picker md:hidden`,children:[(0,Q.jsxs)(`summary`,{children:[r.find(e=>e.id===t)?.title??`General`,(0,Q.jsx)(_a,{"aria-hidden":`true`,className:`size-5 text-muted-foreground`})]}),(0,Q.jsxs)(`nav`,{"aria-label":`Settings sections`,"data-slot":`settings-nav-mobile`,"data-scope":e,children:[e===`project`?(0,Q.jsx)(n,{to:`/settings`,end:!0,"data-slot":`settings-nav-index`,children:`General`}):null,r.map(t=>(0,Q.jsx)(n,{to:_j(e,t.id),"data-section":t.id,children:t.title},t.id))]})]},`${e}-${t}`)}function Sj({section:e,scope:t}){let n=e.component;return(0,Q.jsxs)(`div`,{"data-route":t===`global`?`settings-global-${e.id}`:`settings-${e.id}`,className:`settings-route mx-auto flex min-h-full w-full flex-col`,children:[(0,Q.jsx)(bj,{scope:t,title:e.title,mobileTitle:t===`global`?`Global settings`:`Project settings`}),(0,Q.jsxs)(`div`,{className:`settings-route-body flex min-w-0 flex-1 flex-col md:flex-row`,children:[(0,Q.jsx)(xj,{scope:t,activeId:e.id}),(0,Q.jsxs)(`section`,{className:`settings-panel min-w-0 self-start md:flex-1`,"aria-label":e.title,children:[(0,Q.jsx)(`h2`,{className:`settings-panel-title`,children:e.title}),(0,Q.jsx)(n,{})]})]})]})}function Cj(){return(0,Q.jsxs)(`div`,{"data-route":`settings`,className:`settings-route mx-auto flex min-h-full w-full flex-col`,children:[(0,Q.jsx)(bj,{scope:`project`,title:`General`,mobileTitle:`Project settings`}),(0,Q.jsxs)(`div`,{className:`settings-route-body flex min-w-0 flex-1 flex-col md:flex-row`,children:[(0,Q.jsx)(xj,{scope:`project`,activeId:null}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-5`,children:[(0,Q.jsx)(mj,{}),(0,Q.jsx)(`section`,{className:`rounded-lg border border-border bg-card p-5`,children:(0,Q.jsx)(oS,{})}),(0,Q.jsx)(`h2`,{className:`settings-other-title mt-6 rounded-t-lg border border-b-0 border-border bg-card px-5 pt-5 text-base font-semibold md:hidden`,children:`Other project settings`}),(0,Q.jsx)(`ul`,{"data-slot":`settings-index`,className:`mt-7 flex w-full flex-col gap-5 md:hidden`,children:Qw(`project`).map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(Y,{to:_j(`project`,e.id),"data-section":e.id,className:`flex items-center gap-3.5 rounded-lg border border-border bg-card p-4 transition-colors hover:bg-card-2`,children:[(0,Q.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center text-accent-text`,children:(0,Q.jsx)(e.icon,{"aria-hidden":`true`,className:`size-4`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:e.title}),(0,Q.jsx)(`span`,{className:`block text-xs text-soft-foreground`,children:e.description})]}),(0,Q.jsx)(Ji,{"aria-hidden":`true`,className:`size-4 shrink-0 text-soft-foreground`})]})},e.id))}),(0,Q.jsxs)(`p`,{className:`mt-5 w-full text-[12px] text-soft-foreground`,children:[`Appearance, notifications, host resources and the project registry live in`,` `,(0,Q.jsx)(C,{to:vj,"data-slot":`settings-global-link`,className:`underline underline-offset-2 hover:text-foreground`,children:`Global settings`}),`.`]})]})]})]})}function wj(){let[e,t]=(0,Z.useState)(()=>new Set);return{expandedRuns:e,toggleExpandedRun:(0,Z.useCallback)(e=>t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[])}}var Tj=[{id:`status`,label:`Status`,canFold:!1,defaultExpanded:!0,align:`left`,width:`120px`},{id:`task`,label:`Task`,canFold:!1,defaultExpanded:!0,align:`left`,width:`320px`},{id:`workflow`,label:`Workflow`,canFold:!0,defaultExpanded:!0,align:`left`,width:`84px`,icon:`workflow`},{id:`branch`,label:`Branch`,canFold:!0,defaultExpanded:!1,align:`left`,width:`120px`,icon:`branch`},{id:`diff`,label:`±`,canFold:!0,defaultExpanded:!0,align:`left`,width:`84px`,icon:`diff`},{id:`reference`,label:`Ref`,canFold:!0,defaultExpanded:!0,align:`left`,width:`104px`,icon:`reference`},{id:`tokens`,label:`IN / OUT`,canFold:!0,defaultExpanded:!0,align:`right`,width:`112px`,icon:`tokens`,capability:`tokens`},{id:`cost`,label:`Cost`,canFold:!0,defaultExpanded:!0,align:`right`,width:`64px`,icon:`cost`,capability:`cost`},{id:`cpu`,label:`CPU`,canFold:!0,defaultExpanded:!0,align:`right`,width:`60px`,icon:`cpu`},{id:`memory`,label:`Mem`,canFold:!0,defaultExpanded:!0,align:`right`,width:`80px`,icon:`memory`},{id:`started`,label:`Started`,canFold:!0,defaultExpanded:!0,align:`right`,width:`68px`,icon:`started`}],Ej=new Map(Tj.map(e=>[e.id,e]));function Dj(e){return typeof e!=`object`||!e||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`boolean`))}function Oj(e){let t={};for(let[n,r]of Object.entries(Dj(e))){let e=Ej.get(n);e?.canFold&&(t[e.id]=r)}return t}function kj(e,t){let n=Ej.get(e);return!n||!n.canFold?!0:t[e]??n.defaultExpanded}function Aj(e,t){let n=Dj(e);return Ej.get(t)?.canFold?{...n,[t]:!kj(t,Oj(e))}:n}function jj(e){return Tj.filter(t=>t.capability===void 0||e[t.capability])}function Mj(e,t){return t===`flat`?!1:t===`virtual`||e>=100}function Nj(e,t){let n=t===null?-1:e.indexOf(t);return n<0?[]:[n-1,n,n+1].filter(t=>t>=0&&t<e.length)}function Pj(e,t){let n=e.map(e=>kj(e.id,t)?e.id===`workflow`||e.id===`memory`?120:Number.parseFloat(e.width??`100`):42);return{"--task-columns":e.map((e,t)=>e.id===`task`?`minmax(${n[t]}px, 1fr)`:`${n[t]}px`).join(` `),minInlineSize:Math.max(1240,n.reduce((e,t)=>e+t,0))}}function Fj(e,t){let n=2;return{indexes:e.map(e=>{let r=n;return n+=t.has(e)?2:1,r}),rowCount:n-1}}var Ij=null,{min:Lj,max:Rj,abs:zj,floor:Bj}=Math,Vj=(e,t,n)=>Lj(n,Rj(t,e)),Hj=e=>[...e].sort((e,t)=>e-t),Uj=typeof queueMicrotask==`function`?queueMicrotask:e=>{Promise.resolve().then(e)},Wj=()=>{let e;return[new Promise(t=>{e=t}),e]},Gj=e=>{let t;return()=>(e&&=(t=e(),void 0),t)},Kj=(e,t,n)=>{let r=n?`unshift`:`push`;for(let n=0;n<t;n++)e[r](-1);return e},qj=(e,t)=>{let n=e.t[t];return n===-1?e.o:n},Jj=(e,t,n)=>{let r=e.t[t]===-1;return e.t[t]=n,e.i=Lj(t,e.i),r},Yj=(e,t)=>{if(!e.l)return 0;if(e.i>=t)return e.u[t];e.i<0&&(e.u[0]=0,e.i=0);let n=e.i,r=e.u[n];for(;n<t;)r+=qj(e,n),e.u[++n]=r;return e.i=t,r},Xj=(e,t,n=0,r=e.l-1)=>{let i=n;for(;n<=r;){let a=Bj((n+r)/2);Yj(e,a)<=t?(i=a,n=a+1):r=a-1}return Vj(i,0,e.l-1)},Zj=(e,t,n)=>{let r=t-e.l;return e.i=n?-1:Lj(t-1,e.i),e.l=t,r>0?(Kj(e.u,r),Kj(e.t,r,n),e.o*r):(e.u.splice(r),(n?e.t.splice(0,-r):e.t.splice(r)).reduce((t,n)=>t-(n===-1?e.o:n),0))},Qj=typeof window<`u`,$j=e=>e.documentElement,eM=e=>e.ownerDocument,tM=e=>e.defaultView,nM=Gj(()=>!!/iP(hone|od|ad)/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>0),rM=Gj(()=>`scrollBehavior`in $j(document).style),iM=e=>Rj(e.h(),e.p()),aM=(e,t=40,n=0,r,i=!1)=>{let a=!!n,o=1,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=Ij,g=[0,a?Rj(n-1,0):-1],_=0,v=!1,y=((e,t,n)=>({o:t,t:n?Kj(n.slice(0,Lj(e,n.length)),Rj(0,e-n.length)):Kj([],e),l:e,i:-1,u:Kj([],e+1)}))(e,r?r[1]:t,r&&r[0]),b=new Set,x=()=>l-c,S=()=>x()+d+u,C=(e,t)=>((e,t,n,r)=>{if(r=Lj(r,e.l-1),Yj(e,r)<=t){let i=Xj(e,n,r);return[Xj(e,t,r,i),i]}{let i=Xj(e,t,void 0,r);return[i,Xj(e,n,i)]}})(y,e,t,g[0]),w=()=>Yj(y,y.l),T=(e,t)=>{let n=Yj(y,e)-d;return t?w()-n-E(e):n},E=e=>qj(y,e),D=(e,t=-1)=>y.t[e]===t,O=e=>{e&&(nM()&&p!==0||h&&m===1?d+=e:u+=e)};return{v:()=>{b.clear()},m:()=>o,_:()=>(e=>[e.t.slice(),e.o])(y),S:(e=200)=>{if(!v||a)return g;let t,n;if(f)[t,n]=g;else{let r=Rj(0,S()),a=r+s;i||(e=Rj(0,e),p!==1&&(r-=e),p!==2&&(a+=e)),[t,n]=g=C(Rj(0,r),Rj(0,a)),h&&(t=Lj(t,h[0]),n=Rj(n,h[1]))}return[Rj(t,0),Lj(n,y.l-1)]},$:e=>Xj(y,e-c),I:D,k:T,R:E,T:()=>y.l,C:()=>l,M:()=>p!==0,p:()=>s,O:()=>c,h:w,H:()=>(f=u,u=0,[f,m===2]),W:(e,t)=>{let n=[e,t];return b.add(n),()=>{b.delete(n)}},B:(e,t)=>{let n,r,g=0;switch(e){case 1:{if(t===l&&m===0)break;let e=f;f=0;let n=t-l,i=zj(n);e&&i<zj(e)+1||m!==0||(p=n<0?2:1),a&&=!1,l=t,g=4;let o=x();o>=-s&&o<=w()&&(g+=1,r=i>s);break}case 2:g=8,p!==0&&(n=!0,g+=1),p=0,m=0,h=Ij;break;case 3:{let e=t.filter(([e,t])=>!D(e,t));if(!e.length)break;O(e.reduce((e,[t,n])=>{let r;if(m===2)r=!0;else if(h&&m===1)r=t<h[0];else{let e=x(),n=T(t),i=E(t);r=p!==1&&m===0?n+i<=e:n<e&&n+i<e+s}return r&&(e+=n-E(t)),e},0));for(let[t,n]of e){let e=E(t),r=Jj(y,t,n);i&&(_+=r?n:n-e)}i&&s&&_>s&&(O(((e,t)=>{let n=0,r=[];e.t.forEach((e,i)=>{e!==-1&&(r.push(e),i<t&&n++)}),e.i=-1;let i=Hj(r),a=i.length,o=a/2|0,s=a%2==0?(i[o-1]+i[o])/2:i[o],c=e.o;return((e.o=s)-c)*Rj(t-n,0)})(y,Xj(y,S()))),i=!1),g=3,r=!0;break}case 4:s!==t&&(s||(v=r=!0),s=t,g=3);break;case 5:t[1]?(O(Zj(y,t[0],!0)),m=2,g=1):(Zj(y,t[0]),g=1);break;case 6:c=t;break;case 7:m=1;break;case 8:h=C(t,t+s),g=1}g&&(o=1+(2147483647&o),n&&d&&(u+=d,d=0),b.forEach(([e,t])=>{g&e&&t(r)}))}}},oM=setTimeout,sM=(e,t)=>t?-e:e,cM=(e,t,n,r,i,a)=>{let o=Date.now,s=0,c=!1,l=!1,u=!1,d=!1,f=(()=>{let t,n=()=>{t!=Ij&&clearTimeout(t)},r=()=>{n(),t=oM(()=>{t=Ij,(()=>{if(c||l)return c=!1,void f();u=!1,e.B(2)})()},150)};return r.J=n,r})(),p=()=>{s=o(),u&&(d=!0),a&&e.B(6,a()),e.B(1,r()),f()},m=t=>{if(c||!e.M()||t.ctrlKey)return;let r=o()-s;150>r&&50<r&&(n?t.deltaX:t.deltaY)&&(c=!0)},h=()=>{l=!0,u=d=!1},g=()=>{l=!1,nM()&&(u=!0)};return t.addEventListener(`scroll`,p),t.addEventListener(`wheel`,m,{passive:!0}),t.addEventListener(`touchstart`,h,{passive:!0}),t.addEventListener(`touchend`,g,{passive:!0}),{A:()=>{t.removeEventListener(`scroll`,p),t.removeEventListener(`wheel`,m),t.removeEventListener(`touchstart`,h),t.removeEventListener(`touchend`,g),f.J()},L:()=>{let[t,n]=e.H();t&&(i(t,n,d),d=!1,n&&e.p()>e.h()&&e.B(1,r()))}}},lM=(e,t,n)=>{let r;return[async(i,a)=>{if(!await t())return;r&&r();let o=()=>{let[t,n]=Wj();return r=()=>{n(!1)},e.p()&&oM(r,150),[t,e.W(2,()=>{n(!0)})]};if(a&&rM())e.B(8,i()),Uj(async()=>{for(;;){let t=!0;for(let[n,r]=e.S();n<=r;n++)if(e.I(n)){t=!1;break}if(t)break;let[n,r]=o();try{if(!await n)return}finally{r()}}e.B(7),n(i(),a)});else for(;;){let[t,r]=o();try{if(e.B(7),n(i()),!await t)return}finally{r()}}},()=>{r&&r()}]},uM=(e,t)=>{let n,r,i=Wj(),a=!1,o=t?`scrollLeft`:`scrollTop`,s=t?`overflowX`:`overflowY`,[c,l]=lM(e,()=>i[0],(e,r)=>{e=sM(e,a),r?n.scrollTo({[t?`left`:`top`]:e,behavior:`smooth`}):n[o]=e});return{N(c,u){n=u,t&&(a=getComputedStyle(u).direction===`rtl`),r=cM(e,u,t,()=>sM(u[o],a),(t,n,r)=>{if(r){let e=u.style,t=e[s];e[s]=`hidden`,oM(()=>{e[s]=t})}u[o]=sM(e.C()+t,a),n&&l()}),i[1](!0)},v(){r&&r.A(),i[1](!1),i=Wj()},P:()=>a,V(e){c(()=>e)},X(t){t+=e.C(),c(()=>t)},Y(t,{align:n,smooth:r,offset:i=0}={}){if(t=Vj(t,0,e.T()-1),n===`nearest`){let r=e.k(t),i=e.C();if(r<i)n=`start`;else{if(!(r+e.R(t)>i+e.p()))return;n=`end`}}c(()=>i+e.O()+e.k(t)+(n===`end`?e.R(t)-e.p():n===`center`?(e.R(t)-e.p())/2:0),r)},q:()=>{r&&r.L()}}},dM=e=>{let t;return{j(n){(t||=new(tM(eM(n))).ResizeObserver(e)).observe(n)},D(e){t.unobserve(e)},A(){t&&t.disconnect()}}},fM=(e,t)=>{let n,r=t?`width`:`height`,i=new WeakMap,a=dM(t=>{let a=[];for(let{target:o,contentRect:s}of t)if(o.offsetParent)if(o===n)e.B(4,s[r]);else{let e=i.get(o);e!=Ij&&a.push([e,s[r]])}a.length&&e.B(3,a)});return{G(e){a.j(n=e)},U:(e,t)=>(i.set(e,t),a.j(e),()=>{i.delete(e),a.D(e)}),v:a.A}},pM=Qj?Z.useLayoutEffect:Z.useEffect,mM=`current`,hM=(e,t)=>{if(Array.isArray(e))for(let n of e)hM(n,t);else e==null||typeof e==`boolean`||t.push(e)},gM=(e,t)=>e.key??`_`+t,_M=e=>{let t=(0,Z.useRef)(null);return t[mM]||(t[mM]=e())},vM=e=>{let t=(0,Z.useRef)(e);return pM(()=>{t[mM]=e},[e]),t},yM=(0,Z.memo)(({Z:e,ee:t,te:n,oe:r,ne:i,re:a,se:o,ie:s})=>{let c=(0,Z.useRef)(null);pM(()=>t(c[mM],n),[n]);let l=(0,Z.useMemo)(()=>{let e={contain:`layout style`,position:i&&s?void 0:`absolute`,[o?`height`:`width`]:`100%`,[o?`top`:`left`]:0,[o?`left`:`top`]:r,visibility:!i||s?void 0:`hidden`};return o&&(e.display=`inline-flex`),e},[r,i,s,o]);return(0,Q.jsx)(a,typeof a==`string`?{ref:c,style:l,children:e}:{ref:c,style:l,index:n,children:e})}),bM=(e,t)=>(0,Z.useMemo)(()=>{if(typeof e==`function`)return[n=>e(t[n],n),t.length];let n=(e=>{let t=[];return hM(e,t),t})(e);return[e=>n[e],n.length]},[e,t]),xM=(0,Z.forwardRef)(({children:e,data:t,bufferSize:n,itemSize:r,shift:i,horizontal:a,keepMounted:o,cache:s,startMargin:c=0,ssrCount:l,as:u=`div`,item:d=`div`,scrollRef:f,onScroll:p,onScrollEnd:m},h)=>{let[g,_]=bM(e,t),v=(0,Z.useRef)(null),y=(0,Z.useRef)(!!l),b=vM(p),x=vM(m),[S,C,w,T]=_M(()=>{let e=!!a,t=aM(_,r,l,s,!r);return[t,fM(t,e),uM(t,e),e]});_!==S.T()&&S.B(5,[_,i]),c!==S.O()&&S.B(6,c);let[E,D]=(0,Z.useReducer)(S.m,void 0,S.m),O=S.M(),k=S.h(),A=w.P(),j=[],M=e=>{let t=g(e);return(0,Q.jsx)(yM,{ee:C.U,te:e,oe:S.k(e,A),ne:S.I(e),re:d,Z:t,se:T,ie:y[mM]},gM(t,e))};if(pM(()=>{y[mM]=!1,S.W(1,e=>{e?(0,zd.flushSync)(D):D()}),S.W(4,()=>{b[mM]&&b[mM](S.C())}),S.W(8,()=>{x[mM]&&x[mM]()});let e=v[mM],t=t=>{C.G(t),w.N(e,t)};return f?Uj(()=>{f[mM]&&t(f[mM])}):t(e.parentElement),()=>{S.v(),C.v(),w.v()}},[]),pM(()=>{w.q()},[E]),(0,Z.useImperativeHandle)(h,()=>({get cache(){return S._()},get scrollOffset(){return S.C()},get scrollSize(){return iM(S)},get viewportSize(){return S.p()},findItemIndex:S.$,getItemOffset:S.k,getItemSize:S.R,scrollToIndex:w.Y,scrollTo:w.V,scrollBy:w.X}),[]),o){let e=new Set(o);for(let[t,r]=S.S(n);t<=r;t++)e.add(t);Hj([...e]).forEach(e=>{j.push(M(e))})}else for(let[e,t]=S.S(n);e<=t;e++)j.push(M(e));return(0,Q.jsx)(u,{ref:v,style:{contain:`size style`,overflowAnchor:`none`,flex:`none`,position:`relative`,width:T?k:`100%`,height:T?`100%`:k,pointerEvents:O?`none`:void 0},children:j})});function SM(e,t){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(``),o=(0,Z.useRef)(!1);return{editing:n,draft:i,setDraft:a,begin:()=>{a(e),o.current=!1,r(!0)},commit:()=>{if(o.current)return;o.current=!0,r(!1);let n=i.trim();n.length===0||n===e||t(n)},cancel:()=>{o.current=!0,r(!1)}}}function CM({editor:e,className:t}){return(0,Q.jsx)(`input`,{"data-slot":`title-input`,"aria-label":`Task title`,autoFocus:!0,value:e.draft,onChange:t=>e.setDraft(t.target.value),onBlur:e.commit,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),e.commit()):t.key===`Escape`&&(t.preventDefault(),e.cancel())},className:D(`w-full min-w-0 rounded-sm border border-border bg-card px-1.5 py-0.5 outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`,t)})}function wM(e){let t=new Map,n=new Set,r;return{begin:e,editingId:()=>r?.id??null,subscribeSelection(e){return n.add(e),()=>{n.delete(e)}},snapshot:e=>r?.id===e?r.editor:null,subscribe(e,n){let r=t.get(e);return r||(r=new Set,t.set(e,r)),r.add(n),()=>{r.delete(n),r.size||t.delete(e)}},publish(e,i){let a=r?.id;if(r=e&&i.editing?{id:e,editor:i}:void 0,a!==r?.id)for(let e of n)e();for(let e of new Set([a,r?.id]))if(e)for(let n of t.get(e)??[])n()}}}var TM=(0,Z.createContext)(null),EM={editing:!1,draft:``,begin(){},setDraft(){},commit(){},cancel(){}};function DM({children:e,runs:t,onRename:n}){let[r,i]=(0,Z.useState)(),[a]=(0,Z.useState)(()=>wM(e=>i({run:e}))),o=t.find(e=>e.id===r?.run.id),s=SM(o?W(o):``,e=>{o&&n(o.id,e)});return(0,Z.useEffect)(()=>{r&&s.begin()},[r]),(0,Z.useEffect)(()=>{r&&!o&&(s.cancel(),i(void 0))},[r,o,s]),(0,Z.useLayoutEffect)(()=>{a.publish(o?.id,s)},[a,o?.id,s]),(0,Q.jsx)(TM,{value:a,children:e})}function OM(e){let t=(0,Z.useContext)(TM);if(!t)throw Error(`Task title editor needs its page provider`);return{...(0,Z.useSyncExternalStore)((0,Z.useCallback)(n=>t.subscribe(e.id,n),[t,e.id]),(0,Z.useCallback)(()=>t.snapshot(e.id),[t,e.id]))??EM,begin:()=>t.begin(e)}}var kM=()=>null;function AM(){return jM}function jM(){}function MM(){let e=(0,Z.useContext)(TM);return(0,Z.useSyncExternalStore)(e?.subscribeSelection??AM,e?.editingId??kM)}var NM=(0,Z.createContext)(null);function PM(e,t,n=!1){let[r,i]=(0,Z.useState)(null),a=(0,Z.useRef)(new Map),o=(0,Z.useCallback)((e,t)=>{t?a.current.set(e,t):a.current.delete(e)},[]),s=(0,Z.useCallback)(e=>[...a.current.values()].some(t=>t.includes(e)),[]);return{props:FM(e,t,i,n?s:void 0),value:(0,Z.useMemo)(()=>({focused:r,revision:t,registerList:n?o:void 0}),[r,t,o,n])}}function FM(e,t,n,r){let i=(0,Z.useRef)(r);(0,Z.useLayoutEffect)(()=>{i.current=r});let a=(0,Z.useRef)(null),o=(0,Z.useRef)(null);return(0,Z.useLayoutEffect)(()=>{let e=o.current;if(!e||e.element.isConnected||document.activeElement!==document.body)return;let t=()=>{o.current===e&&(o.current=null,n?.(null))},r=()=>{let n=e.project?`${e.project}/${e.runId}`:e.runId;if(i.current&&!i.current(n)||document.activeElement!==document.body||e.element.isConnected)return t(),!0;let r=[...a.current?.querySelectorAll(`[data-run-id]`)??[]].filter(t=>t.dataset.runId===e.runId&&t.dataset.project===e.project).flatMap(e=>[...e.querySelectorAll(`a,button,input`)]),o=r.find(t=>e.control?t.dataset.taskControl===e.control:t.tagName===e.tag&&t.getAttribute(`aria-label`)===e.label)??r.find(e=>e.tagName===`A`);return o?.focus({preventScroll:!0}),!!o&&document.activeElement===o};if(r()||!a.current)return;let s=()=>{l.disconnect(),document.removeEventListener(`pointerdown`,c,!0),document.removeEventListener(`keydown`,c,!0)},c=()=>{t(),s()},l=new MutationObserver(()=>{r()&&s()});return document.addEventListener(`pointerdown`,c,!0),document.addEventListener(`keydown`,c,!0),l.observe(a.current,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`]}),s},[e,t]),{ref:a,onFocusCapture:e=>{let t=e.target,r=t.closest(`[data-run-id]`);o.current=r?{element:t,runId:r.dataset.runId,project:r.dataset.project,control:t.dataset.taskControl??null,label:t.getAttribute(`aria-label`),tag:t.tagName}:null,n?.(r?r.dataset.project?`${r.dataset.project}/${r.dataset.runId}`:r.dataset.runId:null)},onBlurCapture:e=>{let t=e.target,r=e.currentTarget;queueMicrotask(()=>{o.current?.element===t&&t.isConnected&&!r.contains(document.activeElement)&&(o.current=null,n?.(null))})}}}var IM=new WeakMap;function LM({items:e,itemKey:t,children:r,itemSize:i}){let[a]=n(),o=(0,Z.useRef)(null),s=(0,Z.useRef)(null),[c,l]=(0,Z.useState)({available:null,margin:0}),[u,d]=(0,Z.useState)(null),f=MM(),p=(0,Z.useContext)(NM),m=e.map(t),h=Mj(e.length,a.get(`tasks`)),g=c.available===!0&&h,_=(0,Z.useRef)(Symbol(`task-list`)),v=(0,Z.useRef)(()=>{});(0,Z.useLayoutEffect)(()=>{p?.registerList?.(_.current,m);let e=b.current;return e&&IM.set(e,{keys:m,handle:s,measure:()=>v.current()}),()=>{p?.registerList?.(_.current,null),e&&IM.delete(e)}});let y=FM(String(g),void 0,void 0,e=>m.includes(e)),b=y.ref;return(0,Z.useLayoutEffect)(()=>{let e=b.current,t=e?.closest(`[data-slot="main"]`);if(o.current=t??null,!e||!t){l(e=>e.available===!1?e:{available:!1,margin:0});return}let n=null,r=()=>{let r=Math.max(0,e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop);r!==n&&(n=r,l(e=>e.available===!0&&e.margin===r?e:{available:!0,margin:r}))};r(),v.current=r;let i=new ResizeObserver(r);for(let n=e;n&&n!==t;n=n.parentElement){i.observe(n);for(let e of n.parentElement?.children??[])i.observe(e)}return i.observe(t),()=>i.disconnect()},[]),(0,Q.jsx)(`div`,{ref:b,"data-slot":`task-list-items`,"data-virtualized":g,onFocusCapture:e=>{y.onFocusCapture(e),d(e.target.closest(`[data-task-item]`)?.dataset.taskItem??null)},onBlurCapture:e=>{y.onBlurCapture(e),e.relatedTarget&&!e.currentTarget.contains(e.relatedTarget)&&d(null)},children:g?(0,Q.jsx)(zM,{itemSize:i,items:e,keys:m,handle:s,scroll:o,margin:c.margin,focused:p?.focused??u,editing:f,children:r}):(c.available===null&&h?[]:e).map((t,n)=>(0,Q.jsx)(`div`,{"data-task-item":m[n],"data-first":n===0,"data-last":n===e.length-1,className:`task-list-flat-item`,children:r(t,n)},m[n]))})}function RM({layout:e,revision:t,visibilityRevision:n=``,children:r,...i}){let a=PM(e,t,!0);return(0,Q.jsx)(NM,{value:a.value,children:(0,Q.jsx)(VM,{revision:t,visibilityRevision:`${e}:${n}`,children:(0,Q.jsx)(`div`,{...i,...a.props,children:r})})})}function zM({items:e,keys:t,handle:n,scroll:r,margin:i,focused:a,editing:o,children:s,itemSize:c}){let[l,u]=(0,Z.useState)(!1),d=BM(r);return(0,Z.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=new ResizeObserver(e=>{e.some(e=>e.contentRect.height>0)&&(u(!0),t.disconnect())});return t.observe(e),()=>t.disconnect()},[r]),(0,Q.jsx)(xM,{ref:n,...c===void 0?{}:{itemSize:c},scrollRef:r,startMargin:i,keepMounted:[...new Set([...!l&&e.length?[0]:[],...Nj(t,a),...Nj(t,d),...Nj(t,o)])],data:e,children:(n,r)=>(0,Q.jsx)(`div`,{"data-task-item":t[r],"data-first":r===0,"data-last":r===e.length-1,children:s(n,r)},t[r])})}function BM(e){let[t,n]=(0,Z.useState)(null),r=(0,Z.useRef)(t);return(0,Z.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let i=e=>{if(e.target!==t)return;let i=t.contains(document.activeElement)?document.activeElement.closest(`[data-task-item]`)?.dataset.taskItem??null:null;i!==r.current&&(r.current=i,(0,zd.flushSync)(()=>n(i)))};return document.addEventListener(`scroll`,i,{capture:!0,passive:!0}),()=>document.removeEventListener(`scroll`,i,{capture:!0})},[e]),t}var VM=class extends Z.Component{root={current:null};owner(){return this.root.current?.closest(`[data-slot="main"]`)??null}getSnapshotBeforeUpdate(e){if(e.revision===this.props.revision&&e.visibilityRevision===this.props.visibilityRevision)return null;let t=this.owner();if(!t||!this.root.current)return null;let n=t.getBoundingClientRect();for(let e of this.root.current.querySelectorAll(`[data-task-item]`)){let r=e.getBoundingClientRect();if(r.bottom>n.top&&r.top<n.bottom)return{key:e.dataset.taskItem,top:r.top,scrollTop:t.scrollTop}}return{key:null,top:0,scrollTop:t.scrollTop}}componentDidUpdate(e,t,n){let r=this.owner();if(!n||!r)return;let i=n.key===null?null:this.currentTop(n.key);i!==null&&Math.abs(i-n.top)>.5&&(r.scrollTop+=i-n.top),queueMicrotask(()=>{r.isConnected&&(0,zd.flushSync)(()=>{for(let e of this.root.current?.querySelectorAll(`[data-slot="task-list-items"]`)??[])IM.get(e)?.measure();r.scrollTop!==n.scrollTop&&r.dispatchEvent(new Event(`scroll`))})})}currentTop(e){for(let t of this.root.current?.querySelectorAll(`[data-task-item]`)??[])if(t.dataset.taskItem===e)return t.getBoundingClientRect().top;for(let t of this.root.current?.querySelectorAll(`[data-slot="task-list-items"]`)??[]){let n=IM.get(t),r=n?.keys.indexOf(e)??-1,i=n?.handle.current;if(r>=0&&i)return t.getBoundingClientRect().top+i.getItemOffset(r)}return null}render(){return(0,Q.jsx)(`div`,{ref:this.root,style:{display:`contents`},children:this.props.children})}};function HM(e){return e===void 0?`unknown`:new Intl.NumberFormat().format(e)}function UM(e,t){return`Input tokens: ${HM(e)}; output tokens: ${HM(t)}`}function WM(e,t,n=`compact`){let r=e===void 0?`—`:Ba(e),i=t===void 0?`—`:Ba(t);return n===`table`?`${r} / ${i}`:`IN ${r} · OUT ${i}`}function GM({inputTokens:e,outputTokens:t,variant:n=`compact`,omitWhenUnknown:r=!0,className:i,title:a}){return r&&e===void 0&&t===void 0?null:(0,Q.jsx)(`span`,{"data-slot":`directional-usage`,"aria-label":UM(e,t),title:a,className:D(`font-mono tabular-nums`,i),children:WM(e,t,n)})}function KM({className:e,dot:t,shape:n=`filled`,pulse:r=!1,children:i,...a}){return(0,Q.jsxs)(`span`,{"data-slot":`pill`,className:D(`inline-flex items-center gap-1.5 rounded-full bg-muted px-2.5 py-[3px] text-xs font-medium whitespace-nowrap text-muted-foreground`,e),...a,children:[t?(0,Q.jsx)($,{tone:t,shape:n,pulse:r}):null,i]})}var qM=[{value:`all`,label:`All`},{value:`direct`,label:`Direct tasks`},{value:`automations`,label:`Automations`}];function JM(e){return e?qM:qM.filter(e=>e.value!==`automations`)}function YM(e,t){return e===`automations`&&!t?`all`:e}function XM(e){return e===`direct`||e===`automations`?e:`all`}function ZM(e,t){return t===`all`||Ie(e)===(t===`automations`)}function QM(e){return e===`all`?void 0:e===`automations`}function $M(e,t){let n={all:0,direct:0,automations:0};for(let r of e)zr(r)||r.archived!==(t===`archived`)||(n.all+=1,Ie(r)?n.automations+=1:n.direct+=1);return n}function eN(e,t,n,r,i){let a=Vr(e).archived,o=a>=200;if(n===`all`)return i??(o?`200+`:a);let s=$M(t,`archived`)[n];return o&&r!==!1?`${s}+`:s}function tN(e){return e.rows.map(e=>e.run)}function nN(e,t){switch(e){case`Needs you`:return`pending`;case`Working`:return`running`;case`Archived`:return`neutral`;case`Finished`:return t.some(e=>xe(e).bucket===`error`)?`danger`:`success`}}function rN(e,t,n){return Rr(e,t,Lr(n))}var iN=(e,t)=>JSON.stringify([e,t]);function aN(e,t,n){let r=new Map,i=e.map(e=>{let{run:t}=e,n=iN(t.projectId,t.id);r.set(n,e);let i=t.delegation;return{...t,id:n,...i&&`parentRunId`in i?{delegation:{...i,parentRunId:iN(t.projectId,i.parentRunId)}}:{}}}),a=new Map;for(let e of n){let t=a.get(e.projectId);t?t.push(e):a.set(e.projectId,[e])}let o=new Map;for(let[e,t]of a)for(let[n,r]of Lr(t))o.set(iN(e,n),r);let s=e=>r.get(e.id);return Rr(i,t,o).map(e=>({label:e.label,rows:e.rows.map(e=>({kind:`run`,run:s(e.run),queuePosition:e.queuePosition}))}))}function oN(e){return[e.run]}var sN=/^- \S+ — (?:(?:turn complete|step ".*" complete|step ".*" ended without done|session idle-closed) — |worktree setup (?:done in|failed —|skipped —) )/;function cN(e,t=3){let n=Be(e,`## Progress log`);if(n<0)return[];let r=[];for(let i of e.slice(We(e,n)).split(`
17
+ `)){if(r.length>=t||i.startsWith(`## `))break;let e=i.trim();!e||sN.test(e)||r.push(e.replace(/^[-*] /,``))}return r}function lN({origin:e,counts:t,automations:n,onChange:r}){return(0,Q.jsx)(`div`,{role:`group`,"aria-label":`Task origin`,"data-slot":`origin-filter`,className:`flex flex-wrap items-center gap-1.5`,children:JM(n).map(n=>{let i=n.value===e;return(0,Q.jsxs)(`button`,{type:`button`,"data-origin":n.value,"aria-pressed":i,onClick:()=>r(n.value),className:D(`inline-flex min-h-11 items-center gap-1.5 rounded-full border border-border px-3 text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,i&&`border-accent-strong bg-accent-strong/10 text-accent-text`),children:[n.label,` `,(0,Q.jsx)(`span`,{className:`tabular-nums`,children:t[n.value]})]},n.value)})})}function uN({onExpand:e,onCollapse:t}){return(0,Q.jsxs)(`div`,{"data-slot":`group-fold-controls`,className:`hidden flex-wrap items-center gap-2 md:ml-auto md:flex`,children:[(0,Q.jsx)(E,{type:`button`,variant:`ghost`,className:`min-h-11`,"data-action":`expand-groups`,onClick:e,children:`Expand groups`}),(0,Q.jsx)(E,{type:`button`,variant:`ghost`,className:`min-h-11`,"data-action":`collapse-groups`,onClick:t,children:`Collapse groups`})]})}function dN({origin:e,counts:t,automations:n,onChange:r,labels:i,onSetAll:a}){return(0,Q.jsxs)(`div`,{"data-slot":`task-origin-row`,className:`flex flex-wrap items-center gap-2.5`,children:[(0,Q.jsx)(lN,{origin:e,counts:t,automations:n,onChange:r}),i.length>0?(0,Q.jsx)(uN,{onExpand:()=>a(i,!1),onCollapse:()=>a(i,!0)}):null]})}var fN={pending:`needs you`,running:`working`,success:`finished`,danger:`contains failed tasks`,neutral:`archived`};function pN({id:e,label:t,count:n,tone:r,folded:i,collapsed:a,onToggle:o,children:s}){let c=a?Ji:_a;return(0,Q.jsxs)(`section`,{"data-slot":`task-status-group`,"data-bucket":t,"data-folded":i,"data-tone":r,"aria-labelledby":`${e}-heading`,className:`flex flex-col gap-2.5`,children:[(0,Q.jsx)(`h2`,{id:`${e}-heading`,className:`text-[13px] font-semibold text-foreground`,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`status-group-toggle`,"aria-expanded":!a,"aria-controls":`${e}-rows`,"aria-label":`${t} ${n}${r===`danger`?`, contains failed tasks`:``}`,onClick:o,className:`inline-flex min-h-11 items-center gap-2 rounded-md pr-2 hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,children:[(0,Q.jsx)(c,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,Q.jsx)($,{tone:r,role:`img`,"aria-label":fN[r],title:fN[r]}),(0,Q.jsx)(`span`,{children:t}),` `,(0,Q.jsx)(`span`,{className:`font-normal tabular-nums text-muted-foreground`,children:n})]})}),(0,Q.jsx)(`div`,{id:`${e}-rows`,hidden:a,children:a?null:s})]})}function mN({automationId:e,automationName:t,project:n}){let r=e===void 0?`Direct task`:t??e;return(0,Q.jsxs)(`span`,{"data-slot":`task-origin`,"data-origin":e===void 0?`direct`:`automation`,className:`flex min-w-0 flex-wrap items-center gap-x-1.5 text-xs text-muted-foreground`,children:[n?(0,Q.jsxs)(Q.Fragment,{children:[n,(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`·`})]}):null,(0,Q.jsx)(`span`,{className:`min-w-0 break-words`,title:e===void 0?void 0:`Automation ${e}`,children:r})]})}function hN({projectId:e,runId:t,status:n,error:r,open:i}){let a=rr(e,t,!0),o=a.data===void 0?[]:cN(a.data);return(0,Q.jsxs)(`div`,{"data-slot":`task-preview`,className:`flex flex-col gap-3 rounded-md bg-muted/50 p-4 text-xs`,children:[(0,Q.jsx)(`p`,{className:`font-medium text-foreground first-letter:uppercase`,children:n}),r?(0,Q.jsx)(`p`,{"data-slot":`task-preview-error`,className:`break-words text-danger`,children:r}):null,a.isPending?(0,Q.jsx)(`p`,{role:`status`,className:`text-muted-foreground`,children:`Loading latest progress…`}):a.isError?(0,Q.jsx)(`p`,{"data-slot":`task-preview-unavailable`,className:`text-muted-foreground`,children:`Latest progress is unavailable.`}):o.length===0?(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:`No progress recorded yet.`}):(0,Q.jsx)(`ul`,{"aria-label":`Latest progress`,className:`flex flex-col gap-1 text-muted-foreground`,children:o.map((e,t)=>(0,Q.jsx)(`li`,{className:`break-words`,children:e},t))}),(0,Q.jsx)(`div`,{children:i})]})}var gN=`cez-task-list-folds`,_N=`cez-task-list-folds-changed`;function vN(e,t,n=new Set){let[r,i]=(0,Z.useState)(()=>Kb(gN));(0,Z.useEffect)(()=>{let e=e=>{e instanceof StorageEvent&&e.key!==null&&e.key!==`cez-task-list-folds`||i(e instanceof CustomEvent?e.detail:Kb(gN))};return window.addEventListener(`storage`,e),window.addEventListener(_N,e),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(_N,e)}},[]);let a=(0,Z.useCallback)(n=>JSON.stringify([e,t,n]),[e,t]),o=(0,Z.useCallback)(e=>{i(t=>{let n=e(t);return qb(n,gN),queueMicrotask(()=>window.dispatchEvent(new CustomEvent(_N,{detail:n}))),n})},[]),s=e=>r[a(e)]===!0;return{isFolded:s,isCollapsed:e=>s(e)&&!n.has(e),toggle:e=>o(t=>({...t,[a(e)]:t[a(e)]!==!0})),setAll:(e,t)=>o(n=>({...n,...Object.fromEntries(e.map(e=>[a(e),t]))})),only:(0,Z.useCallback)((e,t)=>o(n=>({...n,...Object.fromEntries(t.map(t=>[a(t),t!==e]))})),[o,a])}}function yN(e,t,n,r){let i=vN(e,t,n),a=(0,Z.useRef)(r);a.current=r;let[o,s]=qk(),c=t===`active`?Fr(o.get(ai)):null,{only:l}=i;return(0,Z.useEffect)(()=>{c!==null&&(l(c,Or),a.current?.(),s(e=>(e.delete(ai),e)))},[c,l,s]),i}function bN(e){let t=e?.capabilities,n=t?.tokenMetrics!==!1;return{tokens:t?.tokenUsageMetrics??n,cost:t?.costMetrics??n}}function xN(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function SN(){let e=L(),t=Cr(),n=Z.useRef(0),r=Z.useRef(0),i=Z.useRef(Promise.resolve()),a=Z.useMemo(()=>Oj(t.data?.taskTable?.expandedColumns),[t.data?.taskTable?.expandedColumns]),o=Z.useCallback(t=>{if(!Tj.find(e=>e.id===t)?.canFold)return;let a=e.getQueryData(V.uiState);if(a===void 0)return;let o=xN(a?.taskTable),s={...o,expandedColumns:Aj(o.expandedColumns,t)};e.setQueryData(V.uiState,{...a,taskTable:s});let c=++n.current;r.current=c;let l=i.current.then(async()=>{let t=await ht({taskTable:s},{keepalive:!0});c===r.current&&e.setQueryData(V.uiState,t)});i.current=l.catch(t=>{G(t instanceof Error?t.message:String(t),{tone:`danger`}),c===r.current&&e.invalidateQueries({queryKey:V.uiState})})},[e]);return{expandedColumns:a,isExpanded:Z.useCallback(e=>kj(e,a),[a]),toggleColumn:o,isPending:t.isPending}}var CN=()=>void 0;function wN({runs:e,view:t,onViewChange:n,onArchiveFinished:r,archivePending:i=!1,onMarkAllRead:a,onRename:o,onTogglePin:s,now:c=Date.now(),showTokens:l=!0,showCost:u=!0,expandedColumns:d=Oj(void 0),onToggleColumn:f=()=>void 0,columnsPending:p=!1,projectName:m,error:h,onRetry:g,archivedPages:_,archivedTotal:v,onArchivedSearch:y,origin:b,onOriginChange:x,automations:S,urlQuery:C=``,onQueryChange:w,foldScope:T=`project`,automationName:D=CN}){let[O,k]=TN(C,w);Z.useEffect(()=>{y?.(O.trim())},[y,O]);let[A,j]=DN(b,x,S),[M,ee]=Z.useState(!1),te=ci(),{expandedRuns:N,toggleExpandedRun:P}=wj(),ne=Z.useRef(null),F=Z.useMemo(()=>e??[],[e]),I=Z.useMemo(()=>ON({all:F,view:t,query:O,origin:A,archivedPages:_,archivedTotal:v,automationName:D}),[F,t,O,A,_,v,D]),{groups:re,needle:ie}=I,ae=Z.useMemo(()=>jj({tokens:l,cost:u}),[l,u]),oe=yN(T,t,new Set(ie?re.map(e=>e.label):[]),()=>k(``)),se=t===`archived`?void 0:s;return(0,Q.jsx)(DM,{runs:_?[...F,..._.runs]:F,onRename:o,children:(0,Q.jsxs)(RM,{layout:`${te}:${M}`,revision:re,visibilityRevision:JSON.stringify([Br.map(oe.isCollapsed),[...N].sort(),t,d]),"data-route":`tasks`,"data-presentation":M?`resources`:`summary`,className:`flex min-h-full flex-col gap-[22px] px-[18px] pt-6 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-9`,children:[(0,Q.jsxs)(`header`,{ref:ne,className:`flex shrink-0 flex-col gap-[22px]`,children:[(0,Q.jsx)(EN,{projectName:m,detailedTable:M}),(0,Q.jsxs)(`div`,{className:`flex gap-6 border-b border-border`,children:[(0,Q.jsx)(BN,{view:`active`,current:t,onSelect:n,count:I.activeCount,children:`Active`}),(0,Q.jsx)(BN,{view:`archived`,current:t,onSelect:n,count:I.archivedCount,children:`Archived`})]}),(0,Q.jsxs)(`div`,{"data-slot":`tasks-toolbar`,className:`flex flex-wrap items-center gap-2.5`,children:[(0,Q.jsx)(AN,{view:t,unread:I.unread,finished:I.finished,archivePending:i,headerRef:ne,onMarkAllRead:()=>a(QM(A)),onArchiveFinished:()=>r(QM(A))}),(0,Q.jsxs)(`div`,{className:`relative order-first w-full md:w-auto md:min-w-64 md:flex-1`,children:[(0,Q.jsx)(Fi,{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:O,onChange:e=>k(e.target.value),placeholder:`Search tasks or automations…`,"aria-label":`Search tasks`,className:`h-11 w-full rounded-md border border-input bg-card pr-3 pl-8 text-[13px] text-foreground outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`})]}),(0,Q.jsx)(jN,{columns:ae,expandedColumns:d,columnsPending:p,onToggleColumn:f,detailedTable:M,onToggleDetailed:()=>ee(e=>!e)}),(0,Q.jsx)(E,{asChild:!0,"data-slot":`new-task-inline`,className:`min-h-11 inline-flex max-md:hidden`,children:(0,Q.jsxs)(Y,{to:`/new`,children:[(0,Q.jsx)(Bi,{"aria-hidden":`true`}),`New task`]})})]}),(0,Q.jsx)(dN,{origin:A,counts:I.originTotals,automations:S,onChange:j,labels:re.map(e=>e.label),onSetAll:oe.setAll})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[e===void 0?(0,Q.jsx)(NN,{error:h,onRetry:g}):(0,Q.jsx)(MN,{view:t,query:O,origin:A,onShowAll:()=>{k(``),j(`all`)},caption:kN(I.visibleCount,I.incomplete,ie),captionOnPhones:ie!==``||I.incomplete,groups:re,folds:oe,grouped:{desktop:te,expandedRuns:N,toggleExpandedRun:P,detailedTable:M,columns:ae,expandedColumns:d,onToggleColumn:f,columnsPending:p,onRename:o,onTogglePin:se,now:c,showTokens:l,showCost:u,automationName:D}}),t===`archived`&&_?(0,Q.jsx)(PN,{pages:_}):null]})]})})}function TN(e,t){let[n,r]=Z.useState(e),i=Z.useRef(e),a=Z.useRef(e),o=Z.useRef([]);return Z.useEffect(()=>{if(e===i.current)return;i.current=e;let t=o.current.indexOf(e);o.current=t===-1?[]:o.current.slice(t+1),t===-1&&e!==a.current&&r(e)},[e]),Z.useEffect(()=>{a.current=n.trim(),t?.(n,e=>{o.current.push(e)})},[t,n]),[n,r]}function EN({projectName:e,detailedTable:t}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h1`,{className:`text-[30px] font-semibold tracking-tight`,children:`Project tasks`}),(0,Q.jsxs)(`p`,{className:`text-[13px] text-muted-foreground`,children:[e?`${e} · `:``,t?`Every resource column shown. Fold columns without losing the saved view.`:`Review runs, pull requests and resource usage.`]})]})}function DN(e,t,n){let[r,i]=Z.useState(`all`);return[YM(e??r,n),t??i]}function ON({all:e,view:t,query:n,origin:r,archivedPages:i,archivedTotal:a,automationName:o}){let s=n.trim(),c=e=>e.automationId===void 0?``:o(e.automationId)??e.automationId,l=i?.query===s,u=new Set(l?i.runs.map(e=>e.id):[]),d=Nr(e,l||s===``?i?.runs??[]:[]).slice(e.length),f=pi(e,n,c),p=new Set(f.map(e=>e.id)),m=pi(e.filter(e=>u.has(e.id)&&!p.has(e.id)),``),h=e=>ZM(e,r),g=rN([...f,...m,...pi(d,``)].filter(h),t,e),_=Nr(e,i?.query===``?i.runs:[]),v=Vr(e).archived>=200,y=e.filter(h);return{groups:g,needle:s,visibleCount:g.reduce((e,t)=>e+tN(t).length,0),originTotals:$M(_,t),activeCount:$M(e,`active`)[r],archivedCount:eN(e,_,r,i?.plainHasMore,a),incomplete:t===`archived`&&v&&i?.hasMore!==!1,finished:$r(y),unread:mh(y)}}function kN(e,t,n){return`${e} ${e===1?`task`:`tasks`}${t?` loaded`:``}${n?` matching “${n}”`:``}`}function AN({view:e,unread:t,finished:n,archivePending:r,headerRef:i,onMarkAllRead:a,onArchiveFinished:o}){let s=Z.useRef(!1),[c,l]=Z.useState(!1),u=n>0||r;return Z.useEffect(()=>{let e=window.matchMedia?.(mi);if(!e)return;let t=()=>{e.matches&&l(!1)};return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,Q.jsxs)(Q.Fragment,{children:[t>0?(0,Q.jsxs)(E,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`mark-all-read`,className:`hidden md:inline-flex`,onClick:a,children:[(0,Q.jsx)(lu,{className:`size-3.5`,"aria-hidden":`true`}),`Mark all read`,` `,(0,Q.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:t})]}):null,e===`active`&&n>0?(0,Q.jsxs)(E,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`archive-finished`,className:`inline-flex`,disabled:r,"aria-busy":r,onClick:o,children:[(0,Q.jsx)(ha,{className:`size-3.5`,"aria-hidden":`true`}),`Archive finished`,` `,(0,Q.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:n})]}):null,e===`active`&&(u||t>0)?(0,Q.jsxs)(Do,{open:c,onOpenChange:l,children:[(0,Q.jsx)(wo,{asChild:!0,children:(0,Q.jsx)(E,{type:`button`,variant:`ghost`,size:`icon`,className:`md:hidden`,"aria-label":`Task actions`,"aria-busy":r,children:(0,Q.jsx)(Tu,{"aria-hidden":`true`})})}),(0,Q.jsxs)(To,{align:`end`,className:`md:hidden`,onCloseAutoFocus:e=>{(s.current||window.matchMedia?.(`(min-width: 48rem)`).matches)&&(e.preventDefault(),s.current=!1,i.current?.querySelector(`[data-view="active"]`)?.focus())},children:[u?(0,Q.jsxs)(bo,{disabled:r||n===0,onSelect:()=>{s.current=!0,o()},children:[(0,Q.jsx)(ha,{"aria-hidden":`true`}),r?`Archiving…`:`Archive finished (${n})`]}):null,t>0?(0,Q.jsxs)(bo,{onSelect:a,children:[(0,Q.jsx)(lu,{"aria-hidden":`true`}),`Mark all read (${t})`]}):null]})]}):null]})}function jN({columns:e,expandedColumns:t,columnsPending:n,onToggleColumn:r,detailedTable:i,onToggleDetailed:a}){return(0,Q.jsxs)(fi,{children:[(0,Q.jsx)(li,{asChild:!0,children:(0,Q.jsx)(E,{"data-slot":`task-columns-trigger`,variant:`outline`,className:`hidden min-h-11 md:inline-flex`,children:`Columns`})}),(0,Q.jsxs)(Qr,{align:`end`,className:`w-72`,children:[(0,Q.jsx)(`h2`,{className:`mb-2 text-base font-medium`,children:`Visible columns`}),(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-muted-foreground`,children:`Status and Task · Always visible`}),(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:e.filter(e=>e.canFold).map(e=>(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Q.jsx)(`input`,{"data-column-toggle":e.id,type:`checkbox`,checked:kj(e.id,t),disabled:n,onChange:()=>r(e.id)}),e.id===`diff`?`Diff`:e.id===`reference`?`Reference`:e.id===`memory`?`Memory`:e.label]},e.id))}),(0,Q.jsx)(`p`,{className:`mt-4 text-xs text-muted-foreground`,children:`Saved automatically. Tokens and cost appear only when supported.`}),(0,Q.jsx)(E,{variant:`outline`,className:`mt-4`,onClick:a,children:i?`Summary view`:`Resource columns`})]})]})}function MN({view:e,query:t,origin:n,onShowAll:r,caption:i,captionOnPhones:a,groups:o,folds:s,grouped:c}){return o.length===0?(0,Q.jsx)(FN,{view:e,query:t,origin:n,onShowAll:r}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{"data-slot":`tasks-result-count`,className:D(`mb-3 text-[12px] text-muted-foreground tabular-nums`,!a&&`max-md:hidden`),children:i}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-[22px]`,children:o.map(t=>{let n=tN(t);return(0,Q.jsx)(pN,{id:`tasks-group-${e}-${t.label.replaceAll(` `,`-`)}`,label:t.label,count:n.length,tone:nN(t.label,n),folded:s.isFolded(t.label),collapsed:s.isCollapsed(t.label),onToggle:()=>s.toggle(t.label),children:(0,Q.jsx)(RN,{group:t,...c})},t.label)})}),(0,Q.jsx)(`p`,{className:`mt-[22px] text-[11px] text-muted-foreground`,children:`Resource details—including tokens, cost, CPU and peak memory—are available when a task row is expanded.`})]})}function NN({error:e,onRetry:t}){return e?(0,Q.jsxs)(`div`,{role:`alert`,className:`rounded-xl border border-border bg-card p-6`,children:[(0,Q.jsx)(`h2`,{className:`text-lg`,children:`Could not load tasks`}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:e}),(0,Q.jsx)(E,{variant:`outline`,className:`mt-4`,onClick:t,children:`Retry`})]}):(0,Q.jsx)(`div`,{role:`status`,"aria-label":`Loading tasks`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:`Loading tasks…`})}function PN({pages:e}){return e.failed?(0,Q.jsxs)(`p`,{role:`alert`,"data-slot":`archived-older-error`,className:`mt-3.5 flex items-center justify-center gap-2.5 text-[13px] text-muted-foreground`,children:[`Could not load older archived tasks.`,(0,Q.jsx)(E,{variant:`outline`,className:`min-h-11`,onClick:e.onLoadMore,children:`Retry`})]}):e.hasMore?(0,Q.jsx)(E,{"data-slot":`archived-older`,variant:`outline`,className:`mt-3.5 min-h-11 self-center`,disabled:e.loading,onClick:e.onLoadMore,children:e.loading?`Loading older archived…`:`Show older archived`}):null}function FN({view:e,query:t,origin:n=`all`,onShowAll:r}){let i=t.trim(),a=i||n!==`all`?`search-miss`:e===`archived`?`archive`:`no-tasks`;return(0,Q.jsx)(`div`,{"data-slot":`tasks-empty`,"data-empty-kind":a,className:`flex flex-1 flex-col`,children:a===`search-miss`?(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(Xa,{}),tone:`neutral`,title:`No matching tasks`,subtitle:i?`No tasks match “${i}”.`:n===`automations`?`No automation started a task here.`:`No task here was started directly.`,actions:r?(0,Q.jsx)(E,{variant:`outline`,className:`min-h-11`,"data-action":`clear-task-filters`,onClick:r,children:`Show all tasks`}):void 0}):a===`archive`?(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(ha,{}),tone:`neutral`,title:`Nothing archived yet`,subtitle:`Finished tasks you archive land here.`}):(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(Vu,{}),tone:`primary`,backdrop:!0,title:`No tasks yet`,subtitle:`Describe a task to get started.`,actions:(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsxs)(Y,{to:`/new`,"data-new-task-action":!0,children:[(0,Q.jsx)(Bi,{"aria-hidden":`true`}),`New task`]})})})})}function IN({rows:e,onRename:t,onTogglePin:n,now:r,showTokens:i,showCost:a,automationName:o,expandedRuns:s,toggleExpandedRun:c}){let l=Fj(e.map(({run:e})=>e.id),s);return(0,Q.jsx)(`div`,{"data-slot":`tasks-summary`,children:(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-5`,role:`table`,"aria-rowcount":l.rowCount,children:[(0,Q.jsx)(`div`,{role:`row`,"aria-rowindex":1,className:`task-summary-grid`,children:[`Task`,`Workflow`,`Changes`,`Pull request`,`Started`].map(e=>(0,Q.jsx)(`div`,{role:`columnheader`,className:`h-8 border-b border-border text-start text-[12px] font-medium uppercase text-muted-foreground`,children:e},e))}),(0,Q.jsx)(LM,{itemSize:103,items:e,itemKey:({run:e})=>e.id,children:({run:e,queuePosition:u},d)=>(0,Q.jsx)(LN,{run:e,queuePosition:u,rowIndex:l.indexes[d],onRename:t,onTogglePin:n,now:r,showTokens:i,showCost:a,automationName:o,open:s.has(e.id),toggleExpandedRun:c})})]})})}var LN=Z.memo(function({run:e,queuePosition:t,rowIndex:n,onRename:r,onTogglePin:i,now:a,showTokens:o,showCost:s,automationName:c,open:l,toggleExpandedRun:u}){let d=xe(e),f=si(e),p=yi(e),m=`task-resources-${e.id}`;return(0,Q.jsxs)(`div`,{role:`rowgroup`,children:[(0,Q.jsxs)(`div`,{role:`row`,"aria-rowindex":n,"data-status":e.status,"data-slot":`task-summary-row`,"data-run-id":e.id,className:`task-summary-grid group/row`,children:[(0,Q.jsxs)(`div`,{role:`cell`,className:`py-5 pr-4 align-top`,children:[(0,Q.jsx)(YN,{run:e,to:`/tasks/${e.id}`,onRename:r,onTogglePin:i}),(0,Q.jsx)(`div`,{className:`mt-1`,children:(0,Q.jsx)(qN,{run:e,automationName:c})}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,"data-task-control":`resources`,"aria-label":`${l?`Hide`:`Show`} resources for ${W(e)}`,"aria-expanded":l,"aria-controls":m,"aria-describedby":`summary-status-${e.id}`,onClick:()=>u(e.id),className:`inline-flex min-h-[26px] items-center gap-1 rounded-md p-0 text-[11px] text-muted-foreground hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,children:(0,Q.jsxs)(KM,{id:`summary-status-${e.id}`,dot:d.tone,shape:d.shape,pulse:d.pulse,children:[d.label,f?` ${f.label}`:``]})}),e.status===`queued`&&t!==null?(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`#`,t,` in queue`]}):null]})]}),(0,Q.jsx)(`div`,{role:`cell`,className:`truncate pr-3 text-xs text-muted-foreground`,title:vi(e),children:vi(e)}),(0,Q.jsx)(`div`,{role:`cell`,className:`pr-2 text-xs`,children:e.diffStat?(0,Q.jsx)(Vy,{stat:e.diffStat}):(0,Q.jsx)(tP,{})}),(0,Q.jsx)(`div`,{role:`cell`,className:`pr-2`,children:p?(0,Q.jsx)(yb,{run:e,reference:p,compact:!0}):(0,Q.jsx)(tP,{})}),(0,Q.jsx)(`div`,{role:`cell`,className:`text-xs text-muted-foreground`,children:za(e.startedAt??e.createdAt,a)})]}),l?(0,Q.jsx)(`div`,{role:`row`,"aria-rowindex":n+1,"data-run-id":e.id,children:(0,Q.jsx)(`div`,{role:`cell`,"aria-colspan":5,className:`border-b border-border pb-5`,children:(0,Q.jsxs)(`div`,{id:m,className:`flex flex-col gap-3`,children:[(0,Q.jsx)(hN,{runId:e.id,status:d.label,error:e.error,open:(0,Q.jsx)(E,{asChild:!0,variant:`outline`,className:`min-h-11`,children:(0,Q.jsxs)(Y,{"data-task-control":`open`,to:`/tasks/${e.id}`,children:[`Open task`,(0,Q.jsxs)(`span`,{className:`sr-only`,children:[`: `,W(e)]})]})})}),(0,Q.jsx)(`div`,{className:`rounded-md bg-muted/50 p-4`,children:(0,Q.jsx)(zN,{run:e,showTokens:o,showCost:s})})]})})}):null]})});function RN({desktop:e,expandedRuns:t,toggleExpandedRun:n,group:r,detailedTable:i,columns:a,expandedColumns:o,onToggleColumn:s,columnsPending:c,onRename:l,onTogglePin:u,now:d,showTokens:f,showCost:p,automationName:m}){let h=r.rows.flatMap(e=>oN(e).map(t=>({run:t,queuePosition:t.status===`queued`?e.queuePosition:null})));return(0,Q.jsxs)(Q.Fragment,{children:[e&&!i?(0,Q.jsx)(IN,{expandedRuns:t,toggleExpandedRun:n,rows:h,onRename:l,onTogglePin:u,now:d,showTokens:f,showCost:p,automationName:m}):null,e&&i?(0,Q.jsx)(`div`,{"data-slot":`tasks-table`,className:`overflow-x-auto rounded-lg border border-border bg-card`,children:(0,Q.jsx)(Ng,{children:(0,Q.jsxs)(`div`,{role:`table`,"aria-rowcount":h.length+1,className:`task-resource-grid`,style:Pj(a,o),children:[(0,Q.jsx)(`div`,{role:`row`,"aria-rowindex":1,className:`task-resource-row`,children:a.map(e=>(0,Q.jsx)(HN,{column:e,expanded:kj(e.id,o),onToggle:s,disabled:c},e.id))}),(0,Q.jsx)(LM,{itemSize:50,items:h,itemKey:({run:e})=>e.id,children:({run:e,queuePosition:t},n)=>(0,Q.jsx)(GN,{rowIndex:n+2,run:e,queuePosition:t,onRename:l,onTogglePin:u,now:d,columns:a,expandedColumns:o,automationName:m})})]})})}):null,e?null:(0,Q.jsx)(`div`,{"data-slot":`task-cards`,className:`flex flex-col rounded-lg border border-border bg-card p-5`,children:(0,Q.jsx)(LM,{itemSize:178,items:h,itemKey:({run:e})=>e.id,children:({run:e,queuePosition:r})=>(0,Q.jsx)($N,{resourcesOpen:t.has(e.id),onToggleResources:n,run:e,queuePosition:r,now:d,showTokens:f,showCost:p,onTogglePin:u,automationName:m},e.id)})})]})}function zN({run:e,showTokens:t,showCost:n}){let r=Ar(e,Nl(e.id));return(0,Q.jsxs)(`dl`,{className:`grid grid-cols-2 gap-4 text-xs md:grid-cols-4`,children:[t?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Tokens in / out`}),(0,Q.jsx)(`dd`,{className:`mt-1`,children:(0,Q.jsx)(GM,{inputTokens:e.inputTokens,outputTokens:e.outputTokens,omitWhenUnknown:!1})})]}):null,n?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Cost`}),(0,Q.jsx)(`dd`,{className:`mt-1`,children:oi(e.costUsd)||`—`})]}):null,(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`CPU`}),(0,Q.jsx)(`dd`,{className:`mt-1`,title:r.cpu.title,children:r.cpu.text||`—`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Memory`}),(0,Q.jsx)(`dd`,{className:`mt-1`,title:r.mem.title,children:r.mem.text||`—`})]}),e.branch?(0,Q.jsxs)(`div`,{className:`col-span-2`,children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Branch`}),(0,Q.jsx)(`dd`,{className:`mt-1 break-all`,children:e.branch})]}):null]})}function BN({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:D(`flex min-h-11 items-center justify-center gap-1.5 border-b-2 border-transparent text-[13px] font-medium text-muted-foreground`,a&&`border-accent-strong font-semibold text-accent-text`),children:[i,r===0?null:(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[` · `,r]})]})}function VN({children:e,right:t=!1,columnId:n,folded:r=!1}){return(0,Q.jsx)(`div`,{role:`columnheader`,"data-column-id":n,"data-folded":r||void 0,className:D(`h-[38px] border-b border-border px-2.5 text-left text-[11px] font-semibold tracking-[0.05em] whitespace-nowrap text-supporting-foreground uppercase first:pl-4 last:pr-4`,t&&`text-right`,r&&`px-0 first:pl-0 last:pr-0`),children:e})}function HN({column:e,expanded:t,onToggle:n,disabled:r}){if(!e.canFold)return(0,Q.jsx)(VN,{columnId:e.id,right:e.align===`right`,children:e.label});let i=t?`Fold`:`Expand`;return(0,Q.jsx)(VN,{columnId:e.id,right:e.align===`right`,folded:!t,children:(0,Q.jsxs)(Pg,{children:[(0,Q.jsx)(Fg,{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:D(`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)(mu,{className:`size-3 opacity-55`,"aria-hidden":`true`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(UN,{icon:e.icon}),(0,Q.jsx)(hu,{className:`size-3 opacity-70`,"aria-hidden":`true`})]})})}),(0,Q.jsxs)(Ig,{side:`top`,children:[e.label,` · `,i,` column`]})]})})}function UN({icon:e}){let t=`size-3.5`;switch(e){case`workflow`:return(0,Q.jsx)(Zi,{className:t,"aria-hidden":`true`});case`branch`:return(0,Q.jsx)(na,{className:t,"aria-hidden":`true`});case`diff`:return(0,Q.jsx)(ya,{className:t,"aria-hidden":`true`});case`reference`:return(0,Q.jsx)(Bu,{className:t,"aria-hidden":`true`});case`tokens`:return(0,Q.jsx)(vu,{className:t,"aria-hidden":`true`});case`cost`:return(0,Q.jsx)(wu,{className:t,"aria-hidden":`true`});case`cpu`:return(0,Q.jsx)(Gi,{className:t,"aria-hidden":`true`});case`memory`:return(0,Q.jsx)(Hu,{className:t,"aria-hidden":`true`});case`started`:return(0,Q.jsx)(gu,{className:t,"aria-hidden":`true`});default:return null}}var WN=`h-[88px] border-b border-border px-2.5 whitespace-nowrap first:pl-4 last:pr-4`,GN=Z.memo(function({rowIndex:e,run:t,queuePosition:n,onRename:r,onTogglePin:i,now:a,columns:o,expandedColumns:s,automationName:c}){let l=_s(),u=xe(t),d=si(t),f=`/tasks/${t.id}`,p=oi(t.costUsd),m=yi(t);return(0,Q.jsx)(`div`,{role:`row`,"aria-rowindex":e,"data-slot":`task-table-row`,"data-run-id":t.id,onClick:e=>{e.target.closest(`a, button, input`)||l(f)},className:`task-resource-row group/row cursor-pointer hover:bg-muted`,children:o.map(e=>{if(e.id===`memory`)return null;if(e.id===`cpu`){let r=kj(`cpu`,s),i=kj(`memory`,s);return n!==null&&(r||i)?(0,Q.jsxs)(`div`,{role:`cell`,"data-slot":`queue-note`,"data-column-id":`cpu-memory`,"aria-colspan":2,style:{gridColumn:`span 2`},className:D(WN,`text-right font-mono text-[11px] text-supporting-foreground`),children:[`#`,n,` in queue`]},e.id):(0,Q.jsx)(XN,{run:t,cpuExpanded:r,memoryExpanded:i},e.id)}return(0,Q.jsx)(KN,{column:e,expanded:kj(e.id,s),run:t,attention:u,scheduled:d,reference:m,cost:p,to:f,onRename:r,onTogglePin:i,now:a,automationName:c},e.id)})})});function KN({column:e,expanded:t,run:n,attention:r,scheduled:i,reference:a,cost:o,to:s,onRename:c,onTogglePin:l,now:u,automationName:d}){if(!t)return(0,Q.jsx)(JN,{column:e.id});switch(e.id){case`status`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:D(WN,`overflow-hidden`),children:(0,Q.jsx)(KM,{dot:r.tone,shape:r.shape,pulse:r.pulse,title:i?.title??r.label,className:`w-full max-w-full overflow-hidden`,children:(0,Q.jsxs)(`span`,{className:`min-w-0 truncate`,children:[r.label,i?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(`span`,{className:`tabular-nums`,children:i.label})]}):null]})})});case`task`:return(0,Q.jsxs)(`div`,{role:`cell`,"data-column-id":e.id,className:D(WN,`min-w-[320px] max-w-0 whitespace-normal`),children:[(0,Q.jsx)(YN,{run:n,to:s,onRename:c,onTogglePin:l}),(0,Q.jsx)(`div`,{className:`mt-1`,children:(0,Q.jsx)(qN,{run:n,automationName:d})})]});case`workflow`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:D(WN,`max-w-0 truncate text-[13px] text-muted-foreground`),children:vi(n)});case`branch`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:D(WN,`max-w-0 overflow-hidden`),children:n.branch?(0,Q.jsx)(nP,{branch:n.branch}):(0,Q.jsx)(tP,{})});case`diff`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:D(WN,`overflow-hidden`),children:n.diffStat?(0,Q.jsx)(Vy,{stat:n.diffStat,compact:!0,className:`block max-w-full`}):(0,Q.jsx)(tP,{})});case`reference`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:D(WN,`overflow-hidden`),children:a?(0,Q.jsx)(yb,{run:n,reference:a,compact:!0,className:`max-w-full overflow-hidden`}):(0,Q.jsx)(tP,{})});case`tokens`:let t=UM(n.inputTokens,n.outputTokens);return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:D(WN,`text-right text-xs text-muted-foreground`),children:(0,Q.jsx)(GM,{inputTokens:n.inputTokens,outputTokens:n.outputTokens,variant:`table`,omitWhenUnknown:!1,title:t,className:`block max-w-full overflow-hidden text-ellipsis`})});case`cost`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:D(WN,`text-right font-mono text-xs text-muted-foreground tabular-nums`),children:o?(0,Q.jsx)(QN,{text:o,accessibleText:`$${n.costUsd}`}):(0,Q.jsx)(tP,{})});case`started`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:D(WN,`text-right text-xs text-supporting-foreground tabular-nums`),children:za(n.startedAt??n.createdAt,u)});default:return null}}function qN({run:e,automationName:t}){return(0,Q.jsx)(mN,{automationId:e.automationId,automationName:e.automationId===void 0?void 0:t(e.automationId)})}function JN({column:e}){return(0,Q.jsx)(`div`,{role:`cell`,"aria-hidden":`true`,"data-column-id":e,"data-folded":`true`,className:D(WN,`px-0 first:pl-0 last:pr-0`)})}function YN({run:e,to:t,onTogglePin:n}){let r=W(e),i=OM(e),a=Zr(e),o=ph(e);return i.editing?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-slot":`table-title-editor`,children:[(0,Q.jsx)(CM,{editor:i,className:`basis-full text-[13px] font-medium`}),(0,Q.jsx)(E,{size:`sm`,"aria-label":`Save title`,onMouseDown:e=>e.preventDefault(),onClick:i.commit,children:`Save`}),(0,Q.jsx)(E,{size:`sm`,variant:`outline`,"aria-label":`Cancel rename`,onMouseDown:e=>e.preventDefault(),onClick:i.cancel,children:`Cancel`})]}):(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.delegation?.role===`worker`?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Worker`}):null,(0,Q.jsx)(Y,{"data-task-control":`title`,to:t,title:r,className:D(`line-clamp-2 min-w-0 flex-1 whitespace-normal rounded-sm text-[13px] leading-[18px] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,a?`font-semibold text-foreground`:o?`font-normal text-foreground`:`font-medium`),children:r}),a?(0,Q.jsx)($,{tone:hh(e),role:`img`,"aria-label":`unread`,title:`Unread — not opened since it finished`,className:`shrink-0`}):null,(0,Q.jsx)(`button`,{type:`button`,"data-slot":`row-rename`,"aria-label":`Rename task`,onClick:i.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)(Ju,{className:`size-3`,"aria-hidden":`true`})}),n?(0,Q.jsx)(Cb,{pinned:!!e.pinned,onToggle:t=>n(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 XN({run:e,cpuExpanded:t,memoryExpanded:n}){let r=Ar(e,Nl(e.id));return(0,Q.jsxs)(Q.Fragment,{children:[t?(0,Q.jsx)(ZN,{column:`cpu`,cell:r.cpu}):(0,Q.jsx)(JN,{column:`cpu`}),n?(0,Q.jsx)(ZN,{column:`memory`,cell:r.mem}):(0,Q.jsx)(JN,{column:`memory`})]})}function ZN({column:e,cell:t}){let n=t.text&&t.title?`${t.text}; ${t.title}`:t.text;return(0,Q.jsx)(`div`,{role:`cell`,"data-usage":e===`memory`?`mem`:e,"data-column-id":e,"data-usage-kind":t.kind,className:D(WN,`overflow-hidden`,`text-right font-mono tabular-nums`,t.kind===`live`&&`bg-accent-strong/5 text-xs font-medium text-foreground`,t.kind===`peak`&&`text-[11px] text-supporting-foreground`,t.kind===`none`&&`text-xs text-soft-foreground`),children:(0,Q.jsx)(QN,{text:t.text||`—`,accessibleText:n||void 0})})}function QN({text:e,accessibleText:t}){return(0,Q.jsx)(`span`,{"data-slot":`bounded-metric`,...t?{"aria-label":t,title:t}:{},className:`block max-w-full overflow-hidden text-ellipsis`,children:e})}var $N=Z.memo(function({resourcesOpen:e,onToggleResources:t,run:n,queuePosition:r,now:i,showTokens:a,showCost:o,onTogglePin:s,automationName:c}){let l=_s(),u=xe(n),d=si(n),f=`/tasks/${n.id}`,p=yi(n),m=Zr(n),h=ph(n);return(0,Q.jsxs)(`div`,{"data-slot":`task-card`,"data-status":n.status,"data-run-id":n.id,onClick:e=>{e.target.closest(`a, button`)||l(f)},className:`cursor-pointer border-b border-border py-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2.5`,children:[(0,Q.jsx)(`button`,{"data-slot":`mobile-resources-toggle`,"data-task-control":`resources`,type:`button`,"aria-controls":`mobile-resources-${n.id}`,"aria-describedby":`mobile-status-${n.id}`,"aria-label":e?`Hide resources`:`Show resources`,title:e?`Hide resources`:`Show resources`,"aria-expanded":e,onClick:()=>t(n.id),children:(0,Q.jsxs)(KM,{id:`mobile-status-${n.id}`,dot:u.tone,shape:u.shape,pulse:u.pulse,className:`mt-px shrink-0`,title:d?.title,children:[u.label,d?(0,Q.jsx)(`span`,{className:`tabular-nums`,children:d.label}):null]})}),(0,Q.jsxs)(Y,{"data-task-control":`title`,to:f,className:D(`order-first w-full min-w-0 rounded-sm text-[14px] leading-[1.35] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,m?`font-semibold text-foreground`:h?`font-normal text-foreground`:`font-medium`),children:[n.delegation?.role===`worker`?(0,Q.jsx)(`span`,{className:`mr-2 text-xs text-muted-foreground`,children:`Worker`}):null,W(n)]}),m?(0,Q.jsx)($,{tone:hh(n),role:`img`,"aria-label":`unread`,title:`Unread — not opened since it finished`,className:`mt-1.5 shrink-0`}):null,(0,Q.jsx)(`div`,{className:`order-first w-full`,children:(0,Q.jsx)(qN,{run:n,automationName:c})}),s?(0,Q.jsx)(Cb,{pinned:!!n.pinned,onToggle:e=>s(n,e),className:`mt-px`}):null]}),(0,Q.jsxs)(`div`,{"data-slot":`mobile-task-meta`,className:`mt-4 grid grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-3 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:vi(n)}),r===null?n.diffStat?(0,Q.jsx)(Vy,{stat:n.diffStat}):(0,Q.jsx)(tP,{}):(0,Q.jsxs)(`span`,{"data-slot":`queue-note`,children:[`#`,r,` in queue`]}),(0,Q.jsx)(`span`,{children:za(n.startedAt??n.createdAt,i)})]}),p?(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(yb,{run:n,reference:p})}):null,e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(hN,{runId:n.id,status:u.label,error:n.error,open:(0,Q.jsx)(E,{asChild:!0,variant:`outline`,className:`min-h-11`,children:(0,Q.jsxs)(Y,{"data-task-control":`open`,to:f,children:[`Open task`,(0,Q.jsxs)(`span`,{className:`sr-only`,children:[`: `,W(n)]})]})})})}),(0,Q.jsx)(eP,{run:n,showTokens:a,showCost:o})]}):null]})});function eP({run:e,showTokens:t,showCost:n}){let r=Ar(e,Nl(e.id));return(0,Q.jsxs)(`dl`,{id:`mobile-resources-${e.id}`,className:`mt-3 grid grid-cols-2 gap-3 rounded-md bg-muted p-3 text-xs`,children:[e.branch?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`Branch`}),(0,Q.jsx)(`dd`,{children:e.branch})]}):null,(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`CPU`}),(0,Q.jsx)(`dd`,{children:r.cpu.text||`—`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`Memory`}),(0,Q.jsx)(`dd`,{children:r.mem.text||`—`})]}),t?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`IN / OUT`}),(0,Q.jsx)(`dd`,{children:(0,Q.jsx)(GM,{inputTokens:e.inputTokens,outputTokens:e.outputTokens})})]}):null,n?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`Cost`}),(0,Q.jsx)(`dd`,{children:oi(e.costUsd)||`—`})]}):null]})}function tP(){return(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`})}function nP({branch:e}){return(0,Q.jsx)(`span`,{title:e,className:`block truncate rounded-[6px] bg-muted px-1.5 py-0.5 font-mono text-[11px] font-medium text-muted-foreground`,children:e})}function rP(){let e=Nn(),t=bN(On().data),n=js(),{view:r,setView:i,origin:a,setOrigin:o,urlQuery:s,writeQuery:c}=aP(),l=Hn(),u=L(),d=cP(e.data,r),f=jn({mutationFn:e=>Je(Bn(),void 0,e),onSuccess:()=>l.invalidateAfter(`runs`,()=>Bn()),onError:e=>G(e.message,{tone:`danger`})}),p=jn({mutationFn:e=>Ae(e),onSuccess:()=>u.invalidateQueries({queryKey:H.runs.all}),onError:e=>G(e.message,{tone:`danger`})}),m=jn({mutationFn:({id:e,title:t})=>Ct(e,{title:t}),onSuccess:()=>u.invalidateQueries({queryKey:H.runs.all}),onError:e=>G(e.message,{tone:`danger`})}),h=Pn(),g=Hb(3e4),_=SN(),v=cr(),y=fr(void 0,{retryOnMount:!1}),b=An({retryOnMount:!1}).data?.projects?.find(e=>e.id===v)?.name,x=[...e.data??[],...d.pages?.runs??[]].some(e=>e.automationId!==void 0),S=dr([void 0],n&&x),C=Z.useCallback(e=>S(void 0,e),[S]),w=Z.useMemo(()=>v===void 0?[]:(e.data??[]).flatMap(e=>{let t=yi(e);return t?[{projectId:v,kind:t.kind,number:t.number}]:[]}),[e.data,v]),T=Z.useCallback((e,t)=>m.mutate({id:e,title:t}),[m.mutate]),E=Z.useCallback((e,t)=>h.mutate({id:e.id,pinned:t}),[h.mutate]);return(0,Q.jsx)(Ga,{projectId:v,repoBase:y,requests:w,children:(0,Q.jsx)(wN,{runs:e.data,projectName:b,error:e.error?.message,onRetry:()=>void e.refetch(),view:r,onViewChange:i,origin:a,onOriginChange:o,automations:n,urlQuery:s,onQueryChange:c,foldScope:`project:${v??`default`}`,automationName:C,onArchiveFinished:e=>{f.isPending||f.mutate(e)},archivePending:f.isPending,onMarkAllRead:e=>p.mutate(e),onRename:T,onTogglePin:E,now:g,showTokens:t.tokens,showCost:t.cost,expandedColumns:_.expandedColumns,onToggleColumn:_.toggleColumn,columnsPending:_.isPending,archivedPages:d.pages,archivedTotal:d.total,onArchivedSearch:d.search})})}function iP(e,t){return n=>(t===null?n.delete(e):n.set(e,t),n)}function aP(){let[e,t]=qk(),n=e.get(`archived`)===`1`?`archived`:`active`,r=XM(e.get(`origin`)),[i,a]=Z.useState(n),[o,s]=Z.useState(r);Z.useEffect(()=>a(n),[n]),Z.useEffect(()=>s(r),[r]);let c=e.get(`q`)??``,l=Z.useRef(void 0);return Z.useEffect(()=>{let e=l;return()=>clearTimeout(e.current)},[]),{view:i,setView:e=>{a(e),t(iP(`archived`,e===`archived`?`1`:null))},origin:o,setOrigin:e=>{s(e),t(iP(`origin`,e===`all`?null:e))},urlQuery:c,writeQuery:Z.useCallback((e,n)=>{clearTimeout(l.current);let r=e.trim();l.current=setTimeout(()=>t(e=>{let t=e.get(`q`),i=iP(`q`,r===``?null:r)(e);return i.get(`q`)!==t&&n(r),i}),oP)},[t])}}var oP=250,sP=150;function cP(e,t){Hn();let n=L(),[r,i]=Z.useState(``),[a,o]=Z.useState(``);Z.useEffect(()=>{let e=setTimeout(()=>o(r),sP);return()=>clearTimeout(e)},[r]);let s=e!==void 0&&Vr(e).archived>=200,{data:c,isError:l,isPlaceholderData:u,hasNextPage:d,isFetchingNextPage:f,fetchNextPage:p,refetch:m}=ar(a,t===`archived`&&(a!==``||s)),h=c?.pages,g=Z.useMemo(()=>h||l?{runs:(h??[]).flatMap(e=>e.runs),query:u?null:a,hasMore:d,loading:f,onLoadMore:()=>void(h?p():m()),failed:l}:void 0,[h,l,u,a,d,f,p,m]),_=a===``?h:n.getQueryData(H.runs.archived(``))?.pages,v=_===void 0?void 0:_.at(-1)?.nextCursor!=null;return{pages:Z.useMemo(()=>g&&{...g,plainHasMore:v},[g,v]),total:_?.[0]?.total,search:i}}function lP({projects:e,perProjectLimit:t}){return e.length===0?null:(0,Q.jsxs)(`p`,{"data-slot":`global-tasks-truncated`,className:`text-[11px] text-soft-foreground`,children:[`Showing every active task and the newest `,t,` archived tasks per project — older archived tasks in`,` `,e.join(`, `),` are in that project’s own Tasks page.`]})}function uP({registry:e}){return e.length<=1?null:(0,Q.jsxs)(`section`,{"data-slot":`other-projects`,className:`rounded-lg border border-border bg-card p-5`,children:[(0,Q.jsx)(`h2`,{className:`text-base font-semibold`,children:`Other projects`}),(0,Q.jsx)(`div`,{className:`mt-3 flex flex-col divide-y divide-border`,children:e.map(e=>(0,Q.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-[13px]`,children:e.name}),(0,Q.jsxs)(C,{to:gs(e.id,`/`),className:`inline-flex min-h-11 shrink-0 items-center rounded-md px-3 text-xs text-accent-text hover:bg-accent-strong/10`,children:[`View tasks`,(0,Q.jsxs)(`span`,{className:`sr-only`,children:[` for `,e.name]})]})]},e.id))})]})}function dP({view:e,filtered:t}){return t?(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(Xa,{}),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)(ha,{}),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)(Vu,{}),tone:`neutral`,title:`No tasks yet`,subtitle:`Start a task in any project and it shows up here.`})}function fP({groupBy:e,filterDetailsOpen:t,message:n,onRetry:r}){return(0,Q.jsx)(`div`,{"data-route":`global-tasks`,"data-presentation":e===`none`?`summary`:`cards`,"data-filter-details":t,className:`flex min-h-full flex-col gap-[22px] px-[18px] pt-6 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-9`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(Ti,{}),tone:`danger`,title:`Tasks across projects did not load`,subtitle:n,actions:(0,Q.jsx)(E,{variant:`outline`,onClick:r,children:`Retry`})})})}function pP({slot:e,label:t,options:n,selected:r,onToggle:i,onClear:a,searchPlaceholder:o,emptyLabel:s=`Nothing to filter by`}){let[c,l]=Z.useState(!1),u=r.length>0,d=r.length===1?n.find(e=>e.value===r[0])?.label??r[0]:`${r.length} selected`;return(0,Q.jsxs)(fi,{open:c,onOpenChange:l,children:[(0,Q.jsx)(li,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`facet-${e}`,"data-active":u?`true`:void 0,"aria-label":`Filter by ${t.toLowerCase()}`,className:D(`inline-flex h-7 items-center gap-1.5 rounded-full border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,u&&`border-accent-strong/40 bg-accent-strong/10 text-foreground`),children:[(0,Q.jsx)(`span`,{className:D(u&&`text-soft-foreground`),children:t}),u?(0,Q.jsx)(`span`,{className:`max-w-[140px] truncate font-semibold`,children:d}):null,(0,Q.jsx)(fu,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Q.jsxs)(Qr,{align:`start`,className:`w-64 p-0`,"data-testid":`facet-${e}-menu`,children:[(0,Q.jsxs)(Ls,{children:[(0,Q.jsx)(Rs,{placeholder:o??`Search ${t.toLowerCase()}…`}),(0,Q.jsxs)(Es,{children:[(0,Q.jsx)(Ns,{children:s}),(0,Q.jsx)(Ps,{children:n.map(e=>{let t=r.includes(e.value);return(0,Q.jsxs)(fc,{value:e.label,onSelect:()=>i(e.value),"data-slot":`facet-option`,"data-value":e.value,"aria-checked":t,role:`option`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:D(`flex size-4 shrink-0 items-center justify-center rounded-[4px] border`,t?`border-accent-strong bg-accent-strong text-accent-strong-foreground`:`border-input`),children:t?(0,Q.jsx)(uu,{className:`size-3`}):null}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.count===void 0?null:(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-soft-foreground tabular-nums`,children:e.count})]},e.value)})})]})]}),u?(0,Q.jsx)(`div`,{className:`border-t border-border p-1`,children:(0,Q.jsxs)(`button`,{type:`button`,"data-action":`facet-${e}-clear`,onClick:()=>a(),className:`w-full rounded-sm px-2 py-1.5 text-left text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[`Clear `,t.toLowerCase()]})}):null]})]})}function mP({label:e,count:t,selected:n,onToggle:r,slot:i,tone:a=`neutral`}){return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":i,"data-selected":n?`true`:void 0,"aria-pressed":n,onClick:r,className:D(`inline-flex h-7 items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium transition-colors`,a===`tag`?`border-accent-strong/25 bg-accent-strong/10 text-accent-text hover:bg-accent-strong/20`:`border-border bg-card text-muted-foreground hover:bg-muted hover:text-foreground`,n&&`border-accent-strong bg-accent-strong text-accent-strong-foreground hover:bg-accent-strong`),children:[e,t===void 0?null:(0,Q.jsx)(`span`,{className:D(`font-mono text-[11px] tabular-nums`,!n&&`text-soft-foreground`),children:t})]})}function hP({slot:e,label:t,value:n,options:r,onChange:i,size:a=`compact`}){return(0,Q.jsx)(`div`,{"data-slot":e,role:`group`,"aria-label":t,className:`inline-flex gap-0.5 rounded-md bg-muted p-[3px]`,children:r.map(e=>{let t=e.value===n;return(0,Q.jsx)(`button`,{type:`button`,"data-value":e.value,"aria-pressed":t,disabled:e.disabled,title:e.title,onClick:()=>i(e.value),className:D(`flex h-6 items-center justify-center rounded-[6px] px-2.5 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,a===`touch`&&`h-11 px-4 text-[13px]`,t&&`bg-card font-semibold text-foreground shadow-xs`),children:e.label},e.value)})})}var gP=` untagged`,_P=[{value:`project`,label:`Project`},{value:`tag`,label:`Tag`},{value:`status`,label:`Status`},{value:`workflow`,label:`Workflow`}];function vP(e,t){return e===t?`none`:t}var yP={query:``,tags:[],statuses:[],workflows:[]};function bP(e,t){let{origin:n,...r}=e;return t===`all`?r:{...r,origin:t}}function xP(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function SP(e){return(e.projects?.length??0)+e.tags.length+e.statuses.length+e.workflows.length+(e.origin===void 0||e.origin===`all`?0:1)}function CP(e){return e.query.trim()!==``||SP(e)>0}function wP(e){return SP(e.filters)+(e.filters.query.trim()===``?0:1)+(e.groupBy===`none`?0:1)}function TP(e){return wP(e)>0}function EP(e,t){let n=new Map(t.map(e=>[e.id,e]));return e.filter(e=>!zr(e)).map(e=>{let t=n.get(e.projectId);return{run:e,project:t,projectName:t?.name||e.projectId,tags:t?.tags??[]}})}function DP(e){let t=new Set;for(let n of e)t.add(n.run.workflow);return[...t].sort((e,t)=>e.localeCompare(t))}function OP(e){let t=new Set;for(let n of e)t.add(n.run.status);return[...t].sort((e,t)=>e.localeCompare(t))}function kP(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 AP=e=>e.tags.length===0?[gP]:e.tags,jP=(e,t)=>e.length===0||t.some(t=>e.includes(t)),MP=(e,t)=>{if(t.length===0)return!0;let n=AP(e).map(e=>e.toLowerCase());return t.some(e=>n.includes(e.toLowerCase()))};function NP(e,t){return{displayTitle:W(e.run),projectName:e.projectName,tags:e.tags,automation:e.run.automationId===void 0?void 0:t(e)??e.run.automationId,references:()=>ni(e.run)}}function PP(e,t,n,r=()=>void 0){let i=t.query.trim()!==``;return e.filter(e=>(n===`archived`?!e.run.archived:e.run.archived)||!ZM(e.run,t.origin??`all`)||!jP(t.projects??[],[e.run.projectId])||!jP(t.statuses,[e.run.status])||!jP(t.workflows,[e.run.workflow])||!MP(e,t.tags)?!1:!i||Gr(e.run,t.query,{scope:`shown`,extras:NP(e,r)}))}function FP(e,t,n,r,i){return PP(e,r===`origin`?{...t,origin:`all`}:{...t,[r]:[]},n,i)}function IP(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(gP,`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 LP(e,t){let n=new Map(t.map(e=>[e.id,e.name]));return e.map(e=>n.get(e)||e)}var RP={query:`q`,project:`project`,tag:`tag`,untagged:`untagged`,status:`status`,workflow:`workflow`,groupBy:`group`,archived:`archived`,origin:`origin`},zP=new Set(_P.map(e=>e.value));function BP(e){let t=new URLSearchParams,n=e.filters.query.trim();n!==``&&t.set(RP.query,n);for(let n of e.filters.tags)n===` untagged`?t.set(RP.untagged,`1`):t.append(RP.tag,n);for(let n of e.filters.projects??[])t.append(RP.project,n);for(let n of e.filters.statuses)t.append(RP.status,n);for(let n of e.filters.workflows)t.append(RP.workflow,n);return e.groupBy!==`none`&&t.set(RP.groupBy,e.groupBy),e.view===`archived`&&t.set(RP.archived,`1`),e.filters.origin!==void 0&&e.filters.origin!==`all`&&t.set(RP.origin,e.filters.origin),t}function VP(e,t){let n=e.getAll(RP.tag).filter(e=>e!==``);e.get(RP.untagged)===`1`&&n.push(gP);let r=e.get(RP.groupBy)??``,i=YM(XM(e.get(RP.origin)),t);return{filters:{query:e.get(RP.query)??``,...e.has(RP.project)?{projects:e.getAll(RP.project).filter(Boolean)}:{},tags:n,statuses:e.getAll(RP.status).filter(e=>e!==``),workflows:e.getAll(RP.workflow).filter(e=>e!==``),...i===`all`?{}:{origin:i}},groupBy:zP.has(r)?r:`none`,view:e.get(RP.archived)===`1`?`archived`:`active`}}var HP=15e3,UP=250,WP=1,GP=new Set([`done`,`failed`,`cancelled`]);function KP(){return JP({request:({task:e,archived:t})=>gt(Wn(e.run.id,{projectId:e.run.projectId}),t),patch:({archived:e})=>t=>({...t,archived:e})})}function qP(){return JP({request:({task:e,read:t})=>Ye(Wn(e.run.id,{projectId:e.run.projectId}),t),patch:({read:e})=>t=>{if(e)return{...t,seenAt:new Date().toISOString()};let{seenAt:n,...r}=t;return r}})}function JP({request:e,patch:t}){let n=Hn();return jn({mutationFn:e,onMutate:e=>n.patchIndex(Wn(e.task.run.id,{projectId:e.task.run.projectId}),()=>t(e)),onError:(e,t,n)=>{n?.rollback(),G(e.message,{tone:`danger`})},onSettled:(e,t,{task:r},i)=>{i?i.settle():n.invalidateAfter(`indexed`,Wn(r.run.id,{projectId:r.run.projectId}))}})}function YP(){let{expandedRuns:e,toggleExpandedRun:t}=wj(),n=An(),r=bN(On().data),i=mn(!0,HP),[a,o]=qk(),s=js(),{filters:c,groupBy:l,view:u}=Z.useMemo(()=>VP(a,s),[a,s]),d=Hb(3e4),f=e=>o(t=>{let n=BP(e(VP(t,!0))),r=t.get(`tasks`);return(r===`flat`||r===`virtual`)&&n.set(`tasks`,r),n}),p=e=>f(t=>({...t,filters:e(t.filters)})),m=e=>f(t=>({...t,groupBy:e})),h=e=>f(t=>({...t,view:e})),[g,_]=Z.useState(l!==`none`||c.tags.length>0),[v,y]=QP(c.query,e=>p(t=>({...t,query:e}))),b=i.data?.referenceStatuses;Z.useEffect(()=>{b&&pr(b)},[b]);let x=Z.useMemo(()=>n.data?.projects??[],[n.data]),S=Z.useMemo(()=>i.data?.runs??[],[i.data]),w=Z.useMemo(()=>EP(S,x),[S,x]),{nameOf:T,visible:D,originTotals:O,statusGroups:k,folds:A}=$P({tasks:w,filters:c,view:u,groupBy:l,index:S,automationsOn:s}),j=Z.useMemo(()=>IP(D,l),[D,l]),M=c.origin??`all`,ee=e=>p(t=>bP(t,e)),te=Z.useMemo(()=>D.flatMap(e=>Wr(e.run,e.project?.repoUrl).filter(t=>ei(t,e.project?.repoUrl)).map(t=>({projectId:e.run.projectId,kind:t.kind,number:t.number}))),[D]),N=LP(i.data?.truncated??[],x),P=(e,t)=>p(n=>({...n,[e]:xP(n[e]??[],t)})),ne=e=>p(t=>({...t,[e]:[]})),F=KP(),I=qP(),re=Z.useCallback((e,t)=>F.mutate({task:e,archived:t}),[F.mutate]),ie=Z.useCallback((e,t)=>I.mutate({task:e,read:t}),[I.mutate]),ae=i.error??n.error;if(ae)return(0,Q.jsx)(fP,{groupBy:l,filterDetailsOpen:g,message:ae.message,onRetry:()=>{i.refetch(),n.refetch()}});let oe=(0,Q.jsxs)(`div`,{className:`relative w-full`,children:[(0,Q.jsx)(Fi,{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:v,onChange:e=>y(e.target.value),placeholder:`Search every project…`,"aria-label":`Search tasks across projects`,className:`h-11 w-full rounded-md border border-input bg-card pr-3 pl-8 text-[13px] text-foreground outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`})]});return(0,Q.jsxs)(RM,{layout:l,revision:j,visibilityRevision:JSON.stringify([Br.map(A.isCollapsed),[...e].sort(),u,g]),"data-route":`global-tasks`,"data-presentation":l===`none`?`summary`:`cards`,"data-filter-details":g,className:`flex min-h-full flex-col gap-[22px] px-[18px] pt-6 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-9`,children:[(0,Q.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-[22px]`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h1`,{className:`text-[30px] font-semibold tracking-tight`,children:`All tasks`}),(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:l===`none`?`Every project. One place to review what your agents have shipped.`:`Filter across projects and act on each run without opening the session.`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-6 border-b border-border`,children:[(0,Q.jsx)(eF,{view:`active`,current:u,onSelect:h,children:`Active`}),(0,Q.jsx)(eF,{view:`archived`,current:u,onSelect:h,children:`Archived`}),(0,Q.jsxs)(`span`,{"data-slot":`global-tasks-count`,className:`ml-auto text-[13px] text-soft-foreground tabular-nums`,children:[D.length,` of `,w.length,N.length>0?` loaded`:``]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,Q.jsx)(`div`,{className:`min-w-0 basis-full md:flex-1 md:basis-auto`,children:oe}),(0,Q.jsxs)(E,{variant:`outline`,"aria-expanded":g,onClick:()=>_(e=>!e),children:[(0,Q.jsx)(ca,{"aria-hidden":`true`}),`Filters`]}),(0,Q.jsx)(E,{asChild:!0,className:`min-h-11`,children:(0,Q.jsxs)(C,{to:gs(n.data?.bootProject??`default`,`/new`),children:[(0,Q.jsx)(Bi,{"aria-hidden":`true`}),`New task`]})})]}),(0,Q.jsx)(dN,{origin:M,counts:O,automations:s,onChange:ee,labels:k.map(e=>e.label),onSetAll:A.setAll})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[22px]`,children:[(0,Q.jsx)(tF,{filters:c,onToggle:P,onClearFacet:ne,onClearAll:()=>{y(``),f(e=>({...e,filters:yP,groupBy:`none`}))},groupBy:l,onGroupByChange:m,projects:x,tasks:w,view:u,automationName:T}),(0,Q.jsx)(lP,{projects:N,perProjectLimit:i.data?.perProjectLimit}),i.data===void 0?(0,Q.jsx)(`div`,{role:`status`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:`Loading tasks…`}):(0,Q.jsx)(XP,{view:u,filtered:CP(c),visibleCount:D.length,referenceRequests:te,lists:{groupBy:l,view:u,statusGroups:k,groups:j,folds:A,row:{now:d,onArchive:re,expandedRuns:e,toggleExpandedRun:t,onSetRead:ie,busy:F.isPending||I.isPending,showCost:r.cost,automationName:T}}}),(0,Q.jsx)(uP,{registry:x})]})]})}function XP({view:e,filtered:t,visibleCount:n,referenceRequests:r,lists:i}){return n===0?(0,Q.jsx)(dP,{view:e,filtered:t}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ga,{requests:r,children:(0,Q.jsx)(ZP,{...i})}),i.groupBy===`none`?(0,Q.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Resource details—including tokens, cost, CPU and peak memory—are available when a task row is expanded.`}):null]})}function ZP({groupBy:e,view:t,statusGroups:n,groups:r,folds:i,row:a}){return(0,Q.jsx)(Q.Fragment,{children:e===`none`?n.map(e=>{let n=tN(e);return(0,Q.jsx)(pN,{id:`global-group-${t}-${e.label.replaceAll(` `,`-`)}`,label:e.label,count:n.length,tone:nN(e.label,n.map(e=>e.run)),folded:i.isFolded(e.label),collapsed:i.isCollapsed(e.label),onToggle:()=>i.toggle(e.label),children:(0,Q.jsx)(nF,{summary:!0,tasks:e.rows.flatMap(oN),showProject:!0,...a})},e.label)}):r.map(t=>(0,Q.jsxs)(`section`,{"data-slot":`task-group`,"data-group-key":t.key,children:[(0,Q.jsxs)(`h2`,{className:`mb-1.5 flex items-center gap-2 text-[12px] font-semibold tracking-[0.04em] text-soft-foreground uppercase`,children:[e===`project`?(0,Q.jsx)(C,{to:gs(t.key,`/`),"data-slot":`group-project-link`,className:`hover:text-foreground hover:underline`,children:t.label}):t.label,(0,Q.jsx)(`span`,{className:`font-mono text-[11px] font-medium tabular-nums`,children:t.tasks.length})]}),(0,Q.jsx)(nF,{tasks:t.tasks,showProject:e!==`project`,...a})]},t.key))})}function QP(e,t){let[n,r]=Z.useState(e),i=Z.useRef(e);return Z.useEffect(()=>{e!==i.current&&r(e),i.current=e},[e]),Z.useEffect(()=>{if(n===i.current)return;let e=setTimeout(()=>{i.current=n,t(n)},UP);return()=>clearTimeout(e)},[n]),[n,r]}function $P({tasks:e,filters:t,view:n,groupBy:r,index:i,automationsOn:a}){let o=Z.useMemo(()=>[...new Set(e.filter(e=>e.run.automationId!==void 0).map(e=>e.run.projectId))],[e]),s=dr(o,a&&o.length>0),c=Z.useCallback(e=>e.run.automationId===void 0?void 0:s(e.run.projectId,e.run.automationId),[s]),l=Z.useMemo(()=>PP(e,t,n,c),[e,t,n,c]),u=$M(FP(e,t,n,`origin`,c).map(e=>e.run),n),d=r===`none`?aN(l,n,i):[];return{nameOf:c,visible:l,originTotals:u,statusGroups:d,folds:vN(`global`,n,new Set(t.query.trim()===``?[]:d.map(e=>e.label)))}}function eF({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:D(`flex min-h-11 items-center justify-center border-b-2 border-transparent text-[13px] font-medium text-muted-foreground`,i&&`border-accent-strong font-semibold text-accent-text`),children:r})}function tF({filters:e,onToggle:t,onClearFacet:n,onClearAll:r,groupBy:i,onGroupByChange:a,projects:o,tasks:s,view:c,automationName:l}){let u=Z.useMemo(()=>Fn(o),[o]),d=Z.useMemo(()=>{let t=(t,n)=>kP(FP(s,e,c,t,l),n);return{projects:t(`projects`,e=>[e.run.projectId]),tags:t(`tags`,AP),statuses:t(`statuses`,e=>[e.run.status]),workflows:t(`workflows`,e=>[e.run.workflow])}},[s,e,c,l]),f=e=>t=>({...t,count:e.get(t.value)??0});return(0,Q.jsxs)(`div`,{"data-slot":`global-tasks-filters`,className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,Q.jsx)(pP,{slot:`project`,label:`Project`,selected:e.projects??[],onToggle:e=>t(`projects`,e),onClear:()=>n(`projects`),options:[...new Map(s.map(e=>[e.run.projectId,e.projectName])).entries()].map(([e,t])=>({value:e,label:t})).map(f(d.projects)),emptyLabel:`No tasks to filter`}),(0,Q.jsx)(pP,{slot:`status`,label:`Status`,selected:e.statuses,onToggle:e=>t(`statuses`,e),onClear:()=>n(`statuses`),options:OP(s).map(e=>({value:e,label:e})).map(f(d.statuses)),emptyLabel:`No tasks to filter`}),(0,Q.jsx)(pP,{slot:`workflow`,label:`Workflow`,selected:e.workflows,onToggle:e=>t(`workflows`,e),onClear:()=>n(`workflows`),options:DP(s).map(e=>({value:e,label:e})).map(f(d.workflows)),emptyLabel:`No tasks to filter`}),(0,Q.jsxs)(`div`,{"data-slot":`group-controls`,className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`text-[11px] font-medium text-soft-foreground`,children:`Group by`}),(0,Q.jsx)(hP,{slot:`group-by`,label:`Group tasks by`,value:i,options:_P,onChange:e=>a(vP(i,e))})]}),TP({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)(oa,{className:`size-3`,"aria-hidden":`true`}),`Clear`,` (${wP({filters:e,groupBy:i})})`]}):null]}),u.length>0?(0,Q.jsxs)(`div`,{"data-slot":`tag-filters`,className:`flex flex-wrap items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] font-medium text-soft-foreground`,children:`Tags`}),u.map(n=>(0,Q.jsx)(mP,{slot:`tag-filter`,tone:`tag`,label:n,count:d.tags.get(n)??0,selected:e.tags.some(e=>e.toLowerCase()===n.toLowerCase()),onToggle:()=>t(`tags`,n)},n)),(0,Q.jsx)(mP,{slot:`tag-filter`,label:`Untagged`,count:d.tags.get(` untagged`)??0,selected:e.tags.includes(gP),onToggle:()=>t(`tags`,gP)})]}):(0,Q.jsxs)(`p`,{"data-slot":`no-tags-hint`,className:`text-[11px] text-soft-foreground`,children:[`Tag connected repositories in`,` `,(0,Q.jsx)(C,{to:`/settings/global/projects`,className:`font-medium text-accent-text hover:underline`,children:Ka(`projects`)}),` `,`to group their tasks together here.`]})]})}function nF({summary:e=!1,expandedRuns:t,toggleExpandedRun:n,tasks:r,now:i,showProject:a,onArchive:o,onSetRead:s,busy:c,showCost:l,automationName:u}){let d=Fj(r.map(e=>`${e.run.projectId}/${e.run.id}`),t),f=ci();return(0,Q.jsxs)(`div`,{role:e?`table`:void 0,"aria-rowcount":e?d.rowCount:void 0,"data-slot":`global-tasks-table`,className:`overflow-x-auto rounded-lg border border-border bg-card p-5`,children:[(0,Q.jsx)(`div`,{"data-slot":`global-summary-head`,className:`text-[12px]`,role:`row`,"aria-rowindex":1,children:[`Task`,`Workflow`,`Changes`,`Pull request`,`Started`].map(e=>(0,Q.jsx)(`span`,{role:`columnheader`,children:e},e))}),(0,Q.jsx)(Ng,{children:(0,Q.jsx)(LM,{...e?{itemSize:f?115:218}:{},items:r,itemKey:e=>`${e.run.projectId}/${e.run.id}`,children:(r,f)=>(0,Q.jsx)(rF,{task:r,summary:e,rowIndex:d.indexes[f],resourcesOpen:t.has(`${r.run.projectId}/${r.run.id}`),toggleExpandedRun:n,now:i,showProject:a,onArchive:o,onSetRead:s,busy:c,showCost:l,automationName:u(r)},`${r.run.projectId}/${r.run.id}`)})})]})}var rF=Z.memo(function({rowIndex:e,resourcesOpen:t,toggleExpandedRun:n,summary:r,task:i,now:a,showProject:o,onArchive:s,onSetRead:c,busy:l,showCost:u,automationName:d}){let f=r?`row`:void 0,p=r?`cell`:void 0,{run:m}=i,h=xe(m),g=gs(m.projectId,`/tasks/${m.id}`),_=Wr(m,i.project?.repoUrl),v=Ar(m,m.usage);return(0,Q.jsxs)(`article`,{role:r?`rowgroup`:void 0,"data-status":m.status,"data-expanded":t,"data-slot":`global-task-row`,"data-run-id":m.id,"data-project":m.projectId,className:`hover:bg-muted max-md:flex max-md:flex-wrap max-md:items-center max-md:gap-x-3 max-md:gap-y-2 max-md:border-b max-md:border-border max-md:py-5 `,children:[(0,Q.jsxs)(`div`,{"data-slot":`global-task-cells`,className:`contents`,role:f,"aria-rowindex":r?e:void 0,children:[(0,Q.jsx)(iF,{summary:r,task:i,showProject:o,automationName:d,resourcesOpen:t,toggleExpandedRun:n}),(0,Q.jsx)(`div`,{role:p,"data-slot":`global-task-workflow`,className:`text-[13px] text-muted-foreground`,children:m.workflow}),(0,Q.jsx)(`div`,{role:p,"data-slot":`global-task-diff`,className:`text-xs text-muted-foreground`,children:(0,Q.jsx)(`span`,{title:`Change totals are available in the project task list`,children:`—`})}),(0,Q.jsx)(`div`,{role:p,"data-slot":`global-task-references`,children:_.length>0?(0,Q.jsx)(sF,{references:_,run:m,repoBase:i.project?.repoUrl}):(0,Q.jsx)(lF,{})}),(0,Q.jsx)(`div`,{role:p,"data-slot":`global-task-age`,className:`text-right text-xs text-soft-foreground tabular-nums`,children:za(m.startedAt??m.createdAt,a)})]}),!r||t?(0,Q.jsx)(`div`,{className:`contents`,role:f,"aria-rowindex":r?e+1:void 0,children:(0,Q.jsxs)(`div`,{"data-slot":`global-task-detail-cell`,role:p,"aria-colspan":r?5:void 0,className:r?`col-span-full flex flex-col gap-3`:`contents`,children:[(0,Q.jsx)(`div`,{"data-slot":`global-task-actions`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,Q.jsx)(aF,{task:i,busy:l,onSetRead:c}),(0,Q.jsx)(oF,{task:i,busy:l,onArchive:s}),(0,Q.jsx)(E,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(C,{to:g,children:`Open task`})})]})}),t?(0,Q.jsxs)(`div`,{"data-slot":`global-task-resources`,className:`col-span-full flex flex-col gap-3`,children:[(0,Q.jsx)(hN,{projectId:m.projectId,runId:m.id,status:h.label,error:m.error,open:(0,Q.jsx)(E,{asChild:!0,variant:`outline`,className:`min-h-11`,children:(0,Q.jsxs)(C,{to:g,children:[`Open task`,(0,Q.jsxs)(`span`,{className:`sr-only`,children:[`: `,W(m)]})]})})}),(0,Q.jsxs)(`dl`,{className:`grid grid-cols-2 gap-4 rounded-md bg-muted/50 p-4 text-xs md:grid-cols-3`,children:[u?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Cost`}),(0,Q.jsx)(`dd`,{className:`mt-1`,children:oi(m.costUsd)||`—`})]}):null,(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`CPU`}),(0,Q.jsx)(`dd`,{"data-usage":`cpu`,"data-usage-kind":v.cpu.kind,title:v.cpu.title,className:`mt-1`,children:v.cpu.text||`—`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Memory`}),(0,Q.jsx)(`dd`,{"data-usage":`mem`,"data-usage-kind":v.mem.kind,title:v.mem.title,className:`mt-1`,children:v.mem.text||`—`})]})]})]}):null]})}):null]})},(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.length===i.tags.length&&n.tags.every((e,t)=>e===i.tags[t])&&Object.keys(r).every(e=>r[e]===a[e])});function iF({summary:e,task:t,showProject:n,automationName:r,resourcesOpen:i,toggleExpandedRun:a}){let{run:o}=t,s=xe(o),c=gs(o.projectId,`/tasks/${o.id}`),l=Zr(o),u=ph(o);return(0,Q.jsxs)(`div`,{role:e?`cell`:void 0,"data-slot":`global-task-title`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[o.delegation?.role===`worker`?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Worker`}):null,(0,Q.jsx)(C,{to:c,title:W(o),"data-task-control":`title`,className:D(`min-w-0 truncate text-[14px] md:text-[13px]`,l?`font-semibold text-foreground`:u?`font-medium text-muted-foreground`:`font-medium`),children:W(o)}),l?(0,Q.jsx)($,{tone:hh(o),role:`img`,"aria-label":`unread`,title:`Unread — not opened since it finished`,className:`shrink-0`}):null]}),(0,Q.jsx)(`div`,{className:`mt-1`,children:(0,Q.jsx)(mN,{automationId:o.automationId,automationName:r,project:n?(0,Q.jsx)(C,{to:gs(o.projectId,`/`),"data-slot":`task-project`,className:`truncate hover:text-foreground`,children:t.projectName}):void 0})}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,"data-task-control":`resources`,"aria-expanded":i,"aria-label":`${i?`Hide`:`Show`} resources for ${W(o)}`,onClick:()=>a(`${o.projectId}/${o.id}`),"aria-describedby":`global-status-${o.projectId}-${o.id}`,title:`Resources and actions`,className:`min-h-[26px] rounded-md p-0 text-[11px] text-muted-foreground hover:bg-muted`,children:(0,Q.jsx)(KM,{id:`global-status-${o.projectId}-${o.id}`,dot:s.tone,shape:s.shape,pulse:s.pulse,children:s.label})}),(0,Q.jsx)(`span`,{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)(cF,{tag:e},e))}):null})]})]})}function aF({task:e,busy:t,onSetRead:n}){if(!Ir(e.run))return null;let r=Zr(e.run),i=W(e.run),a=r?`Mark ${i} read`:`Mark ${i} unread`,o=r?La:Eu;return(0,Q.jsxs)(Pg,{children:[(0,Q.jsx)(Fg,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-action":r?`mark-read`:`mark-unread`,"aria-label":a,disabled:t,onClick:()=>n(e,r),className:D(`inline-flex size-11 items-center justify-center md:size-8 rounded-md transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none disabled:cursor-wait disabled:opacity-50`,r?`text-accent-icon`:`text-soft-foreground`),children:[(0,Q.jsx)(o,{className:`size-3.5`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{children:r?`Mark read`:`Mark unread`})]})}),(0,Q.jsx)(Ig,{side:`left`,children:r?`Mark read`:`Mark unread`})]})}function oF({task:e,busy:t,onArchive:n}){let r=e.run.archived;if(!r&&!GP.has(e.run.status))return null;let i=r?`Restore ${W(e.run)} to the active list`:`Archive ${W(e.run)}`;return(0,Q.jsxs)(Pg,{children:[(0,Q.jsx)(Fg,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-action":r?`unarchive-run`:`archive-run`,"aria-label":i,disabled:t,onClick:()=>n(e,!r),className:`inline-flex size-11 items-center justify-center md:size-8 rounded-md text-soft-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none disabled:cursor-wait disabled:opacity-50`,children:[(0,Q.jsx)(r?iu:ha,{className:`size-3.5`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{children:r?`Unarchive`:`Archive`})]})}),(0,Q.jsx)(Ig,{side:`left`,children:r?`Restore`:`Archive`})]})}function sF({references:e,run:t,repoBase:n}){return(0,Q.jsx)(Sb,{references:e,maxVisible:WP,taskTitle:W(t),projectId:t.projectId,runId:t.id,repoBase:n})}function cF({tag:e,className:t}){return(0,Q.jsx)(`span`,{"data-slot":`project-tag`,className:D(`inline-flex max-w-full items-center truncate rounded-full bg-muted px-1.5 py-px text-[11px] font-medium text-muted-foreground`,t),children:e})}function lF(){return(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`})}var uF=new Map;function dF(e){let t=uF.get(e);return t||(t=new Intl.DateTimeFormat(`en-CA`,{timeZone:e,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}),uF.set(e,t)),t}function fF(e,t){try{let n=dF(t).formatToParts(new Date(e)),r=e=>Number(n.find(t=>t.type===e)?.value),i=r(`year`),a=r(`month`),o=r(`day`);return{year:i,month:a,day:o,hour:r(`hour`)%24,minute:r(`minute`),second:r(`second`),weekday:pF(i,a,o)}}catch{return null}}function pF(e,t,n){return(new Date(Date.UTC(e,t-1,n)).getUTCDay()+6)%7+1}function mF(e,t){let n=fF(t,e);return n?Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second)-t:null}function hF(e,t,n,r,i,a){let o=Date.UTC(e,t-1,n,r,i,0,0),s=o;for(let e=0;e<3;e+=1){let e=mF(a,s);if(e===null)return null;let t=o-e;if(Math.abs(t-s)<1e3)return t;s=t}return s}function gF(e){if(!e)return!1;try{return dF(e).format(new Date(0)),!0}catch{return!1}}var _F=[`daily`,`weekdays`,`weekly`,`hours`,`once`],vF=[1,2,3,4,6,8,12],yF=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],bF=[`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`,`Sunday`],xF=43200,SF=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/,CF=[`hour`,`minute`,`day`,`every`],wF=[`at`,`timeZone`,`latestStartMinutes`],TF=`the due time has passed; choose a later time or use Run now`,EF=Yt([`paused`,`waiting`,`failed`,`missed`,`archived`]);function DF(e){return`unknown time zone "${e}"; use an IANA name such as Europe/Warsaw`}var OF=B({type:Yt(_F),hour:R().int().min(0).max(23).optional(),minute:R().int().min(0).max(59).optional(),day:R().int().min(1).max(7).optional(),every:an([$t(1),$t(2),$t(3),$t(4),$t(6),$t(8),$t(12)]).optional(),at:z().regex(SF,`at must be YYYY-MM-DDTHH:MM`).optional(),timeZone:z().optional(),latestStartMinutes:R().int().min(10).max(xF).optional()}).superRefine((e,t)=>{let n=t=>e[t]!==void 0,r=(e,n)=>t.addIssue({code:`custom`,path:[e],message:n});if(e.type!==`once`){for(let e of wF)n(e)&&r(e,`${e} applies only to a once schedule`);return}for(let e of CF)n(e)&&r(e,`${e} does not apply to a once schedule`);e.at===void 0?r(`at`,`a once schedule needs at (YYYY-MM-DDTHH:MM)`):SF.test(e.at)&&!MF(e.at)&&r(`at`,`at is not a real date and time`),e.timeZone===void 0?r(`timeZone`,`a once schedule needs a timeZone`):gF(e.timeZone)||r(`timeZone`,DF(e.timeZone))});function kF(e){return{type:e.type,hour:e.hour??4,minute:e.minute??0,day:e.day??1,every:e.every??6,...e.at===void 0?{}:{at:e.at},...e.timeZone===void 0?{}:{timeZone:e.timeZone},...e.latestStartMinutes===void 0?{}:{latestStartMinutes:e.latestStartMinutes}}}function AF(e){if(e.type!==`once`||!e.at||!e.timeZone)return null;let t=jF(e.at);return t&&hF(t.year,t.month,t.day,t.hour,t.minute,e.timeZone)}function jF(e){let t=SF.exec(e);if(!t)return null;let[n,r,i,a,o]=t.slice(1).map(Number),s=new Date(Date.UTC(n,r,0)).getUTCDate();return r<1||r>12||i<1||i>s||a>23||o>59?null:{year:n,month:r,day:i,hour:a,minute:o}}var MF=e=>jF(e)!==null,NF=e=>String(e).padStart(2,`0`);function PF(e,t=0){return`${NF(e)}:${NF(t)}`}function FF(e){let t=kF(e);switch(t.type){case`once`:return IF(t);case`daily`:return`every day at ${PF(t.hour,t.minute)}`;case`weekdays`:return`weekdays at ${PF(t.hour,t.minute)}`;case`hours`:return t.every===1?`every hour`:`every ${t.every} hours`;case`weekly`:return`${bF[t.day-1]}s at ${PF(t.hour,t.minute)}`}}function IF(e){let t=e.at?jF(e.at):null;if(!t)return`once`;let{year:n,month:r,day:i,hour:a,minute:o}=t;return`once on ${yF[pF(n,r,i)-1]} ${i} ${LF[r-1]} ${n} at ${PF(a,o)} (${e.timeZone??`UTC`})`}var LF=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function RF(e){let t=kF(e);switch(t.type){case`once`:throw Error(`a once schedule has no cron form`);case`daily`:return`${t.minute} ${t.hour} * * *`;case`weekdays`:return`${t.minute} ${t.hour} * * 1-5`;case`hours`:return`0 */${t.every} * * *`;case`weekly`:return`${t.minute} ${t.hour} * * ${t.day%7}`}}function zF(e,t){switch(e.type){case`once`:return[];case`daily`:return[[e.hour,e.minute]];case`weekdays`:return t<=5?[[e.hour,e.minute]]:[];case`weekly`:return t===e.day?[[e.hour,e.minute]]:[];case`hours`:{let t=[];for(let n=0;n<24;n+=e.every)t.push([n,0]);return t}}}function BF(e,t,n,r,i=1e3){if(e.type===`once`){let r=AF(e);return r!==null&&r>=t&&r<n&&i>0?[r]:[]}let a=kF(e),o=fF(t,r);if(!o||n<=t)return[];let s=[],c=Math.ceil((n-t)/864e5)+2;for(let e=-1;e<=c;e+=1){let c=new Date(Date.UTC(o.year,o.month-1,o.day+e)),l=c.getUTCFullYear(),u=c.getUTCMonth()+1,d=c.getUTCDate();for(let[e,o]of zF(a,pF(l,u,d))){let a=hF(l,u,d,e,o,r);if(a===null||a!==s.at(-1)&&a>=t&&a<n&&(s.push(a),s.length>=i))return s}}return s}function VF(e,t){let n=t-e;if(n<=0)return`now`;let r=Math.floor(n/6e4);if(r<1)return`in <1m`;if(r<60)return`in ${r}m`;let i=Math.floor(r/60);return i<24?`in ${i}h`:`in ${Math.floor(i/24)}d`}var HF=new Map;function UF(e,t){if(!Number.isFinite(e))return null;let n=HF.get(t);try{n??=new Intl.DateTimeFormat(`en-GB`,{timeZone:t,weekday:`short`,year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`})}catch{return null}HF.set(t,n);let r={};for(let t of n.formatToParts(e))r[t.type]=t.value;let i=new Date(`${r.month} 1, ${r.year} UTC`).getUTCMonth();return{weekday:r.weekday,day:r.day,month:r.month,hour:r.hour,minute:r.minute,key:`${r.year}-${i}-${r.day}`,dayNumber:Math.floor(Date.UTC(Number(r.year),i,Number(r.day))/864e5)}}function WF(e,t){let n=UF(Date.parse(e),t);return n?`${n.weekday} ${n.hour}:${n.minute}`:e}function GF(e,t,n){let r=UF(Date.parse(e),t),i=UF(n,t);if(!r||!i)return e;let a=`${r.hour}:${r.minute}`,o=i.dayNumber-r.dayNumber;return o===0?`Today ${a}`:o===1?`Yesterday ${a}`:o>1&&o<7?`${r.weekday} ${a}`:`${r.day} ${r.month} ${a}`}var KF=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],qF=e=>String(e).padStart(2,`0`);function JF(e){let t=e?jF(e):null;if(!t)return null;let{year:n,month:r,day:i,hour:a,minute:o}=t;return{date:`${yF[pF(n,r,i)-1]} ${i} ${KF[r-1]} ${n}`,time:`${qF(a)}:${qF(o)}`}}var YF=36e5;function XF(e){let t=AF(e),n=e.timeZone,r=JF(e.at),i=t===null||!n?null:fF(t,n);if(t===null||!n||!r||!i)return null;let a={date:`${yF[pF(i.year,i.month,i.day)-1]} ${i.day} ${KF[i.month-1]} ${i.year}`,time:`${qF(i.hour)}:${qF(i.minute)}`};if(a.date!==r.date||a.time!==r.time)return{...a,note:`${r.time} does not exist on ${r.date} in ${n}.`};let o=e=>{let t=fF(e,n);return!!t&&t.day===i.day&&t.hour===i.hour&&t.minute===i.minute},s=(mF(n,t-12*YF)??0)-(mF(n,t+12*YF)??0);if(s<=0)return a;let c=o(t+s);if(!c&&!o(t-s))return a;let l=(mF(n,t)??0)/6e4,u=`UTC${l<0?`-`:`+`}${qF(Math.floor(Math.abs(l)/60))}:${qF(Math.abs(l)%60)}`;return{...a,note:`${r.time} happens twice that day; it runs at ${c?`the first`:`the second`} (${u}).`}}var ZF=Yt([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),QF=B({includeExisting:Jt().optional(),authors:Xt(z()).optional(),assignees:Xt(z()).optional(),requireCurrentLabels:Jt().optional(),allLabels:Xt(z()).optional(),anyLabels:Xt(z()).optional(),excludeLabels:Xt(z()).optional(),changedLabels:Xt(z()).optional(),lookbackDays:R(),maxRecords:R()}),$F=Yt([`github`,`schedule`]),eI=he.omit({task:!0,images:!0,systemPrompt:!0}).extend({prompt:z(),variants:an([$t(1),$t(2),$t(3)]).optional(),systemPrompt:z().optional()});function tI(e){let{variants:t,...n}=e;return n}var nI=B({at:z(),outcome:Yt([`launched`,`cancelled`]),runId:z().optional(),receiptId:z().optional(),trigger:Yt([`schedule`,`late`,`manual`,`retry`]).optional()}),rI=B({id:z(),revision:R(),name:z(),description:z().optional(),enabled:Jt(),kind:$F,events:Xt(ZF).optional(),intervalSeconds:R().optional(),filters:QF.optional(),schedule:OF.optional(),task:eI,archived:nI.optional(),createdAt:z(),updatedAt:z()}),iI=B({timestamp:z(),tieBreaker:z().optional()}),aI=B({since:z().datetime(),until:z().datetime(),source:R().int().min(0).max(2),page:R().int().min(1).max(10),item:R().int().min(0).max(100),event:R().int().min(0).max(1e3),cursor:iI.optional()}),oI={lastError:z().max(1e3).optional(),lastErrorAt:z().datetime().optional()},sI=B({revision:R().optional(),baselineAt:z().optional(),armedAt:z().optional(),historyScan:aI.optional(),cursor:iI.optional(),frozenHighWatermark:iI.extend({tieBreaker:z()}).optional(),backlogAfter:iI.extend({tieBreaker:z()}).optional(),nextCheckAt:z().optional(),lastSuccessAt:z().optional(),nextRunAt:z().optional(),lastRunAt:z().optional(),etags:Zt(z(),z()).optional(),backoffUntil:z().optional(),consecutiveFailures:R().optional(),...oI,onceOutcome:Yt([`failed`,`missed`]).optional()});function cI(e){let t=e?.consecutiveFailures??0;if(!(t<3||!e?.lastError))return{consecutiveFailures:t,lastError:e.lastError,...e.lastErrorAt?{lastErrorAt:e.lastErrorAt}:{},...e.backoffUntil?{retryAt:e.backoffUntil}:{}}}var lI=Yt([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]),uI=B({seq:R(),ts:z(),automationId:z(),revision:R(),event:ZF.optional(),result:lI,reason:z().optional(),durationMs:R().optional(),receiptId:z().optional(),runId:z().optional(),githubNumber:R().optional(),githubTitle:z().optional(),githubUrl:z().optional(),rateLimit:B({bucket:Yt([`core`,`search`]),remaining:R().optional(),resetAt:z().optional()}).optional()}),dI=B({matches:R(),launched:R(),duplicates:R(),errors:R()}),fI=rI.extend({state:sI.optional(),latestLog:uI.optional(),counts:dI,nextRunAt:z().optional(),onceStatus:EF.optional()});B({available:Jt(),reason:z().optional(),timeZone:z(),scheduler:B({state:Yt([`scheduled`,`idle`]),nextDue:z().optional()}),automations:Xt(fI)}),B({automation:rI}).extend({once:B({dueAt:z(),timeZone:z(),resolvedInstant:z(),note:z()}).optional()}),B({automation:rI,state:sI.optional(),latestLog:uI.optional(),onceStatus:EF.optional()}),B({id:z(),automationId:z(),mode:Yt([`preview`,`execute`]),status:Yt([`queued`,`running`,`complete`,`error`]),createdAt:z(),completedAt:z().optional(),matches:R().optional(),truncated:Jt().optional(),error:z().optional()}),B({checkId:z()}),B({records:Xt(uI)}),B({receiptId:z(),runId:z()}),B({runId:z()}),rI.omit({id:!0,revision:!0,createdAt:!0,updatedAt:!0,enabled:!0,kind:!0,archived:!0}).extend({kind:$F.optional(),task:eI.omit({variants:!0}).strict(),enable:Jt().optional()}).omit({enable:!0}).extend({enabled:Jt().optional(),expectedRevision:R()}),B({archived:Yt([`include`,`only`]).optional()}),B({mode:Yt([`preview`,`execute`])});function pI({...e}){return(0,Q.jsx)(tf,{"data-slot":`select`,...e})}function mI({...e}){return(0,Q.jsx)(of,{"data-slot":`select-value`,...e})}function hI({className:e,size:t=`default`,children:n,...r}){return(0,Q.jsxs)(rf,{"data-slot":`select-trigger`,"data-size":t,className:D(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-[var(--task-brand-bg)] px-3 py-2 text-sm whitespace-nowrap shadow-none transition-[color,box-shadow] outline-hidden focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-11 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 pointer-hover:bg-muted [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,Q.jsx)(cf,{asChild:!0,children:(0,Q.jsx)(_a,{className:`size-4 opacity-50`})})]})}function gI({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,Q.jsx)(ff,{children:(0,Q.jsxs)(mf,{"data-slot":`select-content`,className:D(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md motion-safe:data-[side=bottom]:slide-in-from-top-2 motion-safe:data-[side=left]:slide-in-from-right-2 motion-safe:data-[side=right]:slide-in-from-left-2 motion-safe:data-[side=top]:slide-in-from-bottom-2 motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:zoom-out-95 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0 motion-safe:data-[state=open]:zoom-in-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,Q.jsx)(vI,{}),(0,Q.jsx)(kf,{className:D(`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)(yI,{})]})})}function _I({className:e,children:t,...n}){return(0,Q.jsxs)(zf,{"data-slot":`select-item`,className:D(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pe-8 ps-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,Q.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute end-2 flex size-3.5 items-center justify-center`,children:(0,Q.jsx)(Uf,{children:(0,Q.jsx)(ia,{className:`size-4`})})}),(0,Q.jsx)(Vf,{children:t})]})}function vI({className:e,...t}){return(0,Q.jsx)(Gf,{"data-slot":`select-scroll-up-button`,className:D(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,Q.jsx)(Xi,{className:`size-4`})})}function yI({className:e,...t}){return(0,Q.jsx)(qf,{"data-slot":`select-scroll-down-button`,className:D(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,Q.jsx)(_a,{className:`size-4`})})}function bI({title:e,subtitle:t,action:n,children:r}){return(0,Q.jsxs)(`main`,{"data-route":`automations`,className:`task-flow-page w-full max-w-full min-w-0 max-md:p-4!`,children:[(0,Q.jsxs)(`header`,{className:`mb-6 flex flex-col items-start gap-5 max-md:mb-4 max-md:gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h1`,{className:`mb-2 text-[28px] font-medium max-md:text-[22px]`,children:e}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t})]}),n]}),r]})}function xI({text:e}){return(0,Q.jsx)(`div`,{role:`status`,className:`rounded-xl border bg-card p-6 text-sm text-muted-foreground`,children:e})}var SI={launched:`success`,manual:`success`,"catch-up":`success`,skipped:`neutral`,missed:`neutral`,"no-match":`neutral`,preview:`neutral`,baseline:`neutral`,duplicate:`neutral`,failed:`danger`,error:`danger`,"rate-limited":`danger`},CI={launched:`Launched`,manual:`Manual`,"catch-up":`Catch up`,skipped:`Skipped`,missed:`Missed`,"no-match":`No match`,preview:`Preview`,baseline:`Baseline`,duplicate:`Duplicate`,failed:`Failed`,error:`Error`,"rate-limited":`Rate limited`};function wI(e){let[t,n]=(0,Z.useState)(),[r,i]=(0,Z.useState)(``),a=(0,Z.useCallback)(t=>de(e,{signal:t}).then(({records:e})=>{t?.aborted||(n(e),i(``))}).catch(e=>{t?.aborted||i(String(e))}),[e]);return(0,Z.useEffect)(()=>{a()},[a]),(0,Z.useEffect)(()=>oe(a),[a]),(0,Z.useEffect)(()=>pl((t,n)=>{t===`automation-change`&&n.automationId===e&&a()}),[e,a]),{records:t,error:r,refresh:a}}function TI(e,t){return e.result!==`failed`&&e.result!==`error`||!e.receiptId||e.runId?!1:!t.some(t=>t.receiptId===e.receiptId&&(t.runId||t.seq>e.seq))}function EI({records:e,all:t,timeZone:n,onRetried:r,readOnly:i=!1}){let a=e=>!i&&TI(e,t),[o,s]=(0,Z.useState)(),[c,l]=(0,Z.useState)(),u=Date.now(),d=async e=>{s(e),l(void 0);try{await Ze(e),r()}catch(t){l({receiptId:e,message:t instanceof Error?t.message:String(t)})}finally{s(void 0)}};return(0,Q.jsx)(`ol`,{className:`grid gap-3`,"aria-label":`Automation execution log`,children:e.map(e=>(0,Q.jsxs)(`li`,{className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(KM,{dot:SI[e.result],children:CI[e.result]}),(0,Q.jsx)(`time`,{className:`text-xs text-muted-foreground`,dateTime:e.ts,title:e.ts,children:GF(e.ts,n,u)})]}),e.reason?(0,Q.jsx)(`p`,{className:`mt-2 text-sm break-words text-muted-foreground`,children:e.reason}):null,e.githubUrl||e.runId||a(e)?(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-sm`,children:[e.githubUrl?(0,Q.jsx)(`a`,{className:`inline-flex min-h-11 items-center underline underline-offset-4 break-all`,href:e.githubUrl,target:`_blank`,rel:`noreferrer`,children:e.githubTitle??`GitHub #${e.githubNumber??``}`}):null,e.runId?(0,Q.jsx)(Y,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`}):null,a(e)?(0,Q.jsx)(E,{variant:`outline`,disabled:o===e.receiptId,onClick:()=>void d(e.receiptId),children:`Retry task`}):null]}):null,c&&c.receiptId===e.receiptId?(0,Q.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm break-words text-destructive`,children:c.message}):null]},e.seq))})}var DI=`all`;function OI({label:e,value:t,onChange:n,options:r}){return(0,Q.jsxs)(pI,{value:t,onValueChange:n,children:[(0,Q.jsx)(hI,{"aria-label":e,className:`w-full sm:w-52`,children:(0,Q.jsx)(mI,{})}),(0,Q.jsx)(gI,{children:r.map(e=>(0,Q.jsx)(_I,{value:e.value,children:e.label},e.value))})]})}function kI({automationId:e,automationName:t,timeZone:n,readOnly:r=!1}){let{records:i,error:a,refresh:o}=wI(e),[s,c]=(0,Z.useState)(DI),[l,u]=(0,Z.useState)(DI),d=(0,Z.useMemo)(()=>(i??[]).filter(e=>(s===DI||e.result===s)&&(l===DI||e.event===l)),[i,s,l]),f=(i??[]).some(e=>e.event);return(0,Q.jsx)(bI,{title:`Execution log`,subtitle:t??`Automation activity`,action:(0,Q.jsx)(E,{variant:`outline`,asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations`,children:`Back to automations`})}),children:a&&!i?(0,Q.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,Q.jsx)(xI,{text:a}),(0,Q.jsx)(E,{variant:`outline`,onClick:()=>void o(),children:`Retry`})]}):i?i.length===0?(0,Q.jsx)(xI,{text:`Nothing has run yet.`}):(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(OI,{label:`Result`,value:s,onChange:c,options:[{value:DI,label:`All results`},...lI.options.map(e=>({value:e,label:CI[e]}))]}),f?(0,Q.jsx)(OI,{label:`Event`,value:l,onChange:u,options:[{value:DI,label:`All events`},...ZF.options.map(e=>({value:e,label:e}))]}):null]}),d.length===0?(0,Q.jsx)(xI,{text:`No rows match these filters.`}):(0,Q.jsx)(EI,{records:d,all:i,timeZone:n,onRetried:()=>void o(),readOnly:r})]}):(0,Q.jsx)(xI,{text:`Loading execution log…`})})}function AI({automationId:e,automationName:t,timeZone:n,showName:r=!1,readOnly:i=!1}){let{records:a,error:o,refresh:s}=wI(e);return(0,Q.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`mt-4 min-w-0 border-t pt-4`,children:[(0,Q.jsxs)(`h3`,{className:`mb-3 text-sm font-medium`,children:[`Recent activity`,r&&t?` · ${t}`:``]}),o&&!a?(0,Q.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,Q.jsx)(xI,{text:o}),(0,Q.jsx)(E,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]}):a?a.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing has run yet.`}):(0,Q.jsx)(EI,{records:a.slice(0,5),all:a,timeZone:n,onRetried:()=>void s(),readOnly:i}):(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading activity…`})]})}function jI({automation:e,timeZone:t,onDeleted:n}){let r=e.archived,i=e.schedule,a=i?XF(i):null,[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(``),f=(0,Z.useRef)(null),p=(0,Z.useRef)(null),m=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let e=m.current===`keep`?p.current:m.current===`delete`?f.current:null;m.current=null,e?.focus()},[o]);let h=async()=>{l(!0);try{await se(e.id),n()}catch(e){d(e instanceof Error?e.message:String(e)),l(!1)}},g=[[`Workflow`,e.task.workflow],[`Runner`,e.task.runner],[`Model`,e.task.model],[`Effort`,e.task.effort]];return(0,Q.jsx)(bI,{title:e.name,subtitle:`Archived one-time schedule. It cannot change; delete it when you no longer need the record.`,children:(0,Q.jsxs)(`div`,{className:`grid min-w-0 max-w-3xl gap-5`,children:[(0,Q.jsxs)(`section`,{className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,Q.jsxs)(`p`,{className:`text-sm break-words`,children:[(0,Q.jsx)(`span`,{children:r.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`}),r.runId?(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsx)(Y,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${r.runId}`,children:`Open task`})]}):null]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Archived ${WF(r.at,t)} (${t}).`}),a&&i?.timeZone?(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Was due ${a.date} ${a.time} (${i.timeZone}).`}):null]}),(0,Q.jsxs)(`section`,{"aria-labelledby":`archived-inputs`,className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,Q.jsx)(`h2`,{id:`archived-inputs`,className:`mb-3 text-[15px] font-medium`,children:`What it ran with`}),(0,Q.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-1`,children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Prompt`}),(0,Q.jsx)(`dd`,{className:`break-words whitespace-pre-wrap`,children:e.task.prompt})]}),g.filter(([,e])=>e).map(([e,t])=>(0,Q.jsxs)(`div`,{className:`grid gap-1`,children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,Q.jsx)(`dd`,{className:`break-words`,children:t})]},e))]})]}),(0,Q.jsxs)(`section`,{className:`min-w-0`,children:[(0,Q.jsx)(AI,{automationId:e.id,automationName:e.name,timeZone:t,readOnly:!0}),(0,Q.jsx)(E,{variant:`outline`,asChild:!0,className:`mt-3`,children:(0,Q.jsx)(Y,{to:`/automations/${e.id}/log`,children:`Execution log`})})]}),(0,Q.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[o?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? Its record and log are removed; the task stays.`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(E,{variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:c,onClick:()=>void h(),children:`Delete schedule`}),(0,Q.jsx)(E,{ref:p,variant:`outline`,disabled:c,onClick:()=>{m.current=`delete`,s(!1)},children:`Keep`})]})]}):(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(E,{ref:f,variant:`outline`,"data-action":`automation-delete`,onClick:()=>{m.current=`keep`,s(!0)},children:`Delete`}),(0,Q.jsx)(E,{variant:`outline`,asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations`,children:`Back to automations`})})]}),u?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:u}):null]})]})})}var MI=`quick-task`;function NI(e={}){let{prompt:t,workflow:n,runner:r,model:i,autonomous:a,archiveWhenDone:o,autoMergePr:s,allowWorkers:c,allowMessaging:l,...u}=tI(e.task??{prompt:``}),d=e.task===void 0;return{name:e.name??``,description:e.description??``,kind:e.kind??`schedule`,schedule:kF(e.schedule??{type:`daily`}),events:e.events??[`issue.opened`],intervalSeconds:e.intervalSeconds??300,filters:e.filters??{lookbackDays:7,maxRecords:25},prompt:t,...n===void 0?d?{workflow:MI}:{}:{workflow:n},...r===void 0?{}:{runner:r},...i===void 0?{}:{model:i},autonomous:a??!0,archiveWhenDone:o??!1,autoMergePr:s??!1,allowWorkers:c!==!1,allowMessaging:l!==!1,enabled:e.enabled??e.enable??!1,taskExtra:u}}function PI(e){switch(e.type){case`daily`:case`weekdays`:return{type:e.type,hour:e.hour,minute:e.minute};case`weekly`:return{type:`weekly`,hour:e.hour,minute:e.minute,day:e.day};case`hours`:return{type:`hours`,every:e.every};case`once`:return{type:`once`,at:e.at??``,timeZone:e.timeZone??``,...e.latestStartMinutes===void 0?{}:{latestStartMinutes:e.latestStartMinutes}}}}function FI(e){return{...e.taskExtra,prompt:e.prompt,...e.workflow?{workflow:e.workflow}:{},...e.runner?{runner:e.runner}:{},...e.model?{model:e.model}:{},autonomous:e.autonomous,...e.archiveWhenDone?{archiveWhenDone:!0}:{},...e.autoMergePr?{autoMergePr:!0}:{},...e.allowWorkers?{}:{allowWorkers:!1},...e.allowMessaging?{}:{allowMessaging:!1}}}function II(e){return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},kind:e.kind,...e.kind===`schedule`?{schedule:PI(e.schedule)}:{events:e.events,intervalSeconds:e.intervalSeconds,filters:e.filters},task:FI(e)}}function LI(e){return{...II(e),enable:e.enabled}}function RI(e,t){return{...II(e),task:{...FI(e),archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging},enabled:e.enabled,expectedRevision:t}}function zI(e){return`'${e.replace(/'/g,`'\\''`)}'`}var BI=new Set([`prompt`,`workflow`,`runner`,`model`,`autonomous`,`worktree`,`archiveWhenDone`,`autoMergePr`,`allowWorkers`,`allowMessaging`]),VI=new Set([`anyLabels`,`authors`,`changedLabels`]);function HI(e){if(e.description!==void 0||!e.name.trim()||!e.task.prompt.trim())return!1;let t=e.task;if(Object.keys(t).some(e=>!BI.has(e))||t.archiveWhenDone===!1||t.autoMergePr===!1||t.allowWorkers===!0||t.allowMessaging===!0||t.worktree!==!0)return!1;if(e.kind===`schedule`)return e.schedule!==void 0;let{events:n,filters:r}=e;return!n?.length||n.some(e=>e.includes(`,`))||!r||r.lookbackDays!==7||r.maxRecords!==25?!1:Object.entries(r).every(([e,t])=>e===`lookbackDays`||e===`maxRecords`||e===`includeExisting`&&t===!0||VI.has(e)&&Array.isArray(t)&&t.length>0)}function UI(e){return e%3600==0?`${e/3600}h`:e%60==0?`${e/60}m`:`${e}s`}function WI(e){return e%1440==0?`${e/1440}d`:e%60==0?`${e/60}h`:`${e}m`}function GI(e,t){return t.startsWith(`-`)?`--${e}=${zI(t)}`:`--${e} ${zI(t)}`}function KI(e){let t=[`${i()} automation add`,GI(`name`,e.name)];if(e.schedule?.type===`once`)t.push(GI(`at`,e.schedule.at),GI(`tz`,e.schedule.timeZone)),e.schedule.latestStartMinutes!==void 0&&t.push(GI(`latest-start`,WI(e.schedule.latestStartMinutes)));else if(e.kind===`schedule`)t.push(GI(`cron`,RF(e.schedule)));else{t.push(GI(`on`,e.events.join(`,`)),`--every ${UI(e.intervalSeconds??300)}`),e.filters?.includeExisting&&t.push(`--include-existing`);for(let n of e.filters?.anyLabels??[])t.push(GI(`label`,n));for(let n of e.filters?.authors??[])t.push(GI(`author`,n));for(let n of e.filters?.changedLabels??[])t.push(GI(`changed-label`,n))}return t.push(...qI(e.task)),e.enable===!0&&t.push(`--enable`),t.push(GI(`prompt`,e.task.prompt)),t.join(` `)}function qI(e){let t=[];return e.workflow&&t.push(GI(`workflow`,e.workflow)),e.runner&&t.push(GI(`runner`,e.runner)),e.model&&t.push(GI(`model`,e.model)),e.autonomous===!1&&t.push(`--no-autonomous`),e.archiveWhenDone&&t.push(`--archive-when-done`),e.autoMergePr&&t.push(`--auto-merge-pr`),e.allowWorkers===!1&&t.push(`--no-workers`),e.allowMessaging===!1&&t.push(`--no-messaging`),t}function JI(e,t){let n=LI(e),r=HI(n)?KI(n):`${i()} automation create --json ${zI(JSON.stringify(n))}`;return t?`CEZ_COCKPIT_URL=${zI(t.origin)} CEZ_PROJECT_ID=${zI(t.projectId)} HSQ_COCKPIT_URL=${zI(t.origin)} HSQ_PROJECT_ID=${zI(t.projectId)} ${r}`:r}function YI({draft:e}){let t=Cs(),n=window.location.origin,r=(0,Z.useMemo)(()=>JI(e,t?{origin:n,projectId:t}:void 0),[e,n,t]),[a,o]=(0,Z.useState)(`idle`),s=(0,Z.useRef)(void 0);(0,Z.useEffect)(()=>()=>clearTimeout(s.current),[]),(0,Z.useEffect)(()=>o(`idle`),[r]);let c=async()=>{clearTimeout(s.current);try{await navigator.clipboard.writeText(r),o(`copied`),s.current=setTimeout(()=>o(`idle`),1600)}catch{o(`failed`)}};return(0,Q.jsxs)(`section`,{"aria-labelledby":`copy-as-cli-heading`,"data-slot":`copy-as-cli`,className:`mbs-4 rounded-xl border bg-card p-4`,children:[(0,Q.jsxs)(`div`,{className:`mbe-2 flex items-center gap-2`,children:[(0,Q.jsx)(`h2`,{id:`copy-as-cli-heading`,className:`text-[15px] font-medium`,children:`Copy as CLI`}),(0,Q.jsxs)(E,{type:`button`,variant:`ghost`,size:`sm`,className:`ms-auto`,onClick:()=>void c(),children:[a===`copied`?(0,Q.jsx)(uu,{"aria-hidden":`true`}):(0,Q.jsx)(bu,{"aria-hidden":`true`}),a===`copied`?`Copied`:`Copy`]})]}),(0,Q.jsx)(`pre`,{className:`m-0 rounded-lg border bg-muted px-2.5 py-2 font-mono text-xs/relaxed break-words whitespace-pre-wrap text-muted-foreground`,children:r}),(0,Q.jsx)(`p`,{role:`status`,className:`mbs-2 text-xs break-words text-muted-foreground`,children:a===`failed`?`Could not copy — select the line and copy it by hand.`:(0,Q.jsxs)(Q.Fragment,{children:[`The definition Save would create. `,(0,Q.jsxs)(`code`,{children:[i(),` automation schema`]}),` prints its shape.`]})})]})}function XI({pressed:e,onClick:t,disabled:n,children:r}){return(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":e,disabled:n,onClick:t,className:D(ac,`h-11 px-4 text-[13px]`,e&&`border-transparent bg-accent-strong text-accent-strong-foreground hover:bg-accent-strong hover:text-accent-strong-foreground`),children:r})}var ZI=ZF.options,QI=[{seconds:60,label:`1 minute`},{seconds:300,label:`5 minutes`},{seconds:900,label:`15 minutes`},{seconds:1800,label:`30 minutes`},{seconds:3600,label:`1 hour`}],$I=[{key:`authors`,label:`Authors`},{key:`assignees`,label:`Assignees`},{key:`allLabels`,label:`Has all labels`},{key:`anyLabels`,label:`Has any label`},{key:`excludeLabels`,label:`Excludes labels`},{key:`changedLabels`,label:`Changed labels`,hint:`Required for the two label events.`}],eL=e=>(e??[]).join(`, `),tL=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean);function nL(e){return e?`Existing matches within the lookback are eligible on the next check. Previously processed matches will not run again.`:`Enabling starts from a current-time baseline. Existing matches will not launch tasks.`}function rL(e){let t=Math.max(1,Math.round(e.intervalSeconds/60));return`Polls GitHub every ${t} minute${t===1?``:`s`} for ${e.events.join(`, `)||`no events`}. ${nL(e.filters.includeExisting)}`}function iL({draft:e,onChange:t,disabledReason:n}){let r=n=>{t({events:e.events.includes(n)?e.events.filter(e=>e!==n):[...e.events,n]})},i=n=>t({filters:{...e.filters,...n}}),a=(n,r)=>{let i=tL(r),{[n]:a,...o}=e.filters;t({filters:i.length?{...o,[n]:i}:o})},o=QI.some(t=>t.seconds===e.intervalSeconds)?QI:[...QI,{seconds:e.intervalSeconds,label:`${Math.round(e.intervalSeconds/60)} minutes`}].sort((e,t)=>e.seconds-t.seconds);return(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[n?(0,Q.jsx)(`p`,{className:`text-xs text-pending-strong`,children:`GitHub unavailable · ${n}`}):null,(0,Q.jsx)(`div`,{role:`group`,"aria-label":`GitHub events`,className:`flex flex-wrap gap-2`,children:ZI.map(t=>(0,Q.jsx)(XI,{pressed:e.events.includes(t),onClick:()=>r(t),children:t},t))}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(Lm,{htmlFor:`automation-interval`,children:`Check every`}),(0,Q.jsxs)(pI,{value:String(e.intervalSeconds),onValueChange:e=>t({intervalSeconds:Number(e)}),children:[(0,Q.jsx)(hI,{id:`automation-interval`,className:`w-full sm:w-48`,"aria-label":`Check every`,children:(0,Q.jsx)(mI,{})}),(0,Q.jsx)(gI,{children:o.map(e=>(0,Q.jsx)(_I,{value:String(e.seconds),children:e.label},e.seconds))})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,Q.jsx)(Um,{"aria-label":`Include existing items`,"aria-describedby":`automation-history-hint`,checked:e.filters.includeExisting??!1,onCheckedChange:e=>i({includeExisting:e})}),(0,Q.jsx)(`span`,{children:`Include existing items`})]}),(0,Q.jsx)(`p`,{id:`automation-history-hint`,className:`text-xs text-muted-foreground`,children:nL(e.filters.includeExisting)})]}),(0,Q.jsxs)(GA,{children:[(0,Q.jsxs)(KA,{className:`group flex min-h-11 items-center gap-2 text-sm font-medium`,children:[`Filters`,(0,Q.jsx)(_a,{"aria-hidden":`true`,className:`size-4 text-soft-foreground transition-transform motion-reduce:transition-none group-data-[state=open]:rotate-180`})]}),(0,Q.jsx)(qA,{children:(0,Q.jsxs)(`div`,{className:`grid gap-4 pt-2 sm:grid-cols-2`,children:[$I.map(t=>(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,Q.jsx)(Lm,{htmlFor:`automation-filter-${t.key}`,children:t.label}),(0,Q.jsx)(Im,{id:`automation-filter-${t.key}`,placeholder:`comma separated`,value:eL(e.filters[t.key]),onChange:e=>a(t.key,e.target.value)}),t.hint?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.hint}):null]},t.key)),(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,Q.jsx)(Lm,{htmlFor:`automation-filter-lookback`,children:`Look back (days)`}),(0,Q.jsx)(Im,{id:`automation-filter-lookback`,type:`number`,min:1,value:e.filters.lookbackDays,onChange:e=>i({lookbackDays:Math.max(1,Number(e.target.value)||1)})})]}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,Q.jsx)(Lm,{htmlFor:`automation-filter-max`,children:`Max records per check`}),(0,Q.jsx)(Im,{id:`automation-filter-max`,type:`number`,min:1,value:e.filters.maxRecords,onChange:e=>i({maxRecords:Math.max(1,Number(e.target.value)||1)})})]})]})})]})]})}var aL=e=>String(e).padStart(2,`0`);function oL({label:e,value:t,max:n,onCommit:r}){let[i,a]=(0,Z.useState)(aL(t)),o=(0,Z.useRef)(null),s=!(/^\d{1,2}$/.test(i)&&Number(i)===t),c=`${e} must be 00–${aL(n)}.`,l=(0,Z.useId)();return(0,Z.useEffect)(()=>{o.current?.setCustomValidity(s?c:``)},[s,c]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Im,{ref:o,"aria-label":e,"aria-invalid":s||void 0,"aria-describedby":s?l:void 0,inputMode:`numeric`,maxLength:2,className:`w-20 text-center tabular-nums`,value:i,onChange:e=>{a(e.target.value),/^\d{1,2}$/.test(e.target.value)&&Number(e.target.value)<=n&&r(Number(e.target.value))},onBlur:()=>a(aL(t))}),s?(0,Q.jsx)(`p`,{id:l,className:`order-last basis-full text-xs text-destructive`,children:c}):null]})}var sL=[{minutes:void 0,label:`No limit`},{minutes:30,label:`30 minutes`},{minutes:120,label:`2 hours`},{minutes:360,label:`6 hours`},{minutes:1440,label:`1 day`},{minutes:10080,label:`7 days`}],cL=`none`,lL=e=>String(e).padStart(2,`0`);function uL(e,t=Date.now()){let n=fF(t,e)??fF(t,`UTC`),r=new Date(Date.UTC(n.year,n.month-1,n.day+1));return`${r.getUTCFullYear()}-${lL(r.getUTCMonth()+1)}-${lL(r.getUTCDate())}T09:00`}function dL(){let e=typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[];return e.includes(`UTC`)?e:[`UTC`,...e]}function fL({value:e,stored:t,onChange:n}){let r=t=>n({...e,...t}),i=e.at?jF(e.at):null,o=e.at?.slice(0,10)??``,s=i?.hour??9,c=i?.minute??0,l=(e,t,n)=>r({at:`${e}T${lL(t)}:${lL(n)}`}),u=(0,Z.useRef)(null),d=(0,Z.useId)(),f=AF(e),p=!(t?.type===`once`&&t.at===e.at&&t.timeZone===e.timeZone)&&f!==null&&f<=Date.now();(0,Z.useEffect)(()=>{u.current?.setCustomValidity(p?TF:``)},[p]);let m=XF(e);return(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-4 gap-y-3`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(Lm,{htmlFor:`automation-once-date`,children:`Date`}),(0,Q.jsx)(Im,{ref:u,id:`automation-once-date`,type:`date`,className:`w-44 max-w-full`,value:o,"aria-invalid":p||void 0,"aria-describedby":p?d:void 0,onChange:e=>{/^\d{4}-\d{2}-\d{2}$/.test(e.target.value)&&l(e.target.value,s,c)},required:!0})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,Q.jsx)(oL,{label:`Hour`,value:s,max:23,onCommit:e=>l(o,e,c)}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,Q.jsx)(oL,{label:`Minute`,value:c,max:59,onCommit:e=>l(o,s,e)})]})]}),p?(0,Q.jsx)(`p`,{id:d,className:`text-xs text-destructive`,children:TF}):null,(0,Q.jsx)(mL,{value:e.timeZone??``,onCommit:e=>r({timeZone:e})}),(0,Q.jsx)(hL,{value:e.latestStartMinutes,onChange:t=>n(pL(e,t))}),m?(0,Q.jsx)(`p`,{className:`text-sm break-words`,children:`Runs once at ${m.time} on ${m.date} (${e.timeZone}). ${m.note?`${m.note} `:``}${a(`Cezarion`)} must be running then.`}):null]})}function pL(e,t){let{latestStartMinutes:n,...r}=e;return t===void 0?r:{...r,latestStartMinutes:t}}function mL({value:e,onCommit:t}){let[n,r]=(0,Z.useState)(e),i=(0,Z.useRef)(null),a=(0,Z.useId)(),o=(0,Z.useId)(),[s]=(0,Z.useState)(dL),c=n!==e||!gF(n),l=DF(n);return(0,Z.useEffect)(()=>{i.current?.setCustomValidity(c?l:``)},[c,l]),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(Lm,{htmlFor:`automation-once-zone`,children:`Time zone`}),(0,Q.jsx)(Im,{ref:i,id:`automation-once-zone`,list:a,autoComplete:`off`,spellCheck:!1,className:`w-full sm:w-72`,value:n,"aria-invalid":c||void 0,"aria-describedby":c?o:void 0,onChange:e=>{r(e.target.value),gF(e.target.value)&&t(e.target.value)}}),(0,Q.jsx)(`datalist`,{id:a,children:s.map(e=>(0,Q.jsx)(`option`,{value:e},e))}),c?(0,Q.jsx)(`p`,{id:o,className:`text-xs break-words text-destructive`,children:l}):null]})}function hL({value:e,onChange:t}){let n=sL.some(t=>t.minutes===e)||e===void 0?sL:[...sL,{minutes:e,label:`${e} minutes`}];return(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(Lm,{htmlFor:`automation-once-latest`,children:`Latest start`}),(0,Q.jsxs)(pI,{value:e===void 0?cL:String(e),onValueChange:e=>t(e===cL?void 0:Number(e)),children:[(0,Q.jsx)(hI,{id:`automation-once-latest`,className:`w-full sm:w-48`,"aria-label":`Latest start`,children:(0,Q.jsx)(mI,{})}),(0,Q.jsx)(gI,{children:n.map(e=>(0,Q.jsx)(_I,{value:e.minutes===void 0?cL:String(e.minutes),children:e.label},e.label))})]}),(0,Q.jsxs)(`p`,{className:`text-xs break-words text-muted-foreground`,children:[`If `,a(`Cezarion`),` was not running at the time, it still starts the task this long afterwards; later, the schedule is marked missed.`]})]})}var gL=[{type:`daily`,label:`Every day`},{type:`weekdays`,label:`Weekdays`},{type:`weekly`,label:`Weekly`},{type:`hours`,label:`Every N hours`},{type:`once`,label:`Once`}];function _L({value:e,stored:t,onChange:n,timeZone:r}){let i=t=>n({...e,...t}),a=t=>i(t===`once`?{type:t,at:e.at??uL(r),timeZone:e.timeZone??r}:{type:t});return(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Q.jsx)(`div`,{role:`group`,"aria-label":`Repeat`,className:`flex flex-wrap gap-2`,children:gL.map(t=>(0,Q.jsx)(XI,{pressed:e.type===t.type,onClick:()=>a(t.type),children:t.label},t.type))}),e.type===`once`?(0,Q.jsx)(fL,{value:e,stored:t,onChange:n}):null,e.type===`weekly`?(0,Q.jsx)(`div`,{role:`group`,"aria-label":`Day of the week`,className:`flex flex-wrap gap-2`,children:yF.map((t,n)=>(0,Q.jsx)(XI,{pressed:e.day===n+1,onClick:()=>i({day:n+1}),children:t},t))}):null,e.type===`once`?null:e.type===`hours`?(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(Lm,{htmlFor:`automation-every`,children:`Run every`}),(0,Q.jsxs)(pI,{value:String(e.every),onValueChange:e=>i({every:Number(e)}),children:[(0,Q.jsx)(hI,{id:`automation-every`,className:`w-full sm:w-48`,"aria-label":`Run every`,children:(0,Q.jsx)(mI,{})}),(0,Q.jsx)(gI,{children:vF.map(e=>(0,Q.jsx)(_I,{value:String(e),children:e===1?`hour`:`${e} hours`},e))})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Counted from midnight, so “every 6 hours” runs at 00:00, 06:00, 12:00 and 18:00.`})]}):(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,Q.jsx)(oL,{label:`Hour`,value:e.hour,max:23,onCommit:e=>i({hour:e})}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,Q.jsx)(oL,{label:`Minute`,value:e.minute,max:59,onCommit:e=>i({minute:e})}),(0,Q.jsx)(`span`,{className:`text-sm break-all text-muted-foreground`,children:r})]}),e.type===`once`?null:(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Cron: `,(0,Q.jsx)(`code`,{className:`font-mono text-foreground`,children:RF(e)})]})]})}var vL=40*864e5,yL=5;function bL({schedule:e,timeZone:t,now:n=Date.now()}){if(e.type===`once`)return(0,Q.jsx)(xL,{schedule:e,now:n});let r=BF(e,n+1,n+vL,t,yL);return(0,Q.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,className:`rounded-xl border bg-card p-4`,children:[(0,Q.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-3 text-[15px] font-medium`,children:`Next 5 runs`}),r.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs in the next 40 days.`}):(0,Q.jsx)(`ol`,{"aria-label":`Next 5 runs`,className:`grid gap-1.5 text-sm`,children:r.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-baseline justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`font-medium tabular-nums`,children:WF(new Date(e).toISOString(),t)}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:VF(n,e)})]},e))}),(0,Q.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Times are in `,t,`, the zone this `,a(`cezar`),` runs in.`]})]})}function xL({schedule:e,now:t}){let n=AF(e),r=XF(e);return(0,Q.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,className:`rounded-xl border bg-card p-4`,children:[(0,Q.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-3 text-[15px] font-medium`,children:`Runs once`}),n===null||!r?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pick a date, a time and a time zone.`}):(0,Q.jsxs)(`p`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium tabular-nums`,children:`${r.date} ${r.time}`}),n>t?(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:VF(t,n)}):null]}),r?.note?(0,Q.jsx)(`p`,{className:`mt-2 text-sm break-words`,children:r.note}):null,n!==null&&n<=t?(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-destructive`,children:`The due time has passed.`}):null,(0,Q.jsx)(`p`,{className:`mt-3 text-xs break-words text-muted-foreground`,children:`Times are in ${e.timeZone??`UTC`}. ${a(`Cezarion`)} must be running then; afterwards the schedule is archived with its task.`})]})}var SL={schedule:`On a schedule`,github:`When GitHub changes`};function CL(e){return/time zone|due time/i.test(e)?`when`:/placeholder|prompt|workflow|runner|model|task|autonomous/i.test(e)?`run`:/\bname\b/i.test(e)?`name`:/schedule|github|event|filter|label|interval|remote|forge|lookback|records?|hour|minute|poll|kind|archived/i.test(e)?`when`:`form`}function wL({title:e,failure:t,section:n,children:r}){return(0,Q.jsxs)(`fieldset`,{className:`grid min-w-0 gap-4 rounded-xl border p-5 max-md:p-4!`,children:[(0,Q.jsx)(`legend`,{className:`px-0`,children:e}),r,t?.section===n&&!t.conflict?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:t.message}):null]})}function TL({draft:e,patch:t,forge:n,automation:r}){return(0,Q.jsx)(Q.Fragment,{children:r?(0,Q.jsxs)(`p`,{className:`text-sm`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Trigger · `}),SL[e.kind]]}):(0,Q.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,Q.jsx)(hP,{slot:`automation-kind`,label:`Trigger`,size:`touch`,value:e.kind,onChange:e=>t({kind:e}),options:[{value:`schedule`,label:SL.schedule},{value:`github`,label:SL.github,disabled:!n.available,...n.available?{}:{title:n.reason??`GitHub is unavailable`}}]}),n.available?null:(0,Q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`GitHub unavailable · ${n.reason??`no GitHub access`}`})]})})}function EL({draft:e,patch:t,forge:n,timeZone:r,automation:i}){return e.kind===`schedule`?(0,Q.jsx)(_L,{value:e.schedule,stored:i?.schedule,onChange:e=>t({schedule:e}),timeZone:r}):(0,Q.jsx)(iL,{draft:e,onChange:t,...n.available?{}:{disabledReason:n.reason??`no GitHub access`}})}function DL({draft:e,patch:t,saving:n,automation:r}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(Lm,{htmlFor:`automation-prompt`,children:`Prompt`}),(0,Q.jsx)(pC,{id:`automation-prompt`,value:e.prompt,onChange:e=>t({prompt:e.target.value}),rows:4,required:!0}),(0,Q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:e.kind===`schedule`?(0,Q.jsxs)(Q.Fragment,{children:[`Available: `,`{{date}}`,` `,`{{time}}`,` `,`{{project}}`,` `,`{{automation}}`,`. A run-context block is appended automatically.`]}):(0,Q.jsxs)(Q.Fragment,{children:[`Available: `,`{{github.number}}`,` `,`{{github.title}}`,` `,`{{github.url}}`,` `,`{{github.labels}}`,`. GitHub content is appended as untrusted context.`]})})]}),(0,Q.jsx)(AL,{draft:e,patch:t}),(0,Q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,Q.jsx)(Um,{"aria-label":`Autonomous`,checked:e.autonomous,onCheckedChange:e=>t({autonomous:e})}),(0,Q.jsxs)(`span`,{children:[`Autonomous `,(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`· runs without waiting for answers`})]})]}),(0,Q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`Each run is an ordinary task in its own worktree, queued behind the parallel cap.`}),(0,Q.jsx)(nk,{archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,onChange:t,disabled:n}),(0,Q.jsx)(ik,{allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging,onChange:t,disabled:n}),r?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`These settings apply to future tasks. Existing tasks keep their settings.`}):null]})}function OL({draft:e,patch:t,automation:n}){let r=e.kind===`schedule`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,Q.jsx)(Um,{"aria-label":n?`Enabled`:`Enable after saving`,checked:e.enabled,onCheckedChange:e=>t({enabled:e})}),(0,Q.jsx)(`span`,{children:n?`Enabled`:`Enable after saving`})]}),(0,Q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:r&&e.schedule.type===`once`?`It runs once at the time set above, then moves to Archived with its task.`:r?`The first run is the next occurrence shown beside the schedule.`:nL(e.filters.includeExisting)})]})}function kL({automation:e,forge:t,timeZone:n,onSaved:r,onReload:i}){let[a,o]=(0,Z.useState)(()=>NI(e)),[s,c]=(0,Z.useState)(e?.revision),[l,u]=(0,Z.useState)(),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(``),y=e=>o(t=>({...t,...e})),b=async t=>{if(t.preventDefault(),d)return;let n=t.currentTarget;if(n instanceof HTMLFormElement&&!n.checkValidity()){n.reportValidity();return}f(!0),u(void 0);let i=`save`;try{if(e&&s!==void 0){let{automation:t}=await Lt(e.id,RI({...a,enabled:e.enabled},s));c(t.revision),a.enabled!==e.enabled&&(i=`enable`,await Ft(e.id,a.enabled))}else await zt(LI(a));r()}catch(t){let n=t instanceof Error?t.message:String(t);i===`save`&&e&&t instanceof it&&t.status===409&&/revision conflict/i.test(n)?u({section:`form`,message:`Edited elsewhere — reload to see the latest version`,conflict:!0}):u({section:i===`enable`?`enable`:CL(n),message:n})}finally{f(!1)}},x=async()=>{if(!(!e||h)){g(!0),v(``);try{await se(e.id),r()}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}}},S=e?`Save changes`:a.enabled?`Save and enable`:`Save paused`,C=a.kind===`schedule`;return(0,Q.jsx)(bI,{title:e?`Edit automation`:`New automation`,subtitle:`Define when it runs and the ordinary task it launches.`,children:(0,Q.jsxs)(`form`,{className:`automation-editor grid min-w-0 gap-5 md:grid-cols-[minmax(0,1fr)_320px] md:items-start`,onSubmit:b,children:[(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[(0,Q.jsx)(wL,{title:`Name`,section:`name`,failure:l,children:(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(Lm,{htmlFor:`automation-name`,children:`Name`}),(0,Q.jsx)(Im,{id:`automation-name`,value:a.name,onChange:e=>y({name:e.target.value}),required:!0})]})}),(0,Q.jsxs)(wL,{title:`When`,section:`when`,failure:l,children:[(0,Q.jsx)(TL,{draft:a,patch:y,forge:t,automation:e}),(0,Q.jsx)(EL,{draft:a,patch:y,forge:t,timeZone:n,automation:e})]}),(0,Q.jsx)(wL,{title:`What to run`,section:`run`,failure:l,children:(0,Q.jsx)(DL,{draft:a,patch:y,saving:d,automation:e})}),(0,Q.jsx)(wL,{title:`Enable`,section:`enable`,failure:l,children:(0,Q.jsx)(OL,{draft:a,patch:y,automation:e})}),l?.section===`form`?(0,Q.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-3 text-sm text-destructive`,children:[(0,Q.jsx)(`span`,{className:`break-words`,children:l.message}),l.conflict&&i?(0,Q.jsx)(E,{type:`button`,variant:`outline`,onClick:i,children:`Reload`}):null]}):null,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(E,{type:`submit`,disabled:d,children:d?`Saving…`:S}),(0,Q.jsx)(E,{type:`button`,variant:`outline`,asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations`,children:`Cancel`})})]}),e?(0,Q.jsxs)(`div`,{className:`grid justify-items-start gap-2 border-t pt-4`,children:[p?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? It will stop running and cannot be restored.`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(E,{type:`button`,variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:h,onClick:()=>void x(),children:`Delete automation`}),(0,Q.jsx)(E,{type:`button`,variant:`outline`,disabled:h,onClick:()=>{m(!1),v(``)},children:`Keep`})]})]}):(0,Q.jsx)(E,{type:`button`,variant:`outline`,"data-action":`automation-delete`,onClick:()=>m(!0),children:`Delete`}),_?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:_}):null]}):null]}),(0,Q.jsxs)(`aside`,{className:`min-w-0 md:sticky md:top-4`,children:[C?(0,Q.jsx)(bL,{schedule:a.schedule,timeZone:n}):(0,Q.jsxs)(`section`,{className:`rounded-xl border bg-card p-4`,children:[(0,Q.jsx)(`h2`,{className:`mb-2 text-[15px] font-medium`,children:`How it polls`}),(0,Q.jsx)(`p`,{className:`text-sm break-words text-muted-foreground`,children:rL(a)})]}),(0,Q.jsx)(YI,{draft:a})]})]})})}function AL({draft:e,patch:t}){let n=wn(),r=sn(),i=$n(),a=e.runner??i.data?.defaultRunner??`claude`,o=xr(a),s=[...new Set([...(n.data?.workflows??[]).map(e=>e.name),...e.workflow?[e.workflow]:[]])],c=[...new Set([...Vt(r.data),...e.runner?[e.runner]:[]])],l=zs(a,o.data,[e.model]),u=l.find(t=>t.id===(e.model??``))?.label??e.model??`auto`,d=e=>(0,Q.jsx)(e,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`});return(0,Q.jsx)(Zs,{children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(ic,{slot:`automation-workflow-pill`,icon:d(Zi),fieldLabel:!0,ariaLabel:`Workflow`,label:e.workflow??`inline steps`,value:e.workflow??``,disabled:e.workflow===void 0,disabledHint:`This automation carries its own steps.`,options:s.map(e=>({value:e,label:e})),onPick:e=>t({workflow:e})}),(0,Q.jsx)(ic,{slot:`automation-runner-pill`,icon:d(la),fieldLabel:!0,ariaLabel:`Runner`,label:e.runner??`default`,value:e.runner??``,options:[{value:``,label:`default`,desc:`The project’s default runner`},...c.map(e=>({value:e,label:Us.find(t=>t.id===e)?.label??e}))],onPick:e=>{t({runner:e||void 0,model:void 0})}}),(0,Q.jsx)(ic,{slot:`automation-model-pill`,icon:d(Gi),fieldLabel:!0,ariaLabel:`Model`,label:u,value:e.model??``,options:l.map(e=>({value:e.id,label:e.label,desc:e.desc})),onPick:e=>t({model:e||void 0})})]})})}function jL({data:e,error:t,refresh:n,archived:r=!1,onArchivedChange:i}){let[o,s]=(0,Z.useState)({}),[c,l]=(0,Z.useState)({}),u=(e,t)=>s(n=>{let{[e]:r,...i}=n;return t?{...i,[e]:t}:i}),d=async(e,t)=>{l(t=>({...t,[e]:!0}));try{await t()}catch(t){u(e,{text:t instanceof Error?t.message:String(t),tone:`error`})}finally{l(t=>({...t,[e]:!1}))}},f=e=>d(e.id,async()=>{u(e.id,{text:`Starting…`,tone:`info`});let{runId:t}=await bt(e.id);u(e.id,{text:`Started task`,tone:`info`,runId:t}),n()}),p=e=>d(e.id,async()=>{u(e.id,void 0),await Ft(e.id,!e.enabled),await n()}),m=e=>d(e.id,async()=>{u(e.id,void 0),await Mt(e.id),await n()}),h=e=>d(e.id,async()=>{u(e.id,{text:`Checking…`,tone:`info`});let{checkId:t}=await yt(e.id,`preview`);for(let r=0;r<60;r+=1){let r=await Le(t);if(r.status===`complete`){u(e.id,{text:`${r.matches??0} filter match${r.matches===1?``:`es`} found; no tasks launched. Counts can include closed items and previously processed events.`,tone:`info`}),n();return}if(r.status===`error`)throw Error(r.error??`Preview failed`);await new Promise(e=>setTimeout(e,500))}throw Error(`Preview is still running`)});return(0,Q.jsx)(bI,{title:`Automations`,subtitle:`Schedules and GitHub checks run while ${a(`Cezarion`)} is open.`,action:(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations/new`,children:`New automation`})}),children:t&&!e?(0,Q.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,Q.jsx)(xI,{text:t}),(0,Q.jsx)(E,{variant:`outline`,onClick:()=>void n(),children:`Retry`})]}):e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ML,{data:e}),i?(0,Q.jsx)(`div`,{className:`mb-4 flex flex-wrap gap-2`,children:(0,Q.jsx)(XI,{pressed:r,onClick:()=>i(!r),children:`Archived`})}):null,r&&e.automations.length===0?(0,Q.jsx)(xI,{text:`No archived one-time schedules.`}):e.automations.length===0?(0,Q.jsx)(X,{icon:(0,Q.jsx)($i,{}),tone:`neutral`,title:`No automations yet`,subtitle:`Create one paused, preview it, then enable it.`,heading:`h2`,actions:(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations/new`,children:`New automation`})})}):(0,Q.jsx)(`ul`,{className:`grid gap-3`,"aria-label":`Automations`,children:e.automations.map(t=>(0,Q.jsx)(UL,{automation:t,timeZone:e.timeZone,note:o[t.id],busy:c[t.id]===!0,onRun:()=>void f(t),onToggle:()=>void p(t),onPreview:()=>void h(t),onCancel:()=>void m(t)},t.id))})]}):(0,Q.jsx)(xI,{text:`Loading automations…`})})}function ML({data:e}){return(0,Q.jsx)(`p`,{"data-slot":`automation-scheduler`,className:D(`mb-4 text-xs break-words`,e.scheduler.state===`scheduled`?`text-success`:`text-muted-foreground`),children:`Scheduler ${e.scheduler.state===`scheduled`?`running`:`idle`} · GitHub ${e.available?`available`:`unavailable`}${e.reason?` · ${e.reason}`:``} · ${e.timeZone}`})}function NL(e){return e.kind===`schedule`&&e.schedule?FF(e.schedule):`on ${(e.events??[]).join(`, `)} · every ${Math.round((e.intervalSeconds??300)/60)} min`}var PL={waiting:{label:`Waiting`,dot:`success`},paused:{label:`Paused`,dot:`neutral`},failed:{label:`Failed`,dot:`danger`},missed:{label:`Missed`,dot:`pending`},archived:{label:`Archived`,dot:`neutral`}};function FL(e){if(e.schedule?.type===`once`)return PL[e.onceStatus??(e.enabled?`waiting`:`paused`)]}function IL({automation:e,badge:t}){return(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`h2`,{className:`flex items-center gap-2 font-semibold break-words`,children:[(0,Q.jsx)(e.kind===`schedule`?Vi:Mi,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),e.name]}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[13px] break-words text-muted-foreground`,children:NL(e)})]}),t?(0,Q.jsx)(KM,{dot:t.dot,children:t.label}):(0,Q.jsx)(KM,{dot:e.enabled?`success`:`neutral`,children:e.enabled?`Enabled`:`Paused`})]})}function LL({automation:e,archive:t}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`mt-3 text-sm break-words`,children:[t.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`,t.runId?(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsx)(Y,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${t.runId}`,children:`Open task`})]}):null]}),(0,Q.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:(0,Q.jsx)(E,{variant:`outline`,asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations/${e.id}`,children:`Details`})})})]})}function RL({automation:e,timeZone:t}){let n=e.kind===`schedule`,r=e.enabled&&n?e.nextRunAt:void 0;return(0,Q.jsx)(`p`,{className:`mt-3 text-sm`,children:!n&&e.enabled?(0,Q.jsx)(`span`,{children:`continuous`}):r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{children:`Next run: ${WF(r,t)}`}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:` · ${VF(Date.now(),Date.parse(r))}`})]}):(0,Q.jsx)(`span`,{children:`Next run: —`})})}function zL({automation:e,timeZone:t}){let n=e.enabled?cI(e.state):void 0;return n?(0,Q.jsxs)(`p`,{role:`alert`,"data-slot":`automation-failing`,className:`mt-3 text-sm break-words text-destructive`,children:[`The last ${n.consecutiveFailures} checks failed: ${n.lastError}`,n.retryAt?(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:` · Next try ${WF(n.retryAt,t)}`}):null]}):null}function BL({automation:e,busy:t,confirmingCancel:n,cancelRef:r,onToggle:i,onRun:a,onPreview:o,onOpenCancel:s}){let c=e.kind===`schedule`,l=e.schedule?.type===`once`;return(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,Q.jsx)(E,{variant:`outline`,asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations/${e.id}`,children:`Edit`})}),(0,Q.jsx)(E,{variant:`outline`,asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations/${e.id}/log`,children:`Execution log`})}),(0,Q.jsx)(E,{variant:`outline`,"data-action":`automation-toggle`,disabled:t,onClick:i,children:e.enabled?`Pause`:`Enable`}),c?(0,Q.jsx)(E,{variant:`outline`,"data-action":`automation-run`,disabled:t,onClick:a,children:`Run now`}):(0,Q.jsx)(E,{variant:`outline`,"data-action":`automation-preview`,disabled:t,onClick:o,children:`Test filter`}),l&&!n?(0,Q.jsx)(E,{variant:`outline`,ref:r,"data-action":`automation-cancel`,disabled:t,onClick:s,children:`Cancel`}):null]})}function VL({automation:e,busy:t,keepRef:n,onConfirm:r,onKeep:i}){return(0,Q.jsxs)(`div`,{className:`mt-3 grid justify-items-start gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-sm break-words`,children:`Cancel “${e.name}”? It will never run, and it moves to Archived.`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(E,{variant:`danger-ghost`,"data-action":`automation-cancel-confirm`,disabled:t,onClick:r,children:`Cancel schedule`}),(0,Q.jsx)(E,{ref:n,variant:`outline`,disabled:t,onClick:i,children:`Keep`})]})]})}function HL({note:e}){return(0,Q.jsxs)(`p`,{role:e.tone===`error`?`alert`:`status`,className:D(`mt-3 text-sm break-words`,e.tone===`error`?`text-destructive`:`text-muted-foreground`),children:[e.text,e.runId?(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsx)(Y,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`})]}):null]})}function UL({automation:e,timeZone:t,note:n,busy:r,onRun:i,onToggle:a,onPreview:o,onCancel:s}){let[c,l]=(0,Z.useState)(!1),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),f=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let e=f.current===`keep`?d.current:f.current===`cancel`?u.current:null;f.current=null,e?.focus()},[c]);let p=()=>{f.current=`keep`,l(!0)},m=()=>{f.current=`cancel`,l(!1)},h=e.archived;return(0,Q.jsxs)(`li`,{"data-slot":`automation-card`,"data-kind":e.kind,className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,Q.jsx)(IL,{automation:e,badge:FL(e)}),h?(0,Q.jsx)(LL,{automation:e,archive:h}):null,h?null:(0,Q.jsx)(RL,{automation:e,timeZone:t}),h?null:(0,Q.jsx)(zL,{automation:e,timeZone:t}),h?null:(0,Q.jsx)(BL,{automation:e,busy:r,confirmingCancel:c,cancelRef:u,onToggle:a,onRun:i,onPreview:o,onOpenCancel:p}),e.schedule?.type===`once`&&!h&&c?(0,Q.jsx)(VL,{automation:e,busy:r,keepRef:d,onConfirm:()=>{l(!1),s()},onKeep:m}):null,n?(0,Q.jsx)(HL,{note:n}):null,(0,Q.jsx)(AI,{automationId:e.id,automationName:e.name,timeZone:t})]})}function WL(e){let t=Cs(),n=js(),[r,i]=(0,Z.useState)(),[a,o]=(0,Z.useState)(``),s=(0,Z.useCallback)(t=>ye({signal:t,...e?{archived:e}:{}}).then(e=>{t?.aborted||(i(e),o(``))}).catch(e=>{t?.aborted||o(String(e))}),[e]);return(0,Z.useEffect)(()=>{n&&s()},[n,s]),(0,Z.useEffect)(()=>oe(async e=>{n&&await s(e)}),[n,s]),(0,Z.useEffect)(()=>pl((e,n)=>{if(e!==`automation-change`)return;let r=n;typeof r.project==`string`&&(t===null||r.project===t)&&s()}),[t,s]),{data:r,error:a,refresh:s}}function GL({mode:e=`list`}){let{automationId:t}=r(),n=_s(),[i,o]=(0,Z.useState)(!1),{data:s,error:c,refresh:l}=WL(e===`list`?i?`only`:void 0:`include`),[u,d]=(0,Z.useState)(0),f=Hs();if(f===`unknown`)return(0,Q.jsx)(`div`,{"data-route":`automations`,className:`task-flow-page flex min-h-full flex-col`,children:(0,Q.jsx)(xI,{text:`Loading automations…`})});if(f===`unavailable`)return(0,Q.jsx)(`div`,{"data-route":`automations`,className:`task-flow-page flex min-h-full flex-col`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)($i,{}),tone:`neutral`,title:`Automations are off`,subtitle:`This server does not run schedules, poll GitHub or launch tasks from them. Unset CEZ_AUTOMATIONS or set it to 1 and restart ${a(`cezar`)} to turn automations on.`,heading:`h2`})});let p=()=>{n(`/automations`),l()},m=s?.automations.find(e=>e.id===t);if(e===`list`)return(0,Q.jsx)(jL,{data:s,error:c,refresh:l,archived:i,onArchivedChange:o});if(!s)return c?(0,Q.jsx)(bI,{title:`Automations`,subtitle:`Could not load automations.`,children:(0,Q.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,Q.jsx)(xI,{text:c}),(0,Q.jsx)(E,{variant:`outline`,onClick:()=>void l(),children:`Retry`})]})}):(0,Q.jsx)(`div`,{"data-route":`automations`,className:`task-flow-page flex min-h-full flex-col`,children:(0,Q.jsx)(xI,{text:`Loading automations…`})});let h={available:s.available,...s.reason?{reason:s.reason}:{}};return e===`new`?(0,Q.jsx)(kL,{forge:h,timeZone:s.timeZone,onSaved:p}):e===`edit`?m?m.archived?(0,Q.jsx)(jI,{automation:m,timeZone:s.timeZone,onDeleted:p}):(0,Q.jsx)(kL,{automation:m,forge:h,timeZone:s.timeZone,onSaved:p,onReload:()=>void l().then(()=>d(e=>e+1))},`${m.id}:${u}`):(0,Q.jsx)(bI,{title:`Automation not found`,subtitle:`This automation may have been removed.`,children:(0,Q.jsx)(E,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(Y,{to:`/automations`,children:`Back to automations`})})}):t?(0,Q.jsx)(kI,{automationId:t,automationName:m?.name,timeZone:s.timeZone,readOnly:!!m?.archived}):(0,Q.jsx)(xI,{text:`Automation not found.`})}function KL({health:e,projects:t,repository:n,onAction:r}){return(0,Q.jsxs)(`section`,{className:`space-y-4 rounded-xl border border-border bg-card p-6 max-md:p-4`,"aria-labelledby":`add-project-heading`,children:[(0,Q.jsx)(`h2`,{id:`add-project-heading`,className:`text-lg font-normal leading-[1.5]`,children:`Add project`}),(0,Q.jsx)(`p`,{className:`text-[13px] leading-[1.5] text-muted-foreground`,children:`Start a new repository, open an existing local folder, or clone a GitHub repository.`}),(0,Q.jsxs)(`dl`,{className:`space-y-4 text-[13px] leading-[1.5] text-muted-foreground`,children:[e.data?.repoRoot?(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-x-3`,children:[(0,Q.jsx)(`dt`,{children:`Local folder`}),(0,Q.jsx)(`dd`,{className:`min-w-0 break-all`,children:e.data.repo?.root??e.data.repoRoot})]}):null,n?(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-x-3`,children:[(0,Q.jsx)(`dt`,{children:`Repository`}),(0,Q.jsx)(`dd`,{className:`min-w-0 break-all`,children:n.replace(/^https:\/\//,``)})]}):null,t.data?.projectsDir?(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-x-3`,children:[(0,Q.jsx)(`dt`,{children:`Checkout folder`}),(0,Q.jsx)(`dd`,{className:`min-w-0 break-all`,children:t.data.projectsDir})]}):null]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Q.jsx)(E,{variant:`outline`,className:`h-10 rounded-lg px-[15px] text-xs font-normal leading-[18px]`,"data-action":`new-project`,onClick:()=>r(`new`),children:`New project`}),(0,Q.jsx)(E,{variant:`outline`,className:`h-10 rounded-lg px-[15px] text-xs font-normal leading-[18px]`,onClick:()=>r(`local`),children:`Open local folder`}),(0,Q.jsx)(E,{variant:`outline`,className:`h-10 rounded-lg px-[15px] text-xs font-normal leading-[18px]`,onClick:()=>r(`clone`),children:`Clone from GitHub`})]})]})}function qL({health:e,copying:t,onCopy:n}){return(0,Q.jsxs)(`section`,{className:`space-y-4 rounded-xl border border-border bg-card p-6 max-md:p-4`,"aria-labelledby":`tools-heading`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`h2`,{id:`tools-heading`,className:`text-lg font-normal leading-[1.5]`,children:`Tools diagnostics`}),(0,Q.jsx)(Y,{to:hx,"data-slot":`tools-settings`,className:gx,children:`Tool settings ›`})]}),(0,Q.jsx)(`p`,{className:`text-[13px] leading-[1.5] text-muted-foreground`,children:`Check the tools available to this local workspace.`}),e.isError?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:`Could not refresh tool diagnostics. Recheck to retry.`}):null,!e.data&&!e.isError?(0,Q.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Checking installed tools…`}):null,e.data?(0,Q.jsx)(`dl`,{className:`space-y-4 text-[13px] leading-[1.5] text-muted-foreground`,children:e.data.checks.map(e=>{let t=mx(e);return(0,Q.jsxs)(`div`,{"data-slot":`tool-row`,"data-tool":e.name,"data-available":e.available,className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,Q.jsxs)(`dt`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{tone:fx(e)}),(0,Q.jsx)(`span`,{className:`font-mono text-[13px] font-medium text-foreground`,children:e.name})]}),(0,Q.jsxs)(`dd`,{className:`flex min-w-0 flex-1 items-center gap-x-3 text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 break-words`,children:[px(e),e.version?` · ${e.version}`:``]}),e.available?null:(0,Q.jsx)(Y,{to:hx,"data-slot":`tool-setup`,className:`${gx} ml-auto`,children:`Set up ›`})]}),t?(0,Q.jsx)(`dd`,{"data-slot":`tool-hint`,className:`basis-full min-w-0 break-words pl-[15px] text-xs leading-snug text-muted-foreground`,children:t}):null]},e.name)})}):null,e.data?.checks.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No tool diagnostics reported by this server.`}):null,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Q.jsx)(E,{variant:`outline`,className:`h-10 rounded-lg px-[15px] text-xs font-normal leading-[18px]`,disabled:e.isFetching,onClick:()=>void e.refetch(),children:e.isFetching?`Checking tools…`:`Recheck tools`}),(0,Q.jsx)(E,{variant:`outline`,className:`h-10 rounded-lg px-[15px] text-xs font-normal leading-[18px]`,disabled:!e.data||t,onClick:()=>void n(),children:t?`Copying…`:`Copy diagnostics`})]})]})}function JL(){let e=On(),t=An(),n=vn(e.data?.repo?.remote),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{"data-route":`workspace-tools`,className:`w-full space-y-[22px] px-9 py-9 max-md:px-[18px] max-md:py-6`,children:[(0,Q.jsx)(`h1`,{className:`text-[28px] font-normal leading-[1.5] max-md:text-[24px]`,children:`Workspace tools`}),(0,Q.jsx)(KL,{health:e,projects:t,repository:n,onAction:i}),(0,Q.jsx)(qL,{health:e,copying:a,onCopy:async()=>{if(!(!e.data||a)){o(!0);try{await navigator.clipboard.writeText(JSON.stringify({version:e.data.version,checks:e.data.checks},null,2)),G(`Diagnostics copied`)}catch{G(`Could not copy diagnostics. Please try again.`,{tone:`danger`})}finally{o(!1)}}}}),r===`new`?(0,Q.jsx)(nh,{open:!0,onOpenChange:e=>{e||i(null)}}):null,r===`local`?(0,Q.jsx)(Pm,{open:!0,onOpenChange:e=>{e||i(null)}}):null,r===`clone`?(0,Q.jsx)(zm,{open:!0,onOpenChange:e=>{e||i(null)}}):null]})}var YL=(0,Z.lazy)(()=>U(()=>import(`./task-thread-C6v4ddX-.js`).then(e=>({default:e.TaskThreadRoute})),__vite__mapDeps([34,5,7,8,9,28,10,11,27,29,30,31,12,35,13,23,21,22,24,36,37,20,16,17,38,39,40,41,25,42,43,44,19,18,45,46,33,47,48,49]))),XL=(0,Z.lazy)(()=>U(()=>import(`./task-changes-Ozgv3HxN.js`).then(e=>({default:e.TaskChangesRoute})),__vite__mapDeps([50,5,7,8,9,10,11,27,28,29,30,31,12,35,13,23,21,22,24,36,37,20,16,17,38,39,40,41,25,42,43,51,52,44,33,53,54,55,47]))),ZL=(0,Z.lazy)(()=>U(()=>import(`./task-files-V84lmxj2.js`).then(e=>({default:e.TaskFilesRoute})),__vite__mapDeps([56,5,7,8,9,10,11,27,28,29,30,31,12,22,13,37,35,23,21,24,36,20,16,17,38,39,40,41,25,42,43,32,33]))),QL=(0,Z.lazy)(async()=>{let{TaskReportRoute:e}=await U(async()=>{let{TaskReportRoute:e}=await import(`./report-reader-CIcjK2_U.js`);return{TaskReportRoute:e}},__vite__mapDeps([26,5,7,8,9,10,11,27,28,29,30,31,12,22,32,13,33]));return{default:e}}),$L=(0,Z.lazy)(()=>U(()=>import(`./task-commits-BxAERDIz.js`).then(e=>({default:e.TaskCommitsRoute})),__vite__mapDeps([57,5,7,8,9,10,11,27,28,29,30,31,12,35,13,23,21,22,24,36,37,20,16,17,38,39,40,41,25,42,43,33,58,52,44,54,55,47]))),eR=(0,Z.lazy)(()=>U(()=>import(`./task-github-item-CByJ7mYg.js`).then(e=>({default:e.TaskGithubItemRoute})),__vite__mapDeps([59,7,5,8,9,10,11,27,28,29,30,31,12,35,13,23,21,22,24,36,37,20,16,17,38,39,40,41,25,42,43,33,60,44,18,61,45,46,62,54,55,47,63]))),tR=(0,Z.lazy)(()=>U(()=>import(`./repo-git-Y7MKcjLs.js`).then(e=>({default:e.RepoGitRoute})),__vite__mapDeps([64,5,7,8,9,10,11,27,28,29,30,31,12,35,13,23,21,22,24,36,65,52,44,51,16,17,39,40,25,33,53,54,55,47,58,66]))),nR=(0,Z.lazy)(()=>U(()=>import(`./github-DKC9GSOG.js`).then(e=>({default:e.GithubRoute})),__vite__mapDeps([67,5,7,8,9,10,11,27,28,29,30,31,12,35,13,23,21,22,24,36,65,17,61,25,45,40,41,46,62,33,60,44,38,18,54,55,47,42,63]))),rR=(0,Z.lazy)(()=>U(()=>import(`./reports-SBr0VYKU.js`).then(e=>({default:e.ReportsRoute})),__vite__mapDeps([68,5,7,8,9,10,11,29,31,25,48,69]))),iR=(0,Z.lazy)(()=>U(()=>import(`./workflows-Cb0BDqy5.js`).then(e=>({default:e.WorkflowsRoute})),__vite__mapDeps([70,5,7,8,9,10,11,27,28,29,30,31,12,22,21,23,24,40,41,71,62,33,72]))),aR=(0,Z.lazy)(()=>U(()=>import(`./activity-route-6spKzFa-.js`).then(e=>({default:e.ProjectActivityRoute})),__vite__mapDeps([73,5,7,8,9,14,13,74,28,10,11,30,31,15,44,38,25,36,75]))),oR=(0,Z.lazy)(()=>U(()=>import(`./global-activity-route-BnUvjKgI.js`).then(e=>({default:e.GlobalActivityRoute})),__vite__mapDeps([76,5,7,8,9,27,28,10,11,29,30,31,12,74,13,15,44,38,25,36,75]))),sR=(0,Z.lazy)(()=>U(()=>import(`./skills-B_NKCTPq.js`).then(e=>({default:e.SkillsRoute})),__vite__mapDeps([77,5,7,8,9,10,11,27,28,29,30,31,12,22,25,62,33,72])));function cR(){let e=t();return(0,Q.jsx)(Ss,{to:{pathname:`/skills`,search:e.search,hash:e.hash},replace:!0})}function lR({sectionId:e}){let n=t();return(0,Q.jsx)(_,{to:{pathname:_j(`global`,e),search:n.search,hash:n.hash},replace:!0})}function uR(){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 dR(){let{projectId:e=``}=r(),n=t(),i=An(),a=On();if(e==="default"){let e=i.data?.bootProject??(i.isError?a.data?.bootProject:void 0);if(e!==void 0){let t=n.pathname.replace(/^\/p\/default(?=\/|$)/,``);return(0,Q.jsx)(_,{to:`/p/${encodeURIComponent(e)}${t||`/`}${n.search}${n.hash}`,replace:!0})}if(!i.isError)return(0,Q.jsx)(uR,{})}if(i.data){if(!(i.data.bootProject===e||i.data.projects.some(t=>t.id===e)))return(0,Q.jsx)(Lk,{projectId:e,registry:i.data})}else if(!i.isError)return(0,Q.jsx)(uR,{});return(0,Q.jsx)(pt,{projectId:i.data?.bootProject===e?null:e,children:(0,Q.jsx)(g,{},e)})}function fR(){let{projectId:e=``}=r();return(0,Q.jsx)(xk,{},e)}var pR=/^\/tasks\/([0-9a-f-]{36})(?=\/|$)/i;function mR(e,t){let n=e.data?.bootProject??t.data?.bootProject;return{resolved:n,settled:(e.data!==void 0||e.isError)&&(t.data!==void 0||t.isError),boot:n??`default`}}function hR(e,t,n){if(!(e.pathname===`/`&&e.search===``&&e.hash===``))return;if(t.data===void 0&&!t.isError)return(0,Q.jsx)(uR,{});let r=A_(b_(),t.data,n);if(r!==null)return(0,Q.jsx)(_,{to:r,replace:!0})}function gR(e,t,n,r,i,a){if(!n)return null;let o=i.data?.runs.find(t=>t.id===e)?.projectId;return o===void 0?r?a.data===void 0&&!a.isError?null:a.data?.runs.find(t=>t.id===e)?.projectId??t:t:o}function _R(e,t){let n=t.pathname===`/p`||t.pathname===`/p/`?`/`:t.pathname;return(0,Q.jsx)(_,{to:`/p/${encodeURIComponent(e)}${n}${t.search}${t.hash}`,replace:!0})}function vR(){let e=t(),n=On(),r=An(),i=pR.exec(e.pathname)?.[1]??null,a=mn(i!==null),o=a.data!==void 0||a.isError,s=a.data!==void 0&&!a.data.runs.some(e=>e.id===i),c=pn(i!==null&&s?i:``),{resolved:l,settled:u,boot:d}=mR(n,r);if(l===void 0&&!u)return(0,Q.jsx)(uR,{});let f=hR(e,r,l);if(f!==void 0)return f;let p=d;if(i!==null){let e=gR(i,d,o,s,a,c);if(e===null)return(0,Q.jsx)(uR,{});p=e}return _R(p,e)}function yR(){return(0,Q.jsxs)(d,{path:`/p/:projectId`,element:(0,Q.jsx)(dR,{}),children:[(0,Q.jsx)(d,{index:!0,element:(0,Q.jsx)(rP,{})}),(0,Q.jsx)(d,{path:`new`,element:(0,Q.jsx)(fR,{})}),(0,Q.jsx)(d,{path:`activity`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(mT,{}),children:(0,Q.jsx)(aR,{})})}),(0,Q.jsxs)(d,{path:`tasks/:id`,element:(0,Q.jsx)(UA,{}),children:[(0,Q.jsx)(d,{index:!0,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Uk,{}),children:(0,Q.jsx)(YL,{})})}),(0,Q.jsx)(d,{path:`changes`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(zk,{tab:`changes`}),children:(0,Q.jsx)(XL,{})})}),(0,Q.jsx)(d,{path:`files`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(zk,{tab:`files`}),children:(0,Q.jsx)(ZL,{})})}),(0,Q.jsx)(d,{path:`report`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{"data-route":`task-report`,children:(0,Q.jsx)(`h1`,{className:`p-4 text-sm text-soft-foreground`,children:`Loading report…`})}),children:(0,Q.jsx)(QL,{})})}),(0,Q.jsx)(d,{path:`commits`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(zk,{tab:`changes`}),children:(0,Q.jsx)($L,{})})}),(0,Q.jsx)(d,{path:`commits/:sha`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(zk,{tab:`changes`}),children:(0,Q.jsx)($L,{})})}),(0,Q.jsx)(d,{path:`issue/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Hk,{kind:`issue`}),children:(0,Q.jsx)(eR,{kind:`issue`})})}),(0,Q.jsx)(d,{path:`pr/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Hk,{kind:`pr`}),children:(0,Q.jsx)(eR,{kind:`pr`})})})]}),(0,Q.jsx)(d,{path:`git`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Fk,{}),children:(0,Q.jsx)(tR,{section:`main`,index:!0})})}),(0,Q.jsx)(d,{path:`git/commits`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Fk,{}),children:(0,Q.jsx)(tR,{section:`main`})})}),(0,Q.jsx)(d,{path:`git/commits/:sha`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Fk,{}),children:(0,Q.jsx)(tR,{section:`main`})})}),(0,Q.jsx)(d,{path:`git/not-landed`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Fk,{}),children:(0,Q.jsx)(tR,{section:`not-landed`})})}),(0,Q.jsx)(d,{path:`git/cleanup`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Fk,{}),children:(0,Q.jsx)(tR,{section:`cleanup`})})}),(0,Q.jsx)(d,{path:`git/branches`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Fk,{}),children:(0,Q.jsx)(tR,{section:`branches`})})}),(0,Q.jsx)(d,{path:`git/changes`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Fk,{}),children:(0,Q.jsx)(tR,{section:`changes`})})}),(0,Q.jsx)(d,{path:`github`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(hT,{}),children:(0,Q.jsx)(nR,{view:`issues`,index:!0})})}),(0,Q.jsx)(d,{path:`github/prs`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(hT,{}),children:(0,Q.jsx)(nR,{view:`prs`})})}),(0,Q.jsx)(d,{path:`github/issues/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(hT,{}),children:(0,Q.jsx)(nR,{view:`issues`})})}),(0,Q.jsx)(d,{path:`github/prs/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(hT,{}),children:(0,Q.jsx)(nR,{view:`prs`})})}),(0,Q.jsx)(d,{path:`github/prs/:n/changes`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(hT,{}),children:(0,Q.jsx)(nR,{view:`prs`,changes:!0})})}),(0,Q.jsx)(d,{path:`automations`,element:(0,Q.jsx)(GL,{})}),(0,Q.jsx)(d,{path:`automations/new`,element:(0,Q.jsx)(GL,{mode:`new`})}),(0,Q.jsx)(d,{path:`automations/:automationId`,element:(0,Q.jsx)(GL,{mode:`edit`})}),(0,Q.jsx)(d,{path:`automations/:automationId/log`,element:(0,Q.jsx)(GL,{mode:`log`})}),(0,Q.jsx)(d,{path:`skills`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Ik,{}),children:(0,Q.jsx)(sR,{})})}),(0,Q.jsx)(d,{path:`reports`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading reports…`}),children:(0,Q.jsx)(rR,{})})}),(0,Q.jsx)(d,{path:`workflows`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Rk,{}),children:(0,Q.jsx)(iR,{})})}),(0,Q.jsx)(d,{path:`workflows/:name`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Rk,{}),children:(0,Q.jsx)(iR,{})})}),(0,Q.jsx)(d,{path:`settings`,element:(0,Q.jsx)(Cj,{})}),(0,Q.jsx)(d,{path:`settings/skills`,element:(0,Q.jsx)(cR,{})}),Qw(`project`).map(e=>(0,Q.jsx)(d,{path:`settings/${e.id}`,element:(0,Q.jsx)(Sj,{section:e,scope:`project`})},e.id)),Qw(`global`).map(e=>(0,Q.jsx)(d,{path:`settings/${e.id}`,element:(0,Q.jsx)(lR,{sectionId:e.id})},e.id)),(0,Q.jsx)(d,{path:`*`,element:(0,Q.jsx)(Nk,{})})]})}function bR(e){let t=A(j(yR()),e),n=t?.at(-1);return!t||!n||n.route.path===`*`?null:{pattern:`/${t.slice(1).map(e=>e.route.path).filter(e=>e!==void 0).join(`/`)}`.replace(/\/$/,``)||`/`,params:n.params}}function xR(){return(0,Q.jsxs)(O,{children:[yR(),(0,Q.jsx)(d,{path:`/tasks`,element:(0,Q.jsx)(YP,{})}),(0,Q.jsx)(d,{path:`/tools`,element:(0,Q.jsx)(JL,{})}),(0,Q.jsx)(d,{path:`/activity`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(mT,{}),children:(0,Q.jsx)(oR,{})})}),(0,Q.jsx)(d,{path:`/settings/global`,element:(0,Q.jsx)(_,{to:vj,replace:!0})}),(0,Q.jsx)(d,{path:`/settings/global/skills`,element:(0,Q.jsx)(_,{to:`/skills`,replace:!0})}),Qw(`global`).map(e=>(0,Q.jsx)(d,{path:_j(`global`,e.id),element:(0,Q.jsx)(Sj,{section:e,scope:`global`})},e.id)),(0,Q.jsx)(d,{path:`*`,element:(0,Q.jsx)(vR,{})})]})}function SR(){let[e]=(0,Z.useState)(eu);return(0,Z.useEffect)(()=>Dr(e),[e]),(0,Q.jsx)(nu,{children:(0,Q.jsx)(ge,{client:e,children:(0,Q.jsxs)(Ml,{children:[(0,Q.jsx)($l,{}),(0,Q.jsx)(fT,{}),(0,Q.jsx)($h,{children:(0,Q.jsx)(WC,{children:(0,Q.jsxs)(h,{children:[(0,Q.jsx)(dT,{}),(0,Q.jsx)(tu.Provider,{value:bR,children:(0,Q.jsx)(Wa,{children:(0,Q.jsx)(uT,{children:(0,Q.jsx)(xR,{})})})}),(0,Q.jsx)(Si,{})]})})})]})})})}var CR=document.querySelector(`meta[name="cez-api-base"]`)?.getAttribute(`content`);c(ne(CR,void 0,void 0));var wR=document.getElementById(`root`);if(!wR)throw Error(`${a(`cezar`)}: #root container is missing from index.html`);(0,Wc.createRoot)(wR).render((0,Q.jsx)(Z.StrictMode,{children:(0,Q.jsx)(SR,{})}));export{pC as $,od as $t,Pk as A,rb as At,ZD as B,Mg as Bt,qk as C,nb as Ct,zk as D,ab as Dt,Bk as E,Yy as Et,mO as F,Pg as Ft,UD as G,ug as Gt,vD as H,ig as Ht,fO as I,Ig as It,iD as J,uh as Jt,uD as K,dg as Kt,uO as L,Ng as Lt,hO as M,Vy as Mt,_O as N,uv as Nt,Rk as O,cb as Ot,pO as P,sv as Pt,mT as Q,Im as Qt,tO as R,Fg as Rt,Xk as S,sb as St,Hk as T,Xy as Tt,xD as U,lg as Ut,yD as V,kg as Vt,VD as W,fg as Wt,yT as X,ch as Xt,vT as Y,lh as Yt,hT as Z,Um as Zt,TA as _,au as _n,Hb as _t,CM as a,Uu as an,Qx as at,pA as b,ib as bt,GA as c,Pu as cn,Ux as ct,VA as d,bu as dn,Ax as dt,rd as en,GS as et,zA as f,pu as fn,kx as ft,yA as g,cu as gn,Mx as gt,CA as h,uu as hn,Lx as ht,GM as i,Wu as in,nS as it,gO as j,qy as jt,Fk as k,Zy as kt,qA as l,ku as ln,Gx as lt,SA as m,du as mn,Bx as mt,bN as n,Qu as nn,RS as nt,SM as o,Bu as on,Yx as ot,xA as p,fu as pn,zx as pt,fD as q,$ as qt,KM as r,Ju as rn,rS as rt,xM as s,Fu as sn,qx as st,VF as t,td as tn,WS as tt,KA as u,Tu as un,Vx as ut,dA as v,iu as vn,hb as vt,Uk as w,tb as wt,Qk as x,Qy as xt,fA as y,mb as yt,WD as z,Ag as zt};