@wjarka/cezarion 0.16.0-dev.1503 → 0.16.0-pr923.1504

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 (79) hide show
  1. package/README.md +15 -4
  2. package/dist/contract/index.js +3 -0
  3. package/dist/contract/runs.d.ts +30 -0
  4. package/dist/contract/skills.d.ts +4 -0
  5. package/dist/core/agent-runner.d.ts +9 -6
  6. package/dist/core/agent-runner.js +4 -2
  7. package/dist/core/agent-runner.js.map +1 -1
  8. package/dist/core/cursor-print-capabilities.d.ts +12 -0
  9. package/dist/core/cursor-print-capabilities.js +77 -0
  10. package/dist/core/cursor-print-capabilities.js.map +1 -0
  11. package/dist/core/cursor-print-process.d.ts +31 -0
  12. package/dist/core/cursor-print-process.js +129 -0
  13. package/dist/core/cursor-print-process.js.map +1 -0
  14. package/dist/core/cursor-print-runner.d.ts +26 -0
  15. package/dist/core/cursor-print-runner.js +512 -0
  16. package/dist/core/cursor-print-runner.js.map +1 -0
  17. package/dist/core/cursor-print-tool-catalog.d.ts +6 -0
  18. package/dist/core/cursor-print-tool-catalog.js +78 -0
  19. package/dist/core/cursor-print-tool-catalog.js.map +1 -0
  20. package/dist/core/cursor-print-ui-mapper.d.ts +47 -0
  21. package/dist/core/cursor-print-ui-mapper.js +573 -0
  22. package/dist/core/cursor-print-ui-mapper.js.map +1 -0
  23. package/dist/core/cursor-runner.d.ts +24 -0
  24. package/dist/core/cursor-runner.js +146 -0
  25. package/dist/core/cursor-runner.js.map +1 -0
  26. package/dist/core/process-usage.d.ts +5 -0
  27. package/dist/core/process-usage.js +24 -4
  28. package/dist/core/process-usage.js.map +1 -1
  29. package/dist/core/runner-factory.d.ts +4 -1
  30. package/dist/core/runner-factory.js +3 -3
  31. package/dist/core/runner-factory.js.map +1 -1
  32. package/dist/delegation/transport.d.ts +13 -13
  33. package/dist/runs/store.d.ts +9 -0
  34. package/dist/runs/store.js +1 -0
  35. package/dist/runs/store.js.map +1 -1
  36. package/dist/server/server.d.ts +118 -92
  37. package/dist/workflows/run.js +39 -8
  38. package/dist/workflows/run.js.map +1 -1
  39. package/package.json +3 -3
  40. package/scripts/mock-ci-tool.mjs +12 -4
  41. package/scripts/mock-cursor-acp.mjs +1 -0
  42. package/scripts/mock-cursor-print.mjs +196 -0
  43. package/scripts/probe-cursor-print.mjs +616 -0
  44. package/web/dist/assets/{agent-accounts-CFOBMVHc.js → agent-accounts-CDhVzwnd.js} +1 -1
  45. package/web/dist/assets/{alert-dialog-BrpNUwMt.js → alert-dialog-A0-kEfJK.js} +1 -1
  46. package/web/dist/assets/{button-C_rd7CPp.js → button-Jj1Itx83.js} +1 -1
  47. package/web/dist/assets/{compare-variants-D6WXhvXA.js → compare-variants-aor2j4bO.js} +1 -1
  48. package/web/dist/assets/{diff-DrEARXTV.js → diff-CDL5SDNO.js} +2 -2
  49. package/web/dist/assets/{diff-controls-B1-j7nFg.js → diff-controls-BWAkxipD.js} +1 -1
  50. package/web/dist/assets/{diff-view-DvGLjdTk.js → diff-view-DWh9FnNY.js} +1 -1
  51. package/web/dist/assets/{dropdown-menu-BegOZFrj.js → dropdown-menu-Ddqp8eUw.js} +1 -1
  52. package/web/dist/assets/{format-DpNe3S0A.js → format-DTNjugyE.js} +1 -1
  53. package/web/dist/assets/{git-toolbar-Cw4ljmhB.js → git-toolbar-B4rwm9Lr.js} +1 -1
  54. package/web/dist/assets/{github-CfV5sqL0.js → github-DgMD1v4U.js} +1 -1
  55. package/web/dist/assets/{image-preview-FOEfqpZP.js → image-preview-Dy5i96RC.js} +1 -1
  56. package/web/dist/assets/{index-DgWWlOLy.js → index-BfAearY6.js} +4 -4
  57. package/web/dist/assets/{nav-row-styles-vp2JbhuJ.js → nav-row-styles-Ci-Ke7wG.js} +1 -1
  58. package/web/dist/assets/{popover-BohP6WTx.js → popover-BjjDOSGv.js} +1 -1
  59. package/web/dist/assets/{preview-pane-connected-qTA5KNoJ.js → preview-pane-connected-Nv_nhV63.js} +1 -1
  60. package/web/dist/assets/{preview-state-vuMviq6q.js → preview-state-D8-YBJ6m.js} +1 -1
  61. package/web/dist/assets/{prompt-templates-Cubdut_C.js → prompt-templates-DFeXUVOZ.js} +1 -1
  62. package/web/dist/assets/{repo-git-Cf4t5PD0.js → repo-git-DcWh5s_b.js} +1 -1
  63. package/web/dist/assets/{run-diff-BpkUW37Z.js → run-diff-1ZzFrOx1.js} +1 -1
  64. package/web/dist/assets/{run-header-68WHf9wV.js → run-header-CPoYzbAy.js} +1 -1
  65. package/web/dist/assets/{skills-DiVIgKeU.js → skills-CnLazLgF.js} +1 -1
  66. package/web/dist/assets/{status-dot-CqTJHSP9.js → status-dot-DwFmt_Jg.js} +1 -1
  67. package/web/dist/assets/{tab-link-B07Hu4QX.js → tab-link-COpvArgR.js} +1 -1
  68. package/web/dist/assets/{task-changes--lQF6EYf.js → task-changes-CY-mi-mC.js} +1 -1
  69. package/web/dist/assets/{task-commits-Cx0qy4DN.js → task-commits-EvLi8T4a.js} +1 -1
  70. package/web/dist/assets/{task-files-D50s-gKW.js → task-files-BR3d8X2U.js} +1 -1
  71. package/web/dist/assets/{task-github-item-DaqmSwYT.js → task-github-item-BVsPg9RI.js} +1 -1
  72. package/web/dist/assets/{task-thread-BPQ64lui.js → task-thread-DQCsu_v8.js} +1 -1
  73. package/web/dist/assets/{textarea-D20O4Pw0.js → textarea-BbNV5Uo2.js} +1 -1
  74. package/web/dist/assets/{thread-state-DWcFMrvb.js → thread-state-DTkIvHsU.js} +1 -1
  75. package/web/dist/assets/{use-hand-to-agent-state-Cy9eyyfL.js → use-hand-to-agent-state-DT-QBsPC.js} +1 -1
  76. package/web/dist/assets/{utils-JsL3ZsJf.js → utils-POVs3UKu.js} +1 -1
  77. package/web/dist/assets/{workflows-jwG7uxqi.js → workflows-BTE-5RwX.js} +1 -1
  78. package/web/dist/assets/{zoomable-image-BJJ64KGc.js → zoomable-image-cL1VgYK4.js} +1 -1
  79. package/web/dist/index.html +13 -13
