cezarion 0.19.0-dev.8799 → 0.19.0-dev.8816

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 (74) hide show
  1. package/package.json +3 -3
  2. package/web/dist/assets/{accounts-section-B3XlbE9-.js → accounts-section-CnQrgrlx.js} +1 -1
  3. package/web/dist/assets/{activity-motion-DtSeos5G.js → activity-motion-SZyZ3Vcd.js} +1 -1
  4. package/web/dist/assets/{activity-route-DwLbg5TU.js → activity-route-kA927mMd.js} +1 -1
  5. package/web/dist/assets/{agent-config-section-TV__fszM.js → agent-config-section-DZ9lz-oU.js} +1 -1
  6. package/web/dist/assets/{agent-defaults-section-CoaKPbd7.js → agent-defaults-section-CAyM93lD.js} +1 -1
  7. package/web/dist/assets/{appearance-BSogGq4y.js → appearance-jU-y46Hc.js} +1 -1
  8. package/web/dist/assets/{archive-on-merge-field-Bzuu6JUq.js → archive-on-merge-field-C5WFm3HO.js} +1 -1
  9. package/web/dist/assets/attention-Dt-QhJ3p.js +1 -0
  10. package/web/dist/assets/automations-route-DzIrboEQ.js +2 -0
  11. package/web/dist/assets/{commit-list-CPCMhqsH.js → commit-list-JK2MEtR0.js} +1 -1
  12. package/web/dist/assets/{diff-eTwHyNBm.js → diff-CC-HnvfR.js} +2 -2
  13. package/web/dist/assets/{diff-controls-DT8_nQ2J.js → diff-controls-CnrIcRRG.js} +1 -1
  14. package/web/dist/assets/{diff-view-BnO_U5xn.js → diff-view-Dzl9i4zr.js} +1 -1
  15. package/web/dist/assets/{file-preview-L0_fbkUZ.js → file-preview-C1Nd5SH3.js} +1 -1
  16. package/web/dist/assets/{folder-browser-BzYB6BT2.js → folder-browser-ZmOa9z3j.js} +1 -1
  17. package/web/dist/assets/{git-toolbar-ywLSmnxR.js → git-toolbar-q-HOZgdL.js} +1 -1
  18. package/web/dist/assets/{github-Bd3i_-h6.js → github-RqiwU49D.js} +1 -1
  19. package/web/dist/assets/{global-activity-route-BbgDC3wz.js → global-activity-route-DTuWu-5a.js} +1 -1
  20. package/web/dist/assets/index-6yHpyOyH.js +21 -0
  21. package/web/dist/assets/index-DNgBNd8o.css +1 -0
  22. package/web/dist/assets/{label-CgZJ4LAh.js → label-D91E4F0a.js} +1 -1
  23. package/web/dist/assets/{markdown-Dn1C5VnY.js → markdown-NDbXgnqb.js} +1 -1
  24. package/web/dist/assets/{notifications-section-3xWRDUrB.js → notifications-section-CQ4HSyLK.js} +1 -1
  25. package/web/dist/assets/{open-in-menu-C09BLcfQ.js → open-in-menu-CqNkccJr.js} +1 -1
  26. package/web/dist/assets/preview-pane-connected-Dm-Ga2KN.js +3 -0
  27. package/web/dist/assets/{project-location-CVu4xirj.js → project-location-CspXXtNm.js} +1 -1
  28. package/web/dist/assets/{project-router-BypHPat0.js → project-router-BifLGgRR.js} +1 -1
  29. package/web/dist/assets/{projects-section-Brds9YmD.js → projects-section-CKPqFZP7.js} +1 -1
  30. package/web/dist/assets/{prompt-templates-section-CAuTp8gl.js → prompt-templates-section-D9Tsgav9.js} +1 -1
  31. package/web/dist/assets/{queries-EvENG6TN.js → queries-D0v1z40Y.js} +1 -1
  32. package/web/dist/assets/{reference-chip-BLHAGMsc.js → reference-chip-CV_vG2eP.js} +1 -1
  33. package/web/dist/assets/{remote-settings-notice-CxRBhjoN.js → remote-settings-notice-40uqklAG.js} +1 -1
  34. package/web/dist/assets/{repo-git-CGdMJ36u.js → repo-git-BBalirax.js} +1 -1
  35. package/web/dist/assets/{report-reader-BQyJblDp.js → report-reader-D3Heszz3.js} +1 -1
  36. package/web/dist/assets/{report-selection-CXF3VYjA.js → report-selection-CDlncYKI.js} +1 -1
  37. package/web/dist/assets/reports-CEaxAigM.js +1 -0
  38. package/web/dist/assets/{resources-section-Cbtu9i_k.js → resources-section-ohdWkreq.js} +1 -1
  39. package/web/dist/assets/{review-panel-DuvFn5VX.js → review-panel-CthaDvZO.js} +4 -4
  40. package/web/dist/assets/{run-detail-refresh-DXnE6Lc2.js → run-detail-refresh-DkwIHh-c.js} +1 -1
  41. package/web/dist/assets/run-header-9NNASXmJ.js +2 -0
  42. package/web/dist/assets/{select-D5UnnIUL.js → select-Bh7vwx79.js} +1 -1
  43. package/web/dist/assets/{session-context-section-CFw0aFoC.js → session-context-section-B5Ee7GbQ.js} +1 -1
  44. package/web/dist/assets/{settings-agent-picker-DIEyNQVg.js → settings-agent-picker-DeczgUDV.js} +1 -1
  45. package/web/dist/assets/settings-shell-BvRwl06q.js +1 -0
  46. package/web/dist/assets/{sidebar-section-CET3Eico.js → sidebar-section-Bn1Uv9AQ.js} +1 -1
  47. package/web/dist/assets/{skills-oxTqCu3h.js → skills-DMyaR3WX.js} +1 -1
  48. package/web/dist/assets/{tab-link-Bjo_gEiX.js → tab-link-DAxoMsUp.js} +1 -1
  49. package/web/dist/assets/task-changes-ChM901cL.js +1 -0
  50. package/web/dist/assets/{task-commits-DEsRCchM.js → task-commits-DOP65FDx.js} +1 -1
  51. package/web/dist/assets/{task-file-scope-CkPO86PU.js → task-file-scope-emNQrzps.js} +1 -1
  52. package/web/dist/assets/{task-files-BuMkWb7X.js → task-files-BYPCvDCO.js} +1 -1
  53. package/web/dist/assets/{task-github-item-wUJ6pMdV.js → task-github-item-CHGyiC4k.js} +1 -1
  54. package/web/dist/assets/{task-groups-nvRvmVHf.js → task-groups-BdayPxX3.js} +1 -1
  55. package/web/dist/assets/{task-thread-CS88T_7I.js → task-thread-BI2pi8dZ.js} +2 -2
  56. package/web/dist/assets/{tasks-table-DGBiE6ux.js → tasks-table-BY5niMlY.js} +1 -1
  57. package/web/dist/assets/thread-state-CdKvrn7R.js +4 -0
  58. package/web/dist/assets/{toaster-Cer2NOxt.js → toaster-DMfiAEnw.js} +1 -1
  59. package/web/dist/assets/use-hand-to-agent-state-stc7Vzni.js +1 -0
  60. package/web/dist/assets/{workflows-D0HHVBzP.js → workflows-DagjPw_m.js} +2 -2
  61. package/web/dist/assets/{workspace-tools-C8GYSy1Y.js → workspace-tools-BaLORh9B.js} +1 -1
  62. package/web/dist/assets/{worktrees-section-Ba0hS8Ls.js → worktrees-section-CSERluzw.js} +4 -4
  63. package/web/dist/index.html +14 -14
  64. package/web/dist/assets/attention-wzzAdp4t.js +0 -1
  65. package/web/dist/assets/automations-route-BO4qUbj8.js +0 -2
  66. package/web/dist/assets/index-8eoz1i7-.js +0 -21
  67. package/web/dist/assets/index-nVjwJYl4.css +0 -1
  68. package/web/dist/assets/preview-pane-connected-BdxTm5Ky.js +0 -3
  69. package/web/dist/assets/reports-CPpFm0jn.js +0 -1
  70. package/web/dist/assets/run-header-CP_2QY0H.js +0 -2
  71. package/web/dist/assets/settings-shell-DUvwIPgV.js +0 -1
  72. package/web/dist/assets/task-changes-TvjFctCc.js +0 -1
  73. package/web/dist/assets/thread-state-DulSg7h8.js +0 -4
  74. package/web/dist/assets/use-hand-to-agent-state-8ZF3Wr1m.js +0 -1
