@wjarka/cezarion 0.18.0-dev.6784 → 0.18.0-dev.6807
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/web/dist/assets/{activity-motion-gOopdagH.js → activity-motion-ankV4z_y.js} +1 -1
- package/web/dist/assets/{activity-route-D7bDtXpW.js → activity-route-C7Lo4d_1.js} +1 -1
- package/web/dist/assets/{agent-accounts-otlDWnij.js → agent-accounts-BAUPVmTO.js} +1 -1
- package/web/dist/assets/attention-C6XIgMqB.js +1 -0
- package/web/dist/assets/{commit-diff-panel-iQf0Rlcx.js → commit-diff-panel-Cmqi-EvU.js} +1 -1
- package/web/dist/assets/{diff-DQfcliZC.js → diff-BawymO3F.js} +2 -2
- package/web/dist/assets/{diff-view-BbM-71Cs.js → diff-view-DHx_pu8b.js} +1 -1
- package/web/dist/assets/{file-preview-DgU8vo8k.js → file-preview-DV7f2pOk.js} +1 -1
- package/web/dist/assets/git-toolbar-BrVfyYBr.js +1 -0
- package/web/dist/assets/{github-hXmxAXmA.js → github-DVXWmfeu.js} +1 -1
- package/web/dist/assets/{global-activity-route-D_r1ImUh.js → global-activity-route-ybR1xgLf.js} +1 -1
- package/web/dist/assets/index-Dc_KmL4Z.js +17 -0
- package/web/dist/assets/{preview-pane-connected-D__9JwyU.js → preview-pane-connected-CT7tXifI.js} +1 -1
- package/web/dist/assets/{project-router-WQWd3UUn.js → project-router-CbWELZZ9.js} +1 -1
- package/web/dist/assets/{project-scope-context-bgdvGX9z.js → project-scope-context-p1OpXpSJ.js} +1 -1
- package/web/dist/assets/{prompt-template-menu-BJfUg1uF.js → prompt-template-menu-Ct3m86h1.js} +1 -1
- package/web/dist/assets/{queries-BJM44umy.js → queries-BAUtqJph.js} +1 -1
- package/web/dist/assets/{reference-chip-vraIzoEF.js → reference-chip-B2B-Ky7w.js} +1 -1
- package/web/dist/assets/{repo-git-B4qZq37d.js → repo-git-DRONt4_i.js} +1 -1
- package/web/dist/assets/{report-reader-Djix-ICM.js → report-reader-BF8rmJRD.js} +1 -1
- package/web/dist/assets/{reports-Do-dkavq.js → reports-Bv91XlcP.js} +1 -1
- package/web/dist/assets/{run-header-Di9LaKQs.js → run-header-CvJ84kr2.js} +1 -1
- package/web/dist/assets/{skills-CPnIvFnR.js → skills-Ceg2Y9LM.js} +1 -1
- package/web/dist/assets/{tab-link-DiNYVlpl.js → tab-link-CT5gqdai.js} +1 -1
- package/web/dist/assets/{task-changes-CW7NzgL5.js → task-changes-BplRsiSs.js} +1 -1
- package/web/dist/assets/{task-commits-Bkwi7o1B.js → task-commits-CYLy-lg-.js} +1 -1
- package/web/dist/assets/{task-files-geRzIszC.js → task-files-COYxL8mg.js} +1 -1
- package/web/dist/assets/task-github-item-DAD__wEa.js +1 -0
- package/web/dist/assets/task-thread-CTEobEyX.js +9 -0
- package/web/dist/assets/{thread-state-CajkV5Ft.js → thread-state-CpdUCQVd.js} +1 -1
- package/web/dist/assets/use-desktop-Bok38AjX.js +1 -0
- package/web/dist/assets/use-hand-to-agent-state-DiBEjj2Y.js +1 -0
- package/web/dist/assets/{useInfiniteQuery-s3lTx_YX.js → useInfiniteQuery-DD7iZHIJ.js} +1 -1
- package/web/dist/assets/useQuery-DVAeyc_X.js +1 -0
- package/web/dist/assets/{workflows-Csr2hbks.js → workflows-Cq6Fg1ZT.js} +1 -1
- package/web/dist/assets/{ws-WW6DrfbT.js → ws-CqtLOaJ8.js} +1 -1
- package/web/dist/index.html +12 -12
- package/web/dist/assets/attention-CVI366xV.js +0 -1
- package/web/dist/assets/git-toolbar-C8agvpYS.js +0 -1
- package/web/dist/assets/index-tN02NX7A.js +0 -17
- package/web/dist/assets/task-github-item-UbCCP2Ud.js +0 -1
- package/web/dist/assets/task-thread-CkiEiypn.js +0 -9
- package/web/dist/assets/use-desktop-Ct4lvA3b.js +0 -1
- package/web/dist/assets/use-hand-to-agent-state-Cnxq_2F6.js +0 -1
- package/web/dist/assets/useQuery-C0ee1rw5.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{E as e,d as t,t as n}from"./button-DGwhwRuD.js";import{t as r}from"./react-runtime-CCIEwYL0.js";import{Ur as i,et as a}from"./project-scope-context-bgdvGX9z.js";import{E as o,P as s,Q as c,ht as l,k as u,n as d,nn as f,q as p}from"./queries-BJM44umy.js";import{Q as m,S as h,y as g}from"./use-desktop-Ct4lvA3b.js";import{I as _,ct as v,m as y}from"./design-icons-DmYTv2r1.js";import{t as b}from"./run-header-Di9LaKQs.js";import{u as x}from"./reference-chip-vraIzoEF.js";import{t as S}from"./project-router-WQWd3UUn.js";import{t as C}from"./centered-state-B5QmAy2y.js";import{E as w,T,an as E}from"./index-tN02NX7A.js";import{n as D,o as O,t as k}from"./use-hand-to-agent-state-Cnxq_2F6.js";var A=r(),j={issue:`Issue`,pr:`Pull request`};function M({kind:t}){let{id:n}=e(),r=l(n);return r.isPending?(0,A.jsx)(T,{kind:t}):r.isError?(0,A.jsx)(w,{tab:`github-item`,error:r.error}):(0,A.jsx)(N,{run:r.data,kind:t})}function N({run:t,kind:r}){let{n:i}=e(),a=Number(i),o=p(),l=c(),d=s(),f=l.isPending||d.isPending,m=g(t,o).some(e=>e.kind===r&&e.number===a),h=u(r,a,m);return(0,A.jsxs)(`div`,{"data-route":`task-github-item`,className:`flex min-h-full flex-col`,children:[(0,A.jsx)(b,{run:t,tab:{kind:r,number:a}}),m?(0,A.jsx)(V,{run:t,kind:r,number:a,repoBase:o,item:h}):f?(0,A.jsx)(T,{kind:r,number:a,heading:`h2`}):(0,A.jsx)(C,{icon:(0,A.jsx)(E,{size:16}),tone:`neutral`,heading:`h2`,title:`#${i} is not linked to this task`,subtitle:`Only the issues and pull requests this task references open here.`,actions:(0,A.jsx)(n,{asChild:!0,variant:`outline`,children:(0,A.jsx)(S,{to:`/tasks/${t.id}`,children:`Back to the session`})})})]})}function P(e,t){return e===`pr`&&t.data?.available===!0&&t.data.item!==null}function F(e,t,n,r){return e===`pr`?n?.[t]??r:r}function I({retry:e,kind:t,number:r}){return(0,A.jsx)(n,{variant:`outline`,disabled:e.isPending,onClick:()=>e.mutate(d.githubItem(t,r)),children:`Retry`})}function L({kind:e,number:t,error:n,retryButton:r}){return(0,A.jsx)(C,{icon:(0,A.jsx)(v,{size:16}),tone:`danger`,heading:`h2`,title:`Could not load ${j[e].toLowerCase()} #${t}`,subtitle:n.message,actions:r})}function R({run:e,kind:r,number:i,repoBase:a,reason:o,retryError:s,retryButton:c}){let l=r===`pr`?_:y,u=h(e,a).find(e=>e.kind===`PR`==(r===`pr`)&&e.number===i)?.url;return(0,A.jsx)(C,{icon:(0,A.jsx)(l,{size:16}),tone:`neutral`,heading:`h2`,title:`GitHub is unavailable`,subtitle:s?.message??o,actions:(0,A.jsxs)(A.Fragment,{children:[c,u&&t(u)?(0,A.jsx)(n,{asChild:!0,variant:`outline`,children:(0,A.jsxs)(`a`,{href:u,target:`_blank`,rel:`noopener noreferrer`,children:[`open on GitHub`,(0,A.jsx)(m,{"aria-hidden":`true`})]})}):null]})})}function z({label:e,repoBase:t}){return(0,A.jsx)(C,{icon:(0,A.jsx)(x,{}),tone:`neutral`,heading:`h2`,title:`${e} was not found in ${H(t)}`,subtitle:`It may have been deleted, or the number points at a different repository.`})}function B({kind:e,item:t,labelColors:n,checks:r}){return(0,A.jsx)(`div`,{className:`min-w-0 px-0.5 md:px-2`,children:(0,A.jsx)(O,{item:t,colors:n??{},checks:r,backLink:null,subNav:null,children:e===`issue`?(0,A.jsx)(U,{item:t},t.url):null})})}function V({run:e,kind:t,number:n,repoBase:r,item:s}){let c=i(),l=f({mutationFn:e=>a(t,n,{refresh:!0}),onSuccess:(e,t)=>c.setQueryData(t,e)}),u=P(t,s),d=o(u?[n]:[],u),p=d.data?.available?d.data.checks:void 0,m=`${j[t]} #${n}`,h=(0,A.jsx)(I,{retry:l,kind:t,number:n});if(s.isPending)return(0,A.jsx)(T,{kind:t,number:n,heading:`h2`});if(s.isError)return(0,A.jsx)(L,{kind:t,number:n,error:l.error??s.error,retryButton:h});let g=s.data;return g.available?g.item?(0,A.jsx)(B,{kind:t,item:g.item,labelColors:g.labelColors,checks:F(t,n,p,g.item.checks)}):(0,A.jsx)(z,{label:m,repoBase:r}):(0,A.jsx)(R,{run:e,kind:t,number:n,repoBase:r,reason:g.reason,retryError:l.error,retryButton:h})}function H(e){if(!e)return`this repository`;try{return new URL(e).pathname.split(`/`).filter(Boolean).slice(0,2).join(`/`)||`this repository`}catch{return`this repository`}}function U({item:e}){let t=k();return(0,A.jsx)(D,{item:e,workflows:t.workflows.data?.workflows??[],skills:t.skillList,workflow:t.workflow,onWorkflowChange:t.setWorkflow,selectedSkills:t.selectedSkills,onSkillsChange:t.setSelectedSkills,engine:t.engine,onEngineChange:t.setEngine,queuedRunId:t.queued.get(e.url)??null,onQueued:t.onQueued},e.url)}export{M as TaskGithubItemRoute};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,E as n,I as r,N as i,d as a,p as o,t as s,u as c,w as l}from"./button-DGwhwRuD.js";import{i as u,r as d,t as f}from"./react-runtime-CCIEwYL0.js";import{n as p}from"./live-refetch-CZb2VOyu.js";import{E as m,Ln as h,P as g,Qn as _,Ur as v,_ as y,ar as b,cr as x,d as S,i as C,l as w,rr as T,w as E,yr as D}from"./project-scope-context-bgdvGX9z.js";import{$ as O,H as ee,L as k,P as A,Qt as j,S as te,St as ne,Tt as M,Xt as N,Yt as P,c as F,d as I,h as L,ht as R,kt as z,lt as re,n as B,nn as V,q as ie,tn as H,wt as ae,yt as oe}from"./queries-BJM44umy.js";import{E as se,L as ce,Q as le,Y as ue,Z as de,_ as fe,b as pe,l as me,n as he,p as ge,q as U,w as _e,z as W}from"./use-desktop-Ct4lvA3b.js";import{n as G}from"./toaster-CoMJoQvk.js";import{A as ve,B as ye,I as be,J as xe,Q as Se,V as Ce,_ as we,b as Te,c as Ee,ct as De,d as K,ft as Oe,h as ke,j as Ae,l as je,n as Me,ot as Ne,p as Pe,pt as Fe,st as Ie,u as Le,y as Re}from"./design-icons-DmYTv2r1.js";import{t as q}from"./createLucideIcon-BHp8sXmF.js";import{_ as ze,a as Be,c as Ve,d as He,f as Ue,g as We,h as Ge,i as Ke,l as qe,m as Je,n as Ye,o as Xe,p as Ze,r as Qe,s as $e,t as et,u as tt,v as nt}from"./run-header-Di9LaKQs.js";import{t as rt}from"./eye-B8okNWXU.js";import{a as it}from"./format-BNCkW110.js";import{t as at}from"./message-square-B-MD-8rD.js";import{a as ot,c as st,i as ct,n as lt,o as ut,r as dt,s as ft,t as pt}from"./thread-state-CajkV5Ft.js";import{i as mt,o as ht,t as gt,u as _t}from"./reference-chip-vraIzoEF.js";import{s as vt,t as J}from"./project-router-WQWd3UUn.js";import"./attention-CVI366xV.js";import{E as yt,S as bt,T as xt,U as St,a as Ct,b as wt,i as Tt,n as Et,r as Dt,t as Ot,w as kt,x as At}from"./agent-accounts-otlDWnij.js";import{n as jt,t as Mt}from"./centered-state-B5QmAy2y.js";import{$ as Nt,$t as Pt,At as Ft,B as It,Ct as Lt,Dt as Rt,Et as zt,Gt as Bt,Ht as Vt,J as Ht,Kt as Ut,L as Wt,Ot as Gt,S as Kt,St as qt,U as Jt,Ut as Yt,Vt as Xt,Wt as Zt,Y as Qt,_ as $t,bt as en,c as Y,cn as tn,dn as nn,et as rn,f as an,i as on,kt as sn,l as X,n as cn,on as ln,s as un,tn as dn,tt as fn,u as Z,w as pn,yt as mn,z as hn}from"./index-tN02NX7A.js";import{t as gn}from"./zoomable-image-C7mEDZaS.js";import{t as _n}from"./report-title-D4Mbu2Er.js";var vn=q(`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`}]]),yn=q(`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`}]]),bn=q(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),xn=q(`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`}]]),Sn=q(`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`}]]),Cn=q(`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`}]]),wn=q(`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`}]]),Q=e(u(),1),$=f(),Tn=12;function En({run:e}){let t=v(),n=V({mutationFn:()=>w(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:B.runs.detail(e.id)}),t.invalidateQueries({queryKey:B.runs.list()}),G(`This task will not resume itself`)},onError:e=>G(e.message,{tone:`danger`})});if(!T(e))return null;let r=new Date(e.autoResumeAt);if(!Number.isFinite(r.getTime()))return null;let i=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(r);return(0,$.jsxs)(`div`,{"data-slot":`auto-resume-hint`,role:`status`,className:`flex flex-wrap items-center gap-x-2 gap-y-1 px-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(Ut,{tone:`neutral`,shape:`ring`}),e.autoResumeReason===`provider-error`?(0,$.jsxs)(`span`,{title:e.error,children:[`Provider error — this task retries automatically at`,` `,(0,$.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i}),` `,`(attempt `,(e.autoResumeAttempts??0)+1,` of `,Tn,`)`]}):(0,$.jsxs)(`span`,{children:[`Usage limit reached — this task resumes automatically at`,` `,(0,$.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i})]}),(0,$.jsx)(`button`,{type:`button`,"data-action":`auto-resume-cancel`,disabled:n.isPending,onClick:()=>n.mutate(),className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground disabled:opacity-50`,children:`Don’t resume`}),(0,$.jsx)(o,{to:`/settings/global/resources`,"data-slot":`auto-resume-settings-link`,className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground`,children:`Auto-resume settings`})]})}function Dn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var On=/^[A-Za-z0-9_./:=+,@%-]+$/;function kn(e){return e.replaceAll(`'`,`'\\''`)}function An(e){return e===``?`''`:On.test(e)?e:`\u0027${kn(e)}\u0027`}function jn(e){if(!Dn(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(An).join(` `)}}function Mn(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 Nn(e){return e.replace(/!\[(?:\\.|[^\]\\])*\]\([^)\s]*(?:\s+"[^"]*")?\)/g,` `)}function Pn(e){return e.replace(/(?<!\\)(?:\*\*|\*|__|~~|`)/g,``).replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/g,`$1`)}function Fn(e){let t=e.trim();return t===``||t.startsWith(`#`)||/^(https?:|mailto:)/i.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t)}function In(e){let t=Mn(Nn(e)),n=new Map;for(let e of t.matchAll(/^\s*\[([^\]]+)\]:\s*(\S+)/gm))Fn(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]){Fn(e[2])&&i.push({label:Pn(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:Pn(e[1]),href:r});continue}let t=(e[4]??e[5])?.replace(/[.,;:!?]+$/,``);t&&Fn(t)&&i.push({label:t,href:t})}return i}var Ln=(0,Q.createContext)(void 0),Rn=(0,Q.createContext)(void 0);function zn(e,t){let n=new Map;for(let r of In(e)){let e=It(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 Bn(e,t){return`report-card-${encodeURIComponent(e)}-${t}`}function Vn({text:e,messageKey:t}){let n=(0,Q.useContext)(hn),r=(0,Q.useContext)(Rn),i=t??r;if(!n||i===void 0)return null;let a=zn(e,n);return a.length===0?null:(0,$.jsx)(`div`,{"data-slot":`report-cards`,className:`flex flex-col gap-3 [margin-block-start:1rem]`,children:a.map(e=>(0,$.jsx)(Hn,{reference:e,messageKey:i},`${e.runId}:${e.artifactId}`))})}function Hn({reference:e,messageKey:n}){let{artifactId:r,runId:i,label:a,href:s}=e,c=(0,Q.useContext)(Ln),u=(0,Q.useContext)(Kt);(0,Q.useLayoutEffect)(()=>u?.register(r,i),[u,r,i]);let d=I(i,r),f=t(),p=l();if(d.isError)return(0,$.jsx)(o,{id:Bn(n,r),"data-slot":`report-card-fallback`,to:s,state:{readerFrom:f.pathname+f.search},children:a});let m=d.data?.artifact;if(m&&!Jt(m.name))return null;let h=new URLSearchParams(f.search);h.set(`report`,r),h.set(`card`,n);let g=new URLSearchParams(f.search).has(`report`)?f.state:null,_=new URLSearchParams(f.search);_.delete(`report`),_.delete(`card`);let v=`${f.pathname}${_.size?`?${_}`:``}`,y=window.navigation,b={reportCardEntry:!0,reportReturnTo:g?.reportReturnTo??v,reportReturnKey:g?.reportReturnKey??y?.currentEntry?.key,reportScrollTop:g?.reportScrollTop},x={pathname:f.pathname,search:`?${h}`,hash:new URL(s,`https://cockpit.invalid`).hash};return(0,$.jsxs)(`section`,{"data-slot":`report-card`,"data-artifact-id":r,"data-report-run-id":i,"aria-busy":d.isPending,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card p-3 text-foreground`,children:[(0,$.jsx)(`h3`,{className:`break-words text-sm font-medium`,children:m?_n(m):a}),(0,$.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`HTML report`}),(0,$.jsx)(o,{id:Bn(n,r),to:x,state:b,onClick:e=>{if(e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault(),c?.(n);let t=b.reportScrollTop??document.querySelector(`[data-slot="main"]`)?.scrollTop;p(x,{state:{...b,reportScrollTop:t}})},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 ${d.isPending?`text-soft-foreground`:`text-accent-text`}`,children:`Read report`})]})}var Un={message:!0,reasoning:!0,tool:!0,hook:!0};function Wn(e){return Object.hasOwn(Un,e)&&Un[e]}var Gn=e=>e.kind===`tool`,Kn=e=>e.kind===`conversation`,qn=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,Jn=(e,t,n)=>`${e} ${e===1?t:n}`;function Yn(e,t){let n=[];return e>0&&n.push(Jn(e,`file`,`files`)),t>0&&n.push(Jn(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function Xn(e){return`${e} earlier tool call${e===1?``:`s`}`}var Zn=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function Qn(e){for(let t of Zn)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t===`Task:`?`Task`:t,detail:e.slice(t.length+1)};return{verb:e}}function $n(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!(e.kind===`reasoning`&&e.text.trim()===``)),n=new Set(t.filter(Gn).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=Wn(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:Yn(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 er(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(Kn(e)){s(),c.push(e);continue}l(),Gn(e)&&qn(e)&&!r.has(e.id)?o.push(e):(s(),Gn(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 er(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 tr=new Map,nr=(0,Q.createContext)(null);function rr(){return(0,Q.useContext)(nr)}function ir({runId:e,children:t}){let n=(0,Q.useMemo)(()=>({get:t=>tr.get(e)?.get(t),set:(t,n)=>{let r=tr.get(e)??new Map;r.set(t,n),tr.set(e,r)}}),[e]);return(0,$.jsx)(nr.Provider,{value:n,children:t})}function ar(e){return e.scrollTop<Math.max(600,e.clientHeight)}function or(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function sr(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 cr(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function lr(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var ur=new Map;function dr(e,t){ur.set(e,t)}function fr(e){return ur.get(e)}var pr=new Map;function mr(e,t){pr.set(e,{...t,...t.rowKeys?{rowKeys:[...t.rowKeys]}:{}})}function hr(e){return pr.get(e)}function gr(e,t,n){let r=pr.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 _r=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}),vr=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),yr=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),br=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),xr=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function Sr(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function Cr(e){let t=Sr(e);return t===void 0?void 0:_r.format(t)}function wr(e){let t=Sr(e);return t===void 0?void 0:vr.format(t)}var Tr=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function Er(e){let t=Sr(e);return t===void 0?void 0:Tr(t)}function Dr(e,t=new Date){let n=Sr(e);if(n===void 0)return;let r=Tr(n);return r===Tr(t)?`Today`:r===Tr(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?yr:br).format(n)}function Or(e,t){let n=Sr(e),r=Sr(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 kr({ts:e}){let t=Cr(e);return t===void 0?null:(0,$.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:wr(e),className:`text-[11px] leading-none text-soft-foreground`,children:t})}function Ar({startedAt:e,completedAt:t}){let n=Cr(t);if(n===void 0)return null;let r=Or(e,t);return(0,$.jsxs)(`div`,{"data-slot":`turn-time`,className:`flex items-center gap-1.5 px-0.5 text-[11px] leading-none text-soft-foreground`,children:[(0,$.jsx)(`time`,{dateTime:t,title:wr(t),children:n}),r===void 0?null:(0,$.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function jr({ts:e}){let t=Dr(e),n=Sr(e);if(t===void 0||n===void 0)return null;let r=xr.format(n);return(0,$.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-[11px] font-medium text-soft-foreground`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),(0,$.jsx)(`time`,{dateTime:Er(e),title:r,children:t}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}var Mr={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 Nr({role:e,children:t,className:n,ts:r,headerActions:i,...a}){let o=Mr[e],s=r===void 0?void 0:Cr(r);return(0,$.jsxs)(`article`,{...a,"data-role":e,"aria-label":o.speaker,className:c(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,o.classes,n),children:[(0,$.jsxs)(`p`,{className:c(`m-0 flex w-full min-w-0 items-start gap-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,o.accent),children:[(0,$.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,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 uppercase tracking-[0.6px]`,children:[(0,$.jsx)(at,{"aria-hidden":`true`,className:`size-4 shrink-0`}),o.label]}),i]}),s===void 0?null:(0,$.jsx)(`span`,{className:`shrink-0 font-normal tracking-normal normal-case`,children:(0,$.jsx)(kr,{ts:r})})]}),(0,$.jsx)(`div`,{className:c(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,o.body,`leading-[1.6]`),children:t})]})}function Pr({text:e,imageCount:t=0,images:n=[],ts:r,onEdit:a,onRemove:o,editLabel:s=`Edit message`,removeLabel:c=`Remove message`,children:l}){let u=t-n.length,[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(e),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(),y=()=>{m(e),v(void 0),f(!0)},b=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,$.jsxs)(Nr,{role:`user`,ts:r,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,$.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(),b())},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,$.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,$.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,$.jsx)(`button`,{type:`button`,onClick:()=>void b(),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,$.jsx)(it,{className:`size-3.5 animate-spin`}):`Save`})]}),_?(0,$.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:_}):null]}):(0,$.jsxs)(Nr,{role:`user`,ts:r,"data-slot":`user-bubble`,className:`group`,children:[a||o?(0,$.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,$.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,$.jsx)(wn,{className:`size-3.5`})}):null,o?(0,$.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,$.jsx)(Ie,{className:`size-3.5`})}):null]}):null,_?(0,$.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:_}):null,l??(0,$.jsx)(Wt,{breaks:!0,children:e}),n.length>0?(0,$.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>x(e.split(`/`).pop()??``)?(0,$.jsx)(gn,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,$.jsxs)(`a`,{href:i(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,$.jsx)(xe,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,u>0?(0,$.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[u,` image`,u>1?`s`:``,` attached`]}):null]})}var Fr=`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`,Ir=[`[data-streamdown="code-block-actions"]`,`[data-streamdown="code-copy-button"]`,`[data-streamdown="code-block-copy-button"]`,`[data-streamdown="code-block-header"]`].join(`,`);function Lr(e,t){let n=e.cloneNode(!0);n.querySelectorAll(Ir).forEach(e=>e.remove());let r=In(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||!Fn(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 Rr(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=Lr(n,t);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:`text/html`}),"text/plain":new Blob([t],{type:`text/plain`})})])}function zr({text:e,ts:t,messageKey:n}){let r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null),c=(0,Q.useRef)(null);(0,Q.useEffect)(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);let l=async t=>{c.current!==null&&clearTimeout(c.current),a(null),s(null);try{await Rr(t,e,r.current),a(t),c.current=setTimeout(()=>a(null),2e3)}catch{s(`Couldn't copy to the clipboard`)}};return(0,$.jsxs)(Nr,{role:`agent`,ts:t,"data-slot":`assistant-message`,headerActions:(0,$.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`flex items-center gap-0.5`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply`,onClick:()=>void l(`html`),className:Fr,children:[(0,$.jsx)(Re,{className:`size-3.5`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{"aria-live":`polite`,children:i===`html`?`Copied`:`Copy`})]}),(0,$.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply as markdown`,onClick:()=>void l(`markdown`),className:Fr,children:[(0,$.jsx)(tn,{className:`size-3.5`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{"aria-live":`polite`,children:i===`markdown`?`Copied`:`Copy markdown`})]})]}),children:[o?(0,$.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:o}):null,(0,$.jsx)(`div`,{ref:r,children:(0,$.jsx)(Wt,{breaks:!0,children:e})}),(0,$.jsx)(Vn,{text:e,messageKey:n})]})}function Br({note:e}){return e.icon===`handoff`?(0,$.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,$.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,$.jsx)(dn,{className:`size-3`})}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}):(0,$.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:c(`px-0.5 text-xs`,e.tone===`danger`?`text-danger [.light_&]:text-red-700`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:`· `,e.text]})}function Vr({incident:e}){let t=j(e.provider);return(0,$.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,$.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,t,` authorization`]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,t,` settings before retrying.`]}),(0,$.jsx)(J,{to:`/settings/agents#providers`,className:`mt-2 inline-flex text-xs font-medium text-foreground underline-offset-2 hover:underline`,children:`Open provider settings`})]})}function Hr({text:e}){let t=(0,Q.useId)();if(e.trim()===``)return null;let n=e.split(`
|
|
2
|
-
`,1)[0]??``,r=n.length<e.length;return(0,$.jsxs)(Y,{"data-slot":`reasoning`,className:`group/reasoning min-w-0`,children:[(0,$.jsxs)(`div`,{id:t,className:`relative flex w-full items-center gap-1.5 rounded-md p-0.5 text-left text-[13px] text-soft-foreground hover:text-muted-foreground`,children:[(0,$.jsx)(K,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/reasoning:rotate-90`}),(0,$.jsx)(`span`,{className:`shrink-0`,children:`Thinking — `}),(0,$.jsx)(`div`,{className:`min-w-0 truncate text-muted-foreground`,children:(0,$.jsx)(Wt,{inline:!0,children:n})}),r?(0,$.jsx)(`span`,{"aria-hidden":!0,children:`…`}):null,(0,$.jsx)(Z,{"aria-labelledby":t,className:`absolute inset-0 rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`})]}),(0,$.jsx)(X,{children:(0,$.jsx)(`div`,{className:`px-6 py-1.5 text-[13px] leading-[1.6] text-soft-foreground`,children:(0,$.jsx)(Wt,{children:e})})})]})}function Ur(){return(0,$.jsxs)(`div`,{"data-slot":`working-indicator`,className:`flex items-center gap-2 py-1 text-[13px] text-soft-foreground`,children:[(0,$.jsx)(it,{role:`status`,"aria-label":`Working`,className:`size-3.5 shrink-0 animate-spin`}),(0,$.jsx)(`span`,{className:`shimmer font-medium`,children:`Working…`})]})}var Wr={read:tn,edit:wn,delete:Ie,move:Sn,search:Se,execute:Pt,think:yn,fetch:ln,task:Ee,plan:Ce,other:Fe},Gr=e=>e.split(`
|
|
3
|
-
`).length;function Kr({text:e,streaming:t}){let[n,r]=(0,Q.useState)(!1),i=(0,Q.useRef)(null),a=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{let e=i.current;t&&e&&a.current&&(e.scrollTop=e.scrollHeight)},[e,t]);let o=Gr(e),s=!t&&!n&&o>12;return(0,$.jsxs)(`div`,{"data-slot":`tool-output`,"data-clamped":s?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`div`,{ref:i,onScroll:t?e=>{a.current=cr(e.currentTarget)}:void 0,className:c(`overflow-x-auto`,t&&`max-h-[216px] overflow-y-auto`,s&&`max-h-[216px] overflow-y-hidden`),children:(0,$.jsx)(`pre`,{className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre text-muted-foreground`,children:e})}),s?(0,$.jsx)(`div`,{"data-slot":`tool-output-fade`,"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-14 bg-gradient-to-b from-transparent to-card-2`}):null]}),!t&&o>12?(0,$.jsx)(`button`,{type:`button`,"data-slot":`tool-output-toggle`,onClick:()=>r(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-[11px] font-medium text-soft-foreground hover:text-foreground`,children:n?`Show less`:`Show all ${o} lines`}):null]})}function qr({diffs:e}){return(0,$.jsx)($.Fragment,{children:e.map((e,t)=>(0,$.jsxs)(`div`,{"data-slot":`diff-preview`,className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`border-b border-border/50 px-4 py-1.5 font-mono text-[11px] wrap-anywhere text-muted-foreground`,children:e.path}),(0,$.jsx)(`pre`,{className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:e.unified===void 0?[...Jr(e.oldText).map((e,t)=>(0,$.jsxs)(`span`,{className:`block bg-diff-del px-4 text-muted-foreground`,children:[`- `,e]},`old-${t}`)),...Jr(e.newText).map((e,t)=>(0,$.jsxs)(`span`,{className:`block bg-diff-add px-4`,children:[`+ `,e]},`new-${t}`))]:e.unified.split(`
|
|
4
|
-
`).map((e,t)=>(0,$.jsx)(Yr,{text:e},t))})]},`${e.path}:${t}`))})}function Jr(e){return e==null||e===``?[]:e.replace(/\n$/,``).split(`
|
|
5
|
-
`)}function Yr({text:e}){return(0,$.jsx)(`span`,{className:c(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del text-muted-foreground`,e.startsWith(`@@`)&&`text-soft-foreground`),children:e})}function Xr(e){return e.toolKind===`execute`&&e.status===`running`&&e.output!==void 0}function Zr(e){let t=e.status===`running`||e.status===`pending`,n=Qn(e.title),{verb:r,detail:i}=e.toolKind===`execute`&&n.detail===void 0?{verb:`Ran`,detail:e.title}:n;return{busy:t,verb:r,detail:i,expandedCommand:(e.toolKind===`execute`?jn(e.input):ft(e.name).toolKind===e.toolKind?ut(e.name,e.input):void 0)??i,Icon:Wr[e.toolKind]??Fe}}function Qr(e,t){return e.output!==void 0&&e.output!==``||e.error!==void 0&&e.error!==``||e.diffs!==void 0&&e.diffs.length>0||t>0}function $r({item:e,busy:t}){return(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[t?(0,$.jsx)(it,{role:`status`,"aria-label":`Running`,className:`size-3.5 animate-spin text-soft-foreground`}):null,e.status===`failed`?(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`failed`}):null,e.status===`declined`?(0,$.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`declined`}):null,e.toolKind===`execute`&&typeof e.exitCode==`number`?(0,$.jsx)(`span`,{"data-slot":`tool-exit`,className:c(`rounded-full px-2 py-px font-mono text-[11px] font-semibold`,e.exitCode===0?`bg-success/10 text-success`:`bg-danger/10 text-danger`),children:e.exitCode}):null]})}function ei({item:e,command:t,busy:n,nested:r,cacheKey:i,renderNested:a}){return(0,$.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[t===void 0?null:(0,$.jsx)(`pre`,{"data-slot":`tool-command`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:t}),e.error!==void 0&&e.error!==``?(0,$.jsx)(`div`,{"data-slot":`tool-error`,className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre-wrap wrap-anywhere text-signal-word-red`,children:e.error}):null,e.diffs!==void 0&&e.diffs.length>0?(0,$.jsx)(qr,{diffs:e.diffs}):null,e.output!==void 0&&e.output!==``?(0,$.jsx)(Kr,{text:e.output,streaming:n}):null,r.length>0?(0,$.jsx)(`div`,{"data-slot":`tool-nested`,className:`flex flex-col gap-2 border-l-2 border-border py-2.5 pr-3 pl-3 ml-4 my-2`,children:a?.(r,i??e.id)}):null]})}function ti({item:e,nested:t=[],cacheKey:n,renderNested:r}){let i=rr(),[a,o]=(0,Q.useState)(()=>n===void 0?null:i?.get(n)??null),s=e=>{n!==void 0&&i?.set(n,e),o(e)},{busy:l,verb:u,detail:d,expandedCommand:f,Icon:p}=Zr(e),m=Qr(e,t.length),h=f!==void 0||m,g=h&&(a??(m&&Xr(e)));return(0,$.jsxs)(Y,{"data-slot":`tool-card`,"data-status":e.status,"data-kind":e.toolKind,open:g,onOpenChange:s,className:c(`min-w-0 overflow-hidden rounded-md border bg-card`,e.status===`failed`?`border-danger/25`:`border-border`),children:[(0,$.jsxs)(Z,{disabled:!h,className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] enabled:hover:bg-muted`,children:[(0,$.jsx)(K,{"aria-hidden":!0,className:c(`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`,!h&&`invisible`)}),(0,$.jsx)(p,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:c(`shrink-0 font-semibold`,l&&`shimmer`,e.status===`declined`&&`text-muted-foreground`),children:u}),d===void 0?null:(0,$.jsx)(`code`,{title:d,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:d}),(0,$.jsx)($r,{item:e,busy:l})]}),(0,$.jsx)(X,{children:(0,$.jsx)(ei,{item:e,command:f,busy:l,nested:t,cacheKey:n,renderNested:r})})]})}function ni(e){let t=e.name??e.event,n=t.indexOf(`:`);return n>0?`${t.slice(0,n)} · ${t.slice(n+1)}`:t}function ri({item:e,cacheKey:t}){let n=rr(),[r,i]=(0,Q.useState)(()=>t===void 0?!1:n?.get(t)??!1),a=e=>{t!==void 0&&n?.set(t,e),i(e)},o=e.status!==`completed`,s=e.entries.some(e=>e.kind===`context`),l=(e.stdout??``)!==``||(e.stderr??``)!==``,u=ni(e);return(0,$.jsxs)(Y,{"data-slot":`hook-card`,"data-status":e.status,open:r,onOpenChange:a,className:c(`min-w-0 overflow-hidden rounded-md border bg-card`,o?`border-danger/25`:`border-border`),children:[(0,$.jsxs)(Z,{className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] hover:bg-muted`,children:[(0,$.jsx)(K,{"aria-hidden":!0,className:`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),(0,$.jsx)(vn,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Hook`}),(0,$.jsx)(`code`,{title:u,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:u}),(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[o?(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.status}):s?(0,$.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`context`}):null,o&&typeof e.exitCode==`number`&&e.exitCode!==0?(0,$.jsx)(`span`,{"data-slot":`hook-exit`,className:`rounded-full bg-danger/10 px-2 py-px font-mono text-[11px] font-semibold text-danger`,children:e.exitCode}):null]})]}),(0,$.jsx)(X,{children:(0,$.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[e.entries.map((e,t)=>(0,$.jsx)(`pre`,{"data-slot":`hook-entry`,"data-kind":e.kind,className:c(`px-3 py-2 font-mono text-xs leading-[1.7] whitespace-pre-wrap [overflow-wrap:anywhere]`,(e.kind===`error`||e.kind===`stop`)&&`text-signal-word-red`),children:e.text},t)),e.source===void 0?null:(0,$.jsx)(`p`,{"data-slot":`hook-source`,className:`px-3 pb-2 font-mono text-[11px] text-muted-foreground [overflow-wrap:anywhere]`,children:e.source}),l?(0,$.jsxs)(Y,{className:`border-t border-border`,children:[(0,$.jsxs)(Z,{"data-slot":`hook-raw-toggle`,className:`group flex w-full items-center gap-1 px-3 py-1 text-left text-xs text-muted-foreground hover:text-foreground`,children:[(0,$.jsx)(K,{"aria-hidden":!0,className:`size-3 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),`Raw output${typeof e.exitCode==`number`?` · exit ${e.exitCode}`:``}`]}),(0,$.jsxs)(X,{children:[e.stdout?(0,$.jsx)(`pre`,{"data-slot":`hook-stdout`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.stdout}):null,e.stderr?(0,$.jsx)(`pre`,{"data-slot":`hook-stderr`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap text-signal-word-red [overflow-wrap:anywhere]`,children:e.stderr}):null]})]}):null]})})]})}function ii({group:e,scope:t}){return(0,$.jsxs)(Y,{"data-slot":`ctx-group`,className:`min-w-0`,children:[(0,$.jsxs)(Z,{className:`group flex h-[34px] tabular-nums w-full items-center gap-2 rounded-md px-2 -mx-2 text-left text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,$.jsx)(K,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),e.label]}),(0,$.jsx)(X,{children:(0,$.jsx)(`div`,{className:`flex flex-col gap-1.5 pt-1.5 pl-4`,children:e.tools.map(e=>(0,$.jsx)(ti,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`},e.id))})})]})}function ai({count:e,children:t}){return(0,$.jsxs)(Y,{"data-slot":`tool-streak`,className:`min-w-0`,children:[(0,$.jsxs)(Z,{className:`group flex items-center gap-1.5 rounded-md p-0.5 tabular-nums text-left text-xs text-soft-foreground hover:text-muted-foreground`,children:[(0,$.jsx)(K,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),Xn(e)]}),(0,$.jsx)(X,{children:(0,$.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t})})]})}function oi({image:e}){return(0,$.jsx)(gn,{"data-slot":`thread-image`,src:e.url,alt:e.name??`image from the agent session`,className:`max-h-72 max-w-full self-start rounded-lg border border-border`})}function si(e){return e.needsConfig&&e.configPending?`Checking task settings…`:e.needsConfig&&e.configError?`Task settings could not be loaded.`:e.providersPending?`Checking agent providers…`:e.providersError?`Provider authentication could not be verified.`:e.canContinue?void 0:e.untouched?`Connect the required workflow providers (${e.missing.join(`, `)}) to continue.`:`Connect an agent provider to continue.`}function ci(e,t=null){let n=O(),r=L(),i=Lt(e),a=i&&!e.runner,o=D(n.data),s=e.runner??(i?r.data?.defaultRunner:void 0)??`claude`,c=yt(t,o,s),l=o.includes(s),u=(i?b(e.workflowDef,c):[c]).filter(e=>!o.includes(e)),d=n.isSuccess&&(!a||r.isSuccess)&&u.length===0,f=si({needsConfig:a,configPending:r.isPending,configError:r.isError,providersPending:n.isPending,providersError:n.isError,canContinue:d,untouched:i,missing:u});return{runners:o,currentRunner:s,runner:c,currentRunnerConnected:l,canContinue:d,providerPending:n.isPending||a&&r.isPending,providerError:n.isError,reason:f,runnerOverride:t!==null||!l?c:void 0}}function li(e,t,n,r,i,a,o,s){let c=!r&&!n&&e.model?{...i?.defaultModels,[t]:e.model}:i?.defaultModels,l=r?null:o,u=bt(t,a,[l,c?.[t]]),d=xt(l,t,c,a),f=wt(t,d,a),p=r?``:s??e.effort??``,m=kt(p,f);return{models:u,model:d,effortOptions:f,effort:m,mustClearStoredEffort:!r&&s===null&&p!==``&&m===``}}function ui(e,t,n,r,{accounts:i,repoAccount:a},o){let s=[...e.steps].reverse().find(e=>e.sessionId),c=s?.profileId??e.agentProfile??`default`;return{sessionStep:s,accountDefaults:r?a:{...a,[n]:c},account:i.some(e=>e.provider===t&&e.id===o)?o:null}}function di(e,t,n,r,i,a,o,{model:s,effort:c,mustClearStoredEffort:l},u){return{text:e.trim()?e:void 0,images:t.length?t:void 0,runner:n,model:!r&&(a!==null||i)?s:void 0,effort:!r&&(o!==null||i)?c:l?``:void 0,agentProfile:u??void 0}}function fi(e,t,n,r,i){return!!t&&(n!==(t.backend??r)||(i??e.agentProfile??t.profileId??`default`)!==(t.profileId??`default`))}function pi({models:e,model:t,effortOptions:n,effort:r}){return{modelLabel:e.find(e=>e.id===t)?.label??`auto`,effortLabel:n.find(e=>e.value===r)?.label??`auto`}}function mi(e){let t=P(),n=sn(e).continueRun,r=L(),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(e.id);f!==e.id&&(p(e.id),a(null),s(null),l(null),d(null));let m=ci(e,i),{runners:h,canContinue:g,currentRunner:_,runner:v}=m,b=ae(v,n),x=r.data?.modelsLocked===!0,S=v!==_,w=li(e,v,S,x,r.data,b.data,o,c),{models:T,model:E,effortOptions:D,effort:O}=w,{modelLabel:ee,effortLabel:k}=pi(w),A=Et(),{accounts:j}=A,{sessionStep:te,accountDefaults:ne,account:M}=ui(e,v,_,S,A,u),N=V({mutationFn:({text:t,images:n})=>g?y(H(e.id),di(t,n,m.runnerOverride,x,S,o,c,w,M)):Promise.reject(Error(m.reason??`Connect an agent provider to continue.`)),onMutate:()=>H(e.id),onSuccess:(e,n,r)=>t.invalidateAfter(`continue`,r),onError:(e,n,r)=>{e instanceof C&&e.status===409&&r&&t.invalidateAfter(`continue`,r)}});return{available:n,canContinue:g,startsNewConversation:fi(e,te,v,_,M),reason:m.reason,providerPending:m.providerPending,pills:(0,$.jsx)(`div`,{"data-slot":`follow-up-engine`,className:`session-engine-controls`,children:(0,$.jsxs)(Tt,{children:[h.length>1||h.some(e=>Ot(j,e))?(0,$.jsx)(Ct,{icon:(0,$.jsx)(Ne,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:h,value:v,accounts:j,account:M,repoAccount:ne,onPick:(e,t)=>{d(t),e!==v&&(a(e),s(null))}}):(0,$.jsx)(Dt,{icon:(0,$.jsx)(Ne,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,readOnly:!0,slot:`session-runner-value`,ariaLabel:`Runner`,label:v,value:v,onPick:()=>{},options:[{value:v,label:v}]}),(0,$.jsx)(Dt,{icon:(0,$.jsx)(Te,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-model-pill`,ariaLabel:`Model`,label:ee,value:E,readOnly:x,disabledHint:`Model selection is locked to native coding-agent settings.`,onPick:e=>{s(e);let t=wt(v,e,b.data);O!==``&&kt(O,t)===``&&l(``)},options:T.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:At(v,b.data,b.isError,b.isFetching)}),(0,$.jsx)(Dt,{icon:(0,$.jsx)(ve,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-effort-pill`,ariaLabel:`Effort`,label:k,value:O,readOnly:x,disabledHint:`Effort selection is locked to native coding-agent settings.`,onPick:e=>l(e),options:D.map(e=>({value:e.value,label:e.label,desc:e.desc}))})]})}),continueWith:(e,t)=>N.mutateAsync({text:e,images:t})}}var hi=120,gi=e=>e!==`pending`&&e!==`running`,_i=e=>e.kind===`tool`&&e.toolKind===`task`,vi=e=>_i(e)&&e.parentItemId===void 0,yi=e=>Wn(e.kind)&&!(e.kind===`tool`&&e.toolKind===`plan`);function bi(e){let t=e.input;if(typeof t!=`object`||!t)return;let n=t;for(let e of[`subagent_type`,`subagentType`,`agent`]){let t=n[e];if(typeof t==`string`&&t.trim()!==``)return t.trim()}}function xi(e){if(e.kind===`tool`)return Si(e.title);if(e.kind===`hook`)return Si(`${e.event} hook${e.status===`completed`?``:` ${e.status}`}`);if(e.kind===`message`||e.kind===`reasoning`){let t=e.text.split(`
|
|
6
|
-
`);for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n!==``)return Si(n)}}}function Si(e){return e.length>hi?`${e.slice(0,hi-1).trimEnd()}…`:e}function Ci(e,t=!1,n=e){let r=Di(e,e=>e.items.some(vi));if(r===-1)return[];let i=e=>!t&&!gi(e.status),a=e=>i(e)&&e.background===!0,o=[],s=!1;for(let t=r-1;t>=0;--t){let n=e[t].items.filter(vi);n.length!==0&&(!s&&!n.some(i)&&(s=!0),(!s||n.some(a))&&o.unshift(...n))}let c=[...o,...e[r].items.filter(vi)];return r!==e.length-1&&!c.some(i)?[]:c.map(r=>wi(r,ji(n,e,r.id),t))}function wi(e,t,n){let r={id:e.id,title:Qn(e.title).detail??e.title,status:e.status,toolCalls:t.filter(e=>e.kind===`tool`).length},i=bi(e);i!==void 0&&(r.agentType=i),n&&!gi(e.status)&&(r.stalled=!0);for(let e=t.length-1;e>=0;--e){let n=xi(t[e]);if(n!==void 0){r.activity=n;break}}return r}function Ti(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.length}}function Ei(e){return e.activity??(e.stalled===!0?`never finished`:`starting…`)}function Di(e,t){for(let n=e.length-1;n>=0;--n)if(t(e[n]))return n;return-1}function Oi(e,t,n=!1,r=e){for(let i=e.length-1;i>=0;--i){let a=e[i].items.find(e=>e.id===t&&vi(e));if(a!==void 0)return wi(a,ji(r,e,t),n)}}function ki(e,t){return Di(e,e=>e.items.some(e=>e.id===t&&vi(e)))}function Ai(e,t,n){let r=[];for(let i=n;i<e.length;i+=1){let n=e[i];for(let e of n.items)yi(e)&&e.parentItemId===t&&e.id!==t&&r.push({entry:e,seqs:n.itemSeqs?.get(e.id)})}return r}function ji(e,t,n){let r=ki(t,n);if(r===-1)return[];let i=Ai(t,n,r);if(e===t)return i.map(({entry:e})=>e);let a=t[r].itemSeqs?.get(n)?.first,o=e=>a===void 0||e.seqs===void 0||e.seqs.first>a,s=new Map;for(let t of Ai(e,n,Math.max(ki(e,n),0)))o(t)&&!s.has(t.entry.id)&&s.set(t.entry.id,t);for(let e of i){let t=s.get(e.entry.id);s.set(e.entry.id,t===void 0?e:Mi(t,e))}return[...s.values()].sort(Ni).map(({entry:e})=>e)}function Mi(e,t){return e.seqs===void 0||t.seqs===void 0?e:{entry:(t.seqs.last>e.seqs.last?t:e).entry,seqs:{first:Math.min(e.seqs.first,t.seqs.first),last:Math.max(e.seqs.last,t.seqs.last)}}}function Ni(e,t){return e.seqs===void 0||t.seqs===void 0?0:e.seqs.first-t.seqs.first}function Pi(e,t){if(e.kind===`entry`){let n=e.entry;return n.kind===`message`&&n.role===`assistant`?[{messageKey:`${t}:${n.id}`,text:n.text}]:[]}return e.kind===`tool-card`?$n(e.children).flatMap(n=>Pi(n,`${t}:${e.id}`)):e.kind===`streak`?e.blocks.flatMap(e=>Pi(e,t)):[]}function Fi(e){return e.flatMap((e,t)=>e.content.kind===`block`?Pi(e.content.block,e.scope).map(n=>({...n,rowKey:e.key,rowIndex:t})):[])}function Ii(e,t,r,i){let a=(0,Q.useContext)(Kt),{projectId:o}=n(),s=(0,Q.useMemo)(()=>Fi(t),[t]);(0,Q.useLayoutEffect)(()=>{if(!a)return;let t=[],n={runId:e,...o?{projectId:o}:{}};for(let e of s){let o=zn(e.text,n);for(let e of o)t.push(a.register(e.artifactId,e.runId));i===`document`&&o.length>0&&t.push(a.registerOpener(e.messageKey,(t,n)=>{let i=Bn(e.messageKey,t);r.jumpToRow(e.rowKey,e.rowIndex,e=>[...e.querySelectorAll(`[id]`)].find(e=>e.id===i)??null,n)}))}return()=>{for(let e of t)e()}},[a,s,e,o,i,r.jumpToRow])}function Li(e){let t=v();return V({mutationFn:t=>m(e,t),retry:!1,networkMode:`always`,onSettled:()=>{t.invalidateQueries({queryKey:B.runs.all})}})}var Ri=e=>(window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}),zi=()=>navigator.onLine;function Bi({permission:e,runId:t,sessionOpen:n=!1}){return e.status!==`pending`||!n?(0,$.jsx)(Hi,{permission:e,state:e.status===`resolved`?`resolved`:`expired`}):(0,$.jsx)(Vi,{permission:e,runId:t},e.requestId)}function Vi({permission:e,runId:t}){let n=Li(t),r=(0,Q.useSyncExternalStore)(Ri,zi,()=>!1),i=(0,Q.useRef)(!1),[a,o]=(0,Q.useState)(`pending`),[s,c]=(0,Q.useState)(),[l,u]=(0,Q.useState)(),d=async t=>{if(!(i.current||!r||a!==`pending`)){i.current=!0,o(`sending`),u(void 0);try{await n.mutateAsync({requestId:e.requestId,optionId:t}),c(t),o(`resolved`)}catch(e){e instanceof C&&e.status===409?o(`expired`):(u(e instanceof Error?e.message:String(e)),o(`pending`))}finally{i.current=!1}}};return(0,$.jsx)(Hi,{permission:{...e,...s===void 0?{}:{optionId:s}},state:a,offline:!r,error:l,onSelect:e=>{d(e)}})}function Hi({permission:e,state:t,offline:n=!1,error:r,onSelect:i}){let a=(0,Q.useId)(),o=e.options.find(t=>t.id===e.optionId),c=t!==`pending`||n||!i,l=t===`expired`?`Approval expired. This session can no longer accept a decision.`:t===`resolved`?`Decision sent: ${o?.label??`Recorded`}.`:t===`sending`?`Sending decision…`:n?`Offline. Reconnect to send a decision.`:`Choose an option to respond to this permission request.`;return(0,$.jsxs)(`section`,{"data-slot":`permission-card`,"data-request-id":e.requestId,"data-state":n&&t===`pending`?`offline`:t,"aria-labelledby":a,"aria-busy":t===`sending`,className:`flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-card p-3.5 text-sm [overflow-wrap:anywhere]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Permission request`}),(0,$.jsx)(`h3`,{id:a,className:`font-semibold whitespace-pre-wrap`,children:e.title})]}),e.details?(0,$.jsx)(`pre`,{className:`min-w-0 font-mono text-xs leading-relaxed whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.details}):null,(0,$.jsx)(`div`,{role:`group`,"aria-labelledby":a,className:`flex min-w-0 flex-col gap-2`,children:e.options.map(t=>(0,$.jsx)(s,{type:`button`,variant:`outline`,disabled:c,"aria-pressed":e.optionId===t.id,className:`h-auto min-h-11 min-w-0 max-w-full justify-start py-2 text-start whitespace-normal [overflow-wrap:anywhere] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,onClick:()=>i?.(t.id),children:t.label},t.id))}),(0,$.jsxs)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:[l,e.reason?` ${e.reason}`:``]}),r&&t===`pending`?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r}):null]})}function Ui(e,t){if(e.length===1)return[t.replace(RegExp(`^${Wi(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 Wi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Gi(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]:[]}function Ki({ask:e}){let t=e.answer===void 0?void 0:Ui(e.questions,e.answer);return(0,$.jsxs)(`div`,{"data-slot":`ask-answers`,className:`flex flex-col gap-4 text-sm`,children:[e.questions.map((n,r)=>{let i=t?.[r],a=Gi(n,i),o=i!==void 0&&a.length===0;return(0,$.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":n.question,children:[(0,$.jsxs)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:[n.header,` · Question `,r+1,` of `,e.questions.length]}),(0,$.jsx)(`p`,{className:`break-words font-semibold`,children:n.question}),n.options?(0,$.jsxs)(`ul`,{className:`flex list-none flex-col gap-1.5`,children:[n.options.map(e=>(0,$.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,$.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-message-user-accent`,children:a.includes(e.label)?`✓`:`○`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description}):null]}),a.includes(e.label)?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-message-user-accent`,children:`Selected`}):null]},e.label)),(0,$.jsxs)(`li`,{"data-selected":o,className:`rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2 font-medium`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-message-user-accent`,children:o?`✓`:`○`}),(0,$.jsx)(`span`,{className:`flex-1`,children:`Other`}),o?(0,$.jsx)(`span`,{className:`text-xs text-message-user-accent`,children:`Selected`}):null]}),o?(0,$.jsx)(qi,{text:i}):null]})]}):i===void 0?null:(0,$.jsx)(qi,{text:i})]},n.id??r)}),!t&&e.answer!==void 0?(0,$.jsx)(qi,{text:e.answer}):null]})}function qi({text:e}){return(0,$.jsx)(`blockquote`,{className:`[margin-block-start:0.5rem] border-s-2 border-message-user-accent ps-3 break-words whitespace-pre-wrap`,children:e})}var Ji=(0,Q.createContext)({targets:new Map,replies:new Map,navigate:()=>{}});function Yi(e,t){let n={};for(let e of t??[])n[e.id]=e.currentStepBackend??e.runner;return n[e.id]=e.steps.find(t=>t.id===e.currentStepId)?.backend??e.runner,n}function Xi(e,t,n=[]){let r={};for(let e of n)r[e.id]=W(e);for(let e of t??[])r[e.id]=W(e);return r[e.id]=W(e),r}function Zi(e,t){return t?.[e]??`Task`}function Qi(e,t,n){return t?n?.[e]??`peer task`:Zi(e,n)}function $i(e,t){return e.senderRunId===t?`outbound`:`inbound`}function ea(e){return e?.relationship===`peer`}function ta(e){switch(e){case`request`:return`Request`;case`progress`:return`Progress`;case`follow-up`:return`Follow-up`;case`reply`:return`Reply`}}function na(e){switch(e){case`pending`:return`Pending`;case`replied`:return`Replied`;case`replied-late`:return`Replied late`;case`timed-out`:return`Timed out`;case`cancelled`:return`Cancelled`;case`completed-without-reply`:return`Completed without reply`;case`failed`:return`Failed`;case`destroyed`:return`Destroyed`;case`sender-closed`:return`Sender closed`;case`human-fallback`:return`Sent to a human`;case`deleted`:return`Recipient deleted`}}function ra(e){if(e.outcome)return na(e.outcome.status);if(e.delivery===`not-delivered`)return ia(`not-delivered`)}function ia(e){switch(e){case`queued`:return`Queued`;case`delivered`:return`Delivered`;case`consumed`:return`Read`;case`not-delivered`:return`Not delivered`}}function aa(e,t){return e.instruction===void 0?e.delivery===`queued`?`${t&&N[t].inputMode===`boundary`?`Queued for delivery. If ${j(t)} is in a turn, delivery waits for that turn to end.`:t?`Queued for delivery. This agent can receive messages during its current turn.`:`Queued for delivery. Timing depends on the recipient agent.`} Pending messages are batched within the size limit; human questions and scheduler capacity can delay delivery.`:e.state===`continuation-required`?ea(e)?`Not delivered. The recipient is not running. Only its human can continue it.`:`Not delivered. The recipient needs a new instruction to resume. A parent can resume its owned worker with ${r()} worker resume; workers cannot resume parents.`:e.state===`destroyed`?`Not delivered. This worker was destroyed.`:void 0:e.instruction}function oa({id:e,peer:t,taskTitles:n,children:r}){return!t||n?.[e]!==void 0?r({title:Zi(e,n),linkable:!0}):(0,$.jsx)(sa,{id:e,children:r})}function sa({id:e,children:t}){let n=R(e);return n.data?t({title:W(n.data),linkable:!0}):n.isPending?t({title:`Peer task`,linkable:!1}):t({title:n.error instanceof C&&n.error.status===404?`Deleted task`:`Task unavailable`,linkable:!1})}var ca={outbound:{classes:`border-message-outbound-border bg-message-outbound-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-outbound-accent`,accent:`text-message-outbound-accent`},inbound:{classes:`border-message-inbound-border bg-message-inbound-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-inbound-accent`,accent:`text-message-inbound-accent`},peer:{classes:`border-message-peer-border bg-message-peer-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-peer-accent`,accent:`text-message-peer-accent`}},la=`inline-flex min-h-11 max-w-full items-center break-words underline underline-offset-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`;function ua({block:e,runId:t,taskTitles:n,recipientBackends:r}){return(0,$.jsx)(`div`,{"data-slot":`worker-conversation`,className:`flex min-w-0 flex-col gap-2`,children:e.batches.map(e=>(0,$.jsx)(da,{batch:e,runId:t,taskTitles:n,recipientBackends:r},e.id))})}function da({batch:e,runId:t,taskTitles:n,recipientBackends:r}){let i=$i(e.messages[0]??{senderRunId:e.senderRunId},t),a=ea(e.messages[0]),o=ca[a?`peer`:i],s=ba(e.messages.map(e=>i===`outbound`?e.recipientRunId:e.senderRunId)),l=i===`outbound`?`SENT to`:`RECEIVED from`,u=`${l} ${s.map(e=>Qi(e,a,n)).join(`, `)}`,d=e.messages[0],f=d?.createdAt??d?.recordedAt;return(0,$.jsxs)(`article`,{"data-slot":`worker-conversation-card`,"data-direction":i,"data-relationship":a?`peer`:`family`,"data-kind":e.kind,className:c(`flex w-full min-w-0 flex-col gap-2 rounded-[8px] border p-3 md:px-4 md:py-[14px]`,o.classes),children:[(0,$.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsxs)(`p`,{className:c(`m-0 flex min-w-0 flex-wrap items-center gap-x-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,o.accent),children:[(0,$.jsx)(`span`,{children:l}),s.map((e,t)=>(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-x-2 normal-case tracking-normal`,children:[t>0?(0,$.jsx)(`span`,{"aria-hidden":!0,children:`,`}):null,(0,$.jsx)(oa,{id:e,peer:a,taskTitles:n,children:t=>(0,$.jsx)(ga,{view:t,to:`/tasks/${e}`,label:`${l} ${t.title}`})})]},e))]}),a?(0,$.jsx)(`span`,{"data-slot":`conversation-relationship`,className:`rounded-full border border-message-peer-border px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-foreground uppercase`,children:`Peer`}):null,(0,$.jsx)(`span`,{"data-slot":`conversation-kind`,className:`rounded-full bg-background/60 px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-foreground uppercase`,children:ta(e.kind)}),e.messages.length===1&&d?(0,$.jsx)(pa,{message:d}):null]}),(0,$.jsx)(fa,{at:f,className:`flex shrink-0 items-center justify-self-end gap-1 whitespace-nowrap text-[11px] text-soft-foreground`,children:e.messages.length>1?`First sent`:null})]}),(0,$.jsx)(ha,{batch:e},`${t}:${d?.messageId??e.id}`),[...new Set(e.messages.map(e=>aa(e,r?.[e.recipientRunId])))].map(e=>e?(0,$.jsx)(`p`,{"data-slot":`conversation-delivery-explanation`,className:`min-w-0 text-xs leading-relaxed text-muted-foreground [overflow-wrap:anywhere]`,children:e},e):null),e.kind===`request`&&e.messages.length>1?(0,$.jsx)(ma,{messages:e.messages,peer:a,runId:t,taskTitles:n}):null,e.messages.length===1&&d?(0,$.jsx)(_a,{message:d,runId:t,taskTitles:n}):null,(0,$.jsx)(va,{batch:e,heading:u})]})}function fa({at:e,className:t,children:n}){return e===void 0||Cr(e)===void 0?null:(0,$.jsxs)(`span`,{className:t,children:[n,(0,$.jsx)(kr,{ts:e})]})}function pa({message:e}){let t=ra(e),n=ia(e.delivery),r=(e.messageKind===`request`||e.messageKind===`reply`)&&n!==t;return(0,$.jsxs)($.Fragment,{children:[t?(0,$.jsx)(`span`,{"data-slot":`conversation-outcome`,className:`text-xs font-medium text-muted-foreground`,children:t}):null,r?(0,$.jsx)(`span`,{"data-slot":`conversation-delivery`,className:`text-xs text-muted-foreground`,children:n}):null]})}function ma({messages:e,peer:t,runId:n,taskTitles:r}){return(0,$.jsx)(`ul`,{className:`grid min-w-0 gap-1 text-xs text-muted-foreground`,children:e.map(e=>{let i=ra(e),a=e.createdAt??e.recordedAt;return(0,$.jsxs)(`li`,{className:`flex min-h-11 min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsx)(oa,{id:e.recipientRunId,peer:t,taskTitles:r,children:t=>(0,$.jsx)(ga,{view:t,to:`/tasks/${e.recipientRunId}`,label:`${t.title}${i?` — ${i}`:``}`})}),i?(0,$.jsx)(`span`,{"data-slot":`conversation-outcome`,children:i}):null,ia(e.delivery)===i?null:(0,$.jsx)(`span`,{"data-slot":`conversation-delivery`,children:ia(e.delivery)}),(0,$.jsx)(_a,{message:e,runId:n,taskTitles:r}),(0,$.jsx)(fa,{at:a,className:`ml-auto whitespace-nowrap`})]},e.id)})})}function ha({batch:e}){let t=rr(),n=`conversation-body:${e.messages[0]?.messageId??e.id}`,[r,i]=(0,Q.useState)(()=>t?.get(n)??!1),a=(0,$.jsx)(`div`,{className:`min-w-0 break-words text-[14px] leading-[1.6] text-foreground select-text [overflow-wrap:anywhere]`,children:(0,$.jsx)(Wt,{breaks:!0,children:e.text})});return e.kind!==`request`&&e.kind!==`reply`?a:(0,$.jsxs)(Y,{"data-slot":`conversation-body`,open:r,onOpenChange:e=>{t?.set(n,e),i(e)},className:`min-w-0`,children:[(0,$.jsxs)(Z,{type:`button`,"data-slot":`conversation-body-toggle`,className:`group/body inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-md px-2 text-start text-xs font-medium text-muted-foreground [@media(hover:hover)_and_(pointer:fine)]:hover:bg-background/40 [@media(hover:hover)_and_(pointer:fine)]:hover:text-foreground active:bg-background/60 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:[(0,$.jsx)(K,{"aria-hidden":!0,className:`size-3.5 shrink-0 group-data-[state=open]/body:rotate-90`}),r?`Hide message`:`Show message`]}),(0,$.jsx)(X,{children:a})]})}function ga({view:e,to:t,label:n}){return e.linkable?(0,$.jsx)(J,{className:la,to:t,"aria-label":n,children:e.title}):(0,$.jsx)(`span`,{"data-slot":`conversation-counterpart`,children:e.title})}function _a({message:e,runId:t,taskTitles:n}){let{targets:r,replies:i,navigate:a}=(0,Q.useContext)(Ji),o=e.requestId?r.get(e.requestId):void 0,s=e.requestId?o?[o]:[]:i.get(e.messageId)??[],l=e.requestId?`request`:`reply`;return s.length===0?e.requestId||e.outcome?.replyId?(0,$.jsxs)(`p`,{"data-slot":`conversation-connector`,className:`text-xs text-muted-foreground`,children:[`Linked `,l,` is outside loaded history.`]}):null:s.map(e=>{let r=$i(e.message,t)===`outbound`,i=r?e.message.recipientRunId:e.message.senderRunId;return(0,$.jsxs)(`button`,{type:`button`,"data-slot":`conversation-connector`,className:c(la,`w-fit gap-1.5 text-xs text-muted-foreground`),onClick:()=>a(e),children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`↗`}),(0,$.jsx)(oa,{id:i,peer:ea(e.message),taskTitles:n,children:e=>(0,$.jsxs)($.Fragment,{children:[`View `,l,` `,r?`to`:`from`,` `,e.title]})})]},e.message.messageId)})}function va({batch:e,heading:t}){return(0,$.jsxs)(Y,{"data-slot":`conversation-details`,className:`group/details`,children:[(0,$.jsxs)(Z,{type:`button`,className:`inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-md px-2 text-left text-xs font-medium text-muted-foreground hover:bg-background/40 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:[(0,$.jsx)(K,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/details:rotate-90`}),`Details`]}),(0,$.jsx)(X,{children:(0,$.jsxs)(`dl`,{className:`grid min-w-0 gap-1 break-all px-2 pb-1 font-mono text-[11px] text-muted-foreground`,children:[(0,$.jsx)(`div`,{className:`sr-only`,children:t}),e.messages.flatMap(e=>ya(e)).map((e,t)=>(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`dt`,{className:`inline font-sans font-medium text-soft-foreground`,children:[e.label,`: `]}),(0,$.jsx)(`dd`,{className:`inline`,children:e.value})]},`${e.label}:${e.value}:${t}`))]})})]})}function ya(e){let t=[{label:`Message`,value:e.messageId},{label:`Sender`,value:e.senderRunId},{label:`Recipient`,value:e.recipientRunId},...ea(e)?[{label:`Relationship`,value:`peer`}]:[],{label:`Delivery`,value:ia(e.delivery)}];return e.requestId&&t.push({label:`Request`,value:e.requestId}),e.outcome?.replyId&&t.push({label:`Reply`,value:e.outcome.replyId}),e.state&&t.push({label:`State`,value:e.state}),e.createdAt&&t.push({label:`Created`,value:e.createdAt}),e.deliveredAt&&t.push({label:e.resumed?`Opening turn completed`:`Delivery acknowledged`,value:e.deliveredAt}),e.recordedAt&&t.push({label:`Event recorded`,value:e.recordedAt}),e.resumed&&t.push({label:`Continuation`,value:`Requested by parent with this instruction`}),e.deadline&&t.push({label:`Deadline`,value:e.deadline}),e.requestHash&&t.push({label:`Hash`,value:e.requestHash}),t}function ba(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}var xa=e(d(),1),Sa=`pending-ask`;function Ca(e){return e.querySelector(`[data-slot="ask-question"] :is(button, textarea):not(:disabled)`)||(e.tabIndex=-1,e)}function wa(e){let t=e.querySelector(`[data-slot="ask-card"][data-pinned="true"]`);return t?Ca(t):null}function Ta(e,t){let n=`${Sa}:${e}`;return e=>{if(!t())return!1;let r=[...e.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===n);return r?wa(r):null}}function Ea(e){return e<=0?`Jump to latest`:`Jump to latest (${e} ${e===1?`question`:`questions`} pending)`}function Da({onGoToQuestion:e}){return(0,$.jsxs)(`div`,{"data-slot":`ask-origin`,className:`flex flex-wrap items-center gap-x-2 rounded-lg border border-dashed border-accent-strong/40 px-3.5 py-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-medium text-link-foreground`,children:`Question asked here`}),(0,$.jsx)(s,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-go-to-question`,className:`min-h-11 min-w-11 px-2 text-foreground underline underline-offset-4`,onClick:e,children:`Go to the question`})]})}var Oa={viewKey:void 0,generation:0},ka=600,Aa=24;function ja(e,t={}){let{surface:n=`document`,onLoadOlder:r,onJumpToLatest:i,rowKeys:a=[]}=t,o=(0,Q.useRef)(e);o.current=e;let s=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(!1),f=(0,Q.useRef)(!0),m=(0,Q.useRef)(0),h=(0,Q.useRef)(0),g=(0,Q.useRef)(new Set),_=(0,Q.useCallback)(e=>{for(let t of[...g.current])t(e)},[]),v=(0,Q.useCallback)(e=>(g.current.add(e),()=>{g.current.delete(e)}),[]),y=(0,Q.useRef)(null),b=(0,Q.useRef)(null),x=(0,Q.useRef)(null),S=(0,Q.useRef)(null),C=(0,Q.useCallback)(e=>{let t=s.current;if(!t)return;let n=S.current;n?n.scrollTo(e):t.scrollTop=e},[]),w=(0,Q.useCallback)(()=>{let e=s.current;e&&C(e.scrollHeight-e.clientHeight)},[C]),T=(0,Q.useCallback)(()=>{if(s.current){if(x.current!==e){x.current=e;let t=fr(e);t&&!t.atBottom?(f.current=!1,y.current=t.top,b.current=hr(e)?.rowKeys?{viewKey:e,top:t.top}:null):(f.current=!0,y.current=null,b.current=null)}y.current===null?f.current&&w():C(y.current)}},[e,C,w]),E=(0,Q.useCallback)(e=>b.current?.viewKey===e,[]),D=(0,Q.useCallback)(e=>{let t=b.current;return!t||!E(e)||e!==o.current?!1:(y.current=t.top,f.current=!1,b.current=null,!0)},[E]),O=(0,Q.useCallback)(e=>{l(e),e&&(s.current=e.closest(n===`panel`?`[data-slot="transcript-viewport"]`:`[data-slot="main"]`),T())},[n,T]),ee=(0,Q.useCallback)(()=>{f.current&&w()},[w]),k=(0,Q.useRef)(!1),A=(0,Q.useRef)(0),j=(0,Q.useRef)(!1),te=(0,Q.useRef)(void 0),ne=(0,Q.useRef)(!1),M=(0,Q.useRef)(!1),N=(0,Q.useRef)(a);N.current=a;let P=(0,Q.useCallback)(e=>[...e.querySelectorAll(`[data-slot="thread-row"][data-row-key]`)].map(e=>{let t=e.getBoundingClientRect();return{key:e.dataset.rowKey,top:t.top,bottom:t.bottom}}),[]),F=(0,Q.useRef)(null),I=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{if(!p())return;let e=e=>{y.current=null,b.current=null,I.current+=1,F.current=null,f.current=!1,C(e)};return window.__cezThreadScrollTo=e,()=>{window.__cezThreadScrollTo===e&&delete window.__cezThreadScrollTo}},[C]);let L=(0,Q.useCallback)(()=>{let e=F.current,t=s.current;if(!e||!t)return;F.current=null;let n=e.beforeTop+Math.max(0,t.scrollHeight-e.beforeHeight),r=t.getBoundingClientRect().top,i=e.anchor===void 0?-1:N.current.indexOf(e.anchor.key),a=S.current;a&&i>=0?a.scrollToIndex(i,{align:`start`,offset:-e.anchor.offset}):C(sr(t.scrollTop,r,e.anchor,P(t),n))},[P,C]),R=(0,Q.useCallback)(()=>{let e=s.current;if(!e||!r||k.current)return;y.current=null,b.current=null,f.current=!1,k.current=!0;let t=A.current+1;A.current=t;let n=e.scrollHeight,i=e.scrollTop,a=e.getBoundingClientRect().top,c=or(a,P(e)),l=c===void 0?-1:N.current.indexOf(c.key),u=o.current,d=I.current;r().then(()=>{o.current===u&&I.current===d&&(F.current={beforeHeight:n,beforeTop:i,anchor:c,anchorIndex:l})},()=>{}).finally(()=>{A.current===t&&(k.current=!1)})},[P,r]);(0,Q.useEffect)(()=>()=>clearTimeout(te.current),[]);let z=(0,Q.useRef)(null),re=(0,Q.useRef)(0),B=(0,Q.useCallback)(()=>n===`document`?++Oa.generation:++re.current,[n]),V=(0,Q.useCallback)((e,t)=>n===`document`?Oa.viewKey===e&&Oa.generation===t:o.current===e&&re.current===t,[n]);(0,Q.useEffect)(()=>()=>z.current?.disconnect(),[e,c]);let ie=(0,Q.useCallback)((t,n,r,i)=>{let a=s.current;if(!a||!c)return;y.current=null,b.current=null,I.current+=1,F.current=null,f.current=!1,m.current=0,d(!0),B(),z.current?.disconnect();let o=()=>[...c.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===t),l=()=>{let e=o();if(!e||getComputedStyle(e).visibility===`hidden`)return!1;let t=r?.(e)??e;return t===e&&(e.tabIndex=-1),t.focus({preventScroll:!0}),document.activeElement===t?(z.current?.disconnect(),!0):!1},u=a.querySelector(`[data-slot="run-header"]`),p=u&&getComputedStyle(u).position===`sticky`?u.getBoundingClientRect().height:0,h=S.current;if(i!==void 0)C(i);else if(h)h.scrollToIndex(n,{align:`start`,...p>0?{offset:-p}:{}});else{let e=o();e&&C(a.scrollTop+e.getBoundingClientRect().top-a.getBoundingClientRect().top-p)}l()||(z.current=new MutationObserver(()=>{l()}),z.current.observe(c,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`,`class`]})),dr(e,{top:i??a.scrollTop,atBottom:!1})},[c,C,e,B]),H=(0,Q.useCallback)(t=>{let n=B(),r=o.current;z.current?.disconnect();let a=s.current;if(!a)return;y.current=null,b.current=null,I.current+=1,F.current=null,f.current=!0,h.current=0,_({direction:`tail`}),dr(e,{top:a.scrollHeight-a.clientHeight,atBottom:!0});let c=()=>{f.current&&w()},l=()=>V(r,n),u=()=>{let e=t?.(a);return e===!1?!0:e?(e.focus({preventScroll:!0}),document.activeElement===e):!1};(i?.()??Promise.resolve()).finally(()=>{requestAnimationFrame(()=>{c(),requestAnimationFrame(()=>{if(c(),!t||!l()||u())return;z.current?.disconnect();let e=new MutationObserver(()=>{l()?u()&&e.disconnect():e.disconnect()});z.current=e,e.observe(a,{childList:!0,subtree:!0})})})})},[i,e,w,B,V,_]),ae=a.at(-1),oe=a.length;return(0,Q.useLayoutEffect)(()=>{I.current+=1,F.current=null,k.current=!1,n===`document`?Oa.viewKey!==e&&(Oa.viewKey=e,Oa.generation+=1):re.current+=1},[e,n]),(0,Q.useLayoutEffect)(()=>{let e=F.current;e?(e.anchor===void 0?-1:N.current.indexOf(e.anchor.key))>e.anchorIndex?L():F.current=null:f.current&&w()},[ae,oe,L,w]),(0,Q.useLayoutEffect)(()=>{!s.current||!c||T()},[c,T]),(0,Q.useEffect)(()=>{let t=s.current,n=c;if(!t||!n)return;m.current=0;let r=null,i=!1,a=t.scrollTop,o,l=0,u,p=e=>{h.current=Date.now(),u=e},g=()=>{B(),z.current?.disconnect(),y.current=null,b.current=null,I.current+=1,F.current=null,f.current=!1,m.current=0},v=()=>{y.current=null,b.current=null,I.current+=1,F.current=null,m.current=Date.now()},x=e=>{if(e.deltaY!==0)if(p(e.deltaY<0?`up`:`down`),e.deltaY<0){g();let e=!j.current;j.current=!0,clearTimeout(te.current),te.current=setTimeout(()=>{j.current=!1},180),e&&ar(t)&&R()}else v()},S=e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)?(p(`up`),g(),!e.repeat&&ar(t)&&R()):[`ArrowDown`,`PageDown`,`End`].includes(e.key)&&(p(`down`),v())},T=e=>{if(e.target!==t||e.button!==0||e.pointerType===`touch`||e.pointerType===`pen`||t.scrollHeight<=t.clientHeight)return;i=!0,M.current=!1,a=t.scrollTop;let n=t.getBoundingClientRect(),r=getComputedStyle(t),o=parseFloat(r.borderLeftWidth)||0,s=parseFloat(r.borderRightWidth)||0,c=n.left+t.clientLeft,l=c+t.clientWidth;!(e.clientX>=n.left+o&&e.clientX<c||e.clientX>=l&&e.clientX<n.right-s)||e.clientY<n.top+t.clientTop||e.clientY>=n.top+t.clientTop+t.clientHeight||(y.current=null,b.current=null,cr(t,80)||(g(),v()))},D=()=>{i=!1},O=e=>{ne.current=!1,r=e.touches[0]?.clientY??null},ee=e=>{let n=e.touches[0]?.clientY;n!==void 0&&(r!==null&&n>r+1?(p(`up`),g(),!ne.current&&ar(t)&&(ne.current=!0,R())):r!==null&&n<r-1&&(p(`down`),v()),r=n)},k=e=>{if(e===0||!i&&Date.now()-h.current>=ka)return;let n=e<0?`up`:`down`;!i&&n!==u||(n!==o&&(o=n,l=0),l+=Math.abs(e),l>=Aa&&(0,xa.flushSync)(()=>_({direction:n,distanceFromBottom:t.scrollHeight-t.clientHeight-t.scrollTop})))},A=()=>{let n=f.current;k(t.scrollTop-a),i&&t.scrollTop!==a&&(t.scrollTop<a?g():v()),i&&!M.current&&t.scrollTop<a&&ar(t)&&(M.current=!0,R()),a=t.scrollTop;let r=cr(t,80);r&&y.current===null&&(f.current||Date.now()-m.current<2e3)&&(f.current=!0),!n&&f.current&&_({direction:`tail`}),d(!r),y.current===null&&!E(e)&&dr(e,{top:t.scrollTop,atBottom:r})};t.addEventListener(`scroll`,A,{passive:!0}),t.addEventListener(`wheel`,x,{passive:!0}),t.addEventListener(`touchstart`,O,{passive:!0}),t.addEventListener(`touchmove`,ee,{passive:!0}),t.addEventListener(`pointerdown`,T,{passive:!0}),window.addEventListener(`pointerup`,D,{passive:!0}),window.addEventListener(`pointercancel`,D,{passive:!0}),t.addEventListener(`keydown`,S);let N;if(typeof ResizeObserver<`u`){N=new ResizeObserver(()=>{let e=y.current;if(e!==null){let n=t.scrollHeight-t.clientHeight;C(Math.min(e,n)),n>=e&&(y.current=null)}else f.current&&w()}),N.observe(n);let e=n.closest(`[data-route="task-thread"]`),r=e?.querySelector(`[data-slot="run-header"]`),i=e?.querySelector(`[data-slot="thread-dock"]`);r&&N.observe(r),i&&N.observe(i)}return()=>{t.removeEventListener(`scroll`,A),t.removeEventListener(`wheel`,x),t.removeEventListener(`touchstart`,O),t.removeEventListener(`touchmove`,ee),t.removeEventListener(`pointerdown`,T),window.removeEventListener(`pointerup`,D),window.removeEventListener(`pointercancel`,D),t.removeEventListener(`keydown`,S),N?.disconnect()}},[e,c,R,C,w,E,B,_]),{attachContent:O,scrollElRef:s,virtualizerRef:S,restoreMeasurements:D,ownsMeasurementRestore:E,pillVisible:u,jumpToLatest:H,jumpToRow:ie,loadOlder:R,restickIfStuck:ee,subscribeReaderScroll:v}}function Ma({runId:e,rows:t,mode:n,controls:r}){return n===`virtual`?(0,$.jsx)(Na,{runId:e,rows:t,controls:r}):(0,$.jsx)(`div`,{ref:r.attachContent,"data-slot":`thread-rows`,"data-virtualized":`false`,className:`[overflow-anchor:none]`,children:t.map(e=>(0,$.jsx)(`div`,{"data-slot":`thread-row`,"data-row-key":e.key,className:`flex w-full flex-col pb-2.5 [contain-intrinsic-block-size:auto_3rem] [content-visibility:auto]`,children:e.node},e.key))})}function Na({runId:e,rows:t,controls:n}){return(0,$.jsx)(Pa,{runId:e,rows:t,controls:n},e)}function Pa({runId:e,rows:t,controls:n}){let r=(0,Q.useRef)(null),i=(0,Q.useRef)(t),a=t[0]?.key,o=i.current[0]?.key,s=a!==o&&(t.some(e=>e.key===o)||i.current.some(e=>e.key===a));(0,Q.useLayoutEffect)(()=>{i.current=t},[t]);let[c]=(0,Q.useState)(()=>hr(e)),[l,u]=(0,Q.useState)(()=>({cache:gr(e,t.length,t.map(e=>e.key)),generation:0})),d=(0,Q.useRef)(l.cache===void 0&&c?.rowKeys?.length===c?.rows&&c!==void 0);(0,Q.useLayoutEffect)(()=>{let r=c?.rowKeys;if(!d.current){n.restoreMeasurements(e);return}if(!(!c||!r)){if(t.length>c.rows||t.some((e,t)=>e.key!==r[t])){d.current=!1,n.restoreMeasurements(e);return}t.length===c.rows&&(d.current=!1,n.restoreMeasurements(e)&&u({cache:c.cache,generation:1}))}},[c,t,n.restoreMeasurements,e]);let f=(0,Q.useRef)(t.length);f.current=t.length;let p=(0,Q.useRef)(t.map(e=>e.key));p.current=t.map(e=>e.key);let m=(0,Q.useRef)(null),h=(0,Q.useCallback)(t=>{n.virtualizerRef.current=t,t?m.current=t:m.current&&=(d.current&&c?.rowKeys&&f.current<c.rows&&n.ownsMeasurementRestore(e)||mr(e,{rows:f.current,cache:m.current.cache,rowKeys:p.current}),null)},[e,n.virtualizerRef,n.ownsMeasurementRestore,c]),[g,_]=(0,Q.useState)(0);return(0,Q.useLayoutEffect)(()=>{let e=()=>{let e=r.current,t=n.scrollElRef.current;!e||!t||_(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[n.scrollElRef]),(0,$.jsx)(`div`,{ref:e=>{r.current=e,n.attachContent(e)},"data-slot":`thread-rows`,"data-virtualized":`true`,className:`[overflow-anchor:none]`,children:(0,$.jsx)(un,{ref:h,scrollRef:n.scrollElRef,startMargin:g,shift:s,...l.cache===void 0?{}:{cache:l.cache},children:t.map(e=>(0,$.jsx)(`div`,{"data-slot":`thread-row`,"data-row-key":e.key,className:`flex w-full flex-col pb-2.5`,children:e.node},e.key))},l.generation)})}function Fa({onJump:e,pendingQuestions:t=0}){return(0,$.jsxs)(`button`,{type:`button`,"data-slot":`jump-to-latest`,"data-pending-questions":t>0?t:void 0,onClick:()=>e(),className:`pointer-events-auto inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-full border border-border bg-background px-3.5 text-xs font-medium text-muted-foreground shadow-modal hover:text-foreground`,children:[(0,$.jsx)(Me,{"aria-hidden":!0,className:`size-3.5`}),Ea(t)]})}function Ia(e){return e.consumedAt?`consumed`:e.deliveredAt?`delivered`:`queued`}function La(e,t){let n=new Map((e.agentInputs??[]).map(e=>[e.id,Ia(e)]));if(n.size===0)return t;let r=!1,i=t.map(e=>{if(e.kind!==`note`||!e.id.startsWith(`agent-input:`))return e;let t=n.get(e.id.slice(12));return!t||e.delivery===t?e:(r=!0,{...e,delivery:t})});return r?i:t}function Ra(e,t,n){return e.kind===`ask`?e.id===t?n===void 0?e:{...e,placement:`origin`}:e.resolved?e:{...e,resolved:!0}:e}function za(e,t,n=t,r){let i=r==null?void 0:n.turns.flatMap(e=>e.items).find(e=>e.kind===`ask`&&e.id===r&&!e.resolved),a=new Map(n.turns.flatMap(e=>e.items).filter(e=>e.kind===`permission`).map(e=>[e.requestId,e])),o=new Set,s=new Set(t.turns.map(e=>e.userMessage?.ask?.id)),c=[];e.task&&c.push({id:`task`,userMessageKey:`task`,userMessage:{text:e.task,images:e.taskImages??[],ts:e.createdAt},entries:[]});for(let t of e.queuedMessages??[])c.push({id:`queued:${t.id}`,userMessageKey:`queued:${t.id}`,userMessage:{text:t.text,images:t.images??[],ts:t.createdAt},inDaySequence:!1,entries:[]});for(let n of t.turns)c.push({id:n.id,userMessageKey:`${n.id}:user`,...n.userMessage===void 0?{}:{userMessage:{text:n.userMessage.text,ask:n.userMessage.ask,imageCount:n.userMessage.imageCount,images:n.userMessage.images,...n.userMessage.ts===void 0?{}:{ts:n.userMessage.ts}}},...n.startedAt===void 0?{}:{startedAt:n.startedAt},...n.completed?.ts===void 0?{}:{completedAt:n.completed.ts},entries:La(e,n.items.map(e=>e.kind===`ask`&&s.has(e.id)?{...e,placement:`origin`}:r!==void 0&&e.kind===`ask`?Ra(e,r,i):e.kind===`permission`?(o.add(e.requestId),a.get(e.requestId)??(e.status===`pending`?{...e,status:`expired`}:e)):e))});let l=[...a.values()].filter(e=>e.status===`pending`&&!o.has(e.requestId));return l.length>0&&c.push({id:`pending-permissions`,entries:l,inDaySequence:!1}),i!==void 0&&c.push({id:Sa,entries:[{...i,placement:`pinned`}],inDaySequence:!1}),c}function Ba(e,t,n){let r=e.findIndex(({content:e})=>e.kind===`block`&&e.block.kind===`entry`&&e.block.entry.kind===`ask`&&e.block.entry.id===t&&e.block.entry.placement===n);return r<0?void 0:{key:e[r].key,index:r}}function Va(e,t){return[{id:`agent:${e}`,entries:t}]}function Ha(e){if(e.inDaySequence!==!1)return e.userMessage?.ts??e.startedAt??e.completedAt}function Ua(e,t){let n=[],r;for(let t of e){let e=Ha(t),i=Er(e);i!==void 0&&e!==void 0&&(r===void 0||i>r)&&(r!==void 0&&n.push({key:`${t.id}:day-separator`,scope:t.id,content:{kind:`day-separator`,ts:e}}),r=i),t.userMessage!==void 0&&n.push({key:t.userMessageKey??`${t.id}:user`,scope:t.id,content:{kind:`user-message`,message:t.userMessage}});for(let e of $n([...t.entries]))n.push({key:`${t.id}:${e.id}`,scope:t.id,content:{kind:`block`,block:e}});t.completedAt!==void 0&&n.push({key:`${t.id}:turn-time`,scope:t.id,content:{kind:`turn-time`,completedAt:t.completedAt,...t.startedAt===void 0?{}:{startedAt:t.startedAt}}})}return n}function Wa({runId:e,viewId:t,sections:n,mode:r,empty:i,renderAsk:a,renderPermission:o,messageActions:s,scrollControls:c,renderMode:l,taskTitles:u,recipientBackends:d}){let f=(0,Q.useMemo)(()=>Ua(n,e),[n,e]),p=ja(`${e}:${t}`,{surface:r}),m=c??p;Ii(e,f,m,r);let h=(0,Q.useMemo)(()=>{let e=new Map;f.forEach((t,n)=>{if(!(t.content.kind!==`block`||t.content.block.kind!==`worker-conversation`))for(let r of t.content.block.batches)for(let i of r.messages)e.set(i.messageId,{message:i,rowKey:t.key,rowIndex:n})});let t=new Map;for(let n of e.values()){let{message:e}=n;if(e.messageKind!==`reply`||!e.requestId)continue;let r=t.get(e.requestId)??[];r.push(n),t.set(e.requestId,r)}return{targets:e,replies:t,navigate:e=>m.jumpToRow(e.rowKey,e.rowIndex)}},[f,m.jumpToRow]),g=(0,Q.useMemo)(()=>f.map(t=>({key:t.key,node:Ga(t,s?.[t.key],a,o,e,u,d)})),[s,a,o,f,e,u,d]),_=l??lr(``,g.length),v=g.length===0?i??null:(0,$.jsx)(Ma,{runId:`${e}:${t}`,rows:g,mode:_,controls:m});return(0,$.jsx)(He,{runId:e,children:(0,$.jsx)(ir,{runId:e,children:(0,$.jsx)(Ji.Provider,{value:h,children:r===`panel`?(0,$.jsxs)(`div`,{"data-slot":`transcript-viewport`,"aria-label":`Agent transcript`,role:`region`,tabIndex:0,className:`relative flex min-h-0 flex-1 flex-col overflow-y-auto [scrollbar-gutter:stable]`,children:[(0,$.jsx)(`div`,{"data-slot":`subagent-stream`,className:`flex flex-col px-5 py-4`,children:v}),m.pillVisible?(0,$.jsx)(`div`,{className:`pointer-events-none sticky inset-x-0 bottom-4 flex justify-center`,children:(0,$.jsx)(Fa,{onJump:m.jumpToLatest})}):null]}):v})})})}function Ga(e,t,n,r,i,a,o){switch(e.content.kind){case`user-message`:return(0,$.jsx)(Ka,{message:e.content.message,actions:t});case`day-separator`:return(0,$.jsx)(jr,{ts:e.content.ts});case`turn-time`:return(0,$.jsx)(Ar,{completedAt:e.content.completedAt,...e.content.startedAt===void 0?{}:{startedAt:e.content.startedAt}});case`block`:return(0,$.jsx)(qa,{block:e.content.block,scope:e.scope,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o});default:return Za(e.content)}}function Ka({message:e,actions:t}){return(0,$.jsx)(Pr,{text:e.text,imageCount:e.imageCount,images:e.images,...e.ts===void 0?{}:{ts:e.ts},onEdit:t?.onEdit,onRemove:t?.onRemove,editLabel:t?.editLabel,removeLabel:t?.removeLabel,children:e.ask?(0,$.jsx)(`div`,{"data-slot":`ask-card`,"data-resolved":`true`,children:(0,$.jsx)(Ki,{ask:e.ask})}):void 0})}function qa({block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){switch(e.kind){case`entry`:return(0,$.jsx)(Rn.Provider,{value:`${t}:${e.entry.id}`,children:(0,$.jsx)(Ya,{entry:e.entry,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`tool-card`:return(0,$.jsx)(ti,{item:e.item,nested:e.children,cacheKey:`${t}:${e.id}`,renderNested:(e,t)=>(0,$.jsx)(Ja,{entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`context-group`:return(0,$.jsx)(ii,{group:e,scope:t});case`streak`:return(0,$.jsx)(ai,{count:e.count,children:e.blocks.map(e=>(0,$.jsx)(qa,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))});case`worker-conversation`:return(0,$.jsx)(ua,{block:e,runId:i,taskTitles:a,recipientBackends:o});default:return Za(e)}}function Ja({entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){return $n([...e]).map(e=>(0,$.jsx)(qa,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))}function Ya({entry:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){switch(e.kind){case`message`:return e.role===`assistant`?(0,$.jsx)(zr,{text:e.text,ts:e.ts}):(0,$.jsx)(Pr,{text:e.text,ts:e.ts});case`reasoning`:return(0,$.jsx)(Hr,{text:e.text});case`tool`:return(0,$.jsx)(ti,{item:e,cacheKey:`${t}:${e.id}`});case`note`:return e.attribution?(0,$.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border px-4 py-3 text-sm`,children:[(0,$.jsxs)(`p`,{className:`mb-2 break-all text-xs text-muted-foreground`,children:[e.attribution.source===`agent`?`Agent input from parent ${e.attribution.parentRunId}`:`Worker lifecycle context for parent ${e.attribution.parentRunId}`,e.delivery?` · ${ia(e.delivery)}`:``]}),(0,$.jsx)(Br,{note:e})]}):(0,$.jsx)(Br,{note:e});case`conversation`:return(0,$.jsx)(ua,{runId:i,taskTitles:a,recipientBackends:o,block:{kind:`worker-conversation`,id:e.id,batches:[{id:e.id,kind:e.messageKind,text:e.text,senderRunId:e.senderRunId,messages:[e]}]}});case`image`:return(0,$.jsx)(oi,{image:e});case`ask`:return n===void 0?(0,$.jsx)(`div`,{"data-slot":`ask-card`,className:`rounded-lg border border-border bg-card px-4 py-3 text-sm`,children:`The agent asked a question. Open the main session to answer it.`}):n(e);case`permission`:return r?r(e):(0,$.jsx)(Bi,{permission:e,runId:i});case`provider-auth-required`:return(0,$.jsx)(Vr,{incident:e});case`preview-server`:return(0,$.jsx)(Xa,{entry:e});case`hook`:return(0,$.jsx)(ri,{item:e,cacheKey:`${t}:${e.id}`});default:return Za(e)}}function Xa({entry:e}){let t=$t(),n=A().data?.capabilities?.preview===!0;return(0,$.jsx)(st,{entry:t?.worktreeRemoved?{kind:`preview-server`,id:e.id,server:e.server,state:`unavailable`}:e,inPreview:t!==null&&t.open&&t.port===e.server.port,onOpen:t!==null&&n?t.openPane:void 0})}function Za(e){throw Error(`Unhandled transcript variant: ${JSON.stringify(e)}`)}function Qa({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,onClose:a,taskTitles:o,recipientBackends:s}){let c=(0,Q.useContext)(Kt),l=(0,Q.useRef)(void 0),u=(0,Q.useRef)(!1);return(0,Q.useEffect)(()=>()=>{l.current?.()},[c,e]),(0,$.jsx)(Xt,{open:r!==void 0,onOpenChange:e=>{e||a()},children:(0,$.jsx)(Vt,{"data-slot":`subagent-sheet`,side:`right`,onCloseAutoFocus:e=>{u.current&&=(e.preventDefault(),!1)},className:`flex min-h-0 w-full gap-0 p-0 sm:max-w-xl`,children:r===void 0?null:(0,$.jsx)(Ln.Provider,{value:e=>{let t=[...document.querySelectorAll(`[data-agent-id]`)].find(e=>e.dataset.agentId===r?.id);l.current?.(),l.current=c?.registerOpener(e,()=>{t?.focus({preventScroll:!0})}),u.current=!0,a()},children:(0,$.jsx)($a,{runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:o,recipientBackends:s})})})})}function $a({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:a,recipientBackends:o}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Zt,{className:`gap-1.5 border-b border-border px-5 py-4`,children:[(0,$.jsxs)(Bt,{className:`flex min-w-0 items-center gap-2 pr-8 text-[16px]`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:r.title}),r.agentType===void 0?null:(0,$.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:r.agentType})]}),(0,$.jsxs)(Yt,{"data-slot":`subagent-meta`,className:`flex items-center gap-2 text-xs`,children:[(0,$.jsx)(eo,{status:r.status}),(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[r.toolCalls,` `,r.toolCalls===1?`tool call`:`tool calls`]})]})]}),(0,$.jsx)(Wa,{runId:e,viewId:`agent:${r.id}`,sections:Va(r.id,i),mode:`panel`,renderAsk:t,renderPermission:n,taskTitles:a,recipientBackends:o,empty:(0,$.jsx)(`div`,{"data-slot":`subagent-empty`,className:`py-2 text-[13px] text-muted-foreground`,children:`No attributed output — see the thread card for this agent's result.`})})]})}function eo({status:e}){let t=e===`completed`?`Completed`:e===`failed`?`Failed`:e===`declined`?`Declined`:e===`pending`?`Pending`:`Running`;return(0,$.jsx)(`span`,{"data-slot":`subagent-status`,"data-status":e,className:c(`rounded-full px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] uppercase`,e===`completed`&&`bg-success/15 text-success`,(e===`failed`||e===`declined`)&&`bg-danger/15 text-danger`,(e===`running`||e===`pending`)&&`bg-muted text-muted-foreground`),children:t})}var to=/^diff --git /;function no(e){let t=e.replace(to,``),n=t.lastIndexOf(` b/`);return ro(n>=0?t.slice(n+3):t)}function ro(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)&&t.length>=2?t.slice(1,-1).replace(/\\(.)/g,`$1`):t}function io(e){let t=ro(e.slice(4));if(t!==`/dev/null`)return t.replace(/^[ab]\//,``)}function ao(e){return{path:no(e),status:`modified`,binary:!1,additions:0,deletions:0,lines:[]}}function oo(e,t){if(t.startsWith(`rename from `))e.status=`renamed`,e.oldPath=ro(t.slice(12));else if(t.startsWith(`rename to `))e.status=`renamed`,e.path=ro(t.slice(10));else if(t.startsWith(`new file mode`))e.status=`added`;else if(t.startsWith(`deleted file mode`))e.status=`deleted`;else if(t.startsWith(`Binary files `)||t===`GIT binary patch`)e.binary=!0;else if(t.startsWith(`+++ `)){let n=io(t);n!==void 0&&(e.path=n)}else if(t.startsWith(`--- `)){let n=io(t);n!==void 0&&e.status===`deleted`&&(e.path=n)}}function so(e,t){e.lines.push(t),t.startsWith(`+`)?e.additions+=1:t.startsWith(`-`)&&(e.deletions+=1)}function co(e){let t=[],n=null,r=!1;for(let i of e.split(`
|
|
7
|
-
`)){if(to.test(i)){n=ao(i),t.push(n),r=!1;continue}if(n){if(!r){i.startsWith(`@@`)?(r=!0,n.lines.push(i)):oo(n,i);continue}so(n,i)}}let i=t.at(-1);return i&&i.lines.at(-1)===``&&i.lines.pop(),t}function lo(e){return{files:e.length,additions:e.reduce((e,t)=>e+t.additions,0),deletions:e.reduce((e,t)=>e+t.deletions,0)}}var uo=20,fo=300;function po({runId:e}){let t=v(),n=oe(e);(0,Q.useEffect)(()=>{t.invalidateQueries({queryKey:B.runs.diff(e)})},[t,e]);let r=(0,Q.useMemo)(()=>co(n.data??``),[n.data]),[i,a]=(0,Q.useState)(!1);if(n.isPending)return(0,$.jsx)(`p`,{className:`px-1 text-xs text-soft-foreground`,children:`Loading diff…`});if(n.isError)return(0,$.jsx)(`p`,{className:`px-1 text-xs text-danger`,children:n.error.message});if(r.length===0)return(0,$.jsx)(`p`,{"data-slot":`run-diff-empty`,className:`px-1 font-mono text-xs text-soft-foreground`,children:n.data.trim()||`(no changes)`});let o=lo(r),c=i?r:r.slice(0,uo);return(0,$.jsxs)(`div`,{"data-slot":`run-diff`,className:`flex min-w-0 flex-col gap-2`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`span`,{children:[o.files,` `,o.files===1?`file`:`files`,` changed`]}),(0,$.jsxs)(`span`,{className:`font-mono font-semibold tabular-nums`,children:[(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,o.additions]}),` `,(0,$.jsxs)(`span`,{className:`text-danger`,children:[`−`,o.deletions]})]})]}),c.map(e=>(0,$.jsx)(ho,{file:e},`${e.oldPath??``}→${e.path}`)),r.length>c.length?(0,$.jsxs)(s,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>a(!0),children:[`Show `,r.length-c.length,` more files`]}):null]})}var mo={added:`added`,deleted:`deleted`,renamed:`renamed`};function ho({file:e}){let[t,n]=(0,Q.useState)(!0),r=mo[e.status];return(0,$.jsxs)(Y,{open:t,onOpenChange:n,"data-slot":`diff-file`,className:`min-w-0 overflow-hidden rounded-md border border-border bg-card`,children:[(0,$.jsxs)(Z,{className:`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-muted/50`,children:[(0,$.jsx)(nn,{className:c(`size-3.5 shrink-0 text-soft-foreground transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),(0,$.jsx)(`span`,{"data-slot":`diff-file-path`,className:`min-w-0 truncate font-mono text-xs font-medium`,children:e.oldPath?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`text-soft-foreground`,children:[e.oldPath,` → `]}),e.path]}):e.path}),r?(0,$.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[12px] font-medium text-muted-foreground`,children:r}):null,e.binary?(0,$.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[12px] font-medium text-muted-foreground`,children:`binary`}):null,(0,$.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[11px] font-semibold tabular-nums`,children:[(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions]}),` `,(0,$.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions]})]})]}),(0,$.jsx)(X,{children:(0,$.jsx)(`div`,{className:`border-t border-border/50`,children:e.binary?(0,$.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`Binary file — no text diff.`}):e.lines.length===0?(0,$.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`No content changes (metadata only).`}):(0,$.jsx)(go,{lines:e.lines})})})]})}function go({lines:e}){let[t,n]=(0,Q.useState)(!1),r=t?e:e.slice(0,fo),i=r.join(`
|
|
8
|
-
`),[a,o]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let e=!1;return rn(i,`diff`).then(t=>{e||o({text:i,tokens:t.tokens})}),()=>{e=!0}},[i]);let s=a?.text===i?a.tokens:fn(i,`diff`)?.tokens??null;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`pre`,{"data-slot":`diff-file-body`,className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:r.map((e,t)=>(0,$.jsxs)(`span`,{"data-line":e.startsWith(`+`)?`add`:e.startsWith(`-`)?`del`:void 0,className:c(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del`,e.startsWith(`@@`)&&`text-soft-foreground`),children:[s?.[t]===void 0?e:s[t].map((e,t)=>(0,$.jsx)(`span`,{style:e.color===void 0?void 0:{color:e.color},children:e.content},t)),e===``?` `:``]},t))}),e.length>fo?(0,$.jsx)(`button`,{type:`button`,"data-slot":`diff-file-toggle`,onClick:()=>n(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-[11px] font-medium text-soft-foreground hover:text-foreground`,children:t?`Show less`:`Show all ${e.length} lines`}):null]})}function _o(e){let t=v();return V({mutationFn:()=>g(e),onSuccess:()=>t.invalidateQueries({queryKey:B.runs.all}),onError:e=>G(e.message,{tone:`danger`})})}function vo({run:e}){return(0,$.jsxs)(`section`,{"data-slot":`review-panel`,"aria-label":`Review the changes`,className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{"data-slot":`review-banner`,className:`flex items-center gap-2.5 rounded-md border border-accent-strong/30 bg-accent-strong/10 px-3.5 py-2.5`,children:[(0,$.jsx)(rt,{className:`size-4 shrink-0 text-accent-icon`,"aria-hidden":`true`}),(0,$.jsxs)(`p`,{className:`min-w-0 text-[13px]`,children:[(0,$.jsx)(`span`,{className:`font-semibold`,children:`Review the changes before anything lands.`}),` `,(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`Read the diff, send notes back, draft a PR — or accept. Nothing merges on its own.`})]})]}),(0,$.jsx)(po,{runId:e.id}),(0,$.jsx)(yo,{run:e})]})}function yo({run:e}){let t=P(),n=v(),r=(0,Q.useRef)(null),[i,o]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(null),u=_o(e.id),d=ci(e),f=()=>n.invalidateQueries({queryKey:B.runs.all}),p=V({mutationFn:async t=>d.canContinue?y(H(e.id),{text:`Review feedback:\n${t}`,runner:d.runnerOverride}):null,onMutate:()=>H(e.id),onSuccess:(e,n,r)=>{e!==null&&(o(``),t.invalidateAfter(`continue`,r))},onError:e=>G(e.message,{tone:`danger`})}),m=V({mutationFn:()=>E(e.id),onSuccess:e=>{G(`Draft PR created — ${e.url}`),f()},onError:e=>{e instanceof C&&e.manual!==void 0&&l(e.manual),G(e.message,{tone:`danger`})}}),h=()=>{let e=i.trim();if(e.length===0){G(`Write what to change first.`),r.current?.focus();return}p.mutate(e)};return(0,$.jsxs)(`div`,{"data-slot":`review-actions`,className:`flex flex-col gap-2`,children:[(0,$.jsx)(Nt,{ref:r,"data-slot":`review-notes`,"aria-label":`Notes for the agent`,placeholder:`Notes for the agent — what should change?`,rows:2,value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{Qt({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),h())},className:`min-h-[52px] text-[13px]`}),d.canContinue?null:(0,$.jsxs)(`p`,{id:`review-provider-guidance`,className:`flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:d.reason}),d.providerPending?null:(0,$.jsx)(J,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(s,{"data-slot":`review-send-back`,variant:`outline`,size:`sm`,title:d.reason??`Send the notes back into the agent's session`,"aria-describedby":d.canContinue?void 0:`review-provider-guidance`,disabled:p.isPending||!d.canContinue,onClick:h,children:[(0,$.jsx)(xn,{"aria-hidden":`true`}),`Send back`]}),a(e.pullRequestUrl)?(0,$.jsx)(s,{asChild:!0,variant:`outline`,size:`sm`,children:(0,$.jsxs)(`a`,{"data-slot":`pr-link`,href:e.pullRequestUrl,target:`_blank`,rel:`noopener noreferrer`,title:`The PR for this task is already open`,children:[(0,$.jsx)(le,{"aria-hidden":`true`}),`PR ↗`]})}):(0,$.jsxs)(s,{"data-slot":`review-draft-pr`,variant:`outline`,size:`sm`,title:`Push the branch and open a draft PR`,disabled:m.isPending,onClick:()=>m.mutate(),children:[(0,$.jsx)(be,{"aria-hidden":`true`}),`Draft PR`]}),e.finishBlocked===null?(0,$.jsxs)(s,{"data-slot":`review-accept`,variant:`primary`,size:`sm`,className:`ml-auto`,title:qt(`review`),disabled:u.isPending,onClick:()=>u.mutate(),children:[(0,$.jsx)(je,{"aria-hidden":`true`}),`Accept`]}):null]}),c===null?null:(0,$.jsx)(bo,{command:c})]})}function bo({command:e}){return(0,$.jsxs)(`button`,{type:`button`,"data-slot":`review-manual`,title:`Copy the command`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>G(`Command copied to clipboard.`)).catch(()=>G(`Run manually: ${e}`))},className:`flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1 py-0.5 text-left font-mono text-[11px] text-soft-foreground hover:bg-muted hover:text-foreground`,children:[(0,$.jsx)(Re,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`truncate`,children:[`manual path: `,e]})]})}function xo(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var So=1500;function Co({status:e}){let t=(0,Q.useRef)(e),[n,r]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{let n=t.current;if(t.current=e,n!==`review`||e!==`done`||xo())return;r(!0);let i=setTimeout(()=>r(!1),So);return()=>clearTimeout(i)},[e]),n?(0,$.jsxs)(`div`,{"data-slot":`accept-celebration`,"aria-hidden":`true`,className:`pointer-events-none fixed inset-0 isolate z-40`,children:[(0,$.jsx)(jt,{}),(0,$.jsx)(`div`,{className:`flex justify-center pt-24`,children:(0,$.jsx)(`span`,{className:`rounded-full border border-accent-strong/30 bg-accent-strong/15 px-4 py-1.5 text-[13px] font-medium text-accent-text shadow-modal`,children:`✓ Changes accepted`})})]}):null}function wo(e){let t=v(),[n,r]=(0,Q.useState)(),i=U(e);(0,Q.useEffect)(()=>{(!i||n&&n!==e.id)&&r(void 0)},[i,e.id,n]);let a=V({mutationFn:async()=>{r(e.id);try{if(!(await S(e.id)).cancelled)throw Error(`The task changed before Stop was accepted. Check its status and retry.`)}catch(e){throw r(void 0),e}},onSettled:()=>t.invalidateQueries({queryKey:B.runs.all})});return{stopping:!!e.stopping||a.isPending||i&&n===e.id,stop:()=>a.mutateAsync()}}function To({agents:e,onSelect:t}){return e.length===0?null:(0,$.jsx)(`ul`,{"data-slot":`agents-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map(e=>(0,$.jsx)(Eo,{agent:e,onSelect:t},e.id))})}function Eo({agent:e,onSelect:t}){let n=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Do,{status:e.status,stalled:e.stalled===!0}),(0,$.jsx)(`span`,{className:`min-w-0 shrink truncate font-medium`,children:e.title}),e.agentType===void 0?null:(0,$.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:e.agentType}),(0,$.jsx)(`span`,{"data-slot":`agent-activity`,className:`min-w-0 flex-1 truncate text-muted-foreground`,children:Ei(e)}),(0,$.jsxs)(`span`,{"data-slot":`agent-tools`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[e.toolCalls,` `,e.toolCalls===1?`tool`:`tools`]})]});return(0,$.jsx)(`li`,{"data-slot":`agent-item`,"data-status":e.status,className:`min-w-0 text-[13px]`,children:t?(0,$.jsx)(`button`,{type:`button`,"data-agent-id":e.id,onClick:()=>t(e.id),"aria-haspopup":`dialog`,className:`flex min-h-5 w-full min-w-0 items-center gap-2.5 rounded-sm text-left hover:bg-muted/50`,children:n}):(0,$.jsx)(`div`,{className:`flex min-h-5 min-w-0 items-center gap-2.5`,children:n})})}function Do({status:e,stalled:t=!1}){return t?(0,$.jsx)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,"data-stalled":`true`,className:`size-[15px] shrink-0 text-soft-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:`3 2.5`,children:(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})}):e===`completed`?(0,$.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 text-success`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,$.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`failed`||e===`declined`?(0,$.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 text-danger`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,$.jsx)(`path`,{d:`m9 9 6 6M15 9l-6 6`})]}):(0,$.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 animate-pulse motion-reduce:animate-none`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,$.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,$.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]})}function Oo(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.filter(e=>e.status!==`cancelled`).length}}function ko({entries:e}){return e.length===0?null:(0,$.jsx)(`ul`,{"data-slot":`plan-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map((e,t)=>(0,$.jsx)(Ao,{entry:e},`${t}:${e.content}`))})}function Ao({entry:e}){return(0,$.jsxs)(`li`,{"data-slot":`plan-item`,"data-status":e.status,className:c(`flex min-h-5 min-w-0 items-center gap-2.5 text-[13px]`,e.status===`completed`&&`text-soft-foreground line-through`,e.status===`in_progress`&&`font-medium`,e.status===`pending`&&`text-muted-foreground`,e.status===`cancelled`&&`text-soft-foreground/70 line-through`),children:[(0,$.jsx)(jo,{status:e.status}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:e.content}),e.status===`in_progress`?(0,$.jsx)(`span`,{"data-slot":`plan-tag`,className:`ml-auto shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:`in progress`}):null]})}function jo({status:e}){return e===`cancelled`?(0,$.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-soft-foreground/70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`,opacity:`.5`}),(0,$.jsx)(`path`,{d:`m8.5 15.5 7-7`})]}):e===`completed`?(0,$.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-success`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,$.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`in_progress`?(0,$.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 animate-pulse motion-reduce:animate-none`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,$.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,$.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]}):(0,$.jsx)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-soft-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})})}function Mo(e){switch(e){case`done`:return`done`;case`running`:case`waiting`:case`review`:return`active`;case`failed`:case`cancelled`:return`failed`;case`pending`:case`skipped`:return`pending`}}function No(e){if(e.length===0)return 0;let t=new Set([`done`,`failed`,`cancelled`,`skipped`]),n=new Set([`running`,`waiting`,`review`]),r=0;for(let i of e)t.has(i.status)?r+=1:n.has(i.status)&&(r+=.5);return r/e.length}function Po({steps:e}){if(e.length===0)return null;let t=No(e)*100;return(0,$.jsxs)(`div`,{"data-slot":`step-rail`,className:`flex min-w-0 flex-col gap-1`,children:[e.map((t,n)=>(0,$.jsxs)(`div`,{"data-slot":`step-row`,"data-visual":Mo(t.status),className:`flex min-h-[22px] min-w-0 items-center gap-2 text-[13px] text-muted-foreground`,children:[(0,$.jsx)(Fo,{visual:Mo(t.status)}),(0,$.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,children:t.name}),t.iterations>1?(0,$.jsxs)(`span`,{"data-slot":`step-iterations`,className:`shrink-0 text-xs text-soft-foreground tabular-nums`,children:[`×`,t.iterations]}):null,(0,$.jsxs)(`span`,{className:`ml-auto shrink-0 pl-2 text-[11px] text-soft-foreground tabular-nums`,children:[t.kind,` · step `,n+1,` of `,e.length]})]},t.id)),(0,$.jsx)(`div`,{"data-slot":`step-progress`,className:`mt-1 h-0.5 overflow-hidden rounded-full bg-muted`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-pending`,style:{width:`${t}%`}})})]})}function Fo({visual:e}){let t=`size-[13px] shrink-0`;switch(e){case`done`:return(0,$.jsx)(Pe,{"aria-hidden":!0,className:c(t,`text-success`)});case`active`:return(0,$.jsx)(it,{role:`status`,"aria-label":`Step running`,className:c(t,`animate-spin stroke-pending motion-reduce:animate-none`)});case`failed`:return(0,$.jsx)(we,{"aria-hidden":!0,className:c(t,`text-danger`)});case`pending`:return(0,$.jsx)(ke,{"aria-hidden":!0,className:c(t,`text-soft-foreground`)})}}var Io={done:`done`,failed:`failed`,cancelled:`cancelled`};function Lo(e){let t=Io[e.status];return t?e.steps.map(e=>Mo(e.status)===`active`?{...e,status:t}:e.status===`pending`?{...e,status:`skipped`}:e):e.steps}function Ro(e,t){let n=t.findIndex(t=>t.id===e);if(n>=0)return n;let r=t.reduce((e,t,n)=>Mo(t.status)===`active`?n:e,-1);if(r>=0)return r;let i=t.findIndex(e=>e.status===`pending`);return i>=0?i:t.reduce((e,t,n)=>t.status===`skipped`?e:n,0)}function zo({items:e,lead:t=0}){let n=(0,Q.useRef)(null),[r,i]=(0,Q.useState)(-1/0);return(0,Q.useLayoutEffect)(()=>{let r=n.current;if(!r)return;let a=()=>{let n=r.getBoundingClientRect().width;if(!n&&r.getClientRects().length===0)return;let a=getComputedStyle(r),o=Number.parseFloat(a.width),s=o>0?n/o:1,c=(Number.parseFloat(a.columnGap)||0)*s,l=Array.from(r.children,e=>e.getBoundingClientRect().width),u=e.map((e,t)=>({...e,width:l[t]??0})),d=-1/0,f=()=>u.reduce((e,t)=>e+t.width,0)+Math.max(0,u.length-1)*c+(u.length>0?t*s:0);for(let t of[...new Set(e.map(e=>e.priority))].sort((e,t)=>e-t)){if(f()<=n)break;d=t,u=u.filter(e=>e.priority>t)}i(e=>e===d?e:d)};if(a(),typeof ResizeObserver>`u`)return;let o=new ResizeObserver(a);o.observe(r);for(let e of r.children)o.observe(e);return()=>o.disconnect()},[e,t]),(0,$.jsx)(`span`,{ref:n,"data-slot":`activity-summary`,className:`relative flex h-[max(1.5em,22px)] min-w-0 flex-1 items-center gap-2.5 overflow-clip whitespace-nowrap text-[13px] font-normal text-muted-foreground tabular-nums`,children:e.map(n=>{let i=n.priority<=r,a=n===e.find(e=>e.priority>r);return(0,$.jsx)(`span`,{"data-summary-item":n.id,"data-hidden":i,"aria-hidden":i||void 0,inert:i||void 0,style:a&&t?{marginInlineStart:t}:void 0,className:`inline-flex w-max shrink-0 items-center gap-1.5 data-[hidden=true]:invisible data-[hidden=true]:absolute`,children:n.content},n.id)})})}function Bo({run:e,references:t}){return(0,$.jsx)(`span`,{className:`inline-flex items-center gap-1.5`,children:t.map(t=>(0,$.jsx)(gt,{reference:t,taskTitle:W(e),inert:!0},ge(t)))})}function Vo(e){return e.accountId===void 0||e.profilesPending?void 0:e.profilesError?e.accountId:e.accountId==="default"?Ot(e.accounts,e.accountBackend)?`default`:void 0:e.known?Ot(e.accounts,e.accountBackend)?e.known.label:void 0:`${e.accountId} (removed)`}function Ho(e){let t=L(),n=F(),{accounts:r}=Et(),i=e.runner??t.data?.defaultRunner??`claude`,a=e.model??`auto`,o=e.effort||`auto`,s=[...e.steps].reverse().find(e=>e.profileId),c=s?.profileId,l=s?.backend??i,u=n.data?.profiles.find(e=>e.id===c&&e.provider===l),d=Vo({accountId:c,profilesPending:n.isPending,profilesError:n.isError,known:u,accounts:r,accountBackend:l}),f=e.modelIdentity&&e.modelIdentity!==a?e.modelIdentity:void 0;return{runner:i,...d?{account:d}:{},model:a,effort:o,...f?{identity:f}:{}}}var Uo=[`running`,`queued`,`waiting`];function Wo(e){return Array.isArray(e)?e.filter(e=>e?.kind===`pr`||e?.kind===`timer`||e?.kind===`worker`||e?.kind===`process`||e?.kind===`peer`||e?.kind===`subagent`):[]}function Go(e){let t=e?new Date(e):void 0;return t&&Number.isFinite(t.getTime())?new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(t):void 0}function Ko(e,t){return`${e} — ${t.status===`failed`?`not delivered; Continue delivers it, Stop discards it`:t.status===`running`?`current turn still working`:`waiting for capacity`}`}function qo(e){return e.kind!==`worker`&&e.kind!==`peer`&&e.kind!==`subagent`}function Jo(e){let t=Wo(e.waits),n=Uo.includes(e.status),r=t.filter(t=>t.phase===`open`?n:t.phase===`resolved`&&qo(t)&&(n||e.status===`failed`)),i=r.some(e=>e.kind===`pr`),a=[...Wo(e.lastWaits),...t.filter(e=>!r.includes(e)&&e.phase!==`open`)],o=i?void 0:a.filter(e=>e.kind===`pr`).at(-1),s=i?void 0:e.lastWaitsError,c=r.some(e=>e.kind===`process`)?void 0:a.filter(e=>e.kind===`process`).at(-1);return r.length||o||s||c?{open:r,lastCi:o,error:s,lastProcess:c}:void 0}function Yo(e){return Jo(e)!==void 0}function Xo(e){return(Jo(e)?.open??[]).filter(e=>e.kind===`pr`).map(e=>({kind:`PR`,number:e.prNumber,url:e.prUrl}))}function Zo({run:e}){let t=Jo(e);if(!t)return null;let{open:n,lastCi:r,error:i,lastProcess:a}=t;return(0,$.jsxs)(`div`,{"data-slot":`open-waits`,className:`flex min-w-0 flex-col gap-1`,children:[n.map(t=>t.kind===`pr`?(0,$.jsx)($o,{run:e,wait:t},t.id):t.kind===`worker`?(0,$.jsx)(es,{wait:t},t.id):t.kind===`process`?(0,$.jsx)(as,{run:e,wait:t},t.id):t.kind===`peer`?(0,$.jsx)(ts,{wait:t},t.id):t.kind===`subagent`?(0,$.jsx)(ns,{wait:t},t.id):(0,$.jsx)(rs,{run:e,wait:t},t.id)),i?(0,$.jsx)(`div`,{"data-slot":`ci-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:i}):r?(0,$.jsx)($o,{run:e,wait:r,settled:!0}):null,a?(0,$.jsx)(as,{run:e,wait:a,settled:!0}):null]})}function Qo(e,t,n){let r=t.result,i=t.until!==`checks`,a={passed:`CI checks passed — observed checks only; not merge approval`,failed:`CI checks failed — inspect the PR checks`,conflicting:i?`PR has merge conflicts — inspect the PR; not merged`:`PR has merge conflicts — inspect the PR; not merge approval`,cancelled:i?`Merge wait cancelled`:`CI wait cancelled`,skipped:`CI checks skipped — inspect the PR checks`,no_checks:`No CI checks found — inspect the PR workflows`,deadline:i?`Merge wait timed out — merge not confirmed`:`CI wait timed out — inspect the PR checks`,error:i?`Merge wait unavailable — inspect access and the PR`:`CI wait unavailable — inspect access and the PR checks`,head_changed:`CI head changed — ${r?.headSha.slice(0,7)} → ${r?.observedHeadSha?.slice(0,7)??`unknown`}`,merged:`PR merged`,closed:`PR closed without merge — inspect the PR`,blocked:`Initiated merge blocked — inspect the PR; not merged`},o=i?`Merge`:`CI`,s=n&&t.phase===`cancelled`;return n?s?`${o} wait cancelled`:r?a[r.outcome]:`${o} wait unavailable`:t.phase===`resolved`?Ko(`${o} result ready`,e):t.until===`merge_or_blocked`?`Waiting for merge or blockage`:i?`Waiting for merge`:`Waiting for CI`}function $o({run:e,wait:t,settled:n=!1}){let r=t.result,i=t.until===`checks`?`CI`:`Merge`,o=n&&t.phase===`cancelled`,s=Qo(e,t,n),c=n?o?t.cancelledAt:r?.observedAt:t.deadline,l=Go(c),u=`${t.repository}#${t.prNumber}`;return(0,$.jsx)(`div`,{"data-slot":`ci-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-[13px] text-muted-foreground [overflow-wrap:anywhere]`,children:(0,$.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-baseline gap-x-3 gap-y-1`,children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Status`}),(0,$.jsx)(`dd`,{children:s}),(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Pull request`}),(0,$.jsx)(`dd`,{className:`min-w-0`,children:a(t.prUrl)?(0,$.jsx)(`a`,{href:t.prUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-h-11 min-w-11 max-w-full items-center rounded-sm px-1 font-medium text-foreground underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:bg-muted`,children:u}):(0,$.jsx)(`span`,{children:u})}),l?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:n?o?`Cancelled`:`Observed`:`Deadline`}),(0,$.jsx)(`dd`,{children:(0,$.jsx)(`time`,{dateTime:c,children:l})})]}):n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Deadline`}),(0,$.jsxs)(`dd`,{children:[i,` deadline unavailable`]})]})]})})}function es({wait:e}){let t=e.workerIds!==void 0,n=new Set((t?e.outcomes:e.requestOutcomes)?.map(e=>`workerId`in e?e.workerId:e.requestId)),r=(e.workerIds??e.requestIds??[]).filter(e=>!n.has(e)).length,i=t?r===1?`worker`:`workers`:r===1?`request reply`:`request replies`,a=Go(e.deadline);return(0,$.jsxs)(`div`,{"data-slot":`worker-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,$.jsxs)(`p`,{children:[`Waiting on `,r,` `,i]}),a?(0,$.jsxs)(`p`,{children:[`Deadline`,` `,(0,$.jsx)(`time`,{dateTime:e.deadline,children:a})]}):(0,$.jsx)(`p`,{children:`Worker wait deadline unavailable`})]})}function ts({wait:e}){let t=e.peerIds.length,n=Go(e.deadline);return(0,$.jsxs)(`div`,{"data-slot":`peer-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,$.jsxs)(`p`,{children:[`Waiting on `,t,` `,t===1?`task`:`tasks`]}),n?(0,$.jsxs)(`p`,{children:[`Deadline`,` `,(0,$.jsx)(`time`,{dateTime:e.deadline,children:n})]}):(0,$.jsx)(`p`,{children:`Peer wait deadline unavailable`})]})}function ns({wait:e}){let t=(Array.isArray(e.children)?e.children:[]).filter(e=>e?.status===`running`).length,n=Go(e.deadline);return(0,$.jsxs)(`div`,{"data-slot":`subagent-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,$.jsxs)(`p`,{children:[`Waiting for `,t,` `,t===1?`subagent`:`subagents`]}),n?(0,$.jsxs)(`p`,{children:[`Check by`,` `,(0,$.jsx)(`time`,{dateTime:e.deadline,children:n})]}):(0,$.jsx)(`p`,{children:`Subagent wait deadline unavailable`})]})}function rs({run:e,wait:t}){let n=Go(t.deadline);return(0,$.jsxs)(`div`,{"data-slot":`monitoring-schedule`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[t.phase===`resolved`?(0,$.jsx)(`p`,{children:Ko(`Automatic check due`,e)}):n?(0,$.jsxs)(`p`,{children:[`Next automatic check`,` `,(0,$.jsx)(`time`,{dateTime:t.deadline,className:`font-medium text-foreground`,children:n})]}):(0,$.jsx)(`p`,{children:`Automatic check time unavailable`}),t.note?(0,$.jsx)(`p`,{children:t.note}):null]})}function is(e){let t=e.result;return t?t.outcome===`exit_file`?t.exitCode===void 0?`PID ${e.pid} wrote an exit file that is not an exit code`:`PID ${e.pid} exited with code ${t.exitCode}`:t.outcome===`exited`?e.startToken===void 0&&t.observedAt===e.registeredAt?`PID ${e.pid} was not running when the wait was registered`:`PID ${e.pid} exited, code unknown`:t.outcome===`deadline`?`PID ${e.pid} still running at the deadline`:`PID ${e.pid} could not be checked`:`PID ${e.pid} still running at the deadline`}function as({run:e,wait:t,settled:n=!1}){let r=n&&t.phase===`cancelled`?`Process wait on PID ${t.pid} cancelled`:n?is(t):t.phase===`resolved`?Ko(is(t),e):`Waiting for PID ${t.pid}${t.note?` — ${t.note}`:``}`,i=!n&&t.phase===`open`?Go(t.deadline):void 0;return(0,$.jsxs)(`div`,{"data-slot":`process-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,$.jsx)(`p`,{children:r}),i?(0,$.jsxs)(`p`,{children:[`Until`,` `,(0,$.jsx)(`time`,{dateTime:t.deadline,children:i})]}):null]})}var os=new Map,ss=new Map;function cs(e){let{referenceProjectId:t,repoBase:n,references:r,requests:i}=We(e.run);return(0,$.jsx)(mt,{projectId:t,repoBase:n,requests:i,children:(0,$.jsx)(ls,{...e,references:r,prNumbers:i.filter(e=>e.kind===`PR`).map(e=>e.number),hasReferences:r.length>0||!!pe(e.run)||!!fe(e.run,n)})})}function ls({run:e,thread:t,currentThread:n,currentComplete:r=!0,onOpenWorker:i,readerScroll:a,prNumbers:o,hasReferences:s,references:c}){let l=he(),u=Ho(e),[d,f]=(0,Q.useState)(()=>os.get(e.id)??!1),p=Ts(a,d),m=p.open,[h,g]=(0,Q.useState)({}),_=us(e,t??n,n,r,o),v=Ge(e),y=t=>h[t]??ss.get(`${e.id}:${t}`)??t===`workers`,b=t=>{let n=!y(t);ss.set(`${e.id}:${t}`,n),g(e=>({...e,[t]:n}))},x=e=>({open:y(e),onToggle:()=>b(e)});return(0,$.jsxs)(`section`,{"data-slot":`run-activity-dock`,ref:p.ref,"data-state":m?`open`:`collapsed`,className:`min-w-0 overflow-hidden rounded-xl border border-border bg-card shadow-xs`,children:[(0,$.jsx)(hs,{run:e,identity:u,activity:_,references:c,open:m,onToggle:()=>{os.set(e.id,!m),f(!m),p.chose(!m)}}),m?(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col border-t border-border`,children:[(0,$.jsx)(vs,{run:e,activity:_,...x(`status`)}),(0,$.jsx)(ys,{run:e,desktop:l,automations:_.automations,...x(`workflow`)}),(0,$.jsx)(bs,{activity:_,desktop:l,onOpenWorker:i,...x(`subagents`)}),(0,$.jsx)(xs,{run:e,...x(`workers`)}),(0,$.jsx)(Ss,{activity:_,desktop:l,...x(`plan`)}),(0,$.jsx)(Cs,{run:e,identity:u,activity:_,...x(`usage`)}),(0,$.jsx)(ws,{run:e,references:c,conflicts:_.conflicts,hasReferences:s,onResume:()=>v.mutate(),...x(`workspace`)})]}):null]})}function us(e,t,n,r,i){let a=A(),o=cn(a.data),s=M(),c=ze(e,{queuePosition:e.status===`queued`?ce(s.data??[]).get(e.id):void 0}),l=ht(i),u=!ue(e)&&e.status!==`queued`,d=(0,Q.useMemo)(()=>r?Ci(n.turns,u,t.turns):[],[r,n.turns,u,t.turns]),f=pt(n)??[],p=Ve(e),m=Ti(d),h=Oo(f);return{line:c,...ds(e,c,p,r?m:void 0,h),...fs(e,o),conflicts:l,waitReferences:Xo(e),agents:d,agentCounts:m,planEntries:f,planCounts:h,automations:St(a.data)}}function ds(e,t,n,r,i){let a=e.steps.every(e=>e.status===`done`||e.status===`skipped`),o=e.status===`done`&&a&&n===`complete`&&r!==void 0&&r.done===r.total&&i.done===i.total;return{allComplete:o,statusText:o?`All complete`:e.status!==`done`||r===void 0?t.label:n===`unknown`?`Workers unavailable`:n===`pending`?`In progress`:`Incomplete`,failed:t.attention.tone===`danger`||e.status===`cancelled`,glyph:o?(0,$.jsx)(Pe,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success`}):(0,$.jsx)(Ut,{tone:t.attention.tone,shape:t.attention.shape,pulse:t.attention.pulse})}}function fs(e,t){return{cost:t.cost&&e.costUsd!==void 0?me(e.costUsd):void 0,tokens:t.tokens&&(e.inputTokens!==void 0||e.outputTokens!==void 0)?(0,$.jsx)(on,{inputTokens:e.inputTokens,outputTokens:e.outputTokens}):void 0}}function ps(e){return e.allComplete?`text-success`:e.failed&&`text-danger`}function ms(e){let t=Lo(e),n=Ro(e.currentStepId,t);return t.length>0?{steps:t,index:n,step:t[n]}:void 0}function hs({run:e,identity:t,activity:n,references:r,open:i,onToggle:a}){let{cost:o}=n,s=[...new Map([...r,...n.waitReferences].map(e=>[ge(e),e])).values()];return(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-label":gs(e,t,n,s,i),onClick:a,className:c(`flex min-h-11 w-full min-w-0 items-center px-3.5 py-2 text-start text-[14px] hover:bg-muted/40 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring`,i?`gap-2.5`:`gap-2`),children:[(0,$.jsx)(ye,{"aria-hidden":!0,className:`size-4 shrink-0 text-accent-text`}),(0,$.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Activity`}),i?null:(0,$.jsx)(_s,{run:e,identity:t,activity:n,summaryReferences:s}),i&&o?(0,$.jsx)(`span`,{"data-slot":`run-activity-cost`,className:`ms-auto shrink-0 text-[13px] text-muted-foreground tabular-nums`,children:o}):null,(0,$.jsx)(Le,{"aria-hidden":!0,className:c(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,i&&!o&&`ms-auto`,i&&`rotate-180`)})]})}function gs(e,t,n,r,i){let{statusText:a,conflicts:o,cost:s}=n,c=`Session activity: ${a}${o.length?`; pull request conflicts`:``}${s?`; cost ${s}`:``}`;if(i)return c;let l=ms(e)?.step,u=l?Mo(l.status):void 0,d=l?`; step ${l.name}, ${u===`active`?`running`:u}`:``,f=r.length?`; ${r.map(e=>`${e.kind} #${e.number}`).join(`; `)}`:``;return`${c}${d}; runner ${t.runner}; model ${t.model}; effort ${t.effort}${f}`}function _s({run:e,identity:t,activity:n,summaryReferences:r}){let{statusText:i,cost:a,conflicts:o}=n,s=ms(e)?.step,l=[{id:`runner`,priority:2,content:t.runner},{id:`model`,priority:4,content:t.model},{id:`effort`,priority:3,content:t.effort},...a?[{id:`cost`,priority:1,content:(0,$.jsx)(`span`,{"data-slot":`run-activity-cost`,children:a})}]:[],...r.length||o.length?[{id:`chips`,priority:0,content:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Bo,{run:e,references:r}),o.length>0?(0,$.jsxs)(`span`,{"data-slot":`run-activity-conflict`,className:`inline-flex items-center gap-1 font-medium text-conflict`,children:[(0,$.jsx)(De,{"aria-hidden":!0,className:`size-3.5`}),`Conflicts`]}):null]})}]:[]];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{"data-slot":`run-activity-status`,title:i,className:c(`inline-flex min-w-[calc(0.875rem+3ch)] flex-[0_1_auto] items-center gap-1.5 text-[13px] whitespace-nowrap text-muted-foreground`,ps(n)),children:[n.glyph,(0,$.jsx)(`span`,{"data-slot":`run-activity-status-label`,className:`min-w-0 truncate`,children:i})]}),s?(0,$.jsxs)(`span`,{"data-slot":`run-activity-step`,className:`flex max-w-max min-w-[calc(1.375rem+2ch)] flex-[1000_1_0] items-center gap-1.5 text-[13px] text-muted-foreground`,children:[(0,$.jsx)(ks,{step:s,decorative:!0}),(0,$.jsx)(`span`,{"data-slot":`run-activity-step-name`,title:s.name,className:`min-w-0 truncate`,children:s.name})]}):null,(0,$.jsx)(`span`,{className:`-ms-2 flex min-w-0 flex-[1_1_0]`,children:(0,$.jsx)(zo,{items:l,lead:8})})]})}function vs({run:e,activity:t,open:n,onToggle:r}){let{line:i,waitReferences:a}=t,o=Xe(e);return(0,$.jsxs)(qe,{slot:`status-row`,icon:t.glyph,title:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{"data-slot":`run-activity-status`,className:c(`truncate`,ps(t)),children:t.statusText}),i.nextCheck?(0,$.jsxs)(`span`,{"data-slot":`run-activity-next-check`,className:`whitespace-normal text-[13px] font-normal text-muted-foreground`,children:[`Next check `,(0,$.jsx)(`time`,{dateTime:i.nextCheck.at,children:i.nextCheck.text})]}):null]}),summary:!n&&a.length>0?(0,$.jsx)(zo,{items:[{id:`chips`,priority:0,content:(0,$.jsx)(Bo,{run:e,references:a})}]}):void 0,open:n,onToggle:Yo(e)||o?r:void 0,children:[(0,$.jsx)(Zo,{run:e}),o?(0,$.jsx)(Ke,{run:e}):null]})}function ys({run:e,desktop:t,automations:n,open:r,onToggle:i}){let a=_e(e),o=ms(e);return!a&&!o?null:(0,$.jsxs)(qe,{slot:`workflow`,icon:o?(0,$.jsx)(ks,{step:o.step}):(0,$.jsx)(Oe,{className:`size-4`}),title:(0,$.jsxs)($.Fragment,{children:[`Workflow`,a?(0,$.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` · `,a]}):null]}),meta:o?{drop:o.step.name,keep:tt(o.index+1,o.steps.length,t,`step`)}:void 0,open:r,onToggle:i,children:[o?(0,$.jsx)(Po,{steps:o.steps}):null,(0,$.jsx)(Os,{run:e,available:n})]})}function bs({activity:e,desktop:t,onOpenWorker:n,open:r,onToggle:i}){let{agents:a,agentCounts:o}=e;return a.length===0?null:(0,$.jsx)(qe,{slot:`subagents`,icon:(0,$.jsx)(Ee,{className:`size-4`}),title:`Subagents`,meta:tt(o.done,o.total,t),open:r,onToggle:i,children:(0,$.jsx)(To,{agents:a,onSelect:n})})}function xs({run:e,open:t,onToggle:n}){return e.delegation?.role===`root`?(0,$.jsx)(Qe,{run:e,open:t,onToggle:n}):null}function Ss({activity:e,desktop:t,open:n,onToggle:r}){let{planEntries:i,planCounts:a}=e;return i.length===0?null:(0,$.jsx)(qe,{slot:`plan`,icon:(0,$.jsx)(Ce,{className:`size-4`}),title:`Plan`,meta:tt(a.done,a.total,t),open:n,onToggle:r,children:(0,$.jsx)(ko,{entries:i})})}function Cs({run:e,identity:t,activity:n,open:r,onToggle:i}){let{cost:a,tokens:o}=n,s=e.modelIdentity?.includes(`/`)?e.modelIdentity.split(`/`)[0]:void 0,c=[...s?[{id:`provider`,priority:2,content:s}]:[],{id:`model`,priority:4,content:t.model},{id:`effort`,priority:3,content:t.effort},...a?[{id:`cost`,priority:1,content:a}]:[],...o?[{id:`tokens`,priority:0,content:o}]:[]];return(0,$.jsx)(qe,{slot:`usage`,icon:(0,$.jsx)(bn,{className:`size-4`}),title:`Usage & agent`,summary:(0,$.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`contents`,children:(0,$.jsx)(zo,{items:c})}),open:r,onToggle:i,children:(0,$.jsx)(Ds,{run:e,tokens:o,cost:a})})}function ws({run:e,references:t,conflicts:n,hasReferences:r,onResume:i,open:a,onToggle:o}){let s=e.delegation?.role===`worker`?e.delegation.destroy:void 0;if(!(e.branch||e.worktreePath||r||Gt(e)||Be(s)))return null;let c=n.length===1?`PR #${n[0]} conflicts`:`${n.length} PRs conflict`;return(0,$.jsx)(qe,{slot:`workspace`,icon:(0,$.jsx)(Ae,{className:`size-4`}),title:`Workspace`,summary:!a&&t.length>0?(0,$.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`contents`,children:(0,$.jsx)(zo,{items:[...e.branch?[{id:`branch`,priority:0,content:(0,$.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.branch})}]:[],{id:`chips`,priority:1,content:(0,$.jsx)(Bo,{run:e,references:t})},...n.length>0?[{id:`conflicts`,priority:2,content:(0,$.jsx)(`span`,{className:`font-medium text-conflict`,children:c})}]:[]]})}):void 0,meta:n.length>0?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-medium text-conflict`,children:[(0,$.jsx)(De,{"aria-hidden":!0,className:`size-3.5`}),c]}):e.branch?(0,$.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.branch}):void 0,open:a,onToggle:o,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 text-[13px] text-muted-foreground`,children:[s?(0,$.jsx)(Ye,{state:s}):null,(0,$.jsx)(Ze,{run:e}),e.branch?(0,$.jsx)(Es,{label:`Branch`,children:(0,$.jsx)(Ue,{branch:e.branch})}):null,e.worktreePath?(0,$.jsx)(Es,{label:`Worktree`,children:(0,$.jsx)(`span`,{className:`min-w-0 break-all font-mono text-[12px] text-foreground`,children:e.worktreePath})}):null,(0,$.jsx)(Je,{run:e,canResume:sn(e).terminal,onResume:i})]})})}function Ts(e,t){let n=(0,Q.useRef)(null),[r,i]=(0,Q.useState)(!1),a=(0,Q.useRef)(t);a.current=t;let o=(0,Q.useRef)({active:!1,override:!1});return(0,Q.useEffect)(()=>e?.(e=>{if(e.direction===`tail`){o.current={active:!1,override:!1},i(!1);return}if(e.direction===`down`){i(!1);return}if(o.current.active=!0,o.current.override||!a.current)return;let t=n.current?.closest(`[data-slot="thread-dock"]`);!t||getComputedStyle(t).position!==`sticky`||e.distanceFromBottom<=t.getBoundingClientRect().height||i(!0)}),[e]),{ref:n,open:t&&!r,chose:e=>{i(!1),e&&o.current.active&&(o.current.override=!0)}}}function Es({label:e,children:t}){return(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`w-20 shrink-0 font-medium text-foreground`,children:e}),t]})}function Ds({run:e,tokens:t,cost:n}){let{runner:r,account:i,model:a,effort:o,identity:s}=Ho(e);return(0,$.jsxs)(`dl`,{"data-slot":`agent-details`,className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-[13px]`,children:[t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Tokens`}),(0,$.jsx)(`dd`,{className:`min-w-0 text-[12px]`,children:t})]}):null,n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Cost`}),(0,$.jsx)(`dd`,{className:`min-w-0 font-mono text-[12px] tabular-nums`,children:n})]}):null,(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Runner`}),(0,$.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px]`,children:r}),i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Account`}),(0,$.jsx)(`dd`,{"data-slot":`agent-badge-account`,className:`min-w-0 break-all font-mono text-[12px]`,children:i})]}):null,(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Model`}),(0,$.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px]`,children:a}),(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Effort`}),(0,$.jsx)(`dd`,{"data-slot":`agent-badge-effort`,className:`min-w-0 break-all font-mono text-[12px]`,children:o}),s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Identity`}),(0,$.jsx)(`dd`,{"data-slot":`agent-badge-identity`,className:`min-w-0 break-all font-mono text-[12px]`,children:s})]}):null]})}function Os({run:e,available:t}){if(!e.automation)return null;let n=`inline-flex min-h-11 items-center rounded-sm text-[13px] font-medium md:min-h-8`;return(0,$.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[`Launched by`,` `,t?(0,$.jsx)(J,{to:`/automations/${encodeURIComponent(e.automation.automationId)}/log`,className:c(n,`text-foreground underline underline-offset-2`),children:`Automation`}):(0,$.jsx)(`span`,{"data-slot":`automation-origin`,title:`Automations are off on this server (CEZ_AUTOMATIONS)`,className:n,children:`Automation`})]})}function ks({step:e,decorative:t=!1}){let n=Mo(e.status),r=`size-4 shrink-0`;switch(n){case`active`:return(0,$.jsx)(it,{...t?{"aria-hidden":!0}:{role:`status`,"aria-label":`Step running`},"data-slot":`workflow-glyph`,"data-visual":n,className:c(r,`animate-spin stroke-pending motion-reduce:animate-none`)});case`failed`:return(0,$.jsx)(we,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":n,className:c(r,`text-danger`)});case`pending`:return(0,$.jsx)(ke,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":n,className:c(r,`text-soft-foreground`)});case`done`:return(0,$.jsx)(Pe,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":n,className:c(r,`text-success`)})}}var As={finish:`Closed when the task finished`,superseded:`Closed when the worker went on`,"parent-stopped":`Closed when the parent stopped`,"worker-stopped":`Closed when the worker stopped`,undeliverable:`Closed: not delivered`};function js(e,t,n){return`${e.header}: ${n?.trim()||t.join(`, `)}`}function Ms({ask:e,run:t,onShowOrigin:n}){let r=e.context?(0,$.jsx)(Ps,{text:e.context}):null;if(e.resolved)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r,(0,$.jsxs)(Nr,{role:`user`,"data-slot":`ask-card`,"data-resolved":`true`,children:[(0,$.jsx)(`span`,{className:`text-soft-foreground`,children:e.closed?As[e.closed]:e.answeredBy===`parent`?`Answered by parent`:`Answered`}),(0,$.jsx)(Ki,{ask:e})]})]});let i=e.placement===`pinned`&&n?n:void 0;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r,e.routedToParent?(0,$.jsx)(Fs,{ask:e,onShowOrigin:i}):(0,$.jsx)(Is,{ask:e,run:t,onShowOrigin:i})]})}function Ns({onShowOrigin:e}){return(0,$.jsx)(s,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-origin`,className:`mbs-2 min-h-11 min-w-11 px-2 text-xs font-medium text-muted-foreground underline underline-offset-4`,onClick:e,children:`Show where it was asked`})}function Ps({text:e}){return(0,$.jsx)(Nr,{role:`agent`,children:(0,$.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`break-words text-sm text-foreground`,children:(0,$.jsx)(Wt,{breaks:!0,children:e})})})}function Fs({ask:e,onShowOrigin:t}){return(0,$.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-routed":`parent`,className:`rounded-lg border border-border bg-card px-4 pt-3.5 pb-3.5`,children:[(0,$.jsx)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:(0,$.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking its parent`})}),(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,$.jsxs)(`div`,{role:`group`,"aria-label":e.question,children:[(0,$.jsx)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:(0,$.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e.header})}),(0,$.jsx)(`p`,{className:`mb-1.5 break-words text-sm font-semibold text-foreground`,children:e.question}),e.options?(0,$.jsx)(`ul`,{className:`flex list-disc flex-col gap-0.5 pl-5 text-[13px] text-muted-foreground`,children:e.options.map(e=>(0,$.jsxs)(`li`,{className:`break-words`,children:[(0,$.jsx)(`span`,{className:`text-foreground`,children:e.label}),e.description?(0,$.jsxs)(`span`,{children:[`: `,e.description]}):null]},e.label))}):(0,$.jsx)(`p`,{"data-slot":`ask-open-routed`,className:`text-[13px] text-muted-foreground`,children:`Open question: answered in words, with no options.`})]},e.id??t))}),(0,$.jsxs)(`p`,{"data-slot":`ask-routed-hint`,className:`mt-3 text-xs text-muted-foreground`,children:[`Routed to parent: answer it in the`,` `,e.parentRunId?(0,$.jsx)(J,{to:`/tasks/${e.parentRunId}`,className:`font-medium text-foreground underline underline-offset-4`,children:`parent task`}):`parent task`,`.`]}),t?(0,$.jsx)(Ns,{onShowOrigin:t}):null]})}function Is({ask:e,run:t,onShowOrigin:n}){let r=mn(t),i=r.blockedBy!==void 0,a=e.questions,o=a.length===1&&a[0]?.options!==void 0&&a[0]?.multiSelect!==!0,[s,c]=(0,Q.useState)({}),[l,u]=(0,Q.useState)({}),d=(e,t)=>c(n=>({...n,[e]:t})),f=e=>u(t=>{if(t[e]===void 0)return t;let n={...t};return delete n[e],n}),p=e=>{d(e,[]),u(t=>({...t,[e]:t[e]??``}))},m=a.some((e,t)=>!e.options||l[t]!==void 0),h=a.every((e,t)=>(s[t]?.length??0)>0||!!l[t]?.trim()),g=()=>void r.send(a.map((e,t)=>js(e,s[t]??[],l[t])).join(`
|
|
9
|
-
`)),_=r.mode===`resume`;return(0,$.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-delivery":r.mode,className:`rounded-lg border border-accent-strong/25 bg-accent-strong/[0.04] [html:not(.light)_&]:bg-card px-4 pt-3.5 pb-3.5`,children:[(0,$.jsx)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:(0,$.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking`})}),(0,$.jsx)(`div`,{className:`flex flex-col gap-4`,children:a.map((e,t)=>(0,$.jsx)(Rs,{question:e,disabled:r.isPending||i,selected:s[t]??[],isOther:l[t]!==void 0,otherAnswer:l[t]??``,onSelect:n=>{i||(f(t),o?r.send(js(e,n)):d(t,n))},onOtherToggle:()=>{i||(l[t]===void 0?p(t):f(t))},onOtherChange:e=>u(n=>({...n,[t]:e}))},e.id??t))}),(0,$.jsx)(Ls,{oneTap:o,hasOtherAnswer:m,resuming:_,disabled:r.isPending||i||!h,questionCount:a.length,onSend:g}),r.blockedBy===`provider`?(0,$.jsxs)(`div`,{"data-slot":`ask-provider-gate`,className:`mt-3 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:r.reason}),(0,$.jsx)(J,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null,r.blockedBy===`no-session`?(0,$.jsx)(`p`,{"data-slot":`ask-no-session`,className:`mt-3 text-xs text-muted-foreground`,children:r.reason}):null,r.error?(0,$.jsx)(`p`,{"data-slot":`ask-error`,role:`alert`,className:`mt-3 text-xs text-danger`,children:r.error}):null,n?(0,$.jsx)(Ns,{onShowOrigin:n}):null]})}function Ls({oneTap:e,hasOtherAnswer:t,resuming:n,disabled:r,questionCount:i,onSend:a}){return e&&!t?n?(0,$.jsx)(`p`,{"data-slot":`ask-resume-hint`,className:`mbs-3 text-[11px] text-soft-foreground`,children:`The session has ended — your answer reopens it and goes to the agent.`}):null:(0,$.jsxs)(`div`,{className:`mbs-3 flex items-center gap-2.5`,children:[(0,$.jsx)(s,{size:`sm`,className:`min-h-11`,disabled:r,onClick:a,children:n?`Send answer & reopen`:`Send answer`}),(0,$.jsx)(`span`,{"data-slot":n?`ask-resume-hint`:`ask-hint`,className:`text-[11px] text-soft-foreground`,children:n?`the session has ended — sending reopens it`:t?`${i>1?`answer each question above`:`enter your answer above`} — or type a reply below`:`${i>1?`answer each question`:`pick one or more`} — or type a reply below`})]})}function Rs({question:e,disabled:t,selected:n,isOther:r,otherAnswer:i,onSelect:a,onOtherToggle:o,onOtherChange:l}){let u=(0,Q.useId)(),d=e.options,f=d!==void 0&&e.multiSelect===!0,p=e=>{if(!f){a([e]);return}a(n.includes(e)?n.filter(t=>t!==e):[...n,e])};return(0,$.jsxs)(`div`,{"data-slot":`ask-question`,role:`group`,"aria-label":e.question,children:[(0,$.jsxs)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`rounded-md bg-accent-strong px-1.5 py-0.5 text-[12px] font-semibold uppercase tracking-wide text-accent-strong-foreground`,children:e.header}),f?(0,$.jsx)(`span`,{className:`ml-auto text-[11px] text-soft-foreground`,children:`select all that apply`}):null]}),(0,$.jsx)(`p`,{className:`mb-2.5 break-words text-sm font-semibold text-foreground`,children:e.question}),d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:d.map(e=>{let r=n.includes(e.label);return(0,$.jsxs)(`button`,{type:`button`,disabled:t,"aria-pressed":r,onClick:()=>p(e.label),className:c(`flex min-h-11 w-full flex-col gap-0.5 rounded-md border px-3.5 py-2.5 text-left transition-colors`,`hover:border-accent-strong/50 hover:bg-accent-strong/[0.06] [html:not(.light)_&]:hover:bg-card disabled:pointer-events-none disabled:opacity-50`,r?`border-accent-strong/60 bg-accent-strong/[0.06] [html:not(.light)_&]:bg-card`:`border-border bg-card`),children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2 text-[14px] font-semibold text-foreground`,children:[f?(0,$.jsx)(`span`,{"aria-hidden":!0,className:c(`flex size-4 shrink-0 items-center justify-center rounded border text-[12px]`,r?`border-accent-strong bg-accent-strong text-accent-strong-foreground`:`border-soft-foreground`),children:r?`✓`:``}):null,(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]}),e.description?(0,$.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:e.description}):null]},e.label)})}),(0,$.jsxs)(`div`,{className:`mt-2`,children:[(0,$.jsx)(s,{type:`button`,variant:`outline`,"aria-pressed":r,"aria-expanded":r,"aria-controls":r?u:void 0,disabled:t,onClick:o,className:c(`w-full justify-start text-left`,r&&`border-accent-strong/60 bg-accent-strong/[0.06] [html:not(.light)_&]:bg-card`),children:`Other`}),r?(0,$.jsxs)(`div`,{className:`mt-2.5`,children:[(0,$.jsx)(`label`,{htmlFor:u,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,$.jsx)(Nt,{id:u,rows:2,value:i,disabled:t,onChange:e=>l(e.target.value),className:`bg-card`})]}):null]})]}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:u,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,$.jsx)(Nt,{id:u,rows:2,value:i,disabled:t,onChange:e=>l(e.target.value),className:`bg-card`})]})]})}var zs=2e3;function Bs(e){let t=0,n=0;for(let r of e)typeof r.seq==`number`&&(r.type===`session.ended`&&r.seq>t&&(t=r.seq),(r.type===`session.started`||r.type===`step-start`&&r.kind===`agent`)&&r.seq>n&&(n=r.seq));return t>n?t:0}function Vs(e){let t=0,n=0;for(let r of e)typeof r.seq==`number`&&(r.type===`turn-end`&&r.seq>t&&(t=r.seq),(r.type===`turn.started`||r.type===`session.started`||r.type===`user-message`||r.type===`step-start`&&r.kind===`agent`)&&r.seq>n&&(n=r.seq));return t>n?t:0}function Hs(e,t){let n=v(),r=(0,Q.useMemo)(()=>Bs(t),[t]),i=(0,Q.useMemo)(()=>Vs(t),[t]),a=e?.id,o=e?.status;(0,Q.useEffect)(()=>{if(!(r!==0&&(o===`running`||o===`waiting`))&&!(i!==0&&o===`running`)||a===void 0)return;let e=setTimeout(()=>{n.invalidateQueries({queryKey:B.runs.detail(a)}),n.invalidateQueries({queryKey:B.runs.list()})},zs);return()=>clearTimeout(e)},[r,i,a,o,n])}function Us(e){let t=e.querySelector(`[data-slot="ask-origin"]`);return t&&(t.tabIndex=-1),t}function Ws({pendingAskId:e,askSeq:t,rows:n,history:r,jumpToRow:i}){let[a,o]=(0,Q.useState)(void 0),s=(0,Q.useCallback)(()=>o(e),[e]),c=r?.visibleEvents,l=t!==void 0&&(c?.some(({seq:e})=>e===t)??!1),u=r?.hasOlder??!1,d=r?.isFetchingOlder??!1,f=r?.olderError,p=r?.loadOlder;return(0,Q.useEffect)(()=>{if(a===void 0)return;if(a!==e){o(void 0);return}let r=Ba(n,a,`origin`);if(r){o(void 0),i(r.key,r.index,Us);return}if(!(p!==void 0&&u&&f===void 0&&t!==void 0&&!l)){o(void 0);return}d||p().catch(()=>{})},[a,e,n,c,l,u,d,f,p,t,i]),{reveal:s,seeking:a!==void 0&&a===e}}function Gs(){let e=(0,Q.useRef)(null);return(0,Q.useLayoutEffect)(()=>{let t=e.current,n=t?.closest(`[data-slot="main"]`),r=t?.querySelector(`[data-slot="run-header"]`),i=t?.querySelector(`[data-slot="thread-dock"]`);if(!n||!r||!i)return;let a=()=>{n.style.setProperty(`--thread-viewport-height`,`${n.clientHeight}px`),n.style.setProperty(`--thread-header-height`,`${r.getBoundingClientRect().height}px`),n.style.setProperty(`--thread-footer-height`,`${i.getBoundingClientRect().height}px`)};a();let o=new ResizeObserver(a);return o.observe(r),o.observe(i),o.observe(n),()=>{o.disconnect(),n.style.removeProperty(`--thread-header-height`),n.style.removeProperty(`--thread-footer-height`),n.style.removeProperty(`--thread-viewport-height`)}},[]),e}function Ks(){let{id:e}=n(),t=R(e),r=an(e),i=t.data?.status,a=(0,Q.useMemo)(()=>lt(r.visibleEvents,{activeTurn:i===`running`}),[r.visibleEvents,i]),o=(0,Q.useMemo)(()=>lt(r.currentEvents,{activeTurn:i===`running`}),[r.currentEvents,i]),c=(0,Q.useRef)(void 0),l=(0,Q.useCallback)(e=>{c.current=e},[]),{mutate:u}=k();if((0,Q.useEffect)(()=>{t.data&&c.current!==t.data.id&&de(t.data)&&u(t.data.id)},[u,t.data?.id,t.data?.status,t.data?.finishedAt,t.data?.seenAt,t.data?.archived]),Hs(t.data,r.visibleEvents),t.isPending)return(0,$.jsx)(pn,{});if(t.isError){let e=t.error instanceof C&&t.error.status===404;return(0,$.jsx)(`div`,{"data-route":`task-thread`,className:`flex min-h-full flex-col`,children:(0,$.jsx)(Mt,{icon:e?(0,$.jsx)(_t,{}):(0,$.jsx)(Cn,{}),tone:e?`neutral`:`danger`,title:e?`Task not found`:`Could not load this task`,subtitle:e?`No run has this id. It may have been deleted, or the link is from another machine.`:t.error.message,actions:(0,$.jsx)(s,{asChild:!0,variant:`outline`,children:(0,$.jsx)(J,{to:`/`,children:`Back to tasks`})})})})}return r.isPending?(0,$.jsx)(pn,{}):(0,$.jsx)(qs,{run:t.data,thread:a,currentThread:o,history:r,onMarkedUnread:l})}function qs({run:e,thread:n,currentThread:r=n,history:i,onMarkedUnread:a}){vt();let o=M(),{pendingAsk:s,transcriptAsk:c,pendingAskId:l,historyLoading:u}=Js(i,r),d=h(e),f=ct(e.status,e.error),p=ue(e),m=!p&&e.status!==`queued`,g=e.status===`queued`,v=mi(e),y=wo(e),b=_o(e.id),x=c||_(e),{hasContinuation:S,continuable:C}=Ys(p,g,v),[w,T]=(0,Q.useState)(void 0),[E,D]=(0,Q.useState)(e.id);E!==e.id&&(D(e.id),T(void 0));let O=(0,Q.useMemo)(()=>w===void 0?void 0:Oi(r.turns,w,m,n.turns),[r.turns,w,m,n.turns]),k=(0,Q.useMemo)(()=>w===void 0?[]:ji(n.turns,r.turns,w),[n.turns,r.turns,w]),A=z(e.id),j=mn(e),{providerBlocked:N,providerReason:P}=Xs(p,Ft(e),S,v),{mutateAsync:F}=ee(e.id),{mutateAsync:I}=te(e.id),{mutateAsync:L}=re(e.id),R=(0,Q.useMemo)(()=>g?{onEditTask:async e=>{await F({task:e})},onEditMessage:(e,t)=>I({msgId:e,message:{text:t}}).then(()=>void 0),onRemoveMessage:e=>L(e).then(()=>void 0)}:void 0,[g,F,I,L]),B=u?void 0:l??null,V=(0,Q.useMemo)(()=>za(e,n,r,B),[e,n,r,B]),H=(0,Q.useMemo)(()=>Ua(V,e.id),[V,e.id]),ae=e.delegation?.role===`root`||e.delegation?.role===`worker`,oe=ne(e.id,{enabled:ae}),ce=(0,Q.useMemo)(()=>Xi(e,o.data,oe.data?.titles),[e,o.data,oe.data]),le=(0,Q.useMemo)(()=>Yi(e,o.data),[e,o.data]),de=(0,Q.useCallback)(t=>(0,$.jsx)(Bi,{permission:t,runId:e.id,sessionOpen:p}),[e.id,p]),pe=(0,Q.useMemo)(()=>{if(R===void 0)return;let t={task:{onEdit:R.onEditTask,editLabel:`Edit the prompt`}};for(let n of e.queuedMessages??[])t[`queued:${n.id}`]={onEdit:e=>R.onEditMessage(n.id,e),onRemove:()=>R.onRemoveMessage(n.id)};return t},[R,e.queuedMessages]),me=fe(e,ie()),{search:he}=t(),ge=lr(he,H.length),U=ja(`${e.id}:main`,{onLoadOlder:i?.hasOlder?i.loadOlder:void 0,onJumpToLatest:i?.jumpToLatest,rowKeys:H.map(({key:e})=>e)}),{pinnedAsk:_e,pendingQuestions:W}=Zs(V),G=Ws({pendingAskId:l,askSeq:i?s?.seq:void 0,rows:H,history:i,jumpToRow:U.jumpToRow}),ve=(0,Q.useRef)(l);u||(ve.current=l);let ye=(0,Q.useRef)({rows:H,jumpToRow:U.jumpToRow,reveal:G.reveal});ye.current={rows:H,jumpToRow:U.jumpToRow,reveal:G.reveal};let be=(0,Q.useCallback)(t=>t.placement===`origin`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t.resolved&&t.context?(0,$.jsx)(Ps,{text:t.context}):null,t.resolved?null:(0,$.jsx)(Da,{onGoToQuestion:()=>{let{rows:e,jumpToRow:n}=ye.current,r=Ba(e,t.id,`pinned`);r&&n(r.key,r.index,e=>wa(e))}})]}):(0,$.jsx)(Ms,{ask:t,run:e,onShowOrigin:()=>ye.current.reveal()}),[e]);return se(U.restickIfStuck),(0,$.jsxs)(`div`,{ref:Gs(),"data-route":`task-thread`,"data-run-id":e.id,className:`flex min-h-full flex-col`,children:[(0,$.jsx)(et,{run:e,onMarkedUnread:()=>a?.(e.id)}),(0,$.jsx)(Qs,{run:e,thread:n,history:i,footer:f,issueUrl:me,sections:V,renderAsk:be,renderPermission:de,messageActions:pe,scroll:U,mode:ge,taskTitles:ce,recipientBackends:le}),(0,$.jsx)(Co,{status:e.status}),(0,$.jsx)(Qa,{runId:e.id,renderAsk:be,renderPermission:de,agent:O,entries:k,taskTitles:ce,recipientBackends:le,onClose:()=>T(void 0)}),(0,$.jsx)($s,{run:e,thread:n,currentThread:r,currentComplete:i?.currentComplete??!0,scroll:U,pendingQuestions:W,onJump:()=>{let e=W>0?_e?.id:void 0;U.jumpToLatest(e===void 0?void 0:Ta(e,()=>ve.current===e))},onOpenWorker:T,sessionOpen:p,attention:d,queued:g,continuable:C,continueAction:v,stopAction:y,finishAction:b,needsAnswer:x,sendMessage:A,reply:j,providerBlocked:N,providerReason:P}),(0,$.jsx)(`div`,{"data-slot":`thread-tail-anchor`,"aria-hidden":`true`,className:`h-px shrink-0 md:hidden`})]})}function Js(e,t){let n=e?ot(e.currentEvents):void 0;return{pendingAsk:n,transcriptAsk:e?n!==void 0:t.turns.some(e=>e.items.some(e=>e.kind===`ask`&&!e.resolved)),pendingAskId:e?n?.requestId:t.turns.flatMap(e=>e.items).reverse().find(e=>e.kind===`ask`&&!e.resolved)?.id,historyLoading:e!==void 0&&(e.isPending||e.contextPending)}}function Ys(e,t,n){let r=!e&&!t&&n.available;return{hasContinuation:r,continuable:r&&n.canContinue}}function Xs(e,t,n,r){let i=e&&!t.usable,a=n&&!r.canContinue;return{providerBlocked:i||a,providerReason:i?t.reason:r.reason}}function Zs(e){let t=e.at(-1),n=t?.id===`pending-ask`?t.entries[0]:void 0;return{pinnedAsk:n,pendingQuestions:n?.kind===`ask`?n.questions.length:0}}function Qs({run:e,thread:t,history:n,footer:r,issueUrl:i,sections:o,renderAsk:s,renderPermission:l,messageActions:u,scroll:d,mode:f,taskTitles:p,recipientBackends:m}){return(0,$.jsxs)(`div`,{"data-slot":`session-conversation`,className:`mx-auto flex w-full max-w-[var(--measure)] flex-1 flex-col gap-2.5 px-[18px] py-3 md:gap-3.5 md:px-16 md:py-5`,children:[n?(0,$.jsx)(rc,{hasOlder:n.hasOlder,loading:n.isFetchingOlder,error:n.olderError,fallback:n.fallback,retainedPages:n.retainedPages,onLoad:d.loadOlder}):null,(0,$.jsx)(Wa,{runId:e.id,viewId:`main`,sections:o,mode:`document`,renderAsk:s,renderPermission:l,messageActions:u,scrollControls:d,renderMode:f,taskTitles:p,recipientBackends:m}),t.turns.length===0?e.status===`queued`?(0,$.jsx)(ic,{run:e}):(0,$.jsx)(`p`,{"data-slot":`thread-empty`,className:`py-6 text-center text-xs text-soft-foreground`,children:`No session events yet.`}):null,e.status===`running`?(0,$.jsx)(Ur,{}):null,r&&r.state===`closed`?(0,$.jsxs)(`div`,{"data-slot":`thread-footer`,"data-state":r.state,className:c(`mt-auto flex items-center gap-2 border-t border-border pt-3 text-xs`,r.tone===`danger`?`text-danger`:`text-soft-foreground`),children:[r.label,a(pe(e))?(0,$.jsx)(`a`,{"data-slot":`pr-link`,href:pe(e),target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`PR ↗`}):null,a(i)?(0,$.jsx)(`a`,{"data-slot":`issue-link`,href:i,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`Issue ↗`}):null]}):null,e.status===`review`?(0,$.jsx)(vo,{run:e}):null]})}function $s({run:e,thread:t,currentThread:n,currentComplete:r,scroll:i,pendingQuestions:a,onJump:o,onOpenWorker:s,sessionOpen:c,attention:l,queued:u,continuable:d,continueAction:f,stopAction:p,finishAction:m,needsAnswer:h,sendMessage:g,reply:_,providerBlocked:v,providerReason:y}){return(0,$.jsxs)(`div`,{"data-slot":`thread-dock`,className:`relative z-10 bg-background pt-1 pb-2 md:pt-1.5 md:pb-4`,children:[i.pillVisible?(0,$.jsx)(`div`,{"data-slot":`thread-jump`,className:`pointer-events-none z-30 flex justify-center`,children:(0,$.jsx)(Fa,{pendingQuestions:a,onJump:o})}):null,(0,$.jsxs)(`div`,{"data-slot":`thread-footer-content`,className:`mx-auto flex w-full max-w-[var(--measure)] flex-col gap-1.5 px-[14px] md:gap-2.5 md:px-16`,children:[(0,$.jsx)(cs,{run:e,thread:t,currentThread:n,currentComplete:r,onOpenWorker:s,readerScroll:i.subscribeReaderScroll},e.id),(0,$.jsx)(En,{run:e}),e.status===`waiting`&&c?(0,$.jsxs)(`div`,{"data-slot":`paused-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(Ut,{tone:l.tone,shape:l.shape,pulse:l.pulse}),l.bucket===`permission`?`Choose an approval option above to continue`:l.bucket===`waiting`?`The agent is paused, waiting for your reply`:`${l.label.charAt(0).toUpperCase()}${l.label.slice(1)} — you can send a message to resume`]}):null,u?(0,$.jsxs)(`div`,{"data-slot":`queued-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(Ut,{tone:`neutral`,shape:`ring`}),`Messages you add now are folded into the prompt before the run starts.`]}):null,d&&f.startsNewConversation?(0,$.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:`Starts a new agent conversation.`}):null,(0,$.jsx)(ec,{run:e,thread:t,stopAction:p,finishAction:m,attention:l,needsAnswer:h,continuable:d,continueAction:f,queued:u,sendMessage:g,reply:_,providerBlocked:v,providerReason:y,sessionOpen:c})]})]})}function ec({run:e,thread:t,stopAction:n,finishAction:r,attention:i,needsAnswer:a,continuable:o,continueAction:s,queued:c,sendMessage:l,reply:u,providerBlocked:d,providerReason:f,sessionOpen:p}){let m=$e(e);return(0,$.jsx)(Ht,{onStop:sn(e,m).cancel?n.stop:void 0,onFinish:zt(e)?()=>r.mutateAsync().catch(()=>void 0):void 0,finishing:r.isPending,secondaryAction:en(e,m)?(0,$.jsx)(nt,{run:e,compactOnMobile:!0}):void 0,stopOnEmpty:tc(e,i,a),stopping:n.stopping,retainDraftUntilSuccess:!0,compactFeedback:!0,pendingLabel:o?`Continuing…`:`Sending…`,failureHint:`Your draft is kept. Check the task status and connection, then retry.`,sessionControls:o?s.pills:void 0,onSubmit:o?(e,t)=>s.continueWith(e,t):c?(e,t)=>l.mutateAsync({text:e,images:t}):async(e,t)=>{let n=await u.send(e,t);if(n!==void 0)throw Error(n)},disabled:d||!p&&!c&&!o,disabledReason:d?f:`Session closed — no session to resume.`,footerEnd:d&&!s.providerPending?(0,$.jsx)(J,{to:`/settings/agents#providers`,className:`text-xs font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):void 0,allowEmptySubmit:o&&!a,emptySubmitLabel:o&&!a?`Continue`:void 0,placeholder:nc(e,c,o),autocompleteSkills:!0,quickReplies:!0,getMentionCandidates:()=>dt(t)})}function tc(e,t,n){return e.status===`queued`||e.status===`running`||e.status===`waiting`&&t.bucket===`none`&&!n}function nc(e,t,n){return t?`Add to the prompt — sent when the run starts…`:n?`Continue — add a prompt, or send to just reopen the session…`:e.status===`waiting`?`Reply — / for skills, @ for files…`:`Message the agent — / for skills, @ for files…`}function rc({hasOlder:e,loading:t,error:n,fallback:r,retainedPages:i,onLoad:a}){return r?(0,$.jsx)(`p`,{"data-slot":`history-fallback`,className:`text-center text-xs text-soft-foreground`,role:`status`,children:`Progressive history is unavailable; showing the complete session.`}):!e&&!n?(0,$.jsxs)(`div`,{"data-slot":`history-start`,className:`flex items-center gap-3 text-[11px] text-soft-foreground`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),`Start of session`,(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]}):(0,$.jsxs)(`div`,{"data-slot":`history-boundary`,"data-retained-pages":i,"aria-busy":t,className:`flex min-h-8 items-center justify-center text-xs text-muted-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:a,disabled:t,className:`rounded-md px-3 py-1.5 font-medium hover:bg-muted disabled:cursor-wait`,children:t?`Loading 100 earlier items…`:n?`Couldn’t load earlier items · Retry`:`Load 100 earlier items`}),(0,$.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:t?`Loading earlier session history`:n||``})]})}function ic({run:e}){let t=Rt(M().data??[],e.id);return(0,$.jsxs)(`div`,{"data-slot":`queued-state`,className:`flex flex-col items-center gap-1.5 py-10 text-center`,children:[(0,$.jsx)(Ut,{tone:`neutral`,shape:`ring`}),(0,$.jsxs)(`p`,{className:`text-[13px] font-medium`,children:[`Waiting for a free agent slot`,t===void 0?``:` — #${t} in queue`]}),(0,$.jsxs)(`p`,{className:`text-xs text-soft-foreground`,children:[e.workflow,` · starts automatically when a slot frees up`]})]})}export{Ks as TaskThreadRoute};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,s as n,u as r}from"./button-DGwhwRuD.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{Ln as o,Mn as s,Rn as c,Un as l,rr as u}from"./project-scope-context-bgdvGX9z.js";import{M as d}from"./live-protocol-aMLJJ0MQ.js";import"./queries-BJM44umy.js";import{t as f}from"./createLucideIcon-BHp8sXmF.js";import{a as ee,d as p,h as te,i as ne,l as re,m as ie,n as ae,o as oe,p as m,r as se,t as ce,u as h}from"./es2015-DTn4s5Lh.js";import{_ as g,b as le,v as ue,x as _,y as de}from"./dropdown-menu-DPrTX-zi.js";import"./attention-CVI366xV.js";function fe(e){if(e.workflow===`(planned)`||e.workflow===`(inbox)`){let t=(e.steps??[]).find(e=>e.kind===`agent`);if(t?.name)return t.name}return e.workflow}var pe=f(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),v=e(i(),1),y=a(),b=`Popover`,[x,me]=ie(b,[_]),S=_(),[he,C]=x(b),w=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=S(t),c=v.useRef(null),[l,u]=v.useState(!1),[d,f]=p({prop:r,defaultProp:i??!1,onChange:a,caller:b});return(0,y.jsx)(le,{...s,children:(0,y.jsx)(he,{scope:t,contentId:re(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:v.useCallback(()=>u(!0),[]),onCustomAnchorRemove:v.useCallback(()=>u(!1),[]),modal:o,children:n})})};w.displayName=b;var ge=`PopoverAnchor`,_e=v.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=C(ge,n),a=S(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return v.useEffect(()=>(o(),()=>s()),[o,s]),(0,y.jsx)(g,{...a,...r,ref:t})});_e.displayName=ge;var ve=`PopoverTrigger`,ye=v.forwardRef((e,t)=>{let{__scopePopover:r,...i}=e,a=C(ve,r),o=S(r),s=n(t,a.triggerRef),c=(0,y.jsx)(te.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":A(a.open),...i,ref:s,onClick:m(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?c:(0,y.jsx)(g,{asChild:!0,...o,children:c})});ye.displayName=ve;var T=`PopoverPortal`,[be,xe]=x(T,{forceMount:void 0}),Se=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=C(T,t);return(0,y.jsx)(be,{scope:t,forceMount:n,children:(0,y.jsx)(h,{present:n||a.open,children:(0,y.jsx)(ne,{asChild:!0,container:i,children:r})})})};Se.displayName=T;var E=`PopoverContent`,D=v.forwardRef((e,t)=>{let n=xe(E,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=C(E,e.__scopePopover);return(0,y.jsx)(h,{present:r||a.open,children:a.modal?(0,y.jsx)(we,{...i,ref:t}):(0,y.jsx)(Te,{...i,ref:t})})});D.displayName=E;var Ce=t(`PopoverContent.RemoveScroll`),we=v.forwardRef((e,t)=>{let r=C(E,e.__scopePopover),i=v.useRef(null),a=n(t,i),o=v.useRef(!1);return v.useEffect(()=>{let e=i.current;if(e)return ce(e)},[]),(0,y.jsx)(ae,{as:Ce,allowPinchZoom:!0,children:(0,y.jsx)(O,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:m(e.onCloseAutoFocus,e=>{e.preventDefault(),o.current||r.triggerRef.current?.focus()}),onPointerDownOutside:m(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;o.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:m(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),Te=v.forwardRef((e,t)=>{let n=C(E,e.__scopePopover),r=v.useRef(!1),i=v.useRef(!1);return(0,y.jsx)(O,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),O=v.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=C(E,n),p=S(n);return se(),(0,y.jsx)(ee,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,y.jsx)(oe,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,y.jsx)(de,{"data-state":A(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),k=`PopoverClose`,Ee=v.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=C(k,n);return(0,y.jsx)(te.button,{type:`button`,...r,ref:t,onClick:m(e.onClick,()=>i.onOpenChange(!1))})});Ee.displayName=k;var De=`PopoverArrow`,Oe=v.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=S(n);return(0,y.jsx)(ue,{...i,...r,ref:t})});Oe.displayName=De;function A(e){return e?`open`:`closed`}var ke=w,Ae=_e,je=ye,Me=Se,Ne=D,Pe=new Set([`queued`,`running`,`waiting`]);function Fe(e){return Pe.has(e)}function j(e){return u(e)?!1:e.status===`queued`||e.status===`running`||e.status===`waiting`}function Ie(e){return j(e)&&e.status!==`queued`}function M(e,t,n){return e.archived||!(e.status===`done`||e.status===`failed`||e.status===`cancelled`)||e.delegation?.role===`worker`||n!==void 0&&l(e)!==n?!1:t===`unpinned`?!e.pinned:t!==`pinned`||e.pinned===!0}var Le=[`done`,`failed`];function N(e){return e.archived||u(e)||!Le.includes(e.status)?!1:e.finishedAt!==void 0}function Re(e){let t=e.finishedAt;return t===void 0||!N(e)?!1:e.seenAt===void 0||e.seenAt<t}var P=[`Needs you`,`Finished`,`Working`,`Archived`],ze={waiting:0,review:1,running:2,queued:4,done:5,failed:6,cancelled:7},Be=3,F=e=>u(e)?Be:ze[e.status]??9;function Ve(e){let t=e=>s[o(e).bucket];return[...e].sort((e,n)=>t(e)-t(n)||F(e)-F(n))[0]}function He(e,t){return t===`archived`?`Archived`:c(e)?`Needs you`:e.status===`waiting`||e.status===`running`||e.status===`queued`?`Working`:`Finished`}function I(e){let t=e.titleSummary;return t===void 0||!(e.titleOrigin===`user`||e.titleOrigin===`marker`)&&/[.!?][A-Z]/.test(t)?e.title:t}function L(e){let t=/^(\d{1,9}): (.+)$/.exec(e),n=t?.[1],r=t?.[2];return n===void 0||r===void 0?{ref:null,rest:e}:{ref:Number(n),rest:r}}function Ue(e,t){return t!==void 0&&L(e).ref===t}function R(e){let t=e.filter(e=>!e.archived&&e.status===`queued`).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));return new Map(t.map((e,t)=>[e.id,t+1]))}function We(e,t){return e.filter(e=>t===`archived`?e.archived:!e.archived).sort((e,n)=>{if(t!==`archived`){let t=Number(!!n.pinned)-Number(!!e.pinned);if(t!==0)return t}let r=F(e)-F(n);if(r!==0)return r;if(u(e)&&u(n)){let t=e.autoResumeAt.localeCompare(n.autoResumeAt);if(t!==0)return t}return e.status===`queued`&&n.status===`queued`?e.createdAt.localeCompare(n.createdAt):n.createdAt.localeCompare(e.createdAt)})}function z(e){return e.delegation?.role===`worker`}function Ge(e,t){if(e==null)return null;let n=t.find(t=>t.id===e);return!n||!z(n)?e:n.delegation?.parentRunId??e}function Ke(e,t,n=R(e)){let r=We(e,t).filter(e=>!z(e)),i=new Map,a=(e,t)=>{let n=i.get(e);n?n.push(t):i.set(e,[t])};for(let e of r)a(He(e,t),{kind:`run`,run:e,queuePosition:n.get(e.id)??null});return P.filter(e=>i.has(e)).map(e=>({label:e,rows:i.get(e)}))}function qe(e,t={}){let n=typeof t==`number`?{overall:t}:d(t),r={"Needs you":`needsYou`,Finished:`finished`,Working:`working`},i=[],a=n.overall===void 0?10:n.overall??1/0;for(let t of e){let e=t.label===`Archived`?1/0:n[r[t.label]]??1/0,o=t.rows.filter(n=>{let r=n.run.pinned;return t.label!==`Archived`&&r?!0:a<=0||e<=0?!1:(--a,--e,!0)});o.length&&i.push({label:t.label,rows:o})}return i}function Je(e,t){if(t.length===0)return[...e];let n=new Set(e.map(e=>e.id)),r=new Set,i=t.filter(e=>n.has(e.id)||r.has(e.id)?!1:(r.add(e.id),!0));return[...e,...i]}function Ye(e){let t=0,n=0,r=0;for(let i of e)if(!z(i)){if(i.archived){n+=1;continue}t+=1,c(i)&&(r+=1)}return{active:t,archived:n,waiting:r}}function Xe(e,t,n){return e.filter(e=>!e.archived&&(!n||l(e)===(t===`automations`)))}var B={"Needs you":`needs-you`,Finished:`finished`,Working:`working`},V=Object.keys(B),Ze=`section`;function Qe(e,t,n){let r=`${Ze}=${B[e]}`;return n?`/?origin=${t===`automations`?`automations`:`direct`}&${r}`:`/?${r}`}function $e(e){return V.find(t=>B[t]===e)??null}function et(e,t){let n={active:0,automations:0,activeWaiting:0,automationsWaiting:0};for(let r of e){if(z(r)||r.archived)continue;let e=+!!c(r);t&&l(r)?(n.automations+=1,n.automationsWaiting+=e):(n.active+=1,n.activeWaiting+=e)}return n}function H(e){let t=e.visualViewport;return t?Math.max(0,Math.round(e.innerHeight-t.height-t.offsetTop)):0}function tt(e,t,n,r=250){let i=e.visualViewport;if(!i)return t(0),()=>{};let a,o=()=>{let i=H(e);t(i),n&&(clearTimeout(a),a=setTimeout(()=>n(i),r))};return t(H(e)),i.addEventListener(`resize`,o),i.addEventListener(`scroll`,o),()=>{clearTimeout(a),i.removeEventListener(`resize`,o),i.removeEventListener(`scroll`,o),t(0)}}function nt(e){let t=e.visualViewport;return t?{top:Math.max(0,Math.round(t.offsetTop)),bottom:H(e)}:{top:0,bottom:0}}function rt(e,t=0){let n=typeof t==`number`?{top:t,right:t,bottom:t,left:t}:t;return{top:(n.top??0)+e.top,right:n.right??0,bottom:(n.bottom??0)+e.bottom,left:n.left??0}}function it(e,t){let n=e.visualViewport;if(!n)return t({top:0,bottom:0}),()=>{};let r=()=>t(nt(e));return r(),n.addEventListener(`resize`,r),n.addEventListener(`scroll`,r),()=>{n.removeEventListener(`resize`,r),n.removeEventListener(`scroll`,r)}}function at(){let[e,t]=(0,v.useState)({top:0,bottom:0});return(0,v.useEffect)(()=>it(window,e=>t(t=>t.top===e.top&&t.bottom===e.bottom?t:e)),[]),e}function ot(e){let t=(0,v.useRef)(e);t.current=e,(0,v.useEffect)(()=>{let e=document.documentElement;return tt(window,t=>e.style.setProperty(`--kb`,`${t}px`),e=>t.current?.(e))},[])}var st=new Set([``,`text`,`search`,`email`,`url`,`tel`,`password`,`number`]);function ct(e){if(!e||typeof e!=`object`)return!1;let t=e,n=t.tagName?.toUpperCase();return n===`TEXTAREA`?!0:n===`INPUT`?st.has((t.type??``).toLowerCase()):t.isContentEditable===!0}var U=new WeakMap;function lt(e){let t=U.get(e),n=t&&t.width===e.innerWidth?Math.max(t.height,e.innerHeight):e.innerHeight;return U.set(e,{width:e.innerWidth,height:n}),n-e.innerHeight}function ut(e){let t=lt(e),n=e.visualViewport?.scale??1;return Math.abs(n-1)<.05&&H(e)>80||t>80&&ct(e.document?.activeElement)}function dt(){let[e,t]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let e=window,n=()=>t(ut(e));n();let r=e.visualViewport;return r?.addEventListener(`resize`,n),r?.addEventListener(`scroll`,n),window.addEventListener(`resize`,n),document.addEventListener(`focusin`,n),document.addEventListener(`focusout`,n),()=>{r?.removeEventListener(`resize`,n),r?.removeEventListener(`scroll`,n),window.removeEventListener(`resize`,n),document.removeEventListener(`focusin`,n),document.removeEventListener(`focusout`,n)}},[]),e}function ft(e){let t=/\/(\d+)\/?$/.exec(e.trim()),n=t?Number(t[1]):NaN;return Number.isInteger(n)&&n>0?n:null}function pt(e){let t=new Set;for(let n of[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl]){let e=n?ft(n):null;e!==null&&t.add(e)}for(let n of[e.prNumber,e.issueNumber,e.markerRefs?.pr,e.markerRefs?.issue])typeof n==`number`&&Number.isInteger(n)&&n>0&&t.add(n);for(let n of e.pullRequests??[])t.add(n.number);return[...t]}var mt=[{id:`title`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.title]},{id:`titleSummary`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.titleSummary]},{id:`displayTitle`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.displayTitle]},{id:`branch`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.branch]},{id:`workflow`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflow]},{id:`workflowLabel`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflowLabel]},{id:`automation`,kind:`text`,scopes:[`stored`,`shown`],source:`reader`,texts:(e,t)=>[t.automation],universe:e=>[...e.automationNames?.values()??[]]},{id:`projectName`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.projectName]},{id:`tags`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>t.tags??[]},{id:`id`,kind:`identifier`,scopes:[`stored`],source:`summary`,texts:e=>[e.id]},{id:`urls`,kind:`link`,scopes:[`stored`],source:`summary`,texts:e=>[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl,...(e.pullRequests??[]).map(e=>e.url)]},{id:`heldReferences`,kind:`reference`,scopes:[`stored`],source:`summary`,numbers:pt},{id:`shownReferences`,kind:`reference`,scopes:[`shown`],source:`reader`,numbers:(e,t)=>t.references?.()??[]}];function ht(e){return e.trim().toLowerCase().split(/\s+/).filter(e=>e!==``)}function gt(e,t){return t&&e.automationId!==void 0?t.get(e.automationId)??e.automationId:void 0}function _t(e,t){let n=t.scope??`stored`,r=t.scope===`shown`?t.extras:{automation:gt(e,t.automationNames)},i=[],a=[],o=[],s={text:i,identifier:a,link:o},c=[];for(let t of mt)if(t.scopes.includes(n)){if(t.kind===`reference`){c.push(()=>t.numbers(e,r));continue}for(let n of t.texts(e,r))typeof n==`string`&&s[t.kind].push(n.toLowerCase())}let l;return{prose:i,ids:a,links:o,references:()=>l??=new Set(c.flatMap(e=>e().map(String)))}}function W(e,t,n={}){let r=ht(t);if(r.length===0)return!1;let{prose:i,ids:a,links:o,references:s}=_t(e,n);return r.every(e=>{if(i.some(t=>t.includes(e)))return!0;let t=e.replace(/^#/,``);return/^\d+$/.test(t)?s().has(String(Number(t)))||a.some(e=>e.startsWith(t)):a.some(t=>t.includes(e))||o.some(t=>t.includes(e))})}var vt=new Set([`running`,`waiting`]);function G(e){return e?e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} kB`:``}function yt(e){return e===void 0?``:`$${e>=10?e.toFixed(0):e.toFixed(2)}`}function bt(e,t=new Date){if(!u(e))return;let n=new Date(e.autoResumeAt);if(!Number.isFinite(n.getTime()))return;let r=n.toDateString()===t.toDateString(),i=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(n);return{label:r?i:`${new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(n)} ${i}`,title:`Resumes automatically at ${new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(n)}`}}function xt(e){return e.steps?fe({workflow:e.workflow,steps:e.steps}):e.workflowLabel??e.workflow}function St(e,t,n=()=>``){let r=e.filter(e=>!z(e));return t.trim()?r.filter(e=>W(e,t,{scope:`shown`,extras:{displayTitle:I(e),automation:n(e),references:()=>K(e)}})):[...r]}function K(e){return Y(e).map(e=>e.number)}function q(e,t){return e.filter(e=>M(e,t)).length}function Ct(e){return q(e)}function wt(e){return J(e)[0]??e.pullRequests?.find(e=>e.url)?.url}function J(e){let t=[];return e.pullRequestUrl&&t.push(e.pullRequestUrl),!(e.markerRefs?.issue!==void 0&&e.markerRefs?.pr===void 0)&&e.referencedPullRequestUrl&&t.push(e.referencedPullRequestUrl),t}function Tt(e,t){if(e.referencedIssueUrl)return e.referencedIssueUrl;let n=e.issueNumber??e.markerRefs?.issue;if(!(!n||!t))return`${t}/issues/${n}`}function Et(e){let t=`${e.kind}#${e.number}`;if(!e.url)return`${t}@project:${e.projectId??`default`}`;try{let n=new URL(e.url),r=n.pathname.split(`/`).filter(Boolean).slice(0,2).join(`/`);return`${t}@${n.host.toLowerCase()}/${r.toLowerCase()}`}catch{return`${t}@${e.url}`}}function Y(e,t,n=e.projectId){let r=J(e),i=e.markerRefs?.pr,a=[...i===void 0||[...r,...(e.pullRequests??[]).flatMap(e=>e.url?[e.url]:[])].some(e=>Z(e)===String(i))?[]:[{kind:`PR`,number:i}],...r.map(e=>({kind:`PR`,url:e})),{kind:`PR`,number:e.prNumber},...(e.pullRequests??[]).map(e=>({kind:`PR`,number:e.number,...e.url?{url:e.url}:{},authoritative:!0})),{kind:`Issue`,url:Tt(e,t)},{kind:`Issue`,number:e.issueNumber}],o=new Set,s=[];for(let e of a){let r=e.url?Number(Z(e.url)):e.number;if(!r||!Number.isInteger(r)||!e.url&&!e.authoritative&&s.some(t=>t.url&&t.kind===e.kind&&t.number===r))continue;let i=e.url??Dt(e.kind,r,t),a={kind:e.kind,number:r,...i?{url:i}:n===void 0?{}:{projectId:n}},c=Et(a);o.has(c)||(o.add(c),s.push(a))}return s}function Dt(e,t,n){if(n)return`${n}/${e===`PR`?`pull`:`issues`}/${t}`}function Ot(e){return Y(e)[0]}function X(e,t){if(!e.url)return!0;if(!t)return!1;let n=kt(t);return n!==void 0&&kt(e.url)===n}function kt(e){try{let t=new URL(e),[n,r]=t.pathname.split(`/`).filter(Boolean);return n&&r?`${t.host}/${n}/${r}`.toLowerCase():void 0}catch{return}}function At(e,t){let n=[];for(let r of Y(e,t)){if(!X(r,t))continue;let e=r.kind===`PR`?`pr`:`issue`;n.some(t=>t.kind===e&&t.number===r.number)||n.push({kind:e,number:r.number})}return n}function jt(e,t,n,r){if(X(n,r))return`/p/${e}/tasks/${t}/${n.kind===`PR`?`pr`:`issue`}/${n.number}`}function Z(e){return/\/(\d+)\/?(?:[?#].*)?$/.exec(e)?.[1]??null}function Mt(e,t){let n=vt.has(e.status)?t:void 0;if(n)return{cpu:{text:`${n.cpuPct.toFixed(0)}%`,kind:`live`},mem:{text:G(n.rssBytes),kind:`live`}};let r=G(e.peakRssBytes);return{cpu:{text:``,kind:`none`},mem:r?{text:`peak ${r}`,kind:`peak`,title:`peak — run finished${e.peakProcCount?` · ${e.peakProcCount} procs`:``}`}:{text:``,kind:`none`}}}var Q=v.createContext(null);function Nt({...e}){let t=v.useRef(!1);return(0,y.jsx)(Q,{value:t,children:(0,y.jsx)(ke,{"data-slot":`popover`,...e})})}function Pt({onPointerDownCapture:e,onKeyDownCapture:t,...n}){let r=v.useContext(Q);return(0,y.jsx)(je,{"data-slot":`popover-trigger`,...n,onPointerDownCapture:t=>{r&&(r.current=t.pointerType===`touch`),e?.(t)},onKeyDownCapture:e=>{r&&(r.current=!1),t?.(e)}})}function Ft({className:e,align:t=`center`,sideOffset:n=4,collisionPadding:i,onOpenAutoFocus:a,...o}){let s=at(),c=v.useContext(Q);return(0,y.jsx)(Me,{children:(0,y.jsx)(Ne,{"data-slot":`popover-content`,align:t,sideOffset:n,onOpenAutoFocus:e=>{let t=c?.current;if(c&&(c.current=!1),a?.(e),e.defaultPrevented||!t)return;let n=e.target;n instanceof HTMLElement&&n.querySelector(`[cmdk-input]`)&&(e.preventDefault(),n.focus({preventScroll:!0}))},collisionPadding:rt(s,i),className:r(`z-50 w-72 max-w-(--radix-popover-content-available-width) [overflow-wrap:anywhere] origin-(--radix-popover-content-transform-origin) rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-hidden motion-safe:data-[side=bottom]:slide-in-from-top-2 motion-safe:data-[side=left]:slide-in-from-right-2 motion-safe:data-[side=right]:slide-in-from-left-2 motion-safe:data-[side=top]:slide-in-from-bottom-2 motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:zoom-out-95 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0 motion-safe:data-[state=open]:zoom-in-95`,e),...o})})}function It({...e}){return(0,y.jsx)(Ae,{"data-slot":`popover-anchor`,...e})}var $=`(min-width: 48rem)`;function Lt(){let[e,t]=(0,v.useState)(()=>typeof window.matchMedia!=`function`||window.matchMedia(`(min-width: 48rem)`).matches);return(0,v.useEffect)(()=>{if(typeof window.matchMedia!=`function`)return;let e=window.matchMedia($),n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}export{V as A,Qe as B,Mt as C,dt as D,ot as E,Ve as F,Je as G,et as H,$e as I,Fe as J,N as K,R as L,Ke as M,z as N,P as O,Ye as P,pe as Q,Ue as R,Y as S,W as T,Xe as U,Ge as V,L as W,M as X,Ie as Y,Re as Z,Tt as _,Ft as a,wt as b,Ct as c,X as d,Z as f,q as g,K as h,It as i,qe as j,Ze as k,yt as l,bt as m,Lt as n,Pt as o,Et as p,j as q,Nt as r,St as s,$ as t,G as u,jt as v,xt as w,Ot as x,At as y,I as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,t as n,u as r}from"./button-DGwhwRuD.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{C as o,Ur as s,en as c,nt as l,r as u,rt as d,yr as f,zt as p}from"./project-scope-context-bgdvGX9z.js";import{$ as m,At as h,Lt as g,M as _,Nt as v,O as y,h as b,n as x,nn as S,nt as C,wt as w}from"./queries-BJM44umy.js";import{t as T}from"./useQuery-C0ee1rw5.js";import{Q as E,a as D,o as O,r as k}from"./use-desktop-Ct4lvA3b.js";import{n as A}from"./toaster-CoMJoQvk.js";import{A as j,Z as ee,_ as M,b as N,ct as P,d as F,ft as te,h as I,l as L,mt as ne,ot as re,r as ie,rt as ae,u as oe,ut as se}from"./design-icons-DmYTv2r1.js";import{t as ce}from"./eye-B8okNWXU.js";import{a as le,i as R}from"./format-BNCkW110.js";import{t as ue}from"./message-square-B-MD-8rD.js";import{t as de}from"./play-CmVAj_fu.js";import{a as fe,i as pe,o as me,r as he,s as ge,t as _e}from"./dialog-B7p5oc5r.js";import{d as z,t as ve,y as B}from"./prompt-template-menu-BJfUg1uF.js";import{t as V}from"./project-router-WQWd3UUn.js";import{B as ye,E as be,G as xe,I as Se,L as H,M as Ce,O as we,P as Te,R as Ee,S as De,T as Oe,a as ke,b as Ae,f as je,h as Me,i as Ne,l as Pe,m as Fe,n as Ie,p as Le,r as Re,s as ze,t as Be,u as Ve,w as He,x as Ue,z as We}from"./agent-accounts-otlDWnij.js";import{d as Ge,f as Ke,i as qe,s as Je,t as Ye,u as Xe}from"./skills-DFBiAuJG.js";import{$ as Ze,F as Qe,L as $e,X as et,Y as tt,pn as nt}from"./index-tN02NX7A.js";import{t as rt}from"./diff-DQfcliZC.js";import{t as it}from"./tab-link-DiNYVlpl.js";var U=e(i(),1),W=a(),at={squash:`Squash and merge`,merge:`Create a merge commit`,rebase:`Rebase and merge`};function G({state:e}){let t=`size-4 shrink-0`;return e===`passing`?(0,W.jsx)(L,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-passing`,className:r(t,`text-success`)}):e===`failing`?(0,W.jsx)(M,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-failing`,className:r(t,`text-danger`)}):e===`pending`?(0,W.jsx)(le,{"aria-hidden":`true`,"data-slot":`gh-merge-status-pending`,className:r(t,`animate-spin text-warning`)}):(0,W.jsx)(I,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-unknown`,className:r(t,`text-soft-foreground`)})}function ot(e){return e?.available?e.mergeState:null}function st(e,t){return e&&t?.methods.includes(e)?e:t?.defaultMethod??t?.methods[0]??null}function ct(e){return e.state===`merged`?`Merged`:e.state===`closed`?`Closed`:e.isDraft?`Draft`:e.mergeable===`conflicting`?`Conflicts must be resolved`:e.canMerge?`Ready to merge`:e.eligibility===`unknown`?`Merge blocked · Requirements unknown`:`Merge blocked`}function lt(e){return e===`approved`||e===`not-required`?`passing`:e===`unknown`?`unknown`:`failing`}function ut(e){return e===`mergeable`?`passing`:e===`conflicting`?`failing`:`unknown`}function dt(e){return e===`conflicting`?`present`:e===`mergeable`?`none`:`unknown`}function ft(e){return e===!0?` · required`:e===null?` · requiredness unknown`:``}function pt(e){return e?.available===!1?e.reason:`GitHub could not load merge requirements.`}function mt(e,t,n){return!!(e&&(t.canMerge||t.canOverride&&n))}function K(e){return e?at[e]:`Merge`}function ht(e){return e===`conflicting`?`true`:void 0}function gt({check:e}){return(0,W.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(G,{state:e.state}),(0,W.jsxs)(`span`,{children:[e.name,` · `,e.state,ft(e.required)]})]}),e.url&&t(e.url)?(0,W.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-muted-foreground underline`,children:`details`}):null]})}function _t({reason:e}){return(0,W.jsxs)(`section`,{"data-slot":`gh-merge-unavailable`,className:`mt-6 rounded-lg border border-border bg-card p-4 text-sm`,children:[(0,W.jsx)(`p`,{className:`font-medium`,children:`Merge status unavailable`}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-soft-foreground`,children:e})]})}function vt({state:e,selectedMethod:t,overrideRules:i,mergeEnabled:a,refreshPending:o,onRefresh:s,onRunAgent:c,onConfirm:l,onMethodChange:u,onOverrideChange:d}){let f=ct(e),p=lt(e.reviewDecision),m=ut(e.mergeable);return(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[e.canMerge?(0,W.jsx)(L,{size:16,"aria-hidden":`true`,className:`mt-0.5 size-5 shrink-0 text-success`}):(0,W.jsx)(P,{size:16,"aria-hidden":`true`,className:`mt-0.5 size-5 shrink-0 text-warning`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsx)(`h3`,{className:`font-semibold`,children:f}),(0,W.jsxs)(n,{type:`button`,variant:`ghost`,size:`sm`,disabled:o,onClick:s,children:[(0,W.jsx)(ee,{size:16,"aria-hidden":`true`,className:r(`size-3.5`,o&&`animate-spin`)}),`Refresh`]})]}),(0,W.jsxs)(`p`,{className:`mt-1 font-mono text-[11px] text-soft-foreground`,children:[e.headRef,` (`,e.headSha.slice(0,7),`) → `,e.baseRef]}),(0,W.jsxs)(`ul`,{className:`mt-3 space-y-2 text-xs`,children:[(0,W.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(G,{state:p}),(0,W.jsxs)(`span`,{children:[`Reviews: `,e.reviewDecision.replaceAll(`-`,` `)]})]}),(0,W.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(G,{state:m}),(0,W.jsxs)(`span`,{children:[`Conflicts: `,dt(e.mergeable)]})]}),e.checks.length===0?(0,W.jsx)(`li`,{children:`No checks configured`}):e.checks.map(e=>(0,W.jsx)(gt,{check:e},e.name)),e.blockers.map(e=>(0,W.jsx)(`li`,{className:`text-soft-foreground`,children:e.message},e.code))]}),e.mergeable===`conflicting`&&c?(0,W.jsx)(n,{className:`mt-4`,onClick:c,children:`Run agent on this PR`}):null,e.canOverride?(0,W.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-2 rounded-md border border-warning/40 bg-warning/5 p-3 text-xs`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>d(e.target.checked),className:`mt-0.5 size-4 accent-accent-strong`}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`span`,{className:`block font-medium`,children:`Merge without waiting for requirements`}),(0,W.jsx)(`span`,{className:`mt-0.5 block text-soft-foreground`,children:`GitHub will allow this only if your permissions can bypass the repository rules.`})]})]}):null,e.eligibility===`unknown`?(0,W.jsx)(`p`,{className:`mt-4 text-xs text-muted-foreground`,children:`GitHub could not confirm review and branch-protection requirements. Passing checks do not establish merge readiness.`}):null,e.state===`open`&&e.methods.length>0?(0,W.jsxs)(`div`,{className:`mt-4 flex flex-col flex-wrap gap-2 sm:flex-row`,children:[(0,W.jsx)(`select`,{"aria-label":`Merge method`,value:t??``,onChange:e=>u(e.target.value),className:`h-9 min-w-0 flex-1 rounded-md border border-input bg-background px-3 text-sm`,children:e.methods.map(e=>(0,W.jsx)(`option`,{value:e,children:at[e]},e))}),(0,W.jsx)(n,{disabled:!a,onClick:l,children:K(t)})]}):null]})]})}function yt({number:e,state:t,selectedMethod:r,confirming:i,overrideRules:a,mergePending:o,mergeError:s,onOpenChange:c,onMerge:l}){return(0,W.jsx)(_e,{open:i,onOpenChange:c,children:(0,W.jsxs)(he,{"data-slot":`gh-merge-confirm`,showCloseButton:!1,children:[(0,W.jsxs)(me,{children:[(0,W.jsxs)(ge,{children:[K(r),` pull request #`,e,`?`]}),(0,W.jsx)(pe,{asChild:!0,children:(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`p`,{children:[`This will merge “`,t.title,`” into `,t.baseRef,`. GitHub will re-check the exact reviewed head before changing the repository.`]}),a&&t.canOverride?(0,W.jsx)(`p`,{"data-slot":`gh-bypass-warning`,className:`mt-4 text-sm text-warning`,children:`You are asking GitHub to bypass unmet repository requirements; GitHub may refuse if your permissions do not allow it.`}):null]})})]}),s?(0,W.jsx)(`p`,{className:`text-sm text-danger`,children:s.message}):null,(0,W.jsxs)(fe,{children:[(0,W.jsx)(n,{variant:`outline`,disabled:o,onClick:()=>c(!1),children:`Cancel`}),(0,W.jsx)(n,{disabled:o,onClick:l,children:o?`Merging…`:K(r)})]})]})})}function bt({number:e,onRunAgent:t}){let n=s(),r=C(),i=T({queryKey:x.githubMergeState(e),queryFn:({signal:t})=>d(e,{},{signal:t}),retry:!1}),a=ot(i.data),[o,c]=(0,U.useState)(null),[l,u]=(0,U.useState)(!1),[f,m]=(0,U.useState)(!1),h=S({mutationFn:t=>d(e,{refresh:!0}),onSuccess:(e,t)=>n.setQueryData(t,e),onError:e=>A(e instanceof Error?e.message:String(e),{tone:`danger`})}),g=st(o,a),_=()=>({mergeState:x.githubMergeState(e),list:x.githubPages(50),comments:x.githubComments(`pr`,e),item:x.githubItem(`pr`,e),refStatus:r===void 0?void 0:x.githubRefStatusOf(r)}),v=S({mutationFn:t=>{if(!a||!g)throw Error(`No merge method is available.`);return p(e,{method:g,expectedHeadSha:a.headSha,...f&&a.canOverride?{overrideRules:!0}:{}})},onSuccess:(t,r)=>{u(!1),A(`Pull request #${e} merged`),n.invalidateQueries({queryKey:r.mergeState}),n.invalidateQueries({queryKey:r.list}),n.invalidateQueries({queryKey:r.comments}),n.invalidateQueries({queryKey:r.item}),r.refStatus&&n.invalidateQueries({queryKey:r.refStatus})},onError:(e,t)=>{A(e instanceof Error?e.message:String(e),{tone:`danger`}),n.invalidateQueries({queryKey:t.mergeState})}});return i.isPending?(0,W.jsx)(B,{"data-slot":`gh-merge-loading`,className:`mt-6 h-32 w-full`}):a?(0,W.jsxs)(`section`,{"data-slot":`gh-merge-box`,"data-eligibility":a.eligibility,"data-conflicting":ht(a.mergeable),"aria-live":`polite`,className:`mt-6 rounded-lg border border-border bg-card p-4`,children:[(0,W.jsx)(vt,{state:a,selectedMethod:g,overrideRules:f,mergeEnabled:mt(g,a,f),refreshPending:h.isPending,onRefresh:()=>h.mutate(x.githubMergeState(e)),onRunAgent:t,onConfirm:()=>u(!0),onMethodChange:c,onOverrideChange:m}),(0,W.jsx)(yt,{number:e,state:a,selectedMethod:g,confirming:l,overrideRules:f,mergePending:v.isPending,mergeError:v.error,onOpenChange:u,onMerge:()=>v.mutate(_())})]}):(0,W.jsx)(_t,{reason:pt(i.data)})}function xt(e){let t=new Set;for(let n of e)for(let e of n.labels)t.add(e);return[...t].sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()))}function St(e,t={}){let n=(t.query??``).trim().toLowerCase(),r=t.labels??[],i=n.replace(/^#/,``),a=i!==``&&/^\d+$/.test(i);return e.filter(e=>r.length>0&&!r.every(t=>e.labels.includes(t))||t.assignees?.length&&!e.assignees?.some(e=>t.assignees.some(t=>t.toLowerCase()===e.toLowerCase()))||t.author!==void 0&&e.author.toLowerCase()!==t.author.toLowerCase()||t.includeNumbers&&!t.includeNumbers.has(e.number)||t.excludeNumbers?.has(e.number)||t.projectId&&e.projectIds!==void 0&&!e.projectIds.includes(t.projectId)?!1:n===``?!0:a?String(e.number).includes(i):`#${e.number} ${e.title} ${e.author} ${e.body??``}`.toLowerCase().includes(n))}function Ct(e,t){let n=e.trim();if(n===``)return!1;let r=n.replace(/^#/,``);return/^\d+$/.test(r)?!t.some(e=>e.number===Number(r)):t.length===0}function q(e){if(!e||!/^[0-9a-fA-F]{6}$/.test(e))return{borderColor:`var(--border)`,color:`var(--muted-foreground)`};let t=`#${e}`;return{backgroundColor:`${t}22`,borderColor:`${t}66`,color:`color-mix(in srgb, ${t} 50%, var(--foreground))`}}function wt({label:e,color:t,plain:n=!1}){return(0,W.jsx)(`span`,{"data-slot":`gh-label`,"data-label":e,style:n?void 0:q(t),className:n?`text-[11px] font-normal text-muted-foreground`:`rounded-full border px-1.5 py-px text-[12px] font-medium`,children:e})}function Tt(e){return e===`pr`?`pull request`:`issue`}function Et(e,t,n){return e===`pr`&&!!(t||n)}function Dt({backLink:e}){return e?(0,W.jsxs)(V,{to:e.to,"data-slot":`gh-back`,className:`mb-3 inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground md:hidden`,children:[(0,W.jsx)(ie,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`Back to the list`]}):null}function Ot({item:e,kindWord:n,commentCount:r,hasDiffStat:i,additions:a,deletions:o}){return(0,W.jsxs)(`p`,{"data-slot":`gh-meta`,className:`flex flex-wrap items-center gap-x-1.5 font-mono text-[11px] text-soft-foreground`,children:[(0,W.jsxs)(`span`,{children:[`#`,e.number]}),`·`,(0,W.jsx)(`span`,{children:n}),`·`,(0,W.jsxs)(`span`,{children:[`opened by `,e.author]}),`·`,(0,W.jsxs)(`span`,{children:[R(e.createdAt),` ago`]}),r?(0,W.jsxs)(W.Fragment,{children:[`·`,(0,W.jsx)(Yt,{count:r})]}):null,i?(0,W.jsxs)(W.Fragment,{children:[`·`,(0,W.jsxs)(`span`,{"data-slot":`gh-diffstat`,children:[(0,W.jsxs)(`span`,{className:`text-success`,children:[`+`,a??0]}),` `,(0,W.jsxs)(`span`,{className:`text-danger`,children:[`−`,o??0]})]})]}):null,`·`,t(e.url)?(0,W.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-open-link`,className:`inline-flex items-center gap-0.5 text-muted-foreground hover:text-foreground hover:underline`,children:[`open on GitHub`,(0,W.jsx)(E,{"aria-hidden":`true`,className:`size-2.5`})]}):(0,W.jsx)(`span`,{"data-slot":`gh-open-link`,className:`text-muted-foreground`,children:`open on GitHub`})]})}function kt({item:e,subNav:t,changes:n}){return e.kind===`pr`?t?(0,W.jsxs)(`nav`,{"aria-label":`Pull request detail`,className:`mt-4 flex border-b border-border`,children:[(0,W.jsx)(it,{to:z(`prs`,t.filter,e.number),active:!n,children:`Conversation`}),(0,W.jsx)(it,{to:z(`prs`,t.filter,e.number,`/changes`),active:n,children:`Changes`})]}):(0,W.jsx)(V,{to:z(`prs`,null,e.number,`/changes`),"data-slot":`gh-files-changed`,className:`mt-3 inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:underline`,children:`Files changed`}):null}function At({item:e,colors:t,checks:n}){return e.labels.length>0||n?(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[e.labels.map(e=>(0,W.jsx)(wt,{label:e,color:t[e]},e)),n?(0,W.jsx)(Xt,{checks:n,url:e.url}):null]}):null}function jt({item:e,colors:t,body:n}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{"data-slot":`gh-body`,className:`mt-5 text-sm`,children:n?(0,W.jsx)($e,{children:n}):(0,W.jsx)(`p`,{className:`text-soft-foreground`,children:`(no description)`})}),(0,W.jsx)(Pt,{item:e,colors:t})]})}function Mt({item:e,colors:t,checks:n,comments:r,backLink:i,subNav:a,onRunAgent:o,afterHeading:s,children:c}){let l=a?.changes??!1,u=Tt(e.kind),d=y(e.kind,e.number,!l).data?.detail,f=d?.body??e.body,p=d?.additions??e.additions,m=d?.deletions??e.deletions,h=Et(e.kind,p,m),g=r??e.comments;return(0,W.jsxs)(`article`,{"data-slot":`gh-detail-inner`,className:`min-w-0 px-4 py-4 md:px-7 md:py-5`,children:[(0,W.jsx)(Dt,{backLink:i}),(0,W.jsxs)(`div`,{"data-slot":`gh-description-card`,className:e.kind===`pr`?`rounded-xl border border-border bg-card p-6`:void 0,children:[e.kind===`pr`?(0,W.jsxs)(`h2`,{className:`mb-4 text-[22px] leading-snug font-normal`,children:[`#`,e.number,` `,e.title]}):null,(0,W.jsx)(Ot,{item:e,kindWord:u,commentCount:g,hasDiffStat:h,additions:p,deletions:m}),e.kind===`pr`?null:(0,W.jsx)(`h2`,{className:`mt-2 text-[22px] leading-snug font-normal`,children:e.title}),s,(0,W.jsx)(kt,{item:e,subNav:a,changes:l}),(0,W.jsx)(At,{item:e,colors:t,checks:n}),l&&e.kind===`pr`?(0,W.jsx)(Nt,{item:e}):(0,W.jsx)(jt,{item:e,colors:t,body:f})]}),e.kind===`pr`?(0,W.jsx)(bt,{number:e.number,onRunAgent:o}):null,c]})}function Nt({item:e}){let i=s(),a=_(e.number),[o,c]=(0,U.useState)(``),[u,d]=(0,U.useState)(null),f=a.data,p=f?.available?f.files.filter(e=>e.path.toLowerCase().includes(o.toLowerCase())):[],m=p.findIndex(e=>e.path===u);(0,U.useEffect)(()=>{p.length>0&&!p.some(e=>e.path===u)&&d(p[0].path)},[f?.available?f.headSha:``,o]);let h=async()=>{let t=f?.available?f.headSha:null,n=x.githubPrChanges(e.number),r=await l(e.number,{refresh:!0});i.setQueryData(n,r),r.available&&t&&t!==r.headSha&&(d(r.files[0]?.path??null),A(`The reviewed revision changed.`))};if(a.isPending)return(0,W.jsx)(`p`,{"aria-live":`polite`,className:`mt-6 text-sm text-muted-foreground`,children:`Loading changed files…`});if(a.isError||!f)return(0,W.jsx)(`p`,{className:`mt-6 text-sm text-danger`,children:`Changed files could not be loaded.`});if(!f.available)return(0,W.jsx)(`p`,{className:`mt-6 text-sm text-muted-foreground`,children:f.reason});let g=p.map(e=>({path:e.path,...e.previousPath?{oldPath:e.previousPath}:{},status:e.status===`removed`?`deleted`:e.status===`changed`?`modified`:e.status,adds:e.additions,dels:e.deletions,binary:e.patchUnavailableReason===`binary`,patch:e.patch??``})),v=t(e.url)?`${e.url}/files`:null,y=p.find(e=>e.path===u);return(0,W.jsxs)(`section`,{"data-slot":`gh-pr-changes`,className:`mt-5 min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,W.jsxs)(`strong`,{children:[f.files.length,` changed files`]}),(0,W.jsxs)(`span`,{className:`text-success`,children:[`+`,f.additions]}),(0,W.jsxs)(`span`,{className:`text-danger`,children:[`−`,f.deletions]}),(0,W.jsxs)(`span`,{className:`font-mono text-muted-foreground`,title:f.headSha,children:[`head `,f.headSha.slice(0,8)]}),(0,W.jsx)(n,{type:`button`,variant:`outline`,size:`sm`,className:`ml-auto min-h-11`,onClick:()=>void h(),children:`Refresh`})]}),f.truncated?(0,W.jsxs)(`p`,{role:`status`,className:`mt-3 rounded-md border border-warning/40 bg-warning/10 p-3 text-xs`,children:[f.reason??`This response is incomplete.`,` `,v?(0,W.jsx)(`a`,{href:v,target:`_blank`,rel:`noopener noreferrer`,className:`underline`,children:`Open all files on GitHub`}):null]}):null,(0,W.jsxs)(`div`,{className:`mt-4 grid min-w-0 gap-4 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,W.jsxs)(`aside`,{className:`min-w-0`,children:[(0,W.jsx)(`input`,{"aria-label":`Filter changed files`,value:o,onChange:e=>c(e.target.value),placeholder:`Filter files…`,className:`min-h-11 w-full rounded-md border border-input bg-background px-3 text-sm`}),(0,W.jsx)(`select`,{"aria-label":`Select changed file`,value:u??``,onChange:e=>d(e.target.value),className:`mt-2 min-h-11 w-full rounded-md border border-input bg-background px-2 text-sm lg:hidden`,children:p.map(e=>(0,W.jsx)(`option`,{children:e.path},e.path))}),(0,W.jsx)(`ul`,{className:`mt-2 hidden max-h-[60vh] overflow-auto lg:block`,children:p.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>d(e.path),className:r(`min-h-11 w-full truncate rounded px-2 text-left text-xs`,u===e.path&&`bg-muted font-medium`),title:e.path,children:[e.status,` · `,e.path,` `,(0,W.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions]}),` `,(0,W.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions]})]})},e.path))})]}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`mb-2 flex justify-end gap-1`,children:[(0,W.jsx)(n,{"aria-label":`Previous file`,variant:`outline`,size:`icon`,className:`min-h-11 min-w-11`,disabled:m<=0,onClick:()=>d(p[m-1]?.path??null),children:(0,W.jsx)(nt,{})}),(0,W.jsx)(n,{"aria-label":`Next file`,variant:`outline`,size:`icon`,className:`min-h-11 min-w-11`,disabled:m<0||m>=p.length-1,onClick:()=>d(p[m+1]?.path??null),children:(0,W.jsx)(F,{size:16})})]}),p.length===0?(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No changed files match this filter.`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(rt,{files:g.filter(e=>e.path===u),wrap:!0,className:`min-w-0`}),y&&!y.patch?(0,W.jsxs)(`p`,{className:`rounded-b border border-border p-3 text-xs text-muted-foreground`,children:[`Patch unavailable: `,y.patchUnavailableReason??`not-provided`,`.`]}):null]})]})]})]})}function Pt({item:e,colors:t}){let n=y(e.kind,e.number),r=n.data,i=(0,U.useMemo)(()=>{let e=[...(r?.comments??[]).map(e=>({row:`comment`,comment:e})),...(r?.events??[]).map(e=>({row:`event`,event:e}))],t=e=>{let t=Date.parse(Ft(e));return Number.isNaN(t)?-1/0:t};return e.sort((e,n)=>t(e)-t(n))},[r?.comments,r?.events]);return n.isPending?(0,W.jsxs)(`section`,{"data-slot":`gh-thread-loading`,className:`mt-6 border-t border-border pt-5`,children:[(0,W.jsx)(B,{className:`mb-3 h-3 w-24`}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsx)(B,{className:`h-14 w-full`}),(0,W.jsx)(B,{className:`h-14 w-full`})]})]}):!r||!r.available?(0,W.jsxs)(`section`,{"data-slot":`gh-thread-error`,className:`mt-6 border-t border-border pt-5 text-xs text-soft-foreground`,children:[(0,W.jsxs)(`span`,{children:[`Couldn’t load comments — `,r?.reason??(n.error instanceof Error?n.error.message:`could not load comments`),`. `]}),(0,W.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-0.5 text-muted-foreground hover:text-foreground hover:underline`,children:[`open on GitHub`,(0,W.jsx)(E,{"aria-hidden":`true`,className:`size-2.5`})]})]}):i.length===0?null:(0,W.jsxs)(`section`,{"data-slot":`gh-thread`,className:`mt-6 border-t border-border pt-5`,children:[(0,W.jsxs)(`h3`,{"data-slot":`gh-thread-header`,className:`mb-4 text-[11px] font-semibold tracking-wide text-soft-foreground uppercase`,children:[`Activity · `,r.comments.length,` comment`,r.comments.length===1?``:`s`]}),(0,W.jsx)(`ul`,{className:`flex flex-col gap-5`,children:It(i).map(e=>e.group===`commits`?(0,W.jsx)(Lt,{commits:e.commits,colors:t},e.commits[0].id):e.entry.row===`comment`?(0,W.jsx)(qt,{comment:e.entry.comment},`${e.entry.comment.kind}-${e.entry.comment.id}`):(0,W.jsx)(Rt,{event:e.entry.event,colors:t},e.entry.event.id))}),r.truncated?(0,W.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-thread-truncated`,className:`mt-4 inline-flex items-center gap-0.5 text-xs text-soft-foreground hover:text-foreground hover:underline`,children:[`thread truncated — open on GitHub`,(0,W.jsx)(E,{"aria-hidden":`true`,className:`size-2.5`})]}):null]})}var Ft=e=>e.row===`comment`?e.comment.createdAt:e.event.createdAt;function It(e){let t=[],n=[],r=()=>{n.length!==0&&(n.length===1?t.push({group:`single`,entry:{row:`event`,event:n[0]}}):t.push({group:`commits`,commits:n}),n=[])};for(let i of e){if(i.row===`event`&&i.event.kind===`committed`&&i.row===`event`){let e=n[n.length-1];e&&e.actor!==i.event.actor&&r(),n.push(i.event);continue}r(),t.push({group:`single`,entry:i})}return r(),t}function Lt({commits:e,colors:t}){let[n,r]=(0,U.useState)(!1),i=e[0]?.actor??`?`;return n?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`true`,className:`min-w-0`,children:(0,W.jsxs)(`button`,{type:`button`,"aria-expanded":!0,onClick:()=>r(!1),className:`flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground hover:text-foreground`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,children:J.committed}),(0,W.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,W.jsxs)(`span`,{children:[`added `,e.length,` commits`]})]})}),e.map(e=>(0,W.jsx)(Rt,{event:e,colors:t},e.id))]}):(0,W.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`false`,className:`min-w-0`,children:(0,W.jsxs)(`button`,{type:`button`,"aria-expanded":!1,onClick:()=>r(!0),className:`flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground hover:text-foreground`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,children:J.committed}),(0,W.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,W.jsxs)(`span`,{children:[`added `,e.length,` commits`]}),(0,W.jsx)(`span`,{className:`shrink-0`,children:R(e[e.length-1].createdAt)})]})})}var J={committed:`⚙`,labeled:`◆`,unlabeled:`◇`,assigned:`◍`,unassigned:`◌`,merged:`⑃`,closed:`⊘`,reopened:`⊙`,head_ref_force_pushed:`↻`,"cross-referenced":`↗`,renamed:`✎`};function Rt({event:e,colors:t}){return(0,W.jsxs)(`li`,{"data-slot":`gh-event-row`,"data-kind":e.kind,className:r(`flex min-w-0 items-center gap-1.5 font-mono text-[11px] text-soft-foreground`,e.kind===`merged`&&`text-accent-foreground`),children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:J[e.kind]}),(0,W.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.actor}),(0,W.jsx)(Wt,{event:e,colors:t}),(0,W.jsx)(`span`,{className:`shrink-0`,children:R(e.createdAt)}),e.url?(0,W.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`open ${e.kind} on GitHub`,className:`ml-auto shrink-0 text-muted-foreground hover:text-foreground`,children:(0,W.jsx)(E,{"aria-hidden":`true`,className:`size-2.5`})}):null]})}function zt({event:e}){return(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:`shrink-0`,children:`committed`}),e.sha?(0,W.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.sha.slice(0,7)}):null,e.message?(0,W.jsx)(`span`,{className:`truncate font-sans text-foreground`,children:e.message}):null,(0,W.jsx)(Gt,{checks:e.checks})]})}function Bt({event:e,colors:t}){return(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:`shrink-0`,children:e.kind===`labeled`?`added the`:`removed the`}),e.label?(0,W.jsx)(`span`,{"data-slot":`gh-event-label`,style:q(e.label.color??t[e.label.name]),className:`max-w-[12rem] truncate rounded-full border px-1.5 py-px font-sans text-[12px]`,children:e.label.name}):null,(0,W.jsx)(`span`,{className:`shrink-0`,children:`label`})]})}function Vt({event:e}){return(0,W.jsxs)(`span`,{className:`truncate`,children:[e.kind===`assigned`?`assigned`:`unassigned`,` `,e.subject??`someone`]})}function Ht({event:e}){return(0,W.jsxs)(`span`,{className:`truncate`,children:[`referenced this in `,e.refNumber?`#${e.refNumber}`:`another thread`,e.refTitle?` ${e.refTitle}`:``]})}var Ut={committed:e=>(0,W.jsx)(zt,{event:e}),labeled:(e,t)=>(0,W.jsx)(Bt,{event:e,colors:t}),unlabeled:(e,t)=>(0,W.jsx)(Bt,{event:e,colors:t}),assigned:e=>(0,W.jsx)(Vt,{event:e}),unassigned:e=>(0,W.jsx)(Vt,{event:e}),merged:()=>(0,W.jsx)(`span`,{children:`merged this`}),closed:()=>(0,W.jsx)(`span`,{children:`closed this`}),reopened:()=>(0,W.jsx)(`span`,{children:`reopened this`}),head_ref_force_pushed:()=>(0,W.jsx)(`span`,{children:`force-pushed`}),renamed:e=>(0,W.jsxs)(`span`,{className:`truncate`,children:[`renamed this to `,e.subject??`—`]}),"cross-referenced":e=>(0,W.jsx)(Ht,{event:e})};function Wt({event:e,colors:t}){return Ut[e.kind]?.(e,t)??null}function Gt({checks:e}){return e?(0,W.jsx)(`span`,{"data-slot":`gh-commit-checks`,"data-checks":e,"aria-label":`checks ${e}`,className:r(`shrink-0`,X[e]),children:Y[e]}):null}var Kt={approved:{label:`approved`,tone:`border-success/40 text-success`},changes_requested:{label:`changes requested`,tone:`border-danger/40 text-danger`},commented:{label:`commented`,tone:`border-border text-muted-foreground`},dismissed:{label:`dismissed`,tone:`border-border text-muted-foreground`}};function qt({comment:e}){let t=e.reviewState?Kt[e.reviewState]:null;return(0,W.jsxs)(`li`,{"data-slot":`gh-thread-entry`,"data-kind":e.kind,className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground`,children:[(0,W.jsx)(Jt,{url:e.avatarUrl,login:e.author}),(0,W.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.author}),(0,W.jsx)(`span`,{children:R(e.createdAt)}),t?(0,W.jsx)(`span`,{"data-slot":`gh-review-chip`,"data-review-state":e.reviewState,className:r(`rounded-full border px-1.5 py-px font-sans text-[12px] font-medium`,t.tone),children:t.label}):null,(0,W.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`open comment on GitHub`,className:`ml-auto shrink-0 text-muted-foreground hover:text-foreground`,children:(0,W.jsx)(E,{"aria-hidden":`true`,className:`size-2.5`})})]}),(0,W.jsx)(`div`,{"data-slot":`gh-thread-body`,className:`text-sm`,children:e.body?(0,W.jsx)($e,{children:e.body}):(0,W.jsx)(`p`,{className:`text-soft-foreground`,children:`(no body)`})})]})}function Jt({url:e,login:t}){let[n,r]=(0,U.useState)(!1);return e&&!n?(0,W.jsx)(`img`,{src:e,alt:``,width:16,height:16,loading:`lazy`,onError:()=>r(!0),"data-slot":`gh-avatar`,className:`size-4 shrink-0 rounded-full`}):(0,W.jsx)(`span`,{"data-slot":`gh-avatar-fallback`,"aria-hidden":`true`,className:`flex size-4 shrink-0 items-center justify-center rounded-full bg-muted text-[8px] font-semibold text-muted-foreground uppercase`,children:t.slice(0,1)||`?`})}var Y={passing:`✓`,failing:`✗`,pending:`○`},X={passing:`text-success`,failing:`text-danger`,pending:`text-muted-foreground`};function Yt({count:e}){return e?(0,W.jsxs)(`span`,{"data-slot":`gh-comment-count`,"data-count":e,"aria-label":`${e} comment${e===1?``:`s`}`,className:`inline-flex shrink-0 items-center gap-0.5`,children:[(0,W.jsx)(ue,{"aria-hidden":`true`,className:`size-3`}),e]}):null}function Xt({checks:e,url:t}){let n=r(`text-[11px] font-medium`,X[e],t&&`hover:underline`),i=`${Y[e]} checks ${e}`;return t?(0,W.jsx)(`a`,{href:`${t}/checks`,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-checks`,"data-checks":e,className:n,children:i}):(0,W.jsx)(`span`,{"data-slot":`gh-checks`,"data-checks":e,className:n,children:i})}function Zt({checks:e}){return(0,W.jsx)(`span`,{"data-slot":`gh-row-checks`,"data-checks":e,title:`checks ${e}`,"aria-label":`checks ${e}`,className:r(`shrink-0 font-sans text-[11px] font-semibold`,X[e]),children:Y[e]})}function Z(e){return`${e.kind===`pr`?`Address GitHub pull request`:`Fix GitHub issue`} #${e.number}: ${e.title}\n\n${e.url}`}function Qt(e,t=[]){let n=Z(e);return e.body?.trim()&&(n+=`\n\n---\n\n${e.body.trim()}`),t.length&&(n+=$t(t)),n}function $t(e){return`\n\nUse these skills where relevant: ${e.join(`, `)}.`}function en(e,t){return e.replace(/\{\{\s*number\s*\}\}/gi,()=>`#${t.number}`).replace(/\{\{\s*title\s*\}\}/gi,()=>t.title).replace(/\{\{\s*url\s*\}\}/gi,()=>t.url)}function tn(e,t){if(e.includes(t.url))return!0;let n=t.kind===`pr`?String.raw`(?:pull\s+request|pr)`:String.raw`issue`;return new RegExp(String.raw`\b${n}\s*#?\s*${t.number}\b`,`i`).test(e)}function Q(e,t,n){let r=(n??``).trim();if(!r)return Qt(e,t);let i=Z(e),a=r.startsWith(i)?i+en(r.slice(i.length),e):en(r,e),o=tn(a,e)?a:`${i}\n\n${a}`;return t.length?o+$t(t):o}function nn(e){let t=[];for(let n of e.slice(0,8)){let e=new Set(t.map(e=>e.id)),r=n;for(let t=2;e.has(r);t++)r=`${n}-${t}`;t.push({id:r,name:n,skill:n,prompt:`{{task}}`})}return t}function rn(e,t,n,r,i={}){return t?{...i,workflow:t,task:Q(e,n,r)}:n.length?{...i,steps:nn(n),task:Q(e,[],r)}:{...i,workflow:`quick-task`,task:Q(e,[],r)}}function an(e){let t=m(),n=b(),r=f(t.data),i=n.data?.defaultRunner,a=be(e.runner,r,i??r[0]??`claude`),o=w(a),s=n.data?.modelsLocked===!0,{accounts:c,repoAccount:l}=Ie(),u=c.some(t=>t.provider===a&&t.id===e.account)?e.account:null,d=Oe(s?null:e.model,a,n.data?.defaultModels,o.data),p=Ae(a,d,o.data);return{runner:a,runnerExplicit:e.runner!==null,model:d,effort:s?``:He(e.effort,p),effortOptions:p,runners:r,defaultRunner:i,canRun:t.isSuccess&&r.length>0,modelsLocked:s,providerPending:t.isPending,providerError:t.isError,accounts:c,account:u,repoAccount:l}}function on(e){return{runner:we(e.runner,e.defaultRunner,e.runnerExplicit),model:e.modelsLocked?void 0:e.model||void 0,effort:e.modelsLocked?void 0:e.effort||void 0}}function sn(e){return{...on(e),...e.account?{agentProfile:e.account}:{}}}function cn({pick:e,onChange:t,disabled:n=!1,accounts:r=!1,layout:i}){let a=(0,U.useRef)(null),o=(0,U.useRef)(null),[s,c]=(0,U.useState)(()=>typeof window<`u`&&window.innerWidth<=767);(0,U.useLayoutEffect)(()=>{let e=a.current;if(i!==`row`||!e)return;let t=()=>{let t=window.innerWidth<=767||e.getBoundingClientRect().width<550,n=document.activeElement;o.current=n instanceof HTMLElement&&e.contains(n)?n:null,c(t)};t();let n=typeof ResizeObserver>`u`?null:new ResizeObserver(t);return n?.observe(e),window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t)}},[i]),(0,U.useLayoutEffect)(()=>{let e=o.current;o.current=null,e&&e.isConnected&&document.activeElement!==e&&e.focus()},[s]);let l=an(e),{runner:u,model:d,effort:f,effortOptions:p,runners:m,canRun:h,modelsLocked:g}=l,_=b(),v=w(u),y=De(u,v.data,[e.model,_.data?.defaultModels?.[u]]),x=n||!h,S=r?l.accounts:[],C=m.length>1||m.some(e=>Be(S,e))?(0,W.jsx)(ke,{icon:(0,W.jsx)(re,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:m,value:u,accounts:S,account:r?l.account:null,repoAccount:r?l.repoAccount:void 0,disabled:x,onPick:(n,i)=>t(r?{runner:n,account:i,model:n===u?e.model:null,effort:e.effort}:{runner:n,account:null,model:null,effort:e.effort})},`runner`):null,T=(0,W.jsx)(Re,{icon:(0,W.jsx)(N,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`model-pill`,ariaLabel:`Model`,label:d===``?`Default`:y.find(e=>e.id===d).label,value:d,disabled:x,readOnly:g===!0,disabledHint:g?`Model selection is locked to native coding-agent settings.`:void 0,onPick:n=>{let r=Ae(u,n,v.data);t({...e,model:n,effort:e.effort===null?null:He(e.effort,r)})},options:y.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:Ue(u,v.data,v.isError,v.isFetching)},`model`),E=(0,W.jsx)(Re,{icon:(0,W.jsx)(j,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`effort-pill`,ariaLabel:`Effort`,label:p.find(e=>e.value===f)?.label??`auto`,value:f,disabled:x,readOnly:g===!0,disabledHint:g?`Effort selection is locked to native coding-agent settings.`:void 0,onPick:n=>t({...e,effort:n}),options:p.map(e=>({value:e.value,label:e.label,desc:e.desc}))},`effort`);return i===`row`?(0,W.jsx)(`div`,{ref:a,"data-slot":`engine-row-box`,children:(0,W.jsx)(`div`,{"data-slot":`engine-row`,className:`engine-row`,role:`group`,"aria-label":`Agent settings`,children:(0,W.jsx)(Ne,{children:s?[C,E,T]:[C,T,E]})})}):(0,W.jsxs)(Ne,{children:[C,T,E]})}var ln={workflow:null,skills:[]},un=`cez-followup-selection`;function dn(e){let t=e&&typeof e==`object`?e:{};return{workflow:typeof t.workflow==`string`?t.workflow:null,skills:Array.isArray(t.skills)?t.skills.filter(e=>typeof e==`string`):[]}}function fn(){try{let e=localStorage.getItem(un);return e?dn(JSON.parse(e)):{...ln}}catch{return{...ln}}}function pn(e){try{localStorage.setItem(un,JSON.stringify(e))}catch{}}var $=`cez-followup-prompt:`;function mn(e){try{return localStorage.getItem($+e)??``}catch{return``}}function hn(e,t){try{t===``?localStorage.removeItem($+e):localStorage.setItem($+e,t)}catch{}}function gn({item:e,workflows:r,skills:i,workflow:a,onWorkflowChange:l,selectedSkills:u,onSkillsChange:d,engine:f,onEngineChange:p,queuedRunId:m,onQueued:h}){let g=s(),_=v(),y=xe(),b=e.kind===`pr`?`PR`:`issue`,C=u.filter(e=>i.some(t=>t.name===e)),[w]=(0,U.useState)(()=>Z(e)),[T,E]=(0,U.useState)(()=>mn(e.url)||w),D=an(f),O=(0,U.useRef)(null),k=(0,U.useRef)(null);(0,U.useEffect)(()=>{hn(e.url,T===w?``:T)},[e.url,T,w]);let j=(0,U.useMemo)(()=>Me(je(_.data?.promptTemplates),{automations:y}),[_.data?.promptTemplates,y]),ee=e=>{let t=O.current,n=Fe({prompt:T,base:w,selectionStart:t?.selectionStart??null,focused:document.activeElement===t,remembered:k.current}),r=Ve(T,n,e);E(r.text),k.current=r.caret,requestAnimationFrame(()=>{O.current?.focus(),O.current?.setSelectionRange(r.caret,r.caret)})},M=Pe(j,C),N=(0,U.useRef)(T);N.current=T;let P=(0,U.useRef)(``);(0,U.useEffect)(()=>{let e=Le(N.current,P.current,M,w);P.current=e.applied,e.text!==N.current&&E(e.text)},[M,w]);let F=S({mutationFn:async()=>D.canRun?o(rn(e,a,C,T,sn(D))):null,onSuccess:t=>{if(t===null)return;let n=t;n&&h(e.url,n.id),A(`Added to the queue — ${b} #${e.number}`),C.length>0&&_.data!==void 0&&c({skillUsage:C.reduce((e,t)=>Ye(e,t),_.data.skillUsage)}).then(()=>g.invalidateQueries({queryKey:x.uiState})).catch(()=>{}),hn(e.url,``),E(w),P.current=``,g.invalidateQueries({queryKey:x.runs.all})},onError:e=>A(e.message,{tone:`danger`})}),te=e=>{tt({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),!F.isPending&&D.canRun&&F.mutate())},I=e=>d(u.includes(e)?u.filter(t=>t!==e):[...u,e]);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`section`,{"data-slot":`gh-hand`,className:`mt-7 rounded-lg border border-border bg-card p-4`,children:[(0,W.jsx)(`h3`,{className:`text-xl font-normal text-foreground`,children:`Hand this to the agent`}),(0,W.jsxs)(`label`,{className:`gh-field gh-prompt-field`,children:[(0,W.jsx)(`span`,{children:`Instructions for the agent`}),(0,W.jsx)(Ze,{ref:O,"data-slot":`gh-custom-prompt`,"aria-label":`Custom prompt`,"aria-keyshortcuts":`Control+Enter Meta+Enter`,value:T,onChange:e=>E(e.target.value),onSelect:e=>{k.current=e.currentTarget.selectionStart},onKeyDown:te,placeholder:`Instructions for the agent… (#${e.number} and its link are always sent)`,className:`mt-3 min-h-20 text-[13px]`})]}),(0,W.jsx)(ve,{templates:j,onInsert:ee}),(0,W.jsxs)(`div`,{className:`gh-handoff-settings`,children:[(0,W.jsxs)(`div`,{className:`gh-field`,children:[(0,W.jsx)(`span`,{children:`Workflow`}),(0,W.jsx)(_n,{workflows:r,value:a,onChange:l})]}),(0,W.jsxs)(`div`,{className:`gh-field`,children:[(0,W.jsx)(`span`,{children:`Skills · select one or more`}),(0,W.jsx)(yn,{skills:i,skillUsage:_.data?.skillUsage,selected:C,onToggle:I})]}),C.length>0?(0,W.jsx)(`div`,{"data-slot":`gh-skill-chips`,className:`mt-2.5 flex flex-wrap gap-1.5`,children:C.map(e=>(0,W.jsxs)(`button`,{type:`button`,"data-slot":`gh-skill-chip`,"data-skill":e,onClick:()=>I(e),title:`Remove this skill`,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium text-foreground transition-colors hover:bg-danger/10 hover:text-danger`,children:[e,(0,W.jsx)(ne,{size:16,"aria-hidden":`true`,className:`size-3`})]},e))}):null,(0,W.jsx)(cn,{layout:`row`,pick:f,onChange:p,disabled:F.isPending||!D.canRun,accounts:!0}),(0,W.jsxs)(`div`,{className:`gh-field`,children:[(0,W.jsx)(`span`,{children:`Account`}),(0,W.jsx)(vn,{resolved:D,disabled:F.isPending||!D.canRun,onPick:e=>p({...f,account:e})})]}),!D.providerPending&&!D.canRun?(0,W.jsxs)(`span`,{"data-slot":`gh-provider-gate`,className:`inline-flex flex-wrap items-center gap-1 text-xs text-muted-foreground`,children:[D.providerError?`Provider authentication could not be verified.`:`Connect an agent provider to run this item.`,(0,W.jsx)(V,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null]}),(0,W.jsxs)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:[e.kind===`pr`?`PR`:`Issue`,` number and link remain attached to the task. Edit the prompt before starting. Cmd/Ctrl+Enter submits; Enter adds a new line.`]})]}),(0,W.jsxs)(`div`,{"data-slot":`gh-handoff-actions`,className:`mt-[22px] flex flex-wrap items-center gap-2.5`,children:[t(e.url)?(0,W.jsx)(n,{asChild:!0,variant:`outline`,children:(0,W.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:`Open in GitHub`})}):null,(0,W.jsxs)(n,{variant:`primary`,"data-action":`gh-run`,disabled:F.isPending||!D.canRun,onClick:()=>F.mutate(),children:[(0,W.jsx)(de,{"aria-hidden":`true`,className:`size-3.5`}),`Run agent on this `,b]}),(0,W.jsx)(`kbd`,{"aria-hidden":`true`,className:`rounded-[5px] border border-b-2 border-border bg-card px-[5px] py-px font-mono text-[11px] font-medium text-muted-foreground`,children:et()}),m?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`span`,{"data-slot":`gh-queued`,className:`flex items-center gap-1 text-xs font-medium text-success`,children:[(0,W.jsx)(L,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`queued`]}),(0,W.jsx)(V,{to:`/tasks/${m}`,"data-slot":`gh-view-run`,className:`text-xs font-semibold text-accent-text hover:underline`,children:`View task →`})]}):null]})]})}function _n({workflows:e,value:t,onChange:n}){let[i,a]=(0,U.useState)(!1),[o,s]=(0,U.useState)(``),c=(0,U.useRef)(null),l=Ge(e,o);return(0,W.jsxs)(k,{open:i,onOpenChange:e=>{a(e),e||s(``)},children:[(0,W.jsx)(O,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,"data-slot":`gh-workflow-trigger`,"aria-label":`Choose a workflow`,className:r(ze,t&&`border-foreground/60 font-mono text-[11px] font-semibold text-foreground`),children:[(0,W.jsx)(te,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),(0,W.jsx)(`span`,{className:`min-w-0 max-w-44 truncate`,children:t??`workflow`}),(0,W.jsx)(oe,{size:16,"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,W.jsx)(D,{align:`start`,sideOffset:8,className:`w-[320px] max-w-[calc(100vw-2rem)] p-0`,children:(0,W.jsxs)(Te,{shouldFilter:!1,children:[(0,W.jsx)(Ee,{placeholder:`search workflows…`,value:o,onValueChange:s,onInput:()=>c.current?.scrollTo(0,0)}),(0,W.jsxs)(ye,{ref:c,"data-slot":`gh-workflow-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[l.length===0?(0,W.jsx)(Se,{children:`Nothing matches.`}):null,(0,W.jsx)(H,{children:l.map(e=>{let r=t===e.name;return(0,W.jsxs)(We,{value:`workflow ${e.name}`,keywords:Ke(e.name,e.description),"data-slot":`gh-workflow-option`,"data-workflow":e.name,onSelect:()=>{n(r?null:e.name),a(!1)},children:[(0,W.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),e.description?(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,r?(0,W.jsx)(L,{size:16,"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},e.name)})})]})]})})]})}function vn({resolved:e,disabled:t,onPick:n}){let r=e.accounts.filter(t=>t.provider===e.runner),i=[...r.some(e=>e.id==="default")?[]:[{value:Ce,label:`Default`}],...r.map(e=>({value:e.id,label:e.label,desc:e.configDir}))],a=e.account??e.repoAccount?.[e.runner]??`default`;return(0,W.jsx)(Re,{icon:(0,W.jsx)(se,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),slot:`account-pill`,ariaLabel:`Account`,label:i.find(e=>e.value===a)?.label??`Default`,value:a,options:i,disabled:t,onPick:n})}function yn({skills:e,skillUsage:t,selected:n,onToggle:i}){let[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(``),[l,u]=(0,U.useState)(null),d=(0,U.useRef)(null),{mostUsed:f,project:p,global:m,ranked:h}=Xe(e,s,t),g=(e,t)=>{let a=n.includes(e.name);return(0,W.jsxs)(We,{value:`skill ${e.name} ${e.path}`,keywords:Ke(e.name,e.description),"data-slot":`gh-skill-option`,"data-skill":e.name,"data-selected":a?`true`:void 0,onSelect:()=>i(e.name),children:[(0,W.jsx)(`span`,{className:r(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.description?(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,(0,W.jsx)(`button`,{type:`button`,"data-slot":`gh-skill-view`,"aria-label":`View skill ${e.name}`,title:`View skill`,onClick:t=>{t.preventDefault(),t.stopPropagation(),u(e)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,W.jsx)(ce,{"aria-hidden":`true`,className:`size-3.5`})}),a?(0,W.jsx)(L,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},e.path)};return e.length===0?null:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Qe,{skill:l,onClose:()=>u(null)}),(0,W.jsxs)(k,{open:a,onOpenChange:e=>{o(e),e||c(``)},children:[(0,W.jsx)(O,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,"data-slot":`gh-skills-trigger`,"aria-label":`Choose skills`,className:r(ze,n.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,W.jsx)(ae,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),`skills`,n.length>0?` · ${n.length}`:``,(0,W.jsx)(oe,{size:16,"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,W.jsx)(D,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,W.jsxs)(Te,{shouldFilter:!1,children:[(0,W.jsx)(Ee,{placeholder:`search skills…`,value:s,onValueChange:c,onInput:()=>d.current?.scrollTo(0,0)}),(0,W.jsxs)(ye,{ref:d,"data-slot":`gh-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[(h?h.length===0:f.length===0&&p.length===0&&m.length===0)?(0,W.jsx)(Se,{children:`Nothing matches.`}):null,h?h.length>0?(0,W.jsx)(H,{children:h.map(e=>g(e,qe(e)))}):null:(0,W.jsxs)(W.Fragment,{children:[f.length>0?(0,W.jsx)(H,{heading:`Most used`,children:f.map(e=>g(e,qe(e)))}):null,p.length>0?(0,W.jsx)(H,{heading:`Project skills`,children:p.map(e=>g(e,!0))}):null,m.length>0?(0,W.jsx)(H,{heading:`Global`,children:m.map(e=>g(e,!1))}):null]})]})]})})]})]})}var bn=new WeakMap;function xn(){let e=fn(),t={workflow:e.workflow,selectedSkills:e.skills,engine:{runner:null,model:null,effort:null,account:null},queued:new Map},n=new Set;return{snapshot:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)}),update:e=>{t={...t,...e},(e.workflow!==void 0||e.selectedSkills!==void 0)&&pn({workflow:t.workflow,skills:[...t.selectedSkills]}),n.forEach(e=>e())}}}function Sn(){let e=s(),{projectId:t}=u(),n=bn.get(e);n||bn.set(e,n=new Map);let r=n.get(t);r||n.set(t,r=xn());let{snapshot:i,subscribe:a,update:o}=r,c=(0,U.useSyncExternalStore)(a,i,i),l=g(),d=h(),f=v(),p=l.data?.workflows;(0,U.useEffect)(()=>{p&&c.workflow!==null&&!p.some(e=>e.name===c.workflow)&&o({workflow:null})},[o,p,c.workflow]);let m=(0,U.useMemo)(()=>Je(d.data??[],f.data?.skillUsage),[d.data,f.data?.skillUsage]);return{...c,workflows:l,skillList:m,setWorkflow:e=>o({workflow:e}),setSelectedSkills:e=>o({selectedSkills:e}),setEngine:e=>o({engine:e}),onQueued:(e,t)=>o({queued:new Map(i().queued).set(e,t)})}}export{Yt as a,It as c,q as d,Ct as f,Zt as i,xt as l,gn as n,Mt as o,Qt as r,wt as s,Sn as t,St as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Nr as e,Wr as t}from"./project-scope-context-bgdvGX9z.js";function n(n,r){return e(n,t,r)}export{n as t};
|