cezarion 0.19.0-dev.8839 → 0.19.0-dev.8841

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/package.json +3 -3
  2. package/web/dist/assets/{accounts-section-Bb5BYebY.js → accounts-section-D1dia-hG.js} +1 -1
  3. package/web/dist/assets/{activity-motion-CA5BGeJu.js → activity-motion-fPvKJxvA.js} +1 -1
  4. package/web/dist/assets/{activity-route-DD4PBjfn.js → activity-route-CB5nog2G.js} +1 -1
  5. package/web/dist/assets/{agent-config-section-95nZ2oyM.js → agent-config-section-D0_Hh9sa.js} +1 -1
  6. package/web/dist/assets/{agent-defaults-section-DEN23fw4.js → agent-defaults-section-Da8_EROm.js} +1 -1
  7. package/web/dist/assets/{appearance-B1Iykzeh.js → appearance-D6Jy-FOI.js} +1 -1
  8. package/web/dist/assets/{automations-route-AUvP1Ssm.js → automations-route-CctTxl3u.js} +1 -1
  9. package/web/dist/assets/{commit-list-DDiXRZp-.js → commit-list-FImAZR2z.js} +1 -1
  10. package/web/dist/assets/{diff-BCDjpdWy.js → diff-DqOJaV4a.js} +2 -2
  11. package/web/dist/assets/{diff-controls-e4A8aqiA.js → diff-controls-DzbvRI1Q.js} +1 -1
  12. package/web/dist/assets/{diff-view-ChmtoShm.js → diff-view-D8TGCcR9.js} +1 -1
  13. package/web/dist/assets/{file-preview-B70cmj6I.js → file-preview-B4UtCBRw.js} +1 -1
  14. package/web/dist/assets/{git-toolbar-DjXTgNSk.js → git-toolbar-Dun1QqPH.js} +1 -1
  15. package/web/dist/assets/{github-gvOaefmM.js → github-BN-W-GO8.js} +1 -1
  16. package/web/dist/assets/{global-activity-route-CyXDQDJJ.js → global-activity-route--JbzbeqH.js} +1 -1
  17. package/web/dist/assets/index-DEWnkuj6.js +21 -0
  18. package/web/dist/assets/index-DOVwFCfP.css +1 -0
  19. package/web/dist/assets/{markdown-0A4VVYvY.js → markdown-DOEDwgDr.js} +1 -1
  20. package/web/dist/assets/{notifications-section-DDL2APZA.js → notifications-section-WK58Ps4V.js} +1 -1
  21. package/web/dist/assets/{preview-pane-connected-C-SuSKu7.js → preview-pane-connected-BWcpAxTc.js} +1 -1
  22. package/web/dist/assets/{projects-section-CZcR4qW7.js → projects-section-DOMgdG7r.js} +1 -1
  23. package/web/dist/assets/{prompt-templates-section-BbzMKGio.js → prompt-templates-section-DQK4c-Yk.js} +1 -1
  24. package/web/dist/assets/{reference-chip-CV_vG2eP.js → reference-chip-DXFYkdLT.js} +1 -1
  25. package/web/dist/assets/{remote-settings-notice-B6hTxIYs.js → remote-settings-notice-B8a6aNBw.js} +1 -1
  26. package/web/dist/assets/{repo-git-Cmjvi7od.js → repo-git-CL-s-Ml4.js} +1 -1
  27. package/web/dist/assets/{report-reader-DF5GJ0Oy.js → report-reader-CYzRGRF-.js} +1 -1
  28. package/web/dist/assets/{reports-UKabUE0O.js → reports-BF3eEnvh.js} +1 -1
  29. package/web/dist/assets/{resources-section-C78q0b21.js → resources-section-Bvw0anG8.js} +1 -1
  30. package/web/dist/assets/{review-panel-Bp-R8WNC.js → review-panel-DJivUXQc.js} +1 -1
  31. package/web/dist/assets/{run-header-BdTKi8uh.js → run-header-B1lhW0fF.js} +2 -2
  32. package/web/dist/assets/{select-XO8RqFp0.js → select-ttlXTWN-.js} +1 -1
  33. package/web/dist/assets/{session-context-section-DrMvcM5c.js → session-context-section-DhNuv3zS.js} +1 -1
  34. package/web/dist/assets/{settings-agent-picker-BwpdE0xN.js → settings-agent-picker-B-a6cPMj.js} +1 -1
  35. package/web/dist/assets/{settings-shell-DJnHvj8U.js → settings-shell-kDDr8_Jd.js} +1 -1
  36. package/web/dist/assets/{sidebar-section-yArRGW70.js → sidebar-section-BP2FtFmc.js} +1 -1
  37. package/web/dist/assets/{skills-BkWTRxwo.js → skills-CWozz5P0.js} +1 -1
  38. package/web/dist/assets/{task-changes-CrAzob8D.js → task-changes-CQEaFA9P.js} +1 -1
  39. package/web/dist/assets/{task-commits-DPoXXQps.js → task-commits-BHYH-E_r.js} +1 -1
  40. package/web/dist/assets/{task-file-scope-CacffK2K.js → task-file-scope-CgfssVeu.js} +1 -1
  41. package/web/dist/assets/{task-files-DgY-RwOe.js → task-files-CD4LqOtt.js} +1 -1
  42. package/web/dist/assets/task-github-item-BBwSUB9p.js +1 -0
  43. package/web/dist/assets/{task-thread-HnpjNSqn.js → task-thread-BPS4pya8.js} +2 -2
  44. package/web/dist/assets/tasks-table-B9Hu3rBi.js +1 -0
  45. package/web/dist/assets/{thread-state-CS4XvjJ-.js → thread-state-22G0OlcH.js} +1 -1
  46. package/web/dist/assets/{use-hand-to-agent-state-Bl0ROgTv.js → use-hand-to-agent-state-BdkYBCvG.js} +1 -1
  47. package/web/dist/assets/{workflows-C9WB0sEl.js → workflows-C9gvUvUy.js} +1 -1
  48. package/web/dist/assets/{workspace-tools-BBBmc9hT.js → workspace-tools-Cg0RKomm.js} +1 -1
  49. package/web/dist/assets/{worktrees-section-BpgeQfSs.js → worktrees-section-DHiLUz-l.js} +1 -1
  50. package/web/dist/index.html +4 -4
  51. package/web/dist/assets/index-01bdo9g3.js +0 -21
  52. package/web/dist/assets/index-Dnupmo-Y.css +0 -1
  53. package/web/dist/assets/task-github-item-CwnXC2qm.js +0 -1
  54. package/web/dist/assets/tasks-table-BY5niMlY.js +0 -1
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r,n as i,t as a}from"./utils-DSMR_WLb.js";import{C as o,E as s,T as c,W as l,Wt as u,dn as d,j as f,n as p,qt as m,rt as h,w as g,xt as _,yt as v}from"./queries-D0v1z40Y.js";import{Fn as y,It as b,L as x,R as S,ct as C,f as w,hi as T,l as E,n as D}from"./toaster-DMfiAEnw.js";import{Z as O}from"./live-protocol-DMhTnCmf.js";import{g as k,h as A}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{i as j}from"./tasks-table-BY5niMlY.js";import{A as M,C as N,E as ee,F as P,J as te,M as ne,X as re,Y as ie,at as ae,c as oe,j as se,n as ce,ot as le,s as ue,u as de,v as fe,x as pe}from"./design-icons-CzEoMH9c.js";import{t as me}from"./createLucideIcon-BHp8sXmF.js";import{n as he,t as ge}from"./circle-x-7nTlobAF.js";import{_ as _e}from"./nav-row-styles-D5HpOmDZ.js";import{i as ve,r as ye,t as be}from"./git-toolbar-DjXTgNSk.js";import{t as xe}from"./info-DA1x_4bz.js";import{t as Se}from"./loader-circle-CPBhhDbB.js";import{i as Ce,n as we,r as Te}from"./diff-controls-e4A8aqiA.js";import{c as Ee,i as De,t as Oe}from"./reference-chip-CV_vG2eP.js";import{t as F}from"./button-B7MKxYjT.js";import{i as I,l as ke,p as Ae,r as je,t as Me}from"./dropdown-menu-4e2iKSMT.js";import{t as L}from"./project-router-BifLGgRR.js";import{t as Ne}from"./status-dot-BRzVlF2X.js";import{a as Pe,o as Fe}from"./format-BU7D3IfE.js";import{d as Ie,n as Le,o as R,s as Re,t as ze,u as Be}from"./page-shell-7pLJMOgh.js";import{t as z}from"./centered-state-V15AR_qo.js";import{At as Ve,Bt as He,Dn as Ue,E as B,Ft as We,Gt as V,Ht as H,It as U,Jt as W,Kt as G,Lt as Ge,Mn as Ke,Mt as qe,Nn as Je,Nt as Ye,Ot as Xe,Pt as Ze,Rt as Qe,T as $e,Ut as K,Vt as et,Wt as q,Yt as J,Zn as tt,Zt as nt,dr as rt,fn as it,ir as at,jn as ot,jt as st,kt as ct,pr as lt,qt as Y,zt as ut}from"./index-01bdo9g3.js";import{t as dt}from"./markdown-BBDDg-4t.js";import{t as ft}from"./diff-BCDjpdWy.js";import{t as pt}from"./change-counts-npLATh-3.js";import{n as mt,r as ht}from"./commit-list-DDiXRZp-.js";var X=e(t(),1);function gt(e,t){let n=T(t),r=n.getQueryCache();return X.useSyncExternalStore(X.useCallback(e=>r.subscribe(O.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var _t=me(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),vt=me(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),Z=n();function yt(){let e=r(),t=o(),n=T(),i=gt({queryKey:u.repo})>0,s=t.data?.info?t.data:null,c=Xe(e,s,`screen`);return(0,Z.jsx)(Be,{route:`repo-git`,density:s?.info?`full`:`empty`,headerSpacing:`compact`,header:{title:`Git`,secondaryActions:(0,Z.jsx)(Re,{type:`button`,variant:`ghost`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:i,onClick:()=>{n.invalidateQueries({queryKey:u.repo}),n.invalidateQueries({queryKey:u.worktrees})},children:(0,Z.jsx)(ie,{size:17,"aria-hidden":`true`,className:a(`size-[17px]`,i&&`motion-safe:animate-spin`)})})},children:(0,Z.jsxs)(`div`,{"data-slot":`git-screen`,children:[s?.info?(0,Z.jsx)(`div`,{className:`mb-[16px]`,children:(0,Z.jsx)(st,{scope:e,repo:s,info:s.info,variant:`screen`},e)}):t.isPending?(0,Z.jsx)(`p`,{"data-slot":`git-screen-loading`,role:`status`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Loading the checkout…`}):t.isError?(0,Z.jsxs)(`p`,{"data-slot":`git-screen-error`,role:`alert`,className:`mb-[16px] px-[10px] text-[13px] text-danger`,children:[`Could not load the repository: `,t.error.message]}):(0,Z.jsx)(`p`,{"data-slot":`git-screen-not-git`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Not a git repository.`}),t.isPending?null:(0,Z.jsx)(ct,{branch:s?.info?.branch??null,counts:c,variant:`screen`})]})})}function bt({entry:e}){return e.keptReason?(0,Z.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-xs text-muted-foreground`,children:e.keptReason}):null}function xt(e){if(e===``)return null;if(e===`@`)return`A branch cannot be named “@”.`;if(e.startsWith(`-`))return`A branch name cannot start with “-”.`;if(/\s/.test(e))return`A branch name cannot contain spaces.`;if(/[\u0000-\u001f\u007f]/.test(e))return`A branch name cannot contain control characters.`;let t=/[~^:?*[\\]/.exec(e);if(t)return`A branch name cannot contain “${t[0]}”.`;if(e.includes(`..`))return`A branch name cannot contain “..”.`;if(e.includes(`@{`))return`A branch name cannot contain “@{”.`;if(e.startsWith(`/`)||e.endsWith(`/`))return`A branch name cannot start or end with “/”.`;if(e.includes(`//`))return`A branch name cannot contain “//”.`;if(e.endsWith(`.`))return`A branch name cannot end with “.”.`;for(let t of e.split(`/`)){if(t.startsWith(`.`))return`A part of a branch name cannot start with “.”.`;if(t.endsWith(`.lock`))return`A part of a branch name cannot end with “.lock”.`}return null}function St({repo:e,info:t}){let n=r(),i=[n,`repo`],o=[n,`health`],s=v(),c=g(),l=new Map((c.data?.branches??[]).map(e=>[e.name,e])),u=T(),f=d({mutationFn:e=>E({name:e},n),onSuccess:async e=>{D(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([u.invalidateQueries({queryKey:i}),u.invalidateQueries({queryKey:o})]),u.setQueryData(i,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),u.setQueryData(o,t=>Ye(t,n,e.branch))},onError:e=>D(e.message,{tone:`danger`})}),[p,m]=(0,X.useState)(``),[h,_]=(0,X.useState)(``),y=h.trim().toLowerCase(),b=Ot(e,c.data?.branches),x=y?b.filter(e=>e.toLowerCase().includes(y)):b,S=p.trim(),C=xt(S);return(0,Z.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 md:grid-cols-[minmax(0,1fr)_290px]`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,Z.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,Z.jsxs)(`label`,{className:`relative block`,children:[(0,Z.jsx)(re,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3 size-4 text-muted-foreground`}),(0,Z.jsx)(tt,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:h,onChange:e=>_(e.target.value),className:`h-10 rounded-lg border-border bg-card pl-10`})]}),(0,Z.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-3.5 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[x.map(e=>{let n=e===t.branch,r=l.get(e);return(0,Z.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":r?.class,className:`flex min-h-[60px] flex-col items-start justify-center gap-1.5 py-2 md:flex-row md:items-center md:justify-start md:gap-2.5`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[8px]`,children:[r?.runId?(0,Z.jsx)(L,{to:`/tasks/${r.runId}`,"data-slot":`branch-task-link`,title:r.title?`Open the task ${r.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] font-mono text-[12px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,Z.jsx)(`span`,{className:a(`min-w-0 truncate font-mono text-[12px]`,n&&`font-medium`),children:e}),r&&!(n&&r.class===`active`)?(0,Z.jsx)(Dt,{entry:r}):null]}),r?(0,Z.jsx)(bt,{entry:r}):null,e.startsWith(`cez/`)&&!n?null:n?(0,Z.jsx)(`span`,{"data-slot":`branch-current`,className:`flex h-8 shrink-0 items-center rounded-md bg-accent-strong/10 px-2.5 text-[12px] font-medium text-accent-text md:ml-auto`,children:`Current`}):(0,Z.jsxs)(F,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`h-8 max-md:h-11 no-hover:h-11 md:ml-auto`,disabled:f.isPending,onClick:()=>f.mutate(e),children:[(0,Z.jsx)(M,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),x.length===0?(0,Z.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-muted-foreground`,children:[`No branches match “`,h.trim(),`”.`]}):null]})]}),(0,Z.jsxs)(`div`,{className:`min-w-0 self-start rounded-xl border border-border bg-card p-5`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold`,children:`Create a branch`}),(0,Z.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-5 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=S;!t||C||f.mutate(t,{onSuccess:()=>m(``)})},children:[(0,Z.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,Z.jsxs)(`p`,{"data-slot":`branch-create-base`,className:`-mt-1 text-xs text-muted-foreground`,children:[`Create from `,(0,Z.jsx)(`span`,{className:`font-mono text-xs text-foreground`,children:t.branch}),`.`]}),(0,Z.jsx)(tt,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background placeholder:text-soft-foreground`,value:p,"aria-invalid":C?!0:void 0,"aria-describedby":C?`new-branch-name-hint`:void 0,onChange:e=>m(e.target.value)}),C?(0,Z.jsx)(`p`,{id:`new-branch-name-hint`,"data-slot":`branch-name-hint`,role:`alert`,className:`-mt-1 text-xs text-danger`,children:C}):null,(0,Z.jsxs)(F,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!S||C!==null||f.isPending,children:[(0,Z.jsx)(te,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,Z.jsx)(`p`,{"data-slot":`branch-create-note`,className:`mt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),s.data?.forge?.available?(0,Z.jsx)(Ct,{}):null]})}function Ct(){let e=p({limit:20});return(0,Z.jsxs)(`div`,{"data-slot":`repo-prs`,className:`min-w-0 rounded-xl border border-border bg-card p-5 md:col-span-2`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold`,children:`Open pull requests`}),e.isPending?(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Loading pull requests…`}):e.isError?(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`No open pull requests.`}):(0,Z.jsx)(`ul`,{className:`mt-3 flex flex-col divide-y divide-border border-t border-border`,children:e.data.prs.map(e=>(0,Z.jsx)(wt,{pr:e},e.number))}):(0,Z.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-3 text-xs text-muted-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function wt({pr:e}){let t=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(P,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-muted-foreground`,children:[`#`,e.number]}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,Z.jsx)(Tt,{checks:e.checks}):null]}),n=`flex min-h-11 min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,Z.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:i(e.url)?(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:a(n,`hover:bg-muted`),children:t}):(0,Z.jsx)(`span`,{className:n,children:t})})}function Tt({checks:e}){let t=e===`passing`?he:e===`failing`?ge:rt;return(0,Z.jsxs)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:a(`inline-flex shrink-0 items-center gap-1 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:[(0,Z.jsx)(t,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),e]})}var Et={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function Dt({entry:e}){return(0,Z.jsx)(`span`,{"data-slot":`branch-class`,className:a(`shrink-0 rounded-[4px] border px-1.5 py-px text-xs leading-4 font-medium`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:Et[e.class]})}function Ot(e,t){let n=new Set(e.branches);for(let e of t??[])n.add(e.name);return[...n].sort((e,t)=>e.localeCompare(t))}function kt(){let e=c(),t=nt(),[n,r]=(0,X.useState)(`unified`),[i,a]=(0,X.useState)(!0),[o,s]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null),d=(0,X.useRef)(null),f=e.isError&&e.error instanceof y&&e.error.status===409,p=e.data?.files??[],m=(0,X.useMemo)(()=>ye(p),[p]),h=(0,X.useMemo)(()=>p.some(dt),[p]),g=t?n:`unified`;return(0,Z.jsx)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:e.isPending?(0,Z.jsx)(`p`,{"data-slot":`changes-loading`,className:`py-6 text-center text-xs text-muted-foreground`,children:`Loading changes…`}):e.isError?(0,Z.jsx)(z,{icon:f?(0,Z.jsx)(N,{size:16}):(0,Z.jsx)(le,{size:16}),tone:f?`neutral`:`danger`,heading:`h2`,title:f?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):p.length===0?(0,Z.jsx)(z,{icon:(0,Z.jsx)(N,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 pb-4 [&_button]:min-h-11`,children:[e.data?(0,Z.jsx)(be,{stat:e.data.stat}):null,(0,Z.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[h&&o?(0,Z.jsx)(Te,{}):null,h?(0,Z.jsx)(Ce,{preview:o,onPreviewChange:s}):null,(0,Z.jsx)(`span`,{className:`flex items-center gap-1.5`,children:(0,Z.jsx)(we,{mode:n,wrap:i,onModeChange:r,onWrapChange:a,disabled:h&&o})})]})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 [--diff-sticky-top:0px] md:flex-row md:items-start`,children:[(0,Z.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_2rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 lg:w-[288px]`,children:[(0,Z.jsx)(`h2`,{"data-slot":`changes-tree-heading`,className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,Z.jsx)(ve,{root:m,selected:l,onSelect:e=>{u(e),d.current?.scrollToPath(e)}})]}),(0,Z.jsx)(ft,{files:p,viewRef:d,mode:g,wrap:i,preview:o,totals:!1,className:`min-w-0 flex-1`})]})]})})}function At({repo:e,info:t}){let{sha:n}=A(),r=e.log,i=(0,X.useMemo)(()=>et(r),[r]);if(n)return(0,Z.jsx)(Nt,{sha:n});let a=Ge(e,t),o=a&&a.behind>0?(0,Z.jsx)(Mt,{info:t,tracking:a}):null;return r.length===0?(0,Z.jsxs)(Z.Fragment,{children:[o?(0,Z.jsx)(`div`,{children:o}):null,(0,Z.jsx)(z,{icon:(0,Z.jsx)(se,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]}):(0,Z.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-4`,children:[o,i.map(e=>(0,Z.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground`,children:e.label}),(0,Z.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.commits.map(e=>(0,Z.jsxs)(`li`,{className:`flex min-h-[52px] items-center gap-3.5 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,Z.jsxs)(L,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-0.5 px-4 py-2 focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,Z.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] font-medium text-foreground`,children:e.subject}),(0,Z.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(mt,{sha:e.hash}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,Z.jsxs)(`span`,{className:`truncate`,children:[e.author,` · `,(0,Z.jsx)(`span`,{title:He(e.when,e.at),children:ut(e.when,e.at)})]})]})]}),(0,Z.jsx)(jt,{source:e.source})]},e.hash))})]},e.label))]})}function jt({source:e}){let t=`hidden max-w-[45%] shrink-0 items-center gap-[5px] pr-4 text-xs text-muted-foreground md:flex`;return e?(0,Z.jsxs)(L,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:a(t,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ne,{"aria-hidden":`true`,className:`size-[11px] shrink-0 text-merged-text`}),(0,Z.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`PR #`,e.prNumber]})]}),(0,Z.jsx)(ue,{"aria-hidden":`true`,className:`size-[12px] shrink-0`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}):(0,Z.jsx)(`span`,{"data-slot":`commit-source`,"data-source":`unknown`,className:t,children:`no task found`})}function Mt({info:e,tracking:t}){let n=Ze(r(),e),i=(0,X.useRef)(null);return(0,Z.jsxs)(`div`,{"data-slot":`git-incoming`,className:`flex min-h-[44px] items-center gap-2.5 rounded-xl border border-border bg-card px-4 py-2`,children:[(0,Z.jsx)(_t,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,Z.jsxs)(`button`,{ref:i,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[28px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,Z.jsx)(Se,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,Z.jsx)(ce,{"aria-hidden":`true`}),`Pull`]}),(0,Z.jsx)(qe,{checkout:n,returnFocus:i})]})}function Nt({sha:e}){return(0,Z.jsx)(ht,{commit:s(e),sha:e,backTo:nt()?`/git`:We,backLabel:`All recent commits`,slot:`repo-commit`,className:`flex min-h-0 flex-1 flex-col`,diffClassName:`px-4 py-4 [--diff-sticky-top:0px] md:px-9`})}var Pt=`Squash-merged branches may show as not landed without GitHub`;function Ft(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function It(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}function Lt(){let e=g(),t=h(),n=r(),i=_(),[a,o]=(0,X.useState)(null);if(e.isPending)return(0,Z.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`py-5 text-[13px] text-muted-foreground`,children:`Loading branches…`});if(e.isError)return(0,Z.jsx)(z,{icon:(0,Z.jsx)(le,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let s=Ft(e.data.branches),c=s.reduce((e,t)=>e+t.rows.length,0),l=It(e.data.branches),u=l>0?(0,Z.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,children:[(0,Z.jsx)(xe,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,Z.jsxs)(`span`,{children:[l,` finished task`,l===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,l===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,Z.jsx)(L,{to:U.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,d=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,Z.jsxs)(De,{projectId:n,repoBase:i,requests:s.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,Z.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[e.data.prStateKnown?null:(0,Z.jsx)(Rt,{}),u,s.length===0?(0,Z.jsx)(ze,{icon:(0,Z.jsx)(at,{size:16}),title:l>0?`Nothing else waiting to land`:`Everything landed`,description:l>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`,actions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,Z.jsx)(L,{to:U.cleanup,children:`Check cleanup`})}),(0,Z.jsx)(F,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,Z.jsx)(L,{to:`/`,children:`View tasks`})})]})}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex flex-col gap-5`,children:s.map(e=>(0,Z.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col gap-1.5`,children:[(0,Z.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.title}),(0,Z.jsx)(`span`,{className:`tabular-nums`,children:e.rows.length}),e.note?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Q,{}),(0,Z.jsx)(`span`,{children:e.note})]}):null]}),(0,Z.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.rows.map(e=>(0,Z.jsx)(zt,{entry:e,finishedAt:e.runId?d.get(e.runId):void 0,onDelete:()=>o(e)},e.name))})]},e.key))}),(0,Z.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-1.5 px-1 text-xs leading-snug text-muted-foreground`,children:[(0,Z.jsx)(xe,{"aria-hidden":`true`,className:`mt-px size-3 shrink-0`}),`Delete a branch from its row's … menu. It confirms and names the commits it drops; nothing here is bulk-deleted.`]}),c<=3?(0,Z.jsx)(Le,{summary:`${c} ${c===1?`branch`:`branches`} waiting to land. Open a draft PR or inspect worktrees in Cleanup.`,actions:(0,Z.jsx)(F,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,Z.jsx)(L,{to:U.cleanup,children:`Open cleanup`})})}):null]})]}),(0,Z.jsx)(Wt,{entry:a,onClose:()=>o(null)})]})}function Rt({className:e}){return(0,Z.jsxs)(`p`,{"data-slot":`git-no-forge`,className:a(`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,e),children:[(0,Z.jsx)(xe,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),Pt,`.`]})}function zt({entry:e,finishedAt:t,onDelete:n}){return(0,Z.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[60px] items-center gap-3 px-4 py-3 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,Z.jsx)(Ht,{entry:e,finishedAt:t}),(0,Z.jsx)(Bt,{entry:e}),(0,Z.jsx)(Vt,{entry:e,onDelete:n})]})}function Bt({entry:e}){return(0,Z.jsx)(Z.Fragment,{children:e.pr?(0,Z.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-1.5 text-xs text-muted-foreground md:flex`,children:[(0,Z.jsx)(Oe,{plain:!0,reference:{kind:`PR`,number:e.pr.number,url:e.pr.url},taskTitle:e.title??e.name,status:e.pr.state===`draft`?`draft`:e.pr.state===`closed`?`closed`:void 0}),(0,Z.jsx)(Ut,{entry:e})]}):null})}function Vt({entry:e,onDelete:t}){let n=T(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,o=!r&&e.runId!==null&&!i,s=d({mutationFn:()=>C(e.runId),onSuccess:e=>{D(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:u.repoBranches}),n.invalidateQueries({queryKey:u.runs.all})},onError:e=>D(e instanceof y&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),[c,l]=(0,X.useState)(!1),f=(0,X.useRef)(null);(0,X.useEffect)(()=>()=>{f.current!==null&&clearTimeout(f.current)},[]);let p=()=>void navigator.clipboard.writeText(e.name).then(()=>{D(`Copied ${e.name}`),f.current!==null&&clearTimeout(f.current),l(!0),f.current=setTimeout(()=>l(!1),2e3)},()=>D(`Could not copy the branch name`,{tone:`danger`})),m=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-sm px-2.5 text-[12.5px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,Z.jsxs)(Z.Fragment,{children:[e.runId?(0,Z.jsx)(L,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:a(m,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:`Open task`}):null,o?(0,Z.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:s.isPending,onClick:()=>s.mutate(),className:a(m,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,Z.jsx)(vt,{"aria-hidden":`true`}),s.isPending?`Creating…`:`Draft PR`]}):null,r?(0,Z.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,"data-copied":c||void 0,"aria-live":`polite`,onClick:p,className:a(m,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[c?(0,Z.jsx)(oe,{"aria-hidden":`true`}):(0,Z.jsx)(fe,{"aria-hidden":`true`}),c?`Copied`:`Copy branch`]}):null,(0,Z.jsxs)(Me,{children:[(0,Z.jsx)(Ae,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-8 shrink-0 items-center justify-center rounded-sm text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,Z.jsx)(pe,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,Z.jsxs)(je,{align:`end`,className:`w-52`,children:[e.runId?(0,Z.jsx)(I,{asChild:!0,className:`md:hidden`,children:(0,Z.jsx)(L,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,o?(0,Z.jsx)(I,{className:`md:hidden`,disabled:s.isPending,onSelect:()=>s.mutate(),children:`Draft PR`}):null,(0,Z.jsx)(I,{className:a(!r&&`md:hidden`),onSelect:p,children:`Copy branch`}),(0,Z.jsx)(ke,{className:`md:hidden`}),(0,Z.jsx)(I,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function Ht({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=t??e.lastCommit.at,a=Pe(i),o=e.runStatus?Ue(e.runStatus):void 0,s=n||!o?a:`${o.label}${a?` ${a}`:``}`,c=Number.isFinite(Date.parse(i))?new Date(i).toLocaleString():void 0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,Z.jsx)(_e,{"aria-label":`Task deleted`,className:`size-[12px] text-muted-foreground`}):(0,Z.jsx)(Ne,{tone:o?.tone??`neutral`,shape:o?.shape??`filled`,"aria-label":o?.label})}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[e.runId?(0,Z.jsx)(L,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] font-medium text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,Z.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] font-medium text-foreground`,title:r,children:r}),(0,Z.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),(0,Z.jsx)(Q,{}),(0,Z.jsxs)(`span`,{className:`shrink-0`,children:[e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Q,{}),(0,Z.jsx)(pt,{adds:e.diffStat.additions,dels:e.diffStat.deletions})]}):null,s?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Q,{}),(0,Z.jsx)(`span`,{className:`truncate`,title:c,children:s})]}):null]}),e.parentRunId?(0,Z.jsx)(L,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-xs text-muted-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,Z.jsx)(bt,{entry:e})]})]})}function Q(){return(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`})}function Ut({entry:e}){let t=m(Ee(`PR`,e.pr?.number).status),n=e.pr?.state,r=n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Q,{}),(0,Z.jsx)(`span`,{"data-slot":`not-landed-pr-state`,children:r})]})}function Wt({entry:e,onClose:t}){let n=T(),[r,i]=(0,X.useState)(``),a=(0,X.useId)(),o=d({mutationFn:e=>w({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;D(e.deleted.length>0?`Deleted ${e.deleted[0]}${t?` and ${t} commit${t===1?``:`s`} with it`:``}`:e.refused[0]?.reason??`Nothing was deleted`),n.invalidateQueries({queryKey:u.repo}),s()},onError:e=>D(e.message,{tone:`danger`})}),s=()=>{i(``),t()},c=e!==null&&r.trim()===e.name,l=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,Z.jsx)(H,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,Z.jsxs)(V,{"data-slot":`delete-branch-dialog`,children:[(0,Z.jsxs)(W,{children:[(0,Z.jsxs)(J,{children:[`Delete `,e?.name,`?`]}),(0,Z.jsx)(G,{asChild:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`p`,{children:e?.class===`orphan`?`Its task was deleted, so this branch is the only copy of the work.`:(0,Z.jsxs)(Z.Fragment,{children:[`This drops the work of `,(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.title??e?.name}),`. It is not on the base branch`,e?.pr?``:` and no pull request carries it`,`.`]})}),(0,Z.jsxs)(`p`,{"data-slot":`delete-branch-dropped`,children:[l,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,e?.lastCommit.sha?(0,Z.jsxs)(Z.Fragment,{children:[` (`,(0,Z.jsx)(Je,{sha:e.lastCommit.sha,variant:`inline`}),`)`]}):null,`.`]})]})})]}),(0,Z.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),c&&e&&!o.isPending&&o.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,Z.jsxs)(`label`,{htmlFor:a,className:`text-[12.5px] text-muted-foreground`,children:[`Type `,(0,Z.jsx)(`span`,{className:`font-mono text-foreground`,children:e?.name}),` to confirm`]}),(0,Z.jsx)(tt,{id:a,"data-slot":`delete-branch-confirm`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value),className:`h-11 font-mono`})]}),(0,Z.jsxs)(Y,{children:[(0,Z.jsx)(q,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,Z.jsx)(K,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!c||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function Gt({base:e}){let t=g(),n=T(),[r,i]=(0,X.useState)({merged:!1,empty:!1}),[a,o]=(0,X.useState)(!1),s=(t.data?.branches??[]).filter(e=>e.class===`merged`),c=(t.data?.branches??[]).filter(e=>e.class===`empty`),l=[...s,...c],f=d({mutationFn:e=>w({names:e}),onSuccess:e=>{let t=e.refused.length;D(`Deleted ${e.deleted.length} branch${e.deleted.length===1?``:`es`}${t?`; kept ${t} that ${t===1?`is`:`are`} no longer safe to delete`:``}`),n.invalidateQueries({queryKey:u.repo})},onError:e=>{n.invalidateQueries({queryKey:u.repo}),D(e.message,{tone:`danger`})}});if(t.isPending)return(0,Z.jsx)(`p`,{"data-slot":`cleanup-branches-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading branches…`});if(t.isError)return(0,Z.jsxs)(`p`,{"data-slot":`cleanup-branches-error`,className:`text-[13px] text-danger`,children:[`Branches did not load: `,t.error.message]});let p=l.length,m=`branch${p===1?``:`es`}`;return(0,Z.jsxs)(`section`,{"data-slot":`cleanup-branches`,"aria-labelledby":`cleanup-branches-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Z.jsxs)(`h2`,{id:`cleanup-branches-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Branches safe to delete · `,p]}),(0,Z.jsxs)(`p`,{className:`text-xs leading-[17px] text-soft-foreground`,children:[`Their work is already on `,e,`, or they have none. Deleting loses nothing.`]})]}),(0,Z.jsxs)(`button`,{type:`button`,"data-action":`cleanup-branches-delete`,disabled:p===0||f.isPending,onClick:()=>o(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,Z.jsx)(ae,{"aria-hidden":`true`,className:`size-[12px]`}),f.isPending?`Deleting…`:`Delete ${p} ${m}`]})]}),(0,Z.jsx)(Kt,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:Pt.toLowerCase(),rows:s,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,Z.jsx)(Kt,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:c,open:r.empty,onToggle:()=>i(e=>({...e,empty:!e.empty}))}),(0,Z.jsx)(H,{open:a,onOpenChange:o,children:(0,Z.jsxs)(V,{children:[(0,Z.jsxs)(W,{children:[(0,Z.jsxs)(J,{children:[`Delete `,p,` `,m,`?`]}),(0,Z.jsxs)(G,{children:[s.length,` merged into `,e,` and `,c.length,` empty. Their work is already on `,e,`, or they have none. Anything that stopped being safe since this list loaded is kept.`]})]}),(0,Z.jsxs)(Y,{children:[(0,Z.jsx)(q,{children:`Keep them`}),(0,Z.jsxs)(K,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{f.mutate(l.map(e=>e.name)),o(!1)},children:[`Delete `,p,` `,m]})]})]})})]})}function Kt({kind:e,title:t,hint:n,rows:r,open:i,onToggle:o}){let s=`cleanup-branches-${e}`;return(0,Z.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":s,disabled:r.length===0,onClick:o,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Z.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,Z.jsx)(`span`,{className:`truncate text-xs text-soft-foreground`,children:n})]}),r.length>0?(0,Z.jsx)(de,{"aria-hidden":`true`,className:a(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,Z.jsx)(`ul`,{id:s,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,Z.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-xs`,children:[(0,Z.jsx)(ot,{value:e.name,className:`shrink-0 text-muted-foreground`}),e.runId?(0,Z.jsx)(L,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,Z.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,Z.jsx)(Ke,{iso:e.lastCommit.at,className:`shrink-0 text-soft-foreground`})]},e.name))}):null]})}function $(e){return e.some(e=>e.sizeBytes===null)?null:e.reduce((e,t)=>e+(t.sizeBytes??0),0)}function qt(e){return e.kind===`dirty`?`${e.uncommittedFiles} uncommitted`:e.kind===`detached-head`?`detached HEAD`:e.kind===`submodules`?`has submodules`:`broken worktree`}function Jt(e){if(e.kind===`dirty`){let t=`${e.uncommittedFiles} uncommitted file${e.uncommittedFiles===1?``:`s`}`;return e.detachedHead?`${t} and a detached HEAD on no branch`:t}return e.kind===`detached-head`?`a detached HEAD whose commit is on no branch`:e.kind===`submodules`?`initialized submodules that Git will not remove without force`:`an unregistered or broken Git worktree directory`}function Yt(e){let t=e.some(e=>e.reclaimBlocker?.kind===`dirty`),n=e.some(e=>e.reclaimBlocker?.kind===`detached-head`||e.reclaimBlocker?.kind===`dirty`&&e.reclaimBlocker.detachedHead),r=e.some(e=>e.reclaimBlocker?.kind===`submodules`),i=e.some(e=>e.reclaimBlocker?.kind===`invalid`),a=[...t?[`uncommitted work`]:[],...n?[`a detached HEAD`]:[],...r?[`initialized submodules`]:[],...i?[`a broken checkout`]:[]];return a.length<=1?a[0]??`uncommitted work`:`${a.slice(0,-1).join(`, `)} or ${a.at(-1)}`}function Xt(e,t,n){let r=Math.max(0,t-e);return e===0?r===0?`Nothing to reclaim — no finished worktrees exceed the keep limit`:n?`Nothing was reclaimed — the worktrees past the keep limit are in use or could not be removed`:`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Reclaimed ${e} worktree${e===1?``:`s`} (branch kept)${r>0?` · ${r} kept: ${n?`in use or could not be removed`:`uncommitted work or in use`}`:``}`}function Zt(e,t){return e===0?`Reclaim now`:t?`Reclaim ${j(t)} now`:`Reclaim ${e} now`}function Qt(e,t,n){let r=t?j(t):String(e);return n?`Discard & reclaim all ${r}`:`Discard & reclaim ${r}`}function $t(e,t){if(!e)return t>0?`No clean worktrees past the keep limit — use Discard & reclaim for blocked worktrees`:`Nothing past the keep limit to reclaim`}function en(e){return e===0?{prefix:`Retention is unlimited (`,suffix:`), so nothing is reclaimed on its own.`}:{prefix:`Retention keeps the newest ${e} finished checkout${e===1?``:`s`} (`,suffix:`) and reclaims the rest.`}}function tn({blocked:e,discardLabel:t,disabled:n,onDiscard:r}){let i=$(e),a=e.length===1?``:`s`,o=e.length===1?`it has`:`they have`;return(0,Z.jsxs)(`div`,{"data-slot":`worktrees-blocked-banner`,className:`flex flex-col gap-[10px] border-b border-border bg-muted/40 px-[14px] py-[10px] md:flex-row md:items-center`,children:[(0,Z.jsxs)(`p`,{className:`min-w-0 flex-1 text-[12px] leading-[17px] text-foreground`,children:[e.length,` worktree`,a,` past the keep limit`,i?` (${j(i)})`:``,` `,`cannot be reclaimed automatically because `,o,` `,Yt(e),`.`]}),(0,Z.jsxs)(`button`,{type:`button`,"data-action":`worktrees-discard-reclaim`,disabled:n,onClick:r,className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] border border-danger/40 px-[10px] text-[12px] font-medium text-danger hover:bg-danger/10 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 md:self-center`,children:[(0,Z.jsx)(lt,{"aria-hidden":`true`,className:`size-[12px]`}),t]})]})}function nn({confirmClean:e,onCloseClean:t,cleanCount:n,cleanBytes:r,reclaimLabel:i,onConfirmClean:a,discardBatch:o,onCloseDiscardBatch:s,onConfirmDiscardBatch:c,discardRow:l,onCloseRow:u,onConfirmRow:d}){let f=o?$(o):null,p=o?o.filter(e=>e.reclaimBlocker!==null).length:0,m=o?o.some(e=>!e.reclaimBlocker):!1,h=o?Qt(o.length,f,m):``;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(H,{open:e,onOpenChange:e=>{e||t()},children:(0,Z.jsxs)(V,{children:[(0,Z.jsxs)(W,{children:[(0,Z.jsx)(J,{children:`Reclaim old worktrees?`}),(0,Z.jsxs)(G,{children:[n,` finished worktree`,n===1?``:`s`,` beyond the keep limit`,r?` (${j(r)})`:``,` `,n===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,Z.jsxs)(Y,{children:[(0,Z.jsx)(q,{children:`Keep them`}),(0,Z.jsx)(K,{"data-action":`worktrees-confirm`,onClick:a,children:i})]})]})}),(0,Z.jsx)(H,{open:o!==null,onOpenChange:e=>{e||s()},children:(0,Z.jsxs)(V,{children:[(0,Z.jsxs)(W,{children:[(0,Z.jsx)(J,{children:`Discard changes and reclaim worktrees?`}),(0,Z.jsx)(G,{children:o?(0,Z.jsxs)(Z.Fragment,{children:[o.length,` finished worktree`,o.length===1?``:`s`,` beyond the keep limit`,f?` (${j(f)})`:``,` will be reclaimed now.`,` `,`Uncommitted files and detached-HEAD commits in `,p,` blocked checkout`,p===1?``:`s`,` will be permanently discarded. Each task’s branch is kept.`]}):null})]}),(0,Z.jsxs)(Y,{children:[(0,Z.jsx)(q,{children:`Keep them`}),(0,Z.jsx)(K,{"data-action":`worktrees-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{o&&c(o),s()},children:h})]})]})}),(0,Z.jsx)(H,{open:l!==null,onOpenChange:e=>{e||u()},children:(0,Z.jsxs)(V,{children:[(0,Z.jsxs)(W,{children:[(0,Z.jsx)(J,{children:`Discard changes and reclaim worktree?`}),(0,Z.jsx)(G,{children:l?.reclaimBlocker?(0,Z.jsxs)(Z.Fragment,{children:[l.title,` has `,Jt(l.reclaimBlocker),`. Reclaiming removes the directory and permanently discards uncommitted or unbranched changes in it. The branch (`,l.branch??l.runId.slice(0,8),`) is kept.`]}):null})]}),(0,Z.jsxs)(Y,{children:[(0,Z.jsx)(q,{children:`Keep it`}),(0,Z.jsx)(K,{"data-action":`worktree-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{l&&d(l),u()},children:`Discard & reclaim`})]})]})})]})}function rn(){let e=f(),t=l().data?.targets.find(e=>e.id===`finder`),n=d({mutationFn:e=>b(e,t.id),onError:e=>D(e.message,{tone:`danger`})}),r=T(),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(null),[c,p]=(0,X.useState)(null),m=()=>Promise.all([r.invalidateQueries({queryKey:u.worktrees}),r.invalidateQueries({queryKey:u.repoBranches})]),h=d({mutationFn:({runIds:e})=>S(e?{discardWork:!0,runIds:e}:void 0),onSuccess:(e,{expected:t,runIds:n})=>{m(),D(Xt(e.reclaimed.length,t,!!n))},onError:e=>D(e.message,{tone:`danger`})}),g=d({mutationFn:({worktree:e,discardWork:t})=>x(e.runId,t?{discardWork:!0}:void 0),onSuccess:(e,{worktree:t})=>{m(),D(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{m(),D(e.message,{tone:`danger`})}});if(e.isPending)return(0,Z.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,Z.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-[13px] text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:_,totalBytes:v,keep:y}=e.data,C=h.isPending||g.isPending,w=_.filter(e=>e.pastKeep),E=w.filter(e=>!e.reclaimBlocker),O=w.filter(e=>e.reclaimBlocker!==null),k=E.length>0,A=$(E),M=$(w),N=Zt(E.length,A),ee=Qt(w.length,M,k),P=v?j(v):null,te=en(y);return(0,Z.jsxs)(`section`,{"data-slot":`worktrees-panel`,"aria-labelledby":`worktrees-panel-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Z.jsxs)(`h2`,{id:`worktrees-panel-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Worktrees on disk`,P?` · ${P}`:``]}),(0,Z.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-xs leading-[17px] text-soft-foreground`,children:[te.prefix,(0,Z.jsx)(L,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:it(`worktrees`,` › `)}),te.suffix,` `,`Reclaim removes the directory only; the branch stays, so its work stays recoverable.`]})]}),(0,Z.jsxs)(`button`,{type:`button`,"data-action":`worktrees-reclaim-now`,disabled:C||!k,title:$t(k,O.length),onClick:()=>a(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,Z.jsx)(lt,{"aria-hidden":`true`,className:`size-[12px]`}),N]})]}),O.length>0?(0,Z.jsx)(tn,{blocked:O,discardLabel:ee,disabled:C,onDiscard:()=>s(w)}):null,_.length===0?(0,Z.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`px-[14px] py-[12px] text-[12.5px] text-soft-foreground`,children:`No task worktrees on disk.`}):(0,Z.jsx)(`ul`,{"aria-label":`Task worktrees on disk`,className:`flex flex-col`,children:_.map(e=>(0,Z.jsx)(sn,{worktree:e,keep:y,disabled:C,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>{e.reclaimBlocker?p(e):g.mutate({worktree:e,discardWork:!1})}},e.runId))}),(0,Z.jsx)(nn,{confirmClean:i,onCloseClean:()=>a(!1),cleanCount:E.length,cleanBytes:A,reclaimLabel:N,onConfirmClean:()=>{h.mutate({expected:E.length}),a(!1)},discardBatch:o,onCloseDiscardBatch:()=>s(null),onConfirmDiscardBatch:e=>{h.mutate({expected:e.length,runIds:e.map(e=>e.runId)})},discardRow:c,onCloseRow:()=>p(null),onConfirmRow:e=>g.mutate({worktree:e,discardWork:!0})})]})}var an=new Set([`queued`,`running`,`waiting`,`review`]);function on(e,t){return an.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`,state:`in-use`}:e.reclaimBlocker?{label:qt(e.reclaimBlocker),tone:`blocked`,state:`blocked`}:e.pastKeep?{label:`reclaimable`,tone:`plain`,state:`reclaimable`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`,state:`kept`}}function sn({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:o}){let s=on(e,t),c=Pe(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${Fe(c)}`:e.status,u=s.tone===`in-use`?`text-status-running`:s.tone===`blocked`?`text-danger`:`text-soft-foreground`,d=e.reclaimBlocker?`Cannot auto-reclaim: ${Jt(e.reclaimBlocker)}`:void 0,f=(0,Z.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":s.state,title:d,className:a(`text-xs`,u),children:s.label}),p=`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:size-11`,m=e.reclaimBlocker?`Discard changes and reclaim the worktree of ${e.title} (branch kept)`:`Reclaim the worktree of ${e.title} (branch kept)`,h=e.reclaimBlocker?`Discard changes and reclaim the directory (branch kept)`:`Reclaim the directory (branch kept)`;return(0,Z.jsxs)(`li`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`flex min-h-[44px] items-center gap-[12px] border-b border-border px-[14px] py-[4px] last:border-0`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Z.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,title:e.title,children:e.title}),(0,Z.jsxs)(`span`,{className:`truncate font-mono text-xs text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,l,(0,Z.jsxs)(`span`,{className:`md:hidden`,children:[` · `,s.label]})]})]}),(0,Z.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-xs tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:j(e.sizeBytes)||`0 kB`}),(0,Z.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:f}),r?(0,Z.jsx)(`button`,{type:`button`,className:p,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,Z.jsx)(ee,{"aria-hidden":`true`,className:`size-[13px]`})}):null,s.tone===`in-use`?null:(0,Z.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":m,title:h,disabled:n,onClick:o,className:a(p,e.reclaimBlocker&&`text-danger hover:text-danger`),children:(0,Z.jsx)(lt,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function cn(e){return e===`main`||e===`changes`?`Split`:`Table`}function ln({section:e,index:t=!1}){let n=o(),r=nt(),[i]=k(),a=cn(e);if(t&&!r&&i.get(`view`)!==`repo`)return(0,Z.jsx)(yt,{});if(n.isPending)return(0,Z.jsx)($e,{});if(n.isError)return(0,Z.jsx)(R,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,Z.jsx)(B,{}),children:(0,Z.jsx)(z,{icon:(0,Z.jsx)(le,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})});let s=n.data.info;return s?(0,Z.jsx)(un,{repo:n.data,info:s,section:e}):(0,Z.jsx)(R,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,Z.jsx)(B,{}),children:(0,Z.jsx)(z,{icon:(0,Z.jsx)(M,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`Squawk is running outside a git repository — start it inside one to browse changes, commits and branches.`})})}function un({repo:e,info:t,section:n}){let r=cn(n),i=g(),a=n===`main`?e.log.length:n===`changes`?e.status.length:n===`branches`?Ot(e,i.data?.branches).length:n===`not-landed`?i.data?.branches.filter(e=>e.class===`not-landed`||e.class===`orphan`).length??0:4;return(0,Z.jsx)(R,{template:r,route:`repo-git`,density:n===`not-landed`&&i.isPending?`full`:Ie(a),rootProps:{"data-git-section":n},beforeHeader:(0,Z.jsx)(B,{}),header:{title:Ve(n,t.branch),headerSlot:`repo-header`,subtitle:(0,Z.jsx)(dn,{repo:e,info:t,section:n}),subtitleSlot:`repo-meta`},children:n===`main`?(0,Z.jsx)(At,{repo:e,info:t}):n===`not-landed`?(0,Z.jsx)(Lt,{}):n===`cleanup`?(0,Z.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[(0,Z.jsx)(rn,{}),(0,Z.jsx)(Gt,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,Z.jsx)(St,{repo:e,info:t}):(0,Z.jsx)(kt,{})})}function dn({repo:e,info:t,section:n}){let r=e.baseBranch??t.branch;switch(n){case`main`:return(0,Z.jsxs)(Z.Fragment,{children:[e.log.length===0?`No commits yet`:`Latest ${e.log.length} commit${e.log.length===1?``:`s`} in the main checkout`,e.tracking?` · ${Qe(e.tracking)}`:``]});case`not-landed`:return(0,Z.jsxs)(Z.Fragment,{children:[`Finished tasks whose commits are not on `,r]});case`branches`:return(0,Z.jsx)(fn,{repo:e,info:t});case`changes`:return(0,Z.jsxs)(Z.Fragment,{children:[e.status.length,` uncommitted file`,e.status.length===1?``:`s`,` in the main checkout`]});case`cleanup`:return(0,Z.jsxs)(Z.Fragment,{children:[`Nothing here can delete work that is not on `,r]})}}function fn({repo:e,info:t}){let n=Ot(e,g().data?.branches).length;return(0,Z.jsxs)(Z.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{ln as RepoGitRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r,n as i,t as a}from"./utils-DSMR_WLb.js";import{C as o,E as s,T as c,W as l,Wt as u,dn as d,j as f,n as p,qt as m,rt as h,w as g,xt as _,yt as v}from"./queries-D0v1z40Y.js";import{Fn as y,It as b,L as x,R as S,ct as C,f as w,hi as T,l as E,n as D}from"./toaster-DMfiAEnw.js";import{Z as O}from"./live-protocol-DMhTnCmf.js";import{g as k,h as A}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{i as j}from"./tasks-table-B9Hu3rBi.js";import{A as M,C as N,E as ee,F as P,J as te,M as ne,X as re,Y as ie,at as ae,c as oe,j as se,n as ce,ot as le,s as ue,u as de,v as fe,x as pe}from"./design-icons-CzEoMH9c.js";import{t as me}from"./createLucideIcon-BHp8sXmF.js";import{n as he,t as ge}from"./circle-x-7nTlobAF.js";import{_ as _e}from"./nav-row-styles-D5HpOmDZ.js";import{i as ve,r as ye,t as be}from"./git-toolbar-Dun1QqPH.js";import{t as xe}from"./info-DA1x_4bz.js";import{t as Se}from"./loader-circle-CPBhhDbB.js";import{i as Ce,n as we,r as Te}from"./diff-controls-DzbvRI1Q.js";import{c as Ee,i as De,t as Oe}from"./reference-chip-DXFYkdLT.js";import{t as F}from"./button-B7MKxYjT.js";import{i as I,l as ke,p as Ae,r as je,t as Me}from"./dropdown-menu-4e2iKSMT.js";import{t as L}from"./project-router-BifLGgRR.js";import{t as Ne}from"./status-dot-BRzVlF2X.js";import{a as Pe,o as Fe}from"./format-BU7D3IfE.js";import{d as Ie,n as Le,o as R,s as Re,t as ze,u as Be}from"./page-shell-7pLJMOgh.js";import{t as z}from"./centered-state-V15AR_qo.js";import{At as Ve,Bt as He,Dn as Ue,E as B,Ft as We,Gt as V,Ht as H,It as U,Jt as W,Kt as G,Lt as Ge,Mn as Ke,Mt as qe,Nn as Je,Nt as Ye,Ot as Xe,Pt as Ze,Rt as Qe,T as $e,Ut as K,Vt as et,Wt as q,Yt as J,Zn as tt,Zt as nt,dr as rt,fn as it,ir as at,jn as ot,jt as st,kt as ct,pr as lt,qt as Y,zt as ut}from"./index-DEWnkuj6.js";import{t as dt}from"./markdown-BBDDg-4t.js";import{t as ft}from"./diff-DqOJaV4a.js";import{t as pt}from"./change-counts-npLATh-3.js";import{n as mt,r as ht}from"./commit-list-FImAZR2z.js";var X=e(t(),1);function gt(e,t){let n=T(t),r=n.getQueryCache();return X.useSyncExternalStore(X.useCallback(e=>r.subscribe(O.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var _t=me(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),vt=me(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),Z=n();function yt(){let e=r(),t=o(),n=T(),i=gt({queryKey:u.repo})>0,s=t.data?.info?t.data:null,c=Xe(e,s,`screen`);return(0,Z.jsx)(Be,{route:`repo-git`,density:s?.info?`full`:`empty`,headerSpacing:`compact`,header:{title:`Git`,secondaryActions:(0,Z.jsx)(Re,{type:`button`,variant:`ghost`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:i,onClick:()=>{n.invalidateQueries({queryKey:u.repo}),n.invalidateQueries({queryKey:u.worktrees})},children:(0,Z.jsx)(ie,{size:17,"aria-hidden":`true`,className:a(`size-[17px]`,i&&`motion-safe:animate-spin`)})})},children:(0,Z.jsxs)(`div`,{"data-slot":`git-screen`,children:[s?.info?(0,Z.jsx)(`div`,{className:`mb-[16px]`,children:(0,Z.jsx)(st,{scope:e,repo:s,info:s.info,variant:`screen`},e)}):t.isPending?(0,Z.jsx)(`p`,{"data-slot":`git-screen-loading`,role:`status`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Loading the checkout…`}):t.isError?(0,Z.jsxs)(`p`,{"data-slot":`git-screen-error`,role:`alert`,className:`mb-[16px] px-[10px] text-[13px] text-danger`,children:[`Could not load the repository: `,t.error.message]}):(0,Z.jsx)(`p`,{"data-slot":`git-screen-not-git`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Not a git repository.`}),t.isPending?null:(0,Z.jsx)(ct,{branch:s?.info?.branch??null,counts:c,variant:`screen`})]})})}function bt({entry:e}){return e.keptReason?(0,Z.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-xs text-muted-foreground`,children:e.keptReason}):null}function xt(e){if(e===``)return null;if(e===`@`)return`A branch cannot be named “@”.`;if(e.startsWith(`-`))return`A branch name cannot start with “-”.`;if(/\s/.test(e))return`A branch name cannot contain spaces.`;if(/[\u0000-\u001f\u007f]/.test(e))return`A branch name cannot contain control characters.`;let t=/[~^:?*[\\]/.exec(e);if(t)return`A branch name cannot contain “${t[0]}”.`;if(e.includes(`..`))return`A branch name cannot contain “..”.`;if(e.includes(`@{`))return`A branch name cannot contain “@{”.`;if(e.startsWith(`/`)||e.endsWith(`/`))return`A branch name cannot start or end with “/”.`;if(e.includes(`//`))return`A branch name cannot contain “//”.`;if(e.endsWith(`.`))return`A branch name cannot end with “.”.`;for(let t of e.split(`/`)){if(t.startsWith(`.`))return`A part of a branch name cannot start with “.”.`;if(t.endsWith(`.lock`))return`A part of a branch name cannot end with “.lock”.`}return null}function St({repo:e,info:t}){let n=r(),i=[n,`repo`],o=[n,`health`],s=v(),c=g(),l=new Map((c.data?.branches??[]).map(e=>[e.name,e])),u=T(),f=d({mutationFn:e=>E({name:e},n),onSuccess:async e=>{D(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([u.invalidateQueries({queryKey:i}),u.invalidateQueries({queryKey:o})]),u.setQueryData(i,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),u.setQueryData(o,t=>Ye(t,n,e.branch))},onError:e=>D(e.message,{tone:`danger`})}),[p,m]=(0,X.useState)(``),[h,_]=(0,X.useState)(``),y=h.trim().toLowerCase(),b=Ot(e,c.data?.branches),x=y?b.filter(e=>e.toLowerCase().includes(y)):b,S=p.trim(),C=xt(S);return(0,Z.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 md:grid-cols-[minmax(0,1fr)_290px]`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,Z.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,Z.jsxs)(`label`,{className:`relative block`,children:[(0,Z.jsx)(re,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3 size-4 text-muted-foreground`}),(0,Z.jsx)(tt,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:h,onChange:e=>_(e.target.value),className:`h-10 rounded-lg border-border bg-card pl-10`})]}),(0,Z.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-3.5 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[x.map(e=>{let n=e===t.branch,r=l.get(e);return(0,Z.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":r?.class,className:`flex min-h-[60px] flex-col items-start justify-center gap-1.5 py-2 md:flex-row md:items-center md:justify-start md:gap-2.5`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[8px]`,children:[r?.runId?(0,Z.jsx)(L,{to:`/tasks/${r.runId}`,"data-slot":`branch-task-link`,title:r.title?`Open the task ${r.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] font-mono text-[12px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,Z.jsx)(`span`,{className:a(`min-w-0 truncate font-mono text-[12px]`,n&&`font-medium`),children:e}),r&&!(n&&r.class===`active`)?(0,Z.jsx)(Dt,{entry:r}):null]}),r?(0,Z.jsx)(bt,{entry:r}):null,e.startsWith(`cez/`)&&!n?null:n?(0,Z.jsx)(`span`,{"data-slot":`branch-current`,className:`flex h-8 shrink-0 items-center rounded-md bg-accent-strong/10 px-2.5 text-[12px] font-medium text-accent-text md:ml-auto`,children:`Current`}):(0,Z.jsxs)(F,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`h-8 max-md:h-11 no-hover:h-11 md:ml-auto`,disabled:f.isPending,onClick:()=>f.mutate(e),children:[(0,Z.jsx)(M,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),x.length===0?(0,Z.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-muted-foreground`,children:[`No branches match “`,h.trim(),`”.`]}):null]})]}),(0,Z.jsxs)(`div`,{className:`min-w-0 self-start rounded-xl border border-border bg-card p-5`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold`,children:`Create a branch`}),(0,Z.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-5 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=S;!t||C||f.mutate(t,{onSuccess:()=>m(``)})},children:[(0,Z.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,Z.jsxs)(`p`,{"data-slot":`branch-create-base`,className:`-mt-1 text-xs text-muted-foreground`,children:[`Create from `,(0,Z.jsx)(`span`,{className:`font-mono text-xs text-foreground`,children:t.branch}),`.`]}),(0,Z.jsx)(tt,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background placeholder:text-soft-foreground`,value:p,"aria-invalid":C?!0:void 0,"aria-describedby":C?`new-branch-name-hint`:void 0,onChange:e=>m(e.target.value)}),C?(0,Z.jsx)(`p`,{id:`new-branch-name-hint`,"data-slot":`branch-name-hint`,role:`alert`,className:`-mt-1 text-xs text-danger`,children:C}):null,(0,Z.jsxs)(F,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!S||C!==null||f.isPending,children:[(0,Z.jsx)(te,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,Z.jsx)(`p`,{"data-slot":`branch-create-note`,className:`mt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),s.data?.forge?.available?(0,Z.jsx)(Ct,{}):null]})}function Ct(){let e=p({limit:20});return(0,Z.jsxs)(`div`,{"data-slot":`repo-prs`,className:`min-w-0 rounded-xl border border-border bg-card p-5 md:col-span-2`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold`,children:`Open pull requests`}),e.isPending?(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Loading pull requests…`}):e.isError?(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`No open pull requests.`}):(0,Z.jsx)(`ul`,{className:`mt-3 flex flex-col divide-y divide-border border-t border-border`,children:e.data.prs.map(e=>(0,Z.jsx)(wt,{pr:e},e.number))}):(0,Z.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-3 text-xs text-muted-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function wt({pr:e}){let t=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(P,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-muted-foreground`,children:[`#`,e.number]}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,Z.jsx)(Tt,{checks:e.checks}):null]}),n=`flex min-h-11 min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,Z.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:i(e.url)?(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:a(n,`hover:bg-muted`),children:t}):(0,Z.jsx)(`span`,{className:n,children:t})})}function Tt({checks:e}){let t=e===`passing`?he:e===`failing`?ge:rt;return(0,Z.jsxs)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:a(`inline-flex shrink-0 items-center gap-1 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:[(0,Z.jsx)(t,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),e]})}var Et={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function Dt({entry:e}){return(0,Z.jsx)(`span`,{"data-slot":`branch-class`,className:a(`shrink-0 rounded-[4px] border px-1.5 py-px text-xs leading-4 font-medium`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:Et[e.class]})}function Ot(e,t){let n=new Set(e.branches);for(let e of t??[])n.add(e.name);return[...n].sort((e,t)=>e.localeCompare(t))}function kt(){let e=c(),t=nt(),[n,r]=(0,X.useState)(`unified`),[i,a]=(0,X.useState)(!0),[o,s]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null),d=(0,X.useRef)(null),f=e.isError&&e.error instanceof y&&e.error.status===409,p=e.data?.files??[],m=(0,X.useMemo)(()=>ye(p),[p]),h=(0,X.useMemo)(()=>p.some(dt),[p]),g=t?n:`unified`;return(0,Z.jsx)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:e.isPending?(0,Z.jsx)(`p`,{"data-slot":`changes-loading`,className:`py-6 text-center text-xs text-muted-foreground`,children:`Loading changes…`}):e.isError?(0,Z.jsx)(z,{icon:f?(0,Z.jsx)(N,{size:16}):(0,Z.jsx)(le,{size:16}),tone:f?`neutral`:`danger`,heading:`h2`,title:f?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):p.length===0?(0,Z.jsx)(z,{icon:(0,Z.jsx)(N,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 pb-4 [&_button]:min-h-11`,children:[e.data?(0,Z.jsx)(be,{stat:e.data.stat}):null,(0,Z.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[h&&o?(0,Z.jsx)(Te,{}):null,h?(0,Z.jsx)(Ce,{preview:o,onPreviewChange:s}):null,(0,Z.jsx)(`span`,{className:`flex items-center gap-1.5`,children:(0,Z.jsx)(we,{mode:n,wrap:i,onModeChange:r,onWrapChange:a,disabled:h&&o})})]})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 [--diff-sticky-top:0px] md:flex-row md:items-start`,children:[(0,Z.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_2rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 lg:w-[288px]`,children:[(0,Z.jsx)(`h2`,{"data-slot":`changes-tree-heading`,className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,Z.jsx)(ve,{root:m,selected:l,onSelect:e=>{u(e),d.current?.scrollToPath(e)}})]}),(0,Z.jsx)(ft,{files:p,viewRef:d,mode:g,wrap:i,preview:o,totals:!1,className:`min-w-0 flex-1`})]})]})})}function At({repo:e,info:t}){let{sha:n}=A(),r=e.log,i=(0,X.useMemo)(()=>et(r),[r]);if(n)return(0,Z.jsx)(Nt,{sha:n});let a=Ge(e,t),o=a&&a.behind>0?(0,Z.jsx)(Mt,{info:t,tracking:a}):null;return r.length===0?(0,Z.jsxs)(Z.Fragment,{children:[o?(0,Z.jsx)(`div`,{children:o}):null,(0,Z.jsx)(z,{icon:(0,Z.jsx)(se,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]}):(0,Z.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-4`,children:[o,i.map(e=>(0,Z.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground`,children:e.label}),(0,Z.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.commits.map(e=>(0,Z.jsxs)(`li`,{className:`flex min-h-[52px] items-center gap-3.5 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,Z.jsxs)(L,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-0.5 px-4 py-2 focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,Z.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] font-medium text-foreground`,children:e.subject}),(0,Z.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(mt,{sha:e.hash}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,Z.jsxs)(`span`,{className:`truncate`,children:[e.author,` · `,(0,Z.jsx)(`span`,{title:He(e.when,e.at),children:ut(e.when,e.at)})]})]})]}),(0,Z.jsx)(jt,{source:e.source})]},e.hash))})]},e.label))]})}function jt({source:e}){let t=`hidden max-w-[45%] shrink-0 items-center gap-[5px] pr-4 text-xs text-muted-foreground md:flex`;return e?(0,Z.jsxs)(L,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:a(t,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ne,{"aria-hidden":`true`,className:`size-[11px] shrink-0 text-merged-text`}),(0,Z.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`PR #`,e.prNumber]})]}),(0,Z.jsx)(ue,{"aria-hidden":`true`,className:`size-[12px] shrink-0`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}):(0,Z.jsx)(`span`,{"data-slot":`commit-source`,"data-source":`unknown`,className:t,children:`no task found`})}function Mt({info:e,tracking:t}){let n=Ze(r(),e),i=(0,X.useRef)(null);return(0,Z.jsxs)(`div`,{"data-slot":`git-incoming`,className:`flex min-h-[44px] items-center gap-2.5 rounded-xl border border-border bg-card px-4 py-2`,children:[(0,Z.jsx)(_t,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,Z.jsxs)(`button`,{ref:i,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[28px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,Z.jsx)(Se,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,Z.jsx)(ce,{"aria-hidden":`true`}),`Pull`]}),(0,Z.jsx)(qe,{checkout:n,returnFocus:i})]})}function Nt({sha:e}){return(0,Z.jsx)(ht,{commit:s(e),sha:e,backTo:nt()?`/git`:We,backLabel:`All recent commits`,slot:`repo-commit`,className:`flex min-h-0 flex-1 flex-col`,diffClassName:`px-4 py-4 [--diff-sticky-top:0px] md:px-9`})}var Pt=`Squash-merged branches may show as not landed without GitHub`;function Ft(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function It(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}function Lt(){let e=g(),t=h(),n=r(),i=_(),[a,o]=(0,X.useState)(null);if(e.isPending)return(0,Z.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`py-5 text-[13px] text-muted-foreground`,children:`Loading branches…`});if(e.isError)return(0,Z.jsx)(z,{icon:(0,Z.jsx)(le,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let s=Ft(e.data.branches),c=s.reduce((e,t)=>e+t.rows.length,0),l=It(e.data.branches),u=l>0?(0,Z.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,children:[(0,Z.jsx)(xe,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,Z.jsxs)(`span`,{children:[l,` finished task`,l===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,l===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,Z.jsx)(L,{to:U.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,d=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,Z.jsxs)(De,{projectId:n,repoBase:i,requests:s.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,Z.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[e.data.prStateKnown?null:(0,Z.jsx)(Rt,{}),u,s.length===0?(0,Z.jsx)(ze,{icon:(0,Z.jsx)(at,{size:16}),title:l>0?`Nothing else waiting to land`:`Everything landed`,description:l>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`,actions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,Z.jsx)(L,{to:U.cleanup,children:`Check cleanup`})}),(0,Z.jsx)(F,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,Z.jsx)(L,{to:`/`,children:`View tasks`})})]})}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex flex-col gap-5`,children:s.map(e=>(0,Z.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col gap-1.5`,children:[(0,Z.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.title}),(0,Z.jsx)(`span`,{className:`tabular-nums`,children:e.rows.length}),e.note?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Q,{}),(0,Z.jsx)(`span`,{children:e.note})]}):null]}),(0,Z.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.rows.map(e=>(0,Z.jsx)(zt,{entry:e,finishedAt:e.runId?d.get(e.runId):void 0,onDelete:()=>o(e)},e.name))})]},e.key))}),(0,Z.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-1.5 px-1 text-xs leading-snug text-muted-foreground`,children:[(0,Z.jsx)(xe,{"aria-hidden":`true`,className:`mt-px size-3 shrink-0`}),`Delete a branch from its row's … menu. It confirms and names the commits it drops; nothing here is bulk-deleted.`]}),c<=3?(0,Z.jsx)(Le,{summary:`${c} ${c===1?`branch`:`branches`} waiting to land. Open a draft PR or inspect worktrees in Cleanup.`,actions:(0,Z.jsx)(F,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,Z.jsx)(L,{to:U.cleanup,children:`Open cleanup`})})}):null]})]}),(0,Z.jsx)(Wt,{entry:a,onClose:()=>o(null)})]})}function Rt({className:e}){return(0,Z.jsxs)(`p`,{"data-slot":`git-no-forge`,className:a(`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,e),children:[(0,Z.jsx)(xe,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),Pt,`.`]})}function zt({entry:e,finishedAt:t,onDelete:n}){return(0,Z.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[60px] items-center gap-3 px-4 py-3 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,Z.jsx)(Ht,{entry:e,finishedAt:t}),(0,Z.jsx)(Bt,{entry:e}),(0,Z.jsx)(Vt,{entry:e,onDelete:n})]})}function Bt({entry:e}){return(0,Z.jsx)(Z.Fragment,{children:e.pr?(0,Z.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-1.5 text-xs text-muted-foreground md:flex`,children:[(0,Z.jsx)(Oe,{plain:!0,reference:{kind:`PR`,number:e.pr.number,url:e.pr.url},taskTitle:e.title??e.name,status:e.pr.state===`draft`?`draft`:e.pr.state===`closed`?`closed`:void 0}),(0,Z.jsx)(Ut,{entry:e})]}):null})}function Vt({entry:e,onDelete:t}){let n=T(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,o=!r&&e.runId!==null&&!i,s=d({mutationFn:()=>C(e.runId),onSuccess:e=>{D(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:u.repoBranches}),n.invalidateQueries({queryKey:u.runs.all})},onError:e=>D(e instanceof y&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),[c,l]=(0,X.useState)(!1),f=(0,X.useRef)(null);(0,X.useEffect)(()=>()=>{f.current!==null&&clearTimeout(f.current)},[]);let p=()=>void navigator.clipboard.writeText(e.name).then(()=>{D(`Copied ${e.name}`),f.current!==null&&clearTimeout(f.current),l(!0),f.current=setTimeout(()=>l(!1),2e3)},()=>D(`Could not copy the branch name`,{tone:`danger`})),m=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-sm px-2.5 text-[12.5px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,Z.jsxs)(Z.Fragment,{children:[e.runId?(0,Z.jsx)(L,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:a(m,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:`Open task`}):null,o?(0,Z.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:s.isPending,onClick:()=>s.mutate(),className:a(m,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,Z.jsx)(vt,{"aria-hidden":`true`}),s.isPending?`Creating…`:`Draft PR`]}):null,r?(0,Z.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,"data-copied":c||void 0,"aria-live":`polite`,onClick:p,className:a(m,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[c?(0,Z.jsx)(oe,{"aria-hidden":`true`}):(0,Z.jsx)(fe,{"aria-hidden":`true`}),c?`Copied`:`Copy branch`]}):null,(0,Z.jsxs)(Me,{children:[(0,Z.jsx)(Ae,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-8 shrink-0 items-center justify-center rounded-sm text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,Z.jsx)(pe,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,Z.jsxs)(je,{align:`end`,className:`w-52`,children:[e.runId?(0,Z.jsx)(I,{asChild:!0,className:`md:hidden`,children:(0,Z.jsx)(L,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,o?(0,Z.jsx)(I,{className:`md:hidden`,disabled:s.isPending,onSelect:()=>s.mutate(),children:`Draft PR`}):null,(0,Z.jsx)(I,{className:a(!r&&`md:hidden`),onSelect:p,children:`Copy branch`}),(0,Z.jsx)(ke,{className:`md:hidden`}),(0,Z.jsx)(I,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function Ht({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=t??e.lastCommit.at,a=Pe(i),o=e.runStatus?Ue(e.runStatus):void 0,s=n||!o?a:`${o.label}${a?` ${a}`:``}`,c=Number.isFinite(Date.parse(i))?new Date(i).toLocaleString():void 0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,Z.jsx)(_e,{"aria-label":`Task deleted`,className:`size-[12px] text-muted-foreground`}):(0,Z.jsx)(Ne,{tone:o?.tone??`neutral`,shape:o?.shape??`filled`,"aria-label":o?.label})}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[e.runId?(0,Z.jsx)(L,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] font-medium text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,Z.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] font-medium text-foreground`,title:r,children:r}),(0,Z.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),(0,Z.jsx)(Q,{}),(0,Z.jsxs)(`span`,{className:`shrink-0`,children:[e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Q,{}),(0,Z.jsx)(pt,{adds:e.diffStat.additions,dels:e.diffStat.deletions})]}):null,s?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Q,{}),(0,Z.jsx)(`span`,{className:`truncate`,title:c,children:s})]}):null]}),e.parentRunId?(0,Z.jsx)(L,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-xs text-muted-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,Z.jsx)(bt,{entry:e})]})]})}function Q(){return(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`})}function Ut({entry:e}){let t=m(Ee(`PR`,e.pr?.number).status),n=e.pr?.state,r=n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Q,{}),(0,Z.jsx)(`span`,{"data-slot":`not-landed-pr-state`,children:r})]})}function Wt({entry:e,onClose:t}){let n=T(),[r,i]=(0,X.useState)(``),a=(0,X.useId)(),o=d({mutationFn:e=>w({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;D(e.deleted.length>0?`Deleted ${e.deleted[0]}${t?` and ${t} commit${t===1?``:`s`} with it`:``}`:e.refused[0]?.reason??`Nothing was deleted`),n.invalidateQueries({queryKey:u.repo}),s()},onError:e=>D(e.message,{tone:`danger`})}),s=()=>{i(``),t()},c=e!==null&&r.trim()===e.name,l=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,Z.jsx)(H,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,Z.jsxs)(V,{"data-slot":`delete-branch-dialog`,children:[(0,Z.jsxs)(W,{children:[(0,Z.jsxs)(J,{children:[`Delete `,e?.name,`?`]}),(0,Z.jsx)(G,{asChild:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`p`,{children:e?.class===`orphan`?`Its task was deleted, so this branch is the only copy of the work.`:(0,Z.jsxs)(Z.Fragment,{children:[`This drops the work of `,(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.title??e?.name}),`. It is not on the base branch`,e?.pr?``:` and no pull request carries it`,`.`]})}),(0,Z.jsxs)(`p`,{"data-slot":`delete-branch-dropped`,children:[l,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,e?.lastCommit.sha?(0,Z.jsxs)(Z.Fragment,{children:[` (`,(0,Z.jsx)(Je,{sha:e.lastCommit.sha,variant:`inline`}),`)`]}):null,`.`]})]})})]}),(0,Z.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),c&&e&&!o.isPending&&o.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,Z.jsxs)(`label`,{htmlFor:a,className:`text-[12.5px] text-muted-foreground`,children:[`Type `,(0,Z.jsx)(`span`,{className:`font-mono text-foreground`,children:e?.name}),` to confirm`]}),(0,Z.jsx)(tt,{id:a,"data-slot":`delete-branch-confirm`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value),className:`h-11 font-mono`})]}),(0,Z.jsxs)(Y,{children:[(0,Z.jsx)(q,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,Z.jsx)(K,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!c||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function Gt({base:e}){let t=g(),n=T(),[r,i]=(0,X.useState)({merged:!1,empty:!1}),[a,o]=(0,X.useState)(!1),s=(t.data?.branches??[]).filter(e=>e.class===`merged`),c=(t.data?.branches??[]).filter(e=>e.class===`empty`),l=[...s,...c],f=d({mutationFn:e=>w({names:e}),onSuccess:e=>{let t=e.refused.length;D(`Deleted ${e.deleted.length} branch${e.deleted.length===1?``:`es`}${t?`; kept ${t} that ${t===1?`is`:`are`} no longer safe to delete`:``}`),n.invalidateQueries({queryKey:u.repo})},onError:e=>{n.invalidateQueries({queryKey:u.repo}),D(e.message,{tone:`danger`})}});if(t.isPending)return(0,Z.jsx)(`p`,{"data-slot":`cleanup-branches-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading branches…`});if(t.isError)return(0,Z.jsxs)(`p`,{"data-slot":`cleanup-branches-error`,className:`text-[13px] text-danger`,children:[`Branches did not load: `,t.error.message]});let p=l.length,m=`branch${p===1?``:`es`}`;return(0,Z.jsxs)(`section`,{"data-slot":`cleanup-branches`,"aria-labelledby":`cleanup-branches-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Z.jsxs)(`h2`,{id:`cleanup-branches-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Branches safe to delete · `,p]}),(0,Z.jsxs)(`p`,{className:`text-xs leading-[17px] text-soft-foreground`,children:[`Their work is already on `,e,`, or they have none. Deleting loses nothing.`]})]}),(0,Z.jsxs)(`button`,{type:`button`,"data-action":`cleanup-branches-delete`,disabled:p===0||f.isPending,onClick:()=>o(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,Z.jsx)(ae,{"aria-hidden":`true`,className:`size-[12px]`}),f.isPending?`Deleting…`:`Delete ${p} ${m}`]})]}),(0,Z.jsx)(Kt,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:Pt.toLowerCase(),rows:s,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,Z.jsx)(Kt,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:c,open:r.empty,onToggle:()=>i(e=>({...e,empty:!e.empty}))}),(0,Z.jsx)(H,{open:a,onOpenChange:o,children:(0,Z.jsxs)(V,{children:[(0,Z.jsxs)(W,{children:[(0,Z.jsxs)(J,{children:[`Delete `,p,` `,m,`?`]}),(0,Z.jsxs)(G,{children:[s.length,` merged into `,e,` and `,c.length,` empty. Their work is already on `,e,`, or they have none. Anything that stopped being safe since this list loaded is kept.`]})]}),(0,Z.jsxs)(Y,{children:[(0,Z.jsx)(q,{children:`Keep them`}),(0,Z.jsxs)(K,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{f.mutate(l.map(e=>e.name)),o(!1)},children:[`Delete `,p,` `,m]})]})]})})]})}function Kt({kind:e,title:t,hint:n,rows:r,open:i,onToggle:o}){let s=`cleanup-branches-${e}`;return(0,Z.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":s,disabled:r.length===0,onClick:o,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Z.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,Z.jsx)(`span`,{className:`truncate text-xs text-soft-foreground`,children:n})]}),r.length>0?(0,Z.jsx)(de,{"aria-hidden":`true`,className:a(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,Z.jsx)(`ul`,{id:s,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,Z.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-xs`,children:[(0,Z.jsx)(ot,{value:e.name,className:`shrink-0 text-muted-foreground`}),e.runId?(0,Z.jsx)(L,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,Z.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,Z.jsx)(Ke,{iso:e.lastCommit.at,className:`shrink-0 text-soft-foreground`})]},e.name))}):null]})}function $(e){return e.some(e=>e.sizeBytes===null)?null:e.reduce((e,t)=>e+(t.sizeBytes??0),0)}function qt(e){return e.kind===`dirty`?`${e.uncommittedFiles} uncommitted`:e.kind===`detached-head`?`detached HEAD`:e.kind===`submodules`?`has submodules`:`broken worktree`}function Jt(e){if(e.kind===`dirty`){let t=`${e.uncommittedFiles} uncommitted file${e.uncommittedFiles===1?``:`s`}`;return e.detachedHead?`${t} and a detached HEAD on no branch`:t}return e.kind===`detached-head`?`a detached HEAD whose commit is on no branch`:e.kind===`submodules`?`initialized submodules that Git will not remove without force`:`an unregistered or broken Git worktree directory`}function Yt(e){let t=e.some(e=>e.reclaimBlocker?.kind===`dirty`),n=e.some(e=>e.reclaimBlocker?.kind===`detached-head`||e.reclaimBlocker?.kind===`dirty`&&e.reclaimBlocker.detachedHead),r=e.some(e=>e.reclaimBlocker?.kind===`submodules`),i=e.some(e=>e.reclaimBlocker?.kind===`invalid`),a=[...t?[`uncommitted work`]:[],...n?[`a detached HEAD`]:[],...r?[`initialized submodules`]:[],...i?[`a broken checkout`]:[]];return a.length<=1?a[0]??`uncommitted work`:`${a.slice(0,-1).join(`, `)} or ${a.at(-1)}`}function Xt(e,t,n){let r=Math.max(0,t-e);return e===0?r===0?`Nothing to reclaim — no finished worktrees exceed the keep limit`:n?`Nothing was reclaimed — the worktrees past the keep limit are in use or could not be removed`:`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Reclaimed ${e} worktree${e===1?``:`s`} (branch kept)${r>0?` · ${r} kept: ${n?`in use or could not be removed`:`uncommitted work or in use`}`:``}`}function Zt(e,t){return e===0?`Reclaim now`:t?`Reclaim ${j(t)} now`:`Reclaim ${e} now`}function Qt(e,t,n){let r=t?j(t):String(e);return n?`Discard & reclaim all ${r}`:`Discard & reclaim ${r}`}function $t(e,t){if(!e)return t>0?`No clean worktrees past the keep limit — use Discard & reclaim for blocked worktrees`:`Nothing past the keep limit to reclaim`}function en(e){return e===0?{prefix:`Retention is unlimited (`,suffix:`), so nothing is reclaimed on its own.`}:{prefix:`Retention keeps the newest ${e} finished checkout${e===1?``:`s`} (`,suffix:`) and reclaims the rest.`}}function tn({blocked:e,discardLabel:t,disabled:n,onDiscard:r}){let i=$(e),a=e.length===1?``:`s`,o=e.length===1?`it has`:`they have`;return(0,Z.jsxs)(`div`,{"data-slot":`worktrees-blocked-banner`,className:`flex flex-col gap-[10px] border-b border-border bg-muted/40 px-[14px] py-[10px] md:flex-row md:items-center`,children:[(0,Z.jsxs)(`p`,{className:`min-w-0 flex-1 text-[12px] leading-[17px] text-foreground`,children:[e.length,` worktree`,a,` past the keep limit`,i?` (${j(i)})`:``,` `,`cannot be reclaimed automatically because `,o,` `,Yt(e),`.`]}),(0,Z.jsxs)(`button`,{type:`button`,"data-action":`worktrees-discard-reclaim`,disabled:n,onClick:r,className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] border border-danger/40 px-[10px] text-[12px] font-medium text-danger hover:bg-danger/10 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 md:self-center`,children:[(0,Z.jsx)(lt,{"aria-hidden":`true`,className:`size-[12px]`}),t]})]})}function nn({confirmClean:e,onCloseClean:t,cleanCount:n,cleanBytes:r,reclaimLabel:i,onConfirmClean:a,discardBatch:o,onCloseDiscardBatch:s,onConfirmDiscardBatch:c,discardRow:l,onCloseRow:u,onConfirmRow:d}){let f=o?$(o):null,p=o?o.filter(e=>e.reclaimBlocker!==null).length:0,m=o?o.some(e=>!e.reclaimBlocker):!1,h=o?Qt(o.length,f,m):``;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(H,{open:e,onOpenChange:e=>{e||t()},children:(0,Z.jsxs)(V,{children:[(0,Z.jsxs)(W,{children:[(0,Z.jsx)(J,{children:`Reclaim old worktrees?`}),(0,Z.jsxs)(G,{children:[n,` finished worktree`,n===1?``:`s`,` beyond the keep limit`,r?` (${j(r)})`:``,` `,n===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,Z.jsxs)(Y,{children:[(0,Z.jsx)(q,{children:`Keep them`}),(0,Z.jsx)(K,{"data-action":`worktrees-confirm`,onClick:a,children:i})]})]})}),(0,Z.jsx)(H,{open:o!==null,onOpenChange:e=>{e||s()},children:(0,Z.jsxs)(V,{children:[(0,Z.jsxs)(W,{children:[(0,Z.jsx)(J,{children:`Discard changes and reclaim worktrees?`}),(0,Z.jsx)(G,{children:o?(0,Z.jsxs)(Z.Fragment,{children:[o.length,` finished worktree`,o.length===1?``:`s`,` beyond the keep limit`,f?` (${j(f)})`:``,` will be reclaimed now.`,` `,`Uncommitted files and detached-HEAD commits in `,p,` blocked checkout`,p===1?``:`s`,` will be permanently discarded. Each task’s branch is kept.`]}):null})]}),(0,Z.jsxs)(Y,{children:[(0,Z.jsx)(q,{children:`Keep them`}),(0,Z.jsx)(K,{"data-action":`worktrees-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{o&&c(o),s()},children:h})]})]})}),(0,Z.jsx)(H,{open:l!==null,onOpenChange:e=>{e||u()},children:(0,Z.jsxs)(V,{children:[(0,Z.jsxs)(W,{children:[(0,Z.jsx)(J,{children:`Discard changes and reclaim worktree?`}),(0,Z.jsx)(G,{children:l?.reclaimBlocker?(0,Z.jsxs)(Z.Fragment,{children:[l.title,` has `,Jt(l.reclaimBlocker),`. Reclaiming removes the directory and permanently discards uncommitted or unbranched changes in it. The branch (`,l.branch??l.runId.slice(0,8),`) is kept.`]}):null})]}),(0,Z.jsxs)(Y,{children:[(0,Z.jsx)(q,{children:`Keep it`}),(0,Z.jsx)(K,{"data-action":`worktree-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{l&&d(l),u()},children:`Discard & reclaim`})]})]})})]})}function rn(){let e=f(),t=l().data?.targets.find(e=>e.id===`finder`),n=d({mutationFn:e=>b(e,t.id),onError:e=>D(e.message,{tone:`danger`})}),r=T(),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(null),[c,p]=(0,X.useState)(null),m=()=>Promise.all([r.invalidateQueries({queryKey:u.worktrees}),r.invalidateQueries({queryKey:u.repoBranches})]),h=d({mutationFn:({runIds:e})=>S(e?{discardWork:!0,runIds:e}:void 0),onSuccess:(e,{expected:t,runIds:n})=>{m(),D(Xt(e.reclaimed.length,t,!!n))},onError:e=>D(e.message,{tone:`danger`})}),g=d({mutationFn:({worktree:e,discardWork:t})=>x(e.runId,t?{discardWork:!0}:void 0),onSuccess:(e,{worktree:t})=>{m(),D(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{m(),D(e.message,{tone:`danger`})}});if(e.isPending)return(0,Z.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,Z.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-[13px] text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:_,totalBytes:v,keep:y}=e.data,C=h.isPending||g.isPending,w=_.filter(e=>e.pastKeep),E=w.filter(e=>!e.reclaimBlocker),O=w.filter(e=>e.reclaimBlocker!==null),k=E.length>0,A=$(E),M=$(w),N=Zt(E.length,A),ee=Qt(w.length,M,k),P=v?j(v):null,te=en(y);return(0,Z.jsxs)(`section`,{"data-slot":`worktrees-panel`,"aria-labelledby":`worktrees-panel-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Z.jsxs)(`h2`,{id:`worktrees-panel-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Worktrees on disk`,P?` · ${P}`:``]}),(0,Z.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-xs leading-[17px] text-soft-foreground`,children:[te.prefix,(0,Z.jsx)(L,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:it(`worktrees`,` › `)}),te.suffix,` `,`Reclaim removes the directory only; the branch stays, so its work stays recoverable.`]})]}),(0,Z.jsxs)(`button`,{type:`button`,"data-action":`worktrees-reclaim-now`,disabled:C||!k,title:$t(k,O.length),onClick:()=>a(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,Z.jsx)(lt,{"aria-hidden":`true`,className:`size-[12px]`}),N]})]}),O.length>0?(0,Z.jsx)(tn,{blocked:O,discardLabel:ee,disabled:C,onDiscard:()=>s(w)}):null,_.length===0?(0,Z.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`px-[14px] py-[12px] text-[12.5px] text-soft-foreground`,children:`No task worktrees on disk.`}):(0,Z.jsx)(`ul`,{"aria-label":`Task worktrees on disk`,className:`flex flex-col`,children:_.map(e=>(0,Z.jsx)(sn,{worktree:e,keep:y,disabled:C,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>{e.reclaimBlocker?p(e):g.mutate({worktree:e,discardWork:!1})}},e.runId))}),(0,Z.jsx)(nn,{confirmClean:i,onCloseClean:()=>a(!1),cleanCount:E.length,cleanBytes:A,reclaimLabel:N,onConfirmClean:()=>{h.mutate({expected:E.length}),a(!1)},discardBatch:o,onCloseDiscardBatch:()=>s(null),onConfirmDiscardBatch:e=>{h.mutate({expected:e.length,runIds:e.map(e=>e.runId)})},discardRow:c,onCloseRow:()=>p(null),onConfirmRow:e=>g.mutate({worktree:e,discardWork:!0})})]})}var an=new Set([`queued`,`running`,`waiting`,`review`]);function on(e,t){return an.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`,state:`in-use`}:e.reclaimBlocker?{label:qt(e.reclaimBlocker),tone:`blocked`,state:`blocked`}:e.pastKeep?{label:`reclaimable`,tone:`plain`,state:`reclaimable`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`,state:`kept`}}function sn({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:o}){let s=on(e,t),c=Pe(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${Fe(c)}`:e.status,u=s.tone===`in-use`?`text-status-running`:s.tone===`blocked`?`text-danger`:`text-soft-foreground`,d=e.reclaimBlocker?`Cannot auto-reclaim: ${Jt(e.reclaimBlocker)}`:void 0,f=(0,Z.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":s.state,title:d,className:a(`text-xs`,u),children:s.label}),p=`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:size-11`,m=e.reclaimBlocker?`Discard changes and reclaim the worktree of ${e.title} (branch kept)`:`Reclaim the worktree of ${e.title} (branch kept)`,h=e.reclaimBlocker?`Discard changes and reclaim the directory (branch kept)`:`Reclaim the directory (branch kept)`;return(0,Z.jsxs)(`li`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`flex min-h-[44px] items-center gap-[12px] border-b border-border px-[14px] py-[4px] last:border-0`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Z.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,title:e.title,children:e.title}),(0,Z.jsxs)(`span`,{className:`truncate font-mono text-xs text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,l,(0,Z.jsxs)(`span`,{className:`md:hidden`,children:[` · `,s.label]})]})]}),(0,Z.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-xs tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:j(e.sizeBytes)||`0 kB`}),(0,Z.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:f}),r?(0,Z.jsx)(`button`,{type:`button`,className:p,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,Z.jsx)(ee,{"aria-hidden":`true`,className:`size-[13px]`})}):null,s.tone===`in-use`?null:(0,Z.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":m,title:h,disabled:n,onClick:o,className:a(p,e.reclaimBlocker&&`text-danger hover:text-danger`),children:(0,Z.jsx)(lt,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function cn(e){return e===`main`||e===`changes`?`Split`:`Table`}function ln({section:e,index:t=!1}){let n=o(),r=nt(),[i]=k(),a=cn(e);if(t&&!r&&i.get(`view`)!==`repo`)return(0,Z.jsx)(yt,{});if(n.isPending)return(0,Z.jsx)($e,{});if(n.isError)return(0,Z.jsx)(R,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,Z.jsx)(B,{}),children:(0,Z.jsx)(z,{icon:(0,Z.jsx)(le,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})});let s=n.data.info;return s?(0,Z.jsx)(un,{repo:n.data,info:s,section:e}):(0,Z.jsx)(R,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,Z.jsx)(B,{}),children:(0,Z.jsx)(z,{icon:(0,Z.jsx)(M,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`Squawk is running outside a git repository — start it inside one to browse changes, commits and branches.`})})}function un({repo:e,info:t,section:n}){let r=cn(n),i=g(),a=n===`main`?e.log.length:n===`changes`?e.status.length:n===`branches`?Ot(e,i.data?.branches).length:n===`not-landed`?i.data?.branches.filter(e=>e.class===`not-landed`||e.class===`orphan`).length??0:4;return(0,Z.jsx)(R,{template:r,route:`repo-git`,density:n===`not-landed`&&i.isPending?`full`:Ie(a),rootProps:{"data-git-section":n},beforeHeader:(0,Z.jsx)(B,{}),header:{title:Ve(n,t.branch),headerSlot:`repo-header`,subtitle:(0,Z.jsx)(dn,{repo:e,info:t,section:n}),subtitleSlot:`repo-meta`},children:n===`main`?(0,Z.jsx)(At,{repo:e,info:t}):n===`not-landed`?(0,Z.jsx)(Lt,{}):n===`cleanup`?(0,Z.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[(0,Z.jsx)(rn,{}),(0,Z.jsx)(Gt,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,Z.jsx)(St,{repo:e,info:t}):(0,Z.jsx)(kt,{})})}function dn({repo:e,info:t,section:n}){let r=e.baseBranch??t.branch;switch(n){case`main`:return(0,Z.jsxs)(Z.Fragment,{children:[e.log.length===0?`No commits yet`:`Latest ${e.log.length} commit${e.log.length===1?``:`s`} in the main checkout`,e.tracking?` · ${Qe(e.tracking)}`:``]});case`not-landed`:return(0,Z.jsxs)(Z.Fragment,{children:[`Finished tasks whose commits are not on `,r]});case`branches`:return(0,Z.jsx)(fn,{repo:e,info:t});case`changes`:return(0,Z.jsxs)(Z.Fragment,{children:[e.status.length,` uncommitted file`,e.status.length===1?``:`s`,` in the main checkout`]});case`cleanup`:return(0,Z.jsxs)(Z.Fragment,{children:[`Nothing here can delete work that is not on `,r]})}}function fn({repo:e,info:t}){let n=Ot(e,g().data?.branches).length;return(0,Z.jsxs)(Z.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{ln as RepoGitRoute};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{B as r,N as i}from"./queries-D0v1z40Y.js";import{Fn as a,nt as o}from"./toaster-DMfiAEnw.js";import{f as s,g as c,h as l,i as u,n as d,p as f}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{ot as p,r as m}from"./design-icons-CzEoMH9c.js";import{a as h,c as g,l as _,s as v,t as y}from"./file-preview-B70cmj6I.js";import{t as b}from"./button-B7MKxYjT.js";import{t as x}from"./centered-state-V15AR_qo.js";import{Mn as S,_ as C,g as w,v as T}from"./index-01bdo9g3.js";import{r as E}from"./html-report-BX3msvci.js";import{t as D}from"./html-report-frame-DkHr39E2.js";var O=e(t(),1),k=n();function A(){let e=s(),t=f();return()=>{if(e.key==="default"||window.history.state?.idx===0){t({pathname:e.pathname.replace(/\/report\/?$/,``)},{replace:!0});return}let n=window.navigation,r=j(e.state);n?.canGoBack?n.back():r?t(r,{state:{filesRestoreKey:e.state?.filesRestoreKey}}):t(-1)}}function j(e){let t=e?.readerFrom;return typeof t==`string`&&t.startsWith(`/`)&&!t.startsWith(`//`)?t:null}function M(e){return e?.type===`file`?e:null}function N(){let[e]=c(),t=e.get(`path`),n=e.get(`artifact`);return{path:t,artifactId:n,conflict:e.getAll(`path`).length>1||e.getAll(`artifact`).length>1||t!==null&&n!==null||t===``||n===``}}function P(){let{id:e=``}=l(),t=N(),n=s(),r=A();return(0,k.jsx)(F,{runId:e,selection:t,fragment:n.hash,onBack:r,variant:`route`})}function F({runId:e,selection:t,fragment:n,onBack:r,variant:i,sourceLookup:a}){let{path:o,conflict:c,selected:l,result:d}=L(e,t,a),f=T(w,!0),p=T(C,!1),m=s(),[h,g]=(0,O.useState)(!1),_=M(d.data);if(i===`route`&&R(_))return(0,k.jsx)(u,{replace:!0,to:{pathname:m.pathname.replace(/\/report\/?$/,`/files`),search:m.search,hash:m.hash}});let v=B(_,o),y=i===`pane`&&!p&&!f?`Conversation`:`Back`,b=i===`pane`&&!h&&z(_),x=I(m.pathname,e,t);return(0,k.jsxs)(`div`,{"data-route":`task-report`,"data-variant":i,onKeyDown:e=>{i!==`pane`||e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),r())},className:i===`route`?`fixed inset-0 z-50 flex flex-col bg-background [padding-block-start:env(safe-area-inset-top)] [padding-inline-end:env(safe-area-inset-right)] [padding-block-end:env(safe-area-inset-bottom)] [padding-inline-start:env(safe-area-inset-left)] md:static md:z-auto md:h-full md:p-0`:`flex h-full min-h-0 flex-col bg-background max-md:[padding-block-start:env(safe-area-inset-top)] max-md:[padding-inline-start:env(safe-area-inset-left)] max-md:[padding-inline-end:env(safe-area-inset-right)]`,children:[(0,k.jsx)(V,{runId:e,file:_,name:v,source:h,onSource:()=>g(e=>!e),onBack:r,backLabel:y,hideDownload:i===`pane`&&p,focusBack:i===`pane`}),(0,k.jsx)(`div`,{"data-slot":`report-body`,className:b?`flex min-h-0 flex-1 flex-col overflow-clip`:`flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,k.jsx)(H,{conflict:c,selected:l,result:d,source:h,name:v,fragment:n,pane:i===`pane`,filesHref:x})})]})}function I(e,t,n){let r=/^\/p\/[^/]+/.exec(e)?.[0]??``,i=n.artifactId?new URLSearchParams({artifact:n.artifactId}):new URLSearchParams({path:n.path??``});return`${r}/tasks/${encodeURIComponent(t)}/files?${i}`}function L(e,t,n){let{path:a=null,artifactId:o=null,conflict:s=!1}=t,c=n?.isPending||n?.isError,l=r(e,o||s||c?null:a),u=i(e,s||c?null:o),d=c&&n?{...n,data:void 0}:o?u:l;return{path:a,conflict:s,selected:a!==null||o!==null,result:d}}function R(e){return e!==null&&(!E(e.path)||!e.artifact&&(e.tooLarge||e.binary))}function z(e){return e!==null&&!e.tooLarge&&!e.binary}function B(e,t){return e?e.artifact?.name??e.path.split(/[\\/]/).at(-1)??e.path:t??`Report`}function V({runId:e,file:t,name:n,source:r,onSource:i,onBack:a,backLabel:s,hideDownload:c,focusBack:l}){let u=(0,O.useRef)(null);(0,O.useEffect)(()=>{l&&u.current?.focus({preventScroll:!0})},[l]);let d=t?.artifact;return(0,k.jsxs)(`header`,{"data-slot":`report-bar`,className:`flex min-h-14 shrink-0 items-center gap-2 border-b border-border bg-card px-2 md:px-4`,children:[(0,k.jsxs)(b,{ref:u,variant:`ghost`,className:`min-h-11 min-w-11 gap-1.5 px-2`,onClick:a,"aria-label":s,children:[(0,k.jsx)(m,{size:18,"aria-hidden":`true`}),(0,k.jsx)(`span`,{className:`max-sm:sr-only`,children:s})]}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`h1`,{className:`truncate text-sm font-medium`,children:n}),t?(0,k.jsxs)(`p`,{className:`truncate text-xs text-soft-foreground`,children:[d?(0,k.jsxs)(k.Fragment,{children:[`Published snapshot · `,(0,k.jsx)(S,{iso:d.createdAt})]}):`Live file`,` · `,h(t.size)]}):null]}),t&&!t.tooLarge&&!t.binary?(0,k.jsx)(b,{variant:`ghost`,className:`min-h-11 px-3 text-accent-text`,onClick:i,children:r?`Preview`:`Source`}):null,d&&!c?(0,k.jsx)(`a`,{className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline focus-visible:ring-2`,href:o(e,d.id,`download`),children:`Download`}):null]})}function H({conflict:e,selected:t,result:n,source:r,name:i,fragment:a,pane:o,filesHref:s}){if(e)return(0,k.jsx)(W,{icon:(0,k.jsx)(v,{}),title:`Invalid report link`,subtitle:`Choose either a path or a published artifact.`});if(!t)return(0,k.jsx)(W,{icon:(0,k.jsx)(g,{}),title:`No report selected`,subtitle:`Open a report from a link in the conversation or from Files.`});if(n.isPending)return(0,k.jsx)(`p`,{role:`status`,"data-slot":`report-loading`,className:`px-4 py-6 text-center text-sm text-soft-foreground`,children:`Loading report…`});if(n.isError)return(0,k.jsx)(U,{result:n});let c=n.data;return c.type===`file`?o&&!E(c.path)?(0,k.jsx)(W,{icon:(0,k.jsx)(g,{}),title:`Not an HTML report`,subtitle:`Open this published file in Files.`,action:(0,k.jsx)(d,{to:s,className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:`Open in Files`})}):c.tooLarge?(0,k.jsx)(W,{icon:(0,k.jsx)(_,{}),title:`Too large to preview`,subtitle:`${h(c.size)} is past the 500 kB preview limit. Download it to read it.`}):c.binary?(0,k.jsx)(W,{icon:(0,k.jsx)(g,{}),title:`Binary file`,subtitle:`This file holds binary data, not readable HTML.`}):r?(0,k.jsx)(`div`,{className:`bg-card`,children:(0,k.jsx)(y,{path:c.path,text:c.content??``})}):(0,k.jsx)(D,{html:c.content??``,title:`Report: ${i}`,fragment:a,className:o?`min-h-0 flex-1`:`min-h-[60dvh] flex-1`}):(0,k.jsx)(W,{icon:(0,k.jsx)(v,{}),title:c.type===`unpublished`?`Report not published`:`Report unavailable`,subtitle:c.reason})}function U({result:e}){let t=e.error instanceof a&&e.error.status===404;return(0,k.jsx)(W,{icon:t?(0,k.jsx)(v,{}):(0,k.jsx)(p,{size:16}),tone:t?`neutral`:`danger`,title:t?`Report missing or deleted`:`Could not load this report`,subtitle:e.error?.message??`Try again.`,action:(0,k.jsx)(b,{variant:`outline`,className:`min-h-11`,onClick:()=>void e.refetch(),children:`Retry`})})}function W({icon:e,title:t,subtitle:n,tone:r=`neutral`,action:i}){return(0,k.jsxs)(`div`,{"data-slot":`report-state`,className:`flex flex-col items-center gap-3 p-6`,children:[(0,k.jsx)(x,{icon:e,tone:r,heading:`h2`,title:t,subtitle:n}),i]})}export{F as ReportReader,P as TaskReportRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{B as r,N as i}from"./queries-D0v1z40Y.js";import{Fn as a,nt as o}from"./toaster-DMfiAEnw.js";import{f as s,g as c,h as l,i as u,n as d,p as f}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{ot as p,r as m}from"./design-icons-CzEoMH9c.js";import{a as h,c as g,l as _,s as v,t as y}from"./file-preview-B4UtCBRw.js";import{t as b}from"./button-B7MKxYjT.js";import{t as x}from"./centered-state-V15AR_qo.js";import{Mn as S,_ as C,g as w,v as T}from"./index-DEWnkuj6.js";import{r as E}from"./html-report-BX3msvci.js";import{t as D}from"./html-report-frame-DkHr39E2.js";var O=e(t(),1),k=n();function A(){let e=s(),t=f();return()=>{if(e.key==="default"||window.history.state?.idx===0){t({pathname:e.pathname.replace(/\/report\/?$/,``)},{replace:!0});return}let n=window.navigation,r=j(e.state);n?.canGoBack?n.back():r?t(r,{state:{filesRestoreKey:e.state?.filesRestoreKey}}):t(-1)}}function j(e){let t=e?.readerFrom;return typeof t==`string`&&t.startsWith(`/`)&&!t.startsWith(`//`)?t:null}function M(e){return e?.type===`file`?e:null}function N(){let[e]=c(),t=e.get(`path`),n=e.get(`artifact`);return{path:t,artifactId:n,conflict:e.getAll(`path`).length>1||e.getAll(`artifact`).length>1||t!==null&&n!==null||t===``||n===``}}function P(){let{id:e=``}=l(),t=N(),n=s(),r=A();return(0,k.jsx)(F,{runId:e,selection:t,fragment:n.hash,onBack:r,variant:`route`})}function F({runId:e,selection:t,fragment:n,onBack:r,variant:i,sourceLookup:a}){let{path:o,conflict:c,selected:l,result:d}=L(e,t,a),f=T(w,!0),p=T(C,!1),m=s(),[h,g]=(0,O.useState)(!1),_=M(d.data);if(i===`route`&&R(_))return(0,k.jsx)(u,{replace:!0,to:{pathname:m.pathname.replace(/\/report\/?$/,`/files`),search:m.search,hash:m.hash}});let v=B(_,o),y=i===`pane`&&!p&&!f?`Conversation`:`Back`,b=i===`pane`&&!h&&z(_),x=I(m.pathname,e,t);return(0,k.jsxs)(`div`,{"data-route":`task-report`,"data-variant":i,onKeyDown:e=>{i!==`pane`||e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),r())},className:i===`route`?`fixed inset-0 z-50 flex flex-col bg-background [padding-block-start:env(safe-area-inset-top)] [padding-inline-end:env(safe-area-inset-right)] [padding-block-end:env(safe-area-inset-bottom)] [padding-inline-start:env(safe-area-inset-left)] md:static md:z-auto md:h-full md:p-0`:`flex h-full min-h-0 flex-col bg-background max-md:[padding-block-start:env(safe-area-inset-top)] max-md:[padding-inline-start:env(safe-area-inset-left)] max-md:[padding-inline-end:env(safe-area-inset-right)]`,children:[(0,k.jsx)(V,{runId:e,file:_,name:v,source:h,onSource:()=>g(e=>!e),onBack:r,backLabel:y,hideDownload:i===`pane`&&p,focusBack:i===`pane`}),(0,k.jsx)(`div`,{"data-slot":`report-body`,className:b?`flex min-h-0 flex-1 flex-col overflow-clip`:`flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,k.jsx)(H,{conflict:c,selected:l,result:d,source:h,name:v,fragment:n,pane:i===`pane`,filesHref:x})})]})}function I(e,t,n){let r=/^\/p\/[^/]+/.exec(e)?.[0]??``,i=n.artifactId?new URLSearchParams({artifact:n.artifactId}):new URLSearchParams({path:n.path??``});return`${r}/tasks/${encodeURIComponent(t)}/files?${i}`}function L(e,t,n){let{path:a=null,artifactId:o=null,conflict:s=!1}=t,c=n?.isPending||n?.isError,l=r(e,o||s||c?null:a),u=i(e,s||c?null:o),d=c&&n?{...n,data:void 0}:o?u:l;return{path:a,conflict:s,selected:a!==null||o!==null,result:d}}function R(e){return e!==null&&(!E(e.path)||!e.artifact&&(e.tooLarge||e.binary))}function z(e){return e!==null&&!e.tooLarge&&!e.binary}function B(e,t){return e?e.artifact?.name??e.path.split(/[\\/]/).at(-1)??e.path:t??`Report`}function V({runId:e,file:t,name:n,source:r,onSource:i,onBack:a,backLabel:s,hideDownload:c,focusBack:l}){let u=(0,O.useRef)(null);(0,O.useEffect)(()=>{l&&u.current?.focus({preventScroll:!0})},[l]);let d=t?.artifact;return(0,k.jsxs)(`header`,{"data-slot":`report-bar`,className:`flex min-h-14 shrink-0 items-center gap-2 border-b border-border bg-card px-2 md:px-4`,children:[(0,k.jsxs)(b,{ref:u,variant:`ghost`,className:`min-h-11 min-w-11 gap-1.5 px-2`,onClick:a,"aria-label":s,children:[(0,k.jsx)(m,{size:18,"aria-hidden":`true`}),(0,k.jsx)(`span`,{className:`max-sm:sr-only`,children:s})]}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`h1`,{className:`truncate text-sm font-medium`,children:n}),t?(0,k.jsxs)(`p`,{className:`truncate text-xs text-soft-foreground`,children:[d?(0,k.jsxs)(k.Fragment,{children:[`Published snapshot · `,(0,k.jsx)(S,{iso:d.createdAt})]}):`Live file`,` · `,h(t.size)]}):null]}),t&&!t.tooLarge&&!t.binary?(0,k.jsx)(b,{variant:`ghost`,className:`min-h-11 px-3 text-accent-text`,onClick:i,children:r?`Preview`:`Source`}):null,d&&!c?(0,k.jsx)(`a`,{className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline focus-visible:ring-2`,href:o(e,d.id,`download`),children:`Download`}):null]})}function H({conflict:e,selected:t,result:n,source:r,name:i,fragment:a,pane:o,filesHref:s}){if(e)return(0,k.jsx)(W,{icon:(0,k.jsx)(v,{}),title:`Invalid report link`,subtitle:`Choose either a path or a published artifact.`});if(!t)return(0,k.jsx)(W,{icon:(0,k.jsx)(g,{}),title:`No report selected`,subtitle:`Open a report from a link in the conversation or from Files.`});if(n.isPending)return(0,k.jsx)(`p`,{role:`status`,"data-slot":`report-loading`,className:`px-4 py-6 text-center text-sm text-soft-foreground`,children:`Loading report…`});if(n.isError)return(0,k.jsx)(U,{result:n});let c=n.data;return c.type===`file`?o&&!E(c.path)?(0,k.jsx)(W,{icon:(0,k.jsx)(g,{}),title:`Not an HTML report`,subtitle:`Open this published file in Files.`,action:(0,k.jsx)(d,{to:s,className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:`Open in Files`})}):c.tooLarge?(0,k.jsx)(W,{icon:(0,k.jsx)(_,{}),title:`Too large to preview`,subtitle:`${h(c.size)} is past the 500 kB preview limit. Download it to read it.`}):c.binary?(0,k.jsx)(W,{icon:(0,k.jsx)(g,{}),title:`Binary file`,subtitle:`This file holds binary data, not readable HTML.`}):r?(0,k.jsx)(`div`,{className:`bg-card`,children:(0,k.jsx)(y,{path:c.path,text:c.content??``})}):(0,k.jsx)(D,{html:c.content??``,title:`Report: ${i}`,fragment:a,className:o?`min-h-0 flex-1`:`min-h-[60dvh] flex-1`}):(0,k.jsx)(W,{icon:(0,k.jsx)(v,{}),title:c.type===`unpublished`?`Report not published`:`Report unavailable`,subtitle:c.reason})}function U({result:e}){let t=e.error instanceof a&&e.error.status===404;return(0,k.jsx)(W,{icon:t?(0,k.jsx)(v,{}):(0,k.jsx)(p,{size:16}),tone:t?`neutral`:`danger`,title:t?`Report missing or deleted`:`Could not load this report`,subtitle:e.error?.message??`Try again.`,action:(0,k.jsx)(b,{variant:`outline`,className:`min-h-11`,onClick:()=>void e.refetch(),children:`Retry`})})}function W({icon:e,title:t,subtitle:n,tone:r=`neutral`,action:i}){return(0,k.jsxs)(`div`,{"data-slot":`report-state`,className:`flex flex-col items-center gap-3 p-6`,children:[(0,k.jsx)(x,{icon:e,tone:r,heading:`h2`,title:t,subtitle:n}),i]})}export{F as ReportReader,P as TaskReportRoute};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r,t as i}from"./utils-DSMR_WLb.js";import{N as a,Rt as o,ct as s}from"./queries-D0v1z40Y.js";import{Hr as c,In as l,Ln as u,Wr as d,br as f,hi as p,pi as m,ri as h,zn as g}from"./toaster-DMfiAEnw.js";import{B as _,F as v,I as y,J as b,N as x,W as S,Y as C,z as w}from"./live-protocol-DMhTnCmf.js";import{f as T,m as E}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{X as D}from"./design-icons-CzEoMH9c.js";import{t as ee}from"./arrow-up-right-DKGzsMqY.js";import{t as te}from"./chevron-right-BENZ-1ZN.js";import{t as O}from"./eye-B8okNWXU.js";import{t as k}from"./button-B7MKxYjT.js";import{t as A}from"./project-router-BifLGgRR.js";import{d as j,l as M,n as N,r as P,t as F}from"./page-shell-7pLJMOgh.js";import{t as I}from"./use-search-params-writer-ClMScnNe.js";import{Mn as L,Zn as R,Zt as z,mn as B,or as V}from"./index-01bdo9g3.js";import{t as H}from"./report-title-D4Mbu2Er.js";import{t as U}from"./html-report-frame-DkHr39E2.js";var W=e(t(),1),G=1e3,K=S().min(1).max(1024);_({q:S().max(G).optional(),before:K.optional(),limit:S().regex(/^(?:[1-9]|[1-9][0-9]|100)$/).transform(Number).optional()}).strict();var q=_({reports:x(_({id:b(),runId:b(),name:S(),title:S(),createdAt:C(),size:w().int().nonnegative(),taskTitle:S(),taskStatus:f}).strict()),nextCursor:K.nullable(),total:w().int().nonnegative()}).strict(),J=_({epoch:b(),generation:w().int().nonnegative(),metadataGeneration:w().int().nonnegative()}).strict(),Y=_({runId:b(),taskTitle:S(),taskStatus:f}).strict(),X=v(`type`,[J.extend({type:y(`snapshot`)}),J.extend({type:y(`content`)}),J.extend({type:y(`metadata`),runs:x(Y)})]),Z=new WeakMap;function ne(e,t){if(!e)return{content:t.type===`content`,metadata:t.type===`metadata`,reset:!1};if(e.epoch!==t.epoch)return{content:!0,metadata:!0,reset:!0};if(!(t.generation<e.generation||t.metadataGeneration<e.metadataGeneration)&&!(e.generation===t.generation&&e.metadataGeneration===t.metadataGeneration))return{content:t.generation!==e.generation,metadata:t.metadataGeneration!==e.metadataGeneration,reset:!1}}var re=class{client;project;state;content=0;metadata=0;patches=new Map;trailing=new Set;flights=new Map;constructor(e,t){this.client=e,this.project=t,e.getQueryCache().subscribe(n=>{if(n.type===`removed`){this.trailing.delete(n.query),this.flights.delete(n.query);return}if(!(n.query.queryKey[0]!==t||n.query.queryKey[1]!==`reports`)){if(n.type===`updated`&&n.action.type===`fetch`&&this.flights.set(n.query,this.metadata),n.query.state.fetchStatus===`idle`&&this.flights.has(n.query)){let e=this.flights.get(n.query);this.flights.delete(n.query),e!==this.metadata&&String(n.query.queryKey[2]??``).trim()===``&&this.client.setQueryData(n.query.queryKey,t=>t&&{...t,pages:t.pages.map(t=>this.patch(t,e))})}!this.trailing.has(n.query)||n.query.state.fetchStatus!==`idle`||(this.trailing.delete(n.query),queueMicrotask(()=>{e.invalidateQueries({queryKey:n.query.queryKey,exact:!0,refetchType:`active`},{cancelRefetch:!1})}))}})}patch(e,t=-1){return{...e,reports:e.reports.map(e=>{let n=this.patches.get(e.runId);return n&&n.version>t?{...e,taskTitle:n.value.taskTitle,taskStatus:n.value.taskStatus}:e})}}async read(e,t){for(;;){let n=this.content,r=this.metadata,i=await t();if(!(n!==this.content||e.trim()!==``&&r!==this.metadata))return e.trim()===``?this.patch(i,r):i}}receive(e,t=!1){let n=this.state;if(!n&&e.type===`snapshot`){this.state=e,this.content++,this.client.getQueryCache().findAll({queryKey:[this.project,`reports`]}).some(e=>e.state.data!==void 0)&&this.invalidate(!0);return}let r=ne(n,e);if(!r){t&&e.type===`snapshot`&&(this.content++,this.invalidate(!0));return}let{metadata:i,reset:a}=r,o=r.content||t&&e.type===`snapshot`;this.state=e,a&&this.patches.clear(),i&&this.metadata++,o&&this.content++,e.type===`metadata`&&!a&&this.patchCaches(e);let s=o||i&&e.type!==`metadata`;(s||i)&&this.invalidate(s)}patchCaches(e){for(let t of e.runs)this.patches.set(t.runId,{value:t,version:this.metadata});this.client.setQueriesData({queryKey:[this.project,`reports`],predicate:e=>String(e.queryKey[2]??``).trim()===``},e=>e&&{...e,pages:e.pages.map(e=>this.patch(e,this.metadata-1))})}invalidate(e){let t={queryKey:[this.project,`reports`],refetchType:`active`,...e?{}:{predicate:e=>String(e.queryKey[2]??``).trim()!==``}};for(let e of this.client.getQueryCache().findAll(t))e.state.fetchStatus===`fetching`&&this.trailing.add(e);this.client.invalidateQueries(t,{cancelRefetch:!1})}};function ie(e,t){let n=Z.get(e);n||(n=new Map,Z.set(e,n));let r=n.get(t);return r||(r=new re(e,t),n.set(t,r)),r}async function ae(e,t){let n=await l.api.v1.p[`:projectId`].reports.state.$get({param:{projectId:e}},u({signal:t}));return J.parse(await g(n,`/reports/state`))}function oe(e){let t=ie(p(),e);return(0,W.useEffect)(()=>{let n=o(`reports:project:${e}`,e=>{let n=X.safeParse(e);n.success&&t.receive(n.data,n.data.type===`snapshot`)}),r,i,a=()=>{if(c()===`finite`&&!r){i=new AbortController;let n=i.signal;ae(e,n).then(e=>{n.aborted||t.receive({type:`snapshot`,...e})}).catch(()=>void 0),r=s({path:`/api/v1/p/${encodeURIComponent(e)}/reports/state`,intervalMs:5e3},(e,n)=>{let r=J.safeParse(e);!n&&r.success&&t.receive({type:`snapshot`,...r.data})})}else c()!==`finite`&&(i?.abort(),r?.(),r=void 0)};a();let l=d(a);return()=>{l(),i?.abort(),r?.(),n()}},[t,e]),t}async function se(e,t,n,r){let i=await l.api.v1.p[`:projectId`].reports.$get({param:{projectId:e},query:{q:t.slice(0,G),...n?{before:n}:{}}},u(r?{signal:r}:void 0));return q.parse(await g(i,`/reports`))}function ce(e){let t=r(),n=oe(t);return h({queryKey:[t,`reports`,e],initialPageParam:void 0,queryFn:({pageParam:r,signal:i})=>n.read(e,()=>se(t,e,r,i)),getNextPageParam:e=>e.nextCursor??void 0,staleTime:0,refetchOnWindowFocus:!0})}var Q=n(),$=new Map;function le(e){let t=z(),[n,r]=(0,W.useState)(!1);return(0,W.useLayoutEffect)(()=>{let n=e.current;if(!n)return;let i=e=>{r(e>0?e>=660:t)};if(i(n.getBoundingClientRect().width),typeof ResizeObserver!=`function`)return;let a=new ResizeObserver(e=>{let t=e[0]?.contentRect.width??n.getBoundingClientRect().width;i(t)});return a.observe(n),()=>a.disconnect()},[e,t]),n}function ue(){let e=T(),t=E(),[n,r]=I(),a=(n.get(`q`)??``).slice(0,G),o=ce(a),s=(0,W.useRef)(null),c=(0,W.useRef)(null),l=(0,W.useRef)(``),u=e.pathname+e.search,d=o.data?.pages.flatMap(e=>e.reports)??[],f=e=>{$.set(u,{scroll:c.current?.scrollTop??0,row:e,pages:o.data?.pages.length??1})},[p,m]=(0,W.useState)(null),h=le(s);(0,W.useLayoutEffect)(()=>{if(!o.data||l.current===u)return;let n=$.get(u),r=e.state?.filesRestoreKey===u;if(!n||!c.current||t!==`POP`&&!r){l.current=u;return}let i=c.current.querySelector(`[data-report-id="${n.row}"]`);if(o.isFetchNextPageError){l.current=u,c.current.scrollTop=0;return}if((!i||o.data.pages.length<n.pages)&&o.hasNextPage){o.isFetchingNextPage||o.fetchNextPage();return}l.current=u,c.current.scrollTop=i?n.scroll:0,i?.focus({preventScroll:!0})},[u,o.data,o.hasNextPage,o.isFetchingNextPage,o.isFetchNextPageError,o.fetchNextPage,e.state,t]);let g=t=>r(n=>(t?n.set(`q`,t.slice(0,G)):n.delete(`q`),$.delete(e.pathname+`?`+n.toString()),n)),_=d.find(e=>e.id===p)??d[0]??null,v=o.isPending?`full`:j(d.length);return(0,Q.jsx)(M,{route:`reports`,density:v,fillHeight:!0,bodyClassName:`gap-4`,header:{title:`Reports`,subtitle:`Published HTML snapshots from tasks in this project.`},children:(0,Q.jsxs)(`div`,{ref:s,"data-slot":`reports-content`,className:`flex min-h-0 min-w-0 flex-1 flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`relative w-full shrink-0`,children:[(0,Q.jsx)(D,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,Q.jsx)(R,{maxLength:G,"aria-label":`Search reports`,placeholder:`Search reports or source tasks…`,value:a,onChange:e=>g(e.target.value),className:`h-10 w-full rounded-lg border-border bg-card pl-9 text-sm max-md:h-11`})]}),o.isPending?(0,Q.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(`p`,{role:`status`,className:`py-4 text-sm text-muted-foreground`,children:`Loading reports…`})}):o.isError&&d.length===0?(0,Q.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-3 rounded-xl border border-border bg-card p-5`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Could not load reports`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o.error.message}),(0,Q.jsx)(k,{variant:`outline`,className:`min-h-11`,onClick:()=>void o.refetch(),children:`Retry`})]})}):d.length===0?(0,Q.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(F,{icon:(0,Q.jsx)(V,{}),title:a?`No matching reports`:`No published reports yet`,description:a?`Try a different keyword or clear the search filter.`:(0,Q.jsxs)(Q.Fragment,{children:[`Publish an HTML snapshot with`,` `,(0,Q.jsxs)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground`,children:[B(),` artifact publish`]}),` `,`to list it here.`]}),actions:a?(0,Q.jsx)(k,{"data-slot":`reports-clear-search`,variant:`outline`,className:`min-h-11`,onClick:()=>g(``),children:`Clear search`}):(0,Q.jsx)(k,{variant:`outline`,className:`min-h-11`,asChild:!0,children:(0,Q.jsx)(A,{to:`/new`,children:`Start a task`})})})}):(0,Q.jsx)(P,{list:(0,Q.jsxs)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1.5`,"aria-label":`Reports`,children:d.map(e=>{let t=_?.id===e.id;return(0,Q.jsxs)(`li`,{"data-slot":`report-row`,"data-selected":h&&t?`true`:void 0,className:i(`reports-row flex items-center gap-3 rounded-xl border border-border bg-card px-4 py-3 transition-colors`,h&&t&&`border-accent-strong/60 bg-sidebar-row-selected/40`),children:[(0,Q.jsx)(V,{"aria-hidden":`true`,className:`reports-icon mt-0.5 size-4 shrink-0 self-start text-accent-text`}),(0,Q.jsxs)(`div`,{className:`reports-lines flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Q.jsx)(`h2`,{className:`flex min-w-0 text-[14px] leading-5 font-semibold text-foreground`,title:H(e),children:(0,Q.jsx)(A,{"data-report-id":e.id,className:`reports-open text-foreground no-underline`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:u,filesRestoreKey:u},onClick:()=>f(e.id),children:(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:H(e)})})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-xs leading-4 text-muted-foreground`,children:[(0,Q.jsx)(A,{className:`reports-task min-w-0 truncate text-xs text-muted-foreground no-underline hover:text-foreground hover:underline`,to:`/tasks/${e.runId}`,children:(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,title:e.taskTitle,children:e.taskTitle})}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,Q.jsx)(L,{className:`shrink-0`,iso:e.createdAt,prefix:`Published · `})]})]}),h?(0,Q.jsx)(`button`,{type:`button`,"data-slot":`report-preview-select`,"aria-label":`Preview ${H(e)}`,"aria-pressed":t,onClick:()=>m(e.id),className:`reports-preview-btn inline-flex min-h-8 min-w-8 shrink-0 items-center justify-center gap-1 rounded-md border border-border bg-background px-2 py-1.5 text-xs text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,children:(0,Q.jsx)(O,{"aria-hidden":`true`,className:`size-3.5`})}):(0,Q.jsx)(te,{"aria-hidden":`true`,"data-slot":`report-open-cue`,className:`reports-cue size-4 shrink-0 text-muted-foreground`})]},e.id)})}),o.hasNextPage?(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(k,{variant:`outline`,className:`min-h-11`,disabled:o.isFetchingNextPage,onClick:()=>void o.fetchNextPage(),children:`Load more reports`})}):null,v===`sparse`?(0,Q.jsx)(N,{summary:`${d.length} published ${d.length===1?`report`:`reports`}. Select a row to open full screen or preview beside the list.`}):null]}),detail:h&&_?(0,Q.jsx)(de,{report:_,restoreKey:u,onOpenReader:()=>f(_.id)}):null})]})})}function de({report:e,restoreKey:t,onOpenReader:n}){let r=(0,W.useContext)(m)!==void 0;return(0,Q.jsxs)(`section`,{"data-slot":`reports-preview-pane`,"aria-label":`Preview of ${H(e)}`,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border bg-card`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h2`,{className:`truncate text-sm font-semibold text-foreground`,children:H(e)}),(0,Q.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-muted-foreground`,children:[e.taskTitle,` · `,(0,Q.jsx)(L,{iso:e.createdAt,prefix:`Published · `})]})]}),(0,Q.jsx)(k,{variant:`outline`,size:`sm`,asChild:!0,className:`h-auto min-h-8 shrink-0 py-1.5`,children:(0,Q.jsxs)(A,{"data-slot":`reports-preview-open`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:t,filesRestoreKey:t},onClick:n,children:[`Open reader`,(0,Q.jsx)(ee,{"aria-hidden":`true`,className:`size-3.5`})]})})]}),r?(0,Q.jsx)(fe,{report:e}):(0,Q.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-xs text-muted-foreground`,children:`Open reader to view this HTML report.`})]})}function fe({report:e}){let t=a(e.runId,e.id);if(t.isPending)return(0,Q.jsx)(`p`,{role:`status`,className:`p-6 text-xs text-muted-foreground`,children:`Loading preview…`});if(t.isError)return(0,Q.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-2 p-6 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`p`,{className:`font-medium text-foreground`,children:`Could not load report preview`}),(0,Q.jsx)(`p`,{children:t.error.message}),(0,Q.jsx)(k,{variant:`outline`,size:`sm`,onClick:()=>void t.refetch(),children:`Retry`})]});let n=t.data;return!n||n.type!==`file`||n.binary||n.content===void 0?(0,Q.jsx)(`p`,{className:`p-6 text-xs text-muted-foreground`,children:`Preview unavailable for this artifact.`}):(0,Q.jsx)(U,{html:n.content,title:H(e),className:`min-h-0 flex-1`})}export{ue as ReportsRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r,t as i}from"./utils-DSMR_WLb.js";import{N as a,Rt as o,ct as s}from"./queries-D0v1z40Y.js";import{Hr as c,In as l,Ln as u,Wr as d,br as f,hi as p,pi as m,ri as h,zn as g}from"./toaster-DMfiAEnw.js";import{B as _,F as v,I as y,J as b,N as x,W as S,Y as C,z as w}from"./live-protocol-DMhTnCmf.js";import{f as T,m as E}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{X as D}from"./design-icons-CzEoMH9c.js";import{t as ee}from"./arrow-up-right-DKGzsMqY.js";import{t as te}from"./chevron-right-BENZ-1ZN.js";import{t as O}from"./eye-B8okNWXU.js";import{t as k}from"./button-B7MKxYjT.js";import{t as A}from"./project-router-BifLGgRR.js";import{d as j,l as M,n as N,r as P,t as F}from"./page-shell-7pLJMOgh.js";import{t as I}from"./use-search-params-writer-ClMScnNe.js";import{Mn as L,Zn as R,Zt as z,mn as B,or as V}from"./index-DEWnkuj6.js";import{t as H}from"./report-title-D4Mbu2Er.js";import{t as U}from"./html-report-frame-DkHr39E2.js";var W=e(t(),1),G=1e3,K=S().min(1).max(1024);_({q:S().max(G).optional(),before:K.optional(),limit:S().regex(/^(?:[1-9]|[1-9][0-9]|100)$/).transform(Number).optional()}).strict();var q=_({reports:x(_({id:b(),runId:b(),name:S(),title:S(),createdAt:C(),size:w().int().nonnegative(),taskTitle:S(),taskStatus:f}).strict()),nextCursor:K.nullable(),total:w().int().nonnegative()}).strict(),J=_({epoch:b(),generation:w().int().nonnegative(),metadataGeneration:w().int().nonnegative()}).strict(),Y=_({runId:b(),taskTitle:S(),taskStatus:f}).strict(),X=v(`type`,[J.extend({type:y(`snapshot`)}),J.extend({type:y(`content`)}),J.extend({type:y(`metadata`),runs:x(Y)})]),Z=new WeakMap;function ne(e,t){if(!e)return{content:t.type===`content`,metadata:t.type===`metadata`,reset:!1};if(e.epoch!==t.epoch)return{content:!0,metadata:!0,reset:!0};if(!(t.generation<e.generation||t.metadataGeneration<e.metadataGeneration)&&!(e.generation===t.generation&&e.metadataGeneration===t.metadataGeneration))return{content:t.generation!==e.generation,metadata:t.metadataGeneration!==e.metadataGeneration,reset:!1}}var re=class{client;project;state;content=0;metadata=0;patches=new Map;trailing=new Set;flights=new Map;constructor(e,t){this.client=e,this.project=t,e.getQueryCache().subscribe(n=>{if(n.type===`removed`){this.trailing.delete(n.query),this.flights.delete(n.query);return}if(!(n.query.queryKey[0]!==t||n.query.queryKey[1]!==`reports`)){if(n.type===`updated`&&n.action.type===`fetch`&&this.flights.set(n.query,this.metadata),n.query.state.fetchStatus===`idle`&&this.flights.has(n.query)){let e=this.flights.get(n.query);this.flights.delete(n.query),e!==this.metadata&&String(n.query.queryKey[2]??``).trim()===``&&this.client.setQueryData(n.query.queryKey,t=>t&&{...t,pages:t.pages.map(t=>this.patch(t,e))})}!this.trailing.has(n.query)||n.query.state.fetchStatus!==`idle`||(this.trailing.delete(n.query),queueMicrotask(()=>{e.invalidateQueries({queryKey:n.query.queryKey,exact:!0,refetchType:`active`},{cancelRefetch:!1})}))}})}patch(e,t=-1){return{...e,reports:e.reports.map(e=>{let n=this.patches.get(e.runId);return n&&n.version>t?{...e,taskTitle:n.value.taskTitle,taskStatus:n.value.taskStatus}:e})}}async read(e,t){for(;;){let n=this.content,r=this.metadata,i=await t();if(!(n!==this.content||e.trim()!==``&&r!==this.metadata))return e.trim()===``?this.patch(i,r):i}}receive(e,t=!1){let n=this.state;if(!n&&e.type===`snapshot`){this.state=e,this.content++,this.client.getQueryCache().findAll({queryKey:[this.project,`reports`]}).some(e=>e.state.data!==void 0)&&this.invalidate(!0);return}let r=ne(n,e);if(!r){t&&e.type===`snapshot`&&(this.content++,this.invalidate(!0));return}let{metadata:i,reset:a}=r,o=r.content||t&&e.type===`snapshot`;this.state=e,a&&this.patches.clear(),i&&this.metadata++,o&&this.content++,e.type===`metadata`&&!a&&this.patchCaches(e);let s=o||i&&e.type!==`metadata`;(s||i)&&this.invalidate(s)}patchCaches(e){for(let t of e.runs)this.patches.set(t.runId,{value:t,version:this.metadata});this.client.setQueriesData({queryKey:[this.project,`reports`],predicate:e=>String(e.queryKey[2]??``).trim()===``},e=>e&&{...e,pages:e.pages.map(e=>this.patch(e,this.metadata-1))})}invalidate(e){let t={queryKey:[this.project,`reports`],refetchType:`active`,...e?{}:{predicate:e=>String(e.queryKey[2]??``).trim()!==``}};for(let e of this.client.getQueryCache().findAll(t))e.state.fetchStatus===`fetching`&&this.trailing.add(e);this.client.invalidateQueries(t,{cancelRefetch:!1})}};function ie(e,t){let n=Z.get(e);n||(n=new Map,Z.set(e,n));let r=n.get(t);return r||(r=new re(e,t),n.set(t,r)),r}async function ae(e,t){let n=await l.api.v1.p[`:projectId`].reports.state.$get({param:{projectId:e}},u({signal:t}));return J.parse(await g(n,`/reports/state`))}function oe(e){let t=ie(p(),e);return(0,W.useEffect)(()=>{let n=o(`reports:project:${e}`,e=>{let n=X.safeParse(e);n.success&&t.receive(n.data,n.data.type===`snapshot`)}),r,i,a=()=>{if(c()===`finite`&&!r){i=new AbortController;let n=i.signal;ae(e,n).then(e=>{n.aborted||t.receive({type:`snapshot`,...e})}).catch(()=>void 0),r=s({path:`/api/v1/p/${encodeURIComponent(e)}/reports/state`,intervalMs:5e3},(e,n)=>{let r=J.safeParse(e);!n&&r.success&&t.receive({type:`snapshot`,...r.data})})}else c()!==`finite`&&(i?.abort(),r?.(),r=void 0)};a();let l=d(a);return()=>{l(),i?.abort(),r?.(),n()}},[t,e]),t}async function se(e,t,n,r){let i=await l.api.v1.p[`:projectId`].reports.$get({param:{projectId:e},query:{q:t.slice(0,G),...n?{before:n}:{}}},u(r?{signal:r}:void 0));return q.parse(await g(i,`/reports`))}function ce(e){let t=r(),n=oe(t);return h({queryKey:[t,`reports`,e],initialPageParam:void 0,queryFn:({pageParam:r,signal:i})=>n.read(e,()=>se(t,e,r,i)),getNextPageParam:e=>e.nextCursor??void 0,staleTime:0,refetchOnWindowFocus:!0})}var Q=n(),$=new Map;function le(e){let t=z(),[n,r]=(0,W.useState)(!1);return(0,W.useLayoutEffect)(()=>{let n=e.current;if(!n)return;let i=e=>{r(e>0?e>=660:t)};if(i(n.getBoundingClientRect().width),typeof ResizeObserver!=`function`)return;let a=new ResizeObserver(e=>{let t=e[0]?.contentRect.width??n.getBoundingClientRect().width;i(t)});return a.observe(n),()=>a.disconnect()},[e,t]),n}function ue(){let e=T(),t=E(),[n,r]=I(),a=(n.get(`q`)??``).slice(0,G),o=ce(a),s=(0,W.useRef)(null),c=(0,W.useRef)(null),l=(0,W.useRef)(``),u=e.pathname+e.search,d=o.data?.pages.flatMap(e=>e.reports)??[],f=e=>{$.set(u,{scroll:c.current?.scrollTop??0,row:e,pages:o.data?.pages.length??1})},[p,m]=(0,W.useState)(null),h=le(s);(0,W.useLayoutEffect)(()=>{if(!o.data||l.current===u)return;let n=$.get(u),r=e.state?.filesRestoreKey===u;if(!n||!c.current||t!==`POP`&&!r){l.current=u;return}let i=c.current.querySelector(`[data-report-id="${n.row}"]`);if(o.isFetchNextPageError){l.current=u,c.current.scrollTop=0;return}if((!i||o.data.pages.length<n.pages)&&o.hasNextPage){o.isFetchingNextPage||o.fetchNextPage();return}l.current=u,c.current.scrollTop=i?n.scroll:0,i?.focus({preventScroll:!0})},[u,o.data,o.hasNextPage,o.isFetchingNextPage,o.isFetchNextPageError,o.fetchNextPage,e.state,t]);let g=t=>r(n=>(t?n.set(`q`,t.slice(0,G)):n.delete(`q`),$.delete(e.pathname+`?`+n.toString()),n)),_=d.find(e=>e.id===p)??d[0]??null,v=o.isPending?`full`:j(d.length);return(0,Q.jsx)(M,{route:`reports`,density:v,fillHeight:!0,bodyClassName:`gap-4`,header:{title:`Reports`,subtitle:`Published HTML snapshots from tasks in this project.`},children:(0,Q.jsxs)(`div`,{ref:s,"data-slot":`reports-content`,className:`flex min-h-0 min-w-0 flex-1 flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`relative w-full shrink-0`,children:[(0,Q.jsx)(D,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,Q.jsx)(R,{maxLength:G,"aria-label":`Search reports`,placeholder:`Search reports or source tasks…`,value:a,onChange:e=>g(e.target.value),className:`h-10 w-full rounded-lg border-border bg-card pl-9 text-sm max-md:h-11`})]}),o.isPending?(0,Q.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(`p`,{role:`status`,className:`py-4 text-sm text-muted-foreground`,children:`Loading reports…`})}):o.isError&&d.length===0?(0,Q.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-3 rounded-xl border border-border bg-card p-5`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Could not load reports`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o.error.message}),(0,Q.jsx)(k,{variant:`outline`,className:`min-h-11`,onClick:()=>void o.refetch(),children:`Retry`})]})}):d.length===0?(0,Q.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(F,{icon:(0,Q.jsx)(V,{}),title:a?`No matching reports`:`No published reports yet`,description:a?`Try a different keyword or clear the search filter.`:(0,Q.jsxs)(Q.Fragment,{children:[`Publish an HTML snapshot with`,` `,(0,Q.jsxs)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground`,children:[B(),` artifact publish`]}),` `,`to list it here.`]}),actions:a?(0,Q.jsx)(k,{"data-slot":`reports-clear-search`,variant:`outline`,className:`min-h-11`,onClick:()=>g(``),children:`Clear search`}):(0,Q.jsx)(k,{variant:`outline`,className:`min-h-11`,asChild:!0,children:(0,Q.jsx)(A,{to:`/new`,children:`Start a task`})})})}):(0,Q.jsx)(P,{list:(0,Q.jsxs)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1.5`,"aria-label":`Reports`,children:d.map(e=>{let t=_?.id===e.id;return(0,Q.jsxs)(`li`,{"data-slot":`report-row`,"data-selected":h&&t?`true`:void 0,className:i(`reports-row flex items-center gap-3 rounded-xl border border-border bg-card px-4 py-3 transition-colors`,h&&t&&`border-accent-strong/60 bg-sidebar-row-selected/40`),children:[(0,Q.jsx)(V,{"aria-hidden":`true`,className:`reports-icon mt-0.5 size-4 shrink-0 self-start text-accent-text`}),(0,Q.jsxs)(`div`,{className:`reports-lines flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Q.jsx)(`h2`,{className:`flex min-w-0 text-[14px] leading-5 font-semibold text-foreground`,title:H(e),children:(0,Q.jsx)(A,{"data-report-id":e.id,className:`reports-open text-foreground no-underline`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:u,filesRestoreKey:u},onClick:()=>f(e.id),children:(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:H(e)})})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-xs leading-4 text-muted-foreground`,children:[(0,Q.jsx)(A,{className:`reports-task min-w-0 truncate text-xs text-muted-foreground no-underline hover:text-foreground hover:underline`,to:`/tasks/${e.runId}`,children:(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,title:e.taskTitle,children:e.taskTitle})}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,Q.jsx)(L,{className:`shrink-0`,iso:e.createdAt,prefix:`Published · `})]})]}),h?(0,Q.jsx)(`button`,{type:`button`,"data-slot":`report-preview-select`,"aria-label":`Preview ${H(e)}`,"aria-pressed":t,onClick:()=>m(e.id),className:`reports-preview-btn inline-flex min-h-8 min-w-8 shrink-0 items-center justify-center gap-1 rounded-md border border-border bg-background px-2 py-1.5 text-xs text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,children:(0,Q.jsx)(O,{"aria-hidden":`true`,className:`size-3.5`})}):(0,Q.jsx)(te,{"aria-hidden":`true`,"data-slot":`report-open-cue`,className:`reports-cue size-4 shrink-0 text-muted-foreground`})]},e.id)})}),o.hasNextPage?(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(k,{variant:`outline`,className:`min-h-11`,disabled:o.isFetchingNextPage,onClick:()=>void o.fetchNextPage(),children:`Load more reports`})}):null,v===`sparse`?(0,Q.jsx)(N,{summary:`${d.length} published ${d.length===1?`report`:`reports`}. Select a row to open full screen or preview beside the list.`}):null]}),detail:h&&_?(0,Q.jsx)(de,{report:_,restoreKey:u,onOpenReader:()=>f(_.id)}):null})]})})}function de({report:e,restoreKey:t,onOpenReader:n}){let r=(0,W.useContext)(m)!==void 0;return(0,Q.jsxs)(`section`,{"data-slot":`reports-preview-pane`,"aria-label":`Preview of ${H(e)}`,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border bg-card`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h2`,{className:`truncate text-sm font-semibold text-foreground`,children:H(e)}),(0,Q.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-muted-foreground`,children:[e.taskTitle,` · `,(0,Q.jsx)(L,{iso:e.createdAt,prefix:`Published · `})]})]}),(0,Q.jsx)(k,{variant:`outline`,size:`sm`,asChild:!0,className:`h-auto min-h-8 shrink-0 py-1.5`,children:(0,Q.jsxs)(A,{"data-slot":`reports-preview-open`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:t,filesRestoreKey:t},onClick:n,children:[`Open reader`,(0,Q.jsx)(ee,{"aria-hidden":`true`,className:`size-3.5`})]})})]}),r?(0,Q.jsx)(fe,{report:e}):(0,Q.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-xs text-muted-foreground`,children:`Open reader to view this HTML report.`})]})}function fe({report:e}){let t=a(e.runId,e.id);if(t.isPending)return(0,Q.jsx)(`p`,{role:`status`,className:`p-6 text-xs text-muted-foreground`,children:`Loading preview…`});if(t.isError)return(0,Q.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-2 p-6 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`p`,{className:`font-medium text-foreground`,children:`Could not load report preview`}),(0,Q.jsx)(`p`,{children:t.error.message}),(0,Q.jsx)(k,{variant:`outline`,size:`sm`,onClick:()=>void t.refetch(),children:`Retry`})]});let n=t.data;return!n||n.type!==`file`||n.binary||n.content===void 0?(0,Q.jsx)(`p`,{className:`p-6 text-xs text-muted-foreground`,children:`Preview unavailable for this artifact.`}):(0,Q.jsx)(U,{html:n.content,title:H(e),className:`min-h-0 flex-1`})}export{ue as ReportsRoute};
@@ -1 +1 @@
1
- import{t as e}from"./react-runtime-CCIEwYL0.js";import{Gt as t,It as n,dn as r}from"./queries-D0v1z40Y.js";import{hi as i,n as a,sn as o}from"./toaster-DMfiAEnw.js";import{n as s}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{k as c}from"./design-icons-CzEoMH9c.js";import{t as l}from"./button-B7MKxYjT.js";import{t as u}from"./switch-DKqVf8-p.js";import{t as d}from"./centered-state-V15AR_qo.js";import{pn as f}from"./index-01bdo9g3.js";import{t as p}from"./settings-select-CCIMGnyA.js";import{n as m}from"./saved-draft-BwzBc-_Y.js";import{t as h}from"./save-cue-Cd3ZAPBS.js";import{n as g,t as _}from"./settings-field-DP9sYv5a.js";var v=e(),y=1,b=1,x=60,S=256;function C(){let e=n();return e.isPending?(0,v.jsx)(`p`,{"data-slot":`resources-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading resource settings…`}):e.isError?(0,v.jsx)(d,{icon:(0,v.jsx)(c,{}),tone:`danger`,title:`Resource settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,v.jsx)(w,{config:e.data})}function w({config:e}){let n=i(),s=r({mutationFn:e=>o(e),onSuccess:e=>n.setQueryData(t.config,e),onError:e=>a(e.message,{tone:`danger`})}),[c,l]=m(e.resources.memoryLimitMb?String(e.resources.memoryLimitMb):``),d=e.resources.monitoringWakeIntervalMinutes??null,[f,p]=m(d===null?`park`:`interval`),[h,_]=m(String(d??5)),y=Number(h),C=!Number.isInteger(y)||y<b||y>x,w=f===`park`?d===null:!C&&d===y,k=f===`interval`&&C,j=()=>s.mutate({resources:{monitoringWakeIntervalMinutes:f===`park`?null:y}},{onSuccess:()=>a(f===`park`?`Monitoring will stay parked`:`Monitoring will re-check every ${y} minutes`)}),M=e.resources.autoResumeOnUsageLimit??!0,N=e=>s.mutate({resources:{autoResumeOnUsageLimit:e}},{onSuccess:()=>a(e?`Tasks stopped by a usage limit will resume themselves`:`Tasks stopped by a usage limit will stay failed`)}),P=c.trim()===``?0:Number(c),F=c.trim()!==``&&(!Number.isInteger(P)||P<S),I=(e.resources.memoryLimitMb??0)===(F?-1:P),L=()=>s.mutate({resources:{memoryLimitMb:P===0?null:P}},{onSuccess:()=>a(P===0?`Memory limit cleared`:`Memory limit set to ${P} MiB`)}),R=e.composerDefaults??{autonomous:null,worktree:null,inheritedAutonomous:`source-dependent`,inheritedWorktree:!0};return(0,v.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,v.jsx)(T,{maxParallel:e.resources.maxParallel,onSelect:e=>s.mutate({resources:{maxParallel:e}}),disabled:s.isPending}),(0,v.jsx)(E,{maxParallel:e.resources.maxParallel,maxMonitoringSessions:e.resources.maxMonitoringSessions,onSelect:e=>s.mutate({resources:{maxMonitoringSessions:e}}),disabled:s.isPending}),(0,v.jsx)(D,{wakeMode:f,setWakeMode:p,wakeInterval:h,setWakeInterval:_,showInvalid:k,wakeSaved:w,saveWake:j,saveIsPending:s.isPending}),(0,v.jsx)(g,{title:`Auto-resume after a usage limit`,hint:`Resumes eligible tasks at the reset time the provider reports. Saves automatically.`,children:(0,v.jsx)(u,{"aria-label":`Auto-resume after a usage limit`,"data-slot":`resources-auto-resume`,checked:M,disabled:s.isPending,onCheckedChange:N})}),(0,v.jsx)(O,{memory:c,setMemory:l,memoryInvalid:F,memorySaved:I,saveMemory:L,saveIsPending:s.isPending}),(0,v.jsx)(A,{composerDefaults:R,saveComposerDefault:(e,t)=>s.mutate({composerDefaults:{[e]:t===`inherit`?null:t===`on`}}),saveIsPending:s.isPending})]})}function T({maxParallel:e,onSelect:t,disabled:n}){return(0,v.jsxs)(g,{title:`Max parallel tasks`,hint:`Limits how many tasks run at once. Saves automatically.`,children:[(0,v.jsx)(p,{"aria-label":`Max parallel tasks`,"data-slot":`resources-max-parallel`,value:e,disabled:n,onChange:e=>t(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+y).map(e=>(0,v.jsx)(`option`,{value:e,children:e},e))}),(0,v.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Need a different limit for one project?`,` `,(0,v.jsx)(s,{to:`/settings/global/projects`,"data-slot":`resources-project-limits-link`,className:`font-medium text-link-foreground hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:`Configure per-project limits`}),`.`]})]})}function E({maxParallel:e,maxMonitoringSessions:t,onSelect:n,disabled:r}){return(0,v.jsxs)(g,{title:`Extra monitoring sessions`,hint:`Extra slots reserved for monitoring sessions. Saves automatically.`,children:[(0,v.jsx)(p,{"aria-label":`Extra monitoring sessions`,"data-slot":`resources-max-monitoring`,value:t??2,disabled:r,onChange:e=>n(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,v.jsx)(`option`,{value:t,children:t},t))}),(0,v.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Capacity: `,e,` active + `,t??2,` monitoring. 0 shares the active slots.`]})]})}function D({wakeMode:e,setWakeMode:t,wakeInterval:n,setWakeInterval:r,showInvalid:i,wakeSaved:a,saveWake:o,saveIsPending:s}){return f(!a),(0,v.jsxs)(g,{title:`Monitoring wake-up`,hint:`Wake monitoring sessions periodically.`,children:[(0,v.jsxs)(`div`,{"data-reports-dirty":``,className:`settings-resource-controls flex flex-wrap items-center gap-2`,children:[(0,v.jsx)(u,{"aria-label":`Monitoring wake-up`,"data-slot":`resources-monitoring-wake-mode`,checked:e===`interval`,disabled:s,onCheckedChange:e=>t(e?`interval`:`park`)}),e===`interval`?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`label`,{htmlFor:`monitoring-wake-interval`,className:`w-full ${_}`,children:`Wake interval`}),(0,v.jsx)(`input`,{id:`monitoring-wake-interval`,type:`number`,min:b,max:x,"aria-label":`Wake interval in minutes`,"data-slot":`resources-monitoring-wake-interval`,value:n,disabled:s,onChange:e=>r(e.target.value),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`}),(0,v.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`minutes`})]}):null,(0,v.jsx)(h,{show:a&&!i&&!s,children:(0,v.jsx)(l,{type:`button`,variant:`primary`,size:`sm`,"data-action":`resources-save-monitoring-wake`,disabled:a||i||s,onClick:o,children:`Save`})})]}),i?(0,v.jsx)(`p`,{"data-slot":`resources-monitoring-wake-invalid`,className:`text-xs text-danger`,children:`Enter a whole number from 1 to 60 minutes.`}):null]})}function O({memory:e,setMemory:t,memoryInvalid:n,memorySaved:r,saveMemory:i,saveIsPending:a}){return f(!r),(0,v.jsxs)(g,{title:`Per-task memory limit`,hint:`Applies to newly started tasks. Leave blank for no limit.`,children:[(0,v.jsxs)(`div`,{"data-reports-dirty":``,className:`settings-resource-controls flex flex-wrap items-center gap-2`,children:[(0,v.jsx)(`input`,{type:`number`,inputMode:`numeric`,min:S,step:256,"aria-label":`Per-task memory limit in MiB`,"data-slot":`resources-memory-limit`,value:e,disabled:a,placeholder:`no limit`,onChange:e=>t(e.target.value),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`}),(0,v.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`MiB`}),(0,v.jsx)(h,{show:r&&!n&&!a,children:(0,v.jsx)(l,{type:`button`,variant:`primary`,size:`sm`,"data-action":`resources-save-memory`,disabled:r||n||a,onClick:i,children:`Save`})})]}),n?(0,v.jsxs)(`p`,{"data-slot":`resources-memory-invalid`,className:`text-xs text-danger`,children:[`Enter a whole number of at least `,S,` MiB, or leave empty for no limit.`]}):null]})}function k(e){return e===null?`inherit`:e?`on`:`off`}function A({composerDefaults:e,saveComposerDefault:t,saveIsPending:n}){return(0,v.jsxs)(g,{title:`New task defaults`,hint:`Apply to new tasks unless overridden.`,children:[(0,v.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,"data-slot":`resources-composer-defaults`,children:[(0,v.jsxs)(`label`,{className:`grid gap-1.5 text-sm sm:grid-cols-1`,children:[(0,v.jsx)(`span`,{className:_,children:`Autonomous by default`}),(0,v.jsxs)(p,{"aria-label":`Autonomous by default`,value:k(e.autonomous),disabled:n,onChange:e=>t(`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,v.jsx)(`option`,{value:`inherit`,children:`Inherit environment`}),(0,v.jsx)(`option`,{value:`on`,children:`On`}),(0,v.jsx)(`option`,{value:`off`,children:`Off`})]}),(0,v.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Inherited: `,e.inheritedAutonomous===`source-dependent`?`Source-dependent — skills on, workflows off`:e.inheritedAutonomous?`On`:`Off`]})]}),(0,v.jsxs)(`label`,{className:`grid gap-1.5 text-sm sm:grid-cols-1`,children:[(0,v.jsx)(`span`,{className:_,children:`Use a worktree by default`}),(0,v.jsxs)(p,{"aria-label":`Use a worktree by default`,value:k(e.worktree),disabled:n,onChange:e=>t(`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,v.jsx)(`option`,{value:`inherit`,children:`Inherit environment`}),(0,v.jsx)(`option`,{value:`on`,children:`On`}),(0,v.jsx)(`option`,{value:`off`,children:`Off`})]}),(0,v.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Inherited: `,e.inheritedWorktree?`On`:`Off`]})]})]}),(0,v.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Interactive skills may recommend both off. Multi-step and parallel runs remain isolated. Saves automatically.`})]})}export{C as ResourcesSection};
1
+ import{t as e}from"./react-runtime-CCIEwYL0.js";import{Gt as t,It as n,dn as r}from"./queries-D0v1z40Y.js";import{hi as i,n as a,sn as o}from"./toaster-DMfiAEnw.js";import{n as s}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{k as c}from"./design-icons-CzEoMH9c.js";import{t as l}from"./button-B7MKxYjT.js";import{t as u}from"./switch-DKqVf8-p.js";import{t as d}from"./centered-state-V15AR_qo.js";import{pn as f}from"./index-DEWnkuj6.js";import{t as p}from"./settings-select-CCIMGnyA.js";import{n as m}from"./saved-draft-BwzBc-_Y.js";import{t as h}from"./save-cue-Cd3ZAPBS.js";import{n as g,t as _}from"./settings-field-DP9sYv5a.js";var v=e(),y=1,b=1,x=60,S=256;function C(){let e=n();return e.isPending?(0,v.jsx)(`p`,{"data-slot":`resources-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading resource settings…`}):e.isError?(0,v.jsx)(d,{icon:(0,v.jsx)(c,{}),tone:`danger`,title:`Resource settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,v.jsx)(w,{config:e.data})}function w({config:e}){let n=i(),s=r({mutationFn:e=>o(e),onSuccess:e=>n.setQueryData(t.config,e),onError:e=>a(e.message,{tone:`danger`})}),[c,l]=m(e.resources.memoryLimitMb?String(e.resources.memoryLimitMb):``),d=e.resources.monitoringWakeIntervalMinutes??null,[f,p]=m(d===null?`park`:`interval`),[h,_]=m(String(d??5)),y=Number(h),C=!Number.isInteger(y)||y<b||y>x,w=f===`park`?d===null:!C&&d===y,k=f===`interval`&&C,j=()=>s.mutate({resources:{monitoringWakeIntervalMinutes:f===`park`?null:y}},{onSuccess:()=>a(f===`park`?`Monitoring will stay parked`:`Monitoring will re-check every ${y} minutes`)}),M=e.resources.autoResumeOnUsageLimit??!0,N=e=>s.mutate({resources:{autoResumeOnUsageLimit:e}},{onSuccess:()=>a(e?`Tasks stopped by a usage limit will resume themselves`:`Tasks stopped by a usage limit will stay failed`)}),P=c.trim()===``?0:Number(c),F=c.trim()!==``&&(!Number.isInteger(P)||P<S),I=(e.resources.memoryLimitMb??0)===(F?-1:P),L=()=>s.mutate({resources:{memoryLimitMb:P===0?null:P}},{onSuccess:()=>a(P===0?`Memory limit cleared`:`Memory limit set to ${P} MiB`)}),R=e.composerDefaults??{autonomous:null,worktree:null,inheritedAutonomous:`source-dependent`,inheritedWorktree:!0};return(0,v.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,v.jsx)(T,{maxParallel:e.resources.maxParallel,onSelect:e=>s.mutate({resources:{maxParallel:e}}),disabled:s.isPending}),(0,v.jsx)(E,{maxParallel:e.resources.maxParallel,maxMonitoringSessions:e.resources.maxMonitoringSessions,onSelect:e=>s.mutate({resources:{maxMonitoringSessions:e}}),disabled:s.isPending}),(0,v.jsx)(D,{wakeMode:f,setWakeMode:p,wakeInterval:h,setWakeInterval:_,showInvalid:k,wakeSaved:w,saveWake:j,saveIsPending:s.isPending}),(0,v.jsx)(g,{title:`Auto-resume after a usage limit`,hint:`Resumes eligible tasks at the reset time the provider reports. Saves automatically.`,children:(0,v.jsx)(u,{"aria-label":`Auto-resume after a usage limit`,"data-slot":`resources-auto-resume`,checked:M,disabled:s.isPending,onCheckedChange:N})}),(0,v.jsx)(O,{memory:c,setMemory:l,memoryInvalid:F,memorySaved:I,saveMemory:L,saveIsPending:s.isPending}),(0,v.jsx)(A,{composerDefaults:R,saveComposerDefault:(e,t)=>s.mutate({composerDefaults:{[e]:t===`inherit`?null:t===`on`}}),saveIsPending:s.isPending})]})}function T({maxParallel:e,onSelect:t,disabled:n}){return(0,v.jsxs)(g,{title:`Max parallel tasks`,hint:`Limits how many tasks run at once. Saves automatically.`,children:[(0,v.jsx)(p,{"aria-label":`Max parallel tasks`,"data-slot":`resources-max-parallel`,value:e,disabled:n,onChange:e=>t(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+y).map(e=>(0,v.jsx)(`option`,{value:e,children:e},e))}),(0,v.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Need a different limit for one project?`,` `,(0,v.jsx)(s,{to:`/settings/global/projects`,"data-slot":`resources-project-limits-link`,className:`font-medium text-link-foreground hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:`Configure per-project limits`}),`.`]})]})}function E({maxParallel:e,maxMonitoringSessions:t,onSelect:n,disabled:r}){return(0,v.jsxs)(g,{title:`Extra monitoring sessions`,hint:`Extra slots reserved for monitoring sessions. Saves automatically.`,children:[(0,v.jsx)(p,{"aria-label":`Extra monitoring sessions`,"data-slot":`resources-max-monitoring`,value:t??2,disabled:r,onChange:e=>n(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,v.jsx)(`option`,{value:t,children:t},t))}),(0,v.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Capacity: `,e,` active + `,t??2,` monitoring. 0 shares the active slots.`]})]})}function D({wakeMode:e,setWakeMode:t,wakeInterval:n,setWakeInterval:r,showInvalid:i,wakeSaved:a,saveWake:o,saveIsPending:s}){return f(!a),(0,v.jsxs)(g,{title:`Monitoring wake-up`,hint:`Wake monitoring sessions periodically.`,children:[(0,v.jsxs)(`div`,{"data-reports-dirty":``,className:`settings-resource-controls flex flex-wrap items-center gap-2`,children:[(0,v.jsx)(u,{"aria-label":`Monitoring wake-up`,"data-slot":`resources-monitoring-wake-mode`,checked:e===`interval`,disabled:s,onCheckedChange:e=>t(e?`interval`:`park`)}),e===`interval`?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`label`,{htmlFor:`monitoring-wake-interval`,className:`w-full ${_}`,children:`Wake interval`}),(0,v.jsx)(`input`,{id:`monitoring-wake-interval`,type:`number`,min:b,max:x,"aria-label":`Wake interval in minutes`,"data-slot":`resources-monitoring-wake-interval`,value:n,disabled:s,onChange:e=>r(e.target.value),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`}),(0,v.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`minutes`})]}):null,(0,v.jsx)(h,{show:a&&!i&&!s,children:(0,v.jsx)(l,{type:`button`,variant:`primary`,size:`sm`,"data-action":`resources-save-monitoring-wake`,disabled:a||i||s,onClick:o,children:`Save`})})]}),i?(0,v.jsx)(`p`,{"data-slot":`resources-monitoring-wake-invalid`,className:`text-xs text-danger`,children:`Enter a whole number from 1 to 60 minutes.`}):null]})}function O({memory:e,setMemory:t,memoryInvalid:n,memorySaved:r,saveMemory:i,saveIsPending:a}){return f(!r),(0,v.jsxs)(g,{title:`Per-task memory limit`,hint:`Applies to newly started tasks. Leave blank for no limit.`,children:[(0,v.jsxs)(`div`,{"data-reports-dirty":``,className:`settings-resource-controls flex flex-wrap items-center gap-2`,children:[(0,v.jsx)(`input`,{type:`number`,inputMode:`numeric`,min:S,step:256,"aria-label":`Per-task memory limit in MiB`,"data-slot":`resources-memory-limit`,value:e,disabled:a,placeholder:`no limit`,onChange:e=>t(e.target.value),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`}),(0,v.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`MiB`}),(0,v.jsx)(h,{show:r&&!n&&!a,children:(0,v.jsx)(l,{type:`button`,variant:`primary`,size:`sm`,"data-action":`resources-save-memory`,disabled:r||n||a,onClick:i,children:`Save`})})]}),n?(0,v.jsxs)(`p`,{"data-slot":`resources-memory-invalid`,className:`text-xs text-danger`,children:[`Enter a whole number of at least `,S,` MiB, or leave empty for no limit.`]}):null]})}function k(e){return e===null?`inherit`:e?`on`:`off`}function A({composerDefaults:e,saveComposerDefault:t,saveIsPending:n}){return(0,v.jsxs)(g,{title:`New task defaults`,hint:`Apply to new tasks unless overridden.`,children:[(0,v.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,"data-slot":`resources-composer-defaults`,children:[(0,v.jsxs)(`label`,{className:`grid gap-1.5 text-sm sm:grid-cols-1`,children:[(0,v.jsx)(`span`,{className:_,children:`Autonomous by default`}),(0,v.jsxs)(p,{"aria-label":`Autonomous by default`,value:k(e.autonomous),disabled:n,onChange:e=>t(`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,v.jsx)(`option`,{value:`inherit`,children:`Inherit environment`}),(0,v.jsx)(`option`,{value:`on`,children:`On`}),(0,v.jsx)(`option`,{value:`off`,children:`Off`})]}),(0,v.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Inherited: `,e.inheritedAutonomous===`source-dependent`?`Source-dependent — skills on, workflows off`:e.inheritedAutonomous?`On`:`Off`]})]}),(0,v.jsxs)(`label`,{className:`grid gap-1.5 text-sm sm:grid-cols-1`,children:[(0,v.jsx)(`span`,{className:_,children:`Use a worktree by default`}),(0,v.jsxs)(p,{"aria-label":`Use a worktree by default`,value:k(e.worktree),disabled:n,onChange:e=>t(`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,v.jsx)(`option`,{value:`inherit`,children:`Inherit environment`}),(0,v.jsx)(`option`,{value:`on`,children:`On`}),(0,v.jsx)(`option`,{value:`off`,children:`Off`})]}),(0,v.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Inherited: `,e.inheritedWorktree?`On`:`Off`]})]})]}),(0,v.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Interactive skills may recommend both off. Multi-step and parallel runs remain isolated. Saves automatically.`})]})}export{C as ResourcesSection};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{l as r,n as i,t as a}from"./utils-DSMR_WLb.js";import{$ as o,$t as s,Ct as c,P as l,Wt as u,Xt as d,Yt as f,_ as p,dn as m,lt as h,rn as g,un as _}from"./queries-D0v1z40Y.js";import{Fn as v,ct as y,dr as b,hi as x,n as S,ot as C,pt as w,rr as T}from"./toaster-DMfiAEnw.js";import{f as E,n as D,p as O}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{B as k,F as ee,K as A,X as te,at as j,c as ne,dt as M,ft as re,s as ie,u as N,v as ae}from"./design-icons-CzEoMH9c.js";import{t as P}from"./createLucideIcon-BHp8sXmF.js";import{t as oe}from"./check-OP-CVgZG.js";import{t as se}from"./chevron-right-BENZ-1ZN.js";import{t as ce}from"./external-link-BE6y205O.js";import{t as F}from"./eye-B8okNWXU.js";import{n as le}from"./smartphone-Lr8Ug2z_.js";import{t as I}from"./loader-circle-CPBhhDbB.js";import{t as ue}from"./message-square-B-MD-8rD.js";import{n as de,t as fe}from"./tool-display-B9NN44oU.js";import{t as pe}from"./square-terminal-B6RYYieR.js";import{t as L}from"./button-B7MKxYjT.js";import{n as R,r as z,t as B}from"./collapsible-BEV4FO-1.js";import{t as V}from"./project-router-BifLGgRR.js";import{O as me}from"./task-groups-BdayPxX3.js";import{a as he,c as ge,i as _e,l as ve,o as ye,s as be,t as xe}from"./report-selection-CDlncYKI.js";import{n as Se}from"./centered-state-V15AR_qo.js";import{$t as Ce,I as we,X as Te,fr as Ee,or as De,pn as Oe,rn as ke,tn as Ae,tr as je,un as Me,vn as Ne}from"./index-01bdo9g3.js";import{i as Pe,r as Fe}from"./highlighter-DvLzHjjY.js";import{t as Ie}from"./zoomable-image-6RTKhLGE.js";import{i as Le,r as Re,t as H}from"./markdown-0A4VVYvY.js";import{r as ze}from"./html-report-BX3msvci.js";import{t as U}from"./textarea-vJt9undk.js";import{t as Be}from"./task-file-scope-CacffK2K.js";import{t as Ve}from"./report-title-D4Mbu2Er.js";var He=P(`anchor`,[[`path`,{d:`M12 6v16`,key:`nqf5sj`}],[`path`,{d:`m19 13 2-1a9 9 0 0 1-18 0l2 1`,key:`y7qv08`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}]]),Ue=P(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),We=P(`corner-up-left`,[[`path`,{d:`M20 20v-7a4 4 0 0 0-4-4H4`,key:`1nkjon`}],[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}]]),Ge=P(`folder-input`,[[`path`,{d:`M2 9V5a2 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 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),Ke=P(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),qe=P(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),W=e(t(),1),G=n();function Je(e,t){if(e.length===1)return[t.replace(RegExp(`^${Ye(e[0].header)}: ?`),``)];let n=t,r=[];for(let[t,i]of e.entries()){let a=`${i.header}: `;if(!n.startsWith(a))return;n=n.slice(a.length);let o=e[t+1],s=o?n.indexOf(`\n${o.header}: `):n.length;if(s<0)return;r.push(n.slice(0,s)),n=n.slice(s+1)}return r}function Ye(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Xe(e,t){if(t===void 0)return[];let n=e.options??[];if(!e.multiSelect)return n.filter(e=>e.label===t).map(e=>e.label);let r=[];function i(e,t){for(let{label:a}of n)t.includes(a)||(e===a?r.push([...t,a]):e.startsWith(`${a}, `)&&i(e.slice(a.length+2),[...t,a]))}return i(t,[]),r.length===1?r[0]:[]}var Ze=`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{l as r,n as i,t as a}from"./utils-DSMR_WLb.js";import{$ as o,$t as s,Ct as c,P as l,Wt as u,Xt as d,Yt as f,_ as p,dn as m,lt as h,rn as g,un as _}from"./queries-D0v1z40Y.js";import{Fn as v,ct as y,dr as b,hi as x,n as S,ot as C,pt as w,rr as T}from"./toaster-DMfiAEnw.js";import{f as E,n as D,p as O}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{B as k,F as ee,K as A,X as te,at as j,c as ne,dt as M,ft as re,s as ie,u as N,v as ae}from"./design-icons-CzEoMH9c.js";import{t as P}from"./createLucideIcon-BHp8sXmF.js";import{t as oe}from"./check-OP-CVgZG.js";import{t as se}from"./chevron-right-BENZ-1ZN.js";import{t as ce}from"./external-link-BE6y205O.js";import{t as F}from"./eye-B8okNWXU.js";import{n as le}from"./smartphone-Lr8Ug2z_.js";import{t as I}from"./loader-circle-CPBhhDbB.js";import{t as ue}from"./message-square-B-MD-8rD.js";import{n as de,t as fe}from"./tool-display-B9NN44oU.js";import{t as pe}from"./square-terminal-B6RYYieR.js";import{t as L}from"./button-B7MKxYjT.js";import{n as R,r as z,t as B}from"./collapsible-BEV4FO-1.js";import{t as V}from"./project-router-BifLGgRR.js";import{O as me}from"./task-groups-BdayPxX3.js";import{a as he,c as ge,i as _e,l as ve,o as ye,s as be,t as xe}from"./report-selection-CDlncYKI.js";import{n as Se}from"./centered-state-V15AR_qo.js";import{$t as Ce,I as we,X as Te,fr as Ee,or as De,pn as Oe,rn as ke,tn as Ae,tr as je,un as Me,vn as Ne}from"./index-DEWnkuj6.js";import{i as Pe,r as Fe}from"./highlighter-DvLzHjjY.js";import{t as Ie}from"./zoomable-image-6RTKhLGE.js";import{i as Le,r as Re,t as H}from"./markdown-DOEDwgDr.js";import{r as ze}from"./html-report-BX3msvci.js";import{t as U}from"./textarea-vJt9undk.js";import{t as Be}from"./task-file-scope-CgfssVeu.js";import{t as Ve}from"./report-title-D4Mbu2Er.js";var He=P(`anchor`,[[`path`,{d:`M12 6v16`,key:`nqf5sj`}],[`path`,{d:`m19 13 2-1a9 9 0 0 1-18 0l2 1`,key:`y7qv08`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}]]),Ue=P(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),We=P(`corner-up-left`,[[`path`,{d:`M20 20v-7a4 4 0 0 0-4-4H4`,key:`1nkjon`}],[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}]]),Ge=P(`folder-input`,[[`path`,{d:`M2 9V5a2 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 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),Ke=P(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),qe=P(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),W=e(t(),1),G=n();function Je(e,t){if(e.length===1)return[t.replace(RegExp(`^${Ye(e[0].header)}: ?`),``)];let n=t,r=[];for(let[t,i]of e.entries()){let a=`${i.header}: `;if(!n.startsWith(a))return;n=n.slice(a.length);let o=e[t+1],s=o?n.indexOf(`\n${o.header}: `):n.length;if(s<0)return;r.push(n.slice(0,s)),n=n.slice(s+1)}return r}function Ye(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Xe(e,t){if(t===void 0)return[];let n=e.options??[];if(!e.multiSelect)return n.filter(e=>e.label===t).map(e=>e.label);let r=[];function i(e,t){for(let{label:a}of n)t.includes(a)||(e===a?r.push([...t,a]):e.startsWith(`${a}, `)&&i(e.slice(a.length+2),[...t,a]))}return i(t,[]),r.length===1?r[0]:[]}var Ze=`
2
2
 
3
3
  Additional comments:
4
4
  `;function Qe(e){let t=e.indexOf(Ze);if(t<0)return{body:e,comment:void 0};let n=e.slice(t+23).trim();return{body:e.slice(0,t),comment:n||void 0}}function $e({ask:e}){let t=e.answer===void 0?void 0:Qe(e.answer),n=t===void 0?void 0:Je(e.questions,t.body);return(0,G.jsxs)(`div`,{"data-slot":`ask-answers`,className:`flex flex-col gap-4 text-sm`,children:[e.questions.map((t,r)=>{let i=n?.[r],a=Xe(t,i),o=i!==void 0&&a.length===0;return(0,G.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":t.question,children:[(0,G.jsxs)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:[t.header,` · Question `,r+1,` of `,e.questions.length]}),(0,G.jsx)(`p`,{className:`break-words font-semibold`,children:t.question}),t.options?(0,G.jsxs)(`ul`,{className:`flex list-none flex-col gap-1.5`,children:[t.options.map(e=>(0,G.jsxs)(`li`,{"data-selected":a.includes(e.label),className:`flex items-start gap-2 rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border data-[selected=true]:bg-message-user-accent/5`,children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-message-user-accent`,children:a.includes(e.label)?`✓`:`○`}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,G.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description}):null]}),a.includes(e.label)?(0,G.jsx)(`span`,{className:`shrink-0 text-xs text-message-user-accent`,children:`Selected`}):null]},e.label)),(0,G.jsxs)(`li`,{"data-selected":o,className:`rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border`,children:[(0,G.jsxs)(`p`,{className:`flex items-start gap-2 font-medium`,children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`text-message-user-accent`,children:o?`✓`:`○`}),(0,G.jsx)(`span`,{className:`flex-1`,children:`Other`}),o?(0,G.jsx)(`span`,{className:`text-xs text-message-user-accent`,children:`Selected`}):null]}),o?(0,G.jsx)(K,{text:i}):null]})]}):i===void 0?null:(0,G.jsx)(K,{text:i})]},t.id??r)}),n&&t?.comment?(0,G.jsxs)(`section`,{className:`flex flex-col gap-1`,"aria-label":`Additional comments`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Additional comments`}),(0,G.jsx)(K,{text:t.comment})]}):null,!n&&e.answer!==void 0?(0,G.jsx)(K,{text:e.answer}):null]})}function K({text:e}){return(0,G.jsx)(`blockquote`,{className:`[margin-block-start:0.5rem] border-s-2 border-message-user-accent ps-3 break-words whitespace-pre-wrap`,children:e})}function q(e,t,n){let r=n[e];return r===void 0?(t[e]?.length??0)>0:r.trim().length>0}function et(e,t,n){let r=n[e]?.trim();if(r)return r;let i=t[e]??[];return i.length>0?i.join(`, `):`Not answered yet`}function tt({stepped:e,mode:t,onModeChange:n,showModeSwitch:r,stepLabel:i,hasSheetContext:o,showContextButtonRef:s,onOpenContext:c,onShowOrigin:l}){return(0,G.jsxs)(`div`,{"data-slot":`ask-header`,className:`flex shrink-0 flex-wrap items-center gap-x-2 gap-y-1 border-b border-border/70 px-2.5 py-1.5 md:px-3 md:py-2`,children:[(0,G.jsx)(`span`,{className:`text-xs font-semibold text-link-foreground`,children:`Needs your answer`}),e&&t===`options`?(0,G.jsx)(`span`,{"data-slot":`ask-step-indicator`,className:`rounded-full bg-accent-strong/15 px-2 py-0.5 text-xs font-semibold text-foreground tabular-nums`,children:i}):null,(0,G.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-1.5`,children:[o?(0,G.jsxs)(L,{ref:s,type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-context`,className:`min-h-11 min-w-11 px-2 text-xs font-medium text-link-foreground underline underline-offset-4 md:min-h-8 md:min-w-0`,onClick:c,children:[(0,G.jsx)(De,{"aria-hidden":`true`,className:`size-3.5`}),`Show context`]}):l?(0,G.jsx)(ct,{onShowOrigin:l}):null,r?(0,G.jsxs)(`div`,{"data-slot":`ask-mode-switch`,role:`group`,"aria-label":`Reply mode`,className:`inline-flex items-center rounded-lg border border-border bg-card p-0.5`,children:[(0,G.jsx)(`button`,{type:`button`,"data-slot":`ask-mode-options`,"aria-pressed":t===`options`,onClick:()=>n(`options`),className:a(`min-h-11 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring md:min-h-7`,t===`options`?`bg-accent-strong text-accent-strong-foreground`:`text-foreground hover:bg-muted/60`),children:`Options`}),(0,G.jsx)(`button`,{type:`button`,"data-slot":`ask-mode-reply`,"aria-pressed":t===`reply`,onClick:()=>n(`reply`),className:a(`min-h-11 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring md:min-h-7`,t===`reply`?`bg-accent-strong text-accent-strong-foreground`:`text-foreground hover:bg-muted/60`),children:`Write a reply`})]}):null]})]})}function nt({questions:e,stepIndex:t,selections:n,otherAnswers:r,hasComment:i,onSelectStep:o}){let s=e.length;return(0,G.jsxs)(`div`,{"data-slot":`ask-step-pills`,role:`group`,"aria-label":`Question steps`,className:`hidden shrink-0 flex-wrap items-center gap-1.5 border-b border-border/60 px-3 py-1.5 md:flex`,children:[e.map((e,i)=>{let s=t===i,c=q(i,n,r);return(0,G.jsxs)(`button`,{type:`button`,"aria-current":s?`step`:void 0,onClick:()=>o(i),className:a(`inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring`,s?`border-accent-strong bg-accent-strong/15 text-foreground`:c?`border-border bg-card text-foreground hover:border-accent-strong/50`:`border-border bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,G.jsx)(`span`,{className:`tabular-nums text-xs font-semibold`,children:c?(0,G.jsx)(oe,{"aria-hidden":`true`,className:`size-3 text-semantic-green`}):`${i+1}.`}),(0,G.jsx)(`span`,{className:`max-w-[140px] truncate`,children:e.header})]},e.id??i)}),(0,G.jsxs)(`button`,{type:`button`,"aria-current":t===s?`step`:void 0,onClick:()=>o(s),className:a(`inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring`,t===s?`border-accent-strong bg-accent-strong/15 text-foreground`:i?`border-border bg-card text-foreground hover:border-accent-strong/50`:`border-dashed border-border bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,G.jsx)(Ke,{"aria-hidden":`true`,className:`size-3`}),(0,G.jsx)(`span`,{children:`Comment`})]})]})}function rt({questions:e,selections:t,otherAnswers:n,comment:r,disabled:i,onCommentChange:o,onJumpToQuestion:s}){let c=(0,W.useId)();return(0,G.jsxs)(`div`,{"data-slot":`ask-comment-step`,className:`flex flex-col gap-2.5`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-2.5`,children:[(0,G.jsx)(`p`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Selected answers`}),(0,G.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map((e,r)=>{let i=q(r,t,n);return(0,G.jsxs)(`li`,{className:`flex items-baseline justify-between gap-2 text-xs`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>s(r),className:`min-h-11 text-start font-medium text-link-foreground underline-offset-4 hover:underline md:min-h-6`,children:e.header}),(0,G.jsx)(`span`,{className:a(`min-w-0 truncate text-end`,i?`text-foreground`:`text-semantic-red`),children:et(r,t,n)})]},e.id??r)})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:c,className:`mb-1 block text-xs font-medium text-foreground`,children:`Additional comments (optional)`}),(0,G.jsx)(U,{id:c,"data-slot":`ask-additional-comment`,rows:2,value:r,disabled:i,placeholder:`Optional extra notes to send with your selections…`,onChange:e=>o(e.target.value),className:`bg-card text-base md:text-[13px]`})]})]})}function it({value:e,onValueChange:t,disabled:n,renderFreeTextReply:r}){let i=(0,W.useId)();return r?(0,G.jsx)(`div`,{"data-slot":`ask-free-text`,children:r({value:e,onValueChange:t,disabled:n})}):(0,G.jsxs)(`div`,{"data-slot":`ask-free-text`,className:`flex flex-col gap-2`,children:[(0,G.jsx)(`label`,{htmlFor:i,className:`text-xs font-medium text-foreground`,children:`Reply to the agent`}),(0,G.jsx)(U,{id:i,rows:2,value:e,disabled:n,placeholder:`Write a free-text reply…`,onChange:e=>t(e.target.value),className:`bg-card text-base md:text-[13px]`})]})}function at({stepIndex:e,questionCount:t,answeredCount:n,allAnswered:r,hasComment:i,resuming:o,disabled:s,onBack:c,onNext:l,onOpenComment:u,onSend:d,questions:f,selections:p,otherAnswers:m,stopControl:h}){let g=e===t-1,_=e===t,v=o?`Send answer & reopen`:`Send answer`;return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e>0?(0,G.jsxs)(L,{type:`button`,variant:`outline`,size:`sm`,className:`min-h-11 min-w-11 px-3 md:min-h-8 md:min-w-0`,onClick:c,children:[(0,G.jsx)(Ee,{"aria-hidden":`true`,className:`size-4`}),`Back`]}):null,(0,G.jsxs)(`span`,{"data-slot":`ask-progress-dots`,"aria-hidden":`true`,className:`flex items-center gap-1.5 px-1 md:hidden`,children:[f.map((t,n)=>{let r=n===e,i=q(n,p,m);return(0,G.jsx)(`span`,{className:a(`size-2 rounded-full motion-safe:transition-colors`,r?`bg-accent-strong`:i?`bg-success`:`bg-border`)},t.id??n)}),(0,G.jsx)(`span`,{className:a(`size-2 rounded-full motion-safe:transition-colors`,_?`bg-accent-strong`:i?`bg-success`:`bg-border/60`)})]}),(0,G.jsxs)(`span`,{"data-slot":`ask-progress-summary`,className:`hidden text-xs text-soft-foreground tabular-nums sm:inline`,children:[n,` of `,t,` answered`]}),o?(0,G.jsx)(`span`,{"data-slot":`ask-resume-hint`,className:`text-xs text-soft-foreground`,children:`Reopens the closed session.`}):null,(0,G.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-2`,children:[h,!g&&!_?(0,G.jsxs)(L,{type:`button`,variant:`outline`,size:`sm`,className:`min-h-11 min-w-11 px-3 md:min-h-8 md:min-w-0`,onClick:l,children:[`Next`,(0,G.jsx)(se,{"aria-hidden":`true`,className:`size-4`})]}):null,g?(0,G.jsx)(L,{type:`button`,variant:`outline`,size:`sm`,className:`min-h-11 min-w-11 px-3 md:min-h-8 md:min-w-0`,onClick:u,children:i?`Edit comment`:`+ Comment`}):null,g||_||r?(0,G.jsx)(L,{type:`button`,size:`sm`,className:`min-h-11 min-w-11 px-3.5 md:min-h-8 md:min-w-0`,disabled:s||!r,onClick:d,children:v}):null]})]})}function ot({oneTap:e,hasOtherAnswer:t,allowComment:n,commentOpen:r,hasComment:i,resuming:a,disabled:o,onToggleComment:s,onSend:c,stopControl:l}){return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n?(0,G.jsxs)(L,{type:`button`,variant:`ghost`,size:`sm`,className:`min-h-11 min-w-11 px-2 text-xs text-muted-foreground hover:text-foreground md:min-h-8 md:min-w-0`,onClick:s,children:[(0,G.jsx)(Ke,{"aria-hidden":`true`,className:`size-3.5`}),r?`Hide comment`:i?`Edit comment`:`+ Add comment`]}):null,(0,G.jsx)(`span`,{"data-slot":a?`ask-resume-hint`:`ask-hint`,className:`text-xs text-soft-foreground`,children:a?`Reopens the closed session.`:e?`Tap an option to send.`:`Choose an answer, then send.`}),(0,G.jsxs)(`div`,{className:`ms-auto flex items-center gap-2`,children:[l,!e||t||r||i?(0,G.jsx)(L,{type:`button`,size:`sm`,className:`min-h-11 min-w-11 px-3.5 md:min-h-8 md:min-w-0`,disabled:o,onClick:c,children:a?`Send answer & reopen`:`Send answer`}):null]})]})}function st({blockedBy:e,reason:t,error:n}){return(0,G.jsxs)(G.Fragment,{children:[t?(0,G.jsxs)(`p`,{"data-slot":`ask-blocked-reason`,className:`text-xs text-muted-foreground`,children:[t,` `,e===`provider`?(0,G.jsx)(V,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):null]}):null,n?(0,G.jsx)(`p`,{role:`alert`,className:`text-xs text-semantic-red`,children:n}):null]})}function ct({onShowOrigin:e,className:t}){return(0,G.jsx)(L,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-origin`,onClick:e,className:a(`min-h-11 min-w-11 px-2 text-xs font-medium text-link-foreground underline underline-offset-4 md:min-h-8 md:min-w-0`,t),children:`Show where it was asked`})}function lt({open:e,onOpenChange:t,runId:n,context:r,onShowOrigin:i,returnFocusRef:a}){let o=(0,W.useRef)(!1);return(0,G.jsx)(_e,{open:e,onOpenChange:t,children:(0,G.jsxs)(ye,{side:`right`,showCloseButton:!1,"data-slot":`ask-context-sheet`,className:`flex w-full max-w-[540px] flex-col gap-0 p-0 sm:max-w-[540px]`,onCloseAutoFocus:e=>{if(e.preventDefault(),o.current){o.current=!1,i?.();return}a?.current?.focus()},children:[(0,G.jsxs)(ge,{className:`relative shrink-0 border-b border-border px-5 py-4 pr-14`,children:[(0,G.jsx)(ve,{children:`Question context`}),(0,G.jsx)(be,{children:`Your selections and drafts stay intact while you read.`}),(0,G.jsx)(he,{asChild:!0,children:(0,G.jsx)(L,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Close`,className:`absolute inset-bs-2 end-2 size-11 md:size-9`,children:(0,G.jsx)(re,{"aria-hidden":`true`,className:`size-4`})})})]}),(0,G.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain break-words px-5 py-4 text-sm text-foreground`,children:(0,G.jsx)(Be,{runId:n,children:(0,G.jsx)(H,{breaks:!0,children:r})})}),i?(0,G.jsx)(`div`,{className:`flex shrink-0 items-center justify-end border-t border-border px-5 py-3`,children:(0,G.jsx)(L,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`ask-show-origin`,className:`min-h-11 md:min-h-8`,onClick:()=>{o.current=!0,t(!1),i()},children:`Show where it was asked`})}):null]})})}function ut(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var dt=/^[A-Za-z0-9_./:=+,@%-]+$/;function ft(e){return e.replaceAll(`'`,`'\\''`)}function pt(e){return e===``?`''`:dt.test(e)?e:`\u0027${ft(e)}\u0027`}function mt(e){if(!ut(e))return;let t=e.command;if(typeof t==`string`&&t!==``)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return e.map(pt).join(` `)}}function ht(e){let t="`".repeat(3),n=`~`.repeat(3);return e.split(t).filter((e,t)=>t%2==0).join(` `).split(n).filter((e,t)=>t%2==0).join(` `).split("`").filter((e,t)=>t%2==0).join(` `)}function gt(e){return e.replace(/!\[(?:\\.|[^\]\\])*\]\([^)\s]*(?:\s+"[^"]*")?\)/g,` `)}function _t(e){return e.replace(/(?<!\\)(?:\*\*|\*|__|~~|`)/g,``).replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/g,`$1`)}function J(e){let t=e.trim();return t===``||t.startsWith(`#`)||/^(https?:|mailto:)/i.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t)}function vt(e){let t=ht(gt(e)),n=new Map;for(let e of t.matchAll(/^\s*\[([^\]]+)\]:\s*(\S+)/gm))J(e[2])&&n.set(e[1].toLowerCase(),e[2]);let r=t.replace(/^\s*\[[^\]]+\]:\s*\S+.*$/gm,` `),i=[];for(let e of r.matchAll(/(?<!!)\[((?:\\.|[^\]\\])+)\](?:\(((?:[^()\s]|\([^)]*\))+)(?:\s+"[^"]*")?\)|\[([^\]]*)\])|<(https?:\/\/[^>\s]+)>|(https?:\/\/[^\s<]+)/g)){if(e[2]){J(e[2])&&i.push({label:_t(e[1]),href:e[2]});continue}if(e[1]!==void 0&&e[3]!==void 0){let t=(e[3].length>0?e[3]:e[1]).toLowerCase(),r=n.get(t);r&&i.push({label:_t(e[1]),href:r});continue}let t=(e[4]??e[5])?.replace(/[.,;:!?]+$/,``);t&&J(t)&&i.push({label:t,href:t})}return i}var yt=(0,W.createContext)(void 0),bt=(0,W.createContext)(void 0);function xt(e,t){let n=new Map;for(let r of vt(e)){let e=Le(r.href,t);if(!e)continue;let i=new URL(e,`https://cockpit.invalid`),a=/^\/p\/([^/]+)\/tasks\/([^/]+)\/report$/.exec(i.pathname),o=/^\/tasks\/([^/]+)\/report$/.exec(i.pathname),s=i.searchParams.get(`artifact`);if(!s||(a?decodeURIComponent(a[1])!==t.projectId:!o))continue;let c=decodeURIComponent(a?a[2]:o[1]),l=`${c}:${s}`;n.has(l)||n.set(l,{runId:c,artifactId:s,label:r.label,href:e})}return[...n.values()]}function St(e,t){return`report-card-${encodeURIComponent(e)}-${t}`}function Ct({text:e,messageKey:t}){let n=(0,W.useContext)(Re),r=(0,W.useContext)(bt),i=t??r;if(!n||i===void 0)return null;let a=xt(e,n);return a.length===0?null:(0,G.jsx)(`div`,{"data-slot":`report-cards`,className:`flex flex-col gap-3 [margin-block-start:1rem]`,children:a.map(e=>(0,G.jsx)(wt,{reference:e,messageKey:i},`${e.runId}:${e.artifactId}`))})}function wt({reference:e,messageKey:t}){let{artifactId:n,runId:r,label:i,href:a}=e,o=(0,W.useContext)(yt),s=(0,W.useContext)(xe);(0,W.useLayoutEffect)(()=>s?.register(n,r),[s,n,r]);let c=l(r,n),u=E(),d=O();if(c.isError)return(0,G.jsx)(D,{id:St(t,n),"data-slot":`report-card-fallback`,to:a,state:{readerFrom:u.pathname+u.search},children:i});let f=c.data?.artifact;if(f&&!ze(f.name))return null;let p=new URLSearchParams(u.search);p.set(`report`,n),p.set(`card`,t);let m=new URLSearchParams(u.search).has(`report`)?u.state:null,h=new URLSearchParams(u.search);h.delete(`report`),h.delete(`card`);let g=`${u.pathname}${h.size?`?${h}`:``}`,_=window.navigation,v={reportCardEntry:!0,reportReturnTo:m?.reportReturnTo??g,reportReturnKey:m?.reportReturnKey??_?.currentEntry?.key,reportScrollTop:m?.reportScrollTop},y={pathname:u.pathname,search:`?${p}`,hash:new URL(a,`https://cockpit.invalid`).hash};return(0,G.jsxs)(`section`,{"data-slot":`report-card`,"data-artifact-id":n,"data-report-run-id":r,"aria-busy":c.isPending,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card p-3 text-foreground`,children:[(0,G.jsx)(`h3`,{className:`break-words text-sm font-medium`,children:f?Ve(f):i}),(0,G.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`HTML report`}),(0,G.jsx)(D,{id:St(t,n),to:y,state:v,onClick:e=>{if(e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault(),o?.(t);let n=v.reportScrollTop??(document.querySelector(`[data-slot="thread-transcript"]`)??document.querySelector(`[data-slot="main"]`))?.scrollTop;d(y,{state:{...v,reportScrollTop:n}})},className:`inline-flex min-h-11 min-w-11 items-center self-start rounded-md border border-border px-3 text-sm active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring ${c.isPending?`text-soft-foreground`:`text-accent-text`}`,children:`Read report`})]})}var Tt={message:!0,reasoning:!0,tool:!0,hook:!0};function Et(e){return Object.hasOwn(Tt,e)&&Tt[e]}var Dt=e=>e.kind===`tool`,Ot=e=>e.kind===`conversation`,kt=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,At=(e,t,n)=>`${e} ${e===1?t:n}`;function jt(e,t){let n=[];return e>0&&n.push(At(e,`file`,`files`)),t>0&&n.push(At(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function Mt(e){return`${e} earlier tool call${e===1?``:`s`}`}var Nt=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function Pt(e){for(let t of Nt)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t===`Task:`?`Task`:t,detail:e.slice(t.length+1)};return{verb:e}}var Ft=new WeakMap;function It(e){let t=Ft.get(e);if(t)return t;let n=Lt(e);return Ft.set(e,n),n}function Lt(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!((e.kind===`reasoning`||e.kind===`message`)&&e.text.trim()===``)),n=new Set(t.filter(Dt).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=Et(e.kind)&&`parentItemId`in e&&e.parentItemId!==void 0&&e.parentItemId!==e.id&&n.has(e.parentItemId)?e.parentItemId:void 0;if(t===void 0)i.push(e);else{let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[],o=[],s=()=>{if(o.length>=2){let e=o.filter(e=>e.toolKind===`read`).length;a.push({kind:`context-group`,id:`group:${o[0].id}`,tools:o,files:e,searches:o.length-e,label:jt(e,o.length-e)})}else for(let e of o)a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]});o=[]},c=[],l=()=>{if(c.length!==0){for(let e of Rt(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(Ot(e)){s(),c.push(e);continue}l(),Dt(e)&&kt(e)&&!r.has(e.id)?o.push(e):(s(),Dt(e)?a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]}):a.push({kind:`entry`,id:e.id,entry:e}))}s(),l();let u=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,d=e=>e.kind===`context-group`?e.tools.length:1,f=[],p=[],m=()=>{if(p.length>3){let e=p.slice(0,p.length-3);f.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+d(t),0),blocks:e}),f.push(...p.slice(p.length-3))}else f.push(...p);p=[]};for(let e of a)u(e)?p.push(e):(m(),f.push(e));return m(),f}function Rt(e){let t=[];for(let n of e){let e=t.at(-1);n.messageKind===`request`&&e?.kind===`request`&&e.senderRunId===n.senderRunId&&e.text===n.text&&e.messages[0].relationship===`peer`==(n.relationship===`peer`)&&!e.messages.some(e=>e.recipientRunId===n.recipientRunId)?e.messages.push(n):t.push({id:`worker-batch:${n.messageId}`,kind:n.messageKind,text:n.text,senderRunId:n.senderRunId,messages:[n]})}return{kind:`worker-conversation`,id:`worker:${e[0].id}`,batches:t}}var zt=new Map,Bt=(0,W.createContext)(null);function Vt(){return(0,W.useContext)(Bt)}function Ht({runId:e,children:t}){let n=(0,W.useMemo)(()=>({get:t=>zt.get(e)?.get(t),set:(t,n)=>{let r=zt.get(e)??new Map;r.set(t,n),zt.set(e,r)}}),[e]);return(0,G.jsx)(Bt.Provider,{value:n,children:t})}function Ut(e){return e.scrollTop<Math.max(600,e.clientHeight)}function Wt(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function Gt(e,t,n,r,i){if(n===void 0)return i;let a=r.find(({key:e})=>e===n.key);return a===void 0?i:e+(a.top-t-n.offset)}function Kt(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function qt(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var Jt=new Map;function Yt(e,t){Jt.set(e,t)}function Xt(e){return Jt.get(e)}var Zt=new Map;function Qt(e,t){Zt.set(e,{...t,...t.rowKeys?{rowKeys:[...t.rowKeys]}:{}})}function $t(e){return Zt.get(e)}function en(e,t,n){let r=Zt.get(e);if(!r||r.rows!==t)return;let i=r.rowKeys;if(!(n&&i&&(n.length!==t||i.length!==t||!n.every((e,t)=>e===i[t]))))return r.cache}var tn=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),nn=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),rn=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),an=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),on=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function Y(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function X(e){let t=Y(e);return t===void 0?void 0:tn.format(t)}function sn(e){let t=Y(e);return t===void 0?void 0:nn.format(t)}var Z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function cn(e){let t=Y(e);return t===void 0?void 0:Z(t)}function ln(e,t=new Date){let n=Y(e);if(n===void 0)return;let r=Z(n);return r===Z(t)?`Today`:r===Z(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?rn:an).format(n)}function un(e,t){let n=Y(e),r=Y(t);if(n===void 0||r===void 0)return;let i=Math.round((r.getTime()-n.getTime())/1e3);if(i<0)return;if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${String(i%60).padStart(2,`0`)}s`:`${Math.floor(a/60)}h ${String(a%60).padStart(2,`0`)}m`}function dn({ts:e}){let t=X(e);return t===void 0?null:(0,G.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:sn(e),className:`text-xs leading-none text-soft-foreground`,children:t})}function fn({startedAt:e,completedAt:t}){let n=X(t);if(n===void 0)return null;let r=un(e,t);return(0,G.jsxs)(`div`,{"data-slot":`turn-time`,className:`flex items-center gap-1.5 px-0.5 text-xs leading-none text-soft-foreground`,children:[(0,G.jsx)(`time`,{dateTime:t,title:sn(t),children:n}),r===void 0?null:(0,G.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function pn({ts:e}){let t=ln(e),n=Y(e);if(t===void 0||n===void 0)return null;let r=on.format(n);return(0,G.jsxs)(`div`,{"data-slot":`day-separator`,role:`separator`,"aria-label":t===`Today`||t===`Yesterday`?`${t}, ${r}`:r,className:`flex items-center gap-3 py-1 text-xs font-medium text-soft-foreground`,children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),(0,G.jsx)(`time`,{dateTime:cn(e),title:r,children:t}),(0,G.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}var mn={assistant:`Agent message`,error:`Runner error`,"session.error":`Session error`,"step-end":`Step status`,lifecycle:`Run status`};function hn({note:e}){return e.icon===`handoff`?(0,G.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,"data-icon":`handoff`,className:`flex items-start gap-2 px-0.5 text-xs text-muted-foreground`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`mt-[-1px] flex size-5 shrink-0 items-center justify-center rounded-full border border-border text-success`,children:(0,G.jsx)(je,{className:`size-3`})}),(0,G.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}):e.details&&e.details.length>0?(0,G.jsxs)(B,{"data-slot":`note-line`,"data-tone":e.tone,className:`group/failure min-w-0 px-0.5 text-xs`,children:[(0,G.jsxs)(`div`,{className:a(`flex items-start gap-2`,e.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[(0,G.jsxs)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap wrap-anywhere`,children:[e.tone===`danger`?`✗ `:null,e.text]}),(0,G.jsxs)(z,{"data-slot":`note-details-toggle`,className:`inline-flex shrink-0 items-center gap-1 rounded-sm px-1.5 py-0.5 text-xs font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 max-md:min-w-11 max-md:justify-center pointer-coarse:min-h-11 pointer-coarse:min-w-11 pointer-coarse:justify-center`,children:[(0,G.jsx)(N,{"aria-hidden":`true`,className:`size-3 shrink-0 motion-safe:transition-transform group-data-[state=open]/failure:rotate-90`}),`Details`]})]}),(0,G.jsx)(R,{children:(0,G.jsx)(`ul`,{"data-slot":`note-details`,className:`mbs-1.5 flex flex-col gap-1 border-s border-border ps-3 font-mono text-xs text-muted-foreground`,children:e.details.map((e,t)=>(0,G.jsxs)(`li`,{className:`min-w-0 whitespace-pre-wrap wrap-anywhere`,children:[(0,G.jsxs)(`span`,{className:`font-sans font-medium text-foreground`,children:[mn[e.source],`:`,` `]}),e.text]},`${e.source}:${t}`))})})]}):(0,G.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:a(`px-0.5 text-xs`,e.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:null,e.text]})}var gn={user:{label:`YOUR MESSAGE`,speaker:`Your message`,classes:`border-message-user-border bg-message-user-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-user-accent`,accent:`text-message-user-accent`,body:`max-md:text-[12px]`},agent:{label:`AGENT RESPONSE`,speaker:`Agent response`,classes:`border-message-agent-border bg-message-agent-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-agent-accent`,accent:`text-message-agent-accent`,body:`text-[15px] md:text-[14px]`}};function Q({role:e,children:t,className:n,ts:r,headerActions:i,...o}){let s=gn[e],c=r===void 0?void 0:X(r);return(0,G.jsxs)(`article`,{...o,"data-role":e,"aria-label":s.speaker,className:a(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,s.classes,n),children:[(0,G.jsxs)(`p`,{className:a(`m-0 flex w-full min-w-0 items-start gap-2 text-xs leading-[1.2] font-semibold tracking-[0.6px] uppercase`,s.accent),children:[(0,G.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 normal-case tracking-normal`,children:[(0,G.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 uppercase tracking-[0.6px]`,children:[(0,G.jsx)(ue,{"aria-hidden":`true`,className:`size-4 shrink-0`}),s.label]}),i]}),c===void 0?null:(0,G.jsx)(`span`,{className:`shrink-0 font-normal tracking-normal normal-case`,children:(0,G.jsx)(dn,{ts:r})})]}),(0,G.jsx)(`div`,{className:a(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,s.body,`leading-[1.6]`),children:t})]})}var _n=[],vn=(0,W.memo)(function({text:e,imageCount:t=0,images:n=_n,ts:i,onEdit:a,onRemove:o,editLabel:s=`Edit message`,removeLabel:c=`Remove message`,children:l}){let u=t-n.length,[d,f]=(0,W.useState)(!1),[p,m]=(0,W.useState)(e),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(),y=()=>{m(e),v(void 0),f(!0)},x=async()=>{let t=p.trim();if(!t||t===e){f(!1);return}g(!0),v(void 0);try{await a?.(t),f(!1)}catch(e){v(e instanceof Error?e.message:`Could not save the message`)}finally{g(!1)}},S=async()=>{g(!0),v(void 0);try{await o?.()}catch(e){v(e instanceof Error?e.message:`Could not remove the message`)}finally{g(!1)}};return d?(0,G.jsxs)(Q,{role:`user`,ts:i,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,G.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),f(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),x())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[14px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,G.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>f(!1),disabled:h,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm px-2 text-xs font-medium text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void x(),disabled:h,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm bg-action px-2 text-xs font-semibold text-action-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:h?(0,G.jsx)(I,{className:`size-3.5 animate-spin`}):`Save`})]}),_?(0,G.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:_}):null]}):(0,G.jsxs)(Q,{role:`user`,ts:i,"data-slot":`user-bubble`,className:`group`,children:[a||o?(0,G.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[a?(0,G.jsx)(`button`,{type:`button`,"aria-label":s,onClick:y,disabled:h,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,G.jsx)(qe,{className:`size-3.5`})}):null,o?(0,G.jsx)(`button`,{type:`button`,"aria-label":c,onClick:()=>void S(),disabled:h,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,G.jsx)(j,{className:`size-3.5`})}):null]}):null,_?(0,G.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:_}):null,l??(0,G.jsx)(H,{breaks:!0,children:e}),n.length>0?(0,G.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>b(e.split(`/`).pop()??``)?(0,G.jsx)(Ie,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,G.jsxs)(`a`,{href:r(e),download:!0,"data-slot":`user-file`,className:`inline-flex min-h-11 min-w-11 max-w-[220px] items-center gap-1.5 rounded-md border border-border bg-background/60 px-2 py-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,G.jsx)(A,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,u>0?(0,G.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[u,` image`,u>1?`s`:``,` attached`]}):null]})}),yn=`inline-flex h-11 min-w-11 items-center justify-center gap-1 rounded-sm px-2 text-xs font-medium text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,bn=[`[data-streamdown="code-block-actions"]`,`[data-streamdown="code-copy-button"]`,`[data-streamdown="code-block-copy-button"]`,`[data-streamdown="code-block-header"]`].join(`,`);function xn(e,t){let n=e.cloneNode(!0);n.querySelectorAll(bn).forEach(e=>e.remove());let r=vt(t);return[...n.querySelectorAll(`button[data-streamdown="link"]`)].forEach(e=>{let t=e.textContent??``,i=r.findIndex(e=>e.label===t);if(i<0)return;let a=r.splice(i,1)[0];if(!a||!J(a.href))return;let o=n.ownerDocument.createElement(`a`);o.setAttribute(`href`,a.href),o.setAttribute(`data-streamdown`,`link`),o.textContent=e.textContent,e.replaceWith(o)}),n.innerHTML}async function Sn(e,t,n){if(e===`markdown`){if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(t);return}if(!navigator.clipboard?.write||typeof ClipboardItem>`u`||!n)throw Error(`Clipboard unavailable`);let r=xn(n,t);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:`text/html`}),"text/plain":new Blob([t],{type:`text/plain`})})])}var Cn=(0,W.memo)(function({text:e,ts:t,messageKey:n}){let r=(0,W.useRef)(null),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(null),c=(0,W.useRef)(null);(0,W.useEffect)(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);let l=async t=>{c.current!==null&&clearTimeout(c.current),a(null),s(null);try{await Sn(t,e,r.current),a(t),c.current=setTimeout(()=>a(null),2e3)}catch{s(`Couldn't copy to the clipboard`)}};return(0,G.jsxs)(Q,{role:`agent`,ts:t,"data-slot":`assistant-message`,headerActions:(0,G.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`flex items-center gap-0.5`,children:[(0,G.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply`,onClick:()=>void l(`html`),className:yn,children:[(0,G.jsx)(ae,{className:`size-3.5`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{"aria-live":`polite`,children:i===`html`?`Copied`:`Copy`})]}),(0,G.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply as markdown`,onClick:()=>void l(`markdown`),className:yn,children:[(0,G.jsx)(De,{className:`size-3.5`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{"aria-live":`polite`,children:i===`markdown`?`Copied`:`Copy markdown`})]})]}),children:[o?(0,G.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:o}):null,(0,G.jsx)(`div`,{ref:r,children:(0,G.jsx)(H,{breaks:!0,children:e})}),(0,G.jsx)(Ct,{text:e,messageKey:n})]})});function wn({incident:e}){let t=g().data;if(!t)return null;let n=d(t,e.provider);return(0,G.jsxs)(`div`,{role:`alert`,"data-slot":`provider-auth-required`,className:`rounded-md border border-danger/30 bg-danger/5 px-3.5 py-3`,children:[(0,G.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,n,` authorization`]}),(0,G.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,n,` settings before retrying.`]}),(0,G.jsx)(V,{to:`/settings/agent-defaults#providers`,className:`mt-2 inline-flex text-xs font-medium text-foreground underline-offset-2 hover:underline`,children:`Open provider settings`})]})}var Tn=(0,W.memo)(function({text:e}){let t=(0,W.useId)();if(e.trim()===``)return null;let n=e.split(`