@@ -1 +1 @@
1
- import"./rolldown-runtime-QTnfLwEv.js";import{i as e,t}from"./react-runtime-CCIEwYL0.js";import{Bt as n,t as r}from"./button-C_rd7CPp.js";import{t as i}from"./utils-JsL3ZsJf.js";import{d as a,f as o,h as s,l as c,m as l,p as u,u as d}from"./alert-dialog-BrpNUwMt.js";e();var f=t();function p({...e}){return(0,f.jsx)(c,{"data-slot":`dialog`,...e})}function m({...e}){return(0,f.jsx)(l,{"data-slot":`dialog-portal`,...e})}function h({className:e,...t}){return(0,f.jsx)(u,{"data-slot":`dialog-overlay`,className:i(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function g({className:e,children:t,showCloseButton:r=!0,...o}){return(0,f.jsxs)(m,{"data-slot":`dialog-portal`,children:[(0,f.jsx)(h,{}),(0,f.jsxs)(a,{"data-slot":`dialog-content`,className:i(`fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-card p-6 shadow-modal duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg`,e),...o,children:[t,r&&(0,f.jsxs)(d,{"data-slot":`dialog-close`,className:`absolute top-4 right-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,f.jsx)(n,{}),(0,f.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function _({className:e,...t}){return(0,f.jsx)(`div`,{"data-slot":`dialog-header`,className:i(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function v({className:e,showCloseButton:t=!1,children:n,...a}){return(0,f.jsxs)(`div`,{"data-slot":`dialog-footer`,className:i(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...a,children:[n,t&&(0,f.jsx)(d,{asChild:!0,children:(0,f.jsx)(r,{variant:`outline`,children:`Close`})})]})}function y({className:e,...t}){return(0,f.jsx)(s,{"data-slot":`dialog-title`,className:i(`text-lg leading-none font-semibold`,e),...t})}function b({className:e,...t}){return(0,f.jsx)(o,{"data-slot":`dialog-description`,className:i(`text-sm text-muted-foreground`,e),...t})}function x({className:e,...t}){return(0,f.jsx)(`textarea`,{"data-slot":`textarea`,className:i(`flex field-sizing-content min-h-16 w-full resize-none rounded-md border border-input bg-[var(--task-brand-bg)] px-3 py-2 text-base shadow-none transition-[color,box-shadow] outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm`,e),...t})}export{v as a,b as i,p as n,_ as o,g as r,y as s,x as t};
1
+ import"./rolldown-runtime-QTnfLwEv.js";import{i as e,t}from"./react-runtime-CCIEwYL0.js";import{Bt as n,t as r}from"./button-Jj1Itx83.js";import{t as i}from"./utils-POVs3UKu.js";import{d as a,f as o,h as s,l as c,m as l,p as u,u as d}from"./alert-dialog-A0-kEfJK.js";e();var f=t();function p({...e}){return(0,f.jsx)(c,{"data-slot":`dialog`,...e})}function m({...e}){return(0,f.jsx)(l,{"data-slot":`dialog-portal`,...e})}function h({className:e,...t}){return(0,f.jsx)(u,{"data-slot":`dialog-overlay`,className:i(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function g({className:e,children:t,showCloseButton:r=!0,...o}){return(0,f.jsxs)(m,{"data-slot":`dialog-portal`,children:[(0,f.jsx)(h,{}),(0,f.jsxs)(a,{"data-slot":`dialog-content`,className:i(`fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-card p-6 shadow-modal duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg`,e),...o,children:[t,r&&(0,f.jsxs)(d,{"data-slot":`dialog-close`,className:`absolute top-4 right-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,f.jsx)(n,{}),(0,f.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function _({className:e,...t}){return(0,f.jsx)(`div`,{"data-slot":`dialog-header`,className:i(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function v({className:e,showCloseButton:t=!1,children:n,...a}){return(0,f.jsxs)(`div`,{"data-slot":`dialog-footer`,className:i(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...a,children:[n,t&&(0,f.jsx)(d,{asChild:!0,children:(0,f.jsx)(r,{variant:`outline`,children:`Close`})})]})}function y({className:e,...t}){return(0,f.jsx)(s,{"data-slot":`dialog-title`,className:i(`text-lg leading-none font-semibold`,e),...t})}function b({className:e,...t}){return(0,f.jsx)(o,{"data-slot":`dialog-description`,className:i(`text-sm text-muted-foreground`,e),...t})}function x({className:e,...t}){return(0,f.jsx)(`textarea`,{"data-slot":`textarea`,className:i(`flex field-sizing-content min-h-16 w-full resize-none rounded-md border border-input bg-[var(--task-brand-bg)] px-3 py-2 text-base shadow-none transition-[color,box-shadow] outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm`,e),...t})}export{v as a,b as i,p as n,_ as o,g as r,y as s,x as t};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Gi as r,Wi as i,fr as a,pr as o,t as s,ta as c}from"./button-C_rd7CPp.js";import{I as l,L as u,N as d,P as f,R as p,i as m,s as h,t as g}from"./utils-JsL3ZsJf.js";import{t as _}from"./createLucideIcon-BHp8sXmF.js";import{t as v}from"./app-window-CSHwDX9N.js";import{t as y}from"./status-dot-CqTJHSP9.js";import{a as b,d as x,i as S}from"./preview-state-vuMviq6q.js";import{n as C}from"./format-DpNe3S0A.js";import{t as w}from"./play-CmVAj_fu.js";import{t as T}from"./square-terminal-B6RYYieR.js";var E=120;function D(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function O(e){let t=e.replace(/\s+/g,` `).trim();return t.length>E?`${t.slice(0,E-1)}…`:t}function k(e,...t){if(D(e))for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return O(t)}}function ee(e){if(!D(e))return;let t=e.command;if(typeof t==`string`&&t.trim()!==``)return O(t);if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return O(e.join(` `))}}function A(e){if(!D(e)||!Array.isArray(e.changes))return[];let t=[];for(let n of e.changes)D(n)&&typeof n.path==`string`&&n.path.trim()!==``&&t.push(n.path);return t}function j(e){return k(e,`description`,`query`,`url`,`filePath`,`file_path`,`path`,`pattern`,`name`)}function M(e,t){return t?`${e} ${t}`:e}function N(e,t){let n=typeof e==`string`?e.toLowerCase():``;switch(n){case`bash`:case`commandexecution`:return{toolKind:`execute`,title:M(`Ran`,ee(t)),subtitle:k(t,`description`)};case`edit`:case`multiedit`:return{toolKind:`edit`,title:M(`Edit`,k(t,`file_path`,`filePath`,`path`))};case`write`:return{toolKind:`edit`,title:M(`Write`,k(t,`file_path`,`filePath`,`path`))};case`notebookedit`:return{toolKind:`edit`,title:M(`Edit`,k(t,`notebook_path`,`notebookPath`,`file_path`,`filePath`,`path`))};case`filechange`:{let e=A(t);return{toolKind:`edit`,title:M(`Edit`,e.length===1?e[0]:e.length>1?`${e.length} files`:void 0)}}case`read`:return{toolKind:`read`,title:M(`Read`,k(t,`file_path`,`filePath`,`path`))};case`imageview`:return{toolKind:`read`,title:M(`View image`,k(t,`path`))};case`glob`:case`grep`:return{toolKind:`search`,title:M(`Search`,k(t,`pattern`,`query`)),subtitle:k(t,`path`)};case`webfetch`:return{toolKind:`fetch`,title:M(`Fetch`,k(t,`url`))};case`websearch`:return{toolKind:`fetch`,title:M(`Web search`,k(t,`query`))};case`task`:case`agent`:{let e=n===`agent`?`Agent`:`Task`,r=k(t,`subagent_type`,`subagentType`),i=k(t,`description`,`prompt`)??r;return{toolKind:`task`,title:i?`${e}: ${i}`:e,subtitle:i===r?void 0:r}}case`skill`:{let e=k(t,`skill`,`name`,`command`);return{toolKind:`task`,title:e?`Skill: ${e}`:`Skill`,subtitle:k(t,`args`,`description`)}}case`todowrite`:case`todolist`:case`plan`:case`taskcreate`:case`taskupdate`:case`tasklist`:return{toolKind:`plan`,title:`Update plan`};case`contextcompaction`:return{toolKind:`other`,title:`Compacted context`};case`mcptoolcall`:{let e=k(t,`server`),n=k(t,`tool`);return e&&n?{toolKind:`other`,title:`${e}.${n}`}:{toolKind:`other`,title:`MCP tool`,subtitle:j(t)}}}if(n.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()!==``?O(e):`Tool`,subtitle:j(t)}}var P=_(`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`}]]),F=_(`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`}]]),I=n();function te(e){let{text:t,...n}=b(e),r={...n,status:t};switch(e.state){case`registered`:return e.server.answeredAtRegistration?{...r,action:{label:`Open`,run:!1}}:{...r,action:{label:`Run and open`,run:!0}};case`adopted`:case`starting`:case`up`:return{...r,action:{label:`Open`,run:!1}};case`stalled`:return{...r,action:{label:`View`,run:!1}};case`exited`:case`stopped`:return{...r,action:{label:`Start again`,run:!0}};case`unavailable`:return r}}var ne={"Run and open":w,Open:v,View:x,"Start again":P};function L({entry:e,inPreview:t,onOpen:n}){let{server:r}=e,i=te(e),a=e.state===`unavailable`,o=n?i.action:void 0,c=t&&o!==void 0&&!o.run,l=c?`In preview`:o?.label,u=c?v:o?ne[o.label]:null,d=S(r.command),f=C(r.registeredAt);return(0,I.jsxs)(`div`,{"data-slot":`preview-server-card`,"data-state":e.state,className:g(`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,a&&`text-muted-foreground`),children:[(0,I.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 text-xs text-soft-foreground`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 font-mono`,children:[(0,I.jsx)(F,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`truncate`,children:`cezar_preview_serve`})]}),a?(0,I.jsx)(`span`,{children:`worktree removed`}):f?(0,I.jsxs)(`span`,{children:[f,` ago`]}):null]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(y,{tone:i.tone,shape:i.ring?`ring`:`filled`,pulse:i.pulse===!0,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`font-semibold text-foreground`,children:r.label}),(0,I.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,r.port]}),(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:i.status})]}),o&&l&&u?(0,I.jsxs)(s,{variant:c||o.label===`View`||o.label===`Open`&&e.state===`starting`?`outline`:`contrast`,size:`sm`,className:`max-md:h-11 max-md:px-3.5`,onClick:()=>n?.({port:r.port,run:o.run}),children:[(0,I.jsx)(u,{"aria-hidden":`true`}),l]}):null]}),(0,I.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,I.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:r.command}),r.cwd?(0,I.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,I.jsx)(`span`,{children:`cwd`}),(0,I.jsx)(`span`,{className:`break-all`,children:r.cwd})]}):null]}),o?.run?(0,I.jsx)(R,{icon:(0,I.jsx)(T,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),children:`${o.label===`Start again`?`Starting again`:`Opening`} runs ${d} in this task's worktree, on the host.`}):null,a?(0,I.jsx)(R,{children:`The worktree this server ran in is gone. Register it again from a new task.`}):null]})}function R({icon:e,children:t}){return(0,I.jsxs)(`p`,{className:`mt-2.5 flex items-start gap-2 text-xs text-muted-foreground`,children:[e,(0,I.jsx)(`span`,{children:t})]})}var z=e(t(),1),B=[`run-event`,`ui-event`];function V(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t||Array.isArray(t))return null;let{seq:n,type:r}=t;return typeof n!=`number`||typeof r!=`string`||r===``?null:t}function H(e,t={}){let[n,r]=(0,z.useState)([]),{cursor:i,afterSeq:a=0,maxEvents:o,compactAt:s,onCompact:c}=t;return(0,z.useEffect)(()=>{if(r([]),!e)return;let t=globalThis.EventSource;if(typeof t!=`function`)return;let n=a,l=null,u,d=!1,f=!1,p=Date.now(),h,g=[],_,v,y=()=>{if(_!==void 0&&globalThis.cancelAnimationFrame?.(_),clearTimeout(v),_=void 0,v=void 0,d||g.length===0)return;let e=g;g=[],r(t=>{let n=[...t,...e];return!f&&s!==void 0&&n.length>=s&&(f=!0,queueMicrotask(()=>{d||c?.()})),o===void 0||n.length<=o?n:n.slice(-o)})},b=()=>{v===void 0&&(v=setTimeout(y,50),typeof globalThis.requestAnimationFrame==`function`&&(_=globalThis.requestAnimationFrame(y)))},x=e=>{p=Date.now();let t=V(e.data);!t||!(t.seq>n)||(n=t.seq,g.push(t),b())},S=()=>{p=Date.now()},C=()=>{d||u!==void 0||(u=setTimeout(()=>{u=void 0,d||w()},1500))},w=()=>{l?.close(),p=Date.now();let r=new URLSearchParams;i!==void 0&&r.set(`cursor`,i),(i!==void 0||a>0)&&r.set(`afterSeq`,String(n));let o=r.size>0?`?${r.toString()}`:``;l=new t(m(`/runs/${encodeURIComponent(e)}/events${o}`),{withCredentials:!0});for(let e of B)l.addEventListener(e,x);l.addEventListener(`ping`,S),l.addEventListener(`error`,()=>{l?.readyState===2&&C()})},T=()=>{document.visibilityState===`visible`&&(!l||l.readyState===2)&&(clearTimeout(u),u=void 0,w())},E=()=>{clearTimeout(u),u=void 0,l?.close()},D=e=>{e.persisted&&w()};return h=setInterval(()=>{d||document.visibilityState!==`visible`||Date.now()-p<=4e4||(clearTimeout(u),u=void 0,w())},1e4),document.addEventListener(`visibilitychange`,T),window.addEventListener(`pagehide`,E),window.addEventListener(`pageshow`,D),w(),()=>{d=!0,_!==void 0&&globalThis.cancelAnimationFrame?.(_),clearTimeout(v),clearTimeout(u),clearInterval(h),document.removeEventListener(`visibilitychange`,T),window.removeEventListener(`pagehide`,E),window.removeEventListener(`pageshow`,D),l?.close()}},[e,i,a,o,s,c]),n}var U=5,W=200,G=5e3;function K(...e){let t=new Map;for(let n of e)for(let e of n)t.set(e.seq,e);return[...t.values()].sort((e,t)=>e.seq-t.seq)}function q(e,t,n){e.setQueryData(t,e=>{if(!e)return{pages:[n],pageParams:[void 0]};let t=[...e.pages],r=[...e.pageParams],i=-1;for(let e=0;e<t.length;e+=1)(i===-1||t[e].asOfSeq>t[i].asOfSeq)&&(i=e);if(i>=0&&t[i].asOfSeq>n.asOfSeq)return e;for(i>=0&&t[i].newerCursor===void 0?(t[i]=n,r[i]=void 0):(t.push(n),r.push(void 0));t.length>U;)t.shift(),r.shift();return{pages:t,pageParams:r}})}function J(e){let t=h(),n=c(),s=[`run-history`,t,e],l=[`run-history-context`,t,e],u=i({queryKey:s,enabled:e!==void 0,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>a(e,t,{signal:n}),getPreviousPageParam:e=>e.olderCursor,getNextPageParam:e=>e.newerCursor,maxPages:U,staleTime:1/0,retry:1}),d=r({queryKey:l,enabled:e!==void 0,queryFn:({signal:t})=>o(e,{signal:t}),retry:1}),f=u.isError||d.isError,p=H(f?e:void 0),m=u.data?.pages??[],g=m.reduce((e,t)=>t.newerCursor===void 0?t:e??t,void 0),_=(0,z.useRef)(!1),v=(0,z.useCallback)(()=>{e===void 0||_.current||(_.current=!0,a(e,void 0).then(r=>q(n,[`run-history`,t,e],r)).catch(()=>{}).finally(()=>{_.current=!1}))},[n,e,t]),y=e=>e!==void 0&&n.getQueryData([`run-history`,t,e])!==void 0,[b,x]=(0,z.useState)(()=>({runId:e,pending:y(e)})),S=b.pending;b.runId!==e&&(S=y(e),x({runId:e,pending:S})),(0,z.useEffect)(()=>{if(!S||e===void 0)return;let r=!1,i=new AbortController;return a(e,void 0,{signal:i.signal}).then(r=>q(n,[`run-history`,t,e],r)).catch(()=>{}).finally(()=>{r||x({runId:e,pending:!1})}),()=>{r=!0,i.abort()}},[n,S,e,t]);let C=H(!f&&g&&!S?e:void 0,{cursor:g?.liveCursor,afterSeq:g?.asOfSeq,maxEvents:G,compactAt:W,onCompact:v}),w=(0,z.useRef)(0);w.current=C.length,(0,z.useEffect)(()=>()=>{w.current>0&&v()},[v]);let T=(0,z.useMemo)(()=>K(...m.map(e=>e.events)),[m]),E=(0,z.useMemo)(()=>f?p:K(T,C),[f,p,T,C]),D=(0,z.useMemo)(()=>{if(f)return p;let e=d.data?.contextEvents??[],t=d.data?.asOfSeq??0;return K(e,E.filter(({seq:e})=>e>t))},[d.data,f,p,E]),O=(0,z.useCallback)(async()=>{await u.fetchPreviousPage()},[u.fetchPreviousPage]),k=(0,z.useCallback)(async()=>{f||await n.resetQueries({queryKey:s,exact:!0})},[f,s,n]);return{visibleEvents:E,currentEvents:D,isPending:!f&&u.isPending,contextPending:!f&&d.isPending,fallback:f,hasOlder:!f&&!!u.hasPreviousPage,isFetchingOlder:u.isFetchingPreviousPage,olderError:u.isFetchPreviousPageError?u.error instanceof Error?u.error.message:`Could not load earlier items`:void 0,loadOlder:O,jumpToLatest:k,retainedPages:m.length}}var Y={"not-delivered":0,queued:1,delivered:2,consumed:3};function re(e){for(let t=e.turns.length-1;t>=0;--t){let n=e.turns[t].planEntries;if(n!==void 0)return n}}function ie(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 ae(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 X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function oe(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 Z(e){return typeof e==`string`?e:void 0}function Q(e){if(!(typeof e!=`string`||e===``))return Number.isFinite(new Date(e).getTime())?e:void 0}function se(e){return e===`claude`||e===`codex`||e===`opencode`||e===`pi`||e===`cursor`||e===`omp`?e:void 0}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{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Gi as r,Wi as i,fr as a,pr as o,t as s,ta as c}from"./button-Jj1Itx83.js";import{I as l,L as u,N as d,P as f,R as p,i as m,s as h,t as g}from"./utils-POVs3UKu.js";import{t as _}from"./createLucideIcon-BHp8sXmF.js";import{t as v}from"./app-window-CSHwDX9N.js";import{t as y}from"./status-dot-DwFmt_Jg.js";import{a as b,d as x,i as S}from"./preview-state-D8-YBJ6m.js";import{n as C}from"./format-DTNjugyE.js";import{t as w}from"./play-CmVAj_fu.js";import{t as T}from"./square-terminal-B6RYYieR.js";var E=120;function D(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function O(e){let t=e.replace(/\s+/g,` `).trim();return t.length>E?`${t.slice(0,E-1)}…`:t}function k(e,...t){if(D(e))for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return O(t)}}function ee(e){if(!D(e))return;let t=e.command;if(typeof t==`string`&&t.trim()!==``)return O(t);if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return O(e.join(` `))}}function A(e){if(!D(e)||!Array.isArray(e.changes))return[];let t=[];for(let n of e.changes)D(n)&&typeof n.path==`string`&&n.path.trim()!==``&&t.push(n.path);return t}function j(e){return k(e,`description`,`query`,`url`,`filePath`,`file_path`,`path`,`pattern`,`name`)}function M(e,t){return t?`${e} ${t}`:e}function N(e,t){let n=typeof e==`string`?e.toLowerCase():``;switch(n){case`bash`:case`commandexecution`:return{toolKind:`execute`,title:M(`Ran`,ee(t)),subtitle:k(t,`description`)};case`edit`:case`multiedit`:return{toolKind:`edit`,title:M(`Edit`,k(t,`file_path`,`filePath`,`path`))};case`write`:return{toolKind:`edit`,title:M(`Write`,k(t,`file_path`,`filePath`,`path`))};case`notebookedit`:return{toolKind:`edit`,title:M(`Edit`,k(t,`notebook_path`,`notebookPath`,`file_path`,`filePath`,`path`))};case`filechange`:{let e=A(t);return{toolKind:`edit`,title:M(`Edit`,e.length===1?e[0]:e.length>1?`${e.length} files`:void 0)}}case`read`:return{toolKind:`read`,title:M(`Read`,k(t,`file_path`,`filePath`,`path`))};case`imageview`:return{toolKind:`read`,title:M(`View image`,k(t,`path`))};case`glob`:case`grep`:return{toolKind:`search`,title:M(`Search`,k(t,`pattern`,`query`)),subtitle:k(t,`path`)};case`webfetch`:return{toolKind:`fetch`,title:M(`Fetch`,k(t,`url`))};case`websearch`:return{toolKind:`fetch`,title:M(`Web search`,k(t,`query`))};case`task`:case`agent`:{let e=n===`agent`?`Agent`:`Task`,r=k(t,`subagent_type`,`subagentType`),i=k(t,`description`,`prompt`)??r;return{toolKind:`task`,title:i?`${e}: ${i}`:e,subtitle:i===r?void 0:r}}case`skill`:{let e=k(t,`skill`,`name`,`command`);return{toolKind:`task`,title:e?`Skill: ${e}`:`Skill`,subtitle:k(t,`args`,`description`)}}case`todowrite`:case`todolist`:case`plan`:case`taskcreate`:case`taskupdate`:case`tasklist`:return{toolKind:`plan`,title:`Update plan`};case`contextcompaction`:return{toolKind:`other`,title:`Compacted context`};case`mcptoolcall`:{let e=k(t,`server`),n=k(t,`tool`);return e&&n?{toolKind:`other`,title:`${e}.${n}`}:{toolKind:`other`,title:`MCP tool`,subtitle:j(t)}}}if(n.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()!==``?O(e):`Tool`,subtitle:j(t)}}var P=_(`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`}]]),F=_(`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`}]]),I=n();function te(e){let{text:t,...n}=b(e),r={...n,status:t};switch(e.state){case`registered`:return e.server.answeredAtRegistration?{...r,action:{label:`Open`,run:!1}}:{...r,action:{label:`Run and open`,run:!0}};case`adopted`:case`starting`:case`up`:return{...r,action:{label:`Open`,run:!1}};case`stalled`:return{...r,action:{label:`View`,run:!1}};case`exited`:case`stopped`:return{...r,action:{label:`Start again`,run:!0}};case`unavailable`:return r}}var ne={"Run and open":w,Open:v,View:x,"Start again":P};function L({entry:e,inPreview:t,onOpen:n}){let{server:r}=e,i=te(e),a=e.state===`unavailable`,o=n?i.action:void 0,c=t&&o!==void 0&&!o.run,l=c?`In preview`:o?.label,u=c?v:o?ne[o.label]:null,d=S(r.command),f=C(r.registeredAt);return(0,I.jsxs)(`div`,{"data-slot":`preview-server-card`,"data-state":e.state,className:g(`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,a&&`text-muted-foreground`),children:[(0,I.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 text-xs text-soft-foreground`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 font-mono`,children:[(0,I.jsx)(F,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`truncate`,children:`cezar_preview_serve`})]}),a?(0,I.jsx)(`span`,{children:`worktree removed`}):f?(0,I.jsxs)(`span`,{children:[f,` ago`]}):null]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(y,{tone:i.tone,shape:i.ring?`ring`:`filled`,pulse:i.pulse===!0,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`font-semibold text-foreground`,children:r.label}),(0,I.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,r.port]}),(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:i.status})]}),o&&l&&u?(0,I.jsxs)(s,{variant:c||o.label===`View`||o.label===`Open`&&e.state===`starting`?`outline`:`contrast`,size:`sm`,className:`max-md:h-11 max-md:px-3.5`,onClick:()=>n?.({port:r.port,run:o.run}),children:[(0,I.jsx)(u,{"aria-hidden":`true`}),l]}):null]}),(0,I.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,I.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:r.command}),r.cwd?(0,I.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,I.jsx)(`span`,{children:`cwd`}),(0,I.jsx)(`span`,{className:`break-all`,children:r.cwd})]}):null]}),o?.run?(0,I.jsx)(R,{icon:(0,I.jsx)(T,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),children:`${o.label===`Start again`?`Starting again`:`Opening`} runs ${d} in this task's worktree, on the host.`}):null,a?(0,I.jsx)(R,{children:`The worktree this server ran in is gone. Register it again from a new task.`}):null]})}function R({icon:e,children:t}){return(0,I.jsxs)(`p`,{className:`mt-2.5 flex items-start gap-2 text-xs text-muted-foreground`,children:[e,(0,I.jsx)(`span`,{children:t})]})}var z=e(t(),1),B=[`run-event`,`ui-event`];function V(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t||Array.isArray(t))return null;let{seq:n,type:r}=t;return typeof n!=`number`||typeof r!=`string`||r===``?null:t}function H(e,t={}){let[n,r]=(0,z.useState)([]),{cursor:i,afterSeq:a=0,maxEvents:o,compactAt:s,onCompact:c}=t;return(0,z.useEffect)(()=>{if(r([]),!e)return;let t=globalThis.EventSource;if(typeof t!=`function`)return;let n=a,l=null,u,d=!1,f=!1,p=Date.now(),h,g=[],_,v,y=()=>{if(_!==void 0&&globalThis.cancelAnimationFrame?.(_),clearTimeout(v),_=void 0,v=void 0,d||g.length===0)return;let e=g;g=[],r(t=>{let n=[...t,...e];return!f&&s!==void 0&&n.length>=s&&(f=!0,queueMicrotask(()=>{d||c?.()})),o===void 0||n.length<=o?n:n.slice(-o)})},b=()=>{v===void 0&&(v=setTimeout(y,50),typeof globalThis.requestAnimationFrame==`function`&&(_=globalThis.requestAnimationFrame(y)))},x=e=>{p=Date.now();let t=V(e.data);!t||!(t.seq>n)||(n=t.seq,g.push(t),b())},S=()=>{p=Date.now()},C=()=>{d||u!==void 0||(u=setTimeout(()=>{u=void 0,d||w()},1500))},w=()=>{l?.close(),p=Date.now();let r=new URLSearchParams;i!==void 0&&r.set(`cursor`,i),(i!==void 0||a>0)&&r.set(`afterSeq`,String(n));let o=r.size>0?`?${r.toString()}`:``;l=new t(m(`/runs/${encodeURIComponent(e)}/events${o}`),{withCredentials:!0});for(let e of B)l.addEventListener(e,x);l.addEventListener(`ping`,S),l.addEventListener(`error`,()=>{l?.readyState===2&&C()})},T=()=>{document.visibilityState===`visible`&&(!l||l.readyState===2)&&(clearTimeout(u),u=void 0,w())},E=()=>{clearTimeout(u),u=void 0,l?.close()},D=e=>{e.persisted&&w()};return h=setInterval(()=>{d||document.visibilityState!==`visible`||Date.now()-p<=4e4||(clearTimeout(u),u=void 0,w())},1e4),document.addEventListener(`visibilitychange`,T),window.addEventListener(`pagehide`,E),window.addEventListener(`pageshow`,D),w(),()=>{d=!0,_!==void 0&&globalThis.cancelAnimationFrame?.(_),clearTimeout(v),clearTimeout(u),clearInterval(h),document.removeEventListener(`visibilitychange`,T),window.removeEventListener(`pagehide`,E),window.removeEventListener(`pageshow`,D),l?.close()}},[e,i,a,o,s,c]),n}var U=5,W=200,G=5e3;function K(...e){let t=new Map;for(let n of e)for(let e of n)t.set(e.seq,e);return[...t.values()].sort((e,t)=>e.seq-t.seq)}function q(e,t,n){e.setQueryData(t,e=>{if(!e)return{pages:[n],pageParams:[void 0]};let t=[...e.pages],r=[...e.pageParams],i=-1;for(let e=0;e<t.length;e+=1)(i===-1||t[e].asOfSeq>t[i].asOfSeq)&&(i=e);if(i>=0&&t[i].asOfSeq>n.asOfSeq)return e;for(i>=0&&t[i].newerCursor===void 0?(t[i]=n,r[i]=void 0):(t.push(n),r.push(void 0));t.length>U;)t.shift(),r.shift();return{pages:t,pageParams:r}})}function J(e){let t=h(),n=c(),s=[`run-history`,t,e],l=[`run-history-context`,t,e],u=i({queryKey:s,enabled:e!==void 0,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>a(e,t,{signal:n}),getPreviousPageParam:e=>e.olderCursor,getNextPageParam:e=>e.newerCursor,maxPages:U,staleTime:1/0,retry:1}),d=r({queryKey:l,enabled:e!==void 0,queryFn:({signal:t})=>o(e,{signal:t}),retry:1}),f=u.isError||d.isError,p=H(f?e:void 0),m=u.data?.pages??[],g=m.reduce((e,t)=>t.newerCursor===void 0?t:e??t,void 0),_=(0,z.useRef)(!1),v=(0,z.useCallback)(()=>{e===void 0||_.current||(_.current=!0,a(e,void 0).then(r=>q(n,[`run-history`,t,e],r)).catch(()=>{}).finally(()=>{_.current=!1}))},[n,e,t]),y=e=>e!==void 0&&n.getQueryData([`run-history`,t,e])!==void 0,[b,x]=(0,z.useState)(()=>({runId:e,pending:y(e)})),S=b.pending;b.runId!==e&&(S=y(e),x({runId:e,pending:S})),(0,z.useEffect)(()=>{if(!S||e===void 0)return;let r=!1,i=new AbortController;return a(e,void 0,{signal:i.signal}).then(r=>q(n,[`run-history`,t,e],r)).catch(()=>{}).finally(()=>{r||x({runId:e,pending:!1})}),()=>{r=!0,i.abort()}},[n,S,e,t]);let C=H(!f&&g&&!S?e:void 0,{cursor:g?.liveCursor,afterSeq:g?.asOfSeq,maxEvents:G,compactAt:W,onCompact:v}),w=(0,z.useRef)(0);w.current=C.length,(0,z.useEffect)(()=>()=>{w.current>0&&v()},[v]);let T=(0,z.useMemo)(()=>K(...m.map(e=>e.events)),[m]),E=(0,z.useMemo)(()=>f?p:K(T,C),[f,p,T,C]),D=(0,z.useMemo)(()=>{if(f)return p;let e=d.data?.contextEvents??[],t=d.data?.asOfSeq??0;return K(e,E.filter(({seq:e})=>e>t))},[d.data,f,p,E]),O=(0,z.useCallback)(async()=>{await u.fetchPreviousPage()},[u.fetchPreviousPage]),k=(0,z.useCallback)(async()=>{f||await n.resetQueries({queryKey:s,exact:!0})},[f,s,n]);return{visibleEvents:E,currentEvents:D,isPending:!f&&u.isPending,contextPending:!f&&d.isPending,fallback:f,hasOlder:!f&&!!u.hasPreviousPage,isFetchingOlder:u.isFetchingPreviousPage,olderError:u.isFetchPreviousPageError?u.error instanceof Error?u.error.message:`Could not load earlier items`:void 0,loadOlder:O,jumpToLatest:k,retainedPages:m.length}}var Y={"not-delivered":0,queued:1,delivered:2,consumed:3};function re(e){for(let t=e.turns.length-1;t>=0;--t){let n=e.turns[t].planEntries;if(n!==void 0)return n}}function ie(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 ae(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 X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function oe(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 Z(e){return typeof e==`string`?e:void 0}function Q(e){if(!(typeof e!=`string`||e===``))return Number.isFinite(new Date(e).getTime())?e:void 0}function se(e){return e===`claude`||e===`codex`||e===`opencode`||e===`pi`||e===`cursor`||e===`omp`?e:void 0}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 ce(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 le(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}}var ue=e=>e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`,de=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function fe(e){if(!X(e)||!Array.isArray(e.todos))return;let t=[];for(let n of e.todos){if(!X(n)||typeof n.content!=`string`)return;t.push({content:n.content,status:de.has(n.status)?n.status:`pending`,...typeof n.activeForm==`string`?{activeForm:n.activeForm}:{}})}return t}function pe(e,t={}){let n=[],r=new Map,i,a=0,o,s=e=>{a+=1;let t={id:e===void 0?`turn-fallback-${a}`:`turn-seq-${e}`,entries:[],v2Items:!1};return n.push(t),t},c=()=>n.at(-1)??s(),m=(e,t)=>{let n=Z(e.stepId);return n===void 0?t:`${n}:${t}`},h=(e,t,n,i)=>{let a=t.kind===`message`&&i!==void 0?{...t,ts:i}:{...t};if(!e.v2Items){e.v2Items=!0;for(let t of e.entries)t.origin===`v1`&&t.entry.kind===`tool`&&r.delete(t.entry.id);e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`tool`))}let o=r.get(n);if(o&&o.turn===e){o.entry.entry=a,r.set(n,o);return}let s={origin:`v2`,entry:a};e.entries.push(s),r.set(n,{turn:e,entry:s})},g=new Map,_=new Map,v=new Set,y=e=>{if(e.messageKind!==`request`)return;let t=_.get(e.messageId);t&&(e.outcome={status:t.status,...t.replyId===void 0?{}:{replyId:t.replyId},observedAt:t.observedAt})},b=(e,t,n)=>{let r=g.get(e.id);if(r)return(Y[r.delivery]<Y.delivered||Y[t]>Y[r.delivery])&&(r.delivery=t),e.text!==``&&(r.text=e.text),e.state!==void 0&&(r.state=e.state),e.createdAt!==void 0&&(r.createdAt=e.createdAt),e.requestHash!==void 0&&(r.requestHash=e.requestHash),e.deadline!==void 0&&(r.deadline=e.deadline),e.requestId!==void 0&&(r.requestId=e.requestId),e.instruction!==void 0&&(r.instruction=e.instruction),e.resumed!==void 0&&(r.resumed=e.resumed),n?.deliveredAt!==void 0&&(r.deliveredAt=n.deliveredAt),n?.consumedAt!==void 0&&(r.consumedAt=n.consumedAt),n?.recordedAt!==void 0&&(t===`delivered`||r.delivery!==`delivered`)&&(r.recordedAt=n.recordedAt),y(r),r;let i={kind:`conversation`,id:`conversation-message:${e.id}`,messageId:e.id,text:e.text,senderRunId:e.senderRunId,recipientRunId:e.recipientRunId,messageKind:e.kind,delivery:t,...n,...e.instruction===void 0?{}:{instruction:e.instruction},...e.resumed===void 0?{}:{resumed:e.resumed},...e.requestId===void 0?{}:{requestId:e.requestId},...e.state===void 0?{}:{state:e.state},...e.createdAt===void 0?{}:{createdAt:e.createdAt},...e.requestHash===void 0?{}:{requestHash:e.requestHash},...e.deadline===void 0?{}:{deadline:e.deadline}};return y(i),g.set(e.id,i),c().entries.push({origin:`meta`,entry:i}),i},x=new Map,S=!1;for(let t of e)switch(t.type){case`handoff`:{let e=oe(t.ts),n=Z(t.message),r=t.notify===!1?`Stopped notifying the webhook${e}`:`${S?`Note sent to webhook`:`Handed off to webhook`}${e}${n?` — ${n}`:``}`;S=t.notify!==!1,c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${t.seq}`,text:r,tone:`dim`,icon:`handoff`}});break}case`webhook.failed`:{let e=typeof t.attempts==`number`?t.attempts:void 0,n=`Webhook delivery failed${Z(t.event)?` (${Z(t.event)})`:``}${e?` after ${e} attempt${e===1?``:`s`}`:``}: ${Z(t.error)??`unknown error`}`;c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${t.seq}`,text:n,tone:`danger`}});break}case`webhook.dry-run`:{let e=t.payload??{},n=`Webhook (dry run, nothing sent): ${Z(t.event)??`delivery`}${Z(e.status)?` · ${Z(e.status)}`:``}`;c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${t.seq}`,text:n,tone:`dim`}});break}case`preview.server-registered`:{let e=d.safeParse(t.server);if(!e.success)break;let n=x.get(e.data.port);n&&(n.turn.entries=n.turn.entries.filter(e=>e!==n.draft));let r=c(),i={origin:`meta`,entry:{kind:`preview-server`,id:`preview-server:${e.data.port}`,server:e.data,state:`registered`,stateAt:t.ts}};r.entries.push(i),x.set(e.data.port,{turn:r,draft:i});break}case`preview.server-state`:{let e=f.safeParse(t.state),n=typeof t.port==`number`?x.get(t.port):void 0;if(!e.success||!n||n.draft.entry.kind!==`preview-server`)break;let{server:r,id:i}=n.draft.entry;n.draft.entry={kind:`preview-server`,id:i,server:r,state:e.data,stateAt:t.ts,...typeof t.exitCode==`number`?{exitCode:t.exitCode}:{},...t.reason===`user`||t.reason===`idle`?{reason:t.reason}:{}};break}case`conversation-message`:{let e=u.safeParse(t);if(!e.success)break;b(e.data.message,e.data.delivery,{deliveredAt:e.data.deliveredAt,consumedAt:e.data.consumedAt,recordedAt:e.data.ts});break}case`request-outcome`:{let e=p.safeParse(t);if(!e.success||_.has(e.data.outcome.requestId))break;let{outcome:n}=e.data;_.set(n.requestId,n);let r=g.get(n.requestId);r&&y(r);break}case`agent-input`:{let e=l.safeParse(t);if(!e.success)break;let{input:n}=e.data;if(v.has(n.id))break;if(v.add(n.id),n.conversation){b({id:n.id,text:n.text,createdAt:n.createdAt,...n.conversation},`delivered`,{deliveredAt:n.deliveredAt,recordedAt:e.data.ts});break}c().entries.push({origin:`meta`,entry:{kind:`note`,id:`agent-input:${n.id}`,text:n.text,tone:`dim`,attribution:{source:n.source,parentRunId:n.parentRunId}}});break}case`user-message`:{let e=Z(t.text)??``;o&&!o.resolved&&(o.resolved=!0,o.answeredBy=`human`,e!==``&&(o.answer=e),o=void 0);let n=s(t.seq),r=Q(t.ts);n.userMessage={text:e,imageCount:typeof t.imageCount==`number`?t.imageCount:0,images:Array.isArray(t.images)?t.images.filter(e=>typeof e==`string`):[],...r===void 0?{}:{ts:r}},r!==void 0&&(n.startedAt=r);break}case`turn.started`:{let e=Z(t.turnId),r=n.at(-1),i=r&&r.turnId===void 0&&!r.v2Items?r:s(t.seq);i.turnId=e;let a=Q(t.ts);i.startedAt===void 0&&a!==void 0&&(i.startedAt=a);break}case`turn.completed`:{let e=Z(t.turnId),r;for(let t=n.length-1;t>=0&&!r;--t)n[t].turnId===e&&(r=n[t]);let i=r??n.at(-1);if(i){let e=Q(t.ts);i.completed={stopReason:Z(t.stopReason)??`end_turn`,...typeof t.costUsd==`number`?{costUsd:t.costUsd}:{},...e===void 0?{}:{ts:e}}}break}case`item.started`:case`item.updated`:case`item.completed`:{if(!X(t.item))break;let e=t.item.kind,n=t.item.id;if(e!==`message`&&e!==`reasoning`&&e!==`tool`||typeof n!=`string`||n===``)break;let i=t.item,a=m(t,i.id);h(r.get(a)?.turn??c(),i,a,t.type===`item.completed`?Q(t.ts):void 0);break}case`item.delta`:{let e=Z(t.itemId)??``,n=r.get(m(t,e)),i=Z(t.delta)??``;if(!n||i===``||!ue(n.entry.entry))break;let a=n.entry.entry;t.field===`output`&&a.kind===`tool`?a.output=(a.output??``)+i:t.field!==`output`&&a.kind!==`tool`&&(a.text+=i);break}case`text`:{let e=c(),n=Z(t.text)??``;if(n===``)break;let r=Q(t.ts);e.entries.push({origin:`v1`,entry:{kind:`message`,id:`v1:${t.seq}`,role:`assistant`,text:n,...r===void 0?{}:{ts:r}}});break}case`tool-call`:{let e=c();if(e.v2Items)break;let n=Z(t.tool)??`Tool`;if(me.has(n))break;let i=N(n,t.input);if(i.toolKind===`plan`){let n=fe(t.input);n!==void 0&&(e.planEntries=n)}let a={kind:`tool`,id:Z(t.id)??`v1:${t.seq}`,name:n,toolKind:i.toolKind,title:i.title,status:`running`,input:t.input},o={origin:`v1`,entry:a};e.entries.push(o),r.set(a.id,{turn:e,entry:o});break}case`tool-result`:{let e=r.get(Z(t.toolCallId)??``);if(!e||e.turn.v2Items||e.entry.origin!==`v1`)break;let n=e.entry.entry;if(n.kind!==`tool`)break;n.status=`completed`,n.output=le(t.result);break}case`note`:case`lifecycle`:{let e=Z(t.message)??``;if(e===``)break;let n=t.tone===`danger`?`danger`:`dim`;c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${t.seq}`,text:e,tone:n}});break}case`error`:{let e=Z(t.message)??``;if(e===``)break;c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${t.seq}`,text:e,tone:`danger`}});break}case`session.error`:{let e=Z(t.message)??``;if(e===``)break;c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v2:${t.seq}`,text:e,tone:`danger`}});break}case`step-end`:{if(t.status!==`failed`)break;let e=Z(t.error)?` — ${Z(t.error)}`:``;c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${t.seq}`,text:`step ${Z(t.stepId)??`?`} failed${e}`,tone:`danger`}});break}case`check-output`:{let e=Z(t.command)??`check`,n=typeof t.exitCode==`number`?t.exitCode:-1,r={kind:`tool`,id:`v1:${t.seq}`,name:`check`,toolKind:`execute`,title:`Ran ${e}`,status:n===0?`completed`:`failed`,output:Z(t.text)??``,exitCode:n};c().entries.push({origin:`meta`,entry:r});break}case`provider-auth-required`:{let e=se(t.provider),n=Z(t.authFailureId);if(e===void 0||n===void 0||n.length<1||n.length>128)break;c().entries.push({origin:`meta`,entry:{kind:`provider-auth-required`,id:`v1:${t.seq}`,provider:e,authFailureId:n}});break}case`image`:{let e=Z(t.url);if(e===void 0)break;let n={kind:`image`,id:`v1:${t.seq}`,url:e},r=Z(t.name);r!==void 0&&(n.name=r),c().entries.push({origin:`meta`,entry:n});break}case`plan.updated`:Array.isArray(t.entries)&&(c().planEntries=t.entries);break;case`session.ended`:i={reason:Z(t.reason)??`end_turn`,...Z(t.message)===void 0?{}:{message:Z(t.message)}};break;case`ask.requested`:{let e=Z(t.requestId);if(e===void 0||!Array.isArray(t.questions))break;let n=t.questions.filter(e=>X(e)&&typeof e.header==`string`&&Array.isArray(e.options));if(n.length===0)break;let r={kind:`ask`,id:e,questions:n,resolved:!1,askSeq:t.seq};c().entries.push({origin:`meta`,entry:r}),o=r;break}case`worker-question-routed`:if(o&&!o.resolved&&o.askSeq===t.askSeq){o.routedToParent=!0;let e=Z(t.parentRunId);e!==void 0&&(o.parentRunId=e)}break;case`worker-question-fallback`:o&&!o.resolved&&o.askSeq===t.askSeq&&(o.routedToParent=!1);break;case`human-input-delivered`:t.source===`parent`&&o&&!o.resolved&&o.askSeq===t.askSeq&&(o.resolved=!0,o.answeredBy=`parent`,o=void 0);break;case`step-start`:case`token-usage`:case`cost`:case`turn-end`:case`done`:case`session`:break;default:break}for(let e of n){if(!e.v2Items)continue;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()))),ce(e))}for(let e of g.values())e.messageKind!==`request`||e.outcome!==void 0||e.delivery!==`not-delivered`&&(e.state!==void 0&&e.state!==`accepted`||(e.outcome={status:`pending`}));return{turns:n.map((e,r)=>{let i=e.entries.some(({entry:e})=>e.kind===`ask`),a=t.activeTurn===!0&&r===n.length-1;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,i||a)}:e)}}),...i===void 0?{}:{sessionEnded:i}}}var me=new Set([`subAgentActivity`,`collabAgentToolCall`,`collabToolCall`]);export{J as a,P as c,ae as i,pe as n,L as o,ie as r,F as s,re as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ar as r,Bn as i,Bt as a,D as o,F as s,Gi as c,It as l,N as u,Ot as d,P as f,Pt as p,Rt as m,Si as h,St as g,V as _,Vn as v,Wt as y,fn as b,qr as ee,t as x,ta as S,z as C}from"./button-C_rd7CPp.js";import{n as w,t as T,y as E}from"./utils-JsL3ZsJf.js";import{U as D,Ut as O,V as k,Xt as A,b as j,gt as M,qn as N,qt as te}from"./alert-dialog-BrpNUwMt.js";import{i as P,r as F,s as I,t as L}from"./popover-BohP6WTx.js";import{L as ne,_ as re,a as ie,c as ae,d as R,f as oe,m as se,n as ce,o as le,p as ue,r as de,s as fe,u as pe,x as me}from"./prompt-templates-Cubdut_C.js";import{f as he,n as z,r as B}from"./format-DpNe3S0A.js";import{n as ge,t as _e}from"./tab-link-B07Hu4QX.js";import{t as ve}from"./play-CmVAj_fu.js";import{a as ye,i as be,n as xe,o as Se,r as Ce,s as we,t as Te}from"./textarea-D20O4Pw0.js";import{d as Ee,f as De,i as Oe,s as ke,t as Ae,u as je}from"./skills-DFBiAuJG.js";import{Bt as Me,Gt as Ne,Kt as Pe,Mt as Fe,Pt as Ie,Ut as Le,Vt as Re,Wt as ze,a as Be,l as V,sn as Ve}from"./index-DgWWlOLy.js";import{t as He}from"./diff-DrEARXTV.js";var H=e(t(),1),U=n();function W({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`skeleton`,className:T(`animate-pulse rounded-md bg-accent`,e),...t})}function Ue(e){let t=new Set;for(let n of e)for(let e of n.labels)t.add(e);return[...t].sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()))}function We(e,t={}){let n=(t.query??``).trim().toLowerCase(),r=t.labels??[],i=n.replace(/^#/,``),a=i!==``&&/^\d+$/.test(i);return e.filter(e=>r.length>0&&!r.every(t=>e.labels.includes(t))||t.assignees?.length&&!e.assignees?.some(e=>t.assignees.some(t=>t.toLowerCase()===e.toLowerCase()))||t.author!==void 0&&e.author.toLowerCase()!==t.author.toLowerCase()||t.includeNumbers&&!t.includeNumbers.has(e.number)||t.excludeNumbers?.has(e.number)||t.projectId&&e.projectIds!==void 0&&!e.projectIds.includes(t.projectId)?!1:n===``?!0:a?String(e.number).includes(i):`#${e.number} ${e.title} ${e.author} ${e.body}`.toLowerCase().includes(n))}function Ge(e,t){let n=e.trim();if(n===``)return!1;let r=n.replace(/^#/,``);return/^\d+$/.test(r)?!t.some(e=>e.number===Number(r)):t.length===0}function G(e){if(!e||!/^[0-9a-fA-F]{6}$/.test(e))return{borderColor:`var(--border)`,color:`var(--muted-foreground)`};let t=`#${e}`;return{backgroundColor:`${t}22`,borderColor:`${t}66`,color:`color-mix(in srgb, ${t} 50%, var(--foreground))`}}function Ke({label:e,color:t,plain:n=!1}){return(0,U.jsx)(`span`,{"data-slot":`gh-label`,"data-label":e,style:n?void 0:G(t),className:n?`text-[11px] font-normal text-muted-foreground`:`rounded-full border px-1.5 py-px text-[12px] font-medium`,children:e})}function qe({item:e,colors:t,checks:n,backLink:r,subNav:i,onRunAgent:a,afterHeading:s,children:c}){let l=i?.changes??!1,u=e.kind===`pr`?`pull request`:`issue`,d=e.kind===`pr`&&!!(e.additions||e.deletions);return(0,U.jsxs)(`article`,{"data-slot":`gh-detail-inner`,className:`min-w-0 px-4 py-4 md:px-7 md:py-5`,children:[r?(0,U.jsxs)(B,{to:r.to,"data-slot":`gh-back`,className:`mb-3 inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground md:hidden`,children:[(0,U.jsx)(o,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`Back to the list`]}):null,(0,U.jsxs)(`div`,{"data-slot":`gh-description-card`,className:e.kind===`pr`?`rounded-xl border border-border bg-card p-6`:void 0,children:[e.kind===`pr`?(0,U.jsxs)(`h2`,{className:`mb-4 text-[22px] leading-snug font-normal`,children:[`#`,e.number,` `,e.title]}):null,(0,U.jsxs)(`p`,{"data-slot":`gh-meta`,className:`flex flex-wrap items-center gap-x-1.5 font-mono text-[11px] text-soft-foreground`,children:[(0,U.jsxs)(`span`,{children:[`#`,e.number]}),`·`,(0,U.jsx)(`span`,{children:u}),`·`,(0,U.jsxs)(`span`,{children:[`opened by `,e.author]}),`·`,(0,U.jsxs)(`span`,{children:[z(e.createdAt),` ago`]}),e.comments?(0,U.jsxs)(U.Fragment,{children:[`·`,(0,U.jsx)(ot,{count:e.comments})]}):null,d?(0,U.jsxs)(U.Fragment,{children:[`·`,(0,U.jsxs)(`span`,{"data-slot":`gh-diffstat`,children:[(0,U.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions??0]}),` `,(0,U.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions??0]})]})]}):null,`·`,w(e.url)?(0,U.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-open-link`,className:`inline-flex items-center gap-0.5 text-muted-foreground hover:text-foreground hover:underline`,children:[`open on GitHub`,(0,U.jsx)(I,{"aria-hidden":`true`,className:`size-2.5`})]}):(0,U.jsx)(`span`,{"data-slot":`gh-open-link`,className:`text-muted-foreground`,children:`open on GitHub`})]}),e.kind===`pr`?null:(0,U.jsx)(`h2`,{className:`mt-2 text-[22px] leading-snug font-normal`,children:e.title}),s,e.kind===`pr`&&i?(0,U.jsxs)(`nav`,{"aria-label":`Pull request detail`,className:`mt-4 flex border-b border-border`,children:[(0,U.jsx)(_e,{to:V(`prs`,i.filter,e.number),active:!l,children:`Conversation`}),(0,U.jsx)(_e,{to:V(`prs`,i.filter,e.number,`/changes`),active:l,children:`Changes`})]}):e.kind===`pr`?(0,U.jsx)(B,{to:V(`prs`,null,e.number,`/changes`),"data-slot":`gh-files-changed`,className:`mt-3 inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:underline`,children:`Files changed`}):null,e.labels.length>0||n?(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[e.labels.map(e=>(0,U.jsx)(Ke,{label:e,color:t[e]},e)),n?(0,U.jsx)(st,{checks:n,url:e.url}):null]}):null,l&&e.kind===`pr`?(0,U.jsx)(Ye,{item:e}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{"data-slot":`gh-body`,className:`mt-5 text-sm`,children:e.body?(0,U.jsx)(Ie,{children:e.body}):(0,U.jsx)(`p`,{className:`text-soft-foreground`,children:`(no description)`})}),(0,U.jsx)(Xe,{item:e,colors:t})]})]}),e.kind===`pr`?(0,U.jsx)(Je,{number:e.number,onRunAgent:a}):null,c]})}var K={squash:`Squash and merge`,merge:`Create a merge commit`,rebase:`Rebase and merge`};function q({state:e}){let t=`size-4 shrink-0`;return e===`passing`?(0,U.jsx)(u,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-passing`,className:T(t,`text-success`)}):e===`failing`?(0,U.jsx)(_,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-failing`,className:T(t,`text-danger`)}):e===`pending`?(0,U.jsx)(he,{"aria-hidden":`true`,"data-slot":`gh-merge-status-pending`,className:T(t,`animate-spin text-warning`)}):(0,U.jsx)(C,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-unknown`,className:T(t,`text-soft-foreground`)})}function Je({number:e,onRunAgent:t}){let n=S(),i=M(),a=c({queryKey:j.githubMergeState(e),queryFn:({signal:t})=>v(e,{},{signal:t}),retry:!1}),o=a.data?.available?a.data.mergeState:null,[s,l]=(0,H.useState)(null),[d,f]=(0,H.useState)(!1),[m,_]=(0,H.useState)(!1),y=N({mutationFn:t=>v(e,{refresh:!0}),onSuccess:(e,t)=>n.setQueryData(t,e),onError:e=>h(e instanceof Error?e.message:String(e),{tone:`danger`})}),b=s&&o?.methods.includes(s)?s:o?.defaultMethod??o?.methods[0]??null,ee=()=>({mergeState:j.githubMergeState(e),list:j.github({limit:Be}),comments:j.githubComments(`pr`,e),item:j.githubItem(`pr`,e),refStatus:i===void 0?void 0:j.githubRefStatusOf(i)}),C=N({mutationFn:t=>{if(!o||!b)throw Error(`No merge method is available.`);return r(e,{method:b,expectedHeadSha:o.headSha,...m&&o.canOverride?{overrideRules:!0}:{}})},onSuccess:(t,r)=>{f(!1),h(`Pull request #${e} merged`),n.invalidateQueries({queryKey:r.mergeState}),n.invalidateQueries({queryKey:r.list}),n.invalidateQueries({queryKey:r.comments}),n.invalidateQueries({queryKey:r.item}),r.refStatus&&n.invalidateQueries({queryKey:r.refStatus})},onError:(e,t)=>{h(e instanceof Error?e.message:String(e),{tone:`danger`}),n.invalidateQueries({queryKey:t.mergeState})}});if(a.isPending)return(0,U.jsx)(W,{"data-slot":`gh-merge-loading`,className:`mt-6 h-32 w-full`});if(!o)return(0,U.jsxs)(`section`,{"data-slot":`gh-merge-unavailable`,className:`mt-6 rounded-lg border border-border bg-card p-4 text-sm`,children:[(0,U.jsx)(`p`,{className:`font-medium`,children:`Merge status unavailable`}),(0,U.jsx)(`p`,{className:`mt-1 text-xs text-soft-foreground`,children:a.data?.available===!1?a.data.reason:`GitHub could not load merge requirements.`})]});let E=o.state===`merged`?`Merged`:o.state===`closed`?`Closed`:o.isDraft?`Draft`:o.mergeable===`conflicting`?`Conflicts must be resolved`:o.canMerge?`Ready to merge`:o.eligibility===`unknown`?`Merge blocked · Requirements unknown`:`Merge blocked`,D=o.reviewDecision===`approved`?`passing`:o.reviewDecision===`unknown`?`unknown`:`failing`,O=o.mergeable===`mergeable`?`passing`:o.mergeable===`conflicting`?`failing`:`unknown`,k=!!(b&&(o.canMerge||o.canOverride&&m));return(0,U.jsxs)(`section`,{"data-slot":`gh-merge-box`,"data-eligibility":o.eligibility,"data-conflicting":o.mergeable===`conflicting`?`true`:void 0,"aria-live":`polite`,className:`mt-6 rounded-lg border border-border bg-card p-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-start gap-3`,children:[o.canMerge?(0,U.jsx)(u,{size:16,"aria-hidden":`true`,className:`mt-0.5 size-5 shrink-0 text-success`}):(0,U.jsx)(p,{size:16,"aria-hidden":`true`,className:`mt-0.5 size-5 shrink-0 text-warning`}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,U.jsx)(`h3`,{className:`font-semibold`,children:E}),(0,U.jsxs)(x,{type:`button`,variant:`ghost`,size:`sm`,disabled:y.isPending,onClick:()=>y.mutate(j.githubMergeState(e)),children:[(0,U.jsx)(g,{size:16,"aria-hidden":`true`,className:T(`size-3.5`,y.isPending&&`animate-spin`)}),`Refresh`]})]}),(0,U.jsxs)(`p`,{className:`mt-1 font-mono text-[11px] text-soft-foreground`,children:[o.headRef,` (`,o.headSha.slice(0,7),`) → `,o.baseRef]}),(0,U.jsxs)(`ul`,{className:`mt-3 space-y-2 text-xs`,children:[(0,U.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(q,{state:D}),(0,U.jsxs)(`span`,{children:[`Reviews: `,o.reviewDecision.replaceAll(`-`,` `)]})]}),(0,U.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(q,{state:O}),(0,U.jsxs)(`span`,{children:[`Conflicts: `,o.mergeable===`conflicting`?`present`:o.mergeable===`mergeable`?`none`:`unknown`]})]}),o.checks.length===0?(0,U.jsx)(`li`,{children:`No checks configured`}):o.checks.map(e=>(0,U.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(q,{state:e.state}),(0,U.jsxs)(`span`,{children:[e.name,` · `,e.state,e.required===!0?` · required`:e.required===null?` · requiredness unknown`:``]})]}),e.url&&w(e.url)?(0,U.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-muted-foreground underline`,children:`details`}):null]},e.name)),o.blockers.map(e=>(0,U.jsx)(`li`,{className:`text-soft-foreground`,children:e.message},e.code))]}),o.mergeable===`conflicting`&&t?(0,U.jsx)(x,{className:`mt-4`,onClick:t,children:`Run agent on this PR`}):null,o.canOverride?(0,U.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-2 rounded-md border border-warning/40 bg-warning/5 p-3 text-xs`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:m,onChange:e=>_(e.target.checked),className:`mt-0.5 size-4 accent-accent-strong`}),(0,U.jsxs)(`span`,{children:[(0,U.jsx)(`span`,{className:`block font-medium`,children:`Merge without waiting for requirements`}),(0,U.jsx)(`span`,{className:`mt-0.5 block text-soft-foreground`,children:`GitHub will allow this only if your permissions can bypass the repository rules.`})]})]}):null,o.eligibility===`unknown`?(0,U.jsx)(`p`,{className:`mt-4 text-xs text-muted-foreground`,children:`GitHub could not confirm review and branch-protection requirements. Passing checks do not establish merge readiness.`}):null,o.state===`open`&&o.methods.length>0?(0,U.jsxs)(`div`,{className:`mt-4 flex flex-col flex-wrap gap-2 sm:flex-row`,children:[(0,U.jsx)(`select`,{"aria-label":`Merge method`,value:b??``,onChange:e=>l(e.target.value),className:`h-9 min-w-0 flex-1 rounded-md border border-input bg-background px-3 text-sm`,children:o.methods.map(e=>(0,U.jsx)(`option`,{value:e,children:K[e]},e))}),(0,U.jsx)(x,{disabled:!k,onClick:()=>f(!0),children:b?K[b]:`Merge`})]}):null]})]}),(0,U.jsx)(xe,{open:d,onOpenChange:f,children:(0,U.jsxs)(Ce,{"data-slot":`gh-merge-confirm`,showCloseButton:!1,children:[(0,U.jsxs)(Se,{children:[(0,U.jsxs)(we,{children:[b?K[b]:`Merge`,` pull request #`,e,`?`]}),(0,U.jsx)(be,{asChild:!0,children:(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`p`,{children:[`This will merge “`,o.title,`” into `,o.baseRef,`. GitHub will re-check the exact reviewed head before changing the repository.`]}),m&&o.canOverride?(0,U.jsx)(`p`,{"data-slot":`gh-bypass-warning`,className:`mt-4 text-sm text-warning`,children:`You are asking GitHub to bypass unmet repository requirements; GitHub may refuse if your permissions do not allow it.`}):null]})})]}),C.error?(0,U.jsx)(`p`,{className:`text-sm text-danger`,children:C.error.message}):null,(0,U.jsxs)(ye,{children:[(0,U.jsx)(x,{variant:`outline`,disabled:C.isPending,onClick:()=>f(!1),children:`Cancel`}),(0,U.jsx)(x,{disabled:C.isPending,onClick:()=>C.mutate(ee()),children:C.isPending?`Merging…`:b?K[b]:`Merge`})]})]})})]})}function Ye({item:e}){let t=S(),n=D(e.number),[r,a]=(0,H.useState)(``),[o,c]=(0,H.useState)(null),l=n.data,u=l?.available?l.files.filter(e=>e.path.toLowerCase().includes(r.toLowerCase())):[],d=u.findIndex(e=>e.path===o);(0,H.useEffect)(()=>{u.length>0&&!u.some(e=>e.path===o)&&c(u[0].path)},[l?.available?l.headSha:``,r]);let f=async()=>{let n=l?.available?l.headSha:null,r=j.githubPrChanges(e.number),a=await i(e.number,{refresh:!0});t.setQueryData(r,a),a.available&&n&&n!==a.headSha&&(c(a.files[0]?.path??null),h(`The reviewed revision changed.`))};if(n.isPending)return(0,U.jsx)(`p`,{"aria-live":`polite`,className:`mt-6 text-sm text-muted-foreground`,children:`Loading changed files…`});if(n.isError||!l)return(0,U.jsx)(`p`,{className:`mt-6 text-sm text-danger`,children:`Changed files could not be loaded.`});if(!l.available)return(0,U.jsx)(`p`,{className:`mt-6 text-sm text-muted-foreground`,children:l.reason});let p=u.map(e=>({path:e.path,...e.previousPath?{oldPath:e.previousPath}:{},status:e.status===`removed`?`deleted`:e.status===`changed`?`modified`:e.status,adds:e.additions,dels:e.deletions,binary:e.patchUnavailableReason===`binary`,patch:e.patch??``})),m=w(e.url)?`${e.url}/files`:null,g=u.find(e=>e.path===o);return(0,U.jsxs)(`section`,{"data-slot":`gh-pr-changes`,className:`mt-5 min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,U.jsxs)(`strong`,{children:[l.files.length,` changed files`]}),(0,U.jsxs)(`span`,{className:`text-success`,children:[`+`,l.additions]}),(0,U.jsxs)(`span`,{className:`text-danger`,children:[`−`,l.deletions]}),(0,U.jsxs)(`span`,{className:`font-mono text-muted-foreground`,title:l.headSha,children:[`head `,l.headSha.slice(0,8)]}),(0,U.jsx)(x,{type:`button`,variant:`outline`,size:`sm`,className:`ml-auto min-h-11`,onClick:()=>void f(),children:`Refresh`})]}),l.truncated?(0,U.jsxs)(`p`,{role:`status`,className:`mt-3 rounded-md border border-warning/40 bg-warning/10 p-3 text-xs`,children:[l.reason??`This response is incomplete.`,` `,m?(0,U.jsx)(`a`,{href:m,target:`_blank`,rel:`noopener noreferrer`,className:`underline`,children:`Open all files on GitHub`}):null]}):null,(0,U.jsxs)(`div`,{className:`mt-4 grid min-w-0 gap-4 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,U.jsxs)(`aside`,{className:`min-w-0`,children:[(0,U.jsx)(`input`,{"aria-label":`Filter changed files`,value:r,onChange:e=>a(e.target.value),placeholder:`Filter files…`,className:`min-h-11 w-full rounded-md border border-input bg-background px-3 text-sm`}),(0,U.jsx)(`select`,{"aria-label":`Select changed file`,value:o??``,onChange:e=>c(e.target.value),className:`mt-2 min-h-11 w-full rounded-md border border-input bg-background px-2 text-sm lg:hidden`,children:u.map(e=>(0,U.jsx)(`option`,{children:e.path},e.path))}),(0,U.jsx)(`ul`,{className:`mt-2 hidden max-h-[60vh] overflow-auto lg:block`,children:u.map(e=>(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{type:`button`,onClick:()=>c(e.path),className:T(`min-h-11 w-full truncate rounded px-2 text-left text-xs`,o===e.path&&`bg-muted font-medium`),title:e.path,children:[e.status,` · `,e.path,` `,(0,U.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions]}),` `,(0,U.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions]})]})},e.path))})]}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`mb-2 flex justify-end gap-1`,children:[(0,U.jsx)(x,{"aria-label":`Previous file`,variant:`outline`,size:`icon`,className:`min-h-11 min-w-11`,disabled:d<=0,onClick:()=>c(u[d-1]?.path??null),children:(0,U.jsx)(Ve,{})}),(0,U.jsx)(x,{"aria-label":`Next file`,variant:`outline`,size:`icon`,className:`min-h-11 min-w-11`,disabled:d<0||d>=u.length-1,onClick:()=>c(u[d+1]?.path??null),children:(0,U.jsx)(s,{size:16})})]}),u.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No changed files match this filter.`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(He,{files:p.filter(e=>e.path===o),wrap:!0,className:`min-w-0`}),g&&!g.patch?(0,U.jsxs)(`p`,{className:`rounded-b border border-border p-3 text-xs text-muted-foreground`,children:[`Patch unavailable: `,g.patchUnavailableReason??`not-provided`,`.`]}):null]})]})]})]})}function Xe({item:e,colors:t}){let n=k(e.kind,e.number),r=n.data,i=(0,H.useMemo)(()=>{let e=[...(r?.comments??[]).map(e=>({row:`comment`,comment:e})),...(r?.events??[]).map(e=>({row:`event`,event:e}))],t=e=>{let t=Date.parse(Ze(e));return Number.isNaN(t)?-1/0:t};return e.sort((e,n)=>t(e)-t(n))},[r?.comments,r?.events]);return n.isPending?(0,U.jsxs)(`section`,{"data-slot":`gh-thread-loading`,className:`mt-6 border-t border-border pt-5`,children:[(0,U.jsx)(W,{className:`mb-3 h-3 w-24`}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(W,{className:`h-14 w-full`}),(0,U.jsx)(W,{className:`h-14 w-full`})]})]}):!r||!r.available?(0,U.jsxs)(`section`,{"data-slot":`gh-thread-error`,className:`mt-6 border-t border-border pt-5 text-xs text-soft-foreground`,children:[(0,U.jsxs)(`span`,{children:[`Couldn’t load comments — `,r?.reason??(n.error instanceof Error?n.error.message:`could not load comments`),`. `]}),(0,U.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-0.5 text-muted-foreground hover:text-foreground hover:underline`,children:[`open on GitHub`,(0,U.jsx)(I,{"aria-hidden":`true`,className:`size-2.5`})]})]}):i.length===0?null:(0,U.jsxs)(`section`,{"data-slot":`gh-thread`,className:`mt-6 border-t border-border pt-5`,children:[(0,U.jsxs)(`h3`,{"data-slot":`gh-thread-header`,className:`mb-4 text-[11px] font-semibold tracking-wide text-soft-foreground uppercase`,children:[`Activity · `,r.comments.length,` comment`,r.comments.length===1?``:`s`]}),(0,U.jsx)(`ul`,{className:`flex flex-col gap-5`,children:Qe(i).map(e=>e.group===`commits`?(0,U.jsx)($e,{commits:e.commits,colors:t},e.commits[0].id):e.entry.row===`comment`?(0,U.jsx)(it,{comment:e.entry.comment},`${e.entry.comment.kind}-${e.entry.comment.id}`):(0,U.jsx)(et,{event:e.entry.event,colors:t},e.entry.event.id))}),r.truncated?(0,U.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-thread-truncated`,className:`mt-4 inline-flex items-center gap-0.5 text-xs text-soft-foreground hover:text-foreground hover:underline`,children:[`thread truncated — open on GitHub`,(0,U.jsx)(I,{"aria-hidden":`true`,className:`size-2.5`})]}):null]})}var Ze=e=>e.row===`comment`?e.comment.createdAt:e.event.createdAt;function Qe(e){let t=[],n=[],r=()=>{n.length!==0&&(n.length===1?t.push({group:`single`,entry:{row:`event`,event:n[0]}}):t.push({group:`commits`,commits:n}),n=[])};for(let i of e){if(i.row===`event`&&i.event.kind===`committed`&&i.row===`event`){let e=n[n.length-1];e&&e.actor!==i.event.actor&&r(),n.push(i.event);continue}r(),t.push({group:`single`,entry:i})}return r(),t}function $e({commits:e,colors:t}){let[n,r]=(0,H.useState)(!1),i=e[0]?.actor??`?`;return n?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`true`,className:`min-w-0`,children:(0,U.jsxs)(`button`,{type:`button`,"aria-expanded":!0,onClick:()=>r(!1),className:`flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground hover:text-foreground`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,children:J.committed}),(0,U.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,U.jsxs)(`span`,{children:[`added `,e.length,` commits`]})]})}),e.map(e=>(0,U.jsx)(et,{event:e,colors:t},e.id))]}):(0,U.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`false`,className:`min-w-0`,children:(0,U.jsxs)(`button`,{type:`button`,"aria-expanded":!1,onClick:()=>r(!0),className:`flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground hover:text-foreground`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,children:J.committed}),(0,U.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,U.jsxs)(`span`,{children:[`added `,e.length,` commits`]}),(0,U.jsx)(`span`,{className:`shrink-0`,children:z(e[e.length-1].createdAt)})]})})}var J={committed:`⚙`,labeled:`◆`,unlabeled:`◇`,assigned:`◍`,unassigned:`◌`,merged:`⑃`,closed:`⊘`,reopened:`⊙`,head_ref_force_pushed:`↻`,"cross-referenced":`↗`,renamed:`✎`};function et({event:e,colors:t}){return(0,U.jsxs)(`li`,{"data-slot":`gh-event-row`,"data-kind":e.kind,className:T(`flex min-w-0 items-center gap-1.5 font-mono text-[11px] text-soft-foreground`,e.kind===`merged`&&`text-accent-foreground`),children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:J[e.kind]}),(0,U.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.actor}),(0,U.jsx)(tt,{event:e,colors:t}),(0,U.jsx)(`span`,{className:`shrink-0`,children:z(e.createdAt)}),e.url?(0,U.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`open ${e.kind} on GitHub`,className:`ml-auto shrink-0 text-muted-foreground hover:text-foreground`,children:(0,U.jsx)(I,{"aria-hidden":`true`,className:`size-2.5`})}):null]})}function tt({event:e,colors:t}){switch(e.kind){case`committed`:return(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:`shrink-0`,children:`committed`}),e.sha?(0,U.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.sha.slice(0,7)}):null,e.message?(0,U.jsx)(`span`,{className:`truncate font-sans text-foreground`,children:e.message}):null,(0,U.jsx)(nt,{checks:e.checks})]});case`labeled`:case`unlabeled`:return(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:`shrink-0`,children:e.kind===`labeled`?`added the`:`removed the`}),e.label?(0,U.jsx)(`span`,{"data-slot":`gh-event-label`,style:G(e.label.color??t[e.label.name]),className:`max-w-[12rem] truncate rounded-full border px-1.5 py-px font-sans text-[12px]`,children:e.label.name}):null,(0,U.jsx)(`span`,{className:`shrink-0`,children:`label`})]});case`assigned`:case`unassigned`:return(0,U.jsxs)(`span`,{className:`truncate`,children:[e.kind===`assigned`?`assigned`:`unassigned`,` `,e.subject??`someone`]});case`merged`:return(0,U.jsx)(`span`,{children:`merged this`});case`closed`:return(0,U.jsx)(`span`,{children:`closed this`});case`reopened`:return(0,U.jsx)(`span`,{children:`reopened this`});case`head_ref_force_pushed`:return(0,U.jsx)(`span`,{children:`force-pushed`});case`renamed`:return(0,U.jsxs)(`span`,{className:`truncate`,children:[`renamed this to `,e.subject??`—`]});case`cross-referenced`:return(0,U.jsxs)(`span`,{className:`truncate`,children:[`referenced this in `,e.refNumber?`#${e.refNumber}`:`another thread`,e.refTitle?` ${e.refTitle}`:``]})}}function nt({checks:e}){return e?(0,U.jsx)(`span`,{"data-slot":`gh-commit-checks`,"data-checks":e,"aria-label":`checks ${e}`,className:T(`shrink-0`,X[e]),children:Y[e]}):null}var rt={approved:{label:`approved`,tone:`border-success/40 text-success`},changes_requested:{label:`changes requested`,tone:`border-danger/40 text-danger`},commented:{label:`commented`,tone:`border-border text-muted-foreground`},dismissed:{label:`dismissed`,tone:`border-border text-muted-foreground`}};function it({comment:e}){let t=e.reviewState?rt[e.reviewState]:null;return(0,U.jsxs)(`li`,{"data-slot":`gh-thread-entry`,"data-kind":e.kind,className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground`,children:[(0,U.jsx)(at,{url:e.avatarUrl,login:e.author}),(0,U.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.author}),(0,U.jsx)(`span`,{children:z(e.createdAt)}),t?(0,U.jsx)(`span`,{"data-slot":`gh-review-chip`,"data-review-state":e.reviewState,className:T(`rounded-full border px-1.5 py-px font-sans text-[12px] font-medium`,t.tone),children:t.label}):null,(0,U.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`open comment on GitHub`,className:`ml-auto shrink-0 text-muted-foreground hover:text-foreground`,children:(0,U.jsx)(I,{"aria-hidden":`true`,className:`size-2.5`})})]}),(0,U.jsx)(`div`,{"data-slot":`gh-thread-body`,className:`text-sm`,children:e.body?(0,U.jsx)(Ie,{children:e.body}):(0,U.jsx)(`p`,{className:`text-soft-foreground`,children:`(no body)`})})]})}function at({url:e,login:t}){let[n,r]=(0,H.useState)(!1);return e&&!n?(0,U.jsx)(`img`,{src:e,alt:``,width:16,height:16,loading:`lazy`,onError:()=>r(!0),"data-slot":`gh-avatar`,className:`size-4 shrink-0 rounded-full`}):(0,U.jsx)(`span`,{"data-slot":`gh-avatar-fallback`,"aria-hidden":`true`,className:`flex size-4 shrink-0 items-center justify-center rounded-full bg-muted text-[8px] font-semibold text-muted-foreground uppercase`,children:t.slice(0,1)||`?`})}var Y={passing:`✓`,failing:`✗`,pending:`○`},X={passing:`text-success`,failing:`text-danger`,pending:`text-muted-foreground`};function ot({count:e}){return e?(0,U.jsxs)(`span`,{"data-slot":`gh-comment-count`,"data-count":e,"aria-label":`${e} comment${e===1?``:`s`}`,className:`inline-flex shrink-0 items-center gap-0.5`,children:[(0,U.jsx)(ge,{"aria-hidden":`true`,className:`size-3`}),e]}):null}function st({checks:e,url:t}){let n=T(`text-[11px] font-medium`,X[e],t&&`hover:underline`),r=`${Y[e]} checks ${e}`;return t?(0,U.jsx)(`a`,{href:`${t}/checks`,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-checks`,"data-checks":e,className:n,children:r}):(0,U.jsx)(`span`,{"data-slot":`gh-checks`,"data-checks":e,className:n,children:r})}function ct({checks:e}){return(0,U.jsx)(`span`,{"data-slot":`gh-row-checks`,"data-checks":e,title:`checks ${e}`,"aria-label":`checks ${e}`,className:T(`shrink-0 font-sans text-[11px] font-semibold`,X[e]),children:Y[e]})}function Z(e){return`${e.kind===`pr`?`Address GitHub pull request`:`Fix GitHub issue`} #${e.number}: ${e.title}\n\n${e.url}`}function lt(e,t=[]){let n=Z(e);return e.body?.trim()&&(n+=`\n\n---\n\n${e.body.trim()}`),t.length&&(n+=ut(t)),n}function ut(e){return`\n\nUse these skills where relevant: ${e.join(`, `)}.`}function dt(e,t){return e.replace(/\{\{\s*number\s*\}\}/gi,()=>`#${t.number}`).replace(/\{\{\s*title\s*\}\}/gi,()=>t.title).replace(/\{\{\s*url\s*\}\}/gi,()=>t.url)}function ft(e,t){if(e.includes(t.url))return!0;let n=t.kind===`pr`?String.raw`(?:pull\s+request|pr)`:String.raw`issue`;return new RegExp(String.raw`\b${n}\s*#?\s*${t.number}\b`,`i`).test(e)}function Q(e,t,n){let r=(n??``).trim();if(!r)return lt(e,t);let i=Z(e),a=r.startsWith(i)?i+dt(r.slice(i.length),e):dt(r,e),o=ft(a,e)?a:`${i}\n\n${a}`;return t.length?o+ut(t):o}function pt(e){let t=[];for(let n of e.slice(0,8)){let e=new Set(t.map(e=>e.id)),r=n;for(let t=2;e.has(r);t++)r=`${n}-${t}`;t.push({id:r,name:n,skill:n,prompt:`{{task}}`})}return t}function mt(e,t,n,r,i={}){return t?{...i,workflow:t,task:Q(e,n,r)}:n.length?{...i,steps:pt(n),task:Q(e,[],r)}:{...i,workflow:`quick-task`,task:Q(e,[],r)}}var ht={workflow:null,skills:[]},gt=`cez-followup-selection`;function _t(e){let t=e&&typeof e==`object`?e:{};return{workflow:typeof t.workflow==`string`?t.workflow:null,skills:Array.isArray(t.skills)?t.skills.filter(e=>typeof e==`string`):[]}}function vt(){try{let e=localStorage.getItem(gt);return e?_t(JSON.parse(e)):{...ht}}catch{return{...ht}}}function yt(e){try{localStorage.setItem(gt,JSON.stringify(e))}catch{}}var $=`cez-followup-prompt:`;function bt(e){try{return localStorage.getItem($+e)??``}catch{return``}}function xt(e,t){try{t===``?localStorage.removeItem($+e):localStorage.setItem($+e,t)}catch{}}function St({item:e,workflows:t,skills:n,workflow:r,onWorkflowChange:i,selectedSkills:o,onSkillsChange:s,engine:c,onEngineChange:l,queuedRunId:d,onQueued:f}){let p=S(),m=te(),g=e.kind===`pr`?`PR`:`issue`,_=o.filter(e=>n.some(t=>t.name===e)),[v]=(0,H.useState)(()=>Z(e)),[y,C]=(0,H.useState)(()=>bt(e.url)||v),T=Pe(c),E=(0,H.useRef)(null),D=(0,H.useRef)(null);(0,H.useEffect)(()=>{xt(e.url,y===v?``:y)},[e.url,y,v]);let O=(0,H.useMemo)(()=>ie(m.data?.promptTemplates),[m.data?.promptTemplates]),k=e=>{let t=E.current,n=fe({prompt:y,base:v,selectionStart:t?.selectionStart??null,focused:document.activeElement===t,remembered:D.current}),r=de(y,n,e);C(r.text),D.current=r.caret,requestAnimationFrame(()=>{E.current?.focus(),E.current?.setSelectionRange(r.caret,r.caret)})},A=ce(O,_),M=(0,H.useRef)(y);M.current=y;let P=(0,H.useRef)(``);(0,H.useEffect)(()=>{let e=le(M.current,P.current,A,v);P.current=e.applied,e.text!==M.current&&C(e.text)},[A,v]);let F=N({mutationFn:async()=>T.canRun?b(mt(e,r,_,y,Ne(T))):null,onSuccess:t=>{if(t===null)return;let n=`runs`in t?t.runs[0]:t;n&&f(e.url,n.id),h(`Added to the queue — ${g} #${e.number}`),_.length>0&&m.data!==void 0&&ee({skillUsage:_.reduce((e,t)=>Ae(e,t),m.data.skillUsage)}).then(()=>p.invalidateQueries({queryKey:j.uiState})).catch(()=>{}),xt(e.url,``),C(v),P.current=``,p.invalidateQueries({queryKey:j.runs.all})},onError:e=>h(e.message,{tone:`danger`})}),I=e=>{Me({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),!F.isPending&&T.canRun&&F.mutate())},L=e=>s(o.includes(e)?o.filter(t=>t!==e):[...o,e]);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`section`,{"data-slot":`gh-hand`,className:`mt-7 rounded-lg border border-border bg-card p-4`,children:[(0,U.jsx)(`h3`,{className:`text-xl font-normal text-foreground`,children:`Hand this to the agent`}),(0,U.jsxs)(`label`,{className:`gh-field gh-prompt-field`,children:[(0,U.jsx)(`span`,{children:`Instructions for the agent`}),(0,U.jsx)(Te,{ref:E,"data-slot":`gh-custom-prompt`,"aria-label":`Custom prompt`,"aria-keyshortcuts":`Control+Enter Meta+Enter`,value:y,onChange:e=>C(e.target.value),onSelect:e=>{D.current=e.currentTarget.selectionStart},onKeyDown:I,placeholder:`Instructions for the agent… (#${e.number} and its link are always sent)`,className:`mt-3 min-h-20 text-[13px]`})]}),(0,U.jsx)(Le,{templates:O,onInsert:k}),(0,U.jsxs)(`div`,{className:`gh-handoff-settings`,children:[(0,U.jsxs)(`div`,{className:`gh-field`,children:[(0,U.jsx)(`span`,{children:`Workflow`}),(0,U.jsx)(Ct,{workflows:t,value:r,onChange:i})]}),(0,U.jsxs)(`div`,{className:`gh-field`,children:[(0,U.jsx)(`span`,{children:`Skills · select one or more`}),(0,U.jsx)(Tt,{skills:n,skillUsage:m.data?.skillUsage,selected:_,onToggle:L})]}),_.length>0?(0,U.jsx)(`div`,{"data-slot":`gh-skill-chips`,className:`mt-2.5 flex flex-wrap gap-1.5`,children:_.map(e=>(0,U.jsxs)(`button`,{type:`button`,"data-slot":`gh-skill-chip`,"data-skill":e,onClick:()=>L(e),title:`Remove this skill`,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium text-foreground transition-colors hover:bg-danger/10 hover:text-danger`,children:[e,(0,U.jsx)(a,{size:16,"aria-hidden":`true`,className:`size-3`})]},e))}):null,(0,U.jsx)(ze,{layout:`row`,pick:c,onChange:l,disabled:F.isPending||!T.canRun,accounts:!0}),(0,U.jsxs)(`div`,{className:`gh-field`,children:[(0,U.jsx)(`span`,{children:`Account`}),(0,U.jsx)(wt,{resolved:T,disabled:F.isPending||!T.canRun,onPick:e=>l({...c,account:e})})]}),!T.providerPending&&!T.canRun?(0,U.jsxs)(`span`,{"data-slot":`gh-provider-gate`,className:`inline-flex flex-wrap items-center gap-1 text-xs text-muted-foreground`,children:[T.providerError?`Provider authentication could not be verified.`:`Connect an agent provider to run this item.`,(0,U.jsx)(B,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null]}),(0,U.jsxs)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:[e.kind===`pr`?`PR`:`Issue`,` number and link remain attached to the task. Edit the prompt before starting. Cmd/Ctrl+Enter submits; Enter adds a new line.`]})]}),(0,U.jsxs)(`div`,{"data-slot":`gh-handoff-actions`,className:`mt-[22px] flex flex-wrap items-center gap-2.5`,children:[w(e.url)?(0,U.jsx)(x,{asChild:!0,variant:`outline`,children:(0,U.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:`Open in GitHub`})}):null,(0,U.jsxs)(x,{variant:`primary`,"data-action":`gh-run`,disabled:F.isPending||!T.canRun,onClick:()=>F.mutate(),children:[(0,U.jsx)(ve,{"aria-hidden":`true`,className:`size-3.5`}),`Run agent on this `,g]}),(0,U.jsx)(`kbd`,{"aria-hidden":`true`,className:`rounded-[5px] border border-b-2 border-border bg-card px-[5px] py-px font-mono text-[11px] font-medium text-muted-foreground`,children:Re()}),d?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`span`,{"data-slot":`gh-queued`,className:`flex items-center gap-1 text-xs font-medium text-success`,children:[(0,U.jsx)(u,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`queued`]}),(0,U.jsx)(B,{to:`/tasks/${d}`,"data-slot":`gh-view-run`,className:`text-xs font-semibold text-accent-text hover:underline`,children:`View task →`})]}):null]})]})}function Ct({workflows:e,value:t,onChange:n}){let[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(``),s=(0,H.useRef)(null),c=Ee(e,a);return(0,U.jsxs)(L,{open:r,onOpenChange:e=>{i(e),e||o(``)},children:[(0,U.jsx)(P,{asChild:!0,children:(0,U.jsxs)(`button`,{type:`button`,"data-slot":`gh-workflow-trigger`,"aria-label":`Choose a workflow`,className:T(me,t&&`border-foreground/60 font-mono text-[11px] font-semibold text-foreground`),children:[(0,U.jsx)(m,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),(0,U.jsx)(`span`,{className:`min-w-0 max-w-44 truncate`,children:t??`workflow`}),(0,U.jsx)(f,{size:16,"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,U.jsx)(F,{align:`start`,sideOffset:8,className:`w-[320px] max-w-[calc(100vw-2rem)] p-0`,children:(0,U.jsxs)(ae,{shouldFilter:!1,children:[(0,U.jsx)(oe,{placeholder:`search workflows…`,value:a,onValueChange:o,onInput:()=>s.current?.scrollTo(0,0)}),(0,U.jsxs)(se,{ref:s,"data-slot":`gh-workflow-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[c.length===0?(0,U.jsx)(pe,{children:`Nothing matches.`}):null,(0,U.jsx)(R,{children:c.map(e=>{let r=t===e.name;return(0,U.jsxs)(ue,{value:`workflow ${e.name}`,keywords:De(e.name,e.description),"data-slot":`gh-workflow-option`,"data-workflow":e.name,onSelect:()=>{n(r?null:e.name),i(!1)},children:[(0,U.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),e.description?(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,r?(0,U.jsx)(u,{size:16,"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},e.name)})})]})]})})]})}function wt({resolved:e,disabled:t,onPick:n}){let r=e.accounts.filter(t=>t.provider===e.runner),i=[...r.some(e=>e.id==="default")?[]:[{value:E,label:`Default`}],...r.map(e=>({value:e.id,label:e.label,desc:e.configDir}))],a=e.account??e.repoAccount?.[e.runner]??`default`;return(0,U.jsx)(re,{icon:(0,U.jsx)(l,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),slot:`account-pill`,ariaLabel:`Account`,label:i.find(e=>e.value===a)?.label??`Default`,value:a,options:i,disabled:t,onPick:n})}function Tt({skills:e,skillUsage:t,selected:n,onToggle:r}){let[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(``),[c,l]=(0,H.useState)(null),p=(0,H.useRef)(null),{mostUsed:m,project:h,global:g,ranked:_}=je(e,o,t),v=(e,t)=>{let i=n.includes(e.name);return(0,U.jsxs)(ue,{value:`skill ${e.name} ${e.path}`,keywords:De(e.name,e.description),"data-slot":`gh-skill-option`,"data-skill":e.name,"data-selected":i?`true`:void 0,onSelect:()=>r(e.name),children:[(0,U.jsx)(`span`,{className:T(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.description?(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,(0,U.jsx)(`button`,{type:`button`,"data-slot":`gh-skill-view`,"aria-label":`View skill ${e.name}`,title:`View skill`,onClick:t=>{t.preventDefault(),t.stopPropagation(),l(e)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,U.jsx)(ne,{"aria-hidden":`true`,className:`size-3.5`})}),i?(0,U.jsx)(u,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},e.path)};return e.length===0?null:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Fe,{skill:c,onClose:()=>l(null)}),(0,U.jsxs)(L,{open:i,onOpenChange:e=>{a(e),e||s(``)},children:[(0,U.jsx)(P,{asChild:!0,children:(0,U.jsxs)(`button`,{type:`button`,"data-slot":`gh-skills-trigger`,"aria-label":`Choose skills`,className:T(me,n.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,U.jsx)(d,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),`skills`,n.length>0?` · ${n.length}`:``,(0,U.jsx)(f,{size:16,"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,U.jsx)(F,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,U.jsxs)(ae,{shouldFilter:!1,children:[(0,U.jsx)(oe,{placeholder:`search skills…`,value:o,onValueChange:s,onInput:()=>p.current?.scrollTo(0,0)}),(0,U.jsxs)(se,{ref:p,"data-slot":`gh-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[(_?_.length===0:m.length===0&&h.length===0&&g.length===0)?(0,U.jsx)(pe,{children:`Nothing matches.`}):null,_?_.length>0?(0,U.jsx)(R,{children:_.map(e=>v(e,Oe(e)))}):null:(0,U.jsxs)(U.Fragment,{children:[m.length>0?(0,U.jsx)(R,{heading:`Most used`,children:m.map(e=>v(e,Oe(e)))}):null,h.length>0?(0,U.jsx)(R,{heading:`Project skills`,children:h.map(e=>v(e,!0))}):null,g.length>0?(0,U.jsx)(R,{heading:`Global`,children:g.map(e=>v(e,!1))}):null]})]})]})})]})]})}var Et=new WeakMap;function Dt(){let e=vt(),t={workflow:e.workflow,selectedSkills:e.skills,engine:{runner:null,model:null,effort:null,account:null},queued:new Map},n=new Set;return{snapshot:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)}),update:e=>{t={...t,...e},(e.workflow!==void 0||e.selectedSkills!==void 0)&&yt({workflow:t.workflow,skills:[...t.selectedSkills]}),n.forEach(e=>e())}}}function Ot(){let e=S(),{projectId:t}=y(),n=Et.get(e);n||Et.set(e,n=new Map);let r=n.get(t);r||n.set(t,r=Dt());let{snapshot:i,subscribe:a,update:o}=r,s=(0,H.useSyncExternalStore)(a,i,i),c=A(),l=O(),u=te(),d=c.data?.workflows;(0,H.useEffect)(()=>{d&&s.workflow!==null&&!d.some(e=>e.name===s.workflow)&&o({workflow:null})},[o,d,s.workflow]);let f=(0,H.useMemo)(()=>ke(l.data??[],u.data?.skillUsage),[l.data,u.data?.skillUsage]);return{...s,workflows:c,skillList:f,setWorkflow:e=>o({workflow:e}),setSelectedSkills:e=>o({selectedSkills:e}),setEngine:e=>o({engine:e}),onQueued:(e,t)=>o({queued:new Map(i().queued).set(e,t)})}}export{ot as a,Qe as c,G as d,Ge as f,ct as i,Ue as l,St as n,qe as o,lt as r,Ke as s,Ot as t,We as u};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ar as r,Bn as i,Bt as a,D as o,F as s,Gi as c,It as l,N as u,Ot as d,P as f,Pt as p,Rt as m,Si as h,St as g,V as _,Vn as v,Wt as y,fn as b,qr as ee,t as x,ta as S,z as C}from"./button-Jj1Itx83.js";import{n as w,t as T,y as E}from"./utils-POVs3UKu.js";import{U as D,Ut as O,V as k,Xt as A,b as j,gt as M,qn as N,qt as te}from"./alert-dialog-A0-kEfJK.js";import{i as P,r as F,s as I,t as L}from"./popover-BjjDOSGv.js";import{L as ne,_ as re,a as ie,c as ae,d as R,f as oe,m as se,n as ce,o as le,p as ue,r as de,s as fe,u as pe,x as me}from"./prompt-templates-DFeXUVOZ.js";import{f as he,n as z,r as B}from"./format-DTNjugyE.js";import{n as ge,t as _e}from"./tab-link-COpvArgR.js";import{t as ve}from"./play-CmVAj_fu.js";import{a as ye,i as be,n as xe,o as Se,r as Ce,s as we,t as Te}from"./textarea-BbNV5Uo2.js";import{d as Ee,f as De,i as Oe,s as ke,t as Ae,u as je}from"./skills-DFBiAuJG.js";import{Bt as Me,Gt as Ne,Kt as Pe,Mt as Fe,Pt as Ie,Ut as Le,Vt as Re,Wt as ze,a as Be,l as V,sn as Ve}from"./index-BfAearY6.js";import{t as He}from"./diff-CDL5SDNO.js";var H=e(t(),1),U=n();function W({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`skeleton`,className:T(`animate-pulse rounded-md bg-accent`,e),...t})}function Ue(e){let t=new Set;for(let n of e)for(let e of n.labels)t.add(e);return[...t].sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()))}function We(e,t={}){let n=(t.query??``).trim().toLowerCase(),r=t.labels??[],i=n.replace(/^#/,``),a=i!==``&&/^\d+$/.test(i);return e.filter(e=>r.length>0&&!r.every(t=>e.labels.includes(t))||t.assignees?.length&&!e.assignees?.some(e=>t.assignees.some(t=>t.toLowerCase()===e.toLowerCase()))||t.author!==void 0&&e.author.toLowerCase()!==t.author.toLowerCase()||t.includeNumbers&&!t.includeNumbers.has(e.number)||t.excludeNumbers?.has(e.number)||t.projectId&&e.projectIds!==void 0&&!e.projectIds.includes(t.projectId)?!1:n===``?!0:a?String(e.number).includes(i):`#${e.number} ${e.title} ${e.author} ${e.body}`.toLowerCase().includes(n))}function Ge(e,t){let n=e.trim();if(n===``)return!1;let r=n.replace(/^#/,``);return/^\d+$/.test(r)?!t.some(e=>e.number===Number(r)):t.length===0}function G(e){if(!e||!/^[0-9a-fA-F]{6}$/.test(e))return{borderColor:`var(--border)`,color:`var(--muted-foreground)`};let t=`#${e}`;return{backgroundColor:`${t}22`,borderColor:`${t}66`,color:`color-mix(in srgb, ${t} 50%, var(--foreground))`}}function Ke({label:e,color:t,plain:n=!1}){return(0,U.jsx)(`span`,{"data-slot":`gh-label`,"data-label":e,style:n?void 0:G(t),className:n?`text-[11px] font-normal text-muted-foreground`:`rounded-full border px-1.5 py-px text-[12px] font-medium`,children:e})}function qe({item:e,colors:t,checks:n,backLink:r,subNav:i,onRunAgent:a,afterHeading:s,children:c}){let l=i?.changes??!1,u=e.kind===`pr`?`pull request`:`issue`,d=e.kind===`pr`&&!!(e.additions||e.deletions);return(0,U.jsxs)(`article`,{"data-slot":`gh-detail-inner`,className:`min-w-0 px-4 py-4 md:px-7 md:py-5`,children:[r?(0,U.jsxs)(B,{to:r.to,"data-slot":`gh-back`,className:`mb-3 inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground md:hidden`,children:[(0,U.jsx)(o,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`Back to the list`]}):null,(0,U.jsxs)(`div`,{"data-slot":`gh-description-card`,className:e.kind===`pr`?`rounded-xl border border-border bg-card p-6`:void 0,children:[e.kind===`pr`?(0,U.jsxs)(`h2`,{className:`mb-4 text-[22px] leading-snug font-normal`,children:[`#`,e.number,` `,e.title]}):null,(0,U.jsxs)(`p`,{"data-slot":`gh-meta`,className:`flex flex-wrap items-center gap-x-1.5 font-mono text-[11px] text-soft-foreground`,children:[(0,U.jsxs)(`span`,{children:[`#`,e.number]}),`·`,(0,U.jsx)(`span`,{children:u}),`·`,(0,U.jsxs)(`span`,{children:[`opened by `,e.author]}),`·`,(0,U.jsxs)(`span`,{children:[z(e.createdAt),` ago`]}),e.comments?(0,U.jsxs)(U.Fragment,{children:[`·`,(0,U.jsx)(ot,{count:e.comments})]}):null,d?(0,U.jsxs)(U.Fragment,{children:[`·`,(0,U.jsxs)(`span`,{"data-slot":`gh-diffstat`,children:[(0,U.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions??0]}),` `,(0,U.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions??0]})]})]}):null,`·`,w(e.url)?(0,U.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-open-link`,className:`inline-flex items-center gap-0.5 text-muted-foreground hover:text-foreground hover:underline`,children:[`open on GitHub`,(0,U.jsx)(I,{"aria-hidden":`true`,className:`size-2.5`})]}):(0,U.jsx)(`span`,{"data-slot":`gh-open-link`,className:`text-muted-foreground`,children:`open on GitHub`})]}),e.kind===`pr`?null:(0,U.jsx)(`h2`,{className:`mt-2 text-[22px] leading-snug font-normal`,children:e.title}),s,e.kind===`pr`&&i?(0,U.jsxs)(`nav`,{"aria-label":`Pull request detail`,className:`mt-4 flex border-b border-border`,children:[(0,U.jsx)(_e,{to:V(`prs`,i.filter,e.number),active:!l,children:`Conversation`}),(0,U.jsx)(_e,{to:V(`prs`,i.filter,e.number,`/changes`),active:l,children:`Changes`})]}):e.kind===`pr`?(0,U.jsx)(B,{to:V(`prs`,null,e.number,`/changes`),"data-slot":`gh-files-changed`,className:`mt-3 inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:underline`,children:`Files changed`}):null,e.labels.length>0||n?(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[e.labels.map(e=>(0,U.jsx)(Ke,{label:e,color:t[e]},e)),n?(0,U.jsx)(st,{checks:n,url:e.url}):null]}):null,l&&e.kind===`pr`?(0,U.jsx)(Ye,{item:e}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{"data-slot":`gh-body`,className:`mt-5 text-sm`,children:e.body?(0,U.jsx)(Ie,{children:e.body}):(0,U.jsx)(`p`,{className:`text-soft-foreground`,children:`(no description)`})}),(0,U.jsx)(Xe,{item:e,colors:t})]})]}),e.kind===`pr`?(0,U.jsx)(Je,{number:e.number,onRunAgent:a}):null,c]})}var K={squash:`Squash and merge`,merge:`Create a merge commit`,rebase:`Rebase and merge`};function q({state:e}){let t=`size-4 shrink-0`;return e===`passing`?(0,U.jsx)(u,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-passing`,className:T(t,`text-success`)}):e===`failing`?(0,U.jsx)(_,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-failing`,className:T(t,`text-danger`)}):e===`pending`?(0,U.jsx)(he,{"aria-hidden":`true`,"data-slot":`gh-merge-status-pending`,className:T(t,`animate-spin text-warning`)}):(0,U.jsx)(C,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-unknown`,className:T(t,`text-soft-foreground`)})}function Je({number:e,onRunAgent:t}){let n=S(),i=M(),a=c({queryKey:j.githubMergeState(e),queryFn:({signal:t})=>v(e,{},{signal:t}),retry:!1}),o=a.data?.available?a.data.mergeState:null,[s,l]=(0,H.useState)(null),[d,f]=(0,H.useState)(!1),[m,_]=(0,H.useState)(!1),y=N({mutationFn:t=>v(e,{refresh:!0}),onSuccess:(e,t)=>n.setQueryData(t,e),onError:e=>h(e instanceof Error?e.message:String(e),{tone:`danger`})}),b=s&&o?.methods.includes(s)?s:o?.defaultMethod??o?.methods[0]??null,ee=()=>({mergeState:j.githubMergeState(e),list:j.github({limit:Be}),comments:j.githubComments(`pr`,e),item:j.githubItem(`pr`,e),refStatus:i===void 0?void 0:j.githubRefStatusOf(i)}),C=N({mutationFn:t=>{if(!o||!b)throw Error(`No merge method is available.`);return r(e,{method:b,expectedHeadSha:o.headSha,...m&&o.canOverride?{overrideRules:!0}:{}})},onSuccess:(t,r)=>{f(!1),h(`Pull request #${e} merged`),n.invalidateQueries({queryKey:r.mergeState}),n.invalidateQueries({queryKey:r.list}),n.invalidateQueries({queryKey:r.comments}),n.invalidateQueries({queryKey:r.item}),r.refStatus&&n.invalidateQueries({queryKey:r.refStatus})},onError:(e,t)=>{h(e instanceof Error?e.message:String(e),{tone:`danger`}),n.invalidateQueries({queryKey:t.mergeState})}});if(a.isPending)return(0,U.jsx)(W,{"data-slot":`gh-merge-loading`,className:`mt-6 h-32 w-full`});if(!o)return(0,U.jsxs)(`section`,{"data-slot":`gh-merge-unavailable`,className:`mt-6 rounded-lg border border-border bg-card p-4 text-sm`,children:[(0,U.jsx)(`p`,{className:`font-medium`,children:`Merge status unavailable`}),(0,U.jsx)(`p`,{className:`mt-1 text-xs text-soft-foreground`,children:a.data?.available===!1?a.data.reason:`GitHub could not load merge requirements.`})]});let E=o.state===`merged`?`Merged`:o.state===`closed`?`Closed`:o.isDraft?`Draft`:o.mergeable===`conflicting`?`Conflicts must be resolved`:o.canMerge?`Ready to merge`:o.eligibility===`unknown`?`Merge blocked · Requirements unknown`:`Merge blocked`,D=o.reviewDecision===`approved`?`passing`:o.reviewDecision===`unknown`?`unknown`:`failing`,O=o.mergeable===`mergeable`?`passing`:o.mergeable===`conflicting`?`failing`:`unknown`,k=!!(b&&(o.canMerge||o.canOverride&&m));return(0,U.jsxs)(`section`,{"data-slot":`gh-merge-box`,"data-eligibility":o.eligibility,"data-conflicting":o.mergeable===`conflicting`?`true`:void 0,"aria-live":`polite`,className:`mt-6 rounded-lg border border-border bg-card p-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-start gap-3`,children:[o.canMerge?(0,U.jsx)(u,{size:16,"aria-hidden":`true`,className:`mt-0.5 size-5 shrink-0 text-success`}):(0,U.jsx)(p,{size:16,"aria-hidden":`true`,className:`mt-0.5 size-5 shrink-0 text-warning`}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,U.jsx)(`h3`,{className:`font-semibold`,children:E}),(0,U.jsxs)(x,{type:`button`,variant:`ghost`,size:`sm`,disabled:y.isPending,onClick:()=>y.mutate(j.githubMergeState(e)),children:[(0,U.jsx)(g,{size:16,"aria-hidden":`true`,className:T(`size-3.5`,y.isPending&&`animate-spin`)}),`Refresh`]})]}),(0,U.jsxs)(`p`,{className:`mt-1 font-mono text-[11px] text-soft-foreground`,children:[o.headRef,` (`,o.headSha.slice(0,7),`) → `,o.baseRef]}),(0,U.jsxs)(`ul`,{className:`mt-3 space-y-2 text-xs`,children:[(0,U.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(q,{state:D}),(0,U.jsxs)(`span`,{children:[`Reviews: `,o.reviewDecision.replaceAll(`-`,` `)]})]}),(0,U.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(q,{state:O}),(0,U.jsxs)(`span`,{children:[`Conflicts: `,o.mergeable===`conflicting`?`present`:o.mergeable===`mergeable`?`none`:`unknown`]})]}),o.checks.length===0?(0,U.jsx)(`li`,{children:`No checks configured`}):o.checks.map(e=>(0,U.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(q,{state:e.state}),(0,U.jsxs)(`span`,{children:[e.name,` · `,e.state,e.required===!0?` · required`:e.required===null?` · requiredness unknown`:``]})]}),e.url&&w(e.url)?(0,U.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-muted-foreground underline`,children:`details`}):null]},e.name)),o.blockers.map(e=>(0,U.jsx)(`li`,{className:`text-soft-foreground`,children:e.message},e.code))]}),o.mergeable===`conflicting`&&t?(0,U.jsx)(x,{className:`mt-4`,onClick:t,children:`Run agent on this PR`}):null,o.canOverride?(0,U.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-2 rounded-md border border-warning/40 bg-warning/5 p-3 text-xs`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:m,onChange:e=>_(e.target.checked),className:`mt-0.5 size-4 accent-accent-strong`}),(0,U.jsxs)(`span`,{children:[(0,U.jsx)(`span`,{className:`block font-medium`,children:`Merge without waiting for requirements`}),(0,U.jsx)(`span`,{className:`mt-0.5 block text-soft-foreground`,children:`GitHub will allow this only if your permissions can bypass the repository rules.`})]})]}):null,o.eligibility===`unknown`?(0,U.jsx)(`p`,{className:`mt-4 text-xs text-muted-foreground`,children:`GitHub could not confirm review and branch-protection requirements. Passing checks do not establish merge readiness.`}):null,o.state===`open`&&o.methods.length>0?(0,U.jsxs)(`div`,{className:`mt-4 flex flex-col flex-wrap gap-2 sm:flex-row`,children:[(0,U.jsx)(`select`,{"aria-label":`Merge method`,value:b??``,onChange:e=>l(e.target.value),className:`h-9 min-w-0 flex-1 rounded-md border border-input bg-background px-3 text-sm`,children:o.methods.map(e=>(0,U.jsx)(`option`,{value:e,children:K[e]},e))}),(0,U.jsx)(x,{disabled:!k,onClick:()=>f(!0),children:b?K[b]:`Merge`})]}):null]})]}),(0,U.jsx)(xe,{open:d,onOpenChange:f,children:(0,U.jsxs)(Ce,{"data-slot":`gh-merge-confirm`,showCloseButton:!1,children:[(0,U.jsxs)(Se,{children:[(0,U.jsxs)(we,{children:[b?K[b]:`Merge`,` pull request #`,e,`?`]}),(0,U.jsx)(be,{asChild:!0,children:(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`p`,{children:[`This will merge “`,o.title,`” into `,o.baseRef,`. GitHub will re-check the exact reviewed head before changing the repository.`]}),m&&o.canOverride?(0,U.jsx)(`p`,{"data-slot":`gh-bypass-warning`,className:`mt-4 text-sm text-warning`,children:`You are asking GitHub to bypass unmet repository requirements; GitHub may refuse if your permissions do not allow it.`}):null]})})]}),C.error?(0,U.jsx)(`p`,{className:`text-sm text-danger`,children:C.error.message}):null,(0,U.jsxs)(ye,{children:[(0,U.jsx)(x,{variant:`outline`,disabled:C.isPending,onClick:()=>f(!1),children:`Cancel`}),(0,U.jsx)(x,{disabled:C.isPending,onClick:()=>C.mutate(ee()),children:C.isPending?`Merging…`:b?K[b]:`Merge`})]})]})})]})}function Ye({item:e}){let t=S(),n=D(e.number),[r,a]=(0,H.useState)(``),[o,c]=(0,H.useState)(null),l=n.data,u=l?.available?l.files.filter(e=>e.path.toLowerCase().includes(r.toLowerCase())):[],d=u.findIndex(e=>e.path===o);(0,H.useEffect)(()=>{u.length>0&&!u.some(e=>e.path===o)&&c(u[0].path)},[l?.available?l.headSha:``,r]);let f=async()=>{let n=l?.available?l.headSha:null,r=j.githubPrChanges(e.number),a=await i(e.number,{refresh:!0});t.setQueryData(r,a),a.available&&n&&n!==a.headSha&&(c(a.files[0]?.path??null),h(`The reviewed revision changed.`))};if(n.isPending)return(0,U.jsx)(`p`,{"aria-live":`polite`,className:`mt-6 text-sm text-muted-foreground`,children:`Loading changed files…`});if(n.isError||!l)return(0,U.jsx)(`p`,{className:`mt-6 text-sm text-danger`,children:`Changed files could not be loaded.`});if(!l.available)return(0,U.jsx)(`p`,{className:`mt-6 text-sm text-muted-foreground`,children:l.reason});let p=u.map(e=>({path:e.path,...e.previousPath?{oldPath:e.previousPath}:{},status:e.status===`removed`?`deleted`:e.status===`changed`?`modified`:e.status,adds:e.additions,dels:e.deletions,binary:e.patchUnavailableReason===`binary`,patch:e.patch??``})),m=w(e.url)?`${e.url}/files`:null,g=u.find(e=>e.path===o);return(0,U.jsxs)(`section`,{"data-slot":`gh-pr-changes`,className:`mt-5 min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,U.jsxs)(`strong`,{children:[l.files.length,` changed files`]}),(0,U.jsxs)(`span`,{className:`text-success`,children:[`+`,l.additions]}),(0,U.jsxs)(`span`,{className:`text-danger`,children:[`−`,l.deletions]}),(0,U.jsxs)(`span`,{className:`font-mono text-muted-foreground`,title:l.headSha,children:[`head `,l.headSha.slice(0,8)]}),(0,U.jsx)(x,{type:`button`,variant:`outline`,size:`sm`,className:`ml-auto min-h-11`,onClick:()=>void f(),children:`Refresh`})]}),l.truncated?(0,U.jsxs)(`p`,{role:`status`,className:`mt-3 rounded-md border border-warning/40 bg-warning/10 p-3 text-xs`,children:[l.reason??`This response is incomplete.`,` `,m?(0,U.jsx)(`a`,{href:m,target:`_blank`,rel:`noopener noreferrer`,className:`underline`,children:`Open all files on GitHub`}):null]}):null,(0,U.jsxs)(`div`,{className:`mt-4 grid min-w-0 gap-4 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,U.jsxs)(`aside`,{className:`min-w-0`,children:[(0,U.jsx)(`input`,{"aria-label":`Filter changed files`,value:r,onChange:e=>a(e.target.value),placeholder:`Filter files…`,className:`min-h-11 w-full rounded-md border border-input bg-background px-3 text-sm`}),(0,U.jsx)(`select`,{"aria-label":`Select changed file`,value:o??``,onChange:e=>c(e.target.value),className:`mt-2 min-h-11 w-full rounded-md border border-input bg-background px-2 text-sm lg:hidden`,children:u.map(e=>(0,U.jsx)(`option`,{children:e.path},e.path))}),(0,U.jsx)(`ul`,{className:`mt-2 hidden max-h-[60vh] overflow-auto lg:block`,children:u.map(e=>(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{type:`button`,onClick:()=>c(e.path),className:T(`min-h-11 w-full truncate rounded px-2 text-left text-xs`,o===e.path&&`bg-muted font-medium`),title:e.path,children:[e.status,` · `,e.path,` `,(0,U.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions]}),` `,(0,U.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions]})]})},e.path))})]}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`mb-2 flex justify-end gap-1`,children:[(0,U.jsx)(x,{"aria-label":`Previous file`,variant:`outline`,size:`icon`,className:`min-h-11 min-w-11`,disabled:d<=0,onClick:()=>c(u[d-1]?.path??null),children:(0,U.jsx)(Ve,{})}),(0,U.jsx)(x,{"aria-label":`Next file`,variant:`outline`,size:`icon`,className:`min-h-11 min-w-11`,disabled:d<0||d>=u.length-1,onClick:()=>c(u[d+1]?.path??null),children:(0,U.jsx)(s,{size:16})})]}),u.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No changed files match this filter.`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(He,{files:p.filter(e=>e.path===o),wrap:!0,className:`min-w-0`}),g&&!g.patch?(0,U.jsxs)(`p`,{className:`rounded-b border border-border p-3 text-xs text-muted-foreground`,children:[`Patch unavailable: `,g.patchUnavailableReason??`not-provided`,`.`]}):null]})]})]})]})}function Xe({item:e,colors:t}){let n=k(e.kind,e.number),r=n.data,i=(0,H.useMemo)(()=>{let e=[...(r?.comments??[]).map(e=>({row:`comment`,comment:e})),...(r?.events??[]).map(e=>({row:`event`,event:e}))],t=e=>{let t=Date.parse(Ze(e));return Number.isNaN(t)?-1/0:t};return e.sort((e,n)=>t(e)-t(n))},[r?.comments,r?.events]);return n.isPending?(0,U.jsxs)(`section`,{"data-slot":`gh-thread-loading`,className:`mt-6 border-t border-border pt-5`,children:[(0,U.jsx)(W,{className:`mb-3 h-3 w-24`}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(W,{className:`h-14 w-full`}),(0,U.jsx)(W,{className:`h-14 w-full`})]})]}):!r||!r.available?(0,U.jsxs)(`section`,{"data-slot":`gh-thread-error`,className:`mt-6 border-t border-border pt-5 text-xs text-soft-foreground`,children:[(0,U.jsxs)(`span`,{children:[`Couldn’t load comments — `,r?.reason??(n.error instanceof Error?n.error.message:`could not load comments`),`. `]}),(0,U.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-0.5 text-muted-foreground hover:text-foreground hover:underline`,children:[`open on GitHub`,(0,U.jsx)(I,{"aria-hidden":`true`,className:`size-2.5`})]})]}):i.length===0?null:(0,U.jsxs)(`section`,{"data-slot":`gh-thread`,className:`mt-6 border-t border-border pt-5`,children:[(0,U.jsxs)(`h3`,{"data-slot":`gh-thread-header`,className:`mb-4 text-[11px] font-semibold tracking-wide text-soft-foreground uppercase`,children:[`Activity · `,r.comments.length,` comment`,r.comments.length===1?``:`s`]}),(0,U.jsx)(`ul`,{className:`flex flex-col gap-5`,children:Qe(i).map(e=>e.group===`commits`?(0,U.jsx)($e,{commits:e.commits,colors:t},e.commits[0].id):e.entry.row===`comment`?(0,U.jsx)(it,{comment:e.entry.comment},`${e.entry.comment.kind}-${e.entry.comment.id}`):(0,U.jsx)(et,{event:e.entry.event,colors:t},e.entry.event.id))}),r.truncated?(0,U.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-thread-truncated`,className:`mt-4 inline-flex items-center gap-0.5 text-xs text-soft-foreground hover:text-foreground hover:underline`,children:[`thread truncated — open on GitHub`,(0,U.jsx)(I,{"aria-hidden":`true`,className:`size-2.5`})]}):null]})}var Ze=e=>e.row===`comment`?e.comment.createdAt:e.event.createdAt;function Qe(e){let t=[],n=[],r=()=>{n.length!==0&&(n.length===1?t.push({group:`single`,entry:{row:`event`,event:n[0]}}):t.push({group:`commits`,commits:n}),n=[])};for(let i of e){if(i.row===`event`&&i.event.kind===`committed`&&i.row===`event`){let e=n[n.length-1];e&&e.actor!==i.event.actor&&r(),n.push(i.event);continue}r(),t.push({group:`single`,entry:i})}return r(),t}function $e({commits:e,colors:t}){let[n,r]=(0,H.useState)(!1),i=e[0]?.actor??`?`;return n?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`true`,className:`min-w-0`,children:(0,U.jsxs)(`button`,{type:`button`,"aria-expanded":!0,onClick:()=>r(!1),className:`flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground hover:text-foreground`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,children:J.committed}),(0,U.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,U.jsxs)(`span`,{children:[`added `,e.length,` commits`]})]})}),e.map(e=>(0,U.jsx)(et,{event:e,colors:t},e.id))]}):(0,U.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`false`,className:`min-w-0`,children:(0,U.jsxs)(`button`,{type:`button`,"aria-expanded":!1,onClick:()=>r(!0),className:`flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground hover:text-foreground`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,children:J.committed}),(0,U.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,U.jsxs)(`span`,{children:[`added `,e.length,` commits`]}),(0,U.jsx)(`span`,{className:`shrink-0`,children:z(e[e.length-1].createdAt)})]})})}var J={committed:`⚙`,labeled:`◆`,unlabeled:`◇`,assigned:`◍`,unassigned:`◌`,merged:`⑃`,closed:`⊘`,reopened:`⊙`,head_ref_force_pushed:`↻`,"cross-referenced":`↗`,renamed:`✎`};function et({event:e,colors:t}){return(0,U.jsxs)(`li`,{"data-slot":`gh-event-row`,"data-kind":e.kind,className:T(`flex min-w-0 items-center gap-1.5 font-mono text-[11px] text-soft-foreground`,e.kind===`merged`&&`text-accent-foreground`),children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:J[e.kind]}),(0,U.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.actor}),(0,U.jsx)(tt,{event:e,colors:t}),(0,U.jsx)(`span`,{className:`shrink-0`,children:z(e.createdAt)}),e.url?(0,U.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`open ${e.kind} on GitHub`,className:`ml-auto shrink-0 text-muted-foreground hover:text-foreground`,children:(0,U.jsx)(I,{"aria-hidden":`true`,className:`size-2.5`})}):null]})}function tt({event:e,colors:t}){switch(e.kind){case`committed`:return(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:`shrink-0`,children:`committed`}),e.sha?(0,U.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.sha.slice(0,7)}):null,e.message?(0,U.jsx)(`span`,{className:`truncate font-sans text-foreground`,children:e.message}):null,(0,U.jsx)(nt,{checks:e.checks})]});case`labeled`:case`unlabeled`:return(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:`shrink-0`,children:e.kind===`labeled`?`added the`:`removed the`}),e.label?(0,U.jsx)(`span`,{"data-slot":`gh-event-label`,style:G(e.label.color??t[e.label.name]),className:`max-w-[12rem] truncate rounded-full border px-1.5 py-px font-sans text-[12px]`,children:e.label.name}):null,(0,U.jsx)(`span`,{className:`shrink-0`,children:`label`})]});case`assigned`:case`unassigned`:return(0,U.jsxs)(`span`,{className:`truncate`,children:[e.kind===`assigned`?`assigned`:`unassigned`,` `,e.subject??`someone`]});case`merged`:return(0,U.jsx)(`span`,{children:`merged this`});case`closed`:return(0,U.jsx)(`span`,{children:`closed this`});case`reopened`:return(0,U.jsx)(`span`,{children:`reopened this`});case`head_ref_force_pushed`:return(0,U.jsx)(`span`,{children:`force-pushed`});case`renamed`:return(0,U.jsxs)(`span`,{className:`truncate`,children:[`renamed this to `,e.subject??`—`]});case`cross-referenced`:return(0,U.jsxs)(`span`,{className:`truncate`,children:[`referenced this in `,e.refNumber?`#${e.refNumber}`:`another thread`,e.refTitle?` ${e.refTitle}`:``]})}}function nt({checks:e}){return e?(0,U.jsx)(`span`,{"data-slot":`gh-commit-checks`,"data-checks":e,"aria-label":`checks ${e}`,className:T(`shrink-0`,X[e]),children:Y[e]}):null}var rt={approved:{label:`approved`,tone:`border-success/40 text-success`},changes_requested:{label:`changes requested`,tone:`border-danger/40 text-danger`},commented:{label:`commented`,tone:`border-border text-muted-foreground`},dismissed:{label:`dismissed`,tone:`border-border text-muted-foreground`}};function it({comment:e}){let t=e.reviewState?rt[e.reviewState]:null;return(0,U.jsxs)(`li`,{"data-slot":`gh-thread-entry`,"data-kind":e.kind,className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground`,children:[(0,U.jsx)(at,{url:e.avatarUrl,login:e.author}),(0,U.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.author}),(0,U.jsx)(`span`,{children:z(e.createdAt)}),t?(0,U.jsx)(`span`,{"data-slot":`gh-review-chip`,"data-review-state":e.reviewState,className:T(`rounded-full border px-1.5 py-px font-sans text-[12px] font-medium`,t.tone),children:t.label}):null,(0,U.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`open comment on GitHub`,className:`ml-auto shrink-0 text-muted-foreground hover:text-foreground`,children:(0,U.jsx)(I,{"aria-hidden":`true`,className:`size-2.5`})})]}),(0,U.jsx)(`div`,{"data-slot":`gh-thread-body`,className:`text-sm`,children:e.body?(0,U.jsx)(Ie,{children:e.body}):(0,U.jsx)(`p`,{className:`text-soft-foreground`,children:`(no body)`})})]})}function at({url:e,login:t}){let[n,r]=(0,H.useState)(!1);return e&&!n?(0,U.jsx)(`img`,{src:e,alt:``,width:16,height:16,loading:`lazy`,onError:()=>r(!0),"data-slot":`gh-avatar`,className:`size-4 shrink-0 rounded-full`}):(0,U.jsx)(`span`,{"data-slot":`gh-avatar-fallback`,"aria-hidden":`true`,className:`flex size-4 shrink-0 items-center justify-center rounded-full bg-muted text-[8px] font-semibold text-muted-foreground uppercase`,children:t.slice(0,1)||`?`})}var Y={passing:`✓`,failing:`✗`,pending:`○`},X={passing:`text-success`,failing:`text-danger`,pending:`text-muted-foreground`};function ot({count:e}){return e?(0,U.jsxs)(`span`,{"data-slot":`gh-comment-count`,"data-count":e,"aria-label":`${e} comment${e===1?``:`s`}`,className:`inline-flex shrink-0 items-center gap-0.5`,children:[(0,U.jsx)(ge,{"aria-hidden":`true`,className:`size-3`}),e]}):null}function st({checks:e,url:t}){let n=T(`text-[11px] font-medium`,X[e],t&&`hover:underline`),r=`${Y[e]} checks ${e}`;return t?(0,U.jsx)(`a`,{href:`${t}/checks`,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-checks`,"data-checks":e,className:n,children:r}):(0,U.jsx)(`span`,{"data-slot":`gh-checks`,"data-checks":e,className:n,children:r})}function ct({checks:e}){return(0,U.jsx)(`span`,{"data-slot":`gh-row-checks`,"data-checks":e,title:`checks ${e}`,"aria-label":`checks ${e}`,className:T(`shrink-0 font-sans text-[11px] font-semibold`,X[e]),children:Y[e]})}function Z(e){return`${e.kind===`pr`?`Address GitHub pull request`:`Fix GitHub issue`} #${e.number}: ${e.title}\n\n${e.url}`}function lt(e,t=[]){let n=Z(e);return e.body?.trim()&&(n+=`\n\n---\n\n${e.body.trim()}`),t.length&&(n+=ut(t)),n}function ut(e){return`\n\nUse these skills where relevant: ${e.join(`, `)}.`}function dt(e,t){return e.replace(/\{\{\s*number\s*\}\}/gi,()=>`#${t.number}`).replace(/\{\{\s*title\s*\}\}/gi,()=>t.title).replace(/\{\{\s*url\s*\}\}/gi,()=>t.url)}function ft(e,t){if(e.includes(t.url))return!0;let n=t.kind===`pr`?String.raw`(?:pull\s+request|pr)`:String.raw`issue`;return new RegExp(String.raw`\b${n}\s*#?\s*${t.number}\b`,`i`).test(e)}function Q(e,t,n){let r=(n??``).trim();if(!r)return lt(e,t);let i=Z(e),a=r.startsWith(i)?i+dt(r.slice(i.length),e):dt(r,e),o=ft(a,e)?a:`${i}\n\n${a}`;return t.length?o+ut(t):o}function pt(e){let t=[];for(let n of e.slice(0,8)){let e=new Set(t.map(e=>e.id)),r=n;for(let t=2;e.has(r);t++)r=`${n}-${t}`;t.push({id:r,name:n,skill:n,prompt:`{{task}}`})}return t}function mt(e,t,n,r,i={}){return t?{...i,workflow:t,task:Q(e,n,r)}:n.length?{...i,steps:pt(n),task:Q(e,[],r)}:{...i,workflow:`quick-task`,task:Q(e,[],r)}}var ht={workflow:null,skills:[]},gt=`cez-followup-selection`;function _t(e){let t=e&&typeof e==`object`?e:{};return{workflow:typeof t.workflow==`string`?t.workflow:null,skills:Array.isArray(t.skills)?t.skills.filter(e=>typeof e==`string`):[]}}function vt(){try{let e=localStorage.getItem(gt);return e?_t(JSON.parse(e)):{...ht}}catch{return{...ht}}}function yt(e){try{localStorage.setItem(gt,JSON.stringify(e))}catch{}}var $=`cez-followup-prompt:`;function bt(e){try{return localStorage.getItem($+e)??``}catch{return``}}function xt(e,t){try{t===``?localStorage.removeItem($+e):localStorage.setItem($+e,t)}catch{}}function St({item:e,workflows:t,skills:n,workflow:r,onWorkflowChange:i,selectedSkills:o,onSkillsChange:s,engine:c,onEngineChange:l,queuedRunId:d,onQueued:f}){let p=S(),m=te(),g=e.kind===`pr`?`PR`:`issue`,_=o.filter(e=>n.some(t=>t.name===e)),[v]=(0,H.useState)(()=>Z(e)),[y,C]=(0,H.useState)(()=>bt(e.url)||v),T=Pe(c),E=(0,H.useRef)(null),D=(0,H.useRef)(null);(0,H.useEffect)(()=>{xt(e.url,y===v?``:y)},[e.url,y,v]);let O=(0,H.useMemo)(()=>ie(m.data?.promptTemplates),[m.data?.promptTemplates]),k=e=>{let t=E.current,n=fe({prompt:y,base:v,selectionStart:t?.selectionStart??null,focused:document.activeElement===t,remembered:D.current}),r=de(y,n,e);C(r.text),D.current=r.caret,requestAnimationFrame(()=>{E.current?.focus(),E.current?.setSelectionRange(r.caret,r.caret)})},A=ce(O,_),M=(0,H.useRef)(y);M.current=y;let P=(0,H.useRef)(``);(0,H.useEffect)(()=>{let e=le(M.current,P.current,A,v);P.current=e.applied,e.text!==M.current&&C(e.text)},[A,v]);let F=N({mutationFn:async()=>T.canRun?b(mt(e,r,_,y,Ne(T))):null,onSuccess:t=>{if(t===null)return;let n=`runs`in t?t.runs[0]:t;n&&f(e.url,n.id),h(`Added to the queue — ${g} #${e.number}`),_.length>0&&m.data!==void 0&&ee({skillUsage:_.reduce((e,t)=>Ae(e,t),m.data.skillUsage)}).then(()=>p.invalidateQueries({queryKey:j.uiState})).catch(()=>{}),xt(e.url,``),C(v),P.current=``,p.invalidateQueries({queryKey:j.runs.all})},onError:e=>h(e.message,{tone:`danger`})}),I=e=>{Me({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),!F.isPending&&T.canRun&&F.mutate())},L=e=>s(o.includes(e)?o.filter(t=>t!==e):[...o,e]);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`section`,{"data-slot":`gh-hand`,className:`mt-7 rounded-lg border border-border bg-card p-4`,children:[(0,U.jsx)(`h3`,{className:`text-xl font-normal text-foreground`,children:`Hand this to the agent`}),(0,U.jsxs)(`label`,{className:`gh-field gh-prompt-field`,children:[(0,U.jsx)(`span`,{children:`Instructions for the agent`}),(0,U.jsx)(Te,{ref:E,"data-slot":`gh-custom-prompt`,"aria-label":`Custom prompt`,"aria-keyshortcuts":`Control+Enter Meta+Enter`,value:y,onChange:e=>C(e.target.value),onSelect:e=>{D.current=e.currentTarget.selectionStart},onKeyDown:I,placeholder:`Instructions for the agent… (#${e.number} and its link are always sent)`,className:`mt-3 min-h-20 text-[13px]`})]}),(0,U.jsx)(Le,{templates:O,onInsert:k}),(0,U.jsxs)(`div`,{className:`gh-handoff-settings`,children:[(0,U.jsxs)(`div`,{className:`gh-field`,children:[(0,U.jsx)(`span`,{children:`Workflow`}),(0,U.jsx)(Ct,{workflows:t,value:r,onChange:i})]}),(0,U.jsxs)(`div`,{className:`gh-field`,children:[(0,U.jsx)(`span`,{children:`Skills · select one or more`}),(0,U.jsx)(Tt,{skills:n,skillUsage:m.data?.skillUsage,selected:_,onToggle:L})]}),_.length>0?(0,U.jsx)(`div`,{"data-slot":`gh-skill-chips`,className:`mt-2.5 flex flex-wrap gap-1.5`,children:_.map(e=>(0,U.jsxs)(`button`,{type:`button`,"data-slot":`gh-skill-chip`,"data-skill":e,onClick:()=>L(e),title:`Remove this skill`,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium text-foreground transition-colors hover:bg-danger/10 hover:text-danger`,children:[e,(0,U.jsx)(a,{size:16,"aria-hidden":`true`,className:`size-3`})]},e))}):null,(0,U.jsx)(ze,{layout:`row`,pick:c,onChange:l,disabled:F.isPending||!T.canRun,accounts:!0}),(0,U.jsxs)(`div`,{className:`gh-field`,children:[(0,U.jsx)(`span`,{children:`Account`}),(0,U.jsx)(wt,{resolved:T,disabled:F.isPending||!T.canRun,onPick:e=>l({...c,account:e})})]}),!T.providerPending&&!T.canRun?(0,U.jsxs)(`span`,{"data-slot":`gh-provider-gate`,className:`inline-flex flex-wrap items-center gap-1 text-xs text-muted-foreground`,children:[T.providerError?`Provider authentication could not be verified.`:`Connect an agent provider to run this item.`,(0,U.jsx)(B,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null]}),(0,U.jsxs)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:[e.kind===`pr`?`PR`:`Issue`,` number and link remain attached to the task. Edit the prompt before starting. Cmd/Ctrl+Enter submits; Enter adds a new line.`]})]}),(0,U.jsxs)(`div`,{"data-slot":`gh-handoff-actions`,className:`mt-[22px] flex flex-wrap items-center gap-2.5`,children:[w(e.url)?(0,U.jsx)(x,{asChild:!0,variant:`outline`,children:(0,U.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:`Open in GitHub`})}):null,(0,U.jsxs)(x,{variant:`primary`,"data-action":`gh-run`,disabled:F.isPending||!T.canRun,onClick:()=>F.mutate(),children:[(0,U.jsx)(ve,{"aria-hidden":`true`,className:`size-3.5`}),`Run agent on this `,g]}),(0,U.jsx)(`kbd`,{"aria-hidden":`true`,className:`rounded-[5px] border border-b-2 border-border bg-card px-[5px] py-px font-mono text-[11px] font-medium text-muted-foreground`,children:Re()}),d?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`span`,{"data-slot":`gh-queued`,className:`flex items-center gap-1 text-xs font-medium text-success`,children:[(0,U.jsx)(u,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`queued`]}),(0,U.jsx)(B,{to:`/tasks/${d}`,"data-slot":`gh-view-run`,className:`text-xs font-semibold text-accent-text hover:underline`,children:`View task →`})]}):null]})]})}function Ct({workflows:e,value:t,onChange:n}){let[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(``),s=(0,H.useRef)(null),c=Ee(e,a);return(0,U.jsxs)(L,{open:r,onOpenChange:e=>{i(e),e||o(``)},children:[(0,U.jsx)(P,{asChild:!0,children:(0,U.jsxs)(`button`,{type:`button`,"data-slot":`gh-workflow-trigger`,"aria-label":`Choose a workflow`,className:T(me,t&&`border-foreground/60 font-mono text-[11px] font-semibold text-foreground`),children:[(0,U.jsx)(m,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),(0,U.jsx)(`span`,{className:`min-w-0 max-w-44 truncate`,children:t??`workflow`}),(0,U.jsx)(f,{size:16,"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,U.jsx)(F,{align:`start`,sideOffset:8,className:`w-[320px] max-w-[calc(100vw-2rem)] p-0`,children:(0,U.jsxs)(ae,{shouldFilter:!1,children:[(0,U.jsx)(oe,{placeholder:`search workflows…`,value:a,onValueChange:o,onInput:()=>s.current?.scrollTo(0,0)}),(0,U.jsxs)(se,{ref:s,"data-slot":`gh-workflow-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[c.length===0?(0,U.jsx)(pe,{children:`Nothing matches.`}):null,(0,U.jsx)(R,{children:c.map(e=>{let r=t===e.name;return(0,U.jsxs)(ue,{value:`workflow ${e.name}`,keywords:De(e.name,e.description),"data-slot":`gh-workflow-option`,"data-workflow":e.name,onSelect:()=>{n(r?null:e.name),i(!1)},children:[(0,U.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),e.description?(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,r?(0,U.jsx)(u,{size:16,"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},e.name)})})]})]})})]})}function wt({resolved:e,disabled:t,onPick:n}){let r=e.accounts.filter(t=>t.provider===e.runner),i=[...r.some(e=>e.id==="default")?[]:[{value:E,label:`Default`}],...r.map(e=>({value:e.id,label:e.label,desc:e.configDir}))],a=e.account??e.repoAccount?.[e.runner]??`default`;return(0,U.jsx)(re,{icon:(0,U.jsx)(l,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),slot:`account-pill`,ariaLabel:`Account`,label:i.find(e=>e.value===a)?.label??`Default`,value:a,options:i,disabled:t,onPick:n})}function Tt({skills:e,skillUsage:t,selected:n,onToggle:r}){let[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(``),[c,l]=(0,H.useState)(null),p=(0,H.useRef)(null),{mostUsed:m,project:h,global:g,ranked:_}=je(e,o,t),v=(e,t)=>{let i=n.includes(e.name);return(0,U.jsxs)(ue,{value:`skill ${e.name} ${e.path}`,keywords:De(e.name,e.description),"data-slot":`gh-skill-option`,"data-skill":e.name,"data-selected":i?`true`:void 0,onSelect:()=>r(e.name),children:[(0,U.jsx)(`span`,{className:T(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.description?(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,(0,U.jsx)(`button`,{type:`button`,"data-slot":`gh-skill-view`,"aria-label":`View skill ${e.name}`,title:`View skill`,onClick:t=>{t.preventDefault(),t.stopPropagation(),l(e)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,U.jsx)(ne,{"aria-hidden":`true`,className:`size-3.5`})}),i?(0,U.jsx)(u,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},e.path)};return e.length===0?null:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Fe,{skill:c,onClose:()=>l(null)}),(0,U.jsxs)(L,{open:i,onOpenChange:e=>{a(e),e||s(``)},children:[(0,U.jsx)(P,{asChild:!0,children:(0,U.jsxs)(`button`,{type:`button`,"data-slot":`gh-skills-trigger`,"aria-label":`Choose skills`,className:T(me,n.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,U.jsx)(d,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),`skills`,n.length>0?` · ${n.length}`:``,(0,U.jsx)(f,{size:16,"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,U.jsx)(F,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,U.jsxs)(ae,{shouldFilter:!1,children:[(0,U.jsx)(oe,{placeholder:`search skills…`,value:o,onValueChange:s,onInput:()=>p.current?.scrollTo(0,0)}),(0,U.jsxs)(se,{ref:p,"data-slot":`gh-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[(_?_.length===0:m.length===0&&h.length===0&&g.length===0)?(0,U.jsx)(pe,{children:`Nothing matches.`}):null,_?_.length>0?(0,U.jsx)(R,{children:_.map(e=>v(e,Oe(e)))}):null:(0,U.jsxs)(U.Fragment,{children:[m.length>0?(0,U.jsx)(R,{heading:`Most used`,children:m.map(e=>v(e,Oe(e)))}):null,h.length>0?(0,U.jsx)(R,{heading:`Project skills`,children:h.map(e=>v(e,!0))}):null,g.length>0?(0,U.jsx)(R,{heading:`Global`,children:g.map(e=>v(e,!1))}):null]})]})]})})]})]})}var Et=new WeakMap;function Dt(){let e=vt(),t={workflow:e.workflow,selectedSkills:e.skills,engine:{runner:null,model:null,effort:null,account:null},queued:new Map},n=new Set;return{snapshot:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)}),update:e=>{t={...t,...e},(e.workflow!==void 0||e.selectedSkills!==void 0)&&yt({workflow:t.workflow,skills:[...t.selectedSkills]}),n.forEach(e=>e())}}}function Ot(){let e=S(),{projectId:t}=y(),n=Et.get(e);n||Et.set(e,n=new Map);let r=n.get(t);r||n.set(t,r=Dt());let{snapshot:i,subscribe:a,update:o}=r,s=(0,H.useSyncExternalStore)(a,i,i),c=A(),l=O(),u=te(),d=c.data?.workflows;(0,H.useEffect)(()=>{d&&s.workflow!==null&&!d.some(e=>e.name===s.workflow)&&o({workflow:null})},[o,d,s.workflow]);let f=(0,H.useMemo)(()=>ke(l.data??[],u.data?.skillUsage),[l.data,u.data?.skillUsage]);return{...s,workflows:c,skillList:f,setWorkflow:e=>o({workflow:e}),setSelectedSkills:e=>o({selectedSkills:e}),setEngine:e=>o({engine:e}),onQueued:(e,t)=>o({queued:new Map(i().queued).set(e,t)})}}export{ot as a,Qe as c,G as d,Ge as f,ct as i,Ue as l,St as n,qe as o,lt as r,Ke as s,Ot as t,We as u};