hive-am 1.7.0 → 1.9.0

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 (214) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/README.md +3 -2
  3. package/package.json +1 -1
  4. package/web/.next/BUILD_ID +1 -1
  5. package/web/.next/app-build-manifest.json +150 -135
  6. package/web/.next/app-path-routes-manifest.json +5 -4
  7. package/web/.next/build-manifest.json +13 -13
  8. package/web/.next/next-server.js.nft.json +1 -1
  9. package/web/.next/prerender-manifest.json +76 -52
  10. package/web/.next/react-loadable-manifest.json +3 -3
  11. package/web/.next/required-server-files.json +7 -5
  12. package/web/.next/routes-manifest.json +6 -0
  13. package/web/.next/server/app/_not-found/page.js +2 -2
  14. package/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  15. package/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  16. package/web/.next/server/app/_not-found.html +1 -1
  17. package/web/.next/server/app/_not-found.rsc +3 -3
  18. package/web/.next/server/app/agents/[id]/page.js +4 -4
  19. package/web/.next/server/app/agents/[id]/page.js.nft.json +1 -1
  20. package/web/.next/server/app/agents/[id]/page_client-reference-manifest.js +1 -1
  21. package/web/.next/server/app/agents/page.js +2 -2
  22. package/web/.next/server/app/agents/page.js.nft.json +1 -1
  23. package/web/.next/server/app/agents/page_client-reference-manifest.js +1 -1
  24. package/web/.next/server/app/agents.html +1 -1
  25. package/web/.next/server/app/agents.rsc +5 -5
  26. package/web/.next/server/app/apple-icon.png/route.js +1 -1
  27. package/web/.next/server/app/chat/page.js +2 -2
  28. package/web/.next/server/app/chat/page.js.nft.json +1 -1
  29. package/web/.next/server/app/chat/page_client-reference-manifest.js +1 -1
  30. package/web/.next/server/app/chat.html +1 -1
  31. package/web/.next/server/app/chat.rsc +4 -4
  32. package/web/.next/server/app/colony/page.js +2 -0
  33. package/web/.next/server/app/colony/page.js.nft.json +1 -0
  34. package/web/.next/server/app/colony/page_client-reference-manifest.js +1 -0
  35. package/web/.next/server/app/colony.html +1 -0
  36. package/web/.next/server/app/colony.meta +15 -0
  37. package/web/.next/server/app/colony.rsc +25 -0
  38. package/web/.next/server/app/connections/page.js +2 -2
  39. package/web/.next/server/app/connections/page.js.nft.json +1 -1
  40. package/web/.next/server/app/connections/page_client-reference-manifest.js +1 -1
  41. package/web/.next/server/app/connections.html +1 -1
  42. package/web/.next/server/app/connections.rsc +4 -4
  43. package/web/.next/server/app/favicon.ico/route.js +1 -1
  44. package/web/.next/server/app/icon.png/route.js +1 -1
  45. package/web/.next/server/app/index.html +1 -1
  46. package/web/.next/server/app/index.rsc +4 -4
  47. package/web/.next/server/app/page.js +2 -2
  48. package/web/.next/server/app/page.js.nft.json +1 -1
  49. package/web/.next/server/app/page_client-reference-manifest.js +1 -1
  50. package/web/.next/server/app/relations/page.js +2 -2
  51. package/web/.next/server/app/relations/page.js.nft.json +1 -1
  52. package/web/.next/server/app/relations/page_client-reference-manifest.js +1 -1
  53. package/web/.next/server/app/relations.html +1 -1
  54. package/web/.next/server/app/relations.rsc +4 -4
  55. package/web/.next/server/app/resources/[id]/page.js +2 -2
  56. package/web/.next/server/app/resources/[id]/page.js.nft.json +1 -1
  57. package/web/.next/server/app/resources/[id]/page_client-reference-manifest.js +1 -1
  58. package/web/.next/server/app/resources/page.js +2 -2
  59. package/web/.next/server/app/resources/page.js.nft.json +1 -1
  60. package/web/.next/server/app/resources/page_client-reference-manifest.js +1 -1
  61. package/web/.next/server/app/resources.html +1 -1
  62. package/web/.next/server/app/resources.rsc +4 -4
  63. package/web/.next/server/app/schedules/page.js +2 -2
  64. package/web/.next/server/app/schedules/page.js.nft.json +1 -1
  65. package/web/.next/server/app/schedules/page_client-reference-manifest.js +1 -1
  66. package/web/.next/server/app/schedules.html +1 -1
  67. package/web/.next/server/app/schedules.rsc +4 -4
  68. package/web/.next/server/app/sessions/page.js +2 -2
  69. package/web/.next/server/app/sessions/page.js.nft.json +1 -1
  70. package/web/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
  71. package/web/.next/server/app/sessions.html +1 -1
  72. package/web/.next/server/app/sessions.rsc +4 -4
  73. package/web/.next/server/app/skills/page.js +2 -2
  74. package/web/.next/server/app/skills/page.js.nft.json +1 -1
  75. package/web/.next/server/app/skills/page_client-reference-manifest.js +1 -1
  76. package/web/.next/server/app/skills.html +1 -1
  77. package/web/.next/server/app/skills.rsc +4 -4
  78. package/web/.next/server/app/types/page.js +2 -2
  79. package/web/.next/server/app/types/page.js.nft.json +1 -1
  80. package/web/.next/server/app/types/page_client-reference-manifest.js +1 -1
  81. package/web/.next/server/app/types.html +1 -1
  82. package/web/.next/server/app/types.rsc +4 -4
  83. package/web/.next/server/app-paths-manifest.json +5 -4
  84. package/web/.next/server/chunks/143.js +1 -1
  85. package/web/.next/server/chunks/272.js +11 -0
  86. package/web/.next/server/chunks/345.js +2 -0
  87. package/web/.next/server/chunks/368.js +1 -1
  88. package/web/.next/server/chunks/403.js +1 -1
  89. package/web/.next/server/chunks/505.js +6 -0
  90. package/web/.next/server/chunks/561.js +1 -0
  91. package/web/.next/server/chunks/616.js +1 -0
  92. package/web/.next/server/chunks/802.js +1 -0
  93. package/web/.next/server/chunks/944.js +1 -1
  94. package/web/.next/server/chunks/953.js +2 -0
  95. package/web/.next/server/middleware-build-manifest.js +1 -1
  96. package/web/.next/server/middleware-react-loadable-manifest.js +1 -1
  97. package/web/.next/server/next-font-manifest.js +1 -1
  98. package/web/.next/server/next-font-manifest.json +1 -1
  99. package/web/.next/server/pages/404.html +1 -1
  100. package/web/.next/server/pages/500.html +1 -1
  101. package/web/.next/server/server-reference-manifest.json +1 -1
  102. package/web/.next/static/chunks/0937d497-daa99a23a4431317.js +1 -0
  103. package/web/.next/static/chunks/1517-01e286ff9d1d8ebe.js +1 -0
  104. package/web/.next/static/chunks/1606-2aa8ee5a6751f920.js +1 -0
  105. package/web/.next/static/chunks/1771-4688ad65e21bb512.js +1 -0
  106. package/web/.next/static/chunks/2547-847f3165f72a62b7.js +1 -0
  107. package/web/.next/static/chunks/2654-4aeef09c0d6bf56a.js +1 -0
  108. package/web/.next/static/chunks/{657.b4c39e676c3e20dc.js → 2657.8d96393b971ae134.js} +1 -1
  109. package/web/.next/static/chunks/2b9ff8ee-0851c7e556e3a39b.js +1 -0
  110. package/web/.next/static/chunks/3214-c9d0c933db5b0f44.js +1 -0
  111. package/web/.next/static/chunks/3757-45ea801718ec19e4.js +1 -0
  112. package/web/.next/static/chunks/3790-3d3f11a264e8ede8.js +1 -0
  113. package/web/.next/static/chunks/4030-bc2e0aa4da0d9ad8.js +1 -0
  114. package/web/.next/static/chunks/4162-c2361cb017547c37.js +1 -0
  115. package/web/.next/static/chunks/4491-49c700f509985c9e.js +1 -0
  116. package/web/.next/static/chunks/4837-8dc05d75f258f9e1.js +1 -0
  117. package/web/.next/static/chunks/5587-7e580517c4105e63.js +1 -0
  118. package/web/.next/static/chunks/5642-09dd4161ddddaf94.js +1 -0
  119. package/web/.next/static/chunks/7097.60e7ac5abf76b2cb.js +1 -0
  120. package/web/.next/static/chunks/7706-bd0d2bda0e0c8d1e.js +1 -0
  121. package/web/.next/static/chunks/8523-82e1ee6239699d8a.js +1 -0
  122. package/web/.next/static/chunks/8701.0db2914c123a180e.js +6 -0
  123. package/web/.next/static/chunks/{350-bdf6b8994a28f2b4.js → 969-ad2583a1ff30fdf0.js} +1 -1
  124. package/web/.next/static/chunks/9977-d80535fa4b24e377.js +1 -0
  125. package/web/.next/static/chunks/app/_not-found/page-d7975fab88bfe2c3.js +1 -0
  126. package/web/.next/static/chunks/app/agents/[id]/page-877114d3b3fab94d.js +1 -0
  127. package/web/.next/static/chunks/app/agents/layout-2536c0c15d09ddcf.js +1 -0
  128. package/web/.next/static/chunks/app/agents/page-0d8769f28c624f9c.js +1 -0
  129. package/web/.next/static/chunks/app/chat/page-b1569cf72e958d8b.js +1 -0
  130. package/web/.next/static/chunks/app/colony/page-ffdc123dac47ad69.js +1 -0
  131. package/web/.next/static/chunks/app/connections/{page-b0ea2eae62cef74e.js → page-2278b79b13b7fea8.js} +1 -1
  132. package/web/.next/static/chunks/app/layout-6e9bec186b02e6d7.js +1 -0
  133. package/web/.next/static/chunks/app/page-68ae166b2f8dbf94.js +1 -0
  134. package/web/.next/static/chunks/app/relations/page-a9d991b174372f37.js +1 -0
  135. package/web/.next/static/chunks/app/resources/[id]/page-48131f750e983a07.js +1 -0
  136. package/web/.next/static/chunks/app/resources/page-706d012a4c0d57ce.js +1 -0
  137. package/web/.next/static/chunks/app/schedules/page-5821c0d26afde69f.js +1 -0
  138. package/web/.next/static/chunks/app/sessions/page-6145eb19002dd390.js +1 -0
  139. package/web/.next/static/chunks/app/skills/page-b94287c3a333870d.js +1 -0
  140. package/web/.next/static/chunks/app/types/page-a991fe9afa51bdb7.js +1 -0
  141. package/web/.next/static/chunks/{fcafe1ac.366e4950d3b0d4b7.js → fcafe1ac.47e831cc63938bfb.js} +1 -1
  142. package/web/.next/static/chunks/framework-ab1d276eb4175e96.js +1 -0
  143. package/web/.next/static/chunks/main-18f19eeb8b4d3fe4.js +1 -0
  144. package/web/.next/static/chunks/main-app-27cc7ffdb888b879.js +1 -0
  145. package/web/.next/static/chunks/pages/{_app-d1670a2c6ce392fc.js → _app-8aeadc281b5934a7.js} +1 -1
  146. package/web/.next/static/chunks/pages/_error-6bffadfc60f180a1.js +1 -0
  147. package/web/.next/static/chunks/webpack-ba68c1813987a630.js +1 -0
  148. package/web/.next/static/css/93c99ed61cbded84.css +1 -0
  149. package/web/.next/static/ompymNZ0AHG5SIqLOAsGL/_buildManifest.js +1 -0
  150. package/web/.next/trace +31 -30
  151. package/web/.next/types/app/agents/[id]/page.ts +1 -1
  152. package/web/.next/types/app/agents/page.ts +1 -1
  153. package/web/.next/types/app/chat/page.ts +1 -1
  154. package/web/.next/types/app/colony/page.ts +84 -0
  155. package/web/.next/types/app/connections/page.ts +1 -1
  156. package/web/.next/types/app/page.ts +1 -1
  157. package/web/.next/types/app/relations/page.ts +1 -1
  158. package/web/.next/types/app/resources/[id]/page.ts +1 -1
  159. package/web/.next/types/app/resources/page.ts +1 -1
  160. package/web/.next/types/app/schedules/page.ts +1 -1
  161. package/web/.next/types/app/sessions/page.ts +1 -1
  162. package/web/.next/types/app/skills/page.ts +1 -1
  163. package/web/.next/types/app/types/page.ts +1 -1
  164. package/web/.next/types/routes.d.ts +2 -1
  165. package/web/.next/types/validator.ts +9 -0
  166. package/web/next.config.mjs +5 -0
  167. package/web/.next/server/chunks/111.js +0 -1
  168. package/web/.next/server/chunks/148.js +0 -1
  169. package/web/.next/server/chunks/213.js +0 -6
  170. package/web/.next/server/chunks/716.js +0 -2
  171. package/web/.next/server/chunks/741.js +0 -2
  172. package/web/.next/server/chunks/837.js +0 -1
  173. package/web/.next/server/chunks/939.js +0 -11
  174. package/web/.next/static/chunks/0937d497-114a2a3de515565e.js +0 -1
  175. package/web/.next/static/chunks/162-68ba190086f5ad39.js +0 -1
  176. package/web/.next/static/chunks/214-35b88db02113ae02.js +0 -1
  177. package/web/.next/static/chunks/281-a855bf409ef9eebd.js +0 -1
  178. package/web/.next/static/chunks/2b9ff8ee-969e65cc354b2150.js +0 -1
  179. package/web/.next/static/chunks/30-9adcbe92b15a6815.js +0 -1
  180. package/web/.next/static/chunks/491-196bcb3dd11bb460.js +0 -1
  181. package/web/.next/static/chunks/517-8f2db464d10a4624.js +0 -1
  182. package/web/.next/static/chunks/587-3c53d91a1c4f99d6.js +0 -1
  183. package/web/.next/static/chunks/606-14fb5aaa4d0ff22d.js +0 -1
  184. package/web/.next/static/chunks/642-dc874c8caf203ee1.js +0 -1
  185. package/web/.next/static/chunks/654-92a63b3c4b412666.js +0 -1
  186. package/web/.next/static/chunks/701.6abcaf5e60463eef.js +0 -6
  187. package/web/.next/static/chunks/706-fa2be0f10ffebe6a.js +0 -1
  188. package/web/.next/static/chunks/757-03361e7a97a605a2.js +0 -1
  189. package/web/.next/static/chunks/771-db19da9b1a24820c.js +0 -1
  190. package/web/.next/static/chunks/837-33c7480524f48577.js +0 -1
  191. package/web/.next/static/chunks/928-09d4a58e977641dc.js +0 -1
  192. package/web/.next/static/chunks/97.594543c2196de524.js +0 -1
  193. package/web/.next/static/chunks/app/_not-found/page-238a7b80bda6b4ae.js +0 -1
  194. package/web/.next/static/chunks/app/agents/[id]/page-9f191f25a366b26b.js +0 -1
  195. package/web/.next/static/chunks/app/agents/layout-71dd98d696935e29.js +0 -1
  196. package/web/.next/static/chunks/app/agents/page-9da499db6d22731f.js +0 -1
  197. package/web/.next/static/chunks/app/chat/page-383bc24e72dab7fa.js +0 -1
  198. package/web/.next/static/chunks/app/layout-cb5af29b0742c513.js +0 -1
  199. package/web/.next/static/chunks/app/page-5e547e87de23d9fa.js +0 -1
  200. package/web/.next/static/chunks/app/relations/page-02710fe1f8a670a9.js +0 -1
  201. package/web/.next/static/chunks/app/resources/[id]/page-1e2afddcb1f04884.js +0 -1
  202. package/web/.next/static/chunks/app/resources/page-195b0af83b8ace0d.js +0 -1
  203. package/web/.next/static/chunks/app/schedules/page-96976fff4ee23538.js +0 -1
  204. package/web/.next/static/chunks/app/sessions/page-f5a98ec3eaffd7a6.js +0 -1
  205. package/web/.next/static/chunks/app/skills/page-bc1acd0663f36129.js +0 -1
  206. package/web/.next/static/chunks/app/types/page-c4c2b2217c4667e8.js +0 -1
  207. package/web/.next/static/chunks/framework-bbac72adbbe2d328.js +0 -1
  208. package/web/.next/static/chunks/main-app-6086068e5fb5eacd.js +0 -1
  209. package/web/.next/static/chunks/main-c15f3fee674e0303.js +0 -1
  210. package/web/.next/static/chunks/pages/_error-95aac014d202fa7a.js +0 -1
  211. package/web/.next/static/chunks/webpack-ef515e41a83a16ac.js +0 -1
  212. package/web/.next/static/css/f5438d03b796884e.css +0 -1
  213. package/web/.next/static/gqk-RaeJBRWW1cWGRixT2/_buildManifest.js +0 -1
  214. /package/web/.next/static/{gqk-RaeJBRWW1cWGRixT2 → ompymNZ0AHG5SIqLOAsGL}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9492],{6119:(e,t,l)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/_not-found/page",function(){return l(81380)}])},33762:(e,t,l)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"HTTPAccessErrorFallback",{enumerable:!0,get:function(){return o}});let r=l(94799),n=l(45525);function o(e){let{status:t,message:l}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("title",{children:t+": "+l}),(0,r.jsx)("div",{style:n.styles.error,children:(0,r.jsxs)("div",{children:[(0,r.jsx)("style",{dangerouslySetInnerHTML:{__html:"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}),(0,r.jsx)("h1",{className:"next-error-h1",style:n.styles.h1,children:t}),(0,r.jsx)("div",{style:n.styles.desc,children:(0,r.jsx)("h2",{style:n.styles.h2,children:l})})]})})]})}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},45525:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"styles",{enumerable:!0,get:function(){return l}});let l={error:{fontFamily:'system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"',height:"100vh",textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},desc:{display:"inline-block"},h1:{display:"inline-block",margin:"0 20px 0 0",padding:"0 23px 0 0",fontSize:24,fontWeight:500,verticalAlign:"top",lineHeight:"49px"},h2:{fontSize:14,fontWeight:400,lineHeight:"49px",margin:0}};("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},81380:(e,t,l)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return o}});let r=l(94799),n=l(33762),o=function(){return(0,r.jsx)("html",{children:(0,r.jsx)("body",{children:(0,r.jsx)(n.HTTPAccessErrorFallback,{status:404,message:"This page could not be found."})})})};("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)}},e=>{e.O(0,[7408,89,7358],()=>e(e.s=6119)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3969],{41530:(e,t,s)=>{"use strict";s.d(t,{O:()=>i,v:()=>c});var n=s(34023),a=s(65751),l=s(91656);function i(){let[e,t]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{var e;let s=navigator;t((0,l.fU)((null==(e=s.userAgentData)?void 0:e.platform)||s.platform||s.userAgent))},[]),e}function c(e,t,s){let i=(0,n.useRef)({handlers:e,paletteOpen:t,mac:s});i.current={handlers:e,paletteOpen:t,mac:s},(0,n.useEffect)(()=>{let e=e=>{let t=e.target instanceof Element?e.target:null,s=(0,l.Oq)(e,{mac:i.current.mac,inField:!!t&&(t.matches('input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="combobox"]')||t instanceof HTMLElement&&t.isContentEditable),inOwn:!!(null==t?void 0:t.closest('[data-hotkeys="own"]')),layers:(0,a.Ot)(),paletteOpen:i.current.paletteOpen,menuOpen:!!document.querySelector('[role="menu"]')});s&&(e.preventDefault(),i.current.handlers[s]())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[])}},46912:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>tW});var n=s(94799),a=s(20422),l=s(89128),i=s(34023),c=s(41463),r=s.n(c),o=s(43624),d=s(75406),u=s(87454),h=s(32098),m=s(68449),g=s(97541),x=s(48538),p=s(3749),f=s(47890),j=s(54609),b=s(77021),v=s(61748),N=s(22547);let y="hive-am.diffc.",k=e=>"".concat(y).concat(e);function w(e){let t=0x811c9dc5;for(let s=0;s<e.length;s++)t^=e.charCodeAt(s),t=Math.imul(t,0x1000193);return(t>>>0).toString(16).padStart(8,"0")}let C=e=>w("".concat(e.kind,"\0").concat(e.text)),S=e=>w(e.map(e=>"".concat(e.kind,"\0").concat(e.text)).join("\n"));function A(e){let t=t=>e.map(t).filter(e=>void 0!==e),s=t(e=>e.newNo),n=t(e=>e.oldNo),a=e=>e.length?{from:Math.min(...e),to:Math.max(...e)}:null,l=a(s),i=a(n);return{newFrom:null==l?void 0:l.from,newTo:null==l?void 0:l.to,oldFrom:null==i?void 0:i.from,oldTo:null==i?void 0:i.to,removed:!l}}function E(e,t){var s,n;let a=null!=(s=e.removed?e.oldFrom:e.newFrom)?s:0,l=null!=(n=e.removed?e.oldTo:e.newTo)?n:a;return e.removed?a===l?t("diffc.range.removedOne",{n:a}):t("diffc.range.removedMany",{from:a,to:l}):a===l?t("diffc.range.one",{n:a}):t("diffc.range.many",{from:a,to:l})}let z=e=>{var t,s;return null!=(s=null!=(t=e.newFrom)?t:e.oldFrom)?s:0};function M(e){if(e.length<=1e3)return e;let t=e.slice(0,1e3),s=t.charCodeAt(t.length-1);return s>=55296&&s<=56319?t.slice(0,-1):t}function F(e,t,s,n,a){return{id:a,path:e,text:M(s),at:n,...A(t),quote:t.slice(0,3).map(e=>({kind:e.kind,text:((e,t)=>{let s=Array.from(e);return s.length>t?s.slice(0,t-1).join("")+"…":e})(e.text.trimEnd(),120)})),count:t.length,first:C(t[0]),sig:S(t),outdated:!1,gone:!1}}function R(e,t){let s=z(t),n=null,a=1/0;for(let l=0;l<e.hunks.length;l++){let i=e.hunks[l].lines;for(let e=0;e+t.count<=i.length;e++){if(C(i[e])!==t.first)continue;let c=i.slice(e,e+t.count);if(S(c)!==t.sig)continue;let r=Math.abs(z(A(c))-s);r<a&&(n={hunk:l,start:e},a=r)}}return n}let P={add:"+",del:"-",ctx:" "};function I(e,t){let s=[...e].sort((e,t)=>e.path<t.path?-1:e.path>t.path?1:z(e)-z(t)),n=[t("diffc.msg.head",{count:s.length})];return s.some(e=>e.removed)&&n.push(t("diffc.msg.legendLines")),s.some(e=>e.outdated)&&n.push(t("diffc.msg.legendOutdated")),n.push(""),s.forEach((e,s)=>{let a=[e.removed&&t("diffc.msg.removed"),e.outdated&&t("diffc.msg.outdated")].filter(Boolean).join(", "),[l,...i]=e.text.replace(/\r\n?/g,"\n").trim().split("\n");for(let t of(n.push("".concat(s+1,". ").concat(e.path,":").concat(function(e){let t=e.removed?e.oldFrom:e.newFrom,s=e.removed?e.oldTo:e.newTo;return t===s?"".concat(t):"".concat(t,"-").concat(s)}(e)).concat(a?" (".concat(a,")"):"",": ").concat(l)),i))n.push(t.trim()?" "+t:"");for(let s of(n.push(" "+t("diffc.msg.code")),e.quote))n.push("".concat(" ","> ").concat(P[s.kind]," ").concat(s.text).trimEnd());e.count>3&&n.push("".concat(" ","> ").concat(t("diffc.msg.more",{count:e.count-3})))}),n.join("\n")}let D=e=>!!e&&"object"==typeof e&&"string"==typeof e.id&&"string"==typeof e.path&&"string"==typeof e.text&&"number"==typeof e.at&&Array.isArray(e.quote)&&"string"==typeof e.sig;var T=s(44738),L=s(14214),U=s(84611),_=s(29718),H=s(8089),K=s(50352),O=s(12349),W=s(56072),q=s(69654);function B(e){var t,s,a,l,c,r,o,d,u,h;let{agent:m,session:g}=e,{t:f}=(0,q.s9)(),{finished:j,live:b}=(0,x.o0)(),[v,N]=(0,i.useState)(null),[y,k]=(0,i.useState)(!1),w=null!=(t=j[m.id])?t:0,C=b[m.id];if((0,i.useEffect)(()=>{if(!m.session_id&&!g)return void N(null);p.FH.get("/agents/".concat(m.id,"/stats").concat(g?"?session=".concat(encodeURIComponent(g)):"")).then(N).catch(()=>void 0)},[m.id,m.session_id,g,w]),!v||0===v.turns&&!C)return null;let S=null==C?void 0:C.usage,A=(0,W.RP)(v.usage)+(S?(0,W.RP)({input:null!=(s=S.input)?s:0,output:null!=(a=S.output)?a:0,cacheRead:null!=(l=S.cacheRead)?l:0,cacheWrite:null!=(c=S.cacheWrite)?c:0}):0),E=(null!=(r=v.cost)?r:0)+(null!=(o=null==C?void 0:C.cost)?o:0),z=(null!=(d=v.usage.credits)?d:0)+(null!=(u=null==S?void 0:S.credits)?u:0),M=null!=(h=null==S?void 0:S.contextPct)?h:v.contextPct,F=null!==v.cost||(null==C?void 0:C.cost)!==void 0,R=v.usage,P=Math.max(1,R.input+R.output+R.cacheRead+R.cacheWrite),I=Math.max(1,...v.tools.map(e=>e.count)),D=Math.max(1,...v.timeline.map(e=>e.tokens));return(0,n.jsxs)("div",{className:"stats-wrap",children:[(0,n.jsxs)("button",{className:"statsbar",onClick:()=>k(e=>!e),"aria-expanded":y,children:[(0,n.jsxs)("span",{className:"sb",title:"".concat(f("stats.contextTitle")," \xb7 ").concat((0,W.yj)(v.lastContext)).concat(v.contextWindow?" / ".concat((0,W.yj)(v.contextWindow)):""),children:[(0,n.jsx)(T.A,{size:14}),(0,n.jsx)("b",{children:null!==M?"".concat(M.toFixed(+(M<10)),"%"):(0,W.yj)(v.lastContext)}),f("stats.context")]}),(0,n.jsxs)("span",{className:"sb",children:[(0,n.jsx)(L.A,{size:14}),(0,n.jsx)("b",{children:(0,W.yj)(A)}),f("stats.tokens")]}),z>0&&(0,n.jsxs)("span",{className:"sb",children:[(0,n.jsx)(U.A,{size:14}),(0,n.jsx)("b",{children:z.toFixed(2)}),f("stats.credits")]}),F&&(0,n.jsxs)("span",{className:"sb",title:v.costEstimated?f("stats.costEstimated"):f("stats.costReported"),children:[(0,n.jsx)(U.A,{size:14}),(0,n.jsxs)("b",{children:[v.costEstimated?"≈ ":"",(0,W.F0)(E)]})]}),(0,n.jsxs)("span",{className:"sb",children:[(0,n.jsx)(_.A,{size:14}),(0,n.jsx)("b",{children:v.turns}),f("stats.turns",{count:v.turns})]}),(0,n.jsxs)("span",{className:"sb",children:[(0,n.jsx)(H.A,{size:14}),(0,n.jsx)("b",{children:v.toolCalls}),f("stats.toolCalls",{count:v.toolCalls}),v.toolErrors>0&&(0,n.jsxs)("em",{className:"tbad",children:[" \xb7 ",f("stats.failed",{count:v.toolErrors})]})]}),v.durationMs>0&&(0,n.jsxs)("span",{className:"sb",children:[(0,n.jsx)(K.A,{size:14}),(0,n.jsx)("b",{children:(0,W.nc)(v.durationMs)}),f("stats.working")]}),(0,n.jsx)(O.A,{size:15,className:"chev2 ".concat(y?"open":"")})]}),y&&(0,n.jsxs)("div",{className:"statspanel",children:[(0,n.jsxs)("section",{children:[(0,n.jsx)("div",{className:"eyebrow",children:f("stats.mix")}),(0,n.jsxs)("div",{className:"mixbar",role:"img","aria-label":f("stats.mix"),children:[(0,n.jsx)("i",{className:"fa-c-cr",style:{width:"".concat(R.cacheRead/P*100,"%")}}),(0,n.jsx)("i",{className:"fa-c-cw",style:{width:"".concat(R.cacheWrite/P*100,"%")}}),(0,n.jsx)("i",{className:"fa-c-in",style:{width:"".concat(R.input/P*100,"%")}}),(0,n.jsx)("i",{className:"fa-c-out",style:{width:"".concat(R.output/P*100,"%")}})]}),(0,n.jsxs)("dl",{className:"legend",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("i",{className:"fa-c-cr"}),(0,n.jsx)("dt",{children:f("stats.cacheRead")}),(0,n.jsx)("dd",{children:(0,W.yj)(R.cacheRead)})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("i",{className:"fa-c-cw"}),(0,n.jsx)("dt",{children:f("stats.cacheWrite")}),(0,n.jsx)("dd",{children:(0,W.yj)(R.cacheWrite)})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("i",{className:"fa-c-in"}),(0,n.jsx)("dt",{children:f("stats.input")}),(0,n.jsx)("dd",{children:(0,W.yj)(R.input)})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("i",{className:"fa-c-out"}),(0,n.jsx)("dt",{children:f("stats.output")}),(0,n.jsxs)("dd",{children:[(0,W.yj)(R.output),R.reasoning>0&&(0,n.jsxs)("span",{className:"muted",children:[" (",f("stats.thinking",{tokens:(0,W.yj)(R.reasoning)}),")"]})]})]})]}),v.models.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"eyebrow mt-m",children:f("stats.models")}),v.models.map(e=>(0,n.jsxs)("div",{className:"row small between",children:[(0,n.jsx)("span",{className:"mono",children:e.model}),(0,n.jsx)("span",{className:"muted",children:f("stats.modelLine",{count:e.messages,out:(0,W.yj)(e.output)})})]},e.model))]})]}),(0,n.jsxs)("section",{children:[(0,n.jsxs)("div",{className:"eyebrow",children:[f("stats.toolsUsed")," ",v.toolTimeMs>0&&(0,n.jsxs)("span",{className:"muted",children:["\xb7 ",f("stats.totalTime",{time:(0,W.nc)(v.toolTimeMs)})]})]}),0===v.tools.length?(0,n.jsx)("p",{className:"muted small m0 mt-s",children:f("stats.noTools")}):v.tools.slice(0,9).map(e=>(0,n.jsxs)("div",{className:"toolrow",title:f("stats.toolTitle",{count:e.count,time:(0,W.nc)(e.totalMs)}),children:[(0,n.jsx)("span",{className:"mono tn",children:e.name.replace(/^mcp__/,"").replace("__"," \xb7 ")}),(0,n.jsx)("span",{className:"tbar",children:(0,n.jsx)("i",{style:{width:"".concat(e.count/I*100,"%")}})}),(0,n.jsxs)("span",{className:"tc",children:[e.count,e.errors>0&&(0,n.jsxs)("em",{className:"tbad",children:[" (",e.errors,"✗)"]})]}),(0,n.jsx)("span",{className:"td muted",children:e.totalMs?(0,W.nc)(e.totalMs/e.count):""})]},e.name))]}),(0,n.jsxs)("section",{className:"fa-span",children:[(0,n.jsx)("div",{className:"eyebrow",children:f("stats.perTurn")}),(0,n.jsx)("div",{className:"tbars",role:"list",children:v.timeline.slice(-40).map((e,t)=>(0,n.jsx)("div",{className:"sbar",role:"listitem",title:"".concat(e.prompt||f("stats.promptFallback"),"\n").concat(f("stats.turnLine",{tokens:(0,W.yj)(e.tokens),tools:e.tools,time:(0,W.nc)(e.durationMs)})).concat(null!==e.cost?" \xb7 ".concat((0,W.F0)(e.cost)):""),children:(0,n.jsx)("i",{style:{height:"".concat(Math.max(4,e.tokens/D*100),"%")}})},t))})]})]})]})}var $=s(29416),Q=s(59959),G=s(83372),J=s(47405),X=s(6673),Z=s(7991),V=s(31606),Y=s(74988),ee=s(52974),et=s(11580);let es=["error","starting","running","ready","stopped","unknown"];function en(e){let{agent:t}=e,{t:s}=(0,q.s9)(),{objects:a}=(0,x.o0)(),l=(0,et.dj)(),[c,o]=(0,b.ud)("hive-am.chat.resources",!1),[d,u]=(0,b.ud)("hive-am.chat.resources.scope","mine"),[h,m]=(0,i.useState)(null);if(0===a.length)return null;let g=a.filter(e=>{var s,n;return e.manager_id===t.id||(null!=(s=e.colony_id)?s:null)===(null!=(n=t.colony_id)?n:null)}),f="all"===d||0===g.length,j=f?a:g,v=e=>j.filter(t=>t.state.status===e).length,N=async(e,t)=>{m("".concat(e.id,":").concat(t));try{await p.FH.post("/objects/".concat(e.id,"/action"),{action:t})}catch(e){l("".concat(s("obj.act.failed",{action:s("obj.act.".concat(t))}),": ").concat(e instanceof Error?e.message:""),"err")}finally{m(null)}};return(0,n.jsxs)("div",{className:"cres",children:[(0,n.jsxs)("button",{type:"button",className:"cres-head","aria-expanded":c,onClick:()=>o(!c),children:[(0,n.jsx)($.A,{size:15,"aria-hidden":!0}),(0,n.jsx)("b",{children:s("cres.title")}),(0,n.jsx)("span",{className:"cres-sum",children:es.filter(e=>v(e)>0).map(e=>(0,n.jsxs)("span",{className:"cres-n ".concat(Y.Wy[e]),children:[(0,n.jsx)(V.md,{status:e}),v(e)," ",(0,n.jsx)("em",{children:s("cres.n.".concat(e))})]},e))}),(0,n.jsx)(O.A,{size:15,className:"chev2 ".concat(c?"open":""),"aria-hidden":!0})]}),c&&(0,n.jsxs)("div",{className:"cres-body",children:[g.length>0&&g.length<a.length&&(0,n.jsxs)("div",{className:"seg cres-scope",role:"group","aria-label":s("cres.scope"),children:[(0,n.jsx)("button",{type:"button","aria-pressed":!f,onClick:()=>u("mine"),children:s("cres.mine",{a1:String(g.length)})}),(0,n.jsx)("button",{type:"button","aria-pressed":f,onClick:()=>u("all"),children:s("cres.all",{a1:String(a.length)})})]}),0===g.length&&(0,n.jsx)("p",{className:"muted small cres-note",children:s("cres.none")}),(0,n.jsx)("ul",{className:"cres-grid",children:j.map(e=>{var t;let a=Y.Nd[e.kind].icon,l=e.state.status,i="running"===l||"starting"===l,c=ee.no.includes(e.kind),o=null!=(t=null==h?void 0:h.startsWith("".concat(e.id,":")))&&t,d=(0,Y.HS)(s,e.state.detail);return(0,n.jsxs)("li",{className:"cres-card ".concat(Y.Wy[l]),children:[(0,n.jsx)("span",{className:"cres-ico",style:{"--c":Y.Nd[e.kind].color},children:(0,n.jsx)(a,{size:16,"aria-hidden":!0})}),(0,n.jsxs)("div",{className:"cres-info",children:[(0,n.jsx)(r(),{className:"cres-name",href:"/resources/".concat(e.id),title:s("obj.open"),children:e.name}),(0,n.jsxs)("span",{className:"cres-st ".concat(Y.Wy[l]),title:d||void 0,children:[(0,n.jsx)(V.md,{status:l}),s("obj.status.".concat(l)),d&&"error"===l?(0,n.jsx)("em",{children:d}):null]})]}),(0,n.jsxs)("div",{className:"cres-act",children:[o&&(0,n.jsx)(Q.A,{size:14,className:"spin muted","aria-hidden":!0}),c&&(i?(0,n.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:!!h,onClick:()=>void N(e,"stop"),"aria-label":s("obj.act.stop"),title:s("obj.act.stop"),children:(0,n.jsx)(G.A,{size:14})}):(0,n.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:!!h,onClick:()=>void N(e,"start"),"aria-label":s("obj.act.start"),title:s("obj.act.start"),children:(0,n.jsx)(J.A,{size:14})})),c&&(0,n.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:!!h,onClick:()=>void N(e,"restart"),"aria-label":s("obj.act.restart"),title:s("obj.act.restart"),children:(0,n.jsx)(X.A,{size:14})}),(0,n.jsx)(r(),{className:"btn ghost icon sm",href:"/resources/".concat(e.id),"aria-label":s("obj.open"),title:s("obj.open"),children:(0,n.jsx)(Z.A,{size:14})})]})]},e.id)})})]})]})}var ea=s(10969),el=s(94227),ei=s(89075),ec=s(10776),er=s(79141),eo=s(12582),ed=s(58311),eu=s(25661),eh=s(68979),em=s(76844);function eg(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=new Map(t.map(e=>[e.path,e])),l=new Set(e);for(let e of t)l.add(e.path);let i={name:"",path:"",type:"dir",children:[],changed:0,additions:0,deletions:0},c=new Map([["",i]]),r=e=>{let t=c.get(e);if(t)return t;let s=e.lastIndexOf("/"),n=r(s<0?"":e.slice(0,s)),a={name:e.slice(s+1),path:e,type:"dir",children:[],changed:0,additions:0,deletions:0};return n.children.push(a),c.set(e,a),a};for(let e of l){var o,d,u,h;let t=e.lastIndexOf("/");r(t<0?"":e.slice(0,t)).children.push({name:e.slice(t+1),path:e,type:"file",children:[],change:a.get(e),changed:+!!a.has(e),additions:null!=(u=null==(o=a.get(e))?void 0:o.additions)?u:0,deletions:null!=(h=null==(d=a.get(e))?void 0:d.deletions)?h:0})}let m=(e,t,s)=>{var a;if(e.children.some(e=>e.path===t))return;let l={name:t.slice(t.lastIndexOf("/")+1),path:t,type:s?"dir":"file",children:[],ignored:!0,lazy:s&&!(t in n),changed:0,additions:0,deletions:0};if(e.children.push(l),s&&c.set(t,l),s)for(let e of null!=(a=n[t])?a:[])m(l,"".concat(t,"/").concat(e.name),e.dir)};for(let e of s){let t=e.endsWith("/"),s=t?e.slice(0,-1):e,n=s.lastIndexOf("/");m(r(n<0?"":s.slice(0,n)),s,t)}let g=e=>{for(let t of(e.children.sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):"dir"===e.type?-1:1),e.children))"dir"===t.type&&g(t),e.changed+=(t.type,t.changed),e.additions+=t.additions,e.deletions+=t.deletions;e.children=e.children.map(e=>{let t=e;for(;"dir"===t.type&&1===t.children.length&&"dir"===t.children[0].type;){let e=t.children[0];t={...e,name:"".concat(t.name,"/").concat(e.name)}}return t})};return g(i),i}function ex(e,t,s){let n=s.query.trim().toLowerCase(),a=e=>(!s.onlyChanged||0!==e.changed)&&(!n||("file"===e.type?e.path.toLowerCase().includes(n):e.children.some(a))),l=[],i=(e,c)=>{for(let r of e.children)a(r)&&(l.push({node:r,depth:c}),"dir"===r.type&&(n||s.onlyChanged||t.has(r.path))&&i(r,c+1))};return i(e,0),l}var ep=s(39696),ef=s(78060),ej=s(61),eb=s(80306),ev=s(6458),eN=s(53983);let ey=/\.(png|jpe?g|gif|webp|svg|ico|bmp|avif)$/i,ek=/\.(md|markdown|mdx)$/i;var ew=s(32480),eC=s(70665);function eS(e){let t={meta:[],hunks:[],binary:!1},s=null,n=0,a=0;for(let i of e.split("\n")){let e=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@ ?(.*)$/.exec(i);if(e){var l;n=Number(e[1]),a=Number(e[2]),s={header:i,section:null!=(l=e[3])?l:"",lines:[]},t.hunks.push(s);continue}if(!s){/^Binary files .* differ$/.test(i)||i.startsWith("GIT binary patch")?t.binary=!0:(/^(rename|copy) (from|to) /.test(i)||/^(new|deleted) file mode/.test(i)||/^similarity index/.test(i))&&t.meta.push(i);continue}let c=i[0];if("+"===c)s.lines.push({kind:"add",newNo:a++,text:i.slice(1)});else if("-"===c)s.lines.push({kind:"del",oldNo:n++,text:i.slice(1)});else if(" "===c)s.lines.push({kind:"ctx",oldNo:n++,newNo:a++,text:i.slice(1)});else if("\\"===c){let e=s.lines[s.lines.length-1];e&&(e.noEol=!0)}}return t}let eA=e=>{var t,s;return null!=(s=null==(t=/^(@@ [^@]+@@)/.exec(e))?void 0:t[1])?s:e};var eE=s(3218),ez=s(97254),eM=s(55267),eF=s(69962),eR=s(41530),eP=s(97356),eI=s(66654),eD=s(7697);function eT(){let[e,t]=(0,i.useState)(""),s=(0,i.useRef)(void 0),n=(0,i.useRef)(0),a=(0,i.useCallback)(e=>{clearTimeout(s.current),t(""),s.current=setTimeout(()=>{n.current=Date.now(),t(e)},Math.max(0,n.current+500-Date.now()))},[]);return(0,i.useEffect)(()=>()=>clearTimeout(s.current),[]),[e,a]}let eL=e=>e.slice(e.lastIndexOf("/")+1);function eU(e){let{path:t,range:s,initial:a,saved:l,editing:c,locked:r,mac:o,onChange:d,onSave:h,onCancel:m,onDelete:g}=e,{t:x}=(0,q.s9)(),[p,f]=(0,i.useState)(a),[j,b]=(0,i.useState)(!1),v=(0,i.useRef)(null),N=(0,i.useRef)(null),y=(0,i.useRef)(null),k=(0,i.useId)(),w=p!==l&&!(""===l&&!p.trim());(0,i.useEffect)(()=>{var e;null==(e=v.current)||e.focus({preventScroll:!0})},[]),(0,i.useEffect)(()=>{var e;j&&(null==(e=N.current)||e.focus())},[j]),(0,i.useLayoutEffect)(()=>{let e=v.current;if(!e)return;e.style.height="auto";let t=parseFloat(getComputedStyle(e).lineHeight)||20;e.style.height="".concat(Math.min(e.scrollHeight,8*t+16),"px")},[p]),(0,i.useEffect)(()=>{let e=window.visualViewport;if(!e)return;let t=()=>{var t;return null==(t=y.current)?void 0:t.style.setProperty("--dc-kb","".concat(Math.max(0,window.innerHeight-e.height-e.offsetTop),"px"))};return t(),e.addEventListener("resize",t),e.addEventListener("scroll",t),()=>{e.removeEventListener("resize",t),e.removeEventListener("scroll",t)}},[]);let C=()=>{w?b(!0):m()},S=()=>{p.trim()&&h(p)},A=1e3-p.length;return(0,n.jsxs)("div",{ref:y,className:"vl-peek dc-editor",role:"group","aria-label":x("diffc.editor.title",{file:eL(t),range:s}),onKeyDown:e=>{if("Escape"===e.key)if(e.preventDefault(),e.stopPropagation(),j){var t;b(!1),null==(t=v.current)||t.focus()}else C();else"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&!j&&(e.preventDefault(),S())},inert:r,children:[(0,n.jsxs)("div",{className:"vl-peek-head",children:[(0,n.jsx)(u.A,{size:13,"aria-hidden":!0}),(0,n.jsx)("b",{title:t,children:eL(t)}),(0,n.jsx)("span",{className:"muted",children:s})]}),(0,n.jsxs)("div",{className:"dc-ed-body",children:[(0,n.jsx)("label",{htmlFor:k,className:"sr-only",children:x("diffc.editor.label")}),(0,n.jsx)("textarea",{ref:v,id:k,className:"input dc-text",rows:3,maxLength:1e3,value:p,onChange:e=>{var t;f(t=e.target.value),d(t)},placeholder:x("diffc.editor.placeholder"),"aria-describedby":"".concat(k,"-hint")}),A<=200&&(0,n.jsx)("p",{className:"dc-left","aria-live":"polite",children:x("diffc.editor.left",{count:A})}),j?(0,n.jsxs)("div",{className:"dc-ask",role:"group","aria-label":x("diffc.editor.discard"),children:[(0,n.jsx)("span",{className:"grow",children:x("diffc.editor.discard")}),(0,n.jsx)("button",{ref:N,type:"button",className:"btn sm",onClick:()=>{var e;b(!1),null==(e=v.current)||e.focus()},children:x("diffc.editor.keep")}),(0,n.jsx)("button",{type:"button",className:"btn sm danger",onClick:m,children:x("diffc.editor.drop")})]}):(0,n.jsxs)("div",{className:"dc-ed-foot",children:[c&&g&&(0,n.jsxs)("button",{type:"button",className:"btn ghost sm danger",onClick:g,children:[(0,n.jsx)(eP.A,{size:13}),x("diffc.delete")]}),(0,n.jsx)("span",{className:"grow dc-ed-hint",id:"".concat(k,"-hint"),children:x("diffc.editor.hint",{keys:o?"⌘ Enter":"Ctrl+Enter"})}),(0,n.jsx)("button",{type:"button",className:"btn ghost sm",onClick:C,children:x("common.cancel")}),(0,n.jsx)("button",{type:"button",className:"btn primary sm",disabled:!p.trim(),onClick:S,children:x(c?"diffc.editor.save":"diffc.editor.add")})]})]})]})}function e_(e){let{ctl:t,sending:s,setSending:a,onGoTo:l}=e,{t:c}=(0,q.s9)(),{items:r}=t,[o,d]=(0,i.useState)(!1),[h,m]=(0,i.useState)(!1),[g,x]=(0,i.useState)(!1),[p,f]=(0,i.useState)(null),[j,b]=(0,i.useState)(null),[v,N]=eT(),y=(0,i.useRef)(null),k=(0,i.useRef)(null),w=(0,i.useId)(),[C,S]=function(){let[e,t]=(0,i.useState)(null),[s,n]=(0,i.useState)();return(0,i.useEffect)(()=>{if(!e)return;let t=e.parentElement;for(;t&&!/auto|scroll|hidden/.test(getComputedStyle(t).overflowX);)t=t.parentElement;let s=null!=t?t:document.documentElement,a=()=>n(s.clientWidth),l=new ResizeObserver(a);return l.observe(s),a(),()=>l.disconnect()},[e]),[t,s?{"--dc-vw":"".concat(s,"px")}:void 0]}();(0,i.useEffect)(()=>{if(!j)return;let e=setTimeout(()=>b(null),8e3);return()=>clearTimeout(e)},[j]),(0,i.useEffect)(()=>{var e;p&&(null==(e=k.current)||e.focus())},[p]),(0,i.useEffect)(()=>{r.length||(d(!1),m(!1))},[r.length]);let A=async()=>{if(s||t.readOnly||!r.length)return;let e=t.busy,n=t.agentName;a(!0),f(null);let l=await t.send(I(r,c));a(!1),l.ok?(t.clear(),b({queued:e,name:n})):f(l.error)},M=(0,n.jsx)("div",{className:"sr-only","aria-live":"polite",children:v});if(!r.length)return j?(0,n.jsxs)("div",{ref:C,style:S,className:"dc-bar done",role:"region","aria-label":c("diffc.bar.label"),children:[M,(0,n.jsxs)("div",{className:"dc-sent",role:"status",children:[(0,n.jsx)("span",{className:"grow",children:c(j.queued?"diffc.sentQueued":"diffc.sent",{name:j.name})}),(0,n.jsx)("button",{type:"button",className:"btn sm",onClick:()=>{b(null),t.onViewChat()},children:c("diffc.viewChat")}),(0,n.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:()=>b(null),"aria-label":c("common.close"),title:c("common.close"),children:(0,n.jsx)(eC.A,{size:14})})]})]}):M;let F=new Set(r.map(e=>e.path)),R=r.filter(e=>e.outdated).length,P=[...F].sort().map(e=>({path:e,list:r.filter(t=>t.path===e).sort((e,t)=>z(e)-z(t))})),D=()=>{var e;d(!1),null==(e=y.current)||e.focus()};return(0,n.jsxs)("div",{ref:C,style:S,className:"dc-bar",role:"region","aria-label":c("diffc.bar.label"),children:[M,o&&(0,n.jsxs)("div",{id:w,className:"dc-list",role:"group","aria-label":c("diffc.review.title"),inert:s,onKeyDown:e=>{"Escape"===e.key&&(e.stopPropagation(),D())},children:[(0,n.jsxs)("div",{className:"dc-list-head",children:[(0,n.jsx)("b",{className:"grow",children:c("diffc.review.title")}),(0,n.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:D,"aria-label":c("common.close"),title:c("common.close"),children:(0,n.jsx)(eC.A,{size:15})})]}),(0,n.jsx)("div",{className:"dc-list-body",children:P.map(e=>(0,n.jsxs)("section",{className:"dc-file",children:[(0,n.jsxs)("h4",{title:e.path,children:[(0,n.jsx)("b",{children:eL(e.path)})," ",(0,n.jsx)("span",{className:"muted mono",children:e.path})]}),(0,n.jsx)("ul",{children:e.list.map(e=>{let s=E(e,c),a=c("diffc.itemAria",{file:eL(e.path),range:s});return(0,n.jsxs)("li",{className:"dc-item",children:[(0,n.jsxs)("button",{type:"button",className:"dc-item-go",onClick:()=>l(e,!1),"aria-label":"".concat(a,": ").concat(e.text),children:[(0,n.jsxs)("span",{className:"dc-item-top",children:[(0,n.jsx)("span",{className:"dc-range",children:s}),e.outdated&&(0,n.jsx)("span",{className:"chip dc-chip",title:e.gone?c("diffc.outdated.gone"):c("diffc.outdated.hint"),children:c("diffc.outdated")})]}),(0,n.jsx)("span",{className:"dc-item-text",children:e.text}),e.outdated&&(0,n.jsx)("span",{className:"dc-item-why",children:e.gone?c("diffc.outdated.gone"):c("diffc.outdated.hint")})]}),(0,n.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:()=>l(e,!0),"aria-label":"".concat(c("diffc.edit"),": ").concat(a),title:c("diffc.edit"),children:(0,n.jsx)(eI.A,{size:14})}),(0,n.jsx)("button",{type:"button",className:"btn ghost icon sm danger",onClick:()=>{t.remove(e.id),N(c("diffc.announce.deleted",{count:r.length-1}))},"aria-label":"".concat(c("diffc.delete"),": ").concat(a),title:c("diffc.delete"),children:(0,n.jsx)(eP.A,{size:14})})]},e.id)})})]},e.path))}),(0,n.jsxs)("div",{className:"dc-list-foot",children:[(0,n.jsx)("button",{type:"button",className:"btn ghost sm","aria-expanded":h,onClick:()=>m(e=>!e),children:h?c("diffc.preview.hide"):c("diffc.preview")}),(0,n.jsx)(ea.WQ,{text:I(r,c),label:c("diffc.copy")})]}),h&&(0,n.jsx)("pre",{className:"mono dc-msg",tabIndex:0,children:I(r,c)})]}),p&&(0,n.jsx)("div",{ref:k,tabIndex:-1,className:"dc-err",children:(0,n.jsxs)(et.lZ,{kind:"err",action:(0,n.jsx)("button",{type:"button",className:"btn sm",onClick:()=>void A(),children:c("diffc.retry")}),children:[c("diffc.sendError"),p?" ".concat(p):""]})}),t.busy&&!t.readOnly&&(0,n.jsx)("p",{className:"dc-note",children:c("diffc.busy",{name:t.agentName})}),t.readOnly&&(0,n.jsx)("p",{className:"dc-note",children:c("diffc.readOnly")}),r.length>=25&&(0,n.jsx)("p",{className:"dc-note",children:c("diffc.limit",{max:25})}),(0,n.jsxs)("div",{className:"dc-row",inert:s,children:[(0,n.jsxs)("div",{className:"dc-sum",children:[(0,n.jsx)(u.A,{size:15,"aria-hidden":!0}),(0,n.jsxs)("span",{children:[c("diffc.bar.count",{count:r.length})," \xb7 ",c("diffc.bar.files",{count:F.size})]}),R>0&&(0,n.jsx)("span",{className:"chip dc-chip",children:c("diffc.outdated.count",{count:R})}),(0,n.jsx)("button",{ref:y,type:"button",className:"btn ghost sm","aria-expanded":o,"aria-controls":o?w:void 0,onClick:()=>d(e=>!e),children:c("diffc.review")})]}),(0,n.jsxs)("div",{className:"dc-acts",children:[r.length>=2&&(0,n.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:()=>x(!0),"aria-label":c("diffc.clear"),title:c("diffc.clear"),children:(0,n.jsx)(eP.A,{size:15})}),(0,n.jsxs)("button",{type:"button",className:"btn primary sm dc-send",disabled:s||t.readOnly,"aria-busy":s,onClick:()=>void A(),"aria-label":s?c("diffc.sending"):c("diffc.sendAria",{count:r.length,name:t.agentName}),children:[(0,n.jsx)(eD.A,{size:14,"aria-hidden":!0}),s?c("diffc.sending"):c("diffc.send",{count:r.length})]})]})]}),g&&(0,n.jsx)(et.TM,{danger:!0,title:c("diffc.clear.title",{count:r.length}),body:c("diffc.clear.body"),confirmLabel:c("diffc.clear.go"),onClose:()=>x(!1),onConfirm:()=>t.clear()})]})}var eH=s(58099);let eK=(0,i.memo)(function(e){var t,s,a,l,i,c,r,o;let{row:d,path:h,ws:m,actions:g,picking:x,onPick:p,index:f=-1,mark:j="",zone:b=!1,title:v,bubble:N,bubbleId:y,onDown:k,onEnter:w,onTap:C,onBubble:S}=e,{t:A}=(0,q.s9)();if("hunk"===d.t)return(0,n.jsxs)("div",{className:"vl-row hunk",children:[(0,n.jsx)("div",{className:"vl-ln",style:{left:0},children:"⋯"}),(0,n.jsx)("div",{className:"vl-ln",style:{left:"calc(6ch + 16px)"},children:"⋯"}),(0,n.jsxs)("div",{className:"vl-hl",children:[(0,n.jsx)("span",{className:"rng mono",children:d.header}),d.section&&(0,n.jsx)("span",{className:"hs",title:d.section,children:d.section}),g&&(null==x?void 0:x.hunk)===d.idx?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{type:"button",className:"hk-btn on",onClick:()=>g.pickAll(d.idx,d.changed),children:A("git.discard.lines.all")}),(0,n.jsxs)("button",{type:"button",className:"hk-btn danger on",disabled:!x.picked.size,onClick:()=>g.discardPicked(d.idx,d.header),children:[(0,n.jsx)(eo.A,{size:12}),A("git.discard.lines.go",{count:x.picked.size})]}),(0,n.jsx)("button",{type:"button",className:"hk-btn on",onClick:g.stopPicking,children:A("common.cancel")})]}):g&&(0,n.jsxs)(n.Fragment,{children:[d.changed>0&&g.canPick&&(0,n.jsxs)("button",{type:"button",className:"hk-btn",disabled:g.blocked,title:A(g.blocked?"diffc.busyPicking":"git.discard.lines.hint"),onClick:()=>g.startPicking(d.idx),children:[(0,n.jsx)(eM.A,{size:12}),A("git.discard.lines")]}),(0,n.jsxs)("button",{type:"button",className:"hk-btn",title:A("git.discard.hunk.hint"),onClick:()=>g.discardHunk(d.idx,d.header),children:[(0,n.jsx)(eo.A,{size:12}),A("git.discard.hunk")]})]})]})]});if("line"===d.t){let e=d.l;return(0,n.jsxs)("div",{className:"vl-row ".concat(e.kind," ").concat(p&&void 0!==d.k&&(null==x?void 0:x.picked.has(d.k))?"picked":""," ").concat(b?"dc-zone":""," ").concat(j),onClick:p&&void 0!==d.k?()=>p(d.k):C&&b?()=>C(f):void 0,onPointerDown:k&&b?e=>k(f,e):void 0,onPointerEnter:w&&b?()=>w(f):void 0,children:[(0,n.jsxs)("div",{className:"vl-ln",style:{left:0},title:v,children:[null!=(t=e.oldNo)?t:"",y&&S&&(0,n.jsx)("button",{type:"button",className:"dc-bubble",title:N,"aria-label":N,onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),S(y)},children:(0,n.jsx)(u.A,{size:12,"aria-hidden":!0})})]}),(0,n.jsx)("div",{className:"vl-ln",style:{left:"calc(6ch + 16px)"},title:v,children:null!=(s=e.newNo)?s:""}),(0,n.jsx)("div",{className:"vl-sg",children:p&&void 0!==d.k?(0,n.jsx)("input",{type:"checkbox",checked:!!(null==x?void 0:x.picked.has(d.k)),onChange:()=>void 0,"aria-label":A("git.discard.lines.pick")}):"add"===e.kind?"+":"del"===e.kind?"−":""}),(0,n.jsx)("div",{className:"vl-cd",children:(0,n.jsx)(ez.SH,{text:e.text,path:h,ws:m})})]})}let{left:E,right:z}=d.r;return(0,n.jsxs)("div",{className:"vl-row split",children:[(0,n.jsx)("div",{className:"vl-ln ".concat(null!=(a=null==E?void 0:E.kind)?a:"void"),style:{left:0},children:null!=(l=null==E?void 0:E.oldNo)?l:""}),(0,n.jsx)("div",{className:"vl-cd ".concat(null!=(i=null==E?void 0:E.kind)?i:"void"),title:E&&E.text.length>60?E.text:void 0,children:E?(0,n.jsx)(ez.SH,{text:E.text,path:h,ws:m}):null}),(0,n.jsx)("div",{className:"vl-ln ".concat(null!=(c=null==z?void 0:z.kind)?c:"void"),children:null!=(r=null==z?void 0:z.newNo)?r:""}),(0,n.jsx)("div",{className:"vl-cd ".concat(null!=(o=null==z?void 0:z.kind)?o:"void"),title:z&&z.text.length>60?z.text:void 0,children:z?(0,n.jsx)(ez.SH,{text:z.text,path:h,ws:m}):null})]})});function eO(e){var t,s;let{parsed:a,layout:l,path:c,cutOff:r=!1,firstIndex:o=0,onDiscardHunk:d,onDiscardLines:u,comments:h}=e,{t:m}=(0,q.s9)(),{whitespace:g}=(0,ep.Wx)(),x=(0,eR.O)(),p=(0,i.useMemo)(()=>(function(e,t,s){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=[],l=(0,eF.KJ)(s);return e.hunks.forEach((e,s)=>{a.push({t:"hunk",idx:s+n,header:eA(e.header),section:l?e.section:"",changed:e.lines.filter(e=>"ctx"!==e.kind).length});let i=0;if("unified"===t)for(let t of e.lines)a.push({t:"line",l:t,hunk:s+n,k:"ctx"===t.kind?void 0:i++});else for(let t of function(e){let t=[];for(let s=0;s<e.length;){let n=e[s];if("ctx"===n.kind){t.push({left:n,right:n}),s++;continue}let a=[],l=[];for(;s<e.length&&"del"===e[s].kind;)a.push(e[s++]);for(;s<e.length&&"add"===e[s].kind;)l.push(e[s++]);for(let e=0;e<Math.max(a.length,l.length);e++)t.push({left:a[e],right:l[e]})}return t}(e.lines))a.push({t:"pair",r:t})}),a})(a,l,c,o),[a,l,c,o]),f=(0,i.useMemo)(()=>a.hunks.reduce((e,t)=>t.lines.reduce((e,t)=>Math.max(e,t.text.length),e),0),[a]),j="unified"===l?"calc(12ch + 32px + 18px + ".concat(f,"ch + 24px)"):void 0,b=(0,i.useRef)(null),v=(0,i.useRef)(null),[N,y]=(0,i.useState)({max:0,track:0});(0,i.useEffect)(()=>{let e=b.current;if(!e||"split"!==l)return void y({max:0,track:0});let t=()=>{let t=e.querySelector(".vl");if(!t)return;let s=document.createElement("canvas").getContext("2d");if(!s)return;s.font=getComputedStyle(t).font;let n=s.measureText("0").width,a=(e.clientWidth-2*(6*n+16))/2;y({max:Math.max(0,Math.ceil(f*n+24-a)),track:e.clientWidth})};t();let s=new ResizeObserver(t);return s.observe(e),()=>s.disconnect()},[l,f,p.length]),(0,i.useEffect)(()=>{var e;v.current&&(v.current.scrollLeft=0),null==(e=b.current)||e.style.setProperty("--hx","0px")},[a,l]),(0,i.useEffect)(()=>{let e=b.current;if(!e||"split"!==l)return;let t=e=>{let t=Math.abs(e.deltaX)>Math.abs(e.deltaY)?e.deltaX:e.shiftKey?e.deltaY:0;t&&v.current&&(e.preventDefault(),v.current.scrollLeft+=t)};return e.addEventListener("wheel",t,{passive:!1}),()=>e.removeEventListener("wheel",t)},[l]);let[k,w]=(0,i.useState)(null);(0,i.useEffect)(()=>{w(null)},[a,l]);let C=e=>w(t=>{if(!t)return t;let s=new Set(t.picked);return s.has(e)?s.delete(e):s.add(e),{...t,picked:s}}),S="unified"===l?h:void 0,[M,P]=(0,i.useState)(null),[I,D]=(0,i.useState)(null),[T,L]=(0,i.useState)(!1),[U,_]=(0,i.useState)(null),[H,K]=(0,i.useState)(!1),[O,W]=(0,i.useState)(),[B,$]=(0,i.useState)(null),[Q,G]=eT(),J=(0,i.useRef)(""),[X,Z]=(0,i.useState)(null),V=(0,i.useRef)(0),Y=(0,i.useCallback)(function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return W({top:e*eH.U,bottom:(t+1)*eH.U+s,key:++V.current})},[]),ee=a.hunks.length-1,et=(0,i.useMemo)(()=>{let e=new Map;if(!S)return e;let t=new Map;for(let s of(p.forEach((e,s)=>{"hunk"===e.t&&t.set(e.idx-o,s)}),S.items)){let n=s.outdated?null:R(a,s);if(n){let a=t.get(n.hunk)+1+n.start;for(let t=0;t<s.count;t++)e.has(a+t)||e.set(a+t,{id:s.id,first:0===t,outdated:!1});continue}let l=z(s),i=p.findIndex(e=>"line"===e.t&&(s.removed?"del"===e.l.kind&&e.l.oldNo===l:e.l.newNo===l));i>=0&&!e.has(i)&&e.set(i,{id:s.id,first:!0,outdated:!0})}return e},[null==S?void 0:S.items,a,p,o]),es=(0,i.useCallback)(e=>{let t=p[e];return!!S&&!k&&(null==t?void 0:t.t)==="line"&&!(r&&t.hunk-o===ee)},[S,k,p,r,o,ee]),en=(0,i.useMemo)(()=>p.flatMap((e,t)=>"line"===e.t?[t]:[]),[p]),ea=(e,t)=>p.slice(e,t+1).flatMap(e=>"line"===e.t?[e.l]:[]),el=e=>null==S?void 0:S.items.find(t=>t.id===e),ei=e=>{let t=[...et].filter(t=>{let[,s]=t;return s.id===e}).map(e=>{let[t]=e;return t});return t.length?{from:Math.min(...t),to:Math.max(...t)}:null},ec=(0,i.useCallback)((e,t)=>{let s=t>=e?1:-1,n=e;for(let a=e+s;s>0?a<=t:a>=t;a+=s){let e=p[a];if((null==e?void 0:e.t)!=="line"||et.has(a)){et.has(a)&&G(m("diffc.announce.clamped"));break}n=a}return n},[p,et,G,m]),er=!!S&&S.total<25,eo=e=>{let t=el(e),s=ei(e);t&&s&&(null==S||!S.locked)&&(J.current=t.text,P(null),Z(null),_({from:s.from,to:s.to,lines:ea(s.from,s.to),initial:t.text,editingId:e}),Y(s.from,s.to,200))},ed=(e,t)=>{if(!S||S.locked)return;let s=Math.min(e,t),n=Math.max(e,t);if(s===n&&et.has(s))return eo(et.get(s).id);if(!er)return void G(m("diffc.limit",{max:25}));let a=ea(s,n);J.current="",Z(null),_({from:s,to:n,lines:a,initial:""}),S.store.setDraft({path:c,lines:a,text:""}),Y(s,n,200)},eu=()=>{var e,t;_(null),P(null),null==S||S.store.setDraft(null),J.current="",null==(t=b.current)||null==(e=t.querySelector(".vf-main"))||e.focus({preventScroll:!0})},eh=()=>!!U&&J.current!==(U.editingId?U.initial:"")&&!(!U.editingId&&!J.current.trim()),em=()=>null==S?void 0:S.store.setDraft(null),eg=(0,i.useRef)({sel:M,editor:U,placed:et,zoneOk:es,extend:ec,openNew:ed,openEdit:eo,dirty:eh,clearDraft:em,dragging:!1,touchTap:!1});eg.current={...eg.current,sel:M,editor:U,placed:et,zoneOk:es,extend:ec,openNew:ed,openEdit:eo,dirty:eh,clearDraft:em};let ex=()=>{var e,t;return null==(t=b.current)||null==(e=t.querySelector(".dc-editor textarea"))?void 0:e.focus()},ef=(0,i.useCallback)((e,t)=>{var s,n;let a=eg.current;if(a.touchTap="touch"===t.pointerType,"touch"===t.pointerType||0!==t.button||!a.zoneOk(e)||!t.target.closest(".vl-ln, .vl-sg"))return;if(t.preventDefault(),K(!1),null==(n=b.current)||null==(s=n.querySelector(".vf-main"))||s.focus({preventScroll:!0}),D(e),a.editor&&a.dirty()){if(t.shiftKey){let t=a.editor.from,s=a.extend(t,e),n=Math.min(t,s),l=Math.max(t,s);_({...a.editor,from:n,to:l,lines:ea(n,l)})}else ex();return}if(a.placed.has(e)&&!t.shiftKey)return void a.openEdit(a.placed.get(e).id);a.editor&&(_(null),a.clearDraft());let l=t.shiftKey&&a.sel?a.sel.a:e;P({a:l,b:a.extend(l,e)}),eg.current.dragging=!0;let i=()=>{window.removeEventListener("pointerup",i),eg.current.dragging=!1;let e=eg.current.sel;e&&eg.current.openNew(e.a,e.b)};window.addEventListener("pointerup",i)},[]),ej=(0,i.useCallback)(e=>{let t=eg.current;t.dragging&&t.sel&&P({a:t.sel.a,b:t.extend(t.sel.a,e)})},[]),eb=(0,i.useCallback)(e=>{let t=eg.current;if(!t.touchTap||!t.zoneOk(e)||t.editor)return;if(K(!0),t.placed.has(e))return void t.openEdit(t.placed.get(e).id);let s=p[e];t.sel&&t.sel.a===t.sel.b&&t.sel.a!==e&&p[t.sel.a].hunk===s.hunk?P({a:t.sel.a,b:t.extend(t.sel.a,e)}):P({a:e,b:e})},[p]),ev=(0,i.useCallback)(e=>{let t=eg.current;if(t.editor&&t.dirty())return void ex();t.openEdit(e)},[]);(0,i.useEffect)(()=>{P(null),$(null),_(e=>{if(!e)return e;let t=F(c,e.lines,"",0,""),s=R(a,t);if(!s)return{...e,from:Math.min(e.from,p.length-1),to:Math.min(e.to,p.length-1)};let n=p.findIndex(e=>"hunk"===e.t&&e.idx-o===s.hunk)+1+s.start;return{...e,from:n,to:n+t.count-1}})},[a]);let eN=(0,i.useRef)(!1);(0,i.useEffect)(()=>{if(!S||eN.current)return;eN.current=!0;let e=S.store.getDraft();if(!e||e.path!==c||!e.lines.length||!e.text.trim())return;let t=R(a,F(c,e.lines,"",0,""));if(!t)return;let s=p.findIndex(e=>"hunk"===e.t&&e.idx-o===t.hunk)+1+t.start,n=s+e.lines.length-1;J.current=e.text;let l=e.editingId?el(e.editingId):void 0;_({from:s,to:n,lines:e.lines,initial:l?l.text:"",editingId:null==l?void 0:l.id}),Z(e.text),Y(s,n,200)},[S]),(0,i.useEffect)(()=>{if(!(null==S?void 0:S.focus))return;let e=ei(S.focus.id);if(!e)return;Y(e.from,e.to,200*!!S.focus.edit),$(e);let t=setTimeout(()=>$(null),1200);return S.focus.edit&&eo(S.focus.id),()=>clearTimeout(t)},[null==S||null==(t=S.focus)?void 0:t.key,et.size>0]);let ey=d?{canPick:"unified"===l&&!!u,blocked:!!U,discardHunk:d,startPicking:e=>{P(null),w({hunk:e,picked:new Set})},stopPicking:()=>w(null),pickAll:(e,t)=>w({hunk:e,picked:new Set(Array.from({length:t},(e,t)=>t))}),discardPicked:(e,t)=>{if(k&&u){let s=[...k.picked].sort((e,t)=>e-t);w(null),u(e,t,s)}}}:void 0,ek=M?Math.min(M.a,M.b):-1,ew=M?Math.max(M.a,M.b):-1,eC=U&&S?(0,n.jsx)(eU,{path:c,range:E(U.editingId&&el(U.editingId)?el(U.editingId):A(U.lines),m),initial:null!=X?X:U.initial,saved:U.initial,editing:!!U.editingId,locked:S.locked,mac:x,onChange:e=>{J.current=e,S.store.setDraft({path:c,lines:U.lines,text:e,editingId:U.editingId})},onSave:e=>{let t=U.editingId?S.total:S.total+1;U.editingId?S.store.update(U.editingId,e):S.store.add(c,U.lines,e),G(m("diffc.announce.added",{range:E(U.editingId&&el(U.editingId)?el(U.editingId):A(U.lines),m),count:t})),Z(null),eu()},onCancel:()=>{Z(null),eu()},onDelete:U.editingId?()=>{S.store.remove(U.editingId),G(m("diffc.announce.deleted",{count:S.total-1})),Z(null),eu()}:void 0},null!=(s=U.editingId)?s:"new"):null;return(0,n.jsxs)("div",{className:"vf is-".concat(l),ref:b,style:{"--vl-left":"0px","--hx":"0px"},children:[a.meta.length>0&&(0,n.jsx)("div",{className:"gx-meta",children:a.meta.join(" \xb7 ")}),(0,n.jsx)("div",{className:"vf-main ".concat(S?"dc-on":""),...S?{tabIndex:0,role:"group","aria-label":m("diffc.region",{file:c.slice(c.lastIndexOf("/")+1)}),onKeyDown:e=>{if(!S||e.target!==e.currentTarget||e.ctrlKey||e.metaKey||e.altKey||!en.length)return;let t=null===I?-1:en.indexOf(I),s=Math.max(1,Math.floor((e.currentTarget.clientHeight||400)/eH.U)-1),n=null;if("ArrowDown"===e.key)n=en[Math.min(en.length-1,t+1)];else if("ArrowUp"===e.key)n=en[Math.max(0,t<0?0:t-1)];else if("Home"===e.key)n=en[0];else if("End"===e.key)n=en[en.length-1];else if("PageDown"===e.key)n=en[Math.min(en.length-1,Math.max(0,t)+s)];else if("PageUp"===e.key)n=en[Math.max(0,t-s)];else if("c"!==e.key&&"C"!==e.key&&("Enter"!==e.key||e.shiftKey)){if("Escape"===e.key){M&&(e.preventDefault(),P(null));return}}else{let t=null!=M?M:null!==I?{a:I,b:I}:null;return t&&es(t.a)?(e.preventDefault(),U&&eh())?void ex():void ed(t.a,t.b):void 0}if(null!=n){if(e.preventDefault(),e.shiftKey&&null!==I&&("ArrowDown"===e.key||"ArrowUp"===e.key)){let e=M?M.a:I,t=p[e],s=p[n];if(!es(e)||t.hunk!==s.hunk)return;let a=ec(e,n);P({a:e,b:a}),D(a),Y(a,a),G(m("diffc.announce.selected",{range:E(A(ea(Math.min(e,a),Math.max(e,a))),m)}));return}D(n),Y(n,n),(e=>{let t=p[e];if((null==t?void 0:t.t)!=="line")return;let s=t.l,n="del"===s.kind?s.oldNo:s.newNo;G("".concat(m("diffc.row.".concat(s.kind),{n:null!=n?n:"",text:s.text.trim()}),". ").concat(m("diffc.row.pos",{i:en.indexOf(e)+1,total:en.length})).concat(et.has(e)?", ".concat(m("diffc.row.hasComment")):"","."))})(n)}},onFocus:e=>{e.target===e.currentTarget&&(L(!0),null===I&&en.length&&D(en[0]))},onBlur:e=>{e.target===e.currentTarget&&L(!1)}}:{},children:(0,n.jsx)(eH.T,{count:p.length,width:j,reveal:O,overlay:eC&&U?{top:(U.to+1)*eH.U,node:eC}:void 0,render:e=>{let t=p[e],s="line"===t.t&&(null==k?void 0:k.hunk)===t.hunk;return(0,n.jsx)(eK,{row:t,path:c,ws:g,actions:"hunk"!==t.t||r&&t.idx===a.hunks.length-1?void 0:ey,picking:"hunk"===t.t||s?k:void 0,onPick:s?C:void 0,...(e=>{if(!S||"line"!==p[e].t)return{};let t=et.get(e),s=es(e),n=(null==t?void 0:t.first)?el(t.id):void 0,a=!!U&&e>=U.from&&e<=U.to,l=[t&&"dc-has",(null==t?void 0:t.first)&&"dc-first",(null==t?void 0:t.outdated)&&"dc-outdated",(e>=ek&&e<=ew||a)&&"dc-sel",T&&I===e&&"dc-cur",B&&e>=B.from&&e<=B.to&&"dc-flash"].filter(Boolean).join(" "),i=p[e],c=r&&i.hunk-o===ee?m("diffc.cutoff"):!s||t||er?void 0:m("diffc.limit",{max:25});return{index:e,mark:l,zone:s,title:c,bubble:n?"".concat(n.outdated?"".concat(m("diffc.outdated"),": "):"").concat(m("diffc.marker",{range:E(n,m),text:Array.from(n.text).length>120?"".concat(Array.from(n.text).slice(0,119).join(""),"…"):n.text})):void 0,bubbleId:null==n?void 0:n.id,onDown:ef,onEnter:ej,onTap:eb,onBubble:ev}})(e)},e)}})}),S&&H&&M&&!U&&(0,n.jsxs)("div",{className:"dc-selbar",role:"group","aria-label":E(A(ea(ek,ew)),m),children:[(0,n.jsx)("span",{className:"grow",children:E(A(ea(ek,ew)),m)}),(0,n.jsx)("button",{type:"button",className:"btn sm",onClick:()=>P(null),children:m("diffc.select.cancel")}),(0,n.jsx)("button",{type:"button",className:"btn primary sm",disabled:!er||S.locked,onClick:()=>ed(ek,ew),children:m("diffc.select.add")})]}),S&&(0,n.jsx)("div",{className:"sr-only","aria-live":"polite",children:Q}),"split"===l&&N.max>0&&(0,n.jsx)("div",{className:"hbar",ref:v,onScroll:e=>{var t;return null==(t=b.current)?void 0:t.style.setProperty("--hx","".concat(e.currentTarget.scrollLeft,"px"))},"aria-label":"Scroll sideways",children:(0,n.jsx)("div",{style:{width:N.track+N.max,height:1}})})]})}function eW(e){let{path:t,hunk:s,index:a,total:l,extent:c,onClose:r,onGo:o}=e,{t:d}=(0,q.s9)(),u=(0,i.useMemo)(()=>({meta:[],hunks:[s],binary:!1}),[s]),h=s.lines.length+1;return(0,n.jsxs)("div",{className:"vl-peek",role:"dialog","aria-label":d("git.peek.title"),onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"vl-peek-head",children:[(0,n.jsx)("b",{children:c?c.from===c.to?d("git.peek.line",{n:c.from}):d("git.peek.lines",{from:c.from,to:c.to}):d("git.peek.title")}),(0,n.jsx)("span",{className:"muted mono small grow",children:eA(s.header)}),(0,n.jsx)("span",{className:"small muted",children:d("git.peek.count",{n:a+1,total:l})}),(0,n.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:a<=0,onClick:()=>o(a-1),"aria-label":d("git.peek.prev"),title:"".concat(d("git.peek.prev")," (Alt+↑)"),children:(0,n.jsx)(ew.A,{size:15})}),(0,n.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:a>=l-1,onClick:()=>o(a+1),"aria-label":d("git.peek.next"),title:"".concat(d("git.peek.next")," (Alt+↓)"),children:(0,n.jsx)(O.A,{size:15})}),(0,n.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:r,"aria-label":d("common.close"),children:(0,n.jsx)(eC.A,{size:14})})]}),(0,n.jsx)("div",{className:"vl-peek-body",style:{height:Math.min(h*eH.U+4,260)},children:(0,n.jsx)(eO,{parsed:u,layout:"unified",path:t,firstIndex:a})})]})}function eq(e){var t,s;let{f:a,agent:l,blame:c,onOpenCommit:r,marks:o,allNew:d,focusLine:u}=e,h=null!=(t=null==o?void 0:o.groups)?t:[],[m,g]=(0,i.useState)(null),x=(0,i.useMemo)(()=>{let e=a.content.split("\n").length;return h.map(t=>({from:Math.min(t.from,e),to:Math.min(t.to,e)}))},[h,a.content]),j=m&&null!=(s=x[m.block])?s:null,[b,v]=(0,i.useState)(),N=(e,t)=>{let s={from:e.from,to:Math.min(e.to,a.content.split("\n").length)};return(s.to-(t+1)<=25?Math.max(s.to,t+1):t+1)*eH.U},y=e=>34+Math.min((e.view.lines.length+1)*eH.U+4,260)+14,k=e=>{let t=x[e];if(!t)return;let s=Math.max(0,t.from-1);g({row:s,block:e}),v({top:s*eH.U,bottom:N(h[e],s)+y(h[e]),key:Date.now()})};(0,i.useEffect)(()=>{g(null)},[a.path,o]),(0,i.useEffect)(()=>{if(!m)return;let e=e=>{if("Escape"===e.key)g(null);else if(e.altKey&&("ArrowDown"===e.key||"ArrowUp"===e.key)){e.preventDefault();let t=m.block+("ArrowDown"===e.key?1:-1);t>=0&&t<h.length&&k(t)}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[m]);let{t:w}=(0,q.s9)(),{whitespace:C}=(0,ep.Wx)(),[S,A]=(0,i.useState)(null),[E,z]=(0,i.useState)(null),M=(0,eE.Z)(a.content,a.path),F=(0,i.useMemo)(()=>M.length&&""===M[M.length-1]?M.slice(0,-1):M,[M]),R=(0,i.useMemo)(()=>a.content.split("\n").reduce((e,t)=>Math.max(e,t.length),0),[a.content]);(0,i.useEffect)(()=>{if(!c||"worktree"!==a.source){A(null),z(null);return}let e=!1;return p.FH.get("/agents/".concat(l.id,"/git/blame?path=").concat(encodeURIComponent(a.path))).then(t=>{e||(A(t),z(null))}).catch(t=>!e&&z(t instanceof Error?t.message:w("git.loadError"))),()=>{e=!0}},[c,l.id,a.path,a.source]);let P=(0,i.useMemo)(()=>{if(!S)return null;let e=-1;return S.lines.map((t,s)=>{let n=t!==S.lines[s-1];return n&&e++,{first:n,g:e%2}})},[S]);if(a.binary)return(0,n.jsx)("p",{className:"gx-note",children:w("git.file.binary")});if(0===F.length)return(0,n.jsx)("p",{className:"gx-note",children:w("git.file.empty")});let I=210*!!S;return(0,n.jsxs)("div",{className:"vf",children:["head"===a.source&&(0,n.jsx)("div",{className:"gx-banner",children:w("git.file.deleted")}),a.truncated&&(0,n.jsx)("div",{className:"gx-banner",children:w("git.file.truncated")}),E&&(0,n.jsx)("div",{className:"gx-banner",children:E}),(null==S?void 0:S.truncated)&&(0,n.jsx)("div",{className:"gx-banner",children:w("git.blame.truncated",{count:S.lines.length})}),(0,n.jsx)("div",{className:"vf-main",style:{"--vl-left":"".concat(I,"px")},children:(0,n.jsx)(eH.T,{count:F.length,width:"calc(".concat(I,"px + ").concat(6,"ch + ").concat(R,"ch + 40px)"),overlay:m&&h[m.block]?{top:N(h[m.block],m.row),node:(0,n.jsx)(eW,{path:a.path,hunk:h[m.block].view,index:m.block,extent:j,onClose:()=>g(null),total:h.length,onGo:k})}:void 0,reveal:u?{top:Math.max(0,u.line-4)*eH.U,bottom:(u.line+2)*eH.U,key:u.key}:b,render:e=>{var t;let s=null==S?void 0:S.lines[e],l=s?S.commits[s]:void 0,i=null==P?void 0:P[e],c="worktree"===a.source?d?"add":null==o?void 0:o.lines.get(e+1):void 0,x=!!o&&o.removedBefore.has(e+1),p=!!o&&e===F.length-1&&o.removedBefore.has(F.length+1),b=o&&"worktree"===a.source?null!=(t=o.blockOfLine.get(e+1))?t:x?o.blockOfRemoval.get(e+1):p?o.blockOfRemoval.get(F.length+1):void 0:void 0;return(0,n.jsxs)("div",{className:"vl-row ".concat(u&&e+1===u.line?"m-hit":""," ").concat(i?"bl-g".concat(i.g):""," ").concat(c?"m-".concat(c):""," ").concat(x?"m-delb":p?"m-dela":""," ").concat(void 0!==b?"has-peek":""," ").concat(j&&e+1>=j.from&&e+1<=j.to?"in-peek":""),onClick:void 0!==b?t=>{var s;if(!t.target.closest(".bl-btn")&&(t.target.closest(".vl-ln")||(null==(s=window.getSelection())?void 0:s.isCollapsed))){if((null==m?void 0:m.row)===e)return void g(null);g({row:e,block:b}),v({top:e*eH.U,bottom:N(h[b],e)+y(h[b]),key:Date.now()})}}:void 0,title:void 0!==b?w("git.peek.hint"):void 0,children:[S&&(0,n.jsx)("div",{className:"vl-bl ".concat((null==i?void 0:i.first)?"first":""),children:(null==i?void 0:i.first)&&l&&(l.uncommitted?(0,n.jsx)("span",{className:"muted",children:w("git.blame.uncommitted")}):(0,n.jsxs)("button",{type:"button",className:"bl-btn",title:"".concat(l.summary,"\n").concat(l.author," \xb7 ").concat((0,W.v7)(l.time)),onClick:()=>r(s),children:[(0,n.jsx)("span",{className:"mono sha",children:l.short}),(0,n.jsx)("span",{className:"who",children:l.author}),(0,n.jsx)("span",{className:"when",children:(0,f.KN)(l.time)})]}))}),(0,n.jsx)("div",{className:"vl-ln",children:e+1}),(0,n.jsx)("div",{className:"vl-cd",children:(0,n.jsx)(ez.Yr,{html:F[e],ws:C})})]},e)}})})]})}function eB(e){let{agent:t,gitRef:s,path:a,toolbar:l=!0}=e,{t:c}=(0,q.s9)(),[r,o]=(0,i.useState)(null),[d,u]=(0,i.useState)(""),[h,m]=(0,i.useState)("preview"),g=ey.test(a),x=ek.test(a);return(0,i.useEffect)(()=>{let e=!1;if(o(null),u(""),m("preview"),!g)return p.FH.get("/agents/".concat(t.id,"/git/ref-file?ref=").concat(encodeURIComponent(s),"&path=").concat(encodeURIComponent(a))).then(t=>!e&&o(t)).catch(t=>!e&&u(t instanceof Error&&/not found/i.test(t.message)?c("git.file.missingAt",{ref:s}):t instanceof Error?t.message:c("git.loadError"))),()=>{e=!0}},[t.id,s,a]),(0,n.jsxs)(n.Fragment,{children:[l&&(0,n.jsxs)("div",{className:"gx-ptools",style:{padding:"6px 14px"},children:[(0,n.jsx)("span",{className:"mono small grow",title:a,style:{overflow:"hidden",textOverflow:"ellipsis"},children:a}),r&&(0,n.jsx)("span",{className:"muted small",children:(0,W.zi)(r.size)}),x&&r&&!r.binary&&(0,n.jsx)(et.$q,{value:h,onChange:m,options:[{id:"preview",label:c("git.view.preview")},{id:"source",label:c("git.view.source")}]}),(0,n.jsx)(ea.WQ,{text:a,label:c("git.copyPath")})]}),(0,n.jsx)("div",{className:"gx-body",children:d?(0,n.jsx)("p",{className:"gx-note",children:d}):g?(0,n.jsx)("div",{className:"gx-image",children:(0,n.jsx)("img",{src:"/api/agents/".concat(t.id,"/git/raw-at?ref=").concat(encodeURIComponent(s),"&path=").concat(encodeURIComponent(a)),alt:a,onError:()=>u(c("git.file.missingAt",{ref:s}))})}):r?r.binary?(0,n.jsx)("p",{className:"gx-note",children:c("git.file.binary")}):x&&"preview"===h?(0,n.jsxs)("div",{className:"gx-md md",children:[r.truncated&&(0,n.jsx)("div",{className:"gx-banner",children:c("git.diff.truncated")}),(0,n.jsx)(ev.oz,{remarkPlugins:[eN.A],components:{a:e=>(0,n.jsx)("a",{...e,target:"_blank",rel:"noreferrer"})},children:r.content})]}):(0,n.jsx)(eq,{f:r,agent:t,blame:!1,onOpenCommit:()=>void 0,marks:null,allNew:!1}):(0,n.jsx)("p",{className:"gx-note",children:c("git.loading")})})]})}let e$={modified:"M",added:"A",deleted:"D",renamed:"R",untracked:"U",conflict:"!",typechange:"T"};function eQ(e){let{status:t,titled:s=!1}=e,{t:a}=(0,q.s9)();return(0,n.jsx)("span",{className:"stl st-".concat(t),title:s?a("git.status.".concat(t)):void 0,children:e$[t]})}function eG(e){let{agent:t,gitRef:s,path:a,label:l}=e,[c,r]=(0,i.useState)(!0);return((0,i.useEffect)(()=>{r(!0)},[s,a]),c)?(0,n.jsxs)("figure",{className:"gx-pic",children:[(0,n.jsx)("figcaption",{className:"muted small",children:l}),(0,n.jsx)("div",{className:"gx-image",children:(0,n.jsx)("img",{src:"/api/agents/".concat(t.id,"/git/raw-at?ref=").concat(encodeURIComponent(s),"&path=").concat(encodeURIComponent(a)),alt:a,onError:()=>r(!1)})})]}):null}function eJ(e){var t;let{agent:s,detailUrl:a,diffUrl:l,header:c,focus:r,embedded:o=!1,before:d,after:u,label:h}=e,{t:m}=(0,q.s9)(),[g,x]=(0,i.useState)(null),[f,j]=(0,i.useState)(null),[b,v]=(0,i.useState)(null),[N,y]=(0,i.useState)("unified"),[k,w]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!1;return x(null),j(null),v(null),w(null),p.FH.get(a).then(t=>{var s,n;e||(x(t),j(null!=(n=r&&t.files.some(e=>e.path===r)?r:null==(s=t.files[0])?void 0:s.path)?n:null))}).catch(t=>!e&&w(t instanceof Error?t.message:m("git.loadError"))),()=>{e=!0}},[s.id,a,r]);let C=null==g?void 0:g.files.find(e=>e.path===f);(0,i.useEffect)(()=>{if(!C)return void v(null);let e=!1;return v(null),p.FH.get(l(C)).then(t=>!e&&v(t)).catch(t=>!e&&w(t instanceof Error?t.message:m("git.loadError"))),()=>{e=!0}},[s.id,a,null==C?void 0:C.path,null==C?void 0:C.oldPath]);let S=(0,i.useMemo)(()=>b&&C&&b.path===C.path?eS(b.diff):null,[b,C]);if(k)return(0,n.jsx)("section",{className:"gx-preview",children:(0,n.jsx)("p",{className:"gx-note err",children:k})});if(!g)return(0,n.jsx)("section",{className:"gx-preview",children:(0,n.jsx)("p",{className:"gx-note",children:m("git.loading")})});let A=!!C&&ey.test(C.path);return(0,n.jsxs)("section",{className:"gx-preview gx-commitview ".concat(o?"embedded":""),"aria-label":h,children:[(0,n.jsx)("header",{className:"gx-chead",children:c(g)}),0===g.files.length?(0,n.jsx)("p",{className:"gx-note",children:m("git.cmp.nofiles")}):(0,n.jsx)("div",{className:"gx-cfilelist",role:"listbox",children:g.files.map(e=>{var t,s;return(0,n.jsxs)("button",{role:"option","aria-selected":f===e.path,className:"gx-cfile ".concat(f===e.path?"sel":""),onClick:()=>j(e.path),title:e.oldPath?"".concat(e.oldPath," → ").concat(e.path):e.path,children:[(0,n.jsx)(eQ,{status:e.status}),(0,n.jsx)("span",{className:"mono nm",children:e.path}),(null!==e.additions||null!==e.deletions)&&(0,n.jsxs)("span",{className:"gx-counts sm",children:[(0,n.jsxs)("i",{className:"add",children:["+",null!=(t=e.additions)?t:0]}),(0,n.jsxs)("i",{className:"del",children:["−",null!=(s=e.deletions)?s:0]})]})]},e.path)})}),C&&(0,n.jsxs)(n.Fragment,{children:[!A&&(0,n.jsx)("div",{className:"gx-ptools",style:{padding:"6px 14px"},children:(0,n.jsx)(et.$q,{value:N,onChange:y,options:[{id:"unified",label:m("git.layout.unified")},{id:"split",label:m("git.layout.split")}]})}),(0,n.jsx)("div",{className:"gx-body",children:A?(0,n.jsxs)("div",{className:"gx-picpair",children:["added"!==C.status&&(0,n.jsx)(eG,{agent:s,gitRef:d,path:null!=(t=C.oldPath)?t:C.path,label:m("git.img.before")}),"deleted"!==C.status&&(0,n.jsx)(eG,{agent:s,gitRef:u,path:C.path,label:m("git.img.after")})]}):S?S.binary?(0,n.jsx)("p",{className:"gx-note",children:m("git.diff.binary")}):0===S.hunks.length?(0,n.jsx)("p",{className:"gx-note",children:m("git.diff.empty")}):(0,n.jsxs)(n.Fragment,{children:[(null==b?void 0:b.truncated)&&(0,n.jsx)("div",{className:"gx-banner",children:m("git.diff.truncated")}),(0,n.jsx)(eO,{parsed:S,layout:N,path:C.path})]}):(0,n.jsx)("p",{className:"gx-note",children:m("git.loading")})})]})]})}function eX(e){let{agent:t,sha:s,embedded:a=!1,focus:l}=e,{t:i}=(0,q.s9)();return(0,n.jsx)(eJ,{agent:t,detailUrl:"/agents/".concat(t.id,"/git/commit?sha=").concat(s),embedded:a,focus:l,before:"".concat(s,"^"),after:s,label:s,diffUrl:e=>"/agents/".concat(t.id,"/git/commit-diff?sha=").concat(s,"&path=").concat(encodeURIComponent(e.path)).concat(e.oldPath?"&old=".concat(encodeURIComponent(e.oldPath)):""),header:e=>{let[t,...s]=e.message.split("\n"),a=s.join("\n").trim();return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("h3",{children:t}),a&&(0,n.jsx)("pre",{className:"gx-cbody",children:a}),(0,n.jsxs)("div",{className:"muted small row gap-s wrap",children:[(0,n.jsx)("span",{className:"mono",children:e.sha.slice(0,10)}),(0,n.jsx)(ea.WQ,{text:e.sha,label:i("git.info.copySha"),compact:!0}),(0,n.jsxs)("span",{children:["\xb7 ",e.author," \xb7 ",(0,W.v7)(e.date)]}),(0,n.jsxs)("span",{children:["\xb7 ",i("git.hist.files",{count:e.files.length})]})]})]})}})}function eZ(e){let{agent:t,sel:s,onSelect:a,onLoaded:l}=e,{t:c}=(0,q.s9)(),[r,o]=(0,i.useState)(null),[d,u]=(0,i.useState)(!1),[h,m]=(0,i.useState)(""),[g,x]=(0,i.useState)("");(0,i.useEffect)(()=>{let e=!1;return o(null),x(""),p.FH.get("/agents/".concat(t.id,"/git/tags")).then(t=>{e||(o(t.tags),u(t.truncated),null==l||l(t.tags))}).catch(t=>!e&&x(t instanceof Error?t.message:"error")),()=>{e=!0}},[t.id]);let j=(0,i.useMemo)(()=>(null!=r?r:[]).filter(e=>!h||"".concat(e.name," ").concat(e.subject).toLowerCase().includes(h.toLowerCase())),[r,h]);return g?(0,n.jsx)("p",{className:"gx-note err",children:g}):r?r.length?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"gx-filter",children:(0,n.jsxs)("div",{className:"search",children:[(0,n.jsx)(ed.A,{size:14}),(0,n.jsx)("input",{className:"input",placeholder:c("git.tags.search"),value:h,onChange:e=>m(e.target.value),"aria-label":c("git.tags.search")})]})}),(0,n.jsxs)("div",{className:"gx-hist",role:"listbox","aria-label":c("git.tab.tags"),children:[j.map(e=>(0,n.jsxs)("button",{role:"option","aria-selected":s===e.name,className:"gx-commit ".concat(s===e.name?"sel":""),onClick:()=>a(e),children:[(0,n.jsxs)("span",{className:"subj",children:[(0,n.jsx)(ej.A,{size:13,style:{verticalAlign:"-2px",marginRight:5}}),e.name]}),(0,n.jsx)("span",{className:"meta",children:e.subject||"—"}),(0,n.jsxs)("span",{className:"meta",children:[(0,n.jsx)("span",{className:"mono sha",children:e.sha.slice(0,8)})," \xb7 ",(0,f.KN)(Date.parse(e.date))]})]},e.name)),!j.length&&(0,n.jsx)("p",{className:"gx-note",children:c("git.noMatch",{query:h})}),d&&(0,n.jsx)("p",{className:"gx-note",children:c("git.tags.truncated",{count:r.length})})]})]}):(0,n.jsx)("p",{className:"gx-note",children:c("git.tags.empty")}):(0,n.jsx)("p",{className:"gx-note",children:c("git.loading")})}function eV(e){var t;let{agent:s,tag:a,onChanged:l}=e,{t:c}=(0,q.s9)(),r=(0,et.dj)(),[o,d]=(0,i.useState)(null),[u,h]=(0,i.useState)(""),m=!!o&&/^[\w./-]+$/.test(o)&&!o.startsWith("-")&&!o.endsWith("/")&&!o.includes(".."),g=async()=>{if(o&&m)try{await p.FH.post("/agents/".concat(s.id,"/git/branch-create"),{branch:o,from:a.name}),r(c("git.tags.branchCreated",{branch:o})),d(null),h(""),null==l||l()}catch(e){h(e instanceof Error?e.message:"error")}},[x,f]=(0,i.useState)("files"),[j,b]=(0,i.useState)(null),[v,N]=(0,i.useState)(!1),[y,k]=(0,i.useState)(new Set),[w,C]=(0,i.useState)(""),[S,A]=(0,i.useState)(null),[E,z]=(0,i.useState)("");(0,i.useEffect)(()=>{f("files"),A(null),C(""),k(new Set)},[a.name]),(0,i.useEffect)(()=>{let e=!1;return b(null),z(""),p.FH.get("/agents/".concat(s.id,"/git/tag-tree?tag=").concat(encodeURIComponent(a.name))).then(t=>{e||(b(t.files),N(t.truncated),k(new Set(t.files.length<=40?t.files.flatMap(e=>e.split("/").slice(0,-1).map((e,t,s)=>s.slice(0,t+1).join("/"))):[])))}).catch(t=>!e&&z(t instanceof Error?t.message:c("git.loadError"))),()=>{e=!0}},[s.id,a.name]);let M=(0,i.useMemo)(()=>j?eg(j,[]):null,[j]),F=(0,i.useMemo)(()=>M?ex(M,y,{query:w,onlyChanged:!1}).slice(0,3e3):[],[M,y,w]);return(0,n.jsxs)("section",{className:"gx-preview gx-tagview","aria-label":a.name,children:[(0,n.jsxs)("header",{className:"gx-chead",children:[(0,n.jsxs)("h3",{children:[(0,n.jsx)(ej.A,{size:16,style:{verticalAlign:"-2px",marginRight:6}}),a.name]}),a.subject&&(0,n.jsx)("div",{children:a.subject}),(0,n.jsxs)("div",{className:"muted small row gap-s wrap",children:[(0,n.jsx)("span",{className:"gx-chip soft",children:a.annotated?c("git.tags.annotated"):c("git.tags.lightweight")}),(0,n.jsx)("span",{className:"mono",children:a.sha.slice(0,10)}),(0,n.jsx)(ea.WQ,{text:a.sha,label:c("git.info.copySha"),compact:!0}),(0,n.jsxs)("span",{children:["\xb7 ",(0,W.v7)(a.date)]}),j&&(0,n.jsxs)("span",{children:["\xb7 ",c("git.tags.nfiles",{count:j.length})]})]}),(0,n.jsx)("div",{className:"row gap-s wrap",style:{marginTop:8},children:null===o?(0,n.jsxs)("button",{className:"btn sm",onClick:()=>d(""),children:[(0,n.jsx)(ec.A,{size:14}),c("git.tags.newBranch")]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("input",{className:"input mono",style:{maxWidth:240},autoFocus:!0,placeholder:c("git.tags.branchName"),value:o,onChange:e=>{d(e.target.value.trim()),h("")},"aria-label":c("git.tags.branchName"),onKeyDown:e=>{"Enter"===e.key&&g(),"Escape"===e.key&&d(null)}}),(0,n.jsx)("button",{className:"btn primary sm",disabled:!m,onClick:()=>void g(),children:c("git.tags.createBranch")}),(0,n.jsx)("button",{className:"btn ghost sm",onClick:()=>{d(null),h("")},children:c("common.cancel")})]})}),u&&(0,n.jsx)("p",{className:"gx-note err",style:{margin:0},children:u}),(0,n.jsx)("div",{style:{marginTop:4},children:(0,n.jsx)(et.$q,{value:x,onChange:f,options:[{id:"files",label:c("git.tags.files")},{id:"changes",label:c("git.tags.changes")}]})})]}),"changes"===x?(0,n.jsx)(eX,{agent:s,sha:a.sha,embedded:!0},a.sha):E?(0,n.jsx)("p",{className:"gx-note err",children:E}):M?(0,n.jsxs)("div",{className:"gx-tagfiles",children:[(0,n.jsxs)("div",{className:"gx-tagtree",children:[(0,n.jsx)("div",{className:"gx-filter",children:(0,n.jsxs)("div",{className:"search",children:[(0,n.jsx)(ed.A,{size:14}),(0,n.jsx)("input",{className:"input",placeholder:c("git.filterPlaceholder"),value:w,onChange:e=>C(e.target.value),"aria-label":c("git.filterPlaceholder")})]})}),(0,n.jsxs)("div",{className:"gx-list",role:"tree",children:[0===F.length?(0,n.jsx)("p",{className:"gx-note",children:w?c("git.noMatch",{query:w}):c("git.noFiles")}):F.map(e=>{let{node:t,depth:s}=e,a="dir"===t.type,l=a&&(!!w||y.has(t.path));return(0,n.jsxs)("button",{type:"button",role:"treeitem","aria-level":s+1,"aria-expanded":a?l:void 0,"aria-selected":!a&&S===t.path,className:"gx-row ".concat(a?"dir":"file"," ").concat(a||S!==t.path?"":"sel"),style:{paddingLeft:8+14*s},title:t.path,onClick:()=>{let e;return a?(e=t.path,k(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})):A(t.path)},children:[(0,n.jsx)("span",{className:"chev",children:a?l?(0,n.jsx)(O.A,{size:14}):(0,n.jsx)(er.A,{size:14}):null}),(0,n.jsx)("span",{className:"ico",children:a?l?(0,n.jsx)(eb.A,{size:15}):(0,n.jsx)(el.A,{size:15}):(0,n.jsx)(eu.A,{size:15})}),(0,n.jsx)("span",{className:"nm",children:t.name})]},t.path)}),v&&(0,n.jsx)("p",{className:"gx-note",children:c("git.treeTruncated",{count:null!=(t=null==j?void 0:j.length)?t:0})})]})]}),(0,n.jsx)("div",{className:"gx-tagfile",children:S?(0,n.jsx)(eB,{agent:s,gitRef:a.name,path:S}):(0,n.jsx)("div",{className:"gx-empty",children:(0,n.jsx)("p",{children:c("git.tags.pick")})})})]}):(0,n.jsx)("p",{className:"gx-note",children:c("git.loading")})]})}var eY=s(71857),e0=s(72705),e1=s(21018);function e4(e){var t,s,a,l;let{refs:c,value:r,onChange:o,label:d,extra:u,icon:h=!0,compact:m=!1}=e,{t:g}=(0,q.s9)(),[x,p]=(0,i.useState)(!1),[j,b]=(0,i.useState)(""),v=(0,i.useRef)(null);(0,e1.s)(x,v,()=>p(!1)),(0,i.useEffect)(()=>{x&&b("")},[x]);let N=e=>!j||"".concat(e.name," ").concat(e.subject).toLowerCase().includes(j.toLowerCase()),y=(0,i.useMemo)(()=>{var e;return(null!=(e=null==c?void 0:c.branches)?e:[]).filter(N)},[c,j]),k=(0,i.useMemo)(()=>{var e;return(null!=(e=null==c?void 0:c.remotes)?e:[]).filter(N)},[c,j]),w=(0,i.useMemo)(()=>{var e;return(null!=(e=null==c?void 0:c.tags)?e:[]).filter(N)},[c,j]),C=j.trim(),S=/^([0-9a-f]{7,40}|HEAD([~^]\d*)*)$/i.test(C)&&![...null!=(s=null==c?void 0:c.branches)?s:[],...null!=(a=null==c?void 0:c.tags)?a:[]].some(e=>e.name===C),A=e=>{o(e),p(!1)},E=(e,t)=>(0,n.jsxs)("button",{type:"button",role:"option","aria-selected":r===e.name,className:"gx-refrow ".concat(r===e.name?"sel":""),onClick:()=>A(e.name),title:e.subject,children:[(0,n.jsxs)("span",{className:"nm",children:[r===e.name?(0,n.jsx)(e0.A,{size:13}):"tag"===t?(0,n.jsx)(ej.A,{size:13}):(0,n.jsx)(ec.A,{size:13}),e.name]}),(0,n.jsxs)("span",{className:"sub",children:[e.subject||"—"," \xb7 ",(0,f.KN)(Date.parse(e.date))]})]},"".concat(t,":").concat(e.name));return(0,n.jsxs)("div",{className:"gx-brmenu gx-refpick",ref:v,children:[m?(0,n.jsxs)("button",{type:"button",className:"btn sm ".concat(r?"primary gx-refbtn":"ghost icon"),"aria-expanded":x,"aria-haspopup":"listbox","aria-label":d,title:d,onClick:()=>p(e=>!e),children:[(0,n.jsx)(ec.A,{size:14}),r&&(0,n.jsx)("span",{className:"nm mono",children:r})]}):(0,n.jsxs)("button",{type:"button",className:"btn sm gx-refbtn","aria-expanded":x,"aria-haspopup":"listbox",title:d,onClick:()=>p(e=>!e),children:[h&&(0,n.jsx)(ec.A,{size:14}),(0,n.jsx)("span",{className:"nm mono",children:null!=(l=null==u||null==(t=u.find(e=>e.value===r))?void 0:t.label)?l:r||g("git.ref.pick")}),(0,n.jsx)(O.A,{size:13})]}),x&&(0,n.jsxs)("div",{className:"gx-pop",role:"listbox",children:[(0,n.jsxs)("div",{className:"search",children:[(0,n.jsx)(ed.A,{size:14}),(0,n.jsx)("input",{className:"input",autoFocus:!0,placeholder:g("git.ref.search"),value:j,onChange:e=>b(e.target.value),"aria-label":g("git.ref.search"),onKeyDown:e=>{"Enter"===e.key&&S&&A(C)}})]}),(0,n.jsxs)("div",{className:"gx-brlist",children:[!j&&(null==u?void 0:u.map(e=>(0,n.jsx)("button",{type:"button",role:"option","aria-selected":r===e.value,className:"gx-refrow ".concat(r===e.value?"sel":""),onClick:()=>A(e.value),children:(0,n.jsxs)("span",{className:"nm",children:[r===e.value&&(0,n.jsx)(e0.A,{size:13}),e.label]})},e.value))),S&&(0,n.jsx)("button",{type:"button",className:"gx-refrow",onClick:()=>A(C),children:(0,n.jsx)("span",{className:"nm mono",children:g("git.ref.useCommit",{ref:C.slice(0,12)})})}),y.length>0&&(0,n.jsx)("div",{className:"gx-brhead",children:g("git.ref.branches")}),y.map(e=>E(e,"branch")),w.length>0&&(0,n.jsx)("div",{className:"gx-brhead",children:g("git.ref.tags")}),w.slice(0,200).map(e=>E(e,"tag")),k.length>0&&(0,n.jsx)("div",{className:"gx-brhead",children:g("git.ref.remotes")}),k.slice(0,200).map(e=>E(e,"branch")),c&&!y.length&&!w.length&&!k.length&&!S&&(0,n.jsx)("p",{className:"gx-note",children:g("git.ref.none")})]})]})]})}function e9(e){let{refs:t,sel:s,onChange:a}=e,{t:l}=(0,q.s9)();return(0,n.jsxs)("div",{className:"gx-cmpside",children:[(0,n.jsx)("label",{className:"label",children:l("git.cmp.base")}),(0,n.jsx)(e4,{refs:t,value:s.base,onChange:e=>a({...s,base:e})}),(0,n.jsx)("div",{className:"row",style:{justifyContent:"center"},children:(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>a({base:s.head,head:s.base}),disabled:!s.base&&!s.head,"aria-label":l("git.cmp.swap"),title:l("git.cmp.swap"),children:(0,n.jsx)(eY.A,{size:15,style:{transform:"rotate(90deg)"}})})}),(0,n.jsx)("label",{className:"label",children:l("git.cmp.head")}),(0,n.jsx)(e4,{refs:t,value:s.head,onChange:e=>a({...s,head:e})}),(!s.base||!s.head)&&(0,n.jsx)("p",{className:"muted small",children:l("git.cmp.pick")})]})}function e2(e){let{agent:t,sel:s}=e,{t:a}=(0,q.s9)();if(!(s.base&&s.head))return(0,n.jsx)("div",{className:"gx-preview",children:(0,n.jsx)("div",{className:"gx-empty",children:(0,n.jsx)("p",{children:a("git.cmp.pick")})})});let l="base=".concat(encodeURIComponent(s.base),"&head=").concat(encodeURIComponent(s.head));return(0,n.jsx)(eJ,{agent:t,detailUrl:"/agents/".concat(t.id,"/git/compare?").concat(l),before:s.base,after:s.head,label:"".concat(s.base," → ").concat(s.head),diffUrl:e=>"/agents/".concat(t.id,"/git/compare-diff?").concat(l,"&path=").concat(encodeURIComponent(e.path)).concat(e.oldPath?"&old=".concat(encodeURIComponent(e.oldPath)):""),header:e=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("h3",{children:[(0,n.jsx)("span",{className:"mono",children:s.base})," → ",(0,n.jsx)("span",{className:"mono",children:s.head})]}),e.base.sha===e.head.sha?(0,n.jsx)("p",{className:"muted small",style:{margin:0},children:a("git.cmp.same")}):(0,n.jsxs)("div",{className:"muted small row gap-s wrap",children:[(0,n.jsx)("span",{children:a("git.cmp.summary",{ahead:e.ahead,behind:e.behind})}),(0,n.jsxs)("span",{children:["\xb7 ",a("git.hist.files",{count:e.files.length})]})]}),e.commits.length>0&&(0,n.jsxs)("details",{className:"gx-cmpcommits",children:[(0,n.jsx)("summary",{children:a("git.cmp.commits",{count:e.ahead})}),(0,n.jsx)("ul",{children:e.commits.map(e=>(0,n.jsxs)("li",{children:[(0,n.jsx)("span",{className:"mono sha",children:e.short})," ",e.subject," ",(0,n.jsxs)("span",{className:"muted",children:["\xb7 ",e.author," \xb7 ",(0,f.KN)(Date.parse(e.date))]})]},e.sha))}),e.commitsTruncated&&(0,n.jsx)("p",{className:"muted small",children:a("git.cmp.more",{count:e.commits.length})})]})]})})}function e3(e){let t=e.split("\n"),s=[];for(let e=0;e<t.length;e++){if(!/^<{7}( |$)/.test(t[e]))continue;let n=-1,a=-1,l=-1;for(let s=e+1;s<t.length&&!/^<{7}( |$)/.test(t[s]);s++)if(/^\|{7}( |$)/.test(t[s])&&n<0)a=s;else if("======="===t[s]&&n<0)n=s;else if(/^>{7}( |$)/.test(t[s])&&n>=0){l=s;break}n<0||l<0||(s.push({start:e,end:l,ours:t.slice(e+1,a>=0?a:n),base:a>=0?t.slice(a+1,n):void 0,theirs:t.slice(n+1,l),oursLabel:t[e].slice(8).trim(),theirsLabel:t[l].slice(8).trim()}),e=l)}return s}function e5(e,t,s){let n=e3(e)[t];if(!n)return e;let a={ours:n.ours,theirs:n.theirs,"ours-theirs":[...n.ours,...n.theirs],"theirs-ours":[...n.theirs,...n.ours]}[s],l=e.split("\n");return l.splice(n.start,n.end-n.start+1,...a),l.join("\n")}var e6=s(96213);function e7(e){let{agent:t,path:s,state:a,a:l,onResolved:c}=e,{t:r}=(0,q.s9)(),[o,u]=(0,i.useState)(null),[h,m]=(0,i.useState)(""),[g,x]=(0,i.useState)(null),[f,j]=(0,i.useState)(0);(0,i.useEffect)(()=>{let e=!1;return u(null),x(null),p.FH.get("/agents/".concat(t.id,"/git/file?path=").concat(encodeURIComponent(s))).then(t=>{e||(u(t),m(t.content))}).catch(t=>!e&&x(t instanceof Error?t.message:r("git.loadError"))),()=>{e=!0}},[t.id,s,f]);let b=(0,i.useMemo)(()=>e3(h),[h]),v="rebase"!==a&&"stash"!==a,N=e=>"mine"===e===v?"ours":"theirs",y=e=>"both-mine"===e?v?"ours-theirs":"theirs-ours":"both-remote"===e?v?"theirs-ours":"ours-theirs":N(e),k=/^(<{7}|>{7})( |$)/m.test(h),w=!!o&&!o.binary&&!o.truncated,C=!!l.busy,S=async e=>{await l.run("resolve",r("git.res.done"),"resolve-side",{path:s,side:N(e)})&&c()},A=async()=>{await l.run("resolve",r("git.res.done"),"resolve",{path:s,content:h})&&c()},E=async()=>{await l.run("unresolve",r("git.res.restored"),"unresolve",{path:s})&&j(e=>e+1)},z=s.lastIndexOf("/"),M=z>=0?s.slice(0,z+1):"",F=s.slice(z+1);return(0,n.jsxs)("section",{className:"gx-preview gx-resolver","aria-label":s,children:[(0,n.jsxs)("header",{className:"gx-phead",children:[(0,n.jsxs)("div",{className:"gx-ptitle",children:[(0,n.jsxs)("span",{className:"gx-path mono",title:s,children:[(0,n.jsx)("span",{className:"dir",children:M}),(0,n.jsx)("b",{children:F})]}),(0,n.jsx)("span",{className:"gx-chip st-conflict",children:r("git.status.conflict")}),w&&(0,n.jsx)("span",{className:"muted small",children:b.length>0?r("git.res.left",{count:b.length}):r("git.res.none")})]}),(0,n.jsxs)("div",{className:"gx-ptools",children:[(0,n.jsx)("button",{className:"btn sm",disabled:C,title:r("git.res.allMine.hint"),onClick:()=>void S("mine"),children:r("git.res.allMine")}),(0,n.jsx)("button",{className:"btn sm",disabled:C,title:r("git.res.allRemote.hint"),onClick:()=>void S("remote"),children:r("git.res.allRemote")}),(0,n.jsx)(ea.WQ,{text:s,label:r("git.copyPath")})]})]}),g?(0,n.jsx)("p",{className:"gx-note err",children:g}):o?w?(0,n.jsxs)("div",{className:"gx-rbody",children:[b.length>0&&(0,n.jsx)("div",{className:"gx-rblocks",children:b.map((e,t)=>(0,n.jsxs)("div",{className:"gx-rcard",children:[(0,n.jsxs)("div",{className:"gx-rtitle",children:[(0,n.jsx)("b",{children:r("git.res.block",{n:t+1,total:b.length})}),(0,n.jsx)("span",{className:"muted small",children:r("git.res.line",{n:e.start+1})})]}),(0,n.jsx)("div",{className:"gx-rsides",children:["mine","remote"].map(l=>{let i,c="ours"===N(l)?e.ours:e.theirs,o=!(i="ours"===N(l)?e.oursLabel:e.theirsLabel)||["HEAD","ours","theirs","Updated upstream","Stashed changes"].includes(i)?"":i;return(0,n.jsxs)("div",{className:"gx-rside ".concat(l),children:[(0,n.jsxs)("div",{className:"gx-rhead",children:[(0,n.jsx)("span",{children:"mine"===l?"stash"===a?r("git.res.mine.stash"):r("git.res.mine"):"stash"===a?r("git.res.remote.stash"):r("git.res.remote")}),o&&(0,n.jsx)("i",{className:"ref",children:o})]}),(0,n.jsx)("pre",{children:c.length?(0,n.jsx)(ez.Cy,{text:c.join("\n"),path:s}):(0,n.jsx)("span",{className:"muted",children:r("git.res.empty")})}),(0,n.jsx)("button",{className:"btn sm",onClick:()=>m(e=>e5(e,t,y(l))),children:"mine"===l?r("git.res.keepMine"):r("git.res.keepRemote")})]},l)})}),(0,n.jsxs)("div",{className:"gx-rboth",children:[(0,n.jsxs)("span",{className:"small muted",children:[r("git.res.both"),":"]}),(0,n.jsx)("button",{className:"btn sm",onClick:()=>m(e=>e5(e,t,y("both-mine"))),children:r("git.res.bothMine")}),(0,n.jsx)("button",{className:"btn sm",onClick:()=>m(e=>e5(e,t,y("both-remote"))),children:r("git.res.bothRemote")})]})]},"".concat(t,"-").concat(e.start)))}),(0,n.jsxs)("div",{className:"gx-rresult",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("label",{className:"label grow",htmlFor:"gx-result",children:r("git.res.result")}),(0,n.jsx)("span",{className:"small muted",children:r("git.res.editHint")})]}),(0,n.jsx)(e6.B,{id:"gx-result",label:r("git.res.result"),value:h,path:s,onChange:m})]}),(0,n.jsxs)("footer",{className:"gx-rfoot",children:[(0,n.jsxs)("button",{className:"btn ghost sm",disabled:C,onClick:()=>void E(),title:r("git.res.restore.hint"),children:[(0,n.jsx)(d.A,{size:14}),r("git.res.restore")]}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsx)("button",{className:"btn primary",disabled:C||k,onClick:()=>void A(),children:r("git.res.markResolved")})]})]}):(0,n.jsx)("p",{className:"gx-note",children:r("git.res.noEdit")}):(0,n.jsx)("p",{className:"gx-note",children:r("git.loading")})]})}function e8(e){let{agent:t,plan:s,a,onClose:l,onGo:i}=e,{t:c}=(0,q.s9)();return(0,n.jsxs)(et.TM,{title:c("git.sw.title",{branch:s.to}),confirmLabel:c("git.sw.anyway"),onConfirm:()=>{a.busy||i()},onClose:l,children:[s.carried>0&&(0,n.jsx)("p",{className:"confirm-body",children:c("git.sw.carried",{count:s.carried,from:s.from})}),(0,n.jsxs)("div",{className:"gx-sw-warn",role:"alert",children:[s.selfRunning&&(0,n.jsx)("div",{children:c("git.warn.running",{name:t.name})}),s.others.length>0&&(0,n.jsx)("div",{children:c("git.sw.others",{count:s.others.length,names:s.others.map(e=>e.name).join(", ")})})]})]})}var te=s(43380),tt=s(24328);function ts(e){let{stashes:t,sel:s,onSelect:a,onSave:l,canSave:i}=e,{t:c}=(0,q.s9)();return(0,n.jsxs)("div",{className:"gx-stashes",children:[(0,n.jsx)("div",{className:"gx-stash-head",children:(0,n.jsxs)("button",{className:"btn sm",disabled:!i,title:i?void 0:c("git.stash.nothing"),onClick:l,children:[(0,n.jsx)(te.A,{size:14}),c("git.stash.save")]})}),t?0===t.length?(0,n.jsx)("p",{className:"gx-note",children:c("git.stash.empty")}):(0,n.jsx)("div",{className:"gx-hist",role:"listbox","aria-label":c("git.tab.stashes"),children:t.map(e=>(0,n.jsxs)("button",{role:"option","aria-selected":s===e.sha,className:"gx-commit ".concat(s===e.sha?"sel":""),onClick:()=>a(e.sha),children:[(0,n.jsx)("span",{className:"subj",children:e.message||"—"}),(0,n.jsxs)("span",{className:"meta",children:[e.branch&&(0,n.jsxs)(n.Fragment,{children:[e.branch," \xb7 "]}),(0,f.KN)(Date.parse(e.date))]}),e.smart&&(0,n.jsx)("span",{className:"refs",children:(0,n.jsx)("i",{className:"ref",children:c("git.stash.smart")})})]},e.sha))}):(0,n.jsx)("p",{className:"gx-note",children:c("git.loading")})]})}function tn(e){let{a:t,onClose:s}=e,{t:a}=(0,q.s9)(),[l,c]=(0,i.useState)(""),r=async()=>{s(),await t.run("stash",a("git.stash.saved"),"stash-save",{message:l})};return(0,n.jsxs)(et.aF,{title:a("git.stash.save"),onClose:s,children:[(0,n.jsx)("p",{className:"confirm-body",children:a("git.stash.save.body")}),(0,n.jsx)("input",{className:"input",autoFocus:!0,value:l,maxLength:200,placeholder:a("git.stash.save.placeholder"),onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&r()},"aria-label":a("git.stash.save.placeholder")}),(0,n.jsxs)("div",{className:"row confirm-actions",children:[(0,n.jsx)("button",{className:"btn ghost",onClick:s,children:a("common.cancel")}),(0,n.jsx)("button",{className:"btn primary",disabled:!!t.busy,onClick:()=>void r(),children:a("git.stash.save")})]})]})}function ta(e){var t,s;let{agent:a,stash:l,a:c}=e,{t:r}=(0,q.s9)(),[o,d]=(0,i.useState)(null),[u,h]=(0,i.useState)(null),[m,g]=(0,i.useState)(null),[x,j]=(0,i.useState)(null),[b,v]=(0,i.useState)(!1),[N,y]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!1;return d(null),h(null),g(null),j(null),y(null),Promise.all([p.FH.get("/agents/".concat(a.id,"/git/stash?sha=").concat(l.sha)),p.FH.get("/agents/".concat(a.id,"/git/commit?sha=").concat(l.sha))]).then(t=>{let[s,n]=t;if(e)return;d(s),h(n);let a=n.files[0];g(a?{path:a.path,untracked:!1,oldPath:a.oldPath}:s.untracked[0]?{path:s.untracked[0],untracked:!0}:null)}).catch(t=>!e&&y(t instanceof Error?t.message:r("git.loadError"))),()=>{e=!0}},[a.id,l.sha]),(0,i.useEffect)(()=>{if(!m||!o)return void j(null);let e=m.untracked?o.untrackedSha:l.sha;if(!e)return;let t=!1;return j(null),p.FH.get("/agents/".concat(a.id,"/git/commit-diff?sha=").concat(e,"&path=").concat(encodeURIComponent(m.path)).concat(m.oldPath?"&old=".concat(encodeURIComponent(m.oldPath)):"")).then(e=>!t&&j(e)).catch(e=>!t&&y(e instanceof Error?e.message:r("git.loadError"))),()=>{t=!0}},[a.id,l.sha,o,null==m?void 0:m.path,null==m?void 0:m.untracked]);let k=(0,i.useMemo)(()=>x?eS(x.diff):null,[x]),w=!!c.busy,C=e=>void c.run("stash",e?r("git.stash.popped"):r("git.stash.applied"),"stash-apply",{sha:l.sha,pop:e}),S=(null!=(t=null==u?void 0:u.files.length)?t:0)+(null!=(s=null==o?void 0:o.untracked.length)?s:0);return(0,n.jsxs)("section",{className:"gx-preview gx-commitview","aria-label":l.message,children:[(0,n.jsxs)("header",{className:"gx-chead",children:[(0,n.jsx)("h3",{children:l.message||"—"}),(0,n.jsxs)("div",{className:"muted small row gap-s wrap",children:[(0,n.jsxs)("span",{children:[l.branch&&"".concat(l.branch," \xb7 "),(0,f.KN)(Date.parse(l.date))]}),o&&(0,n.jsxs)("span",{children:["\xb7 ",r("git.hist.files",{count:S})]})]}),(0,n.jsxs)("div",{className:"row gap-s wrap",children:[(0,n.jsxs)("button",{className:"btn sm",disabled:w,title:r("git.stash.apply.hint"),onClick:()=>C(!1),children:[(0,n.jsx)(tt.A,{size:14}),r("git.stash.apply")]}),(0,n.jsx)("button",{className:"btn sm primary",disabled:w,title:r("git.stash.pop.hint"),onClick:()=>C(!0),children:r("git.stash.pop")}),(0,n.jsxs)("button",{className:"btn sm danger",disabled:w,onClick:()=>v(!0),children:[(0,n.jsx)(eP.A,{size:14}),r("git.stash.drop")]})]})]}),N?(0,n.jsx)("p",{className:"gx-note err",children:N}):u&&o?0===S?(0,n.jsx)("p",{className:"gx-note",children:r("git.hist.noFiles")}):(0,n.jsxs)("div",{className:"gx-cfilelist",role:"listbox",children:[u.files.map(e=>{var t,s;return(0,n.jsxs)("button",{role:"option","aria-selected":(null==m?void 0:m.path)===e.path&&!m.untracked,className:"gx-cfile ".concat((null==m?void 0:m.path)!==e.path||m.untracked?"":"sel"),onClick:()=>g({path:e.path,untracked:!1,oldPath:e.oldPath}),children:[(0,n.jsx)(eQ,{status:e.status}),(0,n.jsx)("span",{className:"mono nm",children:e.path}),(null!==e.additions||null!==e.deletions)&&(0,n.jsxs)("span",{className:"gx-counts sm",children:[(0,n.jsxs)("i",{className:"add",children:["+",null!=(t=e.additions)?t:0]}),(0,n.jsxs)("i",{className:"del",children:["−",null!=(s=e.deletions)?s:0]})]})]},"t-".concat(e.path))}),o.untracked.map(e=>(0,n.jsxs)("button",{role:"option","aria-selected":(null==m?void 0:m.path)===e&&m.untracked,className:"gx-cfile ".concat((null==m?void 0:m.path)===e&&m.untracked?"sel":""),onClick:()=>g({path:e,untracked:!0}),children:[(0,n.jsx)(eQ,{status:"untracked"}),(0,n.jsx)("span",{className:"mono nm",children:e})]},"u-".concat(e)))]}):(0,n.jsx)("p",{className:"gx-note",children:r("git.loading")}),m&&(0,n.jsx)("div",{className:"gx-body",children:k?k.binary?(0,n.jsx)("p",{className:"gx-note",children:r("git.diff.binary")}):0===k.hunks.length?(0,n.jsx)("p",{className:"gx-note",children:r("git.diff.empty")}):(0,n.jsx)(eO,{parsed:k,layout:"unified",path:m.path,cutOff:!!(null==x?void 0:x.truncated)}):(0,n.jsx)("p",{className:"gx-note",children:r("git.loading")})}),b&&(0,n.jsx)(et.TM,{danger:!0,title:r("git.stash.drop.title"),body:r("git.stash.drop.body",{name:l.message||"—"}),confirmLabel:r("git.stash.drop"),onClose:()=>v(!1),onConfirm:()=>{w||c.run("stash",r("git.stash.dropped"),"stash-drop",{sha:l.sha})},children:(0,n.jsx)("p",{className:"gx-lost",children:r("git.discard.all.warn")})})]})}var tl=s(6819),ti=s(50703),tc=s(75014),tr=s(10216);function to(e){let{a:t}=e,{t:s}=(0,q.s9)(),a=t.notice;return a?(0,n.jsxs)("div",{className:"gx-notice err",role:"alert",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("b",{className:"grow",children:a.title}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>t.setNotice(null),"aria-label":s("common.close"),children:(0,n.jsx)(eC.A,{size:14})})]}),(0,n.jsx)("pre",{children:a.text}),a.diverged&&(0,n.jsxs)("div",{className:"row gap-s wrap",children:[(0,n.jsx)("span",{className:"small muted",children:s("git.notice.diverged")}),(0,n.jsx)("button",{className:"btn sm",disabled:!!t.busy,onClick:()=>void t.run("pull",s("git.done.pull"),"pull",{mode:"merge"}),children:s("git.pull.merge")}),(0,n.jsx)("button",{className:"btn sm",disabled:!!t.busy,onClick:()=>void t.run("pull",s("git.done.pull"),"pull",{mode:"rebase"}),children:s("git.pull.rebase")})]})]}):null}function td(e){let{a:t,ahead:s,behind:a,detached:l,changeCount:i,onCommit:c}=e,{t:r}=(0,q.s9)(),o=!!t.busy;return(0,n.jsxs)("div",{className:"gx-acts",role:"group","aria-label":r("git.act.group"),children:[(0,n.jsx)("button",{className:"btn sm",disabled:o,title:"".concat(r("git.act.fetch"),": ").concat(r("git.act.fetch.hint")),"aria-label":r("git.act.fetch"),onClick:()=>void t.run("fetch",r("git.done.fetch"),"fetch"),children:"fetch"===t.busy?(0,n.jsx)(Q.A,{size:14,className:"spin"}):(0,n.jsx)(tl.A,{size:14})}),(0,n.jsxs)("button",{className:"btn sm",disabled:o,title:"".concat(r("git.act.pull"),": ").concat(r("git.act.pull.hint")),"aria-label":r("git.act.pull"),onClick:()=>void t.run("pull",r("git.done.pull"),"pull"),children:["pull"===t.busy?(0,n.jsx)(Q.A,{size:14,className:"spin"}):(0,n.jsx)(ti.A,{size:14}),a>0&&(0,n.jsx)("span",{className:"ct",children:a})]}),(0,n.jsxs)("button",{className:"btn sm",disabled:o||l,title:"".concat(r("git.act.push"),": ").concat(r("git.act.push.hint")),"aria-label":r("git.act.push"),onClick:()=>void t.run("push",r("git.done.push"),"push"),children:["push"===t.busy?(0,n.jsx)(Q.A,{size:14,className:"spin"}):(0,n.jsx)(tc.A,{size:14}),s>0&&(0,n.jsx)("span",{className:"ct",children:s})]}),(0,n.jsxs)("button",{className:"btn sm primary",disabled:o||0===i,title:0===i?r("git.commit.nothing"):void 0,onClick:c,children:["commit"===t.busy?(0,n.jsx)(Q.A,{size:14,className:"spin"}):(0,n.jsx)(tr.A,{size:14}),r("git.act.commit"),i>0&&(0,n.jsx)("span",{className:"ct",children:i})]})]})}var tu=s(92947),th=s(67384);function tm(e){let{agent:t,a:s,current:a,onSwitch:l}=e,{t:c}=(0,q.s9)(),[r,o]=(0,i.useState)(!1),[d,u]=(0,i.useState)(null),[h,m]=(0,i.useState)(""),[g,x]=(0,i.useState)(""),[j,b]=(0,i.useState)(null),[v,N]=(0,i.useState)(null),[y,k]=(0,i.useState)(""),w=(0,i.useRef)(null);(0,e1.s)(r,w,()=>o(!1)),(0,i.useEffect)(()=>{r&&(k(""),b(null),p.FH.get("/agents/".concat(t.id,"/git/branches")).then(u).catch(e=>k(e instanceof Error?e.message:"error")))},[r,t.id]);let C=(0,i.useMemo)(()=>{var e;return(null!=(e=null==d?void 0:d.local)?e:[]).filter(e=>e.name.toLowerCase().includes(h.toLowerCase()))},[d,h]),S=(0,i.useMemo)(()=>{var e,t;let s=new Set((null!=(e=null==d?void 0:d.local)?e:[]).map(e=>e.name));return(null!=(t=null==d?void 0:d.remote)?t:[]).filter(e=>!s.has(e.name.split("/").slice(1).join("/"))&&e.name.toLowerCase().includes(h.toLowerCase()))},[d,h]),A=async(e,t,n,a)=>{o(!1),await s.run(e,t,n,a)},E=/^[\w./-]+$/.test(g)&&!g.startsWith("-")&&!g.endsWith("/")&&!g.includes("..");return(0,n.jsxs)("div",{className:"gx-brmenu",ref:w,children:[(0,n.jsxs)("button",{type:"button",className:"btn sm","aria-expanded":r,"aria-haspopup":"dialog",onClick:()=>o(e=>!e),children:[(0,n.jsx)(ec.A,{size:14}),c("git.act.branches"),(0,n.jsx)(O.A,{size:13})]}),r&&(0,n.jsxs)("div",{className:"gx-pop",role:"dialog","aria-label":c("git.act.branches"),children:[(0,n.jsxs)("div",{className:"search",children:[(0,n.jsx)(ed.A,{size:14}),(0,n.jsx)("input",{className:"input",autoFocus:!0,placeholder:c("git.br.search"),value:h,onChange:e=>m(e.target.value),"aria-label":c("git.br.search")})]}),(0,n.jsxs)("div",{className:"gx-newbr",children:[(0,n.jsx)("input",{className:"input mono",placeholder:c("git.br.newPlaceholder"),value:g,onChange:e=>x(e.target.value.trim()),"aria-label":c("git.br.new",{branch:null!=a?a:""}),onKeyDown:e=>{"Enter"===e.key&&E&&A("switch",c("git.done.switch",{branch:g}),"switch",{branch:g,create:!0})}}),(0,n.jsxs)("button",{className:"btn sm",disabled:!E||!!s.busy,title:c("git.br.new",{branch:null!=a?a:"…"}),onClick:()=>void A("switch",c("git.done.switch",{branch:g}),"switch",{branch:g,create:!0}),children:[(0,n.jsx)(tu.A,{size:14}),c("git.br.create")]})]}),y&&(0,n.jsx)("p",{className:"gx-note err",children:y}),(0,n.jsxs)("div",{className:"gx-brlist",children:[C.length>0&&(0,n.jsx)("div",{className:"gx-brhead",children:c("git.br.local")}),C.map(e=>(0,n.jsxs)("div",{className:"gx-br ".concat(e.name===a?"cur":""),children:[(0,n.jsxs)("button",{className:"grow",disabled:e.name===a||!!s.busy,onClick:()=>{o(!1),l(e.name)},title:c("git.br.switchTo",{branch:e.name}),children:[(0,n.jsxs)("span",{className:"nm",children:[e.name===a&&(0,n.jsx)(e0.A,{size:13}),e.name]}),(0,n.jsxs)("span",{className:"sub",children:[e.subject," \xb7 ",(0,f.KN)(Date.parse(e.date))]})]}),e.name!==a&&(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:!!s.busy,onClick:()=>b(e.name),"aria-label":c("git.br.merge",{branch:null!=a?a:""}),title:c("git.br.merge",{branch:null!=a?a:""}),children:(0,n.jsx)(th.A,{size:14})}),e.name!==a&&(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:!!s.busy,onClick:()=>{s.setNotice(null),N(e.name),o(!1)},"aria-label":c("git.br.delete",{branch:e.name}),title:c("git.br.delete",{branch:e.name}),children:(0,n.jsx)(eP.A,{size:14})})]},e.name)),S.length>0&&(0,n.jsx)("div",{className:"gx-brhead",children:c("git.br.remote")}),S.map(e=>(0,n.jsxs)("div",{className:"gx-br",children:[(0,n.jsxs)("button",{className:"grow",disabled:!!s.busy,onClick:()=>{let t=e.name.split("/").slice(1).join("/");o(!1),l(t)},title:c("git.br.switchTo",{branch:e.name}),children:[(0,n.jsx)("span",{className:"nm",children:e.name}),(0,n.jsxs)("span",{className:"sub",children:[e.subject," \xb7 ",(0,f.KN)(Date.parse(e.date))]})]}),(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:!!s.busy,onClick:()=>b(e.name),"aria-label":c("git.br.merge",{branch:null!=a?a:""}),title:c("git.br.merge",{branch:null!=a?a:""}),children:(0,n.jsx)(th.A,{size:14})})]},e.name)),d&&!C.length&&!S.length&&(0,n.jsx)("p",{className:"gx-note",children:c("git.br.none")})]}),j&&(0,n.jsxs)("div",{className:"gx-mergeask",children:[(0,n.jsx)("span",{children:c("git.br.mergeAsk",{from:j,into:null!=a?a:""})}),(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("button",{className:"btn ghost sm",onClick:()=>b(null),children:c("common.cancel")}),(0,n.jsx)("button",{className:"btn primary sm",disabled:!!s.busy,onClick:()=>void A("merge",c("git.done.merge",{branch:j}),"merge",{branch:j}),children:c("git.br.mergeGo")})]})]})]}),v&&(0,n.jsxs)(et.aF,{title:c("git.br.delete",{branch:v}),onClose:()=>N(null),children:[(0,n.jsx)("p",{className:"confirm-body",children:c("git.br.deleteAsk",{branch:v})}),s.notice&&(0,n.jsx)("pre",{className:"gx-notice err gx-prewrap",children:s.notice.text}),(0,n.jsxs)("div",{className:"row confirm-actions",children:[(0,n.jsx)("button",{className:"btn ghost",onClick:()=>N(null),children:c("common.cancel")}),s.notice&&/not fully merged/i.test(s.notice.text)?(0,n.jsx)("button",{className:"btn danger",disabled:!!s.busy,onClick:async()=>{await s.run("branch-delete",c("git.done.branchDelete"),"branch-delete",{branch:v,force:!0})&&N(null)},children:c("git.br.deleteForce")}):(0,n.jsx)("button",{className:"btn danger",disabled:!!s.busy,onClick:async()=>{await s.run("branch-delete",c("git.done.branchDelete"),"branch-delete",{branch:v})&&N(null)},children:c("git.br.deleteGo")})]})]})]})}function tg(e){let{changes:t,a:s,onClose:a,initialMessage:l=""}=e,{t:c}=(0,q.s9)(),[r,o]=(0,i.useState)(()=>new Set(t.map(e=>e.path))),[d,u]=(0,i.useState)(l),h=t.filter(e=>r.has(e.path)),m=h.flatMap(e=>e.oldPath?[e.path,e.oldPath]:[e.path]),g=!!d.trim()&&h.length>0&&!s.busy,x=async e=>{if(!await s.run("commit",c("git.done.commit"),"commit",{message:d,paths:m}))return void a();a(),e&&await s.run("push",c("git.done.push"),"push")};return(0,n.jsxs)(et.aF,{title:c("git.commit.title"),onClose:a,children:[(0,n.jsxs)("div",{className:"gx-cfiles",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("span",{className:"small muted grow",children:c("git.commit.selected",{n:h.length,total:t.length})}),(0,n.jsx)("button",{className:"btn ghost sm",onClick:()=>o(new Set(t.map(e=>e.path))),children:c("git.commit.all")}),(0,n.jsx)("button",{className:"btn ghost sm",onClick:()=>o(new Set),children:c("git.commit.none")})]}),(0,n.jsx)("div",{className:"gx-clist",children:t.map(e=>{var t,s;return(0,n.jsxs)("label",{className:"gx-crow",title:e.path,children:[(0,n.jsx)("input",{type:"checkbox",checked:r.has(e.path),onChange:()=>{let t;return t=e.path,o(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})}}),(0,n.jsx)(eQ,{status:e.status}),(0,n.jsx)("span",{className:"mono nm",children:e.path}),(null!==e.additions||null!==e.deletions)&&(0,n.jsxs)("span",{className:"gx-counts sm",children:[(0,n.jsxs)("i",{className:"add",children:["+",null!=(t=e.additions)?t:0]}),(0,n.jsxs)("i",{className:"del",children:["−",null!=(s=e.deletions)?s:0]})]})]},e.path)})})]}),(0,n.jsxs)("div",{className:"field",children:[(0,n.jsx)("label",{children:c("git.commit.message")}),(0,n.jsx)("textarea",{className:"textarea",rows:4,autoFocus:!0,value:d,onChange:e=>u(e.target.value),placeholder:c("git.commit.placeholder"),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&g&&x(!1)}}),(0,n.jsx)("span",{className:"hint",children:c("git.commit.hint")})]}),(0,n.jsxs)("div",{className:"row confirm-actions",children:[(0,n.jsx)("button",{className:"btn ghost",onClick:a,children:c("common.cancel")}),(0,n.jsx)("button",{className:"btn",disabled:!g,onClick:()=>void x(!1),children:"commit"===s.busy?c("git.commit.committing"):c("git.commit.go")}),(0,n.jsx)("button",{className:"btn primary",disabled:!g,onClick:()=>void x(!0),children:c("git.commit.goPush")})]})]})}function tx(e){let{agent:t,head:s,sel:a,onSelect:l,refs:c,path:r,onClearPath:o}=e,{t:d}=(0,q.s9)(),[u,h]=(0,i.useState)(null),[m,g]=(0,i.useState)(!1),[x,j]=(0,i.useState)(!1),[b,v]=(0,i.useState)(""),[N,y]=(0,i.useState)(""),[k,w]=(0,i.useState)("message"),[C,S]=(0,i.useState)(""),[A,E]=(0,i.useState)("");(0,i.useEffect)(()=>{let e=setTimeout(()=>E(N.trim()),350);return()=>clearTimeout(e)},[N]);let z=!!(A||r||C),M=async e=>{j(!0);try{let s="skip=".concat(e).concat(A?"&q=".concat(encodeURIComponent(A),"&by=").concat(k):"").concat(r?"&path=".concat(encodeURIComponent(r)):"").concat(C?"&ref=".concat(encodeURIComponent(C)):""),n=await p.FH.get("/agents/".concat(t.id,"/git/log?").concat(s));return h(t=>0===e?n.commits:[...null!=t?t:[],...n.commits]),g(n.hasMore),v(""),n.commits}catch(e){return v(e instanceof Error?e.message:"error"),null}finally{j(!1)}},F=(0,i.useRef)("");return(0,i.useEffect)(()=>{let e="".concat(A,"|").concat(k,"|").concat(null!=r?r:"","|").concat(C),t=e!==F.current;F.current=e,M(0).then(e=>{e&&e.length&&(t||!a)&&l(e[0].sha)})},[t.id,s,A,k,r,C]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"gx-hfilter",children:[(0,n.jsxs)("div",{className:"search",children:[(0,n.jsx)(ed.A,{size:14}),(0,n.jsx)("input",{className:"input",placeholder:d("git.hist.search"),value:N,onChange:e=>y(e.target.value),"aria-label":d("git.hist.search"),title:"content"===k?d("git.hist.by.hint"):void 0})]}),(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsxs)("select",{className:"input",value:k,onChange:e=>w(e.target.value),"aria-label":d("git.hist.search"),title:d("git.hist.by.hint"),children:[(0,n.jsx)("option",{value:"message",children:d("git.hist.by.message")}),(0,n.jsx)("option",{value:"author",children:d("git.hist.by.author")}),(0,n.jsx)("option",{value:"content",children:d("git.hist.by.content")})]}),(0,n.jsx)(e4,{refs:c,value:C,onChange:S,extra:[{value:"",label:d("git.hist.branchCurrent")},{value:"all",label:d("git.hist.branchAll")}]})]}),r&&(0,n.jsxs)("div",{className:"gx-chip soft gx-pathchip",children:[(0,n.jsx)("span",{className:"mono nm",title:r,children:d("git.hist.file",{path:r})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:o,"aria-label":d("git.hist.clearFile"),title:d("git.hist.clearFile"),children:(0,n.jsx)(eC.A,{size:13})})]})]}),b?(0,n.jsx)("p",{className:"gx-note err",children:b}):u?u.length?(0,n.jsxs)("div",{className:"gx-hist",role:"listbox","aria-label":d("git.tab.history"),children:[u.map(e=>(0,n.jsxs)("button",{role:"option","aria-selected":a===e.sha,className:"gx-commit ".concat(a===e.sha?"sel":""),onClick:()=>l(e.sha),children:[(0,n.jsx)("span",{className:"subj",children:e.subject||"—"}),(0,n.jsxs)("span",{className:"meta",children:[(0,n.jsx)("span",{className:"mono sha",children:e.short})," \xb7 ",e.author," \xb7 ",(0,f.KN)(Date.parse(e.date))]}),(e.refs.length>0||e.merge)&&(0,n.jsxs)("span",{className:"refs",children:[e.merge&&(0,n.jsx)("i",{className:"ref",children:d("git.hist.merge")}),e.refs.slice(0,3).map(e=>(0,n.jsx)("i",{className:"ref",children:e},e))]})]},e.sha)),m&&(0,n.jsx)("button",{className:"btn sm gx-more",disabled:x,onClick:()=>void M(u.length),children:x?d("git.loading"):d("git.hist.more")})]}):(0,n.jsx)("p",{className:"gx-note",children:z?d("git.hist.noMatch"):d("git.hist.empty")}):(0,n.jsx)("p",{className:"gx-note",children:d("git.loading")})]})}function tp(e){let{files:t,all:s,summary:a,file:l,onConfirm:i,onClose:c}=e,{t:r}=(0,q.s9)(),o=(0,n.jsxs)("ul",{className:"gx-dlist",children:[t.slice(0,8).map(e=>(0,n.jsx)("li",{className:"mono",children:e},e)),t.length>8&&(0,n.jsx)("li",{className:"muted",children:r("hover.more",{count:t.length-8})})]});if(!s&&l&&!t.length){var d;let e=l.add||l.del?" (+".concat(l.add," −").concat(l.del,")"):"";return(0,n.jsxs)(et.TM,{danger:!0,title:r("git.discard.file.title"),confirmLabel:r("git.discard.file.go"),onConfirm:i,onClose:c,children:[(0,n.jsx)("p",{className:"gx-file-eff mono",children:l.path}),(0,n.jsx)("p",{className:"confirm-body",children:"deleted"===l.status?r("git.discard.file.deleted"):"renamed"===l.status?r("git.discard.file.renamed",{from:null!=(d=l.oldPath)?d:""}):r("git.discard.file.modified",{lines:e})}),(0,n.jsx)("p",{className:"gx-lost",children:r("git.discard.all.warn")})]})}return s?(0,n.jsxs)(et.TM,{danger:!0,title:r("git.discard.all.title"),confirmLabel:r("git.discard.all.go"),onConfirm:i,onClose:c,children:[(0,n.jsxs)("ul",{className:"gx-effects",children:[a&&a.restore>0&&(0,n.jsx)("li",{children:r("git.discard.all.restore",{count:a.restore})}),t.length>0&&(0,n.jsxs)("li",{className:"bad",children:[(0,n.jsx)("b",{children:r("git.discard.all.delete",{count:t.length})}),o]})]}),a&&(0,n.jsx)("p",{className:"muted small confirm-body",children:r("git.discard.all.lines",{add:a.add,del:a.del})}),(0,n.jsx)("p",{className:"gx-lost",children:r("git.discard.all.warn")})]}):(0,n.jsx)(et.TM,{danger:!0,title:r("git.discard.confirm.title"),body:r("git.discard.confirm.body",{count:t.length}),confirmLabel:r("git.discard.confirm.go"),onConfirm:i,onClose:c,children:o})}var tf=s(8591);function tj(e){var t,s;let a,{agent:l,path:c,ignored:r=!1,change:o,stamp:d,refs:u,focusLine:h,onHistory:g,onOpenCommit:x,onDiscard:f,onDiscardHunk:j,onDiscardLines:b,comments:v,commentsLocked:N=!1,commentFocus:y}=e,{t:k}=(0,q.s9)(),[w,C]=(0,i.useState)(!1),S=!!o&&!ey.test(c),A=ek.test(c),E=h?"file":S?"diff":A?"preview":"file",[z,M]=(0,i.useState)(E),[F,R]=(0,i.useState)("unified"),[P,I]=(0,i.useState)(null),[D,T]=(0,i.useState)(null),[L,U]=(0,i.useState)(null),[_,H]=(0,i.useState)(!1),[K,O]=(0,i.useState)(!1),B=ey.test(c),[$,Q]=(0,i.useState)(null);(0,i.useEffect)(()=>{Q(null)},[c]),(0,i.useEffect)(()=>{M(E),O(!1)},[c,S]),(0,i.useEffect)(()=>{let e=!1;U(null);let t="path=".concat(encodeURIComponent(c));return H(!0),("diff"===z&&o?p.FH.get("/agents/".concat(l.id,"/git/diff?").concat(t).concat(o.oldPath?"&old=".concat(encodeURIComponent(o.oldPath)):"")).then(t=>!e&&I(t)):B?Promise.resolve():p.FH.get("/agents/".concat(l.id,"/git/file?").concat(t)).then(t=>!e&&T(t))).catch(t=>!e&&U(t instanceof Error?t.message:k("git.loadError"))).finally(()=>!e&&H(!1)),()=>{e=!0}},[l.id,c,z,null==o?void 0:o.status,null==o?void 0:o.oldPath,d]);let G=(0,i.useMemo)(()=>P&&P.path===c?eS(P.diff):null,[P,c]);(0,i.useEffect)(()=>{!v||!G||G.binary||(null==P?void 0:P.truncated)||v.relocate(c,G)},[G]),(0,i.useEffect)(()=>{y&&o&&(Q(null),M("diff"),R("unified"))},[null==y?void 0:y.key]);let J=!!v&&"diff"===z&&!!o&&!!G&&!G.binary&&G.hunks.length>0,X=J&&!!G&&!$&&(a=!!(null==P?void 0:P.truncated),G.hunks.length>+!!a),Z=(0,i.useMemo)(()=>v?v.items.filter(e=>e.path===c):[],[null==v?void 0:v.items,c]),[V,Y]=(0,i.useState)(null),ee=(null==o?void 0:o.status)==="untracked"||(null==o?void 0:o.status)==="added"&&!o.oldPath;(0,i.useEffect)(()=>{if(Y(null),"file"!==z||!o||B||ee||"deleted"===o.status||"conflict"===o.status)return;let e=!1;return p.FH.get("/agents/".concat(l.id,"/git/diff?path=").concat(encodeURIComponent(c)).concat(o.oldPath?"&old=".concat(encodeURIComponent(o.oldPath)):"")).then(t=>!e&&Y(t)).catch(()=>void 0),()=>{e=!0}},[l.id,c,z,null==o?void 0:o.status,null==o?void 0:o.oldPath,d]);let es=(0,i.useMemo)(()=>V&&V.path===c?eS(V.diff):null,[V,c]),en=(0,i.useMemo)(()=>es?function(e){let t=new Map,s=new Set,n=new Map,a=new Map,l=[];for(let m of e.hunks){var i,c,r,o,d,u,h;let e=m.lines,g=[],x=Number(null!=(c=null==(i=/\+(\d+)/.exec(m.header))?void 0:i[1])?c:1);for(let t=0;t<e.length;t++)g[t]=x,"del"!==e[t].kind&&(x=(null!=(r=e[t].newNo)?r:x)+1);let p=[];for(let t=0;t<e.length;){if("ctx"===e[t].kind){t++;continue}let s=t;for(;t<e.length&&"ctx"!==e[t].kind;)t++;p.push([s,t-1])}for(let[i,c]of p){let r=l.length,m=1/0,p=-1/0;for(let l=i;l<=c;){if("ctx"===e[l].kind){l++;continue}let i=[],o=[];for(;l<=c&&"del"===e[l].kind;)i.push(e[l++]);for(;l<=c&&"add"===e[l].kind;)o.push(e[l++]);o.forEach((e,s)=>{let a=e.newNo;t.set(a,s<i.length?"mod":"add"),n.set(a,r),m=Math.min(m,a),p=Math.max(p,a)});let d=o.length?o[o.length-1].newNo+1:l<e.length?g[l]:x;i.length>o.length&&(s.add(d),a.set(d,r),m=Math.min(m,d),p=Math.max(p,d))}let f=i;for(let t=0;t<3&&f>0&&"ctx"===e[f-1].kind;t++)f--;let j=c;for(let t=0;t<3&&j<e.length-1&&"ctx"===e[j+1].kind;t++)j++;let b=e.slice(f,j+1),v=b.filter(e=>void 0!==e.oldNo),N=b.filter(e=>void 0!==e.newNo);l.push({from:m,to:p,view:{header:"@@ -".concat(null!=(u=null==(o=v[0])?void 0:o.oldNo)?u:0,",").concat(v.length," +").concat(null!=(h=null==(d=N[0])?void 0:d.newNo)?h:0,",").concat(N.length," @@"),section:"",lines:b}})}}return{lines:t,removedBefore:s,blockOfLine:n,blockOfRemoval:a,groups:l}}(es):null,[es]),el=c.lastIndexOf("/"),ei=el>=0?c.slice(0,el+1):"",ec=c.slice(el+1);return(0,n.jsxs)("section",{className:"gx-preview","aria-label":c,children:[(0,n.jsxs)("header",{className:"gx-phead",children:[(0,n.jsxs)("div",{className:"gx-ptitle",children:[(0,n.jsxs)("span",{className:"gx-path mono",title:c,children:[(0,n.jsx)("span",{className:"dir",children:ei}),(0,n.jsx)("b",{children:ec})]}),r&&(0,n.jsx)("span",{className:"gx-chip soft",title:k("git.ignored.hint"),children:k("git.ignored.chip")}),o&&(0,n.jsx)("span",{className:"gx-chip st-".concat(o.status),children:k("git.status.".concat(o.status))}),(null==o?void 0:o.staged)&&(0,n.jsx)("span",{className:"gx-chip soft",children:k("git.staged")}),(null==o?void 0:o.unstaged)&&"untracked"!==o.status&&(0,n.jsx)("span",{className:"gx-chip soft",children:k("git.unstaged")}),o&&(null!==o.additions||null!==o.deletions)&&(0,n.jsxs)("span",{className:"gx-counts",children:[(0,n.jsxs)("i",{className:"add",children:["+",null!=(t=o.additions)?t:0]}),(0,n.jsxs)("i",{className:"del",children:["−",null!=(s=o.deletions)?s:0]})]}),D&&!o&&(0,n.jsx)("span",{className:"muted small",children:(0,W.zi)(D.size)})]}),(0,n.jsxs)("div",{className:"gx-ptr",children:[(null==o?void 0:o.status)!=="untracked"&&!r&&(0,n.jsx)("button",{type:"button",className:"btn ghost icon sm",title:k("git.file.history"),"aria-label":k("git.file.history"),onClick:()=>g(c),children:(0,n.jsx)(m.A,{size:15})}),(null==o?void 0:o.status)!=="untracked"&&!r&&(0,n.jsx)(e4,{refs:u,value:null!=$?$:"",onChange:Q,compact:!0,label:k("git.file.viewAt"),extra:[{value:"",label:k("git.file.viewAt")}]}),!B&&!r&&!$&&(null==o?void 0:o.status)!=="deleted"&&(null==o?void 0:o.status)!=="untracked"&&(null==o?void 0:o.status)!=="conflict"&&(()=>{let e=w&&"file"===z;return(0,n.jsx)("button",{type:"button",className:"btn ghost icon sm ".concat(e?"on":""),"aria-pressed":e,"aria-label":k("git.blame"),title:"".concat(k("git.blame"),": ").concat(k("git.blame.hint")),onClick:()=>{"file"!==z?(M("file"),C(!0)):C(e=>!e)},children:(0,n.jsx)(tf.A,{size:15})})})(),(0,n.jsx)(ea.WQ,{text:c,label:k("git.copyPath"),compact:!0}),o&&"conflict"!==o.status&&(0,n.jsxs)("button",{type:"button",className:"btn sm",title:k("git.discard.hint"),onClick:()=>f(o),children:[(0,n.jsx)(eo.A,{size:14}),k("git.discard")]})]}),(0,n.jsx)("div",{className:"gx-ptools",children:(0,n.jsxs)("div",{className:"gx-ptl",children:[(o||A)&&(0,n.jsx)(et.$q,{value:z,onChange:M,options:[...o?[{id:"diff",label:k("git.view.diff")}]:[],...A?[{id:"preview",label:k("git.view.preview")}]:[],{id:"file",label:k(A?"git.view.source":"git.view.file")}]}),"diff"===z&&o&&(0,n.jsx)(et.$q,{value:F,onChange:R,options:[{id:"unified",label:k("git.layout.unified")},{id:"split",label:k("git.layout.split")}]}),X&&"unified"===F&&(0,n.jsxs)("span",{className:"dc-hint",children:[(0,n.jsx)("span",{className:"fine",children:k("diffc.hint")}),(0,n.jsx)("span",{className:"coarse",children:k("diffc.hint.touch")})]})]})})]}),(null==o?void 0:o.oldPath)&&(0,n.jsx)("div",{className:"gx-banner",children:k("git.renamedFrom",{path:o.oldPath})}),X&&"split"===F&&(0,n.jsxs)("div",{className:"gx-banner row gap-s",children:[(0,n.jsx)("span",{className:"grow",children:k("diffc.splitHint")}),(0,n.jsx)("button",{type:"button",className:"btn sm",onClick:()=>R("unified"),children:k("diffc.splitHint.go")})]}),$&&(0,n.jsxs)("div",{className:"gx-banner row gap-s",children:[(0,n.jsx)("span",{className:"grow",children:k("git.file.atRef",{ref:$})}),(0,n.jsx)("button",{className:"btn sm",onClick:()=>Q(null),children:k("git.file.backToCurrent")})]}),$?(0,n.jsx)(eB,{agent:l,gitRef:$,path:(null==o?void 0:o.oldPath)&&$?o.oldPath:c,toolbar:!1}):(0,n.jsx)("div",{className:"gx-body",children:L?(0,n.jsx)("p",{className:"gx-note err",children:L}):!_||G||D?"diff"===z&&o?G?G.binary?(0,n.jsx)("p",{className:"gx-note",children:k("git.diff.binary")}):0===G.hunks.length?(0,n.jsx)("p",{className:"gx-note",children:k("git.diff.empty")}):(0,n.jsxs)(n.Fragment,{children:[(null==P?void 0:P.truncated)&&(0,n.jsx)("div",{className:"gx-banner",children:k("git.diff.truncated")}),(0,n.jsx)(eO,{parsed:G,layout:F,path:c,cutOff:!!(null==P?void 0:P.truncated),onDiscardHunk:(null==o?void 0:o.status)==="modified"?(e,t)=>j(c,e,t):void 0,onDiscardLines:(null==o?void 0:o.status)==="modified"?(e,t,s)=>b(c,e,t,s):void 0,comments:J&&v&&"unified"===F?{items:Z,store:v,total:v.items.length,focus:y&&Z.some(e=>e.id===y.id)?y:void 0,locked:N}:void 0})]}):null:B&&!K&&(null==o?void 0:o.status)!=="deleted"?(0,n.jsx)("div",{className:"gx-image",children:(0,n.jsx)("img",{src:"/api/agents/".concat(l.id,"/git/raw?path=").concat(encodeURIComponent(c),"&v=").concat(d),alt:ec,onError:()=>O(!0)})}):"preview"===z&&D&&D.path===c?(0,n.jsxs)("div",{className:"gx-md md",children:[D.truncated&&(0,n.jsx)("div",{className:"gx-banner",children:k("git.diff.truncated")}),(0,n.jsx)(ev.oz,{remarkPlugins:[eN.A],components:{a:e=>(0,n.jsx)("a",{...e,target:"_blank",rel:"noreferrer"})},children:D.content})]}):D&&D.path===c?(0,n.jsx)(eq,{f:D,agent:l,blame:w,onOpenCommit:x,marks:en,allNew:ee,focusLine:h}):B&&K?(0,n.jsx)("p",{className:"gx-note",children:k("git.file.binary")}):null:(0,n.jsx)("p",{className:"gx-note",children:k("git.loading")})})]})}var tb=s(43249),tv=s(19431),tN=s(63745);function ty(e){let{name:t}=e;return ey.test(t)?(0,n.jsx)(tb.A,{size:15}):/\.(md|mdx|txt|rst)$/i.test(t)?(0,n.jsx)(tv.A,{size:15}):(0,eF.eX)(t)?(0,n.jsx)(tN.A,{size:15}):(0,n.jsx)(eu.A,{size:15})}let tk=(0,i.memo)(function(e){var t,s;let{rows:a,expanded:l,forceOpen:c,sel:r,onToggle:o,onSelect:d,label:u}=e,{t:h}=(0,q.s9)(),m=(0,i.useRef)(null),[g,x]=(0,i.useState)(null),p=e=>"".concat(e.ignored?"i:":"").concat(e.path),f=a.some(e=>p(e.node)===g)?g:null!=(s=null==(t=a.find(e=>e.node.path===r&&!e.node.ignored))?void 0:t.node.path)?s:a[0]?p(a[0].node):null,j=(0,i.useCallback)(e=>{var t,s;let n=[...null!=(s=null==(t=m.current)?void 0:t.querySelectorAll("[data-row]"))?s:[]],a=n.indexOf(document.activeElement),l=t=>{var s;e.preventDefault(),null==(s=n[Math.max(0,Math.min(n.length-1,t))])||s.focus()};if("ArrowDown"===e.key)l(a+1);else if("ArrowUp"===e.key)l(a-1);else if("Home"===e.key)l(0);else if("End"===e.key)l(n.length-1);else if(a>=0&&("ArrowRight"===e.key||"ArrowLeft"===e.key)){let t=n[a],s="1"===t.dataset.dir,i="true"===t.getAttribute("aria-expanded");if("ArrowRight"===e.key)s&&!i?(e.preventDefault(),t.click()):s&&i&&l(a+1);else if(s&&i)e.preventDefault(),t.click();else{let e=Number(t.getAttribute("aria-level"));for(let t=a-1;t>=0;t--)if(Number(n[t].getAttribute("aria-level"))<e){l(t);break}}}},[]);return(0,n.jsx)("div",{className:"gx-tree-rows",ref:m,onKeyDown:j,role:"tree","aria-label":u,children:a.map(e=>{var t,s;let{node:a,depth:i}=e,u="dir"===a.type,m=u&&(c||l.has(a.path)),g=a.change,j=p(a);return(0,n.jsxs)("button",{"data-row":!0,"data-dir":u?"1":"0","data-path":a.path,type:"button",role:"treeitem","aria-level":i+1,"aria-expanded":u?!!m:void 0,"aria-selected":!u&&r===a.path,tabIndex:f===j?0:-1,onFocus:()=>x(j),className:"gx-row ".concat(u?"dir":"file"," ").concat(a.ignored?"ignored":""," ").concat(g?"changed st-".concat(g.status):""," ").concat(!u&&r===a.path?"sel":""," ").concat(u&&a.changed?"has-changes":""),style:{paddingLeft:8+14*i},title:a.ignored?"".concat(a.path,": ").concat(h("git.ignored.hint")):a.path,onClick:()=>u?o(a):d(a.path),children:[(0,n.jsx)("span",{className:"chev",children:u?m?(0,n.jsx)(O.A,{size:14}):(0,n.jsx)(er.A,{size:14}):null}),(0,n.jsx)("span",{className:"ico",children:u?m?(0,n.jsx)(eb.A,{size:15}):(0,n.jsx)(el.A,{size:15}):(0,n.jsx)(ty,{name:a.name})}),(0,n.jsx)("span",{className:"nm",children:a.name}),u&&a.changed>0&&(0,n.jsx)("span",{className:"dirdot",title:h("git.dirChanged",{count:a.changed}),children:a.changed}),g&&(0,n.jsxs)("span",{className:"meta",children:[(null!==g.additions||null!==g.deletions)&&(0,n.jsxs)("span",{className:"gx-counts sm",children:[(0,n.jsxs)("i",{className:"add",children:["+",null!=(t=g.additions)?t:0]}),(0,n.jsxs)("i",{className:"del",children:["−",null!=(s=g.deletions)?s:0]})]}),(0,n.jsx)(eQ,{status:g.status,titled:!0})]})]},j)})})});var tw=s(32898),tC=s(61904),tS=s(2507);let tA=["files","history","tags","compare","stashes"],tE={files:tw.A,history:m.A,tags:ej.A,compare:tC.A,stashes:tS.A},tz=e=>"gx-tab-".concat(e),tM="gx-side-panel";function tF(e){let{mode:t,onChange:s,stashCount:a,label:l}=e,{t:i}=(0,q.s9)(),c=e=>"".concat(i("git.tab.".concat(e))).concat("stashes"===e&&a?" \xb7 ".concat(a):"");return(0,n.jsx)("div",{className:"gx-tabs",role:"tablist","aria-label":l,onKeyDown:e=>{let n=tA.indexOf(t),a=null;"ArrowRight"===e.key||"ArrowDown"===e.key?a=(n+1)%tA.length:"ArrowLeft"===e.key||"ArrowUp"===e.key?a=(n-1+tA.length)%tA.length:"Home"===e.key?a=0:"End"===e.key&&(a=tA.length-1),null!==a&&(e.preventDefault(),s(tA[a]),requestAnimationFrame(()=>{var e;return null==(e=document.getElementById(tz(tA[a])))?void 0:e.focus()}))},children:tA.map((e,a)=>{let l=tE[e];return(0,n.jsxs)("button",{id:tz(e),type:"button",role:"tab","aria-selected":t===e,"aria-controls":tM,tabIndex:t===e?0:-1,"aria-label":c(e),title:"".concat(c(e)," (Alt+").concat(a+1,")"),className:"gx-tab ".concat(t===e?"on":""),onClick:()=>s(e),children:[(0,n.jsx)(l,{size:15}),t===e&&(0,n.jsx)("span",{children:c(e)})]},e)})})}function tR(e){var t,s,a,l,c,r,o,d,u,h;let{agent:m,git:g,comments:x}=e,{t:j}=(0,q.s9)(),{status:v,tree:N,loading:y,error:k,refresh:w}=g,[C,S]=(0,i.useState)(null),[A,E]=(0,i.useState)(new Set),[z,M]=(0,i.useState)(""),[F,R]=(0,i.useState)(!1),[P,I]=(0,i.useState)(!1),[D,T]=(0,i.useState)("files"),[L,U]=(0,i.useState)(null),[_,H]=(0,i.useState)({base:"",head:""}),[K,B]=(0,i.useState)(!1),[$,Q]=(0,i.useState)(null),[G,J]=(0,i.useState)(),X=(0,i.useRef)(null),[Z,V]=(0,i.useState)(null),[Y,ee]=(0,i.useState)(null),[es,en]=(0,i.useState)(null),[ej,eb]=(0,i.useState)(!1),[ev,eN]=(0,i.useState)(null),[ey,ek]=(0,i.useState)(!1),[ew,eC]=(0,i.useState)(null),[eS,eA]=(0,i.useState)(!1),eE=function(e,t){let{t:s}=(0,q.s9)(),n=(0,et.dj)(),[a,l]=(0,i.useState)(null),[c,r]=(0,i.useState)(null),o=async function(a,i,c){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};l(a),r(null);try{var d,u,h;let a=await p.FH.post("/agents/".concat(e.id,"/git/").concat(c),o),l=null!=(h=(null!=(u=a.output)?u:"").split("\n").filter(Boolean).pop())?h:"",r=["conflicts"===a.pending?s("git.pending.conflicts"):"",(null==(d=a.kept)?void 0:d.length)?s("git.sw.kept",{count:a.kept.length,names:a.kept.slice(0,3).join(", ")}):""].filter(Boolean).join(", ");return n(r?"".concat(i,": ").concat(r):l&&l.length<90?"".concat(i,": ").concat(l):i),await t(),!0}catch(n){let e=n instanceof Error?n.message:"error";return r({title:s("git.notice.failed",{action:i}),text:e,diverged:/fast-forward|divergent/i.test(e)}),await t(),!1}finally{l(null)}};return{busy:a,notice:c,setNotice:r,run:o}}(m,()=>w()),[ez,eM]=(0,i.useState)(null),eF=(0,ep.Wx)(),eR=(0,i.useRef)(new Set),eP=v&&v.isRepo?v:null,eI=function(e,t){let[s,n]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let t=!1;return p.FH.get("/agents/".concat(e.id,"/git/refs")).then(e=>!t&&n(e)).catch(()=>!t&&n({current:null,branches:[],remotes:[],tags:[]})),()=>{t=!0}},[e.id,t]),s}(m,null==eP||null==(t=eP.head)?void 0:t.sha),eD=N&&N.isRepo?N.files:null,eT=N&&N.isRepo?N.ignored:null,[eL,eU]=(0,i.useState)({});(0,i.useEffect)(()=>{eU({})},[m.id,m.effective.cwd]);let eH=(0,i.useMemo)(()=>eP&&eD?eg(eD,eP.changes,eF.showIgnored&&null!=eT?eT:[],eL):null,[eP,eD,eT,eL,eF.showIgnored]),eK=(0,i.useMemo)(()=>{let e=(null!=eT?eT:[]).map(e=>e.replace(/\/$/,""));return t=>e.some(e=>t===e||t.startsWith("".concat(e,"/")))},[eT]),eO=(0,i.useMemo)(()=>{var e;return new Map((null!=(e=null==eP?void 0:eP.changes)?e:[]).map(e=>[e.path,e]))},[eP]),eW=(0,i.useMemo)(()=>{var e;return(null!=(e=null==eP?void 0:eP.changes)?e:[]).reduce((e,t)=>{var s,n;return{add:e.add+(null!=(s=t.additions)?s:0),del:e.del+(null!=(n=t.deletions)?n:0)}},{add:0,del:0})},[eP]);(0,i.useEffect)(()=>{if(!eH)return;let e=new Set,t=s=>{for(let a of s.children)if("dir"===a.type){var n;!eR.current.has(a.path)&&(a.changed>0||0===eR.current.size&&(null!=(n=null==eD?void 0:eD.length)?n:0)<=40)&&e.add(a.path),t(a)}};t(eH);let s=e=>{for(let t of e.children)"dir"===t.type&&(eR.current.add(t.path),s(t))};s(eH),e.size&&E(t=>new Set([...t,...e]))},[eH]);let eq="hive-am.git.where.".concat(m.id),[eB,e$]=(0,i.useState)(!1),eQ=(0,i.useRef)(null);(0,i.useEffect)(()=>{var e,t,s;if(!eH||eB)return;let n=(0,b.CL)(eq,{}),a=e=>!!e&&(!!(null==eD?void 0:eD.includes(e))||!!(null==eP?void 0:eP.changes.some(t=>t.path===e))),l=a(n.file)?n.file:null!=(s=null==(e=null!=(t=null==eP?void 0:eP.changes.find(e=>"conflict"===e.status))?t:null==eP?void 0:eP.changes[0])?void 0:e.path)?s:null;l&&S(l);let i=[...Array.isArray(n.dirs)?n.dirs.filter(e=>"string"==typeof e):[],...a(n.file)?function(e){let t=e.split("/");return t.pop(),t.map((e,s)=>t.slice(0,s+1).join("/"))}(n.file):[]];i.length&&E(e=>new Set([...e,...i])),n.mode&&tA.includes(n.mode)&&T(n.mode),"string"==typeof n.hist&&U(n.hist),"string"==typeof n.commit&&eC(n.commit),n.cmp&&"string"==typeof n.cmp.base&&"string"==typeof n.cmp.head&&H(n.cmp),"string"==typeof n.stash&&en(n.stash),"string"==typeof n.tag&&(eQ.current=n.tag),e$(!0)},[eH]),(0,i.useEffect)(()=>{var e,t;eB&&(0,b.zS)(eq,{file:null!=C?C:void 0,dirs:[...A].slice(0,200),mode:D,hist:null!=L?L:void 0,commit:null!=ew?ew:void 0,cmp:_.base||_.head?_:void 0,stash:null!=es?es:void 0,tag:null!=(t=null!=(e=null==Z?void 0:Z.name)?e:eQ.current)?t:void 0})},[eB,eq,C,A,D,L,ew,_,es,Z]),(0,i.useEffect)(()=>{let e=!1;return p.FH.get("/agents/".concat(m.id,"/git/stashes")).then(t=>{e||(ee(t),en(e=>{var s,n;return e&&t.some(t=>t.sha===e)?e:null!=(n=null==(s=t[0])?void 0:s.sha)?n:null}))}).catch(()=>void 0),()=>{e=!0}},[m.id,null==eP?void 0:eP.generatedAt]),(0,i.useEffect)(()=>{let e=z.trim();if(!K||e.length<2)return void Q(null);let t=!1,s=setTimeout(()=>p.FH.get("/agents/".concat(m.id,"/git/grep?q=").concat(encodeURIComponent(e))).then(s=>!t&&Q({q:e,...s})).catch(()=>!t&&Q({q:e,hits:[],truncated:!1})),350);return()=>{t=!0,clearTimeout(s)}},[m.id,K,z,null==eP?void 0:eP.generatedAt]),(0,i.useEffect)(()=>{let e=e=>{let t=e.target,s=!!t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||"SELECT"===t.tagName||t.isContentEditable);"/"!==e.key||s||e.ctrlKey||e.metaKey||e.altKey?e.altKey&&!e.ctrlKey&&!e.metaKey&&/^[1-5]$/.test(e.key)&&(e.preventDefault(),T(tA[Number(e.key)-1])):(e.preventDefault(),T("files"),setTimeout(()=>{var e;return null==(e=X.current)?void 0:e.focus()},0))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]);let eG=(0,i.useMemo)(()=>eH?ex(eH,A,{query:z,onlyChanged:F}):[],[eH,A,z,F]),eJ=(0,i.useMemo)(()=>eG.slice(0,2e3),[eG]),eY=(0,i.useRef)(eL);eY.current=eL;let e0=(0,i.useCallback)(e=>{let t;t=e.path,E(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s}),!e.ignored||!e.lazy||e.path in eY.current||p.FH.get("/agents/".concat(m.id,"/git/ls?path=").concat(encodeURIComponent(e.path))).then(t=>eU(s=>({...s,[e.path]:t.entries}))).catch(()=>eU(t=>({...t,[e.path]:[]})))},[m.id]),e1=(0,i.useCallback)(e=>{J(void 0),S(e)},[]),[e4,e3]=(0,i.useState)(!1),[e5,e6]=(0,i.useState)(),te=(0,i.useCallback)((e,t)=>{T("files"),e1(e.path),e6({id:e.id,key:Date.now(),edit:t})},[e1]);if((0,i.useEffect)(()=>{x&&eP&&x.syncChanges(new Set(eP.changes.map(e=>e.path)),eP.truncated)},[null==eP?void 0:eP.generatedAt]),k&&!v)return(0,n.jsx)("div",{className:"gx",children:(0,n.jsxs)("div",{className:"gx-empty",children:[(0,n.jsx)("h3",{children:j("git.error.title")}),(0,n.jsx)("p",{children:k}),(0,n.jsx)("button",{className:"btn",onClick:()=>void w(),children:j("git.refresh")})]})});if(!v)return(0,n.jsx)("div",{className:"gx",children:(0,n.jsx)("div",{className:"gx-empty",children:(0,n.jsx)("p",{children:j("git.loading")})})});if(!v.isRepo)return(0,n.jsx)("div",{className:"gx",children:(0,n.jsxs)("div",{className:"gx-empty",children:[(0,n.jsx)(el.A,{size:26,className:"muted"}),(0,n.jsx)("h3",{children:"not-repo"===v.reason?j("git.notRepo.title"):"no-git"===v.reason?j("git.noGit.title"):j("git.error.title")}),(0,n.jsx)("p",{children:"not-repo"===v.reason?j("git.notRepo.body",{path:v.cwd.replace(/^\/home\/[^/]+/,"~")}):"no-git"===v.reason?j("git.noGit.body"):v.message}),(0,n.jsxs)("button",{className:"btn",onClick:()=>void w(),children:[(0,n.jsx)(ei.A,{size:14}),j("git.refresh")]})]})});let tt=C?eO.get(C):void 0,tl=e=>eE.run("switch",e.carried?j("git.done.switchCarried",{branch:e.to,count:e.carried}):j("git.done.switch",{branch:e.to}),e.overlap.length||e.collisions.length?"switch-smart":"switch",{branch:e.to}),ti=async e=>{try{let t=await p.FH.get("/agents/".concat(m.id,"/git/switch-plan?branch=").concat(encodeURIComponent(e)));t.others.length||t.selfRunning?eN(t):await tl(t)}catch(t){eE.setNotice({title:j("git.notice.failed",{action:j("git.done.switch",{branch:e})}),text:t instanceof Error?t.message:"error",diverged:!1})}},tc=e=>e.filter(e=>"untracked"===e.status||"added"===e.status&&!e.oldPath).map(e=>e.path),tr=(0,W.Xd)(v.generatedAt);return(0,n.jsxs)("div",{className:"gx","data-gx-theme":eF.theme,style:{"--g-tab":eF.tabSize},children:[(0,n.jsxs)("div",{className:"gx-bar",children:[(0,n.jsxs)("button",{type:"button",className:"gx-branch","aria-expanded":P,"aria-controls":"gx-info",title:j("git.info.toggle"),onClick:()=>I(e=>!e),children:[(0,n.jsx)(ec.A,{size:14}),(0,n.jsx)("span",{className:"bn",children:null!=(c=v.branch)?c:v.head?"".concat(j("git.detached")," ").concat(v.head.sha):j("git.noCommitsBranch")}),v.head&&(0,n.jsx)("span",{className:"sha",children:v.head.sha}),v.upstream&&(v.upstream.ahead>0||v.upstream.behind>0)&&(0,n.jsxs)("span",{className:"ab",title:j("git.upstream"),children:[v.upstream.ahead>0&&"↑".concat(v.upstream.ahead),v.upstream.ahead>0&&v.upstream.behind>0&&" ",v.upstream.behind>0&&"↓".concat(v.upstream.behind)]}),P?(0,n.jsx)(O.A,{size:14}):(0,n.jsx)(er.A,{size:14})]}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsx)("span",{className:"gx-sum",children:0===v.changes.length?(0,n.jsx)("span",{className:"muted",children:j("git.clean")}):(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("span",{title:j("git.summary",{count:v.changes.length}),"aria-label":j("git.summary",{count:v.changes.length}),children:[(0,n.jsx)("b",{children:v.changes.length})," ",(0,n.jsx)("span",{className:"muted",children:j("git.files.short")})," ",(0,n.jsxs)("i",{className:"add",children:["+",(0,W._E)(eW.add)]})," ",(0,n.jsxs)("i",{className:"del",children:["−",(0,W._E)(eW.del)]})]})})}),(0,n.jsx)(tm,{agent:m,a:eE,current:v.branch,onSwitch:e=>void ti(e)}),(0,n.jsx)(td,{a:eE,ahead:null!=(r=null==(s=v.upstream)?void 0:s.ahead)?r:0,behind:null!=(o=null==(a=v.upstream)?void 0:a.behind)?o:0,detached:!v.branch,changeCount:v.changes.length,onCommit:()=>eA(!0)}),(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:!!eE.busy||0===v.changes.length||!!v.state,onClick:()=>{let e=tc(v.changes);eM({files:e,all:!0,summary:{restore:v.changes.length-e.length,add:eW.add,del:eW.del},go:async()=>{let e=await eE.run("discard-all",j("git.done.discard"),"discard-all");return e&&S(null),e}})},"aria-label":j("git.discard.all"),title:v.state?j("git.discard.all.blocked"):j("git.discard.all"),children:(0,n.jsx)(eo.A,{size:15})}),(0,n.jsx)(ef.i,{}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>void w(),"aria-label":j("git.refresh"),title:"".concat(j("git.refresh")," \xb7 ").concat(j("git.updated",{time:tr})),children:(0,n.jsx)(ei.A,{size:15,className:y?"spin":""})})]}),P&&(0,n.jsxs)("dl",{id:"gx-info",className:"gx-info",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:j("git.info.branch")}),(0,n.jsxs)("dd",{className:"mono",children:[null!=(d=v.branch)?d:v.head?"".concat(j("git.detached")," ").concat(v.head.sha):j("git.noCommitsBranch"),v.branch&&(0,n.jsx)(ea.WQ,{text:v.branch,label:j("git.info.copyBranch")})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:j("git.info.upstreamLabel")}),(0,n.jsx)("dd",{children:v.upstream?0===v.upstream.ahead&&0===v.upstream.behind?j("git.info.inSync"):j("git.info.upstreamStatus",{ahead:v.upstream.ahead,behind:v.upstream.behind}):(0,n.jsx)("span",{className:"muted",children:j("git.info.noUpstream")})})]}),v.head?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:j("git.info.commit")}),(0,n.jsxs)("dd",{className:"mono",children:[v.head.sha,(0,n.jsx)(ea.WQ,{text:v.head.sha,label:j("git.info.copySha")})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:j("git.info.message")}),(0,n.jsx)("dd",{className:"msg",children:v.head.subject||(0,n.jsx)("span",{className:"muted",children:"—"})})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:j("git.info.author")}),(0,n.jsx)("dd",{children:v.head.author})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:j("git.info.when")}),(0,n.jsxs)("dd",{children:[(0,W.v7)(v.head.when)," ",(0,n.jsxs)("span",{className:"muted",children:["\xb7 ",(0,f.KN)(Date.parse(v.head.when))]})]})]})]}):(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:j("git.info.commit")}),(0,n.jsx)("dd",{className:"muted",children:j("git.noCommits")})]})]}),"running"===m.status&&(0,n.jsx)("div",{className:"gx-warn",children:j("git.warn.running",{name:m.name})}),v.state&&(()=>{let e=v.changes.filter(e=>"conflict"===e.status),t="merge"===v.state?j("git.state.merge"):"rebase"===v.state?j("git.state.rebase"):j("git.state.stash");return(0,n.jsxs)("div",{className:"gx-state",role:"status",children:[(0,n.jsx)("b",{children:t}),(0,n.jsxs)("span",{className:"grow",children:["stash"===v.state&&v.stash&&(0,n.jsxs)(n.Fragment,{children:[j("git.state.stash.hint",{from:v.stash.from,to:v.stash.to})," \xb7 "]}),e.length>0?j("git.state.conflicts",{count:e.length}):j("git.state.ready")]}),0===e.length&&("merge"===v.state?(0,n.jsx)("button",{className:"btn primary sm",disabled:!!eE.busy,onClick:()=>eA(!0),children:j("git.state.finishMerge")}):"rebase"===v.state?(0,n.jsx)("button",{className:"btn primary sm",disabled:!!eE.busy,onClick:()=>void eE.run("continue",j("git.done.rebaseContinue"),"rebase-continue"),children:j("git.state.continueRebase")}):(0,n.jsx)("button",{className:"btn primary sm",disabled:!!eE.busy,onClick:()=>void eE.run("smart",j("git.done.smartFinish"),"smart-finish"),children:j("git.state.finishStash")})),"stash"===v.state?(0,n.jsx)("button",{className:"btn sm danger",disabled:!!eE.busy,onClick:()=>ek(!0),children:j("git.state.cancelStash")}):(0,n.jsx)("button",{className:"btn sm danger",disabled:!!eE.busy,onClick:()=>void eE.run("abort",j("git.done.mergeAbort"),"merge-abort"),children:"merge"===v.state?j("git.state.abortMerge"):j("git.state.abortRebase")})]})})(),(0,n.jsx)(to,{a:eE}),v.scope&&(0,n.jsx)("div",{className:"gx-scope",children:j("git.scope",{path:v.scope})}),(0,n.jsxs)("div",{className:"gx-main",children:[(0,n.jsxs)("aside",{className:"gx-tree","aria-label":j("git.filesLabel"),children:[(0,n.jsx)(tF,{mode:D,onChange:T,stashCount:null!=(u=null==Y?void 0:Y.length)?u:0,label:j("git.filesLabel")}),(0,n.jsx)("div",{className:"gx-sidepanel",id:tM,role:"tabpanel","aria-labelledby":tz(D),children:"stashes"===D?(0,n.jsx)(ts,{stashes:Y,sel:es,onSelect:en,onSave:()=>eb(!0),canSave:v.changes.length>0&&!v.state}):"tags"===D?(0,n.jsx)(eZ,{agent:m,sel:null!=(h=null==Z?void 0:Z.name)?h:null,onSelect:V,onLoaded:e=>{var t;let s=eQ.current;eQ.current=null,s&&!Z&&V(null!=(t=e.find(e=>e.name===s))?t:null)}}):"compare"===D?(0,n.jsx)(e9,{refs:eI,sel:_,onChange:H}):"history"===D?(0,n.jsx)(tx,{agent:m,head:null==(l=v.head)?void 0:l.sha,sel:ew,onSelect:eC,refs:eI,path:L,onClearPath:()=>U(null)}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"gx-filter",children:[(0,n.jsxs)("div",{className:"search",children:[(0,n.jsx)(ed.A,{size:14}),(0,n.jsx)("input",{ref:X,className:"input",placeholder:K?j("git.search.placeholder"):j("git.filterPlaceholder"),value:z,onChange:e=>M(e.target.value),"aria-label":j("git.filterPlaceholder")})]}),(0,n.jsxs)("div",{className:"seg icons",role:"group","aria-label":j("git.search.name"),children:[(0,n.jsx)("button",{type:"button","aria-pressed":!K,title:j("git.search.name"),"aria-label":j("git.search.name"),onClick:()=>B(!1),children:(0,n.jsx)(eu.A,{size:14})}),(0,n.jsx)("button",{type:"button","aria-pressed":K,title:j("git.search.content"),"aria-label":j("git.search.content"),onClick:()=>B(!0),children:(0,n.jsx)(eh.A,{size:14})})]}),!K&&(0,n.jsxs)("button",{type:"button",className:"btn sm gx-onlych ".concat(F?"primary":""),"aria-pressed":F,title:j("git.filter.changed"),onClick:()=>R(e=>!e),children:[(0,n.jsx)(em.A,{size:14}),v.changes.length>0&&(0,n.jsx)("span",{className:"ct",children:v.changes.length})]})]}),K?(0,n.jsx)("div",{className:"gx-list gx-hits",children:z.trim().length<2?(0,n.jsx)("p",{className:"gx-note",children:j("git.search.min")}):$&&$.q===z.trim()?0===$.hits.length?(0,n.jsx)("p",{className:"gx-note",children:j("git.search.none",{query:$.q})}):(0,n.jsxs)(n.Fragment,{children:[$.hits.map((e,t)=>(0,n.jsxs)("button",{type:"button",className:"gx-hit ".concat(C===e.path&&(null==G?void 0:G.line)===e.line?"sel":""),onClick:()=>{S(e.path),J({line:e.line,key:Date.now()})},title:"".concat(e.path,":").concat(e.line),children:[(0,n.jsxs)("span",{className:"mono nm",children:[e.path,(0,n.jsxs)("i",{children:[":",e.line]})]}),(0,n.jsx)("span",{className:"mono tx",children:e.text.trim()})]},"".concat(e.path,":").concat(e.line,":").concat(t))),$.truncated&&(0,n.jsx)("p",{className:"gx-note",children:j("git.search.capped",{count:$.hits.length})})]}):(0,n.jsx)("p",{className:"gx-note",children:j("git.search.searching")})}):(0,n.jsxs)("div",{className:"gx-list",children:[eH?0===eJ.length?(0,n.jsx)("p",{className:"gx-note",children:z?j("git.noMatch",{query:z}):F?j("git.clean"):j("git.noFiles")}):(0,n.jsx)(tk,{rows:eJ,expanded:A,forceOpen:!!(z||F),sel:C,onToggle:e0,onSelect:e1,label:j("git.filesLabel")}):(0,n.jsx)("p",{className:"gx-note",children:j("git.loading")}),eG.length>eJ.length&&(0,n.jsx)("p",{className:"gx-note",children:j("git.rowsCapped",{count:eJ.length})}),(null==N?void 0:N.isRepo)&&N.truncated&&(0,n.jsx)("p",{className:"gx-note",children:j("git.treeTruncated",{count:N.files.length})})]})]})})]}),"stashes"===D?(null==Y?void 0:Y.find(e=>e.sha===es))?(0,n.jsx)(ta,{agent:m,stash:Y.find(e=>e.sha===es),a:eE},es):(0,n.jsx)("div",{className:"gx-preview",children:(0,n.jsx)("div",{className:"gx-empty",children:(0,n.jsx)("p",{children:j("git.stash.empty")})})}):"compare"===D?(0,n.jsx)(e2,{agent:m,sel:_}):"tags"===D?Z?(0,n.jsx)(eV,{agent:m,tag:Z,onChanged:()=>void w()},Z.name):(0,n.jsx)("div",{className:"gx-preview",children:(0,n.jsx)("div",{className:"gx-empty",children:(0,n.jsx)("p",{children:j("git.tags.select")})})}):"history"===D?ew?(0,n.jsx)(eX,{agent:m,sha:ew,focus:null!=L?L:void 0},"".concat(ew,"|").concat(null!=L?L:"")):(0,n.jsx)("div",{className:"gx-preview",children:(0,n.jsx)("div",{className:"gx-empty",children:(0,n.jsx)("p",{children:j("git.hist.select")})})}):C&&(null==tt?void 0:tt.status)==="conflict"?(0,n.jsx)(e7,{agent:m,path:C,state:v.state,a:eE,onResolved:()=>{w()}},C):C?(0,n.jsx)(tj,{agent:m,path:C,ignored:eK(C),change:tt,stamp:v.generatedAt,refs:eI,focusLine:G,onHistory:e=>{U(e),eC(null),T("history")},onOpenCommit:e=>{eC(e),T("history")},onDiscard:e=>{var t,s;return eM({files:tc([e]),all:!1,file:{path:e.path,status:e.status,oldPath:e.oldPath,add:null!=(t=e.additions)?t:0,del:null!=(s=e.deletions)?s:0},go:async()=>{let t=await eE.run("discard",j("git.done.discard"),"discard",{path:e.path,oldPath:e.oldPath});return t&&tc([e]).length&&S(null),t}})},onDiscardHunk:(e,t,s)=>void eE.run("discard-hunk",j("git.done.discard"),"discard-hunk",{path:e,index:t,header:s}),onDiscardLines:(e,t,s,n)=>void eE.run("discard-lines",j("git.done.discard"),"discard-lines",{path:e,index:t,header:s,lines:n}),comments:x,commentsLocked:e4,commentFocus:e5},C):(0,n.jsx)("div",{className:"gx-preview",children:(0,n.jsx)("div",{className:"gx-empty",children:(0,n.jsx)("p",{children:j("git.select")})})})]}),x&&(0,n.jsx)(e_,{ctl:x,sending:e4,setSending:e3,onGoTo:te}),ev&&(0,n.jsx)(e8,{agent:m,plan:ev,a:eE,onClose:()=>eN(null),onGo:()=>{eN(null),tl(ev)}}),ej&&(0,n.jsx)(tn,{a:eE,onClose:()=>eb(!1)}),ey&&v.stash&&(0,n.jsx)(et.TM,{danger:!0,title:j("git.state.cancelStash.title"),body:j("git.state.cancelStash.body",{from:v.stash.from}),confirmLabel:j("git.state.cancelStash.go"),onClose:()=>ek(!1),onConfirm:()=>{eE.busy||eE.run("smart",j("git.done.smartCancel"),"smart-cancel")}}),ez&&(0,n.jsx)(tp,{files:ez.files,all:ez.all,summary:ez.summary,file:ez.file,onClose:()=>eM(null),onConfirm:()=>{ez.go()}}),eS&&(0,n.jsx)(tg,{changes:v.changes,a:eE,initialMessage:v.mergeMsg,onClose:()=>eA(!1)})]})}var tP=s(37064),tI=s(5300),tD=s(26701),tT=s(65920),tL=s(48180),tU=s(66477),t_=s(12646);function tH(e){var t;let{agent:s}=e,{t:a}=(0,q.s9)(),{refresh:l}=(0,x.o0)(),c=(0,et.dj)(),[r,o]=(0,i.useState)(null),[d,u]=(0,i.useState)(""),[h,m]=(0,i.useState)(""),[g,j]=(0,i.useState)(!1),[b,v]=(0,i.useState)(!1),[N,y]=(0,i.useState)(!1),k=(0,i.useRef)(""),w=!!r&&d!==k.current,C=(0,i.useRef)(!1);C.current=w;let S=(0,i.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{let t=await p.FH.get("/agents/".concat(s.id,"/notebook"));o(e=>e&&e.version===t.version&&e.enabled===t.enabled&&JSON.stringify(e.shared_with)===JSON.stringify(t.shared_with)?e:t),(e||!C.current)&&(k.current=t.content,u(t.content))}catch(e){m(e instanceof Error?e.message:String(e))}},[s.id]);(0,i.useEffect)(()=>{o(null),m(""),S(!0)},[s.id,S]),(0,i.useEffect)(()=>{let e=setInterval(()=>{"visible"===document.visibilityState&&S()},4e3);return()=>clearInterval(e)},[S]);let A=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d;if(r){j(!0),m("");try{let t=await p.FH.put("/agents/".concat(s.id,"/notebook"),{content:e,version:r.version});o({...r,...t}),k.current=t.content,u(t.content),c(a("notebook.saved"))}catch(e){m(e instanceof Error?e.message:String(e))}j(!1)}},E=async()=>{y(!1),m("");try{await p.FH.post("/agents/".concat(s.id,"/notebook/separate")),c(a("notebook.separated")),await S(!0),await l(["agents"])}catch(e){m(e instanceof Error?e.message:String(e))}},z=async()=>{try{await p.FH.patch("/agents/".concat(s.id),{skill_ids:[...new Set([...s.skill_ids,r.skill_id])]}),await l(["agents"]),await S(!0)}catch(e){m(e instanceof Error?e.message:String(e))}};if(!r)return(0,n.jsx)("div",{className:"pane",children:(0,n.jsx)("p",{className:"hint",children:h||a("git.loading")})});let M=d.length,F=M>r.max,R=M>.8*r.max,P=null!=(t=r.shared_with)?t:[];return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"pane",children:[(0,n.jsx)("p",{className:"hint",style:{margin:0},children:a("notebook.intro")}),P.length>0&&(0,n.jsxs)("div",{className:"banner",children:[(0,n.jsx)(tD.A,{size:16}),(0,n.jsx)("div",{className:"grow",children:a("notebook.sharedWith",{names:P.map(e=>e.name).join(", ")})}),(0,n.jsxs)("button",{className:"btn sm",onClick:()=>y(!0),children:[(0,n.jsx)(tT.A,{size:13}),a("notebook.separate")]})]}),!r.enabled&&(0,n.jsxs)("div",{className:"banner honey",children:[(0,n.jsx)(tL.A,{size:16}),(0,n.jsx)("div",{className:"grow",children:a("notebook.off")}),(0,n.jsx)("button",{className:"btn sm",onClick:z,children:a("notebook.on")})]}),h&&(0,n.jsxs)("div",{className:"banner err",children:[(0,n.jsx)(tL.A,{size:16}),(0,n.jsx)("div",{className:"grow",children:h}),(0,n.jsxs)("button",{className:"btn sm",onClick:()=>{m(""),S(!0)},children:[(0,n.jsx)(ei.A,{size:13}),a("notebook.reload")]})]}),(0,n.jsxs)("div",{className:"row small muted",style:{justifyContent:"space-between"},children:[(0,n.jsxs)("span",{children:[(0,n.jsx)(tU.A,{size:12,style:{verticalAlign:"-1px"}})," ",r.updated_at?a("notebook.updated",{who:a("user"===r.updated_by?"notebook.by.you":"notebook.by.agent"),when:(0,f.KN)(r.updated_at)}):a("notebook.never")]}),(0,n.jsxs)("span",{style:{color:F?"var(--danger, #c0392b)":R?"var(--honey)":void 0},children:[M.toLocaleString()," / ",r.max.toLocaleString()]})]}),(0,n.jsx)(t_.n,{value:d,onChange:u,placeholder:a("notebook.placeholder"),defaultView:"write",minHeight:320})]}),(0,n.jsxs)("div",{className:"savebar col",children:[(0,n.jsx)("span",{className:"muted small",children:w?a("agent.unsavedChanges"):a("agent.allSaved")}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsxs)("button",{className:"btn danger sm",style:{marginRight:"auto"},disabled:!d.trim()||g,onClick:()=>v(!0),children:[(0,n.jsx)(eP.A,{size:14}),a("notebook.clear")]}),w&&(0,n.jsx)("button",{className:"btn ghost sm",onClick:()=>u(k.current),children:a("common.discard")}),(0,n.jsx)("button",{className:"btn primary sm",disabled:!w||g||F,onClick:()=>void A(),children:a("notebook.save")})]})]}),b&&(0,n.jsxs)(et.aF,{title:a("notebook.clear.title"),onClose:()=>v(!1),children:[(0,n.jsx)("p",{style:{margin:0},className:"muted",children:P.length?a("notebook.clear.shared",{names:P.map(e=>e.name).join(", ")}):a("notebook.clear.confirm")}),(0,n.jsxs)("div",{className:"row",style:{justifyContent:"flex-end"},children:[(0,n.jsx)("button",{className:"btn ghost",onClick:()=>v(!1),children:a("common.cancel")}),(0,n.jsx)("button",{className:"btn danger",onClick:()=>{v(!1),A("")},children:a("notebook.clear")})]})]}),N&&(0,n.jsxs)(et.aF,{title:a("notebook.separate.title"),onClose:()=>y(!1),children:[(0,n.jsx)("p",{style:{margin:0},className:"muted",children:a("notebook.separate.confirm",{name:s.name,names:P.map(e=>e.name).join(", ")})}),(0,n.jsxs)("div",{className:"row",style:{justifyContent:"flex-end"},children:[(0,n.jsx)("button",{className:"btn ghost",onClick:()=>y(!1),children:a("common.cancel")}),(0,n.jsx)("button",{className:"btn primary",onClick:()=>void E(),children:a("notebook.separate")})]})]})]})}var tK=s(15426);let tO=["config","notebook","sessions"];function tW(e){let{params:t}=e,{id:s}=(0,i.use)(t);return(0,n.jsx)(tq,{id:s},s)}function tq(e){var t;let{id:s}=e,{t:c}=(0,q.s9)(),{ready:w,error:C,retry:S,refresh:E}=(0,x.q5)(),z=(0,x.fJ)(s),P=(0,o.useRouter)(),I=(0,et.dj)(),[T,L]=(0,v.Z)("tab",""),[U,_]=(0,i.useState)("config"),H=tO.includes(T)?T:U,K=""!==T,[O,W]=(0,i.useState)(!1),[$,Q]=(0,i.useState)([]),[G,J]=(0,i.useState)(void 0),[X,Z]=(0,i.useState)(null),[V,Y]=(0,i.useState)("chat"),ee=function(e,t){var s,n,a;let{finished:l}=(0,x.o0)(),c=null!=(s=null==e?void 0:e.id)?s:"",r=null!=(n=l[c])?n:0,[o,d]=(0,i.useState)(null),[u,h]=(0,i.useState)(null),[m,g]=(0,i.useState)(!1),[f,j]=(0,i.useState)(null),b=(0,i.useRef)(0),v=null!=(a=null==e?void 0:e.effective.cwd)?a:"",N=(null==e?void 0:e.status)==="running",y=(0,i.useCallback)(async e=>{if(!c)return;let t=++b.current;g(!0);try{let[s,n]=await Promise.all([p.FH.get("/agents/".concat(c,"/git/status")),e?p.FH.get("/agents/".concat(c,"/git/tree")):Promise.resolve(null)]);if(t!==b.current)return;d(s),n&&h(n),j(null)}catch(e){t===b.current&&j(e instanceof Error?e.message:"error")}finally{t===b.current&&g(!1)}},[c]);return(0,i.useEffect)(()=>{h(null),d(null)},[v]),(0,i.useEffect)(()=>{y(t)},[y,t,r,v]),(0,tP.n)(()=>y(!0),5e3,{enabled:t&&N,immediate:!1}),{status:o,tree:u,loading:m,error:f,refresh:(0,i.useCallback)(()=>y(!0),[y])}}(z,"changes"===V),es=ee.status&&ee.status.isRepo?ee.status.changes.length:0,el=function(e){let[t,s]=(0,i.useState)([]),n=(0,i.useRef)([]),a=k(e),l=(0,i.useCallback)(e=>{if(e!==n.current)if(n.current=e,s(e),e.length)(0,b.zS)(a,e);else try{localStorage.removeItem(a)}catch(e){}},[a]);(0,i.useLayoutEffect)(()=>{let t=()=>{let t=(e=>{let t=(0,b.CL)(k(e),[]);return Array.isArray(t)?t.filter(D):[]})(e);return n.current=t,s(t),t},i=t(),c=((e,t)=>{let s=e.filter(e=>t-e.at<=2592e6);return s.length===e.length?e:s})(i,Date.now());c!==i&&l(c);let r=e=>{(e.key===a||null===e.key)&&t()};return window.addEventListener("storage",r),()=>window.removeEventListener("storage",r)},[e,a,l]);let c=(0,x.Tu)(e=>e.agents),r=(0,x.Tu)(e=>e.ready);(0,i.useEffect)(()=>{if(!r)return;let e=new Set(c.map(e=>e.id));try{let t=[];for(let s=0;s<localStorage.length;s++){let n=localStorage.key(s);(null==n?void 0:n.startsWith(y))&&!e.has(n.slice(y.length))&&t.push(n)}t.forEach(e=>localStorage.removeItem(e))}catch(e){}},[r,c]);let o=(0,i.useRef)(null);return(0,i.useEffect)(()=>{o.current=null},[e]),(0,i.useMemo)(()=>({items:t,add:(e,t,s)=>{let a=F(e,t,s,Date.now(),"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():"".concat(Date.now().toString(36)).concat(Math.random().toString(36).slice(2)));return l([...n.current,a]),a},update:(e,t)=>l(n.current.map(s=>s.id===e?{...s,text:M(t)}:s)),remove:e=>l(n.current.filter(t=>t.id!==e)),clear:()=>l([]),relocate:(e,t)=>l(function(e,t,s){let n=!1,a=s.map(s=>{if(s.path!==t)return s;let a=R(e,s),l=a?{...s,...A(e.hunks[a.hunk].lines.slice(a.start,a.start+s.count)),outdated:!1,gone:!1}:{...s,outdated:!0};return l.outdated===s.outdated&&l.gone===s.gone&&l.newFrom===s.newFrom&&l.newTo===s.newTo&&l.oldFrom===s.oldFrom&&l.oldTo===s.oldTo&&l.removed===s.removed?s:(n=!0,l)});return n?a:s}(t,e,n.current)),syncChanges:(e,t)=>l(function(e,t,s){if(s)return e;let n=!1,a=e.map(e=>{let s=t.has(e.path);return s||e.gone?s&&e.gone?(n=!0,{...e,gone:!1}):e:(n=!0,{...e,outdated:!0,gone:!0})});return n?a:e}(n.current,e,t)),getDraft:()=>o.current,setDraft:e=>{o.current=e}}),[t,l])}(s),ei=(0,i.useRef)(null),ec=void 0!==G&&G!==(null==z?void 0:z.session_id),er=(0,i.useMemo)(()=>{var e;return{...el,readOnly:ec,busy:(null==z?void 0:z.status)==="running",agentName:null!=(e=null==z?void 0:z.name)?e:"",onViewChat:()=>Y("chat"),send:e=>ei.current?ei.current.send(e,{quiet:!0}):Promise.resolve({ok:!1,error:c("chat.sendFailed")})}},[el,ec,null==z?void 0:z.status,null==z?void 0:z.name,c]),eo=(e,t)=>{let s=null!=t?t:H;_(s),L(e?s:"")},ed=(0,l.A)(z,{onDeleted:()=>P.push("/agents"),onCloned:e=>P.push("/agents/".concat(e.id))}),{draft:eu,setDraft:eh,errors:em,dirty:eg}=ed,ex=()=>{eg?W(!0):eo(!1)};if((0,i.useEffect)(()=>{K&&"sessions"===H&&p.FH.get("/agents/".concat(s,"/sessions")).then(Q).catch(()=>void 0)},[K,H,s,null==z?void 0:z.session_id]),(0,i.useEffect)(()=>{z&&(0,b.zS)(j.O,z.id)},[z]),!z)return(0,n.jsx)("div",{className:"page",children:!w&&C?(0,n.jsxs)(et.lZ,{kind:"err",children:[(0,n.jsx)("span",{children:C})," ",(0,n.jsx)("button",{type:"button",className:"btn sm",onClick:()=>void S(),children:c("fa.retry")})]}):w?(0,n.jsx)(et.pp,{title:c("agent.missing.title"),body:c("agent.missing.body"),action:(0,n.jsx)(r(),{className:"btn",href:"/agents",children:c("agent.missing.back")})}):null});let ep=async e=>{await p.FH.post("/agents/".concat(s,"/resume-session"),{session_id:e}),J(void 0),I(c("agent.resumed"))},ef=$.filter(e=>"delegation"!==e.kind),ej=$.filter(e=>"delegation"===e.kind),eb=(null==(t=$.find(e=>e.session_id===G))?void 0:t.kind)==="delegation",ev=[...G?[{id:"make-current",label:c("agent.makeCurrent"),onClick:()=>void ep(G).catch(e=>I(e instanceof Error?e.message:String(e),"err")),disabled:eb},{id:"back-current",label:c("agent.backToCurrent"),onClick:()=>J(void 0)}]:[],{id:"new-conv",label:c("agent.newConversation"),icon:(0,n.jsx)(d.A,{size:14}),onClick:()=>Z("new"),disabled:!z.session_id||"running"===z.status}];return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("section",{className:"ws-chat",children:[(0,n.jsx)(et.DS,{back:{href:"/colony",label:c("agent.backToColony")},avatar:(0,n.jsx)(et._h,{agent:z}),title:z.name,meta:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(et.PW,{role:z.role}),(0,n.jsx)(et.dJ,{provider:z.provider}),(0,n.jsx)("span",{className:"small",children:z.model||c("model.cliDefault")}),(0,n.jsx)(et.P5,{status:z.status}),(0,n.jsx)(tK.IX,{agent:z,link:!0}),(0,n.jsx)(tK.R4,{agent:z})]}),actions:ev,primary:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"seg",role:"group","aria-label":c("git.tab.label"),children:[(0,n.jsx)("button",{type:"button","aria-pressed":"chat"===V,onClick:()=>Y("chat"),children:c("git.tab.chat")}),(0,n.jsxs)("button",{type:"button","aria-pressed":"changes"===V,onClick:()=>Y("changes"),children:[c("git.tab.changes"),es>0&&(0,n.jsx)("span",{className:"tabcount",children:es}),el.items.length>0&&(0,n.jsxs)("span",{className:"tabcount dc-tabcount",role:"img","aria-label":c("diffc.tab",{count:el.items.length}),title:c("diffc.tab",{count:el.items.length}),children:[(0,n.jsx)(u.A,{size:10,"aria-hidden":!0}),el.items.length]})]})]}),(0,n.jsx)(a.N,{spec:{agentId:s},title:c("dock.agent")}),(0,n.jsxs)("button",{type:"button",className:"btn sm ".concat(K?"primary":""),onClick:()=>K?ex():eo(!0),"aria-expanded":K,"aria-label":c("colony.agentSettings"),children:[(0,n.jsx)(h.A,{size:14}),c("agent.settings"),eg&&(0,n.jsx)("i",{className:"dot run",title:c("agent.unsaved")})]})]})}),(0,n.jsxs)("div",{className:"chat-pane",hidden:"chat"!==V,children:[z.permission_stale&&!G&&(0,n.jsxs)(et.lZ,{kind:"warn",action:(0,n.jsx)("button",{type:"button",className:"btn sm",onClick:()=>Z("new"),children:c("agent.permStale.action")}),children:[(0,n.jsx)("b",{children:c("agent.permStale.title")})," ",c("agent.permStale.body",{a1:(0,f.Ck)(z.effective.permission)})]}),(0,n.jsx)(en,{agent:z}),(0,n.jsx)(B,{agent:z,session:G}),(0,n.jsx)(N.ry,{agent:z,sessionOverride:G,apiRef:ei})]}),"changes"===V&&(0,n.jsx)(tR,{agent:z,git:ee,comments:er})]}),K&&(0,n.jsx)(et._s,{title:z.name,subtitle:"".concat(c("role.".concat(z.role))," \xb7 ").concat(f.xq[z.provider].label),onClose:ex,footer:"config"===H&&eu?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:"muted small grow",children:[eg?c("agent.unsavedChanges"):c("agent.allSaved"),eg&&"running"===z.status?" ".concat(c("agent.appliesNextTurn")):""]}),ed.actions({size:"sm"})]}):void 0,children:(0,n.jsxs)("div",{className:"agent-config",children:[(0,n.jsx)(et.tU,{idPrefix:"cfg",label:c("fa.cfg.tabs"),value:H,onChange:e=>eo(!0,e),tabs:[{id:"config",label:c("agent.tab.config")},{id:"notebook",label:c("agent.tab.notebook")},{id:"sessions",label:c("nav.sessions")}]}),(0,n.jsx)(et.Kp,{id:"config",value:H,idPrefix:"cfg",children:eu&&(0,n.jsx)(n.Fragment,{children:(0,n.jsx)("div",{className:"pane",children:(0,n.jsx)(tI.SU,{draft:eu,onChange:eh,errors:em,selfId:s})})})}),(0,n.jsx)(et.Kp,{id:"notebook",value:H,idPrefix:"cfg",children:(0,n.jsx)(tH,{agent:z})}),(0,n.jsx)(et.Kp,{id:"sessions",value:H,idPrefix:"cfg",children:(0,n.jsxs)("div",{className:"pane",children:[(0,n.jsx)("p",{className:"hint m0",children:c("agent.sessions.intro",{path:(0,f._1)(z.effective.cwd)})}),(0,n.jsx)("div",{className:"eyebrow",children:c("agent.sessions.conversations")}),0===ef.length?(0,n.jsx)(et.pp,{compact:!0,icon:(0,n.jsx)(m.A,{size:22}),title:c("agent.sessions.empty")}):ef.map(e=>{let t=e.session_id===z.session_id;return(0,n.jsxs)("div",{className:"card card-pad col fa-sess ".concat(G===e.session_id?"on":""),children:[(0,n.jsxs)("div",{className:"row gap-xs",children:[(0,n.jsx)("span",{className:"mono grow sess-id",children:e.session_id}),(0,n.jsx)(ea.WQ,{compact:!0,text:e.session_id,label:c("agent.sessions.copyId")}),t&&(0,n.jsx)("span",{className:"chip honey",children:c("sessions.current")})]}),(0,n.jsx)("span",{className:"muted small",children:c("agent.sessions.started",{started:(0,f.KN)(e.first_seen),last:(0,f.KN)(e.last_seen)})}),(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("button",{className:"btn sm",onClick:()=>{J(t?void 0:e.session_id),eo(!1)},children:G===e.session_id?c("agent.sessions.viewing"):c("agent.sessions.read")}),!t&&(0,n.jsx)("button",{className:"btn sm",onClick:()=>ep(e.session_id).then(()=>eo(!1)).catch(e=>I(e instanceof Error?e.message:String(e),"err")),children:c("agent.sessions.resume")})]})]},e.session_id)}),ej.length>0&&(0,n.jsx)("div",{className:"eyebrow mt-s",children:c("agent.sessions.delegated")}),ej.map(e=>{var t;return(0,n.jsxs)("div",{className:"card card-pad col fa-sess ".concat(G===e.session_id?"on":""),children:[(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)(g.A,{size:14,className:"muted"}),(0,n.jsx)("b",{className:"grow",children:c("agent.sessions.from",{name:null!=(t=e.from_name)?t:c("chat.anOrchestrator")})}),(0,n.jsx)("span",{className:"muted small",children:(0,f.KN)(e.last_seen)})]}),e.task&&(0,n.jsx)("span",{className:"small fa-clamp3",children:e.task}),(0,n.jsxs)("div",{className:"row gap-xs",children:[(0,n.jsx)("span",{className:"mono muted small grow sess-id",children:e.session_id}),(0,n.jsx)(ea.WQ,{compact:!0,text:e.session_id,label:c("agent.sessions.copyId")})]}),(0,n.jsx)("div",{className:"row gap-s",children:(0,n.jsx)("button",{className:"btn sm",onClick:()=>{J(G===e.session_id?void 0:e.session_id),eo(!1)},children:G===e.session_id?c("agent.sessions.viewing"):c("agent.sessions.read")})})]},e.session_id)})]})})]})}),ed.deleteModal,ed.cloneModal,O&&(0,n.jsx)(et.TM,{danger:!0,title:c("fa.unsaved.title"),body:c("fa.unsaved.body"),confirmLabel:c("fa.unsaved.discard"),cancelLabel:c("fa.unsaved.keep"),onClose:()=>W(!1),onConfirm:()=>{ed.discard(),eo(!1)}}),"new"===X&&(0,n.jsx)(et.TM,{title:c("agent.newConvTitle"),body:c("agent.newConvBody"),confirmLabel:c("agent.newConvStart"),onClose:()=>Z(null),onConfirm:async()=>{await p.FH.post("/agents/".concat(s,"/new-session")),await E(["agents"]),I(c("agent.newConvStarted"))}})]})}},48776:(e,t,s)=>{"use strict";s.d(t,{G:()=>o});var n=s(94799),a=s(34023),l=s(11580),i=s(48538),c=s(3749),r=s(69654);function o(e){let{agent:t,onClose:s,onDeleted:o}=e,{t:d}=(0,r.s9)(),{refresh:u}=(0,i.zd)(),h=(0,l.dj)(),[m,g]=(0,a.useState)([]);return(0,a.useEffect)(()=>{let e=!1;return c.FH.get("/agents/".concat(t.id,"/notebook")).then(t=>{var s;e||g((null!=(s=t.shared_with)?s:[]).map(e=>e.name))}).catch(()=>void 0),()=>{e=!0}},[t.id]),(0,n.jsx)(l.TM,{title:d("agent.deleteTitle",{name:t.name}),body:m.length?d("agent.deleteBody.shared",{names:m.join(", ")}):d("agent.deleteBody"),danger:!0,confirmLabel:d("agent.delete"),cancelLabel:d("agent.keep"),onClose:s,onConfirm:async()=>{await c.FH.del("/agents/".concat(t.id)),await u(["agents","colonies"]),h(d("agent.deleted")),null==o||o()}})}},54609:(e,t,s)=>{"use strict";s.d(t,{O:()=>n,g:()=>a});let n="hive-am.lastChat",a=(e,t)=>e.some(e=>e.id===t)?"/agents/".concat(t):e[0]?"/agents/".concat(e[0].id):"/chat"},80696:(e,t,s)=>{"use strict";s.d(t,{y:()=>d});var n=s(94799),a=s(34023),l=s(494),i=s(3749),c=s(48538),r=s(69654),o=s(11580);function d(e){var t;let{agent:s,onClose:d,onCloned:u}=e,{t:h}=(0,r.s9)(),{agents:m,colonies:g}=(0,c.q5)(),{refresh:x}=(0,c.zd)(),p=(0,o.dj)(),[f,j]=(0,a.useState)(()=>((e,t)=>{for(let s=2;;s++){let n="".concat(e," ").concat(s);if(!t.has(n.toLowerCase()))return n}})(s.name,new Set(m.map(e=>e.name.toLowerCase())))),[b,v]=(0,a.useState)(null!=(t=s.colony_id)?t:""),[N,y]=(0,a.useState)(!1),[k,w]=(0,a.useState)(""),C=m.some(e=>e.name.toLowerCase()===f.trim().toLowerCase()),S=async()=>{y(!0),w("");try{let e=await i.FH.post("/agents/".concat(s.id,"/clone"),{name:f.trim(),colony_id:b||null});await x(["agents","colonies"]),p(h("agent.cloned",{name:e.name})),null==u||u(e),d()}catch(e){w(e instanceof Error?e.message:String(e)),y(!1)}};return(0,n.jsxs)(o.aF,{title:h("agent.clone.title",{name:s.name}),onClose:d,children:[(0,n.jsx)(o.D0,{label:h("agent.clone.name"),error:C?h("agent.clone.taken"):k,children:(0,n.jsx)("input",{className:"input",value:f,autoFocus:!0,onChange:e=>j(e.target.value),onKeyDown:e=>{"Enter"===e.key&&f.trim()&&!C&&!N&&S()}})}),(0,n.jsx)(o.D0,{label:h("form.colony"),children:(0,n.jsxs)("select",{className:"select",value:b,onChange:e=>v(e.target.value),children:[(0,n.jsx)("option",{value:"",children:h("common.noColony")}),g.map(e=>(0,n.jsx)("option",{value:e.id,children:e.name},e.id))]})}),(0,n.jsxs)("ul",{className:"muted small clone-facts",children:[(0,n.jsx)("li",{children:h("agent.clone.parallel",{name:s.name})}),(0,n.jsx)("li",{children:h("agent.clone.config")}),(0,n.jsx)("li",{children:h("agent.clone.notebook",{name:s.name})}),(0,n.jsx)("li",{children:h("agent.clone.notBring",{name:s.name})})]}),(0,n.jsxs)("div",{className:"row",style:{justifyContent:"flex-end"},children:[(0,n.jsx)("button",{className:"btn ghost",onClick:d,children:h("common.cancel")}),(0,n.jsxs)("button",{className:"btn primary",disabled:!f.trim()||C||N,onClick:()=>void S(),children:[(0,n.jsx)(l.A,{size:14}),N?h("agent.clone.working"):h("agent.clone")]})]})]})}},89128:(e,t,s)=>{"use strict";s.d(t,{A:()=>x});var n=s(94799),a=s(34023),l=s(97356),i=s(494),c=s(11580),r=s(5300),o=s(48776),d=s(80696),u=s(48538),h=s(73506),m=s(3749),g=s(69654);function x(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{t:s}=(0,g.s9)(),{agents:x,colonies:p,objects:f,refresh:j}=(0,u.q5)(),b=(0,c.dj)(),v=(0,a.useMemo)(()=>e?f.filter(t=>t.manager_id===e.id).map(e=>e.id).sort():[],[f,null==e?void 0:e.id]),N=(0,a.useMemo)(()=>e?JSON.stringify((0,r.TN)(e,v)):"",[e,v]),[y,k]=(0,a.useState)(()=>e?(0,r.TN)(e,v):null),[w,C]=(0,a.useState)(!1),[S,A]=(0,a.useState)(!1),[E,z]=(0,a.useState)(!1);(0,a.useEffect)(()=>{k(e?(0,r.TN)(e,v):null)},[N]);let M=y&&e?(0,r.tf)(y,x,e.id,p):{},F=!!y&&JSON.stringify(y)!==N;(0,h.h)(F);let R=async()=>{if(y&&e){if(Object.keys(M).length)return void b(s("edit.fixFields"),"err");C(!0);try{var n;let{type_id:a,object_ids:l,...i}=y;await m.FH.patch("/agents/".concat(e.id),i),JSON.stringify([...l].sort())!==JSON.stringify(v)&&await m.FH.put("/agents/".concat(e.id,"/resources"),{object_ids:l}),await j(["agents","colonies","objects"]),b(s("edit.saved",{name:y.name.trim()})),null==(n=t.onSaved)||n.call(t)}catch(e){b(e instanceof Error?e.message:s("edit.saveFailed"),"err")}C(!1)}},P=()=>{e&&k((0,r.TN)(e,v))};return{draft:y,setDraft:k,errors:M,dirty:F,saving:w,save:R,discard:P,actions:function(){var e,t,a,c,r;let o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,n.jsxs)("span",{className:"foot-actions push-r",children:[(0,n.jsxs)("span",{className:"row gap-s",children:[(0,n.jsxs)("button",{className:"btn danger ".concat(null!=(e=o.size)?e:""),onClick:()=>A(!0),children:[(0,n.jsx)(l.A,{size:o.size?14:15}),s("agent.delete")]}),(0,n.jsx)("button",{className:"btn icon ".concat(null!=(t=o.size)?t:""),onClick:()=>z(!0),title:s("agent.clone.hint"),"aria-label":s("agent.clone"),children:(0,n.jsx)(i.A,{size:o.size?14:15})})]}),o.onCancel?(0,n.jsx)("button",{className:"btn ghost ".concat(null!=(a=o.size)?a:""),onClick:o.onCancel,children:s("common.cancel")}):(0,n.jsx)("button",{className:"btn ghost ".concat(null!=(c=o.size)?c:""),disabled:!F,onClick:P,children:s("common.discard")}),(0,n.jsx)("button",{className:"btn primary ".concat(null!=(r=o.size)?r:""),disabled:!F||w,onClick:R,children:w?s("common.saving"):s("common.saveChanges")})]})},deleteModal:S&&e?(0,n.jsx)(o.G,{agent:e,onClose:()=>A(!1),onDeleted:t.onDeleted}):null,cloneModal:E&&e?(0,n.jsx)(d.y,{agent:e,onClose:()=>z(!1),onCloned:t.onCloned}):null}}},91656:(e,t,s)=>{"use strict";s.d(t,{Oq:()=>l,_n:()=>r,fU:()=>i,wx:()=>c});let n={k:"palette",b:"rail",".":"unread"},a={KeyK:"palette",KeyB:"rail",Period:"unread"};function l(e,t){if(e.isComposing||e.repeat||e.altKey||e.defaultPrevented)return null;if("?"===e.key)return e.ctrlKey||e.metaKey||t.inField||t.inOwn||t.layers>0||t.menuOpen?null:"help";if(!(t.mac?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)||e.shiftKey)return null;let s=/^[\x20-\x7e]$/.test(e.key)?n[e.key.toLowerCase()]:e.code?a[e.code]:void 0;return!s||t.inOwn?null:t.layers>0?"palette"===s&&t.paletteOpen?"palette":null:s}let i=e=>/mac|iphone|ipad|ipod/i.test(null!=e?e:""),c=[{id:"palette",keys:["Mod","K"],label:"keys.open",group:"anywhere"},{id:"rail",keys:["Mod","B"],label:"keys.rail",group:"anywhere"},{id:"unread",keys:["Mod","."],label:"keys.unread",group:"anywhere"},{id:"help",keys:["?"],label:"keys.help",group:"outside"},{id:"terminal",keys:["Ctrl","`"],label:"keys.terminal",group:"existing"},{id:"close",keys:["Esc"],label:"keys.close",group:"existing"},{id:"send",keys:["Mod","Enter"],label:"keys.send",group:"existing"}],r=(e,t)=>e.map(e=>"Mod"===e?t?"⌘":"Ctrl":e).join(" ")},95808:(e,t,s)=>{Promise.resolve().then(s.bind(s,46912))}},e=>{e.O(0,[586,7706,5642,4837,3214,9977,1517,969,1606,4030,2547,7408,89,7358],()=>e(e.s=95808)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1726],{5372:(e,t,n)=>{"use strict";n.d(t,{kh:()=>f,rs:()=>p,z6:()=>m});var r=n(94799),s=n(34023),i=n(56742),a=n(48538),l=n(69654),o=n(47890),c=n(72942),d=n(11580),u=n(15426);function m(){let[e,t]=(0,s.useState)(null),n=(0,s.useRef)(void 0),a=(0,s.useRef)(!1);a.current=!!e;let l=(0,s.useCallback)((e,r,s)=>{clearTimeout(n.current);let i=()=>t({id:e,rect:r.getBoundingClientRect()});s||a.current?i():n.current=setTimeout(i,280)},[]),o=(0,s.useCallback)(()=>{clearTimeout(n.current),t(null)},[]);return(0,s.useEffect)(()=>{if(!e)return;let t=e=>{"Escape"===e.key&&o()};return window.addEventListener("keydown",t),window.addEventListener("scroll",o,!0),window.addEventListener("resize",o),()=>{window.removeEventListener("keydown",t),window.removeEventListener("scroll",o,!0),window.removeEventListener("resize",o)}},[e,o]),(0,s.useEffect)(()=>()=>clearTimeout(n.current),[]),{bind:(0,s.useCallback)(e=>({onMouseEnter:t=>l(e,t.currentTarget,!1),onMouseLeave:o,onFocus:t=>{t.currentTarget.matches(":focus-visible")&&l(e,t.currentTarget,!0)},onBlur:o,onClick:o}),[l,o]),node:e&&"undefined"!=typeof document?(0,i.createPortal)((0,r.jsx)(g,{anchor:e}),document.body):null}}function h(e){let{label:t,children:n}=e;return(0,r.jsxs)("div",{className:"ap-row",children:[(0,r.jsx)("dt",{children:t}),(0,r.jsx)("dd",{children:n})]})}function f(e){let{agent:t,hideColony:n=!1}=e,{t:s}=(0,l.s9)(),i=(0,a.Tu)(e=>e.agents),m=(0,a.Tu)(e=>e.colonies).find(e=>e.id===t.colony_id),f=(0,c.E)((0,a.M_)(t.id)),p=t.worker_ids.map(e=>{var t;return null==(t=i.find(t=>t.id===e))?void 0:t.name}).filter(Boolean),g=i.filter(e=>"orchestrator"===e.role&&e.worker_ids.includes(t.id)).map(e=>e.name),v=e=>e.length>4?"".concat(e.slice(0,4).join(", ")," ").concat(s("hover.more",{count:e.length-4})):e.join(", ");return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"ap-head",children:[(0,r.jsx)(d._h,{agent:t}),(0,r.jsxs)("div",{className:"grow",children:[(0,r.jsx)("b",{className:"ap-name",children:t.name}),(0,r.jsxs)("div",{className:"row gap-s wrap mt-s",children:[(0,r.jsx)(d.PW,{role:t.role}),(0,r.jsx)(d.P5,{status:t.status}),(0,r.jsx)(u.IX,{agent:t}),(0,r.jsx)(u.R4,{agent:t})]})]})]}),(0,r.jsx)("p",{className:"ap-desc ".concat(t.description?"":"muted"),children:t.description||s("switcher.noDescription")}),f&&(0,r.jsxs)("div",{className:"ap-now",children:[(0,r.jsx)("i",{className:"dot run"}),f]}),(0,r.jsxs)("dl",{className:"ap-rows",children:[(0,r.jsxs)(h,{label:s("form.provider"),children:[o.xq[t.provider].label,t.model?" \xb7 ".concat(t.model):" \xb7 ".concat(s("model.cliDefault"))]}),(0,r.jsx)(h,{label:s("inherit.permissions"),children:(0,o.Ck)(t.effective.permission)}),(0,r.jsxs)(h,{label:s("colony.folder"),children:[(0,r.jsx)("span",{className:"mono",children:(0,o._1)(t.effective.cwd)}),t.effective.inherited.includes("cwd")&&(0,r.jsxs)("span",{className:"muted",children:[" \xb7 ",s("colony.fromColony")]})]}),!n&&(0,r.jsx)(h,{label:s("form.colony"),children:m?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("i",{className:"cdot",style:{background:m.color||"var(--honey)"}}),m.name]}):(0,r.jsx)("span",{className:"muted",children:s("common.noColony")})}),"orchestrator"===t.role?(0,r.jsx)(h,{label:s("form.team"),children:p.length?v(p):(0,r.jsx)("span",{className:"muted",children:s("colony.noWorkers")})}):(0,r.jsx)(h,{label:s("rel.directedBy"),children:g.length?v(g):(0,r.jsx)("span",{className:"muted",children:s("hover.noOrchestrator")})}),(0,r.jsx)(h,{label:s("colony.session"),children:(0,r.jsx)("span",{className:"mono",children:t.session_id?"".concat(t.session_id.slice(0,12),"…"):s("colony.noSession")})}),(0,r.jsxs)(h,{label:s("agents.col.updated"),children:[(0,o.KN)(t.updated_at),!!t.queued&&t.queued>0&&(0,r.jsxs)("span",{className:"muted",children:[" \xb7 ",s("queue.count",{count:t.queued})]})]})]})]})}function p(e){var t,n,a;let{target:l,width:o=310,pinned:c=!1,onClose:d,children:u,label:m}=e,h=(0,s.useRef)(null),[f,p]=(0,s.useState)(null),g=(0,s.useCallback)(()=>{var e,t;if(!l)return;let n=null!=(t=null==(e=h.current)?void 0:e.offsetHeight)?t:0,r=l instanceof DOMRect?l:l.getBoundingClientRect(),s=r.right+12+o+8<=window.innerWidth?"right":"left",i="right"===s?r.right+12:Math.max(8,r.left-12-o),a=Math.min(Math.max(8,r.top+r.height/2-n/2),Math.max(8,window.innerHeight-n-8));p(e=>e&&e.left===i&&e.top===a&&e.side===s?e:{left:i,top:a,side:s})},[l,o]);return((0,s.useLayoutEffect)(g),(0,s.useEffect)(()=>{if(!c)return;window.addEventListener("scroll",g,!0),window.addEventListener("resize",g);let e="undefined"!=typeof ResizeObserver&&h.current?new ResizeObserver(g):null;e&&h.current&&e.observe(h.current);let t=e=>{var t;let n=e.target;(null==(t=h.current)?void 0:t.contains(n))||n.closest('.cell, [role="dialog"], .modal, .drawer, .scrim, .menu-pop')||null==d||d()};return document.addEventListener("pointerdown",t),()=>{window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",g),null==e||e.disconnect(),document.removeEventListener("pointerdown",t)}},[c,g,d]),l&&"undefined"!=typeof document)?(0,i.createPortal)((0,r.jsx)("div",{ref:h,className:"ap-card ".concat(c?"pinned":""," ").concat(null!=(t=null==f?void 0:f.side)?t:"right"),role:c?"complementary":"tooltip","aria-label":m,style:{left:null!=(n=null==f?void 0:f.left)?n:-9999,top:null!=(a=null==f?void 0:f.top)?a:-9999,width:o,visibility:f?"visible":"hidden"},children:u}),document.body):null}function g(e){let{anchor:t}=e,n=(0,a.fJ)(t.id);return n?(0,r.jsx)(p,{target:t.rect,children:(0,r.jsx)(f,{agent:n})}):null}},15426:(e,t,n)=>{"use strict";n.d(t,{IX:()=>u,R4:()=>m});var r=n(94799),s=n(41463),i=n.n(s),a=n(34023),l=n(494),o=n(48538),c=n(69654);function d(e){let t=(0,o.Tu)(e=>e.agents);return(0,a.useMemo)(()=>({of:e.cloned_from?t.find(t=>t.id===e.cloned_from):void 0,clones:t.filter(t=>t.cloned_from===e.id)}),[t,e.id,e.cloned_from])}function u(e){let{agent:t,link:n=!1,className:s=""}=e,{t:a}=(0,c.s9)(),{of:o}=d(t);if(!o)return null;let u=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.A,{size:11,"aria-hidden":!0}),o.name]}),m=a("agent.cloneOf",{name:o.name});return n?(0,r.jsx)(i(),{className:"chip clone ".concat(s),href:"/agents/".concat(o.id),title:m,onClick:e=>e.stopPropagation(),children:u}):(0,r.jsx)("span",{className:"chip clone ".concat(s),title:m,children:u})}function m(e){let{agent:t}=e,{t:n}=(0,c.s9)(),{clones:s}=d(t);return s.length?(0,r.jsxs)("span",{className:"chip clone",title:n("agent.clonesList",{names:s.map(e=>e.name).join(", ")}),children:[(0,r.jsx)(l.A,{size:11,"aria-hidden":!0}),n("agent.clones.count",{count:s.length})]}):null}},25229:(e,t,n)=>{"use strict";n.d(t,{v:()=>a});var r=n(94799),s=n(69654);let i={running:"status.running",err:"status.error",unread:"attn.state.doneUnread"};function a(e){let{state:t}=e,{t:n}=(0,s.s9)();return t?(0,r.jsx)("i",{className:"pip ".concat("running"===t?"":t),role:"img","aria-label":n(i[t])}):null}},33974:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});let r=(0,n(74955).A)("PanelLeftOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]])},34237:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>E});var r=n(94799),s=n(34023),i=n(43624),a=n(41463),l=n.n(a),o=n(33974),c=n(78330),d=n(92947),u=n(79141),m=n(58311),h=n(48538),f=n(77021),p=n(47890),g=n(69654),v=n(72942),x=n(40639),j=n(5138),y=n(25229),w=n(5372),b=n(11580),N=n(1517),k=n(494);function C(e){let{activeId:t,collapsed:n=!1,onToggle:i}=e,{t:a}=(0,g.s9)(),{agents:C,colonies:E,live:_,ready:A,dispatches:L}=(0,h.o0)(),{unread:z}=(0,x.QE)(),R=(0,w.z6)(),[S,T]=(0,s.useState)(""),[M,q]=(0,s.useState)(!1),[P,B]=(0,f.ud)("hive-am.switcher.folded",[]),O=Array.isArray(P)?P:[],I=e=>B(t=>{let n=(Array.isArray(t)?t:[]).filter(e=>"free"===e||E.some(t=>t.id===e));return n.includes(e)?n.filter(t=>t!==e):[...n,e]}),F=(0,s.useMemo)(()=>{let e=e=>!S||"".concat(e.name," ").concat(e.description," ").concat(e.provider," ").concat(e.model).toLowerCase().includes(S.toLowerCase()),t=E.map(t=>({key:t.id,name:t.name,color:t.color||"var(--honey)",items:C.filter(n=>n.colony_id===t.id&&e(n))}));for(let n of(t.push({key:"free",name:a("common.noColony"),color:null,items:C.filter(t=>(!t.colony_id||!E.some(e=>e.id===t.colony_id))&&e(t))}),t))n.items.sort((e,t)=>Number("orchestrator"===t.role)-Number("orchestrator"===e.role));return t.filter(e=>e.items.length)},[C,E,S,a]),D=e=>!!S||!O.includes(e),U=e=>e.filter(e=>"running"===e.status).length,W=(e,n)=>n?e:e.filter(e=>e.id===t),H=e=>{let t=e.filter(e=>z[e.id]);return{count:t.length,tone:t.some(e=>"error"===z[e.id].kind)?"err":""}},J=(0,s.useMemo)(()=>new Map(C.map(e=>[e.id,e.name])),[C]),K=(0,s.useRef)(null),Q=(0,s.useRef)("");(0,s.useEffect)(()=>{let e=K.current,r=null==e?void 0:e.querySelector(".sw-item[aria-current]"),s="".concat(t,":").concat(n);if(!e||!r||Q.current===s)return;Q.current=s;let i=e.getBoundingClientRect(),a=r.getBoundingClientRect();a.top<i.top?e.scrollTop-=i.top-a.top:a.bottom>i.bottom&&(e.scrollTop+=a.bottom-i.bottom)});let X=i&&(0,r.jsx)("button",{className:"btn ghost icon sm",onClick:i,"aria-label":n?a("switcher.expand"):a("switcher.collapse"),title:n?a("switcher.expand"):a("switcher.collapse"),"aria-expanded":!n,children:n?(0,r.jsx)(o.A,{size:17}):(0,r.jsx)(c.A,{size:17})});if(n)return(0,r.jsxs)("aside",{className:"switcher mini","aria-label":a("nav.agents"),children:[(0,r.jsxs)("div",{className:"switcher-head",children:[X,(0,r.jsx)("button",{className:"btn ghost icon sm",onClick:()=>q(!0),"aria-label":a("newAgent.title"),title:a("newAgent.title"),children:(0,r.jsx)(d.A,{size:16})})]}),(0,r.jsx)("div",{className:"switcher-list",ref:K,children:F.map(e=>{let n=D(e.key),s=n?0:U(e.items),i=H(e.items),o=[a("switcher.groupSize",{name:e.name,count:e.items.length}),s>0&&a("switcher.groupBusy",{count:s}),i.count>0&&a("attn.group.unread",{count:i.count})].filter(Boolean).join(", ");return(0,r.jsxs)("div",{className:"mini-group",children:[(0,r.jsxs)("button",{type:"button",className:"mini-sep","aria-expanded":n,disabled:!!S,onClick:()=>I(e.key),"aria-label":o,title:"".concat(o,"\n").concat(n?a("switcher.groupFold",{name:e.name}):a("switcher.groupUnfold",{name:e.name})),style:e.color?{"--c":e.color}:void 0,children:[(0,r.jsx)(u.A,{size:10,className:"chev","aria-hidden":!0}),(0,r.jsx)("span",{className:"ms-abbr","aria-hidden":!0,children:function(e){var t;let n=e.trim().split(/[\s_-]+/).filter(Boolean),r=e=>"function"==typeof Intl.Segmenter?Array.from(new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(e),e=>e.segment):Array.from(e);return(n.length>1?r(n[0])[0]+r(n[1])[0]:r(null!=(t=n[0])?t:"").slice(0,2).join("")).toLocaleUpperCase()}(e.name)}),(0,r.jsx)("span",{className:"ms-count","aria-hidden":!0,children:e.items.length}),s>0&&(0,r.jsx)("i",{className:"pip","aria-hidden":!0}),i.count>0&&(0,r.jsx)("i",{className:"pip unread ".concat(i.tone),"aria-hidden":!0})]}),W(e.items,n).map(e=>(0,r.jsx)(l(),{href:"/agents/".concat(e.id),className:"sw-item mini","aria-current":e.id===t?"page":void 0,"aria-label":[e.name,(e=>{let t=(0,j.vp)(e.status,z[e.id]);return"running"===t?a("status.running"):"err"===t?a("status.error"):"unread"===t?a("attn.state.doneUnread"):""})(e),e.cloned_from&&C.some(t=>t.id===e.cloned_from)&&a("agent.cloneOf",{name:C.find(t=>t.id===e.cloned_from).name})].filter(Boolean).join(", "),...R.bind(e.id),children:(0,r.jsxs)("span",{className:"sw-av",children:[(0,r.jsx)(b._h,{agent:e}),(0,r.jsx)(y.v,{state:(0,j.vp)(e.status,z[e.id])})]})},e.id))]},e.key)})}),M&&(0,r.jsx)(N.bC,{onClose:()=>q(!1)}),R.node]});let G=e=>{let n=(0,j.Bs)({agent:e,dispatches:L,nameOf:e=>J.get(e),activity:(0,v.E)(_[e.id]),notice:z[e.id]},a);return(0,r.jsxs)(l(),{href:"/agents/".concat(e.id),className:"sw-item","aria-current":e.id===t?"page":void 0,...R.bind(e.id),children:[(0,r.jsxs)("span",{className:"sw-av",children:[(0,r.jsx)(b._h,{agent:e}),(0,r.jsx)(y.v,{state:(0,j.vp)(e.status,z[e.id])})]}),(0,r.jsxs)("span",{className:"sw-body",children:[(0,r.jsxs)("span",{className:"sw-top",children:[(0,r.jsx)("b",{children:e.name}),"orchestrator"===e.role&&(0,r.jsx)("em",{children:a("role.orchestrator")}),e.cloned_from&&C.some(t=>t.id===e.cloned_from)&&(0,r.jsxs)("em",{className:"clone",title:a("agent.cloneOf",{name:C.find(t=>t.id===e.cloned_from).name}),children:[(0,r.jsx)(k.A,{size:9,"aria-hidden":!0}),C.find(t=>t.id===e.cloned_from).name]})]}),(0,r.jsx)("span",{className:"sw-sub ".concat("desc"===n.kind?e.description?"":"blank":n.kind),children:n.text}),(0,r.jsxs)("span",{className:"sw-meta",children:[(0,r.jsx)("i",{style:{background:p.xq[e.provider].color}}),(0,r.jsxs)("span",{className:"sw-model",children:[p.xq[e.provider].short,e.model?" \xb7 ".concat(e.model):""]}),(0,r.jsx)("span",{className:"sw-ago",children:e.queued&&e.queued>0?a("queue.count",{count:e.queued}):(0,p.KN)(e.updated_at)})]})]})]},e.id)};return(0,r.jsxs)("aside",{className:"switcher","aria-label":a("nav.agents"),children:[(0,r.jsxs)("div",{className:"switcher-head",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{style:{fontFamily:"var(--font-display)",fontSize:16},className:"grow",children:a("nav.agents")}),X,(0,r.jsx)("button",{className:"btn ghost icon sm",onClick:()=>q(!0),"aria-label":a("newAgent.title"),children:(0,r.jsx)(d.A,{size:16})})]}),(0,r.jsxs)("div",{className:"search",children:[(0,r.jsx)(m.A,{size:15}),(0,r.jsx)("input",{className:"input",placeholder:a("switcher.find"),value:S,onChange:e=>T(e.target.value),"aria-label":a("switcher.find")})]})]}),(0,r.jsxs)("div",{className:"switcher-list",ref:K,children:[0===F.length&&(S||A)&&(0,r.jsx)("p",{className:"muted small",style:{padding:16},children:S?a("switcher.noMatch",{query:S}):a("switcher.empty")}),F.map(e=>{let t=D(e.key),n=U(e.items),s=H(e.items);return(0,r.jsxs)("div",{children:[(0,r.jsxs)("button",{type:"button",className:"switcher-group","aria-expanded":t,disabled:!!S,onClick:()=>I(e.key),title:t?a("switcher.groupFold",{name:e.name}):a("switcher.groupUnfold",{name:e.name}),children:[(0,r.jsx)(u.A,{size:13,className:"chev","aria-hidden":!0}),e.color&&(0,r.jsx)("i",{className:"cdot",style:{background:e.color}}),(0,r.jsx)("span",{className:"sg-name",children:e.name}),!t&&n>0&&(0,r.jsx)("i",{className:"pip",role:"img","aria-label":a("switcher.groupBusy",{count:n})}),s.count>0&&(0,r.jsxs)("span",{className:"sg-unread ".concat(s.tone),role:"img","aria-label":a("attn.group.unread",{count:s.count}),children:[(0,r.jsx)("i",{}),s.count]}),(0,r.jsx)("span",{className:"sg-count",children:e.items.length})]}),W(e.items,t).map(G)]},e.key)})]}),M&&(0,r.jsx)(N.bC,{onClose:()=>q(!1)}),R.node]})}function E(e){let{children:t}=e,{id:n}=(0,i.useParams)(),[a,l]=(0,f.ud)("hive-switcher-collapsed",0),o=1===a,[c,d]=(0,s.useState)(!1);return n?(0,r.jsxs)("div",{className:"ws ".concat(o?"sw-collapsed":""," ").concat(c?"sw-anim":""),children:[(0,r.jsx)(C,{activeId:n,collapsed:o,onToggle:()=>{d(!0),l(+!o)}}),t]}):(0,r.jsx)(r.Fragment,{children:t})}},40639:(e,t,n)=>{"use strict";n.d(t,{QE:()=>m,im:()=>v,jl:()=>h});var r=n(94799),s=n(34023),i=n(43624),a=n(77021),l=n(48538),o=n(69654),c=n(5138);let d=(0,s.createContext)(null),u=(0,s.createContext)(null),m=()=>{let e=(0,s.useContext)(d);if(!e)throw Error("AttentionProvider missing");return e},h=()=>{let e=(0,s.useContext)(u);if(!e)throw Error("AttentionProvider missing");return e},f=e=>{var t,n;return null!=(n=null==(t=/^\/agents\/([^/]+)/.exec(null!=e?e:""))?void 0:t[1])?n:null};function p(){let e=(0,a.CL)(c.yl,{});if(!e||"object"!=typeof e||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))r&&("done"===r.kind||"error"===r.kind)&&"number"==typeof r.at&&(t[n]={kind:r.kind,at:r.at,snippet:"string"==typeof r.snippet?r.snippet:""});return t}function g(){return"undefined"!=typeof Notification&&window.isSecureContext?"default"===Notification.permission?"default":Notification.permission:"unsupported"}function v(e){let{children:t}=e,{t:n}=(0,o.s9)(),m=(0,i.usePathname)(),h=(0,i.useRouter)(),{agent:v,onTurnEnd:x}=(0,l.zd)(),j=(0,l.Tu)(e=>e.agents),y=(0,l.Tu)(e=>e.ready),[w,b]=(0,s.useState)({}),N=(0,s.useRef)({}),[k,C]=(0,s.useState)(!1),[E,_]=(0,s.useState)(!1),[A,L]=(0,s.useState)("unsupported"),z=(0,s.useCallback)(e=>{let t=e(N.current);t!==N.current&&(N.current=t,b(t),(0,a.zS)(c.yl,t))},[]);(0,s.useLayoutEffect)(()=>{N.current=p(),b(N.current),_(!0===(0,a.CL)(c.ym,!1)),L(g()),C(!0);let e=e=>{(e.key===c.yl||null===e.key)&&(N.current=p(),b(N.current)),(e.key===c.ym||null===e.key)&&_(!0===(0,a.CL)(c.ym,!1))};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[]);let[R,S]=(0,s.useState)(!0),T=(0,s.useRef)(!0),M=(0,s.useRef)(m);M.current=m,(0,s.useEffect)(()=>{let e=()=>{T.current="visible"===document.visibilityState,S(T.current)};return e(),document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[]);let q=f(m);(0,s.useEffect)(()=>{k&&R&&q&&w[q]&&z(e=>(0,c.Ip)(e,q))},[k,R,q,w,z]),(0,s.useEffect)(()=>{k&&(0,c.wI)(y)&&z(e=>(0,c.gv)(e,new Set(j.map(e=>e.id))))},[k,y,j,z]);let[P,B]=(0,s.useState)(""),O=(0,s.useRef)(void 0),I=(0,s.useRef)(0),F=(0,s.useCallback)(e=>{clearTimeout(O.current),B(""),O.current=setTimeout(()=>{I.current=Date.now(),B(e)},Math.max(0,I.current+2e3-Date.now()))},[]);(0,s.useEffect)(()=>()=>clearTimeout(O.current),[]);let D=(0,s.useRef)(!1);D.current=E&&"granted"===A;let U=(0,s.useCallback)(async e=>{if(!e){_(!1),(0,a.zS)(c.ym,!1);return}let t=g();if("default"===t){try{await Notification.requestPermission()}catch(e){}t=g()}L(t);let n="granted"===t;_(n),(0,a.zS)(c.ym,n)},[]),W=(0,s.useRef)(n);W.current=n,(0,s.useEffect)(()=>x(e=>{var t,n;let r=f(M.current)===e.agentId&&T.current;if(!(0,c.JN)(e,r))return;z(t=>(0,c.Mp)(t,e));let s=null!=(n=null==(t=v(e.agentId))?void 0:t.name)?n:"",i=W.current;if(T.current&&F(i("error"===e.kind?"attn.announce.error":"attn.announce.done",{name:s})),D.current&&(document.hidden||!document.hasFocus()))try{let t=new Notification(s,{body:[i("error"===e.kind?"status.error":"attn.state.done"),e.snippet].filter(Boolean).join("\n"),tag:e.agentId,silent:!0});t.onclick=()=>{window.focus(),h.push("/agents/".concat(e.agentId)),t.close()}}catch(e){}}),[x,z,v,F,h]);let H=Object.keys(w).length,J=(0,s.useRef)("hive-am");(0,s.useEffect)(()=>{J.current=(0,c.WT)(H),document.title!==J.current&&(document.title=J.current)},[H,m]),(0,s.useEffect)(()=>{let e=new MutationObserver(()=>{document.title!==J.current&&(document.title=J.current)});return e.observe(document.head,{childList:!0,subtree:!0,characterData:!0}),()=>e.disconnect()},[]);let[K,Q]=(0,s.useState)(!1),X=(0,s.useMemo)(()=>({open:K,openActivity:()=>Q(!0),closeActivity:()=>Q(!1),toggleActivity:()=>Q(e=>!e)}),[K]),G=(0,s.useMemo)(()=>{var e,t;return{unread:w,latest:null!=(t=null==(e=(0,c.Pw)(w)[0])?void 0:e.id)?t:null,markRead:e=>z(t=>(0,c.Ip)(t,e)),markAll:()=>z(c.Rf),notify:E&&"granted"===A,notifyState:A,setNotify:U,announce:F}},[w,z,E,A,U,F]);return(0,r.jsx)(d.Provider,{value:G,children:(0,r.jsxs)(u.Provider,{value:X,children:[t,(0,r.jsx)("div",{className:"sr-only",role:"status","aria-live":"polite","data-live":!0,children:P})]})})}},72942:(e,t,n)=>{"use strict";n.d(t,{E:()=>i});var r=n(68419),s=n(10969);function i(e){if(!e)return null;let t=e.blocks[e.blocks.length-1],n="dispatch"===e.source?(0,r.Tl)("activity.delegated"):"";if(!t)return"".concat(n).concat((0,r.Tl)("activity.starting"));if("tool"===t.type){let e=(0,s.q0)(t),i="".concat(e.label).concat(e.summary?" ".concat(e.summary):"");return"".concat(n).concat(void 0===t.output?(0,r.Tl)("activity.running",{tool:i}):(0,r.Tl)("activity.ran",{tool:i}))}return"".concat(n).concat("thinking"===t.type?(0,r.Tl)("activity.thinking"):(0,r.Tl)("activity.writing"))}},78330:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});let r=(0,n(74955).A)("PanelLeftClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]])},85691:(e,t,n)=>{Promise.resolve().then(n.bind(n,34237))}},e=>{e.O(0,[586,7706,5642,9977,1517,969,7408,89,7358],()=>e(e.s=85691)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7165],{494:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},3492:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("Heading2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]])},15426:(e,s,t)=>{"use strict";t.d(s,{IX:()=>h,R4:()=>x});var a=t(94799),l=t(41463),n=t.n(l),i=t(34023),d=t(494),c=t(48538),r=t(69654);function o(e){let s=(0,c.Tu)(e=>e.agents);return(0,i.useMemo)(()=>({of:e.cloned_from?s.find(s=>s.id===e.cloned_from):void 0,clones:s.filter(s=>s.cloned_from===e.id)}),[s,e.id,e.cloned_from])}function h(e){let{agent:s,link:t=!1,className:l=""}=e,{t:i}=(0,r.s9)(),{of:c}=o(s);if(!c)return null;let h=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.A,{size:11,"aria-hidden":!0}),c.name]}),x=i("agent.cloneOf",{name:c.name});return t?(0,a.jsx)(n(),{className:"chip clone ".concat(l),href:"/agents/".concat(c.id),title:x,onClick:e=>e.stopPropagation(),children:h}):(0,a.jsx)("span",{className:"chip clone ".concat(l),title:x,children:h})}function x(e){let{agent:s}=e,{t}=(0,r.s9)(),{clones:l}=o(s);return l.length?(0,a.jsxs)("span",{className:"chip clone",title:t("agent.clonesList",{names:l.map(e=>e.name).join(", ")}),children:[(0,a.jsx)(d.A,{size:11,"aria-hidden":!0}),t("agent.clones.count",{count:l.length})]}):null}},20555:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]])},47857:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>j});var a=t(94799),l=t(41463),n=t.n(l),i=t(43624),d=t(34023),c=t(92947),r=t(48538),o=t(77021),h=t(47890),x=t(11580),p=t(1517),m=t(15426),u=t(69654);function j(){let{t:e}=(0,u.s9)(),{agents:s,colonies:t,ready:l,error:j,retry:y}=(0,r.q5)(),k=(0,i.useRouter)(),[g,v]=(0,o.ud)("hive-am.agents.q",""),[b,f]=(0,o.ud)("hive-am.agents.role","all"),[N,A]=(0,o.ud)("hive-am.agents.provider","all"),[M,w]=(0,d.useState)(!1),C=(0,d.useMemo)(()=>s.filter(e=>("all"===b||e.role===b)&&("all"===N||e.provider===N)&&(!g||"".concat(e.name," ").concat(e.description," ").concat(e.cwd).toLowerCase().includes(g.toLowerCase()))),[s,g,b,N]);return(0,a.jsxs)("div",{className:"page",children:[(0,a.jsxs)("div",{className:"page-head",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{children:e("nav.agents")}),(0,a.jsx)("p",{children:e("agents.subtitle")})]}),(0,a.jsxs)("button",{className:"btn primary",onClick:()=>w(!0),children:[(0,a.jsx)(c.A,{size:16}),e("newAgent.title")]})]}),!l&&j&&(0,a.jsx)(x.lZ,{kind:"err",children:(0,a.jsxs)("div",{className:"row gap-s wrap",children:[(0,a.jsxs)("span",{className:"grow",children:[e("cx.loadFailed")," ",j]}),(0,a.jsx)("button",{className:"btn sm",onClick:()=>void y(),children:e("cx.retry")})]})}),(0,a.jsxs)("div",{className:"row wrap agents-filters",children:[(0,a.jsx)(x.DO,{className:"grow",value:g,onChange:v,placeholder:e("agents.searchPlaceholder"),label:e("agents.searchLabel")}),(0,a.jsx)(x.$q,{value:b,onChange:f,options:[{id:"all",label:e("common.all")},{id:"orchestrator",label:e("agents.filter.orchestrators")},{id:"worker",label:e("agents.filter.workers")}]}),(0,a.jsx)(x.$q,{value:N,onChange:A,options:[{id:"all",label:e("agents.filter.anyProvider")},...Object.keys(h.xq).map(e=>({id:e,label:h.xq[e].short}))]})]}),l&&0===s.length?(0,a.jsx)(x.pp,{icon:(0,a.jsx)(x._h,{size:"lg",queen:!0,label:"+"}),title:e("agents.empty.title"),body:e("agents.empty.body"),action:(0,a.jsxs)("button",{className:"btn primary",onClick:()=>w(!0),children:[(0,a.jsx)(c.A,{size:16}),e("newAgent.create")]})}):l?0===C.length?(0,a.jsx)(x.pp,{title:e("agents.noMatch.title"),body:e("agents.noMatch.body"),action:(0,a.jsx)("button",{className:"btn",onClick:()=>{v(""),f("all"),A("all")},children:e("common.clearFilters")})}):(0,a.jsx)("div",{className:"card table-scroll",children:(0,a.jsxs)("table",{className:"table",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:e("agents.col.agent")}),(0,a.jsx)("th",{children:e("agents.col.providerModel")}),(0,a.jsx)("th",{children:e("form.colony")}),(0,a.jsx)("th",{children:e("colony.folder")}),(0,a.jsx)("th",{children:e("agents.col.status")}),(0,a.jsx)("th",{children:e("agents.col.updated")})]})}),(0,a.jsx)("tbody",{children:C.map(s=>{let l=()=>k.push("/agents/".concat(s.id)),i=t.find(e=>e.id===s.colony_id);return(0,a.jsxs)("tr",{className:"row-link",tabIndex:0,"aria-label":e("cx.openAgent",{name:s.name}),onClick:l,onKeyDown:e=>{e.target===e.currentTarget&&("Enter"===e.key||" "===e.key)&&(e.preventDefault(),l())},children:[(0,a.jsx)("td",{children:(0,a.jsxs)("div",{className:"name-cell",children:[(0,a.jsx)(x._h,{agent:s}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("b",{children:[(0,a.jsx)(n(),{href:"/agents/".concat(s.id),onClick:e=>e.stopPropagation(),children:s.name})," ",(0,a.jsx)(m.IX,{agent:s,link:!0}),(0,a.jsx)(m.R4,{agent:s})]}),(0,a.jsx)("span",{children:s.description||("orchestrator"===s.role?e("agents.orchestratorLine",{count:s.worker_ids.length}):e("role.worker"))})]})]})}),(0,a.jsxs)("td",{children:[(0,a.jsx)("div",{className:"fw-600",children:h.xq[s.provider].label}),(0,a.jsx)("span",{className:"muted small",children:s.model||e("model.cliDefault")})]}),(0,a.jsx)("td",{children:i?(0,a.jsxs)("span",{className:"chip",children:[(0,a.jsx)("i",{className:"cdot cx-chip-dot",style:{background:i.color||"var(--honey)"}}),i.name]}):(0,a.jsx)("span",{className:"muted small",children:"—"})}),(0,a.jsxs)("td",{className:"mono muted small",children:[(0,h._1)(s.effective.cwd),s.effective.inherited.includes("cwd")?" \xb7":"",s.effective.inherited.includes("cwd")&&(0,a.jsxs)("span",{className:"muted",children:[" ",e("agents.colonyWord")]})]}),(0,a.jsx)("td",{children:(0,a.jsxs)("div",{className:"row gap-s wrap",children:[(0,a.jsx)(x.PW,{role:s.role}),(0,a.jsx)(x.P5,{status:s.status})]})}),(0,a.jsx)("td",{className:"muted small",children:(0,h.KN)(s.updated_at)})]},s.id)})})]})}):(0,a.jsxs)("div",{className:"card comb-skel",role:"status","aria-label":e("cx.loading"),children:[(0,a.jsx)("div",{className:"skel",style:{width:"100%",height:48}}),(0,a.jsx)("div",{className:"skel",style:{width:"100%",height:48}}),(0,a.jsx)("div",{className:"skel",style:{width:"100%",height:48}})]}),M&&(0,a.jsx)(p.bC,{onClose:()=>w(!1)})]})}},52263:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]])},55712:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]])},55838:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]])},66910:(e,s,t)=>{Promise.resolve().then(t.bind(t,47857))},71529:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]])},91833:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]])},92947:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},98148:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]])},98938:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]])},99579:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]])}},e=>{e.O(0,[586,7706,9977,1517,7408,89,7358],()=>e(e.s=66910)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8457],{3492:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(74955).A)("Heading2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]])},20555:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(74955).A)("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]])},52263:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(74955).A)("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]])},54609:(e,t,a)=>{"use strict";a.d(t,{O:()=>s,g:()=>d});let s="hive-am.lastChat",d=(e,t)=>e.some(e=>e.id===t)?"/agents/".concat(t):e[0]?"/agents/".concat(e[0].id):"/chat"},55712:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(74955).A)("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]])},55838:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(74955).A)("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]])},69925:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>o});var s=a(94799),d=a(34023),h=a(43624),i=a(87454),l=a(92947),c=a(48538),n=a(77021),r=a(54609),y=a(11580),p=a(1517),k=a(69654);function o(){let{t:e}=(0,k.s9)(),{agents:t,ready:a,error:o,retry:u}=(0,c.q5)(),x=(0,h.useRouter)(),[A,M]=(0,d.useState)(!1);return(0,d.useEffect)(()=>{if(!a||0===t.length)return;let e=(0,n.CL)(r.O,"");x.replace("/agents/".concat(t.some(t=>t.id===e)?e:t[0].id))},[a,t,x]),(0,s.jsxs)("div",{className:"page",children:[(0,s.jsx)("div",{className:"page-head",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{children:e("nav.chat")}),(0,s.jsx)("p",{children:e("chat.home.subtitle")})]})}),!a&&o&&(0,s.jsx)(y.lZ,{kind:"err",children:(0,s.jsxs)("div",{className:"row gap-s wrap",children:[(0,s.jsxs)("span",{className:"grow",children:[e("cx.loadFailed")," ",o]}),(0,s.jsx)("button",{className:"btn sm",onClick:()=>void u(),children:e("cx.retry")})]})}),a&&0===t.length&&(0,s.jsx)(y.pp,{icon:(0,s.jsx)(i.A,{size:28}),title:e("chat.home.empty.title"),body:e("chat.home.empty.body"),action:(0,s.jsxs)("button",{className:"btn primary",onClick:()=>M(!0),children:[(0,s.jsx)(l.A,{size:16}),e("newAgent.create")]})}),A&&(0,s.jsx)(p.bC,{onClose:()=>M(!1)})]})}},71529:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(74955).A)("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]])},83518:(e,t,a)=>{Promise.resolve().then(a.bind(a,69925))},87454:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(74955).A)("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]])},91833:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(74955).A)("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]])},92947:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(74955).A)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},98148:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(74955).A)("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]])},98938:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(74955).A)("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]])},99579:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(74955).A)("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]])}},e=>{e.O(0,[586,7706,9977,1517,7408,89,7358],()=>e(e.s=83518)),_N_E=e.O()}]);