agent-relay-server 0.59.0 → 0.60.1

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 (107) hide show
  1. package/docs/openapi.json +156 -1
  2. package/package.json +2 -2
  3. package/public/assets/MessageBubble-vzupFQD8.js +2 -0
  4. package/public/assets/MessageBubble-vzupFQD8.js.map +1 -0
  5. package/public/assets/{PlanGraphPanel-CXix1C-H.js → PlanGraphPanel-DQvycBMW.js} +2 -2
  6. package/public/assets/{PlanGraphPanel-CXix1C-H.js.map → PlanGraphPanel-DQvycBMW.js.map} +1 -1
  7. package/public/assets/{activity-CRafQ1Je.js → activity-gmfkOBhQ.js} +2 -2
  8. package/public/assets/{activity-CRafQ1Je.js.map → activity-gmfkOBhQ.js.map} +1 -1
  9. package/public/assets/{agent-profiles-DW4o5-ND.js → agent-profiles-7X8gFuwj.js} +2 -2
  10. package/public/assets/{agent-profiles-DW4o5-ND.js.map → agent-profiles-7X8gFuwj.js.map} +1 -1
  11. package/public/assets/{agents-Cbegv0Hm.js → agents-D201CuTR.js} +2 -2
  12. package/public/assets/{agents-Cbegv0Hm.js.map → agents-D201CuTR.js.map} +1 -1
  13. package/public/assets/{analytics-DX6T7JX3.js → analytics-CkOTrr5t.js} +2 -2
  14. package/public/assets/{analytics-DX6T7JX3.js.map → analytics-CkOTrr5t.js.map} +1 -1
  15. package/public/assets/{automation-CzSBv4gg.js → automation-_5u-nVs8.js} +2 -2
  16. package/public/assets/{automation-CzSBv4gg.js.map → automation-_5u-nVs8.js.map} +1 -1
  17. package/public/assets/{branch-state-badge-CRA50r81.js → branch-state-badge-BPXXLpQG.js} +2 -2
  18. package/public/assets/{branch-state-badge-CRA50r81.js.map → branch-state-badge-BPXXLpQG.js.map} +1 -1
  19. package/public/assets/{channels-B1MQCPCT.js → channels-BsJu5TXR.js} +2 -2
  20. package/public/assets/{channels-B1MQCPCT.js.map → channels-BsJu5TXR.js.map} +1 -1
  21. package/public/assets/{chat-BqIaFYGJ.js → chat-CHgPGHQD.js} +2 -2
  22. package/public/assets/{chat-BqIaFYGJ.js.map → chat-CHgPGHQD.js.map} +1 -1
  23. package/public/assets/{connectors-C9aFJIrh.js → connectors-arjfBQvc.js} +2 -2
  24. package/public/assets/{connectors-C9aFJIrh.js.map → connectors-arjfBQvc.js.map} +1 -1
  25. package/public/assets/display-CketawEF.js.map +1 -1
  26. package/public/assets/{formatted-body-impl-DOXH7oDF.js → formatted-body-impl-DBt5tnS0.js} +2 -2
  27. package/public/assets/{formatted-body-impl-DOXH7oDF.js.map → formatted-body-impl-DBt5tnS0.js.map} +1 -1
  28. package/public/assets/{index-br_Y6Cvt.js → index-D7js3XlH.js} +6 -6
  29. package/public/assets/{index-br_Y6Cvt.js.map → index-D7js3XlH.js.map} +1 -1
  30. package/public/assets/{insights-B1edq5lk.js → insights-BvjkOXk9.js} +2 -2
  31. package/public/assets/{insights-B1edq5lk.js.map → insights-BvjkOXk9.js.map} +1 -1
  32. package/public/assets/{integrations-Cm4fjp7_.js → integrations-7L1f3eIE.js} +2 -2
  33. package/public/assets/{integrations-Cm4fjp7_.js.map → integrations-7L1f3eIE.js.map} +1 -1
  34. package/public/assets/{maintenance-D6zvw0fU.js → maintenance-BBoL--vs.js} +2 -2
  35. package/public/assets/{maintenance-D6zvw0fU.js.map → maintenance-BBoL--vs.js.map} +1 -1
  36. package/public/assets/{managed-agents-CzfEznM1.js → managed-agents-BjYBzVZt.js} +2 -2
  37. package/public/assets/{managed-agents-CzfEznM1.js.map → managed-agents-BjYBzVZt.js.map} +1 -1
  38. package/public/assets/{markdown-preview-impl-DZlCaTHQ.js → markdown-preview-impl-BnwjZsmO.js} +2 -2
  39. package/public/assets/{markdown-preview-impl-DZlCaTHQ.js.map → markdown-preview-impl-BnwjZsmO.js.map} +1 -1
  40. package/public/assets/{memory-CUUAzJDc.js → memory-SLycz2gC.js} +2 -2
  41. package/public/assets/{memory-CUUAzJDc.js.map → memory-SLycz2gC.js.map} +1 -1
  42. package/public/assets/{messages-6QZH46LG.js → messages-DfSCTe6N.js} +2 -2
  43. package/public/assets/{messages-6QZH46LG.js.map → messages-DfSCTe6N.js.map} +1 -1
  44. package/public/assets/{orchestrators-CrcqkPuc.js → orchestrators-BwxdTQm_.js} +2 -2
  45. package/public/assets/{orchestrators-CrcqkPuc.js.map → orchestrators-BwxdTQm_.js.map} +1 -1
  46. package/public/assets/{overview-418xXZO_.js → overview-Djy3qkY5.js} +2 -2
  47. package/public/assets/{overview-418xXZO_.js.map → overview-Djy3qkY5.js.map} +1 -1
  48. package/public/assets/{pairs-CnedATgT.js → pairs-9KNduLnC.js} +2 -2
  49. package/public/assets/{pairs-CnedATgT.js.map → pairs-9KNduLnC.js.map} +1 -1
  50. package/public/assets/{security-DS13pbag.js → security-tG3q7fFW.js} +2 -2
  51. package/public/assets/{security-DS13pbag.js.map → security-tG3q7fFW.js.map} +1 -1
  52. package/public/assets/{select-BOprGZDS.js → select-CGUdMNOG.js} +2 -2
  53. package/public/assets/{select-BOprGZDS.js.map → select-CGUdMNOG.js.map} +1 -1
  54. package/public/assets/{settings-BgInn_f3.js → settings-CGcqyJ5L.js} +2 -2
  55. package/public/assets/{settings-BgInn_f3.js.map → settings-CGcqyJ5L.js.map} +1 -1
  56. package/public/assets/{store-DHO_a8BD.js → store-DXdfhiVf.js} +2 -2
  57. package/public/assets/store-DXdfhiVf.js.map +1 -0
  58. package/public/assets/{tasks-B-4oCPuv.js → tasks-DWlKg218.js} +2 -2
  59. package/public/assets/{tasks-B-4oCPuv.js.map → tasks-DWlKg218.js.map} +1 -1
  60. package/public/assets/{teams-sCQAs_QA.js → teams-DRchUP_p.js} +2 -2
  61. package/public/assets/{teams-sCQAs_QA.js.map → teams-DRchUP_p.js.map} +1 -1
  62. package/public/assets/{terminal-viewer-impl-BhqS2XpS.js → terminal-viewer-impl-D_Sqe-vo.js} +2 -2
  63. package/public/assets/{terminal-viewer-impl-BhqS2XpS.js.map → terminal-viewer-impl-D_Sqe-vo.js.map} +1 -1
  64. package/public/assets/{work-queue-BDhjlwUH.js → work-queue-HNcyjON9.js} +2 -2
  65. package/public/assets/{work-queue-BDhjlwUH.js.map → work-queue-HNcyjON9.js.map} +1 -1
  66. package/public/assets/{workspaces-6I-C69nf.js → workspaces-CicYE2Ax.js} +2 -2
  67. package/public/assets/{workspaces-6I-C69nf.js.map → workspaces-CicYE2Ax.js.map} +1 -1
  68. package/public/index.html +2 -2
  69. package/src/agent-lifecycle-events.ts +41 -21
  70. package/src/branch-landed.ts +46 -35
  71. package/src/channel-target.ts +10 -0
  72. package/src/cli/index.ts +11 -0
  73. package/src/cli/merges.ts +89 -0
  74. package/src/config.ts +9 -0
  75. package/src/context-advisory.ts +13 -6
  76. package/src/db/merge-lease.ts +95 -1
  77. package/src/db/message-reads.ts +6 -0
  78. package/src/db/messages.ts +16 -1
  79. package/src/db/migrations.ts +30 -0
  80. package/src/db/notification-subscriptions.ts +198 -0
  81. package/src/db/schema.ts +11 -0
  82. package/src/index.ts +2 -0
  83. package/src/maintenance.ts +40 -21
  84. package/src/mcp-merge-tools.ts +66 -0
  85. package/src/mcp-notification-subscription-tools.ts +111 -0
  86. package/src/mcp.ts +5 -3
  87. package/src/merge-pause-maintenance.ts +13 -0
  88. package/src/notification-router.ts +168 -0
  89. package/src/notification-rules.ts +186 -0
  90. package/src/notify.ts +9 -0
  91. package/src/reviewer-pipeline.ts +54 -40
  92. package/src/routes/agent-sessions.ts +4 -2
  93. package/src/routes/commands.ts +20 -0
  94. package/src/routes/index.ts +7 -0
  95. package/src/routes/merges.ts +95 -0
  96. package/src/security.ts +2 -0
  97. package/src/self-resume.ts +11 -6
  98. package/src/services/merge-pause.ts +37 -0
  99. package/src/services/plan-live-bindings.ts +11 -6
  100. package/src/services/rate-limit-resume.ts +17 -10
  101. package/src/services/spawn-agent.ts +10 -8
  102. package/src/services/transient-agent-reaper.ts +11 -6
  103. package/src/token-db.ts +3 -3
  104. package/src/workspace-pr-completion.ts +85 -8
  105. package/public/assets/MessageBubble-BrEKymoV.js +0 -2
  106. package/public/assets/MessageBubble-BrEKymoV.js.map +0 -1
  107. package/public/assets/store-DHO_a8BD.js.map +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./bundle-web-CXNb85wK.js","./chunk-CilyBKbf.js","./preload-helper-CP_edrrL.js","./lib-VSpj1Yz-.js","./markdown-preview-impl-DZlCaTHQ.js","./lib-BZrjIp-o.js","./lucide-react-H_-8G79A.js","./terminal-viewer-impl-BhqS2XpS.js","./store-DHO_a8BD.js","./display-CketawEF.js","./button-73wpRw65.js","./dist-Kkpnjx_M.js","./use-keyboard-viewport-fOL_3RHB.js","./terminal-viewer-impl-BrP-ENHg.css","./formatted-body-impl-DOXH7oDF.js","./overview-418xXZO_.js","./badge-Cy6qO_Jz.js","./card-BU6PvVHv.js","./chat-BqIaFYGJ.js","./react-dom-WI6TjVe7.js","./MessageBubble-BrEKymoV.js","./PlanGraphPanel-CXix1C-H.js","./branch-state-badge-CRA50r81.js","./copy-button-HRopUwui.js","./input-B2EDz-BE.js","./agents-Cbegv0Hm.js","./dist-T7u7IZGJ.js","./dist-Cko2KPW8.js","./dist-DFLciw0h.js","./dist-D41tzJYg.js","./dist-CLHMeXYi.js","./es2015-Df08Opjx.js","./dist-DmN94rc8.js","./dist-Ci1MM51P.js","./managed-agents-CzfEznM1.js","./teams-sCQAs_QA.js","./select-BOprGZDS.js","./dist-D33pM1xy.js","./dist-CC5f7oYw.js","./dist-DUoZnlB2.js","./dist-De2oguBm.js","./agent-profiles-DW4o5-ND.js","./orchestrators-CrcqkPuc.js","./workspaces-6I-C69nf.js","./channels-B1MQCPCT.js","./connectors-C9aFJIrh.js","./integrations-Cm4fjp7_.js","./security-DS13pbag.js","./memory-CUUAzJDc.js","./activity-CRafQ1Je.js","./pairs-CnedATgT.js","./messages-6QZH46LG.js","./work-queue-BDhjlwUH.js","./tasks-B-4oCPuv.js","./automation-CzSBv4gg.js","./analytics-DX6T7JX3.js","./themes-mW9zZP4O.js","./insights-B1edq5lk.js","./maintenance-D6zvw0fU.js","./settings-BgInn_f3.js"])))=>i.map(i=>d[i]);
2
- import{r as e,t}from"./chunk-CilyBKbf.js";import{$ as n,Bt as r,C as i,D as a,Dn as o,E as s,Et as c,F as l,Fn as u,H as d,I as f,In as p,J as m,Jt as h,K as g,L as _,Lt as v,Mn as y,Mt as b,N as x,Nn as S,Nt as ee,Ot as te,P as C,R as ne,S as re,T as ie,Tt as ae,V as oe,Vn as se,Vt as ce,W as w,Wt as T,Y as le,Z as ue,Zt as de,_ as fe,_n as pe,_t as E,a as me,at as he,bn as ge,cn as _e,ct as ve,dt as ye,et as be,f as D,fn as xe,ft as Se,g as Ce,gn as we,hn as Te,i as Ee,in as De,it as Oe,j as ke,k as Ae,kt as je,l as Me,ln as Ne,lt as Pe,m as Fe,mn as Ie,n as Le,o as Re,on as ze,ot as Be,p as Ve,pt as He,qn as Ue,qt as O,r as We,st as Ge,t as Ke,tn as qe,u as Je,un as Ye,v as Xe,vt as Ze,w as Qe,wt as $e,xn as et,yn as tt,z as nt,zt as rt}from"./lucide-react-H_-8G79A.js";import{t as it}from"./react-dom-WI6TjVe7.js";import{a as at,i as ot,o as st,s as ct,t as k}from"./store-DHO_a8BD.js";import{$ as lt,C as ut,D as dt,E as ft,G as pt,H as mt,K as ht,R as gt,S as _t,T as vt,U as yt,V as bt,W as xt,X as St,Y as Ct,Z as wt,_ as Tt,a as Et,b as Dt,c as Ot,d as A,f as kt,h as At,i as jt,k as Mt,lt as Nt,m as Pt,n as Ft,o as It,p as Lt,q as Rt,r as zt,st as Bt,t as Vt,u as Ht,ut as Ut,w as Wt,x as Gt,y as Kt}from"./display-CketawEF.js";import{n as qt,t as Jt}from"./themes-mW9zZP4O.js";import{a as Yt,i as Xt,o as Zt,r as Qt,t as $t}from"./dist-Kkpnjx_M.js";import{n as en,t as j}from"./dist-DFLciw0h.js";import{i as tn,n as M,r as nn,t as rn}from"./dist-Cko2KPW8.js";import{t as an}from"./dist-CC5f7oYw.js";import{t as on}from"./dist-Ci1MM51P.js";import{t as sn}from"./dist-DmN94rc8.js";import{a as cn,i as ln,n as un,o as dn,r as fn,s as pn,t as mn}from"./es2015-Df08Opjx.js";import{t as hn}from"./dist-DUoZnlB2.js";import{t as gn}from"./dist-D41tzJYg.js";import{t as _n}from"./dist-De2oguBm.js";import{t as vn}from"./dist-CLHMeXYi.js";import{a as yn,i as bn,n as xn,r as Sn,t as Cn}from"./dist-T7u7IZGJ.js";import{t as wn}from"./dist-D33pM1xy.js";import{t as N}from"./badge-Cy6qO_Jz.js";import{t as P}from"./button-73wpRw65.js";import{t as F}from"./input-B2EDz-BE.js";import{t as Tn}from"./copy-button-HRopUwui.js";import{t as I}from"./preload-helper-CP_edrrL.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var En=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,ie());else{var t=n(l);t!==null&&se(x,t.startTime-e)}}var S=!1,ee=-1,te=5,C=-1;function ne(){return g?!0:!(e.unstable_now()-C<te)}function re(){if(g=!1,S){var t=e.unstable_now();C=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(ee),ee=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&ne());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&se(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?ie():S=!1}}}var ie;if(typeof y==`function`)ie=function(){y(re)};else if(typeof MessageChannel<`u`){var ae=new MessageChannel,oe=ae.port2;ae.port1.onmessage=re,ie=function(){oe.postMessage(null)}}else ie=function(){_(re,0)};function se(t,n){ee=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):te=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(ee),ee=-1):h=!0,se(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,ie()))),r},e.unstable_shouldYield=ne,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Dn=t(((e,t)=>{t.exports=En()})),On=t((e=>{var t=Dn(),n=Ue(),r=it();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),S=Symbol.for(`react.suspense`),ee=Symbol.for(`react.suspense_list`),te=Symbol.for(`react.memo`),C=Symbol.for(`react.lazy`),ne=Symbol.for(`react.activity`),re=Symbol.for(`react.memo_cache_sentinel`),ie=Symbol.iterator;function ae(e){return typeof e!=`object`||!e?null:(e=ie&&e[ie]||e[`@@iterator`],typeof e==`function`?e:null)}var oe=Symbol.for(`react.client.reference`);function se(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===oe?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case S:return`Suspense`;case ee:return`SuspenseList`;case ne:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case te:return t=e.displayName||null,t===null?se(e.type)||`Memo`:t;case C:t=e._payload,e=e._init;try{return se(e(t))}catch{}}return null}var ce=Array.isArray,w=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,T=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,le={pending:!1,data:null,method:null,action:null},ue=[],de=-1;function fe(e){return{current:e}}function pe(e){0>de||(e.current=ue[de],ue[de]=null,de--)}function E(e,t){de++,ue[de]=e.current,e.current=t}var me=fe(null),he=fe(null),ge=fe(null),_e=fe(null);function ve(e,t){switch(E(ge,t),E(he,e),E(me,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}pe(me),E(me,e)}function ye(){pe(me),pe(he),pe(ge)}function be(e){e.memoizedState!==null&&E(_e,e);var t=me.current,n=Hd(t,e.type);t!==n&&(E(he,e),E(me,n))}function D(e){he.current===e&&(pe(me),pe(he)),_e.current===e&&(pe(_e),Qf._currentValue=le)}var xe,Se;function Ce(e){if(xe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);xe=t&&t[1]||``,Se=-1<e.stack.indexOf(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./bundle-web-CXNb85wK.js","./chunk-CilyBKbf.js","./preload-helper-CP_edrrL.js","./lib-VSpj1Yz-.js","./markdown-preview-impl-BnwjZsmO.js","./lib-BZrjIp-o.js","./lucide-react-H_-8G79A.js","./terminal-viewer-impl-D_Sqe-vo.js","./store-DXdfhiVf.js","./display-CketawEF.js","./button-73wpRw65.js","./dist-Kkpnjx_M.js","./use-keyboard-viewport-fOL_3RHB.js","./terminal-viewer-impl-BrP-ENHg.css","./formatted-body-impl-DBt5tnS0.js","./overview-Djy3qkY5.js","./badge-Cy6qO_Jz.js","./card-BU6PvVHv.js","./chat-CHgPGHQD.js","./react-dom-WI6TjVe7.js","./MessageBubble-vzupFQD8.js","./PlanGraphPanel-DQvycBMW.js","./branch-state-badge-BPXXLpQG.js","./copy-button-HRopUwui.js","./input-B2EDz-BE.js","./agents-D201CuTR.js","./dist-T7u7IZGJ.js","./dist-Cko2KPW8.js","./dist-DFLciw0h.js","./dist-D41tzJYg.js","./dist-CLHMeXYi.js","./es2015-Df08Opjx.js","./dist-DmN94rc8.js","./dist-Ci1MM51P.js","./managed-agents-BjYBzVZt.js","./teams-DRchUP_p.js","./select-CGUdMNOG.js","./dist-D33pM1xy.js","./dist-CC5f7oYw.js","./dist-DUoZnlB2.js","./dist-De2oguBm.js","./agent-profiles-7X8gFuwj.js","./orchestrators-BwxdTQm_.js","./workspaces-CicYE2Ax.js","./channels-BsJu5TXR.js","./connectors-arjfBQvc.js","./integrations-7L1f3eIE.js","./security-tG3q7fFW.js","./memory-SLycz2gC.js","./activity-gmfkOBhQ.js","./pairs-9KNduLnC.js","./messages-DfSCTe6N.js","./work-queue-HNcyjON9.js","./tasks-DWlKg218.js","./automation-_5u-nVs8.js","./analytics-CkOTrr5t.js","./themes-mW9zZP4O.js","./insights-BvjkOXk9.js","./maintenance-BBoL--vs.js","./settings-CGcqyJ5L.js"])))=>i.map(i=>d[i]);
2
+ import{r as e,t}from"./chunk-CilyBKbf.js";import{$ as n,Bt as r,C as i,D as a,Dn as o,E as s,Et as c,F as l,Fn as u,H as d,I as f,In as p,J as m,Jt as h,K as g,L as _,Lt as v,Mn as y,Mt as b,N as x,Nn as S,Nt as ee,Ot as te,P as C,R as ne,S as re,T as ie,Tt as ae,V as oe,Vn as se,Vt as ce,W as w,Wt as T,Y as le,Z as ue,Zt as de,_ as fe,_n as pe,_t as E,a as me,at as he,bn as ge,cn as _e,ct as ve,dt as ye,et as be,f as D,fn as xe,ft as Se,g as Ce,gn as we,hn as Te,i as Ee,in as De,it as Oe,j as ke,k as Ae,kt as je,l as Me,ln as Ne,lt as Pe,m as Fe,mn as Ie,n as Le,o as Re,on as ze,ot as Be,p as Ve,pt as He,qn as Ue,qt as O,r as We,st as Ge,t as Ke,tn as qe,u as Je,un as Ye,v as Xe,vt as Ze,w as Qe,wt as $e,xn as et,yn as tt,z as nt,zt as rt}from"./lucide-react-H_-8G79A.js";import{t as it}from"./react-dom-WI6TjVe7.js";import{a as at,i as ot,o as st,s as ct,t as k}from"./store-DXdfhiVf.js";import{$ as lt,C as ut,D as dt,E as ft,G as pt,H as mt,K as ht,R as gt,S as _t,T as vt,U as yt,V as bt,W as xt,X as St,Y as Ct,Z as wt,_ as Tt,a as Et,b as Dt,c as Ot,d as A,f as kt,h as At,i as jt,k as Mt,lt as Nt,m as Pt,n as Ft,o as It,p as Lt,q as Rt,r as zt,st as Bt,t as Vt,u as Ht,ut as Ut,w as Wt,x as Gt,y as Kt}from"./display-CketawEF.js";import{n as qt,t as Jt}from"./themes-mW9zZP4O.js";import{a as Yt,i as Xt,o as Zt,r as Qt,t as $t}from"./dist-Kkpnjx_M.js";import{n as en,t as j}from"./dist-DFLciw0h.js";import{i as tn,n as M,r as nn,t as rn}from"./dist-Cko2KPW8.js";import{t as an}from"./dist-CC5f7oYw.js";import{t as on}from"./dist-Ci1MM51P.js";import{t as sn}from"./dist-DmN94rc8.js";import{a as cn,i as ln,n as un,o as dn,r as fn,s as pn,t as mn}from"./es2015-Df08Opjx.js";import{t as hn}from"./dist-DUoZnlB2.js";import{t as gn}from"./dist-D41tzJYg.js";import{t as _n}from"./dist-De2oguBm.js";import{t as vn}from"./dist-CLHMeXYi.js";import{a as yn,i as bn,n as xn,r as Sn,t as Cn}from"./dist-T7u7IZGJ.js";import{t as wn}from"./dist-D33pM1xy.js";import{t as N}from"./badge-Cy6qO_Jz.js";import{t as P}from"./button-73wpRw65.js";import{t as F}from"./input-B2EDz-BE.js";import{t as Tn}from"./copy-button-HRopUwui.js";import{t as I}from"./preload-helper-CP_edrrL.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var En=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,ie());else{var t=n(l);t!==null&&se(x,t.startTime-e)}}var S=!1,ee=-1,te=5,C=-1;function ne(){return g?!0:!(e.unstable_now()-C<te)}function re(){if(g=!1,S){var t=e.unstable_now();C=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(ee),ee=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&ne());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&se(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?ie():S=!1}}}var ie;if(typeof y==`function`)ie=function(){y(re)};else if(typeof MessageChannel<`u`){var ae=new MessageChannel,oe=ae.port2;ae.port1.onmessage=re,ie=function(){oe.postMessage(null)}}else ie=function(){_(re,0)};function se(t,n){ee=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):te=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(ee),ee=-1):h=!0,se(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,ie()))),r},e.unstable_shouldYield=ne,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Dn=t(((e,t)=>{t.exports=En()})),On=t((e=>{var t=Dn(),n=Ue(),r=it();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),S=Symbol.for(`react.suspense`),ee=Symbol.for(`react.suspense_list`),te=Symbol.for(`react.memo`),C=Symbol.for(`react.lazy`),ne=Symbol.for(`react.activity`),re=Symbol.for(`react.memo_cache_sentinel`),ie=Symbol.iterator;function ae(e){return typeof e!=`object`||!e?null:(e=ie&&e[ie]||e[`@@iterator`],typeof e==`function`?e:null)}var oe=Symbol.for(`react.client.reference`);function se(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===oe?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case S:return`Suspense`;case ee:return`SuspenseList`;case ne:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case te:return t=e.displayName||null,t===null?se(e.type)||`Memo`:t;case C:t=e._payload,e=e._init;try{return se(e(t))}catch{}}return null}var ce=Array.isArray,w=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,T=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,le={pending:!1,data:null,method:null,action:null},ue=[],de=-1;function fe(e){return{current:e}}function pe(e){0>de||(e.current=ue[de],ue[de]=null,de--)}function E(e,t){de++,ue[de]=e.current,e.current=t}var me=fe(null),he=fe(null),ge=fe(null),_e=fe(null);function ve(e,t){switch(E(ge,t),E(he,e),E(me,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}pe(me),E(me,e)}function ye(){pe(me),pe(he),pe(ge)}function be(e){e.memoizedState!==null&&E(_e,e);var t=me.current,n=Hd(t,e.type);t!==n&&(E(he,e),E(me,n))}function D(e){he.current===e&&(pe(me),pe(he)),_e.current===e&&(pe(_e),Qf._currentValue=le)}var xe,Se;function Ce(e){if(xe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);xe=t&&t[1]||``,Se=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+xe+e+Se}var we=!1;function Te(e,t){if(!e||we)return``;we=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,`props`,{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,`name`,{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
5
5
  `),l=s.split(`
@@ -11,11 +11,11 @@ Error generating stack: `+e.message+`
11
11
 
12
12
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
13
13
 
14
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return L.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},fr=`DialogDescriptionWarning`,pr=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ur(fr).contentName}}.`;return L.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},mr=zn,hr=Gn,gr=qn,_r=Zn,vr=nr,yr=ir,br=or,xr=`rovingFocusGroup.onEntryFocus`,Sr={bubbles:!1,cancelable:!0},Cr=`RovingFocusGroup`,[wr,Tr,Er]=an(Cr),[Dr,Or]=tn(Cr,[Er]),[kr,Ar]=Dr(Cr),jr=L.forwardRef((e,t)=>(0,R.jsx)(wr.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,R.jsx)(wr.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,R.jsx)(Mr,{...e,ref:t})})}));jr.displayName=Cr;var Mr=L.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=L.useRef(null),p=Zt(t,f),m=hn(a),[h,g]=on({prop:o,defaultProp:s??null,onChange:c,caller:Cr}),[_,v]=L.useState(!1),y=gn(l),b=Tr(n),x=L.useRef(!1),[S,ee]=L.useState(0);return L.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(xr,y),()=>e.removeEventListener(xr,y)},[y]),(0,R.jsx)(kr,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:L.useCallback(e=>g(e),[g]),onItemShiftTab:L.useCallback(()=>v(!0),[]),onFocusableItemAdd:L.useCallback(()=>ee(e=>e+1),[]),onFocusableItemRemove:L.useCallback(()=>ee(e=>e-1),[]),children:(0,R.jsx)(j.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:M(e.onMouseDown,()=>{x.current=!0}),onFocus:M(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(xr,Sr);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);Rr([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:M(e.onBlur,()=>v(!1))})})}),Nr=`RovingFocusGroupItem`,Pr=L.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=pn(),l=a||c,u=Ar(Nr,n),d=u.currentTabStopId===l,f=Tr(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return L.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,R.jsx)(wr.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,R.jsx)(j.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:M(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:M(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:M(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=Lr(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?zr(n,r+1):n.slice(r+1)}setTimeout(()=>Rr(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});Pr.displayName=Nr;var Fr={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Ir(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function Lr(e,t,n){let r=Ir(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return Fr[r]}function Rr(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function zr(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Br=jr,Vr=Pr,Hr=[`Enter`,` `],Ur=[`ArrowDown`,`PageUp`,`Home`],Wr=[`ArrowUp`,`PageDown`,`End`],Gr=[...Ur,...Wr],Kr={ltr:[...Hr,`ArrowRight`],rtl:[...Hr,`ArrowLeft`]},qr={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},Jr=`Menu`,[Yr,Xr,Zr]=an(Jr),[Qr,$r]=tn(Jr,[Zr,yn,Or]),ei=yn(),ti=Or(),[ni,ri]=Qr(Jr),[ii,ai]=Qr(Jr),oi=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=ei(t),[c,l]=L.useState(null),u=L.useRef(!1),d=gn(a),f=hn(i);return L.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,R.jsx)(bn,{...s,children:(0,R.jsx)(ni,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,R.jsx)(ii,{scope:t,onClose:L.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};oi.displayName=Jr;var si=`MenuAnchor`,ci=L.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=ei(n);return(0,R.jsx)(Cn,{...i,...r,ref:t})});ci.displayName=si;var li=`MenuPortal`,[ui,di]=Qr(li,{forceMount:void 0}),fi=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=ri(li,t);return(0,R.jsx)(ui,{scope:t,forceMount:n,children:(0,R.jsx)(sn,{present:n||a.open,children:(0,R.jsx)(ln,{asChild:!0,container:i,children:r})})})};fi.displayName=li;var pi=`MenuContent`,[mi,hi]=Qr(pi),gi=L.forwardRef((e,t)=>{let n=di(pi,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=ri(pi,e.__scopeMenu),o=ai(pi,e.__scopeMenu);return(0,R.jsx)(Yr.Provider,{scope:e.__scopeMenu,children:(0,R.jsx)(sn,{present:r||a.open,children:(0,R.jsx)(Yr.Slot,{scope:e.__scopeMenu,children:o.modal?(0,R.jsx)(_i,{...i,ref:t}):(0,R.jsx)(vi,{...i,ref:t})})})})}),_i=L.forwardRef((e,t)=>{let n=ri(pi,e.__scopeMenu),r=L.useRef(null),i=Zt(t,r);return L.useEffect(()=>{let e=r.current;if(e)return mn(e)},[]),(0,R.jsx)(bi,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:M(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),vi=L.forwardRef((e,t)=>{let n=ri(pi,e.__scopeMenu);return(0,R.jsx)(bi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),yi=Qt(`MenuContent.ScrollLock`),bi=L.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=ri(pi,n),_=ai(pi,n),v=ei(n),y=ti(n),b=Xr(n),[x,S]=L.useState(null),ee=L.useRef(null),te=Zt(t,ee,g.onContentChange),C=L.useRef(0),ne=L.useRef(``),re=L.useRef(0),ie=L.useRef(null),ae=L.useRef(`right`),oe=L.useRef(0),se=m?un:L.Fragment,ce=m?{as:yi,allowPinchZoom:!0}:void 0,w=e=>{let t=ne.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=na(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){ne.current=t,window.clearTimeout(C.current),t!==``&&(C.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};L.useEffect(()=>()=>window.clearTimeout(C.current),[]),fn();let T=L.useCallback(e=>ae.current===ie.current?.side&&ia(e,ie.current?.area),[]);return(0,R.jsx)(mi,{scope:n,searchRef:ne,onItemEnter:L.useCallback(e=>{T(e)&&e.preventDefault()},[T]),onItemLeave:L.useCallback(e=>{T(e)||(ee.current?.focus(),S(null))},[T]),onTriggerLeave:L.useCallback(e=>{T(e)&&e.preventDefault()},[T]),pointerGraceTimerRef:re,onPointerGraceIntentChange:L.useCallback(e=>{ie.current=e},[]),children:(0,R.jsx)(se,{...ce,children:(0,R.jsx)(cn,{asChild:!0,trapped:i,onMountAutoFocus:M(a,e=>{e.preventDefault(),ee.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,R.jsx)(dn,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,R.jsx)(Br,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:M(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,R.jsx)(Sn,{role:`menu`,"aria-orientation":`vertical`,"data-state":Zi(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:te,style:{outline:`none`,...h.style},onKeyDown:M(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&w(e.key));let i=ee.current;if(e.target!==i||!Gr.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);Wr.includes(e.key)&&a.reverse(),ea(a)}),onBlur:M(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(C.current),ne.current=``)}),onPointerMove:M(e.onPointerMove,aa(e=>{let t=e.target,n=oe.current!==e.clientX;e.currentTarget.contains(t)&&n&&(ae.current=e.clientX>oe.current?`right`:`left`,oe.current=e.clientX)}))})})})})})})});gi.displayName=pi;var xi=`MenuGroup`,Si=L.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,R.jsx)(j.div,{role:`group`,...r,ref:t})});Si.displayName=xi;var Ci=`MenuLabel`,wi=L.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,R.jsx)(j.div,{...r,ref:t})});wi.displayName=Ci;var Ti=`MenuItem`,Ei=`menu.itemSelect`,Di=L.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=L.useRef(null),o=ai(Ti,e.__scopeMenu),s=hi(Ti,e.__scopeMenu),c=Zt(t,a),l=L.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(Ei,{bubbles:!0,cancelable:!0});e.addEventListener(Ei,e=>r?.(e),{once:!0}),en(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,R.jsx)(Oi,{...i,ref:c,disabled:n,onClick:M(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:M(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:M(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||Hr.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});Di.displayName=Ti;var Oi=L.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=hi(Ti,n),s=ti(n),c=L.useRef(null),l=Zt(t,c),[u,d]=L.useState(!1),[f,p]=L.useState(``);return L.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,R.jsx)(Yr.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,R.jsx)(Vr,{asChild:!0,...s,focusable:!r,children:(0,R.jsx)(j.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:M(e.onPointerMove,aa(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:M(e.onPointerLeave,aa(e=>o.onItemLeave(e))),onFocus:M(e.onFocus,()=>d(!0)),onBlur:M(e.onBlur,()=>d(!1))})})})}),ki=`MenuCheckboxItem`,Ai=L.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,R.jsx)(Ii,{scope:e.__scopeMenu,checked:n,children:(0,R.jsx)(Di,{role:`menuitemcheckbox`,"aria-checked":Qi(n)?`mixed`:n,...i,ref:t,"data-state":$i(n),onSelect:M(i.onSelect,()=>r?.(Qi(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Ai.displayName=ki;var ji=`MenuRadioGroup`,[Mi,Ni]=Qr(ji,{value:void 0,onValueChange:()=>{}}),z=L.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=gn(r);return(0,R.jsx)(Mi,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,R.jsx)(Si,{...i,ref:t})})});z.displayName=ji;var B=`MenuRadioItem`,Pi=L.forwardRef((e,t)=>{let{value:n,...r}=e,i=Ni(B,e.__scopeMenu),a=n===i.value;return(0,R.jsx)(Ii,{scope:e.__scopeMenu,checked:a,children:(0,R.jsx)(Di,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":$i(a),onSelect:M(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});Pi.displayName=B;var Fi=`MenuItemIndicator`,[Ii,Li]=Qr(Fi,{checked:!1}),Ri=L.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=Li(Fi,n);return(0,R.jsx)(sn,{present:r||Qi(a.checked)||a.checked===!0,children:(0,R.jsx)(j.span,{...i,ref:t,"data-state":$i(a.checked)})})});Ri.displayName=Fi;var zi=`MenuSeparator`,Bi=L.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,R.jsx)(j.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});Bi.displayName=zi;var Vi=`MenuArrow`,Hi=L.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=ei(n);return(0,R.jsx)(xn,{...i,...r,ref:t})});Hi.displayName=Vi;var Ui=`MenuSub`,[Wi,Gi]=Qr(Ui),Ki=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=ri(Ui,t),o=ei(t),[s,c]=L.useState(null),[l,u]=L.useState(null),d=gn(i);return L.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,R.jsx)(bn,{...o,children:(0,R.jsx)(ni,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,R.jsx)(Wi,{scope:t,contentId:pn(),triggerId:pn(),trigger:s,onTriggerChange:c,children:n})})})};Ki.displayName=Ui;var qi=`MenuSubTrigger`,Ji=L.forwardRef((e,t)=>{let n=ri(qi,e.__scopeMenu),r=ai(qi,e.__scopeMenu),i=Gi(qi,e.__scopeMenu),a=hi(qi,e.__scopeMenu),o=L.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=L.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return L.useEffect(()=>u,[u]),L.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,R.jsx)(ci,{asChild:!0,...l,children:(0,R.jsx)(Oi,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Zi(n.open),...e,ref:Yt(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:M(e.onPointerMove,aa(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:M(e.onPointerLeave,aa(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:M(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||Kr[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});Ji.displayName=qi;var Yi=`MenuSubContent`,Xi=L.forwardRef((e,t)=>{let n=di(pi,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=ri(pi,e.__scopeMenu),o=ai(pi,e.__scopeMenu),s=Gi(Yi,e.__scopeMenu),c=L.useRef(null),l=Zt(t,c);return(0,R.jsx)(Yr.Provider,{scope:e.__scopeMenu,children:(0,R.jsx)(sn,{present:r||a.open,children:(0,R.jsx)(Yr.Slot,{scope:e.__scopeMenu,children:(0,R.jsx)(bi,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:l,align:`start`,side:o.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:M(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:M(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:M(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=qr[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});Xi.displayName=Yi;function Zi(e){return e?`open`:`closed`}function Qi(e){return e===`indeterminate`}function $i(e){return Qi(e)?`indeterminate`:e?`checked`:`unchecked`}function ea(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function ta(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function na(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=ta(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function ra(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function ia(e,t){return t?ra({x:e.clientX,y:e.clientY},t):!1}function aa(e){return t=>t.pointerType===`mouse`?e(t):void 0}var oa=oi,sa=ci,ca=fi,la=gi,ua=Si,da=wi,fa=Di,pa=Ai,ma=z,ha=Pi,ga=Ri,_a=Bi,va=Hi,ya=Ji,ba=Xi,xa=`DropdownMenu`,[Sa,Ca]=tn(xa,[$r]),wa=$r(),[Ta,Ea]=Sa(xa),Da=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=wa(t),l=L.useRef(null),[u,d]=on({prop:i,defaultProp:a??!1,onChange:o,caller:xa});return(0,R.jsx)(Ta,{scope:t,triggerId:pn(),triggerRef:l,contentId:pn(),open:u,onOpenChange:d,onOpenToggle:L.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,R.jsx)(oa,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};Da.displayName=xa;var Oa=`DropdownMenuTrigger`,ka=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Ea(Oa,n),o=wa(n);return(0,R.jsx)(sa,{asChild:!0,...o,children:(0,R.jsx)(j.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:Yt(t,a.triggerRef),onPointerDown:M(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:M(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});ka.displayName=Oa;var Aa=`DropdownMenuPortal`,ja=e=>{let{__scopeDropdownMenu:t,...n}=e,r=wa(t);return(0,R.jsx)(ca,{...r,...n})};ja.displayName=Aa;var Ma=`DropdownMenuContent`,Na=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ea(Ma,n),a=wa(n),o=L.useRef(!1);return(0,R.jsx)(la,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:M(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:M(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Na.displayName=Ma;var Pa=`DropdownMenuGroup`,Fa=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(ua,{...i,...r,ref:t})});Fa.displayName=Pa;var Ia=`DropdownMenuLabel`,La=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(da,{...i,...r,ref:t})});La.displayName=Ia;var Ra=`DropdownMenuItem`,za=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(fa,{...i,...r,ref:t})});za.displayName=Ra;var Ba=`DropdownMenuCheckboxItem`,Va=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(pa,{...i,...r,ref:t})});Va.displayName=Ba;var Ha=`DropdownMenuRadioGroup`,Ua=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(ma,{...i,...r,ref:t})});Ua.displayName=Ha;var Wa=`DropdownMenuRadioItem`,Ga=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(ha,{...i,...r,ref:t})});Ga.displayName=Wa;var Ka=`DropdownMenuItemIndicator`,qa=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(ga,{...i,...r,ref:t})});qa.displayName=Ka;var Ja=`DropdownMenuSeparator`,Ya=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(_a,{...i,...r,ref:t})});Ya.displayName=Ja;var Xa=`DropdownMenuArrow`,Za=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(va,{...i,...r,ref:t})});Za.displayName=Xa;var Qa=`DropdownMenuSubTrigger`,$a=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(ya,{...i,...r,ref:t})});$a.displayName=Qa;var eo=`DropdownMenuSubContent`,to=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(ba,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});to.displayName=eo;var no=Da,ro=ka,io=ja,ao=Na,oo=La,so=za,co=Ya,lo=`Label`,uo=L.forwardRef((e,t)=>(0,R.jsx)(j.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));uo.displayName=lo;var fo=uo;function V(e,t){return L.useReducer((e,n)=>t[e][n]??e,e)}var H=`ScrollArea`,[po,mo]=tn(H),[ho,go]=po(H),_o=L.forwardRef((e,t)=>{let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=L.useState(null),[l,u]=L.useState(null),[d,f]=L.useState(null),[p,m]=L.useState(null),[h,g]=L.useState(null),[_,v]=L.useState(0),[y,b]=L.useState(0),[x,S]=L.useState(!1),[ee,te]=L.useState(!1),C=Zt(t,e=>c(e)),ne=hn(i);return(0,R.jsx)(ho,{scope:n,type:r,dir:ne,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:u,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:x,onScrollbarXEnabledChange:S,scrollbarY:h,onScrollbarYChange:g,scrollbarYEnabled:ee,onScrollbarYEnabledChange:te,onCornerWidthChange:v,onCornerHeightChange:b,children:(0,R.jsx)(j.div,{dir:ne,...o,ref:C,style:{position:`relative`,"--radix-scroll-area-corner-width":_+`px`,"--radix-scroll-area-corner-height":y+`px`,...e.style}})})});_o.displayName=H;var vo=`ScrollAreaViewport`,yo=L.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=go(vo,n),s=Zt(t,L.useRef(null),o.onViewportChange);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:i}),(0,R.jsx)(j.div,{"data-radix-scroll-area-viewport":``,...a,ref:s,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,R.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})});yo.displayName=vo;var bo=`ScrollAreaScrollbar`,xo=L.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=go(bo,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return L.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,R.jsx)(So,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,R.jsx)(Co,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,R.jsx)(wo,{...r,ref:t,forceMount:n}):i.type===`always`?(0,R.jsx)(To,{...r,ref:t}):null});xo.displayName=bo;var So=L.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=go(bo,e.__scopeScrollArea),[a,o]=L.useState(!1);return L.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=()=>{window.clearTimeout(t),o(!0)},r=()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)};return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,R.jsx)(sn,{present:n||a,children:(0,R.jsx)(wo,{"data-state":a?`visible`:`hidden`,...r,ref:t})})}),Co=L.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=go(bo,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=Go(()=>c(`SCROLL_END`),100),[s,c]=V(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return L.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),L.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r};return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,R.jsx)(sn,{present:n||s!==`hidden`,children:(0,R.jsx)(To,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:M(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:M(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})}),wo=L.forwardRef((e,t)=>{let n=go(bo,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=L.useState(!1),s=e.orientation===`horizontal`,c=Go(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return Ko(n.viewport,c),Ko(n.content,c),(0,R.jsx)(sn,{present:r||a,children:(0,R.jsx)(To,{"data-state":a?`visible`:`hidden`,...i,ref:t})})}),To=L.forwardRef((e,t)=>{let{orientation:n=`vertical`,...r}=e,i=go(bo,e.__scopeScrollArea),a=L.useRef(null),o=L.useRef(0),[s,c]=L.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=Ro(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:e=>a.current=e,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:e=>o.current=e};function d(e,t){return Bo(e,o.current,s,t)}return n===`horizontal`?(0,R.jsx)(Eo,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=Vo(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,R.jsx)(Do,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=Vo(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null}),Eo=L.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=go(bo,e.__scopeScrollArea),[o,s]=L.useState(),c=L.useRef(null),l=Zt(t,c,a.onScrollbarXChange);return L.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,R.jsx)(Ao,{"data-orientation":`horizontal`,...i,ref:l,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":zo(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),Uo(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Lo(o.paddingLeft),paddingEnd:Lo(o.paddingRight)}})}})}),Do=L.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=go(bo,e.__scopeScrollArea),[o,s]=L.useState(),c=L.useRef(null),l=Zt(t,c,a.onScrollbarYChange);return L.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,R.jsx)(Ao,{"data-orientation":`vertical`,...i,ref:l,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":zo(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),Uo(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Lo(o.paddingTop),paddingEnd:Lo(o.paddingBottom)}})}})}),[Oo,ko]=po(bo),Ao=L.forwardRef((e,t)=>{let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:s,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:u,onResize:d,...f}=e,p=go(bo,n),[m,h]=L.useState(null),g=Zt(t,e=>h(e)),_=L.useRef(null),v=L.useRef(``),y=p.viewport,b=r.content-r.viewport,x=gn(u),S=gn(c),ee=Go(d,10);function te(e){_.current&&l({x:e.clientX-_.current.left,y:e.clientY-_.current.top})}return L.useEffect(()=>{let e=e=>{let t=e.target;m?.contains(t)&&x(e,b)};return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[y,m,b,x]),L.useEffect(S,[r,S]),Ko(m,ee),Ko(p.content,ee),(0,R.jsx)(Oo,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:gn(a),onThumbPointerUp:gn(o),onThumbPositionChange:S,onThumbPointerDown:gn(s),children:(0,R.jsx)(j.div,{...f,ref:g,style:{position:`absolute`,...f.style},onPointerDown:M(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),_.current=m.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,p.viewport&&(p.viewport.style.scrollBehavior=`auto`),te(e))}),onPointerMove:M(e.onPointerMove,te),onPointerUp:M(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=v.current,p.viewport&&(p.viewport.style.scrollBehavior=``),_.current=null})})})}),jo=`ScrollAreaThumb`,Mo=L.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=ko(jo,e.__scopeScrollArea);return(0,R.jsx)(sn,{present:n||i.hasThumb,children:(0,R.jsx)(No,{ref:t,...r})})}),No=L.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:r,...i}=e,a=go(jo,n),o=ko(jo,n),{onThumbPositionChange:s}=o,c=Zt(t,e=>o.onThumbChange(e)),l=L.useRef(void 0),u=Go(()=>{l.current&&=(l.current(),void 0)},100);return L.useEffect(()=>{let e=a.viewport;if(e){let t=()=>{u(),l.current||(l.current=Wo(e,s),s())};return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,R.jsx)(j.div,{"data-state":o.hasThumb?`visible`:`hidden`,...i,ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:M(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:M(e.onPointerUp,o.onThumbPointerUp)})});Mo.displayName=jo;var Po=`ScrollAreaCorner`,Fo=L.forwardRef((e,t)=>{let n=go(Po,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,R.jsx)(Io,{...e,ref:t}):null});Fo.displayName=Po;var Io=L.forwardRef((e,t)=>{let{__scopeScrollArea:n,...r}=e,i=go(Po,n),[a,o]=L.useState(0),[s,c]=L.useState(0),l=!!(a&&s);return Ko(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),Ko(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),l?(0,R.jsx)(j.div,{...r,ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null});function Lo(e){return e?parseInt(e,10):0}function Ro(e,t){let n=e/t;return isNaN(n)?0:n}function zo(e){let t=Ro(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Bo(e,t,n,r=`ltr`){let i=zo(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return Ho([c,l],d)(e)}function Vo(e,t,n=`ltr`){let r=zo(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=wn(e,n===`ltr`?[0,o]:[o*-1,0]);return Ho([0,o],[0,s])(c)}function Ho(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Uo(e,t){return e>0&&e<t}var Wo=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return(function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)})(),()=>window.cancelAnimationFrame(r)};function Go(e,t){let n=gn(e),r=L.useRef(0);return L.useEffect(()=>()=>window.clearTimeout(r.current),[]),L.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Ko(e,t){let n=gn(t);rn(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}var qo=_o,Jo=yo,Yo=Fo,Xo=`Separator`,Zo=`horizontal`,Qo=[`horizontal`,`vertical`],$o=L.forwardRef((e,t)=>{let{decorative:n,orientation:r=Zo,...i}=e,a=es(r)?r:Zo,o=n?{role:`none`}:{"aria-orientation":a===`vertical`?a:void 0,role:`separator`};return(0,R.jsx)(j.div,{"data-orientation":a,...o,...i,ref:t})});$o.displayName=Xo;function es(e){return Qo.includes(e)}var ts=$o,ns=`Switch`,[rs,is]=tn(ns),[as,os]=rs(ns),ss=L.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,p]=L.useState(null),m=Zt(t,e=>p(e)),h=L.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=on({prop:i,defaultProp:a??!1,onChange:l,caller:ns});return(0,R.jsxs)(as,{scope:n,checked:_,disabled:s,children:[(0,R.jsx)(j.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":fs(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:M(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,R.jsx)(ds,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});ss.displayName=ns;var cs=`SwitchThumb`,ls=L.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=os(cs,n);return(0,R.jsx)(j.span,{"data-state":fs(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});ls.displayName=cs;var us=`SwitchBubbleInput`,ds=L.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=L.useRef(null),s=Zt(o,a),c=_n(n),l=vn(t);return L.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,R.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});ds.displayName=us;function fs(e){return e?`checked`:`unchecked`}var ps=ss,ms=ls,hs=`Tabs`,[gs,_s]=tn(hs,[Or]),vs=Or(),[ys,bs]=gs(hs),xs=L.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=hn(s),[d,f]=on({prop:r,onChange:i,defaultProp:a??``,caller:hs});return(0,R.jsx)(ys,{scope:n,baseId:pn(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,R.jsx)(j.div,{dir:u,"data-orientation":o,...l,ref:t})})});xs.displayName=hs;var Ss=`TabsList`,Cs=L.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=bs(Ss,n),o=vs(n);return(0,R.jsx)(Br,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,R.jsx)(j.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});Cs.displayName=Ss;var ws=`TabsTrigger`,Ts=L.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=bs(ws,n),s=vs(n),c=Os(o.baseId,r),l=ks(o.baseId,r),u=r===o.value;return(0,R.jsx)(Vr,{asChild:!0,...s,focusable:!i,active:u,children:(0,R.jsx)(j.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:M(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:M(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:M(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});Ts.displayName=ws;var Es=`TabsContent`,Ds=L.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=bs(Es,n),c=Os(s.baseId,r),l=ks(s.baseId,r),u=r===s.value,d=L.useRef(u);return L.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,R.jsx)(sn,{present:i||u,children:({present:n})=>(0,R.jsx)(j.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})});Ds.displayName=Es;function Os(e,t){return`${e}-trigger-${t}`}function ks(e,t){return`${e}-content-${t}`}var As=xs,js=Cs,Ms=Ts,Ns=Ds,[Ps,Fs]=tn(`Tooltip`,[yn]),Is=yn(),Ls=`TooltipProvider`,Rs=700,zs=`tooltip.open`,[Bs,Vs]=Ps(Ls),Hs=e=>{let{__scopeTooltip:t,delayDuration:n=Rs,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=L.useRef(!0),s=L.useRef(!1),c=L.useRef(0);return L.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,R.jsx)(Bs,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:L.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:L.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:L.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};Hs.displayName=Ls;var Us=`Tooltip`,[Ws,Gs]=Ps(Us),Ks=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=Vs(Us,e.__scopeTooltip),l=Is(t),[u,d]=L.useState(null),f=pn(),p=L.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=L.useRef(!1),[_,v]=on({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(zs))):c.onClose(),a?.(e)},caller:Us}),y=L.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=L.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=L.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=L.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return L.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,R.jsx)(bn,{...l,children:(0,R.jsx)(Ws,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:L.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:L.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};Ks.displayName=Us;var qs=`TooltipTrigger`,Js=L.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Gs(qs,n),a=Vs(qs,n),o=Is(n),s=Zt(t,L.useRef(null),i.onTriggerChange),c=L.useRef(!1),l=L.useRef(!1),u=L.useCallback(()=>c.current=!1,[]);return L.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,R.jsx)(Cn,{asChild:!0,...o,children:(0,R.jsx)(j.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:M(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:M(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:M(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:M(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:M(e.onBlur,i.onClose),onClick:M(e.onClick,i.onClose)})})});Js.displayName=qs;var Ys=`TooltipPortal`,[Xs,Zs]=Ps(Ys,{forceMount:void 0}),Qs=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=Gs(Ys,t);return(0,R.jsx)(Xs,{scope:t,forceMount:n,children:(0,R.jsx)(sn,{present:n||a.open,children:(0,R.jsx)(ln,{asChild:!0,container:i,children:r})})})};Qs.displayName=Ys;var $s=`TooltipContent`,ec=L.forwardRef((e,t)=>{let n=Zs($s,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=Gs($s,e.__scopeTooltip);return(0,R.jsx)(sn,{present:r||o.open,children:o.disableHoverableContent?(0,R.jsx)(ac,{side:i,...a,ref:t}):(0,R.jsx)(tc,{side:i,...a,ref:t})})}),tc=L.forwardRef((e,t)=>{let n=Gs($s,e.__scopeTooltip),r=Vs($s,e.__scopeTooltip),i=L.useRef(null),a=Zt(t,i),[o,s]=L.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=L.useCallback(()=>{s(null),d(!1)},[d]),p=L.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=lc(r,cc(r,n.getBoundingClientRect())),a=uc(t.getBoundingClientRect());s(fc([...i,...a])),d(!0)},[d]);return L.useEffect(()=>()=>f(),[f]),L.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),L.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!dc(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,R.jsx)(ac,{...e,ref:a})}),[nc,rc]=Ps(Us,{isInside:!1}),ic=Xt(`TooltipContent`),ac=L.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=Gs($s,n),l=Is(n),{onClose:u}=c;return L.useEffect(()=>(document.addEventListener(zs,u),()=>document.removeEventListener(zs,u)),[u]),L.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,R.jsx)(dn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,R.jsxs)(Sn,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,R.jsx)(ic,{children:r}),(0,R.jsx)(nc,{scope:n,isInside:!0,children:(0,R.jsx)(Nn,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});ec.displayName=$s;var oc=`TooltipArrow`,sc=L.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Is(n);return rc(oc,n).isInside?null:(0,R.jsx)(xn,{...i,...r,ref:t})});sc.displayName=oc;function cc(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function lc(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function uc(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function dc(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function fc(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),pc(t)}function pc(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var mc=Hs,hc=kn();function gc({delayDuration:e=0,...t}){return(0,R.jsx)(mc,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function U(e){return k(e)}function _c(){let e=U(e=>e.pairs);return(0,L.useMemo)(()=>{let t={};for(let n of e)(n.status===`active`||n.status===`pending`)&&(n.requesterId&&(t[n.requesterId]=n),n.targetId&&(t[n.targetId]=n));return t},[e])}function vc(e){let t=U(e=>e.messages),n=U(e=>e.tasks),r=U(e=>e.pairs),i=U(e=>e.inboxReadCursors),a=U(e=>e.inboxArchivedThreads);return(0,L.useMemo)(()=>{if(!e)return{unread:0,needsHumanResponse:!1,pendingPairInvite:!1,claimableTasks:0,total:0,score:0};let o=t.filter(t=>Tt(t)===e.id&&!Wt(t)),s=Number(a[e.id]||0),c=s>=o.filter(e=>ut(e)&&Dt(e)).reduce((e,t)=>Math.max(e,t.id),0)&&s>0?0:o.filter(t=>ft(i,e.id,t)).length,l=zt(e),u=r.find(t=>(t.status===`active`||t.status===`pending`)&&(t.requesterId===e.id||t.targetId===e.id))?.status===`pending`,d=n.filter(t=>_t(t)&&Ht(t.target,e)).length+t.filter(t=>Gt(t)&&Ht(t.to,e)).length;return{unread:c,needsHumanResponse:l,pendingPairInvite:u,claimableTasks:d,total:c+ +!!l+ +!!u+d,score:c*10+(l?8:0)+(u?4:0)+d*2}},[e,t,n,r,i,a])}function yc(){let e=U(e=>e.agents),t=U(e=>e.showBuiltIns),n=U(e=>e.showOffline),r=U(e=>e.agentSort),i=U(e=>e.agentSortDir),a=U(e=>e.agentPresetFilter),o=U(e=>e.agentStatusFilter),s=U(e=>e.agentTagFilter),c=U(e=>e.agentHostFilter),l=U(e=>e.managedPolicies),u=U(e=>e.pairs);return(0,L.useMemo)(()=>{let d=Rt(e,t,l);if(a){let e=bc(u);d=xc(d,a,at.getState().now,e)}n||(d=d.filter(e=>e.status!==`offline`)),o===`starting`?d=d.filter(e=>e.status!==`offline`&&!e.ready):o&&(d=d.filter(e=>e.status===o)),s&&(d=d.filter(e=>(e.tags||[]).includes(s))),c&&(d=d.filter(e=>(e.machine||``)===c));let f=i===`desc`?-1:1;return[...d].sort((e,t)=>r===`name`?A(e).localeCompare(A(t))*f:r===`lastSeen`?(new Date(t.lastSeen).getTime()-new Date(e.lastSeen).getTime())*f||A(e).localeCompare(A(t)):r===`created`?(new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime())*f||A(e).localeCompare(A(t)):((Ut[e.status]??9)-(Ut[t.status]??9))*f||A(e).localeCompare(A(t)))},[e,t,n,l,r,i,a,o,s,c,u,ct()])}function bc(e){let t={};for(let n of e)(n.status===`active`||n.status===`pending`)&&(n.requesterId&&(t[n.requesterId]=n),n.targetId&&(t[n.targetId]=n));return t}function xc(e,t,n,r){switch(t){case`active`:return e.filter(e=>e.status!==`offline`);case`offline_stale`:return e.filter(e=>e.status===`offline`||Kt(n,e));case`claude`:case`codex`:return e.filter(e=>It(e)===t);case`paired`:return e.filter(e=>!!r[e.id]);case`unpaired`:return e.filter(e=>!r[e.id]);default:return e}}function Sc(){let e=U(e=>e.messages),t=U(e=>e.inboxReadCursors),n=U(e=>e.inboxArchivedThreads),r=U(e=>e.inboxDrafts),i=U(e=>e.agentsById);return(0,L.useMemo)(()=>{let a=new Map;for(let t of e){if(Wt(t))continue;let e=Tt(t);e&&(a.has(e)||a.set(e,{id:e,peer:e,messages:[],lastMessage:null,previewMessage:null,attention:{unread:0,needsHumanResponse:!1,score:0},archived:!1,draft:``}),a.get(e).messages.push(t))}for(let e of a.values()){e.messages.sort((e,t)=>e.id-t.id),e.lastMessage=e.messages[e.messages.length-1]||null;let a=null;for(let t=e.messages.length-1;t>=0;t--){let n=e.messages[t];if(n&&!vt(n)){a=n;break}}e.previewMessage=a||e.lastMessage;let o=e.messages.filter(n=>ft(t,e.peer,n)).length,s=zt(i[e.peer]);e.attention={unread:o,needsHumanResponse:s,score:o*10+(s?8:0)};let c=Number(n[e.peer]||0);e.archived=!!(e.lastMessage?.id&&c>=e.lastMessage.id),e.draft=r[e.peer]||``}return[...a.values()].sort((e,t)=>{let n=(t.attention.score||0)-(e.attention.score||0);return n===0?(t.lastMessage?.id||0)-(e.lastMessage?.id||0):n})},[e,t,n,r,i])}function Cc(){let e=Sc(),t=U(e=>e.agents),n=U(e=>e.showBuiltIns),r=U(e=>e.showOffline),i=U(e=>e.managedPolicies),a=U(e=>e.pairs),o=U(e=>e.tasks),s=U(e=>e.messages),c=(0,L.useMemo)(()=>new Set(Rt(t,n,i).filter(e=>r||e.status!==`offline`).map(e=>e.id)),[t,n,r,i]);return(0,L.useMemo)(()=>{let l=e.filter(e=>!e.archived&&c.has(e.peer)).reduce((e,t)=>e+(t.attention.unread||0),0),u=Rt(t,n,i).filter(e=>(r||e.status!==`offline`)&&zt(e)).length,d=a.filter(e=>e.status===`pending`).length,f=o.filter(_t).length+s.filter(Gt).length;return{unreadInbox:l,needsHumanResponse:u,pendingPairInvites:d,claimableTasks:f,total:l+u+d+f}},[e,c,t,n,r,i,a,o,s])}function wc(){let e=U(e=>e.agents),t=U(e=>e.showBuiltIns),n=U(e=>e.managedPolicies);return(0,L.useMemo)(()=>Rt(e,t,n).filter(e=>e.status!==`offline`).length,[e,t,n])}function Tc(){let e=U(e=>e.agents);return(0,L.useMemo)(()=>e.filter(e=>e.status===`busy`).length,[e])}function Ec(){let e=U(e=>e.agents),t=U(e=>e.showBuiltIns),n=U(e=>e.showOffline),r=U(e=>e.managedPolicies);return(0,L.useMemo)(()=>{let i=Rt(e,t,r);return n?i:i.filter(e=>e.status!==`offline`)},[e,t,n,r])}function Dc(){let e=U(e=>e.agents),t=U(e=>e.showBuiltIns),n=U(e=>e.managedPolicies);return(0,L.useMemo)(()=>[...new Set(Rt(e,t,n).map(e=>e.machine).filter(Boolean))].sort(),[e,t,n])}function Oc(){let e=U(e=>e.agents),t=U(e=>e.showBuiltIns),n=U(e=>e.managedPolicies);return(0,L.useMemo)(()=>[...new Set(Rt(e,t,n).flatMap(e=>e.tags||[]))],[e,t,n])}function kc(){let e=U(e=>e.tasks),t=U(e=>e.messages);return(0,L.useMemo)(()=>{let n=e.filter(e=>!lt.has(e.status)).map(e=>({id:`task-`+e.id,sourceType:`task`,title:e.title,body:e.body,severity:e.severity||`info`,status:e.status,owner:e.claimedBy||``,target:e.target,source:e.source,channel:e.channel||``,updatedAt:e.updatedAt||e.createdAt,createdAt:e.createdAt,claimable:_t(e),task:e})),r=t.filter(Gt).map(e=>({id:`message-`+e.id,sourceType:`message`,title:e.subject||`Claimable message #`+e.id,body:dt(e),severity:`warning`,status:e.claimedBy?`claimed`:`open`,owner:e.claimedBy||``,target:e.to,source:`message`,channel:e.channel||``,updatedAt:e.claimedAt||e.createdAt,createdAt:e.createdAt,claimable:Gt(e),message:e}));return[...n,...r].sort((e,t)=>{let n=Number(t.claimable)-Number(e.claimable);if(n!==0)return n;let r={critical:0,warning:1,info:2},i=(r[e.severity]??9)-(r[t.severity]??9);return i===0?xt(e.updatedAt)-xt(t.updatedAt):i})},[e,t])}function Ac(){let e=U(e=>e.commandQuery),t=U(e=>e.agents),n=U(e=>e.agentsById),r=U(e=>e.showBuiltIns),i=U(e=>e.showOffline),a=U(e=>e.managedPolicies);return(0,L.useMemo)(()=>{let n=Rt(t,r,a).filter(e=>i||e.status!==`offline`),o=[...new Set(n.flatMap(e=>e.tags||[]))],s=se(),c=[jc(`open-chat`,`Open chat`,`Human console`,`MessageCircle`,`openView`,{view:`chat`}),jc(`open-work`,`Open work queue`,`Claimable messages and tasks`,`ListChecks`,`openView`,{view:`work`}),jc(`open-workspaces`,`Open workspaces`,`Agent worktrees and merge state`,`GitBranch`,`openView`,{view:`workspaces`}),jc(`show-stale`,`Show stale agents`,`Filter agents to offline or stale`,`Filter`,`agentPreset`,{preset:`offline_stale`}),jc(`copy-url`,`Copy relay URL`,s,`Copy`,`copy`,{value:s}),jc(`export-md`,`Export timeline as Markdown`,`Activity audit trace`,`FileDown`,`exportActivity`,{format:`markdown`}),jc(`export-json`,`Export timeline as JSON`,`Activity audit trace`,`Braces`,`exportActivity`,{format:`json`}),...n.slice(0,12).map(e=>jc(`msg-`+e.id,`Message agent: `+A(e),e.id,`Send`,`messageAgent`,{agentId:e.id})),...n.filter(e=>It(e)===`codex`).slice(0,8).map(e=>jc(`pair-`+e.id,`Pair Codex: `+A(e),e.id,`Link`,`pairAgent`,{agentId:e.id})),...o.map(e=>jc(`tag-`+e,`Filter tag: `+e,`#`+e,`Tag`,`filterTag`,{tag:e}))],l=e.trim().toLowerCase();return(l?c.filter(e=>e.search.includes(l)):c).slice(0,24)},[e,t,n,r,i,a])}function jc(e,t,n,r,i,a){return{id:e,title:t,subtitle:n,icon:r,action:i,payload:a,search:`${t}\n${n}\n${i}`.toLowerCase()}}function Mc({className:e,size:t=`default`,...n}){return(0,R.jsx)(ps,{"data-slot":`switch`,"data-size":t,className:S(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,R.jsx)(ms,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`})})}function Nc({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,R.jsx)(ts,{"data-slot":`separator`,decorative:n,orientation:t,className:S(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...r})}function Pc({...e}){return(0,R.jsx)(no,{"data-slot":`dropdown-menu`,...e})}function Fc({...e}){return(0,R.jsx)(ro,{"data-slot":`dropdown-menu-trigger`,...e})}function Ic({className:e,align:t=`start`,sideOffset:n=4,...r}){return(0,R.jsx)(io,{children:(0,R.jsx)(ao,{"data-slot":`dropdown-menu-content`,sideOffset:n,align:t,className:S(`z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}function Lc({className:e,inset:t,variant:n=`default`,...r}){return(0,R.jsx)(so,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:S(`group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function Rc({className:e,inset:t,...n}){return(0,R.jsx)(oo,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:S(`px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7`,e),...n})}function zc({className:e,...t}){return(0,R.jsx)(co,{"data-slot":`dropdown-menu-separator`,className:S(`-mx-1 my-1 h-px bg-border`,e),...t})}var Bc={LayoutDashboard:Se,MessageCircle:ue,Bot:tt,Server:ie,MessagesSquare:m,Plug:f,PlugZap:ne,Activity:y,Link:ve,Mail:be,ListChecks:Ge,ClipboardList:de,CalendarClock:Ie,AreaChart:xe,Settings:Qe,Workflow:Re,BrainCircuit:pe,FolderTree:c,Shield:re,Wrench:me,UserCog:D,Lightbulb:ye,Users:Me};function Vc(e){return new Date(e.createdAt).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}var Hc=[[`messages`,`Messages`],[`replies`,`Replies`],[`errors`,`Errors`]];function Uc(){let e=k(e=>e.notifications),t=k(e=>e.notificationUnread),n=k(e=>e.notificationSettings),r=k(e=>e.notificationPermission),i=k(e=>e.set),a=k(e=>e.openNotification),o=k(e=>e.markNotificationsRead),s=k(e=>e.clearNotifications),c=k(e=>e.requestBrowserNotifications),l=t>0?et:ge;function u(e){i({notificationSettings:{...n,...e}})}return(0,R.jsxs)(Pc,{onOpenChange:e=>{e&&o()},children:[(0,R.jsx)(Fc,{asChild:!0,children:(0,R.jsxs)(`button`,{className:`relative flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors w-full`,children:[(0,R.jsx)(l,{className:`w-3.5 h-3.5`}),(0,R.jsx)(`span`,{children:`Notifications`}),t>0&&(0,R.jsx)(N,{variant:`destructive`,className:`ml-auto text-[10px] px-1.5 py-0`,children:t})]})}),(0,R.jsxs)(Ic,{align:`start`,side:`right`,className:`w-80 p-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1.5 py-1`,children:[(0,R.jsx)(Rc,{className:`p-0`,children:`Notifications`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`button`,{type:`button`,title:`Mark read`,onClick:o,className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,children:(0,R.jsx)(Ye,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(`button`,{type:`button`,title:`Clear`,onClick:s,className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,children:(0,R.jsx)(Fe,{className:`h-3.5 w-3.5`})})]})]}),(0,R.jsxs)(`div`,{className:`px-1.5 py-1.5 space-y-2`,children:[(0,R.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`In-app notifications`}),(0,R.jsx)(Mc,{size:`sm`,checked:n.enabled,onCheckedChange:e=>u({enabled:e})})]}),(0,R.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Browser notifications`}),(0,R.jsx)(Mc,{size:`sm`,checked:n.browserEnabled&&r===`granted`,disabled:r===`unsupported`,onCheckedChange:e=>{e&&r!==`granted`?c():u({browserEnabled:e})}})]}),(0,R.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,children:Hc.map(([e,t])=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>u({[e]:!n[e]}),className:S(`rounded border px-2 py-1 text-[11px] transition-colors`,n[e]?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-accent`),children:t},e))})]}),(0,R.jsx)(zc,{}),(0,R.jsx)(`div`,{className:`max-h-80 overflow-y-auto`,children:e.length===0?(0,R.jsx)(`div`,{className:`px-1.5 py-8 text-center text-xs text-muted-foreground`,children:`No notifications`}):e.slice(0,20).map(e=>(0,R.jsxs)(Lc,{onSelect:t=>{t.preventDefault(),a(e)},className:`flex flex-col items-start gap-0.5 px-2 py-2`,children:[(0,R.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[(0,R.jsx)(`span`,{className:S(`h-1.5 w-1.5 rounded-full`,e.severity===`error`?`bg-red-400`:e.severity===`warning`?`bg-yellow-400`:`bg-blue-400`)}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium`,children:e.title}),(0,R.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Vc(e)})]}),(0,R.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:e.body})]},e.id))})]})]})}function Wc(){let e=k(e=>e.theme),t=k(e=>e.set);return(0,R.jsxs)(Pc,{children:[(0,R.jsx)(Fc,{asChild:!0,children:(0,R.jsxs)(`button`,{className:`flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors w-full`,children:[(0,R.jsx)(w,{className:`w-3.5 h-3.5`}),(0,R.jsx)(`span`,{children:`Theme`}),(0,R.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:Jt.find(t=>t.id===e)?.label})]})}),(0,R.jsx)(Ic,{align:`start`,side:`right`,className:`w-40`,children:Jt.map(n=>(0,R.jsxs)(Lc,{onSelect:()=>t({theme:n.id}),children:[(0,R.jsx)(`span`,{className:`flex-1`,children:n.label}),e===n.id&&(0,R.jsx)(Ne,{className:`w-3.5 h-3.5 text-primary`})]},n.id))})]})}function Gc(){let e=k(e=>e.view),t=k(e=>e.switchView),n=k(e=>e.connected),r=k(e=>e.showOffline),i=k(e=>e.showBuiltIns),a=k(e=>e.autoRefresh),o=k(e=>e.stats),s=k(e=>e.openCommandPalette),c=k(e=>e.set),l=k(e=>e.startAutoRefresh),u=k(e=>e.stopAutoRefresh),d=Cc(),f=wc();function p(e){return e===`overview`&&d.total>0?(0,R.jsx)(N,{variant:`destructive`,className:`ml-auto text-[10px] px-1.5 py-0`,children:d.total}):e===`chat`&&d.unreadInbox>0?(0,R.jsx)(N,{variant:`destructive`,className:`ml-auto text-[10px] px-1.5 py-0`,children:d.unreadInbox}):e===`agents`?(0,R.jsx)(N,{variant:`secondary`,className:`ml-auto text-[10px] px-1.5 py-0`,children:f}):e===`pairs`&&d.pendingPairInvites>0?(0,R.jsx)(N,{className:`ml-auto text-[10px] px-1.5 py-0 bg-yellow-500/20 text-yellow-400`,children:d.pendingPairInvites}):e===`work`&&d.claimableTasks>0?(0,R.jsx)(N,{className:`ml-auto text-[10px] px-1.5 py-0 bg-yellow-500/20 text-yellow-400`,children:d.claimableTasks}):null}return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`nav`,{className:`flex-1 overflow-y-auto py-2 px-2`,children:Bt.map(n=>{let r=Bc[n.icon]||tt;return(0,R.jsxs)(`button`,{onClick:()=>t(n.key),className:S(`w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm transition-colors my-0.5`,e===n.key?`bg-primary text-primary-foreground`:`text-foreground hover:bg-accent`),children:[(0,R.jsx)(r,{className:`w-4 h-4 shrink-0`}),n.label,p(n.key)]},n.key)})}),(0,R.jsxs)(`div`,{className:`mt-auto border-t border-border p-4 space-y-3 text-xs`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:S(`w-2 h-2 rounded-full`,n?`bg-emerald-500`:`bg-red-500 animate-pulse`)}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:n?`Live`:`Reconnecting...`})]}),(0,R.jsxs)(`button`,{onClick:s,className:`flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors w-full`,children:[(0,R.jsx)(O,{className:`w-3.5 h-3.5`}),(0,R.jsx)(`span`,{children:`Command palette`}),(0,R.jsx)(`kbd`,{className:`ml-auto text-[10px] bg-muted px-1.5 py-0.5 rounded`,children:`⌘K`})]}),(0,R.jsx)(Uc,{}),(0,R.jsx)(Wc,{}),(0,R.jsx)(Nc,{}),(0,R.jsxs)(`label`,{className:`flex items-center justify-between cursor-pointer`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Show offline`}),(0,R.jsx)(Mc,{checked:r,onCheckedChange:e=>c({showOffline:e})})]}),(0,R.jsxs)(`label`,{className:`flex items-center justify-between cursor-pointer`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`System agents`}),(0,R.jsx)(Mc,{checked:i,onCheckedChange:e=>c({showBuiltIns:e})})]}),(0,R.jsxs)(`label`,{className:`flex items-center justify-between cursor-pointer`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Auto refresh`}),(0,R.jsx)(Mc,{checked:a,onCheckedChange:e=>{c({autoRefresh:e}),e?l():u()}})]}),o.version&&(0,R.jsxs)(`div`,{className:`text-muted-foreground pt-1`,children:[`v`,o.version]})]})]})}function Kc(){return(0,R.jsxs)(`aside`,{className:`hidden xl:flex w-[250px] min-w-[250px] h-[calc(100dvh-var(--sat))] sticky top-[var(--sat)] flex-col border-r border-border bg-card`,children:[(0,R.jsxs)(`div`,{className:`px-5 py-4 font-bold text-base border-b border-border flex items-center gap-2`,children:[(0,R.jsx)(C,{className:`w-4 h-4 text-primary`}),`Agent Relay`]}),(0,R.jsx)(Gc,{})]})}function qc(){let e=k(e=>e.mobileMenuOpen),t=k(e=>e.set);return(0,L.useEffect)(()=>{if(!e)return;function n(e){e.key===`Escape`&&t({mobileMenuOpen:!1})}return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e]),(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:S(`xl:hidden fixed inset-0 z-40 bg-black/50 transition-opacity duration-200`,e?`opacity-100`:`opacity-0 pointer-events-none`),onClick:()=>t({mobileMenuOpen:!1})}),(0,R.jsxs)(`aside`,{inert:!e,className:S(`xl:hidden fixed inset-y-0 left-0 z-50 w-[280px] flex flex-col pt-[var(--sat)] bg-card border-r border-border transition-transform duration-200 ease-out`,e?`translate-x-0`:`-translate-x-full`),children:[(0,R.jsxs)(`div`,{className:`px-5 py-4 font-bold text-base border-b border-border flex items-center gap-2`,children:[(0,R.jsx)(C,{className:`w-4 h-4 text-primary`}),`Agent Relay`,(0,R.jsx)(`button`,{onClick:()=>t({mobileMenuOpen:!1}),className:`ml-auto p-1 text-muted-foreground hover:text-foreground transition-colors`,"aria-label":`Close menu`,children:(0,R.jsx)(Ee,{className:`w-4 h-4`})})]}),(0,R.jsx)(Gc,{})]})]})}var Jc=500*1024,Yc={bash:`bash`,c:`c`,conf:`properties`,cpp:`cpp`,cs:`csharp`,css:`css`,csv:`csv`,cts:`typescript`,diff:`diff`,dockerfile:`dockerfile`,env:`dotenv`,gemspec:`ruby`,go:`go`,graphql:`graphql`,h:`c`,hcl:`hcl`,hpp:`cpp`,html:`html`,ini:`ini`,java:`java`,js:`javascript`,json:`json`,jsonc:`jsonc`,jsx:`jsx`,kt:`kotlin`,less:`less`,log:`log`,lua:`lua`,mjs:`javascript`,mts:`typescript`,patch:`diff`,php:`php`,plist:`xml`,podspec:`ruby`,properties:`properties`,py:`python`,rake:`ruby`,rb:`ruby`,rs:`rust`,scss:`scss`,sh:`bash`,sql:`sql`,svelte:`svelte`,swift:`swift`,toml:`toml`,ts:`typescript`,tsx:`tsx`,txt:`text`,vue:`vue`,webmanifest:`json`,xml:`xml`,yaml:`yaml`,yml:`yaml`,zsh:`bash`},Xc={".bashrc":`bash`,".env":`dotenv`,".eslintrc":`json`,".gitignore":`gitignore`,".npmrc":`properties`,".prettierrc":`json`,".swiftformat":`properties`,".swiftlint.yml":`yaml`,".watchmanconfig":`json`,"app.config":`json`,"app.webmanifest":`json`,berksfile:`ruby`,brewfile:`ruby`,"bun.lock":`json`,capfile:`ruby`,cartfile:`ruby`,"composer.lock":`json`,dangerfile:`ruby`,"deno.lock":`json`,fastfile:`ruby`,"flake.lock":`json`,gemfile:`ruby`,guardfile:`ruby`,podfile:`ruby`,rakefile:`ruby`,dockerfile:`dockerfile`,makefile:`make`},Zc=null;function Qc(){return Zc??=I(()=>import(`./bundle-web-CXNb85wK.js`),__vite__mapDeps([0,1,2,3]),import.meta.url),Zc}function $c(e){return new TextEncoder().encode(e).length}function el(e){return e.split(`/`).filter(Boolean).pop()||e}function tl(e){let t=e?.slice(0,240).split(/\r?\n/,1)[0]?.toLowerCase()||``;return t.startsWith(`#!`)?/\b(bash|dash|ksh|sh|zsh)\b/.test(t)?`bash`:/\bfish\b/.test(t)?`fish`:/\b(ts-node|tsx)\b/.test(t)?`typescript`:/\b(node|bun|deno)\b/.test(t)?`javascript`:/\bpython[0-9.]*\b/.test(t)?`python`:/\bruby\b/.test(t)?`ruby`:/\bswift\b/.test(t)?`swift`:/\bperl\b/.test(t)?`perl`:/\bphp\b/.test(t)?`php`:null:null}function nl(e,t,n,r){if(n)return n;let i=el(e).toLowerCase();if(Xc[i])return Xc[i];if(i.endsWith(`.d.ts`))return`typescript`;let a=tl(r);if(a)return a;let o=i.includes(`.`)?i.slice(i.lastIndexOf(`.`)+1):``;return o&&Yc[o]?Yc[o]:t?.includes(`json`)?`json`:t?.includes(`javascript`)?`javascript`:t?.includes(`typescript`)?`typescript`:t?.includes(`xml`)?`xml`:t?.includes(`yaml`)||t?.includes(`yml`)?`yaml`:t?.includes(`shellscript`)?`bash`:null}function rl(e,t,n,r){let i=nl(e,t,n,r);return!!(i&&i!==`text`&&i!==`log`)}var il=(0,L.memo)(function({content:e,path:t,mediaType:n,languageHint:r,compact:i=!1}){let a=k(e=>e.theme),o=Jt.find(e=>e.id===a)?.dark??!0,s=(0,L.useMemo)(()=>nl(t,n,r,e)||`text`,[e,r,n,t]),c=$c(e)>Jc,[l,u]=(0,L.useState)(``),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)(!1);function h(){return(0,R.jsx)(Tn,{value:e,label:`Copy code`,copiedLabel:`Copied code`,size:`icon`,variant:`ghost`,className:`absolute right-2 top-2 h-7 w-7 bg-background/80 opacity-0 shadow-sm backdrop-blur transition-opacity hover:bg-muted group-hover/code:opacity-100 focus-visible:opacity-100`})}return(0,L.useEffect)(()=>{if(c||s===`text`||s===`log`){u(``),f(!1),m(!1);return}let t=!1;return f(!0),m(!1),Qc().then(({codeToHtml:t})=>t(e,{lang:s,theme:o?`github-dark-default`:`github-light-default`})).then(e=>{t||u(e)}).catch(()=>{t||(u(``),m(!0))}).finally(()=>{t||f(!1)}),()=>{t=!0}},[e,o,s,c]),d?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-sm text-muted-foreground`,children:[(0,R.jsx)(Be,{className:`h-4 w-4 animate-spin`}),`Highlighting`]}):c||p||!l?(0,R.jsxs)(`div`,{className:`group/code relative`,children:[h(),(0,R.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap break-words font-mono text-xs leading-5 ${i?`p-3`:`p-4`}`,children:e||` `})]}):(0,R.jsxs)(`div`,{className:`group/code relative`,children:[h(),(0,R.jsx)(`div`,{className:`code-preview overflow-auto font-mono text-xs leading-5 ${i?`p-3`:`p-4`}`,dangerouslySetInnerHTML:{__html:l}})]})}),al=(0,L.lazy)(()=>I(()=>import(`./markdown-preview-impl-DZlCaTHQ.js`).then(e=>({default:e.MarkdownPreview})),__vite__mapDeps([4,5,1,3,6]),import.meta.url));function ol(e){return(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading preview…`}),children:(0,R.jsx)(al,{...e})})}var sl=e(it(),1);function cl({src:e,alt:t,onClose:n}){let[r,i]=(0,L.useState)(!1);return(0,L.useEffect)(()=>{let e=document.body.style.overflow;document.body.style.overflow=`hidden`;function t(e){e.key===`Escape`&&n()}return document.addEventListener(`keydown`,t),()=>{document.body.style.overflow=e,document.removeEventListener(`keydown`,t)}},[n]),(0,R.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex flex-col bg-black/95`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 p-2`,children:[(0,R.jsx)(`button`,{type:`button`,className:`rounded-full bg-white/10 p-2 text-white/70 hover:bg-white/20 hover:text-white`,onClick:()=>i(!r),title:r?`Fit to screen`:`Actual size`,children:r?(0,R.jsx)(Le,{className:`h-4 w-4`}):(0,R.jsx)(We,{className:`h-4 w-4`})}),(0,R.jsx)(`button`,{type:`button`,className:`rounded-full bg-white/10 p-2 text-white/70 hover:bg-white/20 hover:text-white`,onClick:n,title:`Close`,children:(0,R.jsx)(Ee,{className:`h-4 w-4`})})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 ${r?`overflow-auto`:`flex items-center justify-center overflow-hidden p-4`}`,onClick:r?void 0:n,children:(0,R.jsx)(`img`,{src:e,alt:t,className:r?`max-w-none`:`max-h-full max-w-full cursor-zoom-in object-contain`,onClick:e=>{e.stopPropagation(),i(!r)}})})]})}function ll({src:e,alt:t=``,className:n,style:r}){let[i,a]=(0,L.useState)(!1);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`img`,{src:e,alt:t,className:`${n||``} cursor-zoom-in`,style:r,onClick:()=>a(!0)}),i&&(0,sl.createPortal)((0,R.jsx)(cl,{src:e,alt:t,onClose:()=>a(!1)}),document.body)]})}var ul=`agent-relay:file-git-status`;function dl(){try{return window.localStorage.getItem(ul)!==`off`}catch{return!0}}function fl(e){try{window.localStorage.setItem(ul,e?`on`:`off`)}catch{}}function pl(e){switch(e){case`staged`:return{dot:`bg-green-500`,text:`text-green-400`,label:`Staged`};case`unstaged`:return{dot:`bg-amber-500`,text:`text-amber-400`,label:`Modified (unstaged)`};case`staged-unstaged`:return{dot:`bg-amber-500`,text:`text-green-400`,label:`Staged + unstaged changes`};case`untracked`:return{dot:`bg-sky-500`,text:`text-sky-400`,label:`Untracked`};default:return null}}function ml(e,t,n){let r=`/orchestrators/${encodeURIComponent(e)}/files/list?path=${encodeURIComponent(t)}`;return n?`${r}&git=1`:r}function hl({status:e}){let t=pl(e);return t?(0,R.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${t.dot}`,title:t.label}):null}function gl(e){return e===void 0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function _l(e,t){let n=t.replace(/\/+$/,``);return e===n?`/`:e.startsWith(n+`/`)?e.slice(n.length+1):e}function vl(e,t){let n=e.toLowerCase();return n.endsWith(`.md`)||n.endsWith(`.mdx`)||n.endsWith(`.markdown`)||t===`text/markdown`}function yl(e,t,n){return vl(e,t)?`markdown`:rl(e,t,void 0,n)?`code`:null}function bl(e){return`agent-relay:file-view-mode:${e}`}function xl(e){try{let t=window.localStorage.getItem(bl(e));return t===`raw`||t===`rendered`?t:`rendered`}catch{return`rendered`}}function Sl(e,t){try{window.localStorage.setItem(bl(e),t)}catch{}}function Cl(e,t){let n=_l(e,t);if(n===`/`)return[{label:`/`,path:t}];let r=n.split(`/`).filter(Boolean),i=[{label:`/`,path:t}];for(let e=0;e<r.length;e++)i.push({label:r[e],path:`${t.replace(/\/+$/,``)}/${r.slice(0,e+1).join(`/`)}`});return i}function wl(e,t){let n=k(e=>e.apiCall),[r,i]=(0,L.useState)(null),[a,o]=(0,L.useState)(!1),[s,c]=(0,L.useState)(``);return(0,L.useEffect)(()=>{if(!e||!t){i(null),c(``);return}let r=!1;return o(!0),c(``),n(`GET`,`/orchestrators/${encodeURIComponent(e)}/files/read?path=${encodeURIComponent(t)}`).then(e=>{r||i(e)}).catch(e=>{r||(i(null),c(Ct(e)))}).finally(()=>{r||o(!1)}),()=>{r=!0}},[n,e,t]),{file:r,loading:a,error:s}}function Tl(e,t,n=!1){let r=k(e=>e.apiCall),[i,a]=(0,L.useState)(null),[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(``);return(0,L.useEffect)(()=>{if(!e||!t){a(null),l(``);return}let i=!1;return s(!0),l(``),r(`GET`,ml(e,t,n)).then(e=>{i||a(e)}).catch(e=>{i||(a(null),l(Ct(e)))}).finally(()=>{i||s(!1)}),()=>{i=!0}},[r,e,t,n]),{listing:i,loading:o,error:c}}function El({content:e,line:t,lineRef:n}){return(0,R.jsx)(`div`,{className:`w-full py-2 font-mono text-xs leading-5`,children:e.split(`
15
- `).map((e,r)=>{let i=r+1,a=i===t;return(0,R.jsxs)(`div`,{ref:a?n:void 0,className:`grid grid-cols-[2.5rem_minmax(0,1fr)] px-1 sm:grid-cols-[4rem_minmax(0,1fr)] sm:px-2 ${a?`bg-primary/15`:``}`,children:[(0,R.jsx)(`div`,{className:`select-none pr-2 text-right text-muted-foreground sm:pr-3`,children:i}),(0,R.jsx)(`pre`,{className:`overflow-hidden whitespace-pre-wrap break-words`,children:e||` `})]},i)})})}function Dl({orchestratorId:e,selectedPath:t,onReadError:n,git:r=!1}){let{listing:i,loading:a,error:o}=Tl(e,t,r);return(0,L.useEffect)(()=>{n(o)},[o,n]),t?a?(0,R.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(Be,{className:`h-4 w-4 animate-spin`}),`Loading directory`]}):o?(0,R.jsx)(`div`,{className:`h-full bg-muted/20`}):i?(0,R.jsxs)(`div`,{className:`h-full overflow-auto bg-muted/20`,children:[(0,R.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-background px-3 py-2 text-xs`,children:[(0,R.jsx)(ae,{className:`h-3.5 w-3.5 text-blue-400`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:i.path}),(0,R.jsxs)(N,{variant:`outline`,className:`text-[10px]`,children:[i.entries.length,` items`]})]}),(0,R.jsxs)(`div`,{className:`divide-y divide-border/60`,children:[i.entries.map(e=>{let t=e.type===`directory`?ae:b,n=pl(e.gitStatus);return(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[(0,R.jsx)(t,{className:`h-4 w-4 shrink-0 ${e.type===`directory`?`text-blue-400`:`text-muted-foreground`}`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs ${n?.text??``}`,children:e.name}),e.symlink&&(0,R.jsx)(Pe,{className:`h-3 w-3 shrink-0 text-muted-foreground/60`}),(0,R.jsx)(hl,{status:e.gitStatus}),e.type!==`directory`&&(0,R.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:gl(e.size)})]},e.path)}),i.entries.length===0&&(0,R.jsx)(`div`,{className:`px-3 py-8 text-center text-sm text-muted-foreground`,children:`No files`})]})]}):null:(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Select a directory to preview`})}function Ol({orchestratorId:e,selectedPath:t,line:n,onReadError:r}){let{file:i,loading:a,error:o}=wl(e,t),s=(0,L.useRef)(null),[c,l]=(0,L.useState)(`raw`);(0,L.useEffect)(()=>{r(o)},[o,r]),(0,L.useEffect)(()=>{n>0&&s.current?.scrollIntoView({block:`center`})},[i,n]),(0,L.useEffect)(()=>{if(!i||i.encoding===`binary`)return;if(n>0){l(`raw`);return}let e=yl(i.path,i.mediaType,i.content);l(e?xl(e):`raw`)},[i?.path,i?.encoding,i?.mediaType,i?.content,n]);function u(e,t){l(e),t&&Sl(t,e)}if(!t)return(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Select a file to preview`});if(a)return(0,R.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(Be,{className:`h-4 w-4 animate-spin`}),`Loading file`]});if(o)return(0,R.jsx)(`div`,{className:`h-full bg-muted/20`});if(!i)return null;if(i.encoding===`base64`)return(0,R.jsxs)(`div`,{className:`flex h-full flex-col bg-muted/20`,children:[(0,R.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-background px-3 py-2 text-xs`,children:[(0,R.jsx)(b,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:i.path}),(0,R.jsx)(Tn,{value:i.path,label:`Copy path`,copiedLabel:`Copied path`,size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0`}),(0,R.jsx)(N,{variant:`outline`,className:`text-[10px]`,children:gl(i.size)})]}),(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:(0,R.jsx)(ll,{src:`data:${i.mediaType};base64,${i.content??``}`,alt:i.name,className:`max-h-full max-w-full object-contain`,style:{imageRendering:i.mediaType===`image/svg+xml`?`auto`:void 0}})})]});if(i.encoding===`binary`)return(0,R.jsxs)(`div`,{className:`p-4 text-sm`,children:[(0,R.jsx)(`div`,{className:`font-medium`,children:i.name}),(0,R.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:i.truncated?`File too large to preview.`:`Binary file preview is not available.`}),(0,R.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,R.jsx)(N,{variant:`secondary`,children:i.mediaType}),(0,R.jsx)(N,{variant:`outline`,children:gl(i.size)})]})]});let d=i.content??``,f=vl(i.path,i.mediaType),p=!f&&rl(i.path,i.mediaType,void 0,d),m=f||p,h=f?`markdown`:p?`code`:null;return(0,R.jsxs)(`div`,{className:`h-full overflow-auto bg-muted/20`,children:[(0,R.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-background px-3 py-2 text-xs`,children:[(0,R.jsx)(b,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:i.path}),(0,R.jsx)(Tn,{value:i.path,label:`Copy path`,copiedLabel:`Copied path`,size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0`}),i.truncated&&(0,R.jsx)(N,{variant:`secondary`,className:`text-[10px]`,children:`truncated`}),(0,R.jsx)(N,{variant:`outline`,className:`text-[10px]`,children:gl(i.size)}),m&&(0,R.jsxs)(`div`,{className:`flex shrink-0 rounded-md border border-border bg-muted/40 p-0.5`,children:[(0,R.jsx)(`button`,{type:`button`,className:`rounded px-2 py-1 text-[10px] font-medium ${c===`raw`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>u(`raw`,h),children:`Raw`}),(0,R.jsx)(`button`,{type:`button`,className:`rounded px-2 py-1 text-[10px] font-medium ${c===`rendered`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>u(`rendered`,h),children:f?`Rendered`:`Highlighted`})]})]}),c===`rendered`&&f&&(0,R.jsx)(ol,{content:d,path:i.path}),c===`rendered`&&p&&(0,R.jsx)(il,{content:d,path:i.path,mediaType:i.mediaType}),c===`raw`&&(0,R.jsx)(El,{content:d,line:n,lineRef:s})]})}function kl({overlay:e=!1}){let t=k(e=>e.apiCall),n=k(e=>e.orchestrators),r=k(e=>e.fileOrchestratorId),i=k(e=>e.filePath),a=k(e=>e.fileSelectedPath),o=k(e=>e.fileSelectedLine),s=k(e=>e.set),l=k(e=>e.closeFileOverlay),u=k(e=>e.openOrchestratorSpawnAt),[d,f]=(0,L.useState)(null),[p,m]=(0,L.useState)(i),[h,g]=(0,L.useState)(!1),[v,y]=(0,L.useState)(``),[S,ee]=(0,L.useState)(``),[te,C]=(0,L.useState)(dl),ne=(0,L.useMemo)(()=>n.filter(e=>e.status===`online`),[n]),re=n.find(e=>e.id===r)||ne[0];(0,L.useEffect)(()=>{if(!re)return;let e={};r||(e.fileOrchestratorId=re.id),i||(e.filePath=re.baseDir),Object.keys(e).length&&s(e)},[r,i,re,s]),(0,L.useEffect)(()=>m(i),[i]);async function ie(e=i){if(!(!re||!e)){g(!0),y(``);try{let n=await t(`GET`,ml(re.id,e,te));f(n),s({filePath:n.path}),m(n.path),ee(``)}catch(e){y(Ct(e))}finally{g(!1)}}}(0,L.useEffect)(()=>{ie(i)},[re?.id,i,te]);function oe(e){C(e),fl(e)}function se(e){s({fileOrchestratorId:e,filePath:n.find(t=>t.id===e)?.baseDir||``,fileSelectedPath:``,fileSelectedLine:0})}function ce(e){ee(``),e.type===`directory`?s({filePath:e.path,fileSelectedPath:``,fileSelectedLine:0}):s({fileSelectedPath:e.path,fileSelectedLine:0})}function w(){if(!re)return;let t=p.trim()||i||re.baseDir;e&&l(),u({orchestratorId:re.id,cwd:t})}let le=d?Cl(d.path,d.baseDir):[],ue=v||S;return(0,R.jsxs)(`div`,{className:e?`flex h-full flex-col`:`flex h-[calc(100dvh-5rem)] flex-col gap-3 md:gap-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a?`hidden md:flex`:``}`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,R.jsx)(c,{className:`h-5 w-5 text-primary`}),`Files`]}),(0,R.jsxs)(`select`,{value:re?.id||``,onChange:e=>se(e.target.value),className:`h-9 rounded-md border border-input bg-background px-3 text-sm`,children:[ne.length===0&&(0,R.jsx)(`option`,{value:``,children:`No online orchestrators`}),ne.map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.hostname||e.id},e.id))]}),e&&(0,R.jsx)(P,{size:`icon`,variant:`ghost`,className:`ml-auto h-8 w-8`,onClick:l,title:`Close`,children:(0,R.jsx)(Ee,{className:`h-4 w-4`})})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a?`hidden md:flex`:``}`,children:[(0,R.jsx)(F,{value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&s({filePath:p,fileSelectedPath:``,fileSelectedLine:0})},className:`min-w-0 flex-1 basis-full font-mono text-xs sm:basis-auto`,placeholder:re?.baseDir||`Path`}),(0,R.jsxs)(P,{size:`sm`,variant:`outline`,className:`gap-1`,onClick:()=>ie(p),disabled:h||!re,children:[h?(0,R.jsx)(Be,{className:`h-3.5 w-3.5 animate-spin`}):(0,R.jsx)(x,{className:`h-3.5 w-3.5`}),`Open`]}),(0,R.jsxs)(P,{size:`sm`,className:`gap-1`,onClick:w,disabled:!re,children:[(0,R.jsx)(_,{className:`h-3.5 w-3.5`}),(0,R.jsx)(`span`,{className:`sm:hidden`,children:`Spawn`}),(0,R.jsx)(`span`,{className:`hidden sm:inline`,children:`Spawn from here`})]}),(0,R.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,title:`Show git status colors`,children:[(0,R.jsx)($e,{className:`h-3.5 w-3.5`}),(0,R.jsx)(`span`,{className:`hidden sm:inline`,children:`Git`}),(0,R.jsx)(Mc,{checked:te,onCheckedChange:oe})]})]}),le.length>0&&(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 text-xs text-muted-foreground ${a?`hidden md:flex`:``}`,children:le.map((e,t)=>(0,R.jsxs)(`button`,{type:`button`,className:`rounded px-1.5 py-0.5 font-mono hover:bg-accent hover:text-foreground`,onClick:()=>s({filePath:e.path,fileSelectedPath:``,fileSelectedLine:0}),children:[e.label,t<le.length-1&&e.label!==`/`?` /`:``]},`${e.path}-${t}`))}),ue&&(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:ue}),(0,R.jsxs)(`div`,{className:`grid min-h-0 flex-1 overflow-hidden md:rounded-md md:border md:border-border md:grid-cols-[22rem_minmax(0,1fr)] ${a?``:`rounded-md border border-border`}`,children:[(0,R.jsxs)(`div`,{className:`min-h-0 overflow-auto border-b border-border bg-card md:border-b-0 md:border-r ${a?`hidden md:block`:``}`,children:[d?.parent&&(0,R.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-accent`,onClick:()=>s({filePath:d.parent,fileSelectedPath:``,fileSelectedLine:0}),children:[(0,R.jsx)(T,{className:`h-4 w-4 text-muted-foreground`}),(0,R.jsx)(`span`,{children:`Parent directory`})]}),d?.entries.map(e=>{let t=a===e.path||i===e.path,n=e.type===`directory`?ae:b,r=pl(e.gitStatus);return(0,R.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-accent ${t?`bg-accent`:``}`,onClick:()=>ce(e),children:[(0,R.jsx)(n,{className:`h-4 w-4 shrink-0 ${e.type===`directory`?`text-blue-400`:`text-muted-foreground`}`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs ${r?.text??``}`,children:e.name}),e.symlink&&(0,R.jsx)(Pe,{className:`h-3 w-3 shrink-0 text-muted-foreground/60`}),(0,R.jsx)(hl,{status:e.gitStatus}),e.type!==`directory`&&(0,R.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:gl(e.size)})]},e.path)}),!h&&d&&d.entries.length===0&&(0,R.jsx)(`div`,{className:`px-3 py-8 text-center text-sm text-muted-foreground`,children:`No files`})]}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden ${a?``:`hidden md:flex`}`,children:[(0,R.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 border-b border-border px-3 py-2 text-xs text-muted-foreground hover:text-foreground md:hidden`,onClick:()=>s({fileSelectedPath:``,fileSelectedLine:0}),children:[(0,R.jsx)(T,{className:`h-3.5 w-3.5`}),`Back to files`]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,R.jsx)(Ol,{orchestratorId:re?.id||``,selectedPath:a,line:o,onReadError:ee})})]})]})]})}function Al(){return(0,R.jsx)(kl,{})}function jl(){return k(e=>e.fileOverlayOpen)?(0,R.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/80 backdrop-blur-sm`,children:(0,R.jsx)(`div`,{className:`absolute inset-4 overflow-hidden rounded-md border border-border bg-background p-4 shadow-xl`,children:(0,R.jsx)(kl,{overlay:!0})})}):null}function Ml(e,t){let n=L.useRef(!1),r=L.useRef(t);r.current=t,L.useEffect(()=>{if(!e||!r.current)return;window.history.pushState({sheetGuard:!0},``),n.current=!0;function t(){n.current&&(n.current=!1,r.current?.(!1))}return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t),n.current&&(n.current=!1,window.history.back())}},[e])}function Nl({...e}){return Ml(e.open,e.onOpenChange),(0,R.jsx)(mr,{"data-slot":`sheet`,...e})}function Pl({...e}){return(0,R.jsx)(hr,{"data-slot":`sheet-portal`,...e})}function Fl({className:e,...t}){return(0,R.jsx)(gr,{"data-slot":`sheet-overlay`,className:S(`fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function Il({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,R.jsxs)(Pl,{children:[(0,R.jsx)(Fl,{}),(0,R.jsxs)(_r,{"data-slot":`sheet-content`,"data-side":n,className:S(`fixed z-50 flex flex-col bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out overflow-hidden max-w-[100dvw] data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-full data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-full data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10`,e),...i,children:[t,r&&(0,R.jsx)(br,{"data-slot":`sheet-close`,asChild:!0,children:(0,R.jsxs)(P,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`,children:[(0,R.jsx)(Ee,{}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function Ll({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`sheet-header`,className:S(`flex flex-col gap-0.5 p-4`,e),...t})}function Rl({className:e,...t}){return(0,R.jsx)(vr,{"data-slot":`sheet-title`,className:S(`font-heading text-base font-medium text-foreground`,e),...t})}function zl({className:e,orientation:t=`horizontal`,...n}){return(0,R.jsx)(As,{"data-slot":`tabs`,"data-orientation":t,className:S(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var Bl=$t(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function W({className:e,variant:t=`default`,...n}){return(0,R.jsx)(js,{"data-slot":`tabs-list`,"data-variant":t,className:S(Bl({variant:t}),e),...n})}function G({className:e,...t}){return(0,R.jsx)(Ms,{"data-slot":`tabs-trigger`,className:S(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function K({className:e,...t}){return(0,R.jsx)(Ns,{"data-slot":`tabs-content`,className:S(`flex-1 text-sm outline-none`,e),...t})}function q({agent:e,now:t,className:n}){return(0,R.jsx)(`span`,{className:S(`inline-block w-2.5 h-2.5 rounded-full shrink-0`,mt(e,t),n)})}var J={codex:`text-blue-400 bg-blue-500/10 border-blue-500/25`,claude:`text-yellow-400 bg-yellow-500/10 border-yellow-500/25`,user:`text-emerald-400 bg-emerald-500/10 border-emerald-500/25`,system:`text-purple-400 bg-purple-500/10 border-purple-500/25`,channel:`text-blue-400 bg-blue-500/10 border-blue-500/25`,agent:`text-zinc-400 bg-zinc-500/10 border-zinc-500/25`},Vl={codex:Ce,claude:fe,user:Je,system:ie,channel:m,agent:tt};function Hl({agent:e,className:t}){let n=It(e),r=Vl[n]||tt;return(0,R.jsx)(`span`,{className:S(`inline-flex items-center justify-center w-5 h-5 rounded-md border text-sm`,J[n]||J.agent,t),children:(0,R.jsx)(r,{className:`w-3.5 h-3.5`})})}function Ul({agent:e,compact:t=!1}){let n=$l(e);return n.length===0?null:(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:n.slice(0,t?4:void 0).map(e=>(0,R.jsx)(N,{variant:`outline`,className:`text-[9px] px-1 py-0 h-4`,children:e},e))})}function Wl({agent:e,compact:t=!1,className:n=``}){let r=Kl(e);return(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 ${n}`,children:r.map(e=>{let n=e.Icon;return(0,R.jsxs)(`span`,{title:e.title,className:`inline-flex h-5 min-w-5 items-center justify-center gap-1 rounded-md border px-1.5 text-[10px] leading-none ${e.className}`,children:[(0,R.jsx)(n,{className:`h-3 w-3 shrink-0`}),!t&&(0,R.jsx)(`span`,{children:e.label})]},e.key)})})}function Gl({agent:e}){let t=e.context;if(!t)return null;let n=nu(t);if(n===null)return(0,R.jsxs)(`div`,{className:`space-y-1`,title:ru(t),children:[(0,R.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:`collecting`}),(0,R.jsx)(`span`,{children:`--`})]}),(0,R.jsx)(`div`,{className:`h-1.5 rounded-full bg-muted overflow-hidden`,children:(0,R.jsx)(`div`,{className:`h-full w-0 bg-muted-foreground/30`})})]});let r=Math.round(n*100),i=r>=80?`bg-red-500`:r>=60?`bg-yellow-500`:`bg-emerald-500`;return(0,R.jsxs)(`div`,{className:`space-y-1`,title:ru(t),children:[(0,R.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:t.lifecycleState}),(0,R.jsxs)(`span`,{children:[r,`%`]})]}),(0,R.jsx)(`div`,{className:`h-1.5 rounded-full bg-muted overflow-hidden`,children:(0,R.jsx)(`div`,{className:`h-full ${i}`,style:{width:`${Math.max(0,Math.min(100,r))}%`}})})]})}function Kl(e){let t=ql(e),n=Jl(e),r=Yl(e);return[{key:`origin`,label:t?`Relay`:`External`,title:t?`Agent Relay spawned this agent`:`Externally started agent registered with Agent Relay`,Icon:t?ke:Te,className:t?`border-sky-500/30 bg-sky-500/10 text-sky-300`:`border-zinc-500/30 bg-zinc-500/10 text-zinc-300`},n,r]}function ql(e){return typeof e.meta?.spawnRequestId==`string`||typeof e.meta?.policyName==`string`||typeof e.meta?.automationRunId==`string`}function Jl(e){let t=String(e.providerCapabilities?.session?.approvalMode||e.meta?.approvalMode||`guarded`).toLowerCase();return t===`open`?{key:`approval`,label:`Open`,title:`Approval mode: open`,Icon:he,className:`border-emerald-500/30 bg-emerald-500/10 text-emerald-300`}:t===`read-only`?{key:`approval`,label:`Read-only`,title:`Approval mode: read-only`,Icon:v,className:`border-blue-500/30 bg-blue-500/10 text-blue-300`}:{key:`approval`,label:`Guarded`,title:`Approval mode: guarded`,Icon:Oe,className:`border-amber-500/30 bg-amber-500/10 text-amber-300`}}function Yl(e){let t=Xl(e.meta?.workspace),n=wt(t.requestedMode)||wt(e.meta?.workspaceMode),r=wt(t.mode),a=n&&n!==`inherit`?n:r&&n!==`inherit`?r:`default`;return a===`isolated`?{key:`workspace`,label:`Isolated`,title:`Workspace: isolated worktree`,Icon:$e,iconColor:`text-violet-300`,className:`border-violet-500/30 bg-violet-500/10 text-violet-300`}:a===`shared`?{key:`workspace`,label:`Shared`,title:`Workspace: shared repo checkout`,Icon:i,iconColor:`text-cyan-300`,className:`border-cyan-500/30 bg-cyan-500/10 text-cyan-300`}:{key:`workspace`,label:`Default`,title:r?`Workspace: default/inherit, resolved to ${r}`:`Workspace: default/inherit`,Icon:He,iconColor:`text-zinc-400`,className:`border-zinc-500/30 bg-zinc-500/10 text-zinc-300`}}function Xl(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Zl(e){let t=Xl(e.meta?.workspace),n=wt(t.repoRoot)||wt(t.sourceCwd)||wt(e.meta?.cwd);return n?bt(n,2):``}function Ql(e){return!!(e.context||e.providerCapabilities?.context)}function $l(e){let t=e.providerCapabilities,n=e.context,r=[];t?.lifecycle.managed?r.push(`managed`):t&&r.push(`bridge`),t?.session?.approvalMode===`read-only`?r.push(`read-only`):t?.session?.fileWrite&&r.push(`write`),t?.session?.shell&&r.push(`shell`),(t?.model?.alias||t?.model?.id)&&r.push(String(t.model.alias||t.model.id));let i=Vt(e).length;if(i&&r.push(i===1?`1 subagent`:`${i} subagents`),n){let e=nu(n);r.push(e===null?`ctx collecting`:`${Math.round(e*100)}% ctx`)}return r}function eu({context:e,expected:t=!!e,size:n=26,className:r}){let i=nu(e);if(i===null&&!t)return null;let a=n>=24?3:2.5,o=n/2,s=o-a,c=2*Math.PI*s,l=i===null?c:c*(1-i),u=i===null,d=u?`text-muted-foreground`:i>.8?`text-red-400`:i>.5?`text-yellow-400`:`text-emerald-400`,f=u?null:Math.round(i*100);return(0,R.jsxs)(`div`,{className:`relative shrink-0 ${u?`opacity-70`:``} ${r??``}`,style:{width:n,height:n},title:ru(e),children:[(0,R.jsxs)(`svg`,{width:n,height:n,viewBox:`0 0 ${n} ${n}`,className:`rotate-[-90deg]`,children:[(0,R.jsx)(`circle`,{cx:o,cy:o,r:s,fill:`none`,strokeWidth:a,className:`stroke-muted-foreground/20`}),(0,R.jsx)(`circle`,{cx:o,cy:o,r:s,fill:`none`,strokeWidth:a,strokeDasharray:c,strokeDashoffset:l,strokeLinecap:`round`,className:`${d} stroke-current transition-all duration-500`})]}),(0,R.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center font-semibold leading-none ${u?`text-muted-foreground`:d}`,style:{fontSize:n>=24?8:7},children:u?`?`:f})]})}function tu(e){let t=e.context;return!t?.tokensUsed&&!t?.tokensMax?null:t.tokensUsed&&t.tokensMax?`${iu(t.tokensUsed)} / ${iu(t.tokensMax)}`:t.tokensUsed?iu(t.tokensUsed):t.tokensMax?iu(t.tokensMax):null}function nu(e){return!e||typeof e.utilization!=`number`||!Number.isFinite(e.utilization)?null:Math.min(1,Math.max(0,e.utilization))}function ru(e){if(!e)return`Context: collecting; provider has not reported usage yet`;let t=nu(e),n=`${e.source}/${e.confidence}`,r=Number.isFinite(e.lastUpdatedAt)?new Date(e.lastUpdatedAt).toLocaleString():`unknown`;return t===null?`Context: unknown; ${n}; updated ${r}`:`Context: ${Math.round(t*100)}%; ${n}; updated ${r}`}function iu(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}var au=(0,L.lazy)(()=>I(()=>import(`./terminal-viewer-impl-BhqS2XpS.js`).then(e=>({default:e.TerminalDialog})),__vite__mapDeps([7,1,6,8,9,10,11,12,13]),import.meta.url));function ou(e){return e.open?(0,R.jsx)(L.Suspense,{fallback:null,children:(0,R.jsx)(au,{...e})}):null}function su({orchestratorId:e,session:t,lines:n=200}){let r=k(e=>e.apiCall),[i,o]=(0,L.useState)([]),[s,c]=(0,L.useState)(``),[l,u]=(0,L.useState)(!1),[f,p]=(0,L.useState)(`provider`),[m,h]=(0,L.useState)(null);async function g(){if(!l)try{o((await r(`GET`,`/orchestrators/${encodeURIComponent(e)}/logs/${encodeURIComponent(t)}?lines=${n}${f===`mirror`?`&stream=mirror`:``}`)).lines||[]),h(null)}catch(e){h(Ct(e))}}(0,L.useEffect)(()=>{g();let e=setInterval(()=>void g(),1500);return()=>clearInterval(e)},[e,t,l,f]);let _=s?i.filter(e=>e.toLowerCase().includes(s.toLowerCase())):i;return(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(`div`,{className:`relative min-w-48 flex-1`,children:[(0,R.jsx)(a,{className:`absolute left-2 top-2.5 h-4 w-4 text-muted-foreground`}),(0,R.jsx)(F,{className:`pl-8`,value:s,onChange:e=>c(e.target.value),placeholder:`Search logs`})]}),(0,R.jsxs)(`div`,{className:`flex rounded-md border border-border overflow-hidden`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>p(`provider`),title:`Provider output`,className:S(`flex items-center gap-1 px-2 py-1.5 text-xs`,f===`provider`?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/50`),children:[(0,R.jsx)(Ce,{className:`h-3.5 w-3.5`}),` Output`]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>p(`mirror`),title:`Session-mirror diagnostics (clean)`,className:S(`flex items-center gap-1 px-2 py-1.5 text-xs border-l border-border`,f===`mirror`?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/50`),children:[(0,R.jsx)(we,{className:`h-3.5 w-3.5`}),` Mirror`]})]}),(0,R.jsx)(P,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>u(e=>!e),title:l?`Resume logs`:`Pause logs`,children:l?(0,R.jsx)(nt,{className:`h-4 w-4`}):(0,R.jsx)(d,{className:`h-4 w-4`})}),(0,R.jsx)(P,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>Lt(`${t}.log`,i.join(`
14
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return L.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},fr=`DialogDescriptionWarning`,pr=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ur(fr).contentName}}.`;return L.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},mr=zn,hr=Gn,gr=qn,_r=Zn,vr=nr,yr=ir,br=or,xr=`rovingFocusGroup.onEntryFocus`,Sr={bubbles:!1,cancelable:!0},Cr=`RovingFocusGroup`,[wr,Tr,Er]=an(Cr),[Dr,Or]=tn(Cr,[Er]),[kr,Ar]=Dr(Cr),jr=L.forwardRef((e,t)=>(0,R.jsx)(wr.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,R.jsx)(wr.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,R.jsx)(Mr,{...e,ref:t})})}));jr.displayName=Cr;var Mr=L.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=L.useRef(null),p=Zt(t,f),m=hn(a),[h,g]=on({prop:o,defaultProp:s??null,onChange:c,caller:Cr}),[_,v]=L.useState(!1),y=gn(l),b=Tr(n),x=L.useRef(!1),[S,ee]=L.useState(0);return L.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(xr,y),()=>e.removeEventListener(xr,y)},[y]),(0,R.jsx)(kr,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:L.useCallback(e=>g(e),[g]),onItemShiftTab:L.useCallback(()=>v(!0),[]),onFocusableItemAdd:L.useCallback(()=>ee(e=>e+1),[]),onFocusableItemRemove:L.useCallback(()=>ee(e=>e-1),[]),children:(0,R.jsx)(j.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:M(e.onMouseDown,()=>{x.current=!0}),onFocus:M(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(xr,Sr);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);Rr([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:M(e.onBlur,()=>v(!1))})})}),Nr=`RovingFocusGroupItem`,Pr=L.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=pn(),l=a||c,u=Ar(Nr,n),d=u.currentTabStopId===l,f=Tr(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return L.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,R.jsx)(wr.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,R.jsx)(j.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:M(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:M(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:M(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=Lr(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?zr(n,r+1):n.slice(r+1)}setTimeout(()=>Rr(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});Pr.displayName=Nr;var Fr={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Ir(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function Lr(e,t,n){let r=Ir(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return Fr[r]}function Rr(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function zr(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Br=jr,Vr=Pr,Hr=[`Enter`,` `],Ur=[`ArrowDown`,`PageUp`,`Home`],Wr=[`ArrowUp`,`PageDown`,`End`],Gr=[...Ur,...Wr],Kr={ltr:[...Hr,`ArrowRight`],rtl:[...Hr,`ArrowLeft`]},qr={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},Jr=`Menu`,[Yr,Xr,Zr]=an(Jr),[Qr,$r]=tn(Jr,[Zr,yn,Or]),ei=yn(),ti=Or(),[ni,ri]=Qr(Jr),[ii,ai]=Qr(Jr),oi=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=ei(t),[c,l]=L.useState(null),u=L.useRef(!1),d=gn(a),f=hn(i);return L.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,R.jsx)(bn,{...s,children:(0,R.jsx)(ni,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,R.jsx)(ii,{scope:t,onClose:L.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};oi.displayName=Jr;var si=`MenuAnchor`,ci=L.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=ei(n);return(0,R.jsx)(Cn,{...i,...r,ref:t})});ci.displayName=si;var li=`MenuPortal`,[ui,di]=Qr(li,{forceMount:void 0}),fi=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=ri(li,t);return(0,R.jsx)(ui,{scope:t,forceMount:n,children:(0,R.jsx)(sn,{present:n||a.open,children:(0,R.jsx)(ln,{asChild:!0,container:i,children:r})})})};fi.displayName=li;var pi=`MenuContent`,[mi,hi]=Qr(pi),gi=L.forwardRef((e,t)=>{let n=di(pi,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=ri(pi,e.__scopeMenu),o=ai(pi,e.__scopeMenu);return(0,R.jsx)(Yr.Provider,{scope:e.__scopeMenu,children:(0,R.jsx)(sn,{present:r||a.open,children:(0,R.jsx)(Yr.Slot,{scope:e.__scopeMenu,children:o.modal?(0,R.jsx)(_i,{...i,ref:t}):(0,R.jsx)(vi,{...i,ref:t})})})})}),_i=L.forwardRef((e,t)=>{let n=ri(pi,e.__scopeMenu),r=L.useRef(null),i=Zt(t,r);return L.useEffect(()=>{let e=r.current;if(e)return mn(e)},[]),(0,R.jsx)(bi,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:M(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),vi=L.forwardRef((e,t)=>{let n=ri(pi,e.__scopeMenu);return(0,R.jsx)(bi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),yi=Qt(`MenuContent.ScrollLock`),bi=L.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=ri(pi,n),_=ai(pi,n),v=ei(n),y=ti(n),b=Xr(n),[x,S]=L.useState(null),ee=L.useRef(null),te=Zt(t,ee,g.onContentChange),C=L.useRef(0),ne=L.useRef(``),re=L.useRef(0),ie=L.useRef(null),ae=L.useRef(`right`),oe=L.useRef(0),se=m?un:L.Fragment,ce=m?{as:yi,allowPinchZoom:!0}:void 0,w=e=>{let t=ne.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=na(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){ne.current=t,window.clearTimeout(C.current),t!==``&&(C.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};L.useEffect(()=>()=>window.clearTimeout(C.current),[]),fn();let T=L.useCallback(e=>ae.current===ie.current?.side&&ia(e,ie.current?.area),[]);return(0,R.jsx)(mi,{scope:n,searchRef:ne,onItemEnter:L.useCallback(e=>{T(e)&&e.preventDefault()},[T]),onItemLeave:L.useCallback(e=>{T(e)||(ee.current?.focus(),S(null))},[T]),onTriggerLeave:L.useCallback(e=>{T(e)&&e.preventDefault()},[T]),pointerGraceTimerRef:re,onPointerGraceIntentChange:L.useCallback(e=>{ie.current=e},[]),children:(0,R.jsx)(se,{...ce,children:(0,R.jsx)(cn,{asChild:!0,trapped:i,onMountAutoFocus:M(a,e=>{e.preventDefault(),ee.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,R.jsx)(dn,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,R.jsx)(Br,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:M(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,R.jsx)(Sn,{role:`menu`,"aria-orientation":`vertical`,"data-state":Zi(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:te,style:{outline:`none`,...h.style},onKeyDown:M(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&w(e.key));let i=ee.current;if(e.target!==i||!Gr.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);Wr.includes(e.key)&&a.reverse(),ea(a)}),onBlur:M(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(C.current),ne.current=``)}),onPointerMove:M(e.onPointerMove,aa(e=>{let t=e.target,n=oe.current!==e.clientX;e.currentTarget.contains(t)&&n&&(ae.current=e.clientX>oe.current?`right`:`left`,oe.current=e.clientX)}))})})})})})})});gi.displayName=pi;var xi=`MenuGroup`,Si=L.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,R.jsx)(j.div,{role:`group`,...r,ref:t})});Si.displayName=xi;var Ci=`MenuLabel`,wi=L.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,R.jsx)(j.div,{...r,ref:t})});wi.displayName=Ci;var Ti=`MenuItem`,Ei=`menu.itemSelect`,Di=L.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=L.useRef(null),o=ai(Ti,e.__scopeMenu),s=hi(Ti,e.__scopeMenu),c=Zt(t,a),l=L.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(Ei,{bubbles:!0,cancelable:!0});e.addEventListener(Ei,e=>r?.(e),{once:!0}),en(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,R.jsx)(Oi,{...i,ref:c,disabled:n,onClick:M(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:M(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:M(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||Hr.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});Di.displayName=Ti;var Oi=L.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=hi(Ti,n),s=ti(n),c=L.useRef(null),l=Zt(t,c),[u,d]=L.useState(!1),[f,p]=L.useState(``);return L.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,R.jsx)(Yr.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,R.jsx)(Vr,{asChild:!0,...s,focusable:!r,children:(0,R.jsx)(j.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:M(e.onPointerMove,aa(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:M(e.onPointerLeave,aa(e=>o.onItemLeave(e))),onFocus:M(e.onFocus,()=>d(!0)),onBlur:M(e.onBlur,()=>d(!1))})})})}),ki=`MenuCheckboxItem`,Ai=L.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,R.jsx)(Ii,{scope:e.__scopeMenu,checked:n,children:(0,R.jsx)(Di,{role:`menuitemcheckbox`,"aria-checked":Qi(n)?`mixed`:n,...i,ref:t,"data-state":$i(n),onSelect:M(i.onSelect,()=>r?.(Qi(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Ai.displayName=ki;var ji=`MenuRadioGroup`,[Mi,Ni]=Qr(ji,{value:void 0,onValueChange:()=>{}}),z=L.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=gn(r);return(0,R.jsx)(Mi,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,R.jsx)(Si,{...i,ref:t})})});z.displayName=ji;var B=`MenuRadioItem`,Pi=L.forwardRef((e,t)=>{let{value:n,...r}=e,i=Ni(B,e.__scopeMenu),a=n===i.value;return(0,R.jsx)(Ii,{scope:e.__scopeMenu,checked:a,children:(0,R.jsx)(Di,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":$i(a),onSelect:M(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});Pi.displayName=B;var Fi=`MenuItemIndicator`,[Ii,Li]=Qr(Fi,{checked:!1}),Ri=L.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=Li(Fi,n);return(0,R.jsx)(sn,{present:r||Qi(a.checked)||a.checked===!0,children:(0,R.jsx)(j.span,{...i,ref:t,"data-state":$i(a.checked)})})});Ri.displayName=Fi;var zi=`MenuSeparator`,Bi=L.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,R.jsx)(j.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});Bi.displayName=zi;var Vi=`MenuArrow`,Hi=L.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=ei(n);return(0,R.jsx)(xn,{...i,...r,ref:t})});Hi.displayName=Vi;var Ui=`MenuSub`,[Wi,Gi]=Qr(Ui),Ki=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=ri(Ui,t),o=ei(t),[s,c]=L.useState(null),[l,u]=L.useState(null),d=gn(i);return L.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,R.jsx)(bn,{...o,children:(0,R.jsx)(ni,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,R.jsx)(Wi,{scope:t,contentId:pn(),triggerId:pn(),trigger:s,onTriggerChange:c,children:n})})})};Ki.displayName=Ui;var qi=`MenuSubTrigger`,Ji=L.forwardRef((e,t)=>{let n=ri(qi,e.__scopeMenu),r=ai(qi,e.__scopeMenu),i=Gi(qi,e.__scopeMenu),a=hi(qi,e.__scopeMenu),o=L.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=L.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return L.useEffect(()=>u,[u]),L.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,R.jsx)(ci,{asChild:!0,...l,children:(0,R.jsx)(Oi,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Zi(n.open),...e,ref:Yt(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:M(e.onPointerMove,aa(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:M(e.onPointerLeave,aa(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:M(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||Kr[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});Ji.displayName=qi;var Yi=`MenuSubContent`,Xi=L.forwardRef((e,t)=>{let n=di(pi,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=ri(pi,e.__scopeMenu),o=ai(pi,e.__scopeMenu),s=Gi(Yi,e.__scopeMenu),c=L.useRef(null),l=Zt(t,c);return(0,R.jsx)(Yr.Provider,{scope:e.__scopeMenu,children:(0,R.jsx)(sn,{present:r||a.open,children:(0,R.jsx)(Yr.Slot,{scope:e.__scopeMenu,children:(0,R.jsx)(bi,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:l,align:`start`,side:o.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:M(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:M(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:M(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=qr[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});Xi.displayName=Yi;function Zi(e){return e?`open`:`closed`}function Qi(e){return e===`indeterminate`}function $i(e){return Qi(e)?`indeterminate`:e?`checked`:`unchecked`}function ea(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function ta(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function na(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=ta(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function ra(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function ia(e,t){return t?ra({x:e.clientX,y:e.clientY},t):!1}function aa(e){return t=>t.pointerType===`mouse`?e(t):void 0}var oa=oi,sa=ci,ca=fi,la=gi,ua=Si,da=wi,fa=Di,pa=Ai,ma=z,ha=Pi,ga=Ri,_a=Bi,va=Hi,ya=Ji,ba=Xi,xa=`DropdownMenu`,[Sa,Ca]=tn(xa,[$r]),wa=$r(),[Ta,Ea]=Sa(xa),Da=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=wa(t),l=L.useRef(null),[u,d]=on({prop:i,defaultProp:a??!1,onChange:o,caller:xa});return(0,R.jsx)(Ta,{scope:t,triggerId:pn(),triggerRef:l,contentId:pn(),open:u,onOpenChange:d,onOpenToggle:L.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,R.jsx)(oa,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};Da.displayName=xa;var Oa=`DropdownMenuTrigger`,ka=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Ea(Oa,n),o=wa(n);return(0,R.jsx)(sa,{asChild:!0,...o,children:(0,R.jsx)(j.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:Yt(t,a.triggerRef),onPointerDown:M(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:M(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});ka.displayName=Oa;var Aa=`DropdownMenuPortal`,ja=e=>{let{__scopeDropdownMenu:t,...n}=e,r=wa(t);return(0,R.jsx)(ca,{...r,...n})};ja.displayName=Aa;var Ma=`DropdownMenuContent`,Na=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ea(Ma,n),a=wa(n),o=L.useRef(!1);return(0,R.jsx)(la,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:M(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:M(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Na.displayName=Ma;var Pa=`DropdownMenuGroup`,Fa=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(ua,{...i,...r,ref:t})});Fa.displayName=Pa;var Ia=`DropdownMenuLabel`,La=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(da,{...i,...r,ref:t})});La.displayName=Ia;var Ra=`DropdownMenuItem`,za=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(fa,{...i,...r,ref:t})});za.displayName=Ra;var Ba=`DropdownMenuCheckboxItem`,Va=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(pa,{...i,...r,ref:t})});Va.displayName=Ba;var Ha=`DropdownMenuRadioGroup`,Ua=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(ma,{...i,...r,ref:t})});Ua.displayName=Ha;var Wa=`DropdownMenuRadioItem`,Ga=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(ha,{...i,...r,ref:t})});Ga.displayName=Wa;var Ka=`DropdownMenuItemIndicator`,qa=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(ga,{...i,...r,ref:t})});qa.displayName=Ka;var Ja=`DropdownMenuSeparator`,Ya=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(_a,{...i,...r,ref:t})});Ya.displayName=Ja;var Xa=`DropdownMenuArrow`,Za=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(va,{...i,...r,ref:t})});Za.displayName=Xa;var Qa=`DropdownMenuSubTrigger`,$a=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(ya,{...i,...r,ref:t})});$a.displayName=Qa;var eo=`DropdownMenuSubContent`,to=L.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wa(n);return(0,R.jsx)(ba,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});to.displayName=eo;var no=Da,ro=ka,io=ja,ao=Na,oo=La,so=za,co=Ya,lo=`Label`,uo=L.forwardRef((e,t)=>(0,R.jsx)(j.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));uo.displayName=lo;var fo=uo;function V(e,t){return L.useReducer((e,n)=>t[e][n]??e,e)}var H=`ScrollArea`,[po,mo]=tn(H),[ho,go]=po(H),_o=L.forwardRef((e,t)=>{let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=L.useState(null),[l,u]=L.useState(null),[d,f]=L.useState(null),[p,m]=L.useState(null),[h,g]=L.useState(null),[_,v]=L.useState(0),[y,b]=L.useState(0),[x,S]=L.useState(!1),[ee,te]=L.useState(!1),C=Zt(t,e=>c(e)),ne=hn(i);return(0,R.jsx)(ho,{scope:n,type:r,dir:ne,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:u,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:x,onScrollbarXEnabledChange:S,scrollbarY:h,onScrollbarYChange:g,scrollbarYEnabled:ee,onScrollbarYEnabledChange:te,onCornerWidthChange:v,onCornerHeightChange:b,children:(0,R.jsx)(j.div,{dir:ne,...o,ref:C,style:{position:`relative`,"--radix-scroll-area-corner-width":_+`px`,"--radix-scroll-area-corner-height":y+`px`,...e.style}})})});_o.displayName=H;var vo=`ScrollAreaViewport`,yo=L.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=go(vo,n),s=Zt(t,L.useRef(null),o.onViewportChange);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:i}),(0,R.jsx)(j.div,{"data-radix-scroll-area-viewport":``,...a,ref:s,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,R.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})});yo.displayName=vo;var bo=`ScrollAreaScrollbar`,xo=L.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=go(bo,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return L.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,R.jsx)(So,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,R.jsx)(Co,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,R.jsx)(wo,{...r,ref:t,forceMount:n}):i.type===`always`?(0,R.jsx)(To,{...r,ref:t}):null});xo.displayName=bo;var So=L.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=go(bo,e.__scopeScrollArea),[a,o]=L.useState(!1);return L.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=()=>{window.clearTimeout(t),o(!0)},r=()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)};return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,R.jsx)(sn,{present:n||a,children:(0,R.jsx)(wo,{"data-state":a?`visible`:`hidden`,...r,ref:t})})}),Co=L.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=go(bo,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=Go(()=>c(`SCROLL_END`),100),[s,c]=V(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return L.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),L.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r};return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,R.jsx)(sn,{present:n||s!==`hidden`,children:(0,R.jsx)(To,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:M(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:M(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})}),wo=L.forwardRef((e,t)=>{let n=go(bo,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=L.useState(!1),s=e.orientation===`horizontal`,c=Go(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return Ko(n.viewport,c),Ko(n.content,c),(0,R.jsx)(sn,{present:r||a,children:(0,R.jsx)(To,{"data-state":a?`visible`:`hidden`,...i,ref:t})})}),To=L.forwardRef((e,t)=>{let{orientation:n=`vertical`,...r}=e,i=go(bo,e.__scopeScrollArea),a=L.useRef(null),o=L.useRef(0),[s,c]=L.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=Ro(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:e=>a.current=e,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:e=>o.current=e};function d(e,t){return Bo(e,o.current,s,t)}return n===`horizontal`?(0,R.jsx)(Eo,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=Vo(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,R.jsx)(Do,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=Vo(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null}),Eo=L.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=go(bo,e.__scopeScrollArea),[o,s]=L.useState(),c=L.useRef(null),l=Zt(t,c,a.onScrollbarXChange);return L.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,R.jsx)(Ao,{"data-orientation":`horizontal`,...i,ref:l,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":zo(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),Uo(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Lo(o.paddingLeft),paddingEnd:Lo(o.paddingRight)}})}})}),Do=L.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=go(bo,e.__scopeScrollArea),[o,s]=L.useState(),c=L.useRef(null),l=Zt(t,c,a.onScrollbarYChange);return L.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,R.jsx)(Ao,{"data-orientation":`vertical`,...i,ref:l,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":zo(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),Uo(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Lo(o.paddingTop),paddingEnd:Lo(o.paddingBottom)}})}})}),[Oo,ko]=po(bo),Ao=L.forwardRef((e,t)=>{let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:s,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:u,onResize:d,...f}=e,p=go(bo,n),[m,h]=L.useState(null),g=Zt(t,e=>h(e)),_=L.useRef(null),v=L.useRef(``),y=p.viewport,b=r.content-r.viewport,x=gn(u),S=gn(c),ee=Go(d,10);function te(e){_.current&&l({x:e.clientX-_.current.left,y:e.clientY-_.current.top})}return L.useEffect(()=>{let e=e=>{let t=e.target;m?.contains(t)&&x(e,b)};return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[y,m,b,x]),L.useEffect(S,[r,S]),Ko(m,ee),Ko(p.content,ee),(0,R.jsx)(Oo,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:gn(a),onThumbPointerUp:gn(o),onThumbPositionChange:S,onThumbPointerDown:gn(s),children:(0,R.jsx)(j.div,{...f,ref:g,style:{position:`absolute`,...f.style},onPointerDown:M(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),_.current=m.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,p.viewport&&(p.viewport.style.scrollBehavior=`auto`),te(e))}),onPointerMove:M(e.onPointerMove,te),onPointerUp:M(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=v.current,p.viewport&&(p.viewport.style.scrollBehavior=``),_.current=null})})})}),jo=`ScrollAreaThumb`,Mo=L.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=ko(jo,e.__scopeScrollArea);return(0,R.jsx)(sn,{present:n||i.hasThumb,children:(0,R.jsx)(No,{ref:t,...r})})}),No=L.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:r,...i}=e,a=go(jo,n),o=ko(jo,n),{onThumbPositionChange:s}=o,c=Zt(t,e=>o.onThumbChange(e)),l=L.useRef(void 0),u=Go(()=>{l.current&&=(l.current(),void 0)},100);return L.useEffect(()=>{let e=a.viewport;if(e){let t=()=>{u(),l.current||(l.current=Wo(e,s),s())};return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,R.jsx)(j.div,{"data-state":o.hasThumb?`visible`:`hidden`,...i,ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:M(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:M(e.onPointerUp,o.onThumbPointerUp)})});Mo.displayName=jo;var Po=`ScrollAreaCorner`,Fo=L.forwardRef((e,t)=>{let n=go(Po,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,R.jsx)(Io,{...e,ref:t}):null});Fo.displayName=Po;var Io=L.forwardRef((e,t)=>{let{__scopeScrollArea:n,...r}=e,i=go(Po,n),[a,o]=L.useState(0),[s,c]=L.useState(0),l=!!(a&&s);return Ko(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),Ko(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),l?(0,R.jsx)(j.div,{...r,ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null});function Lo(e){return e?parseInt(e,10):0}function Ro(e,t){let n=e/t;return isNaN(n)?0:n}function zo(e){let t=Ro(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Bo(e,t,n,r=`ltr`){let i=zo(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return Ho([c,l],d)(e)}function Vo(e,t,n=`ltr`){let r=zo(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=wn(e,n===`ltr`?[0,o]:[o*-1,0]);return Ho([0,o],[0,s])(c)}function Ho(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Uo(e,t){return e>0&&e<t}var Wo=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return(function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)})(),()=>window.cancelAnimationFrame(r)};function Go(e,t){let n=gn(e),r=L.useRef(0);return L.useEffect(()=>()=>window.clearTimeout(r.current),[]),L.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Ko(e,t){let n=gn(t);rn(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}var qo=_o,Jo=yo,Yo=Fo,Xo=`Separator`,Zo=`horizontal`,Qo=[`horizontal`,`vertical`],$o=L.forwardRef((e,t)=>{let{decorative:n,orientation:r=Zo,...i}=e,a=es(r)?r:Zo,o=n?{role:`none`}:{"aria-orientation":a===`vertical`?a:void 0,role:`separator`};return(0,R.jsx)(j.div,{"data-orientation":a,...o,...i,ref:t})});$o.displayName=Xo;function es(e){return Qo.includes(e)}var ts=$o,ns=`Switch`,[rs,is]=tn(ns),[as,os]=rs(ns),ss=L.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,p]=L.useState(null),m=Zt(t,e=>p(e)),h=L.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=on({prop:i,defaultProp:a??!1,onChange:l,caller:ns});return(0,R.jsxs)(as,{scope:n,checked:_,disabled:s,children:[(0,R.jsx)(j.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":fs(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:M(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,R.jsx)(ds,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});ss.displayName=ns;var cs=`SwitchThumb`,ls=L.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=os(cs,n);return(0,R.jsx)(j.span,{"data-state":fs(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});ls.displayName=cs;var us=`SwitchBubbleInput`,ds=L.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=L.useRef(null),s=Zt(o,a),c=_n(n),l=vn(t);return L.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,R.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});ds.displayName=us;function fs(e){return e?`checked`:`unchecked`}var ps=ss,ms=ls,hs=`Tabs`,[gs,_s]=tn(hs,[Or]),vs=Or(),[ys,bs]=gs(hs),xs=L.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=hn(s),[d,f]=on({prop:r,onChange:i,defaultProp:a??``,caller:hs});return(0,R.jsx)(ys,{scope:n,baseId:pn(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,R.jsx)(j.div,{dir:u,"data-orientation":o,...l,ref:t})})});xs.displayName=hs;var Ss=`TabsList`,Cs=L.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=bs(Ss,n),o=vs(n);return(0,R.jsx)(Br,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,R.jsx)(j.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});Cs.displayName=Ss;var ws=`TabsTrigger`,Ts=L.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=bs(ws,n),s=vs(n),c=Os(o.baseId,r),l=ks(o.baseId,r),u=r===o.value;return(0,R.jsx)(Vr,{asChild:!0,...s,focusable:!i,active:u,children:(0,R.jsx)(j.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:M(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:M(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:M(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});Ts.displayName=ws;var Es=`TabsContent`,Ds=L.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=bs(Es,n),c=Os(s.baseId,r),l=ks(s.baseId,r),u=r===s.value,d=L.useRef(u);return L.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,R.jsx)(sn,{present:i||u,children:({present:n})=>(0,R.jsx)(j.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})});Ds.displayName=Es;function Os(e,t){return`${e}-trigger-${t}`}function ks(e,t){return`${e}-content-${t}`}var As=xs,js=Cs,Ms=Ts,Ns=Ds,[Ps,Fs]=tn(`Tooltip`,[yn]),Is=yn(),Ls=`TooltipProvider`,Rs=700,zs=`tooltip.open`,[Bs,Vs]=Ps(Ls),Hs=e=>{let{__scopeTooltip:t,delayDuration:n=Rs,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=L.useRef(!0),s=L.useRef(!1),c=L.useRef(0);return L.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,R.jsx)(Bs,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:L.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:L.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:L.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};Hs.displayName=Ls;var Us=`Tooltip`,[Ws,Gs]=Ps(Us),Ks=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=Vs(Us,e.__scopeTooltip),l=Is(t),[u,d]=L.useState(null),f=pn(),p=L.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=L.useRef(!1),[_,v]=on({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(zs))):c.onClose(),a?.(e)},caller:Us}),y=L.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=L.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=L.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=L.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return L.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,R.jsx)(bn,{...l,children:(0,R.jsx)(Ws,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:L.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:L.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};Ks.displayName=Us;var qs=`TooltipTrigger`,Js=L.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Gs(qs,n),a=Vs(qs,n),o=Is(n),s=Zt(t,L.useRef(null),i.onTriggerChange),c=L.useRef(!1),l=L.useRef(!1),u=L.useCallback(()=>c.current=!1,[]);return L.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,R.jsx)(Cn,{asChild:!0,...o,children:(0,R.jsx)(j.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:M(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:M(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:M(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:M(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:M(e.onBlur,i.onClose),onClick:M(e.onClick,i.onClose)})})});Js.displayName=qs;var Ys=`TooltipPortal`,[Xs,Zs]=Ps(Ys,{forceMount:void 0}),Qs=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=Gs(Ys,t);return(0,R.jsx)(Xs,{scope:t,forceMount:n,children:(0,R.jsx)(sn,{present:n||a.open,children:(0,R.jsx)(ln,{asChild:!0,container:i,children:r})})})};Qs.displayName=Ys;var $s=`TooltipContent`,ec=L.forwardRef((e,t)=>{let n=Zs($s,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=Gs($s,e.__scopeTooltip);return(0,R.jsx)(sn,{present:r||o.open,children:o.disableHoverableContent?(0,R.jsx)(ac,{side:i,...a,ref:t}):(0,R.jsx)(tc,{side:i,...a,ref:t})})}),tc=L.forwardRef((e,t)=>{let n=Gs($s,e.__scopeTooltip),r=Vs($s,e.__scopeTooltip),i=L.useRef(null),a=Zt(t,i),[o,s]=L.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=L.useCallback(()=>{s(null),d(!1)},[d]),p=L.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=lc(r,cc(r,n.getBoundingClientRect())),a=uc(t.getBoundingClientRect());s(fc([...i,...a])),d(!0)},[d]);return L.useEffect(()=>()=>f(),[f]),L.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),L.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!dc(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,R.jsx)(ac,{...e,ref:a})}),[nc,rc]=Ps(Us,{isInside:!1}),ic=Xt(`TooltipContent`),ac=L.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=Gs($s,n),l=Is(n),{onClose:u}=c;return L.useEffect(()=>(document.addEventListener(zs,u),()=>document.removeEventListener(zs,u)),[u]),L.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,R.jsx)(dn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,R.jsxs)(Sn,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,R.jsx)(ic,{children:r}),(0,R.jsx)(nc,{scope:n,isInside:!0,children:(0,R.jsx)(Nn,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});ec.displayName=$s;var oc=`TooltipArrow`,sc=L.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Is(n);return rc(oc,n).isInside?null:(0,R.jsx)(xn,{...i,...r,ref:t})});sc.displayName=oc;function cc(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function lc(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function uc(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function dc(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function fc(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),pc(t)}function pc(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var mc=Hs,hc=kn();function gc({delayDuration:e=0,...t}){return(0,R.jsx)(mc,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function U(e){return k(e)}function _c(){let e=U(e=>e.pairs);return(0,L.useMemo)(()=>{let t={};for(let n of e)(n.status===`active`||n.status===`pending`)&&(n.requesterId&&(t[n.requesterId]=n),n.targetId&&(t[n.targetId]=n));return t},[e])}function vc(e){let t=U(e=>e.messages),n=U(e=>e.tasks),r=U(e=>e.pairs),i=U(e=>e.inboxReadCursors),a=U(e=>e.inboxArchivedThreads);return(0,L.useMemo)(()=>{if(!e)return{unread:0,needsHumanResponse:!1,pendingPairInvite:!1,claimableTasks:0,total:0,score:0};let o=t.filter(t=>Tt(t)===e.id&&!Wt(t)),s=Number(a[e.id]||0),c=s>=o.filter(e=>ut(e)&&Dt(e)).reduce((e,t)=>Math.max(e,t.id),0)&&s>0?0:o.filter(t=>ft(i,e.id,t)).length,l=zt(e),u=r.find(t=>(t.status===`active`||t.status===`pending`)&&(t.requesterId===e.id||t.targetId===e.id))?.status===`pending`,d=n.filter(t=>_t(t)&&Ht(t.target,e)).length+t.filter(t=>Gt(t)&&Ht(t.to,e)).length;return{unread:c,needsHumanResponse:l,pendingPairInvite:u,claimableTasks:d,total:c+ +!!l+ +!!u+d,score:c*10+(l?8:0)+(u?4:0)+d*2}},[e,t,n,r,i,a])}function yc(){let e=U(e=>e.agents),t=U(e=>e.showBuiltIns),n=U(e=>e.showOffline),r=U(e=>e.agentSort),i=U(e=>e.agentSortDir),a=U(e=>e.agentPresetFilter),o=U(e=>e.agentStatusFilter),s=U(e=>e.agentTagFilter),c=U(e=>e.agentHostFilter),l=U(e=>e.managedPolicies),u=U(e=>e.pairs);return(0,L.useMemo)(()=>{let d=Rt(e,t,l);if(a){let e=bc(u);d=xc(d,a,at.getState().now,e)}n||(d=d.filter(e=>e.status!==`offline`)),o===`starting`?d=d.filter(e=>e.status!==`offline`&&!e.ready):o&&(d=d.filter(e=>e.status===o)),s&&(d=d.filter(e=>(e.tags||[]).includes(s))),c&&(d=d.filter(e=>(e.machine||``)===c));let f=i===`desc`?-1:1;return[...d].sort((e,t)=>r===`name`?A(e).localeCompare(A(t))*f:r===`lastSeen`?(new Date(t.lastSeen).getTime()-new Date(e.lastSeen).getTime())*f||A(e).localeCompare(A(t)):r===`created`?(new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime())*f||A(e).localeCompare(A(t)):((Ut[e.status]??9)-(Ut[t.status]??9))*f||A(e).localeCompare(A(t)))},[e,t,n,l,r,i,a,o,s,c,u,ct()])}function bc(e){let t={};for(let n of e)(n.status===`active`||n.status===`pending`)&&(n.requesterId&&(t[n.requesterId]=n),n.targetId&&(t[n.targetId]=n));return t}function xc(e,t,n,r){switch(t){case`active`:return e.filter(e=>e.status!==`offline`);case`offline_stale`:return e.filter(e=>e.status===`offline`||Kt(n,e));case`claude`:case`codex`:return e.filter(e=>It(e)===t);case`paired`:return e.filter(e=>!!r[e.id]);case`unpaired`:return e.filter(e=>!r[e.id]);default:return e}}function Sc(){let e=U(e=>e.messages),t=U(e=>e.inboxReadCursors),n=U(e=>e.inboxArchivedThreads),r=U(e=>e.inboxDrafts),i=U(e=>e.agentsById);return(0,L.useMemo)(()=>{let a=new Map;for(let t of e){if(Wt(t))continue;let e=Tt(t);e&&(a.has(e)||a.set(e,{id:e,peer:e,messages:[],lastMessage:null,previewMessage:null,attention:{unread:0,needsHumanResponse:!1,score:0},archived:!1,draft:``}),a.get(e).messages.push(t))}for(let e of a.values()){e.messages.sort((e,t)=>e.id-t.id),e.lastMessage=e.messages[e.messages.length-1]||null;let a=null;for(let t=e.messages.length-1;t>=0;t--){let n=e.messages[t];if(n&&!vt(n)){a=n;break}}e.previewMessage=a||e.lastMessage;let o=e.messages.filter(n=>ft(t,e.peer,n)).length,s=zt(i[e.peer]);e.attention={unread:o,needsHumanResponse:s,score:o*10+(s?8:0)};let c=Number(n[e.peer]||0);e.archived=!!(e.lastMessage?.id&&c>=e.lastMessage.id),e.draft=r[e.peer]||``}return[...a.values()].sort((e,t)=>{let n=(t.attention.score||0)-(e.attention.score||0);return n===0?(t.lastMessage?.id||0)-(e.lastMessage?.id||0):n})},[e,t,n,r,i])}function Cc(){let e=Sc(),t=U(e=>e.agents),n=U(e=>e.showBuiltIns),r=U(e=>e.showOffline),i=U(e=>e.managedPolicies),a=U(e=>e.pairs),o=U(e=>e.tasks),s=U(e=>e.messages),c=(0,L.useMemo)(()=>new Set(Rt(t,n,i).filter(e=>r||e.status!==`offline`).map(e=>e.id)),[t,n,r,i]);return(0,L.useMemo)(()=>{let l=e.filter(e=>!e.archived&&c.has(e.peer)).reduce((e,t)=>e+(t.attention.unread||0),0),u=Rt(t,n,i).filter(e=>(r||e.status!==`offline`)&&zt(e)).length,d=a.filter(e=>e.status===`pending`).length,f=o.filter(_t).length+s.filter(Gt).length;return{unreadInbox:l,needsHumanResponse:u,pendingPairInvites:d,claimableTasks:f,total:l+u+d+f}},[e,c,t,n,r,i,a,o,s])}function wc(){let e=U(e=>e.agents),t=U(e=>e.showBuiltIns),n=U(e=>e.managedPolicies);return(0,L.useMemo)(()=>Rt(e,t,n).filter(e=>e.status!==`offline`).length,[e,t,n])}function Tc(){let e=U(e=>e.agents);return(0,L.useMemo)(()=>e.filter(e=>e.status===`busy`).length,[e])}function Ec(){let e=U(e=>e.agents),t=U(e=>e.showBuiltIns),n=U(e=>e.showOffline),r=U(e=>e.managedPolicies);return(0,L.useMemo)(()=>{let i=Rt(e,t,r);return n?i:i.filter(e=>e.status!==`offline`)},[e,t,n,r])}function Dc(){let e=U(e=>e.agents),t=U(e=>e.showBuiltIns),n=U(e=>e.managedPolicies);return(0,L.useMemo)(()=>[...new Set(Rt(e,t,n).map(e=>e.machine).filter(Boolean))].sort(),[e,t,n])}function Oc(){let e=U(e=>e.agents),t=U(e=>e.showBuiltIns),n=U(e=>e.managedPolicies);return(0,L.useMemo)(()=>[...new Set(Rt(e,t,n).flatMap(e=>e.tags||[]))],[e,t,n])}function kc(){let e=U(e=>e.tasks),t=U(e=>e.messages);return(0,L.useMemo)(()=>{let n=e.filter(e=>!lt.has(e.status)).map(e=>({id:`task-`+e.id,sourceType:`task`,title:e.title,body:e.body,severity:e.severity||`info`,status:e.status,owner:e.claimedBy||``,target:e.target,source:e.source,channel:e.channel||``,updatedAt:e.updatedAt||e.createdAt,createdAt:e.createdAt,claimable:_t(e),task:e})),r=t.filter(Gt).map(e=>({id:`message-`+e.id,sourceType:`message`,title:e.subject||`Claimable message #`+e.id,body:dt(e),severity:`warning`,status:e.claimedBy?`claimed`:`open`,owner:e.claimedBy||``,target:e.to,source:`message`,channel:e.channel||``,updatedAt:e.claimedAt||e.createdAt,createdAt:e.createdAt,claimable:Gt(e),message:e}));return[...n,...r].sort((e,t)=>{let n=Number(t.claimable)-Number(e.claimable);if(n!==0)return n;let r={critical:0,warning:1,info:2},i=(r[e.severity]??9)-(r[t.severity]??9);return i===0?xt(e.updatedAt)-xt(t.updatedAt):i})},[e,t])}function Ac(){let e=U(e=>e.commandQuery),t=U(e=>e.agents),n=U(e=>e.agentsById),r=U(e=>e.showBuiltIns),i=U(e=>e.showOffline),a=U(e=>e.managedPolicies);return(0,L.useMemo)(()=>{let n=Rt(t,r,a).filter(e=>i||e.status!==`offline`),o=[...new Set(n.flatMap(e=>e.tags||[]))],s=se(),c=[jc(`open-chat`,`Open chat`,`Human console`,`MessageCircle`,`openView`,{view:`chat`}),jc(`open-work`,`Open work queue`,`Claimable messages and tasks`,`ListChecks`,`openView`,{view:`work`}),jc(`open-workspaces`,`Open workspaces`,`Agent worktrees and merge state`,`GitBranch`,`openView`,{view:`workspaces`}),jc(`show-stale`,`Show stale agents`,`Filter agents to offline or stale`,`Filter`,`agentPreset`,{preset:`offline_stale`}),jc(`copy-url`,`Copy relay URL`,s,`Copy`,`copy`,{value:s}),jc(`export-md`,`Export timeline as Markdown`,`Activity audit trace`,`FileDown`,`exportActivity`,{format:`markdown`}),jc(`export-json`,`Export timeline as JSON`,`Activity audit trace`,`Braces`,`exportActivity`,{format:`json`}),...n.slice(0,12).map(e=>jc(`msg-`+e.id,`Message agent: `+A(e),e.id,`Send`,`messageAgent`,{agentId:e.id})),...n.filter(e=>It(e)===`codex`).slice(0,8).map(e=>jc(`pair-`+e.id,`Pair Codex: `+A(e),e.id,`Link`,`pairAgent`,{agentId:e.id})),...o.map(e=>jc(`tag-`+e,`Filter tag: `+e,`#`+e,`Tag`,`filterTag`,{tag:e}))],l=e.trim().toLowerCase();return(l?c.filter(e=>e.search.includes(l)):c).slice(0,24)},[e,t,n,r,i,a])}function jc(e,t,n,r,i,a){return{id:e,title:t,subtitle:n,icon:r,action:i,payload:a,search:`${t}\n${n}\n${i}`.toLowerCase()}}function Mc({className:e,size:t=`default`,...n}){return(0,R.jsx)(ps,{"data-slot":`switch`,"data-size":t,className:S(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,R.jsx)(ms,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`})})}function Nc({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,R.jsx)(ts,{"data-slot":`separator`,decorative:n,orientation:t,className:S(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...r})}function Pc({...e}){return(0,R.jsx)(no,{"data-slot":`dropdown-menu`,...e})}function Fc({...e}){return(0,R.jsx)(ro,{"data-slot":`dropdown-menu-trigger`,...e})}function Ic({className:e,align:t=`start`,sideOffset:n=4,...r}){return(0,R.jsx)(io,{children:(0,R.jsx)(ao,{"data-slot":`dropdown-menu-content`,sideOffset:n,align:t,className:S(`z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}function Lc({className:e,inset:t,variant:n=`default`,...r}){return(0,R.jsx)(so,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:S(`group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function Rc({className:e,inset:t,...n}){return(0,R.jsx)(oo,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:S(`px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7`,e),...n})}function zc({className:e,...t}){return(0,R.jsx)(co,{"data-slot":`dropdown-menu-separator`,className:S(`-mx-1 my-1 h-px bg-border`,e),...t})}var Bc={LayoutDashboard:Se,MessageCircle:ue,Bot:tt,Server:ie,MessagesSquare:m,Plug:f,PlugZap:ne,Activity:y,Link:ve,Mail:be,ListChecks:Ge,ClipboardList:de,CalendarClock:Ie,AreaChart:xe,Settings:Qe,Workflow:Re,BrainCircuit:pe,FolderTree:c,Shield:re,Wrench:me,UserCog:D,Lightbulb:ye,Users:Me};function Vc(e){return new Date(e.createdAt).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}var Hc=[[`messages`,`Messages`],[`replies`,`Replies`],[`errors`,`Errors`]];function Uc(){let e=k(e=>e.notifications),t=k(e=>e.notificationUnread),n=k(e=>e.notificationSettings),r=k(e=>e.notificationPermission),i=k(e=>e.set),a=k(e=>e.openNotification),o=k(e=>e.markNotificationsRead),s=k(e=>e.clearNotifications),c=k(e=>e.requestBrowserNotifications),l=t>0?et:ge;function u(e){i({notificationSettings:{...n,...e}})}return(0,R.jsxs)(Pc,{onOpenChange:e=>{e&&o()},children:[(0,R.jsx)(Fc,{asChild:!0,children:(0,R.jsxs)(`button`,{className:`relative flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors w-full`,children:[(0,R.jsx)(l,{className:`w-3.5 h-3.5`}),(0,R.jsx)(`span`,{children:`Notifications`}),t>0&&(0,R.jsx)(N,{variant:`destructive`,className:`ml-auto text-[10px] px-1.5 py-0`,children:t})]})}),(0,R.jsxs)(Ic,{align:`start`,side:`right`,className:`w-80 p-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1.5 py-1`,children:[(0,R.jsx)(Rc,{className:`p-0`,children:`Notifications`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`button`,{type:`button`,title:`Mark read`,onClick:o,className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,children:(0,R.jsx)(Ye,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(`button`,{type:`button`,title:`Clear`,onClick:s,className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,children:(0,R.jsx)(Fe,{className:`h-3.5 w-3.5`})})]})]}),(0,R.jsxs)(`div`,{className:`px-1.5 py-1.5 space-y-2`,children:[(0,R.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`In-app notifications`}),(0,R.jsx)(Mc,{size:`sm`,checked:n.enabled,onCheckedChange:e=>u({enabled:e})})]}),(0,R.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Browser notifications`}),(0,R.jsx)(Mc,{size:`sm`,checked:n.browserEnabled&&r===`granted`,disabled:r===`unsupported`,onCheckedChange:e=>{e&&r!==`granted`?c():u({browserEnabled:e})}})]}),(0,R.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,children:Hc.map(([e,t])=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>u({[e]:!n[e]}),className:S(`rounded border px-2 py-1 text-[11px] transition-colors`,n[e]?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-accent`),children:t},e))})]}),(0,R.jsx)(zc,{}),(0,R.jsx)(`div`,{className:`max-h-80 overflow-y-auto`,children:e.length===0?(0,R.jsx)(`div`,{className:`px-1.5 py-8 text-center text-xs text-muted-foreground`,children:`No notifications`}):e.slice(0,20).map(e=>(0,R.jsxs)(Lc,{onSelect:t=>{t.preventDefault(),a(e)},className:`flex flex-col items-start gap-0.5 px-2 py-2`,children:[(0,R.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[(0,R.jsx)(`span`,{className:S(`h-1.5 w-1.5 rounded-full`,e.severity===`error`?`bg-red-400`:e.severity===`warning`?`bg-yellow-400`:`bg-blue-400`)}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium`,children:e.title}),(0,R.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Vc(e)})]}),(0,R.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:e.body})]},e.id))})]})]})}function Wc(){let e=k(e=>e.theme),t=k(e=>e.set);return(0,R.jsxs)(Pc,{children:[(0,R.jsx)(Fc,{asChild:!0,children:(0,R.jsxs)(`button`,{className:`flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors w-full`,children:[(0,R.jsx)(w,{className:`w-3.5 h-3.5`}),(0,R.jsx)(`span`,{children:`Theme`}),(0,R.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:Jt.find(t=>t.id===e)?.label})]})}),(0,R.jsx)(Ic,{align:`start`,side:`right`,className:`w-40`,children:Jt.map(n=>(0,R.jsxs)(Lc,{onSelect:()=>t({theme:n.id}),children:[(0,R.jsx)(`span`,{className:`flex-1`,children:n.label}),e===n.id&&(0,R.jsx)(Ne,{className:`w-3.5 h-3.5 text-primary`})]},n.id))})]})}function Gc(){let e=k(e=>e.view),t=k(e=>e.switchView),n=k(e=>e.connected),r=k(e=>e.showOffline),i=k(e=>e.showBuiltIns),a=k(e=>e.autoRefresh),o=k(e=>e.stats),s=k(e=>e.openCommandPalette),c=k(e=>e.set),l=k(e=>e.startAutoRefresh),u=k(e=>e.stopAutoRefresh),d=Cc(),f=wc();function p(e){return e===`overview`&&d.total>0?(0,R.jsx)(N,{variant:`destructive`,className:`ml-auto text-[10px] px-1.5 py-0`,children:d.total}):e===`chat`&&d.unreadInbox>0?(0,R.jsx)(N,{variant:`destructive`,className:`ml-auto text-[10px] px-1.5 py-0`,children:d.unreadInbox}):e===`agents`?(0,R.jsx)(N,{variant:`secondary`,className:`ml-auto text-[10px] px-1.5 py-0`,children:f}):e===`pairs`&&d.pendingPairInvites>0?(0,R.jsx)(N,{className:`ml-auto text-[10px] px-1.5 py-0 bg-yellow-500/20 text-yellow-400`,children:d.pendingPairInvites}):e===`work`&&d.claimableTasks>0?(0,R.jsx)(N,{className:`ml-auto text-[10px] px-1.5 py-0 bg-yellow-500/20 text-yellow-400`,children:d.claimableTasks}):null}return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`nav`,{className:`flex-1 overflow-y-auto py-2 px-2`,children:Bt.map(n=>{let r=Bc[n.icon]||tt;return(0,R.jsxs)(`button`,{onClick:()=>t(n.key),className:S(`w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm transition-colors my-0.5`,e===n.key?`bg-primary text-primary-foreground`:`text-foreground hover:bg-accent`),children:[(0,R.jsx)(r,{className:`w-4 h-4 shrink-0`}),n.label,p(n.key)]},n.key)})}),(0,R.jsxs)(`div`,{className:`mt-auto border-t border-border p-4 space-y-3 text-xs`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:S(`w-2 h-2 rounded-full`,n?`bg-emerald-500`:`bg-red-500 animate-pulse`)}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:n?`Live`:`Reconnecting...`})]}),(0,R.jsxs)(`button`,{onClick:s,className:`flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors w-full`,children:[(0,R.jsx)(O,{className:`w-3.5 h-3.5`}),(0,R.jsx)(`span`,{children:`Command palette`}),(0,R.jsx)(`kbd`,{className:`ml-auto text-[10px] bg-muted px-1.5 py-0.5 rounded`,children:`⌘K`})]}),(0,R.jsx)(Uc,{}),(0,R.jsx)(Wc,{}),(0,R.jsx)(Nc,{}),(0,R.jsxs)(`label`,{className:`flex items-center justify-between cursor-pointer`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Show offline`}),(0,R.jsx)(Mc,{checked:r,onCheckedChange:e=>c({showOffline:e})})]}),(0,R.jsxs)(`label`,{className:`flex items-center justify-between cursor-pointer`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`System agents`}),(0,R.jsx)(Mc,{checked:i,onCheckedChange:e=>c({showBuiltIns:e})})]}),(0,R.jsxs)(`label`,{className:`flex items-center justify-between cursor-pointer`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Auto refresh`}),(0,R.jsx)(Mc,{checked:a,onCheckedChange:e=>{c({autoRefresh:e}),e?l():u()}})]}),o.version&&(0,R.jsxs)(`div`,{className:`text-muted-foreground pt-1`,children:[`v`,o.version]})]})]})}function Kc(){return(0,R.jsxs)(`aside`,{className:`hidden xl:flex w-[250px] min-w-[250px] h-[calc(100dvh-var(--sat))] sticky top-[var(--sat)] flex-col border-r border-border bg-card`,children:[(0,R.jsxs)(`div`,{className:`px-5 py-4 font-bold text-base border-b border-border flex items-center gap-2`,children:[(0,R.jsx)(C,{className:`w-4 h-4 text-primary`}),`Agent Relay`]}),(0,R.jsx)(Gc,{})]})}function qc(){let e=k(e=>e.mobileMenuOpen),t=k(e=>e.set);return(0,L.useEffect)(()=>{if(!e)return;function n(e){e.key===`Escape`&&t({mobileMenuOpen:!1})}return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e]),(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:S(`xl:hidden fixed inset-0 z-40 bg-black/50 transition-opacity duration-200`,e?`opacity-100`:`opacity-0 pointer-events-none`),onClick:()=>t({mobileMenuOpen:!1})}),(0,R.jsxs)(`aside`,{inert:!e,className:S(`xl:hidden fixed inset-y-0 left-0 z-50 w-[280px] flex flex-col pt-[var(--sat)] bg-card border-r border-border transition-transform duration-200 ease-out`,e?`translate-x-0`:`-translate-x-full`),children:[(0,R.jsxs)(`div`,{className:`px-5 py-4 font-bold text-base border-b border-border flex items-center gap-2`,children:[(0,R.jsx)(C,{className:`w-4 h-4 text-primary`}),`Agent Relay`,(0,R.jsx)(`button`,{onClick:()=>t({mobileMenuOpen:!1}),className:`ml-auto p-1 text-muted-foreground hover:text-foreground transition-colors`,"aria-label":`Close menu`,children:(0,R.jsx)(Ee,{className:`w-4 h-4`})})]}),(0,R.jsx)(Gc,{})]})]})}var Jc=500*1024,Yc={bash:`bash`,c:`c`,conf:`properties`,cpp:`cpp`,cs:`csharp`,css:`css`,csv:`csv`,cts:`typescript`,diff:`diff`,dockerfile:`dockerfile`,env:`dotenv`,gemspec:`ruby`,go:`go`,graphql:`graphql`,h:`c`,hcl:`hcl`,hpp:`cpp`,html:`html`,ini:`ini`,java:`java`,js:`javascript`,json:`json`,jsonc:`jsonc`,jsx:`jsx`,kt:`kotlin`,less:`less`,log:`log`,lua:`lua`,mjs:`javascript`,mts:`typescript`,patch:`diff`,php:`php`,plist:`xml`,podspec:`ruby`,properties:`properties`,py:`python`,rake:`ruby`,rb:`ruby`,rs:`rust`,scss:`scss`,sh:`bash`,sql:`sql`,svelte:`svelte`,swift:`swift`,toml:`toml`,ts:`typescript`,tsx:`tsx`,txt:`text`,vue:`vue`,webmanifest:`json`,xml:`xml`,yaml:`yaml`,yml:`yaml`,zsh:`bash`},Xc={".bashrc":`bash`,".env":`dotenv`,".eslintrc":`json`,".gitignore":`gitignore`,".npmrc":`properties`,".prettierrc":`json`,".swiftformat":`properties`,".swiftlint.yml":`yaml`,".watchmanconfig":`json`,"app.config":`json`,"app.webmanifest":`json`,berksfile:`ruby`,brewfile:`ruby`,"bun.lock":`json`,capfile:`ruby`,cartfile:`ruby`,"composer.lock":`json`,dangerfile:`ruby`,"deno.lock":`json`,fastfile:`ruby`,"flake.lock":`json`,gemfile:`ruby`,guardfile:`ruby`,podfile:`ruby`,rakefile:`ruby`,dockerfile:`dockerfile`,makefile:`make`},Zc=null;function Qc(){return Zc??=I(()=>import(`./bundle-web-CXNb85wK.js`),__vite__mapDeps([0,1,2,3]),import.meta.url),Zc}function $c(e){return new TextEncoder().encode(e).length}function el(e){return e.split(`/`).filter(Boolean).pop()||e}function tl(e){let t=e?.slice(0,240).split(/\r?\n/,1)[0]?.toLowerCase()||``;return t.startsWith(`#!`)?/\b(bash|dash|ksh|sh|zsh)\b/.test(t)?`bash`:/\bfish\b/.test(t)?`fish`:/\b(ts-node|tsx)\b/.test(t)?`typescript`:/\b(node|bun|deno)\b/.test(t)?`javascript`:/\bpython[0-9.]*\b/.test(t)?`python`:/\bruby\b/.test(t)?`ruby`:/\bswift\b/.test(t)?`swift`:/\bperl\b/.test(t)?`perl`:/\bphp\b/.test(t)?`php`:null:null}function nl(e,t,n,r){if(n)return n;let i=el(e).toLowerCase();if(Xc[i])return Xc[i];if(i.endsWith(`.d.ts`))return`typescript`;let a=tl(r);if(a)return a;let o=i.includes(`.`)?i.slice(i.lastIndexOf(`.`)+1):``;return o&&Yc[o]?Yc[o]:t?.includes(`json`)?`json`:t?.includes(`javascript`)?`javascript`:t?.includes(`typescript`)?`typescript`:t?.includes(`xml`)?`xml`:t?.includes(`yaml`)||t?.includes(`yml`)?`yaml`:t?.includes(`shellscript`)?`bash`:null}function rl(e,t,n,r){let i=nl(e,t,n,r);return!!(i&&i!==`text`&&i!==`log`)}var il=(0,L.memo)(function({content:e,path:t,mediaType:n,languageHint:r,compact:i=!1}){let a=k(e=>e.theme),o=Jt.find(e=>e.id===a)?.dark??!0,s=(0,L.useMemo)(()=>nl(t,n,r,e)||`text`,[e,r,n,t]),c=$c(e)>Jc,[l,u]=(0,L.useState)(``),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)(!1);function h(){return(0,R.jsx)(Tn,{value:e,label:`Copy code`,copiedLabel:`Copied code`,size:`icon`,variant:`ghost`,className:`absolute right-2 top-2 h-7 w-7 bg-background/80 opacity-0 shadow-sm backdrop-blur transition-opacity hover:bg-muted group-hover/code:opacity-100 focus-visible:opacity-100`})}return(0,L.useEffect)(()=>{if(c||s===`text`||s===`log`){u(``),f(!1),m(!1);return}let t=!1;return f(!0),m(!1),Qc().then(({codeToHtml:t})=>t(e,{lang:s,theme:o?`github-dark-default`:`github-light-default`})).then(e=>{t||u(e)}).catch(()=>{t||(u(``),m(!0))}).finally(()=>{t||f(!1)}),()=>{t=!0}},[e,o,s,c]),d?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-sm text-muted-foreground`,children:[(0,R.jsx)(Be,{className:`h-4 w-4 animate-spin`}),`Highlighting`]}):c||p||!l?(0,R.jsxs)(`div`,{className:`group/code relative`,children:[h(),(0,R.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap break-words font-mono text-xs leading-5 ${i?`p-3`:`p-4`}`,children:e||` `})]}):(0,R.jsxs)(`div`,{className:`group/code relative`,children:[h(),(0,R.jsx)(`div`,{className:`code-preview overflow-auto font-mono text-xs leading-5 ${i?`p-3`:`p-4`}`,dangerouslySetInnerHTML:{__html:l}})]})}),al=(0,L.lazy)(()=>I(()=>import(`./markdown-preview-impl-BnwjZsmO.js`).then(e=>({default:e.MarkdownPreview})),__vite__mapDeps([4,5,1,3,6]),import.meta.url));function ol(e){return(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading preview…`}),children:(0,R.jsx)(al,{...e})})}var sl=e(it(),1);function cl({src:e,alt:t,onClose:n}){let[r,i]=(0,L.useState)(!1);return(0,L.useEffect)(()=>{let e=document.body.style.overflow;document.body.style.overflow=`hidden`;function t(e){e.key===`Escape`&&n()}return document.addEventListener(`keydown`,t),()=>{document.body.style.overflow=e,document.removeEventListener(`keydown`,t)}},[n]),(0,R.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex flex-col bg-black/95`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 p-2`,children:[(0,R.jsx)(`button`,{type:`button`,className:`rounded-full bg-white/10 p-2 text-white/70 hover:bg-white/20 hover:text-white`,onClick:()=>i(!r),title:r?`Fit to screen`:`Actual size`,children:r?(0,R.jsx)(Le,{className:`h-4 w-4`}):(0,R.jsx)(We,{className:`h-4 w-4`})}),(0,R.jsx)(`button`,{type:`button`,className:`rounded-full bg-white/10 p-2 text-white/70 hover:bg-white/20 hover:text-white`,onClick:n,title:`Close`,children:(0,R.jsx)(Ee,{className:`h-4 w-4`})})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 ${r?`overflow-auto`:`flex items-center justify-center overflow-hidden p-4`}`,onClick:r?void 0:n,children:(0,R.jsx)(`img`,{src:e,alt:t,className:r?`max-w-none`:`max-h-full max-w-full cursor-zoom-in object-contain`,onClick:e=>{e.stopPropagation(),i(!r)}})})]})}function ll({src:e,alt:t=``,className:n,style:r}){let[i,a]=(0,L.useState)(!1);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`img`,{src:e,alt:t,className:`${n||``} cursor-zoom-in`,style:r,onClick:()=>a(!0)}),i&&(0,sl.createPortal)((0,R.jsx)(cl,{src:e,alt:t,onClose:()=>a(!1)}),document.body)]})}var ul=`agent-relay:file-git-status`;function dl(){try{return window.localStorage.getItem(ul)!==`off`}catch{return!0}}function fl(e){try{window.localStorage.setItem(ul,e?`on`:`off`)}catch{}}function pl(e){switch(e){case`staged`:return{dot:`bg-green-500`,text:`text-green-400`,label:`Staged`};case`unstaged`:return{dot:`bg-amber-500`,text:`text-amber-400`,label:`Modified (unstaged)`};case`staged-unstaged`:return{dot:`bg-amber-500`,text:`text-green-400`,label:`Staged + unstaged changes`};case`untracked`:return{dot:`bg-sky-500`,text:`text-sky-400`,label:`Untracked`};default:return null}}function ml(e,t,n){let r=`/orchestrators/${encodeURIComponent(e)}/files/list?path=${encodeURIComponent(t)}`;return n?`${r}&git=1`:r}function hl({status:e}){let t=pl(e);return t?(0,R.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${t.dot}`,title:t.label}):null}function gl(e){return e===void 0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function _l(e,t){let n=t.replace(/\/+$/,``);return e===n?`/`:e.startsWith(n+`/`)?e.slice(n.length+1):e}function vl(e,t){let n=e.toLowerCase();return n.endsWith(`.md`)||n.endsWith(`.mdx`)||n.endsWith(`.markdown`)||t===`text/markdown`}function yl(e,t,n){return vl(e,t)?`markdown`:rl(e,t,void 0,n)?`code`:null}function bl(e){return`agent-relay:file-view-mode:${e}`}function xl(e){try{let t=window.localStorage.getItem(bl(e));return t===`raw`||t===`rendered`?t:`rendered`}catch{return`rendered`}}function Sl(e,t){try{window.localStorage.setItem(bl(e),t)}catch{}}function Cl(e,t){let n=_l(e,t);if(n===`/`)return[{label:`/`,path:t}];let r=n.split(`/`).filter(Boolean),i=[{label:`/`,path:t}];for(let e=0;e<r.length;e++)i.push({label:r[e],path:`${t.replace(/\/+$/,``)}/${r.slice(0,e+1).join(`/`)}`});return i}function wl(e,t){let n=k(e=>e.apiCall),[r,i]=(0,L.useState)(null),[a,o]=(0,L.useState)(!1),[s,c]=(0,L.useState)(``);return(0,L.useEffect)(()=>{if(!e||!t){i(null),c(``);return}let r=!1;return o(!0),c(``),n(`GET`,`/orchestrators/${encodeURIComponent(e)}/files/read?path=${encodeURIComponent(t)}`).then(e=>{r||i(e)}).catch(e=>{r||(i(null),c(Ct(e)))}).finally(()=>{r||o(!1)}),()=>{r=!0}},[n,e,t]),{file:r,loading:a,error:s}}function Tl(e,t,n=!1){let r=k(e=>e.apiCall),[i,a]=(0,L.useState)(null),[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(``);return(0,L.useEffect)(()=>{if(!e||!t){a(null),l(``);return}let i=!1;return s(!0),l(``),r(`GET`,ml(e,t,n)).then(e=>{i||a(e)}).catch(e=>{i||(a(null),l(Ct(e)))}).finally(()=>{i||s(!1)}),()=>{i=!0}},[r,e,t,n]),{listing:i,loading:o,error:c}}function El({content:e,line:t,lineRef:n}){return(0,R.jsx)(`div`,{className:`w-full py-2 font-mono text-xs leading-5`,children:e.split(`
15
+ `).map((e,r)=>{let i=r+1,a=i===t;return(0,R.jsxs)(`div`,{ref:a?n:void 0,className:`grid grid-cols-[2.5rem_minmax(0,1fr)] px-1 sm:grid-cols-[4rem_minmax(0,1fr)] sm:px-2 ${a?`bg-primary/15`:``}`,children:[(0,R.jsx)(`div`,{className:`select-none pr-2 text-right text-muted-foreground sm:pr-3`,children:i}),(0,R.jsx)(`pre`,{className:`overflow-hidden whitespace-pre-wrap break-words`,children:e||` `})]},i)})})}function Dl({orchestratorId:e,selectedPath:t,onReadError:n,git:r=!1}){let{listing:i,loading:a,error:o}=Tl(e,t,r);return(0,L.useEffect)(()=>{n(o)},[o,n]),t?a?(0,R.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(Be,{className:`h-4 w-4 animate-spin`}),`Loading directory`]}):o?(0,R.jsx)(`div`,{className:`h-full bg-muted/20`}):i?(0,R.jsxs)(`div`,{className:`h-full overflow-auto bg-muted/20`,children:[(0,R.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-background px-3 py-2 text-xs`,children:[(0,R.jsx)(ae,{className:`h-3.5 w-3.5 text-blue-400`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:i.path}),(0,R.jsxs)(N,{variant:`outline`,className:`text-[10px]`,children:[i.entries.length,` items`]})]}),(0,R.jsxs)(`div`,{className:`divide-y divide-border/60`,children:[i.entries.map(e=>{let t=e.type===`directory`?ae:b,n=pl(e.gitStatus);return(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[(0,R.jsx)(t,{className:`h-4 w-4 shrink-0 ${e.type===`directory`?`text-blue-400`:`text-muted-foreground`}`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs ${n?.text??``}`,children:e.name}),e.symlink&&(0,R.jsx)(Pe,{className:`h-3 w-3 shrink-0 text-muted-foreground/60`}),(0,R.jsx)(hl,{status:e.gitStatus}),e.type!==`directory`&&(0,R.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:gl(e.size)})]},e.path)}),i.entries.length===0&&(0,R.jsx)(`div`,{className:`px-3 py-8 text-center text-sm text-muted-foreground`,children:`No files`})]})]}):null:(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Select a directory to preview`})}function Ol({orchestratorId:e,selectedPath:t,line:n,onReadError:r}){let{file:i,loading:a,error:o}=wl(e,t),s=(0,L.useRef)(null),[c,l]=(0,L.useState)(`raw`);(0,L.useEffect)(()=>{r(o)},[o,r]),(0,L.useEffect)(()=>{n>0&&s.current?.scrollIntoView({block:`center`})},[i,n]),(0,L.useEffect)(()=>{if(!i||i.encoding===`binary`)return;if(n>0){l(`raw`);return}let e=yl(i.path,i.mediaType,i.content);l(e?xl(e):`raw`)},[i?.path,i?.encoding,i?.mediaType,i?.content,n]);function u(e,t){l(e),t&&Sl(t,e)}if(!t)return(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Select a file to preview`});if(a)return(0,R.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(Be,{className:`h-4 w-4 animate-spin`}),`Loading file`]});if(o)return(0,R.jsx)(`div`,{className:`h-full bg-muted/20`});if(!i)return null;if(i.encoding===`base64`)return(0,R.jsxs)(`div`,{className:`flex h-full flex-col bg-muted/20`,children:[(0,R.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-background px-3 py-2 text-xs`,children:[(0,R.jsx)(b,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:i.path}),(0,R.jsx)(Tn,{value:i.path,label:`Copy path`,copiedLabel:`Copied path`,size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0`}),(0,R.jsx)(N,{variant:`outline`,className:`text-[10px]`,children:gl(i.size)})]}),(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:(0,R.jsx)(ll,{src:`data:${i.mediaType};base64,${i.content??``}`,alt:i.name,className:`max-h-full max-w-full object-contain`,style:{imageRendering:i.mediaType===`image/svg+xml`?`auto`:void 0}})})]});if(i.encoding===`binary`)return(0,R.jsxs)(`div`,{className:`p-4 text-sm`,children:[(0,R.jsx)(`div`,{className:`font-medium`,children:i.name}),(0,R.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:i.truncated?`File too large to preview.`:`Binary file preview is not available.`}),(0,R.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,R.jsx)(N,{variant:`secondary`,children:i.mediaType}),(0,R.jsx)(N,{variant:`outline`,children:gl(i.size)})]})]});let d=i.content??``,f=vl(i.path,i.mediaType),p=!f&&rl(i.path,i.mediaType,void 0,d),m=f||p,h=f?`markdown`:p?`code`:null;return(0,R.jsxs)(`div`,{className:`h-full overflow-auto bg-muted/20`,children:[(0,R.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-background px-3 py-2 text-xs`,children:[(0,R.jsx)(b,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:i.path}),(0,R.jsx)(Tn,{value:i.path,label:`Copy path`,copiedLabel:`Copied path`,size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0`}),i.truncated&&(0,R.jsx)(N,{variant:`secondary`,className:`text-[10px]`,children:`truncated`}),(0,R.jsx)(N,{variant:`outline`,className:`text-[10px]`,children:gl(i.size)}),m&&(0,R.jsxs)(`div`,{className:`flex shrink-0 rounded-md border border-border bg-muted/40 p-0.5`,children:[(0,R.jsx)(`button`,{type:`button`,className:`rounded px-2 py-1 text-[10px] font-medium ${c===`raw`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>u(`raw`,h),children:`Raw`}),(0,R.jsx)(`button`,{type:`button`,className:`rounded px-2 py-1 text-[10px] font-medium ${c===`rendered`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>u(`rendered`,h),children:f?`Rendered`:`Highlighted`})]})]}),c===`rendered`&&f&&(0,R.jsx)(ol,{content:d,path:i.path}),c===`rendered`&&p&&(0,R.jsx)(il,{content:d,path:i.path,mediaType:i.mediaType}),c===`raw`&&(0,R.jsx)(El,{content:d,line:n,lineRef:s})]})}function kl({overlay:e=!1}){let t=k(e=>e.apiCall),n=k(e=>e.orchestrators),r=k(e=>e.fileOrchestratorId),i=k(e=>e.filePath),a=k(e=>e.fileSelectedPath),o=k(e=>e.fileSelectedLine),s=k(e=>e.set),l=k(e=>e.closeFileOverlay),u=k(e=>e.openOrchestratorSpawnAt),[d,f]=(0,L.useState)(null),[p,m]=(0,L.useState)(i),[h,g]=(0,L.useState)(!1),[v,y]=(0,L.useState)(``),[S,ee]=(0,L.useState)(``),[te,C]=(0,L.useState)(dl),ne=(0,L.useMemo)(()=>n.filter(e=>e.status===`online`),[n]),re=n.find(e=>e.id===r)||ne[0];(0,L.useEffect)(()=>{if(!re)return;let e={};r||(e.fileOrchestratorId=re.id),i||(e.filePath=re.baseDir),Object.keys(e).length&&s(e)},[r,i,re,s]),(0,L.useEffect)(()=>m(i),[i]);async function ie(e=i){if(!(!re||!e)){g(!0),y(``);try{let n=await t(`GET`,ml(re.id,e,te));f(n),s({filePath:n.path}),m(n.path),ee(``)}catch(e){y(Ct(e))}finally{g(!1)}}}(0,L.useEffect)(()=>{ie(i)},[re?.id,i,te]);function oe(e){C(e),fl(e)}function se(e){s({fileOrchestratorId:e,filePath:n.find(t=>t.id===e)?.baseDir||``,fileSelectedPath:``,fileSelectedLine:0})}function ce(e){ee(``),e.type===`directory`?s({filePath:e.path,fileSelectedPath:``,fileSelectedLine:0}):s({fileSelectedPath:e.path,fileSelectedLine:0})}function w(){if(!re)return;let t=p.trim()||i||re.baseDir;e&&l(),u({orchestratorId:re.id,cwd:t})}let le=d?Cl(d.path,d.baseDir):[],ue=v||S;return(0,R.jsxs)(`div`,{className:e?`flex h-full flex-col`:`flex h-[calc(100dvh-5rem)] flex-col gap-3 md:gap-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a?`hidden md:flex`:``}`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,R.jsx)(c,{className:`h-5 w-5 text-primary`}),`Files`]}),(0,R.jsxs)(`select`,{value:re?.id||``,onChange:e=>se(e.target.value),className:`h-9 rounded-md border border-input bg-background px-3 text-sm`,children:[ne.length===0&&(0,R.jsx)(`option`,{value:``,children:`No online orchestrators`}),ne.map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.hostname||e.id},e.id))]}),e&&(0,R.jsx)(P,{size:`icon`,variant:`ghost`,className:`ml-auto h-8 w-8`,onClick:l,title:`Close`,children:(0,R.jsx)(Ee,{className:`h-4 w-4`})})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a?`hidden md:flex`:``}`,children:[(0,R.jsx)(F,{value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&s({filePath:p,fileSelectedPath:``,fileSelectedLine:0})},className:`min-w-0 flex-1 basis-full font-mono text-xs sm:basis-auto`,placeholder:re?.baseDir||`Path`}),(0,R.jsxs)(P,{size:`sm`,variant:`outline`,className:`gap-1`,onClick:()=>ie(p),disabled:h||!re,children:[h?(0,R.jsx)(Be,{className:`h-3.5 w-3.5 animate-spin`}):(0,R.jsx)(x,{className:`h-3.5 w-3.5`}),`Open`]}),(0,R.jsxs)(P,{size:`sm`,className:`gap-1`,onClick:w,disabled:!re,children:[(0,R.jsx)(_,{className:`h-3.5 w-3.5`}),(0,R.jsx)(`span`,{className:`sm:hidden`,children:`Spawn`}),(0,R.jsx)(`span`,{className:`hidden sm:inline`,children:`Spawn from here`})]}),(0,R.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,title:`Show git status colors`,children:[(0,R.jsx)($e,{className:`h-3.5 w-3.5`}),(0,R.jsx)(`span`,{className:`hidden sm:inline`,children:`Git`}),(0,R.jsx)(Mc,{checked:te,onCheckedChange:oe})]})]}),le.length>0&&(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 text-xs text-muted-foreground ${a?`hidden md:flex`:``}`,children:le.map((e,t)=>(0,R.jsxs)(`button`,{type:`button`,className:`rounded px-1.5 py-0.5 font-mono hover:bg-accent hover:text-foreground`,onClick:()=>s({filePath:e.path,fileSelectedPath:``,fileSelectedLine:0}),children:[e.label,t<le.length-1&&e.label!==`/`?` /`:``]},`${e.path}-${t}`))}),ue&&(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:ue}),(0,R.jsxs)(`div`,{className:`grid min-h-0 flex-1 overflow-hidden md:rounded-md md:border md:border-border md:grid-cols-[22rem_minmax(0,1fr)] ${a?``:`rounded-md border border-border`}`,children:[(0,R.jsxs)(`div`,{className:`min-h-0 overflow-auto border-b border-border bg-card md:border-b-0 md:border-r ${a?`hidden md:block`:``}`,children:[d?.parent&&(0,R.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-accent`,onClick:()=>s({filePath:d.parent,fileSelectedPath:``,fileSelectedLine:0}),children:[(0,R.jsx)(T,{className:`h-4 w-4 text-muted-foreground`}),(0,R.jsx)(`span`,{children:`Parent directory`})]}),d?.entries.map(e=>{let t=a===e.path||i===e.path,n=e.type===`directory`?ae:b,r=pl(e.gitStatus);return(0,R.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-accent ${t?`bg-accent`:``}`,onClick:()=>ce(e),children:[(0,R.jsx)(n,{className:`h-4 w-4 shrink-0 ${e.type===`directory`?`text-blue-400`:`text-muted-foreground`}`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs ${r?.text??``}`,children:e.name}),e.symlink&&(0,R.jsx)(Pe,{className:`h-3 w-3 shrink-0 text-muted-foreground/60`}),(0,R.jsx)(hl,{status:e.gitStatus}),e.type!==`directory`&&(0,R.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:gl(e.size)})]},e.path)}),!h&&d&&d.entries.length===0&&(0,R.jsx)(`div`,{className:`px-3 py-8 text-center text-sm text-muted-foreground`,children:`No files`})]}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden ${a?``:`hidden md:flex`}`,children:[(0,R.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 border-b border-border px-3 py-2 text-xs text-muted-foreground hover:text-foreground md:hidden`,onClick:()=>s({fileSelectedPath:``,fileSelectedLine:0}),children:[(0,R.jsx)(T,{className:`h-3.5 w-3.5`}),`Back to files`]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,R.jsx)(Ol,{orchestratorId:re?.id||``,selectedPath:a,line:o,onReadError:ee})})]})]})]})}function Al(){return(0,R.jsx)(kl,{})}function jl(){return k(e=>e.fileOverlayOpen)?(0,R.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/80 backdrop-blur-sm`,children:(0,R.jsx)(`div`,{className:`absolute inset-4 overflow-hidden rounded-md border border-border bg-background p-4 shadow-xl`,children:(0,R.jsx)(kl,{overlay:!0})})}):null}function Ml(e,t){let n=L.useRef(!1),r=L.useRef(t);r.current=t,L.useEffect(()=>{if(!e||!r.current)return;window.history.pushState({sheetGuard:!0},``),n.current=!0;function t(){n.current&&(n.current=!1,r.current?.(!1))}return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t),n.current&&(n.current=!1,window.history.back())}},[e])}function Nl({...e}){return Ml(e.open,e.onOpenChange),(0,R.jsx)(mr,{"data-slot":`sheet`,...e})}function Pl({...e}){return(0,R.jsx)(hr,{"data-slot":`sheet-portal`,...e})}function Fl({className:e,...t}){return(0,R.jsx)(gr,{"data-slot":`sheet-overlay`,className:S(`fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function Il({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,R.jsxs)(Pl,{children:[(0,R.jsx)(Fl,{}),(0,R.jsxs)(_r,{"data-slot":`sheet-content`,"data-side":n,className:S(`fixed z-50 flex flex-col bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out overflow-hidden max-w-[100dvw] data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-full data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-full data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10`,e),...i,children:[t,r&&(0,R.jsx)(br,{"data-slot":`sheet-close`,asChild:!0,children:(0,R.jsxs)(P,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`,children:[(0,R.jsx)(Ee,{}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function Ll({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`sheet-header`,className:S(`flex flex-col gap-0.5 p-4`,e),...t})}function Rl({className:e,...t}){return(0,R.jsx)(vr,{"data-slot":`sheet-title`,className:S(`font-heading text-base font-medium text-foreground`,e),...t})}function zl({className:e,orientation:t=`horizontal`,...n}){return(0,R.jsx)(As,{"data-slot":`tabs`,"data-orientation":t,className:S(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var Bl=$t(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function W({className:e,variant:t=`default`,...n}){return(0,R.jsx)(js,{"data-slot":`tabs-list`,"data-variant":t,className:S(Bl({variant:t}),e),...n})}function G({className:e,...t}){return(0,R.jsx)(Ms,{"data-slot":`tabs-trigger`,className:S(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function K({className:e,...t}){return(0,R.jsx)(Ns,{"data-slot":`tabs-content`,className:S(`flex-1 text-sm outline-none`,e),...t})}function q({agent:e,now:t,className:n}){return(0,R.jsx)(`span`,{className:S(`inline-block w-2.5 h-2.5 rounded-full shrink-0`,mt(e,t),n)})}var J={codex:`text-blue-400 bg-blue-500/10 border-blue-500/25`,claude:`text-yellow-400 bg-yellow-500/10 border-yellow-500/25`,user:`text-emerald-400 bg-emerald-500/10 border-emerald-500/25`,system:`text-purple-400 bg-purple-500/10 border-purple-500/25`,channel:`text-blue-400 bg-blue-500/10 border-blue-500/25`,agent:`text-zinc-400 bg-zinc-500/10 border-zinc-500/25`},Vl={codex:Ce,claude:fe,user:Je,system:ie,channel:m,agent:tt};function Hl({agent:e,className:t}){let n=It(e),r=Vl[n]||tt;return(0,R.jsx)(`span`,{className:S(`inline-flex items-center justify-center w-5 h-5 rounded-md border text-sm`,J[n]||J.agent,t),children:(0,R.jsx)(r,{className:`w-3.5 h-3.5`})})}function Ul({agent:e,compact:t=!1}){let n=$l(e);return n.length===0?null:(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:n.slice(0,t?4:void 0).map(e=>(0,R.jsx)(N,{variant:`outline`,className:`text-[9px] px-1 py-0 h-4`,children:e},e))})}function Wl({agent:e,compact:t=!1,className:n=``}){let r=Kl(e);return(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 ${n}`,children:r.map(e=>{let n=e.Icon;return(0,R.jsxs)(`span`,{title:e.title,className:`inline-flex h-5 min-w-5 items-center justify-center gap-1 rounded-md border px-1.5 text-[10px] leading-none ${e.className}`,children:[(0,R.jsx)(n,{className:`h-3 w-3 shrink-0`}),!t&&(0,R.jsx)(`span`,{children:e.label})]},e.key)})})}function Gl({agent:e}){let t=e.context;if(!t)return null;let n=nu(t);if(n===null)return(0,R.jsxs)(`div`,{className:`space-y-1`,title:ru(t),children:[(0,R.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:`collecting`}),(0,R.jsx)(`span`,{children:`--`})]}),(0,R.jsx)(`div`,{className:`h-1.5 rounded-full bg-muted overflow-hidden`,children:(0,R.jsx)(`div`,{className:`h-full w-0 bg-muted-foreground/30`})})]});let r=Math.round(n*100),i=r>=80?`bg-red-500`:r>=60?`bg-yellow-500`:`bg-emerald-500`;return(0,R.jsxs)(`div`,{className:`space-y-1`,title:ru(t),children:[(0,R.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:t.lifecycleState}),(0,R.jsxs)(`span`,{children:[r,`%`]})]}),(0,R.jsx)(`div`,{className:`h-1.5 rounded-full bg-muted overflow-hidden`,children:(0,R.jsx)(`div`,{className:`h-full ${i}`,style:{width:`${Math.max(0,Math.min(100,r))}%`}})})]})}function Kl(e){let t=ql(e),n=Jl(e),r=Yl(e);return[{key:`origin`,label:t?`Relay`:`External`,title:t?`Agent Relay spawned this agent`:`Externally started agent registered with Agent Relay`,Icon:t?ke:Te,className:t?`border-sky-500/30 bg-sky-500/10 text-sky-300`:`border-zinc-500/30 bg-zinc-500/10 text-zinc-300`},n,r]}function ql(e){return typeof e.meta?.spawnRequestId==`string`||typeof e.meta?.policyName==`string`||typeof e.meta?.automationRunId==`string`}function Jl(e){let t=String(e.providerCapabilities?.session?.approvalMode||e.meta?.approvalMode||`guarded`).toLowerCase();return t===`open`?{key:`approval`,label:`Open`,title:`Approval mode: open`,Icon:he,className:`border-emerald-500/30 bg-emerald-500/10 text-emerald-300`}:t===`read-only`?{key:`approval`,label:`Read-only`,title:`Approval mode: read-only`,Icon:v,className:`border-blue-500/30 bg-blue-500/10 text-blue-300`}:{key:`approval`,label:`Guarded`,title:`Approval mode: guarded`,Icon:Oe,className:`border-amber-500/30 bg-amber-500/10 text-amber-300`}}function Yl(e){let t=Xl(e.meta?.workspace),n=wt(t.requestedMode)||wt(e.meta?.workspaceMode),r=wt(t.mode),a=n&&n!==`inherit`?n:r&&n!==`inherit`?r:`default`;return a===`isolated`?{key:`workspace`,label:`Isolated`,title:`Workspace: isolated worktree`,Icon:$e,iconColor:`text-violet-300`,className:`border-violet-500/30 bg-violet-500/10 text-violet-300`}:a===`shared`?{key:`workspace`,label:`Shared`,title:`Workspace: shared repo checkout`,Icon:i,iconColor:`text-cyan-300`,className:`border-cyan-500/30 bg-cyan-500/10 text-cyan-300`}:{key:`workspace`,label:`Default`,title:r?`Workspace: default/inherit, resolved to ${r}`:`Workspace: default/inherit`,Icon:He,iconColor:`text-zinc-400`,className:`border-zinc-500/30 bg-zinc-500/10 text-zinc-300`}}function Xl(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Zl(e){let t=Xl(e.meta?.workspace),n=wt(t.repoRoot)||wt(t.sourceCwd)||wt(e.meta?.cwd);return n?bt(n,2):``}function Ql(e){return!!(e.context||e.providerCapabilities?.context)}function $l(e){let t=e.providerCapabilities,n=e.context,r=[];t?.lifecycle.managed?r.push(`managed`):t&&r.push(`bridge`),t?.session?.approvalMode===`read-only`?r.push(`read-only`):t?.session?.fileWrite&&r.push(`write`),t?.session?.shell&&r.push(`shell`),(t?.model?.alias||t?.model?.id)&&r.push(String(t.model.alias||t.model.id));let i=Vt(e).length;if(i&&r.push(i===1?`1 subagent`:`${i} subagents`),n){let e=nu(n);r.push(e===null?`ctx collecting`:`${Math.round(e*100)}% ctx`)}return r}function eu({context:e,expected:t=!!e,size:n=26,className:r}){let i=nu(e);if(i===null&&!t)return null;let a=n>=24?3:2.5,o=n/2,s=o-a,c=2*Math.PI*s,l=i===null?c:c*(1-i),u=i===null,d=u?`text-muted-foreground`:i>.8?`text-red-400`:i>.5?`text-yellow-400`:`text-emerald-400`,f=u?null:Math.round(i*100);return(0,R.jsxs)(`div`,{className:`relative shrink-0 ${u?`opacity-70`:``} ${r??``}`,style:{width:n,height:n},title:ru(e),children:[(0,R.jsxs)(`svg`,{width:n,height:n,viewBox:`0 0 ${n} ${n}`,className:`rotate-[-90deg]`,children:[(0,R.jsx)(`circle`,{cx:o,cy:o,r:s,fill:`none`,strokeWidth:a,className:`stroke-muted-foreground/20`}),(0,R.jsx)(`circle`,{cx:o,cy:o,r:s,fill:`none`,strokeWidth:a,strokeDasharray:c,strokeDashoffset:l,strokeLinecap:`round`,className:`${d} stroke-current transition-all duration-500`})]}),(0,R.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center font-semibold leading-none ${u?`text-muted-foreground`:d}`,style:{fontSize:n>=24?8:7},children:u?`?`:f})]})}function tu(e){let t=e.context;return!t?.tokensUsed&&!t?.tokensMax?null:t.tokensUsed&&t.tokensMax?`${iu(t.tokensUsed)} / ${iu(t.tokensMax)}`:t.tokensUsed?iu(t.tokensUsed):t.tokensMax?iu(t.tokensMax):null}function nu(e){return!e||typeof e.utilization!=`number`||!Number.isFinite(e.utilization)?null:Math.min(1,Math.max(0,e.utilization))}function ru(e){if(!e)return`Context: collecting; provider has not reported usage yet`;let t=nu(e),n=`${e.source}/${e.confidence}`,r=Number.isFinite(e.lastUpdatedAt)?new Date(e.lastUpdatedAt).toLocaleString():`unknown`;return t===null?`Context: unknown; ${n}; updated ${r}`:`Context: ${Math.round(t*100)}%; ${n}; updated ${r}`}function iu(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}var au=(0,L.lazy)(()=>I(()=>import(`./terminal-viewer-impl-D_Sqe-vo.js`).then(e=>({default:e.TerminalDialog})),__vite__mapDeps([7,1,6,8,9,10,11,12,13]),import.meta.url));function ou(e){return e.open?(0,R.jsx)(L.Suspense,{fallback:null,children:(0,R.jsx)(au,{...e})}):null}function su({orchestratorId:e,session:t,lines:n=200}){let r=k(e=>e.apiCall),[i,o]=(0,L.useState)([]),[s,c]=(0,L.useState)(``),[l,u]=(0,L.useState)(!1),[f,p]=(0,L.useState)(`provider`),[m,h]=(0,L.useState)(null);async function g(){if(!l)try{o((await r(`GET`,`/orchestrators/${encodeURIComponent(e)}/logs/${encodeURIComponent(t)}?lines=${n}${f===`mirror`?`&stream=mirror`:``}`)).lines||[]),h(null)}catch(e){h(Ct(e))}}(0,L.useEffect)(()=>{g();let e=setInterval(()=>void g(),1500);return()=>clearInterval(e)},[e,t,l,f]);let _=s?i.filter(e=>e.toLowerCase().includes(s.toLowerCase())):i;return(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(`div`,{className:`relative min-w-48 flex-1`,children:[(0,R.jsx)(a,{className:`absolute left-2 top-2.5 h-4 w-4 text-muted-foreground`}),(0,R.jsx)(F,{className:`pl-8`,value:s,onChange:e=>c(e.target.value),placeholder:`Search logs`})]}),(0,R.jsxs)(`div`,{className:`flex rounded-md border border-border overflow-hidden`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>p(`provider`),title:`Provider output`,className:S(`flex items-center gap-1 px-2 py-1.5 text-xs`,f===`provider`?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/50`),children:[(0,R.jsx)(Ce,{className:`h-3.5 w-3.5`}),` Output`]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>p(`mirror`),title:`Session-mirror diagnostics (clean)`,className:S(`flex items-center gap-1 px-2 py-1.5 text-xs border-l border-border`,f===`mirror`?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/50`),children:[(0,R.jsx)(we,{className:`h-3.5 w-3.5`}),` Mirror`]})]}),(0,R.jsx)(P,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>u(e=>!e),title:l?`Resume logs`:`Pause logs`,children:l?(0,R.jsx)(nt,{className:`h-4 w-4`}):(0,R.jsx)(d,{className:`h-4 w-4`})}),(0,R.jsx)(P,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>Lt(`${t}.log`,i.join(`
16
16
  `),`text/plain`),title:`Download logs`,children:(0,R.jsx)(ce,{className:`h-4 w-4`})})]}),m&&(0,R.jsx)(`div`,{className:`text-sm text-destructive`,children:m}),(0,R.jsx)(`pre`,{className:`max-h-96 overflow-auto rounded-md border border-border bg-zinc-950 p-3 text-xs leading-5 text-zinc-100`,children:_.join(`
17
17
  `)||`No log output`})]})}var cu={running:`bg-emerald-500/20 text-emerald-400`,starting:`bg-blue-500/20 text-blue-400`,stopping:`bg-yellow-500/20 text-yellow-400`,stopped:`bg-zinc-500/20 text-zinc-400`,backoff:`bg-red-500/20 text-red-400`};function lu({agent:e,orchestrators:t}){let n=st(),[r,i]=(0,L.useState)(null),[a,o]=(0,L.useState)([]),[s,c]=(0,L.useState)({spawn:!0,workspace:!0,runtime:!0,profile:!0,lifecycle:!0,activity:!1}),l=typeof e.meta?.policyName==`string`?e.meta.policyName:null,u=typeof e.meta?.profile==`string`?e.meta.profile:null,d=St(e.meta?.agentProfile)?e.meta.agentProfile:null,f=du(d?.projection)?d.projection:null,m=t.find(t=>t.managedAgents.some(t=>t.agentId===e.id)),h=m?.managedAgents.find(t=>t.agentId===e.id);(0,L.useEffect)(()=>{if(!l)return;let e=!1;return p(`GET`,`/spawn-policies/`+encodeURIComponent(l)+`/status`).then(t=>{e||i(t)}).catch(()=>{e||i(null)}),()=>{e=!0}},[l,e.lastSeen]),(0,L.useEffect)(()=>{let t=!1;return p(`GET`,`/activity?agentId=`+encodeURIComponent(e.id)+`&limit=20`).then(e=>{t||o(e)}).catch(()=>{t||o([])}),()=>{t=!0}},[e.id,e.lastSeen]);function g(e){c(t=>({...t,[e]:!t[e]}))}function _(){let t=r?.policy,n=r?.state,i=[`# Agent Diagnostics`,`Agent: ${e.id}`,`Status: ${e.status}`,`Provider: ${e.meta?.provider||`unknown`}`,`Machine: ${e.machine||`unknown`}`];if(l&&i.push(`Policy: ${l}`),u&&i.push(`Agent Profile: ${u}`),t&&(i.push(``,`## Spawn Config`),i.push(`Provider: ${t.provider}`),t.model&&i.push(`Model: ${t.model}`),t.effort&&i.push(`Effort: ${t.effort}`),i.push(`CWD: ${t.cwd}`),i.push(`Permission: ${t.permissionMode}`),i.push(`Mode: ${t.mode}`),t.rig&&i.push(`Rig: ${t.rig}`),t.tags.length&&i.push(`Tags: ${t.tags.join(`, `)}`),t.capabilities.length&&i.push(`Caps: ${t.capabilities.join(`, `)}`)),f){i.push(``,`## Agent Profile Projection`),i.push(`Profile: ${f.profileName}`),i.push(`Provider: ${f.provider}`),i.push(`Base: ${f.base}`),f.warnings.length&&i.push(`Warnings: ${f.warnings.length}`);for(let e of f.entries)i.push(`- ${e.capability}: requested=${e.requested} result=${e.result} detail=${e.detail}`)}if(h&&(i.push(``,`## Runtime`),h.pid&&i.push(`PID: ${h.pid}`),h.sessionName&&i.push(`Session: ${h.sessionName}`),h.supervisor&&i.push(`Supervisor: ${h.supervisor}`),h.systemdUnit&&i.push(`Systemd: ${h.systemdUnit}`),h.terminalSession&&i.push(`Terminal: ${h.terminalSession} (${h.terminalAvailable?`available`:`unavailable`})`),h.tmuxSession&&h.tmuxSession!==h.sessionName&&i.push(`Legacy tmux: ${h.tmuxSession}`),h.spawnRequestId&&i.push(`Spawn Request: ${h.spawnRequestId}`),h.startedAt&&i.push(`Started: ${new Date(h.startedAt).toISOString()}`),m&&i.push(`Orchestrator: ${m.hostname} (${m.id.slice(-8)})`)),h?.workspace&&(i.push(``,`## Workspace`),i.push(`Mode: ${h.workspace.mode}`),h.workspace.status&&i.push(`Status: ${h.workspace.status}`),h.workspace.worktreePath&&i.push(`Worktree: ${h.workspace.worktreePath}`),h.workspace.repoRoot&&i.push(`Repo: ${h.workspace.repoRoot}`),h.workspace.branch&&i.push(`Branch: ${h.workspace.branch}`),h.workspace.baseRef&&i.push(`Base: ${h.workspace.baseRef}`),h.workspace.baseSha&&i.push(`Base SHA: ${h.workspace.baseSha}`),h.workspace.stewardAgentId&&i.push(`Steward: ${h.workspace.stewardAgentId}`)),n&&(i.push(``,`## Lifecycle`),i.push(`Status: ${n.status}`),i.push(`Restarts: ${n.restartCount}`),i.push(`Consecutive failures: ${n.consecutiveFailures}`),n.lastSpawnAt&&i.push(`Last spawn: ${new Date(n.lastSpawnAt).toISOString()}`),n.lastStopAt&&i.push(`Last stop: ${new Date(n.lastStopAt).toISOString()}`),n.healthySince&&i.push(`Healthy since: ${new Date(n.healthySince).toISOString()}`),n.backoffUntil&&i.push(`Backoff until: ${new Date(n.backoffUntil).toISOString()}`),n.lastError&&i.push(`Last error: ${n.lastError}`)),a.length>0){i.push(``,`## Recent Activity`);for(let e of a.slice(0,10))i.push(`- [${new Date(typeof e.createdAt==`number`?e.createdAt:Date.parse(String(e.createdAt))).toISOString()}] ${e.title}${e.body?`: `+e.body.slice(0,100):``}`)}let o=e.meta?.package;o?.name&&o?.version&&(i.push(``,`## Versions`),i.push(`Runner: ${o.name}@${o.version}`));let s=e.meta?.contracts;if(s)for(let[e,t]of Object.entries(s))i.push(`Contract ${e}: ${t}`);return i.join(`
18
18
  `)}let v=r?.policy,y=r?.state;return(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`h3`,{className:`text-sm font-medium flex items-center gap-1.5`,children:[(0,R.jsx)(Xe,{className:`w-3.5 h-3.5 text-muted-foreground`}),`Diagnostics`]}),(0,R.jsx)(Tn,{value:_,label:`Copy Bundle`,showText:!0,size:`sm`,variant:`outline`,className:`h-7 text-xs gap-1`,iconClassName:`w-3 h-3`})]}),v&&(0,R.jsx)(uu,{title:`Spawn Config`,expanded:!!s.spawn,onToggle:()=>g(`spawn`),children:(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 text-xs`,children:[(0,R.jsx)(Y,{label:`Provider`,value:v.provider}),v.model&&(0,R.jsx)(Y,{label:`Model`,value:v.model}),v.effort&&(0,R.jsx)(Y,{label:`Effort`,value:v.effort}),(0,R.jsx)(Y,{label:`Permission`,value:v.permissionMode}),(0,R.jsx)(Y,{label:`Mode`,value:v.mode}),v.rig&&(0,R.jsx)(Y,{label:`Rig`,value:v.rig}),(0,R.jsx)(Y,{label:`CWD`,value:v.cwd,className:`col-span-2`,mono:!0}),v.tags.length>0&&(0,R.jsxs)(`div`,{className:`col-span-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Tags`}),(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-0.5`,children:v.tags.map(e=>(0,R.jsx)(N,{variant:`outline`,className:`text-[10px]`,children:e},e))})]}),v.capabilities.length>0&&(0,R.jsxs)(`div`,{className:`col-span-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Capabilities`}),(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-0.5`,children:v.capabilities.map(e=>(0,R.jsx)(N,{variant:`secondary`,className:`text-[10px]`,children:e},e))})]}),v.providerArgs.length>0&&(0,R.jsx)(Y,{label:`Provider Args`,value:v.providerArgs.join(` `),className:`col-span-2`,mono:!0}),v.binding&&(0,R.jsx)(Y,{label:`Channel`,value:`${v.binding.type}:${v.binding.channelId}`,className:`col-span-2`})]})}),(u||f)&&(0,R.jsx)(uu,{title:`Agent Profile`,expanded:!!s.profile,onToggle:()=>g(`profile`),children:(0,R.jsxs)(`div`,{className:`space-y-2 text-xs`,children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1`,children:[u&&(0,R.jsx)(Y,{label:`Profile`,value:u}),f?.base&&(0,R.jsx)(Y,{label:`Base`,value:f.base}),f?.provider&&(0,R.jsx)(Y,{label:`Provider`,value:f.provider}),f&&(0,R.jsx)(Y,{label:`Unsupported`,value:String(f.unsupported.length)})]}),f?.warnings.length?(0,R.jsxs)(`div`,{className:`rounded border border-yellow-500/20 bg-yellow-500/5 px-2 py-1.5`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Projection warnings`}),(0,R.jsx)(`div`,{className:`mt-1 space-y-1`,children:f.warnings.slice(0,4).map(e=>(0,R.jsx)(`div`,{className:`break-words text-yellow-200/80`,children:e},e))})]}):null,f&&(0,R.jsx)(`div`,{className:`space-y-1`,children:f.entries.map(e=>(0,R.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2 rounded border border-border/60 px-2 py-1`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`font-mono text-[11px]`,children:e.capability}),(0,R.jsx)(`div`,{className:`break-words text-muted-foreground`,children:e.detail})]}),(0,R.jsx)(N,{variant:e.result===`unsupported`?`destructive`:e.result===`partial`?`outline`:`secondary`,className:`h-5 text-[10px]`,children:e.result})]},e.capability))})]})}),h?.workspace&&(0,R.jsx)(uu,{title:`Workspace`,expanded:!!s.workspace,onToggle:()=>g(`workspace`),children:(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 text-xs`,children:[(0,R.jsx)(Y,{label:`Mode`,value:h.workspace.mode}),h.workspace.status&&(0,R.jsx)(Y,{label:`Status`,value:h.workspace.status}),h.workspace.worktreePath&&(0,R.jsx)(Y,{label:`Worktree`,value:h.workspace.worktreePath,className:`col-span-2`,mono:!0}),h.workspace.repoRoot&&(0,R.jsx)(Y,{label:`Repo`,value:h.workspace.repoRoot,className:`col-span-2`,mono:!0}),h.workspace.branch&&(0,R.jsx)(Y,{label:`Branch`,value:h.workspace.branch,className:`col-span-2`,mono:!0}),h.workspace.baseRef&&(0,R.jsx)(Y,{label:`Base`,value:h.workspace.baseRef}),h.workspace.baseSha&&(0,R.jsx)(Y,{label:`Base SHA`,value:h.workspace.baseSha.slice(0,12),mono:!0}),h.workspace.stewardAgentId&&(0,R.jsx)(Y,{label:`Steward`,value:h.workspace.stewardAgentId,className:`col-span-2`,mono:!0})]})}),h&&(0,R.jsx)(uu,{title:`Runtime`,expanded:!!s.runtime,onToggle:()=>g(`runtime`),children:(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 text-xs`,children:[h.pid&&(0,R.jsx)(Y,{label:`PID`,value:String(h.pid),mono:!0}),h.sessionName&&(0,R.jsx)(Y,{label:`Session`,value:h.sessionName,mono:!0}),h.supervisor&&(0,R.jsx)(Y,{label:`Supervisor`,value:h.supervisor}),h.systemdUnit&&(0,R.jsx)(Y,{label:`Systemd`,value:h.systemdUnit,mono:!0}),h.terminalSession&&(0,R.jsx)(Y,{label:`Terminal`,value:`${h.terminalSession} (${h.terminalAvailable?`available`:`unavailable`})`,mono:!0}),h.tmuxSession&&h.tmuxSession!==h.sessionName&&(0,R.jsx)(Y,{label:`Legacy tmux`,value:h.tmuxSession,mono:!0}),h.spawnRequestId&&(0,R.jsx)(Y,{label:`Spawn ID`,value:h.spawnRequestId.slice(0,12),mono:!0}),h.startedAt&&(0,R.jsx)(Y,{label:`Started`,value:At(h.startedAt)}),m&&(0,R.jsx)(Y,{label:`Orchestrator`,value:`${m.hostname} (${m.id.slice(-8)})`}),m&&(0,R.jsx)(Y,{label:`Orch Status`,value:m.status})]})}),y&&(0,R.jsx)(uu,{title:`Lifecycle`,expanded:!!s.lifecycle,onToggle:()=>g(`lifecycle`),children:(0,R.jsxs)(`div`,{className:`space-y-2 text-xs`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Status`}),(0,R.jsx)(N,{className:cu[y.status]||`bg-zinc-500/20 text-zinc-400`,children:y.status})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1`,children:[(0,R.jsx)(Y,{label:`Restarts`,value:String(y.restartCount)}),(0,R.jsx)(Y,{label:`Failures`,value:String(y.consecutiveFailures)}),y.lastSpawnAt&&(0,R.jsx)(Y,{label:`Last spawn`,value:yt(n,y.lastSpawnAt)}),y.lastStopAt&&(0,R.jsx)(Y,{label:`Last stop`,value:yt(n,y.lastStopAt)}),y.healthySince&&(0,R.jsx)(Y,{label:`Healthy since`,value:yt(n,y.healthySince)}),y.backoffUntil&&(0,R.jsx)(Y,{label:`Backoff until`,value:y.backoffUntil>n?yt(n,y.backoffUntil):`expired`})]}),y.lastError&&(0,R.jsxs)(`div`,{className:`rounded border border-red-500/20 bg-red-500/5 px-2 py-1.5`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Last error`}),(0,R.jsx)(`div`,{className:`mt-0.5 break-words text-red-300/80`,children:y.lastError})]})]})}),(0,R.jsx)(uu,{title:`Activity (${a.length})`,expanded:!!s.activity,onToggle:()=>g(`activity`),children:a.length===0?(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No recent events`}):(0,R.jsx)(`div`,{className:`space-y-1`,children:a.slice(0,15).map(e=>(0,R.jsxs)(`div`,{className:`flex items-start gap-2 text-xs`,children:[(0,R.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground tabular-nums w-14`,children:yt(n,typeof e.createdAt==`number`?e.createdAt:Date.parse(String(e.createdAt)))}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:e.title}),e.body&&(0,R.jsx)(`span`,{className:`text-muted-foreground ml-1 break-words`,children:e.body.length>80?e.body.slice(0,80)+`...`:e.body})]})]},e.id))})}),!v&&!h&&!y&&a.length===0&&(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No managed-agent diagnostics available for this agent.`})]})}function uu({title:e,expanded:t,onToggle:n,children:r}){return(0,R.jsxs)(`div`,{className:`rounded-md border border-border`,children:[(0,R.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium hover:bg-muted/50`,onClick:n,children:[t?(0,R.jsx)(_e,{className:`w-3 h-3`}):(0,R.jsx)(ze,{className:`w-3 h-3`}),e]}),t&&(0,R.jsx)(`div`,{className:`px-2.5 pb-2.5`,children:r})]})}function du(e){return St(e)&&typeof e.profileName==`string`&&typeof e.provider==`string`&&typeof e.base==`string`&&Array.isArray(e.entries)&&Array.isArray(e.warnings)&&Array.isArray(e.unsupported)}function Y({label:e,value:t,className:n=``,mono:r=!1}){return(0,R.jsxs)(`div`,{className:`min-w-0 ${n}`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,R.jsx)(`div`,{className:`truncate ${r?`font-mono`:``}`,title:t,children:t})]})}function fu(e,t){return!!e.spawnedBy&&e.status!==`offline`&&!Kt(t,e)}function pu(e,t){let n=new Map;for(let r of e){if(!r.spawnedBy||!fu(r,t))continue;let e=n.get(r.spawnedBy);e?e.push(r):n.set(r.spawnedBy,[r])}return n}function mu(e,t,n){let r=new Set(e.map(e=>e.id)),i=pu(e,n),a=[],o=new Set;for(let s of e){if(o.has(s.id)||s.spawnedBy&&!fu(s,n))continue;let e=!!(s.spawnedBy&&r.has(s.spawnedBy));if(fu(s,n)&&e)continue;let c=i.get(s.id)??[];a.push({agent:s,depth:0,parent:s.spawnedBy?t[s.spawnedBy]??null:null,children:c}),o.add(s.id);for(let e of c)o.has(e.id)||(a.push({agent:e,depth:1,parent:s,children:[]}),o.add(e.id))}return a}function hu(e,t){let n=new Set(e.map(e=>e.id));return e.filter(e=>e.spawnedBy&&!fu(e,t)?!1:!fu(e,t)||!e.spawnedBy||!n.has(e.spawnedBy))}function gu(e){return[...e].sort((e,t)=>A(e).localeCompare(A(t)))}var _u=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function vu(e){return!e||e.status!==`offline`&&e.status!==`stale`?!1:(typeof e.meta?.provider==`string`?e.meta.provider:e.providerCapabilities?.model?.provider)===`claude`}function yu(e){for(let t of e){let e=t.metadata,n=typeof e?.provider==`string`?e.provider:``,r=typeof e?.claudeResumeId==`string`?e.claudeResumeId:``;if(n===`claude`&&_u.test(r))return{resumeId:r,timestamp:t.ts}}return null}function bu(){let e=k(e=>e.agentDetailOpen),t=k(e=>e.agentDetailId),n=k(e=>e.agentsById),i=k(e=>e.messages),a=k(e=>e.orchestrators),o=k(e=>e.fetchOrchestrators),c=st(),u=k(e=>e.set),d=k(e=>e.closeAgentDetail),f=k(e=>e.openAgentDetail),m=k(e=>e.openComposeToAgent),h=k(e=>e.openInboxThread),_=k(e=>e.openRename),v=k(e=>e.openPairInvite),y=k(e=>e.switchView),b=k(e=>e.openConfirm),S=k(e=>e.showError),te=k(e=>e.showNotification),C=k(e=>e.doAgentAction),ne=k(e=>e.doDeleteAgent),re=k(e=>e.openFilesForAgent),[ie,ae]=(0,L.useState)([]),[se,ce]=(0,L.useState)(null),[w,T]=(0,L.useState)(`overview`),[ue,de]=(0,L.useState)(!1),[fe,E]=(0,L.useState)(null),[me,he]=(0,L.useState)(!1),[ge,_e]=(0,L.useState)(null),ye=k(e=>e.livenessMismatches),be=k(e=>e.commandStalls),D=n[t]||null,xe=_c(),Se=D?xe[D.id]??null:null,we=(0,L.useMemo)(()=>Object.values(n),[n]),Te=(0,L.useMemo)(()=>t?i.filter(e=>e.from===t||e.to===t).sort((e,t)=>t.id-e.id).slice(0,8):[],[i,t]);(0,L.useEffect)(()=>{if(!e||!D?.context){ae([]);return}let t=!1;return p(`GET`,`/agents/`+encodeURIComponent(D.id)+`/context-snapshots?limit=24`).then(e=>{t||ae(e)}).catch(()=>{t||ae([])}),()=>{t=!0}},[e,D?.id,D?.context?.lastUpdatedAt]),(0,L.useEffect)(()=>{if(_e(null),!e||!D||!vu(D))return;let t=!1;return p(`GET`,`/agents/`+encodeURIComponent(D.id)+`/timeline?limit=50`).then(e=>{t||_e(yu(e))}).catch(()=>{t||_e(null)}),()=>{t=!0}},[e,D?.id,D?.status,D?.meta?.provider]),(0,L.useEffect)(()=>{if(!e||!D){ce(null);return}let t=!1;return p(`GET`,`/agents/`+encodeURIComponent(D.id)+`/active-memories`).then(e=>{t||ce(e)}).catch(()=>{t||ce(null)}),()=>{t=!0}},[e,D?.id]),(0,L.useEffect)(()=>{T(`overview`),de(!1),E(null)},[t]),(0,L.useEffect)(()=>{e&&D?.meta?.tmuxSession&&a.length===0&&o()},[e,D?.id,D?.meta?.tmuxSession,a.length]);async function Ee(){if(D)try{if(!(await p(`DELETE`,`/agents/`+encodeURIComponent(D.id)+`/active-memories`)).supported){S(`Memory Clear Unavailable`,`The active memory broker does not support clearing active memories.`);return}ce({agentId:D.id,supported:!0,memories:[],total:0}),te(`Active memories cleared`)}catch(e){S(`Memory Clear Failed`,e.message)}}async function Oe(){if(!(!D||me)){he(!0);try{E(await p(`POST`,`/agents/`+encodeURIComponent(D.id)+`/terminal-session`)),de(!0)}catch(e){S(`Terminal Failed`,e.message)}finally{he(!1)}}}async function ke(e){if(e){de(!0);return}de(!1);let t=fe;if(E(null),D&&t?.mode===`guest`)try{await p(`DELETE`,`/agents/`+encodeURIComponent(D.id)+`/terminal-session/`+encodeURIComponent(t.session))}catch{}}if(!D)return(0,R.jsx)(Nl,{open:e,onOpenChange:e=>!e&&d(),children:(0,R.jsx)(Il,{className:`w-full max-w-[100dvw] sm:max-w-md lg:max-w-lg`,children:(0,R.jsx)(Ll,{children:(0,R.jsx)(Rl,{children:`Agent`})})})});let je=jt(c,D,Pt(),Se),Ne=Et(D,`restart`),Pe=Et(D,`shutdown`),Ie=Et(D,`reconnect`),Le=Et(D,`compact`),Re=Et(D,`clearContext`),ze=!!(ge&&vu(D)),Be=Ft(D),He=ku(D.meta?.package),Ue=Au(D.meta?.contracts),O=D.providerCapabilities,We=gt(D),Ge=tu(D),Ke=Vt(D),Je=Mu(D),Ye=Je?Nu(D,Je,a):null,Xe=!!(Je&&Ye?.status===`online`&&D.providerCapabilities?.terminal?.live?.read),Qe=D.providerCapabilities?.model?.provider??(typeof D.meta?.provider==`string`?D.meta.provider:void 0),$e=!!(Xe&&(D.providerCapabilities?.terminal?.live?.write||Qe===`claude`)),et=D.providerCapabilities?.terminal?.attach?.create===!0,tt=Xe||et,nt=ju(D.meta?.lastExit),it=typeof D.meta?.lastError==`string`?D.meta.lastError:nt?.lastError,at=D.spawnedBy?n[D.spawnedBy]??null:null,ot=gu(pu(we,c).get(D.id)??[]),ct=ye[D.id]??null,lt=(je.tone===`offline`||je.tone===`stale`)&&Xe,ut=!!ct||lt,ft=be[D.id]??null;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Nl,{open:e,onOpenChange:e=>!e&&d(),children:(0,R.jsxs)(Il,{className:`w-full max-w-[100dvw] sm:max-w-md lg:max-w-lg p-0`,children:[(0,R.jsxs)(Ll,{className:`shrink-0 p-4 border-b border-border`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,R.jsx)(q,{agent:D,now:c}),(0,R.jsx)(Hl,{agent:D}),(0,R.jsx)(Rl,{className:`text-base truncate`,children:A(D)}),Ql(D)&&(0,R.jsx)(eu,{context:D.context,expected:!0})]}),(0,R.jsx)(Wl,{agent:D,className:`mt-2`})]}),(0,R.jsxs)(`div`,{className:`shrink-0 flex flex-wrap items-center gap-2 p-4 border-b border-border`,children:[(0,R.jsxs)(P,{size:`sm`,variant:`outline`,onClick:()=>{m(D),d()},children:[(0,R.jsx)(s,{className:`w-3 h-3 mr-1`}),`Message`]}),(0,R.jsxs)(P,{size:`sm`,variant:`outline`,onClick:()=>{h(D.id),y(`chat`),d()},children:[(0,R.jsx)(le,{className:`w-3 h-3 mr-1`}),`Chat`]}),(0,R.jsxs)(P,{size:`sm`,variant:`outline`,onClick:()=>{v(D.id),d()},children:[(0,R.jsx)(ve,{className:`w-3 h-3 mr-1`}),`Pair`]}),tt&&(0,R.jsx)(P,{size:`sm`,variant:`outline`,className:`hidden sm:inline-flex px-2`,disabled:me,title:et?`Open guest terminal`:`Open live terminal`,onClick:()=>void Oe(),children:(0,R.jsx)(Ce,{className:`w-3.5 h-3.5`})}),ze&&(0,R.jsx)(P,{size:`sm`,variant:`outline`,className:`hidden sm:inline-flex px-2`,title:`Resume Claude session`,onClick:()=>b(`Resume Claude Session`,`Resume ${A(D)} from Claude session ${ge?.resumeId}? This can reload a large prior context and consume tokens.`,()=>C(D,`resume`,`agent-detail-drawer`)),children:(0,R.jsx)(qe,{className:`w-3.5 h-3.5`})}),Le&&(0,R.jsx)(P,{size:`sm`,variant:`outline`,className:`hidden sm:inline-flex px-2`,title:`Compact context`,onClick:()=>b(`Compact Agent`,`Compact context for ${A(D)}?`,()=>C(D,`compact`,`agent-detail-drawer`)),children:(0,R.jsx)(g,{className:`w-3.5 h-3.5`})}),Ne&&(0,R.jsx)(P,{size:`sm`,variant:`outline`,className:`hidden sm:inline-flex px-2`,title:`Restart`,onClick:()=>b(`Restart Agent`,`Restart ${A(D)}?`,()=>C(D,`restart`,`agent-detail-drawer`)),children:(0,R.jsx)(Ae,{className:`w-3.5 h-3.5`})}),Pe&&(0,R.jsx)(P,{size:`sm`,variant:`outline`,className:`hidden sm:inline-flex px-2`,title:`Shutdown`,onClick:()=>b(`Shutdown Agent`,`Shutdown ${A(D)}?`,()=>C(D,`shutdown`,`agent-detail-drawer`)),children:(0,R.jsx)(l,{className:`w-3.5 h-3.5`})}),(0,R.jsxs)(Pc,{children:[(0,R.jsx)(Fc,{asChild:!0,children:(0,R.jsx)(P,{size:`sm`,variant:`outline`,className:`px-2`,children:(0,R.jsx)(r,{className:`w-3.5 h-3.5`})})}),(0,R.jsxs)(Ic,{align:`end`,children:[tt&&(0,R.jsxs)(Lc,{className:`sm:hidden`,disabled:me,onClick:()=>void Oe(),children:[(0,R.jsx)(Ce,{className:`w-3.5 h-3.5`}),`Terminal`]}),ze&&(0,R.jsxs)(Lc,{className:`sm:hidden`,onClick:()=>b(`Resume Claude Session`,`Resume ${A(D)} from Claude session ${ge?.resumeId}? This can reload a large prior context and consume tokens.`,()=>C(D,`resume`,`agent-detail-drawer`)),children:[(0,R.jsx)(qe,{className:`w-3.5 h-3.5`}),`Resume`]}),Le&&(0,R.jsxs)(Lc,{className:`sm:hidden`,onClick:()=>b(`Compact Agent`,`Compact context for ${A(D)}?`,()=>C(D,`compact`,`agent-detail-drawer`)),children:[(0,R.jsx)(g,{className:`w-3.5 h-3.5`}),`Compact`]}),Ne&&(0,R.jsxs)(Lc,{className:`sm:hidden`,onClick:()=>b(`Restart Agent`,`Restart ${A(D)}?`,()=>C(D,`restart`,`agent-detail-drawer`)),children:[(0,R.jsx)(Ae,{className:`w-3.5 h-3.5`}),`Restart`]}),Pe&&(0,R.jsxs)(Lc,{className:`sm:hidden`,onClick:()=>b(`Shutdown Agent`,`Shutdown ${A(D)}?`,()=>C(D,`shutdown`,`agent-detail-drawer`)),children:[(0,R.jsx)(l,{className:`w-3.5 h-3.5`}),`Shutdown`]}),(tt||ze||Le||Ne||Pe)&&(0,R.jsx)(zc,{className:`sm:hidden`}),(0,R.jsxs)(Lc,{onClick:()=>_(D),children:[(0,R.jsx)(oe,{className:`w-3.5 h-3.5`}),`Rename`]}),Ie&&(0,R.jsxs)(Lc,{onClick:()=>b(`Reconnect Agent`,`Reconnect ${A(D)}?`,()=>C(D,`reconnect`,`agent-detail-drawer`)),children:[(0,R.jsx)(x,{className:`w-3.5 h-3.5`}),`Reconnect`]}),Re&&(0,R.jsxs)(Lc,{onClick:()=>b(`Clear Context`,`Clear context for ${A(D)}?`,()=>C(D,`clearContext`,`agent-detail-drawer`)),children:[(0,R.jsx)(rt,{className:`w-3.5 h-3.5`}),`Clear Context`]}),Be&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(zc,{}),(0,R.jsxs)(Lc,{variant:`destructive`,onClick:()=>b(`Forget Agent`,`Forget ${A(D)}?`,()=>ne(D.id)),children:[(0,R.jsx)(Fe,{className:`w-3.5 h-3.5`}),`Forget`]})]})]})]})]}),ut&&(0,R.jsxs)(`div`,{className:`shrink-0 mx-4 mt-3 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-100`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,R.jsx)(Ve,{className:`w-3.5 h-3.5`}),`Liveness mismatch`]}),(0,R.jsx)(`div`,{className:`mt-1 text-amber-50/85`,children:ct?.detail??`Relay marks this agent offline, but a live terminal session is still reachable — the process may still be running.`}),tt&&(0,R.jsxs)(P,{size:`sm`,variant:`outline`,className:`mt-2 h-7 text-xs`,disabled:me,onClick:()=>void Oe(),children:[(0,R.jsx)(Ce,{className:`w-3 h-3 mr-1`}),`Open terminal`]})]}),ft&&(0,R.jsxs)(`div`,{className:`shrink-0 mx-4 mt-3 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-100`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,R.jsx)(Ve,{className:`w-3.5 h-3.5`}),ft.kind===`clear`?`Context clear stalled`:`Compaction stalled`]}),(0,R.jsx)(`div`,{className:`mt-1 text-amber-50/85`,children:ft.detail}),tt&&(0,R.jsxs)(P,{size:`sm`,variant:`outline`,className:`mt-2 h-7 text-xs`,disabled:me,onClick:()=>void Oe(),children:[(0,R.jsx)(Ce,{className:`w-3 h-3 mr-1`}),`Open terminal`]})]}),(0,R.jsxs)(zl,{value:w,onValueChange:e=>T(e),className:`flex-1 min-h-0 gap-0`,children:[(0,R.jsxs)(W,{variant:`line`,className:`w-full shrink-0 px-4 pt-2`,children:[(0,R.jsx)(G,{value:`overview`,children:`Overview`}),(0,R.jsxs)(G,{value:`timeline`,children:[(0,R.jsx)(Ze,{className:`w-3.5 h-3.5`}),`Timeline`]}),(0,R.jsxs)(G,{value:`logs`,children:[(0,R.jsx)(ee,{className:`w-3.5 h-3.5`}),`Logs`]})]}),(0,R.jsx)(K,{value:`overview`,className:`min-h-0 overflow-y-auto overflow-x-hidden`,children:(0,R.jsxs)(`div`,{className:`p-4 space-y-4 min-w-0`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Status`}),(0,R.jsxs)(`div`,{className:`space-y-1 text-sm min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex justify-between gap-2 min-w-0`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`State`}),(0,R.jsx)(N,{className:pt(je.tone),children:je.label})]}),We?.recommendedAction&&(0,R.jsxs)(`div`,{className:`rounded-md border border-red-500/20 bg-red-500/10 px-2.5 py-2 text-xs text-red-200`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,R.jsx)(De,{className:`w-3.5 h-3.5`}),`Recommended action`]}),(0,R.jsx)(`div`,{className:`mt-1 text-red-100/80`,children:We.recommendedAction})]}),it&&(0,R.jsxs)(`div`,{className:`rounded-md border border-amber-500/25 bg-amber-500/10 px-2.5 py-2 text-xs text-amber-100`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,R.jsx)(De,{className:`w-3.5 h-3.5`}),`Last launch error`]}),(0,R.jsx)(`div`,{className:`mt-1 break-words text-amber-50/85`,children:it}),nt&&(0,R.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-x-3 gap-y-1 text-amber-50/70`,children:[nt.detectedAt&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-amber-100/55`,children:`Detected`}),(0,R.jsx)(`div`,{children:yt(c,nt.detectedAt)})]}),typeof nt.runtimeMs==`number`&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-amber-100/55`,children:`Runtime`}),(0,R.jsxs)(`div`,{children:[Math.max(0,Math.round(nt.runtimeMs/1e3)),`s`]})]}),nt.systemd?.unit&&(0,R.jsxs)(`div`,{className:`col-span-2 min-w-0`,children:[(0,R.jsx)(`span`,{className:`text-amber-100/55`,children:`Unit`}),(0,R.jsx)(`div`,{className:`truncate font-mono`,children:nt.systemd.unit})]}),nt.systemd&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-amber-100/55`,children:`Systemd`}),(0,R.jsx)(`div`,{children:[nt.systemd.activeState,nt.systemd.subState].filter(Boolean).join(`/`)||`unknown`})]}),nt.systemd?.result&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-amber-100/55`,children:`Result`}),(0,R.jsx)(`div`,{children:nt.systemd.result})]}),nt.logFile&&(0,R.jsxs)(`div`,{className:`col-span-2 min-w-0`,children:[(0,R.jsx)(`span`,{className:`text-amber-100/55`,children:`Log`}),(0,R.jsxs)(`div`,{className:`truncate font-mono`,children:[nt.logFile,` (`,nt.logBytes??`unknown`,` bytes`,nt.logEmpty?`, empty`:``,`)`]})]})]}),nt?.logTail?.length?(0,R.jsx)(`pre`,{className:`mt-2 max-h-28 overflow-auto whitespace-pre-wrap break-words rounded border border-amber-500/15 bg-black/20 p-2 text-[11px] text-amber-50/75`,children:nt.logTail.slice(-5).join(`
19
- `)}):null,nt?.unavailable?.length?(0,R.jsx)(`div`,{className:`mt-1 text-amber-50/55`,children:nt.unavailable.join(`; `)}):null]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 pt-0.5 text-xs`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Last seen`}),(0,R.jsx)(`div`,{children:yt(c,D.lastSeen)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Created`}),(0,R.jsx)(`div`,{title:At(D.createdAt),children:yt(c,D.createdAt)})]})]})]})]}),D.context&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Nc,{}),(0,R.jsx)(wu,{context:D.context,tokens:Ge,history:ie,now:c})]}),(D.spawnedBy||ot.length>0||Se)&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Nc,{}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Relationships`}),(0,R.jsxs)(`div`,{className:`space-y-2`,children:[D.spawnedBy&&(0,R.jsxs)(`div`,{className:`rounded-md border border-border p-2 text-xs`,children:[(0,R.jsx)(`div`,{className:`mb-1 text-muted-foreground`,children:`Spawned by`}),(0,R.jsx)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded px-1 py-1 text-left hover:bg-muted/50 disabled:pointer-events-none disabled:opacity-60`,disabled:!at,onClick:()=>at&&f(at),children:at?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(q,{agent:at,now:c}),(0,R.jsx)(Hl,{agent:at}),(0,R.jsx)(`span`,{className:`truncate font-medium`,children:A(at)})]}):(0,R.jsx)(`span`,{className:`truncate font-mono`,children:D.spawnedBy})})]}),ot.length>0&&(0,R.jsxs)(`div`,{className:`rounded-md border border-border p-2 text-xs`,children:[(0,R.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Children`}),(0,R.jsx)(N,{variant:`secondary`,className:`h-4 px-1.5 text-[9px]`,children:ot.length})]}),(0,R.jsx)(`div`,{className:`space-y-1`,children:ot.map(e=>(0,R.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded px-1 py-1 text-left hover:bg-muted/50`,onClick:()=>f(e),children:[(0,R.jsx)(q,{agent:e,now:c}),(0,R.jsx)(Hl,{agent:e}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:A(e)}),(0,R.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.status})]},e.id))})]}),D.spawnedBy&&ot.length===0&&(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,R.jsx)(Me,{className:`h-3.5 w-3.5`}),`No live child agents`]}),Se&&(0,R.jsxs)(`div`,{className:`rounded-md border border-border p-2 text-xs`,children:[(0,R.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Pair`}),(0,R.jsx)(N,{className:Se.status===`active`?`bg-emerald-500/20 text-emerald-400`:`bg-yellow-500/20 text-yellow-400`,children:Se.status})]}),Se.objective&&(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:Se.objective})]})]})]})]}),(O||Ke.length>0)&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Nc,{}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Runtime`}),(0,R.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[We&&(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Provider state`}),(0,R.jsx)(`div`,{children:We.state})]}),We.reason&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Reason`}),(0,R.jsx)(`div`,{children:We.reason})]}),We.source&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Source`}),(0,R.jsx)(`div`,{children:We.source})]}),We.updatedAt&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Updated`}),(0,R.jsx)(`div`,{children:yt(c,We.updatedAt)})]})]}),O?.model&&(0,R.jsxs)(`div`,{className:`space-y-1`,children:[O.model.provider&&(0,R.jsxs)(`div`,{className:`flex justify-between gap-2 min-w-0`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Provider`}),(0,R.jsx)(`span`,{className:`truncate`,children:O.model.provider})]}),(O.model.alias||O.model.id)&&(0,R.jsxs)(`div`,{className:`flex justify-between gap-2 min-w-0`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Model`}),(0,R.jsx)(`span`,{className:`truncate`,children:O.model.alias||O.model.id})]}),O.model.effort&&(0,R.jsxs)(`div`,{className:`flex justify-between gap-2 min-w-0`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Effort`}),(0,R.jsx)(`span`,{className:`truncate`,children:O.model.effort})]})]}),O?.session&&(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1`,children:[O.session.approvalMode&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Mode`}),(0,R.jsx)(`div`,{children:O.session.approvalMode})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Files`}),(0,R.jsx)(`div`,{children:O.session.fileWrite?`read/write`:O.session.fileRead?`read-only`:`none`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Shell`}),(0,R.jsx)(`div`,{children:O.session.shell?`yes`:`no`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Confidence`}),(0,R.jsx)(`div`,{children:O.confidence})]})]}),O?.lifecycle&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Lifecycle`}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:[(0,R.jsx)(N,{variant:O.lifecycle.managed?`secondary`:`outline`,className:`text-[10px]`,children:O.lifecycle.managed?`managed`:`bridge`}),O.lifecycle.shutdownHard&&(0,R.jsx)(N,{variant:`outline`,className:`text-[10px]`,children:`shutdown`}),O.lifecycle.restartHard&&(0,R.jsx)(N,{variant:`outline`,className:`text-[10px]`,children:`restart`}),O.lifecycle.reconnect&&(0,R.jsx)(N,{variant:`outline`,className:`text-[10px]`,children:`reconnect`})]})]}),Ke.length>0&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Subagents`}),(0,R.jsx)(`div`,{className:`space-y-1 mt-1`,children:Ke.map(e=>(0,R.jsxs)(`div`,{className:`flex justify-between gap-2 text-xs rounded border border-border px-2 py-1`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e.label}),e.role&&(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e.role})]},e.id))})]})]})]})]}),se&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Nc,{}),(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-2`,children:[(0,R.jsxs)(`h3`,{className:`text-sm font-medium flex items-center gap-1.5`,children:[(0,R.jsx)(pe,{className:`w-3.5 h-3.5 text-muted-foreground`}),`Memory`]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[se.supported&&(0,R.jsx)(N,{variant:`secondary`,className:`text-[10px]`,children:se.memories.length}),se.supported&&se.memories.length>0&&(0,R.jsxs)(P,{size:`sm`,variant:`outline`,className:`h-7 text-xs gap-1`,onClick:()=>b(`Clear Active Memories`,`Clear active memories for ${A(D)}?`,Ee),children:[(0,R.jsx)(rt,{className:`w-3 h-3`}),`Clear`]})]})]}),se.supported?se.memories.length===0?(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No active memories`}):(0,R.jsx)(`div`,{className:`space-y-2`,children:se.memories.map(e=>(0,R.jsx)(xu,{memory:e,now:c,onOpen:()=>{u({selectedMemoryId:e.id}),y(`memory`),d()}},e.id))}):(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Active memory list unavailable`})]})]}),D.meta?.runnerManaged===!0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Nc,{}),(0,R.jsx)(lu,{agent:D,orchestrators:a})]}),(0,R.jsx)(Nc,{}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Identity`}),(0,R.jsxs)(`div`,{className:`space-y-2.5 text-sm min-w-0`,children:[(0,R.jsx)(Cu,{label:`Agent ID`,value:D.id,copyLabel:`Copy agent ID`}),typeof D.meta?.cwd==`string`&&D.meta.cwd&&(0,R.jsx)(Cu,{label:`Working dir`,value:D.meta.cwd,copyLabel:`Copy working dir`,title:`Open ${D.meta.cwd} in Files`,onClick:()=>{d(),re(D)}}),(D.machine||D.rig||He)&&(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1.5 text-xs`,children:[D.machine&&(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Machine`}),(0,R.jsx)(`div`,{className:`truncate`,title:D.machine,children:D.machine})]}),D.rig&&(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Rig`}),(0,R.jsx)(`div`,{className:`truncate`,title:D.rig,children:D.rig})]}),He&&(0,R.jsxs)(`div`,{className:`col-span-2 min-w-0`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Package`}),(0,R.jsxs)(`div`,{className:`break-all font-mono`,children:[He.name,` v`,He.version]})]})]}),Ue.length>0&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Contracts`}),(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:Ue.map(([e,t])=>(0,R.jsxs)(N,{variant:`secondary`,className:`text-[10px]`,children:[e,`=`,t]},e))})]}),D.tags.length>0&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Tags`}),(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:D.tags.map(e=>(0,R.jsx)(N,{variant:`outline`,className:`text-[10px]`,children:e},e))})]}),ht(D.capabilities).length>0&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Capabilities`}),(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:ht(D.capabilities).map(e=>(0,R.jsx)(N,{variant:`secondary`,className:`text-[10px]`,children:e},e))})]})]})]}),Te.length>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Nc,{}),(0,R.jsxs)(`details`,{className:`group`,children:[(0,R.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 text-sm font-medium`,children:[(0,R.jsx)(`span`,{children:`Recent messages`}),(0,R.jsxs)(`span`,{className:`text-[11px] font-normal text-muted-foreground`,children:[Te.length,` `,(0,R.jsx)(`span`,{className:`group-open:hidden`,children:`· show`}),(0,R.jsx)(`span`,{className:`hidden group-open:inline`,children:`· hide`})]})]}),(0,R.jsx)(`div`,{className:`mt-2 space-y-2`,children:Te.map(e=>(0,R.jsxs)(`div`,{className:`rounded border border-border p-2 text-xs space-y-0.5 min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground min-w-0`,children:[(0,R.jsx)(`span`,{className:`font-medium text-foreground truncate shrink-0 max-w-[40%]`,children:kt(e.from,n)}),(0,R.jsx)(`span`,{className:`shrink-0`,children:`→`}),(0,R.jsx)(`span`,{className:`truncate max-w-[40%]`,children:kt(e.to,n)}),(0,R.jsxs)(`span`,{className:`ml-auto shrink-0 text-[10px]`,children:[(0,R.jsxs)(`span`,{className:`opacity-40 mr-1`,children:[`#`,e.id]}),yt(c,e.createdAt)]})]}),(0,R.jsx)(`div`,{className:`text-foreground whitespace-pre-wrap break-words line-clamp-3`,children:dt(e)})]},e.id))})]})]})]})}),(0,R.jsx)(K,{value:`timeline`,className:`min-h-0 overflow-y-auto overflow-x-hidden`,children:(0,R.jsx)(Eu,{agentId:D.id,open:e&&w===`timeline`,now:c})}),(0,R.jsx)(K,{value:`logs`,className:`min-h-0 overflow-y-auto overflow-x-hidden`,children:Je&&Ye?(0,R.jsx)(`div`,{className:`p-4`,children:(0,R.jsx)(su,{orchestratorId:Ye.id,session:Je})}):(0,R.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`No session logs available for this agent.`})})]})]})}),fe&&(0,R.jsx)(ou,{open:ue,onOpenChange:e=>void ke(e),orchestratorId:fe.orchestratorId,session:fe.session,interactive:fe.interactive||$e})]})}function xu({memory:e,now:t,onOpen:n}){let r=e.sensitivity===`secret`?`bg-red-500/10 text-red-400 border-red-500/30`:e.sensitivity===`sensitive`?`bg-yellow-500/10 text-yellow-400 border-yellow-500/30`:`bg-zinc-500/10 text-zinc-400 border-zinc-500/30`;return(0,R.jsx)(`button`,{onClick:n,className:`w-full rounded-md border border-border p-2 text-left text-xs hover:border-zinc-600 transition-colors`,children:(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[(0,R.jsx)(N,{variant:`secondary`,className:`text-[10px]`,children:e.type}),(0,R.jsx)(N,{variant:`outline`,className:`text-[10px] font-mono`,children:e.scope}),(0,R.jsx)(N,{className:`text-[10px] ${r}`,children:e.sensitivity})]}),(0,R.jsx)(`div`,{className:`font-medium truncate`,children:e.title}),(0,R.jsx)(`div`,{className:`text-muted-foreground line-clamp-2 mt-0.5`,children:e.content})]}),(0,R.jsx)(`div`,{className:`shrink-0 text-right text-[10px] text-muted-foreground`,title:At(e.lastAccessedAt??e.updatedAt),children:yt(t,e.lastAccessedAt??e.updatedAt)})]})})}function Su(e){return e>=.8?`text-red-400`:e>=.6?`text-yellow-400`:`text-emerald-400`}function Cu({label:e,value:t,onClick:n,title:r,copyLabel:i}){let a=`block w-full break-all text-left font-mono text-xs leading-snug ${n?`text-muted-foreground transition-colors hover:text-foreground`:`text-foreground`}`;return(0,R.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground`,children:e}),(0,R.jsx)(Tn,{value:t,label:i??`Copy ${e.toLowerCase()}`,size:`icon-xs`,className:`-my-1 shrink-0 text-muted-foreground`})]}),n?(0,R.jsx)(`button`,{type:`button`,className:a,title:r,onClick:n,children:t}):(0,R.jsx)(`div`,{className:a,title:r,children:t})]})}function wu({context:e,tokens:t,history:n,now:r}){let i=Number.isFinite(e.utilization)?Math.max(0,Math.min(1,e.utilization)):null,a=i===null?null:Math.round(i*100),o=i===null?`text-muted-foreground`:Su(i);return(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 min-w-0`,children:[(0,R.jsx)(`h3`,{className:`shrink-0 text-sm font-medium`,children:`Context`}),(0,R.jsxs)(`span`,{className:`truncate text-[11px] text-muted-foreground`,title:`source ${e.source}, confidence ${e.confidence}`,children:[e.lifecycleState,` · `,e.source,`/`,e.confidence]})]}),(0,R.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,R.jsx)(`span`,{className:`text-2xl font-semibold leading-none ${o}`,children:a===null?`—`:`${a}%`}),t&&(0,R.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[t,` tokens`]})]}),n.length>1&&(0,R.jsx)(Tu,{snapshots:n,now:r}),e.warmTopics.length>0&&(0,R.jsxs)(`div`,{className:`mt-2`,children:[(0,R.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Warm topics`}),(0,R.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:e.warmTopics.map(e=>(0,R.jsx)(N,{variant:`outline`,className:`text-[10px]`,children:e},e))})]})]})}function Tu({snapshots:e,now:t}){let n=e.slice(-24),[r,i]=(0,L.useState)(null);if(n.length<2)return null;let a=n.length,o=e=>Math.max(0,Math.min(1,e)),s=e=>({x:e/(a-1)*100,y:40-o(n[e].utilization)*40}),c=n.map((e,t)=>{let n=s(t);return`${n.x.toFixed(2)},${n.y.toFixed(2)}`}).join(` `),l=Su(o(n[a-1].utilization)),u=r==null?n[a-1]:n[r],d=s(r??a-1);return(0,R.jsxs)(`div`,{className:`mt-2`,children:[(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsxs)(`svg`,{viewBox:`0 0 100 40`,preserveAspectRatio:`none`,className:`h-12 w-full`,"aria-label":`Context utilization history`,children:[(0,R.jsx)(`line`,{x1:`0`,y1:`20`,x2:`100`,y2:`20`,className:`stroke-muted-foreground/15`,strokeWidth:`0.5`,strokeDasharray:`2 2`}),(0,R.jsx)(`polygon`,{points:`0,40 ${c} 100,40`,className:`fill-current text-primary/10`}),(0,R.jsx)(`polyline`,{points:c,fill:`none`,className:`stroke-current ${l}`,strokeWidth:`1.25`,strokeLinejoin:`round`,strokeLinecap:`round`,vectorEffect:`non-scaling-stroke`}),(0,R.jsx)(`circle`,{cx:d.x,cy:d.y,r:`1.6`,className:`fill-current ${l}`,vectorEffect:`non-scaling-stroke`})]}),(0,R.jsx)(`div`,{className:`absolute inset-0 flex`,children:n.map((e,t)=>(0,R.jsx)(`button`,{type:`button`,"aria-label":`${Math.round(o(e.utilization)*100)}% utilization`,className:`h-full flex-1`,onClick:()=>i(t===r?null:t)},e.id))})]}),(0,R.jsxs)(`div`,{className:`mt-1 flex items-center justify-between text-[10px] text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:r==null?(0,R.jsxs)(R.Fragment,{children:[a,` samples · since `,yt(t,n[0].capturedAt)]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:l,children:[Math.round(o(u.utilization)*100),`%`]}),` · `,new Date(u.capturedAt).toLocaleTimeString()]})}),(0,R.jsx)(`span`,{children:`0–100%`})]})]})}function Eu({agentId:e,open:t,now:n}){let[r,i]=(0,L.useState)([]),[a,o]=(0,L.useState)(!1),[s,c]=(0,L.useState)(null),[l,u]=(0,L.useState)(50),d=(0,L.useCallback)(t=>{o(!0),c(null);let n=!1;return p(`GET`,`/agents/`+encodeURIComponent(e)+`/timeline?limit=`+t).then(e=>{n||(i(e),u(t))}).catch(e=>{n||c(e.message)}).finally(()=>{n||o(!1)}),()=>{n=!0}},[e]);return(0,L.useEffect)(()=>{if(t)return d(50)},[t,e,d]),(0,R.jsxs)(`div`,{className:`p-4 space-y-3 min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium`,children:`Timeline`}),(0,R.jsxs)(P,{size:`sm`,variant:`outline`,className:`h-7 text-xs`,disabled:a,onClick:()=>d(l),children:[(0,R.jsx)(x,{className:`w-3 h-3 mr-1`}),`Refresh`]})]}),s&&(0,R.jsx)(`div`,{className:`text-xs text-red-300`,children:s}),!s&&r.length===0&&!a&&(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No timeline activity recorded for this agent.`}),(0,R.jsx)(`div`,{className:`space-y-1.5`,children:r.map((e,t)=>(0,R.jsx)(Ou,{entry:e,now:n},`${e.ts}:${e.source}:${t}`))}),r.length>=l&&l<200&&(0,R.jsx)(P,{size:`sm`,variant:`outline`,className:`w-full h-7 text-xs`,disabled:a,onClick:()=>d(200),children:`Load full timeline`})]})}function Du(e){return e.metadata?.mismatch===!0||e.metadata?.stalled===!0?(0,R.jsx)(Ve,{className:`w-3.5 h-3.5 text-amber-400`}):e.source===`command`?(0,R.jsx)(Ce,{className:`w-3.5 h-3.5 text-sky-400`}):e.source===`delivery`?(0,R.jsx)(s,{className:`w-3.5 h-3.5 text-violet-400`}):e.kind===`state`?(0,R.jsx)(o,{className:`w-3.5 h-3.5 text-emerald-400`}):(0,R.jsx)(y,{className:`w-3.5 h-3.5 text-muted-foreground`})}function Ou({entry:e,now:t}){let n=typeof e.metadata?.status==`string`?e.metadata.status:``,r=/fail|error|poison|dead/i.test(n),i=e.metadata?.fromState,a=e.metadata?.toState,o=typeof i==`string`&&typeof a==`string`?`${i} → ${a}`:null;return(0,R.jsxs)(`div`,{className:`flex gap-2 rounded border border-border px-2 py-1.5 text-xs min-w-0`,children:[(0,R.jsx)(`div`,{className:`shrink-0 mt-0.5`,children:Du(e)}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,R.jsx)(`span`,{className:`font-medium truncate ${r?`text-red-300`:`text-foreground`}`,children:e.title}),(0,R.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] text-muted-foreground`,title:At(e.ts),children:yt(t,e.ts)})]}),o&&(0,R.jsx)(`div`,{className:`text-muted-foreground font-mono text-[11px]`,children:o}),e.detail&&(0,R.jsx)(`div`,{className:`text-muted-foreground whitespace-pre-wrap break-words line-clamp-3`,children:e.detail})]})]})}function ku(e){return St(e)&&typeof e.name==`string`&&typeof e.version==`string`?{name:e.name,version:e.version}:null}function Au(e){return St(e)?Object.entries(e).filter(e=>typeof e[1]==`number`):[]}function ju(e){if(!St(e)||typeof e.lastError!=`string`)return null;let t=St(e.systemd)?{unit:typeof e.systemd.unit==`string`?e.systemd.unit:void 0,activeState:typeof e.systemd.activeState==`string`?e.systemd.activeState:void 0,subState:typeof e.systemd.subState==`string`?e.systemd.subState:void 0,result:typeof e.systemd.result==`string`?e.systemd.result:void 0,execMainCode:typeof e.systemd.execMainCode==`string`?e.systemd.execMainCode:void 0,execMainStatus:typeof e.systemd.execMainStatus==`string`?e.systemd.execMainStatus:void 0}:void 0;return{lastError:e.lastError,detectedAt:typeof e.detectedAt==`number`?e.detectedAt:void 0,runtimeMs:typeof e.runtimeMs==`number`?e.runtimeMs:void 0,logFile:typeof e.logFile==`string`?e.logFile:void 0,logBytes:typeof e.logBytes==`number`?e.logBytes:void 0,logEmpty:typeof e.logEmpty==`boolean`?e.logEmpty:void 0,logTail:Array.isArray(e.logTail)?e.logTail.filter(e=>typeof e==`string`):void 0,systemd:t,unavailable:Array.isArray(e.unavailable)?e.unavailable.filter(e=>typeof e==`string`):void 0}}function Mu(e){let t=e?.meta?.tmuxSession;return typeof t==`string`&&t.trim()?t:null}function Nu(e,t,n){return e?n.find(n=>n.managedAgents.some(n=>n.agentId===e.id||n.tmuxSession===t))??null:null}function Pu({className:e,children:t,...n}){return(0,R.jsxs)(qo,{"data-slot":`scroll-area`,className:S(`relative`,e),...n,children:[(0,R.jsx)(Jo,{"data-slot":`scroll-area-viewport`,className:`size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1`,children:t}),(0,R.jsx)(Fu,{}),(0,R.jsx)(Yo,{})]})}function Fu({className:e,orientation:t=`vertical`,...n}){return(0,R.jsx)(xo,{"data-slot":`scroll-area-scrollbar`,"data-orientation":t,orientation:t,className:S(`flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent`,e),...n,children:(0,R.jsx)(Mo,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}function Iu(){let e=k(e=>e.channelDetailOpen),t=k(e=>e.channelDetailId),n=k(e=>e.channels),r=k(e=>e.messages),i=k(e=>e.agentsById),a=st(),o=k(e=>e.closeChannelDetail),s=n.find(e=>e.id===t)||null,c=Ot(s),l=(0,L.useMemo)(()=>s?r.filter(e=>Mt(e,s)).sort((e,t)=>t.id-e.id).slice(0,8):[],[r,s]);return(0,R.jsx)(Nl,{open:e,onOpenChange:e=>!e&&o(),children:(0,R.jsxs)(Il,{className:`w-full max-w-[100dvw] sm:max-w-md lg:max-w-lg p-0`,children:[(0,R.jsx)(Ll,{className:`shrink-0 p-4 border-b border-border`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,R.jsx)(N,{className:pt(c.tone),children:c.label}),(0,R.jsx)(Rl,{className:`text-base truncate`,children:s?.name||`Channel`})]})}),(0,R.jsx)(Pu,{className:`flex-1 min-h-0`,children:(0,R.jsxs)(`div`,{className:`p-4 space-y-4`,children:[s&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Route`}),(0,R.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,R.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Type`}),(0,R.jsx)(`span`,{className:`truncate`,children:s.type})]}),(0,R.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Direction`}),(0,R.jsx)(`span`,{className:`truncate`,children:s.direction})]}),s.target&&(0,R.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Target`}),(0,R.jsx)(`span`,{className:`truncate`,children:s.target})]}),(0,R.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Agent`}),(0,R.jsx)(`span`,{className:`truncate`,children:s.agentId})]}),(0,R.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Transport`}),(0,R.jsx)(`span`,{className:`truncate`,children:s.transport})]}),(0,R.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Last seen`}),(0,R.jsx)(`span`,{className:`shrink-0`,children:yt(a,s.lastSeen)})]})]})]}),ht(s.capabilities).length>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Nc,{}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Capabilities`}),(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:ht(s.capabilities).map(e=>(0,R.jsx)(N,{variant:`secondary`,className:`text-[10px]`,children:e},e))})]})]}),s.meta&&Object.keys(s.meta).length>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Nc,{}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Metadata`}),(0,R.jsx)(`div`,{className:`space-y-1 text-sm`,children:Object.entries(s.meta).map(([e,t])=>(0,R.jsxs)(`div`,{className:`flex justify-between gap-2 min-w-0`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e}),(0,R.jsx)(`span`,{className:`truncate`,children:String(t)})]},e))})]})]})]}),l.length>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Nc,{}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Recent Messages`}),(0,R.jsx)(`div`,{className:`space-y-2`,children:l.map(e=>(0,R.jsxs)(`div`,{className:`rounded border border-border p-2 text-xs space-y-0.5 min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground min-w-0`,children:[(0,R.jsx)(`span`,{className:`font-medium text-foreground truncate shrink-0 max-w-[40%]`,children:kt(e.from,i)}),(0,R.jsx)(`span`,{className:`shrink-0`,children:`→`}),(0,R.jsx)(`span`,{className:`truncate max-w-[40%]`,children:kt(e.to,i)}),(0,R.jsxs)(`span`,{className:`ml-auto shrink-0 text-[10px]`,children:[(0,R.jsxs)(`span`,{className:`opacity-40 mr-1`,children:[`#`,e.id]}),yt(a,e.createdAt)]})]}),(0,R.jsx)(`div`,{className:`text-foreground whitespace-pre-wrap break-words line-clamp-3`,children:dt(e)})]},e.id))})]})]})]})})]})})}var Lu=!1;function Ru(e,t){let n=L.useRef(!1),r=L.useRef(t);r.current=t,L.useEffect(()=>{if(!e||!r.current)return;Lu=!1,window.history.pushState({dialogGuard:!0},``),n.current=!0;function t(){if(Lu){Lu=!1;return}n.current&&(n.current=!1,r.current?.(!1))}return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t),n.current&&(n.current=!1,Lu=!0,window.history.back())}},[e])}function zu({...e}){return Ru(e.open,e.onOpenChange),(0,R.jsx)(mr,{"data-slot":`dialog`,...e})}function Bu({...e}){return(0,R.jsx)(hr,{"data-slot":`dialog-portal`,...e})}function Vu({className:e,blur:t=!0,...n}){return(0,R.jsx)(gr,{"data-slot":`dialog-overlay`,className:S(`fixed inset-0 isolate z-50 bg-black/10 duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,t&&`supports-backdrop-filter:backdrop-blur-xs`,e),...n})}function Hu({className:e,children:t,showCloseButton:n=!0,blurOverlay:r=!0,...i}){return(0,R.jsxs)(Bu,{children:[(0,R.jsx)(Vu,{blur:r}),(0,R.jsxs)(_r,{"data-slot":`dialog-content`,className:S(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...i,children:[t,n&&(0,R.jsx)(br,{"data-slot":`dialog-close`,asChild:!0,children:(0,R.jsxs)(P,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`,children:[(0,R.jsx)(Ee,{}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function Uu({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`dialog-header`,className:S(`flex flex-col gap-2`,e),...t})}function Wu({className:e,showCloseButton:t=!1,children:n,...r}){return(0,R.jsxs)(`div`,{"data-slot":`dialog-footer`,className:S(`-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,R.jsx)(br,{asChild:!0,children:(0,R.jsx)(P,{variant:`outline`,children:`Close`})})]})}function Gu({className:e,...t}){return(0,R.jsx)(vr,{"data-slot":`dialog-title`,className:S(`font-heading text-base leading-none font-medium`,e),...t})}function X({className:e,...t}){return(0,R.jsx)(yr,{"data-slot":`dialog-description`,className:S(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function Ku({className:e,...t}){return(0,R.jsx)(`textarea`,{"data-slot":`textarea`,className:S(`flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...t})}function Z({className:e,...t}){return(0,R.jsx)(fo,{"data-slot":`label`,className:S(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function qu(){let e=k(e=>e.composeOpen),t=k(e=>e.compose),n=k(e=>e.replyTo),r=k(e=>e.set),i=k(e=>e.doSend),a=k(e=>e.cancelReply),o=Ec();function s(){r({composeOpen:!1}),a()}function c(e){r({compose:{...t,...e}})}return(0,R.jsx)(zu,{open:e,onOpenChange:e=>!e&&s(),children:(0,R.jsxs)(Hu,{className:`max-w-lg`,children:[(0,R.jsx)(Uu,{children:(0,R.jsx)(Gu,{children:n?`Reply to #${n.id}`:`Compose Message`})}),(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`From`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:t.from,onChange:e=>c({from:e.target.value}),children:[(0,R.jsx)(`option`,{value:``,children:`Select agent...`}),o.map(e=>(0,R.jsx)(`option`,{value:e.id,children:A(e)},e.id))]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`To`}),(0,R.jsx)(F,{value:t.to,onChange:e=>c({to:e.target.value}),placeholder:`agent-id, tag:name, cap:name, or broadcast`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Subject`}),(0,R.jsx)(F,{value:t.subject,onChange:e=>c({subject:e.target.value}),placeholder:`Optional subject...`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Channel`}),(0,R.jsx)(F,{value:t.channel,onChange:e=>c({channel:e.target.value}),placeholder:`Optional channel...`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Message`}),(0,R.jsx)(Ku,{value:t.body,onChange:e=>c({body:e.target.value}),rows:4,placeholder:`Message body...`,autoFocus:!0})]}),(0,R.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(Mc,{checked:t.claimable,onCheckedChange:e=>c({claimable:e})}),(0,R.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Claimable task`})]})]}),(0,R.jsxs)(Wu,{children:[(0,R.jsx)(P,{variant:`outline`,onClick:s,children:`Cancel`}),(0,R.jsx)(P,{onClick:i,children:`Send`})]})]})})}function Ju(){let e=k(e=>e.confirmModal),t=k(e=>e.set);function n(){t({confirmModal:{show:!1,title:``,message:``,action:null}})}return(0,R.jsx)(zu,{open:e.show,onOpenChange:e=>!e&&n(),children:(0,R.jsxs)(Hu,{className:`sm:max-w-sm`,children:[(0,R.jsxs)(Uu,{children:[(0,R.jsx)(Gu,{children:e.title}),(0,R.jsx)(X,{children:e.message})]}),(0,R.jsxs)(Wu,{children:[(0,R.jsx)(P,{variant:`outline`,onClick:n,children:`Cancel`}),(0,R.jsx)(P,{variant:`destructive`,onClick:()=>{e.action?.(),n()},children:`Confirm`})]})]})})}function Yu(){let e=k(e=>e.errorModal),t=k(e=>e.set);function n(){t({errorModal:{show:!1,title:``,message:``}})}return(0,R.jsx)(zu,{open:e.show,onOpenChange:e=>!e&&n(),children:(0,R.jsxs)(Hu,{className:`sm:max-w-sm`,children:[(0,R.jsxs)(Uu,{children:[(0,R.jsx)(Gu,{children:e.title}),(0,R.jsx)(X,{children:e.message})]}),(0,R.jsx)(Wu,{children:(0,R.jsx)(P,{onClick:n,children:`OK`})})]})})}function Xu(){let e=k(e=>e.renameModal),t=k(e=>e.set),n=k(e=>e.doRename);function r(){t({renameModal:{show:!1,agentId:``,label:``}})}return(0,R.jsx)(zu,{open:e.show,onOpenChange:e=>!e&&r(),children:(0,R.jsxs)(Hu,{className:`sm:max-w-sm`,children:[(0,R.jsx)(Uu,{children:(0,R.jsx)(Gu,{children:`Rename Agent`})}),(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsx)(Z,{children:`Label`}),(0,R.jsx)(F,{value:e.label,onChange:n=>t({renameModal:{...e,label:n.target.value}}),onKeyDown:e=>e.key===`Enter`&&n(),placeholder:`Human-friendly name...`,autoFocus:!0}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Leave empty to clear the label.`})]}),(0,R.jsxs)(Wu,{children:[(0,R.jsx)(P,{variant:`outline`,onClick:r,children:`Cancel`}),(0,R.jsx)(P,{onClick:n,children:`Save`})]})]})})}function Zu(){let e=k(e=>e.pairInviteOpen),t=k(e=>e.pairInvite),n=k(e=>e.set),r=k(e=>e.closePairInvite),i=k(e=>e.doCreatePair),a=Ec();function o(e){n({pairInvite:{...t,...e}})}return(0,R.jsx)(zu,{open:e,onOpenChange:e=>!e&&r(),children:(0,R.jsxs)(Hu,{className:`sm:max-w-sm`,children:[(0,R.jsx)(Uu,{children:(0,R.jsx)(Gu,{children:`Pair Agents`})}),(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Requester`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:t.requesterId,onChange:e=>o({requesterId:e.target.value}),children:[(0,R.jsx)(`option`,{value:``,children:`Select agent...`}),a.map(e=>(0,R.jsx)(`option`,{value:e.id,children:A(e)},e.id))]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Target`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:t.targetId,onChange:e=>o({targetId:e.target.value}),children:[(0,R.jsx)(`option`,{value:``,children:`Select agent...`}),a.map(e=>(0,R.jsx)(`option`,{value:e.id,children:A(e)},e.id))]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Objective`}),(0,R.jsx)(F,{value:t.objective,onChange:e=>o({objective:e.target.value}),placeholder:`What should they work on?`})]})]}),(0,R.jsxs)(Wu,{children:[(0,R.jsx)(P,{variant:`outline`,onClick:r,children:`Cancel`}),(0,R.jsx)(P,{onClick:i,children:`Create Pair`})]})]})})}function Qu(){let e=k(e=>e.pairMessageOpen),t=k(e=>e.pairMessage),n=k(e=>e.set),r=k(e=>e.closePairMessage),i=k(e=>e.doSendPairMessage);function a(e){n({pairMessage:{...t,...e}})}return(0,R.jsx)(zu,{open:e,onOpenChange:e=>!e&&r(),children:(0,R.jsxs)(Hu,{className:`sm:max-w-sm`,children:[(0,R.jsx)(Uu,{children:(0,R.jsx)(Gu,{children:`Pair Message`})}),(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Subject`}),(0,R.jsx)(F,{value:t.subject,onChange:e=>a({subject:e.target.value}),placeholder:`Optional subject...`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Message`}),(0,R.jsx)(Ku,{value:t.body,onChange:e=>a({body:e.target.value}),rows:4,placeholder:`Message body...`,autoFocus:!0})]})]}),(0,R.jsxs)(Wu,{children:[(0,R.jsx)(P,{variant:`outline`,onClick:r,children:`Cancel`}),(0,R.jsx)(P,{onClick:i,children:`Send`})]})]})})}var $u=(0,L.lazy)(()=>I(()=>import(`./formatted-body-impl-DOXH7oDF.js`).then(e=>({default:e.FormattedBody})),__vite__mapDeps([14,1,5,3,6,9]),import.meta.url));function ed(e){return(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(`span`,{className:e.className,children:e.text}),children:(0,R.jsx)($u,{...e})})}function td(){let e=k(e=>e.threadOpen),t=k(e=>e.threadMessages),n=k(e=>e.agentsById),r=st(),i=k(e=>e.set);return(0,R.jsx)(zu,{open:e,onOpenChange:e=>!e&&i({threadOpen:!1}),children:(0,R.jsxs)(Hu,{className:`max-w-2xl max-h-[80vh]`,children:[(0,R.jsx)(Uu,{children:(0,R.jsxs)(Gu,{children:[`Thread (`,t.length,` messages)`]})}),(0,R.jsx)(Pu,{className:`max-h-[60vh]`,children:(0,R.jsx)(`div`,{className:`space-y-3 pr-4`,children:t.map(e=>(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-3 space-y-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:kt(e.from,n)}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:kt(e.to,n)}),(0,R.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:yt(r,e.createdAt)})]}),e.subject&&(0,R.jsx)(`div`,{className:`text-sm font-medium`,children:e.subject}),(0,R.jsx)(ed,{text:dt(e),rawBody:e.body,className:`text-sm text-muted-foreground`}),(0,R.jsxs)(`div`,{className:`flex gap-1.5 flex-wrap`,children:[e.channel&&(0,R.jsx)(N,{variant:`secondary`,className:`text-[10px]`,children:e.channel}),e.claimedBy&&(0,R.jsxs)(N,{variant:`secondary`,className:`text-[10px]`,children:[`claimed by `,kt(e.claimedBy,n)]})]})]},e.id))})})]})})}function nd(){let e=k(e=>e.taskEventsOpen),t=k(e=>e.taskEvents),n=k(e=>e.set),r=k(e=>e.switchView);function i(e){n({selectedMemoryId:e,taskEventsOpen:!1}),r(`memory`)}return(0,R.jsx)(zu,{open:e,onOpenChange:e=>!e&&n({taskEventsOpen:!1}),children:(0,R.jsxs)(Hu,{className:`max-w-2xl max-h-[80vh]`,children:[(0,R.jsx)(Uu,{children:(0,R.jsxs)(Gu,{children:[`Task Events (`,t.length,`)`]})}),(0,R.jsx)(Pu,{className:`max-h-[60vh]`,children:(0,R.jsxs)(`div`,{className:`space-y-2 pr-4`,children:[t.map(e=>(0,R.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-border p-3`,children:[(0,R.jsx)(N,{className:Nt[e.severity]||Nt.info,children:e.severity}),(0,R.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium`,children:e.title}),(0,R.jsx)(N,{variant:`outline`,className:`text-[10px]`,children:e.type})]}),e.body&&(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 whitespace-pre-wrap`,children:e.body}),(0,R.jsx)(rd,{event:e,onOpen:i}),(0,R.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[At(e.createdAt),` · `,e.source]})]})]},e.id)),t.length===0&&(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-8`,children:`No events recorded.`})]})})]})})}function rd({event:e,onOpen:t}){if(e.type!==`memory.captured`)return null;let n=typeof e.metadata?.memoryId==`string`?e.metadata.memoryId:``,r=e.metadata?.memory&&typeof e.metadata.memory==`object`&&!Array.isArray(e.metadata.memory)?e.metadata.memory:{},i=typeof r.title==`string`?r.title:e.body||n,a=typeof r.scope==`string`?r.scope:``,o=typeof r.type==`string`?r.type:`memory`,s=typeof r.sensitivity==`string`?r.sensitivity:``;return(0,R.jsx)(`div`,{className:`mt-2 rounded-md border border-border bg-muted/20 p-2 text-xs`,children:(0,R.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(pe,{className:`w-3.5 h-3.5 mt-0.5 text-muted-foreground shrink-0`}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[(0,R.jsx)(N,{variant:`secondary`,className:`text-[10px]`,children:o}),a&&(0,R.jsx)(N,{variant:`outline`,className:`text-[10px] font-mono`,children:a}),s&&(0,R.jsx)(N,{variant:`outline`,className:`text-[10px]`,children:s})]}),(0,R.jsx)(`div`,{className:`font-medium truncate`,children:i}),n&&(0,R.jsx)(`div`,{className:`font-mono text-[10px] text-muted-foreground truncate`,children:n})]}),n&&(0,R.jsx)(P,{size:`sm`,variant:`outline`,className:`h-7 text-xs shrink-0`,onClick:()=>t(n),children:`Open`})]})})}function id({open:e,onOpenChange:t,onSelect:n,orchestratorId:r,initialPath:i,title:a=`Select Directory`}){let o=k(e=>e.apiCall),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(null),[d,f]=(0,L.useState)(null),[p,m]=(0,L.useState)(!1),[h,g]=(0,L.useState)(``),[_,v]=(0,L.useState)(null),y=l?.path||i||``,b=(0,L.useMemo)(()=>y.split(`/`).filter(Boolean),[y]),x=(0,L.useCallback)(async e=>{if(r){c(!0),f(null),m(!1);try{let t=e?`?path=${encodeURIComponent(e)}`:``;u(await o(`GET`,`/orchestrators/${encodeURIComponent(r)}/directories${t}`))}catch(e){f(Ct(e))}finally{c(!1)}}},[r,o]);(0,L.useEffect)(()=>{e&&r&&(u(null),f(null),m(!1),x(i||void 0))},[e,r]);async function S(){if(!(!h.trim()||!l)){v(null);try{u(await o(`POST`,`/orchestrators/${encodeURIComponent(r)}/directories`,{path:l.path,name:h.trim()})),m(!1),g(``)}catch(e){v(Ct(e))}}}function ee(){y&&(n(y),t(!1))}function C(e){x(`/`+b.slice(0,e+1).join(`/`))}return(0,R.jsx)(zu,{open:e,onOpenChange:t,children:(0,R.jsxs)(Hu,{className:`max-w-lg max-h-[85dvh] flex flex-col`,children:[(0,R.jsx)(Uu,{children:(0,R.jsxs)(Gu,{className:`flex items-center gap-2`,children:[(0,R.jsx)(je,{className:`h-4 w-4`}),a]})}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-muted/50 px-2 py-1.5 text-xs overflow-x-auto`,children:[(0,R.jsx)(`button`,{type:`button`,className:`font-mono text-muted-foreground hover:text-foreground shrink-0`,onClick:()=>l?.baseDir&&x(l.baseDir),children:`/`}),b.map((e,t)=>(0,R.jsxs)(`span`,{className:`shrink-0`,children:[(0,R.jsx)(`button`,{type:`button`,className:`font-mono text-muted-foreground hover:text-foreground`,onClick:()=>C(t),children:e}),t<b.length-1&&(0,R.jsx)(`span`,{className:`text-muted-foreground/50 mx-0.5`,children:`/`})]},`${e}-${t}`))]}),(0,R.jsxs)(`div`,{className:`flex-1 min-h-0 rounded-md border border-border bg-background overflow-y-auto`,style:{maxHeight:`40dvh`},children:[s&&(0,R.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,R.jsx)(Be,{className:`h-5 w-5 animate-spin text-muted-foreground`})}),!s&&d&&(0,R.jsx)(`div`,{className:`px-3 py-4 text-sm text-destructive`,children:d}),!s&&l&&(0,R.jsxs)(`div`,{className:`p-1`,children:[l.parent&&(0,R.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm hover:bg-muted`,onClick:()=>x(l.parent),children:[(0,R.jsx)(T,{className:`h-4 w-4 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`..`})]}),l.entries.map(e=>(0,R.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm hover:bg-muted`,onClick:()=>x(e.path),children:[(0,R.jsx)(ae,{className:`h-4 w-4 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)),l.entries.length===0&&!l.parent&&(0,R.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground text-center`,children:`Empty directory`}),l.entries.length===0&&l.parent&&(0,R.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground text-center`,children:`No subdirectories`})]})]}),p?(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(F,{autoFocus:!0,value:h,onChange:e=>{g(e.target.value),v(null)},onKeyDown:e=>{e.key===`Enter`&&S(),e.key===`Escape`&&(m(!1),g(``))},placeholder:`New directory name...`,className:`flex-1 font-mono text-sm`}),(0,R.jsx)(P,{type:`button`,size:`icon`,variant:`outline`,onClick:S,disabled:!h.trim(),children:(0,R.jsx)(Ne,{className:`h-4 w-4`})}),(0,R.jsx)(P,{type:`button`,size:`icon`,variant:`ghost`,onClick:()=>{m(!1),g(``),v(null)},children:(0,R.jsx)(Ee,{className:`h-4 w-4`})})]}):(0,R.jsxs)(P,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>m(!0),disabled:!l||s,children:[(0,R.jsx)(te,{className:`h-4 w-4 mr-1.5`}),`New Directory`]}),_&&(0,R.jsx)(`p`,{className:`text-xs text-destructive`,children:_}),(0,R.jsxs)(Wu,{children:[(0,R.jsx)(P,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,R.jsx)(P,{onClick:ee,disabled:!y,children:`Select`})]})]})})}function ad({value:e,onChange:t,orchestratorId:n,placeholder:r,disabled:i}){let[a,o]=(0,L.useState)(!1);return(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(F,{value:e,onChange:e=>t(e.target.value),placeholder:r,disabled:i,className:`flex-1 font-mono text-sm`}),(0,R.jsx)(P,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>o(!0),disabled:i||!n,title:`Browse directories`,children:(0,R.jsx)(je,{className:`h-4 w-4`})}),n&&(0,R.jsx)(id,{open:a,onOpenChange:o,onSelect:t,orchestratorId:n,initialPath:e||void 0})]})}function od({model:e}){if(!e)return null;let t=sd(e);return t.length===0?null:(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>(0,R.jsxs)(N,{variant:`outline`,className:`gap-1 text-[10px]`,children:[(0,R.jsx)(e.Icon,{className:`h-3 w-3`}),e.label]},e.label))})}function sd(e){let t=[],n=e.limits?.contextWindowTokens?.value;return n&&t.push({label:cd(n),Icon:v}),e.capabilities?.modalities.input.image&&t.push({label:`Image input`,Icon:E}),(e.capabilities?.modalities.output.image||e.capabilities?.tools?.imageGeneration)&&t.push({label:`Image output`,Icon:E}),e.capabilities?.tools?.code&&t.push({label:`Code`,Icon:h}),t}function cd(e){return e>=1e6?`${e/1e6}M ctx`:e>=1e3?`${Math.round(e/1e3)}K ctx`:`${e} ctx`}function ld(){let e=k(e=>e.orchestratorSpawnOpen),t=k(e=>e.orchestrators),n=k(e=>e.spawnOrchId),r=k(e=>e.spawnProvider),i=k(e=>e.spawnModel),a=k(e=>e.spawnEffort),o=k(e=>e.spawnProfile),s=k(e=>e.spawnCwd),c=k(e=>e.spawnLabel),l=k(e=>e.spawnApproval),u=k(e=>e.spawnWorkspaceMode),d=k(e=>e.spawnPrompt),f=k(e=>e.spawnSystemPromptAppend),p=k(e=>e.spawnCount),m=k(e=>e.spawnCwdHistory),h=k(e=>e.isSpawning),g=k(e=>!!e.pendingForkImport),_=k(e=>e.set),v=k(e=>e.submitOrchestratorSpawn),y=k(e=>e.selectSpawnHistory),b=k(e=>e.agentProfiles),x=t.find(e=>e.id===n),S=x?.providers||[],ee=ot[r]?.models||[],te=ee.find(e=>e.alias===i),C=te?.efforts||[],ne=!!(x&&S.length>0&&s.trim())&&!h,re=t.filter(e=>e.status===`online`),ie=re.length>1,ae=m.filter(e=>re.some(t=>t.id===e.orchId)).slice(0,5);function oe(e){let n=t.find(t=>t.id===e),r=n?.providers[0]||``;_({spawnOrchId:e,spawnProvider:r,spawnModel:r&&ot[r]?.defaultModel||``,spawnEffort:``,spawnCwd:n?.baseDir||``})}function se(e){_({spawnProvider:e,spawnModel:ot[e]?.defaultModel||``,spawnEffort:``})}function ce(e){_({spawnModel:e,spawnEffort:``})}return(0,R.jsx)(zu,{open:e,onOpenChange:e=>!e&&_({orchestratorSpawnOpen:!1}),children:(0,R.jsxs)(Hu,{className:`max-w-lg max-h-[90dvh] flex flex-col`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,R.jsx)(Uu,{children:(0,R.jsx)(Gu,{children:`Spawn Agent`})}),(0,R.jsxs)(`div`,{className:`space-y-3 overflow-y-auto flex-1 min-h-0 -mx-4 px-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Orchestrator`}),(0,R.jsx)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:n,onChange:e=>oe(e.target.value),children:t.filter(e=>e.status===`online`).map(e=>(0,R.jsxs)(`option`,{value:e.id,children:[e.hostname,` (`,e.id.slice(-8),`)`]},e.id))})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Provider`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:r,onChange:e=>se(e.target.value),disabled:!S.length,children:[!S.length&&(0,R.jsx)(`option`,{value:r,children:`No providers available`}),S.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Model`}),(0,R.jsx)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:i,onChange:e=>ce(e.target.value),disabled:!ee.length,children:ee.map(e=>(0,R.jsx)(`option`,{value:e.alias,children:e.label},e.alias))})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Effort`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:a,onChange:e=>_({spawnEffort:e.target.value}),disabled:!C.length,children:[(0,R.jsx)(`option`,{value:``,children:`Default`}),C.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,R.jsx)(od,{model:te}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Agent Profile`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:o||`default-relay`,onChange:e=>_({spawnProfile:e.target.value}),children:[!b.length&&(0,R.jsx)(`option`,{value:`default-relay`,children:`default-relay`}),b.map(e=>(0,R.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Approval Mode`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:l,onChange:e=>_({spawnApproval:e.target.value}),children:[(0,R.jsx)(`option`,{value:`open`,children:`Open`}),(0,R.jsx)(`option`,{value:`guarded`,children:`Guarded`}),(0,R.jsx)(`option`,{value:`read-only`,children:`Read-only`})]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Workspace`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:u,onChange:e=>_({spawnWorkspaceMode:e.target.value}),children:[(0,R.jsx)(`option`,{value:`inherit`,children:`Default`}),(0,R.jsx)(`option`,{value:`isolated`,children:`Isolated worktree`}),(0,R.jsx)(`option`,{value:`shared`,children:`Shared cwd`})]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Working Directory`}),(0,R.jsx)(`div`,{className:`mt-1`,children:(0,R.jsx)(ad,{value:s,onChange:e=>_({spawnCwd:e}),orchestratorId:n,placeholder:`Select a project directory`})}),ae.length>0&&(0,R.jsxs)(`div`,{className:`mt-2`,children:[(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mb-1`,children:`Recent`}),(0,R.jsx)(`div`,{className:`flex gap-1.5 overflow-x-auto pb-1 sm:flex-wrap sm:overflow-x-visible sm:pb-0`,children:ae.map(e=>{let t=e.cwd.replace(/\/+$/,``).split(`/`).pop()||e.cwd,r=re.find(t=>t.id===e.orchId)?.hostname,i=e.orchId===n&&e.cwd===s;return(0,R.jsx)(`button`,{type:`button`,title:ie&&r?`${r}: ${e.cwd}`:e.cwd,onClick:()=>y(e.orchId,e.cwd),className:`shrink-0 rounded-full border px-2.5 py-1 text-xs font-mono transition-colors ${i?`border-primary bg-primary/10 text-foreground`:`border-input bg-background text-muted-foreground hover:bg-accent hover:text-foreground`}`,children:ie&&r?`${r}: ${t}`:t},`${e.orchId}:${e.cwd}`)})})]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Label`}),(0,R.jsx)(F,{value:c,onChange:e=>_({spawnLabel:e.target.value}),placeholder:`Optional label...`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Initial Prompt`}),(0,R.jsx)(Ku,{value:d,onChange:e=>_({spawnPrompt:e.target.value}),rows:3,placeholder:`Optional initial task...`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Codex starts this as the first App Server turn; Claude receives it as a launch prompt.`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`System Prompt Append`}),(0,R.jsx)(Ku,{value:f,onChange:e=>_({spawnSystemPromptAppend:e.target.value}),rows:5,placeholder:`Optional launch context...`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Use for fork history or launch context. It informs the session but does not start work by itself.`})]}),!g&&(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsx)(Z,{children:`Number of Agents`}),(0,R.jsx)(`span`,{className:`text-sm font-mono tabular-nums text-muted-foreground`,children:p})]}),(0,R.jsx)(`input`,{type:`range`,min:1,max:10,step:1,value:p,onChange:e=>_({spawnCount:Number(e.target.value)}),className:`w-full mt-2 accent-primary`,"aria-label":`Number of agents to spawn`}),p>1&&(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[`Spawns `,p,` identical agents`,c.trim()?`, labelled "${c.trim()} 1"…"${c.trim()} ${p}"`:``,`.`]})]})]}),(0,R.jsxs)(Wu,{children:[(0,R.jsx)(P,{variant:`outline`,onClick:()=>_({orchestratorSpawnOpen:!1}),disabled:h,children:`Cancel`}),(0,R.jsx)(P,{onClick:v,disabled:!ne,children:h?`Spawning…`:S.length?p>1?`Spawn ${p}`:`Spawn`:`No providers`})]})]})})}function ud(){return`host-${Math.random().toString(36).slice(2,8)}`}function dd(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function fd(){let e=k(e=>e.orchestratorInstallOpen),t=k(e=>e.set),n=k(e=>e.showError),r=k(e=>e.showNotification),i=(0,L.useMemo)(()=>new URL(se()).origin,[]),[a,o]=(0,L.useState)(ud),[s,c]=(0,L.useState)(`$HOME/projects`),[l,u]=(0,L.useState)([`claude`,`codex`]),[d,f]=(0,L.useState)(`4860`),[m,h]=(0,L.useState)(``),[g,_]=(0,L.useState)(``),[v,y]=(0,L.useState)(),[b,x]=(0,L.useState)(!1);async function S(){if(!a.trim()){n(`Validation`,`Orchestrator id is required`);return}if(!s.trim()){n(`Validation`,`Base directory is required`);return}if(!l.length){n(`Validation`,`Select at least one provider`);return}x(!0);try{let e=await p(`POST`,`/orchestrators/bootstrap`,{id:a.trim(),relayUrl:i,baseDir:s.trim(),providers:l,apiPort:Number(d)||4860,pathPrefix:m.split(`:`).map(e=>e.trim()).filter(Boolean)});_(e.command),y(e.expiresAt)}catch(e){n(`Install Command Failed`,e.message)}finally{x(!1)}}return(0,R.jsx)(zu,{open:e,onOpenChange:e=>!e&&t({orchestratorInstallOpen:!1}),children:(0,R.jsxs)(Hu,{className:`max-w-2xl overflow-hidden`,children:[(0,R.jsx)(Uu,{children:(0,R.jsxs)(Gu,{className:`flex items-center gap-2`,children:[(0,R.jsx)(ie,{className:`w-4 h-4`}),`Add Orchestrator`]})}),(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Orchestrator ID`}),(0,R.jsx)(F,{value:a,onChange:e=>o(e.target.value)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Relay URL`}),(0,R.jsx)(F,{value:i,readOnly:!0})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Base Directory`}),(0,R.jsx)(F,{value:s,onChange:e=>c(e.target.value)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`API Port`}),(0,R.jsx)(F,{value:d,onChange:e=>f(e.target.value),inputMode:`numeric`})]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Providers`}),(0,R.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-2`,children:[`claude`,`codex`].map(e=>(0,R.jsx)(P,{type:`button`,size:`sm`,variant:l.includes(e)?`default`:`outline`,onClick:()=>u(dd(l,e)),children:e},e))})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Extra PATH Prefix`}),(0,R.jsx)(F,{value:m,onChange:e=>h(e.target.value),placeholder:`/opt/homebrew/bin:/custom/bin`})]}),g&&(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,R.jsx)(Z,{children:`Install Command`}),v&&(0,R.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`Install token expires `,new Date(v*1e3).toLocaleString()]})]}),(0,R.jsx)(`pre`,{className:`max-h-40 w-full overflow-y-auto whitespace-pre-wrap break-all rounded-md border border-input bg-muted/40 p-3 font-mono text-xs leading-relaxed`,children:g})]})]}),(0,R.jsxs)(Wu,{children:[(0,R.jsx)(P,{variant:`outline`,onClick:()=>t({orchestratorInstallOpen:!1}),children:`Close`}),g&&(0,R.jsx)(Tn,{value:g,label:`Copy`,showText:!0,size:`default`,variant:`outline`,className:`gap-1`,onCopied:()=>r(`Install command copied`)}),(0,R.jsxs)(P,{className:`gap-1`,onClick:S,disabled:b,children:[(0,R.jsx)(Ce,{className:`w-3.5 h-3.5`}),b?`Generating...`:`Generate Command`]})]})]})})}function pd(){let e=k(e=>e.policyModal),t=k(e=>e.orchestrators),n=k(e=>e.agentProfiles),r=k(e=>e.set),i=k(e=>e.submitPolicy),a=t.find(t=>t.id===e.orchestratorId),o=a?.providers||[],s=ot[e.provider]?.models||[],c=s.find(t=>t.alias===e.model),l=c?.efforts||[],u=!!e.editing,d=e.provider===`claude`&&a?.providerStatus?.find(e=>e.name===`claude`)?.features?.rig===!0;function f(t){r({policyModal:{...e,...t}})}function p(n){let r=t.find(e=>e.id===n)?.providers[0]||e.provider;f({orchestratorId:n,provider:r,model:ot[r]?.defaultModel||``,effort:``})}function m(e){f({provider:e,rig:``,model:ot[e]?.defaultModel||``,effort:``})}return(0,R.jsx)(zu,{open:e.open,onOpenChange:e=>!e&&f({open:!1}),children:(0,R.jsxs)(Hu,{className:`max-w-lg max-h-[90vh] overflow-y-auto`,children:[(0,R.jsx)(Uu,{children:(0,R.jsx)(Gu,{children:u?`Edit Policy`:`Create Managed Agent`})}),(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Policy Name`}),(0,R.jsx)(F,{value:e.name,onChange:e=>f({name:e.target.value}),placeholder:`my-agent`,disabled:u})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Label`}),(0,R.jsx)(F,{value:e.label,onChange:e=>f({label:e.target.value}),placeholder:`Human-friendly name...`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Description`}),(0,R.jsx)(F,{value:e.description,onChange:e=>f({description:e.target.value}),placeholder:`What does this agent do?`})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Orchestrator`}),(0,R.jsx)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.orchestratorId,onChange:e=>p(e.target.value),children:t.filter(e=>e.status===`online`).map(e=>(0,R.jsxs)(`option`,{value:e.id,children:[e.hostname,` (`,e.id.slice(-8),`)`]},e.id))})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Provider`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.provider,onChange:e=>m(e.target.value),disabled:!o.length,children:[!o.length&&(0,R.jsx)(`option`,{value:e.provider,children:`No providers available`}),o.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})]})]}),d&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Rig`}),(0,R.jsx)(F,{value:e.rig,onChange:e=>f({rig:e.target.value}),placeholder:`Leave empty to auto-detect from .claude-rig`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`claude-rig profile name. Auto-detects from project's .claude-rig file if empty.`})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Model`}),(0,R.jsx)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.model,onChange:e=>f({model:e.target.value,effort:``}),children:s.map(e=>(0,R.jsx)(`option`,{value:e.alias,children:e.label},e.alias))})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Effort`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.effort,onChange:e=>f({effort:e.target.value}),disabled:!l.length,children:[(0,R.jsx)(`option`,{value:``,children:`Default`}),l.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,R.jsx)(od,{model:c}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Agent Profile`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.profile||`default-relay`,onChange:e=>f({profile:e.target.value}),children:[!n.length&&(0,R.jsx)(`option`,{value:`default-relay`,children:`default-relay`}),n.map(e=>(0,R.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Working Directory`}),(0,R.jsx)(`div`,{className:`mt-1`,children:(0,R.jsx)(ad,{value:e.cwd,onChange:e=>f({cwd:e}),orchestratorId:e.orchestratorId,placeholder:a?.baseDir||`/path/to/project`})})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Mode`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.mode,onChange:e=>f({mode:e.target.value}),children:[(0,R.jsx)(`option`,{value:`always-on`,children:`Always On`}),(0,R.jsx)(`option`,{value:`on-demand`,children:`On Demand`})]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Permission Mode`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.permissionMode,onChange:e=>f({permissionMode:e.target.value}),children:[(0,R.jsx)(`option`,{value:`open`,children:`Open`}),(0,R.jsx)(`option`,{value:`guarded`,children:`Guarded`}),(0,R.jsx)(`option`,{value:`read-only`,children:`Read-only`})]})]})]}),e.mode===`on-demand`&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Keepalive (seconds)`}),(0,R.jsx)(F,{type:`number`,value:e.keepaliveSeconds,onChange:e=>f({keepaliveSeconds:e.target.value}),placeholder:`300`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Seconds to keep agent alive after last activity.`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Initial Prompt`}),(0,R.jsx)(Ku,{value:e.prompt,onChange:e=>f({prompt:e.target.value}),rows:3,placeholder:`Optional initial task or instructions...`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Codex starts this as the first App Server turn; Claude receives it as a launch prompt.`})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Tags`}),(0,R.jsx)(F,{value:e.tags,onChange:e=>f({tags:e.target.value}),placeholder:`tag1, tag2`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Capabilities`}),(0,R.jsx)(F,{value:e.capabilities,onChange:e=>f({capabilities:e.target.value}),placeholder:`chat, review`})]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Provider Args`}),(0,R.jsx)(F,{value:e.providerArgs,onChange:e=>f({providerArgs:e.target.value}),placeholder:`--flag value`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Space-separated args passed to the provider CLI.`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Channel Binding`}),(0,R.jsx)(F,{value:e.channelId,onChange:e=>f({channelId:e.target.value}),placeholder:`Channel ID (optional)`})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Backoff Schedule (seconds)`}),(0,R.jsx)(F,{value:e.backoffSchedule,onChange:e=>f({backoffSchedule:e.target.value}),placeholder:`5, 15, 60, 300`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Backoff Reset After (s)`}),(0,R.jsx)(F,{type:`number`,value:e.backoffResetAfterSeconds,onChange:e=>f({backoffResetAfterSeconds:e.target.value}),placeholder:`600`})]})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsx)(Z,{htmlFor:`restartOnUpdate`,children:`Restart on policy update`}),(0,R.jsx)(Mc,{id:`restartOnUpdate`,checked:e.restartOnUpdate,onCheckedChange:e=>f({restartOnUpdate:e})})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsx)(Z,{htmlFor:`dailyRestart`,children:`Scheduled daily restart`}),(0,R.jsx)(Mc,{id:`dailyRestart`,checked:e.scheduledDailyRestart,onCheckedChange:e=>f({scheduledDailyRestart:e})})]})]}),(0,R.jsxs)(Wu,{children:[(0,R.jsx)(P,{variant:`outline`,onClick:()=>f({open:!1}),children:`Cancel`}),(0,R.jsx)(P,{onClick:i,children:u?`Save`:`Create`})]})]})})}function md({title:e,children:t,defaultOpen:n=!0}){let[r,i]=(0,L.useState)(n);return(0,R.jsxs)(`div`,{className:`border border-border rounded-md`,children:[(0,R.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-sm font-medium hover:bg-accent`,onClick:()=>i(!r),children:[r?(0,R.jsx)(_e,{className:`h-3.5 w-3.5`}):(0,R.jsx)(ze,{className:`h-3.5 w-3.5`}),e]}),r&&(0,R.jsx)(`div`,{className:`space-y-3 border-t border-border px-3 py-3`,children:t})]})}function hd({value:e,onChange:t,options:n,disabled:r}){return(0,R.jsx)(`select`,{className:`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e,onChange:e=>t(e.target.value),disabled:r,children:n.map(e=>(0,R.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function gd({env:e,onChange:t,disabled:n}){let r=Object.entries(e),[i,a]=(0,L.useState)(``),[o,s]=(0,L.useState)(``);function c(){i.trim()&&(t({...e,[i.trim()]:o}),a(``),s(``))}function l(n){let r={...e};delete r[n],t(r)}return(0,R.jsxs)(`div`,{className:`space-y-1.5`,children:[r.map(([e,t])=>(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsxs)(`code`,{className:`min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 text-xs`,children:[e,`=`,t]}),!n&&(0,R.jsx)(P,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-6 w-6 shrink-0`,onClick:()=>l(e),children:(0,R.jsx)(Fe,{className:`h-3 w-3`})})]},e)),!n&&(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(F,{value:i,onChange:e=>a(e.target.value),placeholder:`KEY`,className:`flex-1 text-xs font-mono`}),(0,R.jsx)(F,{value:o,onChange:e=>s(e.target.value),placeholder:`value`,className:`flex-1 text-xs font-mono`,onKeyDown:e=>e.key===`Enter`&&c()}),(0,R.jsx)(P,{type:`button`,variant:`outline`,size:`icon-sm`,className:`h-8 w-8 shrink-0`,onClick:c,children:(0,R.jsx)(_,{className:`h-3 w-3`})})]}),r.length===0&&n&&(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No environment variables`})]})}var _d=[{value:`host`,label:`Host — full access, relay-aware`},{value:`minimal`,label:`Minimal — relay disabled, repo-scoped`},{value:`isolated`,label:`Isolated — strict isolation`}],vd=[{value:`any`,label:`Any provider`},{value:`claude`,label:`Claude`},{value:`codex`,label:`Codex`}],yd=[{value:`host`,label:`Host — use host config`},{value:`profile`,label:`Profile — use profile config`},{value:`repo`,label:`Repo — use repo config only`},{value:`none`,label:`None — disabled`}],Q=[{value:`host`,label:`Host — full filesystem`},{value:`workspace`,label:`Workspace — working directory tree`},{value:`repo`,label:`Repo — repository root only`}],bd=[{value:`allow`,label:`Allow`},{value:`ignore`,label:`Ignore`}],xd=[{value:``,label:`Default`},{value:`open`,label:`Open — allow all`},{value:`guarded`,label:`Guarded — prompt for risky`},{value:`read-only`,label:`Read-only`}];function Sd(){let{open:e,mode:t,profile:n}=k(e=>e.profileModal),r=k(e=>e.closeProfileModal),i=k(e=>e.updateProfileModal),a=k(e=>e.saveProfile),o=t===`view`||n.builtIn===!0,s=t===`create`||t===`duplicate`,c=t===`view`?`Profile: ${n.name}`:t===`edit`?`Edit: ${n.name}`:t===`duplicate`?`Duplicate Profile`:`Create Profile`;function l(e){i({instructions:{...n.instructions,...e}})}function u(e){i({relay:{...n.relay,...e}})}function d(e){i({permissions:{...n.permissions,...e}})}function f(e){let t=n.providerOptions||{},r={...t.codex&&typeof t.codex==`object`&&!Array.isArray(t.codex)?t.codex:{}};if(!e.trim())delete r.toolOutputTokenLimit;else{let t=Number(e);if(!Number.isSafeInteger(t))return;r.toolOutputTokenLimit=t}i({providerOptions:{...t,codex:r}})}function p(e){if(!e.trim()){i({maxSpawnedAgents:void 0});return}let t=Number(e);!Number.isInteger(t)||t<0||i({maxSpawnedAgents:Math.min(t,100)})}function m(e){let t=e===`host`;i({base:e,relay:{context:t,skills:t,plugins:t,statusLine:t,mcp:t},mcp:{...n.mcp,mode:t?`host`:`none`},hooks:{mode:t?`host`:`none`},permissions:{...n.permissions,filesystem:t?`host`:`repo`},instructions:{...n.instructions,globalInstructions:t?`allow`:`ignore`}})}let h=n.providerOptions?.codex&&typeof n.providerOptions.codex==`object`&&!Array.isArray(n.providerOptions.codex)?n.providerOptions.codex:{},g=Number.isSafeInteger(h.toolOutputTokenLimit)?String(h.toolOutputTokenLimit):``;return(0,R.jsx)(zu,{open:e,onOpenChange:e=>!e&&r(),children:(0,R.jsxs)(Hu,{className:`max-w-lg max-h-[90vh] overflow-y-auto`,children:[(0,R.jsx)(Uu,{children:(0,R.jsxs)(Gu,{className:`flex items-center gap-2`,children:[c,n.builtIn&&(0,R.jsx)(N,{variant:`secondary`,className:`text-[10px]`,children:`Built-in`})]})}),(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsxs)(md,{title:`General`,defaultOpen:!0,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Name`}),(0,R.jsx)(F,{value:n.name,onChange:e=>i({name:e.target.value}),placeholder:`my-profile`,disabled:o||t===`edit`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Description`}),(0,R.jsx)(F,{value:n.description||``,onChange:e=>i({description:e.target.value}),placeholder:`What this profile configures`,disabled:o})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Base`}),(0,R.jsx)(hd,{value:n.base,onChange:e=>m(e),options:_d,disabled:o})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Provider`}),(0,R.jsx)(hd,{value:n.provider||`any`,onChange:e=>i({provider:e}),options:vd,disabled:o})]})]})]}),(0,R.jsxs)(md,{title:`Instructions`,defaultOpen:!1,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`System Prompt`}),(0,R.jsx)(Ku,{value:n.instructions.system||``,onChange:e=>l({system:e.target.value}),placeholder:`Custom system prompt...`,rows:3,disabled:o,className:`font-mono text-xs`})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Repo Instructions`}),(0,R.jsx)(hd,{value:n.instructions.repoInstructions,onChange:e=>l({repoInstructions:e}),options:bd,disabled:o})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Global Instructions`}),(0,R.jsx)(hd,{value:n.instructions.globalInstructions,onChange:e=>l({globalInstructions:e}),options:bd,disabled:o})]})]})]}),(0,R.jsx)(md,{title:`Relay Integration`,defaultOpen:!1,children:(0,R.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[`context`,`skills`,`plugins`,`statusLine`,`mcp`].map(e=>(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(Z,{className:`capitalize`,children:e===`statusLine`?`Status Line`:e===`mcp`?`MCP Tools`:e}),(0,R.jsx)(Mc,{checked:n.relay[e]??!0,onCheckedChange:t=>u({[e]:t}),disabled:o})]},e))})}),(0,R.jsx)(md,{title:`MCP & Hooks`,defaultOpen:!1,children:(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`MCP Mode`}),(0,R.jsx)(hd,{value:n.mcp.mode,onChange:e=>i({mcp:{...n.mcp,mode:e}}),options:yd,disabled:o})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Hooks Mode`}),(0,R.jsx)(hd,{value:n.hooks.mode,onChange:e=>i({hooks:{mode:e}}),options:yd,disabled:o})]})]})}),(0,R.jsx)(md,{title:`Permissions`,defaultOpen:!1,children:(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Approval Mode`}),(0,R.jsx)(hd,{value:n.permissions.mode||``,onChange:e=>d({mode:e||void 0}),options:xd,disabled:o})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Filesystem Scope`}),(0,R.jsx)(hd,{value:n.permissions.filesystem,onChange:e=>d({filesystem:e}),options:Q,disabled:o})]})]})}),(0,R.jsx)(md,{title:`Spawning`,defaultOpen:!1,children:(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Spawn Quota`}),(0,R.jsx)(F,{type:`number`,min:0,max:100,step:1,value:n.maxSpawnedAgents===void 0?``:String(n.maxSpawnedAgents),onChange:e=>p(e.target.value),placeholder:`0`,disabled:o}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Max concurrent live child agents this profile may spawn. Empty or 0 = cannot spawn (default). Children never inherit it (no grandchildren).`})]})}),(0,R.jsx)(md,{title:`Environment Variables`,defaultOpen:!1,children:(0,R.jsx)(gd,{env:n.env||{},onChange:e=>i({env:e}),disabled:o})}),(0,R.jsxs)(md,{title:`Provider Options`,defaultOpen:!1,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Codex Tool Output Limit`}),(0,R.jsx)(F,{type:`number`,min:1e3,max:2e5,value:g,onChange:e=>f(e.target.value),placeholder:`12000`,disabled:o})]}),(0,R.jsx)(Ku,{value:JSON.stringify(n.providerOptions||{},null,2),onChange:e=>{try{i({providerOptions:JSON.parse(e.target.value)})}catch{}},rows:3,disabled:o,className:`font-mono text-xs`,placeholder:`{}`})]})]}),!o&&(0,R.jsxs)(Wu,{children:[(0,R.jsx)(P,{variant:`outline`,onClick:r,children:`Cancel`}),(0,R.jsx)(P,{onClick:a,children:s?`Create`:`Save`})]})]})})}function Cd(){let e=k(e=>e.commandPaletteOpen),t=k(e=>e.commandQuery),n=k(e=>e.set),r=k(e=>e.closeCommandPalette),i=k(e=>e.runCommand),a=Ac(),o=(0,L.useRef)(null);return(0,L.useEffect)(()=>{e&&setTimeout(()=>o.current?.focus(),50)},[e]),e?(0,R.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,onClick:e=>{e.target===e.currentTarget&&r()},children:[(0,R.jsx)(`div`,{className:`fixed inset-0 bg-black/60`}),(0,R.jsxs)(`div`,{className:`relative w-full max-w-lg bg-card border border-border rounded-xl shadow-2xl overflow-hidden`,children:[(0,R.jsx)(`div`,{className:`p-3 border-b border-border`,children:(0,R.jsx)(F,{ref:o,value:t,onChange:e=>n({commandQuery:e.target.value}),placeholder:`Type a command...`,className:`border-0 bg-transparent focus-visible:ring-0 text-base`})}),(0,R.jsxs)(`div`,{className:`max-h-80 overflow-y-auto p-2`,children:[a.map(e=>(0,R.jsxs)(`button`,{onClick:()=>i(e),className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-lg hover:bg-accent text-left transition-colors`,children:[(0,R.jsx)(Ke[e.icon]||ze,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,R.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,R.jsx)(`div`,{className:`text-sm`,children:e.title}),e.subtitle&&(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:e.subtitle})]})]},e.id)),a.length===0&&(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`No matching commands.`})]})]})]}):null}function wd(){let e=k(e=>e.set),t=k(e=>e.connected);return(0,R.jsxs)(`div`,{className:`xl:hidden sticky top-0 z-30 bg-card border-b border-border px-4 h-[var(--header-h)] flex items-center gap-3`,children:[(0,R.jsx)(`button`,{onClick:()=>e({mobileMenuOpen:!0}),className:`p-1 -ml-1 text-muted-foreground hover:text-foreground transition-colors`,"aria-label":`Open menu`,children:(0,R.jsx)(n,{className:`w-5 h-5`})}),(0,R.jsx)(C,{className:`w-4 h-4 text-primary`}),(0,R.jsx)(`span`,{className:`font-bold text-sm`,children:`Agent Relay`}),(0,R.jsx)(`span`,{className:`ml-auto w-2 h-2 rounded-full ${t?`bg-emerald-500`:`bg-red-500 animate-pulse`}`})]})}var Td=(0,L.lazy)(()=>I(()=>import(`./overview-418xXZO_.js`).then(e=>({default:e.OverviewView})),__vite__mapDeps([15,1,6,8,9,16,11,17]),import.meta.url)),Ed=(0,L.lazy)(()=>I(()=>import(`./chat-BqIaFYGJ.js`).then(e=>({default:e.ChatView})),__vite__mapDeps([18,1,6,19,8,9,20,21,22,23,10,11,16,24,12]),import.meta.url)),Dd=(0,L.lazy)(()=>I(()=>import(`./agents-Cbegv0Hm.js`).then(e=>({default:e.AgentsView})),__vite__mapDeps([25,1,26,27,6,11,28,19,29,30,31,32,33,8,9,22,23,10,16,17]),import.meta.url)),Od=(0,L.lazy)(()=>I(()=>import(`./managed-agents-CzfEznM1.js`).then(e=>({default:e.ManagedAgentsView})),__vite__mapDeps([34,1,6,8,9,10,11]),import.meta.url)),kd=(0,L.lazy)(()=>I(()=>import(`./teams-sCQAs_QA.js`).then(e=>({default:e.TeamsView})),__vite__mapDeps([35,1,36,26,27,6,11,28,19,29,30,37,38,39,31,33,40,8,9,21,16,10,17,24]),import.meta.url)),Ad=(0,L.lazy)(()=>I(()=>import(`./agent-profiles-DW4o5-ND.js`).then(e=>({default:e.AgentProfilesView})),__vite__mapDeps([41,6,1,8,9,16,11,10]),import.meta.url)),jd=(0,L.lazy)(()=>I(()=>import(`./orchestrators-CrcqkPuc.js`).then(e=>({default:e.OrchestratorsView})),__vite__mapDeps([42,6,1,8,9,16,11,10,17]),import.meta.url)),Md=(0,L.lazy)(()=>I(()=>import(`./workspaces-6I-C69nf.js`).then(e=>({default:e.WorkspacesView})),__vite__mapDeps([43,1,6,8,9,23,10,11,16,17]),import.meta.url)),$=(0,L.lazy)(()=>I(()=>import(`./channels-B1MQCPCT.js`).then(e=>({default:e.ChannelsView})),__vite__mapDeps([44,6,1,8,9,16,11,10,17]),import.meta.url)),Nd=(0,L.lazy)(()=>I(()=>import(`./connectors-C9aFJIrh.js`).then(e=>({default:e.ConnectorsView})),__vite__mapDeps([45,6,1,8,9,16,11,10,17]),import.meta.url)),Pd=(0,L.lazy)(()=>I(()=>import(`./integrations-Cm4fjp7_.js`).then(e=>({default:e.IntegrationsView})),__vite__mapDeps([46,6,1,8,9,16,11,10,17]),import.meta.url)),Fd=(0,L.lazy)(()=>I(()=>import(`./security-DS13pbag.js`).then(e=>({default:e.SecurityView})),__vite__mapDeps([47,1,6,23,10,11,16,17,24]),import.meta.url)),Id=(0,L.lazy)(()=>I(()=>import(`./memory-CUUAzJDc.js`).then(e=>({default:e.MemoryView})),__vite__mapDeps([48,1,6,8,9,16,11,10,17,24]),import.meta.url)),Ld=(0,L.lazy)(()=>I(()=>import(`./activity-CRafQ1Je.js`).then(e=>({default:e.ActivityView})),__vite__mapDeps([49,1,6,8,9,20,16,11,10,17]),import.meta.url)),Rd=(0,L.lazy)(()=>I(()=>import(`./pairs-CnedATgT.js`).then(e=>({default:e.PairsView})),__vite__mapDeps([50,6,1,8,9,16,11,10,17]),import.meta.url)),zd=(0,L.lazy)(()=>I(()=>import(`./messages-6QZH46LG.js`).then(e=>({default:e.MessagesView})),__vite__mapDeps([51,1,6,8,9,16,11,10,17]),import.meta.url)),Bd=(0,L.lazy)(()=>I(()=>import(`./work-queue-BDhjlwUH.js`).then(e=>({default:e.WorkQueueView})),__vite__mapDeps([52,6,1,8,9,16,11,10,17]),import.meta.url)),Vd=(0,L.lazy)(()=>I(()=>import(`./tasks-B-4oCPuv.js`).then(e=>({default:e.TasksView})),__vite__mapDeps([53,1,6,8,9,16,11,10,17]),import.meta.url)),Hd=(0,L.lazy)(()=>I(()=>import(`./automation-CzSBv4gg.js`).then(e=>({default:e.AutomationView})),__vite__mapDeps([54,1,6,8,9,16,11,10,17,24]),import.meta.url)),Ud=(0,L.lazy)(()=>I(()=>import(`./analytics-DX6T7JX3.js`).then(e=>({default:e.AnalyticsView})),__vite__mapDeps([55,1,6,8,9,17,56]),import.meta.url)),Wd=(0,L.lazy)(()=>I(()=>import(`./insights-B1edq5lk.js`).then(e=>({default:e.InsightsView})),__vite__mapDeps([57,1,6,16,11,10,17,24,9]),import.meta.url)),Gd=(0,L.lazy)(()=>I(()=>import(`./maintenance-D6zvw0fU.js`).then(e=>({default:e.MaintenanceView})),__vite__mapDeps([58,1,6,8,9,16,11,10]),import.meta.url)),Kd=(0,L.lazy)(()=>I(()=>import(`./settings-BgInn_f3.js`).then(e=>({default:e.SettingsView})),__vite__mapDeps([59,1,36,26,27,6,11,28,19,29,30,37,38,39,31,33,40,8,9,10,24]),import.meta.url)),qd=class extends L.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary]`,e.message,`
19
+ `)}):null,nt?.unavailable?.length?(0,R.jsx)(`div`,{className:`mt-1 text-amber-50/55`,children:nt.unavailable.join(`; `)}):null]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 pt-0.5 text-xs`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Last seen`}),(0,R.jsx)(`div`,{children:yt(c,D.lastSeen)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Created`}),(0,R.jsx)(`div`,{title:At(D.createdAt),children:yt(c,D.createdAt)})]})]})]})]}),D.context&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Nc,{}),(0,R.jsx)(wu,{context:D.context,tokens:Ge,history:ie,now:c})]}),(D.spawnedBy||ot.length>0||Se)&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Nc,{}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Relationships`}),(0,R.jsxs)(`div`,{className:`space-y-2`,children:[D.spawnedBy&&(0,R.jsxs)(`div`,{className:`rounded-md border border-border p-2 text-xs`,children:[(0,R.jsx)(`div`,{className:`mb-1 text-muted-foreground`,children:`Spawned by`}),(0,R.jsx)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded px-1 py-1 text-left hover:bg-muted/50 disabled:pointer-events-none disabled:opacity-60`,disabled:!at,onClick:()=>at&&f(at),children:at?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(q,{agent:at,now:c}),(0,R.jsx)(Hl,{agent:at}),(0,R.jsx)(`span`,{className:`truncate font-medium`,children:A(at)})]}):(0,R.jsx)(`span`,{className:`truncate font-mono`,children:D.spawnedBy})})]}),ot.length>0&&(0,R.jsxs)(`div`,{className:`rounded-md border border-border p-2 text-xs`,children:[(0,R.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Children`}),(0,R.jsx)(N,{variant:`secondary`,className:`h-4 px-1.5 text-[9px]`,children:ot.length})]}),(0,R.jsx)(`div`,{className:`space-y-1`,children:ot.map(e=>(0,R.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded px-1 py-1 text-left hover:bg-muted/50`,onClick:()=>f(e),children:[(0,R.jsx)(q,{agent:e,now:c}),(0,R.jsx)(Hl,{agent:e}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:A(e)}),(0,R.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.status})]},e.id))})]}),D.spawnedBy&&ot.length===0&&(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,R.jsx)(Me,{className:`h-3.5 w-3.5`}),`No live child agents`]}),Se&&(0,R.jsxs)(`div`,{className:`rounded-md border border-border p-2 text-xs`,children:[(0,R.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Pair`}),(0,R.jsx)(N,{className:Se.status===`active`?`bg-emerald-500/20 text-emerald-400`:`bg-yellow-500/20 text-yellow-400`,children:Se.status})]}),Se.objective&&(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:Se.objective})]})]})]})]}),(O||Ke.length>0)&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Nc,{}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Runtime`}),(0,R.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[We&&(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Provider state`}),(0,R.jsx)(`div`,{children:We.state})]}),We.reason&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Reason`}),(0,R.jsx)(`div`,{children:We.reason})]}),We.source&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Source`}),(0,R.jsx)(`div`,{children:We.source})]}),We.updatedAt&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Updated`}),(0,R.jsx)(`div`,{children:yt(c,We.updatedAt)})]})]}),O?.model&&(0,R.jsxs)(`div`,{className:`space-y-1`,children:[O.model.provider&&(0,R.jsxs)(`div`,{className:`flex justify-between gap-2 min-w-0`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Provider`}),(0,R.jsx)(`span`,{className:`truncate`,children:O.model.provider})]}),(O.model.alias||O.model.id)&&(0,R.jsxs)(`div`,{className:`flex justify-between gap-2 min-w-0`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Model`}),(0,R.jsx)(`span`,{className:`truncate`,children:O.model.alias||O.model.id})]}),O.model.effort&&(0,R.jsxs)(`div`,{className:`flex justify-between gap-2 min-w-0`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Effort`}),(0,R.jsx)(`span`,{className:`truncate`,children:O.model.effort})]})]}),O?.session&&(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1`,children:[O.session.approvalMode&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Mode`}),(0,R.jsx)(`div`,{children:O.session.approvalMode})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Files`}),(0,R.jsx)(`div`,{children:O.session.fileWrite?`read/write`:O.session.fileRead?`read-only`:`none`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Shell`}),(0,R.jsx)(`div`,{children:O.session.shell?`yes`:`no`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Confidence`}),(0,R.jsx)(`div`,{children:O.confidence})]})]}),O?.lifecycle&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Lifecycle`}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:[(0,R.jsx)(N,{variant:O.lifecycle.managed?`secondary`:`outline`,className:`text-[10px]`,children:O.lifecycle.managed?`managed`:`bridge`}),O.lifecycle.shutdownHard&&(0,R.jsx)(N,{variant:`outline`,className:`text-[10px]`,children:`shutdown`}),O.lifecycle.restartHard&&(0,R.jsx)(N,{variant:`outline`,className:`text-[10px]`,children:`restart`}),O.lifecycle.reconnect&&(0,R.jsx)(N,{variant:`outline`,className:`text-[10px]`,children:`reconnect`})]})]}),Ke.length>0&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Subagents`}),(0,R.jsx)(`div`,{className:`space-y-1 mt-1`,children:Ke.map(e=>(0,R.jsxs)(`div`,{className:`flex justify-between gap-2 text-xs rounded border border-border px-2 py-1`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e.label}),e.role&&(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e.role})]},e.id))})]})]})]})]}),se&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Nc,{}),(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-2`,children:[(0,R.jsxs)(`h3`,{className:`text-sm font-medium flex items-center gap-1.5`,children:[(0,R.jsx)(pe,{className:`w-3.5 h-3.5 text-muted-foreground`}),`Memory`]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[se.supported&&(0,R.jsx)(N,{variant:`secondary`,className:`text-[10px]`,children:se.memories.length}),se.supported&&se.memories.length>0&&(0,R.jsxs)(P,{size:`sm`,variant:`outline`,className:`h-7 text-xs gap-1`,onClick:()=>b(`Clear Active Memories`,`Clear active memories for ${A(D)}?`,Ee),children:[(0,R.jsx)(rt,{className:`w-3 h-3`}),`Clear`]})]})]}),se.supported?se.memories.length===0?(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No active memories`}):(0,R.jsx)(`div`,{className:`space-y-2`,children:se.memories.map(e=>(0,R.jsx)(xu,{memory:e,now:c,onOpen:()=>{u({selectedMemoryId:e.id}),y(`memory`),d()}},e.id))}):(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Active memory list unavailable`})]})]}),D.meta?.runnerManaged===!0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Nc,{}),(0,R.jsx)(lu,{agent:D,orchestrators:a})]}),(0,R.jsx)(Nc,{}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Identity`}),(0,R.jsxs)(`div`,{className:`space-y-2.5 text-sm min-w-0`,children:[(0,R.jsx)(Cu,{label:`Agent ID`,value:D.id,copyLabel:`Copy agent ID`}),typeof D.meta?.cwd==`string`&&D.meta.cwd&&(0,R.jsx)(Cu,{label:`Working dir`,value:D.meta.cwd,copyLabel:`Copy working dir`,title:`Open ${D.meta.cwd} in Files`,onClick:()=>{d(),re(D)}}),(D.machine||D.rig||He)&&(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1.5 text-xs`,children:[D.machine&&(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Machine`}),(0,R.jsx)(`div`,{className:`truncate`,title:D.machine,children:D.machine})]}),D.rig&&(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Rig`}),(0,R.jsx)(`div`,{className:`truncate`,title:D.rig,children:D.rig})]}),He&&(0,R.jsxs)(`div`,{className:`col-span-2 min-w-0`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Package`}),(0,R.jsxs)(`div`,{className:`break-all font-mono`,children:[He.name,` v`,He.version]})]})]}),Ue.length>0&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Contracts`}),(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:Ue.map(([e,t])=>(0,R.jsxs)(N,{variant:`secondary`,className:`text-[10px]`,children:[e,`=`,t]},e))})]}),D.tags.length>0&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Tags`}),(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:D.tags.map(e=>(0,R.jsx)(N,{variant:`outline`,className:`text-[10px]`,children:e},e))})]}),ht(D.capabilities).length>0&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Capabilities`}),(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:ht(D.capabilities).map(e=>(0,R.jsx)(N,{variant:`secondary`,className:`text-[10px]`,children:e},e))})]})]})]}),Te.length>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Nc,{}),(0,R.jsxs)(`details`,{className:`group`,children:[(0,R.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 text-sm font-medium`,children:[(0,R.jsx)(`span`,{children:`Recent messages`}),(0,R.jsxs)(`span`,{className:`text-[11px] font-normal text-muted-foreground`,children:[Te.length,` `,(0,R.jsx)(`span`,{className:`group-open:hidden`,children:`· show`}),(0,R.jsx)(`span`,{className:`hidden group-open:inline`,children:`· hide`})]})]}),(0,R.jsx)(`div`,{className:`mt-2 space-y-2`,children:Te.map(e=>(0,R.jsxs)(`div`,{className:`rounded border border-border p-2 text-xs space-y-0.5 min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground min-w-0`,children:[(0,R.jsx)(`span`,{className:`font-medium text-foreground truncate shrink-0 max-w-[40%]`,children:kt(e.from,n)}),(0,R.jsx)(`span`,{className:`shrink-0`,children:`→`}),(0,R.jsx)(`span`,{className:`truncate max-w-[40%]`,children:kt(e.to,n)}),(0,R.jsxs)(`span`,{className:`ml-auto shrink-0 text-[10px]`,children:[(0,R.jsxs)(`span`,{className:`opacity-40 mr-1`,children:[`#`,e.id]}),yt(c,e.createdAt)]})]}),(0,R.jsx)(`div`,{className:`text-foreground whitespace-pre-wrap break-words line-clamp-3`,children:dt(e)})]},e.id))})]})]})]})}),(0,R.jsx)(K,{value:`timeline`,className:`min-h-0 overflow-y-auto overflow-x-hidden`,children:(0,R.jsx)(Eu,{agentId:D.id,open:e&&w===`timeline`,now:c})}),(0,R.jsx)(K,{value:`logs`,className:`min-h-0 overflow-y-auto overflow-x-hidden`,children:Je&&Ye?(0,R.jsx)(`div`,{className:`p-4`,children:(0,R.jsx)(su,{orchestratorId:Ye.id,session:Je})}):(0,R.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`No session logs available for this agent.`})})]})]})}),fe&&(0,R.jsx)(ou,{open:ue,onOpenChange:e=>void ke(e),orchestratorId:fe.orchestratorId,session:fe.session,interactive:fe.interactive||$e})]})}function xu({memory:e,now:t,onOpen:n}){let r=e.sensitivity===`secret`?`bg-red-500/10 text-red-400 border-red-500/30`:e.sensitivity===`sensitive`?`bg-yellow-500/10 text-yellow-400 border-yellow-500/30`:`bg-zinc-500/10 text-zinc-400 border-zinc-500/30`;return(0,R.jsx)(`button`,{onClick:n,className:`w-full rounded-md border border-border p-2 text-left text-xs hover:border-zinc-600 transition-colors`,children:(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[(0,R.jsx)(N,{variant:`secondary`,className:`text-[10px]`,children:e.type}),(0,R.jsx)(N,{variant:`outline`,className:`text-[10px] font-mono`,children:e.scope}),(0,R.jsx)(N,{className:`text-[10px] ${r}`,children:e.sensitivity})]}),(0,R.jsx)(`div`,{className:`font-medium truncate`,children:e.title}),(0,R.jsx)(`div`,{className:`text-muted-foreground line-clamp-2 mt-0.5`,children:e.content})]}),(0,R.jsx)(`div`,{className:`shrink-0 text-right text-[10px] text-muted-foreground`,title:At(e.lastAccessedAt??e.updatedAt),children:yt(t,e.lastAccessedAt??e.updatedAt)})]})})}function Su(e){return e>=.8?`text-red-400`:e>=.6?`text-yellow-400`:`text-emerald-400`}function Cu({label:e,value:t,onClick:n,title:r,copyLabel:i}){let a=`block w-full break-all text-left font-mono text-xs leading-snug ${n?`text-muted-foreground transition-colors hover:text-foreground`:`text-foreground`}`;return(0,R.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground`,children:e}),(0,R.jsx)(Tn,{value:t,label:i??`Copy ${e.toLowerCase()}`,size:`icon-xs`,className:`-my-1 shrink-0 text-muted-foreground`})]}),n?(0,R.jsx)(`button`,{type:`button`,className:a,title:r,onClick:n,children:t}):(0,R.jsx)(`div`,{className:a,title:r,children:t})]})}function wu({context:e,tokens:t,history:n,now:r}){let i=Number.isFinite(e.utilization)?Math.max(0,Math.min(1,e.utilization)):null,a=i===null?null:Math.round(i*100),o=i===null?`text-muted-foreground`:Su(i);return(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 min-w-0`,children:[(0,R.jsx)(`h3`,{className:`shrink-0 text-sm font-medium`,children:`Context`}),(0,R.jsxs)(`span`,{className:`truncate text-[11px] text-muted-foreground`,title:`source ${e.source}, confidence ${e.confidence}`,children:[e.lifecycleState,` · `,e.source,`/`,e.confidence]})]}),(0,R.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,R.jsx)(`span`,{className:`text-2xl font-semibold leading-none ${o}`,children:a===null?`—`:`${a}%`}),t&&(0,R.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[t,` tokens`]})]}),n.length>1&&(0,R.jsx)(Tu,{snapshots:n,now:r}),e.warmTopics.length>0&&(0,R.jsxs)(`div`,{className:`mt-2`,children:[(0,R.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Warm topics`}),(0,R.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:e.warmTopics.map(e=>(0,R.jsx)(N,{variant:`outline`,className:`text-[10px]`,children:e},e))})]})]})}function Tu({snapshots:e,now:t}){let n=e.slice(-24),[r,i]=(0,L.useState)(null);if(n.length<2)return null;let a=n.length,o=e=>Math.max(0,Math.min(1,e)),s=e=>({x:e/(a-1)*100,y:40-o(n[e].utilization)*40}),c=n.map((e,t)=>{let n=s(t);return`${n.x.toFixed(2)},${n.y.toFixed(2)}`}).join(` `),l=Su(o(n[a-1].utilization)),u=r==null?n[a-1]:n[r],d=s(r??a-1);return(0,R.jsxs)(`div`,{className:`mt-2`,children:[(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsxs)(`svg`,{viewBox:`0 0 100 40`,preserveAspectRatio:`none`,className:`h-12 w-full`,"aria-label":`Context utilization history`,children:[(0,R.jsx)(`line`,{x1:`0`,y1:`20`,x2:`100`,y2:`20`,className:`stroke-muted-foreground/15`,strokeWidth:`0.5`,strokeDasharray:`2 2`}),(0,R.jsx)(`polygon`,{points:`0,40 ${c} 100,40`,className:`fill-current text-primary/10`}),(0,R.jsx)(`polyline`,{points:c,fill:`none`,className:`stroke-current ${l}`,strokeWidth:`1.25`,strokeLinejoin:`round`,strokeLinecap:`round`,vectorEffect:`non-scaling-stroke`}),(0,R.jsx)(`circle`,{cx:d.x,cy:d.y,r:`1.6`,className:`fill-current ${l}`,vectorEffect:`non-scaling-stroke`})]}),(0,R.jsx)(`div`,{className:`absolute inset-0 flex`,children:n.map((e,t)=>(0,R.jsx)(`button`,{type:`button`,"aria-label":`${Math.round(o(e.utilization)*100)}% utilization`,className:`h-full flex-1`,onClick:()=>i(t===r?null:t)},e.id))})]}),(0,R.jsxs)(`div`,{className:`mt-1 flex items-center justify-between text-[10px] text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:r==null?(0,R.jsxs)(R.Fragment,{children:[a,` samples · since `,yt(t,n[0].capturedAt)]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:l,children:[Math.round(o(u.utilization)*100),`%`]}),` · `,new Date(u.capturedAt).toLocaleTimeString()]})}),(0,R.jsx)(`span`,{children:`0–100%`})]})]})}function Eu({agentId:e,open:t,now:n}){let[r,i]=(0,L.useState)([]),[a,o]=(0,L.useState)(!1),[s,c]=(0,L.useState)(null),[l,u]=(0,L.useState)(50),d=(0,L.useCallback)(t=>{o(!0),c(null);let n=!1;return p(`GET`,`/agents/`+encodeURIComponent(e)+`/timeline?limit=`+t).then(e=>{n||(i(e),u(t))}).catch(e=>{n||c(e.message)}).finally(()=>{n||o(!1)}),()=>{n=!0}},[e]);return(0,L.useEffect)(()=>{if(t)return d(50)},[t,e,d]),(0,R.jsxs)(`div`,{className:`p-4 space-y-3 min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium`,children:`Timeline`}),(0,R.jsxs)(P,{size:`sm`,variant:`outline`,className:`h-7 text-xs`,disabled:a,onClick:()=>d(l),children:[(0,R.jsx)(x,{className:`w-3 h-3 mr-1`}),`Refresh`]})]}),s&&(0,R.jsx)(`div`,{className:`text-xs text-red-300`,children:s}),!s&&r.length===0&&!a&&(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No timeline activity recorded for this agent.`}),(0,R.jsx)(`div`,{className:`space-y-1.5`,children:r.map((e,t)=>(0,R.jsx)(Ou,{entry:e,now:n},`${e.ts}:${e.source}:${t}`))}),r.length>=l&&l<200&&(0,R.jsx)(P,{size:`sm`,variant:`outline`,className:`w-full h-7 text-xs`,disabled:a,onClick:()=>d(200),children:`Load full timeline`})]})}function Du(e){return e.metadata?.mismatch===!0||e.metadata?.stalled===!0?(0,R.jsx)(Ve,{className:`w-3.5 h-3.5 text-amber-400`}):e.source===`command`?(0,R.jsx)(Ce,{className:`w-3.5 h-3.5 text-sky-400`}):e.source===`delivery`?(0,R.jsx)(s,{className:`w-3.5 h-3.5 text-violet-400`}):e.kind===`state`?(0,R.jsx)(o,{className:`w-3.5 h-3.5 text-emerald-400`}):(0,R.jsx)(y,{className:`w-3.5 h-3.5 text-muted-foreground`})}function Ou({entry:e,now:t}){let n=typeof e.metadata?.status==`string`?e.metadata.status:``,r=/fail|error|poison|dead/i.test(n),i=e.metadata?.fromState,a=e.metadata?.toState,o=typeof i==`string`&&typeof a==`string`?`${i} → ${a}`:null;return(0,R.jsxs)(`div`,{className:`flex gap-2 rounded border border-border px-2 py-1.5 text-xs min-w-0`,children:[(0,R.jsx)(`div`,{className:`shrink-0 mt-0.5`,children:Du(e)}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,R.jsx)(`span`,{className:`font-medium truncate ${r?`text-red-300`:`text-foreground`}`,children:e.title}),(0,R.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] text-muted-foreground`,title:At(e.ts),children:yt(t,e.ts)})]}),o&&(0,R.jsx)(`div`,{className:`text-muted-foreground font-mono text-[11px]`,children:o}),e.detail&&(0,R.jsx)(`div`,{className:`text-muted-foreground whitespace-pre-wrap break-words line-clamp-3`,children:e.detail})]})]})}function ku(e){return St(e)&&typeof e.name==`string`&&typeof e.version==`string`?{name:e.name,version:e.version}:null}function Au(e){return St(e)?Object.entries(e).filter(e=>typeof e[1]==`number`):[]}function ju(e){if(!St(e)||typeof e.lastError!=`string`)return null;let t=St(e.systemd)?{unit:typeof e.systemd.unit==`string`?e.systemd.unit:void 0,activeState:typeof e.systemd.activeState==`string`?e.systemd.activeState:void 0,subState:typeof e.systemd.subState==`string`?e.systemd.subState:void 0,result:typeof e.systemd.result==`string`?e.systemd.result:void 0,execMainCode:typeof e.systemd.execMainCode==`string`?e.systemd.execMainCode:void 0,execMainStatus:typeof e.systemd.execMainStatus==`string`?e.systemd.execMainStatus:void 0}:void 0;return{lastError:e.lastError,detectedAt:typeof e.detectedAt==`number`?e.detectedAt:void 0,runtimeMs:typeof e.runtimeMs==`number`?e.runtimeMs:void 0,logFile:typeof e.logFile==`string`?e.logFile:void 0,logBytes:typeof e.logBytes==`number`?e.logBytes:void 0,logEmpty:typeof e.logEmpty==`boolean`?e.logEmpty:void 0,logTail:Array.isArray(e.logTail)?e.logTail.filter(e=>typeof e==`string`):void 0,systemd:t,unavailable:Array.isArray(e.unavailable)?e.unavailable.filter(e=>typeof e==`string`):void 0}}function Mu(e){let t=e?.meta?.tmuxSession;return typeof t==`string`&&t.trim()?t:null}function Nu(e,t,n){return e?n.find(n=>n.managedAgents.some(n=>n.agentId===e.id||n.tmuxSession===t))??null:null}function Pu({className:e,children:t,...n}){return(0,R.jsxs)(qo,{"data-slot":`scroll-area`,className:S(`relative`,e),...n,children:[(0,R.jsx)(Jo,{"data-slot":`scroll-area-viewport`,className:`size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1`,children:t}),(0,R.jsx)(Fu,{}),(0,R.jsx)(Yo,{})]})}function Fu({className:e,orientation:t=`vertical`,...n}){return(0,R.jsx)(xo,{"data-slot":`scroll-area-scrollbar`,"data-orientation":t,orientation:t,className:S(`flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent`,e),...n,children:(0,R.jsx)(Mo,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}function Iu(){let e=k(e=>e.channelDetailOpen),t=k(e=>e.channelDetailId),n=k(e=>e.channels),r=k(e=>e.messages),i=k(e=>e.agentsById),a=st(),o=k(e=>e.closeChannelDetail),s=n.find(e=>e.id===t)||null,c=Ot(s),l=(0,L.useMemo)(()=>s?r.filter(e=>Mt(e,s)).sort((e,t)=>t.id-e.id).slice(0,8):[],[r,s]);return(0,R.jsx)(Nl,{open:e,onOpenChange:e=>!e&&o(),children:(0,R.jsxs)(Il,{className:`w-full max-w-[100dvw] sm:max-w-md lg:max-w-lg p-0`,children:[(0,R.jsx)(Ll,{className:`shrink-0 p-4 border-b border-border`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,R.jsx)(N,{className:pt(c.tone),children:c.label}),(0,R.jsx)(Rl,{className:`text-base truncate`,children:s?.name||`Channel`})]})}),(0,R.jsx)(Pu,{className:`flex-1 min-h-0`,children:(0,R.jsxs)(`div`,{className:`p-4 space-y-4`,children:[s&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Route`}),(0,R.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,R.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Type`}),(0,R.jsx)(`span`,{className:`truncate`,children:s.type})]}),(0,R.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Direction`}),(0,R.jsx)(`span`,{className:`truncate`,children:s.direction})]}),s.target&&(0,R.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Target`}),(0,R.jsx)(`span`,{className:`truncate`,children:s.target})]}),(0,R.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Agent`}),(0,R.jsx)(`span`,{className:`truncate`,children:s.agentId})]}),(0,R.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Transport`}),(0,R.jsx)(`span`,{className:`truncate`,children:s.transport})]}),(0,R.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Last seen`}),(0,R.jsx)(`span`,{className:`shrink-0`,children:yt(a,s.lastSeen)})]})]})]}),ht(s.capabilities).length>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Nc,{}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Capabilities`}),(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:ht(s.capabilities).map(e=>(0,R.jsx)(N,{variant:`secondary`,className:`text-[10px]`,children:e},e))})]})]}),s.meta&&Object.keys(s.meta).length>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Nc,{}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Metadata`}),(0,R.jsx)(`div`,{className:`space-y-1 text-sm`,children:Object.entries(s.meta).map(([e,t])=>(0,R.jsxs)(`div`,{className:`flex justify-between gap-2 min-w-0`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e}),(0,R.jsx)(`span`,{className:`truncate`,children:String(t)})]},e))})]})]})]}),l.length>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Nc,{}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Recent Messages`}),(0,R.jsx)(`div`,{className:`space-y-2`,children:l.map(e=>(0,R.jsxs)(`div`,{className:`rounded border border-border p-2 text-xs space-y-0.5 min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground min-w-0`,children:[(0,R.jsx)(`span`,{className:`font-medium text-foreground truncate shrink-0 max-w-[40%]`,children:kt(e.from,i)}),(0,R.jsx)(`span`,{className:`shrink-0`,children:`→`}),(0,R.jsx)(`span`,{className:`truncate max-w-[40%]`,children:kt(e.to,i)}),(0,R.jsxs)(`span`,{className:`ml-auto shrink-0 text-[10px]`,children:[(0,R.jsxs)(`span`,{className:`opacity-40 mr-1`,children:[`#`,e.id]}),yt(a,e.createdAt)]})]}),(0,R.jsx)(`div`,{className:`text-foreground whitespace-pre-wrap break-words line-clamp-3`,children:dt(e)})]},e.id))})]})]})]})})]})})}var Lu=!1;function Ru(e,t){let n=L.useRef(!1),r=L.useRef(t);r.current=t,L.useEffect(()=>{if(!e||!r.current)return;Lu=!1,window.history.pushState({dialogGuard:!0},``),n.current=!0;function t(){if(Lu){Lu=!1;return}n.current&&(n.current=!1,r.current?.(!1))}return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t),n.current&&(n.current=!1,Lu=!0,window.history.back())}},[e])}function zu({...e}){return Ru(e.open,e.onOpenChange),(0,R.jsx)(mr,{"data-slot":`dialog`,...e})}function Bu({...e}){return(0,R.jsx)(hr,{"data-slot":`dialog-portal`,...e})}function Vu({className:e,blur:t=!0,...n}){return(0,R.jsx)(gr,{"data-slot":`dialog-overlay`,className:S(`fixed inset-0 isolate z-50 bg-black/10 duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,t&&`supports-backdrop-filter:backdrop-blur-xs`,e),...n})}function Hu({className:e,children:t,showCloseButton:n=!0,blurOverlay:r=!0,...i}){return(0,R.jsxs)(Bu,{children:[(0,R.jsx)(Vu,{blur:r}),(0,R.jsxs)(_r,{"data-slot":`dialog-content`,className:S(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...i,children:[t,n&&(0,R.jsx)(br,{"data-slot":`dialog-close`,asChild:!0,children:(0,R.jsxs)(P,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`,children:[(0,R.jsx)(Ee,{}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function Uu({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`dialog-header`,className:S(`flex flex-col gap-2`,e),...t})}function Wu({className:e,showCloseButton:t=!1,children:n,...r}){return(0,R.jsxs)(`div`,{"data-slot":`dialog-footer`,className:S(`-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,R.jsx)(br,{asChild:!0,children:(0,R.jsx)(P,{variant:`outline`,children:`Close`})})]})}function Gu({className:e,...t}){return(0,R.jsx)(vr,{"data-slot":`dialog-title`,className:S(`font-heading text-base leading-none font-medium`,e),...t})}function X({className:e,...t}){return(0,R.jsx)(yr,{"data-slot":`dialog-description`,className:S(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function Ku({className:e,...t}){return(0,R.jsx)(`textarea`,{"data-slot":`textarea`,className:S(`flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...t})}function Z({className:e,...t}){return(0,R.jsx)(fo,{"data-slot":`label`,className:S(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function qu(){let e=k(e=>e.composeOpen),t=k(e=>e.compose),n=k(e=>e.replyTo),r=k(e=>e.set),i=k(e=>e.doSend),a=k(e=>e.cancelReply),o=Ec();function s(){r({composeOpen:!1}),a()}function c(e){r({compose:{...t,...e}})}return(0,R.jsx)(zu,{open:e,onOpenChange:e=>!e&&s(),children:(0,R.jsxs)(Hu,{className:`max-w-lg`,children:[(0,R.jsx)(Uu,{children:(0,R.jsx)(Gu,{children:n?`Reply to #${n.id}`:`Compose Message`})}),(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`From`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:t.from,onChange:e=>c({from:e.target.value}),children:[(0,R.jsx)(`option`,{value:``,children:`Select agent...`}),o.map(e=>(0,R.jsx)(`option`,{value:e.id,children:A(e)},e.id))]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`To`}),(0,R.jsx)(F,{value:t.to,onChange:e=>c({to:e.target.value}),placeholder:`agent-id, tag:name, cap:name, or broadcast`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Subject`}),(0,R.jsx)(F,{value:t.subject,onChange:e=>c({subject:e.target.value}),placeholder:`Optional subject...`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Channel`}),(0,R.jsx)(F,{value:t.channel,onChange:e=>c({channel:e.target.value}),placeholder:`Optional channel...`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Message`}),(0,R.jsx)(Ku,{value:t.body,onChange:e=>c({body:e.target.value}),rows:4,placeholder:`Message body...`,autoFocus:!0})]}),(0,R.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(Mc,{checked:t.claimable,onCheckedChange:e=>c({claimable:e})}),(0,R.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Claimable task`})]})]}),(0,R.jsxs)(Wu,{children:[(0,R.jsx)(P,{variant:`outline`,onClick:s,children:`Cancel`}),(0,R.jsx)(P,{onClick:i,children:`Send`})]})]})})}function Ju(){let e=k(e=>e.confirmModal),t=k(e=>e.set);function n(){t({confirmModal:{show:!1,title:``,message:``,action:null}})}return(0,R.jsx)(zu,{open:e.show,onOpenChange:e=>!e&&n(),children:(0,R.jsxs)(Hu,{className:`sm:max-w-sm`,children:[(0,R.jsxs)(Uu,{children:[(0,R.jsx)(Gu,{children:e.title}),(0,R.jsx)(X,{children:e.message})]}),(0,R.jsxs)(Wu,{children:[(0,R.jsx)(P,{variant:`outline`,onClick:n,children:`Cancel`}),(0,R.jsx)(P,{variant:`destructive`,onClick:()=>{e.action?.(),n()},children:`Confirm`})]})]})})}function Yu(){let e=k(e=>e.errorModal),t=k(e=>e.set);function n(){t({errorModal:{show:!1,title:``,message:``}})}return(0,R.jsx)(zu,{open:e.show,onOpenChange:e=>!e&&n(),children:(0,R.jsxs)(Hu,{className:`sm:max-w-sm`,children:[(0,R.jsxs)(Uu,{children:[(0,R.jsx)(Gu,{children:e.title}),(0,R.jsx)(X,{children:e.message})]}),(0,R.jsx)(Wu,{children:(0,R.jsx)(P,{onClick:n,children:`OK`})})]})})}function Xu(){let e=k(e=>e.renameModal),t=k(e=>e.set),n=k(e=>e.doRename);function r(){t({renameModal:{show:!1,agentId:``,label:``}})}return(0,R.jsx)(zu,{open:e.show,onOpenChange:e=>!e&&r(),children:(0,R.jsxs)(Hu,{className:`sm:max-w-sm`,children:[(0,R.jsx)(Uu,{children:(0,R.jsx)(Gu,{children:`Rename Agent`})}),(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsx)(Z,{children:`Label`}),(0,R.jsx)(F,{value:e.label,onChange:n=>t({renameModal:{...e,label:n.target.value}}),onKeyDown:e=>e.key===`Enter`&&n(),placeholder:`Human-friendly name...`,autoFocus:!0}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Leave empty to clear the label.`})]}),(0,R.jsxs)(Wu,{children:[(0,R.jsx)(P,{variant:`outline`,onClick:r,children:`Cancel`}),(0,R.jsx)(P,{onClick:n,children:`Save`})]})]})})}function Zu(){let e=k(e=>e.pairInviteOpen),t=k(e=>e.pairInvite),n=k(e=>e.set),r=k(e=>e.closePairInvite),i=k(e=>e.doCreatePair),a=Ec();function o(e){n({pairInvite:{...t,...e}})}return(0,R.jsx)(zu,{open:e,onOpenChange:e=>!e&&r(),children:(0,R.jsxs)(Hu,{className:`sm:max-w-sm`,children:[(0,R.jsx)(Uu,{children:(0,R.jsx)(Gu,{children:`Pair Agents`})}),(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Requester`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:t.requesterId,onChange:e=>o({requesterId:e.target.value}),children:[(0,R.jsx)(`option`,{value:``,children:`Select agent...`}),a.map(e=>(0,R.jsx)(`option`,{value:e.id,children:A(e)},e.id))]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Target`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:t.targetId,onChange:e=>o({targetId:e.target.value}),children:[(0,R.jsx)(`option`,{value:``,children:`Select agent...`}),a.map(e=>(0,R.jsx)(`option`,{value:e.id,children:A(e)},e.id))]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Objective`}),(0,R.jsx)(F,{value:t.objective,onChange:e=>o({objective:e.target.value}),placeholder:`What should they work on?`})]})]}),(0,R.jsxs)(Wu,{children:[(0,R.jsx)(P,{variant:`outline`,onClick:r,children:`Cancel`}),(0,R.jsx)(P,{onClick:i,children:`Create Pair`})]})]})})}function Qu(){let e=k(e=>e.pairMessageOpen),t=k(e=>e.pairMessage),n=k(e=>e.set),r=k(e=>e.closePairMessage),i=k(e=>e.doSendPairMessage);function a(e){n({pairMessage:{...t,...e}})}return(0,R.jsx)(zu,{open:e,onOpenChange:e=>!e&&r(),children:(0,R.jsxs)(Hu,{className:`sm:max-w-sm`,children:[(0,R.jsx)(Uu,{children:(0,R.jsx)(Gu,{children:`Pair Message`})}),(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Subject`}),(0,R.jsx)(F,{value:t.subject,onChange:e=>a({subject:e.target.value}),placeholder:`Optional subject...`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Message`}),(0,R.jsx)(Ku,{value:t.body,onChange:e=>a({body:e.target.value}),rows:4,placeholder:`Message body...`,autoFocus:!0})]})]}),(0,R.jsxs)(Wu,{children:[(0,R.jsx)(P,{variant:`outline`,onClick:r,children:`Cancel`}),(0,R.jsx)(P,{onClick:i,children:`Send`})]})]})})}var $u=(0,L.lazy)(()=>I(()=>import(`./formatted-body-impl-DBt5tnS0.js`).then(e=>({default:e.FormattedBody})),__vite__mapDeps([14,1,5,3,6,9]),import.meta.url));function ed(e){return(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(`span`,{className:e.className,children:e.text}),children:(0,R.jsx)($u,{...e})})}function td(){let e=k(e=>e.threadOpen),t=k(e=>e.threadMessages),n=k(e=>e.agentsById),r=st(),i=k(e=>e.set);return(0,R.jsx)(zu,{open:e,onOpenChange:e=>!e&&i({threadOpen:!1}),children:(0,R.jsxs)(Hu,{className:`max-w-2xl max-h-[80vh]`,children:[(0,R.jsx)(Uu,{children:(0,R.jsxs)(Gu,{children:[`Thread (`,t.length,` messages)`]})}),(0,R.jsx)(Pu,{className:`max-h-[60vh]`,children:(0,R.jsx)(`div`,{className:`space-y-3 pr-4`,children:t.map(e=>(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-3 space-y-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:kt(e.from,n)}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:kt(e.to,n)}),(0,R.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:yt(r,e.createdAt)})]}),e.subject&&(0,R.jsx)(`div`,{className:`text-sm font-medium`,children:e.subject}),(0,R.jsx)(ed,{text:dt(e),rawBody:e.body,className:`text-sm text-muted-foreground`}),(0,R.jsxs)(`div`,{className:`flex gap-1.5 flex-wrap`,children:[e.channel&&(0,R.jsx)(N,{variant:`secondary`,className:`text-[10px]`,children:e.channel}),e.claimedBy&&(0,R.jsxs)(N,{variant:`secondary`,className:`text-[10px]`,children:[`claimed by `,kt(e.claimedBy,n)]})]})]},e.id))})})]})})}function nd(){let e=k(e=>e.taskEventsOpen),t=k(e=>e.taskEvents),n=k(e=>e.set),r=k(e=>e.switchView);function i(e){n({selectedMemoryId:e,taskEventsOpen:!1}),r(`memory`)}return(0,R.jsx)(zu,{open:e,onOpenChange:e=>!e&&n({taskEventsOpen:!1}),children:(0,R.jsxs)(Hu,{className:`max-w-2xl max-h-[80vh]`,children:[(0,R.jsx)(Uu,{children:(0,R.jsxs)(Gu,{children:[`Task Events (`,t.length,`)`]})}),(0,R.jsx)(Pu,{className:`max-h-[60vh]`,children:(0,R.jsxs)(`div`,{className:`space-y-2 pr-4`,children:[t.map(e=>(0,R.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-border p-3`,children:[(0,R.jsx)(N,{className:Nt[e.severity]||Nt.info,children:e.severity}),(0,R.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium`,children:e.title}),(0,R.jsx)(N,{variant:`outline`,className:`text-[10px]`,children:e.type})]}),e.body&&(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 whitespace-pre-wrap`,children:e.body}),(0,R.jsx)(rd,{event:e,onOpen:i}),(0,R.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[At(e.createdAt),` · `,e.source]})]})]},e.id)),t.length===0&&(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-8`,children:`No events recorded.`})]})})]})})}function rd({event:e,onOpen:t}){if(e.type!==`memory.captured`)return null;let n=typeof e.metadata?.memoryId==`string`?e.metadata.memoryId:``,r=e.metadata?.memory&&typeof e.metadata.memory==`object`&&!Array.isArray(e.metadata.memory)?e.metadata.memory:{},i=typeof r.title==`string`?r.title:e.body||n,a=typeof r.scope==`string`?r.scope:``,o=typeof r.type==`string`?r.type:`memory`,s=typeof r.sensitivity==`string`?r.sensitivity:``;return(0,R.jsx)(`div`,{className:`mt-2 rounded-md border border-border bg-muted/20 p-2 text-xs`,children:(0,R.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(pe,{className:`w-3.5 h-3.5 mt-0.5 text-muted-foreground shrink-0`}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[(0,R.jsx)(N,{variant:`secondary`,className:`text-[10px]`,children:o}),a&&(0,R.jsx)(N,{variant:`outline`,className:`text-[10px] font-mono`,children:a}),s&&(0,R.jsx)(N,{variant:`outline`,className:`text-[10px]`,children:s})]}),(0,R.jsx)(`div`,{className:`font-medium truncate`,children:i}),n&&(0,R.jsx)(`div`,{className:`font-mono text-[10px] text-muted-foreground truncate`,children:n})]}),n&&(0,R.jsx)(P,{size:`sm`,variant:`outline`,className:`h-7 text-xs shrink-0`,onClick:()=>t(n),children:`Open`})]})})}function id({open:e,onOpenChange:t,onSelect:n,orchestratorId:r,initialPath:i,title:a=`Select Directory`}){let o=k(e=>e.apiCall),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(null),[d,f]=(0,L.useState)(null),[p,m]=(0,L.useState)(!1),[h,g]=(0,L.useState)(``),[_,v]=(0,L.useState)(null),y=l?.path||i||``,b=(0,L.useMemo)(()=>y.split(`/`).filter(Boolean),[y]),x=(0,L.useCallback)(async e=>{if(r){c(!0),f(null),m(!1);try{let t=e?`?path=${encodeURIComponent(e)}`:``;u(await o(`GET`,`/orchestrators/${encodeURIComponent(r)}/directories${t}`))}catch(e){f(Ct(e))}finally{c(!1)}}},[r,o]);(0,L.useEffect)(()=>{e&&r&&(u(null),f(null),m(!1),x(i||void 0))},[e,r]);async function S(){if(!(!h.trim()||!l)){v(null);try{u(await o(`POST`,`/orchestrators/${encodeURIComponent(r)}/directories`,{path:l.path,name:h.trim()})),m(!1),g(``)}catch(e){v(Ct(e))}}}function ee(){y&&(n(y),t(!1))}function C(e){x(`/`+b.slice(0,e+1).join(`/`))}return(0,R.jsx)(zu,{open:e,onOpenChange:t,children:(0,R.jsxs)(Hu,{className:`max-w-lg max-h-[85dvh] flex flex-col`,children:[(0,R.jsx)(Uu,{children:(0,R.jsxs)(Gu,{className:`flex items-center gap-2`,children:[(0,R.jsx)(je,{className:`h-4 w-4`}),a]})}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-muted/50 px-2 py-1.5 text-xs overflow-x-auto`,children:[(0,R.jsx)(`button`,{type:`button`,className:`font-mono text-muted-foreground hover:text-foreground shrink-0`,onClick:()=>l?.baseDir&&x(l.baseDir),children:`/`}),b.map((e,t)=>(0,R.jsxs)(`span`,{className:`shrink-0`,children:[(0,R.jsx)(`button`,{type:`button`,className:`font-mono text-muted-foreground hover:text-foreground`,onClick:()=>C(t),children:e}),t<b.length-1&&(0,R.jsx)(`span`,{className:`text-muted-foreground/50 mx-0.5`,children:`/`})]},`${e}-${t}`))]}),(0,R.jsxs)(`div`,{className:`flex-1 min-h-0 rounded-md border border-border bg-background overflow-y-auto`,style:{maxHeight:`40dvh`},children:[s&&(0,R.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,R.jsx)(Be,{className:`h-5 w-5 animate-spin text-muted-foreground`})}),!s&&d&&(0,R.jsx)(`div`,{className:`px-3 py-4 text-sm text-destructive`,children:d}),!s&&l&&(0,R.jsxs)(`div`,{className:`p-1`,children:[l.parent&&(0,R.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm hover:bg-muted`,onClick:()=>x(l.parent),children:[(0,R.jsx)(T,{className:`h-4 w-4 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`..`})]}),l.entries.map(e=>(0,R.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm hover:bg-muted`,onClick:()=>x(e.path),children:[(0,R.jsx)(ae,{className:`h-4 w-4 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)),l.entries.length===0&&!l.parent&&(0,R.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground text-center`,children:`Empty directory`}),l.entries.length===0&&l.parent&&(0,R.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground text-center`,children:`No subdirectories`})]})]}),p?(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(F,{autoFocus:!0,value:h,onChange:e=>{g(e.target.value),v(null)},onKeyDown:e=>{e.key===`Enter`&&S(),e.key===`Escape`&&(m(!1),g(``))},placeholder:`New directory name...`,className:`flex-1 font-mono text-sm`}),(0,R.jsx)(P,{type:`button`,size:`icon`,variant:`outline`,onClick:S,disabled:!h.trim(),children:(0,R.jsx)(Ne,{className:`h-4 w-4`})}),(0,R.jsx)(P,{type:`button`,size:`icon`,variant:`ghost`,onClick:()=>{m(!1),g(``),v(null)},children:(0,R.jsx)(Ee,{className:`h-4 w-4`})})]}):(0,R.jsxs)(P,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>m(!0),disabled:!l||s,children:[(0,R.jsx)(te,{className:`h-4 w-4 mr-1.5`}),`New Directory`]}),_&&(0,R.jsx)(`p`,{className:`text-xs text-destructive`,children:_}),(0,R.jsxs)(Wu,{children:[(0,R.jsx)(P,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,R.jsx)(P,{onClick:ee,disabled:!y,children:`Select`})]})]})})}function ad({value:e,onChange:t,orchestratorId:n,placeholder:r,disabled:i}){let[a,o]=(0,L.useState)(!1);return(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(F,{value:e,onChange:e=>t(e.target.value),placeholder:r,disabled:i,className:`flex-1 font-mono text-sm`}),(0,R.jsx)(P,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>o(!0),disabled:i||!n,title:`Browse directories`,children:(0,R.jsx)(je,{className:`h-4 w-4`})}),n&&(0,R.jsx)(id,{open:a,onOpenChange:o,onSelect:t,orchestratorId:n,initialPath:e||void 0})]})}function od({model:e}){if(!e)return null;let t=sd(e);return t.length===0?null:(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>(0,R.jsxs)(N,{variant:`outline`,className:`gap-1 text-[10px]`,children:[(0,R.jsx)(e.Icon,{className:`h-3 w-3`}),e.label]},e.label))})}function sd(e){let t=[],n=e.limits?.contextWindowTokens?.value;return n&&t.push({label:cd(n),Icon:v}),e.capabilities?.modalities.input.image&&t.push({label:`Image input`,Icon:E}),(e.capabilities?.modalities.output.image||e.capabilities?.tools?.imageGeneration)&&t.push({label:`Image output`,Icon:E}),e.capabilities?.tools?.code&&t.push({label:`Code`,Icon:h}),t}function cd(e){return e>=1e6?`${e/1e6}M ctx`:e>=1e3?`${Math.round(e/1e3)}K ctx`:`${e} ctx`}function ld(){let e=k(e=>e.orchestratorSpawnOpen),t=k(e=>e.orchestrators),n=k(e=>e.spawnOrchId),r=k(e=>e.spawnProvider),i=k(e=>e.spawnModel),a=k(e=>e.spawnEffort),o=k(e=>e.spawnProfile),s=k(e=>e.spawnCwd),c=k(e=>e.spawnLabel),l=k(e=>e.spawnApproval),u=k(e=>e.spawnWorkspaceMode),d=k(e=>e.spawnPrompt),f=k(e=>e.spawnSystemPromptAppend),p=k(e=>e.spawnCount),m=k(e=>e.spawnCwdHistory),h=k(e=>e.isSpawning),g=k(e=>!!e.pendingForkImport),_=k(e=>e.set),v=k(e=>e.submitOrchestratorSpawn),y=k(e=>e.selectSpawnHistory),b=k(e=>e.agentProfiles),x=t.find(e=>e.id===n),S=x?.providers||[],ee=ot[r]?.models||[],te=ee.find(e=>e.alias===i),C=te?.efforts||[],ne=!!(x&&S.length>0&&s.trim())&&!h,re=t.filter(e=>e.status===`online`),ie=re.length>1,ae=m.filter(e=>re.some(t=>t.id===e.orchId)).slice(0,5);function oe(e){let n=t.find(t=>t.id===e),r=n?.providers[0]||``;_({spawnOrchId:e,spawnProvider:r,spawnModel:r&&ot[r]?.defaultModel||``,spawnEffort:``,spawnCwd:n?.baseDir||``})}function se(e){_({spawnProvider:e,spawnModel:ot[e]?.defaultModel||``,spawnEffort:``})}function ce(e){_({spawnModel:e,spawnEffort:``})}return(0,R.jsx)(zu,{open:e,onOpenChange:e=>!e&&_({orchestratorSpawnOpen:!1}),children:(0,R.jsxs)(Hu,{className:`max-w-lg max-h-[90dvh] flex flex-col`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,R.jsx)(Uu,{children:(0,R.jsx)(Gu,{children:`Spawn Agent`})}),(0,R.jsxs)(`div`,{className:`space-y-3 overflow-y-auto flex-1 min-h-0 -mx-4 px-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Orchestrator`}),(0,R.jsx)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:n,onChange:e=>oe(e.target.value),children:t.filter(e=>e.status===`online`).map(e=>(0,R.jsxs)(`option`,{value:e.id,children:[e.hostname,` (`,e.id.slice(-8),`)`]},e.id))})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Provider`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:r,onChange:e=>se(e.target.value),disabled:!S.length,children:[!S.length&&(0,R.jsx)(`option`,{value:r,children:`No providers available`}),S.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Model`}),(0,R.jsx)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:i,onChange:e=>ce(e.target.value),disabled:!ee.length,children:ee.map(e=>(0,R.jsx)(`option`,{value:e.alias,children:e.label},e.alias))})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Effort`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:a,onChange:e=>_({spawnEffort:e.target.value}),disabled:!C.length,children:[(0,R.jsx)(`option`,{value:``,children:`Default`}),C.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,R.jsx)(od,{model:te}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Agent Profile`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:o||`default-relay`,onChange:e=>_({spawnProfile:e.target.value}),children:[!b.length&&(0,R.jsx)(`option`,{value:`default-relay`,children:`default-relay`}),b.map(e=>(0,R.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Approval Mode`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:l,onChange:e=>_({spawnApproval:e.target.value}),children:[(0,R.jsx)(`option`,{value:`open`,children:`Open`}),(0,R.jsx)(`option`,{value:`guarded`,children:`Guarded`}),(0,R.jsx)(`option`,{value:`read-only`,children:`Read-only`})]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Workspace`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:u,onChange:e=>_({spawnWorkspaceMode:e.target.value}),children:[(0,R.jsx)(`option`,{value:`inherit`,children:`Default`}),(0,R.jsx)(`option`,{value:`isolated`,children:`Isolated worktree`}),(0,R.jsx)(`option`,{value:`shared`,children:`Shared cwd`})]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Working Directory`}),(0,R.jsx)(`div`,{className:`mt-1`,children:(0,R.jsx)(ad,{value:s,onChange:e=>_({spawnCwd:e}),orchestratorId:n,placeholder:`Select a project directory`})}),ae.length>0&&(0,R.jsxs)(`div`,{className:`mt-2`,children:[(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mb-1`,children:`Recent`}),(0,R.jsx)(`div`,{className:`flex gap-1.5 overflow-x-auto pb-1 sm:flex-wrap sm:overflow-x-visible sm:pb-0`,children:ae.map(e=>{let t=e.cwd.replace(/\/+$/,``).split(`/`).pop()||e.cwd,r=re.find(t=>t.id===e.orchId)?.hostname,i=e.orchId===n&&e.cwd===s;return(0,R.jsx)(`button`,{type:`button`,title:ie&&r?`${r}: ${e.cwd}`:e.cwd,onClick:()=>y(e.orchId,e.cwd),className:`shrink-0 rounded-full border px-2.5 py-1 text-xs font-mono transition-colors ${i?`border-primary bg-primary/10 text-foreground`:`border-input bg-background text-muted-foreground hover:bg-accent hover:text-foreground`}`,children:ie&&r?`${r}: ${t}`:t},`${e.orchId}:${e.cwd}`)})})]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Label`}),(0,R.jsx)(F,{value:c,onChange:e=>_({spawnLabel:e.target.value}),placeholder:`Optional label...`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Initial Prompt`}),(0,R.jsx)(Ku,{value:d,onChange:e=>_({spawnPrompt:e.target.value}),rows:3,placeholder:`Optional initial task...`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Codex starts this as the first App Server turn; Claude receives it as a launch prompt.`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`System Prompt Append`}),(0,R.jsx)(Ku,{value:f,onChange:e=>_({spawnSystemPromptAppend:e.target.value}),rows:5,placeholder:`Optional launch context...`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Use for fork history or launch context. It informs the session but does not start work by itself.`})]}),!g&&(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsx)(Z,{children:`Number of Agents`}),(0,R.jsx)(`span`,{className:`text-sm font-mono tabular-nums text-muted-foreground`,children:p})]}),(0,R.jsx)(`input`,{type:`range`,min:1,max:10,step:1,value:p,onChange:e=>_({spawnCount:Number(e.target.value)}),className:`w-full mt-2 accent-primary`,"aria-label":`Number of agents to spawn`}),p>1&&(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[`Spawns `,p,` identical agents`,c.trim()?`, labelled "${c.trim()} 1"…"${c.trim()} ${p}"`:``,`.`]})]})]}),(0,R.jsxs)(Wu,{children:[(0,R.jsx)(P,{variant:`outline`,onClick:()=>_({orchestratorSpawnOpen:!1}),disabled:h,children:`Cancel`}),(0,R.jsx)(P,{onClick:v,disabled:!ne,children:h?`Spawning…`:S.length?p>1?`Spawn ${p}`:`Spawn`:`No providers`})]})]})})}function ud(){return`host-${Math.random().toString(36).slice(2,8)}`}function dd(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function fd(){let e=k(e=>e.orchestratorInstallOpen),t=k(e=>e.set),n=k(e=>e.showError),r=k(e=>e.showNotification),i=(0,L.useMemo)(()=>new URL(se()).origin,[]),[a,o]=(0,L.useState)(ud),[s,c]=(0,L.useState)(`$HOME/projects`),[l,u]=(0,L.useState)([`claude`,`codex`]),[d,f]=(0,L.useState)(`4860`),[m,h]=(0,L.useState)(``),[g,_]=(0,L.useState)(``),[v,y]=(0,L.useState)(),[b,x]=(0,L.useState)(!1);async function S(){if(!a.trim()){n(`Validation`,`Orchestrator id is required`);return}if(!s.trim()){n(`Validation`,`Base directory is required`);return}if(!l.length){n(`Validation`,`Select at least one provider`);return}x(!0);try{let e=await p(`POST`,`/orchestrators/bootstrap`,{id:a.trim(),relayUrl:i,baseDir:s.trim(),providers:l,apiPort:Number(d)||4860,pathPrefix:m.split(`:`).map(e=>e.trim()).filter(Boolean)});_(e.command),y(e.expiresAt)}catch(e){n(`Install Command Failed`,e.message)}finally{x(!1)}}return(0,R.jsx)(zu,{open:e,onOpenChange:e=>!e&&t({orchestratorInstallOpen:!1}),children:(0,R.jsxs)(Hu,{className:`max-w-2xl overflow-hidden`,children:[(0,R.jsx)(Uu,{children:(0,R.jsxs)(Gu,{className:`flex items-center gap-2`,children:[(0,R.jsx)(ie,{className:`w-4 h-4`}),`Add Orchestrator`]})}),(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Orchestrator ID`}),(0,R.jsx)(F,{value:a,onChange:e=>o(e.target.value)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Relay URL`}),(0,R.jsx)(F,{value:i,readOnly:!0})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Base Directory`}),(0,R.jsx)(F,{value:s,onChange:e=>c(e.target.value)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`API Port`}),(0,R.jsx)(F,{value:d,onChange:e=>f(e.target.value),inputMode:`numeric`})]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Providers`}),(0,R.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-2`,children:[`claude`,`codex`].map(e=>(0,R.jsx)(P,{type:`button`,size:`sm`,variant:l.includes(e)?`default`:`outline`,onClick:()=>u(dd(l,e)),children:e},e))})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Extra PATH Prefix`}),(0,R.jsx)(F,{value:m,onChange:e=>h(e.target.value),placeholder:`/opt/homebrew/bin:/custom/bin`})]}),g&&(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,R.jsx)(Z,{children:`Install Command`}),v&&(0,R.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`Install token expires `,new Date(v*1e3).toLocaleString()]})]}),(0,R.jsx)(`pre`,{className:`max-h-40 w-full overflow-y-auto whitespace-pre-wrap break-all rounded-md border border-input bg-muted/40 p-3 font-mono text-xs leading-relaxed`,children:g})]})]}),(0,R.jsxs)(Wu,{children:[(0,R.jsx)(P,{variant:`outline`,onClick:()=>t({orchestratorInstallOpen:!1}),children:`Close`}),g&&(0,R.jsx)(Tn,{value:g,label:`Copy`,showText:!0,size:`default`,variant:`outline`,className:`gap-1`,onCopied:()=>r(`Install command copied`)}),(0,R.jsxs)(P,{className:`gap-1`,onClick:S,disabled:b,children:[(0,R.jsx)(Ce,{className:`w-3.5 h-3.5`}),b?`Generating...`:`Generate Command`]})]})]})})}function pd(){let e=k(e=>e.policyModal),t=k(e=>e.orchestrators),n=k(e=>e.agentProfiles),r=k(e=>e.set),i=k(e=>e.submitPolicy),a=t.find(t=>t.id===e.orchestratorId),o=a?.providers||[],s=ot[e.provider]?.models||[],c=s.find(t=>t.alias===e.model),l=c?.efforts||[],u=!!e.editing,d=e.provider===`claude`&&a?.providerStatus?.find(e=>e.name===`claude`)?.features?.rig===!0;function f(t){r({policyModal:{...e,...t}})}function p(n){let r=t.find(e=>e.id===n)?.providers[0]||e.provider;f({orchestratorId:n,provider:r,model:ot[r]?.defaultModel||``,effort:``})}function m(e){f({provider:e,rig:``,model:ot[e]?.defaultModel||``,effort:``})}return(0,R.jsx)(zu,{open:e.open,onOpenChange:e=>!e&&f({open:!1}),children:(0,R.jsxs)(Hu,{className:`max-w-lg max-h-[90vh] overflow-y-auto`,children:[(0,R.jsx)(Uu,{children:(0,R.jsx)(Gu,{children:u?`Edit Policy`:`Create Managed Agent`})}),(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Policy Name`}),(0,R.jsx)(F,{value:e.name,onChange:e=>f({name:e.target.value}),placeholder:`my-agent`,disabled:u})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Label`}),(0,R.jsx)(F,{value:e.label,onChange:e=>f({label:e.target.value}),placeholder:`Human-friendly name...`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Description`}),(0,R.jsx)(F,{value:e.description,onChange:e=>f({description:e.target.value}),placeholder:`What does this agent do?`})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Orchestrator`}),(0,R.jsx)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.orchestratorId,onChange:e=>p(e.target.value),children:t.filter(e=>e.status===`online`).map(e=>(0,R.jsxs)(`option`,{value:e.id,children:[e.hostname,` (`,e.id.slice(-8),`)`]},e.id))})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Provider`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.provider,onChange:e=>m(e.target.value),disabled:!o.length,children:[!o.length&&(0,R.jsx)(`option`,{value:e.provider,children:`No providers available`}),o.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})]})]}),d&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Rig`}),(0,R.jsx)(F,{value:e.rig,onChange:e=>f({rig:e.target.value}),placeholder:`Leave empty to auto-detect from .claude-rig`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`claude-rig profile name. Auto-detects from project's .claude-rig file if empty.`})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Model`}),(0,R.jsx)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.model,onChange:e=>f({model:e.target.value,effort:``}),children:s.map(e=>(0,R.jsx)(`option`,{value:e.alias,children:e.label},e.alias))})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Effort`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.effort,onChange:e=>f({effort:e.target.value}),disabled:!l.length,children:[(0,R.jsx)(`option`,{value:``,children:`Default`}),l.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,R.jsx)(od,{model:c}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Agent Profile`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.profile||`default-relay`,onChange:e=>f({profile:e.target.value}),children:[!n.length&&(0,R.jsx)(`option`,{value:`default-relay`,children:`default-relay`}),n.map(e=>(0,R.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Working Directory`}),(0,R.jsx)(`div`,{className:`mt-1`,children:(0,R.jsx)(ad,{value:e.cwd,onChange:e=>f({cwd:e}),orchestratorId:e.orchestratorId,placeholder:a?.baseDir||`/path/to/project`})})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Mode`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.mode,onChange:e=>f({mode:e.target.value}),children:[(0,R.jsx)(`option`,{value:`always-on`,children:`Always On`}),(0,R.jsx)(`option`,{value:`on-demand`,children:`On Demand`})]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Permission Mode`}),(0,R.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.permissionMode,onChange:e=>f({permissionMode:e.target.value}),children:[(0,R.jsx)(`option`,{value:`open`,children:`Open`}),(0,R.jsx)(`option`,{value:`guarded`,children:`Guarded`}),(0,R.jsx)(`option`,{value:`read-only`,children:`Read-only`})]})]})]}),e.mode===`on-demand`&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Keepalive (seconds)`}),(0,R.jsx)(F,{type:`number`,value:e.keepaliveSeconds,onChange:e=>f({keepaliveSeconds:e.target.value}),placeholder:`300`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Seconds to keep agent alive after last activity.`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Initial Prompt`}),(0,R.jsx)(Ku,{value:e.prompt,onChange:e=>f({prompt:e.target.value}),rows:3,placeholder:`Optional initial task or instructions...`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Codex starts this as the first App Server turn; Claude receives it as a launch prompt.`})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Tags`}),(0,R.jsx)(F,{value:e.tags,onChange:e=>f({tags:e.target.value}),placeholder:`tag1, tag2`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Capabilities`}),(0,R.jsx)(F,{value:e.capabilities,onChange:e=>f({capabilities:e.target.value}),placeholder:`chat, review`})]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Provider Args`}),(0,R.jsx)(F,{value:e.providerArgs,onChange:e=>f({providerArgs:e.target.value}),placeholder:`--flag value`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Space-separated args passed to the provider CLI.`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Channel Binding`}),(0,R.jsx)(F,{value:e.channelId,onChange:e=>f({channelId:e.target.value}),placeholder:`Channel ID (optional)`})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Backoff Schedule (seconds)`}),(0,R.jsx)(F,{value:e.backoffSchedule,onChange:e=>f({backoffSchedule:e.target.value}),placeholder:`5, 15, 60, 300`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Backoff Reset After (s)`}),(0,R.jsx)(F,{type:`number`,value:e.backoffResetAfterSeconds,onChange:e=>f({backoffResetAfterSeconds:e.target.value}),placeholder:`600`})]})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsx)(Z,{htmlFor:`restartOnUpdate`,children:`Restart on policy update`}),(0,R.jsx)(Mc,{id:`restartOnUpdate`,checked:e.restartOnUpdate,onCheckedChange:e=>f({restartOnUpdate:e})})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsx)(Z,{htmlFor:`dailyRestart`,children:`Scheduled daily restart`}),(0,R.jsx)(Mc,{id:`dailyRestart`,checked:e.scheduledDailyRestart,onCheckedChange:e=>f({scheduledDailyRestart:e})})]})]}),(0,R.jsxs)(Wu,{children:[(0,R.jsx)(P,{variant:`outline`,onClick:()=>f({open:!1}),children:`Cancel`}),(0,R.jsx)(P,{onClick:i,children:u?`Save`:`Create`})]})]})})}function md({title:e,children:t,defaultOpen:n=!0}){let[r,i]=(0,L.useState)(n);return(0,R.jsxs)(`div`,{className:`border border-border rounded-md`,children:[(0,R.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-sm font-medium hover:bg-accent`,onClick:()=>i(!r),children:[r?(0,R.jsx)(_e,{className:`h-3.5 w-3.5`}):(0,R.jsx)(ze,{className:`h-3.5 w-3.5`}),e]}),r&&(0,R.jsx)(`div`,{className:`space-y-3 border-t border-border px-3 py-3`,children:t})]})}function hd({value:e,onChange:t,options:n,disabled:r}){return(0,R.jsx)(`select`,{className:`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e,onChange:e=>t(e.target.value),disabled:r,children:n.map(e=>(0,R.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function gd({env:e,onChange:t,disabled:n}){let r=Object.entries(e),[i,a]=(0,L.useState)(``),[o,s]=(0,L.useState)(``);function c(){i.trim()&&(t({...e,[i.trim()]:o}),a(``),s(``))}function l(n){let r={...e};delete r[n],t(r)}return(0,R.jsxs)(`div`,{className:`space-y-1.5`,children:[r.map(([e,t])=>(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsxs)(`code`,{className:`min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 text-xs`,children:[e,`=`,t]}),!n&&(0,R.jsx)(P,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-6 w-6 shrink-0`,onClick:()=>l(e),children:(0,R.jsx)(Fe,{className:`h-3 w-3`})})]},e)),!n&&(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(F,{value:i,onChange:e=>a(e.target.value),placeholder:`KEY`,className:`flex-1 text-xs font-mono`}),(0,R.jsx)(F,{value:o,onChange:e=>s(e.target.value),placeholder:`value`,className:`flex-1 text-xs font-mono`,onKeyDown:e=>e.key===`Enter`&&c()}),(0,R.jsx)(P,{type:`button`,variant:`outline`,size:`icon-sm`,className:`h-8 w-8 shrink-0`,onClick:c,children:(0,R.jsx)(_,{className:`h-3 w-3`})})]}),r.length===0&&n&&(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No environment variables`})]})}var _d=[{value:`host`,label:`Host — full access, relay-aware`},{value:`minimal`,label:`Minimal — relay disabled, repo-scoped`},{value:`isolated`,label:`Isolated — strict isolation`}],vd=[{value:`any`,label:`Any provider`},{value:`claude`,label:`Claude`},{value:`codex`,label:`Codex`}],yd=[{value:`host`,label:`Host — use host config`},{value:`profile`,label:`Profile — use profile config`},{value:`repo`,label:`Repo — use repo config only`},{value:`none`,label:`None — disabled`}],Q=[{value:`host`,label:`Host — full filesystem`},{value:`workspace`,label:`Workspace — working directory tree`},{value:`repo`,label:`Repo — repository root only`}],bd=[{value:`allow`,label:`Allow`},{value:`ignore`,label:`Ignore`}],xd=[{value:``,label:`Default`},{value:`open`,label:`Open — allow all`},{value:`guarded`,label:`Guarded — prompt for risky`},{value:`read-only`,label:`Read-only`}];function Sd(){let{open:e,mode:t,profile:n}=k(e=>e.profileModal),r=k(e=>e.closeProfileModal),i=k(e=>e.updateProfileModal),a=k(e=>e.saveProfile),o=t===`view`||n.builtIn===!0,s=t===`create`||t===`duplicate`,c=t===`view`?`Profile: ${n.name}`:t===`edit`?`Edit: ${n.name}`:t===`duplicate`?`Duplicate Profile`:`Create Profile`;function l(e){i({instructions:{...n.instructions,...e}})}function u(e){i({relay:{...n.relay,...e}})}function d(e){i({permissions:{...n.permissions,...e}})}function f(e){let t=n.providerOptions||{},r={...t.codex&&typeof t.codex==`object`&&!Array.isArray(t.codex)?t.codex:{}};if(!e.trim())delete r.toolOutputTokenLimit;else{let t=Number(e);if(!Number.isSafeInteger(t))return;r.toolOutputTokenLimit=t}i({providerOptions:{...t,codex:r}})}function p(e){if(!e.trim()){i({maxSpawnedAgents:void 0});return}let t=Number(e);!Number.isInteger(t)||t<0||i({maxSpawnedAgents:Math.min(t,100)})}function m(e){let t=e===`host`;i({base:e,relay:{context:t,skills:t,plugins:t,statusLine:t,mcp:t},mcp:{...n.mcp,mode:t?`host`:`none`},hooks:{mode:t?`host`:`none`},permissions:{...n.permissions,filesystem:t?`host`:`repo`},instructions:{...n.instructions,globalInstructions:t?`allow`:`ignore`}})}let h=n.providerOptions?.codex&&typeof n.providerOptions.codex==`object`&&!Array.isArray(n.providerOptions.codex)?n.providerOptions.codex:{},g=Number.isSafeInteger(h.toolOutputTokenLimit)?String(h.toolOutputTokenLimit):``;return(0,R.jsx)(zu,{open:e,onOpenChange:e=>!e&&r(),children:(0,R.jsxs)(Hu,{className:`max-w-lg max-h-[90vh] overflow-y-auto`,children:[(0,R.jsx)(Uu,{children:(0,R.jsxs)(Gu,{className:`flex items-center gap-2`,children:[c,n.builtIn&&(0,R.jsx)(N,{variant:`secondary`,className:`text-[10px]`,children:`Built-in`})]})}),(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsxs)(md,{title:`General`,defaultOpen:!0,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Name`}),(0,R.jsx)(F,{value:n.name,onChange:e=>i({name:e.target.value}),placeholder:`my-profile`,disabled:o||t===`edit`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Description`}),(0,R.jsx)(F,{value:n.description||``,onChange:e=>i({description:e.target.value}),placeholder:`What this profile configures`,disabled:o})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Base`}),(0,R.jsx)(hd,{value:n.base,onChange:e=>m(e),options:_d,disabled:o})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Provider`}),(0,R.jsx)(hd,{value:n.provider||`any`,onChange:e=>i({provider:e}),options:vd,disabled:o})]})]})]}),(0,R.jsxs)(md,{title:`Instructions`,defaultOpen:!1,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`System Prompt`}),(0,R.jsx)(Ku,{value:n.instructions.system||``,onChange:e=>l({system:e.target.value}),placeholder:`Custom system prompt...`,rows:3,disabled:o,className:`font-mono text-xs`})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Repo Instructions`}),(0,R.jsx)(hd,{value:n.instructions.repoInstructions,onChange:e=>l({repoInstructions:e}),options:bd,disabled:o})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Global Instructions`}),(0,R.jsx)(hd,{value:n.instructions.globalInstructions,onChange:e=>l({globalInstructions:e}),options:bd,disabled:o})]})]})]}),(0,R.jsx)(md,{title:`Relay Integration`,defaultOpen:!1,children:(0,R.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[`context`,`skills`,`plugins`,`statusLine`,`mcp`].map(e=>(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(Z,{className:`capitalize`,children:e===`statusLine`?`Status Line`:e===`mcp`?`MCP Tools`:e}),(0,R.jsx)(Mc,{checked:n.relay[e]??!0,onCheckedChange:t=>u({[e]:t}),disabled:o})]},e))})}),(0,R.jsx)(md,{title:`MCP & Hooks`,defaultOpen:!1,children:(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`MCP Mode`}),(0,R.jsx)(hd,{value:n.mcp.mode,onChange:e=>i({mcp:{...n.mcp,mode:e}}),options:yd,disabled:o})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Hooks Mode`}),(0,R.jsx)(hd,{value:n.hooks.mode,onChange:e=>i({hooks:{mode:e}}),options:yd,disabled:o})]})]})}),(0,R.jsx)(md,{title:`Permissions`,defaultOpen:!1,children:(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Approval Mode`}),(0,R.jsx)(hd,{value:n.permissions.mode||``,onChange:e=>d({mode:e||void 0}),options:xd,disabled:o})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Filesystem Scope`}),(0,R.jsx)(hd,{value:n.permissions.filesystem,onChange:e=>d({filesystem:e}),options:Q,disabled:o})]})]})}),(0,R.jsx)(md,{title:`Spawning`,defaultOpen:!1,children:(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Spawn Quota`}),(0,R.jsx)(F,{type:`number`,min:0,max:100,step:1,value:n.maxSpawnedAgents===void 0?``:String(n.maxSpawnedAgents),onChange:e=>p(e.target.value),placeholder:`0`,disabled:o}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Max concurrent live child agents this profile may spawn. Empty or 0 = cannot spawn (default). Children never inherit it (no grandchildren).`})]})}),(0,R.jsx)(md,{title:`Environment Variables`,defaultOpen:!1,children:(0,R.jsx)(gd,{env:n.env||{},onChange:e=>i({env:e}),disabled:o})}),(0,R.jsxs)(md,{title:`Provider Options`,defaultOpen:!1,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Z,{children:`Codex Tool Output Limit`}),(0,R.jsx)(F,{type:`number`,min:1e3,max:2e5,value:g,onChange:e=>f(e.target.value),placeholder:`12000`,disabled:o})]}),(0,R.jsx)(Ku,{value:JSON.stringify(n.providerOptions||{},null,2),onChange:e=>{try{i({providerOptions:JSON.parse(e.target.value)})}catch{}},rows:3,disabled:o,className:`font-mono text-xs`,placeholder:`{}`})]})]}),!o&&(0,R.jsxs)(Wu,{children:[(0,R.jsx)(P,{variant:`outline`,onClick:r,children:`Cancel`}),(0,R.jsx)(P,{onClick:a,children:s?`Create`:`Save`})]})]})})}function Cd(){let e=k(e=>e.commandPaletteOpen),t=k(e=>e.commandQuery),n=k(e=>e.set),r=k(e=>e.closeCommandPalette),i=k(e=>e.runCommand),a=Ac(),o=(0,L.useRef)(null);return(0,L.useEffect)(()=>{e&&setTimeout(()=>o.current?.focus(),50)},[e]),e?(0,R.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,onClick:e=>{e.target===e.currentTarget&&r()},children:[(0,R.jsx)(`div`,{className:`fixed inset-0 bg-black/60`}),(0,R.jsxs)(`div`,{className:`relative w-full max-w-lg bg-card border border-border rounded-xl shadow-2xl overflow-hidden`,children:[(0,R.jsx)(`div`,{className:`p-3 border-b border-border`,children:(0,R.jsx)(F,{ref:o,value:t,onChange:e=>n({commandQuery:e.target.value}),placeholder:`Type a command...`,className:`border-0 bg-transparent focus-visible:ring-0 text-base`})}),(0,R.jsxs)(`div`,{className:`max-h-80 overflow-y-auto p-2`,children:[a.map(e=>(0,R.jsxs)(`button`,{onClick:()=>i(e),className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-lg hover:bg-accent text-left transition-colors`,children:[(0,R.jsx)(Ke[e.icon]||ze,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,R.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,R.jsx)(`div`,{className:`text-sm`,children:e.title}),e.subtitle&&(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:e.subtitle})]})]},e.id)),a.length===0&&(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`No matching commands.`})]})]})]}):null}function wd(){let e=k(e=>e.set),t=k(e=>e.connected);return(0,R.jsxs)(`div`,{className:`xl:hidden sticky top-0 z-30 bg-card border-b border-border px-4 h-[var(--header-h)] flex items-center gap-3`,children:[(0,R.jsx)(`button`,{onClick:()=>e({mobileMenuOpen:!0}),className:`p-1 -ml-1 text-muted-foreground hover:text-foreground transition-colors`,"aria-label":`Open menu`,children:(0,R.jsx)(n,{className:`w-5 h-5`})}),(0,R.jsx)(C,{className:`w-4 h-4 text-primary`}),(0,R.jsx)(`span`,{className:`font-bold text-sm`,children:`Agent Relay`}),(0,R.jsx)(`span`,{className:`ml-auto w-2 h-2 rounded-full ${t?`bg-emerald-500`:`bg-red-500 animate-pulse`}`})]})}var Td=(0,L.lazy)(()=>I(()=>import(`./overview-Djy3qkY5.js`).then(e=>({default:e.OverviewView})),__vite__mapDeps([15,1,6,8,9,16,11,17]),import.meta.url)),Ed=(0,L.lazy)(()=>I(()=>import(`./chat-CHgPGHQD.js`).then(e=>({default:e.ChatView})),__vite__mapDeps([18,1,6,19,8,9,20,21,22,23,10,11,16,24,12]),import.meta.url)),Dd=(0,L.lazy)(()=>I(()=>import(`./agents-D201CuTR.js`).then(e=>({default:e.AgentsView})),__vite__mapDeps([25,1,26,27,6,11,28,19,29,30,31,32,33,8,9,22,23,10,16,17]),import.meta.url)),Od=(0,L.lazy)(()=>I(()=>import(`./managed-agents-BjYBzVZt.js`).then(e=>({default:e.ManagedAgentsView})),__vite__mapDeps([34,1,6,8,9,10,11]),import.meta.url)),kd=(0,L.lazy)(()=>I(()=>import(`./teams-DRchUP_p.js`).then(e=>({default:e.TeamsView})),__vite__mapDeps([35,1,36,26,27,6,11,28,19,29,30,37,38,39,31,33,40,8,9,21,16,10,17,24]),import.meta.url)),Ad=(0,L.lazy)(()=>I(()=>import(`./agent-profiles-7X8gFuwj.js`).then(e=>({default:e.AgentProfilesView})),__vite__mapDeps([41,6,1,8,9,16,11,10]),import.meta.url)),jd=(0,L.lazy)(()=>I(()=>import(`./orchestrators-BwxdTQm_.js`).then(e=>({default:e.OrchestratorsView})),__vite__mapDeps([42,6,1,8,9,16,11,10,17]),import.meta.url)),Md=(0,L.lazy)(()=>I(()=>import(`./workspaces-CicYE2Ax.js`).then(e=>({default:e.WorkspacesView})),__vite__mapDeps([43,1,6,8,9,23,10,11,16,17]),import.meta.url)),$=(0,L.lazy)(()=>I(()=>import(`./channels-BsJu5TXR.js`).then(e=>({default:e.ChannelsView})),__vite__mapDeps([44,6,1,8,9,16,11,10,17]),import.meta.url)),Nd=(0,L.lazy)(()=>I(()=>import(`./connectors-arjfBQvc.js`).then(e=>({default:e.ConnectorsView})),__vite__mapDeps([45,6,1,8,9,16,11,10,17]),import.meta.url)),Pd=(0,L.lazy)(()=>I(()=>import(`./integrations-7L1f3eIE.js`).then(e=>({default:e.IntegrationsView})),__vite__mapDeps([46,6,1,8,9,16,11,10,17]),import.meta.url)),Fd=(0,L.lazy)(()=>I(()=>import(`./security-tG3q7fFW.js`).then(e=>({default:e.SecurityView})),__vite__mapDeps([47,1,6,23,10,11,16,17,24]),import.meta.url)),Id=(0,L.lazy)(()=>I(()=>import(`./memory-SLycz2gC.js`).then(e=>({default:e.MemoryView})),__vite__mapDeps([48,1,6,8,9,16,11,10,17,24]),import.meta.url)),Ld=(0,L.lazy)(()=>I(()=>import(`./activity-gmfkOBhQ.js`).then(e=>({default:e.ActivityView})),__vite__mapDeps([49,1,6,8,9,20,16,11,10,17]),import.meta.url)),Rd=(0,L.lazy)(()=>I(()=>import(`./pairs-9KNduLnC.js`).then(e=>({default:e.PairsView})),__vite__mapDeps([50,6,1,8,9,16,11,10,17]),import.meta.url)),zd=(0,L.lazy)(()=>I(()=>import(`./messages-DfSCTe6N.js`).then(e=>({default:e.MessagesView})),__vite__mapDeps([51,1,6,8,9,16,11,10,17]),import.meta.url)),Bd=(0,L.lazy)(()=>I(()=>import(`./work-queue-HNcyjON9.js`).then(e=>({default:e.WorkQueueView})),__vite__mapDeps([52,6,1,8,9,16,11,10,17]),import.meta.url)),Vd=(0,L.lazy)(()=>I(()=>import(`./tasks-DWlKg218.js`).then(e=>({default:e.TasksView})),__vite__mapDeps([53,1,6,8,9,16,11,10,17]),import.meta.url)),Hd=(0,L.lazy)(()=>I(()=>import(`./automation-_5u-nVs8.js`).then(e=>({default:e.AutomationView})),__vite__mapDeps([54,1,6,8,9,16,11,10,17,24]),import.meta.url)),Ud=(0,L.lazy)(()=>I(()=>import(`./analytics-CkOTrr5t.js`).then(e=>({default:e.AnalyticsView})),__vite__mapDeps([55,1,6,8,9,17,56]),import.meta.url)),Wd=(0,L.lazy)(()=>I(()=>import(`./insights-BvjkOXk9.js`).then(e=>({default:e.InsightsView})),__vite__mapDeps([57,1,6,16,11,10,17,24,9]),import.meta.url)),Gd=(0,L.lazy)(()=>I(()=>import(`./maintenance-BBoL--vs.js`).then(e=>({default:e.MaintenanceView})),__vite__mapDeps([58,1,6,8,9,16,11,10]),import.meta.url)),Kd=(0,L.lazy)(()=>I(()=>import(`./settings-CGcqyJ5L.js`).then(e=>({default:e.SettingsView})),__vite__mapDeps([59,1,36,26,27,6,11,28,19,29,30,37,38,39,31,33,40,8,9,10,24]),import.meta.url)),qd=class extends L.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary]`,e.message,`
20
20
  `,t.componentStack)}render(){return this.state.error?(0,R.jsxs)(`div`,{className:`p-6 text-sm font-mono whitespace-pre-wrap`,children:[(0,R.jsx)(`h2`,{className:`text-red-400 text-lg mb-2`,children:`Dashboard Error`}),(0,R.jsx)(`p`,{className:`text-foreground mb-4`,children:this.state.error.message}),(0,R.jsx)(`pre`,{className:`text-muted-foreground text-xs overflow-auto`,children:this.state.error.stack}),(0,R.jsx)(`button`,{className:`mt-4 px-3 py-1 bg-zinc-700 rounded text-sm`,onClick:()=>this.setState({error:null}),children:`Retry`})]}):this.props.children}},Jd={overview:Td,chat:Ed,agents:Dd,managed:Od,teams:kd,profiles:Ad,orchestrators:jd,workspaces:Md,files:Al,channels:$,connectors:Nd,integrations:Pd,security:Fd,memory:Id,activity:Ld,pairs:Rd,messages:zd,work:Bd,tasks:Vd,automation:Hd,analytics:Ud,insights:Wd,maintenance:Gd,settings:Kd},Yd=`fixed z-50 top-[calc(var(--header-h,3rem)+0.5rem)] inset-x-3 xl:inset-x-auto xl:top-auto xl:bottom-4 xl:right-4 xl:max-w-sm animate-in fade-in slide-in-from-top-2 xl:slide-in-from-bottom-2 duration-200`;function Xd(){return(0,R.jsxs)(`div`,{className:`flex items-center justify-center py-16 text-muted-foreground text-sm`,children:[(0,R.jsx)(`span`,{className:`inline-block w-3 h-3 mr-2 rounded-full bg-muted-foreground/60 animate-pulse`}),`Loading…`]})}function Zd(){let e=k(e=>e.notification),t=k(e=>e.toastNotification),n=k(e=>e.openNotification),r=k(e=>e.dismissToast);if(t){let e=t;return(0,R.jsxs)(`div`,{className:`${Yd} flex items-start gap-2 px-4 py-3 bg-zinc-800 text-zinc-100 text-sm rounded-md shadow-lg border border-zinc-700`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{n(e),r()},className:`flex-1 min-w-0 text-left cursor-pointer`,children:[(0,R.jsx)(`div`,{className:`font-medium truncate`,children:e.title}),(0,R.jsx)(`div`,{className:`text-xs text-zinc-300 line-clamp-2 mt-0.5`,children:e.body}),(0,R.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-zinc-400 mt-1`,children:`Tap to open`})]}),(0,R.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`Dismiss`,className:`shrink-0 -mr-1 -mt-1 px-1 text-lg leading-none text-zinc-400 hover:text-zinc-100`,children:`×`})]})}return e?(0,R.jsx)(`div`,{className:`${Yd} px-4 py-2 bg-zinc-800 text-zinc-100 text-sm rounded-md shadow-lg border border-zinc-700`,children:e}):null}function Qd(){let e=k(e=>e.init),t=k(e=>e.destroy),n=k(e=>e.theme),r=k(e=>e.view),i=k(e=>e.authNeeded),a=k(e=>e.connectionError),o=k(e=>e.authToken),s=k(e=>e.set),c=k(e=>e.saveTokenAndRefresh),l=k(e=>e.openCommandPalette),u=k(e=>e.commandPaletteOpen),d=k(e=>e.closeCommandPalette);(0,L.useEffect)(()=>{qt(n)},[n]),(0,L.useEffect)(()=>(e(),()=>t()),[]),(0,L.useEffect)(()=>{function e(e){(e.metaKey||e.ctrlKey)&&e.key?.toLowerCase()===`k`?(e.preventDefault(),l()):e.key===`Escape`&&u&&(e.preventDefault(),d())}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[u]);let f=Jd[r]||Td;return(0,R.jsx)(qd,{children:(0,R.jsx)(gc,{children:(0,R.jsxs)(`div`,{className:`flex min-h-[calc(100dvh-var(--sat))] mt-[var(--sat)]`,children:[(0,R.jsx)(Kc,{}),(0,R.jsx)(qc,{}),(0,R.jsxs)(`main`,{className:`flex-1 min-w-0 h-[calc(100dvh-var(--sat))] overflow-y-auto`,children:[(0,R.jsx)(wd,{}),!i&&a&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2 p-3 bg-amber-950/40 border-b border-amber-800/60 text-amber-200 text-sm`,children:[(0,R.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full bg-amber-400 animate-pulse`}),`Relay unreachable — showing last known data. Reconnecting…`]}),i&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2 p-3 bg-card border-b border-border`,children:[(0,R.jsx)(Oe,{className:`w-4 h-4 text-muted-foreground`}),(0,R.jsx)(F,{type:`password`,placeholder:`Relay token...`,value:o,onChange:e=>s({authToken:e.target.value}),onKeyDown:e=>e.key===`Enter`&&c(),className:`max-w-xs h-8`}),(0,R.jsx)(P,{size:`sm`,onClick:c,children:`Connect`})]}),(0,R.jsx)(`div`,{className:`p-4 md:p-6`,children:(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(Xd,{}),children:(0,R.jsx)(f,{})})})]}),(0,R.jsx)(bu,{}),(0,R.jsx)(Iu,{}),(0,R.jsx)(qu,{}),(0,R.jsx)(Ju,{}),(0,R.jsx)(Yu,{}),(0,R.jsx)(Xu,{}),(0,R.jsx)(Zu,{}),(0,R.jsx)(Qu,{}),(0,R.jsx)(td,{}),(0,R.jsx)(nd,{}),(0,R.jsx)(ld,{}),(0,R.jsx)(fd,{}),(0,R.jsx)(pd,{}),(0,R.jsx)(Sd,{}),(0,R.jsx)(jl,{}),(0,R.jsx)(Cd,{}),(0,R.jsx)(Zd,{})]})})})}if((0,hc.createRoot)(document.getElementById(`root`)).render((0,R.jsx)(L.StrictMode,{children:(0,R.jsx)(Qd,{})})),`serviceWorker`in navigator){let e=new URL(`sw.js`,window.location.href),t=new URL(`.`,e),n=new URL(`/`,window.location.origin),r=new URL(`sw.js`,n);t.href!==n.href&&navigator.serviceWorker.getRegistration(n.pathname).then(e=>{e?.scope===n.href&&e.active?.scriptURL===r.href&&e.unregister()}).catch(()=>{}),navigator.serviceWorker.register(e.toString(),{scope:t.pathname}).catch(()=>{})}export{zc as A,_c as B,Dl as C,Pc as D,il as E,Sc as F,An as G,Dc as H,Cc as I,Tc as L,Nc as M,Mc as N,Ic as O,vc as P,Ec as R,q as S,ll as T,Oc as U,yc as V,kc as W,eu as _,Hu as a,Yl as b,mu as c,hu as d,su as f,Gl as g,Wl as h,zu as i,Fc as j,Lc as k,pu as l,Ul as m,Z as n,Gu as o,ou as p,Ku as r,Pu as s,ed as t,gu as u,Ql as v,Ol as w,Hl as x,Zl as y,wc as z};
21
- //# sourceMappingURL=index-br_Y6Cvt.js.map
21
+ //# sourceMappingURL=index-D7js3XlH.js.map