@@ -1,3 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{Xr as i,Yr as a,Zr as o,mr as s,n as c}from"./toaster-Cer2NOxt.js";import{t as l}from"./createLucideIcon-BHp8sXmF.js";import{t as u}from"./arrow-right-Dh_Lx3um.js";import{t as d}from"./check-OP-CVgZG.js";import{t as f}from"./chevron-down-CHGyCDBH.js";import{n as p,t as m}from"./circle-x-7nTlobAF.js";import{n as h,t as g}from"./smartphone-Lr8Ug2z_.js";import{t as _}from"./info-DA1x_4bz.js";import{t as v}from"./loader-circle-CPBhhDbB.js";import{n as y,t as ee}from"./moon-CRE9nU5R.js";import{t as b}from"./play-CmVAj_fu.js";import{o as x}from"./tool-display-B9NN44oU.js";import{n as te,o as S,s as C}from"./thread-state-DulSg7h8.js";import{t as ne}from"./square-terminal-B6RYYieR.js";import{t as w}from"./button-B7MKxYjT.js";import{a as T,c as re,i as E,l as D,p as O,r as k,s as ie,t as A}from"./dropdown-menu-4e2iKSMT.js";import{s as ae}from"./project-router-BypHPat0.js";import{t as j}from"./status-dot-BRzVlF2X.js";import{$n as oe,Bn as se,Rn as ce,Vn as le,_ as ue,c as de,cr as fe,d as pe,dr as me,f as M,l as he,lr as N,nr as ge,p as _e,u as ve,v as ye,y as be,zn as xe}from"./index-8eoz1i7-.js";var Se=l(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),P=l(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),Ce=l(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),F=l(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),I=l(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),L=l(`folder-x`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),we=l(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),R=l(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),z=l(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),Te=l(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),Ee=l(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),B=l(`monitor-smartphone`,[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]),V=l(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),H=l(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),U=l(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),W=l(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),G=l(`tablet`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]),K=l(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),q=l(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),De=l(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),J=e(t(),1),Oe=1e3,ke=[500,1e3,2e3,4e3,8e3],Ae=1;function je(e,t){let n=`/api/v1/p/${encodeURIComponent(e.projectId)}/runs/${encodeURIComponent(e.runId)}/preview/ws`,r=()=>`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${n}`,o=null,c,l=!1,u=!1,d=0,f=0,p=()=>typeof document>`u`||a(),m=()=>{if(l||!p())return;let e=globalThis.WebSocket;if(typeof e!=`function`)return;let n=new e(r());n.binaryType=`blob`,o=n,n.addEventListener(`open`,()=>{n===o&&(u=!0,t.onTransport(`open`))}),n.addEventListener(`message`,e=>{if(n!==o)return;let r=e.data;if(typeof r==`string`){let e;try{e=JSON.parse(r)}catch{return}let n=s.safeParse(e);n.success&&t.onMessage(n.data);return}r instanceof Blob&&(f=0,t.onFrame(r))}),n.addEventListener(`error`,()=>void 0),n.addEventListener(`close`,()=>{if(n!==o||l)return;if(o=null,!u){if(d+=1,d>=2){l=!0,t.onTransport(`blocked`);return}t.onTransport(`reconnecting`,d),c=setTimeout(m,Oe);return}if(f>=5){l=!0,t.onTransport(`closed`);return}let e=ke[Math.min(f,ke.length-1)];f+=1,t.onTransport(`reconnecting`,f),c=setTimeout(m,e)})},h=i(e=>{if(!l)if(e)o||m();else{clearTimeout(c),c=void 0;let e=o;o=null,e?.close(),t.onTransport(`connecting`)}});return t.onTransport(`connecting`),m(),{send(e){o?.readyState===Ae&&o.send(JSON.stringify(e))},close(){l=!0,h(),clearTimeout(c),c=void 0;let e=o;o=null,e?.close()}}}var Y=n();function Me({iconOnly:e=!1,responsive:t=!1,className:n}){return t?(0,Y.jsx)(se,{children:(0,Y.jsxs)(ce,{children:[(0,Y.jsx)(le,{asChild:!0,children:(0,Y.jsxs)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex h-7 min-w-7 shrink-0 items-center justify-center gap-0 rounded-full bg-muted px-0 text-xs font-semibold text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none @min-[860px]:gap-1.5 @min-[860px]:px-2.5`,n),children:[(0,Y.jsx)(I,{className:`size-3.5`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[860px]:inline`,children:`Experimental`})]})}),(0,Y.jsx)(xe,{children:`Experimental`})]})}):e?(0,Y.jsx)(se,{children:(0,Y.jsxs)(ce,{children:[(0,Y.jsx)(le,{asChild:!0,children:(0,Y.jsx)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex size-7 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,n),children:(0,Y.jsx)(I,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Y.jsx)(xe,{children:`Experimental`})]})}):(0,Y.jsxs)(`span`,{"data-slot":`preview-experimental`,className:r(`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full bg-muted px-2.5 text-xs font-semibold text-muted-foreground`,n),children:[(0,Y.jsx)(I,{className:`size-3.5`,"aria-hidden":`true`}),`Experimental`]})}function X({text:e,source:t,onCopy:n,className:i}){let a=e.replace(/\s+$/,``).split(`
2
- `);return(0,Y.jsxs)(`div`,{"data-slot":`preview-log-tail`,className:r(`min-w-0 rounded-lg bg-muted px-3.5 py-3 font-mono text-xs`,i),children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 font-sans text-xs text-soft-foreground`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,Y.jsx)(`span`,{className:`font-semibold tracking-wide uppercase`,children:`Log tail`}),` last ${a.length} ${a.length===1?`line`:`lines`} · ${t}`]}),(0,Y.jsxs)(`button`,{type:`button`,className:`-m-2 inline-flex min-h-11 items-center gap-1.5 rounded-sm p-2 text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:min-h-0 md:p-0`,onClick:()=>n(e),children:[(0,Y.jsx)(N,{className:`size-3.5`,"aria-hidden":`true`}),`Copy`]})]}),(0,Y.jsx)(`pre`,{className:`max-h-48 overflow-auto break-words whitespace-pre-wrap text-foreground`,children:e.replace(/\s+$/,``)})]})}var Ne=/^([a-z][a-z0-9+.-]*):/i;function Pe(e,t){let n=e.trim();if(n===``)return{kind:`error`,message:`Type a URL or a port.`};if(/^\d{1,5}$/.test(n)){let e=Number(n);return e<1||e>65535?{kind:`error`,message:`A port is a number from 1 to 65535.`}:t.some(t=>t.port===e)?{kind:`server`,port:e}:{kind:`url`,url:`http://localhost:${e}`}}let r=Ne.exec(n)?.[1]?.toLowerCase();return r&&!/^[a-z0-9.-]+:\d/i.test(n)?r!==`http`&&r!==`https`?{kind:`error`,message:`Only http and https addresses open here.`}:Fe(n):Fe(`http://${n}`)}function Fe(e){let t={kind:`error`,message:`That is not a valid address.`};if(/\s/.test(e))return t;try{new URL(e)}catch{return t}return{kind:`url`,url:e}}function Ie(e){return e.replace(/^https?:\/\//i,``)}var Le=`https://github.com/hearsay-tools/squawk#environment-variables`;function Re({state:e,actions:t,url:n,worktree:r}){switch(e.stage){case`chromium-missing`:return(0,Y.jsx)(He,{state:e,actions:t});case`downloading`:return(0,Y.jsx)(We,{state:e,actions:t});case`download-failed`:return(0,Y.jsx)(Ge,{state:e,actions:t});case`sandbox-failed`:return(0,Y.jsx)(Ke,{state:e,actions:t});case`browser-exited`:return(0,Y.jsx)(qe,{state:e,actions:t});case`needs-approval`:return(0,Y.jsx)(Xe,{state:e,actions:t});case`port-held`:return(0,Y.jsx)(Ze,{state:e,actions:t});case`server-starting`:return(0,Y.jsx)(Qe,{state:e,actions:t});case`server-stalled`:return(0,Y.jsx)($e,{state:e,actions:t});case`server-exited`:return(0,Y.jsx)(et,{state:e,actions:t});case`server-stopped`:return(0,Y.jsx)(tt,{state:e,actions:t});case`loading`:return(0,Y.jsx)(rt,{step:e.step,url:n});case`worktree-removed`:return(0,Y.jsx)(it,{state:e,actions:t,worktree:r});case`proxy-blocked`:return(0,Y.jsx)(at,{actions:t});case`taken-over`:return(0,Y.jsx)(st,{state:e,actions:t})}}function Z({icon:e,title:t,children:n,state:r}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":r,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:e}),(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:t}),n]})}var Q=({children:e})=>(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e}),$=({children:e})=>(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e});function ze({server:e}){return(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(ne,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`Runs ${M(e.command)} in this task's worktree, on the host.`})]})}function Be({copy:e,command:t,label:n}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-install-command`,className:`min-w-0 rounded-lg bg-muted px-3.5 py-3`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-3 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:[(0,Y.jsx)(`span`,{children:n}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Copy command`,className:`-m-2 inline-flex size-11 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:size-6`,onClick:()=>e(t),children:(0,Y.jsx)(N,{className:`size-4`,"aria-hidden":`true`})})]}),(0,Y.jsx)(`code`,{className:`block font-mono text-sm break-words whitespace-pre-wrap text-foreground`,children:t})]})}function Ve({server:e,status:t}){return(0,Y.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,Y.jsx)(j,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:t})]}),(0,Y.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,Y.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:e.command}),e.cwd?(0,Y.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,Y.jsx)(`span`,{children:`cwd`}),(0,Y.jsx)(`span`,{className:`break-all`,children:e.cwd})]}):null]}),(0,Y.jsx)(`div`,{className:`mt-2.5`,children:(0,Y.jsx)(ze,{server:e})})]})}function He({state:e,actions:t}){return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(F,{}),title:`This host has no browser yet`,children:[(0,Y.jsx)(Q,{children:e.canDownload?`Preview runs Chromium on the machine Squawk runs on. Squawk can download it into ~/.cache/cez/ (about 150 MB). Nothing else on the host changes.`:`Preview runs Chromium on the machine Squawk runs on. Squawk has no download for this platform, so install it with the system package manager.`}),e.canDownload?(0,Y.jsx)($,{children:(0,Y.jsxs)(w,{variant:`contrast`,onClick:t.download,children:[(0,Y.jsx)(F,{"aria-hidden":`true`}),`Download Chromium`]})}):null,(0,Y.jsx)(Be,{command:e.installCommand,copy:t.copy,label:e.canDownload?`Or install it yourself`:`Install it yourself`})]})}function Ue(e){return Math.round(e/1e6)}function We({state:e,actions:t}){let n=(0,J.useRef)(null);n.current??={at:Date.now(),received:e.received};let r=e.total>0?Math.min(100,Math.floor(e.received/e.total*100)):0,i=(Date.now()-n.current.at)/1e3,a=i>=1?(e.received-n.current.received)/i:0,o=a>0?Math.ceil((e.total-e.received)/a):void 0;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(F,{}),title:`Downloading Chromium`,children:[(0,Y.jsx)(Q,{children:`Into ~/.cache/cez/, no root needed. Nothing else on the host changes.`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":`Chromium download`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r,className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:`h-full rounded-full bg-success`,style:{width:`${r}%`}})}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:`${Ue(e.received)} of ${Ue(e.total)} MB · ${r}%`}),o===void 0?null:(0,Y.jsx)(`span`,{children:`about ${o} s left`})]})]}),(0,Y.jsx)($,{children:(0,Y.jsx)(w,{variant:`outline`,onClick:t.cancelDownload,children:`Cancel`})})]})}function Ge({state:e,actions:t}){return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(K,{className:`text-danger`}),title:`Couldn't download Chromium`,children:[(0,Y.jsx)(Q,{children:`${e.error.replace(/\.$/,``)}. Install Chromium with the system package manager, then retry.`}),(0,Y.jsx)(Be,{command:e.installCommand,copy:t.copy,label:`Install it yourself`}),(0,Y.jsxs)($,{children:[(0,Y.jsxs)(w,{variant:`contrast`,onClick:t.download,children:[(0,Y.jsx)(x,{"aria-hidden":`true`}),`Retry download`]}),(0,Y.jsxs)(w,{variant:`outline`,onClick:()=>t.copy(`Chromium download failed\n${e.error}\nInstall: ${e.installCommand}`),children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}function Ke({state:e,actions:t}){return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(W,{className:`text-danger`}),title:`Chromium couldn't start its sandbox`,children:[(0,Y.jsx)(Q,{children:`The host blocks the sandbox Chromium needs. This usually means Squawk runs as root, or inside a container without user namespaces.`}),(0,Y.jsx)(X,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,Y.jsxs)($,{children:[(0,Y.jsxs)(w,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,Y.jsx)(x,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(w,{variant:`outline`,onClick:()=>t.copy(`Chromium failed to start its sandbox\n${e.stderrTail}`),children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),`Copy diagnostics`]})]}),(0,Y.jsx)(`a`,{className:`text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:Le,target:`_blank`,rel:`noopener noreferrer`,children:`Docs: running without the sandbox (CEZ_PREVIEW_NO_SANDBOX=1)`})]})}function qe({state:e,actions:t}){let n=e.reason===`timeout`,r=e.signal?` (${e.signal})`:e.exitCode===void 0?``:` (code ${e.exitCode})`,i=e.serverUp?`The dev server is still up; only the browser needs a restart.`:`The browser needs a restart.`,a=n?`Chromium did not start in time`:`Chromium exited${r}`;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(m,{className:`text-danger`}),title:n?`The browser did not start`:`The browser stopped`,children:[(0,Y.jsx)(Q,{children:n?`Chromium did not open its DevTools port in time. ${i}`:`Chromium exited unexpectedly${r}. ${i}`}),(0,Y.jsx)(X,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,Y.jsxs)($,{children:[(0,Y.jsxs)(w,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,Y.jsx)(x,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(w,{variant:`outline`,onClick:()=>t.copy(`${a}\n${e.stderrTail}`),children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}var Je=2;function Ye(e){let[t,n]=(0,J.useState)(()=>Date.now());return(0,J.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function Xe({state:e,actions:t}){let{server:n,wasRunning:r}=e;return(0,Y.jsxs)(Z,{state:e.stage,icon:r?(0,Y.jsx)(q,{className:`text-pending-strong`}):(0,Y.jsx)(b,{}),title:r?`Nothing answers on :${n.port} anymore`:`${n.label} isn't running yet`,children:[(0,Y.jsx)(Q,{children:r?`${n.label} was running when the agent registered it, likely inside the agent's own session, which has ended. Squawk can start it with the registered command.`:`The agent registered this server. Nothing runs until you approve it here.`}),(0,Y.jsx)(Ve,{server:n,status:r?`was running when registered · silent now`:`registered · not started`}),(0,Y.jsx)($,{children:(0,Y.jsxs)(w,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(b,{"aria-hidden":`true`}),`Run and open`]})})]})}function Ze({state:e,actions:t}){let{server:n,ownerTitle:r}=e;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(K,{className:`text-pending-strong`}),title:`${n.label} :${n.port} is in use by another task`,children:[(0,Y.jsx)(Q,{children:`Task "${r}" is running its own server on :${n.port}. Register a different port for this task, or stop that task's server.`}),(0,Y.jsx)($,{children:(0,Y.jsx)(w,{variant:`contrast`,onClick:t.close,children:`Close preview`})})]})}function Qe({state:e,actions:t}){let{server:n}=e,r=Ye(1e3),i=Math.max(0,Math.floor((r-Date.parse(e.startedAt))/1e3)),[a,o]=(0,J.useState)(()=>Date.now());(0,J.useEffect)(()=>o(Date.now()),[e.attempt]);let s=Math.max(0,Math.ceil(Je-(r-a)/1e3));return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(b,{}),title:`Starting ${n.label}`,children:[(0,Y.jsx)(Q,{children:`Squawk ran ${M(n.command)} in the worktree. The page opens as soon as :${n.port} answers.`}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border px-3.5 py-3 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-2.5 font-semibold text-foreground`,children:[(0,Y.jsx)(v,{className:`size-4 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}),s>0?`Attempt ${e.attempt} · next try in ${s} s`:`Attempt ${e.attempt}`]}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`started ${i} s ago`})]}),e.logTail.length>0?(0,Y.jsx)(X,{text:e.logTail.join(`
3
- `),source:M(n.command),onCopy:t.copy}):null,(0,Y.jsx)($,{children:(0,Y.jsx)(w,{variant:`outline`,onClick:()=>t.stop(n.port),children:`Stop server`})})]})}function $e({state:e,actions:t}){let{server:n}=e;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(R,{className:`text-pending-strong`}),title:`${n.label} is running, but :${n.port} is silent`,children:[(0,Y.jsx)(Q,{children:`The process has run for 2 min without opening the port. It may be waiting on another service, or listening somewhere else.`}),(0,Y.jsx)(X,{text:e.logTail,source:M(n.command),onCopy:t.copy}),(0,Y.jsxs)($,{children:[(0,Y.jsx)(w,{variant:`contrast`,onClick:()=>t.keepWaiting(n.port),children:`Keep waiting`}),(0,Y.jsx)(w,{variant:`outline`,onClick:()=>t.stop(n.port),children:`Stop server`})]})]})}function et({state:e,actions:t}){let{server:n}=e;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(m,{className:`text-danger`}),title:e.exitCode===null?`${n.label} was stopped by a signal`:`${n.label} exited with code ${e.exitCode}`,children:[(0,Y.jsx)(Q,{children:`${M(n.command)} stopped.`}),(0,Y.jsx)(X,{text:e.logTail,source:M(n.command),onCopy:t.copy}),(0,Y.jsx)($,{children:(0,Y.jsxs)(w,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(x,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(ze,{server:n})]})}function tt({state:e,actions:t}){let{server:n}=e,r=e.reason===`idle`;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(ee,{}),title:r?`Stopped after 15 min idle`:`${n.label} stopped`,children:[(0,Y.jsx)(Q,{children:r?`Nobody had this pane open for 15 min, so Squawk stopped ${n.label} :${n.port} and the browser to free memory. Start again reopens ${Ie(e.lastUrl)}.`:`You stopped ${n.label} :${n.port}. Start again reopens ${Ie(e.lastUrl)}.`}),(0,Y.jsx)($,{children:(0,Y.jsxs)(w,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(x,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(ze,{server:n})]})}var nt=[`browser`,`page`,`frame`];function rt({step:e,url:t}){let n=nt.indexOf(e),i=t?Ie(t):`the page`;return(0,Y.jsx)(`div`,{"data-slot":`preview-state`,"data-state":`loading`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center px-6 py-8`,children:(0,Y.jsx)(`ol`,{"aria-label":`Opening the page`,className:`mx-auto flex flex-col gap-4 text-sm`,children:[{done:`Browser started`,active:`Starting the browser`},{done:`Opened ${i}`,active:`Opening ${i}`},{done:`First frame`,active:`First frame`}].map((e,t)=>{let i=t<n,a=t===n;return(0,Y.jsxs)(`li`,{"aria-current":a?`step`:void 0,className:r(`flex items-center gap-3`,a?`font-semibold text-foreground`:i?`text-foreground`:`text-soft-foreground`),children:[i?(0,Y.jsx)(p,{className:`size-5 text-success`,"aria-hidden":`true`}):a?(0,Y.jsx)(v,{className:`size-5 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}):(0,Y.jsx)(Ce,{className:`size-5 text-border`,"aria-hidden":`true`}),i?e.done:a?e.active:e.done]},t)})})})}function it({state:e,actions:t,worktree:n}){let r=n?/\.ai\/(?:cezar|squawk)\/worktrees\/[^/]+/.exec(n)?.[0]:void 0,i=e.server?.label;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(L,{}),title:`This task's worktree is gone`,children:[(0,Y.jsx)(Q,{children:`${i??`The server`} ran in ${r??`this task's worktree`}, which has been removed. There is nothing left to start.`}),e.server?(0,Y.jsx)(S,{entry:{kind:`preview-server`,id:`preview-server:${e.server.port}`,server:e.server,state:`unavailable`},inPreview:!1}):null,(0,Y.jsx)($,{children:(0,Y.jsx)(w,{variant:`outline`,onClick:t.close,children:`Close preview`})})]})}function at({actions:e}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":`proxy-blocked`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`div`,{children:(0,Y.jsx)(Me,{})}),(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:(0,Y.jsx)(V,{})}),(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Preview doesn't work behind this proxy yet`}),(0,Y.jsx)(Q,{children:`The proxy in front of Squawk didn't let the preview's WebSocket through. This is a known gap behind Basic Auth. Everything else in Squawk keeps working.`}),(0,Y.jsxs)($,{children:[(0,Y.jsx)(w,{variant:`outline`,onClick:e.close,children:`Close preview`}),(0,Y.jsx)(`a`,{className:`inline-flex min-h-11 items-center text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:Le,target:`_blank`,rel:`noopener noreferrer`,children:`Which setups work`})]})]})}function ot(e){let t=/iPhone/.test(e)?`iPhone`:/iPad/.test(e)?`iPad`:/Android/.test(e)?`Android`:/Windows/.test(e)?`Windows`:/Mac OS X|Macintosh/.test(e)?`Mac`:/Linux|X11/.test(e)?`Linux`:``,n=/Edg\//.test(e)?`Edge`:/Firefox\/|FxiOS/.test(e)?`Firefox`:/Chrome\/|CriOS/.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:``;return n&&t?`${n} on ${t}`:n||t}function st({state:e,actions:t}){let n=ot(e.by);return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(B,{}),title:`Preview is open somewhere else`,children:[(0,Y.jsx)(Q,{children:`Another tab took this browser${n?` (${n})`:``}. Only one tab can view and drive it at a time.`}),(0,Y.jsxs)($,{children:[(0,Y.jsxs)(w,{variant:`contrast`,onClick:t.useHere,children:[(0,Y.jsx)(F,{"aria-hidden":`true`}),`Use it here`]}),(0,Y.jsx)(w,{variant:`outline`,onClick:t.close,children:`Close preview`})]})]})}function ct({attempt:e,exhausted:t,onReconnect:n}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-connection-banner`,role:`status`,className:`absolute inset-x-3 top-3 z-10 flex flex-wrap items-center justify-between gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-3.5 py-2.5 text-sm shadow-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,Y.jsx)(De,{className:`size-4 shrink-0 text-danger`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{className:`font-semibold text-foreground`,children:`Lost the connection to the host`}),t?null:(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` · reconnecting (attempt ${e} of 5)`})]})]}),(0,Y.jsx)(w,{variant:`outline`,onClick:n,children:t?`Reconnect`:`Reconnect now`})]})}function lt({servers:e,states:t,onOpen:n,agentLive:r=!1,agentIdle:i=!1,onOpenAgent:a}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":i?`agent-idle`:`empty`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Open a page in this task's browser`}),(0,Y.jsx)(Q,{children:`The browser runs on the host, next to the worktree. Type a URL, a bare port such as 3000, or open a server the agent registered.`}),i?(0,Y.jsxs)(`p`,{role:`status`,className:`flex items-start gap-2 text-sm text-foreground`,children:[(0,Y.jsx)(q,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`The agent is not driving the browser now.`})]}):null,r&&a!==void 0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-agent`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.jsx)(`h3`,{id:`preview-agent`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Driven by the agent`}),(0,Y.jsxs)(`div`,{"data-slot":`preview-agent-entry`,className:`flex items-center justify-between gap-3 px-3.5 py-2 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,Y.jsx)(j,{tone:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`The agent drives this page through agent-browser.`})]}),(0,Y.jsx)(w,{variant:`outline`,size:`sm`,className:`max-md:h-11`,"aria-label":`Open the agent's page`,onClick:a,children:`Open`})]})]}):null,e.length>0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-registered`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.jsx)(`h3`,{id:`preview-registered`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Registered in this task`}),(0,Y.jsx)(`ul`,{children:e.map(e=>{let r=ve(e,t),i=_e(r);return(0,Y.jsxs)(`li`,{className:`flex items-center justify-between gap-3 border-b border-border px-3.5 py-2 text-sm last:border-b-0`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,Y.jsx)(j,{tone:i.tone,shape:i.ring?`ring`:`filled`,pulse:i.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:i.text})]}),(0,Y.jsx)(w,{variant:`outline`,size:`sm`,className:`max-md:h-11`,onClick:()=>n(e.port),children:pe(r)?`Open`:`Review`})]},e.port)})})]}):null,(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(_,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`Review opens a server's approval in this pane: its command, cwd and Run and open. Nothing runs from this list. Paste works; copying text out, file pickers and downloads don't yet.`})]})]})}function ut({dialog:e,onResult:t}){let[n,r]=(0,J.useState)(e.defaultPrompt??``),i=e.type===`beforeunload`,a=(0,J.useRef)(null),o=(0,J.useRef)(null);(0,J.useEffect)(()=>{(e.type===`prompt`?o.current:a.current)?.focus()},[e.type]);let s=(0,J.useRef)(t);s.current=t,(0,J.useEffect)(()=>{let e=e=>{if(e.key!==`Escape`||e.defaultPrevented)return;let t=e.target instanceof Element?e.target:null;t&&t!==document.body&&!t.closest(`[data-slot="preview-pane-body"], [data-slot="preview-page-dialog"]`)||(e.stopPropagation(),s.current({accept:!1}))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let c=()=>t(e.type===`prompt`?{accept:!0,text:n}:{accept:!0});return(0,Y.jsx)(`div`,{"data-slot":`preview-page-dialog`,className:`absolute inset-0 z-20 flex items-center justify-center bg-foreground/30 p-4`,children:(0,Y.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":`${e.origin} says`,className:`w-full max-w-[380px] rounded-xl border border-card-edge bg-card p-4 shadow-modal`,children:[(0,Y.jsx)(`p`,{className:`mb-3 truncate font-mono text-xs text-muted-foreground`,children:`${e.origin} says`}),(0,Y.jsx)(`p`,{className:`mb-4 text-sm break-words whitespace-pre-wrap text-foreground`,children:e.message||(i?`Changes you made may not be saved.`:``)}),e.type===`prompt`?(0,Y.jsx)(`input`,{ref:o,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c()},className:`mb-4 h-11 w-full rounded-md border border-border bg-background px-3 text-sm outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}):null,(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[e.type===`alert`?null:(0,Y.jsx)(w,{variant:`outline`,onClick:()=>t({accept:!1}),children:i?`Stay`:`Cancel`}),(0,Y.jsx)(w,{ref:a,variant:`contrast`,onClick:c,children:i?`Leave`:`OK`})]})]})})}var dt=10,ft=500,pt=500,mt=4,ht=16,gt=e=>!!e.altKey|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0);function _t(e,t,n,r){return{x:Math.round((e-n.left)/r),y:Math.round((t-n.top)/r)}}function vt(e,t){return{rect:e,scale:t,touches:new Map,multiTouch:!1,click:{at:-1/0,x:0,y:0,button:-1,count:1}}}var yt=[`left`,`middle`,`right`];function bt(e,t,n,r){let i=_t(n.clientX,n.clientY,t.rect,t.scale);return{t:`mouse`,type:e,x:i.x,y:i.y,button:yt[n.button]??`none`,buttons:n.buttons,clickCount:1,modifiers:gt(n),...r}}var xt=e=>e===0?0:-e;function St(e,t,n,r,i){let a=_t(t,n,e.rect,e.scale);return{t:`mouse`,type:`mouseWheel`,x:a.x,y:a.y,button:`none`,buttons:0,deltaX:xt(r/e.scale),deltaY:xt(i/e.scale),modifiers:0}}function Ct(e,t){let{touches:n}=t,r=n.get(e.pointerId),i=()=>{n.delete(e.pointerId),n.size===0&&(t.multiTouch=!1)};switch(e.type){case`pointerdown`:return n.set(e.pointerId,{startX:e.clientX,startY:e.clientY,startAt:e.timeStamp,lastX:e.clientX,lastY:e.clientY,scrolling:!1}),n.size>1&&(t.multiTouch=!0),[];case`pointermove`:{if(!r)return[];if(t.multiTouch)return r.lastX=e.clientX,r.lastY=e.clientY,[];if(!r.scrolling){if(Math.hypot(e.clientX-r.startX,e.clientY-r.startY)<=dt)return[];r.scrolling=!0}let n=e.clientX-r.lastX,i=e.clientY-r.lastY;return r.lastX=e.clientX,r.lastY=e.clientY,n===0&&i===0?[]:[St(t,e.clientX,e.clientY,n,i)]}case`pointerup`:{let n=r!==void 0&&!t.multiTouch&&!r.scrolling&&e.timeStamp-r.startAt<=ft;if(i(),!n||!r)return[];let a={...e,clientX:r.startX,clientY:r.startY};return[bt(`mouseMoved`,t,a,{button:`none`,buttons:0}),bt(`mousePressed`,t,a,{button:`left`,buttons:1}),bt(`mouseReleased`,t,a,{button:`left`,buttons:0})]}case`pointercancel`:return i(),[]}}function wt(e,t){if(e.pointerType===`touch`)return Ct(e,t);switch(e.type){case`pointerdown`:{let n=t.click,r=n.button===e.button&&e.timeStamp-n.at<=pt&&Math.hypot(e.clientX-n.x,e.clientY-n.y)<=mt;return t.click={at:e.timeStamp,x:e.clientX,y:e.clientY,button:e.button,count:r?n.count+1:1},[bt(`mousePressed`,t,e,{clickCount:t.click.count})]}case`pointermove`:return[bt(`mouseMoved`,t,e,{button:e.buttons&1?`left`:`none`})];case`pointerup`:return[bt(`mouseReleased`,t,e,{clickCount:t.click.count})];case`pointercancel`:return[]}}function Tt(e,t,n){let r=_t(e.clientX,e.clientY,t,n),i=e.deltaMode===1?ht:1;return{t:`mouse`,type:`mouseWheel`,x:r.x,y:r.y,button:`none`,buttons:e.buttons??0,deltaX:e.deltaX*i/n,deltaY:e.deltaY*i/n,modifiers:gt(e)}}var Et={a:`selectAll`,c:`copy`,x:`cut`,z:`undo`,y:`redo`};function Dt(e){let t=e.key.toLowerCase(),n=(e.ctrlKey||e.metaKey)&&!e.getModifierState?.(`AltGraph`);if(n&&(t===`v`||t===`k`))return;let r={t:`key`,key:e.key,code:e.code,modifiers:gt(e),vk:e.keyCode};if(e.type===`keyup`)return{...r,type:`keyUp`};let i=n?``:e.key.length===1?e.key:e.key===`Enter`?`\r`:e.key===`Tab`?` `:``,a=n?t===`z`&&e.shiftKey?`redo`:Et[t]:void 0,o={t:`key`,type:i?`keyDown`:`rawKeyDown`,key:e.key,code:e.code,text:i,modifiers:gt(e),vk:e.keyCode};return a?{...o,commands:[a]}:o}function Ot(e){return e?{t:`insertText`,text:e}:void 0}var kt=e=>e,At=e=>e.key===`Escape`&&e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey;function jt({scale:e,send:t,onLeave:n}){let r=(0,J.useRef)(null),i=(0,J.useRef)(vt({left:0,top:0},e)),a=(0,J.useRef)(e);a.current=e;let o=(0,J.useRef)(t);o.current=t;let s=(0,J.useRef)(void 0),c=()=>{let e=r.current;e&&(i.current.rect=e.getBoundingClientRect()),i.current.scale=a.current},l=e=>{c();for(let t of wt(kt(e),i.current))o.current(t)},u=()=>{let e=s.current;e&&(s.current=void 0,cancelAnimationFrame(e.frame),l(e.event))};(0,J.useEffect)(()=>()=>{s.current&&cancelAnimationFrame(s.current.frame)},[]),(0,J.useEffect)(()=>{document.activeElement===document.body&&r.current?.focus({preventScroll:!0})},[]),(0,J.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{e.preventDefault(),c(),o.current(Tt(e,i.current.rect,i.current.scale))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,J.useEffect)(()=>{let e=e=>{if(document.activeElement!==r.current)return;let t=Ot(e.clipboardData?.getData(`text`)??``);t&&(e.preventDefault(),o.current(t))};return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)},[]);let d=e=>{u(),r.current?.focus({preventScroll:!0});try{r.current?.setPointerCapture(e.pointerId)}catch{}l(e.nativeEvent)},f=e=>{let t=e.nativeEvent;if(t.pointerType===`touch`)return l(t);let n=s.current;if(n){n.event=t;return}s.current={event:t,frame:requestAnimationFrame(()=>{let e=s.current;s.current=void 0,e&&l(e.event)})}},p=e=>{u(),l(e.nativeEvent)},m=e=>{if(At(e)){e.preventDefault(),e.stopPropagation(),e.type===`keydown`&&(n?n():r.current?.blur());return}let i=Dt(e.nativeEvent);i&&(e.preventDefault(),e.stopPropagation(),t(i))};return(0,Y.jsx)(`div`,{ref:r,"data-slot":`preview-input`,role:`application`,"aria-label":`Page preview, interactive`,"aria-description":`Keys go to the page, Tab included. Press Shift+Escape to return to the cockpit.`,tabIndex:0,onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onContextMenu:e=>e.preventDefault(),onKeyDown:m,onKeyUp:m,className:`absolute inset-0 touch-none select-none outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-inset`})}async function Mt(e){if(typeof createImageBitmap==`function`){let t=await createImageBitmap(e);return{source:t,width:t.width,height:t.height,release:()=>t.close()}}let t=URL.createObjectURL(e),n=new Image;return n.src=t,await n.decode(),{source:n,width:n.naturalWidth,height:n.naturalHeight,release:()=>URL.revokeObjectURL(t)}}function Nt({ref:e,viewport:t,dimmed:n=!1,cursor:i,onSize:o,renderInput:s,children:c}){let l=(0,J.useRef)(0),u=(0,J.useRef)(null),d=(0,J.useRef)(null),[f,p]=(0,J.useState)(null),m=(0,J.useRef)(o);m.current=o,(0,J.useImperativeHandle)(e,()=>({async draw(e){let t=++l.current,n=d.current,r=n?.getContext(`2d`);if(!(!n||!r||!a()))try{let i=await Mt(e);try{if(t!==l.current||!a()||d.current!==n)return;n.width!==i.width&&(n.width=i.width),n.height!==i.height&&(n.height=i.height),r.drawImage(i.source,0,0)}finally{i.release()}}catch{}}}),[]),(0,J.useEffect)(()=>{let e=u.current;if(!e)return;let t=()=>{let t=Math.round(e.clientWidth),n=Math.round(e.clientHeight);t===0||n===0||(p(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n}),m.current?.({w:t,h:n}))};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let h=t===`fit`?f:t,g=t===`fit`||!f?1:Math.min(1,(f.w-24)/t.w,(f.h-24)/t.h),_=h?{width:Math.floor(h.w*g),height:Math.floor(h.h*g)}:void 0;return(0,Y.jsxs)(`div`,{ref:u,"data-slot":`preview-stage`,"data-viewport":t===`fit`?`fit`:`${t.w}x${t.h}`,className:r(`relative min-h-0 flex-1 overflow-hidden bg-muted`,t!==`fit`&&`flex items-start justify-center overflow-auto p-3`),children:[h?(0,Y.jsxs)(`div`,{"data-slot":`preview-surface`,"data-scale":g,style:{..._,cursor:i},className:r(`relative shrink-0 bg-card`,t!==`fit`&&`shadow-md`,n&&`opacity-60 saturate-50`),children:[(0,Y.jsx)(`canvas`,{ref:d,"aria-label":`Page preview`,role:`img`,style:_,className:`block touch-none select-none`}),s?.({canvas:d.current,scale:g,viewport:h})]}):null,c]})}var Pt=`cez-preview-quality`,Ft=[{value:`normal`,label:`Normal`,detail:`The default. Lighter on CPU and network.`},{value:`high`,label:`High`,detail:`Sharper text and fine detail. Uses more CPU and network.`},{value:`ultra`,label:`Ultra`,detail:`High at your screen's pixel density, up to 2×. Uses the most CPU and network.`}];function It(e){return Ft.find(t=>t.value===e)?.value??`normal`}var Lt=e=>Ft.find(t=>t.value===e)?.label??`Normal`;function Rt(){try{return It(localStorage.getItem(Pt))}catch{return`normal`}}function zt(e){try{localStorage.setItem(Pt,e)}catch{}}var Bt=[{w:390,h:844,icon:g},{w:820,h:1180,icon:G},{w:1440,h:900,icon:y}],Vt=`size-8 shrink-0 max-md:size-11`,Ht=e=>e===`fit`?`Fit`:`${e.w} × ${e.h}`;function Ut(e){let[t,n]=(0,J.useState)(()=>Date.now());return(0,J.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var Wt=e=>`${e.fps} fps · ${e.kbps} KB/s${e.rttMs===void 0?``:` · ${e.rttMs} ms`}`;function Gt({stats:e,shrunk:t}){let n=Ut(250),r=e.lastFrameAt===void 0||n-e.lastFrameAt>=1e3;return t?(0,Y.jsx)(j,{"data-slot":`preview-stats`,tone:r?`neutral`:`success`,"aria-label":`Preview is live`,role:`img`}):(0,Y.jsxs)(`span`,{"data-slot":`preview-stats`,role:`img`,"aria-label":r?`idle`:Wt(e),className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(j,{tone:r?`neutral`:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[960px]:inline-block w-[28ch] overflow-hidden text-ellipsis`,children:r?`idle`:Wt(e)})]})}function Kt({current:e,agentShown:t,...n}){let r=e?e.label:t?`Agent's page`:`Server`;return(0,Y.jsxs)(w,{variant:`outline`,size:`sm`,className:`max-w-[9rem] min-w-0 gap-1.5 @min-[760px]:max-w-[11rem] max-md:h-11`,"aria-label":e?`Server: ${e.label} :${e.port}`:t?`Server: ${r}`:`Server`,...n,children:[e||t?(0,Y.jsx)(j,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}):(0,Y.jsx)(C,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:r}),e?(0,Y.jsxs)(`span`,{className:`font-mono font-normal text-muted-foreground`,children:[`:`,e.port]}):null,(0,Y.jsx)(f,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}function qt({shown:e,live:t,onSelect:n}){return(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":e||void 0,onSelect:n,children:[(0,Y.jsx)(j,{tone:t?`success`:`neutral`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`agent-browser`}),e?(0,Y.jsx)(d,{className:`size-4`,"aria-hidden":`true`}):null]})}function Jt(e,t){return e?`${e.label} :${e.port}`:t?`Agent's page`:`Preview`}function Yt(e){let t=e.onPickAgent!==void 0,n=e.agentLive===!0&&t,r=e.agentShown===!0;return{agentLive:n,agentShown:r,agentListed:n||r&&t}}function Xt(e){let{compact:t=!1,navEnabled:n,loading:r=!1}=e,i=(0,J.useRef)(null),a=e.urlInputRef??i,o=(0,J.useRef)(!1),[s,c]=(0,J.useState)(null),[l,d]=(0,J.useState)(!1),f=(0,Y.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Back`,disabled:!n,onClick:e.onBack,children:(0,Y.jsx)(Se,{"aria-hidden":`true`})}),p=(0,Y.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Forward`,disabled:!n,onClick:e.onForward,children:(0,Y.jsx)(u,{"aria-hidden":`true`})}),m=(0,Y.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Reload`,"aria-busy":r||void 0,disabled:!n||r,onClick:()=>e.onReload(!1),children:(0,Y.jsx)(U,{"aria-hidden":`true`})}),h=e.onSession?(0,Y.jsxs)(w,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1 max-md:h-11`,onClick:e.onSession,children:[(0,Y.jsx)(me,{"aria-hidden":`true`}),`Session`]}):null,g=r?(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":`Loading the page`,className:`absolute inset-x-0 bottom-0 h-0.5 overflow-hidden bg-transparent`,children:(0,Y.jsx)(`div`,{className:`preview-progress h-full w-2/5 bg-success`})}):null,_=(0,Y.jsx)(Qt,{props:e,input:a,draft:s,setDraft:c,focused:l,setFocused:d}),{agentListed:v}=Yt(e),y=e.servers.length+ +!!v>=2,ee=y||e.adopted,b={back:f,forward:p,reload:m,address:_,more:(0,Y.jsx)(rn,{props:e,compact:t}),session:h,progress:g};return t?(0,Y.jsx)(an,{props:e,elements:b}):(0,Y.jsx)(on,{props:e,elements:b,switcher:y,crowded:ee,input:a,focusUrlAfterMenu:o})}function Zt({props:e,input:t,focusUrlAfterMenu:n}){let{servers:r,current:i}=e,{agentLive:a,agentShown:o,agentListed:s}=Yt(e);return(0,Y.jsxs)(A,{children:[(0,Y.jsx)(O,{asChild:!0,children:(0,Y.jsx)(Kt,{current:i,agentShown:o})}),(0,Y.jsxs)(k,{align:`start`,className:`min-w-64`,onCloseAutoFocus:e=>{n.current&&(n.current=!1,e.preventDefault(),t.current?.focus())},children:[s?(0,Y.jsx)(qt,{shown:o,live:a,onSelect:()=>e.onPickAgent?.()}):null,r.map(t=>{let n=_e(ve(t,e.serverStates));return(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":i?.port===t.port||void 0,onSelect:()=>e.onPickServer(t.port),children:[(0,Y.jsx)(j,{tone:n.tone,shape:n.ring?`ring`:`filled`,pulse:n.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:t.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,t.port]}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:n.text}),i?.port===t.port?(0,Y.jsx)(d,{className:`size-4`,"aria-hidden":`true`}):null]},t.port)}),(0,Y.jsx)(D,{}),(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>{n.current=!0},children:[(0,Y.jsx)(h,{"aria-hidden":`true`}),`Type a URL instead`]})]})]})}function Qt({props:e,input:t,draft:n,setDraft:i,focused:a,setFocused:o}){let{url:s,adopted:c}=e;return(0,Y.jsxs)(`div`,{className:`relative flex min-w-20 flex-1 items-center`,children:[(0,Y.jsx)(h,{className:`pointer-events-none absolute left-2.5 size-4 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`input`,{ref:t,type:`text`,"aria-label":`Page address`,placeholder:`Type a URL or a port`,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,value:n??(a?s:Ie(s)),title:s||void 0,className:r(`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-muted pl-8 font-mono text-[13px] text-foreground outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:bg-background focus-visible:ring-[3px] focus-visible:ring-ring/30 max-md:h-11`,c?`pr-40`:`pr-2.5`),onFocus:e=>{let t=e.currentTarget;o(!0),requestAnimationFrame(()=>{document.activeElement===t&&t.select()})},onBlur:()=>{o(!1),i(null)},onChange:e=>i(e.target.value),onKeyDown:t=>{t.key===`Enter`?(e.onNavigate(n??s),t.currentTarget.blur()):t.key===`Escape`&&t.currentTarget.blur()}}),c&&!a?(0,Y.jsxs)(`span`,{className:`pointer-events-none absolute right-2 inline-flex h-6 items-center gap-1 rounded-full border border-border bg-card px-2 text-xs font-semibold text-muted-foreground`,children:[(0,Y.jsx)(z,{className:`size-3`,"aria-hidden":`true`}),`Not started by Squawk`]}):null]})}function $t({props:e}){let{viewport:t}=e;return(0,Y.jsxs)(A,{children:[(0,Y.jsx)(O,{asChild:!0,children:(0,Y.jsxs)(w,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Viewport size: ${Ht(t)}`,children:[t===`fit`?(0,Y.jsx)(Ee,{"aria-hidden":`true`}):(0,Y.jsx)(y,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:r(`hidden @min-[620px]:inline`,t!==`fit`&&`font-mono font-normal`),children:Ht(t)}),(0,Y.jsx)(f,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(k,{align:`start`,className:`min-w-56`,children:[(0,Y.jsxs)(E,{className:`gap-2.5`,"aria-current":t===`fit`||void 0,onSelect:()=>e.onViewport(`fit`),children:[(0,Y.jsx)(Ee,{"aria-hidden":`true`}),`Fit`,(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`pane size`}),t===`fit`?(0,Y.jsx)(d,{className:`size-4`,"aria-hidden":`true`}):null]}),Bt.map(({w:n,h:r,icon:i})=>(0,Y.jsxs)(E,{className:`gap-2.5 font-mono`,"aria-current":t!==`fit`&&t.w===n&&t.h===r||void 0,onSelect:()=>e.onViewport({w:n,h:r}),children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),n,` × `,r,t!==`fit`&&t.w===n&&t.h===r?(0,Y.jsx)(d,{className:`ml-auto size-4`,"aria-hidden":`true`}):null]},`${n}x${r}`))]})]})}function en({quality:e,onQuality:t,compact:n}){return(0,Y.jsx)(ie,{value:e,onValueChange:e=>t(It(e)),children:Ft.map(e=>(0,Y.jsx)(re,{value:e.value,"data-quality":e.value,className:r(`items-start`,n&&`min-h-11`),children:(0,Y.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{children:e.label}),(0,Y.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:e.detail})]})},e.value))})}function tn({props:e}){let{quality:t}=e;return(0,Y.jsxs)(A,{children:[(0,Y.jsx)(O,{asChild:!0,children:(0,Y.jsxs)(w,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Stream quality: ${Lt(t)}`,children:[(0,Y.jsx)(we,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[680px]:inline`,children:Lt(t)}),(0,Y.jsx)(f,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(k,{align:`start`,className:`w-64`,children:[(0,Y.jsx)(T,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(en,{quality:t,onQuality:e.onQuality,compact:!1})]})]})}function nn({stats:e,status:t,crowded:n}){return e?(0,Y.jsx)(Gt,{stats:e,shrunk:n}):t?(0,Y.jsxs)(`span`,{"data-slot":`preview-status`,role:`img`,"aria-label":t.label,title:t.label,className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(j,{tone:t.tone,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[760px]:inline`,children:t.label})]}):null}function rn({props:e,compact:t}){let{stats:n,navEnabled:r,url:i,current:a,adopted:o}=e;return(0,Y.jsxs)(A,{children:[(0,Y.jsx)(O,{asChild:!0,children:(0,Y.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`More`,children:(0,Y.jsx)(fe,{"aria-hidden":`true`})})}),(0,Y.jsxs)(k,{align:`end`,className:`min-w-64`,children:[n&&!t?(0,Y.jsx)(T,{className:`font-mono text-xs font-normal text-muted-foreground`,children:Wt(n)}):null,(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:!r,onSelect:()=>e.onReload(!0),children:[(0,Y.jsx)(H,{"aria-hidden":`true`}),`Reload without cache`]}),(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:i===``,onSelect:e.onCopyUrl,children:[(0,Y.jsx)(ge,{"aria-hidden":`true`}),`Copy page URL`]}),a?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(D,{}),o?(0,Y.jsxs)(E,{disabled:!0,className:`items-start gap-2.5 opacity-100 data-[disabled]:opacity-100`,children:[(0,Y.jsx)(Te,{className:`mt-0.5 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`Stop server · ${a.label} :${a.port}`}),(0,Y.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:`Squawk didn't start this server, so it won't stop it. Stop it where it was started.`})]})]}):(0,Y.jsxs)(E,{variant:`destructive`,className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>e.onStop(a.port),children:[(0,Y.jsx)(P,{"aria-hidden":`true`}),`Stop server · ${a.label} :${a.port}`]})]}):null,t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(D,{}),(0,Y.jsx)(T,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(en,{quality:e.quality,onQuality:e.onQuality,compact:!0}),(0,Y.jsx)(D,{}),(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5`,onSelect:e.onClose,children:[(0,Y.jsx)(oe,{"aria-hidden":`true`}),`Close preview`]})]}):null]})]})}function an({props:e,elements:t}){let{stats:n,current:r,badge:i=!0}=e,{agentShown:a}=Yt(e),{back:o,forward:s,reload:c,address:l,more:u,session:d,progress:f}=t;return(0,Y.jsxs)(`div`,{"data-slot":`preview-toolbar`,"data-compact":``,className:`relative flex shrink-0 flex-col border-b border-border bg-background`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-2 pt-[max(0.25rem,env(safe-area-inset-top))]`,children:[d,(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col items-center leading-tight`,children:[(0,Y.jsxs)(`span`,{className:`flex max-w-full items-center gap-1.5 text-sm font-semibold text-foreground`,children:[n?(0,Y.jsx)(j,{tone:`success`,"aria-hidden":`true`}):null,(0,Y.jsx)(`span`,{className:`truncate`,children:Jt(r,a)})]}),i?(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Experimental`}):null]}),u]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1`,children:[o,s,c,l]}),f]})}function on({props:e,elements:t,switcher:n,crowded:r,input:i,focusUrlAfterMenu:a}){let{badge:o=!0,stats:s,status:c}=e,{back:l,forward:u,reload:d,address:f,more:p,session:m,progress:h}=t;return(0,Y.jsxs)(`div`,{"data-slot":`preview-toolbar`,className:`@container relative flex shrink-0 items-center gap-1 border-b border-border bg-background px-2 py-2 @min-[640px]:gap-1.5 @min-[640px]:px-2.5`,children:[m,l,u,d,n?(0,Y.jsx)(Zt,{props:e,input:i,focusUrlAfterMenu:a}):null,f,(0,Y.jsx)($t,{props:e}),(0,Y.jsx)(tn,{props:e}),(0,Y.jsx)(nn,{stats:s,status:c,crowded:r}),o?(0,Y.jsx)(Me,{iconOnly:r,responsive:!r}):null,(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-5 w-px shrink-0 bg-border`}),p,(0,Y.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Close preview`,onClick:e.onClose,children:(0,Y.jsx)(oe,{"aria-hidden":`true`})}),h]})}function sn({transport:e,takenOver:t,empty:n,stage:r,hasFrame:i,lost:a,url:o,worktree:s}){let c=a||e!==`blocked`&&t!==void 0;return e===`blocked`?{content:{kind:`state`,state:{stage:`proxy-blocked`}},dim:c}:t===void 0?n||r?.stage===`agent-idle`?{content:{kind:`empty`,agentIdle:!n&&r?.stage===`agent-idle`},dim:c}:r?.stage===`streaming`||r?.stage===`loading`&&i?{content:{kind:`none`},dim:c}:r?{content:{kind:`state`,state:r,url:o,worktree:s},dim:c}:a?{content:{kind:`none`},dim:c}:{content:{kind:`state`,state:{t:`state`,stage:`loading`,step:`browser`},url:o},dim:c}:{content:{kind:`state`,state:{stage:`taken-over`,by:t}},dim:c}}function cn(e,{servers:t,serverStates:n,agentLive:r,openServer:i,openAgent:a,actions:o}){switch(e.kind){case`none`:return null;case`state`:{let{kind:t,...n}=e;return(0,Y.jsx)(Re,{...n,actions:o})}case`empty`:return(0,Y.jsx)(lt,{servers:t,states:n,onOpen:e=>i(e),agentLive:r===!0,agentIdle:e.agentIdle,onOpenAgent:a})}}function ln(){let e=typeof window>`u`?void 0:window.devicePixelRatio;return typeof e==`number`&&e>0?e:1}function un(){let[e,t]=(0,J.useState)(ln);return(0,J.useEffect)(()=>{let n=window.matchMedia?.(`(resolution: ${e}dppx)`);if(!n)return;let r=()=>t(ln());return n.addEventListener(`change`,r),()=>n.removeEventListener(`change`,r)},[e]),e}var dn=2e3,fn=500,pn=1e3;function mn(e,t){switch(e.stage){case`needs-approval`:case`port-held`:case`server-starting`:case`server-stalled`:case`server-exited`:case`server-stopped`:return e.server.port===t;case`loading`:case`streaming`:return!0;default:return!1}}function hn(e){navigator.clipboard?.writeText(e).then(()=>c(`Copied`),()=>c(`Couldn't copy to the clipboard`,{tone:`danger`}))}var gn=e=>`http://localhost:${e.port}${e.path&&e.path!==`/`?e.path:``}`;function _n(e,t){return e?.port===void 0?e?.agent===!0||e?.url!==void 0:e.restored!==!0||t.some(t=>t.port===e.port)}function vn(e){return`port`in e?{port:e.port}:`agent`in e?{agent:!0}:{url:e.url}}function yn({run:e,servers:t,request:n,onTarget:r,onLive:i,onClose:s}){let l=un(),u=(0,J.useRef)(l);u.current=l;let d=o(),f=(0,J.useRef)(crypto.randomUUID()),p=(0,J.useRef)(!1),m=ae(),h=ye(ue,!1),[g,_]=(0,J.useState)(0),[v,y]=(0,J.useState)({state:`connecting`,attempt:0}),[ee,b]=(0,J.useState)(!1),[x,te]=(0,J.useState)(void 0),[S,C]=(0,J.useState)(void 0),[ne,w]=(0,J.useState)(``),[T,re]=(0,J.useState)(void 0),[E,D]=(0,J.useState)(!1),[O,k]=(0,J.useState)(void 0),[ie,A]=(0,J.useState)(!1),[j,oe]=(0,J.useState)(!1),[se,ce]=(0,J.useState)(void 0),[le,de]=(0,J.useState)(void 0),[fe,pe]=(0,J.useState)(void 0),[me,M]=(0,J.useState)(`fit`),[he,N]=(0,J.useState)(Rt),[ge,_e]=(0,J.useState)(null),[ve,be]=(0,J.useState)(void 0),[xe,Se]=(0,J.useState)(0),P=(0,J.useRef)(void 0),Ce=(0,J.useRef)(null),F=(0,J.useRef)(null),I=(0,J.useRef)(void 0),L=(0,J.useRef)(void 0),we=(0,J.useRef)(he);we.current=he;let R=(0,J.useRef)({port:T,stage:S,agent:E});R.current={port:T,stage:S,agent:E};let z=(0,J.useRef)([]),Te=(0,J.useRef)(void 0),Ee=(0,J.useRef)(!1),B=(0,J.useRef)(!1),V=(0,J.useCallback)(e=>{B.current&&P.current?.send(e)},[]),H=(0,J.useRef)([]),U=(0,J.useCallback)(e=>{B.current?P.current?.send(e):H.current.push(e)},[]);(0,J.useEffect)(()=>{let t;return t=je({projectId:m??`default`,runId:e.id},{onFrame(e){if(!a())return;let n=Date.now();z.current.push({at:n,bytes:e.size}),Ee.current||(Ee.current=!0,oe(!0)),(Ce.current?.draw(e)??Promise.resolve()).finally(()=>t?.send({t:`ack`}))},onMessage(e){switch(e.t){case`state`:if(C(e),(e.stage===`streaming`||e.stage===`loading`)&&Se(e=>e+1),L.current!==void 0&&mn(e,L.current)){let n=L.current;L.current=void 0,(e.stage===`needs-approval`||e.stage===`server-exited`||e.stage===`server-stopped`)&&t?.send({t:`run`,port:n})}return;case`url`:return w(e.url);case`cursor`:return ce(e.cursor);case`dialog`:return de(e);case`pong`:Te.current=Math.max(0,Date.now()-e.ts);return;case`downloadProgress`:C(t=>t?.stage===`downloading`?{...t,received:e.received,total:e.total}:t);return;case`replaced`:te(e.by),B.current=!1,H.current=[],t?.close();return}},onTransport(e,n){if(B.current=e===`open`,y({state:e,attempt:n??0}),(e===`blocked`||e===`closed`)&&(H.current=[]),e===`open`){b(!0),I.current&&(t?.send({t:`open`,target:I.current,viewerId:f.current,resume:p.current,quality:we.current,dpr:u.current}),p.current=!0);for(let e of H.current.splice(0))t?.send(e)}}}),P.current=t,()=>{B.current=!1,H.current=[],t?.close(),P.current===t&&(P.current=void 0)}},[m,e.id,g]);let W=d&&v.state===`open`&&x===void 0,G=h||me===`fit`?ge:me;(0,J.useEffect)(()=>{G&&W&&(S?.stage===`streaming`||S?.stage===`loading`)&&V({t:`resize`,w:G.w,h:G.h,...l===1?{}:{dpr:l}})},[G?.w,G?.h,l,W,S?.stage,xe,V]),(0,J.useEffect)(()=>{if(!W)return;let e=setInterval(()=>V({t:`ping`,ts:Date.now()}),dn);return()=>clearInterval(e)},[W,V]);let K=W&&S?.stage===`streaming`;(0,J.useEffect)(()=>{if(!K){pe(void 0);return}let e=setInterval(()=>{let e=Date.now();z.current=z.current.filter(t=>e-t.at<=pn);let t={fps:z.current.length,kbps:Math.round(z.current.reduce((e,t)=>e+t.bytes,0)/1024),...Te.current===void 0?{}:{rttMs:Te.current},...z.current.length>0?{lastFrameAt:z.current.at(-1).at}:{}};pe(e=>{let n=t.lastFrameAt??e?.lastFrameAt,r={...t,...n===void 0?{}:{lastFrameAt:n}};return e&&e.fps===r.fps&&e.kbps===r.kbps&&e.rttMs===r.rttMs&&e.lastFrameAt===r.lastFrameAt?e:r})},fn);return()=>clearInterval(e)},[K]),(0,J.useEffect)(()=>(i?.(K),()=>i?.(!1)),[K,i]),(0,J.useEffect)(()=>{O&&r?.(O)},[O,r]);let q=(0,J.useCallback)((e,t,n=!1)=>{I.current=e,L.current=n&&`port`in e?e.port:void 0,A(!0),C(void 0),te(void 0),be(void 0),w(t),re(`port`in e?e.port:void 0),D(`agent`in e),k(vn(e)),V({t:`open`,target:e,viewerId:f.current,quality:we.current,dpr:u.current}),p.current=B.current},[V]),De=(0,J.useCallback)((e,n=!1)=>{let r=t.find(t=>t.port===e);q({port:e},r?gn(r):`http://localhost:${e}`,n)},[t,q]),Oe=(0,J.useCallback)(()=>q({agent:!0},``),[q]);(0,J.useEffect)(()=>{if(n?.agent){if(R.current.agent&&R.current.stage?.stage===`streaming`)return;Oe();return}if(n?.url!==void 0){let e=Pe(n.url,t);e.kind===`server`?De(e.port):e.kind===`url`&&q({url:e.url},e.url);return}n?.port!==void 0&&(n.restored&&!t.some(e=>e.port===n.port)||R.current.port===n.port&&R.current.stage?.stage===`streaming`&&n.run!==!0||De(n.port,n.run===!0))},[n]);let ke=!ie&&!x&&v.state!==`blocked`,Ae=_n(n,t);(0,J.useEffect)(()=>{ke&&!Ae&&F.current?.focus()},[ke,Ae]);let Y=e=>{let n=Pe(e,t);if(n.kind===`error`)return be(n.message);if(n.kind===`server`)return De(n.port);if(R.current.stage?.stage===`streaming`&&!R.current.agent)return I.current={url:n.url},L.current=void 0,re(void 0),k({url:n.url}),be(void 0),w(n.url),V({t:`nav`,url:n.url});q({url:n.url},n.url)},Me=(0,J.useCallback)(e=>{we.current=e,N(e),zt(e),V({t:`quality`,quality:e})},[V]),X=()=>{p.current=!1,te(void 0),y({state:`connecting`,attempt:0}),Ee.current=!1,_(e=>e+1)};return{compact:h,transport:v,everOpened:ee,takenOver:x,stage:S,url:ne,port:T,agent:E,hasFrame:j,cursor:se,dialog:le,setDialog:de,stats:fe,viewport:me,setViewport:M,quality:he,chooseQuality:Me,setStageSize:_e,addressError:ve,stageHandle:Ce,urlInput:F,send:V,connected:W,streaming:K,openServer:De,openAgent:Oe,empty:ke,navigate:Y,reconnect:X,actions:(0,J.useMemo)(()=>({download:()=>U({t:`download`}),cancelDownload:()=>U({t:`cancelDownload`}),retryBrowser:()=>U({t:`retryBrowser`}),run:e=>{B.current?V({t:`run`,port:e}):c(`The preview is reconnecting. Run the server again once it is back.`,{tone:`danger`})},stop:e=>U({t:`stop`,port:e}),keepWaiting:e=>U({t:`keepWaiting`,port:e}),close:s,useHere:X,copy:hn}),[V,U,s])}}function bn(e){return(0,Y.jsx)(be,{onClose:e.onClose,children:(0,Y.jsx)(Cn,{...e})})}function xn(e,t,n,r){return e.state===`blocked`?{tone:`neutral`,label:`not supported`}:n?{tone:`neutral`,label:`paused`}:t&&(e.state===`reconnecting`||e.state===`closed`)?{tone:`danger`,label:`offline`}:e.state===`open`?r?Sn(r):void 0:{tone:`neutral`,label:`connecting…`}}function Sn(e){switch(e.stage){case`downloading`:return{tone:`pending`,label:`downloading`};case`download-failed`:return{tone:`danger`,label:`download failed`};case`sandbox-failed`:return{tone:`danger`,label:`browser failed`};case`browser-exited`:return{tone:`danger`,label:e.reason===`timeout`?`browser timed out`:`browser exited`};case`needs-approval`:return{tone:`neutral`,label:`not started`};case`port-held`:return{tone:`danger`,label:`port in use`};case`server-starting`:return{tone:`pending`,label:`waiting for :${e.server.port}`};case`server-stalled`:return{tone:`pending`,label:`waiting · 2 min`};case`server-exited`:return{tone:`danger`,label:`server exited`};case`server-stopped`:return{tone:`neutral`,label:`stopped`};case`agent-idle`:return{tone:`neutral`,label:`agent idle`};case`loading`:return{tone:`neutral`,label:`connecting…`};default:return}}function Cn(e){let{run:t,servers:n,serverStates:r,agentLive:i,onSession:a,onClose:o}=e,s=yn(e),{compact:c,transport:l,everOpened:u,takenOver:d,stage:f,url:p,port:m,agent:h,hasFrame:g,stats:_,viewport:v,setViewport:y,quality:ee,chooseQuality:b,addressError:x,urlInput:te,send:S,streaming:C,openServer:ne,openAgent:w,empty:T,navigate:re,actions:E}=s,D=n.find(e=>e.port===m),O=f?.stage===`streaming`&&f.adopted,k=u&&(l.state===`reconnecting`||l.state===`closed`),{content:ie,dim:A}=sn({transport:l.state,takenOver:d,empty:T,stage:f,hasFrame:g,lost:k,url:p,worktree:t.worktreePath}),ae=cn(ie,{servers:n,serverStates:r,agentLive:i,openServer:ne,openAgent:w,actions:E});return(0,Y.jsxs)(`section`,{"data-slot":`preview-pane-body`,"aria-label":`Live preview`,className:`flex h-full min-h-0 flex-col bg-background text-foreground`,children:[(0,Y.jsx)(Xt,{url:p,servers:n,serverStates:r,badge:l.state!==`blocked`,current:D,agentLive:i===!0,agentShown:h,adopted:O,viewport:c?`fit`:v,quality:ee,compact:c,navEnabled:C,loading:f?.stage===`loading`,stats:C?_??{fps:0,kbps:0}:void 0,status:C?void 0:xn(l,u,d!==void 0,f),urlInputRef:te,onSession:a,onNavigate:re,onBack:()=>S({t:`back`}),onForward:()=>S({t:`forward`}),onReload:e=>S({t:`reload`,...e?{ignoreCache:!0}:{}}),onPickServer:e=>ne(e),onPickAgent:w,onViewport:y,onQuality:b,onCopyUrl:()=>hn(p),onStop:E.stop,onClose:o}),x?(0,Y.jsx)(`p`,{role:`alert`,className:`border-b border-border bg-card px-3 py-1.5 text-xs text-danger`,children:x}):null,(0,Y.jsx)(wn,{transportState:s,overlay:ae,dim:A,lost:k})]})}function wn({transportState:e,overlay:t,dim:n,lost:r}){let{connected:i,dialog:a,hasFrame:o,stage:s,stageHandle:c,compact:l,viewport:u,cursor:d,setStageSize:f,send:p,urlInput:m,transport:h,reconnect:g,setDialog:_}=e,v=s?.stage,y=i&&t===null&&!a;return(0,Y.jsxs)(Nt,{ref:c,viewport:l?`fit`:u,dimmed:n&&o&&(v===`streaming`||v===`loading`||n),cursor:d,onSize:f,renderInput:e=>y?(0,Y.jsx)(jt,{scale:e.scale,send:p,onLeave:()=>m.current?.focus()}):null,children:[r?(0,Y.jsx)(ct,{attempt:h.attempt,exhausted:h.state===`closed`,onReconnect:g}):null,t?(0,Y.jsx)(`div`,{"data-slot":`preview-overlay`,className:n&&o?`absolute inset-0 overflow-auto bg-background/85`:`absolute inset-0 overflow-auto bg-background`,children:t}):null,a?(0,Y.jsx)(ut,{dialog:a,onResult:e=>{_(void 0),p({t:`dialogResult`,...e})}}):null]})}function Tn(e){let{visibleEvents:t}=he(e);return(0,J.useMemo)(()=>{let e=new Map;for(let n of te(t,{activeTurn:!1}).turns)for(let t of n.items)t.kind===`preview-server`&&e.set(t.server.port,t);return e},[t])}function En(e){let t=Tn(e.run.id),n=de(e.run.id);return(0,Y.jsx)(bn,{...e,serverStates:t,agentLive:n})}export{En as ConnectedPreviewPane};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r,t as i}from"./utils-DSMR_WLb.js";import{N as a,Rt as o,ct as s}from"./queries-EvENG6TN.js";import{Hr as c,In as l,Ln as u,Wr as d,br as f,hi as p,pi as m,ri as h,zn as g}from"./toaster-Cer2NOxt.js";import{B as _,F as v,I as y,J as b,N as x,W as S,Y as C,z as w}from"./live-protocol-DMhTnCmf.js";import{f as T,m as E}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{X as D}from"./design-icons-CzEoMH9c.js";import{t as O}from"./arrow-up-right-DKGzsMqY.js";import{t as k}from"./chevron-right-BENZ-1ZN.js";import{t as A}from"./eye-B8okNWXU.js";import{t as j}from"./button-B7MKxYjT.js";import{t as M}from"./project-router-BypHPat0.js";import{d as N,l as ee,n as te,r as ne,t as P}from"./page-shell-7pLJMOgh.js";import{t as F}from"./use-search-params-writer-ClMScnNe.js";import{Xn as I,Xt as L,ar as R,jn as z,pn as B}from"./index-8eoz1i7-.js";import{t as V}from"./report-title-D4Mbu2Er.js";import{t as H}from"./html-report-frame-DkHr39E2.js";var U=e(t(),1),W=1e3,G=S().min(1).max(1024);_({q:S().max(W).optional(),before:G.optional(),limit:S().regex(/^(?:[1-9]|[1-9][0-9]|100)$/).transform(Number).optional()}).strict();var K=_({reports:x(_({id:b(),runId:b(),name:S(),title:S(),createdAt:C(),size:w().int().nonnegative(),taskTitle:S(),taskStatus:f}).strict()),nextCursor:G.nullable(),total:w().int().nonnegative()}).strict(),q=_({epoch:b(),generation:w().int().nonnegative(),metadataGeneration:w().int().nonnegative()}).strict(),J=_({runId:b(),taskTitle:S(),taskStatus:f}).strict(),Y=v(`type`,[q.extend({type:y(`snapshot`)}),q.extend({type:y(`content`)}),q.extend({type:y(`metadata`),runs:x(J)})]),X=new WeakMap;function re(e,t){if(!e)return{content:t.type===`content`,metadata:t.type===`metadata`,reset:!1};if(e.epoch!==t.epoch)return{content:!0,metadata:!0,reset:!0};if(!(t.generation<e.generation||t.metadataGeneration<e.metadataGeneration)&&!(e.generation===t.generation&&e.metadataGeneration===t.metadataGeneration))return{content:t.generation!==e.generation,metadata:t.metadataGeneration!==e.metadataGeneration,reset:!1}}var ie=class{client;project;state;content=0;metadata=0;patches=new Map;trailing=new Set;flights=new Map;constructor(e,t){this.client=e,this.project=t,e.getQueryCache().subscribe(n=>{if(n.type===`removed`){this.trailing.delete(n.query),this.flights.delete(n.query);return}if(!(n.query.queryKey[0]!==t||n.query.queryKey[1]!==`reports`)){if(n.type===`updated`&&n.action.type===`fetch`&&this.flights.set(n.query,this.metadata),n.query.state.fetchStatus===`idle`&&this.flights.has(n.query)){let e=this.flights.get(n.query);this.flights.delete(n.query),e!==this.metadata&&String(n.query.queryKey[2]??``).trim()===``&&this.client.setQueryData(n.query.queryKey,t=>t&&{...t,pages:t.pages.map(t=>this.patch(t,e))})}!this.trailing.has(n.query)||n.query.state.fetchStatus!==`idle`||(this.trailing.delete(n.query),queueMicrotask(()=>{e.invalidateQueries({queryKey:n.query.queryKey,exact:!0,refetchType:`active`},{cancelRefetch:!1})}))}})}patch(e,t=-1){return{...e,reports:e.reports.map(e=>{let n=this.patches.get(e.runId);return n&&n.version>t?{...e,taskTitle:n.value.taskTitle,taskStatus:n.value.taskStatus}:e})}}async read(e,t){for(;;){let n=this.content,r=this.metadata,i=await t();if(!(n!==this.content||e.trim()!==``&&r!==this.metadata))return e.trim()===``?this.patch(i,r):i}}receive(e,t=!1){let n=this.state;if(!n&&e.type===`snapshot`){this.state=e,this.content++,this.client.getQueryCache().findAll({queryKey:[this.project,`reports`]}).some(e=>e.state.data!==void 0)&&this.invalidate(!0);return}let r=re(n,e);if(!r){t&&e.type===`snapshot`&&(this.content++,this.invalidate(!0));return}let{metadata:i,reset:a}=r,o=r.content||t&&e.type===`snapshot`;this.state=e,a&&this.patches.clear(),i&&this.metadata++,o&&this.content++,e.type===`metadata`&&!a&&this.patchCaches(e);let s=o||i&&e.type!==`metadata`;(s||i)&&this.invalidate(s)}patchCaches(e){for(let t of e.runs)this.patches.set(t.runId,{value:t,version:this.metadata});this.client.setQueriesData({queryKey:[this.project,`reports`],predicate:e=>String(e.queryKey[2]??``).trim()===``},e=>e&&{...e,pages:e.pages.map(e=>this.patch(e,this.metadata-1))})}invalidate(e){let t={queryKey:[this.project,`reports`],refetchType:`active`,...e?{}:{predicate:e=>String(e.queryKey[2]??``).trim()!==``}};for(let e of this.client.getQueryCache().findAll(t))e.state.fetchStatus===`fetching`&&this.trailing.add(e);this.client.invalidateQueries(t,{cancelRefetch:!1})}};function ae(e,t){let n=X.get(e);n||(n=new Map,X.set(e,n));let r=n.get(t);return r||(r=new ie(e,t),n.set(t,r)),r}async function oe(e,t){let n=await l.api.v1.p[`:projectId`].reports.state.$get({param:{projectId:e}},u({signal:t}));return q.parse(await g(n,`/reports/state`))}function se(e){let t=ae(p(),e);return(0,U.useEffect)(()=>{let n=o(`reports:project:${e}`,e=>{let n=Y.safeParse(e);n.success&&t.receive(n.data,n.data.type===`snapshot`)}),r,i,a=()=>{if(c()===`finite`&&!r){i=new AbortController;let n=i.signal;oe(e,n).then(e=>{n.aborted||t.receive({type:`snapshot`,...e})}).catch(()=>void 0),r=s({path:`/api/v1/p/${encodeURIComponent(e)}/reports/state`,intervalMs:5e3},(e,n)=>{let r=q.safeParse(e);!n&&r.success&&t.receive({type:`snapshot`,...r.data})})}else c()!==`finite`&&(i?.abort(),r?.(),r=void 0)};a();let l=d(a);return()=>{l(),i?.abort(),r?.(),n()}},[t,e]),t}async function ce(e,t,n,r){let i=await l.api.v1.p[`:projectId`].reports.$get({param:{projectId:e},query:{q:t.slice(0,W),...n?{before:n}:{}}},u(r?{signal:r}:void 0));return K.parse(await g(i,`/reports`))}function Z(e){let t=r(),n=se(t);return h({queryKey:[t,`reports`,e],initialPageParam:void 0,queryFn:({pageParam:r,signal:i})=>n.read(e,()=>ce(t,e,r,i)),getNextPageParam:e=>e.nextCursor??void 0,staleTime:0,refetchOnWindowFocus:!0})}var Q=n(),$=new Map;function le(e){let t=L(),[n,r]=(0,U.useState)(!1);return(0,U.useLayoutEffect)(()=>{let n=e.current;if(!n)return;let i=e=>{r(e>0?e>=660:t)};if(i(n.getBoundingClientRect().width),typeof ResizeObserver!=`function`)return;let a=new ResizeObserver(e=>{let t=e[0]?.contentRect.width??n.getBoundingClientRect().width;i(t)});return a.observe(n),()=>a.disconnect()},[e,t]),n}function ue(){let e=T(),t=E(),[n,r]=F(),a=(n.get(`q`)??``).slice(0,W),o=Z(a),s=(0,U.useRef)(null),c=(0,U.useRef)(null),l=(0,U.useRef)(``),u=e.pathname+e.search,d=o.data?.pages.flatMap(e=>e.reports)??[],f=e=>{$.set(u,{scroll:c.current?.scrollTop??0,row:e,pages:o.data?.pages.length??1})},[p,m]=(0,U.useState)(null),h=le(s);(0,U.useLayoutEffect)(()=>{if(!o.data||l.current===u)return;let n=$.get(u),r=e.state?.filesRestoreKey===u;if(!n||!c.current||t!==`POP`&&!r){l.current=u;return}let i=c.current.querySelector(`[data-report-id="${n.row}"]`);if(o.isFetchNextPageError){l.current=u,c.current.scrollTop=0;return}if((!i||o.data.pages.length<n.pages)&&o.hasNextPage){o.isFetchingNextPage||o.fetchNextPage();return}l.current=u,c.current.scrollTop=i?n.scroll:0,i?.focus({preventScroll:!0})},[u,o.data,o.hasNextPage,o.isFetchingNextPage,o.isFetchNextPageError,o.fetchNextPage,e.state,t]);let g=t=>r(n=>(t?n.set(`q`,t.slice(0,W)):n.delete(`q`),$.delete(e.pathname+`?`+n.toString()),n)),_=d.find(e=>e.id===p)??d[0]??null,v=o.isPending?`full`:N(d.length);return(0,Q.jsx)(ee,{route:`reports`,density:v,fillHeight:!0,bodyClassName:`gap-4`,header:{title:`Reports`,subtitle:`Published HTML snapshots from tasks in this project.`},children:(0,Q.jsxs)(`div`,{ref:s,"data-slot":`reports-content`,className:`flex min-h-0 min-w-0 flex-1 flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`relative w-full shrink-0`,children:[(0,Q.jsx)(D,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,Q.jsx)(I,{maxLength:W,"aria-label":`Search reports`,placeholder:`Search reports or source tasks…`,value:a,onChange:e=>g(e.target.value),className:`h-10 w-full rounded-lg border-border bg-card pl-9 text-sm max-md:h-11`})]}),o.isPending?(0,Q.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(`p`,{role:`status`,className:`py-4 text-sm text-muted-foreground`,children:`Loading reports…`})}):o.isError&&d.length===0?(0,Q.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-3 rounded-xl border border-border bg-card p-5`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Could not load reports`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o.error.message}),(0,Q.jsx)(j,{variant:`outline`,className:`min-h-11`,onClick:()=>void o.refetch(),children:`Retry`})]})}):d.length===0?(0,Q.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(P,{icon:(0,Q.jsx)(R,{}),title:a?`No matching reports`:`No published reports yet`,description:a?`Try a different keyword or clear the search filter.`:(0,Q.jsxs)(Q.Fragment,{children:[`Publish an HTML snapshot with`,` `,(0,Q.jsxs)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground`,children:[B(),` artifact publish`]}),` `,`to list it here.`]}),actions:a?(0,Q.jsx)(j,{"data-slot":`reports-clear-search`,variant:`outline`,className:`min-h-11`,onClick:()=>g(``),children:`Clear search`}):(0,Q.jsx)(j,{variant:`outline`,className:`min-h-11`,asChild:!0,children:(0,Q.jsx)(M,{to:`/new`,children:`Start a task`})})})}):(0,Q.jsx)(ne,{list:(0,Q.jsxs)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1.5`,"aria-label":`Reports`,children:d.map(e=>{let t=_?.id===e.id;return(0,Q.jsxs)(`li`,{"data-slot":`report-row`,"data-selected":h&&t?`true`:void 0,className:i(`reports-row flex items-center gap-3 rounded-xl border border-border bg-card px-4 py-3 transition-colors`,h&&t&&`border-accent-strong/60 bg-sidebar-row-selected/40`),children:[(0,Q.jsx)(R,{"aria-hidden":`true`,className:`reports-icon mt-0.5 size-4 shrink-0 self-start text-accent-text`}),(0,Q.jsxs)(`div`,{className:`reports-lines flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Q.jsx)(`h2`,{className:`flex min-w-0 text-[14px] leading-5 font-semibold text-foreground`,title:V(e),children:(0,Q.jsx)(M,{"data-report-id":e.id,className:`reports-open text-foreground no-underline`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:u,filesRestoreKey:u},onClick:()=>f(e.id),children:(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:V(e)})})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-xs leading-4 text-muted-foreground`,children:[(0,Q.jsx)(M,{className:`reports-task min-w-0 truncate text-xs text-muted-foreground no-underline hover:text-foreground hover:underline`,to:`/tasks/${e.runId}`,children:(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,title:e.taskTitle,children:e.taskTitle})}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,Q.jsx)(z,{className:`shrink-0`,iso:e.createdAt,prefix:`Published · `})]})]}),h?(0,Q.jsx)(`button`,{type:`button`,"data-slot":`report-preview-select`,"aria-label":`Preview ${V(e)}`,"aria-pressed":t,onClick:()=>m(e.id),className:`reports-preview-btn inline-flex min-h-8 min-w-8 shrink-0 items-center justify-center gap-1 rounded-md border border-border bg-background px-2 py-1.5 text-xs text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,children:(0,Q.jsx)(A,{"aria-hidden":`true`,className:`size-3.5`})}):(0,Q.jsx)(k,{"aria-hidden":`true`,"data-slot":`report-open-cue`,className:`reports-cue size-4 shrink-0 text-muted-foreground`})]},e.id)})}),o.hasNextPage?(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(j,{variant:`outline`,className:`min-h-11`,disabled:o.isFetchingNextPage,onClick:()=>void o.fetchNextPage(),children:`Load more reports`})}):null,v===`sparse`?(0,Q.jsx)(te,{summary:`${d.length} published ${d.length===1?`report`:`reports`}. Select a row to open full screen or preview beside the list.`}):null]}),detail:h&&_?(0,Q.jsx)(de,{report:_,restoreKey:u,onOpenReader:()=>f(_.id)}):null})]})})}function de({report:e,restoreKey:t,onOpenReader:n}){let r=(0,U.useContext)(m)!==void 0;return(0,Q.jsxs)(`section`,{"data-slot":`reports-preview-pane`,"aria-label":`Preview of ${V(e)}`,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border bg-card`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h2`,{className:`truncate text-sm font-semibold text-foreground`,children:V(e)}),(0,Q.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-muted-foreground`,children:[e.taskTitle,` · `,(0,Q.jsx)(z,{iso:e.createdAt,prefix:`Published · `})]})]}),(0,Q.jsx)(j,{variant:`outline`,size:`sm`,asChild:!0,className:`h-auto min-h-8 shrink-0 py-1.5`,children:(0,Q.jsxs)(M,{"data-slot":`reports-preview-open`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:t,filesRestoreKey:t},onClick:n,children:[`Open reader`,(0,Q.jsx)(O,{"aria-hidden":`true`,className:`size-3.5`})]})})]}),r?(0,Q.jsx)(fe,{report:e}):(0,Q.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-xs text-muted-foreground`,children:`Open reader to view this HTML report.`})]})}function fe({report:e}){let t=a(e.runId,e.id);if(t.isPending)return(0,Q.jsx)(`p`,{role:`status`,className:`p-6 text-xs text-muted-foreground`,children:`Loading preview…`});if(t.isError)return(0,Q.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-2 p-6 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`p`,{className:`font-medium text-foreground`,children:`Could not load report preview`}),(0,Q.jsx)(`p`,{children:t.error.message}),(0,Q.jsx)(j,{variant:`outline`,size:`sm`,onClick:()=>void t.refetch(),children:`Retry`})]});let n=t.data;return!n||n.type!==`file`||n.binary||n.content===void 0?(0,Q.jsx)(`p`,{className:`p-6 text-xs text-muted-foreground`,children:`Preview unavailable for this artifact.`}):(0,Q.jsx)(H,{html:n.content,title:V(e),className:`min-h-0 flex-1`})}export{ue as ReportsRoute};
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{n as r,t as i}from"./utils-DSMR_WLb.js";import{Ct as a,G as o,H as s,K as c,St as l,U as u,W as d,Wt as f,Y as p,dn as m,f as h,ln as g,lt as _,rn as v,rt as ee,tt as y,un as te,xt as b,yt as ne}from"./queries-EvENG6TN.js";import{An as re,Fn as ie,It as ae,Lt as x,cr as oe,hi as se,n as S,or as C,tt as w,ut as ce,yr as le}from"./toaster-Cer2NOxt.js";import{a as ue,d as de,f as fe,g as T,m as pe,o as me,p as he,s as ge}from"./tasks-table-DGBiE6ux.js";import{F as _e,at as ve,ft as ye,i as be,l as xe,p as Se,q as Ce,t as we,v as E,x as Te}from"./design-icons-CzEoMH9c.js";import{t as D}from"./createLucideIcon-BHp8sXmF.js";import{t as Ee}from"./app-window-CSHwDX9N.js";import{n as De,r as Oe,t as ke}from"./open-in-menu-C09BLcfQ.js";import{t as Ae}from"./info-DA1x_4bz.js";import{t as je}from"./message-square-B-MD-8rD.js";import{i as Me,n as Ne,t as O}from"./reference-chip-BLHAGMsc.js";import{t as Pe}from"./square-terminal-B6RYYieR.js";import{t as k}from"./button-B7MKxYjT.js";import{a as A,i as j,l as M,n as N,p as P,r as F,t as I}from"./dropdown-menu-4e2iKSMT.js";import{i as Fe,r as Ie,t as Le}from"./popover-CZV6tz9i.js";import{a as Re,i as ze,o as Be,r as Ve,s as He,t as Ue}from"./dialog-B531GGAo.js";import{c as We,s as Ge,t as L}from"./project-router-BypHPat0.js";import"./attention-wzzAdp4t.js";import{T as Ke,f as R,u as qe}from"./task-groups-nvRvmVHf.js";import{t as Je}from"./status-dot-BRzVlF2X.js";import{t as Ye}from"./format-BU7D3IfE.js";import{$t as Xe,Dn as Ze,Gt as z,Hn as Qe,Ht as B,Jt as V,Kt as H,L as $e,R as U,Un as et,Ut as tt,Vt as nt,Wn as rt,Wt as it,Zt as at,_n as ot,a as st,ar as ct,cn as W,er as lt,m as ut,o as dt,pr as ft,qt as pt,r as G,rn as mt,sn as K,tr as ht,yn as q,z as gt}from"./index-8eoz1i7-.js";import{t as _t}from"./markdown-Dn1C5VnY.js";import{t as vt}from"./textarea-vJt9undk.js";import{t as yt}from"./task-file-scope-CkPO86PU.js";import{t as J}from"./tab-link-Bjo_gEiX.js";var bt=D(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),xt=D(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),St=D(`pin-off`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),Y=e(t(),1),X=n();function Ct(e){let t=_();return m({mutationFn:t=>w(te(e),t),onSuccess:()=>t.invalidateAfter(`runs`,()=>g()),onError:e=>S(e.message,{tone:`danger`})})}function wt(e){return e.archived?`Unarchive`:`Archive task`}function Tt({run:e,open:t,onOpenChange:n,onConfirm:r}){return(0,X.jsx)(nt,{open:t,onOpenChange:n,children:(0,X.jsxs)(it,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,X.jsxs)(pt,{children:[(0,X.jsx)(V,{children:`Archive task?`}),(0,X.jsxs)(z,{children:[`Move “`,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,title:R(e),children:R(e)}),`” out of Active tasks. You can restore it from Archived.`]})]}),(0,X.jsxs)(H,{children:[(0,X.jsx)(tt,{children:`Cancel`}),(0,X.jsx)(B,{className:`bg-accent-strong text-accent-strong-foreground hover:brightness-[0.96]`,onClick:r,children:`Archive task`})]})]})})}function Et({run:e,className:t}){let[n,r]=(0,Y.useState)(!1),a=Ct(e.id),o=wt(e);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(k,{type:`button`,variant:`outline`,"data-slot":`archive-action`,"aria-label":o,title:e.archived?`Put this task back in Active tasks`:`Move this task out of Active tasks`,disabled:a.isPending,className:i(`h-11 gap-[7px] px-3`,t),onClick:()=>e.archived?a.mutate(!1):r(!0),children:[e.archived?(0,X.jsx)(ft,{"aria-hidden":`true`}):(0,X.jsx)(we,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:o})]}),(0,X.jsx)(Tt,{run:e,open:n,onOpenChange:r,onConfirm:()=>{a.mutate(!0),r(!1)}})]})}function Dt({run:e,action:t,prUrl:n,patch:i}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`text-sm [overflow-wrap:anywhere]`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:t.phase===`blocked`?`Completion blocked`:`Completion pending`}),` · `,t.message||(t.phase===`blocked`?`Completion needs attention.`:`Checking completion actions.`)]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[n&&r(n)?(0,X.jsx)(k,{variant:`outline`,asChild:!0,children:(0,X.jsx)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,children:`Open PR`})}):null,e.autoMergePr?(0,X.jsx)(k,{variant:`outline`,disabled:i.isPending,onClick:()=>i.mutate({autoMergePr:!1},{onError:e=>S(e.message,{tone:`danger`})}),children:i.isPending?`Saving…`:`Disable auto-merge`}):null]})]})}function Ot({run:e,blocker:t,flags:n}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`text-sm [overflow-wrap:anywhere]`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Archive blocked`}),` · `,t.message]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[t.runId?(0,X.jsx)(k,{variant:`outline`,asChild:!0,children:(0,X.jsx)(L,{to:`/tasks/${t.runId}`,children:`Open blocking task`})}):null,t.pullRequestUrl&&r(t.pullRequestUrl)?(0,X.jsx)(k,{variant:`outline`,asChild:!0,children:(0,X.jsx)(`a`,{href:t.pullRequestUrl,target:`_blank`,rel:`noopener noreferrer`,children:`Open blocking PR`})}):null,n.archive?(0,X.jsx)(Et,{run:e}):null]})]})}function kt({run:e}){let t=o(e.id),n=W(e),r=e.status===`done`?e.completionAction:void 0,i=n.archive?e.archiveBlocker:void 0,a=r&&r.phase!==`complete`?r:void 0;if(!a&&!i)return null;let s=e.pullRequestUrl??e.pullRequests?.find(e=>e.url)?.url;return(0,X.jsxs)(`section`,{"data-slot":`completion-status`,"aria-label":`Completion action`,className:`grid min-w-0 gap-2 rounded-lg border border-card-edge bg-card p-3 shadow-card [margin-block:0.75rem]`,children:[a?(0,X.jsx)(Dt,{run:e,action:a,prUrl:s,patch:t}):null,i?(0,X.jsx)(Ot,{run:e,blocker:i,flags:n}):null]})}var At=[`running`,`queued`,`waiting`];function jt(e,{queuePosition:t,now:n=new Date}){let r=re(e),i=Ze(e,r).label,a=t===void 0?i:`${i} #${t}`,o=At.includes(e.status)?Nt(e,n):void 0;return o?{attention:r,label:a,nextCheck:o}:{attention:r,label:a}}function Mt(e){return e.nextCheck?`${e.label} · Next check ${e.nextCheck.text}`:e.label}function Nt(e,t){let n;for(let t of Array.isArray(e.waits)?e.waits:[]){if(t?.kind!==`timer`||t.phase!==`open`)continue;let e=new Date(t.deadline);Number.isFinite(e.getTime())&&(!n||e<n)&&(n=e)}if(n)return{at:n.toISOString(),text:Ye(n,t)}}async function Z(e,t){try{await navigator.clipboard.writeText(e),S(t)}catch{S(`Run manually: ${e}`)}}function Pt(e){let t=b(),n=h(),r=(0,Y.useMemo)(()=>T(e,t),[e,t]);return{referenceProjectId:n,repoBase:t,references:r,requests:(0,Y.useMemo)(()=>n===void 0?[]:r.filter(e=>ue(e,t)).map(e=>({projectId:n,kind:e.kind,number:e.number})),[r,n,t])}}function Ft(e){return m({mutationFn:()=>x(e.id),onError:e=>{if(e instanceof ie&&e.command){Z(e.command,`No terminal found — command copied to clipboard.`);return}S(e.message,{tone:`danger`})}})}function Q(e,t){let n=d(),r=a(),i=v(),o=m({mutationFn:t=>ae(e.id,t),onError:e=>S(e.message,{tone:`danger`})}),s=ot(),c=Ke(e),l=s.runnersOn(e=>t&&c.sessionId!==void 0&&e===c.backend?c.profileId??`default`:s.repoAccount?.[e]).runners,u=e=>!r.isSuccess||!i.isSuccess||l.includes(e??`claude`);return{canResumeHere:t&&u(mt(e)),choices:e.worktreePath?(n.data?.targets??[]).filter(e=>{let t=De(e.id);return t===void 0||i.isSuccess&&u(t)}).map(t=>({target:t,...Xe(e,t.id)?{suffix:` (resume)`,title:`Resume this run's session`}:{}})):[],open:o}}function It({run:e,canResume:t,onResume:n}){let{canResumeHere:r,choices:i,open:a}=Q(e,t),o=v().data,s=K(e);return!r&&i.length===0&&!s?null:(0,X.jsxs)(X.Fragment,{children:[r||i.length>0?(0,X.jsxs)(`div`,{className:`task-open-targets flex flex-wrap gap-3`,children:[r?(0,X.jsxs)(k,{variant:`outline`,"data-target":`terminal-resume`,onClick:n,children:[(0,X.jsx)(Pe,{}),`Terminal (resume session)`]}):null,i.map(({target:e,suffix:t,title:n})=>{let r=Oe(e,o);return(0,X.jsxs)(k,{variant:`outline`,"data-target":e.id,title:n,disabled:a.isPending,onClick:()=>a.mutate(e.id),children:[(0,X.jsx)(r,{"aria-hidden":`true`}),e.label,t??``]},e.id)}),e.worktreePath?(0,X.jsxs)(k,{variant:`outline`,onClick:()=>{let t=e.worktreePath;t&&navigator.clipboard.writeText(t).then(()=>S(`Worktree path copied`)).catch(()=>S(`Path: ${t}`))},children:[(0,X.jsx)(E,{}),`Copy worktree path`]}):null]}):null,s?(0,X.jsxs)(`div`,{"data-slot":`resume-command`,className:`mt-5 border-t border-border pt-5`,children:[(0,X.jsx)(`h3`,{className:`text-base font-medium`,children:`Resume in a terminal`}),(0,X.jsx)(`pre`,{className:`my-4 whitespace-pre-wrap break-all rounded-lg border border-border bg-background p-4 text-xs`,children:s}),(0,X.jsxs)(k,{variant:`outline`,onClick:()=>void Z(s,`Command copied to clipboard.`),children:[(0,X.jsx)(E,{}),`Copy resume command`]})]}):null]})}function Lt({run:e,canResume:t,onResume:n}){let{canResumeHere:r,choices:i,open:a}=Q(e,t),o=K(e),s=e.worktreePath;if(!r&&i.length===0&&!o&&!s)return null;let c=`max-md:min-h-11`;return(0,X.jsxs)(`div`,{"data-slot":`workspace-tools`,className:`flex min-w-0 flex-wrap gap-2`,children:[r||i.length>0?(0,X.jsx)(ke,{choices:i,onPick:e=>a.mutate(e),disabled:a.isPending,triggerVariant:`outline`,className:c,leading:r?(0,X.jsxs)(j,{"data-target":`terminal-resume`,onSelect:n,children:[(0,X.jsx)(Pe,{"aria-hidden":`true`}),`Terminal (resume session)`]}):void 0}):null,s?(0,X.jsxs)(k,{variant:`outline`,size:`sm`,className:c,onClick:()=>void Z(s,`Worktree path copied`),children:[(0,X.jsx)(E,{"aria-hidden":`true`}),`Copy worktree path`]}):null,o?(0,X.jsxs)(k,{variant:`outline`,size:`sm`,"data-slot":`resume-command`,title:o,className:c,onClick:()=>void Z(o,`Command copied to clipboard.`),children:[(0,X.jsx)(E,{"aria-hidden":`true`}),`Copy resume command`]}):null]})}function Rt({run:e,canResume:t,onResume:n,onOpen:r,onClose:i}){let{canResumeHere:a,choices:o}=Q(e,t);return!a&&o.length===0?null:r?(0,X.jsx)(j,{onSelect:r,children:`Open in…`}):(0,X.jsxs)(`section`,{"aria-label":`Open task worktree in…`,className:`task-action-panel my-5 rounded-xl border border-border bg-card p-6`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`h2`,{className:`text-lg font-medium`,children:`Open task worktree in…`}),(0,X.jsx)(k,{variant:`ghost`,size:`icon`,"aria-label":`Close worktree chooser`,onClick:i,children:(0,X.jsx)(ye,{})})]}),e.worktreePath?(0,X.jsx)(`p`,{className:`my-4 break-all text-xs text-muted-foreground`,children:e.worktreePath}):null,(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(It,{run:e,canResume:t,onResume:n})})]})}function zt({branch:e}){let[t,n]=(0,Y.useState)(null),r=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]);let i=t===e,a=async()=>{r.current!==null&&clearTimeout(r.current),n(null);try{if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(e),n(e),r.current=setTimeout(()=>n(null),2e3)}catch{S(`Could not copy branch. Select and copy: ${e}`)}};return(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`,children:[(0,X.jsx)(`span`,{"data-slot":`branch-chip`,className:`min-w-0 rounded-sm border border-border bg-card px-1.5 py-px font-mono text-xs font-medium break-all`,children:e}),(0,X.jsxs)(`button`,{type:`button`,"aria-label":i?`Copied branch name`:`Copy branch name`,onClick:()=>void a(),className:`inline-flex min-h-11 shrink-0 items-center gap-1 rounded-sm px-2 text-xs font-medium text-foreground hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground md:min-h-8`,children:[(0,X.jsx)(E,{className:`size-3.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{"aria-live":`polite`,children:i?`Copied`:`Copy`})]})]})}function Bt({run:e}){let t=b(),n=h(),i=r=>n===void 0?void 0:fe(n,e.id,r,t),a=(0,Y.useMemo)(()=>T(e,t),[e,t]),o=[],s=[],c=a.filter(e=>e.kind===`PR`);for(let t of c)o.push((0,X.jsx)(O,{reference:t,to:i(t),taskTitle:R(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`,conflictAction:(0,X.jsx)(at,{run:e,prNumber:t.number})},ge(t)));let l=pe(e);l&&r(l)&&!c.some(e=>e.url===l)&&o.push((0,X.jsx)(O,{reference:{kind:`PR`,url:l},taskTitle:R(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`pr`));let u=a.filter(e=>e.kind===`Issue`);for(let t of u)s.push((0,X.jsx)(O,{reference:t,to:i(t),taskTitle:R(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},ge(t)));let d=de(e,t);if(d&&r(d)&&!u.some(e=>e.url===d)){let t=me(d);s.push((0,X.jsx)(O,{reference:{kind:`Issue`,...t?{number:Number(t)}:{},url:d},to:t?i({kind:`Issue`,number:Number(t),url:d}):void 0,taskTitle:R(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`issue`))}return o.length===0&&s.length===0?null:(0,X.jsx)(`div`,{"data-slot":`linked-references`,className:`flex min-w-0 flex-col gap-3`,children:[[`PR`,`PRs`,o],[`Issue`,`Issues`,s]].map(([e,t,n])=>n.length>0?(0,X.jsxs)(`div`,{"data-reference-kind":e,className:`grid min-w-0 grid-cols-[5rem_minmax(0,1fr)] items-center gap-x-2 gap-y-1`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),(0,X.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:n})]},e):null)})}function Vt(){let e=Ge(),t=l();return $e(t.data?.projects?.find(n=>n.id===(e??t.data?.bootProject)))}var Ht=e=>e.map(e=>`${e.name}: ${U(e.url)}`).join(`
2
- `);function Ut(e){return Vt().length>0||e.notify===!0}function $({run:e}){let t=Vt(),n=t.length>0,r=u(e.id),[i,a]=(0,Y.useState)(null),o=e.notify===!0;return!n&&!o?null:(0,X.jsxs)(X.Fragment,{children:[o?(0,X.jsxs)(I,{children:[(0,X.jsx)(P,{asChild:!0,children:(0,X.jsxs)(k,{variant:`outline`,size:`sm`,"data-slot":`notifying-chip`,className:`h-11 gap-1.5 md:h-[30px]`,"aria-label":n?`Notifying ${gt(t)} — webhook actions`:`Notifying — webhook actions`,title:n?Ht(t):void 0,children:[(0,X.jsx)(Je,{tone:`success`}),(0,X.jsx)(`span`,{children:`Notifying`}),(0,X.jsx)(xe,{"aria-hidden":`true`,className:`size-3.5`})]})}),(0,X.jsxs)(F,{align:`end`,"data-slot":`notifying-menu`,className:`w-[240px] max-w-[calc(100vw-2rem)] p-2`,children:[n?(0,X.jsx)(A,{"data-slot":`notifying-targets`,className:`flex flex-col gap-0.5 px-2 py-1.5 text-xs font-normal text-muted-foreground`,children:t.map(e=>(0,X.jsx)(`span`,{"data-webhook-target":e.id,className:`truncate`,title:U(e.url),children:e.name},e.id))}):null,n?(0,X.jsxs)(j,{className:`min-h-11`,onSelect:()=>a(`note`),children:[(0,X.jsx)(je,{"aria-hidden":`true`}),` Send a note…`]}):null,(0,X.jsxs)(j,{variant:`destructive`,className:`min-h-11`,disabled:r.isPending,onSelect:()=>r.mutate({notify:!1},{onSuccess:()=>S(`Stopped notifying the webhook`),onError:e=>S(`Could not stop notifying. ${e.message}`,{tone:`danger`})}),children:[(0,X.jsx)(bt,{"aria-hidden":`true`}),` Stop notifying`]})]})]}):(0,X.jsxs)(k,{variant:`outline`,size:`sm`,"data-action":`handoff`,className:`size-11 px-0 md:h-[30px] md:w-auto md:px-2.5`,"aria-label":`Hand off to webhook`,onClick:()=>a(`handoff`),children:[(0,X.jsx)(lt,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`max-md:sr-only`,children:`Hand off`})]}),n?(0,X.jsx)(Wt,{mode:i,targets:t,pending:r.isPending,onOpenChange:e=>!e&&a(null),onSubmit:e=>r.mutate({notify:!0,...e?{message:e}:{}},{onSuccess:()=>{a(null),S(i===`note`?`Note sent to the webhook`:`Handed off to the webhook`)},onError:e=>S(`Could not hand off. ${e.message}`,{tone:`danger`})})}):null]})}function Wt({mode:e,targets:t,pending:n,onOpenChange:r,onSubmit:i}){let a=(0,Y.useId)(),o=(0,Y.useId)(),[s,c]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{e!==null&&c(``)},[e]);let l=e===`note`,u=gt(t);return(0,X.jsx)(Ue,{open:e!==null,onOpenChange:e=>{e||c(``),r(e)},children:(0,X.jsx)(Ve,{"data-slot":`handoff-dialog`,className:`max-sm:top-auto max-sm:bottom-0 max-sm:left-0 max-sm:max-w-none max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none max-sm:rounded-t-xl max-sm:border-x-0 max-sm:border-b-0 max-sm:pb-[max(1.5rem,env(safe-area-inset-bottom))] max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100`,children:(0,X.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),i(s.trim())},children:[(0,X.jsxs)(Be,{className:`text-left`,children:[(0,X.jsx)(He,{children:l?`Send a note to ${t.length===1?`the webhook`:`the webhooks`}`:`Hand off to webhook`}),(0,X.jsx)(ze,{children:(0,X.jsx)(`span`,{"data-webhook-destination":``,title:Ht(t),children:l?`${u} ${t.length===1?`gets`:`get`} this note with the task's current status.`:`${u} will start receiving this task's status updates. Add a note (optional).`})})]}),(0,X.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,X.jsx)(`label`,{htmlFor:a,className:`text-[13px] font-medium`,children:`Note`}),(0,X.jsx)(vt,{id:a,"data-slot":`handoff-note`,"aria-describedby":o,rows:4,maxLength:1e5,className:`min-h-24`,placeholder:`e.g. Take over from here, ping me when the PR is green`,value:s,onChange:e=>c(e.target.value)}),(0,X.jsxs)(`p`,{id:o,className:`flex items-center gap-1.5 text-[12px] text-muted-foreground`,children:[(0,X.jsx)(Ae,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),`The note goes to the webhook only, not to the agent.`]})]}),(0,X.jsxs)(Re,{className:`gap-2 max-sm:flex-col-reverse max-sm:[&>button]:h-11 max-sm:[&>button]:w-full`,children:[(0,X.jsx)(k,{type:`button`,variant:`ghost`,className:`sm:h-9`,onClick:()=>r(!1),children:`Cancel`}),(0,X.jsxs)(k,{type:`submit`,variant:`contrast`,className:`sm:h-9`,"data-action":`handoff-submit`,disabled:n||l&&s.trim()===``,children:[(0,X.jsx)(lt,{"aria-hidden":`true`}),l?`Send note`:`Hand off`]})]})]})})})}function Gt({id:e}){return(0,X.jsxs)(L,{to:`/tasks/${e}`,"aria-label":`Parent task ${e}`,"data-slot":`mobile-parent-task-link`,className:`inline-flex shrink-0 items-center justify-center gap-1 rounded-sm px-2 text-[13px] text-muted-foreground [min-block-size:2.75rem] [min-inline-size:2.75rem] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:bg-muted active:text-foreground`,children:[(0,X.jsx)(be,{"aria-hidden":!0,className:`shrink-0 [block-size:1.2cap] [inline-size:auto]`}),`Parent`]})}function Kt({id:e}){let t=p(e),n=t.data?R(t.data):e;return(0,X.jsxs)(`div`,{"data-slot":`parent-task`,className:`flex min-w-0 flex-wrap items-center gap-x-2 text-[13px] text-muted-foreground`,children:[(0,X.jsxs)(L,{to:`/tasks/${e}`,"aria-label":`Parent task ${e}`,title:`Parent · ${n}`,"data-slot":`parent-task-link`,className:`flex min-h-11 min-w-0 max-w-full items-center gap-2 rounded-sm text-muted-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:text-foreground`,children:[(0,X.jsx)(be,{"aria-hidden":!0,className:`h-[1.2cap] w-auto shrink-0`}),(0,X.jsx)(`span`,{className:`shrink-0`,children:`Parent`}),(0,X.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,X.jsx)(`span`,{className:`min-w-0 overflow-clip text-ellipsis whitespace-nowrap`,children:n})]}),t.isError?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{children:`Parent record unavailable or deleted`}),(0,X.jsx)(k,{variant:`outline`,className:`min-h-11`,onClick:()=>void t.refetch(),children:`Retry parent task`})]}):null]})}var qt=3,Jt=(e,t)=>e.kind===t.kind&&e.number===t.number;function Yt(e,t,n=qt){let r=t?e.findIndex(e=>Jt(e,t)):-1;if(e.length<=n||r<n)return{inline:e.slice(0,n),overflow:e.slice(n)};let i=[...e.slice(0,n-1),e[r]];return{inline:i,overflow:e.filter(e=>!i.includes(e))}}var Xt=(e,t)=>`/tasks/${e}/${t.kind}/${t.number}`;function Zt({tab:e}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(e.kind===`pr`?_e:Se,{"aria-hidden":`true`,className:`mr-1 size-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`sr-only`,children:e.kind===`pr`?`Pull request`:`Issue`}),` #`,e.number,(0,X.jsx)(Ne,{kind:e.kind===`pr`?`PR`:`Issue`,number:e.number,className:`ml-1`})]})}function Qt(e,t){let n=e[0],r=e.length+ +!!t;return n?`Preview :${n.port}${r>1?` +${r-1}`:``}`:t?`Preview · agent`:`Preview`}function $t({servers:e}){let t=ut();if(t===null)return null;let n=t.agentLive===!0,r=e[0],i=e.length+ +!!n===1?r?{port:r.port}:{agent:!0}:{};return(0,X.jsxs)(k,{variant:`outline`,size:`sm`,"data-slot":`preview-toggle`,className:`max-md:h-11`,"aria-pressed":t.open,onClick:()=>t.openPane(i),children:[(0,X.jsx)(Ee,{"aria-hidden":`true`}),Qt(e,n),t.live?(0,X.jsx)(Je,{tone:`success`,"aria-label":`Preview is live`}):null]})}function en(e){return e?.role===`worker`?`Worker session`:e?.role===`root`?`Parent session`:`Task session`}function tn({run:e,compact:t=!1}){if(e.delegation?.role!==`worker`)return null;let n=e.delegation.supervisorRunId??e.delegation.parentRunId;return t?(0,X.jsx)(Gt,{id:n}):(0,X.jsx)(Kt,{id:n})}function nn({isDesktop:e,desktopActivitySlot:t,attention:n,statusLine:r}){return e&&t?(0,X.jsx)(X.Fragment,{children:t}):(0,X.jsx)(G,{dot:n.tone,shape:n.shape,pulse:n.pulse,className:`max-md:hidden`,children:Mt(r)})}function rn(e,t,n){return n&&!e.archiveBlocker&&t.archive?(0,X.jsx)(Et,{run:e}):null}function an({archived:e,className:t}){return e?(0,X.jsx)(G,{"data-slot":`run-archived-pill`,dot:q.tone,shape:q.shape,className:t,children:q.label}):null}function on({run:e}){return e.archived&&e.autoArchive?.reason===`pull-requests-merged`&&e.autoArchive.archivedAt===e.archivedAt?(0,X.jsx)(`p`,{"data-slot":`auto-archive-reason`,className:`text-[13px] text-muted-foreground`,children:`Archived automatically after all associated PRs merged.`}):null}function sn({shown:e,run:t,previewToggle:n}){let r=Ut(t);return e&&(n||r)?(0,X.jsxs)(`div`,{"data-slot":`run-mobile-actions`,className:`flex flex-wrap items-center gap-2 pt-2`,children:[n,(0,X.jsx)($,{run:t})]}):null}function cn({isDesktop:e,phoneBar:t,run:n,previewToggle:r,mobileActivitySlot:a}){let o=Ut(n);if(e||!a)return null;let s=t&&(!!r||o);return(0,X.jsxs)(`div`,{"data-slot":s?`run-mobile-actions`:void 0,"data-mobile-session-bar":t||void 0,className:i(`flex flex-wrap items-center gap-2 md:hidden`,t&&`border-t border-border py-1`),children:[a,s?(0,X.jsxs)(`span`,{className:`ms-auto flex shrink-0 flex-wrap items-center gap-2`,children:[r,(0,X.jsx)($,{run:n})]}):null]})}function ln({run:e,tab:t,activeItem:n,inlineItemTabs:r,overflowItemTabs:a,phoneBar:o,isDesktop:s}){let c=(0,Y.useRef)(null),[l,u]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{let e=c.current;if(!e||s){u(!1);return}let t=()=>u(e.scrollWidth-e.clientWidth-e.scrollLeft>1),n=new ResizeObserver(t);n.observe(e);for(let t of e.children)n.observe(t);return e.addEventListener(`scroll`,t,{passive:!0}),t(),()=>{n.disconnect(),e.removeEventListener(`scroll`,t)}},[s,r,a,e.diffStat?.files]);let d=n?`${n.kind}#${n.number}`:null;return(0,Y.useEffect)(()=>{!d||s||c.current?.querySelector(`[aria-current="page"]`)?.scrollIntoView?.({block:`nearest`,inline:`nearest`})},[d,r.map(e=>`${e.kind}#${e.number}`).join(`,`),s]),(0,X.jsxs)(`div`,{ref:c,"data-slot":`run-tabs`,"data-phone-bar":o||void 0,"data-overflow-end":l||void 0,className:i(`flex flex-wrap items-end gap-1 border-b border-border md:mt-5 max-md:flex-nowrap max-md:overflow-x-auto max-md:border-b-0 max-md:shadow-[inset_0_-1px_0_var(--border)] max-md:gap-0 max-md:[&>*]:mb-0 max-md:[&>*]:shrink-0 max-md:[&>a]:min-h-11 max-md:[&>a]:px-2 max-md:[&>a]:text-[13.5px]`,o?`mt-0`:`mt-3`),children:[(0,X.jsx)(J,{to:`/tasks/${e.id}`,active:t===`session`,replace:o,children:`Session`}),(0,X.jsx)(J,{to:`/tasks/${e.id}/changes`,active:t===`changes`,replace:o,count:e.diffStat&&e.diffStat.files>0?e.diffStat.files:void 0,children:`Changes`}),(0,X.jsx)(J,{to:`/tasks/${e.id}/commits`,active:t===`commits`,replace:o,children:`Commits`}),(0,X.jsx)(J,{to:`/tasks/${e.id}/files`,active:t===`files`,replace:o,children:`Files`}),r.map(t=>(0,X.jsx)(J,{to:Xt(e.id,t),active:n!==null&&Jt(t,n),replace:o,children:(0,X.jsx)(Zt,{tab:t})},`${t.kind}-${t.number}`)),a.length>0?(0,X.jsxs)(I,{children:[(0,X.jsxs)(P,{"data-slot":`run-tabs-more`,"aria-label":`${a.length} more linked items`,className:`-mb-px flex h-8 items-center rounded-t-md border-b-2 border-transparent px-3 text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground max-md:min-h-11 max-md:px-3.5 max-md:text-[13.5px]`,children:[`+`,a.length]}),(0,X.jsx)(F,{align:`end`,children:a.map(t=>(0,X.jsx)(j,{asChild:!0,children:(0,X.jsx)(L,{to:Xt(e.id,t),replace:o,children:(0,X.jsx)(Zt,{tab:t})})},`${t.kind}-${t.number}`))})]}):null]})}function un({run:e,tab:t=`session`,onMarkedUnread:n,desktopActivitySlot:r,mobileActivitySlot:a}){let o=re(e),s=W(e),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(!1),f=dn(e,n),p=ee(),m=ne(),h=jt(e,{queuePosition:e.status===`queued`?qe(p.data??[]).get(e.id):void 0}),g=rt(),_=et(),v=g!==null&&!_?g:null,y=v!==null,{referenceProjectId:te,repoBase:b,requests:ie}=Pt(e),ae=(0,Y.useMemo)(()=>he(e,b),[e,b]),x=typeof t==`object`?t:null,{inline:oe,overflow:se}=Yt(ae,x),S=m.data?.capabilities?.preview===!0,C=e.worktreePath&&S?(0,X.jsx)($t,{servers:e.previewServers??[]}):null,w=(0,X.jsx)(hn,{run:e,actions:f,onOpenChooser:()=>d(!0),onToggleNotes:()=>l(e=>!e)}),ce=rn(e,s,_);return(0,X.jsx)(Me,{projectId:te,repoBase:b,requests:ie,children:(0,X.jsxs)(`header`,{"data-slot":`run-header`,"data-sticky":t===`session`||void 0,className:i(`relative z-20 shrink-0 bg-background px-4 md:px-9 md:pt-7`,y?`pt-0`:`pt-[18px]`,t===`session`&&`border-b border-border`),children:[(0,X.jsx)(on,{run:e}),(0,X.jsx)(kt,{run:e}),(0,X.jsxs)(`div`,{className:`w-full`,children:[(0,X.jsx)(tn,{run:e}),v?(0,X.jsxs)(Qe,{slot:v,children:[(0,X.jsx)(mn,{run:e,status:(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,X.jsx)(G,{"data-slot":`mobile-run-status`,dot:o.tone,shape:o.shape,pulse:o.pulse,className:`max-w-full self-start truncate px-2 py-px text-xs leading-4`,children:h.label}),(0,X.jsx)(an,{archived:e.archived,className:`px-2 py-px text-xs leading-4`})]})}),(0,X.jsx)(tn,{run:e,compact:!0}),w]}):(0,X.jsxs)(`div`,{"data-slot":`run-title-row`,className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 md:flex-nowrap`,children:[(0,X.jsx)(`p`,{"data-slot":`session-kind`,className:`text-[12px] font-semibold tracking-[0.14em] text-muted-foreground uppercase md:hidden`,children:en(e.delegation)}),(0,X.jsx)(pn,{run:e}),(0,X.jsx)(nn,{isDesktop:_,desktopActivitySlot:r,attention:o,statusLine:h}),(0,X.jsx)(an,{archived:e.archived,className:`max-md:hidden`}),(0,X.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 md:gap-2.5`,children:[ce,C,(0,X.jsx)($,{run:e}),w]})]}),(0,X.jsx)(sn,{shown:v!==null&&!a,run:e,previewToggle:C}),(0,X.jsx)(ln,{run:e,tab:t,activeItem:x,inlineItemTabs:oe,overflowItemTabs:se,phoneBar:y,isDesktop:_}),(0,X.jsx)(cn,{isDesktop:_,phoneBar:y,run:e,previewToggle:C,mobileActivitySlot:a}),c?(0,X.jsx)(vn,{runId:e.id,onClose:()=>l(!1)}):null,u?(0,X.jsx)(Rt,{run:e,canResume:W(e).terminal,onResume:()=>f.terminal.mutate(),onClose:()=>d(!1)}):null]}),(0,X.jsx)(_n,{run:e,actions:f})]})})}function dn(e,t){let n=se(),r=We(),[i,a]=(0,Y.useState)(null),o=()=>n.invalidateQueries({queryKey:f.runs.all}),l=e=>S(e.message,{tone:`danger`}),u=c(),d={isPending:u.isPending,mutate:()=>u.mutate({id:e.id,pinned:!e.pinned})},p=s();return{pin:d,markUnread:{isPending:p.isPending,mutate:()=>{t?.(),p.mutate(e.id,{onError:l})}},delete:m({mutationFn:()=>ce(e.id),onSuccess:()=>{o(),r(`/`)},onError:l}),terminal:Ft(e),confirming:i,setConfirming:a}}function fn(e){let t=o(e.id),n=R(e);return{title:n,editor:dt(n,e=>t.mutate({title:e},{onError:e=>S(e.message,{tone:`danger`})}))}}function pn({run:e}){let{title:t,editor:n}=fn(e);return n.editing?(0,X.jsx)(st,{editor:n,className:`flex-1 text-[16px] font-semibold`}):(0,X.jsxs)(`span`,{className:`group flex min-w-0 items-center gap-1`,children:[(0,X.jsx)(`h1`,{className:`line-clamp-2 min-w-0 break-words text-2xl font-semibold tracking-tight`,title:e.task,children:t}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Rename task`,onClick:n.begin,className:`shrink-0 rounded-sm p-1 text-soft-foreground opacity-0 transition-opacity group-hover:opacity-100 hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,X.jsx)(ht,{className:`size-3.5`,"aria-hidden":`true`})})]})}function mn({run:e,status:t}){let{title:n,editor:r}=fn(e);return(0,X.jsxs)(Le,{open:r.editing,onOpenChange:e=>{e?r.begin():r.commit()},children:[(0,X.jsxs)(`div`,{"data-slot":`mobile-run-title`,className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`h1`,{className:`line-clamp-2 break-words text-[15px] leading-[18px] font-semibold text-foreground`,title:e.task,children:n}),t]}),(0,X.jsx)(Fe,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":`Rename task`,className:`flex size-11 shrink-0 items-center justify-center rounded-sm text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,X.jsx)(ht,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,X.jsx)(Ie,{align:`end`,className:`w-64 max-w-[calc(100vw-16px)] p-2`,onEscapeKeyDown:e=>{e.preventDefault(),r.cancel()},children:(0,X.jsx)(st,{editor:r,className:`text-[16px] font-semibold`})})]})}function hn({run:e,actions:t,onToggleNotes:n,onOpenChooser:r}){let i=W(e),a=K(e),s=et(),c=Ct(e.id),[l,u]=(0,Y.useState)(!1),d=o(e.id),f=(0,Y.useId)();return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Tt,{run:e,open:l,onOpenChange:u,onConfirm:()=>{c.mutate(!0),u(!1)}}),(0,X.jsxs)(I,{children:[(0,X.jsx)(P,{asChild:!0,children:(0,X.jsx)(k,{variant:`ghost`,size:`icon-sm`,className:`size-11`,"aria-label":`Run actions`,children:(0,X.jsx)(Te,{"aria-hidden":`true`})})}),(0,X.jsxs)(F,{align:`end`,"data-slot":`run-actions-menu`,className:`w-[270px] max-w-[calc(100vw-2rem)] p-3`,children:[(0,X.jsx)(A,{className:`px-2 py-3 text-[12px] font-normal text-muted-foreground`,children:`TASK ACTIONS`}),!s&&i.archive&&!e.archiveBlocker?(0,X.jsx)(j,{disabled:c.isPending,onSelect:()=>e.archived?c.mutate(!1):u(!0),children:wt(e)}):null,(0,X.jsxs)(j,{onSelect:n,children:[(0,X.jsx)(ct,{"aria-hidden":`true`}),` Notes / handoff`]}),(0,X.jsx)(Rt,{run:e,canResume:i.terminal,onResume:()=>t.terminal.mutate(),onOpen:r}),a?(0,X.jsxs)(j,{onSelect:()=>void Z(a,`Command copied to clipboard.`),children:[(0,X.jsx)(E,{"aria-hidden":`true`}),` Copy resume command`]}):null,i.markUnread?(0,X.jsxs)(j,{disabled:t.markUnread.isPending,onSelect:()=>t.markUnread.mutate(),children:[(0,X.jsx)(xt,{"aria-hidden":`true`}),` Mark unread`]}):null,i.pin?(0,X.jsxs)(N,{"data-slot":`pin-run`,className:`min-h-11`,checked:!!e.pinned,disabled:t.pin.isPending,onCheckedChange:()=>t.pin.mutate(),children:[e.pinned?(0,X.jsx)(St,{"aria-hidden":`true`}):(0,X.jsx)(Ce,{"aria-hidden":`true`}),e.pinned?`Unpin task`:`Pin task`]}):null,(0,X.jsx)(M,{}),(0,X.jsx)(A,{className:`text-xs text-muted-foreground`,children:`AFTER DONE`}),(0,X.jsx)(N,{"data-slot":`archive-when-done`,className:`min-h-11`,checked:e.archiveWhenDone===!0,disabled:d.isPending,onCheckedChange:e=>d.mutate({archiveWhenDone:e},{onError:e=>S(e.message,{tone:`danger`})}),children:`Archive when Done`}),(0,X.jsx)(N,{"data-slot":`auto-merge-pr`,className:`min-h-11`,checked:e.autoMergePr===!0,disabled:d.isPending,"aria-describedby":f,onCheckedChange:e=>d.mutate({autoMergePr:e},{onError:e=>S(e.message,{tone:`danger`})}),children:`Auto-merge PR`}),(0,X.jsx)(`p`,{id:f,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block:0.5rem]`,children:`After Done, auto-merge can mark a draft PR ready. It waits for current-head CI and GitHub rules. Merge comes before archive.`}),e.delegation?.role===`worker`?null:(0,X.jsx)(gn,{run:e,patch:d}),i.deleteRun?(0,X.jsx)(M,{}):null,i.deleteRun?(0,X.jsxs)(j,{variant:`destructive`,onSelect:()=>t.setConfirming(`delete`),children:[(0,X.jsx)(ve,{"aria-hidden":`true`}),` Delete task…`]}):null]})]})]})}function gn({run:e,patch:t}){let n=(0,Y.useId)(),r=(0,Y.useId)(),i=(0,Y.useId)(),a=e=>S(e.message,{tone:`danger`});return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{}),(0,X.jsx)(A,{className:`text-xs text-muted-foreground`,children:`TASK ACCESS`}),(0,X.jsx)(N,{"data-slot":`allow-workers`,className:`min-h-11`,checked:oe(e),disabled:t.isPending,"aria-describedby":`${n} ${i}`,onCheckedChange:e=>t.mutate({allowWorkers:e},{onError:a}),children:`Allow Squawk workers`}),(0,X.jsx)(`p`,{id:n,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block-end:0.5rem]`,children:`Agents in this task can start Squawk workers. Each worker is a separate paid agent session. Worker limits cap resources, not spending.`}),(0,X.jsx)(N,{"data-slot":`allow-messaging`,className:`min-h-11`,checked:C(e),disabled:t.isPending,"aria-describedby":`${r} ${i}`,onCheckedChange:e=>t.mutate({allowMessaging:e},{onError:a}),children:`Allow task messaging`}),(0,X.jsx)(`p`,{id:r,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block-end:0.5rem]`,children:`Agents in this task can message other tasks in this project.`}),(0,X.jsx)(`p`,{id:i,"data-slot":`task-access-session-note`,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block-end:0.5rem]`,children:`Turning one off applies at once. Turning one on reaches a running agent at its next session.`})]})}function _n({run:e,actions:t}){let n=t.confirming;return(0,X.jsx)(nt,{open:n!==null,onOpenChange:e=>!e&&t.setConfirming(null),children:(0,X.jsxs)(it,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,X.jsxs)(pt,{children:[(0,X.jsx)(V,{className:`text-danger`,children:`Delete task permanently?`}),(0,X.jsx)(z,{children:(0,X.jsxs)(X.Fragment,{children:[`Delete “`,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,title:R(e),children:R(e)}),`” and its transcript`,e.delegation?.role===`worker`&&!le(e.delegation.workspace)?``:`, worktree and branch`,`. This cannot be undone.`]})})]}),(0,X.jsxs)(H,{children:[(0,X.jsx)(tt,{children:`Cancel`}),(0,X.jsx)(B,{className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{t.delete.mutate(),t.setConfirming(null)},children:`Delete task`})]})]})})}function vn({runId:e,onClose:t}){let n=y(e);return(0,X.jsxs)(`div`,{"data-slot":`notes-panel`,className:`my-5 flex max-h-[min(45dvh,420px)] flex-col overflow-hidden rounded-xl border border-border bg-card p-6`,children:[(0,X.jsxs)(`div`,{className:`mb-4 flex shrink-0 items-center justify-between gap-3`,children:[(0,X.jsx)(`h2`,{className:`text-lg font-medium`,children:`Notes / handoff`}),(0,X.jsx)(k,{variant:`ghost`,size:`icon`,"aria-label":`Close notes`,onClick:t,children:(0,X.jsx)(ye,{})})]}),(0,X.jsx)(`div`,{"data-slot":`notes-panel-body`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:n.isPending?(0,X.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`Loading notes…`}):n.isError?(0,X.jsx)(`p`,{className:`text-xs text-danger`,children:n.error.message}):n.data.trim().length>0?(0,X.jsx)(yt,{runId:e,children:(0,X.jsx)(_t,{children:n.data})}):(0,X.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`No notes yet — the handoff file is seeded when the task starts.`})}),(0,X.jsxs)(`div`,{className:`mt-4 flex shrink-0 gap-3`,children:[(0,X.jsx)(k,{variant:`outline`,disabled:!n.data?.trim(),onClick:()=>void Z(n.data??``,`Notes copied`),children:`Copy notes`}),(0,X.jsx)(k,{variant:`outline`,onClick:t,children:`Close`})]})]})}export{Ft as a,Lt as i,zt as n,Pt as o,Bt as r,jt as s,un as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ft as r,It as i,Mt as a,St as o,gt as s,kt as c}from"./queries-EvENG6TN.js";import{Cn as l,Dn as u,On as d,Sn as f,n as p,wn as m}from"./toaster-Cer2NOxt.js";import{n as h,p as g,r as _}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{l as v,u as y}from"./design-icons-CzEoMH9c.js";import{t as b}from"./plus-CxRU2X8C.js";import{t as x}from"./button-B7MKxYjT.js";import{n as ee,r as S,t as C}from"./collapsible-BEV4FO-1.js";import{t as w}from"./switch-DKqVf8-p.js";import{t as T}from"./badge-DQ3U69Ht.js";import{n as E,s as D,t as O}from"./project-router-BypHPat0.js";import"./attention-wzzAdp4t.js";import{a as k,l as te}from"./page-shell-7pLJMOgh.js";import{Kn as ne,R as re,Xn as A,dt as j,fn as M,ft as N,ut as ie}from"./index-8eoz1i7-.js";import{t as ae}from"./textarea-vJt9undk.js";import{n as oe,t as se}from"./saved-draft-BwzBc-_Y.js";import{ArchiveOnMergeField as ce}from"./archive-on-merge-field-Bzuu6JUq.js";import{a as le,i as ue,n as de,t as fe}from"./projects-section-Brds9YmD.js";import{n as P}from"./settings-field-DP9sYv5a.js";import{t as pe}from"./project-location-CVu4xirj.js";var F=e(t(),1),I={"needs-you":{label:`Needs you`,hint:`Asks a question, asks for permission, or waits for review`},failed:{label:`Failed`,hint:`Failed, with no scheduled resume`},done:{label:`Done`,hint:`Finished`},cancelled:{label:`Cancelled`,hint:`Was cancelled`},running:{label:`Running`,hint:`Runs an agent turn`},"waiting-workers":{label:`Waiting for agents`,hint:`Waits on its workers or their replies`},"waiting-ci":{label:`Waiting on CI`,hint:`Waits on a pull request's checks`},"waiting-timer":{label:`Waiting`,hint:`Waits on a timer`},"waiting-other":{label:`Any other wait`,hint:`Waits on anything else, including wait types added later`}},L=(e,t)=>e.length===t.length&&e.every(e=>t.includes(e)),R={name:``,description:``,url:``,token:``,tasks:!0,triggers:u,agent:!1};function z(e){return{name:e.name,description:e.description??``,url:e.url,token:``,tasks:e.tasks,triggers:e.triggers??u,agent:e.agent}}var B=e=>d.filter(t=>e.includes(t));function me(e){let t=e.description.trim();return{name:e.name.trim(),url:e.url.trim(),...t?{description:t}:{},...e.token?{token:e.token}:{},tasks:e.tasks,...L(e.triggers,u)?{}:{triggers:B(e.triggers)},agent:e.agent}}function he(e){return e.name.trim()!==``||e.description.trim()!==``||e.url.trim()!==``||e.token!==``||e.tasks!==R.tasks||e.agent!==R.agent||!L(e.triggers,R.triggers)}function ge(e,t){let n={},r=e.name.trim(),i=e.description.trim(),a=e.url.trim();return r!==t.name&&(n.name=r),i!==(t.description??``)&&(n.description=i),a!==t.url&&(n.url=a),e.token&&(n.token=e.token),e.tasks!==t.tasks&&(n.tasks=e.tasks),L(e.triggers,t.triggers??u)||(n.triggers=B(e.triggers)),e.agent!==t.agent&&(n.agent=e.agent),n}var V=n(),H=`flex flex-col gap-1 text-[13px]`,U=`text-xs text-muted-foreground`;function W({draft:e,onChange:t,tokenSet:n}){let r=(0,F.useId)(),i=(0,F.useId)(),a=(0,F.useId)(),o=(0,F.useId)(),s=(0,F.useId)(),c=(0,F.useId)(),u=(0,F.useId)(),p=(0,F.useId)(),h=(0,F.useId)(),g=(0,F.useId)();return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,14rem),1fr))] gap-3`,children:[(0,V.jsxs)(`div`,{className:H,children:[(0,V.jsx)(`label`,{htmlFor:r,className:U,children:`Name`}),(0,V.jsx)(A,{id:r,"data-slot":`webhook-name`,autoComplete:`off`,maxLength:80,placeholder:`e.g. Team bot`,value:e.name,onChange:e=>t({name:e.target.value})})]}),(0,V.jsxs)(`div`,{className:H,children:[(0,V.jsx)(`label`,{htmlFor:o,className:U,children:`URL`}),(0,V.jsx)(A,{id:o,"data-slot":`webhook-url`,type:`url`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,maxLength:m,placeholder:`https://bot.example/hooks/cez`,value:e.url,onChange:e=>t({url:e.target.value})})]})]}),(0,V.jsxs)(`div`,{className:H,children:[(0,V.jsx)(`label`,{htmlFor:i,className:U,children:`Description`}),(0,V.jsx)(ae,{id:i,"data-slot":`webhook-description`,"aria-describedby":a,rows:2,maxLength:f,placeholder:`e.g. Posts to the #releases channel. Use it for release notes.`,value:e.description,onChange:e=>t({description:e.target.value})}),(0,V.jsx)(`span`,{id:a,className:`text-xs text-soft-foreground`,children:`Agents read the name and description to decide when to use this webhook.`})]}),(0,V.jsxs)(`div`,{className:H,children:[(0,V.jsx)(`label`,{htmlFor:s,className:U,children:`Token`}),(0,V.jsx)(A,{id:s,"data-slot":`webhook-token`,type:`password`,autoComplete:`new-password`,spellCheck:!1,maxLength:l,"aria-describedby":c,placeholder:n?`Token set — type to replace`:`Optional Bearer token`,value:e.token,onChange:e=>t({token:e.target.value})}),(0,V.jsx)(`span`,{id:c,className:`text-xs text-soft-foreground`,children:n?`The token is stored in ~/.cezar and never shown again. Leave it empty to keep it.`:`The token is stored in ~/.cezar, never in the repo. It is sent as a Bearer header.`})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,V.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3`,children:[(0,V.jsx)(w,{id:u,"aria-describedby":p,"data-slot":`webhook-tasks`,checked:e.tasks,onCheckedChange:e=>t({tasks:e})}),(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-col text-[13px]`,children:[(0,V.jsx)(`label`,{htmlFor:u,className:`font-medium`,children:`Task notifications`}),(0,V.jsx)(`span`,{id:p,className:`text-xs text-soft-foreground`,children:`Tasks you hand off, or start with notify on, send their status here.`})]})]}),e.tasks?(0,V.jsxs)(`fieldset`,{"data-slot":`webhook-triggers`,className:`flex flex-col gap-1 sm:ps-[3.25rem]`,children:[(0,V.jsx)(`legend`,{className:`pbe-1 text-xs text-muted-foreground`,children:`Send a delivery when a task enters`}),(0,V.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-x-3`,children:d.map(n=>(0,V.jsxs)(`label`,{className:`flex min-h-11 items-start gap-2.5 pbs-2 text-[13px]`,children:[(0,V.jsx)(`input`,{type:`checkbox`,"data-trigger":n,checked:e.triggers.includes(n),onChange:r=>t({triggers:r.target.checked?[...e.triggers,n]:e.triggers.filter(e=>e!==n)}),className:`mbs-0.5 size-[18px] shrink-0`}),(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,V.jsx)(`span`,{className:`font-medium`,children:I[n].label}),(0,V.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:I[n].hint})]})]},n))}),(0,V.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`Handing a task off and Send test always deliver.`})]}):null]}),(0,V.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3`,children:[(0,V.jsx)(w,{id:h,"aria-describedby":g,"data-slot":`webhook-agent`,checked:e.agent,onCheckedChange:e=>t({agent:e})}),(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-col text-[13px]`,children:[(0,V.jsx)(`label`,{htmlFor:h,className:`font-medium`,children:`Let agents send reports`}),(0,V.jsx)(`span`,{id:g,className:`text-xs text-soft-foreground`,children:`Agents in this project may post a report here when the task calls for it.`})]})]})]})}var G=`max-sm:h-11`,K=(e,t)=>({tone:`alert`,text:`Not saved: ${e.message}. Fix the field and select ${t} again.`}),_e=e=>e.dryRun?{tone:`ok`,text:`Dry run: nothing was sent.`}:e.ok?{tone:`ok`,text:`Delivered (HTTP ${e.status??200}).`}:{tone:`danger`,text:`Not delivered: ${e.error??`unknown error`}.`};function q({feedback:e}){return e?(0,V.jsx)(`p`,{"data-slot":e.tone===`alert`?`webhook-error`:`webhook-result`,role:e.tone===`alert`?`alert`:`status`,className:e.tone===`ok`?`text-[13px] text-muted-foreground`:`text-[13px] text-danger`,children:e.text}):null}var J=`rounded-md border border-border bg-background`,Y=`flex flex-col gap-3 border-bs border-border p-3`;function ve({projectId:e,webhook:t,defaultOpen:n=!1}){let i=r(),o=c(),s=a(),[l,u]=(0,F.useState)(n),[d,f]=oe(z(t),se),[m,h]=(0,F.useState)(null),g=ge(d,t),_=Object.keys(g).length>0;M(_);let y=d.name.trim()!==``&&d.url.trim()!==``,b=i.isPending||o.isPending||s.isPending,w={projectId:e,webhookId:t.id},E=e=>i.mutate({...w,...g},{onSuccess:()=>{f(e=>({...e,token:``})),e?e():p(`${d.name.trim()} saved`)},onError:e=>h(K(e,`Save`))}),D=()=>s.mutate(w,{onSuccess:e=>h(_e(e)),onError:e=>h({tone:`danger`,text:e.message})});return(0,V.jsx)(`li`,{"data-slot":`webhook-card`,"data-webhook-id":t.id,className:J,children:(0,V.jsxs)(C,{open:l,onOpenChange:u,children:[(0,V.jsx)(S,{asChild:!0,children:(0,V.jsxs)(`button`,{type:`button`,"data-action":`webhook-toggle`,className:`group flex min-h-11 w-full items-center gap-3 rounded-md p-3 text-start focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-foreground pointer-hover:bg-muted/50 active:bg-muted/50`,children:[(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,V.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,V.jsx)(`span`,{"data-slot":`webhook-card-name`,className:`min-w-0 break-words text-[13px] font-medium`,children:t.name}),t.tasks?(0,V.jsx)(T,{variant:`secondary`,"data-badge":`tasks`,children:`Task notifications`}):null,t.agent?(0,V.jsx)(T,{variant:`secondary`,"data-badge":`agent`,children:`Agents`}):null]}),(0,V.jsx)(`span`,{"data-slot":`webhook-card-url`,className:`truncate text-[12px] text-muted-foreground`,children:re(t.url)})]}),(0,V.jsx)(v,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground group-data-[state=open]:rotate-180`})]})}),(0,V.jsx)(ee,{children:(0,V.jsxs)(`form`,{"data-slot":`webhook-form`,"data-reports-dirty":``,className:Y,onSubmit:e=>{e.preventDefault(),h(null),y&&_&&E()},children:[(0,V.jsx)(W,{draft:d,tokenSet:t.tokenSet,onChange:e=>f(t=>({...t,...e}))}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(x,{type:`submit`,size:`sm`,className:G,"data-action":`webhook-save`,disabled:b||!y||!_,children:`Save`}),(0,V.jsx)(x,{type:`button`,size:`sm`,className:G,variant:`outline`,"data-action":`webhook-test`,disabled:b||!y,onClick:()=>{h(null),_?E(D):D()},children:`Send test`}),t.tokenSet?(0,V.jsx)(x,{type:`button`,size:`sm`,className:G,variant:`ghost`,"data-action":`webhook-clear-token`,disabled:b,onClick:()=>i.mutate({...w,token:``},{onSuccess:()=>p(`Webhook token cleared`),onError:e=>h({tone:`danger`,text:`Token not cleared: ${e.message}.`})}),children:`Clear token`}):null,(0,V.jsx)(x,{type:`button`,size:`sm`,className:G,variant:`danger-ghost`,"data-action":`webhook-remove`,"aria-label":`Remove ${t.name}`,disabled:b,onClick:()=>o.mutate(w,{onSuccess:()=>p(`${t.name} removed`),onError:e=>h({tone:`danger`,text:`Not removed: ${e.message}.`})}),children:`Remove`})]}),(0,V.jsx)(q,{feedback:m})]})})]})})}function ye({projectId:e,onCreated:t,onCancel:n}){let r=s(),[i,a]=(0,F.useState)(R),[o,c]=(0,F.useState)(null),l=i.name.trim()!==``&&i.url.trim()!==``;return M(he(i)),(0,V.jsxs)(`li`,{"data-slot":`webhook-card`,"data-draft":``,className:J,children:[(0,V.jsx)(`p`,{className:`p-3 text-[13px] font-medium`,children:`New webhook`}),(0,V.jsxs)(`form`,{"data-slot":`webhook-form`,"data-reports-dirty":``,"aria-label":`New webhook`,className:Y,onSubmit:n=>{n.preventDefault(),c(null),l&&r.mutate({projectId:e,...me(i)},{onSuccess:({webhook:e})=>{p(`${e.name} created`),t(e)},onError:e=>c(K(e,`Create`))})},children:[(0,V.jsx)(W,{draft:i,tokenSet:!1,onChange:e=>a(t=>({...t,...e}))}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(x,{type:`submit`,size:`sm`,className:G,"data-action":`webhook-create`,disabled:r.isPending||!l,children:`Create`}),(0,V.jsx)(x,{type:`button`,size:`sm`,className:G,variant:`ghost`,"data-action":`webhook-cancel`,disabled:r.isPending,onClick:n,children:`Cancel`})]}),(0,V.jsx)(q,{feedback:o})]})]})}function be({project:e}){let t=e.webhooks??[],[n,r]=(0,F.useState)(!1),[i,a]=(0,F.useState)(null),o=t.length>=16;return(0,V.jsx)(P,{title:`Webhooks`,hint:`A webhook gets a POST from Squawk. Tasks can send their status to it, and agents can send it reports.`,children:(0,V.jsxs)(`div`,{"data-slot":`project-webhooks`,className:`flex flex-col gap-3`,children:[t.length===0&&!n?(0,V.jsx)(`p`,{"data-slot":`webhooks-empty`,className:`text-[13px] text-soft-foreground`,children:`No webhooks yet. Add one to send task updates to a bot, or to let agents post reports.`}):null,t.length>0||n?(0,V.jsxs)(`ul`,{className:`flex flex-col gap-2`,children:[t.map(t=>(0,V.jsx)(ve,{projectId:e.id,webhook:t,defaultOpen:t.id===i},t.id)),n?(0,V.jsx)(ye,{projectId:e.id,onCancel:()=>r(!1),onCreated:e=>{a(e.id),r(!1)}}):null]}):null,n?null:(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsxs)(x,{type:`button`,size:`sm`,variant:`outline`,className:`max-sm:h-11`,"data-action":`webhook-add`,disabled:o,onClick:()=>r(!0),children:[(0,V.jsx)(b,{"aria-hidden":`true`}),`Add webhook`]}),o?(0,V.jsxs)(`span`,{className:`text-xs text-soft-foreground`,children:[`A project holds at most `,16,` webhooks.`]}):null]})]})})}function X(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}function xe(){let e=D(),t=o(),n=i();if(t.isPending)return(0,V.jsx)(`p`,{"data-slot":`project-general-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading project…`});if(t.isError)return(0,V.jsxs)(`p`,{"data-slot":`project-general-error`,className:`text-[13px] text-danger`,children:[`Could not read the project registry — `,t.error.message]});let r=t.data,a=r?.projects.find(t=>t.id===e);return!r||!a?null:(0,V.jsxs)(`div`,{"data-slot":`project-general`,className:`flex w-full flex-col gap-5`,children:[(0,V.jsxs)(`section`,{className:`flex flex-col gap-5 rounded-lg border border-border bg-card p-5 [&_select]:min-h-11 [&_select]:w-full`,children:[(0,V.jsx)(`h2`,{className:`text-lg font-semibold`,children:`General`}),(0,V.jsx)(pe,{}),(0,V.jsx)(Se,{project:a}),(0,V.jsx)(P,{title:`Max parallel tasks`,hint:n.data?`The workspace limit (${n.data.resources.maxParallel}) still applies as an overall ceiling.`:`How many of this project's tasks may run at once. The workspace limit still applies as an overall ceiling.`,children:n.data?(0,V.jsx)(fe,{project:a,workspaceMax:n.data.resources.maxParallel}):(0,V.jsx)(`p`,{className:`text-[13px] text-soft-foreground`,children:`Loading the workspace limit…`})}),(0,V.jsx)(be,{project:a},a.id)]}),(0,V.jsx)(`section`,{className:`rounded-lg border border-border bg-card p-5`,children:(0,V.jsx)(Z,{project:a,bootProject:r.bootProject})})]})}function Se({project:e}){return(0,V.jsxs)(`dl`,{"data-slot":`project-facts`,className:`grid grid-cols-1 gap-4 text-[13px] sm:grid-cols-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Project`}),(0,V.jsx)(`dd`,{className:`mt-1 font-medium`,children:e.name})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Branch`}),(0,V.jsx)(`dd`,{className:`mt-1 break-all`,children:e.branch??`—`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Status`}),(0,V.jsxs)(`dd`,{"data-slot":`project-general-status`,className:e.status===`missing`?`mt-1 text-danger`:`mt-1`,children:[de[e.status],e.status===`missing`?` — remove it below, or restore the folder`:null]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Added`}),(0,V.jsxs)(`dd`,{className:`mt-1`,children:[X(e.addedAt),(0,V.jsx)(`span`,{className:`text-soft-foreground`,children:e.source===`checkout`?` · cloned from GitHub`:` · opened locally`})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Last opened`}),(0,V.jsx)(`dd`,{className:`mt-1`,children:X(e.lastOpenedAt)})]})]})}function Z({project:e,bootProject:t}){let[n,r]=(0,F.useState)(null),i=le(),a=g(),o=e.id===t;return(0,V.jsxs)(P,{title:`Remove from workspace`,hint:`Unregisters this project so it leaves the sidebar and the project list. Nothing on disk is deleted — the folder, its git history and its task history all stay, and opening it again re-registers it.`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsxs)(x,{type:`button`,variant:`outline`,size:`sm`,"data-action":`project-general-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:o?`Squawk is serving this project — it re-registers itself at every start`:void 0,disabled:o||i.isPending,onClick:()=>r(e),className:`text-danger`,children:[`Remove `,e.name]}),o?(0,V.jsx)(`span`,{"data-slot":`project-general-remove-boot`,className:`text-xs text-soft-foreground`,children:`Squawk is serving this project — it re-registers itself at every start.`}):null]}),(0,V.jsx)(ue,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{r(null),i.confirm(e,()=>void a(`/p/${encodeURIComponent(t)}`))}})]})}function Ce(e){return e===`global`?{Link:h,NavLink:_}:{Link:O,NavLink:E}}function Q({scope:e,title:t,mobileTitle:n,description:r}){let i=ne().name,a=e===`global`?`every project`:i??`this project`;return{headerSlot:`settings-main-header`,title:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`md:hidden`,children:n}),(0,V.jsxs)(`span`,{className:`max-md:hidden`,children:[t,` `,(0,V.jsxs)(`span`,{"data-slot":`page-header-scope`,className:`font-normal text-soft-foreground`,children:[`· `,a]})]})]}),subtitle:r,hideSubtitleOnMobile:!0,headerExtra:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{"data-slot":`settings-mobile-scope`,className:`mt-1 text-[13px] text-muted-foreground md:hidden`,children:e===`global`?`Applies to every project`:a}),e===`global`?(0,V.jsx)(`span`,{"data-slot":`settings-scope-chip`,className:`sr-only`,children:`Global settings`}):null]})}}function $({scope:e,activeId:t}){let{NavLink:n}=Ce(e),r=N(e);return(0,V.jsxs)(`details`,{className:`settings-section-picker md:hidden`,children:[(0,V.jsxs)(`summary`,{children:[r.find(e=>e.id===t)?.title??`General`,(0,V.jsx)(v,{"aria-hidden":`true`,className:`size-5 text-muted-foreground`})]}),(0,V.jsxs)(`nav`,{"aria-label":`Settings sections`,"data-slot":`settings-nav-mobile`,"data-scope":e,children:[e===`project`?(0,V.jsx)(n,{to:`/settings`,end:!0,"data-slot":`settings-nav-index`,children:`General`}):null,r.map(t=>(0,V.jsx)(n,{to:j(e,t.id),"data-section":t.id,children:t.title},t.id))]})]},`${e}-${t}`)}function we({section:e,scope:t}){let n=e.component,r=Q({scope:t,title:e.title,description:e.description,mobileTitle:t===`global`?`Global settings`:`Project settings`});return(0,V.jsx)(e.id===`agent-config`?te:k,{route:t===`global`?`settings-global-${e.id}`:`settings-${e.id}`,density:`full`,className:`settings-route`,header:r,children:(0,V.jsxs)(`div`,{className:`settings-route-body flex min-w-0 flex-1 flex-col md:flex-row`,children:[(0,V.jsxs)(`div`,{"data-slot":`settings-mobile-section`,className:`flex flex-col gap-2 md:hidden`,children:[(0,V.jsx)($,{scope:t,activeId:e.id}),e.description?(0,V.jsx)(`p`,{"data-slot":`settings-mobile-section-subtitle`,className:`px-1 text-[13px] leading-normal text-muted-foreground`,children:e.description}):null]}),(0,V.jsxs)(`section`,{className:`settings-panel min-w-0 self-start md:flex-1`,"aria-label":e.title,children:[(0,V.jsx)(`h2`,{className:`settings-panel-title sr-only`,children:e.title}),(0,V.jsx)(n,{})]})]})})}function Te(){return(0,V.jsx)(k,{route:`settings`,density:`full`,className:`settings-route`,header:Q({scope:`project`,title:`General`,mobileTitle:`Project settings`}),children:(0,V.jsxs)(`div`,{className:`settings-route-body flex min-w-0 flex-1 flex-col md:flex-row`,children:[(0,V.jsx)($,{scope:`project`,activeId:null}),(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-5`,children:[(0,V.jsx)(xe,{}),(0,V.jsx)(`section`,{className:`rounded-lg border border-card-edge bg-card p-5 shadow-card`,children:(0,V.jsx)(ce,{})}),(0,V.jsx)(`h2`,{className:`settings-other-title mt-6 rounded-t-lg border border-b-0 border-card-edge bg-card px-5 pt-5 text-base font-semibold shadow-card md:hidden`,children:`Other project settings`}),(0,V.jsx)(`ul`,{"data-slot":`settings-index`,className:`mt-7 flex w-full flex-col gap-5 md:hidden`,children:N(`project`).map(e=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(O,{to:j(`project`,e.id),"data-section":e.id,className:`flex items-center gap-3.5 rounded-lg border border-card-edge bg-card p-4 shadow-card transition-colors hover:bg-card-2`,children:[(0,V.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center text-accent-text`,children:(0,V.jsx)(e.icon,{"aria-hidden":`true`,className:`size-4`})}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:e.title}),(0,V.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description})]}),(0,V.jsx)(y,{"aria-hidden":`true`,className:`size-4 shrink-0 text-soft-foreground`})]})},e.id))}),(0,V.jsxs)(`p`,{className:`mt-5 w-full text-[12px] text-soft-foreground`,children:[`Appearance, notifications, host resources and the project registry live in`,` `,(0,V.jsx)(h,{to:ie,"data-slot":`settings-global-link`,className:`underline underline-offset-2 hover:text-foreground`,children:`Global settings`}),`.`]})]})]})})}export{Te as SettingsIndexRoute,we as SettingsSectionRoute};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{C as i,Wt as a,X as o,Y as s,dn as c,yt as l}from"./queries-EvENG6TN.js";import{Bt as u,Fn as d,Ft as f,Ht as p,Lt as m,Tt as h,at as g,ct as _,hi as v,n as y,tr as b}from"./toaster-Cer2NOxt.js";import{h as x}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{C as S,j as C,l as w}from"./design-icons-CzEoMH9c.js";import{t as T}from"./run-header-CP_2QY0H.js";import{i as E,n as D,r as ee}from"./git-toolbar-ywLSmnxR.js";import{t as O}from"./button-B7MKxYjT.js";import{a as k,i as A,o as j,r as M,s as N,t as P}from"./dialog-B531GGAo.js";import{b as F,f as I}from"./task-groups-nvRvmVHf.js";import{c as L,d as R}from"./page-shell-7pLJMOgh.js";import{t as z}from"./centered-state-V15AR_qo.js";import{C as B,Nn as V,S as H,Xt as U,Y as W,in as G}from"./index-8eoz1i7-.js";import{t as K}from"./markdown-BBDDg-4t.js";import{t as q}from"./textarea-vJt9undk.js";import{t as J}from"./diff-eTwHyNBm.js";var Y=e(t(),1),X=`no worktree — this task ran directly in the repo working tree`;function Z(e){let t=e=>({id:`commit`,label:`Commit`,enabled:!1,reason:e});return e.hasWorktree?e.run.status===`running`?t(`Commit unavailable — the agent is still working in this worktree`):e.changedFiles===void 0?t(`Commit unavailable — changes are still loading`):e.changedFiles===0?t(`Commit unavailable — no changes to commit`):{id:`commit`,label:`Commit`,enabled:!0}:t(`Commit unavailable — ${X}`)}function Q(e){let t=e=>({id:`push`,label:`Push`,enabled:!1,reason:e});return e.hasWorktree?e.remote===void 0?t(`Push unavailable — no remote configured`):e.branch===void 0?t(`Push unavailable — the run has no branch to push`):e.run.status===`running`?t(`Push unavailable — the agent is still working in this worktree`):{id:`push`,label:`Push`,enabled:!0}:t(`Push unavailable — ${X}`)}function te(e){let t=e=>({id:`create-pr`,label:`Draft PR`,enabled:!1,reason:e});return!e.hasWorktree||e.branch===void 0?t(`Draft PR unavailable — ${X}`):e.forge===null?t(`Draft PR unavailable — no supported forge remote (GitHub) detected`):e.forge.available?b(e.run)?t(`Draft PR unavailable — the run is waiting on a usage-limit hold; choose Don’t resume first`):F(e.run)?t(`Draft PR unavailable — the run is still active; wait for the review gate`):{id:`create-pr`,label:`Draft PR`,enabled:!0}:t(`Draft PR unavailable — ${e.forge.reason??`the forge is unreachable`}`)}function ne(e){let t=e.prUrl?{id:`view-pr`,label:`View PR`,enabled:!0,href:e.prUrl}:Z(e),n=e.prUrl?[Z(e),Q(e)]:[Q(e),te(e)],r=[];if(e.localHandoff&&e.cliHandoff!==!1){let t=e.hasSession?F(e.run)?{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — the session is still active in the engine`}:{id:`open-terminal`,label:`Open in terminal`,enabled:!0}:{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — no agent session to resume`};r.push(t)}return{primary:t,secondary:n,menu:r}}var $=n();function re({run:e,open:t,onOpenChange:n}){let r=v(),[i,o]=(0,Y.useState)(``),s=I(e),l=(0,Y.useRef)(s);l.current=s,(0,Y.useEffect)(()=>{t&&o(l.current)},[t]);let u=c({mutationFn:t=>g(e.id,t),onSuccess:t=>{y(`Committed ${V(t.sha)}`),n(!1),r.invalidateQueries({queryKey:a.runs.changes(e.id)}),r.invalidateQueries({queryKey:a.runs.all})},onError:e=>y(e.message,{tone:`danger`})}),d=()=>{let e=i.trim();e.length===0||u.isPending||u.mutate(e)};return(0,$.jsx)(P,{open:t,onOpenChange:n,children:(0,$.jsxs)(M,{"data-slot":`commit-dialog`,children:[(0,$.jsxs)(j,{children:[(0,$.jsx)(N,{children:`Commit changes`}),(0,$.jsxs)(A,{children:[`Stages everything in the task's worktree (git add -A) and commits to`,` `,e.branch?(0,$.jsx)(`span`,{className:`font-mono`,children:e.branch}):`its branch`,`.`]})]}),(0,$.jsx)(q,{"data-slot":`commit-message`,"aria-label":`Commit message`,rows:3,value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{W({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(),d())}}),(0,$.jsxs)(k,{children:[(0,$.jsx)(O,{variant:`outline`,onClick:()=>n(!1),children:`Cancel`}),(0,$.jsx)(O,{"data-slot":`commit-confirm`,disabled:i.trim().length===0||u.isPending,onClick:d,children:u.isPending?`Committing…`:`Commit`})]})]})})}function ie(){let{id:e}=x(),t=s(e);return t.isPending?(0,$.jsx)(B,{tab:`changes`}):t.isError?(0,$.jsx)(H,{tab:`changes`,error:t.error}):(0,$.jsx)(ae,{run:t.data})}function ae({run:e}){let t=l(),n=i(),r=o(e.id,F(e)),s=U(),[p,h]=(0,Y.useState)(`unified`),[g,b]=(0,Y.useState)(!0),[x,S]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(null),[E,O]=(0,Y.useState)(!1),k=(0,Y.useRef)(null),A=v(),j=()=>A.invalidateQueries({queryKey:a.runs.all}),M=e=>y(e.message,{tone:`danger`}),N=c({mutationFn:()=>u(e.id),onSuccess:e=>y(e.upstreamSet?`Pushed ${e.branch} to ${e.remote} (upstream set)`:`Pushed ${e.branch} to ${e.remote}`),onError:M}),P=c({mutationFn:()=>_(e.id),onSuccess:e=>{y(`Draft PR created — ${e.url}`),j()},onError:M}),I=c({mutationFn:()=>m(e.id),onError:e=>{if(e instanceof d&&e.command){navigator.clipboard.writeText(e.command).then(()=>y(`No terminal found — command copied to clipboard.`)).catch(()=>y(`Run manually: ${e.command}`));return}M(e)}}),z=c({mutationFn:t=>f(e.id,t),onError:M}),B=r.isError&&r.error instanceof d&&r.error.status===409,V=ne({run:e,cliHandoff:e.cliHandoff,hasWorktree:!!e.worktreePath&&!B,branch:e.branch,changedFiles:r.data?.stat.files,remote:n.data?.info?.remote,forge:t.data?.forge??null,localHandoff:t.data?.capabilities.localHandoff??!1,hasSession:G(e)!==void 0,prUrl:e.pullRequestUrl}),H=e=>{switch(e){case`commit`:O(!0);break;case`push`:N.mutate();break;case`create-pr`:P.mutate();break;case`open-terminal`:I.mutate();break;case`view-pr`:break}},W=r.data?.files??[],q=(0,Y.useMemo)(()=>ee(W),[W]),J=(0,Y.useMemo)(()=>W.some(K),[W]),X=s?p:`unified`;return(0,$.jsxs)(L,{route:`task-changes`,density:R(W.length),flushPadding:!0,children:[(0,$.jsx)(T,{run:e,tab:`changes`}),(0,$.jsx)(D,{bar:V,healthReady:t.data!==void 0,branch:e.branch,stat:r.data?.stat,mode:X,wrap:g,preview:x,onModeChange:h,onWrapChange:b,onPreviewChange:J?S:void 0,onAction:H}),r.data?.repointedHead?(0,$.jsxs)(`p`,{"data-slot":`repointed-head-note`,className:`border-b px-4 py-2 text-xs text-soft-foreground md:px-9`,children:[`HEAD is on `,(0,$.jsx)(`code`,{children:r.data.repointedHead.headBranch}),`, not this task's branch`,` `,(0,$.jsx)(`code`,{children:r.data.repointedHead.taskBranch}),` — showing only what this task changed there.`]}):null,(0,$.jsx)(oe,{changes:r,changesRefused:B,fileCount:W.length,children:(0,$.jsx)(se,{runId:e.id,files:W,tree:q,selected:C,selectFile:e=>{w(e),k.current?.scrollToPath(e)},diffRef:k,effectiveMode:X,effectiveWrap:g,preview:x,localHandoff:t.data?.capabilities.localHandoff,onOpenInApp:z.mutate})}),(0,$.jsx)(re,{run:e,open:E,onOpenChange:O})]})}function oe({changes:e,changesRefused:t,fileCount:n,children:r}){return e.isPending?(0,$.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):e.isError?(0,$.jsx)(z,{icon:t?(0,$.jsx)(S,{size:16}):(0,$.jsx)(C,{size:16}),tone:t?`neutral`:`danger`,heading:`h2`,title:t?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):n===0?(0,$.jsx)(z,{icon:(0,$.jsx)(S,{size:16}),tone:`neutral`,heading:`h2`,title:`No changes yet`,subtitle:`The worktree matches its base branch. Changes appear here as the agent works.`}):r}function se({runId:e,files:t,tree:n,selected:i,selectFile:a,diffRef:o,effectiveMode:s,effectiveWrap:c,preview:l,localHandoff:u,onOpenInApp:d}){let[f,m]=(0,Y.useState)(!1);return(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-4 px-4 pb-9 pt-0 [--diff-sticky-top:0px] md:flex-row md:items-start md:gap-5 md:px-9`,children:[(0,$.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`w-full shrink-0 rounded-xl border border-border bg-card md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_2rem)] md:w-60 md:overflow-y-auto md:overscroll-contain md:p-3.5 lg:w-[288px]`,children:[(0,$.jsxs)(`button`,{type:`button`,"data-slot":`changes-tree-toggle`,"aria-expanded":f,onClick:()=>m(e=>!e),className:`flex min-h-11 w-full items-center justify-between gap-2 px-3.5 py-2 text-left text-xs font-semibold text-foreground md:hidden`,children:[(0,$.jsxs)(`span`,{children:[`Changed files`,` `,(0,$.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`(`,t.length,`)`]})]}),(0,$.jsx)(w,{size:16,"aria-hidden":`true`,className:r(`size-4 shrink-0 text-muted-foreground motion-safe:transition-transform`,f&&`rotate-180`)})]}),(0,$.jsx)(`h2`,{className:`mb-3 hidden border-b border-border pb-3 text-xs font-semibold md:block`,children:`Changed files`}),(0,$.jsx)(`div`,{className:r(f?`border-t border-border px-3.5 py-3 md:border-t-0 md:p-0`:`hidden md:block`),children:(0,$.jsx)(E,{root:n,selected:i,onSelect:e=>{a(e),m(!1)}})})]}),(0,$.jsx)(J,{files:t,viewRef:o,mode:s,wrap:c,preview:l,loadFileText:t=>ce(e,t),imageSrc:t=>p(e,t),onOpenInApp:u?e=>d(e):void 0,totals:!1,className:`min-w-0 flex-1`})]})}async function ce(e,t){try{let n=await h(e,t);return n.type!==`file`||n.binary||n.tooLarge?null:n.content??null}catch{return null}}export{ie as TaskChangesRoute};
@@ -1,4 +0,0 @@
1
- import{t as e}from"./react-runtime-CCIEwYL0.js";import{t}from"./utils-DSMR_WLb.js";import{gr as n,hr as r,ti as i}from"./toaster-Cer2NOxt.js";import{h as a,p as o,v as s}from"./live-protocol-DMhTnCmf.js";import{t as c}from"./createLucideIcon-BHp8sXmF.js";import{t as l}from"./app-window-CSHwDX9N.js";import{t as u}from"./play-CmVAj_fu.js";import{i as d,n as ee,o as te,r as ne}from"./tool-display-B9NN44oU.js";import{t as re}from"./square-terminal-B6RYYieR.js";import{t as ie}from"./button-B7MKxYjT.js";import{t as ae}from"./status-dot-BRzVlF2X.js";import{a as oe,o as se}from"./format-BU7D3IfE.js";import{ar as ce,f,p}from"./index-8eoz1i7-.js";var m=c(`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`}]]),h=e(),g={registered:e=>e.server.answeredAtRegistration?{label:`Open`,run:!1}:{label:`Run and open`,run:!0},adopted:()=>({label:`Open`,run:!1}),starting:()=>({label:`Open`,run:!1}),up:()=>({label:`Open`,run:!1}),stalled:()=>({label:`View`,run:!1}),exited:()=>({label:`Start again`,run:!0}),stopped:()=>({label:`Start again`,run:!0}),unavailable:()=>void 0};function _(e){let{text:t,...n}=p(e),r={...n,status:t},i=g[e.state](e);return i?{...r,action:i}:r}var v={"Run and open":u,Open:l,View:ce,"Start again":te};function y({entry:e,inPreview:n,onOpen:r}){let{server:i}=e,a=_(e),o=e.state===`unavailable`,s=r?a.action:void 0,c=f(i.command),l=oe(i.registeredAt);return(0,h.jsxs)(`div`,{"data-slot":`preview-server-card`,"data-state":e.state,className:t(`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,o&&`text-muted-foreground`),children:[(0,h.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 text-xs text-soft-foreground`,children:[(0,h.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 font-mono`,children:[(0,h.jsx)(m,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`truncate`,children:`cezar_preview_serve`})]}),o?(0,h.jsx)(`span`,{children:`worktree removed`}):l?(0,h.jsx)(`span`,{children:se(l)}):null]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-2`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,h.jsx)(ae,{tone:a.tone,shape:a.ring?`ring`:`filled`,pulse:a.pulse===!0,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`font-semibold text-foreground`,children:i.label}),(0,h.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,i.port]}),(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:a.status})]}),(0,h.jsx)(le,{entry:e,inPreview:n,action:s,onOpen:r})]}),(0,h.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,h.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:i.command}),i.cwd?(0,h.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,h.jsx)(`span`,{children:`cwd`}),(0,h.jsx)(`span`,{className:`break-all`,children:i.cwd})]}):null]}),s?.run?(0,h.jsx)(b,{icon:(0,h.jsx)(re,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),children:`${s.label===`Start again`?`Starting again`:`Opening`} runs ${c} in this task's worktree, on the host.`}):null,o?(0,h.jsx)(b,{children:`The worktree this server ran in is gone. Register it again from a new task.`}):null]})}function le({entry:e,inPreview:t,action:n,onOpen:r}){let{server:i}=e,a=t&&n!==void 0&&!n.run,o=a?`In preview`:n?.label,s=a?l:n?v[n.label]:null;return n&&o&&s?(0,h.jsxs)(ie,{variant:a||n.label===`View`||n.label===`Open`&&e.state===`starting`?`outline`:`contrast`,size:`sm`,className:`max-md:h-11 max-md:px-3.5`,onClick:()=>r?.({port:i.port,run:n.run}),children:[(0,h.jsx)(s,{"aria-hidden":`true`}),o]}):null}function b({icon:e,children:t}){return(0,h.jsxs)(`p`,{className:`mt-2.5 flex items-start gap-2 text-xs text-muted-foreground`,children:[e,(0,h.jsx)(`span`,{children:t})]})}function x(e,t){return e.kind===`message`&&e.role===`user`&&e.skillInput?.source===t&&typeof e.skillInput.id==`string`&&e.skillInput.id!==``}function ue(){return{turns:[],itemsById:new Map,turnSeq:0,eventSeq:0,permissions:new Map,conversationEntries:new Map,outcomesByRequest:new Map,seenInputs:new Set,previewByPort:new Map,handedOff:!1}}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function C(e){return typeof e==`string`?e:void 0}function w(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`,hourCycle:`h23`})}`}function T(e){if(!(typeof e!=`string`||e===``))return Number.isFinite(new Date(e).getTime())?e:void 0}function de(e){return i.safeParse(e).data}function E(e,t){e.turnSeq+=1;let n={id:t===void 0?`turn-fallback-${e.turnSeq}`:`turn-seq-${t}`,entries:[],v2Items:!1};return e.turns.push(n),n}function D(e){return e.turns.at(-1)??E(e)}function O(e,t){let n={origin:`meta`,entry:t,firstSeq:e.eventSeq,lastSeq:e.eventSeq};return D(e).entries.push(n),n}var k=[/^run failed\s+[—-]\s+/,/^continue failed(?:\s+[—-]\s+|:\s+)/,/^step\s+"[^"]+"\s+failed:\s+/,/^step\s+\S+\s+failed\s+[—-]\s+/],A=/^(?:run failed\s+[—-]\s+|continue failed(?:\s+[—-]\s+|:\s+))/;function j(e){return e.trim().replace(/\s+/g,` `)}function M(e){let t=e.trim(),n=!0;for(;n;){n=!1;for(let e of k){let r=t.replace(e,``).trim();r!==t&&r!==``&&(t=r,n=!0)}}return j(t)}function N(e,t,n){if(t===e.primarySource&&n===e.primaryText||e.draft.entry.kind!==`note`)return;let r=e.draft.entry;r.details?.some(e=>e.source===t&&e.text===n)||(r.details=[...r.details??[],{source:t,text:n}])}function P(e,t,n){let r=e.failures;if(r)for(let e=r.length-1;e>=0;--e){let i=r[e];if(t!==``&&i.cause===t||t===``&&i.fatal&&(n===void 0||i.stepId===void 0||i.stepId===n))return i}}function F(e,t,n){let r=D(e),i=P(r,n.cause,n.stepId);if(i){i.draft.lastSeq=Math.max(i.draft.lastSeq,t.seq),n.fatal&&(i.fatal=!0),n.stepId!==void 0&&i.stepId===void 0&&(i.stepId=n.stepId),N(i,n.source,n.text);return}let a={draft:O(e,{kind:`note`,id:n.id,text:n.text,tone:`danger`}),cause:n.cause,primarySource:n.source,primaryText:n.text,...n.stepId===void 0?{}:{stepId:n.stepId},fatal:n.fatal};r.failures=[...r.failures??[],a]}function I(e,t,n){if(!A.test(n))return!1;let r=e.turns.at(-1);if(!r)return!1;let i=M(n);if(i===``)return!1;let a=P(r,i,C(t.stepId));return a?(a.draft.lastSeq=Math.max(a.draft.lastSeq,t.seq),a.fatal=!0,N(a,`lifecycle`,n),!0):!1}function L(e,t,n){let r=e.turns.at(-1);if(!r)return;let i=P(r,n?M(n):``,C(t.stepId));i&&(i.fatal=!0)}function R(e){for(let t of e.permissions.values())t.status===`pending`&&(t.status=`expired`)}function z(e,t){let n=C(e.stepId);return n===void 0?t:`${n}:${t}`}function B(e,t){t.v2Items=!0;for(let n of t.entries)n.origin===`v1`&&n.entry.kind===`tool`&&e.itemsById.delete(n.entry.id);t.entries=t.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`tool`))}function V(e,t,n,r,i,a=!1){let o=n.kind===`message`&&i!==void 0?{...n,ts:i}:{...n};!t.v2Items&&o.kind!==`hook`&&B(e,t);let s=e.itemsById.get(r);if(s&&s.turn===t){s.entry.entry=o,s.entry.lastSeq=e.eventSeq,s.entry.streaming=a;return}let c={origin:`v2`,entry:o,firstSeq:e.eventSeq,lastSeq:e.eventSeq,streaming:a};t.entries.push(c),e.itemsById.set(r,{turn:t,entry:c})}var H={"not-delivered":0,queued:1,delivered:2,consumed:3},fe=[`instruction`,`resumed`,`requestId`,`relationship`,`state`,`createdAt`,`requestHash`,`deadline`];function U(e){let t={};for(let n of fe)e[n]!==void 0&&Object.assign(t,{[n]:e[n]});return t}function W(e,t){if(t.messageKind!==`request`)return;let n=e.outcomesByRequest.get(t.messageId);n&&(t.outcome={status:n.status,...n.replyId===void 0?{}:{replyId:n.replyId},observedAt:n.observedAt})}function pe(e,t){let n=e.conversationEntries.get(t);n&&W(e,n)}function me(e,t,n,r){(H[e.delivery]<H.delivered||H[n]>H[e.delivery])&&(e.delivery=n),t.text!==``&&(e.text=t.text),Object.assign(e,U(t)),r.deliveredAt!==void 0&&(e.deliveredAt=r.deliveredAt),r.consumedAt!==void 0&&(e.consumedAt=r.consumedAt),r.recordedAt!==void 0&&(n===`delivered`||e.delivery!==`delivered`)&&(e.recordedAt=r.recordedAt)}function G(e,t,n,r){let i=e.conversationEntries.get(t.id);if(i){me(i,t,n,r),W(e,i);return}let a={kind:`conversation`,id:`conversation-message:${t.id}`,messageId:t.id,text:t.text,senderRunId:t.senderRunId,recipientRunId:t.recipientRunId,messageKind:t.kind,delivery:n,...r,...U(t)};W(e,a),e.conversationEntries.set(t.id,a),O(e,a)}function he(e,t){let n=w(t.ts),r=C(t.message),i=t.notify===!1?`Stopped notifying the webhook${n}`:`${e.handedOff?`Note sent to webhook`:`Handed off to webhook`}${n}${r?` — ${r}`:``}`;e.handedOff=t.notify!==!1,O(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`dim`,icon:`handoff`})}function ge(e,t){let n=typeof t.attempts==`number`?t.attempts:void 0,r=C(t.webhookName),i=`${r?`Delivery to ${r} failed`:`Webhook delivery failed`}${C(t.event)?` (${C(t.event)})`:``}${n?` after ${n} attempt${n===1?``:`s`}`:``}: ${C(t.error)??`unknown error`}`;O(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`danger`})}function _e(e,t){let n=C(t.webhookName)??`webhook`,r=C(t.title),i=`v1:${t.seq}`;if(t.ok===!1){O(e,{kind:`note`,id:i,text:`Report to ${n} failed: ${C(t.error)??`unknown error`}`,tone:`danger`});return}let a=`${t.dryRun===!0?`Report to ${n} (dry run, nothing sent)`:`Sent report to ${n}`}${w(t.ts)}${r?` — ${r}`:``}`;O(e,t.dryRun===!0?{kind:`note`,id:i,text:a,tone:`dim`}:{kind:`note`,id:i,text:a,tone:`dim`,icon:`handoff`})}function ve(e,t){let n=t.payload??{},r=`Webhook (dry run, nothing sent): ${C(t.event)??`delivery`}${C(n.status)?` · ${C(n.status)}`:``}`;O(e,{kind:`note`,id:`v1:${t.seq}`,text:r,tone:`dim`})}function ye(e,t){let n=r.safeParse(t.server);if(!n.success)return;let i=e.previewByPort.get(n.data.port);i&&(i.turn.entries=i.turn.entries.filter(e=>e!==i.draft));let a=D(e),o={origin:`meta`,firstSeq:t.seq,lastSeq:t.seq,entry:{kind:`preview-server`,id:`preview-server:${n.data.port}`,server:n.data,state:`registered`,stateAt:t.ts}};a.entries.push(o),e.previewByPort.set(n.data.port,{turn:a,draft:o})}function be(e,t){let r=n.safeParse(t.state),i=typeof t.port==`number`?e.previewByPort.get(t.port):void 0;if(!r.success||!i||i.draft.entry.kind!==`preview-server`)return;let{server:a,id:o}=i.draft.entry;i.draft.lastSeq=t.seq,i.draft.entry={kind:`preview-server`,id:o,server:a,state:r.data,stateAt:t.ts,...typeof t.exitCode==`number`?{exitCode:t.exitCode}:{},...t.reason===`user`||t.reason===`idle`?{reason:t.reason}:{}}}function xe(e,t){let n=a.safeParse(t);if(!n.success)return;let{message:r,delivery:i,deliveredAt:o,consumedAt:s,ts:c}=n.data;G(e,r,i,{deliveredAt:o,consumedAt:s,recordedAt:c})}function Se(e,t){let n=s.safeParse(t);if(!n.success)return;let{outcome:r}=n.data,i=e.outcomesByRequest.get(r.requestId);i&&!(i.status===`timed-out`&&r.status===`replied-late`)||(e.outcomesByRequest.set(r.requestId,r),pe(e,r.requestId))}function Ce(e,t){let n=o.safeParse(t);if(!n.success)return;let{input:r}=n.data;if(!e.seenInputs.has(r.id)){if(e.seenInputs.add(r.id),r.conversation){G(e,{id:r.id,text:r.text,createdAt:r.createdAt,...r.conversation},`delivered`,{deliveredAt:r.deliveredAt,recordedAt:n.data.ts});return}O(e,{kind:`note`,id:`agent-input:${r.id}`,text:r.text,tone:`dim`,attribution:{source:r.source,parentRunId:r.parentRunId}})}}function we(e,t){let n=C(t.text)??``,r=e.pendingAsk;e.pendingAsk&&!e.pendingAsk.resolved&&(e.pendingAsk.resolved=!0,e.pendingAsk.answeredBy=`human`,n!==``&&(e.pendingAsk.answer=n),e.pendingAsk=void 0);let i=E(e,t.seq),a=T(t.ts);i.userMessage={text:n,ask:r,imageCount:typeof t.imageCount==`number`?t.imageCount:0,images:Array.isArray(t.images)?t.images.filter(e=>typeof e==`string`):[],...a===void 0?{}:{ts:a}},a!==void 0&&(i.startedAt=a)}function Te(e,t){let n=e.turns.at(-1),r=n&&n.turnId===void 0&&!n.v2Items?n:E(e,t.seq);r.turnId=C(t.turnId),r.startedAt??=T(t.ts)}function Ee(e,t){for(let n=e.turns.length-1;n>=0;--n)if(e.turns[n].turnId===t)return e.turns[n];return e.turns.at(-1)}function De(e,t){R(e);let n=Ee(e,C(t.turnId));if(!n)return;let r=T(t.ts);n.completed={stopReason:C(t.stopReason)??`end_turn`,...typeof t.costUsd==`number`?{costUsd:t.costUsd}:{},...r===void 0?{}:{ts:r}}}var K=new Set([`message`,`reasoning`,`tool`,`hook`]),Oe=e=>K.has(e.kind);function ke(e){if(!(!S(e)||!K.has(e.kind)))return typeof e.id==`string`&&e.id!==``?e:void 0}function q(e,t){let n=ke(t.item);if(!n)return;let r=z(t,n.id),i=e.itemsById.get(r),a=t.type===`item.completed`,o=!a&&(n.kind===`message`||n.kind===`reasoning`);V(e,i?.turn??D(e),n,r,a?T(t.ts):void 0,o)}function Ae(e,t){let n=e.itemsById.get(z(t,C(t.itemId)??``)),r=C(t.delta)??``;if(!n||r===``||!Oe(n.entry.entry))return;let i=n.entry.entry;n.entry.lastSeq=t.seq,t.field===`output`&&i.kind===`tool`?i.output=(i.output??``)+r:t.field!==`output`&&(i.kind===`message`||i.kind===`reasoning`)&&(i.text+=r)}function je(e,t){let n=D(e),r=C(t.text)??``;if(r===``)return;let i=T(t.ts);n.entries.push({origin:`v1`,firstSeq:t.seq,lastSeq:t.seq,entry:{kind:`message`,id:`v1:${t.seq}`,role:`assistant`,text:r,...i===void 0?{}:{ts:i}}})}var Me=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function Ne(e){if(!S(e)||!Array.isArray(e.todos))return;let t=[];for(let n of e.todos){if(!S(n)||typeof n.content!=`string`)return;t.push({content:n.content,status:Me.has(n.status)?n.status:`pending`,...typeof n.activeForm==`string`?{activeForm:n.activeForm}:{}})}return t}var Pe=new Set([`subAgentActivity`,`collabAgentToolCall`,`collabToolCall`]);function Fe(e,t){let n=D(e),r=C(t.tool)??`Tool`;if(n.v2Items||Pe.has(r))return;let i=ee(r,t.input),a=i.toolKind===`plan`?Ne(t.input):void 0;a!==void 0&&(n.planEntries=a);let o={kind:`tool`,id:C(t.id)??`v1:${t.seq}`,name:r,toolKind:i.toolKind,title:i.title,status:`running`,input:t.input},s={origin:`v1`,entry:o,firstSeq:t.seq,lastSeq:t.seq};n.entries.push(s),e.itemsById.set(o.id,{turn:n,entry:s})}function Ie(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}}function Le(e,t){let n=e.itemsById.get(C(t.toolCallId)??``);if(!n||n.turn.v2Items||n.entry.origin!==`v1`)return;let r=n.entry.entry;r.kind===`tool`&&(n.entry.lastSeq=t.seq,r.status=`completed`,r.output=Ie(t.result))}function Re(e,t,n,r){let i=C(t.message)??``;i!==``&&O(e,{kind:`note`,id:n,text:i,tone:r})}function J(e,t){let n=C(t.message)??``;t.type===`lifecycle`&&n!==``&&I(e,t,n)||Re(e,t,`v1:${t.seq}`,t.tone===`danger`?`danger`:`dim`)}function ze(e,t){let n=C(t.message)??``;n!==``&&F(e,t,{id:`v1:${t.seq}`,source:`error`,text:n,cause:M(n),stepId:C(t.stepId),fatal:!1})}function Be(e,t){let n=C(t.message)??``;n!==``&&F(e,t,{id:`v2:${t.seq}`,source:`session.error`,text:n,cause:M(n),stepId:C(t.stepId),fatal:t.fatal===!0})}function Ve(e,t){if(t.status!==`failed`)return;let n=C(t.stepId),r=C(t.error),i=r?` — ${r}`:``;F(e,t,{id:`v1:${t.seq}`,source:`step-end`,text:`step ${n??`?`} failed${i}`,cause:r?M(r):``,stepId:n,fatal:!0})}function He(e,t){let n=C(t.command)??`check`,r=typeof t.exitCode==`number`?t.exitCode:-1;O(e,{kind:`tool`,id:`v1:${t.seq}`,name:`check`,toolKind:`execute`,title:`Ran ${n}`,status:r===0?`completed`:`failed`,output:C(t.text)??``,exitCode:r})}function Ue(e,t){let n=de(t.provider),r=C(t.authFailureId)??``;n===void 0||r.length<1||r.length>128||O(e,{kind:`provider-auth-required`,id:`v1:${t.seq}`,provider:n,authFailureId:r})}function We(e,t){let n=C(t.url);if(n===void 0)return;let r={kind:`image`,id:`v1:${t.seq}`,url:n},i=C(t.name);i!==void 0&&(r.name=i),O(e,r)}function Ge(e,t){Array.isArray(t.entries)&&(D(e).planEntries=t.entries)}function Ke(e,t){R(e);let n=C(t.reason)??`end_turn`,r=C(t.message);n===`error`&&L(e,t,r),e.sessionEnded={reason:n,...r===void 0?{}:{message:r}}}var qe=new Set([`allow_once`,`allow_always`,`reject_once`,`reject_always`]);function Je(e){return S(e)&&typeof e.id==`string`&&e.id!==``&&typeof e.label==`string`&&e.label!==``&&qe.has(e.kind)}function Ye(e){if(!(!Array.isArray(e)||e.length===0||!e.every(Je)))return new Set(e.map(e=>e.id)).size===e.length?e:void 0}function Xe(e,t){let n=C(t.requestId),r=C(t.title),i=Ye(t.options);if(!n||!r||e.permissions.has(n)||!i)return;let a=C(t.itemId),o=C(t.details),s={kind:`permission`,id:`permission:${n}`,requestId:n,title:r,options:i.map(e=>({...e})),status:`pending`,...a===void 0?{}:{itemId:a},...o===void 0?{}:{details:o}};e.permissions.set(n,s),O(e,s)}function Ze(e,t){let n=e.permissions.get(C(t.requestId)??``);if(!n||n.status!==`pending`)return;let r=C(t.optionId);r!==void 0&&n.options.some(e=>e.id===r)?(n.status=`resolved`,n.optionId=r):n.status=`expired`;let i=C(t.reason);i!==void 0&&(n.reason=i)}function Qe(e,t){let n=d(t),r=n&&ne(n);if(!r)return;let i={kind:`ask`,...r,questions:r.questions,resolved:!1};O(e,i),e.pendingAsk=i}function Y(e,t){let n=e.pendingAsk;return n&&!n.resolved&&n.askSeq===t.askSeq?n:void 0}function $e(e,t){let n=Y(e,t);if(!n)return;n.routedToParent=!0;let r=C(t.parentRunId);r!==void 0&&(n.parentRunId=r)}function et(e,t){let n=Y(e,t);n&&(n.routedToParent=!1)}function tt(e,t){let n=Y(e,t);n&&X(e,n,`undeliverable`)}var nt=new Set([`finish`,`superseded`,`parent-stopped`,`worker-stopped`,`undeliverable`]);function rt(e,t){let n=Y(e,t);n&&nt.has(t.reason)&&X(e,n,t.reason)}function X(e,t,n){t.resolved=!0,t.closed=n,e.pendingAsk=void 0}function it(e,t){let n=Y(e,t);if(n){if(t.source===`cezar`){X(e,n,`undeliverable`);return}t.source===`parent`&&(n.resolved=!0,n.answeredBy=`parent`,e.pendingAsk=void 0)}}var Z=()=>{},at=new Map([[`handoff`,he],[`webhook.failed`,ge],[`webhook.dry-run`,ve],[`webhook.report`,_e],[`preview.server-registered`,ye],[`preview.server-state`,be],[`conversation-message`,xe],[`request-outcome`,Se],[`agent-input`,Ce],[`user-message`,we],[`turn.started`,Te],[`turn.completed`,De],[`item.started`,q],[`item.updated`,q],[`item.completed`,q],[`item.delta`,Ae],[`text`,je],[`tool-call`,Fe],[`tool-result`,Le],[`note`,J],[`lifecycle`,J],[`error`,ze],[`session.error`,Be],[`step-end`,Ve],[`check-output`,He],[`provider-auth-required`,Ue],[`image`,We],[`plan.updated`,Ge],[`session.started`,e=>R(e)],[`session.ended`,Ke],[`permission.requested`,Xe],[`permission.resolved`,Ze],[`ask.requested`,Qe],[`worker-question-routed`,$e],[`worker-question-fallback`,et],[`worker-question-undelivered`,tt],[`human-ask-closed`,rt],[`human-input-delivered`,it],[`step-start`,Z],[`token-usage`,Z],[`cost`,Z],[`turn-end`,Z],[`done`,Z],[`session`,Z]]);function ot(e,t){e.eventSeq=t.seq,at.get(t.type)?.(e,t)}function st(e){for(let t=e.turns.length-1;t>=0;--t){let n=e.turns[t].planEntries;if(n!==void 0)return n}}function ct(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=new Set;for(let e=t.length-1;e>=0;--e)n.add(t[e]);return[...n]}function lt(e,t){let n=e?.turns.at(-1);if(!n)return!1;let r=M(t);return r!==``&&n.items.some(e=>e.kind===`note`&&e.tone===`danger`&&M(e.text)===r)}function ut(e,t,n){switch(e){case`waiting`:return{state:`waiting`};case`failed`:return{state:`closed`,tone:`danger`,label:t!==void 0&&t!==``&&!lt(n,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 Q(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
- `)+1;/^CEZ:ASK[ \t]+.+$/.test(e.slice(t))&&(n=e.slice(0,t).trimEnd())}return n.includes(`CEZ:`)?n.split(`
3
- `).filter(e=>!/^CEZ:(?:PR=\d+|ISSUE=\d+|TITLE=.+)\s*$/.test(e)).join(`
4
- `):n}var dt=/\s*(?:^|\n)C(?:E(?:Z(?::.*)?)?)?$/,ft=/[ \t]+CEZ(?::[A-Z]*)?$/;function $(e){return e.replace(dt,``).replace(ft,``)}function pt(e,t,n){return t!==``&&e.some(e=>e.norm===``?n>e.firstSeq:e.norm.startsWith(t)||t.startsWith(e.norm))}function mt(e,t){let n=e=>Q(e,!0).replace(/\s+/g,``),r=new Set,i=[],a=[];for(let{origin:o,entry:s,firstSeq:c,streaming:l}of e.entries)if(o===`v2`&&s.kind===`message`){let e=n(s.text);r.add(e),i.push(e),t&&l===!0&&a.push({norm:e,firstSeq:c})}if(i.length===0)return;r.add(i.join(``));let o=[],s={entries:[],texts:[]},c=()=>{let e=n(s.texts.join(``)),t=s.entries[0],i=s.entries.length>=2&&r.has(e);if(t&&(i||pt(a,e,t.firstSeq))){s={entries:[],texts:[]};return}o.push(...s.entries),s={entries:[],texts:[]}};for(let t of e.entries)t.origin===`v1`&&t.entry.kind===`message`?(s.entries.push(t),s.texts.push(t.entry.text)):(c(),o.push(t));c(),e.entries=o}function ht(e,t){let n=new Set;for(let{origin:t,entry:r}of e.entries)t===`v2`&&r.kind===`message`&&n.add(Q(r.text,!0).trim());n.size!==0&&(e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`message`&&n.has(Q(e.entry.text,!0).trim()))),mt(e,t))}function gt(e){let t=e.failures?.filter(e=>e.fatal&&e.cause!==``);if(!t||t.length===0)return;let n=new Map;for(let e of t)n.set(e.cause,e);e.entries=e.entries.filter(e=>{if(e.entry.kind!==`message`||e.entry.role!==`assistant`)return!0;let t=Q(e.entry.text,!0).trim();if(t===``)return!0;let r=n.get(j(t));return r?(r.draft.firstSeq=Math.min(r.draft.firstSeq,e.firstSeq),r.draft.lastSeq=Math.max(r.draft.lastSeq,e.lastSeq),N(r,`assistant`,t),!1):!0})}function _t(e){e.userMessage&&(e.entries=e.entries.filter(({entry:e})=>!x(e,`human`)))}function vt(e){for(let t of e.conversationEntries.values())t.messageKind!==`request`||t.outcome!==void 0||t.delivery!==`not-delivered`&&(t.state!==void 0&&t.state!==`accepted`||(t.outcome={status:`pending`}))}function yt(e,t,n){let{entry:r}=e;if(r.kind!==`message`||r.role!==`assistant`)return r;let i=Q(r.text,t);return n&&e.streaming===!0?{...r,text:$(i),streaming:!0}:{...r,text:i}}function bt(e,t){let n=t||e.entries.some(({entry:e})=>e.kind===`ask`);return{id:e.id,...e.turnId===void 0?{}:{turnId:e.turnId},...e.userMessage===void 0?{}:{userMessage:e.userMessage},...e.startedAt===void 0?{}:{startedAt:e.startedAt},...e.planEntries===void 0?{}:{planEntries:e.planEntries},...e.completed===void 0?{}:{completed:e.completed},items:e.entries.map(e=>yt(e,n,t)),itemSeqs:xt(e.entries)}}function xt(e){let t=new Map;for(let{entry:n,firstSeq:r,lastSeq:i}of e)t.has(n.id)||t.set(n.id,{first:r,last:i});return t}function St(e,t={}){let n=ue();for(let t of e)ot(n,t);let r=n.turns.length-1;for(let[e,i]of n.turns.entries())i.v2Items&&ht(i,t.activeTurn===!0&&e===r),gt(i),_t(i);return vt(n),{turns:n.turns.map((e,n)=>bt(e,t.activeTurn===!0&&n===r)),...n.sessionEnded===void 0?{}:{sessionEnded:n.sessionEnded}}}export{x as a,ut as i,St as n,y as o,ct as r,m as s,st as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{n as r,t as i}from"./utils-DSMR_WLb.js";import{A as a,Ct as o,Jt as s,Wt as c,_ as l,a as u,c as d,dn as f,f as p,k as m,rn as h,sn as g}from"./queries-EvENG6TN.js";import{$ as _,I as v,J as y,Pr as b,Y as x,a as S,hi as C,ii as w,n as T,st as E}from"./toaster-Cer2NOxt.js";import{Y as D,c as O,ct as k,ft as A,g as j,it as M,k as N,l as ee,m as P,ot as F,r as I,tt as L,u as te,ut as R,y as ne}from"./design-icons-CzEoMH9c.js";import{t as re}from"./chevron-down-CHGyCDBH.js";import{t as z}from"./external-link-BE6y205O.js";import{t as ie}from"./eye-B8okNWXU.js";import{t as ae}from"./loader-circle-CPBhhDbB.js";import{t as oe}from"./message-square-B-MD-8rD.js";import{t as se}from"./play-CmVAj_fu.js";import{t as B}from"./button-B7MKxYjT.js";import{i as ce,r as le,t as ue}from"./popover-CZV6tz9i.js";import{a as de,i as fe,o as pe,r as me,s as he,t as ge}from"./dialog-B531GGAo.js";import{t as V}from"./project-router-BypHPat0.js";import{a as _e,i as H,o as U,r as ve,s as ye,t as be}from"./command-KdW7aO0N.js";import{d as xe,f as W,i as Se,o as Ce,p as we,s as Te,t as Ee,u as De}from"./skills-pM_PouEs.js";import{$ as Oe,A as ke,F as Ae,G as je,H as Me,I as Ne,Jn as G,M as Pe,Mn as Fe,N as Ie,Nn as Le,P as Re,Q as ze,U as K,V as Be,W as Ve,X as He,Y as Ue,_n as We,bt as q,dr as Ge,j as Ke,jn as J,mn as qe,nt as Je,q as Ye,rt as Xe,tt as Ze}from"./index-8eoz1i7-.js";import{t as Qe}from"./markdown-Dn1C5VnY.js";import{t as $e}from"./textarea-vJt9undk.js";import{t as et}from"./diff-eTwHyNBm.js";import{t as Y}from"./change-counts-npLATh-3.js";import{t as tt}from"./tab-link-Bjo_gEiX.js";var X=e(t(),1),Z=n(),nt={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,Z.jsx)(O,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-passing`,className:i(t,`text-semantic-green`)}):e===`failing`?(0,Z.jsx)(j,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-failing`,className:i(t,`text-semantic-red`)}):e===`pending`?(0,Z.jsx)(ae,{"aria-hidden":`true`,"data-slot":`gh-merge-status-pending`,className:i(t,`animate-spin text-semantic-amber motion-reduce:animate-none`)}):e===`review`?(0,Z.jsx)(P,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-review`,className:i(t,`text-semantic-info`)}):e===`conflict`?(0,Z.jsx)(F,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-conflict`,className:i(t,`text-semantic-conflict`)}):(0,Z.jsx)(P,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-unknown`,className:i(t,`text-soft-foreground`)})}function rt(e){return e?.available?e.mergeState:null}function it(e,t){return e&&t?.methods.includes(e)?e:t?.defaultMethod??t?.methods[0]??null}function at(e){return e.state===`merged`?`Merged`:e.state===`closed`?`Closed`:e.isDraft?`Draft`:e.mergeable===`conflicting`?`Conflicts must be resolved`:e.canMerge?`Ready to merge`:e.eligibility===`unknown`?`Merge blocked · Requirements unknown`:`Merge blocked`}function ot(e){return e===`approved`||e===`not-required`?`passing`:e===`review-required`?`review`:e===`unknown`?`unknown`:`failing`}function st(e){switch(e){case`approved`:return`Approved`;case`not-required`:return`Not required`;case`review-required`:return`Waiting for review`;case`changes-requested`:return`Changes requested`;case`unknown`:return`Unknown`}}function ct(e){return e===`mergeable`?`passing`:e===`conflicting`?`conflict`:`unknown`}function lt(e){return e===`conflicting`?`present`:e===`mergeable`?`none`:`unknown`}function ut(e){return e===!0?` · required`:e===null?` · requiredness unknown`:``}function dt(e){return e?.available===!1?e.reason:`GitHub could not load merge requirements.`}function ft(e,t,n){return!!(e&&(t.canMerge||t.canOverride&&n))}function $(e){return e?nt[e]:`Merge`}function pt(e){return e===`conflicting`?`true`:void 0}function mt({check:e}){return(0,Z.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(Q,{state:e.state}),(0,Z.jsxs)(`span`,{children:[e.name,` · `,e.state,ut(e.required)]})]}),e.url&&r(e.url)?(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-muted-foreground underline`,children:`details`}):null]})}function ht({reason:e}){return(0,Z.jsxs)(`section`,{"data-slot":`gh-merge-unavailable`,className:`mt-6 rounded-lg border border-border bg-card p-4 text-sm`,children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:`Merge status unavailable`}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-soft-foreground`,children:e})]})}function gt({state:e,selectedMethod:t,overrideRules:n,mergeEnabled:r,refreshPending:a,onRefresh:o,onRunAgent:s,onConfirm:c,onMethodChange:l,onOverrideChange:u}){let d=at(e),f=ot(e.reviewDecision),p=ct(e.mergeable);return(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[e.canMerge?(0,Z.jsx)(O,{size:16,"aria-hidden":`true`,className:`mt-0.5 size-5 shrink-0 text-semantic-green`}):(0,Z.jsx)(F,{size:16,"aria-hidden":`true`,className:i(`mt-0.5 size-5 shrink-0`,e.mergeable===`conflicting`?`text-semantic-conflict`:`text-semantic-amber`)}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`h3`,{className:`font-semibold`,children:d}),(0,Z.jsxs)(B,{type:`button`,variant:`ghost`,size:`sm`,disabled:a,onClick:o,children:[(0,Z.jsx)(D,{size:16,"aria-hidden":`true`,className:i(`size-3.5`,a&&`animate-spin`)}),`Refresh`]})]}),(0,Z.jsxs)(`p`,{className:`mt-1 font-mono text-xs text-soft-foreground`,children:[e.headRef,` (`,Le(e.headSha),`) → `,e.baseRef]}),(0,Z.jsxs)(`ul`,{className:`mt-3 space-y-2 text-xs`,children:[(0,Z.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Q,{state:f}),(0,Z.jsxs)(`span`,{children:[`Reviews: `,st(e.reviewDecision)]})]}),(0,Z.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Q,{state:p}),(0,Z.jsxs)(`span`,{children:[`Conflicts: `,lt(e.mergeable)]})]}),e.checks.length===0?(0,Z.jsx)(`li`,{children:`No checks configured`}):e.checks.map(e=>(0,Z.jsx)(mt,{check:e},e.name)),e.blockers.map(e=>(0,Z.jsx)(`li`,{className:`text-soft-foreground`,children:e.message},e.code))]}),e.mergeable===`conflicting`&&s?(0,Z.jsx)(B,{className:`mt-4`,onClick:s,children:`Run agent on this PR`}):null,e.canOverride?(0,Z.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-2 rounded-md border border-pending-strong/40 bg-pending/10 p-3 text-xs`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>u(e.target.checked),className:`mt-0.5 size-4 accent-accent-strong`}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`block font-medium`,children:`Merge without waiting for requirements`}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-soft-foreground`,children:`GitHub will allow this only if your permissions can bypass the repository rules.`})]})]}):null,e.eligibility===`unknown`?(0,Z.jsx)(`p`,{className:`mt-4 text-xs text-muted-foreground`,children:`GitHub could not confirm review and branch-protection requirements. Passing checks do not establish merge readiness.`}):null,e.state===`open`&&e.methods.length>0?(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-col flex-wrap gap-2 sm:flex-row`,children:[(0,Z.jsx)(`select`,{"aria-label":`Merge method`,value:t??``,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:e.methods.map(e=>(0,Z.jsx)(`option`,{value:e,children:nt[e]},e))}),(0,Z.jsx)(B,{disabled:!r,onClick:c,children:$(t)})]}):null]})]})}function _t({number:e,state:t,selectedMethod:n,confirming:r,overrideRules:i,mergePending:a,mergeError:o,onOpenChange:s,onMerge:c}){return(0,Z.jsx)(ge,{open:r,onOpenChange:s,children:(0,Z.jsxs)(me,{"data-slot":`gh-merge-confirm`,showCloseButton:!1,children:[(0,Z.jsxs)(pe,{children:[(0,Z.jsxs)(he,{children:[$(n),` pull request #`,e,`?`]}),(0,Z.jsx)(fe,{asChild:!0,children:(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`p`,{children:[`This will merge “`,t.title,`” into `,t.baseRef,`. GitHub will re-check the exact reviewed head before changing the repository.`]}),i&&t.canOverride?(0,Z.jsx)(`p`,{"data-slot":`gh-bypass-warning`,className:`mt-4 text-sm text-semantic-amber`,children:`You are asking GitHub to bypass unmet repository requirements; GitHub may refuse if your permissions do not allow it.`}):null]})})]}),o?(0,Z.jsx)(`p`,{className:`text-sm text-danger`,children:o.message}):null,(0,Z.jsxs)(de,{children:[(0,Z.jsx)(B,{variant:`outline`,disabled:a,onClick:()=>s(!1),children:`Cancel`}),(0,Z.jsx)(B,{disabled:a,onClick:c,children:a?`Merging…`:$(n)})]})]})})}function vt({number:e,onRunAgent:t}){let n=C(),r=p(),i=w({queryKey:c.githubMergeState(e),queryFn:({signal:t})=>x(e,{},{signal:t}),retry:!1}),a=rt(i.data),[o,s]=(0,X.useState)(null),[l,u]=(0,X.useState)(!1),[d,m]=(0,X.useState)(!1),h=f({mutationFn:t=>x(e,{refresh:!0}),onSuccess:(e,t)=>n.setQueryData(t,e),onError:e=>T(e instanceof Error?e.message:String(e),{tone:`danger`})}),g=it(o,a),v=()=>({mergeState:c.githubMergeState(e),list:c.githubPages(50),comments:c.githubComments(`pr`,e),item:c.githubItem(`pr`,e),refStatus:r===void 0?void 0:c.githubRefStatusOf(r)}),y=f({mutationFn:t=>{if(!a||!g)throw Error(`No merge method is available.`);return _(e,{method:g,expectedHeadSha:a.headSha,...d&&a.canOverride?{overrideRules:!0}:{}})},onSuccess:(t,r)=>{u(!1),T(`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)=>{T(e instanceof Error?e.message:String(e),{tone:`danger`}),n.invalidateQueries({queryKey:t.mergeState})}});return i.isPending?(0,Z.jsx)(G,{"data-slot":`gh-merge-loading`,className:`mt-6 h-32 w-full`}):a?(0,Z.jsxs)(`section`,{"data-slot":`gh-merge-box`,"data-eligibility":a.eligibility,"data-conflicting":pt(a.mergeable),"aria-live":`polite`,className:`mt-6 rounded-lg border border-card-edge bg-card p-4 shadow-card`,children:[(0,Z.jsx)(gt,{state:a,selectedMethod:g,overrideRules:d,mergeEnabled:ft(g,a,d),refreshPending:h.isPending,onRefresh:()=>h.mutate(c.githubMergeState(e)),onRunAgent:t,onConfirm:()=>u(!0),onMethodChange:s,onOverrideChange:m}),(0,Z.jsx)(_t,{number:e,state:a,selectedMethod:g,confirming:l,overrideRules:d,mergePending:y.isPending,mergeError:y.error,onOpenChange:u,onMerge:()=>y.mutate(v())})]}):(0,Z.jsx)(ht,{reason:dt(i.data)})}function yt(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 bt(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 xt(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 St(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 Ct({label:e,color:t,plain:n=!1}){return(0,Z.jsx)(`span`,{"data-slot":`gh-label`,"data-label":e,style:n?void 0:St(t),className:n?`text-xs font-normal text-muted-foreground`:`rounded-full border px-1.5 py-px text-[12px] font-medium`,children:e})}function wt(e){return e===`pr`?`pull request`:`issue`}function Tt(e,t,n){return e===`pr`&&!!(t||n)}function Et({backLink:e}){return e?(0,Z.jsxs)(V,{to:e.to,"data-slot":`gh-back`,className:`mb-3 inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground md:hidden`,children:[(0,Z.jsx)(I,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`Back to the list`]}):null}var Dt=i(`text-sm`,`[&_[data-streamdown="code-block"]]:relative [&_[data-streamdown="code-block"]]:my-2.5 [&_[data-streamdown="code-block"]]:gap-0 [&_[data-streamdown="code-block"]]:overflow-hidden [&_[data-streamdown="code-block"]]:rounded-lg [&_[data-streamdown="code-block"]]:border [&_[data-streamdown="code-block"]]:border-border [&_[data-streamdown="code-block"]]:bg-background [&_[data-streamdown="code-block"]]:p-0 [&_[data-streamdown="code-block"]]:![content-visibility:visible] [&_[data-streamdown="code-block"]]:![contain-intrinsic-size:auto]`,`[&_[data-streamdown="code-block-header"]]:h-7 [&_[data-streamdown="code-block-header"]]:border-b [&_[data-streamdown="code-block-header"]]:border-border [&_[data-streamdown="code-block-header"]]:bg-muted/40 [&_[data-streamdown="code-block-header"]]:px-3 [&_[data-streamdown="code-block-header"]]:text-xs`,`[&_[data-streamdown="code-block-header"][data-language=""]]:hidden [&_[data-streamdown="code-block-header"]:not([data-language])]:hidden [&_[data-streamdown="code-block-header"]:has(>span:empty)]:hidden`,`[&_[data-streamdown="code-block"]>*:has([data-streamdown="code-block-actions"])]:absolute [&_[data-streamdown="code-block"]>*:has([data-streamdown="code-block-actions"])]:top-1 [&_[data-streamdown="code-block"]>*:has([data-streamdown="code-block-actions"])]:right-1.5 [&_[data-streamdown="code-block"]>*:has([data-streamdown="code-block-actions"])]:mt-0 [&_[data-streamdown="code-block"]>*:has([data-streamdown="code-block-actions"])]:h-auto`,`[&_[data-streamdown="code-block-actions"]]:border-0 [&_[data-streamdown="code-block-actions"]]:bg-transparent [&_[data-streamdown="code-block-actions"]]:p-0 [&_[data-streamdown="code-block-actions"]]:backdrop-blur-none`,`[&_[data-streamdown="image-fallback"]]:inline-flex [&_[data-streamdown="image-fallback"]]:rounded-md [&_[data-streamdown="image-fallback"]]:border [&_[data-streamdown="image-fallback"]]:border-dashed [&_[data-streamdown="image-fallback"]]:border-border [&_[data-streamdown="image-fallback"]]:bg-muted/40 [&_[data-streamdown="image-fallback"]]:px-3 [&_[data-streamdown="image-fallback"]]:py-2 [&_[data-streamdown="image-fallback"]]:not-italic [&_[data-streamdown="image-fallback"]]:after:content-["_—_open_on_GitHub_to_view"]`,`[&_[data-streamdown="code-block-body"]]:rounded-none [&_[data-streamdown="code-block-body"]]:border-0 [&_[data-streamdown="code-block-body"]]:bg-transparent [&_[data-streamdown="code-block-body"]]:px-3.5 [&_[data-streamdown="code-block-body"]]:py-2.5 [&_[data-streamdown="code-block-body"]]:pr-10`);function Ot(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function kt({item:e,kindWord:t,commentCount:n,hasDiffStat:i,additions:a,deletions:o}){return(0,Z.jsxs)(`p`,{"data-slot":`gh-meta`,className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 text-xs text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[`#`,e.number]}),`·`,(0,Z.jsx)(`span`,{children:t}),`·`,(0,Z.jsxs)(`span`,{children:[`opened by `,e.author]}),`·`,(0,Z.jsx)(J,{iso:e.createdAt,title:Ot(e.createdAt)}),n?(0,Z.jsxs)(Z.Fragment,{children:[`·`,(0,Z.jsx)(tn,{count:n})]}):null,i?(0,Z.jsxs)(Z.Fragment,{children:[`·`,(0,Z.jsx)(`span`,{"data-slot":`gh-diffstat`,children:(0,Z.jsx)(Y,{adds:a??0,dels:o??0})})]}):null,`·`,r(e.url)?(0,Z.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,Z.jsx)(z,{"aria-hidden":`true`,className:`size-2.5`})]}):(0,Z.jsx)(`span`,{"data-slot":`gh-open-link`,className:`text-muted-foreground`,children:`open on GitHub`})]})}function At({item:e,subNav:t,changes:n}){return e.kind===`pr`?t?(0,Z.jsxs)(`nav`,{"aria-label":`Pull request detail`,className:`mt-4 flex border-b border-border`,children:[(0,Z.jsx)(tt,{to:q(`prs`,t.filter,e.number),active:!n,children:`Conversation`}),(0,Z.jsx)(tt,{to:q(`prs`,t.filter,e.number,`/changes`),active:n,children:`Changes`})]}):(0,Z.jsx)(V,{to:q(`prs`,null,e.number,`/changes`),"data-slot":`gh-files-changed`,className:`mt-3 inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:underline`,children:`Files changed`}):null}function jt({item:e,colors:t,checks:n}){return e.labels.length>0||n?(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[e.labels.map(e=>(0,Z.jsx)(Ct,{label:e,color:t[e]},e)),n?(0,Z.jsx)(nn,{checks:n,url:e.url}):null]}):null}function Mt({item:e,colors:t,body:n}){return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{"data-slot":`gh-body`,className:i(`mt-5`,Dt),children:n?(0,Z.jsx)(Qe,{children:n}):(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:`(no description)`})}),(0,Z.jsx)(It,{item:e,colors:t})]})}function Nt({item:e,colors:t,checks:n,comments:r,backLink:i,subNav:a,onRunAgent:o,afterHeading:s,headerAction:c,children:l}){let d=a?.changes??!1,f=wt(e.kind),p=u(e.kind,e.number,!d).data?.detail,m=p?.body??e.body,h=p?.additions??e.additions,g=p?.deletions??e.deletions,_=Tt(e.kind,h,g),v=r??e.comments;return(0,Z.jsxs)(`article`,{"data-slot":`gh-detail-inner`,className:`min-w-0 px-4 py-4 md:px-7 md:py-5`,children:[(0,Z.jsx)(Et,{backLink:i}),(0,Z.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,Z.jsx)(Pt,{action:c,className:`mb-4`,children:(0,Z.jsxs)(`h2`,{className:`min-w-0 text-[22px] leading-snug font-semibold tracking-tight`,children:[`#`,e.number,` `,e.title]})}):null,(0,Z.jsx)(Pt,{action:e.kind===`pr`?void 0:c,children:(0,Z.jsx)(kt,{item:e,kindWord:f,commentCount:v,hasDiffStat:_,additions:h,deletions:g})}),e.kind===`pr`?null:(0,Z.jsx)(`h2`,{className:`mt-2 text-[22px] leading-snug font-semibold tracking-tight`,children:e.title}),s,(0,Z.jsx)(At,{item:e,subNav:a,changes:d}),(0,Z.jsx)(jt,{item:e,colors:t,checks:n}),d&&e.kind===`pr`?(0,Z.jsx)(Ft,{item:e}):(0,Z.jsx)(Mt,{item:e,colors:t,body:m})]}),e.kind===`pr`?(0,Z.jsx)(vt,{number:e.number,onRunAgent:o}):null,l]})}function Pt({action:e,className:t,children:n}){return e?(0,Z.jsxs)(`div`,{"data-slot":`gh-header-row`,className:i(`flex flex-wrap items-center gap-x-3 gap-y-2`,t),children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:n}),(0,Z.jsx)(`div`,{"data-slot":`gh-header-action`,className:`flex shrink-0 items-center gap-2`,children:e})]}):t?(0,Z.jsx)(`div`,{className:t,children:n}):(0,Z.jsx)(Z.Fragment,{children:n})}function Ft({item:e}){let t=C(),n=d(e.number),[a,o]=(0,X.useState)(``),[s,l]=(0,X.useState)(null),u=n.data,f=e=>u?.available?u.files.filter(t=>t.path.toLowerCase().includes(e.toLowerCase())):[],p=f(a),m=p.some(e=>e.path===s)?s:p[0]?.path??null,h=p.findIndex(e=>e.path===m),g=e=>{o(e);let t=f(e),n=m??s,r=t.some(e=>e.path===n)?n:t[0]?.path??n;r!==s&&l(r)},_=async()=>{let n=u?.available?u.headSha:null,r=c.githubPrChanges(e.number),i=await y(e.number,{refresh:!0});t.setQueryData(r,i),i.available&&n&&n!==i.headSha&&(l(i.files[0]?.path??null),T(`The reviewed revision changed.`))};if(n.isPending)return(0,Z.jsx)(`p`,{"aria-live":`polite`,className:`mt-6 text-sm text-muted-foreground`,children:`Loading changed files…`});if(n.isError||!u)return(0,Z.jsx)(`p`,{className:`mt-6 text-sm text-danger`,children:`Changed files could not be loaded.`});if(!u.available)return(0,Z.jsx)(`p`,{className:`mt-6 text-sm text-muted-foreground`,children:u.reason});let v=p.map(e=>({path:e.path,...e.previousPath?{oldPath:e.previousPath}:{},status:e.status===`removed`?`deleted`:e.status===`changed`?`modified`:e.status,adds:e.additions,dels:e.deletions,binary:e.patchUnavailableReason===`binary`,patch:e.patch??``})),b=r(e.url)?`${e.url}/files`:null,x=p.find(e=>e.path===m);return(0,Z.jsxs)(`section`,{"data-slot":`gh-pr-changes`,className:`mt-5 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,Z.jsxs)(`strong`,{children:[u.files.length,` changed files`]}),(0,Z.jsx)(Y,{adds:u.additions,dels:u.deletions}),(0,Z.jsx)(Fe,{sha:u.headSha,variant:`inline`,prefix:`head `,className:`text-muted-foreground`}),(0,Z.jsx)(B,{type:`button`,variant:`outline`,size:`sm`,className:`ml-auto min-h-11`,onClick:()=>void _(),children:`Refresh`})]}),u.truncated?(0,Z.jsxs)(`p`,{role:`status`,className:`mt-3 rounded-md border border-pending-strong/40 bg-pending/10 p-3 text-xs`,children:[u.reason??`This response is incomplete.`,` `,b?(0,Z.jsx)(`a`,{href:b,target:`_blank`,rel:`noopener noreferrer`,className:`underline`,children:`Open all files on GitHub`}):null]}):null,(0,Z.jsxs)(`div`,{className:`mt-4 grid min-w-0 gap-4 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`aside`,{className:`min-w-0`,children:[(0,Z.jsx)(`input`,{"aria-label":`Filter changed files`,value:a,onChange:e=>g(e.target.value),placeholder:`Filter files…`,className:`min-h-11 w-full rounded-md border border-input bg-background px-3 text-sm`}),(0,Z.jsxs)(`div`,{className:`relative mt-2 lg:hidden`,children:[(0,Z.jsx)(`select`,{"aria-label":`Select changed file`,value:m??``,onChange:e=>l(e.target.value),className:`min-h-11 w-full appearance-none rounded-md border border-input bg-background py-2 pr-8 pl-3 text-sm`,children:p.map(e=>(0,Z.jsx)(`option`,{children:e.path},e.path))}),(0,Z.jsx)(re,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 right-2.5 size-4 -translate-y-1/2 text-muted-foreground`})]}),(0,Z.jsx)(`ul`,{className:`mt-2 hidden max-h-[60vh] overflow-auto lg:block`,children:p.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>l(e.path),className:i(`min-h-11 w-full truncate rounded px-2 text-left text-xs`,m===e.path&&`bg-muted font-medium`),title:e.path,children:[e.status,` · `,e.path,` `,(0,Z.jsx)(Y,{adds:e.additions,dels:e.deletions})]})},e.path))})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex justify-end gap-1`,children:[(0,Z.jsx)(B,{"aria-label":`Previous file`,variant:`outline`,size:`icon`,className:`min-h-11 min-w-11`,disabled:h<=0,onClick:()=>l(p[h-1]?.path??null),children:(0,Z.jsx)(Ge,{})}),(0,Z.jsx)(B,{"aria-label":`Next file`,variant:`outline`,size:`icon`,className:`min-h-11 min-w-11`,disabled:h<0||h>=p.length-1,onClick:()=>l(p[h+1]?.path??null),children:(0,Z.jsx)(te,{size:16})})]}),p.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No changed files match this filter.`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(et,{files:v.filter(e=>e.path===m),wrap:!0,className:`min-w-0`}),x&&!x.patch?(0,Z.jsxs)(`p`,{className:`rounded-b border border-border p-3 text-xs text-muted-foreground`,children:[`Patch unavailable: `,x.patchUnavailableReason??`not-provided`,`.`]}):null]})]})]})]})}function It({item:e,colors:t}){let n=u(e.kind,e.number),r=n.data,i=(0,X.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(Lt(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,Z.jsxs)(`section`,{"data-slot":`gh-thread-loading`,className:`mt-6 border-t border-border pt-5`,children:[(0,Z.jsx)(G,{className:`mb-3 h-3 w-24`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(G,{className:`h-14 w-full`}),(0,Z.jsx)(G,{className:`h-14 w-full`})]})]}):!r||!r.available?(0,Z.jsxs)(`section`,{"data-slot":`gh-thread-error`,className:`mt-6 border-t border-border pt-5 text-xs text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{children:[`Couldn’t load comments — `,r?.reason??(n.error instanceof Error?n.error.message:`could not load comments`),`. `]}),(0,Z.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,Z.jsx)(z,{"aria-hidden":`true`,className:`size-2.5`})]})]}):i.length===0?null:(0,Z.jsxs)(`section`,{"data-slot":`gh-thread`,className:`mt-6 border-t border-border pt-5`,children:[(0,Z.jsxs)(`h3`,{"data-slot":`gh-thread-header`,className:`mb-4 text-xs font-semibold tracking-wide text-muted-foreground uppercase`,children:[`Activity · `,r.comments.length,` comment`,r.comments.length===1?``:`s`]}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-5`,children:Rt(i).map(e=>e.group===`commits`?(0,Z.jsx)(zt,{commits:e.commits,colors:t},e.commits[0].id):e.entry.row===`comment`?(0,Z.jsx)(Xt,{comment:e.entry.comment},`${e.entry.comment.kind}-${e.entry.comment.id}`):(0,Z.jsx)(Vt,{event:e.entry.event,colors:t},e.entry.event.id))}),r.truncated?(0,Z.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-muted-foreground hover:text-foreground hover:underline`,children:[`thread truncated — open on GitHub`,(0,Z.jsx)(z,{"aria-hidden":`true`,className:`size-2.5`})]}):null]})}var Lt=e=>e.row===`comment`?e.comment.createdAt:e.event.createdAt;function Rt(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 zt({commits:e,colors:t}){let[n,r]=(0,X.useState)(!1),i=e[0]?.actor??`?`;return n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`true`,className:`min-w-0`,children:(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":!0,onClick:()=>r(!1),className:`flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:Bt.committed}),(0,Z.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,Z.jsxs)(`span`,{children:[`added `,e.length,` commits`]})]})}),e.map(e=>(0,Z.jsx)(Vt,{event:e,colors:t},e.id))]}):(0,Z.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`false`,className:`min-w-0`,children:(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":!1,onClick:()=>r(!0),className:`flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:Bt.committed}),(0,Z.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,Z.jsxs)(`span`,{children:[`added `,e.length,` commits`]}),(0,Z.jsx)(J,{iso:e[e.length-1].createdAt,className:`shrink-0`})]})})}var Bt={committed:`⚙`,labeled:`◆`,unlabeled:`◇`,assigned:`◍`,unassigned:`◌`,merged:`⑃`,closed:`⊘`,reopened:`⊙`,head_ref_force_pushed:`↻`,"cross-referenced":`↗`,renamed:`✎`};function Vt({event:e,colors:t}){return(0,Z.jsxs)(`li`,{"data-slot":`gh-event-row`,"data-kind":e.kind,className:i(`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,e.kind===`merged`&&`text-accent-foreground`),children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:Bt[e.kind]}),(0,Z.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.actor}),(0,Z.jsx)(qt,{event:e,colors:t}),(0,Z.jsx)(J,{iso:e.createdAt,className:`shrink-0`}),e.url?(0,Z.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,Z.jsx)(z,{"aria-hidden":`true`,className:`size-2.5`})}):null]})}function Ht({event:e}){return(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0`,children:`committed`}),e.sha?(0,Z.jsx)(Fe,{sha:e.sha,variant:`inline`,className:`shrink-0 text-xs text-muted-foreground`}):null,e.message?(0,Z.jsx)(`span`,{className:`truncate font-sans text-foreground`,children:e.message}):null,(0,Z.jsx)(Jt,{checks:e.checks})]})}function Ut({event:e,colors:t}){return(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0`,children:e.kind===`labeled`?`added the`:`removed the`}),e.label?(0,Z.jsx)(`span`,{"data-slot":`gh-event-label`,style:St(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,Z.jsx)(`span`,{className:`shrink-0`,children:`label`})]})}function Wt({event:e}){return(0,Z.jsxs)(`span`,{className:`truncate`,children:[e.kind===`assigned`?`assigned`:`unassigned`,` `,e.subject??`someone`]})}function Gt({event:e}){return(0,Z.jsxs)(`span`,{className:`truncate`,children:[`referenced this in `,e.refNumber?`#${e.refNumber}`:`another thread`,e.refTitle?` ${e.refTitle}`:``]})}var Kt={committed:e=>(0,Z.jsx)(Ht,{event:e}),labeled:(e,t)=>(0,Z.jsx)(Ut,{event:e,colors:t}),unlabeled:(e,t)=>(0,Z.jsx)(Ut,{event:e,colors:t}),assigned:e=>(0,Z.jsx)(Wt,{event:e}),unassigned:e=>(0,Z.jsx)(Wt,{event:e}),merged:()=>(0,Z.jsx)(`span`,{children:`merged this`}),closed:()=>(0,Z.jsx)(`span`,{children:`closed this`}),reopened:()=>(0,Z.jsx)(`span`,{children:`reopened this`}),head_ref_force_pushed:()=>(0,Z.jsx)(`span`,{children:`force-pushed`}),renamed:e=>(0,Z.jsxs)(`span`,{className:`truncate`,children:[`renamed this to `,e.subject??`—`]}),"cross-referenced":e=>(0,Z.jsx)(Gt,{event:e})};function qt({event:e,colors:t}){return Kt[e.kind]?.(e,t)??null}function Jt({checks:e}){return e?(0,Z.jsx)(`span`,{"data-slot":`gh-commit-checks`,"data-checks":e,"aria-label":`checks ${e}`,className:i(`shrink-0`,$t[e]),children:Qt[e]}):null}var Yt={approved:{label:`Approved`,tone:`border-success/40 text-semantic-green`},changes_requested:{label:`Changes requested`,tone:`border-danger/40 text-semantic-red`},commented:{label:`Commented`,tone:`border-border text-muted-foreground`},dismissed:{label:`Dismissed`,tone:`border-border text-muted-foreground`}};function Xt({comment:e}){let t=e.reviewState?Yt[e.reviewState]:null;return(0,Z.jsxs)(`li`,{"data-slot":`gh-thread-entry`,"data-kind":e.kind,className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Zt,{url:e.avatarUrl,login:e.author}),(0,Z.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.author}),(0,Z.jsx)(J,{iso:e.createdAt}),t?(0,Z.jsx)(`span`,{"data-slot":`gh-review-chip`,"data-review-state":e.reviewState,className:i(`rounded-full border px-1.5 py-px font-sans text-[12px] font-medium`,t.tone),children:t.label}):null,(0,Z.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,Z.jsx)(z,{"aria-hidden":`true`,className:`size-2.5`})})]}),(0,Z.jsx)(`div`,{"data-slot":`gh-thread-body`,className:Dt,children:e.body?(0,Z.jsx)(Qe,{children:e.body}):(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:`(no body)`})})]})}function Zt({url:e,login:t}){let[n,r]=(0,X.useState)(!1);return e&&!n?(0,Z.jsx)(`img`,{src:e,alt:``,width:20,height:20,loading:`lazy`,onError:()=>r(!0),"data-slot":`gh-avatar`,className:`size-5 shrink-0 rounded-full`}):(0,Z.jsx)(`span`,{"data-slot":`gh-avatar-fallback`,"aria-hidden":`true`,className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-semibold text-muted-foreground uppercase`,children:t.slice(0,1)||`?`})}var Qt={passing:`✓`,failing:`✗`,pending:`○`},$t={passing:`text-semantic-green`,failing:`text-semantic-red`,pending:`text-semantic-amber`},en={passing:`Checks passing`,failing:`Checks failing`,pending:`Checks pending`};function tn({count:e}){return e?(0,Z.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,Z.jsx)(oe,{"aria-hidden":`true`,className:`size-3`}),e]}):null}function nn({checks:e,url:t}){let n=i(`text-xs font-medium`,$t[e],t&&`hover:underline`),r=`${Qt[e]} ${en[e]}`;return t?(0,Z.jsx)(`a`,{href:`${t}/checks`,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-checks`,"data-checks":e,className:n,children:r}):(0,Z.jsx)(`span`,{"data-slot":`gh-checks`,"data-checks":e,className:n,children:r})}function rn({checks:e}){return(0,Z.jsx)(`span`,{"data-slot":`gh-row-checks`,"data-checks":e,title:en[e],"aria-label":en[e],className:i(`shrink-0 font-sans text-xs font-semibold`,$t[e]),children:Qt[e]})}function an(e){return`${e.kind===`pr`?`Address GitHub pull request`:`Fix GitHub issue`} #${e.number}: ${e.title}\n\n${e.url}`}function on(e,t=[]){let n=an(e);return e.body?.trim()&&(n+=`\n\n---\n\n${e.body.trim()}`),t.length&&(n+=sn(t)),n}function sn(e){return`\n\nUse these skills where relevant: ${e.join(`, `)}.`}function cn(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 ln(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 un(e,t,n){let r=(n??``).trim();if(!r)return on(e,t);let i=an(e),a=r.startsWith(i)?i+cn(r.slice(i.length),e):cn(r,e),o=ln(a,e)?a:`${i}\n\n${a}`;return t.length?o+sn(t):o}function dn(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 fn(e,t,n,r,i={}){return t?{...i,workflow:t,task:un(e,n.map(e=>e.id),r)}:n.length?{...i,steps:dn(n.map(e=>e.id)).map((e,t)=>({...e,...n[t]?.path===void 0?{}:{skillPath:n[t].path}})),task:un(e,[],r)}:{...i,workflow:`quick-task`,task:un(e,[],r)}}function pn(e){let t=o(),n=l(),r=h(),{runners:i,uninstalled:a,signedOut:s,accounts:c,repoAccount:u,accountFor:d}=We(),f=n.data?.defaultRunner,p=Ae(e.runner,i,f??i[0]??`claude`),m=n.data?.modelsLocked===!0,_=d(p,e.account),v=g(p,!0,_??u?.[p]),y=Re(m?null:e.model,p,r.data,n.data?.defaultModels,v.data),b=Ke(y,v.data);return{runner:p,runnerExplicit:e.runner!==null,model:y,effort:m?``:Ie(e.effort,b),effortOptions:b,runners:i,uninstalled:a,signedOut:s,defaultRunner:f,canRun:t.isSuccess&&i.length>0,modelsLocked:m,providerPending:t.isPending,providerError:t.isError,accounts:c,account:_,repoAccount:u}}function mn(e){return{runner:Ne(e.runner,e.defaultRunner,e.runnerExplicit),model:e.modelsLocked?void 0:e.model||void 0,effort:e.modelsLocked?void 0:e.effort||void 0}}function hn(e){return{...mn(e),...e.account?{agentProfile:e.account}:{}}}function gn(e,t){let{runners:n,uninstalled:r,signedOut:i}=e;return n.length>1||r.length>0||i.length>0||n.some(e=>qe(t,e))}function _n({pick:e,onChange:t,disabled:n=!1,accounts:r=!1,layout:i}){let a=(0,X.useRef)(null),o=(0,X.useRef)(null),[s,c]=(0,X.useState)(()=>typeof window<`u`&&window.innerWidth<=767);(0,X.useLayoutEffect)(()=>{let e=a.current;if(i!==`row`||!e)return;let t=()=>{let t=window.innerWidth<=767||e.getBoundingClientRect().width<550,n=document.activeElement;o.current=n instanceof HTMLElement&&e.contains(n)?n:null,c(t)};t();let n=typeof ResizeObserver>`u`?null:new ResizeObserver(t);return n?.observe(e),window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t)}},[i]),(0,X.useLayoutEffect)(()=>{let e=o.current;o.current=null,e&&e.isConnected&&document.activeElement!==e&&e.focus()},[s]);let u=pn(e),{runner:d,model:f,effort:p,effortOptions:m,runners:_,canRun:v,modelsLocked:y}=u,b=l(),x=h(),S=g(d,!0,u.account??u.repoAccount?.[d]),C=Pe(d,x.data,S.data,[e.model,b.data?.defaultModels?.[d]]),w=n||!v,T=r?u.accounts:[],E=gn(u,T)?(0,Z.jsx)(je,{icon:(0,Z.jsx)(M,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:_,uninstalled:u.uninstalled,signedOut:u.signedOut,value:d,accounts:T,account:r?u.account:null,repoAccount:r?u.repoAccount:void 0,disabled:w,onPick:(n,i)=>t(r?{runner:n,account:i,model:n===d?e.model:null,effort:e.effort}:{runner:n,account:null,model:null,effort:e.effort})},`runner`):null,D=(0,Z.jsx)(K,{icon:(0,Z.jsx)(ne,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`model-pill`,ariaLabel:`Model`,label:f===``?`Default`:C.find(e=>e.id===f).label,value:f,disabled:w,readOnly:y===!0,disabledHint:y?`Model selection is locked to native coding-agent settings.`:void 0,onPick:n=>{let r=Ke(n,S.data);t({...e,model:n,effort:e.effort===null?null:Ie(e.effort,r)})},options:C.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:ke(d,x.data,S)},`model`),O=(0,Z.jsx)(K,{icon:(0,Z.jsx)(N,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`effort-pill`,ariaLabel:`Effort`,label:m.find(e=>e.value===p)?.label??`auto`,value:p,disabled:w,readOnly:y===!0,disabledHint:y?`Effort selection is locked to native coding-agent settings.`:void 0,onPick:n=>t({...e,effort:n}),options:m.map(e=>({value:e.value,label:e.label,desc:e.desc}))},`effort`);return i===`row`?(0,Z.jsx)(`div`,{ref:a,"data-slot":`engine-row-box`,children:(0,Z.jsx)(`div`,{"data-slot":`engine-row`,className:`engine-row`,role:`group`,"aria-label":`Agent settings`,children:(0,Z.jsx)(Ve,{fill:`model-pill`,children:s?[E,O,D]:[E,D,O]})})}):(0,Z.jsxs)(Ve,{children:[E,D,O]})}var vn={workflow:null,skills:[]},yn=`cez-followup-selection`;function bn(e){let t=e&&typeof e==`object`?e:{};return{workflow:typeof t.workflow==`string`?t.workflow:null,skills:Array.isArray(t.skills)?t.skills.flatMap(e=>typeof e==`string`?[{id:e}]:!e||typeof e!=`object`||typeof e.id!=`string`?[]:[{id:e.id,...typeof e.path==`string`?{path:e.path}:{}}]):[]}}function xn(){try{let e=localStorage.getItem(yn);return e?bn(JSON.parse(e)):{...vn}}catch{return{...vn}}}function Sn(e){try{localStorage.setItem(yn,JSON.stringify(e))}catch{}}var Cn=`cez-followup-prompt:`;function wn(e){try{return localStorage.getItem(Cn+e)??``}catch{return``}}function Tn(e,t){try{t===``?localStorage.removeItem(Cn+e):localStorage.setItem(Cn+e,t)}catch{}}function En({item:e,workflows:t,skills:n,workflow:i,onWorkflowChange:a,selectedSkills:o,onSkillsChange:l,engine:u,onEngineChange:d,queuedRunId:p,onQueued:h}){let g=C(),_=m(),y=e.kind===`pr`?`PR`:`issue`,b=pn(u),x=s(b.runner,b.account),S=o.filter(e=>x.unchecked||e.path===void 0||n.some(t=>t.id===e.id&&(e.path===void 0||t.path===e.path))),w=S.length!==o.length,[D]=(0,X.useState)(()=>an(e)),[k,A]=(0,X.useState)(()=>wn(e.url)||D),j=(0,X.useRef)(null),M=(0,X.useRef)(null);(0,X.useEffect)(()=>{Tn(e.url,k===D?``:k)},[e.url,k,D]);let N=(0,X.useMemo)(()=>Ze(_.data?.promptTemplates),[_.data?.promptTemplates]),ee=e=>{let t=j.current,n=Xe({prompt:k,base:D,selectionStart:t?.selectionStart??null,focused:document.activeElement===t,remembered:M.current}),r=Oe(k,n,e);A(r.text),M.current=r.caret,requestAnimationFrame(()=>{j.current?.focus(),j.current?.setSelectionRange(r.caret,r.caret)})},P=ze(N,S.map(e=>e.id)),F=(0,X.useRef)(k);F.current=k;let I=(0,X.useRef)(``);(0,X.useEffect)(()=>{let e=Je(F.current,I.current,P,D);I.current=e.applied,e.text!==F.current&&A(e.text)},[P,D]);let L=f({mutationFn:async()=>!b.canRun||w?null:E(fn(e,i,S,k,hn(b))),onSuccess:t=>{if(t===null)return;let n=t;n&&h(e.url,n.id),T(`Added to the queue — ${y} #${e.number}`),S.length>0&&_.data!==void 0&&v({skillUsage:S.reduce((e,t)=>Ee(e,t.id),_.data.skillUsage)}).then(()=>g.invalidateQueries({queryKey:c.uiState})).catch(()=>{}),Tn(e.url,``),A(D),I.current=``,g.invalidateQueries({queryKey:c.runs.all})},onError:e=>T(e.message,{tone:`danger`})}),te=e=>{Ue({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(),!L.isPending&&b.canRun&&L.mutate())},R=e=>l(o.some(t=>W(t)===W(e))?o.filter(t=>W(t)!==W(e)):[...o,Te(e)]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`section`,{"data-slot":`gh-hand`,className:`mt-7 rounded-lg border border-border bg-card p-4`,children:[(0,Z.jsx)(`h3`,{className:`text-xl font-normal text-foreground`,children:`Hand this to the agent`}),(0,Z.jsxs)(`label`,{className:`gh-field gh-prompt-field`,children:[(0,Z.jsx)(`span`,{children:`Instructions for the agent`}),(0,Z.jsx)($e,{ref:j,"data-slot":`gh-custom-prompt`,"aria-label":`Custom prompt`,"aria-keyshortcuts":`Control+Enter Meta+Enter`,value:k,onChange:e=>A(e.target.value),onSelect:e=>{M.current=e.currentTarget.selectionStart},onKeyDown:te,placeholder:`Instructions for the agent… (#${e.number} and its link are always sent)`,className:`mt-3 min-h-20 text-[13px]`})]}),(0,Z.jsx)(Me,{templates:N,onInsert:ee}),(0,Z.jsxs)(`div`,{className:`gh-handoff-settings`,children:[(0,Z.jsxs)(`div`,{className:`gh-field`,children:[(0,Z.jsx)(`span`,{children:`Workflow`}),(0,Z.jsx)(On,{workflows:t,value:i,onChange:a})]}),(0,Z.jsxs)(`div`,{className:`gh-field`,children:[(0,Z.jsx)(`span`,{children:`Skills · select one or more`}),(0,Z.jsx)(An,{skills:n,skillUsage:_.data?.skillUsage,selected:o,onToggle:R})]}),o.length>0?(0,Z.jsx)(`div`,{"data-slot":`gh-skill-chips`,className:`mt-2.5 flex flex-wrap gap-1.5`,children:o.map(e=>(0,Z.jsx)(Dn,{skill:e,skills:n,unchecked:x.unchecked,onRemove:()=>R(e)},W(e)))}):null,w?(0,Z.jsx)(`p`,{role:`alert`,children:`A selected skill path is unavailable. Remove it or choose a current copy before starting.`}):null,(0,Z.jsx)(_n,{layout:`row`,pick:u,onChange:d,disabled:L.isPending||!b.canRun,accounts:!0}),(0,Z.jsxs)(`div`,{className:`gh-field`,children:[(0,Z.jsx)(`span`,{children:`Account`}),(0,Z.jsx)(kn,{resolved:b,disabled:L.isPending||!b.canRun,onPick:e=>d({...u,account:e})})]}),!b.providerPending&&!b.canRun?(0,Z.jsxs)(`span`,{"data-slot":`gh-provider-gate`,className:`inline-flex flex-wrap items-center gap-1 text-xs text-muted-foreground`,children:[b.providerError?`Provider authentication could not be verified.`:`Connect an agent provider to run this item.`,(0,Z.jsx)(V,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null]}),(0,Z.jsxs)(`p`,{className:`text-xs 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,Z.jsxs)(`div`,{"data-slot":`gh-handoff-actions`,className:`mt-[22px] flex flex-wrap items-center gap-2.5`,children:[r(e.url)?(0,Z.jsx)(B,{asChild:!0,variant:`outline`,children:(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:`Open in GitHub`})}):null,(0,Z.jsxs)(B,{variant:`primary`,"data-action":`gh-run`,disabled:L.isPending||!b.canRun||w,onClick:()=>L.mutate(),children:[(0,Z.jsx)(se,{"aria-hidden":`true`,className:`size-3.5`}),`Run agent on this `,y]}),(0,Z.jsx)(`kbd`,{"aria-hidden":`true`,className:`rounded-[5px] border border-b-2 border-border bg-card px-[5px] py-px font-mono text-xs font-medium text-muted-foreground`,children:He()}),p?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{"data-slot":`gh-queued`,className:`flex items-center gap-1 text-xs font-medium text-success`,children:[(0,Z.jsx)(O,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`queued`]}),(0,Z.jsx)(V,{to:`/tasks/${p}`,"data-slot":`gh-view-run`,className:`text-xs font-semibold text-accent-text hover:underline`,children:`View task →`})]}):null]})]})}function Dn({skill:e,skills:t,unchecked:n,onRemove:r}){let i=t.find(t=>t.id===e.id&&(e.path===void 0||t.path===e.path)),a=[i?.name??e.id,e.path].filter(Boolean).join(` · `),o=!n&&e.path!==void 0&&!i?` (unavailable)`:n||!i?` (unchecked)`:``;return(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-skill-chip`,"data-skill":e.id,onClick:r,title:`Remove skill ${a}`,"aria-label":`Remove skill ${a}`,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:[a,o,(0,Z.jsx)(A,{size:16,"aria-hidden":`true`,className:`size-3`})]})}function On({workflows:e,value:t,onChange:n}){let[r,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(``),c=(0,X.useRef)(null),l=xe(e,o);return(0,Z.jsxs)(ue,{open:r,onOpenChange:e=>{a(e),e||s(``)},children:[(0,Z.jsx)(ce,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-workflow-trigger`,"aria-label":`Choose a workflow`,className:i(Ye,t&&`border-foreground/60 font-mono text-xs font-semibold text-foreground`),children:[(0,Z.jsx)(R,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),(0,Z.jsx)(`span`,{className:`min-w-0 max-w-44 truncate`,children:t??`workflow`}),(0,Z.jsx)(ee,{size:16,"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Z.jsx)(le,{align:`start`,sideOffset:8,className:`w-[320px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Z.jsxs)(be,{shouldFilter:!1,children:[(0,Z.jsx)(_e,{placeholder:`Search workflows…`,value:o,onValueChange:s,onInput:()=>c.current?.scrollTo(0,0)}),(0,Z.jsxs)(ye,{ref:c,"data-slot":`gh-workflow-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[l.length===0?(0,Z.jsx)(ve,{children:`Nothing matches.`}):null,(0,Z.jsx)(H,{children:l.map(e=>{let r=t===e.name;return(0,Z.jsxs)(U,{value:`workflow ${e.name}`,keywords:we(e.name,e.description),"data-slot":`gh-workflow-option`,"data-workflow":e.name,onSelect:()=>{n(r?null:e.name),a(!1)},children:[(0,Z.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),e.description?(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,r?(0,Z.jsx)(O,{size:16,"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},e.name)})})]})]})})]})}function kn({resolved:e,disabled:t,onPick:n}){let r=e.accounts.filter(t=>t.provider===e.runner),i=[...r.some(e=>e.id==="default")?[]:[{value:b,label:`Default`}],...r.map(e=>({value:e.id,label:e.label,...e.configDir?{desc:e.configDir}:{}}))],a=e.account??e.repoAccount?.[e.runner]??`default`;return(0,Z.jsx)(K,{icon:(0,Z.jsx)(k,{"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 An({skills:e,skillUsage:t,selected:n,onToggle:r}){let[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(null),d=(0,X.useRef)(null),{mostUsed:f,project:p,global:m,ranked:h}=De(e,s,t),g=(e,t)=>{let a=n.some(t=>W(t)===W(e));return(0,Z.jsxs)(U,{value:W(e),keywords:we(e.name,e.description),"data-slot":`gh-skill-option`,"data-skill":e.id,"data-selected":a?`true`:void 0,onSelect:()=>r(Te(e)),children:[(0,Z.jsx)(`span`,{className:i(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.path?(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-xs`,children:e.path}):null,e.description?(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,(0,Z.jsx)(`button`,{type:`button`,"data-slot":`gh-skill-view`,"aria-label":`View skill ${e.name}`,title:`View skill`,onClick:t=>{t.preventDefault(),t.stopPropagation(),u(e)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,Z.jsx)(ie,{"aria-hidden":`true`,className:`size-3.5`})}),a?(0,Z.jsx)(O,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},W(e))};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Be,{skill:l,onClose:()=>u(null)}),(0,Z.jsxs)(ue,{open:a,onOpenChange:e=>{o(e),e||c(``)},children:[(0,Z.jsx)(ce,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-skills-trigger`,"aria-label":`Choose skills`,className:i(Ye,n.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,Z.jsx)(L,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),`skills`,n.length>0?` · ${n.length}`:``,(0,Z.jsx)(ee,{size:16,"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Z.jsx)(le,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Z.jsxs)(be,{shouldFilter:!1,children:[(0,Z.jsx)(_e,{placeholder:`Search skills…`,value:s,onValueChange:c,onInput:()=>d.current?.scrollTo(0,0)}),(0,Z.jsxs)(ye,{ref:d,"data-slot":`gh-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[s.trim()&&!e.some(e=>e.id===s.trim())?(0,Z.jsx)(H,{children:(0,Z.jsxs)(U,{value:`typed-skill`,onSelect:()=>r({id:s.trim()}),children:[`Use skill id “`,s.trim(),`” (unchecked)`]})}):null,(h?h.length===0:f.length===0&&p.length===0&&m.length===0)?(0,Z.jsx)(ve,{children:`Nothing matches.`}):null,h?h.length>0?(0,Z.jsx)(H,{children:h.map(e=>g(e,Se(e)))}):null:(0,Z.jsxs)(Z.Fragment,{children:[f.length>0?(0,Z.jsx)(H,{heading:`Most used`,children:f.map(e=>g(e,Se(e)))}):null,p.length>0?(0,Z.jsx)(H,{heading:`Project skills`,children:p.map(e=>g(e,!0))}):null,m.length>0?(0,Z.jsx)(H,{heading:`Global`,children:m.map(e=>g(e,!1))}):null]})]})]})})]})]})}var jn=new WeakMap;function Mn(){let e=xn(),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)&&Sn({workflow:t.workflow,skills:[...t.selectedSkills]}),n.forEach(e=>e())}}}function Nn(){let e=C(),{projectId:t}=S(),n=jn.get(e);n||jn.set(e,n=new Map);let r=n.get(t);r||n.set(t,r=Mn());let{snapshot:i,subscribe:o,update:c}=r,l=(0,X.useSyncExternalStore)(o,i,i),u=a(),d=pn(l.engine),f=s(d.runner,d.account),p=m(),h=u.data?.workflows;(0,X.useEffect)(()=>{h&&l.workflow!==null&&!h.some(e=>e.name===l.workflow)&&c({workflow:null})},[c,h,l.workflow]);let g=(0,X.useMemo)(()=>Ce(f.data??[],p.data?.skillUsage),[f.data,p.data?.skillUsage]);return{...l,workflows:u,skillList:g,skillsUnchecked:f.unchecked,setWorkflow:e=>c({workflow:e}),setSelectedSkills:e=>c({selectedSkills:e}),setEngine:e=>c({engine:e}),onQueued:(e,t)=>c({queued:new Map(i().queued).set(e,t)})}}export{tn as a,Rt as c,St as d,xt as f,rn as i,yt as l,En as n,Nt as o,on as r,Ct as s,Nn as t,bt as u};