@wjarka/cezarion 0.18.0-dev.6210 → 0.18.0-dev.6217

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/package.json +2 -2
  2. package/web/dist/assets/{activity-motion-CMR2FerL.js → activity-motion-DjMpx0QL.js} +1 -1
  3. package/web/dist/assets/{activity-route-DXS9Ymj7.js → activity-route-CE2cYbQO.js} +1 -1
  4. package/web/dist/assets/{commit-diff-panel-D6qd0Twy.js → commit-diff-panel-DBrsQdXO.js} +1 -1
  5. package/web/dist/assets/{diff-hym46LSx.js → diff-D81T6FlH.js} +2 -2
  6. package/web/dist/assets/{diff-view-_yNeX9eg.js → diff-view-Sqk3iny_.js} +1 -1
  7. package/web/dist/assets/{file-preview-BUmlTtoq.js → file-preview-CFvc38AT.js} +1 -1
  8. package/web/dist/assets/{git-toolbar-CyP2nq4z.js → git-toolbar-CZAj0VNk.js} +1 -1
  9. package/web/dist/assets/{github-CUoR_Zoi.js → github-Cdg3-sQK.js} +1 -1
  10. package/web/dist/assets/{global-activity-route-CYONcWvg.js → global-activity-route-9DUVLRv0.js} +1 -1
  11. package/web/dist/assets/index-CCrif8vP.css +1 -0
  12. package/web/dist/assets/{index-aewNqo85.js → index-s7PhnzDS.js} +5 -5
  13. package/web/dist/assets/{preview-pane-connected-D4zb4o4f.js → preview-pane-connected-DVlhmoyi.js} +1 -1
  14. package/web/dist/assets/{repo-git-Cm2rl3mi.js → repo-git-CwibBYwB.js} +1 -1
  15. package/web/dist/assets/{report-reader-B55XaKdM.js → report-reader-BdYHFEdw.js} +1 -1
  16. package/web/dist/assets/{reports-DV1p5ANp.js → reports-CWlWhffn.js} +1 -1
  17. package/web/dist/assets/{run-header-JJRW4anN.js → run-header-Dc5892Cu.js} +1 -1
  18. package/web/dist/assets/{skills-B23AfCjv.js → skills-B2Cc1jJi.js} +1 -1
  19. package/web/dist/assets/{task-changes-UpfXmFh-.js → task-changes-CN0VE5bZ.js} +1 -1
  20. package/web/dist/assets/{task-commits-ojjs1kes.js → task-commits-ycrhlORw.js} +1 -1
  21. package/web/dist/assets/{task-files-H9WcCcuP.js → task-files-CjqaWaul.js} +1 -1
  22. package/web/dist/assets/{task-github-item-OWr0Bv76.js → task-github-item-CezPgdB9.js} +1 -1
  23. package/web/dist/assets/{task-thread-982bQzuA.js → task-thread-BfsMGE4k.js} +1 -1
  24. package/web/dist/assets/{thread-state-9nrcMlnW.js → thread-state-B6Ar3fj6.js} +1 -1
  25. package/web/dist/assets/{use-hand-to-agent-state-C5obI4ms.js → use-hand-to-agent-state-BOTjwkGM.js} +1 -1
  26. package/web/dist/assets/{workflows-vvg7FkDS.js → workflows-B32GiY9u.js} +1 -1
  27. package/web/dist/index.html +2 -2
  28. package/web/dist/assets/index-BulLoFyk.css +0 -1
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{D as t,I as n,L as r,M as i,t as a,u as o}from"./button-CS5tOblf.js";import{i as s,t as c}from"./react-runtime-CCIEwYL0.js";import{Kr as l,Rt as u,f as d,on as f,tn as p,wn as m}from"./project-scope-context-DSkcNKO7.js";import{$ as h,J as g,K as _,X as v,Y as y,Z as b,et as x,rt as S,z as C}from"./live-protocol-DBPXI6ks.js";import{$t as w,I as ee,Rt as te,Z as T,jt as ne,n as E}from"./queries-D2MPDhtr.js";import{t as re}from"./useQuery-8pHkglP4.js";import{n as D}from"./toaster-CRVRHlMR.js";import{G as ie,Q as ae,Z as O,ct as k,d as oe,ht as se,l as ce,mt as le,u as ue}from"./design-icons-DmYTv2r1.js";import{t as A}from"./input-DIwJvCgi.js";import{t as j}from"./project-router-BFKfAFvq.js";import{c as de,i as fe,o as pe,p as me}from"./skills-DFBiAuJG.js";import{t as he}from"./centered-state-BmsqxbI8.js";import{$ as ge,I as _e,P as ve,en as ye}from"./index-aewNqo85.js";import{t as be}from"./skill-empty-hint-YDmkqgo-.js";var M=e(s(),1),N=`owner/name, an https, ssh or git URL, git@host:path, or a local or file:// path`,xe=new Set([`https`,`http`,`ssh`,`git`,`file`]);function P(e){let t=e.trim();if(!t||t.startsWith(`-`)||t.includes(`::`))return null;if(t.startsWith(`~/`))return`home`;if(/^(\/|\.\/|\.\.\/)/.test(t)||/^[A-Za-z]:[\\/]/.test(t))return`local`;if(/^[\w.-]+\/[\w.-]+$/.test(t))return`github`;let n=/^([a-z][a-z0-9+.-]*):\/\//i.exec(t);return n?xe.has(n[1].toLowerCase())?`url`:null:/^[\w.-]+@[\w.-]+:/.test(t)?`scp`:null}function F(e){return e.length>0&&e.length<=256&&!e.startsWith(`-`)&&!e.includes(`..`)&&/^[A-Za-z0-9._/-]+$/.test(e)}var Se=S().trim().min(1).max(500).refine(e=>P(e)!==null,{message:`Use ${N}.`}),Ce=S().trim().refine(F,{message:`Use a branch, tag or commit SHA, such as main.`}),we=x({repo:S().min(1).max(500),ref:S().min(1).max(256)}).strict();x({repo:Se,ref:Ce.optional()}).strict(),we.extend({enabled:y()}).strict();var Te=_([`refused-format`,`fetch-failed`,`ref-not-found`]),Ee=v(`state`,[x({state:b(`idle`)}),x({state:b(`loading`)}),x({state:b(`ok`),skillCount:h().int().min(0)}),x({state:b(`error`),cause:Te,detail:S(),skillCount:h().int().min(0)})]);x({sources:g(x({repo:S(),ref:S(),enabled:y(),status:Ee})),editable:y(),configIssue:S().nullable()});var I=()=>[i(),`skills`,`sources`];async function De(e){return m(await d.api.v1.p[`:projectId`].skills.sources.$get({param:{projectId:i()}},u(e)),`/skills/sources`)}async function Oe(e){return m(await d.api.v1.p[`:projectId`].skills.sources.$post({param:{projectId:i()},json:e}),`/skills/sources`)}async function ke(e){return m(await d.api.v1.p[`:projectId`].skills.sources.$patch({param:{projectId:i()},json:e}),`/skills/sources`)}async function Ae(e){return m(await d.api.v1.p[`:projectId`].skills.sources.$delete({param:{projectId:i()},json:e}),`/skills/sources`)}async function je(e){return m(await d.api.v1.p[`:projectId`].skills.sources.retry.$post({param:{projectId:i()},json:e}),`/skills/sources/retry`)}var L=c(),Me=1e3,R=e=>`${e.repo} @ ${e.ref}`;function Ne(){return re({queryKey:I(),queryFn:({signal:e})=>De({signal:e}),refetchInterval:e=>e.state.data?.sources.some(e=>e.status.state===`loading`)?Me:!1})}function Pe(){return{sources:I(),lists:[E.skills,E.skillsReady,E.importableSkills,E.importableSkillsReady]}}function z(e,t=Pe()){for(let n of t.lists)e.invalidateQueries({queryKey:n,exact:!0})}function B(e,t){let n=l();return w({mutationFn:async t=>{let n=Pe();return{answer:await e(t),keys:n}},onSuccess:({answer:e,keys:r},i)=>{n.setQueryData(r.sources,e),n.invalidateQueries({queryKey:r.sources,exact:!0}),z(n,r),t?.(i)},onError:e=>D(e.message,{tone:`danger`})})}function Fe(e){let t=l(),n=(0,M.useRef)(!1),r=e?.sources.some(e=>e.status.state===`loading`)??!1;(0,M.useEffect)(()=>{n.current&&!r&&z(t),n.current=r},[r,t])}function Ie(){let e=Ne();Fe(e.data);let t=B(ke),i=B(Ae,e=>D(`Removed ${R(e)}. Add it again to restore its skill switches.`)),o=B(je),s=e.data,c=s?.editable===!0&&s.configIssue===null,l=t.isPending||i.isPending;return(0,L.jsxs)(`section`,{"data-slot":`skill-sources`,"aria-labelledby":`skill-sources-heading`,className:`flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-3 @min-[520px]:p-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{id:`skill-sources-heading`,className:`text-[15px] font-semibold`,children:`Team skill sources`}),(0,L.jsxs)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:[`Repos whose skills this project can use. Changes are saved to`,` `,(0,L.jsx)(`span`,{className:`font-mono`,children:`.ai/cezar/config.json`}),`.`]})]}),e.isError?(0,L.jsxs)(V,{slot:`skill-sources-error`,alert:!0,children:[`Could not load the team skill sources: `,e.error.message,` `,(0,L.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,className:`mt-2 min-h-11`,disabled:e.isFetching,onClick:()=>void e.refetch(),children:`Retry`})]}):null,s?.configIssue?(0,L.jsx)(V,{slot:`skill-sources-config-issue`,alert:!0,children:s.configIssue}):null,s&&!s.editable?(0,L.jsxs)(V,{slot:`skill-sources-read-only`,children:[`Sources are read-only on this remote cockpit. To edit them here, run`,` `,(0,L.jsxs)(`span`,{className:`font-mono`,children:[n(),` remote-settings enable`]}),` on the machine running `,r(`cezar`),`.`]}):null,e.isPending?(0,L.jsx)(`p`,{role:`status`,"aria-busy":`true`,className:`text-xs text-muted-foreground`,children:`Loading sources…`}):s&&s.configIssue===null&&s.sources.length===0?(0,L.jsx)(`p`,{"data-slot":`skill-sources-empty`,className:`text-xs leading-relaxed text-soft-foreground`,children:`No team skill sources yet. Add a repo below to use its skills in this project.`}):s&&s.sources.length>0?(0,L.jsx)(`ul`,{"data-slot":`skill-source-list`,className:`flex flex-col divide-y divide-border rounded-lg border border-border`,children:s.sources.map(e=>(0,L.jsx)(Le,{source:e,editable:c,busy:l,retrying:o.isPending,onToggle:()=>t.mutate({repo:e.repo,ref:e.ref,enabled:!e.enabled}),onRemove:()=>i.mutate({repo:e.repo,ref:e.ref}),onRetry:()=>o.mutate({repo:e.repo,ref:e.ref})},JSON.stringify([e.repo,e.ref])))}):null,s?(0,L.jsx)(Ve,{disabled:!c}):null]})}function V({slot:e,alert:t=!1,children:n}){return(0,L.jsxs)(`div`,{role:t?`alert`:void 0,"data-slot":e,className:`flex items-start gap-2 rounded-lg border border-border bg-background p-3 text-xs leading-relaxed text-muted-foreground`,children:[t?(0,L.jsx)(k,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-danger`}):null,(0,L.jsx)(`div`,{className:`min-w-0 break-words`,children:n})]})}function Le({source:e,editable:t,busy:n,retrying:r,onToggle:i,onRemove:o,onRetry:s}){let c=(0,M.useId)(),l=Re(e),u=e.status.state===`error`,d=e.enabled&&(u||e.status.state===`idle`);return(0,L.jsxs)(`li`,{"data-slot":`skill-source`,"data-repo":e.repo,"data-ref":e.ref,"data-state":e.enabled?e.status.state:`disabled`,className:`flex flex-col gap-2 p-2.5 @min-[520px]:flex-row @min-[520px]:items-center`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`p`,{className:`break-all font-mono text-[13px] text-foreground`,children:[e.repo,` `,(0,L.jsxs)(`span`,{className:`text-muted-foreground`,children:[`@ `,e.ref]})]}),(0,L.jsx)(`p`,{id:c,"data-slot":`skill-source-status`,role:u?`alert`:void 0,"aria-live":u?void 0:`polite`,className:u?`mt-1 text-xs leading-relaxed text-danger`:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:l})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[d?(0,L.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`skill-source-retry`,className:`min-h-11`,disabled:!t||r,"aria-label":`Retry ${R(e)}`,onClick:s,children:[(0,L.jsx)(O,{"aria-hidden":`true`}),`Retry`]}):null,(0,L.jsx)(`span`,{className:`inline-flex min-h-11 min-w-11 items-center justify-center`,children:(0,L.jsx)(ye,{"data-slot":`skill-source-switch`,"aria-label":`Enable ${R(e)}`,"aria-describedby":c,checked:e.enabled,disabled:!t||n,onCheckedChange:i,className:`relative before:absolute before:-inset-x-1 before:-inset-y-2.5 before:content-['']`})}),(0,L.jsx)(a,{type:`button`,variant:`ghost`,size:`icon`,"data-slot":`skill-source-remove`,className:`size-11`,disabled:!t||n,"aria-label":`Remove ${R(e)}`,onClick:o,children:(0,L.jsx)(le,{"aria-hidden":`true`})})]})]})}function Re(e){if(!e.enabled)return`Disabled. Its skills are hidden from the catalog and from tasks.`;let t=e.status;switch(t.state){case`loading`:return`Fetching…`;case`idle`:return`Not fetched yet. Use Retry to fetch it now.`;case`ok`:return t.skillCount===1?`1 skill`:`${t.skillCount} skills`;case`error`:{let e=t.skillCount>0?` Skills from an earlier fetch still show.`:``;return t.cause===`refused-format`?`${r(`cezar`)} does not accept this repo format. Remove it, then add it as ${N}.`:t.cause===`ref-not-found`?`${t.detail} Check the ref, or remove the source and add it with another ref.${e}`:`Could not fetch: ${ze(t.detail)} Check the network and your access to the repo, then Retry.${e}`}}}var ze=e=>/[.!?]$/.test(e.trim())?e.trim():`${e.trim()}.`;function Be(e,t){return e.trim()?P(e)===null?`Use ${N}.`:t.trim()&&!F(t.trim())?`Use a branch, tag or commit SHA for the ref, such as main.`:null:`Enter a repo.`}function Ve({disabled:e}){let[t,n]=(0,M.useState)(``),[r,i]=(0,M.useState)(``),[o,s]=(0,M.useState)(null),c=(0,M.useId)(),l=(0,M.useId)(),u=(0,M.useId)(),d=B(Oe,()=>{n(``),i(``)});return(0,L.jsxs)(`form`,{"data-slot":`skill-source-add`,"aria-label":`Add a team skill source`,noValidate:!0,onSubmit:e=>{e.preventDefault();let n=Be(t,r);s(n),!n&&d.mutate(r.trim()?{repo:t.trim(),ref:r.trim()}:{repo:t.trim()})},className:`flex flex-col gap-2 @min-[520px]:flex-row @min-[520px]:flex-wrap @min-[520px]:items-end`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,L.jsx)(`label`,{htmlFor:c,className:`text-xs font-medium`,children:`Repo`}),(0,L.jsx)(A,{id:c,"data-slot":`skill-source-repo`,value:t,placeholder:`owner/name`,autoComplete:`off`,spellCheck:!1,disabled:e,"aria-invalid":o?!0:void 0,"aria-describedby":o?u:void 0,onChange:e=>{n(e.target.value),s(null)},className:`h-11 font-mono text-[13px]`})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-1 @min-[520px]:w-36`,children:[(0,L.jsx)(`label`,{htmlFor:l,className:`text-xs font-medium`,children:`Ref`}),(0,L.jsx)(A,{id:l,"data-slot":`skill-source-ref`,value:r,placeholder:`main`,autoComplete:`off`,spellCheck:!1,disabled:e,onChange:e=>{i(e.target.value),s(null)},className:`h-11 font-mono text-[13px]`})]}),(0,L.jsx)(a,{type:`submit`,"data-slot":`skill-source-submit`,className:`h-11`,disabled:e||d.isPending,children:`Add source`}),o?(0,L.jsx)(`p`,{id:u,role:`alert`,"data-slot":`skill-source-problem`,className:`text-xs text-danger @min-[520px]:basis-full`,children:o}):null]})}var He=[[`.ai`,`cezar`,`skills`],[`.ai`,`squawk`,`skills`],[`.ai`,`skills`],[`.claude`,`skills`],[`.agents`,`skills`],[`skills`]];function Ue(e){let t=e.split(`/`).slice(0,-1);if((e===`SKILL.md`||e.endsWith(`/SKILL.md`)||t.at(-1)===`commands`)&&t.pop(),t[0]===`plugins`&&t[1])return{kind:`plugin`,name:t[1]};for(let e of He){let n=We(t,e);if(n!==-1&&(e.length>1||n===t.length-1)){t.splice(n,e.length);break}}return t.length>0?{kind:`directory`,name:t.join(`/`)}:null}function We(e,t){for(let n=e.length-t.length;n>=0;n--)if(t.every((t,r)=>e[n+r]===t))return n;return-1}var H=[{id:`project`,label:`This project`,sources:new Set([`ai`,`cezar`,`agents`])},{id:`global`,label:`Global`,sources:new Set([`global`])},{id:`builtin`,label:`Built-in`,sources:new Set([`builtin`])}],U=(e,t,n,r)=>({key:e,label:t,kind:n,locked:r,items:[],children:[]});function Ge(e){let t=H.map(e=>U(`source\u0000${e.id}`,e.label,`source`,!0)),n=new Map;for(let r of e){let{skill:e}=r;if(!e.team){let n=H.findIndex(t=>t.sources.has(e.source));t[n===-1?0:n].items.push(r);continue}let{repo:i,path:a}=e.team,o=n.get(i);o||(o=U(`repo\u0000${i}`,i,`repo`,!1),n.set(i,o));let s=Ue(a);if(!s){o.items.push(r);continue}let c=`${o.key}\u0000${s.kind}\u0000${s.name}`,l=o.children.find(e=>e.key===c);l||(l=U(c,s.name,s.kind,!1),o.children.push(l)),l.items.push(r)}for(let e of n.values())e.children.sort((e,t)=>e.label.localeCompare(t.label));let r=[...n.values()].sort((e,t)=>e.label.localeCompare(t.label));return[t[0],...r,t[1],t[2]].filter(e=>e.items.length>0||e.children.length>0)}function W(e){return e.flatMap(e=>[e.key,...W(e.children)])}function G(e){return[...e.items,...e.children.flatMap(G)]}function Ke(e,t){let n=G(e);if(e.locked)return{enabled:n.length,total:n.length,state:`on`,refs:[]};let r=[],i=0;for(let{skill:e}of n)e.team&&(r.push({repo:e.team.repo,name:e.name}),t(e)&&i++);let a=i===0?`off`:i===r.length?`on`:`mixed`;return{enabled:i,total:r.length,state:a,refs:r}}function K(e,t){if(t.trim()===``)return null;let n=new Set,r=(e,i)=>{let a=[...i,e.label];for(let{skill:r,key:i}of e.items){let e=[r.description??``,...a].join(` `);de(r.name,e,t)>0&&n.add(i)}for(let t of e.children)r(t,a)};for(let t of e)r(t,[]);return n}function q(e,t){let n=[],r=(e,i)=>{let a=[...i,e.key],o=e.items.some(e=>t.has(e.key));o&&n.push(...a.filter(e=>!n.includes(e)));for(let t of e.children)o=r(t,a)||o;return o};for(let t of e)r(t,[]);return n}function J(e){let t=e?.disabledTeamSkills;if(!Array.isArray(t))return[];let n=[];for(let e of t){let t=C.safeParse(e);t.success&&n.push(t.data)}return n}var Y=(e,t)=>e.repo===t.repo&&e.name===t.name;function X(e){return e.team?{repo:e.team.repo,name:e.name}:void 0}function qe(e,t,n){let r=new Map;for(let e of t)r.has(e.name)||r.set(e.name,e);let i=[],a=new Set;for(let t of e){let e=X(t);if(!e)continue;let o=JSON.stringify([e.repo,e.name]);if(a.has(o))continue;a.add(o);let s=n(e),c=r.get(t.name),l=c?X(c):void 0;s&&c&&!(l&&Y(l,e))?i.push({skill:t,on:s,hiddenBy:c.team?.repo??c.source}):i.push({skill:t,on:s})}return i}var Z=new Map;function Je(e){let t=Z.get(e);return t||(t={chain:Promise.resolve(),latest:0},Z.set(e,t)),t}function Ye(e){let t=l(),n=T(e),[r,i]=M.useState(0),a=M.useMemo(()=>J(n.data),[n.data]),o=M.useCallback(e=>!a.some(t=>Y(t,e)),[a]),s=M.useCallback(n=>{let r=[e,`ui-state`],a=[e,`skills`],o=t.getQueryData(r),s=n(J(o));t.setQueryData(r,{...o,disabledTeamSkills:s});let c=Je(e),l=++c.latest;i(e=>e+1),c.chain=c.chain.then(async()=>{try{let n=await p({disabledTeamSkills:s},e);l===c.latest&&(t.setQueryData(r,n),t.invalidateQueries({queryKey:a}))}catch(e){D(e instanceof Error?e.message:String(e),{tone:`danger`}),l===c.latest&&t.invalidateQueries({queryKey:r})}finally{i(e=>e-1)}})},[e,t]);return{disabled:a,isOn:o,toggle:M.useCallback(e=>{let t={repo:e.repo,name:e.name};s(e=>e.some(e=>Y(e,t))?e.filter(e=>!Y(e,t)):[...e,t])},[s]),setMany:M.useCallback((e,t)=>{let n=e.map(e=>({repo:e.repo,name:e.name}));s(e=>{if(t)return e.filter(e=>!n.some(t=>Y(e,t)));let r=[...e];for(let e of n)r.some(t=>Y(t,e))||r.push(e);return r})},[s]),pending:r>0,ready:n.isSuccess}}var Q=`__bm`,Xe=`__import`,$=e=>e.team?`${e.team.repo}\u0000${e.name}`:e.path,Ze=e=>e.source!==`team`&&e.source!==`builtin`;function Qe(){return(0,L.jsx)(`div`,{"data-route":`skills`,className:`mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:(0,L.jsx)($e,{})})}function $e(){let e=ne(),n=te(),r=ee(),[a]=t(),[o,s]=(0,M.useState)(``),c=Ye(i()),l=et(),u=(0,M.useMemo)(()=>e.data??[],[e.data]),d=(0,M.useMemo)(()=>r.data??[],[r.data]),f=r.isSuccess,p=(0,M.useMemo)(()=>tt(u,f?d:null,c.isOn),[u,d,f,c.isOn]),m=(0,M.useMemo)(()=>Ge(p),[p]),h=new Map;for(let e of p)h.set(e.skill.name,(h.get(e.skill.name)??0)+1);let g=e=>(h.get(e.name)??0)>1&&e.team!==void 0,_=e=>{let t=X(e);return t&&f?c.isOn(t):!0},v=e=>{let t=X(e);return t?{ariaLabel:g(e)?`Enable ${e.name} from ${t.repo}`:`Enable ${e.name}`,checked:_(e),disabled:!f||!c.ready,locked:!1,onCheckedChange:()=>c.toggle(t)}:{ariaLabel:`${e.name} is always enabled`,checked:!0,disabled:!0,locked:!0,onCheckedChange:()=>{}}},y=e=>`/skills?skill=${encodeURIComponent(e.name)}${g(e)?`&repo=${encodeURIComponent(e.team.repo)}`:``}`,b=a.get(`skill`),x=nt(p,b,a.get(`repo`),_)?.key??null,S=rt(m,x),C=e=>{s(e);let t=K(m,e);t&&t.size>0&&S.open(q(m,t))};if(e.isError)return(0,L.jsx)(he,{icon:(0,L.jsx)(k,{}),tone:`danger`,heading:`h2`,title:`Could not load skills`,subtitle:e.error.message});let w=b===Q,T=e.isPending?[]:it({tree:m,matches:K(m,o),isOpen:S.isOpen,onFold:S.toggle,openKey:x,workflows:n.data?.workflows??[],activationFor:v,linkFor:y,groupActivationFor:e=>Ke(e,_),switchable:f&&c.ready,onActivate:c.setMany});return(0,L.jsxs)(`div`,{"data-slot":`skills-section`,className:`@container flex min-w-0 flex-col gap-[22px]`,children:[(0,L.jsxs)(`header`,{className:`flex flex-col gap-4 @min-[700px]:flex-row @min-[700px]:items-center @min-[700px]:justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-[25px] font-semibold md:text-[30px]`,children:`Skills`}),(0,L.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground md:text-[13px]`,children:`Markdown playbooks your agents can follow.`})]}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,L.jsxs)(j,{to:w?`/skills`:`/skills?skill=${Q}`,"data-slot":`bookmarklets-row`,"aria-current":w?`page`:void 0,"aria-expanded":w,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium aria-[current=page]:bg-accent-strong/10 hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,L.jsx)(se,{"aria-hidden":`true`,className:`size-4 text-link-foreground`}),`Run from GitHub`]})})]}),w?(0,L.jsx)(`section`,{"data-slot":`skills-bookmarklets`,className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:(0,L.jsx)(ge,{skills:p.filter(e=>_(e.skill)&&!e.hiddenBy).map(e=>e.skill)})}):null,(0,L.jsx)(Ie,{}),(0,L.jsx)(ot,{query:o,onQuery:C,refreshing:l.isPending,onRefresh:()=>l.mutate(),onFoldAll:S.setAll}),(0,L.jsxs)(`section`,{"data-slot":`skills-list`,"aria-label":`Skills`,className:`flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-2 @min-[520px]:p-3`,children:[r.isError?(0,L.jsx)(st,{message:r.error.message,retrying:r.isFetching,onRetry:()=>void r.refetch()}):null,(0,L.jsx)(`div`,{"data-slot":`skill-rows`,className:`min-h-0 overflow-y-auto md:max-h-[calc(100dvh-260px)]`,children:e.isPending?(0,L.jsx)(`p`,{role:`status`,"aria-busy":`true`,className:`min-h-72 p-3 text-[13px] text-muted-foreground`,children:`Loading skills…`}):T.length>0?(0,L.jsxs)(`table`,{"data-slot":`skills-table`,className:`w-full table-fixed border-collapse text-left`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-border text-[12px] text-muted-foreground`,children:[(0,L.jsx)(`th`,{scope:`col`,className:`px-2 py-2 font-semibold`,children:`Skill / group`}),(0,L.jsx)(`th`,{scope:`col`,className:`hidden w-[30%] px-2 py-2 font-semibold @min-[520px]:table-cell`,children:`Used by`}),(0,L.jsx)(`th`,{scope:`col`,className:`w-[116px] px-2 py-2 text-right font-semibold`,children:`Enabled`})]})}),(0,L.jsx)(`tbody`,{children:T})]}):(0,L.jsx)(`p`,{className:`px-2.5 py-2 text-xs leading-relaxed text-soft-foreground`,children:p.length>0?`(no skills match)`:(0,L.jsx)(be,{})})})]})]})}function et(){let e=l();return w({mutationFn:()=>f(),onSuccess:t=>{e.setQueryData(E.skills,t),e.invalidateQueries({queryKey:E.importableSkills}),D(`Team skills refreshed.`)},onError:e=>D(e.message,{tone:`danger`})})}function tt(e,t,n){let r=new Set(e.filter(Ze).map(e=>e.name)),i=t?qe(t.filter(e=>!r.has(e.name)),e,n):[],a=(e,t)=>({skill:e,key:$(e),...t?{hiddenBy:t}:{}}),o=new Set((t??[]).map($)),s=[...e.filter(e=>e.source!==`team`||!o.has($(e))).map(e=>a(e)),...i.map(e=>a(e.skill,e.on?e.hiddenBy:void 0))].sort((e,t)=>e.skill.name.localeCompare(t.skill.name)),c=new Map(s.map(e=>[e.skill,e]));return pe(s.map(e=>e.skill)).map(e=>c.get(e))}function nt(e,t,n,r){if(t===null||t===Q)return null;if(t===Xe)return e.find(e=>!r(e.skill))??null;let i=e.filter(e=>e.skill.name===t);return i.find(e=>n===null||e.skill.team?.repo===n)??i[0]??null}function rt(e,t){let[n,r]=(0,M.useState)({}),i=e=>r(t=>({...t,...Object.fromEntries(e.map(e=>[e,!0]))})),a=t?q(e,new Set([t])).join(``):``;return(0,M.useEffect)(()=>{a&&r(e=>({...e,...Object.fromEntries(a.split(``).map(e=>[e,!0]))}))},[a]),{isOpen:(e,t)=>n[e.key]??t===0,toggle:(e,t)=>r(n=>({...n,[e]:t})),open:i,setAll:t=>r(Object.fromEntries(W(e).map(e=>[e,t])))}}function it(e){let t=[],n=t=>e.matches===null||e.matches.has(t.key),r=e=>e.items.some(n)||e.children.some(r),i=(a,o)=>{if(!r(a))return;let s=e.isOpen(a,o);if(t.push((0,L.jsx)(ut,{node:a,depth:o,open:s,onFold:()=>e.onFold(a.key,!s),activation:e.groupActivationFor(a),switchable:e.switchable,onActivate:e.onActivate},a.key)),s){for(let r of a.items.filter(n)){let n=r.key===e.openKey,i=me(e.workflows,r.skill.name),a=e.activationFor(r.skill);t.push((0,L.jsx)(ft,{item:r,depth:o+1,href:n?`/skills`:e.linkFor(r.skill),expanded:n,usedBy:i,activation:a},r.key)),n&&t.push((0,L.jsx)(at,{skill:r.skill,usedBy:i,activation:a},`${r.key}\u0000detail`))}for(let e of a.children)i(e,o+1)}};for(let t of e.tree)i(t,0);return t}function at({skill:e,usedBy:t,activation:n}){return(0,L.jsx)(`tr`,{"data-slot":`skill-detail-row`,children:(0,L.jsx)(`td`,{colSpan:3,className:`border-b border-border px-3 pb-5 @min-[520px]:px-5`,children:(0,L.jsx)(`div`,{"data-slot":`skills-detail`,className:`min-w-0 rounded-lg border border-border bg-background p-4 md:p-5`,children:(0,L.jsx)(ve,{skill:e,usedBy:t,activation:n})})})})}function ot({query:e,onQuery:t,refreshing:n,onRefresh:r,onFoldAll:i}){return(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsxs)(`div`,{className:`sw-search relative min-w-0 basis-full sm:basis-auto sm:flex-1`,children:[(0,L.jsx)(ae,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,L.jsx)(A,{"data-slot":`skills-filter`,placeholder:`Filter skills…`,"aria-label":`Filter skills`,value:e,onChange:e=>t(e.target.value),className:`h-11 min-w-0 bg-card pl-9 text-xs`})]}),(0,L.jsxs)(`button`,{type:`button`,"data-slot":`skills-refresh`,title:`git fetch the team skills repos`,disabled:n,onClick:r,className:`flex h-11 shrink-0 items-center gap-1.5 rounded-md border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-55`,children:[(0,L.jsx)(O,{"aria-hidden":`true`,className:o(`size-3`,n&&`motion-safe:animate-spin`)}),n?`Refreshing…`:`Refresh`]}),(0,L.jsx)(a,{type:`button`,variant:`outline`,"data-slot":`skills-expand-all`,className:`h-11 text-xs`,onClick:()=>i(!0),children:`Expand groups`}),(0,L.jsx)(a,{type:`button`,variant:`outline`,"data-slot":`skills-collapse-all`,className:`h-11 text-xs`,onClick:()=>i(!1),children:`Collapse groups`})]})}function st({message:e,retrying:t,onRetry:n}){return(0,L.jsxs)(`div`,{role:`alert`,"data-slot":`skills-importable-error`,className:`flex flex-col items-start gap-2 rounded-lg border border-border bg-background p-3 text-xs text-muted-foreground`,children:[(0,L.jsxs)(`span`,{children:[`Could not load the team skills, so they cannot be switched right now. Your saved choice is kept.`,` `,e]}),(0,L.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,className:`min-h-11`,disabled:t,onClick:n,children:`Retry`})]})}var ct={repo:`repository`,plugin:`plugin`,directory:`directory`},lt=e=>({paddingInlineStart:`${e*16}px`});function ut({node:e,depth:t,open:n,onFold:r,activation:i,switchable:a,onActivate:s}){let c=n?ue:oe,l=ct[e.kind],u=e.locked||a;return(0,L.jsxs)(`tr`,{"data-slot":`skill-group-row`,"data-group":e.label,"data-kind":e.kind,"data-level":t,className:o(`border-b border-border`,t===0&&`bg-muted/40`),children:[(0,L.jsx)(`th`,{scope:`row`,className:`min-w-0 p-0 text-left font-normal`,children:(0,L.jsx)(`span`,{className:`flex min-w-0`,style:lt(t),children:(0,L.jsxs)(`button`,{type:`button`,"data-slot":`skill-group-toggle`,"aria-expanded":n,onClick:r,className:`flex min-h-11 min-w-0 flex-1 items-center gap-2 rounded-md px-2 text-left hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-link-foreground`,children:[(0,L.jsx)(c,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),(0,L.jsx)(`span`,{className:o(`min-w-0 [overflow-wrap:anywhere]`,t===0?`text-[13px] font-semibold`:`text-[13px] font-medium`),children:e.label}),l?(0,L.jsx)(`span`,{className:`shrink-0 text-[12px] text-soft-foreground`,children:l}):null]})})}),(0,L.jsx)(`td`,{"aria-hidden":`true`,className:`hidden @min-[520px]:table-cell`}),(0,L.jsx)(`td`,{className:`px-1 py-0 text-right`,children:(0,L.jsxs)(`span`,{className:`inline-flex items-center justify-end gap-1`,children:[(0,L.jsx)(`span`,{"data-slot":`skill-group-count`,className:`text-[12px] tabular-nums text-muted-foreground`,children:u?`${i.enabled} / ${i.total}`:`—`}),(0,L.jsx)(dt,{label:e.label,locked:e.locked,state:u?i.state:null,disabled:e.locked||!a||i.total===0,onClick:()=>s(i.refs,i.state!==`on`)})]})})]})}function dt({label:e,locked:t,state:n,disabled:r,onClick:i}){return(0,L.jsx)(`button`,{type:`button`,role:`checkbox`,"data-slot":`skill-group-switch`,"data-state":n??`unknown`,"aria-checked":n===null?void 0:n===`mixed`?`mixed`:n===`on`,"aria-busy":n===null||void 0,"aria-label":t?`${e} skills are always enabled`:`Enable all skills in ${e}`,disabled:r,onClick:i,className:`group/check inline-flex size-11 shrink-0 items-center justify-center rounded-md focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-link-foreground disabled:cursor-default`,children:(0,L.jsx)(`span`,{"aria-hidden":`true`,className:o(`inline-flex size-5 items-center justify-center rounded border-2 transition-colors`,n===`on`||n===`mixed`?`border-accent-strong bg-accent-strong text-accent-strong-foreground`:`border-muted-foreground bg-card text-transparent`,n===null&&`border-dashed border-soft-foreground`,`group-disabled/check:opacity-60`),children:n===`mixed`?(0,L.jsx)(ie,{className:`size-3.5`}):(0,L.jsx)(ce,{className:`size-3.5`})})})}function ft({item:e,depth:t,href:n,expanded:r,usedBy:i,activation:a}){let{skill:s,hiddenBy:c}=e,l=fe(s),u=[...new Set(i.map(e=>e.split(` › `)[0]))];return(0,L.jsxs)(`tr`,{"data-slot":`skill-table-row`,className:o(`border-b border-border`,r&&`border-transparent`),children:[(0,L.jsx)(`td`,{className:`min-w-0 p-0`,style:lt(t),children:(0,L.jsxs)(j,{to:n,"data-slot":`skill-row`,"data-skill":s.name,"data-repo":s.team?.repo,"data-project":l?`true`:void 0,"data-enabled":a.checked?`true`:void 0,"aria-current":r?`page`:void 0,"aria-expanded":r,className:o(`selection-row flex min-h-11 min-w-0 flex-col justify-center gap-1 rounded-md px-3 py-2 transition-colors hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-link-foreground`,r&&`bg-accent-strong/10`),children:[(0,L.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:(0,L.jsx)(`span`,{className:o(`min-w-0 break-words text-[13px]`,l?`font-semibold text-foreground`:`font-normal text-muted-foreground`),children:s.name})}),s.description?(0,L.jsx)(`span`,{className:`line-clamp-1 text-xs leading-relaxed text-supporting-foreground`,children:s.description}):null,u.length>0?(0,L.jsxs)(`span`,{"data-slot":`skill-used-by-inline`,className:`text-xs text-supporting-foreground @min-[520px]:hidden`,children:[`Used by `,u.join(`, `)]}):null,c?(0,L.jsxs)(`span`,{"data-slot":`skill-hidden-by`,className:`min-w-0 text-xs text-supporting-foreground [overflow-wrap:anywhere]`,children:[`hidden by `,c]}):null]})}),(0,L.jsx)(`td`,{"data-slot":`skill-used-by-cell`,className:`hidden px-2 py-2 align-middle text-xs text-supporting-foreground @min-[520px]:table-cell`,children:u.length>0?(0,L.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:u.join(`, `)}):(0,L.jsx)(`span`,{className:`text-soft-foreground`,children:`—`})}),(0,L.jsx)(`td`,{className:`px-1 py-0 text-right align-middle`,children:(0,L.jsx)(`span`,{className:`inline-flex justify-end`,children:(0,L.jsx)(_e,{skill:s,activation:a})})})]})}export{Qe as SkillsRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{D as t,I as n,L as r,M as i,t as a,u as o}from"./button-CS5tOblf.js";import{i as s,t as c}from"./react-runtime-CCIEwYL0.js";import{Kr as l,Rt as u,f as d,on as f,tn as p,wn as m}from"./project-scope-context-DSkcNKO7.js";import{$ as h,J as g,K as _,X as v,Y as y,Z as b,et as x,rt as S,z as C}from"./live-protocol-DBPXI6ks.js";import{$t as w,I as ee,Rt as te,Z as T,jt as ne,n as E}from"./queries-D2MPDhtr.js";import{t as re}from"./useQuery-8pHkglP4.js";import{n as D}from"./toaster-CRVRHlMR.js";import{G as ie,Q as ae,Z as O,ct as k,d as oe,ht as se,l as ce,mt as le,u as ue}from"./design-icons-DmYTv2r1.js";import{t as A}from"./input-DIwJvCgi.js";import{t as j}from"./project-router-BFKfAFvq.js";import{c as de,i as fe,o as pe,p as me}from"./skills-DFBiAuJG.js";import{t as he}from"./centered-state-BmsqxbI8.js";import{$ as ge,I as _e,P as ve,en as ye}from"./index-s7PhnzDS.js";import{t as be}from"./skill-empty-hint-YDmkqgo-.js";var M=e(s(),1),N=`owner/name, an https, ssh or git URL, git@host:path, or a local or file:// path`,xe=new Set([`https`,`http`,`ssh`,`git`,`file`]);function P(e){let t=e.trim();if(!t||t.startsWith(`-`)||t.includes(`::`))return null;if(t.startsWith(`~/`))return`home`;if(/^(\/|\.\/|\.\.\/)/.test(t)||/^[A-Za-z]:[\\/]/.test(t))return`local`;if(/^[\w.-]+\/[\w.-]+$/.test(t))return`github`;let n=/^([a-z][a-z0-9+.-]*):\/\//i.exec(t);return n?xe.has(n[1].toLowerCase())?`url`:null:/^[\w.-]+@[\w.-]+:/.test(t)?`scp`:null}function F(e){return e.length>0&&e.length<=256&&!e.startsWith(`-`)&&!e.includes(`..`)&&/^[A-Za-z0-9._/-]+$/.test(e)}var Se=S().trim().min(1).max(500).refine(e=>P(e)!==null,{message:`Use ${N}.`}),Ce=S().trim().refine(F,{message:`Use a branch, tag or commit SHA, such as main.`}),we=x({repo:S().min(1).max(500),ref:S().min(1).max(256)}).strict();x({repo:Se,ref:Ce.optional()}).strict(),we.extend({enabled:y()}).strict();var Te=_([`refused-format`,`fetch-failed`,`ref-not-found`]),Ee=v(`state`,[x({state:b(`idle`)}),x({state:b(`loading`)}),x({state:b(`ok`),skillCount:h().int().min(0)}),x({state:b(`error`),cause:Te,detail:S(),skillCount:h().int().min(0)})]);x({sources:g(x({repo:S(),ref:S(),enabled:y(),status:Ee})),editable:y(),configIssue:S().nullable()});var I=()=>[i(),`skills`,`sources`];async function De(e){return m(await d.api.v1.p[`:projectId`].skills.sources.$get({param:{projectId:i()}},u(e)),`/skills/sources`)}async function Oe(e){return m(await d.api.v1.p[`:projectId`].skills.sources.$post({param:{projectId:i()},json:e}),`/skills/sources`)}async function ke(e){return m(await d.api.v1.p[`:projectId`].skills.sources.$patch({param:{projectId:i()},json:e}),`/skills/sources`)}async function Ae(e){return m(await d.api.v1.p[`:projectId`].skills.sources.$delete({param:{projectId:i()},json:e}),`/skills/sources`)}async function je(e){return m(await d.api.v1.p[`:projectId`].skills.sources.retry.$post({param:{projectId:i()},json:e}),`/skills/sources/retry`)}var L=c(),Me=1e3,R=e=>`${e.repo} @ ${e.ref}`;function Ne(){return re({queryKey:I(),queryFn:({signal:e})=>De({signal:e}),refetchInterval:e=>e.state.data?.sources.some(e=>e.status.state===`loading`)?Me:!1})}function Pe(){return{sources:I(),lists:[E.skills,E.skillsReady,E.importableSkills,E.importableSkillsReady]}}function z(e,t=Pe()){for(let n of t.lists)e.invalidateQueries({queryKey:n,exact:!0})}function B(e,t){let n=l();return w({mutationFn:async t=>{let n=Pe();return{answer:await e(t),keys:n}},onSuccess:({answer:e,keys:r},i)=>{n.setQueryData(r.sources,e),n.invalidateQueries({queryKey:r.sources,exact:!0}),z(n,r),t?.(i)},onError:e=>D(e.message,{tone:`danger`})})}function Fe(e){let t=l(),n=(0,M.useRef)(!1),r=e?.sources.some(e=>e.status.state===`loading`)??!1;(0,M.useEffect)(()=>{n.current&&!r&&z(t),n.current=r},[r,t])}function Ie(){let e=Ne();Fe(e.data);let t=B(ke),i=B(Ae,e=>D(`Removed ${R(e)}. Add it again to restore its skill switches.`)),o=B(je),s=e.data,c=s?.editable===!0&&s.configIssue===null,l=t.isPending||i.isPending;return(0,L.jsxs)(`section`,{"data-slot":`skill-sources`,"aria-labelledby":`skill-sources-heading`,className:`flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-3 @min-[520px]:p-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{id:`skill-sources-heading`,className:`text-[15px] font-semibold`,children:`Team skill sources`}),(0,L.jsxs)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:[`Repos whose skills this project can use. Changes are saved to`,` `,(0,L.jsx)(`span`,{className:`font-mono`,children:`.ai/cezar/config.json`}),`.`]})]}),e.isError?(0,L.jsxs)(V,{slot:`skill-sources-error`,alert:!0,children:[`Could not load the team skill sources: `,e.error.message,` `,(0,L.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,className:`mt-2 min-h-11`,disabled:e.isFetching,onClick:()=>void e.refetch(),children:`Retry`})]}):null,s?.configIssue?(0,L.jsx)(V,{slot:`skill-sources-config-issue`,alert:!0,children:s.configIssue}):null,s&&!s.editable?(0,L.jsxs)(V,{slot:`skill-sources-read-only`,children:[`Sources are read-only on this remote cockpit. To edit them here, run`,` `,(0,L.jsxs)(`span`,{className:`font-mono`,children:[n(),` remote-settings enable`]}),` on the machine running `,r(`cezar`),`.`]}):null,e.isPending?(0,L.jsx)(`p`,{role:`status`,"aria-busy":`true`,className:`text-xs text-muted-foreground`,children:`Loading sources…`}):s&&s.configIssue===null&&s.sources.length===0?(0,L.jsx)(`p`,{"data-slot":`skill-sources-empty`,className:`text-xs leading-relaxed text-soft-foreground`,children:`No team skill sources yet. Add a repo below to use its skills in this project.`}):s&&s.sources.length>0?(0,L.jsx)(`ul`,{"data-slot":`skill-source-list`,className:`flex flex-col divide-y divide-border rounded-lg border border-border`,children:s.sources.map(e=>(0,L.jsx)(Le,{source:e,editable:c,busy:l,retrying:o.isPending,onToggle:()=>t.mutate({repo:e.repo,ref:e.ref,enabled:!e.enabled}),onRemove:()=>i.mutate({repo:e.repo,ref:e.ref}),onRetry:()=>o.mutate({repo:e.repo,ref:e.ref})},JSON.stringify([e.repo,e.ref])))}):null,s?(0,L.jsx)(Ve,{disabled:!c}):null]})}function V({slot:e,alert:t=!1,children:n}){return(0,L.jsxs)(`div`,{role:t?`alert`:void 0,"data-slot":e,className:`flex items-start gap-2 rounded-lg border border-border bg-background p-3 text-xs leading-relaxed text-muted-foreground`,children:[t?(0,L.jsx)(k,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-danger`}):null,(0,L.jsx)(`div`,{className:`min-w-0 break-words`,children:n})]})}function Le({source:e,editable:t,busy:n,retrying:r,onToggle:i,onRemove:o,onRetry:s}){let c=(0,M.useId)(),l=Re(e),u=e.status.state===`error`,d=e.enabled&&(u||e.status.state===`idle`);return(0,L.jsxs)(`li`,{"data-slot":`skill-source`,"data-repo":e.repo,"data-ref":e.ref,"data-state":e.enabled?e.status.state:`disabled`,className:`flex flex-col gap-2 p-2.5 @min-[520px]:flex-row @min-[520px]:items-center`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`p`,{className:`break-all font-mono text-[13px] text-foreground`,children:[e.repo,` `,(0,L.jsxs)(`span`,{className:`text-muted-foreground`,children:[`@ `,e.ref]})]}),(0,L.jsx)(`p`,{id:c,"data-slot":`skill-source-status`,role:u?`alert`:void 0,"aria-live":u?void 0:`polite`,className:u?`mt-1 text-xs leading-relaxed text-danger`:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:l})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[d?(0,L.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`skill-source-retry`,className:`min-h-11`,disabled:!t||r,"aria-label":`Retry ${R(e)}`,onClick:s,children:[(0,L.jsx)(O,{"aria-hidden":`true`}),`Retry`]}):null,(0,L.jsx)(`span`,{className:`inline-flex min-h-11 min-w-11 items-center justify-center`,children:(0,L.jsx)(ye,{"data-slot":`skill-source-switch`,"aria-label":`Enable ${R(e)}`,"aria-describedby":c,checked:e.enabled,disabled:!t||n,onCheckedChange:i,className:`relative before:absolute before:-inset-x-1 before:-inset-y-2.5 before:content-['']`})}),(0,L.jsx)(a,{type:`button`,variant:`ghost`,size:`icon`,"data-slot":`skill-source-remove`,className:`size-11`,disabled:!t||n,"aria-label":`Remove ${R(e)}`,onClick:o,children:(0,L.jsx)(le,{"aria-hidden":`true`})})]})]})}function Re(e){if(!e.enabled)return`Disabled. Its skills are hidden from the catalog and from tasks.`;let t=e.status;switch(t.state){case`loading`:return`Fetching…`;case`idle`:return`Not fetched yet. Use Retry to fetch it now.`;case`ok`:return t.skillCount===1?`1 skill`:`${t.skillCount} skills`;case`error`:{let e=t.skillCount>0?` Skills from an earlier fetch still show.`:``;return t.cause===`refused-format`?`${r(`cezar`)} does not accept this repo format. Remove it, then add it as ${N}.`:t.cause===`ref-not-found`?`${t.detail} Check the ref, or remove the source and add it with another ref.${e}`:`Could not fetch: ${ze(t.detail)} Check the network and your access to the repo, then Retry.${e}`}}}var ze=e=>/[.!?]$/.test(e.trim())?e.trim():`${e.trim()}.`;function Be(e,t){return e.trim()?P(e)===null?`Use ${N}.`:t.trim()&&!F(t.trim())?`Use a branch, tag or commit SHA for the ref, such as main.`:null:`Enter a repo.`}function Ve({disabled:e}){let[t,n]=(0,M.useState)(``),[r,i]=(0,M.useState)(``),[o,s]=(0,M.useState)(null),c=(0,M.useId)(),l=(0,M.useId)(),u=(0,M.useId)(),d=B(Oe,()=>{n(``),i(``)});return(0,L.jsxs)(`form`,{"data-slot":`skill-source-add`,"aria-label":`Add a team skill source`,noValidate:!0,onSubmit:e=>{e.preventDefault();let n=Be(t,r);s(n),!n&&d.mutate(r.trim()?{repo:t.trim(),ref:r.trim()}:{repo:t.trim()})},className:`flex flex-col gap-2 @min-[520px]:flex-row @min-[520px]:flex-wrap @min-[520px]:items-end`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,L.jsx)(`label`,{htmlFor:c,className:`text-xs font-medium`,children:`Repo`}),(0,L.jsx)(A,{id:c,"data-slot":`skill-source-repo`,value:t,placeholder:`owner/name`,autoComplete:`off`,spellCheck:!1,disabled:e,"aria-invalid":o?!0:void 0,"aria-describedby":o?u:void 0,onChange:e=>{n(e.target.value),s(null)},className:`h-11 font-mono text-[13px]`})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-1 @min-[520px]:w-36`,children:[(0,L.jsx)(`label`,{htmlFor:l,className:`text-xs font-medium`,children:`Ref`}),(0,L.jsx)(A,{id:l,"data-slot":`skill-source-ref`,value:r,placeholder:`main`,autoComplete:`off`,spellCheck:!1,disabled:e,onChange:e=>{i(e.target.value),s(null)},className:`h-11 font-mono text-[13px]`})]}),(0,L.jsx)(a,{type:`submit`,"data-slot":`skill-source-submit`,className:`h-11`,disabled:e||d.isPending,children:`Add source`}),o?(0,L.jsx)(`p`,{id:u,role:`alert`,"data-slot":`skill-source-problem`,className:`text-xs text-danger @min-[520px]:basis-full`,children:o}):null]})}var He=[[`.ai`,`cezar`,`skills`],[`.ai`,`squawk`,`skills`],[`.ai`,`skills`],[`.claude`,`skills`],[`.agents`,`skills`],[`skills`]];function Ue(e){let t=e.split(`/`).slice(0,-1);if((e===`SKILL.md`||e.endsWith(`/SKILL.md`)||t.at(-1)===`commands`)&&t.pop(),t[0]===`plugins`&&t[1])return{kind:`plugin`,name:t[1]};for(let e of He){let n=We(t,e);if(n!==-1&&(e.length>1||n===t.length-1)){t.splice(n,e.length);break}}return t.length>0?{kind:`directory`,name:t.join(`/`)}:null}function We(e,t){for(let n=e.length-t.length;n>=0;n--)if(t.every((t,r)=>e[n+r]===t))return n;return-1}var H=[{id:`project`,label:`This project`,sources:new Set([`ai`,`cezar`,`agents`])},{id:`global`,label:`Global`,sources:new Set([`global`])},{id:`builtin`,label:`Built-in`,sources:new Set([`builtin`])}],U=(e,t,n,r)=>({key:e,label:t,kind:n,locked:r,items:[],children:[]});function Ge(e){let t=H.map(e=>U(`source\u0000${e.id}`,e.label,`source`,!0)),n=new Map;for(let r of e){let{skill:e}=r;if(!e.team){let n=H.findIndex(t=>t.sources.has(e.source));t[n===-1?0:n].items.push(r);continue}let{repo:i,path:a}=e.team,o=n.get(i);o||(o=U(`repo\u0000${i}`,i,`repo`,!1),n.set(i,o));let s=Ue(a);if(!s){o.items.push(r);continue}let c=`${o.key}\u0000${s.kind}\u0000${s.name}`,l=o.children.find(e=>e.key===c);l||(l=U(c,s.name,s.kind,!1),o.children.push(l)),l.items.push(r)}for(let e of n.values())e.children.sort((e,t)=>e.label.localeCompare(t.label));let r=[...n.values()].sort((e,t)=>e.label.localeCompare(t.label));return[t[0],...r,t[1],t[2]].filter(e=>e.items.length>0||e.children.length>0)}function W(e){return e.flatMap(e=>[e.key,...W(e.children)])}function G(e){return[...e.items,...e.children.flatMap(G)]}function Ke(e,t){let n=G(e);if(e.locked)return{enabled:n.length,total:n.length,state:`on`,refs:[]};let r=[],i=0;for(let{skill:e}of n)e.team&&(r.push({repo:e.team.repo,name:e.name}),t(e)&&i++);let a=i===0?`off`:i===r.length?`on`:`mixed`;return{enabled:i,total:r.length,state:a,refs:r}}function K(e,t){if(t.trim()===``)return null;let n=new Set,r=(e,i)=>{let a=[...i,e.label];for(let{skill:r,key:i}of e.items){let e=[r.description??``,...a].join(` `);de(r.name,e,t)>0&&n.add(i)}for(let t of e.children)r(t,a)};for(let t of e)r(t,[]);return n}function q(e,t){let n=[],r=(e,i)=>{let a=[...i,e.key],o=e.items.some(e=>t.has(e.key));o&&n.push(...a.filter(e=>!n.includes(e)));for(let t of e.children)o=r(t,a)||o;return o};for(let t of e)r(t,[]);return n}function J(e){let t=e?.disabledTeamSkills;if(!Array.isArray(t))return[];let n=[];for(let e of t){let t=C.safeParse(e);t.success&&n.push(t.data)}return n}var Y=(e,t)=>e.repo===t.repo&&e.name===t.name;function X(e){return e.team?{repo:e.team.repo,name:e.name}:void 0}function qe(e,t,n){let r=new Map;for(let e of t)r.has(e.name)||r.set(e.name,e);let i=[],a=new Set;for(let t of e){let e=X(t);if(!e)continue;let o=JSON.stringify([e.repo,e.name]);if(a.has(o))continue;a.add(o);let s=n(e),c=r.get(t.name),l=c?X(c):void 0;s&&c&&!(l&&Y(l,e))?i.push({skill:t,on:s,hiddenBy:c.team?.repo??c.source}):i.push({skill:t,on:s})}return i}var Z=new Map;function Je(e){let t=Z.get(e);return t||(t={chain:Promise.resolve(),latest:0},Z.set(e,t)),t}function Ye(e){let t=l(),n=T(e),[r,i]=M.useState(0),a=M.useMemo(()=>J(n.data),[n.data]),o=M.useCallback(e=>!a.some(t=>Y(t,e)),[a]),s=M.useCallback(n=>{let r=[e,`ui-state`],a=[e,`skills`],o=t.getQueryData(r),s=n(J(o));t.setQueryData(r,{...o,disabledTeamSkills:s});let c=Je(e),l=++c.latest;i(e=>e+1),c.chain=c.chain.then(async()=>{try{let n=await p({disabledTeamSkills:s},e);l===c.latest&&(t.setQueryData(r,n),t.invalidateQueries({queryKey:a}))}catch(e){D(e instanceof Error?e.message:String(e),{tone:`danger`}),l===c.latest&&t.invalidateQueries({queryKey:r})}finally{i(e=>e-1)}})},[e,t]);return{disabled:a,isOn:o,toggle:M.useCallback(e=>{let t={repo:e.repo,name:e.name};s(e=>e.some(e=>Y(e,t))?e.filter(e=>!Y(e,t)):[...e,t])},[s]),setMany:M.useCallback((e,t)=>{let n=e.map(e=>({repo:e.repo,name:e.name}));s(e=>{if(t)return e.filter(e=>!n.some(t=>Y(e,t)));let r=[...e];for(let e of n)r.some(t=>Y(t,e))||r.push(e);return r})},[s]),pending:r>0,ready:n.isSuccess}}var Q=`__bm`,Xe=`__import`,$=e=>e.team?`${e.team.repo}\u0000${e.name}`:e.path,Ze=e=>e.source!==`team`&&e.source!==`builtin`;function Qe(){return(0,L.jsx)(`div`,{"data-route":`skills`,className:`mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:(0,L.jsx)($e,{})})}function $e(){let e=ne(),n=te(),r=ee(),[a]=t(),[o,s]=(0,M.useState)(``),c=Ye(i()),l=et(),u=(0,M.useMemo)(()=>e.data??[],[e.data]),d=(0,M.useMemo)(()=>r.data??[],[r.data]),f=r.isSuccess,p=(0,M.useMemo)(()=>tt(u,f?d:null,c.isOn),[u,d,f,c.isOn]),m=(0,M.useMemo)(()=>Ge(p),[p]),h=new Map;for(let e of p)h.set(e.skill.name,(h.get(e.skill.name)??0)+1);let g=e=>(h.get(e.name)??0)>1&&e.team!==void 0,_=e=>{let t=X(e);return t&&f?c.isOn(t):!0},v=e=>{let t=X(e);return t?{ariaLabel:g(e)?`Enable ${e.name} from ${t.repo}`:`Enable ${e.name}`,checked:_(e),disabled:!f||!c.ready,locked:!1,onCheckedChange:()=>c.toggle(t)}:{ariaLabel:`${e.name} is always enabled`,checked:!0,disabled:!0,locked:!0,onCheckedChange:()=>{}}},y=e=>`/skills?skill=${encodeURIComponent(e.name)}${g(e)?`&repo=${encodeURIComponent(e.team.repo)}`:``}`,b=a.get(`skill`),x=nt(p,b,a.get(`repo`),_)?.key??null,S=rt(m,x),C=e=>{s(e);let t=K(m,e);t&&t.size>0&&S.open(q(m,t))};if(e.isError)return(0,L.jsx)(he,{icon:(0,L.jsx)(k,{}),tone:`danger`,heading:`h2`,title:`Could not load skills`,subtitle:e.error.message});let w=b===Q,T=e.isPending?[]:it({tree:m,matches:K(m,o),isOpen:S.isOpen,onFold:S.toggle,openKey:x,workflows:n.data?.workflows??[],activationFor:v,linkFor:y,groupActivationFor:e=>Ke(e,_),switchable:f&&c.ready,onActivate:c.setMany});return(0,L.jsxs)(`div`,{"data-slot":`skills-section`,className:`@container flex min-w-0 flex-col gap-[22px]`,children:[(0,L.jsxs)(`header`,{className:`flex flex-col gap-4 @min-[700px]:flex-row @min-[700px]:items-center @min-[700px]:justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-[25px] font-semibold md:text-[30px]`,children:`Skills`}),(0,L.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground md:text-[13px]`,children:`Markdown playbooks your agents can follow.`})]}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,L.jsxs)(j,{to:w?`/skills`:`/skills?skill=${Q}`,"data-slot":`bookmarklets-row`,"aria-current":w?`page`:void 0,"aria-expanded":w,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium aria-[current=page]:bg-accent-strong/10 hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,L.jsx)(se,{"aria-hidden":`true`,className:`size-4 text-link-foreground`}),`Run from GitHub`]})})]}),w?(0,L.jsx)(`section`,{"data-slot":`skills-bookmarklets`,className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:(0,L.jsx)(ge,{skills:p.filter(e=>_(e.skill)&&!e.hiddenBy).map(e=>e.skill)})}):null,(0,L.jsx)(Ie,{}),(0,L.jsx)(ot,{query:o,onQuery:C,refreshing:l.isPending,onRefresh:()=>l.mutate(),onFoldAll:S.setAll}),(0,L.jsxs)(`section`,{"data-slot":`skills-list`,"aria-label":`Skills`,className:`flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-2 @min-[520px]:p-3`,children:[r.isError?(0,L.jsx)(st,{message:r.error.message,retrying:r.isFetching,onRetry:()=>void r.refetch()}):null,(0,L.jsx)(`div`,{"data-slot":`skill-rows`,className:`min-h-0 overflow-y-auto md:max-h-[calc(100dvh-260px)]`,children:e.isPending?(0,L.jsx)(`p`,{role:`status`,"aria-busy":`true`,className:`min-h-72 p-3 text-[13px] text-muted-foreground`,children:`Loading skills…`}):T.length>0?(0,L.jsxs)(`table`,{"data-slot":`skills-table`,className:`w-full table-fixed border-collapse text-left`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-border text-[12px] text-muted-foreground`,children:[(0,L.jsx)(`th`,{scope:`col`,className:`px-2 py-2 font-semibold`,children:`Skill / group`}),(0,L.jsx)(`th`,{scope:`col`,className:`hidden w-[30%] px-2 py-2 font-semibold @min-[520px]:table-cell`,children:`Used by`}),(0,L.jsx)(`th`,{scope:`col`,className:`w-[116px] px-2 py-2 text-right font-semibold`,children:`Enabled`})]})}),(0,L.jsx)(`tbody`,{children:T})]}):(0,L.jsx)(`p`,{className:`px-2.5 py-2 text-xs leading-relaxed text-soft-foreground`,children:p.length>0?`(no skills match)`:(0,L.jsx)(be,{})})})]})]})}function et(){let e=l();return w({mutationFn:()=>f(),onSuccess:t=>{e.setQueryData(E.skills,t),e.invalidateQueries({queryKey:E.importableSkills}),D(`Team skills refreshed.`)},onError:e=>D(e.message,{tone:`danger`})})}function tt(e,t,n){let r=new Set(e.filter(Ze).map(e=>e.name)),i=t?qe(t.filter(e=>!r.has(e.name)),e,n):[],a=(e,t)=>({skill:e,key:$(e),...t?{hiddenBy:t}:{}}),o=new Set((t??[]).map($)),s=[...e.filter(e=>e.source!==`team`||!o.has($(e))).map(e=>a(e)),...i.map(e=>a(e.skill,e.on?e.hiddenBy:void 0))].sort((e,t)=>e.skill.name.localeCompare(t.skill.name)),c=new Map(s.map(e=>[e.skill,e]));return pe(s.map(e=>e.skill)).map(e=>c.get(e))}function nt(e,t,n,r){if(t===null||t===Q)return null;if(t===Xe)return e.find(e=>!r(e.skill))??null;let i=e.filter(e=>e.skill.name===t);return i.find(e=>n===null||e.skill.team?.repo===n)??i[0]??null}function rt(e,t){let[n,r]=(0,M.useState)({}),i=e=>r(t=>({...t,...Object.fromEntries(e.map(e=>[e,!0]))})),a=t?q(e,new Set([t])).join(``):``;return(0,M.useEffect)(()=>{a&&r(e=>({...e,...Object.fromEntries(a.split(``).map(e=>[e,!0]))}))},[a]),{isOpen:(e,t)=>n[e.key]??t===0,toggle:(e,t)=>r(n=>({...n,[e]:t})),open:i,setAll:t=>r(Object.fromEntries(W(e).map(e=>[e,t])))}}function it(e){let t=[],n=t=>e.matches===null||e.matches.has(t.key),r=e=>e.items.some(n)||e.children.some(r),i=(a,o)=>{if(!r(a))return;let s=e.isOpen(a,o);if(t.push((0,L.jsx)(ut,{node:a,depth:o,open:s,onFold:()=>e.onFold(a.key,!s),activation:e.groupActivationFor(a),switchable:e.switchable,onActivate:e.onActivate},a.key)),s){for(let r of a.items.filter(n)){let n=r.key===e.openKey,i=me(e.workflows,r.skill.name),a=e.activationFor(r.skill);t.push((0,L.jsx)(ft,{item:r,depth:o+1,href:n?`/skills`:e.linkFor(r.skill),expanded:n,usedBy:i,activation:a},r.key)),n&&t.push((0,L.jsx)(at,{skill:r.skill,usedBy:i,activation:a},`${r.key}\u0000detail`))}for(let e of a.children)i(e,o+1)}};for(let t of e.tree)i(t,0);return t}function at({skill:e,usedBy:t,activation:n}){return(0,L.jsx)(`tr`,{"data-slot":`skill-detail-row`,children:(0,L.jsx)(`td`,{colSpan:3,className:`border-b border-border px-3 pb-5 @min-[520px]:px-5`,children:(0,L.jsx)(`div`,{"data-slot":`skills-detail`,className:`min-w-0 rounded-lg border border-border bg-background p-4 md:p-5`,children:(0,L.jsx)(ve,{skill:e,usedBy:t,activation:n})})})})}function ot({query:e,onQuery:t,refreshing:n,onRefresh:r,onFoldAll:i}){return(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsxs)(`div`,{className:`sw-search relative min-w-0 basis-full sm:basis-auto sm:flex-1`,children:[(0,L.jsx)(ae,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,L.jsx)(A,{"data-slot":`skills-filter`,placeholder:`Filter skills…`,"aria-label":`Filter skills`,value:e,onChange:e=>t(e.target.value),className:`h-11 min-w-0 bg-card pl-9 text-xs`})]}),(0,L.jsxs)(`button`,{type:`button`,"data-slot":`skills-refresh`,title:`git fetch the team skills repos`,disabled:n,onClick:r,className:`flex h-11 shrink-0 items-center gap-1.5 rounded-md border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-55`,children:[(0,L.jsx)(O,{"aria-hidden":`true`,className:o(`size-3`,n&&`motion-safe:animate-spin`)}),n?`Refreshing…`:`Refresh`]}),(0,L.jsx)(a,{type:`button`,variant:`outline`,"data-slot":`skills-expand-all`,className:`h-11 text-xs`,onClick:()=>i(!0),children:`Expand groups`}),(0,L.jsx)(a,{type:`button`,variant:`outline`,"data-slot":`skills-collapse-all`,className:`h-11 text-xs`,onClick:()=>i(!1),children:`Collapse groups`})]})}function st({message:e,retrying:t,onRetry:n}){return(0,L.jsxs)(`div`,{role:`alert`,"data-slot":`skills-importable-error`,className:`flex flex-col items-start gap-2 rounded-lg border border-border bg-background p-3 text-xs text-muted-foreground`,children:[(0,L.jsxs)(`span`,{children:[`Could not load the team skills, so they cannot be switched right now. Your saved choice is kept.`,` `,e]}),(0,L.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,className:`min-h-11`,disabled:t,onClick:n,children:`Retry`})]})}var ct={repo:`repository`,plugin:`plugin`,directory:`directory`},lt=e=>({paddingInlineStart:`${e*16}px`});function ut({node:e,depth:t,open:n,onFold:r,activation:i,switchable:a,onActivate:s}){let c=n?ue:oe,l=ct[e.kind],u=e.locked||a;return(0,L.jsxs)(`tr`,{"data-slot":`skill-group-row`,"data-group":e.label,"data-kind":e.kind,"data-level":t,className:o(`border-b border-border`,t===0&&`bg-muted/40`),children:[(0,L.jsx)(`th`,{scope:`row`,className:`min-w-0 p-0 text-left font-normal`,children:(0,L.jsx)(`span`,{className:`flex min-w-0`,style:lt(t),children:(0,L.jsxs)(`button`,{type:`button`,"data-slot":`skill-group-toggle`,"aria-expanded":n,onClick:r,className:`flex min-h-11 min-w-0 flex-1 items-center gap-2 rounded-md px-2 text-left hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-link-foreground`,children:[(0,L.jsx)(c,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),(0,L.jsx)(`span`,{className:o(`min-w-0 [overflow-wrap:anywhere]`,t===0?`text-[13px] font-semibold`:`text-[13px] font-medium`),children:e.label}),l?(0,L.jsx)(`span`,{className:`shrink-0 text-[12px] text-soft-foreground`,children:l}):null]})})}),(0,L.jsx)(`td`,{"aria-hidden":`true`,className:`hidden @min-[520px]:table-cell`}),(0,L.jsx)(`td`,{className:`px-1 py-0 text-right`,children:(0,L.jsxs)(`span`,{className:`inline-flex items-center justify-end gap-1`,children:[(0,L.jsx)(`span`,{"data-slot":`skill-group-count`,className:`text-[12px] tabular-nums text-muted-foreground`,children:u?`${i.enabled} / ${i.total}`:`—`}),(0,L.jsx)(dt,{label:e.label,locked:e.locked,state:u?i.state:null,disabled:e.locked||!a||i.total===0,onClick:()=>s(i.refs,i.state!==`on`)})]})})]})}function dt({label:e,locked:t,state:n,disabled:r,onClick:i}){return(0,L.jsx)(`button`,{type:`button`,role:`checkbox`,"data-slot":`skill-group-switch`,"data-state":n??`unknown`,"aria-checked":n===null?void 0:n===`mixed`?`mixed`:n===`on`,"aria-busy":n===null||void 0,"aria-label":t?`${e} skills are always enabled`:`Enable all skills in ${e}`,disabled:r,onClick:i,className:`group/check inline-flex size-11 shrink-0 items-center justify-center rounded-md focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-link-foreground disabled:cursor-default`,children:(0,L.jsx)(`span`,{"aria-hidden":`true`,className:o(`inline-flex size-5 items-center justify-center rounded border-2 transition-colors`,n===`on`||n===`mixed`?`border-accent-strong bg-accent-strong text-accent-strong-foreground`:`border-muted-foreground bg-card text-transparent`,n===null&&`border-dashed border-soft-foreground`,`group-disabled/check:opacity-60`),children:n===`mixed`?(0,L.jsx)(ie,{className:`size-3.5`}):(0,L.jsx)(ce,{className:`size-3.5`})})})}function ft({item:e,depth:t,href:n,expanded:r,usedBy:i,activation:a}){let{skill:s,hiddenBy:c}=e,l=fe(s),u=[...new Set(i.map(e=>e.split(` › `)[0]))];return(0,L.jsxs)(`tr`,{"data-slot":`skill-table-row`,className:o(`border-b border-border`,r&&`border-transparent`),children:[(0,L.jsx)(`td`,{className:`min-w-0 p-0`,style:lt(t),children:(0,L.jsxs)(j,{to:n,"data-slot":`skill-row`,"data-skill":s.name,"data-repo":s.team?.repo,"data-project":l?`true`:void 0,"data-enabled":a.checked?`true`:void 0,"aria-current":r?`page`:void 0,"aria-expanded":r,className:o(`selection-row flex min-h-11 min-w-0 flex-col justify-center gap-1 rounded-md px-3 py-2 transition-colors hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-link-foreground`,r&&`bg-accent-strong/10`),children:[(0,L.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:(0,L.jsx)(`span`,{className:o(`min-w-0 break-words text-[13px]`,l?`font-semibold text-foreground`:`font-normal text-muted-foreground`),children:s.name})}),s.description?(0,L.jsx)(`span`,{className:`line-clamp-1 text-xs leading-relaxed text-supporting-foreground`,children:s.description}):null,u.length>0?(0,L.jsxs)(`span`,{"data-slot":`skill-used-by-inline`,className:`text-xs text-supporting-foreground @min-[520px]:hidden`,children:[`Used by `,u.join(`, `)]}):null,c?(0,L.jsxs)(`span`,{"data-slot":`skill-hidden-by`,className:`min-w-0 text-xs text-supporting-foreground [overflow-wrap:anywhere]`,children:[`hidden by `,c]}):null]})}),(0,L.jsx)(`td`,{"data-slot":`skill-used-by-cell`,className:`hidden px-2 py-2 align-middle text-xs text-supporting-foreground @min-[520px]:table-cell`,children:u.length>0?(0,L.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:u.join(`, `)}):(0,L.jsx)(`span`,{className:`text-soft-foreground`,children:`—`})}),(0,L.jsx)(`td`,{className:`px-1 py-0 text-right align-middle`,children:(0,L.jsx)(`span`,{className:`inline-flex justify-end`,children:(0,L.jsx)(_e,{skill:s,activation:a})})})]})}export{Qe as SkillsRoute};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{E as t,t as n}from"./button-CS5tOblf.js";import{i as r,t as i}from"./react-runtime-CCIEwYL0.js";import{Ct as a,Kr as o,Kt as s,Qt as c,Wt as l,gn as u,h as d,i as f,w as p}from"./project-scope-context-DSkcNKO7.js";import{$t as m,P as h,_t as g,dt as _,gt as v,n as y}from"./queries-D2MPDhtr.js";import{R as b,q as x}from"./popover-G6KGT-qq.js";import{n as S}from"./toaster-CRVRHlMR.js";import{M as C,w}from"./design-icons-DmYTv2r1.js";import{t as T}from"./run-header-JJRW4anN.js";import{i as E,n as D,r as O}from"./git-toolbar-CyP2nq4z.js";import{a as k,i as A,o as j,r as M,s as N,t as P}from"./dialog-Dw7fMdDQ.js";import{t as F}from"./centered-state-BmsqxbI8.js";import{D as I,Dt as L,E as R,Y as z,et as B,yt as V}from"./index-aewNqo85.js";import{t as H}from"./markdown-BBDDg-4t.js";import{t as U}from"./diff-hym46LSx.js";var W=e(r(),1),G=e=>e===`running`||e===`queued`||e===`waiting`,K=`no worktree — this task ran directly in the repo working tree`;function q(e){let t=e=>({id:`commit`,label:`Commit`,enabled:!1,reason:e});return e.hasWorktree?e.status===`running`?t(`Commit unavailable — the agent is still working in this worktree`):e.changedFiles===void 0?t(`Commit unavailable — changes are still loading`):e.changedFiles===0?t(`Commit unavailable — no changes to commit`):{id:`commit`,label:`Commit`,enabled:!0}:t(`Commit unavailable — ${K}`)}function J(e){let t=e=>({id:`push`,label:`Push`,enabled:!1,reason:e});return e.hasWorktree?e.remote===void 0?t(`Push unavailable — no remote configured`):e.branch===void 0?t(`Push unavailable — the run has no branch to push`):e.status===`running`?t(`Push unavailable — the agent is still working in this worktree`):{id:`push`,label:`Push`,enabled:!0}:t(`Push unavailable — ${K}`)}function Y(e){let t=e=>({id:`create-pr`,label:`Create PR`,enabled:!1,reason:e});return!e.hasWorktree||e.branch===void 0?t(`Create PR unavailable — ${K}`):e.forge===null?t(`Create PR unavailable — no supported forge remote (GitHub) detected`):e.forge.available?G(e.status)?t(`Create PR unavailable — the run is still active; wait for the review gate`):{id:`create-pr`,label:`Create PR`,enabled:!0}:t(`Create PR unavailable — ${e.forge.reason??`the forge is unreachable`}`)}function X(e){let t=e.prUrl?{id:`view-pr`,label:`View PR`,enabled:!0,href:e.prUrl}:q(e),n=e.prUrl?[q(e),J(e)]:[J(e),Y(e)],r=[];if(e.localHandoff){let t=e.hasSession?G(e.status)?{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — the session is still active in the engine`}:{id:`open-terminal`,label:`Open in terminal`,enabled:!0}:{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — no agent session to resume`};r.push(t)}return{primary:t,secondary:n,menu:r}}var Z=i();function Q({run:e,open:t,onOpenChange:r}){let i=o(),[a,s]=(0,W.useState)(``),c=b(e),l=(0,W.useRef)(c);l.current=c,(0,W.useEffect)(()=>{t&&s(l.current)},[t]);let u=m({mutationFn:t=>d(e.id,t),onSuccess:t=>{S(`Committed ${t.sha.slice(0,7)}`),r(!1),i.invalidateQueries({queryKey:y.runs.changes(e.id)}),i.invalidateQueries({queryKey:y.runs.all})},onError:e=>S(e.message,{tone:`danger`})}),f=()=>{let e=a.trim();e.length===0||u.isPending||u.mutate(e)};return(0,Z.jsx)(P,{open:t,onOpenChange:r,children:(0,Z.jsxs)(M,{"data-slot":`commit-dialog`,children:[(0,Z.jsxs)(j,{children:[(0,Z.jsx)(N,{children:`Commit changes`}),(0,Z.jsxs)(A,{children:[`Stages everything in the task's worktree (git add -A) and commits to`,` `,e.branch?(0,Z.jsx)(`span`,{className:`font-mono`,children:e.branch}):`its branch`,`.`]})]}),(0,Z.jsx)(B,{"data-slot":`commit-message`,"aria-label":`Commit message`,rows:3,value:a,onChange:e=>s(e.target.value),onKeyDown:e=>{z({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())}}),(0,Z.jsxs)(k,{children:[(0,Z.jsx)(n,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,Z.jsx)(n,{"data-slot":`commit-confirm`,disabled:a.trim().length===0||u.isPending,onClick:f,children:u.isPending?`Committing…`:`Commit`})]})]})})}function $(){let{id:e}=t(),n=v(e);return n.isPending?(0,Z.jsx)(I,{tab:`changes`}):n.isError?(0,Z.jsx)(R,{tab:`changes`,error:n.error}):(0,Z.jsx)(ee,{run:n.data})}function ee({run:e}){let t=h(),n=_(),r=g(e.id,x(e)),i=V(),[a,u]=(0,W.useState)(`unified`),[d,v]=(0,W.useState)(!1),[b,C]=(0,W.useState)(!1),[w,E]=(0,W.useState)(null),[k,A]=(0,W.useState)(!1),j=(0,W.useRef)(null),M=o(),N=()=>M.invalidateQueries({queryKey:y.runs.all}),P=e=>S(e.message,{tone:`danger`}),F=m({mutationFn:()=>c(e.id),onSuccess:e=>S(e.upstreamSet?`Pushed ${e.branch} to ${e.remote} (upstream set)`:`Pushed ${e.branch} to ${e.remote}`),onError:P}),I=m({mutationFn:()=>p(e.id),onSuccess:e=>{S(`Draft PR created — ${e.url}`),N()},onError:P}),R=m({mutationFn:()=>s(e.id),onError:e=>{if(e instanceof f&&e.command){navigator.clipboard.writeText(e.command).then(()=>S(`No terminal found — command copied to clipboard.`)).catch(()=>S(`Run manually: ${e.command}`));return}P(e)}}),z=m({mutationFn:t=>l(e.id,t),onError:P}),B=r.isError&&r.error instanceof f&&r.error.status===409,U=X({status:e.status,hasWorktree:!!e.worktreePath&&!B,branch:e.branch,changedFiles:r.data?.stat.files,remote:n.data?.info?.remote,forge:t.data?.forge??null,localHandoff:t.data?.capabilities.localHandoff??!1,hasSession:L(e)!==void 0,prUrl:e.pullRequestUrl}),G=e=>{switch(e){case`commit`:A(!0);break;case`push`:F.mutate();break;case`create-pr`:I.mutate();break;case`open-terminal`:R.mutate();break;case`view-pr`:break}},K=r.data?.files??[],q=(0,W.useMemo)(()=>O(K),[K]),J=(0,W.useMemo)(()=>K.some(H),[K]),Y=i?a:`unified`,$=!i||d;return(0,Z.jsxs)(`div`,{"data-route":`task-changes`,className:`flex min-h-full flex-col`,children:[(0,Z.jsx)(T,{run:e,tab:`changes`}),(0,Z.jsx)(D,{bar:U,healthReady:t.data!==void 0,branch:e.branch,stat:r.data?.stat,mode:Y,wrap:$,preview:b,onModeChange:u,onWrapChange:v,onPreviewChange:J?C:void 0,onAction:G}),r.data?.repointedHead?(0,Z.jsxs)(`p`,{"data-slot":`repointed-head-note`,className:`border-b px-4 py-2 text-xs text-soft-foreground md:px-9`,children:[`HEAD is on `,(0,Z.jsx)(`code`,{children:r.data.repointedHead.headBranch}),`, not this task's branch`,` `,(0,Z.jsx)(`code`,{children:r.data.repointedHead.taskBranch}),` — showing only what this task changed there.`]}):null,(0,Z.jsx)(te,{changes:r,changesRefused:B,fileCount:K.length,children:(0,Z.jsx)(ne,{runId:e.id,files:K,tree:q,selected:w,selectFile:e=>{E(e),j.current?.scrollToPath(e)},diffRef:j,effectiveMode:Y,effectiveWrap:$,preview:b,localHandoff:t.data?.capabilities.localHandoff,onOpenInApp:z.mutate})}),(0,Z.jsx)(Q,{run:e,open:k,onOpenChange:A})]})}function te({changes:e,changesRefused:t,fileCount:n,children:r}){return e.isPending?(0,Z.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):e.isError?(0,Z.jsx)(F,{icon:t?(0,Z.jsx)(w,{size:16}):(0,Z.jsx)(C,{size:16}),tone:t?`neutral`:`danger`,heading:`h2`,title:t?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):n===0?(0,Z.jsx)(F,{icon:(0,Z.jsx)(w,{size:16}),tone:`neutral`,heading:`h2`,title:`No changes yet`,subtitle:`The worktree matches its base branch. Changes appear here as the agent works.`}):r}function ne({runId:e,files:t,tree:n,selected:r,selectFile:i,diffRef:a,effectiveMode:o,effectiveWrap:s,preview:c,localHandoff:l,onOpenInApp:d}){return(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:0px] md:[--diff-sticky-top:1rem] md:px-9`,children:[(0,Z.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 md:block lg:w-[250px]`,children:[(0,Z.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,Z.jsx)(E,{root:n,selected:r,onSelect:i})]}),(0,Z.jsx)(U,{files:t,viewRef:a,mode:o,wrap:s,preview:c,loadFileText:t=>re(e,t),imageSrc:t=>u(e,t),onOpenInApp:l?e=>d(e):void 0,className:`min-w-0 flex-1`})]})}async function re(e,t){try{let n=await a(e,t);return n.type!==`file`||n.binary||n.tooLarge?null:n.content??null}catch{return null}}export{$ as TaskChangesRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{E as t,t as n}from"./button-CS5tOblf.js";import{i as r,t as i}from"./react-runtime-CCIEwYL0.js";import{Ct as a,Kr as o,Kt as s,Qt as c,Wt as l,gn as u,h as d,i as f,w as p}from"./project-scope-context-DSkcNKO7.js";import{$t as m,P as h,_t as g,dt as _,gt as v,n as y}from"./queries-D2MPDhtr.js";import{R as b,q as x}from"./popover-G6KGT-qq.js";import{n as S}from"./toaster-CRVRHlMR.js";import{M as C,w}from"./design-icons-DmYTv2r1.js";import{t as T}from"./run-header-Dc5892Cu.js";import{i as E,n as D,r as O}from"./git-toolbar-CZAj0VNk.js";import{a as k,i as A,o as j,r as M,s as N,t as P}from"./dialog-Dw7fMdDQ.js";import{t as F}from"./centered-state-BmsqxbI8.js";import{D as I,Dt as L,E as R,Y as z,et as B,yt as V}from"./index-s7PhnzDS.js";import{t as H}from"./markdown-BBDDg-4t.js";import{t as U}from"./diff-D81T6FlH.js";var W=e(r(),1),G=e=>e===`running`||e===`queued`||e===`waiting`,K=`no worktree — this task ran directly in the repo working tree`;function q(e){let t=e=>({id:`commit`,label:`Commit`,enabled:!1,reason:e});return e.hasWorktree?e.status===`running`?t(`Commit unavailable — the agent is still working in this worktree`):e.changedFiles===void 0?t(`Commit unavailable — changes are still loading`):e.changedFiles===0?t(`Commit unavailable — no changes to commit`):{id:`commit`,label:`Commit`,enabled:!0}:t(`Commit unavailable — ${K}`)}function J(e){let t=e=>({id:`push`,label:`Push`,enabled:!1,reason:e});return e.hasWorktree?e.remote===void 0?t(`Push unavailable — no remote configured`):e.branch===void 0?t(`Push unavailable — the run has no branch to push`):e.status===`running`?t(`Push unavailable — the agent is still working in this worktree`):{id:`push`,label:`Push`,enabled:!0}:t(`Push unavailable — ${K}`)}function Y(e){let t=e=>({id:`create-pr`,label:`Create PR`,enabled:!1,reason:e});return!e.hasWorktree||e.branch===void 0?t(`Create PR unavailable — ${K}`):e.forge===null?t(`Create PR unavailable — no supported forge remote (GitHub) detected`):e.forge.available?G(e.status)?t(`Create PR unavailable — the run is still active; wait for the review gate`):{id:`create-pr`,label:`Create PR`,enabled:!0}:t(`Create PR unavailable — ${e.forge.reason??`the forge is unreachable`}`)}function X(e){let t=e.prUrl?{id:`view-pr`,label:`View PR`,enabled:!0,href:e.prUrl}:q(e),n=e.prUrl?[q(e),J(e)]:[J(e),Y(e)],r=[];if(e.localHandoff){let t=e.hasSession?G(e.status)?{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — the session is still active in the engine`}:{id:`open-terminal`,label:`Open in terminal`,enabled:!0}:{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — no agent session to resume`};r.push(t)}return{primary:t,secondary:n,menu:r}}var Z=i();function Q({run:e,open:t,onOpenChange:r}){let i=o(),[a,s]=(0,W.useState)(``),c=b(e),l=(0,W.useRef)(c);l.current=c,(0,W.useEffect)(()=>{t&&s(l.current)},[t]);let u=m({mutationFn:t=>d(e.id,t),onSuccess:t=>{S(`Committed ${t.sha.slice(0,7)}`),r(!1),i.invalidateQueries({queryKey:y.runs.changes(e.id)}),i.invalidateQueries({queryKey:y.runs.all})},onError:e=>S(e.message,{tone:`danger`})}),f=()=>{let e=a.trim();e.length===0||u.isPending||u.mutate(e)};return(0,Z.jsx)(P,{open:t,onOpenChange:r,children:(0,Z.jsxs)(M,{"data-slot":`commit-dialog`,children:[(0,Z.jsxs)(j,{children:[(0,Z.jsx)(N,{children:`Commit changes`}),(0,Z.jsxs)(A,{children:[`Stages everything in the task's worktree (git add -A) and commits to`,` `,e.branch?(0,Z.jsx)(`span`,{className:`font-mono`,children:e.branch}):`its branch`,`.`]})]}),(0,Z.jsx)(B,{"data-slot":`commit-message`,"aria-label":`Commit message`,rows:3,value:a,onChange:e=>s(e.target.value),onKeyDown:e=>{z({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())}}),(0,Z.jsxs)(k,{children:[(0,Z.jsx)(n,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,Z.jsx)(n,{"data-slot":`commit-confirm`,disabled:a.trim().length===0||u.isPending,onClick:f,children:u.isPending?`Committing…`:`Commit`})]})]})})}function $(){let{id:e}=t(),n=v(e);return n.isPending?(0,Z.jsx)(I,{tab:`changes`}):n.isError?(0,Z.jsx)(R,{tab:`changes`,error:n.error}):(0,Z.jsx)(ee,{run:n.data})}function ee({run:e}){let t=h(),n=_(),r=g(e.id,x(e)),i=V(),[a,u]=(0,W.useState)(`unified`),[d,v]=(0,W.useState)(!1),[b,C]=(0,W.useState)(!1),[w,E]=(0,W.useState)(null),[k,A]=(0,W.useState)(!1),j=(0,W.useRef)(null),M=o(),N=()=>M.invalidateQueries({queryKey:y.runs.all}),P=e=>S(e.message,{tone:`danger`}),F=m({mutationFn:()=>c(e.id),onSuccess:e=>S(e.upstreamSet?`Pushed ${e.branch} to ${e.remote} (upstream set)`:`Pushed ${e.branch} to ${e.remote}`),onError:P}),I=m({mutationFn:()=>p(e.id),onSuccess:e=>{S(`Draft PR created — ${e.url}`),N()},onError:P}),R=m({mutationFn:()=>s(e.id),onError:e=>{if(e instanceof f&&e.command){navigator.clipboard.writeText(e.command).then(()=>S(`No terminal found — command copied to clipboard.`)).catch(()=>S(`Run manually: ${e.command}`));return}P(e)}}),z=m({mutationFn:t=>l(e.id,t),onError:P}),B=r.isError&&r.error instanceof f&&r.error.status===409,U=X({status:e.status,hasWorktree:!!e.worktreePath&&!B,branch:e.branch,changedFiles:r.data?.stat.files,remote:n.data?.info?.remote,forge:t.data?.forge??null,localHandoff:t.data?.capabilities.localHandoff??!1,hasSession:L(e)!==void 0,prUrl:e.pullRequestUrl}),G=e=>{switch(e){case`commit`:A(!0);break;case`push`:F.mutate();break;case`create-pr`:I.mutate();break;case`open-terminal`:R.mutate();break;case`view-pr`:break}},K=r.data?.files??[],q=(0,W.useMemo)(()=>O(K),[K]),J=(0,W.useMemo)(()=>K.some(H),[K]),Y=i?a:`unified`,$=!i||d;return(0,Z.jsxs)(`div`,{"data-route":`task-changes`,className:`flex min-h-full flex-col`,children:[(0,Z.jsx)(T,{run:e,tab:`changes`}),(0,Z.jsx)(D,{bar:U,healthReady:t.data!==void 0,branch:e.branch,stat:r.data?.stat,mode:Y,wrap:$,preview:b,onModeChange:u,onWrapChange:v,onPreviewChange:J?C:void 0,onAction:G}),r.data?.repointedHead?(0,Z.jsxs)(`p`,{"data-slot":`repointed-head-note`,className:`border-b px-4 py-2 text-xs text-soft-foreground md:px-9`,children:[`HEAD is on `,(0,Z.jsx)(`code`,{children:r.data.repointedHead.headBranch}),`, not this task's branch`,` `,(0,Z.jsx)(`code`,{children:r.data.repointedHead.taskBranch}),` — showing only what this task changed there.`]}):null,(0,Z.jsx)(te,{changes:r,changesRefused:B,fileCount:K.length,children:(0,Z.jsx)(ne,{runId:e.id,files:K,tree:q,selected:w,selectFile:e=>{E(e),j.current?.scrollToPath(e)},diffRef:j,effectiveMode:Y,effectiveWrap:$,preview:b,localHandoff:t.data?.capabilities.localHandoff,onOpenInApp:z.mutate})}),(0,Z.jsx)(Q,{run:e,open:k,onOpenChange:A})]})}function te({changes:e,changesRefused:t,fileCount:n,children:r}){return e.isPending?(0,Z.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):e.isError?(0,Z.jsx)(F,{icon:t?(0,Z.jsx)(w,{size:16}):(0,Z.jsx)(C,{size:16}),tone:t?`neutral`:`danger`,heading:`h2`,title:t?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):n===0?(0,Z.jsx)(F,{icon:(0,Z.jsx)(w,{size:16}),tone:`neutral`,heading:`h2`,title:`No changes yet`,subtitle:`The worktree matches its base branch. Changes appear here as the agent works.`}):r}function ne({runId:e,files:t,tree:n,selected:r,selectFile:i,diffRef:a,effectiveMode:o,effectiveWrap:s,preview:c,localHandoff:l,onOpenInApp:d}){return(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:0px] md:[--diff-sticky-top:1rem] md:px-9`,children:[(0,Z.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 md:block lg:w-[250px]`,children:[(0,Z.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,Z.jsx)(E,{root:n,selected:r,onSelect:i})]}),(0,Z.jsx)(U,{files:t,viewRef:a,mode:o,wrap:s,preview:c,loadFileText:t=>re(e,t),imageSrc:t=>u(e,t),onOpenInApp:l?e=>d(e):void 0,className:`min-w-0 flex-1`})]})}async function re(e,t){try{let n=await a(e,t);return n.type!==`file`||n.binary||n.tooLarge?null:n.content??null}catch{return null}}export{$ as TaskChangesRoute};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{E as t,u as n}from"./button-CS5tOblf.js";import{i as r,t as i}from"./react-runtime-CCIEwYL0.js";import{i as a}from"./project-scope-context-DSkcNKO7.js";import{_t as o,gt as s,vt as c,yt as l}from"./queries-D2MPDhtr.js";import{q as u}from"./popover-G6KGT-qq.js";import{C as d,M as f,Q as p,w as m}from"./design-icons-DmYTv2r1.js";import{t as h}from"./run-header-JJRW4anN.js";import{t as g}from"./input-DIwJvCgi.js";import{t as _}from"./project-router-BFKfAFvq.js";import{t as v}from"./centered-state-BmsqxbI8.js";import{D as y,E as b,s as x}from"./index-aewNqo85.js";import{t as S}from"./commit-diff-panel-D6qd0Twy.js";var C=e(r(),1),w=i(),T=77;function E({slot:e,commits:t,className:r,heading:i}){let[a,o]=(0,C.useState)(``),s=a.trim().toLowerCase(),c=s?t.filter(e=>e.subject.toLowerCase().includes(s)):t,l=c.length>150,u=(0,C.useRef)(null),d=(0,C.useRef)(null),[f,m]=(0,C.useState)(0);(0,C.useLayoutEffect)(()=>{if(!l)return;let e=()=>{let e=u.current,t=d.current;!e||!t||m(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[l]);let h=c.map(n=>(0,w.jsx)(D,{commit:n,detailed:e===`task-commits`&&t.length===1},n.sha));return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`label`,{className:`relative mb-[22px] block`,children:[(0,w.jsx)(p,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute top-3.5 left-3 size-4 text-muted-foreground`}),(0,w.jsx)(g,{"aria-label":`Search commit messages`,placeholder:`Search commit messages…`,value:a,onChange:e=>o(e.target.value),className:`h-11 bg-card pl-10`})]}),(0,w.jsxs)(`div`,{ref:e=>{u.current=e,e&&(d.current=e.closest(`[data-slot="main"]`))},"data-slot":e,"data-virtualized":l,className:n(`flex flex-col divide-y divide-border rounded-xl border border-border bg-card px-4 py-1 md:px-5`,r),children:[i?(0,w.jsx)(`div`,{className:`flex min-h-14 flex-wrap items-center gap-2 py-4`,children:i}):null,c.length===0?(0,w.jsx)(`p`,{role:`status`,className:`py-5 text-sm text-muted-foreground`,children:`No loaded commits match your search.`}):null,l?(0,w.jsx)(x,{scrollRef:d,startMargin:f,itemSize:T,children:h}):h]})]})}function D({commit:e,detailed:t}){return(0,w.jsx)(`div`,{className:`[contain-intrinsic-block-size:auto_77px] [content-visibility:auto]`,children:(0,w.jsxs)(_,{"data-slot":`commit-row`,"data-sha":e.sha,to:e.href,className:n(`flex min-h-[76px] min-w-0 flex-col items-start gap-3 rounded-sm py-4 hover:bg-muted`,!t&&`md:flex-row md:items-center md:py-3`),children:[(0,w.jsx)(f,{size:16,"aria-hidden":`true`,className:n(`shrink-0 text-accent-text`,t?`size-[22px]`:`size-4`)}),(0,w.jsxs)(`span`,{className:n(`min-w-0 w-full`,!t&&`md:w-auto md:flex-1`),children:[(0,w.jsx)(`span`,{className:n(`block font-normal`,t?`text-[22px] leading-snug`:`text-[13px] md:truncate`),children:e.subject}),(0,w.jsxs)(`span`,{className:`mt-1 block truncate text-[11px] text-soft-foreground`,children:[e.author,` · `,e.when]})]}),(0,w.jsx)(`span`,{className:`shrink-0 rounded-md bg-muted px-2 py-1 font-mono text-[11px] text-muted-foreground`,children:e.shaLabel}),t?(0,w.jsxs)(`span`,{className:`inline-flex min-h-11 items-center gap-2 rounded-lg bg-action px-3 text-xs font-medium text-action-foreground`,children:[(0,w.jsx)(m,{size:16,"aria-hidden":`true`,className:`size-4`}),`View changes`]}):null]})})}function O(){let{id:e}=t(),n=s(e);return n.isPending?(0,w.jsx)(y,{tab:`changes`}):n.isError?(0,w.jsx)(b,{tab:`changes`,error:n.error}):(0,w.jsx)(k,{run:n.data})}function k({run:e}){let{sha:n}=t(),r=l(e.id,u(e));return(0,w.jsxs)(`div`,{"data-route":`task-commits`,className:`flex min-h-full flex-col`,children:[(0,w.jsx)(h,{run:e,tab:`commits`}),n?(0,w.jsx)(A,{runId:e.id,sha:n}):r.isPending?(0,w.jsx)(`p`,{"data-slot":`commits-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading commits…`}):r.isError?(0,w.jsx)(v,{icon:(0,w.jsx)(f,{size:16}),tone:r.error instanceof a&&r.error.status===409?`neutral`:`danger`,heading:`h2`,title:r.error instanceof a&&r.error.status===409?`No commits to show`:`Could not load the commits`,subtitle:r.error.message}):r.data.commits.length===0?(0,w.jsx)(v,{icon:(0,w.jsx)(f,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`This task hasn't committed anything on its branch. Autosave commits and any the agent makes appear here.`}):(0,w.jsxs)(`div`,{className:`px-[18px] py-[22px] md:px-9`,children:[(0,w.jsx)(E,{slot:`task-commits`,heading:(0,w.jsxs)(`h2`,{className:`text-base font-semibold`,children:[r.data.commits.length,` `,r.data.commits.length===1?`commit`:`commits`,` in this task`]}),className:`w-full`,commits:r.data.commits.map(t=>({...t,shaLabel:t.sha.slice(0,8),href:`/tasks/${e.id}/commits/${t.sha}`}))}),(0,w.jsx)(j,{run:e})]})]})}function A({runId:e,sha:t}){return(0,w.jsx)(S,{commit:c(e,t),sha:t,backTo:`/tasks/${e}/commits`,backLabel:`All commits`,slot:`task-commit`,className:`mx-auto flex min-h-0 w-full max-w-[var(--measure)] flex-1 flex-col`,diffClassName:`px-4 py-4 [--diff-sticky-top:0px] md:[--diff-sticky-top:1rem] md:px-6`})}function j({run:e}){let t=o(e.id,u(e));return t.isPending?(0,w.jsx)(`p`,{className:`mt-[22px] text-xs text-muted-foreground`,children:`Loading changed files…`}):t.isError?(0,w.jsxs)(`p`,{role:`status`,className:`mt-[22px] text-xs text-danger`,children:[`Could not load changed files: `,t.error.message]}):t.data.files.length===0?null:(0,w.jsxs)(`section`,{"data-slot":`task-commit-files`,className:`mt-[22px] rounded-[10px] border border-border bg-card p-5`,children:[(0,w.jsxs)(`h2`,{className:`mb-4 text-[16px] font-semibold`,children:[t.data.files.length,` changed files`]}),(0,w.jsx)(`ul`,{className:`space-y-4`,children:t.data.files.map(t=>(0,w.jsx)(`li`,{children:(0,w.jsxs)(_,{to:`/tasks/${e.id}/changes`,className:`flex min-h-11 items-center gap-2 text-xs text-muted-foreground hover:text-foreground`,children:[(0,w.jsx)(d,{size:16,"aria-hidden":`true`,className:`size-[15px] shrink-0`}),(0,w.jsx)(`span`,{className:`break-all`,children:t.path})]})},t.path))})]})}export{O as TaskCommitsRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{E as t,u as n}from"./button-CS5tOblf.js";import{i as r,t as i}from"./react-runtime-CCIEwYL0.js";import{i as a}from"./project-scope-context-DSkcNKO7.js";import{_t as o,gt as s,vt as c,yt as l}from"./queries-D2MPDhtr.js";import{q as u}from"./popover-G6KGT-qq.js";import{C as d,M as f,Q as p,w as m}from"./design-icons-DmYTv2r1.js";import{t as h}from"./run-header-Dc5892Cu.js";import{t as g}from"./input-DIwJvCgi.js";import{t as _}from"./project-router-BFKfAFvq.js";import{t as v}from"./centered-state-BmsqxbI8.js";import{D as y,E as b,s as x}from"./index-s7PhnzDS.js";import{t as S}from"./commit-diff-panel-DBrsQdXO.js";var C=e(r(),1),w=i(),T=77;function E({slot:e,commits:t,className:r,heading:i}){let[a,o]=(0,C.useState)(``),s=a.trim().toLowerCase(),c=s?t.filter(e=>e.subject.toLowerCase().includes(s)):t,l=c.length>150,u=(0,C.useRef)(null),d=(0,C.useRef)(null),[f,m]=(0,C.useState)(0);(0,C.useLayoutEffect)(()=>{if(!l)return;let e=()=>{let e=u.current,t=d.current;!e||!t||m(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[l]);let h=c.map(n=>(0,w.jsx)(D,{commit:n,detailed:e===`task-commits`&&t.length===1},n.sha));return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`label`,{className:`relative mb-[22px] block`,children:[(0,w.jsx)(p,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute top-3.5 left-3 size-4 text-muted-foreground`}),(0,w.jsx)(g,{"aria-label":`Search commit messages`,placeholder:`Search commit messages…`,value:a,onChange:e=>o(e.target.value),className:`h-11 bg-card pl-10`})]}),(0,w.jsxs)(`div`,{ref:e=>{u.current=e,e&&(d.current=e.closest(`[data-slot="main"]`))},"data-slot":e,"data-virtualized":l,className:n(`flex flex-col divide-y divide-border rounded-xl border border-border bg-card px-4 py-1 md:px-5`,r),children:[i?(0,w.jsx)(`div`,{className:`flex min-h-14 flex-wrap items-center gap-2 py-4`,children:i}):null,c.length===0?(0,w.jsx)(`p`,{role:`status`,className:`py-5 text-sm text-muted-foreground`,children:`No loaded commits match your search.`}):null,l?(0,w.jsx)(x,{scrollRef:d,startMargin:f,itemSize:T,children:h}):h]})]})}function D({commit:e,detailed:t}){return(0,w.jsx)(`div`,{className:`[contain-intrinsic-block-size:auto_77px] [content-visibility:auto]`,children:(0,w.jsxs)(_,{"data-slot":`commit-row`,"data-sha":e.sha,to:e.href,className:n(`flex min-h-[76px] min-w-0 flex-col items-start gap-3 rounded-sm py-4 hover:bg-muted`,!t&&`md:flex-row md:items-center md:py-3`),children:[(0,w.jsx)(f,{size:16,"aria-hidden":`true`,className:n(`shrink-0 text-accent-text`,t?`size-[22px]`:`size-4`)}),(0,w.jsxs)(`span`,{className:n(`min-w-0 w-full`,!t&&`md:w-auto md:flex-1`),children:[(0,w.jsx)(`span`,{className:n(`block font-normal`,t?`text-[22px] leading-snug`:`text-[13px] md:truncate`),children:e.subject}),(0,w.jsxs)(`span`,{className:`mt-1 block truncate text-[11px] text-soft-foreground`,children:[e.author,` · `,e.when]})]}),(0,w.jsx)(`span`,{className:`shrink-0 rounded-md bg-muted px-2 py-1 font-mono text-[11px] text-muted-foreground`,children:e.shaLabel}),t?(0,w.jsxs)(`span`,{className:`inline-flex min-h-11 items-center gap-2 rounded-lg bg-action px-3 text-xs font-medium text-action-foreground`,children:[(0,w.jsx)(m,{size:16,"aria-hidden":`true`,className:`size-4`}),`View changes`]}):null]})})}function O(){let{id:e}=t(),n=s(e);return n.isPending?(0,w.jsx)(y,{tab:`changes`}):n.isError?(0,w.jsx)(b,{tab:`changes`,error:n.error}):(0,w.jsx)(k,{run:n.data})}function k({run:e}){let{sha:n}=t(),r=l(e.id,u(e));return(0,w.jsxs)(`div`,{"data-route":`task-commits`,className:`flex min-h-full flex-col`,children:[(0,w.jsx)(h,{run:e,tab:`commits`}),n?(0,w.jsx)(A,{runId:e.id,sha:n}):r.isPending?(0,w.jsx)(`p`,{"data-slot":`commits-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading commits…`}):r.isError?(0,w.jsx)(v,{icon:(0,w.jsx)(f,{size:16}),tone:r.error instanceof a&&r.error.status===409?`neutral`:`danger`,heading:`h2`,title:r.error instanceof a&&r.error.status===409?`No commits to show`:`Could not load the commits`,subtitle:r.error.message}):r.data.commits.length===0?(0,w.jsx)(v,{icon:(0,w.jsx)(f,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`This task hasn't committed anything on its branch. Autosave commits and any the agent makes appear here.`}):(0,w.jsxs)(`div`,{className:`px-[18px] py-[22px] md:px-9`,children:[(0,w.jsx)(E,{slot:`task-commits`,heading:(0,w.jsxs)(`h2`,{className:`text-base font-semibold`,children:[r.data.commits.length,` `,r.data.commits.length===1?`commit`:`commits`,` in this task`]}),className:`w-full`,commits:r.data.commits.map(t=>({...t,shaLabel:t.sha.slice(0,8),href:`/tasks/${e.id}/commits/${t.sha}`}))}),(0,w.jsx)(j,{run:e})]})]})}function A({runId:e,sha:t}){return(0,w.jsx)(S,{commit:c(e,t),sha:t,backTo:`/tasks/${e}/commits`,backLabel:`All commits`,slot:`task-commit`,className:`mx-auto flex min-h-0 w-full max-w-[var(--measure)] flex-1 flex-col`,diffClassName:`px-4 py-4 [--diff-sticky-top:0px] md:[--diff-sticky-top:1rem] md:px-6`})}function j({run:e}){let t=o(e.id,u(e));return t.isPending?(0,w.jsx)(`p`,{className:`mt-[22px] text-xs text-muted-foreground`,children:`Loading changed files…`}):t.isError?(0,w.jsxs)(`p`,{role:`status`,className:`mt-[22px] text-xs text-danger`,children:[`Could not load changed files: `,t.error.message]}):t.data.files.length===0?null:(0,w.jsxs)(`section`,{"data-slot":`task-commit-files`,className:`mt-[22px] rounded-[10px] border border-border bg-card p-5`,children:[(0,w.jsxs)(`h2`,{className:`mb-4 text-[16px] font-semibold`,children:[t.data.files.length,` changed files`]}),(0,w.jsx)(`ul`,{className:`space-y-4`,children:t.data.files.map(t=>(0,w.jsx)(`li`,{children:(0,w.jsxs)(_,{to:`/tasks/${e.id}/changes`,className:`flex min-h-11 items-center gap-2 text-xs text-muted-foreground hover:text-foreground`,children:[(0,w.jsx)(d,{size:16,"aria-hidden":`true`,className:`size-[15px] shrink-0`}),(0,w.jsx)(`span`,{className:`break-all`,children:t.path})]})},t.path))})]})}export{O as TaskCommitsRoute};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,D as n,E as r,T as i,t as a,u as o}from"./button-CS5tOblf.js";import{i as s,t as c}from"./react-runtime-CCIEwYL0.js";import{N as l,i as u,s as d}from"./project-scope-context-DSkcNKO7.js";import{C as f,f as p,gt as m,u as h,xt as g}from"./queries-D2MPDhtr.js";import{C as _,E as v,Q as y,ct as b,d as x}from"./design-icons-DmYTv2r1.js";import{t as S}from"./createLucideIcon-BHp8sXmF.js";import{n as C,t as w}from"./run-header-JJRW4anN.js";import{a as T,i as E,n as D,r as O}from"./file-preview-BUmlTtoq.js";import{t as k}from"./input-DIwJvCgi.js";import{t as A}from"./centered-state-BmsqxbI8.js";import{D as j,E as M,z as N}from"./index-aewNqo85.js";var P=S(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),F=S(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),I=e(s(),1),L=c();function R({runId:e,path:n,artifactId:r}){let i=f(e,r?null:n),o=h(e,r),s=r?o:i,c=(0,I.useContext)(N),u=t(),p=u.pathname.replace(/\/files\/?$/,`/report`)+u.search,m=s.data,g=(0,I.useMemo)(()=>m?.type===`file`&&m.source!==`artifact`?{runId:e,...c,basePath:m.path}:null,[m,c,e]);if(!n&&!r)return(0,L.jsx)(O,{runId:e,path:null,className:`min-w-0 flex-1`});if(s.isPending)return(0,L.jsx)(`p`,{role:`status`,className:`p-4`,children:`Loading file…`});if(s.isError)return(0,L.jsxs)(`section`,{"data-slot":`file-preview`,className:`min-w-0 flex-1 rounded-lg border p-4`,children:[(0,L.jsx)(`h2`,{children:`Could not load this file`}),(0,L.jsx)(`p`,{className:`wrap-anywhere text-sm`,children:s.error.message}),(0,L.jsx)(a,{variant:`outline`,onClick:()=>void s.refetch(),children:`Retry`})]});if(!m)return(0,L.jsx)(`p`,{role:`alert`,className:`p-4`,children:`No file data was returned.`});if(m.type!==`file`)return(0,L.jsxs)(`section`,{"data-slot":`file-preview`,className:`min-w-0 flex-1 rounded-lg border p-4`,children:[(0,L.jsx)(`h2`,{children:m.type===`unpublished`?`File not published`:`Cannot preview this file`}),(0,L.jsx)(`p`,{className:`wrap-anywhere py-2 font-mono text-xs`,children:m.path}),(0,L.jsx)(`p`,{className:`text-sm`,children:m.reason}),(0,L.jsx)(a,{variant:`outline`,onClick:()=>void s.refetch(),children:`Retry`})]});let _=m.artifact;return(0,L.jsx)(N.Provider,{value:g,children:(0,L.jsx)(D,{runId:e,entry:m,documentPreview:!0,readerHref:p,className:`min-w-0 flex-1`,imageUrl:_?d(e,_.id,`image`):l(e,n),..._?{downloadUrl:d(e,_.id,`download`),snapshot:new Date(_.createdAt).toLocaleString()}:{}},_?.id??m.path)})}var z=new Map;function B(e){let t=e?.filesRestoreKey;return typeof t==`string`&&t?t:null}var V=(0,I.createContext)(null);function H(){let{key:e}=t(),n=i()===`POP`,[r,a]=(0,I.useState)({key:e,generation:0});if(r.key===e)return r.generation;let o={key:e,generation:n?r.generation+1:r.generation};return a(o),o.generation}var U=()=>document.querySelector(`[data-slot="main"]`);function W(e,n){let r=(0,I.useRef)(null),a=t(),o=i()===`POP`?a.key:B(a.state),[s]=(0,I.useState)(()=>{let t=o?z.get(o):void 0;return t?.runId===e?t:null}),c=(0,I.useRef)(new Set(s?.folders??[])),l=(0,I.useRef)(new Set),[u,d]=(0,I.useState)(0),f=(0,I.useRef)(s===null),p=(0,I.useCallback)(()=>{f.current&&z.set(a.key,{runId:e,folders:new Set(c.current),tree:r.current?.scrollTop??0,main:U()?.scrollTop??0})},[a.key,e]),m=(0,I.useMemo)(()=>({isOpen:e=>c.current.has(e),setOpen:(e,t)=>{t?c.current.add(e):c.current.delete(e),p()},loading:(e,t)=>{s?.folders.has(e)&&(t?l.current.add(e):l.current.delete(e),d(l.current.size))}}),[s,p]);return(0,I.useEffect)(()=>{if(f.current||!s||!n||l.current.size>0)return;r.current&&(r.current.scrollTop=s.tree);let e=U();e&&(e.scrollTop=s.main),f.current=!0,p()},[s,n,u,p]),(0,I.useEffect)(()=>{p();let e=[r.current,U()].filter(e=>e!==null);for(let t of e)t.addEventListener(`scroll`,p,{passive:!0});return()=>{for(let t of e)t.removeEventListener(`scroll`,p)}},[p]),{tree:r,folders:m}}function G({runId:e,selected:t,onSelect:n}){return(0,L.jsx)(`nav`,{"data-slot":`files-tree`,"aria-label":`Worktree files`,className:`min-w-0 text-[13px]`,children:(0,L.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,L.jsx)(K,{runId:e,path:``,depth:0,selected:t,onSelect:n})})})}function K({runId:e,path:t,depth:n,selected:r,onSelect:i}){let a=g(e,t),o=(0,I.useContext)(V);return(0,I.useEffect)(()=>{if(!(!t||!o))return o.loading(t,a.isPending),()=>o.loading(t,!1)},[o,t,a.isPending]),a.isPending?(0,L.jsx)(`li`,{"data-slot":`files-tree-loading`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Loading…`}):a.isError?(0,L.jsx)(`li`,{"data-slot":`files-tree-error`,className:`px-1.5 py-1 text-xs text-danger`,style:{paddingLeft:`${6+n*14}px`},children:a.error.message}):a.data.type===`dir`?a.data.entries.length===0?(0,L.jsx)(`li`,{"data-slot":`files-tree-empty`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Empty directory`}):(0,L.jsx)(L.Fragment,{children:a.data.entries.map(a=>a.type===`dir`?(0,L.jsx)(q,{runId:e,name:a.name,path:t===``?a.name:`${t}/${a.name}`,depth:n,selected:r,onSelect:i},a.name):(0,L.jsx)(J,{name:a.name,path:t===``?a.name:`${t}/${a.name}`,size:a.size,depth:n,selected:r,onSelect:i},a.name))}):null}function q({runId:e,name:t,path:n,depth:r,selected:i,onSelect:a}){let s=(0,I.useContext)(V),[c,l]=(0,I.useState)(()=>s?.isOpen(n)??!1);return(0,L.jsxs)(`li`,{children:[(0,L.jsxs)(`button`,{type:`button`,"data-slot":`files-dir`,"data-path":n,"data-state":c?`open`:`closed`,"aria-expanded":c,onClick:()=>{s?.setOpen(n,!c),l(!c)},className:`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:`${6+r*14}px`},children:[(0,L.jsx)(x,{size:16,"aria-hidden":`true`,className:o(`order-last ml-auto size-3.5 shrink-0 transition-transform motion-reduce:transition-none`,c&&`rotate-90`)}),(0,L.jsx)(v,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate font-normal`,children:t})]}),c?(0,L.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,L.jsx)(K,{runId:e,path:n,depth:r+1,selected:i,onSelect:a})}):null]})}function J({name:e,path:t,size:n,depth:r,selected:i,onSelect:a}){let s=i===t,c=T(t)?F:_;return(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{type:`button`,"data-slot":`files-file`,"data-path":t,"aria-current":s?`true`:void 0,onClick:()=>a(t),className:o(`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left hover:bg-muted`,s?`bg-muted font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${6+r*14}px`},children:[(0,L.jsx)(c,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),n===void 0?null:(0,L.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[11px] tabular-nums text-soft-foreground`,children:E(n)})]})})}function Y(){let{id:e}=r(),t=m(e),n=H();return t.isPending?(0,L.jsx)(j,{tab:`files`}):t.isError?(0,L.jsx)(M,{tab:`files`,error:t.error}):(0,L.jsx)(C,{runId:t.data.id,children:(0,L.jsx)(Z,{run:t.data},`${t.data.id}:${n}`)})}function X(e,t,n,r){let i=f(e,r||n!==null?null:t),a=h(e,r?null:n);return r||t===null&&n===null?!0:!(n===null?i:a).isPending}function Z({run:e}){let t=g(e.id,``),r=p(e.id),[i,o]=n(),s=i.get(`path`),c=i.get(`artifact`),l=i.getAll(`path`).length>1||i.getAll(`artifact`).length>1||s!==null&&c!==null,[d,f]=(0,I.useState)(s??``);(0,I.useEffect)(()=>f(s??``),[s]);let m=(e,t)=>{let n=new URLSearchParams(i);n.delete(`path`),n.delete(`artifact`),n.set(e,t),o(n)},h=t.isError&&t.error instanceof u&&t.error.status===409,_=X(e.id,s,c,l),v=W(e.id,!t.isPending&&_);return(0,L.jsxs)(`div`,{"data-route":`task-files`,className:`flex min-h-full flex-col`,children:[(0,L.jsx)(w,{run:e,tab:`files`}),(0,L.jsxs)(`form`,{className:`flex min-w-0 gap-2 px-[18px] pt-[22px] md:px-9`,onSubmit:e=>{e.preventDefault(),d.trim()&&m(`path`,d.trim())},children:[(0,L.jsxs)(`label`,{className:`relative min-w-0 flex-1`,children:[(0,L.jsx)(y,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,L.jsx)(k,{"aria-label":`File path in the worktree`,placeholder:`Open a file by path…`,value:d,onChange:e=>f(e.target.value),className:`h-11 min-w-0 bg-card pl-10`})]}),(0,L.jsx)(a,{type:`submit`,variant:`outline`,className:`h-11 shrink-0`,disabled:!d.trim(),children:`Open file`})]}),(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-col items-stretch gap-5 px-[18px] py-[22px] [--diff-sticky-top:1rem] md:flex-row md:items-start md:px-9`,children:[(0,L.jsxs)(`aside`,{ref:v.tree,"data-slot":`files-tree-pane`,className:`w-full shrink-0 rounded-xl border border-border bg-card p-3.5 md:sticky md:top-[var(--diff-sticky-top)] md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] md:w-60 md:overflow-y-auto md:overscroll-contain lg:w-72`,children:[(0,L.jsx)(`h2`,{className:`sr-only`,children:`Worktree files`}),t.isPending?(0,L.jsx)(`p`,{"data-slot":`files-loading`,className:`py-4 text-xs`,children:`Loading files…`}):t.isError?(0,L.jsx)(A,{icon:h?(0,L.jsx)(P,{}):(0,L.jsx)(b,{size:16}),tone:h?`neutral`:`danger`,heading:`h2`,title:h?`No files to browse`:`Could not load the files`,subtitle:t.error.message}):(0,L.jsx)(V.Provider,{value:v.folders,children:(0,L.jsx)(G,{runId:e.id,selected:s,onSelect:e=>m(`path`,e)})}),(0,L.jsxs)(`section`,{className:`mt-4 border-t border-border pt-3`,"aria-label":`Published artifacts`,children:[(0,L.jsx)(`h2`,{className:`text-sm font-medium`,children:`Published artifacts`}),r.isPending?(0,L.jsx)(`p`,{className:`py-2 text-xs`,children:`Loading published files…`}):r.isError?(0,L.jsx)(`p`,{role:`alert`,className:`py-2 text-xs`,children:`Could not load published files.`}):r.data.artifacts.length===0?(0,L.jsx)(`p`,{className:`py-2 text-xs text-muted-foreground`,children:`No published files yet.`}):(0,L.jsx)(`ul`,{children:r.data.artifacts.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsx)(`button`,{type:`button`,"aria-current":e.id===c?`true`:void 0,className:`min-h-11 w-full rounded px-2 py-2 text-left text-xs wrap-anywhere hover:bg-muted focus-visible:ring-2`,onClick:()=>m(`artifact`,e.id),children:e.name})},e.id))}),(0,L.jsx)(a,{variant:`ghost`,className:`min-h-11`,onClick:()=>void r.refetch(),children:`Refresh published files`})]})]}),l?(0,L.jsx)(`p`,{role:`alert`,className:`p-4`,children:`Invalid file link: choose either a path or a published artifact.`}):s!==null||c!==null||t.isSuccess?(0,L.jsx)(R,{runId:e.id,path:s,artifactId:c}):null]}),(0,L.jsx)(`p`,{className:`px-[18px] pb-6 text-xs text-muted-foreground md:px-9`,children:`Browsing files is read-only. Worktree contents may differ from your main checkout. Published files are snapshots.`})]})}export{Y as TaskFilesRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,D as n,E as r,T as i,t as a,u as o}from"./button-CS5tOblf.js";import{i as s,t as c}from"./react-runtime-CCIEwYL0.js";import{N as l,i as u,s as d}from"./project-scope-context-DSkcNKO7.js";import{C as f,f as p,gt as m,u as h,xt as g}from"./queries-D2MPDhtr.js";import{C as _,E as v,Q as y,ct as b,d as x}from"./design-icons-DmYTv2r1.js";import{t as S}from"./createLucideIcon-BHp8sXmF.js";import{n as C,t as w}from"./run-header-Dc5892Cu.js";import{a as T,i as E,n as D,r as O}from"./file-preview-CFvc38AT.js";import{t as k}from"./input-DIwJvCgi.js";import{t as A}from"./centered-state-BmsqxbI8.js";import{D as j,E as M,z as N}from"./index-s7PhnzDS.js";var P=S(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),F=S(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),I=e(s(),1),L=c();function R({runId:e,path:n,artifactId:r}){let i=f(e,r?null:n),o=h(e,r),s=r?o:i,c=(0,I.useContext)(N),u=t(),p=u.pathname.replace(/\/files\/?$/,`/report`)+u.search,m=s.data,g=(0,I.useMemo)(()=>m?.type===`file`&&m.source!==`artifact`?{runId:e,...c,basePath:m.path}:null,[m,c,e]);if(!n&&!r)return(0,L.jsx)(O,{runId:e,path:null,className:`min-w-0 flex-1`});if(s.isPending)return(0,L.jsx)(`p`,{role:`status`,className:`p-4`,children:`Loading file…`});if(s.isError)return(0,L.jsxs)(`section`,{"data-slot":`file-preview`,className:`min-w-0 flex-1 rounded-lg border p-4`,children:[(0,L.jsx)(`h2`,{children:`Could not load this file`}),(0,L.jsx)(`p`,{className:`wrap-anywhere text-sm`,children:s.error.message}),(0,L.jsx)(a,{variant:`outline`,onClick:()=>void s.refetch(),children:`Retry`})]});if(!m)return(0,L.jsx)(`p`,{role:`alert`,className:`p-4`,children:`No file data was returned.`});if(m.type!==`file`)return(0,L.jsxs)(`section`,{"data-slot":`file-preview`,className:`min-w-0 flex-1 rounded-lg border p-4`,children:[(0,L.jsx)(`h2`,{children:m.type===`unpublished`?`File not published`:`Cannot preview this file`}),(0,L.jsx)(`p`,{className:`wrap-anywhere py-2 font-mono text-xs`,children:m.path}),(0,L.jsx)(`p`,{className:`text-sm`,children:m.reason}),(0,L.jsx)(a,{variant:`outline`,onClick:()=>void s.refetch(),children:`Retry`})]});let _=m.artifact;return(0,L.jsx)(N.Provider,{value:g,children:(0,L.jsx)(D,{runId:e,entry:m,documentPreview:!0,readerHref:p,className:`min-w-0 flex-1`,imageUrl:_?d(e,_.id,`image`):l(e,n),..._?{downloadUrl:d(e,_.id,`download`),snapshot:new Date(_.createdAt).toLocaleString()}:{}},_?.id??m.path)})}var z=new Map;function B(e){let t=e?.filesRestoreKey;return typeof t==`string`&&t?t:null}var V=(0,I.createContext)(null);function H(){let{key:e}=t(),n=i()===`POP`,[r,a]=(0,I.useState)({key:e,generation:0});if(r.key===e)return r.generation;let o={key:e,generation:n?r.generation+1:r.generation};return a(o),o.generation}var U=()=>document.querySelector(`[data-slot="main"]`);function W(e,n){let r=(0,I.useRef)(null),a=t(),o=i()===`POP`?a.key:B(a.state),[s]=(0,I.useState)(()=>{let t=o?z.get(o):void 0;return t?.runId===e?t:null}),c=(0,I.useRef)(new Set(s?.folders??[])),l=(0,I.useRef)(new Set),[u,d]=(0,I.useState)(0),f=(0,I.useRef)(s===null),p=(0,I.useCallback)(()=>{f.current&&z.set(a.key,{runId:e,folders:new Set(c.current),tree:r.current?.scrollTop??0,main:U()?.scrollTop??0})},[a.key,e]),m=(0,I.useMemo)(()=>({isOpen:e=>c.current.has(e),setOpen:(e,t)=>{t?c.current.add(e):c.current.delete(e),p()},loading:(e,t)=>{s?.folders.has(e)&&(t?l.current.add(e):l.current.delete(e),d(l.current.size))}}),[s,p]);return(0,I.useEffect)(()=>{if(f.current||!s||!n||l.current.size>0)return;r.current&&(r.current.scrollTop=s.tree);let e=U();e&&(e.scrollTop=s.main),f.current=!0,p()},[s,n,u,p]),(0,I.useEffect)(()=>{p();let e=[r.current,U()].filter(e=>e!==null);for(let t of e)t.addEventListener(`scroll`,p,{passive:!0});return()=>{for(let t of e)t.removeEventListener(`scroll`,p)}},[p]),{tree:r,folders:m}}function G({runId:e,selected:t,onSelect:n}){return(0,L.jsx)(`nav`,{"data-slot":`files-tree`,"aria-label":`Worktree files`,className:`min-w-0 text-[13px]`,children:(0,L.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,L.jsx)(K,{runId:e,path:``,depth:0,selected:t,onSelect:n})})})}function K({runId:e,path:t,depth:n,selected:r,onSelect:i}){let a=g(e,t),o=(0,I.useContext)(V);return(0,I.useEffect)(()=>{if(!(!t||!o))return o.loading(t,a.isPending),()=>o.loading(t,!1)},[o,t,a.isPending]),a.isPending?(0,L.jsx)(`li`,{"data-slot":`files-tree-loading`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Loading…`}):a.isError?(0,L.jsx)(`li`,{"data-slot":`files-tree-error`,className:`px-1.5 py-1 text-xs text-danger`,style:{paddingLeft:`${6+n*14}px`},children:a.error.message}):a.data.type===`dir`?a.data.entries.length===0?(0,L.jsx)(`li`,{"data-slot":`files-tree-empty`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Empty directory`}):(0,L.jsx)(L.Fragment,{children:a.data.entries.map(a=>a.type===`dir`?(0,L.jsx)(q,{runId:e,name:a.name,path:t===``?a.name:`${t}/${a.name}`,depth:n,selected:r,onSelect:i},a.name):(0,L.jsx)(J,{name:a.name,path:t===``?a.name:`${t}/${a.name}`,size:a.size,depth:n,selected:r,onSelect:i},a.name))}):null}function q({runId:e,name:t,path:n,depth:r,selected:i,onSelect:a}){let s=(0,I.useContext)(V),[c,l]=(0,I.useState)(()=>s?.isOpen(n)??!1);return(0,L.jsxs)(`li`,{children:[(0,L.jsxs)(`button`,{type:`button`,"data-slot":`files-dir`,"data-path":n,"data-state":c?`open`:`closed`,"aria-expanded":c,onClick:()=>{s?.setOpen(n,!c),l(!c)},className:`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:`${6+r*14}px`},children:[(0,L.jsx)(x,{size:16,"aria-hidden":`true`,className:o(`order-last ml-auto size-3.5 shrink-0 transition-transform motion-reduce:transition-none`,c&&`rotate-90`)}),(0,L.jsx)(v,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate font-normal`,children:t})]}),c?(0,L.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,L.jsx)(K,{runId:e,path:n,depth:r+1,selected:i,onSelect:a})}):null]})}function J({name:e,path:t,size:n,depth:r,selected:i,onSelect:a}){let s=i===t,c=T(t)?F:_;return(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{type:`button`,"data-slot":`files-file`,"data-path":t,"aria-current":s?`true`:void 0,onClick:()=>a(t),className:o(`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left hover:bg-muted`,s?`bg-muted font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${6+r*14}px`},children:[(0,L.jsx)(c,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),n===void 0?null:(0,L.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[11px] tabular-nums text-soft-foreground`,children:E(n)})]})})}function Y(){let{id:e}=r(),t=m(e),n=H();return t.isPending?(0,L.jsx)(j,{tab:`files`}):t.isError?(0,L.jsx)(M,{tab:`files`,error:t.error}):(0,L.jsx)(C,{runId:t.data.id,children:(0,L.jsx)(Z,{run:t.data},`${t.data.id}:${n}`)})}function X(e,t,n,r){let i=f(e,r||n!==null?null:t),a=h(e,r?null:n);return r||t===null&&n===null?!0:!(n===null?i:a).isPending}function Z({run:e}){let t=g(e.id,``),r=p(e.id),[i,o]=n(),s=i.get(`path`),c=i.get(`artifact`),l=i.getAll(`path`).length>1||i.getAll(`artifact`).length>1||s!==null&&c!==null,[d,f]=(0,I.useState)(s??``);(0,I.useEffect)(()=>f(s??``),[s]);let m=(e,t)=>{let n=new URLSearchParams(i);n.delete(`path`),n.delete(`artifact`),n.set(e,t),o(n)},h=t.isError&&t.error instanceof u&&t.error.status===409,_=X(e.id,s,c,l),v=W(e.id,!t.isPending&&_);return(0,L.jsxs)(`div`,{"data-route":`task-files`,className:`flex min-h-full flex-col`,children:[(0,L.jsx)(w,{run:e,tab:`files`}),(0,L.jsxs)(`form`,{className:`flex min-w-0 gap-2 px-[18px] pt-[22px] md:px-9`,onSubmit:e=>{e.preventDefault(),d.trim()&&m(`path`,d.trim())},children:[(0,L.jsxs)(`label`,{className:`relative min-w-0 flex-1`,children:[(0,L.jsx)(y,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,L.jsx)(k,{"aria-label":`File path in the worktree`,placeholder:`Open a file by path…`,value:d,onChange:e=>f(e.target.value),className:`h-11 min-w-0 bg-card pl-10`})]}),(0,L.jsx)(a,{type:`submit`,variant:`outline`,className:`h-11 shrink-0`,disabled:!d.trim(),children:`Open file`})]}),(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-col items-stretch gap-5 px-[18px] py-[22px] [--diff-sticky-top:1rem] md:flex-row md:items-start md:px-9`,children:[(0,L.jsxs)(`aside`,{ref:v.tree,"data-slot":`files-tree-pane`,className:`w-full shrink-0 rounded-xl border border-border bg-card p-3.5 md:sticky md:top-[var(--diff-sticky-top)] md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] md:w-60 md:overflow-y-auto md:overscroll-contain lg:w-72`,children:[(0,L.jsx)(`h2`,{className:`sr-only`,children:`Worktree files`}),t.isPending?(0,L.jsx)(`p`,{"data-slot":`files-loading`,className:`py-4 text-xs`,children:`Loading files…`}):t.isError?(0,L.jsx)(A,{icon:h?(0,L.jsx)(P,{}):(0,L.jsx)(b,{size:16}),tone:h?`neutral`:`danger`,heading:`h2`,title:h?`No files to browse`:`Could not load the files`,subtitle:t.error.message}):(0,L.jsx)(V.Provider,{value:v.folders,children:(0,L.jsx)(G,{runId:e.id,selected:s,onSelect:e=>m(`path`,e)})}),(0,L.jsxs)(`section`,{className:`mt-4 border-t border-border pt-3`,"aria-label":`Published artifacts`,children:[(0,L.jsx)(`h2`,{className:`text-sm font-medium`,children:`Published artifacts`}),r.isPending?(0,L.jsx)(`p`,{className:`py-2 text-xs`,children:`Loading published files…`}):r.isError?(0,L.jsx)(`p`,{role:`alert`,className:`py-2 text-xs`,children:`Could not load published files.`}):r.data.artifacts.length===0?(0,L.jsx)(`p`,{className:`py-2 text-xs text-muted-foreground`,children:`No published files yet.`}):(0,L.jsx)(`ul`,{children:r.data.artifacts.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsx)(`button`,{type:`button`,"aria-current":e.id===c?`true`:void 0,className:`min-h-11 w-full rounded px-2 py-2 text-left text-xs wrap-anywhere hover:bg-muted focus-visible:ring-2`,onClick:()=>m(`artifact`,e.id),children:e.name})},e.id))}),(0,L.jsx)(a,{variant:`ghost`,className:`min-h-11`,onClick:()=>void r.refetch(),children:`Refresh published files`})]})]}),l?(0,L.jsx)(`p`,{role:`alert`,className:`p-4`,children:`Invalid file link: choose either a path or a published artifact.`}):s!==null||c!==null||t.isSuccess?(0,L.jsx)(R,{runId:e.id,path:s,artifactId:c}):null]}),(0,L.jsx)(`p`,{className:`px-[18px] pb-6 text-xs text-muted-foreground md:px-9`,children:`Browsing files is read-only. Worktree contents may differ from your main checkout. Published files are snapshots.`})]})}export{Y as TaskFilesRoute};
@@ -1 +1 @@
1
- import{E as e,d as t,t as n}from"./button-CS5tOblf.js";import{t as r}from"./react-runtime-CCIEwYL0.js";import{Kr as i,et as a}from"./project-scope-context-DSkcNKO7.js";import{$ as o,$t as s,E as c,J as l,P as u,gt as d,k as f,n as p}from"./queries-D2MPDhtr.js";import{Z as m,_ as h,b as g}from"./popover-G6KGT-qq.js";import{I as _,ct as v,m as y}from"./design-icons-DmYTv2r1.js";import{t as b}from"./run-header-JJRW4anN.js";import{u as x}from"./reference-chip-Drpbf-MP.js";import{t as S}from"./project-router-BFKfAFvq.js";import{t as C}from"./centered-state-BmsqxbI8.js";import{E as w,T,cn as E}from"./index-aewNqo85.js";import{n as D,o as O,t as k}from"./use-hand-to-agent-state-C5obI4ms.js";var A=r(),j={issue:`Issue`,pr:`Pull request`};function M({kind:t}){let{id:n}=e(),r=d(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),s=l(),c=o(),d=u(),p=c.isPending||d.isPending,m=h(t,s).some(e=>e.kind===r&&e.number===a),g=f(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:s,item:g}):p?(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(p.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=g(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:o}){let l=i(),u=s({mutationFn:e=>a(t,n,{refresh:!0}),onSuccess:(e,t)=>l.setQueryData(t,e)}),d=P(t,o),f=c(d?[n]:[],d),p=f.data?.available?f.data.checks:void 0,m=`${j[t]} #${n}`,h=(0,A.jsx)(I,{retry:u,kind:t,number:n});if(o.isPending)return(0,A.jsx)(T,{kind:t,number:n,heading:`h2`});if(o.isError)return(0,A.jsx)(L,{kind:t,number:n,error:u.error??o.error,retryButton:h});let g=o.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:u.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
+ import{E as e,d as t,t as n}from"./button-CS5tOblf.js";import{t as r}from"./react-runtime-CCIEwYL0.js";import{Kr as i,et as a}from"./project-scope-context-DSkcNKO7.js";import{$ as o,$t as s,E as c,J as l,P as u,gt as d,k as f,n as p}from"./queries-D2MPDhtr.js";import{Z as m,_ as h,b as g}from"./popover-G6KGT-qq.js";import{I as _,ct as v,m as y}from"./design-icons-DmYTv2r1.js";import{t as b}from"./run-header-Dc5892Cu.js";import{u as x}from"./reference-chip-Drpbf-MP.js";import{t as S}from"./project-router-BFKfAFvq.js";import{t as C}from"./centered-state-BmsqxbI8.js";import{E as w,T,cn as E}from"./index-s7PhnzDS.js";import{n as D,o as O,t as k}from"./use-hand-to-agent-state-BOTjwkGM.js";var A=r(),j={issue:`Issue`,pr:`Pull request`};function M({kind:t}){let{id:n}=e(),r=d(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),s=l(),c=o(),d=u(),p=c.isPending||d.isPending,m=h(t,s).some(e=>e.kind===r&&e.number===a),g=f(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:s,item:g}):p?(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(p.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=g(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:o}){let l=i(),u=s({mutationFn:e=>a(t,n,{refresh:!0}),onSuccess:(e,t)=>l.setQueryData(t,e)}),d=P(t,o),f=c(d?[n]:[],d),p=f.data?.available?f.data.checks:void 0,m=`${j[t]} #${n}`,h=(0,A.jsx)(I,{retry:u,kind:t,number:n});if(o.isPending)return(0,A.jsx)(T,{kind:t,number:n,heading:`h2`});if(o.isError)return(0,A.jsx)(L,{kind:t,number:n,error:u.error??o.error,retryButton:h});let g=o.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:u.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,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,E as n,I as r,L as i,N as a,d as o,p as s,t as c,u as l,w as u}from"./button-CS5tOblf.js";import{i as d,r as f,t as p}from"./react-runtime-CCIEwYL0.js";import{n as m}from"./live-refetch-CZb2VOyu.js";import{Bn as h,E as g,Hn as _,Kr as v,P as y,Sr as b,Vn as x,_ as S,ar as C,d as w,er as T,i as E,ir as D,l as O,nr as ee,sr as k,tr as A,ur as te,w as ne}from"./project-scope-context-DSkcNKO7.js";import{$t as j,At as re,Ct as M,Et as N,J as P,P as F,Qt as I,R as L,S as R,Tt as ie,U as z,Xt as ae,bt as B,c as oe,d as se,et as V,gt as ce,h as le,n as H,ut as ue,x as de}from"./queries-D2MPDhtr.js";import{I as fe,J as pe,R as U,S as me,X as he,Z as ge,d as W,h as _e,q as ve,s as ye,v as be,w as xe}from"./popover-G6KGT-qq.js";import{n as G}from"./toaster-CRVRHlMR.js";import{A as Se,B as Ce,I as we,J as Te,Q as Ee,V as De,_ as Oe,b as ke,c as Ae,ct as je,d as K,ft as Me,g as Ne,h as Pe,j as Fe,l as Ie,n as Le,o as Re,ot as ze,p as Be,pt as Ve,st as He,u as Ue,y as We}from"./design-icons-DmYTv2r1.js";import{t as q}from"./createLucideIcon-BHp8sXmF.js";import{a as Ge,c as Ke,i as qe,l as Je,n as Ye,o as Xe,r as Ze,s as Qe,t as $e}from"./run-header-JJRW4anN.js";import{t as et}from"./eye-B8okNWXU.js";import{a as tt}from"./format-BNCkW110.js";import{t as nt}from"./message-square-B-MD-8rD.js";import{a as rt,i as it,n as at,o as ot,r as st,t as ct}from"./thread-state-9nrcMlnW.js";import{i as lt,o as ut,t as dt,u as ft}from"./reference-chip-Drpbf-MP.js";import{s as pt,t as J}from"./project-router-BFKfAFvq.js";import"./attention-VmnPpwJx.js";import{E as mt,S as ht,T as gt,a as _t,b as vt,i as yt,n as bt,r as xt,t as St,w as Ct,x as wt}from"./agent-accounts-BNlpWTOY.js";import{n as Tt,t as Et}from"./centered-state-BmsqxbI8.js";import{At as Dt,B as Ot,Ft as kt,Gt as At,J as jt,Jt as Mt,Kt as Nt,L as Pt,Mt as Ft,Ot as It,Pt as Lt,S as Rt,St as zt,Tt as Bt,U as Vt,Xt as Ht,Y as Ut,Yt as Wt,_ as Gt,c as Y,dn as Kt,et as qt,f as Jt,i as Yt,in as Xt,jt as Zt,kt as Qt,l as X,ln as $t,mn as en,n as tn,nn,nt as rn,qt as an,s as on,t as sn,tt as cn,u as Z,vt as ln,w as un,wt as dn,xt as fn,yt as pn,z as mn}from"./index-aewNqo85.js";import{t as hn}from"./zoomable-image-UzXCYU7Z.js";import{t as gn}from"./report-title-D4Mbu2Er.js";var _n=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`}]]),vn=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`}]]),yn=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`}]]),bn=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`}]]),xn=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`}]]),Sn=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`}]]),Cn=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(d(),1),$=p(),wn=12;function Tn({run:e}){let t=v(),n=j({mutationFn:()=>O(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:H.runs.detail(e.id)}),t.invalidateQueries({queryKey:H.runs.list()}),G(`This task will not resume itself`)},onError:e=>G(e.message,{tone:`danger`})});if(!C(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)(Ht,{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 `,wn,`)`]}):(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)(s,{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 En(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Dn=/^[A-Za-z0-9_./:=+,@%-]+$/;function On(e){return e.replaceAll(`'`,`'\\''`)}function kn(e){return e===``?`''`:Dn.test(e)?e:`\u0027${On(e)}\u0027`}function An(e){if(!En(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(kn).join(` `)}}function jn(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 Mn(e){return e.replace(/!\[(?:\\.|[^\]\\])*\]\([^)\s]*(?:\s+"[^"]*")?\)/g,` `)}function Nn(e){return e.replace(/(?<!\\)(?:\*\*|\*|__|~~|`)/g,``).replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/g,`$1`)}function Pn(e){let t=e.trim();return t===``||t.startsWith(`#`)||/^(https?:|mailto:)/i.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t)}function Fn(e){let t=jn(Mn(e)),n=new Map;for(let e of t.matchAll(/^\s*\[([^\]]+)\]:\s*(\S+)/gm))Pn(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]){Pn(e[2])&&i.push({label:Nn(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:Nn(e[1]),href:r});continue}let t=(e[4]??e[5])?.replace(/[.,;:!?]+$/,``);t&&Pn(t)&&i.push({label:t,href:t})}return i}var In=(0,Q.createContext)(void 0),Ln=(0,Q.createContext)(void 0);function Rn(e,t){let n=new Map;for(let r of Fn(e)){let e=Ot(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 zn(e,t){return`report-card-${encodeURIComponent(e)}-${t}`}function Bn({text:e,messageKey:t}){let n=(0,Q.useContext)(mn),r=(0,Q.useContext)(Ln),i=t??r;if(!n||i===void 0)return null;let a=Rn(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)(Vn,{reference:e,messageKey:i},`${e.runId}:${e.artifactId}`))})}function Vn({reference:e,messageKey:n}){let{artifactId:r,runId:i,label:a,href:o}=e,c=(0,Q.useContext)(In),l=(0,Q.useContext)(Rt);(0,Q.useLayoutEffect)(()=>l?.register(r,i),[l,r,i]);let d=se(i,r),f=t(),p=u();if(d.isError)return(0,$.jsx)(s,{id:zn(n,r),"data-slot":`report-card-fallback`,to:o,state:{readerFrom:f.pathname+f.search},children:a});let m=d.data?.artifact;if(m&&!Vt(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(o,`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?gn(m):a}),(0,$.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`HTML report`}),(0,$.jsx)(s,{id:zn(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 Hn={message:!0,reasoning:!0,tool:!0,hook:!0};function Un(e){return Object.hasOwn(Hn,e)&&Hn[e]}var Wn=e=>e.kind===`tool`,Gn=e=>e.kind===`conversation`,Kn=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,qn=(e,t,n)=>`${e} ${e===1?t:n}`;function Jn(e,t){let n=[];return e>0&&n.push(qn(e,`file`,`files`)),t>0&&n.push(qn(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function Yn(e){return`${e} earlier tool call${e===1?``:`s`}`}var Xn=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function Zn(e){for(let t of Xn)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 Qn(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!(e.kind===`reasoning`&&e.text.trim()===``)),n=new Set(t.filter(Wn).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=Un(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:Jn(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 $n(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(Gn(e)){s(),c.push(e);continue}l(),Wn(e)&&Kn(e)&&!r.has(e.id)?o.push(e):(s(),Wn(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 $n(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 er=new Map,tr=(0,Q.createContext)(null);function nr(){return(0,Q.useContext)(tr)}function rr({runId:e,children:t}){let n=(0,Q.useMemo)(()=>({get:t=>er.get(e)?.get(t),set:(t,n)=>{let r=er.get(e)??new Map;r.set(t,n),er.set(e,r)}}),[e]);return(0,$.jsx)(tr.Provider,{value:n,children:t})}function ir(e){return e.scrollTop<Math.max(600,e.clientHeight)}function ar(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function or(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 sr(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function cr(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var lr=new Map;function ur(e,t){lr.set(e,t)}function dr(e){return lr.get(e)}var fr=new Map;function pr(e,t){fr.set(e,{...t,...t.rowKeys?{rowKeys:[...t.rowKeys]}:{}})}function mr(e){return fr.get(e)}function hr(e,t,n){let r=fr.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 gr=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}),_r=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),vr=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),yr=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),br=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function xr(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function Sr(e){let t=xr(e);return t===void 0?void 0:gr.format(t)}function Cr(e){let t=xr(e);return t===void 0?void 0:_r.format(t)}var wr=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function Tr(e){let t=xr(e);return t===void 0?void 0:wr(t)}function Er(e,t=new Date){let n=xr(e);if(n===void 0)return;let r=wr(n);return r===wr(t)?`Today`:r===wr(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?vr:yr).format(n)}function Dr(e,t){let n=xr(e),r=xr(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 Or({ts:e}){let t=Sr(e);return t===void 0?null:(0,$.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:Cr(e),className:`text-[11px] leading-none text-soft-foreground`,children:t})}function kr({startedAt:e,completedAt:t}){let n=Sr(t);if(n===void 0)return null;let r=Dr(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:Cr(t),children:n}),r===void 0?null:(0,$.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function Ar({ts:e}){let t=Er(e),n=xr(e);if(t===void 0||n===void 0)return null;let r=br.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:Tr(e),title:r,children:t}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}var jr={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 Mr({role:e,children:t,className:n,ts:r,headerActions:i,...a}){let o=jr[e],s=r===void 0?void 0:Sr(r);return(0,$.jsxs)(`article`,{...a,"data-role":e,"aria-label":o.speaker,className:l(`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:l(`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)(nt,{"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)(Or,{ts:r})})]}),(0,$.jsx)(`div`,{className:l(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,o.body,`leading-[1.6]`),children:t})]})}function Nr({text:e,imageCount:t=0,images:n=[],ts:r,onEdit:i,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 i?.(t),f(!1)}catch(e){v(e instanceof Error?e.message:`Could not save the message`)}finally{g(!1)}},x=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)(Mr,{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)(tt,{className:`size-3.5 animate-spin`}):`Save`})]}),_?(0,$.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:_}):null]}):(0,$.jsxs)(Mr,{role:`user`,ts:r,"data-slot":`user-bubble`,className:`group`,children:[i||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:[i?(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)(Cn,{className:`size-3.5`})}):null,o?(0,$.jsx)(`button`,{type:`button`,"aria-label":c,onClick:()=>void x(),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)(He,{className:`size-3.5`})}):null]}):null,_?(0,$.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:_}):null,l??(0,$.jsx)(Pt,{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=>te(e.split(`/`).pop()??``)?(0,$.jsx)(hn,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,$.jsxs)(`a`,{href:a(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)(Te,{"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 Pr=`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`,Fr=[`[data-streamdown="code-block-actions"]`,`[data-streamdown="code-copy-button"]`,`[data-streamdown="code-block-copy-button"]`,`[data-streamdown="code-block-header"]`].join(`,`);function Ir(e,t){let n=e.cloneNode(!0);n.querySelectorAll(Fr).forEach(e=>e.remove());let r=Fn(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||!Pn(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 Lr(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=Ir(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 Rr({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 Lr(t,e,r.current),a(t),c.current=setTimeout(()=>a(null),2e3)}catch{s(`Couldn't copy to the clipboard`)}};return(0,$.jsxs)(Mr,{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:Pr,children:[(0,$.jsx)(We,{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:Pr,children:[(0,$.jsx)(Kt,{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)(Pt,{breaks:!0,children:e})}),(0,$.jsx)(Bn,{text:e,messageKey:n})]})}function zr({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)(Xt,{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:l(`px-0.5 text-xs`,e.tone===`danger`?`text-danger [.light_&]:text-red-700`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:`· `,e.text]})}var Br={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,pi:`pi`,cursor:`Cursor`,omp:`OMP`};function Vr({incident:e}){let t=Br[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(`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,E as n,I as r,L as i,N as a,d as o,p as s,t as c,u as l,w as u}from"./button-CS5tOblf.js";import{i as d,r as f,t as p}from"./react-runtime-CCIEwYL0.js";import{n as m}from"./live-refetch-CZb2VOyu.js";import{Bn as h,E as g,Hn as _,Kr as v,P as y,Sr as b,Vn as x,_ as S,ar as C,d as w,er as T,i as E,ir as D,l as O,nr as ee,sr as k,tr as A,ur as te,w as ne}from"./project-scope-context-DSkcNKO7.js";import{$t as j,At as re,Ct as M,Et as N,J as P,P as F,Qt as I,R as L,S as R,Tt as ie,U as z,Xt as ae,bt as B,c as oe,d as se,et as V,gt as ce,h as le,n as H,ut as ue,x as de}from"./queries-D2MPDhtr.js";import{I as fe,J as pe,R as U,S as me,X as he,Z as ge,d as W,h as _e,q as ve,s as ye,v as be,w as xe}from"./popover-G6KGT-qq.js";import{n as G}from"./toaster-CRVRHlMR.js";import{A as Se,B as Ce,I as we,J as Te,Q as Ee,V as De,_ as Oe,b as ke,c as Ae,ct as je,d as K,ft as Me,g as Ne,h as Pe,j as Fe,l as Ie,n as Le,o as Re,ot as ze,p as Be,pt as Ve,st as He,u as Ue,y as We}from"./design-icons-DmYTv2r1.js";import{t as q}from"./createLucideIcon-BHp8sXmF.js";import{a as Ge,c as Ke,i as qe,l as Je,n as Ye,o as Xe,r as Ze,s as Qe,t as $e}from"./run-header-Dc5892Cu.js";import{t as et}from"./eye-B8okNWXU.js";import{a as tt}from"./format-BNCkW110.js";import{t as nt}from"./message-square-B-MD-8rD.js";import{a as rt,i as it,n as at,o as ot,r as st,t as ct}from"./thread-state-B6Ar3fj6.js";import{i as lt,o as ut,t as dt,u as ft}from"./reference-chip-Drpbf-MP.js";import{s as pt,t as J}from"./project-router-BFKfAFvq.js";import"./attention-VmnPpwJx.js";import{E as mt,S as ht,T as gt,a as _t,b as vt,i as yt,n as bt,r as xt,t as St,w as Ct,x as wt}from"./agent-accounts-BNlpWTOY.js";import{n as Tt,t as Et}from"./centered-state-BmsqxbI8.js";import{At as Dt,B as Ot,Ft as kt,Gt as At,J as jt,Jt as Mt,Kt as Nt,L as Pt,Mt as Ft,Ot as It,Pt as Lt,S as Rt,St as zt,Tt as Bt,U as Vt,Xt as Ht,Y as Ut,Yt as Wt,_ as Gt,c as Y,dn as Kt,et as qt,f as Jt,i as Yt,in as Xt,jt as Zt,kt as Qt,l as X,ln as $t,mn as en,n as tn,nn,nt as rn,qt as an,s as on,t as sn,tt as cn,u as Z,vt as ln,w as un,wt as dn,xt as fn,yt as pn,z as mn}from"./index-s7PhnzDS.js";import{t as hn}from"./zoomable-image-UzXCYU7Z.js";import{t as gn}from"./report-title-D4Mbu2Er.js";var _n=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`}]]),vn=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`}]]),yn=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`}]]),bn=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`}]]),xn=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`}]]),Sn=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`}]]),Cn=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(d(),1),$=p(),wn=12;function Tn({run:e}){let t=v(),n=j({mutationFn:()=>O(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:H.runs.detail(e.id)}),t.invalidateQueries({queryKey:H.runs.list()}),G(`This task will not resume itself`)},onError:e=>G(e.message,{tone:`danger`})});if(!C(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)(Ht,{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 `,wn,`)`]}):(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)(s,{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 En(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Dn=/^[A-Za-z0-9_./:=+,@%-]+$/;function On(e){return e.replaceAll(`'`,`'\\''`)}function kn(e){return e===``?`''`:Dn.test(e)?e:`\u0027${On(e)}\u0027`}function An(e){if(!En(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(kn).join(` `)}}function jn(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 Mn(e){return e.replace(/!\[(?:\\.|[^\]\\])*\]\([^)\s]*(?:\s+"[^"]*")?\)/g,` `)}function Nn(e){return e.replace(/(?<!\\)(?:\*\*|\*|__|~~|`)/g,``).replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/g,`$1`)}function Pn(e){let t=e.trim();return t===``||t.startsWith(`#`)||/^(https?:|mailto:)/i.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t)}function Fn(e){let t=jn(Mn(e)),n=new Map;for(let e of t.matchAll(/^\s*\[([^\]]+)\]:\s*(\S+)/gm))Pn(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]){Pn(e[2])&&i.push({label:Nn(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:Nn(e[1]),href:r});continue}let t=(e[4]??e[5])?.replace(/[.,;:!?]+$/,``);t&&Pn(t)&&i.push({label:t,href:t})}return i}var In=(0,Q.createContext)(void 0),Ln=(0,Q.createContext)(void 0);function Rn(e,t){let n=new Map;for(let r of Fn(e)){let e=Ot(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 zn(e,t){return`report-card-${encodeURIComponent(e)}-${t}`}function Bn({text:e,messageKey:t}){let n=(0,Q.useContext)(mn),r=(0,Q.useContext)(Ln),i=t??r;if(!n||i===void 0)return null;let a=Rn(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)(Vn,{reference:e,messageKey:i},`${e.runId}:${e.artifactId}`))})}function Vn({reference:e,messageKey:n}){let{artifactId:r,runId:i,label:a,href:o}=e,c=(0,Q.useContext)(In),l=(0,Q.useContext)(Rt);(0,Q.useLayoutEffect)(()=>l?.register(r,i),[l,r,i]);let d=se(i,r),f=t(),p=u();if(d.isError)return(0,$.jsx)(s,{id:zn(n,r),"data-slot":`report-card-fallback`,to:o,state:{readerFrom:f.pathname+f.search},children:a});let m=d.data?.artifact;if(m&&!Vt(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(o,`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?gn(m):a}),(0,$.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`HTML report`}),(0,$.jsx)(s,{id:zn(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 Hn={message:!0,reasoning:!0,tool:!0,hook:!0};function Un(e){return Object.hasOwn(Hn,e)&&Hn[e]}var Wn=e=>e.kind===`tool`,Gn=e=>e.kind===`conversation`,Kn=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,qn=(e,t,n)=>`${e} ${e===1?t:n}`;function Jn(e,t){let n=[];return e>0&&n.push(qn(e,`file`,`files`)),t>0&&n.push(qn(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function Yn(e){return`${e} earlier tool call${e===1?``:`s`}`}var Xn=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function Zn(e){for(let t of Xn)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 Qn(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!(e.kind===`reasoning`&&e.text.trim()===``)),n=new Set(t.filter(Wn).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=Un(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:Jn(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 $n(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(Gn(e)){s(),c.push(e);continue}l(),Wn(e)&&Kn(e)&&!r.has(e.id)?o.push(e):(s(),Wn(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 $n(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 er=new Map,tr=(0,Q.createContext)(null);function nr(){return(0,Q.useContext)(tr)}function rr({runId:e,children:t}){let n=(0,Q.useMemo)(()=>({get:t=>er.get(e)?.get(t),set:(t,n)=>{let r=er.get(e)??new Map;r.set(t,n),er.set(e,r)}}),[e]);return(0,$.jsx)(tr.Provider,{value:n,children:t})}function ir(e){return e.scrollTop<Math.max(600,e.clientHeight)}function ar(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function or(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 sr(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function cr(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var lr=new Map;function ur(e,t){lr.set(e,t)}function dr(e){return lr.get(e)}var fr=new Map;function pr(e,t){fr.set(e,{...t,...t.rowKeys?{rowKeys:[...t.rowKeys]}:{}})}function mr(e){return fr.get(e)}function hr(e,t,n){let r=fr.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 gr=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}),_r=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),vr=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),yr=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),br=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function xr(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function Sr(e){let t=xr(e);return t===void 0?void 0:gr.format(t)}function Cr(e){let t=xr(e);return t===void 0?void 0:_r.format(t)}var wr=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function Tr(e){let t=xr(e);return t===void 0?void 0:wr(t)}function Er(e,t=new Date){let n=xr(e);if(n===void 0)return;let r=wr(n);return r===wr(t)?`Today`:r===wr(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?vr:yr).format(n)}function Dr(e,t){let n=xr(e),r=xr(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 Or({ts:e}){let t=Sr(e);return t===void 0?null:(0,$.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:Cr(e),className:`text-[11px] leading-none text-soft-foreground`,children:t})}function kr({startedAt:e,completedAt:t}){let n=Sr(t);if(n===void 0)return null;let r=Dr(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:Cr(t),children:n}),r===void 0?null:(0,$.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function Ar({ts:e}){let t=Er(e),n=xr(e);if(t===void 0||n===void 0)return null;let r=br.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:Tr(e),title:r,children:t}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}var jr={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 Mr({role:e,children:t,className:n,ts:r,headerActions:i,...a}){let o=jr[e],s=r===void 0?void 0:Sr(r);return(0,$.jsxs)(`article`,{...a,"data-role":e,"aria-label":o.speaker,className:l(`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:l(`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)(nt,{"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)(Or,{ts:r})})]}),(0,$.jsx)(`div`,{className:l(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,o.body,`leading-[1.6]`),children:t})]})}function Nr({text:e,imageCount:t=0,images:n=[],ts:r,onEdit:i,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 i?.(t),f(!1)}catch(e){v(e instanceof Error?e.message:`Could not save the message`)}finally{g(!1)}},x=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)(Mr,{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)(tt,{className:`size-3.5 animate-spin`}):`Save`})]}),_?(0,$.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:_}):null]}):(0,$.jsxs)(Mr,{role:`user`,ts:r,"data-slot":`user-bubble`,className:`group`,children:[i||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:[i?(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)(Cn,{className:`size-3.5`})}):null,o?(0,$.jsx)(`button`,{type:`button`,"aria-label":c,onClick:()=>void x(),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)(He,{className:`size-3.5`})}):null]}):null,_?(0,$.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:_}):null,l??(0,$.jsx)(Pt,{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=>te(e.split(`/`).pop()??``)?(0,$.jsx)(hn,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,$.jsxs)(`a`,{href:a(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)(Te,{"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 Pr=`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`,Fr=[`[data-streamdown="code-block-actions"]`,`[data-streamdown="code-copy-button"]`,`[data-streamdown="code-block-copy-button"]`,`[data-streamdown="code-block-header"]`].join(`,`);function Ir(e,t){let n=e.cloneNode(!0);n.querySelectorAll(Fr).forEach(e=>e.remove());let r=Fn(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||!Pn(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 Lr(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=Ir(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 Rr({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 Lr(t,e,r.current),a(t),c.current=setTimeout(()=>a(null),2e3)}catch{s(`Couldn't copy to the clipboard`)}};return(0,$.jsxs)(Mr,{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:Pr,children:[(0,$.jsx)(We,{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:Pr,children:[(0,$.jsx)(Kt,{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)(Pt,{breaks:!0,children:e})}),(0,$.jsx)(Bn,{text:e,messageKey:n})]})}function zr({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)(Xt,{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:l(`px-0.5 text-xs`,e.tone===`danger`?`text-danger [.light_&]:text-red-700`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:`· `,e.text]})}var Br={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,pi:`pi`,cursor:`Cursor`,omp:`OMP`};function Vr({incident:e}){let t=Br[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
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)(Pt,{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)(Pt,{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)(tt,{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:Kt,edit:Cn,delete:He,move:xn,search:Ee,execute:nn,think:vn,fetch:$t,task:Ae,plan:De,other:Ve},Gr=e=>e.split(`
3
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=sr(e.currentTarget)}:void 0,className:l(`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] text-soft-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
4
  `).map((e,t)=>(0,$.jsx)(Yr,{text:e},t))})]},`${e.path}:${t}`))})}function Jr(e){return e==null||e===``?[]:e.replace(/\n$/,``).split(`
@@ -1,4 +1,4 @@
1
- import{t as e,u as t}from"./button-CS5tOblf.js";import{t as n}from"./react-runtime-CCIEwYL0.js";import{hr as r,mr as i}from"./project-scope-context-DSkcNKO7.js";import{U as a,W as o,_ as s,f as c,g as l,h as ee,m as u}from"./live-protocol-DBPXI6ks.js";import{t as d}from"./createLucideIcon-BHp8sXmF.js";import{t as f}from"./app-window-CSHwDX9N.js";import{i as p}from"./format-BNCkW110.js";import{t as te}from"./play-CmVAj_fu.js";import{Xt as ne,dn as re,g as ie,h as ae,nn as oe}from"./index-aewNqo85.js";var m=d(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),h=d(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),g=n(),_={registered:e=>e.server.answeredAtRegistration?{label:`Open`,run:!1}:{label:`Run and open`,run:!0},adopted:()=>({label:`Open`,run:!1}),starting:()=>({label:`Open`,run:!1}),up:()=>({label:`Open`,run:!1}),stalled:()=>({label:`View`,run:!1}),exited:()=>({label:`Start again`,run:!0}),stopped:()=>({label:`Start again`,run:!0}),unavailable:()=>void 0};function v(e){let{text:t,...n}=ie(e),r={...n,status:t},i=_[e.state](e);return i?{...r,action:i}:r}var se={"Run and open":te,Open:f,View:re,"Start again":m};function ce({entry:e,inPreview:n,onOpen:r}){let{server:i}=e,a=v(e),o=e.state===`unavailable`,s=r?a.action:void 0,c=ae(i.command),l=p(i.registeredAt);return(0,g.jsxs)(`div`,{"data-slot":`preview-server-card`,"data-state":e.state,className:t(`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,o&&`text-muted-foreground`),children:[(0,g.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 text-xs text-soft-foreground`,children:[(0,g.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 font-mono`,children:[(0,g.jsx)(h,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,g.jsx)(`span`,{className:`truncate`,children:`cezar_preview_serve`})]}),o?(0,g.jsx)(`span`,{children:`worktree removed`}):l?(0,g.jsxs)(`span`,{children:[l,` ago`]}):null]}),(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-2`,children:[(0,g.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,g.jsx)(ne,{tone:a.tone,shape:a.ring?`ring`:`filled`,pulse:a.pulse===!0,"aria-hidden":`true`}),(0,g.jsx)(`span`,{className:`font-semibold text-foreground`,children:i.label}),(0,g.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,i.port]}),(0,g.jsx)(`span`,{className:`text-muted-foreground`,children:a.status})]}),(0,g.jsx)(le,{entry:e,inPreview:n,action:s,onOpen:r})]}),(0,g.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,g.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:i.command}),i.cwd?(0,g.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,g.jsx)(`span`,{children:`cwd`}),(0,g.jsx)(`span`,{className:`break-all`,children:i.cwd})]}):null]}),s?.run?(0,g.jsx)(y,{icon:(0,g.jsx)(oe,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),children:`${s.label===`Start again`?`Starting again`:`Opening`} runs ${c} in this task's worktree, on the host.`}):null,o?(0,g.jsx)(y,{children:`The worktree this server ran in is gone. Register it again from a new task.`}):null]})}function le({entry:t,inPreview:n,action:r,onOpen:i}){let{server:a}=t,o=n&&r!==void 0&&!r.run,s=o?`In preview`:r?.label,c=o?f:r?se[r.label]:null;return r&&s&&c?(0,g.jsxs)(e,{variant:o||r.label===`View`||r.label===`Open`&&t.state===`starting`?`outline`:`contrast`,size:`sm`,className:`max-md:h-11 max-md:px-3.5`,onClick:()=>i?.({port:a.port,run:r.run}),children:[(0,g.jsx)(c,{"aria-hidden":`true`}),s]}):null}function y({icon:e,children:t}){return(0,g.jsxs)(`p`,{className:`mt-2.5 flex items-start gap-2 text-xs text-muted-foreground`,children:[e,(0,g.jsx)(`span`,{children:t})]})}var b=120;function x(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function S(e){let t=e.replace(/\s+/g,` `).trim();return t.length>b?`${t.slice(0,b-1)}…`:t}function C(e,...t){if(x(e))for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return S(t)}}function ue(e){if(!x(e))return;let t=e.command;if(typeof t==`string`&&t.trim()!==``)return S(t);if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return S(e.join(` `))}}function de(e){if(!x(e)||!Array.isArray(e.changes))return[];let t=[];for(let n of e.changes)x(n)&&typeof n.path==`string`&&n.path.trim()!==``&&t.push(n.path);return t}function w(e){return C(e,`description`,`query`,`url`,`filePath`,`file_path`,`path`,`pattern`,`name`)}function T(e,t){return t?`${e} ${t}`:e}var fe=new Map([[`bash`,`execute`],[`commandexecution`,`execute`],[`edit`,`edit`],[`multiedit`,`edit`],[`write`,`edit`],[`notebookedit`,`edit`],[`filechange`,`edit`],[`read`,`read`],[`imageview`,`read`],[`glob`,`search`],[`grep`,`search`],[`webfetch`,`fetch`],[`websearch`,`fetch`],[`task`,`task`],[`agent`,`task`],[`skill`,`task`],[`todowrite`,`plan`],[`todolist`,`plan`],[`plan`,`plan`],[`taskcreate`,`plan`],[`taskupdate`,`plan`],[`tasklist`,`plan`],[`contextcompaction`,`other`],[`mcptoolcall`,`other`]]);function pe(e,t){switch(e){case`write`:return{toolKind:`edit`,title:T(`Write`,C(t,`file_path`,`filePath`,`path`))};case`notebookedit`:return{toolKind:`edit`,title:T(`Edit`,C(t,`notebook_path`,`notebookPath`,`file_path`,`filePath`,`path`))};case`filechange`:{let e=de(t);return{toolKind:`edit`,title:T(`Edit`,e.length===1?e[0]:e.length>1?`${e.length} files`:void 0)}}default:return{toolKind:`edit`,title:T(`Edit`,C(t,`file_path`,`filePath`,`path`))}}}function me(e,t){return e===`imageview`?{toolKind:`read`,title:T(`View image`,C(t,`path`))}:{toolKind:`read`,title:T(`Read`,C(t,`file_path`,`filePath`,`path`))}}function he(e,t){return e===`webfetch`?{toolKind:`fetch`,title:T(`Fetch`,C(t,`url`))}:{toolKind:`fetch`,title:T(`Web search`,C(t,`query`))}}function ge(e,t){if(e===`skill`){let e=C(t,`skill`,`name`,`command`);return{toolKind:`task`,title:e?`Skill: ${e}`:`Skill`,subtitle:C(t,`args`,`description`)}}let n=e===`agent`?`Agent`:`Task`,r=C(t,`subagent_type`,`subagentType`),i=C(t,`description`,`prompt`)??r;return{toolKind:`task`,title:i?`${n}: ${i}`:n,subtitle:i===r?void 0:r}}function _e(e,t,n){if(t===`contextcompaction`)return{toolKind:`other`,title:`Compacted context`};if(t===`mcptoolcall`){let e=C(n,`server`),t=C(n,`tool`);return e&&t?{toolKind:`other`,title:`${e}.${t}`}:{toolKind:`other`,title:`MCP tool`,subtitle:w(n)}}if(t.startsWith(`mcp__`)){let t=e.split(`__`).filter(e=>e!==``);if(t.length>=3)return{toolKind:`other`,title:`${t[1]}.${t.slice(2).join(`__`)}`}}return{toolKind:`other`,title:typeof e==`string`&&e.trim()!==``?S(e):`Tool`,subtitle:w(n)}}function ve(e,t){let n=typeof e==`string`?e.toLowerCase():``;switch(fe.get(n)){case`execute`:return{toolKind:`execute`,title:T(`Ran`,ue(t)),subtitle:C(t,`description`)};case`edit`:return pe(n,t);case`read`:return me(n,t);case`search`:return{toolKind:`search`,title:T(`Search`,C(t,`pattern`,`query`)),subtitle:C(t,`path`)};case`fetch`:return he(n,t);case`task`:return ge(n,t);case`plan`:return{toolKind:`plan`,title:`Update plan`};default:return _e(e,n,t)}}function ye(e,t){if(t.type===`ask.requested`&&typeof t.requestId==`string`&&a.safeParse({questions:t.questions}).success)return t;if(t.type===`human-input-delivered`||t.type===`human-ask-closed`){let n=(t.type===`human-input-delivered`?l:ee).safeParse(t);if(n.success&&n.data.askSeq===e?.seq)return}return e}function E(e){if(!(e.type!==`ask.requested`||typeof e.requestId!=`string`))return{requestId:e.requestId,questions:e.questions,...e.context===void 0?{}:{context:e.context}}}function D(e){let t=E(e);return t&&{seq:e.seq,...t}}function O(e,t){let n=ye(e&&{type:`ask.requested`,seq:e.seq,ts:``},t);return n===t?D(t):n===void 0?void 0:e}function k(e){let t;for(let n of e)t=O(t,n);return t}function A(e){let t=Array.isArray(e.questions)?e.questions.filter(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e.header==`string`&&(e.options===void 0||Array.isArray(e.options))):[];if(t.length===0)return;let n=typeof e.context==`string`&&e.context!==``?e.context:void 0;return{id:e.requestId,questions:t,...n===void 0?{}:{context:n},askSeq:e.seq}}function j(){return{turns:[],itemsById:new Map,turnSeq:0,permissions:new Map,conversationEntries:new Map,outcomesByRequest:new Map,seenInputs:new Set,previewByPort:new Map,handedOff:!1}}function M(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function N(e){return typeof e==`string`?e:void 0}function P(e){let t=typeof e==`string`?new Date(e):void 0;return!t||Number.isNaN(t.getTime())?``:` · ${t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}`}function F(e){if(!(typeof e!=`string`||e===``))return Number.isFinite(new Date(e).getTime())?e:void 0}var be=new Set(o.options);function xe(e){return typeof e==`string`&&be.has(e)?e:void 0}function I(e,t){e.turnSeq+=1;let n={id:t===void 0?`turn-fallback-${e.turnSeq}`:`turn-seq-${t}`,entries:[],v2Items:!1};return e.turns.push(n),n}function L(e){return e.turns.at(-1)??I(e)}function R(e,t){L(e).entries.push({origin:`meta`,entry:t})}function z(e){for(let t of e.permissions.values())t.status===`pending`&&(t.status=`expired`)}function B(e,t){let n=N(e.stepId);return n===void 0?t:`${n}:${t}`}function Se(e,t){t.v2Items=!0;for(let n of t.entries)n.origin===`v1`&&n.entry.kind===`tool`&&e.itemsById.delete(n.entry.id);t.entries=t.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`tool`))}function Ce(e,t,n,r,i){let a=n.kind===`message`&&i!==void 0?{...n,ts:i}:{...n};!t.v2Items&&a.kind!==`hook`&&Se(e,t);let o=e.itemsById.get(r);if(o&&o.turn===t){o.entry.entry=a;return}let s={origin:`v2`,entry:a};t.entries.push(s),e.itemsById.set(r,{turn:t,entry:s})}var V={"not-delivered":0,queued:1,delivered:2,consumed:3},we=[`instruction`,`resumed`,`requestId`,`relationship`,`state`,`createdAt`,`requestHash`,`deadline`];function H(e){let t={};for(let n of we)e[n]!==void 0&&Object.assign(t,{[n]:e[n]});return t}function U(e,t){if(t.messageKind!==`request`)return;let n=e.outcomesByRequest.get(t.messageId);n&&(t.outcome={status:n.status,...n.replyId===void 0?{}:{replyId:n.replyId},observedAt:n.observedAt})}function Te(e,t){let n=e.conversationEntries.get(t);n&&U(e,n)}function Ee(e,t,n,r){(V[e.delivery]<V.delivered||V[n]>V[e.delivery])&&(e.delivery=n),t.text!==``&&(e.text=t.text),Object.assign(e,H(t)),r.deliveredAt!==void 0&&(e.deliveredAt=r.deliveredAt),r.consumedAt!==void 0&&(e.consumedAt=r.consumedAt),r.recordedAt!==void 0&&(n===`delivered`||e.delivery!==`delivered`)&&(e.recordedAt=r.recordedAt)}function W(e,t,n,r){let i=e.conversationEntries.get(t.id);if(i){Ee(i,t,n,r),U(e,i);return}let a={kind:`conversation`,id:`conversation-message:${t.id}`,messageId:t.id,text:t.text,senderRunId:t.senderRunId,recipientRunId:t.recipientRunId,messageKind:t.kind,delivery:n,...r,...H(t)};U(e,a),e.conversationEntries.set(t.id,a),R(e,a)}function De(e,t){let n=P(t.ts),r=N(t.message),i=t.notify===!1?`Stopped notifying the webhook${n}`:`${e.handedOff?`Note sent to webhook`:`Handed off to webhook`}${n}${r?` — ${r}`:``}`;e.handedOff=t.notify!==!1,R(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`dim`,icon:`handoff`})}function Oe(e,t){let n=typeof t.attempts==`number`?t.attempts:void 0,r=N(t.webhookName),i=`${r?`Delivery to ${r} failed`:`Webhook delivery failed`}${N(t.event)?` (${N(t.event)})`:``}${n?` after ${n} attempt${n===1?``:`s`}`:``}: ${N(t.error)??`unknown error`}`;R(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`danger`})}function ke(e,t){let n=N(t.webhookName)??`webhook`,r=N(t.title),i=`v1:${t.seq}`;if(t.ok===!1){R(e,{kind:`note`,id:i,text:`Report to ${n} failed: ${N(t.error)??`unknown error`}`,tone:`danger`});return}let a=`${t.dryRun===!0?`Report to ${n} (dry run, nothing sent)`:`Sent report to ${n}`}${P(t.ts)}${r?` — ${r}`:``}`;R(e,t.dryRun===!0?{kind:`note`,id:i,text:a,tone:`dim`}:{kind:`note`,id:i,text:a,tone:`dim`,icon:`handoff`})}function Ae(e,t){let n=t.payload??{},r=`Webhook (dry run, nothing sent): ${N(t.event)??`delivery`}${N(n.status)?` · ${N(n.status)}`:``}`;R(e,{kind:`note`,id:`v1:${t.seq}`,text:r,tone:`dim`})}function je(e,t){let n=i.safeParse(t.server);if(!n.success)return;let r=e.previewByPort.get(n.data.port);r&&(r.turn.entries=r.turn.entries.filter(e=>e!==r.draft));let a=L(e),o={origin:`meta`,entry:{kind:`preview-server`,id:`preview-server:${n.data.port}`,server:n.data,state:`registered`,stateAt:t.ts}};a.entries.push(o),e.previewByPort.set(n.data.port,{turn:a,draft:o})}function Me(e,t){let n=r.safeParse(t.state),i=typeof t.port==`number`?e.previewByPort.get(t.port):void 0;if(!n.success||!i||i.draft.entry.kind!==`preview-server`)return;let{server:a,id:o}=i.draft.entry;i.draft.entry={kind:`preview-server`,id:o,server:a,state:n.data,stateAt:t.ts,...typeof t.exitCode==`number`?{exitCode:t.exitCode}:{},...t.reason===`user`||t.reason===`idle`?{reason:t.reason}:{}}}function Ne(e,t){let n=u.safeParse(t);if(!n.success)return;let{message:r,delivery:i,deliveredAt:a,consumedAt:o,ts:s}=n.data;W(e,r,i,{deliveredAt:a,consumedAt:o,recordedAt:s})}function Pe(e,t){let n=s.safeParse(t);if(!n.success)return;let{outcome:r}=n.data,i=e.outcomesByRequest.get(r.requestId);i&&!(i.status===`timed-out`&&r.status===`replied-late`)||(e.outcomesByRequest.set(r.requestId,r),Te(e,r.requestId))}function Fe(e,t){let n=c.safeParse(t);if(!n.success)return;let{input:r}=n.data;if(!e.seenInputs.has(r.id)){if(e.seenInputs.add(r.id),r.conversation){W(e,{id:r.id,text:r.text,createdAt:r.createdAt,...r.conversation},`delivered`,{deliveredAt:r.deliveredAt,recordedAt:n.data.ts});return}R(e,{kind:`note`,id:`agent-input:${r.id}`,text:r.text,tone:`dim`,attribution:{source:r.source,parentRunId:r.parentRunId}})}}function Ie(e,t){let n=N(t.text)??``,r=e.pendingAsk;e.pendingAsk&&!e.pendingAsk.resolved&&(e.pendingAsk.resolved=!0,e.pendingAsk.answeredBy=`human`,n!==``&&(e.pendingAsk.answer=n),e.pendingAsk=void 0);let i=I(e,t.seq),a=F(t.ts);i.userMessage={text:n,ask:r,imageCount:typeof t.imageCount==`number`?t.imageCount:0,images:Array.isArray(t.images)?t.images.filter(e=>typeof e==`string`):[],...a===void 0?{}:{ts:a}},a!==void 0&&(i.startedAt=a)}function Le(e,t){let n=e.turns.at(-1),r=n&&n.turnId===void 0&&!n.v2Items?n:I(e,t.seq);r.turnId=N(t.turnId),r.startedAt??=F(t.ts)}function Re(e,t){for(let n=e.turns.length-1;n>=0;--n)if(e.turns[n].turnId===t)return e.turns[n];return e.turns.at(-1)}function ze(e,t){z(e);let n=Re(e,N(t.turnId));if(!n)return;let r=F(t.ts);n.completed={stopReason:N(t.stopReason)??`end_turn`,...typeof t.costUsd==`number`?{costUsd:t.costUsd}:{},...r===void 0?{}:{ts:r}}}var G=new Set([`message`,`reasoning`,`tool`,`hook`]),Be=e=>G.has(e.kind);function Ve(e){if(!(!M(e)||!G.has(e.kind)))return typeof e.id==`string`&&e.id!==``?e:void 0}function K(e,t){let n=Ve(t.item);if(!n)return;let r=B(t,n.id);Ce(e,e.itemsById.get(r)?.turn??L(e),n,r,t.type===`item.completed`?F(t.ts):void 0)}function He(e,t){let n=e.itemsById.get(B(t,N(t.itemId)??``)),r=N(t.delta)??``;if(!n||r===``||!Be(n.entry.entry))return;let i=n.entry.entry;t.field===`output`&&i.kind===`tool`?i.output=(i.output??``)+r:t.field!==`output`&&(i.kind===`message`||i.kind===`reasoning`)&&(i.text+=r)}function Ue(e,t){let n=L(e),r=N(t.text)??``;if(r===``)return;let i=F(t.ts);n.entries.push({origin:`v1`,entry:{kind:`message`,id:`v1:${t.seq}`,role:`assistant`,text:r,...i===void 0?{}:{ts:i}}})}var We=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function Ge(e){if(!M(e)||!Array.isArray(e.todos))return;let t=[];for(let n of e.todos){if(!M(n)||typeof n.content!=`string`)return;t.push({content:n.content,status:We.has(n.status)?n.status:`pending`,...typeof n.activeForm==`string`?{activeForm:n.activeForm}:{}})}return t}var Ke=new Set([`subAgentActivity`,`collabAgentToolCall`,`collabToolCall`]);function qe(e,t){let n=L(e),r=N(t.tool)??`Tool`;if(n.v2Items||Ke.has(r))return;let i=ve(r,t.input),a=i.toolKind===`plan`?Ge(t.input):void 0;a!==void 0&&(n.planEntries=a);let o={kind:`tool`,id:N(t.id)??`v1:${t.seq}`,name:r,toolKind:i.toolKind,title:i.title,status:`running`,input:t.input},s={origin:`v1`,entry:o};n.entries.push(s),e.itemsById.set(o.id,{turn:n,entry:s})}function Je(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}}function Ye(e,t){let n=e.itemsById.get(N(t.toolCallId)??``);if(!n||n.turn.v2Items||n.entry.origin!==`v1`)return;let r=n.entry.entry;r.kind===`tool`&&(r.status=`completed`,r.output=Je(t.result))}function q(e,t,n,r){let i=N(t.message)??``;i!==``&&R(e,{kind:`note`,id:n,text:i,tone:r})}function J(e,t){q(e,t,`v1:${t.seq}`,t.tone===`danger`?`danger`:`dim`)}function Xe(e,t){q(e,t,`v1:${t.seq}`,`danger`)}function Ze(e,t){q(e,t,`v2:${t.seq}`,`danger`)}function Qe(e,t){if(t.status!==`failed`)return;let n=N(t.error)?` — ${N(t.error)}`:``;R(e,{kind:`note`,id:`v1:${t.seq}`,text:`step ${N(t.stepId)??`?`} failed${n}`,tone:`danger`})}function $e(e,t){let n=N(t.command)??`check`,r=typeof t.exitCode==`number`?t.exitCode:-1;R(e,{kind:`tool`,id:`v1:${t.seq}`,name:`check`,toolKind:`execute`,title:`Ran ${n}`,status:r===0?`completed`:`failed`,output:N(t.text)??``,exitCode:r})}function et(e,t){let n=xe(t.provider),r=N(t.authFailureId)??``;n===void 0||r.length<1||r.length>128||R(e,{kind:`provider-auth-required`,id:`v1:${t.seq}`,provider:n,authFailureId:r})}function tt(e,t){let n=N(t.url);if(n===void 0)return;let r={kind:`image`,id:`v1:${t.seq}`,url:n},i=N(t.name);i!==void 0&&(r.name=i),R(e,r)}function nt(e,t){Array.isArray(t.entries)&&(L(e).planEntries=t.entries)}function rt(e,t){z(e);let n=N(t.message);e.sessionEnded={reason:N(t.reason)??`end_turn`,...n===void 0?{}:{message:n}}}var it=new Set([`allow_once`,`allow_always`,`reject_once`,`reject_always`]);function at(e){return M(e)&&typeof e.id==`string`&&e.id!==``&&typeof e.label==`string`&&e.label!==``&&it.has(e.kind)}function ot(e){if(!(!Array.isArray(e)||e.length===0||!e.every(at)))return new Set(e.map(e=>e.id)).size===e.length?e:void 0}function st(e,t){let n=N(t.requestId),r=N(t.title),i=ot(t.options);if(!n||!r||e.permissions.has(n)||!i)return;let a=N(t.itemId),o=N(t.details),s={kind:`permission`,id:`permission:${n}`,requestId:n,title:r,options:i.map(e=>({...e})),status:`pending`,...a===void 0?{}:{itemId:a},...o===void 0?{}:{details:o}};e.permissions.set(n,s),R(e,s)}function ct(e,t){let n=e.permissions.get(N(t.requestId)??``);if(!n||n.status!==`pending`)return;let r=N(t.optionId);r!==void 0&&n.options.some(e=>e.id===r)?(n.status=`resolved`,n.optionId=r):n.status=`expired`;let i=N(t.reason);i!==void 0&&(n.reason=i)}function lt(e,t){let n=D(t),r=n&&A(n);if(!r)return;let i={kind:`ask`,...r,questions:r.questions,resolved:!1};R(e,i),e.pendingAsk=i}function Y(e,t){let n=e.pendingAsk;return n&&!n.resolved&&n.askSeq===t.askSeq?n:void 0}function ut(e,t){let n=Y(e,t);if(!n)return;n.routedToParent=!0;let r=N(t.parentRunId);r!==void 0&&(n.parentRunId=r)}function dt(e,t){let n=Y(e,t);n&&(n.routedToParent=!1)}function ft(e,t){let n=Y(e,t);n&&X(e,n,`undeliverable`)}var pt=new Set([`finish`,`superseded`,`parent-stopped`,`worker-stopped`,`undeliverable`]);function mt(e,t){let n=Y(e,t);n&&pt.has(t.reason)&&X(e,n,t.reason)}function X(e,t,n){t.resolved=!0,t.closed=n,e.pendingAsk=void 0}function Z(e,t){let n=Y(e,t);if(n){if(t.source===`cezar`){X(e,n,`undeliverable`);return}t.source===`parent`&&(n.resolved=!0,n.answeredBy=`parent`,e.pendingAsk=void 0)}}var Q=()=>{},ht=new Map([[`handoff`,De],[`webhook.failed`,Oe],[`webhook.dry-run`,Ae],[`webhook.report`,ke],[`preview.server-registered`,je],[`preview.server-state`,Me],[`conversation-message`,Ne],[`request-outcome`,Pe],[`agent-input`,Fe],[`user-message`,Ie],[`turn.started`,Le],[`turn.completed`,ze],[`item.started`,K],[`item.updated`,K],[`item.completed`,K],[`item.delta`,He],[`text`,Ue],[`tool-call`,qe],[`tool-result`,Ye],[`note`,J],[`lifecycle`,J],[`error`,Xe],[`session.error`,Ze],[`step-end`,Qe],[`check-output`,$e],[`provider-auth-required`,et],[`image`,tt],[`plan.updated`,nt],[`session.started`,e=>z(e)],[`session.ended`,rt],[`permission.requested`,st],[`permission.resolved`,ct],[`ask.requested`,lt],[`worker-question-routed`,ut],[`worker-question-fallback`,dt],[`worker-question-undelivered`,ft],[`human-ask-closed`,mt],[`human-input-delivered`,Z],[`step-start`,Q],[`token-usage`,Q],[`cost`,Q],[`turn-end`,Q],[`done`,Q],[`session`,Q]]);function gt(e,t){ht.get(t.type)?.(e,t)}function _t(e){for(let t=e.turns.length-1;t>=0;--t){let n=e.turns[t].planEntries;if(n!==void 0)return n}}function vt(e){let t=[];for(let n of e.turns)for(let e of n.items)if(e.kind===`tool`){for(let n of e.locations??[])t.push(n.path);for(let n of e.diffs??[])t.push(n.path)}let n=[];for(let e=t.length-1;e>=0;--e)n.includes(t[e])||n.push(t[e]);return n}function yt(e,t){switch(e){case`waiting`:return{state:`waiting`};case`failed`:return{state:`closed`,tone:`danger`,label:t?`Session failed — ${t}`:`Session failed`};case`review`:return{state:`closed`,tone:`dim`,label:`Session closed — waiting for your review`};case`done`:case`cancelled`:return{state:`closed`,tone:`dim`,label:`Session closed`};default:return null}}function $(e,t){let n=e.replace(/\s*CEZ:DONE\s*$/,``).replace(/\s*CEZ:MONITORING\s*$/,``);if(t){let e=n.trimEnd(),t=e.lastIndexOf(`
1
+ import{t as e,u as t}from"./button-CS5tOblf.js";import{t as n}from"./react-runtime-CCIEwYL0.js";import{hr as r,mr as i}from"./project-scope-context-DSkcNKO7.js";import{U as a,W as o,_ as s,f as c,g as l,h as ee,m as u}from"./live-protocol-DBPXI6ks.js";import{t as d}from"./createLucideIcon-BHp8sXmF.js";import{t as f}from"./app-window-CSHwDX9N.js";import{i as p}from"./format-BNCkW110.js";import{t as te}from"./play-CmVAj_fu.js";import{Xt as ne,dn as re,g as ie,h as ae,nn as oe}from"./index-s7PhnzDS.js";var m=d(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),h=d(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),g=n(),_={registered:e=>e.server.answeredAtRegistration?{label:`Open`,run:!1}:{label:`Run and open`,run:!0},adopted:()=>({label:`Open`,run:!1}),starting:()=>({label:`Open`,run:!1}),up:()=>({label:`Open`,run:!1}),stalled:()=>({label:`View`,run:!1}),exited:()=>({label:`Start again`,run:!0}),stopped:()=>({label:`Start again`,run:!0}),unavailable:()=>void 0};function v(e){let{text:t,...n}=ie(e),r={...n,status:t},i=_[e.state](e);return i?{...r,action:i}:r}var se={"Run and open":te,Open:f,View:re,"Start again":m};function ce({entry:e,inPreview:n,onOpen:r}){let{server:i}=e,a=v(e),o=e.state===`unavailable`,s=r?a.action:void 0,c=ae(i.command),l=p(i.registeredAt);return(0,g.jsxs)(`div`,{"data-slot":`preview-server-card`,"data-state":e.state,className:t(`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,o&&`text-muted-foreground`),children:[(0,g.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 text-xs text-soft-foreground`,children:[(0,g.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 font-mono`,children:[(0,g.jsx)(h,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,g.jsx)(`span`,{className:`truncate`,children:`cezar_preview_serve`})]}),o?(0,g.jsx)(`span`,{children:`worktree removed`}):l?(0,g.jsxs)(`span`,{children:[l,` ago`]}):null]}),(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-2`,children:[(0,g.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,g.jsx)(ne,{tone:a.tone,shape:a.ring?`ring`:`filled`,pulse:a.pulse===!0,"aria-hidden":`true`}),(0,g.jsx)(`span`,{className:`font-semibold text-foreground`,children:i.label}),(0,g.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,i.port]}),(0,g.jsx)(`span`,{className:`text-muted-foreground`,children:a.status})]}),(0,g.jsx)(le,{entry:e,inPreview:n,action:s,onOpen:r})]}),(0,g.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,g.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:i.command}),i.cwd?(0,g.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,g.jsx)(`span`,{children:`cwd`}),(0,g.jsx)(`span`,{className:`break-all`,children:i.cwd})]}):null]}),s?.run?(0,g.jsx)(y,{icon:(0,g.jsx)(oe,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),children:`${s.label===`Start again`?`Starting again`:`Opening`} runs ${c} in this task's worktree, on the host.`}):null,o?(0,g.jsx)(y,{children:`The worktree this server ran in is gone. Register it again from a new task.`}):null]})}function le({entry:t,inPreview:n,action:r,onOpen:i}){let{server:a}=t,o=n&&r!==void 0&&!r.run,s=o?`In preview`:r?.label,c=o?f:r?se[r.label]:null;return r&&s&&c?(0,g.jsxs)(e,{variant:o||r.label===`View`||r.label===`Open`&&t.state===`starting`?`outline`:`contrast`,size:`sm`,className:`max-md:h-11 max-md:px-3.5`,onClick:()=>i?.({port:a.port,run:r.run}),children:[(0,g.jsx)(c,{"aria-hidden":`true`}),s]}):null}function y({icon:e,children:t}){return(0,g.jsxs)(`p`,{className:`mt-2.5 flex items-start gap-2 text-xs text-muted-foreground`,children:[e,(0,g.jsx)(`span`,{children:t})]})}var b=120;function x(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function S(e){let t=e.replace(/\s+/g,` `).trim();return t.length>b?`${t.slice(0,b-1)}…`:t}function C(e,...t){if(x(e))for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return S(t)}}function ue(e){if(!x(e))return;let t=e.command;if(typeof t==`string`&&t.trim()!==``)return S(t);if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return S(e.join(` `))}}function de(e){if(!x(e)||!Array.isArray(e.changes))return[];let t=[];for(let n of e.changes)x(n)&&typeof n.path==`string`&&n.path.trim()!==``&&t.push(n.path);return t}function w(e){return C(e,`description`,`query`,`url`,`filePath`,`file_path`,`path`,`pattern`,`name`)}function T(e,t){return t?`${e} ${t}`:e}var fe=new Map([[`bash`,`execute`],[`commandexecution`,`execute`],[`edit`,`edit`],[`multiedit`,`edit`],[`write`,`edit`],[`notebookedit`,`edit`],[`filechange`,`edit`],[`read`,`read`],[`imageview`,`read`],[`glob`,`search`],[`grep`,`search`],[`webfetch`,`fetch`],[`websearch`,`fetch`],[`task`,`task`],[`agent`,`task`],[`skill`,`task`],[`todowrite`,`plan`],[`todolist`,`plan`],[`plan`,`plan`],[`taskcreate`,`plan`],[`taskupdate`,`plan`],[`tasklist`,`plan`],[`contextcompaction`,`other`],[`mcptoolcall`,`other`]]);function pe(e,t){switch(e){case`write`:return{toolKind:`edit`,title:T(`Write`,C(t,`file_path`,`filePath`,`path`))};case`notebookedit`:return{toolKind:`edit`,title:T(`Edit`,C(t,`notebook_path`,`notebookPath`,`file_path`,`filePath`,`path`))};case`filechange`:{let e=de(t);return{toolKind:`edit`,title:T(`Edit`,e.length===1?e[0]:e.length>1?`${e.length} files`:void 0)}}default:return{toolKind:`edit`,title:T(`Edit`,C(t,`file_path`,`filePath`,`path`))}}}function me(e,t){return e===`imageview`?{toolKind:`read`,title:T(`View image`,C(t,`path`))}:{toolKind:`read`,title:T(`Read`,C(t,`file_path`,`filePath`,`path`))}}function he(e,t){return e===`webfetch`?{toolKind:`fetch`,title:T(`Fetch`,C(t,`url`))}:{toolKind:`fetch`,title:T(`Web search`,C(t,`query`))}}function ge(e,t){if(e===`skill`){let e=C(t,`skill`,`name`,`command`);return{toolKind:`task`,title:e?`Skill: ${e}`:`Skill`,subtitle:C(t,`args`,`description`)}}let n=e===`agent`?`Agent`:`Task`,r=C(t,`subagent_type`,`subagentType`),i=C(t,`description`,`prompt`)??r;return{toolKind:`task`,title:i?`${n}: ${i}`:n,subtitle:i===r?void 0:r}}function _e(e,t,n){if(t===`contextcompaction`)return{toolKind:`other`,title:`Compacted context`};if(t===`mcptoolcall`){let e=C(n,`server`),t=C(n,`tool`);return e&&t?{toolKind:`other`,title:`${e}.${t}`}:{toolKind:`other`,title:`MCP tool`,subtitle:w(n)}}if(t.startsWith(`mcp__`)){let t=e.split(`__`).filter(e=>e!==``);if(t.length>=3)return{toolKind:`other`,title:`${t[1]}.${t.slice(2).join(`__`)}`}}return{toolKind:`other`,title:typeof e==`string`&&e.trim()!==``?S(e):`Tool`,subtitle:w(n)}}function ve(e,t){let n=typeof e==`string`?e.toLowerCase():``;switch(fe.get(n)){case`execute`:return{toolKind:`execute`,title:T(`Ran`,ue(t)),subtitle:C(t,`description`)};case`edit`:return pe(n,t);case`read`:return me(n,t);case`search`:return{toolKind:`search`,title:T(`Search`,C(t,`pattern`,`query`)),subtitle:C(t,`path`)};case`fetch`:return he(n,t);case`task`:return ge(n,t);case`plan`:return{toolKind:`plan`,title:`Update plan`};default:return _e(e,n,t)}}function ye(e,t){if(t.type===`ask.requested`&&typeof t.requestId==`string`&&a.safeParse({questions:t.questions}).success)return t;if(t.type===`human-input-delivered`||t.type===`human-ask-closed`){let n=(t.type===`human-input-delivered`?l:ee).safeParse(t);if(n.success&&n.data.askSeq===e?.seq)return}return e}function E(e){if(!(e.type!==`ask.requested`||typeof e.requestId!=`string`))return{requestId:e.requestId,questions:e.questions,...e.context===void 0?{}:{context:e.context}}}function D(e){let t=E(e);return t&&{seq:e.seq,...t}}function O(e,t){let n=ye(e&&{type:`ask.requested`,seq:e.seq,ts:``},t);return n===t?D(t):n===void 0?void 0:e}function k(e){let t;for(let n of e)t=O(t,n);return t}function A(e){let t=Array.isArray(e.questions)?e.questions.filter(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e.header==`string`&&(e.options===void 0||Array.isArray(e.options))):[];if(t.length===0)return;let n=typeof e.context==`string`&&e.context!==``?e.context:void 0;return{id:e.requestId,questions:t,...n===void 0?{}:{context:n},askSeq:e.seq}}function j(){return{turns:[],itemsById:new Map,turnSeq:0,permissions:new Map,conversationEntries:new Map,outcomesByRequest:new Map,seenInputs:new Set,previewByPort:new Map,handedOff:!1}}function M(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function N(e){return typeof e==`string`?e:void 0}function P(e){let t=typeof e==`string`?new Date(e):void 0;return!t||Number.isNaN(t.getTime())?``:` · ${t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}`}function F(e){if(!(typeof e!=`string`||e===``))return Number.isFinite(new Date(e).getTime())?e:void 0}var be=new Set(o.options);function xe(e){return typeof e==`string`&&be.has(e)?e:void 0}function I(e,t){e.turnSeq+=1;let n={id:t===void 0?`turn-fallback-${e.turnSeq}`:`turn-seq-${t}`,entries:[],v2Items:!1};return e.turns.push(n),n}function L(e){return e.turns.at(-1)??I(e)}function R(e,t){L(e).entries.push({origin:`meta`,entry:t})}function z(e){for(let t of e.permissions.values())t.status===`pending`&&(t.status=`expired`)}function B(e,t){let n=N(e.stepId);return n===void 0?t:`${n}:${t}`}function Se(e,t){t.v2Items=!0;for(let n of t.entries)n.origin===`v1`&&n.entry.kind===`tool`&&e.itemsById.delete(n.entry.id);t.entries=t.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`tool`))}function Ce(e,t,n,r,i){let a=n.kind===`message`&&i!==void 0?{...n,ts:i}:{...n};!t.v2Items&&a.kind!==`hook`&&Se(e,t);let o=e.itemsById.get(r);if(o&&o.turn===t){o.entry.entry=a;return}let s={origin:`v2`,entry:a};t.entries.push(s),e.itemsById.set(r,{turn:t,entry:s})}var V={"not-delivered":0,queued:1,delivered:2,consumed:3},we=[`instruction`,`resumed`,`requestId`,`relationship`,`state`,`createdAt`,`requestHash`,`deadline`];function H(e){let t={};for(let n of we)e[n]!==void 0&&Object.assign(t,{[n]:e[n]});return t}function U(e,t){if(t.messageKind!==`request`)return;let n=e.outcomesByRequest.get(t.messageId);n&&(t.outcome={status:n.status,...n.replyId===void 0?{}:{replyId:n.replyId},observedAt:n.observedAt})}function Te(e,t){let n=e.conversationEntries.get(t);n&&U(e,n)}function Ee(e,t,n,r){(V[e.delivery]<V.delivered||V[n]>V[e.delivery])&&(e.delivery=n),t.text!==``&&(e.text=t.text),Object.assign(e,H(t)),r.deliveredAt!==void 0&&(e.deliveredAt=r.deliveredAt),r.consumedAt!==void 0&&(e.consumedAt=r.consumedAt),r.recordedAt!==void 0&&(n===`delivered`||e.delivery!==`delivered`)&&(e.recordedAt=r.recordedAt)}function W(e,t,n,r){let i=e.conversationEntries.get(t.id);if(i){Ee(i,t,n,r),U(e,i);return}let a={kind:`conversation`,id:`conversation-message:${t.id}`,messageId:t.id,text:t.text,senderRunId:t.senderRunId,recipientRunId:t.recipientRunId,messageKind:t.kind,delivery:n,...r,...H(t)};U(e,a),e.conversationEntries.set(t.id,a),R(e,a)}function De(e,t){let n=P(t.ts),r=N(t.message),i=t.notify===!1?`Stopped notifying the webhook${n}`:`${e.handedOff?`Note sent to webhook`:`Handed off to webhook`}${n}${r?` — ${r}`:``}`;e.handedOff=t.notify!==!1,R(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`dim`,icon:`handoff`})}function Oe(e,t){let n=typeof t.attempts==`number`?t.attempts:void 0,r=N(t.webhookName),i=`${r?`Delivery to ${r} failed`:`Webhook delivery failed`}${N(t.event)?` (${N(t.event)})`:``}${n?` after ${n} attempt${n===1?``:`s`}`:``}: ${N(t.error)??`unknown error`}`;R(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`danger`})}function ke(e,t){let n=N(t.webhookName)??`webhook`,r=N(t.title),i=`v1:${t.seq}`;if(t.ok===!1){R(e,{kind:`note`,id:i,text:`Report to ${n} failed: ${N(t.error)??`unknown error`}`,tone:`danger`});return}let a=`${t.dryRun===!0?`Report to ${n} (dry run, nothing sent)`:`Sent report to ${n}`}${P(t.ts)}${r?` — ${r}`:``}`;R(e,t.dryRun===!0?{kind:`note`,id:i,text:a,tone:`dim`}:{kind:`note`,id:i,text:a,tone:`dim`,icon:`handoff`})}function Ae(e,t){let n=t.payload??{},r=`Webhook (dry run, nothing sent): ${N(t.event)??`delivery`}${N(n.status)?` · ${N(n.status)}`:``}`;R(e,{kind:`note`,id:`v1:${t.seq}`,text:r,tone:`dim`})}function je(e,t){let n=i.safeParse(t.server);if(!n.success)return;let r=e.previewByPort.get(n.data.port);r&&(r.turn.entries=r.turn.entries.filter(e=>e!==r.draft));let a=L(e),o={origin:`meta`,entry:{kind:`preview-server`,id:`preview-server:${n.data.port}`,server:n.data,state:`registered`,stateAt:t.ts}};a.entries.push(o),e.previewByPort.set(n.data.port,{turn:a,draft:o})}function Me(e,t){let n=r.safeParse(t.state),i=typeof t.port==`number`?e.previewByPort.get(t.port):void 0;if(!n.success||!i||i.draft.entry.kind!==`preview-server`)return;let{server:a,id:o}=i.draft.entry;i.draft.entry={kind:`preview-server`,id:o,server:a,state:n.data,stateAt:t.ts,...typeof t.exitCode==`number`?{exitCode:t.exitCode}:{},...t.reason===`user`||t.reason===`idle`?{reason:t.reason}:{}}}function Ne(e,t){let n=u.safeParse(t);if(!n.success)return;let{message:r,delivery:i,deliveredAt:a,consumedAt:o,ts:s}=n.data;W(e,r,i,{deliveredAt:a,consumedAt:o,recordedAt:s})}function Pe(e,t){let n=s.safeParse(t);if(!n.success)return;let{outcome:r}=n.data,i=e.outcomesByRequest.get(r.requestId);i&&!(i.status===`timed-out`&&r.status===`replied-late`)||(e.outcomesByRequest.set(r.requestId,r),Te(e,r.requestId))}function Fe(e,t){let n=c.safeParse(t);if(!n.success)return;let{input:r}=n.data;if(!e.seenInputs.has(r.id)){if(e.seenInputs.add(r.id),r.conversation){W(e,{id:r.id,text:r.text,createdAt:r.createdAt,...r.conversation},`delivered`,{deliveredAt:r.deliveredAt,recordedAt:n.data.ts});return}R(e,{kind:`note`,id:`agent-input:${r.id}`,text:r.text,tone:`dim`,attribution:{source:r.source,parentRunId:r.parentRunId}})}}function Ie(e,t){let n=N(t.text)??``,r=e.pendingAsk;e.pendingAsk&&!e.pendingAsk.resolved&&(e.pendingAsk.resolved=!0,e.pendingAsk.answeredBy=`human`,n!==``&&(e.pendingAsk.answer=n),e.pendingAsk=void 0);let i=I(e,t.seq),a=F(t.ts);i.userMessage={text:n,ask:r,imageCount:typeof t.imageCount==`number`?t.imageCount:0,images:Array.isArray(t.images)?t.images.filter(e=>typeof e==`string`):[],...a===void 0?{}:{ts:a}},a!==void 0&&(i.startedAt=a)}function Le(e,t){let n=e.turns.at(-1),r=n&&n.turnId===void 0&&!n.v2Items?n:I(e,t.seq);r.turnId=N(t.turnId),r.startedAt??=F(t.ts)}function Re(e,t){for(let n=e.turns.length-1;n>=0;--n)if(e.turns[n].turnId===t)return e.turns[n];return e.turns.at(-1)}function ze(e,t){z(e);let n=Re(e,N(t.turnId));if(!n)return;let r=F(t.ts);n.completed={stopReason:N(t.stopReason)??`end_turn`,...typeof t.costUsd==`number`?{costUsd:t.costUsd}:{},...r===void 0?{}:{ts:r}}}var G=new Set([`message`,`reasoning`,`tool`,`hook`]),Be=e=>G.has(e.kind);function Ve(e){if(!(!M(e)||!G.has(e.kind)))return typeof e.id==`string`&&e.id!==``?e:void 0}function K(e,t){let n=Ve(t.item);if(!n)return;let r=B(t,n.id);Ce(e,e.itemsById.get(r)?.turn??L(e),n,r,t.type===`item.completed`?F(t.ts):void 0)}function He(e,t){let n=e.itemsById.get(B(t,N(t.itemId)??``)),r=N(t.delta)??``;if(!n||r===``||!Be(n.entry.entry))return;let i=n.entry.entry;t.field===`output`&&i.kind===`tool`?i.output=(i.output??``)+r:t.field!==`output`&&(i.kind===`message`||i.kind===`reasoning`)&&(i.text+=r)}function Ue(e,t){let n=L(e),r=N(t.text)??``;if(r===``)return;let i=F(t.ts);n.entries.push({origin:`v1`,entry:{kind:`message`,id:`v1:${t.seq}`,role:`assistant`,text:r,...i===void 0?{}:{ts:i}}})}var We=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function Ge(e){if(!M(e)||!Array.isArray(e.todos))return;let t=[];for(let n of e.todos){if(!M(n)||typeof n.content!=`string`)return;t.push({content:n.content,status:We.has(n.status)?n.status:`pending`,...typeof n.activeForm==`string`?{activeForm:n.activeForm}:{}})}return t}var Ke=new Set([`subAgentActivity`,`collabAgentToolCall`,`collabToolCall`]);function qe(e,t){let n=L(e),r=N(t.tool)??`Tool`;if(n.v2Items||Ke.has(r))return;let i=ve(r,t.input),a=i.toolKind===`plan`?Ge(t.input):void 0;a!==void 0&&(n.planEntries=a);let o={kind:`tool`,id:N(t.id)??`v1:${t.seq}`,name:r,toolKind:i.toolKind,title:i.title,status:`running`,input:t.input},s={origin:`v1`,entry:o};n.entries.push(s),e.itemsById.set(o.id,{turn:n,entry:s})}function Je(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}}function Ye(e,t){let n=e.itemsById.get(N(t.toolCallId)??``);if(!n||n.turn.v2Items||n.entry.origin!==`v1`)return;let r=n.entry.entry;r.kind===`tool`&&(r.status=`completed`,r.output=Je(t.result))}function q(e,t,n,r){let i=N(t.message)??``;i!==``&&R(e,{kind:`note`,id:n,text:i,tone:r})}function J(e,t){q(e,t,`v1:${t.seq}`,t.tone===`danger`?`danger`:`dim`)}function Xe(e,t){q(e,t,`v1:${t.seq}`,`danger`)}function Ze(e,t){q(e,t,`v2:${t.seq}`,`danger`)}function Qe(e,t){if(t.status!==`failed`)return;let n=N(t.error)?` — ${N(t.error)}`:``;R(e,{kind:`note`,id:`v1:${t.seq}`,text:`step ${N(t.stepId)??`?`} failed${n}`,tone:`danger`})}function $e(e,t){let n=N(t.command)??`check`,r=typeof t.exitCode==`number`?t.exitCode:-1;R(e,{kind:`tool`,id:`v1:${t.seq}`,name:`check`,toolKind:`execute`,title:`Ran ${n}`,status:r===0?`completed`:`failed`,output:N(t.text)??``,exitCode:r})}function et(e,t){let n=xe(t.provider),r=N(t.authFailureId)??``;n===void 0||r.length<1||r.length>128||R(e,{kind:`provider-auth-required`,id:`v1:${t.seq}`,provider:n,authFailureId:r})}function tt(e,t){let n=N(t.url);if(n===void 0)return;let r={kind:`image`,id:`v1:${t.seq}`,url:n},i=N(t.name);i!==void 0&&(r.name=i),R(e,r)}function nt(e,t){Array.isArray(t.entries)&&(L(e).planEntries=t.entries)}function rt(e,t){z(e);let n=N(t.message);e.sessionEnded={reason:N(t.reason)??`end_turn`,...n===void 0?{}:{message:n}}}var it=new Set([`allow_once`,`allow_always`,`reject_once`,`reject_always`]);function at(e){return M(e)&&typeof e.id==`string`&&e.id!==``&&typeof e.label==`string`&&e.label!==``&&it.has(e.kind)}function ot(e){if(!(!Array.isArray(e)||e.length===0||!e.every(at)))return new Set(e.map(e=>e.id)).size===e.length?e:void 0}function st(e,t){let n=N(t.requestId),r=N(t.title),i=ot(t.options);if(!n||!r||e.permissions.has(n)||!i)return;let a=N(t.itemId),o=N(t.details),s={kind:`permission`,id:`permission:${n}`,requestId:n,title:r,options:i.map(e=>({...e})),status:`pending`,...a===void 0?{}:{itemId:a},...o===void 0?{}:{details:o}};e.permissions.set(n,s),R(e,s)}function ct(e,t){let n=e.permissions.get(N(t.requestId)??``);if(!n||n.status!==`pending`)return;let r=N(t.optionId);r!==void 0&&n.options.some(e=>e.id===r)?(n.status=`resolved`,n.optionId=r):n.status=`expired`;let i=N(t.reason);i!==void 0&&(n.reason=i)}function lt(e,t){let n=D(t),r=n&&A(n);if(!r)return;let i={kind:`ask`,...r,questions:r.questions,resolved:!1};R(e,i),e.pendingAsk=i}function Y(e,t){let n=e.pendingAsk;return n&&!n.resolved&&n.askSeq===t.askSeq?n:void 0}function ut(e,t){let n=Y(e,t);if(!n)return;n.routedToParent=!0;let r=N(t.parentRunId);r!==void 0&&(n.parentRunId=r)}function dt(e,t){let n=Y(e,t);n&&(n.routedToParent=!1)}function ft(e,t){let n=Y(e,t);n&&X(e,n,`undeliverable`)}var pt=new Set([`finish`,`superseded`,`parent-stopped`,`worker-stopped`,`undeliverable`]);function mt(e,t){let n=Y(e,t);n&&pt.has(t.reason)&&X(e,n,t.reason)}function X(e,t,n){t.resolved=!0,t.closed=n,e.pendingAsk=void 0}function Z(e,t){let n=Y(e,t);if(n){if(t.source===`cezar`){X(e,n,`undeliverable`);return}t.source===`parent`&&(n.resolved=!0,n.answeredBy=`parent`,e.pendingAsk=void 0)}}var Q=()=>{},ht=new Map([[`handoff`,De],[`webhook.failed`,Oe],[`webhook.dry-run`,Ae],[`webhook.report`,ke],[`preview.server-registered`,je],[`preview.server-state`,Me],[`conversation-message`,Ne],[`request-outcome`,Pe],[`agent-input`,Fe],[`user-message`,Ie],[`turn.started`,Le],[`turn.completed`,ze],[`item.started`,K],[`item.updated`,K],[`item.completed`,K],[`item.delta`,He],[`text`,Ue],[`tool-call`,qe],[`tool-result`,Ye],[`note`,J],[`lifecycle`,J],[`error`,Xe],[`session.error`,Ze],[`step-end`,Qe],[`check-output`,$e],[`provider-auth-required`,et],[`image`,tt],[`plan.updated`,nt],[`session.started`,e=>z(e)],[`session.ended`,rt],[`permission.requested`,st],[`permission.resolved`,ct],[`ask.requested`,lt],[`worker-question-routed`,ut],[`worker-question-fallback`,dt],[`worker-question-undelivered`,ft],[`human-ask-closed`,mt],[`human-input-delivered`,Z],[`step-start`,Q],[`token-usage`,Q],[`cost`,Q],[`turn-end`,Q],[`done`,Q],[`session`,Q]]);function gt(e,t){ht.get(t.type)?.(e,t)}function _t(e){for(let t=e.turns.length-1;t>=0;--t){let n=e.turns[t].planEntries;if(n!==void 0)return n}}function vt(e){let t=[];for(let n of e.turns)for(let e of n.items)if(e.kind===`tool`){for(let n of e.locations??[])t.push(n.path);for(let n of e.diffs??[])t.push(n.path)}let n=[];for(let e=t.length-1;e>=0;--e)n.includes(t[e])||n.push(t[e]);return n}function yt(e,t){switch(e){case`waiting`:return{state:`waiting`};case`failed`:return{state:`closed`,tone:`danger`,label:t?`Session failed — ${t}`:`Session failed`};case`review`:return{state:`closed`,tone:`dim`,label:`Session closed — waiting for your review`};case`done`:case`cancelled`:return{state:`closed`,tone:`dim`,label:`Session closed`};default:return null}}function $(e,t){let n=e.replace(/\s*CEZ:DONE\s*$/,``).replace(/\s*CEZ:MONITORING\s*$/,``);if(t){let e=n.trimEnd(),t=e.lastIndexOf(`
2
2
  `)+1;/^CEZ:ASK[ \t]+.+$/.test(e.slice(t))&&(n=e.slice(0,t).trimEnd())}return n.includes(`CEZ:`)?n.split(`
3
3
  `).filter(e=>!/^CEZ:(?:PR=\d+|ISSUE=\d+|TITLE=.+)\s*$/.test(e)).join(`
4
4
  `):n}function bt(e){let t=e=>$(e,!0).replace(/\s+/g,``),n=new Set,r=[];for(let{origin:i,entry:a}of e.entries)if(i===`v2`&&a.kind===`message`){let e=t(a.text);n.add(e),r.push(e)}if(r.length===0)return;n.add(r.join(``));let i=[],a={entries:[],texts:[]},o=()=>{if(a.entries.length>=2&&n.has(t(a.texts.join(``)))){a={entries:[],texts:[]};return}i.push(...a.entries),a={entries:[],texts:[]}};for(let t of e.entries)t.origin===`v1`&&t.entry.kind===`message`?(a.entries.push(t),a.texts.push(t.entry.text)):(o(),i.push(t));o(),e.entries=i}function xt(e){let t=new Set;for(let{origin:n,entry:r}of e.entries)n===`v2`&&r.kind===`message`&&t.add($(r.text,!0).trim());t.size!==0&&(e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`message`&&t.has($(e.entry.text,!0).trim()))),bt(e))}function St(e){for(let t of e.conversationEntries.values())t.messageKind!==`request`||t.outcome!==void 0||t.delivery!==`not-delivered`&&(t.state!==void 0&&t.state!==`accepted`||(t.outcome={status:`pending`}))}function Ct(e,t){let n=t||e.entries.some(({entry:e})=>e.kind===`ask`);return{id:e.id,...e.turnId===void 0?{}:{turnId:e.turnId},...e.userMessage===void 0?{}:{userMessage:e.userMessage},...e.startedAt===void 0?{}:{startedAt:e.startedAt},...e.planEntries===void 0?{}:{planEntries:e.planEntries},...e.completed===void 0?{}:{completed:e.completed},items:e.entries.map(({entry:e})=>e.kind===`message`&&e.role===`assistant`?{...e,text:$(e.text,n)}:e)}}function wt(e,t={}){let n=j();for(let t of e)gt(n,t);for(let e of n.turns)e.v2Items&&xt(e);St(n);let r=n.turns.length-1;return{turns:n.turns.map((e,n)=>Ct(e,t.activeTurn===!0&&n===r)),...n.sessionEnded===void 0?{}:{sessionEnded:n.sessionEnded}}}export{k as a,m as c,yt as i,wt as n,ce as o,vt as r,h as s,_t as t};