@mndrk/agx 2.4.7 → 2.4.9

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 (129) hide show
  1. package/README.md +22 -53
  2. package/cloud-runtime/standalone/apps/local/.next/BUILD_ID +1 -1
  3. package/cloud-runtime/standalone/apps/local/.next/build-manifest.json +2 -2
  4. package/cloud-runtime/standalone/apps/local/.next/prerender-manifest.json +3 -3
  5. package/cloud-runtime/standalone/apps/local/.next/server/app/_global-error.html +2 -2
  6. package/cloud-runtime/standalone/apps/local/.next/server/app/_global-error.rsc +1 -1
  7. package/cloud-runtime/standalone/apps/local/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  8. package/cloud-runtime/standalone/apps/local/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/cloud-runtime/standalone/apps/local/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  10. package/cloud-runtime/standalone/apps/local/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  11. package/cloud-runtime/standalone/apps/local/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  12. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  13. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.html +2 -2
  14. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.rsc +3 -3
  15. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  16. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  17. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  18. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  19. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  20. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  21. package/cloud-runtime/standalone/apps/local/.next/server/app/agents/[id]/page_client-reference-manifest.js +1 -1
  22. package/cloud-runtime/standalone/apps/local/.next/server/app/agents/page_client-reference-manifest.js +1 -1
  23. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.html +2 -2
  24. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.rsc +3 -3
  25. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.segments/_full.segment.rsc +3 -3
  26. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.segments/_head.segment.rsc +1 -1
  27. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.segments/_index.segment.rsc +2 -2
  28. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.segments/_tree.segment.rsc +2 -2
  29. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.segments/agents/__PAGE__.segment.rsc +1 -1
  30. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.segments/agents.segment.rsc +1 -1
  31. package/cloud-runtime/standalone/apps/local/.next/server/app/index.html +2 -2
  32. package/cloud-runtime/standalone/apps/local/.next/server/app/index.rsc +3 -3
  33. package/cloud-runtime/standalone/apps/local/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  34. package/cloud-runtime/standalone/apps/local/.next/server/app/index.segments/_full.segment.rsc +3 -3
  35. package/cloud-runtime/standalone/apps/local/.next/server/app/index.segments/_head.segment.rsc +1 -1
  36. package/cloud-runtime/standalone/apps/local/.next/server/app/index.segments/_index.segment.rsc +2 -2
  37. package/cloud-runtime/standalone/apps/local/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  38. package/cloud-runtime/standalone/apps/local/.next/server/app/integrations/github/select-repos/page_client-reference-manifest.js +1 -1
  39. package/cloud-runtime/standalone/apps/local/.next/server/app/integrations/github/select-repos.html +2 -2
  40. package/cloud-runtime/standalone/apps/local/.next/server/app/integrations/github/select-repos.rsc +4 -4
  41. package/cloud-runtime/standalone/apps/local/.next/server/app/integrations/github/select-repos.segments/_full.segment.rsc +4 -4
  42. package/cloud-runtime/standalone/apps/local/.next/server/app/integrations/github/select-repos.segments/_head.segment.rsc +1 -1
  43. package/cloud-runtime/standalone/apps/local/.next/server/app/integrations/github/select-repos.segments/_index.segment.rsc +2 -2
  44. package/cloud-runtime/standalone/apps/local/.next/server/app/integrations/github/select-repos.segments/_tree.segment.rsc +2 -2
  45. package/cloud-runtime/standalone/apps/local/.next/server/app/integrations/github/select-repos.segments/integrations/github/select-repos/__PAGE__.segment.rsc +2 -2
  46. package/cloud-runtime/standalone/apps/local/.next/server/app/integrations/github/select-repos.segments/integrations/github/select-repos.segment.rsc +1 -1
  47. package/cloud-runtime/standalone/apps/local/.next/server/app/integrations/github/select-repos.segments/integrations/github.segment.rsc +1 -1
  48. package/cloud-runtime/standalone/apps/local/.next/server/app/integrations/github/select-repos.segments/integrations.segment.rsc +1 -1
  49. package/cloud-runtime/standalone/apps/local/.next/server/app/page_client-reference-manifest.js +1 -1
  50. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/automations/page_client-reference-manifest.js +1 -1
  51. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/env-vars/page_client-reference-manifest.js +1 -1
  52. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/folders/page_client-reference-manifest.js +1 -1
  53. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/graph/[taskId]/page_client-reference-manifest.js +1 -1
  54. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/notifications/page_client-reference-manifest.js +1 -1
  55. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/objectives/[objectiveId]/page_client-reference-manifest.js +1 -1
  56. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/objectives/page_client-reference-manifest.js +1 -1
  57. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/page_client-reference-manifest.js +1 -1
  58. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/prs/page_client-reference-manifest.js +1 -1
  59. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/teams/[teamId]/agents/[agentId]/page_client-reference-manifest.js +1 -1
  60. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/teams/[teamId]/page_client-reference-manifest.js +1 -1
  61. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/teams/adopt/page_client-reference-manifest.js +1 -1
  62. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/teams/new/page_client-reference-manifest.js +1 -1
  63. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/teams/page_client-reference-manifest.js +1 -1
  64. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/teams/replace/page_client-reference-manifest.js +1 -1
  65. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/terminal/page_client-reference-manifest.js +1 -1
  66. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/thread/[threadId]/page_client-reference-manifest.js +1 -1
  67. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/thread/page_client-reference-manifest.js +1 -1
  68. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/tracking/[tracker]/page_client-reference-manifest.js +1 -1
  69. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/tracking/connect/page_client-reference-manifest.js +1 -1
  70. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/tracking/page_client-reference-manifest.js +1 -1
  71. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  72. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.html +2 -2
  73. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.rsc +3 -3
  74. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.segments/_full.segment.rsc +3 -3
  75. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.segments/_head.segment.rsc +1 -1
  76. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.segments/_index.segment.rsc +2 -2
  77. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.segments/_tree.segment.rsc +2 -2
  78. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.segments/projects/__PAGE__.segment.rsc +1 -1
  79. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.segments/projects.segment.rsc +1 -1
  80. package/cloud-runtime/standalone/apps/local/.next/server/app/setup/page_client-reference-manifest.js +1 -1
  81. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.html +2 -2
  82. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.rsc +3 -3
  83. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.segments/_full.segment.rsc +3 -3
  84. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.segments/_head.segment.rsc +1 -1
  85. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.segments/_index.segment.rsc +2 -2
  86. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.segments/_tree.segment.rsc +2 -2
  87. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.segments/setup/__PAGE__.segment.rsc +1 -1
  88. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.segments/setup.segment.rsc +1 -1
  89. package/cloud-runtime/standalone/apps/local/.next/server/app/status/page_client-reference-manifest.js +1 -1
  90. package/cloud-runtime/standalone/apps/local/.next/server/app/status.html +2 -2
  91. package/cloud-runtime/standalone/apps/local/.next/server/app/status.rsc +3 -3
  92. package/cloud-runtime/standalone/apps/local/.next/server/app/status.segments/_full.segment.rsc +3 -3
  93. package/cloud-runtime/standalone/apps/local/.next/server/app/status.segments/_head.segment.rsc +1 -1
  94. package/cloud-runtime/standalone/apps/local/.next/server/app/status.segments/_index.segment.rsc +2 -2
  95. package/cloud-runtime/standalone/apps/local/.next/server/app/status.segments/_tree.segment.rsc +2 -2
  96. package/cloud-runtime/standalone/apps/local/.next/server/app/status.segments/status/__PAGE__.segment.rsc +1 -1
  97. package/cloud-runtime/standalone/apps/local/.next/server/app/status.segments/status.segment.rsc +1 -1
  98. package/cloud-runtime/standalone/apps/local/.next/server/chunks/apps_local_29a06140._.js +1 -1
  99. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/[root-of-the-server]__5187dece._.js +1 -1
  100. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/[root-of-the-server]__7752d2d2._.js +1 -1
  101. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/[root-of-the-server]__e8c6a1f1._.js +1 -1
  102. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/apps_local_components_TrackerBoard_tsx_98970bab._.js +1 -1
  103. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/apps_local_components_projects_ProjectObjectivesWorkspace_tsx_751ab3d3._.js +2 -2
  104. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/apps_local_eec36ab6._.js +1 -1
  105. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/apps_local_fed01721._.js +1 -1
  106. package/cloud-runtime/standalone/apps/local/.next/server/middleware-manifest.json +5 -5
  107. package/cloud-runtime/standalone/apps/local/.next/server/pages/404.html +2 -2
  108. package/cloud-runtime/standalone/apps/local/.next/server/pages/500.html +2 -2
  109. package/cloud-runtime/standalone/apps/local/.next/server/server-reference-manifest.js +1 -1
  110. package/cloud-runtime/standalone/apps/local/.next/server/server-reference-manifest.json +1 -1
  111. package/cloud-runtime/standalone/apps/local/.next/static/chunks/{5092f14c2bf43204.js → 3fce625820bc2bd4.js} +1 -1
  112. package/cloud-runtime/standalone/apps/local/.next/static/chunks/6d8a7494a0cea7a0.css +1 -0
  113. package/cloud-runtime/standalone/apps/local/.next/static/chunks/{40857295bb9226c4.js → 8b87c2521c519a1f.js} +7 -7
  114. package/cloud-runtime/standalone/apps/local/.next/static/chunks/{90dcb743d23feeca.js → 90dd4ab03ab145d1.js} +2 -2
  115. package/cloud-runtime/standalone/apps/local/.next/static/chunks/{52a7b1805199c6fb.js → b4716c6337e3335c.js} +1 -1
  116. package/cloud-runtime/standalone/apps/local/.next/static/chunks/{1fbcd40dccee738f.js → cf33cb29946990e3.js} +2 -2
  117. package/cloud-runtime/standalone/apps/local/.next/static/chunks/{7bfbfcd072f8d61e.js → d0ba5f3dc5296486.js} +3 -3
  118. package/cloud-runtime/standalone/apps/local/app/integrations/github/select-repos/page.tsx +2 -0
  119. package/cloud-runtime/standalone/apps/local/app/layout.tsx +1 -1
  120. package/cloud-runtime/standalone/apps/local/components/TrackerBoard.tsx +39 -1
  121. package/cloud-runtime/standalone/apps/local/components/projects/ProjectObjectivesWorkspace.tsx +22 -2
  122. package/cloud-runtime/standalone/apps/local/components/tracking/TrackerSetup.tsx +22 -14
  123. package/cloud-runtime/standalone/apps/local/lib/tracker/adapters/github/adapter.tsx +40 -4
  124. package/cloud-runtime/standalone/apps/local/worker/index.js +1 -1
  125. package/package.json +2 -2
  126. package/cloud-runtime/standalone/apps/local/.next/static/chunks/5159169343ce6d2f.css +0 -1
  127. /package/cloud-runtime/standalone/apps/local/.next/static/{xVMVGrzDjtD1H0bGL76NJ → EGpM0P8xAEWKkoW-3Ib69}/_buildManifest.js +0 -0
  128. /package/cloud-runtime/standalone/apps/local/.next/static/{xVMVGrzDjtD1H0bGL76NJ → EGpM0P8xAEWKkoW-3Ib69}/_clientMiddlewareManifest.json +0 -0
  129. /package/cloud-runtime/standalone/apps/local/.next/static/{xVMVGrzDjtD1H0bGL76NJ → EGpM0P8xAEWKkoW-3Ib69}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,629155,e=>{"use strict";let t=(0,e.i(363732).default)("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);e.s(["Hash",()=>t],629155)},878001,507193,493141,e=>{"use strict";var t=e.i(363732);let r=(0,t.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);e.s(["ArrowDown",()=>r],878001);let a=(0,t.default)("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);e.s(["ArrowUp",()=>a],507193);let s=(0,t.default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);e.s(["ChevronLeft",()=>s],493141)},417442,e=>{"use strict";let t=(0,e.i(363732).default)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);e.s(["ArrowRight",()=>t],417442)},437307,e=>{"use strict";let t=(0,e.i(363732).default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);e.s(["XCircle",()=>t],437307)},982141,e=>{"use strict";let t="agx:lastRun",r="agx:lastSession";function a(){return void 0!==window.localStorage}function s(e){if(!a())return{};try{let t=window.localStorage.getItem(e);if(!t)return{};return JSON.parse(t)}catch{return{}}}function n(e,t){if(a())try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function l(e){return s(t)[e]??null}function i(e,r){let a=s(t);a[e]=r,n(t,a)}function o(e){return s(r)[e]??null}function c(e,t){let a=s(r);a[e]=t,n(r,a)}e.s(["loadLastRunForIssue",()=>l,"loadLastSessionForEntity",()=>o,"persistLastRunForIssue",()=>i,"persistLastSessionForEntity",()=>c])},276013,e=>{"use strict";var t=e.i(762281),r=e.i(935851);function a({onResize:e,className:a,ariaLabel:s}){let n=(0,r.useRef)(0),l=(0,r.useRef)(e);l.current=e;let i=(0,r.useCallback)(e=>{e.preventDefault(),n.current=e.clientX,document.body.style.cursor="col-resize",document.body.style.userSelect="none";let t=e=>{let t=e.clientX-n.current;n.current=e.clientX,l.current(t)},r=()=>{document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",r)};window.addEventListener("mousemove",t),window.addEventListener("mouseup",r)},[]);return(0,t.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":s,className:`group relative z-10 w-0 shrink-0 cursor-col-resize ${a??""}`,onMouseDown:i,children:(0,t.jsx)("div",{className:"absolute inset-y-0 -left-1 w-2 transition-colors group-hover:bg-[var(--primary)]/40"})})}e.s(["ResizeHandle",()=>a])},638703,e=>{"use strict";var t=e.i(762281),r=e.i(498027);let a=(0,e.i(363732).default)("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);function s({visible:e,onClick:s,direction:n="bottom",label:l,offsetClassName:i}){if(!e)return null;let o="top"===n?a:r.ChevronDown;return(0,t.jsx)("div",{className:`pointer-events-none absolute inset-x-0 ${i??("top"===n?"top-3":"bottom-3")} z-10 flex justify-center`,children:(0,t.jsxs)("button",{type:"button",onClick:s,className:`pointer-events-auto inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full border border-[var(--app-shell-border)] bg-[var(--app-shell-surface)] text-[var(--foreground)] text-xs font-medium shadow-md hover:bg-[var(--app-shell-elevated)] transition-colors animate-in fade-in ${"top"===n?"slide-in-from-top-1":"slide-in-from-bottom-1"} duration-200`,children:[(0,t.jsx)(o,{className:"w-3.5 h-3.5"}),l??("top"===n?"Back to top":"Jump to latest")]})})}e.s(["JumpToLatestButton",()=>s],638703)},741746,e=>{"use strict";let t=(0,e.i(363732).default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);e.s(["AlertCircle",()=>t],741746)},889016,e=>{"use strict";let t=(0,e.i(363732).default)("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);e.s(["Tag",()=>t],889016)},794731,e=>{"use strict";let t=(0,e.i(363732).default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);e.s(["Trash2",()=>t],794731)},66386,e=>{"use strict";var t=e.i(935851),r=e.i(506420);function a(e){return"string"!=typeof e?null:e.trim()||null}function s(e,t){return(e.get(t)?.trim()??"")||null}function n(){let e=(0,r.useRouter)(),n=(0,r.usePathname)(),l=(0,r.useSearchParams)(),i=(0,t.useCallback)(e=>s(l,e),[l]),o=(0,t.useCallback)((e,t)=>(function(e,t,r){let n=function(e,t){let r={...t},n=e=>Object.prototype.hasOwnProperty.call(t,e);if(n("issue")&&!n("run")){let n=s(e,"issue");a(t.issue)!==n&&(r.run=null)}if(n("job")&&!n("run")){let n=s(e,"job");a(t.job)!==n&&(r.run=null)}if(n("open")&&!n("message")){let n=s(e,"open");a(t.open)!==n&&(r.message=null)}if(n("group")&&!n("issue")){let n=s(e,"group");a(t.group)!==n&&(r.issue=null,r.run=null)}if(n("issue")&&!n("group")){let n=s(e,"issue");a(t.issue)!==n&&(r.group=null)}return r}(t,r),l=new URLSearchParams(t.toString());for(let[e,t]of Object.entries(n)){let r=a(t);r?l.set(e,r):l.delete(e)}let i=l.toString();return i?`${e}?${i}`:e})(t??n,l,e),[n,l]),c=(0,t.useCallback)((t,r)=>{e.push(o(t,r))},[o,e]),d=(0,t.useCallback)((t,r)=>{e.replace(o(t,r))},[o,e]);return{pathname:n,searchParams:l,getSelection:i,buildHref:o,pushSelection:c,replaceSelection:d}}e.s(["useUrlSelection",()=>n])},203096,e=>{"use strict";let t=(0,e.i(363732).default)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);e.s(["RefreshCw",()=>t],203096)},580873,e=>{"use strict";let t=(0,e.i(363732).default)("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]);e.s(["Clock",()=>t],580873)},990933,e=>{"use strict";function t(e){if("string"==typeof e)return e.trim()||void 0}function r(e,r){let a=new Set,s=new Set;!function e(t,r){if(t)for(let a of t)r(a),e(a.content,r)}(e.content,e=>{if("participantMention"!==e.type)return;let t=e.attrs??{},r="string"==typeof t.id?t.id.trim():"",n="string"==typeof t.kind?t.kind:"agent";r&&"agent"===n&&(a.add(r),"parallel"===t.mode&&s.add(r))});let n=t(r);return{...n?{pinnedParticipantId:n}:{},mentionedParticipantIds:Array.from(a),parallelParticipantIds:Array.from(s)}}function a(e,r){let a=function(e){if(!Array.isArray(e))return[];let t=new Set,r=[];for(let a of e){if("string"!=typeof a)continue;let e=a.trim();!e||t.has(e)||(t.add(e),r.push(e))}return r}(e),s=t(r);return s&&a.includes(s)?[s,...a.filter(e=>e!==s)]:a}e.s(["extractComposerRouting",()=>r,"orderParticipantIds",()=>a])},352687,e=>{"use strict";var t=e.i(762281),r=e.i(935851);function a({isOpen:e,title:a,message:s,preview:n,confirmLabel:l="Confirm",cancelLabel:i="Cancel",variant:o="default",onConfirm:c,onCancel:d}){let u=(0,r.useRef)(null),m=(0,r.useRef)(null);(0,r.useEffect)(()=>{if(e){let e=setTimeout(()=>u.current?.focus(),50);return()=>clearTimeout(e)}},[e]);let p=(0,r.useCallback)(e=>{"Escape"===e.key&&d()},[d]);if(!e)return null;let f="danger"===o;return(0,t.jsxs)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/50 backdrop-blur-md",style:{animation:"confirm-overlay-in 200ms ease-out"},onClick:e=>e.target===e.currentTarget&&d(),onKeyDown:p,children:[(0,t.jsxs)("div",{ref:m,className:"w-full max-w-md mx-4 bg-[var(--card-bg)] rounded-2xl border border-[var(--card-border)] shadow-2xl overflow-hidden",style:{animation:"confirm-dialog-in 250ms cubic-bezier(0.34, 1.56, 0.64, 1)"},children:[(0,t.jsx)("div",{className:"px-6 pt-6 pb-3",children:(0,t.jsxs)("div",{className:"flex items-start gap-4",children:[f&&(0,t.jsx)("div",{className:"flex-shrink-0 w-11 h-11 rounded-full bg-red-500/10 border border-red-500/20 flex items-center justify-center",children:(0,t.jsx)("svg",{className:"w-5 h-5 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("h3",{className:"text-[15px] font-semibold text-[var(--foreground)]",children:a}),(0,t.jsx)("p",{className:"mt-1 text-[13px] text-[var(--muted-foreground)] leading-relaxed",children:s})]})]})}),n&&(0,t.jsx)("div",{className:"mx-6 mb-3 px-3 py-2.5 rounded-lg bg-[var(--muted)]/40 border border-[var(--card-border)]",children:(0,t.jsxs)("p",{className:"text-[12px] text-[var(--muted-foreground)] line-clamp-3 leading-relaxed italic",children:["“",n,"”"]})}),(0,t.jsx)("div",{className:"mx-6 border-t border-[var(--card-border)]"}),(0,t.jsxs)("div",{className:"px-6 py-4 flex items-center justify-end gap-2.5",children:[(0,t.jsx)("button",{onClick:d,className:"px-4 py-2 rounded-lg text-[13px] font-medium text-[var(--muted-foreground)] hover:text-[var(--foreground)] hover:bg-[var(--muted)]/60 transition-all duration-150",children:i}),(0,t.jsx)("button",{ref:u,onClick:c,className:`px-4 py-2 rounded-lg text-[13px] font-medium transition-all duration-150 ${f?"bg-red-500 text-white hover:bg-red-600 active:scale-[0.97]":"btn-primary active:scale-[0.97]"}`,children:l})]})]}),(0,t.jsx)("style",{children:`
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,629155,e=>{"use strict";let t=(0,e.i(363732).default)("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);e.s(["Hash",()=>t],629155)},878001,507193,493141,e=>{"use strict";var t=e.i(363732);let r=(0,t.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);e.s(["ArrowDown",()=>r],878001);let a=(0,t.default)("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);e.s(["ArrowUp",()=>a],507193);let s=(0,t.default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);e.s(["ChevronLeft",()=>s],493141)},417442,e=>{"use strict";let t=(0,e.i(363732).default)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);e.s(["ArrowRight",()=>t],417442)},437307,e=>{"use strict";let t=(0,e.i(363732).default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);e.s(["XCircle",()=>t],437307)},982141,e=>{"use strict";let t="agx:lastRun",r="agx:lastSession";function a(){return void 0!==window.localStorage}function s(e){if(!a())return{};try{let t=window.localStorage.getItem(e);if(!t)return{};return JSON.parse(t)}catch{return{}}}function n(e,t){if(a())try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function l(e){return s(t)[e]??null}function i(e,r){let a=s(t);a[e]=r,n(t,a)}function o(e){return s(r)[e]??null}function c(e,t){let a=s(r);a[e]=t,n(r,a)}e.s(["loadLastRunForIssue",()=>l,"loadLastSessionForEntity",()=>o,"persistLastRunForIssue",()=>i,"persistLastSessionForEntity",()=>c])},276013,e=>{"use strict";var t=e.i(762281),r=e.i(935851);function a({onResize:e,className:a,ariaLabel:s}){let n=(0,r.useRef)(0),l=(0,r.useRef)(e);l.current=e;let i=(0,r.useCallback)(e=>{e.preventDefault(),n.current=e.clientX,document.body.style.cursor="col-resize",document.body.style.userSelect="none";let t=e=>{let t=e.clientX-n.current;n.current=e.clientX,l.current(t)},r=()=>{document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",r)};window.addEventListener("mousemove",t),window.addEventListener("mouseup",r)},[]);return(0,t.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":s,className:`group relative z-10 w-0 shrink-0 cursor-col-resize ${a??""}`,onMouseDown:i,children:(0,t.jsx)("div",{className:"absolute inset-y-0 -left-1 w-2 transition-colors group-hover:bg-[var(--primary)]/40"})})}e.s(["ResizeHandle",()=>a])},638703,e=>{"use strict";var t=e.i(762281),r=e.i(498027);let a=(0,e.i(363732).default)("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);function s({visible:e,onClick:s,direction:n="bottom",label:l,offsetClassName:i}){if(!e)return null;let o="top"===n?a:r.ChevronDown;return(0,t.jsx)("div",{className:`pointer-events-none absolute inset-x-0 ${i??("top"===n?"top-3":"bottom-3")} z-10 flex justify-center`,children:(0,t.jsxs)("button",{type:"button",onClick:s,className:`pointer-events-auto inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full border border-[var(--app-shell-border)] bg-[var(--app-shell-surface)] text-[var(--foreground)] text-xs font-medium shadow-md hover:bg-[var(--app-shell-elevated)] transition-colors animate-in fade-in ${"top"===n?"slide-in-from-top-1":"slide-in-from-bottom-1"} duration-200`,children:[(0,t.jsx)(o,{className:"w-3.5 h-3.5"}),l??("top"===n?"Back to top":"Jump to latest")]})})}e.s(["JumpToLatestButton",()=>s],638703)},741746,e=>{"use strict";let t=(0,e.i(363732).default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);e.s(["AlertCircle",()=>t],741746)},889016,e=>{"use strict";let t=(0,e.i(363732).default)("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);e.s(["Tag",()=>t],889016)},794731,e=>{"use strict";let t=(0,e.i(363732).default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);e.s(["Trash2",()=>t],794731)},66386,e=>{"use strict";var t=e.i(935851),r=e.i(506420);function a(e){return"string"!=typeof e?null:e.trim()||null}function s(e,t){return(e.get(t)?.trim()??"")||null}function n(){let e=(0,r.useRouter)(),n=(0,r.usePathname)(),l=(0,r.useSearchParams)(),i=(0,t.useCallback)(e=>s(l,e),[l]),o=(0,t.useCallback)((e,t)=>(function(e,t,r){let n=function(e,t){let r={...t},n=e=>Object.prototype.hasOwnProperty.call(t,e);if(n("issue")&&!n("run")){let n=s(e,"issue");a(t.issue)!==n&&(r.run=null)}if(n("job")&&!n("run")){let n=s(e,"job");a(t.job)!==n&&(r.run=null)}if(n("open")&&!n("message")){let n=s(e,"open");a(t.open)!==n&&(r.message=null)}if(n("group")&&!n("issue")){let n=s(e,"group");a(t.group)!==n&&(r.issue=null,r.run=null)}if(n("issue")&&!n("group")){let n=s(e,"issue");a(t.issue)!==n&&(r.group=null)}return r}(t,r),l=new URLSearchParams(t.toString());for(let[e,t]of Object.entries(n)){let r=a(t);r?l.set(e,r):l.delete(e)}let i=l.toString();return i?`${e}?${i}`:e})(t??n,l,e),[n,l]),c=(0,t.useCallback)((t,r)=>{e.push(o(t,r))},[o,e]),d=(0,t.useCallback)((t,r)=>{e.replace(o(t,r))},[o,e]);return{pathname:n,searchParams:l,getSelection:i,buildHref:o,pushSelection:c,replaceSelection:d}}e.s(["useUrlSelection",()=>n])},203096,e=>{"use strict";let t=(0,e.i(363732).default)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);e.s(["RefreshCw",()=>t],203096)},580873,e=>{"use strict";let t=(0,e.i(363732).default)("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]);e.s(["Clock",()=>t],580873)},990933,e=>{"use strict";function t(e){if("string"==typeof e)return e.trim()||void 0}function r(e,r){let a=new Set,s=new Set;!function e(t,r){if(t)for(let a of t)r(a),e(a.content,r)}(e.content,e=>{if("participantMention"!==e.type)return;let t=e.attrs??{},r="string"==typeof t.id?t.id.trim():"",n="string"==typeof t.kind?t.kind:"agent";r&&"agent"===n&&(a.add(r),"parallel"===t.mode&&s.add(r))});let n=t(r);return{...n?{pinnedParticipantId:n}:{},mentionedParticipantIds:Array.from(a),parallelParticipantIds:Array.from(s)}}function a(e,r){let a=function(e){if(!Array.isArray(e))return[];let t=new Set,r=[];for(let a of e){if("string"!=typeof a)continue;let e=a.trim();!e||t.has(e)||(t.add(e),r.push(e))}return r}(e),s=t(r);return s&&a.includes(s)?[s,...a.filter(e=>e!==s)]:a}e.s(["extractComposerRouting",()=>r,"orderParticipantIds",()=>a])},352687,e=>{"use strict";var t=e.i(762281),r=e.i(935851);function a({isOpen:e,title:a,message:s,preview:n,confirmLabel:l="Confirm",cancelLabel:i="Cancel",variant:o="default",onConfirm:c,onCancel:d}){let u=(0,r.useRef)(null),p=(0,r.useRef)(null);(0,r.useEffect)(()=>{if(e){let e=setTimeout(()=>u.current?.focus(),50);return()=>clearTimeout(e)}},[e]);let m=(0,r.useCallback)(e=>{"Escape"===e.key&&d()},[d]);if(!e)return null;let h="danger"===o;return(0,t.jsxs)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/50 backdrop-blur-md",style:{animation:"confirm-overlay-in 200ms ease-out"},onClick:e=>e.target===e.currentTarget&&d(),onKeyDown:m,children:[(0,t.jsxs)("div",{ref:p,className:"w-full max-w-md mx-4 bg-[var(--card-bg)] rounded-2xl border border-[var(--card-border)] shadow-2xl overflow-hidden",style:{animation:"confirm-dialog-in 250ms cubic-bezier(0.34, 1.56, 0.64, 1)"},children:[(0,t.jsx)("div",{className:"px-6 pt-6 pb-3",children:(0,t.jsxs)("div",{className:"flex items-start gap-4",children:[h&&(0,t.jsx)("div",{className:"flex-shrink-0 w-11 h-11 rounded-full bg-red-500/10 border border-red-500/20 flex items-center justify-center",children:(0,t.jsx)("svg",{className:"w-5 h-5 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("h3",{className:"text-[15px] font-semibold text-[var(--foreground)]",children:a}),(0,t.jsx)("p",{className:"mt-1 text-[13px] text-[var(--muted-foreground)] leading-relaxed",children:s})]})]})}),n&&(0,t.jsx)("div",{className:"mx-6 mb-3 px-3 py-2.5 rounded-lg bg-[var(--muted)]/40 border border-[var(--card-border)]",children:(0,t.jsxs)("p",{className:"text-[12px] text-[var(--muted-foreground)] line-clamp-3 leading-relaxed italic",children:["“",n,"”"]})}),(0,t.jsx)("div",{className:"mx-6 border-t border-[var(--card-border)]"}),(0,t.jsxs)("div",{className:"px-6 py-4 flex items-center justify-end gap-2.5",children:[(0,t.jsx)("button",{onClick:d,className:"px-4 py-2 rounded-lg text-[13px] font-medium text-[var(--muted-foreground)] hover:text-[var(--foreground)] hover:bg-[var(--muted)]/60 transition-all duration-150",children:i}),(0,t.jsx)("button",{ref:u,onClick:c,className:`px-4 py-2 rounded-lg text-[13px] font-medium transition-all duration-150 ${h?"bg-red-500 text-white hover:bg-red-600 active:scale-[0.97]":"btn-primary active:scale-[0.97]"}`,children:l})]})]}),(0,t.jsx)("style",{children:`
2
2
  @keyframes confirm-overlay-in {
3
3
  from { opacity: 0; }
4
4
  to { opacity: 1; }
@@ -13,4 +13,4 @@
13
13
  transform: scale(1) translateY(0);
14
14
  }
15
15
  }
16
- `})]})}e.s(["default",()=>a])},945028,490011,e=>{"use strict";var t=e.i(935851);function r(e){return`threadId=${encodeURIComponent(e)}`}function a(e){return`workspaceId=${encodeURIComponent(e)}`}function s(e){let[s,n]=(0,t.useState)([]),[l,i]=(0,t.useState)([]),[o,c]=(0,t.useState)([]),d=(0,t.useRef)(e),u=(0,t.useRef)(e);d.current=e,u.current!==e&&(u.current=e,n([]),i([]),c([]));let m=(0,t.useCallback)(async e=>{let t=e?.trim()||d.current?.trim();if(!t){n([]),i([]);return}let s=r(t);try{let[e,r]=await Promise.all([fetch(`/api/history?${s}`),fetch(`/api/logs?${a(t)}`)]);if(d.current!==t)return;e.ok&&n(await e.json()),r.ok&&i(await r.json())}catch{}},[]),p=(0,t.useCallback)(async e=>{let t=e?.trim()||d.current?.trim();if(!t){n([]),i([]);return}let s=r(t);await Promise.all([fetch(`/api/history?${s}`,{method:"DELETE"}),fetch(`/api/logs?${a(t)}`,{method:"DELETE"})]),d.current===t&&(n([]),i([]))},[]),f=(0,t.useCallback)(async(e,t=10,r,a,s,l,i,o,u,m)=>{let p=r?.trim()||d.current?.trim();if(!p)return;let f=Date.now(),h=crypto.randomUUID(),x={id:h,role:"user",participantId:null,content:e,timestamp:f,rootMessageId:a||null,parentMessageId:a||null,depth:+!!a,...l&&l.length>0?{attachments:l}:{}};n(e=>[...e,x]);try{let r=await fetch("/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:p,prompt:e,promptPrefix:u||void 0,maxRounds:t,userMessageId:h,rootMessageId:a||void 0,attachmentIds:s?.length?s:void 0,activeParticipantIds:Array.isArray(i)?i:void 0,projectSlug:o?.trim()||void 0,routing:m})}),l=await r.json().catch(e=>(console.warn("[useGroupChat] failed to parse run response:",e),null));r.ok&&l?.chatRunId?c(e=>[{chatRunId:l.chatRunId,threadId:p,rootMessageId:a||h,status:"queued",optimistic:!0,enqueuedAt:Date.now()},...e.filter(e=>e.chatRunId!==l.chatRunId)]):r.ok||(console.error(`[useGroupChat] POST /api/chat failed (${r.status}):`,l?.error||r.statusText),n(e=>e.map(e=>e.id===h?{...e,sendFailed:!0}:e)))}catch(e){console.error("[useGroupChat] network error sending message:",e),n(e=>e.map(e=>e.id===h?{...e,sendFailed:!0}:e))}return h},[]),h=(0,t.useCallback)(async()=>{let e=d.current?.trim();if(e)try{await fetch(`/api/processes?workspaceId=${encodeURIComponent(e)}`,{method:"DELETE"})}catch{}},[]),x=(0,t.useCallback)(async e=>{let t=d.current?.trim();if(t)try{await fetch(`/api/processes?workspaceId=${encodeURIComponent(t)}&threadId=${encodeURIComponent(e)}`,{method:"DELETE"})}catch{}},[]);return{messages:s,setMessages:n,logs:l,sendMessage:f,loadHistory:m,clearHistory:p,clearLogs:(0,t.useCallback)(async e=>{let t=e?.trim()||d.current?.trim();t?(await fetch(`/api/logs?${a(t)}`,{method:"DELETE"}).catch(e=>console.warn("[useGroupChat] delete logs failed:",e)),d.current===t&&i([])):i([])},[]),chatRuns:o,setChatRuns:c,stop:h,stopThread:x}}e.s(["useGroupChat",()=>s],945028);let n=new Set(["spawning","running"]);function l(e,r){let a=r?.intervalMs??1500,s=r?.idleIntervalMs??1e4,[l,i]=(0,t.useState)(new Set),[o,c]=(0,t.useState)([]),[d,u]=(0,t.useState)({}),[m,p]=(0,t.useState)([]),f=(0,t.useRef)(e);f.current=e,(0,t.useRef)(r?.messages??[]).current=r?.messages??[];let h=(0,t.useRef)(r?.setMessages);h.current=r?.setMessages;let x=(0,t.useRef)(0),g=(0,t.useRef)(new Map),y=(0,t.useRef)(new Map);(0,t.useEffect)(()=>{let e=r?.messages??[];if(e.length>0){let t=Math.max(...e.map(e=>e.timestamp));t>x.current&&(x.current=t)}},[r?.messages]),(0,t.useEffect)(()=>()=>{for(let e of g.current.values())e.close();g.current.clear()},[]);let v=(0,t.useCallback)(async()=>{let e=f.current;if(!e){i(new Set),c([]),u({}),p([]);return}let t=null;if(e.threadId?t=`/api/processes?threadId=${encodeURIComponent(e.threadId)}`:e.workspaceId&&(t=`/api/processes?workspaceId=${encodeURIComponent(e.workspaceId)}`),!t){i(new Set),c([]),u({}),p([]);return}try{let a=e.workspaceId||e.threadId,s=a?`/api/history?threadId=${encodeURIComponent(a)}&since=${x.current}`:null,l=a?`/api/chat-runs?threadId=${encodeURIComponent(a)}&limit=20`:null,o=[fetch(t)];s&&o.push(fetch(s)),l&&o.push(fetch(l));let[d,u,m]=await Promise.all(o),g=f.current;if(g?.threadId!==e.threadId||g?.workspaceId!==e.workspaceId)return;if(d.ok){let e=await d.json();c(e);let t=new Set(e.filter(e=>n.has(e.state)).map(e=>e.agentId));i(t)}if(m?.ok){var r;let e=(r=await m.json(),Array.isArray(r)?r.map(e=>{if(!e||"object"!=typeof e)return null;let t="string"==typeof e.chatRunId?e.chatRunId:"string"==typeof e.id?e.id:null,r="string"==typeof e.threadId?e.threadId:null,a="string"==typeof e.status?e.status:null,s="string"==typeof e.rootMessageId?e.rootMessageId:(e.rootMessageId,null);return t&&r&&a&&("queued"===a||"running"===a||"awaiting_user"===a||"blocked"===a||"completed"===a||"failed"===a||"cancelled"===a)?{chatRunId:t,threadId:r,rootMessageId:s,status:a,optimistic:!1}:null}).filter(e=>!!e):[]);p(e)}if(u?.ok&&h.current){let e=await u.json();if(e.length>0){let t=Math.max(...e.map(e=>e.timestamp));t>x.current&&(x.current=t),h.current(t=>{let r=new Set(t.map(e=>e.id)),a=e.filter(e=>!r.has(e.id)),s=t.map(t=>e.find(e=>e.id===t.id)??t);return 0===a.length?s:[...s,...a].sort((e,t)=>e.timestamp-t.timestamp)})}}}catch{}},[]);(0,t.useEffect)(()=>{let e=m.filter(e=>"queued"===e.status||"running"===e.status),t=new Set(e.map(e=>e.chatRunId));for(let[e,r]of g.current.entries())t.has(e)||(r.close(),g.current.delete(e),y.current.delete(e));for(let t of e){if(g.current.has(t.chatRunId))continue;let e=new EventSource(`/api/chat-runs/${encodeURIComponent(t.chatRunId)}/events`);g.current.set(t.chatRunId,e);let r=new Map;y.current.set(t.chatRunId,r);let a=new Set;e.addEventListener("chat",s=>{let n;try{n=JSON.parse(s.data)}catch{return}switch(n.type){case"participant-start":case"participant-thinking":a.add(n.participantId),r.has(n.participantId)||r.set(n.participantId,{text:"",thoughts:[]}),u(e=>e[n.participantId]?e:{...e,[n.participantId]:{content:"",rootMessageId:t.rootMessageId??null}});break;case"text-delta":{r.has(n.participantId)||r.set(n.participantId,{text:"",thoughts:[]});let e=r.get(n.participantId);e&&(e.text+=n.delta,u(r=>{let a={...r},s=t.rootMessageId??null;return a[n.participantId]={content:e.text,rootMessageId:s},a}));break}case"participant-thought":{let e=r.get(n.participantId);e&&(e.thoughts.push(n.content),u(t=>{let r=t[n.participantId];return r?{...t,[n.participantId]:{...r,thoughts:[...e.thoughts]}}:t}));break}case"participant-end":a.delete(n.participantId),v().then(()=>{u(e=>{let t={...e};return delete t[n.participantId],t})});break;case"participant-error":a.delete(n.participantId),v().then(()=>{u(e=>{let t={...e};return delete t[n.participantId],t})});break;case"done":e.close(),g.current.delete(t.chatRunId),y.current.delete(t.chatRunId)}}),e.onerror=()=>{e.close(),g.current.delete(t.chatRunId),y.current.delete(t.chatRunId)}}},[m]);let b=e?.threadId||e?.workspaceId||null,j=m.some(e=>"queued"===e.status||"running"===e.status),w=o.some(e=>n.has(e.state)),k=j||w?a:s;return(0,t.useEffect)(()=>{if(!b){i(new Set),c([]),u({}),p([]);return}v();let e=setInterval(v,k);return()=>clearInterval(e)},[b,k,v]),{activeAgents:l,processes:o,streaming:d,chatRuns:m,poll:v}}e.s(["useProcessPolling",()=>l],490011)},640481,e=>{"use strict";let t=(0,e.i(363732).default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);e.s(["Pencil",()=>t],640481)},558201,e=>{"use strict";let t=(0,e.i(363732).default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);e.s(["Terminal",()=>t],558201)},781873,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"BailoutToCSR",{enumerable:!0,get:function(){return s}});let a=e.r(804984);function s({reason:e,children:t}){if("u"<typeof window)throw Object.defineProperty(new a.BailoutToCSRError(e),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return t}},373512,(e,t,r)=>{"use strict";function a(e){return e.split("/").map(e=>encodeURIComponent(e)).join("/")}Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"encodeURIPath",{enumerable:!0,get:function(){return a}})},974052,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"PreloadChunks",{enumerable:!0,get:function(){return o}});let a=e.r(762281),s=e.r(866389),n=e.r(721014),l=e.r(373512),i=e.r(162998);function o({moduleIds:e}){if("u">typeof window)return null;let t=n.workAsyncStorage.getStore();if(void 0===t)return null;let r=[];if(t.reactLoadableManifest&&e){let a=t.reactLoadableManifest;for(let t of e){if(!a[t])continue;let e=a[t].files;r.push(...e)}}if(0===r.length)return null;let o=(0,i.getDeploymentIdQueryOrEmptyString)();return(0,a.jsx)(a.Fragment,{children:r.map(e=>{let r=`${t.assetPrefix}/_next/${(0,l.encodeURIPath)(e)}${o}`;return e.endsWith(".css")?(0,a.jsx)("link",{precedence:"dynamic",href:r,rel:"stylesheet",as:"style",nonce:t.nonce},e):((0,s.preload)(r,{as:"script",fetchPriority:"low",nonce:t.nonce}),null)})})}},184790,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"default",{enumerable:!0,get:function(){return c}});let a=e.r(762281),s=e.r(935851),n=e.r(781873),l=e.r(974052);function i(e){return{default:e&&"default"in e?e.default:e}}let o={loader:()=>Promise.resolve(i(()=>null)),loading:null,ssr:!0},c=function(e){let t={...o,...e},r=(0,s.lazy)(()=>t.loader().then(i)),c=t.loading;function d(e){let i=c?(0,a.jsx)(c,{isLoading:!0,pastDelay:!0,error:null}):null,o=!t.ssr||!!t.loading,d=o?s.Suspense:s.Fragment,u=t.ssr?(0,a.jsxs)(a.Fragment,{children:["u"<typeof window?(0,a.jsx)(l.PreloadChunks,{moduleIds:t.modules}):null,(0,a.jsx)(r,{...e})]}):(0,a.jsx)(n.BailoutToCSR,{reason:"next/dynamic",children:(0,a.jsx)(r,{...e})});return(0,a.jsx)(d,{...o?{fallback:i}:{},children:u})}return d.displayName="LoadableComponent",d}},353899,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"default",{enumerable:!0,get:function(){return s}});let a=e.r(555682)._(e.r(184790));function s(e,t){let r={};"function"==typeof e&&(r.loader=e);let s={...r,...t};return(0,a.default)({...s,modules:s.loadableGenerated?.modules})}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},245110,e=>{"use strict";let t=(0,e.i(363732).default)("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);e.s(["ExternalLink",()=>t],245110)},257587,e=>{"use strict";let t=(0,e.i(363732).default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);e.s(["Settings",()=>t],257587)},459073,e=>{"use strict";let t=(0,e.i(363732).default)("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);e.s(["FolderPlus",()=>t],459073)},693646,e=>{"use strict";let t=(0,e.i(363732).default)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);e.s(["Save",()=>t],693646)},509501,e=>{"use strict";var t=e.i(935851);function r(e,r){let[a,s]=(0,t.useState)([]),[n,l]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{let t=!1;return async function(){try{let a=await fetch("/api/participants"),n=a.ok?await a.json():[];if(!r){t||(s(n),l(!0));return}let i=new URLSearchParams;i.set("projectId",r);let o=await fetch(`/api/trackers/${encodeURIComponent(e)}/worker?${i}`).catch(()=>null),c=o?.ok?await o.json().catch(()=>null):null,d=c?.job?.teamId||void 0;if(d){let e=await fetch(`/api/projects/${encodeURIComponent(r)}/teams/${encodeURIComponent(d)}/agents`);if(e.ok){let r=await e.json(),a=Array.isArray(r.agents)?r.agents.sort((e,t)=>(e.routing_order??0)-(t.routing_order??0)).map(e=>e.agent_id).filter(e=>"string"==typeof e&&e.trim().length>0):[];if(a.length>0){let e=new Map(a.map((e,t)=>[e,t])),r=n.filter(t=>e.has(t.id)).sort((t,r)=>(e.get(t.id)??Number.MAX_SAFE_INTEGER)-(e.get(r.id)??Number.MAX_SAFE_INTEGER));if(!t&&r.length>0){s(r),l(!0);return}}}}let u=await fetch(`/api/projects/${encodeURIComponent(r)}/agents`);if(!u.ok){t||(s(n),l(!0));return}let m=await u.json(),p=Array.isArray(m.agents)?m.agents.map(e=>e.agent_id).filter(e=>"string"==typeof e&&e.trim().length>0):[],f=new Map(p.map((e,t)=>[e,t])),h=n.filter(e=>f.has(e.id)).sort((e,t)=>(f.get(e.id)??Number.MAX_SAFE_INTEGER)-(f.get(t.id)??Number.MAX_SAFE_INTEGER));t||(s(h),l(!0))}catch{t||(s([]),l(!0))}}(),()=>{t=!0}},[e,r]),{participants:a,participantsLoaded:n}}e.s(["useTrackerParticipants",()=>r])},807087,e=>{"use strict";let t=(0,e.i(363732).default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);e.s(["CheckCircle2",()=>t],807087)},287472,e=>{"use strict";var t=e.i(935851);let r=new Map;function a(e){let t=r.get(e);return t?Date.now()-t.ts>3e5?(r.delete(e),null):t:null}function s(e){r.delete(e)}function n(e,n){let[l,i]=(0,t.useState)(!1),[o,c]=(0,t.useState)(!0),[d,u]=(0,t.useState)(null),[m,p]=(0,t.useState)({claude:!1,codex:!1,gemini:!1}),[f,h]=(0,t.useState)({}),x=(0,t.useRef)(null),g=`/api/trackers/${encodeURIComponent(e)}`,y=`${e}:${n}`,v=(0,t.useCallback)(async()=>{try{let e=await fetch(`${g}/mcp-setup`),t=await e.json();h(t.configured??{})}catch{}},[g]),b=(0,t.useCallback)(async()=>{if(!n)return i(!1),!1;let e=a(y);if(e)return i(e.connected),u(e.user),p(e.clis),h(e.mcpConfigured),c(!1),e.connected;try{var t;let e=`?projectId=${encodeURIComponent(n)}`,[a,s]=await Promise.all([fetch(`${g}/status${e}`),fetch(`${g}/mcp-setup`)]),l=await a.json(),o=await s.json(),c=l.clis??{claude:!1,codex:!1,gemini:!1},d=o.configured??{},m=l.user??null;return i(l.connected),u(m),p(c),h(d),t={connected:l.connected,user:m,clis:c,mcpConfigured:d},r.set(y,{...t,ts:Date.now()}),l.connected}catch{return i(!1),!1}finally{c(!1)}},[n,g,y]);(0,t.useEffect)(()=>{let e=a(y);e?(i(e.connected),u(e.user),p(e.clis),h(e.mcpConfigured),c(!1)):(c(!0),i(!1),u(null))},[e,n,y]),(0,t.useEffect)(()=>(b(),()=>{x.current&&clearInterval(x.current)}),[b]);let j=(0,t.useCallback)(()=>{n&&(s(y),window.open(`${g}/auth?projectId=${encodeURIComponent(n)}`,"_blank","noopener"),x.current&&clearInterval(x.current),x.current=setInterval(async()=>{s(y),await b()&&x.current&&(clearInterval(x.current),x.current=null)},2e3))},[n,g,y,b]),w=(0,t.useCallback)(async e=>{if(!n)return{ok:!1,error:"Missing projectId"};try{let t=await fetch(`${g}/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:n,accessToken:e})});if(!t.ok){let e=await t.json().catch(()=>({}));return{ok:!1,error:e.error||"Failed to save token"}}return s(y),await b(),{ok:!0}}catch{return{ok:!1,error:"Failed to connect"}}},[n,g,y,b]);return{connected:l,loading:o,user:d,clis:m,mcpConfigured:f,connect:j,connectWithKey:w,disconnect:(0,t.useCallback)(async()=>{n&&(s(y),await fetch(`${g}/status?projectId=${encodeURIComponent(n)}`,{method:"DELETE"}),"github"===e&&Object.keys(sessionStorage).filter(e=>e.startsWith("github_")).forEach(e=>sessionStorage.removeItem(e)),i(!1),u(null))},[n,g,y,e]),configureMcp:(0,t.useCallback)(async e=>{try{let t=await fetch(`${g}/mcp-setup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cli:e})});if(!t.ok){let e=await t.json().catch(()=>({}));return{ok:!1,error:e.error||"Failed to configure MCP"}}return await v(),{ok:!0}}catch{return{ok:!1,error:"Failed to configure MCP"}}},[g,v]),refresh:b}}e.s(["useTrackerConnection",()=>n])},637790,166735,e=>{"use strict";var t=e.i(363732);let r=(0,t.default)("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);e.s(["Key",()=>r],637790);let a=(0,t.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);e.s(["Globe",()=>a],166735)},711190,e=>{"use strict";let t=(0,e.i(363732).default)("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]);e.s(["LogOut",()=>t],711190)},202192,457242,e=>{"use strict";var t=e.i(762281),r=e.i(935851),a=e.i(807087),s=e.i(637790),n=e.i(166735),l=e.i(906724),i=e.i(741746),o=e.i(558201),c=e.i(711190),d=e.i(681619),u=e.i(929870),m=e.i(797167),p=e.i(203096);let f=(0,e.i(363732).default)("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);function h({projectId:e}){let[a,s]=(0,r.useState)([]),[n,i]=(0,r.useState)(!0),[o,c]=(0,r.useState)(null),[d,h]=(0,r.useState)(null),[x,g]=(0,r.useState)(!1),[y,v]=(0,r.useState)([]),[b,j]=(0,r.useState)(!1),[w,k]=(0,r.useState)(null),[N,I]=(0,r.useState)(""),[C,S]=(0,r.useState)("all"),[M,R]=(0,r.useState)(new Set),[P,E]=(0,r.useState)(!1),$=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/github/repos",{cache:"no-store"});if(!e.ok)throw Error("Failed to load repos");let t=await e.json();s(t.repos??[]),c(null)}catch{c("Failed to load repositories")}finally{i(!1)}},[]);(0,r.useEffect)(()=>{$()},[$]);let L=(0,r.useCallback)((e,t)=>`${e}/${t}`.toLowerCase(),[]),A=(0,r.useMemo)(()=>new Set(a.map(e=>L(e.owner,e.name))),[a,L]),T=(0,r.useCallback)(async()=>{if(g(!0),R(new Set),I(""),S("all"),!(y.length>0)){j(!0),k(null);try{let t=await fetch(`/api/github/user-repos?projectId=${encodeURIComponent(e)}`,{cache:"no-store"});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e?.error??"Failed to fetch repos")}let r=await t.json();v(r.repos??[])}catch(e){k(e instanceof Error?e.message:"Failed to fetch repos")}finally{j(!1)}}},[e,y.length]),O=()=>{g(!1)};(0,r.useEffect)(()=>{if(!x)return;let e=e=>{"Escape"===e.key&&O()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x]);let _=(0,r.useMemo)(()=>{let e=[],t=[];for(let r of y)A.has(L(r.owner,r.name))?e.push(r):t.push(r);return[...e,...t]},[y,A,L]),U=(0,r.useMemo)(()=>{let e=N.trim().toLowerCase();return _.filter(t=>("public"!==C||!t.private)&&("private"!==C||!!t.private)&&(!e||t.fullName.toLowerCase().includes(e)||(t.description??"").toLowerCase().includes(e)))},[_,N,C]),z=(0,r.useMemo)(()=>U.filter(e=>!A.has(L(e.owner,e.name))),[U,A,L]),F=z.length>0&&z.every(e=>M.has(e.id)),D=async()=>{if(0!==M.size){E(!0);try{let e=y.filter(e=>M.has(e.id));await Promise.all(e.map(e=>fetch("/api/github/repos",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({owner:e.owner,name:e.name,defaultBranch:e.defaultBranch,private:e.private})}))),await $(),O()}finally{E(!1)}}},q=(0,r.useCallback)(async e=>{h(e);try{await fetch("/api/github/repos",{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({id:e})}),await $()}finally{h(null)}},[$]);return(0,t.jsxs)("div",{className:"w-full max-w-md space-y-4",children:[(0,t.jsxs)("div",{className:"border rounded-xl p-5 flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{className:"text-sm font-medium",children:"Attached repositories"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Repos the local agent watches for PRs, reviews, and comments."})]}),(0,t.jsxs)("button",{type:"button",onClick:T,className:"text-xs px-2.5 py-1.5 rounded border hover:bg-accent inline-flex items-center gap-1",children:[(0,t.jsx)(u.Plus,{className:"w-3.5 h-3.5"}),"Add"]})]}),n?(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(l.Loader2,{className:"w-4 h-4 animate-spin"}),"Loading repositories…"]}):o?(0,t.jsx)("p",{className:"text-sm text-destructive",children:o}):0===a.length?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No repositories attached yet."}):(0,t.jsx)("ul",{className:"divide-y",children:a.map(e=>(0,t.jsxs)("li",{className:"flex items-center justify-between py-2",children:[(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsxs)("span",{className:"text-sm font-mono",children:[e.owner,"/",e.name]}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:[e.defaultBranch??"no default branch",e.private?" · private":" · public",e.accessRevoked?" · access revoked":""]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>q(e.id),disabled:d===e.id,className:"p-1.5 rounded hover:bg-accent disabled:opacity-50",title:"Remove",children:(0,t.jsx)(m.X,{className:"w-3.5 h-3.5"})})]},e.id))})]}),(0,t.jsxs)("div",{className:"border rounded-xl p-5 flex items-center justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{className:"text-sm font-medium",children:"Sync"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Pull the latest PRs, reviews, and comments for attached repos."})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>alert("Sync will run when worker is scheduled"),className:"text-xs px-3 py-1.5 rounded border hover:bg-accent inline-flex items-center gap-1.5",children:[(0,t.jsx)(p.RefreshCw,{className:"w-3.5 h-3.5"}),"Sync now"]})]}),x&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:O,children:(0,t.jsxs)("div",{className:"w-full max-w-3xl max-h-[90vh] flex flex-col rounded-xl border border-[var(--border)] bg-[var(--background)] text-[var(--foreground)] shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)("header",{className:"px-6 py-5 border-b border-[var(--border)] flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-[var(--muted-foreground)] mb-1",children:[(0,t.jsx)("span",{children:"GitHub"}),(0,t.jsx)("span",{children:"·"}),(0,t.jsx)("span",{children:"Attach repositories"})]}),(0,t.jsx)("h1",{className:"text-xl font-semibold tracking-tight",children:"Select repositories"}),(0,t.jsx)("p",{className:"text-sm text-[var(--muted-foreground)] mt-1",children:"Pick the repos you want agx to track. Already-attached repos are pinned at the top."})]}),(0,t.jsx)("button",{onClick:O,className:"p-1.5 rounded hover:bg-[var(--item-hover-bg)] text-[var(--muted-foreground)]","aria-label":"Close",children:(0,t.jsx)(m.X,{className:"w-4 h-4"})})]}),(0,t.jsx)("div",{className:"px-6 py-4 flex-1 overflow-hidden flex flex-col",children:w?(0,t.jsx)("div",{className:"rounded-lg border border-[var(--status-failed-border)] bg-[var(--status-failed-bg)] text-[var(--status-failed)] px-4 py-3 text-sm",children:w}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 mb-3",children:[(0,t.jsxs)("div",{className:"relative flex-1",children:[(0,t.jsxs)("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--muted-foreground)]",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,t.jsx)("path",{d:"m21 21-4.3-4.3"})]}),(0,t.jsx)("input",{type:"text",value:N,onChange:e=>I(e.target.value),placeholder:"Search repositories...",className:"w-full pl-9 pr-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--input)] text-sm focus:outline-none focus:border-[var(--primary)] focus:bg-[var(--input-focus)] transition-colors"})]}),(0,t.jsx)("div",{className:"flex gap-1 rounded-lg border border-[var(--border)] p-1",children:["all","public","private"].map(e=>(0,t.jsx)("button",{onClick:()=>S(e),className:`px-3 py-1 text-xs rounded-md capitalize transition-colors ${C===e?"bg-[var(--primary)] text-[var(--primary-foreground)]":"text-[var(--muted-foreground)] hover:text-[var(--foreground)]"}`,children:e},e))})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2 text-xs text-[var(--muted-foreground)]",children:[(0,t.jsxs)("button",{onClick:()=>{R(e=>{let t=new Set(e);return F?z.forEach(e=>t.delete(e.id)):z.forEach(e=>t.add(e.id)),t})},disabled:0===z.length,className:"hover:text-[var(--foreground)] transition-colors disabled:opacity-50",children:[F?"Deselect all":"Select all",N||"all"!==C?` (${z.length} shown)`:""]}),M.size>0&&(0,t.jsx)("button",{onClick:()=>R(new Set),className:"hover:text-[var(--foreground)] transition-colors",children:"Clear selection"})]}),(0,t.jsx)("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--card-bg)] overflow-hidden flex-1 min-h-0",children:(0,t.jsx)("div",{className:"h-full overflow-y-auto",children:b?(0,t.jsx)("div",{className:"divide-y divide-[var(--border)]",children:Array.from({length:6}).map((e,r)=>(0,t.jsxs)("div",{className:"px-4 py-3 flex items-center gap-3 animate-pulse",children:[(0,t.jsx)("div",{className:"w-4 h-4 rounded bg-[var(--muted)]"}),(0,t.jsx)("div",{className:"w-6 h-6 rounded-full bg-[var(--muted)]"}),(0,t.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,t.jsx)("div",{className:"h-3 w-1/3 rounded bg-[var(--muted)]"}),(0,t.jsx)("div",{className:"h-2 w-2/3 rounded bg-[var(--muted)]"})]})]},r))}):0===U.length?(0,t.jsx)("div",{className:"px-4 py-10 text-center text-sm text-[var(--muted-foreground)]",children:0===y.length?"No repositories found on your account.":"No repos match your search."}):(0,t.jsx)("ul",{className:"divide-y divide-[var(--border)]",children:U.map(e=>{let r=A.has(L(e.owner,e.name)),a=M.has(e.id);return(0,t.jsx)("li",{children:(0,t.jsxs)("label",{className:`flex items-start gap-3 px-4 py-3 transition-colors ${r?"bg-[var(--primary-muted)]/40 cursor-default":a?"bg-[var(--primary-muted)] cursor-pointer":"hover:bg-[var(--item-hover-bg)] cursor-pointer"}`,children:[r?(0,t.jsx)("div",{className:"mt-1 w-4 h-4 rounded-sm bg-[var(--primary)]/20 text-[var(--primary)] flex items-center justify-center",title:"Already attached",children:(0,t.jsx)(f,{className:"w-2.5 h-2.5"})}):(0,t.jsx)("input",{type:"checkbox",checked:a,onChange:()=>{!A.has(L(e.owner,e.name))&&R(t=>{let r=new Set(t);return r.has(e.id)?r.delete(e.id):r.add(e.id),r})},className:"mt-1 accent-[var(--primary)]"}),(0,t.jsx)("img",{src:e.avatarUrl,alt:"",className:"w-6 h-6 rounded-full mt-0.5 flex-shrink-0"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)("span",{className:"text-sm font-medium truncate",children:e.fullName}),r&&(0,t.jsxs)("span",{className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded bg-[var(--primary)]/15 text-[var(--primary)] flex items-center gap-1",children:[(0,t.jsx)(f,{className:"w-2.5 h-2.5"}),"Attached"]}),e.private&&(0,t.jsx)("span",{className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded bg-[var(--muted)] text-[var(--muted-foreground)]",children:"Private"})]}),e.description&&(0,t.jsx)("p",{className:"text-xs text-[var(--muted-foreground)] mt-0.5 line-clamp-1",children:e.description}),(0,t.jsxs)("div",{className:"text-[11px] text-[var(--muted-foreground)] mt-0.5",children:["Updated ",function(e){let t=Math.floor((Date.now()-new Date(e).getTime())/1e3);if(t<60)return"just now";let r=Math.floor(t/60);if(r<60)return`${r}m ago`;let a=Math.floor(r/60);if(a<24)return`${a}h ago`;let s=Math.floor(a/24);if(s<30)return`${s}d ago`;let n=Math.floor(s/30);return n<12?`${n}mo ago`:`${Math.floor(n/12)}y ago`}(e.updatedAt)]})]})]})},e.id)})})})})]})}),(0,t.jsxs)("footer",{className:"px-6 py-4 border-t border-[var(--border)] flex items-center justify-between gap-3",children:[(0,t.jsxs)("span",{className:"text-sm text-[var(--muted-foreground)]",children:[M.size," selected"]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{onClick:O,className:"px-4 py-2 rounded-lg border border-[var(--border)] hover:bg-[var(--item-hover-bg)] text-sm font-medium transition-colors",children:"Cancel"}),(0,t.jsx)("button",{onClick:D,disabled:0===M.size||P,className:"px-4 py-2 rounded-lg bg-[var(--primary)] hover:bg-[var(--primary-hover)] text-[var(--primary-foreground)] text-sm font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:P?"Attaching...":`Attach ${M.size} ${1===M.size?"repo":"repos"}`})]})]})]})})]})}e.s(["Pin",()=>f],457242);var x=e.i(352687);let g={claude:{name:"Claude Code",configPath:"~/.claude/settings.json"},codex:{name:"Codex CLI",configPath:"~/.codex/config.toml"},gemini:{name:"Gemini CLI",configPath:"~/.gemini/settings.json"}};function y({trackerType:e,projectId:u,connected:m,onConnect:p,onConnectWithKey:f,onDisconnect:y,loading:v=!1,clis:b,mcpConfigured:j,onConfigureMcp:w}){let[k,N]=r.default.useState(""),[I,C]=r.default.useState(null),[S,M]=r.default.useState(!1),[R,P]=r.default.useState(!1),[E,$]=r.default.useState(null),[L,A]=r.default.useState({}),[T,O]=r.default.useState(!1),_=async e=>{if(!w)return;$(e),A(t=>({...t,[e]:""}));let t=await w(e);t.ok||A(r=>({...r,[e]:t.error??"Failed to install MCP"})),$(null)},U=b?["claude","codex","gemini"].filter(e=>b[e]):["claude"];if(v)return(0,t.jsx)("div",{className:"flex items-center justify-center p-12",children:(0,t.jsx)(l.Loader2,{className:"animate-spin h-8 w-8 text-muted-foreground"})});if(m)return(0,t.jsxs)("div",{className:"p-8 flex flex-col items-center gap-6",children:[(0,t.jsxs)("div",{className:"w-full max-w-md p-8 border border-green-500/20 bg-green-500/5 rounded-2xl flex flex-col items-center gap-4 text-center",children:[(0,t.jsx)("div",{className:"h-16 w-16 rounded-full bg-green-500/10 flex items-center justify-center text-green-600 shadow-inner",children:(0,t.jsx)(a.CheckCircle2,{className:"h-8 w-8"})}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("h3",{className:"text-xl font-bold text-foreground capitalize",children:[e," Connected"]}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground leading-relaxed",children:["Your ",e," workspace is successfully connected. The agent can now sync issues and manage your backlog."]})]}),(0,t.jsxs)("div",{className:"mt-2 px-4 py-1.5 rounded-full bg-background border text-xs font-medium text-muted-foreground flex items-center gap-2",children:[(0,t.jsx)("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500 animate-pulse"}),"Active Connection"]}),y&&(0,t.jsxs)("button",{onClick:()=>O(!0),className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-destructive transition-colors mt-1",children:[(0,t.jsx)(c.LogOut,{className:"h-3.5 w-3.5"}),"Disconnect"]})]}),"github"===e&&(0,t.jsx)(h,{projectId:u}),y&&(0,t.jsx)(x.default,{isOpen:T,title:`Disconnect ${e}?`,message:"github"===e?"This revokes the stored credentials. Your attached repositories and synced history stay — reconnecting will resume where you left off.":`This revokes the stored credentials for ${e}. Project settings and synced history stay.`,confirmLabel:"Disconnect",cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{O(!1),y()},onCancel:()=>O(!1)}),"github"!==e&&U.length>0&&(0,t.jsx)("div",{className:"w-full max-w-md",children:(0,t.jsxs)("div",{className:"border rounded-xl p-5 flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(o.Terminal,{className:"h-4 w-4 text-muted-foreground"}),(0,t.jsx)("span",{className:"text-sm font-medium",children:"MCP Server"})]}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground leading-relaxed -mt-2",children:["Install the ",e," MCP server so agents can access ",e," directly."]}),U.map(e=>{let r=g[e],s=j?.[e]??!1,n=E===e,o=L[e];return(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-foreground",children:r.name}),s?(0,t.jsxs)("span",{className:"text-xs font-medium text-green-600 flex items-center gap-1",children:[(0,t.jsx)(a.CheckCircle2,{className:"h-3.5 w-3.5"}),"Installed"]}):(0,t.jsx)("button",{onClick:()=>_(e),disabled:n||!w,className:"flex items-center gap-1.5 px-3 py-1 bg-secondary text-secondary-foreground rounded-md text-xs font-semibold hover:bg-secondary/90 disabled:opacity-50 transition-all active:scale-[0.98]",children:n?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(l.Loader2,{className:"h-3 w-3 animate-spin"}),"Installing…"]}):(0,t.jsx)(t.Fragment,{children:"Install"})})]}),s&&(0,t.jsxs)("p",{className:"text-[10px] text-muted-foreground",children:["Configured in ",(0,t.jsx)("code",{className:"font-mono",children:r.configPath})]}),o&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-destructive bg-destructive/10 p-2 rounded-md",children:[(0,t.jsx)(i.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),o]})]},e)})]})})]});let z=async()=>{if(k.trim()){P(!0),C(null);try{let e=await f(k.trim());e.ok?(N(""),M(!1)):C(e.error??"Failed to connect")}catch(e){C("An unexpected error occurred")}finally{P(!1)}}};return(0,t.jsxs)("div",{className:"flex flex-col items-center gap-6 p-8",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(d.TrackerIcon,{trackerType:e,className:"h-16 w-16"}),(0,t.jsx)("div",{className:"absolute -bottom-1 -right-1 h-6 w-6 rounded-full bg-background border flex items-center justify-center shadow-sm",children:(0,t.jsx)(n.Globe,{className:"h-3 w-3 text-muted-foreground"})})]}),(0,t.jsxs)("div",{className:"text-center space-y-2",children:[(0,t.jsxs)("h3",{className:"text-lg font-semibold capitalize",children:["Connect to ",e]}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground text-center max-w-sm leading-relaxed",children:["Link your ",e," account to import issues, track progress, and automate your workflow."]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 w-full max-w-xs pt-2",children:[(0,t.jsxs)("button",{onClick:p,className:"flex items-center justify-center gap-2 w-full px-4 py-2.5 bg-primary text-primary-foreground rounded-lg text-sm font-semibold hover:bg-primary/90 transition-all active:scale-[0.98] shadow-sm",children:[(0,t.jsx)(n.Globe,{className:"h-4 w-4"}),"Connect with OAuth"]}),"github"!==e&&(0,t.jsxs)("button",{onClick:()=>{M(!S),C(null)},className:"flex items-center justify-center gap-2 w-full px-4 py-2 text-sm text-muted-foreground hover:text-foreground transition-colors font-medium",children:[(0,t.jsx)(s.Key,{className:"h-3.5 w-3.5"}),S?"Use OAuth instead":"Connect with API key"]}),(0,t.jsx)("div",{className:`grid transition-all duration-300 ease-in-out ${S?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0 pointer-events-none"}`,children:(0,t.jsx)("div",{className:"overflow-hidden",children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 pt-2",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"password",value:k,onChange:e=>{N(e.target.value),I&&C(null)},placeholder:"Paste your API key here",className:`w-full px-3 py-2 border rounded-lg text-sm bg-background transition-colors focus:outline-none focus:ring-2 focus:ring-primary/20 ${I?"border-destructive":"focus:border-primary"}`,onKeyDown:e=>"Enter"===e.key&&z()}),(0,t.jsx)(s.Key,{className:"absolute right-3 top-2.5 h-4 w-4 text-muted-foreground/50"})]}),I&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-destructive bg-destructive/10 p-2 rounded-md",children:[(0,t.jsx)(i.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("p",{children:I})]}),(0,t.jsx)("button",{onClick:z,disabled:R||!k.trim(),className:"flex items-center justify-center gap-2 w-full px-4 py-2 bg-secondary text-secondary-foreground rounded-lg text-sm font-semibold hover:bg-secondary/90 disabled:opacity-50 transition-all active:scale-[0.98]",children:R?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(l.Loader2,{className:"h-4 w-4 animate-spin"}),"Connecting..."]}):"Verify & Connect"}),(0,t.jsxs)("p",{className:"text-[10px] text-muted-foreground text-center px-2",children:["Your API key is stored securely and only used for ",e," integration."]})]})})})]})]})}e.s(["default",()=>y],202192)},427877,e=>{"use strict";var t=e.i(762281),r=e.i(935851),a=e.i(506420),s=e.i(524123),n=e.i(471387);function l({params:e}){let{slug:l,tracker:i}=(0,r.use)(e),o=(0,a.useSearchParams)(),{projects:c}=(0,s.useProjects)(),d=c.find(e=>e.slug===l),u="true"===o.get("settings"),m="github"===i?o.get("repo"):null;return(0,r.useEffect)(()=>{"github"===i&&m&&d?.id&&fetch("/api/github/repos/sync",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectId:d.id,repoId:m})}).catch(()=>{})},[i,m,d?.id]),(0,t.jsx)(n.default,{trackerType:i,projectId:d?.id,projectSlug:d?.slug??l,initialShowSettings:u,initialGroupId:m??void 0})}e.s(["default",()=>l])},469612,e=>{e.v(t=>Promise.all(["static/chunks/256961ed1522219b.js"].map(t=>e.l(t))).then(()=>t(668610)))},501223,e=>{e.v(t=>Promise.all(["static/chunks/94f26a112344ab1b.css","static/chunks/5591af73db0a3aee.js","static/chunks/42a62b80b32a97f7.js"].map(t=>e.l(t))).then(()=>t(844118)))}]);
16
+ `})]})}e.s(["default",()=>a])},945028,490011,e=>{"use strict";var t=e.i(935851);function r(e){return`threadId=${encodeURIComponent(e)}`}function a(e){return`workspaceId=${encodeURIComponent(e)}`}function s(e){let[s,n]=(0,t.useState)([]),[l,i]=(0,t.useState)([]),[o,c]=(0,t.useState)([]),d=(0,t.useRef)(e),u=(0,t.useRef)(e);d.current=e,u.current!==e&&(u.current=e,n([]),i([]),c([]));let p=(0,t.useCallback)(async e=>{let t=e?.trim()||d.current?.trim();if(!t){n([]),i([]);return}let s=r(t);try{let[e,r]=await Promise.all([fetch(`/api/history?${s}`),fetch(`/api/logs?${a(t)}`)]);if(d.current!==t)return;e.ok&&n(await e.json()),r.ok&&i(await r.json())}catch{}},[]),m=(0,t.useCallback)(async e=>{let t=e?.trim()||d.current?.trim();if(!t){n([]),i([]);return}let s=r(t);await Promise.all([fetch(`/api/history?${s}`,{method:"DELETE"}),fetch(`/api/logs?${a(t)}`,{method:"DELETE"})]),d.current===t&&(n([]),i([]))},[]),h=(0,t.useCallback)(async(e,t=10,r,a,s,l,i,o,u,p)=>{let m=r?.trim()||d.current?.trim();if(!m)return;let h=Date.now(),f=crypto.randomUUID(),x={id:f,role:"user",participantId:null,content:e,timestamp:h,rootMessageId:a||null,parentMessageId:a||null,depth:+!!a,...l&&l.length>0?{attachments:l}:{}};n(e=>[...e,x]);try{let r=await fetch("/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:m,prompt:e,promptPrefix:u||void 0,maxRounds:t,userMessageId:f,rootMessageId:a||void 0,attachmentIds:s?.length?s:void 0,activeParticipantIds:Array.isArray(i)?i:void 0,projectSlug:o?.trim()||void 0,routing:p})}),l=await r.json().catch(e=>(console.warn("[useGroupChat] failed to parse run response:",e),null));r.ok&&l?.chatRunId?c(e=>[{chatRunId:l.chatRunId,threadId:m,rootMessageId:a||f,status:"queued",optimistic:!0,enqueuedAt:Date.now()},...e.filter(e=>e.chatRunId!==l.chatRunId)]):r.ok||(console.error(`[useGroupChat] POST /api/chat failed (${r.status}):`,l?.error||r.statusText),n(e=>e.map(e=>e.id===f?{...e,sendFailed:!0}:e)))}catch(e){console.error("[useGroupChat] network error sending message:",e),n(e=>e.map(e=>e.id===f?{...e,sendFailed:!0}:e))}return f},[]),f=(0,t.useCallback)(async()=>{let e=d.current?.trim();if(e)try{await fetch(`/api/processes?workspaceId=${encodeURIComponent(e)}`,{method:"DELETE"})}catch{}},[]),x=(0,t.useCallback)(async e=>{let t=d.current?.trim();if(t)try{await fetch(`/api/processes?workspaceId=${encodeURIComponent(t)}&threadId=${encodeURIComponent(e)}`,{method:"DELETE"})}catch{}},[]);return{messages:s,setMessages:n,logs:l,sendMessage:h,loadHistory:p,clearHistory:m,clearLogs:(0,t.useCallback)(async e=>{let t=e?.trim()||d.current?.trim();t?(await fetch(`/api/logs?${a(t)}`,{method:"DELETE"}).catch(e=>console.warn("[useGroupChat] delete logs failed:",e)),d.current===t&&i([])):i([])},[]),chatRuns:o,setChatRuns:c,stop:f,stopThread:x}}e.s(["useGroupChat",()=>s],945028);let n=new Set(["spawning","running"]);function l(e,r){let a=r?.intervalMs??1500,s=r?.idleIntervalMs??1e4,[l,i]=(0,t.useState)(new Set),[o,c]=(0,t.useState)([]),[d,u]=(0,t.useState)({}),[p,m]=(0,t.useState)([]),h=(0,t.useRef)(e);h.current=e,(0,t.useRef)(r?.messages??[]).current=r?.messages??[];let f=(0,t.useRef)(r?.setMessages);f.current=r?.setMessages;let x=(0,t.useRef)(0),g=(0,t.useRef)(new Map),y=(0,t.useRef)(new Map);(0,t.useEffect)(()=>{let e=r?.messages??[];if(e.length>0){let t=Math.max(...e.map(e=>e.timestamp));t>x.current&&(x.current=t)}},[r?.messages]),(0,t.useEffect)(()=>()=>{for(let e of g.current.values())e.close();g.current.clear()},[]);let v=(0,t.useCallback)(async()=>{let e=h.current;if(!e){i(new Set),c([]),u({}),m([]);return}let t=null;if(e.threadId?t=`/api/processes?threadId=${encodeURIComponent(e.threadId)}`:e.workspaceId&&(t=`/api/processes?workspaceId=${encodeURIComponent(e.workspaceId)}`),!t){i(new Set),c([]),u({}),m([]);return}try{let a=e.workspaceId||e.threadId,s=a?`/api/history?threadId=${encodeURIComponent(a)}&since=${x.current}`:null,l=a?`/api/chat-runs?threadId=${encodeURIComponent(a)}&limit=20`:null,o=[fetch(t)];s&&o.push(fetch(s)),l&&o.push(fetch(l));let[d,u,p]=await Promise.all(o),g=h.current;if(g?.threadId!==e.threadId||g?.workspaceId!==e.workspaceId)return;if(d.ok){let e=await d.json();c(e);let t=new Set(e.filter(e=>n.has(e.state)).map(e=>e.agentId));i(t)}if(p?.ok){var r;let e=(r=await p.json(),Array.isArray(r)?r.map(e=>{if(!e||"object"!=typeof e)return null;let t="string"==typeof e.chatRunId?e.chatRunId:"string"==typeof e.id?e.id:null,r="string"==typeof e.threadId?e.threadId:null,a="string"==typeof e.status?e.status:null,s="string"==typeof e.rootMessageId?e.rootMessageId:(e.rootMessageId,null);return t&&r&&a&&("queued"===a||"running"===a||"awaiting_user"===a||"blocked"===a||"completed"===a||"failed"===a||"cancelled"===a)?{chatRunId:t,threadId:r,rootMessageId:s,status:a,optimistic:!1}:null}).filter(e=>!!e):[]);m(e)}if(u?.ok&&f.current){let e=await u.json();if(e.length>0){let t=Math.max(...e.map(e=>e.timestamp));t>x.current&&(x.current=t),f.current(t=>{let r=new Set(t.map(e=>e.id)),a=e.filter(e=>!r.has(e.id)),s=t.map(t=>e.find(e=>e.id===t.id)??t);return 0===a.length?s:[...s,...a].sort((e,t)=>e.timestamp-t.timestamp)})}}}catch{}},[]);(0,t.useEffect)(()=>{let e=p.filter(e=>"queued"===e.status||"running"===e.status),t=new Set(e.map(e=>e.chatRunId));for(let[e,r]of g.current.entries())t.has(e)||(r.close(),g.current.delete(e),y.current.delete(e));for(let t of e){if(g.current.has(t.chatRunId))continue;let e=new EventSource(`/api/chat-runs/${encodeURIComponent(t.chatRunId)}/events`);g.current.set(t.chatRunId,e);let r=new Map;y.current.set(t.chatRunId,r);let a=new Set;e.addEventListener("chat",s=>{let n;try{n=JSON.parse(s.data)}catch{return}switch(n.type){case"participant-start":case"participant-thinking":a.add(n.participantId),r.has(n.participantId)||r.set(n.participantId,{text:"",thoughts:[]}),u(e=>e[n.participantId]?e:{...e,[n.participantId]:{content:"",rootMessageId:t.rootMessageId??null}});break;case"text-delta":{r.has(n.participantId)||r.set(n.participantId,{text:"",thoughts:[]});let e=r.get(n.participantId);e&&(e.text+=n.delta,u(r=>{let a={...r},s=t.rootMessageId??null;return a[n.participantId]={content:e.text,rootMessageId:s},a}));break}case"participant-thought":{let e=r.get(n.participantId);e&&(e.thoughts.push(n.content),u(t=>{let r=t[n.participantId];return r?{...t,[n.participantId]:{...r,thoughts:[...e.thoughts]}}:t}));break}case"participant-end":a.delete(n.participantId),v().then(()=>{u(e=>{let t={...e};return delete t[n.participantId],t})});break;case"participant-error":a.delete(n.participantId),v().then(()=>{u(e=>{let t={...e};return delete t[n.participantId],t})});break;case"done":e.close(),g.current.delete(t.chatRunId),y.current.delete(t.chatRunId)}}),e.onerror=()=>{e.close(),g.current.delete(t.chatRunId),y.current.delete(t.chatRunId)}}},[p]);let b=e?.threadId||e?.workspaceId||null,j=p.some(e=>"queued"===e.status||"running"===e.status),w=o.some(e=>n.has(e.state)),k=j||w?a:s;return(0,t.useEffect)(()=>{if(!b){i(new Set),c([]),u({}),m([]);return}v();let e=setInterval(v,k);return()=>clearInterval(e)},[b,k,v]),{activeAgents:l,processes:o,streaming:d,chatRuns:p,poll:v}}e.s(["useProcessPolling",()=>l],490011)},640481,e=>{"use strict";let t=(0,e.i(363732).default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);e.s(["Pencil",()=>t],640481)},558201,e=>{"use strict";let t=(0,e.i(363732).default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);e.s(["Terminal",()=>t],558201)},781873,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"BailoutToCSR",{enumerable:!0,get:function(){return s}});let a=e.r(804984);function s({reason:e,children:t}){if("u"<typeof window)throw Object.defineProperty(new a.BailoutToCSRError(e),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return t}},373512,(e,t,r)=>{"use strict";function a(e){return e.split("/").map(e=>encodeURIComponent(e)).join("/")}Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"encodeURIPath",{enumerable:!0,get:function(){return a}})},974052,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"PreloadChunks",{enumerable:!0,get:function(){return o}});let a=e.r(762281),s=e.r(866389),n=e.r(721014),l=e.r(373512),i=e.r(162998);function o({moduleIds:e}){if("u">typeof window)return null;let t=n.workAsyncStorage.getStore();if(void 0===t)return null;let r=[];if(t.reactLoadableManifest&&e){let a=t.reactLoadableManifest;for(let t of e){if(!a[t])continue;let e=a[t].files;r.push(...e)}}if(0===r.length)return null;let o=(0,i.getDeploymentIdQueryOrEmptyString)();return(0,a.jsx)(a.Fragment,{children:r.map(e=>{let r=`${t.assetPrefix}/_next/${(0,l.encodeURIPath)(e)}${o}`;return e.endsWith(".css")?(0,a.jsx)("link",{precedence:"dynamic",href:r,rel:"stylesheet",as:"style",nonce:t.nonce},e):((0,s.preload)(r,{as:"script",fetchPriority:"low",nonce:t.nonce}),null)})})}},184790,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"default",{enumerable:!0,get:function(){return c}});let a=e.r(762281),s=e.r(935851),n=e.r(781873),l=e.r(974052);function i(e){return{default:e&&"default"in e?e.default:e}}let o={loader:()=>Promise.resolve(i(()=>null)),loading:null,ssr:!0},c=function(e){let t={...o,...e},r=(0,s.lazy)(()=>t.loader().then(i)),c=t.loading;function d(e){let i=c?(0,a.jsx)(c,{isLoading:!0,pastDelay:!0,error:null}):null,o=!t.ssr||!!t.loading,d=o?s.Suspense:s.Fragment,u=t.ssr?(0,a.jsxs)(a.Fragment,{children:["u"<typeof window?(0,a.jsx)(l.PreloadChunks,{moduleIds:t.modules}):null,(0,a.jsx)(r,{...e})]}):(0,a.jsx)(n.BailoutToCSR,{reason:"next/dynamic",children:(0,a.jsx)(r,{...e})});return(0,a.jsx)(d,{...o?{fallback:i}:{},children:u})}return d.displayName="LoadableComponent",d}},353899,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"default",{enumerable:!0,get:function(){return s}});let a=e.r(555682)._(e.r(184790));function s(e,t){let r={};"function"==typeof e&&(r.loader=e);let s={...r,...t};return(0,a.default)({...s,modules:s.loadableGenerated?.modules})}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},245110,e=>{"use strict";let t=(0,e.i(363732).default)("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);e.s(["ExternalLink",()=>t],245110)},257587,e=>{"use strict";let t=(0,e.i(363732).default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);e.s(["Settings",()=>t],257587)},459073,e=>{"use strict";let t=(0,e.i(363732).default)("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);e.s(["FolderPlus",()=>t],459073)},693646,e=>{"use strict";let t=(0,e.i(363732).default)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);e.s(["Save",()=>t],693646)},509501,e=>{"use strict";var t=e.i(935851);function r(e,r){let[a,s]=(0,t.useState)([]),[n,l]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{let t=!1;return async function(){try{let a=await fetch("/api/participants"),n=a.ok?await a.json():[];if(!r){t||(s(n),l(!0));return}let i=new URLSearchParams;i.set("projectId",r);let o=await fetch(`/api/trackers/${encodeURIComponent(e)}/worker?${i}`).catch(()=>null),c=o?.ok?await o.json().catch(()=>null):null,d=c?.job?.teamId||void 0;if(d){let e=await fetch(`/api/projects/${encodeURIComponent(r)}/teams/${encodeURIComponent(d)}/agents`);if(e.ok){let r=await e.json(),a=Array.isArray(r.agents)?r.agents.sort((e,t)=>(e.routing_order??0)-(t.routing_order??0)).map(e=>e.agent_id).filter(e=>"string"==typeof e&&e.trim().length>0):[];if(a.length>0){let e=new Map(a.map((e,t)=>[e,t])),r=n.filter(t=>e.has(t.id)).sort((t,r)=>(e.get(t.id)??Number.MAX_SAFE_INTEGER)-(e.get(r.id)??Number.MAX_SAFE_INTEGER));if(!t&&r.length>0){s(r),l(!0);return}}}}let u=await fetch(`/api/projects/${encodeURIComponent(r)}/agents`);if(!u.ok){t||(s(n),l(!0));return}let p=await u.json(),m=Array.isArray(p.agents)?p.agents.map(e=>e.agent_id).filter(e=>"string"==typeof e&&e.trim().length>0):[],h=new Map(m.map((e,t)=>[e,t])),f=n.filter(e=>h.has(e.id)).sort((e,t)=>(h.get(e.id)??Number.MAX_SAFE_INTEGER)-(h.get(t.id)??Number.MAX_SAFE_INTEGER));t||(s(f),l(!0))}catch{t||(s([]),l(!0))}}(),()=>{t=!0}},[e,r]),{participants:a,participantsLoaded:n}}e.s(["useTrackerParticipants",()=>r])},807087,e=>{"use strict";let t=(0,e.i(363732).default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);e.s(["CheckCircle2",()=>t],807087)},287472,e=>{"use strict";var t=e.i(935851);let r=new Map;function a(e){let t=r.get(e);return t?Date.now()-t.ts>3e5?(r.delete(e),null):t:null}function s(e){r.delete(e)}function n(e,n){let[l,i]=(0,t.useState)(!1),[o,c]=(0,t.useState)(!0),[d,u]=(0,t.useState)(null),[p,m]=(0,t.useState)({claude:!1,codex:!1,gemini:!1}),[h,f]=(0,t.useState)({}),x=(0,t.useRef)(null),g=`/api/trackers/${encodeURIComponent(e)}`,y=`${e}:${n}`,v=(0,t.useCallback)(async()=>{try{let e=await fetch(`${g}/mcp-setup`),t=await e.json();f(t.configured??{})}catch{}},[g]),b=(0,t.useCallback)(async()=>{if(!n)return i(!1),!1;let e=a(y);if(e)return i(e.connected),u(e.user),m(e.clis),f(e.mcpConfigured),c(!1),e.connected;try{var t;let e=`?projectId=${encodeURIComponent(n)}`,[a,s]=await Promise.all([fetch(`${g}/status${e}`),fetch(`${g}/mcp-setup`)]),l=await a.json(),o=await s.json(),c=l.clis??{claude:!1,codex:!1,gemini:!1},d=o.configured??{},p=l.user??null;return i(l.connected),u(p),m(c),f(d),t={connected:l.connected,user:p,clis:c,mcpConfigured:d},r.set(y,{...t,ts:Date.now()}),l.connected}catch{return i(!1),!1}finally{c(!1)}},[n,g,y]);(0,t.useEffect)(()=>{let e=a(y);e?(i(e.connected),u(e.user),m(e.clis),f(e.mcpConfigured),c(!1)):(c(!0),i(!1),u(null))},[e,n,y]),(0,t.useEffect)(()=>(b(),()=>{x.current&&clearInterval(x.current)}),[b]);let j=(0,t.useCallback)(()=>{n&&(s(y),window.open(`${g}/auth?projectId=${encodeURIComponent(n)}`,"_blank","noopener"),x.current&&clearInterval(x.current),x.current=setInterval(async()=>{s(y),await b()&&x.current&&(clearInterval(x.current),x.current=null)},2e3))},[n,g,y,b]),w=(0,t.useCallback)(async e=>{if(!n)return{ok:!1,error:"Missing projectId"};try{let t=await fetch(`${g}/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:n,accessToken:e})});if(!t.ok){let e=await t.json().catch(()=>({}));return{ok:!1,error:e.error||"Failed to save token"}}return s(y),await b(),{ok:!0}}catch{return{ok:!1,error:"Failed to connect"}}},[n,g,y,b]);return{connected:l,loading:o,user:d,clis:p,mcpConfigured:h,connect:j,connectWithKey:w,disconnect:(0,t.useCallback)(async()=>{n&&(s(y),await fetch(`${g}/status?projectId=${encodeURIComponent(n)}`,{method:"DELETE"}),"github"===e&&Object.keys(sessionStorage).filter(e=>e.startsWith("github_")).forEach(e=>sessionStorage.removeItem(e)),i(!1),u(null))},[n,g,y,e]),configureMcp:(0,t.useCallback)(async e=>{try{let t=await fetch(`${g}/mcp-setup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cli:e})});if(!t.ok){let e=await t.json().catch(()=>({}));return{ok:!1,error:e.error||"Failed to configure MCP"}}return await v(),{ok:!0}}catch{return{ok:!1,error:"Failed to configure MCP"}}},[g,v]),refresh:b}}e.s(["useTrackerConnection",()=>n])},637790,166735,e=>{"use strict";var t=e.i(363732);let r=(0,t.default)("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);e.s(["Key",()=>r],637790);let a=(0,t.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);e.s(["Globe",()=>a],166735)},711190,e=>{"use strict";let t=(0,e.i(363732).default)("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]);e.s(["LogOut",()=>t],711190)},202192,457242,e=>{"use strict";var t=e.i(762281),r=e.i(935851),a=e.i(807087),s=e.i(637790),n=e.i(166735),l=e.i(906724),i=e.i(741746),o=e.i(558201),c=e.i(711190),d=e.i(681619),u=e.i(929870),p=e.i(797167),m=e.i(203096);let h=(0,e.i(363732).default)("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);function f({projectId:e}){let[a,s]=(0,r.useState)([]),[n,i]=(0,r.useState)(!0),[o,c]=(0,r.useState)(null),[d,f]=(0,r.useState)(null),[x,g]=(0,r.useState)(!1),[y,v]=(0,r.useState)([]),[b,j]=(0,r.useState)(!1),[w,k]=(0,r.useState)(null),[N,C]=(0,r.useState)(""),[I,S]=(0,r.useState)("all"),[M,R]=(0,r.useState)(new Set),[P,E]=(0,r.useState)(!1),$=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/github/repos",{cache:"no-store"});if(!e.ok)throw Error("Failed to load repos");let t=await e.json();s(t.repos??[]),c(null)}catch{c("Failed to load repositories")}finally{i(!1)}},[]);(0,r.useEffect)(()=>{$()},[$]);let L=(0,r.useCallback)((e,t)=>`${e}/${t}`.toLowerCase(),[]),A=(0,r.useMemo)(()=>new Set(a.map(e=>L(e.owner,e.name))),[a,L]),T=(0,r.useCallback)(async()=>{if(g(!0),R(new Set),C(""),S("all"),!(y.length>0)){j(!0),k(null);try{let t=await fetch(`/api/github/user-repos?projectId=${encodeURIComponent(e)}`,{cache:"no-store"});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e?.error??"Failed to fetch repos")}let r=await t.json();v(r.repos??[])}catch(e){k(e instanceof Error?e.message:"Failed to fetch repos")}finally{j(!1)}}},[e,y.length]),O=()=>{g(!1)};(0,r.useEffect)(()=>{if(!x)return;let e=e=>{"Escape"===e.key&&O()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x]);let _=(0,r.useMemo)(()=>{let e=[],t=[];for(let r of y)A.has(L(r.owner,r.name))?e.push(r):t.push(r);return[...e,...t]},[y,A,L]),U=(0,r.useMemo)(()=>{let e=N.trim().toLowerCase();return _.filter(t=>("public"!==I||!t.private)&&("private"!==I||!!t.private)&&(!e||t.fullName.toLowerCase().includes(e)||(t.description??"").toLowerCase().includes(e)))},[_,N,I]),z=(0,r.useMemo)(()=>U.filter(e=>!A.has(L(e.owner,e.name))),[U,A,L]),F=z.length>0&&z.every(e=>M.has(e.id)),D=async()=>{if(0!==M.size){E(!0);try{let e=y.filter(e=>M.has(e.id));await Promise.all(e.map(e=>fetch("/api/github/repos",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({owner:e.owner,name:e.name,defaultBranch:e.defaultBranch,private:e.private})}))),await $(),O()}finally{E(!1)}}},q=(0,r.useCallback)(async e=>{f(e);try{await fetch("/api/github/repos",{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({id:e})}),await $()}finally{f(null)}},[$]);return(0,t.jsxs)("div",{className:"w-full max-w-md space-y-4",children:[(0,t.jsxs)("div",{className:"border rounded-xl p-5 flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{className:"text-sm font-medium",children:"Attached repositories"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Repos the local agent watches for PRs, reviews, and comments."})]}),(0,t.jsxs)("button",{type:"button",onClick:T,className:"text-xs px-2.5 py-1.5 rounded border hover:bg-accent inline-flex items-center gap-1",children:[(0,t.jsx)(u.Plus,{className:"w-3.5 h-3.5"}),"Add"]})]}),n?(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(l.Loader2,{className:"w-4 h-4 animate-spin"}),"Loading repositories…"]}):o?(0,t.jsx)("p",{className:"text-sm text-destructive",children:o}):0===a.length?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No repositories attached yet."}):(0,t.jsx)("ul",{className:"divide-y",children:a.map(e=>(0,t.jsxs)("li",{className:"flex items-center justify-between py-2",children:[(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsxs)("span",{className:"text-sm font-mono",children:[e.owner,"/",e.name]}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:[e.defaultBranch??"no default branch",e.private?" · private":" · public",e.accessRevoked?" · access revoked":""]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>q(e.id),disabled:d===e.id,className:"p-1.5 rounded hover:bg-accent disabled:opacity-50",title:"Remove",children:(0,t.jsx)(p.X,{className:"w-3.5 h-3.5"})})]},e.id))})]}),(0,t.jsxs)("div",{className:"border rounded-xl p-5 flex items-center justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{className:"text-sm font-medium",children:"Sync"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Pull the latest PRs, reviews, and comments for attached repos."})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>alert("Sync will run when worker is scheduled"),className:"text-xs px-3 py-1.5 rounded border hover:bg-accent inline-flex items-center gap-1.5",children:[(0,t.jsx)(m.RefreshCw,{className:"w-3.5 h-3.5"}),"Sync now"]})]}),x&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:O,children:(0,t.jsxs)("div",{className:"w-full max-w-3xl max-h-[90vh] flex flex-col rounded-xl border border-[var(--border)] bg-[var(--background)] text-[var(--foreground)] shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)("header",{className:"px-6 py-5 border-b border-[var(--border)] flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-[var(--muted-foreground)] mb-1",children:[(0,t.jsx)("span",{children:"GitHub"}),(0,t.jsx)("span",{children:"·"}),(0,t.jsx)("span",{children:"Attach repositories"})]}),(0,t.jsx)("h1",{className:"text-xl font-semibold tracking-tight",children:"Select repositories"}),(0,t.jsx)("p",{className:"text-sm text-[var(--muted-foreground)] mt-1",children:"Pick the repos you want agx to track. Already-attached repos are pinned at the top."})]}),(0,t.jsx)("button",{onClick:O,className:"p-1.5 rounded hover:bg-[var(--item-hover-bg)] text-[var(--muted-foreground)]","aria-label":"Close",children:(0,t.jsx)(p.X,{className:"w-4 h-4"})})]}),(0,t.jsx)("div",{className:"px-6 py-4 flex-1 overflow-hidden flex flex-col",children:w?(0,t.jsx)("div",{className:"rounded-lg border border-[var(--status-failed-border)] bg-[var(--status-failed-bg)] text-[var(--status-failed)] px-4 py-3 text-sm",children:w}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 mb-3",children:[(0,t.jsxs)("div",{className:"relative flex-1",children:[(0,t.jsxs)("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--muted-foreground)]",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,t.jsx)("path",{d:"m21 21-4.3-4.3"})]}),(0,t.jsx)("input",{type:"text",value:N,onChange:e=>C(e.target.value),placeholder:"Search repositories...",className:"w-full pl-9 pr-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--input)] text-sm focus:outline-none focus:border-[var(--primary)] focus:bg-[var(--input-focus)] transition-colors"})]}),(0,t.jsx)("div",{className:"flex gap-1 rounded-lg border border-[var(--border)] p-1",children:["all","public","private"].map(e=>(0,t.jsx)("button",{onClick:()=>S(e),className:`px-3 py-1 text-xs rounded-md capitalize transition-colors ${I===e?"bg-[var(--primary)] text-[var(--primary-foreground)]":"text-[var(--muted-foreground)] hover:text-[var(--foreground)]"}`,children:e},e))})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2 text-xs text-[var(--muted-foreground)]",children:[(0,t.jsxs)("button",{onClick:()=>{R(e=>{let t=new Set(e);return F?z.forEach(e=>t.delete(e.id)):z.forEach(e=>t.add(e.id)),t})},disabled:0===z.length,className:"hover:text-[var(--foreground)] transition-colors disabled:opacity-50",children:[F?"Deselect all":"Select all",N||"all"!==I?` (${z.length} shown)`:""]}),M.size>0&&(0,t.jsx)("button",{onClick:()=>R(new Set),className:"hover:text-[var(--foreground)] transition-colors",children:"Clear selection"})]}),(0,t.jsx)("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--card-bg)] overflow-hidden flex-1 min-h-0",children:(0,t.jsx)("div",{className:"h-full overflow-y-auto",children:b?(0,t.jsx)("div",{className:"divide-y divide-[var(--border)]",children:Array.from({length:6}).map((e,r)=>(0,t.jsxs)("div",{className:"px-4 py-3 flex items-center gap-3 animate-pulse",children:[(0,t.jsx)("div",{className:"w-4 h-4 rounded bg-[var(--muted)]"}),(0,t.jsx)("div",{className:"w-6 h-6 rounded-full bg-[var(--muted)]"}),(0,t.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,t.jsx)("div",{className:"h-3 w-1/3 rounded bg-[var(--muted)]"}),(0,t.jsx)("div",{className:"h-2 w-2/3 rounded bg-[var(--muted)]"})]})]},r))}):0===U.length?(0,t.jsx)("div",{className:"px-4 py-10 text-center text-sm text-[var(--muted-foreground)]",children:0===y.length?"No repositories found on your account.":"No repos match your search."}):(0,t.jsx)("ul",{className:"divide-y divide-[var(--border)]",children:U.map(e=>{let r=A.has(L(e.owner,e.name)),a=M.has(e.id);return(0,t.jsx)("li",{children:(0,t.jsxs)("label",{className:`flex items-start gap-3 px-4 py-3 transition-colors ${r?"bg-[var(--primary-muted)]/40 cursor-default":a?"bg-[var(--primary-muted)] cursor-pointer":"hover:bg-[var(--item-hover-bg)] cursor-pointer"}`,children:[r?(0,t.jsx)("div",{className:"mt-1 w-4 h-4 rounded-sm bg-[var(--primary)]/20 text-[var(--primary)] flex items-center justify-center",title:"Already attached",children:(0,t.jsx)(h,{className:"w-2.5 h-2.5"})}):(0,t.jsx)("input",{type:"checkbox",checked:a,onChange:()=>{!A.has(L(e.owner,e.name))&&R(t=>{let r=new Set(t);return r.has(e.id)?r.delete(e.id):r.add(e.id),r})},className:"mt-1 accent-[var(--primary)]"}),(0,t.jsx)("img",{src:e.avatarUrl,alt:"",className:"w-6 h-6 rounded-full mt-0.5 flex-shrink-0"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)("span",{className:"text-sm font-medium truncate",children:e.fullName}),r&&(0,t.jsxs)("span",{className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded bg-[var(--primary)]/15 text-[var(--primary)] flex items-center gap-1",children:[(0,t.jsx)(h,{className:"w-2.5 h-2.5"}),"Attached"]}),e.private&&(0,t.jsx)("span",{className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded bg-[var(--muted)] text-[var(--muted-foreground)]",children:"Private"})]}),e.description&&(0,t.jsx)("p",{className:"text-xs text-[var(--muted-foreground)] mt-0.5 line-clamp-1",children:e.description}),(0,t.jsxs)("div",{className:"text-[11px] text-[var(--muted-foreground)] mt-0.5",children:["Updated ",function(e){let t=Math.floor((Date.now()-new Date(e).getTime())/1e3);if(t<60)return"just now";let r=Math.floor(t/60);if(r<60)return`${r}m ago`;let a=Math.floor(r/60);if(a<24)return`${a}h ago`;let s=Math.floor(a/24);if(s<30)return`${s}d ago`;let n=Math.floor(s/30);return n<12?`${n}mo ago`:`${Math.floor(n/12)}y ago`}(e.updatedAt)]})]})]})},e.id)})})})})]})}),(0,t.jsxs)("footer",{className:"px-6 py-4 border-t border-[var(--border)] flex items-center justify-between gap-3",children:[(0,t.jsxs)("span",{className:"text-sm text-[var(--muted-foreground)]",children:[M.size," selected"]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{onClick:O,className:"px-4 py-2 rounded-lg border border-[var(--border)] hover:bg-[var(--item-hover-bg)] text-sm font-medium transition-colors",children:"Cancel"}),(0,t.jsx)("button",{onClick:D,disabled:0===M.size||P,className:"px-4 py-2 rounded-lg bg-[var(--primary)] hover:bg-[var(--primary-hover)] text-[var(--primary-foreground)] text-sm font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:P?"Attaching...":`Attach ${M.size} ${1===M.size?"repo":"repos"}`})]})]})]})})]})}e.s(["Pin",()=>h],457242);var x=e.i(352687);let g={claude:{name:"Claude Code",configPath:"~/.claude/settings.json"},codex:{name:"Codex CLI",configPath:"~/.codex/config.toml"},gemini:{name:"Gemini CLI",configPath:"~/.gemini/settings.json"}};function y({trackerType:e,projectId:u,connected:p,onConnect:m,onConnectWithKey:h,onDisconnect:y,loading:v=!1,clis:b,mcpConfigured:j,onConfigureMcp:w}){let[k,N]=r.default.useState(""),[C,I]=r.default.useState(null),[S,M]=r.default.useState(!1),[R,P]=r.default.useState(!1),[E,$]=r.default.useState(null),[L,A]=r.default.useState({}),[T,O]=r.default.useState(!1),_=async e=>{if(!w)return;$(e),A(t=>({...t,[e]:""}));let t=await w(e);t.ok||A(r=>({...r,[e]:t.error??"Failed to install MCP"})),$(null)},U=b?["claude","codex","gemini"].filter(e=>b[e]):["claude"];if(v)return(0,t.jsx)("div",{className:"flex items-center justify-center p-12",children:(0,t.jsx)(l.Loader2,{className:"animate-spin h-8 w-8 text-muted-foreground"})});if(p)return(0,t.jsxs)("div",{className:"p-8 flex flex-col items-center gap-6",children:[(0,t.jsxs)("div",{className:"w-full max-w-md p-8 border border-green-500/20 bg-green-500/5 rounded-2xl flex flex-col items-center gap-4 text-center",children:[(0,t.jsx)("div",{className:"h-16 w-16 rounded-full bg-green-500/10 flex items-center justify-center text-green-600 shadow-inner",children:(0,t.jsx)(a.CheckCircle2,{className:"h-8 w-8"})}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("h3",{className:"text-xl font-bold text-foreground capitalize",children:[e," Connected"]}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground leading-relaxed",children:["Your ",e," workspace is successfully connected. The agent can now sync issues and manage your backlog."]})]}),(0,t.jsxs)("div",{className:"mt-2 px-4 py-1.5 rounded-full bg-background border text-xs font-medium text-muted-foreground flex items-center gap-2",children:[(0,t.jsx)("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500 animate-pulse"}),"Active Connection"]}),y&&(0,t.jsxs)("button",{onClick:()=>O(!0),className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-destructive transition-colors mt-1",children:[(0,t.jsx)(c.LogOut,{className:"h-3.5 w-3.5"}),"Disconnect"]})]}),"github"===e&&(0,t.jsx)(f,{projectId:u}),y&&(0,t.jsx)(x.default,{isOpen:T,title:`Disconnect ${e}?`,message:"github"===e?"This revokes the stored credentials. Your attached repositories and synced history stay — reconnecting will resume where you left off.":`This revokes the stored credentials for ${e}. Project settings and synced history stay.`,confirmLabel:"Disconnect",cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{O(!1),y()},onCancel:()=>O(!1)}),"github"!==e&&U.length>0&&(0,t.jsx)("div",{className:"w-full max-w-md",children:(0,t.jsxs)("div",{className:"border rounded-xl p-5 flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(o.Terminal,{className:"h-4 w-4 text-muted-foreground"}),(0,t.jsx)("span",{className:"text-sm font-medium",children:"MCP Server"})]}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground leading-relaxed -mt-2",children:["Install the ",e," MCP server so agents can access ",e," directly."]}),U.map(e=>{let r=g[e],s=j?.[e]??!1,n=E===e,o=L[e];return(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-foreground",children:r.name}),s?(0,t.jsxs)("span",{className:"text-xs font-medium text-green-600 flex items-center gap-1",children:[(0,t.jsx)(a.CheckCircle2,{className:"h-3.5 w-3.5"}),"Installed"]}):(0,t.jsx)("button",{onClick:()=>_(e),disabled:n||!w,className:"flex items-center gap-1.5 px-3 py-1 bg-secondary text-secondary-foreground rounded-md text-xs font-semibold hover:bg-secondary/90 disabled:opacity-50 transition-all active:scale-[0.98]",children:n?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(l.Loader2,{className:"h-3 w-3 animate-spin"}),"Installing…"]}):(0,t.jsx)(t.Fragment,{children:"Install"})})]}),s&&(0,t.jsxs)("p",{className:"text-[10px] text-muted-foreground",children:["Configured in ",(0,t.jsx)("code",{className:"font-mono",children:r.configPath})]}),o&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-destructive bg-destructive/10 p-2 rounded-md",children:[(0,t.jsx)(i.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),o]})]},e)})]})})]});let z=async()=>{if(k.trim()){P(!0),I(null);try{let e=await h(k.trim());e.ok?(N(""),M(!1)):I(e.error??"Failed to connect")}catch(e){I("An unexpected error occurred")}finally{P(!1)}}};return(0,t.jsxs)("div",{className:"flex flex-col items-center gap-6 p-8",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(d.TrackerIcon,{trackerType:e,className:"h-16 w-16"}),(0,t.jsx)("div",{className:"absolute -bottom-1 -right-1 h-6 w-6 rounded-full bg-background border flex items-center justify-center shadow-sm",children:(0,t.jsx)(n.Globe,{className:"h-3 w-3 text-muted-foreground"})})]}),(0,t.jsxs)("div",{className:"text-center space-y-2",children:[(0,t.jsxs)("h3",{className:"text-lg font-semibold capitalize",children:["Connect to ",e]}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground text-center max-w-sm leading-relaxed",children:["Link your ",e," account to import issues, track progress, and automate your workflow."]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 w-full max-w-xs pt-2",children:[(0,t.jsxs)("button",{onClick:m,className:"flex items-center justify-center gap-2 w-full px-4 py-2.5 bg-primary text-primary-foreground rounded-lg text-sm font-semibold hover:bg-primary/90 transition-all active:scale-[0.98] shadow-sm",children:[(0,t.jsx)(n.Globe,{className:"h-4 w-4"}),"Connect with OAuth"]}),(0,t.jsxs)("button",{onClick:()=>{M(!S),I(null)},className:"flex items-center justify-center gap-2 w-full px-4 py-2 text-sm text-muted-foreground hover:text-foreground transition-colors font-medium",children:[(0,t.jsx)(s.Key,{className:"h-3.5 w-3.5"}),S?"Use OAuth instead":"github"===e?"Connect with Personal Access Token":"Connect with API key"]}),(0,t.jsx)("div",{className:`grid transition-all duration-300 ease-in-out ${S?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0 pointer-events-none"}`,children:(0,t.jsx)("div",{className:"overflow-hidden",children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 pt-2",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"password",value:k,onChange:e=>{N(e.target.value),C&&I(null)},placeholder:"github"===e?"ghp_… or github_pat_…":"Paste your API key here",className:`w-full px-3 py-2 border rounded-lg text-sm bg-background transition-colors focus:outline-none focus:ring-2 focus:ring-primary/20 ${C?"border-destructive":"focus:border-primary"}`,onKeyDown:e=>"Enter"===e.key&&z()}),(0,t.jsx)(s.Key,{className:"absolute right-3 top-2.5 h-4 w-4 text-muted-foreground/50"})]}),C&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-destructive bg-destructive/10 p-2 rounded-md",children:[(0,t.jsx)(i.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("p",{children:C})]}),(0,t.jsx)("button",{onClick:z,disabled:R||!k.trim(),className:"flex items-center justify-center gap-2 w-full px-4 py-2 bg-secondary text-secondary-foreground rounded-lg text-sm font-semibold hover:bg-secondary/90 disabled:opacity-50 transition-all active:scale-[0.98]",children:R?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(l.Loader2,{className:"h-4 w-4 animate-spin"}),"Connecting..."]}):"Verify & Connect"}),(0,t.jsx)("p",{className:"text-[10px] text-muted-foreground text-center px-2",children:"github"===e?"Fine-grained PAT recommended. Needs repo access + read on issues/pull requests.":`Your API key is stored securely and only used for ${e} integration.`})]})})})]})]})}e.s(["default",()=>y],202192)},427877,e=>{"use strict";var t=e.i(762281),r=e.i(935851),a=e.i(506420),s=e.i(524123),n=e.i(471387);function l({params:e}){let{slug:l,tracker:i}=(0,r.use)(e),o=(0,a.useSearchParams)(),{projects:c}=(0,s.useProjects)(),d=c.find(e=>e.slug===l),u="true"===o.get("settings"),p="github"===i?o.get("repo"):null;return(0,r.useEffect)(()=>{"github"===i&&p&&d?.id&&fetch("/api/github/repos/sync",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectId:d.id,repoId:p})}).catch(()=>{})},[i,p,d?.id]),(0,t.jsx)(n.default,{trackerType:i,projectId:d?.id,projectSlug:d?.slug??l,initialShowSettings:u,initialGroupId:p??void 0})}e.s(["default",()=>l])},469612,e=>{e.v(t=>Promise.all(["static/chunks/256961ed1522219b.js"].map(t=>e.l(t))).then(()=>t(668610)))},501223,e=>{e.v(t=>Promise.all(["static/chunks/94f26a112344ab1b.css","static/chunks/5591af73db0a3aee.js","static/chunks/42a62b80b32a97f7.js"].map(t=>e.l(t))).then(()=>t(844118)))}]);
@@ -1 +1 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,506420,(e,t,s)=>{t.exports=e.r(27944)},279992,e=>{"use strict";var t=e.i(762281),s=e.i(935851),r=e.i(506420);function a(){let e=(0,r.useRouter)(),a=(0,r.useSearchParams)(),[o,i]=(0,s.useState)(null),[n,l]=(0,s.useState)(null),[d,c]=(0,s.useState)(null),[u,m]=(0,s.useState)(null),[g,h]=(0,s.useState)(null),[p,x]=(0,s.useState)(null),[v,f]=(0,s.useState)(null),[b,j]=(0,s.useState)([]),[y,N]=(0,s.useState)(new Set),[w,S]=(0,s.useState)(""),[_,k]=(0,s.useState)("all"),[C,I]=(0,s.useState)(!0),[$,z]=(0,s.useState)(!1),[M,P]=(0,s.useState)(null);(0,s.useEffect)(()=>{let e=a.get("access_token"),t=sessionStorage.getItem("github_token"),s=e||t;if(!s){P("Missing access token"),I(!1);return}if(e){let t=a.get("refresh_token"),s=a.get("expires_in"),r=a.get("scope"),o=a.get("session"),n=a.get("login"),d=a.get("expires_at");i(e),l(t),c(s),m(r),h(o),x(n),f(d),sessionStorage.setItem("github_token",e),t&&sessionStorage.setItem("github_refresh_token",t),s&&sessionStorage.setItem("github_expires_in",s),r&&sessionStorage.setItem("github_scope",r),o&&sessionStorage.setItem("github_session",o),n&&sessionStorage.setItem("github_login",n),d&&sessionStorage.setItem("github_expires_at",d),window.history.replaceState({},"","/integrations/github/select-repos")}else i(s),l(sessionStorage.getItem("github_refresh_token")),c(sessionStorage.getItem("github_expires_in")),m(sessionStorage.getItem("github_scope")),h(sessionStorage.getItem("github_session")),x(sessionStorage.getItem("github_login")),f(sessionStorage.getItem("github_expires_at"))},[a]),(0,s.useEffect)(()=>{o&&(async()=>{try{let e={Authorization:`token ${o}`,Accept:"application/vnd.github+json","User-Agent":"agx","X-GitHub-Api-Version":"2022-11-28"},t=[],s=1;for(;s<=10;){let r=`https://api.github.com/user/repos?per_page=100&page=${s}&visibility=all&affiliation=owner,collaborator,organization_member&sort=updated`,a=await fetch(r,{headers:e});if(!a.ok)throw Error(`Failed to fetch repos: ${a.status}`);let o=await a.json();if(t.push(...o),o.length<100)break;s++}j(t),I(!1)}catch(e){P(e instanceof Error?e.message:"Failed to fetch repos"),I(!1)}})()},[o]);let A=(0,s.useMemo)(()=>{let e=w.trim().toLowerCase();return b.filter(t=>("public"!==_||!t.private)&&("private"!==_||!!t.private)&&(!e||t.full_name.toLowerCase().includes(e)||(t.description??"").toLowerCase().includes(e)))},[b,w,_]),E=A.length>0&&A.every(e=>y.has(e.id)),T=async()=>{if(!o||0===y.size)return;z(!0);let t=b.filter(e=>y.has(e.id));try{await Promise.all(t.map(e=>fetch("/api/github/repos",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({owner:e.owner.login,name:e.name,private:e.private})})))}catch(e){P(e instanceof Error?e.message:"Failed to save repos"),z(!1);return}let s=new URLSearchParams({access_token:o,repos:t.map(e=>e.full_name).join(",")});n&&s.set("refresh_token",n),d&&s.set("expires_in",d),u&&s.set("scope",u),g&&s.set("session",g),p&&s.set("login",p),v&&s.set("expires_at",v),u&&s.set("scopes",u),e.push(`/api/trackers/github/token-receive?${s.toString()}`)};return(0,t.jsx)("div",{className:"min-h-screen bg-[var(--background)] text-[var(--foreground)]",children:(0,t.jsxs)("div",{className:"max-w-3xl mx-auto px-6 py-10",children:[(0,t.jsxs)("header",{className:"mb-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-[var(--muted-foreground)] mb-2",children:[(0,t.jsx)("span",{children:"GitHub"}),(0,t.jsx)("span",{children:"·"}),(0,t.jsx)("span",{children:"Connect"})]}),(0,t.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:"Select repositories"}),(0,t.jsx)("p",{className:"text-sm text-[var(--muted-foreground)] mt-1",children:"Pick the repos you want agx to track. You can change this later in project settings."}),u&&(0,t.jsxs)("p",{className:"text-[11px] text-[var(--muted-foreground)] mt-2 font-mono",children:["Token scopes: ",u]})]}),M?(0,t.jsx)("div",{className:"rounded-lg border border-[var(--status-failed-border)] bg-[var(--status-failed-bg)] text-[var(--status-failed)] px-4 py-3 text-sm",children:M}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 mb-3",children:[(0,t.jsxs)("div",{className:"relative flex-1",children:[(0,t.jsxs)("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--muted-foreground)]",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,t.jsx)("path",{d:"m21 21-4.3-4.3"})]}),(0,t.jsx)("input",{type:"text",value:w,onChange:e=>S(e.target.value),placeholder:"Search repositories...",className:"w-full pl-9 pr-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--input)] text-sm focus:outline-none focus:border-[var(--primary)] focus:bg-[var(--input-focus)] transition-colors"})]}),(0,t.jsx)("div",{className:"flex gap-1 rounded-lg border border-[var(--border)] p-1",children:["all","public","private"].map(e=>(0,t.jsx)("button",{onClick:()=>k(e),className:`px-3 py-1 text-xs rounded-md capitalize transition-colors ${_===e?"bg-[var(--primary)] text-[var(--primary-foreground)]":"text-[var(--muted-foreground)] hover:text-[var(--foreground)]"}`,children:e},e))})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2 text-xs text-[var(--muted-foreground)]",children:[(0,t.jsxs)("button",{onClick:()=>{N(e=>{let t=new Set(e);return E?A.forEach(e=>t.delete(e.id)):A.forEach(e=>t.add(e.id)),t})},disabled:0===A.length,className:"hover:text-[var(--foreground)] transition-colors disabled:opacity-50",children:[E?"Deselect all":"Select all",w||"all"!==_?` (${A.length} shown)`:""]}),y.size>0&&(0,t.jsx)("button",{onClick:()=>N(new Set),className:"hover:text-[var(--foreground)] transition-colors",children:"Clear selection"})]}),(0,t.jsx)("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--card-bg)] overflow-hidden",children:(0,t.jsx)("div",{className:"max-h-[60vh] overflow-y-auto",children:C?(0,t.jsx)("div",{className:"divide-y divide-[var(--border)]",children:Array.from({length:6}).map((e,s)=>(0,t.jsxs)("div",{className:"px-4 py-3 flex items-center gap-3 animate-pulse",children:[(0,t.jsx)("div",{className:"w-4 h-4 rounded bg-[var(--muted)]"}),(0,t.jsx)("div",{className:"w-6 h-6 rounded-full bg-[var(--muted)]"}),(0,t.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,t.jsx)("div",{className:"h-3 w-1/3 rounded bg-[var(--muted)]"}),(0,t.jsx)("div",{className:"h-2 w-2/3 rounded bg-[var(--muted)]"})]})]},s))}):0===A.length?(0,t.jsx)("div",{className:"px-4 py-10 text-center text-sm text-[var(--muted-foreground)]",children:0===b.length?"No repositories found on your account.":"No repos match your search."}):(0,t.jsx)("ul",{className:"divide-y divide-[var(--border)]",children:A.map(e=>{let s=y.has(e.id);return(0,t.jsx)("li",{children:(0,t.jsxs)("label",{className:`flex items-start gap-3 px-4 py-3 cursor-pointer transition-colors ${s?"bg-[var(--primary-muted)]":"hover:bg-[var(--item-hover-bg)]"}`,children:[(0,t.jsx)("input",{type:"checkbox",checked:s,onChange:()=>{var t;return t=e.id,void N(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},className:"mt-1 accent-[var(--primary)]"}),(0,t.jsx)("img",{src:e.owner.avatar_url,alt:"",className:"w-6 h-6 rounded-full mt-0.5 flex-shrink-0"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)("span",{className:"text-sm font-medium truncate",children:e.full_name}),e.private&&(0,t.jsx)("span",{className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded bg-[var(--muted)] text-[var(--muted-foreground)]",children:"Private"})]}),e.description&&(0,t.jsx)("p",{className:"text-xs text-[var(--muted-foreground)] mt-0.5 line-clamp-1",children:e.description}),(0,t.jsxs)("div",{className:"text-[11px] text-[var(--muted-foreground)] mt-0.5",children:["Updated ",function(e){let t=Math.floor((Date.now()-new Date(e).getTime())/1e3);if(t<60)return"just now";let s=Math.floor(t/60);if(s<60)return`${s}m ago`;let r=Math.floor(s/60);if(r<24)return`${r}h ago`;let a=Math.floor(r/24);if(a<30)return`${a}d ago`;let o=Math.floor(a/30);return o<12?`${o}mo ago`:`${Math.floor(o/12)}y ago`}(e.updated_at)]})]})]})},e.id)})})})}),(0,t.jsxs)("div",{className:"flex items-center justify-between mt-4",children:[(0,t.jsxs)("span",{className:"text-sm text-[var(--muted-foreground)]",children:[y.size," selected"]}),(0,t.jsx)("button",{onClick:T,disabled:0===y.size||$,className:"px-4 py-2 rounded-lg bg-[var(--primary)] hover:bg-[var(--primary-hover)] text-[var(--primary-foreground)] text-sm font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:$?"Connecting...":`Continue with ${y.size} ${1===y.size?"repo":"repos"}`})]})]})]})})}e.s(["default",()=>a])}]);
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,506420,(e,t,s)=>{t.exports=e.r(27944)},279992,e=>{"use strict";var t=e.i(762281),s=e.i(935851),r=e.i(506420);function a(){let e=(0,r.useRouter)(),a=(0,r.useSearchParams)(),[o,i]=(0,s.useState)(null),[n,l]=(0,s.useState)(null),[d,c]=(0,s.useState)(null),[u,m]=(0,s.useState)(null),[g,h]=(0,s.useState)(null),[p,x]=(0,s.useState)(null),[v,f]=(0,s.useState)(null),[b,j]=(0,s.useState)([]),[y,N]=(0,s.useState)(new Set),[w,S]=(0,s.useState)(""),[_,k]=(0,s.useState)("all"),[C,I]=(0,s.useState)(!0),[$,z]=(0,s.useState)(!1),[M,P]=(0,s.useState)(null);(0,s.useEffect)(()=>{let e=a.get("access_token"),t=sessionStorage.getItem("github_token"),s=e||t;if(!s){P("Missing access token"),I(!1);return}if(e){let t=a.get("refresh_token"),s=a.get("expires_in"),r=a.get("scope"),o=a.get("session"),n=a.get("login"),d=a.get("expires_at");i(e),l(t),c(s),m(r),h(o),x(n),f(d),sessionStorage.setItem("github_token",e),t&&sessionStorage.setItem("github_refresh_token",t),s&&sessionStorage.setItem("github_expires_in",s),r&&sessionStorage.setItem("github_scope",r),o&&sessionStorage.setItem("github_session",o),n&&sessionStorage.setItem("github_login",n),d&&sessionStorage.setItem("github_expires_at",d),window.history.replaceState({},"","/integrations/github/select-repos")}else i(s),l(sessionStorage.getItem("github_refresh_token")),c(sessionStorage.getItem("github_expires_in")),m(sessionStorage.getItem("github_scope")),h(sessionStorage.getItem("github_session")),x(sessionStorage.getItem("github_login")),f(sessionStorage.getItem("github_expires_at"))},[a]),(0,s.useEffect)(()=>{o&&(async()=>{try{let e={Authorization:`token ${o}`,Accept:"application/vnd.github+json","User-Agent":"agx","X-GitHub-Api-Version":"2022-11-28"},t=[],s=1;for(;s<=10;){let r=`https://api.github.com/user/repos?per_page=100&page=${s}&visibility=all&affiliation=owner,collaborator,organization_member&sort=updated`,a=await fetch(r,{headers:e});if(!a.ok)throw Error(`Failed to fetch repos: ${a.status}`);let o=await a.json();if(t.push(...o),o.length<100)break;s++}j(t),I(!1)}catch(e){P(e instanceof Error?e.message:"Failed to fetch repos"),I(!1)}})()},[o]);let A=(0,s.useMemo)(()=>{let e=w.trim().toLowerCase();return b.filter(t=>("public"!==_||!t.private)&&("private"!==_||!!t.private)&&(!e||t.full_name.toLowerCase().includes(e)||(t.description??"").toLowerCase().includes(e)))},[b,w,_]),E=A.length>0&&A.every(e=>y.has(e.id)),T=async()=>{if(!o||0===y.size)return;z(!0);let t=b.filter(e=>y.has(e.id));try{await Promise.all(t.map(e=>fetch("/api/github/repos",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({owner:e.owner.login,name:e.name,private:e.private})})))}catch(e){P(e instanceof Error?e.message:"Failed to save repos"),z(!1);return}let s=new URLSearchParams({access_token:o,repos:t.map(e=>e.full_name).join(",")});n&&s.set("refresh_token",n),d&&s.set("expires_in",d),u&&s.set("scope",u),g&&s.set("session",g),p&&s.set("login",p),v&&s.set("expires_at",v),u&&s.set("scopes",u),e.push(`/api/trackers/github/token-receive?${s.toString()}`)};return(0,t.jsx)("div",{className:"min-h-screen bg-[var(--background)] text-[var(--foreground)]",children:(0,t.jsxs)("div",{className:"max-w-3xl mx-auto px-6 py-10",children:[(0,t.jsxs)("header",{className:"mb-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-[var(--muted-foreground)] mb-2",children:[(0,t.jsx)("span",{children:"GitHub"}),(0,t.jsx)("span",{children:"·"}),(0,t.jsx)("span",{children:"Connect"})]}),(0,t.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:"Select repositories"}),(0,t.jsx)("p",{className:"text-sm text-[var(--muted-foreground)] mt-1",children:"Pick the repos you want agx to track. You can change this later in project settings."}),u&&(0,t.jsxs)("p",{className:"text-[11px] text-[var(--muted-foreground)] mt-2 font-mono",children:["Token scopes: ",u]})]}),M?(0,t.jsx)("div",{className:"rounded-lg border border-[var(--status-failed-border)] bg-[var(--status-failed-bg)] text-[var(--status-failed)] px-4 py-3 text-sm",children:M}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 mb-3",children:[(0,t.jsxs)("div",{className:"relative flex-1",children:[(0,t.jsxs)("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--muted-foreground)]",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,t.jsx)("path",{d:"m21 21-4.3-4.3"})]}),(0,t.jsx)("input",{type:"text",value:w,onChange:e=>S(e.target.value),placeholder:"Search repositories...",className:"w-full pl-9 pr-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--input)] text-sm focus:outline-none focus:border-[var(--primary)] focus:bg-[var(--input-focus)] transition-colors"})]}),(0,t.jsx)("div",{className:"flex gap-1 rounded-lg border border-[var(--border)] p-1",children:["all","public","private"].map(e=>(0,t.jsx)("button",{onClick:()=>k(e),className:`px-3 py-1 text-xs rounded-md capitalize transition-colors ${_===e?"bg-[var(--primary)] text-[var(--primary-foreground)]":"text-[var(--muted-foreground)] hover:text-[var(--foreground)]"}`,children:e},e))})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2 text-xs text-[var(--muted-foreground)]",children:[(0,t.jsxs)("button",{onClick:()=>{N(e=>{let t=new Set(e);return E?A.forEach(e=>t.delete(e.id)):A.forEach(e=>t.add(e.id)),t})},disabled:0===A.length,className:"hover:text-[var(--foreground)] transition-colors disabled:opacity-50",children:[E?"Deselect all":"Select all",w||"all"!==_?` (${A.length} shown)`:""]}),y.size>0&&(0,t.jsx)("button",{onClick:()=>N(new Set),className:"hover:text-[var(--foreground)] transition-colors",children:"Clear selection"})]}),(0,t.jsx)("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--card-bg)] overflow-hidden",children:(0,t.jsx)("div",{className:"max-h-[60vh] overflow-y-auto",children:C?(0,t.jsx)("div",{className:"divide-y divide-[var(--border)]",children:Array.from({length:6}).map((e,s)=>(0,t.jsxs)("div",{className:"px-4 py-3 flex items-center gap-3 animate-pulse",children:[(0,t.jsx)("div",{className:"w-4 h-4 rounded bg-[var(--muted)]"}),(0,t.jsx)("div",{className:"w-6 h-6 rounded-full bg-[var(--muted)]"}),(0,t.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,t.jsx)("div",{className:"h-3 w-1/3 rounded bg-[var(--muted)]"}),(0,t.jsx)("div",{className:"h-2 w-2/3 rounded bg-[var(--muted)]"})]})]},s))}):0===A.length?(0,t.jsx)("div",{className:"px-4 py-10 text-center text-sm text-[var(--muted-foreground)]",children:0===b.length?"No repositories found on your account.":"No repos match your search."}):(0,t.jsx)("ul",{className:"divide-y divide-[var(--border)]",children:A.map(e=>{let s=y.has(e.id);return(0,t.jsx)("li",{children:(0,t.jsxs)("label",{className:`flex items-start gap-3 px-4 py-3 cursor-pointer transition-colors ${s?"bg-[var(--primary-muted)]":"hover:bg-[var(--item-hover-bg)]"}`,children:[(0,t.jsx)("input",{type:"checkbox",checked:s,onChange:()=>{var t;return t=e.id,void N(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},className:"mt-1 accent-[var(--primary)]"}),(0,t.jsx)("img",{src:e.owner.avatar_url,alt:"",className:"w-6 h-6 rounded-full mt-0.5 flex-shrink-0"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)("span",{className:"text-sm font-medium truncate",children:e.full_name}),e.private&&(0,t.jsx)("span",{className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded bg-[var(--muted)] text-[var(--muted-foreground)]",children:"Private"})]}),e.description&&(0,t.jsx)("p",{className:"text-xs text-[var(--muted-foreground)] mt-0.5 line-clamp-1",children:e.description}),(0,t.jsxs)("div",{className:"text-[11px] text-[var(--muted-foreground)] mt-0.5",children:["Updated ",function(e){let t=Math.floor((Date.now()-new Date(e).getTime())/1e3);if(t<60)return"just now";let s=Math.floor(t/60);if(s<60)return`${s}m ago`;let r=Math.floor(s/60);if(r<24)return`${r}h ago`;let a=Math.floor(r/24);if(a<30)return`${a}d ago`;let o=Math.floor(a/30);return o<12?`${o}mo ago`:`${Math.floor(o/12)}y ago`}(e.updated_at)]})]})]})},e.id)})})})}),(0,t.jsxs)("div",{className:"flex items-center justify-between mt-4",children:[(0,t.jsxs)("span",{className:"text-sm text-[var(--muted-foreground)]",children:[y.size," selected"]}),(0,t.jsx)("button",{onClick:T,disabled:0===y.size||$,className:"px-4 py-2 rounded-lg bg-[var(--primary)] hover:bg-[var(--primary-hover)] text-[var(--primary-foreground)] text-sm font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:$?"Connecting...":`Continue with ${y.size} ${1===y.size?"repo":"repos"}`})]})]})]})})}e.s(["default",()=>a,"dynamic",0,"force-dynamic"])}]);
@@ -1,4 +1,4 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,558201,e=>{"use strict";let t=(0,e.i(363732).default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);e.s(["Terminal",()=>t],558201)},203096,e=>{"use strict";let t=(0,e.i(363732).default)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);e.s(["RefreshCw",()=>t],203096)},741746,e=>{"use strict";let t=(0,e.i(363732).default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);e.s(["AlertCircle",()=>t],741746)},352687,e=>{"use strict";var t=e.i(762281),s=e.i(935851);function r({isOpen:e,title:r,message:a,preview:l,confirmLabel:n="Confirm",cancelLabel:i="Cancel",variant:c="default",onConfirm:o,onCancel:d}){let u=(0,s.useRef)(null),x=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(e){let e=setTimeout(()=>u.current?.focus(),50);return()=>clearTimeout(e)}},[e]);let m=(0,s.useCallback)(e=>{"Escape"===e.key&&d()},[d]);if(!e)return null;let h="danger"===c;return(0,t.jsxs)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/50 backdrop-blur-md",style:{animation:"confirm-overlay-in 200ms ease-out"},onClick:e=>e.target===e.currentTarget&&d(),onKeyDown:m,children:[(0,t.jsxs)("div",{ref:x,className:"w-full max-w-md mx-4 bg-[var(--card-bg)] rounded-2xl border border-[var(--card-border)] shadow-2xl overflow-hidden",style:{animation:"confirm-dialog-in 250ms cubic-bezier(0.34, 1.56, 0.64, 1)"},children:[(0,t.jsx)("div",{className:"px-6 pt-6 pb-3",children:(0,t.jsxs)("div",{className:"flex items-start gap-4",children:[h&&(0,t.jsx)("div",{className:"flex-shrink-0 w-11 h-11 rounded-full bg-red-500/10 border border-red-500/20 flex items-center justify-center",children:(0,t.jsx)("svg",{className:"w-5 h-5 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("h3",{className:"text-[15px] font-semibold text-[var(--foreground)]",children:r}),(0,t.jsx)("p",{className:"mt-1 text-[13px] text-[var(--muted-foreground)] leading-relaxed",children:a})]})]})}),l&&(0,t.jsx)("div",{className:"mx-6 mb-3 px-3 py-2.5 rounded-lg bg-[var(--muted)]/40 border border-[var(--card-border)]",children:(0,t.jsxs)("p",{className:"text-[12px] text-[var(--muted-foreground)] line-clamp-3 leading-relaxed italic",children:["“",l,"”"]})}),(0,t.jsx)("div",{className:"mx-6 border-t border-[var(--card-border)]"}),(0,t.jsxs)("div",{className:"px-6 py-4 flex items-center justify-end gap-2.5",children:[(0,t.jsx)("button",{onClick:d,className:"px-4 py-2 rounded-lg text-[13px] font-medium text-[var(--muted-foreground)] hover:text-[var(--foreground)] hover:bg-[var(--muted)]/60 transition-all duration-150",children:i}),(0,t.jsx)("button",{ref:u,onClick:o,className:`px-4 py-2 rounded-lg text-[13px] font-medium transition-all duration-150 ${h?"bg-red-500 text-white hover:bg-red-600 active:scale-[0.97]":"btn-primary active:scale-[0.97]"}`,children:n})]})]}),(0,t.jsx)("style",{children:`
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,558201,e=>{"use strict";let t=(0,e.i(363732).default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);e.s(["Terminal",()=>t],558201)},203096,e=>{"use strict";let t=(0,e.i(363732).default)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);e.s(["RefreshCw",()=>t],203096)},741746,e=>{"use strict";let t=(0,e.i(363732).default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);e.s(["AlertCircle",()=>t],741746)},352687,e=>{"use strict";var t=e.i(762281),s=e.i(935851);function r({isOpen:e,title:r,message:a,preview:l,confirmLabel:n="Confirm",cancelLabel:i="Cancel",variant:o="default",onConfirm:c,onCancel:d}){let u=(0,s.useRef)(null),x=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(e){let e=setTimeout(()=>u.current?.focus(),50);return()=>clearTimeout(e)}},[e]);let m=(0,s.useCallback)(e=>{"Escape"===e.key&&d()},[d]);if(!e)return null;let h="danger"===o;return(0,t.jsxs)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/50 backdrop-blur-md",style:{animation:"confirm-overlay-in 200ms ease-out"},onClick:e=>e.target===e.currentTarget&&d(),onKeyDown:m,children:[(0,t.jsxs)("div",{ref:x,className:"w-full max-w-md mx-4 bg-[var(--card-bg)] rounded-2xl border border-[var(--card-border)] shadow-2xl overflow-hidden",style:{animation:"confirm-dialog-in 250ms cubic-bezier(0.34, 1.56, 0.64, 1)"},children:[(0,t.jsx)("div",{className:"px-6 pt-6 pb-3",children:(0,t.jsxs)("div",{className:"flex items-start gap-4",children:[h&&(0,t.jsx)("div",{className:"flex-shrink-0 w-11 h-11 rounded-full bg-red-500/10 border border-red-500/20 flex items-center justify-center",children:(0,t.jsx)("svg",{className:"w-5 h-5 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("h3",{className:"text-[15px] font-semibold text-[var(--foreground)]",children:r}),(0,t.jsx)("p",{className:"mt-1 text-[13px] text-[var(--muted-foreground)] leading-relaxed",children:a})]})]})}),l&&(0,t.jsx)("div",{className:"mx-6 mb-3 px-3 py-2.5 rounded-lg bg-[var(--muted)]/40 border border-[var(--card-border)]",children:(0,t.jsxs)("p",{className:"text-[12px] text-[var(--muted-foreground)] line-clamp-3 leading-relaxed italic",children:["“",l,"”"]})}),(0,t.jsx)("div",{className:"mx-6 border-t border-[var(--card-border)]"}),(0,t.jsxs)("div",{className:"px-6 py-4 flex items-center justify-end gap-2.5",children:[(0,t.jsx)("button",{onClick:d,className:"px-4 py-2 rounded-lg text-[13px] font-medium text-[var(--muted-foreground)] hover:text-[var(--foreground)] hover:bg-[var(--muted)]/60 transition-all duration-150",children:i}),(0,t.jsx)("button",{ref:u,onClick:c,className:`px-4 py-2 rounded-lg text-[13px] font-medium transition-all duration-150 ${h?"bg-red-500 text-white hover:bg-red-600 active:scale-[0.97]":"btn-primary active:scale-[0.97]"}`,children:n})]})]}),(0,t.jsx)("style",{children:`
2
2
  @keyframes confirm-overlay-in {
3
3
  from { opacity: 0; }
4
4
  to { opacity: 1; }
@@ -13,4 +13,4 @@
13
13
  transform: scale(1) translateY(0);
14
14
  }
15
15
  }
16
- `})]})}e.s(["default",()=>r])},807087,e=>{"use strict";let t=(0,e.i(363732).default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);e.s(["CheckCircle2",()=>t],807087)},287472,e=>{"use strict";var t=e.i(935851);let s=new Map;function r(e){let t=s.get(e);return t?Date.now()-t.ts>3e5?(s.delete(e),null):t:null}function a(e){s.delete(e)}function l(e,l){let[n,i]=(0,t.useState)(!1),[c,o]=(0,t.useState)(!0),[d,u]=(0,t.useState)(null),[x,m]=(0,t.useState)({claude:!1,codex:!1,gemini:!1}),[h,p]=(0,t.useState)({}),f=(0,t.useRef)(null),g=`/api/trackers/${encodeURIComponent(e)}`,v=`${e}:${l}`,b=(0,t.useCallback)(async()=>{try{let e=await fetch(`${g}/mcp-setup`),t=await e.json();p(t.configured??{})}catch{}},[g]),j=(0,t.useCallback)(async()=>{if(!l)return i(!1),!1;let e=r(v);if(e)return i(e.connected),u(e.user),m(e.clis),p(e.mcpConfigured),o(!1),e.connected;try{var t;let e=`?projectId=${encodeURIComponent(l)}`,[r,a]=await Promise.all([fetch(`${g}/status${e}`),fetch(`${g}/mcp-setup`)]),n=await r.json(),c=await a.json(),o=n.clis??{claude:!1,codex:!1,gemini:!1},d=c.configured??{},x=n.user??null;return i(n.connected),u(x),m(o),p(d),t={connected:n.connected,user:x,clis:o,mcpConfigured:d},s.set(v,{...t,ts:Date.now()}),n.connected}catch{return i(!1),!1}finally{o(!1)}},[l,g,v]);(0,t.useEffect)(()=>{let e=r(v);e?(i(e.connected),u(e.user),m(e.clis),p(e.mcpConfigured),o(!1)):(o(!0),i(!1),u(null))},[e,l,v]),(0,t.useEffect)(()=>(j(),()=>{f.current&&clearInterval(f.current)}),[j]);let y=(0,t.useCallback)(()=>{l&&(a(v),window.open(`${g}/auth?projectId=${encodeURIComponent(l)}`,"_blank","noopener"),f.current&&clearInterval(f.current),f.current=setInterval(async()=>{a(v),await j()&&f.current&&(clearInterval(f.current),f.current=null)},2e3))},[l,g,v,j]),w=(0,t.useCallback)(async e=>{if(!l)return{ok:!1,error:"Missing projectId"};try{let t=await fetch(`${g}/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:l,accessToken:e})});if(!t.ok){let e=await t.json().catch(()=>({}));return{ok:!1,error:e.error||"Failed to save token"}}return a(v),await j(),{ok:!0}}catch{return{ok:!1,error:"Failed to connect"}}},[l,g,v,j]);return{connected:n,loading:c,user:d,clis:x,mcpConfigured:h,connect:y,connectWithKey:w,disconnect:(0,t.useCallback)(async()=>{l&&(a(v),await fetch(`${g}/status?projectId=${encodeURIComponent(l)}`,{method:"DELETE"}),"github"===e&&Object.keys(sessionStorage).filter(e=>e.startsWith("github_")).forEach(e=>sessionStorage.removeItem(e)),i(!1),u(null))},[l,g,v,e]),configureMcp:(0,t.useCallback)(async e=>{try{let t=await fetch(`${g}/mcp-setup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cli:e})});if(!t.ok){let e=await t.json().catch(()=>({}));return{ok:!1,error:e.error||"Failed to configure MCP"}}return await b(),{ok:!0}}catch{return{ok:!1,error:"Failed to configure MCP"}}},[g,b]),refresh:j}}e.s(["useTrackerConnection",()=>l])},711190,e=>{"use strict";let t=(0,e.i(363732).default)("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]);e.s(["LogOut",()=>t],711190)},637790,166735,e=>{"use strict";var t=e.i(363732);let s=(0,t.default)("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);e.s(["Key",()=>s],637790);let r=(0,t.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);e.s(["Globe",()=>r],166735)},202192,457242,e=>{"use strict";var t=e.i(762281),s=e.i(935851),r=e.i(807087),a=e.i(637790),l=e.i(166735),n=e.i(906724),i=e.i(741746),c=e.i(558201),o=e.i(711190),d=e.i(681619),u=e.i(929870),x=e.i(797167),m=e.i(203096);let h=(0,e.i(363732).default)("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);function p({projectId:e}){let[r,a]=(0,s.useState)([]),[l,i]=(0,s.useState)(!0),[c,o]=(0,s.useState)(null),[d,p]=(0,s.useState)(null),[f,g]=(0,s.useState)(!1),[v,b]=(0,s.useState)([]),[j,y]=(0,s.useState)(!1),[w,N]=(0,s.useState)(null),[k,C]=(0,s.useState)(""),[S,L]=(0,s.useState)("all"),[T,$]=(0,s.useState)(new Set),[P,M]=(0,s.useState)(!1),z=(0,s.useCallback)(async()=>{try{let e=await fetch("/api/github/repos",{cache:"no-store"});if(!e.ok)throw Error("Failed to load repos");let t=await e.json();a(t.repos??[]),o(null)}catch{o("Failed to load repositories")}finally{i(!1)}},[]);(0,s.useEffect)(()=>{z()},[z]);let I=(0,s.useCallback)((e,t)=>`${e}/${t}`.toLowerCase(),[]),A=(0,s.useMemo)(()=>new Set(r.map(e=>I(e.owner,e.name))),[r,I]),E=(0,s.useCallback)(async()=>{if(g(!0),$(new Set),C(""),L("all"),!(v.length>0)){y(!0),N(null);try{let t=await fetch(`/api/github/user-repos?projectId=${encodeURIComponent(e)}`,{cache:"no-store"});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e?.error??"Failed to fetch repos")}let s=await t.json();b(s.repos??[])}catch(e){N(e instanceof Error?e.message:"Failed to fetch repos")}finally{y(!1)}}},[e,v.length]),F=()=>{g(!1)};(0,s.useEffect)(()=>{if(!f)return;let e=e=>{"Escape"===e.key&&F()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[f]);let R=(0,s.useMemo)(()=>{let e=[],t=[];for(let s of v)A.has(I(s.owner,s.name))?e.push(s):t.push(s);return[...e,...t]},[v,A,I]),O=(0,s.useMemo)(()=>{let e=k.trim().toLowerCase();return R.filter(t=>("public"!==S||!t.private)&&("private"!==S||!!t.private)&&(!e||t.fullName.toLowerCase().includes(e)||(t.description??"").toLowerCase().includes(e)))},[R,k,S]),D=(0,s.useMemo)(()=>O.filter(e=>!A.has(I(e.owner,e.name))),[O,A,I]),U=D.length>0&&D.every(e=>T.has(e.id)),K=async()=>{if(0!==T.size){M(!0);try{let e=v.filter(e=>T.has(e.id));await Promise.all(e.map(e=>fetch("/api/github/repos",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({owner:e.owner,name:e.name,defaultBranch:e.defaultBranch,private:e.private})}))),await z(),F()}finally{M(!1)}}},B=(0,s.useCallback)(async e=>{p(e);try{await fetch("/api/github/repos",{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({id:e})}),await z()}finally{p(null)}},[z]);return(0,t.jsxs)("div",{className:"w-full max-w-md space-y-4",children:[(0,t.jsxs)("div",{className:"border rounded-xl p-5 flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{className:"text-sm font-medium",children:"Attached repositories"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Repos the local agent watches for PRs, reviews, and comments."})]}),(0,t.jsxs)("button",{type:"button",onClick:E,className:"text-xs px-2.5 py-1.5 rounded border hover:bg-accent inline-flex items-center gap-1",children:[(0,t.jsx)(u.Plus,{className:"w-3.5 h-3.5"}),"Add"]})]}),l?(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(n.Loader2,{className:"w-4 h-4 animate-spin"}),"Loading repositories…"]}):c?(0,t.jsx)("p",{className:"text-sm text-destructive",children:c}):0===r.length?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No repositories attached yet."}):(0,t.jsx)("ul",{className:"divide-y",children:r.map(e=>(0,t.jsxs)("li",{className:"flex items-center justify-between py-2",children:[(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsxs)("span",{className:"text-sm font-mono",children:[e.owner,"/",e.name]}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:[e.defaultBranch??"no default branch",e.private?" · private":" · public",e.accessRevoked?" · access revoked":""]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>B(e.id),disabled:d===e.id,className:"p-1.5 rounded hover:bg-accent disabled:opacity-50",title:"Remove",children:(0,t.jsx)(x.X,{className:"w-3.5 h-3.5"})})]},e.id))})]}),(0,t.jsxs)("div",{className:"border rounded-xl p-5 flex items-center justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{className:"text-sm font-medium",children:"Sync"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Pull the latest PRs, reviews, and comments for attached repos."})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>alert("Sync will run when worker is scheduled"),className:"text-xs px-3 py-1.5 rounded border hover:bg-accent inline-flex items-center gap-1.5",children:[(0,t.jsx)(m.RefreshCw,{className:"w-3.5 h-3.5"}),"Sync now"]})]}),f&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:F,children:(0,t.jsxs)("div",{className:"w-full max-w-3xl max-h-[90vh] flex flex-col rounded-xl border border-[var(--border)] bg-[var(--background)] text-[var(--foreground)] shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)("header",{className:"px-6 py-5 border-b border-[var(--border)] flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-[var(--muted-foreground)] mb-1",children:[(0,t.jsx)("span",{children:"GitHub"}),(0,t.jsx)("span",{children:"·"}),(0,t.jsx)("span",{children:"Attach repositories"})]}),(0,t.jsx)("h1",{className:"text-xl font-semibold tracking-tight",children:"Select repositories"}),(0,t.jsx)("p",{className:"text-sm text-[var(--muted-foreground)] mt-1",children:"Pick the repos you want agx to track. Already-attached repos are pinned at the top."})]}),(0,t.jsx)("button",{onClick:F,className:"p-1.5 rounded hover:bg-[var(--item-hover-bg)] text-[var(--muted-foreground)]","aria-label":"Close",children:(0,t.jsx)(x.X,{className:"w-4 h-4"})})]}),(0,t.jsx)("div",{className:"px-6 py-4 flex-1 overflow-hidden flex flex-col",children:w?(0,t.jsx)("div",{className:"rounded-lg border border-[var(--status-failed-border)] bg-[var(--status-failed-bg)] text-[var(--status-failed)] px-4 py-3 text-sm",children:w}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 mb-3",children:[(0,t.jsxs)("div",{className:"relative flex-1",children:[(0,t.jsxs)("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--muted-foreground)]",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,t.jsx)("path",{d:"m21 21-4.3-4.3"})]}),(0,t.jsx)("input",{type:"text",value:k,onChange:e=>C(e.target.value),placeholder:"Search repositories...",className:"w-full pl-9 pr-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--input)] text-sm focus:outline-none focus:border-[var(--primary)] focus:bg-[var(--input-focus)] transition-colors"})]}),(0,t.jsx)("div",{className:"flex gap-1 rounded-lg border border-[var(--border)] p-1",children:["all","public","private"].map(e=>(0,t.jsx)("button",{onClick:()=>L(e),className:`px-3 py-1 text-xs rounded-md capitalize transition-colors ${S===e?"bg-[var(--primary)] text-[var(--primary-foreground)]":"text-[var(--muted-foreground)] hover:text-[var(--foreground)]"}`,children:e},e))})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2 text-xs text-[var(--muted-foreground)]",children:[(0,t.jsxs)("button",{onClick:()=>{$(e=>{let t=new Set(e);return U?D.forEach(e=>t.delete(e.id)):D.forEach(e=>t.add(e.id)),t})},disabled:0===D.length,className:"hover:text-[var(--foreground)] transition-colors disabled:opacity-50",children:[U?"Deselect all":"Select all",k||"all"!==S?` (${D.length} shown)`:""]}),T.size>0&&(0,t.jsx)("button",{onClick:()=>$(new Set),className:"hover:text-[var(--foreground)] transition-colors",children:"Clear selection"})]}),(0,t.jsx)("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--card-bg)] overflow-hidden flex-1 min-h-0",children:(0,t.jsx)("div",{className:"h-full overflow-y-auto",children:j?(0,t.jsx)("div",{className:"divide-y divide-[var(--border)]",children:Array.from({length:6}).map((e,s)=>(0,t.jsxs)("div",{className:"px-4 py-3 flex items-center gap-3 animate-pulse",children:[(0,t.jsx)("div",{className:"w-4 h-4 rounded bg-[var(--muted)]"}),(0,t.jsx)("div",{className:"w-6 h-6 rounded-full bg-[var(--muted)]"}),(0,t.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,t.jsx)("div",{className:"h-3 w-1/3 rounded bg-[var(--muted)]"}),(0,t.jsx)("div",{className:"h-2 w-2/3 rounded bg-[var(--muted)]"})]})]},s))}):0===O.length?(0,t.jsx)("div",{className:"px-4 py-10 text-center text-sm text-[var(--muted-foreground)]",children:0===v.length?"No repositories found on your account.":"No repos match your search."}):(0,t.jsx)("ul",{className:"divide-y divide-[var(--border)]",children:O.map(e=>{let s=A.has(I(e.owner,e.name)),r=T.has(e.id);return(0,t.jsx)("li",{children:(0,t.jsxs)("label",{className:`flex items-start gap-3 px-4 py-3 transition-colors ${s?"bg-[var(--primary-muted)]/40 cursor-default":r?"bg-[var(--primary-muted)] cursor-pointer":"hover:bg-[var(--item-hover-bg)] cursor-pointer"}`,children:[s?(0,t.jsx)("div",{className:"mt-1 w-4 h-4 rounded-sm bg-[var(--primary)]/20 text-[var(--primary)] flex items-center justify-center",title:"Already attached",children:(0,t.jsx)(h,{className:"w-2.5 h-2.5"})}):(0,t.jsx)("input",{type:"checkbox",checked:r,onChange:()=>{!A.has(I(e.owner,e.name))&&$(t=>{let s=new Set(t);return s.has(e.id)?s.delete(e.id):s.add(e.id),s})},className:"mt-1 accent-[var(--primary)]"}),(0,t.jsx)("img",{src:e.avatarUrl,alt:"",className:"w-6 h-6 rounded-full mt-0.5 flex-shrink-0"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)("span",{className:"text-sm font-medium truncate",children:e.fullName}),s&&(0,t.jsxs)("span",{className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded bg-[var(--primary)]/15 text-[var(--primary)] flex items-center gap-1",children:[(0,t.jsx)(h,{className:"w-2.5 h-2.5"}),"Attached"]}),e.private&&(0,t.jsx)("span",{className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded bg-[var(--muted)] text-[var(--muted-foreground)]",children:"Private"})]}),e.description&&(0,t.jsx)("p",{className:"text-xs text-[var(--muted-foreground)] mt-0.5 line-clamp-1",children:e.description}),(0,t.jsxs)("div",{className:"text-[11px] text-[var(--muted-foreground)] mt-0.5",children:["Updated ",function(e){let t=Math.floor((Date.now()-new Date(e).getTime())/1e3);if(t<60)return"just now";let s=Math.floor(t/60);if(s<60)return`${s}m ago`;let r=Math.floor(s/60);if(r<24)return`${r}h ago`;let a=Math.floor(r/24);if(a<30)return`${a}d ago`;let l=Math.floor(a/30);return l<12?`${l}mo ago`:`${Math.floor(l/12)}y ago`}(e.updatedAt)]})]})]})},e.id)})})})})]})}),(0,t.jsxs)("footer",{className:"px-6 py-4 border-t border-[var(--border)] flex items-center justify-between gap-3",children:[(0,t.jsxs)("span",{className:"text-sm text-[var(--muted-foreground)]",children:[T.size," selected"]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{onClick:F,className:"px-4 py-2 rounded-lg border border-[var(--border)] hover:bg-[var(--item-hover-bg)] text-sm font-medium transition-colors",children:"Cancel"}),(0,t.jsx)("button",{onClick:K,disabled:0===T.size||P,className:"px-4 py-2 rounded-lg bg-[var(--primary)] hover:bg-[var(--primary-hover)] text-[var(--primary-foreground)] text-sm font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:P?"Attaching...":`Attach ${T.size} ${1===T.size?"repo":"repos"}`})]})]})]})})]})}e.s(["Pin",()=>h],457242);var f=e.i(352687);let g={claude:{name:"Claude Code",configPath:"~/.claude/settings.json"},codex:{name:"Codex CLI",configPath:"~/.codex/config.toml"},gemini:{name:"Gemini CLI",configPath:"~/.gemini/settings.json"}};function v({trackerType:e,projectId:u,connected:x,onConnect:m,onConnectWithKey:h,onDisconnect:v,loading:b=!1,clis:j,mcpConfigured:y,onConfigureMcp:w}){let[N,k]=s.default.useState(""),[C,S]=s.default.useState(null),[L,T]=s.default.useState(!1),[$,P]=s.default.useState(!1),[M,z]=s.default.useState(null),[I,A]=s.default.useState({}),[E,F]=s.default.useState(!1),R=async e=>{if(!w)return;z(e),A(t=>({...t,[e]:""}));let t=await w(e);t.ok||A(s=>({...s,[e]:t.error??"Failed to install MCP"})),z(null)},O=j?["claude","codex","gemini"].filter(e=>j[e]):["claude"];if(b)return(0,t.jsx)("div",{className:"flex items-center justify-center p-12",children:(0,t.jsx)(n.Loader2,{className:"animate-spin h-8 w-8 text-muted-foreground"})});if(x)return(0,t.jsxs)("div",{className:"p-8 flex flex-col items-center gap-6",children:[(0,t.jsxs)("div",{className:"w-full max-w-md p-8 border border-green-500/20 bg-green-500/5 rounded-2xl flex flex-col items-center gap-4 text-center",children:[(0,t.jsx)("div",{className:"h-16 w-16 rounded-full bg-green-500/10 flex items-center justify-center text-green-600 shadow-inner",children:(0,t.jsx)(r.CheckCircle2,{className:"h-8 w-8"})}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("h3",{className:"text-xl font-bold text-foreground capitalize",children:[e," Connected"]}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground leading-relaxed",children:["Your ",e," workspace is successfully connected. The agent can now sync issues and manage your backlog."]})]}),(0,t.jsxs)("div",{className:"mt-2 px-4 py-1.5 rounded-full bg-background border text-xs font-medium text-muted-foreground flex items-center gap-2",children:[(0,t.jsx)("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500 animate-pulse"}),"Active Connection"]}),v&&(0,t.jsxs)("button",{onClick:()=>F(!0),className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-destructive transition-colors mt-1",children:[(0,t.jsx)(o.LogOut,{className:"h-3.5 w-3.5"}),"Disconnect"]})]}),"github"===e&&(0,t.jsx)(p,{projectId:u}),v&&(0,t.jsx)(f.default,{isOpen:E,title:`Disconnect ${e}?`,message:"github"===e?"This revokes the stored credentials. Your attached repositories and synced history stay — reconnecting will resume where you left off.":`This revokes the stored credentials for ${e}. Project settings and synced history stay.`,confirmLabel:"Disconnect",cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{F(!1),v()},onCancel:()=>F(!1)}),"github"!==e&&O.length>0&&(0,t.jsx)("div",{className:"w-full max-w-md",children:(0,t.jsxs)("div",{className:"border rounded-xl p-5 flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(c.Terminal,{className:"h-4 w-4 text-muted-foreground"}),(0,t.jsx)("span",{className:"text-sm font-medium",children:"MCP Server"})]}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground leading-relaxed -mt-2",children:["Install the ",e," MCP server so agents can access ",e," directly."]}),O.map(e=>{let s=g[e],a=y?.[e]??!1,l=M===e,c=I[e];return(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-foreground",children:s.name}),a?(0,t.jsxs)("span",{className:"text-xs font-medium text-green-600 flex items-center gap-1",children:[(0,t.jsx)(r.CheckCircle2,{className:"h-3.5 w-3.5"}),"Installed"]}):(0,t.jsx)("button",{onClick:()=>R(e),disabled:l||!w,className:"flex items-center gap-1.5 px-3 py-1 bg-secondary text-secondary-foreground rounded-md text-xs font-semibold hover:bg-secondary/90 disabled:opacity-50 transition-all active:scale-[0.98]",children:l?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.Loader2,{className:"h-3 w-3 animate-spin"}),"Installing…"]}):(0,t.jsx)(t.Fragment,{children:"Install"})})]}),a&&(0,t.jsxs)("p",{className:"text-[10px] text-muted-foreground",children:["Configured in ",(0,t.jsx)("code",{className:"font-mono",children:s.configPath})]}),c&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-destructive bg-destructive/10 p-2 rounded-md",children:[(0,t.jsx)(i.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),c]})]},e)})]})})]});let D=async()=>{if(N.trim()){P(!0),S(null);try{let e=await h(N.trim());e.ok?(k(""),T(!1)):S(e.error??"Failed to connect")}catch(e){S("An unexpected error occurred")}finally{P(!1)}}};return(0,t.jsxs)("div",{className:"flex flex-col items-center gap-6 p-8",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(d.TrackerIcon,{trackerType:e,className:"h-16 w-16"}),(0,t.jsx)("div",{className:"absolute -bottom-1 -right-1 h-6 w-6 rounded-full bg-background border flex items-center justify-center shadow-sm",children:(0,t.jsx)(l.Globe,{className:"h-3 w-3 text-muted-foreground"})})]}),(0,t.jsxs)("div",{className:"text-center space-y-2",children:[(0,t.jsxs)("h3",{className:"text-lg font-semibold capitalize",children:["Connect to ",e]}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground text-center max-w-sm leading-relaxed",children:["Link your ",e," account to import issues, track progress, and automate your workflow."]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 w-full max-w-xs pt-2",children:[(0,t.jsxs)("button",{onClick:m,className:"flex items-center justify-center gap-2 w-full px-4 py-2.5 bg-primary text-primary-foreground rounded-lg text-sm font-semibold hover:bg-primary/90 transition-all active:scale-[0.98] shadow-sm",children:[(0,t.jsx)(l.Globe,{className:"h-4 w-4"}),"Connect with OAuth"]}),"github"!==e&&(0,t.jsxs)("button",{onClick:()=>{T(!L),S(null)},className:"flex items-center justify-center gap-2 w-full px-4 py-2 text-sm text-muted-foreground hover:text-foreground transition-colors font-medium",children:[(0,t.jsx)(a.Key,{className:"h-3.5 w-3.5"}),L?"Use OAuth instead":"Connect with API key"]}),(0,t.jsx)("div",{className:`grid transition-all duration-300 ease-in-out ${L?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0 pointer-events-none"}`,children:(0,t.jsx)("div",{className:"overflow-hidden",children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 pt-2",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"password",value:N,onChange:e=>{k(e.target.value),C&&S(null)},placeholder:"Paste your API key here",className:`w-full px-3 py-2 border rounded-lg text-sm bg-background transition-colors focus:outline-none focus:ring-2 focus:ring-primary/20 ${C?"border-destructive":"focus:border-primary"}`,onKeyDown:e=>"Enter"===e.key&&D()}),(0,t.jsx)(a.Key,{className:"absolute right-3 top-2.5 h-4 w-4 text-muted-foreground/50"})]}),C&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-destructive bg-destructive/10 p-2 rounded-md",children:[(0,t.jsx)(i.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("p",{children:C})]}),(0,t.jsx)("button",{onClick:D,disabled:$||!N.trim(),className:"flex items-center justify-center gap-2 w-full px-4 py-2 bg-secondary text-secondary-foreground rounded-lg text-sm font-semibold hover:bg-secondary/90 disabled:opacity-50 transition-all active:scale-[0.98]",children:$?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.Loader2,{className:"h-4 w-4 animate-spin"}),"Connecting..."]}):"Verify & Connect"}),(0,t.jsxs)("p",{className:"text-[10px] text-muted-foreground text-center px-2",children:["Your API key is stored securely and only used for ",e," integration."]})]})})})]})]})}e.s(["default",()=>v],202192)},108537,e=>{"use strict";var t=e.i(762281),s=e.i(935851),r=e.i(429056),a=e.i(807087),l=e.i(711190);let n=(0,e.i(363732).default)("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);var i=e.i(202192),c=e.i(906724);let o=/^[A-Z]{2,10}$/;function d({projectId:e,trackerType:s}){return"github"===s?null:(0,t.jsx)(u,{projectId:e})}function u({projectId:e}){let[r,a]=(0,s.useState)(""),[l,n]=(0,s.useState)(null),[i,d]=(0,s.useState)(!0),[u,x]=(0,s.useState)(null),[m,h]=(0,s.useState)(null),[p,f]=(0,s.useState)(!1),[g,v]=(0,s.useState)(null),[b,j]=(0,s.useState)(null),y=(0,s.useCallback)(async()=>{d(!0);try{let t=await fetch(`/api/projects/${e}`,{cache:"no-store"});if(!t.ok)throw Error("Failed to load project");let s=await t.json(),r=s.project?.identifier_prefix??null;n(r),a(r??""),x(null)}catch{x("Failed to load project settings")}finally{d(!1)}},[e]);(0,s.useEffect)(()=>{y()},[y]);let w=(0,s.useCallback)(e=>e?o.test(e)?null:"Must be 2-10 uppercase letters (e.g. TSK, AGX).":null,[]),N=(0,s.useCallback)(async t=>{f(!0),v(null);try{let s=await fetch(`/api/projects/${e}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({identifier_prefix:t})});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e?.error??"Failed to save")}let r=await s.json(),l=r.project?.identifier_prefix??null;n(l),a(l??""),j(Date.now())}catch(e){v(e instanceof Error?e.message:"Failed to save")}finally{f(!1)}},[e]),k=(l??"")!==r.trim().toUpperCase();return(0,t.jsxs)("section",{className:"border border-zinc-200 dark:border-zinc-800 rounded-lg p-5 space-y-4 mx-6 mb-6",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-sm font-medium",children:"Task identifier prefix"}),(0,t.jsxs)("p",{className:"text-xs text-zinc-500 mt-0.5",children:["Used to identify tasks in branches, PR titles, and links (e.g."," ",(0,t.jsx)("span",{className:"font-mono",children:"TSK-42"}),"). Set once; existing tasks keep their current identifiers."]})]}),i?(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-zinc-500",children:[(0,t.jsx)(c.Loader2,{className:"w-4 h-4 animate-spin"}),"Loading..."]}):u?(0,t.jsx)("p",{className:"text-sm text-red-500",children:u}):(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{type:"text",value:r,onChange:e=>{a(e.target.value.toUpperCase()),h(null),v(null)},onBlur:e=>{h(w(e.target.value.trim().toUpperCase()))},placeholder:"TSK",maxLength:10,className:"w-40 px-2 py-1.5 text-sm font-mono rounded border border-zinc-300 dark:border-zinc-700 bg-transparent"}),(0,t.jsx)("button",{type:"button",onClick:()=>{let e=r.trim().toUpperCase(),t=w(e);t?h(t):(h(null),N(e||null))},disabled:p||!k||!!m,className:"text-xs px-3 py-1.5 rounded bg-zinc-900 text-white dark:bg-white dark:text-zinc-900 hover:opacity-90 disabled:opacity-50",children:p?"Saving...":"Save"}),l?(0,t.jsx)("button",{type:"button",onClick:()=>{h(null),N(null)},disabled:p,className:"text-xs px-3 py-1.5 rounded border border-zinc-300 dark:border-zinc-700 hover:bg-zinc-100 dark:hover:bg-zinc-800 disabled:opacity-50",children:"Clear"}):null]}),(0,t.jsxs)("p",{className:"text-xs text-zinc-500",children:["2-10 uppercase letters, matching"," ",(0,t.jsxs)("span",{className:"font-mono",children:["/^[A-Z]","{2,10}","$/"]}),"."]}),m&&(0,t.jsx)("p",{className:"text-xs text-red-500",children:m}),g&&(0,t.jsx)("p",{className:"text-xs text-red-500",children:g}),b&&!g&&!m&&(0,t.jsx)("p",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"Saved."})]})]})}var x=e.i(681619),m=e.i(524123),h=e.i(287472),p=e.i(235136);let f=[{type:"linear",label:"Linear"},{type:"jira",label:"Jira Cloud"},{type:"github",label:"GitHub"}];function g(){return(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center min-h-[calc(100vh-3.5rem)] gap-8 p-8 -mt-7 animate-pulse",children:[(0,t.jsxs)("div",{className:"space-y-3 text-center flex flex-col items-center",children:[(0,t.jsx)("div",{className:"h-7 w-56 rounded-lg bg-muted"}),(0,t.jsx)("div",{className:"h-4 w-80 rounded bg-muted"})]}),(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 w-full max-w-lg",children:[0,1].map(e=>(0,t.jsxs)("div",{className:"flex flex-col items-center gap-4 p-8 rounded-xl border border-border",children:[(0,t.jsx)("div",{className:"h-16 w-16 rounded-xl bg-muted"}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,t.jsx)("div",{className:"h-4 w-20 rounded bg-muted"}),(0,t.jsx)("div",{className:"h-3 w-24 rounded bg-muted"})]})]},e))})]})}function v(){return(0,t.jsxs)("div",{className:"flex flex-col items-center gap-6 p-8 animate-pulse",children:[(0,t.jsx)("div",{className:"h-16 w-16 rounded-xl bg-muted"}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2 w-full max-w-sm",children:[(0,t.jsx)("div",{className:"h-5 w-40 rounded bg-muted"}),(0,t.jsx)("div",{className:"h-3 w-72 rounded bg-muted"}),(0,t.jsx)("div",{className:"h-3 w-56 rounded bg-muted"})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 w-full max-w-xs pt-2",children:[(0,t.jsx)("div",{className:"h-10 w-full rounded-lg bg-muted"}),(0,t.jsx)("div",{className:"h-8 w-full rounded-lg bg-muted/60"})]})]})}function b({params:e}){let{slug:c}=(0,s.use)(e),{projects:o}=(0,m.useProjects)(),u=o.find(e=>e.slug===c),b=u?.id??"",{connections:j,defaultTracker:y,loading:w,removeConnection:N,setDefaultTracker:k}=(0,p.useTrackerConnections)(b),C=new Set(j.filter(e=>e.connected).map(e=>e.type)),S=C.size,[L,T]=(0,s.useState)(null),{connected:$,loading:P,connect:M,connectWithKey:z,disconnect:I,clis:A,mcpConfigured:E,configureMcp:F}=(0,h.useTrackerConnection)(L??"linear",b);return(0,t.jsx)("div",{className:"flex flex-col h-full bg-background",children:(0,t.jsx)("main",{className:"flex-1 overflow-auto",children:L?(0,t.jsx)("div",{className:"flex flex-col items-center px-6 py-12",children:(0,t.jsxs)("div",{className:"w-full max-w-2xl",children:[(0,t.jsxs)("button",{onClick:()=>T(null),className:"group flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground mb-8 transition-colors",children:[(0,t.jsx)(r.ArrowLeft,{className:"h-3 w-3 transition-transform group-hover:-translate-x-0.5"}),"Back to tracker picker"]}),(0,t.jsxs)("div",{className:"bg-card border rounded-xl shadow-sm overflow-hidden",children:[(0,t.jsx)("div",{className:"px-6 pt-8 pb-1 text-center",children:(0,t.jsxs)("h2",{className:"text-2xl font-semibold tracking-tight",children:["Connect ",f.find(e=>e.type===L)?.label??L]})}),P?(0,t.jsx)(v,{}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)(i.default,{projectId:b,trackerType:L,connected:$,loading:!1,onConnect:M,onConnectWithKey:z,onDisconnect:()=>{I(),T(null)},clis:A,mcpConfigured:E,onConfigureMcp:F}),(0,t.jsx)(d,{projectId:b,trackerType:L??void 0})]})]})]})}):w?(0,t.jsx)(g,{}):(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center min-h-[calc(100vh-3.5rem)] gap-8 p-8 -mt-7",children:[(0,t.jsxs)("div",{className:"space-y-2 text-center",children:[(0,t.jsx)("h2",{className:"text-2xl font-bold tracking-tight",children:"Connect Issue Tracker"}),(0,t.jsx)("p",{className:"text-muted-foreground max-w-md mx-auto",children:"Choose an issue tracker to connect to this project to enable issue tracking and agent workflows."})]}),(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 w-full max-w-lg",children:f.map(e=>{let s=C.has(e.type),r=y===e.type,i=s&&S>1&&!r&&"github"!==e.type;return(0,t.jsxs)("div",{className:"relative flex flex-col items-center gap-4 p-8 rounded-xl border transition-all duration-200 group cursor-pointer active:scale-[0.98] "+(s?r?"border-yellow-500/40 bg-yellow-500/5 hover:border-yellow-500/60 hover:bg-yellow-500/10":"border-green-500/20 bg-green-500/5 hover:border-green-500/40 hover:bg-green-500/10":"border-border hover:border-primary/50 hover:bg-accent/50 hover:shadow-md"),onClick:()=>T(e.type),children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(x.TrackerIcon,{trackerType:e.type,className:"h-16 w-16 transition-transform group-hover:scale-105"}),s&&(0,t.jsx)("div",{className:"absolute -top-1 -right-1 h-6 w-6 rounded-full bg-green-500 border-2 border-background flex items-center justify-center text-white shadow-sm",children:(0,t.jsx)(a.CheckCircle2,{className:"h-4 w-4"})})]}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-1",children:[(0,t.jsx)("span",{className:"text-base font-semibold",children:e.label}),s?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-green-600",children:["Connected",r&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded-full bg-yellow-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-yellow-700",children:[(0,t.jsx)(n,{className:"h-3 w-3 fill-yellow-500 text-yellow-500"}),"Default"]})]}):(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Click to connect"})]}),s&&(0,t.jsxs)("div",{className:"flex flex-col items-center gap-1.5",children:[i&&(0,t.jsxs)("button",{onClick:t=>{t.stopPropagation(),k(e.type)},className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[(0,t.jsx)(n,{className:"h-3.5 w-3.5"}),"Set as default"]}),(0,t.jsxs)("button",{onClick:t=>{t.stopPropagation(),N(e.type)},className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-destructive transition-colors",children:[(0,t.jsx)(l.LogOut,{className:"h-3.5 w-3.5"}),"Disconnect"]})]})]},e.type)})})]})})})}e.s(["default",()=>b],108537)}]);
16
+ `})]})}e.s(["default",()=>r])},807087,e=>{"use strict";let t=(0,e.i(363732).default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);e.s(["CheckCircle2",()=>t],807087)},287472,e=>{"use strict";var t=e.i(935851);let s=new Map;function r(e){let t=s.get(e);return t?Date.now()-t.ts>3e5?(s.delete(e),null):t:null}function a(e){s.delete(e)}function l(e,l){let[n,i]=(0,t.useState)(!1),[o,c]=(0,t.useState)(!0),[d,u]=(0,t.useState)(null),[x,m]=(0,t.useState)({claude:!1,codex:!1,gemini:!1}),[h,p]=(0,t.useState)({}),f=(0,t.useRef)(null),g=`/api/trackers/${encodeURIComponent(e)}`,b=`${e}:${l}`,v=(0,t.useCallback)(async()=>{try{let e=await fetch(`${g}/mcp-setup`),t=await e.json();p(t.configured??{})}catch{}},[g]),j=(0,t.useCallback)(async()=>{if(!l)return i(!1),!1;let e=r(b);if(e)return i(e.connected),u(e.user),m(e.clis),p(e.mcpConfigured),c(!1),e.connected;try{var t;let e=`?projectId=${encodeURIComponent(l)}`,[r,a]=await Promise.all([fetch(`${g}/status${e}`),fetch(`${g}/mcp-setup`)]),n=await r.json(),o=await a.json(),c=n.clis??{claude:!1,codex:!1,gemini:!1},d=o.configured??{},x=n.user??null;return i(n.connected),u(x),m(c),p(d),t={connected:n.connected,user:x,clis:c,mcpConfigured:d},s.set(b,{...t,ts:Date.now()}),n.connected}catch{return i(!1),!1}finally{c(!1)}},[l,g,b]);(0,t.useEffect)(()=>{let e=r(b);e?(i(e.connected),u(e.user),m(e.clis),p(e.mcpConfigured),c(!1)):(c(!0),i(!1),u(null))},[e,l,b]),(0,t.useEffect)(()=>(j(),()=>{f.current&&clearInterval(f.current)}),[j]);let y=(0,t.useCallback)(()=>{l&&(a(b),window.open(`${g}/auth?projectId=${encodeURIComponent(l)}`,"_blank","noopener"),f.current&&clearInterval(f.current),f.current=setInterval(async()=>{a(b),await j()&&f.current&&(clearInterval(f.current),f.current=null)},2e3))},[l,g,b,j]),w=(0,t.useCallback)(async e=>{if(!l)return{ok:!1,error:"Missing projectId"};try{let t=await fetch(`${g}/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:l,accessToken:e})});if(!t.ok){let e=await t.json().catch(()=>({}));return{ok:!1,error:e.error||"Failed to save token"}}return a(b),await j(),{ok:!0}}catch{return{ok:!1,error:"Failed to connect"}}},[l,g,b,j]);return{connected:n,loading:o,user:d,clis:x,mcpConfigured:h,connect:y,connectWithKey:w,disconnect:(0,t.useCallback)(async()=>{l&&(a(b),await fetch(`${g}/status?projectId=${encodeURIComponent(l)}`,{method:"DELETE"}),"github"===e&&Object.keys(sessionStorage).filter(e=>e.startsWith("github_")).forEach(e=>sessionStorage.removeItem(e)),i(!1),u(null))},[l,g,b,e]),configureMcp:(0,t.useCallback)(async e=>{try{let t=await fetch(`${g}/mcp-setup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cli:e})});if(!t.ok){let e=await t.json().catch(()=>({}));return{ok:!1,error:e.error||"Failed to configure MCP"}}return await v(),{ok:!0}}catch{return{ok:!1,error:"Failed to configure MCP"}}},[g,v]),refresh:j}}e.s(["useTrackerConnection",()=>l])},711190,e=>{"use strict";let t=(0,e.i(363732).default)("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]);e.s(["LogOut",()=>t],711190)},637790,166735,e=>{"use strict";var t=e.i(363732);let s=(0,t.default)("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);e.s(["Key",()=>s],637790);let r=(0,t.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);e.s(["Globe",()=>r],166735)},202192,457242,e=>{"use strict";var t=e.i(762281),s=e.i(935851),r=e.i(807087),a=e.i(637790),l=e.i(166735),n=e.i(906724),i=e.i(741746),o=e.i(558201),c=e.i(711190),d=e.i(681619),u=e.i(929870),x=e.i(797167),m=e.i(203096);let h=(0,e.i(363732).default)("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);function p({projectId:e}){let[r,a]=(0,s.useState)([]),[l,i]=(0,s.useState)(!0),[o,c]=(0,s.useState)(null),[d,p]=(0,s.useState)(null),[f,g]=(0,s.useState)(!1),[b,v]=(0,s.useState)([]),[j,y]=(0,s.useState)(!1),[w,N]=(0,s.useState)(null),[k,C]=(0,s.useState)(""),[S,L]=(0,s.useState)("all"),[T,$]=(0,s.useState)(new Set),[P,M]=(0,s.useState)(!1),z=(0,s.useCallback)(async()=>{try{let e=await fetch("/api/github/repos",{cache:"no-store"});if(!e.ok)throw Error("Failed to load repos");let t=await e.json();a(t.repos??[]),c(null)}catch{c("Failed to load repositories")}finally{i(!1)}},[]);(0,s.useEffect)(()=>{z()},[z]);let A=(0,s.useCallback)((e,t)=>`${e}/${t}`.toLowerCase(),[]),I=(0,s.useMemo)(()=>new Set(r.map(e=>A(e.owner,e.name))),[r,A]),E=(0,s.useCallback)(async()=>{if(g(!0),$(new Set),C(""),L("all"),!(b.length>0)){y(!0),N(null);try{let t=await fetch(`/api/github/user-repos?projectId=${encodeURIComponent(e)}`,{cache:"no-store"});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e?.error??"Failed to fetch repos")}let s=await t.json();v(s.repos??[])}catch(e){N(e instanceof Error?e.message:"Failed to fetch repos")}finally{y(!1)}}},[e,b.length]),F=()=>{g(!1)};(0,s.useEffect)(()=>{if(!f)return;let e=e=>{"Escape"===e.key&&F()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[f]);let R=(0,s.useMemo)(()=>{let e=[],t=[];for(let s of b)I.has(A(s.owner,s.name))?e.push(s):t.push(s);return[...e,...t]},[b,I,A]),O=(0,s.useMemo)(()=>{let e=k.trim().toLowerCase();return R.filter(t=>("public"!==S||!t.private)&&("private"!==S||!!t.private)&&(!e||t.fullName.toLowerCase().includes(e)||(t.description??"").toLowerCase().includes(e)))},[R,k,S]),D=(0,s.useMemo)(()=>O.filter(e=>!I.has(A(e.owner,e.name))),[O,I,A]),U=D.length>0&&D.every(e=>T.has(e.id)),K=async()=>{if(0!==T.size){M(!0);try{let e=b.filter(e=>T.has(e.id));await Promise.all(e.map(e=>fetch("/api/github/repos",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({owner:e.owner,name:e.name,defaultBranch:e.defaultBranch,private:e.private})}))),await z(),F()}finally{M(!1)}}},B=(0,s.useCallback)(async e=>{p(e);try{await fetch("/api/github/repos",{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({id:e})}),await z()}finally{p(null)}},[z]);return(0,t.jsxs)("div",{className:"w-full max-w-md space-y-4",children:[(0,t.jsxs)("div",{className:"border rounded-xl p-5 flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{className:"text-sm font-medium",children:"Attached repositories"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Repos the local agent watches for PRs, reviews, and comments."})]}),(0,t.jsxs)("button",{type:"button",onClick:E,className:"text-xs px-2.5 py-1.5 rounded border hover:bg-accent inline-flex items-center gap-1",children:[(0,t.jsx)(u.Plus,{className:"w-3.5 h-3.5"}),"Add"]})]}),l?(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(n.Loader2,{className:"w-4 h-4 animate-spin"}),"Loading repositories…"]}):o?(0,t.jsx)("p",{className:"text-sm text-destructive",children:o}):0===r.length?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No repositories attached yet."}):(0,t.jsx)("ul",{className:"divide-y",children:r.map(e=>(0,t.jsxs)("li",{className:"flex items-center justify-between py-2",children:[(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsxs)("span",{className:"text-sm font-mono",children:[e.owner,"/",e.name]}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:[e.defaultBranch??"no default branch",e.private?" · private":" · public",e.accessRevoked?" · access revoked":""]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>B(e.id),disabled:d===e.id,className:"p-1.5 rounded hover:bg-accent disabled:opacity-50",title:"Remove",children:(0,t.jsx)(x.X,{className:"w-3.5 h-3.5"})})]},e.id))})]}),(0,t.jsxs)("div",{className:"border rounded-xl p-5 flex items-center justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{className:"text-sm font-medium",children:"Sync"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Pull the latest PRs, reviews, and comments for attached repos."})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>alert("Sync will run when worker is scheduled"),className:"text-xs px-3 py-1.5 rounded border hover:bg-accent inline-flex items-center gap-1.5",children:[(0,t.jsx)(m.RefreshCw,{className:"w-3.5 h-3.5"}),"Sync now"]})]}),f&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:F,children:(0,t.jsxs)("div",{className:"w-full max-w-3xl max-h-[90vh] flex flex-col rounded-xl border border-[var(--border)] bg-[var(--background)] text-[var(--foreground)] shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)("header",{className:"px-6 py-5 border-b border-[var(--border)] flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-[var(--muted-foreground)] mb-1",children:[(0,t.jsx)("span",{children:"GitHub"}),(0,t.jsx)("span",{children:"·"}),(0,t.jsx)("span",{children:"Attach repositories"})]}),(0,t.jsx)("h1",{className:"text-xl font-semibold tracking-tight",children:"Select repositories"}),(0,t.jsx)("p",{className:"text-sm text-[var(--muted-foreground)] mt-1",children:"Pick the repos you want agx to track. Already-attached repos are pinned at the top."})]}),(0,t.jsx)("button",{onClick:F,className:"p-1.5 rounded hover:bg-[var(--item-hover-bg)] text-[var(--muted-foreground)]","aria-label":"Close",children:(0,t.jsx)(x.X,{className:"w-4 h-4"})})]}),(0,t.jsx)("div",{className:"px-6 py-4 flex-1 overflow-hidden flex flex-col",children:w?(0,t.jsx)("div",{className:"rounded-lg border border-[var(--status-failed-border)] bg-[var(--status-failed-bg)] text-[var(--status-failed)] px-4 py-3 text-sm",children:w}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 mb-3",children:[(0,t.jsxs)("div",{className:"relative flex-1",children:[(0,t.jsxs)("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--muted-foreground)]",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,t.jsx)("path",{d:"m21 21-4.3-4.3"})]}),(0,t.jsx)("input",{type:"text",value:k,onChange:e=>C(e.target.value),placeholder:"Search repositories...",className:"w-full pl-9 pr-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--input)] text-sm focus:outline-none focus:border-[var(--primary)] focus:bg-[var(--input-focus)] transition-colors"})]}),(0,t.jsx)("div",{className:"flex gap-1 rounded-lg border border-[var(--border)] p-1",children:["all","public","private"].map(e=>(0,t.jsx)("button",{onClick:()=>L(e),className:`px-3 py-1 text-xs rounded-md capitalize transition-colors ${S===e?"bg-[var(--primary)] text-[var(--primary-foreground)]":"text-[var(--muted-foreground)] hover:text-[var(--foreground)]"}`,children:e},e))})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2 text-xs text-[var(--muted-foreground)]",children:[(0,t.jsxs)("button",{onClick:()=>{$(e=>{let t=new Set(e);return U?D.forEach(e=>t.delete(e.id)):D.forEach(e=>t.add(e.id)),t})},disabled:0===D.length,className:"hover:text-[var(--foreground)] transition-colors disabled:opacity-50",children:[U?"Deselect all":"Select all",k||"all"!==S?` (${D.length} shown)`:""]}),T.size>0&&(0,t.jsx)("button",{onClick:()=>$(new Set),className:"hover:text-[var(--foreground)] transition-colors",children:"Clear selection"})]}),(0,t.jsx)("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--card-bg)] overflow-hidden flex-1 min-h-0",children:(0,t.jsx)("div",{className:"h-full overflow-y-auto",children:j?(0,t.jsx)("div",{className:"divide-y divide-[var(--border)]",children:Array.from({length:6}).map((e,s)=>(0,t.jsxs)("div",{className:"px-4 py-3 flex items-center gap-3 animate-pulse",children:[(0,t.jsx)("div",{className:"w-4 h-4 rounded bg-[var(--muted)]"}),(0,t.jsx)("div",{className:"w-6 h-6 rounded-full bg-[var(--muted)]"}),(0,t.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,t.jsx)("div",{className:"h-3 w-1/3 rounded bg-[var(--muted)]"}),(0,t.jsx)("div",{className:"h-2 w-2/3 rounded bg-[var(--muted)]"})]})]},s))}):0===O.length?(0,t.jsx)("div",{className:"px-4 py-10 text-center text-sm text-[var(--muted-foreground)]",children:0===b.length?"No repositories found on your account.":"No repos match your search."}):(0,t.jsx)("ul",{className:"divide-y divide-[var(--border)]",children:O.map(e=>{let s=I.has(A(e.owner,e.name)),r=T.has(e.id);return(0,t.jsx)("li",{children:(0,t.jsxs)("label",{className:`flex items-start gap-3 px-4 py-3 transition-colors ${s?"bg-[var(--primary-muted)]/40 cursor-default":r?"bg-[var(--primary-muted)] cursor-pointer":"hover:bg-[var(--item-hover-bg)] cursor-pointer"}`,children:[s?(0,t.jsx)("div",{className:"mt-1 w-4 h-4 rounded-sm bg-[var(--primary)]/20 text-[var(--primary)] flex items-center justify-center",title:"Already attached",children:(0,t.jsx)(h,{className:"w-2.5 h-2.5"})}):(0,t.jsx)("input",{type:"checkbox",checked:r,onChange:()=>{!I.has(A(e.owner,e.name))&&$(t=>{let s=new Set(t);return s.has(e.id)?s.delete(e.id):s.add(e.id),s})},className:"mt-1 accent-[var(--primary)]"}),(0,t.jsx)("img",{src:e.avatarUrl,alt:"",className:"w-6 h-6 rounded-full mt-0.5 flex-shrink-0"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)("span",{className:"text-sm font-medium truncate",children:e.fullName}),s&&(0,t.jsxs)("span",{className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded bg-[var(--primary)]/15 text-[var(--primary)] flex items-center gap-1",children:[(0,t.jsx)(h,{className:"w-2.5 h-2.5"}),"Attached"]}),e.private&&(0,t.jsx)("span",{className:"text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded bg-[var(--muted)] text-[var(--muted-foreground)]",children:"Private"})]}),e.description&&(0,t.jsx)("p",{className:"text-xs text-[var(--muted-foreground)] mt-0.5 line-clamp-1",children:e.description}),(0,t.jsxs)("div",{className:"text-[11px] text-[var(--muted-foreground)] mt-0.5",children:["Updated ",function(e){let t=Math.floor((Date.now()-new Date(e).getTime())/1e3);if(t<60)return"just now";let s=Math.floor(t/60);if(s<60)return`${s}m ago`;let r=Math.floor(s/60);if(r<24)return`${r}h ago`;let a=Math.floor(r/24);if(a<30)return`${a}d ago`;let l=Math.floor(a/30);return l<12?`${l}mo ago`:`${Math.floor(l/12)}y ago`}(e.updatedAt)]})]})]})},e.id)})})})})]})}),(0,t.jsxs)("footer",{className:"px-6 py-4 border-t border-[var(--border)] flex items-center justify-between gap-3",children:[(0,t.jsxs)("span",{className:"text-sm text-[var(--muted-foreground)]",children:[T.size," selected"]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{onClick:F,className:"px-4 py-2 rounded-lg border border-[var(--border)] hover:bg-[var(--item-hover-bg)] text-sm font-medium transition-colors",children:"Cancel"}),(0,t.jsx)("button",{onClick:K,disabled:0===T.size||P,className:"px-4 py-2 rounded-lg bg-[var(--primary)] hover:bg-[var(--primary-hover)] text-[var(--primary-foreground)] text-sm font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:P?"Attaching...":`Attach ${T.size} ${1===T.size?"repo":"repos"}`})]})]})]})})]})}e.s(["Pin",()=>h],457242);var f=e.i(352687);let g={claude:{name:"Claude Code",configPath:"~/.claude/settings.json"},codex:{name:"Codex CLI",configPath:"~/.codex/config.toml"},gemini:{name:"Gemini CLI",configPath:"~/.gemini/settings.json"}};function b({trackerType:e,projectId:u,connected:x,onConnect:m,onConnectWithKey:h,onDisconnect:b,loading:v=!1,clis:j,mcpConfigured:y,onConfigureMcp:w}){let[N,k]=s.default.useState(""),[C,S]=s.default.useState(null),[L,T]=s.default.useState(!1),[$,P]=s.default.useState(!1),[M,z]=s.default.useState(null),[A,I]=s.default.useState({}),[E,F]=s.default.useState(!1),R=async e=>{if(!w)return;z(e),I(t=>({...t,[e]:""}));let t=await w(e);t.ok||I(s=>({...s,[e]:t.error??"Failed to install MCP"})),z(null)},O=j?["claude","codex","gemini"].filter(e=>j[e]):["claude"];if(v)return(0,t.jsx)("div",{className:"flex items-center justify-center p-12",children:(0,t.jsx)(n.Loader2,{className:"animate-spin h-8 w-8 text-muted-foreground"})});if(x)return(0,t.jsxs)("div",{className:"p-8 flex flex-col items-center gap-6",children:[(0,t.jsxs)("div",{className:"w-full max-w-md p-8 border border-green-500/20 bg-green-500/5 rounded-2xl flex flex-col items-center gap-4 text-center",children:[(0,t.jsx)("div",{className:"h-16 w-16 rounded-full bg-green-500/10 flex items-center justify-center text-green-600 shadow-inner",children:(0,t.jsx)(r.CheckCircle2,{className:"h-8 w-8"})}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("h3",{className:"text-xl font-bold text-foreground capitalize",children:[e," Connected"]}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground leading-relaxed",children:["Your ",e," workspace is successfully connected. The agent can now sync issues and manage your backlog."]})]}),(0,t.jsxs)("div",{className:"mt-2 px-4 py-1.5 rounded-full bg-background border text-xs font-medium text-muted-foreground flex items-center gap-2",children:[(0,t.jsx)("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500 animate-pulse"}),"Active Connection"]}),b&&(0,t.jsxs)("button",{onClick:()=>F(!0),className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-destructive transition-colors mt-1",children:[(0,t.jsx)(c.LogOut,{className:"h-3.5 w-3.5"}),"Disconnect"]})]}),"github"===e&&(0,t.jsx)(p,{projectId:u}),b&&(0,t.jsx)(f.default,{isOpen:E,title:`Disconnect ${e}?`,message:"github"===e?"This revokes the stored credentials. Your attached repositories and synced history stay — reconnecting will resume where you left off.":`This revokes the stored credentials for ${e}. Project settings and synced history stay.`,confirmLabel:"Disconnect",cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{F(!1),b()},onCancel:()=>F(!1)}),"github"!==e&&O.length>0&&(0,t.jsx)("div",{className:"w-full max-w-md",children:(0,t.jsxs)("div",{className:"border rounded-xl p-5 flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(o.Terminal,{className:"h-4 w-4 text-muted-foreground"}),(0,t.jsx)("span",{className:"text-sm font-medium",children:"MCP Server"})]}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground leading-relaxed -mt-2",children:["Install the ",e," MCP server so agents can access ",e," directly."]}),O.map(e=>{let s=g[e],a=y?.[e]??!1,l=M===e,o=A[e];return(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-foreground",children:s.name}),a?(0,t.jsxs)("span",{className:"text-xs font-medium text-green-600 flex items-center gap-1",children:[(0,t.jsx)(r.CheckCircle2,{className:"h-3.5 w-3.5"}),"Installed"]}):(0,t.jsx)("button",{onClick:()=>R(e),disabled:l||!w,className:"flex items-center gap-1.5 px-3 py-1 bg-secondary text-secondary-foreground rounded-md text-xs font-semibold hover:bg-secondary/90 disabled:opacity-50 transition-all active:scale-[0.98]",children:l?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.Loader2,{className:"h-3 w-3 animate-spin"}),"Installing…"]}):(0,t.jsx)(t.Fragment,{children:"Install"})})]}),a&&(0,t.jsxs)("p",{className:"text-[10px] text-muted-foreground",children:["Configured in ",(0,t.jsx)("code",{className:"font-mono",children:s.configPath})]}),o&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-destructive bg-destructive/10 p-2 rounded-md",children:[(0,t.jsx)(i.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),o]})]},e)})]})})]});let D=async()=>{if(N.trim()){P(!0),S(null);try{let e=await h(N.trim());e.ok?(k(""),T(!1)):S(e.error??"Failed to connect")}catch(e){S("An unexpected error occurred")}finally{P(!1)}}};return(0,t.jsxs)("div",{className:"flex flex-col items-center gap-6 p-8",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(d.TrackerIcon,{trackerType:e,className:"h-16 w-16"}),(0,t.jsx)("div",{className:"absolute -bottom-1 -right-1 h-6 w-6 rounded-full bg-background border flex items-center justify-center shadow-sm",children:(0,t.jsx)(l.Globe,{className:"h-3 w-3 text-muted-foreground"})})]}),(0,t.jsxs)("div",{className:"text-center space-y-2",children:[(0,t.jsxs)("h3",{className:"text-lg font-semibold capitalize",children:["Connect to ",e]}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground text-center max-w-sm leading-relaxed",children:["Link your ",e," account to import issues, track progress, and automate your workflow."]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 w-full max-w-xs pt-2",children:[(0,t.jsxs)("button",{onClick:m,className:"flex items-center justify-center gap-2 w-full px-4 py-2.5 bg-primary text-primary-foreground rounded-lg text-sm font-semibold hover:bg-primary/90 transition-all active:scale-[0.98] shadow-sm",children:[(0,t.jsx)(l.Globe,{className:"h-4 w-4"}),"Connect with OAuth"]}),(0,t.jsxs)("button",{onClick:()=>{T(!L),S(null)},className:"flex items-center justify-center gap-2 w-full px-4 py-2 text-sm text-muted-foreground hover:text-foreground transition-colors font-medium",children:[(0,t.jsx)(a.Key,{className:"h-3.5 w-3.5"}),L?"Use OAuth instead":"github"===e?"Connect with Personal Access Token":"Connect with API key"]}),(0,t.jsx)("div",{className:`grid transition-all duration-300 ease-in-out ${L?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0 pointer-events-none"}`,children:(0,t.jsx)("div",{className:"overflow-hidden",children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 pt-2",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"password",value:N,onChange:e=>{k(e.target.value),C&&S(null)},placeholder:"github"===e?"ghp_… or github_pat_…":"Paste your API key here",className:`w-full px-3 py-2 border rounded-lg text-sm bg-background transition-colors focus:outline-none focus:ring-2 focus:ring-primary/20 ${C?"border-destructive":"focus:border-primary"}`,onKeyDown:e=>"Enter"===e.key&&D()}),(0,t.jsx)(a.Key,{className:"absolute right-3 top-2.5 h-4 w-4 text-muted-foreground/50"})]}),C&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-destructive bg-destructive/10 p-2 rounded-md",children:[(0,t.jsx)(i.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("p",{children:C})]}),(0,t.jsx)("button",{onClick:D,disabled:$||!N.trim(),className:"flex items-center justify-center gap-2 w-full px-4 py-2 bg-secondary text-secondary-foreground rounded-lg text-sm font-semibold hover:bg-secondary/90 disabled:opacity-50 transition-all active:scale-[0.98]",children:$?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.Loader2,{className:"h-4 w-4 animate-spin"}),"Connecting..."]}):"Verify & Connect"}),(0,t.jsx)("p",{className:"text-[10px] text-muted-foreground text-center px-2",children:"github"===e?"Fine-grained PAT recommended. Needs repo access + read on issues/pull requests.":`Your API key is stored securely and only used for ${e} integration.`})]})})})]})]})}e.s(["default",()=>b],202192)},108537,e=>{"use strict";var t=e.i(762281),s=e.i(935851),r=e.i(429056),a=e.i(807087),l=e.i(711190);let n=(0,e.i(363732).default)("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);var i=e.i(202192),o=e.i(906724);let c=/^[A-Z]{2,10}$/;function d({projectId:e,trackerType:s}){return"github"===s?null:(0,t.jsx)(u,{projectId:e})}function u({projectId:e}){let[r,a]=(0,s.useState)(""),[l,n]=(0,s.useState)(null),[i,d]=(0,s.useState)(!0),[u,x]=(0,s.useState)(null),[m,h]=(0,s.useState)(null),[p,f]=(0,s.useState)(!1),[g,b]=(0,s.useState)(null),[v,j]=(0,s.useState)(null),y=(0,s.useCallback)(async()=>{d(!0);try{let t=await fetch(`/api/projects/${e}`,{cache:"no-store"});if(!t.ok)throw Error("Failed to load project");let s=await t.json(),r=s.project?.identifier_prefix??null;n(r),a(r??""),x(null)}catch{x("Failed to load project settings")}finally{d(!1)}},[e]);(0,s.useEffect)(()=>{y()},[y]);let w=(0,s.useCallback)(e=>e?c.test(e)?null:"Must be 2-10 uppercase letters (e.g. TSK, AGX).":null,[]),N=(0,s.useCallback)(async t=>{f(!0),b(null);try{let s=await fetch(`/api/projects/${e}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({identifier_prefix:t})});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e?.error??"Failed to save")}let r=await s.json(),l=r.project?.identifier_prefix??null;n(l),a(l??""),j(Date.now())}catch(e){b(e instanceof Error?e.message:"Failed to save")}finally{f(!1)}},[e]),k=(l??"")!==r.trim().toUpperCase();return(0,t.jsxs)("section",{className:"border border-zinc-200 dark:border-zinc-800 rounded-lg p-5 space-y-4 mx-6 mb-6",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-sm font-medium",children:"Task identifier prefix"}),(0,t.jsxs)("p",{className:"text-xs text-zinc-500 mt-0.5",children:["Used to identify tasks in branches, PR titles, and links (e.g."," ",(0,t.jsx)("span",{className:"font-mono",children:"TSK-42"}),"). Set once; existing tasks keep their current identifiers."]})]}),i?(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-zinc-500",children:[(0,t.jsx)(o.Loader2,{className:"w-4 h-4 animate-spin"}),"Loading..."]}):u?(0,t.jsx)("p",{className:"text-sm text-red-500",children:u}):(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{type:"text",value:r,onChange:e=>{a(e.target.value.toUpperCase()),h(null),b(null)},onBlur:e=>{h(w(e.target.value.trim().toUpperCase()))},placeholder:"TSK",maxLength:10,className:"w-40 px-2 py-1.5 text-sm font-mono rounded border border-zinc-300 dark:border-zinc-700 bg-transparent"}),(0,t.jsx)("button",{type:"button",onClick:()=>{let e=r.trim().toUpperCase(),t=w(e);t?h(t):(h(null),N(e||null))},disabled:p||!k||!!m,className:"text-xs px-3 py-1.5 rounded bg-zinc-900 text-white dark:bg-white dark:text-zinc-900 hover:opacity-90 disabled:opacity-50",children:p?"Saving...":"Save"}),l?(0,t.jsx)("button",{type:"button",onClick:()=>{h(null),N(null)},disabled:p,className:"text-xs px-3 py-1.5 rounded border border-zinc-300 dark:border-zinc-700 hover:bg-zinc-100 dark:hover:bg-zinc-800 disabled:opacity-50",children:"Clear"}):null]}),(0,t.jsxs)("p",{className:"text-xs text-zinc-500",children:["2-10 uppercase letters, matching"," ",(0,t.jsxs)("span",{className:"font-mono",children:["/^[A-Z]","{2,10}","$/"]}),"."]}),m&&(0,t.jsx)("p",{className:"text-xs text-red-500",children:m}),g&&(0,t.jsx)("p",{className:"text-xs text-red-500",children:g}),v&&!g&&!m&&(0,t.jsx)("p",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"Saved."})]})]})}var x=e.i(681619),m=e.i(524123),h=e.i(287472),p=e.i(235136);let f=[{type:"linear",label:"Linear"},{type:"jira",label:"Jira Cloud"},{type:"github",label:"GitHub"}];function g(){return(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center min-h-[calc(100vh-3.5rem)] gap-8 p-8 -mt-7 animate-pulse",children:[(0,t.jsxs)("div",{className:"space-y-3 text-center flex flex-col items-center",children:[(0,t.jsx)("div",{className:"h-7 w-56 rounded-lg bg-muted"}),(0,t.jsx)("div",{className:"h-4 w-80 rounded bg-muted"})]}),(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 w-full max-w-lg",children:[0,1].map(e=>(0,t.jsxs)("div",{className:"flex flex-col items-center gap-4 p-8 rounded-xl border border-border",children:[(0,t.jsx)("div",{className:"h-16 w-16 rounded-xl bg-muted"}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,t.jsx)("div",{className:"h-4 w-20 rounded bg-muted"}),(0,t.jsx)("div",{className:"h-3 w-24 rounded bg-muted"})]})]},e))})]})}function b(){return(0,t.jsxs)("div",{className:"flex flex-col items-center gap-6 p-8 animate-pulse",children:[(0,t.jsx)("div",{className:"h-16 w-16 rounded-xl bg-muted"}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2 w-full max-w-sm",children:[(0,t.jsx)("div",{className:"h-5 w-40 rounded bg-muted"}),(0,t.jsx)("div",{className:"h-3 w-72 rounded bg-muted"}),(0,t.jsx)("div",{className:"h-3 w-56 rounded bg-muted"})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 w-full max-w-xs pt-2",children:[(0,t.jsx)("div",{className:"h-10 w-full rounded-lg bg-muted"}),(0,t.jsx)("div",{className:"h-8 w-full rounded-lg bg-muted/60"})]})]})}function v({params:e}){let{slug:o}=(0,s.use)(e),{projects:c}=(0,m.useProjects)(),u=c.find(e=>e.slug===o),v=u?.id??"",{connections:j,defaultTracker:y,loading:w,removeConnection:N,setDefaultTracker:k}=(0,p.useTrackerConnections)(v),C=new Set(j.filter(e=>e.connected).map(e=>e.type)),S=C.size,[L,T]=(0,s.useState)(null),{connected:$,loading:P,connect:M,connectWithKey:z,disconnect:A,clis:I,mcpConfigured:E,configureMcp:F}=(0,h.useTrackerConnection)(L??"linear",v);return(0,t.jsx)("div",{className:"flex flex-col h-full bg-background",children:(0,t.jsx)("main",{className:"flex-1 overflow-auto",children:L?(0,t.jsx)("div",{className:"flex flex-col items-center px-6 py-12",children:(0,t.jsxs)("div",{className:"w-full max-w-2xl",children:[(0,t.jsxs)("button",{onClick:()=>T(null),className:"group flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground mb-8 transition-colors",children:[(0,t.jsx)(r.ArrowLeft,{className:"h-3 w-3 transition-transform group-hover:-translate-x-0.5"}),"Back to tracker picker"]}),(0,t.jsxs)("div",{className:"bg-card border rounded-xl shadow-sm overflow-hidden",children:[(0,t.jsx)("div",{className:"px-6 pt-8 pb-1 text-center",children:(0,t.jsxs)("h2",{className:"text-2xl font-semibold tracking-tight",children:["Connect ",f.find(e=>e.type===L)?.label??L]})}),P?(0,t.jsx)(b,{}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)(i.default,{projectId:v,trackerType:L,connected:$,loading:!1,onConnect:M,onConnectWithKey:z,onDisconnect:()=>{A(),T(null)},clis:I,mcpConfigured:E,onConfigureMcp:F}),(0,t.jsx)(d,{projectId:v,trackerType:L??void 0})]})]})]})}):w?(0,t.jsx)(g,{}):(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center min-h-[calc(100vh-3.5rem)] gap-8 p-8 -mt-7",children:[(0,t.jsxs)("div",{className:"space-y-2 text-center",children:[(0,t.jsx)("h2",{className:"text-2xl font-bold tracking-tight",children:"Connect Issue Tracker"}),(0,t.jsx)("p",{className:"text-muted-foreground max-w-md mx-auto",children:"Choose an issue tracker to connect to this project to enable issue tracking and agent workflows."})]}),(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 w-full max-w-lg",children:f.map(e=>{let s=C.has(e.type),r=y===e.type,i=s&&S>1&&!r&&"github"!==e.type;return(0,t.jsxs)("div",{className:"relative flex flex-col items-center gap-4 p-8 rounded-xl border transition-all duration-200 group cursor-pointer active:scale-[0.98] "+(s?r?"border-yellow-500/40 bg-yellow-500/5 hover:border-yellow-500/60 hover:bg-yellow-500/10":"border-green-500/20 bg-green-500/5 hover:border-green-500/40 hover:bg-green-500/10":"border-border hover:border-primary/50 hover:bg-accent/50 hover:shadow-md"),onClick:()=>T(e.type),children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(x.TrackerIcon,{trackerType:e.type,className:"h-16 w-16 transition-transform group-hover:scale-105"}),s&&(0,t.jsx)("div",{className:"absolute -top-1 -right-1 h-6 w-6 rounded-full bg-green-500 border-2 border-background flex items-center justify-center text-white shadow-sm",children:(0,t.jsx)(a.CheckCircle2,{className:"h-4 w-4"})})]}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-1",children:[(0,t.jsx)("span",{className:"text-base font-semibold",children:e.label}),s?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-green-600",children:["Connected",r&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded-full bg-yellow-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-yellow-700",children:[(0,t.jsx)(n,{className:"h-3 w-3 fill-yellow-500 text-yellow-500"}),"Default"]})]}):(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Click to connect"})]}),s&&(0,t.jsxs)("div",{className:"flex flex-col items-center gap-1.5",children:[i&&(0,t.jsxs)("button",{onClick:t=>{t.stopPropagation(),k(e.type)},className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[(0,t.jsx)(n,{className:"h-3.5 w-3.5"}),"Set as default"]}),(0,t.jsxs)("button",{onClick:t=>{t.stopPropagation(),N(e.type)},className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-destructive transition-colors",children:[(0,t.jsx)(l.LogOut,{className:"h-3.5 w-3.5"}),"Disconnect"]})]})]},e.type)})})]})})})}e.s(["default",()=>v],108537)}]);