@pi-chamber/web 1.0.8-rc.3 → 1.0.8-rc.4

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 (102) hide show
  1. package/dist/assets/{AgentsSurface-wsW9VCRp.js → AgentsSurface-DbCBygRD.js} +1 -1
  2. package/dist/assets/{ChoicesArtifact-EwCf4Yxu.js → ChoicesArtifact-DUqhCvXh.js} +1 -1
  3. package/dist/assets/{DiagramView-BX6N99cQ.js → DiagramView-CnVOyJd2.js} +1 -1
  4. package/dist/assets/{DiffView-CI0eSnPP.js → DiffView-Db8JXsvA.js} +1 -1
  5. package/dist/assets/{FileSaveConflictDialog-GLj2W7VE.js → FileSaveConflictDialog-D6xyf709.js} +1 -1
  6. package/dist/assets/{FilesView-CI0tfZQL.js → FilesView-Cir0Wl9F.js} +1 -1
  7. package/dist/assets/{GitHubDetailScaffold-B85tZ9m7.js → GitHubDetailScaffold-US37Di_K.js} +1 -1
  8. package/dist/assets/{GitHubLinkPicker-Y6AuNiGl.js → GitHubLinkPicker-k_D-sk-e.js} +1 -1
  9. package/dist/assets/{GitHubListPrimitives-BJHBud6i.js → GitHubListPrimitives-DuUXrJGk.js} +1 -1
  10. package/dist/assets/{GitView-DueE69kW.js → GitView-BdX_3XRr.js} +3 -3
  11. package/dist/assets/{IssuesSurface-Cg-xkdIu.js → IssuesSurface-Cw93HC0G.js} +2 -2
  12. package/dist/assets/{JsonTreeView-Cvg6lc40.js → JsonTreeView-Bze4htWt.js} +1 -1
  13. package/dist/assets/{MarkdownRendererImpl-DExPx-QM.js → MarkdownRendererImpl-Ch7NDkF9.js} +1 -1
  14. package/dist/assets/{PatchDiff-_c3HZ34I.js → PatchDiff-l68Yz45X.js} +1 -1
  15. package/dist/assets/{PierreDiffViewer-CZnaqO-_.js → PierreDiffViewer-BHBySiXQ.js} +1 -1
  16. package/dist/assets/{PullRequestsSurface-C9AYPiwo.js → PullRequestsSurface-CGD4_ljc.js} +2 -2
  17. package/dist/assets/{SessionSwitcherContent-DOpnN-8S.js → SessionSwitcherContent-DqP8OWzB.js} +1 -1
  18. package/dist/assets/{SessionSwitcherDropdown-CmHMPZ69.js → SessionSwitcherDropdown-BkTg-cVd.js} +2 -2
  19. package/dist/assets/{SessionUnreadDot-CZCQ4t1J.js → SessionUnreadDot-CgvC3F5e.js} +1 -1
  20. package/dist/assets/{SettingsView-D5PO5M3z.js → SettingsView-CkIxCYhs.js} +3 -3
  21. package/dist/assets/{SettingsWindow-DXV5UOE8.js → SettingsWindow-DSdhzapT.js} +1 -1
  22. package/dist/assets/{SubagentsArtifact-CO1ZiI1x.js → SubagentsArtifact-BN3aX_8M.js} +1 -1
  23. package/dist/assets/{ToolOutputDialog-GOwNLj-y.js → ToolOutputDialog-CLwm4TjA.js} +1 -1
  24. package/dist/assets/{ToolPartDiffPreview-BoaiZji6.js → ToolPartDiffPreview-ERAStEKA.js} +1 -1
  25. package/dist/assets/{VirtualizedFileDiff-Chq1X8nw.js → VirtualizedFileDiff-DwR2fZHv.js} +1 -1
  26. package/dist/assets/{VisualFrame-u7aRcX7O.js → VisualFrame-Dwp7B_st.js} +1 -1
  27. package/dist/assets/{VisualsArtifact-D9vPjihW.js → VisualsArtifact-DlOxifHd.js} +1 -1
  28. package/dist/assets/{collapsible-BjpDEohv.js → collapsible-CW-_qd6v.js} +1 -1
  29. package/dist/assets/{computeVirtualFileMetrics-DmPCxbok.js → computeVirtualFileMetrics-SlBfr8LB.js} +1 -1
  30. package/dist/assets/{contextFileOpenGuard-CukNcUeY.js → contextFileOpenGuard-CHoFT50j.js} +1 -1
  31. package/dist/assets/{fileTreeStatus-CDyfNPYO.js → fileTreeStatus-D0uiC1D0.js} +1 -1
  32. package/dist/assets/{gitStatusPredicates-uI7Y7L5k.js → gitStatusPredicates-Bj3pkh2e.js} +1 -1
  33. package/dist/assets/{githubLink-B9Mxac4R.js → githubLink-CheLNuP0.js} +1 -1
  34. package/dist/assets/{index-BxKPJ9uG.js → index-BFkW-BPM.js} +3 -3
  35. package/dist/assets/{index-BWq2ibCw.js → index-C8zaLvup.js} +1 -1
  36. package/dist/assets/{main-ckQ0ciIN.js → main-CUEqZRu1.js} +2 -2
  37. package/dist/assets/{main-CWfC-9xT.js → main-V66ie29o.js} +4 -4
  38. package/dist/assets/{markdownCore-p2q2Kxwo.js → markdownCore-BRedKgCo.js} +1 -1
  39. package/dist/assets/{miniChat-x2TrwRYA.js → miniChat-BXwuEQhz.js} +2 -2
  40. package/dist/assets/{mobile-B0x2G8h1.js → mobile-7s-xLDG3.js} +2 -2
  41. package/dist/assets/{nativeFileSave-D542OJlG.js → nativeFileSave-Bj-V_9ae.js} +1 -1
  42. package/dist/assets/{pi-session-focus-preference-Q_RZUCnt.js → pi-session-focus-preference-clbekCjz.js} +1 -1
  43. package/dist/assets/{renderDiffWithHighlighter-CSFGSknx.js → renderDiffWithHighlighter-g9eKWi78.js} +1 -1
  44. package/dist/assets/{renderElectronMiniChatApp-CFIdesZT.js → renderElectronMiniChatApp-B6BN8YgC.js} +2 -2
  45. package/dist/assets/{renderFileWithHighlighter-C5JE0mRX.js → renderFileWithHighlighter-DKl6vubK.js} +1 -1
  46. package/dist/assets/{renderMobileApp-B1ybjcGM.js → renderMobileApp-Bp735rW7.js} +3 -3
  47. package/dist/assets/{runtimeEndpointReset-DyZSKCYM.js → runtimeEndpointReset-CtHv_OMT.js} +7 -7
  48. package/dist/assets/{runtimeSurface-BR_dhe7_.js → runtimeSurface-DD4Vn4HC.js} +1 -1
  49. package/dist/assets/{selection-CfOpW4rA.js → selection-DDT954wY.js} +1 -1
  50. package/dist/assets/useAppFontEffects-DJCrUN2D.js +226 -0
  51. package/dist/assets/{useGitHubRemoteSearch-M1AE2YuX.js → useGitHubRemoteSearch-B77fMiwQ.js} +1 -1
  52. package/dist/assets/{useSwitcherItems-D0i2BYYP.js → useSwitcherItems-CFY3mP06.js} +1 -1
  53. package/dist/assets/{web-components-wOQkOurQ.js → web-components-XIP_3VZv.js} +1 -1
  54. package/dist/index.html +3 -3
  55. package/dist/mini-chat.html +2 -2
  56. package/dist/mobile.html +2 -2
  57. package/package.json +2 -1
  58. package/pichamber.d.ts +139 -0
  59. package/plugins/subagents/extension.js +5 -5
  60. package/plugins/subagents/package.json +3 -2
  61. package/plugins/visuals/choices.js +8 -7
  62. package/plugins/visuals/extension.js +4 -4
  63. package/plugins/visuals/package.json +1 -1
  64. package/server/lib/marketplace/DOCUMENTATION.md +2 -2
  65. package/server/lib/marketplace/npm-registry.js +1 -1
  66. package/server/lib/marketplace/npm-registry.test.js +1 -1
  67. package/server/lib/marketplace/service.test.js +4 -4
  68. package/server/lib/open-url/DOCUMENTATION.md +1 -1
  69. package/server/lib/pi/extension-card.js +48 -0
  70. package/server/lib/pi/extension-card.test.js +35 -0
  71. package/server/lib/pi/extension-commands.js +49 -0
  72. package/server/lib/pi/extension-commands.test.js +38 -0
  73. package/server/lib/pi/extension-protocol.js +1 -2
  74. package/server/lib/pi/fixtures/pichamber-gui-demo.ts +52 -223
  75. package/server/lib/pi/routes-extension-events.test.js +35 -48
  76. package/server/lib/pi/routes.js +44 -54
  77. package/server/lib/pi/routes.test.js +32 -0
  78. package/server/lib/pi/session-daemon/DOCUMENTATION.md +7 -7
  79. package/server/lib/pi/session-daemon/extension-bridge-draft.test.js +0 -54
  80. package/server/lib/pi/session-daemon/extension-bridge.js +39 -162
  81. package/server/lib/pi/session-daemon/extension-controls.js +12 -57
  82. package/server/lib/pi/session-daemon/extension-controls.test.js +4 -34
  83. package/server/lib/pi/session-daemon/pichamber-api.js +38 -0
  84. package/server/lib/pi/session-daemon/pichamber-api.test.js +24 -0
  85. package/server/lib/pi/session-daemon/plugin-host.js +5 -7
  86. package/server/lib/pi/session-daemon/plugin-host.test.js +2 -3
  87. package/server/lib/pi/session-daemon/session-daemon-controls.e2e.test.js +53 -7
  88. package/server/lib/pi/session-daemon/session-daemon-drafts.e2e.test.js +5 -5
  89. package/server/lib/pi/session-daemon/session-daemon-extensions.e2e.test.js +9 -4
  90. package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +28 -71
  91. package/server/lib/pi/session-daemon/session-daemon-plugins.e2e.test.js +1 -1
  92. package/server/lib/pi/session-daemon/session-daemon.js +138 -78
  93. package/server/lib/pi/session-daemon/session-daemon.test.js +68 -0
  94. package/server/lib/plugins/DOCUMENTATION.md +3 -3
  95. package/server/lib/plugins/impact.js +2 -4
  96. package/server/lib/plugins/impact.test.js +0 -1
  97. package/server/lib/plugins/manifest.js +9 -5
  98. package/server/lib/plugins/manifest.test.js +5 -4
  99. package/server/lib/plugins/store.test.js +1 -1
  100. package/server/lib/plugins/visuals-extension.test.js +16 -14
  101. package/dist/assets/useAppFontEffects-COMvkffC.js +0 -226
  102. package/server/lib/pi/session-daemon/pichamber-ui.js +0 -44
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/useAppFontEffects-COMvkffC.js","assets/index-BxKPJ9uG.js","assets/vendor-zustand-CXhN0IMY.js","assets/vendor-react-Bz1tRBxM.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-BKkUfl9q.js","assets/vendor-fuse.js-t_7AcMTv.js","assets/index-C5JgjS20.css","assets/vendor-boot-D-KEJjsM.js","assets/runtimeSurface-BR_dhe7_.js","assets/nativeFileSave-D542OJlG.js"])))=>i.map(i=>d[i]);
2
- import{_ as Ne}from"./vendor-vite-runtime-DD1OZmLC.js";import{j as e,aY as We,aZ as Ye,a_ as Qe,a$ as Xe,b0 as Ze}from"./vendor-boot-D-KEJjsM.js";import{R as o}from"./vendor-react-Bz1tRBxM.js";import{h as le,k as Le,u as mt,e as ht,f as ft,l as xt,m as pt,n as gt,r as bt,o as et,t as vt,g as ce,G as yt,a as jt,p as wt,c as kt,d as Ct,i as Nt,j as St}from"./useGitHubRemoteSearch-M1AE2YuX.js";import{j as Ee,t as G,N as Rt,B as P,I as M,bi as Lt,f as tt,D as Me,h as ze,i as Ae,V as Et,W as Ft,af as Se,a0 as we,aY as Pt,aZ as Tt}from"./useAppFontEffects-COMvkffC.js";import{i as I,T as Mt,r as zt,j as At,k as Dt,g as $t,l as Gt,m as Ht,f as qt,n as De,p as It,q as Ot,t as Bt,v as _t,w as Ut,x as Vt,y as Kt,z as Jt}from"./runtimeEndpointReset-DyZSKCYM.js";import{z as Wt,A as Yt,B as Qt,C as Xt,D as st,E as Zt,F as es,H as ge,I as ts,q as ss,J as te,K as ns,L as as,M as ls,N as os,O as fe,u as is,i as rs,P as cs,b as ds,c as $e,j as ke,e as Ce,k as us,f as Ge,h as He,l as qe,m as nt,n as ms,p as Ie,Q as hs,v as fs,w as xs,x as ps,y as gs,R as be,S as he,T as bs,G as vs,U as ys,V as js,W as ws}from"./GitHubDetailScaffold-B85tZ9m7.js";import{c as xe,E as ks,s as Cs,u as Ns,A as Ss}from"./index-BxKPJ9uG.js";import{S as ve,d as Rs}from"./GitHubListPrimitives-BJHBud6i.js";import{P as Ls}from"./PierreDiffViewer-CZnaqO-_.js";import{c as Es,p as Fs}from"./vendor-zustand-CXhN0IMY.js";import"./vendor-clsx-B-dksMZM.js";import"./runtimeSurface-BR_dhe7_.js";import"./nativeFileSave-D542OJlG.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./SessionUnreadDot-CZCQ4t1J.js";/* empty css */import"./permissionStore-zIpxq9Pq.js";import"./vendor-dompurify-BGCr_sdL.js";import"./web-components-wOQkOurQ.js";import"./computeVirtualFileMetrics-DmPCxbok.js";import"./vendor-shiki-BEwTOAFg.js";import"./vendor-shikijs-core-Ck_OPM_T.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-DPFxvYtK.js";import"./vendor-hast-util-to-html-O3stl53j.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-C40bX6nM.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-DrfmQi8i.js";import"./vendor-pierre-theming-BO6EPniU.js";import"./vendor-shikijs-engine-javascript-DL394yyj.js";import"./vendor-oniguruma-to-es-DgwFOwdE.js";import"./vendor-oniguruma-parser-BrbMHgHx.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./VirtualizedFileDiff-Chq1X8nw.js";import"./renderDiffWithHighlighter-CSFGSknx.js";import"./vendor-diff-C3JhlQdm.js";import"./StickyHorizontalScrollbar-CMbTn5WQ.js";import"./appThemeRegistry-Ca8eGRB9.js";import"./registerCustomTheme-C-h6lsYW.js";const Fe=()=>{const t=Ee(),[s,n]=o.useState(null);return{send:o.useCallback(async l=>{const d=t.github;if(!d)return G.error("GitHub is not available in this runtime"),!1;n(l.key);try{const c=await d.agentContext(l.directory,l.repo,l.contextType,l.number,l.contextOptions),r=Wt({kind:l.kind,repo:l.repo,number:l.number,detail:l.detail}),f=Yt({kind:l.kind,repo:l.repo,number:l.number,contextText:c.text}),x=Rt.getState();x.setPendingInputText(r,"append");const k=x.pendingSyntheticParts??[];return x.setPendingSyntheticParts([...k,{text:f,synthetic:!0}]),G.success("Added to composer"),!0}catch(c){return G.error(c instanceof Error?c.message:"Failed to fetch GitHub context"),!1}finally{n(null)}},[t.github]),sendingKey:s}},Ps=800,Ts=3,Pe={added:{icon:"add-circle",letter:"A",tint:"text-[var(--status-success)]"},removed:{icon:"subtract",letter:"D",tint:"text-[var(--status-error)]"},modified:{icon:"pencil",letter:"M",tint:"text-[var(--status-warning)]"},renamed:{icon:"expand-up-down",letter:"R",tint:"text-[var(--status-info)]"},other:{icon:"file",letter:"•",tint:"text-muted-foreground"}},at=t=>{switch((t??"").toLowerCase()){case"added":return"added";case"removed":return"removed";case"modified":return"modified";case"renamed":return"renamed";default:return"other"}},lt=t=>Pe[t].icon,Ms=t=>Pe[t].letter,Re=t=>Pe[t].tint,ot=t=>{const s=t.lastIndexOf("/");return s<0?{dir:"",base:t}:{dir:t.slice(0,s),base:t.slice(s+1)}},it=t=>{const s=typeof t.additions=="number"?t.additions:0,n=typeof t.deletions=="number"?t.deletions:0;return s!==0||n!==0?s+n:typeof t.changes=="number"?t.changes:0},rt=t=>it(t)>Ps,zs=t=>{const s=new Map;for(const a of t){const l=a.filename.lastIndexOf("/"),d=l<0?"":a.filename.slice(0,l),c=s.get(d);c?c.push(a):s.set(d,[a])}const n=[...s.entries()].map(([a,l])=>({folder:a,files:[...l].sort((d,c)=>d.filename.localeCompare(c.filename,void 0,{sensitivity:"base"}))}));return n.sort((a,l)=>a.folder===""?1:l.folder===""?-1:a.folder.localeCompare(l.folder,void 0,{sensitivity:"base"})),n},As=t=>{let s=0,n=0;for(const a of t)s+=typeof a.additions=="number"?a.additions:0,n+=typeof a.deletions=="number"?a.deletions:0;return{additions:s,deletions:n}},Ds=t=>{const s={};return t.forEach((n,a)=>{s[n.filename]=a>=Ts||rt(n)}),s},$s=(t,s,n)=>{if(!s)return null;const a=t.split("/");if(a.length!==3||a.some(r=>r.length===0))return null;const[l,d,c]=a;return`https://${l}/${d}/${c}/blob/${s}/${n}`},Gs=({comment:t,onRemove:s})=>e.jsxs("div",{className:"rounded-md border border-dashed border-border p-2.5 typography-ui text-foreground",contentEditable:!1,onPointerDown:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(M,{name:"chat-1",className:"size-3.5 shrink-0","aria-hidden":"true"}),e.jsx("span",{children:"Pending — sent when you submit the review"}),e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Discard this comment",title:"Discard this comment",onClick:s,className:"ml-auto size-6",children:e.jsx(M,{name:"delete-bin",className:"size-3.5"})})]}),e.jsx("p",{className:"mt-1.5 whitespace-pre-wrap break-words",children:t.body})]}),Oe=({thread:t,replyAllowed:s,replyDisabledReason:n,resolveAllowed:a,resolveDisabledReason:l,busy:d,onReply:c,onToggleResolved:r})=>{const[f,x]=o.useState(!t.resolved),[k,m]=o.useState(!1),[g,p]=o.useState(""),[z,F]=o.useState(!1),L=t.comments.length,j=async()=>{const b=g.trim();if(!(b.length===0||z||d)){F(!0);try{await c(b)&&(p(""),m(!1))}finally{F(!1)}}};return e.jsxs("div",{className:"rounded-md border border-border/60 bg-[var(--surface-elevated)] p-2.5 typography-ui text-foreground",contentEditable:!1,onPointerDown:b=>b.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(M,{name:t.resolved?"check":"chat-1",className:xe("size-3.5 shrink-0",t.resolved?"text-[var(--status-success)]":""),"aria-hidden":"true"}),e.jsxs("button",{type:"button",className:"hover:text-foreground","aria-expanded":f,onClick:()=>x(b=>!b),children:[t.resolved?"Resolved":"Open"," · ",L," ",L===1?"comment":"comments"]}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"ml-auto",disabled:!a||d,title:l??(t.resolved?"Reopen this conversation":"Resolve this conversation"),"aria-label":t.resolved?"Reopen conversation":"Resolve conversation",onClick:r,children:t.resolved?"Unresolve":"Resolve"})]}),f?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 flex flex-col gap-2",children:t.comments.map((b,i)=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"typography-micro text-muted-foreground",children:b.author?.login??"ghost"}),e.jsx(ss,{markdown:b.body,html:b.bodyHtml??null,fallbackUrl:b.url})]},b.id??`${t.id}-${i}`))}),s?k?e.jsxs("div",{className:"mt-2",children:[e.jsx("textarea",{autoFocus:!0,value:g,rows:2,placeholder:"Reply","aria-label":"Reply to this conversation",disabled:z||d,onChange:b=>p(b.target.value),onKeyDown:b=>{b.nativeEvent.isComposing||(b.key==="Escape"&&(b.preventDefault(),m(!1)),b.key==="Enter"&&(b.metaKey||b.ctrlKey)&&!b.shiftKey&&!b.altKey&&!b.repeat&&(b.preventDefault(),b.stopPropagation(),j()))},className:"min-h-12 w-full rounded-md border border-border bg-[var(--surface-elevated)] p-2 typography-ui text-foreground"}),e.jsxs("div",{className:"mt-1.5 flex justify-end gap-1.5",children:[e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>m(!1),children:"Cancel"}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:z||d||g.trim().length===0,onClick:()=>{j()},children:z?"Replying…":"Reply"})]})]}):e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"mt-2",onClick:()=>m(!0),children:"Reply"}):n?e.jsxs("p",{className:"mt-2 typography-micro text-muted-foreground",title:n,children:["Reply unavailable — ",n.charAt(0).toLowerCase()+n.slice(1)]}):null]}):null]})},Hs=({path:t,line:s,sendingToAgent:n,onCancel:a,onAddToReview:l,onSendToAgent:d})=>{const[c,r]=o.useState(""),f=o.useRef(null),x=c.trim();o.useLayoutEffect(()=>{const m=window.requestAnimationFrame(()=>{f.current?.focus({preventScroll:!0})});return()=>window.cancelAnimationFrame(m)},[]);const k=()=>{x&&l(x)};return e.jsxs("div",{className:"rounded-md border border-border/60 bg-[var(--surface-elevated)] p-2.5",contentEditable:!1,onPointerDown:m=>m.stopPropagation(),children:[e.jsxs("p",{className:"truncate font-mono typography-micro text-muted-foreground",title:`${t}:${s}`,children:[t,":",s]}),e.jsx("textarea",{ref:f,value:c,rows:3,placeholder:"Add a comment…","aria-label":`Comment on ${t} line ${s}`,onChange:m=>r(m.target.value),onFocus:m=>{const g=m.currentTarget.value.length;m.currentTarget.setSelectionRange(g,g)},onKeyDown:m=>{m.nativeEvent.isComposing||(m.key==="Escape"&&(m.preventDefault(),a()),m.key==="Enter"&&(m.metaKey||m.ctrlKey)&&!m.shiftKey&&!m.altKey&&!m.repeat&&(m.preventDefault(),m.stopPropagation(),k()))},className:"mt-1.5 min-h-16 w-full rounded-md border border-border bg-[var(--surface-elevated)] p-2 typography-ui text-foreground"}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"mr-auto typography-micro text-muted-foreground",children:"Ctrl/Cmd+Enter to add"}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:a,children:"Cancel"}),e.jsx(P,{type:"button",variant:"outline",size:"xs",disabled:!x||n,title:"Send this line to the agent",onClick:()=>d(x),children:n?"Sending…":"Send to agent"}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:!x,onClick:k,children:"Add to review"})]})]})},qs=({file:t,collapsed:s,onToggleCollapse:n,viewed:a,onToggleViewed:l,blobUrl:d,threads:c,directory:r,repo:f,number:x,github:k,access:m,onThreadsChanged:g})=>{const p=I(w=>w.threadAction),z=le(w=>w.removeComment),F=le(w=>w.addComment),L=Le(f,x),[j,b]=o.useState(null),[i,C]=o.useState(!1),{send:h,sendingKey:O}=Fe(),{original:N,modified:E}=o.useMemo(()=>Qt(t.patch),[t.patch]),T=o.useMemo(()=>Xt(t.patch),[t.patch]),B=`pr-${x}-file-${t.filename}`,V=st(m),S=Zt(m),D=es(m),K=o.useCallback(w=>{if(!w||!V.allowed)return;const H=(w.endSide??w.side??"additions")==="deletions"?"deletions":"additions",ie=H==="deletions"?T.syntheticToOld.get(w.end):T.syntheticToNew.get(w.end);if(ie==null){G.error("That line is outside the rendered hunks");return}b({synthLine:w.end,side:H,realLine:ie,realSide:H==="deletions"?"LEFT":"RIGHT"})},[V.allowed,T]),_=at(t.status),{dir:X,base:R}=ot(t.filename),q=rt(t),[y,de]=o.useState(!1),Q=q&&!y&&!a&&t.patch!=null,ee=c.filter(w=>!w.resolved).length,Z=o.useMemo(()=>L.filter(w=>w.path===t.filename),[L,t.filename]),{annotations:se,orphans:ne}=o.useMemo(()=>{const w=new Map,$=[],H=(A,U)=>{const W=`${A}:${U}`;let J=w.get(W);return J||(J={side:A,synthLine:U,threads:[],pendings:[]},w.set(W,J)),J};for(const A of c){const U=A.line??A.originalLine??null;if(U==null){$.push(A);continue}let W,J;if(A.diffSide==="LEFT"?(J="deletions",W=T.oldToSynthetic.get(U)):A.diffSide==="RIGHT"?(J="additions",W=T.newToSynthetic.get(U)):(W=T.newToSynthetic.get(U),J="additions",W==null&&(W=T.oldToSynthetic.get(U),J="deletions")),W==null){$.push(A);continue}H(J,W).threads.push(A)}for(const A of Z){if(A.line==null)continue;const U=A.side==="LEFT"?"deletions":"additions",W=U==="deletions"?T.oldToSynthetic.get(A.line):T.newToSynthetic.get(A.line);W!=null&&H(U,W).pendings.push(A)}return j&&H(j.side,j.synthLine),{annotations:[...w.values()].sort((A,U)=>A.synthLine-U.synthLine).map(A=>({side:A.side,lineNumber:A.synthLine,metadata:{threads:A.threads,pendings:A.pendings,draft:j&&j.side===A.side&&j.synthLine===A.synthLine?{realLine:j.realLine,realSide:j.realSide}:null}})),orphans:$}},[c,Z,j,T]),oe=o.useCallback(async(w,$)=>{const H=w.comments[w.comments.length-1]?.id??null;if(typeof H!="number")return G.error("Cannot reply to this thread yet"),!1;if(i)return!1;C(!0);try{return(await p(r,f,x,w.id,{action:"reply",body:$,commentId:H},k)).ok?(G.success("Reply posted"),g(),!0):(G.error("Failed to post reply"),!1)}finally{C(!1)}},[r,f,x,k,p,i,g]),ae=o.useCallback(w=>{i||(C(!0),p(r,f,x,w.id,w.resolved?{action:"unresolve"}:{action:"resolve"},k).then($=>{$.ok?(G.success(w.resolved?"Thread reopened":"Thread resolved"),g()):G.error("Failed to update thread")}).finally(()=>C(!1)))},[r,f,x,k,p,i,g]),ue=o.useCallback(w=>e.jsxs("div",{className:"flex flex-col gap-1.5 px-3 py-2",contentEditable:!1,onPointerDown:$=>$.stopPropagation(),children:[w.metadata.threads.map($=>e.jsx(Oe,{thread:$,replyAllowed:S.allowed,replyDisabledReason:S.reason,resolveAllowed:D.allowed,resolveDisabledReason:D.reason,busy:i,onReply:H=>oe($,H),onToggleResolved:()=>ae($)},$.id)),w.metadata.pendings.map($=>e.jsx(Gs,{comment:$,onRemove:()=>z(f,x,$.id)},$.id)),w.metadata.draft?e.jsx(Hs,{path:t.filename,line:w.metadata.draft.realLine,sendingToAgent:O===`${B}-draft-agent`,onCancel:()=>b(null),onAddToReview:$=>{const H=w.metadata.draft;H&&(F(f,x,{path:t.filename,body:$,line:H.realLine,side:H.realSide}),b(null),G.success("Added to review"))},onSendToAgent:$=>{const H=w.metadata.draft;H&&h({key:`${B}-draft-agent`,kind:"lines",directory:r,repo:f,number:x,contextType:"pr",contextOptions:{includeDiff:!0},detail:`${t.filename} line ${H.realLine} ("${$.trim()}")`})}}):null]}),[S.allowed,S.reason,D.allowed,D.reason,i,oe,ae,z,F,f,x,t.filename,B,O,r,h]);return e.jsxs("article",{className:"overflow-hidden rounded-md border border-border/60",children:[e.jsxs("div",{className:"sticky top-8 z-[5] flex items-center gap-1.5 bg-[var(--surface-muted)] px-2 py-1.5",children:[e.jsx(P,{type:"button",variant:"ghost",size:"icon",onClick:()=>n(t.filename),"aria-label":s?`Expand ${t.filename}`:`Collapse ${t.filename}`,title:s?"Expand":"Collapse",className:"size-6",children:e.jsx(M,{name:s?"arrow-right-s":"arrow-down-s",className:"size-4"})}),e.jsx(M,{name:lt(_),className:xe("size-3.5 shrink-0",Re(_)),"aria-hidden":"true"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono typography-micro",title:t.filename,children:[X?e.jsxs("span",{className:"text-muted-foreground",children:[X,"/"]}):null,e.jsx("span",{className:"text-foreground",children:R})]}),_!=="other"?e.jsx("span",{className:xe("shrink-0 rounded px-1 font-mono typography-micro",Re(_)),title:t.status??void 0,children:Ms(_)}):null,e.jsx(ge,{additions:t.additions,deletions:t.deletions,className:"typography-micro"}),c.length>0||Z.length>0?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-muted-foreground",title:`${c.length} ${c.length===1?"conversation":"conversations"}${Z.length>0?`, ${Z.length} pending`:""}`,children:[e.jsx(M,{name:"chat-1",className:"size-3.5","aria-hidden":"true"}),c.length>0?e.jsx("span",{className:"tabular-nums",children:ee>0?ee:c.length}):null,Z.length>0?e.jsxs("span",{className:"tabular-nums",children:["+",Z.length]}):null]}):null,e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",onClick:w=>w.stopPropagation(),children:[e.jsx(Lt,{checked:a,onChange:w=>l(t.filename,w),ariaLabel:a?`Mark ${t.filename} as not viewed`:`Mark ${t.filename} as viewed`}),e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Viewed"})]}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{h({key:`${B}-agent`,kind:"file",directory:r,repo:f,number:x,contextType:"pr",contextOptions:{includeDiff:!0},detail:t.filename})},disabled:O===`${B}-agent`,"aria-label":`Send ${t.filename} to agent`,children:"Send to agent"})]}),s?null:e.jsxs("div",{className:"flex flex-col gap-2 p-2",children:[ne.length>0?e.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md bg-[var(--surface-muted)] px-2 py-2",children:[e.jsxs("p",{className:"typography-micro text-muted-foreground",children:["Other conversations (",ne.length,") — ",ne.length===1?"this line is":"these lines are"," no longer in the diff"]}),ne.map(w=>e.jsx(Oe,{thread:w,replyAllowed:S.allowed,replyDisabledReason:S.reason,resolveAllowed:D.allowed,resolveDisabledReason:D.reason,busy:i,onReply:$=>oe(w,$),onToggleResolved:()=>ae(w)},w.id))]}):null,Q?e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-[var(--surface-muted)] px-3 py-3 typography-ui",children:[e.jsx(M,{name:"file",className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsxs("p",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:["Large diff — ",it(t)," changed lines"]}),e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>de(!0),children:"Load diff"})]}):t.patch?e.jsx("div",{className:"min-h-24 overflow-hidden",children:e.jsx(Ls,{original:N,modified:E,language:ts(t.filename),fileName:t.filename,renderSideBySide:!1,layout:"inline",enableGutterUtility:V.allowed&&j===null,enableLineSelection:V.allowed&&j===null,onGutterUtilityClick:K,onLineSelectionEnd:K,lineAnnotations:se,renderAnnotation:w=>ue(w)})}):e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-[var(--surface-muted)] px-3 py-3 typography-ui",children:[e.jsx(M,{name:"file",className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("p",{className:"min-w-0 flex-1 text-muted-foreground",children:"Diff not available for this file."}),d?e.jsx(P,{type:"button",variant:"link",size:"sm",asChild:!0,children:e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",children:"Open on GitHub"})}):null]})]})]})},Is=o.memo(qs),Os=({directory:t,repo:s,number:n,github:a,pr:l,access:d,onCommented:c})=>{const r=I(i=>i.addComment),f=I(i=>i.performAction),x=le(i=>i.clearCommentDraft),{draft:k,onDraftChange:m,flushDraft:g}=mt(s,n),{busy:p,error:z,submit:F}=ht({postComment:i=>r(t,s,n,i,a),runFollowUp:i=>f(t,s,n,i,a),verbs:{close:"close",reopen:"reopen"},doneLabels:{close:"Closed with comment",reopen:"Reopened with comment"},afterPost:()=>{m(""),x(s,n),c()}}),L=st(d),j=l.state==="open"?"close":l.state==="closed"?"reopen":null,b=j?te(j,l,d):null;return L.allowed?e.jsx(ft,{draft:k,onDraftChange:m,onDraftBlur:g,ariaLabel:"Leave a comment on this pull request",busy:p,error:z,disabledReason:L.reason,followUp:j?{id:j,label:j==="close"?"Close with comment":"Reopen with comment",busyLabel:j==="close"?"Closing…":"Reopening…",onRun:()=>{F(j,k)},allowed:b?.allowed===!0,reason:b?.reason}:null,onSubmitComment:()=>{F("comment",k)}}):null},Bs={comment:"Comment",approve:"Approve","request-changes":"Request changes"},_s=({repo:t,number:s,verdicts:n,summary:a,verdict:l,pendingCount:d,busy:c,textareaRef:r,onSubmit:f})=>{const x=le(p=>p.setSummary),k=le(p=>p.setVerdict),m=n.includes(l)?l:n[0]??"comment",g=as({verdict:m,summary:a,pendingCount:d});return e.jsxs("div",{children:[e.jsx(Mt,{ref:r,rows:3,value:a,placeholder:"Summarize your review (optional)","aria-label":"Review summary",disabled:c,onChange:p=>x(t,s,p.target.value),onKeyDown:p=>{p.nativeEvent.isComposing||p.key==="Enter"&&(p.metaKey||p.ctrlKey)&&!p.shiftKey&&!p.altKey&&!p.repeat&&(p.preventDefault(),p.stopPropagation(),g&&!c&&f())}}),e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[e.jsxs("label",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:"sr-only",children:"Review verdict"}),e.jsx("select",{value:m,disabled:c,onChange:p=>k(t,s,p.target.value),"aria-label":"Review verdict",className:"h-7 max-w-40 truncate rounded-md border border-border bg-[var(--surface-elevated)] px-1.5 typography-micro text-foreground",children:n.map(p=>e.jsx("option",{value:p,children:Bs[p]},p))})]}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:c||!g,title:g?`Submit review${d>0?` with ${d} ${d===1?"line comment":"line comments"}`:""}`:"Add a summary or a line comment first",onClick:f,children:c?"Submitting…":"Submit review"})]})]})},ct=({directory:t,repo:s,number:n,github:a,access:l,size:d="sm",onReviewSubmitted:c})=>{const r=I(T=>T.submitReview),f=le(T=>T.removeComments),x=le(T=>T.clearSummary),k=le(T=>T.clearComments),m=Le(s,n),g=xt(s,n),p=pt(s,n),[z,F]=o.useState(!1),[L,j]=o.useState(!1),b=o.useRef(null),i=o.useMemo(()=>ns(l),[l]),C=i.includes(p)?p:i[0]??"comment",h=m.length,O=h>0||g.trim().length>0;if(o.useEffect(()=>{if(!z)return;const T=window.requestAnimationFrame(()=>b.current?.focus({preventScroll:!0}));return()=>window.cancelAnimationFrame(T)},[z]),i.length===0)return null;const N=async()=>{if(L)return;const T=g,B=[...m];j(!0);try{const V=B.map(D=>({path:D.path,body:D.body,...D.line!=null?{line:D.line}:{},...D.side?{side:D.side}:{}})),S=await r(t,s,n,{event:C,body:T.trim()?T:void 0,comments:V},a);if(!S.ok){G.error(S.error?.kind==="failed"?S.error.message:"Failed to submit review");return}f(s,n,B.map(D=>D.id)),x(s,n,T),G.success(C==="approve"?"Pull request approved":C==="request-changes"?"Changes requested":"Review submitted"),F(!1),c?.()}finally{j(!1)}},E=h>0?`Review · ${h}`:"Review";return e.jsxs(We,{open:z,onOpenChange:F,children:[e.jsxs(Ye,{render:e.jsx(P,{type:"button",variant:h>0?"default":"outline",size:d,className:"shrink-0","aria-label":h>0?`Review pull request, ${h} ${h===1?"line comment":"line comments"} pending`:"Review pull request",title:O?"Finish your review":"Approve, request changes, or comment with a review"}),children:[e.jsx(M,{name:"file-check",className:"size-3.5","aria-hidden":"true"}),E]}),e.jsx(Qe,{children:e.jsx(Xe,{className:"z-50",side:"top",align:"end",sideOffset:8,collisionPadding:8,children:e.jsxs(Ze,{"aria-label":"Review pull request",className:"w-[min(24rem,calc(100vw-2rem))] rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-3 shadow-lg",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("p",{className:"min-w-0 truncate typography-ui-label text-foreground",children:h>0?`Review · ${h} ${h===1?"line comment":"line comments"}`:"Review pull request"}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[h>0?e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Discard pending line comments",title:"Discard pending line comments",disabled:L,onClick:()=>k(s,n),className:"size-6",children:e.jsx(M,{name:"delete-bin",className:"size-3.5"})}):null,e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Close review",onClick:()=>F(!1),className:"size-6",children:e.jsx(M,{name:"close",className:"size-3.5"})})]})]}),e.jsx(_s,{repo:s,number:n,verdicts:i,summary:g,verdict:C,pendingCount:h,busy:L,textareaRef:b,onSubmit:()=>{N()}})]})})})]})},ye=(t,s)=>`${t}#${s}`,Be=50,Us=Object.freeze([]),_e=(t,s)=>{const n=Object.keys(t);if(n.length<=Be)return t;const a={};for(const l of n.slice(n.length-Be))a[l]=t[l];if(!(s in a)&&s in t){const l=Object.keys(a)[0];delete a[l],a[s]=t[s]}return a},pe=Es()(Fs((t,s)=>({entries:{},setViewed:(n,a,l,d)=>{const c=ye(n,a);(s().entries[c]?.viewed.includes(l)??!1)!==d&&t(x=>{const k=x.entries[c]??{viewed:[],headSha:null},m=d?[...k.viewed,l]:k.viewed.filter(g=>g!==l);return{entries:_e({...x.entries,[c]:{...k,viewed:m}},c)}})},syncHeadSha:(n,a,l)=>{const d=ye(n,a),c=s().entries[d];c&&c.headSha===(l??null)||t(r=>({entries:_e({...r.entries,[d]:{viewed:[],headSha:l??null}},d)}))},resetForRuntimeSwitch:()=>t({entries:{}})}),{name:"pichamber:github-viewed-files",version:1,storage:ks(),partialize:t=>({entries:t.entries})}));typeof window<"u"&&Cs(()=>{pe.getState().resetForRuntimeSwitch()});const Vs=(t,s)=>pe(n=>n.entries[ye(t,s)]?.viewed??Us),Ks=(t,s)=>pe(n=>n.entries[ye(t,s)]?.viewed.length??0),Ue=20,Js=[],Ws=[],Ve=t=>`pr-file-${encodeURIComponent(t)}`,dt=o.memo(({file:t,viewed:s,threadCount:n,pendingCount:a,showDir:l,onSelectFile:d})=>{const c=at(t.status),{dir:r,base:f}=ot(t.filename);return e.jsxs("button",{type:"button",onClick:()=>d(t.filename),title:t.filename,"aria-label":`Go to ${t.filename}`,className:"flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-left hover:bg-interactive-hover",children:[e.jsx(M,{name:lt(c),className:xe("size-3.5 shrink-0",Re(c)),"aria-hidden":"true"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono typography-micro",children:[l&&r?e.jsxs("span",{className:"text-muted-foreground",children:[r,"/"]}):null,e.jsx("span",{className:"text-foreground",children:f})]}),e.jsx(ge,{additions:t.additions,deletions:t.deletions,className:"typography-micro"}),n>0?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-0.5 typography-micro text-muted-foreground",title:`${n} ${n===1?"conversation":"conversations"}`,children:[e.jsx(M,{name:"chat-1",className:"size-3","aria-hidden":"true"}),e.jsx("span",{className:"tabular-nums",children:n})]}):null,a>0?e.jsxs("span",{className:"shrink-0 tabular-nums typography-micro text-muted-foreground",title:`${a} pending`,children:["+",a]}):null,s?e.jsx(M,{name:"check",className:"size-3.5 shrink-0 text-[var(--status-success)]","aria-label":"Viewed"}):null]})});dt.displayName="FileJumpRow";const ut=({files:t,viewedPaths:s,threadCounts:n,pendingCounts:a,onSelectFile:l})=>{const[d,c]=o.useState(""),r=o.useMemo(()=>zs(t),[t]),f=o.useMemo(()=>new Set(s),[s]),x=d.trim().toLowerCase(),k=o.useMemo(()=>x?r.map(m=>({...m,files:m.files.filter(g=>g.filename.toLowerCase().includes(x))})).filter(m=>m.files.length>0):r,[r,x]);return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-1",children:[e.jsx(tt,{value:d,onChange:m=>c(m.target.value),placeholder:"Filter files","aria-label":"Filter files",className:"h-7 shrink-0 typography-micro"}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",role:"list","aria-label":"Changed files",children:k.length===0?e.jsx("p",{className:"px-1.5 py-2 typography-micro text-muted-foreground",children:t.length===0?"No changed files":"No files match"}):k.map(m=>e.jsxs("div",{role:"group","aria-label":m.folder||"Repository root",children:[r.length>1?e.jsx("p",{className:"truncate px-1.5 pt-1.5 pb-0.5 typography-micro text-muted-foreground",title:m.folder||"/",children:m.folder||"/"}):null,m.files.map(g=>e.jsx(dt,{file:g,viewed:f.has(g.filename),threadCount:n.get(g.filename)??0,pendingCount:a.get(g.filename)??0,showDir:r.length<=1,onSelectFile:l},g.filename))]},m.folder))})]})},Ys=t=>{const[s,n]=o.useState(!1),{onSelectFile:a}=t,l=o.useCallback(d=>{n(!1),a(d)},[a]);return e.jsxs(We,{open:s,onOpenChange:n,children:[e.jsxs(Ye,{render:e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"shrink-0","aria-label":`Jump to file, ${t.files.length} ${t.files.length===1?"file":"files"}`,title:"Jump to file"}),children:[e.jsx(M,{name:"file",className:"size-3.5","aria-hidden":"true"}),"Files"]}),e.jsx(Qe,{children:e.jsx(Xe,{className:"z-50",side:"bottom",align:"start",sideOffset:4,collisionPadding:8,children:e.jsx(Ze,{"aria-label":"Jump to file",className:"flex max-h-[min(28rem,calc(100dvh-4rem))] w-[min(22rem,calc(100vw-2rem))] flex-col rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-1.5 shadow-lg",children:e.jsx(ut,{...t,onSelectFile:l})})})})]})},Qs=48,Xs=(t,s)=>{const[n,a]=o.useState(null);return o.useLayoutEffect(()=>{if(!s)return;const l=t.current?.closest("[data-diff-virtual-root]");if(!(l instanceof HTMLElement))return;const d=()=>{const r=Math.max(160,Math.floor(l.clientHeight-Qs));a(f=>f===r?f:r)};if(d(),typeof ResizeObserver>"u")return;const c=new ResizeObserver(d);return c.observe(l),()=>c.disconnect()},[t,s]),n},Zs=t=>{const{directory:s,repo:n,number:a,github:l,access:d,headSha:c=null}=t,r=t.files?.files??Js,f=Vs(n,a),x=Ks(n,a),k=Le(n,a);o.useEffect(()=>{pe.getState().syncHeadSha(n,a,c)},[n,a,c]);const m=o.useMemo(()=>Ds(r),[r]),g=o.useRef(m);g.current=m;const p=o.useRef(r);p.current=r;const[z,F]=o.useState({}),[L,j]=o.useState(Ue),b=o.useMemo(()=>As(r),[r]),i=o.useMemo(()=>{const R=new Map;for(const q of t.threads){if(!q.path)continue;const y=R.get(q.path)??[];y.push(q),R.set(q.path,y)}return R},[t.threads]),C=o.useMemo(()=>{const R=new Map;for(const[q,y]of i)R.set(q,y.length);return R},[i]),h=o.useMemo(()=>{const R=new Map;for(const q of k)R.set(q.path,(R.get(q.path)??0)+1);return R},[k]),O=o.useCallback(R=>{F(q=>({...q,[R]:!(q[R]??g.current[R]??!1)}))},[]),N=o.useCallback(()=>{F(Object.fromEntries(p.current.map(R=>[R.filename,!1])))},[]),E=o.useCallback(()=>{F(Object.fromEntries(p.current.map(R=>[R.filename,!0])))},[]),T=o.useCallback((R,q)=>{pe.getState().setViewed(n,a,R,q),F(y=>({...y,[R]:q}))},[n,a]),B=o.useCallback(R=>{F(y=>y[R]??g.current[R]??!1?{...y,[R]:!1}:y);const q=p.current.findIndex(y=>y.filename===R);q>=0&&j(y=>q<y?y:q+1),requestAnimationFrame(()=>{document.getElementById(Ve(R))?.scrollIntoView({block:"start"})})},[]),V=o.useMemo(()=>r.slice(0,L),[r,L]),S=o.useRef(null),D=Xs(S,V.length>0),K=o.useMemo(()=>new Set(f),[f]),_=r.length===1?"1 file":`${r.length} files`,X=r.length===0?"Nothing viewed yet":`${x}/${r.length} viewed`;return e.jsxs("section",{"aria-label":"Changed files",className:"@container flex flex-col gap-2","data-diff-virtual-content":!0,children:[e.jsx(ve,{error:t.filesError,onRetry:t.onRetryFiles,label:"Changed files"}),e.jsx(ve,{error:t.threadsError,onRetry:t.onRetryDetail,label:"Review threads"}),e.jsxs("div",{className:"sticky top-0 z-10 flex h-8 shrink-0 items-center gap-2 border-b border-border/60 bg-[var(--surface-background)] px-1 text-[12px]",children:[e.jsx("span",{className:"shrink-0 text-muted-foreground",children:_}),e.jsx(ge,{additions:b.additions,deletions:b.deletions}),e.jsxs("span",{className:"shrink-0 tabular-nums text-muted-foreground","aria-label":X,children:[x,"/",r.length," viewed"]}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[e.jsx(ct,{directory:s,repo:n,number:a,github:l,access:d,size:"xs",onReviewSubmitted:t.onReviewSubmitted}),e.jsx("span",{className:"@4xl:hidden",children:e.jsx(Ys,{files:r,viewedPaths:f,threadCounts:C,pendingCounts:h,onSelectFile:B})}),e.jsx(P,{type:"button",variant:"ghost",size:"icon",onClick:N,"aria-label":"Expand all files",title:"Expand all files",className:"size-7",children:e.jsx(M,{name:"expand-up-down",className:"size-3.5"})}),e.jsx(P,{type:"button",variant:"ghost",size:"icon",onClick:E,"aria-label":"Collapse all files",title:"Collapse all files",className:"size-7",children:e.jsx(M,{name:"collapse-vertical",className:"size-3.5"})})]})]}),t.filesLoading&&V.length===0?e.jsx(Rs,{rows:5,label:"Loading changed files"}):null,!t.filesLoading&&V.length===0?e.jsx("p",{className:"px-1 py-4 typography-micro text-muted-foreground",children:"No changed files"}):null,V.length>0?e.jsxs("div",{className:"flex min-h-0 items-start gap-3",children:[e.jsx("aside",{ref:S,"aria-label":"Changed files",style:D!=null?{height:D}:void 0,className:"sticky top-10 hidden max-h-[calc(100dvh-10rem)] w-60 shrink-0 flex-col @4xl:flex",children:e.jsx(ut,{files:r,viewedPaths:f,threadCounts:C,pendingCounts:h,onSelectFile:B})}),e.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:V.map(R=>e.jsx("div",{id:Ve(R.filename),className:"scroll-mt-12",children:e.jsx(Is,{file:R,collapsed:z[R.filename]??m[R.filename]??!1,onToggleCollapse:O,viewed:K.has(R.filename),onToggleViewed:T,blobUrl:$s(n,c,R.filename),threads:i.get(R.filename)??Ws,directory:s,repo:n,number:a,github:l,access:d,onThreadsChanged:t.onRetryDetail})},R.filename))})]}):null,r.length>L?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>j(L+Ue),children:"Show more files"})}):null,t.filesHasMore?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:t.onLoadMoreFiles,children:"Load more files"})}):null]})},en=({directory:t,repo:s,number:n,github:a,checks:l,checksError:d,checksLoading:c,onRetryChecks:r,onOpenFilesAtLine:f})=>{const[x,k]=o.useState({}),[m,g]=o.useState({}),{send:p,sendingKey:z}=Fe(),F=ls(l);return e.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-1 py-1",children:[e.jsx("p",{className:"min-w-0 flex-1 typography-micro text-muted-foreground","aria-live":"polite",children:F?F.text:c?"Loading checks…":"No checks reported for this pull request."}),F&&F.failed>0?e.jsxs(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{p({key:`pr-${n}-failed-checks`,kind:"checks",directory:t,repo:s,number:n,contextType:"checks"})},disabled:z===`pr-${n}-failed-checks`,"aria-label":"Send failed checks to agent",title:"Send failed checks to agent",children:[e.jsx(M,{name:"send-plane-2",className:"size-3.5"}),"Send failures to agent"]}):null,e.jsxs(P,{type:"button",variant:"ghost",size:"xs",onClick:r,"aria-label":"Refresh checks",title:"Refresh checks",children:[e.jsx(M,{name:"refresh",className:xe("size-3.5",c&&"animate-spin")}),"Refresh"]})]}),e.jsx(ve,{error:d,onRetry:r,label:"Checks"}),l?e.jsx(tn,{checks:l,directory:t,repo:s,number:n,github:a,expandedJobs:x,onToggleJob:L=>k(j=>({...j,[L]:!j[L]})),jobSteps:m,setJobSteps:g,sendingKey:z,send:p,onOpenFilesAtLine:f}):null]})},tn=({checks:t,directory:s,repo:n,number:a,github:l,expandedJobs:d,onToggleJob:c,jobSteps:r,setJobSteps:f,sendingKey:x,send:k,onOpenFilesAtLine:m})=>{const g=I(i=>i.rerunFailedChecks),[p,z]=o.useState({}),F=async i=>{const C=`run-${i.id??i.name}`;if(c(C),!(d[C]||r[C]||i.id==null)){f(h=>({...h,[C]:{steps:[],loading:!0}}));try{const O=(await l.checkJobs(s,n,i.runId??null,i.id)).jobs[0];f(E=>({...E,[C]:{steps:O?.steps??[],loading:!1}}));const N=await l.checkAnnotations(s,n,i.id).catch(()=>null);N&&z(E=>({...E,[i.id]:{loading:!1,items:N.annotations}}))}catch{f(h=>({...h,[C]:{steps:[],loading:!1}}))}}},L=async i=>{(await g(s,n,i,l)).ok?G.success("Re-run requested"):G.error("Re-run failed")},j=i=>{const C=`run-${i.id??i.name}`,h=d[C]??!1,O=r[C],N=os(i);return e.jsxs("div",{className:"rounded-md px-2 py-2 hover:bg-interactive-hover",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(fe,{state:i.conclusion??i.status}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui text-foreground",title:i.name,children:i.name}),i.conclusion?e.jsx("span",{className:"typography-micro text-muted-foreground",children:i.conclusion}):null,e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{F(i)},"aria-expanded":h,"aria-label":`${h?"Collapse":"Expand"} ${i.name}`,children:"Details"}),N&&i.runId!=null?e.jsx(P,{type:"button",variant:"outline",size:"xs",onClick:()=>{L(i.runId)},children:"Re-run"}):null,N?e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{k({key:`${C}-agent`,kind:"check",directory:s,repo:n,number:a,contextType:"checks",detail:i.name})},disabled:x===`${C}-agent`,"aria-label":`Send ${i.name} to agent`,children:"Send to agent"}):null]}),h?e.jsxs("div",{className:"mt-1.5 flex flex-col gap-1 border-t border-border/60 pt-1.5",children:[O?.loading?e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Loading steps…"}):null,(O?.steps??[]).map((E,T)=>e.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(fe,{state:E.conclusion??E.status}),e.jsx("span",{className:"truncate",children:E.name}),E.conclusion?e.jsxs("span",{children:["· ",E.conclusion]}):null]},`${E.name}-${T}`)),i.id!=null&&p[i.id]?.items?.length?e.jsx("div",{className:"flex flex-col gap-1",children:p[i.id]?.items.map((E,T)=>e.jsxs("div",{className:"typography-micro text-muted-foreground",children:[E.path&&E.startLine&&m?e.jsxs("button",{type:"button",className:"font-mono underline",onClick:()=>m(E.path,E.startLine),children:[E.path,":",E.startLine]}):e.jsxs("span",{className:"font-mono",children:[E.path,E.startLine?`:${E.startLine}`:""]})," ",E.title?e.jsxs("span",{className:"text-foreground",children:[E.title," — "]}):null,E.message]},T))}):null]}):null]},C)},b=(i,C)=>e.jsxs("div",{className:"flex items-center gap-1.5 rounded-md px-2 py-2 hover:bg-interactive-hover",children:[e.jsx(fe,{state:i.state}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui text-foreground",title:i.context,children:i.context}),i.description?e.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:i.description}):null]},`${i.context}-${C}`);return e.jsxs("div",{className:"flex flex-col gap-1",children:[t.sectionErrors?.runs||t.sectionErrors?.statuses?e.jsx("div",{className:"rounded-md border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] px-2 py-1 typography-micro text-foreground",role:"alert",children:"Some check sources failed to load; counts below are partial, not empty."}):null,t.runs.length>0?e.jsx("div",{className:"flex flex-col","aria-label":"Check runs",children:t.runs.map(j)}):null,t.statuses.length>0?e.jsx("div",{className:"flex flex-col","aria-label":"Commit statuses",children:t.statuses.map(b)}):null,t.runs.length===0&&t.statuses.length===0?e.jsx("p",{className:"typography-ui text-muted-foreground",children:"No checks reported for this pull request."}):null]})},Ke=({pr:t})=>e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(nt,{login:t.author?.login,avatarUrl:t.author?.avatarUrl,size:"xs"}),t.author?.login??"ghost"]}),t.updatedAt?` · updated ${gs(t.updatedAt)}`:"",t.draft?" · Draft":""]}),Je=({pr:t,filesCount:s})=>e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"shrink-0 truncate",title:t.base,children:t.base}),e.jsx("span",{className:"shrink-0","aria-label":"receives changes from",children:"←"}),e.jsx("code",{className:"min-w-0 flex-1 truncate",title:t.head,children:t.head}),typeof s=="number"?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 tabular-nums",children:[e.jsx(M,{name:"file-code",className:"size-3 shrink-0","aria-hidden":"true"}),s," ",s===1?"file":"files"]}):null,e.jsx(ge,{additions:t.additions,deletions:t.deletions})]}),sn=({repo:t,pr:s,access:n,acting:a,mergeMethod:l,onMergeMethodChange:d,onRun:c,checkingOut:r,onCheckout:f,onCopyLink:x,askSending:k,onAskAgent:m})=>{const g=I(N=>N.setMergeMethod),p=s.state==="open",z=be.filter(N=>te(N.id,s,n).allowed),F=z.some(N=>N.id===l)?l:z[0]?.id??l,L=te(F,s,n),j=te("ready",s,n),b=te("draft",s,n),i=te("close",s,n),C=te("reopen",s,n),h=be.find(N=>N.id===F)??be[0],O=z.length===0||a;return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-3 pt-1 pb-2","aria-label":"Pull request actions",children:[p&&!s.draft?e.jsxs("span",{role:"group","aria-label":"Merge pull request",className:"inline-flex shrink-0 items-center gap-1",children:[e.jsx(ce,{copy:he(F,s.base,s.head),busy:a,disabled:!L.allowed,disabledReason:L.reason??`Merge via ${h.label}`,label:F==="merge"?"Merge pull request":h.label,icon:e.jsx(M,{name:"git-merge",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c(F)}),e.jsxs(Me,{modal:!1,children:[e.jsx(ze,{asChild:!0,children:e.jsx(P,{type:"button",variant:"default",size:"xs",className:"shrink-0 px-1.5",title:"Merge options","aria-label":"Merge options",disabled:O,children:e.jsx(M,{name:"arrow-down-s",className:"size-3.5"})})}),e.jsx(Ae,{align:"start",className:"w-72",children:e.jsx(Et,{value:F,onValueChange:N=>{const E=N;d(E),g(t,E)},children:be.map(N=>{const E=te(N.id,s,n);return e.jsx(Ft,{value:N.id,disabled:!E.allowed,title:E.reason??N.description,children:e.jsxs("span",{className:"flex min-w-0 flex-col",children:[e.jsx("span",{className:"truncate",children:N.label}),e.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:N.description})]})},N.id)})})})]})]}):null,p&&s.draft?e.jsx(ce,{copy:he("ready",s.base,s.head),busy:a,disabled:!j.allowed,disabledReason:j.reason??"Ready for review",label:"Ready for review",icon:e.jsx(M,{name:"git-pull-request",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("ready")}):null,p&&!s.draft?e.jsx(ce,{copy:he("draft",s.base,s.head),busy:a,variant:"outline",disabled:!b.allowed,disabledReason:b.reason??"Convert to draft",label:"Convert to draft",icon:e.jsx(M,{name:"pencil",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("draft")}):null,p?e.jsx(ce,{copy:he("close",s.base,s.head),busy:a,destructive:!0,variant:"outline",disabled:!i.allowed,disabledReason:i.reason??"Close pull request",label:"Close",icon:e.jsx(M,{name:"close",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("close")}):e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>c("reopen"),disabled:!C.allowed||a,title:C.reason??"Reopen pull request","aria-label":"Reopen pull request",children:[e.jsx(M,{name:"history",className:"size-3.5","aria-hidden":"true"}),"Reopen"]}),e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>f("worktree"),disabled:r,title:"Check out in a new worktree","aria-label":"Check out in a new worktree",children:[e.jsx(M,{name:"git-branch",className:"size-3.5","aria-hidden":"true"}),r?"Checking out…":"Check out"]}),e.jsx(ce,{copy:{title:"Check out this branch here?",detail:"This switches your current checkout to the PR branch. Uncommitted work may be disrupted.",confirm:"Check out here",progress:"Checking out…"},busy:r,variant:"outline",label:"Check out here",icon:e.jsx(M,{name:"git-branch",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>f("current")}),e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:m,disabled:k,title:"Send pull request context to the agent composer","aria-label":"Ask agent about this pull request",children:[e.jsx(M,{name:"send-plane-2",className:"size-3.5","aria-hidden":"true"}),k?"Asking…":"Ask agent"]}),e.jsxs(P,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{Se(s.url)},title:"Review on GitHub","aria-label":"Review on GitHub",children:[e.jsx(M,{name:"external-link",className:"size-3.5","aria-hidden":"true"}),"Review on GitHub"]}),e.jsxs(Me,{modal:!1,children:[e.jsx(ze,{asChild:!0,children:e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 px-1.5","aria-label":"More pull request actions",title:"More pull request actions",children:e.jsx(M,{name:"more-2",className:"size-4"})})}),e.jsxs(Ae,{align:"end",className:"w-60",children:[e.jsxs(we,{onClick:()=>{Se(s.url)},children:[e.jsx(M,{name:"external-link",className:"size-3.5"}),"Open on GitHub"]}),e.jsxs(we,{onClick:x,children:[e.jsx(M,{name:"file-copy",className:"size-3.5"}),"Copy link"]}),e.jsx(Pt,{}),e.jsxs(we,{onClick:()=>f("worktree"),disabled:r,children:[e.jsx(M,{name:"git-branch",className:"size-3.5"}),"Check out in new worktree"]})]})]})]})},nn=({pr:t,access:s,acting:n,onRun:a})=>{const l=bs(t);if(!l)return null;const d=te("update-branch",t,s),c=l.tone==="error"?"border-[var(--status-error-border)] bg-[var(--status-error-background)] text-foreground":"border-[var(--status-warning-border)] bg-[var(--status-warning-background)] text-foreground",r=l.tone==="error"?"text-[var(--status-error)]":"text-[var(--status-warning)]";return e.jsxs("div",{className:`mx-3 mb-2 flex flex-wrap items-center gap-x-2 gap-y-1.5 rounded-md border px-2.5 py-2 ${c}`,role:"status",children:[e.jsx(M,{name:l.icon,className:`size-4 shrink-0 ${r}`,"aria-hidden":"true"}),e.jsxs("p",{className:"min-w-0 flex-1 basis-48",children:[e.jsxs("span",{className:"typography-ui-label font-medium",children:[l.title," ",e.jsx("code",{className:"font-mono",children:t.base})]}),e.jsx("span",{className:"block typography-micro text-muted-foreground",children:l.detail})]}),l.canUpdate?e.jsx(ce,{copy:he("update-branch",t.base,t.head),busy:n,variant:"outline",disabled:!d.allowed,disabledReason:d.reason??"Update branch",label:"Update branch",icon:e.jsx(M,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>a("update-branch")}):e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{Se(t.url)},title:"Resolve conflicts on GitHub","aria-label":"Resolve conflicts on GitHub",children:[e.jsx(M,{name:"external-link",className:"size-3.5","aria-hidden":"true"}),"Resolve on GitHub"]})]})},an=t=>{const{directory:s,repo:n,number:a,github:l,detail:d}=t,c=I(u=>u.performAction),r=I(u=>u.updateTitleBody),f=I(u=>u.checkout),[x,k]=o.useState("summary"),[m,g]=o.useState(!1),[p,z]=o.useState(()=>zt(n)??"merge"),[F,L]=o.useState(!1),[j,b]=o.useState(""),[i,C]=o.useState(!1),[h,O]=o.useState(""),[N,E]=o.useState("newest"),[T,B]=o.useState(1),[V,S]=o.useState(!1),[D,K]=o.useState(null),_=gt(n,a),{send:X,sendingKey:R}=Fe(),q=is(s,n),y=d?.pr??null,de=d?.sectionErrors??null,Q=o.useMemo(()=>({capabilities:d?.capabilities??null,isAuthor:rs(y?.author?.login,d?.viewerLogin),permissionFallback:d?.viewerPermission?.fallback===!0}),[d?.capabilities,d?.viewerLogin,d?.viewerPermission?.fallback,y?.author?.login]),ee=cs(y,Q);o.useEffect(()=>{k("summary"),L(!1),C(!1),B(1),K(null)},[n,a]);const Z=o.useCallback(async u=>{g(!0);try{const Y=await c(s,n,a,u,l);if(!Y.ok){G.error(Y.error?.kind==="failed"?Y.error.message:"Action failed");return}u==="close"?G.success("Pull request closed"):u==="reopen"?G.success("Pull request reopened"):u==="update-branch"?G.success("Branch update requested"):u==="ready"?G.success("Marked as ready for review"):u==="draft"?G.success("Converted to draft"):G.success("Pull request merged")}finally{g(!1)}},[s,n,a,l,c]),se=o.useCallback(()=>{X({key:`pr-${a}-ask`,kind:"pr",directory:s,repo:n,number:a,contextType:"pr"})},[X,s,n,a]),ne=o.useCallback(async()=>{if(!j.trim()){G.error("Enter a title");return}const u=await r(s,n,a,{title:j.trim()},l);u.ok?(G.success("Title updated"),L(!1)):G.error(u.error?.kind==="failed"?u.error.message:"Failed to update title")},[j,s,n,a,l,r]),oe=o.useCallback(async()=>{const u=await r(s,n,a,{body:h},l);u.ok?(G.success("Description updated"),C(!1)):G.error(u.error?.kind==="failed"?u.error.message:"Failed to update description")},[h,s,n,a,l,r]),ae=Ee().git,ue=o.useCallback(async u=>{if(u==="current"){const Y=await Ne(()=>import("./useAppFontEffects-COMvkffC.js").then(re=>re.f8),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(re=>re.useGitStore.getState().directories.get(s)?.status??null).catch(()=>null);if(Y&&!Y.isClean){G.error("Working tree has uncommitted changes. Commit or stash first, or use New worktree.");return}}S(!0);try{const Y=await f(s,n,a,u,l);Y.ok?(await bt(s,ae),K({path:Y.path??null,branch:Y.branch??""}),G.success(u==="worktree"?"Worktree created":"Branch checked out")):G.error(Y.error?.kind==="failed"?Y.error.message:"Checkout failed")}finally{S(!1)}},[s,n,a,l,ae,f]),w=o.useCallback(()=>{D?.path&&Ne(async()=>{const{useSessionUIStore:u}=await import("./useAppFontEffects-COMvkffC.js").then(Y=>Y.f5);return{useSessionUIStore:u}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(({useSessionUIStore:u})=>{u.getState().openNewSessionDraft({directoryOverride:D.path}),Ns.getState().setActiveMainTab("chat")})},[D]),$=ds(y?.url),H=o.useMemo(()=>{const u=[...t.comments];return u.sort((Y,je)=>{const re=Y.createdAt?Date.parse(Y.createdAt):0,Te=je.createdAt?Date.parse(je.createdAt):0;return N==="newest"?Te-re:re-Te}),u},[t.comments,N]),A=H.slice(0,T*20),U=A.filter(u=>!$e(u.author?.login)),W=A.filter(u=>$e(u.author?.login));if(t.detailError&&!d)return e.jsx(ke,{header:e.jsx(Ce,{onBack:t.onBack,backLabel:"Back to pull requests",repoName:q,number:a,openLabel:`Open pull request #${a} on GitHub`,title:`Pull request #${a}`}),tabs:[],activeTab:"",onTabChange:()=>{},children:e.jsx(et,{info:vt(t.detailError),onRetry:t.onRetryDetail})});if(!y){const u=t.seed&&t.seed.number===a?t.seed:null;return e.jsx(ke,{header:e.jsx(Ce,{onBack:t.onBack,backLabel:"Back to pull requests",repoName:q,number:a,url:u?.url??null,numberTintClass:u?He("pr",u.state,u.draft):void 0,statePill:u?e.jsx(Ge,{kind:"pr",state:u.state,draft:u.draft}):void 0,openLabel:`Open pull request #${a} on GitHub`,title:u?.title??null,meta:u?e.jsx(Ke,{pr:u}):void 0,branches:u?e.jsx(Je,{pr:u,filesCount:u.changedFiles??null}):void 0}),tabs:[],activeTab:"",onTabChange:()=>{},children:e.jsx(us,{label:"Loading pull request"})})}const J=t.checks?.summary??null,me=t.files?.files.length??y.changedFiles??0,v=_>0&&!t.hideFilesTab?`${me} · ${_} pending`:String(me);return e.jsx(ke,{header:e.jsxs(e.Fragment,{children:[e.jsx(Ce,{onBack:t.onBack,backLabel:"Back to pull requests",repoName:q,number:y.number,url:y.url,numberTintClass:He("pr",y.state,y.draft),statePill:e.jsx(Ge,{kind:"pr",state:y.state,draft:y.draft}),openLabel:`Open pull request #${y.number} on GitHub`,title:y.title,onEditTitle:()=>{b(y.title),L(!0)},editTitleLabel:"Edit pull request title",editTitleDisabledReason:ee.allowed?null:ee.reason,meta:e.jsx(Ke,{pr:y}),branches:e.jsx(Je,{pr:y,filesCount:me})}),e.jsx(sn,{directory:s,repo:n,number:a,github:l,pr:y,access:Q,acting:m,mergeMethod:p,onMergeMethodChange:z,onRun:u=>{Z(u)},checkingOut:V,onCheckout:u=>{ue(u)},onCopyLink:$,askSending:R===`pr-${a}-ask`,onAskAgent:se}),e.jsx(nn,{pr:y,access:Q,acting:m,onRun:u=>{Z(u)}})]}),tabs:[{id:"summary",label:"Summary"},...t.hideFilesTab?[]:[{id:"files",label:"Code",hint:v}],{id:"checks",label:"Checks",hint:J?`${J.success}/${J.total}`:void 0,glyph:J?e.jsx(fe,{state:J.state}):void 0}],activeTab:x,onTabChange:u=>k(u),children:e.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2",children:[t.detailStale?e.jsxs("p",{className:"typography-micro text-muted-foreground",role:"note",children:["Showing saved details — last refresh failed."," ",e.jsx("button",{type:"button",className:"underline",onClick:t.onRetryDetail,children:"Retry"})]}):null,Q.permissionFallback?e.jsx("p",{className:"typography-micro text-muted-foreground",role:"note",children:"Permissions could not be loaded — actions stay enabled and any failure will be shown after you act."}):null,F?e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 py-1",children:[e.jsx(tt,{value:j,onChange:u=>b(u.target.value),"aria-label":"Pull request title",className:"h-7"}),e.jsx(P,{type:"button",variant:"default",size:"xs",onClick:()=>{ne()},children:"Save"}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>L(!1),children:"Cancel"})]}):null,D?e.jsxs("p",{className:"flex flex-wrap items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(M,{name:"check",className:"size-3.5 shrink-0 text-[var(--status-success)]"}),e.jsxs("span",{children:["Ready on ",D.branch,D.path?` at ${D.path}`:"","."]}),D.path?e.jsx(P,{type:"button",variant:"default",size:"xs",onClick:w,children:"Open session here"}):null,e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>K(null),"aria-label":"Dismiss checkout result",children:"Dismiss"})]}):null,x==="summary"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-1.5 py-1",children:[e.jsx(qe,{icon:"user",label:"Reviewers",children:e.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5",children:[y.requestedReviewers.length===0?e.jsx("span",{className:"typography-micro text-muted-foreground",children:"None"}):y.requestedReviewers.map(u=>e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 typography-micro text-muted-foreground",children:[e.jsx(nt,{login:u.login,avatarUrl:u.avatarUrl,size:"xs"}),e.jsx("span",{className:"truncate",children:u.login})]},u.login)),e.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground",children:[y.reviewSummary.approvals," approvals · ",y.reviewSummary.changesRequested," changes requested ·"," ",y.reviewSummary.commented," commented"]})]})}),e.jsx(qe,{icon:"list-unordered",label:"Labels",children:e.jsx("span",{className:"flex min-w-0 flex-wrap items-center gap-1",children:y.labels.length===0?e.jsx("span",{className:"typography-micro text-muted-foreground",children:"None"}):y.labels.map(u=>e.jsx(ms,{name:u.name,color:u.color},u.name))})})]}),e.jsx(Ie,{id:`pr-${a}-description`,title:"Description",action:i?void 0:e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{O(y.body??""),C(!0)},"aria-label":"Edit description",title:ee.reason??"Edit description",disabled:!ee.allowed,children:"Edit"}),children:i?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("textarea",{value:h,onChange:u=>O(u.target.value),rows:6,"aria-label":"Pull request description",className:"min-h-24 w-full rounded-md border border-border bg-[var(--surface-elevated)] p-2 typography-ui text-foreground"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(P,{type:"button",variant:"default",size:"sm",onClick:()=>{oe()},children:"Save"}),e.jsx(P,{type:"button",variant:"ghost",size:"sm",onClick:()=>C(!1),children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(hs,{markdown:y.body??"",html:y.bodyHtml??null,fallbackUrl:y.url,label:"pull request description"}),y.body?.trim()?null:e.jsx("p",{className:"typography-micro text-muted-foreground",children:"No description provided."})]})}),e.jsx(Ie,{id:`pr-${a}-comments`,title:`Comments${H.length?` (${H.length})`:""}`,action:e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1",children:[t.hideFilesTab?e.jsx(ct,{directory:s,repo:n,number:a,github:l,access:Q,size:"xs",onReviewSubmitted:t.onRetryDetail}):null,e.jsx(ps,{order:N,onToggle:()=>E(N==="newest"?"oldest":"newest")})]}),children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(ve,{error:t.commentsError,onRetry:t.onRetryComments,label:"Comments"}),U.map(u=>e.jsx(fs,{comment:u},u.id)),e.jsx(xs,{comments:W}),t.commentsLoading&&H.length===0&&!t.commentsError?e.jsx("p",{className:"typography-micro text-muted-foreground",children:"Loading comments…"}):null,H.length===0&&!t.commentsLoading&&!t.commentsError?e.jsx("p",{className:"typography-micro text-muted-foreground",children:"No comments yet."}):null,H.length>A.length?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>B(T+1),children:"Show older comments"})}):t.commentsHasMore?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:t.onLoadMoreComments,disabled:t.commentsLoading,children:t.commentsLoading?"Loading…":"Load older comments"})}):null,e.jsx(Os,{directory:s,repo:n,number:a,github:l,pr:y,access:Q,onCommented:()=>{t.onRetryComments(),t.onRetryDetail()}})]})})]}):null,x==="files"&&!t.hideFilesTab?e.jsx(Zs,{files:t.files,filesLoading:t.filesLoading,filesError:t.filesError,filesHasMore:t.filesHasMore,onLoadMoreFiles:t.onLoadMoreFiles,onRetryFiles:t.onRetryFiles,threads:t.threads,threadsError:de?.threads??null,onRetryDetail:t.onRetryDetail,directory:s,repo:n,number:a,github:l,access:Q,headSha:y.headSha??null,onReviewSubmitted:t.onRetryDetail},`${n}#${a}`):null,x==="checks"?e.jsx(en,{directory:s,repo:n,number:a,github:l,checks:t.checks,checksError:t.checksError,checksLoading:t.checksLoading,onRetryChecks:t.onRetryChecks,onOpenFilesAtLine:t.onOpenFilesAtLine}):null]})})},ln=({items:t,hasMore:s,isLoadingMore:n,isLoading:a,isRefreshing:l,stale:d,error:c,filters:r,checksByUrl:f,incompleteNotice:x=null,remote:k=null,numberJump:m=null,onFiltersChange:g,onClearFilters:p,onLoadMore:z,onRetry:F,onOpen:L,headerActionsSlot:j=null,headerActionsPresentation:b="drawer"})=>{const i=r.state==="open"&&r.involvement==="all"&&!r.search.trim(),C=o.useCallback(h=>e.jsx("li",{role:"listitem",children:e.jsx(yt,{glyph:e.jsx(vs,{kind:"pr",state:h.state,draft:h.draft}),glyphBelow:e.jsx(fe,{state:(h.url?f[h.url]:void 0)??null}),number:`#${h.number}`,title:h.title,status:e.jsx(ge,{additions:h.additions,deletions:h.deletions,className:"typography-micro"}),meta:e.jsxs(e.Fragment,{children:[e.jsx(jt,{login:h.author?.login,avatarUrl:h.author?.avatarUrl}),e.jsx(wt,{head:h.head,base:h.base}),h.draft?e.jsx("span",{className:"shrink-0 rounded bg-[var(--surface-muted)] px-1 typography-micro text-muted-foreground",children:"Draft"}):null]}),updatedAt:h.updatedAt,onOpen:()=>L(h.number),ariaLabel:`Open pull request #${h.number} ${h.title}`})},h.number),[f,L]);return e.jsx(kt,{items:t,renderRow:C,hasMore:s,isLoadingMore:n,isLoading:a,isRefreshing:l,stale:d,error:c,searchValue:r.search,onSearchChange:h=>g({search:h}),searchPlaceholder:"Search pull requests, or label:bug",searchAriaLabel:"Search pull requests",toolbarControls:e.jsx(Ct,{stateValue:r.state,stateOptions:ws.map(h=>({id:h.id,label:h.label})),onStateChange:h=>g({state:h}),involvementValue:r.involvement,involvementOptions:js.map(h=>({id:h.id,label:h.label})),onInvolvementChange:h=>g({involvement:h}),sortValue:r.sort,sortOptions:ys.map(h=>({id:h.id,label:h.label})),onSortChange:h=>g({sort:h}),sortAriaLabel:"Sort pull requests"}),headerActionsSlot:j,headerActionsPresentation:b,isDefaultFilters:i,noItemsTitle:r.state==="open"?"No open pull requests":"No pull requests yet",noItemsBody:"Pull requests for this repository appear here.",noItemsIcon:"git-pull-request",listAriaLabel:"Pull requests",skeletonLabel:"Loading pull requests",incompleteNotice:x,remote:k,numberJump:m,numberJumpKind:"pull request",onClearFilters:p,onLoadMore:z,onRetry:F,onOpen:L})},on=t=>{const s=At(n=>n.results);return o.useMemo(()=>{const n=Dt(s),a={};for(const l of t){if(!l.url)continue;const d=n.get(l.url);d!==void 0&&(a[l.url]=d)}return a},[t,s])},da=({hideFilesTab:t=!1,headerActionsSlot:s=null,headerActionsPresentation:n="drawer"})=>{const a=Tt()??"";return a?e.jsx(rn,{directory:a,hideFilesTab:t,headerActionsSlot:s,headerActionsPresentation:n}):e.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center",children:e.jsx("p",{className:"typography-ui text-muted-foreground",children:"Open a project to browse pull requests."})})},rn=({directory:t,hideFilesTab:s,headerActionsSlot:n=null,headerActionsPresentation:a="drawer"})=>{const d=Ee().github??null,[c,r]=o.useState(!1),[f,x]=o.useState(!1),k=o.useRef(null);return o.useEffect(()=>$t(),[]),e.jsx(Nt,{directory:t,isRefreshing:c,onRefresh:()=>k.current?.(),children:({repo:m,directory:g})=>e.jsx(cn,{directory:g,repo:m,github:d,refreshing:c,setRefreshing:r,loadingMore:f,setLoadingMore:x,refreshRef:k,hideFilesTab:s,headerActionsSlot:n,headerActionsPresentation:a},m)})},cn=({directory:t,repo:s,github:n,refreshing:a,setRefreshing:l,loadingMore:d,setLoadingMore:c,refreshRef:r,hideFilesTab:f,headerActionsSlot:x=null,headerActionsPresentation:k="drawer"})=>{const m=I(v=>v.ensureCollectionsFresh),g=I(v=>v.searchRemote),p=I(v=>v.loadMoreRemote),z=I(v=>v.loadMoreCollection),F=I(v=>v.refreshAllForScope),L=I(v=>v.selectPullRequest),j=I(v=>v.setFilters),b=I(v=>v.resetFilters),i=Gt(t,s),C=Ht(t),h=qt(),O=C.repo===s?C.number:null,N=i.state==="open"?"open":i.state==="all"?"both":"closed";o.useEffect(()=>{if(!n)return;let v=!1;return l(!0),m(t,s,N,n).then(()=>{v||l(!1)}).catch(()=>{v||l(!1)}),()=>{v=!0}},[t,s,n,N]),o.useEffect(()=>{if(!n)return;const v=()=>{typeof document<"u"&&document.hidden||m(t,s,N,n).catch(()=>{})};return window.addEventListener("focus",v),document.addEventListener("visibilitychange",v),()=>{window.removeEventListener("focus",v),document.removeEventListener("visibilitychange",v)}},[t,s,n,N]);const E=De(s,"open"),T=De(s,"closed"),B=o.useMemo(()=>It(s),[s,E?.data,T?.data]),V=o.useMemo(()=>new Set(B.map(v=>v.number)),[B]),S=o.useMemo(()=>Ot(B,{state:i.state,involvement:i.involvement,search:i.search,sort:i.sort,viewerLogin:h}),[B,i.state,i.involvement,i.search,i.sort,h]),D=on(S),K=N==="both"?[E,T]:[N==="open"?E:T],_=K.some(v=>v?.data!=null),X=_&&K.every(v=>v?.data?.nextCursor==null),R=K.reduce((v,u)=>v+(u?.data?.items.length??0),0),q=K.find(v=>v?.error)?.error??null,y=K.some(v=>v?.isLoading),de=K.some(v=>v?.stale),Q=i.search.trim(),ee=i.involvement!=="all"&&!h,Z=Q.length>0||i.involvement!=="all",se=o.useMemo(()=>({state:i.state,involvement:i.involvement,q:Q}),[i.state,i.involvement,Q]),ne=`${se.state}|${se.involvement}|${se.q}`,oe=!X&&_&&S.length===0&&(Q.length>0||ee),ae=o.useCallback(v=>n?g(t,s,v,n):Promise.resolve(null),[t,s,n,g]),ue=o.useCallback(v=>n?p(t,s,v,n):Promise.resolve(null),[t,s,n,p]),{remoteView:w,numberJump:$,remotePending:H,handleSearchAll:ie}=St({repo:s,query:se,queryKey:ne,autoRemote:oe,indexNumbers:V,visibleItems:S,searchText:Q,useRemoteEntry:Jt,runSearch:ae,runLoadMore:ue}),A=o.useMemo(()=>{if(X||!_||!Z)return null;const v=S.length===1?"1 match":`${S.length} matches`,u=R===1?"1 most recent loaded pull request":`${R} most recent loaded pull requests`;return`Showing ${v} from the ${u}`},[X,_,Z,S.length,R]),U=o.useCallback(()=>{n&&(l(!0),F(t,s,n).then(()=>{l(!1)}).catch(()=>l(!1)))},[t,s,n,F,l]);o.useEffect(()=>(r.current=U,()=>{r.current===U&&(r.current=null)}),[r,U]);const W=o.useCallback(()=>{if(!n)return;c(!0);const v=N==="both"?["open","closed"]:[N];Promise.all(v.map(u=>z(t,s,u,n))).then(()=>c(!1)).catch(()=>c(!1))},[t,s,N,n,z,c]),J=o.useCallback(v=>{L(t,s,v)},[t,s,L]),me=o.useCallback(()=>{L(t,null,null)},[t,L]);return n?O!=null?e.jsx(dn,{directory:t,repo:s,number:O,github:n,onBack:me,hideFilesTab:f,seed:Bt(s,O)}):e.jsx(ln,{items:S,headerActionsSlot:x,headerActionsPresentation:k,hasMore:K.some(v=>v?.data?.nextCursor!=null),isLoadingMore:d,isLoading:y,isRefreshing:a&&_,stale:de,error:q,filters:i,checksByUrl:D,incompleteNotice:A?{summary:A,searching:H,onSearchAll:ie}:null,remote:w,numberJump:$,onFiltersChange:v=>j(t,s,v),onClearFilters:()=>b(t,s),onLoadMore:W,onRetry:U,onOpen:J}):e.jsx(et,{info:{reason:"failed",message:"GitHub is not available in this runtime."}})},dn=({directory:t,repo:s,number:n,github:a,onBack:l,hideFilesTab:d,seed:c})=>{const r=I(S=>S.ensureDetail),f=I(S=>S.ensureComments),x=I(S=>S.ensureFiles),k=I(S=>S.ensureChecks),m=I(S=>S.loadMoreFiles),g=I(S=>S.loadMoreComments),p=I(S=>S.refreshComments),z=I(S=>S.refreshDetail),F=I(S=>S.refreshChecks);o.useEffect(()=>{r(t,s,n,a).catch(()=>{}),f(t,s,n,a).catch(()=>{}),d||x(t,s,n,a).catch(()=>{}),k(t,s,n,a).catch(()=>{})},[t,s,n,d]);const L=_t(s,n),j=Ut(s,n),b=Vt(s,n),i=Kt(s,n),C=L?.data?.detail??null,h=o.useCallback((S,D)=>{const K=Ss(t);Ne(async()=>{const{useUIStore:_}=await import("./index-BxKPJ9uG.js").then(X=>X.d2);return{useUIStore:_}},__vite__mapDeps([1,2,3,4,5,6,7,8])).then(({useUIStore:_})=>{_.getState().openContextFileAtLine(K,S,D)}).catch(()=>{})},[t]),O=o.useCallback(()=>{m(t,s,n,a).catch(()=>{})},[t,s,n,a,m]),N=o.useCallback(()=>{g(t,s,n,a).catch(()=>{})},[t,s,n,a,g]),E=o.useCallback(()=>{p(t,s,n,a).catch(()=>{})},[t,s,n,a,p]),T=o.useCallback(()=>{z(t,s,n,a).catch(()=>{})},[t,s,n,a,z]),B=o.useCallback(()=>{x(t,s,n,a).catch(()=>{})},[t,s,n,a,x]),V=o.useCallback(()=>{F(t,s,n,a).catch(()=>{})},[t,s,n,a,F]);return e.jsx(an,{hideFilesTab:d,seed:c,directory:t,repo:s,number:n,github:a,detail:C,detailError:L?.error??null,detailStale:L?.stale??!1,files:b?.data??null,filesError:b?.error??null,filesLoading:b?.isLoading??!1,filesHasMore:b?.data?.nextCursor!=null,onLoadMoreFiles:O,checks:i?.data??null,checksError:i?.error??null,checksLoading:i?.isLoading??!1,reviews:C?.reviews??[],threads:C?.threads??[],comments:j?.data?.comments??[],commentsError:j?.error??null,commentsLoading:j?.isLoading??!1,commentsHasMore:j?.data?.nextCursor!=null,onLoadMoreComments:N,onRetryComments:E,onBack:l,onRetryDetail:T,onRetryFiles:B,onRetryChecks:V,onOpenFilesAtLine:h})};export{da as PullRequestsSurface};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/useAppFontEffects-DJCrUN2D.js","assets/index-BFkW-BPM.js","assets/vendor-zustand-CXhN0IMY.js","assets/vendor-react-Bz1tRBxM.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-BKkUfl9q.js","assets/vendor-fuse.js-t_7AcMTv.js","assets/index-C5JgjS20.css","assets/vendor-boot-D-KEJjsM.js","assets/runtimeSurface-DD4Vn4HC.js","assets/nativeFileSave-Bj-V_9ae.js"])))=>i.map(i=>d[i]);
2
+ import{_ as Ne}from"./vendor-vite-runtime-DD1OZmLC.js";import{j as e,aY as We,aZ as Ye,a_ as Qe,a$ as Xe,b0 as Ze}from"./vendor-boot-D-KEJjsM.js";import{R as o}from"./vendor-react-Bz1tRBxM.js";import{h as le,k as Le,u as mt,e as ht,f as ft,l as xt,m as pt,n as gt,r as bt,o as et,t as vt,g as ce,G as yt,a as jt,p as wt,c as kt,d as Ct,i as Nt,j as St}from"./useGitHubRemoteSearch-B77fMiwQ.js";import{j as Ee,t as G,N as Rt,B as P,I as M,bi as Lt,f as tt,D as Me,h as ze,i as Ae,V as Et,W as Ft,af as Se,a0 as we,aY as Pt,aZ as Tt}from"./useAppFontEffects-DJCrUN2D.js";import{i as I,T as Mt,r as zt,j as At,k as Dt,g as $t,l as Gt,m as Ht,f as qt,n as De,p as It,q as Ot,t as Bt,v as _t,w as Ut,x as Vt,y as Kt,z as Jt}from"./runtimeEndpointReset-CtHv_OMT.js";import{z as Wt,A as Yt,B as Qt,C as Xt,D as st,E as Zt,F as es,H as ge,I as ts,q as ss,J as te,K as ns,L as as,M as ls,N as os,O as fe,u as is,i as rs,P as cs,b as ds,c as $e,j as ke,e as Ce,k as us,f as Ge,h as He,l as qe,m as nt,n as ms,p as Ie,Q as hs,v as fs,w as xs,x as ps,y as gs,R as be,S as he,T as bs,G as vs,U as ys,V as js,W as ws}from"./GitHubDetailScaffold-US37Di_K.js";import{c as xe,E as ks,s as Cs,u as Ns,A as Ss}from"./index-BFkW-BPM.js";import{S as ve,d as Rs}from"./GitHubListPrimitives-DuUXrJGk.js";import{P as Ls}from"./PierreDiffViewer-BHBySiXQ.js";import{c as Es,p as Fs}from"./vendor-zustand-CXhN0IMY.js";import"./vendor-clsx-B-dksMZM.js";import"./runtimeSurface-DD4Vn4HC.js";import"./nativeFileSave-Bj-V_9ae.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./SessionUnreadDot-CgvC3F5e.js";/* empty css */import"./permissionStore-zIpxq9Pq.js";import"./vendor-dompurify-BGCr_sdL.js";import"./web-components-XIP_3VZv.js";import"./computeVirtualFileMetrics-SlBfr8LB.js";import"./vendor-shiki-BEwTOAFg.js";import"./vendor-shikijs-core-Ck_OPM_T.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-DPFxvYtK.js";import"./vendor-hast-util-to-html-O3stl53j.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-C40bX6nM.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-DrfmQi8i.js";import"./vendor-pierre-theming-BO6EPniU.js";import"./vendor-shikijs-engine-javascript-DL394yyj.js";import"./vendor-oniguruma-to-es-DgwFOwdE.js";import"./vendor-oniguruma-parser-BrbMHgHx.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./VirtualizedFileDiff-DwR2fZHv.js";import"./renderDiffWithHighlighter-g9eKWi78.js";import"./vendor-diff-C3JhlQdm.js";import"./StickyHorizontalScrollbar-CMbTn5WQ.js";import"./appThemeRegistry-Ca8eGRB9.js";import"./registerCustomTheme-C-h6lsYW.js";const Fe=()=>{const t=Ee(),[s,n]=o.useState(null);return{send:o.useCallback(async l=>{const d=t.github;if(!d)return G.error("GitHub is not available in this runtime"),!1;n(l.key);try{const c=await d.agentContext(l.directory,l.repo,l.contextType,l.number,l.contextOptions),r=Wt({kind:l.kind,repo:l.repo,number:l.number,detail:l.detail}),f=Yt({kind:l.kind,repo:l.repo,number:l.number,contextText:c.text}),x=Rt.getState();x.setPendingInputText(r,"append");const k=x.pendingSyntheticParts??[];return x.setPendingSyntheticParts([...k,{text:f,synthetic:!0}]),G.success("Added to composer"),!0}catch(c){return G.error(c instanceof Error?c.message:"Failed to fetch GitHub context"),!1}finally{n(null)}},[t.github]),sendingKey:s}},Ps=800,Ts=3,Pe={added:{icon:"add-circle",letter:"A",tint:"text-[var(--status-success)]"},removed:{icon:"subtract",letter:"D",tint:"text-[var(--status-error)]"},modified:{icon:"pencil",letter:"M",tint:"text-[var(--status-warning)]"},renamed:{icon:"expand-up-down",letter:"R",tint:"text-[var(--status-info)]"},other:{icon:"file",letter:"•",tint:"text-muted-foreground"}},at=t=>{switch((t??"").toLowerCase()){case"added":return"added";case"removed":return"removed";case"modified":return"modified";case"renamed":return"renamed";default:return"other"}},lt=t=>Pe[t].icon,Ms=t=>Pe[t].letter,Re=t=>Pe[t].tint,ot=t=>{const s=t.lastIndexOf("/");return s<0?{dir:"",base:t}:{dir:t.slice(0,s),base:t.slice(s+1)}},it=t=>{const s=typeof t.additions=="number"?t.additions:0,n=typeof t.deletions=="number"?t.deletions:0;return s!==0||n!==0?s+n:typeof t.changes=="number"?t.changes:0},rt=t=>it(t)>Ps,zs=t=>{const s=new Map;for(const a of t){const l=a.filename.lastIndexOf("/"),d=l<0?"":a.filename.slice(0,l),c=s.get(d);c?c.push(a):s.set(d,[a])}const n=[...s.entries()].map(([a,l])=>({folder:a,files:[...l].sort((d,c)=>d.filename.localeCompare(c.filename,void 0,{sensitivity:"base"}))}));return n.sort((a,l)=>a.folder===""?1:l.folder===""?-1:a.folder.localeCompare(l.folder,void 0,{sensitivity:"base"})),n},As=t=>{let s=0,n=0;for(const a of t)s+=typeof a.additions=="number"?a.additions:0,n+=typeof a.deletions=="number"?a.deletions:0;return{additions:s,deletions:n}},Ds=t=>{const s={};return t.forEach((n,a)=>{s[n.filename]=a>=Ts||rt(n)}),s},$s=(t,s,n)=>{if(!s)return null;const a=t.split("/");if(a.length!==3||a.some(r=>r.length===0))return null;const[l,d,c]=a;return`https://${l}/${d}/${c}/blob/${s}/${n}`},Gs=({comment:t,onRemove:s})=>e.jsxs("div",{className:"rounded-md border border-dashed border-border p-2.5 typography-ui text-foreground",contentEditable:!1,onPointerDown:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(M,{name:"chat-1",className:"size-3.5 shrink-0","aria-hidden":"true"}),e.jsx("span",{children:"Pending — sent when you submit the review"}),e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Discard this comment",title:"Discard this comment",onClick:s,className:"ml-auto size-6",children:e.jsx(M,{name:"delete-bin",className:"size-3.5"})})]}),e.jsx("p",{className:"mt-1.5 whitespace-pre-wrap break-words",children:t.body})]}),Oe=({thread:t,replyAllowed:s,replyDisabledReason:n,resolveAllowed:a,resolveDisabledReason:l,busy:d,onReply:c,onToggleResolved:r})=>{const[f,x]=o.useState(!t.resolved),[k,m]=o.useState(!1),[g,p]=o.useState(""),[z,F]=o.useState(!1),L=t.comments.length,j=async()=>{const b=g.trim();if(!(b.length===0||z||d)){F(!0);try{await c(b)&&(p(""),m(!1))}finally{F(!1)}}};return e.jsxs("div",{className:"rounded-md border border-border/60 bg-[var(--surface-elevated)] p-2.5 typography-ui text-foreground",contentEditable:!1,onPointerDown:b=>b.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(M,{name:t.resolved?"check":"chat-1",className:xe("size-3.5 shrink-0",t.resolved?"text-[var(--status-success)]":""),"aria-hidden":"true"}),e.jsxs("button",{type:"button",className:"hover:text-foreground","aria-expanded":f,onClick:()=>x(b=>!b),children:[t.resolved?"Resolved":"Open"," · ",L," ",L===1?"comment":"comments"]}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"ml-auto",disabled:!a||d,title:l??(t.resolved?"Reopen this conversation":"Resolve this conversation"),"aria-label":t.resolved?"Reopen conversation":"Resolve conversation",onClick:r,children:t.resolved?"Unresolve":"Resolve"})]}),f?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 flex flex-col gap-2",children:t.comments.map((b,i)=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"typography-micro text-muted-foreground",children:b.author?.login??"ghost"}),e.jsx(ss,{markdown:b.body,html:b.bodyHtml??null,fallbackUrl:b.url})]},b.id??`${t.id}-${i}`))}),s?k?e.jsxs("div",{className:"mt-2",children:[e.jsx("textarea",{autoFocus:!0,value:g,rows:2,placeholder:"Reply","aria-label":"Reply to this conversation",disabled:z||d,onChange:b=>p(b.target.value),onKeyDown:b=>{b.nativeEvent.isComposing||(b.key==="Escape"&&(b.preventDefault(),m(!1)),b.key==="Enter"&&(b.metaKey||b.ctrlKey)&&!b.shiftKey&&!b.altKey&&!b.repeat&&(b.preventDefault(),b.stopPropagation(),j()))},className:"min-h-12 w-full rounded-md border border-border bg-[var(--surface-elevated)] p-2 typography-ui text-foreground"}),e.jsxs("div",{className:"mt-1.5 flex justify-end gap-1.5",children:[e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>m(!1),children:"Cancel"}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:z||d||g.trim().length===0,onClick:()=>{j()},children:z?"Replying…":"Reply"})]})]}):e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"mt-2",onClick:()=>m(!0),children:"Reply"}):n?e.jsxs("p",{className:"mt-2 typography-micro text-muted-foreground",title:n,children:["Reply unavailable — ",n.charAt(0).toLowerCase()+n.slice(1)]}):null]}):null]})},Hs=({path:t,line:s,sendingToAgent:n,onCancel:a,onAddToReview:l,onSendToAgent:d})=>{const[c,r]=o.useState(""),f=o.useRef(null),x=c.trim();o.useLayoutEffect(()=>{const m=window.requestAnimationFrame(()=>{f.current?.focus({preventScroll:!0})});return()=>window.cancelAnimationFrame(m)},[]);const k=()=>{x&&l(x)};return e.jsxs("div",{className:"rounded-md border border-border/60 bg-[var(--surface-elevated)] p-2.5",contentEditable:!1,onPointerDown:m=>m.stopPropagation(),children:[e.jsxs("p",{className:"truncate font-mono typography-micro text-muted-foreground",title:`${t}:${s}`,children:[t,":",s]}),e.jsx("textarea",{ref:f,value:c,rows:3,placeholder:"Add a comment…","aria-label":`Comment on ${t} line ${s}`,onChange:m=>r(m.target.value),onFocus:m=>{const g=m.currentTarget.value.length;m.currentTarget.setSelectionRange(g,g)},onKeyDown:m=>{m.nativeEvent.isComposing||(m.key==="Escape"&&(m.preventDefault(),a()),m.key==="Enter"&&(m.metaKey||m.ctrlKey)&&!m.shiftKey&&!m.altKey&&!m.repeat&&(m.preventDefault(),m.stopPropagation(),k()))},className:"mt-1.5 min-h-16 w-full rounded-md border border-border bg-[var(--surface-elevated)] p-2 typography-ui text-foreground"}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"mr-auto typography-micro text-muted-foreground",children:"Ctrl/Cmd+Enter to add"}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:a,children:"Cancel"}),e.jsx(P,{type:"button",variant:"outline",size:"xs",disabled:!x||n,title:"Send this line to the agent",onClick:()=>d(x),children:n?"Sending…":"Send to agent"}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:!x,onClick:k,children:"Add to review"})]})]})},qs=({file:t,collapsed:s,onToggleCollapse:n,viewed:a,onToggleViewed:l,blobUrl:d,threads:c,directory:r,repo:f,number:x,github:k,access:m,onThreadsChanged:g})=>{const p=I(w=>w.threadAction),z=le(w=>w.removeComment),F=le(w=>w.addComment),L=Le(f,x),[j,b]=o.useState(null),[i,C]=o.useState(!1),{send:h,sendingKey:O}=Fe(),{original:N,modified:E}=o.useMemo(()=>Qt(t.patch),[t.patch]),T=o.useMemo(()=>Xt(t.patch),[t.patch]),B=`pr-${x}-file-${t.filename}`,V=st(m),S=Zt(m),D=es(m),K=o.useCallback(w=>{if(!w||!V.allowed)return;const H=(w.endSide??w.side??"additions")==="deletions"?"deletions":"additions",ie=H==="deletions"?T.syntheticToOld.get(w.end):T.syntheticToNew.get(w.end);if(ie==null){G.error("That line is outside the rendered hunks");return}b({synthLine:w.end,side:H,realLine:ie,realSide:H==="deletions"?"LEFT":"RIGHT"})},[V.allowed,T]),_=at(t.status),{dir:X,base:R}=ot(t.filename),q=rt(t),[y,de]=o.useState(!1),Q=q&&!y&&!a&&t.patch!=null,ee=c.filter(w=>!w.resolved).length,Z=o.useMemo(()=>L.filter(w=>w.path===t.filename),[L,t.filename]),{annotations:se,orphans:ne}=o.useMemo(()=>{const w=new Map,$=[],H=(A,U)=>{const W=`${A}:${U}`;let J=w.get(W);return J||(J={side:A,synthLine:U,threads:[],pendings:[]},w.set(W,J)),J};for(const A of c){const U=A.line??A.originalLine??null;if(U==null){$.push(A);continue}let W,J;if(A.diffSide==="LEFT"?(J="deletions",W=T.oldToSynthetic.get(U)):A.diffSide==="RIGHT"?(J="additions",W=T.newToSynthetic.get(U)):(W=T.newToSynthetic.get(U),J="additions",W==null&&(W=T.oldToSynthetic.get(U),J="deletions")),W==null){$.push(A);continue}H(J,W).threads.push(A)}for(const A of Z){if(A.line==null)continue;const U=A.side==="LEFT"?"deletions":"additions",W=U==="deletions"?T.oldToSynthetic.get(A.line):T.newToSynthetic.get(A.line);W!=null&&H(U,W).pendings.push(A)}return j&&H(j.side,j.synthLine),{annotations:[...w.values()].sort((A,U)=>A.synthLine-U.synthLine).map(A=>({side:A.side,lineNumber:A.synthLine,metadata:{threads:A.threads,pendings:A.pendings,draft:j&&j.side===A.side&&j.synthLine===A.synthLine?{realLine:j.realLine,realSide:j.realSide}:null}})),orphans:$}},[c,Z,j,T]),oe=o.useCallback(async(w,$)=>{const H=w.comments[w.comments.length-1]?.id??null;if(typeof H!="number")return G.error("Cannot reply to this thread yet"),!1;if(i)return!1;C(!0);try{return(await p(r,f,x,w.id,{action:"reply",body:$,commentId:H},k)).ok?(G.success("Reply posted"),g(),!0):(G.error("Failed to post reply"),!1)}finally{C(!1)}},[r,f,x,k,p,i,g]),ae=o.useCallback(w=>{i||(C(!0),p(r,f,x,w.id,w.resolved?{action:"unresolve"}:{action:"resolve"},k).then($=>{$.ok?(G.success(w.resolved?"Thread reopened":"Thread resolved"),g()):G.error("Failed to update thread")}).finally(()=>C(!1)))},[r,f,x,k,p,i,g]),ue=o.useCallback(w=>e.jsxs("div",{className:"flex flex-col gap-1.5 px-3 py-2",contentEditable:!1,onPointerDown:$=>$.stopPropagation(),children:[w.metadata.threads.map($=>e.jsx(Oe,{thread:$,replyAllowed:S.allowed,replyDisabledReason:S.reason,resolveAllowed:D.allowed,resolveDisabledReason:D.reason,busy:i,onReply:H=>oe($,H),onToggleResolved:()=>ae($)},$.id)),w.metadata.pendings.map($=>e.jsx(Gs,{comment:$,onRemove:()=>z(f,x,$.id)},$.id)),w.metadata.draft?e.jsx(Hs,{path:t.filename,line:w.metadata.draft.realLine,sendingToAgent:O===`${B}-draft-agent`,onCancel:()=>b(null),onAddToReview:$=>{const H=w.metadata.draft;H&&(F(f,x,{path:t.filename,body:$,line:H.realLine,side:H.realSide}),b(null),G.success("Added to review"))},onSendToAgent:$=>{const H=w.metadata.draft;H&&h({key:`${B}-draft-agent`,kind:"lines",directory:r,repo:f,number:x,contextType:"pr",contextOptions:{includeDiff:!0},detail:`${t.filename} line ${H.realLine} ("${$.trim()}")`})}}):null]}),[S.allowed,S.reason,D.allowed,D.reason,i,oe,ae,z,F,f,x,t.filename,B,O,r,h]);return e.jsxs("article",{className:"overflow-hidden rounded-md border border-border/60",children:[e.jsxs("div",{className:"sticky top-8 z-[5] flex items-center gap-1.5 bg-[var(--surface-muted)] px-2 py-1.5",children:[e.jsx(P,{type:"button",variant:"ghost",size:"icon",onClick:()=>n(t.filename),"aria-label":s?`Expand ${t.filename}`:`Collapse ${t.filename}`,title:s?"Expand":"Collapse",className:"size-6",children:e.jsx(M,{name:s?"arrow-right-s":"arrow-down-s",className:"size-4"})}),e.jsx(M,{name:lt(_),className:xe("size-3.5 shrink-0",Re(_)),"aria-hidden":"true"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono typography-micro",title:t.filename,children:[X?e.jsxs("span",{className:"text-muted-foreground",children:[X,"/"]}):null,e.jsx("span",{className:"text-foreground",children:R})]}),_!=="other"?e.jsx("span",{className:xe("shrink-0 rounded px-1 font-mono typography-micro",Re(_)),title:t.status??void 0,children:Ms(_)}):null,e.jsx(ge,{additions:t.additions,deletions:t.deletions,className:"typography-micro"}),c.length>0||Z.length>0?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-muted-foreground",title:`${c.length} ${c.length===1?"conversation":"conversations"}${Z.length>0?`, ${Z.length} pending`:""}`,children:[e.jsx(M,{name:"chat-1",className:"size-3.5","aria-hidden":"true"}),c.length>0?e.jsx("span",{className:"tabular-nums",children:ee>0?ee:c.length}):null,Z.length>0?e.jsxs("span",{className:"tabular-nums",children:["+",Z.length]}):null]}):null,e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",onClick:w=>w.stopPropagation(),children:[e.jsx(Lt,{checked:a,onChange:w=>l(t.filename,w),ariaLabel:a?`Mark ${t.filename} as not viewed`:`Mark ${t.filename} as viewed`}),e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Viewed"})]}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{h({key:`${B}-agent`,kind:"file",directory:r,repo:f,number:x,contextType:"pr",contextOptions:{includeDiff:!0},detail:t.filename})},disabled:O===`${B}-agent`,"aria-label":`Send ${t.filename} to agent`,children:"Send to agent"})]}),s?null:e.jsxs("div",{className:"flex flex-col gap-2 p-2",children:[ne.length>0?e.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md bg-[var(--surface-muted)] px-2 py-2",children:[e.jsxs("p",{className:"typography-micro text-muted-foreground",children:["Other conversations (",ne.length,") — ",ne.length===1?"this line is":"these lines are"," no longer in the diff"]}),ne.map(w=>e.jsx(Oe,{thread:w,replyAllowed:S.allowed,replyDisabledReason:S.reason,resolveAllowed:D.allowed,resolveDisabledReason:D.reason,busy:i,onReply:$=>oe(w,$),onToggleResolved:()=>ae(w)},w.id))]}):null,Q?e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-[var(--surface-muted)] px-3 py-3 typography-ui",children:[e.jsx(M,{name:"file",className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsxs("p",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:["Large diff — ",it(t)," changed lines"]}),e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>de(!0),children:"Load diff"})]}):t.patch?e.jsx("div",{className:"min-h-24 overflow-hidden",children:e.jsx(Ls,{original:N,modified:E,language:ts(t.filename),fileName:t.filename,renderSideBySide:!1,layout:"inline",enableGutterUtility:V.allowed&&j===null,enableLineSelection:V.allowed&&j===null,onGutterUtilityClick:K,onLineSelectionEnd:K,lineAnnotations:se,renderAnnotation:w=>ue(w)})}):e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-[var(--surface-muted)] px-3 py-3 typography-ui",children:[e.jsx(M,{name:"file",className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("p",{className:"min-w-0 flex-1 text-muted-foreground",children:"Diff not available for this file."}),d?e.jsx(P,{type:"button",variant:"link",size:"sm",asChild:!0,children:e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",children:"Open on GitHub"})}):null]})]})]})},Is=o.memo(qs),Os=({directory:t,repo:s,number:n,github:a,pr:l,access:d,onCommented:c})=>{const r=I(i=>i.addComment),f=I(i=>i.performAction),x=le(i=>i.clearCommentDraft),{draft:k,onDraftChange:m,flushDraft:g}=mt(s,n),{busy:p,error:z,submit:F}=ht({postComment:i=>r(t,s,n,i,a),runFollowUp:i=>f(t,s,n,i,a),verbs:{close:"close",reopen:"reopen"},doneLabels:{close:"Closed with comment",reopen:"Reopened with comment"},afterPost:()=>{m(""),x(s,n),c()}}),L=st(d),j=l.state==="open"?"close":l.state==="closed"?"reopen":null,b=j?te(j,l,d):null;return L.allowed?e.jsx(ft,{draft:k,onDraftChange:m,onDraftBlur:g,ariaLabel:"Leave a comment on this pull request",busy:p,error:z,disabledReason:L.reason,followUp:j?{id:j,label:j==="close"?"Close with comment":"Reopen with comment",busyLabel:j==="close"?"Closing…":"Reopening…",onRun:()=>{F(j,k)},allowed:b?.allowed===!0,reason:b?.reason}:null,onSubmitComment:()=>{F("comment",k)}}):null},Bs={comment:"Comment",approve:"Approve","request-changes":"Request changes"},_s=({repo:t,number:s,verdicts:n,summary:a,verdict:l,pendingCount:d,busy:c,textareaRef:r,onSubmit:f})=>{const x=le(p=>p.setSummary),k=le(p=>p.setVerdict),m=n.includes(l)?l:n[0]??"comment",g=as({verdict:m,summary:a,pendingCount:d});return e.jsxs("div",{children:[e.jsx(Mt,{ref:r,rows:3,value:a,placeholder:"Summarize your review (optional)","aria-label":"Review summary",disabled:c,onChange:p=>x(t,s,p.target.value),onKeyDown:p=>{p.nativeEvent.isComposing||p.key==="Enter"&&(p.metaKey||p.ctrlKey)&&!p.shiftKey&&!p.altKey&&!p.repeat&&(p.preventDefault(),p.stopPropagation(),g&&!c&&f())}}),e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[e.jsxs("label",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:"sr-only",children:"Review verdict"}),e.jsx("select",{value:m,disabled:c,onChange:p=>k(t,s,p.target.value),"aria-label":"Review verdict",className:"h-7 max-w-40 truncate rounded-md border border-border bg-[var(--surface-elevated)] px-1.5 typography-micro text-foreground",children:n.map(p=>e.jsx("option",{value:p,children:Bs[p]},p))})]}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:c||!g,title:g?`Submit review${d>0?` with ${d} ${d===1?"line comment":"line comments"}`:""}`:"Add a summary or a line comment first",onClick:f,children:c?"Submitting…":"Submit review"})]})]})},ct=({directory:t,repo:s,number:n,github:a,access:l,size:d="sm",onReviewSubmitted:c})=>{const r=I(T=>T.submitReview),f=le(T=>T.removeComments),x=le(T=>T.clearSummary),k=le(T=>T.clearComments),m=Le(s,n),g=xt(s,n),p=pt(s,n),[z,F]=o.useState(!1),[L,j]=o.useState(!1),b=o.useRef(null),i=o.useMemo(()=>ns(l),[l]),C=i.includes(p)?p:i[0]??"comment",h=m.length,O=h>0||g.trim().length>0;if(o.useEffect(()=>{if(!z)return;const T=window.requestAnimationFrame(()=>b.current?.focus({preventScroll:!0}));return()=>window.cancelAnimationFrame(T)},[z]),i.length===0)return null;const N=async()=>{if(L)return;const T=g,B=[...m];j(!0);try{const V=B.map(D=>({path:D.path,body:D.body,...D.line!=null?{line:D.line}:{},...D.side?{side:D.side}:{}})),S=await r(t,s,n,{event:C,body:T.trim()?T:void 0,comments:V},a);if(!S.ok){G.error(S.error?.kind==="failed"?S.error.message:"Failed to submit review");return}f(s,n,B.map(D=>D.id)),x(s,n,T),G.success(C==="approve"?"Pull request approved":C==="request-changes"?"Changes requested":"Review submitted"),F(!1),c?.()}finally{j(!1)}},E=h>0?`Review · ${h}`:"Review";return e.jsxs(We,{open:z,onOpenChange:F,children:[e.jsxs(Ye,{render:e.jsx(P,{type:"button",variant:h>0?"default":"outline",size:d,className:"shrink-0","aria-label":h>0?`Review pull request, ${h} ${h===1?"line comment":"line comments"} pending`:"Review pull request",title:O?"Finish your review":"Approve, request changes, or comment with a review"}),children:[e.jsx(M,{name:"file-check",className:"size-3.5","aria-hidden":"true"}),E]}),e.jsx(Qe,{children:e.jsx(Xe,{className:"z-50",side:"top",align:"end",sideOffset:8,collisionPadding:8,children:e.jsxs(Ze,{"aria-label":"Review pull request",className:"w-[min(24rem,calc(100vw-2rem))] rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-3 shadow-lg",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("p",{className:"min-w-0 truncate typography-ui-label text-foreground",children:h>0?`Review · ${h} ${h===1?"line comment":"line comments"}`:"Review pull request"}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[h>0?e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Discard pending line comments",title:"Discard pending line comments",disabled:L,onClick:()=>k(s,n),className:"size-6",children:e.jsx(M,{name:"delete-bin",className:"size-3.5"})}):null,e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Close review",onClick:()=>F(!1),className:"size-6",children:e.jsx(M,{name:"close",className:"size-3.5"})})]})]}),e.jsx(_s,{repo:s,number:n,verdicts:i,summary:g,verdict:C,pendingCount:h,busy:L,textareaRef:b,onSubmit:()=>{N()}})]})})})]})},ye=(t,s)=>`${t}#${s}`,Be=50,Us=Object.freeze([]),_e=(t,s)=>{const n=Object.keys(t);if(n.length<=Be)return t;const a={};for(const l of n.slice(n.length-Be))a[l]=t[l];if(!(s in a)&&s in t){const l=Object.keys(a)[0];delete a[l],a[s]=t[s]}return a},pe=Es()(Fs((t,s)=>({entries:{},setViewed:(n,a,l,d)=>{const c=ye(n,a);(s().entries[c]?.viewed.includes(l)??!1)!==d&&t(x=>{const k=x.entries[c]??{viewed:[],headSha:null},m=d?[...k.viewed,l]:k.viewed.filter(g=>g!==l);return{entries:_e({...x.entries,[c]:{...k,viewed:m}},c)}})},syncHeadSha:(n,a,l)=>{const d=ye(n,a),c=s().entries[d];c&&c.headSha===(l??null)||t(r=>({entries:_e({...r.entries,[d]:{viewed:[],headSha:l??null}},d)}))},resetForRuntimeSwitch:()=>t({entries:{}})}),{name:"pichamber:github-viewed-files",version:1,storage:ks(),partialize:t=>({entries:t.entries})}));typeof window<"u"&&Cs(()=>{pe.getState().resetForRuntimeSwitch()});const Vs=(t,s)=>pe(n=>n.entries[ye(t,s)]?.viewed??Us),Ks=(t,s)=>pe(n=>n.entries[ye(t,s)]?.viewed.length??0),Ue=20,Js=[],Ws=[],Ve=t=>`pr-file-${encodeURIComponent(t)}`,dt=o.memo(({file:t,viewed:s,threadCount:n,pendingCount:a,showDir:l,onSelectFile:d})=>{const c=at(t.status),{dir:r,base:f}=ot(t.filename);return e.jsxs("button",{type:"button",onClick:()=>d(t.filename),title:t.filename,"aria-label":`Go to ${t.filename}`,className:"flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-left hover:bg-interactive-hover",children:[e.jsx(M,{name:lt(c),className:xe("size-3.5 shrink-0",Re(c)),"aria-hidden":"true"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono typography-micro",children:[l&&r?e.jsxs("span",{className:"text-muted-foreground",children:[r,"/"]}):null,e.jsx("span",{className:"text-foreground",children:f})]}),e.jsx(ge,{additions:t.additions,deletions:t.deletions,className:"typography-micro"}),n>0?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-0.5 typography-micro text-muted-foreground",title:`${n} ${n===1?"conversation":"conversations"}`,children:[e.jsx(M,{name:"chat-1",className:"size-3","aria-hidden":"true"}),e.jsx("span",{className:"tabular-nums",children:n})]}):null,a>0?e.jsxs("span",{className:"shrink-0 tabular-nums typography-micro text-muted-foreground",title:`${a} pending`,children:["+",a]}):null,s?e.jsx(M,{name:"check",className:"size-3.5 shrink-0 text-[var(--status-success)]","aria-label":"Viewed"}):null]})});dt.displayName="FileJumpRow";const ut=({files:t,viewedPaths:s,threadCounts:n,pendingCounts:a,onSelectFile:l})=>{const[d,c]=o.useState(""),r=o.useMemo(()=>zs(t),[t]),f=o.useMemo(()=>new Set(s),[s]),x=d.trim().toLowerCase(),k=o.useMemo(()=>x?r.map(m=>({...m,files:m.files.filter(g=>g.filename.toLowerCase().includes(x))})).filter(m=>m.files.length>0):r,[r,x]);return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-1",children:[e.jsx(tt,{value:d,onChange:m=>c(m.target.value),placeholder:"Filter files","aria-label":"Filter files",className:"h-7 shrink-0 typography-micro"}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",role:"list","aria-label":"Changed files",children:k.length===0?e.jsx("p",{className:"px-1.5 py-2 typography-micro text-muted-foreground",children:t.length===0?"No changed files":"No files match"}):k.map(m=>e.jsxs("div",{role:"group","aria-label":m.folder||"Repository root",children:[r.length>1?e.jsx("p",{className:"truncate px-1.5 pt-1.5 pb-0.5 typography-micro text-muted-foreground",title:m.folder||"/",children:m.folder||"/"}):null,m.files.map(g=>e.jsx(dt,{file:g,viewed:f.has(g.filename),threadCount:n.get(g.filename)??0,pendingCount:a.get(g.filename)??0,showDir:r.length<=1,onSelectFile:l},g.filename))]},m.folder))})]})},Ys=t=>{const[s,n]=o.useState(!1),{onSelectFile:a}=t,l=o.useCallback(d=>{n(!1),a(d)},[a]);return e.jsxs(We,{open:s,onOpenChange:n,children:[e.jsxs(Ye,{render:e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"shrink-0","aria-label":`Jump to file, ${t.files.length} ${t.files.length===1?"file":"files"}`,title:"Jump to file"}),children:[e.jsx(M,{name:"file",className:"size-3.5","aria-hidden":"true"}),"Files"]}),e.jsx(Qe,{children:e.jsx(Xe,{className:"z-50",side:"bottom",align:"start",sideOffset:4,collisionPadding:8,children:e.jsx(Ze,{"aria-label":"Jump to file",className:"flex max-h-[min(28rem,calc(100dvh-4rem))] w-[min(22rem,calc(100vw-2rem))] flex-col rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-1.5 shadow-lg",children:e.jsx(ut,{...t,onSelectFile:l})})})})]})},Qs=48,Xs=(t,s)=>{const[n,a]=o.useState(null);return o.useLayoutEffect(()=>{if(!s)return;const l=t.current?.closest("[data-diff-virtual-root]");if(!(l instanceof HTMLElement))return;const d=()=>{const r=Math.max(160,Math.floor(l.clientHeight-Qs));a(f=>f===r?f:r)};if(d(),typeof ResizeObserver>"u")return;const c=new ResizeObserver(d);return c.observe(l),()=>c.disconnect()},[t,s]),n},Zs=t=>{const{directory:s,repo:n,number:a,github:l,access:d,headSha:c=null}=t,r=t.files?.files??Js,f=Vs(n,a),x=Ks(n,a),k=Le(n,a);o.useEffect(()=>{pe.getState().syncHeadSha(n,a,c)},[n,a,c]);const m=o.useMemo(()=>Ds(r),[r]),g=o.useRef(m);g.current=m;const p=o.useRef(r);p.current=r;const[z,F]=o.useState({}),[L,j]=o.useState(Ue),b=o.useMemo(()=>As(r),[r]),i=o.useMemo(()=>{const R=new Map;for(const q of t.threads){if(!q.path)continue;const y=R.get(q.path)??[];y.push(q),R.set(q.path,y)}return R},[t.threads]),C=o.useMemo(()=>{const R=new Map;for(const[q,y]of i)R.set(q,y.length);return R},[i]),h=o.useMemo(()=>{const R=new Map;for(const q of k)R.set(q.path,(R.get(q.path)??0)+1);return R},[k]),O=o.useCallback(R=>{F(q=>({...q,[R]:!(q[R]??g.current[R]??!1)}))},[]),N=o.useCallback(()=>{F(Object.fromEntries(p.current.map(R=>[R.filename,!1])))},[]),E=o.useCallback(()=>{F(Object.fromEntries(p.current.map(R=>[R.filename,!0])))},[]),T=o.useCallback((R,q)=>{pe.getState().setViewed(n,a,R,q),F(y=>({...y,[R]:q}))},[n,a]),B=o.useCallback(R=>{F(y=>y[R]??g.current[R]??!1?{...y,[R]:!1}:y);const q=p.current.findIndex(y=>y.filename===R);q>=0&&j(y=>q<y?y:q+1),requestAnimationFrame(()=>{document.getElementById(Ve(R))?.scrollIntoView({block:"start"})})},[]),V=o.useMemo(()=>r.slice(0,L),[r,L]),S=o.useRef(null),D=Xs(S,V.length>0),K=o.useMemo(()=>new Set(f),[f]),_=r.length===1?"1 file":`${r.length} files`,X=r.length===0?"Nothing viewed yet":`${x}/${r.length} viewed`;return e.jsxs("section",{"aria-label":"Changed files",className:"@container flex flex-col gap-2","data-diff-virtual-content":!0,children:[e.jsx(ve,{error:t.filesError,onRetry:t.onRetryFiles,label:"Changed files"}),e.jsx(ve,{error:t.threadsError,onRetry:t.onRetryDetail,label:"Review threads"}),e.jsxs("div",{className:"sticky top-0 z-10 flex h-8 shrink-0 items-center gap-2 border-b border-border/60 bg-[var(--surface-background)] px-1 text-[12px]",children:[e.jsx("span",{className:"shrink-0 text-muted-foreground",children:_}),e.jsx(ge,{additions:b.additions,deletions:b.deletions}),e.jsxs("span",{className:"shrink-0 tabular-nums text-muted-foreground","aria-label":X,children:[x,"/",r.length," viewed"]}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[e.jsx(ct,{directory:s,repo:n,number:a,github:l,access:d,size:"xs",onReviewSubmitted:t.onReviewSubmitted}),e.jsx("span",{className:"@4xl:hidden",children:e.jsx(Ys,{files:r,viewedPaths:f,threadCounts:C,pendingCounts:h,onSelectFile:B})}),e.jsx(P,{type:"button",variant:"ghost",size:"icon",onClick:N,"aria-label":"Expand all files",title:"Expand all files",className:"size-7",children:e.jsx(M,{name:"expand-up-down",className:"size-3.5"})}),e.jsx(P,{type:"button",variant:"ghost",size:"icon",onClick:E,"aria-label":"Collapse all files",title:"Collapse all files",className:"size-7",children:e.jsx(M,{name:"collapse-vertical",className:"size-3.5"})})]})]}),t.filesLoading&&V.length===0?e.jsx(Rs,{rows:5,label:"Loading changed files"}):null,!t.filesLoading&&V.length===0?e.jsx("p",{className:"px-1 py-4 typography-micro text-muted-foreground",children:"No changed files"}):null,V.length>0?e.jsxs("div",{className:"flex min-h-0 items-start gap-3",children:[e.jsx("aside",{ref:S,"aria-label":"Changed files",style:D!=null?{height:D}:void 0,className:"sticky top-10 hidden max-h-[calc(100dvh-10rem)] w-60 shrink-0 flex-col @4xl:flex",children:e.jsx(ut,{files:r,viewedPaths:f,threadCounts:C,pendingCounts:h,onSelectFile:B})}),e.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:V.map(R=>e.jsx("div",{id:Ve(R.filename),className:"scroll-mt-12",children:e.jsx(Is,{file:R,collapsed:z[R.filename]??m[R.filename]??!1,onToggleCollapse:O,viewed:K.has(R.filename),onToggleViewed:T,blobUrl:$s(n,c,R.filename),threads:i.get(R.filename)??Ws,directory:s,repo:n,number:a,github:l,access:d,onThreadsChanged:t.onRetryDetail})},R.filename))})]}):null,r.length>L?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>j(L+Ue),children:"Show more files"})}):null,t.filesHasMore?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:t.onLoadMoreFiles,children:"Load more files"})}):null]})},en=({directory:t,repo:s,number:n,github:a,checks:l,checksError:d,checksLoading:c,onRetryChecks:r,onOpenFilesAtLine:f})=>{const[x,k]=o.useState({}),[m,g]=o.useState({}),{send:p,sendingKey:z}=Fe(),F=ls(l);return e.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-1 py-1",children:[e.jsx("p",{className:"min-w-0 flex-1 typography-micro text-muted-foreground","aria-live":"polite",children:F?F.text:c?"Loading checks…":"No checks reported for this pull request."}),F&&F.failed>0?e.jsxs(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{p({key:`pr-${n}-failed-checks`,kind:"checks",directory:t,repo:s,number:n,contextType:"checks"})},disabled:z===`pr-${n}-failed-checks`,"aria-label":"Send failed checks to agent",title:"Send failed checks to agent",children:[e.jsx(M,{name:"send-plane-2",className:"size-3.5"}),"Send failures to agent"]}):null,e.jsxs(P,{type:"button",variant:"ghost",size:"xs",onClick:r,"aria-label":"Refresh checks",title:"Refresh checks",children:[e.jsx(M,{name:"refresh",className:xe("size-3.5",c&&"animate-spin")}),"Refresh"]})]}),e.jsx(ve,{error:d,onRetry:r,label:"Checks"}),l?e.jsx(tn,{checks:l,directory:t,repo:s,number:n,github:a,expandedJobs:x,onToggleJob:L=>k(j=>({...j,[L]:!j[L]})),jobSteps:m,setJobSteps:g,sendingKey:z,send:p,onOpenFilesAtLine:f}):null]})},tn=({checks:t,directory:s,repo:n,number:a,github:l,expandedJobs:d,onToggleJob:c,jobSteps:r,setJobSteps:f,sendingKey:x,send:k,onOpenFilesAtLine:m})=>{const g=I(i=>i.rerunFailedChecks),[p,z]=o.useState({}),F=async i=>{const C=`run-${i.id??i.name}`;if(c(C),!(d[C]||r[C]||i.id==null)){f(h=>({...h,[C]:{steps:[],loading:!0}}));try{const O=(await l.checkJobs(s,n,i.runId??null,i.id)).jobs[0];f(E=>({...E,[C]:{steps:O?.steps??[],loading:!1}}));const N=await l.checkAnnotations(s,n,i.id).catch(()=>null);N&&z(E=>({...E,[i.id]:{loading:!1,items:N.annotations}}))}catch{f(h=>({...h,[C]:{steps:[],loading:!1}}))}}},L=async i=>{(await g(s,n,i,l)).ok?G.success("Re-run requested"):G.error("Re-run failed")},j=i=>{const C=`run-${i.id??i.name}`,h=d[C]??!1,O=r[C],N=os(i);return e.jsxs("div",{className:"rounded-md px-2 py-2 hover:bg-interactive-hover",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(fe,{state:i.conclusion??i.status}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui text-foreground",title:i.name,children:i.name}),i.conclusion?e.jsx("span",{className:"typography-micro text-muted-foreground",children:i.conclusion}):null,e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{F(i)},"aria-expanded":h,"aria-label":`${h?"Collapse":"Expand"} ${i.name}`,children:"Details"}),N&&i.runId!=null?e.jsx(P,{type:"button",variant:"outline",size:"xs",onClick:()=>{L(i.runId)},children:"Re-run"}):null,N?e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{k({key:`${C}-agent`,kind:"check",directory:s,repo:n,number:a,contextType:"checks",detail:i.name})},disabled:x===`${C}-agent`,"aria-label":`Send ${i.name} to agent`,children:"Send to agent"}):null]}),h?e.jsxs("div",{className:"mt-1.5 flex flex-col gap-1 border-t border-border/60 pt-1.5",children:[O?.loading?e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Loading steps…"}):null,(O?.steps??[]).map((E,T)=>e.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(fe,{state:E.conclusion??E.status}),e.jsx("span",{className:"truncate",children:E.name}),E.conclusion?e.jsxs("span",{children:["· ",E.conclusion]}):null]},`${E.name}-${T}`)),i.id!=null&&p[i.id]?.items?.length?e.jsx("div",{className:"flex flex-col gap-1",children:p[i.id]?.items.map((E,T)=>e.jsxs("div",{className:"typography-micro text-muted-foreground",children:[E.path&&E.startLine&&m?e.jsxs("button",{type:"button",className:"font-mono underline",onClick:()=>m(E.path,E.startLine),children:[E.path,":",E.startLine]}):e.jsxs("span",{className:"font-mono",children:[E.path,E.startLine?`:${E.startLine}`:""]})," ",E.title?e.jsxs("span",{className:"text-foreground",children:[E.title," — "]}):null,E.message]},T))}):null]}):null]},C)},b=(i,C)=>e.jsxs("div",{className:"flex items-center gap-1.5 rounded-md px-2 py-2 hover:bg-interactive-hover",children:[e.jsx(fe,{state:i.state}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui text-foreground",title:i.context,children:i.context}),i.description?e.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:i.description}):null]},`${i.context}-${C}`);return e.jsxs("div",{className:"flex flex-col gap-1",children:[t.sectionErrors?.runs||t.sectionErrors?.statuses?e.jsx("div",{className:"rounded-md border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] px-2 py-1 typography-micro text-foreground",role:"alert",children:"Some check sources failed to load; counts below are partial, not empty."}):null,t.runs.length>0?e.jsx("div",{className:"flex flex-col","aria-label":"Check runs",children:t.runs.map(j)}):null,t.statuses.length>0?e.jsx("div",{className:"flex flex-col","aria-label":"Commit statuses",children:t.statuses.map(b)}):null,t.runs.length===0&&t.statuses.length===0?e.jsx("p",{className:"typography-ui text-muted-foreground",children:"No checks reported for this pull request."}):null]})},Ke=({pr:t})=>e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(nt,{login:t.author?.login,avatarUrl:t.author?.avatarUrl,size:"xs"}),t.author?.login??"ghost"]}),t.updatedAt?` · updated ${gs(t.updatedAt)}`:"",t.draft?" · Draft":""]}),Je=({pr:t,filesCount:s})=>e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"shrink-0 truncate",title:t.base,children:t.base}),e.jsx("span",{className:"shrink-0","aria-label":"receives changes from",children:"←"}),e.jsx("code",{className:"min-w-0 flex-1 truncate",title:t.head,children:t.head}),typeof s=="number"?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 tabular-nums",children:[e.jsx(M,{name:"file-code",className:"size-3 shrink-0","aria-hidden":"true"}),s," ",s===1?"file":"files"]}):null,e.jsx(ge,{additions:t.additions,deletions:t.deletions})]}),sn=({repo:t,pr:s,access:n,acting:a,mergeMethod:l,onMergeMethodChange:d,onRun:c,checkingOut:r,onCheckout:f,onCopyLink:x,askSending:k,onAskAgent:m})=>{const g=I(N=>N.setMergeMethod),p=s.state==="open",z=be.filter(N=>te(N.id,s,n).allowed),F=z.some(N=>N.id===l)?l:z[0]?.id??l,L=te(F,s,n),j=te("ready",s,n),b=te("draft",s,n),i=te("close",s,n),C=te("reopen",s,n),h=be.find(N=>N.id===F)??be[0],O=z.length===0||a;return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-3 pt-1 pb-2","aria-label":"Pull request actions",children:[p&&!s.draft?e.jsxs("span",{role:"group","aria-label":"Merge pull request",className:"inline-flex shrink-0 items-center gap-1",children:[e.jsx(ce,{copy:he(F,s.base,s.head),busy:a,disabled:!L.allowed,disabledReason:L.reason??`Merge via ${h.label}`,label:F==="merge"?"Merge pull request":h.label,icon:e.jsx(M,{name:"git-merge",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c(F)}),e.jsxs(Me,{modal:!1,children:[e.jsx(ze,{asChild:!0,children:e.jsx(P,{type:"button",variant:"default",size:"xs",className:"shrink-0 px-1.5",title:"Merge options","aria-label":"Merge options",disabled:O,children:e.jsx(M,{name:"arrow-down-s",className:"size-3.5"})})}),e.jsx(Ae,{align:"start",className:"w-72",children:e.jsx(Et,{value:F,onValueChange:N=>{const E=N;d(E),g(t,E)},children:be.map(N=>{const E=te(N.id,s,n);return e.jsx(Ft,{value:N.id,disabled:!E.allowed,title:E.reason??N.description,children:e.jsxs("span",{className:"flex min-w-0 flex-col",children:[e.jsx("span",{className:"truncate",children:N.label}),e.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:N.description})]})},N.id)})})})]})]}):null,p&&s.draft?e.jsx(ce,{copy:he("ready",s.base,s.head),busy:a,disabled:!j.allowed,disabledReason:j.reason??"Ready for review",label:"Ready for review",icon:e.jsx(M,{name:"git-pull-request",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("ready")}):null,p&&!s.draft?e.jsx(ce,{copy:he("draft",s.base,s.head),busy:a,variant:"outline",disabled:!b.allowed,disabledReason:b.reason??"Convert to draft",label:"Convert to draft",icon:e.jsx(M,{name:"pencil",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("draft")}):null,p?e.jsx(ce,{copy:he("close",s.base,s.head),busy:a,destructive:!0,variant:"outline",disabled:!i.allowed,disabledReason:i.reason??"Close pull request",label:"Close",icon:e.jsx(M,{name:"close",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("close")}):e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>c("reopen"),disabled:!C.allowed||a,title:C.reason??"Reopen pull request","aria-label":"Reopen pull request",children:[e.jsx(M,{name:"history",className:"size-3.5","aria-hidden":"true"}),"Reopen"]}),e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>f("worktree"),disabled:r,title:"Check out in a new worktree","aria-label":"Check out in a new worktree",children:[e.jsx(M,{name:"git-branch",className:"size-3.5","aria-hidden":"true"}),r?"Checking out…":"Check out"]}),e.jsx(ce,{copy:{title:"Check out this branch here?",detail:"This switches your current checkout to the PR branch. Uncommitted work may be disrupted.",confirm:"Check out here",progress:"Checking out…"},busy:r,variant:"outline",label:"Check out here",icon:e.jsx(M,{name:"git-branch",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>f("current")}),e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:m,disabled:k,title:"Send pull request context to the agent composer","aria-label":"Ask agent about this pull request",children:[e.jsx(M,{name:"send-plane-2",className:"size-3.5","aria-hidden":"true"}),k?"Asking…":"Ask agent"]}),e.jsxs(P,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{Se(s.url)},title:"Review on GitHub","aria-label":"Review on GitHub",children:[e.jsx(M,{name:"external-link",className:"size-3.5","aria-hidden":"true"}),"Review on GitHub"]}),e.jsxs(Me,{modal:!1,children:[e.jsx(ze,{asChild:!0,children:e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 px-1.5","aria-label":"More pull request actions",title:"More pull request actions",children:e.jsx(M,{name:"more-2",className:"size-4"})})}),e.jsxs(Ae,{align:"end",className:"w-60",children:[e.jsxs(we,{onClick:()=>{Se(s.url)},children:[e.jsx(M,{name:"external-link",className:"size-3.5"}),"Open on GitHub"]}),e.jsxs(we,{onClick:x,children:[e.jsx(M,{name:"file-copy",className:"size-3.5"}),"Copy link"]}),e.jsx(Pt,{}),e.jsxs(we,{onClick:()=>f("worktree"),disabled:r,children:[e.jsx(M,{name:"git-branch",className:"size-3.5"}),"Check out in new worktree"]})]})]})]})},nn=({pr:t,access:s,acting:n,onRun:a})=>{const l=bs(t);if(!l)return null;const d=te("update-branch",t,s),c=l.tone==="error"?"border-[var(--status-error-border)] bg-[var(--status-error-background)] text-foreground":"border-[var(--status-warning-border)] bg-[var(--status-warning-background)] text-foreground",r=l.tone==="error"?"text-[var(--status-error)]":"text-[var(--status-warning)]";return e.jsxs("div",{className:`mx-3 mb-2 flex flex-wrap items-center gap-x-2 gap-y-1.5 rounded-md border px-2.5 py-2 ${c}`,role:"status",children:[e.jsx(M,{name:l.icon,className:`size-4 shrink-0 ${r}`,"aria-hidden":"true"}),e.jsxs("p",{className:"min-w-0 flex-1 basis-48",children:[e.jsxs("span",{className:"typography-ui-label font-medium",children:[l.title," ",e.jsx("code",{className:"font-mono",children:t.base})]}),e.jsx("span",{className:"block typography-micro text-muted-foreground",children:l.detail})]}),l.canUpdate?e.jsx(ce,{copy:he("update-branch",t.base,t.head),busy:n,variant:"outline",disabled:!d.allowed,disabledReason:d.reason??"Update branch",label:"Update branch",icon:e.jsx(M,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>a("update-branch")}):e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{Se(t.url)},title:"Resolve conflicts on GitHub","aria-label":"Resolve conflicts on GitHub",children:[e.jsx(M,{name:"external-link",className:"size-3.5","aria-hidden":"true"}),"Resolve on GitHub"]})]})},an=t=>{const{directory:s,repo:n,number:a,github:l,detail:d}=t,c=I(u=>u.performAction),r=I(u=>u.updateTitleBody),f=I(u=>u.checkout),[x,k]=o.useState("summary"),[m,g]=o.useState(!1),[p,z]=o.useState(()=>zt(n)??"merge"),[F,L]=o.useState(!1),[j,b]=o.useState(""),[i,C]=o.useState(!1),[h,O]=o.useState(""),[N,E]=o.useState("newest"),[T,B]=o.useState(1),[V,S]=o.useState(!1),[D,K]=o.useState(null),_=gt(n,a),{send:X,sendingKey:R}=Fe(),q=is(s,n),y=d?.pr??null,de=d?.sectionErrors??null,Q=o.useMemo(()=>({capabilities:d?.capabilities??null,isAuthor:rs(y?.author?.login,d?.viewerLogin),permissionFallback:d?.viewerPermission?.fallback===!0}),[d?.capabilities,d?.viewerLogin,d?.viewerPermission?.fallback,y?.author?.login]),ee=cs(y,Q);o.useEffect(()=>{k("summary"),L(!1),C(!1),B(1),K(null)},[n,a]);const Z=o.useCallback(async u=>{g(!0);try{const Y=await c(s,n,a,u,l);if(!Y.ok){G.error(Y.error?.kind==="failed"?Y.error.message:"Action failed");return}u==="close"?G.success("Pull request closed"):u==="reopen"?G.success("Pull request reopened"):u==="update-branch"?G.success("Branch update requested"):u==="ready"?G.success("Marked as ready for review"):u==="draft"?G.success("Converted to draft"):G.success("Pull request merged")}finally{g(!1)}},[s,n,a,l,c]),se=o.useCallback(()=>{X({key:`pr-${a}-ask`,kind:"pr",directory:s,repo:n,number:a,contextType:"pr"})},[X,s,n,a]),ne=o.useCallback(async()=>{if(!j.trim()){G.error("Enter a title");return}const u=await r(s,n,a,{title:j.trim()},l);u.ok?(G.success("Title updated"),L(!1)):G.error(u.error?.kind==="failed"?u.error.message:"Failed to update title")},[j,s,n,a,l,r]),oe=o.useCallback(async()=>{const u=await r(s,n,a,{body:h},l);u.ok?(G.success("Description updated"),C(!1)):G.error(u.error?.kind==="failed"?u.error.message:"Failed to update description")},[h,s,n,a,l,r]),ae=Ee().git,ue=o.useCallback(async u=>{if(u==="current"){const Y=await Ne(()=>import("./useAppFontEffects-DJCrUN2D.js").then(re=>re.f8),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(re=>re.useGitStore.getState().directories.get(s)?.status??null).catch(()=>null);if(Y&&!Y.isClean){G.error("Working tree has uncommitted changes. Commit or stash first, or use New worktree.");return}}S(!0);try{const Y=await f(s,n,a,u,l);Y.ok?(await bt(s,ae),K({path:Y.path??null,branch:Y.branch??""}),G.success(u==="worktree"?"Worktree created":"Branch checked out")):G.error(Y.error?.kind==="failed"?Y.error.message:"Checkout failed")}finally{S(!1)}},[s,n,a,l,ae,f]),w=o.useCallback(()=>{D?.path&&Ne(async()=>{const{useSessionUIStore:u}=await import("./useAppFontEffects-DJCrUN2D.js").then(Y=>Y.f5);return{useSessionUIStore:u}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(({useSessionUIStore:u})=>{u.getState().openNewSessionDraft({directoryOverride:D.path}),Ns.getState().setActiveMainTab("chat")})},[D]),$=ds(y?.url),H=o.useMemo(()=>{const u=[...t.comments];return u.sort((Y,je)=>{const re=Y.createdAt?Date.parse(Y.createdAt):0,Te=je.createdAt?Date.parse(je.createdAt):0;return N==="newest"?Te-re:re-Te}),u},[t.comments,N]),A=H.slice(0,T*20),U=A.filter(u=>!$e(u.author?.login)),W=A.filter(u=>$e(u.author?.login));if(t.detailError&&!d)return e.jsx(ke,{header:e.jsx(Ce,{onBack:t.onBack,backLabel:"Back to pull requests",repoName:q,number:a,openLabel:`Open pull request #${a} on GitHub`,title:`Pull request #${a}`}),tabs:[],activeTab:"",onTabChange:()=>{},children:e.jsx(et,{info:vt(t.detailError),onRetry:t.onRetryDetail})});if(!y){const u=t.seed&&t.seed.number===a?t.seed:null;return e.jsx(ke,{header:e.jsx(Ce,{onBack:t.onBack,backLabel:"Back to pull requests",repoName:q,number:a,url:u?.url??null,numberTintClass:u?He("pr",u.state,u.draft):void 0,statePill:u?e.jsx(Ge,{kind:"pr",state:u.state,draft:u.draft}):void 0,openLabel:`Open pull request #${a} on GitHub`,title:u?.title??null,meta:u?e.jsx(Ke,{pr:u}):void 0,branches:u?e.jsx(Je,{pr:u,filesCount:u.changedFiles??null}):void 0}),tabs:[],activeTab:"",onTabChange:()=>{},children:e.jsx(us,{label:"Loading pull request"})})}const J=t.checks?.summary??null,me=t.files?.files.length??y.changedFiles??0,v=_>0&&!t.hideFilesTab?`${me} · ${_} pending`:String(me);return e.jsx(ke,{header:e.jsxs(e.Fragment,{children:[e.jsx(Ce,{onBack:t.onBack,backLabel:"Back to pull requests",repoName:q,number:y.number,url:y.url,numberTintClass:He("pr",y.state,y.draft),statePill:e.jsx(Ge,{kind:"pr",state:y.state,draft:y.draft}),openLabel:`Open pull request #${y.number} on GitHub`,title:y.title,onEditTitle:()=>{b(y.title),L(!0)},editTitleLabel:"Edit pull request title",editTitleDisabledReason:ee.allowed?null:ee.reason,meta:e.jsx(Ke,{pr:y}),branches:e.jsx(Je,{pr:y,filesCount:me})}),e.jsx(sn,{directory:s,repo:n,number:a,github:l,pr:y,access:Q,acting:m,mergeMethod:p,onMergeMethodChange:z,onRun:u=>{Z(u)},checkingOut:V,onCheckout:u=>{ue(u)},onCopyLink:$,askSending:R===`pr-${a}-ask`,onAskAgent:se}),e.jsx(nn,{pr:y,access:Q,acting:m,onRun:u=>{Z(u)}})]}),tabs:[{id:"summary",label:"Summary"},...t.hideFilesTab?[]:[{id:"files",label:"Code",hint:v}],{id:"checks",label:"Checks",hint:J?`${J.success}/${J.total}`:void 0,glyph:J?e.jsx(fe,{state:J.state}):void 0}],activeTab:x,onTabChange:u=>k(u),children:e.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2",children:[t.detailStale?e.jsxs("p",{className:"typography-micro text-muted-foreground",role:"note",children:["Showing saved details — last refresh failed."," ",e.jsx("button",{type:"button",className:"underline",onClick:t.onRetryDetail,children:"Retry"})]}):null,Q.permissionFallback?e.jsx("p",{className:"typography-micro text-muted-foreground",role:"note",children:"Permissions could not be loaded — actions stay enabled and any failure will be shown after you act."}):null,F?e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 py-1",children:[e.jsx(tt,{value:j,onChange:u=>b(u.target.value),"aria-label":"Pull request title",className:"h-7"}),e.jsx(P,{type:"button",variant:"default",size:"xs",onClick:()=>{ne()},children:"Save"}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>L(!1),children:"Cancel"})]}):null,D?e.jsxs("p",{className:"flex flex-wrap items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(M,{name:"check",className:"size-3.5 shrink-0 text-[var(--status-success)]"}),e.jsxs("span",{children:["Ready on ",D.branch,D.path?` at ${D.path}`:"","."]}),D.path?e.jsx(P,{type:"button",variant:"default",size:"xs",onClick:w,children:"Open session here"}):null,e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>K(null),"aria-label":"Dismiss checkout result",children:"Dismiss"})]}):null,x==="summary"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-1.5 py-1",children:[e.jsx(qe,{icon:"user",label:"Reviewers",children:e.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5",children:[y.requestedReviewers.length===0?e.jsx("span",{className:"typography-micro text-muted-foreground",children:"None"}):y.requestedReviewers.map(u=>e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 typography-micro text-muted-foreground",children:[e.jsx(nt,{login:u.login,avatarUrl:u.avatarUrl,size:"xs"}),e.jsx("span",{className:"truncate",children:u.login})]},u.login)),e.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground",children:[y.reviewSummary.approvals," approvals · ",y.reviewSummary.changesRequested," changes requested ·"," ",y.reviewSummary.commented," commented"]})]})}),e.jsx(qe,{icon:"list-unordered",label:"Labels",children:e.jsx("span",{className:"flex min-w-0 flex-wrap items-center gap-1",children:y.labels.length===0?e.jsx("span",{className:"typography-micro text-muted-foreground",children:"None"}):y.labels.map(u=>e.jsx(ms,{name:u.name,color:u.color},u.name))})})]}),e.jsx(Ie,{id:`pr-${a}-description`,title:"Description",action:i?void 0:e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{O(y.body??""),C(!0)},"aria-label":"Edit description",title:ee.reason??"Edit description",disabled:!ee.allowed,children:"Edit"}),children:i?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("textarea",{value:h,onChange:u=>O(u.target.value),rows:6,"aria-label":"Pull request description",className:"min-h-24 w-full rounded-md border border-border bg-[var(--surface-elevated)] p-2 typography-ui text-foreground"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(P,{type:"button",variant:"default",size:"sm",onClick:()=>{oe()},children:"Save"}),e.jsx(P,{type:"button",variant:"ghost",size:"sm",onClick:()=>C(!1),children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(hs,{markdown:y.body??"",html:y.bodyHtml??null,fallbackUrl:y.url,label:"pull request description"}),y.body?.trim()?null:e.jsx("p",{className:"typography-micro text-muted-foreground",children:"No description provided."})]})}),e.jsx(Ie,{id:`pr-${a}-comments`,title:`Comments${H.length?` (${H.length})`:""}`,action:e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1",children:[t.hideFilesTab?e.jsx(ct,{directory:s,repo:n,number:a,github:l,access:Q,size:"xs",onReviewSubmitted:t.onRetryDetail}):null,e.jsx(ps,{order:N,onToggle:()=>E(N==="newest"?"oldest":"newest")})]}),children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(ve,{error:t.commentsError,onRetry:t.onRetryComments,label:"Comments"}),U.map(u=>e.jsx(fs,{comment:u},u.id)),e.jsx(xs,{comments:W}),t.commentsLoading&&H.length===0&&!t.commentsError?e.jsx("p",{className:"typography-micro text-muted-foreground",children:"Loading comments…"}):null,H.length===0&&!t.commentsLoading&&!t.commentsError?e.jsx("p",{className:"typography-micro text-muted-foreground",children:"No comments yet."}):null,H.length>A.length?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>B(T+1),children:"Show older comments"})}):t.commentsHasMore?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:t.onLoadMoreComments,disabled:t.commentsLoading,children:t.commentsLoading?"Loading…":"Load older comments"})}):null,e.jsx(Os,{directory:s,repo:n,number:a,github:l,pr:y,access:Q,onCommented:()=>{t.onRetryComments(),t.onRetryDetail()}})]})})]}):null,x==="files"&&!t.hideFilesTab?e.jsx(Zs,{files:t.files,filesLoading:t.filesLoading,filesError:t.filesError,filesHasMore:t.filesHasMore,onLoadMoreFiles:t.onLoadMoreFiles,onRetryFiles:t.onRetryFiles,threads:t.threads,threadsError:de?.threads??null,onRetryDetail:t.onRetryDetail,directory:s,repo:n,number:a,github:l,access:Q,headSha:y.headSha??null,onReviewSubmitted:t.onRetryDetail},`${n}#${a}`):null,x==="checks"?e.jsx(en,{directory:s,repo:n,number:a,github:l,checks:t.checks,checksError:t.checksError,checksLoading:t.checksLoading,onRetryChecks:t.onRetryChecks,onOpenFilesAtLine:t.onOpenFilesAtLine}):null]})})},ln=({items:t,hasMore:s,isLoadingMore:n,isLoading:a,isRefreshing:l,stale:d,error:c,filters:r,checksByUrl:f,incompleteNotice:x=null,remote:k=null,numberJump:m=null,onFiltersChange:g,onClearFilters:p,onLoadMore:z,onRetry:F,onOpen:L,headerActionsSlot:j=null,headerActionsPresentation:b="drawer"})=>{const i=r.state==="open"&&r.involvement==="all"&&!r.search.trim(),C=o.useCallback(h=>e.jsx("li",{role:"listitem",children:e.jsx(yt,{glyph:e.jsx(vs,{kind:"pr",state:h.state,draft:h.draft}),glyphBelow:e.jsx(fe,{state:(h.url?f[h.url]:void 0)??null}),number:`#${h.number}`,title:h.title,status:e.jsx(ge,{additions:h.additions,deletions:h.deletions,className:"typography-micro"}),meta:e.jsxs(e.Fragment,{children:[e.jsx(jt,{login:h.author?.login,avatarUrl:h.author?.avatarUrl}),e.jsx(wt,{head:h.head,base:h.base}),h.draft?e.jsx("span",{className:"shrink-0 rounded bg-[var(--surface-muted)] px-1 typography-micro text-muted-foreground",children:"Draft"}):null]}),updatedAt:h.updatedAt,onOpen:()=>L(h.number),ariaLabel:`Open pull request #${h.number} ${h.title}`})},h.number),[f,L]);return e.jsx(kt,{items:t,renderRow:C,hasMore:s,isLoadingMore:n,isLoading:a,isRefreshing:l,stale:d,error:c,searchValue:r.search,onSearchChange:h=>g({search:h}),searchPlaceholder:"Search pull requests, or label:bug",searchAriaLabel:"Search pull requests",toolbarControls:e.jsx(Ct,{stateValue:r.state,stateOptions:ws.map(h=>({id:h.id,label:h.label})),onStateChange:h=>g({state:h}),involvementValue:r.involvement,involvementOptions:js.map(h=>({id:h.id,label:h.label})),onInvolvementChange:h=>g({involvement:h}),sortValue:r.sort,sortOptions:ys.map(h=>({id:h.id,label:h.label})),onSortChange:h=>g({sort:h}),sortAriaLabel:"Sort pull requests"}),headerActionsSlot:j,headerActionsPresentation:b,isDefaultFilters:i,noItemsTitle:r.state==="open"?"No open pull requests":"No pull requests yet",noItemsBody:"Pull requests for this repository appear here.",noItemsIcon:"git-pull-request",listAriaLabel:"Pull requests",skeletonLabel:"Loading pull requests",incompleteNotice:x,remote:k,numberJump:m,numberJumpKind:"pull request",onClearFilters:p,onLoadMore:z,onRetry:F,onOpen:L})},on=t=>{const s=At(n=>n.results);return o.useMemo(()=>{const n=Dt(s),a={};for(const l of t){if(!l.url)continue;const d=n.get(l.url);d!==void 0&&(a[l.url]=d)}return a},[t,s])},da=({hideFilesTab:t=!1,headerActionsSlot:s=null,headerActionsPresentation:n="drawer"})=>{const a=Tt()??"";return a?e.jsx(rn,{directory:a,hideFilesTab:t,headerActionsSlot:s,headerActionsPresentation:n}):e.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center",children:e.jsx("p",{className:"typography-ui text-muted-foreground",children:"Open a project to browse pull requests."})})},rn=({directory:t,hideFilesTab:s,headerActionsSlot:n=null,headerActionsPresentation:a="drawer"})=>{const d=Ee().github??null,[c,r]=o.useState(!1),[f,x]=o.useState(!1),k=o.useRef(null);return o.useEffect(()=>$t(),[]),e.jsx(Nt,{directory:t,isRefreshing:c,onRefresh:()=>k.current?.(),children:({repo:m,directory:g})=>e.jsx(cn,{directory:g,repo:m,github:d,refreshing:c,setRefreshing:r,loadingMore:f,setLoadingMore:x,refreshRef:k,hideFilesTab:s,headerActionsSlot:n,headerActionsPresentation:a},m)})},cn=({directory:t,repo:s,github:n,refreshing:a,setRefreshing:l,loadingMore:d,setLoadingMore:c,refreshRef:r,hideFilesTab:f,headerActionsSlot:x=null,headerActionsPresentation:k="drawer"})=>{const m=I(v=>v.ensureCollectionsFresh),g=I(v=>v.searchRemote),p=I(v=>v.loadMoreRemote),z=I(v=>v.loadMoreCollection),F=I(v=>v.refreshAllForScope),L=I(v=>v.selectPullRequest),j=I(v=>v.setFilters),b=I(v=>v.resetFilters),i=Gt(t,s),C=Ht(t),h=qt(),O=C.repo===s?C.number:null,N=i.state==="open"?"open":i.state==="all"?"both":"closed";o.useEffect(()=>{if(!n)return;let v=!1;return l(!0),m(t,s,N,n).then(()=>{v||l(!1)}).catch(()=>{v||l(!1)}),()=>{v=!0}},[t,s,n,N]),o.useEffect(()=>{if(!n)return;const v=()=>{typeof document<"u"&&document.hidden||m(t,s,N,n).catch(()=>{})};return window.addEventListener("focus",v),document.addEventListener("visibilitychange",v),()=>{window.removeEventListener("focus",v),document.removeEventListener("visibilitychange",v)}},[t,s,n,N]);const E=De(s,"open"),T=De(s,"closed"),B=o.useMemo(()=>It(s),[s,E?.data,T?.data]),V=o.useMemo(()=>new Set(B.map(v=>v.number)),[B]),S=o.useMemo(()=>Ot(B,{state:i.state,involvement:i.involvement,search:i.search,sort:i.sort,viewerLogin:h}),[B,i.state,i.involvement,i.search,i.sort,h]),D=on(S),K=N==="both"?[E,T]:[N==="open"?E:T],_=K.some(v=>v?.data!=null),X=_&&K.every(v=>v?.data?.nextCursor==null),R=K.reduce((v,u)=>v+(u?.data?.items.length??0),0),q=K.find(v=>v?.error)?.error??null,y=K.some(v=>v?.isLoading),de=K.some(v=>v?.stale),Q=i.search.trim(),ee=i.involvement!=="all"&&!h,Z=Q.length>0||i.involvement!=="all",se=o.useMemo(()=>({state:i.state,involvement:i.involvement,q:Q}),[i.state,i.involvement,Q]),ne=`${se.state}|${se.involvement}|${se.q}`,oe=!X&&_&&S.length===0&&(Q.length>0||ee),ae=o.useCallback(v=>n?g(t,s,v,n):Promise.resolve(null),[t,s,n,g]),ue=o.useCallback(v=>n?p(t,s,v,n):Promise.resolve(null),[t,s,n,p]),{remoteView:w,numberJump:$,remotePending:H,handleSearchAll:ie}=St({repo:s,query:se,queryKey:ne,autoRemote:oe,indexNumbers:V,visibleItems:S,searchText:Q,useRemoteEntry:Jt,runSearch:ae,runLoadMore:ue}),A=o.useMemo(()=>{if(X||!_||!Z)return null;const v=S.length===1?"1 match":`${S.length} matches`,u=R===1?"1 most recent loaded pull request":`${R} most recent loaded pull requests`;return`Showing ${v} from the ${u}`},[X,_,Z,S.length,R]),U=o.useCallback(()=>{n&&(l(!0),F(t,s,n).then(()=>{l(!1)}).catch(()=>l(!1)))},[t,s,n,F,l]);o.useEffect(()=>(r.current=U,()=>{r.current===U&&(r.current=null)}),[r,U]);const W=o.useCallback(()=>{if(!n)return;c(!0);const v=N==="both"?["open","closed"]:[N];Promise.all(v.map(u=>z(t,s,u,n))).then(()=>c(!1)).catch(()=>c(!1))},[t,s,N,n,z,c]),J=o.useCallback(v=>{L(t,s,v)},[t,s,L]),me=o.useCallback(()=>{L(t,null,null)},[t,L]);return n?O!=null?e.jsx(dn,{directory:t,repo:s,number:O,github:n,onBack:me,hideFilesTab:f,seed:Bt(s,O)}):e.jsx(ln,{items:S,headerActionsSlot:x,headerActionsPresentation:k,hasMore:K.some(v=>v?.data?.nextCursor!=null),isLoadingMore:d,isLoading:y,isRefreshing:a&&_,stale:de,error:q,filters:i,checksByUrl:D,incompleteNotice:A?{summary:A,searching:H,onSearchAll:ie}:null,remote:w,numberJump:$,onFiltersChange:v=>j(t,s,v),onClearFilters:()=>b(t,s),onLoadMore:W,onRetry:U,onOpen:J}):e.jsx(et,{info:{reason:"failed",message:"GitHub is not available in this runtime."}})},dn=({directory:t,repo:s,number:n,github:a,onBack:l,hideFilesTab:d,seed:c})=>{const r=I(S=>S.ensureDetail),f=I(S=>S.ensureComments),x=I(S=>S.ensureFiles),k=I(S=>S.ensureChecks),m=I(S=>S.loadMoreFiles),g=I(S=>S.loadMoreComments),p=I(S=>S.refreshComments),z=I(S=>S.refreshDetail),F=I(S=>S.refreshChecks);o.useEffect(()=>{r(t,s,n,a).catch(()=>{}),f(t,s,n,a).catch(()=>{}),d||x(t,s,n,a).catch(()=>{}),k(t,s,n,a).catch(()=>{})},[t,s,n,d]);const L=_t(s,n),j=Ut(s,n),b=Vt(s,n),i=Kt(s,n),C=L?.data?.detail??null,h=o.useCallback((S,D)=>{const K=Ss(t);Ne(async()=>{const{useUIStore:_}=await import("./index-BFkW-BPM.js").then(X=>X.d2);return{useUIStore:_}},__vite__mapDeps([1,2,3,4,5,6,7,8])).then(({useUIStore:_})=>{_.getState().openContextFileAtLine(K,S,D)}).catch(()=>{})},[t]),O=o.useCallback(()=>{m(t,s,n,a).catch(()=>{})},[t,s,n,a,m]),N=o.useCallback(()=>{g(t,s,n,a).catch(()=>{})},[t,s,n,a,g]),E=o.useCallback(()=>{p(t,s,n,a).catch(()=>{})},[t,s,n,a,p]),T=o.useCallback(()=>{z(t,s,n,a).catch(()=>{})},[t,s,n,a,z]),B=o.useCallback(()=>{x(t,s,n,a).catch(()=>{})},[t,s,n,a,x]),V=o.useCallback(()=>{F(t,s,n,a).catch(()=>{})},[t,s,n,a,F]);return e.jsx(an,{hideFilesTab:d,seed:c,directory:t,repo:s,number:n,github:a,detail:C,detailError:L?.error??null,detailStale:L?.stale??!1,files:b?.data??null,filesError:b?.error??null,filesLoading:b?.isLoading??!1,filesHasMore:b?.data?.nextCursor!=null,onLoadMoreFiles:O,checks:i?.data??null,checksError:i?.error??null,checksLoading:i?.isLoading??!1,reviews:C?.reviews??[],threads:C?.threads??[],comments:j?.data?.comments??[],commentsError:j?.error??null,commentsLoading:j?.isLoading??!1,commentsHasMore:j?.data?.nextCursor!=null,onLoadMoreComments:N,onRetryComments:E,onBack:l,onRetryDetail:T,onRetryFiles:B,onRetryChecks:V,onOpenFilesAtLine:h})};export{da as PullRequestsSurface};
@@ -1 +1 @@
1
- import{j as e,aW as C}from"./vendor-boot-D-KEJjsM.js";import{R as f}from"./vendor-react-Bz1tRBxM.js";import{x as w,I as x,y as R,z as G,A as M,C as F,E as z,F as B,r as H,G as W}from"./useAppFontEffects-COMvkffC.js";import{u as q}from"./useSwitcherItems-D0i2BYYP.js";import{u as J,c as k}from"./index-BxKPJ9uG.js";import{S as K,a as O,f as Q}from"./SessionUnreadDot-CZCQ4t1J.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./runtimeSurface-BR_dhe7_.js";import"./nativeFileSave-D542OJlG.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";function le({onSelect:s,variant:m,scopeProjectId:d}){const i=q(!0,{scopeProjectId:d}),o=w(t=>t.openNewSessionDraft),a=J(t=>t.setActiveMainTab),l=f.useCallback(()=>{a("chat"),s(),o()},[s,o,a]),[c,p]=f.useState(new Set),u=f.useCallback(t=>{p(h=>{const r=new Set(h);return r.has(t)?r.delete(t):r.add(t),r})},[]);return e.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(C,{onClick:l,className:k("group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),children:[e.jsx(x,{name:"chat-new",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate typography-ui-label font-normal leading-tight text-foreground",children:"New session"})]}),i.length===0?e.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:"No recent sessions"}):i.map(t=>e.jsx(D,{item:t,depth:0,variant:m,expandedParents:c,toggleParent:u,closeDropdown:s},t.node.session.id))]})})}function D({item:s,depth:m,variant:d,expandedParents:i,toggleParent:o,closeDropdown:a}){const{node:l,secondaryMeta:c}=s,p=l.session,u=l.children.length>0,t=i.has(p.id);return e.jsxs(e.Fragment,{children:[e.jsx(V,{session:p,depth:m,variant:d,secondaryMeta:c,hasChildren:u,isExpanded:t,onToggleExpand:u?()=>o(p.id):void 0,closeDropdown:a}),u&&t?l.children.map(h=>e.jsx(D,{item:{node:h,projectId:s.projectId,groupDirectory:s.groupDirectory,secondaryMeta:c},depth:m+1,variant:d,expandedParents:i,toggleParent:o,closeDropdown:a},h.session.id)):null]})}function V({session:s,depth:m,variant:d,secondaryMeta:i,hasChildren:o,isExpanded:a,onToggleExpand:l,closeDropdown:c}){const p=w(n=>n.currentSessionId),u=w(n=>n.setCurrentSession),t=R(s.id),h=G(s.id),r=M(s.id),g=p===s.id,L=F(s),N=t?.type??"idle",b=N==="busy"||N==="retry",S=z({pendingInput:r,isStreaming:b,unseenCount:h,isActive:g}),y=S==="needs-input",A=y&&r?B(r.kind,r.count):null,T=S==="unread",U=s.time?.updated||s.time?.created||Date.now(),E=Q(U),v=i?.projectLabel?.trim()||null,j=i?.branchLabel?.trim()||null,I=j&&j!=="HEAD"?j:null,P=f.useCallback(()=>{if(g){c();return}const n=H(s);u(s.id,n??null),c()},[c,g,s,u]);return e.jsxs(C,{onClick:n=>{if(n.target?.closest("[data-switcher-expand]")){n.preventDefault();return}P()},"data-slot":"session-switcher-item",className:k("group relative flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),style:{paddingLeft:8+m*12},children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[d==="compact"&&o?e.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:n=>{n.preventDefault(),n.stopPropagation(),l?.()},className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded text-subtle-foreground hover:text-foreground","aria-label":a?"Collapse subsessions":"Expand subsessions",children:a?e.jsx(x,{name:"arrow-down-s",className:"h-3.5 w-3.5"}):e.jsx(x,{name:"arrow-right-s",className:"h-3.5 w-3.5"})}):null,e.jsx("span",{className:"truncate typography-ui-label font-normal leading-tight text-foreground",children:L})]}),d==="default"?e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 truncate text-subtle-foreground leading-tight typography-micro",children:[o?e.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:n=>{n.preventDefault(),n.stopPropagation(),l?.()},className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-subtle-foreground hover:text-foreground","aria-label":a?"Collapse subsessions":"Expand subsessions",children:a?e.jsx(x,{name:"arrow-down-s",className:"h-3 w-3"}):e.jsx(x,{name:"arrow-right-s",className:"h-3 w-3"})}):null,e.jsx("span",{className:"flex-shrink-0",children:b?e.jsx(K,{sessionId:s.id,running:!0}):T?e.jsx(O,{label:"Session complete"}):E}),v?e.jsx("span",{className:"truncate",children:v}):null,I?e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[e.jsx(x,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-subtle-foreground"}),e.jsx("span",{className:"truncate",children:I})]}):null]}):null]}),y?e.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:e.jsx(W,{label:A??"Needs input"})}):b?e.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse","aria-label":"Session active",title:"Session active"})}):null]})}export{le as default};
1
+ import{j as e,aW as C}from"./vendor-boot-D-KEJjsM.js";import{R as f}from"./vendor-react-Bz1tRBxM.js";import{x as w,I as x,y as R,z as G,A as M,C as F,E as z,F as B,r as H,G as W}from"./useAppFontEffects-DJCrUN2D.js";import{u as q}from"./useSwitcherItems-CFY3mP06.js";import{u as J,c as k}from"./index-BFkW-BPM.js";import{S as K,a as O,f as Q}from"./SessionUnreadDot-CgvC3F5e.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./runtimeSurface-DD4Vn4HC.js";import"./nativeFileSave-Bj-V_9ae.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";function le({onSelect:s,variant:m,scopeProjectId:d}){const i=q(!0,{scopeProjectId:d}),o=w(t=>t.openNewSessionDraft),a=J(t=>t.setActiveMainTab),l=f.useCallback(()=>{a("chat"),s(),o()},[s,o,a]),[c,p]=f.useState(new Set),u=f.useCallback(t=>{p(h=>{const r=new Set(h);return r.has(t)?r.delete(t):r.add(t),r})},[]);return e.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(C,{onClick:l,className:k("group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),children:[e.jsx(x,{name:"chat-new",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate typography-ui-label font-normal leading-tight text-foreground",children:"New session"})]}),i.length===0?e.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:"No recent sessions"}):i.map(t=>e.jsx(D,{item:t,depth:0,variant:m,expandedParents:c,toggleParent:u,closeDropdown:s},t.node.session.id))]})})}function D({item:s,depth:m,variant:d,expandedParents:i,toggleParent:o,closeDropdown:a}){const{node:l,secondaryMeta:c}=s,p=l.session,u=l.children.length>0,t=i.has(p.id);return e.jsxs(e.Fragment,{children:[e.jsx(V,{session:p,depth:m,variant:d,secondaryMeta:c,hasChildren:u,isExpanded:t,onToggleExpand:u?()=>o(p.id):void 0,closeDropdown:a}),u&&t?l.children.map(h=>e.jsx(D,{item:{node:h,projectId:s.projectId,groupDirectory:s.groupDirectory,secondaryMeta:c},depth:m+1,variant:d,expandedParents:i,toggleParent:o,closeDropdown:a},h.session.id)):null]})}function V({session:s,depth:m,variant:d,secondaryMeta:i,hasChildren:o,isExpanded:a,onToggleExpand:l,closeDropdown:c}){const p=w(n=>n.currentSessionId),u=w(n=>n.setCurrentSession),t=R(s.id),h=G(s.id),r=M(s.id),g=p===s.id,L=F(s),N=t?.type??"idle",b=N==="busy"||N==="retry",S=z({pendingInput:r,isStreaming:b,unseenCount:h,isActive:g}),y=S==="needs-input",A=y&&r?B(r.kind,r.count):null,T=S==="unread",U=s.time?.updated||s.time?.created||Date.now(),E=Q(U),v=i?.projectLabel?.trim()||null,j=i?.branchLabel?.trim()||null,I=j&&j!=="HEAD"?j:null,P=f.useCallback(()=>{if(g){c();return}const n=H(s);u(s.id,n??null),c()},[c,g,s,u]);return e.jsxs(C,{onClick:n=>{if(n.target?.closest("[data-switcher-expand]")){n.preventDefault();return}P()},"data-slot":"session-switcher-item",className:k("group relative flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),style:{paddingLeft:8+m*12},children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[d==="compact"&&o?e.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:n=>{n.preventDefault(),n.stopPropagation(),l?.()},className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded text-subtle-foreground hover:text-foreground","aria-label":a?"Collapse subsessions":"Expand subsessions",children:a?e.jsx(x,{name:"arrow-down-s",className:"h-3.5 w-3.5"}):e.jsx(x,{name:"arrow-right-s",className:"h-3.5 w-3.5"})}):null,e.jsx("span",{className:"truncate typography-ui-label font-normal leading-tight text-foreground",children:L})]}),d==="default"?e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 truncate text-subtle-foreground leading-tight typography-micro",children:[o?e.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:n=>{n.preventDefault(),n.stopPropagation(),l?.()},className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-subtle-foreground hover:text-foreground","aria-label":a?"Collapse subsessions":"Expand subsessions",children:a?e.jsx(x,{name:"arrow-down-s",className:"h-3 w-3"}):e.jsx(x,{name:"arrow-right-s",className:"h-3 w-3"})}):null,e.jsx("span",{className:"flex-shrink-0",children:b?e.jsx(K,{sessionId:s.id,running:!0}):T?e.jsx(O,{label:"Session complete"}):E}),v?e.jsx("span",{className:"truncate",children:v}):null,I?e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[e.jsx(x,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-subtle-foreground"}),e.jsx("span",{className:"truncate",children:I})]}):null]}):null]}),y?e.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:e.jsx(W,{label:A??"Needs input"})}):b?e.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse","aria-label":"Session active",title:"Session active"})}):null]})}export{le as default};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionSwitcherContent-DOpnN-8S.js","assets/vendor-boot-D-KEJjsM.js","assets/vendor-react-Bz1tRBxM.js","assets/vendor-clsx-B-dksMZM.js","assets/useAppFontEffects-COMvkffC.js","assets/index-BxKPJ9uG.js","assets/vendor-zustand-CXhN0IMY.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-tailwind-merge-BKkUfl9q.js","assets/vendor-fuse.js-t_7AcMTv.js","assets/index-C5JgjS20.css","assets/runtimeSurface-BR_dhe7_.js","assets/nativeFileSave-D542OJlG.js","assets/useSwitcherItems-D0i2BYYP.js","assets/SessionUnreadDot-CZCQ4t1J.js"])))=>i.map(i=>d[i]);
2
- import{_ as m}from"./vendor-vite-runtime-DD1OZmLC.js";import{j as e}from"./vendor-boot-D-KEJjsM.js";import{a as c,R as d}from"./vendor-react-Bz1tRBxM.js";import{D as l,h as x,i as u}from"./useAppFontEffects-COMvkffC.js";import{u as n,c as f}from"./index-BxKPJ9uG.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./runtimeSurface-BR_dhe7_.js";import"./nativeFileSave-D542OJlG.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";const w=d.lazy(()=>m(()=>import("./SessionSwitcherContent-DOpnN-8S.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])));function R({children:p,variant:t="default",scopeProjectId:i=null,align:a="start"}){const r=n(o=>o.isSessionDropdownOpen),s=n(o=>o.setSessionDropdownOpen);return e.jsxs(l,{open:r,onOpenChange:s,modal:!1,children:[e.jsx(x,{asChild:!0,children:p}),e.jsx(u,{align:a,sideOffset:6,className:f("overflow-hidden p-1 max-w-[calc(100vw-32px)]",t==="compact"?"w-[280px]":"w-[360px]"),children:r?e.jsx(c.Suspense,{fallback:e.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:"Loading…"}),children:e.jsx(w,{onSelect:()=>s(!1),variant:t,scopeProjectId:i})}):null})]})}export{R as SessionSwitcherDropdown};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionSwitcherContent-DqP8OWzB.js","assets/vendor-boot-D-KEJjsM.js","assets/vendor-react-Bz1tRBxM.js","assets/vendor-clsx-B-dksMZM.js","assets/useAppFontEffects-DJCrUN2D.js","assets/index-BFkW-BPM.js","assets/vendor-zustand-CXhN0IMY.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-tailwind-merge-BKkUfl9q.js","assets/vendor-fuse.js-t_7AcMTv.js","assets/index-C5JgjS20.css","assets/runtimeSurface-DD4Vn4HC.js","assets/nativeFileSave-Bj-V_9ae.js","assets/useSwitcherItems-CFY3mP06.js","assets/SessionUnreadDot-CgvC3F5e.js"])))=>i.map(i=>d[i]);
2
+ import{_ as m}from"./vendor-vite-runtime-DD1OZmLC.js";import{j as e}from"./vendor-boot-D-KEJjsM.js";import{a as c,R as d}from"./vendor-react-Bz1tRBxM.js";import{D as l,h as x,i as u}from"./useAppFontEffects-DJCrUN2D.js";import{u as n,c as f}from"./index-BFkW-BPM.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./runtimeSurface-DD4Vn4HC.js";import"./nativeFileSave-Bj-V_9ae.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";const w=d.lazy(()=>m(()=>import("./SessionSwitcherContent-DqP8OWzB.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])));function R({children:p,variant:t="default",scopeProjectId:i=null,align:a="start"}){const r=n(o=>o.isSessionDropdownOpen),s=n(o=>o.setSessionDropdownOpen);return e.jsxs(l,{open:r,onOpenChange:s,modal:!1,children:[e.jsx(x,{asChild:!0,children:p}),e.jsx(u,{align:a,sideOffset:6,className:f("overflow-hidden p-1 max-w-[calc(100vw-32px)]",t==="compact"?"w-[280px]":"w-[360px]"),children:r?e.jsx(c.Suspense,{fallback:e.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:"Loading…"}),children:e.jsx(w,{onSelect:()=>s(!1),variant:t,scopeProjectId:i})}):null})]})}export{R as SessionSwitcherDropdown};
@@ -1 +1 @@
1
- import{g as D,X as b,Y as y,Z as p}from"./useAppFontEffects-COMvkffC.js";import{j as d}from"./vendor-boot-D-KEJjsM.js";import"./vendor-react-Bz1tRBxM.js";import{c as h}from"./index-BxKPJ9uG.js";const F=(e,t,o)=>{const r=`${o}:`,a=new Set([...t].filter(s=>s.startsWith(r)));return e.size===a.size&&[...a].every(s=>e.has(s))?e:a},I=(e,t)=>{const o=new Set(e);return o.has(t)?o.delete(t):o.add(t),o},w=e=>{const t=new Date(e),o=new Date,r=(i,n)=>i.getFullYear()===n.getFullYear()&&i.getMonth()===n.getMonth()&&i.getDate()===n.getDate(),a=new Date(o);return a.setDate(o.getDate()-1),r(t,o)?"Today":r(t,a)?"Yesterday":t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}).replace(",","")},j=e=>{const t=new Date,o=new Date(e);if(((a,s)=>a.getFullYear()===s.getFullYear()&&a.getMonth()===s.getMonth()&&a.getDate()===s.getDate())(o,t)){const a=Date.now()-e;return a<6e4?"Just now":a<36e5?`${Math.floor(a/6e4)}min ago`:`${Math.floor(a/36e5)}h ago`}return w(e)},z=e=>{const t=Math.max(0,Date.now()-e),o=6e4,r=60*o,a=24*r,s=7*a,i=30*a,n=365*a;return t<r?`${Math.max(1,Math.floor(t/o))}m`:t<a?`${Math.floor(t/r)}h`:t<s?`${Math.floor(t/a)}d ago`:t<5*s?`${Math.floor(t/s)}w ago`:t<n?`${Math.floor(t/i)}mo`:`${Math.floor(t/n)}y ago`},m=e=>e.toLowerCase().replace(/[-_]/g,"").trim(),E=(e,t)=>e?m(e)!==m(t):!1,Y=e=>{const t=new Map;return e.forEach(o=>{t.set(o.id,o)}),Array.from(t.values())},k=(e,t)=>D({label:e.label,path:e.normalizedPath},t),P="calc(1.25rem * var(--padding-scale, 1))",g="size-4 shrink-0",M="min-w-0 truncate typography-ui-label font-normal",S=g,x=M,$="group relative my-0.5 flex w-full cursor-pointer items-center gap-1.5 rounded-xl px-3 py-2 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",_=$,T=e=>e?S:g,U=e=>e?x:M,f=1e3,l=60*f,c=60*l,C=e=>{const t=Math.max(0,e);return t<l?`${Math.floor(t/f)}s`:t<c?`${Math.floor(t/l)}m ${Math.floor(t%l/f)}s`:`${Math.floor(t/c)}h ${Math.floor(t%c/l)}m`},v=1e3,B=({sessionId:e,running:t,className:o})=>{const r=b(e),a=y(e),s=p(t,v),i=t?Math.max(0,s-(r??s)):a;if(i===void 0)return null;const n=C(i),u=t?`Active for ${n}`:`Last turn took ${n}`;return d.jsx("span",{className:h("shrink-0 tabular-nums",t?"text-primary":"text-[var(--status-info)]",o),"aria-label":u,title:u,children:n})};function K({label:e,className:t}){return d.jsx("span",{className:h("size-1.5 shrink-0 rounded-full bg-foreground",t),"aria-label":e,title:e})}export{B as S,K as a,U as b,_ as c,j as d,Y as e,z as f,k as g,g as h,M as i,$ as j,E as k,P as l,F as m,T as s,I as t};
1
+ import{g as D,X as b,Y as y,Z as p}from"./useAppFontEffects-DJCrUN2D.js";import{j as d}from"./vendor-boot-D-KEJjsM.js";import"./vendor-react-Bz1tRBxM.js";import{c as h}from"./index-BFkW-BPM.js";const F=(e,t,o)=>{const r=`${o}:`,a=new Set([...t].filter(s=>s.startsWith(r)));return e.size===a.size&&[...a].every(s=>e.has(s))?e:a},I=(e,t)=>{const o=new Set(e);return o.has(t)?o.delete(t):o.add(t),o},w=e=>{const t=new Date(e),o=new Date,r=(i,n)=>i.getFullYear()===n.getFullYear()&&i.getMonth()===n.getMonth()&&i.getDate()===n.getDate(),a=new Date(o);return a.setDate(o.getDate()-1),r(t,o)?"Today":r(t,a)?"Yesterday":t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}).replace(",","")},j=e=>{const t=new Date,o=new Date(e);if(((a,s)=>a.getFullYear()===s.getFullYear()&&a.getMonth()===s.getMonth()&&a.getDate()===s.getDate())(o,t)){const a=Date.now()-e;return a<6e4?"Just now":a<36e5?`${Math.floor(a/6e4)}min ago`:`${Math.floor(a/36e5)}h ago`}return w(e)},z=e=>{const t=Math.max(0,Date.now()-e),o=6e4,r=60*o,a=24*r,s=7*a,i=30*a,n=365*a;return t<r?`${Math.max(1,Math.floor(t/o))}m`:t<a?`${Math.floor(t/r)}h`:t<s?`${Math.floor(t/a)}d ago`:t<5*s?`${Math.floor(t/s)}w ago`:t<n?`${Math.floor(t/i)}mo`:`${Math.floor(t/n)}y ago`},m=e=>e.toLowerCase().replace(/[-_]/g,"").trim(),E=(e,t)=>e?m(e)!==m(t):!1,Y=e=>{const t=new Map;return e.forEach(o=>{t.set(o.id,o)}),Array.from(t.values())},k=(e,t)=>D({label:e.label,path:e.normalizedPath},t),P="calc(1.25rem * var(--padding-scale, 1))",g="size-4 shrink-0",M="min-w-0 truncate typography-ui-label font-normal",S=g,x=M,$="group relative my-0.5 flex w-full cursor-pointer items-center gap-1.5 rounded-xl px-3 py-2 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",_=$,T=e=>e?S:g,U=e=>e?x:M,f=1e3,l=60*f,c=60*l,C=e=>{const t=Math.max(0,e);return t<l?`${Math.floor(t/f)}s`:t<c?`${Math.floor(t/l)}m ${Math.floor(t%l/f)}s`:`${Math.floor(t/c)}h ${Math.floor(t%c/l)}m`},v=1e3,B=({sessionId:e,running:t,className:o})=>{const r=b(e),a=y(e),s=p(t,v),i=t?Math.max(0,s-(r??s)):a;if(i===void 0)return null;const n=C(i),u=t?`Active for ${n}`:`Last turn took ${n}`;return d.jsx("span",{className:h("shrink-0 tabular-nums",t?"text-primary":"text-[var(--status-info)]",o),"aria-label":u,title:u,children:n})};function K({label:e,className:t}){return d.jsx("span",{className:h("size-1.5 shrink-0 rounded-full bg-foreground",t),"aria-label":e,title:e})}export{B as S,K as a,U as b,_ as c,j as d,Y as e,z as f,k as g,g as h,M as i,$ as j,E as k,P as l,F as m,T as s,I as t};