@wjarka/cezarion 0.14.7 → 0.14.8

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.
@@ -1,7 +1,7 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/task-thread-DDPFDS8C.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-runtime-CCIEwYL0.js","assets/alert-dialog-B422RI-k.js","assets/utils-PYYcpCFZ.js","assets/bundle-mjs-BT31bpU6.js","assets/collapsible-Cy_Fmkrd.js","assets/agent-accounts-BZm_2WAv.js","assets/dropdown-menu-dwDGT8MM.js","assets/textarea-FjaU370i.js","assets/createLucideIcon-BHp8sXmF.js","assets/pill-BsbO6G7y.js","assets/external-link-BE6y205O.js","assets/square-terminal-B6RYYieR.js","assets/prompt-templates-BlTGJB5W.js","assets/run-header-IFyIGCey.js","assets/project-router-DbLkll25.js","assets/markdown-C_IcKVQd.js","assets/chunk-BO2N2NFS-DE6qKn3r.js","assets/lib-BxQXEXDF.js","assets/highlighter-CdHqIwFr.js","assets/diff-stat-Cgnl_hYF.js","assets/token-metrics-Clxh03bE.js","assets/tab-link-BWNp3mLY.js","assets/use-desktop-BaYgO7YW.js","assets/run-header-BJQfFL2l.css","assets/message-square-B-MD-8rD.js","assets/search-x-I9Q8pgUa.js","assets/thread-loading-77sJ8Yu_.js","assets/skills-DFBiAuJG.js","assets/use-submit-shortcut-KWJsC906.js","assets/lib-BQXq3kEf.js","assets/zoomable-image-Z3JDnm0b.js","assets/run-diff-CyG0Nciv.js","assets/chevron-right-BENZ-1ZN.js","assets/task-thread-Dc3wplva.css","assets/compare-variants-D2dRj6H_.js","assets/task-changes-CpJImtq8.js","assets/git-toolbar-UiHnGvE0.js","assets/diff-controls-BGrXGi7O.js","assets/diff-tRE59UNb2.js","assets/image-preview-C2JGcBlC.js","assets/task-files-CjTiGtjt.js","assets/task-commits-hujrykPI.js","assets/commit-list-CLxXMZvP.js","assets/repo-git-CWD2dO8S.js","assets/repo-git-Dkgz4rfB.css","assets/github-CaGjGQnW.js","assets/github-DTIn5Tro.css","assets/workflows-DGUQmWy7.js","assets/skill-empty-hint-oOtzR3v0.js","assets/skills-e7wHnuoc.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/task-thread-DGM2dZV-.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-runtime-CCIEwYL0.js","assets/alert-dialog-B422RI-k.js","assets/utils-PYYcpCFZ.js","assets/bundle-mjs-BT31bpU6.js","assets/collapsible-Cy_Fmkrd.js","assets/agent-accounts-BZm_2WAv.js","assets/dropdown-menu-dwDGT8MM.js","assets/textarea-FjaU370i.js","assets/createLucideIcon-BHp8sXmF.js","assets/pill-BsbO6G7y.js","assets/external-link-BE6y205O.js","assets/square-terminal-B6RYYieR.js","assets/prompt-templates-BlTGJB5W.js","assets/run-header-IFyIGCey.js","assets/project-router-DbLkll25.js","assets/markdown-C_IcKVQd.js","assets/chunk-BO2N2NFS-DE6qKn3r.js","assets/lib-BxQXEXDF.js","assets/highlighter-CdHqIwFr.js","assets/diff-stat-Cgnl_hYF.js","assets/token-metrics-Clxh03bE.js","assets/tab-link-BWNp3mLY.js","assets/use-desktop-BaYgO7YW.js","assets/run-header-BJQfFL2l.css","assets/message-square-B-MD-8rD.js","assets/search-x-I9Q8pgUa.js","assets/thread-loading-77sJ8Yu_.js","assets/skills-DFBiAuJG.js","assets/use-submit-shortcut-KWJsC906.js","assets/lib-BQXq3kEf.js","assets/zoomable-image-Z3JDnm0b.js","assets/run-diff-CyG0Nciv.js","assets/chevron-right-BENZ-1ZN.js","assets/task-thread-BQFdz1dJ.css","assets/compare-variants-Ciqwvd_f.js","assets/task-changes-D2PHtWUW.js","assets/git-toolbar-UiHnGvE0.js","assets/diff-controls-BGrXGi7O.js","assets/diff-tRE59UNb2.js","assets/image-preview-C2JGcBlC.js","assets/task-files-BS7c7CFm.js","assets/task-commits-N5u9U0_R.js","assets/commit-list-Dcnk7TnI.js","assets/repo-git-Bm3s6Why.js","assets/repo-git-Dkgz4rfB.css","assets/github-D-MrkbJ7.js","assets/github-DTIn5Tro.css","assets/workflows-Czl0ZfXH.js","assets/skill-empty-hint-oOtzR3v0.js","assets/skills-C-C4DVFY.js"])))=>i.map(i=>d[i]);
2
2
  import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,n,t as r}from"./react-runtime-CCIEwYL0.js";import{$i as i,$t as a,Aa as o,An as s,Ar as c,B as l,Ba as u,Bn as d,Br as f,Bt as p,C as m,Ca as h,Ci as g,Cr as _,Ct as v,D as y,Dn as b,Dr as x,Dt as S,Er as C,Et as ee,F as w,Ft as te,Ga as T,Gn as E,Gr as D,Ha as ne,Ht as re,Ia as ie,Ii as ae,In as oe,Ir as se,It as ce,J as le,Ja as O,Ji as ue,Jn as de,Jr as fe,Ka as pe,Ki as k,Kn as me,Kr as A,Kt as he,L as ge,La as j,Ln as M,Lr as _e,M as ve,Mt as ye,N,Na as be,Nn as xe,Nr as Se,Nt as Ce,O as we,Oa as Te,Or as Ee,Ot as De,Pi as Oe,Qi as ke,Ra as Ae,Ri as je,Rn as Me,Rr as Ne,Rt as Pe,Sa as Fe,Si as Ie,Sr as P,St as Le,T as Re,Ta as F,Tn as ze,Tt as Be,Ua as Ve,Ui as He,Un as Ue,Ur as We,Ut as Ge,V as Ke,Va as qe,Vi as Je,Vn as Ye,Vr as Xe,Vt as Ze,W as Qe,Wa as $e,Wn as et,Wr as tt,X as nt,Xi as rt,Xr as it,Y as at,Yi as ot,Yt as st,Z as ct,Zn as lt,Zr as ut,_a as dt,_n as ft,_r as pt,a as mt,aa as ht,ai as gt,an as _t,at as vt,ba as yt,br as bt,c as xt,ca as St,cn as Ct,cr as wt,d as I,da as Tt,dn as Et,dt as Dt,ei as Ot,en as kt,fa as At,fi as jt,fn as Mt,fr as Nt,ft as Pt,ga as Ft,gi as It,gr as Lt,gt as Rt,ha as zt,hn as Bt,hr as Vt,ht as Ht,i as Ut,ia as Wt,ii as Gt,in as L,it as Kt,j as qt,ja as Jt,jn as Yt,jr as Xt,k as Zt,ka as Qt,ki as $t,kr as en,l as R,la as tn,li as nn,ln as rn,lr as an,lt as on,ma as z,mi as sn,mr as cn,mt as ln,n as un,na as dn,ni as fn,nn as pn,o as mn,oa as hn,on as gn,or as _n,pa as vn,pn as yn,pr as bn,pt as xn,q as Sn,qa as Cn,qi as wn,qr as Tn,qt as En,r as Dn,ra as On,rn as kn,s as An,sa as B,sn as jn,sr as Mn,t as Nn,ta as Pn,ti as Fn,tn as In,tt as Ln,u as Rn,ua as zn,un as Bn,ur as Vn,va as V,vi as Hn,vr as Un,wa as Wn,wi as Gn,wn as H,wr as Kn,wt as qn,xa as Jn,xr as Yn,ya as Xn,yr as Zn,z as Qn,za as $n,zn as er,zr as tr,zt as nr}from"./alert-dialog-B422RI-k.js";import{O as rr,f as ir,i as ar,l as or,n as sr,o as cr,p as lr,s as ur,t as U}from"./utils-PYYcpCFZ.js";import{i as dr}from"./bundle-mjs-BT31bpU6.js";import{_ as fr,a as pr,c as mr,d as hr,f as gr,g as _r,h as vr,i as yr,l as br,m as xr,p as Sr,r as Cr,t as wr,u as Tr,v as Er,y as Dr}from"./dropdown-menu-dwDGT8MM.js";import{a as Or,i as kr,n as Ar,o as jr,r as Mr,t as Nr}from"./agent-accounts-BZm_2WAv.js";import{a as Pr,i as Fr,n as Ir,o as Lr,r as Rr,s as zr,t as Br}from"./textarea-FjaU370i.js";import{t as W}from"./createLucideIcon-BHp8sXmF.js";import{A as Vr,C as Hr,D as Ur,E as Wr,M as Gr,N as Kr,O as qr,S as Jr,T as Yr,a as Xr,k as G,n as Zr,o as Qr,r as $r,t as ei,v as ti,w as ni,y as ri}from"./pill-BsbO6G7y.js";import{t as ii}from"./chevron-right-BENZ-1ZN.js";import{t as ai}from"./external-link-BE6y205O.js";import{A as oi,C as si,D as ci,E as li,F as ui,I as di,M as fi,N as pi,O as mi,P as hi,S as gi,T as _i,_ as vi,a as yi,b as bi,c as xi,d as Si,f as Ci,g as wi,h as Ti,i as Ei,j as K,k as q,l as Di,m as Oi,n as ki,o as Ai,p as ji,r as Mi,t as Ni,u as Pi,v as Fi,w as Ii,x as Li,y as Ri}from"./prompt-templates-BlTGJB5W.js";import{a as zi,c as Bi,i as Vi,l as Hi,n as Ui,o as Wi,r as Gi,s as Ki,t as J,u as qi}from"./project-router-DbLkll25.js";import{t as Ji}from"./search-x-I9Q8pgUa.js";import{r as Yi,t as Xi}from"./markdown-C_IcKVQd.js";import{a as Zi,c as Qi,d as $i,f as ea,i as ta,o as na,s as ra,t as ia,u as aa}from"./skills-DFBiAuJG.js";import{a as oa,d as sa,f as ca,i as la,l as ua,n as da,o as fa,p as pa,r as ma,t as ha,u as ga}from"./thread-loading-77sJ8Yu_.js";import{t as _a}from"./diff-stat-Cgnl_hYF.js";import{i as va,n as ya,r as ba,t as xa}from"./token-metrics-Clxh03bE.js";import{n as Sa}from"./use-submit-shortcut-KWJsC906.js";import{i as Ca,n as wa,r as Ta}from"./highlighter-CdHqIwFr.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 Ea=class extends O{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 Jt({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=Da(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=Da(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=Da(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=Da(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){j.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=>qe(t,e))}findAll(e={}){return this.getAll().filter(t=>qe(e,t))}notify(e){j.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return j.batch(()=>Promise.all(e.map(e=>e.continue().catch(Ve))))}};function Da(e){return e.options.scope?.id}var Oa=class extends O{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??u(r,t),a=this.get(i);return a||(a=new be({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(){j.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=>ne(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>ne(e,t)):t}notify(e){j.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){j.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){j.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},ka=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Oa,this.#t=e.mutationCache||new Ea,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=Cn.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=ie.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=Ae(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return j.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;j.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return j.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=j.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Ve).catch(Ve)}invalidateQueries(e,t={}){return j.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=j.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(Ve)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Ve)}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(Ve).catch(Ve)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ve).catch(Ve)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return ie.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($n(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{$e(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set($n(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{$e(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||=u(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===pe&&(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()}},Y=e(t(),1),Aa=n();function ja(e,t){if(e===`ping`)return{project:null,event:{type:`ping`}};let n;try{n=JSON.parse(t)}catch{return null}if(!Ma(n))return null;let r=n.project;if(typeof r!=`string`||r===``)return null;switch(e){case`run`:{let{project:e,...t}=n;return Na(t)?{project:r,event:{type:`run`,run:t}}:null}case`run-deleted`:{let e=n.id;return typeof e==`string`&&e?{project:r,event:{type:`run-deleted`,id:e}}:null}case`todos`:return Array.isArray(n.items)?{project:r,event:{type:`todos`,items:n.items}}:null;case`usage`:return Ma(n.usage)?{project:r,event:{type:`usage`,usage:n.usage}}:null;default:return null}}function Ma(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Na(e){return Ma(e)&&typeof e.id==`string`&&e.id!==``}function Pa(e,t){if(!e)return;let n=e.findIndex(e=>e.id===t.id);if(n>=0){let r=[...e];return r[n]=Ia(e[n],t),r}let r=t.createdAt??``,i=e.findIndex(e=>(e.createdAt??``).localeCompare(r)<0),a=[...e];return a.splice(i<0?e.length:i,0,t),a}function Fa(e,t){if(!e)return;let n=e.filter(e=>e.id!==t);return n.length===e.length?e:n}function Ia(e,t){return e?.usage?{...t,usage:e.usage}:t}var La=Object.freeze({});function Ra(){let e=La,t=new Set;return{subscribe(e){return t.add(e),()=>t.delete(e)},get:()=>e,set(n){e=n;for(let e of t)e()}}}var X=r(),za=ar(`/workspace/events`),Ba=2,Va=3e3,Ha=[`run`,`run-deleted`,`todos`,`usage`,`ping`],Ua=[`project-added`,`project-removed`,`checkout-progress`,`automation-change`],Wa=new Set;function Ga(e){return Wa.add(e),()=>{Wa.delete(e)}}var Ka=400;function qa(e){let t;return{onEvent(n){n.type!==`run`&&n.type!==`run-deleted`||t===void 0&&(t=setTimeout(()=>{t=void 0,e.invalidateQueries({queryKey:P.runsIndex})},Ka))},cancel(){clearTimeout(t),t=void 0}}}function Ja(e){return e[1]===`runs`&&e[2]===`list`}function Ya(e){e.invalidateQueries({queryKey:L.runs.all}),e.invalidateQueries({predicate:e=>Ja(e.queryKey)}),e.invalidateQueries({queryKey:P.runsIndex}),e.invalidateQueries({queryKey:L.todos}),e.invalidateQueries({queryKey:L.health}),e.invalidateQueries({queryKey:L.worktrees}),e.invalidateQueries({queryKey:P.providerStatus}),e.invalidateQueries({predicate:({queryKey:e})=>e.length===3&&e[1]===`github`&&(e[2]===null||typeof e[2]==`number`)})}function Xa(e){return cr()??Za(e)}function Za(e){let t=e.getQueryData(P.projects)?.bootProject;return typeof t==`string`&&t!==``?t:e.getQueryData(L.health)?.bootProject??e.getQueryData([`default`,`health`])?.bootProject}function Qa(e,t){return[e===t?`default`:e,`runs`,`list`]}function $a(e,t,n){if(n.type!==`run`&&n.type!==`run-deleted`)return;let r=Qa(t,Za(e));if(n.type===`run`){e.setQueryData(r,e=>Pa(e,n.run));return}e.setQueryData(r,e=>Fa(e,n.id))}function eo(e){let t=new Map;return{refresh(n){let r=L.runs.detail(n);if(!e.getQueryState(r))return;let i=JSON.stringify(r);clearTimeout(t.get(i)),e.cancelQueries({queryKey:r},{revert:!1}),t.set(i,setTimeout(()=>{t.delete(i),e.invalidateQueries({queryKey:r})},400))},cancel(){for(let e of t.values())clearTimeout(e);t.clear()}}}function to(e,t,n,r){switch(n.type){case`run`:{e.invalidateQueries({queryKey:[...L.runs.all,`relationships`]}),e.setQueryData(L.runs.list(),e=>Pa(e,n.run));let t=L.runs.detail(n.run.id);if(e.getQueryData(t)!==void 0&&e.setQueryData(t,e=>Ia(e,n.run)),r(n.run.id),n.run.delegation?.role===`worker`){let t=L.runs.detail(n.run.delegation.parentRunId);e.setQueryData(t,e=>{if(!e)return e;let{finishBlocked:t,...n}=e;return n}),r(n.run.delegation.parentRunId)}let i=L.runs.changes(n.run.id);e.getQueryData(i)!==void 0&&e.invalidateQueries({queryKey:i}),e.invalidateQueries({queryKey:L.worktrees});return}case`run-deleted`:e.invalidateQueries({queryKey:[...L.runs.all,`relationships`]}),e.setQueryData(L.runs.list(),e=>Fa(e,n.id)),e.removeQueries({queryKey:L.runs.detail(n.id)}),e.removeQueries({queryKey:L.runs.diff(n.id)}),e.invalidateQueries({queryKey:L.worktrees});return;case`todos`:e.setQueryData(L.todos,n.items);return;case`usage`:t.set(n.usage);return;case`ping`:return}}function no(e,t=za){let n=o();(0,Y.useEffect)(()=>{let r=globalThis.EventSource;if(typeof r!=`function`)return;let i=null,a=qa(n),o=eo(n),s,c=!1,l=!1,u=!1,d=!1,f=()=>{u=!0,d=!1;let e=P.providerStatus;n.cancelQueries({queryKey:e,exact:!0}).then(()=>n.invalidateQueries({queryKey:e,exact:!0,refetchType:`active`})).finally(()=>{if(l||!d){u=!1;return}f()})},p=()=>{l||s!==void 0||(s=setTimeout(()=>{s=void 0,l||m()},Va))},m=()=>{i?.close(),i=new r(t,{withCredentials:!0}),i.addEventListener(`open`,()=>{c&&Ya(n),c=!0});for(let t of Ha)i.addEventListener(t,r=>{let i=ja(t,r.data);i&&(a.onEvent(i.event),i.project!==null&&$a(n,i.project,i.event),!(i.project!==null&&i.project!==Xa(n))&&to(n,e,i.event,o.refresh))});for(let e of Ua)i.addEventListener(e,t=>{let r;try{r=JSON.parse(t.data)}catch{return}e!==`checkout-progress`&&e!==`automation-change`&&n.invalidateQueries({queryKey:P.projects});for(let t of[...Wa])t(e,r)});i.addEventListener(`provider-status`,e=>{let t;try{t=JSON.parse(e.data)}catch{return}let r=tn(t);if(!r)return;let i=P.providerStatus,a=St(n.getQueryData(i),r);if(a!==void 0){n.setQueryData(i,a);return}if(u){d=!0;return}f()}),i.addEventListener(`error`,()=>{i?.readyState===Ba&&p()})},h=()=>{document.visibilityState===`visible`&&(Ya(n),(!i||i.readyState===Ba)&&(clearTimeout(s),s=void 0,m()))},g=()=>{clearTimeout(s),s=void 0,i?.close()},_=e=>{e.persisted&&(Ya(n),m())};return document.addEventListener(`visibilitychange`,h),window.addEventListener(`pagehide`,g),window.addEventListener(`pageshow`,_),m(),()=>{l=!0,clearTimeout(s),a.cancel(),o.cancel(),document.removeEventListener(`visibilitychange`,h),window.removeEventListener(`pagehide`,g),window.removeEventListener(`pageshow`,_),i?.close(),i=null}},[n,e,t])}var ro=(0,Y.createContext)(null);function io({children:e}){let[t]=(0,Y.useState)(Ra);return no(t),ze(),(0,X.jsx)(ro.Provider,{value:t,children:e})}function ao(e){let t=(0,Y.useContext)(ro),n=t?t.get:so;return(0,Y.useSyncExternalStore)(t?t.subscribe:oo,()=>e?n()[e]:void 0,()=>void 0)}var oo=()=>()=>void 0,so=()=>La;function co(){return new ka({defaultOptions:{queries:{refetchInterval:!1,staleTime:5*6e4,gcTime:30*6e4,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:(e,t)=>t instanceof fn&&t.status>=400&&t.status<500?!1:e<1},mutations:{retry:!1}}})}var lo=class extends Y.Component{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:Error(String(e))}}componentDidCatch(e,t){console.error(`cezar cockpit: uncaught render error`,e,t.componentStack)}render(){let{error:e}=this.state;return e?(0,X.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,X.jsx)(`h1`,{style:{fontSize:`20px`,fontWeight:600,margin:0},children:`The cockpit hit an error`}),(0,X.jsxs)(`p`,{style:{margin:0,maxWidth:`52ch`},children:[`Reload to carry on. Nothing on disk changed — cezar’s state lives in`,` `,(0,X.jsx)(`code`,{children:`.ai/cezar/`}),`, and this page never wrote to it.`]}),(0,X.jsx)(`pre`,{"data-slot":`app-error-detail`,style:{margin:0,maxWidth:`100%`,overflowX:`auto`,textAlign:`left`,opacity:.75},children:e.message}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>location.reload(),style:{padding:`6px 14px`,cursor:`pointer`},children:`Reload`})]}):this.props.children}},uo=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`}),fo=`VisuallyHidden`,po=Y.forwardRef((e,t)=>(0,X.jsx)(N.span,{...e,ref:t,style:{...uo,...e.style}}));po.displayName=fo;var mo=po;function ho(e){let t=Y.useRef({value:e,previous:e});return Y.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var go=`Label`,_o=Y.forwardRef((e,t)=>(0,X.jsx)(N.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));_o.displayName=go;var vo=_o,yo=`Switch`,[bo,xo]=ve(yo),[So,Co]=bo(yo);function wo(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]=Zt({prop:n,defaultProp:i??!1,onChange:c,caller:yo}),[m,h]=Y.useState(null),[g,_]=Y.useState(null),v={checked:f,setChecked:p,disabled:a,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:Y.useRef(!1),required:l,defaultChecked:i,isFormControl:!m||!!o||!!m.closest(`form`),bubbleInput:g,setBubbleInput:_};return(0,X.jsx)(So,{scope:t,...v,children:Mo(d)?d(v):r})}var To=`SwitchTrigger`,Eo=Y.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}=Co(To,e),h=Qn(r,u),g=Y.useRef(c);return Y.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,X.jsx)(N.button,{type:`button`,role:`switch`,"aria-checked":c,"aria-required":l,"data-state":No(c),"data-disabled":s?``:void 0,disabled:s,value:o,...n,ref:h,onClick:qt(t,e=>{d(e=>!e),m&&p&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})});Eo.displayName=To;var Do=Y.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,X.jsx)(wo,{__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,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Eo,{...d,ref:t,__scopeSwitch:n}),e&&(0,X.jsx)(jo,{__scopeSwitch:n})]})})});Do.displayName=yo;var Oo=`SwitchThumb`,ko=Y.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=Co(Oo,n);return(0,X.jsx)(N.span,{"data-state":No(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});ko.displayName=Oo;var Ao=`SwitchBubbleInput`,jo=Y.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}=Co(Ao,e),m=Qn(n,p),h=ho(a),g=Er(r);Y.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 _=Y.useRef(a);return(0,X.jsx)(N.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%)`}})});jo.displayName=Ao;function Mo(e){return typeof e==`function`}function No(e){return e?`checked`:`unchecked`}var Po=`Tabs`,[Fo,Io]=ve(Po,[gr]),Lo=gr(),[Ro,zo]=Fo(Po),Bo=Y.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=Dr(s),[d,f]=Zt({prop:r,onChange:i,defaultProp:a??``,caller:Po});return(0,X.jsx)(Ro,{scope:n,baseId:y(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,X.jsx)(N.div,{dir:u,"data-orientation":o,...l,ref:t})})});Bo.displayName=Po;var Vo=`TabsList`,Ho=Y.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=zo(Vo,n),o=Lo(n);return(0,X.jsx)(hr,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,X.jsx)(N.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});Ho.displayName=Vo;var Uo=`TabsTrigger`,Wo=Y.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=zo(Uo,n),s=Lo(n),c=qo(o.baseId,r),l=Jo(o.baseId,r),u=r===o.value;return(0,X.jsx)(Tr,{asChild:!0,...s,focusable:!i,active:u,children:(0,X.jsx)(N.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:qt(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:qt(e.onKeyDown,e=>{i||e.target!==e.currentTarget||[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:qt(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});Wo.displayName=Uo;var Go=`TabsContent`,Ko=Y.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=zo(Go,n),c=qo(s.baseId,r),l=Jo(s.baseId,r),u=r===s.value,d=Y.useRef(u);return Y.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,X.jsx)(we,{present:i||u,children:({present:n})=>(0,X.jsx)(N.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})})});Ko.displayName=Go;function qo(e,t){return`${e}-trigger-${t}`}function Jo(e,t){return`${e}-content-${t}`}var Yo=Bo,Xo=Ho,Zo=Wo,Qo=Ko,[$o,es]=ve(`Tooltip`,[fr]),ts=fr(),ns=`TooltipProvider`,rs=700,is=`tooltip.open`,[as,os]=$o(ns),ss=e=>{let{__scopeTooltip:t,delayDuration:n=rs,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=Y.useRef(!0),s=Y.useRef(!1),c=Y.useRef(0);return Y.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,X.jsx)(as,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:Y.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:Y.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:Y.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};ss.displayName=ns;var cs=`Tooltip`,[ls,us]=$o(cs),ds=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=os(cs,e.__scopeTooltip),l=ts(t),[u,d]=Y.useState(null),f=y(),p=Y.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=Y.useRef(!1),[_,v]=Zt({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(is))):c.onClose(),a?.(e)},caller:cs}),b=Y.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),x=Y.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),S=Y.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),C=Y.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return Y.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,X.jsx)(_r,{...l,children:(0,X.jsx)(ls,{scope:t,contentId:f,open:_,stateAttribute:b,trigger:u,onTriggerChange:d,onTriggerEnter:Y.useCallback(()=>{c.isOpenDelayedRef.current?C():x()},[c.isOpenDelayedRef,C,x]),onTriggerLeave:Y.useCallback(()=>{m?S():(window.clearTimeout(p.current),p.current=0)},[S,m]),onOpen:x,onClose:S,disableHoverableContent:m,children:n})})};ds.displayName=cs;var fs=`TooltipTrigger`,ps=Y.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=us(fs,n),a=os(fs,n),o=ts(n),s=Qn(t,Y.useRef(null),i.onTriggerChange),c=Y.useRef(!1),l=Y.useRef(!1),u=Y.useCallback(()=>c.current=!1,[]);return Y.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,X.jsx)(Sr,{asChild:!0,...o,children:(0,X.jsx)(N.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:qt(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:qt(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:qt(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:qt(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:qt(e.onBlur,i.onClose),onClick:qt(e.onClick,i.onClose)})})});ps.displayName=fs;var ms=`TooltipPortal`,[hs,gs]=$o(ms,{forceMount:void 0}),_s=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=us(ms,t);return(0,X.jsx)(hs,{scope:t,forceMount:n,children:(0,X.jsx)(we,{present:n||a.open,children:(0,X.jsx)(m,{asChild:!0,container:i,children:r})})})};_s.displayName=ms;var vs=`TooltipContent`,ys=Y.forwardRef((e,t)=>{let n=gs(vs,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=us(vs,e.__scopeTooltip);return(0,X.jsx)(we,{present:r||o.open,children:o.disableHoverableContent?(0,X.jsx)(ws,{side:i,...a,ref:t}):(0,X.jsx)(bs,{side:i,...a,ref:t})})}),bs=Y.forwardRef((e,t)=>{let n=us(vs,e.__scopeTooltip),r=os(vs,e.__scopeTooltip),i=Y.useRef(null),a=Qn(t,i),[o,s]=Y.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=Y.useCallback(()=>{s(null),d(!1)},[d]),p=Y.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Os(r,Ds(r,n.getBoundingClientRect())),a=ks(t.getBoundingClientRect()),o=js([...i,...a]);s(o),d(!0)},[d]);return Y.useEffect(()=>()=>f(),[f]),Y.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]),Y.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=!As(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,X.jsx)(ws,{...e,ref:a})}),[xs,Ss]=$o(cs,{isInside:!1}),Cs=ge(`TooltipContent`),ws=Y.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=us(vs,n),l=ts(n),{onClose:u}=c;return Y.useEffect(()=>(document.addEventListener(is,u),()=>document.removeEventListener(is,u)),[u]),Y.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,X.jsx)(Re,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,X.jsxs)(vr,{"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,X.jsx)(Cs,{children:r}),(0,X.jsx)(xs,{scope:n,isInside:!0,children:(0,X.jsx)(mo,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});ys.displayName=vs;var Ts=`TooltipArrow`,Es=Y.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=ts(n);return Ss(Ts,n).isInside?null:(0,X.jsx)(xr,{...i,...r,ref:t})});Es.displayName=Ts;function Ds(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 Os(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 ks(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 As(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 js(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)),Ms(t)}function Ms(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 Ns=ss,Ps=ds,Fs=ps,Is=_s,Ls=ys,Rs=Es,zs=l(`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 Bs({className:e,variant:t=`default`,asChild:n=!1,...r}){return(0,X.jsx)(n?w:`span`,{"data-slot":`badge`,"data-variant":t,className:U(zs({variant:t}),e),...r})}var Vs=W(`bookmark`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),Hs=W(`check-check`,[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]),Us=W(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Ws=W(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Gs=W(`chevrons-left`,[[`path`,{d:`m11 17-5-5 5-5`,key:`13zhaf`}],[`path`,{d:`m18 17-5-5 5-5`,key:`h8a8et`}]]),Ks=W(`chevrons-right`,[[`path`,{d:`m6 17 5-5-5-5`,key:`xnjwq`}],[`path`,{d:`m13 17 5-5-5-5`,key:`17xmmf`}]]),qs=W(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),Js=W(`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`}]]),Ys=W(`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`}]]),Xs=W(`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`}]]),Zs=W(`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`}]]),Qs=W(`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`}]]),$s=W(`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`}]]),ec=W(`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`}]]),tc=W(`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`}]]),nc=W(`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`}]]),rc=W(`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`}]]),ic=W(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),ac=W(`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`}]]),oc=W(`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`}]]),sc=W(`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`}]]),cc=W(`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`}]]),lc=W(`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`}]]),uc=W(`package-check`,[[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`path`,{d:`m16 17 2 2 4-4`,key:`uh5qu3`}],[`path`,{d:`M21 11.127V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.729l7 4a2 2 0 0 0 2 .001l1.32-.753`,key:`kpkbpo`}],[`path`,{d:`M3.29 7 12 12l8.71-5`,key:`19ckod`}],[`path`,{d:`m7.5 4.27 8.997 5.148`,key:`9yrvtv`}]]),dc=W(`scale`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`m19 8 3 8a5 5 0 0 1-6 0zV7`,key:`zcdpyk`}],[`path`,{d:`M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1`,key:`1yorad`}],[`path`,{d:`m5 8 3 8a5 5 0 0 1-6 0zV7`,key:`eua70x`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}]]),fc=W(`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`}]]),pc=W(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function mc({path:e,selected:t,onSelect:n,onEnter:r,decorate:i,emptyHint:a,showHidden:o=!1}){let s=ft(e,o),c=s.data?.parent??null;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{"data-slot":`fs-breadcrumb`,className:`truncate font-mono text-[11.5px] text-soft-foreground`,title:s.data?.path??void 0,children:s.data?.path??(s.isError?``:`Loading…`)}),s.isError?(0,X.jsx)(`p`,{"data-slot":`fs-error`,className:`min-w-0 break-words text-[13px] text-danger`,children:s.error instanceof Error?s.error.message:`could not list that folder`}):(0,X.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,X.jsx)(`li`,{className:`flex`,children:(0,X.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,X.jsx)(Xs,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),`Up one level`]})}),(s.data?.dirs??[]).map(e=>(0,X.jsxs)(`li`,{className:`flex items-stretch`,children:[(0,X.jsxs)(`button`,{type:`button`,"data-slot":`fs-dir`,"aria-pressed":t?.path===e.path,onClick:()=>n(e),onDoubleClick:()=>r(e.path),className:U(`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,X.jsx)(Gr,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`truncate`,children:e.name}),i?.(e)]}),(0,X.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,X.jsx)(ii,{className:`size-3.5`,"aria-hidden":`true`})})]},e.path)),s.data&&s.data.dirs.length===0?(0,X.jsx)(`li`,{className:`px-3 py-2 text-[13px] text-muted-foreground`,children:a}):null]}),s.data?.truncated?(0,X.jsx)(`p`,{"data-slot":`fs-truncated`,className:`text-[11.5px] text-muted-foreground`,children:`Too many folders to list — only the first ones are shown.`}):null]})}function hc(e,t,n=!1){let r=ft(e,n);return t?.path??r.data?.path??null}function gc({open:e,onOpenChange:t}){let[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(null),o=M(),s=et(),c=Fe(),l=new Set((o.data?.projects??[]).map(e=>e.root)),u=e=>{r(e),a(null),s.reset()},d=hc(n,i);return(0,X.jsx)(Ir,{open:e,onOpenChange:t,children:(0,X.jsxs)(Rr,{"data-slot":`add-project-dialog`,className:`sm:max-w-lg`,children:[(0,X.jsxs)(Lr,{children:[(0,X.jsx)(zr,{children:`Open local folder`}),(0,X.jsx)(Fr,{children:`Pick the folder cezar should run in. Git repos are marked; any folder works.`})]}),(0,X.jsx)(mc,{path:n,selected:i,onSelect:a,onEnter:u,emptyHint:`No subfolders here — “Add project” registers this folder.`,decorate:e=>(0,X.jsxs)(X.Fragment,{children:[e.isRepo?(0,X.jsx)(Bs,{variant:`outline`,className:`shrink-0 text-[10px]`,children:`git`}):null,l.has(e.path)?(0,X.jsx)(Bs,{variant:`ghost`,className:`shrink-0 text-[10px] text-muted-foreground`,children:`already added`}):null]})}),s.isError?(0,X.jsx)(`p`,{"data-slot":`add-project-error`,className:`min-w-0 break-words text-[13px] text-danger`,children:s.error instanceof Error?s.error.message:`could not add that folder`}):null,(0,X.jsxs)(Pr,{className:`min-w-0 sm:items-center sm:justify-between`,children:[(0,X.jsx)(`span`,{"data-slot":`add-project-target`,className:`min-w-0 truncate font-mono text-[11.5px] text-muted-foreground`,title:d??void 0,children:d??``}),(0,X.jsxs)(`span`,{className:`flex shrink-0 gap-2`,children:[(0,X.jsx)(I,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,X.jsx)(I,{"data-slot":`add-project-confirm`,disabled:d===null||s.isPending,onClick:()=>{d===null||s.isPending||s.mutate(d,{onSuccess:({project:e})=>{t(!1),c(`/p/${encodeURIComponent(e.id)}/`)}})},children:s.isPending?`Adding…`:`Add project`})]})]})]})})}function _c({className:e,type:t,...n}){return(0,X.jsx)(`input`,{type:t,"data-slot":`input`,className:U(`h-11 w-full min-w-0 rounded-md border border-input bg-[var(--task-brand-bg)] px-3 py-1 text-base shadow-none transition-[color,box-shadow] outline-none 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 vc({className:e,...t}){return(0,X.jsx)(vo,{"data-slot":`label`,className:U(`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 yc({open:e,onOpenChange:t}){let[n,r]=(0,Y.useState)(``),[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(null),c=M(),l=Et(),u=Fe(),d=(0,Y.useMemo)(()=>`co-${Math.random().toString(36).slice(2)}-${Date.now().toString(36)}`,[]),f=(0,Y.useRef)(d);f.current=d,(0,Y.useEffect)(()=>Ga((e,t)=>{if(e!==`checkout-progress`)return;let n=t;n?.checkoutId===f.current&&(n.phase===`cloning`&&n.line?s(n.line):n.phase!==`cloning`&&s(null))}),[]);let m=(0,Y.useMemo)(()=>{let e=n.trim().replace(/\/+$/,``).replace(/\.git$/,``).split(`/`).pop()??``;return e.includes(`:`)?e.split(`:`).pop()??``:e},[n]),h=i.trim()===``?m:i.trim(),g=c.data?.projectsDir??``,_=h===``?``:`${g.replace(/\/+$/,``)}/${h}`,v=()=>{n.trim()===``||l.isPending||(s(null),l.mutate({url:n.trim(),checkoutId:d,...i.trim()===``?{}:{name:i.trim()}},{onSuccess:({project:e})=>{t(!1),u(`/p/${encodeURIComponent(e.id)}/`)}}))};return(0,X.jsx)(Ir,{open:e,onOpenChange:e=>l.isPending?void 0:t(e),children:(0,X.jsxs)(Rr,{"data-slot":`clone-project-dialog`,className:`sm:max-w-lg`,children:[(0,X.jsxs)(Lr,{children:[(0,X.jsx)(zr,{children:`Clone from GitHub`}),(0,X.jsxs)(Fr,{children:[`cezar clones with `,(0,X.jsx)(`code`,{children:`gh`}),` into your checkout root and adds the result as a project.`]})]}),(0,X.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,X.jsx)(vc,{htmlFor:`clone-url`,children:`Repository`}),(0,X.jsx)(_c,{id:`clone-url`,"data-slot":`clone-url`,autoFocus:!0,placeholder:`owner/repo or https://github.com/owner/repo`,value:n,disabled:l.isPending,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&v()}})]}),(0,X.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,X.jsx)(vc,{htmlFor:`clone-name`,children:`Folder name`}),(0,X.jsx)(_c,{id:`clone-name`,"data-slot":`clone-name`,placeholder:m===``?`repo`:m,value:i,disabled:l.isPending,onChange:e=>a(e.target.value)}),(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,X.jsx)(`p`,{"data-slot":`clone-target`,className:`min-w-0 flex-1 truncate font-mono text-[11.5px] text-soft-foreground`,title:_,children:_}),l.isPending?(0,X.jsx)(I,{"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,X.jsx)(p,{className:`size-3.5`,"aria-hidden":`true`})}):(0,X.jsx)(I,{asChild:!0,variant:`ghost`,size:`icon-sm`,className:`size-7`,children:(0,X.jsx)(z,{to:`/settings/global/projects`,"data-slot":`clone-root-settings`,"aria-label":`Edit checkout root`,title:`Edit checkout root`,children:(0,X.jsx)(p,{className:`size-3.5`,"aria-hidden":`true`})})})]})]}),l.isPending?(0,X.jsx)(`p`,{"data-slot":`clone-progress`,className:`truncate font-mono text-[11.5px] text-muted-foreground`,children:o??`Starting the clone…`}):null,l.isError?(0,X.jsx)(`p`,{"data-slot":`clone-error`,className:`text-[13px] text-danger`,children:l.error instanceof Error?l.error.message:`could not clone that repository`}):null,(0,X.jsxs)(Pr,{children:[(0,X.jsx)(I,{variant:`outline`,disabled:l.isPending,onClick:()=>t(!1),children:`Cancel`}),(0,X.jsx)(I,{"data-slot":`clone-confirm`,disabled:n.trim()===``||h===``||l.isPending,onClick:v,children:l.isPending?`Cloning…`:`Clone`})]})]})})}var bc=[{to:`/`,label:`Tasks`,icon:S,match:[`/`,`/tasks`,`/compare`],badge:`tasks-unread`},{to:`/inbox`,label:`Inbox`,icon:qn,match:[`/inbox`],badge:`inbox-count`,inbox:!0},{to:`/git`,label:`Git`,icon:Rt,match:[`/git`]},{to:`/github`,label:`GitHub`,icon:Le,match:[`/github`],forge:!0},{to:`/automations`,label:`Automations`,icon:pn,match:[`/automations`],forge:!0,automations:!0},{to:`/skills`,label:`Skills`,icon:Ge,match:[`/skills`],badge:`skills-update`},{to:`/workflows`,label:`Workflows`,icon:a,match:[`/workflows`]},{to:`/settings`,label:`Settings`,icon:p,match:[`/settings`]}];function xc({forge:e=!1,inbox:t=!1,automations:n=!1}={}){return bc.filter(r=>(!r.forge||e)&&(!r.inbox||t)&&(!r.automations||n))}function Sc(e,t){return t===`/`?e===`/`:e===t||e.startsWith(t+`/`)}function Cc(e){let t=null;for(let n of bc)for(let r of n.match)Sc(e,r)&&(t===null||r.length>t.length)&&(t={to:n.to,length:r.length});return t?.to??null}function wc(e){let t=Cc(e);return bc.find(e=>e.to===t)??null}var Tc=`cez-theme`,Ec=`(prefers-color-scheme: light)`,Dc=`dark`;function Oc(e){return e===`light`||e===`dark`||e===`system`?e:Dc}function kc(e,t){return e===`light`||e===`system`&&t?`light`:`dark`}function Ac(){try{return Oc(localStorage.getItem(Tc))}catch{return Dc}}function jc(e){try{localStorage.setItem(Tc,e)}catch{}}function Mc(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(Ec).matches}function Nc(e,t){e.classList.toggle(`light`,t===`light`),e.style.colorScheme=t}function Pc(e){return`/cezarion-mark-${e}.svg`}function Fc(e){let t=document.querySelector(`link[rel="icon"]`);t&&(t.href=Pc(e))}var Ic=Y.createContext(null);function Lc({children:e}){let[t,n]=Y.useState(Ac),[r,i]=Y.useState(Mc);Y.useEffect(()=>{let e=window.matchMedia?.(Ec);if(!e)return;i(e.matches);let t=e=>i(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let a=kc(t,r);Y.useLayoutEffect(()=>{Nc(document.documentElement,a),Fc(a)},[a]);let o=Y.useCallback(e=>{n(e),jc(e)},[]),s=Y.useMemo(()=>({theme:t,resolvedTheme:a,setTheme:o}),[t,a,o]);return(0,X.jsx)(Ic.Provider,{value:s,children:e})}function Rc(){let e=Y.useContext(Ic);if(!e)throw Error(`cezar: useTheme() must be called inside <ThemeProvider>`);return e}var zc={light:`dark`,dark:`system`,system:`light`},Bc={light:`light`,dark:`dark`,system:`system`};function Vc({className:e}){let{theme:t,setTheme:n}=Rc(),r=zc[t],i=he;return(0,X.jsx)(I,{type:`button`,variant:`ghost`,size:`icon-sm`,className:e,"data-slot":`theme-toggle`,"data-theme-pref":t,title:`Theme: ${Bc[t]}`,"aria-label":`Theme: ${Bc[t]}. Switch to ${Bc[r]}.`,onClick:()=>n(r),children:(0,X.jsx)(i,{"aria-hidden":`true`})})}var Hc=`cezar:open-command-palette`;function Uc(){window.dispatchEvent(new Event(Hc))}function Wc(e){return[...e].sort((e,t)=>Date.parse(t.createdAt)-Date.parse(e.createdAt))}function Gc(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 Kc(e,t,n){let r=Wc(e).map(e=>({projectId:t,id:e.id,title:e.title,titleSummary:e.titleSummary,titleOrigin:e.titleOrigin,status:e.status,activity:e.activity,createdAt:e.createdAt,finishedAt:e.finishedAt,seenAt:e.seenAt,archived:e.archived,autoResumeAt:e.autoResumeAt,...e.hasPendingHumanAsk===void 0?{}:{hasPendingHumanAsk:e.hasPendingHumanAsk},...e.delegation?{delegation:rr.parse(e.delegation)}:{},workflow:e.workflow,branch:e.branch,startedAt:e.startedAt})),i=new Set(r.map(qc)),a=(n??[]).filter(e=>!i.has(qc(e))).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return[...r,...a]}var qc=e=>`${e.projectId??``}/${e.id}`;function Jc(e){let t=e.filter(e=>Ur(e)).sort((e,t)=>(t.finishedAt??``).localeCompare(e.finishedAt??``)),n=new Set(t.map(qc));return{recentlyFinished:t,otherTasks:e.filter(e=>!n.has(qc(e)))}}function Yc(e,t){return[...e].sort((e,n)=>Number(e.id===t)-Number(n.id===t)||n.lastOpenedAt.localeCompare(e.lastOpenedAt))}function Xc(){let[e,t]=Y.useState(!1),n=Bi();ca(`k`,()=>t(e=>!e));let r=Y.useCallback(()=>{t(!1),n(`/new`)},[n]);return ca(`n`,r),pa(`c`,r),Y.useEffect(()=>{let e=()=>t(!0);return window.addEventListener(Hc,e),()=>window.removeEventListener(Hc,e)},[]),(0,X.jsx)(ci,{open:e,onOpenChange:t,title:`Command palette`,description:`Search projects, tasks, views, actions, and skills`,showCloseButton:!1,filter:Gc,className:`top-[10vh] translate-y-0 sm:max-w-2xl lg:max-w-3xl xl:max-w-4xl`,children:(0,X.jsx)(Qc,{close:()=>t(!1)})})}function Zc({task:e,projectName:t,showProject:n,now:r,onSelect:i}){let a=it(e),o=A(e);return(0,X.jsxs)(K,{value:`task ${o} ${e.id}`,keywords:t?[t]:void 0,"data-slot":`palette-task`,"data-run-id":e.id,"data-project-id":e.projectId??void 0,onSelect:()=>i(e),children:[(0,X.jsx)(G,{tone:a.tone,pulse:a.pulse,"aria-label":a.label,role:`img`}),e.delegation?.role===`worker`?(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Worker`}):null,(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:o}),n&&t?(0,X.jsx)(`span`,{"data-slot":`palette-task-project`,className:`shrink-0 truncate text-xs text-soft-foreground`,children:t}):null,(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-soft-foreground tabular-nums`,children:Yi(e.finishedAt??e.createdAt,r)})]})}function Qc({close:e}){let t=Bi(),n=Fe(),[r,i]=Y.useState(``),a=r.trim()!==``,o=Ki(),{theme:s,setTheme:c}=Rc(),l=wt(),u=Nt(),d=M(),f=Vt(),p=H(),m=Date.now(),h=d.data,g=h!==void 0&&h.projects.length>1,_=an(g),v=Y.useMemo(()=>g?Yc(h.projects,o):[],[g,h,o]),y=Y.useMemo(()=>new Map((h?.projects??[]).map(e=>[e.id,e.name])),[h]),b=o??h?.bootProject??null,x=Y.useMemo(()=>Kc(l.data??[],b,_.data?.runs),[l.data,b,_.data]),S=Y.useMemo(()=>Jc(x),[x]),C=a?[]:S.recentlyFinished,w=a?x:S.otherTasks,te=g,T=e=>e.projectId===null?null:y.get(e.projectId)??null,E=f.data?.skillUsage,D=Y.useMemo(()=>ra(u.data??[],E),[u.data,E]),ne=n=>{e(),t(n)},re=t=>{e(),n(t)},ie=n=>{e(),t(zi(n,`/`))},ae=n=>{e(),t(n.projectId===null?`/tasks/${n.id}`:zi(n.projectId,`/tasks/${n.id}`))},oe=zc[s];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oi,{placeholder:`Search projects, tasks, views, actions, skills…`,value:r,onValueChange:i}),(0,X.jsxs)(fi,{className:`max-h-[55vh] min-h-[14rem] sm:max-h-[60vh] lg:max-h-[68vh]`,children:[(0,X.jsx)(mi,{children:`Nothing matches.`}),(0,X.jsx)(q,{children:(0,X.jsxs)(K,{value:`new task`,"data-slot":`palette-view`,"data-nav-to":`/new`,onSelect:()=>ne(`/new`),children:[(0,X.jsx)(ce,{"aria-hidden":`true`}),`New task`,(0,X.jsx)(hi,{children:`C`})]})}),!a&&C.length>0?(0,X.jsx)(q,{heading:`Recently finished`,children:C.map(e=>(0,X.jsx)(Zc,{task:e,projectName:T(e),showProject:te,now:m,onSelect:ae},qc(e)))}):null,(0,X.jsxs)(q,{heading:`Views`,children:[g?(0,X.jsxs)(K,{value:`view All tasks`,"data-slot":`palette-view`,"data-nav-to":`/tasks`,onSelect:()=>re(`/tasks`),children:[(0,X.jsx)(ee,{"aria-hidden":`true`}),`All tasks`]}):null,xc({forge:p.data?.forge?.available===!0,inbox:p.data?.capabilities.followups===!0,automations:p.data?.capabilities.automations===!0}).map(e=>{let t=e.icon;return(0,X.jsxs)(K,{value:`view ${e.label}`,"data-slot":`palette-view`,"data-nav-to":e.to,onSelect:()=>ne(e.to),children:[(0,X.jsx)(t,{"aria-hidden":`true`}),e.label]},e.to)})]}),v.length>0?(0,X.jsx)(q,{heading:`Projects`,children:v.map(e=>{let t=e.id===o,n=e.status===`missing`;return(0,X.jsxs)(K,{value:`project ${e.name} ${e.id}`,keywords:[e.root],"data-slot":`palette-project`,"data-project-id":e.id,disabled:n,onSelect:()=>ie(e.id),children:[(0,X.jsx)(Pt,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),n?(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-soft-foreground`,children:`folder not found`}):e.branch===void 0?null:(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-soft-foreground`,children:e.branch}),t?(0,X.jsx)(at,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},e.id)})}):null,w.length>0?(0,X.jsx)(q,{heading:`Tasks`,children:w.map(e=>(0,X.jsx)(Zc,{task:e,projectName:T(e),showProject:te,now:m,onSelect:ae},qc(e)))}):null,(0,X.jsx)(q,{heading:`Actions`,children:(0,X.jsxs)(K,{value:`action toggle theme`,"data-slot":`palette-action`,"data-action":`toggle-theme`,onSelect:()=>{c(oe),e()},children:[(0,X.jsx)(he,{"aria-hidden":`true`}),`Toggle theme`,(0,X.jsxs)(hi,{className:`tracking-normal`,children:[s,` → `,oe]})]})}),D.length>0?(0,X.jsx)(q,{heading:`Skills`,children:D.map(e=>(0,X.jsxs)(K,{value:`skill ${e.name} ${e.path}`,keywords:e.description?[e.description]:void 0,"data-slot":`palette-skill`,"data-skill":e.name,onSelect:()=>ne(`/new?skill=${encodeURIComponent(e.name)}`),children:[(0,X.jsx)(`span`,{className:`shrink-0 font-medium`,children:e.name}),e.description?(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null]},e.path))}):null]})]})}var $c=`cez-sidebar-width`;function el(e){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?Math.min(420,Math.max(264,Math.round(t))):264}function tl(){try{let e=localStorage.getItem($c);return e===null?264:el(e)}catch{return 264}}function nl(e){try{localStorage.setItem($c,String(el(e)))}catch{}}var rl=`(min-width: 768px)`,il=Y.createContext(void 0);function al(){return Y.useContext(il)}function ol(e){return yt({path:`/tasks/:id`,end:!0},Wi(e))!==null}function sl({children:e,breadcrumb:t,repo:n=null,inboxCount:r=null,unreadCount:i=null,skillsUpdateAvailable:a=!1,version:o=null,latestVersion:s=null,taskQuickList:c,sessionScope:l,toolsMenu:u,forgeAvailable:d=!0,inboxAvailable:f=!0,automationsAvailable:p=!0,singleProject:m=!1,banner:h,projectGroups:g}){let{pathname:_}=Jn(),v=Wi(_),y=v===`/new`?`/new`:Cc(v),b=wc(v),[x,S]=Y.useState(!1),C=Y.useRef(null),ee=Y.useRef(null),w=ol(_),[te,T]=Y.useState(tl),E=Y.useCallback(e=>{let t=el(e);T(t),nl(t)},[]);Y.useLayoutEffect(()=>{if(w)return;let e=ee.current;e&&(e.scrollTop=0)},[_,w]),Y.useEffect(()=>{S(!1)},[_]),Y.useEffect(()=>{let e=window.matchMedia?.(rl);if(!e)return;e.matches&&S(!1);let t=e=>{e.matches&&S(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let D={activeTo:y,items:xc({forge:d,inbox:f,automations:p}),repo:n,inboxCount:f?r:null,unreadCount:i,skillsUpdateAvailable:a,version:o,latestVersion:s,taskQuickList:c,sessionScope:l,toolsMenu:u,projectGroups:g,singleProject:m};return(0,X.jsx)(la,{open:x,onOpenChange:S,children:(0,X.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,X.jsx)(cl,{...D,width:te,onWidthChange:E}),(0,X.jsx)(ul,{...D,onNavigate:()=>S(!1),onCloseAutoFocus:e=>{C.current?.isConnected&&(e.preventDefault(),C.current.focus())}}),(0,X.jsxs)(`div`,{className:`grid min-w-0 flex-1 grid-rows-[auto_auto_1fr_auto] overflow-hidden`,children:[(0,X.jsx)(_l,{title:b?.label??`cezar`,repo:n,onTrigger:e=>{C.current=e}}),(0,X.jsxs)(`header`,{"data-slot":`desktop-breadcrumb`,className:U(`row-start-1 hidden min-w-0 items-center gap-3 border-b border-border text-[13px] text-muted-foreground md:flex`,v===`/new`?`h-[72px] px-11`:`h-16 px-9`),children:[(0,X.jsx)(Dt,{"aria-hidden":`true`,className:`size-4 shrink-0`}),t?.project??n?.name?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`truncate font-medium text-foreground`,children:t?.project??n?.name}),(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`/`})]}):null,(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:t?.page??b?.label??`Cezarion`}),t?.branch??n?.branch?(0,X.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 text-[11px]`,children:[(0,X.jsx)(Ze,{"aria-hidden":`true`,className:`size-4 text-accent-text`}),t?.branch??n?.branch]}):null]}),h?(0,X.jsx)(`div`,{"data-slot":`banner-slot`,className:`row-start-2`,children:h}):null,(0,X.jsx)(`main`,{ref:ee,"data-slot":`main`,className:`row-start-3 min-h-0 overflow-y-auto overscroll-contain`,children:e}),(0,X.jsx)(`div`,{"data-slot":`composer`,className:`row-start-4 pb-[max(env(safe-area-inset-bottom),var(--kb,0px))]`})]})]})})}function cl({width:e,onWidthChange:t,...n}){return(0,X.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,X.jsx)(dl,{...n}),(0,X.jsx)(ll,{width:e,onWidthChange:t})]})}function ll({width:e,onWidthChange:t}){let n=Y.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(el(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,X.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(el(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 ul({onNavigate:e,onCloseAutoFocus:t,...n}){return(0,X.jsxs)(fa,{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,X.jsx)(ua,{className:`sr-only`,children:`Navigation`}),(0,X.jsx)(dl,{...n,onNavigate:e,headerAction:(0,X.jsx)(oa,{asChild:!0,children:(0,X.jsx)(I,{variant:`ghost`,size:`icon`,"aria-label":`Close menu`,className:`absolute top-5 -right-14 size-11`,children:(0,X.jsx)(In,{className:`size-[22px]`,"aria-hidden":`true`})})})})]})}function dl({activeTo:e,items:t,repo:n,inboxCount:r,unreadCount:i,skillsUpdateAvailable:a,version:o,latestVersion:s,taskQuickList:c,sessionScope:l,toolsMenu:u,projectGroups:d,singleProject:f,onNavigate:p,headerAction:m}){return(0,X.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,X.jsxs)(`div`,{className:`flex items-center gap-[9px] px-4 pt-5 pb-2`,children:[(0,X.jsx)(`span`,{"data-slot":`brand-wordmark`,className:`text-[23px] leading-normal font-semibold tracking-[-0.03em] text-foreground`,children:`Cezarion`}),m?(0,X.jsx)(`div`,{className:U(`shrink-0`,(!n||d)&&`ml-auto`),children:m}):null]}),(0,X.jsx)(`div`,{className:`px-4 pb-2`,children:(0,X.jsx)(hl,{})}),(0,X.jsx)(`div`,{className:`flex gap-1.5 px-4 pb-2`,children:(0,X.jsx)(I,{asChild:!0,variant:`ghost`,className:U(`relative h-[42px] min-w-0 flex-1 justify-start gap-2.5 px-2.5 font-medium text-muted-foreground`,e===`/new`&&`bg-[var(--task-brand-selected)] text-accent-text`),children:(0,X.jsxs)(J,{to:`/new`,onClick:p,children:[(0,X.jsx)(ce,{className:`size-[18px]`,"aria-hidden":`true`}),`New task`,(0,X.jsx)(`kbd`,{"aria-hidden":`true`,className:`sr-only`,children:`C`})]})})}),l?(0,X.jsx)(`div`,{className:`shrink-0 px-4 pb-3`,children:l}):null,d?(0,X.jsx)(X.Fragment,{children:(0,X.jsx)(`div`,{"data-slot":`project-groups`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 pt-0 pb-2`,children:(0,X.jsx)(il.Provider,{value:p,children:d})})}):(0,X.jsxs)(`div`,{"data-slot":`single-project-navigation`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:[n?(0,X.jsxs)(`div`,{className:`mx-4 mb-1 flex min-h-[55px] items-center gap-2 rounded-md bg-muted px-2 text-[13px] font-semibold`,children:[(0,X.jsx)(Dt,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0`,children:[(0,X.jsx)(`span`,{"data-slot":`repo-chip`,className:`block truncate`,children:n.name}),(0,X.jsx)(`span`,{className:`block truncate font-['IBM_Plex_Mono'] text-[10px] font-normal text-soft-foreground`,children:n.branch})]})]}):null,(0,X.jsx)(`nav`,{"aria-label":`Main`,className:`flex flex-col gap-0.5 px-4`,children:t.map(t=>{let n=t.to===e,o=t.icon;return(0,X.jsxs)(J,{to:t.to,onClick:p,"aria-current":n?`page`:void 0,className:U(`selection-row focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground flex h-11 w-full items-center gap-2.5 rounded-md px-2.5 text-xs md:text-[11px] font-normal text-muted-foreground transition-colors hover:bg-muted hover:text-foreground md:h-[30px]`,n&&`bg-[var(--task-brand-selected)] text-[var(--accent-text)]`),children:[(0,X.jsx)(o,{className:`size-[15px] shrink-0 text-soft-foreground`,"aria-hidden":`true`}),t.label,t.badge===`inbox-count`&&r?(0,X.jsx)(`span`,{"data-slot":`nav-badge`,className:`ml-auto rounded-full bg-accent-strong px-1.5 py-px text-[10.5px] font-semibold text-accent-strong-foreground`,children:r}):null,t.badge===`tasks-unread`&&i?(0,X.jsx)(`span`,{"data-slot":`nav-unread-badge`,title:`${i} unread finished ${i===1?`task`:`tasks`}`,className:`ml-auto rounded-full bg-accent-strong px-1.5 py-px text-[10.5px] font-semibold text-accent-strong-foreground`,children:i}):null,t.badge===`skills-update`&&a?(0,X.jsxs)(`span`,{"data-slot":`nav-update-marker`,className:`ml-auto flex items-center`,children:[(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-accent-strong`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Skills update available`})]}):null]},t.to)})}),(0,X.jsx)(`div`,{"data-slot":`task-quick-list`,className:`px-4 pb-2`,children:c})]}),(0,X.jsxs)(`div`,{"data-slot":`sidebar-footer`,className:`shrink-0 px-4 pt-2 pb-3`,children:[(0,X.jsxs)(`div`,{"data-slot":`sidebar-footer-controls`,className:`flex items-center justify-between gap-1 border-t border-border pt-3`,children:[f?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(fl,{onNavigate:p}),(0,X.jsx)(ml,{})]}),(0,X.jsx)(pl,{onNavigate:p}),(0,X.jsx)(`div`,{"data-slot":`tools-menu`,className:`shrink-0`,children:u}),(0,X.jsx)(Vc,{})]}),o?(0,X.jsxs)(`div`,{className:`sr-only`,children:[(0,X.jsx)(gl,{version:o,latestVersion:s}),s&&s!==o?(0,X.jsx)(`span`,{className:`min-w-0 text-[10px] text-accent-text`,children:`Update available`}):null]}):null]})]})}function fl({onNavigate:e}){let{pathname:t}=Jn(),n=t===`/tasks`;return(0,X.jsxs)(z,{to:`/tasks`,"data-slot":`all-tasks-link`,"aria-label":`All tasks`,title:`All tasks`,onClick:e,"aria-current":n?`page`:void 0,className:U(`selection-row flex size-9 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted`,n&&`bg-muted`),children:[(0,X.jsx)(ee,{className:U(`size-4 shrink-0`,n?`text-accent-text`:`text-muted-foreground`),"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`All tasks`})]})}function pl({className:e,onNavigate:t}){return(0,X.jsx)(I,{asChild:!0,variant:`ghost`,size:`icon`,className:U(`size-9`,e),children:(0,X.jsxs)(z,{to:`/settings/global`,"data-slot":`global-settings-link`,"aria-label":`Global settings`,title:`Global settings`,onClick:t,children:[(0,X.jsx)(nr,{className:`size-4`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Global settings`})]})})}function ml(){let[e,t]=Y.useState(!1),[n,r]=Y.useState(!1);return(0,X.jsxs)(wr,{children:[(0,X.jsx)(br,{asChild:!0,children:(0,X.jsxs)(I,{variant:`ghost`,"aria-label":`Add project`,title:`Add project`,className:`size-9 p-0 text-muted-foreground`,children:[(0,X.jsx)(xn,{className:`size-4`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Add project`})]})}),(0,X.jsxs)(Cr,{align:`start`,className:`w-56`,children:[(0,X.jsx)(pr,{className:`text-xs text-soft-foreground`,children:`Add project`}),(0,X.jsxs)(yr,{"data-slot":`add-project-local`,onSelect:()=>t(!0),children:[(0,X.jsx)(Dt,{"aria-hidden":`true`}),`Open local folder…`]}),(0,X.jsxs)(yr,{"data-slot":`add-project-clone`,onSelect:()=>r(!0),children:[(0,X.jsx)(Le,{"aria-hidden":`true`}),`Clone from GitHub…`]})]}),e?(0,X.jsx)(gc,{open:!0,onOpenChange:t}):null,n?(0,X.jsx)(yc,{open:!0,onOpenChange:r}):null]})}function hl(){return(0,X.jsxs)(`button`,{type:`button`,"data-slot":`command-palette-hint`,title:`Search — command palette (⌘K / Ctrl+K)`,onClick:()=>Uc(),className:`flex h-11 w-full items-center gap-2 rounded-lg border border-border bg-[var(--task-brand-bg)] px-2.5 text-left text-xs font-normal text-muted-foreground transition-colors hover:border-[var(--composer-border)] hover:text-foreground md:h-10`,children:[(0,X.jsx)(Pe,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`truncate`,children:`Search…`}),(0,X.jsx)(`kbd`,{"aria-hidden":`true`,className:`ml-auto shrink-0 font-sans text-[10px] font-normal text-soft-foreground`,children:sa(`k`)})]})}function gl({version:e,latestVersion:t}){let n=!!(t&&t!==e);return(0,X.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 text-[10px] text-muted-foreground`,children:[n?(0,X.jsx)(G,{tone:`pending`,pulse:!0,className:`size-[5px] shrink-0`}):null,(0,X.jsxs)(`span`,{className:`truncate`,children:[`v`,e]})]})}function _l({title:e,repo:t,onTrigger:n}){return(0,X.jsx)(`header`,{"data-slot":`mobile-top-bar`,className:`row-start-1 border-b border-border bg-card pt-[env(safe-area-inset-top)] md:hidden`,children:(0,X.jsxs)(`div`,{className:`flex h-[52px] items-center gap-3 px-3.5`,children:[(0,X.jsx)(ga,{asChild:!0,children:(0,X.jsx)(I,{variant:`ghost`,size:`icon`,"aria-label":`Open menu`,onClick:e=>n(e.currentTarget),className:`-ml-1.5 size-11`,children:(0,X.jsx)(De,{className:`size-[17px]`,"aria-hidden":`true`})})}),(0,X.jsx)(`span`,{className:`shrink-0 text-[19px] font-semibold tracking-[-0.03em]`,children:`Cezarion`}),t?(0,X.jsx)(ga,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"data-slot":`mobile-project-picker`,"aria-label":`Switch project: ${t.name}`,onClick:e=>n(e.currentTarget),className:`ml-auto flex h-11 min-w-0 items-center gap-2 text-[13px] focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(Dt,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,X.jsx)(`span`,{className:`max-w-28 truncate`,children:t.name}),(0,X.jsx)(nt,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`})]})}):null,e===`cezar`?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:U(`text-soft-foreground`,t&&`hidden`),children:`·`}),(0,X.jsx)(`span`,{"data-slot":`mobile-route-title`,className:U(`truncate text-[13px] font-medium text-muted-foreground`,t&&`sr-only`),children:e})]}),(0,X.jsx)(`div`,{"data-slot":`mobile-status`,className:`ml-auto flex items-center gap-2`})]})})}var vl=Y.createContext(null);function yl({children:e}){let[t,n]=Y.useState(`active`),r=Y.useMemo(()=>[t,n],[t]);return(0,X.jsx)(vl.Provider,{value:r,children:e})}function bl(){let e=Y.useContext(vl);if(!e)throw Error(`useListView must be used inside a <ListViewProvider>`);return e}var xl=[`claude`,`codex`,`opencode`,`pi`,`cursor`],Sl={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,pi:`pi`,cursor:`Cursor`};function Cl(e){if(typeof e!=`object`||!e||Array.isArray(e))return{};let t=e,n={};for(let e of xl){let r=t[e];typeof r==`string`&&r.length>0&&r.length<=128&&(n[e]=r)}return n}function wl(e,t){if(!e)return[];let n=new Map(e.providers.map(e=>[e.provider,e]));return xl.flatMap(e=>{let r=n.get(e);return r?.status!==`disconnected`||!r.authFailureId||t[e]===r.authFailureId?[]:[{provider:e,label:Sl[e],authFailureId:r.authFailureId}]})}function Tl(e,t){return{...e,...Object.fromEntries(t.map(({provider:e,authFailureId:t})=>[e,t]))}}function El({status:e,pending:t,error:n,dismissals:r,onDismissAuthFailures:i}){if(t||!e)return null;let a;try{a=zn(e)}catch{return null}let o=wl(a,r);if(o.length>0)return(0,X.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,X.jsx)(G,{tone:`danger`}),(0,X.jsxs)(`span`,{children:[`Provider authentication failed during a task:`,` `,o.map(({label:e})=>e).join(`, `),`.`]}),(0,X.jsx)(J,{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,X.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,X.jsx)(pc,{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,X.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,X.jsx)(G,{tone:c?`danger`:`pending`}),(0,X.jsx)(`span`,{children:s?`No agent provider is enabled.`:c?`No connected provider could be verified.`:`No agent provider credentials were found.`}),(0,X.jsx)(J,{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 Dl(e){if(!(typeof e!=`object`||!e||Array.isArray(e)))return e}function Ol(){let e=Me(),t=bt(),n=o(),r=(0,Y.useRef)(Promise.resolve()),i=(0,Y.useRef)(0),a=(0,Y.useRef)(0),s=(0,Y.useRef)(Dl(t.data));(0,Y.useEffect)(()=>{a.current===0&&(s.current=Dl(t.data))},[t.data]);let c=(0,Y.useCallback)(e=>{let t=P.uiState,o=Dl(n.getQueryData(t)),c=Tl(Cl(o?.dismissedProviderAuthFailures),e),l={...o,dismissedProviderAuthFailures:c};a.current+=1,n.setQueryData(t,l);let u=++i.current;r.current=r.current.then(async()=>{try{let e=await ot({dismissedProviderAuthFailures:c});s.current=Dl(e),u===i.current&&n.setQueryData(t,e)}catch(e){u===i.current&&(s.current===void 0?n.removeQueries({queryKey:t,exact:!0}):n.setQueryData(t,s.current),n.invalidateQueries({queryKey:t}),B(e instanceof Error?e.message:String(e),{tone:`danger`}))}finally{--a.current}})},[n]);return(0,X.jsx)(El,{status:e.data,pending:e.isPending,error:e.isError,dismissals:Cl(Dl(t.data)?.dismissedProviderAuthFailures),onDismissAuthFailures:c})}function kl({pinned:e,onToggle:t,className:n}){return(0,X.jsx)(`button`,{type:`button`,"data-slot":`pin-toggle`,"data-pinned":e?`true`:void 0,"aria-pressed":e,"aria-label":e?`Unpin task`:`Pin task`,title:e?`Unpin from the top of the list`:`Pin to the top of the list`,onClick:n=>{n.stopPropagation(),t(!e)},className:U(`inline-flex size-5 shrink-0 items-center justify-center rounded-sm text-soft-foreground transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,e&&`text-accent-text hover:text-accent-text`,n,`max-md:min-h-11 max-md:min-w-11 no-hover:min-h-11 no-hover:min-w-11`),children:(0,X.jsx)(te,{className:U(`size-[18px]`),"aria-hidden":`true`})})}function Al({runs:e,view:t,onViewChange:n,currentRunId:r=null,now:i=Date.now(),showTokens:a=!0,showCost:o=!0,onTogglePin:s,showViewControls:c=!0}){let l=We(e),u=Xe(e,t),d=t===`archived`?void 0:s;return(0,X.jsxs)(`div`,{"data-slot":`quick-list`,children:[c?(0,X.jsx)(`div`,{className:`sticky top-0 z-10 bg-sidebar pt-2 pb-1`,children:(0,X.jsxs)(`div`,{className:`inline-flex w-full gap-0.5 rounded-md bg-muted p-[3px]`,children:[(0,X.jsxs)(Ml,{view:`active`,current:t,onSelect:n,count:l.active,children:[`Active`,l.waiting>0&&t!==`active`?(0,X.jsx)(G,{tone:`pending`,pulse:!0,"data-slot":`waiting-dot`,"aria-label":`needs you`}):null]}),(0,X.jsx)(Ml,{view:`archived`,current:t,onSelect:n,count:l.archived,children:`Archived`})]})}):null,u.length===0?(0,X.jsx)(`p`,{className:`px-3 py-3.5 text-xs text-soft-foreground`,children:t===`archived`?`Nothing archived yet.`:`No tasks yet — describe one.`}):(0,X.jsx)(jl,{buckets:u,currentRunId:r,now:i,showTokens:a,showCost:o,onTogglePin:d})]})}function jl({buckets:e,currentRunId:t=null,now:n=Date.now(),scope:r=null,showTokens:i=!0,showCost:a=!0,onTogglePin:o}){let[s,c]=Y.useState(()=>new Set),l=e=>c(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),u=[];for(let t of[`Pinned`,`Recent`,`Archived`]){let n=e.filter(e=>t===`Recent`?e.label!==`Pinned`&&e.label!==`Archived`:e.label===t).flatMap(e=>e.rows);n.length&&u.push({label:t,rows:n})}let d=u.flatMap(e=>e.rows).filter(e=>e.kind===`run`),f=new Set(d.filter(e=>e.run.delegation?.role!==`worker`).map(e=>e.run.id)),p=new Map;for(let e of d){let t=e.run.delegation;t?.role!==`worker`||!f.has(t.parentRunId)||e.run.pinned&&!d.find(e=>e.run.id===t.parentRunId)?.run.pinned||p.set(t.parentRunId,[...p.get(t.parentRunId)??[],e])}let m=new Set([...p.values()].flat().map(e=>e.run.id)),h=e=>(0,X.jsx)(Nl,{row:e,currentRunId:t,now:n,scope:r,showTokens:i,showCost:a,expanded:e.kind===`group`&&s.has(e.groupId),onToggle:l,onTogglePin:o});return(0,X.jsx)(X.Fragment,{children:u.filter(e=>e.rows.some(e=>e.kind!==`run`||!m.has(e.run.id))).map(e=>(0,X.jsxs)(`div`,{"data-slot":`quick-list-bucket`,"data-bucket":e.label,children:[(0,X.jsx)(`h2`,{className:`pl-9 pt-3 pb-2 text-[9px] font-medium tracking-[0.14em] text-soft-foreground uppercase`,children:e.label}),e.rows.filter(e=>e.kind!==`run`||!m.has(e.run.id)).map(e=>(0,X.jsxs)(`div`,{"data-session-family":e.kind===`run`?e.run.id:void 0,children:[h(e),e.kind===`run`&&p.has(e.run.id)?(0,X.jsx)(`div`,{className:`ml-5`,"data-slot":`session-workers`,children:p.get(e.run.id).map(e=>(0,X.jsx)(`div`,{children:h(e)},e.run.id))}):null]},e.kind===`group`?e.groupId:e.run.id))]},e.label))})}function Ml({view:e,current:t,onSelect:n,count:r,children:i}){let a=e===t;return(0,X.jsxs)(`button`,{type:`button`,"data-slot":`view-tab`,"data-view":e,"aria-pressed":a,onClick:()=>n(e),className:U(`flex min-h-11 min-w-0 flex-1 items-center justify-center gap-1.5 rounded-[7px] text-[11px] font-medium text-muted-foreground md:min-h-[30px]`,a&&`bg-card font-semibold text-foreground shadow-xs`),children:[i,r>0?(0,X.jsx)(`span`,{className:`font-mono text-[11px] tabular-nums`,children:r}):null]})}function Nl({row:e,currentRunId:t,now:n,scope:r,expanded:i,onToggle:a,showTokens:o,showCost:s,onTogglePin:c}){return e.kind===`run`?(0,X.jsx)(Il,{run:e.run,queuePosition:e.queuePosition,currentRunId:t,now:n,scope:r,showTokens:o,showCost:s,onTogglePin:c}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex items-center rounded-sm hover:bg-muted`,children:[(0,X.jsxs)(`button`,{type:`button`,"data-slot":`group-tile`,"data-group-id":e.groupId,"aria-expanded":i,onClick:()=>a(e.groupId),className:`flex min-w-0 flex-1 items-center gap-2 px-2.5 py-[7px] text-left`,children:[(0,X.jsx)(nt,{className:U(`size-3 shrink-0 text-soft-foreground transition-transform`,!i&&`-rotate-90`),"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`min-w-[7rem] flex-1 truncate text-[13px] font-medium`,children:e.title}),(0,X.jsxs)(`span`,{className:`shrink-0 rounded-full bg-muted px-1.5 py-px font-mono text-[10.5px] font-semibold text-muted-foreground`,children:[`×`,e.members.length]})]}),(0,X.jsx)(J,{to:zi(r,`/compare/${e.groupId}`),"data-slot":`group-compare`,title:`Compare the variants`,"aria-label":`Compare the variants of ${e.title}`,className:`mr-1.5 inline-flex size-6 shrink-0 items-center justify-center rounded-sm text-soft-foreground hover:bg-accent-strong/10 hover:text-accent-icon`,children:(0,X.jsx)(dc,{className:`size-3.5`,"aria-hidden":`true`})})]}),i?(0,X.jsx)(Pl,{members:e.members,currentRunId:t,now:n,scope:r,showTokens:o,showCost:s,onTogglePin:c}):null]})}function Pl({members:e,currentRunId:t,now:n,scope:r,showTokens:i,showCost:a,onTogglePin:o}){let s=e.map(e=>(0,X.jsx)(Il,{run:e,queuePosition:null,currentRunId:t,now:n,scope:r,variant:!0,showTokens:i,showCost:a,onTogglePin:o},e.id));return r?(0,X.jsx)(Hr,{projectId:r,requests:e.flatMap(e=>_e(e).map(e=>({projectId:r,kind:e.kind,number:e.number}))),children:s}):(0,X.jsx)(X.Fragment,{children:s})}var Fl=`w-0 overflow-hidden opacity-0 group-hover/task-row:mr-1 group-hover/task-row:w-5 group-hover/task-row:opacity-100 focus-visible:mr-1 focus-visible:w-5 focus-visible:opacity-100 no-hover:mr-1 no-hover:size-11 no-hover:opacity-100 data-[pinned=true]:mr-1 data-[pinned=true]:w-5 data-[pinned=true]:opacity-100`;function Il({run:e,queuePosition:t,currentRunId:n,now:r,scope:i,variant:a=!1,showTokens:o,showCost:s,onTogglePin:c}){let l=Bi(),u=zi(i,`/tasks/${e.id}`),d=it(e),f=e.id===n,p=se(e),m=_e(e),h=A(e),g=D(h,p?.number)?fe(h).rest:h,_=Ur(e),v=Wr(e),y=a?``:t===null?Yi(e.finishedAt??e.createdAt,r):`#${t}`;return(0,X.jsxs)(`div`,{"data-slot":`task-row`,"data-run-id":e.id,"data-active":f?`true`:void 0,onClick:e=>{e.currentTarget.contains(e.target)&&(e.target.closest(`a, button, input`)||l(u))},className:U(`selection-row group/task-row flex cursor-pointer items-center gap-2 rounded-sm pl-2.5 hover:bg-muted`,f&&`bg-[var(--task-brand-selected)]`,a&&`pl-[26px]`),children:[(0,X.jsx)(G,{tone:d.tone,pulse:d.pulse,"aria-label":d.label,title:d.label,role:`img`}),m.length?(0,X.jsx)(`div`,{"data-slot":`session-references`,className:`flex flex-wrap items-center gap-1`,children:m.map(t=>(0,X.jsx)(Qr,{run:e,reference:t,compact:!0,className:`h-auto shrink-0 gap-[2px] px-1 py-px text-[10px] no-hover:min-h-11 no-hover:min-w-11`},`${t.kind}-${t.number}-${t.url}`))}):null,(0,X.jsxs)(J,{to:u,title:h,"aria-current":f?`page`:void 0,className:`flex min-w-0 flex-1 items-center gap-2 py-[7px] pr-2.5 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,children:[a?(0,X.jsx)(`span`,{className:`inline-flex size-[15px] shrink-0 items-center justify-center rounded-full bg-accent-strong/15 font-mono text-[9.5px] font-semibold text-accent-text`,children:e.variant??`?`}):null,(0,X.jsx)(`span`,{"data-slot":`task-row-title`,className:U(`min-w-[7rem] flex-1 truncate text-[13px]`,_?`font-semibold text-foreground`:v?`font-medium text-muted-foreground`:`font-medium`),children:a?Ll(e,o,s):g}),e.diffStat?(0,X.jsx)(_a,{stat:e.diffStat,className:`hidden shrink-0 text-[10.5px] @min-[23rem]/sidebar:inline`}):null,y&&(t!==null||!p)?(0,X.jsx)(`span`,{className:`shrink-0 text-[11px] text-supporting-foreground tabular-nums`,children:y}):null,_?(0,X.jsx)(G,{tone:`accent`,role:`img`,"aria-label":`unread`,title:`Unread — not opened since it finished`,className:`ml-0.5 shrink-0`}):null]}),e.delegation?.role===`worker`?(0,X.jsxs)(`span`,{className:`sr-only`,children:[`Worker · `,d.label]}):null,c?(0,X.jsx)(kl,{pinned:!!e.pinned,onToggle:t=>c(e,t),className:Fl}):null]})}function Ll(e,t,n){let r=[e.runner??`claude`];t&&(e.inputTokens!==void 0||e.outputTokens!==void 0)&&r.push(va(e.inputTokens,e.outputTokens));let i=en(e.costUsd);return n&&i&&r.push(i),r.join(` · `)}function Rl({showViewControls:e=!0}){let t=wt(),n=xe(),r=xa(H().data),[i,a]=bl(),o=Hi(`/tasks/:id/*`),s=Hi(`/tasks/:id`),c=ma(3e4),l=Ye(),u=Y.useMemo(()=>l===void 0?[]:(t.data??[]).flatMap(e=>_e(e).map(e=>({projectId:l,kind:e.kind,number:e.number}))),[t.data,l]);return t.data?(0,X.jsx)(Hr,{projectId:l,requests:u,children:(0,X.jsx)(Al,{showViewControls:e,runs:t.data,view:i,onViewChange:a,currentRunId:o?.params.id??s?.params.id??null,now:c,showTokens:r.tokens,showCost:r.cost,onTogglePin:(e,t)=>n.mutate({id:e.id,pinned:t})})}):null}function zl(){let[e,t]=bl(),n=wt(),r=M().data,i=ur(),a=(r?.projects??[]).filter(e=>e.id!==r?.bootProject),o=Te({queries:a.map(e=>({queryKey:[e.id,`runs`,`list`],queryFn:async()=>[],enabled:!1}))}),s=new Set,c=[],l=(e,t)=>{let n=`${e}:${t.id}`;s.has(n)||(s.add(n),c.push(t))};for(let e of n.data??[])l(i,e);a.forEach((e,t)=>{for(let n of o[t]?.data??[])l(e.id,n)});let u=We(c);return(0,X.jsxs)(`div`,{"data-slot":`sidebar-session-scope`,role:`group`,"aria-label":`Session scope`,className:`flex w-full gap-1 rounded-lg bg-muted p-[3px]`,children:[(0,X.jsxs)(Ml,{view:`active`,current:e,onSelect:t,count:u.active,children:[`Active`,u.waiting>0&&e!==`active`?(0,X.jsx)(G,{tone:`pending`,pulse:!0,"data-slot":`waiting-dot`,"aria-label":`needs you`}):null]}),(0,X.jsx)(Ml,{view:`archived`,current:e,onSelect:t,count:u.archived,children:`Archived`})]})}var Bl=`cez-sidebar-collapsed`;function Vl(e){if(typeof e!=`object`||!e||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))typeof r==`boolean`&&(t[n]=r);return t}function Hl(){try{let e=localStorage.getItem(Bl);return e===null?{}:Vl(JSON.parse(e))}catch{return{}}}function Ul(e){try{localStorage.setItem(Bl,JSON.stringify(e))}catch{}}function Wl(e,t,n){let r=e?.[t];return r===void 0?t!==n:r}var Gl=10;function Kl(e){let[t,n]=Y.useState(Hl),r=Y.useRef(t);return{collapsed:t,toggle:Y.useCallback(t=>{let i={...r.current,[t]:!Wl(r.current,t,e)};r.current=i,Ul(i),n(i)},[e])}}function ql({projects:e,bootProjectId:t,inboxAvailable:n=!1,automationsAvailable:r=!1,inboxCount:i=null,skillsUpdateAvailable:a=!1}){let{pathname:o}=Jn(),s=Vi(o),c=s??t,{collapsed:l,toggle:u}=Kl(c),[d]=bl(),f=Cc(Wi(o)),p=Hi(`/tasks/:id/*`),m=Hi(`/tasks/:id`),h=p?.params.id??m?.params.id??null,g=ma(3e4),_=xa(H().data);return(0,X.jsx)(`div`,{"data-slot":`project-group-list`,children:Y.useMemo(()=>[...e].sort((e,t)=>t.lastOpenedAt.localeCompare(e.lastOpenedAt)),[e]).map(e=>(0,X.jsx)(Jl,{project:e,boot:e.id===t,active:e.id===s,collapsed:Wl(l,e.id,c),onToggle:u,view:d,activeTo:f,currentRunId:h,now:g,inboxAvailable:n,automationsAvailable:r,inboxCount:i,skillsUpdateAvailable:a,showTokens:_.tokens,showCost:_.cost},e.id))})}function Jl({project:e,boot:t,active:n,collapsed:r,onToggle:i,view:a,activeTo:o,currentRunId:s,now:c,inboxAvailable:l,automationsAvailable:u,inboxCount:d,skillsUpdateAvailable:p,showTokens:m,showCost:h}){let g=e.status===`missing`,_=oe(e.id,!r&&!g,t),v=al(),y=xe(e.id,t?`default`:e.id),b=_.data?We(_.data).waiting:0,x=_.data?f(Xe(_.data,a),Gl):[],S=x.flatMap(t=>t.rows.flatMap(t=>_e(t.kind===`run`?t.run:t.members[0]).map(t=>({projectId:e.id,kind:t.kind,number:t.number}))));if(g)return(0,X.jsx)(`div`,{"data-slot":`project-group`,"data-project":e.id,"data-status":`missing`,className:`mb-3`,children:(0,X.jsxs)(`div`,{"data-slot":`project-group-header`,title:`${e.root} is gone — remove it in Global settings → Projects`,className:`flex h-11 w-full items-center gap-[7px] rounded-lg px-2 text-[13px] font-semibold opacity-55 md:h-[34px]`,children:[(0,X.jsx)(`span`,{className:`w-3 shrink-0`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`truncate`,children:e.name}),(0,X.jsx)(`span`,{"data-slot":`project-missing`,className:`ml-auto shrink-0 rounded-full bg-danger/15 px-[7px] py-px text-[10px] font-medium text-danger`,children:`folder not found`})]})});let C=`project-group-${e.id}`;return(0,X.jsxs)(`div`,{"data-slot":`project-group`,"data-project":e.id,"data-status":e.status,"data-collapsed":r?``:void 0,"data-active":n?``:void 0,className:`mb-3`,children:[(0,X.jsxs)(`div`,{className:`relative flex min-h-10 w-full items-center gap-2 rounded-md bg-muted px-2 py-2 text-left text-[13px] font-semibold`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),"aria-expanded":!r,"aria-controls":C,"aria-label":`Toggle ${e.name}`,"data-slot":`project-group-header`,className:`absolute inset-0 rounded-md hover:bg-muted/80`}),r?(0,X.jsx)(Dt,{className:`pointer-events-none relative size-[18px] shrink-0 text-muted-foreground`,"aria-hidden":`true`}):(0,X.jsx)(Pt,{className:`pointer-events-none relative size-[18px] shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,X.jsx)(J,{to:zi(e.id,`/`),onClick:()=>{v?.(),i(e.id)},className:`pointer-events-auto relative min-w-0 flex-1 truncate`,"aria-label":`Open ${e.name}`,children:e.name}),e.branch?(0,X.jsx)(`span`,{"data-slot":`project-branch`,className:`pointer-events-none relative max-w-[40%] shrink-0 truncate font-['IBM_Plex_Mono'] text-[10px] leading-[14px] font-normal text-soft-foreground`,children:e.branch}):null,b?(0,X.jsx)(`span`,{"data-slot":`project-attention`,title:`${b} task${b===1?``:`s`} need${b===1?`s`:``} you`,className:`pointer-events-none relative shrink-0 rounded-full bg-pending/15 px-1.5 py-0.5 text-[10px] font-medium text-pending-strong`,children:b}):null,(0,X.jsx)(nt,{className:U(`pointer-events-none relative size-4 shrink-0 text-muted-foreground transition-transform`,r&&`-rotate-90`),"aria-hidden":`true`})]}),r?null:(0,X.jsxs)(`div`,{id:C,"data-slot":`project-group-body`,className:`mt-1`,children:[(0,X.jsx)(`nav`,{"aria-label":`${e.name} navigation`,className:`flex flex-col gap-0.5`,children:xc({forge:e.forge===`github`,inbox:l,automations:u}).map(t=>{let r=n&&t.to===o,i=t.icon;return(0,X.jsxs)(J,{to:zi(e.id,t.to),onClick:v,"aria-current":r?`page`:void 0,className:U(`selection-row focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground flex h-11 w-full items-center gap-2.5 rounded-md px-2.5 text-xs md:text-[11px] font-normal text-muted-foreground transition-colors hover:bg-muted hover:text-foreground md:h-[30px]`,r&&`bg-[var(--task-brand-selected)] text-accent-text`),children:[(0,X.jsx)(i,{className:`size-[15px] shrink-0 text-soft-foreground`,"aria-hidden":`true`}),t.label,t.badge===`inbox-count`&&n&&d?(0,X.jsx)(`span`,{"data-slot":`nav-badge`,className:`ml-auto rounded-full bg-accent-strong px-1.5 py-px text-[10.5px] font-semibold text-accent-strong-foreground`,children:d}):null,t.badge===`skills-update`&&n&&p?(0,X.jsxs)(`span`,{"data-slot":`nav-update-marker`,className:`ml-auto flex items-center`,children:[(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-accent-strong`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Skills update available`})]}):null]},t.to)})}),(0,X.jsx)(Hr,{projectId:e.id,requests:S,children:(0,X.jsx)(jl,{buckets:x,currentRunId:n?s:null,now:c,scope:e.id,showTokens:m,showCost:h,onTogglePin:a===`archived`?void 0:(e,t)=>y.mutate({id:e.id,pinned:t})})}),(0,X.jsx)(J,{to:zi(e.id,`/`),onClick:v,"data-slot":`project-group-more`,className:`flex min-h-9 items-center rounded-md px-3 text-[11px] text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,children:`More…`})]})]})}var Yl={claude:!0,codex:!0,opencode:!0,pi:!0,cursor:!0},Xl=e=>Object.hasOwn(Yl,e.name);function Zl(e){let t=e.checks.filter(Xl);if(t.length&&!t.some(e=>e.available))return`no agent CLI found — install one to run tasks`;let n=t.find(t=>t.name===e.defaultRunner);return n&&!n.available?`default runner (${e.defaultRunner}) not found`:null}function Ql(e){let t=`cezar v${e.version}`,n=Zl(e);if(n)return`${t} · ${n}`;let r=e.checks.filter(e=>!e.available).map(e=>e.name);return r.length?`${t} · optional: ${r.join(`, `)} not installed`:t}function $l(e){return e.forge?.available?null:e.forge?`GitHub is unreachable — ${e.forge.reason??`unknown reason`}. The GitHub tab is hidden until it comes back.`:`No GitHub remote detected — the GitHub tab is hidden. Every plain-git feature still works.`}function eu({health:e,sessionScope:t}){if(!e)return null;let n=Zl(e);return(0,X.jsxs)(wr,{children:[(0,X.jsx)(br,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"data-slot":`tools-menu-trigger`,"aria-label":`Tools`,title:Ql(e),className:`relative flex size-9 items-center justify-center gap-0.5 rounded-lg text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground md:min-h-9`,children:[(0,X.jsx)(kt,{className:`size-4`,"aria-hidden":`true`}),n?(0,X.jsx)(G,{tone:`pending`,className:`absolute top-1 right-1 size-1.5`}):null,(0,X.jsx)(`span`,{className:`sr-only`,children:`Tools`}),(0,X.jsx)(nt,{className:`size-[11px]`,"aria-hidden":`true`})]})}),(0,X.jsxs)(Cr,{side:`top`,align:`start`,"data-slot":`tools-menu-content`,className:`w-[240px]`,children:[t?(0,X.jsx)(`div`,{className:`px-2 py-2`,children:t}):null,(0,X.jsx)(pr,{className:`text-[11px] font-semibold tracking-[.04em] text-soft-foreground uppercase`,children:`Installed tools`}),e.checks.map(e=>e.available?(0,X.jsx)(tu,{check:e},e.name):(0,X.jsx)(nu,{check:e},e.name)),$l(e)?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(mr,{}),(0,X.jsx)(`p`,{"data-slot":`forge-note`,className:`px-2 py-1.5 text-[11px] leading-snug text-muted-foreground`,children:$l(e)})]}):null,(0,X.jsx)(mr,{}),(0,X.jsx)(yr,{asChild:!0,children:(0,X.jsx)(z,{to:`/tools`,children:`Tools diagnostics`})}),(0,X.jsx)(yr,{asChild:!0,children:(0,X.jsxs)(J,{to:`/settings/agents`,"data-slot":`tools-settings`,className:`gap-2 text-[12.5px] text-muted-foreground`,children:[(0,X.jsx)(p,{className:`size-3.5`,"aria-hidden":`true`}),`Tool settings`]})})]})]})}function tu({check:e}){return(0,X.jsxs)(`div`,{"data-slot":`tool-row`,"data-tool":e.name,"data-available":`true`,className:`flex items-center gap-2 rounded-sm px-2 py-1.5`,children:[(0,X.jsx)(G,{tone:`success`}),(0,X.jsx)(`span`,{className:`font-mono text-[12.5px] font-medium`,children:e.name}),(0,X.jsx)(`span`,{"data-slot":`tool-version`,className:`ml-auto font-mono text-[11.5px] font-medium text-muted-foreground tabular-nums`,children:e.version??`not found`})]})}function nu({check:e}){return(0,X.jsx)(yr,{asChild:!0,children:(0,X.jsxs)(J,{to:`/settings/agents`,"data-slot":`tool-row`,"data-tool":e.name,"data-available":`false`,className:`flex-col items-stretch gap-1`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(G,{tone:`danger`}),(0,X.jsx)(`span`,{className:`font-mono text-[12.5px] font-medium`,children:e.name}),(0,X.jsx)(`span`,{"data-slot":`tool-version`,className:`ml-auto font-mono text-[11.5px] font-medium text-muted-foreground`,children:`not found`})]}),(0,X.jsxs)(`span`,{className:`flex items-end justify-between gap-3 pl-[15px]`,children:[e.hint?(0,X.jsx)(`span`,{"data-slot":`tool-hint`,className:`min-w-0 text-[11px] leading-snug text-muted-foreground`,children:e.hint}):null,(0,X.jsx)(`span`,{"data-slot":`tool-setup`,className:`ml-auto shrink-0 text-[11.5px] font-semibold text-accent-text`,children:`Set up →`})]})]})})}function ru(e){return e?.trim()||null}function iu({projectName:e,pageLabel:t}){let n=ru(e),r=ru(t);return n&&r?`${n} — ${r} · cezar`:n?`${n} · cezar`:r?`${r} · cezar`:`cezar`}function au(e){let t=iu(e);(0,Y.useEffect)(()=>{document.title=t},[t])}var ou=`cez-last-location`;function su(){try{let e=localStorage.getItem(ou);return e===null?null:JSON.parse(e)}catch{return null}}function cu(e){try{localStorage.setItem(ou,JSON.stringify(e))}catch{}}var lu=new Set([`projectId`,`pathname`,`search`,`hash`]);function uu(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e;if(Object.keys(t).some(e=>!lu.has(e))||typeof t.projectId!=`string`||t.projectId.length<1||t.projectId.length>64||typeof t.pathname!=`string`||t.pathname.length<1||t.pathname.length>2048||!t.pathname.startsWith(`/p/`)||t.search!==void 0&&(typeof t.search!=`string`||t.search.length>4096||!t.search.startsWith(`?`))||t.hash!==void 0&&(typeof t.hash!=`string`||t.hash.length>2048||!t.hash.startsWith(`#`)))return null;try{if(Vi(t.pathname)!==t.projectId)return null}catch{return null}return{projectId:t.projectId,pathname:t.pathname,...t.search===void 0?{}:{search:t.search},...t.hash===void 0?{}:{hash:t.hash}}}function du(e,t){let n=t.projects.find(t=>t.id===e);return n!==void 0&&n.status!==`missing`}function fu(e,t){if(t===void 0)return null;let n;try{n=Vi(e.pathname)}catch{return null}return n===null||!du(n,t)?null:uu({projectId:n,pathname:e.pathname,...e.search===``?{}:{search:e.search},...e.hash===``?{}:{hash:e.hash}})}function pu(e,t,n){let r=uu(e);return r===null||!(t===void 0?n!==void 0&&r.projectId===n:du(r.projectId,t))?null:`${r.pathname}${r.search??``}${r.hash??``}`}function mu(e,t){let n=uu(e);return n!==null&&n.projectId===t.projectId&&n.pathname===t.pathname&&(n.search??``)===(t.search??``)&&(n.hash??``)===(t.hash??``)}function hu(){return(0,X.jsx)(`div`,{"data-route":`compare`,className:`flex min-h-full flex-col`,children:(0,X.jsx)(R,{icon:(0,X.jsx)(qi,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading variants…`,subtitle:`Fetching every variant's status, spend and diff summary.`})})}function gu(){return(0,X.jsx)(`div`,{"data-route":`github`,className:`flex min-h-full flex-col`,children:(0,X.jsx)(R,{icon:(0,X.jsx)(qi,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading GitHub…`,subtitle:`Fetching open issues and pull requests.`})})}function _u(e){let t=Me(),n=Mt(),r=At(t.data),i=n.data?.defaultRunner,a=gi(e.runner,r,i??r[0]??`claude`),o=Mn(a),s=n.data?.modelsLocked===!0,{accounts:c,repoAccount:l}=Ar(),u=c.some(t=>t.provider===a&&t.id===e.account)?e.account:null,d=Li(s?null:e.model,a,n.data?.defaultModels,o.data),f=wi(a,d,o.data);return{runner:a,runnerExplicit:e.runner!==null,model:d,effort:s?``:bi(e.effort,f),effortOptions:f,runners:r,defaultRunner:i,canRun:t.isSuccess&&r.length>0,modelsLocked:s,providerPending:t.isPending,providerError:t.isError,accounts:c,account:u,repoAccount:l}}function vu(e){return{runner:Ii(e.runner,e.defaultRunner,e.runnerExplicit),model:e.modelsLocked?void 0:e.model||void 0,effort:e.modelsLocked?void 0:e.effort||void 0}}function yu(e){return{...vu(e),...e.account?{agentProfile:e.account}:{}}}function bu({pick:e,onChange:t,disabled:n=!1,accounts:r=!1}){let i=_u(e),{runner:a,model:o,effort:s,effortOptions:c,runners:l,canRun:u,modelsLocked:d}=i,f=Mt(),p=Mn(a),m=Fi(a,p.data,[e.model,f.data?.defaultModels?.[a]]),h=n||!u,g=r?i.accounts:[];return(0,X.jsxs)(X.Fragment,{children:[l.length>1||l.some(e=>Nr(g,e))?(0,X.jsx)(Di,{icon:(0,X.jsx)(En,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:l,value:a,accounts:g,account:r?i.account:null,repoAccount:r?i.repoAccount:void 0,disabled:h,onPick:(n,i)=>t(r?{runner:n,account:i,model:n===a?e.model:null,effort:e.effort}:{runner:n,account:null,model:null,effort:e.effort})}):null,(0,X.jsx)(xi,{icon:(0,X.jsx)(vt,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`model-pill`,ariaLabel:`Model`,label:o===``?`Default`:m.find(e=>e.id===o).label,value:o,disabled:h,readOnly:d===!0,disabledHint:d?`Model selection is locked to native coding-agent settings.`:void 0,onPick:n=>{let r=wi(a,n,p.data);t({...e,model:n,effort:e.effort===null?null:bi(e.effort,r)})},options:m.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:vi(a,p.data,p.isError,p.isFetching)}),(0,X.jsx)(xi,{icon:(0,X.jsx)(Ht,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`effort-pill`,ariaLabel:`Effort`,label:c.find(e=>e.value===s)?.label??`auto`,value:s,disabled:h,readOnly:d===!0,disabledHint:d?`Effort selection is locked to native coding-agent settings.`:void 0,onPick:n=>t({...e,effort:n}),options:c.map(e=>({value:e.value,label:e.label,desc:e.desc}))})]})}function xu({templates:e,onInsert:t,triggerClassName:n,disabled:r,iconOnly:i=!1,label:a=`Template`}){let[o,s]=(0,Y.useState)(!1),c=(0,Y.useRef)(null),l=Bi();return e.length===0?null:(0,X.jsxs)(Mr,{open:o,onOpenChange:s,children:[(0,X.jsx)(jr,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-trigger`,"aria-label":`Insert a prompt template`,title:`Insert a prompt template`,disabled:r,className:U(`inline-flex h-[26px] items-center gap-1.5 rounded-full border border-border bg-card text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,i?`w-[26px] justify-center px-0`:`h-11 gap-2 rounded-lg px-3 text-foreground`,n),children:[(0,X.jsx)(ye,{"aria-hidden":`true`,className:i?`size-3 shrink-0 text-accent-icon`:`size-[18px] shrink-0 text-muted-foreground`}),i?null:(0,X.jsxs)(X.Fragment,{children:[a,(0,X.jsx)(nt,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`})]})]})}),(0,X.jsx)(Or,{align:`start`,sideOffset:8,"data-slot":`prompt-template-menu`,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,onCloseAutoFocus:e=>e.preventDefault(),children:(0,X.jsxs)(li,{filter:Zi,children:[(0,X.jsx)(oi,{placeholder:`search templates…`,onInput:()=>c.current?.scrollTo(0,0)}),(0,X.jsxs)(fi,{ref:c,"data-slot":`prompt-template-list-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[(0,X.jsx)(mi,{children:`Nothing matches.`}),(0,X.jsx)(q,{heading:`Insert a template`,children:e.map(e=>(0,X.jsxs)(K,{value:`template ${e.label} ${e.id}`,keywords:[e.text,...e.skills??[]],"data-slot":`prompt-template-option`,"data-template":e.id,title:e.text,className:`flex-col items-start gap-0.5`,onSelect:()=>{t(e.text),s(!1)},children:[(0,X.jsxs)(`span`,{className:`flex w-full items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12.5px] font-medium text-foreground`,children:e.label}),e.skills&&e.skills.length>0?(0,X.jsxs)(`span`,{"data-slot":`prompt-template-assigned`,title:`Applied automatically with: ${e.skills.join(`, `)}`,className:`inline-flex shrink-0 items-center gap-0.5 text-[10px] font-medium text-accent-text`,children:[(0,X.jsx)(Ge,{"aria-hidden":`true`,className:`size-2.5`}),e.skills.length]}):null]}),(0,X.jsx)(`span`,{className:`line-clamp-1 text-[11px] text-soft-foreground`,children:e.text})]},e.id))}),(0,X.jsx)(pi,{}),(0,X.jsx)(q,{children:(0,X.jsx)(K,{value:`edit prompt templates settings`,"data-slot":`prompt-template-settings`,className:`text-[12px] text-muted-foreground`,onSelect:()=>{s(!1),l(`/settings/prompt-templates`)},children:`Edit templates…`})})]})]})})]})}function Su(e){return e.filter(e=>!e.startedTaskId)}function Cu(e){return e.runnable??!!(e.suggestedSkill||e.suggestedPrompt)}function wu(){let e=H(),t=e.data?.capabilities.followups===!0,n=e.data!==void 0&&!t,r=cn(!n),i=wt(),a=Ye(),o=M().data?.projects?.find(e=>e.id===a)?.name,s=r.data===void 0?void 0:Su(r.data);return(0,X.jsxs)(`div`,{"data-route":`inbox`,"data-inbox-empty":s?.length===0&&!n,className:`task-flow-page flex min-h-full flex-col`,children:[(0,X.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-5`,children:[(0,X.jsx)(`h1`,{className:`text-[28px] font-medium`,children:`Inbox`}),(0,X.jsx)(`p`,{className:`text-[13px] text-soft-foreground`,children:n?`Disabled for this server; per-task Notes still run.`:`Follow-ups from your agents. Review the suggestion, then start a new task.`})]}),(0,X.jsx)(`div`,{className:`flex flex-1 flex-col`,children:n?(0,X.jsx)(R,{icon:(0,X.jsx)(qn,{}),tone:`neutral`,title:`Inbox is off`,subtitle:`Agents are not asked to leave follow-ups. Set CEZ_FOLLOWUPS=1 and restart Cezarion to enable Inbox.`,heading:`h2`}):s===void 0?r.isError?(0,X.jsx)(R,{icon:(0,X.jsx)(st,{}),tone:`danger`,title:`Could not load the inbox`,subtitle:r.error.message,actions:(0,X.jsx)(I,{variant:`outline`,onClick:()=>void r.refetch(),children:`Retry`}),heading:`h2`}):(0,X.jsx)(`div`,{role:`status`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:`Loading follow-ups…`}):s.length===0?e.isPending?null:(0,X.jsx)(R,{icon:(0,X.jsx)(qn,{}),tone:`neutral`,title:`You’re all caught up`,subtitle:`No follow-ups to review. New suggestions and notes from your agents will appear here.`,heading:`h2`}):(0,X.jsx)(`ul`,{"data-slot":`todo-list`,className:`flex w-full flex-col gap-5`,children:s.map(e=>(0,X.jsx)(Tu,{todo:e,projectName:o,sourceTaskExists:e.taskId===void 0?null:i.data?.some(t=>t.id===e.taskId)??!1},e.id))})})]})}function Tu({todo:e,projectName:t,sourceTaskExists:n}){let r=Bi(),a=o(),s=Vt(),[c,l]=(0,Y.useState)({runner:null,model:null,effort:null,account:null}),u=_u(c),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(``),h=(0,Y.useRef)(null),g=yi(s.data?.promptTemplates),_=e=>{let t=h.current?.selectionStart??p.length,n=Mi(p,t,e);m(n.text),requestAnimationFrame(()=>{h.current?.focus(),h.current?.setSelectionRange(n.caret,n.caret)})},v=F({mutationFn:async()=>u.canRun?Wt(e.id,{...vu(u),prompt:p.trim()||void 0}):null,onSuccess:e=>{if(e===null)return;let{run:t}=e;a.invalidateQueries({queryKey:L.todos}),a.invalidateQueries({queryKey:L.runs.all}),r(`/tasks/${t.id}`)},onError:e=>B(e.message,{tone:`danger`})}),y=F({mutationFn:()=>i(e.id),onSuccess:()=>{a.setQueryData(L.todos,t=>t?.filter(t=>t.id!==e.id)),a.invalidateQueries({queryKey:L.todos})},onError:e=>B(e.message,{tone:`danger`})}),b=v.isPending||y.isPending,x=Cu(e);return(0,X.jsxs)(`li`,{"data-slot":`todo-card`,"data-runnable":x,"data-id":e.id,className:`flex flex-col gap-2.5 rounded-lg border border-border bg-card p-4 shadow-xs`,children:[(0,X.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`p`,{"data-slot":`todo-summary`,className:`text-sm leading-snug font-medium text-foreground`,children:e.summary}),(0,X.jsxs)(`div`,{"data-slot":`todo-meta`,className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-soft-foreground`,children:[t?(0,X.jsx)(`span`,{children:t}):null,(0,X.jsx)(`span`,{children:x?`Runnable follow-up`:`Note only`}),e.ts?(0,X.jsxs)(`span`,{children:[Yi(e.ts),` ago`]}):null,e.action?(0,X.jsx)(`span`,{children:e.action}):null,e.taskId===void 0?null:n?(0,X.jsxs)(J,{to:`/tasks/${e.taskId}`,"data-slot":`todo-source`,className:`text-muted-foreground underline decoration-border underline-offset-2 hover:text-foreground`,children:[`Source task `,(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`↗`})]}):(0,X.jsx)(`span`,{"data-slot":`todo-source-gone`,children:`source task deleted`}),sr(e.prUrl)?(0,X.jsx)(`a`,{href:e.prUrl,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`todo-pr`,className:`text-muted-foreground underline decoration-border underline-offset-2 hover:text-foreground`,children:`PR`}):null,e.suggestedSkill?(0,X.jsxs)(`span`,{"data-slot":`todo-skill`,className:`font-mono`,children:[`skill: `,e.suggestedSkill]}):null]})]})}),x&&e.suggestedPrompt&&e.suggestedPrompt!==e.summary?(0,X.jsx)(`p`,{"data-slot":`todo-prompt`,className:`whitespace-pre-wrap break-words text-[13px] leading-relaxed text-muted-foreground`,children:e.suggestedPrompt}):null,x?(0,X.jsxs)(`div`,{"data-slot":`todo-engine`,className:`flex flex-wrap items-center gap-2 pl-5`,children:[(0,X.jsx)(bu,{pick:c,onChange:l,disabled:b||!u.canRun}),!u.providerPending&&!u.canRun?(0,X.jsxs)(`span`,{"data-slot":`todo-provider-gate`,className:`inline-flex flex-wrap items-center gap-1 text-xs text-muted-foreground`,children:[u.providerError?`Provider authentication could not be verified.`:`Connect an agent provider to run this follow-up.`,(0,X.jsx)(J,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null]}):null,x?d?(0,X.jsxs)(`div`,{"data-slot":`todo-instructions`,className:`flex flex-col gap-2 pl-5`,children:[(0,X.jsx)(`label`,{htmlFor:`todo-instructions-${e.id}`,className:`text-xs text-muted-foreground`,children:`Additional instructions`}),(0,X.jsx)(Br,{ref:h,id:`todo-instructions-${e.id}`,"data-slot":`todo-instructions-input`,"aria-label":`Extra instructions for this follow-up`,value:p,onChange:e=>m(e.target.value),placeholder:`Add instructions for the agent… (appended to the suggestion above)`,maxLength:2e4,className:`min-h-11 text-[13px]`})]}):(0,X.jsx)(`button`,{type:`button`,"data-slot":`todo-instructions-toggle`,onClick:()=>f(!0),className:`self-start pl-5 text-xs font-medium text-muted-foreground underline decoration-border underline-offset-2 hover:text-foreground`,children:p.trim()?`Edit instructions (added)`:`+ Add instructions`}):null,(0,X.jsxs)(`div`,{"data-slot":`todo-actions`,className:`flex flex-wrap items-center gap-3`,children:[x&&d?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(xu,{templates:g,onInsert:_}),(0,X.jsx)(I,{type:`button`,variant:`outline`,"data-slot":`todo-instructions-hide`,onClick:()=>f(!1),children:`Hide instructions`})]}):null,x?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(I,{type:`button`,variant:`primary`,size:`sm`,"data-action":`todo-run`,title:`Start a task from this follow-up`,disabled:b||!u.canRun,onClick:()=>v.mutate(),children:`Run follow-up`}),(0,X.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,"data-action":`todo-dismiss`,title:`Check off (remove)`,disabled:b,onClick:()=>y.mutate(),children:`Dismiss`})]}):(0,X.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,"data-action":`todo-acknowledge`,title:`Acknowledge and remove this note`,disabled:b,onClick:()=>y.mutate(),children:`Acknowledge`})]})]})}function Eu({source:e,className:t}){return(0,X.jsx)(`span`,{"data-slot":`skill-source`,"data-source":e,className:U(`shrink-0 rounded bg-accent-strong/10 px-2 py-1 text-[10.5px]`,ta({source:e})?`font-semibold text-foreground`:`text-soft-foreground`,t),children:e===`team`?`Team`:e})}function Du({skill:e,usedBy:t,heading:n=`h2`}){return(0,X.jsxs)(`div`,{"data-slot":`skill-detail`,className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start gap-4`,children:[(0,X.jsxs)(`span`,{className:`sw-detail-source`,children:[(0,X.jsx)(Eu,{source:e.source}),` skill`]}),(0,X.jsx)(n,{className:`min-w-0 text-[19px] font-normal md:text-2xl break-words [overflow-wrap:anywhere]`,children:e.name})]}),(0,X.jsxs)(`p`,{"data-slot":`skill-path`,className:`mt-4 text-[11px] break-all text-soft-foreground`,children:[e.path,e.team?` · from ${e.team.repo}`:``]}),e.description?(0,X.jsx)(`p`,{"data-slot":`skill-description`,className:`mt-2.5 text-[13px] text-muted-foreground`,children:e.description}):null,t===void 0?null:(0,X.jsxs)(`section`,{"data-slot":`skill-used-by`,className:`mt-5`,children:[(0,X.jsx)(`h3`,{className:`text-[13px] font-semibold`,children:`Used by`}),t.length>0?(0,X.jsx)(`ul`,{className:`mt-1.5 flex flex-col gap-1`,children:t.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-1.5 font-mono text-xs text-muted-foreground`,children:[(0,X.jsx)(Qe,{"aria-hidden":`true`,className:`size-3 shrink-0 text-soft-foreground`}),e]},e))}):(0,X.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,X.jsx)(`section`,{className:`mt-5`,children:(0,X.jsx)(`div`,{"data-slot":`skill-body`,className:`mt-2 text-sm`,children:(0,X.jsx)(Xi,{children:e.body})})})]})}function Ou({skill:e,onClose:t}){return(0,X.jsx)(Ir,{open:e!==null,onOpenChange:e=>e?void 0:t(),children:(0,X.jsx)(Rr,{"data-slot":`skill-preview`,className:`block max-h-[80dvh] overflow-y-auto sm:max-w-2xl`,children:e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(zr,{className:`sr-only`,children:e.name}),(0,X.jsx)(Fr,{className:`sr-only`,children:`Read-only skill preview`}),(0,X.jsx)(Du,{skill:e,heading:`h3`}),(0,X.jsx)(`p`,{className:`mt-5`,children:(0,X.jsx)(J,{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 ku(e,t,n){let r=e.skill===``?{source:`workflow`,ref:`quick-task`}:{source:`skill`,ref:e.skill};return Ti({task:e.ref,source:r,model:``,runner:t,defaultRunner:n,variants:1,images:[],todoId:e.todo})}function Au(e,t){return e.kind===`failed`?{message:`Auto-start failed: ${e.message} — review and press Start`,tone:`danger`}:e.kind===`blocked`?{message:`Auto-start blocked (bad key) — review and press Start`,tone:`danger`}:t===``?{message:`Prefilled from link — review and press Start`,tone:`default`}:{message:`Unknown skill "${t}" — prefilled for quick-task; review and press Start`,tone:`danger`}}function ju(e,t){return`Use the "${e}" skill on: ${t}`}function Mu(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.variants>1?!0:e.explicitWorktree??n??e.configuredWorktree:!1}}function Nu(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 Pu={text:``,source:null,runner:null,agentProfile:null,model:null,effort:null,variants:1,planFirst:!1,worktree:null,autonomous:null,generateFollowups:null},Fu=`cez-new-task-draft`;function Iu(e){return e===null?Fu:`${Fu}:${e}`}function Lu(e){let t=e&&typeof e==`object`?e:{};return{text:typeof t.text==`string`?t.text:``,source:Ru(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,variants:t.variants===2||t.variants===3?t.variants:1,planFirst:t.planFirst===!0,worktree:typeof t.worktree==`boolean`?t.worktree:null,autonomous:typeof t.autonomous==`boolean`?t.autonomous:null,generateFollowups:typeof t.generateFollowups==`boolean`?t.generateFollowups:null}}function Ru(e){return!!e&&typeof e==`object`&&(e.source===`skill`||e.source===`workflow`)&&typeof e.ref==`string`}var zu=new Map,Bu=new Map;function Vu(e=null){return Bu.get(Iu(e))??0}function Hu(e=null){let t=Iu(e),n=zu.get(t);if(n)return{...n};let r;try{let e=localStorage.getItem(t);r=e?Lu(JSON.parse(e)):{...Pu}}catch{r={...Pu}}return zu.set(t,r),{...r}}function Uu(e,t=null){let n=Iu(t);Bu.set(n,Vu(t)+1),zu.set(n,{...e});try{localStorage.setItem(n,JSON.stringify(e))}catch{}}function Wu(e=null,t){t!==void 0&&Vu(e)!==t||Uu({...Hu(e),text:``,source:null},e)}function Gu(e){let t=typeof e==`string`?new URLSearchParams(e):e;return{skill:(t.get(`skill`)??``).trim(),ref:(t.get(`ref`)??t.get(`task`)??``).trim(),auto:t.get(`auto`)===`1`,key:t.get(`key`)??``,todo:(t.get(`todo`)??``).trim()}}function Ku(e,t,n){return{task:e,steps:[...n.steps],rationale:n.rationale,fallback:n.fallback,images:[...t]}}function qu(e,t){return!Number.isInteger(t)||t<0||t>=e.length?[...e]:e.filter((e,n)=>n!==t)}function Ju(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 Yu(e){return e.command??e.prompt??``}function Xu(e,t=120){let n=e.split(`
3
3
  `)[0]??``;return n.length>t?`${n.slice(0,t-1)}…`:n}function Zu(e){let{task:t,steps:n,model:r,modelsLocked:i,effort:a,runner:o,runnerExplicit:s,defaultRunner:c,variants:l,images:u,generateFollowups:d,todoId:f}=e;return{task:t,steps:[...n],model:i?void 0:r||void 0,effort:i?void 0:a||void 0,runner:Ii(o,c,s),variants:l>1?l:void 0,images:u.length>0?[...u]:void 0,generateFollowups:d!==!1&&void 0,todoId:f||void 0}}function Qu({plan:e,starting:t,startAvailable:n,startUnavailableReason:r,startUnavailableAction:i,onStepsChange:a,onStart:o,onDiscard:s}){let[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(null),f=(0,Y.useRef)(null),p=(0,Y.useId)();(0,Y.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(Ju(e.steps,c,n)),m()},g=e.steps.length===0;return(0,X.jsxs)(`div`,{"data-slot":`plan-page`,children:[(0,X.jsxs)(`header`,{"data-slot":`plan-page-header`,children:[(0,X.jsx)(`h1`,{children:`New task / Plan first`}),(0,X.jsx)(`p`,{children:`Review the proposed chain before launching.`})]}),(0,X.jsx)(`div`,{"data-slot":`plan-canvas`,children:(0,X.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,X.jsxs)(`header`,{"data-slot":`dialog-header`,className:`flex flex-col gap-1 px-5 pt-4 pb-3.5 text-left`,children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsx)(`h2`,{id:p,"data-slot":`dialog-title`,className:`text-[11px] font-semibold tracking-[0.08em] text-muted-foreground uppercase`,children:`Proposed chain`}),(0,X.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,X.jsx)(In,{"aria-hidden":`true`,className:`size-4`})})]}),(0,X.jsx)(`p`,{"data-slot":`plan-task`,title:e.task,className:`text-[18px] font-medium text-foreground`,children:Xu(e.task)}),e.fallback?(0,X.jsx)(`p`,{"data-slot":`plan-fallback`,className:`text-xs text-soft-foreground italic`,children:`planner unavailable — single-step plan`}):e.rationale===``?null:(0,X.jsx)(`p`,{"data-slot":`plan-rationale`,className:`text-xs text-muted-foreground`,children:e.rationale})]}),(0,X.jsx)(`ol`,{"data-slot":`plan-steps`,className:`flex-1 space-y-2 overflow-y-auto px-5 py-4`,children:g?(0,X.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,X.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:U(`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,X.jsx)(v,{"aria-hidden":`true`,className:`size-3.5 shrink-0 cursor-grab text-soft-foreground`}),(0,X.jsx)(`span`,{className:`w-5 shrink-0 font-mono text-[11px] text-soft-foreground tabular-nums`,children:String(n+1).padStart(2,`0`)}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-[13px] font-medium`,children:t.name??t.id}),t.skill?(0,X.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-[10.5px] font-medium text-accent-text`,children:t.skill}):null,t.command?(0,X.jsx)(`span`,{"data-slot":`plan-badge-check`,className:`shrink-0 rounded-full bg-muted px-1.5 py-px text-[10.5px] font-medium text-muted-foreground`,children:`check`}):null]}),(0,X.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap break-words font-mono text-[11px] text-muted-foreground`,children:Yu(t)})]}),(0,X.jsxs)(`span`,{"data-slot":`plan-step-actions`,className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(I,{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(Ju(e.steps,n,n-1)),children:`Move up`}),(0,X.jsx)(I,{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(Ju(e.steps,n,n+1)),children:`Move down`}),(0,X.jsx)(I,{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(qu(e.steps,n)),children:`Remove`})]})]},t.id))}),!n&&r?(0,X.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,X.jsx)(`span`,{children:r}),i]}):null,(0,X.jsxs)(`div`,{"data-slot":`plan-actions`,className:`flex flex-wrap items-center gap-3 px-6 pt-3 pb-6`,children:[(0,X.jsxs)(I,{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,X.jsx)(ui,{"aria-hidden":`true`,className:`size-3.5`}),t?`Starting…`:`Start`]}),(0,X.jsx)($u,{steps:e.steps,disabled:g}),(0,X.jsx)(I,{type:`button`,variant:`outline`,onClick:s,children:`Discard`})]}),(0,X.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 $u({steps:e,disabled:t}){let n=o(),[r,i]=(0,Y.useState)(!1),[a,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(!1),f=async t=>{let r=a.trim();if(!(r===``||u)){d(!0);try{let a=await Hn({name:r,steps:e,...t?{overwrite:!0}:{}});B(`Saved — ${a.path.split(`/`).pop()??a.path}`),n.invalidateQueries({queryKey:L.workflows}),l(!1),i(!1),s(``)}catch(e){e instanceof fn&&e.exists===!0?l(!0):B(e instanceof Error?e.message:String(e),{tone:`danger`})}finally{d(!1)}}};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(I,{type:`button`,variant:`outline`,"data-slot":`plan-save`,disabled:t,onClick:()=>i(!0),children:`Save as chain`}),(0,X.jsx)(Ir,{open:r,onOpenChange:e=>i(!!e),children:(0,X.jsxs)(Rr,{"data-slot":`plan-save-dialog`,className:`sm:max-w-sm`,showCloseButton:!1,children:[(0,X.jsxs)(Lr,{children:[(0,X.jsx)(zr,{children:`Save as chain`}),(0,X.jsx)(Fr,{children:`Saves these steps as a reusable workflow — it joins the picker like any other chain.`})]}),(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),f(!1)},children:[(0,X.jsx)(`label`,{htmlFor:`plan-chain-name`,className:`mb-2 block text-[11px] text-muted-foreground`,children:`Chain name`}),(0,X.jsx)(_c,{id:`plan-chain-name`,value:a,onChange:e=>s(e.target.value),"aria-label":`Chain name`,placeholder:`e.g. fix-and-verify-v2`,maxLength:80,autoFocus:!0}),(0,X.jsxs)(Pr,{className:`mt-4`,children:[(0,X.jsx)(I,{type:`button`,variant:`outline`,onClick:()=>i(!1),children:`Cancel`}),(0,X.jsx)(I,{type:`submit`,disabled:a.trim()===``||u,children:u?`Saving…`:`Save chain`})]})]})]})}),(0,X.jsx)(Nn,{open:c,onOpenChange:e=>e?void 0:l(!1),children:(0,X.jsxs)(Ut,{"data-slot":`plan-overwrite-dialog`,children:[(0,X.jsxs)(An,{children:[(0,X.jsxs)(xt,{children:[`Overwrite “`,a.trim(),`”?`]}),(0,X.jsx)(mt,{children:`A chain with this name already exists. Overwriting replaces its steps with this plan.`})]}),(0,X.jsxs)(mn,{children:[(0,X.jsx)(Dn,{children:`Cancel`}),(0,X.jsx)(un,{onClick:()=>void f(!0),children:`Overwrite chain`})]})]})})]})}function ed(){let[e]=Wn(),t=Bi(),n=o(),{projectId:r}=h(),i=Fn().projectId,a=M(),[s]=(0,Y.useState)(()=>Gu(e)),c=H(),l=Un(),u=Nt(),d=de(),f=Vt(),p=Mt(),m=Zn(),[g,_]=(0,Y.useState)(()=>({...Hu(i),...s.ref===``?{}:{text:s.ref},...s.skill===``?{}:{source:{source:`skill`,ref:s.skill}}})),v=(0,Y.useRef)(g);(0,Y.useEffect)(()=>{Uu(v.current,i)},[i]);let y=(0,Y.useRef)(!1),b=(0,Y.useRef)(!0);(0,Y.useEffect)(()=>(b.current=!0,()=>{b.current=!1}),[]);let x=e=>{if(!b.current||y.current)return;let t={...v.current,...e};v.current=t,Uu(t,i),_(t)},S=f.data?.recentSources,C=u.data,ee=f.data?.skillUsage,w=(0,Y.useMemo)(()=>ra(C??[],ee),[C,ee]),te=l.data?.workflows??[],T=a.data?.projects??[],E=u.data!==void 0&&l.data!==void 0&&!f.isPending,D=si(g.source,w,te),ne=D?.source===`skill`?w.find(e=>e.name===D.ref):void 0,ie=(0,Y.useRef)(null),ae=(0,Y.useRef)(null),oe=(0,Y.useMemo)(()=>yi(f.data?.promptTemplates),[f.data?.promptTemplates]),se=ki(oe,D?.source===`skill`?[D.ref]:[]),ce=(0,Y.useRef)(g.text);ce.current=g.text;let le=(0,Y.useRef)(``);(0,Y.useEffect)(()=>{if(!E||y.current)return;let e=Ai(ce.current,le.current,se);le.current=e.applied,e.text!==ce.current&&x({text:e.text})},[se,E]);let O=Me(),ue=At(O.data),fe=p.data?.defaultRunner,pe=fe??`claude`,k=ue.length>0?gi(g.runner,ue,pe):null,me=k??pe,A=O.isSuccess&&ue.length>0,he=Mn(me),ge=p.data?.modelsLocked===!0,j=k===null?[]:Fi(k,he.data,[g.model,p.data?.defaultModels?.[k]]),_e=k===null?``:Li(ge?null:g.model,k,p.data?.defaultModels,he.data),ve=wi(me,_e,he.data),ye=ge?``:bi(g.effort,ve),{accounts:N,repoAccount:be}=Ar(),xe=N.some(e=>e.provider===me&&e.id===g.agentProfile)?g.agentProfile:null,Se=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{let e=A&&!Se.current;Se.current=A,e&&document.activeElement===document.body&&document.querySelector(`textarea[aria-label="Describe a task for the agent"]`)?.focus()},[A]);let Ce=d.data===void 0||d.data.info!==null,we=Ce?g.variants:1,Te=Ce,Ee=we>1,De=Mu({hasGit:Ce,variants:we,planFirst:g.planFirst,explicitAutonomous:g.autonomous,explicitWorktree:g.worktree,interactive:ne?.interactive,configuredAutonomous:m.data?.composerDefaults?.autonomous??m.data?.composerDefaults?.inheritedAutonomous??`source-dependent`,configuredWorktree:m.data?.composerDefaults?.worktree??m.data?.composerDefaults?.inheritedWorktree??!0,source:D?.source??`workflow`}),Oe=De.worktree,ke=De.autonomous,Ae=c.data===void 0||c.data.capabilities.followups,je=Ae?g.generateFollowups??f.data?.lastGenerateFollowups??!0:!1,[Ne,Pe]=(0,Y.useState)(null),[Fe,Ie]=(0,Y.useState)(!1),[P,Le]=(0,Y.useState)(!1),[Re,F]=(0,Y.useState)(()=>s.auto&&s.ref!==``),[ze,Be]=(0,Y.useState)(()=>!s.auto&&s.ref!==``?{kind:`prefill`}:null),Ve=(0,Y.useRef)(!1),Ue=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{Ve.current||(Ve.current=!0,e.toString()!==``&&t(`/new`,{replace:!0}))},[]),(0,Y.useEffect)(()=>{if(Ue.current||!s.auto||s.ref===``||O.isPending)return;if(!A||k===null){Ue.current=!0,Be({kind:`prefill`}),F(!1);return}if(p.isPending)return;if(Ue.current=!0,fe===void 0){Be({kind:`prefill`}),F(!1);return}let e=Vu(i);(async()=>{let r=``;try{r=(await $t()).key}catch{}if(r!==``&&s.key===r)try{let r=await It(ku(s,k,fe));Wu(i,e),n.invalidateQueries({queryKey:L.runs.all}),b.current&&t(_i(r));return}catch(e){Be({kind:`failed`,message:e instanceof Error?e.message:String(e)})}else Be({kind:`blocked`});F(!1)})()},[p.isPending,fe,O.isPending,A,k]),(0,Y.useEffect)(()=>{if(ze===null||!E)return;Be(null);let e=s.skill!==``&&!w.some(e=>e.name===s.skill)?s.skill:``;e!==``&&x({text:ju(s.skill,s.ref),source:null});let{message:t,tone:n}=Au(ze,e);B(t,{tone:n}),document.querySelector(`[data-slot="composer"] button[aria-label="Start task"], [data-slot="composer"] button[aria-label="Plan task"]`)?.focus()},[ze,E]);let We=async(e,r)=>{let a=Vu(i);if(!A||k===null)throw Error(O.isPending?`Checking agent providers…`:O.isError?`Provider authentication could not be verified.`:`Connect an agent provider before starting a task.`);if(!E)throw Error(`Still loading workflows and skills — try again in a second.`);if(g.planFirst){Ie(!0);try{let t=await He(e);b.current&&Pe(Ku(e,r,t))}finally{Ie(!1)}return}let o=await It(Ti({task:e,source:D,model:_e,modelsLocked:ge,effort:ye,runner:k,runnerExplicit:g.runner!==null,agentProfile:xe,defaultRunner:fe,variants:we,images:r,worktree:Oe,autonomous:ke,generateFollowups:je,todoId:s.todo}));wn({lastTask:D,...D?{recentSources:Ri(S,D)}:{},...Ae?{lastGenerateFollowups:je}:{},...D?.source===`skill`&&f.data!==void 0?{skillUsage:ia(f.data.skillUsage,D.ref)}:{}}).then(()=>n.invalidateQueries({queryKey:L.uiState})).catch(()=>{}),Wu(i,a),n.invalidateQueries({queryKey:L.runs.all}),b.current&&t(_i(o))},Ge=async()=>{if(Ne===null||Ne.steps.length===0||P||!A||k===null)return;let e=Vu(i);Le(!0);try{let r=await It(Zu({task:Ne.task,steps:Ne.steps,model:_e,modelsLocked:ge,effort:ye,runner:k,runnerExplicit:g.runner!==null,defaultRunner:fe,variants:we,images:Ne.images,generateFollowups:je,todoId:s.todo}));Ae&&wn({lastGenerateFollowups:je}).then(()=>n.invalidateQueries({queryKey:L.uiState})).catch(()=>{}),Wu(i,e),Pe(null),n.invalidateQueries({queryKey:L.runs.all}),b.current&&t(_i(r))}catch(e){B(e instanceof Error?e.message:String(e),{tone:`danger`})}finally{Le(!1)}};return Re?(0,X.jsxs)(`div`,{"data-route":`new`,className:`relative isolate flex min-h-full flex-col items-center justify-center overflow-x-clip px-6`,children:[(0,X.jsx)(Rn,{}),(0,X.jsxs)(`div`,{"data-slot":`auto-starting`,role:`status`,className:`text-center`,children:[(0,X.jsx)(`h1`,{className:`animate-pulse text-lg font-semibold tracking-tight`,children:`Starting task…`}),(0,X.jsx)(`p`,{className:`mt-1.5 text-[13.5px] text-muted-foreground`,children:`Launched from a bookmarklet — taking you to the run.`})]})]}):(0,X.jsxs)(`div`,{"data-route":`new`,"data-plan-review":Ne===null?void 0:`true`,className:`relative isolate flex min-h-full flex-col overflow-x-clip pb-16`,children:[(0,X.jsxs)(`div`,{ref:ae,style:Ne===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,X.jsxs)(`header`,{className:`mb-7 max-md:mb-5`,children:[(0,X.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,X.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,X.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.`})]}),(0,X.jsx)(da,{ref:ie,onSubmit:We,retainDraftUntilSuccess:!0,idleFeedback:(0,X.jsxs)(`div`,{"data-slot":`new-task-mode-note`,className:`flex items-center justify-between gap-3 text-[11px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{children:g.planFirst?`Review the plan before starting the task.`:`Start immediately with the selected configuration.`}),(0,X.jsx)(`kbd`,{className:`hidden font-sans md:inline`,children:Sa()})]}),pendingLabel:g.planFirst?`Planning task…`:`Starting task…`,failureHint:g.planFirst?`Could not create the plan. Your draft is kept. Please retry.`:void 0,clearOnSuccess:!g.planFirst,onPendingChange:e=>{y.current=e},value:g.text,onValueChange:e=>x({text:e}),autoFocus:!0,placeholder:`Describe a task for the agent — / for skills…`,ariaLabel:`Describe a task for the agent`,sendAriaLabel:g.planFirst?`Plan task`:`Start task`,disabled:!A||P,disabledReason:O.isPending?`Checking agent providers…`:O.isError?`Provider authentication could not be verified.`:`Connect an agent provider before starting a task.`,autocompleteSkills:!0,footerStart:(0,X.jsxs)(X.Fragment,{children:[T.length>1&&r!==void 0?(0,X.jsx)(ad,{projects:T,projectId:r,onPick:e=>t(`/p/${encodeURIComponent(e)}/new`,{replace:!0})}):null,(0,X.jsx)(xu,{label:`Template`,templates:oe,onInsert:e=>ie.current?.insertAtCaret(e)}),(0,X.jsx)(od,{source:D,ready:E,skills:w,skillUsage:ee,workflows:te,onPick:e=>x({source:e})})]}),agentOptions:(0,X.jsxs)(`div`,{"data-slot":`agent-options`,role:`group`,"aria-label":`Agent settings`,className:`new-task-agent-options`,children:[ue.length>1||ue.some(e=>Nr(N,e))?(0,X.jsx)(Di,{icon:(0,X.jsx)(En,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:ue,value:me,accounts:N,account:xe,repoAccount:be,onPick:(e,t)=>x({runner:e,agentProfile:t,...e===me?{}:{model:null}}),disabled:!A}):null,(0,X.jsx)(xi,{icon:(0,X.jsx)(vt,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`model-pill`,ariaLabel:`Model`,label:j.find(e=>e.id===_e)?.label??`auto`,value:_e,disabled:!A,readOnly:ge,disabledHint:ge?`Model selection is locked to native coding-agent settings.`:void 0,onPick:e=>{let t=wi(me,e,he.data);x({model:e,effort:g.effort===null?null:bi(g.effort,t)})},options:j.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:vi(me,he.data,he.isError,he.isFetching)}),(0,X.jsx)(xi,{icon:(0,X.jsx)(Ht,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`effort-pill`,ariaLabel:`Effort`,label:ve.find(e=>e.value===ye)?.label??`auto`,value:ye,disabled:!A,readOnly:ge,disabledHint:ge?`Effort selection is locked to native coding-agent settings.`:void 0,onPick:e=>x({effort:e}),options:ve.map(e=>({value:e.value,label:e.label,desc:e.desc}))})]}),executionOptions:(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,X.jsxs)(`details`,{"data-slot":`execution-options`,open:!0,className:`group rounded-xl border border-border bg-card xl:self-start`,children:[(0,X.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 hover:bg-muted/50 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-foreground [&::-webkit-details-marker]:hidden`,children:[(0,X.jsx)(re,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:`Execution settings`}),(0,X.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:[ji.find(e=>e.id===me)?.label??me,` · `,j.find(e=>e.id===_e)?.label??`auto`]})]}),(0,X.jsxs)(`div`,{className:`space-y-3 border-t border-border px-5 pt-3 pb-5`,children:[(0,X.jsx)(`p`,{className:`hidden text-[11px] text-muted-foreground xl:block`,children:`Control where and how this task runs.`}),(0,X.jsxs)(`div`,{role:`group`,"aria-label":`Run settings`,className:`new-task-run-settings`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{children:`Parallel variants`}),(0,X.jsx)(xi,{slot:`variants-pill`,ariaLabel:`Parallel variants`,label:we>1?`×${we} variants`:`×1`,value:String(we),onPick:e=>x({variants:Number(e)}),disabled:!Ce,hint:`How many times to run this task in parallel — each variant gets its own worktree, and you pick the diff you keep. ×1 runs it once.`,disabledHint:`Parallel variants need a git repository — each variant runs in its own worktree.`,options:[{value:`1`,label:`×1`,desc:`One run`},{value:`2`,label:`×2 variants`,desc:`Two competing runs — pick the diff you keep`},{value:`3`,label:`×3 variants`,desc:`Three competing runs — pick the diff you keep`}]})]}),Te?(0,X.jsx)(td,{on:Oe,disabled:Ee,disabledReason:`Parallel variants always use isolated worktrees`,onChange:e=>x({worktree:e})}):null,(0,X.jsx)(nd,{on:ke,disabled:g.planFirst,onChange:e=>x({autonomous:e})}),ne?.interactive&&(g.autonomous===null||g.worktree===null)?(0,X.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,d.data?(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{children:`Base branch`}),(0,X.jsx)(sd,{repo:d.data})]}):null]}),(0,X.jsxs)(`p`,{"data-slot":`execution-tip`,className:`hidden rounded-lg bg-background p-3 text-[11px] leading-5 text-muted-foreground xl:block`,children:[(0,X.jsx)(Rt,{"aria-hidden":`true`,className:`mb-2 size-[18px] text-accent-text`}),Oe&&Ce?`Changes stay in their own worktree, separate from your working directory.`:`Changes are made in the current working directory.`]})]})]}),Ae?(0,X.jsx)(`section`,{"data-slot":`followups-options`,"aria-label":`Follow-ups preference`,className:`rounded-xl border border-border bg-card p-4`,children:(0,X.jsx)(rd,{on:je,onChange:e=>x({generateFollowups:e})})}):null]}),footerEnd:(0,X.jsxs)(X.Fragment,{children:[!A&&!O.isPending?(0,X.jsx)(J,{to:`/settings/agents#providers`,className:`text-xs font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):null,(0,X.jsx)(cd,{planFirst:g.planFirst,planning:Fe,onModeChange:e=>x({planFirst:e})}),(0,X.jsx)(`kbd`,{"aria-hidden":`true`,className:`hidden rounded-[5px] border border-b-2 border-border bg-card px-[5px] py-px font-mono text-[10.5px] font-medium text-muted-foreground md:inline`,children:Sa()})]})}),(0,X.jsx)(`p`,{"data-slot":`run-mode-note`,className:`mt-2.5 text-[13px] text-muted-foreground`,children:Nu({worktree:Oe,hasGit:Ce})})]}),Ne===null?null:(0,X.jsx)(Qu,{plan:Ne,starting:P,startAvailable:A,startUnavailableReason:O.isPending?`Checking agent providers…`:O.isError?`Provider authentication could not be verified.`:`Connect an agent provider before starting a task.`,startUnavailableAction:O.isPending?void 0:(0,X.jsx)(J,{to:`/settings/agents#providers`,children:`Configure providers`}),onStepsChange:e=>Pe(t=>t&&{...t,steps:e}),onStart:()=>void Ge(),onDiscard:()=>{Pe(null),requestAnimationFrame(()=>ae.current?.querySelector(`textarea`)?.focus())}})]})}function td({on:e,disabled:t,disabledReason:n,onChange:r}){return(0,X.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,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`block text-[13px] font-medium`,children:`Worktree`}),(0,X.jsx)(`span`,{className:`block text-[10px] text-muted-foreground`,children:`Run in an isolated working copy`})]}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:U(`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,X.jsx)(`span`,{className:U(`size-[18px] rounded-full`,e?`ml-auto bg-accent-strong-foreground`:`bg-foreground`)})})]})}function nd({on:e,disabled:t,onChange:n}){return(0,X.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,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`block text-[13px] font-medium`,children:`Autonomous`}),(0,X.jsx)(`span`,{className:`block text-[10px] text-muted-foreground`,children:`Let the agent proceed without prompts`})]}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:U(`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,X.jsx)(`span`,{className:U(`size-[18px] rounded-full`,e?`ml-auto bg-accent-strong-foreground`:`bg-foreground`)})})]})}function rd({on:e,onChange:t}){return(0,X.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,"data-slot":`generate-followups-toggle`,onClick:()=>t(!e),title:e?`Agents can add newly discovered follow-up work to the task inbox`:`Follow-up generation is off; agents still maintain the handoff journal`,"aria-label":`Follow-ups`,className:`flex min-h-11 w-full items-center justify-between gap-4 text-left text-foreground`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`block text-[15px]`,children:`Follow-ups`}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-[1.5] text-muted-foreground`,children:`Generate suggestions in Inbox after this task. Enabled by default; your choice is remembered.`})]}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:U(`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,X.jsx)(`span`,{className:U(`size-[18px] rounded-full`,e?`ml-auto bg-accent-strong-foreground`:`bg-foreground`)})})]})}function id(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 ad({projects:e,projectId:t,onPick:n}){let[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(``),s=e.find(e=>e.id===t),c=id(e,a);return(0,X.jsxs)(Mr,{open:r,onOpenChange:e=>{i(e),e||o(``)},children:[(0,X.jsx)(jr,{asChild:!0,children:(0,X.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:U(Si,`border-foreground/60 font-semibold text-foreground`),children:[(0,X.jsx)(Pt,{"aria-hidden":`true`,className:`size-3 shrink-0 text-soft-foreground`}),(0,X.jsx)(`span`,{className:`max-w-40 truncate`,children:s?.name??t}),Pi]})}),(0,X.jsx)(Or,{align:`start`,sideOffset:8,className:`w-[300px] max-w-[calc(100vw-2rem)] p-0`,children:(0,X.jsxs)(li,{shouldFilter:!1,children:[(0,X.jsx)(oi,{placeholder:`search projects…`,value:a,onValueChange:o}),(0,X.jsxs)(fi,{"data-slot":`project-menu`,className:`max-h-[min(18rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[c.length===0?(0,X.jsx)(mi,{children:`Nothing matches.`}):null,c.map(e=>(0,X.jsxs)(K,{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,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium`,children:e.name}),e.status===`missing`?(0,X.jsx)(`span`,{className:`shrink-0 text-[11px] text-soft-foreground`,children:`folder not found`}):e.branch===void 0?null:(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-soft-foreground`,children:e.branch}),e.id===t?(0,X.jsx)(at,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},e.id))]}),(0,X.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 od({source:e,ready:t,skills:n,skillUsage:r,workflows:i,onPick:o}){let[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(null),p=(0,Y.useRef)(null),{mostUsed:m,project:h,global:g,ranked:_}=aa(n,l,r),v=i.find(e=>e.name===Ci),y=$i(i,l).filter(e=>e.name!==Ci),b=i.some(e=>e.name!==Ci),x=Qi(`no skill`,`none plain ${Ci} ${v?.description??``}`,l)>0,S=!x&&(_?_.length===0:m.length===0&&h.length===0&&g.length===0)&&y.length===0,C=e=>{o(e),c(!1)},ee=t=>C(e?.source===t.source&&e.ref===t.ref?null:t),w=(t,n)=>{let r=e?.source===`skill`&&e.ref===t.name;return(0,X.jsxs)(K,{value:`skill ${t.name} ${t.path}`,keywords:ea(t.name,t.description),"data-slot":`source-option`,"data-source-kind":`skill`,"data-source-ref":t.name,onSelect:()=>ee({source:`skill`,ref:t.name}),children:[(0,X.jsx)(`span`,{className:U(`shrink-0 font-mono text-xs`,n&&`font-semibold`),children:t.name}),t.description?(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:t.description}):null,(0,X.jsx)(`button`,{type:`button`,"data-slot":`source-skill-view`,"aria-label":`View skill ${t.name}`,title:`View skill`,onClick:e=>{e.preventDefault(),e.stopPropagation(),f(t)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,X.jsx)(di,{"aria-hidden":`true`,className:`size-3.5`})}),r?(0,X.jsx)(at,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},t.path)},te=e===null||e.source===`skill`?Ge:a,T=(0,X.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(),o(null))},className:U(Si,`font-mono text-[11.5px]`,e===null?`text-muted-foreground`:`rounded-r-none border-r-0 border-foreground/60 pr-1.5 font-semibold text-foreground`),children:[(0,X.jsx)(te,{"aria-hidden":`true`,className:U(`size-3 shrink-0`,e===null?`text-muted-foreground`:`text-accent-icon`)}),(0,X.jsx)(`span`,{className:`max-w-44 truncate`,children:t?e?.ref??(b?`Skill or workflow`:`Skill`):`…`}),Pi]});return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ou,{skill:d,onClose:()=>f(null)}),(0,X.jsxs)(Mr,{open:s,onOpenChange:e=>{c(e),e||u(``)},children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center`,children:[(0,X.jsx)(jr,{asChild:!0,children:T}),e!==null&&t?(0,X.jsx)(`button`,{type:`button`,"data-slot":`source-pill-clear`,"aria-label":`Clear the ${e.source} ${e.ref}`,title:`Run without it`,onClick:()=>o(null),className:U(Si,`rounded-l-none border-foreground/60 pl-1.5 pr-2 text-soft-foreground hover:text-foreground`),children:(0,X.jsx)(In,{"aria-hidden":`true`,className:`size-3`})}):null]}),(0,X.jsx)(Or,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,X.jsxs)(li,{shouldFilter:!1,children:[(0,X.jsx)(oi,{placeholder:`search skills & workflows…`,value:l,onValueChange:u,onInput:()=>p.current?.scrollTo(0,0)}),(0,X.jsxs)(fi,{ref:p,"data-slot":`source-menu`,className:`max-h-[min(18rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[S?(0,X.jsx)(mi,{children:`Nothing matches.`}):null,x?(0,X.jsx)(q,{children:(0,X.jsxs)(K,{value:`none no-skill`,keywords:[`none`,`plain`,...ea(Ci)],"data-slot":`source-option`,"data-source-kind":`none`,onSelect:()=>C(null),children:[(0,X.jsx)(Ln,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-soft-foreground`}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs font-medium`,children:`No skill`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:v?.description??`One agent run on your task — no ceremony.`}),e===null?(0,X.jsx)(at,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]})}):null,_?_.length>0?(0,X.jsx)(q,{children:_.map(e=>w(e,ta(e)))}):null:(0,X.jsxs)(X.Fragment,{children:[m.length>0?(0,X.jsx)(q,{heading:`Most used`,children:m.map(e=>w(e,ta(e)))}):null,h.length>0?(0,X.jsx)(q,{heading:`Project skills`,children:h.map(e=>w(e,!0))}):null]}),y.length>0?(0,X.jsx)(q,{heading:`Workflows`,children:y.map(t=>{let n=e?.source===`workflow`&&e.ref===t.name;return(0,X.jsxs)(K,{value:`workflow ${t.name}`,keywords:ea(t.name,t.description),"data-slot":`source-option`,"data-source-kind":`workflow`,"data-source-ref":t.name,onSelect:()=>ee({source:`workflow`,ref:t.name}),children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:t.name}),t.description?(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:t.description}):null,n?(0,X.jsx)(at,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},t.name)})}):null,g.length>0?(0,X.jsx)(q,{heading:`Global`,children:g.map(e=>w(e,!1))}):null]})]})})]})]})}function sd({repo:e}){let t=o(),n=F({mutationFn:e=>k({baseBranch:e}),onSuccess:e=>{t.invalidateQueries({queryKey:L.repo}),B(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=>B(e.message,{tone:`danger`})});return e.info?(0,X.jsx)(xi,{slot:`base-pill`,ariaLabel:`Base branch`,label:(0,X.jsx)(`span`,{className:`text-[11.5px]`,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 cd({planFirst:e,planning:t,onModeChange:n}){return(0,X.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,X.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":!e,onClick:()=>n(!1),className:U(`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,X.jsx)(at,{"aria-hidden":`true`,className:`size-3.5`}),`Start`]}),(0,X.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e,"aria-busy":t||void 0,"data-slot":`mode-plan`,onClick:()=>n(!0),className:U(`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 ld(){return(0,X.jsx)(`div`,{"data-route":`not-found`,className:`flex min-h-full flex-col`,children:(0,X.jsx)(R,{icon:(0,X.jsx)(Ys,{}),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,X.jsx)(I,{asChild:!0,variant:`outline`,children:(0,X.jsx)(J,{to:`/`,children:`Back to tasks`})})})})}function ud(){return(0,X.jsx)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:(0,X.jsx)(R,{icon:(0,X.jsx)(qi,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading repository…`,subtitle:`Fetching the repo's git state.`})})}function dd(){return(0,X.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,X.jsx)(`h1`,{className:`text-[30px] font-semibold tracking-tight`,children:`Skills`}),(0,X.jsx)(`p`,{className:`mt-1 text-[13px] text-muted-foreground`,children:`Markdown playbooks your agents can follow.`}),(0,X.jsx)(`p`,{"data-slot":`skills-loading`,role:`status`,className:`mt-6 text-xs text-muted-foreground`,children:`Loading skills…`}),(0,X.jsxs)(`div`,{"aria-hidden":`true`,className:`mt-4 flex flex-col gap-[22px] motion-safe:animate-pulse`,children:[(0,X.jsx)(`div`,{className:`h-11 rounded-lg border border-border bg-card`}),(0,X.jsx)(`div`,{className:`h-80 rounded-xl border border-border bg-card`})]})]})}function fd({projectId:e,registry:t}){let n=t.projects.length?t.projects:[{id:t.bootProject,name:t.bootProject}];return(0,X.jsx)(`div`,{"data-route":`unknown-project`,className:`flex min-h-full flex-col`,children:(0,X.jsx)(R,{icon:(0,X.jsx)(nc,{}),tone:`neutral`,title:`“${e}” isn’t registered here`,subtitle:`This cezar doesn’t serve a project by that id. The link may come from another machine’s workspace — these are the projects registered on this one:`,children:(0,X.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,X.jsx)(`li`,{children:(0,X.jsxs)(z,{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,X.jsxs)(`span`,{className:`font-mono text-[11px] font-normal text-soft-foreground`,children:[`/p/`,e.id]})]})},e.id))})})})}function pd(){return(0,X.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,X.jsx)(`h1`,{className:`text-[30px] font-semibold tracking-tight`,children:`Workflows`}),(0,X.jsx)(`p`,{className:`mt-1 text-[13px] text-muted-foreground`,children:`Portable skill chains. Steps run from top to bottom.`}),(0,X.jsx)(`p`,{"data-slot":`workflows-loading`,role:`status`,className:`mt-6 text-xs text-muted-foreground`,children:`Loading workflows…`}),(0,X.jsxs)(`div`,{"aria-hidden":`true`,className:`mt-4 flex flex-col gap-[22px] motion-safe:animate-pulse`,children:[(0,X.jsx)(`div`,{className:`h-11 rounded-lg border border-border bg-card`}),(0,X.jsx)(`div`,{className:`h-80 rounded-xl border border-border bg-card`})]})]})}function md({tab:e}){return(0,X.jsx)(`div`,{"data-route":`task-${e}`,className:`flex min-h-full flex-col`,children:(0,X.jsx)(R,{icon:(0,X.jsx)(qi,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:e===`changes`?`Loading changes…`:`Loading files…`,subtitle:`Fetching the run record.`})})}function hd({tab:e,error:t}){let n=t instanceof fn&&t.status===404;return(0,X.jsx)(`div`,{"data-route":`task-${e}`,className:`flex min-h-full flex-col`,children:(0,X.jsx)(R,{icon:n?(0,X.jsx)(Ji,{}):(0,X.jsx)(st,{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,X.jsx)(I,{asChild:!0,variant:`outline`,children:(0,X.jsx)(J,{to:`/`,children:`Back to tasks`})})})})}function gd({className:e,orientation:t=`horizontal`,...n}){return(0,X.jsx)(Yo,{"data-slot":`tabs`,"data-orientation":t,orientation:t,className:U(`group/tabs flex gap-2 data-[orientation=horizontal]:flex-col`,e),...n})}var _d=l(`group/tabs-list inline-flex w-fit items-center justify-center rounded-md p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function vd({className:e,variant:t=`default`,...n}){return(0,X.jsx)(Xo,{"data-slot":`tabs-list`,"data-variant":t,className:U(_d({variant:t}),e),...n})}function yd({className:e,...t}){return(0,X.jsx)(Zo,{"data-slot":`tabs-trigger`,className:U(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-sm border border-transparent px-3 py-1 text-[12.5px] font-medium whitespace-nowrap text-muted-foreground transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-xs group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent`,`data-[state=active]:bg-card data-[state=active]:font-semibold data-[state=active]:text-foreground`,`after:absolute after:bg-accent-strong after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100`,e),...t})}function bd({className:e,...t}){return(0,X.jsx)(Qo,{"data-slot":`tabs-content`,className:U(`flex-1 outline-none`,e),...t})}function xd(e){return ji.flatMap(t=>{let n=e.filter(e=>e.provider===t.id);return n.length<2?[{runner:t,account:null,label:t.label,desc:t.desc,missing:!1}]:n.map(e=>({runner:t,account:e.isDefault?null:e.id,label:`${t.label} · ${e.label}`,desc:e.exists?e.configDir:`${e.configDir} — folder not created yet`,missing:!e.exists}))})}var Sd=e=>e.length>ji.length;function Cd({rows:e,runner:t,accountFor:n,providerStatus:r,disabled:i=!1,accountDisabled:a=!1,onPick:o}){let s=Sd(e);return(0,X.jsx)(`div`,{role:`radiogroup`,"aria-label":`Default runner`,"data-slot":`agents-runner`,className:U(`gap-0.5 rounded-md border border-border bg-card p-0.5`,s?`flex max-w-md flex-col`:`inline-flex w-fit`),children:e.map(c=>{let l=Tt(r.data,c.runner.id),u=!r.isPending&&!r.isError&&l?.enabled===!0&&l.status===`connected`,d=r.isPending?`Checking provider authentication…`:r.isError?`Provider authentication could not be verified.`:l?.enabled===!1?`This provider is disabled. Enable it above or choose another provider.`:u?void 0:`Connect this provider before selecting it.`,f=e.filter(e=>e.runner.id===c.runner.id).length>1,p=c.runner.id===t&&c.account===n(c.runner.id);return(0,X.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":p,"data-value":c.runner.id,"data-account":c.account??``,title:d??c.desc,disabled:i||!u||f&&a,onClick:()=>o(c.runner.id,c.account,f),className:U(`rounded-sm px-3 py-1.5 text-left font-mono text-[13px] font-medium transition-colors disabled:opacity-50`,p?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:[c.label,s?(0,X.jsx)(`span`,{"data-slot":c.missing?`agents-account-missing`:`agents-account-dir`,"data-runner":c.runner.id,className:`ml-2 font-sans text-[11.5px] text-soft-foreground`,children:c.desc}):null]},`${c.runner.id}:${c.account??``}`)})})}function wd({open:e,onOpenChange:t,providers:n,initialProvider:r}){let[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(r??n[0]??`claude`),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(!1),g=Bt(),_=f.trim();return(0,X.jsx)(Ir,{open:e,onOpenChange:t,children:(0,X.jsxs)(Rr,{"data-slot":`add-account-dialog`,className:`sm:max-w-lg`,children:[(0,X.jsxs)(Lr,{children:[(0,X.jsx)(zr,{children:`Add agent account`}),(0,X.jsx)(Fr,{children:`The config folder this account uses. It does not have to exist yet — Connect signs in and the CLI creates it.`})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`label`,{className:`flex items-center gap-2 text-[13px]`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`Agent`}),(0,X.jsx)(`select`,{"aria-label":`Agent`,"data-slot":`add-account-provider`,value:c,onChange:e=>l(e.target.value),className:`rounded-md border border-input bg-card px-2 py-1 text-[13px] outline-none focus-visible:border-ring`,children:n.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))})]}),(0,X.jsxs)(`label`,{className:`flex min-w-0 flex-1 items-center gap-2 text-[13px]`,children:[(0,X.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Name`}),(0,X.jsx)(`input`,{type:`text`,"aria-label":`Account name`,"data-slot":`add-account-label`,value:u,placeholder:`Work`,onChange:e=>d(e.target.value),className:`min-w-0 flex-1 rounded-md border border-input bg-card px-2 py-1 text-[13px] outline-none focus-visible:border-ring`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 text-[13px]`,children:[(0,X.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Folder`}),(0,X.jsx)(`input`,{type:`text`,spellCheck:!1,autoComplete:`off`,"aria-label":`Config folder`,"data-slot":`add-account-dir`,value:f,placeholder:c===`codex`?`~/.codex-second`:`~/.claude-second`,onChange:e=>{p(e.target.value),s(null),g.reset()},className:`min-w-0 flex-1 rounded-md border border-input bg-card px-2 py-1 font-mono text-[12.5px] outline-none focus-visible:border-ring`}),(0,X.jsx)(I,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`add-account-browse`,"aria-expanded":m,onClick:()=>h(e=>!e),children:m?`Hide folders`:`Browse…`})]}),(0,X.jsxs)(`p`,{className:`text-[11.5px] text-soft-foreground`,children:[`A `,(0,X.jsx)(`code`,{children:`~`}),` is kept as written and expanded when the agent runs.`]})]}),m?(0,X.jsx)(mc,{path:i,selected:o,onSelect:e=>{s(e),p(e.path),g.reset()},onEnter:e=>{a(e),s(null),g.reset()},showHidden:!0,emptyHint:`No subfolders here — pick this folder by typing its path above.`}):null,g.isError?(0,X.jsx)(`p`,{"data-slot":`add-account-error`,className:`min-w-0 break-words text-[13px] text-danger`,children:g.error instanceof Error?g.error.message:`could not add that folder`}):null,(0,X.jsxs)(Pr,{className:`min-w-0 sm:items-center sm:justify-end`,children:[(0,X.jsx)(I,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,X.jsx)(I,{"data-slot":`add-account-confirm`,disabled:_===``||g.isPending,onClick:()=>{_===``||g.isPending||g.mutate({provider:c,configDir:_,...u.trim()?{label:u.trim()}:{}},{onSuccess:()=>{t(!1),d(``),p(``),s(null),h(!1),B(`Account added — use Connect to sign in`)}})},children:g.isPending?`Adding…`:`Add account`})]})]})})}function Td(e){let t=(0,Y.useRef)(null),n=e.rows.find(t=>t.runner.id===e.runner&&t.account===e.accountFor(t.runner.id));return(0,X.jsxs)(`details`,{ref:t,className:`settings-agent-picker`,children:[(0,X.jsxs)(`summary`,{children:[(0,X.jsx)(En,{"aria-hidden":`true`,className:`size-4 text-accent-text`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1`,children:(n?.label??e.runner).replace(/^codex/,`Codex`).replace(/^claude/,`Claude Code`)}),(0,X.jsx)(nt,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`})]}),(0,X.jsx)(Cd,{...e,onPick:(...n)=>{e.onPick(...n),t.current&&(t.current.open=!1)}})]})}var Ed={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,pi:`pi`,cursor:`Cursor`},Dd={claude:`npm i -g @anthropic-ai/claude-code`,codex:`npm i -g @openai/codex`,opencode:`https://opencode.ai`,pi:`https://github.com/badlogic/pi-mono`,cursor:`https://cursor.com/docs/cli/installation`},Od={connected:{label:`Connected`,tone:`success`},disconnected:{label:`Not connected`,tone:`pending`},"not-installed":{label:`Not installed`,tone:`neutral`},unknown:{label:`Could not verify`,tone:`danger`}};function kd(){let e=Bn();return e.isPending?(0,X.jsx)(`p`,{"data-slot":`accounts-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent accounts…`}):e.isError?(0,X.jsx)(R,{icon:(0,X.jsx)(rc,{}),tone:`danger`,title:`Agent accounts did not load`,subtitle:e.error.message,heading:`h2`}):(0,X.jsx)(Ad,{data:e.data})}function Ad({data:e}){let t=H(),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(null),o=E(),s=[`claude`,`codex`,`opencode`,`pi`,`cursor`];return e.editable?(0,X.jsxs)(`div`,{"data-slot":`accounts-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-5 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,X.jsx)(`div`,{children:(0,X.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Manage runner installations, logins and defaults for new projects.`})}),(0,X.jsxs)(gd,{defaultValue:`claude`,children:[(0,X.jsx)(vd,{variant:`line`,"data-slot":`accounts-tabs`,children:s.map(e=>(0,X.jsx)(yd,{value:e,"data-provider":e,children:Ed[e]},e))}),s.map(n=>(0,X.jsx)(bd,{value:n,className:`pt-4`,children:(0,X.jsx)(jd,{provider:n,check:t.data?.checks?.find(e=>e.name===n),accounts:e.profiles.filter(e=>e.provider===n),canCarryAccounts:e.profileCapableProviders.includes(n),defaultAccountId:e.defaults[n]??null,onAdd:()=>r(n),onRemove:a})},n))]}),(0,X.jsx)(Md,{profiles:e}),n===null?null:(0,X.jsx)(wd,{open:!0,onOpenChange:e=>!e&&r(null),providers:e.profileCapableProviders,initialProvider:n},n),(0,X.jsx)(Nn,{open:i!==null,onOpenChange:e=>!e&&a(null),children:(0,X.jsxs)(Ut,{"data-slot":`accounts-remove-confirm`,children:[(0,X.jsxs)(An,{children:[(0,X.jsxs)(xt,{children:[`Remove “`,i?.label,`”?`]}),(0,X.jsxs)(mt,{children:[`This only forgets the account. Nothing in `,i?.configDir,` is deleted — not your login, not your sessions. Projects using it fall back to the default account, and tasks that ran under it can no longer be resumed from here.`]})]}),(0,X.jsxs)(mn,{children:[(0,X.jsx)(Dn,{children:`Cancel`}),(0,X.jsx)(un,{"data-action":`accounts-remove-confirm`,disabled:o.isPending,onClick:()=>{let e=i;e&&o.mutate(e.id,{onSuccess:()=>{a(null),B(`Removed ${e.label}`)},onError:e=>B(e.message,{tone:`danger`})})},children:`Remove`})]})]})})]}):(0,X.jsx)(`div`,{"data-slot":`accounts-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-4 p-4 md:p-6`,children:(0,X.jsx)(`p`,{"data-slot":`accounts-hosted`,className:`text-[13px] text-soft-foreground`,children:`Agent accounts are managed from the machine that owns the checkout — this cockpit runs in hosted mode.`})})}function jd({provider:e,check:t,accounts:n,canCarryAccounts:r,defaultAccountId:i,onAdd:a,onRemove:o}){let s=t?.available===!0,c=n.filter(e=>e.isDefault).length;return(0,X.jsxs)(`div`,{"data-slot":`accounts-provider`,"data-provider":e,className:`flex flex-col gap-4`,children:[(0,X.jsx)(`h3`,{className:`settings-account-provider-title`,children:Ed[e]}),(0,X.jsxs)(`div`,{className:`settings-account-installation settings-readout`,children:[t===void 0?(0,X.jsx)(`span`,{children:`Checking…`}):s?(0,X.jsx)(`span`,{"data-slot":`agent-installed`,children:`Installed`}):(0,X.jsxs)(`span`,{"data-slot":`agent-installed`,children:[`Not installed — `,(0,X.jsx)(`code`,{children:Dd[e]})]}),s&&t?.version?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,children:` · `}),(0,X.jsx)(`span`,{"data-slot":`agent-version`,children:t.version})]}):null,(0,X.jsxs)(`span`,{className:`settings-account-count`,children:[n.length,` `,n.length===1?`account`:`accounts`,` (`,c,` discovered, `,n.length-c,` added)`]})]}),(0,X.jsx)(`ul`,{className:`bg-card`,children:[...n].sort((e,t)=>Number(t.id===i)-Number(e.id===i)).map(e=>(0,X.jsx)(Nd,{account:e,isMachineDefault:i===e.id||i===null&&e.isDefault,onRemove:()=>o(e)},e.id))}),r?(0,X.jsx)(`div`,{className:`settings-account-add-row`,children:(0,X.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,"data-action":`accounts-add`,"data-provider":e,onClick:a,children:`Add account`})}):null,r?null:(0,X.jsxs)(`p`,{"data-slot":`accounts-single-only`,className:`text-[11.5px] text-soft-foreground`,children:[Ed[e],` can only hold one account here: it keeps its credentials outside its config folder, so a second folder would change settings without changing the login — which would say “work account” while billing the other one.`]})]})}function Md({profiles:e}){let[t,n]=(0,Y.useState)(null),r=o(),i=Zn(),a=Me(),s=_n(),c=Vn(),l=F({mutationFn:e=>ue(e),onSuccess:e=>r.setQueryData(P.config,e),onError:e=>B(e.message,{tone:`danger`})});if(i.data===void 0)return null;let u=xd(e.profiles),d=i.data.agentDefaults.runner??`claude`,f=i.data.agentDefaults.models??{};return(0,X.jsxs)(`section`,{"data-slot":`accounts-defaults`,className:`flex flex-col gap-3 rounded-lg border border-border bg-card/40 p-3.5`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-[13px] font-semibold text-foreground`,children:`Defaults for new projects`}),(0,X.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`What a project runs when it has not chosen for itself — set once instead of per repository. A project that has chosen keeps its own.`})]}),(0,X.jsx)(Td,{rows:u,runner:d,accountFor:t=>e.defaults[t]??null,providerStatus:a,disabled:l.isPending,accountDisabled:c.isPending,onPick:(e,t,n)=>{e!==d&&l.mutate({agentDefaults:{runner:e}}),n&&c.mutate({projectId:null,provider:e,profileId:t},{onError:e=>B(e.message,{tone:`danger`})})}}),(0,X.jsxs)(`div`,{className:`settings-account-models flex flex-col gap-2`,children:[(0,X.jsxs)(`label`,{className:`settings-model-agent-choice`,children:[(0,X.jsx)(`span`,{children:`Default model for`}),(0,X.jsx)(`select`,{"aria-label":`Model agent`,value:t??d,onChange:e=>n(e.target.value),children:ji.map(e=>(0,X.jsx)(`option`,{value:e.id,children:Ed[e.id]},e.id))})]}),ji.filter(e=>e.id===(t??d)).map(e=>(0,X.jsxs)(`label`,{className:`settings-account-model flex items-center gap-3`,children:[(0,X.jsx)(vt,{className:`size-4 text-accent-icon shrink-0`}),(0,X.jsx)(`span`,{className:`w-24 shrink-0 text-xs text-muted-foreground`,children:Ed[e.id]}),(0,X.jsxs)(`select`,{"aria-label":`Default model for ${e.label}`,"data-slot":`accounts-default-model`,"data-runner":e.id,value:f[e.id]??``,disabled:l.isPending,onChange:t=>l.mutate({agentDefaults:{models:{[e.id]:t.target.value||null}}}),className:`block w-full max-w-xs rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[Fi(e.id,s[e.id].data,[f[e.id]]).map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.id===``?`Native default`:e.label},e.id)),vi(e.id,s[e.id].data,s[e.id].isError,s[e.id].isFetching)?(0,X.jsx)(`option`,{disabled:!0,children:vi(e.id,s[e.id].data,s[e.id].isError,s[e.id].isFetching)}):null]})]},e.id))]})]})}function Nd({account:e,isMachineDefault:t,onRemove:n}){let[r,i]=(0,Y.useState)(!1),a=ir(e),o=yn(),s=d(),c=jn(a,e.status===void 0),l=e.status??c.data?.status,u=l?Od[l.status]:void 0;return(0,X.jsxs)(`li`,{"data-slot":`account-row`,"data-account":e.id,className:`flex flex-col gap-2 px-3.5 py-3`,children:[(0,X.jsxs)(`div`,{className:`settings-account-card`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-[13px] font-medium text-foreground`,children:e.label}),e.isDefault?(0,X.jsx)(Bs,{variant:`ghost`,className:`shrink-0 text-[10px] text-muted-foreground`,children:`discovered`}):null]}),t&&(0,X.jsx)(`p`,{className:`settings-account-default-note`,children:`Default account for new projects. Credentials are not displayed.`}),(0,X.jsxs)(`div`,{className:`settings-account-readout settings-readout`,children:[(0,X.jsx)(`p`,{"data-slot":`account-path`,className:`mt-0.5 truncate font-mono text-[11.5px] text-soft-foreground`,title:e.path,children:e.configDir}),(0,X.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(G,{tone:u?.tone??`neutral`,pulse:u===void 0}),(0,X.jsx)(`span`,{"data-slot":`account-status`,children:u?.label??`Checking…`}),e.exists?e.looksValid?null:(0,X.jsxs)(`span`,{"data-slot":`account-unrecognised`,children:[`— this folder does not look like `,Ed[e.provider],` config yet`]}):(0,X.jsx)(`span`,{"data-slot":`account-missing`,children:`— folder not created yet; Connect will make it`})]})]})]}),(0,X.jsxs)(`div`,{className:`settings-account-actions`,children:[l?.status===`connected`?null:(0,X.jsx)(I,{type:`button`,size:`sm`,"data-action":`account-connect`,disabled:o.isPending,onClick:()=>o.mutate({provider:e.provider,...e.isDefault?{}:{profileId:e.id}},{onSuccess:e=>B(e.opened?`Finish signing in in the terminal, then Check again.`:`This account is already connected.`),onError:e=>B(e instanceof fn&&e.command?`${e.message} — run: ${e.command}`:e.message,{tone:`danger`})}),children:`Connect`}),(0,X.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-recheck`,disabled:s.isPending,title:`Re-probe this account's login now, instead of waiting for the cached answer`,onClick:()=>s.mutate(a,{onError:e=>B(e.message,{tone:`danger`})}),children:`Check again`}),(0,X.jsx)(Fd,{account:e,onRemove:n}),(0,X.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-details-toggle`,"aria-expanded":r,onClick:()=>i(e=>!e),children:r?`Hide details`:`Show details`})]})]}),r?(0,X.jsx)(Pd,{account:e,routeId:a}):null]})}function Pd({account:e,routeId:t}){let n=gn(t,!0),r=s(),i=Yt().data?.targets??[],a=i.filter(e=>ri(e.id)===void 0&&e.id!==`terminal`&&e.id!==`finder`).map(e=>({target:e})),o=i.filter(e=>ri(e.id)===void 0).map(e=>({target:e})),c=(e,n,i)=>r.mutate({routeId:t,file:e,...i?{target:i}:{}},{onError:e=>B(e.message,{tone:`danger`}),onSuccess:()=>B(`Opened ${n}`)});return(0,X.jsxs)(`div`,{"data-slot":`account-details`,className:`rounded-md border border-border/60 bg-muted/30 p-3`,children:[n.isPending?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Reading account details…`}):n.isError?(0,X.jsx)(`p`,{"data-slot":`account-details-error`,className:`text-xs text-danger`,children:n.error.message}):n.data.available?(0,X.jsx)(`dl`,{"data-slot":`account-identity`,className:`grid grid-cols-[7rem_minmax(0,1fr)] gap-x-3 gap-y-1 text-xs`,children:n.data.fields.map(e=>(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,X.jsx)(`dd`,{className:`min-w-0 truncate text-foreground`,title:e.value,children:e.value})]},e.label))}):(0,X.jsx)(`p`,{"data-slot":`account-identity-unavailable`,className:`text-xs text-muted-foreground`,children:n.data.reason??`No account details to show.`}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5 border-t border-border/60 pt-2.5`,children:[(0,X.jsx)(`span`,{className:`mr-1 text-xs text-muted-foreground`,children:`Config files`}),e.files.map(e=>(0,X.jsx)(ti,{slot:`account-open-file`,label:e.label,triggerVariant:`outline`,disabled:r.isPending,title:e.exists?e.path:`${e.path} — not created yet`,choices:a,onPick:t=>c(e.id,e.label,t),leading:(0,X.jsxs)(yr,{"data-target":`system`,onSelect:()=>c(e.id,e.label),children:[(0,X.jsx)(ai,{"aria-hidden":`true`}),`System default`]})},e.id)),(0,X.jsx)(ti,{slot:`account-open-folder`,label:`Folder`,disabled:r.isPending,title:e.path,choices:o,onPick:e=>c(`folder`,`folder`,e),leading:(0,X.jsxs)(yr,{"data-target":`system`,onSelect:()=>c(`folder`,`folder`),children:[(0,X.jsx)(ai,{"aria-hidden":`true`}),`System default`]})})]})]})}function Fd({account:e,onRemove:t}){let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(e.label),o=Lt();return(0,X.jsx)(X.Fragment,{children:e.isDefault?null:(0,X.jsx)(`div`,{"data-slot":`account-manage`,className:`settings-account-management`,children:n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`input`,{type:`text`,autoFocus:!0,"aria-label":`Name for ${e.label}`,"data-slot":`account-rename-input`,value:i,onChange:e=>a(e.target.value),className:`w-48 rounded-md border border-input bg-card px-2 py-1 text-xs outline-none focus-visible:border-ring`}),(0,X.jsx)(I,{type:`button`,size:`sm`,"data-action":`account-rename-save`,disabled:o.isPending||i.trim()===``||i.trim()===e.label,onClick:()=>o.mutate({id:e.id,label:i.trim()},{onSuccess:()=>r(!1),onError:e=>B(e.message,{tone:`danger`})}),children:`Save`}),(0,X.jsx)(I,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{a(e.label),r(!1)},children:`Cancel`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-rename`,onClick:()=>r(!0),children:`Rename`}),(0,X.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-remove`,onClick:t,children:`Remove account`}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Renaming changes what cezar calls this account, not its folder.`})]})})})}var Id=1500;function Ld(e,t){let n=(0,Y.useMemo)(()=>e.split(`
4
4
  `).map(e=>[{content:e}]),[e]),r=(0,Y.useMemo)(()=>wa(t),[t]),i=n.length>Id,[a,o]=(0,Y.useState)(null);return(0,Y.useEffect)(()=>{if(r===null||i)return;let t=!1;return Ta(e,r).then(n=>{t||o({key:e,tokens:n.tokens})}),()=>{t=!0}},[e,r,i]),r===null||i?n:a?.key===e?a.tokens:Ca(e,r)?.tokens??n}var Rd=`m-0 min-h-full w-full whitespace-pre font-mono text-xs leading-[1.7] px-3 py-2 [tab-size:2]`;function zd({value:e,onChange:t,language:n,readOnly:r,className:i,...a}){let o=Ld(e,n),s=(0,Y.useRef)(null),c=(0,Y.useRef)(null),l=()=>{let e=c.current,t=s.current;!e||!t||(t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft)};return(0,Y.useLayoutEffect)(l,[e]),(0,X.jsxs)(`div`,{"data-slot":`code-editor`,className:U(`relative overflow-hidden rounded-md border border-input bg-card`,i),children:[(0,X.jsx)(`pre`,{ref:s,"aria-hidden":`true`,className:U(Rd,`pointer-events-none absolute inset-0 overflow-auto text-soft-foreground`),children:o.map((e,t)=>(0,X.jsx)(`span`,{className:`block`,children:e.length===0?`
5
5
  `:(0,X.jsxs)(X.Fragment,{children:[e.map((e,t)=>(0,X.jsx)(`span`,{style:e.color===void 0?void 0:{color:e.color},children:e.content},t)),`
6
6
  `]})},t))}),(0,X.jsx)(`textarea`,{ref:c,"data-slot":`code-editor-input`,value:e,readOnly:r,onChange:e=>t?.(e.target.value),onScroll:l,spellCheck:!1,autoCorrect:`off`,autoCapitalize:`off`,autoComplete:`off`,wrap:`off`,className:U(Rd,`relative block resize-none overflow-auto bg-transparent text-transparent caret-foreground outline-none`,`selection:bg-accent-strong/30 focus-visible:ring-0`,r&&`cursor-default`),...a})]})}var Bd=`An editor-plus-commit: a saved change reaches a run after you commit it to the base branch.`;function Vd(e){return t=>t.runners.includes(e)}function Z(e,t,n,r,i){let a=Vd(e),o=t===`mcp`?e=>a(e)&&(e.holdsMcp===!0||e.kind===`mcp`):e=>a(e)&&e.kind===t;return{id:t,label:n,note:r,...i?{empty:i}:{},files:o}}var Hd=[{id:`claude`,label:`Claude`,groups:[Z(`claude`,`settings`,`Settings`),Z(`claude`,`mcp`,`MCP`,`A dedicated .mcp.json (key: mcpServers), shared via version control.`),Z(`claude`,`memory`,`Memory & instructions`)]},{id:`codex`,label:`Codex`,note:Bd,groups:[Z(`codex`,`settings`,`Settings`),Z(`codex`,`mcp`,`MCP`,`Inside config.toml under [mcp_servers.<id>] — the same file as Codex’s settings.`),Z(`codex`,`memory`,`Memory & instructions`)]},{id:`opencode`,label:`OpenCode`,note:Bd,groups:[Z(`opencode`,`settings`,`Settings`),Z(`opencode`,`mcp`,`MCP`,`Under the "mcp" key in opencode.json — the same file as OpenCode’s settings.`),Z(`opencode`,`memory`,`Memory & instructions`)]},{id:`pi`,label:`Pi`,note:Bd,groups:[Z(`pi`,`settings`,`Settings`),Z(`pi`,`mcp`,`MCP`,`Pi ships no MCP client, so it has no MCP file to edit.`,`Nothing to list: Pi’s README says "No MCP." Give Pi tools as CLI programs with a README (Pi skills), or install a Pi extension that adds MCP support and configure servers there.`),Z(`pi`,`memory`,`Memory & instructions`)]},{id:`cursor`,label:`Cursor`,note:Bd,groups:[Z(`cursor`,`settings`,`Settings`),Z(`cursor`,`mcp`,`MCP`,`Cursor CLI uses the editor’s MCP configuration.`),Z(`cursor`,`memory`,`Memory & instructions`,`Cursor also reads CLAUDE.md and .cursor/rules.`)]}];function Ud(e){let t=Hd.find(t=>t.id===e);if(!t)throw Error(`no agent descriptor for ${e}`);return t}function Wd(e){return e.seeded?`Copied into each run’s worktree — takes effect on your next run.`:e.tracked===`tracked`?`Runs read the committed copy — this edit applies after you commit it.`:e.tracked===`outside-repo`?`Applies to every session on this machine.`:`Personal, git-ignored.`}function Gd(){let e=Ct(),t=H(),n=(0,Y.useMemo)(()=>t.data?Oi(t.data.checks):Hd.map(e=>e.id),[t.data]);return e.isPending?(0,X.jsx)(`p`,{"data-slot":`agent-config-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent config…`}):e.isError?(0,X.jsx)(R,{icon:(0,X.jsx)(ec,{}),tone:`danger`,title:`Agent config did not load`,subtitle:e.error.message,heading:`h2`}):(0,X.jsx)(Kd,{listing:e.data,installed:n})}function Kd({listing:e,installed:t}){let[n,r]=(0,Y.useState)(`claude`),[i,a]=(0,Y.useState)(null),o=Ud(n),s=e.files.find(e=>e.id===i)??null,c=e=>{r(e),a(null)};return(0,X.jsxs)(`div`,{"data-slot":`agent-config`,className:`flex flex-col gap-5 p-4 md:p-6`,children:[(0,X.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Edit agent instructions and MCP configuration for this project.`}),!e.editable&&(0,X.jsx)(`div`,{"data-slot":`agent-config-readonly`,className:`rounded-md border border-border bg-muted/40 px-3 py-2 text-[13px] text-soft-foreground`,children:`Read-only: agent config is edited from the machine that owns the checkout (this cockpit runs in hosted mode). You can still see every file and which one wins.`}),(0,X.jsx)(`div`,{"data-slot":`agent-config-agents`,role:`tablist`,className:`flex flex-wrap gap-1`,children:Hd.map(e=>(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===o.id,"data-slot":`agent-config-agent`,"data-agent":e.id,"data-selected":e.id===o.id,onClick:()=>c(e.id),className:U(`flex min-w-11 items-center justify-center gap-2 rounded-md px-3 py-1.5 text-[13px] transition-colors`,e.id===o.id?`bg-background font-semibold shadow-sm`:`hover:bg-muted/60`),children:[e.label,!t.includes(e.id)&&(0,X.jsx)(Bs,{variant:`outline`,className:`text-[10px] text-soft-foreground`,children:`not installed`})]},e.id))}),o.note&&(0,X.jsx)(`p`,{"data-slot":`agent-config-agent-note`,className:`text-[12px] text-soft-foreground`,children:o.note}),(0,X.jsxs)(`div`,{className:`grid min-w-0 gap-6 lg:grid-cols-[minmax(0,20rem)_minmax(0,1fr)]`,children:[(0,X.jsx)(`nav`,{"data-slot":`agent-config-nav`,className:`flex min-w-0 flex-col gap-5`,children:(0,X.jsx)(qd,{agent:o,listing:e,selectedId:i,onSelect:a})}),(0,X.jsx)(`div`,{"data-slot":`agent-config-editor-pane`,className:`min-w-0`,children:s?(0,X.jsx)(Yd,{file:s},s.id):(0,X.jsx)(`div`,{className:`flex h-full min-h-40 items-center justify-center rounded-md border border-dashed border-border text-[13px] text-soft-foreground`,children:`Select a config file to view or edit it.`})})]})]})}function qd({agent:e,listing:t,selectedId:n,onSelect:r}){return(0,X.jsx)(X.Fragment,{children:e.groups.map(i=>{let a=t.files.filter(i.files),o=e.id===`claude`&&i.id===`mcp`;return a.length===0&&!(o&&t.userMcp)&&!i.empty?null:(0,X.jsxs)(`section`,{"data-slot":`agent-config-group`,"data-group":i.id,"data-agent":e.id,children:[(0,X.jsx)(`p`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wide text-soft-foreground`,children:i.label}),i.note&&(0,X.jsx)(`p`,{className:`mb-2 text-[12px] text-soft-foreground`,children:i.note}),a.length===0&&i.empty&&(0,X.jsx)(`p`,{"data-slot":`agent-config-group-empty`,className:`rounded-md border border-dashed border-border px-3 py-2 text-[12px] text-soft-foreground`,children:i.empty}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-1`,children:a.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,"data-slot":`agent-config-file`,"data-selected":e.id===n,onClick:()=>r(e.id),className:U(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] transition-colors`,e.id===n?`bg-accent-strong/15 text-foreground`:`hover:bg-muted/60`),children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[12px]`,children:e.label}),e.seeded&&(0,X.jsx)(Bs,{variant:`outline`,className:`shrink-0 text-[10px]`,children:`seeded`}),!e.exists&&(0,X.jsx)(`span`,{className:`shrink-0 text-[11px] text-soft-foreground`,children:`absent`})]})},e.id))}),o&&t.userMcp&&(0,X.jsx)(Jd,{userMcp:t.userMcp})]},i.id)})})}function Jd({userMcp:e}){return(0,X.jsxs)(`div`,{"data-slot":`agent-config-user-mcp`,className:`mt-3`,children:[(0,X.jsx)(`h4`,{className:`mb-1 text-[12px] font-semibold`,children:`User & local scopes`}),(0,X.jsxs)(`p`,{className:`mb-2 text-[12px] text-soft-foreground`,children:[`Managed by `,(0,X.jsx)(`code`,{className:`font-mono`,children:`claude mcp add`}),` in `,e.path,` — cezar does not edit Claude’s state file.`]}),e.readable?e.servers.length>0?(0,X.jsx)(`ul`,{className:`flex flex-wrap gap-1`,children:e.servers.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(Bs,{variant:`outline`,className:`font-mono text-[11px]`,children:e})},e))}):(0,X.jsx)(`p`,{className:`text-[12px] text-soft-foreground`,children:`No user-scoped MCP servers.`}):(0,X.jsx)(`p`,{className:`text-[12px] text-soft-foreground`,children:`Could not read the file.`})]})}function Yd({file:e}){let t=rn(e.id),n=er(e.id),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),l=t.data?.version??null;(0,Y.useEffect)(()=>{t.data&&(i(t.data.content),o(!1),c(null))},[t.data?.version,t.data]);let u=r??t.data?.content??``,d=t.data?u!==t.data.content:!1,f=e.writable;return(0,X.jsxs)(`div`,{"data-slot":`settings-config-editor`,className:`flex flex-col gap-3`,children:[(0,X.jsx)(`h3`,{className:`text-sm`,children:`Configuration file`}),(0,X.jsxs)(`p`,{"data-slot":`agent-config-scope`,title:e.path,className:`text-[12px] text-muted-foreground break-words`,children:[e.scope.charAt(0).toUpperCase()+e.scope.slice(1),` scope · `,e.path]}),(0,X.jsxs)(`div`,{className:`settings-readout flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.label}),(0,X.jsx)(Bs,{variant:`outline`,className:`text-[10px] uppercase`,children:e.format}),(0,X.jsx)(`a`,{href:e.docsUrl,target:`_blank`,rel:`noreferrer`,className:`text-[12px] text-soft-foreground underline hover:text-foreground`,children:`docs`})]}),(0,X.jsxs)(`div`,{className:`settings-config-content-heading`,children:[(0,X.jsx)(`h3`,{children:e.kind===`mcp`||e.holdsMcp?`MCP configuration`:`File contents`}),(e.kind===`mcp`||e.holdsMcp)&&(0,X.jsx)(`p`,{children:`Review server commands before saving. MCP servers execute locally.`})]}),t.isPending?(0,X.jsx)(`p`,{className:`text-[13px] text-soft-foreground`,children:`Loading file…`}):t.isError?(0,X.jsx)(`p`,{className:`text-[13px] text-destructive`,children:t.error.message}):(0,X.jsx)(zd,{value:u,language:e.format,readOnly:!f,onChange:i,"aria-label":`${e.label} contents`,className:`h-[210px]`}),s&&(0,X.jsx)(`p`,{"data-slot":`agent-config-format-error`,className:`text-[12px] text-destructive`,children:s}),a&&(0,X.jsxs)(`div`,{"data-slot":`agent-config-conflict`,className:`flex items-center justify-between gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px]`,children:[(0,X.jsx)(`span`,{children:`The file changed on disk since you opened it.`}),(0,X.jsx)(I,{size:`sm`,variant:`outline`,onClick:()=>void t.refetch(),children:`Reload from disk`})]}),f&&(0,X.jsxs)(`div`,{className:`settings-form-actions`,children:[(0,X.jsx)(I,{size:`sm`,onClick:()=>{c(null),o(!1),n.mutate({content:u,version:l},{onSuccess:()=>{i(null),B(`${e.exists?`Saved`:`Created`} ${e.label}`)},onError:e=>{e instanceof fn&&e.status===409?o(!0):e instanceof fn&&e.status===400?c(e.message):B(e.message,{tone:`danger`})}})},disabled:!d||n.isPending,children:e.exists?`Save file`:`Create file`}),(0,X.jsx)(I,{size:`sm`,variant:`outline`,onClick:()=>i(null),disabled:!d||n.isPending,children:`Reset`}),d&&(0,X.jsx)(`span`,{className:`text-[12px] text-soft-foreground`,children:`Unsaved changes`})]}),(0,X.jsxs)(`div`,{className:`settings-config-save-help`,children:[(0,X.jsx)(`p`,{"data-slot":`agent-config-precedence`,className:`text-[12px] text-soft-foreground`,children:e.precedence}),(0,X.jsxs)(`p`,{"data-slot":`agent-config-effect`,className:`text-[12px] text-foreground/80`,children:[Wd(e),e.hotReload?` ${e.hotReload}`:``]}),e.readOnlyReason&&(0,X.jsx)(`p`,{children:e.readOnlyReason})]})]})}function Xd({className:e,size:t=`default`,...n}){return(0,X.jsx)(Do,{"data-slot":`switch`,"data-size":t,className:U(`peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-none transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-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,X.jsx)(ko,{"data-slot":`switch-thumb`,className:U(`pointer-events-none block rounded-full bg-background ring-0 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`)})})}var Zd=[{id:`claude`,label:`Claude Code`,login:`claude auth login`},{id:`codex`,label:`Codex`,login:`codex login`},{id:`opencode`,label:`OpenCode`,login:`opencode auth login`},{id:`pi`,label:`pi`,login:`pi /login`},{id:`cursor`,label:`Cursor`,login:`agent login`}],Qd=e=>({claude:e,codex:e,opencode:e,pi:e,cursor:e}),$d={connected:{label:`Credentials found`,tone:`success`},disconnected:{label:`Not connected`,tone:`pending`},"not-installed":{label:`Not installed`,tone:`neutral`},unknown:{label:`Could not verify`,tone:`danger`}};function ef(e,t,n){return{providers:e.providers.map(e=>e.provider===t?{...e,enabled:n}:e)}}function tf(){let e=Me(),t=Ue(),n=lt(),r=o(),[i,a]=(0,Y.useState)(null),s=(0,Y.useRef)(Promise.resolve()),c=(0,Y.useRef)(Qd(0)),l=(0,Y.useRef)(Qd(0)),u=(0,Y.useRef)(e.data);(0,Y.useEffect)(()=>{i&&Tt(e.data,i.provider)?.status===`connected`&&a(null)},[i,e.data]),(0,Y.useEffect)(()=>{if(e.data){if(Object.values(l.current).every(e=>e===0)||!u.current){u.current=e.data;return}u.current={providers:e.data.providers.map(e=>({...e,enabled:l.current[e.provider]>0?Tt(u.current,e.provider)?.enabled??e.enabled:e.enabled}))}}},[e.data]);let d=(0,Y.useCallback)((e,t)=>{let n=P.providerStatus,i=r.getQueryData(n);if(!i)return;u.current||=i;let a=ef(i,e,t);l.current[e]+=1,r.setQueryData(n,a);let o=++c.current[e];s.current=s.current.then(async()=>{try{let i=await On(e,t),a=Tt(i,e)?.enabled;if(a===void 0)return;if(u.current=ef(u.current??i,e,a),o===c.current[e]){let t=r.getQueryData(n);r.setQueryData(n,t?ef(t,e,a):i)}}catch(t){if(o===c.current[e]){let i=Tt(u.current,e)?.enabled,a=r.getQueryData(n);a&&i!==void 0?r.setQueryData(n,ef(a,e,i)):u.current?r.setQueryData(n,u.current):r.removeQueries({queryKey:n,exact:!0}),B(t instanceof Error?t.message:String(t),{tone:`danger`})}}finally{--l.current[e]}})},[r]),f=F({mutationFn:e=>jt(e),onSuccess:async(e,t)=>{a(null),B(e.opened?`Finish signing in in the terminal, then check again.`:`Provider is already connected.`),await r.invalidateQueries({queryKey:P.providerStatus}),lr(t)&&await kn(r,t,`none`)},onError:(e,t)=>{if(e instanceof fn&&e.command){let n=Zd.find(e=>e.id===t)?.label??t;a({provider:t,label:n,message:e.message,command:e.command});return}B(e.message,{tone:`danger`})}}),p=async e=>{try{await navigator.clipboard.writeText(e),B(`Command copied`)}catch{B(`Could not copy the command`,{tone:`danger`})}};return(0,X.jsxs)(`section`,{id:`providers`,"data-slot":`provider-settings`,className:`scroll-mt-20`,children:[(0,X.jsxs)(`div`,{className:`mb-2`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Providers`}),(0,X.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Connect the coding agents available on this computer.`})]}),e.isError?(0,X.jsxs)(`div`,{role:`alert`,className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border border-danger/30 bg-danger/5 px-3 py-2.5`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:`Provider status could not be loaded`}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.error.message})]}),(0,X.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,disabled:e.isFetching,onClick:()=>void e.refetch(),children:`Retry`})]}):null,(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:Zd.map(r=>{let a=Tt(e.data,r.id),o=a?.status,s=o?$d[o]:e.isPending?{label:`Checking…`,tone:`neutral`}:$d.unknown,c=f.isPending&&f.variables===r.id,l=o===`disconnected`||o===`unknown`,u=a?.authFailureId;return(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsxs)(`div`,{"data-slot":`provider-card`,"data-provider":r.id,className:`rounded-md border border-border bg-card px-3.5 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`h3`,{className:`text-[13px] font-semibold text-foreground`,children:r.label}),(0,X.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(G,{tone:s.tone,pulse:e.isPending}),(0,X.jsx)(`span`,{children:s.label}),a?.enabled===!1?(0,X.jsx)(`span`,{children:`Disabled`}):null]}),o===`not-installed`?(0,X.jsxs)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:[`Install `,r.label,`, then run `,(0,X.jsx)(`code`,{children:r.login}),`.`]}):o===`unknown`||e.isError&&!o?(0,X.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:`Verification failed. Check again when the provider is available.`}):a?.hint?(0,X.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:a.hint}):null]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o===`not-installed`?null:(0,X.jsx)(Xd,{checked:a?.enabled??!0,"aria-label":`Use ${r.label}`,onCheckedChange:e=>d(r.id,e)}),l?(0,X.jsx)(I,{type:`button`,variant:`ghost`,size:`sm`,disabled:t.isPending,onClick:()=>t.mutate(void 0,{onError:e=>B(e.message,{tone:`danger`})}),children:`Check again`}):null,o===`disconnected`?(0,X.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,disabled:f.isPending,onClick:()=>f.mutate(r.id),children:c?`Opening…`:`Connect`}):null,u===void 0?null:(0,X.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,disabled:n.isPending,onClick:()=>n.mutate({provider:r.id,authFailureId:u},{onSuccess:()=>B(`${r.label} can be tried again.`),onError:e=>B(e.message,{tone:`danger`})}),children:`Try again`})]})]}),u===void 0?null:(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Use this after completing the provider sign-in flow. cezar cannot validate the credential without a task/model request; it will verify it on the next task.`})]}),i?.provider===r.id&&o!==`connected`?(0,X.jsxs)(`div`,{role:`region`,"aria-label":`${i.label} manual sign-in`,className:`rounded-md border border-pending/40 bg-pending/5 px-3.5 py-3`,children:[(0,X.jsx)(`p`,{className:`text-[13px] text-foreground`,children:i.message}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`code`,{className:`min-w-0 flex-1 overflow-x-auto rounded-sm bg-muted px-2 py-1.5 text-xs`,children:i.command}),(0,X.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void p(i.command),children:`Copy command`})]})]}):null]},r.id)})})]})}var nf=2e4;function rf(){let e=Mt(),t=_n(),n=Me();return e.isPending?(0,X.jsx)(`p`,{"data-slot":`agents-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent settings…`}):e.isError?(0,X.jsx)(R,{icon:(0,X.jsx)(le,{}),tone:`danger`,title:`Agent settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,X.jsx)(af,{config:e.data,catalogs:t,providerStatus:n})}function af({config:e,catalogs:t,providerStatus:n}){let r=de(),i=o(),a=F({mutationFn:e=>k(e),onSuccess:e=>{i.setQueryData(L.config,e),i.invalidateQueries({queryKey:L.health}),i.invalidateQueries({queryKey:L.repo})},onError:e=>B(e.message,{tone:`danger`})}),[s,c]=(0,Y.useState)(e.systemPrompt??``),l=s.trim(),u=l===(e.systemPrompt??``),d=l.length>nf;return(0,X.jsxs)(`div`,{"data-slot":`agents-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,X.jsx)(of,{defaultRunner:e.defaultRunner,providerStatus:n,saving:a.isPending,onPick:e=>a.mutate({defaultRunner:e})}),(0,X.jsx)(sf,{title:`Default model`,hint:e.modelsLocked?`Models are locked to the defaults configured in the native coding-agent settings.`:`The model preselected in the composer for each runner. Auto lets the runner decide per task.`,children:(0,X.jsx)(`div`,{className:`flex flex-col gap-4`,children:ji.map(r=>{let i=Tt(n.data,r.id),o=!n.isPending&&!n.isError&&i?.enabled===!0&&i.status===`connected`,s=n.isPending?`Checking provider authentication…`:n.isError?`Provider authentication could not be verified.`:i?.enabled===!1?`This provider is disabled. Enable it above or choose another provider.`:o?void 0:`Connect this provider before selecting it.`,c=t[r.id],l=vi(r.id,c.data,c.isError,c.isFetching),u=Fi(r.id,c.data,[e.defaultModels[r.id]]),d=e.defaultModels[r.id]??``,f=u.find(e=>e.id===d)?.label??d??`auto (default)`;return(0,X.jsxs)(`label`,{className:`settings-option-row`,children:[(0,X.jsx)(`div`,{children:(0,X.jsx)(`h3`,{children:r.label})}),e.modelsLocked?(0,X.jsx)(`output`,{"aria-label":`Default model for ${r.label}`,"data-slot":`agents-model`,"data-runner":r.id,title:`Model selection is locked to native coding-agent settings.`,className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs`,children:f}):(0,X.jsxs)(`select`,{"aria-label":`Default model for ${r.label}`,"data-slot":`agents-model`,"data-runner":r.id,value:d,title:s??r.desc,disabled:a.isPending||!o,onChange:e=>a.mutate({defaultModels:{[r.id]:e.target.value||null}}),className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[u.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.id===``?`Native agent default`:e.label},e.id)),l?(0,X.jsx)(`option`,{disabled:!0,children:l}):null]})]},r.id)})})}),(0,X.jsxs)(sf,{title:`System prompt`,hint:`Extra instructions for every run in this project.`,children:[(0,X.jsx)(Br,{"aria-label":`System prompt`,"data-slot":`agents-system-prompt`,value:s,onChange:e=>c(e.target.value),placeholder:`Extra rules for every agent run — conventions, tone, review requirements…`,className:`min-h-48 w-full`}),(0,X.jsxs)(`div`,{className:`settings-form-actions`,children:[(0,X.jsx)(I,{type:`button`,variant:`primary`,size:`sm`,"data-action":`agents-save-prompt`,disabled:u||d||a.isPending,onClick:()=>a.mutate({systemPrompt:l===``?null:l},{onSuccess:()=>B(l===``?`System prompt cleared`:`System prompt saved`)}),children:`Save prompt`}),d?(0,X.jsxs)(`p`,{"data-slot":`agents-prompt-limit`,className:`text-[11px] text-danger`,children:[l.length.toLocaleString(),` characters — the limit is`,` `,nf.toLocaleString(),`.`]}):(0,X.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Leave empty and save to clear. Applied to new runs only.`})]})]}),(0,X.jsxs)(`section`,{"data-slot":`agents-task-runs`,className:`settings-field flex flex-col gap-5`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Task runs`}),(0,X.jsx)(cf,{title:`Live title updates`,hint:`Refresh a task's short title through the namer model as the run progresses. A manual rename always wins and stops updates for that task.`,children:(0,X.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,X.jsx)(Xd,{"aria-label":`Live title updates`,"data-slot":`agents-live-title-updates`,checked:e.liveTitleUpdates??!0,disabled:a.isPending,onCheckedChange:e=>a.mutate({liveTitleUpdates:e},{onSuccess:()=>B(e?`Live title updates on`:`Live title updates off`)})}),(0,X.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.liveTitleUpdates??!0?`On`:`Off`,e.liveTitleUpdates===null&&` (default)`]})]})}),(0,X.jsx)(cf,{title:`Review changes before finishing`,hint:`When on, a task with changes pauses so you can Accept, Send back, or open a Draft PR. Autonomous tasks always skip this and finish on their own. Default: off — tasks finish without asking.`,children:(0,X.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,X.jsx)(Xd,{"aria-label":`Review changes before finishing`,"data-slot":`agents-review-gate`,checked:e.reviewGate??!1,disabled:a.isPending,onCheckedChange:e=>a.mutate({reviewGate:e},{onSuccess:()=>B(e?`Review gate on`:`Review gate off`)})}),(0,X.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.reviewGate??!1?`On`:`Off`,e.reviewGate===null&&` (default)`]})]})}),(0,X.jsx)(cf,{title:`Base branch`,hint:`New task worktrees branch from this and draft PRs target it. Also settable from the Git view.`,children:r.data?.info?(0,X.jsxs)(`select`,{"aria-label":`Base branch`,"data-slot":`agents-base-branch`,value:e.baseBranch??``,disabled:a.isPending,onChange:e=>a.mutate({baseBranch:e.target.value||null}),className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,X.jsx)(`option`,{value:``,children:`follow checked-out branch (default)`}),r.data.branches.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))]}):(0,X.jsx)(`p`,{"data-slot":`agents-base-branch-unavailable`,className:`text-[13px] text-soft-foreground`,children:r.isPending?`Loading branches…`:`Not a git repository — tasks run in place, no branching.`})})]}),(0,X.jsxs)(`details`,{className:`settings-disclosure`,children:[(0,X.jsx)(`summary`,{children:`Provider connections`}),(0,X.jsx)(tf,{})]})]})}function of({defaultRunner:e,providerStatus:t,saving:n,onPick:r}){let i=Bn(),a=M(),o=Fn(),s=de(),c=Vn(),l=o.projectId??`default`,u=s.data?.info?.root,d=u?i.data?.selections[u]:void 0,f=i.data?.defaults,p=xd(i.data?.profiles??[]),m=Sd(p);return(0,X.jsxs)(sf,{title:`Default runner`,hint:`Project defaults. A task can override these choices.`,children:[(0,X.jsx)(Td,{rows:p,runner:e,accountFor:e=>d?.[e]??f?.[e]??null,providerStatus:t,disabled:n,accountDisabled:c.isPending||a.data===void 0,onPick:(t,n,i)=>{t!==e&&r(t),i&&c.mutate({projectId:l,provider:t,profileId:n},{onError:e=>B(e.message,{tone:`danger`})})}}),!t.isPending&&!t.isError&&Tt(t.data,e)?.enabled===!1?(0,X.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`This provider is disabled. Enable it above or choose another provider.`}):null,m?(0,X.jsx)(`p`,{className:`max-w-md text-[13px] text-muted-foreground`,children:`The account is personal and never committed. Tasks already started under another account can’t be resumed here — their sessions live in that account’s folder.`}):null]})}function sf({title:e,hint:t,children:n}){return(0,X.jsxs)(`section`,{className:`settings-field flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,X.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t})]}),n]})}function cf({title:e,hint:t,children:n}){return(0,X.jsxs)(`section`,{className:`settings-option-row`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{children:e}),(0,X.jsx)(`p`,{children:t})]}),n]})}var lf=`cez-accent`,uf=`cez-density`,df=`cez-width`,ff=`cezarion`,pf=`comfortable`,mf=`narrow`;function hf(e){return ff}function gf(e){return e===`comfortable`||e===`compact`||e===`ultra`?e:pf}function _f(e){return e===`narrow`||e===`wide`?e:mf}function vf(e){let t=e&&typeof e==`object`?e:{};return{accent:hf(t.accent),density:gf(t.density),width:_f(t.width)}}function yf(){try{return{accent:hf(localStorage.getItem(lf)),density:gf(localStorage.getItem(uf)),width:_f(localStorage.getItem(df))}}catch{return{accent:ff,density:pf,width:mf}}}function bf(e){try{localStorage.setItem(lf,e.accent),localStorage.setItem(uf,e.density),localStorage.setItem(df,e.width)}catch{}}function xf(e,t){t.accent===`cezarion`?delete e.dataset.accent:e.dataset.accent=t.accent,t.density===`comfortable`?delete e.dataset.density:e.dataset.density=t.density,t.width===`narrow`?delete e.dataset.width:e.dataset.width=t.width}var Sf=Y.createContext(null);function Cf({children:e}){let t=o(),n=bt(),[r,i]=Y.useState(yf),a=n.data;Y.useEffect(()=>{if(a===void 0)return;let e=vf(a.appearance);i(e),bf(e)},[a]),Y.useLayoutEffect(()=>{xf(document.documentElement,r)},[r]);let s=Y.useCallback(e=>{i(e),bf(e),ot({appearance:e}).then(e=>t.setQueryData(P.uiState,e)).catch(e=>{B(e instanceof Error?e.message:String(e),{tone:`danger`}),t.invalidateQueries({queryKey:P.uiState})})},[t]),c=Y.useCallback(e=>s({...r,accent:e}),[s,r]),l=Y.useCallback(e=>s({...r,density:e}),[s,r]),u=Y.useCallback(e=>s({...r,width:e}),[s,r]),d=Y.useMemo(()=>({accent:r.accent,density:r.density,width:r.width,setAccent:c,setDensity:l,setWidth:u}),[r,c,l,u]);return(0,X.jsx)(Sf.Provider,{value:d,children:e})}function wf(){let e=Y.useContext(Sf);if(!e)throw Error(`cezar: useAppearance() must be called inside <AppearanceProvider>`);return e}var Tf=[{value:`system`,label:`System`,icon:cc},{value:`light`,label:`Light`,icon:fc},{value:`dark`,label:`Dark`,icon:lc}],Ef=[{value:`cezarion`,label:`Cezarion`,swatch:`var(--accent-strong)`}],Df=[{value:`comfortable`,label:`Comfortable`},{value:`compact`,label:`Compact`},{value:`ultra`,label:`Compact for real`}],Of=[{value:`narrow`,label:`Narrow`},{value:`wide`,label:`Wide`}];function kf({slot:e,label:t,value:n,options:r,onChange:i}){return(0,X.jsx)(`div`,{role:`radiogroup`,"aria-label":t,"data-slot":e,className:`inline-flex w-fit gap-0.5 rounded-md border border-border bg-card p-0.5 max-md:max-w-full max-md:flex-wrap`,children:r.map(e=>{let t=e.value===n;return(0,X.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"data-value":e.value,onClick:()=>i(e.value),className:U(`flex min-h-11 items-center gap-2 rounded-sm px-3 py-1.5 text-[13px] font-medium transition-colors`,t?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:[e.icon?(0,X.jsx)(e.icon,{"aria-hidden":`true`,className:`size-3.5`}):null,e.swatch?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 rounded-full border border-border`,style:{background:e.swatch}}):null,e.label]},e.value)})})}function Af({title:e,hint:t,children:n}){return(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,X.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t})]}),n]})}function jf(){let{theme:e,setTheme:t}=Rc(),{accent:n,density:r,width:i,setAccent:a,setDensity:o,setWidth:s}=wf();return(0,X.jsxs)(`div`,{"data-slot":`appearance-section`,className:`flex w-full flex-col gap-7 rounded-lg border border-border bg-card p-5`,children:[(0,X.jsx)(Af,{title:`Theme`,hint:`System follows your OS preference. Applies to this browser.`,children:(0,X.jsx)(kf,{slot:`appearance-theme`,label:`Theme`,value:e,options:Tf,onChange:t})}),Ef.length>1?(0,X.jsx)(Af,{title:`Accent`,hint:`The cockpit brand accent. Saved with your workspace appearance.`,children:(0,X.jsx)(kf,{slot:`appearance-accent`,label:`Accent`,value:n,options:Ef,onChange:a})}):null,(0,X.jsx)(Af,{title:`Density`,hint:`Compact tightens spacing across the cockpit — text stays the same size.`,children:(0,X.jsx)(kf,{slot:`appearance-density`,label:`Density`,value:r,options:Df,onChange:o})}),(0,X.jsx)(Af,{title:`Reading width`,hint:`Wide lets a task's session and commits use more of the screen. Narrow keeps a comfortable reading column. The Changes tab is always full-width.`,children:(0,X.jsx)(kf,{slot:`appearance-width`,label:`Reading width`,value:i,options:Of,onChange:s})}),(0,X.jsxs)(`div`,{className:`settings-appearance-preview settings-readout`,children:[(0,X.jsx)(`span`,{className:`text-[10px] text-soft-foreground`,children:`PREVIEW`}),(0,X.jsx)(`p`,{className:`mt-3 text-base`,children:`Review finalization retries`}),(0,X.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Needs you · cezar · Task `,`#`,`227`]}),(0,X.jsx)(`span`,{className:`mt-3 inline-flex rounded-md border border-accent-strong/30 bg-accent-strong/10 px-4 py-3 text-xs text-accent-text`,children:`Open task`})]}),(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`Changes apply immediately. Theme is browser-local; density and reading width are saved with your workspace.`})]})}var Mf=`http://localhost:4321`;function Nf(e,t,n,r=Mf,i=null){let a=e=>encodeURIComponent(e).replaceAll(`'`,`%27`),o=`(()=>{const m=location.href.match(/^https:\\/\\/github\\.com\\/([^\\/]+)\\/([^\\/]+)\\/(pull|issues)\\/\\d+/);if(!m){alert('Open a GitHub PR or issue first');return;}const q='${`${e?`skill=${a(e)}&`:``}auto=${t?`1`:`0`}&key=${a(n)}&ref=`}'+encodeURIComponent(location.href);open('${r.replaceAll(`'`,`%27`)}${i===null||i===``?`/new`:`/p/${a(i)}/new`}?'+q,'_blank');})();`;return`javascript:${encodeURIComponent(o)}`}function Pf(){let e=Nt();return e.isPending?(0,X.jsx)(`p`,{"data-slot":`bookmarklets-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading bookmarklets…`}):e.isError?(0,X.jsx)(R,{icon:(0,X.jsx)(st,{}),tone:`danger`,heading:`h2`,title:`Could not load bookmarklets`,subtitle:e.error.message}):(0,X.jsx)(`div`,{className:`flex min-h-full flex-1 overflow-y-auto`,children:(0,X.jsx)(Ff,{skills:na(e.data??[])})})}function Ff({skills:e}){let t=b(),n=H(),r=M(),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(``),c=t.data?.key??``,l=window.location.origin,u=Ki()??n.data?.bootProject??null,d=r.data?.projects.find(e=>e.id===u)?.name??Ih(n.data)?.name??null,f=o.trim().toLowerCase(),p=e.filter(e=>e.name.toLowerCase().includes(f));return(0,X.jsxs)(`div`,{"data-slot":`bookmarklet-panel`,className:`flex w-full min-w-0 flex-col gap-[18px] p-5`,children:[(0,X.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Run from GitHub`}),(0,X.jsxs)(`p`,{className:`text-[13px] leading-relaxed text-muted-foreground`,children:[`Drag a launcher to your browser's bookmarks bar. Then open a GitHub PR or issue and click that bookmark. Cezar must be running: `,(0,X.jsx)(`span`,{className:`font-mono`,children:`npx cezarion`}),`.`]}),(0,X.jsxs)(`div`,{className:`settings-bookmarklet-project rounded-lg bg-background p-3.5`,children:[(0,X.jsxs)(`p`,{className:`text-[13px]`,children:[`Project`,d?` · ${d}`:``]}),(0,X.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`Launchers target this cockpit and this project. Keep Cezarion running.`})]}),(0,X.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2.5 text-[13px] font-medium`,children:[(0,X.jsx)(`input`,{type:`checkbox`,"data-slot":`bm-auto`,checked:i,onChange:e=>a(e.target.checked),className:`size-[18px] shrink-0`}),`One-click launch (auto-submit)`]}),(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-soft-foreground`,children:`Off by default. Re-drag the launchers after changing this option.`}),(0,X.jsx)(`div`,{"data-slot":`bm-generic`,className:`rounded-lg border border-border bg-muted/30 p-3.5`,children:(0,X.jsx)(If,{label:d?`cezar (${d}): this PR/issue`:`cezar: this PR/issue`,url:Nf(``,!1,c,l,u),generic:!0,hint:`Prefills the form only—never auto-starts, even when auto-submit is on.`})}),(0,X.jsx)(_c,{"data-slot":`bm-filter`,placeholder:`Filter bookmarklet skills…`,"aria-label":`Filter bookmarklet skills`,value:o,onChange:e=>s(e.target.value),className:`h-11 text-[13px]`}),(0,X.jsx)(`div`,{"data-slot":`bm-list`,className:`flex flex-col divide-y divide-border [&>[data-slot=bm-row]]:py-3.5`,children:p.length>0?p.map(e=>(0,X.jsx)(If,{label:d?`/${e.name} (${d})`:`/${e.name}`,url:Nf(e.name,i,c,l,u)},e.path)):(0,X.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:e.length>0?`(no skills match)`:`(no skills yet — the generic launcher above still works)`})}),(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-soft-foreground`,children:`These are bookmarklet drag sources, not run buttons. Clicking one here explains installation; it does not start a task.`}),(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-soft-foreground md:hidden`,children:`No drag-and-drop? Copy the URL for manual bookmark setup where your browser allows it, or install using a desktop browser.`})]})}function If({label:e,url:t,hint:n,generic:r=!1}){let i=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{i.current?.setAttribute(`href`,t)},[t]);let a=async()=>{try{await navigator.clipboard.writeText(t),B(`Bookmarklet URL copied.`)}catch{B(`Copy failed — drag the button instead.`,{tone:`danger`})}};return(0,X.jsxs)(`div`,{"data-slot":`bm-row`,className:`flex min-w-0 flex-col gap-2.5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`a`,{ref:i,draggable:!0,"data-slot":`bm-link`,title:`Drag me to your bookmarks bar`,"aria-label":`${r?`Drag to bookmarks`:`Drag launcher`}: ${e}`,onClick:e=>{e.preventDefault(),B(`Drag me to your bookmarks bar`)},className:`inline-flex min-h-11 min-w-0 items-center rounded-md border border-border px-3 text-xs font-medium transition-colors hover:bg-muted ${r?`bg-accent-strong/10 text-accent-text`:`bg-card text-foreground`}`,children:(0,X.jsx)(`span`,{className:`break-words`,children:e})}),(0,X.jsx)(`button`,{type:`button`,"data-slot":`bm-copy`,title:`Copy the bookmarklet URL`,onClick:()=>void a(),className:`min-h-11 shrink-0 rounded-md border border-border px-3 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:`Copy URL`})]}),n?(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-soft-foreground`,children:n}):null]})}function Lf(e){return{enabled:(e&&typeof e==`object`?e:{}).enabled===!0}}function Rf(){let e=globalThis.Notification;if(typeof e!=`function`)return`unsupported`;let t=e.permission;return t===`granted`||t===`denied`?t:`default`}function zf(e,t){let n=new Map,r=[];for(let i of t??[]){let t={status:i.status,wantsAttention:ut(i)};n.set(i.id,t);let a=e.get(i.id);a!==void 0&&(a.status===t.status&&a.wantsAttention===t.wantsAttention||t.wantsAttention&&r.push(i))}return{entering:r,statuses:n}}function Bf(e){return e.enabled&&e.hidden&&e.permission===`granted`}function Vf(e){let t=it(e).label;return{title:e.titleSummary??e.title,body:`Task ${t}`,tag:`cezar-run-${e.id}`}}function Hf(){let e=o(),t=bt(),[n,r]=Y.useState(!1),[i,a]=Y.useState(Rf),s=t.data;Y.useEffect(()=>{s!==void 0&&r(Lf(s.notifications).enabled)},[s]);let c=Y.useCallback(t=>{r(t),ot({notifications:{enabled:t}}).then(t=>e.setQueryData(P.uiState,t)).catch(t=>{B(t instanceof Error?t.message:String(t),{tone:`danger`}),e.invalidateQueries({queryKey:P.uiState})})},[e]),l=Y.useCallback(e=>{if(!e){c(!1);return}if(Rf()!=="default"){c(!0);return}c(!0),Notification.requestPermission().then(e=>a(e)).catch(()=>a(Rf()))},[c]),u=i===`unsupported`;return(0,X.jsx)(`div`,{"data-slot":`notifications-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:(0,X.jsx)(`label`,{htmlFor:`notifications-enabled`,children:`Notify when an agent needs you`})}),(0,X.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`A browser notification when a task starts waiting, asks for review, or fails — only while this tab is in the background. Off by default.`})]}),(0,X.jsx)(Xd,{id:`notifications-enabled`,"data-slot":`notifications-toggle`,checked:n,disabled:u,onCheckedChange:l})]}),u?null:(0,X.jsxs)(`p`,{"data-slot":`notifications-permission`,"data-permission":i,className:`mt-4 text-[13px] text-muted-foreground`,children:[`Browser permission · `,i===`granted`?`Allowed`:i===`denied`?`Blocked`:`Not requested`]}),(0,X.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Permission is requested only when you enable notifications.`}),u?(0,X.jsx)(`p`,{"data-slot":`notifications-unsupported`,className:`text-[13px] text-muted-foreground`,children:`This browser does not support notifications, so the toggle is unavailable here.`}):null,!u&&n&&i===`denied`?(0,X.jsxs)(`div`,{"data-slot":`notifications-denied`,className:`mt-5 flex flex-col gap-2`,children:[(0,X.jsx)(`h3`,{className:`text-sm`,children:`Allow notifications in your browser`}),(0,X.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`This browser is blocking notifications. Your preference is saved. Allow notifications in the browser’s site settings to receive them.`}),(0,X.jsx)(`p`,{className:`settings-readout`,children:`Notifications are blocked for this site.`})]}):null]})})}function Uf(){let e=me();return{isPending:e.isPending,confirm:(t,n)=>e.mutate(t.id,{onSuccess:()=>{B(`${t.name} removed from the workspace — its files are untouched`),n?.()},onError:e=>B(e.message,{tone:`danger`})})}}function Wf({project:e,onOpenChange:t,onConfirm:n}){return(0,X.jsx)(Nn,{open:e!==null,onOpenChange:t,children:(0,X.jsxs)(Ut,{children:[(0,X.jsxs)(An,{children:[(0,X.jsxs)(xt,{children:[`Remove `,e?.name,` from the workspace?`]}),(0,X.jsxs)(mt,{children:[`This only unregisters the project — `,(0,X.jsx)(`strong`,{children:`nothing on disk is deleted`}),`. The folder, its git history and its task history all stay exactly where they are, and opening it again re-registers it with everything intact.`,(0,X.jsx)(`span`,{className:`mt-1 block truncate font-mono text-[11px] text-foreground`,title:e?.root,children:e?.root})]})]}),(0,X.jsxs)(mn,{children:[(0,X.jsx)(Dn,{children:`Keep it`}),(0,X.jsx)(un,{"data-action":`projects-confirm-remove`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:n,children:`Remove from list`})]})]})})}function Q({title:e,hint:t,children:n}){return(0,X.jsxs)(`section`,{className:`settings-field flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,X.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t})]}),n]})}var Gf=1,Kf={ok:`ok`,"not-git":`no git repo`,missing:`folder not found`};function qf(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Jf(){let e=Zn(),t=M();return e.isPending||t.isPending?(0,X.jsx)(`p`,{"data-slot":`projects-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading projects…`}):e.isError||t.isError?(0,X.jsx)(R,{icon:(0,X.jsx)(ln,{}),tone:`danger`,title:`Project settings did not load`,subtitle:(e.error??t.error)?.message,heading:`h2`}):(0,X.jsx)(Yf,{config:e.data,registry:t.data})}function Yf({config:e,registry:t}){let[n,r]=(0,Y.useState)(!1);return(0,X.jsxs)(`div`,{"data-slot":`projects-section`,className:`mx-auto flex w-full max-w-4xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,X.jsx)(Xf,{configKey:`browseRoot`,value:e.browseRoot,title:`Default browse folder`,hint:`Where “Open local folder…” starts. The picker cannot navigate above this folder.`,placeholder:`~/`,slot:`browse`,savedLabel:`Browse folder`,footer:`Only affects folder browsing; GitHub checkouts use the separate checkout folder.`}),(0,X.jsx)(Xf,{configKey:`projectsDir`,value:e.projectsDir,title:`Default checkout folder`,hint:`Where “Clone from GitHub” puts new projects: <folder>/<project name>.`,placeholder:`~/cezar/projects`,slot:`checkout`,savedLabel:`Checkout folder`,footer:`Only affects new checkouts; projects already registered keep their location.`,refreshProjects:!0}),(0,X.jsx)(Zf,{registry:t,workspaceMax:e.resources.maxParallel}),(0,X.jsx)(I,{className:`self-start`,onClick:()=>r(!0),children:`Add project`}),n?(0,X.jsx)(gc,{open:!0,onOpenChange:r}):null]})}function Xf({configKey:e,value:t,title:n,hint:r,placeholder:i,slot:a,savedLabel:s,footer:c,refreshProjects:l=!1}){let u=o(),d=F({mutationFn:t=>ue(e===`browseRoot`?{browseRoot:t}:{projectsDir:t}),onSuccess:t=>{u.setQueryData(P.config,t),e===`browseRoot`?u.invalidateQueries({queryKey:P.fsBrowseRoot}):l&&u.invalidateQueries({queryKey:P.projects})}}),[f,p]=(0,Y.useState)(t),m=f.trim(),h=m===t,g=d.isError?d.error.message:null;return(0,X.jsxs)(Q,{title:n,hint:`${r} ${e===`browseRoot`?`Choose an existing folder; it is verified writable before saving.`:`The folder is created recursively if needed, then verified writable before saving.`}`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`text`,spellCheck:!1,"aria-label":n,"aria-invalid":g!==null,"data-slot":`projects-${a}-root`,value:f,disabled:d.isPending,placeholder:i,onChange:e=>{p(e.target.value),d.isError&&d.reset()},className:`block w-full max-w-sm rounded-md border border-input bg-card px-3 py-1.5 font-mono text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-danger disabled:opacity-50`}),(0,X.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,"data-action":`projects-save-${a}-root`,disabled:h||m===``||d.isPending,onClick:()=>d.mutate(m,{onSuccess:()=>B(`${s} set to ${m}`)}),children:`Save`})]}),g===null?(0,X.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:c}):(0,X.jsxs)(`p`,{"data-slot":`projects-${a}-root-error`,role:`alert`,className:`text-[11px] text-danger`,children:[g,` — setting unchanged`]})]})}function Zf({registry:e,workspaceMax:t}){let[n,r]=(0,Y.useState)(null),i=Uf(),a=(0,Y.useMemo)(()=>_(e.projects),[e.projects]);return(0,X.jsxs)(Q,{title:`Registered projects`,hint:`Connected repositories. Removing a project only unregisters it — no files on disk are deleted.`,children:[e.projects.length===0?(0,X.jsx)(`p`,{"data-slot":`projects-empty`,className:`text-[13px] text-soft-foreground`,children:`No projects registered yet.`}):(0,X.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border`,children:(0,X.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,X.jsx)(`caption`,{className:`sr-only`,children:`Projects registered in this workspace`}),(0,X.jsxs)(`colgroup`,{children:[(0,X.jsx)(`col`,{}),(0,X.jsx)(`col`,{style:{width:`104px`}}),(0,X.jsx)(`col`,{style:{width:`260px`}}),(0,X.jsx)(`col`,{style:{width:`150px`}}),(0,X.jsx)(`col`,{style:{width:`72px`}}),(0,X.jsx)(`col`,{style:{width:`92px`}})]}),(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{className:`border-b border-border text-left text-[12px] text-soft-foreground`,children:[(0,X.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Project`}),(0,X.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Status`}),(0,X.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Tags`}),(0,X.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Max parallel`}),(0,X.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Added`}),(0,X.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium text-right`,children:`Actions`})]})}),(0,X.jsx)(`tbody`,{children:e.projects.map(n=>(0,X.jsx)(Qf,{project:n,isBoot:n.id===e.bootProject,workspaceMax:t,vocabulary:a,disabled:i.isPending,onRemove:()=>r(n)},n.id))})]})}),(0,X.jsx)(Wf,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{if(!n)return;let e=n;r(null),i.confirm(e)}})]})}function Qf({project:e,isBoot:t,workspaceMax:n,vocabulary:r,disabled:i,onRemove:a}){return(0,X.jsxs)(`tr`,{"data-slot":`project-row`,"data-project":e.id,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`th`,{scope:`row`,className:`max-w-0 px-3 py-2 text-left font-normal`,children:[(0,X.jsx)(`span`,{className:`block truncate text-foreground`,children:e.name}),(0,X.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-soft-foreground`,title:e.root,children:e.root})]}),(0,X.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,X.jsx)(`span`,{"data-slot":`project-status`,className:e.status===`missing`?`text-[12px] text-danger`:`text-[12px] text-soft-foreground`,children:Kf[e.status]}),e.status===`missing`?null:(0,X.jsxs)(`span`,{className:`ml-1 text-[11px] text-soft-foreground`,children:[`· `,e.source]})]}),(0,X.jsx)(`td`,{className:`px-3 py-2`,children:(0,X.jsx)($f,{project:e,vocabulary:r})}),(0,X.jsx)(`td`,{className:`px-3 py-2`,children:(0,X.jsx)(ep,{project:e,workspaceMax:n})}),(0,X.jsx)(`td`,{className:`px-3 py-2 tabular-nums text-soft-foreground`,children:qf(e.addedAt)}),(0,X.jsxs)(`td`,{className:`px-3 py-2 text-right`,children:[e.status===`missing`?null:(0,X.jsx)(I,{asChild:!0,variant:`outline`,className:`mr-2`,children:(0,X.jsx)(z,{to:`/p/${encodeURIComponent(e.id)}`,children:`Open`})}),(0,X.jsx)(I,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`project-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:t?`cezar is serving this project — it re-registers itself at every start`:void 0,disabled:i||t,onClick:a,children:`Remove`})]})]})}function $f({project:e,vocabulary:t}){let n=pt(),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(-1),l=(0,Y.useRef)(null),u=e.tags??[],d=Kn(t,u,r),f=a&&d.length>0,p=(t,r)=>{n.mutate({id:e.id,tags:t},{onSuccess:()=>B(r),onError:e=>B(e.message,{tone:`danger`})})},m=t=>{let n=t.trim().slice(0,32);if(c(-1),n){if(u.some(e=>e.toLowerCase()===n.toLowerCase())){i(``);return}if(u.length>=20){B(`${e.name} already has the maximum of 20 tags`,{tone:`danger`});return}i(``),p([...u,n],`${e.name} tagged \u201c${n}\u201d`)}},h=t=>{p(u.filter(e=>e!==t),`\u201c${t}\u201d removed from ${e.name}`)},g=`project-tag-suggestions-${e.id}`;return(0,X.jsxs)(`div`,{"data-slot":`project-tags`,className:`flex flex-wrap items-center gap-1`,children:[u.map(t=>(0,X.jsxs)(`span`,{"data-slot":`project-tag`,className:`inline-flex max-w-full items-center gap-1 rounded-full bg-accent-strong/15 py-px pr-1 pl-2 text-[11px] font-medium whitespace-nowrap text-accent-text`,children:[t,(0,X.jsx)(`button`,{type:`button`,"data-action":`project-tag-remove`,"aria-label":`Remove tag ${t} from ${e.name}`,disabled:n.isPending,onClick:()=>h(t),className:`rounded-full p-0.5 hover:bg-accent-strong/25 disabled:opacity-50`,children:(0,X.jsx)(In,{className:`size-3`,"aria-hidden":`true`})})]},t)),(0,X.jsxs)(Mr,{open:f,onOpenChange:o,children:[(0,X.jsx)(kr,{asChild:!0,children:(0,X.jsx)(`input`,{ref:l,type:`text`,"data-slot":`project-tag-input`,"aria-label":`Add a tag to ${e.name}`,role:`combobox`,"aria-expanded":f,"aria-controls":f?g:void 0,"aria-autocomplete":`list`,"aria-activedescendant":f&&s>=0?`${g}-${s}`:void 0,placeholder:u.length===0?`Add tag…`:`+`,value:r,maxLength:32,disabled:n.isPending,onFocus:()=>o(!0),onBlur:()=>o(!1),onChange:e=>{if(o(!0),c(-1),e.target.value.includes(`,`)){i(e.target.value.replace(/,/g,``));return}i(e.target.value)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(d.length===0)return;e.preventDefault(),o(!0);let t=e.key===`ArrowDown`?1:-1,n=s+t;c(n>=d.length?-1:n<-1?d.length-1:n);return}if(e.key===`Escape`&&f){e.preventDefault(),o(!1),c(-1);return}if(e.key===`Enter`||e.key===`,`){e.preventDefault(),m(s>=0?d[s]??r:r);return}if(e.key===`Tab`){o(!1);return}if(e.key===`Backspace`&&r===``&&u.length>0){e.preventDefault();let t=u[u.length-1];t!==void 0&&h(t)}},className:`h-6 w-16 min-w-0 flex-1 rounded-md border border-input bg-card px-1.5 text-[12px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`})}),(0,X.jsxs)(Or,{align:`start`,sideOffset:4,id:g,role:`listbox`,"data-slot":`project-tag-suggestions`,className:`w-56 p-1`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,X.jsx)(`p`,{className:`px-2 pt-1 pb-1.5 text-[10.5px] text-soft-foreground`,children:`Tags used in this workspace`}),d.map((e,t)=>(0,X.jsx)(`button`,{type:`button`,id:`${g}-${t}`,role:`option`,"aria-selected":t===s,"data-slot":`project-tag-suggestion`,onMouseDown:e=>e.preventDefault(),onClick:()=>{m(e),l.current?.focus()},onMouseEnter:()=>c(t),className:U(`flex w-full items-center rounded-sm px-2 py-1 text-left text-[12px] font-medium text-accent-text`,t===s&&`bg-muted`),children:e},e))]})]})]})}function ep({project:e,workspaceMax:t}){let n=pt(),r=e.maxParallel===void 0?``:String(e.maxParallel);return(0,X.jsxs)(`select`,{"aria-label":`Max parallel tasks for ${e.name}`,"data-slot":`project-max-parallel`,value:r,disabled:n.isPending,onChange:r=>{let i=r.target.value,a=i===``?null:Number(i);n.mutate({id:e.id,maxParallel:a},{onSuccess:()=>B(a===null?`${e.name} inherits the workspace limit (${t})`:`${e.name} runs at most ${a} task${a===1?``:`s`} at a time`),onError:e=>B(e.message,{tone:`danger`})})},className:`block w-44 rounded-md border border-input bg-card px-2 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,X.jsxs)(`option`,{value:``,children:[`Inherit workspace (`,t,`)`]}),Array.from({length:16},(e,t)=>t+Gf).map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))]})}function tp(){let e=Vt();return e.isPending?(0,X.jsx)(`p`,{"data-slot":`prompt-templates-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading prompt templates…`}):e.isError?(0,X.jsx)(R,{icon:(0,X.jsx)(ye,{}),tone:`danger`,title:`Prompt templates did not load`,subtitle:e.error.message,heading:`h2`}):(0,X.jsx)(np,{initial:yi(e.data.promptTemplates)})}function np({initial:e}){let t=o(),n=Nt(),r=Vt(),[i,a]=(0,Y.useState)(e),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(``),d=F({mutationFn:e=>wn({promptTemplates:e}),onSuccess:e=>{t.setQueryData(L.uiState,e),B(`Prompt templates saved`)},onError:e=>B(e.message,{tone:`danger`})}),f=JSON.stringify(i)!==JSON.stringify(e),p=i.some(e=>e.label.trim()===``||e.text.trim()===``),m=(e,t)=>a(n=>n.map(n=>n.id===e?{...n,...t}:n)),h=(e,t)=>a(n=>n.map(n=>{if(n.id!==e)return n;let r=n.skills??[],i=r.includes(t)?r.filter(e=>e!==t):[...r,t],{skills:a,...o}=n;return i.length>0?{...o,skills:i}:o})),g=e=>a(t=>t.filter(t=>t.id!==e));return(0,X.jsx)(`div`,{"data-slot":`prompt-templates-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:(0,X.jsxs)(ip,{title:`Reusable instructions`,hint:`Insert templates from task composers, or apply them automatically with selected skills when the prompt is empty.`,children:[(0,X.jsx)(`div`,{"data-slot":`prompt-template-list`,className:`flex flex-col gap-3`,children:i.length===0?(0,X.jsx)(`p`,{"data-slot":`prompt-templates-empty`,className:`text-[13px] text-soft-foreground`,children:`No templates. Add one below, or reset to the built-ins.`}):i.map(e=>(0,X.jsxs)(`div`,{"data-slot":`prompt-template-row`,"data-template":e.id,className:`flex flex-col gap-1.5 rounded-md border border-border bg-card p-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`label`,{htmlFor:`template-label-${e.id}`,className:`text-sm`,children:`Template label`}),(0,X.jsx)(_c,{id:`template-label-${e.id}`,"aria-label":`Label for ${e.label||`this template`}`,"data-slot":`prompt-template-label-input`,value:e.label,maxLength:80,onChange:t=>m(e.id,{label:t.target.value}),className:`flex-1`})]}),(0,X.jsx)(`label`,{htmlFor:`template-text-${e.id}`,className:`text-sm`,children:`Instructions`}),(0,X.jsx)(Br,{id:`template-text-${e.id}`,"aria-label":`Text for ${e.label||`this template`}`,"data-slot":`prompt-template-text-input`,value:e.text,maxLength:2e3,onChange:t=>m(e.id,{text:t.target.value}),className:`min-h-14 text-[13px]`}),(0,X.jsx)(`p`,{className:`mt-3 text-sm`,children:`Apply automatically with skills`}),(0,X.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5`,children:[(0,X.jsx)(rp,{label:e.label,skills:n.data??[],skillUsage:r.data?.skillUsage,selected:e.skills??[],onToggle:t=>h(e.id,t)}),(e.skills??[]).map(t=>(0,X.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skill-chip`,"data-skill":t,title:`Stop applying “${e.label}” automatically with ${t}`,onClick:()=>h(e.id,t),className:`inline-flex items-center gap-1 rounded-full border border-border bg-muted px-2 py-px font-mono text-[11px] font-medium text-foreground transition-colors hover:bg-danger/10 hover:text-danger`,children:[t,(0,X.jsx)(In,{"aria-hidden":`true`,className:`size-3`})]},t))]}),(0,X.jsx)(I,{type:`button`,className:`self-start`,variant:`outline`,size:`sm`,"data-action":`prompt-template-remove`,title:`Remove this template`,onClick:()=>g(e.id),children:`Delete template`})]},e.id))}),(0,X.jsxs)(`div`,{"data-slot":`prompt-template-new`,className:`flex flex-col gap-1.5 rounded-md border border-dashed border-border p-3`,children:[(0,X.jsx)(`h3`,{className:`text-lg`,children:`New template`}),(0,X.jsx)(`label`,{htmlFor:`new-template-label`,className:`text-sm`,children:`Label`}),(0,X.jsx)(_c,{id:`new-template-label`,"aria-label":`New template label`,"data-slot":`prompt-template-new-label`,placeholder:`e.g. Review security`,value:s,maxLength:80,onChange:e=>c(e.target.value)}),(0,X.jsx)(`label`,{htmlFor:`new-template-text`,className:`text-sm`,children:`Instructions to insert`}),(0,X.jsx)(Br,{id:`new-template-text`,"aria-label":`New template text`,"data-slot":`prompt-template-new-text`,placeholder:`Enter reusable instructions…`,value:l,maxLength:2e3,onChange:e=>u(e.target.value),className:`min-h-14 text-[13px]`}),(0,X.jsxs)(I,{type:`button`,variant:`outline`,size:`sm`,"data-action":`prompt-template-add`,disabled:!s.trim()||!l.trim(),onClick:()=>{let e=s.trim(),t=l.trim();!e||!t||(a(n=>[...n,{id:Ei(),label:e,text:t}]),c(``),u(``))},className:`self-start`,children:[(0,X.jsx)(ce,{"aria-hidden":`true`,className:`size-3.5`}),`Add template`]})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(I,{type:`button`,variant:`primary`,size:`sm`,"data-action":`prompt-templates-save`,disabled:!f||p||d.isPending,onClick:()=>d.mutate(i),children:`Save`}),(0,X.jsx)(I,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`prompt-templates-reset`,disabled:d.isPending,onClick:()=>a(Ni.map(e=>({...e}))),children:`Reset to defaults`}),p?(0,X.jsx)(`p`,{"data-slot":`prompt-templates-invalid`,className:`text-[11px] text-danger`,children:`Every template needs both a label and text.`}):null]})]})})}function rp({label:e,skills:t,skillUsage:n,selected:r,onToggle:i}){let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(``),l=(0,Y.useRef)(null),{mostUsed:u,project:d,global:f,ranked:p}=aa(t,s,n),m=(e,t)=>{let n=r.includes(e.name);return(0,X.jsxs)(K,{value:`skill ${e.name} ${e.path}`,keywords:ea(e.name,e.description),"data-slot":`prompt-template-skill-option`,"data-skill":e.name,"data-selected":n?`true`:void 0,onSelect:()=>i(e.name),children:[(0,X.jsx)(`span`,{className:U(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.description?(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,n?(0,X.jsx)(at,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},e.path)};return(0,X.jsxs)(Mr,{open:a,onOpenChange:e=>{o(e),e||c(``)},children:[(0,X.jsx)(jr,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skills-trigger`,"aria-label":`Apply ${e||`this template`} automatically with a skill`,title:`Pick the skills this template applies itself to`,disabled:t.length===0,className:U(`inline-flex h-[26px] items-center gap-1.5 rounded-full border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,r.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,X.jsx)(Ge,{"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),t.length===0?`no skills found`:`apply with…`,(0,X.jsx)(nt,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,X.jsx)(Or,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,X.jsxs)(li,{shouldFilter:!1,children:[(0,X.jsx)(oi,{placeholder:`search skills…`,value:s,onValueChange:c,onInput:()=>l.current?.scrollTo(0,0)}),(0,X.jsxs)(fi,{ref:l,"data-slot":`prompt-template-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[(p?p.length===0:u.length===0&&d.length===0&&f.length===0)?(0,X.jsx)(mi,{children:`Nothing matches.`}):null,p?p.length>0?(0,X.jsx)(q,{children:p.map(e=>m(e,ta(e)))}):null:(0,X.jsxs)(X.Fragment,{children:[u.length>0?(0,X.jsx)(q,{heading:`Most used`,children:u.map(e=>m(e,ta(e)))}):null,d.length>0?(0,X.jsx)(q,{heading:`Project skills`,children:d.map(e=>m(e,!0))}):null,f.length>0?(0,X.jsx)(q,{heading:`Global`,children:f.map(e=>m(e,!1))}):null]})]})]})})]})}function ip({title:e,hint:t,children:n}){return(0,X.jsxs)(`section`,{className:`settings-field flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,X.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t})]}),n]})}var ap=1,op=1,sp=60,cp=256;function lp(){let e=Zn();return e.isPending?(0,X.jsx)(`p`,{"data-slot":`resources-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading resource settings…`}):e.isError?(0,X.jsx)(R,{icon:(0,X.jsx)(Ht,{}),tone:`danger`,title:`Resource settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,X.jsx)(up,{config:e.data})}function up({config:e}){let t=o(),n=F({mutationFn:e=>ue(e),onSuccess:e=>t.setQueryData(P.config,e),onError:e=>B(e.message,{tone:`danger`})}),[r,i]=(0,Y.useState)(e.resources.memoryLimitMb?String(e.resources.memoryLimitMb):``),a=e.resources.monitoringWakeIntervalMinutes??null,[s,c]=(0,Y.useState)(a===null?`park`:`interval`),[l,u]=(0,Y.useState)(String(a??5)),d=Number(l),f=!Number.isInteger(d)||d<op||d>sp,p=s===`park`?a===null:!f&&a===d,m=()=>n.mutate({resources:{monitoringWakeIntervalMinutes:s===`park`?null:d}},{onSuccess:()=>B(s===`park`?`Monitoring will stay parked`:`Monitoring will re-check every ${d} minutes`)}),h=e.resources.autoResumeOnUsageLimit??!0,g=e=>n.mutate({resources:{autoResumeOnUsageLimit:e}},{onSuccess:()=>B(e?`Tasks stopped by a usage limit will resume themselves`:`Tasks stopped by a usage limit will stay failed`)}),_=r.trim()===``?0:Number(r),v=r.trim()!==``&&(!Number.isInteger(_)||_<cp),y=(e.resources.memoryLimitMb??0)===(v?-1:_),b=()=>n.mutate({resources:{memoryLimitMb:_===0?null:_}},{onSuccess:()=>B(_===0?`Memory limit cleared`:`Memory limit set to ${_} MiB`)}),x=e.composerDefaults??{autonomous:null,worktree:null,inheritedAutonomous:`source-dependent`,inheritedWorktree:!0},S=(e,t)=>n.mutate({composerDefaults:{[e]:t===`inherit`?null:t===`on`}});return(0,X.jsxs)(`div`,{"data-slot":`resources-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,X.jsxs)(Q,{title:`Max parallel tasks`,hint:`Limit simultaneously running tasks.`,children:[(0,X.jsx)(`select`,{"aria-label":`Max parallel tasks`,"data-slot":`resources-max-parallel`,value:e.resources.maxParallel,disabled:n.isPending,onChange:e=>n.mutate({resources:{maxParallel:Number(e.target.value)}}),className:`block w-28 rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:Array.from({length:16},(e,t)=>t+ap).map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))}),(0,X.jsxs)(`p`,{className:`text-[11px] text-soft-foreground`,children:[`Need a different limit for one project?`,` `,(0,X.jsx)(z,{to:`/settings/global/projects`,"data-slot":`resources-project-limits-link`,className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground`,children:`Configure per-project limits`}),`.`]})]}),(0,X.jsxs)(Q,{title:`Extra monitoring sessions`,hint:`Additional capacity reserved for monitoring.`,children:[(0,X.jsx)(`select`,{"aria-label":`Extra monitoring sessions`,"data-slot":`resources-max-monitoring`,value:e.resources.maxMonitoringSessions??2,disabled:n.isPending,onChange:e=>n.mutate({resources:{maxMonitoringSessions:Number(e.target.value)}}),className:`block w-28 rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:Array.from({length:17},(e,t)=>(0,X.jsx)(`option`,{value:t,children:t},t))}),(0,X.jsxs)(`p`,{className:`text-[11px] text-soft-foreground`,children:[`Capacity: `,e.resources.maxParallel,` active + `,e.resources.maxMonitoringSessions??2,` monitoring. Set 0 to make monitoring share active slots.`]})]}),(0,X.jsxs)(Q,{title:`Monitoring wake-up`,hint:`Wake monitoring sessions periodically.`,children:[(0,X.jsxs)(`div`,{className:`settings-resource-controls flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(Xd,{"aria-label":`Monitoring wake-up`,"data-slot":`resources-monitoring-wake-mode`,checked:s===`interval`,disabled:n.isPending,onCheckedChange:e=>c(e?`interval`:`park`)}),s===`interval`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`label`,{htmlFor:`monitoring-wake-interval`,className:`w-full text-sm`,children:`Wake interval`}),(0,X.jsx)(`input`,{id:`monitoring-wake-interval`,type:`number`,min:op,max:sp,"aria-label":`Wake interval in minutes`,"data-slot":`resources-monitoring-wake-interval`,value:l,disabled:n.isPending,onChange:e=>u(e.target.value),className:`block w-24 rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`}),(0,X.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`minutes`})]}):null,(0,X.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,"data-action":`resources-save-monitoring-wake`,disabled:p||s===`interval`&&f||n.isPending,onClick:m,children:`Save`})]}),s===`interval`&&f?(0,X.jsx)(`p`,{"data-slot":`resources-monitoring-wake-invalid`,className:`text-[11px] text-danger`,children:`Enter a whole number from 1 to 60 minutes.`}):(0,X.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Applied consistently to Claude, Codex and OpenCode.`})]}),(0,X.jsxs)(Q,{title:`Auto-resume after a usage limit`,hint:`Resume eligible tasks once the provider usage limit resets.`,children:[(0,X.jsx)(Xd,{"aria-label":`Auto-resume after a usage limit`,"data-slot":`resources-auto-resume`,checked:h,disabled:n.isPending,onCheckedChange:g}),(0,X.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Applies to Claude, Codex and OpenCode — whenever the provider says when the limit lifts.`})]}),(0,X.jsxs)(Q,{title:`Per-task memory limit`,hint:`Leave blank for no limit.`,children:[(0,X.jsxs)(`div`,{className:`settings-resource-controls flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`number`,inputMode:`numeric`,min:cp,step:256,"aria-label":`Per-task memory limit in MiB`,"data-slot":`resources-memory-limit`,value:r,disabled:n.isPending,placeholder:`no limit`,onChange:e=>i(e.target.value),className:`block w-32 rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`}),(0,X.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`MiB`}),(0,X.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,"data-action":`resources-save-memory`,disabled:y||v||n.isPending,onClick:b,children:`Save`})]}),v?(0,X.jsxs)(`p`,{"data-slot":`resources-memory-invalid`,className:`text-[11px] text-danger`,children:[`Enter a whole number of at least `,cp,` MiB, or leave empty for no limit.`]}):(0,X.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Applies to newly started tasks.`})]}),(0,X.jsxs)(Q,{title:`New task defaults`,hint:`Apply to new tasks unless overridden.`,children:[(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,"data-slot":`resources-composer-defaults`,children:[(0,X.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Autonomous by default`}),(0,X.jsxs)(`select`,{"aria-label":`Autonomous by default`,value:x.autonomous===null?`inherit`:x.autonomous?`on`:`off`,disabled:n.isPending,onChange:e=>S(`autonomous`,e.target.value),className:`rounded-md border border-input bg-card px-3 py-1.5 shadow-xs outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:[(0,X.jsx)(`option`,{value:`inherit`,children:`Inherit environment`}),(0,X.jsx)(`option`,{value:`on`,children:`On`}),(0,X.jsx)(`option`,{value:`off`,children:`Off`})]}),(0,X.jsxs)(`span`,{className:`text-[11px] text-soft-foreground`,children:[`Inherited: `,x.inheritedAutonomous===`source-dependent`?`Source-dependent — skills on, workflows off`:x.inheritedAutonomous?`On`:`Off`]})]}),(0,X.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Use a worktree by default`}),(0,X.jsxs)(`select`,{"aria-label":`Use a worktree by default`,value:x.worktree===null?`inherit`:x.worktree?`on`:`off`,disabled:n.isPending,onChange:e=>S(`worktree`,e.target.value),className:`rounded-md border border-input bg-card px-3 py-1.5 shadow-xs outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:[(0,X.jsx)(`option`,{value:`inherit`,children:`Inherit environment`}),(0,X.jsx)(`option`,{value:`on`,children:`On`}),(0,X.jsx)(`option`,{value:`off`,children:`Off`})]}),(0,X.jsxs)(`span`,{className:`text-[11px] text-soft-foreground`,children:[`Inherited: `,x.inheritedWorktree?`On`:`Off`]})]})]}),(0,X.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Interactive skills may recommend both off. Multi-step and parallel runs remain isolated.`})]})]})}function dp(){let e=Zn(),t=M().data?.bootProject??``,n=bn(t,!!t);return e.isPending?(0,X.jsx)(`p`,{"data-slot":`skills-settings-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading skill settings…`}):e.isError?(0,X.jsx)(R,{icon:(0,X.jsx)(uc,{}),tone:`danger`,title:`Skill settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,X.jsx)(fp,{projectId:t,config:e.data,update:n.data,updateError:n.error})}function fp({projectId:e,config:t,update:n,updateError:r}){let i=o(),a=F({mutationFn:e=>ue(e),onSuccess:e=>i.setQueryData(P.config,e),onError:e=>B(e.message,{tone:`danger`})}),s=t.skillsAutoUpdate===null,c=(()=>{if(r)return`Installation status is unavailable right now.`;if(!n)return`Checking tracked Open Mercato installations…`;if(n.status===`unavailable`)return n.scopes.find(e=>e.reason)?.reason??`Automatic skill updates are unavailable.`;if(n.scopes.every(e=>e.skills.length===0))return`No tracked Open Mercato installation found.`;let e=new Set(n.scopes.flatMap(e=>e.skills)).size;return n.status===`current`?`${e} tracked skill${e===1?``:`s`} · Up to date`:`${e} tracked Open Mercato skill${e===1?``:`s`} found.`})();return(0,X.jsx)(`div`,{"data-slot":`skills-settings-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-4 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:(0,X.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:(0,X.jsx)(`label`,{htmlFor:`skills-auto-update`,children:`Update Open Mercato skills automatically`})}),(0,X.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Checks installed Open Mercato skills in the background and applies available updates. Other skills and untracked folders are never changed.`})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[(0,X.jsx)(Xd,{id:`skills-auto-update`,"data-slot":`skills-auto-update`,checked:t.effectiveSkillsAutoUpdate,disabled:a.isPending,onCheckedChange:e=>a.mutate({skillsAutoUpdate:e})}),(0,X.jsxs)(`span`,{className:`text-[11px] text-soft-foreground`,children:[t.effectiveSkillsAutoUpdate?`On`:`Off`,s?` (default)`:``]})]})]}),(0,X.jsx)(`h3`,{className:`mt-4 text-lg`,children:`Installation status`}),(0,X.jsx)(`p`,{"data-slot":`skills-installation-status`,role:r||n?.status===`unavailable`?`status`:void 0,className:n?.status===`current`&&n.scopes.some(e=>e.skills.length>0)?`text-[13px] text-success`:`text-[13px] text-soft-foreground`,children:c}),(0,X.jsx)(`p`,{className:`mt-3 text-[13px] text-muted-foreground`,children:`Manage installed skills and sources from the Skills catalog.`}),e?(0,X.jsx)(I,{asChild:!0,variant:`outline`,className:`mt-2 self-start`,children:(0,X.jsx)(z,{to:`/p/${encodeURIComponent(e)}/skills`,children:`Open Skills`})}):null,(0,X.jsxs)(`details`,{className:`settings-disclosure`,children:[(0,X.jsx)(`summary`,{children:`Update preference inheritance`}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-md border border-border bg-muted/30 px-3 py-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{children:s?`No override is saved. CEZ_SKILLS_AUTO_UPDATE supplies the inherited default when set; otherwise it is on.`:`An explicit workspace override is saved.`}),(0,X.jsx)(I,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`skills-use-default`,disabled:s||a.isPending,onClick:()=>a.mutate({skillsAutoUpdate:null}),children:`Use default`})]})]})]})})}function pp(){let e=Yn(),t=Yt().data?.targets.find(e=>e.id===`finder`),n=F({mutationFn:e=>je(e,t.id),onError:e=>B(e.message,{tone:`danger`})}),r=o(),[i,a]=(0,Y.useState)(null),s=()=>r.invalidateQueries({queryKey:L.worktrees}),l=F({mutationFn:()=>rt(),onSuccess:e=>{s(),B(e.reclaimed.length===0?`Nothing to reclaim — all worktrees are within the limit`:`Reclaimed ${e.reclaimed.length} worktree${e.reclaimed.length===1?``:`s`} (branch kept)`)},onError:e=>B(e.message,{tone:`danger`})}),u=F({mutationFn:e=>ke(e),onSuccess:()=>{s(),B(`Worktree removed`)},onError:e=>B(e.message,{tone:`danger`})});if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,X.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-[13px] text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:d,totalBytes:f,keep:p}=e.data,m=l.isPending||u.isPending;return(0,X.jsxs)(`div`,{"data-slot":`worktrees-panel`,className:`flex flex-col gap-3`,children:[d.length===0?(0,X.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`text-[13px] text-soft-foreground`,children:`No task worktrees on disk.`}):(0,X.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border`,children:(0,X.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,X.jsx)(`caption`,{className:`sr-only`,children:`Task worktrees currently materialized on disk`}),(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{className:`border-b border-border text-left text-[12px] text-soft-foreground`,children:[(0,X.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Task`}),(0,X.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Status`}),(0,X.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Size`}),(0,X.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Age`}),(0,X.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium text-right`,children:`Actions`})]})}),(0,X.jsx)(`tbody`,{children:d.map(e=>(0,X.jsx)(mp,{worktree:e,disabled:m,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onDelete:()=>a({kind:`delete`,runId:e.runId,title:e.title})},e.runId))})]})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`p`,{"data-slot":`worktrees-footer`,className:`text-[12px] text-soft-foreground`,children:[d.length,` worktree`,d.length===1?``:`s`,f===null?` · size unavailable`:` · ${c(f)||`0 kB`} on disk`,` · `,p===0?`keeping all (unlimited)`:`keeping the last ${p}`]}),(0,X.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,"data-action":`worktrees-reclaim-now`,disabled:m,onClick:()=>a({kind:`reclaim`}),children:`Reclaim now`})]}),(0,X.jsx)(Nn,{open:i!==null,onOpenChange:e=>!e&&a(null),children:(0,X.jsxs)(Ut,{children:[(0,X.jsxs)(An,{children:[(0,X.jsx)(xt,{children:i?.kind===`delete`?`Delete this worktree?`:`Reclaim old worktrees?`}),(0,X.jsx)(mt,{children:i?.kind===`delete`?(0,X.jsxs)(X.Fragment,{children:[`This removes the worktree directory and its branch — the local-only work is not recoverable afterwards.`,(0,X.jsx)(`span`,{className:`mt-1 block truncate font-medium text-foreground`,title:i.title,children:i.title})]}):`Finished worktrees beyond the keep-limit are reclaimed now (directory only). Their branches are kept, so the work stays recoverable.`})]}),(0,X.jsxs)(mn,{children:[(0,X.jsx)(Dn,{children:`Keep it`}),(0,X.jsx)(un,{"data-action":`worktrees-confirm`,className:i?.kind===`delete`?`bg-danger text-danger-foreground hover:brightness-[0.96]`:void 0,onClick:()=>{i?.kind===`reclaim`?l.mutate():i?.kind===`delete`&&u.mutate(i.runId),a(null)},children:i?.kind===`delete`?`Delete`:`Reclaim now`})]})]})})]})}function mp({worktree:e,disabled:t,onOpen:n,opening:r,onDelete:i}){return(0,X.jsxs)(`tr`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`th`,{scope:`row`,className:`max-w-[220px] px-3 py-2 text-left font-normal`,children:[(0,X.jsx)(`span`,{className:`block truncate text-foreground`,title:e.title,children:e.title}),(0,X.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-soft-foreground`,children:e.branch??e.runId.slice(0,8)})]}),(0,X.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`text-[12px] text-soft-foreground`,children:e.status}),e.reclaimable?(0,X.jsx)(`span`,{"data-slot":`worktree-reclaimable`,className:`ml-1 text-[11px] text-soft-foreground`,children:`(reclaimable)`}):null]}),(0,X.jsx)(`td`,{className:`px-3 py-2 tabular-nums text-soft-foreground`,children:e.sizeBytes===null?`—`:c(e.sizeBytes)||`0 kB`}),(0,X.jsx)(`td`,{className:`px-3 py-2 tabular-nums text-soft-foreground`,children:Yi(e.finishedAt??void 0)||`—`}),(0,X.jsxs)(`td`,{className:`px-3 py-2 text-right`,children:[n?(0,X.jsx)(I,{variant:`outline`,className:`mr-2`,"aria-label":`Open folder for ${e.title}`,disabled:r,onClick:n,children:`Open folder`}):null,(0,X.jsx)(I,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`worktree-delete`,"aria-label":`Delete the worktree for ${e.title}`,disabled:t,onClick:i,children:`Delete`})]})]})}var hp=0,gp=1e3;function _p(){let e=Mt();return e.isPending?(0,X.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading worktree settings…`}):e.isError?(0,X.jsx)(R,{icon:(0,X.jsx)(tc,{}),tone:`danger`,title:`Worktree settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,X.jsx)(vp,{config:e.data})}function vp({config:e}){let t=o(),n=F({mutationFn:e=>k(e),onSuccess:e=>t.setQueryData(L.config,e),onError:e=>B(e.message,{tone:`danger`})}),[r,i]=(0,Y.useState)(String(e.worktreeRetention)),a=Number(r),s=r.trim()===``||!Number.isInteger(a)||a<hp||a>gp,c=e.worktreeRetention===(s?-1:a);return(0,X.jsxs)(`div`,{"data-slot":`worktrees-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,X.jsxs)(Q,{title:`Keep last N worktrees`,hint:`Older finished worktrees are reclaimed to free disk; their branch is kept so the work stays recoverable. 0 = unlimited. In-review and running tasks are never reclaimed, so the count on disk can exceed this.`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`number`,inputMode:`numeric`,min:hp,max:gp,step:1,"aria-label":`Keep last N finished worktrees`,"data-slot":`resources-worktree-retention`,value:r,disabled:n.isPending,onChange:e=>i(e.target.value),className:`block w-32 rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`}),(0,X.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`worktrees`}),(0,X.jsx)(I,{type:`button`,variant:`primary`,size:`sm`,className:`self-start`,"data-action":`resources-save-retention`,disabled:c||s||n.isPending,onClick:()=>n.mutate({worktreeRetention:a},{onSuccess:()=>{t.invalidateQueries({queryKey:L.worktrees}),B(a===0?`Keeping all worktrees (unlimited)`:`Keeping the last ${a} finished worktree${a===1?``:`s`}`)}}),children:`Save retention`})]}),s?(0,X.jsxs)(`p`,{"data-slot":`resources-retention-invalid`,className:`text-[11px] text-danger`,children:[`Enter a whole number from `,hp,` to `,gp,` (0 = unlimited).`]}):(0,X.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:a===0?`Keeping every finished worktree.`:`Keeping the last ${a} finished worktree${a===1?``:`s`} on disk.`})]}),(0,X.jsx)(Q,{title:`Worktrees on disk`,hint:`Task worktrees currently on disk. Delete one to reclaim its space now, or reclaim everything past the keep-limit at once. Branches are always kept, so the work stays recoverable.`,children:(0,X.jsx)(pp,{})})]})}function yp(e,t){return function(){return(0,X.jsx)(R,{icon:(0,X.jsx)(t,{}),tone:`neutral`,title:e,subtitle:`This section arrives in a later phase of the redesign.`,heading:`h2`})}}var bp=[{id:`agents`,title:`Agents`,description:`Default runner, models and system prompt.`,icon:le,component:rf,scope:`project`},{id:`agent-config`,title:`Agent config`,description:`Edit the coding agents’ own config files, per scope.`,icon:ec,component:Gd,scope:`project`},{id:`worktrees`,title:`Worktrees`,description:`How many finished task worktrees this project keeps on disk.`,icon:tc,component:_p,scope:`project`},{id:`bookmarklets`,title:`Bookmarklets`,description:`Launch skills from a GitHub PR or issue.`,icon:Vs,component:Pf,scope:`project`},{id:`prompt-templates`,title:`Prompt templates`,description:`Reusable snippets for follow-up instructions.`,icon:ye,component:tp,scope:`project`},{id:`appearance`,title:`Appearance`,description:`Theme, accent and density.`,icon:Ce,component:jf,scope:`global`},{id:`notifications`,title:`Notifications`,description:`Browser notifications when an agent needs you.`,icon:Sn,component:Hf,scope:`global`},{id:`resources`,title:`Resources`,description:`Parallel tasks and per-task memory limit, across every project.`,icon:vt,component:lp,scope:`global`},{id:`skills`,title:`Skills`,description:`Updates for skills installed on this machine.`,icon:Ge,component:dp,scope:`global`},{id:`accounts`,title:`Agent accounts`,description:`Second logins, and the agent and models a project uses when it has chosen none.`,icon:Be,component:kd,scope:`global`},{id:`projects`,title:`Projects`,description:`The workspace registry and where GitHub checkouts land.`,icon:ln,component:Jf,scope:`global`},{id:`keyboard`,title:`Keyboard`,description:`Shortcuts.`,icon:ic,component:yp(`Keyboard`,ic),scope:`global`,hidden:!0}];function xp(e,t){return bp.filter(n=>!n.hidden&&n.scope===e&&!(t?.singleProject===!0&&n.id===`projects`))}function Sp(){let e=Ki(),t=M().data;return e===null?null:t?.projects.find(t=>t.id===e)?.root??null}function Cp(e){navigator.clipboard.writeText(e).then(()=>B(`Project folder copied`)).catch(()=>B(e))}function wp(){let e=Sp();return e===null?null:(0,X.jsx)(Q,{title:`Project folder`,hint:`Where this project lives on disk. Every task worktree, git command and agent run resolves against it.`,children:(0,X.jsxs)(`div`,{"data-slot":`project-location`,"data-variant":`field`,className:`flex flex-col gap-3`,children:[(0,X.jsx)(`span`,{"data-slot":`project-location-path`,className:`w-full min-w-0 rounded-md border border-border bg-background p-3 text-[13px] break-all text-foreground`,children:e}),(0,X.jsxs)(`div`,{className:`flex w-full flex-wrap items-center gap-2 border-t border-border pt-4`,children:[(0,X.jsxs)(`button`,{type:`button`,"data-action":`project-location-copy`,title:`Copy the project folder path`,onClick:()=>Cp(e),className:`inline-flex min-h-11 items-center gap-2 rounded-md border border-border bg-card px-3 text-xs text-foreground transition-colors hover:bg-muted`,children:[(0,X.jsx)(Kt,{"aria-hidden":`true`,className:`size-4`}),`Copy path`]}),(0,X.jsx)(Ep,{root:e})]})]})})}function Tp(){let e=Sp();return e===null?null:(0,X.jsxs)(`div`,{"data-slot":`project-location`,"data-variant":`nav`,className:`mt-auto px-2.5 pt-3`,children:[(0,X.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Project folder`}),(0,X.jsx)(`button`,{type:`button`,"data-action":`project-location-copy`,title:`${e} — click to copy`,onClick:()=>Cp(e),className:`block w-full truncate text-left font-mono text-[11px] text-muted-foreground transition-colors hover:text-foreground`,children:e})]})}function Ep({root:e}){let t=Yt(),n=F({mutationFn:e=>ae(e),onError:e=>B(e.message,{tone:`danger`})}),r=(t.data?.targets??[]).filter(e=>ri(e.id)===void 0).map(e=>({target:e}));return r.length===0?null:(0,X.jsx)(ti,{slot:`project-location-open`,label:`Open with`,triggerVariant:`outline`,title:e,disabled:n.isPending,choices:r,onPick:e=>n.mutate(e,{onSuccess:()=>B(`Opening the project folder in ${r.find(t=>t.target.id===e)?.target.label??e}`)})})}function Dp(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}function Op({capabilities:e}){let t=Ki(),n=M(),r=Zn();if(n.isPending)return(0,X.jsx)(`p`,{"data-slot":`project-general-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading project…`});if(n.isError)return(0,X.jsxs)(`p`,{"data-slot":`project-general-error`,className:`text-[13px] text-danger`,children:[`Could not read the project registry — `,n.error.message]});let i=n.data,a=i?.projects.find(e=>e.id===t);if(!i||!a)return null;let o=e?.singleProject!==!0;return(0,X.jsxs)(`div`,{"data-slot":`project-general`,className:`flex w-full flex-col gap-5`,children:[(0,X.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,X.jsx)(`h2`,{className:`text-lg font-semibold`,children:`General`}),(0,X.jsx)(wp,{}),(0,X.jsx)(kp,{project:a,canRemove:o}),o?(0,X.jsx)(X.Fragment,{children:(0,X.jsx)(Q,{title:`Max parallel tasks`,hint:r.data?`The workspace limit (${r.data.resources.maxParallel}) still applies as an overall ceiling.`:`How many of this project's tasks may run at once. The workspace limit still applies as an overall ceiling.`,children:r.data?(0,X.jsx)(ep,{project:a,workspaceMax:r.data.resources.maxParallel}):(0,X.jsx)(`p`,{className:`text-[13px] text-soft-foreground`,children:`Loading the workspace limit…`})})}):null]}),o?(0,X.jsx)(`section`,{className:`rounded-lg border border-border bg-card p-5`,children:(0,X.jsx)(Ap,{project:a,bootProject:i.bootProject})}):null]})}function kp({project:e,canRemove:t}){return(0,X.jsxs)(`dl`,{"data-slot":`project-facts`,className:`grid grid-cols-1 gap-4 text-[13px] sm:grid-cols-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Project`}),(0,X.jsx)(`dd`,{className:`mt-1 font-medium`,children:e.name})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Branch`}),(0,X.jsx)(`dd`,{className:`mt-1 break-all`,children:e.branch??`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Status`}),(0,X.jsxs)(`dd`,{"data-slot":`project-general-status`,className:e.status===`missing`?`mt-1 text-danger`:`mt-1`,children:[Kf[e.status],e.status===`missing`?t?` — remove it below, or restore the folder`:` — restore the folder at the path above`:null]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Added`}),(0,X.jsxs)(`dd`,{className:`mt-1`,children:[Dp(e.addedAt),(0,X.jsx)(`span`,{className:`text-soft-foreground`,children:e.source===`checkout`?` · cloned from GitHub`:` · opened locally`})]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Last opened`}),(0,X.jsx)(`dd`,{className:`mt-1`,children:Dp(e.lastOpenedAt)})]})]})}function Ap({project:e,bootProject:t}){let[n,r]=(0,Y.useState)(null),i=Uf(),a=Fe(),o=e.id===t;return(0,X.jsxs)(Q,{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,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsxs)(I,{type:`button`,variant:`outline`,size:`sm`,"data-action":`project-general-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:o?`cezar is serving this project — it re-registers itself at every start`:void 0,disabled:o||i.isPending,onClick:()=>r(e),className:`text-danger`,children:[`Remove `,e.name]}),o?(0,X.jsx)(`span`,{"data-slot":`project-general-remove-boot`,className:`text-[11px] text-soft-foreground`,children:`cezar is serving this project — it re-registers itself at every start.`}):null]}),(0,X.jsx)(Wf,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{r(null),i.confirm(e,()=>void a(`/p/${encodeURIComponent(t)}`))}})]})}function jp(e,t){return e===`global`?`/settings/global/${t}`:`/settings/${t}`}function Mp(e){return e===`global`?`/settings/global`:`/settings`}function Np(e){return e===`global`?{Link:z,NavLink:zt}:{Link:J,NavLink:Ui}}function Pp({scope:e,activeId:t,capabilities:n}){let{NavLink:r}=Np(e);return(0,X.jsxs)(`nav`,{"aria-label":`Settings sections`,"data-slot":`settings-nav`,"data-scope":e,className:`hidden w-[180px] shrink-0 flex-col gap-1 md:flex`,children:[(0,X.jsx)(r,{to:Mp(e),end:!0,"data-slot":`settings-nav-index`,"aria-current":t===null?`page`:void 0,className:U(`flex min-h-11 items-center gap-2.5 rounded-md px-2.5 py-2 text-[13px] font-medium transition-colors`,t===null?`bg-accent-strong/10 text-accent-text`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:`General`}),xp(e,n).map(n=>(0,X.jsx)(r,{to:jp(e,n.id),"data-section":n.id,"aria-current":n.id===t?`page`:void 0,className:U(`flex min-h-11 items-center gap-2.5 rounded-md px-2.5 py-2 text-[13px] font-medium transition-colors`,n.id===t?`bg-accent-strong/10 text-accent-text`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:n.title},n.id)),e===`global`?(0,X.jsx)(`p`,{className:`mt-auto px-2.5 pt-3 text-[11px] text-soft-foreground`,children:`Stored in ~/.cezar`}):(0,X.jsx)(Tp,{})]})}function Fp({scope:e,activeId:t,capabilities:n}){let{NavLink:r}=Np(e),i=xp(e,n);return(0,X.jsxs)(`details`,{className:`settings-section-picker md:hidden`,children:[(0,X.jsxs)(`summary`,{children:[i.find(e=>e.id===t)?.title??`General`,(0,X.jsx)(nt,{"aria-hidden":`true`,className:`size-5 text-muted-foreground`})]}),(0,X.jsxs)(`nav`,{"aria-label":`Settings sections`,"data-slot":`settings-nav-mobile`,children:[(0,X.jsx)(r,{to:Mp(e),end:!0,"data-slot":`settings-nav-index`,children:`General`}),i.map(t=>(0,X.jsx)(r,{to:jp(e,t.id),"data-section":t.id,children:t.title},t.id))]})]},`${e}-${t}`)}function Ip({section:e,scope:t,capabilities:n}){let r=e.component;return(0,X.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,X.jsxs)(`header`,{className:`settings-route-header flex shrink-0 flex-col gap-2`,children:[(0,X.jsx)(`h1`,{className:`text-[28px] font-semibold tracking-tight`,children:t===`global`?`Global settings`:`Project settings`}),(0,X.jsx)(`p`,{className:`text-[13px] text-soft-foreground`,children:t===`global`?`Preferences for you and this machine, shared by every project.`:`Configure this project and its agents.`}),t===`global`?(0,X.jsx)(`span`,{"data-slot":`settings-scope-chip`,className:`sr-only`,children:`Global settings`}):null]}),(0,X.jsxs)(`div`,{className:`settings-route-body flex min-w-0 flex-1 flex-col md:flex-row`,children:[(0,X.jsx)(Pp,{scope:t,activeId:e.id,capabilities:n}),(0,X.jsx)(Fp,{scope:t,activeId:e.id,capabilities:n}),(0,X.jsxs)(`section`,{className:`settings-panel min-w-0 self-start md:flex-1`,"aria-label":e.title,children:[(0,X.jsx)(`h2`,{className:`settings-panel-title`,children:e.title}),(0,X.jsx)(r,{})]})]})]})}function Lp({scope:e,capabilities:t}){let{Link:n}=Np(e),r=e===`global`;return(0,X.jsxs)(`div`,{"data-route":r?`settings-global`:`settings`,className:`settings-route mx-auto flex min-h-full w-full flex-col`,children:[(0,X.jsxs)(`header`,{className:`settings-route-header flex shrink-0 flex-col gap-2`,children:[(0,X.jsx)(`h1`,{className:`text-[28px] font-semibold tracking-tight`,children:r?`Global settings`:`Project settings`}),(0,X.jsx)(`p`,{className:`text-[13px] text-soft-foreground`,children:r?`Preferences for you and this machine, shared by every project.`:`Configure this project and its agents.`})]}),(0,X.jsxs)(`div`,{className:`settings-route-body flex min-w-0 flex-1 flex-col md:flex-row`,children:[(0,X.jsx)(Pp,{scope:e,activeId:null,capabilities:t}),(0,X.jsx)(Fp,{scope:e,activeId:null,capabilities:t}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[r?(0,X.jsxs)(`section`,{className:`mb-5 rounded-lg border border-border bg-card p-5`,children:[(0,X.jsx)(`span`,{className:`inline-flex rounded bg-accent-strong/10 px-2 py-1 text-[11px] text-accent-text`,children:`Stored locally · ~/.cezar`}),(0,X.jsx)(`p`,{className:`mt-4 text-[13px] text-muted-foreground`,children:`Changes here apply across every connected project. Agent instructions and worktree settings remain project-specific.`})]}):(0,X.jsx)(Op,{capabilities:t}),r?null:(0,X.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,X.jsx)(`ul`,{"data-slot":`settings-index`,className:U(`flex w-full flex-col gap-5`,r?null:`mt-7 md:hidden`),children:xp(e,t).map(t=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(n,{to:jp(e,t.id),"data-section":t.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,X.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center text-accent-text`,children:(0,X.jsx)(t.icon,{"aria-hidden":`true`,className:`size-4`})}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:t.title}),(0,X.jsx)(`span`,{className:`block text-xs text-soft-foreground`,children:t.description})]}),(0,X.jsx)(ct,{"aria-hidden":`true`,className:`size-4 shrink-0 text-soft-foreground`})]})},t.id))}),(0,X.jsx)(`p`,{className:`mt-5 w-full text-[12px] text-soft-foreground`,children:r?(0,X.jsx)(X.Fragment,{children:`Agents, worktrees, bookmarklets and prompt templates are per project.`}):(0,X.jsxs)(X.Fragment,{children:[`Appearance, notifications, host resources and the project registry live in`,` `,(0,X.jsx)(z,{to:Mp(`global`),"data-slot":`settings-global-link`,className:`underline underline-offset-2 hover:text-foreground`,children:`Global settings`}),`.`]})})]})]})]})}function Rp({delayDuration:e=0,...t}){return(0,X.jsx)(Ns,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function zp({...e}){return(0,X.jsx)(Ps,{"data-slot":`tooltip`,...e})}function Bp({...e}){return(0,X.jsx)(Fs,{"data-slot":`tooltip-trigger`,...e})}function Vp({className:e,sideOffset:t=0,children:n,...r}){return(0,X.jsx)(Is,{children:(0,X.jsxs)(Ls,{"data-slot":`tooltip-content`,sideOffset:t,className:U(`z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-contrast px-3 py-1.5 text-xs text-balance text-contrast-foreground fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,e),...r,children:[n,(0,X.jsx)(Rs,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-contrast fill-contrast`})]})})}var Hp=[{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`}],Up=new Map(Hp.map(e=>[e.id,e]));function Wp(e){return typeof e!=`object`||!e||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`boolean`))}function Gp(e){let t={};for(let[n,r]of Object.entries(Wp(e))){let e=Up.get(n);e?.canFold&&(t[e.id]=r)}return t}function Kp(e,t){let n=Up.get(e);return!n||!n.canFold?!0:t[e]??n.defaultExpanded}function qp(e,t){let n=Wp(e);return Up.get(t)?.canFold?{...n,[t]:!Kp(t,Gp(e))}:n}function Jp(e){return Hp.filter(t=>t.capability===void 0||e[t.capability])}function Yp(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function Xp(){let e=o(),t=bt(),n=Y.useRef(0),r=Y.useRef(0),i=Y.useRef(Promise.resolve()),a=Y.useMemo(()=>Gp(t.data?.taskTable?.expandedColumns),[t.data?.taskTable?.expandedColumns]),s=Y.useCallback(t=>{if(!Hp.find(e=>e.id===t)?.canFold)return;let a=e.getQueryData(P.uiState);if(a===void 0)return;let o=Yp(a?.taskTable),s={...o,expandedColumns:qp(o.expandedColumns,t)};e.setQueryData(P.uiState,{...a,taskTable:s});let c=++n.current;r.current=c;let l=i.current.then(async()=>{let t=await ot({taskTable:s},{keepalive:!0});c===r.current&&e.setQueryData(P.uiState,t)});i.current=l.catch(t=>{B(t instanceof Error?t.message:String(t),{tone:`danger`}),c===r.current&&e.invalidateQueries({queryKey:P.uiState})})},[e]);return{expandedColumns:a,isExpanded:Y.useCallback(e=>Kp(e,a),[a]),toggleColumn:s,isPending:t.isPending}}function Zp({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=Gp(void 0),onToggleColumn:f=()=>void 0,columnsPending:p=!1,projectName:m,error:h,onRetry:g}){let[_,v]=Y.useState(``),[y,b]=Y.useState(!1),S=Y.useRef(null),ee=Y.useRef(!1),[w,te]=Y.useState(!1);Y.useEffect(()=>{let e=window.matchMedia?.(`(min-width: 768px)`);if(!e)return;let t=()=>{e.matches&&te(!1)};return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let T=e??[],E=We(T),D=Tn(x(T,_),t),ne=tt(T),re=C(x(T,_),t),ie=Ee(T),ae=Jp({tokens:l,cost:u}),oe=qr(T),se=t===`archived`?void 0:s;return(0,X.jsxs)(`div`,{"data-route":`tasks`,"data-presentation":y?`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,X.jsxs)(`header`,{ref:S,className:`flex shrink-0 flex-col gap-[22px]`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h1`,{className:`text-[30px] font-semibold tracking-tight`,children:`Project tasks`}),(0,X.jsxs)(`p`,{className:`text-[13px] text-muted-foreground`,children:[m?`${m} · `:``,y?`Every resource column shown. Fold columns without losing the saved view.`:`Review runs, pull requests and resource usage.`]})]}),(0,X.jsxs)(`div`,{className:`flex gap-6 border-b border-border`,children:[(0,X.jsx)(tm,{view:`active`,current:t,onSelect:n,count:E.active,children:`Active`}),(0,X.jsx)(tm,{view:`archived`,current:t,onSelect:n,count:E.archived,children:`Archived`})]}),(0,X.jsxs)(`div`,{"data-slot":`tasks-toolbar`,className:`flex flex-wrap items-center gap-2.5`,children:[oe>0?(0,X.jsxs)(I,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`mark-all-read`,className:`hidden md:inline-flex`,onClick:a,children:[(0,X.jsx)(Hs,{className:`size-3.5`,"aria-hidden":`true`}),`Mark all read`]}):null,t===`active`&&ie>0?(0,X.jsxs)(I,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`archive-finished`,className:`inline-flex`,disabled:i,"aria-busy":i,onClick:r,children:[(0,X.jsx)(Ke,{className:`size-3.5`,"aria-hidden":`true`}),`Archive finished`]}):null,t===`active`&&(ie>0||i)?(0,X.jsxs)(wr,{open:w,onOpenChange:te,children:[(0,X.jsx)(br,{asChild:!0,children:(0,X.jsx)(I,{type:`button`,variant:`ghost`,size:`icon`,className:`md:hidden`,"aria-label":`Task actions`,"aria-busy":i,children:(0,X.jsx)(Qs,{"aria-hidden":`true`})})}),(0,X.jsx)(Cr,{align:`end`,className:`md:hidden`,onCloseAutoFocus:e=>{(ee.current||window.matchMedia?.(`(min-width: 768px)`).matches)&&(e.preventDefault(),ee.current=!1,S.current?.querySelector(`[data-view="active"]`)?.focus())},children:(0,X.jsxs)(yr,{disabled:i||ie===0,onSelect:()=>{ee.current=!0,r()},children:[(0,X.jsx)(Ke,{"aria-hidden":`true`}),i?`Archiving…`:`Archive finished`]})})]}):null,(0,X.jsxs)(`div`,{className:`relative order-first w-full md:w-auto md:flex-1`,children:[(0,X.jsx)(Pe,{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,X.jsx)(`input`,{type:`text`,value:_,onChange:e=>v(e.target.value),placeholder:`Search tasks…`,"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,X.jsxs)(Mr,{children:[(0,X.jsx)(jr,{asChild:!0,children:(0,X.jsx)(I,{"data-slot":`task-columns-trigger`,variant:`outline`,className:`hidden min-h-11 md:inline-flex`,children:`Columns`})}),(0,X.jsxs)(Or,{align:`end`,className:`w-72`,children:[(0,X.jsx)(`h2`,{className:`mb-2 text-base font-medium`,children:`Visible columns`}),(0,X.jsx)(`p`,{className:`mb-4 text-xs text-muted-foreground`,children:`Status and Task · Always visible`}),(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:ae.filter(e=>e.canFold).map(e=>(0,X.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,X.jsx)(`input`,{"data-column-toggle":e.id,type:`checkbox`,checked:Kp(e.id,d),disabled:p,onChange:()=>f(e.id)}),e.id===`diff`?`Diff`:e.id===`reference`?`Reference`:e.id===`memory`?`Memory`:e.label]},e.id))}),(0,X.jsx)(`p`,{className:`mt-4 text-xs text-muted-foreground`,children:`Saved automatically. Tokens and cost appear only when supported.`}),(0,X.jsx)(I,{variant:`outline`,className:`mt-4`,onClick:()=>b(e=>!e),children:y?`Summary view`:`Resource columns`})]})]}),(0,X.jsx)(I,{asChild:!0,"data-slot":`new-task-inline`,className:`min-h-11 inline-flex`,children:(0,X.jsxs)(J,{to:`/new`,children:[(0,X.jsx)(ce,{"aria-hidden":`true`}),`New task`]})})]})]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[e===void 0?h?(0,X.jsxs)(`div`,{role:`alert`,className:`rounded-xl border border-border bg-card p-6`,children:[(0,X.jsx)(`h2`,{className:`text-lg`,children:`Could not load tasks`}),(0,X.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:h}),(0,X.jsx)(I,{variant:`outline`,className:`mt-4`,onClick:g,children:`Retry`})]}):(0,X.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…`}):D.length===0?(0,X.jsx)(Qp,{view:t,query:_}):(0,X.jsxs)(X.Fragment,{children:[y?null:(0,X.jsx)($p,{projectName:m,runs:D,positions:ne,onRename:o,onTogglePin:se,now:c,showTokens:l,showCost:u}),(0,X.jsx)(`div`,{"data-slot":`tasks-table`,hidden:!y,className:U(`hidden overflow-x-auto rounded-lg border border-border bg-card`,y&&`md:block`),children:(0,X.jsx)(Rp,{children:(0,X.jsxs)(`table`,{className:`w-full table-fixed border-collapse`,children:[(0,X.jsx)(`colgroup`,{children:ae.map(e=>{let t=Kp(e.id,d);return(0,X.jsx)(`col`,{"data-column-id":e.id,"data-expanded":t,style:{width:t?e.width:`42px`}},e.id)})}),(0,X.jsx)(`thead`,{children:(0,X.jsx)(`tr`,{children:ae.map(e=>(0,X.jsx)(rm,{column:e,expanded:Kp(e.id,d),onToggle:f,disabled:p},e.id))})}),(0,X.jsx)(`tbody`,{className:`[&>tr:last-child>td]:border-b-0`,children:D.map(e=>(0,X.jsx)(om,{run:e,queuePosition:e.status===`queued`?ne.get(e.id)??null:null,onRename:o,onTogglePin:se,now:c,columns:ae,expandedColumns:d},e.id))})]})})}),(0,X.jsx)(`div`,{"data-slot":`task-cards`,className:`flex flex-col rounded-lg border border-border bg-card p-5 md:hidden`,children:D.map(e=>(0,X.jsx)(pm,{run:e,projectName:m,queuePosition:e.status===`queued`?ne.get(e.id)??null:null,now:c,showTokens:l,showCost:u,onTogglePin:se},e.id))}),(0,X.jsx)(`p`,{className:`mt-[22px] text-[11px] text-muted-foreground md:hidden`,children:`Resource details—including tokens, cost, CPU and peak memory—are available when a task row is expanded.`})]}),re.map(e=>(0,X.jsxs)(`div`,{"data-slot":`compare-strip`,"data-group-id":e.groupId,className:`mt-3.5 flex flex-wrap items-center gap-2.5 rounded-lg border border-border bg-card px-3.5 py-2.5 text-[12.5px] text-muted-foreground shadow-xs`,children:[(0,X.jsx)(dc,{className:`size-[15px] shrink-0 text-soft-foreground`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e.title}),` — `,e.count,` variants finished`]}),(0,X.jsx)(I,{asChild:!0,variant:`outline`,size:`sm`,className:`md:ml-auto`,children:(0,X.jsx)(J,{to:`/compare/${e.groupId}`,children:`Compare`})})]},e.groupId))]}),(0,X.jsx)(J,{to:`/new`,"data-slot":`new-task-fab`,"aria-label":`New task`,className:`fixed right-4 bottom-[calc(16px+env(safe-area-inset-bottom))] z-20 inline-flex size-14 items-center justify-center rounded-full bg-action text-action-foreground shadow-modal md:hidden`,children:(0,X.jsx)(ce,{className:`size-[22px]`,"aria-hidden":`true`})})]})}function Qp({view:e,query:t}){let n=t.trim(),r=n?`search-miss`:e===`archived`?`archive`:`no-tasks`;return(0,X.jsx)(`div`,{"data-slot":`tasks-empty`,"data-empty-kind":r,className:`flex flex-1 flex-col`,children:r===`search-miss`?(0,X.jsx)(R,{heading:`h2`,icon:(0,X.jsx)(Ji,{}),tone:`neutral`,title:`No matching tasks`,subtitle:`No tasks match “${n}”.`}):r===`archive`?(0,X.jsx)(R,{heading:`h2`,icon:(0,X.jsx)(Ke,{}),tone:`neutral`,title:`Nothing archived yet`,subtitle:`Finished tasks you archive land here.`}):(0,X.jsx)(R,{heading:`h2`,icon:(0,X.jsx)(oc,{}),tone:`primary`,backdrop:!0,title:`No tasks yet`,subtitle:`Describe a task to get started.`,actions:(0,X.jsx)(I,{asChild:!0,children:(0,X.jsxs)(J,{to:`/new`,children:[(0,X.jsx)(ce,{"aria-hidden":`true`}),`New task`]})})})})}function $p({projectName:e,runs:t,positions:n,onRename:r,onTogglePin:i,now:a,showTokens:o,showCost:s}){let[c,l]=Y.useState(()=>new Set);return(0,X.jsxs)(`div`,{"data-slot":`tasks-summary`,className:`hidden md:block`,children:[(0,X.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-5`,children:(0,X.jsxs)(`table`,{className:`w-full table-fixed border-collapse`,children:[(0,X.jsxs)(`colgroup`,{children:[(0,X.jsx)(`col`,{}),(0,X.jsx)(`col`,{className:`w-[136px]`}),(0,X.jsx)(`col`,{className:`w-[106px]`}),(0,X.jsx)(`col`,{className:`w-[116px]`}),(0,X.jsx)(`col`,{className:`w-[70px]`})]}),(0,X.jsx)(`thead`,{children:(0,X.jsx)(`tr`,{children:[`Task`,`Workflow`,`Changes`,`Pull request`,`Started`].map(e=>(0,X.jsx)(`th`,{className:`h-8 border-b border-border text-left text-[10px] font-medium uppercase text-muted-foreground`,children:e},e))})}),(0,X.jsx)(`tbody`,{children:t.map(t=>{let u=it(t),d=Se(t),f=se(t),p=c.has(t.id),m=`task-resources-${t.id}`;return(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsxs)(`tr`,{"data-status":t.status,"data-slot":`task-summary-row`,className:`group/row border-b border-border last:border-0`,children:[(0,X.jsxs)(`td`,{className:`py-5 pr-4 align-top`,children:[(0,X.jsx)(lm,{run:t,to:`/tasks/${t.id}`,onRename:r,onTogglePin:i}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":`${p?`Hide`:`Show`} resources for ${A(t)}`,"aria-expanded":p,"aria-controls":m,"aria-describedby":`summary-status-${t.id}`,onClick:()=>l(e=>{let n=new Set(e);return p?n.delete(t.id):n.add(t.id),n}),className:`inline-flex min-h-[26px] items-center gap-1 rounded-md p-0 text-[11px] text-muted-foreground hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,children:(0,X.jsxs)(ei,{id:`summary-status-${t.id}`,dot:u.tone,pulse:u.pulse,children:[u.label,d?` ${d.label}`:``]})}),e?(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}):null,t.status===`queued`?(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`#`,n.get(t.id),` in queue`]}):null]})]}),(0,X.jsx)(`td`,{className:`truncate pr-3 text-xs text-muted-foreground`,title:tr(t),children:tr(t)}),(0,X.jsx)(`td`,{className:`pr-2 text-xs`,children:t.diffStat?(0,X.jsx)(_a,{stat:t.diffStat}):(0,X.jsx)(hm,{})}),(0,X.jsx)(`td`,{className:`pr-2`,children:f?(0,X.jsx)(Qr,{run:t,reference:f,compact:!0}):(0,X.jsx)(hm,{})}),(0,X.jsx)(`td`,{className:`text-xs text-muted-foreground`,children:Yi(t.startedAt??t.createdAt,a)})]}),p?(0,X.jsx)(`tr`,{children:(0,X.jsx)(`td`,{colSpan:5,className:`border-b border-border pb-5`,children:(0,X.jsx)(`div`,{id:m,className:`rounded-md bg-muted/50 p-4`,children:(0,X.jsx)(em,{run:t,showTokens:o,showCost:s})})})}):null]},t.id)})})]})}),(0,X.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 em({run:e,showTokens:t,showCost:n}){let r=Ne(e,ao(e.id));return(0,X.jsxs)(`dl`,{className:`grid grid-cols-2 gap-4 text-xs md:grid-cols-4`,children:[t?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:`Tokens in / out`}),(0,X.jsx)(`dd`,{className:`mt-1`,children:(0,X.jsx)(ya,{inputTokens:e.inputTokens,outputTokens:e.outputTokens,omitWhenUnknown:!1})})]}):null,n?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:`Cost`}),(0,X.jsx)(`dd`,{className:`mt-1`,children:en(e.costUsd)||`—`})]}):null,(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:`CPU`}),(0,X.jsx)(`dd`,{className:`mt-1`,title:r.cpu.title,children:r.cpu.text||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:`Memory`}),(0,X.jsx)(`dd`,{className:`mt-1`,title:r.mem.title,children:r.mem.text||`—`})]}),e.branch?(0,X.jsxs)(`div`,{className:`col-span-2`,children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:`Branch`}),(0,X.jsx)(`dd`,{className:`mt-1 break-all`,children:e.branch})]}):null]})}function tm({view:e,current:t,onSelect:n,count:r,children:i}){let a=e===t;return(0,X.jsxs)(`button`,{type:`button`,"data-slot":`overview-tab`,"data-view":e,"aria-pressed":a,onClick:()=>n(e),className:U(`flex min-h-11 items-center justify-center gap-1.5 border-b-2 border-transparent text-[12.5px] font-medium text-muted-foreground`,a&&`border-accent-strong font-semibold text-accent-text`),children:[i,r>0?(0,X.jsxs)(`span`,{className:`tabular-nums`,children:[` · `,r]}):null]})}function nm({children:e,right:t=!1,columnId:n,folded:r=!1}){return(0,X.jsx)(`th`,{scope:`col`,"data-column-id":n,"data-folded":r||void 0,className:U(`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 rm({column:e,expanded:t,onToggle:n,disabled:r}){if(!e.canFold)return(0,X.jsx)(nm,{columnId:e.id,right:e.align===`right`,children:e.label});let i=t?`Fold`:`Expand`;return(0,X.jsx)(nm,{columnId:e.id,right:e.align===`right`,folded:!t,children:(0,X.jsxs)(zp,{children:[(0,X.jsx)(Bp,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":`${i} ${e.label} column`,"aria-pressed":t,disabled:r,onClick:()=>n(e.id),className:U(`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,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{children:e.label}),(0,X.jsx)(Gs,{className:`size-3 opacity-55`,"aria-hidden":`true`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(im,{icon:e.icon}),(0,X.jsx)(Ks,{className:`size-3 opacity-70`,"aria-hidden":`true`})]})})}),(0,X.jsxs)(Vp,{side:`top`,children:[e.label,` · `,i,` column`]})]})})}function im({icon:e}){let t=`size-3.5`;switch(e){case`workflow`:return(0,X.jsx)(a,{className:t,"aria-hidden":`true`});case`branch`:return(0,X.jsx)(Rt,{className:t,"aria-hidden":`true`});case`diff`:return(0,X.jsx)(on,{className:t,"aria-hidden":`true`});case`reference`:return(0,X.jsx)(ac,{className:t,"aria-hidden":`true`});case`tokens`:return(0,X.jsx)(Js,{className:t,"aria-hidden":`true`});case`cost`:return(0,X.jsx)(Zs,{className:t,"aria-hidden":`true`});case`cpu`:return(0,X.jsx)(vt,{className:t,"aria-hidden":`true`});case`memory`:return(0,X.jsx)(sc,{className:t,"aria-hidden":`true`});case`started`:return(0,X.jsx)(qs,{className:t,"aria-hidden":`true`});default:return null}}var am=`h-[88px] border-b border-border px-2.5 whitespace-nowrap first:pl-4 last:pr-4`;function om({run:e,queuePosition:t,onRename:n,onTogglePin:r,now:i,columns:a,expandedColumns:o}){let s=Bi(),c=it(e),l=Se(e),u=`/tasks/${e.id}`,d=en(e.costUsd),f=se(e);return(0,X.jsx)(`tr`,{"data-slot":`task-table-row`,"data-run-id":e.id,onClick:e=>{e.target.closest(`a, button, input`)||s(u)},className:`group/row cursor-pointer hover:bg-muted`,children:a.map(a=>a.id===`memory`?null:a.id===`cpu`?t===null?(0,X.jsx)(um,{run:e,cpuExpanded:Kp(`cpu`,o),memoryExpanded:Kp(`memory`,o)},a.id):(0,X.jsxs)(`td`,{"data-slot":`queue-note`,"data-column-id":`cpu-memory`,colSpan:2,className:U(am,`text-right font-mono text-[11.5px] text-supporting-foreground`),children:[`#`,t,` in queue`]},a.id):(0,X.jsx)(sm,{column:a,expanded:Kp(a.id,o),run:e,attention:c,scheduled:l,reference:f,cost:d,to:u,onRename:n,onTogglePin:r,now:i},a.id))})}function sm({column:e,expanded:t,run:n,attention:r,scheduled:i,reference:a,cost:o,to:s,onRename:c,onTogglePin:l,now:u}){if(!t)return(0,X.jsx)(cm,{column:e.id});switch(e.id){case`status`:return(0,X.jsx)(`td`,{"data-column-id":e.id,className:U(am,`overflow-hidden`),children:(0,X.jsx)(ei,{dot:r.tone,pulse:r.pulse,title:i?.title??r.label,className:`w-full max-w-full overflow-hidden`,children:(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[r.label,i?(0,X.jsxs)(X.Fragment,{children:[` `,(0,X.jsx)(`span`,{className:`tabular-nums`,children:i.label})]}):null]})})});case`task`:return(0,X.jsx)(`td`,{"data-column-id":e.id,className:U(am,`min-w-[320px] max-w-0 whitespace-normal`),children:(0,X.jsx)(lm,{run:n,to:s,onRename:c,onTogglePin:l})});case`workflow`:return(0,X.jsx)(`td`,{"data-column-id":e.id,className:U(am,`max-w-0 truncate text-[12.5px] text-muted-foreground`),children:tr(n)});case`branch`:return(0,X.jsx)(`td`,{"data-column-id":e.id,className:U(am,`max-w-0 overflow-hidden`),children:n.branch?(0,X.jsx)(gm,{branch:n.branch}):(0,X.jsx)(hm,{})});case`diff`:return(0,X.jsx)(`td`,{"data-column-id":e.id,className:U(am,`overflow-hidden`),children:n.diffStat?(0,X.jsx)(_a,{stat:n.diffStat,compact:!0,className:`block max-w-full`}):(0,X.jsx)(hm,{})});case`reference`:return(0,X.jsx)(`td`,{"data-column-id":e.id,className:U(am,`overflow-hidden`),children:a?(0,X.jsx)(Qr,{run:n,reference:a,compact:!0,className:`max-w-full overflow-hidden`}):(0,X.jsx)(hm,{})});case`tokens`:let t=ba(n.inputTokens,n.outputTokens);return(0,X.jsx)(`td`,{"data-column-id":e.id,className:U(am,`text-right text-xs text-muted-foreground`),children:(0,X.jsx)(ya,{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,X.jsx)(`td`,{"data-column-id":e.id,className:U(am,`text-right font-mono text-xs text-muted-foreground tabular-nums`),children:o?(0,X.jsx)(fm,{text:o,accessibleText:`$${n.costUsd}`}):(0,X.jsx)(hm,{})});case`started`:return(0,X.jsx)(`td`,{"data-column-id":e.id,className:U(am,`text-right text-xs text-supporting-foreground tabular-nums`),children:Yi(n.startedAt??n.createdAt,u)});case`cpu`:case`memory`:return null}}function cm({column:e}){return(0,X.jsx)(`td`,{role:`presentation`,"aria-hidden":`true`,"data-column-id":e,"data-folded":`true`,className:U(am,`px-0 first:pl-0 last:pr-0`)})}function lm({run:e,to:t,onRename:n,onTogglePin:r}){let i=A(e),a=$r(i,t=>n(e.id,t)),o=Ur(e),s=Wr(e);return a.editing?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-slot":`table-title-editor`,children:[(0,X.jsx)(Zr,{editor:a,className:`basis-full text-[13px] font-medium`}),(0,X.jsx)(I,{size:`sm`,"aria-label":`Save title`,onMouseDown:e=>e.preventDefault(),onClick:a.commit,children:`Save`}),(0,X.jsx)(I,{size:`sm`,variant:`outline`,"aria-label":`Cancel rename`,onMouseDown:e=>e.preventDefault(),onClick:a.cancel,children:`Cancel`})]}):(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.delegation?.role===`worker`?(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Worker`}):null,(0,X.jsx)(J,{to:t,title:i,className:U(`line-clamp-2 min-w-0 flex-1 whitespace-normal rounded-sm text-[13px] leading-[18px] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,o?`font-semibold text-foreground`:s?`font-normal text-foreground`:`font-medium`),children:i}),o?(0,X.jsx)(G,{tone:`accent`,role:`img`,"aria-label":`unread`,title:`Unread — not opened since it finished`,className:`shrink-0`}):null,(0,X.jsx)(`button`,{type:`button`,"data-slot":`row-rename`,"aria-label":`Rename task`,onClick:a.begin,className:`shrink-0 rounded-sm p-0.5 text-soft-foreground opacity-0 transition-opacity group-hover/row:opacity-100 hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,X.jsx)(Vr,{className:`size-3`,"aria-hidden":`true`})}),r?(0,X.jsx)(kl,{pinned:!!e.pinned,onToggle:t=>r(e,t),className:`size-[19px] opacity-0 group-hover/row:opacity-100 focus-visible:opacity-100 no-hover:opacity-100 data-[pinned=true]:opacity-100`}):null]})}function um({run:e,cpuExpanded:t,memoryExpanded:n}){let r=Ne(e,ao(e.id));return(0,X.jsxs)(X.Fragment,{children:[t?(0,X.jsx)(dm,{column:`cpu`,cell:r.cpu}):(0,X.jsx)(cm,{column:`cpu`}),n?(0,X.jsx)(dm,{column:`memory`,cell:r.mem}):(0,X.jsx)(cm,{column:`memory`})]})}function dm({column:e,cell:t}){let n=t.text&&t.title?`${t.text}; ${t.title}`:t.text;return(0,X.jsx)(`td`,{"data-usage":e===`memory`?`mem`:e,"data-column-id":e,"data-usage-kind":t.kind,className:U(am,`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-[11.5px] text-supporting-foreground`,t.kind===`none`&&`text-xs text-soft-foreground`),children:(0,X.jsx)(fm,{text:t.text||`—`,accessibleText:n||void 0})})}function fm({text:e,accessibleText:t}){return(0,X.jsx)(`span`,{"data-slot":`bounded-metric`,...t?{"aria-label":t,title:t}:{},className:`block max-w-full overflow-hidden text-ellipsis`,children:e})}function pm({run:e,projectName:t,queuePosition:n,now:r,showTokens:i,showCost:a,onTogglePin:o}){let s=Bi(),[c,l]=Y.useState(!1),u=it(e),d=Se(e),f=`/tasks/${e.id}`,p=se(e),m=Ur(e),h=Wr(e);return(0,X.jsxs)(`div`,{"data-slot":`task-card`,"data-status":e.status,"data-run-id":e.id,onClick:e=>{e.target.closest(`a, button`)||s(f)},className:`cursor-pointer border-b border-border py-5 first:pt-0 last:border-0 last:pb-0`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2.5`,children:[(0,X.jsx)(`button`,{"data-slot":`mobile-resources-toggle`,type:`button`,"aria-controls":`mobile-resources-${e.id}`,"aria-describedby":`mobile-status-${e.id}`,"aria-label":c?`Hide resources`:`Show resources`,title:c?`Hide resources`:`Show resources`,"aria-expanded":c,onClick:()=>l(e=>!e),children:(0,X.jsxs)(ei,{id:`mobile-status-${e.id}`,dot:u.tone,pulse:u.pulse,className:`mt-px shrink-0`,title:d?.title,children:[u.label,d?(0,X.jsx)(`span`,{className:`tabular-nums`,children:d.label}):null]})}),(0,X.jsxs)(J,{to:f,className:U(`order-first w-full min-w-0 rounded-sm text-[13.5px] leading-[1.35] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,m?`font-semibold text-foreground`:h?`font-normal text-foreground`:`font-medium`),children:[e.delegation?.role===`worker`?(0,X.jsx)(`span`,{className:`mr-2 text-xs text-muted-foreground`,children:`Worker`}):null,A(e)]}),m?(0,X.jsx)(G,{tone:`accent`,role:`img`,"aria-label":`unread`,title:`Unread — not opened since it finished`,className:`mt-1.5 shrink-0`}):null,t?(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t}):null,o?(0,X.jsx)(kl,{pinned:!!e.pinned,onToggle:t=>o(e,t),className:`-mr-1 mt-px`}):null]}),(0,X.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,X.jsx)(`span`,{children:tr(e)}),n===null?e.diffStat?(0,X.jsx)(_a,{stat:e.diffStat}):(0,X.jsx)(hm,{}):(0,X.jsxs)(`span`,{"data-slot":`queue-note`,children:[`#`,n,` in queue`]}),(0,X.jsx)(`span`,{children:Yi(e.startedAt??e.createdAt,r)})]}),p?(0,X.jsx)(`div`,{className:`mt-3`,children:(0,X.jsx)(Qr,{run:e,reference:p})}):null,c?(0,X.jsx)(mm,{run:e,showTokens:i,showCost:a}):null]})}function mm({run:e,showTokens:t,showCost:n}){let r=Ne(e,ao(e.id));return(0,X.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,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:`Branch`}),(0,X.jsx)(`dd`,{children:e.branch})]}):null,(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:`CPU`}),(0,X.jsx)(`dd`,{children:r.cpu.text||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:`Memory`}),(0,X.jsx)(`dd`,{children:r.mem.text||`—`})]}),t?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:`IN / OUT`}),(0,X.jsx)(`dd`,{children:(0,X.jsx)(ya,{inputTokens:e.inputTokens,outputTokens:e.outputTokens})})]}):null,n?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:`Cost`}),(0,X.jsx)(`dd`,{children:en(e.costUsd)||`—`})]}):null]})}function hm(){return(0,X.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`})}function gm({branch:e}){return(0,X.jsx)(`span`,{title:e,className:`block truncate rounded-[6px] bg-muted px-1.5 py-0.5 font-mono text-[11.5px] font-medium text-muted-foreground`,children:e})}function _m(){let e=wt(),t=xa(H().data),[n,r]=Y.useState(`active`),i=o(),a=F({mutationFn:Gt,onSuccess:()=>i.invalidateQueries({queryKey:L.runs.all}),onError:e=>B(e.message,{tone:`danger`})}),s=F({mutationFn:Oe,onSuccess:()=>i.invalidateQueries({queryKey:L.runs.all}),onError:e=>B(e.message,{tone:`danger`})}),c=F({mutationFn:({id:e,title:t})=>Je(e,{title:t}),onSuccess:()=>i.invalidateQueries({queryKey:L.runs.all}),onError:e=>B(e.message,{tone:`danger`})}),l=xe(),u=ma(3e4),d=Xp(),f=Ye(),p=M({retryOnMount:!1}).data?.projects?.find(e=>e.id===f)?.name;return(0,X.jsx)(Hr,{projectId:f,requests:Y.useMemo(()=>f===void 0?[]:(e.data??[]).flatMap(e=>{let t=se(e);return t?[{projectId:f,kind:t.kind,number:t.number}]:[]}),[e.data,f]),children:(0,X.jsx)(Zp,{runs:e.data,projectName:p,error:e.error?.message,onRetry:()=>void e.refetch(),view:n,onViewChange:r,onArchiveFinished:()=>{a.isPending||a.mutate()},archivePending:a.isPending,onMarkAllRead:()=>s.mutate(),onRename:(e,t)=>c.mutate({id:e,title:t}),onTogglePin:(e,t)=>l.mutate({id:e.id,pinned:t}),now:u,showTokens:t.tokens,showCost:t.cost,expandedColumns:d.expandedColumns,onToggleColumn:d.toggleColumn,columnsPending:d.isPending})})}function vm({slot:e,label:t,options:n,selected:r,onToggle:i,onClear:a,searchPlaceholder:o,emptyLabel:s=`Nothing to filter by`}){let[c,l]=Y.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,X.jsxs)(Mr,{open:c,onOpenChange:l,children:[(0,X.jsx)(jr,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"data-slot":`facet-${e}`,"data-active":u?`true`:void 0,"aria-label":`Filter by ${t.toLowerCase()}`,className:U(`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,X.jsx)(`span`,{className:U(u&&`text-soft-foreground`),children:t}),u?(0,X.jsx)(`span`,{className:`max-w-[140px] truncate font-semibold`,children:d}):null,(0,X.jsx)(Ws,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,X.jsxs)(Or,{align:`start`,className:`w-64 p-0`,"data-testid":`facet-${e}-menu`,children:[(0,X.jsxs)(li,{children:[(0,X.jsx)(oi,{placeholder:o??`Search ${t.toLowerCase()}…`}),(0,X.jsxs)(fi,{children:[(0,X.jsx)(mi,{children:s}),(0,X.jsx)(q,{children:n.map(e=>{let t=r.includes(e.value);return(0,X.jsxs)(K,{value:e.label,onSelect:()=>i(e.value),"data-slot":`facet-option`,"data-value":e.value,"aria-checked":t,role:`option`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:U(`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,X.jsx)(Us,{className:`size-3`}):null}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.count===void 0?null:(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-soft-foreground tabular-nums`,children:e.count})]},e.value)})})]})]}),u?(0,X.jsx)(`div`,{className:`border-t border-border p-1`,children:(0,X.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 ym({label:e,count:t,selected:n,onToggle:r,slot:i,tone:a=`neutral`}){return(0,X.jsxs)(`button`,{type:`button`,"data-slot":i,"data-selected":n?`true`:void 0,"aria-pressed":n,onClick:r,className:U(`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,X.jsx)(`span`,{className:U(`font-mono text-[11px] tabular-nums`,!n&&`text-soft-foreground`),children:t})]})}function bm({slot:e,label:t,value:n,options:r,onChange:i}){return(0,X.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,X.jsx)(`button`,{type:`button`,"data-value":e.value,"aria-pressed":t,onClick:()=>i(e.value),className:U(`flex h-6 items-center justify-center rounded-[6px] px-2.5 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground`,t&&`bg-card font-semibold text-foreground shadow-xs`),children:e.label},e.value)})})}var xm=` untagged`,Sm=[{value:`project`,label:`Project`},{value:`tag`,label:`Tag`},{value:`status`,label:`Status`},{value:`workflow`,label:`Workflow`}];function Cm(e,t){return e===t?`none`:t}var wm={query:``,tags:[],statuses:[],workflows:[]};function Tm(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function Em(e){return(e.projects?.length??0)+e.tags.length+e.statuses.length+e.workflows.length}function Dm(e){return e.query.trim()!==``||Em(e)>0}function Om(e){return Em(e.filters)+(e.filters.query.trim()===``?0:1)+(e.groupBy===`none`?0:1)}function km(e){return Om(e)>0}function Am(e,t){let n=new Map(t.map(e=>[e.id,e]));return e.map(e=>{let t=n.get(e.projectId);return{run:e,project:t,projectName:t?.name||e.projectId,tags:t?.tags??[]}})}function jm(e){let t=new Set;for(let n of e)t.add(n.run.workflow);return[...t].sort((e,t)=>e.localeCompare(t))}function Mm(e){let t=new Set;for(let n of e)t.add(n.run.status);return[...t].sort((e,t)=>e.localeCompare(t))}function Nm(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 Pm=e=>e.tags.length===0?[xm]:e.tags,Fm=(e,t)=>e.length===0||t.some(t=>e.includes(t)),Im=(e,t)=>{if(t.length===0)return!0;let n=Pm(e).map(e=>e.toLowerCase());return t.some(e=>n.includes(e.toLowerCase()))};function Lm(e){return[A(e.run),e.projectName,e.run.workflow,e.run.branch??``,...e.tags].join(`
7
- `).toLowerCase()}function Rm(e,t,n){let r=t.query.trim().toLowerCase().split(/\s+/).filter(Boolean);return e.filter(e=>{if((n===`archived`?!e.run.archived:e.run.archived)||!Fm(t.projects??[],[e.run.projectId])||!Fm(t.statuses,[e.run.status])||!Fm(t.workflows,[e.run.workflow])||!Im(e,t.tags))return!1;if(r.length===0)return!0;let i=Lm(e);return r.every(e=>i.includes(e))})}function zm(e,t,n,r){return Rm(e,{...t,[r]:[]},n)}function Bm(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(xm,`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 Vm(e,t){let n=new Map(t.map(e=>[e.id,e.name]));return e.map(e=>n.get(e)||e)}var $={query:`q`,project:`project`,tag:`tag`,untagged:`untagged`,status:`status`,workflow:`workflow`,groupBy:`group`,archived:`archived`},Hm=new Set(Sm.map(e=>e.value));function Um(e){let t=new URLSearchParams,n=e.filters.query.trim();n!==``&&t.set($.query,n);for(let n of e.filters.tags)n===` untagged`?t.set($.untagged,`1`):t.append($.tag,n);for(let n of e.filters.projects??[])t.append($.project,n);for(let n of e.filters.statuses)t.append($.status,n);for(let n of e.filters.workflows)t.append($.workflow,n);return e.groupBy!==`none`&&t.set($.groupBy,e.groupBy),e.view===`archived`&&t.set($.archived,`1`),t}function Wm(e){let t=e.getAll($.tag).filter(e=>e!==``);e.get($.untagged)===`1`&&t.push(xm);let n=e.get($.groupBy)??``;return{filters:{query:e.get($.query)??``,...e.has($.project)?{projects:e.getAll($.project).filter(Boolean)}:{},tags:t,statuses:e.getAll($.status).filter(e=>e!==``),workflows:e.getAll($.workflow).filter(e=>e!==``)},groupBy:Hm.has(n)?n:`none`,view:e.get($.archived)===`1`?`archived`:`active`}}var Gm=15e3,Km=250,qm=1,Jm=220,Ym=new Set([`done`,`failed`,`cancelled`]);function Xm(){return Qm({request:({task:e,archived:t})=>gt(e.run.projectId,e.run.id,t),patch:({archived:e})=>t=>({...t,archived:e})})}function Zm(){return Qm({request:({task:e,read:t})=>dn(e.run.projectId,e.run.id,t),patch:({read:e})=>t=>{if(e)return{...t,seenAt:new Date().toISOString()};let{seenAt:n,...r}=t;return r}})}function Qm({request:e,patch:t}){let n=o();return F({mutationFn:e,onMutate:async e=>{await n.cancelQueries({queryKey:P.runsIndex});let r=n.getQueryData(P.runsIndex),i=t(e),{task:a}=e;return n.setQueryData(P.runsIndex,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.projectId===a.run.projectId&&e.id===a.run.id?i(e):e)}),{previous:r}},onError:(e,t,r)=>{r?.previous&&n.setQueryData(P.runsIndex,r.previous),B(e.message,{tone:`danger`})},onSettled:(e,t,{task:r})=>{n.invalidateQueries({queryKey:P.runsIndex}),n.invalidateQueries({queryKey:L.runs.all}),n.invalidateQueries({queryKey:[r.run.projectId,`runs`,`list`]})}})}function $m(){let e=M(),t=xa(H().data),n=an(!0,Gm),[r,i]=Wn(),{filters:a,groupBy:o,view:s}=Y.useMemo(()=>Wm(r),[r]),c=ma(3e4),l=e=>i(t=>Um(e(Wm(t))),{replace:!0}),u=e=>l(t=>({...t,filters:e(t.filters)})),d=e=>l(t=>({...t,groupBy:e})),f=e=>l(t=>({...t,view:e})),[p,m]=Y.useState(o!==`none`||a.tags.length>0),[h,g]=Y.useState(a.query),_=Y.useRef(a.query);Y.useEffect(()=>{a.query!==_.current&&g(a.query),_.current=a.query},[a.query]),Y.useEffect(()=>{if(h===_.current)return;let e=setTimeout(()=>{_.current=h,u(e=>({...e,query:h}))},Km);return()=>clearTimeout(e)},[h]);let v=n.data?.referenceStatuses;Y.useEffect(()=>{v&&_t(v)},[v]);let y=Y.useMemo(()=>e.data?.projects??[],[e.data]),b=Y.useMemo(()=>Am(n.data?.runs??[],y),[n.data,y]),x=Y.useMemo(()=>Rm(b,a,s),[b,a,s]),S=Y.useMemo(()=>Bm(x,o),[x,o]),C=Y.useMemo(()=>x.flatMap(e=>_e(e.run,e.project?.repoUrl).map(t=>({projectId:e.run.projectId,kind:t.kind,number:t.number}))),[x]),w=Vm(n.data?.truncated??[],y),te=(e,t)=>u(n=>({...n,[e]:Tm(n[e]??[],t)})),T=e=>u(t=>({...t,[e]:[]})),E=Xm(),D=Zm();if(n.isError||e.isError)return(0,X.jsx)(`div`,{"data-route":`global-tasks`,"data-presentation":o===`none`?`summary`:`cards`,"data-filter-details":p,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,X.jsx)(R,{icon:(0,X.jsx)(ee,{}),tone:`danger`,title:`Tasks across projects did not load`,subtitle:(n.error??e.error)?.message,actions:(0,X.jsx)(I,{variant:`outline`,onClick:()=>{n.refetch(),e.refetch()},children:`Retry`})})});let ne=(0,X.jsxs)(`div`,{className:`relative w-full`,children:[(0,X.jsx)(Pe,{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,X.jsx)(`input`,{type:`text`,value:h,onChange:e=>g(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,X.jsxs)(`div`,{"data-route":`global-tasks`,"data-presentation":o===`none`?`summary`:`cards`,"data-filter-details":p,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,X.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-[22px]`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h1`,{className:`text-[30px] font-semibold tracking-tight`,children:`All tasks`}),(0,X.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:o===`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,X.jsxs)(`div`,{className:`flex items-center gap-6 border-b border-border`,children:[(0,X.jsx)(eh,{view:`active`,current:s,onSelect:f,children:`Active`}),(0,X.jsx)(eh,{view:`archived`,current:s,onSelect:f,children:`Archived`}),(0,X.jsxs)(`span`,{"data-slot":`global-tasks-count`,className:`ml-auto text-[12.5px] text-soft-foreground tabular-nums`,children:[x.length,` of `,b.length]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,X.jsx)(`div`,{className:`min-w-0 basis-full md:flex-1 md:basis-auto`,children:ne}),(0,X.jsxs)(I,{variant:`outline`,"aria-expanded":p,onClick:()=>m(e=>!e),children:[(0,X.jsx)(re,{"aria-hidden":`true`}),`Filters`]}),(0,X.jsx)(I,{asChild:!0,className:`min-h-11`,children:(0,X.jsxs)(z,{to:zi(e.data?.bootProject??`default`,`/new`),children:[(0,X.jsx)(ce,{"aria-hidden":`true`}),`New task`]})})]})]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[22px]`,children:[(0,X.jsx)(th,{filters:a,onToggle:te,onClearFacet:T,onClearAll:()=>{g(``),l(e=>({...e,filters:wm,groupBy:`none`}))},groupBy:o,onGroupByChange:d,projects:y,tasks:b,view:s}),w.length>0?(0,X.jsxs)(`p`,{"data-slot":`global-tasks-truncated`,className:`text-[11.5px] text-soft-foreground`,children:[`Showing the newest `,n.data?.perProjectLimit,` tasks per project — older ones in`,` `,w.join(`, `),` are only in that project’s own Tasks page.`]}):null,n.data===void 0?(0,X.jsx)(`div`,{role:`status`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:`Loading tasks…`}):x.length===0?(0,X.jsx)(uh,{view:s,filtered:Dm(a)}):(0,X.jsx)(Hr,{requests:C,children:S.map(e=>(0,X.jsxs)(`section`,{"data-slot":`task-group`,"data-group-key":e.key,children:[o===`none`?null:(0,X.jsxs)(`h2`,{className:`mb-1.5 flex items-center gap-2 text-[12px] font-semibold tracking-[0.04em] text-soft-foreground uppercase`,children:[o===`project`?(0,X.jsx)(z,{to:zi(e.key,`/`),"data-slot":`group-project-link`,className:`hover:text-foreground hover:underline`,children:e.label}):e.label,(0,X.jsx)(`span`,{className:`font-mono text-[11px] font-medium tabular-nums`,children:e.tasks.length})]}),(0,X.jsx)(nh,{tasks:e.tasks,now:c,showProject:o!==`project`,onArchive:(e,t)=>E.mutate({task:e,archived:t}),onSetRead:(e,t)=>D.mutate({task:e,read:t}),busy:E.isPending||D.isPending,showCost:t.cost})]},e.key))}),o===`none`&&x.length>0?(0,X.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,y.length>1?(0,X.jsxs)(`section`,{"data-slot":`other-projects`,className:`rounded-lg border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:`Other projects`}),(0,X.jsx)(`div`,{className:`mt-3 flex flex-col divide-y divide-border`,children:y.map(e=>(0,X.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between gap-3`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate text-[13px]`,children:e.name}),(0,X.jsxs)(z,{to:zi(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,X.jsxs)(`span`,{className:`sr-only`,children:[` for `,e.name]})]})]},e.id))})]}):null]})]})}function eh({view:e,current:t,onSelect:n,children:r}){let i=e===t;return(0,X.jsx)(`button`,{type:`button`,"data-slot":`overview-tab`,"data-view":e,"aria-pressed":i,onClick:()=>n(e),className:U(`flex min-h-11 items-center justify-center border-b-2 border-transparent text-[12.5px] font-medium text-muted-foreground`,i&&`border-accent-strong font-semibold text-accent-text`),children:r})}function th({filters:e,onToggle:t,onClearFacet:n,onClearAll:r,groupBy:i,onGroupByChange:a,projects:o,tasks:s,view:c}){let l=Y.useMemo(()=>_(o),[o]),u=Y.useMemo(()=>{let t=(t,n)=>Nm(zm(s,e,c,t),n);return{projects:t(`projects`,e=>[e.run.projectId]),tags:t(`tags`,Pm),statuses:t(`statuses`,e=>[e.run.status]),workflows:t(`workflows`,e=>[e.run.workflow])}},[s,e,c]),d=e=>t=>({...t,count:e.get(t.value)??0});return(0,X.jsxs)(`div`,{"data-slot":`global-tasks-filters`,className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,X.jsx)(vm,{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(d(u.projects)),emptyLabel:`No tasks to filter`}),(0,X.jsx)(vm,{slot:`status`,label:`Status`,selected:e.statuses,onToggle:e=>t(`statuses`,e),onClear:()=>n(`statuses`),options:Mm(s).map(e=>({value:e,label:e})).map(d(u.statuses)),emptyLabel:`No tasks to filter`}),(0,X.jsx)(vm,{slot:`workflow`,label:`Workflow`,selected:e.workflows,onToggle:e=>t(`workflows`,e),onClear:()=>n(`workflows`),options:jm(s).map(e=>({value:e,label:e})).map(d(u.workflows)),emptyLabel:`No tasks to filter`}),(0,X.jsxs)(`div`,{"data-slot":`group-controls`,className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`text-[11px] font-medium text-soft-foreground`,children:`Group by`}),(0,X.jsx)(bm,{slot:`group-by`,label:`Group tasks by`,value:i,options:Sm,onChange:e=>a(Cm(i,e))})]}),km({filters:e,groupBy:i})?(0,X.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,X.jsx)(In,{className:`size-3`,"aria-hidden":`true`}),`Clear`,` (${Om({filters:e,groupBy:i})})`]}):null]}),l.length>0?(0,X.jsxs)(`div`,{"data-slot":`tag-filters`,className:`flex flex-wrap items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium text-soft-foreground`,children:`Tags`}),l.map(n=>(0,X.jsx)(ym,{slot:`tag-filter`,tone:`tag`,label:n,count:u.tags.get(n)??0,selected:e.tags.some(e=>e.toLowerCase()===n.toLowerCase()),onToggle:()=>t(`tags`,n)},n)),(0,X.jsx)(ym,{slot:`tag-filter`,label:`Untagged`,count:u.tags.get(` untagged`)??0,selected:e.tags.includes(xm),onToggle:()=>t(`tags`,xm)})]}):(0,X.jsxs)(`p`,{"data-slot":`no-tags-hint`,className:`text-[11px] text-soft-foreground`,children:[`Tag connected repositories in`,` `,(0,X.jsx)(z,{to:`/settings/global/projects`,className:`font-medium text-accent-text hover:underline`,children:`Settings → Projects`}),` `,`to group their tasks together here.`]})]})}function nh({tasks:e,now:t,showProject:n,onArchive:r,onSetRead:i,busy:a,showCost:o}){return(0,X.jsxs)(`div`,{"data-slot":`global-tasks-table`,className:`overflow-x-auto rounded-lg border border-border bg-card p-5`,children:[(0,X.jsx)(`div`,{"data-slot":`global-summary-head`,"aria-hidden":`true`,children:[`Task`,`Workflow`,`Changes`,`Pull request`,`Started`].map(e=>(0,X.jsx)(`span`,{children:e},e))}),(0,X.jsx)(Rp,{children:e.map(e=>(0,X.jsx)(rh,{task:e,now:t,showProject:n,onArchive:r,onSetRead:i,busy:a,showCost:o},`${e.run.projectId}/${e.run.id}`))})]})}function rh({task:e,now:t,showProject:n,onArchive:r,onSetRead:i,busy:a,showCost:o}){let{run:s}=e,[c,l]=Y.useState(!1),u=it(s),d=zi(s.projectId,`/tasks/${s.id}`),f=Ur(s),p=Wr(s),m=_e(s,e.project?.repoUrl),h=Ne(s,s.usage);return(0,X.jsxs)(`article`,{"data-status":s.status,"data-expanded":c,"data-slot":`global-task-row`,"data-run-id":s.id,"data-project":s.projectId,className:`hover:bg-muted max-md:flex max-md:flex-wrap max-md:items-center max-md:gap-x-3 max-md:gap-y-2 max-md:border-b max-md:border-border max-md:py-5 max-md:first:pt-0 max-md:last:border-0 max-md:last:pb-0`,children:[(0,X.jsxs)(`div`,{"data-slot":`global-task-title`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[s.delegation?.role===`worker`?(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Worker`}):null,(0,X.jsx)(z,{to:d,title:A(s),className:U(`min-w-0 truncate text-[13px]`,f?`font-semibold text-foreground`:p?`font-medium text-muted-foreground`:`font-medium`),children:A(s)}),f?(0,X.jsx)(G,{tone:`accent`,role:`img`,"aria-label":`unread`,title:`Unread — not opened since it finished`,className:`shrink-0`}):null]}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,"aria-expanded":c,"aria-label":`${c?`Hide`:`Show`} resources for ${A(s)}`,onClick:()=>l(e=>!e),"aria-describedby":`global-status-${s.projectId}-${s.id}`,title:`Resources and actions`,className:`min-h-[26px] rounded-md p-0 text-[11px] text-muted-foreground hover:bg-muted`,children:(0,X.jsx)(ei,{id:`global-status-${s.projectId}-${s.id}`,dot:u.tone,pulse:u.pulse,children:u.label})}),n?(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:(0,X.jsx)(z,{to:zi(s.projectId,`/`),className:`truncate hover:text-foreground`,children:e.projectName})}):null,(0,X.jsx)(`span`,{children:e.tags.length>0?(0,X.jsx)(`span`,{className:`flex flex-wrap items-center gap-1`,children:e.tags.map(e=>(0,X.jsx)(ch,{tag:e},e))}):null})]})]}),(0,X.jsx)(`div`,{"data-slot":`global-task-references`,children:m.length>0?(0,X.jsx)(oh,{references:m,run:s}):(0,X.jsx)(lh,{})}),(0,X.jsx)(`div`,{"data-slot":`global-task-workflow`,className:`text-[12.5px] text-muted-foreground`,children:s.workflow}),(0,X.jsx)(`div`,{"data-slot":`global-task-diff`,className:`text-xs text-muted-foreground`,children:(0,X.jsx)(`span`,{title:`Change totals are available in the project task list`,children:`—`})}),(0,X.jsx)(`div`,{"data-slot":`global-task-age`,className:`text-right text-xs text-soft-foreground tabular-nums`,children:Yi(s.startedAt??s.createdAt,t)}),(0,X.jsx)(`div`,{"data-slot":`global-task-actions`,children:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,X.jsx)(ih,{task:e,busy:a,onSetRead:i}),(0,X.jsx)(ah,{task:e,busy:a,onArchive:r}),(0,X.jsx)(I,{asChild:!0,variant:`outline`,children:(0,X.jsx)(z,{to:d,children:`Open task`})})]})}),c?(0,X.jsx)(`div`,{"data-slot":`global-task-resources`,className:`col-span-full`,children:(0,X.jsxs)(`dl`,{className:`grid grid-cols-2 gap-4 rounded-md bg-muted/50 p-4 text-xs md:grid-cols-3`,children:[o?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:`Cost`}),(0,X.jsx)(`dd`,{className:`mt-1`,children:en(s.costUsd)||`—`})]}):null,(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:`CPU`}),(0,X.jsx)(`dd`,{"data-usage":`cpu`,"data-usage-kind":h.cpu.kind,title:h.cpu.title,className:`mt-1`,children:h.cpu.text||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:`Memory`}),(0,X.jsx)(`dd`,{"data-usage":`mem`,"data-usage-kind":h.mem.kind,title:h.mem.title,className:`mt-1`,children:h.mem.text||`—`})]})]})}):null]})}function ih({task:e,busy:t,onSetRead:n}){if(!Yr(e.run))return null;let r=Ur(e.run),i=A(e.run),a=r?`Mark ${i} read`:`Mark ${i} unread`,o=r?di:$s;return(0,X.jsxs)(zp,{children:[(0,X.jsx)(Bp,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"data-action":r?`mark-read`:`mark-unread`,"aria-label":a,disabled:t,onClick:()=>n(e,r),className:U(`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,X.jsx)(o,{className:`size-3.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:r?`Mark read`:`Mark unread`})]})}),(0,X.jsx)(Vp,{side:`left`,children:r?`Mark read`:`Mark unread`})]})}function ah({task:e,busy:t,onArchive:n}){let r=e.run.archived;if(!r&&!Ym.has(e.run.status))return null;let i=r?`Restore ${A(e.run)} to the active list`:`Archive ${A(e.run)}`;return(0,X.jsxs)(zp,{children:[(0,X.jsx)(Bp,{asChild:!0,children:(0,X.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,X.jsx)(r?Kr:Ke,{className:`size-3.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:r?`Unarchive`:`Archive`})]})}),(0,X.jsx)(Vp,{side:`left`,children:r?`Restore`:`Archive`})]})}function oh({references:e,run:t}){let n=e.slice(0,qm),r=e.length-n.length,i=A(t);return(0,X.jsxs)(`span`,{className:`flex flex-nowrap items-center gap-1`,children:[n.map(e=>(0,X.jsx)(Jr,{reference:e,taskTitle:i,projectId:t.projectId,conflictAction:(0,X.jsx)(Xr,{projectId:t.projectId,runId:t.id,prNumber:e.number}),className:`shrink-0`},`${e.kind}#${e.number}`)),r>0?(0,X.jsx)(sh,{references:e,taskTitle:i,hidden:r,projectId:t.projectId}):null]})}function sh({references:e,taskTitle:t,hidden:n,projectId:r}){let[i,a]=Y.useState(!1),o=Y.useRef(!1),s=Y.useRef(void 0);Y.useEffect(()=>()=>clearTimeout(s.current),[]);let c=e=>e.pointerType!==`touch`,l=()=>clearTimeout(s.current),u=e=>{c(e)&&(l(),o.current=!0,a(!0))},d=e=>{c(e)&&(l(),s.current=setTimeout(()=>a(!1),Jm))};return(0,X.jsxs)(Mr,{open:i,onOpenChange:a,children:[(0,X.jsx)(jr,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"data-slot":`reference-overflow`,"aria-label":`Show all ${e.length} references for ${t}`,onPointerEnter:u,onPointerLeave:d,onPointerDown:()=>{o.current=!1},onClick:()=>{o.current=!1},className:`shrink-0 rounded-full px-1 text-[11px] font-medium text-soft-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:[`+`,n]})}),(0,X.jsxs)(Or,{align:`start`,className:`w-auto min-w-40 p-1.5`,"data-slot":`reference-overflow-list`,onPointerEnter:u,onPointerLeave:d,onOpenAutoFocus:e=>{o.current&&e.preventDefault()},onCloseAutoFocus:e=>{o.current&&e.preventDefault()},children:[(0,X.jsx)(`p`,{className:`px-1 pb-1.5 text-[10.5px] text-soft-foreground`,children:`References`}),(0,X.jsx)(`span`,{className:`flex flex-col items-start gap-1`,children:e.map(e=>(0,X.jsx)(Jr,{reference:e,taskTitle:t,projectId:r},`${e.kind}#${e.number}`))})]})]})}function ch({tag:e,className:t}){return(0,X.jsx)(`span`,{"data-slot":`project-tag`,className:U(`inline-flex max-w-full items-center truncate rounded-full bg-muted px-1.5 py-px text-[10.5px] font-medium text-muted-foreground`,t),children:e})}function lh(){return(0,X.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`})}function uh({view:e,filtered:t}){return t?(0,X.jsx)(R,{heading:`h2`,icon:(0,X.jsx)(Ji,{}),tone:`neutral`,title:`No matching tasks`,subtitle:`No task in any project matches these filters.`}):e===`archived`?(0,X.jsx)(R,{heading:`h2`,icon:(0,X.jsx)(Ke,{}),tone:`neutral`,title:`Nothing archived yet`,subtitle:`Finished tasks you archive land here, from every project.`}):(0,X.jsx)(R,{heading:`h2`,icon:(0,X.jsx)(oc,{}),tone:`neutral`,title:`No tasks yet`,subtitle:`Start a task in any project and it shows up here.`})}function dh({mode:e=`list`}){let{automationId:t}=h(),n=Bi(),r=Ki(),[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)({}),u=H(),d=u.data!==void 0,f=d&&u.data.capabilities?.automations!==!0,p=()=>Gn().then(e=>{a(e),s(``)}).catch(e=>s(String(e)));if((0,Y.useEffect)(()=>{d&&!f&&p()},[d,f]),(0,Y.useEffect)(()=>Ga((e,t)=>{if(e!==`automation-change`)return;let n=t;typeof n.project==`string`&&(r===null||n.project===r)&&p()}),[r]),!d)return(0,X.jsx)(`div`,{"data-route":`automations`,className:`task-flow-page flex min-h-full flex-col`,children:(0,X.jsx)(gh,{text:`Loading automations…`})});if(f)return(0,X.jsx)(`div`,{"data-route":`automations`,className:`task-flow-page flex min-h-full flex-col`,children:(0,X.jsx)(R,{icon:(0,X.jsx)(pn,{}),tone:`neutral`,title:`GitHub automations are off`,subtitle:`This server does not poll GitHub or launch tasks from it. Set CEZ_AUTOMATIONS=1 and restart cezar to turn automations on.`,heading:`h2`})});if(e===`new`)return(0,X.jsx)(mh,{onSaved:()=>{n(`/automations`),p()}});if(e===`edit`){let e=i?.automations.find(e=>e.id===t);return o?(0,X.jsxs)(hh,{title:`Edit automation`,subtitle:`Could not load this automation.`,children:[(0,X.jsx)(gh,{text:o}),(0,X.jsx)(I,{variant:`outline`,onClick:()=>void p(),children:`Retry`})]}):i&&!e?(0,X.jsx)(hh,{title:`Automation not found`,subtitle:`This automation may have been removed.`,children:(0,X.jsx)(I,{asChild:!0,variant:`outline`,children:(0,X.jsx)(J,{to:`/automations`,children:`Back to automations`})})}):e?(0,X.jsx)(mh,{automation:e,onSaved:()=>{n(`/automations`),p()}}):(0,X.jsx)(gh,{text:`Loading automation…`})}if(e===`log`){let e=i?.automations.find(e=>e.id===t);return t?(0,X.jsx)(ph,{automationId:t,automationName:e?.name}):(0,X.jsx)(gh,{text:`Automation not found.`})}let m=async e=>{l(t=>({...t,[e.id]:`Checking…`}));try{let{checkId:t}=await nn(e.id,`preview`);for(let n=0;n<60;n+=1){let n=await Ie(t);if(n.status===`complete`){l(t=>({...t,[e.id]:`${n.matches??0} match${n.matches===1?``:`es`} found; no tasks launched.`})),p();return}if(n.status===`error`)throw Error(n.error??`Preview failed`);await new Promise(e=>setTimeout(e,500))}throw Error(`Preview is still running`)}catch(t){l(n=>({...n,[e.id]:t instanceof Error?t.message:String(t)}))}};return(0,X.jsx)(hh,{title:`Automations`,subtitle:`Checks run while Cezarion is open. No webhook or public URL required.`,action:(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(I,{asChild:!0,children:(0,X.jsx)(J,{to:`/automations/new`,children:`New automation`})}),(0,X.jsx)(I,{variant:`outline`,asChild:!0,children:(0,X.jsx)(J,{to:`/github`,children:`GitHub`})})]}),children:o?(0,X.jsxs)(`div`,{className:`grid gap-3`,children:[(0,X.jsx)(gh,{text:o}),(0,X.jsx)(I,{variant:`outline`,onClick:()=>void p(),children:`Retry`})]}):i?(0,X.jsxs)(X.Fragment,{children:[i.automations.length===0?(0,X.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-6`,children:[(0,X.jsx)(`h2`,{className:`text-xl font-normal`,children:`No automations yet`}),(0,X.jsx)(`p`,{className:`mt-5 text-sm text-muted-foreground`,children:`Create a bounded trigger to start ordinary tasks from new GitHub issues.`})]}):(0,X.jsx)(`div`,{className:`grid gap-3`,children:i.automations.map(e=>(0,X.jsxs)(`article`,{className:`rounded-xl border bg-card p-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`font-semibold`,children:e.name}),(0,X.jsxs)(`p`,{className:`mt-6 text-[13px] text-muted-foreground`,children:[e.events.join(`, `),` · every `,Math.round(e.intervalSeconds/60),` min`]})]}),(0,X.jsx)(`span`,{className:`rounded-lg border px-4 py-3 text-xs`,children:e.enabled?`Enabled`:`Paused`})]}),(0,X.jsx)(fh,{data:i}),(0,X.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-3`,children:[(0,X.jsx)(I,{variant:`outline`,asChild:!0,children:(0,X.jsx)(J,{to:`/automations/${e.id}`,children:`Edit`})}),(0,X.jsx)(I,{variant:`outline`,asChild:!0,children:(0,X.jsx)(J,{to:`/automations/${e.id}/log`,children:`Execution log`})}),(0,X.jsx)(I,{variant:`outline`,onClick:()=>void Pn(e.id,!e.enabled).then(p),children:e.enabled?`Pause`:`Enable`}),(0,X.jsx)(I,{variant:`outline`,onClick:()=>void m(e),disabled:c[e.id]===`Checking…`,children:`Test filter`})]}),c[e.id]&&(0,X.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,role:`status`,children:c[e.id]})]},e.id))}),i.automations.length===0?(0,X.jsx)(fh,{data:i}):null,i.automations.map(e=>(0,X.jsx)(ph,{automationId:e.id,automationName:e.name,showName:i.automations.length>1,inline:!0},e.id))]}):(0,X.jsx)(gh,{text:`Loading automations…`})})}function fh({data:e}){return(0,X.jsxs)(`p`,{"data-slot":`automation-scheduler`,className:`mt-4 text-xs ${e.available?e.scheduler.state===`scheduled`?`text-success`:`text-muted-foreground`:`text-destructive`}`,children:[`Scheduler `,e.scheduler.state,` · GitHub `,e.available?`available`:`unavailable`,e.reason?` · ${e.reason}`:``]})}function ph({automationId:e,automationName:t,inline:n=!1,showName:r=!1}){let[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(``),c=()=>g(e).then(({records:e})=>{a(e),s(``)}).catch(e=>s(String(e)));(0,Y.useEffect)(()=>{c()},[e]),(0,Y.useEffect)(()=>Ga((t,n)=>{t===`automation-change`&&n.automationId===e&&c()}),[e]);let l=(0,X.jsx)(X.Fragment,{children:o?(0,X.jsxs)(`div`,{className:`grid gap-3`,children:[(0,X.jsx)(gh,{text:o}),(0,X.jsx)(I,{variant:`outline`,onClick:()=>void c(),children:`Retry`})]}):i?i.length===0?(0,X.jsx)(gh,{text:`No checks have run yet.`}):(0,X.jsx)(`ol`,{className:`grid gap-3`,"aria-label":`Automation execution log`,children:(n?i.slice(0,5):i).map(e=>(0,X.jsxs)(`li`,{className:`rounded-xl border bg-card p-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium capitalize`,children:e.result.replace(`-`,` `)}),(0,X.jsx)(`time`,{className:`text-xs text-muted-foreground`,dateTime:e.ts,children:new Date(e.ts).toLocaleString()})]}),e.reason&&(0,X.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:e.reason}),(e.githubUrl||e.runId)&&(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-3 text-sm`,children:[e.githubUrl&&(0,X.jsx)(`a`,{className:`underline underline-offset-4`,href:e.githubUrl,target:`_blank`,rel:`noreferrer`,children:e.githubTitle??`GitHub #${e.githubNumber??``}`}),e.runId&&(0,X.jsx)(J,{className:`underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`})]})]},e.seq))}):(0,X.jsx)(gh,{text:`Loading execution log…`})});return n?(0,X.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`mt-5 rounded-xl border border-border bg-card p-6`,children:[(0,X.jsxs)(`h2`,{className:`mb-4 text-lg font-medium`,children:[`Recent activity`,r?` · ${t}`:``]}),l]}):(0,X.jsx)(hh,{title:`Execution log`,subtitle:t??`Automation activity`,action:(0,X.jsx)(I,{variant:`outline`,asChild:!0,children:(0,X.jsx)(J,{to:`/automations`,children:`Back to automations`})}),children:l})}function mh({automation:e,onSaved:t}){let[n,r]=(0,Y.useState)(e?.name??``),[i,a]=(0,Y.useState)(e?.task.prompt??`Review {{github.url}}`),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(``);return(0,X.jsx)(hh,{title:e?`Edit automation`:`New automation`,subtitle:`Define a bounded GitHub trigger and the ordinary task it launches.`,children:(0,X.jsxs)(`form`,{className:`automation-editor grid gap-5`,onSubmit:async r=>{if(r.preventDefault(),!c){l(!0),d(``);try{e?(await ht(e.id,{name:n,description:e.description,events:e.events,intervalSeconds:e.intervalSeconds,filters:e.filters,task:{...e.task,prompt:i},enabled:e.enabled,expectedRevision:e.revision}),o&&!e.enabled&&await Pn(e.id,!0)):await sn({name:n,events:[`issue.opened`],intervalSeconds:300,filters:{lookbackDays:7,maxRecords:25},task:{prompt:i,workflow:`quick-task`},enable:o}),t()}catch(e){d(String(e))}finally{l(!1)}}},children:[(0,X.jsxs)(`fieldset`,{className:`grid gap-4 rounded-xl border p-5`,children:[(0,X.jsx)(`legend`,{className:`px-2 font-semibold`,children:`When GitHub changes`}),(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsx)(vc,{htmlFor:`automation-name`,children:`Name`}),(0,X.jsx)(_c,{id:`automation-name`,value:n,onChange:e=>r(e.target.value),required:!0})]}),(0,X.jsx)(`div`,{className:`flex items-center gap-2 text-sm`,children:e?`Saved trigger · ${e.events.join(`, `)} · Every ${Math.round(e.intervalSeconds/60)} minutes`:`New issue · every 5 minutes · last 7 days · maximum 25 records`})]}),(0,X.jsxs)(`fieldset`,{className:`grid gap-4 rounded-xl border p-5`,children:[(0,X.jsx)(`legend`,{className:`px-2 font-semibold`,children:`What task to run`}),(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsx)(vc,{htmlFor:`automation-prompt`,children:`Prompt`}),(0,X.jsx)(Br,{id:`automation-prompt`,value:i,onChange:e=>a(e.target.value),rows:2,required:!0})]}),(0,X.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Available: `,`{{github.number}}`,` `,`{{github.title}}`,` `,`{{github.url}}`,` `,`{{github.labels}}`]}),(0,X.jsx)(`p`,{className:`text-xs text-pending-strong`,children:`GitHub content is appended as untrusted context.`})]}),e?.enabled?null:(0,X.jsxs)(`fieldset`,{className:`relative rounded-xl border p-5`,children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:`Review and enable`}),(0,X.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Save and enable from a current-time baseline`]}),(0,X.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Existing matches will not launch tasks.`})]}),u&&(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:u}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(I,{type:`submit`,disabled:c,children:c?`Saving…`:`Save automation`}),(0,X.jsx)(I,{type:`button`,variant:`outline`,onClick:t,children:`Cancel`})]})]})})}function hh({title:e,subtitle:t,action:n,children:r}){return(0,X.jsxs)(`main`,{"data-route":`automations`,className:`task-flow-page w-full`,children:[(0,X.jsxs)(`header`,{className:`mb-6 flex flex-col items-start gap-5`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-2 flex items-center gap-2`,children:(0,X.jsx)(`h1`,{className:`text-[28px] font-medium`,children:e})}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t})]}),n]}),r]})}function gh({text:e}){return(0,X.jsx)(`div`,{role:`status`,className:`rounded-xl border bg-card p-6 text-sm text-muted-foreground`,children:e})}function _h(){let e=H(),t=M(),n=Xt(e.data?.repo?.remote),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!1),s=async()=>{if(!(!e.data||a)){o(!0);try{await navigator.clipboard.writeText(JSON.stringify({version:e.data.version,checks:e.data.checks},null,2)),B(`Diagnostics copied`)}catch{B(`Could not copy diagnostics. Please try again.`,{tone:`danger`})}finally{o(!1)}}};return(0,X.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,X.jsx)(`h1`,{className:`text-[28px] font-normal leading-[1.5] max-md:text-[24px]`,children:`Workspace tools`}),e.data?.capabilities.singleProject===!0?null:(0,X.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,X.jsx)(`h2`,{id:`add-project-heading`,className:`text-lg font-normal leading-[1.5]`,children:`Add project`}),(0,X.jsx)(`p`,{className:`text-[13px] leading-[1.5] text-muted-foreground`,children:`Open an existing local folder or clone a GitHub repository.`}),(0,X.jsxs)(`dl`,{className:`space-y-4 text-[13px] leading-[1.5] text-muted-foreground`,children:[e.data?.repoRoot?(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-x-3`,children:[(0,X.jsx)(`dt`,{children:`Local folder`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all`,children:e.data.repo?.root??e.data.repoRoot})]}):null,n?(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-x-3`,children:[(0,X.jsx)(`dt`,{children:`Repository`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all`,children:n.replace(/^https:\/\//,``)})]}):null,t.data?.projectsDir?(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-x-3`,children:[(0,X.jsx)(`dt`,{children:`Checkout folder`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all`,children:t.data.projectsDir})]}):null]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,X.jsx)(I,{variant:`outline`,className:`h-10 rounded-lg px-[15px] text-xs font-normal leading-[18px]`,onClick:()=>i(`local`),children:`Open local folder`}),(0,X.jsx)(I,{variant:`outline`,className:`h-10 rounded-lg px-[15px] text-xs font-normal leading-[18px]`,onClick:()=>i(`clone`),children:`Clone from GitHub`})]})]}),(0,X.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,X.jsx)(`h2`,{id:`tools-heading`,className:`text-lg font-normal leading-[1.5]`,children:`Tools diagnostics`}),(0,X.jsx)(`p`,{className:`text-[13px] leading-[1.5] text-muted-foreground`,children:`Check the tools available to this local workspace.`}),e.isError?(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:`Could not refresh tool diagnostics. Recheck to retry.`}):null,!e.data&&!e.isError?(0,X.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Checking installed tools…`}):null,e.data?(0,X.jsx)(`dl`,{className:`space-y-4 text-[13px] leading-[1.5] text-muted-foreground`,children:e.data.checks.map(e=>(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-x-4`,children:[(0,X.jsx)(`dt`,{children:e.name}),(0,X.jsxs)(`dd`,{className:`min-w-0 break-words text-muted-foreground`,children:[e.available?`Installed`:`Not installed`,e.version?` · ${e.version}`:``]})]},e.name))}):null,e.data?.checks.length===0?(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No tool diagnostics reported by this server.`}):null,(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,X.jsx)(I,{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,X.jsx)(I,{variant:`outline`,className:`h-10 rounded-lg px-[15px] text-xs font-normal leading-[18px]`,disabled:!e.data||a,onClick:()=>void s(),children:a?`Copying…`:`Copy diagnostics`})]})]}),r===`local`?(0,X.jsx)(gc,{open:!0,onOpenChange:e=>{e||i(null)}}):null,r===`clone`?(0,X.jsx)(yc,{open:!0,onOpenChange:e=>{e||i(null)}}):null]})}var vh=(0,Y.lazy)(()=>dr(()=>import(`./task-thread-DDPFDS8C.js`).then(e=>({default:e.TaskThreadRoute})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35]))),yh=(0,Y.lazy)(()=>dr(()=>import(`./compare-variants-D2dRj6H_.js`).then(e=>({default:e.CompareVariantsRoute})),__vite__mapDeps([36,1,2,3,4,5,6,16,10,27,17,18,19,20,22,33,34]))),bh=(0,Y.lazy)(()=>dr(()=>import(`./task-changes-CpJImtq8.js`).then(e=>({default:e.TaskChangesRoute})),__vite__mapDeps([37,1,2,3,4,5,9,11,8,7,10,12,13,38,39,21,15,6,16,17,18,19,20,22,23,24,25,30,40,41,32]))),xh=(0,Y.lazy)(()=>dr(()=>import(`./task-files-CjTiGtjt.js`).then(e=>({default:e.TaskFilesRoute})),__vite__mapDeps([42,1,2,3,4,5,10,15,8,6,7,11,12,13,16,17,18,19,20,21,22,23,24,25]))),Sh=(0,Y.lazy)(()=>dr(()=>import(`./task-commits-hujrykPI.js`).then(e=>({default:e.TaskCommitsRoute})),__vite__mapDeps([43,1,2,3,4,5,11,8,7,10,12,13,39,15,6,16,17,18,19,20,21,22,23,24,25,27,40,41,32,44,31]))),Ch=(0,Y.lazy)(()=>dr(()=>import(`./repo-git-CWD2dO8S.js`).then(e=>({default:e.RepoGitRoute})),__vite__mapDeps([45,1,2,3,4,5,10,39,38,8,12,13,21,16,27,40,41,32,23,24,44,31,46]))),wh=(0,Y.lazy)(()=>dr(()=>import(`./github-CaGjGQnW.js`).then(e=>({default:e.GithubRoute})),__vite__mapDeps([47,1,2,3,4,5,7,8,9,10,12,14,16,26,17,18,19,20,29,30,40,21,41,32,23,48]))),Th=(0,Y.lazy)(()=>dr(()=>import(`./workflows-DGUQmWy7.js`).then(e=>({default:e.WorkflowsRoute})),__vite__mapDeps([49,1,2,3,4,5,8,9,29,50]))),Eh=(0,Y.lazy)(()=>dr(()=>import(`./skills-e7wHnuoc.js`).then(e=>({default:e.SkillsRoute})),__vite__mapDeps([51,1,2,3,4,5,9,14,8,10,16,29,50])));function Dh(){let e=Jn();return(0,X.jsx)(Gi,{to:{pathname:`/skills`,search:e.search,hash:e.hash},replace:!0})}function Oh({sectionId:e}){let t=Jn();return(0,X.jsx)(Ft,{to:{pathname:jp(`global`,e),search:t.search,hash:t.hash},replace:!0})}function kh(){return(0,X.jsx)(`div`,{"data-route":`scope-resolving`,className:`flex min-h-full flex-col`,children:(0,X.jsx)(`p`,{className:`px-4 py-6 text-center text-xs text-soft-foreground`,children:`Loading…`})})}function Ah(){let{projectId:e=``}=h(),t=Jn(),n=M(),r=H();if(e==="default"){let e=n.data?.bootProject??(n.isError?r.data?.bootProject:void 0);if(e!==void 0){let n=t.pathname.replace(/^\/p\/default(?=\/|$)/,``);return(0,X.jsx)(Ft,{to:`/p/${encodeURIComponent(e)}${n||`/`}${t.search}${t.hash}`,replace:!0})}if(!n.isError)return(0,X.jsx)(kh,{})}if(n.data){if(!(n.data.bootProject===e||n.data.projects.some(t=>t.id===e)))return(0,X.jsx)(fd,{projectId:e,registry:n.data})}else if(!n.isError)return(0,X.jsx)(kh,{});return(0,X.jsx)(Ot,{projectId:n.data?.bootProject===e?null:e,children:(0,X.jsx)(dt,{},e)})}function jh(){let{projectId:e=``}=h();return(0,X.jsx)(ed,{},e)}function Mh(){let e=Jn(),t=H(),n=M(),r=t.data?.bootProject??n.data?.bootProject,i=(t.data!==void 0||t.isError)&&(n.data!==void 0||n.isError);if(r===void 0&&!i)return(0,X.jsx)(kh,{});let a=r??`default`;if(e.pathname===`/`&&e.search===``&&e.hash===``){if(n.data===void 0&&!n.isError)return(0,X.jsx)(kh,{});let e=pu(su(),n.data,r);if(e!==null)return(0,X.jsx)(Ft,{to:e,replace:!0})}let o=e.pathname===`/p`||e.pathname===`/p/`?`/`:e.pathname;return(0,X.jsx)(Ft,{to:`/p/${encodeURIComponent(a)}${o}${e.search}${e.hash}`,replace:!0})}var Nh=[{pattern:`/`,pageLabel:`Tasks`},{pattern:`/tasks`,pageLabel:`All tasks`},{pattern:`/tools`,pageLabel:`Workspace tools`},{pattern:`/new`,pageLabel:`New task`},{pattern:`/compare/:groupId`,pageLabel:`Compare`},{pattern:`/git/*`,pageLabel:`Git`},{pattern:`/github/*`,pageLabel:`GitHub`},{pattern:`/automations/*`,pageLabel:`Automations`},{pattern:`/skills`,pageLabel:`Skills`},{pattern:`/inbox`,pageLabel:`Inbox`},{pattern:`/workflows/*`,pageLabel:`Workflows`},{pattern:`/settings/*`,pageLabel:`Settings`}];function Ph(e){let t=Wi(e),n=yt({path:`/tasks/:id/*`,end:!0},t);return n?{pageLabel:null,taskId:n.params.id??null}:{pageLabel:Nh.find(({pattern:e})=>yt({path:e,end:!0},t))?.pageLabel??null,taskId:null}}function Fh(){let e=H().data?.capabilities;return(0,X.jsxs)(Xn,{children:[(0,X.jsxs)(V,{path:`/p/:projectId`,element:(0,X.jsx)(Ah,{}),children:[(0,X.jsx)(V,{index:!0,element:(0,X.jsx)(_m,{})}),(0,X.jsx)(V,{path:`new`,element:(0,X.jsx)(jh,{})}),(0,X.jsx)(V,{path:`tasks/:id`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(ha,{}),children:(0,X.jsx)(vh,{})})}),(0,X.jsx)(V,{path:`tasks/:id/changes`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(md,{tab:`changes`}),children:(0,X.jsx)(bh,{})})}),(0,X.jsx)(V,{path:`tasks/:id/files`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(md,{tab:`files`}),children:(0,X.jsx)(xh,{})})}),(0,X.jsx)(V,{path:`tasks/:id/commits`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(md,{tab:`changes`}),children:(0,X.jsx)(Sh,{})})}),(0,X.jsx)(V,{path:`tasks/:id/commits/:sha`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(md,{tab:`changes`}),children:(0,X.jsx)(Sh,{})})}),(0,X.jsx)(V,{path:`compare/:groupId`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(hu,{}),children:(0,X.jsx)(yh,{})})}),(0,X.jsx)(V,{path:`git`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(ud,{}),children:(0,X.jsx)(Ch,{tab:`changes`})})}),(0,X.jsx)(V,{path:`git/commits`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(ud,{}),children:(0,X.jsx)(Ch,{tab:`commits`})})}),(0,X.jsx)(V,{path:`git/commits/:sha`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(ud,{}),children:(0,X.jsx)(Ch,{tab:`commits`})})}),(0,X.jsx)(V,{path:`git/branches`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(ud,{}),children:(0,X.jsx)(Ch,{tab:`branches`})})}),(0,X.jsx)(V,{path:`github`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(gu,{}),children:(0,X.jsx)(wh,{view:`issues`,index:!0})})}),(0,X.jsx)(V,{path:`github/prs`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(gu,{}),children:(0,X.jsx)(wh,{view:`prs`})})}),(0,X.jsx)(V,{path:`github/issues/:n`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(gu,{}),children:(0,X.jsx)(wh,{view:`issues`})})}),(0,X.jsx)(V,{path:`github/prs/:n`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(gu,{}),children:(0,X.jsx)(wh,{view:`prs`})})}),(0,X.jsx)(V,{path:`github/prs/:n/changes`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(gu,{}),children:(0,X.jsx)(wh,{view:`prs`,changes:!0})})}),(0,X.jsx)(V,{path:`automations`,element:(0,X.jsx)(dh,{})}),(0,X.jsx)(V,{path:`automations/new`,element:(0,X.jsx)(dh,{mode:`new`})}),(0,X.jsx)(V,{path:`automations/:automationId`,element:(0,X.jsx)(dh,{mode:`edit`})}),(0,X.jsx)(V,{path:`automations/:automationId/log`,element:(0,X.jsx)(dh,{mode:`log`})}),(0,X.jsx)(V,{path:`skills`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(dd,{}),children:(0,X.jsx)(Eh,{})})}),(0,X.jsx)(V,{path:`inbox`,element:(0,X.jsx)(wu,{})}),(0,X.jsx)(V,{path:`workflows`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(pd,{}),children:(0,X.jsx)(Th,{})})}),(0,X.jsx)(V,{path:`workflows/:name`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(pd,{}),children:(0,X.jsx)(Th,{})})}),(0,X.jsx)(V,{path:`settings`,element:(0,X.jsx)(Lp,{scope:`project`,capabilities:e})}),(0,X.jsx)(V,{path:`settings/skills`,element:(0,X.jsx)(Dh,{})}),xp(`project`,e).map(t=>(0,X.jsx)(V,{path:`settings/${t.id}`,element:(0,X.jsx)(Ip,{section:t,scope:`project`,capabilities:e})},t.id)),xp(`global`,e).map(e=>(0,X.jsx)(V,{path:`settings/${e.id}`,element:(0,X.jsx)(Oh,{sectionId:e.id})},e.id)),(0,X.jsx)(V,{path:`*`,element:(0,X.jsx)(ld,{})})]}),(0,X.jsx)(V,{path:`/tasks`,element:(0,X.jsx)($m,{})}),(0,X.jsx)(V,{path:`/tools`,element:(0,X.jsx)(_h,{})}),(0,X.jsx)(V,{path:`/settings/global`,element:(0,X.jsx)(Lp,{scope:`global`,capabilities:e})}),xp(`global`,e).map(t=>(0,X.jsx)(V,{path:jp(`global`,t.id),element:(0,X.jsx)(Ip,{section:t,scope:`global`,capabilities:e})},t.id)),(0,X.jsx)(V,{path:`*`,element:(0,X.jsx)(Mh,{})})]})}function Ih(e){let t=e?.repo;if(!t)return null;let n=t.root.replace(/[\\/]+$/,``).split(/[\\/]/).pop();return n?{name:n,branch:t.branch}:null}function Lh(e){return e?.available===!0&&(e.status===`available`||e.status===`error`)}function Rh({children:e}){let{pathname:t}=Jn(),n=Ki(),r=H(),i=r.data?.capabilities.followups===!0,a=r.data?.capabilities.automations===!0,o=cn(i),s=Lh(bn(n??``,n!==null).data),c=wt(),l=M().data,u=Ph(t),d=l?.bootProject??r.data?.bootProject??null,f=n!==null&&n===d,p=l?.projects.find(e=>e.id===n),m=oe(n??``,p!==void 0&&u.taskId!==null,l?.bootProject===n).data,h=t===`/tools`||t===`/settings/global`||t.startsWith(`/settings/global/`),g=h?null:p?.name??(f?Ih(r.data)?.name??null:null),_=u.taskId?m?.find(e=>e.id===u.taskId):void 0,v=_?A(_):u.pageLabel;au({projectName:g,pageLabel:v});let y=l&&l.projects.length>0?l:null;return(0,X.jsxs)(yl,{children:[(0,X.jsx)(sl,{repo:t===`/tools`?Ih(r.data):h?null:p?{name:p.name,branch:p.id===d?r.data?.repo?.branch??``:``}:Ih(r.data),breadcrumb:{project:t===`/tools`?`Workspace`:g,page:_?`Tasks / ${v}`:v??`Cezarion`,branch:_?.worktreePath?`Isolated worktree`:void 0},version:r.data?.version??null,latestVersion:r.data?.latestVersion??null,inboxCount:o.data?.length??null,unreadCount:c.data?qr(c.data):null,skillsUpdateAvailable:s,forgeAvailable:p?p.forge===`github`:r.data?.forge?.available===!0,inboxAvailable:i,automationsAvailable:a,banner:(0,X.jsx)(Ol,{}),singleProject:r.data?.capabilities.singleProject===!0,taskQuickList:(0,X.jsx)(Rl,{showViewControls:!1}),projectGroups:y?(0,X.jsx)(ql,{projects:y.projects,bootProjectId:y.bootProject,inboxAvailable:i,automationsAvailable:a,inboxCount:o.data?.length??null,skillsUpdateAvailable:s}):void 0,toolsMenu:(0,X.jsx)(eu,{health:r.data,sessionScope:(0,X.jsx)(zl,{})}),children:e}),(0,X.jsx)(Xc,{})]})}function zh(){let e=Jn(),t=M();return(0,Y.useEffect)(()=>{let n=fu(e,t.data);n!==null&&(mu(su(),n)||cu(n))},[e.hash,e.pathname,e.search,t.data]),null}function Bh(){let e=o(),t=Lf(bt().data?.notifications).enabled,n=(0,Y.useRef)(t);n.current=t;let r=(0,Y.useRef)(new Map);return(0,Y.useEffect)(()=>{let t=$n(L.runs.list()),i=e=>{let{entering:t,statuses:i}=zf(r.current,e);if(r.current=i,t.length!==0&&Bf({enabled:n.current,hidden:document.visibilityState===`hidden`,permission:Rf()}))for(let e of t)Vh(e)};return i(e.getQueryData(L.runs.list())),e.getQueryCache().subscribe(e=>{e.query.queryHash!==t||e.type!==`updated`||i(e.query.state.data)})},[e]),null}function Vh(e){let t=globalThis.Notification;if(typeof t!=`function`)return;let n=Vf(e);try{new t(n.title,{body:n.body,tag:n.tag})}catch{}}function Hh(){let[e]=(0,Y.useState)(co);return(0,X.jsx)(lo,{children:(0,X.jsx)(Qt,{client:e,children:(0,X.jsxs)(io,{children:[(0,X.jsx)(Bh,{}),(0,X.jsx)(Lc,{children:(0,X.jsx)(Cf,{children:(0,X.jsxs)(vn,{children:[(0,X.jsx)(zh,{}),(0,X.jsx)(ni,{children:(0,X.jsx)(Rh,{children:(0,X.jsx)(Fh,{})})}),(0,X.jsx)(hn,{})]})})})]})})})}function Uh(){return(document.querySelector(`meta[name="cez-api-base"]`)?.getAttribute(`content`))?.trim()||``}or(Uh());var Wh=document.getElementById(`root`);if(!Wh)throw Error(`cezar: #root container is missing from index.html`);(0,Aa.createRoot)(Wh).render((0,X.jsx)(Y.StrictMode,{children:(0,X.jsx)(Hh,{})}));export{ud as a,Eu as c,yu as d,_u as f,dc as g,_c as h,pd as i,xu as l,hu as m,hd as n,Du as o,gu as p,md as r,Ou as s,Ff as t,bu as u};
7
+ `).toLowerCase()}function Rm(e,t,n){let r=t.query.trim().toLowerCase().split(/\s+/).filter(Boolean);return e.filter(e=>{if((n===`archived`?!e.run.archived:e.run.archived)||!Fm(t.projects??[],[e.run.projectId])||!Fm(t.statuses,[e.run.status])||!Fm(t.workflows,[e.run.workflow])||!Im(e,t.tags))return!1;if(r.length===0)return!0;let i=Lm(e);return r.every(e=>i.includes(e))})}function zm(e,t,n,r){return Rm(e,{...t,[r]:[]},n)}function Bm(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(xm,`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 Vm(e,t){let n=new Map(t.map(e=>[e.id,e.name]));return e.map(e=>n.get(e)||e)}var $={query:`q`,project:`project`,tag:`tag`,untagged:`untagged`,status:`status`,workflow:`workflow`,groupBy:`group`,archived:`archived`},Hm=new Set(Sm.map(e=>e.value));function Um(e){let t=new URLSearchParams,n=e.filters.query.trim();n!==``&&t.set($.query,n);for(let n of e.filters.tags)n===` untagged`?t.set($.untagged,`1`):t.append($.tag,n);for(let n of e.filters.projects??[])t.append($.project,n);for(let n of e.filters.statuses)t.append($.status,n);for(let n of e.filters.workflows)t.append($.workflow,n);return e.groupBy!==`none`&&t.set($.groupBy,e.groupBy),e.view===`archived`&&t.set($.archived,`1`),t}function Wm(e){let t=e.getAll($.tag).filter(e=>e!==``);e.get($.untagged)===`1`&&t.push(xm);let n=e.get($.groupBy)??``;return{filters:{query:e.get($.query)??``,...e.has($.project)?{projects:e.getAll($.project).filter(Boolean)}:{},tags:t,statuses:e.getAll($.status).filter(e=>e!==``),workflows:e.getAll($.workflow).filter(e=>e!==``)},groupBy:Hm.has(n)?n:`none`,view:e.get($.archived)===`1`?`archived`:`active`}}var Gm=15e3,Km=250,qm=1,Jm=220,Ym=new Set([`done`,`failed`,`cancelled`]);function Xm(){return Qm({request:({task:e,archived:t})=>gt(e.run.projectId,e.run.id,t),patch:({archived:e})=>t=>({...t,archived:e})})}function Zm(){return Qm({request:({task:e,read:t})=>dn(e.run.projectId,e.run.id,t),patch:({read:e})=>t=>{if(e)return{...t,seenAt:new Date().toISOString()};let{seenAt:n,...r}=t;return r}})}function Qm({request:e,patch:t}){let n=o();return F({mutationFn:e,onMutate:async e=>{await n.cancelQueries({queryKey:P.runsIndex});let r=n.getQueryData(P.runsIndex),i=t(e),{task:a}=e;return n.setQueryData(P.runsIndex,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.projectId===a.run.projectId&&e.id===a.run.id?i(e):e)}),{previous:r}},onError:(e,t,r)=>{r?.previous&&n.setQueryData(P.runsIndex,r.previous),B(e.message,{tone:`danger`})},onSettled:(e,t,{task:r})=>{n.invalidateQueries({queryKey:P.runsIndex}),n.invalidateQueries({queryKey:L.runs.all}),n.invalidateQueries({queryKey:[r.run.projectId,`runs`,`list`]})}})}function $m(){let e=M(),t=xa(H().data),n=an(!0,Gm),[r,i]=Wn(),{filters:a,groupBy:o,view:s}=Y.useMemo(()=>Wm(r),[r]),c=ma(3e4),l=e=>i(t=>Um(e(Wm(t))),{replace:!0}),u=e=>l(t=>({...t,filters:e(t.filters)})),d=e=>l(t=>({...t,groupBy:e})),f=e=>l(t=>({...t,view:e})),[p,m]=Y.useState(o!==`none`||a.tags.length>0),[h,g]=Y.useState(a.query),_=Y.useRef(a.query);Y.useEffect(()=>{a.query!==_.current&&g(a.query),_.current=a.query},[a.query]),Y.useEffect(()=>{if(h===_.current)return;let e=setTimeout(()=>{_.current=h,u(e=>({...e,query:h}))},Km);return()=>clearTimeout(e)},[h]);let v=n.data?.referenceStatuses;Y.useEffect(()=>{v&&_t(v)},[v]);let y=Y.useMemo(()=>e.data?.projects??[],[e.data]),b=Y.useMemo(()=>Am(n.data?.runs??[],y),[n.data,y]),x=Y.useMemo(()=>Rm(b,a,s),[b,a,s]),S=Y.useMemo(()=>Bm(x,o),[x,o]),C=Y.useMemo(()=>x.flatMap(e=>_e(e.run,e.project?.repoUrl).map(t=>({projectId:e.run.projectId,kind:t.kind,number:t.number}))),[x]),w=Vm(n.data?.truncated??[],y),te=(e,t)=>u(n=>({...n,[e]:Tm(n[e]??[],t)})),T=e=>u(t=>({...t,[e]:[]})),E=Xm(),D=Zm();if(n.isError||e.isError)return(0,X.jsx)(`div`,{"data-route":`global-tasks`,"data-presentation":o===`none`?`summary`:`cards`,"data-filter-details":p,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,X.jsx)(R,{icon:(0,X.jsx)(ee,{}),tone:`danger`,title:`Tasks across projects did not load`,subtitle:(n.error??e.error)?.message,actions:(0,X.jsx)(I,{variant:`outline`,onClick:()=>{n.refetch(),e.refetch()},children:`Retry`})})});let ne=(0,X.jsxs)(`div`,{className:`relative w-full`,children:[(0,X.jsx)(Pe,{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,X.jsx)(`input`,{type:`text`,value:h,onChange:e=>g(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,X.jsxs)(`div`,{"data-route":`global-tasks`,"data-presentation":o===`none`?`summary`:`cards`,"data-filter-details":p,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,X.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-[22px]`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h1`,{className:`text-[30px] font-semibold tracking-tight`,children:`All tasks`}),(0,X.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:o===`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,X.jsxs)(`div`,{className:`flex items-center gap-6 border-b border-border`,children:[(0,X.jsx)(eh,{view:`active`,current:s,onSelect:f,children:`Active`}),(0,X.jsx)(eh,{view:`archived`,current:s,onSelect:f,children:`Archived`}),(0,X.jsxs)(`span`,{"data-slot":`global-tasks-count`,className:`ml-auto text-[12.5px] text-soft-foreground tabular-nums`,children:[x.length,` of `,b.length]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,X.jsx)(`div`,{className:`min-w-0 basis-full md:flex-1 md:basis-auto`,children:ne}),(0,X.jsxs)(I,{variant:`outline`,"aria-expanded":p,onClick:()=>m(e=>!e),children:[(0,X.jsx)(re,{"aria-hidden":`true`}),`Filters`]}),(0,X.jsx)(I,{asChild:!0,className:`min-h-11`,children:(0,X.jsxs)(z,{to:zi(e.data?.bootProject??`default`,`/new`),children:[(0,X.jsx)(ce,{"aria-hidden":`true`}),`New task`]})})]})]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[22px]`,children:[(0,X.jsx)(th,{filters:a,onToggle:te,onClearFacet:T,onClearAll:()=>{g(``),l(e=>({...e,filters:wm,groupBy:`none`}))},groupBy:o,onGroupByChange:d,projects:y,tasks:b,view:s}),w.length>0?(0,X.jsxs)(`p`,{"data-slot":`global-tasks-truncated`,className:`text-[11.5px] text-soft-foreground`,children:[`Showing the newest `,n.data?.perProjectLimit,` tasks per project — older ones in`,` `,w.join(`, `),` are only in that project’s own Tasks page.`]}):null,n.data===void 0?(0,X.jsx)(`div`,{role:`status`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:`Loading tasks…`}):x.length===0?(0,X.jsx)(uh,{view:s,filtered:Dm(a)}):(0,X.jsx)(Hr,{requests:C,children:S.map(e=>(0,X.jsxs)(`section`,{"data-slot":`task-group`,"data-group-key":e.key,children:[o===`none`?null:(0,X.jsxs)(`h2`,{className:`mb-1.5 flex items-center gap-2 text-[12px] font-semibold tracking-[0.04em] text-soft-foreground uppercase`,children:[o===`project`?(0,X.jsx)(z,{to:zi(e.key,`/`),"data-slot":`group-project-link`,className:`hover:text-foreground hover:underline`,children:e.label}):e.label,(0,X.jsx)(`span`,{className:`font-mono text-[11px] font-medium tabular-nums`,children:e.tasks.length})]}),(0,X.jsx)(nh,{tasks:e.tasks,now:c,showProject:o!==`project`,onArchive:(e,t)=>E.mutate({task:e,archived:t}),onSetRead:(e,t)=>D.mutate({task:e,read:t}),busy:E.isPending||D.isPending,showCost:t.cost})]},e.key))}),o===`none`&&x.length>0?(0,X.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,y.length>1?(0,X.jsxs)(`section`,{"data-slot":`other-projects`,className:`rounded-lg border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:`Other projects`}),(0,X.jsx)(`div`,{className:`mt-3 flex flex-col divide-y divide-border`,children:y.map(e=>(0,X.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between gap-3`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate text-[13px]`,children:e.name}),(0,X.jsxs)(z,{to:zi(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,X.jsxs)(`span`,{className:`sr-only`,children:[` for `,e.name]})]})]},e.id))})]}):null]})]})}function eh({view:e,current:t,onSelect:n,children:r}){let i=e===t;return(0,X.jsx)(`button`,{type:`button`,"data-slot":`overview-tab`,"data-view":e,"aria-pressed":i,onClick:()=>n(e),className:U(`flex min-h-11 items-center justify-center border-b-2 border-transparent text-[12.5px] font-medium text-muted-foreground`,i&&`border-accent-strong font-semibold text-accent-text`),children:r})}function th({filters:e,onToggle:t,onClearFacet:n,onClearAll:r,groupBy:i,onGroupByChange:a,projects:o,tasks:s,view:c}){let l=Y.useMemo(()=>_(o),[o]),u=Y.useMemo(()=>{let t=(t,n)=>Nm(zm(s,e,c,t),n);return{projects:t(`projects`,e=>[e.run.projectId]),tags:t(`tags`,Pm),statuses:t(`statuses`,e=>[e.run.status]),workflows:t(`workflows`,e=>[e.run.workflow])}},[s,e,c]),d=e=>t=>({...t,count:e.get(t.value)??0});return(0,X.jsxs)(`div`,{"data-slot":`global-tasks-filters`,className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,X.jsx)(vm,{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(d(u.projects)),emptyLabel:`No tasks to filter`}),(0,X.jsx)(vm,{slot:`status`,label:`Status`,selected:e.statuses,onToggle:e=>t(`statuses`,e),onClear:()=>n(`statuses`),options:Mm(s).map(e=>({value:e,label:e})).map(d(u.statuses)),emptyLabel:`No tasks to filter`}),(0,X.jsx)(vm,{slot:`workflow`,label:`Workflow`,selected:e.workflows,onToggle:e=>t(`workflows`,e),onClear:()=>n(`workflows`),options:jm(s).map(e=>({value:e,label:e})).map(d(u.workflows)),emptyLabel:`No tasks to filter`}),(0,X.jsxs)(`div`,{"data-slot":`group-controls`,className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`text-[11px] font-medium text-soft-foreground`,children:`Group by`}),(0,X.jsx)(bm,{slot:`group-by`,label:`Group tasks by`,value:i,options:Sm,onChange:e=>a(Cm(i,e))})]}),km({filters:e,groupBy:i})?(0,X.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,X.jsx)(In,{className:`size-3`,"aria-hidden":`true`}),`Clear`,` (${Om({filters:e,groupBy:i})})`]}):null]}),l.length>0?(0,X.jsxs)(`div`,{"data-slot":`tag-filters`,className:`flex flex-wrap items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium text-soft-foreground`,children:`Tags`}),l.map(n=>(0,X.jsx)(ym,{slot:`tag-filter`,tone:`tag`,label:n,count:u.tags.get(n)??0,selected:e.tags.some(e=>e.toLowerCase()===n.toLowerCase()),onToggle:()=>t(`tags`,n)},n)),(0,X.jsx)(ym,{slot:`tag-filter`,label:`Untagged`,count:u.tags.get(` untagged`)??0,selected:e.tags.includes(xm),onToggle:()=>t(`tags`,xm)})]}):(0,X.jsxs)(`p`,{"data-slot":`no-tags-hint`,className:`text-[11px] text-soft-foreground`,children:[`Tag connected repositories in`,` `,(0,X.jsx)(z,{to:`/settings/global/projects`,className:`font-medium text-accent-text hover:underline`,children:`Settings → Projects`}),` `,`to group their tasks together here.`]})]})}function nh({tasks:e,now:t,showProject:n,onArchive:r,onSetRead:i,busy:a,showCost:o}){return(0,X.jsxs)(`div`,{"data-slot":`global-tasks-table`,className:`overflow-x-auto rounded-lg border border-border bg-card p-5`,children:[(0,X.jsx)(`div`,{"data-slot":`global-summary-head`,"aria-hidden":`true`,children:[`Task`,`Workflow`,`Changes`,`Pull request`,`Started`].map(e=>(0,X.jsx)(`span`,{children:e},e))}),(0,X.jsx)(Rp,{children:e.map(e=>(0,X.jsx)(rh,{task:e,now:t,showProject:n,onArchive:r,onSetRead:i,busy:a,showCost:o},`${e.run.projectId}/${e.run.id}`))})]})}function rh({task:e,now:t,showProject:n,onArchive:r,onSetRead:i,busy:a,showCost:o}){let{run:s}=e,[c,l]=Y.useState(!1),u=it(s),d=zi(s.projectId,`/tasks/${s.id}`),f=Ur(s),p=Wr(s),m=_e(s,e.project?.repoUrl),h=Ne(s,s.usage);return(0,X.jsxs)(`article`,{"data-status":s.status,"data-expanded":c,"data-slot":`global-task-row`,"data-run-id":s.id,"data-project":s.projectId,className:`hover:bg-muted max-md:flex max-md:flex-wrap max-md:items-center max-md:gap-x-3 max-md:gap-y-2 max-md:border-b max-md:border-border max-md:py-5 max-md:first:pt-0 max-md:last:border-0 max-md:last:pb-0`,children:[(0,X.jsxs)(`div`,{"data-slot":`global-task-title`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[s.delegation?.role===`worker`?(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Worker`}):null,(0,X.jsx)(z,{to:d,title:A(s),className:U(`min-w-0 truncate text-[13px]`,f?`font-semibold text-foreground`:p?`font-medium text-muted-foreground`:`font-medium`),children:A(s)}),f?(0,X.jsx)(G,{tone:`accent`,role:`img`,"aria-label":`unread`,title:`Unread — not opened since it finished`,className:`shrink-0`}):null]}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,"aria-expanded":c,"aria-label":`${c?`Hide`:`Show`} resources for ${A(s)}`,onClick:()=>l(e=>!e),"aria-describedby":`global-status-${s.projectId}-${s.id}`,title:`Resources and actions`,className:`min-h-[26px] rounded-md p-0 text-[11px] text-muted-foreground hover:bg-muted`,children:(0,X.jsx)(ei,{id:`global-status-${s.projectId}-${s.id}`,dot:u.tone,pulse:u.pulse,children:u.label})}),n?(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:(0,X.jsx)(z,{to:zi(s.projectId,`/`),className:`truncate hover:text-foreground`,children:e.projectName})}):null,(0,X.jsx)(`span`,{children:e.tags.length>0?(0,X.jsx)(`span`,{className:`flex flex-wrap items-center gap-1`,children:e.tags.map(e=>(0,X.jsx)(ch,{tag:e},e))}):null})]})]}),(0,X.jsx)(`div`,{"data-slot":`global-task-references`,children:m.length>0?(0,X.jsx)(oh,{references:m,run:s}):(0,X.jsx)(lh,{})}),(0,X.jsx)(`div`,{"data-slot":`global-task-workflow`,className:`text-[12.5px] text-muted-foreground`,children:s.workflow}),(0,X.jsx)(`div`,{"data-slot":`global-task-diff`,className:`text-xs text-muted-foreground`,children:(0,X.jsx)(`span`,{title:`Change totals are available in the project task list`,children:`—`})}),(0,X.jsx)(`div`,{"data-slot":`global-task-age`,className:`text-right text-xs text-soft-foreground tabular-nums`,children:Yi(s.startedAt??s.createdAt,t)}),(0,X.jsx)(`div`,{"data-slot":`global-task-actions`,children:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,X.jsx)(ih,{task:e,busy:a,onSetRead:i}),(0,X.jsx)(ah,{task:e,busy:a,onArchive:r}),(0,X.jsx)(I,{asChild:!0,variant:`outline`,children:(0,X.jsx)(z,{to:d,children:`Open task`})})]})}),c?(0,X.jsx)(`div`,{"data-slot":`global-task-resources`,className:`col-span-full`,children:(0,X.jsxs)(`dl`,{className:`grid grid-cols-2 gap-4 rounded-md bg-muted/50 p-4 text-xs md:grid-cols-3`,children:[o?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:`Cost`}),(0,X.jsx)(`dd`,{className:`mt-1`,children:en(s.costUsd)||`—`})]}):null,(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:`CPU`}),(0,X.jsx)(`dd`,{"data-usage":`cpu`,"data-usage-kind":h.cpu.kind,title:h.cpu.title,className:`mt-1`,children:h.cpu.text||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:`Memory`}),(0,X.jsx)(`dd`,{"data-usage":`mem`,"data-usage-kind":h.mem.kind,title:h.mem.title,className:`mt-1`,children:h.mem.text||`—`})]})]})}):null]})}function ih({task:e,busy:t,onSetRead:n}){if(!Yr(e.run))return null;let r=Ur(e.run),i=A(e.run),a=r?`Mark ${i} read`:`Mark ${i} unread`,o=r?di:$s;return(0,X.jsxs)(zp,{children:[(0,X.jsx)(Bp,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"data-action":r?`mark-read`:`mark-unread`,"aria-label":a,disabled:t,onClick:()=>n(e,r),className:U(`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,X.jsx)(o,{className:`size-3.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:r?`Mark read`:`Mark unread`})]})}),(0,X.jsx)(Vp,{side:`left`,children:r?`Mark read`:`Mark unread`})]})}function ah({task:e,busy:t,onArchive:n}){let r=e.run.archived;if(!r&&!Ym.has(e.run.status))return null;let i=r?`Restore ${A(e.run)} to the active list`:`Archive ${A(e.run)}`;return(0,X.jsxs)(zp,{children:[(0,X.jsx)(Bp,{asChild:!0,children:(0,X.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,X.jsx)(r?Kr:Ke,{className:`size-3.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:r?`Unarchive`:`Archive`})]})}),(0,X.jsx)(Vp,{side:`left`,children:r?`Restore`:`Archive`})]})}function oh({references:e,run:t}){let n=e.slice(0,qm),r=e.length-n.length,i=A(t);return(0,X.jsxs)(`span`,{className:`flex flex-nowrap items-center gap-1`,children:[n.map(e=>(0,X.jsx)(Jr,{reference:e,taskTitle:i,projectId:t.projectId,conflictAction:(0,X.jsx)(Xr,{projectId:t.projectId,runId:t.id,prNumber:e.number}),className:`shrink-0`},`${e.kind}#${e.number}`)),r>0?(0,X.jsx)(sh,{references:e,taskTitle:i,hidden:r,projectId:t.projectId}):null]})}function sh({references:e,taskTitle:t,hidden:n,projectId:r}){let[i,a]=Y.useState(!1),o=Y.useRef(!1),s=Y.useRef(void 0);Y.useEffect(()=>()=>clearTimeout(s.current),[]);let c=e=>e.pointerType!==`touch`,l=()=>clearTimeout(s.current),u=e=>{c(e)&&(l(),o.current=!0,a(!0))},d=e=>{c(e)&&(l(),s.current=setTimeout(()=>a(!1),Jm))};return(0,X.jsxs)(Mr,{open:i,onOpenChange:a,children:[(0,X.jsx)(jr,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"data-slot":`reference-overflow`,"aria-label":`Show all ${e.length} references for ${t}`,onPointerEnter:u,onPointerLeave:d,onPointerDown:()=>{o.current=!1},onClick:()=>{o.current=!1},className:`shrink-0 rounded-full px-1 text-[11px] font-medium text-soft-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:[`+`,n]})}),(0,X.jsxs)(Or,{align:`start`,className:`w-auto min-w-40 p-1.5`,"data-slot":`reference-overflow-list`,onPointerEnter:u,onPointerLeave:d,onOpenAutoFocus:e=>{o.current&&e.preventDefault()},onCloseAutoFocus:e=>{o.current&&e.preventDefault()},children:[(0,X.jsx)(`p`,{className:`px-1 pb-1.5 text-[10.5px] text-soft-foreground`,children:`References`}),(0,X.jsx)(`span`,{className:`flex flex-col items-start gap-1`,children:e.map(e=>(0,X.jsx)(Jr,{reference:e,taskTitle:t,projectId:r},`${e.kind}#${e.number}`))})]})]})}function ch({tag:e,className:t}){return(0,X.jsx)(`span`,{"data-slot":`project-tag`,className:U(`inline-flex max-w-full items-center truncate rounded-full bg-muted px-1.5 py-px text-[10.5px] font-medium text-muted-foreground`,t),children:e})}function lh(){return(0,X.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`})}function uh({view:e,filtered:t}){return t?(0,X.jsx)(R,{heading:`h2`,icon:(0,X.jsx)(Ji,{}),tone:`neutral`,title:`No matching tasks`,subtitle:`No task in any project matches these filters.`}):e===`archived`?(0,X.jsx)(R,{heading:`h2`,icon:(0,X.jsx)(Ke,{}),tone:`neutral`,title:`Nothing archived yet`,subtitle:`Finished tasks you archive land here, from every project.`}):(0,X.jsx)(R,{heading:`h2`,icon:(0,X.jsx)(oc,{}),tone:`neutral`,title:`No tasks yet`,subtitle:`Start a task in any project and it shows up here.`})}function dh({mode:e=`list`}){let{automationId:t}=h(),n=Bi(),r=Ki(),[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)({}),u=H(),d=u.data!==void 0,f=d&&u.data.capabilities?.automations!==!0,p=()=>Gn().then(e=>{a(e),s(``)}).catch(e=>s(String(e)));if((0,Y.useEffect)(()=>{d&&!f&&p()},[d,f]),(0,Y.useEffect)(()=>Ga((e,t)=>{if(e!==`automation-change`)return;let n=t;typeof n.project==`string`&&(r===null||n.project===r)&&p()}),[r]),!d)return(0,X.jsx)(`div`,{"data-route":`automations`,className:`task-flow-page flex min-h-full flex-col`,children:(0,X.jsx)(gh,{text:`Loading automations…`})});if(f)return(0,X.jsx)(`div`,{"data-route":`automations`,className:`task-flow-page flex min-h-full flex-col`,children:(0,X.jsx)(R,{icon:(0,X.jsx)(pn,{}),tone:`neutral`,title:`GitHub automations are off`,subtitle:`This server does not poll GitHub or launch tasks from it. Set CEZ_AUTOMATIONS=1 and restart cezar to turn automations on.`,heading:`h2`})});if(e===`new`)return(0,X.jsx)(mh,{onSaved:()=>{n(`/automations`),p()}});if(e===`edit`){let e=i?.automations.find(e=>e.id===t);return o?(0,X.jsxs)(hh,{title:`Edit automation`,subtitle:`Could not load this automation.`,children:[(0,X.jsx)(gh,{text:o}),(0,X.jsx)(I,{variant:`outline`,onClick:()=>void p(),children:`Retry`})]}):i&&!e?(0,X.jsx)(hh,{title:`Automation not found`,subtitle:`This automation may have been removed.`,children:(0,X.jsx)(I,{asChild:!0,variant:`outline`,children:(0,X.jsx)(J,{to:`/automations`,children:`Back to automations`})})}):e?(0,X.jsx)(mh,{automation:e,onSaved:()=>{n(`/automations`),p()}}):(0,X.jsx)(gh,{text:`Loading automation…`})}if(e===`log`){let e=i?.automations.find(e=>e.id===t);return t?(0,X.jsx)(ph,{automationId:t,automationName:e?.name}):(0,X.jsx)(gh,{text:`Automation not found.`})}let m=async e=>{l(t=>({...t,[e.id]:`Checking…`}));try{let{checkId:t}=await nn(e.id,`preview`);for(let n=0;n<60;n+=1){let n=await Ie(t);if(n.status===`complete`){l(t=>({...t,[e.id]:`${n.matches??0} match${n.matches===1?``:`es`} found; no tasks launched.`})),p();return}if(n.status===`error`)throw Error(n.error??`Preview failed`);await new Promise(e=>setTimeout(e,500))}throw Error(`Preview is still running`)}catch(t){l(n=>({...n,[e.id]:t instanceof Error?t.message:String(t)}))}};return(0,X.jsx)(hh,{title:`Automations`,subtitle:`Checks run while Cezarion is open. No webhook or public URL required.`,action:(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(I,{asChild:!0,children:(0,X.jsx)(J,{to:`/automations/new`,children:`New automation`})}),(0,X.jsx)(I,{variant:`outline`,asChild:!0,children:(0,X.jsx)(J,{to:`/github`,children:`GitHub`})})]}),children:o?(0,X.jsxs)(`div`,{className:`grid gap-3`,children:[(0,X.jsx)(gh,{text:o}),(0,X.jsx)(I,{variant:`outline`,onClick:()=>void p(),children:`Retry`})]}):i?(0,X.jsxs)(X.Fragment,{children:[i.automations.length===0?(0,X.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-6`,children:[(0,X.jsx)(`h2`,{className:`text-xl font-normal`,children:`No automations yet`}),(0,X.jsx)(`p`,{className:`mt-5 text-sm text-muted-foreground`,children:`Create a bounded trigger to start ordinary tasks from new GitHub issues.`})]}):(0,X.jsx)(`div`,{className:`grid gap-3`,children:i.automations.map(e=>(0,X.jsxs)(`article`,{className:`rounded-xl border bg-card p-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`font-semibold`,children:e.name}),(0,X.jsxs)(`p`,{className:`mt-6 text-[13px] text-muted-foreground`,children:[e.events.join(`, `),` · every `,Math.round(e.intervalSeconds/60),` min`]})]}),(0,X.jsx)(`span`,{className:`rounded-lg border px-4 py-3 text-xs`,children:e.enabled?`Enabled`:`Paused`})]}),(0,X.jsx)(fh,{data:i}),(0,X.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-3`,children:[(0,X.jsx)(I,{variant:`outline`,asChild:!0,children:(0,X.jsx)(J,{to:`/automations/${e.id}`,children:`Edit`})}),(0,X.jsx)(I,{variant:`outline`,asChild:!0,children:(0,X.jsx)(J,{to:`/automations/${e.id}/log`,children:`Execution log`})}),(0,X.jsx)(I,{variant:`outline`,onClick:()=>void Pn(e.id,!e.enabled).then(p),children:e.enabled?`Pause`:`Enable`}),(0,X.jsx)(I,{variant:`outline`,onClick:()=>void m(e),disabled:c[e.id]===`Checking…`,children:`Test filter`})]}),c[e.id]&&(0,X.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,role:`status`,children:c[e.id]})]},e.id))}),i.automations.length===0?(0,X.jsx)(fh,{data:i}):null,i.automations.map(e=>(0,X.jsx)(ph,{automationId:e.id,automationName:e.name,showName:i.automations.length>1,inline:!0},e.id))]}):(0,X.jsx)(gh,{text:`Loading automations…`})})}function fh({data:e}){return(0,X.jsxs)(`p`,{"data-slot":`automation-scheduler`,className:`mt-4 text-xs ${e.available?e.scheduler.state===`scheduled`?`text-success`:`text-muted-foreground`:`text-destructive`}`,children:[`Scheduler `,e.scheduler.state,` · GitHub `,e.available?`available`:`unavailable`,e.reason?` · ${e.reason}`:``]})}function ph({automationId:e,automationName:t,inline:n=!1,showName:r=!1}){let[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(``),c=()=>g(e).then(({records:e})=>{a(e),s(``)}).catch(e=>s(String(e)));(0,Y.useEffect)(()=>{c()},[e]),(0,Y.useEffect)(()=>Ga((t,n)=>{t===`automation-change`&&n.automationId===e&&c()}),[e]);let l=(0,X.jsx)(X.Fragment,{children:o?(0,X.jsxs)(`div`,{className:`grid gap-3`,children:[(0,X.jsx)(gh,{text:o}),(0,X.jsx)(I,{variant:`outline`,onClick:()=>void c(),children:`Retry`})]}):i?i.length===0?(0,X.jsx)(gh,{text:`No checks have run yet.`}):(0,X.jsx)(`ol`,{className:`grid gap-3`,"aria-label":`Automation execution log`,children:(n?i.slice(0,5):i).map(e=>(0,X.jsxs)(`li`,{className:`rounded-xl border bg-card p-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium capitalize`,children:e.result.replace(`-`,` `)}),(0,X.jsx)(`time`,{className:`text-xs text-muted-foreground`,dateTime:e.ts,children:new Date(e.ts).toLocaleString()})]}),e.reason&&(0,X.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:e.reason}),(e.githubUrl||e.runId)&&(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-3 text-sm`,children:[e.githubUrl&&(0,X.jsx)(`a`,{className:`underline underline-offset-4`,href:e.githubUrl,target:`_blank`,rel:`noreferrer`,children:e.githubTitle??`GitHub #${e.githubNumber??``}`}),e.runId&&(0,X.jsx)(J,{className:`underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`})]})]},e.seq))}):(0,X.jsx)(gh,{text:`Loading execution log…`})});return n?(0,X.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`mt-5 rounded-xl border border-border bg-card p-6`,children:[(0,X.jsxs)(`h2`,{className:`mb-4 text-lg font-medium`,children:[`Recent activity`,r?` · ${t}`:``]}),l]}):(0,X.jsx)(hh,{title:`Execution log`,subtitle:t??`Automation activity`,action:(0,X.jsx)(I,{variant:`outline`,asChild:!0,children:(0,X.jsx)(J,{to:`/automations`,children:`Back to automations`})}),children:l})}function mh({automation:e,onSaved:t}){let[n,r]=(0,Y.useState)(e?.name??``),[i,a]=(0,Y.useState)(e?.task.prompt??`Review {{github.url}}`),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(``);return(0,X.jsx)(hh,{title:e?`Edit automation`:`New automation`,subtitle:`Define a bounded GitHub trigger and the ordinary task it launches.`,children:(0,X.jsxs)(`form`,{className:`automation-editor grid gap-5`,onSubmit:async r=>{if(r.preventDefault(),!c){l(!0),d(``);try{e?(await ht(e.id,{name:n,description:e.description,events:e.events,intervalSeconds:e.intervalSeconds,filters:e.filters,task:{...e.task,prompt:i},enabled:e.enabled,expectedRevision:e.revision}),o&&!e.enabled&&await Pn(e.id,!0)):await sn({name:n,events:[`issue.opened`],intervalSeconds:300,filters:{lookbackDays:7,maxRecords:25},task:{prompt:i,workflow:`quick-task`},enable:o}),t()}catch(e){d(String(e))}finally{l(!1)}}},children:[(0,X.jsxs)(`fieldset`,{className:`grid gap-4 rounded-xl border p-5`,children:[(0,X.jsx)(`legend`,{className:`px-2 font-semibold`,children:`When GitHub changes`}),(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsx)(vc,{htmlFor:`automation-name`,children:`Name`}),(0,X.jsx)(_c,{id:`automation-name`,value:n,onChange:e=>r(e.target.value),required:!0})]}),(0,X.jsx)(`div`,{className:`flex items-center gap-2 text-sm`,children:e?`Saved trigger · ${e.events.join(`, `)} · Every ${Math.round(e.intervalSeconds/60)} minutes`:`New issue · every 5 minutes · last 7 days · maximum 25 records`})]}),(0,X.jsxs)(`fieldset`,{className:`grid gap-4 rounded-xl border p-5`,children:[(0,X.jsx)(`legend`,{className:`px-2 font-semibold`,children:`What task to run`}),(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsx)(vc,{htmlFor:`automation-prompt`,children:`Prompt`}),(0,X.jsx)(Br,{id:`automation-prompt`,value:i,onChange:e=>a(e.target.value),rows:2,required:!0})]}),(0,X.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Available: `,`{{github.number}}`,` `,`{{github.title}}`,` `,`{{github.url}}`,` `,`{{github.labels}}`]}),(0,X.jsx)(`p`,{className:`text-xs text-pending-strong`,children:`GitHub content is appended as untrusted context.`})]}),e?.enabled?null:(0,X.jsxs)(`fieldset`,{className:`relative rounded-xl border p-5`,children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:`Review and enable`}),(0,X.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Save and enable from a current-time baseline`]}),(0,X.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Existing matches will not launch tasks.`})]}),u&&(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:u}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(I,{type:`submit`,disabled:c,children:c?`Saving…`:`Save automation`}),(0,X.jsx)(I,{type:`button`,variant:`outline`,onClick:t,children:`Cancel`})]})]})})}function hh({title:e,subtitle:t,action:n,children:r}){return(0,X.jsxs)(`main`,{"data-route":`automations`,className:`task-flow-page w-full`,children:[(0,X.jsxs)(`header`,{className:`mb-6 flex flex-col items-start gap-5`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-2 flex items-center gap-2`,children:(0,X.jsx)(`h1`,{className:`text-[28px] font-medium`,children:e})}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t})]}),n]}),r]})}function gh({text:e}){return(0,X.jsx)(`div`,{role:`status`,className:`rounded-xl border bg-card p-6 text-sm text-muted-foreground`,children:e})}function _h(){let e=H(),t=M(),n=Xt(e.data?.repo?.remote),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!1),s=async()=>{if(!(!e.data||a)){o(!0);try{await navigator.clipboard.writeText(JSON.stringify({version:e.data.version,checks:e.data.checks},null,2)),B(`Diagnostics copied`)}catch{B(`Could not copy diagnostics. Please try again.`,{tone:`danger`})}finally{o(!1)}}};return(0,X.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,X.jsx)(`h1`,{className:`text-[28px] font-normal leading-[1.5] max-md:text-[24px]`,children:`Workspace tools`}),e.data?.capabilities.singleProject===!0?null:(0,X.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,X.jsx)(`h2`,{id:`add-project-heading`,className:`text-lg font-normal leading-[1.5]`,children:`Add project`}),(0,X.jsx)(`p`,{className:`text-[13px] leading-[1.5] text-muted-foreground`,children:`Open an existing local folder or clone a GitHub repository.`}),(0,X.jsxs)(`dl`,{className:`space-y-4 text-[13px] leading-[1.5] text-muted-foreground`,children:[e.data?.repoRoot?(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-x-3`,children:[(0,X.jsx)(`dt`,{children:`Local folder`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all`,children:e.data.repo?.root??e.data.repoRoot})]}):null,n?(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-x-3`,children:[(0,X.jsx)(`dt`,{children:`Repository`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all`,children:n.replace(/^https:\/\//,``)})]}):null,t.data?.projectsDir?(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-x-3`,children:[(0,X.jsx)(`dt`,{children:`Checkout folder`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all`,children:t.data.projectsDir})]}):null]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,X.jsx)(I,{variant:`outline`,className:`h-10 rounded-lg px-[15px] text-xs font-normal leading-[18px]`,onClick:()=>i(`local`),children:`Open local folder`}),(0,X.jsx)(I,{variant:`outline`,className:`h-10 rounded-lg px-[15px] text-xs font-normal leading-[18px]`,onClick:()=>i(`clone`),children:`Clone from GitHub`})]})]}),(0,X.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,X.jsx)(`h2`,{id:`tools-heading`,className:`text-lg font-normal leading-[1.5]`,children:`Tools diagnostics`}),(0,X.jsx)(`p`,{className:`text-[13px] leading-[1.5] text-muted-foreground`,children:`Check the tools available to this local workspace.`}),e.isError?(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:`Could not refresh tool diagnostics. Recheck to retry.`}):null,!e.data&&!e.isError?(0,X.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Checking installed tools…`}):null,e.data?(0,X.jsx)(`dl`,{className:`space-y-4 text-[13px] leading-[1.5] text-muted-foreground`,children:e.data.checks.map(e=>(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-x-4`,children:[(0,X.jsx)(`dt`,{children:e.name}),(0,X.jsxs)(`dd`,{className:`min-w-0 break-words text-muted-foreground`,children:[e.available?`Installed`:`Not installed`,e.version?` · ${e.version}`:``]})]},e.name))}):null,e.data?.checks.length===0?(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No tool diagnostics reported by this server.`}):null,(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,X.jsx)(I,{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,X.jsx)(I,{variant:`outline`,className:`h-10 rounded-lg px-[15px] text-xs font-normal leading-[18px]`,disabled:!e.data||a,onClick:()=>void s(),children:a?`Copying…`:`Copy diagnostics`})]})]}),r===`local`?(0,X.jsx)(gc,{open:!0,onOpenChange:e=>{e||i(null)}}):null,r===`clone`?(0,X.jsx)(yc,{open:!0,onOpenChange:e=>{e||i(null)}}):null]})}var vh=(0,Y.lazy)(()=>dr(()=>import(`./task-thread-DGM2dZV-.js`).then(e=>({default:e.TaskThreadRoute})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35]))),yh=(0,Y.lazy)(()=>dr(()=>import(`./compare-variants-Ciqwvd_f.js`).then(e=>({default:e.CompareVariantsRoute})),__vite__mapDeps([36,1,2,3,4,5,6,16,10,27,17,18,19,20,22,33,34]))),bh=(0,Y.lazy)(()=>dr(()=>import(`./task-changes-D2PHtWUW.js`).then(e=>({default:e.TaskChangesRoute})),__vite__mapDeps([37,1,2,3,4,5,9,11,8,7,10,12,13,38,39,21,15,6,16,17,18,19,20,22,23,24,25,30,40,41,32]))),xh=(0,Y.lazy)(()=>dr(()=>import(`./task-files-BS7c7CFm.js`).then(e=>({default:e.TaskFilesRoute})),__vite__mapDeps([42,1,2,3,4,5,10,15,8,6,7,11,12,13,16,17,18,19,20,21,22,23,24,25]))),Sh=(0,Y.lazy)(()=>dr(()=>import(`./task-commits-N5u9U0_R.js`).then(e=>({default:e.TaskCommitsRoute})),__vite__mapDeps([43,1,2,3,4,5,11,8,7,10,12,13,39,15,6,16,17,18,19,20,21,22,23,24,25,27,40,41,32,44,31]))),Ch=(0,Y.lazy)(()=>dr(()=>import(`./repo-git-Bm3s6Why.js`).then(e=>({default:e.RepoGitRoute})),__vite__mapDeps([45,1,2,3,4,5,10,39,38,8,12,13,21,16,27,40,41,32,23,24,44,31,46]))),wh=(0,Y.lazy)(()=>dr(()=>import(`./github-D-MrkbJ7.js`).then(e=>({default:e.GithubRoute})),__vite__mapDeps([47,1,2,3,4,5,7,8,9,10,12,14,16,26,17,18,19,20,29,30,40,21,41,32,23,48]))),Th=(0,Y.lazy)(()=>dr(()=>import(`./workflows-Czl0ZfXH.js`).then(e=>({default:e.WorkflowsRoute})),__vite__mapDeps([49,1,2,3,4,5,8,9,29,50]))),Eh=(0,Y.lazy)(()=>dr(()=>import(`./skills-C-C4DVFY.js`).then(e=>({default:e.SkillsRoute})),__vite__mapDeps([51,1,2,3,4,5,9,14,8,10,16,29,50])));function Dh(){let e=Jn();return(0,X.jsx)(Gi,{to:{pathname:`/skills`,search:e.search,hash:e.hash},replace:!0})}function Oh({sectionId:e}){let t=Jn();return(0,X.jsx)(Ft,{to:{pathname:jp(`global`,e),search:t.search,hash:t.hash},replace:!0})}function kh(){return(0,X.jsx)(`div`,{"data-route":`scope-resolving`,className:`flex min-h-full flex-col`,children:(0,X.jsx)(`p`,{className:`px-4 py-6 text-center text-xs text-soft-foreground`,children:`Loading…`})})}function Ah(){let{projectId:e=``}=h(),t=Jn(),n=M(),r=H();if(e==="default"){let e=n.data?.bootProject??(n.isError?r.data?.bootProject:void 0);if(e!==void 0){let n=t.pathname.replace(/^\/p\/default(?=\/|$)/,``);return(0,X.jsx)(Ft,{to:`/p/${encodeURIComponent(e)}${n||`/`}${t.search}${t.hash}`,replace:!0})}if(!n.isError)return(0,X.jsx)(kh,{})}if(n.data){if(!(n.data.bootProject===e||n.data.projects.some(t=>t.id===e)))return(0,X.jsx)(fd,{projectId:e,registry:n.data})}else if(!n.isError)return(0,X.jsx)(kh,{});return(0,X.jsx)(Ot,{projectId:n.data?.bootProject===e?null:e,children:(0,X.jsx)(dt,{},e)})}function jh(){let{projectId:e=``}=h();return(0,X.jsx)(ed,{},e)}function Mh(){let e=Jn(),t=H(),n=M(),r=t.data?.bootProject??n.data?.bootProject,i=(t.data!==void 0||t.isError)&&(n.data!==void 0||n.isError);if(r===void 0&&!i)return(0,X.jsx)(kh,{});let a=r??`default`;if(e.pathname===`/`&&e.search===``&&e.hash===``){if(n.data===void 0&&!n.isError)return(0,X.jsx)(kh,{});let e=pu(su(),n.data,r);if(e!==null)return(0,X.jsx)(Ft,{to:e,replace:!0})}let o=e.pathname===`/p`||e.pathname===`/p/`?`/`:e.pathname;return(0,X.jsx)(Ft,{to:`/p/${encodeURIComponent(a)}${o}${e.search}${e.hash}`,replace:!0})}var Nh=[{pattern:`/`,pageLabel:`Tasks`},{pattern:`/tasks`,pageLabel:`All tasks`},{pattern:`/tools`,pageLabel:`Workspace tools`},{pattern:`/new`,pageLabel:`New task`},{pattern:`/compare/:groupId`,pageLabel:`Compare`},{pattern:`/git/*`,pageLabel:`Git`},{pattern:`/github/*`,pageLabel:`GitHub`},{pattern:`/automations/*`,pageLabel:`Automations`},{pattern:`/skills`,pageLabel:`Skills`},{pattern:`/inbox`,pageLabel:`Inbox`},{pattern:`/workflows/*`,pageLabel:`Workflows`},{pattern:`/settings/*`,pageLabel:`Settings`}];function Ph(e){let t=Wi(e),n=yt({path:`/tasks/:id/*`,end:!0},t);return n?{pageLabel:null,taskId:n.params.id??null}:{pageLabel:Nh.find(({pattern:e})=>yt({path:e,end:!0},t))?.pageLabel??null,taskId:null}}function Fh(){let e=H().data?.capabilities;return(0,X.jsxs)(Xn,{children:[(0,X.jsxs)(V,{path:`/p/:projectId`,element:(0,X.jsx)(Ah,{}),children:[(0,X.jsx)(V,{index:!0,element:(0,X.jsx)(_m,{})}),(0,X.jsx)(V,{path:`new`,element:(0,X.jsx)(jh,{})}),(0,X.jsx)(V,{path:`tasks/:id`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(ha,{}),children:(0,X.jsx)(vh,{})})}),(0,X.jsx)(V,{path:`tasks/:id/changes`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(md,{tab:`changes`}),children:(0,X.jsx)(bh,{})})}),(0,X.jsx)(V,{path:`tasks/:id/files`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(md,{tab:`files`}),children:(0,X.jsx)(xh,{})})}),(0,X.jsx)(V,{path:`tasks/:id/commits`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(md,{tab:`changes`}),children:(0,X.jsx)(Sh,{})})}),(0,X.jsx)(V,{path:`tasks/:id/commits/:sha`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(md,{tab:`changes`}),children:(0,X.jsx)(Sh,{})})}),(0,X.jsx)(V,{path:`compare/:groupId`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(hu,{}),children:(0,X.jsx)(yh,{})})}),(0,X.jsx)(V,{path:`git`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(ud,{}),children:(0,X.jsx)(Ch,{tab:`changes`})})}),(0,X.jsx)(V,{path:`git/commits`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(ud,{}),children:(0,X.jsx)(Ch,{tab:`commits`})})}),(0,X.jsx)(V,{path:`git/commits/:sha`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(ud,{}),children:(0,X.jsx)(Ch,{tab:`commits`})})}),(0,X.jsx)(V,{path:`git/branches`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(ud,{}),children:(0,X.jsx)(Ch,{tab:`branches`})})}),(0,X.jsx)(V,{path:`github`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(gu,{}),children:(0,X.jsx)(wh,{view:`issues`,index:!0})})}),(0,X.jsx)(V,{path:`github/prs`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(gu,{}),children:(0,X.jsx)(wh,{view:`prs`})})}),(0,X.jsx)(V,{path:`github/issues/:n`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(gu,{}),children:(0,X.jsx)(wh,{view:`issues`})})}),(0,X.jsx)(V,{path:`github/prs/:n`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(gu,{}),children:(0,X.jsx)(wh,{view:`prs`})})}),(0,X.jsx)(V,{path:`github/prs/:n/changes`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(gu,{}),children:(0,X.jsx)(wh,{view:`prs`,changes:!0})})}),(0,X.jsx)(V,{path:`automations`,element:(0,X.jsx)(dh,{})}),(0,X.jsx)(V,{path:`automations/new`,element:(0,X.jsx)(dh,{mode:`new`})}),(0,X.jsx)(V,{path:`automations/:automationId`,element:(0,X.jsx)(dh,{mode:`edit`})}),(0,X.jsx)(V,{path:`automations/:automationId/log`,element:(0,X.jsx)(dh,{mode:`log`})}),(0,X.jsx)(V,{path:`skills`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(dd,{}),children:(0,X.jsx)(Eh,{})})}),(0,X.jsx)(V,{path:`inbox`,element:(0,X.jsx)(wu,{})}),(0,X.jsx)(V,{path:`workflows`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(pd,{}),children:(0,X.jsx)(Th,{})})}),(0,X.jsx)(V,{path:`workflows/:name`,element:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(pd,{}),children:(0,X.jsx)(Th,{})})}),(0,X.jsx)(V,{path:`settings`,element:(0,X.jsx)(Lp,{scope:`project`,capabilities:e})}),(0,X.jsx)(V,{path:`settings/skills`,element:(0,X.jsx)(Dh,{})}),xp(`project`,e).map(t=>(0,X.jsx)(V,{path:`settings/${t.id}`,element:(0,X.jsx)(Ip,{section:t,scope:`project`,capabilities:e})},t.id)),xp(`global`,e).map(e=>(0,X.jsx)(V,{path:`settings/${e.id}`,element:(0,X.jsx)(Oh,{sectionId:e.id})},e.id)),(0,X.jsx)(V,{path:`*`,element:(0,X.jsx)(ld,{})})]}),(0,X.jsx)(V,{path:`/tasks`,element:(0,X.jsx)($m,{})}),(0,X.jsx)(V,{path:`/tools`,element:(0,X.jsx)(_h,{})}),(0,X.jsx)(V,{path:`/settings/global`,element:(0,X.jsx)(Lp,{scope:`global`,capabilities:e})}),xp(`global`,e).map(t=>(0,X.jsx)(V,{path:jp(`global`,t.id),element:(0,X.jsx)(Ip,{section:t,scope:`global`,capabilities:e})},t.id)),(0,X.jsx)(V,{path:`*`,element:(0,X.jsx)(Mh,{})})]})}function Ih(e){let t=e?.repo;if(!t)return null;let n=t.root.replace(/[\\/]+$/,``).split(/[\\/]/).pop();return n?{name:n,branch:t.branch}:null}function Lh(e){return e?.available===!0&&(e.status===`available`||e.status===`error`)}function Rh({children:e}){let{pathname:t}=Jn(),n=Ki(),r=H(),i=r.data?.capabilities.followups===!0,a=r.data?.capabilities.automations===!0,o=cn(i),s=Lh(bn(n??``,n!==null).data),c=wt(),l=M().data,u=Ph(t),d=l?.bootProject??r.data?.bootProject??null,f=n!==null&&n===d,p=l?.projects.find(e=>e.id===n),m=oe(n??``,p!==void 0&&u.taskId!==null,l?.bootProject===n).data,h=t===`/tools`||t===`/settings/global`||t.startsWith(`/settings/global/`),g=h?null:p?.name??(f?Ih(r.data)?.name??null:null),_=u.taskId?m?.find(e=>e.id===u.taskId):void 0,v=_?A(_):u.pageLabel;au({projectName:g,pageLabel:v});let y=l&&l.projects.length>0?l:null;return(0,X.jsxs)(yl,{children:[(0,X.jsx)(sl,{repo:t===`/tools`?Ih(r.data):h?null:p?{name:p.name,branch:p.id===d?r.data?.repo?.branch??``:``}:Ih(r.data),breadcrumb:{project:t===`/tools`?`Workspace`:g,page:_?`Tasks / ${v}`:v??`Cezarion`,branch:_?.worktreePath?`Isolated worktree`:void 0},version:r.data?.version??null,latestVersion:r.data?.latestVersion??null,inboxCount:o.data?.length??null,unreadCount:c.data?qr(c.data):null,skillsUpdateAvailable:s,forgeAvailable:p?p.forge===`github`:r.data?.forge?.available===!0,inboxAvailable:i,automationsAvailable:a,banner:(0,X.jsx)(Ol,{}),singleProject:r.data?.capabilities.singleProject===!0,taskQuickList:(0,X.jsx)(Rl,{showViewControls:!1}),projectGroups:y?(0,X.jsx)(ql,{projects:y.projects,bootProjectId:y.bootProject,inboxAvailable:i,automationsAvailable:a,inboxCount:o.data?.length??null,skillsUpdateAvailable:s}):void 0,toolsMenu:(0,X.jsx)(eu,{health:r.data,sessionScope:(0,X.jsx)(zl,{})}),children:e}),(0,X.jsx)(Xc,{})]})}function zh(){let e=Jn(),t=M();return(0,Y.useEffect)(()=>{let n=fu(e,t.data);n!==null&&(mu(su(),n)||cu(n))},[e.hash,e.pathname,e.search,t.data]),null}function Bh(){let e=o(),t=Lf(bt().data?.notifications).enabled,n=(0,Y.useRef)(t);n.current=t;let r=(0,Y.useRef)(new Map);return(0,Y.useEffect)(()=>{let t=$n(L.runs.list()),i=e=>{let{entering:t,statuses:i}=zf(r.current,e);if(r.current=i,t.length!==0&&Bf({enabled:n.current,hidden:document.visibilityState===`hidden`,permission:Rf()}))for(let e of t)Vh(e)};return i(e.getQueryData(L.runs.list())),e.getQueryCache().subscribe(e=>{e.query.queryHash!==t||e.type!==`updated`||i(e.query.state.data)})},[e]),null}function Vh(e){let t=globalThis.Notification;if(typeof t!=`function`)return;let n=Vf(e);try{new t(n.title,{body:n.body,tag:n.tag})}catch{}}function Hh(){let[e]=(0,Y.useState)(co);return(0,X.jsx)(lo,{children:(0,X.jsx)(Qt,{client:e,children:(0,X.jsxs)(io,{children:[(0,X.jsx)(Bh,{}),(0,X.jsx)(Lc,{children:(0,X.jsx)(Cf,{children:(0,X.jsxs)(vn,{children:[(0,X.jsx)(zh,{}),(0,X.jsx)(ni,{children:(0,X.jsx)(Rh,{children:(0,X.jsx)(Fh,{})})}),(0,X.jsx)(hn,{})]})})})]})})})}function Uh(){return(document.querySelector(`meta[name="cez-api-base"]`)?.getAttribute(`content`))?.trim()||``}or(Uh());var Wh=document.getElementById(`root`);if(!Wh)throw Error(`cezar: #root container is missing from index.html`);(0,Aa.createRoot)(Wh).render((0,X.jsx)(Y.StrictMode,{children:(0,X.jsx)(Hh,{})}));export{ud as a,Eu as c,yu as d,_u as f,dc as g,_c as h,pd as i,xu as l,hu as m,hd as n,Du as o,gu as p,md as r,Ou as s,Ff as t,bu as u};