hive-am 1.2.2 → 1.3.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 (110) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/package.json +1 -1
  3. package/server/dist/context.js +62 -0
  4. package/server/dist/db/migrations.js +7 -0
  5. package/server/dist/db.js +4 -4
  6. package/server/dist/history/claude.js +8 -2
  7. package/server/dist/http/routes/agents.js +1 -1
  8. package/server/dist/http/validate.js +2 -0
  9. package/server/dist/instructions.js +4 -0
  10. package/server/dist/models.js +2 -0
  11. package/server/dist/providers/claude.js +13 -1
  12. package/server/dist/providers/opencode-server.js +59 -0
  13. package/server/dist/providers/opencode.js +4 -1
  14. package/server/dist/stats.js +15 -3
  15. package/web/.next/BUILD_ID +1 -1
  16. package/web/.next/app-build-manifest.json +70 -70
  17. package/web/.next/app-path-routes-manifest.json +7 -7
  18. package/web/.next/build-manifest.json +2 -2
  19. package/web/.next/prerender-manifest.json +49 -49
  20. package/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  21. package/web/.next/server/app/_not-found.html +1 -1
  22. package/web/.next/server/app/_not-found.rsc +3 -3
  23. package/web/.next/server/app/agents/[id]/page.js +3 -3
  24. package/web/.next/server/app/agents/[id]/page.js.nft.json +1 -1
  25. package/web/.next/server/app/agents/[id]/page_client-reference-manifest.js +1 -1
  26. package/web/.next/server/app/agents/page.js +1 -1
  27. package/web/.next/server/app/agents/page_client-reference-manifest.js +1 -1
  28. package/web/.next/server/app/agents.html +1 -1
  29. package/web/.next/server/app/agents.rsc +4 -4
  30. package/web/.next/server/app/connections/page.js +1 -1
  31. package/web/.next/server/app/connections/page_client-reference-manifest.js +1 -1
  32. package/web/.next/server/app/connections.html +1 -1
  33. package/web/.next/server/app/connections.rsc +4 -4
  34. package/web/.next/server/app/index.html +1 -1
  35. package/web/.next/server/app/index.rsc +4 -4
  36. package/web/.next/server/app/page.js +1 -1
  37. package/web/.next/server/app/page.js.nft.json +1 -1
  38. package/web/.next/server/app/page_client-reference-manifest.js +1 -1
  39. package/web/.next/server/app/relations/page.js +1 -1
  40. package/web/.next/server/app/relations/page_client-reference-manifest.js +1 -1
  41. package/web/.next/server/app/relations.html +1 -1
  42. package/web/.next/server/app/relations.rsc +4 -4
  43. package/web/.next/server/app/resources/[id]/page.js +1 -1
  44. package/web/.next/server/app/resources/[id]/page.js.nft.json +1 -1
  45. package/web/.next/server/app/resources/[id]/page_client-reference-manifest.js +1 -1
  46. package/web/.next/server/app/resources/page.js +1 -1
  47. package/web/.next/server/app/resources/page.js.nft.json +1 -1
  48. package/web/.next/server/app/resources/page_client-reference-manifest.js +1 -1
  49. package/web/.next/server/app/resources.html +1 -1
  50. package/web/.next/server/app/resources.rsc +4 -4
  51. package/web/.next/server/app/schedules/page.js +1 -1
  52. package/web/.next/server/app/schedules/page_client-reference-manifest.js +1 -1
  53. package/web/.next/server/app/schedules.html +1 -1
  54. package/web/.next/server/app/schedules.rsc +4 -4
  55. package/web/.next/server/app/sessions/page.js +1 -1
  56. package/web/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
  57. package/web/.next/server/app/sessions.html +1 -1
  58. package/web/.next/server/app/sessions.rsc +4 -4
  59. package/web/.next/server/app/skills/page.js +1 -1
  60. package/web/.next/server/app/skills/page_client-reference-manifest.js +1 -1
  61. package/web/.next/server/app/skills.html +1 -1
  62. package/web/.next/server/app/skills.rsc +4 -4
  63. package/web/.next/server/app/types/page.js +1 -1
  64. package/web/.next/server/app/types/page_client-reference-manifest.js +1 -1
  65. package/web/.next/server/app/types.html +1 -1
  66. package/web/.next/server/app/types.rsc +4 -4
  67. package/web/.next/server/app-paths-manifest.json +7 -7
  68. package/web/.next/server/chunks/143.js +1 -1
  69. package/web/.next/server/chunks/274.js +1 -1
  70. package/web/.next/server/chunks/306.js +1 -1
  71. package/web/.next/server/chunks/451.js +1 -0
  72. package/web/.next/server/chunks/505.js +1 -1
  73. package/web/.next/server/chunks/612.js +1 -1
  74. package/web/.next/server/chunks/716.js +2 -2
  75. package/web/.next/server/pages/404.html +1 -1
  76. package/web/.next/server/pages/500.html +1 -1
  77. package/web/.next/server/server-reference-manifest.json +1 -1
  78. package/web/.next/static/chunks/281-d8a0dcfaa6d064e4.js +1 -0
  79. package/web/.next/static/chunks/{291-efae53ea5f7ee92d.js → 291-23f314877fa39054.js} +1 -1
  80. package/web/.next/static/chunks/304-681348099f874a30.js +1 -0
  81. package/web/.next/static/chunks/350-0fe82e622e7a670f.js +1 -0
  82. package/web/.next/static/chunks/{491-6b4e6201f5110dff.js → 491-28f093772bd460ac.js} +1 -1
  83. package/web/.next/static/chunks/517-373a80c8ba432bdc.js +1 -0
  84. package/web/.next/static/chunks/654-92a63b3c4b412666.js +1 -0
  85. package/web/.next/static/chunks/705-780e48e55b0346bd.js +1 -0
  86. package/web/.next/static/chunks/{844-fe55292e0701f436.js → 844-519177e6198ca84f.js} +1 -1
  87. package/web/.next/static/chunks/app/agents/[id]/page-c005161cec5527d8.js +1 -0
  88. package/web/.next/static/chunks/app/agents/{page-f4c4c80f955f3967.js → page-9bb8cba69776c719.js} +1 -1
  89. package/web/.next/static/chunks/app/connections/{page-0936beaf02d863c6.js → page-eb11cfb1ffeab3ca.js} +1 -1
  90. package/web/.next/static/chunks/app/{layout-99620746d028dda8.js → layout-49b46c9b5aa512a8.js} +1 -1
  91. package/web/.next/static/chunks/app/{page-a7f292117b7d76bf.js → page-da042d146caeeab6.js} +1 -1
  92. package/web/.next/static/chunks/app/relations/{page-fba25393c8688714.js → page-a44fd515a3b0525e.js} +1 -1
  93. package/web/.next/static/chunks/app/resources/[id]/{page-d110d89bb8b5fca7.js → page-bf05836f97248ca7.js} +1 -1
  94. package/web/.next/static/chunks/app/resources/{page-bbd0b450d3f3131d.js → page-800f774e5cacf4c9.js} +1 -1
  95. package/web/.next/static/chunks/app/schedules/{page-a1124397fc760413.js → page-96976fff4ee23538.js} +1 -1
  96. package/web/.next/static/chunks/app/sessions/{page-0e322811b0cde724.js → page-a7534ebd90e982d6.js} +1 -1
  97. package/web/.next/static/chunks/app/skills/{page-22ea0ef89d9f7a13.js → page-bc1acd0663f36129.js} +1 -1
  98. package/web/.next/static/chunks/app/types/{page-18c4e1db2724d41d.js → page-ebd37e220f77c1f3.js} +1 -1
  99. package/web/.next/static/css/{b7a03c62468f4263.css → d42799b7e6a0e8a2.css} +1 -1
  100. package/web/.next/trace +29 -29
  101. package/web/.next/server/chunks/555.js +0 -1
  102. package/web/.next/static/chunks/176-aeaf907a6ea5627d.js +0 -1
  103. package/web/.next/static/chunks/350-56599dc3bf06066d.js +0 -1
  104. package/web/.next/static/chunks/486-13e08542f3a1cbac.js +0 -1
  105. package/web/.next/static/chunks/517-ccaf8cc5c733cbd8.js +0 -1
  106. package/web/.next/static/chunks/705-c7e75806f77b880c.js +0 -1
  107. package/web/.next/static/chunks/839-4aefe6e71be6e1ef.js +0 -1
  108. package/web/.next/static/chunks/app/agents/[id]/page-3faf40800981a736.js +0 -1
  109. /package/web/.next/static/{7BI__-ayGDTlOrSboD_bT → aSYzbHk1M5YeS_d3SQKTZ}/_buildManifest.js +0 -0
  110. /package/web/.next/static/{7BI__-ayGDTlOrSboD_bT → aSYzbHk1M5YeS_d3SQKTZ}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[177],{5506:(e,t,n)=>{"use strict";n.d(t,{Shell:()=>B});var l=n(94799),a=n(41463),s=n.n(a),r=n(43624),i=n(34023),o=n(84616),c=n(6261),d=n(29416),u=n(26701),h=n(74955);let m=(0,h.A)("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);var v=n(15223),k=n(54234),y=n(73784);let p=(0,h.A)("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);var b=n(68449),x=n(70283);let g=(0,h.A)("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),f=(0,h.A)("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);var j=n(48538),w=n(69654),A=n(86606);function N(){let[e,t]=(0,i.useState)(null),[n,a]=(0,i.useState)(null),s=(0,i.useRef)(null);return((0,i.useEffect)(()=>{let e,n=null,l=()=>{clearTimeout(e),n=null,t(null),a(null)},s=e=>e instanceof Element?e.closest("[title],[data-tip]"):null,r=function(a){let s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!a||a===n)return;l();let r=(e=>{var t,n;let l=e.getAttribute("title");return null!==l&&(e.removeAttribute("title"),l.trim()&&(e.dataset.tip=l,e.getAttribute("aria-label")||(null==(t=e.textContent)?void 0:t.trim())||e.setAttribute("aria-label",l))),null!=(n=e.dataset.tip)?n:""})(a);if(!r)return;n=a;let i=()=>{n===a&&a.isConnected&&t({text:r,rect:a.getBoundingClientRect()})};s?i():e=setTimeout(i,350)},i=e=>r(s(e.target)),o=e=>{n&&!(e.relatedTarget instanceof Node&&n.contains(e.relatedTarget))&&l()},c=e=>{let t=s(e.target);t&&t.matches(":focus-visible")&&r(t,!0)},d=e=>{"Escape"===e.key&&l()};return document.addEventListener("mouseover",i),document.addEventListener("mouseout",o),document.addEventListener("focusin",c),document.addEventListener("focusout",l),document.addEventListener("pointerdown",l,!0),document.addEventListener("keydown",d),window.addEventListener("scroll",l,!0),window.addEventListener("blur",l),()=>{l(),document.removeEventListener("mouseover",i),document.removeEventListener("mouseout",o),document.removeEventListener("focusin",c),document.removeEventListener("focusout",l),document.removeEventListener("pointerdown",l,!0),document.removeEventListener("keydown",d),window.removeEventListener("scroll",l,!0),window.removeEventListener("blur",l)}},[]),(0,i.useLayoutEffect)(()=>{if(!e||!s.current)return;let{width:t,height:n}=s.current.getBoundingClientRect(),l=e.rect.top-n-8<8;a({left:Math.min(Math.max(8,e.rect.left+e.rect.width/2-t/2),window.innerWidth-t-8),top:l?e.rect.bottom+8:e.rect.top-n-8,below:l})},[e]),e)?(0,l.jsx)("div",{ref:s,className:"tooltip",role:"tooltip","data-live":!0,"data-below":(null==n?void 0:n.below)?"1":void 0,style:n?{left:n.left,top:n.top}:{left:0,top:0,visibility:"hidden"},children:e.text}):null}var M=n(42162),E=n(19431),z=n(70665),C=n(92947),S=n(80306),L=n(12349),H=n(75010);n(21169);var _=n(69538);let T=(e,t)=>getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t,F=()=>({background:T("--bg-deep","#0c1411"),foreground:T("--ink","#e7eee9"),cursor:T("--honey","#e8a317"),cursorAccent:T("--bg-deep","#0c1411"),selectionBackground:"rgba(232,163,23,.35)"});function P(e){let{id:t,visible:a,onEnded:s}=e,{t:r}=(0,w.s9)(),o=(0,i.useRef)(null),c=(0,i.useRef)(null),d=(0,i.useRef)(a);return d.current=a,(0,i.useEffect)(()=>{let e=!1,l=null,a,i=!1,u=0,h=null,m=null,v=null,k=null,y=e=>{(null==l?void 0:l.readyState)===WebSocket.OPEN&&l.send(JSON.stringify(e))},p=()=>{var e;if(h&&m&&(null==(e=o.current)?void 0:e.offsetParent))try{m.fit(),y({t:"resize",cols:h.cols,rows:h.rows})}catch(e){}};return(async()=>{let[{Terminal:b},{FitAddon:x},{WebLinksAddon:g}]=await Promise.all([n.e(209).then(n.bind(n,75657)),n.e(97).then(n.bind(n,57097)),n.e(545).then(n.bind(n,90545))]);if(e||!o.current)return;h=new b({fontFamily:T("--font-mono","ui-monospace, monospace"),fontSize:13,lineHeight:1.15,cursorBlink:!0,scrollback:5e3,theme:F(),allowProposedApi:!1}),m=new x,h.loadAddon(m),h.loadAddon(new g),h.open(o.current),c.current={fit:p,focus:()=>null==h?void 0:h.focus()},d.current&&(p(),h.focus()),h.onData(e=>y({t:"in",d:e}));let f=()=>{var e;let t=null==h?void 0:h.getSelection();return t&&(null==(e=navigator.clipboard)||e.writeText(t).catch(()=>{})),!!t};h.onSelectionChange(()=>{f()}),h.attachCustomKeyEventHandler(e=>"keydown"!==e.type||!e.ctrlKey||!!e.altKey||!!e.metaKey||!("c"===e.key.toLowerCase()&&(e.shiftKey||(null==h?void 0:h.hasSelection())))||(f(),!1)),(v=new ResizeObserver(p)).observe(o.current),(k=new MutationObserver(()=>{h&&(h.options.theme=F())})).observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});let j=()=>{var n;(l=new WebSocket("".concat("ws://".concat(location.hostname,":").concat(null!=(n=_.env.NEXT_PUBLIC_HIVE_WS_PORT)?n:4400,"/ws/terminal"),"?id=").concat(encodeURIComponent(t)))).onopen=()=>{u=0},l.onmessage=e=>{let t=JSON.parse(e.data);"init"===t.t?(h.reset(),p()):"out"===t.t?h.write(t.d):"exit"===t.t?(i=!0,h.write("\r\n\x1b[2m[".concat(r("dock.ended",{code:t.code}),"]\x1b[0m\r\n")),s(t.code)):"gone"===t.t&&(i=!0,h.write("\r\n\x1b[2m[".concat(r("dock.gone"),"]\x1b[0m\r\n")),s(null))},l.onclose=()=>{e||i||(a=setTimeout(j,Math.min(5e3,600*2**u++)))}};j()})(),()=>{e=!0,clearTimeout(a),null==v||v.disconnect(),null==k||k.disconnect(),null==l||l.close(),null==h||h.dispose(),c.current=null}},[t]),(0,i.useEffect)(()=>{if(a){let e=setTimeout(()=>{var e,t;null==(e=c.current)||e.fit(),null==(t=c.current)||t.focus()},30);return()=>clearTimeout(e)}},[a]),(0,l.jsx)("div",{className:"xterm-box",ref:o})}let R=e=>"dock-tab-".concat(e);function q(){var e;let{t}=(0,w.s9)(),n=(0,M.n)(),[a,s]=(0,i.useState)(null),r=(0,i.useRef)(null);(0,i.useEffect)(()=>{let e=e=>{r.current&&n.setHeight(r.current.h+(r.current.y-e.clientY))},t=()=>{r.current=null,document.body.style.userSelect=""};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)}},[n]);let o=n.tabs.some(e=>e.key===n.active),c=null==(e=[...n.tabs].reverse().find(e=>"term"===e.kind))?void 0:e.cwd;return(0,l.jsxs)("section",{className:"dock",style:{height:n.height,display:n.open?void 0:"none"},"aria-hidden":!n.open,"aria-label":t("dock.title"),children:[(0,l.jsx)("div",{className:"dock-grip",onPointerDown:e=>{r.current={y:e.clientY,h:n.height},document.body.style.userSelect="none",e.preventDefault()},role:"separator","aria-orientation":"horizontal"}),(0,l.jsxs)("div",{className:"dock-bar",children:[(0,l.jsx)("div",{className:"dock-tabs",role:"tablist","aria-label":t("dock.title"),onKeyDown:e=>{var t;let l=n.tabs.map(e=>e.key),a=l.indexOf(null!=(t=n.active)?t:""),s=null;if("ArrowRight"===e.key)s=(a+1)%l.length;else if("ArrowLeft"===e.key)s=(a-1+l.length)%l.length;else if("Home"===e.key)s=0;else if("End"===e.key)s=l.length-1;else if("Delete"===e.key&&a>=0){e.preventDefault(),n.closeTab(l[a]);return}null!==s&&l.length&&(e.preventDefault(),n.setActive(l[s]),requestAnimationFrame(()=>{var e;return null==(e=document.getElementById(R(l[s])))?void 0:e.focus()}))},children:n.tabs.map(e=>{var a;let s=n.active===e.key,r=R(e.key);return(0,l.jsxs)("div",{className:"dock-tabwrap ".concat(s?"on":""),children:[(0,l.jsxs)("button",{id:r,type:"button",role:"tab","aria-selected":s,"aria-controls":"".concat(r,"-panel"),tabIndex:s||!o&&e===n.tabs[0]?0:-1,className:"dock-tab-btn",onClick:()=>n.setActive(e.key),title:"term"===e.kind?e.cwd:t("obj.logs"),children:["term"===e.kind?(0,l.jsx)(x.A,{size:14}):(0,l.jsx)(E.A,{size:14}),(0,l.jsx)("span",{className:"nm",children:e.title}),"term"===e.kind&&void 0!==e.ended&&(0,l.jsx)("i",{className:"odot off",title:t("dock.ended",{code:null!=(a=e.ended)?a:""})})]}),(0,l.jsx)("button",{type:"button",className:"dock-x",tabIndex:-1,onClick:()=>n.closeTab(e.key),"aria-label":"".concat(t("common.close"),": ").concat(e.title),children:(0,l.jsx)(z.A,{size:12})})]},e.key)})}),n.enabled&&(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:()=>void n.openTerminal(c?{cwd:c}:{}),"aria-label":t("dock.new"),title:t("dock.new"),children:(0,l.jsx)(C.A,{size:15})}),n.enabled&&(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:()=>s(null!=c?c:""),"aria-label":t("dock.inFolder"),title:t("dock.inFolder"),children:(0,l.jsx)(S.A,{size:15})}),(0,l.jsx)("span",{className:"grow"}),(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:()=>n.setOpen(!1),"aria-label":t("dock.hide"),title:"".concat(t("dock.hide")," (Ctrl+`)"),children:(0,l.jsx)(L.A,{size:15})})]}),(0,l.jsxs)("div",{className:"dock-body",children:[n.error&&(0,l.jsx)("p",{className:"gx-note err gx-hint-row",role:"alert",children:n.error}),!n.enabled&&!n.tabs.length&&(0,l.jsx)("p",{className:"gx-note",children:t("dock.disabled")}),n.enabled&&!n.tabs.length&&!n.error&&(0,l.jsx)("p",{className:"gx-note",children:t("dock.empty")}),n.tabs.map(e=>(0,l.jsx)("div",{id:"".concat(R(e.key),"-panel"),role:"tabpanel","aria-labelledby":R(e.key),className:"dock-pane",hidden:n.active!==e.key,children:"term"===e.kind?(0,l.jsx)(P,{id:e.id,visible:n.open&&n.active===e.key,onEnded:t=>n.markEnded(e.key,t)}):n.open&&(0,l.jsx)("div",{className:"dock-logpane",children:(0,l.jsx)(H.I,{id:e.objectId,height:"100%"})})},e.key))]}),null!==a&&(0,l.jsxs)(A.aF,{title:t("dock.inFolder"),onClose:()=>s(null),children:[(0,l.jsx)(A.dR,{value:a,onChange:s,label:t("obj.f.folder"),hint:t("dock.folder.hint")}),(0,l.jsxs)("div",{className:"row confirm-actions",children:[(0,l.jsx)("button",{className:"btn ghost",onClick:()=>s(null),children:t("common.cancel")}),(0,l.jsx)("button",{className:"btn primary",disabled:!a.startsWith("/"),onClick:()=>{s(null),n.openTerminal({cwd:a})},children:t("dock.open")})]})]})]})}function O(){return(0,l.jsx)("img",{src:"/icon.png",width:34,height:34,alt:"","aria-hidden":!0,className:"brand-mark"})}function V(){let{locale:e,setLocale:t,t:n}=(0,w.s9)();return(0,l.jsxs)("div",{className:"lang-row",role:"group","aria-label":n("lang.label"),children:[(0,l.jsx)(o.A,{size:15,"aria-hidden":!0}),(0,l.jsx)("div",{className:"seg",children:w.YZ.map(n=>(0,l.jsx)("button",{type:"button","aria-pressed":e===n.id,lang:n.id,title:n.name,"aria-label":n.name,onClick:()=>t(n.id),children:n.short},n.id))})]})}function I(){let e=(0,r.usePathname)(),{t}=(0,w.s9)(),{agents:n,types:a,skills:o,connections:h,objects:A,connected:N}=(0,j.o0)(),E=(0,M.n)(),[z,C]=(0,i.useState)(!1);(0,i.useEffect)(()=>{let e=document.documentElement,t=()=>C("dark"===e.dataset.theme);t();let n=new MutationObserver(t);return n.observe(e,{attributes:!0,attributeFilter:["data-theme"]}),()=>n.disconnect()},[]);let S=n.filter(e=>"running"===e.status).length,L=(t,n,a,r)=>{let i="/"===t?"/"===e:e.startsWith(t);return(0,l.jsxs)(s(),{href:t,className:"nav","aria-current":i?"page":void 0,children:[a,(0,l.jsx)("span",{className:"t",children:n}),void 0!==r&&(0,l.jsx)("span",{className:"count",children:r})]},t)};return(0,l.jsxs)("nav",{className:"rail","aria-label":t("nav.main"),children:[(0,l.jsxs)("div",{className:"brand",children:[(0,l.jsx)(O,{}),(0,l.jsxs)("div",{children:["hive-am",(0,l.jsx)("small",{children:t("app.tagline")})]})]}),(0,l.jsx)(V,{}),L("/",t("nav.colony"),(0,l.jsx)(c.A,{size:18}),S||void 0),L("/resources",t("nav.objects"),(0,l.jsx)(d.A,{size:18}),A.length||void 0),L("/agents",t("nav.agents"),(0,l.jsx)(u.A,{size:18}),n.length),L("/relations",t("nav.relations"),(0,l.jsx)(m,{size:18})),L("/connections",t("nav.connections"),(0,l.jsx)(v.A,{size:18}),h.length||void 0),L("/schedules",t("nav.schedules"),(0,l.jsx)(k.A,{size:18})),(0,l.jsx)("div",{className:"nav-label",children:t("nav.library")}),L("/types",t("nav.types"),(0,l.jsx)(y.A,{size:18}),a.length),L("/skills",t("nav.skills"),(0,l.jsx)(p,{size:18}),o.length),(0,l.jsx)("div",{className:"nav-label",children:t("nav.history")}),L("/sessions",t("nav.sessions"),(0,l.jsx)(b.A,{size:18})),(0,l.jsxs)("div",{className:"rail-foot",children:[(0,l.jsxs)("button",{type:"button",className:"nav",onClick:E.toggle,"aria-pressed":E.open,title:"".concat(t("dock.nav")," (Ctrl+`)"),children:[(0,l.jsx)(x.A,{size:18}),(0,l.jsx)("span",{className:"t",children:t("dock.nav")}),E.tabs.length>0&&(0,l.jsx)("span",{className:"count",children:E.tabs.length})]}),(0,l.jsxs)("div",{className:"conn",children:[(0,l.jsx)("i",{className:"dot ".concat(N?"ok":"err")}),t(N?"nav.connected":"nav.offline")]}),(0,l.jsxs)("button",{type:"button",className:"nav",onClick:()=>{let e=z?"light":"dark";document.documentElement.dataset.theme=e;try{localStorage.setItem("hive-theme",e)}catch(e){}},"aria-pressed":z,children:[z?(0,l.jsx)(g,{size:18}):(0,l.jsx)(f,{size:18}),(0,l.jsx)("span",{className:"t",children:t("nav.switchTheme")})]})]})]})}function B(e){let{children:t}=e;return(0,l.jsx)(w.CY,{children:(0,l.jsx)(j.Of,{children:(0,l.jsx)(M.$,{children:(0,l.jsxs)(A.l$,{children:[(0,l.jsx)(N,{}),(0,l.jsxs)("div",{className:"shell",children:[(0,l.jsx)(I,{}),(0,l.jsx)("main",{className:"main",children:t})]}),(0,l.jsx)(q,{})]})})})})}},6261:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Hexagon",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]])},15151:e=>{e.exports={style:{fontFamily:"'JetBrains Mono', 'JetBrains Mono Fallback'",fontStyle:"normal"},className:"__className_4dc837",variable:"__variable_4dc837"}},15223:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]])},19431:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]])},21169:()=>{},26701:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]])},29416:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]])},39856:e=>{e.exports={style:{fontFamily:"'Bricolage Grotesque', 'Bricolage Grotesque Fallback'",fontStyle:"normal"},className:"__className_23d1a5",variable:"__variable_23d1a5"}},42162:(e,t,n)=>{"use strict";n.d(t,{$:()=>u,n:()=>o});var l=n(94799),a=n(34023),s=n(3749),r=n(69654);let i=(0,a.createContext)(null),o=()=>{let e=(0,a.useContext)(i);if(!e)throw Error("DockProvider missing");return e},c="hive-am.dock",d=e=>Math.max(140,Math.min(e,Math.round(.8*window.innerHeight)));function u(e){let{children:t}=e,{t:n}=(0,r.s9)(),[o,u]=(0,a.useState)(!1),[h,m]=(0,a.useState)(320),[v,k]=(0,a.useState)([]),[y,p]=(0,a.useState)(null),[b,x]=(0,a.useState)(!0),[g,f]=(0,a.useState)(""),j=(0,a.useRef)(!1);(0,a.useEffect)(()=>{try{var e;let t=JSON.parse(null!=(e=localStorage.getItem(c))?e:"{}");"number"==typeof t.height&&m(d(t.height)),t.open&&u(!0),"string"==typeof t.active&&p(t.active)}catch(e){}s.FH.get("/terminals").then(e=>{x(e.enabled),k(t=>[...e.terminals.map(e=>({key:"t:".concat(e.id),kind:"term",id:e.id,title:e.title,cwd:e.cwd,ended:e.alive?void 0:e.exitCode})),...t.filter(e=>"logs"===e.kind)]),p(t=>t&&e.terminals.some(e=>"t:".concat(e.id)===t)?t:e.terminals[0]?"t:".concat(e.terminals[0].id):t)}).catch(()=>void 0).finally(()=>{j.current=!0})},[]),(0,a.useEffect)(()=>{if(j.current)try{localStorage.setItem(c,JSON.stringify({open:o,height:h,active:y}))}catch(e){}},[o,h,y]),(0,a.useEffect)(()=>{document.documentElement.style.setProperty("--app-h",o?"calc(100vh - ".concat(h,"px)"):"100vh")},[o,h]);let w=(0,a.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};f("");try{let t=await s.FH.post("/terminals",e),n={key:"t:".concat(t.id),kind:"term",id:t.id,title:t.title,cwd:t.cwd};k(e=>[...e,n]),p(n.key),u(!0)}catch(e){f(e instanceof Error?e.message:n("dock.failed")),u(!0)}},[n]),A=(0,a.useCallback)((e,t)=>{let n="l:".concat(e);k(l=>l.some(e=>e.key===n)?l:[...l,{key:n,kind:"logs",objectId:e,title:t}]),p(n),u(!0)},[]),N=(0,a.useCallback)(e=>{k(t=>{let n=t.find(t=>t.key===e);(null==n?void 0:n.kind)==="term"&&s.FH.del("/terminals/".concat(n.id)).catch(()=>void 0);let l=t.filter(t=>t.key!==e);return p(t=>{var n,a;return t===e?null!=(a=null==(n=l[l.length-1])?void 0:n.key)?a:null:t}),l})},[]),M=(0,a.useCallback)((e,t)=>k(n=>n.map(n=>n.key===e&&"term"===n.kind?{...n,ended:null!=t?t:0}:n)),[]),E=(0,a.useCallback)(()=>{if(o)return void u(!1);u(!0),!v.length&&b&&w()},[o,v.length,b,w]);(0,a.useEffect)(()=>{let e=e=>{!e.ctrlKey||e.altKey||e.metaKey||"`"!==e.key&&"Backquote"!==e.code||(e.preventDefault(),e.stopPropagation(),E())};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[E]);let z=(0,a.useMemo)(()=>({open:o,height:h,tabs:v,active:y,enabled:b,error:g,toggle:E,setOpen:u,setHeight:e=>m(d(e)),setActive:p,openTerminal:w,openLogs:A,closeTab:N,markEnded:M}),[o,h,v,y,b,g,E,w,A,N,M]);return(0,l.jsx)(i.Provider,{value:z,children:t})}},54234:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]])},64883:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Eraser",[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]])},68449:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]])},70283:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]])},73784:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]])},75010:(e,t,n)=>{"use strict";n.d(t,{I:()=>d});var l=n(94799),a=n(34023),s=n(98392),r=n(64883),i=n(3749),o=n(69654);let c=/\u001b\[[0-9;?]*[ -/]*[@-~]/g;function d(e){let{id:t,height:n=220}=e,{t:d}=(0,o.s9)(),[u,h]=(0,a.useState)(null),m=(0,a.useRef)(""),v=(0,a.useRef)(null),k=(0,a.useRef)(!0),[y,p]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{let e=!1,n;h(null),m.current="",k.current=!0,p(!1);let l=async()=>{try{let n=m.current?"after=".concat(encodeURIComponent(m.current)):"tail=300",l=await i.FH.get("/objects/".concat(t,"/logs?").concat(n));if(e)return;m.current=l.cursor||m.current;let a=l.text.replace(c,"");h(e=>{let t=l.reset?"":null!=e?e:"";if(!a)return null!=e?e:"";let n=!t||t.endsWith("\n")||a.startsWith("\n")?t+a:"".concat(t,"\n").concat(a);return n.length>2e5?n.slice(n.length-2e5):n})}catch(e){}e||(n=setTimeout(l,1200))};return l(),()=>{e=!0,clearTimeout(n)}},[t]),(0,a.useEffect)(()=>{let e=v.current;e&&k.current&&(e.scrollTop=e.scrollHeight)},[u]),(0,l.jsxs)("div",{className:"logv",children:[(0,l.jsx)("pre",{ref:v,className:"logv-body mono",style:{height:n},onScroll:()=>{let e=v.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<24;k.current=t,p(!t)},tabIndex:0,children:null===u?d("git.loading"):u.trim()?u:d("obj.logs.empty")}),(0,l.jsxs)("div",{className:"logv-tools",children:[y&&(0,l.jsxs)("button",{className:"btn sm",onClick:()=>{let e=v.current;e&&(e.scrollTop=e.scrollHeight,k.current=!0,p(!1))},children:[(0,l.jsx)(s.A,{size:14}),d("obj.logs.bottom")]}),(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:()=>h(""),"aria-label":d("obj.logs.clear"),title:d("obj.logs.clear"),children:(0,l.jsx)(r.A,{size:14})})]})]})}},80306:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]])},84616:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]])},87968:()=>{},92605:(e,t,n)=>{Promise.resolve().then(n.bind(n,5506)),Promise.resolve().then(n.t.bind(n,39856,23)),Promise.resolve().then(n.t.bind(n,98682,23)),Promise.resolve().then(n.t.bind(n,15151,23)),Promise.resolve().then(n.t.bind(n,87968,23))},92947:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},98392:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]])},98682:e=>{e.exports={style:{fontFamily:"'Hanken Grotesk', 'Hanken Grotesk Fallback'",fontStyle:"normal"},className:"__className_67a390",variable:"__variable_67a390"}}},e=>{e.O(0,[584,597,586,839,408,89,358],()=>e(e.s=92605)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[177],{5506:(e,t,n)=>{"use strict";n.d(t,{Shell:()=>B});var l=n(94799),a=n(41463),s=n.n(a),r=n(43624),i=n(34023),o=n(84616),c=n(6261),d=n(29416),u=n(26701),h=n(74955);let m=(0,h.A)("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);var v=n(15223),k=n(54234),y=n(73784);let p=(0,h.A)("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);var b=n(68449),x=n(70283);let g=(0,h.A)("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),f=(0,h.A)("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);var j=n(48538),w=n(69654),A=n(10804);function N(){let[e,t]=(0,i.useState)(null),[n,a]=(0,i.useState)(null),s=(0,i.useRef)(null);return((0,i.useEffect)(()=>{let e,n=null,l=()=>{clearTimeout(e),n=null,t(null),a(null)},s=e=>e instanceof Element?e.closest("[title],[data-tip]"):null,r=function(a){let s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!a||a===n)return;l();let r=(e=>{var t,n;let l=e.getAttribute("title");return null!==l&&(e.removeAttribute("title"),l.trim()&&(e.dataset.tip=l,e.getAttribute("aria-label")||(null==(t=e.textContent)?void 0:t.trim())||e.setAttribute("aria-label",l))),null!=(n=e.dataset.tip)?n:""})(a);if(!r)return;n=a;let i=()=>{n===a&&a.isConnected&&t({text:r,rect:a.getBoundingClientRect()})};s?i():e=setTimeout(i,350)},i=e=>r(s(e.target)),o=e=>{n&&!(e.relatedTarget instanceof Node&&n.contains(e.relatedTarget))&&l()},c=e=>{let t=s(e.target);t&&t.matches(":focus-visible")&&r(t,!0)},d=e=>{"Escape"===e.key&&l()};return document.addEventListener("mouseover",i),document.addEventListener("mouseout",o),document.addEventListener("focusin",c),document.addEventListener("focusout",l),document.addEventListener("pointerdown",l,!0),document.addEventListener("keydown",d),window.addEventListener("scroll",l,!0),window.addEventListener("blur",l),()=>{l(),document.removeEventListener("mouseover",i),document.removeEventListener("mouseout",o),document.removeEventListener("focusin",c),document.removeEventListener("focusout",l),document.removeEventListener("pointerdown",l,!0),document.removeEventListener("keydown",d),window.removeEventListener("scroll",l,!0),window.removeEventListener("blur",l)}},[]),(0,i.useLayoutEffect)(()=>{if(!e||!s.current)return;let{width:t,height:n}=s.current.getBoundingClientRect(),l=e.rect.top-n-8<8;a({left:Math.min(Math.max(8,e.rect.left+e.rect.width/2-t/2),window.innerWidth-t-8),top:l?e.rect.bottom+8:e.rect.top-n-8,below:l})},[e]),e)?(0,l.jsx)("div",{ref:s,className:"tooltip",role:"tooltip","data-live":!0,"data-below":(null==n?void 0:n.below)?"1":void 0,style:n?{left:n.left,top:n.top}:{left:0,top:0,visibility:"hidden"},children:e.text}):null}var M=n(42162),E=n(19431),z=n(70665),C=n(92947),S=n(80306),L=n(12349),H=n(75010);n(21169);var _=n(69538);let T=(e,t)=>getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t,F=()=>({background:T("--bg-deep","#0c1411"),foreground:T("--ink","#e7eee9"),cursor:T("--honey","#e8a317"),cursorAccent:T("--bg-deep","#0c1411"),selectionBackground:"rgba(232,163,23,.35)"});function P(e){let{id:t,visible:a,onEnded:s}=e,{t:r}=(0,w.s9)(),o=(0,i.useRef)(null),c=(0,i.useRef)(null),d=(0,i.useRef)(a);return d.current=a,(0,i.useEffect)(()=>{let e=!1,l=null,a,i=!1,u=0,h=null,m=null,v=null,k=null,y=e=>{(null==l?void 0:l.readyState)===WebSocket.OPEN&&l.send(JSON.stringify(e))},p=()=>{var e;if(h&&m&&(null==(e=o.current)?void 0:e.offsetParent))try{m.fit(),y({t:"resize",cols:h.cols,rows:h.rows})}catch(e){}};return(async()=>{let[{Terminal:b},{FitAddon:x},{WebLinksAddon:g}]=await Promise.all([n.e(209).then(n.bind(n,75657)),n.e(97).then(n.bind(n,57097)),n.e(545).then(n.bind(n,90545))]);if(e||!o.current)return;h=new b({fontFamily:T("--font-mono","ui-monospace, monospace"),fontSize:13,lineHeight:1.15,cursorBlink:!0,scrollback:5e3,theme:F(),allowProposedApi:!1}),m=new x,h.loadAddon(m),h.loadAddon(new g),h.open(o.current),c.current={fit:p,focus:()=>null==h?void 0:h.focus()},d.current&&(p(),h.focus()),h.onData(e=>y({t:"in",d:e}));let f=()=>{var e;let t=null==h?void 0:h.getSelection();return t&&(null==(e=navigator.clipboard)||e.writeText(t).catch(()=>{})),!!t};h.onSelectionChange(()=>{f()}),h.attachCustomKeyEventHandler(e=>"keydown"!==e.type||!e.ctrlKey||!!e.altKey||!!e.metaKey||!("c"===e.key.toLowerCase()&&(e.shiftKey||(null==h?void 0:h.hasSelection())))||(f(),!1)),(v=new ResizeObserver(p)).observe(o.current),(k=new MutationObserver(()=>{h&&(h.options.theme=F())})).observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});let j=()=>{var n;(l=new WebSocket("".concat("ws://".concat(location.hostname,":").concat(null!=(n=_.env.NEXT_PUBLIC_HIVE_WS_PORT)?n:4400,"/ws/terminal"),"?id=").concat(encodeURIComponent(t)))).onopen=()=>{u=0},l.onmessage=e=>{let t=JSON.parse(e.data);"init"===t.t?(h.reset(),p()):"out"===t.t?h.write(t.d):"exit"===t.t?(i=!0,h.write("\r\n\x1b[2m[".concat(r("dock.ended",{code:t.code}),"]\x1b[0m\r\n")),s(t.code)):"gone"===t.t&&(i=!0,h.write("\r\n\x1b[2m[".concat(r("dock.gone"),"]\x1b[0m\r\n")),s(null))},l.onclose=()=>{e||i||(a=setTimeout(j,Math.min(5e3,600*2**u++)))}};j()})(),()=>{e=!0,clearTimeout(a),null==v||v.disconnect(),null==k||k.disconnect(),null==l||l.close(),null==h||h.dispose(),c.current=null}},[t]),(0,i.useEffect)(()=>{if(a){let e=setTimeout(()=>{var e,t;null==(e=c.current)||e.fit(),null==(t=c.current)||t.focus()},30);return()=>clearTimeout(e)}},[a]),(0,l.jsx)("div",{className:"xterm-box",ref:o})}let R=e=>"dock-tab-".concat(e);function q(){var e;let{t}=(0,w.s9)(),n=(0,M.n)(),[a,s]=(0,i.useState)(null),r=(0,i.useRef)(null);(0,i.useEffect)(()=>{let e=e=>{r.current&&n.setHeight(r.current.h+(r.current.y-e.clientY))},t=()=>{r.current=null,document.body.style.userSelect=""};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)}},[n]);let o=n.tabs.some(e=>e.key===n.active),c=null==(e=[...n.tabs].reverse().find(e=>"term"===e.kind))?void 0:e.cwd;return(0,l.jsxs)("section",{className:"dock",style:{height:n.height,display:n.open?void 0:"none"},"aria-hidden":!n.open,"aria-label":t("dock.title"),children:[(0,l.jsx)("div",{className:"dock-grip",onPointerDown:e=>{r.current={y:e.clientY,h:n.height},document.body.style.userSelect="none",e.preventDefault()},role:"separator","aria-orientation":"horizontal"}),(0,l.jsxs)("div",{className:"dock-bar",children:[(0,l.jsx)("div",{className:"dock-tabs",role:"tablist","aria-label":t("dock.title"),onKeyDown:e=>{var t;let l=n.tabs.map(e=>e.key),a=l.indexOf(null!=(t=n.active)?t:""),s=null;if("ArrowRight"===e.key)s=(a+1)%l.length;else if("ArrowLeft"===e.key)s=(a-1+l.length)%l.length;else if("Home"===e.key)s=0;else if("End"===e.key)s=l.length-1;else if("Delete"===e.key&&a>=0){e.preventDefault(),n.closeTab(l[a]);return}null!==s&&l.length&&(e.preventDefault(),n.setActive(l[s]),requestAnimationFrame(()=>{var e;return null==(e=document.getElementById(R(l[s])))?void 0:e.focus()}))},children:n.tabs.map(e=>{var a;let s=n.active===e.key,r=R(e.key);return(0,l.jsxs)("div",{className:"dock-tabwrap ".concat(s?"on":""),children:[(0,l.jsxs)("button",{id:r,type:"button",role:"tab","aria-selected":s,"aria-controls":"".concat(r,"-panel"),tabIndex:s||!o&&e===n.tabs[0]?0:-1,className:"dock-tab-btn",onClick:()=>n.setActive(e.key),title:"term"===e.kind?e.cwd:t("obj.logs"),children:["term"===e.kind?(0,l.jsx)(x.A,{size:14}):(0,l.jsx)(E.A,{size:14}),(0,l.jsx)("span",{className:"nm",children:e.title}),"term"===e.kind&&void 0!==e.ended&&(0,l.jsx)("i",{className:"odot off",title:t("dock.ended",{code:null!=(a=e.ended)?a:""})})]}),(0,l.jsx)("button",{type:"button",className:"dock-x",tabIndex:-1,onClick:()=>n.closeTab(e.key),"aria-label":"".concat(t("common.close"),": ").concat(e.title),children:(0,l.jsx)(z.A,{size:12})})]},e.key)})}),n.enabled&&(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:()=>void n.openTerminal(c?{cwd:c}:{}),"aria-label":t("dock.new"),title:t("dock.new"),children:(0,l.jsx)(C.A,{size:15})}),n.enabled&&(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:()=>s(null!=c?c:""),"aria-label":t("dock.inFolder"),title:t("dock.inFolder"),children:(0,l.jsx)(S.A,{size:15})}),(0,l.jsx)("span",{className:"grow"}),(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:()=>n.setOpen(!1),"aria-label":t("dock.hide"),title:"".concat(t("dock.hide")," (Ctrl+`)"),children:(0,l.jsx)(L.A,{size:15})})]}),(0,l.jsxs)("div",{className:"dock-body",children:[n.error&&(0,l.jsx)("p",{className:"gx-note err gx-hint-row",role:"alert",children:n.error}),!n.enabled&&!n.tabs.length&&(0,l.jsx)("p",{className:"gx-note",children:t("dock.disabled")}),n.enabled&&!n.tabs.length&&!n.error&&(0,l.jsx)("p",{className:"gx-note",children:t("dock.empty")}),n.tabs.map(e=>(0,l.jsx)("div",{id:"".concat(R(e.key),"-panel"),role:"tabpanel","aria-labelledby":R(e.key),className:"dock-pane",hidden:n.active!==e.key,children:"term"===e.kind?(0,l.jsx)(P,{id:e.id,visible:n.open&&n.active===e.key,onEnded:t=>n.markEnded(e.key,t)}):n.open&&(0,l.jsx)("div",{className:"dock-logpane",children:(0,l.jsx)(H.I,{id:e.objectId,height:"100%"})})},e.key))]}),null!==a&&(0,l.jsxs)(A.aF,{title:t("dock.inFolder"),onClose:()=>s(null),children:[(0,l.jsx)(A.dR,{value:a,onChange:s,label:t("obj.f.folder"),hint:t("dock.folder.hint")}),(0,l.jsxs)("div",{className:"row confirm-actions",children:[(0,l.jsx)("button",{className:"btn ghost",onClick:()=>s(null),children:t("common.cancel")}),(0,l.jsx)("button",{className:"btn primary",disabled:!a.startsWith("/"),onClick:()=>{s(null),n.openTerminal({cwd:a})},children:t("dock.open")})]})]})]})}function O(){return(0,l.jsx)("img",{src:"/icon.png",width:34,height:34,alt:"","aria-hidden":!0,className:"brand-mark"})}function V(){let{locale:e,setLocale:t,t:n}=(0,w.s9)();return(0,l.jsxs)("div",{className:"lang-row",role:"group","aria-label":n("lang.label"),children:[(0,l.jsx)(o.A,{size:15,"aria-hidden":!0}),(0,l.jsx)("div",{className:"seg",children:w.YZ.map(n=>(0,l.jsx)("button",{type:"button","aria-pressed":e===n.id,lang:n.id,title:n.name,"aria-label":n.name,onClick:()=>t(n.id),children:n.short},n.id))})]})}function I(){let e=(0,r.usePathname)(),{t}=(0,w.s9)(),{agents:n,types:a,skills:o,connections:h,objects:A,connected:N}=(0,j.o0)(),E=(0,M.n)(),[z,C]=(0,i.useState)(!1);(0,i.useEffect)(()=>{let e=document.documentElement,t=()=>C("dark"===e.dataset.theme);t();let n=new MutationObserver(t);return n.observe(e,{attributes:!0,attributeFilter:["data-theme"]}),()=>n.disconnect()},[]);let S=n.filter(e=>"running"===e.status).length,L=(t,n,a,r)=>{let i="/"===t?"/"===e:e.startsWith(t);return(0,l.jsxs)(s(),{href:t,className:"nav","aria-current":i?"page":void 0,children:[a,(0,l.jsx)("span",{className:"t",children:n}),void 0!==r&&(0,l.jsx)("span",{className:"count",children:r})]},t)};return(0,l.jsxs)("nav",{className:"rail","aria-label":t("nav.main"),children:[(0,l.jsxs)("div",{className:"brand",children:[(0,l.jsx)(O,{}),(0,l.jsxs)("div",{children:["hive-am",(0,l.jsx)("small",{children:t("app.tagline")})]})]}),(0,l.jsx)(V,{}),L("/",t("nav.colony"),(0,l.jsx)(c.A,{size:18}),S||void 0),L("/resources",t("nav.objects"),(0,l.jsx)(d.A,{size:18}),A.length||void 0),L("/agents",t("nav.agents"),(0,l.jsx)(u.A,{size:18}),n.length),L("/relations",t("nav.relations"),(0,l.jsx)(m,{size:18})),L("/connections",t("nav.connections"),(0,l.jsx)(v.A,{size:18}),h.length||void 0),L("/schedules",t("nav.schedules"),(0,l.jsx)(k.A,{size:18})),(0,l.jsx)("div",{className:"nav-label",children:t("nav.library")}),L("/types",t("nav.types"),(0,l.jsx)(y.A,{size:18}),a.length),L("/skills",t("nav.skills"),(0,l.jsx)(p,{size:18}),o.length),(0,l.jsx)("div",{className:"nav-label",children:t("nav.history")}),L("/sessions",t("nav.sessions"),(0,l.jsx)(b.A,{size:18})),(0,l.jsxs)("div",{className:"rail-foot",children:[(0,l.jsxs)("button",{type:"button",className:"nav",onClick:E.toggle,"aria-pressed":E.open,title:"".concat(t("dock.nav")," (Ctrl+`)"),children:[(0,l.jsx)(x.A,{size:18}),(0,l.jsx)("span",{className:"t",children:t("dock.nav")}),E.tabs.length>0&&(0,l.jsx)("span",{className:"count",children:E.tabs.length})]}),(0,l.jsxs)("div",{className:"conn",children:[(0,l.jsx)("i",{className:"dot ".concat(N?"ok":"err")}),t(N?"nav.connected":"nav.offline")]}),(0,l.jsxs)("button",{type:"button",className:"nav",onClick:()=>{let e=z?"light":"dark";document.documentElement.dataset.theme=e;try{localStorage.setItem("hive-theme",e)}catch(e){}},"aria-pressed":z,children:[z?(0,l.jsx)(g,{size:18}):(0,l.jsx)(f,{size:18}),(0,l.jsx)("span",{className:"t",children:t("nav.switchTheme")})]})]})]})}function B(e){let{children:t}=e;return(0,l.jsx)(w.CY,{children:(0,l.jsx)(j.Of,{children:(0,l.jsx)(M.$,{children:(0,l.jsxs)(A.l$,{children:[(0,l.jsx)(N,{}),(0,l.jsxs)("div",{className:"shell",children:[(0,l.jsx)(I,{}),(0,l.jsx)("main",{className:"main",children:t})]}),(0,l.jsx)(q,{})]})})})})}},6261:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Hexagon",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]])},15151:e=>{e.exports={style:{fontFamily:"'JetBrains Mono', 'JetBrains Mono Fallback'",fontStyle:"normal"},className:"__className_4dc837",variable:"__variable_4dc837"}},15223:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]])},19431:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]])},21169:()=>{},26701:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]])},29416:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]])},39856:e=>{e.exports={style:{fontFamily:"'Bricolage Grotesque', 'Bricolage Grotesque Fallback'",fontStyle:"normal"},className:"__className_23d1a5",variable:"__variable_23d1a5"}},42162:(e,t,n)=>{"use strict";n.d(t,{$:()=>u,n:()=>o});var l=n(94799),a=n(34023),s=n(3749),r=n(69654);let i=(0,a.createContext)(null),o=()=>{let e=(0,a.useContext)(i);if(!e)throw Error("DockProvider missing");return e},c="hive-am.dock",d=e=>Math.max(140,Math.min(e,Math.round(.8*window.innerHeight)));function u(e){let{children:t}=e,{t:n}=(0,r.s9)(),[o,u]=(0,a.useState)(!1),[h,m]=(0,a.useState)(320),[v,k]=(0,a.useState)([]),[y,p]=(0,a.useState)(null),[b,x]=(0,a.useState)(!0),[g,f]=(0,a.useState)(""),j=(0,a.useRef)(!1);(0,a.useEffect)(()=>{try{var e;let t=JSON.parse(null!=(e=localStorage.getItem(c))?e:"{}");"number"==typeof t.height&&m(d(t.height)),t.open&&u(!0),"string"==typeof t.active&&p(t.active)}catch(e){}s.FH.get("/terminals").then(e=>{x(e.enabled),k(t=>[...e.terminals.map(e=>({key:"t:".concat(e.id),kind:"term",id:e.id,title:e.title,cwd:e.cwd,ended:e.alive?void 0:e.exitCode})),...t.filter(e=>"logs"===e.kind)]),p(t=>t&&e.terminals.some(e=>"t:".concat(e.id)===t)?t:e.terminals[0]?"t:".concat(e.terminals[0].id):t)}).catch(()=>void 0).finally(()=>{j.current=!0})},[]),(0,a.useEffect)(()=>{if(j.current)try{localStorage.setItem(c,JSON.stringify({open:o,height:h,active:y}))}catch(e){}},[o,h,y]),(0,a.useEffect)(()=>{document.documentElement.style.setProperty("--app-h",o?"calc(100vh - ".concat(h,"px)"):"100vh")},[o,h]);let w=(0,a.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};f("");try{let t=await s.FH.post("/terminals",e),n={key:"t:".concat(t.id),kind:"term",id:t.id,title:t.title,cwd:t.cwd};k(e=>[...e,n]),p(n.key),u(!0)}catch(e){f(e instanceof Error?e.message:n("dock.failed")),u(!0)}},[n]),A=(0,a.useCallback)((e,t)=>{let n="l:".concat(e);k(l=>l.some(e=>e.key===n)?l:[...l,{key:n,kind:"logs",objectId:e,title:t}]),p(n),u(!0)},[]),N=(0,a.useCallback)(e=>{k(t=>{let n=t.find(t=>t.key===e);(null==n?void 0:n.kind)==="term"&&s.FH.del("/terminals/".concat(n.id)).catch(()=>void 0);let l=t.filter(t=>t.key!==e);return p(t=>{var n,a;return t===e?null!=(a=null==(n=l[l.length-1])?void 0:n.key)?a:null:t}),l})},[]),M=(0,a.useCallback)((e,t)=>k(n=>n.map(n=>n.key===e&&"term"===n.kind?{...n,ended:null!=t?t:0}:n)),[]),E=(0,a.useCallback)(()=>{if(o)return void u(!1);u(!0),!v.length&&b&&w()},[o,v.length,b,w]);(0,a.useEffect)(()=>{let e=e=>{!e.ctrlKey||e.altKey||e.metaKey||"`"!==e.key&&"Backquote"!==e.code||(e.preventDefault(),e.stopPropagation(),E())};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[E]);let z=(0,a.useMemo)(()=>({open:o,height:h,tabs:v,active:y,enabled:b,error:g,toggle:E,setOpen:u,setHeight:e=>m(d(e)),setActive:p,openTerminal:w,openLogs:A,closeTab:N,markEnded:M}),[o,h,v,y,b,g,E,w,A,N,M]);return(0,l.jsx)(i.Provider,{value:z,children:t})}},54234:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]])},64883:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Eraser",[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]])},68449:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]])},70283:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]])},73784:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]])},75010:(e,t,n)=>{"use strict";n.d(t,{I:()=>d});var l=n(94799),a=n(34023),s=n(98392),r=n(64883),i=n(3749),o=n(69654);let c=/\u001b\[[0-9;?]*[ -/]*[@-~]/g;function d(e){let{id:t,height:n=220}=e,{t:d}=(0,o.s9)(),[u,h]=(0,a.useState)(null),m=(0,a.useRef)(""),v=(0,a.useRef)(null),k=(0,a.useRef)(!0),[y,p]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{let e=!1,n;h(null),m.current="",k.current=!0,p(!1);let l=async()=>{try{let n=m.current?"after=".concat(encodeURIComponent(m.current)):"tail=300",l=await i.FH.get("/objects/".concat(t,"/logs?").concat(n));if(e)return;m.current=l.cursor||m.current;let a=l.text.replace(c,"");h(e=>{let t=l.reset?"":null!=e?e:"";if(!a)return null!=e?e:"";let n=!t||t.endsWith("\n")||a.startsWith("\n")?t+a:"".concat(t,"\n").concat(a);return n.length>2e5?n.slice(n.length-2e5):n})}catch(e){}e||(n=setTimeout(l,1200))};return l(),()=>{e=!0,clearTimeout(n)}},[t]),(0,a.useEffect)(()=>{let e=v.current;e&&k.current&&(e.scrollTop=e.scrollHeight)},[u]),(0,l.jsxs)("div",{className:"logv",children:[(0,l.jsx)("pre",{ref:v,className:"logv-body mono",style:{height:n},onScroll:()=>{let e=v.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<24;k.current=t,p(!t)},tabIndex:0,children:null===u?d("git.loading"):u.trim()?u:d("obj.logs.empty")}),(0,l.jsxs)("div",{className:"logv-tools",children:[y&&(0,l.jsxs)("button",{className:"btn sm",onClick:()=>{let e=v.current;e&&(e.scrollTop=e.scrollHeight,k.current=!0,p(!1))},children:[(0,l.jsx)(s.A,{size:14}),d("obj.logs.bottom")]}),(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:()=>h(""),"aria-label":d("obj.logs.clear"),title:d("obj.logs.clear"),children:(0,l.jsx)(r.A,{size:14})})]})]})}},80306:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]])},84616:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]])},87968:()=>{},92605:(e,t,n)=>{Promise.resolve().then(n.bind(n,5506)),Promise.resolve().then(n.t.bind(n,39856,23)),Promise.resolve().then(n.t.bind(n,98682,23)),Promise.resolve().then(n.t.bind(n,15151,23)),Promise.resolve().then(n.t.bind(n,87968,23))},92947:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},98392:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});let l=(0,n(74955).A)("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]])},98682:e=>{e.exports={style:{fontFamily:"'Hanken Grotesk', 'Hanken Grotesk Fallback'",fontStyle:"normal"},className:"__className_67a390",variable:"__variable_67a390"}}},e=>{e.O(0,[584,597,586,281,408,89,358],()=>e(e.s=92605)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{2432:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]])},3414:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},6261:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("Hexagon",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]])},6673:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]])},7991:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]])},26701:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]])},29416:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]])},32098:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]])},32335:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("LockOpen",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]])},33691:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]])},34265:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},34978:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("Container",[["path",{d:"M22 7.7c0-.6-.4-1.2-.8-1.5l-6.3-3.9a1.72 1.72 0 0 0-1.7 0l-10.3 6c-.5.2-.9.8-.9 1.4v6.6c0 .5.4 1.2.8 1.5l6.3 3.9a1.72 1.72 0 0 0 1.7 0l10.3-6c.5-.3.9-1 .9-1.5Z",key:"1t2lqe"}],["path",{d:"M10 21.9V14L2.1 9.1",key:"o7czzq"}],["path",{d:"m10 14 11.9-6.9",key:"zm5e20"}],["path",{d:"M14 19.8v-8.1",key:"159ecu"}],["path",{d:"M18 17.5V9.4",key:"11uown"}]])},36098:(e,t,l)=>{"use strict";l.r(t),l.d(t,{default:()=>Z});var n=l(94799),s=l(41463),o=l.n(s),a=l(34023),i=l(92947),c=l(6261),r=l(77841),d=l(73784),h=l(75406),m=l(71529),y=l(14910),u=l(32098),x=l(70665);let p=(0,l(74955).A)("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);var g=l(97356),k=l(48538),j=l(77021),f=l(3749),v=l(47890),b=l(86606),w=l(41435),N=l(1517),C=l(12646),A=l(73506),M=l(22214),_=l(69654);let z=v.hg,L=["cwd","permission","skills","prompt"];function S(e){let{colony:t,onClose:l}=e,{t:s}=(0,_.s9)(),{agents:o,skills:i,colonies:c,refresh:r}=(0,k.q5)(),d=(0,b.dj)(),[h,m]=(0,a.useState)(()=>t?{name:t.name,color:t.color,cwd:t.cwd,permission:t.permission,system_prompt:t.system_prompt,skill_ids:t.skill_ids,skill_loads:t.skill_loads,agent_ids:t.agent_ids,inherit:t.inherit}:{name:"",color:z[c.length%z.length],cwd:"",permission:"acceptEdits",system_prompt:"",skill_ids:[],skill_loads:{},agent_ids:[],inherit:{cwd:!0,permission:!0,skills:!0,prompt:!0}}),y=(0,a.useMemo)(()=>JSON.stringify(h),[]),u=JSON.stringify(h)!==y;(0,A.h)(u);let[x,p]=(0,a.useState)(!1),j=()=>{u?p(!0):l()},[v,w]=(0,a.useState)(""),[N,L]=(0,a.useState)(!1),[S,F]=(0,a.useState)(!1),[D,E]=(0,a.useState)(!1),H=(e,t)=>m(l=>({...l,[e]:t})),T=async e=>{E(!0);try{let n={...h,name:h.name.trim(),color:h.color.toLowerCase(),inherit:e};t?await f.FH.patch("/colonies/".concat(t.id),n):await f.FH.post("/colonies",n),await r(["agents","colonies"]),d(t?s("colony.saved"):s("colony.created")),l()}catch(e){L(!1),w(e instanceof Error?e.message:s("edit.saveFailed")),E(!1)}};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(b._s,{title:t?s("colony.editTitle",{name:t.name}):s("colony.newTitle"),subtitle:s("colony.subtitle"),onClose:j,footer:(0,n.jsxs)(n.Fragment,{children:[t&&(0,n.jsxs)("button",{className:"btn danger push-r",onClick:()=>F(!0),children:[(0,n.jsx)(g.A,{size:15}),s("common.delete")]}),(0,n.jsx)("button",{className:"btn ghost",onClick:j,children:s("common.cancel")}),(0,n.jsx)("button",{className:"btn primary",onClick:()=>h.name.trim()?c.some(e=>e.id!==(null==t?void 0:t.id)&&e.name.toLowerCase()===h.name.trim().toLowerCase())?void w(s("colony.err.nameTaken")):/^#[0-9a-f]{6}$/i.test(h.color)?void(w(""),L(!0)):void w(s("colony.err.color")):void w(s("colony.err.name")),children:t?s("colony.save"):s("colony.create")})]}),children:[(0,n.jsx)(b.D0,{label:s("form.name"),error:v,children:(0,n.jsx)("input",{className:"input",value:h.name,onChange:e=>H("name",e.target.value),placeholder:s("colony.name.placeholder"),"data-autofocus":!0})}),(0,n.jsx)(b.D0,{label:s("colony.color"),children:(0,n.jsxs)("div",{className:"swatches",children:[z.map(e=>(0,n.jsx)("button",{type:"button",className:"swatch",style:{"--c":e},"aria-pressed":h.color.toLowerCase()===e,"aria-label":s("colony.colorOption",{color:e}),onClick:()=>H("color",e)},e)),(0,n.jsx)("label",{className:"swatch custom ".concat(z.includes(h.color.toLowerCase())?"":"on"),style:{"--c":/^#[0-9a-f]{6}$/i.test(h.color)?h.color:"transparent"},title:s("colony.colorCustom"),children:(0,n.jsx)("input",{type:"color",value:/^#[0-9a-f]{6}$/i.test(h.color)?h.color:"#2f8f5b",onChange:e=>H("color",e.target.value),"aria-label":s("colony.colorCustom")})}),(0,n.jsx)("input",{className:"input hex-input mono",value:h.color,maxLength:7,spellCheck:!1,"aria-label":s("colony.colorHex"),placeholder:"#2f8f5b",onChange:e=>{let t=e.target.value.trim();H("color",t.startsWith("#")||!t?t:"#".concat(t))}})]})}),(0,n.jsx)(b.dR,{value:h.cwd,onChange:e=>H("cwd",e)}),(0,n.jsx)(b.en,{value:h.permission,onChange:e=>H("permission",e)}),(0,n.jsx)(b.D0,{label:s("inherit.context"),hint:s("colony.context.hint"),children:(0,n.jsx)(C.n,{value:h.system_prompt,onChange:e=>H("system_prompt",e),placeholder:s("colony.context.placeholder"),defaultView:"write",minHeight:160})}),(0,n.jsx)(b.D0,{label:s("form.skills"),children:(0,n.jsx)(b.kV,{skills:i,value:h.skill_ids,loads:h.skill_loads,onChange:(e,t)=>m({...h,skill_ids:e,skill_loads:t})})}),(0,n.jsx)(b.D0,{label:s("colony.members"),hint:s("colony.members.hint"),children:0===o.length?(0,n.jsx)("p",{className:"hint",children:s("colony.members.empty")}):(0,n.jsx)(M.C,{value:h.agent_ids,onChange:e=>H("agent_ids",e),items:o.map(e=>{let l=e.colony_id&&e.colony_id!==(null==t?void 0:t.id)?c.find(t=>t.id===e.colony_id):null;return{id:e.id,name:e.name,note:l?s("colony.currentlyIn",{name:l.name}):e.description||s("role.".concat(e.role))}})})})]}),N&&(0,n.jsx)(q,{draft:h,colony:t,members:o.filter(e=>h.agent_ids.includes(e.id)),busy:D,onBack:()=>L(!1),onConfirm:T}),x&&(0,n.jsx)(b.TM,{danger:!0,title:s("fa.unsaved.title"),body:s("fa.unsaved.body"),confirmLabel:s("fa.unsaved.discard"),cancelLabel:s("fa.unsaved.keep"),onClose:()=>p(!1),onConfirm:l}),S&&t&&(0,n.jsx)(b.TM,{title:s("colony.deleteTitle",{name:t.name}),body:s("colony.deleteBody",{count:t.agent_ids.length}),danger:!0,confirmLabel:s("colony.delete"),cancelLabel:s("colony.keep"),onClose:()=>F(!1),onConfirm:async()=>{await f.FH.del("/colonies/".concat(t.id)),await r(["agents","colonies"]),d(s("colony.deleted")),l()}})]})}function q(e){let{draft:t,colony:l,members:s,busy:o,onBack:i,onConfirm:c}=e,{t:r}=(0,_.s9)(),d={cwd:!!t.cwd,permission:!0,skills:t.skill_ids.length>0,prompt:!!t.system_prompt.trim()},[h,m]=(0,a.useState)(()=>({cwd:(!l||l.inherit.cwd)&&d.cwd,permission:!l||l.inherit.permission,skills:(!l||l.inherit.skills)&&d.skills,prompt:(!l||l.inherit.prompt)&&d.prompt})),y=(0,a.useMemo)(()=>h.cwd&&t.cwd&&s.filter(e=>!e.overrides.includes("cwd")&&e.effective.cwd!==t.cwd).length,[h.cwd,t.cwd,s]);return(0,n.jsxs)(b.aF,{title:r("inheritAsk.title"),onClose:i,children:[(0,n.jsx)("p",{className:"muted small m0",children:r("inheritAsk.intro")}),(0,n.jsx)("div",{className:"col gap-s",children:L.map(e=>(0,n.jsx)(b.Tl,{disabled:!d[e],checked:h[e],onChange:t=>m(l=>({...l,[e]:t})),label:(0,n.jsxs)(n.Fragment,{children:[r("inheritAsk.field.".concat(e)),"cwd"===e&&t.cwd?(0,n.jsxs)("span",{className:"muted mono fw-400",children:[" \xb7 ",(0,v._1)(t.cwd)]}):null,"permission"===e?(0,n.jsxs)("span",{className:"muted fw-400",children:[" \xb7 ",(0,v.Ck)(t.permission)]}):null]}),hint:d[e]?r("inheritAsk.hint.".concat(e)):r("inheritAsk.empty.".concat(e))},e))}),y?(0,n.jsx)(b.lZ,{kind:"honey",children:r("inheritAsk.folderMoves",{count:Number(y)})}):null,(0,n.jsxs)("div",{className:"row push-end",children:[(0,n.jsx)("button",{className:"btn ghost",onClick:i,children:r("common.back")}),(0,n.jsx)("button",{className:"btn primary",disabled:o,onClick:()=>c(h),children:o?r("common.saving"):l?r("colony.save"):r("colony.create")})]})]})}var F=l(5300),D=l(89128);function E(e){let{agent:t,onClose:l}=e,{t:s}=(0,_.s9)(),o=(0,D.A)(t,{onSaved:l,onDeleted:l});return o.draft?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(b._s,{title:s("edit.title",{name:t.name}),subtitle:s("running"===t.status?"edit.subtitleRunning":"edit.subtitleIdle"),onClose:l,footer:o.actions({onCancel:l}),children:(0,n.jsx)(F.SU,{draft:o.draft,onChange:o.setDraft,errors:o.errors,selfId:t.id})}),o.deleteModal]}):null}var H=l(48776),T=l(42366),O=l(5372),I=l(31606),V=l(95587),R=l(74988);let W=74*Math.sqrt(3),P=[[1,0],[1,-1],[0,-1],[-1,0],[-1,1],[0,1]],B=e=>{let[t,l]=e;return{x:W*(t+l/2),y:111*l}},K=(e,t,l)=>Array.from({length:6},(n,s)=>{let o=(60*s-30)*Math.PI/180;return"".concat((e+l*Math.cos(o)).toFixed(1),",").concat((t+l*Math.sin(o)).toFixed(1))}).join(" ");function Z(){var e,t,l;let{t:s}=(0,_.s9)(),{agents:C,colonies:A,objects:M,dispatches:z,ready:L,error:q,retry:F,refresh:D}=(0,k.q5)(),Z=(0,b.dj)(),[J,U]=(0,a.useState)(null),[X,G]=(0,a.useState)(null),[Y,$]=(0,a.useState)(null),[Q,ee]=(0,a.useState)(null),[et,el]=(0,a.useState)(null),[en,es]=(0,a.useState)(null),[eo,ea]=(0,j.ud)("hive-colony-layout",{}),[ei,ec]=(0,a.useState)(null),[er,ed]=(0,j.ud)("hive-colony-zoom",1),eh=er>=.4&&er<=2.5?er:1,em=e=>ed(Math.min(2.5,Math.max(.4,Math.round(100*e)/100))),ey=(0,a.useMemo)(()=>ei?{...eo,[ei.key]:{x:ei.x,y:ei.y}}:eo,[eo,ei]),{clusters:eu,width:ex,height:ep}=(0,a.useMemo)(()=>(function(e,t,l){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},s=e=>!!e&&t.some(t=>t.id===e),o=t.map(t=>({key:t.id,colony:t,members:e.filter(e=>e.colony_id===t.id),things:l.filter(e=>e.colony_id===t.id)}));o.push({key:"free",colony:null,members:e.filter(e=>!s(e.colony_id)),things:l.filter(e=>!s(e.colony_id))});let a=[],i=0,c=0,r=0;for(let t of o){if(!t.members.length&&!t.things.length&&!t.colony&&e.length+l.length>0)continue;let s=function(e){let t=e.filter(e=>"orchestrator"===e.role);for(let l of[...t])for(let n of l.worker_ids){let l=e.find(e=>e.id===n);l&&!t.includes(l)&&t.push(l)}for(let l of e)t.includes(l)||t.push(l);return t}(t.members),o=(function(e){let t=[[0,0]];for(let l=1;t.length<e;l++){let e=P[4][0]*l,n=P[4][1]*l;for(let s=0;s<6;s++)for(let o=0;o<l;o++)t.push([e,n]),e+=P[s][0],n+=P[s][1]}return t.slice(0,e)})(s.length+t.things.length+1).map(B),d=Math.min(...o.map(e=>e.x))-W/2,h=Math.max(...o.map(e=>e.x))+W/2,m=Math.min(...o.map(e=>e.y))-74,y=Math.max(...o.map(e=>e.y))+74,u=h-d+52,x=y-m+52+50,p=t.colony?n[t.key]:void 0;!p&&i>0&&i+u>880&&(i=0,c+=r+36,r=0);let g=p?p.x:i,k=p?p.y:c,j=o.map((e,l)=>{var o,a,i;let c=null!=(a=s[l])?a:null,r=t.things[l-s.length],h=t.colony?void 0:n[null!=(i=null==(o=null!=c?c:r)?void 0:o.id)?i:""];return{agent:c,object:r,x:h?h.x:g+(e.x-d)+26,y:h?h.y:k+(e.y-m)+26+50}});a.push({key:t.key,colony:t.colony,cells:j,x:g,y:k,w:u,h:x}),p||(i+=u+36,r=Math.max(r,x))}let d=0,h=0;for(let e of a)if(e.colony)d=Math.max(d,e.x+e.w),h=Math.max(h,e.y+e.h);else for(let t of e.cells)d=Math.max(d,t.x+W/2+26),h=Math.max(h,t.y+74+26);return{clusters:a,width:d,height:h}})(C,A,M,ey),[C,A,M,ey]),eg=(0,a.useRef)(null),[ek,ej]=(0,a.useState)(0);(0,a.useEffect)(()=>{let e=eg.current;if(!e)return;let t=new ResizeObserver(()=>ej(e.clientWidth));return t.observe(e),ej(e.clientWidth),()=>t.disconnect()},[L,0===C.length]);let ef=(0,a.useRef)(eh);ef.current=eh,(0,a.useEffect)(()=>{let e=eg.current;if(!e)return;let t=e=>{(e.ctrlKey||e.metaKey)&&(e.preventDefault(),em(ef.current*(e.deltaY<0?1.1:1/1.1)))};return e.addEventListener("wheel",t,{passive:!1}),()=>e.removeEventListener("wheel",t)},[L]);let ev=ex+80,eb=ep+80,ew=(ek?Math.min(1,(ek-24)/ev):1)*eh,eN=(0,a.useRef)(null),eC=(0,a.useRef)(!1),eA=function(e,t,l,n){let s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{x:0,y:0};if(0===e.button){eN.current={key:t,sx:e.clientX,sy:e.clientY,ox:l,oy:n,min:s,moved:!1};try{e.currentTarget.setPointerCapture(e.pointerId)}catch(e){}}},eM=e=>{let t=eN.current;if(!t)return;let l=(e.clientX-t.sx)/ew,n=(e.clientY-t.sy)/ew;!t.moved&&Math.hypot(l,n)*ew<6||(t.moved=!0,t.last={x:Math.max(t.min.x,t.ox+l),y:Math.max(t.min.y,t.oy+n)},ec({key:t.key,...t.last}))},e_=()=>{let e=eN.current;eN.current=null,(null==e?void 0:e.moved)&&e.last&&(eC.current=!0,setTimeout(()=>{eC.current=!1},0),ea({...eo,[e.key]:e.last}),ec(null))},ez=function(e,t,l,n){let s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{x:0,y:0},o={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[e.key];if(!o||e.altKey||e.ctrlKey||e.metaKey)return;e.preventDefault();let a=e.shiftKey?64:16;ea({...eo,[t]:{x:Math.max(s.x,l+o[0]*a),y:Math.max(s.y,n+o[1]*a)}})},eL=(e,t,l,n)=>({onPointerDown:s=>eA(s,e,t,l,n),onPointerMove:eM,onPointerUp:e_,onPointerCancel:e_}),eS=new Map;for(let e of eu)for(let t of e.cells)t.agent&&eS.set(t.agent.id,{x:t.x+40,y:t.y+40}),t.object&&eS.set(t.object.id,{x:t.x+40,y:t.y+40});let eq=M.filter(e=>"cluster"===e.kind).flatMap(e=>e.config.members.map(t=>({from:e.id,to:t}))),eF=M.filter(e=>e.manager_id&&eS.has(e.manager_id)&&eS.has(e.id)).map(e=>({from:e.manager_id,to:e.id})),eD=e=>M.filter(t=>t.manager_id===e),[eE,eH]=(0,a.useState)(null),eT=null!=(e=C.find(e=>e.id===J))?e:null,eO=null!=(t=M.find(e=>e.id===J))?t:null,[eI,eV]=(0,a.useState)(null);(0,a.useLayoutEffect)(()=>{eV(J?document.querySelector('[data-sid="'.concat(J,'"]')):null)},[J,C.length,M.length]),(0,a.useEffect)(()=>{if(!J)return;let e=e=>{"Escape"!==e.key||document.querySelector('[role="dialog"]')||U(null)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[J]);let eR=null!=X?X:J,eW=C.filter(e=>"orchestrator"===e.role).flatMap(e=>e.worker_ids.map(t=>({from:e.id,to:t}))),eP=new Set(eR?[eR,...[...eW,...eq,...eF].filter(e=>e.from===eR||e.to===eR).flatMap(e=>[e.from,e.to])]:[]),eB=e=>C.filter(t=>"orchestrator"===t.role&&t.worker_ids.includes(e)),eK=C.filter(e=>"running"===e.status).length,eZ=M.filter(e=>"running"===e.state.status).length,eJ=C.filter(e=>"orchestrator"===e.role).length,eU=e=>{var t,l;return null!=(l=null==(t=C.find(t=>t.id===e))?void 0:t.name)?l:s("colony.removedAgent")},eX=z.filter(e=>"running"===e.status).length,eG=[{id:"agents",n:C.length,label:s("stat.agents",{count:C.length}),href:"/agents"},{id:"colonies",n:A.length,label:s("stat.colonies",{count:A.length})},{id:"objects",n:M.length,label:s("stat.objects",{count:M.length}),href:"/resources",title:M.length?s("obj.running",{count:eZ}):void 0},{id:"queens",n:eJ,label:s("stat.orchestrators",{count:eJ}),href:"/agents"},{id:"working",n:eK,label:s("stat.working"),href:"/agents"},{id:"tasks",n:eX,label:s("stat.tasks"),href:"#recent"}],eY=eT?A.find(e=>e.id===eT.colony_id):void 0,e$=async(e,t)=>{try{var l,n;await f.FH.patch("/agents/".concat(e.id),{colony_id:t||null,overrides:[]}),await D(["agents","colonies"]),Z(t?s("colony.joined",{name:e.name,colony:null!=(n=null==(l=A.find(e=>e.id===t))?void 0:l.name)?n:""}):s("colony.left",{name:e.name}))}catch(e){Z(e instanceof Error?e.message:s("colony.moveFailed"),"err")}};return(0,n.jsxs)("div",{className:"page",children:[(0,n.jsxs)("div",{className:"page-head",children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("h1",{children:s("nav.colony")}),(0,n.jsx)(T.B,{label:s("colony.helpLabel"),title:s("colony.howTitle"),children:s("colony.howBody")})]}),(0,n.jsx)("p",{children:s("colony.page.subtitle")})]}),(0,n.jsx)("div",{className:"cx-head-actions",children:(0,n.jsx)(w.W1,{label:s("cx.new"),icon:(0,n.jsx)(i.A,{size:14}),children:e=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(w.Dr,{icon:(0,n.jsx)(c.A,{size:15}),onClick:()=>{e(),$({})},children:s("newAgent.title")}),(0,n.jsx)(w.Dr,{icon:(0,n.jsx)(r.A,{size:15}),onClick:()=>{e(),ee("new")},children:s("colony.newTitle")}),(0,n.jsx)(w.Dr,{icon:(0,n.jsx)(d.A,{size:15}),onClick:()=>{e(),es({})},children:s("obj.new")})]})})})]}),(0,n.jsx)("div",{className:"stats",children:eG.map(e=>{let t=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("b",{children:e.n}),(0,n.jsx)("span",{children:e.label})]});return e.href?(0,n.jsx)(o(),{href:e.href,className:"card stat",title:e.title,"aria-label":"".concat(e.n," ").concat(e.label,". ").concat(s("cx.stat.open",{label:e.label})),children:t},e.id):(0,n.jsx)("div",{className:"card stat",title:e.title,children:t},e.id)})}),(0,n.jsxs)("div",{className:"colony",children:[(0,n.jsxs)("div",{className:"comb-wrap",ref:eg,children:[L?0===C.length&&0===A.length&&0===M.length?(0,n.jsx)("div",{className:"comb-empty-wrap",children:(0,n.jsx)(b.pp,{icon:(0,n.jsx)(b._h,{size:"lg",queen:!0,label:"+"}),title:s("colony.empty.title"),body:s("colony.empty.body"),action:(0,n.jsxs)("div",{className:"row",children:[(0,n.jsxs)("button",{className:"btn",onClick:()=>ee("new"),children:[(0,n.jsx)(i.A,{size:16}),s("colony.empty.createColony")]}),(0,n.jsxs)("button",{className:"btn primary",onClick:()=>$({}),children:[(0,n.jsx)(i.A,{size:16}),s("colony.empty.createAgent")]})]})})}):(0,n.jsx)("div",{className:"comb-box",style:{width:ev*ew,height:eb*ew},children:(0,n.jsxs)("div",{className:"comb",style:{width:ev,height:eb,transform:"scale(".concat(ew,")"),transformOrigin:"0 0","--w":"".concat(.9*W,"px"),"--h":"".concat(133.20000000000002,"px")},children:[(0,n.jsx)("svg",{className:"links",width:ev,height:eb,children:eu.filter(e=>e.colony).map(e=>{let t=e.colony.color||"var(--honey)";return(0,n.jsxs)("g",{children:[e.cells.map((e,l)=>(0,n.jsx)("polygon",{points:K(e.x+40,e.y+40,74),style:{fill:t,stroke:t},strokeWidth:44,strokeLinejoin:"round"},"o"+l)),e.cells.map((e,l)=>(0,n.jsx)("polygon",{points:K(e.x+40,e.y+40,74),style:{fill:"color-mix(in srgb, ".concat(t," 9%, var(--surface))"),stroke:"color-mix(in srgb, ".concat(t," 9%, var(--surface))")},strokeWidth:38,strokeLinejoin:"round"},"i"+l))]},e.key)})}),eu.map(e=>(0,n.jsxs)("div",{children:[e.colony?(0,n.jsxs)("button",{className:"colony-label draggable ".concat((null==ei?void 0:ei.key)===e.key?"dragging":""),style:{left:e.x+e.w/2+40,top:e.y+50-10+40,"--c":e.colony.color||"var(--honey)"},...eL(e.key,e.x,e.y),onKeyDown:t=>ez(t,e.key,e.x,e.y),onClick:()=>{eC.current||ee(e.colony)},title:"".concat(e.colony.cwd?s("colony.editHover",{path:(0,v._1)(e.colony.cwd)}):s("colony.editHoverShort")," \xb7 ").concat(s("colony.dragHint")," \xb7 ").concat(s("cx.moveHint")),children:[(0,n.jsx)("i",{className:"cdot"}),e.colony.name,(0,n.jsx)("small",{children:s("colony.agentCount",{count:e.cells.filter(e=>e.agent).length})}),(0,n.jsx)(r.A,{size:13,className:"muted"})]}):A.length>0&&e.cells.some(e=>e.agent)?(0,n.jsx)("span",{className:"colony-label cx-unplaced",style:{left:e.x+e.w/2+40,top:e.y+50-10+40},children:(0,n.jsx)("small",{children:s("common.noColony")})}):null,e.cells.map((t,l)=>{let o=t.agent,a={left:t.x+40,top:t.y+40},c=t.object;if(c){let{icon:l,color:o}=R.Nd[c.kind];return(0,n.jsxs)("button",{"data-sid":c.id,className:"cell fill obj st-".concat(c.state.status," ").concat("running"===c.state.status?"running":""," ").concat(eR&&!eP.has(c.id)?"dim":""," ").concat(eR&&eP.has(c.id)&&c.id!==eR?"linked":""," ").concat(e.colony?"":"draggable"),style:{...a,"--c":o},"aria-pressed":J===c.id,onMouseEnter:()=>G(c.id),onMouseLeave:()=>G(null),onFocus:()=>G(c.id),onBlur:()=>G(null),...e.colony?{}:{...eL(c.id,t.x,t.y,{x:W/2,y:74}),onKeyDown:e=>ez(e,c.id,t.x,t.y,{x:W/2,y:74})},onClick:()=>{eC.current||U(c.id===J?null:c.id)},"aria-label":"".concat(c.name,", ").concat(s("obj.kind.".concat(c.kind)),", ").concat(s("obj.status.".concat(c.state.status))),title:c.state.detail?"".concat(s("obj.status.".concat(c.state.status)),": ").concat(c.state.detail):s("obj.status.".concat(c.state.status)),children:[(0,n.jsx)("span",{className:"shape"}),(0,n.jsxs)("span",{className:"label",children:[(0,n.jsx)(l,{size:16}),(0,n.jsx)("b",{children:c.name}),(0,n.jsx)("small",{children:s("obj.status.".concat(c.state.status))})]}),(0,n.jsx)("span",{className:"pip o-".concat(c.state.status)}),c.manager_id&&(0,n.jsxs)("span",{className:"ltag top mgr",title:s("colony.managedBy",{name:eU(c.manager_id)}),children:["⚙ ",eU(c.manager_id)]})]},c.id)}return o?(0,n.jsxs)("button",{"data-sid":o.id,className:"cell fill ".concat("orchestrator"===o.role?"queen":""," ").concat("running"===o.status?"running":""," ").concat(eR&&!eP.has(o.id)?"dim":""," ").concat(eR&&eP.has(o.id)&&o.id!==eR?"linked":""," ").concat(e.colony?"":"draggable"),onMouseEnter:()=>G(o.id),onMouseLeave:()=>G(null),onFocus:()=>G(o.id),onBlur:()=>G(null),style:{...a,"--c":v.xq[o.provider].color},"aria-pressed":J===o.id,...e.colony?{}:{...eL(o.id,t.x,t.y,{x:W/2,y:74}),onKeyDown:e=>ez(e,o.id,t.x,t.y,{x:W/2,y:74}),title:s("cx.moveHint")},onClick:()=>{eC.current||U(o.id===J?null:o.id)},"aria-label":"".concat(o.name,", ").concat(s("role.".concat(o.role)),", ").concat(v.xq[o.provider].short,", ").concat(s("status.".concat(o.status))),children:[(0,n.jsx)("span",{className:"shape"}),(0,n.jsxs)("span",{className:"label",children:[(0,n.jsx)("b",{children:o.name}),(0,n.jsx)("small",{children:v.xq[o.provider].short})]}),"idle"!==o.status&&(0,n.jsx)("span",{className:"pip ".concat("error"===o.status?"err":"")}),eD(o.id).length>0&&(0,n.jsxs)("span",{className:"ltag top mgr",title:s("colony.manages",{names:eD(o.id).map(e=>e.name).join(", ")}),children:["⚙ ",1===eD(o.id).length?eD(o.id)[0].name:eD(o.id).length]}),("orchestrator"===o.role?o.worker_ids.length>0:eB(o.id).length>0)&&(0,n.jsx)("span",{className:"ltag",title:"orchestrator"===o.role?s("colony.delegatesTo",{count:o.worker_ids.length}):s("colony.connectedTo",{names:eB(o.id).map(e=>e.name).join(", ")}),children:"orchestrator"===o.role?"↓ ".concat(o.worker_ids.length):"↑ ".concat(1===eB(o.id).length?eB(o.id)[0].name:eB(o.id).length)})]},o.id):(0,n.jsxs)("button",{className:"cell ghost",style:a,onClick:()=>{var t;return $({colonyId:null==(t=e.colony)?void 0:t.id})},"aria-label":e.colony?s("colony.addTo",{name:e.colony.name}):s("colony.addAgent"),children:[(0,n.jsx)("svg",{className:"ghost-hex",viewBox:"0 0 100 115",preserveAspectRatio:"none","aria-hidden":!0,children:(0,n.jsx)("polygon",{points:"50,2 98,29 98,86 50,113 2,86 2,29"})}),(0,n.jsxs)("span",{className:"label",children:[(0,n.jsx)(i.A,{size:18}),s("colony.addAgent")]})]},e.key+"g"+l)})]},e.key+"l")),(0,n.jsxs)("svg",{className:"links top",width:ev,height:eb,"aria-hidden":!0,children:[eW.filter(e=>!!eR&&(e.from===eR||e.to===eR)).map(e=>{var t;let l=eS.get(e.from),s=eS.get(e.to);if(!l||!s)return null;let o=s.x-l.x,a=s.y-l.y,i=Math.hypot(o,a)||1,c=o/i,r=a/i,d=l.x+45.88*c,h=l.y+45.88*r,m=s.x-45.88*c,y=s.y-45.88*r,u=(null==(t=C.find(t=>t.id===e.to))?void 0:t.status)==="running",x=!!eR&&(e.from===eR||e.to===eR),p=!!eR&&!x;return(0,n.jsxs)("g",{opacity:p?.18:1,children:[(0,n.jsx)("line",{x1:d,y1:h,x2:m,y2:y,stroke:"var(--surface)",strokeWidth:x?8:5,strokeLinecap:"round",opacity:.85}),(0,n.jsx)("line",{x1:d,y1:h,x2:m,y2:y,stroke:"var(--honey)",strokeWidth:x?3.5:2.2,strokeDasharray:u?"7 6":x?void 0:"1 6",strokeLinecap:"round",children:u&&(0,n.jsx)("animate",{attributeName:"stroke-dashoffset",from:"26",to:"0",dur:"0.8s",repeatCount:"indefinite"})}),(0,n.jsx)("circle",{cx:m,cy:y,r:x?5.5:4,fill:"var(--honey)",stroke:"var(--surface)",strokeWidth:2})]},e.from+e.to)}),[...eq.map(e=>({...e,kind:"cluster"})),...eF.map(e=>({...e,kind:"manager"}))].filter(e=>!!eR&&(e.from===eR||e.to===eR)).map(e=>{let t=eS.get(e.from),l=eS.get(e.to);if(!t||!l)return null;let s=l.x-t.x,o=l.y-t.y,a=Math.hypot(s,o)||1,i=s/a,c=o/a,r="cluster"===e.kind?v.Ng:"var(--link-manager)";return(0,n.jsxs)("g",{children:[(0,n.jsx)("line",{x1:t.x+45.88*i,y1:t.y+45.88*c,x2:l.x-45.88*i,y2:l.y-45.88*c,stroke:"var(--surface)",strokeWidth:8,strokeLinecap:"round",opacity:.9}),(0,n.jsx)("line",{x1:t.x+45.88*i,y1:t.y+45.88*c,x2:l.x-45.88*i,y2:l.y-45.88*c,stroke:r,strokeWidth:3,strokeDasharray:"cluster"===e.kind?"3 5":"8 5",strokeLinecap:"round"}),(0,n.jsx)("circle",{cx:l.x-45.88*i,cy:l.y-45.88*c,r:5,fill:r,stroke:"var(--surface)",strokeWidth:2})]},e.kind+e.from+e.to)})]})]})}):q?(0,n.jsx)("div",{className:"comb-skel",children:(0,n.jsx)(b.lZ,{kind:"err",children:(0,n.jsxs)("div",{className:"row gap-s wrap",children:[(0,n.jsxs)("span",{className:"grow",children:[s("cx.loadFailed")," ",q]}),(0,n.jsx)("button",{className:"btn sm",onClick:()=>void F(),children:s("cx.retry")})]})})}):(0,n.jsxs)("div",{className:"comb-skel",role:"status","aria-label":s("cx.loading"),children:[(0,n.jsx)("div",{className:"skel",style:{width:220,height:190}}),(0,n.jsxs)("div",{className:"row gap-l",children:[(0,n.jsx)("div",{className:"skel",style:{width:150,height:130}}),(0,n.jsx)("div",{className:"skel",style:{width:150,height:130}})]})]}),(0,n.jsxs)("div",{className:"comb-zoom",role:"group","aria-label":s("colony.zoom"),children:[Object.keys(eo).length>0&&(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>ea({}),title:s("colony.layout.reset"),"aria-label":s("colony.layout.reset"),children:(0,n.jsx)(h.A,{size:14})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>em(eh/1.2),disabled:eh<=.4,title:s("colony.zoom.out"),"aria-label":s("colony.zoom.out"),children:(0,n.jsx)(m.A,{size:14})}),(0,n.jsxs)("button",{className:"btn ghost sm zoom-pct",onClick:()=>em(1),title:s("colony.zoom.fit"),"aria-label":s("colony.zoom.fit"),children:[Math.round(100*eh),"%"]}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>em(1.2*eh),disabled:eh>=2.5,title:s("colony.zoom.in"),"aria-label":s("colony.zoom.in"),children:(0,n.jsx)(i.A,{size:14})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>em(1),title:s("colony.zoom.fit"),"aria-label":s("colony.zoom.fit"),children:(0,n.jsx)(y.A,{size:14})})]}),(0,n.jsxs)("div",{className:"comb-legend",children:[Object.keys(v.xq).map(e=>(0,n.jsxs)("span",{className:"pbadge",style:{"--c":v.xq[e].color},children:[(0,n.jsx)("i",{}),v.xq[e].short]},e)),(0,n.jsxs)("span",{className:"pbadge",style:{"--c":"var(--honey)"},children:[(0,n.jsx)("i",{}),s("role.orchestrator")]})]})]}),eO?(0,n.jsx)(I.wl,{object:eO,target:eI,onClose:()=>U(null),onCreateManager:()=>{var e;return $({colonyId:null!=(e=eO.colony_id)?e:void 0,manager:!0,objectId:eO.id})}},eO.id):eT?(0,n.jsxs)(O.rs,{target:eI,pinned:!0,width:340,label:eT.name,onClose:()=>U(null),children:[(0,n.jsxs)("div",{className:"ap-corner row gap-s",children:[(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>el(eT.id),"aria-label":s("colony.settingsFor",{name:eT.name}),title:s("colony.agentSettings"),children:(0,n.jsx)(u.A,{size:16})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>U(null),"aria-label":s("common.close"),title:"".concat(s("common.close")," (Esc)"),children:(0,n.jsx)(x.A,{size:16})})]}),(0,n.jsx)(O.kh,{agent:eT,hideColony:!0}),(0,n.jsxs)("div",{className:"field ap-pin-field",children:[(0,n.jsx)("label",{children:s("form.colony")}),(0,n.jsxs)("select",{className:"select",value:null!=(l=null==eY?void 0:eY.id)?l:"",onChange:e=>void e$(eT,e.target.value),children:[(0,n.jsx)("option",{value:"",children:s("common.noColony")}),A.map(e=>(0,n.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),(0,n.jsxs)("div",{className:"row ap-pin-actions",children:[(0,n.jsxs)(o(),{className:"btn primary grow",href:"/agents/".concat(eT.id),children:[s("colony.openChat")," ",(0,n.jsx)(p,{size:16})]}),(0,n.jsx)("button",{className:"btn danger icon",onClick:()=>eH(eT.id),"aria-label":s("agent.delete"),title:s("agent.delete"),children:(0,n.jsx)(g.A,{size:16})})]})]},eT.id):null]}),(0,n.jsxs)("div",{className:"card card-pad recent",id:"recent",children:[(0,n.jsx)("div",{className:"eyebrow recent-head",children:s("colony.recent")}),0===z.length?(0,n.jsx)("p",{className:"muted small m0",children:s("colony.recentEmpty")}):(0,n.jsx)("div",{className:"recent-grid",children:z.slice(0,6).map(e=>(0,n.jsxs)("div",{className:"feed-item",children:[(0,n.jsx)("i",{className:"dot ".concat("running"===e.status?"run":"done"===e.status?"ok":"err")}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"feed-line",children:[C.some(t=>t.id===e.from_id)?(0,n.jsx)(o(),{href:"/agents/".concat(e.from_id),"aria-label":s("cx.openAgent",{name:eU(e.from_id)}),children:eU(e.from_id)}):(0,n.jsx)("b",{children:eU(e.from_id)})," → ",C.some(t=>t.id===e.to_id)?(0,n.jsx)(o(),{href:"/agents/".concat(e.to_id),"aria-label":s("cx.openAgent",{name:eU(e.to_id)}),children:eU(e.to_id)}):(0,n.jsx)("b",{children:eU(e.to_id)})]}),(0,n.jsx)("div",{className:"muted small ellipsis",children:e.task}),(0,n.jsx)("div",{className:"muted feed-when",children:(0,v.KN)(e.created_at)})]})]},e.id))})]}),eE&&C.find(e=>e.id===eE)&&(0,n.jsx)(H.G,{agent:C.find(e=>e.id===eE),onClose:()=>eH(null),onDeleted:()=>U(null)}),Y&&(0,n.jsx)(N.b,{presetColonyId:Y.colonyId,presetObjectId:Y.objectId,manager:Y.manager,onClose:()=>$(null),onCreated:e=>U(e)}),et&&C.find(e=>e.id===et)&&(0,n.jsx)(E,{agent:C.find(e=>e.id===et),onClose:()=>el(null)},et),en&&(0,n.jsx)(V.X,{presetColonyId:en.colonyId,onClose:()=>es(null),onSaved:e=>U(e)}),Q&&(0,n.jsx)(S,{colony:"new"===Q?void 0:Q,onClose:()=>ee(null)})]})}},47405:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]])},48776:(e,t,l)=>{"use strict";l.d(t,{G:()=>c});var n=l(94799),s=l(86606),o=l(48538),a=l(3749),i=l(69654);function c(e){let{agent:t,onClose:l,onDeleted:c}=e,{t:r}=(0,i.s9)(),{refresh:d}=(0,o.zd)(),h=(0,s.dj)();return(0,n.jsx)(s.TM,{title:r("agent.deleteTitle",{name:t.name}),body:r("agent.deleteBody"),danger:!0,confirmLabel:r("agent.delete"),cancelLabel:r("agent.keep"),onClose:l,onConfirm:async()=>{await a.FH.del("/agents/".concat(t.id)),await d(["agents","colonies"]),h(r("agent.deleted")),null==c||c()}})}},64883:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("Eraser",[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]])},66654:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]])},66826:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]])},73784:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("Boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]])},73885:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("PlugZap",[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]])},75406:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]])},77701:(e,t,l)=>{Promise.resolve().then(l.bind(l,36098))},89128:(e,t,l)=>{"use strict";l.d(t,{A:()=>y});var n=l(94799),s=l(34023),o=l(97356),a=l(86606),i=l(5300),c=l(48776),r=l(48538),d=l(73506),h=l(3749),m=l(69654);function y(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{t:l}=(0,m.s9)(),{agents:y,colonies:u,objects:x,refresh:p}=(0,r.q5)(),g=(0,a.dj)(),k=(0,s.useMemo)(()=>e?x.filter(t=>t.manager_id===e.id).map(e=>e.id).sort():[],[x,null==e?void 0:e.id]),j=(0,s.useMemo)(()=>e?JSON.stringify((0,i.TN)(e,k)):"",[e,k]),[f,v]=(0,s.useState)(()=>e?(0,i.TN)(e,k):null),[b,w]=(0,s.useState)(!1),[N,C]=(0,s.useState)(!1);(0,s.useEffect)(()=>{v(e?(0,i.TN)(e,k):null)},[j]);let A=f&&e?(0,i.tf)(f,y,e.id,u):{},M=!!f&&JSON.stringify(f)!==j;(0,d.h)(M);let _=async()=>{if(f&&e){if(Object.keys(A).length)return void g(l("edit.fixFields"),"err");w(!0);try{var n;let{type_id:s,object_ids:o,...a}=f;await h.FH.patch("/agents/".concat(e.id),a),JSON.stringify([...o].sort())!==JSON.stringify(k)&&await h.FH.put("/agents/".concat(e.id,"/resources"),{object_ids:o}),await p(["agents","colonies","objects"]),g(l("edit.saved",{name:f.name.trim()})),null==(n=t.onSaved)||n.call(t)}catch(e){g(e instanceof Error?e.message:l("edit.saveFailed"),"err")}w(!1)}},z=()=>{e&&v((0,i.TN)(e,k))};return{draft:f,setDraft:v,errors:A,dirty:M,saving:b,save:_,discard:z,actions:function(){var e,t,s,a;let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("button",{className:"btn danger push-r ".concat(null!=(e=i.size)?e:""),onClick:()=>C(!0),children:[(0,n.jsx)(o.A,{size:i.size?14:15}),l("agent.delete")]}),i.onCancel?(0,n.jsx)("button",{className:"btn ghost ".concat(null!=(t=i.size)?t:""),onClick:i.onCancel,children:l("common.cancel")}):(0,n.jsx)("button",{className:"btn ghost ".concat(null!=(s=i.size)?s:""),disabled:!M,onClick:z,children:l("common.discard")}),(0,n.jsx)("button",{className:"btn primary ".concat(null!=(a=i.size)?a:""),disabled:!M||b,onClick:_,children:b?l("common.saving"):l("common.saveChanges")})]})},deleteModal:N&&e?(0,n.jsx)(c.G,{agent:e,onClose:()=>C(!1),onDeleted:t.onDeleted}):null}}},94726:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},98392:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]])}},e=>{e.O(0,[586,706,486,839,517,350,291,844,408,89,358],()=>e(e.s=77701)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{2432:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]])},3414:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},6261:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("Hexagon",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]])},6673:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]])},7991:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]])},26701:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]])},29416:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]])},32098:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]])},32335:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("LockOpen",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]])},33691:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]])},34265:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},34978:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("Container",[["path",{d:"M22 7.7c0-.6-.4-1.2-.8-1.5l-6.3-3.9a1.72 1.72 0 0 0-1.7 0l-10.3 6c-.5.2-.9.8-.9 1.4v6.6c0 .5.4 1.2.8 1.5l6.3 3.9a1.72 1.72 0 0 0 1.7 0l10.3-6c.5-.3.9-1 .9-1.5Z",key:"1t2lqe"}],["path",{d:"M10 21.9V14L2.1 9.1",key:"o7czzq"}],["path",{d:"m10 14 11.9-6.9",key:"zm5e20"}],["path",{d:"M14 19.8v-8.1",key:"159ecu"}],["path",{d:"M18 17.5V9.4",key:"11uown"}]])},36098:(e,t,l)=>{"use strict";l.r(t),l.d(t,{default:()=>Z});var n=l(94799),s=l(41463),o=l.n(s),a=l(34023),i=l(92947),c=l(6261),r=l(77841),d=l(73784),h=l(75406),m=l(71529),y=l(14910),u=l(32098),x=l(70665);let p=(0,l(74955).A)("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);var g=l(97356),k=l(48538),j=l(77021),f=l(3749),v=l(47890),b=l(10804),w=l(41435),N=l(1517),C=l(12646),A=l(73506),M=l(22214),_=l(69654);let z=v.hg,L=["cwd","permission","skills","prompt"];function S(e){let{colony:t,onClose:l}=e,{t:s}=(0,_.s9)(),{agents:o,skills:i,colonies:c,refresh:r}=(0,k.q5)(),d=(0,b.dj)(),[h,m]=(0,a.useState)(()=>t?{name:t.name,color:t.color,cwd:t.cwd,permission:t.permission,system_prompt:t.system_prompt,skill_ids:t.skill_ids,skill_loads:t.skill_loads,agent_ids:t.agent_ids,inherit:t.inherit}:{name:"",color:z[c.length%z.length],cwd:"",permission:"acceptEdits",system_prompt:"",skill_ids:[],skill_loads:{},agent_ids:[],inherit:{cwd:!0,permission:!0,skills:!0,prompt:!0}}),y=(0,a.useMemo)(()=>JSON.stringify(h),[]),u=JSON.stringify(h)!==y;(0,A.h)(u);let[x,p]=(0,a.useState)(!1),j=()=>{u?p(!0):l()},[v,w]=(0,a.useState)(""),[N,L]=(0,a.useState)(!1),[S,F]=(0,a.useState)(!1),[D,E]=(0,a.useState)(!1),H=(e,t)=>m(l=>({...l,[e]:t})),T=async e=>{E(!0);try{let n={...h,name:h.name.trim(),color:h.color.toLowerCase(),inherit:e};t?await f.FH.patch("/colonies/".concat(t.id),n):await f.FH.post("/colonies",n),await r(["agents","colonies"]),d(t?s("colony.saved"):s("colony.created")),l()}catch(e){L(!1),w(e instanceof Error?e.message:s("edit.saveFailed")),E(!1)}};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(b._s,{title:t?s("colony.editTitle",{name:t.name}):s("colony.newTitle"),subtitle:s("colony.subtitle"),onClose:j,footer:(0,n.jsxs)(n.Fragment,{children:[t&&(0,n.jsxs)("button",{className:"btn danger push-r",onClick:()=>F(!0),children:[(0,n.jsx)(g.A,{size:15}),s("common.delete")]}),(0,n.jsx)("button",{className:"btn ghost",onClick:j,children:s("common.cancel")}),(0,n.jsx)("button",{className:"btn primary",onClick:()=>h.name.trim()?c.some(e=>e.id!==(null==t?void 0:t.id)&&e.name.toLowerCase()===h.name.trim().toLowerCase())?void w(s("colony.err.nameTaken")):/^#[0-9a-f]{6}$/i.test(h.color)?void(w(""),L(!0)):void w(s("colony.err.color")):void w(s("colony.err.name")),children:t?s("colony.save"):s("colony.create")})]}),children:[(0,n.jsx)(b.D0,{label:s("form.name"),error:v,children:(0,n.jsx)("input",{className:"input",value:h.name,onChange:e=>H("name",e.target.value),placeholder:s("colony.name.placeholder"),"data-autofocus":!0})}),(0,n.jsx)(b.D0,{label:s("colony.color"),children:(0,n.jsxs)("div",{className:"swatches",children:[z.map(e=>(0,n.jsx)("button",{type:"button",className:"swatch",style:{"--c":e},"aria-pressed":h.color.toLowerCase()===e,"aria-label":s("colony.colorOption",{color:e}),onClick:()=>H("color",e)},e)),(0,n.jsx)("label",{className:"swatch custom ".concat(z.includes(h.color.toLowerCase())?"":"on"),style:{"--c":/^#[0-9a-f]{6}$/i.test(h.color)?h.color:"transparent"},title:s("colony.colorCustom"),children:(0,n.jsx)("input",{type:"color",value:/^#[0-9a-f]{6}$/i.test(h.color)?h.color:"#2f8f5b",onChange:e=>H("color",e.target.value),"aria-label":s("colony.colorCustom")})}),(0,n.jsx)("input",{className:"input hex-input mono",value:h.color,maxLength:7,spellCheck:!1,"aria-label":s("colony.colorHex"),placeholder:"#2f8f5b",onChange:e=>{let t=e.target.value.trim();H("color",t.startsWith("#")||!t?t:"#".concat(t))}})]})}),(0,n.jsx)(b.dR,{value:h.cwd,onChange:e=>H("cwd",e)}),(0,n.jsx)(b.en,{value:h.permission,onChange:e=>H("permission",e)}),(0,n.jsx)(b.D0,{label:s("inherit.context"),hint:s("colony.context.hint"),children:(0,n.jsx)(C.n,{value:h.system_prompt,onChange:e=>H("system_prompt",e),placeholder:s("colony.context.placeholder"),defaultView:"write",minHeight:160})}),(0,n.jsx)(b.D0,{label:s("form.skills"),children:(0,n.jsx)(b.kV,{skills:i,value:h.skill_ids,loads:h.skill_loads,onChange:(e,t)=>m({...h,skill_ids:e,skill_loads:t})})}),(0,n.jsx)(b.D0,{label:s("colony.members"),hint:s("colony.members.hint"),children:0===o.length?(0,n.jsx)("p",{className:"hint",children:s("colony.members.empty")}):(0,n.jsx)(M.C,{value:h.agent_ids,onChange:e=>H("agent_ids",e),items:o.map(e=>{let l=e.colony_id&&e.colony_id!==(null==t?void 0:t.id)?c.find(t=>t.id===e.colony_id):null;return{id:e.id,name:e.name,note:l?s("colony.currentlyIn",{name:l.name}):e.description||s("role.".concat(e.role))}})})})]}),N&&(0,n.jsx)(q,{draft:h,colony:t,members:o.filter(e=>h.agent_ids.includes(e.id)),busy:D,onBack:()=>L(!1),onConfirm:T}),x&&(0,n.jsx)(b.TM,{danger:!0,title:s("fa.unsaved.title"),body:s("fa.unsaved.body"),confirmLabel:s("fa.unsaved.discard"),cancelLabel:s("fa.unsaved.keep"),onClose:()=>p(!1),onConfirm:l}),S&&t&&(0,n.jsx)(b.TM,{title:s("colony.deleteTitle",{name:t.name}),body:s("colony.deleteBody",{count:t.agent_ids.length}),danger:!0,confirmLabel:s("colony.delete"),cancelLabel:s("colony.keep"),onClose:()=>F(!1),onConfirm:async()=>{await f.FH.del("/colonies/".concat(t.id)),await r(["agents","colonies"]),d(s("colony.deleted")),l()}})]})}function q(e){let{draft:t,colony:l,members:s,busy:o,onBack:i,onConfirm:c}=e,{t:r}=(0,_.s9)(),d={cwd:!!t.cwd,permission:!0,skills:t.skill_ids.length>0,prompt:!!t.system_prompt.trim()},[h,m]=(0,a.useState)(()=>({cwd:(!l||l.inherit.cwd)&&d.cwd,permission:!l||l.inherit.permission,skills:(!l||l.inherit.skills)&&d.skills,prompt:(!l||l.inherit.prompt)&&d.prompt})),y=(0,a.useMemo)(()=>h.cwd&&t.cwd&&s.filter(e=>!e.overrides.includes("cwd")&&e.effective.cwd!==t.cwd).length,[h.cwd,t.cwd,s]);return(0,n.jsxs)(b.aF,{title:r("inheritAsk.title"),onClose:i,children:[(0,n.jsx)("p",{className:"muted small m0",children:r("inheritAsk.intro")}),(0,n.jsx)("div",{className:"col gap-s",children:L.map(e=>(0,n.jsx)(b.Tl,{disabled:!d[e],checked:h[e],onChange:t=>m(l=>({...l,[e]:t})),label:(0,n.jsxs)(n.Fragment,{children:[r("inheritAsk.field.".concat(e)),"cwd"===e&&t.cwd?(0,n.jsxs)("span",{className:"muted mono fw-400",children:[" \xb7 ",(0,v._1)(t.cwd)]}):null,"permission"===e?(0,n.jsxs)("span",{className:"muted fw-400",children:[" \xb7 ",(0,v.Ck)(t.permission)]}):null]}),hint:d[e]?r("inheritAsk.hint.".concat(e)):r("inheritAsk.empty.".concat(e))},e))}),y?(0,n.jsx)(b.lZ,{kind:"honey",children:r("inheritAsk.folderMoves",{count:Number(y)})}):null,(0,n.jsxs)("div",{className:"row push-end",children:[(0,n.jsx)("button",{className:"btn ghost",onClick:i,children:r("common.back")}),(0,n.jsx)("button",{className:"btn primary",disabled:o,onClick:()=>c(h),children:o?r("common.saving"):l?r("colony.save"):r("colony.create")})]})]})}var F=l(5300),D=l(89128);function E(e){let{agent:t,onClose:l}=e,{t:s}=(0,_.s9)(),o=(0,D.A)(t,{onSaved:l,onDeleted:l});return o.draft?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(b._s,{title:s("edit.title",{name:t.name}),subtitle:s("running"===t.status?"edit.subtitleRunning":"edit.subtitleIdle"),onClose:l,footer:o.actions({onCancel:l}),children:(0,n.jsx)(F.SU,{draft:o.draft,onChange:o.setDraft,errors:o.errors,selfId:t.id})}),o.deleteModal]}):null}var H=l(48776),T=l(42366),O=l(5372),I=l(31606),V=l(95587),R=l(74988);let W=74*Math.sqrt(3),P=[[1,0],[1,-1],[0,-1],[-1,0],[-1,1],[0,1]],B=e=>{let[t,l]=e;return{x:W*(t+l/2),y:111*l}},K=(e,t,l)=>Array.from({length:6},(n,s)=>{let o=(60*s-30)*Math.PI/180;return"".concat((e+l*Math.cos(o)).toFixed(1),",").concat((t+l*Math.sin(o)).toFixed(1))}).join(" ");function Z(){var e,t,l;let{t:s}=(0,_.s9)(),{agents:C,colonies:A,objects:M,dispatches:z,ready:L,error:q,retry:F,refresh:D}=(0,k.q5)(),Z=(0,b.dj)(),[J,U]=(0,a.useState)(null),[X,G]=(0,a.useState)(null),[Y,$]=(0,a.useState)(null),[Q,ee]=(0,a.useState)(null),[et,el]=(0,a.useState)(null),[en,es]=(0,a.useState)(null),[eo,ea]=(0,j.ud)("hive-colony-layout",{}),[ei,ec]=(0,a.useState)(null),[er,ed]=(0,j.ud)("hive-colony-zoom",1),eh=er>=.4&&er<=2.5?er:1,em=e=>ed(Math.min(2.5,Math.max(.4,Math.round(100*e)/100))),ey=(0,a.useMemo)(()=>ei?{...eo,[ei.key]:{x:ei.x,y:ei.y}}:eo,[eo,ei]),{clusters:eu,width:ex,height:ep}=(0,a.useMemo)(()=>(function(e,t,l){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},s=e=>!!e&&t.some(t=>t.id===e),o=t.map(t=>({key:t.id,colony:t,members:e.filter(e=>e.colony_id===t.id),things:l.filter(e=>e.colony_id===t.id)}));o.push({key:"free",colony:null,members:e.filter(e=>!s(e.colony_id)),things:l.filter(e=>!s(e.colony_id))});let a=[],i=0,c=0,r=0;for(let t of o){if(!t.members.length&&!t.things.length&&!t.colony&&e.length+l.length>0)continue;let s=function(e){let t=e.filter(e=>"orchestrator"===e.role);for(let l of[...t])for(let n of l.worker_ids){let l=e.find(e=>e.id===n);l&&!t.includes(l)&&t.push(l)}for(let l of e)t.includes(l)||t.push(l);return t}(t.members),o=(function(e){let t=[[0,0]];for(let l=1;t.length<e;l++){let e=P[4][0]*l,n=P[4][1]*l;for(let s=0;s<6;s++)for(let o=0;o<l;o++)t.push([e,n]),e+=P[s][0],n+=P[s][1]}return t.slice(0,e)})(s.length+t.things.length+1).map(B),d=Math.min(...o.map(e=>e.x))-W/2,h=Math.max(...o.map(e=>e.x))+W/2,m=Math.min(...o.map(e=>e.y))-74,y=Math.max(...o.map(e=>e.y))+74,u=h-d+52,x=y-m+52+50,p=t.colony?n[t.key]:void 0;!p&&i>0&&i+u>880&&(i=0,c+=r+36,r=0);let g=p?p.x:i,k=p?p.y:c,j=o.map((e,l)=>{var o,a,i;let c=null!=(a=s[l])?a:null,r=t.things[l-s.length],h=t.colony?void 0:n[null!=(i=null==(o=null!=c?c:r)?void 0:o.id)?i:""];return{agent:c,object:r,x:h?h.x:g+(e.x-d)+26,y:h?h.y:k+(e.y-m)+26+50}});a.push({key:t.key,colony:t.colony,cells:j,x:g,y:k,w:u,h:x}),p||(i+=u+36,r=Math.max(r,x))}let d=0,h=0;for(let e of a)if(e.colony)d=Math.max(d,e.x+e.w),h=Math.max(h,e.y+e.h);else for(let t of e.cells)d=Math.max(d,t.x+W/2+26),h=Math.max(h,t.y+74+26);return{clusters:a,width:d,height:h}})(C,A,M,ey),[C,A,M,ey]),eg=(0,a.useRef)(null),[ek,ej]=(0,a.useState)(0);(0,a.useEffect)(()=>{let e=eg.current;if(!e)return;let t=new ResizeObserver(()=>ej(e.clientWidth));return t.observe(e),ej(e.clientWidth),()=>t.disconnect()},[L,0===C.length]);let ef=(0,a.useRef)(eh);ef.current=eh,(0,a.useEffect)(()=>{let e=eg.current;if(!e)return;let t=e=>{(e.ctrlKey||e.metaKey)&&(e.preventDefault(),em(ef.current*(e.deltaY<0?1.1:1/1.1)))};return e.addEventListener("wheel",t,{passive:!1}),()=>e.removeEventListener("wheel",t)},[L]);let ev=ex+80,eb=ep+80,ew=(ek?Math.min(1,(ek-24)/ev):1)*eh,eN=(0,a.useRef)(null),eC=(0,a.useRef)(!1),eA=function(e,t,l,n){let s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{x:0,y:0};if(0===e.button){eN.current={key:t,sx:e.clientX,sy:e.clientY,ox:l,oy:n,min:s,moved:!1};try{e.currentTarget.setPointerCapture(e.pointerId)}catch(e){}}},eM=e=>{let t=eN.current;if(!t)return;let l=(e.clientX-t.sx)/ew,n=(e.clientY-t.sy)/ew;!t.moved&&Math.hypot(l,n)*ew<6||(t.moved=!0,t.last={x:Math.max(t.min.x,t.ox+l),y:Math.max(t.min.y,t.oy+n)},ec({key:t.key,...t.last}))},e_=()=>{let e=eN.current;eN.current=null,(null==e?void 0:e.moved)&&e.last&&(eC.current=!0,setTimeout(()=>{eC.current=!1},0),ea({...eo,[e.key]:e.last}),ec(null))},ez=function(e,t,l,n){let s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{x:0,y:0},o={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[e.key];if(!o||e.altKey||e.ctrlKey||e.metaKey)return;e.preventDefault();let a=e.shiftKey?64:16;ea({...eo,[t]:{x:Math.max(s.x,l+o[0]*a),y:Math.max(s.y,n+o[1]*a)}})},eL=(e,t,l,n)=>({onPointerDown:s=>eA(s,e,t,l,n),onPointerMove:eM,onPointerUp:e_,onPointerCancel:e_}),eS=new Map;for(let e of eu)for(let t of e.cells)t.agent&&eS.set(t.agent.id,{x:t.x+40,y:t.y+40}),t.object&&eS.set(t.object.id,{x:t.x+40,y:t.y+40});let eq=M.filter(e=>"cluster"===e.kind).flatMap(e=>e.config.members.map(t=>({from:e.id,to:t}))),eF=M.filter(e=>e.manager_id&&eS.has(e.manager_id)&&eS.has(e.id)).map(e=>({from:e.manager_id,to:e.id})),eD=e=>M.filter(t=>t.manager_id===e),[eE,eH]=(0,a.useState)(null),eT=null!=(e=C.find(e=>e.id===J))?e:null,eO=null!=(t=M.find(e=>e.id===J))?t:null,[eI,eV]=(0,a.useState)(null);(0,a.useLayoutEffect)(()=>{eV(J?document.querySelector('[data-sid="'.concat(J,'"]')):null)},[J,C.length,M.length]),(0,a.useEffect)(()=>{if(!J)return;let e=e=>{"Escape"!==e.key||document.querySelector('[role="dialog"]')||U(null)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[J]);let eR=null!=X?X:J,eW=C.filter(e=>"orchestrator"===e.role).flatMap(e=>e.worker_ids.map(t=>({from:e.id,to:t}))),eP=new Set(eR?[eR,...[...eW,...eq,...eF].filter(e=>e.from===eR||e.to===eR).flatMap(e=>[e.from,e.to])]:[]),eB=e=>C.filter(t=>"orchestrator"===t.role&&t.worker_ids.includes(e)),eK=C.filter(e=>"running"===e.status).length,eZ=M.filter(e=>"running"===e.state.status).length,eJ=C.filter(e=>"orchestrator"===e.role).length,eU=e=>{var t,l;return null!=(l=null==(t=C.find(t=>t.id===e))?void 0:t.name)?l:s("colony.removedAgent")},eX=z.filter(e=>"running"===e.status).length,eG=[{id:"agents",n:C.length,label:s("stat.agents",{count:C.length}),href:"/agents"},{id:"colonies",n:A.length,label:s("stat.colonies",{count:A.length})},{id:"objects",n:M.length,label:s("stat.objects",{count:M.length}),href:"/resources",title:M.length?s("obj.running",{count:eZ}):void 0},{id:"queens",n:eJ,label:s("stat.orchestrators",{count:eJ}),href:"/agents"},{id:"working",n:eK,label:s("stat.working"),href:"/agents"},{id:"tasks",n:eX,label:s("stat.tasks"),href:"#recent"}],eY=eT?A.find(e=>e.id===eT.colony_id):void 0,e$=async(e,t)=>{try{var l,n;await f.FH.patch("/agents/".concat(e.id),{colony_id:t||null,overrides:[]}),await D(["agents","colonies"]),Z(t?s("colony.joined",{name:e.name,colony:null!=(n=null==(l=A.find(e=>e.id===t))?void 0:l.name)?n:""}):s("colony.left",{name:e.name}))}catch(e){Z(e instanceof Error?e.message:s("colony.moveFailed"),"err")}};return(0,n.jsxs)("div",{className:"page",children:[(0,n.jsxs)("div",{className:"page-head",children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("h1",{children:s("nav.colony")}),(0,n.jsx)(T.B,{label:s("colony.helpLabel"),title:s("colony.howTitle"),children:s("colony.howBody")})]}),(0,n.jsx)("p",{children:s("colony.page.subtitle")})]}),(0,n.jsx)("div",{className:"cx-head-actions",children:(0,n.jsx)(w.W1,{label:s("cx.new"),icon:(0,n.jsx)(i.A,{size:14}),children:e=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(w.Dr,{icon:(0,n.jsx)(c.A,{size:15}),onClick:()=>{e(),$({})},children:s("newAgent.title")}),(0,n.jsx)(w.Dr,{icon:(0,n.jsx)(r.A,{size:15}),onClick:()=>{e(),ee("new")},children:s("colony.newTitle")}),(0,n.jsx)(w.Dr,{icon:(0,n.jsx)(d.A,{size:15}),onClick:()=>{e(),es({})},children:s("obj.new")})]})})})]}),(0,n.jsx)("div",{className:"stats",children:eG.map(e=>{let t=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("b",{children:e.n}),(0,n.jsx)("span",{children:e.label})]});return e.href?(0,n.jsx)(o(),{href:e.href,className:"card stat",title:e.title,"aria-label":"".concat(e.n," ").concat(e.label,". ").concat(s("cx.stat.open",{label:e.label})),children:t},e.id):(0,n.jsx)("div",{className:"card stat",title:e.title,children:t},e.id)})}),(0,n.jsxs)("div",{className:"colony",children:[(0,n.jsxs)("div",{className:"comb-wrap",ref:eg,children:[L?0===C.length&&0===A.length&&0===M.length?(0,n.jsx)("div",{className:"comb-empty-wrap",children:(0,n.jsx)(b.pp,{icon:(0,n.jsx)(b._h,{size:"lg",queen:!0,label:"+"}),title:s("colony.empty.title"),body:s("colony.empty.body"),action:(0,n.jsxs)("div",{className:"row",children:[(0,n.jsxs)("button",{className:"btn",onClick:()=>ee("new"),children:[(0,n.jsx)(i.A,{size:16}),s("colony.empty.createColony")]}),(0,n.jsxs)("button",{className:"btn primary",onClick:()=>$({}),children:[(0,n.jsx)(i.A,{size:16}),s("colony.empty.createAgent")]})]})})}):(0,n.jsx)("div",{className:"comb-box",style:{width:ev*ew,height:eb*ew},children:(0,n.jsxs)("div",{className:"comb",style:{width:ev,height:eb,transform:"scale(".concat(ew,")"),transformOrigin:"0 0","--w":"".concat(.9*W,"px"),"--h":"".concat(133.20000000000002,"px")},children:[(0,n.jsx)("svg",{className:"links",width:ev,height:eb,children:eu.filter(e=>e.colony).map(e=>{let t=e.colony.color||"var(--honey)";return(0,n.jsxs)("g",{children:[e.cells.map((e,l)=>(0,n.jsx)("polygon",{points:K(e.x+40,e.y+40,74),style:{fill:t,stroke:t},strokeWidth:44,strokeLinejoin:"round"},"o"+l)),e.cells.map((e,l)=>(0,n.jsx)("polygon",{points:K(e.x+40,e.y+40,74),style:{fill:"color-mix(in srgb, ".concat(t," 9%, var(--surface))"),stroke:"color-mix(in srgb, ".concat(t," 9%, var(--surface))")},strokeWidth:38,strokeLinejoin:"round"},"i"+l))]},e.key)})}),eu.map(e=>(0,n.jsxs)("div",{children:[e.colony?(0,n.jsxs)("button",{className:"colony-label draggable ".concat((null==ei?void 0:ei.key)===e.key?"dragging":""),style:{left:e.x+e.w/2+40,top:e.y+50-10+40,"--c":e.colony.color||"var(--honey)"},...eL(e.key,e.x,e.y),onKeyDown:t=>ez(t,e.key,e.x,e.y),onClick:()=>{eC.current||ee(e.colony)},title:"".concat(e.colony.cwd?s("colony.editHover",{path:(0,v._1)(e.colony.cwd)}):s("colony.editHoverShort")," \xb7 ").concat(s("colony.dragHint")," \xb7 ").concat(s("cx.moveHint")),children:[(0,n.jsx)("i",{className:"cdot"}),e.colony.name,(0,n.jsx)("small",{children:s("colony.agentCount",{count:e.cells.filter(e=>e.agent).length})}),(0,n.jsx)(r.A,{size:13,className:"muted"})]}):A.length>0&&e.cells.some(e=>e.agent)?(0,n.jsx)("span",{className:"colony-label cx-unplaced",style:{left:e.x+e.w/2+40,top:e.y+50-10+40},children:(0,n.jsx)("small",{children:s("common.noColony")})}):null,e.cells.map((t,l)=>{let o=t.agent,a={left:t.x+40,top:t.y+40},c=t.object;if(c){let{icon:l,color:o}=R.Nd[c.kind];return(0,n.jsxs)("button",{"data-sid":c.id,className:"cell fill obj st-".concat(c.state.status," ").concat("running"===c.state.status?"running":""," ").concat(eR&&!eP.has(c.id)?"dim":""," ").concat(eR&&eP.has(c.id)&&c.id!==eR?"linked":""," ").concat(e.colony?"":"draggable"),style:{...a,"--c":o},"aria-pressed":J===c.id,onMouseEnter:()=>G(c.id),onMouseLeave:()=>G(null),onFocus:()=>G(c.id),onBlur:()=>G(null),...e.colony?{}:{...eL(c.id,t.x,t.y,{x:W/2,y:74}),onKeyDown:e=>ez(e,c.id,t.x,t.y,{x:W/2,y:74})},onClick:()=>{eC.current||U(c.id===J?null:c.id)},"aria-label":"".concat(c.name,", ").concat(s("obj.kind.".concat(c.kind)),", ").concat(s("obj.status.".concat(c.state.status))),title:c.state.detail?"".concat(s("obj.status.".concat(c.state.status)),": ").concat(c.state.detail):s("obj.status.".concat(c.state.status)),children:[(0,n.jsx)("span",{className:"shape"}),(0,n.jsxs)("span",{className:"label",children:[(0,n.jsx)(l,{size:16}),(0,n.jsx)("b",{children:c.name}),(0,n.jsx)("small",{children:s("obj.status.".concat(c.state.status))})]}),(0,n.jsx)("span",{className:"pip o-".concat(c.state.status)}),c.manager_id&&(0,n.jsxs)("span",{className:"ltag top mgr",title:s("colony.managedBy",{name:eU(c.manager_id)}),children:["⚙ ",eU(c.manager_id)]})]},c.id)}return o?(0,n.jsxs)("button",{"data-sid":o.id,className:"cell fill ".concat("orchestrator"===o.role?"queen":""," ").concat("running"===o.status?"running":""," ").concat(eR&&!eP.has(o.id)?"dim":""," ").concat(eR&&eP.has(o.id)&&o.id!==eR?"linked":""," ").concat(e.colony?"":"draggable"),onMouseEnter:()=>G(o.id),onMouseLeave:()=>G(null),onFocus:()=>G(o.id),onBlur:()=>G(null),style:{...a,"--c":v.xq[o.provider].color},"aria-pressed":J===o.id,...e.colony?{}:{...eL(o.id,t.x,t.y,{x:W/2,y:74}),onKeyDown:e=>ez(e,o.id,t.x,t.y,{x:W/2,y:74}),title:s("cx.moveHint")},onClick:()=>{eC.current||U(o.id===J?null:o.id)},"aria-label":"".concat(o.name,", ").concat(s("role.".concat(o.role)),", ").concat(v.xq[o.provider].short,", ").concat(s("status.".concat(o.status))),children:[(0,n.jsx)("span",{className:"shape"}),(0,n.jsxs)("span",{className:"label",children:[(0,n.jsx)("b",{children:o.name}),(0,n.jsx)("small",{children:v.xq[o.provider].short})]}),"idle"!==o.status&&(0,n.jsx)("span",{className:"pip ".concat("error"===o.status?"err":"")}),eD(o.id).length>0&&(0,n.jsxs)("span",{className:"ltag top mgr",title:s("colony.manages",{names:eD(o.id).map(e=>e.name).join(", ")}),children:["⚙ ",1===eD(o.id).length?eD(o.id)[0].name:eD(o.id).length]}),("orchestrator"===o.role?o.worker_ids.length>0:eB(o.id).length>0)&&(0,n.jsx)("span",{className:"ltag",title:"orchestrator"===o.role?s("colony.delegatesTo",{count:o.worker_ids.length}):s("colony.connectedTo",{names:eB(o.id).map(e=>e.name).join(", ")}),children:"orchestrator"===o.role?"↓ ".concat(o.worker_ids.length):"↑ ".concat(1===eB(o.id).length?eB(o.id)[0].name:eB(o.id).length)})]},o.id):(0,n.jsxs)("button",{className:"cell ghost",style:a,onClick:()=>{var t;return $({colonyId:null==(t=e.colony)?void 0:t.id})},"aria-label":e.colony?s("colony.addTo",{name:e.colony.name}):s("colony.addAgent"),children:[(0,n.jsx)("svg",{className:"ghost-hex",viewBox:"0 0 100 115",preserveAspectRatio:"none","aria-hidden":!0,children:(0,n.jsx)("polygon",{points:"50,2 98,29 98,86 50,113 2,86 2,29"})}),(0,n.jsxs)("span",{className:"label",children:[(0,n.jsx)(i.A,{size:18}),s("colony.addAgent")]})]},e.key+"g"+l)})]},e.key+"l")),(0,n.jsxs)("svg",{className:"links top",width:ev,height:eb,"aria-hidden":!0,children:[eW.filter(e=>!!eR&&(e.from===eR||e.to===eR)).map(e=>{var t;let l=eS.get(e.from),s=eS.get(e.to);if(!l||!s)return null;let o=s.x-l.x,a=s.y-l.y,i=Math.hypot(o,a)||1,c=o/i,r=a/i,d=l.x+45.88*c,h=l.y+45.88*r,m=s.x-45.88*c,y=s.y-45.88*r,u=(null==(t=C.find(t=>t.id===e.to))?void 0:t.status)==="running",x=!!eR&&(e.from===eR||e.to===eR),p=!!eR&&!x;return(0,n.jsxs)("g",{opacity:p?.18:1,children:[(0,n.jsx)("line",{x1:d,y1:h,x2:m,y2:y,stroke:"var(--surface)",strokeWidth:x?8:5,strokeLinecap:"round",opacity:.85}),(0,n.jsx)("line",{x1:d,y1:h,x2:m,y2:y,stroke:"var(--honey)",strokeWidth:x?3.5:2.2,strokeDasharray:u?"7 6":x?void 0:"1 6",strokeLinecap:"round",children:u&&(0,n.jsx)("animate",{attributeName:"stroke-dashoffset",from:"26",to:"0",dur:"0.8s",repeatCount:"indefinite"})}),(0,n.jsx)("circle",{cx:m,cy:y,r:x?5.5:4,fill:"var(--honey)",stroke:"var(--surface)",strokeWidth:2})]},e.from+e.to)}),[...eq.map(e=>({...e,kind:"cluster"})),...eF.map(e=>({...e,kind:"manager"}))].filter(e=>!!eR&&(e.from===eR||e.to===eR)).map(e=>{let t=eS.get(e.from),l=eS.get(e.to);if(!t||!l)return null;let s=l.x-t.x,o=l.y-t.y,a=Math.hypot(s,o)||1,i=s/a,c=o/a,r="cluster"===e.kind?v.Ng:"var(--link-manager)";return(0,n.jsxs)("g",{children:[(0,n.jsx)("line",{x1:t.x+45.88*i,y1:t.y+45.88*c,x2:l.x-45.88*i,y2:l.y-45.88*c,stroke:"var(--surface)",strokeWidth:8,strokeLinecap:"round",opacity:.9}),(0,n.jsx)("line",{x1:t.x+45.88*i,y1:t.y+45.88*c,x2:l.x-45.88*i,y2:l.y-45.88*c,stroke:r,strokeWidth:3,strokeDasharray:"cluster"===e.kind?"3 5":"8 5",strokeLinecap:"round"}),(0,n.jsx)("circle",{cx:l.x-45.88*i,cy:l.y-45.88*c,r:5,fill:r,stroke:"var(--surface)",strokeWidth:2})]},e.kind+e.from+e.to)})]})]})}):q?(0,n.jsx)("div",{className:"comb-skel",children:(0,n.jsx)(b.lZ,{kind:"err",children:(0,n.jsxs)("div",{className:"row gap-s wrap",children:[(0,n.jsxs)("span",{className:"grow",children:[s("cx.loadFailed")," ",q]}),(0,n.jsx)("button",{className:"btn sm",onClick:()=>void F(),children:s("cx.retry")})]})})}):(0,n.jsxs)("div",{className:"comb-skel",role:"status","aria-label":s("cx.loading"),children:[(0,n.jsx)("div",{className:"skel",style:{width:220,height:190}}),(0,n.jsxs)("div",{className:"row gap-l",children:[(0,n.jsx)("div",{className:"skel",style:{width:150,height:130}}),(0,n.jsx)("div",{className:"skel",style:{width:150,height:130}})]})]}),(0,n.jsxs)("div",{className:"comb-zoom",role:"group","aria-label":s("colony.zoom"),children:[Object.keys(eo).length>0&&(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>ea({}),title:s("colony.layout.reset"),"aria-label":s("colony.layout.reset"),children:(0,n.jsx)(h.A,{size:14})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>em(eh/1.2),disabled:eh<=.4,title:s("colony.zoom.out"),"aria-label":s("colony.zoom.out"),children:(0,n.jsx)(m.A,{size:14})}),(0,n.jsxs)("button",{className:"btn ghost sm zoom-pct",onClick:()=>em(1),title:s("colony.zoom.fit"),"aria-label":s("colony.zoom.fit"),children:[Math.round(100*eh),"%"]}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>em(1.2*eh),disabled:eh>=2.5,title:s("colony.zoom.in"),"aria-label":s("colony.zoom.in"),children:(0,n.jsx)(i.A,{size:14})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>em(1),title:s("colony.zoom.fit"),"aria-label":s("colony.zoom.fit"),children:(0,n.jsx)(y.A,{size:14})})]}),(0,n.jsxs)("div",{className:"comb-legend",children:[Object.keys(v.xq).map(e=>(0,n.jsxs)("span",{className:"pbadge",style:{"--c":v.xq[e].color},children:[(0,n.jsx)("i",{}),v.xq[e].short]},e)),(0,n.jsxs)("span",{className:"pbadge",style:{"--c":"var(--honey)"},children:[(0,n.jsx)("i",{}),s("role.orchestrator")]})]})]}),eO?(0,n.jsx)(I.wl,{object:eO,target:eI,onClose:()=>U(null),onCreateManager:()=>{var e;return $({colonyId:null!=(e=eO.colony_id)?e:void 0,manager:!0,objectId:eO.id})}},eO.id):eT?(0,n.jsxs)(O.rs,{target:eI,pinned:!0,width:340,label:eT.name,onClose:()=>U(null),children:[(0,n.jsxs)("div",{className:"ap-corner row gap-s",children:[(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>el(eT.id),"aria-label":s("colony.settingsFor",{name:eT.name}),title:s("colony.agentSettings"),children:(0,n.jsx)(u.A,{size:16})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>U(null),"aria-label":s("common.close"),title:"".concat(s("common.close")," (Esc)"),children:(0,n.jsx)(x.A,{size:16})})]}),(0,n.jsx)(O.kh,{agent:eT,hideColony:!0}),(0,n.jsxs)("div",{className:"field ap-pin-field",children:[(0,n.jsx)("label",{children:s("form.colony")}),(0,n.jsxs)("select",{className:"select",value:null!=(l=null==eY?void 0:eY.id)?l:"",onChange:e=>void e$(eT,e.target.value),children:[(0,n.jsx)("option",{value:"",children:s("common.noColony")}),A.map(e=>(0,n.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),(0,n.jsxs)("div",{className:"row ap-pin-actions",children:[(0,n.jsxs)(o(),{className:"btn primary grow",href:"/agents/".concat(eT.id),children:[s("colony.openChat")," ",(0,n.jsx)(p,{size:16})]}),(0,n.jsx)("button",{className:"btn danger icon",onClick:()=>eH(eT.id),"aria-label":s("agent.delete"),title:s("agent.delete"),children:(0,n.jsx)(g.A,{size:16})})]})]},eT.id):null]}),(0,n.jsxs)("div",{className:"card card-pad recent",id:"recent",children:[(0,n.jsx)("div",{className:"eyebrow recent-head",children:s("colony.recent")}),0===z.length?(0,n.jsx)("p",{className:"muted small m0",children:s("colony.recentEmpty")}):(0,n.jsx)("div",{className:"recent-grid",children:z.slice(0,6).map(e=>(0,n.jsxs)("div",{className:"feed-item",children:[(0,n.jsx)("i",{className:"dot ".concat("running"===e.status?"run":"done"===e.status?"ok":"err")}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"feed-line",children:[C.some(t=>t.id===e.from_id)?(0,n.jsx)(o(),{href:"/agents/".concat(e.from_id),"aria-label":s("cx.openAgent",{name:eU(e.from_id)}),children:eU(e.from_id)}):(0,n.jsx)("b",{children:eU(e.from_id)})," → ",C.some(t=>t.id===e.to_id)?(0,n.jsx)(o(),{href:"/agents/".concat(e.to_id),"aria-label":s("cx.openAgent",{name:eU(e.to_id)}),children:eU(e.to_id)}):(0,n.jsx)("b",{children:eU(e.to_id)})]}),(0,n.jsx)("div",{className:"muted small ellipsis",children:e.task}),(0,n.jsx)("div",{className:"muted feed-when",children:(0,v.KN)(e.created_at)})]})]},e.id))})]}),eE&&C.find(e=>e.id===eE)&&(0,n.jsx)(H.G,{agent:C.find(e=>e.id===eE),onClose:()=>eH(null),onDeleted:()=>U(null)}),Y&&(0,n.jsx)(N.b,{presetColonyId:Y.colonyId,presetObjectId:Y.objectId,manager:Y.manager,onClose:()=>$(null),onCreated:e=>U(e)}),et&&C.find(e=>e.id===et)&&(0,n.jsx)(E,{agent:C.find(e=>e.id===et),onClose:()=>el(null)},et),en&&(0,n.jsx)(V.X,{presetColonyId:en.colonyId,onClose:()=>es(null),onSaved:e=>U(e)}),Q&&(0,n.jsx)(S,{colony:"new"===Q?void 0:Q,onClose:()=>ee(null)})]})}},47405:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]])},48776:(e,t,l)=>{"use strict";l.d(t,{G:()=>c});var n=l(94799),s=l(10804),o=l(48538),a=l(3749),i=l(69654);function c(e){let{agent:t,onClose:l,onDeleted:c}=e,{t:r}=(0,i.s9)(),{refresh:d}=(0,o.zd)(),h=(0,s.dj)();return(0,n.jsx)(s.TM,{title:r("agent.deleteTitle",{name:t.name}),body:r("agent.deleteBody"),danger:!0,confirmLabel:r("agent.delete"),cancelLabel:r("agent.keep"),onClose:l,onConfirm:async()=>{await a.FH.del("/agents/".concat(t.id)),await d(["agents","colonies"]),h(r("agent.deleted")),null==c||c()}})}},64883:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("Eraser",[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]])},66654:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]])},66826:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]])},73784:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("Boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]])},73885:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("PlugZap",[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]])},75406:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]])},77701:(e,t,l)=>{Promise.resolve().then(l.bind(l,36098))},89128:(e,t,l)=>{"use strict";l.d(t,{A:()=>y});var n=l(94799),s=l(34023),o=l(97356),a=l(10804),i=l(5300),c=l(48776),r=l(48538),d=l(73506),h=l(3749),m=l(69654);function y(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{t:l}=(0,m.s9)(),{agents:y,colonies:u,objects:x,refresh:p}=(0,r.q5)(),g=(0,a.dj)(),k=(0,s.useMemo)(()=>e?x.filter(t=>t.manager_id===e.id).map(e=>e.id).sort():[],[x,null==e?void 0:e.id]),j=(0,s.useMemo)(()=>e?JSON.stringify((0,i.TN)(e,k)):"",[e,k]),[f,v]=(0,s.useState)(()=>e?(0,i.TN)(e,k):null),[b,w]=(0,s.useState)(!1),[N,C]=(0,s.useState)(!1);(0,s.useEffect)(()=>{v(e?(0,i.TN)(e,k):null)},[j]);let A=f&&e?(0,i.tf)(f,y,e.id,u):{},M=!!f&&JSON.stringify(f)!==j;(0,d.h)(M);let _=async()=>{if(f&&e){if(Object.keys(A).length)return void g(l("edit.fixFields"),"err");w(!0);try{var n;let{type_id:s,object_ids:o,...a}=f;await h.FH.patch("/agents/".concat(e.id),a),JSON.stringify([...o].sort())!==JSON.stringify(k)&&await h.FH.put("/agents/".concat(e.id,"/resources"),{object_ids:o}),await p(["agents","colonies","objects"]),g(l("edit.saved",{name:f.name.trim()})),null==(n=t.onSaved)||n.call(t)}catch(e){g(e instanceof Error?e.message:l("edit.saveFailed"),"err")}w(!1)}},z=()=>{e&&v((0,i.TN)(e,k))};return{draft:f,setDraft:v,errors:A,dirty:M,saving:b,save:_,discard:z,actions:function(){var e,t,s,a;let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("button",{className:"btn danger push-r ".concat(null!=(e=i.size)?e:""),onClick:()=>C(!0),children:[(0,n.jsx)(o.A,{size:i.size?14:15}),l("agent.delete")]}),i.onCancel?(0,n.jsx)("button",{className:"btn ghost ".concat(null!=(t=i.size)?t:""),onClick:i.onCancel,children:l("common.cancel")}):(0,n.jsx)("button",{className:"btn ghost ".concat(null!=(s=i.size)?s:""),disabled:!M,onClick:z,children:l("common.discard")}),(0,n.jsx)("button",{className:"btn primary ".concat(null!=(a=i.size)?a:""),disabled:!M||b,onClick:_,children:b?l("common.saving"):l("common.saveChanges")})]})},deleteModal:N&&e?(0,n.jsx)(c.G,{agent:e,onClose:()=>C(!1),onDeleted:t.onDeleted}):null}}},94726:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},98392:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});let n=(0,l(74955).A)("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]])}},e=>{e.O(0,[586,706,304,281,517,350,291,844,408,89,358],()=>e(e.s=77701)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[964],{27949:(e,r,l)=>{Promise.resolve().then(l.bind(l,86300))},86300:(e,r,l)=>{"use strict";l.r(r),l.d(r,{default:()=>v});var s=l(94799),t=l(34023),a=l(20831),i=l(15334);l(40117);var n=l(70665),o=l(10964),d=l(48538),c=l(77021),h=l(3749),u=l(47890),m=l(86606),x=l(69654);let p=e=>{let r=u.hg[e%u.hg.length];return"color-mix(in srgb, ".concat(r," calc(100% - var(--series-mix, 0%)), white)")},g={agent:function(e){let{data:r}=e,{t:l}=(0,x.s9)(),t=r.agent;return(0,s.jsxs)("div",{className:"rnode ".concat(r.dim?"dim":""," ").concat(r.active?"active":""),children:["worker"===t.role&&(0,s.jsx)(a.h7,{type:"target",position:i.yX.Top}),(0,s.jsx)(m._h,{agent:t}),(0,s.jsx)("b",{children:t.name}),(0,s.jsx)("small",{children:"orchestrator"===t.role?l("role.orchestrator"):u.xq[t.provider].short}),"orchestrator"===t.role&&(0,s.jsx)(a.h7,{type:"source",position:i.yX.Bottom})]})}},j={link:function(e){let{id:r,sourceX:l,sourceY:t,targetX:o,targetY:d,sourcePosition:c,targetPosition:h,data:u}=e,[m,x,p]=(0,i.Fp)({sourceX:l,sourceY:t,targetX:o,targetY:d,sourcePosition:c,targetPosition:h,curvature:.35});return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(a.tE,{id:r,path:m,interactionWidth:26,style:{stroke:u.color,strokeWidth:u.active?4:2.5,opacity:u.dim?.15:1,transition:"opacity .15s, stroke-width .15s"}}),u.show&&(0,s.jsx)(a.rV,{children:(0,s.jsx)("button",{className:"edge-x nodrag nopan",style:{transform:"translate(-50%, -50%) translate(".concat(x,"px, ").concat(p,"px)")},onClick:u.onRemove,"aria-label":u.label,title:u.label,children:(0,s.jsx)(n.A,{size:13,strokeWidth:3})})})]})}};function v(){let{t:e,locale:r}=(0,x.s9)(),{agents:l,refresh:i,ready:u,error:v,retry:k}=(0,d.q5)(),w=(0,m.dj)(),[f,N]=(0,c.ud)("hive-rel-pos-v2",{}),[b,y]=(0,t.useState)([]),[_,C]=(0,t.useState)(null),[E,M]=(0,t.useState)(null),[F,O]=(0,t.useState)(null),[S,W]=(0,t.useState)(0),A=(0,t.useMemo)(()=>(function(e){let r=e.filter(e=>"orchestrator"===e.role),l=e.filter(e=>"worker"===e.role),s=e=>r.find(r=>r.worker_ids.includes(e.id)),t={},a=0;for(let e of r){let r=l.filter(r=>{var l;return(null==(l=s(r))?void 0:l.id)===e.id}),i=Math.max(1,r.length);r.forEach((e,r)=>t[e.id]={x:a+190*r,y:280}),t[e.id]={x:a+(i-1)*190/2,y:0},a+=190*i+114}return l.filter(e=>!s(e)).forEach((e,r)=>t[e.id]={x:a+190*r,y:280}),t})(l),[l]);(0,t.useEffect)(()=>{y(l.map(e=>{var r,l;return{id:e.id,type:"agent",position:null!=(l=null!=(r=f[e.id])?r:A[e.id])?l:{x:0,y:0},data:{agent:e,dim:!1,active:!1}}}))},[l,A,f]);let T=(0,t.useMemo)(()=>new Map(l.filter(e=>"orchestrator"===e.role).map((e,r)=>[e.id,r])),[l]),V=null!=_?_:F,z=e=>{var r,s;return null!=(s=null==(r=l.find(r=>r.id===e))?void 0:r.name)?s:"?"},L=(0,t.useCallback)(async(r,l,s)=>{try{await h.FH.put("/orchestrators/".concat(r,"/workers"),{worker_ids:l}),await i(["agents"]),w(s)}catch(r){w(r instanceof Error?r.message:e("rel.updateFailed"),"err")}},[i,w]),R=(0,t.useCallback)((r,s)=>{let t=l.find(e=>e.id===r);t&&L(r,t.worker_ids.filter(e=>e!==s),e("rel.disconnected",{worker:z(s),orchestrator:t.name}))},[l,L]),Z=(0,t.useCallback)((r,s)=>{let t=l.find(e=>e.id===r);!t||t.worker_ids.includes(s)||L(r,[...t.worker_ids,s],e("rel.connected",{worker:z(s),orchestrator:t.name}))},[l,L]),q=(0,t.useMemo)(()=>l.filter(e=>"orchestrator"===e.role).flatMap(r=>r.worker_ids.map(s=>{var t,a;let i="".concat(r.id,">").concat(s),n=!!V&&(r.id===V||s===V);return{id:i,source:r.id,target:s,type:"link",animated:(null==(t=l.find(e=>e.id===s))?void 0:t.status)==="running",data:{color:p(null!=(a=T.get(r.id))?a:0),dim:!!V&&!n,active:n||E===i,show:n||E===i,label:e("rel.disconnectLabel",{worker:z(s),orchestrator:r.name}),onRemove:()=>R(r.id,s)}}})),[l,V,E,T,R,r]),B=(0,t.useMemo)(()=>{let e=new Set(V?[V]:[]);if(V)for(let r of q)(r.source===V||r.target===V)&&(e.add(r.source),e.add(r.target));return b.map(r=>({...r,selected:r.id===F,data:{...r.data,dim:!!V&&!e.has(r.id),active:r.id===V}}))},[b,q,V,F]),H=(0,t.useCallback)(e=>{y(r=>(0,a._0)(e,r));let r=e.filter(e=>"position"===e.type&&!e.dragging&&e.position);r.length&&N(e=>{let l={...e};for(let e of r)"position"===e.type&&e.position&&(l[e.id]=e.position);return l})},[]),P=l.find(e=>e.id===F),X=l.filter(e=>"orchestrator"===e.role),G=l.filter(e=>"worker"===e.role);return(0,s.jsxs)("div",{className:"page full rel",children:[(0,s.jsxs)("div",{className:"rel-hud",children:[(0,s.jsx)("h1",{children:e("nav.relations")}),(0,s.jsx)("p",{children:e("rel.hud")})]}),(0,s.jsx)("div",{className:"rel-tools",children:(0,s.jsxs)("button",{className:"btn sm",onClick:()=>{N({}),W(e=>e+1),w(e("rel.layoutReset"))},children:[(0,s.jsx)(o.A,{size:14}),e("rel.autoArrange")]})}),u?0===l.length?(0,s.jsx)("div",{className:"rel-empty",children:(0,s.jsx)(m.pp,{title:e("rel.empty.title"),body:e("rel.empty.body")})}):(0,s.jsxs)(a.Gc,{nodes:B,edges:q,nodeTypes:g,edgeTypes:j,onNodesChange:H,onConnect:e=>{e.source&&e.target&&Z(e.source,e.target)},onNodeMouseEnter:(e,r)=>C(r.id),onNodeMouseLeave:()=>C(null),onNodeClick:(e,r)=>O(e=>e===r.id?null:r.id),onPaneClick:()=>O(null),onEdgeMouseEnter:(e,r)=>M(r.id),onEdgeMouseLeave:()=>M(null),fitView:!0,fitViewOptions:{padding:.35,maxZoom:1.1},minZoom:.3,proOptions:{hideAttribution:!0},deleteKeyCode:null,nodesConnectable:!0,children:[(0,s.jsx)(a.VS,{gap:28,color:"var(--line-strong)"}),(0,s.jsx)(a.H2,{showInteractive:!1})]},S):v?(0,s.jsx)("div",{className:"rel-empty",children:(0,s.jsx)(m.lZ,{kind:"err",children:(0,s.jsxs)("div",{className:"row gap-s wrap",children:[(0,s.jsxs)("span",{className:"grow",children:[e("cx.loadFailed")," ",v]}),(0,s.jsx)("button",{className:"btn sm",onClick:()=>void k(),children:e("cx.retry")})]})})}):(0,s.jsx)("div",{className:"rel-empty comb-skel",role:"status","aria-label":e("cx.loading"),children:(0,s.jsx)("div",{className:"skel",style:{width:200,height:120}})}),P&&(0,s.jsxs)("aside",{className:"rel-panel card",children:[(0,s.jsxs)("div",{className:"row gap-l",children:[(0,s.jsx)(m._h,{agent:P}),(0,s.jsxs)("div",{className:"grow",children:[(0,s.jsx)("b",{className:"rel-panel-name",children:P.name}),(0,s.jsx)("div",{className:"muted small",children:e("role.".concat(P.role))})]}),(0,s.jsx)("button",{className:"btn ghost icon sm",onClick:()=>O(null),"aria-label":e("common.close"),children:(0,s.jsx)(n.A,{size:16})})]}),"orchestrator"===P.role?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"eyebrow",children:e("rel.delegatesTo",{count:P.worker_ids.length})}),0===P.worker_ids.length&&(0,s.jsx)("p",{className:"muted small m0",children:e("rel.noWorkers")}),P.worker_ids.map(r=>(0,s.jsxs)("div",{className:"relrow",children:[(0,s.jsx)("span",{className:"grow",children:z(r)}),(0,s.jsx)("button",{className:"btn sm",onClick:()=>R(P.id,r),children:e("rel.disconnect")})]},r)),(0,s.jsxs)("select",{className:"select",value:"",onChange:e=>e.target.value&&Z(P.id,e.target.value),"aria-label":e("rel.connectWorker"),children:[(0,s.jsx)("option",{value:"",children:e("rel.connectWorker")}),G.filter(e=>!P.worker_ids.includes(e.id)).map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"eyebrow",children:e("rel.directedBy")}),0===X.filter(e=>e.worker_ids.includes(P.id)).length&&(0,s.jsx)("p",{className:"muted small m0",children:e("rel.noOrchestrators")}),X.filter(e=>e.worker_ids.includes(P.id)).map(r=>{var l;return(0,s.jsxs)("div",{className:"relrow",children:[(0,s.jsx)("i",{className:"cdot cx-chip-dot",style:{background:p(null!=(l=T.get(r.id))?l:0)}}),(0,s.jsx)("span",{className:"grow",children:r.name}),(0,s.jsx)("button",{className:"btn sm",onClick:()=>R(r.id,P.id),children:e("rel.disconnect")})]},r.id)}),(0,s.jsxs)("select",{className:"select",value:"",onChange:e=>e.target.value&&Z(e.target.value,P.id),"aria-label":e("rel.connectOrchestrator"),children:[(0,s.jsx)("option",{value:"",children:e("rel.connectOrchestrator")}),X.filter(e=>!e.worker_ids.includes(P.id)).map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))]})]})]})]})}}},e=>{e.O(0,[48,986,586,562,839,408,89,358],()=>e(e.s=27949)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[964],{27949:(e,r,l)=>{Promise.resolve().then(l.bind(l,86300))},86300:(e,r,l)=>{"use strict";l.r(r),l.d(r,{default:()=>v});var s=l(94799),t=l(34023),a=l(20831),i=l(15334);l(40117);var n=l(70665),o=l(10964),d=l(48538),c=l(77021),h=l(3749),u=l(47890),m=l(10804),x=l(69654);let p=e=>{let r=u.hg[e%u.hg.length];return"color-mix(in srgb, ".concat(r," calc(100% - var(--series-mix, 0%)), white)")},g={agent:function(e){let{data:r}=e,{t:l}=(0,x.s9)(),t=r.agent;return(0,s.jsxs)("div",{className:"rnode ".concat(r.dim?"dim":""," ").concat(r.active?"active":""),children:["worker"===t.role&&(0,s.jsx)(a.h7,{type:"target",position:i.yX.Top}),(0,s.jsx)(m._h,{agent:t}),(0,s.jsx)("b",{children:t.name}),(0,s.jsx)("small",{children:"orchestrator"===t.role?l("role.orchestrator"):u.xq[t.provider].short}),"orchestrator"===t.role&&(0,s.jsx)(a.h7,{type:"source",position:i.yX.Bottom})]})}},j={link:function(e){let{id:r,sourceX:l,sourceY:t,targetX:o,targetY:d,sourcePosition:c,targetPosition:h,data:u}=e,[m,x,p]=(0,i.Fp)({sourceX:l,sourceY:t,targetX:o,targetY:d,sourcePosition:c,targetPosition:h,curvature:.35});return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(a.tE,{id:r,path:m,interactionWidth:26,style:{stroke:u.color,strokeWidth:u.active?4:2.5,opacity:u.dim?.15:1,transition:"opacity .15s, stroke-width .15s"}}),u.show&&(0,s.jsx)(a.rV,{children:(0,s.jsx)("button",{className:"edge-x nodrag nopan",style:{transform:"translate(-50%, -50%) translate(".concat(x,"px, ").concat(p,"px)")},onClick:u.onRemove,"aria-label":u.label,title:u.label,children:(0,s.jsx)(n.A,{size:13,strokeWidth:3})})})]})}};function v(){let{t:e,locale:r}=(0,x.s9)(),{agents:l,refresh:i,ready:u,error:v,retry:k}=(0,d.q5)(),w=(0,m.dj)(),[f,N]=(0,c.ud)("hive-rel-pos-v2",{}),[b,y]=(0,t.useState)([]),[_,C]=(0,t.useState)(null),[E,M]=(0,t.useState)(null),[F,O]=(0,t.useState)(null),[S,W]=(0,t.useState)(0),A=(0,t.useMemo)(()=>(function(e){let r=e.filter(e=>"orchestrator"===e.role),l=e.filter(e=>"worker"===e.role),s=e=>r.find(r=>r.worker_ids.includes(e.id)),t={},a=0;for(let e of r){let r=l.filter(r=>{var l;return(null==(l=s(r))?void 0:l.id)===e.id}),i=Math.max(1,r.length);r.forEach((e,r)=>t[e.id]={x:a+190*r,y:280}),t[e.id]={x:a+(i-1)*190/2,y:0},a+=190*i+114}return l.filter(e=>!s(e)).forEach((e,r)=>t[e.id]={x:a+190*r,y:280}),t})(l),[l]);(0,t.useEffect)(()=>{y(l.map(e=>{var r,l;return{id:e.id,type:"agent",position:null!=(l=null!=(r=f[e.id])?r:A[e.id])?l:{x:0,y:0},data:{agent:e,dim:!1,active:!1}}}))},[l,A,f]);let T=(0,t.useMemo)(()=>new Map(l.filter(e=>"orchestrator"===e.role).map((e,r)=>[e.id,r])),[l]),V=null!=_?_:F,z=e=>{var r,s;return null!=(s=null==(r=l.find(r=>r.id===e))?void 0:r.name)?s:"?"},L=(0,t.useCallback)(async(r,l,s)=>{try{await h.FH.put("/orchestrators/".concat(r,"/workers"),{worker_ids:l}),await i(["agents"]),w(s)}catch(r){w(r instanceof Error?r.message:e("rel.updateFailed"),"err")}},[i,w]),R=(0,t.useCallback)((r,s)=>{let t=l.find(e=>e.id===r);t&&L(r,t.worker_ids.filter(e=>e!==s),e("rel.disconnected",{worker:z(s),orchestrator:t.name}))},[l,L]),Z=(0,t.useCallback)((r,s)=>{let t=l.find(e=>e.id===r);!t||t.worker_ids.includes(s)||L(r,[...t.worker_ids,s],e("rel.connected",{worker:z(s),orchestrator:t.name}))},[l,L]),q=(0,t.useMemo)(()=>l.filter(e=>"orchestrator"===e.role).flatMap(r=>r.worker_ids.map(s=>{var t,a;let i="".concat(r.id,">").concat(s),n=!!V&&(r.id===V||s===V);return{id:i,source:r.id,target:s,type:"link",animated:(null==(t=l.find(e=>e.id===s))?void 0:t.status)==="running",data:{color:p(null!=(a=T.get(r.id))?a:0),dim:!!V&&!n,active:n||E===i,show:n||E===i,label:e("rel.disconnectLabel",{worker:z(s),orchestrator:r.name}),onRemove:()=>R(r.id,s)}}})),[l,V,E,T,R,r]),B=(0,t.useMemo)(()=>{let e=new Set(V?[V]:[]);if(V)for(let r of q)(r.source===V||r.target===V)&&(e.add(r.source),e.add(r.target));return b.map(r=>({...r,selected:r.id===F,data:{...r.data,dim:!!V&&!e.has(r.id),active:r.id===V}}))},[b,q,V,F]),H=(0,t.useCallback)(e=>{y(r=>(0,a._0)(e,r));let r=e.filter(e=>"position"===e.type&&!e.dragging&&e.position);r.length&&N(e=>{let l={...e};for(let e of r)"position"===e.type&&e.position&&(l[e.id]=e.position);return l})},[]),P=l.find(e=>e.id===F),X=l.filter(e=>"orchestrator"===e.role),G=l.filter(e=>"worker"===e.role);return(0,s.jsxs)("div",{className:"page full rel",children:[(0,s.jsxs)("div",{className:"rel-hud",children:[(0,s.jsx)("h1",{children:e("nav.relations")}),(0,s.jsx)("p",{children:e("rel.hud")})]}),(0,s.jsx)("div",{className:"rel-tools",children:(0,s.jsxs)("button",{className:"btn sm",onClick:()=>{N({}),W(e=>e+1),w(e("rel.layoutReset"))},children:[(0,s.jsx)(o.A,{size:14}),e("rel.autoArrange")]})}),u?0===l.length?(0,s.jsx)("div",{className:"rel-empty",children:(0,s.jsx)(m.pp,{title:e("rel.empty.title"),body:e("rel.empty.body")})}):(0,s.jsxs)(a.Gc,{nodes:B,edges:q,nodeTypes:g,edgeTypes:j,onNodesChange:H,onConnect:e=>{e.source&&e.target&&Z(e.source,e.target)},onNodeMouseEnter:(e,r)=>C(r.id),onNodeMouseLeave:()=>C(null),onNodeClick:(e,r)=>O(e=>e===r.id?null:r.id),onPaneClick:()=>O(null),onEdgeMouseEnter:(e,r)=>M(r.id),onEdgeMouseLeave:()=>M(null),fitView:!0,fitViewOptions:{padding:.35,maxZoom:1.1},minZoom:.3,proOptions:{hideAttribution:!0},deleteKeyCode:null,nodesConnectable:!0,children:[(0,s.jsx)(a.VS,{gap:28,color:"var(--line-strong)"}),(0,s.jsx)(a.H2,{showInteractive:!1})]},S):v?(0,s.jsx)("div",{className:"rel-empty",children:(0,s.jsx)(m.lZ,{kind:"err",children:(0,s.jsxs)("div",{className:"row gap-s wrap",children:[(0,s.jsxs)("span",{className:"grow",children:[e("cx.loadFailed")," ",v]}),(0,s.jsx)("button",{className:"btn sm",onClick:()=>void k(),children:e("cx.retry")})]})})}):(0,s.jsx)("div",{className:"rel-empty comb-skel",role:"status","aria-label":e("cx.loading"),children:(0,s.jsx)("div",{className:"skel",style:{width:200,height:120}})}),P&&(0,s.jsxs)("aside",{className:"rel-panel card",children:[(0,s.jsxs)("div",{className:"row gap-l",children:[(0,s.jsx)(m._h,{agent:P}),(0,s.jsxs)("div",{className:"grow",children:[(0,s.jsx)("b",{className:"rel-panel-name",children:P.name}),(0,s.jsx)("div",{className:"muted small",children:e("role.".concat(P.role))})]}),(0,s.jsx)("button",{className:"btn ghost icon sm",onClick:()=>O(null),"aria-label":e("common.close"),children:(0,s.jsx)(n.A,{size:16})})]}),"orchestrator"===P.role?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"eyebrow",children:e("rel.delegatesTo",{count:P.worker_ids.length})}),0===P.worker_ids.length&&(0,s.jsx)("p",{className:"muted small m0",children:e("rel.noWorkers")}),P.worker_ids.map(r=>(0,s.jsxs)("div",{className:"relrow",children:[(0,s.jsx)("span",{className:"grow",children:z(r)}),(0,s.jsx)("button",{className:"btn sm",onClick:()=>R(P.id,r),children:e("rel.disconnect")})]},r)),(0,s.jsxs)("select",{className:"select",value:"",onChange:e=>e.target.value&&Z(P.id,e.target.value),"aria-label":e("rel.connectWorker"),children:[(0,s.jsx)("option",{value:"",children:e("rel.connectWorker")}),G.filter(e=>!P.worker_ids.includes(e.id)).map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"eyebrow",children:e("rel.directedBy")}),0===X.filter(e=>e.worker_ids.includes(P.id)).length&&(0,s.jsx)("p",{className:"muted small m0",children:e("rel.noOrchestrators")}),X.filter(e=>e.worker_ids.includes(P.id)).map(r=>{var l;return(0,s.jsxs)("div",{className:"relrow",children:[(0,s.jsx)("i",{className:"cdot cx-chip-dot",style:{background:p(null!=(l=T.get(r.id))?l:0)}}),(0,s.jsx)("span",{className:"grow",children:r.name}),(0,s.jsx)("button",{className:"btn sm",onClick:()=>R(r.id,P.id),children:e("rel.disconnect")})]},r.id)}),(0,s.jsxs)("select",{className:"select",value:"",onChange:e=>e.target.value&&Z(e.target.value,P.id),"aria-label":e("rel.connectOrchestrator"),children:[(0,s.jsx)("option",{value:"",children:e("rel.connectOrchestrator")}),X.filter(e=>!e.worker_ids.includes(P.id)).map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))]})]})]})]})}}},e=>{e.O(0,[48,986,586,562,281,408,89,358],()=>e(e.s=27949)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[594],{72317:(e,s,u)=>{Promise.resolve().then(u.bind(u,75750))},75750:(e,s,u)=>{"use strict";u.r(s),u.d(s,{default:()=>_});var n=u(94799),r=u(34023),t=u(84491);function _(e){let{params:s}=e,{id:u}=(0,r.use)(s);return(0,n.jsx)(t.D,{id:u})}}},e=>{e.O(0,[586,706,837,486,581,839,517,350,291,844,30,491,408,89,358],()=>e(e.s=72317)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[594],{72317:(e,s,u)=>{Promise.resolve().then(u.bind(u,75750))},75750:(e,s,u)=>{"use strict";u.r(s),u.d(s,{default:()=>_});var n=u(94799),r=u(34023),t=u(84491);function _(e){let{params:s}=e,{id:u}=(0,r.use)(s);return(0,n.jsx)(t.D,{id:u})}}},e=>{e.O(0,[586,706,837,304,581,281,517,350,291,844,30,491,408,89,358],()=>e(e.s=72317)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[752],{57933:(e,s,t)=>{Promise.resolve().then(t.bind(t,89976))},89976:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>u});var r=t(94799),i=t(34023),n=t(48538),o=t(84491);function u(){var e;let{objects:s,ready:t}=(0,n.o0)(),u=null==(e=s[0])?void 0:e.id;return(0,i.useEffect)(()=>{t&&u&&window.history.replaceState(window.history.state,"","/resources/".concat(u))},[t,u]),(0,r.jsx)(o.D,{id:u})}}},e=>{e.O(0,[586,706,837,486,581,839,517,350,291,844,30,491,408,89,358],()=>e(e.s=57933)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[752],{57933:(e,s,t)=>{Promise.resolve().then(t.bind(t,89976))},89976:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>u});var r=t(94799),i=t(34023),n=t(48538),o=t(84491);function u(){var e;let{objects:s,ready:t}=(0,n.o0)(),u=null==(e=s[0])?void 0:e.id;return(0,i.useEffect)(()=>{t&&u&&window.history.replaceState(window.history.state,"","/resources/".concat(u))},[t,u]),(0,r.jsx)(o.D,{id:u})}}},e=>{e.O(0,[586,706,837,304,581,281,517,350,291,844,30,491,408,89,358],()=>e(e.s=57933)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[547],{14676:(e,s,t)=>{Promise.resolve().then(t.bind(t,95339))},17395:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});let n=(0,t(74955).A)("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]])},32480:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});let n=(0,t(74955).A)("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]])},37064:(e,s,t)=>{"use strict";t.d(s,{n:()=>a});var n=t(34023);function a(e,s){let{enabled:t=!0,pauseHidden:a=!0,immediate:c=!0,onError:d}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},l=(0,n.useRef)(e);l.current=e;let i=(0,n.useRef)(d);i.current=d,(0,n.useEffect)(()=>{let e;if(!t)return;let n=!1,d=0,r=!1,h=()=>{clearTimeout(e),n||(e=setTimeout(()=>void u(),s*Math.min(6,2**d)))},u=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!n&&!r){if(!e&&a&&"undefined"!=typeof document&&"hidden"===document.visibilityState)return void h();r=!0;try{await l.current(),d=0}catch(e){var s;0==d++&&(null==(s=i.current)||s.call(i,e))}finally{r=!1,h()}}},o=()=>{"visible"!==document.visibilityState||r||(clearTimeout(e),u())};return c?u(!0):h(),a&&document.addEventListener("visibilitychange",o),()=>{n=!0,clearTimeout(e),document.removeEventListener("visibilitychange",o)}},[s,t,a,c])}},47405:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});let n=(0,t(74955).A)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]])},54234:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});let n=(0,t(74955).A)("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]])},95339:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>k});var n=t(94799),a=t(34023),c=t(54234),d=t(17395),l=t(47405),i=t(97356),r=t(32480),h=t(12349),u=t(3749),o=t(48538),m=t(37064),x=t(56072),p=t(47890),j=t(69654),v=t(86606);let y=["failed","skipped_reassigned"];function k(){var e;let{t:s}=(0,j.s9)(),t=(0,v.dj)(),{agents:k,ready:f}=(0,o.q5)(),[b,g]=(0,a.useState)(null),[N,_]=(0,a.useState)(null),[w,A]=(0,a.useState)([]),[M,z]=(0,a.useState)(null),[C,S]=(0,a.useState)(!1),F=(0,a.useCallback)(async()=>{g((await u.FH.get("/schedules")).sort((e,s)=>{var t,n;return(null!=(t=e.next_due)?t:1/0)-(null!=(n=s.next_due)?n:1/0)})),S(!1)},[]);(0,m.n)(F,1e4,{onError:()=>S(!0)});let E=null==b||null==(e=b.find(e=>e.id===N))?void 0:e.fire_count;(0,a.useEffect)(()=>{N&&u.FH.get("/schedules/".concat(N,"/runs")).then(A).catch(()=>A([]))},[N,E]);let T=async e=>{await u.FH.del("/schedules/".concat(e.id)),await F()};return(0,n.jsxs)("div",{className:"page",children:[(0,n.jsx)("div",{className:"page-head",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{children:s("nav.schedules")}),(0,n.jsx)("p",{children:s("sched.subtitle")})]})}),C&&(0,n.jsx)(v.lZ,{kind:"err",children:s("fa.sched.loadFailed")}),f&&b&&0===b.length?(0,n.jsx)(v.pp,{icon:(0,n.jsx)(c.A,{size:28}),title:s("sched.empty.title"),body:s("sched.empty.body")}):(0,n.jsx)("div",{className:"sched-list",children:(null!=b?b:[]).map(e=>{let a=k.find(s=>s.id===e.agent_id),c="once"!==e.kind;return(0,n.jsxs)("div",{className:"card card-pad sched ".concat(e.enabled?"":"off"),children:[(0,n.jsxs)("div",{className:"row gap-s",children:[a?(0,n.jsx)(v._h,{agent:a,size:"sm"}):null,(0,n.jsx)("b",{children:e.agent_name}),(0,n.jsx)("span",{className:"chip",children:s("sched.kind.".concat(e.kind))}),(0,n.jsx)("span",{className:"chip",children:e.thread_id?e.place||"chat":s("sched.where.web")}),!e.enabled&&(0,n.jsx)("span",{className:"chip warn",children:s("sched.paused")}),(0,n.jsx)("span",{className:"grow"}),c&&(0,n.jsx)("button",{className:"btn ghost sm",onClick:()=>{u.FH.patch("/schedules/".concat(e.id),{enabled:!e.enabled}).then(F).catch(e=>t(e.message,"err"))},children:e.enabled?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(d.A,{size:14}),s("sched.pause")]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(l.A,{size:14}),s("sched.resume")]})}),(0,n.jsx)("button",{className:"btn ghost sm","aria-label":s("common.delete"),onClick:()=>z(e),children:(0,n.jsx)(i.A,{size:14})})]}),(c||"watch"===e.kind)&&(0,n.jsx)("div",{className:"small",children:(0,n.jsx)("code",{children:e.description})}),(0,n.jsx)("p",{className:"note",children:e.note}),(0,n.jsxs)("div",{className:"meta muted small",children:[(0,n.jsxs)("span",{children:[s("watch"===e.kind?"sched.until":"sched.next"),": ",e.next_due?"".concat((0,x.v7)(e.next_due)," \xb7 ").concat(s("sched.in",{when:(e=>{let t=Math.max(1,Math.round((e-Date.now())/6e4));if(t<60)return s("sched.minShort",{count:t});let n=Math.round(t/60);return n<48?s("sched.hourShort",{count:n}):s("sched.dayShort",{count:Math.round(n/24)})})(e.next_due)})):s("sched.never")]}),c&&e.last_status&&(0,n.jsxs)("span",{children:[s("sched.last"),": ",(0,n.jsx)("span",{className:"chip ".concat(y.includes(e.last_status)?"warn":""),children:s("sched.status.".concat(e.last_status))})," ",(0,p.KN)(e.last_fired_at)]}),c&&(0,n.jsx)("span",{children:s("sched.runs",{count:e.fire_count})}),c&&(0,n.jsx)("button",{className:"linkbtn",onClick:()=>_(N===e.id?null:e.id),children:N===e.id?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(r.A,{size:13})," ",s("sched.hide")]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(h.A,{size:13})," ",s("sched.history")]})})]}),N===e.id&&(0,n.jsx)("div",{className:"sched-runs",children:0===w.length?(0,n.jsx)("span",{className:"muted",children:s("sched.noRuns")}):w.map(e=>(0,n.jsxs)("div",{className:"r",children:[(0,n.jsx)("span",{className:"muted",children:(0,x.v7)(e.fired_at)}),(0,n.jsx)("span",{className:"chip ".concat(y.includes(e.status)?"warn":""),children:s("sched.status.".concat(e.status))}),e.duration_ms?(0,n.jsxs)("span",{className:"muted",children:[Math.round(e.duration_ms/1e3)," s"]}):null,e.detail?(0,n.jsx)("span",{className:"muted",children:e.detail}):null]},e.id))})]},e.id)})}),M&&(0,n.jsx)(v.TM,{danger:!0,title:s("sched.deleteTitle"),body:s("sched.deleteBody"),confirmLabel:s("common.delete"),onConfirm:()=>T(M),onClose:()=>z(null)})]})}},97356:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});let n=(0,t(74955).A)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])}},e=>{e.O(0,[586,839,408,89,358],()=>e(e.s=14676)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[547],{14676:(e,s,t)=>{Promise.resolve().then(t.bind(t,95339))},17395:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});let n=(0,t(74955).A)("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]])},32480:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});let n=(0,t(74955).A)("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]])},37064:(e,s,t)=>{"use strict";t.d(s,{n:()=>a});var n=t(34023);function a(e,s){let{enabled:t=!0,pauseHidden:a=!0,immediate:c=!0,onError:d}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},l=(0,n.useRef)(e);l.current=e;let i=(0,n.useRef)(d);i.current=d,(0,n.useEffect)(()=>{let e;if(!t)return;let n=!1,d=0,r=!1,h=()=>{clearTimeout(e),n||(e=setTimeout(()=>void u(),s*Math.min(6,2**d)))},u=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!n&&!r){if(!e&&a&&"undefined"!=typeof document&&"hidden"===document.visibilityState)return void h();r=!0;try{await l.current(),d=0}catch(e){var s;0==d++&&(null==(s=i.current)||s.call(i,e))}finally{r=!1,h()}}},o=()=>{"visible"!==document.visibilityState||r||(clearTimeout(e),u())};return c?u(!0):h(),a&&document.addEventListener("visibilitychange",o),()=>{n=!0,clearTimeout(e),document.removeEventListener("visibilitychange",o)}},[s,t,a,c])}},47405:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});let n=(0,t(74955).A)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]])},54234:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});let n=(0,t(74955).A)("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]])},95339:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>k});var n=t(94799),a=t(34023),c=t(54234),d=t(17395),l=t(47405),i=t(97356),r=t(32480),h=t(12349),u=t(3749),o=t(48538),m=t(37064),x=t(56072),p=t(47890),j=t(69654),v=t(10804);let y=["failed","skipped_reassigned"];function k(){var e;let{t:s}=(0,j.s9)(),t=(0,v.dj)(),{agents:k,ready:f}=(0,o.q5)(),[b,g]=(0,a.useState)(null),[N,_]=(0,a.useState)(null),[w,A]=(0,a.useState)([]),[M,z]=(0,a.useState)(null),[C,S]=(0,a.useState)(!1),F=(0,a.useCallback)(async()=>{g((await u.FH.get("/schedules")).sort((e,s)=>{var t,n;return(null!=(t=e.next_due)?t:1/0)-(null!=(n=s.next_due)?n:1/0)})),S(!1)},[]);(0,m.n)(F,1e4,{onError:()=>S(!0)});let E=null==b||null==(e=b.find(e=>e.id===N))?void 0:e.fire_count;(0,a.useEffect)(()=>{N&&u.FH.get("/schedules/".concat(N,"/runs")).then(A).catch(()=>A([]))},[N,E]);let T=async e=>{await u.FH.del("/schedules/".concat(e.id)),await F()};return(0,n.jsxs)("div",{className:"page",children:[(0,n.jsx)("div",{className:"page-head",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{children:s("nav.schedules")}),(0,n.jsx)("p",{children:s("sched.subtitle")})]})}),C&&(0,n.jsx)(v.lZ,{kind:"err",children:s("fa.sched.loadFailed")}),f&&b&&0===b.length?(0,n.jsx)(v.pp,{icon:(0,n.jsx)(c.A,{size:28}),title:s("sched.empty.title"),body:s("sched.empty.body")}):(0,n.jsx)("div",{className:"sched-list",children:(null!=b?b:[]).map(e=>{let a=k.find(s=>s.id===e.agent_id),c="once"!==e.kind;return(0,n.jsxs)("div",{className:"card card-pad sched ".concat(e.enabled?"":"off"),children:[(0,n.jsxs)("div",{className:"row gap-s",children:[a?(0,n.jsx)(v._h,{agent:a,size:"sm"}):null,(0,n.jsx)("b",{children:e.agent_name}),(0,n.jsx)("span",{className:"chip",children:s("sched.kind.".concat(e.kind))}),(0,n.jsx)("span",{className:"chip",children:e.thread_id?e.place||"chat":s("sched.where.web")}),!e.enabled&&(0,n.jsx)("span",{className:"chip warn",children:s("sched.paused")}),(0,n.jsx)("span",{className:"grow"}),c&&(0,n.jsx)("button",{className:"btn ghost sm",onClick:()=>{u.FH.patch("/schedules/".concat(e.id),{enabled:!e.enabled}).then(F).catch(e=>t(e.message,"err"))},children:e.enabled?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(d.A,{size:14}),s("sched.pause")]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(l.A,{size:14}),s("sched.resume")]})}),(0,n.jsx)("button",{className:"btn ghost sm","aria-label":s("common.delete"),onClick:()=>z(e),children:(0,n.jsx)(i.A,{size:14})})]}),(c||"watch"===e.kind)&&(0,n.jsx)("div",{className:"small",children:(0,n.jsx)("code",{children:e.description})}),(0,n.jsx)("p",{className:"note",children:e.note}),(0,n.jsxs)("div",{className:"meta muted small",children:[(0,n.jsxs)("span",{children:[s("watch"===e.kind?"sched.until":"sched.next"),": ",e.next_due?"".concat((0,x.v7)(e.next_due)," \xb7 ").concat(s("sched.in",{when:(e=>{let t=Math.max(1,Math.round((e-Date.now())/6e4));if(t<60)return s("sched.minShort",{count:t});let n=Math.round(t/60);return n<48?s("sched.hourShort",{count:n}):s("sched.dayShort",{count:Math.round(n/24)})})(e.next_due)})):s("sched.never")]}),c&&e.last_status&&(0,n.jsxs)("span",{children:[s("sched.last"),": ",(0,n.jsx)("span",{className:"chip ".concat(y.includes(e.last_status)?"warn":""),children:s("sched.status.".concat(e.last_status))})," ",(0,p.KN)(e.last_fired_at)]}),c&&(0,n.jsx)("span",{children:s("sched.runs",{count:e.fire_count})}),c&&(0,n.jsx)("button",{className:"linkbtn",onClick:()=>_(N===e.id?null:e.id),children:N===e.id?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(r.A,{size:13})," ",s("sched.hide")]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(h.A,{size:13})," ",s("sched.history")]})})]}),N===e.id&&(0,n.jsx)("div",{className:"sched-runs",children:0===w.length?(0,n.jsx)("span",{className:"muted",children:s("sched.noRuns")}):w.map(e=>(0,n.jsxs)("div",{className:"r",children:[(0,n.jsx)("span",{className:"muted",children:(0,x.v7)(e.fired_at)}),(0,n.jsx)("span",{className:"chip ".concat(y.includes(e.status)?"warn":""),children:s("sched.status.".concat(e.status))}),e.duration_ms?(0,n.jsxs)("span",{className:"muted",children:[Math.round(e.duration_ms/1e3)," s"]}):null,e.detail?(0,n.jsx)("span",{className:"muted",children:e.detail}):null]},e.id))})]},e.id)})}),M&&(0,n.jsx)(v.TM,{danger:!0,title:s("sched.deleteTitle"),body:s("sched.deleteBody"),confirmLabel:s("common.delete"),onConfirm:()=>T(M),onClose:()=>z(null)})]})}},97356:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});let n=(0,t(74955).A)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])}},e=>{e.O(0,[586,281,408,89,358],()=>e(e.s=14676)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[898],{15065:(e,s,n)=>{Promise.resolve().then(n.bind(n,25382))},25382:(e,s,n)=>{"use strict";n.r(s),n.d(s,{default:()=>p});var t=n(94799),a=n(41463),l=n.n(a),i=n(34023),r=n(3749),c=n(48538),o=n(37064),d=n(61748),u=n(51705),m=n(47890),h=n(56072),g=n(86606),v=n(69654);function p(){let{t:e,locale:s}=(0,v.s9)(),{agents:n}=(0,c.q5)(),[a,p]=(0,i.useState)(null),[x,j]=(0,i.useState)(""),[f,w]=(0,i.useState)("all"),[N,_]=(0,d.Z)("session",""),[y,b]=(0,i.useState)(!1),[k,E]=(0,i.useState)(null),[S,L]=(0,i.useState)(0),[C,R]=(0,i.useState)(100),M=(0,i.useRef)(null),P=null===a||a.some(e=>e.pending);(0,o.n)(async()=>{p(await r.FH.get("/sessions")),b(!1)},2500,{enabled:P,onError:()=>{b(!0),p(e=>null!=e?e:[])}});let q=(0,i.useMemo)(()=>N&&(null==a?void 0:a.find(e=>e.session_id===N))||null,[a,N]);(0,i.useEffect)(()=>{R(100)},[null==q?void 0:q.session_id]),(0,i.useEffect)(()=>{let e=!1;return q?(r.FH.get("/agents/".concat(q.agent_id,"/history?session=").concat(encodeURIComponent(q.session_id),"&limit=").concat(C)).then(s=>{var n;e||(E(s.messages),L(null!=(n=s.total)?n:s.messages.length))}).catch(()=>!e&&E([])),()=>{e=!0}):void E(null)},[null==q?void 0:q.agent_id,null==q?void 0:q.session_id,C]),(0,i.useEffect)(()=>{k&&100===C&&M.current&&(M.current.scrollTop=M.current.scrollHeight)},[k,C]);let F=(0,i.useMemo)(()=>(null!=a?a:[]).filter(e=>("all"===f||e.provider===f)&&(!x||"".concat(e.agent_name," ").concat(e.preview," ").concat(e.cwd).toLowerCase().includes(x.toLowerCase()))),[a,x,f]),O=(0,i.useMemo)(()=>{let e=new Map;for(let n of F){var s;let t=new Date(n.last_seen).toLocaleDateString((0,v.VR)(),{weekday:"long",day:"numeric",month:"short"});e.set(t,[...null!=(s=e.get(t))?s:[],n])}return[...e.entries()]},[F,s]),T=q&&n.find(e=>e.id===q.agent_id),Z=k?S-k.length:0;return(0,t.jsx)("div",{className:"page full",children:!y||(null==a?void 0:a.length)?a&&!a.length?(0,t.jsx)("div",{className:"m-xl",children:(0,t.jsx)(g.pp,{title:e("sessions.empty.title"),body:e("sessions.empty.body"),action:(0,t.jsx)(l(),{className:"btn primary",href:"/agents",children:e("sessions.empty.go")})})}):(0,t.jsxs)("div",{className:"sk-ws sx-ws",children:[(0,t.jsxs)("aside",{className:"switcher","aria-label":e("nav.sessions"),children:[(0,t.jsxs)("div",{className:"switcher-head",children:[(0,t.jsx)("b",{className:"fa-title",children:e("nav.sessions")}),(0,t.jsx)(g.DO,{value:x,onChange:j,placeholder:e("sessions.searchPlaceholder"),label:e("sessions.searchLabel")}),(0,t.jsx)(g.$q,{value:f,onChange:w,options:[{id:"all",label:e("common.all")},...Object.keys(m.xq).map(e=>({id:e,label:m.xq[e].short}))]})]}),(0,t.jsxs)("div",{className:"switcher-list",children:[null===a&&(0,t.jsx)("p",{className:"muted small pad-m",children:e("sessions.reading")}),O.map(s=>{let[n,a]=s;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"switcher-group",children:[n,(0,t.jsx)("span",{children:a.length})]}),a.map(s=>{var n;return(0,t.jsxs)("button",{className:"sk-item","aria-current":(null==q?void 0:q.session_id)===s.session_id,onClick:()=>_(s.session_id),children:[(0,t.jsxs)("div",{className:"row gap-xs",children:[(0,t.jsx)("b",{className:"grow",children:s.agent_name}),(0,t.jsx)(g.dJ,{provider:s.provider}),s.current&&(0,t.jsx)("span",{className:"chip honey",children:e("sessions.current")})]}),(0,t.jsx)("span",{className:"sk-desc",children:s.preview||(s.pending?e("sessions.counting"):s.task||e("sessions.emptySession"))}),(0,t.jsxs)("span",{className:"sk-meta",children:[(0,m.KN)(s.last_seen),"delegation"===s.kind&&" \xb7 ".concat(e("sessions.delegatedBy",{name:null!=(n=s.from_name)?n:e("chat.anOrchestrator")})),s.pending&&!s.message_count?" \xb7 …":" \xb7 ".concat(e("sessions.messages",{count:s.message_count})),(0,h.RP)(s.usage)>0&&" \xb7 ".concat((0,h.yj)((0,h.RP)(s.usage))," ").concat(e("stats.tokens")),null!==s.cost&&" \xb7 ≈ ".concat((0,h.F0)(s.cost))]})]},s.agent_id+s.session_id)})]},n)}),a&&a.length>0&&!F.length&&(0,t.jsx)("p",{className:"muted small pad-m",children:e("sessions.noMatch")})]})]}),q?(0,t.jsxs)("section",{className:"sk-main",children:[(0,t.jsxs)("header",{className:"sx-head",children:[(0,t.jsxs)("div",{className:"grow",children:[(0,t.jsx)("b",{className:"fa-title lg",children:q.agent_name}),(0,t.jsxs)("div",{className:"muted small mono ellipsis",children:[(0,m._1)(q.cwd)," \xb7 ",q.session_id]})]}),T&&(0,t.jsx)(l(),{className:"btn sm primary",href:"/agents/".concat(T.id),children:e("sessions.openAgent")})]}),(0,t.jsx)("div",{className:"transcript col sx-transcript",ref:M,children:null===k?(0,t.jsx)("p",{className:"muted",children:e("sessions.loading")}):0===k.length?(0,t.jsx)("p",{className:"muted",children:e("sessions.noMessages")}):(0,t.jsxs)(t.Fragment,{children:[Z>0&&(0,t.jsx)("button",{className:"btn sm push-c",onClick:()=>R(C+200),children:e("sessions.older",{count:Z})}),(0,t.jsx)(u.BZ,{msgs:k,agent:{id:q.agent_id,name:q.agent_name,provider:q.provider,role:q.agent_role}})]})})]}):(0,t.jsx)("section",{className:"sk-main sk-none",children:(0,t.jsx)("p",{className:"muted",children:e("sessions.select")})})]}):(0,t.jsx)("div",{className:"m-xl",children:(0,t.jsx)(g.lZ,{kind:"err",children:e("fa.sessions.loadFailed")})})})}},37064:(e,s,n)=>{"use strict";n.d(s,{n:()=>a});var t=n(34023);function a(e,s){let{enabled:n=!0,pauseHidden:a=!0,immediate:l=!0,onError:i}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=(0,t.useRef)(e);r.current=e;let c=(0,t.useRef)(i);c.current=i,(0,t.useEffect)(()=>{let e;if(!n)return;let t=!1,i=0,o=!1,d=()=>{clearTimeout(e),t||(e=setTimeout(()=>void u(),s*Math.min(6,2**i)))},u=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!t&&!o){if(!e&&a&&"undefined"!=typeof document&&"hidden"===document.visibilityState)return void d();o=!0;try{await r.current(),i=0}catch(e){var s;0==i++&&(null==(s=c.current)||s.call(c,e))}finally{o=!1,d()}}},m=()=>{"visible"!==document.visibilityState||o||(clearTimeout(e),u())};return l?u(!0):d(),a&&document.addEventListener("visibilitychange",m),()=>{t=!0,clearTimeout(e),document.removeEventListener("visibilitychange",m)}},[s,n,a,l])}},61748:(e,s,n)=>{"use strict";n.d(s,{Z:()=>l});var t=n(34023);let a="hive-am:query";function l(e,s){let[n,l]=(0,t.useState)(s);return(0,t.useEffect)(()=>{let n=()=>{var n;return l(null!=(n=new URLSearchParams(location.search).get(e))?n:s)};return n(),window.addEventListener("popstate",n),window.addEventListener(a,n),()=>{window.removeEventListener("popstate",n),window.removeEventListener(a,n)}},[e,s]),[n,(0,t.useCallback)(n=>{let t=new URL(location.href);n===s?t.searchParams.delete(e):t.searchParams.set(e,n),history.replaceState(history.state,"",t),l(n),window.dispatchEvent(new Event(a))},[e,s])]}}},e=>{e.O(0,[586,706,176,839,350,705,408,89,358],()=>e(e.s=15065)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[898],{15065:(e,s,n)=>{Promise.resolve().then(n.bind(n,25382))},25382:(e,s,n)=>{"use strict";n.r(s),n.d(s,{default:()=>p});var t=n(94799),a=n(41463),l=n.n(a),i=n(34023),r=n(3749),c=n(48538),o=n(37064),d=n(61748),u=n(51705),m=n(47890),h=n(56072),g=n(10804),v=n(69654);function p(){let{t:e,locale:s}=(0,v.s9)(),{agents:n}=(0,c.q5)(),[a,p]=(0,i.useState)(null),[x,j]=(0,i.useState)(""),[f,w]=(0,i.useState)("all"),[N,_]=(0,d.Z)("session",""),[y,b]=(0,i.useState)(!1),[k,E]=(0,i.useState)(null),[S,L]=(0,i.useState)(0),[C,R]=(0,i.useState)(100),M=(0,i.useRef)(null),P=null===a||a.some(e=>e.pending);(0,o.n)(async()=>{p(await r.FH.get("/sessions")),b(!1)},2500,{enabled:P,onError:()=>{b(!0),p(e=>null!=e?e:[])}});let q=(0,i.useMemo)(()=>N&&(null==a?void 0:a.find(e=>e.session_id===N))||null,[a,N]);(0,i.useEffect)(()=>{R(100)},[null==q?void 0:q.session_id]),(0,i.useEffect)(()=>{let e=!1;return q?(r.FH.get("/agents/".concat(q.agent_id,"/history?session=").concat(encodeURIComponent(q.session_id),"&limit=").concat(C)).then(s=>{var n;e||(E(s.messages),L(null!=(n=s.total)?n:s.messages.length))}).catch(()=>!e&&E([])),()=>{e=!0}):void E(null)},[null==q?void 0:q.agent_id,null==q?void 0:q.session_id,C]),(0,i.useEffect)(()=>{k&&100===C&&M.current&&(M.current.scrollTop=M.current.scrollHeight)},[k,C]);let F=(0,i.useMemo)(()=>(null!=a?a:[]).filter(e=>("all"===f||e.provider===f)&&(!x||"".concat(e.agent_name," ").concat(e.preview," ").concat(e.cwd).toLowerCase().includes(x.toLowerCase()))),[a,x,f]),O=(0,i.useMemo)(()=>{let e=new Map;for(let n of F){var s;let t=new Date(n.last_seen).toLocaleDateString((0,v.VR)(),{weekday:"long",day:"numeric",month:"short"});e.set(t,[...null!=(s=e.get(t))?s:[],n])}return[...e.entries()]},[F,s]),T=q&&n.find(e=>e.id===q.agent_id),Z=k?S-k.length:0;return(0,t.jsx)("div",{className:"page full",children:!y||(null==a?void 0:a.length)?a&&!a.length?(0,t.jsx)("div",{className:"m-xl",children:(0,t.jsx)(g.pp,{title:e("sessions.empty.title"),body:e("sessions.empty.body"),action:(0,t.jsx)(l(),{className:"btn primary",href:"/agents",children:e("sessions.empty.go")})})}):(0,t.jsxs)("div",{className:"sk-ws sx-ws",children:[(0,t.jsxs)("aside",{className:"switcher","aria-label":e("nav.sessions"),children:[(0,t.jsxs)("div",{className:"switcher-head",children:[(0,t.jsx)("b",{className:"fa-title",children:e("nav.sessions")}),(0,t.jsx)(g.DO,{value:x,onChange:j,placeholder:e("sessions.searchPlaceholder"),label:e("sessions.searchLabel")}),(0,t.jsx)(g.$q,{value:f,onChange:w,options:[{id:"all",label:e("common.all")},...Object.keys(m.xq).map(e=>({id:e,label:m.xq[e].short}))]})]}),(0,t.jsxs)("div",{className:"switcher-list",children:[null===a&&(0,t.jsx)("p",{className:"muted small pad-m",children:e("sessions.reading")}),O.map(s=>{let[n,a]=s;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"switcher-group",children:[n,(0,t.jsx)("span",{children:a.length})]}),a.map(s=>{var n;return(0,t.jsxs)("button",{className:"sk-item","aria-current":(null==q?void 0:q.session_id)===s.session_id,onClick:()=>_(s.session_id),children:[(0,t.jsxs)("div",{className:"row gap-xs",children:[(0,t.jsx)("b",{className:"grow",children:s.agent_name}),(0,t.jsx)(g.dJ,{provider:s.provider}),s.current&&(0,t.jsx)("span",{className:"chip honey",children:e("sessions.current")})]}),(0,t.jsx)("span",{className:"sk-desc",children:s.preview||(s.pending?e("sessions.counting"):s.task||e("sessions.emptySession"))}),(0,t.jsxs)("span",{className:"sk-meta",children:[(0,m.KN)(s.last_seen),"delegation"===s.kind&&" \xb7 ".concat(e("sessions.delegatedBy",{name:null!=(n=s.from_name)?n:e("chat.anOrchestrator")})),s.pending&&!s.message_count?" \xb7 …":" \xb7 ".concat(e("sessions.messages",{count:s.message_count})),(0,h.RP)(s.usage)>0&&" \xb7 ".concat((0,h.yj)((0,h.RP)(s.usage))," ").concat(e("stats.tokens")),null!==s.cost&&" \xb7 ≈ ".concat((0,h.F0)(s.cost))]})]},s.agent_id+s.session_id)})]},n)}),a&&a.length>0&&!F.length&&(0,t.jsx)("p",{className:"muted small pad-m",children:e("sessions.noMatch")})]})]}),q?(0,t.jsxs)("section",{className:"sk-main",children:[(0,t.jsxs)("header",{className:"sx-head",children:[(0,t.jsxs)("div",{className:"grow",children:[(0,t.jsx)("b",{className:"fa-title lg",children:q.agent_name}),(0,t.jsxs)("div",{className:"muted small mono ellipsis",children:[(0,m._1)(q.cwd)," \xb7 ",q.session_id]})]}),T&&(0,t.jsx)(l(),{className:"btn sm primary",href:"/agents/".concat(T.id),children:e("sessions.openAgent")})]}),(0,t.jsx)("div",{className:"transcript col sx-transcript",ref:M,children:null===k?(0,t.jsx)("p",{className:"muted",children:e("sessions.loading")}):0===k.length?(0,t.jsx)("p",{className:"muted",children:e("sessions.noMessages")}):(0,t.jsxs)(t.Fragment,{children:[Z>0&&(0,t.jsx)("button",{className:"btn sm push-c",onClick:()=>R(C+200),children:e("sessions.older",{count:Z})}),(0,t.jsx)(u.BZ,{msgs:k,agent:{id:q.agent_id,name:q.agent_name,provider:q.provider,role:q.agent_role}})]})})]}):(0,t.jsx)("section",{className:"sk-main sk-none",children:(0,t.jsx)("p",{className:"muted",children:e("sessions.select")})})]}):(0,t.jsx)("div",{className:"m-xl",children:(0,t.jsx)(g.lZ,{kind:"err",children:e("fa.sessions.loadFailed")})})})}},37064:(e,s,n)=>{"use strict";n.d(s,{n:()=>a});var t=n(34023);function a(e,s){let{enabled:n=!0,pauseHidden:a=!0,immediate:l=!0,onError:i}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=(0,t.useRef)(e);r.current=e;let c=(0,t.useRef)(i);c.current=i,(0,t.useEffect)(()=>{let e;if(!n)return;let t=!1,i=0,o=!1,d=()=>{clearTimeout(e),t||(e=setTimeout(()=>void u(),s*Math.min(6,2**i)))},u=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!t&&!o){if(!e&&a&&"undefined"!=typeof document&&"hidden"===document.visibilityState)return void d();o=!0;try{await r.current(),i=0}catch(e){var s;0==i++&&(null==(s=c.current)||s.call(c,e))}finally{o=!1,d()}}},m=()=>{"visible"!==document.visibilityState||o||(clearTimeout(e),u())};return l?u(!0):d(),a&&document.addEventListener("visibilitychange",m),()=>{t=!0,clearTimeout(e),document.removeEventListener("visibilitychange",m)}},[s,n,a,l])}},61748:(e,s,n)=>{"use strict";n.d(s,{Z:()=>l});var t=n(34023);let a="hive-am:query";function l(e,s){let[n,l]=(0,t.useState)(s);return(0,t.useEffect)(()=>{let n=()=>{var n;return l(null!=(n=new URLSearchParams(location.search).get(e))?n:s)};return n(),window.addEventListener("popstate",n),window.addEventListener(a,n),()=>{window.removeEventListener("popstate",n),window.removeEventListener(a,n)}},[e,s]),[n,(0,t.useCallback)(n=>{let t=new URL(location.href);n===s?t.searchParams.delete(e):t.searchParams.set(e,n),history.replaceState(history.state,"",t),l(n),window.dispatchEvent(new Event(a))},[e,s])]}}},e=>{e.O(0,[586,706,654,281,350,705,408,89,358],()=>e(e.s=15065)),_N_E=e.O()}]);