agent-relay-server 0.115.0 → 0.116.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/openapi.json +1 -1
- package/package.json +3 -3
- package/public/assets/MessageBubble-BJllE_2c.js +4 -0
- package/public/assets/MessageBubble-BJllE_2c.js.map +1 -0
- package/public/assets/{PlanGraphPanel-C17_n4Ff.js → PlanGraphPanel-CoK024n9.js} +2 -2
- package/public/assets/{PlanGraphPanel-C17_n4Ff.js.map → PlanGraphPanel-CoK024n9.js.map} +1 -1
- package/public/assets/{activity-G-s2N4eU.js → activity-CBjg7NSP.js} +2 -2
- package/public/assets/{activity-G-s2N4eU.js.map → activity-CBjg7NSP.js.map} +1 -1
- package/public/assets/{agent-profiles-v4CcpJWT.js → agent-profiles-DzkjQaCS.js} +2 -2
- package/public/assets/{agent-profiles-v4CcpJWT.js.map → agent-profiles-DzkjQaCS.js.map} +1 -1
- package/public/assets/{agents-CuEoaCLs.js → agents-Bu1i1jH-.js} +2 -2
- package/public/assets/{agents-CuEoaCLs.js.map → agents-Bu1i1jH-.js.map} +1 -1
- package/public/assets/{analytics-Dvg0J33b.js → analytics-Cc2GoEq_.js} +2 -2
- package/public/assets/{analytics-Dvg0J33b.js.map → analytics-Cc2GoEq_.js.map} +1 -1
- package/public/assets/{automation-wXSbBEei.js → automation-CcMveyvi.js} +2 -2
- package/public/assets/{automation-wXSbBEei.js.map → automation-CcMveyvi.js.map} +1 -1
- package/public/assets/{branch-state-badge-YzkNCHyZ.js → branch-state-badge-CYWBVZDI.js} +2 -2
- package/public/assets/{branch-state-badge-YzkNCHyZ.js.map → branch-state-badge-CYWBVZDI.js.map} +1 -1
- package/public/assets/{channels-Vl9YHoGK.js → channels-IdC7jyLt.js} +2 -2
- package/public/assets/{channels-Vl9YHoGK.js.map → channels-IdC7jyLt.js.map} +1 -1
- package/public/assets/{chat-yiXwg4kh.js → chat-CP4x6Gcr.js} +2 -2
- package/public/assets/{chat-yiXwg4kh.js.map → chat-CP4x6Gcr.js.map} +1 -1
- package/public/assets/{connectors-C33KsouZ.js → connectors-Dngl_FJz.js} +2 -2
- package/public/assets/{connectors-C33KsouZ.js.map → connectors-Dngl_FJz.js.map} +1 -1
- package/public/assets/formatted-body-impl-CBHoD82a.js +3 -0
- package/public/assets/formatted-body-impl-CBHoD82a.js.map +1 -0
- package/public/assets/{index-DYwuv_Na.css → index-DcmG5gLR.css} +1 -1
- package/public/assets/{index-4XRZ-n_A.js → index-DocqZ4Q0.js} +6 -6
- package/public/assets/{index-4XRZ-n_A.js.map → index-DocqZ4Q0.js.map} +1 -1
- package/public/assets/{insights-C5Ft13cw.js → insights-Du9X-nwA.js} +2 -2
- package/public/assets/{insights-C5Ft13cw.js.map → insights-Du9X-nwA.js.map} +1 -1
- package/public/assets/{integrations-DR3pboEG.js → integrations-BlSadMFC.js} +2 -2
- package/public/assets/{integrations-DR3pboEG.js.map → integrations-BlSadMFC.js.map} +1 -1
- package/public/assets/{maintenance-Ddl6-McO.js → maintenance-KeCPGZG4.js} +2 -2
- package/public/assets/{maintenance-Ddl6-McO.js.map → maintenance-KeCPGZG4.js.map} +1 -1
- package/public/assets/{managed-agents-pLThsagU.js → managed-agents-YKqARLQn.js} +2 -2
- package/public/assets/{managed-agents-pLThsagU.js.map → managed-agents-YKqARLQn.js.map} +1 -1
- package/public/assets/{markdown-preview-impl-CiENso5E.js → markdown-preview-impl-Bo8ql-lO.js} +2 -2
- package/public/assets/{markdown-preview-impl-CiENso5E.js.map → markdown-preview-impl-Bo8ql-lO.js.map} +1 -1
- package/public/assets/{memory-CSzdP2o2.js → memory-BlftQACU.js} +2 -2
- package/public/assets/{memory-CSzdP2o2.js.map → memory-BlftQACU.js.map} +1 -1
- package/public/assets/{messages-1ton_JT5.js → messages-DQu0Np7r.js} +2 -2
- package/public/assets/{messages-1ton_JT5.js.map → messages-DQu0Np7r.js.map} +1 -1
- package/public/assets/{orchestrators-C2kC07Qm.js → orchestrators-CW00iA0W.js} +2 -2
- package/public/assets/{orchestrators-C2kC07Qm.js.map → orchestrators-CW00iA0W.js.map} +1 -1
- package/public/assets/{overview-CXc2vQRQ.js → overview-DyiH9eVP.js} +2 -2
- package/public/assets/{overview-CXc2vQRQ.js.map → overview-DyiH9eVP.js.map} +1 -1
- package/public/assets/{pairs-DLfFKNEf.js → pairs-Ee8Npq67.js} +2 -2
- package/public/assets/{pairs-DLfFKNEf.js.map → pairs-Ee8Npq67.js.map} +1 -1
- package/public/assets/{projects-TM20JuNI.js → projects-CqeJsfB6.js} +2 -2
- package/public/assets/{projects-TM20JuNI.js.map → projects-CqeJsfB6.js.map} +1 -1
- package/public/assets/{prompt-settings-DWYbD9TA.js → prompt-settings-0fHJtGD5.js} +2 -2
- package/public/assets/{prompt-settings-DWYbD9TA.js.map → prompt-settings-0fHJtGD5.js.map} +1 -1
- package/public/assets/{registry-BWRVKBhU.js → registry-QTLN8Jy-.js} +2 -2
- package/public/assets/{registry-BWRVKBhU.js.map → registry-QTLN8Jy-.js.map} +1 -1
- package/public/assets/{security-DcNNqoA4.js → security-B0FTbGXU.js} +2 -2
- package/public/assets/{security-DcNNqoA4.js.map → security-B0FTbGXU.js.map} +1 -1
- package/public/assets/{select-DkpcyiTY.js → select-DhY0OvwP.js} +2 -2
- package/public/assets/{select-DkpcyiTY.js.map → select-DhY0OvwP.js.map} +1 -1
- package/public/assets/{settings-C9-w25pF.js → settings-B2UEpdBi.js} +2 -2
- package/public/assets/{settings-C9-w25pF.js.map → settings-B2UEpdBi.js.map} +1 -1
- package/public/assets/{store-BZ2N51To.js → store-DwgQJjEv.js} +2 -2
- package/public/assets/store-DwgQJjEv.js.map +1 -0
- package/public/assets/tasks-BvDfBcxZ.js +2 -0
- package/public/assets/tasks-BvDfBcxZ.js.map +1 -0
- package/public/assets/{teams-CQZ6a8A5.js → teams-CIqsg55S.js} +2 -2
- package/public/assets/{teams-CQZ6a8A5.js.map → teams-CIqsg55S.js.map} +1 -1
- package/public/assets/{terminal-viewer-impl-B1A49Vs2.js → terminal-viewer-impl-Cig30gnt.js} +2 -2
- package/public/assets/{terminal-viewer-impl-B1A49Vs2.js.map → terminal-viewer-impl-Cig30gnt.js.map} +1 -1
- package/public/assets/types-DSwhOFcJ.js.map +1 -1
- package/public/assets/{user-avatar-C3eL_il0.js → user-avatar-Ct6HEqZm.js} +2 -2
- package/public/assets/{user-avatar-C3eL_il0.js.map → user-avatar-Ct6HEqZm.js.map} +1 -1
- package/public/assets/{work-queue-IfxOcGe5.js → work-queue-XWcDwe8G.js} +2 -2
- package/public/assets/{work-queue-IfxOcGe5.js.map → work-queue-XWcDwe8G.js.map} +1 -1
- package/public/assets/{workspaces-gPEVu-L5.js → workspaces-EI4N2N7L.js} +2 -2
- package/public/assets/{workspaces-gPEVu-L5.js.map → workspaces-EI4N2N7L.js.map} +1 -1
- package/public/index.html +3 -3
- package/runner/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/src/branch-landed.ts +14 -1
- package/src/db/mappers.ts +3 -0
- package/src/db/migrations.ts +39 -0
- package/src/db/schema.ts +2 -0
- package/src/db/task-entity.ts +78 -3
- package/src/mcp-task-tools.ts +16 -7
- package/src/routes/tasks.ts +13 -5
- package/src/services/spawn-agent.ts +25 -22
- package/src/services/task-entity.ts +6 -1
- package/public/assets/MessageBubble-Dy37JuVw.js +0 -4
- package/public/assets/MessageBubble-Dy37JuVw.js.map +0 -1
- package/public/assets/formatted-body-impl-CfnhWZAX.js +0 -3
- package/public/assets/formatted-body-impl-CfnhWZAX.js.map +0 -1
- package/public/assets/store-BZ2N51To.js.map +0 -1
- package/public/assets/tasks-DuH_JQJM.js +0 -2
- package/public/assets/tasks-DuH_JQJM.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./bundle-web-BLavPdXe.js","./chunk-CilyBKbf.js","./preload-helper-C_JMBXql.js","./lib-DHj_xjQT.js","./markdown-preview-impl-
|
|
2
|
-
import{r as e,t}from"./chunk-CilyBKbf.js";import{$ as n,$n as r,A as i,B as a,Bn as o,Bt as s,D as c,Dt as l,E as u,En as d,Et as f,F as p,Ft as m,G as h,H as g,Ht as _,In as v,It as y,Jt as b,K as x,L as S,Ln as C,Lt as ee,Mn as te,Mt as ne,N as w,Nn as T,On as re,Pn as ie,Qt as ae,R as oe,Rt as E,Sn as D,T as se,Tn as ce,U as le,Ut as ue,V as de,W as fe,X as pe,Xt as me,Y as he,Zt as ge,_ as _e,_t as ve,a as ye,bn as be,bt as xe,cn as Se,cr as Ce,d as we,dt as Te,en as O,er as k,fn as Ee,ft as De,g as Oe,gn as ke,gt as Ae,h as je,hn as Me,hr as Ne,ht as Pe,i as Fe,it as Ie,jn as Le,jt as Re,k as ze,n as Be,nr as Ve,nt as He,o as Ue,on as We,ot as Ge,p as Ke,pn as qe,pt as A,q as Je,qn as Ye,r as Xe,rn as Ze,rr as Qe,s as $e,sn as et,st as tt,t as nt,tt as rt,u as it,un as at,vn as ot,w as st,wn as ct,wt as lt,x as ut,xt as dt,y as ft,yt as pt,z as mt,zn as ht}from"./lucide-react-Dc3ZwCBi.js";import{t as gt}from"./react-dom-cLkVFBsS.js";import{c as _t,d as vt,f as yt,p as bt,s as xt,t as j}from"./store-BZ2N51To.js";import{a as St,d as Ct,f as wt,h as Tt,i as Et,n as Dt,p as Ot,r as kt,u as At}from"./types-DSwhOFcJ.js";import{B as jt,C as Mt,D as Nt,E as Pt,G as Ft,J as It,K as M,O as Lt,Q as Rt,S as zt,T as Bt,W as Vt,X as Ht,Y as Ut,a as Wt,c as Gt,ct as Kt,d as N,f as qt,h as Jt,i as Yt,j as Xt,k as Zt,lt as Qt,m as $t,n as en,o as tn,ot as nn,p as rn,q as an,r as on,t as sn,u as cn,w as ln,x as un,y as dn}from"./display-_5kFrHJh.js";import{n as fn,t as pn}from"./themes-DjSwmAZN.js";import{a as mn,i as hn,o as gn,r as _n,t as vn}from"./dist-Cs8X0P1d.js";import{n as yn,t as P}from"./dist-CQ0Z-TDi.js";import{i as bn,n as F,r as xn,t as Sn}from"./dist-ChDX_t12.js";import{t as Cn}from"./dist-DyNJNwpi.js";import{t as wn}from"./dist-CBMWGhWc.js";import{t as Tn}from"./dist-CmFeEXMe.js";import{a as En,i as Dn,n as On,o as kn,r as An,s as jn,t as Mn}from"./es2015-VnZ2kVIz.js";import{t as Nn}from"./dist-D2jvo5oA.js";import{t as Pn}from"./dist-mm7c7nBt.js";import{t as Fn}from"./dist-y03IwOrd.js";import{t as In}from"./dist-CDZZxxJq.js";import{a as Ln,i as Rn,n as zn,r as Bn,t as Vn}from"./dist-DV83j9tm.js";import{t as Hn}from"./dist-BiLuYU6G.js";import{t as I}from"./badge-BhUZ1cAb.js";import{t as L}from"./button-C-V4oij1.js";import{t as R}from"./input-CtLT7WXi.js";import{t as Un}from"./copy-button-BStzXgtd.js";import{t as z}from"./preload-helper-C_JMBXql.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 Wn=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,T());else{var t=n(l);t!==null&&ae(x,t.startTime-e)}}var S=!1,C=-1,ee=5,te=-1;function ne(){return g?!0:!(e.unstable_now()-te<ee)}function w(){if(g=!1,S){var t=e.unstable_now();te=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-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&&ae(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?T():S=!1}}}var T;if(typeof y==`function`)T=function(){y(w)};else if(typeof MessageChannel<`u`){var re=new MessageChannel,ie=re.port2;re.port1.onmessage=w,T=function(){ie.postMessage(null)}}else T=function(){_(w,0)};function ae(t,n){C=_(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`):ee=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(C),C=-1):h=!0,ae(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,T()))),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}}}})),Gn=t(((e,t)=>{t.exports=Wn()})),Kn=t((e=>{var t=Gn(),n=Ne(),r=gt();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`),C=Symbol.for(`react.suspense_list`),ee=Symbol.for(`react.memo`),te=Symbol.for(`react.lazy`),ne=Symbol.for(`react.activity`),w=Symbol.for(`react.memo_cache_sentinel`),T=Symbol.iterator;function re(e){return typeof e!=`object`||!e?null:(e=T&&e[T]||e[`@@iterator`],typeof e==`function`?e:null)}var ie=Symbol.for(`react.client.reference`);function ae(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ie?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 C: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 ee:return t=e.displayName||null,t===null?ae(e.type)||`Memo`:t;case te:t=e._payload,e=e._init;try{return ae(e(t))}catch{}}return null}var oe=Array.isArray,E=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,se={pending:!1,data:null,method:null,action:null},ce=[],le=-1;function ue(e){return{current:e}}function de(e){0>le||(e.current=ce[le],ce[le]=null,le--)}function fe(e,t){le++,ce[le]=e.current,e.current=t}var pe=ue(null),me=ue(null),he=ue(null),ge=ue(null);function _e(e,t){switch(fe(he,t),fe(me,e),fe(pe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?$(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=$(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}de(pe),fe(pe,e)}function ve(){de(pe),de(me),de(he)}function ye(e){e.memoizedState!==null&&fe(ge,e);var t=pe.current,n=Hd(t,e.type);t!==n&&(fe(me,e),fe(pe,n))}function be(e){me.current===e&&(de(pe),de(me)),ge.current===e&&(de(ge),Qf._currentValue=se)}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-BLavPdXe.js","./chunk-CilyBKbf.js","./preload-helper-C_JMBXql.js","./lib-DHj_xjQT.js","./markdown-preview-impl-Bo8ql-lO.js","./lib-BLoevhQO.js","./lucide-react-Dc3ZwCBi.js","./terminal-viewer-impl-Cig30gnt.js","./store-DwgQJjEv.js","./display-_5kFrHJh.js","./types-DSwhOFcJ.js","./button-C-V4oij1.js","./dist-Cs8X0P1d.js","./use-keyboard-viewport-DucYmqmP.js","./terminal-viewer-impl-BrP-ENHg.css","./formatted-body-impl-CBHoD82a.js","./overview-DyiH9eVP.js","./badge-BhUZ1cAb.js","./card-DAkf5Kzw.js","./chat-CP4x6Gcr.js","./react-dom-cLkVFBsS.js","./MessageBubble-BJllE_2c.js","./user-avatar-Ct6HEqZm.js","./PlanGraphPanel-CoK024n9.js","./branch-state-badge-CYWBVZDI.js","./copy-button-BStzXgtd.js","./input-CtLT7WXi.js","./agents-Bu1i1jH-.js","./dist-DV83j9tm.js","./dist-ChDX_t12.js","./dist-CQ0Z-TDi.js","./dist-mm7c7nBt.js","./dist-CDZZxxJq.js","./es2015-VnZ2kVIz.js","./dist-CmFeEXMe.js","./dist-CBMWGhWc.js","./managed-agents-YKqARLQn.js","./teams-CIqsg55S.js","./select-DhY0OvwP.js","./dist-BiLuYU6G.js","./dist-DyNJNwpi.js","./dist-D2jvo5oA.js","./dist-y03IwOrd.js","./agent-profiles-DzkjQaCS.js","./orchestrators-CW00iA0W.js","./workspaces-EI4N2N7L.js","./channels-IdC7jyLt.js","./connectors-Dngl_FJz.js","./integrations-BlSadMFC.js","./security-B0FTbGXU.js","./memory-BlftQACU.js","./activity-CBjg7NSP.js","./pairs-Ee8Npq67.js","./messages-DQu0Np7r.js","./work-queue-XWcDwe8G.js","./tasks-BvDfBcxZ.js","./automation-CcMveyvi.js","./analytics-Cc2GoEq_.js","./themes-DjSwmAZN.js","./insights-Du9X-nwA.js","./projects-CqeJsfB6.js","./prompt-settings-0fHJtGD5.js","./registry-QTLN8Jy-.js","./maintenance-KeCPGZG4.js","./settings-B2UEpdBi.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e,t}from"./chunk-CilyBKbf.js";import{$ as n,$n as r,A as i,B as a,Bn as o,Bt as s,D as c,Dt as l,E as u,En as d,Et as f,F as p,Ft as m,G as h,H as g,Ht as _,In as v,It as y,Jt as b,K as x,L as S,Ln as C,Lt as ee,Mn as te,Mt as ne,N as w,Nn as T,On as re,Pn as ie,Qt as ae,R as oe,Rt as E,Sn as D,T as se,Tn as ce,U as le,Ut as ue,V as de,W as fe,X as pe,Xt as me,Y as he,Zt as ge,_ as _e,_t as ve,a as ye,bn as be,bt as xe,cn as Se,cr as Ce,d as we,dt as Te,en as O,er as k,fn as Ee,ft as De,g as Oe,gn as ke,gt as Ae,h as je,hn as Me,hr as Ne,ht as Pe,i as Fe,it as Ie,jn as Le,jt as Re,k as ze,n as Be,nr as Ve,nt as He,o as Ue,on as We,ot as Ge,p as Ke,pn as qe,pt as A,q as Je,qn as Ye,r as Xe,rn as Ze,rr as Qe,s as $e,sn as et,st as tt,t as nt,tt as rt,u as it,un as at,vn as ot,w as st,wn as ct,wt as lt,x as ut,xt as dt,y as ft,yt as pt,z as mt,zn as ht}from"./lucide-react-Dc3ZwCBi.js";import{t as gt}from"./react-dom-cLkVFBsS.js";import{c as _t,d as vt,f as yt,p as bt,s as xt,t as j}from"./store-DwgQJjEv.js";import{a as St,d as Ct,f as wt,h as Tt,i as Et,n as Dt,p as Ot,r as kt,u as At}from"./types-DSwhOFcJ.js";import{B as jt,C as Mt,D as Nt,E as Pt,G as Ft,J as It,K as M,O as Lt,Q as Rt,S as zt,T as Bt,W as Vt,X as Ht,Y as Ut,a as Wt,c as Gt,ct as Kt,d as N,f as qt,h as Jt,i as Yt,j as Xt,k as Zt,lt as Qt,m as $t,n as en,o as tn,ot as nn,p as rn,q as an,r as on,t as sn,u as cn,w as ln,x as un,y as dn}from"./display-_5kFrHJh.js";import{n as fn,t as pn}from"./themes-DjSwmAZN.js";import{a as mn,i as hn,o as gn,r as _n,t as vn}from"./dist-Cs8X0P1d.js";import{n as yn,t as P}from"./dist-CQ0Z-TDi.js";import{i as bn,n as F,r as xn,t as Sn}from"./dist-ChDX_t12.js";import{t as Cn}from"./dist-DyNJNwpi.js";import{t as wn}from"./dist-CBMWGhWc.js";import{t as Tn}from"./dist-CmFeEXMe.js";import{a as En,i as Dn,n as On,o as kn,r as An,s as jn,t as Mn}from"./es2015-VnZ2kVIz.js";import{t as Nn}from"./dist-D2jvo5oA.js";import{t as Pn}from"./dist-mm7c7nBt.js";import{t as Fn}from"./dist-y03IwOrd.js";import{t as In}from"./dist-CDZZxxJq.js";import{a as Ln,i as Rn,n as zn,r as Bn,t as Vn}from"./dist-DV83j9tm.js";import{t as Hn}from"./dist-BiLuYU6G.js";import{t as I}from"./badge-BhUZ1cAb.js";import{t as L}from"./button-C-V4oij1.js";import{t as R}from"./input-CtLT7WXi.js";import{t as Un}from"./copy-button-BStzXgtd.js";import{t as z}from"./preload-helper-C_JMBXql.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 Wn=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,T());else{var t=n(l);t!==null&&ae(x,t.startTime-e)}}var S=!1,C=-1,ee=5,te=-1;function ne(){return g?!0:!(e.unstable_now()-te<ee)}function w(){if(g=!1,S){var t=e.unstable_now();te=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-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&&ae(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?T():S=!1}}}var T;if(typeof y==`function`)T=function(){y(w)};else if(typeof MessageChannel<`u`){var re=new MessageChannel,ie=re.port2;re.port1.onmessage=w,T=function(){ie.postMessage(null)}}else T=function(){_(w,0)};function ae(t,n){C=_(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`):ee=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(C),C=-1):h=!0,ae(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,T()))),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}}}})),Gn=t(((e,t)=>{t.exports=Wn()})),Kn=t((e=>{var t=Gn(),n=Ne(),r=gt();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`),C=Symbol.for(`react.suspense_list`),ee=Symbol.for(`react.memo`),te=Symbol.for(`react.lazy`),ne=Symbol.for(`react.activity`),w=Symbol.for(`react.memo_cache_sentinel`),T=Symbol.iterator;function re(e){return typeof e!=`object`||!e?null:(e=T&&e[T]||e[`@@iterator`],typeof e==`function`?e:null)}var ie=Symbol.for(`react.client.reference`);function ae(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ie?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 C: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 ee:return t=e.displayName||null,t===null?ae(e.type)||`Memo`:t;case te:t=e._payload,e=e._init;try{return ae(e(t))}catch{}}return null}var oe=Array.isArray,E=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,se={pending:!1,data:null,method:null,action:null},ce=[],le=-1;function ue(e){return{current:e}}function de(e){0>le||(e.current=ce[le],ce[le]=null,le--)}function fe(e,t){le++,ce[le]=e.current,e.current=t}var pe=ue(null),me=ue(null),he=ue(null),ge=ue(null);function _e(e,t){switch(fe(he,t),fe(me,e),fe(pe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?$(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=$(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}de(pe),fe(pe,e)}function ve(){de(pe),de(me),de(he)}function ye(e){e.memoizedState!==null&&fe(ge,e);var t=pe.current,n=Hd(t,e.type);t!==n&&(fe(me,e),fe(pe,n))}function be(e){me.current===e&&(de(pe),de(me)),ge.current===e&&(de(ge),Qf._currentValue=se)}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,13 +11,13 @@ 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 B.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Lr=`DialogDescriptionWarning`,Rr=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Fr(Lr).contentName}}.`;return B.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},zr=ur,Br=gr,Vr=vr,Hr=Sr,Ur=Dr,Wr=kr,Gr=jr,Kr=`rovingFocusGroup.onEntryFocus`,qr={bubbles:!1,cancelable:!0},Jr=`RovingFocusGroup`,[Yr,Xr,Zr]=Cn(Jr),[Qr,$r]=bn(Jr,[Zr]),[ei,ti]=Qr(Jr),ni=B.forwardRef((e,t)=>(0,V.jsx)(Yr.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,V.jsx)(Yr.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,V.jsx)(ri,{...e,ref:t})})}));ni.displayName=Jr;var ri=B.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=B.useRef(null),p=gn(t,f),m=Nn(a),[h,g]=wn({prop:o,defaultProp:s??null,onChange:c,caller:Jr}),[_,v]=B.useState(!1),y=Pn(l),b=Xr(n),x=B.useRef(!1),[S,C]=B.useState(0);return B.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(Kr,y),()=>e.removeEventListener(Kr,y)},[y]),(0,V.jsx)(ei,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:B.useCallback(e=>g(e),[g]),onItemShiftTab:B.useCallback(()=>v(!0),[]),onFocusableItemAdd:B.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:B.useCallback(()=>C(e=>e-1),[]),children:(0,V.jsx)(P.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:F(e.onMouseDown,()=>{x.current=!0}),onFocus:F(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(Kr,qr);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);li([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:F(e.onBlur,()=>v(!1))})})}),ii=`RovingFocusGroupItem`,ai=B.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=jn(),l=a||c,u=ti(ii,n),d=u.currentTabStopId===l,f=Xr(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return B.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,V.jsx)(Yr.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,V.jsx)(P.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:F(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:F(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:F(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=ci(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?ui(n,r+1):n.slice(r+1)}setTimeout(()=>li(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});ai.displayName=ii;var oi={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function si(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function ci(e,t,n){let r=si(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return oi[r]}function li(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function ui(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var di=ni,fi=ai,pi=[`Enter`,` `],mi=[`ArrowDown`,`PageUp`,`Home`],hi=[`ArrowUp`,`PageDown`,`End`],gi=[...mi,...hi],_i={ltr:[...pi,`ArrowRight`],rtl:[...pi,`ArrowLeft`]},vi={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},yi=`Menu`,[bi,xi,Si]=Cn(yi),[Ci,wi]=bn(yi,[Si,Ln,$r]),Ti=Ln(),Ei=$r(),[Di,Oi]=Ci(yi),[ki,Ai]=Ci(yi),ji=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Ti(t),[c,l]=B.useState(null),u=B.useRef(!1),d=Pn(a),f=Nn(i);return B.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,V.jsx)(Rn,{...s,children:(0,V.jsx)(Di,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,V.jsx)(ki,{scope:t,onClose:B.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};ji.displayName=yi;var H=`MenuAnchor`,Mi=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Ti(n);return(0,V.jsx)(Vn,{...i,...r,ref:t})});Mi.displayName=H;var Ni=`MenuPortal`,[Pi,Fi]=Ci(Ni,{forceMount:void 0}),Ii=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Oi(Ni,t);return(0,V.jsx)(Pi,{scope:t,forceMount:n,children:(0,V.jsx)(Tn,{present:n||a.open,children:(0,V.jsx)(Dn,{asChild:!0,container:i,children:r})})})};Ii.displayName=Ni;var Li=`MenuContent`,[Ri,zi]=Ci(Li),Bi=B.forwardRef((e,t)=>{let n=Fi(Li,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Oi(Li,e.__scopeMenu),o=Ai(Li,e.__scopeMenu);return(0,V.jsx)(bi.Provider,{scope:e.__scopeMenu,children:(0,V.jsx)(Tn,{present:r||a.open,children:(0,V.jsx)(bi.Slot,{scope:e.__scopeMenu,children:o.modal?(0,V.jsx)(Vi,{...i,ref:t}):(0,V.jsx)(Hi,{...i,ref:t})})})})}),Vi=B.forwardRef((e,t)=>{let n=Oi(Li,e.__scopeMenu),r=B.useRef(null),i=gn(t,r);return B.useEffect(()=>{let e=r.current;if(e)return Mn(e)},[]),(0,V.jsx)(Wi,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:F(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Hi=B.forwardRef((e,t)=>{let n=Oi(Li,e.__scopeMenu);return(0,V.jsx)(Wi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Ui=_n(`MenuContent.ScrollLock`),Wi=B.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=Oi(Li,n),_=Ai(Li,n),v=Ti(n),y=Ei(n),b=xi(n),[x,S]=B.useState(null),C=B.useRef(null),ee=gn(t,C,g.onContentChange),te=B.useRef(0),ne=B.useRef(``),w=B.useRef(0),T=B.useRef(null),re=B.useRef(`right`),ie=B.useRef(0),ae=m?On:B.Fragment,oe=m?{as:Ui,allowPinchZoom:!0}:void 0,E=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=Oa(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){ne.current=t,window.clearTimeout(te.current),t!==``&&(te.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};B.useEffect(()=>()=>window.clearTimeout(te.current),[]),An();let D=B.useCallback(e=>re.current===T.current?.side&&Aa(e,T.current?.area),[]);return(0,V.jsx)(Ri,{scope:n,searchRef:ne,onItemEnter:B.useCallback(e=>{D(e)&&e.preventDefault()},[D]),onItemLeave:B.useCallback(e=>{D(e)||(C.current?.focus(),S(null))},[D]),onTriggerLeave:B.useCallback(e=>{D(e)&&e.preventDefault()},[D]),pointerGraceTimerRef:w,onPointerGraceIntentChange:B.useCallback(e=>{T.current=e},[]),children:(0,V.jsx)(ae,{...oe,children:(0,V.jsx)(En,{asChild:!0,trapped:i,onMountAutoFocus:F(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,V.jsx)(kn,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,V.jsx)(di,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:F(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,V.jsx)(Bn,{role:`menu`,"aria-orientation":`vertical`,"data-state":Ca(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:ee,style:{outline:`none`,...h.style},onKeyDown:F(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&&E(e.key));let i=C.current;if(e.target!==i||!gi.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);hi.includes(e.key)&&a.reverse(),Ea(a)}),onBlur:F(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(te.current),ne.current=``)}),onPointerMove:F(e.onPointerMove,ja(e=>{let t=e.target,n=ie.current!==e.clientX;e.currentTarget.contains(t)&&n&&(re.current=e.clientX>ie.current?`right`:`left`,ie.current=e.clientX)}))})})})})})})});Bi.displayName=Li;var Gi=`MenuGroup`,Ki=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,V.jsx)(P.div,{role:`group`,...r,ref:t})});Ki.displayName=Gi;var qi=`MenuLabel`,Ji=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,V.jsx)(P.div,{...r,ref:t})});Ji.displayName=qi;var Yi=`MenuItem`,Xi=`menu.itemSelect`,Zi=B.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=B.useRef(null),o=Ai(Yi,e.__scopeMenu),s=zi(Yi,e.__scopeMenu),c=gn(t,a),l=B.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(Xi,{bubbles:!0,cancelable:!0});e.addEventListener(Xi,e=>r?.(e),{once:!0}),yn(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,V.jsx)(Qi,{...i,ref:c,disabled:n,onClick:F(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:F(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:F(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||pi.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});Zi.displayName=Yi;var Qi=B.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=zi(Yi,n),s=Ei(n),c=B.useRef(null),l=gn(t,c),[u,d]=B.useState(!1),[f,p]=B.useState(``);return B.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,V.jsx)(bi.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,V.jsx)(fi,{asChild:!0,...s,focusable:!r,children:(0,V.jsx)(P.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:F(e.onPointerMove,ja(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:F(e.onPointerLeave,ja(e=>o.onItemLeave(e))),onFocus:F(e.onFocus,()=>d(!0)),onBlur:F(e.onBlur,()=>d(!1))})})})}),$i=`MenuCheckboxItem`,ea=B.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,V.jsx)(ca,{scope:e.__scopeMenu,checked:n,children:(0,V.jsx)(Zi,{role:`menuitemcheckbox`,"aria-checked":wa(n)?`mixed`:n,...i,ref:t,"data-state":Ta(n),onSelect:F(i.onSelect,()=>r?.(wa(n)?!0:!n),{checkForDefaultPrevented:!1})})})});ea.displayName=$i;var ta=`MenuRadioGroup`,[na,ra]=Ci(ta,{value:void 0,onValueChange:()=>{}}),ia=B.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=Pn(r);return(0,V.jsx)(na,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,V.jsx)(Ki,{...i,ref:t})})});ia.displayName=ta;var aa=`MenuRadioItem`,oa=B.forwardRef((e,t)=>{let{value:n,...r}=e,i=ra(aa,e.__scopeMenu),a=n===i.value;return(0,V.jsx)(ca,{scope:e.__scopeMenu,checked:a,children:(0,V.jsx)(Zi,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Ta(a),onSelect:F(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});oa.displayName=aa;var sa=`MenuItemIndicator`,[ca,la]=Ci(sa,{checked:!1}),ua=B.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=la(sa,n);return(0,V.jsx)(Tn,{present:r||wa(a.checked)||a.checked===!0,children:(0,V.jsx)(P.span,{...i,ref:t,"data-state":Ta(a.checked)})})});ua.displayName=sa;var da=`MenuSeparator`,fa=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,V.jsx)(P.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});fa.displayName=da;var pa=`MenuArrow`,ma=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Ti(n);return(0,V.jsx)(zn,{...i,...r,ref:t})});ma.displayName=pa;var ha=`MenuSub`,[ga,_a]=Ci(ha),va=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=Oi(ha,t),o=Ti(t),[s,c]=B.useState(null),[l,u]=B.useState(null),d=Pn(i);return B.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,V.jsx)(Rn,{...o,children:(0,V.jsx)(Di,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,V.jsx)(ga,{scope:t,contentId:jn(),triggerId:jn(),trigger:s,onTriggerChange:c,children:n})})})};va.displayName=ha;var ya=`MenuSubTrigger`,ba=B.forwardRef((e,t)=>{let n=Oi(ya,e.__scopeMenu),r=Ai(ya,e.__scopeMenu),i=_a(ya,e.__scopeMenu),a=zi(ya,e.__scopeMenu),o=B.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=B.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return B.useEffect(()=>u,[u]),B.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,V.jsx)(Mi,{asChild:!0,...l,children:(0,V.jsx)(Qi,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Ca(n.open),...e,ref:mn(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:F(e.onPointerMove,ja(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:F(e.onPointerLeave,ja(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:F(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||_i[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});ba.displayName=ya;var xa=`MenuSubContent`,Sa=B.forwardRef((e,t)=>{let n=Fi(Li,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Oi(Li,e.__scopeMenu),o=Ai(Li,e.__scopeMenu),s=_a(xa,e.__scopeMenu),c=B.useRef(null),l=gn(t,c);return(0,V.jsx)(bi.Provider,{scope:e.__scopeMenu,children:(0,V.jsx)(Tn,{present:r||a.open,children:(0,V.jsx)(bi.Slot,{scope:e.__scopeMenu,children:(0,V.jsx)(Wi,{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:F(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:F(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:F(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=vi[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});Sa.displayName=xa;function Ca(e){return e?`open`:`closed`}function wa(e){return e===`indeterminate`}function Ta(e){return wa(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 Da(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Oa(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=Da(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 ka(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 Aa(e,t){return t?ka({x:e.clientX,y:e.clientY},t):!1}function ja(e){return t=>t.pointerType===`mouse`?e(t):void 0}var Ma=ji,Na=Mi,Pa=Ii,Fa=Bi,Ia=Ki,La=Ji,Ra=Zi,za=ea,Ba=ia,Va=oa,Ha=ua,Ua=fa,Wa=ma,Ga=ba,Ka=Sa,qa=`DropdownMenu`,[Ja,Ya]=bn(qa,[wi]),Xa=wi(),[Za,Qa]=Ja(qa),$a=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=Xa(t),l=B.useRef(null),[u,d]=wn({prop:i,defaultProp:a??!1,onChange:o,caller:qa});return(0,V.jsx)(Za,{scope:t,triggerId:jn(),triggerRef:l,contentId:jn(),open:u,onOpenChange:d,onOpenToggle:B.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,V.jsx)(Ma,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};$a.displayName=qa;var eo=`DropdownMenuTrigger`,to=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Qa(eo,n),o=Xa(n);return(0,V.jsx)(Na,{asChild:!0,...o,children:(0,V.jsx)(P.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:mn(t,a.triggerRef),onPointerDown:F(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:F(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});to.displayName=eo;var no=`DropdownMenuPortal`,ro=e=>{let{__scopeDropdownMenu:t,...n}=e,r=Xa(t);return(0,V.jsx)(Pa,{...r,...n})};ro.displayName=no;var io=`DropdownMenuContent`,ao=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Qa(io,n),a=Xa(n),o=B.useRef(!1);return(0,V.jsx)(Fa,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:F(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:F(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)`}})});ao.displayName=io;var oo=`DropdownMenuGroup`,so=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(Ia,{...i,...r,ref:t})});so.displayName=oo;var co=`DropdownMenuLabel`,lo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(La,{...i,...r,ref:t})});lo.displayName=co;var U=`DropdownMenuItem`,W=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(Ra,{...i,...r,ref:t})});W.displayName=U;var uo=`DropdownMenuCheckboxItem`,fo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(za,{...i,...r,ref:t})});fo.displayName=uo;var po=`DropdownMenuRadioGroup`,mo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(Ba,{...i,...r,ref:t})});mo.displayName=po;var ho=`DropdownMenuRadioItem`,go=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(Va,{...i,...r,ref:t})});go.displayName=ho;var _o=`DropdownMenuItemIndicator`,vo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(Ha,{...i,...r,ref:t})});vo.displayName=_o;var yo=`DropdownMenuSeparator`,bo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(Ua,{...i,...r,ref:t})});bo.displayName=yo;var xo=`DropdownMenuArrow`,So=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(Wa,{...i,...r,ref:t})});So.displayName=xo;var Co=`DropdownMenuSubTrigger`,wo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(Ga,{...i,...r,ref:t})});wo.displayName=Co;var To=`DropdownMenuSubContent`,Eo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(Ka,{...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)`}})});Eo.displayName=To;var Do=$a,Oo=to,ko=ro,Ao=ao,jo=lo,Mo=W,No=bo,Po=`Label`,Fo=B.forwardRef((e,t)=>(0,V.jsx)(P.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));Fo.displayName=Po;var Io=Fo;function Lo(e,t){return B.useReducer((e,n)=>t[e][n]??e,e)}var Ro=`ScrollArea`,[zo,Bo]=bn(Ro),[Vo,Ho]=zo(Ro),Uo=B.forwardRef((e,t)=>{let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=B.useState(null),[l,u]=B.useState(null),[d,f]=B.useState(null),[p,m]=B.useState(null),[h,g]=B.useState(null),[_,v]=B.useState(0),[y,b]=B.useState(0),[x,S]=B.useState(!1),[C,ee]=B.useState(!1),te=gn(t,e=>c(e)),ne=Nn(i);return(0,V.jsx)(Vo,{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:C,onScrollbarYEnabledChange:ee,onCornerWidthChange:v,onCornerHeightChange:b,children:(0,V.jsx)(P.div,{dir:ne,...o,ref:te,style:{position:`relative`,"--radix-scroll-area-corner-width":_+`px`,"--radix-scroll-area-corner-height":y+`px`,...e.style}})})});Uo.displayName=Ro;var Wo=`ScrollAreaViewport`,Go=B.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=Ho(Wo,n),s=gn(t,B.useRef(null),o.onViewportChange);return(0,V.jsxs)(V.Fragment,{children:[(0,V.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,V.jsx)(P.div,{"data-radix-scroll-area-viewport":``,...a,ref:s,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,V.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})});Go.displayName=Wo;var Ko=`ScrollAreaScrollbar`,qo=B.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Ho(Ko,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return B.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,V.jsx)(Jo,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,V.jsx)(Yo,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,V.jsx)(Xo,{...r,ref:t,forceMount:n}):i.type===`always`?(0,V.jsx)(Zo,{...r,ref:t}):null});qo.displayName=Ko;var Jo=B.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Ho(Ko,e.__scopeScrollArea),[a,o]=B.useState(!1);return B.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,V.jsx)(Tn,{present:n||a,children:(0,V.jsx)(Xo,{"data-state":a?`visible`:`hidden`,...r,ref:t})})}),Yo=B.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Ho(Ko,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=_s(()=>c(`SCROLL_END`),100),[s,c]=Lo(`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 B.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),B.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,V.jsx)(Tn,{present:n||s!==`hidden`,children:(0,V.jsx)(Zo,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:F(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:F(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})}),Xo=B.forwardRef((e,t)=>{let n=Ho(Ko,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=B.useState(!1),s=e.orientation===`horizontal`,c=_s(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return vs(n.viewport,c),vs(n.content,c),(0,V.jsx)(Tn,{present:r||a,children:(0,V.jsx)(Zo,{"data-state":a?`visible`:`hidden`,...i,ref:t})})}),Zo=B.forwardRef((e,t)=>{let{orientation:n=`vertical`,...r}=e,i=Ho(Ko,e.__scopeScrollArea),a=B.useRef(null),o=B.useRef(0),[s,c]=B.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=us(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 fs(e,o.current,s,t)}return n===`horizontal`?(0,V.jsx)(Qo,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=ps(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,V.jsx)($o,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=ps(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}),Qo=B.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=Ho(Ko,e.__scopeScrollArea),[o,s]=B.useState(),c=B.useRef(null),l=gn(t,c,a.onScrollbarXChange);return B.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,V.jsx)(ns,{"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":ds(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),hs(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:ls(o.paddingLeft),paddingEnd:ls(o.paddingRight)}})}})}),$o=B.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=Ho(Ko,e.__scopeScrollArea),[o,s]=B.useState(),c=B.useRef(null),l=gn(t,c,a.onScrollbarYChange);return B.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,V.jsx)(ns,{"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":ds(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),hs(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:ls(o.paddingTop),paddingEnd:ls(o.paddingBottom)}})}})}),[es,ts]=zo(Ko),ns=B.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=Ho(Ko,n),[m,h]=B.useState(null),g=gn(t,e=>h(e)),_=B.useRef(null),v=B.useRef(``),y=p.viewport,b=r.content-r.viewport,x=Pn(u),S=Pn(c),C=_s(d,10);function ee(e){_.current&&l({x:e.clientX-_.current.left,y:e.clientY-_.current.top})}return B.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]),B.useEffect(S,[r,S]),vs(m,C),vs(p.content,C),(0,V.jsx)(es,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:Pn(a),onThumbPointerUp:Pn(o),onThumbPositionChange:S,onThumbPointerDown:Pn(s),children:(0,V.jsx)(P.div,{...f,ref:g,style:{position:`absolute`,...f.style},onPointerDown:F(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`),ee(e))}),onPointerMove:F(e.onPointerMove,ee),onPointerUp:F(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})})})}),rs=`ScrollAreaThumb`,is=B.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=ts(rs,e.__scopeScrollArea);return(0,V.jsx)(Tn,{present:n||i.hasThumb,children:(0,V.jsx)(as,{ref:t,...r})})}),as=B.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:r,...i}=e,a=Ho(rs,n),o=ts(rs,n),{onThumbPositionChange:s}=o,c=gn(t,e=>o.onThumbChange(e)),l=B.useRef(void 0),u=_s(()=>{l.current&&=(l.current(),void 0)},100);return B.useEffect(()=>{let e=a.viewport;if(e){let t=()=>{u(),l.current||(l.current=gs(e,s),s())};return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,V.jsx)(P.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:F(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:F(e.onPointerUp,o.onThumbPointerUp)})});is.displayName=rs;var os=`ScrollAreaCorner`,ss=B.forwardRef((e,t)=>{let n=Ho(os,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,V.jsx)(cs,{...e,ref:t}):null});ss.displayName=os;var cs=B.forwardRef((e,t)=>{let{__scopeScrollArea:n,...r}=e,i=Ho(os,n),[a,o]=B.useState(0),[s,c]=B.useState(0),l=!!(a&&s);return vs(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),vs(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),l?(0,V.jsx)(P.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 ls(e){return e?parseInt(e,10):0}function us(e,t){let n=e/t;return isNaN(n)?0:n}function ds(e){let t=us(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function fs(e,t,n,r=`ltr`){let i=ds(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 ms([c,l],d)(e)}function ps(e,t,n=`ltr`){let r=ds(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=Hn(e,n===`ltr`?[0,o]:[o*-1,0]);return ms([0,o],[0,s])(c)}function ms(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 hs(e,t){return e>0&&e<t}var gs=(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 _s(e,t){let n=Pn(e),r=B.useRef(0);return B.useEffect(()=>()=>window.clearTimeout(r.current),[]),B.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function vs(e,t){let n=Pn(t);Sn(()=>{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 ys=Uo,bs=Go,xs=ss,Ss=`Separator`,Cs=`horizontal`,ws=[`horizontal`,`vertical`],Ts=B.forwardRef((e,t)=>{let{decorative:n,orientation:r=Cs,...i}=e,a=Es(r)?r:Cs,o=n?{role:`none`}:{"aria-orientation":a===`vertical`?a:void 0,role:`separator`};return(0,V.jsx)(P.div,{"data-orientation":a,...o,...i,ref:t})});Ts.displayName=Ss;function Es(e){return ws.includes(e)}var Ds=Ts,Os=`Switch`,[ks,As]=bn(Os),[js,Ms]=ks(Os),Ns=B.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]=B.useState(null),m=gn(t,e=>p(e)),h=B.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=wn({prop:i,defaultProp:a??!1,onChange:l,caller:Os});return(0,V.jsxs)(js,{scope:n,checked:_,disabled:s,children:[(0,V.jsx)(P.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":Rs(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:F(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,V.jsx)(Ls,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});Ns.displayName=Os;var Ps=`SwitchThumb`,Fs=B.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=Ms(Ps,n);return(0,V.jsx)(P.span,{"data-state":Rs(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});Fs.displayName=Ps;var Is=`SwitchBubbleInput`,Ls=B.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=B.useRef(null),s=gn(o,a),c=Fn(n),l=In(t);return B.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,V.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}})});Ls.displayName=Is;function Rs(e){return e?`checked`:`unchecked`}var zs=Ns,Bs=Fs,Vs=`Tabs`,[Hs,Us]=bn(Vs,[$r]),Ws=$r(),[Gs,Ks]=Hs(Vs),qs=B.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=Nn(s),[d,f]=wn({prop:r,onChange:i,defaultProp:a??``,caller:Vs});return(0,V.jsx)(Gs,{scope:n,baseId:jn(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,V.jsx)(P.div,{dir:u,"data-orientation":o,...l,ref:t})})});qs.displayName=Vs;var Js=`TabsList`,Ys=B.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=Ks(Js,n),o=Ws(n);return(0,V.jsx)(di,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,V.jsx)(P.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});Ys.displayName=Js;var Xs=`TabsTrigger`,Zs=B.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=Ks(Xs,n),s=Ws(n),c=ec(o.baseId,r),l=tc(o.baseId,r),u=r===o.value;return(0,V.jsx)(fi,{asChild:!0,...s,focusable:!i,active:u,children:(0,V.jsx)(P.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:F(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:F(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:F(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});Zs.displayName=Xs;var Qs=`TabsContent`,$s=B.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=Ks(Qs,n),c=ec(s.baseId,r),l=tc(s.baseId,r),u=r===s.value,d=B.useRef(u);return B.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,V.jsx)(Tn,{present:i||u,children:({present:n})=>(0,V.jsx)(P.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})})});$s.displayName=Qs;function ec(e,t){return`${e}-trigger-${t}`}function tc(e,t){return`${e}-content-${t}`}var nc=qs,rc=Ys,ic=Zs,ac=$s,[oc,sc]=bn(`Tooltip`,[Ln]),cc=Ln(),lc=`TooltipProvider`,uc=700,dc=`tooltip.open`,[fc,pc]=oc(lc),mc=e=>{let{__scopeTooltip:t,delayDuration:n=uc,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=B.useRef(!0),s=B.useRef(!1),c=B.useRef(0);return B.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,V.jsx)(fc,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:B.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:B.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:B.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};mc.displayName=lc;var hc=`Tooltip`,[gc,_c]=oc(hc),vc=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=pc(hc,e.__scopeTooltip),l=cc(t),[u,d]=B.useState(null),f=jn(),p=B.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=B.useRef(!1),[_,v]=wn({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(dc))):c.onClose(),a?.(e)},caller:hc}),y=B.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=B.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=B.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=B.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return B.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,V.jsx)(Rn,{...l,children:(0,V.jsx)(gc,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:B.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:B.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};vc.displayName=hc;var yc=`TooltipTrigger`,bc=B.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=_c(yc,n),a=pc(yc,n),o=cc(n),s=gn(t,B.useRef(null),i.onTriggerChange),c=B.useRef(!1),l=B.useRef(!1),u=B.useCallback(()=>c.current=!1,[]);return B.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,V.jsx)(Vn,{asChild:!0,...o,children:(0,V.jsx)(P.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:F(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:F(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:F(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:F(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:F(e.onBlur,i.onClose),onClick:F(e.onClick,i.onClose)})})});bc.displayName=yc;var xc=`TooltipPortal`,[Sc,Cc]=oc(xc,{forceMount:void 0}),wc=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=_c(xc,t);return(0,V.jsx)(Sc,{scope:t,forceMount:n,children:(0,V.jsx)(Tn,{present:n||a.open,children:(0,V.jsx)(Dn,{asChild:!0,container:i,children:r})})})};wc.displayName=xc;var Tc=`TooltipContent`,Ec=B.forwardRef((e,t)=>{let n=Cc(Tc,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=_c(Tc,e.__scopeTooltip);return(0,V.jsx)(Tn,{present:r||o.open,children:o.disableHoverableContent?(0,V.jsx)(jc,{side:i,...a,ref:t}):(0,V.jsx)(Dc,{side:i,...a,ref:t})})}),Dc=B.forwardRef((e,t)=>{let n=_c(Tc,e.__scopeTooltip),r=pc(Tc,e.__scopeTooltip),i=B.useRef(null),a=gn(t,i),[o,s]=B.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=B.useCallback(()=>{s(null),d(!1)},[d]),p=B.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Fc(r,Pc(r,n.getBoundingClientRect())),a=Ic(t.getBoundingClientRect());s(Rc([...i,...a])),d(!0)},[d]);return B.useEffect(()=>()=>f(),[f]),B.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]),B.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=!Lc(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,V.jsx)(jc,{...e,ref:a})}),[Oc,kc]=oc(hc,{isInside:!1}),Ac=hn(`TooltipContent`),jc=B.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=_c(Tc,n),l=cc(n),{onClose:u}=c;return B.useEffect(()=>(document.addEventListener(dc,u),()=>document.removeEventListener(dc,u)),[u]),B.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,V.jsx)(kn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,V.jsxs)(Bn,{"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,V.jsx)(Ac,{children:r}),(0,V.jsx)(Oc,{scope:n,isInside:!0,children:(0,V.jsx)(ir,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});Ec.displayName=Tc;var Mc=`TooltipArrow`,Nc=B.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=cc(n);return kc(Mc,n).isInside?null:(0,V.jsx)(zn,{...i,...r,ref:t})});Nc.displayName=Mc;function Pc(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 Fc(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 Ic(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 Lc(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 Rc(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)),zc(t)}function zc(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 Bc=mc,Vc=vc,Hc=bc,Uc=wc,Wc=Ec,Gc=Nc;function Kc({delayDuration:e=0,...t}){return(0,V.jsx)(Bc,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function qc({...e}){return(0,V.jsx)(Vc,{"data-slot":`tooltip`,...e})}function Jc({...e}){return(0,V.jsx)(Hc,{"data-slot":`tooltip-trigger`,...e})}function Yc({className:e,sideOffset:t=0,children:n,...r}){return(0,V.jsx)(Uc,{children:(0,V.jsxs)(Wc,{"data-slot":`tooltip-content`,sideOffset:t,className:k(`z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 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-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 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,children:[n,(0,V.jsx)(Gc,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}function G(e){return j(e)}function Xc(){let e=G(e=>e.pairs);return(0,B.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 Zc(e){let t=G(e=>e.messages),n=G(e=>e.tasks),r=G(e=>e.pairs),i=G(e=>e.inboxReadCursors),a=G(e=>e.inboxArchivedThreads);return(0,B.useMemo)(()=>{if(!e)return{unread:0,needsHumanResponse:!1,pendingPairInvite:!1,claimableTasks:0,total:0,score:0};let o=t.filter(t=>dn(t)===e.id&&!Pt(t)),s=Number(a[e.id]||0),c=s>=o.filter(e=>Bt(e)&&zt(e)).reduce((e,t)=>Math.max(e,t.id),0)&&s>0?0:o.filter(t=>Lt(i,e.id,t)).length,l=on(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=>ln(t)&&cn(t.target,e)).length+t.filter(t=>Mt(t)&&cn(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 Qc(){let e=G(e=>e.agents),t=G(e=>e.showBuiltIns),n=G(e=>e.showOffline),r=G(e=>e.agentSort),i=G(e=>e.agentSortDir),a=G(e=>e.agentPresetFilter),o=G(e=>e.agentStatusFilter),s=G(e=>e.agentTagFilter),c=G(e=>e.agentHostFilter),l=G(e=>e.managedPolicies),u=G(e=>e.pairs);return(0,B.useMemo)(()=>{let d=Ht(e,t,l);if(a){let e=$c(u);d=el(d,a,vt.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`?N(e).localeCompare(N(t))*f:r===`lastSeen`?(new Date(t.lastSeen).getTime()-new Date(e.lastSeen).getTime())*f||N(e).localeCompare(N(t)):r===`created`?(new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime())*f||N(e).localeCompare(N(t)):((Qt[e.status]??9)-(Qt[t.status]??9))*f||N(e).localeCompare(N(t)))},[e,t,n,l,r,i,a,o,s,c,u,bt()])}function $c(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 el(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`||un(n,e));case`paired`:return e.filter(e=>!!r[e.id]);case`unpaired`:return e.filter(e=>!r[e.id]);default:return Ot().includes(t)?e.filter(e=>tn(e)===t):e}}function tl(){let e=G(e=>e.messages),t=G(e=>e.inboxReadCursors),n=G(e=>e.inboxArchivedThreads),r=G(e=>e.inboxDrafts),i=G(e=>e.agentsById),a=G(e=>e.coordinatorMutes);return(0,B.useMemo)(()=>{let o=new Map;for(let t of e){if(Pt(t))continue;let e=dn(t);e&&(o.has(e)||o.set(e,{id:e,peer:e,messages:[],lastMessage:null,previewMessage:null,attention:{unread:0,needsHumanResponse:!1,score:0},archived:!1,draft:``}),o.get(e).messages.push(t))}for(let e of o.values()){e.messages.sort((e,t)=>e.id-t.id),e.lastMessage=e.messages[e.messages.length-1]||null;let o=null;for(let t=e.messages.length-1;t>=0;t--){let n=e.messages[t];if(n&&!Nt(n)){o=n;break}}e.previewMessage=o||e.lastMessage;let s=a.includes(e.peer),c=s?0:e.messages.filter(n=>Lt(t,e.peer,n)).length,l=s?!1:on(i[e.peer]);e.attention={unread:c,needsHumanResponse:l,score:c*10+(l?8:0)};let u=Number(n[e.peer]||0);e.archived=!!(e.lastMessage?.id&&u>=e.lastMessage.id),e.draft=r[e.peer]||``}return[...o.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,a])}function nl(){let e=tl(),t=G(e=>e.agents),n=G(e=>e.showBuiltIns),r=G(e=>e.showOffline),i=G(e=>e.managedPolicies),a=G(e=>e.pairs),o=G(e=>e.tasks),s=G(e=>e.messages),c=(0,B.useMemo)(()=>new Set(Ht(t,n,i).filter(e=>r||e.status!==`offline`).map(e=>e.id)),[t,n,r,i]);return(0,B.useMemo)(()=>{let l=e.filter(e=>!e.archived&&c.has(e.peer)).reduce((e,t)=>e+(t.attention.unread||0),0),u=Ht(t,n,i).filter(e=>(r||e.status!==`offline`)&&on(e)).length,d=a.filter(e=>e.status===`pending`).length,f=o.filter(ln).length+s.filter(Mt).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 rl(){let e=G(e=>e.agents),t=G(e=>e.showBuiltIns),n=G(e=>e.managedPolicies);return(0,B.useMemo)(()=>Ht(e,t,n).filter(e=>e.status!==`offline`).length,[e,t,n])}function il(){let e=G(e=>e.agents);return(0,B.useMemo)(()=>e.filter(e=>e.status===`busy`).length,[e])}function al(){let e=G(e=>e.agents),t=G(e=>e.showBuiltIns),n=G(e=>e.showOffline),r=G(e=>e.managedPolicies);return(0,B.useMemo)(()=>{let i=Ht(e,t,r);return n?i:i.filter(e=>e.status!==`offline`)},[e,t,n,r])}function ol(){let e=G(e=>e.agents),t=G(e=>e.showBuiltIns),n=G(e=>e.managedPolicies);return(0,B.useMemo)(()=>[...new Set(Ht(e,t,n).map(e=>e.machine).filter(Boolean))].sort(),[e,t,n])}function sl(){let e=G(e=>e.agents),t=G(e=>e.showBuiltIns),n=G(e=>e.managedPolicies);return(0,B.useMemo)(()=>[...new Set(Ht(e,t,n).flatMap(e=>e.tags||[]))],[e,t,n])}function cl(){let e=G(e=>e.tasks),t=G(e=>e.messages);return(0,B.useMemo)(()=>{let n=e.filter(e=>(e.kind??`claim`)===`claim`).filter(e=>!Rt.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:ln(e),task:e})),r=t.filter(Mt).map(e=>({id:`message-`+e.id,sourceType:`message`,title:e.subject||`Claimable message #`+e.id,body:Zt(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:Mt(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?an(e.updatedAt)-an(t.updatedAt):i})},[e,t])}function ll(){let e=G(e=>e.commandQuery),t=G(e=>e.agents),n=G(e=>e.agentsById),r=G(e=>e.showBuiltIns),i=G(e=>e.showOffline),a=G(e=>e.managedPolicies);return(0,B.useMemo)(()=>{let n=Ht(t,r,a).filter(e=>i||e.status!==`offline`),o=[...new Set(n.flatMap(e=>e.tags||[]))],s=Ce(),c=[ul(`open-chat`,`Open chat`,`Human console`,`MessageCircle`,`openView`,{view:`chat`}),ul(`open-work`,`Open work queue`,`Claimable messages and tasks`,`ListChecks`,`openView`,{view:`work`}),ul(`open-workspaces`,`Open workspaces`,`Agent worktrees and merge state`,`GitBranch`,`openView`,{view:`workspaces`}),ul(`show-stale`,`Show stale agents`,`Filter agents to offline or stale`,`Filter`,`agentPreset`,{preset:`offline_stale`}),ul(`copy-url`,`Copy relay URL`,s,`Copy`,`copy`,{value:s}),ul(`export-md`,`Export timeline as Markdown`,`Activity audit trace`,`FileDown`,`exportActivity`,{format:`markdown`}),ul(`export-json`,`Export timeline as JSON`,`Activity audit trace`,`Braces`,`exportActivity`,{format:`json`}),...n.slice(0,12).map(e=>ul(`msg-`+e.id,`Message agent: `+N(e),e.id,`Send`,`messageAgent`,{agentId:e.id})),...n.filter(e=>e.providerCapabilities?.liveSession?.inject===!0).slice(0,8).map(e=>ul(`pair-`+e.id,`Pair: `+N(e),e.id,`Link`,`pairAgent`,{agentId:e.id})),...o.map(e=>ul(`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 ul(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 dl({className:e,size:t=`default`,...n}){return(0,V.jsx)(zs,{"data-slot":`switch`,"data-size":t,className:k(`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,V.jsx)(Bs,{"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 fl({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,V.jsx)(Ds,{"data-slot":`separator`,decorative:n,orientation:t,className:k(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...r})}function pl({...e}){return(0,V.jsx)(Do,{"data-slot":`dropdown-menu`,...e})}function ml({...e}){return(0,V.jsx)(Oo,{"data-slot":`dropdown-menu-trigger`,...e})}function hl({className:e,align:t=`start`,sideOffset:n=4,...r}){return(0,V.jsx)(ko,{children:(0,V.jsx)(Ao,{"data-slot":`dropdown-menu-content`,sideOffset:n,align:t,className:k(`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 gl({className:e,inset:t,variant:n=`default`,...r}){return(0,V.jsx)(Mo,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:k(`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 _l({className:e,inset:t,...n}){return(0,V.jsx)(jo,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:k(`px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7`,e),...n})}function vl({className:e,...t}){return(0,V.jsx)(No,{"data-slot":`dropdown-menu-separator`,className:k(`-mx-1 my-1 h-px bg-border`,e),...t})}var yl={LayoutDashboard:xe,MessageCircle:Ie,Bot:C,Server:c,MessagesSquare:rt,Plug:a,PlugZap:g,Activity:r,Link:Ae,Mail:tt,ListChecks:Pe,ClipboardList:at,CalendarClock:Le,AreaChart:re,Settings:u,Workflow:$e,BrainCircuit:ie,FolderTree:y,Shield:st,Wrench:Ue,UserCog:Ke,Lightbulb:pt,Users:it,Boxes:v,PackagePlus:pe,FileText:ue};function bl(e){return new Date(e.createdAt).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}var xl=[[`messages`,`Messages`],[`replies`,`Replies`],[`errors`,`Errors`]];function Sl(){let e=j(e=>e.notifications),t=j(e=>e.notificationUnread),n=j(e=>e.notificationSettings),r=j(e=>e.notificationPermission),i=j(e=>e.set),a=j(e=>e.openNotification),s=j(e=>e.markNotificationsRead),c=j(e=>e.clearNotifications),l=j(e=>e.requestBrowserNotifications),u=t>0?o:ht;function f(e){i({notificationSettings:{...n,...e}})}return(0,V.jsxs)(pl,{onOpenChange:e=>{e&&s()},children:[(0,V.jsx)(ml,{asChild:!0,children:(0,V.jsxs)(`button`,{className:`relative flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors w-full`,children:[(0,V.jsx)(u,{className:`w-3.5 h-3.5`}),(0,V.jsx)(`span`,{children:`Notifications`}),t>0&&(0,V.jsx)(I,{variant:`destructive`,className:`ml-auto text-[10px] px-1.5 py-0`,children:t})]})}),(0,V.jsxs)(hl,{align:`start`,side:`right`,className:`w-80 p-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1.5 py-1`,children:[(0,V.jsx)(_l,{className:`p-0`,children:`Notifications`}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,V.jsx)(`button`,{type:`button`,title:`Mark read`,onClick:s,className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,children:(0,V.jsx)(d,{className:`h-3.5 w-3.5`})}),(0,V.jsx)(`button`,{type:`button`,title:`Clear`,onClick:c,className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,children:(0,V.jsx)(Oe,{className:`h-3.5 w-3.5`})})]})]}),(0,V.jsxs)(`div`,{className:`px-1.5 py-1.5 space-y-2`,children:[(0,V.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`In-app notifications`}),(0,V.jsx)(dl,{size:`sm`,checked:n.enabled,onCheckedChange:e=>f({enabled:e})})]}),(0,V.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Browser notifications`}),(0,V.jsx)(dl,{size:`sm`,checked:n.browserEnabled&&r===`granted`,disabled:r===`unsupported`,onCheckedChange:e=>{e&&r!==`granted`?l():f({browserEnabled:e})}})]}),(0,V.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,children:xl.map(([e,t])=>(0,V.jsx)(`button`,{type:`button`,onClick:()=>f({[e]:!n[e]}),className:k(`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,V.jsx)(vl,{}),(0,V.jsx)(`div`,{className:`max-h-80 overflow-y-auto`,children:e.length===0?(0,V.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,V.jsxs)(gl,{onSelect:t=>{t.preventDefault(),a(e)},className:`flex flex-col items-start gap-0.5 px-2 py-2`,children:[(0,V.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[(0,V.jsx)(`span`,{className:k(`h-1.5 w-1.5 rounded-full`,e.severity===`error`?`bg-red-400`:e.severity===`warning`?`bg-yellow-400`:`bg-blue-400`)}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium`,children:e.title}),(0,V.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:bl(e)})]}),(0,V.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:e.body}),e.routing?.reason&&(0,V.jsxs)(`span`,{className:`line-clamp-1 text-[10px] text-muted-foreground/80`,children:[`routed because `,e.routing.reason]})]},e.id))})]})]})}function Cl(){let e=j(e=>e.theme),t=j(e=>e.set);return(0,V.jsxs)(pl,{children:[(0,V.jsx)(ml,{asChild:!0,children:(0,V.jsxs)(`button`,{className:`flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors w-full`,children:[(0,V.jsx)(he,{className:`w-3.5 h-3.5`}),(0,V.jsx)(`span`,{children:`Theme`}),(0,V.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:pn.find(t=>t.id===e)?.label})]})}),(0,V.jsx)(hl,{align:`start`,side:`right`,className:`w-40`,children:pn.map(n=>(0,V.jsxs)(gl,{onSelect:()=>t({theme:n.id}),children:[(0,V.jsx)(`span`,{className:`flex-1`,children:n.label}),e===n.id&&(0,V.jsx)(ce,{className:`w-3.5 h-3.5 text-primary`})]},n.id))})]})}function wl(){let e=j(e=>e.view),t=j(e=>e.switchView),n=j(e=>e.connected),r=j(e=>e.showOffline),i=j(e=>e.showBuiltIns),a=j(e=>e.autoRefresh),o=j(e=>e.stats),s=j(e=>e.openCommandPalette),c=j(e=>e.set),l=j(e=>e.startAutoRefresh),u=j(e=>e.stopAutoRefresh),d=nl(),f=rl();function p(e){return e===`overview`&&d.total>0?(0,V.jsx)(I,{variant:`destructive`,className:`ml-auto text-[10px] px-1.5 py-0`,children:d.total}):e===`chat`&&d.unreadInbox>0?(0,V.jsx)(I,{variant:`destructive`,className:`ml-auto text-[10px] px-1.5 py-0`,children:d.unreadInbox}):e===`agents`?(0,V.jsx)(I,{variant:`secondary`,className:`ml-auto text-[10px] px-1.5 py-0`,children:f}):e===`pairs`&&d.pendingPairInvites>0?(0,V.jsx)(I,{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,V.jsx)(I,{className:`ml-auto text-[10px] px-1.5 py-0 bg-yellow-500/20 text-yellow-400`,children:d.claimableTasks}):null}return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`nav`,{className:`flex-1 overflow-y-auto py-2 px-2`,children:nn.map(n=>{let r=yl[n.icon]||C;return(0,V.jsxs)(`button`,{onClick:()=>t(n.key),className:k(`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,V.jsx)(r,{className:`w-4 h-4 shrink-0`}),n.label,p(n.key)]},n.key)})}),(0,V.jsxs)(`div`,{className:`mt-auto border-t border-border p-4 space-y-3 text-xs`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:k(`w-2 h-2 rounded-full`,n?`bg-emerald-500`:`bg-red-500 animate-pulse`)}),(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:n?`Live`:`Reconnecting...`})]}),(0,V.jsxs)(`button`,{onClick:s,className:`flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors w-full`,children:[(0,V.jsx)(We,{className:`w-3.5 h-3.5`}),(0,V.jsx)(`span`,{children:`Command palette`}),(0,V.jsx)(`kbd`,{className:`ml-auto text-[10px] bg-muted px-1.5 py-0.5 rounded`,children:`⌘K`})]}),(0,V.jsx)(Sl,{}),(0,V.jsx)(Cl,{}),(0,V.jsx)(fl,{}),(0,V.jsxs)(`label`,{className:`flex items-center justify-between cursor-pointer`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Show offline`}),(0,V.jsx)(dl,{checked:r,onCheckedChange:e=>c({showOffline:e})})]}),(0,V.jsxs)(`label`,{className:`flex items-center justify-between cursor-pointer`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`System agents`}),(0,V.jsx)(dl,{checked:i,onCheckedChange:e=>c({showBuiltIns:e})})]}),(0,V.jsxs)(`label`,{className:`flex items-center justify-between cursor-pointer`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Auto refresh`}),(0,V.jsx)(dl,{checked:a,onCheckedChange:e=>{c({autoRefresh:e}),e?l():u()}})]}),o.version&&(0,V.jsxs)(`div`,{className:`text-muted-foreground pt-1`,children:[`v`,o.version]})]})]})}function Tl(){return(0,V.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,V.jsxs)(`div`,{className:`px-5 py-4 font-bold text-base border-b border-border flex items-center gap-2`,children:[(0,V.jsx)(oe,{className:`w-4 h-4 text-primary`}),`Agent Relay`]}),(0,V.jsx)(wl,{})]})}function El(){let e=j(e=>e.mobileMenuOpen),t=j(e=>e.set);return(0,B.useEffect)(()=>{if(!e)return;function n(e){e.key===`Escape`&&t({mobileMenuOpen:!1})}return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e]),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:k(`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,V.jsxs)(`aside`,{inert:!e,className:k(`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,V.jsxs)(`div`,{className:`px-5 py-4 font-bold text-base border-b border-border flex items-center gap-2`,children:[(0,V.jsx)(oe,{className:`w-4 h-4 text-primary`}),`Agent Relay`,(0,V.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,V.jsx)(ye,{className:`w-4 h-4`})})]}),(0,V.jsx)(wl,{})]})]})}var Dl=500*1024,Ol={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`},kl={".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`},Al=null;function jl(){return Al??=z(()=>import(`./bundle-web-BLavPdXe.js`),__vite__mapDeps([0,1,2,3]),import.meta.url),Al}function Ml(e){return new TextEncoder().encode(e).length}function Nl(e){return e.split(`/`).filter(Boolean).pop()||e}function Pl(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 Fl(e,t,n,r){if(n)return n;let i=Nl(e).toLowerCase();if(kl[i])return kl[i];if(i.endsWith(`.d.ts`))return`typescript`;let a=Pl(r);if(a)return a;let o=i.includes(`.`)?i.slice(i.lastIndexOf(`.`)+1):``;return o&&Ol[o]?Ol[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 Il(e,t,n,r){let i=Fl(e,t,n,r);return!!(i&&i!==`text`&&i!==`log`)}var Ll=(0,B.memo)(function({content:e,path:t,mediaType:n,languageHint:r,compact:i=!1}){let a=j(e=>e.theme),o=pn.find(e=>e.id===a)?.dark??!0,s=(0,B.useMemo)(()=>Fl(t,n,r,e)||`text`,[e,r,n,t]),c=Ml(e)>Dl,[l,u]=(0,B.useState)(``),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(!1);function h(){return(0,V.jsx)(Un,{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,B.useEffect)(()=>{if(c||s===`text`||s===`log`){u(``),f(!1),m(!1);return}let t=!1;return f(!0),m(!1),jl().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,V.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-sm text-muted-foreground`,children:[(0,V.jsx)(A,{className:`h-4 w-4 animate-spin`}),`Highlighting`]}):c||p||!l?(0,V.jsxs)(`div`,{className:`group/code relative`,children:[h(),(0,V.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap break-words font-mono text-xs leading-5 ${i?`p-3`:`p-4`}`,children:e||` `})]}):(0,V.jsxs)(`div`,{className:`group/code relative`,children:[h(),(0,V.jsx)(`div`,{className:`code-preview overflow-auto font-mono text-xs leading-5 ${i?`p-3`:`p-4`}`,dangerouslySetInnerHTML:{__html:l}})]})}),Rl=(0,B.lazy)(()=>z(()=>import(`./markdown-preview-impl-CiENso5E.js`).then(e=>({default:e.MarkdownPreview})),__vite__mapDeps([4,5,1,3,6]),import.meta.url));function K(e){return(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading preview…`}),children:(0,V.jsx)(Rl,{...e})})}var zl=e(gt(),1);function q({src:e,alt:t,onClose:n}){let[r,i]=(0,B.useState)(!1);return(0,B.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,V.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex flex-col bg-black/95`,children:[(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 p-2`,children:[(0,V.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,V.jsx)(Be,{className:`h-4 w-4`}):(0,V.jsx)(Xe,{className:`h-4 w-4`})}),(0,V.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,V.jsx)(ye,{className:`h-4 w-4`})})]}),(0,V.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,V.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 J({src:e,alt:t=``,className:n,style:r}){let[i,a]=(0,B.useState)(!1);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`img`,{src:e,alt:t,className:`${n||``} cursor-zoom-in`,style:r,onClick:()=>a(!0)}),i&&(0,zl.createPortal)((0,V.jsx)(q,{src:e,alt:t,onClose:()=>a(!1)}),document.body)]})}var Y=`agent-relay:file-git-status`;function Bl(){try{return window.localStorage.getItem(Y)!==`off`}catch{return!0}}function Vl(e){try{window.localStorage.setItem(Y,e?`on`:`off`)}catch{}}function Hl(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 Ul(e,t,n){let r=`/orchestrators/${encodeURIComponent(e)}/files/list?path=${encodeURIComponent(t)}`;return n?`${r}&git=1`:r}function Wl({status:e}){let t=Hl(e);return t?(0,V.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 Kl(e,t){let n=t.replace(/\/+$/,``);return e===n?`/`:e.startsWith(n+`/`)?e.slice(n.length+1):e}function ql(e,t){let n=e.toLowerCase();return n.endsWith(`.md`)||n.endsWith(`.mdx`)||n.endsWith(`.markdown`)||t===`text/markdown`}function Jl(e,t,n){return ql(e,t)?`markdown`:Il(e,t,void 0,n)?`code`:null}function Yl(e){return`agent-relay:file-view-mode:${e}`}function Xl(e){try{let t=window.localStorage.getItem(Yl(e));return t===`raw`||t===`rendered`?t:`rendered`}catch{return`rendered`}}function Zl(e,t){try{window.localStorage.setItem(Yl(e),t)}catch{}}function Ql(e,t){let n=Kl(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 $l(e,t){let n=j(e=>e.apiCall),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(``);return(0,B.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(At(e)))}).finally(()=>{r||o(!1)}),()=>{r=!0}},[n,e,t]),{file:r,loading:a,error:s}}function eu(e,t,n=!1){let r=j(e=>e.apiCall),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(``);return(0,B.useEffect)(()=>{if(!e||!t){a(null),l(``);return}let i=!1;return s(!0),l(``),r(`GET`,Ul(e,t,n)).then(e=>{i||a(e)}).catch(e=>{i||(a(null),l(At(e)))}).finally(()=>{i||s(!1)}),()=>{i=!0}},[r,e,t,n]),{listing:i,loading:o,error:c}}function tu({content:e,line:t,lineRef:n}){return(0,V.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,V.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,V.jsx)(`div`,{className:`select-none pr-2 text-right text-muted-foreground sm:pr-3`,children:i}),(0,V.jsx)(`pre`,{className:`overflow-hidden whitespace-pre-wrap break-words`,children:e||` `})]},i)})})}function nu({orchestratorId:e,selectedPath:t,onReadError:n,git:r=!1}){let{listing:i,loading:a,error:o}=eu(e,t,r);return(0,B.useEffect)(()=>{n(o)},[o,n]),t?a?(0,V.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,V.jsx)(A,{className:`h-4 w-4 animate-spin`}),`Loading directory`]}):o?(0,V.jsx)(`div`,{className:`h-full bg-muted/20`}):i?(0,V.jsxs)(`div`,{className:`h-full overflow-auto bg-muted/20`,children:[(0,V.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,V.jsx)(m,{className:`h-3.5 w-3.5 text-blue-400`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:i.path}),(0,V.jsxs)(I,{variant:`outline`,className:`text-[10px]`,children:[i.entries.length,` items`]})]}),(0,V.jsxs)(`div`,{className:`divide-y divide-border/60`,children:[i.entries.map(e=>{let t=e.type===`directory`?m:_,n=Hl(e.gitStatus);return(0,V.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[(0,V.jsx)(t,{className:`h-4 w-4 shrink-0 ${e.type===`directory`?`text-blue-400`:`text-muted-foreground`}`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs ${n?.text??``}`,children:e.name}),e.symlink&&(0,V.jsx)(ve,{className:`h-3 w-3 shrink-0 text-muted-foreground/60`}),(0,V.jsx)(Wl,{status:e.gitStatus}),e.type!==`directory`&&(0,V.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Gl(e.size)})]},e.path)}),i.entries.length===0&&(0,V.jsx)(`div`,{className:`px-3 py-8 text-center text-sm text-muted-foreground`,children:`No files`})]})]}):null:(0,V.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Select a directory to preview`})}function ru({orchestratorId:e,selectedPath:t,line:n,onReadError:r}){let{file:i,loading:a,error:o}=$l(e,t),s=(0,B.useRef)(null),[c,l]=(0,B.useState)(`raw`);(0,B.useEffect)(()=>{r(o)},[o,r]),(0,B.useEffect)(()=>{n>0&&s.current?.scrollIntoView({block:`center`})},[i,n]),(0,B.useEffect)(()=>{if(!i||i.encoding===`binary`)return;if(n>0){l(`raw`);return}let e=Jl(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&&Zl(t,e)}if(!t)return(0,V.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,V.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,V.jsx)(A,{className:`h-4 w-4 animate-spin`}),`Loading file`]});if(o)return(0,V.jsx)(`div`,{className:`h-full bg-muted/20`});if(!i)return null;if(i.encoding===`base64`)return(0,V.jsxs)(`div`,{className:`flex h-full flex-col bg-muted/20`,children:[(0,V.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,V.jsx)(_,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:i.path}),(0,V.jsx)(Un,{value:i.path,label:`Copy path`,copiedLabel:`Copied path`,size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0`}),(0,V.jsx)(I,{variant:`outline`,className:`text-[10px]`,children:Gl(i.size)})]}),(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:(0,V.jsx)(J,{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,V.jsxs)(`div`,{className:`p-4 text-sm`,children:[(0,V.jsx)(`div`,{className:`font-medium`,children:i.name}),(0,V.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:i.truncated?`File too large to preview.`:`Binary file preview is not available.`}),(0,V.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,V.jsx)(I,{variant:`secondary`,children:i.mediaType}),(0,V.jsx)(I,{variant:`outline`,children:Gl(i.size)})]})]});let d=i.content??``,f=ql(i.path,i.mediaType),p=!f&&Il(i.path,i.mediaType,void 0,d),m=f||p,h=f?`markdown`:p?`code`:null;return(0,V.jsxs)(`div`,{className:`h-full overflow-auto bg-muted/20`,children:[(0,V.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,V.jsx)(_,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:i.path}),(0,V.jsx)(Un,{value:i.path,label:`Copy path`,copiedLabel:`Copied path`,size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0`}),i.truncated&&(0,V.jsx)(I,{variant:`secondary`,className:`text-[10px]`,children:`truncated`}),(0,V.jsx)(I,{variant:`outline`,className:`text-[10px]`,children:Gl(i.size)}),m&&(0,V.jsxs)(`div`,{className:`flex shrink-0 rounded-md border border-border bg-muted/40 p-0.5`,children:[(0,V.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,V.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,V.jsx)(K,{content:d,path:i.path}),c===`rendered`&&p&&(0,V.jsx)(Ll,{content:d,path:i.path,mediaType:i.mediaType}),c===`raw`&&(0,V.jsx)(tu,{content:d,line:n,lineRef:s})]})}function iu({overlay:e=!1}){let t=j(e=>e.apiCall),n=j(e=>e.orchestrators),r=j(e=>e.fileOrchestratorId),i=j(e=>e.filePath),a=j(e=>e.fileSelectedPath),o=j(e=>e.fileSelectedLine),s=j(e=>e.set),c=j(e=>e.closeFileOverlay),l=j(e=>e.openOrchestratorSpawnAt),[u,d]=(0,B.useState)(null),[f,p]=(0,B.useState)(i),[h,g]=(0,B.useState)(!1),[v,b]=(0,B.useState)(``),[x,C]=(0,B.useState)(``),[ee,te]=(0,B.useState)(Bl),w=(0,B.useMemo)(()=>n.filter(e=>e.status===`online`),[n]),T=n.find(e=>e.id===r)||w[0];(0,B.useEffect)(()=>{if(!T)return;let e={};r||(e.fileOrchestratorId=T.id),i||(e.filePath=T.baseDir),Object.keys(e).length&&s(e)},[r,i,T,s]),(0,B.useEffect)(()=>p(i),[i]);async function re(e=i){if(!(!T||!e)){g(!0),b(``);try{let n=await t(`GET`,Ul(T.id,e,ee));d(n),s({filePath:n.path}),p(n.path),C(``)}catch(e){b(At(e))}finally{g(!1)}}}(0,B.useEffect)(()=>{re(i)},[T?.id,i,ee]);function ie(e){te(e),Vl(e)}function ae(e){s({fileOrchestratorId:e,filePath:n.find(t=>t.id===e)?.baseDir||``,fileSelectedPath:``,fileSelectedLine:0})}function oe(e){C(``),e.type===`directory`?s({filePath:e.path,fileSelectedPath:``,fileSelectedLine:0}):s({fileSelectedPath:e.path,fileSelectedLine:0})}function E(){if(!T)return;let t=f.trim()||i||T.baseDir;e&&c(),l({orchestratorId:T.id,cwd:t})}let D=u?Ql(u.path,u.baseDir):[],se=v||x;return(0,V.jsxs)(`div`,{className:e?`flex h-full flex-col`:`flex h-[calc(100dvh-5rem)] flex-col gap-3 md:gap-4`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a?`hidden md:flex`:``}`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,V.jsx)(y,{className:`h-5 w-5 text-primary`}),`Files`]}),(0,V.jsxs)(`select`,{value:T?.id||``,onChange:e=>ae(e.target.value),className:`h-9 rounded-md border border-input bg-background px-3 text-sm`,children:[w.length===0&&(0,V.jsx)(`option`,{value:``,children:`No online orchestrators`}),w.map(e=>(0,V.jsx)(`option`,{value:e.id,children:e.hostname||e.id},e.id))]}),e&&(0,V.jsx)(L,{size:`icon`,variant:`ghost`,className:`ml-auto h-8 w-8`,onClick:c,title:`Close`,children:(0,V.jsx)(ye,{className:`h-4 w-4`})})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a?`hidden md:flex`:``}`,children:[(0,V.jsx)(R,{value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&s({filePath:f,fileSelectedPath:``,fileSelectedLine:0})},className:`min-w-0 flex-1 basis-full font-mono text-xs sm:basis-auto`,placeholder:T?.baseDir||`Path`}),(0,V.jsxs)(L,{size:`sm`,variant:`outline`,className:`gap-1`,onClick:()=>re(f),disabled:h||!T,children:[h?(0,V.jsx)(A,{className:`h-3.5 w-3.5 animate-spin`}):(0,V.jsx)(S,{className:`h-3.5 w-3.5`}),`Open`]}),(0,V.jsxs)(L,{size:`sm`,className:`gap-1`,onClick:E,disabled:!T,children:[(0,V.jsx)(de,{className:`h-3.5 w-3.5`}),(0,V.jsx)(`span`,{className:`sm:hidden`,children:`Spawn`}),(0,V.jsx)(`span`,{className:`hidden sm:inline`,children:`Spawn from here`})]}),(0,V.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,title:`Show git status colors`,children:[(0,V.jsx)(ne,{className:`h-3.5 w-3.5`}),(0,V.jsx)(`span`,{className:`hidden sm:inline`,children:`Git`}),(0,V.jsx)(dl,{checked:ee,onCheckedChange:ie})]})]}),D.length>0&&(0,V.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 text-xs text-muted-foreground ${a?`hidden md:flex`:``}`,children:D.map((e,t)=>(0,V.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<D.length-1&&e.label!==`/`?` /`:``]},`${e.path}-${t}`))}),se&&(0,V.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:se}),(0,V.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,V.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:[u?.parent&&(0,V.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:u.parent,fileSelectedPath:``,fileSelectedLine:0}),children:[(0,V.jsx)(Ze,{className:`h-4 w-4 text-muted-foreground`}),(0,V.jsx)(`span`,{children:`Parent directory`})]}),u?.entries.map(e=>{let t=a===e.path||i===e.path,n=e.type===`directory`?m:_,r=Hl(e.gitStatus);return(0,V.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:()=>oe(e),children:[(0,V.jsx)(n,{className:`h-4 w-4 shrink-0 ${e.type===`directory`?`text-blue-400`:`text-muted-foreground`}`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs ${r?.text??``}`,children:e.name}),e.symlink&&(0,V.jsx)(ve,{className:`h-3 w-3 shrink-0 text-muted-foreground/60`}),(0,V.jsx)(Wl,{status:e.gitStatus}),e.type!==`directory`&&(0,V.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Gl(e.size)})]},e.path)}),!h&&u&&u.entries.length===0&&(0,V.jsx)(`div`,{className:`px-3 py-8 text-center text-sm text-muted-foreground`,children:`No files`})]}),(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden ${a?``:`hidden md:flex`}`,children:[(0,V.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,V.jsx)(Ze,{className:`h-3.5 w-3.5`}),`Back to files`]}),(0,V.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,V.jsx)(ru,{orchestratorId:T?.id||``,selectedPath:a,line:o,onReadError:C})})]})]})]})}function au(){return(0,V.jsx)(iu,{})}function ou(){return j(e=>e.fileOverlayOpen)?(0,V.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/80 backdrop-blur-sm`,children:(0,V.jsx)(`div`,{className:`absolute inset-4 overflow-hidden rounded-md border border-border bg-background p-4 shadow-xl`,children:(0,V.jsx)(iu,{overlay:!0})})}):null}function su(e,t){let n=B.useRef(!1),r=B.useRef(t);r.current=t,B.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 cu({...e}){return su(e.open,e.onOpenChange),(0,V.jsx)(zr,{"data-slot":`sheet`,...e})}function lu({...e}){return(0,V.jsx)(Gr,{"data-slot":`sheet-close`,...e})}function uu({...e}){return(0,V.jsx)(Br,{"data-slot":`sheet-portal`,...e})}function du({className:e,...t}){return(0,V.jsx)(Vr,{"data-slot":`sheet-overlay`,className:k(`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 fu({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,V.jsxs)(uu,{children:[(0,V.jsx)(du,{}),(0,V.jsxs)(Hr,{"data-slot":`sheet-content`,"data-side":n,className:k(`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,V.jsx)(Gr,{"data-slot":`sheet-close`,asChild:!0,children:(0,V.jsxs)(L,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`,children:[(0,V.jsx)(ye,{}),(0,V.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function pu({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`sheet-header`,className:k(`flex flex-col gap-0.5 p-4`,e),...t})}function mu({className:e,...t}){return(0,V.jsx)(Ur,{"data-slot":`sheet-title`,className:k(`font-heading text-base font-medium text-foreground`,e),...t})}function hu({className:e,orientation:t=`horizontal`,...n}){return(0,V.jsx)(nc,{"data-slot":`tabs`,"data-orientation":t,className:k(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var gu=vn(`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 _u({className:e,variant:t=`default`,...n}){return(0,V.jsx)(rc,{"data-slot":`tabs-list`,"data-variant":t,className:k(gu({variant:t}),e),...n})}function vu({className:e,...t}){return(0,V.jsx)(ic,{"data-slot":`tabs-trigger`,className:k(`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 yu({className:e,...t}){return(0,V.jsx)(ac,{"data-slot":`tabs-content`,className:k(`flex-1 text-sm outline-none`,e),...t})}function bu({agent:e,now:t,className:n}){return(0,V.jsx)(`span`,{className:k(`inline-block w-2.5 h-2.5 rounded-full shrink-0`,Ft(e,t),n)})}function xu({className:e}){return(0,V.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,className:e,children:(0,V.jsx)(`path`,{d:`m3.127 10.604 3.135-1.76.053-.153-.053-.085H6.11l-.525-.032-1.791-.048-1.554-.065-1.505-.08-.38-.081L0 7.832l.036-.234.32-.214.455.04 1.009.069 1.513.105 1.097.064 1.626.17h.259l.036-.105-.089-.065-.068-.064-1.566-1.062-1.695-1.121-.887-.646-.48-.327-.243-.306-.104-.67.435-.48.585.04.15.04.593.456 1.267.981 1.654 1.218.242.202.097-.068.012-.049-.109-.181-.9-1.626-.96-1.655-.428-.686-.113-.411a2 2 0 0 1-.068-.484l.496-.674L4.446 0l.662.089.279.242.411.94.666 1.48 1.033 2.014.302.597.162.553.06.17h.105v-.097l.085-1.134.157-1.392.154-1.792.052-.504.25-.605.497-.327.387.186.319.456-.045.294-.19 1.23-.37 1.93-.243 1.29h.142l.161-.16.654-.868 1.097-1.372.484-.545.565-.601.363-.287h.686l.505.751-.226.775-.707.895-.585.759-.839 1.13-.524.904.048.072.125-.012 1.897-.403 1.024-.186 1.223-.21.553.258.06.263-.218.536-1.307.323-1.533.307-2.284.54-.028.02.032.04 1.029.098.44.024h1.077l2.005.15.525.346.315.424-.053.323-.807.411-3.631-.863-.872-.218h-.12v.073l.726.71 1.331 1.202 1.667 1.55.084.383-.214.302-.226-.032-1.464-1.101-.565-.497-1.28-1.077h-.084v.113l.295.432 1.557 2.34.08.718-.112.234-.404.141-.444-.08-.911-1.28-.94-1.44-.759-1.291-.093.053-.448 4.821-.21.246-.484.186-.403-.307-.214-.496.214-.98.258-1.28.21-1.016.19-1.263.112-.42-.008-.028-.092.012-.953 1.307-1.448 1.957-1.146 1.227-.274.109-.477-.247.045-.44.266-.39 1.586-2.018.956-1.25.617-.723-.004-.105h-.036l-4.212 2.736-.75.096-.324-.302.04-.496.154-.162 1.267-.871z`})})}function Su({className:e}){return(0,V.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,className:e,children:(0,V.jsx)(`path`,{d:`M22.282 9.821a5.985 5.985 0 0 0-.516-4.91 6.046 6.046 0 0 0-6.51-2.9A6.065 6.065 0 0 0 4.981 4.18a5.985 5.985 0 0 0-3.998 2.9 6.046 6.046 0 0 0 .743 7.097 5.98 5.98 0 0 0 .51 4.911 6.051 6.051 0 0 0 6.515 2.9A5.985 5.985 0 0 0 13.26 24a6.056 6.056 0 0 0 5.772-4.206 5.99 5.99 0 0 0 3.997-2.9 6.056 6.056 0 0 0-.747-7.073zM13.26 22.43a4.476 4.476 0 0 1-2.876-1.04l.141-.081 4.779-2.758a.795.795 0 0 0 .392-.681v-6.737l2.02 1.168a.071.071 0 0 1 .038.052v5.583a4.504 4.504 0 0 1-4.494 4.494zM3.6 18.304a4.47 4.47 0 0 1-.535-3.014l.142.085 4.783 2.759a.771.771 0 0 0 .78 0l5.843-3.369v2.332a.08.08 0 0 1-.033.062L9.74 19.95a4.5 4.5 0 0 1-6.14-1.646zM2.34 7.896a4.485 4.485 0 0 1 2.366-1.973V11.6a.766.766 0 0 0 .388.676l5.815 3.355-2.02 1.168a.076.076 0 0 1-.071 0l-4.83-2.786A4.504 4.504 0 0 1 2.34 7.872zm16.597 3.855-5.833-3.387L15.119 7.2a.076.076 0 0 1 .071 0l4.83 2.791a4.494 4.494 0 0 1-.676 8.105v-5.678a.79.79 0 0 0-.407-.667zm2.01-3.023-.141-.085-4.774-2.782a.776.776 0 0 0-.785 0L9.409 9.23V6.897a.066.066 0 0 1 .028-.061l4.83-2.787a4.5 4.5 0 0 1 6.68 4.66zm-12.64 4.135-2.02-1.164a.08.08 0 0 1-.038-.057V6.075a4.5 4.5 0 0 1 7.375-3.453l-.142.08L8.704 5.46a.795.795 0 0 0-.393.681zm1.097-2.365 2.602-1.5 2.607 1.5v2.999l-2.597 1.5-2.607-1.5z`})})}var Cu={claude:xu,anthropic:xu,codex:Su,openai:Su},wu={claude:`text-orange-400`,anthropic:`text-orange-400`};function Tu({provider:e,className:t}){let n=e.toLowerCase(),r=Cu[n];return r?(0,V.jsx)(`span`,{role:`img`,"aria-label":e,title:e,className:`inline-flex shrink-0`,children:(0,V.jsx)(r,{className:k(wu[n],t)})}):(0,V.jsx)(`span`,{className:`capitalize`,children:e})}var Eu={codex:`text-blue-400 bg-blue-500/10 border-blue-500/25`,claude:`text-orange-400 bg-orange-500/10 border-orange-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`},Du={codex:_e,claude:xu,user:we,system:c,channel:rt,agent:C};function Ou({agent:e,className:t}){let n=tn(e),r=Du[n]||C;return(0,V.jsx)(`span`,{className:k(`inline-flex items-center justify-center w-5 h-5 rounded-md border text-sm`,Eu[n]||Eu.agent,t),children:(0,V.jsx)(r,{className:`w-3.5 h-3.5`})})}function ku({agent:e,compact:t=!1}){let n=zu(e);return n.length===0?null:(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:n.slice(0,t?4:void 0).map(e=>(0,V.jsx)(I,{variant:`outline`,className:`text-[9px] px-1 py-0 h-4`,children:e},e))})}function Au({agent:e,compact:t=!1,className:n=``}){let r=Mu(e);return(0,V.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 ${n}`,children:r.map(e=>{let n=e.Icon;return(0,V.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,V.jsx)(n,{className:`h-3 w-3 shrink-0`}),!t&&(0,V.jsx)(`span`,{children:e.label})]},e.key)})})}function ju({agent:e}){let t=e.context;if(!t)return null;let n=Hu(t);if(n===null)return(0,V.jsxs)(`div`,{className:`space-y-1`,title:Uu(t),children:[(0,V.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground`,children:[(0,V.jsx)(`span`,{children:`collecting`}),(0,V.jsx)(`span`,{children:`--`})]}),(0,V.jsx)(`div`,{className:`h-1.5 rounded-full bg-muted overflow-hidden`,children:(0,V.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,V.jsxs)(`div`,{className:`space-y-1`,title:Uu(t),children:[(0,V.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground`,children:[(0,V.jsx)(`span`,{children:t.lifecycleState}),(0,V.jsxs)(`span`,{children:[r,`%`]})]}),(0,V.jsx)(`div`,{className:`h-1.5 rounded-full bg-muted overflow-hidden`,children:(0,V.jsx)(`div`,{className:`h-full ${i}`,style:{width:`${Math.max(0,Math.min(100,r))}%`}})})]})}function Mu(e){let t=Nu(e),n=Pu(e),r=Fu(e);return[{key:`origin`,label:t?`Relay`:`External`,title:t?`Agent Relay spawned this agent`:`Externally started agent registered with Agent Relay`,Icon:t?p: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 Nu(e){return typeof e.meta?.spawnRequestId==`string`||typeof e.meta?.policyName==`string`||typeof e.meta?.automationRunId==`string`}function Pu(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:De,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:b,className:`border-blue-500/30 bg-blue-500/10 text-blue-300`}:{key:`approval`,label:`Guarded`,title:`Approval mode: guarded`,Icon:Te,className:`border-amber-500/30 bg-amber-500/10 text-amber-300`}}function Fu(e){let t=Iu(e.meta?.workspace),n=wt(t.requestedMode)||wt(e.meta?.workspaceMode),r=wt(t.mode),i=n&&n!==`inherit`?n:r&&n!==`inherit`?r:`default`;return i===`isolated`?{key:`workspace`,label:`Isolated`,title:`Workspace: isolated worktree`,Icon:ne,iconColor:`text-violet-300`,className:`border-violet-500/30 bg-violet-500/10 text-violet-300`}:i===`shared`?{key:`workspace`,label:`Shared`,title:`Workspace: shared repo checkout`,Icon:se,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:dt,iconColor:`text-zinc-400`,className:`border-zinc-500/30 bg-zinc-500/10 text-zinc-300`}}function Iu(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Lu(e){let t=Iu(e.meta?.workspace),n=wt(t.repoRoot)||wt(t.sourceCwd)||wt(e.meta?.cwd);return n?Vt(n,2):``}function Ru(e){return!!(e.context||e.providerCapabilities?.context)}function zu(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=sn(e).length;if(i&&r.push(i===1?`1 subagent`:`${i} subagents`),n){let e=Hu(n);r.push(e===null?`ctx collecting`:`${Math.round(e*100)}% ctx`)}return r}function Bu({context:e,expected:t=!!e,size:n=26,className:r}){let i=Hu(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,V.jsxs)(`div`,{className:`relative shrink-0 ${u?`opacity-70`:``} ${r??``}`,style:{width:n,height:n},title:Uu(e),children:[(0,V.jsxs)(`svg`,{width:n,height:n,viewBox:`0 0 ${n} ${n}`,className:`rotate-[-90deg]`,children:[(0,V.jsx)(`circle`,{cx:o,cy:o,r:s,fill:`none`,strokeWidth:a,className:`stroke-muted-foreground/20`}),(0,V.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,V.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 Vu(e){let t=e.context;return!t?.tokensUsed&&!t?.tokensMax?null:t.tokensUsed&&t.tokensMax?`${Wu(t.tokensUsed)} / ${Wu(t.tokensMax)}`:t.tokensUsed?Wu(t.tokensUsed):t.tokensMax?Wu(t.tokensMax):null}function Hu(e){return!e||typeof e.utilization!=`number`||!Number.isFinite(e.utilization)?null:Math.min(1,Math.max(0,e.utilization))}function Uu(e){if(!e)return`Context: collecting; provider has not reported usage yet`;let t=Hu(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 Wu(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}var Gu=(0,B.lazy)(()=>z(()=>import(`./terminal-viewer-impl-B1A49Vs2.js`).then(e=>({default:e.TerminalDialog})),__vite__mapDeps([7,1,6,8,9,10,11,12,13,14]),import.meta.url));function X(e){return e.open?(0,V.jsx)(B.Suspense,{fallback:null,children:(0,V.jsx)(Gu,{...e})}):null}function Ku({orchestratorId:e,session:t,lines:n=200}){let r=j(e=>e.apiCall),[a,o]=(0,B.useState)([]),[s,c]=(0,B.useState)(``),[l,u]=(0,B.useState)(!1),[d,f]=(0,B.useState)(`provider`),[p,m]=(0,B.useState)(null);async function h(){if(!l)try{o((await r(`GET`,`/orchestrators/${encodeURIComponent(e)}/logs/${encodeURIComponent(t)}?lines=${n}${d===`mirror`?`&stream=mirror`:``}`)).lines||[]),m(null)}catch(e){m(At(e))}}(0,B.useEffect)(()=>{h();let e=setInterval(()=>void h(),1500);return()=>clearInterval(e)},[e,t,l,d]);let g=s?a.filter(e=>e.toLowerCase().includes(s.toLowerCase())):a;return(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsxs)(`div`,{className:`relative min-w-48 flex-1`,children:[(0,V.jsx)(i,{className:`absolute left-2 top-2.5 h-4 w-4 text-muted-foreground`}),(0,V.jsx)(R,{className:`pl-8`,value:s,onChange:e=>c(e.target.value),placeholder:`Search logs`})]}),(0,V.jsxs)(`div`,{className:`flex rounded-md border border-border overflow-hidden`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>f(`provider`),title:`Provider output`,className:k(`flex items-center gap-1 px-2 py-1.5 text-xs`,d===`provider`?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/50`),children:[(0,V.jsx)(_e,{className:`h-3.5 w-3.5`}),` Output`]}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>f(`mirror`),title:`Session-mirror diagnostics (clean)`,className:k(`flex items-center gap-1 px-2 py-1.5 text-xs border-l border-border`,d===`mirror`?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/50`),children:[(0,V.jsx)(T,{className:`h-3.5 w-3.5`}),` Mirror`]})]}),(0,V.jsx)(L,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>u(e=>!e),title:l?`Resume logs`:`Pause logs`,children:l?(0,V.jsx)(le,{className:`h-4 w-4`}):(0,V.jsx)(Je,{className:`h-4 w-4`})}),(0,V.jsx)(L,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>rn(`${t}.log`,a.join(`
|
|
14
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return B.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Lr=`DialogDescriptionWarning`,Rr=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Fr(Lr).contentName}}.`;return B.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},zr=ur,Br=gr,Vr=vr,Hr=Sr,Ur=Dr,Wr=kr,Gr=jr,Kr=`rovingFocusGroup.onEntryFocus`,qr={bubbles:!1,cancelable:!0},Jr=`RovingFocusGroup`,[Yr,Xr,Zr]=Cn(Jr),[Qr,$r]=bn(Jr,[Zr]),[ei,ti]=Qr(Jr),ni=B.forwardRef((e,t)=>(0,V.jsx)(Yr.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,V.jsx)(Yr.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,V.jsx)(ri,{...e,ref:t})})}));ni.displayName=Jr;var ri=B.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=B.useRef(null),p=gn(t,f),m=Nn(a),[h,g]=wn({prop:o,defaultProp:s??null,onChange:c,caller:Jr}),[_,v]=B.useState(!1),y=Pn(l),b=Xr(n),x=B.useRef(!1),[S,C]=B.useState(0);return B.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(Kr,y),()=>e.removeEventListener(Kr,y)},[y]),(0,V.jsx)(ei,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:B.useCallback(e=>g(e),[g]),onItemShiftTab:B.useCallback(()=>v(!0),[]),onFocusableItemAdd:B.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:B.useCallback(()=>C(e=>e-1),[]),children:(0,V.jsx)(P.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:F(e.onMouseDown,()=>{x.current=!0}),onFocus:F(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(Kr,qr);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);li([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:F(e.onBlur,()=>v(!1))})})}),ii=`RovingFocusGroupItem`,ai=B.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=jn(),l=a||c,u=ti(ii,n),d=u.currentTabStopId===l,f=Xr(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return B.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,V.jsx)(Yr.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,V.jsx)(P.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:F(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:F(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:F(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=ci(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?ui(n,r+1):n.slice(r+1)}setTimeout(()=>li(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});ai.displayName=ii;var oi={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function si(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function ci(e,t,n){let r=si(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return oi[r]}function li(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function ui(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var di=ni,fi=ai,pi=[`Enter`,` `],mi=[`ArrowDown`,`PageUp`,`Home`],hi=[`ArrowUp`,`PageDown`,`End`],gi=[...mi,...hi],_i={ltr:[...pi,`ArrowRight`],rtl:[...pi,`ArrowLeft`]},vi={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},yi=`Menu`,[bi,xi,Si]=Cn(yi),[Ci,wi]=bn(yi,[Si,Ln,$r]),Ti=Ln(),Ei=$r(),[Di,Oi]=Ci(yi),[ki,Ai]=Ci(yi),ji=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Ti(t),[c,l]=B.useState(null),u=B.useRef(!1),d=Pn(a),f=Nn(i);return B.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,V.jsx)(Rn,{...s,children:(0,V.jsx)(Di,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,V.jsx)(ki,{scope:t,onClose:B.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};ji.displayName=yi;var H=`MenuAnchor`,Mi=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Ti(n);return(0,V.jsx)(Vn,{...i,...r,ref:t})});Mi.displayName=H;var Ni=`MenuPortal`,[Pi,Fi]=Ci(Ni,{forceMount:void 0}),Ii=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Oi(Ni,t);return(0,V.jsx)(Pi,{scope:t,forceMount:n,children:(0,V.jsx)(Tn,{present:n||a.open,children:(0,V.jsx)(Dn,{asChild:!0,container:i,children:r})})})};Ii.displayName=Ni;var Li=`MenuContent`,[Ri,zi]=Ci(Li),Bi=B.forwardRef((e,t)=>{let n=Fi(Li,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Oi(Li,e.__scopeMenu),o=Ai(Li,e.__scopeMenu);return(0,V.jsx)(bi.Provider,{scope:e.__scopeMenu,children:(0,V.jsx)(Tn,{present:r||a.open,children:(0,V.jsx)(bi.Slot,{scope:e.__scopeMenu,children:o.modal?(0,V.jsx)(Vi,{...i,ref:t}):(0,V.jsx)(Hi,{...i,ref:t})})})})}),Vi=B.forwardRef((e,t)=>{let n=Oi(Li,e.__scopeMenu),r=B.useRef(null),i=gn(t,r);return B.useEffect(()=>{let e=r.current;if(e)return Mn(e)},[]),(0,V.jsx)(Wi,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:F(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Hi=B.forwardRef((e,t)=>{let n=Oi(Li,e.__scopeMenu);return(0,V.jsx)(Wi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Ui=_n(`MenuContent.ScrollLock`),Wi=B.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=Oi(Li,n),_=Ai(Li,n),v=Ti(n),y=Ei(n),b=xi(n),[x,S]=B.useState(null),C=B.useRef(null),ee=gn(t,C,g.onContentChange),te=B.useRef(0),ne=B.useRef(``),w=B.useRef(0),T=B.useRef(null),re=B.useRef(`right`),ie=B.useRef(0),ae=m?On:B.Fragment,oe=m?{as:Ui,allowPinchZoom:!0}:void 0,E=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=Oa(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){ne.current=t,window.clearTimeout(te.current),t!==``&&(te.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};B.useEffect(()=>()=>window.clearTimeout(te.current),[]),An();let D=B.useCallback(e=>re.current===T.current?.side&&Aa(e,T.current?.area),[]);return(0,V.jsx)(Ri,{scope:n,searchRef:ne,onItemEnter:B.useCallback(e=>{D(e)&&e.preventDefault()},[D]),onItemLeave:B.useCallback(e=>{D(e)||(C.current?.focus(),S(null))},[D]),onTriggerLeave:B.useCallback(e=>{D(e)&&e.preventDefault()},[D]),pointerGraceTimerRef:w,onPointerGraceIntentChange:B.useCallback(e=>{T.current=e},[]),children:(0,V.jsx)(ae,{...oe,children:(0,V.jsx)(En,{asChild:!0,trapped:i,onMountAutoFocus:F(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,V.jsx)(kn,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,V.jsx)(di,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:F(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,V.jsx)(Bn,{role:`menu`,"aria-orientation":`vertical`,"data-state":Ca(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:ee,style:{outline:`none`,...h.style},onKeyDown:F(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&&E(e.key));let i=C.current;if(e.target!==i||!gi.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);hi.includes(e.key)&&a.reverse(),Ea(a)}),onBlur:F(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(te.current),ne.current=``)}),onPointerMove:F(e.onPointerMove,ja(e=>{let t=e.target,n=ie.current!==e.clientX;e.currentTarget.contains(t)&&n&&(re.current=e.clientX>ie.current?`right`:`left`,ie.current=e.clientX)}))})})})})})})});Bi.displayName=Li;var Gi=`MenuGroup`,Ki=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,V.jsx)(P.div,{role:`group`,...r,ref:t})});Ki.displayName=Gi;var qi=`MenuLabel`,Ji=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,V.jsx)(P.div,{...r,ref:t})});Ji.displayName=qi;var Yi=`MenuItem`,Xi=`menu.itemSelect`,Zi=B.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=B.useRef(null),o=Ai(Yi,e.__scopeMenu),s=zi(Yi,e.__scopeMenu),c=gn(t,a),l=B.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(Xi,{bubbles:!0,cancelable:!0});e.addEventListener(Xi,e=>r?.(e),{once:!0}),yn(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,V.jsx)(Qi,{...i,ref:c,disabled:n,onClick:F(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:F(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:F(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||pi.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});Zi.displayName=Yi;var Qi=B.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=zi(Yi,n),s=Ei(n),c=B.useRef(null),l=gn(t,c),[u,d]=B.useState(!1),[f,p]=B.useState(``);return B.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,V.jsx)(bi.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,V.jsx)(fi,{asChild:!0,...s,focusable:!r,children:(0,V.jsx)(P.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:F(e.onPointerMove,ja(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:F(e.onPointerLeave,ja(e=>o.onItemLeave(e))),onFocus:F(e.onFocus,()=>d(!0)),onBlur:F(e.onBlur,()=>d(!1))})})})}),$i=`MenuCheckboxItem`,ea=B.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,V.jsx)(ca,{scope:e.__scopeMenu,checked:n,children:(0,V.jsx)(Zi,{role:`menuitemcheckbox`,"aria-checked":wa(n)?`mixed`:n,...i,ref:t,"data-state":Ta(n),onSelect:F(i.onSelect,()=>r?.(wa(n)?!0:!n),{checkForDefaultPrevented:!1})})})});ea.displayName=$i;var ta=`MenuRadioGroup`,[na,ra]=Ci(ta,{value:void 0,onValueChange:()=>{}}),ia=B.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=Pn(r);return(0,V.jsx)(na,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,V.jsx)(Ki,{...i,ref:t})})});ia.displayName=ta;var aa=`MenuRadioItem`,oa=B.forwardRef((e,t)=>{let{value:n,...r}=e,i=ra(aa,e.__scopeMenu),a=n===i.value;return(0,V.jsx)(ca,{scope:e.__scopeMenu,checked:a,children:(0,V.jsx)(Zi,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Ta(a),onSelect:F(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});oa.displayName=aa;var sa=`MenuItemIndicator`,[ca,la]=Ci(sa,{checked:!1}),ua=B.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=la(sa,n);return(0,V.jsx)(Tn,{present:r||wa(a.checked)||a.checked===!0,children:(0,V.jsx)(P.span,{...i,ref:t,"data-state":Ta(a.checked)})})});ua.displayName=sa;var da=`MenuSeparator`,fa=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,V.jsx)(P.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});fa.displayName=da;var pa=`MenuArrow`,ma=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Ti(n);return(0,V.jsx)(zn,{...i,...r,ref:t})});ma.displayName=pa;var ha=`MenuSub`,[ga,_a]=Ci(ha),va=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=Oi(ha,t),o=Ti(t),[s,c]=B.useState(null),[l,u]=B.useState(null),d=Pn(i);return B.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,V.jsx)(Rn,{...o,children:(0,V.jsx)(Di,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,V.jsx)(ga,{scope:t,contentId:jn(),triggerId:jn(),trigger:s,onTriggerChange:c,children:n})})})};va.displayName=ha;var ya=`MenuSubTrigger`,ba=B.forwardRef((e,t)=>{let n=Oi(ya,e.__scopeMenu),r=Ai(ya,e.__scopeMenu),i=_a(ya,e.__scopeMenu),a=zi(ya,e.__scopeMenu),o=B.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=B.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return B.useEffect(()=>u,[u]),B.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,V.jsx)(Mi,{asChild:!0,...l,children:(0,V.jsx)(Qi,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Ca(n.open),...e,ref:mn(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:F(e.onPointerMove,ja(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:F(e.onPointerLeave,ja(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:F(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||_i[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});ba.displayName=ya;var xa=`MenuSubContent`,Sa=B.forwardRef((e,t)=>{let n=Fi(Li,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Oi(Li,e.__scopeMenu),o=Ai(Li,e.__scopeMenu),s=_a(xa,e.__scopeMenu),c=B.useRef(null),l=gn(t,c);return(0,V.jsx)(bi.Provider,{scope:e.__scopeMenu,children:(0,V.jsx)(Tn,{present:r||a.open,children:(0,V.jsx)(bi.Slot,{scope:e.__scopeMenu,children:(0,V.jsx)(Wi,{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:F(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:F(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:F(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=vi[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});Sa.displayName=xa;function Ca(e){return e?`open`:`closed`}function wa(e){return e===`indeterminate`}function Ta(e){return wa(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 Da(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Oa(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=Da(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 ka(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 Aa(e,t){return t?ka({x:e.clientX,y:e.clientY},t):!1}function ja(e){return t=>t.pointerType===`mouse`?e(t):void 0}var Ma=ji,Na=Mi,Pa=Ii,Fa=Bi,Ia=Ki,La=Ji,Ra=Zi,za=ea,Ba=ia,Va=oa,Ha=ua,Ua=fa,Wa=ma,Ga=ba,Ka=Sa,qa=`DropdownMenu`,[Ja,Ya]=bn(qa,[wi]),Xa=wi(),[Za,Qa]=Ja(qa),$a=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=Xa(t),l=B.useRef(null),[u,d]=wn({prop:i,defaultProp:a??!1,onChange:o,caller:qa});return(0,V.jsx)(Za,{scope:t,triggerId:jn(),triggerRef:l,contentId:jn(),open:u,onOpenChange:d,onOpenToggle:B.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,V.jsx)(Ma,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};$a.displayName=qa;var eo=`DropdownMenuTrigger`,to=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Qa(eo,n),o=Xa(n);return(0,V.jsx)(Na,{asChild:!0,...o,children:(0,V.jsx)(P.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:mn(t,a.triggerRef),onPointerDown:F(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:F(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});to.displayName=eo;var no=`DropdownMenuPortal`,ro=e=>{let{__scopeDropdownMenu:t,...n}=e,r=Xa(t);return(0,V.jsx)(Pa,{...r,...n})};ro.displayName=no;var io=`DropdownMenuContent`,ao=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Qa(io,n),a=Xa(n),o=B.useRef(!1);return(0,V.jsx)(Fa,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:F(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:F(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)`}})});ao.displayName=io;var oo=`DropdownMenuGroup`,so=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(Ia,{...i,...r,ref:t})});so.displayName=oo;var co=`DropdownMenuLabel`,lo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(La,{...i,...r,ref:t})});lo.displayName=co;var U=`DropdownMenuItem`,W=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(Ra,{...i,...r,ref:t})});W.displayName=U;var uo=`DropdownMenuCheckboxItem`,fo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(za,{...i,...r,ref:t})});fo.displayName=uo;var po=`DropdownMenuRadioGroup`,mo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(Ba,{...i,...r,ref:t})});mo.displayName=po;var ho=`DropdownMenuRadioItem`,go=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(Va,{...i,...r,ref:t})});go.displayName=ho;var _o=`DropdownMenuItemIndicator`,vo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(Ha,{...i,...r,ref:t})});vo.displayName=_o;var yo=`DropdownMenuSeparator`,bo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(Ua,{...i,...r,ref:t})});bo.displayName=yo;var xo=`DropdownMenuArrow`,So=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(Wa,{...i,...r,ref:t})});So.displayName=xo;var Co=`DropdownMenuSubTrigger`,wo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(Ga,{...i,...r,ref:t})});wo.displayName=Co;var To=`DropdownMenuSubContent`,Eo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xa(n);return(0,V.jsx)(Ka,{...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)`}})});Eo.displayName=To;var Do=$a,Oo=to,ko=ro,Ao=ao,jo=lo,Mo=W,No=bo,Po=`Label`,Fo=B.forwardRef((e,t)=>(0,V.jsx)(P.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));Fo.displayName=Po;var Io=Fo;function Lo(e,t){return B.useReducer((e,n)=>t[e][n]??e,e)}var Ro=`ScrollArea`,[zo,Bo]=bn(Ro),[Vo,Ho]=zo(Ro),Uo=B.forwardRef((e,t)=>{let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=B.useState(null),[l,u]=B.useState(null),[d,f]=B.useState(null),[p,m]=B.useState(null),[h,g]=B.useState(null),[_,v]=B.useState(0),[y,b]=B.useState(0),[x,S]=B.useState(!1),[C,ee]=B.useState(!1),te=gn(t,e=>c(e)),ne=Nn(i);return(0,V.jsx)(Vo,{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:C,onScrollbarYEnabledChange:ee,onCornerWidthChange:v,onCornerHeightChange:b,children:(0,V.jsx)(P.div,{dir:ne,...o,ref:te,style:{position:`relative`,"--radix-scroll-area-corner-width":_+`px`,"--radix-scroll-area-corner-height":y+`px`,...e.style}})})});Uo.displayName=Ro;var Wo=`ScrollAreaViewport`,Go=B.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=Ho(Wo,n),s=gn(t,B.useRef(null),o.onViewportChange);return(0,V.jsxs)(V.Fragment,{children:[(0,V.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,V.jsx)(P.div,{"data-radix-scroll-area-viewport":``,...a,ref:s,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,V.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})});Go.displayName=Wo;var Ko=`ScrollAreaScrollbar`,qo=B.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Ho(Ko,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return B.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,V.jsx)(Jo,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,V.jsx)(Yo,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,V.jsx)(Xo,{...r,ref:t,forceMount:n}):i.type===`always`?(0,V.jsx)(Zo,{...r,ref:t}):null});qo.displayName=Ko;var Jo=B.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Ho(Ko,e.__scopeScrollArea),[a,o]=B.useState(!1);return B.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,V.jsx)(Tn,{present:n||a,children:(0,V.jsx)(Xo,{"data-state":a?`visible`:`hidden`,...r,ref:t})})}),Yo=B.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Ho(Ko,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=_s(()=>c(`SCROLL_END`),100),[s,c]=Lo(`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 B.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),B.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,V.jsx)(Tn,{present:n||s!==`hidden`,children:(0,V.jsx)(Zo,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:F(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:F(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})}),Xo=B.forwardRef((e,t)=>{let n=Ho(Ko,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=B.useState(!1),s=e.orientation===`horizontal`,c=_s(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return vs(n.viewport,c),vs(n.content,c),(0,V.jsx)(Tn,{present:r||a,children:(0,V.jsx)(Zo,{"data-state":a?`visible`:`hidden`,...i,ref:t})})}),Zo=B.forwardRef((e,t)=>{let{orientation:n=`vertical`,...r}=e,i=Ho(Ko,e.__scopeScrollArea),a=B.useRef(null),o=B.useRef(0),[s,c]=B.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=us(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 fs(e,o.current,s,t)}return n===`horizontal`?(0,V.jsx)(Qo,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=ps(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,V.jsx)($o,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=ps(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}),Qo=B.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=Ho(Ko,e.__scopeScrollArea),[o,s]=B.useState(),c=B.useRef(null),l=gn(t,c,a.onScrollbarXChange);return B.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,V.jsx)(ns,{"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":ds(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),hs(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:ls(o.paddingLeft),paddingEnd:ls(o.paddingRight)}})}})}),$o=B.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=Ho(Ko,e.__scopeScrollArea),[o,s]=B.useState(),c=B.useRef(null),l=gn(t,c,a.onScrollbarYChange);return B.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,V.jsx)(ns,{"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":ds(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),hs(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:ls(o.paddingTop),paddingEnd:ls(o.paddingBottom)}})}})}),[es,ts]=zo(Ko),ns=B.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=Ho(Ko,n),[m,h]=B.useState(null),g=gn(t,e=>h(e)),_=B.useRef(null),v=B.useRef(``),y=p.viewport,b=r.content-r.viewport,x=Pn(u),S=Pn(c),C=_s(d,10);function ee(e){_.current&&l({x:e.clientX-_.current.left,y:e.clientY-_.current.top})}return B.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]),B.useEffect(S,[r,S]),vs(m,C),vs(p.content,C),(0,V.jsx)(es,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:Pn(a),onThumbPointerUp:Pn(o),onThumbPositionChange:S,onThumbPointerDown:Pn(s),children:(0,V.jsx)(P.div,{...f,ref:g,style:{position:`absolute`,...f.style},onPointerDown:F(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`),ee(e))}),onPointerMove:F(e.onPointerMove,ee),onPointerUp:F(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})})})}),rs=`ScrollAreaThumb`,is=B.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=ts(rs,e.__scopeScrollArea);return(0,V.jsx)(Tn,{present:n||i.hasThumb,children:(0,V.jsx)(as,{ref:t,...r})})}),as=B.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:r,...i}=e,a=Ho(rs,n),o=ts(rs,n),{onThumbPositionChange:s}=o,c=gn(t,e=>o.onThumbChange(e)),l=B.useRef(void 0),u=_s(()=>{l.current&&=(l.current(),void 0)},100);return B.useEffect(()=>{let e=a.viewport;if(e){let t=()=>{u(),l.current||(l.current=gs(e,s),s())};return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,V.jsx)(P.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:F(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:F(e.onPointerUp,o.onThumbPointerUp)})});is.displayName=rs;var os=`ScrollAreaCorner`,ss=B.forwardRef((e,t)=>{let n=Ho(os,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,V.jsx)(cs,{...e,ref:t}):null});ss.displayName=os;var cs=B.forwardRef((e,t)=>{let{__scopeScrollArea:n,...r}=e,i=Ho(os,n),[a,o]=B.useState(0),[s,c]=B.useState(0),l=!!(a&&s);return vs(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),vs(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),l?(0,V.jsx)(P.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 ls(e){return e?parseInt(e,10):0}function us(e,t){let n=e/t;return isNaN(n)?0:n}function ds(e){let t=us(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function fs(e,t,n,r=`ltr`){let i=ds(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 ms([c,l],d)(e)}function ps(e,t,n=`ltr`){let r=ds(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=Hn(e,n===`ltr`?[0,o]:[o*-1,0]);return ms([0,o],[0,s])(c)}function ms(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 hs(e,t){return e>0&&e<t}var gs=(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 _s(e,t){let n=Pn(e),r=B.useRef(0);return B.useEffect(()=>()=>window.clearTimeout(r.current),[]),B.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function vs(e,t){let n=Pn(t);Sn(()=>{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 ys=Uo,bs=Go,xs=ss,Ss=`Separator`,Cs=`horizontal`,ws=[`horizontal`,`vertical`],Ts=B.forwardRef((e,t)=>{let{decorative:n,orientation:r=Cs,...i}=e,a=Es(r)?r:Cs,o=n?{role:`none`}:{"aria-orientation":a===`vertical`?a:void 0,role:`separator`};return(0,V.jsx)(P.div,{"data-orientation":a,...o,...i,ref:t})});Ts.displayName=Ss;function Es(e){return ws.includes(e)}var Ds=Ts,Os=`Switch`,[ks,As]=bn(Os),[js,Ms]=ks(Os),Ns=B.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]=B.useState(null),m=gn(t,e=>p(e)),h=B.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=wn({prop:i,defaultProp:a??!1,onChange:l,caller:Os});return(0,V.jsxs)(js,{scope:n,checked:_,disabled:s,children:[(0,V.jsx)(P.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":Rs(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:F(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,V.jsx)(Ls,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});Ns.displayName=Os;var Ps=`SwitchThumb`,Fs=B.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=Ms(Ps,n);return(0,V.jsx)(P.span,{"data-state":Rs(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});Fs.displayName=Ps;var Is=`SwitchBubbleInput`,Ls=B.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=B.useRef(null),s=gn(o,a),c=Fn(n),l=In(t);return B.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,V.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}})});Ls.displayName=Is;function Rs(e){return e?`checked`:`unchecked`}var zs=Ns,Bs=Fs,Vs=`Tabs`,[Hs,Us]=bn(Vs,[$r]),Ws=$r(),[Gs,Ks]=Hs(Vs),qs=B.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=Nn(s),[d,f]=wn({prop:r,onChange:i,defaultProp:a??``,caller:Vs});return(0,V.jsx)(Gs,{scope:n,baseId:jn(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,V.jsx)(P.div,{dir:u,"data-orientation":o,...l,ref:t})})});qs.displayName=Vs;var Js=`TabsList`,Ys=B.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=Ks(Js,n),o=Ws(n);return(0,V.jsx)(di,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,V.jsx)(P.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});Ys.displayName=Js;var Xs=`TabsTrigger`,Zs=B.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=Ks(Xs,n),s=Ws(n),c=ec(o.baseId,r),l=tc(o.baseId,r),u=r===o.value;return(0,V.jsx)(fi,{asChild:!0,...s,focusable:!i,active:u,children:(0,V.jsx)(P.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:F(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:F(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:F(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});Zs.displayName=Xs;var Qs=`TabsContent`,$s=B.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=Ks(Qs,n),c=ec(s.baseId,r),l=tc(s.baseId,r),u=r===s.value,d=B.useRef(u);return B.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,V.jsx)(Tn,{present:i||u,children:({present:n})=>(0,V.jsx)(P.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})})});$s.displayName=Qs;function ec(e,t){return`${e}-trigger-${t}`}function tc(e,t){return`${e}-content-${t}`}var nc=qs,rc=Ys,ic=Zs,ac=$s,[oc,sc]=bn(`Tooltip`,[Ln]),cc=Ln(),lc=`TooltipProvider`,uc=700,dc=`tooltip.open`,[fc,pc]=oc(lc),mc=e=>{let{__scopeTooltip:t,delayDuration:n=uc,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=B.useRef(!0),s=B.useRef(!1),c=B.useRef(0);return B.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,V.jsx)(fc,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:B.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:B.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:B.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};mc.displayName=lc;var hc=`Tooltip`,[gc,_c]=oc(hc),vc=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=pc(hc,e.__scopeTooltip),l=cc(t),[u,d]=B.useState(null),f=jn(),p=B.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=B.useRef(!1),[_,v]=wn({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(dc))):c.onClose(),a?.(e)},caller:hc}),y=B.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=B.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=B.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=B.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return B.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,V.jsx)(Rn,{...l,children:(0,V.jsx)(gc,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:B.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:B.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};vc.displayName=hc;var yc=`TooltipTrigger`,bc=B.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=_c(yc,n),a=pc(yc,n),o=cc(n),s=gn(t,B.useRef(null),i.onTriggerChange),c=B.useRef(!1),l=B.useRef(!1),u=B.useCallback(()=>c.current=!1,[]);return B.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,V.jsx)(Vn,{asChild:!0,...o,children:(0,V.jsx)(P.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:F(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:F(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:F(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:F(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:F(e.onBlur,i.onClose),onClick:F(e.onClick,i.onClose)})})});bc.displayName=yc;var xc=`TooltipPortal`,[Sc,Cc]=oc(xc,{forceMount:void 0}),wc=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=_c(xc,t);return(0,V.jsx)(Sc,{scope:t,forceMount:n,children:(0,V.jsx)(Tn,{present:n||a.open,children:(0,V.jsx)(Dn,{asChild:!0,container:i,children:r})})})};wc.displayName=xc;var Tc=`TooltipContent`,Ec=B.forwardRef((e,t)=>{let n=Cc(Tc,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=_c(Tc,e.__scopeTooltip);return(0,V.jsx)(Tn,{present:r||o.open,children:o.disableHoverableContent?(0,V.jsx)(jc,{side:i,...a,ref:t}):(0,V.jsx)(Dc,{side:i,...a,ref:t})})}),Dc=B.forwardRef((e,t)=>{let n=_c(Tc,e.__scopeTooltip),r=pc(Tc,e.__scopeTooltip),i=B.useRef(null),a=gn(t,i),[o,s]=B.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=B.useCallback(()=>{s(null),d(!1)},[d]),p=B.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Fc(r,Pc(r,n.getBoundingClientRect())),a=Ic(t.getBoundingClientRect());s(Rc([...i,...a])),d(!0)},[d]);return B.useEffect(()=>()=>f(),[f]),B.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]),B.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=!Lc(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,V.jsx)(jc,{...e,ref:a})}),[Oc,kc]=oc(hc,{isInside:!1}),Ac=hn(`TooltipContent`),jc=B.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=_c(Tc,n),l=cc(n),{onClose:u}=c;return B.useEffect(()=>(document.addEventListener(dc,u),()=>document.removeEventListener(dc,u)),[u]),B.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,V.jsx)(kn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,V.jsxs)(Bn,{"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,V.jsx)(Ac,{children:r}),(0,V.jsx)(Oc,{scope:n,isInside:!0,children:(0,V.jsx)(ir,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});Ec.displayName=Tc;var Mc=`TooltipArrow`,Nc=B.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=cc(n);return kc(Mc,n).isInside?null:(0,V.jsx)(zn,{...i,...r,ref:t})});Nc.displayName=Mc;function Pc(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 Fc(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 Ic(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 Lc(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 Rc(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)),zc(t)}function zc(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 Bc=mc,Vc=vc,Hc=bc,Uc=wc,Wc=Ec,Gc=Nc;function Kc({delayDuration:e=0,...t}){return(0,V.jsx)(Bc,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function qc({...e}){return(0,V.jsx)(Vc,{"data-slot":`tooltip`,...e})}function Jc({...e}){return(0,V.jsx)(Hc,{"data-slot":`tooltip-trigger`,...e})}function Yc({className:e,sideOffset:t=0,children:n,...r}){return(0,V.jsx)(Uc,{children:(0,V.jsxs)(Wc,{"data-slot":`tooltip-content`,sideOffset:t,className:k(`z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 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-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 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,children:[n,(0,V.jsx)(Gc,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}function G(e){return j(e)}function Xc(){let e=G(e=>e.pairs);return(0,B.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 Zc(e){let t=G(e=>e.messages),n=G(e=>e.tasks),r=G(e=>e.pairs),i=G(e=>e.inboxReadCursors),a=G(e=>e.inboxArchivedThreads);return(0,B.useMemo)(()=>{if(!e)return{unread:0,needsHumanResponse:!1,pendingPairInvite:!1,claimableTasks:0,total:0,score:0};let o=t.filter(t=>dn(t)===e.id&&!Pt(t)),s=Number(a[e.id]||0),c=s>=o.filter(e=>Bt(e)&&zt(e)).reduce((e,t)=>Math.max(e,t.id),0)&&s>0?0:o.filter(t=>Lt(i,e.id,t)).length,l=on(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=>ln(t)&&cn(t.target,e)).length+t.filter(t=>Mt(t)&&cn(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 Qc(){let e=G(e=>e.agents),t=G(e=>e.showBuiltIns),n=G(e=>e.showOffline),r=G(e=>e.agentSort),i=G(e=>e.agentSortDir),a=G(e=>e.agentPresetFilter),o=G(e=>e.agentStatusFilter),s=G(e=>e.agentTagFilter),c=G(e=>e.agentHostFilter),l=G(e=>e.managedPolicies),u=G(e=>e.pairs);return(0,B.useMemo)(()=>{let d=Ht(e,t,l);if(a){let e=$c(u);d=el(d,a,vt.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`?N(e).localeCompare(N(t))*f:r===`lastSeen`?(new Date(t.lastSeen).getTime()-new Date(e.lastSeen).getTime())*f||N(e).localeCompare(N(t)):r===`created`?(new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime())*f||N(e).localeCompare(N(t)):((Qt[e.status]??9)-(Qt[t.status]??9))*f||N(e).localeCompare(N(t)))},[e,t,n,l,r,i,a,o,s,c,u,bt()])}function $c(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 el(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`||un(n,e));case`paired`:return e.filter(e=>!!r[e.id]);case`unpaired`:return e.filter(e=>!r[e.id]);default:return Ot().includes(t)?e.filter(e=>tn(e)===t):e}}function tl(){let e=G(e=>e.messages),t=G(e=>e.inboxReadCursors),n=G(e=>e.inboxArchivedThreads),r=G(e=>e.inboxDrafts),i=G(e=>e.agentsById),a=G(e=>e.coordinatorMutes);return(0,B.useMemo)(()=>{let o=new Map;for(let t of e){if(Pt(t))continue;let e=dn(t);e&&(o.has(e)||o.set(e,{id:e,peer:e,messages:[],lastMessage:null,previewMessage:null,attention:{unread:0,needsHumanResponse:!1,score:0},archived:!1,draft:``}),o.get(e).messages.push(t))}for(let e of o.values()){e.messages.sort((e,t)=>e.id-t.id),e.lastMessage=e.messages[e.messages.length-1]||null;let o=null;for(let t=e.messages.length-1;t>=0;t--){let n=e.messages[t];if(n&&!Nt(n)){o=n;break}}e.previewMessage=o||e.lastMessage;let s=a.includes(e.peer),c=s?0:e.messages.filter(n=>Lt(t,e.peer,n)).length,l=s?!1:on(i[e.peer]);e.attention={unread:c,needsHumanResponse:l,score:c*10+(l?8:0)};let u=Number(n[e.peer]||0);e.archived=!!(e.lastMessage?.id&&u>=e.lastMessage.id),e.draft=r[e.peer]||``}return[...o.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,a])}function nl(){let e=tl(),t=G(e=>e.agents),n=G(e=>e.showBuiltIns),r=G(e=>e.showOffline),i=G(e=>e.managedPolicies),a=G(e=>e.pairs),o=G(e=>e.tasks),s=G(e=>e.messages),c=(0,B.useMemo)(()=>new Set(Ht(t,n,i).filter(e=>r||e.status!==`offline`).map(e=>e.id)),[t,n,r,i]);return(0,B.useMemo)(()=>{let l=e.filter(e=>!e.archived&&c.has(e.peer)).reduce((e,t)=>e+(t.attention.unread||0),0),u=Ht(t,n,i).filter(e=>(r||e.status!==`offline`)&&on(e)).length,d=a.filter(e=>e.status===`pending`).length,f=o.filter(ln).length+s.filter(Mt).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 rl(){let e=G(e=>e.agents),t=G(e=>e.showBuiltIns),n=G(e=>e.managedPolicies);return(0,B.useMemo)(()=>Ht(e,t,n).filter(e=>e.status!==`offline`).length,[e,t,n])}function il(){let e=G(e=>e.agents);return(0,B.useMemo)(()=>e.filter(e=>e.status===`busy`).length,[e])}function al(){let e=G(e=>e.agents),t=G(e=>e.showBuiltIns),n=G(e=>e.showOffline),r=G(e=>e.managedPolicies);return(0,B.useMemo)(()=>{let i=Ht(e,t,r);return n?i:i.filter(e=>e.status!==`offline`)},[e,t,n,r])}function ol(){let e=G(e=>e.agents),t=G(e=>e.showBuiltIns),n=G(e=>e.managedPolicies);return(0,B.useMemo)(()=>[...new Set(Ht(e,t,n).map(e=>e.machine).filter(Boolean))].sort(),[e,t,n])}function sl(){let e=G(e=>e.agents),t=G(e=>e.showBuiltIns),n=G(e=>e.managedPolicies);return(0,B.useMemo)(()=>[...new Set(Ht(e,t,n).flatMap(e=>e.tags||[]))],[e,t,n])}function cl(){let e=G(e=>e.tasks),t=G(e=>e.messages);return(0,B.useMemo)(()=>{let n=e.filter(e=>(e.kind??`claim`)===`claim`).filter(e=>!Rt.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:ln(e),task:e})),r=t.filter(Mt).map(e=>({id:`message-`+e.id,sourceType:`message`,title:e.subject||`Claimable message #`+e.id,body:Zt(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:Mt(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?an(e.updatedAt)-an(t.updatedAt):i})},[e,t])}function ll(){let e=G(e=>e.commandQuery),t=G(e=>e.agents),n=G(e=>e.agentsById),r=G(e=>e.showBuiltIns),i=G(e=>e.showOffline),a=G(e=>e.managedPolicies);return(0,B.useMemo)(()=>{let n=Ht(t,r,a).filter(e=>i||e.status!==`offline`),o=[...new Set(n.flatMap(e=>e.tags||[]))],s=Ce(),c=[ul(`open-chat`,`Open chat`,`Human console`,`MessageCircle`,`openView`,{view:`chat`}),ul(`open-work`,`Open work queue`,`Claimable messages and tasks`,`ListChecks`,`openView`,{view:`work`}),ul(`open-workspaces`,`Open workspaces`,`Agent worktrees and merge state`,`GitBranch`,`openView`,{view:`workspaces`}),ul(`show-stale`,`Show stale agents`,`Filter agents to offline or stale`,`Filter`,`agentPreset`,{preset:`offline_stale`}),ul(`copy-url`,`Copy relay URL`,s,`Copy`,`copy`,{value:s}),ul(`export-md`,`Export timeline as Markdown`,`Activity audit trace`,`FileDown`,`exportActivity`,{format:`markdown`}),ul(`export-json`,`Export timeline as JSON`,`Activity audit trace`,`Braces`,`exportActivity`,{format:`json`}),...n.slice(0,12).map(e=>ul(`msg-`+e.id,`Message agent: `+N(e),e.id,`Send`,`messageAgent`,{agentId:e.id})),...n.filter(e=>e.providerCapabilities?.liveSession?.inject===!0).slice(0,8).map(e=>ul(`pair-`+e.id,`Pair: `+N(e),e.id,`Link`,`pairAgent`,{agentId:e.id})),...o.map(e=>ul(`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 ul(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 dl({className:e,size:t=`default`,...n}){return(0,V.jsx)(zs,{"data-slot":`switch`,"data-size":t,className:k(`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,V.jsx)(Bs,{"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 fl({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,V.jsx)(Ds,{"data-slot":`separator`,decorative:n,orientation:t,className:k(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...r})}function pl({...e}){return(0,V.jsx)(Do,{"data-slot":`dropdown-menu`,...e})}function ml({...e}){return(0,V.jsx)(Oo,{"data-slot":`dropdown-menu-trigger`,...e})}function hl({className:e,align:t=`start`,sideOffset:n=4,...r}){return(0,V.jsx)(ko,{children:(0,V.jsx)(Ao,{"data-slot":`dropdown-menu-content`,sideOffset:n,align:t,className:k(`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 gl({className:e,inset:t,variant:n=`default`,...r}){return(0,V.jsx)(Mo,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:k(`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 _l({className:e,inset:t,...n}){return(0,V.jsx)(jo,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:k(`px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7`,e),...n})}function vl({className:e,...t}){return(0,V.jsx)(No,{"data-slot":`dropdown-menu-separator`,className:k(`-mx-1 my-1 h-px bg-border`,e),...t})}var yl={LayoutDashboard:xe,MessageCircle:Ie,Bot:C,Server:c,MessagesSquare:rt,Plug:a,PlugZap:g,Activity:r,Link:Ae,Mail:tt,ListChecks:Pe,ClipboardList:at,CalendarClock:Le,AreaChart:re,Settings:u,Workflow:$e,BrainCircuit:ie,FolderTree:y,Shield:st,Wrench:Ue,UserCog:Ke,Lightbulb:pt,Users:it,Boxes:v,PackagePlus:pe,FileText:ue};function bl(e){return new Date(e.createdAt).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}var xl=[[`messages`,`Messages`],[`replies`,`Replies`],[`errors`,`Errors`]];function Sl(){let e=j(e=>e.notifications),t=j(e=>e.notificationUnread),n=j(e=>e.notificationSettings),r=j(e=>e.notificationPermission),i=j(e=>e.set),a=j(e=>e.openNotification),s=j(e=>e.markNotificationsRead),c=j(e=>e.clearNotifications),l=j(e=>e.requestBrowserNotifications),u=t>0?o:ht;function f(e){i({notificationSettings:{...n,...e}})}return(0,V.jsxs)(pl,{onOpenChange:e=>{e&&s()},children:[(0,V.jsx)(ml,{asChild:!0,children:(0,V.jsxs)(`button`,{className:`relative flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors w-full`,children:[(0,V.jsx)(u,{className:`w-3.5 h-3.5`}),(0,V.jsx)(`span`,{children:`Notifications`}),t>0&&(0,V.jsx)(I,{variant:`destructive`,className:`ml-auto text-[10px] px-1.5 py-0`,children:t})]})}),(0,V.jsxs)(hl,{align:`start`,side:`right`,className:`w-80 p-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1.5 py-1`,children:[(0,V.jsx)(_l,{className:`p-0`,children:`Notifications`}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,V.jsx)(`button`,{type:`button`,title:`Mark read`,onClick:s,className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,children:(0,V.jsx)(d,{className:`h-3.5 w-3.5`})}),(0,V.jsx)(`button`,{type:`button`,title:`Clear`,onClick:c,className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,children:(0,V.jsx)(Oe,{className:`h-3.5 w-3.5`})})]})]}),(0,V.jsxs)(`div`,{className:`px-1.5 py-1.5 space-y-2`,children:[(0,V.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`In-app notifications`}),(0,V.jsx)(dl,{size:`sm`,checked:n.enabled,onCheckedChange:e=>f({enabled:e})})]}),(0,V.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Browser notifications`}),(0,V.jsx)(dl,{size:`sm`,checked:n.browserEnabled&&r===`granted`,disabled:r===`unsupported`,onCheckedChange:e=>{e&&r!==`granted`?l():f({browserEnabled:e})}})]}),(0,V.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,children:xl.map(([e,t])=>(0,V.jsx)(`button`,{type:`button`,onClick:()=>f({[e]:!n[e]}),className:k(`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,V.jsx)(vl,{}),(0,V.jsx)(`div`,{className:`max-h-80 overflow-y-auto`,children:e.length===0?(0,V.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,V.jsxs)(gl,{onSelect:t=>{t.preventDefault(),a(e)},className:`flex flex-col items-start gap-0.5 px-2 py-2`,children:[(0,V.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[(0,V.jsx)(`span`,{className:k(`h-1.5 w-1.5 rounded-full`,e.severity===`error`?`bg-red-400`:e.severity===`warning`?`bg-yellow-400`:`bg-blue-400`)}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium`,children:e.title}),(0,V.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:bl(e)})]}),(0,V.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:e.body}),e.routing?.reason&&(0,V.jsxs)(`span`,{className:`line-clamp-1 text-[10px] text-muted-foreground/80`,children:[`routed because `,e.routing.reason]})]},e.id))})]})]})}function Cl(){let e=j(e=>e.theme),t=j(e=>e.set);return(0,V.jsxs)(pl,{children:[(0,V.jsx)(ml,{asChild:!0,children:(0,V.jsxs)(`button`,{className:`flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors w-full`,children:[(0,V.jsx)(he,{className:`w-3.5 h-3.5`}),(0,V.jsx)(`span`,{children:`Theme`}),(0,V.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:pn.find(t=>t.id===e)?.label})]})}),(0,V.jsx)(hl,{align:`start`,side:`right`,className:`w-40`,children:pn.map(n=>(0,V.jsxs)(gl,{onSelect:()=>t({theme:n.id}),children:[(0,V.jsx)(`span`,{className:`flex-1`,children:n.label}),e===n.id&&(0,V.jsx)(ce,{className:`w-3.5 h-3.5 text-primary`})]},n.id))})]})}function wl(){let e=j(e=>e.view),t=j(e=>e.switchView),n=j(e=>e.connected),r=j(e=>e.showOffline),i=j(e=>e.showBuiltIns),a=j(e=>e.autoRefresh),o=j(e=>e.stats),s=j(e=>e.openCommandPalette),c=j(e=>e.set),l=j(e=>e.startAutoRefresh),u=j(e=>e.stopAutoRefresh),d=nl(),f=rl();function p(e){return e===`overview`&&d.total>0?(0,V.jsx)(I,{variant:`destructive`,className:`ml-auto text-[10px] px-1.5 py-0`,children:d.total}):e===`chat`&&d.unreadInbox>0?(0,V.jsx)(I,{variant:`destructive`,className:`ml-auto text-[10px] px-1.5 py-0`,children:d.unreadInbox}):e===`agents`?(0,V.jsx)(I,{variant:`secondary`,className:`ml-auto text-[10px] px-1.5 py-0`,children:f}):e===`pairs`&&d.pendingPairInvites>0?(0,V.jsx)(I,{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,V.jsx)(I,{className:`ml-auto text-[10px] px-1.5 py-0 bg-yellow-500/20 text-yellow-400`,children:d.claimableTasks}):null}return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`nav`,{className:`flex-1 overflow-y-auto py-2 px-2`,children:nn.map(n=>{let r=yl[n.icon]||C;return(0,V.jsxs)(`button`,{onClick:()=>t(n.key),className:k(`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,V.jsx)(r,{className:`w-4 h-4 shrink-0`}),n.label,p(n.key)]},n.key)})}),(0,V.jsxs)(`div`,{className:`mt-auto border-t border-border p-4 space-y-3 text-xs`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:k(`w-2 h-2 rounded-full`,n?`bg-emerald-500`:`bg-red-500 animate-pulse`)}),(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:n?`Live`:`Reconnecting...`})]}),(0,V.jsxs)(`button`,{onClick:s,className:`flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors w-full`,children:[(0,V.jsx)(We,{className:`w-3.5 h-3.5`}),(0,V.jsx)(`span`,{children:`Command palette`}),(0,V.jsx)(`kbd`,{className:`ml-auto text-[10px] bg-muted px-1.5 py-0.5 rounded`,children:`⌘K`})]}),(0,V.jsx)(Sl,{}),(0,V.jsx)(Cl,{}),(0,V.jsx)(fl,{}),(0,V.jsxs)(`label`,{className:`flex items-center justify-between cursor-pointer`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Show offline`}),(0,V.jsx)(dl,{checked:r,onCheckedChange:e=>c({showOffline:e})})]}),(0,V.jsxs)(`label`,{className:`flex items-center justify-between cursor-pointer`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`System agents`}),(0,V.jsx)(dl,{checked:i,onCheckedChange:e=>c({showBuiltIns:e})})]}),(0,V.jsxs)(`label`,{className:`flex items-center justify-between cursor-pointer`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Auto refresh`}),(0,V.jsx)(dl,{checked:a,onCheckedChange:e=>{c({autoRefresh:e}),e?l():u()}})]}),o.version&&(0,V.jsxs)(`div`,{className:`text-muted-foreground pt-1`,children:[`v`,o.version]})]})]})}function Tl(){return(0,V.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,V.jsxs)(`div`,{className:`px-5 py-4 font-bold text-base border-b border-border flex items-center gap-2`,children:[(0,V.jsx)(oe,{className:`w-4 h-4 text-primary`}),`Agent Relay`]}),(0,V.jsx)(wl,{})]})}function El(){let e=j(e=>e.mobileMenuOpen),t=j(e=>e.set);return(0,B.useEffect)(()=>{if(!e)return;function n(e){e.key===`Escape`&&t({mobileMenuOpen:!1})}return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e]),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:k(`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,V.jsxs)(`aside`,{inert:!e,className:k(`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,V.jsxs)(`div`,{className:`px-5 py-4 font-bold text-base border-b border-border flex items-center gap-2`,children:[(0,V.jsx)(oe,{className:`w-4 h-4 text-primary`}),`Agent Relay`,(0,V.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,V.jsx)(ye,{className:`w-4 h-4`})})]}),(0,V.jsx)(wl,{})]})]})}var Dl=500*1024,Ol={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`},kl={".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`},Al=null;function jl(){return Al??=z(()=>import(`./bundle-web-BLavPdXe.js`),__vite__mapDeps([0,1,2,3]),import.meta.url),Al}function Ml(e){return new TextEncoder().encode(e).length}function Nl(e){return e.split(`/`).filter(Boolean).pop()||e}function Pl(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 Fl(e,t,n,r){if(n)return n;let i=Nl(e).toLowerCase();if(kl[i])return kl[i];if(i.endsWith(`.d.ts`))return`typescript`;let a=Pl(r);if(a)return a;let o=i.includes(`.`)?i.slice(i.lastIndexOf(`.`)+1):``;return o&&Ol[o]?Ol[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 Il(e,t,n,r){let i=Fl(e,t,n,r);return!!(i&&i!==`text`&&i!==`log`)}var Ll=(0,B.memo)(function({content:e,path:t,mediaType:n,languageHint:r,compact:i=!1}){let a=j(e=>e.theme),o=pn.find(e=>e.id===a)?.dark??!0,s=(0,B.useMemo)(()=>Fl(t,n,r,e)||`text`,[e,r,n,t]),c=Ml(e)>Dl,[l,u]=(0,B.useState)(``),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(!1);function h(){return(0,V.jsx)(Un,{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,B.useEffect)(()=>{if(c||s===`text`||s===`log`){u(``),f(!1),m(!1);return}let t=!1;return f(!0),m(!1),jl().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,V.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-sm text-muted-foreground`,children:[(0,V.jsx)(A,{className:`h-4 w-4 animate-spin`}),`Highlighting`]}):c||p||!l?(0,V.jsxs)(`div`,{className:`group/code relative`,children:[h(),(0,V.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap break-words font-mono text-xs leading-5 ${i?`p-3`:`p-4`}`,children:e||` `})]}):(0,V.jsxs)(`div`,{className:`group/code relative`,children:[h(),(0,V.jsx)(`div`,{className:`code-preview overflow-auto font-mono text-xs leading-5 ${i?`p-3`:`p-4`}`,dangerouslySetInnerHTML:{__html:l}})]})}),Rl=(0,B.lazy)(()=>z(()=>import(`./markdown-preview-impl-Bo8ql-lO.js`).then(e=>({default:e.MarkdownPreview})),__vite__mapDeps([4,5,1,3,6]),import.meta.url));function K(e){return(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading preview…`}),children:(0,V.jsx)(Rl,{...e})})}var zl=e(gt(),1);function q({src:e,alt:t,onClose:n}){let[r,i]=(0,B.useState)(!1);return(0,B.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,V.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex flex-col bg-black/95`,children:[(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 p-2`,children:[(0,V.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,V.jsx)(Be,{className:`h-4 w-4`}):(0,V.jsx)(Xe,{className:`h-4 w-4`})}),(0,V.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,V.jsx)(ye,{className:`h-4 w-4`})})]}),(0,V.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,V.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 J({src:e,alt:t=``,className:n,style:r}){let[i,a]=(0,B.useState)(!1);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`img`,{src:e,alt:t,className:`${n||``} cursor-zoom-in`,style:r,onClick:()=>a(!0)}),i&&(0,zl.createPortal)((0,V.jsx)(q,{src:e,alt:t,onClose:()=>a(!1)}),document.body)]})}var Y=`agent-relay:file-git-status`;function Bl(){try{return window.localStorage.getItem(Y)!==`off`}catch{return!0}}function Vl(e){try{window.localStorage.setItem(Y,e?`on`:`off`)}catch{}}function Hl(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 Ul(e,t,n){let r=`/orchestrators/${encodeURIComponent(e)}/files/list?path=${encodeURIComponent(t)}`;return n?`${r}&git=1`:r}function Wl({status:e}){let t=Hl(e);return t?(0,V.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 Kl(e,t){let n=t.replace(/\/+$/,``);return e===n?`/`:e.startsWith(n+`/`)?e.slice(n.length+1):e}function ql(e,t){let n=e.toLowerCase();return n.endsWith(`.md`)||n.endsWith(`.mdx`)||n.endsWith(`.markdown`)||t===`text/markdown`}function Jl(e,t,n){return ql(e,t)?`markdown`:Il(e,t,void 0,n)?`code`:null}function Yl(e){return`agent-relay:file-view-mode:${e}`}function Xl(e){try{let t=window.localStorage.getItem(Yl(e));return t===`raw`||t===`rendered`?t:`rendered`}catch{return`rendered`}}function Zl(e,t){try{window.localStorage.setItem(Yl(e),t)}catch{}}function Ql(e,t){let n=Kl(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 $l(e,t){let n=j(e=>e.apiCall),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(``);return(0,B.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(At(e)))}).finally(()=>{r||o(!1)}),()=>{r=!0}},[n,e,t]),{file:r,loading:a,error:s}}function eu(e,t,n=!1){let r=j(e=>e.apiCall),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(``);return(0,B.useEffect)(()=>{if(!e||!t){a(null),l(``);return}let i=!1;return s(!0),l(``),r(`GET`,Ul(e,t,n)).then(e=>{i||a(e)}).catch(e=>{i||(a(null),l(At(e)))}).finally(()=>{i||s(!1)}),()=>{i=!0}},[r,e,t,n]),{listing:i,loading:o,error:c}}function tu({content:e,line:t,lineRef:n}){return(0,V.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,V.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,V.jsx)(`div`,{className:`select-none pr-2 text-right text-muted-foreground sm:pr-3`,children:i}),(0,V.jsx)(`pre`,{className:`overflow-hidden whitespace-pre-wrap break-words`,children:e||` `})]},i)})})}function nu({orchestratorId:e,selectedPath:t,onReadError:n,git:r=!1}){let{listing:i,loading:a,error:o}=eu(e,t,r);return(0,B.useEffect)(()=>{n(o)},[o,n]),t?a?(0,V.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,V.jsx)(A,{className:`h-4 w-4 animate-spin`}),`Loading directory`]}):o?(0,V.jsx)(`div`,{className:`h-full bg-muted/20`}):i?(0,V.jsxs)(`div`,{className:`h-full overflow-auto bg-muted/20`,children:[(0,V.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,V.jsx)(m,{className:`h-3.5 w-3.5 text-blue-400`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:i.path}),(0,V.jsxs)(I,{variant:`outline`,className:`text-[10px]`,children:[i.entries.length,` items`]})]}),(0,V.jsxs)(`div`,{className:`divide-y divide-border/60`,children:[i.entries.map(e=>{let t=e.type===`directory`?m:_,n=Hl(e.gitStatus);return(0,V.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[(0,V.jsx)(t,{className:`h-4 w-4 shrink-0 ${e.type===`directory`?`text-blue-400`:`text-muted-foreground`}`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs ${n?.text??``}`,children:e.name}),e.symlink&&(0,V.jsx)(ve,{className:`h-3 w-3 shrink-0 text-muted-foreground/60`}),(0,V.jsx)(Wl,{status:e.gitStatus}),e.type!==`directory`&&(0,V.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Gl(e.size)})]},e.path)}),i.entries.length===0&&(0,V.jsx)(`div`,{className:`px-3 py-8 text-center text-sm text-muted-foreground`,children:`No files`})]})]}):null:(0,V.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Select a directory to preview`})}function ru({orchestratorId:e,selectedPath:t,line:n,onReadError:r}){let{file:i,loading:a,error:o}=$l(e,t),s=(0,B.useRef)(null),[c,l]=(0,B.useState)(`raw`);(0,B.useEffect)(()=>{r(o)},[o,r]),(0,B.useEffect)(()=>{n>0&&s.current?.scrollIntoView({block:`center`})},[i,n]),(0,B.useEffect)(()=>{if(!i||i.encoding===`binary`)return;if(n>0){l(`raw`);return}let e=Jl(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&&Zl(t,e)}if(!t)return(0,V.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,V.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,V.jsx)(A,{className:`h-4 w-4 animate-spin`}),`Loading file`]});if(o)return(0,V.jsx)(`div`,{className:`h-full bg-muted/20`});if(!i)return null;if(i.encoding===`base64`)return(0,V.jsxs)(`div`,{className:`flex h-full flex-col bg-muted/20`,children:[(0,V.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,V.jsx)(_,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:i.path}),(0,V.jsx)(Un,{value:i.path,label:`Copy path`,copiedLabel:`Copied path`,size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0`}),(0,V.jsx)(I,{variant:`outline`,className:`text-[10px]`,children:Gl(i.size)})]}),(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:(0,V.jsx)(J,{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,V.jsxs)(`div`,{className:`p-4 text-sm`,children:[(0,V.jsx)(`div`,{className:`font-medium`,children:i.name}),(0,V.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:i.truncated?`File too large to preview.`:`Binary file preview is not available.`}),(0,V.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,V.jsx)(I,{variant:`secondary`,children:i.mediaType}),(0,V.jsx)(I,{variant:`outline`,children:Gl(i.size)})]})]});let d=i.content??``,f=ql(i.path,i.mediaType),p=!f&&Il(i.path,i.mediaType,void 0,d),m=f||p,h=f?`markdown`:p?`code`:null;return(0,V.jsxs)(`div`,{className:`h-full overflow-auto bg-muted/20`,children:[(0,V.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,V.jsx)(_,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:i.path}),(0,V.jsx)(Un,{value:i.path,label:`Copy path`,copiedLabel:`Copied path`,size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0`}),i.truncated&&(0,V.jsx)(I,{variant:`secondary`,className:`text-[10px]`,children:`truncated`}),(0,V.jsx)(I,{variant:`outline`,className:`text-[10px]`,children:Gl(i.size)}),m&&(0,V.jsxs)(`div`,{className:`flex shrink-0 rounded-md border border-border bg-muted/40 p-0.5`,children:[(0,V.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,V.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,V.jsx)(K,{content:d,path:i.path}),c===`rendered`&&p&&(0,V.jsx)(Ll,{content:d,path:i.path,mediaType:i.mediaType}),c===`raw`&&(0,V.jsx)(tu,{content:d,line:n,lineRef:s})]})}function iu({overlay:e=!1}){let t=j(e=>e.apiCall),n=j(e=>e.orchestrators),r=j(e=>e.fileOrchestratorId),i=j(e=>e.filePath),a=j(e=>e.fileSelectedPath),o=j(e=>e.fileSelectedLine),s=j(e=>e.set),c=j(e=>e.closeFileOverlay),l=j(e=>e.openOrchestratorSpawnAt),[u,d]=(0,B.useState)(null),[f,p]=(0,B.useState)(i),[h,g]=(0,B.useState)(!1),[v,b]=(0,B.useState)(``),[x,C]=(0,B.useState)(``),[ee,te]=(0,B.useState)(Bl),w=(0,B.useMemo)(()=>n.filter(e=>e.status===`online`),[n]),T=n.find(e=>e.id===r)||w[0];(0,B.useEffect)(()=>{if(!T)return;let e={};r||(e.fileOrchestratorId=T.id),i||(e.filePath=T.baseDir),Object.keys(e).length&&s(e)},[r,i,T,s]),(0,B.useEffect)(()=>p(i),[i]);async function re(e=i){if(!(!T||!e)){g(!0),b(``);try{let n=await t(`GET`,Ul(T.id,e,ee));d(n),s({filePath:n.path}),p(n.path),C(``)}catch(e){b(At(e))}finally{g(!1)}}}(0,B.useEffect)(()=>{re(i)},[T?.id,i,ee]);function ie(e){te(e),Vl(e)}function ae(e){s({fileOrchestratorId:e,filePath:n.find(t=>t.id===e)?.baseDir||``,fileSelectedPath:``,fileSelectedLine:0})}function oe(e){C(``),e.type===`directory`?s({filePath:e.path,fileSelectedPath:``,fileSelectedLine:0}):s({fileSelectedPath:e.path,fileSelectedLine:0})}function E(){if(!T)return;let t=f.trim()||i||T.baseDir;e&&c(),l({orchestratorId:T.id,cwd:t})}let D=u?Ql(u.path,u.baseDir):[],se=v||x;return(0,V.jsxs)(`div`,{className:e?`flex h-full flex-col`:`flex h-[calc(100dvh-5rem)] flex-col gap-3 md:gap-4`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a?`hidden md:flex`:``}`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,V.jsx)(y,{className:`h-5 w-5 text-primary`}),`Files`]}),(0,V.jsxs)(`select`,{value:T?.id||``,onChange:e=>ae(e.target.value),className:`h-9 rounded-md border border-input bg-background px-3 text-sm`,children:[w.length===0&&(0,V.jsx)(`option`,{value:``,children:`No online orchestrators`}),w.map(e=>(0,V.jsx)(`option`,{value:e.id,children:e.hostname||e.id},e.id))]}),e&&(0,V.jsx)(L,{size:`icon`,variant:`ghost`,className:`ml-auto h-8 w-8`,onClick:c,title:`Close`,children:(0,V.jsx)(ye,{className:`h-4 w-4`})})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a?`hidden md:flex`:``}`,children:[(0,V.jsx)(R,{value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&s({filePath:f,fileSelectedPath:``,fileSelectedLine:0})},className:`min-w-0 flex-1 basis-full font-mono text-xs sm:basis-auto`,placeholder:T?.baseDir||`Path`}),(0,V.jsxs)(L,{size:`sm`,variant:`outline`,className:`gap-1`,onClick:()=>re(f),disabled:h||!T,children:[h?(0,V.jsx)(A,{className:`h-3.5 w-3.5 animate-spin`}):(0,V.jsx)(S,{className:`h-3.5 w-3.5`}),`Open`]}),(0,V.jsxs)(L,{size:`sm`,className:`gap-1`,onClick:E,disabled:!T,children:[(0,V.jsx)(de,{className:`h-3.5 w-3.5`}),(0,V.jsx)(`span`,{className:`sm:hidden`,children:`Spawn`}),(0,V.jsx)(`span`,{className:`hidden sm:inline`,children:`Spawn from here`})]}),(0,V.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,title:`Show git status colors`,children:[(0,V.jsx)(ne,{className:`h-3.5 w-3.5`}),(0,V.jsx)(`span`,{className:`hidden sm:inline`,children:`Git`}),(0,V.jsx)(dl,{checked:ee,onCheckedChange:ie})]})]}),D.length>0&&(0,V.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 text-xs text-muted-foreground ${a?`hidden md:flex`:``}`,children:D.map((e,t)=>(0,V.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<D.length-1&&e.label!==`/`?` /`:``]},`${e.path}-${t}`))}),se&&(0,V.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:se}),(0,V.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,V.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:[u?.parent&&(0,V.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:u.parent,fileSelectedPath:``,fileSelectedLine:0}),children:[(0,V.jsx)(Ze,{className:`h-4 w-4 text-muted-foreground`}),(0,V.jsx)(`span`,{children:`Parent directory`})]}),u?.entries.map(e=>{let t=a===e.path||i===e.path,n=e.type===`directory`?m:_,r=Hl(e.gitStatus);return(0,V.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:()=>oe(e),children:[(0,V.jsx)(n,{className:`h-4 w-4 shrink-0 ${e.type===`directory`?`text-blue-400`:`text-muted-foreground`}`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs ${r?.text??``}`,children:e.name}),e.symlink&&(0,V.jsx)(ve,{className:`h-3 w-3 shrink-0 text-muted-foreground/60`}),(0,V.jsx)(Wl,{status:e.gitStatus}),e.type!==`directory`&&(0,V.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Gl(e.size)})]},e.path)}),!h&&u&&u.entries.length===0&&(0,V.jsx)(`div`,{className:`px-3 py-8 text-center text-sm text-muted-foreground`,children:`No files`})]}),(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden ${a?``:`hidden md:flex`}`,children:[(0,V.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,V.jsx)(Ze,{className:`h-3.5 w-3.5`}),`Back to files`]}),(0,V.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,V.jsx)(ru,{orchestratorId:T?.id||``,selectedPath:a,line:o,onReadError:C})})]})]})]})}function au(){return(0,V.jsx)(iu,{})}function ou(){return j(e=>e.fileOverlayOpen)?(0,V.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/80 backdrop-blur-sm`,children:(0,V.jsx)(`div`,{className:`absolute inset-4 overflow-hidden rounded-md border border-border bg-background p-4 shadow-xl`,children:(0,V.jsx)(iu,{overlay:!0})})}):null}function su(e,t){let n=B.useRef(!1),r=B.useRef(t);r.current=t,B.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 cu({...e}){return su(e.open,e.onOpenChange),(0,V.jsx)(zr,{"data-slot":`sheet`,...e})}function lu({...e}){return(0,V.jsx)(Gr,{"data-slot":`sheet-close`,...e})}function uu({...e}){return(0,V.jsx)(Br,{"data-slot":`sheet-portal`,...e})}function du({className:e,...t}){return(0,V.jsx)(Vr,{"data-slot":`sheet-overlay`,className:k(`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 fu({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,V.jsxs)(uu,{children:[(0,V.jsx)(du,{}),(0,V.jsxs)(Hr,{"data-slot":`sheet-content`,"data-side":n,className:k(`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,V.jsx)(Gr,{"data-slot":`sheet-close`,asChild:!0,children:(0,V.jsxs)(L,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`,children:[(0,V.jsx)(ye,{}),(0,V.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function pu({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`sheet-header`,className:k(`flex flex-col gap-0.5 p-4`,e),...t})}function mu({className:e,...t}){return(0,V.jsx)(Ur,{"data-slot":`sheet-title`,className:k(`font-heading text-base font-medium text-foreground`,e),...t})}function hu({className:e,orientation:t=`horizontal`,...n}){return(0,V.jsx)(nc,{"data-slot":`tabs`,"data-orientation":t,className:k(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var gu=vn(`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 _u({className:e,variant:t=`default`,...n}){return(0,V.jsx)(rc,{"data-slot":`tabs-list`,"data-variant":t,className:k(gu({variant:t}),e),...n})}function vu({className:e,...t}){return(0,V.jsx)(ic,{"data-slot":`tabs-trigger`,className:k(`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 yu({className:e,...t}){return(0,V.jsx)(ac,{"data-slot":`tabs-content`,className:k(`flex-1 text-sm outline-none`,e),...t})}function bu({agent:e,now:t,className:n}){return(0,V.jsx)(`span`,{className:k(`inline-block w-2.5 h-2.5 rounded-full shrink-0`,Ft(e,t),n)})}function xu({className:e}){return(0,V.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,className:e,children:(0,V.jsx)(`path`,{d:`m3.127 10.604 3.135-1.76.053-.153-.053-.085H6.11l-.525-.032-1.791-.048-1.554-.065-1.505-.08-.38-.081L0 7.832l.036-.234.32-.214.455.04 1.009.069 1.513.105 1.097.064 1.626.17h.259l.036-.105-.089-.065-.068-.064-1.566-1.062-1.695-1.121-.887-.646-.48-.327-.243-.306-.104-.67.435-.48.585.04.15.04.593.456 1.267.981 1.654 1.218.242.202.097-.068.012-.049-.109-.181-.9-1.626-.96-1.655-.428-.686-.113-.411a2 2 0 0 1-.068-.484l.496-.674L4.446 0l.662.089.279.242.411.94.666 1.48 1.033 2.014.302.597.162.553.06.17h.105v-.097l.085-1.134.157-1.392.154-1.792.052-.504.25-.605.497-.327.387.186.319.456-.045.294-.19 1.23-.37 1.93-.243 1.29h.142l.161-.16.654-.868 1.097-1.372.484-.545.565-.601.363-.287h.686l.505.751-.226.775-.707.895-.585.759-.839 1.13-.524.904.048.072.125-.012 1.897-.403 1.024-.186 1.223-.21.553.258.06.263-.218.536-1.307.323-1.533.307-2.284.54-.028.02.032.04 1.029.098.44.024h1.077l2.005.15.525.346.315.424-.053.323-.807.411-3.631-.863-.872-.218h-.12v.073l.726.71 1.331 1.202 1.667 1.55.084.383-.214.302-.226-.032-1.464-1.101-.565-.497-1.28-1.077h-.084v.113l.295.432 1.557 2.34.08.718-.112.234-.404.141-.444-.08-.911-1.28-.94-1.44-.759-1.291-.093.053-.448 4.821-.21.246-.484.186-.403-.307-.214-.496.214-.98.258-1.28.21-1.016.19-1.263.112-.42-.008-.028-.092.012-.953 1.307-1.448 1.957-1.146 1.227-.274.109-.477-.247.045-.44.266-.39 1.586-2.018.956-1.25.617-.723-.004-.105h-.036l-4.212 2.736-.75.096-.324-.302.04-.496.154-.162 1.267-.871z`})})}function Su({className:e}){return(0,V.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,className:e,children:(0,V.jsx)(`path`,{d:`M22.282 9.821a5.985 5.985 0 0 0-.516-4.91 6.046 6.046 0 0 0-6.51-2.9A6.065 6.065 0 0 0 4.981 4.18a5.985 5.985 0 0 0-3.998 2.9 6.046 6.046 0 0 0 .743 7.097 5.98 5.98 0 0 0 .51 4.911 6.051 6.051 0 0 0 6.515 2.9A5.985 5.985 0 0 0 13.26 24a6.056 6.056 0 0 0 5.772-4.206 5.99 5.99 0 0 0 3.997-2.9 6.056 6.056 0 0 0-.747-7.073zM13.26 22.43a4.476 4.476 0 0 1-2.876-1.04l.141-.081 4.779-2.758a.795.795 0 0 0 .392-.681v-6.737l2.02 1.168a.071.071 0 0 1 .038.052v5.583a4.504 4.504 0 0 1-4.494 4.494zM3.6 18.304a4.47 4.47 0 0 1-.535-3.014l.142.085 4.783 2.759a.771.771 0 0 0 .78 0l5.843-3.369v2.332a.08.08 0 0 1-.033.062L9.74 19.95a4.5 4.5 0 0 1-6.14-1.646zM2.34 7.896a4.485 4.485 0 0 1 2.366-1.973V11.6a.766.766 0 0 0 .388.676l5.815 3.355-2.02 1.168a.076.076 0 0 1-.071 0l-4.83-2.786A4.504 4.504 0 0 1 2.34 7.872zm16.597 3.855-5.833-3.387L15.119 7.2a.076.076 0 0 1 .071 0l4.83 2.791a4.494 4.494 0 0 1-.676 8.105v-5.678a.79.79 0 0 0-.407-.667zm2.01-3.023-.141-.085-4.774-2.782a.776.776 0 0 0-.785 0L9.409 9.23V6.897a.066.066 0 0 1 .028-.061l4.83-2.787a4.5 4.5 0 0 1 6.68 4.66zm-12.64 4.135-2.02-1.164a.08.08 0 0 1-.038-.057V6.075a4.5 4.5 0 0 1 7.375-3.453l-.142.08L8.704 5.46a.795.795 0 0 0-.393.681zm1.097-2.365 2.602-1.5 2.607 1.5v2.999l-2.597 1.5-2.607-1.5z`})})}var Cu={claude:xu,anthropic:xu,codex:Su,openai:Su},wu={claude:`text-orange-400`,anthropic:`text-orange-400`};function Tu({provider:e,className:t}){let n=e.toLowerCase(),r=Cu[n];return r?(0,V.jsx)(`span`,{role:`img`,"aria-label":e,title:e,className:`inline-flex shrink-0`,children:(0,V.jsx)(r,{className:k(wu[n],t)})}):(0,V.jsx)(`span`,{className:`capitalize`,children:e})}var Eu={codex:`text-blue-400 bg-blue-500/10 border-blue-500/25`,claude:`text-orange-400 bg-orange-500/10 border-orange-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`},Du={codex:_e,claude:xu,user:we,system:c,channel:rt,agent:C};function Ou({agent:e,className:t}){let n=tn(e),r=Du[n]||C;return(0,V.jsx)(`span`,{className:k(`inline-flex items-center justify-center w-5 h-5 rounded-md border text-sm`,Eu[n]||Eu.agent,t),children:(0,V.jsx)(r,{className:`w-3.5 h-3.5`})})}function ku({agent:e,compact:t=!1}){let n=zu(e);return n.length===0?null:(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:n.slice(0,t?4:void 0).map(e=>(0,V.jsx)(I,{variant:`outline`,className:`text-[9px] px-1 py-0 h-4`,children:e},e))})}function Au({agent:e,compact:t=!1,className:n=``}){let r=Mu(e);return(0,V.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 ${n}`,children:r.map(e=>{let n=e.Icon;return(0,V.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,V.jsx)(n,{className:`h-3 w-3 shrink-0`}),!t&&(0,V.jsx)(`span`,{children:e.label})]},e.key)})})}function ju({agent:e}){let t=e.context;if(!t)return null;let n=Hu(t);if(n===null)return(0,V.jsxs)(`div`,{className:`space-y-1`,title:Uu(t),children:[(0,V.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground`,children:[(0,V.jsx)(`span`,{children:`collecting`}),(0,V.jsx)(`span`,{children:`--`})]}),(0,V.jsx)(`div`,{className:`h-1.5 rounded-full bg-muted overflow-hidden`,children:(0,V.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,V.jsxs)(`div`,{className:`space-y-1`,title:Uu(t),children:[(0,V.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground`,children:[(0,V.jsx)(`span`,{children:t.lifecycleState}),(0,V.jsxs)(`span`,{children:[r,`%`]})]}),(0,V.jsx)(`div`,{className:`h-1.5 rounded-full bg-muted overflow-hidden`,children:(0,V.jsx)(`div`,{className:`h-full ${i}`,style:{width:`${Math.max(0,Math.min(100,r))}%`}})})]})}function Mu(e){let t=Nu(e),n=Pu(e),r=Fu(e);return[{key:`origin`,label:t?`Relay`:`External`,title:t?`Agent Relay spawned this agent`:`Externally started agent registered with Agent Relay`,Icon:t?p: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 Nu(e){return typeof e.meta?.spawnRequestId==`string`||typeof e.meta?.policyName==`string`||typeof e.meta?.automationRunId==`string`}function Pu(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:De,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:b,className:`border-blue-500/30 bg-blue-500/10 text-blue-300`}:{key:`approval`,label:`Guarded`,title:`Approval mode: guarded`,Icon:Te,className:`border-amber-500/30 bg-amber-500/10 text-amber-300`}}function Fu(e){let t=Iu(e.meta?.workspace),n=wt(t.requestedMode)||wt(e.meta?.workspaceMode),r=wt(t.mode),i=n&&n!==`inherit`?n:r&&n!==`inherit`?r:`default`;return i===`isolated`?{key:`workspace`,label:`Isolated`,title:`Workspace: isolated worktree`,Icon:ne,iconColor:`text-violet-300`,className:`border-violet-500/30 bg-violet-500/10 text-violet-300`}:i===`shared`?{key:`workspace`,label:`Shared`,title:`Workspace: shared repo checkout`,Icon:se,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:dt,iconColor:`text-zinc-400`,className:`border-zinc-500/30 bg-zinc-500/10 text-zinc-300`}}function Iu(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Lu(e){let t=Iu(e.meta?.workspace),n=wt(t.repoRoot)||wt(t.sourceCwd)||wt(e.meta?.cwd);return n?Vt(n,2):``}function Ru(e){return!!(e.context||e.providerCapabilities?.context)}function zu(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=sn(e).length;if(i&&r.push(i===1?`1 subagent`:`${i} subagents`),n){let e=Hu(n);r.push(e===null?`ctx collecting`:`${Math.round(e*100)}% ctx`)}return r}function Bu({context:e,expected:t=!!e,size:n=26,className:r}){let i=Hu(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,V.jsxs)(`div`,{className:`relative shrink-0 ${u?`opacity-70`:``} ${r??``}`,style:{width:n,height:n},title:Uu(e),children:[(0,V.jsxs)(`svg`,{width:n,height:n,viewBox:`0 0 ${n} ${n}`,className:`rotate-[-90deg]`,children:[(0,V.jsx)(`circle`,{cx:o,cy:o,r:s,fill:`none`,strokeWidth:a,className:`stroke-muted-foreground/20`}),(0,V.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,V.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 Vu(e){let t=e.context;return!t?.tokensUsed&&!t?.tokensMax?null:t.tokensUsed&&t.tokensMax?`${Wu(t.tokensUsed)} / ${Wu(t.tokensMax)}`:t.tokensUsed?Wu(t.tokensUsed):t.tokensMax?Wu(t.tokensMax):null}function Hu(e){return!e||typeof e.utilization!=`number`||!Number.isFinite(e.utilization)?null:Math.min(1,Math.max(0,e.utilization))}function Uu(e){if(!e)return`Context: collecting; provider has not reported usage yet`;let t=Hu(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 Wu(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}var Gu=(0,B.lazy)(()=>z(()=>import(`./terminal-viewer-impl-Cig30gnt.js`).then(e=>({default:e.TerminalDialog})),__vite__mapDeps([7,1,6,8,9,10,11,12,13,14]),import.meta.url));function X(e){return e.open?(0,V.jsx)(B.Suspense,{fallback:null,children:(0,V.jsx)(Gu,{...e})}):null}function Ku({orchestratorId:e,session:t,lines:n=200}){let r=j(e=>e.apiCall),[a,o]=(0,B.useState)([]),[s,c]=(0,B.useState)(``),[l,u]=(0,B.useState)(!1),[d,f]=(0,B.useState)(`provider`),[p,m]=(0,B.useState)(null);async function h(){if(!l)try{o((await r(`GET`,`/orchestrators/${encodeURIComponent(e)}/logs/${encodeURIComponent(t)}?lines=${n}${d===`mirror`?`&stream=mirror`:``}`)).lines||[]),m(null)}catch(e){m(At(e))}}(0,B.useEffect)(()=>{h();let e=setInterval(()=>void h(),1500);return()=>clearInterval(e)},[e,t,l,d]);let g=s?a.filter(e=>e.toLowerCase().includes(s.toLowerCase())):a;return(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsxs)(`div`,{className:`relative min-w-48 flex-1`,children:[(0,V.jsx)(i,{className:`absolute left-2 top-2.5 h-4 w-4 text-muted-foreground`}),(0,V.jsx)(R,{className:`pl-8`,value:s,onChange:e=>c(e.target.value),placeholder:`Search logs`})]}),(0,V.jsxs)(`div`,{className:`flex rounded-md border border-border overflow-hidden`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>f(`provider`),title:`Provider output`,className:k(`flex items-center gap-1 px-2 py-1.5 text-xs`,d===`provider`?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/50`),children:[(0,V.jsx)(_e,{className:`h-3.5 w-3.5`}),` Output`]}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>f(`mirror`),title:`Session-mirror diagnostics (clean)`,className:k(`flex items-center gap-1 px-2 py-1.5 text-xs border-l border-border`,d===`mirror`?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/50`),children:[(0,V.jsx)(T,{className:`h-3.5 w-3.5`}),` Mirror`]})]}),(0,V.jsx)(L,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>u(e=>!e),title:l?`Resume logs`:`Pause logs`,children:l?(0,V.jsx)(le,{className:`h-4 w-4`}):(0,V.jsx)(Je,{className:`h-4 w-4`})}),(0,V.jsx)(L,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>rn(`${t}.log`,a.join(`
|
|
16
16
|
`),`text/plain`),title:`Download logs`,children:(0,V.jsx)(O,{className:`h-4 w-4`})})]}),p&&(0,V.jsx)(`div`,{className:`text-sm text-destructive`,children:p}),(0,V.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:g.join(`
|
|
17
17
|
`)||`No log output`})]})}function qu(e,t){let n=t?.meta?.busyHealth;if(!t||t.status!==`busy`||!Ct(n)||n.status!==`stuck-busy`)return null;let r=typeof n.activeWorkStartedAt==`number`?n.activeWorkStartedAt:0;if(!r)return null;let i=typeof n.lastProgressAt==`number`?n.lastProgressAt:r;return{kind:typeof n.kind==`string`?n.kind:`provider-turn`,thresholdMs:typeof n.thresholdMs==`number`&&n.thresholdMs>0?n.thresholdMs:0,activeWorkId:typeof n.activeWorkId==`string`?n.activeWorkId:void 0,activeWorkLabel:typeof n.activeWorkLabel==`string`?n.activeWorkLabel:void 0,activeWorkStartedAt:r,activeWorkAgeMs:Math.max(0,e-r),lastProgressAt:i,staleForMs:Math.max(0,e-i)}}var Ju={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 Yu({agent:e,orchestrators:t}){let n=yt(),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)([]),[s,c]=(0,B.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=Ct(e.meta?.agentProfile)?e.meta.agentProfile:null,f=Zu(d?.projection)?d.projection:null,p=t.find(t=>t.managedAgents.some(t=>t.agentId===e.id)),m=p?.managedAgents.find(t=>t.agentId===e.id);(0,B.useEffect)(()=>{if(!l)return;let e=!1;return Qe(`GET`,`/spawn-policies/`+encodeURIComponent(l)+`/status`).then(t=>{e||i(t)}).catch(()=>{e||i(null)}),()=>{e=!0}},[l,e.lastSeen]),(0,B.useEffect)(()=>{let t=!1;return Qe(`GET`,`/activity?agentId=`+encodeURIComponent(e.id)+`&limit=20`).then(e=>{t||o(e)}).catch(()=>{t||o([])}),()=>{t=!0}},[e.id,e.lastSeen]);function h(e){c(t=>({...t,[e]:!t[e]}))}function g(){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(m&&(i.push(``,`## Runtime`),m.pid&&i.push(`PID: ${m.pid}`),m.sessionName&&i.push(`Session: ${m.sessionName}`),m.supervisor&&i.push(`Supervisor: ${m.supervisor}`),m.systemdUnit&&i.push(`Systemd: ${m.systemdUnit}`),m.terminalSession&&i.push(`Terminal: ${m.terminalSession} (${m.terminalAvailable?`available`:`unavailable`})`),m.tmuxSession&&m.tmuxSession!==m.sessionName&&i.push(`Legacy tmux: ${m.tmuxSession}`),m.spawnRequestId&&i.push(`Spawn Request: ${m.spawnRequestId}`),m.startedAt&&i.push(`Started: ${new Date(m.startedAt).toISOString()}`),p&&i.push(`Orchestrator: ${p.hostname} (${p.id.slice(-8)})`)),m?.workspace&&(i.push(``,`## Workspace`),i.push(`Mode: ${m.workspace.mode}`),m.workspace.status&&i.push(`Status: ${m.workspace.status}`),m.workspace.worktreePath&&i.push(`Worktree: ${m.workspace.worktreePath}`),m.workspace.repoRoot&&i.push(`Repo: ${m.workspace.repoRoot}`),m.workspace.branch&&i.push(`Branch: ${m.workspace.branch}`),m.workspace.baseRef&&i.push(`Base: ${m.workspace.baseRef}`),m.workspace.baseSha&&i.push(`Base SHA: ${m.workspace.baseSha}`),m.workspace.stewardAgentId&&i.push(`Steward: ${m.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 _=r?.policy,v=r?.state;return(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsxs)(`h3`,{className:`text-sm font-medium flex items-center gap-1.5`,children:[(0,V.jsx)(ft,{className:`w-3.5 h-3.5 text-muted-foreground`}),`Diagnostics`]}),(0,V.jsx)(Un,{value:g,label:`Copy Bundle`,showText:!0,size:`sm`,variant:`outline`,className:`h-7 text-xs gap-1`,iconClassName:`w-3 h-3`})]}),_&&(0,V.jsx)(Xu,{title:`Spawn Config`,expanded:!!s.spawn,onToggle:()=>h(`spawn`),children:(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 text-xs`,children:[(0,V.jsx)(Z,{label:`Provider`,value:_.provider}),_.model&&(0,V.jsx)(Z,{label:`Model`,value:_.model}),_.effort&&(0,V.jsx)(Z,{label:`Effort`,value:_.effort}),(0,V.jsx)(Z,{label:`Permission`,value:_.permissionMode}),(0,V.jsx)(Z,{label:`Mode`,value:_.mode}),_.rig&&(0,V.jsx)(Z,{label:`Rig`,value:_.rig}),(0,V.jsx)(Z,{label:`CWD`,value:_.cwd,className:`col-span-2`,mono:!0}),_.tags.length>0&&(0,V.jsxs)(`div`,{className:`col-span-2`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Tags`}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-0.5`,children:_.tags.map(e=>(0,V.jsx)(I,{variant:`outline`,className:`text-[10px]`,children:e},e))})]}),_.capabilities.length>0&&(0,V.jsxs)(`div`,{className:`col-span-2`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Capabilities`}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-0.5`,children:_.capabilities.map(e=>(0,V.jsx)(I,{variant:`secondary`,className:`text-[10px]`,children:e},e))})]}),_.providerArgs.length>0&&(0,V.jsx)(Z,{label:`Provider Args`,value:_.providerArgs.join(` `),className:`col-span-2`,mono:!0}),_.binding&&(0,V.jsx)(Z,{label:`Channel`,value:`${_.binding.type}:${_.binding.channelId}`,className:`col-span-2`})]})}),(u||f)&&(0,V.jsx)(Xu,{title:`Agent Profile`,expanded:!!s.profile,onToggle:()=>h(`profile`),children:(0,V.jsxs)(`div`,{className:`space-y-2 text-xs`,children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1`,children:[u&&(0,V.jsx)(Z,{label:`Profile`,value:u}),f?.base&&(0,V.jsx)(Z,{label:`Base`,value:f.base}),f?.provider&&(0,V.jsx)(Z,{label:`Provider`,value:f.provider}),f&&(0,V.jsx)(Z,{label:`Unsupported`,value:String(f.unsupported.length)})]}),f?.warnings.length?(0,V.jsxs)(`div`,{className:`rounded border border-yellow-500/20 bg-yellow-500/5 px-2 py-1.5`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Projection warnings`}),(0,V.jsx)(`div`,{className:`mt-1 space-y-1`,children:f.warnings.slice(0,4).map(e=>(0,V.jsx)(`div`,{className:`break-words text-yellow-200/80`,children:e},e))})]}):null,f&&(0,V.jsx)(`div`,{className:`space-y-1`,children:f.entries.map(e=>(0,V.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2 rounded border border-border/60 px-2 py-1`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`font-mono text-[11px]`,children:e.capability}),(0,V.jsx)(`div`,{className:`break-words text-muted-foreground`,children:e.detail})]}),(0,V.jsx)(I,{variant:e.result===`unsupported`?`destructive`:e.result===`partial`?`outline`:`secondary`,className:`h-5 text-[10px]`,children:e.result})]},e.capability))})]})}),m?.workspace&&(0,V.jsx)(Xu,{title:`Workspace`,expanded:!!s.workspace,onToggle:()=>h(`workspace`),children:(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 text-xs`,children:[(0,V.jsx)(Z,{label:`Mode`,value:m.workspace.mode}),m.workspace.status&&(0,V.jsx)(Z,{label:`Status`,value:m.workspace.status}),m.workspace.worktreePath&&(0,V.jsx)(Z,{label:`Worktree`,value:m.workspace.worktreePath,className:`col-span-2`,mono:!0}),m.workspace.repoRoot&&(0,V.jsx)(Z,{label:`Repo`,value:m.workspace.repoRoot,className:`col-span-2`,mono:!0}),m.workspace.branch&&(0,V.jsx)(Z,{label:`Branch`,value:m.workspace.branch,className:`col-span-2`,mono:!0}),m.workspace.baseRef&&(0,V.jsx)(Z,{label:`Base`,value:m.workspace.baseRef}),m.workspace.baseSha&&(0,V.jsx)(Z,{label:`Base SHA`,value:m.workspace.baseSha.slice(0,12),mono:!0}),m.workspace.stewardAgentId&&(0,V.jsx)(Z,{label:`Steward`,value:m.workspace.stewardAgentId,className:`col-span-2`,mono:!0})]})}),m&&(0,V.jsx)(Xu,{title:`Runtime`,expanded:!!s.runtime,onToggle:()=>h(`runtime`),children:(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 text-xs`,children:[m.pid&&(0,V.jsx)(Z,{label:`PID`,value:String(m.pid),mono:!0}),m.sessionName&&(0,V.jsx)(Z,{label:`Session`,value:m.sessionName,mono:!0}),m.supervisor&&(0,V.jsx)(Z,{label:`Supervisor`,value:m.supervisor}),m.systemdUnit&&(0,V.jsx)(Z,{label:`Systemd`,value:m.systemdUnit,mono:!0}),m.terminalSession&&(0,V.jsx)(Z,{label:`Terminal`,value:`${m.terminalSession} (${m.terminalAvailable?`available`:`unavailable`})`,mono:!0}),m.tmuxSession&&m.tmuxSession!==m.sessionName&&(0,V.jsx)(Z,{label:`Legacy tmux`,value:m.tmuxSession,mono:!0}),m.spawnRequestId&&(0,V.jsx)(Z,{label:`Spawn ID`,value:m.spawnRequestId.slice(0,12),mono:!0}),m.startedAt&&(0,V.jsx)(Z,{label:`Started`,value:Jt(m.startedAt)}),p&&(0,V.jsx)(Z,{label:`Orchestrator`,value:`${p.hostname} (${p.id.slice(-8)})`}),p&&(0,V.jsx)(Z,{label:`Orch Status`,value:p.status})]})}),v&&(0,V.jsx)(Xu,{title:`Lifecycle`,expanded:!!s.lifecycle,onToggle:()=>h(`lifecycle`),children:(0,V.jsxs)(`div`,{className:`space-y-2 text-xs`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Status`}),(0,V.jsx)(I,{className:Ju[v.status]||`bg-zinc-500/20 text-zinc-400`,children:v.status})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1`,children:[(0,V.jsx)(Z,{label:`Restarts`,value:String(v.restartCount)}),(0,V.jsx)(Z,{label:`Failures`,value:String(v.consecutiveFailures)}),v.lastSpawnAt&&(0,V.jsx)(Z,{label:`Last spawn`,value:M(n,v.lastSpawnAt)}),v.lastStopAt&&(0,V.jsx)(Z,{label:`Last stop`,value:M(n,v.lastStopAt)}),v.healthySince&&(0,V.jsx)(Z,{label:`Healthy since`,value:M(n,v.healthySince)}),v.backoffUntil&&(0,V.jsx)(Z,{label:`Backoff until`,value:v.backoffUntil>n?M(n,v.backoffUntil):`expired`})]}),v.lastError&&(0,V.jsxs)(`div`,{className:`rounded border border-red-500/20 bg-red-500/5 px-2 py-1.5`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Last error`}),(0,V.jsx)(`div`,{className:`mt-0.5 break-words text-red-300/80`,children:v.lastError})]})]})}),(0,V.jsx)(Xu,{title:`Activity (${a.length})`,expanded:!!s.activity,onToggle:()=>h(`activity`),children:a.length===0?(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No recent events`}):(0,V.jsx)(`div`,{className:`space-y-1`,children:a.slice(0,15).map(e=>(0,V.jsxs)(`div`,{className:`flex items-start gap-2 text-xs`,children:[(0,V.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground tabular-nums w-14`,children:M(n,typeof e.createdAt==`number`?e.createdAt:Date.parse(String(e.createdAt)))}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`span`,{className:`font-medium`,children:e.title}),e.body&&(0,V.jsx)(`span`,{className:`text-muted-foreground ml-1 break-words`,children:e.body.length>80?e.body.slice(0,80)+`...`:e.body})]})]},e.id))})}),!_&&!m&&!v&&a.length===0&&(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No managed-agent diagnostics available for this agent.`})]})}function Xu({title:e,expanded:t,onToggle:n,children:r}){return(0,V.jsxs)(`div`,{className:`rounded-md border border-border`,children:[(0,V.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,V.jsx)(ct,{className:`w-3 h-3`}):(0,V.jsx)(D,{className:`w-3 h-3`}),e]}),t&&(0,V.jsx)(`div`,{className:`px-2.5 pb-2.5`,children:r})]})}function Zu(e){return Ct(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 Z({label:e,value:t,className:n=``,mono:r=!1}){return(0,V.jsxs)(`div`,{className:`min-w-0 ${n}`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,V.jsx)(`div`,{className:`truncate ${r?`font-mono`:``}`,title:t,children:t})]})}function Qu({agent:e,className:t=``,onNavigate:n}){let r=typeof e.meta?.cwd==`string`?e.meta.cwd:``,i=j(e=>r?e.projectByCwd[r]:null),a=j(e=>e.fetchProjectForCwd),o=j(e=>e.openProjectFocus);return(0,B.useEffect)(()=>{r&&a(r)},[r,a]),i?(0,V.jsxs)(`button`,{type:`button`,title:`Project: ${i.title||i.slug} — open in Projects`,onClick:e=>{e.stopPropagation(),n?.(),o(i.id)},className:`inline-flex h-5 max-w-full items-center gap-1 rounded-full border border-indigo-500/30 bg-indigo-500/10 px-1.5 text-[10px] font-medium text-indigo-300 transition-colors hover:bg-indigo-500/20 ${t}`,children:[(0,V.jsx)(v,{className:`h-3 w-3 shrink-0`}),(0,V.jsx)(`span`,{className:`truncate`,children:i.title||i.slug})]}):null}function $u({className:e}){return(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,className:e,children:(0,V.jsx)(`path`,{d:`M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.65 7.65 0 0 1 2-.27c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8Z`})})}var ed={github:$u},td=ke;function nd({provider:e,className:t}){return(0,V.jsx)(ed[e]??td,{className:k(`shrink-0`,t)})}var rd={open:`border-emerald-500/25 bg-emerald-500/10 text-emerald-300`,closed:`border-zinc-500/25 bg-zinc-500/10 text-zinc-300`,unknown:`border-amber-500/25 bg-amber-500/10 text-amber-300`},id=1440*60*1e3;function ad(e){return`${e.repo}#${e.externalKey}`}function od(e,t){return e.statusSyncedAt?`Status synced ${M(t,e.statusSyncedAt)} (${Jt(e.statusSyncedAt)})`:`Status not yet synced`}function sd({issueRef:e,now:t=Date.now(),compact:n=!1,showSync:r=!1,className:i}){let a=ad(e),o=!e.statusSyncedAt||t-e.statusSyncedAt>id,s=[e.title?`${a}: ${e.title}`:a,`Status: ${e.status}`,od(e,t)].join(`
|
|
19
19
|
`);return(0,V.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,title:s,"aria-label":`Open ${a}`,onClick:e=>e.stopPropagation(),className:k(`inline-flex h-5 max-w-full items-center gap-1.5 rounded-full border pl-1.5 pr-2 text-[10px] font-medium leading-none transition-colors hover:brightness-125 focus:outline-none focus-visible:ring-1 focus-visible:ring-current`,rd[e.status],i),children:[(0,V.jsx)(nd,{provider:e.provider,className:`h-3 w-3 opacity-90`}),(0,V.jsx)(`span`,{className:`truncate font-mono tracking-tight`,children:a}),!n&&(0,V.jsx)(`span`,{className:`shrink-0 opacity-70`,children:e.status}),r&&!n&&(0,V.jsxs)(`span`,{className:k(`shrink-0 tabular-nums`,o?`opacity-45`:`opacity-65`),children:[(0,V.jsx)(`span`,{"aria-hidden":!0,className:`mr-1 opacity-60`,children:`·`}),e.statusSyncedAt?M(t,e.statusSyncedAt):`unsynced`]}),(0,V.jsx)(me,{className:`ml-0.5 h-2.5 w-2.5 shrink-0 opacity-60`})]})}var cd={read:`read`,edit:`edited`,done:`completed`},ld={done:`border-emerald-500/30 bg-emerald-500/10 text-emerald-300`},ud=[];function dd(e){let t=new Map;for(let n of e){let e=t.get(n.issueRef.id),r={action:n.action,count:n.count,firstAt:n.firstAt,lastAt:n.lastAt};e?(e.actions.push(r),e.lastAt=Math.max(e.lastAt,n.lastAt)):t.set(n.issueRef.id,{issueRef:n.issueRef,actions:[r],lastAt:n.lastAt})}return[...t.values()].sort((e,t)=>t.lastAt-e.lastAt||e.issueRef.id.localeCompare(t.issueRef.id))}function fd({agentId:e,now:t}){let n=j(e=>e.fetchAgentIssueActivity),r=j(t=>t.issueActivityByAgent[e]??ud),i=j(e=>e.issueRefsById),a=j(t=>!!t.issueLoading[`agent:${e}`]),o=j(t=>t.issueErrors[`agent:${e}`]??null),s=(0,B.useMemo)(()=>dd(r.map(e=>({...e,issueRef:i[e.issueRef.id]??e.issueRef}))),[r,i]);return(0,B.useEffect)(()=>{n(e)},[e,n]),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium`,children:`Issues`}),a?(0,V.jsx)(I,{variant:`secondary`,className:`text-[10px]`,children:`loading`}):(0,V.jsx)(I,{variant:`secondary`,className:`text-[10px]`,children:s.length})]}),o?(0,V.jsx)(`div`,{className:`text-xs text-destructive`,children:o}):s.length===0?(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No issue activity recorded for this agent.`}):(0,V.jsx)(`div`,{className:`space-y-2`,children:s.map(e=>(0,V.jsxs)(`div`,{className:`rounded-md border border-border px-2.5 py-2 text-xs`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,V.jsx)(sd,{issueRef:e.issueRef,now:t}),(0,V.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground`,title:Jt(e.lastAt),children:M(t,e.lastAt)})]}),(0,V.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:e.actions.map(e=>(0,V.jsxs)(I,{variant:`outline`,className:k(`text-[10px]`,ld[e.action]),title:`${e.count} event${e.count===1?``:`s`} since ${Jt(e.firstAt)}`,children:[cd[e.action],e.count>1?` ${e.count}`:``]},e.action))})]},e.issueRef.id))})]})]})}function pd(e){let t=e?.meta?.tmuxSession;return typeof t==`string`&&t.trim()?t:null}function md(e,t,n){return e?n.find(n=>n.managedAgents.some(n=>n.agentId===e.id||n.tmuxSession===t))??null:null}function hd({agent:e,health:t,showLogs:n,setTab:r,openConfirm:i,doAgentAction:a}){let o=Wt(e,`interrupt`),s=Wt(e,`restart`),c=Wt(e,`shutdown`),l=t.activeWorkLabel||t.kind;return(0,V.jsxs)(`div`,{className:`shrink-0 mx-4 mt-3 rounded-md border border-red-500/35 bg-red-500/10 px-3 py-2 text-xs text-red-100`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,V.jsx)(je,{className:`w-3.5 h-3.5`}),`Stuck busy`]}),(0,V.jsxs)(`div`,{className:`mt-1 text-red-50/85`,children:[`No provider progress for `,Math.max(1,Math.floor(t.staleForMs/6e4)),` min while `,l,` is active.`]}),(0,V.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[o&&(0,V.jsxs)(L,{size:`sm`,variant:`outline`,className:`h-7 text-xs`,onClick:()=>a(e,`interrupt`,`agent-detail-drawer`),children:[(0,V.jsx)(qe,{className:`w-3 h-3 mr-1`}),`Interrupt`]}),s&&(0,V.jsxs)(L,{size:`sm`,variant:`outline`,className:`h-7 text-xs`,onClick:()=>i(`Restart Agent`,`Restart ${N(e)}?`,()=>a(e,`restart`,`agent-detail-drawer`)),children:[(0,V.jsx)(w,{className:`w-3 h-3 mr-1`}),`Restart`]}),c&&(0,V.jsxs)(L,{size:`sm`,variant:`outline`,className:`h-7 text-xs`,onClick:()=>i(`Shutdown Agent`,`Shutdown ${N(e)}?`,()=>a(e,`shutdown`,`agent-detail-drawer`)),children:[(0,V.jsx)(mt,{className:`w-3 h-3 mr-1`}),`Shutdown`]}),(0,V.jsxs)(L,{size:`sm`,variant:`outline`,className:`h-7 text-xs`,onClick:()=>r(n?`logs`:`timeline`),children:[(0,V.jsx)(ue,{className:`w-3 h-3 mr-1`}),`Diagnostics`]})]})]})}function gd(e){return!e||e.status!==`offline`&&e.status!==`stale`?!1:!!(typeof e.meta?.provider==`string`?e.meta.provider:e.providerCapabilities?.model?.provider)}function _d(e){for(let t of e){let e=t.metadata,n=typeof e?.claudeResumeId==`string`?e.claudeResumeId:``;if(n)return{resumeId:n,timestamp:t.ts}}return null}function vd(e,t){return!!e.spawnedBy&&e.status!==`offline`&&!un(t,e)}function yd(e,t){let n=new Map;for(let r of e){if(!r.spawnedBy||!vd(r,t))continue;let e=n.get(r.spawnedBy);e?e.push(r):n.set(r.spawnedBy,[r])}return n}function Q(e,t,n){let r=new Set(e.map(e=>e.id)),i=yd(e,n),a=[],o=new Set;for(let s of e){if(o.has(s.id)||s.spawnedBy&&!vd(s,n))continue;let e=!!(s.spawnedBy&&r.has(s.spawnedBy));if(vd(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 bd(e,t){let n=new Set(e.map(e=>e.id));return e.filter(e=>e.spawnedBy&&!vd(e,t)?!1:!vd(e,t)||!e.spawnedBy||!n.has(e.spawnedBy))}function xd(e){return[...e].sort((e,t)=>N(e).localeCompare(N(t)))}var Sd={open:`bg-blue-400`,claimed:`bg-purple-300`,in_progress:`bg-purple-400`,blocked:`bg-yellow-400`,orphaned:`bg-zinc-400`,done:`bg-emerald-400`,failed:`bg-red-400`,canceled:`bg-zinc-400`};function Cd({id:e,title:t,status:n,onClick:r,className:i,compact:a}){let o=n?Sd[n]:void 0;return(0,V.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),r(e)},title:t?`Task T${e}: ${t}`:`Task T${e}`,"aria-label":`Open task T${e}`,className:k(`inline-flex max-w-full items-center rounded-full border font-medium leading-none transition-colors hover:brightness-125 focus:outline-none focus-visible:ring-1 focus-visible:ring-current`,a?`h-4 gap-1 pl-1 pr-1.5 text-[9px]`:`h-5 gap-1.5 pl-1.5 pr-2 text-[10px]`,`border-orange-500/25 bg-orange-500/10 text-orange-300`,i),children:[o&&(0,V.jsx)(`span`,{className:k(`h-1.5 w-1.5 shrink-0 rounded-full`,o)}),(0,V.jsxs)(`span`,{className:`truncate font-mono tracking-tight`,children:[`T`,e]}),!a&&t&&(0,V.jsx)(`span`,{className:`max-w-[8rem] truncate opacity-70`,children:t})]})}function wd(){let e=j(e=>e.agentDetailOpen),t=j(e=>e.agentDetailId),r=j(e=>e.agentsById),i=j(e=>e.messages),a=j(e=>e.orchestrators),o=j(e=>e.fetchOrchestrators),s=yt(),c=j(e=>e.set),u=j(e=>e.closeAgentDetail),d=j(e=>e.openAgentDetail),f=j(e=>e.openComposeToAgent),p=j(e=>e.openInboxThread),m=j(e=>e.openRename),h=j(e=>e.openPairInvite),g=j(e=>e.switchView),_=j(e=>e.openConfirm),v=j(e=>e.showError),y=j(e=>e.showNotification),b=j(e=>e.doAgentAction),C=j(e=>e.doDeleteAgent),ee=j(e=>e.openFilesForAgent),te=j(e=>e.openTaskDetail),ne=j(e=>e.openTaskDetailById),[T,re]=(0,B.useState)([]),[oe,E]=(0,B.useState)(null),[D,se]=(0,B.useState)(null),[ce,le]=(0,B.useState)([]),[de,fe]=(0,B.useState)(`overview`),[pe,me]=(0,B.useState)(!1),[he,ve]=(0,B.useState)(null),[ye,xe]=(0,B.useState)(!1),[Se,Ce]=(0,B.useState)(null),we=j(e=>e.livenessMismatches),Te=j(e=>e.commandStalls),O=r[t]||null,k=Xc(),Ee=O?k[O.id]??null:null,De=(0,B.useMemo)(()=>Object.values(r),[r]),ke=(0,B.useMemo)(()=>t?i.filter(e=>e.from===t||e.to===t).sort((e,t)=>t.id-e.id).slice(0,8):[],[i,t]);(0,B.useEffect)(()=>{if(!e||!O?.context){re([]);return}let t=!1;return Qe(`GET`,`/agents/`+encodeURIComponent(O.id)+`/context-snapshots?limit=24`).then(e=>{t||re(e)}).catch(()=>{t||re([])}),()=>{t=!0}},[e,O?.id,O?.context?.lastUpdatedAt]),(0,B.useEffect)(()=>{if(Ce(null),!e||!O||!gd(O))return;let t=!1;return Qe(`GET`,`/agents/`+encodeURIComponent(O.id)+`/timeline?limit=50`).then(e=>{t||Ce(_d(e))}).catch(()=>{t||Ce(null)}),()=>{t=!0}},[e,O?.id,O?.status,O?.meta?.provider]),(0,B.useEffect)(()=>{if(!e||!O){E(null);return}let t=!1;return Qe(`GET`,`/agents/`+encodeURIComponent(O.id)+`/active-memories`).then(e=>{t||E(e)}).catch(()=>{t||E(null)}),()=>{t=!0}},[e,O?.id]),(0,B.useEffect)(()=>{if(!e||!O){se(null);return}let t=!1;return Qe(`GET`,`/agents/`+encodeURIComponent(O.id)+`/crash-report`).then(e=>{t||se(e.report)}).catch(()=>{t||se(null)}),()=>{t=!0}},[e,O?.id]),(0,B.useEffect)(()=>{if(!e||!O){le([]);return}let t=!1;return Qe(`GET`,`/tasks?kind=deliverable&ownerAgentId=`+encodeURIComponent(O.id)+`&limit=50`).then(e=>{t||le(e)}).catch(()=>{t||le([])}),()=>{t=!0}},[e,O?.id]),(0,B.useEffect)(()=>{fe(`overview`),me(!1),ve(null)},[t]),(0,B.useEffect)(()=>{e&&O?.meta?.tmuxSession&&a.length===0&&o()},[e,O?.id,O?.meta?.tmuxSession,a.length]);async function Ne(){if(O)try{if(!(await Qe(`DELETE`,`/agents/`+encodeURIComponent(O.id)+`/active-memories`)).supported){v(`Memory Clear Unavailable`,`The active memory broker does not support clearing active memories.`);return}E({agentId:O.id,supported:!0,memories:[],total:0}),y(`Active memories cleared`)}catch(e){v(`Memory Clear Failed`,e.message)}}async function Pe(){if(!(!O||ye)){xe(!0);try{ve(await Qe(`POST`,`/agents/`+encodeURIComponent(O.id)+`/terminal-session`)),me(!0)}catch(e){v(`Terminal Failed`,e.message)}finally{xe(!1)}}}async function Fe(e){if(e){me(!0);return}me(!1);let t=he;if(ve(null),O&&t?.mode===`guest`)try{await Qe(`DELETE`,`/agents/`+encodeURIComponent(O.id)+`/terminal-session/`+encodeURIComponent(t.session))}catch{}}if(!O)return(0,V.jsx)(cu,{open:e,onOpenChange:e=>!e&&u(),children:(0,V.jsx)(fu,{className:`w-full max-w-[100dvw] sm:max-w-md lg:max-w-lg`,children:(0,V.jsx)(pu,{children:(0,V.jsx)(mu,{children:`Agent`})})})});let Ie=Yt(s,O,$t(),Ee),Le=Wt(O,`restart`),Re=Wt(O,`shutdown`),Be=Wt(O,`reconnect`),Ve=Wt(O,`compact`),Ue=Wt(O,`clearContext`),We=!!(Se&&gd(O)),Ge=en(O),Ke=Nd(O.meta?.package),qe=Pd(O.meta?.contracts),A=O.providerCapabilities,Je=jt(O),Ye=Vu(O),Xe=sn(O),Ze=pd(O),$e=Ze?md(O,Ze,a):null,et=!!(Ze&&$e?.status===`online`&&O.providerCapabilities?.terminal?.live?.read),tt=!!(et&&O.providerCapabilities?.terminal?.live?.write),nt=O.providerCapabilities?.terminal?.attach?.create===!0,rt=et||nt,at=Ld(O.meta?.lastExit),ot=typeof O.meta?.lastError==`string`?O.meta.lastError:at?.lastError,st=O.spawnedBy?r[O.spawnedBy]??null:null,ct=xd(yd(De,s).get(O.id)??[]),lt=we[O.id]??null,ut=(Ie.tone===`offline`||Ie.tone===`stale`)&&et,dt=!!lt||ut,ft=Te[O.id]??null,pt=qu(s,O),ht=new Set([`done`,`failed`,`canceled`]),gt=ce.find(e=>!ht.has(e.status))??null,_t=[...ce.filter(e=>!ht.has(e.status)),...ce.filter(e=>ht.has(e.status))];return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(cu,{open:e,onOpenChange:e=>!e&&u(),children:(0,V.jsxs)(fu,{className:`w-full max-w-[100dvw] sm:max-w-md lg:max-w-lg p-0`,children:[(0,V.jsxs)(pu,{className:`shrink-0 p-4 border-b border-border`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,V.jsx)(bu,{agent:O,now:s}),(0,V.jsx)(Ou,{agent:O}),(0,V.jsx)(mu,{className:`text-base truncate`,children:N(O)}),Ru(O)&&(0,V.jsx)(Bu,{context:O.context,expected:!0})]}),(0,V.jsx)(Au,{agent:O,className:`mt-2`})]}),(0,V.jsxs)(`div`,{className:`shrink-0 flex flex-wrap items-center gap-2 p-4 border-b border-border`,children:[(0,V.jsxs)(L,{size:`sm`,variant:`outline`,onClick:()=>{f(O),u()},children:[(0,V.jsx)(ze,{className:`w-3 h-3 mr-1`}),`Message`]}),(0,V.jsxs)(L,{size:`sm`,variant:`outline`,onClick:()=>{p(O.id),g(`chat`),u()},children:[(0,V.jsx)(He,{className:`w-3 h-3 mr-1`}),`Chat`]}),(0,V.jsxs)(L,{size:`sm`,variant:`outline`,onClick:()=>{h(O.id),u()},children:[(0,V.jsx)(Ae,{className:`w-3 h-3 mr-1`}),`Pair`]}),rt&&(0,V.jsx)(L,{size:`sm`,variant:`outline`,className:`hidden sm:inline-flex px-2`,disabled:ye,title:nt?`Open guest terminal`:`Open live terminal`,onClick:()=>void Pe(),children:(0,V.jsx)(_e,{className:`w-3.5 h-3.5`})}),We&&(0,V.jsx)(L,{size:`sm`,variant:`outline`,className:`hidden sm:inline-flex px-2`,title:`Resume session`,onClick:()=>_(`Resume Session`,`Resume ${N(O)} from session ${Se?.resumeId}? This can reload a large prior context and consume tokens.`,()=>b(O,`resume`,`agent-detail-drawer`)),children:(0,V.jsx)(Me,{className:`w-3.5 h-3.5`})}),Ve&&(0,V.jsx)(L,{size:`sm`,variant:`outline`,className:`hidden sm:inline-flex px-2`,title:`Compact context`,onClick:()=>_(`Compact Agent`,`Compact context for ${N(O)}?`,()=>b(O,`compact`,`agent-detail-drawer`)),children:(0,V.jsx)(n,{className:`w-3.5 h-3.5`})}),Le&&(0,V.jsx)(L,{size:`sm`,variant:`outline`,className:`hidden sm:inline-flex px-2`,title:`Restart`,onClick:()=>_(`Restart Agent`,`Restart ${N(O)}?`,()=>b(O,`restart`,`agent-detail-drawer`)),children:(0,V.jsx)(w,{className:`w-3.5 h-3.5`})}),Re&&(0,V.jsx)(L,{size:`sm`,variant:`outline`,className:`hidden sm:inline-flex px-2`,title:`Shutdown`,onClick:()=>_(`Shutdown Agent`,`Shutdown ${N(O)}?`,()=>b(O,`shutdown`,`agent-detail-drawer`)),children:(0,V.jsx)(mt,{className:`w-3.5 h-3.5`})}),(0,V.jsxs)(pl,{children:[(0,V.jsx)(ml,{asChild:!0,children:(0,V.jsx)(L,{size:`sm`,variant:`outline`,className:`px-2`,children:(0,V.jsx)(ae,{className:`w-3.5 h-3.5`})})}),(0,V.jsxs)(hl,{align:`end`,children:[rt&&(0,V.jsxs)(gl,{className:`sm:hidden`,disabled:ye,onClick:()=>void Pe(),children:[(0,V.jsx)(_e,{className:`w-3.5 h-3.5`}),`Terminal`]}),We&&(0,V.jsxs)(gl,{className:`sm:hidden`,onClick:()=>_(`Resume Session`,`Resume ${N(O)} from session ${Se?.resumeId}? This can reload a large prior context and consume tokens.`,()=>b(O,`resume`,`agent-detail-drawer`)),children:[(0,V.jsx)(Me,{className:`w-3.5 h-3.5`}),`Resume`]}),Ve&&(0,V.jsxs)(gl,{className:`sm:hidden`,onClick:()=>_(`Compact Agent`,`Compact context for ${N(O)}?`,()=>b(O,`compact`,`agent-detail-drawer`)),children:[(0,V.jsx)(n,{className:`w-3.5 h-3.5`}),`Compact`]}),Le&&(0,V.jsxs)(gl,{className:`sm:hidden`,onClick:()=>_(`Restart Agent`,`Restart ${N(O)}?`,()=>b(O,`restart`,`agent-detail-drawer`)),children:[(0,V.jsx)(w,{className:`w-3.5 h-3.5`}),`Restart`]}),Re&&(0,V.jsxs)(gl,{className:`sm:hidden`,onClick:()=>_(`Shutdown Agent`,`Shutdown ${N(O)}?`,()=>b(O,`shutdown`,`agent-detail-drawer`)),children:[(0,V.jsx)(mt,{className:`w-3.5 h-3.5`}),`Shutdown`]}),(rt||We||Ve||Le||Re)&&(0,V.jsx)(vl,{className:`sm:hidden`}),(0,V.jsxs)(gl,{onClick:()=>m(O),children:[(0,V.jsx)(x,{className:`w-3.5 h-3.5`}),`Rename`]}),Be&&(0,V.jsxs)(gl,{onClick:()=>_(`Reconnect Agent`,`Reconnect ${N(O)}?`,()=>b(O,`reconnect`,`agent-detail-drawer`)),children:[(0,V.jsx)(S,{className:`w-3.5 h-3.5`}),`Reconnect`]}),Ue&&(0,V.jsxs)(gl,{onClick:()=>_(`Clear Context`,`Clear context for ${N(O)}?`,()=>b(O,`clearContext`,`agent-detail-drawer`)),children:[(0,V.jsx)(ge,{className:`w-3.5 h-3.5`}),`Clear Context`]}),Ge&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(vl,{}),(0,V.jsxs)(gl,{variant:`destructive`,onClick:()=>_(`Forget Agent`,`Forget ${N(O)}?`,()=>C(O.id)),children:[(0,V.jsx)(Oe,{className:`w-3.5 h-3.5`}),`Forget`]})]})]})]})]}),dt&&(0,V.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,V.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,V.jsx)(je,{className:`w-3.5 h-3.5`}),`Liveness mismatch`]}),(0,V.jsx)(`div`,{className:`mt-1 text-amber-50/85`,children:lt?.detail??`Relay marks this agent offline, but a live terminal session is still reachable — the process may still be running.`}),rt&&(0,V.jsxs)(L,{size:`sm`,variant:`outline`,className:`mt-2 h-7 text-xs`,disabled:ye,onClick:()=>void Pe(),children:[(0,V.jsx)(_e,{className:`w-3 h-3 mr-1`}),`Open terminal`]})]}),ft&&(0,V.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,V.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,V.jsx)(je,{className:`w-3.5 h-3.5`}),ft.kind===`clear`?`Context clear stalled`:`Compaction stalled`]}),(0,V.jsx)(`div`,{className:`mt-1 text-amber-50/85`,children:ft.detail}),rt&&(0,V.jsxs)(L,{size:`sm`,variant:`outline`,className:`mt-2 h-7 text-xs`,disabled:ye,onClick:()=>void Pe(),children:[(0,V.jsx)(_e,{className:`w-3 h-3 mr-1`}),`Open terminal`]})]}),pt&&(0,V.jsx)(hd,{agent:O,health:pt,showLogs:!!Ze,setTab:fe,openConfirm:_,doAgentAction:b}),(0,V.jsxs)(hu,{value:de,onValueChange:e=>fe(e),className:`flex-1 min-h-0 gap-0`,children:[(0,V.jsxs)(_u,{variant:`line`,className:`w-full shrink-0 px-4 pt-2`,children:[(0,V.jsx)(vu,{value:`overview`,children:`Overview`}),(0,V.jsxs)(vu,{value:`timeline`,children:[(0,V.jsx)(l,{className:`w-3.5 h-3.5`}),`Timeline`]}),(0,V.jsxs)(vu,{value:`logs`,children:[(0,V.jsx)(ue,{className:`w-3.5 h-3.5`}),`Logs`]})]}),(0,V.jsx)(yu,{value:`overview`,className:`min-h-0 overflow-y-auto overflow-x-hidden`,children:(0,V.jsxs)(`div`,{className:`p-4 space-y-4 min-w-0`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Status`}),(0,V.jsxs)(`div`,{className:`space-y-1 text-sm min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex justify-between gap-2 min-w-0`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`State`}),(0,V.jsx)(I,{className:It(Ie.tone),children:Ie.label})]}),gt&&(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2 min-w-0`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Working on`}),(0,V.jsx)(Cd,{id:gt.id,title:gt.title,status:gt.status,onClick:()=>te(gt)})]}),Je?.recommendedAction&&(0,V.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,V.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,V.jsx)(be,{className:`w-3.5 h-3.5`}),`Recommended action`]}),(0,V.jsx)(`div`,{className:`mt-1 text-red-100/80`,children:Je.recommendedAction})]}),ot&&(0,V.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,V.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,V.jsx)(be,{className:`w-3.5 h-3.5`}),`Last launch error`]}),(0,V.jsx)(`div`,{className:`mt-1 break-words text-amber-50/85`,children:ot}),at&&(0,V.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-x-3 gap-y-1 text-amber-50/70`,children:[at.detectedAt&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-amber-100/55`,children:`Detected`}),(0,V.jsx)(`div`,{children:M(s,at.detectedAt)})]}),typeof at.runtimeMs==`number`&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-amber-100/55`,children:`Runtime`}),(0,V.jsxs)(`div`,{children:[Math.max(0,Math.round(at.runtimeMs/1e3)),`s`]})]}),at.systemd?.unit&&(0,V.jsxs)(`div`,{className:`col-span-2 min-w-0`,children:[(0,V.jsx)(`span`,{className:`text-amber-100/55`,children:`Unit`}),(0,V.jsx)(`div`,{className:`truncate font-mono`,children:at.systemd.unit})]}),at.systemd&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-amber-100/55`,children:`Systemd`}),(0,V.jsx)(`div`,{children:[at.systemd.activeState,at.systemd.subState].filter(Boolean).join(`/`)||`unknown`})]}),at.systemd?.result&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-amber-100/55`,children:`Result`}),(0,V.jsx)(`div`,{children:at.systemd.result})]}),at.logFile&&(0,V.jsxs)(`div`,{className:`col-span-2 min-w-0`,children:[(0,V.jsx)(`span`,{className:`text-amber-100/55`,children:`Log`}),(0,V.jsxs)(`div`,{className:`truncate font-mono`,children:[at.logFile,` (`,at.logBytes??`unknown`,` bytes`,at.logEmpty?`, empty`:``,`)`]})]})]}),at?.logTail?.length?(0,V.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:at.logTail.slice(-5).join(`
|
|
20
20
|
`)}):null,at?.unavailable?.length?(0,V.jsx)(`div`,{className:`mt-1 text-amber-50/55`,children:at.unavailable.join(`; `)}):null]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 pt-0.5 text-xs`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Last seen`}),(0,V.jsx)(`div`,{children:M(s,O.lastSeen)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Created`}),(0,V.jsx)(`div`,{title:Jt(O.createdAt),children:M(s,O.createdAt)})]})]})]})]}),_t.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Tasks`}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:_t.map(e=>(0,V.jsx)(Cd,{id:e.id,title:e.title,status:e.status,compact:!0,onClick:()=>ne(e.id)},e.id))})]})]}),D&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsx)(Id,{report:D,now:s})]}),O.context&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsx)(Od,{context:O.context,tokens:Ye,history:T,now:s})]}),(0,V.jsx)(fd,{agentId:O.id,now:s}),(O.spawnedBy||ct.length>0||Ee)&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Relationships`}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[O.spawnedBy&&(0,V.jsxs)(`div`,{className:`rounded-md border border-border p-2 text-xs`,children:[(0,V.jsx)(`div`,{className:`mb-1 text-muted-foreground`,children:`Spawned by`}),(0,V.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:!st,onClick:()=>st&&d(st),children:st?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(bu,{agent:st,now:s}),(0,V.jsx)(Ou,{agent:st}),(0,V.jsx)(`span`,{className:`truncate font-medium`,children:N(st)})]}):(0,V.jsx)(`span`,{className:`truncate font-mono`,children:O.spawnedBy})})]}),ct.length>0&&(0,V.jsxs)(`div`,{className:`rounded-md border border-border p-2 text-xs`,children:[(0,V.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Children`}),(0,V.jsx)(I,{variant:`secondary`,className:`h-4 px-1.5 text-[9px]`,children:ct.length})]}),(0,V.jsx)(`div`,{className:`space-y-1`,children:ct.map(e=>(0,V.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded px-1 py-1 text-left hover:bg-muted/50`,onClick:()=>d(e),children:[(0,V.jsx)(bu,{agent:e,now:s}),(0,V.jsx)(Ou,{agent:e}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:N(e)}),(0,V.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.status})]},e.id))})]}),O.spawnedBy&&ct.length===0&&(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,V.jsx)(it,{className:`h-3.5 w-3.5`}),`No live child agents`]}),Ee&&(0,V.jsxs)(`div`,{className:`rounded-md border border-border p-2 text-xs`,children:[(0,V.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Pair`}),(0,V.jsx)(I,{className:Ee.status===`active`?`bg-emerald-500/20 text-emerald-400`:`bg-yellow-500/20 text-yellow-400`,children:Ee.status})]}),Ee.objective&&(0,V.jsx)(`p`,{className:`text-muted-foreground`,children:Ee.objective})]})]})]})]}),(A||Xe.length>0)&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Runtime`}),(0,V.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[Je&&(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Provider state`}),(0,V.jsx)(`div`,{children:Je.state})]}),Je.reason&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Reason`}),(0,V.jsx)(`div`,{children:Je.reason})]}),Je.source&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Source`}),(0,V.jsx)(`div`,{children:Je.source})]}),Je.updatedAt&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Updated`}),(0,V.jsx)(`div`,{children:M(s,Je.updatedAt)})]})]}),A?.model&&(0,V.jsxs)(`div`,{className:`space-y-1`,children:[A.model.provider&&(0,V.jsxs)(`div`,{className:`flex justify-between gap-2 min-w-0`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Provider`}),(0,V.jsx)(`span`,{className:`truncate`,children:A.model.provider})]}),(A.model.alias||A.model.id)&&(0,V.jsxs)(`div`,{className:`flex justify-between gap-2 min-w-0`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Model`}),(0,V.jsx)(`span`,{className:`truncate`,children:A.model.alias||A.model.id})]}),A.model.effort&&(0,V.jsxs)(`div`,{className:`flex justify-between gap-2 min-w-0`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Effort`}),(0,V.jsx)(`span`,{className:`truncate`,children:A.model.effort})]})]}),A?.session&&(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1`,children:[A.session.approvalMode&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Mode`}),(0,V.jsx)(`div`,{children:A.session.approvalMode})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Files`}),(0,V.jsx)(`div`,{children:A.session.fileWrite?`read/write`:A.session.fileRead?`read-only`:`none`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Shell`}),(0,V.jsx)(`div`,{children:A.session.shell?`yes`:`no`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Confidence`}),(0,V.jsx)(`div`,{children:A.confidence})]})]}),A?.lifecycle&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Lifecycle`}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:[(0,V.jsx)(I,{variant:A.lifecycle.managed?`secondary`:`outline`,className:`text-[10px]`,children:A.lifecycle.managed?`managed`:`bridge`}),A.lifecycle.shutdownHard&&(0,V.jsx)(I,{variant:`outline`,className:`text-[10px]`,children:`shutdown`}),A.lifecycle.restartHard&&(0,V.jsx)(I,{variant:`outline`,className:`text-[10px]`,children:`restart`}),A.lifecycle.reconnect&&(0,V.jsx)(I,{variant:`outline`,className:`text-[10px]`,children:`reconnect`})]})]}),Xe.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Subagents`}),(0,V.jsx)(`div`,{className:`space-y-1 mt-1`,children:Xe.map(e=>(0,V.jsxs)(`div`,{className:`flex justify-between gap-2 text-xs rounded border border-border px-2 py-1`,children:[(0,V.jsx)(`span`,{className:`truncate`,children:e.label}),e.role&&(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e.role})]},e.id))})]})]})]})]}),oe&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-2`,children:[(0,V.jsxs)(`h3`,{className:`text-sm font-medium flex items-center gap-1.5`,children:[(0,V.jsx)(ie,{className:`w-3.5 h-3.5 text-muted-foreground`}),`Memory`]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[oe.supported&&(0,V.jsx)(I,{variant:`secondary`,className:`text-[10px]`,children:oe.memories.length}),oe.supported&&oe.memories.length>0&&(0,V.jsxs)(L,{size:`sm`,variant:`outline`,className:`h-7 text-xs gap-1`,onClick:()=>_(`Clear Active Memories`,`Clear active memories for ${N(O)}?`,Ne),children:[(0,V.jsx)(ge,{className:`w-3 h-3`}),`Clear`]})]})]}),oe.supported?oe.memories.length===0?(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No active memories`}):(0,V.jsx)(`div`,{className:`space-y-2`,children:oe.memories.map(e=>(0,V.jsx)(Td,{memory:e,now:s,onOpen:()=>{c({selectedMemoryId:e.id}),g(`memory`),u()}},e.id))}):(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Active memory list unavailable`})]})]}),O.meta?.runnerManaged===!0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsx)(Yu,{agent:O,orchestrators:a})]}),(0,V.jsx)(fl,{}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Identity`}),(0,V.jsxs)(`div`,{className:`space-y-2.5 text-sm min-w-0`,children:[(0,V.jsx)(Dd,{label:`Agent ID`,value:O.id,copyLabel:`Copy agent ID`}),typeof O.meta?.cwd==`string`&&O.meta.cwd&&(0,V.jsx)(Dd,{label:`Working dir`,value:O.meta.cwd,copyLabel:`Copy working dir`,title:`Open ${O.meta.cwd} in Files`,onClick:()=>{u(),ee(O)}}),(0,V.jsx)(Qu,{agent:O,onNavigate:u}),(O.machine||O.rig||Ke)&&(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1.5 text-xs`,children:[O.machine&&(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Machine`}),(0,V.jsx)(`div`,{className:`truncate`,title:O.machine,children:O.machine})]}),O.rig&&(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Rig`}),(0,V.jsx)(`div`,{className:`truncate`,title:O.rig,children:O.rig})]}),Ke&&(0,V.jsxs)(`div`,{className:`col-span-2 min-w-0`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Package`}),(0,V.jsxs)(`div`,{className:`break-all font-mono`,children:[Ke.name,` v`,Ke.version]})]})]}),qe.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Contracts`}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:qe.map(([e,t])=>(0,V.jsxs)(I,{variant:`secondary`,className:`text-[10px]`,children:[e,`=`,t]},e))})]}),O.tags.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Tags`}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:O.tags.map(e=>(0,V.jsx)(I,{variant:`outline`,className:`text-[10px]`,children:e},e))})]}),Ut(O.capabilities).length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Capabilities`}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:Ut(O.capabilities).map(e=>(0,V.jsx)(I,{variant:`secondary`,className:`text-[10px]`,children:e},e))})]})]})]}),ke.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsxs)(`details`,{className:`group`,children:[(0,V.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 text-sm font-medium`,children:[(0,V.jsx)(`span`,{children:`Recent messages`}),(0,V.jsxs)(`span`,{className:`text-[11px] font-normal text-muted-foreground`,children:[ke.length,` `,(0,V.jsx)(`span`,{className:`group-open:hidden`,children:`· show`}),(0,V.jsx)(`span`,{className:`hidden group-open:inline`,children:`· hide`})]})]}),(0,V.jsx)(`div`,{className:`mt-2 space-y-2`,children:ke.map(e=>(0,V.jsxs)(`div`,{className:`rounded border border-border p-2 text-xs space-y-0.5 min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground min-w-0`,children:[(0,V.jsx)(`span`,{className:`font-medium text-foreground truncate shrink-0 max-w-[40%]`,children:qt(e.from,r)}),(0,V.jsx)(`span`,{className:`shrink-0`,children:`→`}),(0,V.jsx)(`span`,{className:`truncate max-w-[40%]`,children:qt(e.to,r)}),(0,V.jsxs)(`span`,{className:`ml-auto shrink-0 text-[10px]`,children:[(0,V.jsxs)(`span`,{className:`opacity-40 mr-1`,children:[`#`,e.id]}),M(s,e.createdAt)]})]}),(0,V.jsx)(`div`,{className:`text-foreground whitespace-pre-wrap break-words line-clamp-3`,children:Zt(e)})]},e.id))})]})]})]})}),(0,V.jsx)(yu,{value:`timeline`,className:`min-h-0 overflow-y-auto overflow-x-hidden`,children:(0,V.jsx)(Ad,{agentId:O.id,open:e&&de===`timeline`,now:s})}),(0,V.jsx)(yu,{value:`logs`,className:`min-h-0 overflow-y-auto overflow-x-hidden`,children:Ze&&$e?(0,V.jsx)(`div`,{className:`p-4`,children:(0,V.jsx)(Ku,{orchestratorId:$e.id,session:Ze})}):(0,V.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`No session logs available for this agent.`})})]})]})}),he&&(0,V.jsx)(X,{open:pe,onOpenChange:e=>void Fe(e),orchestratorId:he.orchestratorId,session:he.session,interactive:he.interactive||tt})]})}function Td({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,V.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,V.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[(0,V.jsx)(I,{variant:`secondary`,className:`text-[10px]`,children:e.type}),(0,V.jsx)(I,{variant:`outline`,className:`text-[10px] font-mono`,children:e.scope}),(0,V.jsx)(I,{className:`text-[10px] ${r}`,children:e.sensitivity})]}),(0,V.jsx)(`div`,{className:`font-medium truncate`,children:e.title}),(0,V.jsx)(`div`,{className:`text-muted-foreground line-clamp-2 mt-0.5`,children:e.content})]}),(0,V.jsx)(`div`,{className:`shrink-0 text-right text-[10px] text-muted-foreground`,title:Jt(e.lastAccessedAt??e.updatedAt),children:M(t,e.lastAccessedAt??e.updatedAt)})]})})}function Ed(e){return e>=.8?`text-red-400`:e>=.6?`text-yellow-400`:`text-emerald-400`}function Dd({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,V.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground`,children:e}),(0,V.jsx)(Un,{value:t,label:i??`Copy ${e.toLowerCase()}`,size:`icon-xs`,className:`-my-1 shrink-0 text-muted-foreground`})]}),n?(0,V.jsx)(`button`,{type:`button`,className:a,title:r,onClick:n,children:t}):(0,V.jsx)(`div`,{className:a,title:r,children:t})]})}function Od({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`:Ed(i);return(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 min-w-0`,children:[(0,V.jsx)(`h3`,{className:`shrink-0 text-sm font-medium`,children:`Context`}),(0,V.jsxs)(`span`,{className:`truncate text-[11px] text-muted-foreground`,title:`source ${e.source}, confidence ${e.confidence}`,children:[e.lifecycleState,` · `,e.source,`/`,e.confidence]})]}),(0,V.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,V.jsx)(`span`,{className:`text-2xl font-semibold leading-none ${o}`,children:a===null?`—`:`${a}%`}),t&&(0,V.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[t,` tokens`]})]}),n.length>1&&(0,V.jsx)(kd,{snapshots:n,now:r}),e.warmTopics.length>0&&(0,V.jsxs)(`div`,{className:`mt-2`,children:[(0,V.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Warm topics`}),(0,V.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:e.warmTopics.map(e=>(0,V.jsx)(I,{variant:`outline`,className:`text-[10px]`,children:e},e))})]})]})}function kd({snapshots:e,now:t}){let n=e.slice(-24),[r,i]=(0,B.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=Ed(o(n[a-1].utilization)),u=r==null?n[a-1]:n[r],d=s(r??a-1);return(0,V.jsxs)(`div`,{className:`mt-2`,children:[(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsxs)(`svg`,{viewBox:`0 0 100 40`,preserveAspectRatio:`none`,className:`h-12 w-full`,"aria-label":`Context utilization history`,children:[(0,V.jsx)(`line`,{x1:`0`,y1:`20`,x2:`100`,y2:`20`,className:`stroke-muted-foreground/15`,strokeWidth:`0.5`,strokeDasharray:`2 2`}),(0,V.jsx)(`polygon`,{points:`0,40 ${c} 100,40`,className:`fill-current text-primary/10`}),(0,V.jsx)(`polyline`,{points:c,fill:`none`,className:`stroke-current ${l}`,strokeWidth:`1.25`,strokeLinejoin:`round`,strokeLinecap:`round`,vectorEffect:`non-scaling-stroke`}),(0,V.jsx)(`circle`,{cx:d.x,cy:d.y,r:`1.6`,className:`fill-current ${l}`,vectorEffect:`non-scaling-stroke`})]}),(0,V.jsx)(`div`,{className:`absolute inset-0 flex`,children:n.map((e,t)=>(0,V.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,V.jsxs)(`div`,{className:`mt-1 flex items-center justify-between text-[10px] text-muted-foreground`,children:[(0,V.jsx)(`span`,{children:r==null?(0,V.jsxs)(V.Fragment,{children:[a,` samples · since `,M(t,n[0].capturedAt)]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`span`,{className:l,children:[Math.round(o(u.utilization)*100),`%`]}),` · `,new Date(u.capturedAt).toLocaleTimeString()]})}),(0,V.jsx)(`span`,{children:`0–100%`})]})]})}function Ad({agentId:e,open:t,now:n}){let[r,i]=(0,B.useState)([]),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(50),d=(0,B.useCallback)(t=>{o(!0),c(null);let n=!1;return Qe(`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,B.useEffect)(()=>{if(t)return d(50)},[t,e,d]),(0,V.jsxs)(`div`,{className:`p-4 space-y-3 min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium`,children:`Timeline`}),(0,V.jsxs)(L,{size:`sm`,variant:`outline`,className:`h-7 text-xs`,disabled:a,onClick:()=>d(l),children:[(0,V.jsx)(S,{className:`w-3 h-3 mr-1`}),`Refresh`]})]}),s&&(0,V.jsx)(`div`,{className:`text-xs text-red-300`,children:s}),!s&&r.length===0&&!a&&(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No timeline activity recorded for this agent.`}),(0,V.jsx)(`div`,{className:`space-y-1.5`,children:r.map((e,t)=>(0,V.jsx)(Md,{entry:e,now:n},`${e.ts}:${e.source}:${t}`))}),r.length>=l&&l<200&&(0,V.jsx)(L,{size:`sm`,variant:`outline`,className:`w-full h-7 text-xs`,disabled:a,onClick:()=>d(200),children:`Load full timeline`})]})}function jd(e){return e.metadata?.mismatch===!0||e.metadata?.stalled===!0?(0,V.jsx)(je,{className:`w-3.5 h-3.5 text-amber-400`}):e.source===`command`?(0,V.jsx)(_e,{className:`w-3.5 h-3.5 text-sky-400`}):e.source===`delivery`?(0,V.jsx)(ze,{className:`w-3.5 h-3.5 text-violet-400`}):e.kind===`state`?(0,V.jsx)(Ye,{className:`w-3.5 h-3.5 text-emerald-400`}):(0,V.jsx)(r,{className:`w-3.5 h-3.5 text-muted-foreground`})}function Md({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,V.jsxs)(`div`,{className:`flex gap-2 rounded border border-border px-2 py-1.5 text-xs min-w-0`,children:[(0,V.jsx)(`div`,{className:`shrink-0 mt-0.5`,children:jd(e)}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,V.jsx)(`span`,{className:`font-medium truncate ${r?`text-red-300`:`text-foreground`}`,children:e.title}),(0,V.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] text-muted-foreground`,title:Jt(e.ts),children:M(t,e.ts)})]}),o&&(0,V.jsx)(`div`,{className:`text-muted-foreground font-mono text-[11px]`,children:o}),e.detail&&(0,V.jsx)(`div`,{className:`text-muted-foreground whitespace-pre-wrap break-words line-clamp-3`,children:e.detail})]})]})}function Nd(e){return Ct(e)&&typeof e.name==`string`&&typeof e.version==`string`?{name:e.name,version:e.version}:null}function Pd(e){return Ct(e)?Object.entries(e).filter(e=>typeof e[1]==`number`):[]}var Fd={oom:`bg-red-500/20 text-red-400`,killed:`bg-red-500/20 text-red-400`,"provider-crash":`bg-orange-500/20 text-orange-400`,"token-401":`bg-amber-500/20 text-amber-400`,"onboarding-gate":`bg-amber-500/20 text-amber-400`,"transport-loss":`bg-sky-500/20 text-sky-400`,"clean-exit":`bg-emerald-500/20 text-emerald-400`,unknown:`bg-zinc-500/20 text-zinc-400`};function Id({report:e,now:t}){let n=e.diagnosis,r=Fd[n.cause]??`bg-zinc-500/20 text-zinc-400`;return(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`h3`,{className:`text-sm font-medium mb-2 flex items-center gap-1.5`,children:[(0,V.jsx)(be,{className:`w-3.5 h-3.5 text-muted-foreground`}),`Why it died`]}),(0,V.jsxs)(`div`,{className:`rounded-md border border-border bg-muted/30 px-3 py-2.5 text-xs space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,V.jsx)(I,{className:r,children:n.cause}),(0,V.jsxs)(`span`,{className:`text-muted-foreground`,children:[n.confidence,` confidence`]}),(0,V.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,title:Jt(n.detectedAt),children:M(t,n.detectedAt)})]}),(0,V.jsx)(`div`,{className:`font-medium text-foreground`,children:n.summary}),n.evidence.length>0&&(0,V.jsx)(`ul`,{className:`space-y-0.5 text-muted-foreground`,children:n.evidence.map((e,t)=>(0,V.jsxs)(`li`,{className:`flex gap-1.5`,children:[(0,V.jsx)(`span`,{className:`shrink-0 text-muted-foreground/50`,children:`·`}),(0,V.jsx)(`span`,{children:e})]},t))}),(n.signal!=null||n.exitCode!=null||n.oom===!0||n.heartbeatGapMs!=null||(n.activeWork?.length??0)>0)&&(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 text-[11px] pt-0.5`,children:[n.signal!=null&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Signal`}),(0,V.jsx)(`div`,{className:`font-mono`,children:n.signal})]}),n.exitCode!=null&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Exit code`}),(0,V.jsx)(`div`,{className:`font-mono`,children:n.exitCode})]}),n.oom===!0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`OOM`}),(0,V.jsx)(`div`,{children:`yes`})]}),n.heartbeatGapMs!=null&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Heartbeat gap`}),(0,V.jsxs)(`div`,{children:[Math.round(n.heartbeatGapMs/1e3),`s`]})]}),(n.activeWork?.length??0)>0&&(0,V.jsxs)(`div`,{className:`col-span-2 min-w-0`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`Active work`}),(0,V.jsx)(`div`,{className:`truncate`,children:n.activeWork.join(`, `)})]})]}),n.logTail&&n.logTail.length>0&&(0,V.jsx)(`pre`,{className:`mt-1 max-h-28 overflow-auto whitespace-pre-wrap break-words rounded border border-border bg-black/20 p-2 text-[11px] text-muted-foreground`,children:n.logTail.slice(-5).join(`
|
|
21
|
-
`)})]})]})}function Ld(e){if(!Ct(e)||typeof e.lastError!=`string`)return null;let t=Ct(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 Rd({className:e,children:t,...n}){return(0,V.jsxs)(ys,{"data-slot":`scroll-area`,className:k(`relative`,e),...n,children:[(0,V.jsx)(bs,{"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,V.jsx)(zd,{}),(0,V.jsx)(xs,{})]})}function zd({className:e,orientation:t=`vertical`,...n}){return(0,V.jsx)(qo,{"data-slot":`scroll-area-scrollbar`,"data-orientation":t,orientation:t,className:k(`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,V.jsx)(is,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}function Bd(){let e=j(e=>e.channelDetailOpen),t=j(e=>e.channelDetailId),n=j(e=>e.channels),r=j(e=>e.messages),i=j(e=>e.agentsById),a=yt(),o=j(e=>e.closeChannelDetail),s=n.find(e=>e.id===t)||null,c=Gt(s),l=(0,B.useMemo)(()=>s?r.filter(e=>Xt(e,s)).sort((e,t)=>t.id-e.id).slice(0,8):[],[r,s]);return(0,V.jsx)(cu,{open:e,onOpenChange:e=>!e&&o(),children:(0,V.jsxs)(fu,{className:`w-full max-w-[100dvw] sm:max-w-md lg:max-w-lg p-0`,children:[(0,V.jsx)(pu,{className:`shrink-0 p-4 border-b border-border`,children:(0,V.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,V.jsx)(I,{className:It(c.tone),children:c.label}),(0,V.jsx)(mu,{className:`text-base truncate`,children:s?.name||`Channel`})]})}),(0,V.jsx)(Rd,{className:`flex-1 min-h-0`,children:(0,V.jsxs)(`div`,{className:`p-4 space-y-4`,children:[s&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Route`}),(0,V.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,V.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Type`}),(0,V.jsx)(`span`,{className:`truncate`,children:s.type})]}),(0,V.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Direction`}),(0,V.jsx)(`span`,{className:`truncate`,children:s.direction})]}),s.target&&(0,V.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Target`}),(0,V.jsx)(`span`,{className:`truncate`,children:s.target})]}),(0,V.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Agent`}),(0,V.jsx)(`span`,{className:`truncate`,children:s.agentId})]}),(0,V.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Transport`}),(0,V.jsx)(`span`,{className:`truncate`,children:s.transport})]}),(0,V.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Last seen`}),(0,V.jsx)(`span`,{className:`shrink-0`,children:M(a,s.lastSeen)})]})]})]}),Ut(s.capabilities).length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Capabilities`}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Ut(s.capabilities).map(e=>(0,V.jsx)(I,{variant:`secondary`,className:`text-[10px]`,children:e},e))})]})]}),s.meta&&Object.keys(s.meta).length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Metadata`}),(0,V.jsx)(`div`,{className:`space-y-1 text-sm`,children:Object.entries(s.meta).map(([e,t])=>(0,V.jsxs)(`div`,{className:`flex justify-between gap-2 min-w-0`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e}),(0,V.jsx)(`span`,{className:`truncate`,children:String(t)})]},e))})]})]})]}),l.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Recent Messages`}),(0,V.jsx)(`div`,{className:`space-y-2`,children:l.map(e=>(0,V.jsxs)(`div`,{className:`rounded border border-border p-2 text-xs space-y-0.5 min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground min-w-0`,children:[(0,V.jsx)(`span`,{className:`font-medium text-foreground truncate shrink-0 max-w-[40%]`,children:qt(e.from,i)}),(0,V.jsx)(`span`,{className:`shrink-0`,children:`→`}),(0,V.jsx)(`span`,{className:`truncate max-w-[40%]`,children:qt(e.to,i)}),(0,V.jsxs)(`span`,{className:`ml-auto shrink-0 text-[10px]`,children:[(0,V.jsxs)(`span`,{className:`opacity-40 mr-1`,children:[`#`,e.id]}),M(a,e.createdAt)]})]}),(0,V.jsx)(`div`,{className:`text-foreground whitespace-pre-wrap break-words line-clamp-3`,children:Zt(e)})]},e.id))})]})]})]})})]})})}function Vd({className:e,...t}){return(0,V.jsx)(`textarea`,{"data-slot":`textarea`,className:k(`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 $({className:e,...t}){return(0,V.jsx)(Io,{"data-slot":`label`,className:k(`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})}var Hd=(0,B.lazy)(()=>z(()=>import(`./formatted-body-impl-CfnhWZAX.js`).then(e=>({default:e.FormattedBody})),__vite__mapDeps([15,1,5,3,6,8,9,10]),import.meta.url));function Ud(e){return(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(`span`,{className:e.className,children:e.text}),children:(0,V.jsx)(Hd,{...e})})}var Wd={none:`None`,uncommitted:`Uncommitted`,"committed-on-branch":`On Branch`,"landed-on-main":`Landed`,deploying:`Deploying`,deployed:`Deployed`},Gd={open:`bg-blue-500/10 text-blue-400 border-blue-500/20`,claimed:`bg-purple-500/10 text-purple-300 border-purple-500/20`,in_progress:`bg-purple-500/10 text-purple-400 border-purple-500/20`,blocked:`bg-yellow-500/10 text-yellow-400 border-yellow-500/20`,orphaned:`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`,done:`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`,failed:`bg-red-500/10 text-red-400 border-red-500/20`,canceled:`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`},Kd={none:`bg-zinc-500/10 text-zinc-400`,uncommitted:`bg-yellow-500/10 text-yellow-400`,"committed-on-branch":`bg-blue-500/10 text-blue-400`,"landed-on-main":`bg-emerald-500/10 text-emerald-400`,deploying:`bg-purple-500/10 text-purple-400`,deployed:`bg-teal-500/10 text-teal-400`};function qd(e){let t=e.dispatch;return{title:e.title??``,intent:e.intent??``,latestSteer:e.latestSteer??``,doneWhen:e.doneWhen??``,teamId:e.teamId??``,dispatchComplexity:t?.complexity??``,dispatchType:t?.type??``,dispatchFootprint:t?.contextFootprint??``,dispatchCriticality:t?.criticality??``}}function Jd(){let e=yt(),t=j(e=>e.taskDetailOpen),n=j(e=>e.taskDetailId),r=j(e=>e.taskDetailById),i=j(e=>e.taskMemoryById),a=j(e=>e.taskHistoryById),o=j(e=>e.taskDispatchResultById),s=j(e=>e.taskDispatchLoadingId),c=j(e=>e.agentsById),l=j(e=>e.providerCatalog),u=j(e=>e.closeTaskDetail),d=j(e=>e.doEditTask),f=j(e=>e.doDispatchTask),p=j(e=>e.doSpawnWithTask),m=l.map(e=>e.provider),[g,_]=(0,B.useState)(!1),[v,y]=(0,B.useState)(null),[b,x]=(0,B.useState)(``),[S,C]=(0,B.useState)(``),[ee,te]=(0,B.useState)(``),w=n==null?null:r[n]??null,T=n==null?null:i[n]??null,re=n==null?[]:a[n]??[],ie=n==null?null:o[n]??null,ae=n!=null&&s===n,oe=w?Gd[w.status]??`bg-zinc-500/10 text-zinc-400`:``,E=w?.deliverableStage?Kd[w.deliverableStage]??`bg-zinc-500/10 text-zinc-400`:``;function D(e){e||(u(),_(!1),y(null))}function se(){w&&(y(qd(w)),_(!0))}function ce(){_(!1),y(null)}async function le(){if(!w||!v)return;let e={};v.dispatchComplexity&&(e.complexity=v.dispatchComplexity),v.dispatchType&&(e.type=v.dispatchType),v.dispatchFootprint&&(e.contextFootprint=v.dispatchFootprint),v.dispatchCriticality&&(e.criticality=v.dispatchCriticality);let t={...v.title===w.title?{}:{title:v.title},...v.intent===(w.intent??``)?{}:{intent:v.intent},...v.latestSteer===(w.latestSteer??``)?{}:{latestSteer:v.latestSteer},...v.doneWhen===(w.doneWhen??``)?{}:{doneWhen:v.doneWhen},...v.teamId===(w.teamId??``)?{}:{teamId:v.teamId},...Object.keys(e).length||w.dispatch?{dispatch:Object.keys(e).length?e:null}:{}};if(!Object.keys(t).length){ce();return}await d(w.id,t),_(!1),y(null)}function ue(){if(!w)return;let e={};b&&(e.provider=b),S&&(e.model=S),ee&&(e.effort=ee),f(w.id,Object.keys(e).length?e:void 0)}return(0,V.jsx)(cu,{open:t,onOpenChange:D,children:(0,V.jsxs)(fu,{className:`w-full max-w-[100dvw] sm:max-w-lg lg:max-w-xl p-0 flex flex-col`,showCloseButton:!1,children:[(0,V.jsx)(pu,{className:`shrink-0 p-4 border-b border-border`,children:(0,V.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`div`,{className:`flex items-center gap-2 flex-wrap mb-1`,children:w&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(I,{variant:`outline`,className:`text-xs border ${oe}`,children:w.status}),w.deliverableStage&&(0,V.jsx)(I,{variant:`secondary`,className:`text-xs ${E}`,children:Wd[w.deliverableStage]??w.deliverableStage}),(0,V.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`T`,w.id]})]})}),(0,V.jsx)(mu,{className:`text-base leading-snug`,children:w?.title??`Task`})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[w&&!g&&(0,V.jsx)(L,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,onClick:se,title:`Edit task`,children:(0,V.jsx)(h,{className:`w-3.5 h-3.5`})}),(0,V.jsx)(lu,{asChild:!0,children:(0,V.jsxs)(L,{size:`icon-sm`,variant:`ghost`,title:`Close`,children:[(0,V.jsx)(ye,{className:`w-4 h-4`}),(0,V.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}),(0,V.jsx)(Rd,{className:`flex-1 min-h-0 overflow-x-hidden`,children:(0,V.jsxs)(`div`,{className:`p-4 space-y-5 min-w-0`,children:[!w&&(0,V.jsx)(`div`,{className:`text-sm text-muted-foreground text-center py-8`,children:`Loading…`}),w&&g&&v&&(0,V.jsx)(Yd,{form:v,onChange:e=>y(t=>t&&{...t,...e}),onSave:()=>void le(),onCancel:ce}),w&&!g&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Status`}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-sm`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground mb-0.5`,children:`Execution`}),(0,V.jsx)(I,{variant:`outline`,className:`text-xs border ${oe}`,children:w.status})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground mb-0.5`,children:`Deliverable stage`}),(0,V.jsx)(I,{variant:`secondary`,className:`text-xs ${E}`,children:Wd[w.deliverableStage??`none`]??w.deliverableStage??`none`})]})]}),w.blockedBy&&w.blockedBy.length>0&&(0,V.jsx)(`div`,{className:`mt-2 space-y-1`,children:w.blockedBy.map((e,t)=>(0,V.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-yellow-400 min-w-0`,children:[(0,V.jsx)(`span`,{className:`font-medium capitalize shrink-0`,children:e.type}),e.ref&&(0,V.jsxs)(`span`,{className:`text-muted-foreground truncate min-w-0`,children:[`→ `,e.ref]}),e.note&&(0,V.jsx)(`span`,{className:`text-muted-foreground truncate min-w-0`,children:e.note})]},t))})]}),(0,V.jsx)(fl,{}),(w.intent||w.doneWhen)&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`section`,{className:`space-y-2`,children:[w.intent&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1`,children:`Intent`}),(0,V.jsx)(Ud,{text:w.intent,className:`text-sm min-w-0 break-words [overflow-wrap:anywhere]`})]}),w.doneWhen&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1`,children:`Done when`}),(0,V.jsx)(Ud,{text:w.doneWhen,className:`text-sm min-w-0 break-words [overflow-wrap:anywhere]`})]})]}),(0,V.jsx)(fl,{})]}),(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Ownership`}),(0,V.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[w.ownerAgentId&&(0,V.jsxs)(`div`,{className:`flex gap-2 min-w-0`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Owner`}),(0,V.jsx)(`span`,{className:`min-w-0 break-words [overflow-wrap:anywhere]`,title:w.ownerAgentId,children:c[w.ownerAgentId]?N(c[w.ownerAgentId]):w.ownerAgentId})]}),w.createdBy&&(0,V.jsxs)(`div`,{className:`flex gap-2 min-w-0`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Created by`}),(0,V.jsx)(`span`,{className:`min-w-0 break-words [overflow-wrap:anywhere]`,title:w.createdBy,children:w.createdBy})]}),w.teamId&&(0,V.jsxs)(`div`,{className:`flex gap-2 min-w-0`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Team`}),(0,V.jsx)(`span`,{className:`min-w-0 break-words [overflow-wrap:anywhere] font-mono text-xs`,title:w.teamId,children:w.teamId})]}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Created`}),(0,V.jsx)(`span`,{title:Jt(w.createdAt),children:M(e,w.createdAt)})]}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Updated`}),(0,V.jsx)(`span`,{title:Jt(w.updatedAt),children:M(e,w.updatedAt)})]})]})]}),(w.dispatchWorkShape?.specified||w.dispatchDecision||w.boundWorkerModel)&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsx)(Xd,{detail:w})]}),(w.branch||w.commits&&w.commits.length>0)&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Code`}),w.branch&&(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm mb-1 min-w-0`,children:[(0,V.jsx)(ne,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,V.jsx)(`span`,{className:`font-mono text-xs truncate min-w-0`,title:w.branch,children:w.branch})]}),w.commits?.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm ml-1 min-w-0`,children:[(0,V.jsx)(Re,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,V.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground shrink-0`,children:e.sha.slice(0,8)}),e.subject&&(0,V.jsx)(`span`,{className:`text-xs truncate min-w-0`,children:e.subject})]},e.sha))]})]}),w.issues&&w.issues.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsx)(Qd,{issues:w.issues})]}),(w.dependsOn&&w.dependsOn.length>0||w.dependents&&w.dependents.length>0)&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsx)($d,{dependsOn:w.dependsOn??[],dependents:w.dependents??[]})]}),w.gates&&w.gates.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsx)(ef,{gates:w.gates,now:e})]}),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsx)(Zd,{taskId:w.id,pinProvider:b,pinModel:S,pinEffort:ee,onPinProvider:x,onPinModel:C,onPinEffort:te,onDispatch:ue,onSpawn:e=>void p(w.id,e),loading:ae,result:ie,providers:m})]}),T&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsx)(tf,{memory:T,now:e})]}),re.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsx)(nf,{history:re,now:e})]})]})]})})]})})}function Yd({form:e,onChange:t,onSave:n,onCancel:r}){return(0,V.jsxs)(`section`,{className:`space-y-4`,children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Edit Task fields`}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)($,{htmlFor:`edit-title`,children:`Title`}),(0,V.jsx)(R,{id:`edit-title`,value:e.title,onChange:e=>t({title:e.target.value})})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)($,{htmlFor:`edit-intent`,children:`Intent`}),(0,V.jsx)(Vd,{id:`edit-intent`,value:e.intent,onChange:e=>t({intent:e.target.value}),rows:3})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)($,{htmlFor:`edit-steer`,children:`Latest steer`}),(0,V.jsx)(Vd,{id:`edit-steer`,value:e.latestSteer,onChange:e=>t({latestSteer:e.target.value}),rows:2,placeholder:`Redirect or re-scope in-flight work`})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)($,{htmlFor:`edit-done-when`,children:`Done when`}),(0,V.jsx)(Vd,{id:`edit-done-when`,value:e.doneWhen,onChange:e=>t({doneWhen:e.target.value}),rows:2})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)($,{htmlFor:`edit-team`,children:`Team ID`}),(0,V.jsx)(R,{id:`edit-team`,value:e.teamId,onChange:e=>t({teamId:e.target.value})})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)($,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Dispatch work-shape`}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`edit-complexity`,className:`text-xs`,children:`Complexity`}),(0,V.jsxs)(`select`,{id:`edit-complexity`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchComplexity,onChange:e=>t({dispatchComplexity:e.target.value}),children:[(0,V.jsx)(`option`,{value:``,children:`—`}),Dt.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`edit-type`,className:`text-xs`,children:`Type`}),(0,V.jsxs)(`select`,{id:`edit-type`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchType,onChange:e=>t({dispatchType:e.target.value}),children:[(0,V.jsx)(`option`,{value:``,children:`—`}),St.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`edit-footprint`,className:`text-xs`,children:`Context footprint`}),(0,V.jsxs)(`select`,{id:`edit-footprint`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchFootprint,onChange:e=>t({dispatchFootprint:e.target.value}),children:[(0,V.jsx)(`option`,{value:``,children:`—`}),Et.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`edit-criticality`,className:`text-xs`,children:`Criticality`}),(0,V.jsxs)(`select`,{id:`edit-criticality`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchCriticality,onChange:e=>t({dispatchCriticality:e.target.value}),children:[(0,V.jsx)(`option`,{value:``,children:`—`}),kt.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]})]})]}),(0,V.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,V.jsx)(L,{size:`sm`,onClick:n,children:`Save`}),(0,V.jsx)(L,{size:`sm`,variant:`outline`,onClick:r,children:`Cancel`})]})]})}function Xd({detail:e}){let t=e.dispatchWorkShape,n=e.dispatchDecision,r=e.boundWorkerModel;return(0,V.jsxs)(`section`,{className:`space-y-3`,children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Dispatch`}),t&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Work shape`}),t.specified?(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[t.complexity&&(0,V.jsx)(I,{variant:`secondary`,className:`text-xs`,children:t.complexity}),t.type&&(0,V.jsx)(I,{variant:`secondary`,className:`text-xs`,children:t.type}),t.contextFootprint&&(0,V.jsx)(I,{variant:`secondary`,className:`text-xs`,children:t.contextFootprint}),t.criticality&&(0,V.jsx)(I,{variant:`secondary`,className:`text-xs`,children:t.criticality})]}):(0,V.jsx)(`span`,{className:`text-xs italic text-muted-foreground`,children:`Not specified`})]}),n&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Decision`}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[n.target.provider&&(0,V.jsx)(I,{variant:`secondary`,className:`text-xs font-mono`,children:n.target.provider}),n.target.model&&(0,V.jsx)(I,{variant:`outline`,className:`text-xs font-mono`,children:n.target.model}),n.target.effort&&(0,V.jsx)(I,{variant:`outline`,className:`text-xs`,children:n.target.effort}),n.pinned&&(0,V.jsx)(I,{variant:`outline`,className:`text-xs text-yellow-400 border-yellow-500/30`,children:`pinned`})]}),n.rationale&&(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.rationale}),n.warnings?.map((e,t)=>(0,V.jsxs)(`div`,{className:`flex items-start gap-1 text-xs text-yellow-400 mt-0.5`,children:[(0,V.jsx)(je,{className:`w-3 h-3 shrink-0 mt-0.5`}),(0,V.jsx)(`span`,{children:e})]},t))]}),r&&(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Bound worker`}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[r.provider&&(0,V.jsx)(I,{variant:`secondary`,className:`text-xs font-mono`,children:r.provider}),r.model&&(0,V.jsx)(I,{variant:`outline`,className:`text-xs font-mono`,children:r.model}),r.effort&&(0,V.jsx)(I,{variant:`outline`,className:`text-xs`,children:r.effort})]}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground font-mono truncate min-w-0`,title:r.agentId,children:r.agentId})]})]})}function Zd({taskId:e,pinProvider:t,pinModel:n,pinEffort:r,onPinProvider:i,onPinModel:a,onPinEffort:o,onDispatch:s,onSpawn:c,loading:l,result:u,providers:d}){return(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-3`,children:`Spawn with task`}),(0,V.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 mb-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`spawn-provider-${e}`,className:`text-xs`,children:`Provider pin`}),(0,V.jsxs)(`select`,{id:`spawn-provider-${e}`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-xs`,value:t,onChange:e=>i(e.target.value),children:[(0,V.jsx)(`option`,{value:``,children:`auto`}),d.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`spawn-model-${e}`,className:`text-xs`,children:`Model pin`}),(0,V.jsx)(R,{id:`spawn-model-${e}`,className:`mt-1 h-8 text-xs`,value:n,onChange:e=>a(e.target.value),placeholder:`auto`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`spawn-effort-${e}`,className:`text-xs`,children:`Effort pin`}),(0,V.jsx)(R,{id:`spawn-effort-${e}`,className:`mt-1 h-8 text-xs`,value:r,onChange:e=>o(e.target.value),placeholder:`auto`})]})]}),(0,V.jsxs)(L,{size:`sm`,onClick:s,disabled:l,className:`gap-1.5`,children:[(0,V.jsx)(Fe,{className:`w-3.5 h-3.5`}),l?`Planning…`:`Plan dispatch`]}),u&&(0,V.jsxs)(`div`,{className:`mt-3 rounded-md border border-border bg-muted/20 p-3 space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,V.jsx)(Fe,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0 mt-0.5`}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,V.jsx)(I,{variant:`secondary`,className:`text-xs font-mono`,children:u.decision.target.provider}),u.decision.target.model&&(0,V.jsx)(I,{variant:`outline`,className:`text-xs font-mono`,children:u.decision.target.model}),u.decision.target.effort&&(0,V.jsx)(I,{variant:`outline`,className:`text-xs`,children:u.decision.target.effort}),u.decision.pinned&&(0,V.jsx)(I,{variant:`outline`,className:`text-xs text-yellow-400 border-yellow-500/30`,children:`pinned`})]}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u.decision.rationale}),u.decision.factors.band&&(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Band: `,u.decision.factors.band,u.decision.factors.contextWindowTokens?` · ${(u.decision.factors.contextWindowTokens/1e3).toFixed(0)}k ctx`:``]}),u.decision.warnings.length>0&&(0,V.jsx)(`div`,{className:`space-y-0.5`,children:u.decision.warnings.map((e,t)=>(0,V.jsxs)(`div`,{className:`flex items-start gap-1 text-xs text-yellow-400`,children:[(0,V.jsx)(je,{className:`w-3 h-3 shrink-0 mt-0.5`}),(0,V.jsx)(`span`,{children:e})]},t))}),u.decision.review&&(0,V.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Auto-review: `,u.decision.review.reason,` → `,u.decision.review.target.provider,`/`,u.decision.review.target.model??`default`,u.reviewTaskId&&(0,V.jsxs)(`span`,{className:`ml-1`,children:[`(task T`,u.reviewTaskId,`)`]})]})]})]}),(0,V.jsx)(`div`,{className:`pt-1 border-t border-border/50`,children:(0,V.jsxs)(L,{size:`sm`,className:`gap-1.5 w-full`,onClick:()=>c(u.decision.target),children:[(0,V.jsx)(Fe,{className:`w-3.5 h-3.5`}),`Spawn worker with task T`,e]})})]})]})}function Qd({issues:e}){return(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Linked Issues`}),(0,V.jsx)(`div`,{className:`space-y-1.5`,children:e.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-sm min-w-0`,children:[(0,V.jsxs)(`span`,{className:`font-mono text-xs text-muted-foreground shrink-0`,children:[e.provider,`/`,e.externalKey]}),e.title&&(0,V.jsx)(`span`,{className:`truncate flex-1 min-w-0`,children:e.title}),(0,V.jsx)(I,{variant:`secondary`,className:`text-xs shrink-0`,children:e.status}),e.url&&(0,V.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,V.jsx)(me,{className:`w-3.5 h-3.5`})})]},e.issueRefId))})]})}function $d({dependsOn:e,dependents:t}){return(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Dependencies`}),(0,V.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[e.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Depends on: `}),e.map((t,n)=>(0,V.jsxs)(`span`,{className:`font-mono text-xs`,children:[`T`,t,n<e.length-1?`, `:``]},t))]}),t.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Blocks: `}),t.map((e,n)=>(0,V.jsxs)(`span`,{className:`font-mono text-xs`,children:[`T`,e,n<t.length-1?`, `:``]},e))]})]})]})}function ef({gates:e,now:t}){return(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Gate Ledger`}),(0,V.jsx)(`div`,{className:`space-y-2`,children:[...e].sort((e,t)=>t.ranAt-e.ranAt).map(e=>(0,V.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[e.status===`pass`?(0,V.jsx)(ot,{className:`w-4 h-4 text-emerald-400 shrink-0 mt-0.5`}):(0,V.jsx)(Ee,{className:`w-4 h-4 text-red-400 shrink-0 mt-0.5`}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,V.jsx)(`span`,{className:`font-mono text-xs font-medium truncate min-w-0`,children:e.gate}),(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto shrink-0`,title:Jt(e.ranAt),children:M(t,e.ranAt)})]}),e.detail&&(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 truncate`,children:e.detail}),e.commitSha&&(0,V.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.commitSha.slice(0,8)})]})]},e.gate+e.ranAt))})]})}function tf({memory:e,now:t}){return(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Task Memory`}),(0,V.jsxs)(`div`,{className:`space-y-3`,children:[e.workingState&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Working state`}),(0,V.jsx)(`p`,{className:`text-xs whitespace-pre-wrap [overflow-wrap:anywhere] bg-muted/30 rounded p-2`,children:e.workingState})]}),e.ledger.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:[`Ruled out (`,e.ledger.length,`)`]}),(0,V.jsx)(`div`,{className:`space-y-1`,children:e.ledger.map((e,t)=>(0,V.jsxs)(`div`,{className:`text-xs bg-muted/20 rounded p-1.5`,children:[(0,V.jsx)(`span`,{className:`font-medium`,children:e.ruledOut}),e.why&&(0,V.jsxs)(`span`,{className:`text-muted-foreground`,children:[` — `,e.why]})]},t))})]}),e.decisions.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:[`Decisions (`,e.decisions.length,`)`]}),(0,V.jsx)(`div`,{className:`space-y-1.5`,children:e.decisions.map((e,n)=>(0,V.jsxs)(`div`,{className:`text-xs`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0`,children:[(0,V.jsx)(`span`,{className:`font-medium truncate min-w-0`,children:e.decision}),(0,V.jsx)(`span`,{className:`text-muted-foreground ml-auto shrink-0`,title:Jt(e.at),children:M(t,e.at)})]}),e.rationale&&(0,V.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:e.rationale}),e.by&&(0,V.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`by `,e.by]})]},n))})]})]})]})}function nf({history:e,now:t}){return(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`History`}),(0,V.jsx)(`div`,{className:`space-y-2`,children:[...e].reverse().slice(0,30).map(e=>(0,V.jsxs)(`div`,{className:`flex items-start gap-2 text-xs`,children:[(0,V.jsx)(Se,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0 mt-0.5`}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,V.jsx)(`span`,{className:`font-mono text-muted-foreground shrink-0`,children:e.type}),(0,V.jsx)(`span`,{className:`ml-auto text-muted-foreground shrink-0`,title:Jt(e.createdAt),children:M(t,e.createdAt)})]}),e.title&&e.title!==e.type&&(0,V.jsx)(`p`,{className:`text-foreground mt-0.5 truncate`,children:e.title})]})]},e.id))})]})}var rf=!1;function af(e,t){let n=B.useRef(!1),r=B.useRef(t);r.current=t,B.useEffect(()=>{if(!e||!r.current)return;rf=!1,window.history.pushState({dialogGuard:!0},``),n.current=!0;function t(){if(rf){rf=!1;return}n.current&&(n.current=!1,r.current?.(!1))}return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t),n.current&&(n.current=!1,rf=!0,window.history.back())}},[e])}function of({...e}){return af(e.open,e.onOpenChange),(0,V.jsx)(zr,{"data-slot":`dialog`,...e})}function sf({...e}){return(0,V.jsx)(Br,{"data-slot":`dialog-portal`,...e})}function cf({className:e,blur:t=!0,...n}){return(0,V.jsx)(Vr,{"data-slot":`dialog-overlay`,className:k(`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 lf({className:e,children:t,showCloseButton:n=!0,blurOverlay:r=!0,...i}){return(0,V.jsxs)(sf,{children:[(0,V.jsx)(cf,{blur:r}),(0,V.jsxs)(Hr,{"data-slot":`dialog-content`,className:k(`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,V.jsx)(Gr,{"data-slot":`dialog-close`,asChild:!0,children:(0,V.jsxs)(L,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`,children:[(0,V.jsx)(ye,{}),(0,V.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function uf({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`dialog-header`,className:k(`flex flex-col gap-2`,e),...t})}function df({className:e,showCloseButton:t=!1,children:n,...r}){return(0,V.jsxs)(`div`,{"data-slot":`dialog-footer`,className:k(`-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,V.jsx)(Gr,{asChild:!0,children:(0,V.jsx)(L,{variant:`outline`,children:`Close`})})]})}function ff({className:e,...t}){return(0,V.jsx)(Ur,{"data-slot":`dialog-title`,className:k(`font-heading text-base leading-none font-medium`,e),...t})}function pf({className:e,...t}){return(0,V.jsx)(Wr,{"data-slot":`dialog-description`,className:k(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function mf(){let e=j(e=>e.composeOpen),t=j(e=>e.compose),n=j(e=>e.replyTo),r=j(e=>e.set),i=j(e=>e.doSend),a=j(e=>e.cancelReply),o=al();function s(){r({composeOpen:!1}),a()}function c(e){r({compose:{...t,...e}})}return(0,V.jsx)(of,{open:e,onOpenChange:e=>!e&&s(),children:(0,V.jsxs)(lf,{className:`max-w-lg`,children:[(0,V.jsx)(uf,{children:(0,V.jsx)(ff,{children:n?`Reply to #${n.id}`:`Compose Message`})}),(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`From`}),(0,V.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,V.jsx)(`option`,{value:``,children:`Select agent...`}),o.map(e=>(0,V.jsx)(`option`,{value:e.id,children:N(e)},e.id))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`To`}),(0,V.jsx)(R,{value:t.to,onChange:e=>c({to:e.target.value}),placeholder:`agent-id, tag:name, cap:name, or broadcast`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Subject`}),(0,V.jsx)(R,{value:t.subject,onChange:e=>c({subject:e.target.value}),placeholder:`Optional subject...`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Channel`}),(0,V.jsx)(R,{value:t.channel,onChange:e=>c({channel:e.target.value}),placeholder:`Optional channel...`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Message`}),(0,V.jsx)(Vd,{value:t.body,onChange:e=>c({body:e.target.value}),rows:4,placeholder:`Message body...`,autoFocus:!0})]}),(0,V.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(dl,{checked:t.claimable,onCheckedChange:e=>c({claimable:e})}),(0,V.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Claimable task`})]})]}),(0,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:s,children:`Cancel`}),(0,V.jsx)(L,{onClick:i,children:`Send`})]})]})})}function hf(){let e=j(e=>e.confirmModal),t=j(e=>e.set);function n(){t({confirmModal:{show:!1,title:``,message:``,action:null}})}return(0,V.jsx)(of,{open:e.show,onOpenChange:e=>!e&&n(),children:(0,V.jsxs)(lf,{className:`sm:max-w-sm`,children:[(0,V.jsxs)(uf,{children:[(0,V.jsx)(ff,{children:e.title}),(0,V.jsx)(pf,{children:e.message})]}),(0,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:n,children:`Cancel`}),(0,V.jsx)(L,{variant:`destructive`,onClick:()=>{e.action?.(),n()},children:`Confirm`})]})]})})}function gf(){let e=j(e=>e.errorModal),t=j(e=>e.set);function n(){t({errorModal:{show:!1,title:``,message:``}})}return(0,V.jsx)(of,{open:e.show,onOpenChange:e=>!e&&n(),children:(0,V.jsxs)(lf,{className:`sm:max-w-sm`,children:[(0,V.jsxs)(uf,{children:[(0,V.jsx)(ff,{children:e.title}),(0,V.jsx)(pf,{children:e.message})]}),(0,V.jsx)(df,{children:(0,V.jsx)(L,{onClick:n,children:`OK`})})]})})}function _f(){let e=j(e=>e.renameModal),t=j(e=>e.set),n=j(e=>e.doRename);function r(){t({renameModal:{show:!1,agentId:``,label:``}})}return(0,V.jsx)(of,{open:e.show,onOpenChange:e=>!e&&r(),children:(0,V.jsxs)(lf,{className:`sm:max-w-sm`,children:[(0,V.jsx)(uf,{children:(0,V.jsx)(ff,{children:`Rename Agent`})}),(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsx)($,{children:`Label`}),(0,V.jsx)(R,{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,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Leave empty to clear the label.`})]}),(0,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:r,children:`Cancel`}),(0,V.jsx)(L,{onClick:n,children:`Save`})]})]})})}function vf(){let e=j(e=>e.pairInviteOpen),t=j(e=>e.pairInvite),n=j(e=>e.set),r=j(e=>e.closePairInvite),i=j(e=>e.doCreatePair),a=al();function o(e){n({pairInvite:{...t,...e}})}return(0,V.jsx)(of,{open:e,onOpenChange:e=>!e&&r(),children:(0,V.jsxs)(lf,{className:`sm:max-w-sm`,children:[(0,V.jsx)(uf,{children:(0,V.jsx)(ff,{children:`Pair Agents`})}),(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Requester`}),(0,V.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,V.jsx)(`option`,{value:``,children:`Select agent...`}),a.map(e=>(0,V.jsx)(`option`,{value:e.id,children:N(e)},e.id))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Target`}),(0,V.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,V.jsx)(`option`,{value:``,children:`Select agent...`}),a.map(e=>(0,V.jsx)(`option`,{value:e.id,children:N(e)},e.id))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Objective`}),(0,V.jsx)(R,{value:t.objective,onChange:e=>o({objective:e.target.value}),placeholder:`What should they work on?`})]})]}),(0,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:r,children:`Cancel`}),(0,V.jsx)(L,{onClick:i,children:`Create Pair`})]})]})})}function yf(){let e=j(e=>e.pairMessageOpen),t=j(e=>e.pairMessage),n=j(e=>e.set),r=j(e=>e.closePairMessage),i=j(e=>e.doSendPairMessage);function a(e){n({pairMessage:{...t,...e}})}return(0,V.jsx)(of,{open:e,onOpenChange:e=>!e&&r(),children:(0,V.jsxs)(lf,{className:`sm:max-w-sm`,children:[(0,V.jsx)(uf,{children:(0,V.jsx)(ff,{children:`Pair Message`})}),(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Subject`}),(0,V.jsx)(R,{value:t.subject,onChange:e=>a({subject:e.target.value}),placeholder:`Optional subject...`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Message`}),(0,V.jsx)(Vd,{value:t.body,onChange:e=>a({body:e.target.value}),rows:4,placeholder:`Message body...`,autoFocus:!0})]})]}),(0,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:r,children:`Cancel`}),(0,V.jsx)(L,{onClick:i,children:`Send`})]})]})})}function bf(){let e=j(e=>e.threadOpen),t=j(e=>e.threadMessages),n=j(e=>e.agentsById),r=yt(),i=j(e=>e.set);return(0,V.jsx)(of,{open:e,onOpenChange:e=>!e&&i({threadOpen:!1}),children:(0,V.jsxs)(lf,{className:`max-w-2xl max-h-[80vh]`,children:[(0,V.jsx)(uf,{children:(0,V.jsxs)(ff,{children:[`Thread (`,t.length,` messages)`]})}),(0,V.jsx)(Rd,{className:`max-h-[60vh]`,children:(0,V.jsx)(`div`,{className:`space-y-3 pr-4`,children:t.map(e=>(0,V.jsxs)(`div`,{className:`rounded-lg border border-border p-3 space-y-1`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,V.jsx)(`span`,{className:`font-medium`,children:qt(e.from,n)}),(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:qt(e.to,n)}),(0,V.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:M(r,e.createdAt)})]}),e.subject&&(0,V.jsx)(`div`,{className:`text-sm font-medium`,children:e.subject}),(0,V.jsx)(Ud,{text:Zt(e),rawBody:e.body,issueRepo:n[e.from===`user`?e.to:e.from]?.issueRepo,className:`text-sm text-muted-foreground`}),(0,V.jsxs)(`div`,{className:`flex gap-1.5 flex-wrap`,children:[e.channel&&(0,V.jsx)(I,{variant:`secondary`,className:`text-[10px]`,children:e.channel}),e.claimedBy&&(0,V.jsxs)(I,{variant:`secondary`,className:`text-[10px]`,children:[`claimed by `,qt(e.claimedBy,n)]})]})]},e.id))})})]})})}function xf(){let e=j(e=>e.taskEventsOpen),t=j(e=>e.taskEvents),n=j(e=>e.set),r=j(e=>e.switchView);function i(e){n({selectedMemoryId:e,taskEventsOpen:!1}),r(`memory`)}return(0,V.jsx)(of,{open:e,onOpenChange:e=>!e&&n({taskEventsOpen:!1}),children:(0,V.jsxs)(lf,{className:`max-w-2xl max-h-[80vh]`,children:[(0,V.jsx)(uf,{children:(0,V.jsxs)(ff,{children:[`Task Events (`,t.length,`)`]})}),(0,V.jsx)(Rd,{className:`max-h-[60vh]`,children:(0,V.jsxs)(`div`,{className:`space-y-2 pr-4`,children:[t.map(e=>(0,V.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-border p-3`,children:[(0,V.jsx)(I,{className:Kt[e.severity]||Kt.info,children:e.severity}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`text-sm font-medium`,children:e.title}),(0,V.jsx)(I,{variant:`outline`,className:`text-[10px]`,children:e.type})]}),e.body&&(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 whitespace-pre-wrap`,children:e.body}),(0,V.jsx)(Sf,{event:e,onOpen:i}),(0,V.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[Jt(e.createdAt),` · `,e.source]})]})]},e.id)),t.length===0&&(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-8`,children:`No events recorded.`})]})})]})})}function Sf({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,V.jsx)(`div`,{className:`mt-2 rounded-md border border-border bg-muted/20 p-2 text-xs`,children:(0,V.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,V.jsx)(ie,{className:`w-3.5 h-3.5 mt-0.5 text-muted-foreground shrink-0`}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[(0,V.jsx)(I,{variant:`secondary`,className:`text-[10px]`,children:o}),a&&(0,V.jsx)(I,{variant:`outline`,className:`text-[10px] font-mono`,children:a}),s&&(0,V.jsx)(I,{variant:`outline`,className:`text-[10px]`,children:s})]}),(0,V.jsx)(`div`,{className:`font-medium truncate`,children:i}),n&&(0,V.jsx)(`div`,{className:`font-mono text-[10px] text-muted-foreground truncate`,children:n})]}),n&&(0,V.jsx)(L,{size:`sm`,variant:`outline`,className:`h-7 text-xs shrink-0`,onClick:()=>t(n),children:`Open`})]})})}function Cf(){let e=j(e=>e.taskCreateOpen),t=j(e=>e.taskCreateForm),n=j(e=>e.closeTaskCreate),r=j(e=>e.setTaskCreateForm),i=j(e=>e.doCreateTask);return(0,V.jsx)(of,{open:e,onOpenChange:e=>!e&&n(),children:(0,V.jsxs)(lf,{className:`max-w-lg`,children:[(0,V.jsx)(uf,{children:(0,V.jsx)(ff,{children:`New Task`})}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsxs)($,{htmlFor:`task-title`,children:[`Title `,(0,V.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,V.jsx)(R,{id:`task-title`,value:t.title,onChange:e=>r({title:e.target.value}),placeholder:`Short description of the work`,autoFocus:!0})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)($,{htmlFor:`task-intent`,children:`Intent`}),(0,V.jsx)(Vd,{id:`task-intent`,value:t.intent,onChange:e=>r({intent:e.target.value}),placeholder:`What is this task trying to accomplish?`,rows:3})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)($,{htmlFor:`task-done-when`,children:`Done when`}),(0,V.jsx)(Vd,{id:`task-done-when`,value:t.doneWhen,onChange:e=>r({doneWhen:e.target.value}),placeholder:`Acceptance criteria`,rows:2})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsxs)($,{htmlFor:`task-issue-refs`,children:[`Issue refs `,(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(comma-separated, e.g. owner/repo#123)`})]}),(0,V.jsx)(R,{id:`task-issue-refs`,value:t.issueRefs,onChange:e=>r({issueRefs:e.target.value}),placeholder:`owner/repo#123, owner/repo#456`})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsxs)($,{htmlFor:`task-depends-on`,children:[`Depends on `,(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(comma-separated task IDs)`})]}),(0,V.jsx)(R,{id:`task-depends-on`,value:t.dependsOn,onChange:e=>r({dependsOn:e.target.value}),placeholder:`42, 43`})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)($,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Dispatch work-shape (optional)`}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`dispatch-complexity`,className:`text-xs`,children:`Complexity`}),(0,V.jsxs)(`select`,{id:`dispatch-complexity`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchComplexity,onChange:e=>r({dispatchComplexity:e.target.value}),children:[(0,V.jsx)(`option`,{value:``,children:`—`}),Dt.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`dispatch-type`,className:`text-xs`,children:`Type`}),(0,V.jsxs)(`select`,{id:`dispatch-type`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchType,onChange:e=>r({dispatchType:e.target.value}),children:[(0,V.jsx)(`option`,{value:``,children:`—`}),St.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`dispatch-footprint`,className:`text-xs`,children:`Context footprint`}),(0,V.jsxs)(`select`,{id:`dispatch-footprint`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchFootprint,onChange:e=>r({dispatchFootprint:e.target.value}),children:[(0,V.jsx)(`option`,{value:``,children:`—`}),Et.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`dispatch-criticality`,className:`text-xs`,children:`Criticality`}),(0,V.jsxs)(`select`,{id:`dispatch-criticality`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchCriticality,onChange:e=>r({dispatchCriticality:e.target.value}),children:[(0,V.jsx)(`option`,{value:``,children:`—`}),kt.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]})]})]})]}),(0,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:n,children:`Cancel`}),(0,V.jsx)(L,{onClick:()=>void i(),disabled:!t.title.trim(),children:`Create`})]})]})})}function wf({open:e,onOpenChange:t,onSelect:n,orchestratorId:r,initialPath:i,title:a=`Select Directory`}){let o=j(e=>e.apiCall),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(null),[d,f]=(0,B.useState)(null),[p,h]=(0,B.useState)(!1),[g,_]=(0,B.useState)(``),[v,y]=(0,B.useState)(null),b=l?.path||i||``,x=(0,B.useMemo)(()=>b.split(`/`).filter(Boolean),[b]),S=(0,B.useCallback)(async e=>{if(r){c(!0),f(null),h(!1);try{let t=e?`?path=${encodeURIComponent(e)}`:``;u(await o(`GET`,`/orchestrators/${encodeURIComponent(r)}/directories${t}`))}catch(e){f(At(e))}finally{c(!1)}}},[r,o]);(0,B.useEffect)(()=>{e&&r&&(u(null),f(null),h(!1),S(i||void 0))},[e,r]);async function C(){if(!(!g.trim()||!l)){y(null);try{u(await o(`POST`,`/orchestrators/${encodeURIComponent(r)}/directories`,{path:l.path,name:g.trim()})),h(!1),_(``)}catch(e){y(At(e))}}}function te(){b&&(n(b),t(!1))}function ne(e){S(`/`+x.slice(0,e+1).join(`/`))}return(0,V.jsx)(of,{open:e,onOpenChange:t,children:(0,V.jsxs)(lf,{className:`max-w-lg max-h-[85dvh] flex flex-col`,children:[(0,V.jsx)(uf,{children:(0,V.jsxs)(ff,{className:`flex items-center gap-2`,children:[(0,V.jsx)(E,{className:`h-4 w-4`}),a]})}),(0,V.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,V.jsx)(`button`,{type:`button`,className:`font-mono text-muted-foreground hover:text-foreground shrink-0`,onClick:()=>l?.baseDir&&S(l.baseDir),children:`/`}),x.map((e,t)=>(0,V.jsxs)(`span`,{className:`shrink-0`,children:[(0,V.jsx)(`button`,{type:`button`,className:`font-mono text-muted-foreground hover:text-foreground`,onClick:()=>ne(t),children:e}),t<x.length-1&&(0,V.jsx)(`span`,{className:`text-muted-foreground/50 mx-0.5`,children:`/`})]},`${e}-${t}`))]}),(0,V.jsxs)(`div`,{className:`flex-1 min-h-0 rounded-md border border-border bg-background overflow-y-auto`,style:{maxHeight:`40dvh`},children:[s&&(0,V.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,V.jsx)(A,{className:`h-5 w-5 animate-spin text-muted-foreground`})}),!s&&d&&(0,V.jsx)(`div`,{className:`px-3 py-4 text-sm text-destructive`,children:d}),!s&&l&&(0,V.jsxs)(`div`,{className:`p-1`,children:[l.parent&&(0,V.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:()=>S(l.parent),children:[(0,V.jsx)(Ze,{className:`h-4 w-4 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`..`})]}),l.entries.map(e=>(0,V.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:()=>S(e.path),children:[(0,V.jsx)(m,{className:`h-4 w-4 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)),l.entries.length===0&&!l.parent&&(0,V.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground text-center`,children:`Empty directory`}),l.entries.length===0&&l.parent&&(0,V.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground text-center`,children:`No subdirectories`})]})]}),p?(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(R,{autoFocus:!0,value:g,onChange:e=>{_(e.target.value),y(null)},onKeyDown:e=>{e.key===`Enter`&&C(),e.key===`Escape`&&(h(!1),_(``))},placeholder:`New directory name...`,className:`flex-1 font-mono text-sm`}),(0,V.jsx)(L,{type:`button`,size:`icon`,variant:`outline`,onClick:C,disabled:!g.trim(),children:(0,V.jsx)(ce,{className:`h-4 w-4`})}),(0,V.jsx)(L,{type:`button`,size:`icon`,variant:`ghost`,onClick:()=>{h(!1),_(``),y(null)},children:(0,V.jsx)(ye,{className:`h-4 w-4`})})]}):(0,V.jsxs)(L,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>h(!0),disabled:!l||s,children:[(0,V.jsx)(ee,{className:`h-4 w-4 mr-1.5`}),`New Directory`]}),v&&(0,V.jsx)(`p`,{className:`text-xs text-destructive`,children:v}),(0,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,V.jsx)(L,{onClick:te,disabled:!b,children:`Select`})]})]})})}function Tf({value:e,onChange:t,orchestratorId:n,placeholder:r,disabled:i}){let[a,o]=(0,B.useState)(!1);return(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(R,{value:e,onChange:e=>t(e.target.value),placeholder:r,disabled:i,className:`flex-1 font-mono text-sm`}),(0,V.jsx)(L,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>o(!0),disabled:i||!n,title:`Browse directories`,children:(0,V.jsx)(E,{className:`h-4 w-4`})}),n&&(0,V.jsx)(wf,{open:a,onOpenChange:o,onSelect:t,orchestratorId:n,initialPath:e||void 0})]})}function Ef({model:e}){if(!e)return null;let t=Df(e);return t.length===0?null:(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>(0,V.jsxs)(I,{variant:`outline`,className:`gap-1 text-[10px]`,children:[(0,V.jsx)(e.Icon,{className:`h-3 w-3`}),e.label]},e.label))})}function Df(e){let t=[],n=e.limits?.contextWindowTokens?.value;return n&&t.push({label:Of(n),Icon:b}),e.capabilities?.modalities.input.image&&t.push({label:`Image input`,Icon:f}),(e.capabilities?.modalities.output.image||e.capabilities?.tools?.imageGeneration)&&t.push({label:`Image output`,Icon:f}),e.capabilities?.tools?.code&&t.push({label:`Code`,Icon:et}),t}function Of(e){return e>=1e6?`${e/1e6}M ctx`:e>=1e3?`${Math.round(e/1e3)}K ctx`:`${e} ctx`}function kf(){let e=j(e=>e.orchestratorSpawnOpen),t=j(e=>e.orchestrators),n=j(e=>e.spawnOrchId),r=j(e=>e.spawnProvider),i=j(e=>e.spawnModel),a=j(e=>e.spawnEffort),o=j(e=>e.spawnProfile),s=j(e=>e.spawnCwd),c=j(e=>e.spawnLabel),l=j(e=>e.spawnApproval),u=j(e=>e.spawnWorkspaceMode),d=j(e=>e.spawnPrompt),f=j(e=>e.spawnSystemPromptAppend),p=j(e=>e.spawnCount),m=j(e=>e.spawnCwdHistory),h=j(e=>e.isSpawning),g=j(e=>!!e.pendingForkImport),_=j(e=>e.set),v=j(e=>e.submitOrchestratorSpawn),y=j(e=>e.selectSpawnHistory),b=j(e=>e.agentProfiles),x=j(e=>e.providerCatalog),S=t.find(e=>e.id===n),C=S?.providers||[],ee=xt(r,x),te=ee.find(e=>e.alias===i),ne=te?.efforts||[],w=!!(S&&C.length>0&&s.trim())&&!h,T=t.filter(e=>e.status===`online`),re=T.length>1,ie=m.filter(e=>T.some(t=>t.id===e.orchId)).slice(0,5);function ae(e){let n=t.find(t=>t.id===e),r=n?.providers[0]||``;_({spawnOrchId:e,spawnProvider:r,spawnModel:r?_t(r,x):``,spawnEffort:``,spawnCwd:n?.baseDir||``})}function oe(e){_({spawnProvider:e,spawnModel:_t(e,x),spawnEffort:``})}function E(e){_({spawnModel:e,spawnEffort:``})}return(0,V.jsx)(of,{open:e,onOpenChange:e=>!e&&_({orchestratorSpawnOpen:!1}),children:(0,V.jsxs)(lf,{className:`max-w-lg max-h-[90dvh] flex flex-col`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,V.jsx)(uf,{children:(0,V.jsx)(ff,{children:`Spawn Agent`})}),(0,V.jsxs)(`div`,{className:`space-y-3 overflow-y-auto flex-1 min-h-0 -mx-4 px-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Orchestrator`}),(0,V.jsx)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:n,onChange:e=>ae(e.target.value),children:t.filter(e=>e.status===`online`).map(e=>(0,V.jsxs)(`option`,{value:e.id,children:[e.hostname,` (`,e.id.slice(-8),`)`]},e.id))})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Provider`}),(0,V.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:r,onChange:e=>oe(e.target.value),disabled:!C.length,children:[!C.length&&(0,V.jsx)(`option`,{value:r,children:`No providers available`}),C.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Model`}),(0,V.jsx)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:i,onChange:e=>E(e.target.value),disabled:!ee.length,children:ee.map(e=>(0,V.jsx)(`option`,{value:e.alias,children:e.label},e.alias))})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Effort`}),(0,V.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:!ne.length,children:[(0,V.jsx)(`option`,{value:``,children:`Default`}),ne.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,V.jsx)(Ef,{model:te}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Agent Profile`}),(0,V.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,V.jsx)(`option`,{value:`default-relay`,children:`default-relay`}),b.map(e=>(0,V.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Approval Mode`}),(0,V.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,V.jsx)(`option`,{value:`open`,children:`Open`}),(0,V.jsx)(`option`,{value:`guarded`,children:`Guarded`}),(0,V.jsx)(`option`,{value:`read-only`,children:`Read-only`})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Workspace`}),(0,V.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,V.jsx)(`option`,{value:`inherit`,children:`Default`}),(0,V.jsx)(`option`,{value:`isolated`,children:`Isolated worktree`}),(0,V.jsx)(`option`,{value:`shared`,children:`Shared cwd`})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Working Directory`}),(0,V.jsx)(`div`,{className:`mt-1`,children:(0,V.jsx)(Tf,{value:s,onChange:e=>_({spawnCwd:e}),orchestratorId:n,placeholder:`Select a project directory`})}),ie.length>0&&(0,V.jsxs)(`div`,{className:`mt-2`,children:[(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground mb-1`,children:`Recent`}),(0,V.jsx)(`div`,{className:`flex gap-1.5 overflow-x-auto pb-1 sm:flex-wrap sm:overflow-x-visible sm:pb-0`,children:ie.map(e=>{let t=e.cwd.replace(/\/+$/,``).split(`/`).pop()||e.cwd,r=T.find(t=>t.id===e.orchId)?.hostname,i=e.orchId===n&&e.cwd===s;return(0,V.jsx)(`button`,{type:`button`,title:re&&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:re&&r?`${r}: ${t}`:t},`${e.orchId}:${e.cwd}`)})})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Label`}),(0,V.jsx)(R,{value:c,onChange:e=>_({spawnLabel:e.target.value}),placeholder:`Optional label...`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Initial Prompt`}),(0,V.jsx)(Vd,{value:d,onChange:e=>_({spawnPrompt:e.target.value}),rows:3,placeholder:`Optional initial task...`}),(0,V.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,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`System Prompt Append`}),(0,V.jsx)(Vd,{value:f,onChange:e=>_({spawnSystemPromptAppend:e.target.value}),rows:5,placeholder:`Optional launch context...`}),(0,V.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,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)($,{children:`Number of Agents`}),(0,V.jsx)(`span`,{className:`text-sm font-mono tabular-nums text-muted-foreground`,children:p})]}),(0,V.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,V.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,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:()=>_({orchestratorSpawnOpen:!1}),disabled:h,children:`Cancel`}),(0,V.jsx)(L,{onClick:v,disabled:!w,children:h?`Spawning…`:C.length?p>1?`Spawn ${p}`:`Spawn`:`No providers`})]})]})})}function Af(){return`host-${Math.random().toString(36).slice(2,8)}`}function jf(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function Mf(){let e=j(e=>e.orchestratorInstallOpen),t=j(e=>e.set),n=j(e=>e.showError),r=j(e=>e.showNotification),i=(0,B.useMemo)(()=>new URL(Ce()).origin,[]),[a,o]=(0,B.useState)(Af),[s,l]=(0,B.useState)(`$HOME/projects`),[u,d]=(0,B.useState)(Ot()),[f,p]=(0,B.useState)(`4860`),[m,h]=(0,B.useState)(``),[g,_]=(0,B.useState)(``),[v,y]=(0,B.useState)(),[b,x]=(0,B.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(!u.length){n(`Validation`,`Select at least one provider`);return}x(!0);try{let e=await Qe(`POST`,`/orchestrators/bootstrap`,{id:a.trim(),relayUrl:i,baseDir:s.trim(),providers:u,apiPort:Number(f)||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,V.jsx)(of,{open:e,onOpenChange:e=>!e&&t({orchestratorInstallOpen:!1}),children:(0,V.jsxs)(lf,{className:`max-w-2xl overflow-hidden`,children:[(0,V.jsx)(uf,{children:(0,V.jsxs)(ff,{className:`flex items-center gap-2`,children:[(0,V.jsx)(c,{className:`w-4 h-4`}),`Add Orchestrator`]})}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Orchestrator ID`}),(0,V.jsx)(R,{value:a,onChange:e=>o(e.target.value)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Relay URL`}),(0,V.jsx)(R,{value:i,readOnly:!0})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Base Directory`}),(0,V.jsx)(R,{value:s,onChange:e=>l(e.target.value)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`API Port`}),(0,V.jsx)(R,{value:f,onChange:e=>p(e.target.value),inputMode:`numeric`})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Providers`}),(0,V.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-2`,children:Ot().map(e=>(0,V.jsx)(L,{type:`button`,size:`sm`,variant:u.includes(e)?`default`:`outline`,onClick:()=>d(jf(u,e)),children:Tt(e)},e))})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Extra PATH Prefix`}),(0,V.jsx)(R,{value:m,onChange:e=>h(e.target.value),placeholder:`/opt/homebrew/bin:/custom/bin`})]}),g&&(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,V.jsx)($,{children:`Install Command`}),v&&(0,V.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`Install token expires `,new Date(v*1e3).toLocaleString()]})]}),(0,V.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,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:()=>t({orchestratorInstallOpen:!1}),children:`Close`}),g&&(0,V.jsx)(Un,{value:g,label:`Copy`,showText:!0,size:`default`,variant:`outline`,className:`gap-1`,onCopied:()=>r(`Install command copied`)}),(0,V.jsxs)(L,{className:`gap-1`,onClick:S,disabled:b,children:[(0,V.jsx)(_e,{className:`w-3.5 h-3.5`}),b?`Generating...`:`Generate Command`]})]})]})})}function Nf(){let e=j(e=>e.policyModal),t=j(e=>e.orchestrators),n=j(e=>e.agentProfiles),r=j(e=>e.set),i=j(e=>e.submitPolicy),a=j(e=>e.providerCatalog),o=t.find(t=>t.id===e.orchestratorId),s=o?.providers||[],c=xt(e.provider,a),l=c.find(t=>t.alias===e.model),u=l?.efforts||[],d=!!e.editing,f=o?.providerStatus?.find(t=>t.name===e.provider)?.features?.rig===!0;function p(t){r({policyModal:{...e,...t}})}function m(n){let r=t.find(e=>e.id===n)?.providers[0]||e.provider;p({orchestratorId:n,provider:r,model:_t(r,a),effort:``})}function h(e){p({provider:e,rig:``,model:_t(e,a),effort:``})}return(0,V.jsx)(of,{open:e.open,onOpenChange:e=>!e&&p({open:!1}),children:(0,V.jsxs)(lf,{className:`max-w-lg max-h-[90vh] overflow-y-auto`,children:[(0,V.jsx)(uf,{children:(0,V.jsx)(ff,{children:d?`Edit Policy`:`Create Managed Agent`})}),(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Policy Name`}),(0,V.jsx)(R,{value:e.name,onChange:e=>p({name:e.target.value}),placeholder:`my-agent`,disabled:d})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Label`}),(0,V.jsx)(R,{value:e.label,onChange:e=>p({label:e.target.value}),placeholder:`Human-friendly name...`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Description`}),(0,V.jsx)(R,{value:e.description,onChange:e=>p({description:e.target.value}),placeholder:`What does this agent do?`})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Orchestrator`}),(0,V.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=>m(e.target.value),children:t.filter(e=>e.status===`online`).map(e=>(0,V.jsxs)(`option`,{value:e.id,children:[e.hostname,` (`,e.id.slice(-8),`)`]},e.id))})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Provider`}),(0,V.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=>h(e.target.value),disabled:!s.length,children:[!s.length&&(0,V.jsx)(`option`,{value:e.provider,children:`No providers available`}),s.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]})]}),f&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Rig`}),(0,V.jsx)(R,{value:e.rig,onChange:e=>p({rig:e.target.value}),placeholder:`Leave empty to auto-detect from .claude-rig`}),(0,V.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,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Model`}),(0,V.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=>p({model:e.target.value,effort:``}),children:c.map(e=>(0,V.jsx)(`option`,{value:e.alias,children:e.label},e.alias))})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Effort`}),(0,V.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=>p({effort:e.target.value}),disabled:!u.length,children:[(0,V.jsx)(`option`,{value:``,children:`Default`}),u.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,V.jsx)(Ef,{model:l}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Agent Profile`}),(0,V.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=>p({profile:e.target.value}),children:[!n.length&&(0,V.jsx)(`option`,{value:`default-relay`,children:`default-relay`}),n.map(e=>(0,V.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Working Directory`}),(0,V.jsx)(`div`,{className:`mt-1`,children:(0,V.jsx)(Tf,{value:e.cwd,onChange:e=>p({cwd:e}),orchestratorId:e.orchestratorId,placeholder:o?.baseDir||`/path/to/project`})})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Mode`}),(0,V.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=>p({mode:e.target.value}),children:[(0,V.jsx)(`option`,{value:`always-on`,children:`Always On`}),(0,V.jsx)(`option`,{value:`on-demand`,children:`On Demand`})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Permission Mode`}),(0,V.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=>p({permissionMode:e.target.value}),children:[(0,V.jsx)(`option`,{value:`open`,children:`Open`}),(0,V.jsx)(`option`,{value:`guarded`,children:`Guarded`}),(0,V.jsx)(`option`,{value:`read-only`,children:`Read-only`})]})]})]}),e.mode===`on-demand`&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Keepalive (seconds)`}),(0,V.jsx)(R,{type:`number`,value:e.keepaliveSeconds,onChange:e=>p({keepaliveSeconds:e.target.value}),placeholder:`300`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Seconds to keep agent alive after last activity.`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Initial Prompt`}),(0,V.jsx)(Vd,{value:e.prompt,onChange:e=>p({prompt:e.target.value}),rows:3,placeholder:`Optional initial task or instructions...`}),(0,V.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,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Tags`}),(0,V.jsx)(R,{value:e.tags,onChange:e=>p({tags:e.target.value}),placeholder:`tag1, tag2`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Capabilities`}),(0,V.jsx)(R,{value:e.capabilities,onChange:e=>p({capabilities:e.target.value}),placeholder:`chat, review`})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Provider Args`}),(0,V.jsx)(R,{value:e.providerArgs,onChange:e=>p({providerArgs:e.target.value}),placeholder:`--flag value`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Space-separated args passed to the provider CLI.`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Channel Binding`}),(0,V.jsx)(R,{value:e.channelId,onChange:e=>p({channelId:e.target.value}),placeholder:`Channel ID (optional)`})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Backoff Schedule (seconds)`}),(0,V.jsx)(R,{value:e.backoffSchedule,onChange:e=>p({backoffSchedule:e.target.value}),placeholder:`5, 15, 60, 300`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Backoff Reset After (s)`}),(0,V.jsx)(R,{type:`number`,value:e.backoffResetAfterSeconds,onChange:e=>p({backoffResetAfterSeconds:e.target.value}),placeholder:`600`})]})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)($,{htmlFor:`restartOnUpdate`,children:`Restart on policy update`}),(0,V.jsx)(dl,{id:`restartOnUpdate`,checked:e.restartOnUpdate,onCheckedChange:e=>p({restartOnUpdate:e})})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)($,{htmlFor:`dailyRestart`,children:`Scheduled daily restart`}),(0,V.jsx)(dl,{id:`dailyRestart`,checked:e.scheduledDailyRestart,onCheckedChange:e=>p({scheduledDailyRestart:e})})]})]}),(0,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:()=>p({open:!1}),children:`Cancel`}),(0,V.jsx)(L,{onClick:i,children:d?`Save`:`Create`})]})]})})}function Pf({children:e}){return(0,V.jsxs)(qc,{children:[(0,V.jsx)(Jc,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":`More info`,className:`inline-flex shrink-0 text-muted-foreground transition-colors hover:text-foreground`,children:(0,V.jsx)(lt,{className:`h-3 w-3`})})}),(0,V.jsx)(Yc,{className:`max-w-xs leading-relaxed`,children:e})]})}function Ff({children:e,tip:t,className:n}){return(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)($,{className:n,children:e}),(0,V.jsx)(Pf,{children:t})]})}var If=[`core`,`workspace`,`memory`,`artifacts`,`blackboard`,`subscriptions`,`spawn-lifecycle`,`plans`,`teams`,`project`,`issues`],Lf=[{value:``,label:`Off`},{value:`all`,label:`All`}],Rf=[{value:``,label:`Off`},{value:`all`,label:`All safe settings`}],zf=[{value:``,label:`Instance default`},{value:`direct`,label:`Direct`},{value:`pr`,label:`Pull request`}],Bf=[{value:`any`,label:`Any provider`},...Ot().map(e=>({value:e,label:Tt(e)}))],Vf={relay:`bg-blue-500/10 text-blue-400 border-blue-500/30`,repo:`bg-emerald-500/10 text-emerald-400 border-emerald-500/30`,inline:`bg-amber-500/10 text-amber-400 border-amber-500/30`,provider:`bg-fuchsia-500/10 text-fuchsia-400 border-fuchsia-500/30`,profile:`bg-slate-500/10 text-slate-400 border-slate-500/30`};function Hf(e){return e?e.policy??`all`:``}function Uf(e){if(e)return e===`all`?{policy:`all`}:{}}function Wf({value:e,onChange:t,options:n,disabled:r}){return(0,V.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,V.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function Gf(e,t){return`${e.source}:${e.provider??`any`}:${e.ref}:${t}`}function Kf({source:e}){return(0,V.jsx)(I,{variant:`outline`,className:`text-[10px] ${Vf[e]}`,children:e})}function qf({skills:e,plugins:t,mcp:n,onChangeSkills:r,onChangePlugins:i,onChangeMcp:a,projectMcp:o,projectSkills:s,projectSettings:c,sharedMcp:l,readOnly:u}){let[d,f]=(0,B.useState)([]),[p,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)(!1),[_,v]=(0,B.useState)(null),[y,b]=(0,B.useState)(null),[x,S]=(0,B.useState)(`repo`),[C,ee]=(0,B.useState)(``),[te,ne]=(0,B.useState)(`any`);async function w(e){if(b(e),!p){g(!0),v(null);try{f((await Qe(`GET`,`/provisioning/capabilities`)).capabilities),m(!0)}catch(e){v(At(e))}finally{g(!1)}}}function T(n){let a=C.trim();if(!a)return;let o={source:x,ref:a,enabled:!0,...te===`any`?{}:{provider:te}};n===`skill`?r([...e,o]):i([...t,o]),ee(``),b(null)}function re(n,a){let o=n===`skill`?e:t;if(o.some(e=>e.source===`relay`&&e.ref===a))return;let s=[...o,{source:`relay`,ref:a,enabled:!0}];n===`skill`?r(s):i(s),b(null)}function ie(e){let t=e.variants.find(e=>e.enabled);if(!t)return;let r=t.definition;a({...n,servers:{...n.servers??{},[e.capability.slug]:r?.server??{}}}),b(null)}function ae(t,n){r(e.map((e,r)=>r===t?{...e,...n}:e))}function oe(e,n){i(t.map((t,r)=>r===e?{...t,...n}:t))}function E(e){let t={...n.servers??{}};delete t[e],a({...n,servers:t})}let D=d.filter(e=>e.capability.kind===`skill`),se=d.filter(e=>e.capability.kind===`plugin`),ce=d.filter(e=>e.capability.kind===`mcp`);return(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsx)(Jf,{projectMcp:o,projectSkills:s,projectSettings:c,sharedMcp:l}),(0,V.jsx)(Xf,{title:`Skills from registry`,kind:`skill`,refs:e,readOnly:u,adding:y===`skill`,caps:D,loading:h,fetchError:_,empty:`No skills assigned`,manualRef:C,manualSource:x,manualProvider:te,onAddClick:()=>void w(`skill`),onCancel:()=>b(null),onManualRef:ee,onManualSource:S,onManualProvider:ne,onAddManual:()=>T(`skill`),onAddRelay:e=>re(`skill`,e),onUpdate:ae,onRemove:t=>r(e.filter((e,n)=>n!==t))}),(0,V.jsx)(Xf,{title:`Plugins from registry`,kind:`plugin`,refs:t,readOnly:u,adding:y===`plugin`,caps:se,loading:h,fetchError:_,empty:`No plugins assigned`,manualRef:C,manualSource:x,manualProvider:te,onAddClick:()=>void w(`plugin`),onCancel:()=>b(null),onManualRef:ee,onManualSource:S,onManualProvider:ne,onAddManual:()=>T(`plugin`),onAddRelay:e=>re(`plugin`,e),onUpdate:oe,onRemove:e=>i(t.filter((t,n)=>n!==e))}),(0,V.jsx)($f,{mcpKeys:Object.keys(n.servers??{}),caps:ce,adding:y===`mcp`,loading:h,fetchError:_,readOnly:u,onAddClick:()=>void w(`mcp`),onAddMcp:ie,onCancel:()=>b(null),onRemove:E})]})}function Jf(e){return(0,V.jsxs)(`div`,{className:`rounded border border-border bg-muted/20 p-2`,children:[(0,V.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[`Project and shared injection`,(0,V.jsxs)(Pf,{children:[`Read-only mirror of the Provisioning Policies above — what this profile injects from the project's `,(0,V.jsx)(`code`,{children:`.mcp.json`}),`/`,(0,V.jsx)(`code`,{children:`.claude`}),` and how its MCP is routed.`]})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,V.jsxs)(I,{variant:e.projectMcp?`default`:`outline`,className:`text-[10px]`,children:[`project MCP: `,Hf(e.projectMcp)||`off`]}),(0,V.jsxs)(I,{variant:e.projectSkills?`default`:`outline`,className:`text-[10px]`,children:[`project skills: `,Hf(e.projectSkills)||`off`]}),(0,V.jsxs)(I,{variant:e.projectSettings?`default`:`outline`,className:`text-[10px]`,children:[`project settings: `,Hf(e.projectSettings)||`off`]}),(0,V.jsxs)(I,{variant:e.sharedMcp?`default`:`outline`,className:`text-[10px]`,children:[`shared MCP: `,Hf(e.sharedMcp)||`off`]})]})]})}function Yf(e){return[...new Set(e.variants.map(e=>e.sourceType||`relay`))].join(`, `)}function Xf(e){return(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,V.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:e.title}),!e.readOnly&&(0,V.jsxs)(L,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 gap-1 text-xs`,onClick:e.onAddClick,children:[(0,V.jsx)(de,{className:`h-3 w-3`}),`Add `,e.kind]})]}),e.refs.length===0&&!e.adding&&(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.empty}),e.refs.map((t,n)=>(0,V.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 rounded border border-border bg-card/60 px-2 py-1`,children:[(0,V.jsx)(I,{variant:`outline`,className:`text-[10px] ${e.kind===`skill`?`bg-blue-500/10 text-blue-400 border-blue-500/30`:`bg-violet-500/10 text-violet-400 border-violet-500/30`}`,children:e.kind}),(0,V.jsx)(Kf,{source:t.source}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:t.ref}),t.provider&&t.provider!==`any`&&(0,V.jsx)(I,{variant:`secondary`,className:`text-[10px]`,children:t.provider}),(0,V.jsx)(dl,{checked:t.enabled,onCheckedChange:t=>e.onUpdate(n,{enabled:t}),disabled:e.readOnly,size:`sm`}),!e.readOnly&&(0,V.jsx)(L,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-5 w-5`,onClick:()=>e.onRemove(n),children:(0,V.jsx)(Oe,{className:`h-3 w-3`})})]},Gf(t,n))),e.adding&&(0,V.jsxs)(`div`,{className:`mt-1.5 space-y-2 rounded border border-border bg-card/60 p-2`,children:[e.loading&&(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Loading...`}),e.fetchError&&(0,V.jsx)(`div`,{className:`text-xs text-destructive`,children:e.fetchError}),!e.loading&&e.caps.length===0&&!e.fetchError&&(0,V.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`No `,e.kind,` capabilities in registry`]}),e.caps.length>0&&(0,V.jsx)(`div`,{className:`max-h-44 space-y-0.5 overflow-y-auto rounded border border-border/60 bg-background/40 p-1`,children:e.caps.map(t=>(0,V.jsxs)(`button`,{type:`button`,onClick:()=>e.onAddRelay(t.capability.slug),className:`w-full rounded px-2 py-1 text-left font-mono text-xs hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:[t.capability.slug,t.capability.title?` - ${t.capability.title}`:``,t.variants.length>0&&(0,V.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,Yf(t),`)`]})]},t.capability.id))}),(0,V.jsx)(Zf,{}),(0,V.jsx)(Qf,{...e}),(0,V.jsx)(L,{type:`button`,variant:`ghost`,size:`sm`,className:`mt-1 h-6 text-xs`,onClick:e.onCancel,children:`Cancel`})]})]})}function Zf(){return(0,V.jsxs)(`div`,{className:`flex items-center gap-2 pt-0.5`,children:[(0,V.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,V.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:`or add manually`}),(0,V.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function Qf(e){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-[1fr_1fr] gap-1.5`,children:[(0,V.jsx)(Wf,{value:e.manualSource,onChange:t=>e.onManualSource(t),options:[{value:`repo`,label:`Repo ref`},{value:`inline`,label:`Inline ref`},{value:`provider`,label:`Provider ref`},{value:`relay`,label:`Relay ref`}]}),(0,V.jsx)(Wf,{value:e.manualProvider,onChange:t=>e.onManualProvider(t),options:Bf})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(R,{value:e.manualRef,onChange:t=>e.onManualRef(t.target.value),placeholder:e.kind===`skill`?`.claude/skills/name or registry slug`:`.relay/plugins/name or registry slug`,className:`font-mono text-xs`}),(0,V.jsx)(L,{type:`button`,variant:`outline`,size:`sm`,className:`h-8 text-xs`,onClick:e.onAddManual,children:`Add ref`})]})]})}function $f(e){return(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,V.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`MCP from registry`}),!e.readOnly&&(0,V.jsxs)(L,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 gap-1 text-xs`,onClick:e.onAddClick,children:[(0,V.jsx)(de,{className:`h-3 w-3`}),`Add MCP`]})]}),e.mcpKeys.length===0&&!e.adding&&(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No MCP servers from registry`}),e.mcpKeys.map(t=>(0,V.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 rounded border border-border bg-card/60 px-2 py-1`,children:[(0,V.jsx)(I,{variant:`outline`,className:`border-emerald-500/30 bg-emerald-500/10 text-[10px] text-emerald-400`,children:`mcp`}),(0,V.jsx)(Kf,{source:`profile`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:t}),!e.readOnly&&(0,V.jsx)(L,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-5 w-5`,onClick:()=>e.onRemove(t),children:(0,V.jsx)(Oe,{className:`h-3 w-3`})})]},t)),e.adding&&(0,V.jsxs)(`div`,{className:`mt-1.5 space-y-2 rounded border border-border bg-card/60 p-2`,children:[e.loading&&(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Loading...`}),e.fetchError&&(0,V.jsx)(`div`,{className:`text-xs text-destructive`,children:e.fetchError}),!e.loading&&e.caps.length===0&&!e.fetchError&&(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No MCP capabilities in registry`}),e.caps.length>0&&(0,V.jsx)(`div`,{className:`max-h-44 space-y-0.5 overflow-y-auto rounded border border-border/60 bg-background/40 p-1`,children:e.caps.map(t=>(0,V.jsxs)(`button`,{type:`button`,onClick:()=>e.onAddMcp(t),className:`w-full rounded px-2 py-1 text-left font-mono text-xs hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:[t.capability.slug,t.capability.title?` - ${t.capability.title}`:``,t.variants.length>0&&(0,V.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,Yf(t),`)`]})]},t.capability.id))}),(0,V.jsx)(L,{type:`button`,variant:`ghost`,size:`sm`,className:`mt-1 h-6 text-xs`,onClick:e.onCancel,children:`Cancel`})]})]})}function ep(e){let t=Ot();return e&&e!==`any`&&t.includes(e)?e:t[0]??``}function tp({profile:e}){let[t,n]=(0,B.useState)(()=>ep(e.provider)),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(null);async function l(r=t){if(e.name.trim()){o(!0),c(null);try{let t=await Qe(`GET`,`/agent-profiles/${encodeURIComponent(e.name)}/resolved?provider=${encodeURIComponent(r)}`);n(t.provider),i(t.profile.provisioning??{skills:[],plugins:[],mcpServers:{}})}catch(e){c(At(e)),i(null)}finally{o(!1)}}}let u=e.relay.tools?.groups??[],d=u.length?u.join(`, `):`all groups`,f=Object.keys(r?.mcpServers??{});return(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)($,{children:`Provider`}),(0,V.jsx)(Wf,{value:t,onChange:e=>{n(e),l(e)},options:Ot().map(e=>({value:e,label:Tt(e)}))})]}),(0,V.jsx)(L,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void l(),disabled:a||!e.name.trim(),children:a?`Resolving...`:`Resolve`})]}),s&&(0,V.jsx)(`div`,{className:`rounded border border-destructive/40 bg-destructive/10 px-2 py-1 text-xs text-destructive`,children:s}),(0,V.jsxs)(`div`,{className:`rounded border border-border bg-muted/20 p-2`,children:[(0,V.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:`Relay tool surface`}),(0,V.jsx)(`div`,{className:`mt-1 font-mono text-xs`,children:d})]}),!r&&!s&&(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Resolve this profile to inspect materialized provisioning.`}),r&&(0,V.jsxs)(`div`,{className:`grid gap-2`,children:[(0,V.jsx)(np,{title:`Skills`,values:r.skills.map(e=>e.name),empty:`No resolved skills`}),(0,V.jsx)(np,{title:`Plugins`,values:r.plugins.map(e=>e.name),empty:`No resolved plugins`}),(0,V.jsx)(np,{title:`MCP Servers`,values:f,empty:`No resolved MCP servers`}),(r.skipped?.length??0)>0&&(0,V.jsxs)(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 p-2`,children:[(0,V.jsx)(`div`,{className:`text-xs font-medium text-amber-300`,children:`Skipped`}),(0,V.jsx)(`div`,{className:`mt-1 space-y-1`,children:r.skipped.map(e=>(0,V.jsxs)(`div`,{className:`text-xs`,children:[(0,V.jsxs)(`span`,{className:`font-mono`,children:[e.kind,`:`,e.ref]}),(0,V.jsxs)(`span`,{className:`text-muted-foreground`,children:[` - `,e.detail]})]},`${e.kind}:${e.ref}:${e.reason}`))})]})]})]})}function np({title:e,values:t,empty:n}){return(0,V.jsxs)(`div`,{className:`rounded border border-border bg-card/60 p-2`,children:[(0,V.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:e}),t.length===0?(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n}):(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map((e,t)=>(0,V.jsx)(I,{variant:`outline`,className:`font-mono text-[10px]`,children:e},`${e}:${t}`))})]})}function rp({title:e,children:t,defaultOpen:n=!0}){let[r,i]=(0,B.useState)(n);return(0,V.jsxs)(`div`,{className:`border border-border rounded-md`,children:[(0,V.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,V.jsx)(ct,{className:`h-3.5 w-3.5`}):(0,V.jsx)(D,{className:`h-3.5 w-3.5`}),e]}),r&&(0,V.jsx)(`div`,{className:`space-y-3 border-t border-border px-3 py-3`,children:t})]})}function ip({value:e,onChange:t,options:n,disabled:r}){return(0,V.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,V.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function ap({env:e,onChange:t,disabled:n}){let r=Object.entries(e),[i,a]=(0,B.useState)(``),[o,s]=(0,B.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,V.jsxs)(`div`,{className:`space-y-1.5`,children:[r.map(([e,t])=>(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsxs)(`code`,{className:`min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 text-xs`,children:[e,`=`,t]}),!n&&(0,V.jsx)(L,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-6 w-6 shrink-0`,onClick:()=>l(e),children:(0,V.jsx)(Oe,{className:`h-3 w-3`})})]},e)),!n&&(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(R,{value:i,onChange:e=>a(e.target.value),placeholder:`KEY`,className:`flex-1 text-xs font-mono`}),(0,V.jsx)(R,{value:o,onChange:e=>s(e.target.value),placeholder:`value`,className:`flex-1 text-xs font-mono`,onKeyDown:e=>e.key===`Enter`&&c()}),(0,V.jsx)(L,{type:`button`,variant:`outline`,size:`icon-sm`,className:`h-8 w-8 shrink-0`,onClick:c,children:(0,V.jsx)(de,{className:`h-3 w-3`})})]}),r.length===0&&n&&(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No environment variables`})]})}var op=[{value:`host`,label:`Host — full access, relay-aware`},{value:`minimal`,label:`Minimal — relay disabled, repo-scoped`},{value:`isolated`,label:`Isolated — strict isolation`},{value:`vanilla`,label:`Vanilla — zero host bleed (plugins/skills/hooks/MCP/CLAUDE.md off)`}],sp=[{value:`any`,label:`Any provider`},...Ot().map(e=>({value:e,label:Tt(e)}))],cp=[{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`}],lp=[{value:`host`,label:`Host — full filesystem`},{value:`workspace`,label:`Workspace — working directory tree`},{value:`repo`,label:`Repo — repository root only`}],up=[{value:`allow`,label:`Allow`},{value:`ignore`,label:`Ignore`}],dp=[{value:``,label:`Default`},{value:`open`,label:`Open — allow all`},{value:`guarded`,label:`Guarded — prompt for risky`},{value:`read-only`,label:`Read-only`}],fp={context:`Injects relay's context preamble each turn (memory + situational awareness).`,skills:`Makes the bundled Agent Relay skills available to the agent.`,plugins:`Loads the bundled Agent Relay Claude plugin (session registration, approval hooks).`,statusLine:`Enables the relay status-line probe (quota + context-window reporting).`,mcp:`Master switch for relay's own MCP tools (relay_* — messaging, memory, spawn, etc.). One of three independent MCP sources, alongside Project MCP (the project's .mcp.json) and MCP Mode (the host's ambient MCP).`},pp={context:`Context`,skills:`Skills`,plugins:`Plugins`,statusLine:`Status Line`,mcp:`MCP Tools`};function mp({values:e,onChange:t,disabled:n,placeholder:r}){let[i,a]=(0,B.useState)(``);function o(){let n=i.trim();n&&(t([...e,n]),a(``))}function s(n,r){t(e.map((e,t)=>t===n?r:e))}function c(n){t(e.filter((e,t)=>t!==n))}return(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[e.map((e,t)=>(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(R,{value:e,onChange:e=>s(t,e.target.value),disabled:n,className:`flex-1 text-xs`}),!n&&(0,V.jsx)(L,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-6 w-6 shrink-0`,onClick:()=>c(t),children:(0,V.jsx)(Oe,{className:`h-3 w-3`})})]},`${e}-${t}`)),!n&&(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(R,{value:i,onChange:e=>a(e.target.value),placeholder:r,className:`flex-1 text-xs`,onKeyDown:e=>e.key===`Enter`&&o()}),(0,V.jsx)(L,{type:`button`,variant:`outline`,size:`icon-sm`,className:`h-8 w-8 shrink-0`,onClick:o,children:(0,V.jsx)(de,{className:`h-3 w-3`})})]}),e.length===0&&n&&(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`None`})]})}function hp(){let{open:e,mode:t,profile:n}=j(e=>e.profileModal),r=j(e=>e.closeProfileModal),i=j(e=>e.updateProfileModal),a=j(e=>e.saveProfile),o=t===`view`,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,t){let r=n.relay.tools?.groups??[],i=t?[...new Set([...r,e])]:r.filter(t=>t!==e);u({tools:i.length?{groups:i}:void 0})}function f(e){i({projectMcp:Uf(e)})}function p(e){i({projectSkills:Uf(e)})}function m(e){i({projectSettings:Uf(e)})}function h(e){i({sharedMcp:Uf(e)})}function g(e){i({permissions:{...n.permissions,...e}})}function _(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 v(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 y(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 b=n.providerOptions?.codex&&typeof n.providerOptions.codex==`object`&&!Array.isArray(n.providerOptions.codex)?n.providerOptions.codex:{},x=Number.isSafeInteger(b.toolOutputTokenLimit)?String(b.toolOutputTokenLimit):``;return(0,V.jsx)(of,{open:e,onOpenChange:e=>!e&&r(),children:(0,V.jsxs)(lf,{className:`max-w-2xl max-h-[90vh] overflow-y-auto`,children:[(0,V.jsx)(uf,{children:(0,V.jsxs)(ff,{className:`flex items-center gap-2`,children:[c,n.builtIn&&(0,V.jsx)(I,{variant:`secondary`,className:`text-[10px]`,children:`Built-in`})]})}),(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(rp,{title:`General`,defaultOpen:!0,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Name`}),(0,V.jsx)(R,{value:n.name,onChange:e=>i({name:e.target.value}),placeholder:`my-profile`,disabled:o||t===`edit`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Description`}),(0,V.jsx)(R,{value:n.description||``,onChange:e=>i({description:e.target.value}),placeholder:`What this profile configures`,disabled:o})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(Ff,{tip:`Emoji shown across the dashboard wherever an agent on this profile appears (conversation rows, agent cards, chat header). A single emoji; leave blank for a neutral marker.`,children:`Icon`}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(R,{value:n.icon||``,onChange:e=>i({icon:e.target.value}),placeholder:`🤖`,maxLength:8,disabled:o,className:`w-24 text-center text-base`}),(0,V.jsx)(`span`,{className:`text-2xl leading-none`,"aria-hidden":!0,children:n.icon?.trim()||`•`})]})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Base`}),(0,V.jsx)(ip,{value:n.base,onChange:e=>y(e),options:op,disabled:o})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Provider`}),(0,V.jsx)(ip,{value:n.provider||`any`,onChange:e=>i({provider:e}),options:sp,disabled:o})]})]})]}),(0,V.jsxs)(rp,{title:`Instructions`,defaultOpen:!1,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`System Prompt`}),(0,V.jsx)(Vd,{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,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Append Instructions`}),(0,V.jsx)(mp,{values:n.instructions.append??[],onChange:e=>l({append:e}),disabled:o,placeholder:`Append instruction fragment`})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Repo Instructions`}),(0,V.jsx)(ip,{value:n.instructions.repoInstructions,onChange:e=>l({repoInstructions:e}),options:up,disabled:o})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Global Instructions`}),(0,V.jsx)(ip,{value:n.instructions.globalInstructions,onChange:e=>l({globalInstructions:e}),options:up,disabled:o})]})]})]}),(0,V.jsxs)(rp,{title:`Relay Integration`,defaultOpen:!1,children:[(0,V.jsxs)(`p`,{className:`rounded border border-border bg-muted/20 px-2 py-1.5 text-xs text-muted-foreground`,children:[`MCP comes from three independent sources — relay (`,(0,V.jsx)(`span`,{className:`font-medium text-foreground`,children:`MCP Tools`}),` below), the project (`,(0,V.jsx)(`span`,{className:`font-medium text-foreground`,children:`Project MCP`}),` in Provisioning Policies), and the host (`,(0,V.jsx)(`span`,{className:`font-medium text-foreground`,children:`MCP Mode`}),` in MCP & Hooks). Toggle each separately and mix freely.`]}),(0,V.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[`context`,`skills`,`plugins`,`statusLine`,`mcp`].map(e=>(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsx)(Ff,{tip:fp[e],children:pp[e]}),(0,V.jsx)(dl,{checked:n.relay[e]??!0,onCheckedChange:t=>u({[e]:t}),disabled:o})]},e))}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(Ff,{tip:`Pick which subsets of relay's MCP tools the agent gets. No groups selected = the full relay tool surface.`,children:`Relay Tool Groups`}),(0,V.jsx)(`div`,{className:`mt-1 grid grid-cols-2 gap-1.5`,children:If.map(e=>(0,V.jsxs)(`label`,{className:`flex items-center gap-2 rounded border border-border px-2 py-1 text-xs`,children:[(0,V.jsx)(`input`,{type:`checkbox`,className:`rounded`,checked:(n.relay.tools?.groups??[]).includes(e),onChange:t=>d(e,t.target.checked),disabled:o}),(0,V.jsx)(`span`,{className:`font-mono`,children:e})]},e))}),(0,V.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`No groups selected means full relay MCP tool surface.`})]})]}),(0,V.jsx)(rp,{title:`MCP & Hooks`,defaultOpen:!1,children:(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(Ff,{tip:`The host's ambient MCP servers (your rig's configured MCP). Host = inherit them; None = no host MCP (clean, no bleed). Separate from relay's own MCP and the project's MCP.`,children:`MCP Mode`}),(0,V.jsx)(ip,{value:n.mcp.mode,onChange:e=>i({mcp:{...n.mcp,mode:e}}),options:cp,disabled:o})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(Ff,{tip:`The host's hook configuration. Host = inherit it; None = no host hooks.`,children:`Hooks Mode`}),(0,V.jsx)(ip,{value:n.hooks.mode,onChange:e=>i({hooks:{mode:e}}),options:cp,disabled:o})]})]})}),(0,V.jsx)(rp,{title:`Provisioning Policies`,defaultOpen:!1,children:(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(Ff,{tip:`Injects the MCP servers declared in the spawn directory's project .mcp.json, via relay's controlled config path (survives --strict-mcp-config, no trust modal). All = every declared server. This is the project's MCP source — distinct from relay's MCP Tools and the host's MCP Mode.`,children:`Project MCP`}),(0,V.jsx)(ip,{value:Hf(n.projectMcp),onChange:f,options:Lf,disabled:o})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(Ff,{tip:`Injects skills committed under the project's .claude/skills.`,children:`Project Skills`}),(0,V.jsx)(ip,{value:Hf(n.projectSkills),onChange:p,options:Lf,disabled:o})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(Ff,{tip:`Injects the project's .claude/settings.json (permission/security keys stripped).`,children:`Project Settings`}),(0,V.jsx)(ip,{value:Hf(n.projectSettings),onChange:m,options:Rf,disabled:o})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(Ff,{tip:`Routes the agent's non-identity MCP through one shared orchestrator listener so the MCP session survives restarts and keeps correct worktree-cwd routing. A transport choice, not a source selector.`,children:`Shared MCP`}),(0,V.jsx)(ip,{value:Hf(n.sharedMcp),onChange:h,options:Lf,disabled:o})]}),(0,V.jsxs)(`div`,{className:`col-span-2`,children:[(0,V.jsx)(Ff,{tip:`How the agent's isolated branch lands: Direct (rebase/FF), Pull request, or the instance default.`,children:`Landing Strategy`}),(0,V.jsx)(ip,{value:n.landingStrategy??``,onChange:e=>i({landingStrategy:e||void 0}),options:zf,disabled:o})]})]})}),(0,V.jsx)(rp,{title:`Permissions`,defaultOpen:!1,children:(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Approval Mode`}),(0,V.jsx)(ip,{value:n.permissions.mode||``,onChange:e=>g({mode:e||void 0}),options:dp,disabled:o})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Filesystem Scope`}),(0,V.jsx)(ip,{value:n.permissions.filesystem,onChange:e=>g({filesystem:e}),options:lp,disabled:o})]})]})}),(0,V.jsx)(rp,{title:`Spawning`,defaultOpen:!1,children:(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Spawn Quota`}),(0,V.jsx)(R,{type:`number`,min:0,max:100,step:1,value:n.maxSpawnedAgents===void 0?``:String(n.maxSpawnedAgents),onChange:e=>v(e.target.value),placeholder:`0`,disabled:o}),(0,V.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,V.jsx)(rp,{title:`Environment Variables`,defaultOpen:!1,children:(0,V.jsx)(ap,{env:n.env||{},onChange:e=>i({env:e}),disabled:o})}),(0,V.jsx)(rp,{title:`Registry Capabilities`,defaultOpen:!1,children:(0,V.jsx)(qf,{skills:n.skills??[],plugins:n.plugins??[],mcp:n.mcp,onChangeSkills:e=>i({skills:e}),onChangePlugins:e=>i({plugins:e}),onChangeMcp:e=>i({mcp:e}),projectMcp:n.projectMcp,projectSkills:n.projectSkills,projectSettings:n.projectSettings,sharedMcp:n.sharedMcp,readOnly:o})}),(0,V.jsx)(rp,{title:`Resolved Provisioning`,defaultOpen:t===`view`,children:(0,V.jsx)(tp,{profile:n})}),(0,V.jsxs)(rp,{title:`Provider Options`,defaultOpen:!1,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Codex Tool Output Limit`}),(0,V.jsx)(R,{type:`number`,min:1e3,max:2e5,value:x,onChange:e=>_(e.target.value),placeholder:`12000`,disabled:o})]}),(0,V.jsx)(Vd,{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,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:r,children:`Cancel`}),(0,V.jsx)(L,{onClick:a,children:s?`Create`:`Save`})]})]})})}function gp(){let e=j(e=>e.commandPaletteOpen),t=j(e=>e.commandQuery),n=j(e=>e.set),r=j(e=>e.closeCommandPalette),i=j(e=>e.runCommand),a=ll(),o=(0,B.useRef)(null);return(0,B.useEffect)(()=>{e&&setTimeout(()=>o.current?.focus(),50)},[e]),e?(0,V.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,onClick:e=>{e.target===e.currentTarget&&r()},children:[(0,V.jsx)(`div`,{className:`fixed inset-0 bg-black/60`}),(0,V.jsxs)(`div`,{className:`relative w-full max-w-lg bg-card border border-border rounded-xl shadow-2xl overflow-hidden`,children:[(0,V.jsx)(`div`,{className:`p-3 border-b border-border`,children:(0,V.jsx)(R,{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,V.jsxs)(`div`,{className:`max-h-80 overflow-y-auto p-2`,children:[a.map(e=>(0,V.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,V.jsx)(nt[e.icon]||D,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-sm`,children:e.title}),e.subtitle&&(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:e.subtitle})]})]},e.id)),a.length===0&&(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`No matching commands.`})]})]})]}):null}function _p(){let e=j(e=>e.set),t=j(e=>e.connected);return(0,V.jsxs)(`div`,{className:`xl:hidden shrink-0 sticky top-0 z-30 bg-card border-b border-border px-4 h-[var(--header-h)] flex items-center gap-3`,children:[(0,V.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,V.jsx)(Ge,{className:`w-5 h-5`})}),(0,V.jsx)(oe,{className:`w-4 h-4 text-primary`}),(0,V.jsx)(`span`,{className:`font-bold text-sm`,children:`Agent Relay`}),(0,V.jsx)(`span`,{className:`ml-auto w-2 h-2 rounded-full ${t?`bg-emerald-500`:`bg-red-500 animate-pulse`}`})]})}function vp(e){return e===`five_hour`?`5h burst`:e===`seven_day`?`7-day`:e===`seven_day_sonnet`?`7-day Sonnet`:e===`seven_day_opus`?`7-day Opus`:e===`primary`?`Primary`:e===`secondary`?`Secondary`:e}function yp(e,t){if(!t)return``;let n=Math.max(0,(t-e)/1e3);if(n<60)return`${Math.floor(n)}s`;if(n<3600)return`${Math.floor(n/60)}m`;if(n<86400){let e=Math.floor(n/3600),t=Math.round(n%3600/60);return t===60?`${e+1}h`:t>0?`${e}h ${t}m`:`${e}h`}let r=Math.floor(n/86400),i=Math.round(n%86400/3600);return i===24?`${r+1}d`:i>0?`${r}d ${i}h`:`${r}d`}var bp=`agent-relay:quota-widget`,xp=300*1e3,Sp=8;function Cp(e){return!e.quota&&e.lastError?.type===`unavailable`}function wp(e,t){let n=t===`5h`?[`five_hour`,`primary`]:[`seven_day`,`secondary`];return e.quota?.windows.find(e=>n.includes(e.name))}function Tp(e,t){if(!t)return``;let n=Math.max(0,(t-e)/1e3);return n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.round(n/3600)}h`:`${(n/86400).toFixed(1).replace(/\.0$/,``)}d`}function Ep({record:e,now:t,advisory:n}){let r=(0,V.jsx)(Tu,{provider:e.provider,className:`w-3.5 h-3.5`});if(Cp(e))return(0,V.jsxs)(`span`,{className:`flex items-center gap-1 shrink-0 text-muted-foreground`,children:[r,(0,V.jsx)(`span`,{className:`italic`,children:`unavailable`})]});if(!e.quota){let n=e.lastAttemptAt?M(t,e.lastAttemptAt):``,i=e.lastError?.retryAfterMs,a=i==null?null:Math.ceil(Math.max(0,(e.lastAttemptAt+i-t)/1e3));return(0,V.jsxs)(`span`,{className:`flex items-center gap-1 shrink-0 text-muted-foreground`,children:[r,n&&(0,V.jsx)(`span`,{children:n}),a!=null&&a>0&&(0,V.jsxs)(`span`,{className:`text-amber-400/70`,children:[`~`,a,`s`]})]})}let i=wp(e,`5h`),a=wp(e,`7d`);function o(e){if(!e)return null;let n=Math.round(e.utilization*100),r=Tp(t,e.resetsAt);return(0,V.jsxs)(`span`,{className:`tabular-nums`,children:[n,`%`,r?`/${r}`:``]})}let s=(e.stale||e.lastError)&&e.lastAttemptAt?M(t,e.lastAttemptAt):``;return(0,V.jsxs)(`span`,{className:`flex items-center gap-1.5 shrink-0 text-foreground/70`,children:[r,(0,V.jsx)(Mp,{advisory:n}),o(i),o(a),s&&(0,V.jsx)(`span`,{className:`text-muted-foreground/70`,children:s})]})}function Dp(){try{let e=localStorage.getItem(bp);return{open:!0,pinned:!1,...e?JSON.parse(e):{}}}catch{return{open:!0,pinned:!1}}}function Op(e){try{localStorage.setItem(bp,JSON.stringify(e))}catch{}}function kp(){let[{open:e,pinned:t},n]=(0,B.useState)(Dp),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(`loading`),d=yt(),f=j(e=>e.connected);(0,B.useEffect)(()=>{if(!f)return;let e=!1;async function t(){try{let[t,n,r]=await Promise.all([Qe(`GET`,`/provider-quotas`),Qe(`GET`,`/providers/quota-config`).catch(()=>null),Qe(`GET`,`/provider-quotas/advisory`).catch(()=>null)]);e||(i(t),o(n),c(r),u(`ok`))}catch{e||u(`error`)}}t();let n=setInterval(()=>void t(),xp);return()=>{e=!0,clearInterval(n)}},[f,j(e=>e.quotaSeq)]);let p=e||t,m=(r?.quotas??[]).filter(e=>a?.[e.provider]?.showInWidget!==!1),h=m.some(e=>e.stale&&!Cp(e)),g=m.some(e=>e.lastError&&!Cp(e));function _(){if(t)return;let r={open:!e,pinned:t};n(r),Op(r)}function v(){let r=t?{open:e,pinned:!1}:{open:!0,pinned:!0};n(r),Op(r)}return(0,V.jsxs)(`div`,{className:`shrink-0 border-b border-border`,children:[(0,V.jsxs)(`div`,{className:`w-full flex items-center gap-2 px-4 py-2 text-xs hover:bg-muted/30 transition-colors`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:_,"aria-expanded":p,className:`min-w-0 flex flex-1 items-center gap-2 text-left`,children:[(0,V.jsx)(D,{className:`w-3.5 h-3.5 shrink-0 text-muted-foreground transition-transform ${p?`rotate-90`:``}`}),(0,V.jsx)(`span`,{className:`font-semibold text-foreground/80 shrink-0 ${p?``:`hidden sm:inline`}`,children:`Provider Quotas`}),l===`loading`&&(0,V.jsx)(A,{className:`w-3 h-3 text-muted-foreground animate-spin`}),l===`error`&&(0,V.jsx)(`span`,{className:`text-amber-400 text-[10px]`,children:`● unavailable`}),!p&&l===`ok`&&m.length>0&&(0,V.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-0.5 text-[10px]`,children:m.map(e=>(0,V.jsx)(Ep,{record:e,now:d,advisory:s?.advisories[e.provider]},`${e.provider}:${e.accountKey}`))}),p&&h&&(0,V.jsx)(`span`,{className:`text-amber-400 text-[10px]`,children:`● stale`}),p&&g&&(0,V.jsx)(`span`,{className:`text-red-400 text-[10px]`,children:`● error`})]}),(0,V.jsx)(`button`,{type:`button`,onClick:v,"aria-pressed":t,title:t?`Unpin`:`Pin always-on`,className:`p-0.5 rounded hover:bg-muted transition-colors ${t?`text-primary`:`text-muted-foreground/50 hover:text-muted-foreground`}`,children:(0,V.jsx)(fe,{className:`w-3 h-3`})})]}),p&&(0,V.jsxs)(`div`,{className:`px-4 py-3`,children:[l===`loading`&&(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-1.5`,children:[(0,V.jsx)(A,{className:`w-3 h-3 animate-spin`}),`Loading quota data…`]}),l===`error`&&(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Quota data unavailable — check that you are authenticated and the server is reachable.`}),l===`ok`&&r!==null&&m.length===0&&(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No quota data yet — waiting for runner to report.`}),l===`ok`&&r!==null&&m.length>0&&(0,V.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3`,children:m.map(e=>{let t=a?.[e.provider],n={enabled:t?.sparklineEnabled??!0,rangeHours:t?.sparklineRangeHours??Sp};return(0,V.jsx)(Ip,{record:e,now:d,advisory:s?.advisories[e.provider],sparklineCfg:n},`${e.provider}:${e.accountKey}`)})})]})]})}var Ap={prefer:{icon:ut,badge:`text-emerald-400 bg-emerald-500/10 border-emerald-500/20`,dot:`bg-emerald-400`},caution:{icon:s,badge:`text-amber-400 bg-amber-500/10 border-amber-500/20`,dot:`bg-amber-400`},"avoid-large":{icon:s,badge:`text-orange-400 bg-orange-500/10 border-orange-500/20`,dot:`bg-orange-400`},"hard-avoid":{icon:je,badge:`text-red-400 bg-red-500/10 border-red-500/20`,dot:`bg-red-400`}};function jp({advisory:e}){if(!e)return null;if(e.blockedNow)return(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[9px] font-medium text-red-400 bg-red-500/10 border border-red-500/20 rounded px-1 py-0.5 shrink-0`,children:[(0,V.jsx)(je,{className:`w-2.5 h-2.5`}),`at capacity`]});let t=e.quotaPenaltyBand;if(t===`normal`)return null;let n=Ap[t],r=n.icon;return(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[9px] font-medium ${n.badge} border rounded px-1 py-0.5 shrink-0`,children:[(0,V.jsx)(r,{className:`w-2.5 h-2.5`}),t]})}function Mp({advisory:e}){if(!e)return null;if(e.blockedNow)return(0,V.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-red-500 shrink-0`,title:`at capacity`});let t=e.quotaPenaltyBand;return t===`normal`?null:(0,V.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${Ap[t].dot} shrink-0`,title:t})}function Np(e,t){if(!e||e.confidence===`low`||e.burnRatio===null)return null;let n=e.burnRatio.toFixed(1);return!e.earlyWallMs||e.earlyWallMs<=0?`${n}× rate`:`${n}× · ~${yp(t,t+e.earlyWallMs)} before reset`}function Pp({burnWindow:e,now:t}){if(!e)return null;if(e.confidence===`low`||e.burnRatio===null)return(0,V.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-muted-foreground/50`,children:[(0,V.jsx)(Se,{className:`w-2.5 h-2.5 shrink-0`}),(0,V.jsx)(`span`,{className:`italic`,children:`building burn history…`})]});let n=Np(e,t);return n?(0,V.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-muted-foreground/70 tabular-nums`,children:[(0,V.jsx)(s,{className:`w-2.5 h-2.5 shrink-0`}),(0,V.jsx)(`span`,{children:n})]}):null}function Fp({provider:e,windowName:t,rangeHours:n}){let[r,i]=(0,B.useState)([]);yt(),(0,B.useEffect)(()=>{let r=!1,a=Date.now()-n*36e5;return Qe(`GET`,`/provider-quotas/history?provider=${encodeURIComponent(e)}&sinceMs=${a}&limit=500`).then(e=>{r||i(e.filter(e=>!!e.quota).map(e=>{let n=e.quota.windows.find(e=>e.name===t);return n?{t:e.capturedAt,v:n.utilization}:null}).filter(Boolean))}).catch(()=>{}),()=>{r=!0}},[e,t,n]);let a=(0,B.useMemo)(()=>{if(r.length<2)return null;let e=r[0].t,t=r[r.length-1].t-e||1;return r.map(n=>{let r=1+(n.t-e)/t*118,i=1+(1-n.v)*22;return`${r.toFixed(1)},${i.toFixed(1)}`}).join(` `)},[r]);if(!a)return null;let o=r.length>0?Math.round(r[r.length-1].v*100):0;return(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(`svg`,{width:120,height:24,viewBox:`0 0 120 24`,className:`shrink-0`,children:(0,V.jsx)(`polyline`,{points:a,fill:`none`,stroke:o>=90?`#ef4444`:o>=70?`#f59e0b`:`#10b981`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,opacity:.8})}),(0,V.jsxs)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums`,children:[n,`h`]})]})}function Ip({record:e,now:t,advisory:n,sparklineCfg:r}){let{provider:i,accountKey:a,quota:o,stale:s,lastError:c,lastUpdatedAt:l,lastAttemptAt:u}=e;if(Cp(e))return(0,V.jsxs)(`div`,{className:`rounded border border-border bg-muted/20 p-3 space-y-1.5 opacity-70`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,V.jsx)(Tu,{provider:i,className:`w-3.5 h-3.5 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground bg-muted border border-border rounded px-1 py-0.5 shrink-0`,children:`unavailable`})]}),(0,V.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[`Quota unavailable — `,c?.message??`no readable credentials`]})]});let d=c?.retryAfterMs,f=d==null?null:Math.max(0,u+d-t),p=f==null?null:Math.ceil(f/1e3),m=(s||!!c)&&u>0;return(0,V.jsxs)(`div`,{className:`rounded border ${c?`border-red-500/30`:s?`border-amber-500/30`:`border-border`} bg-card p-3 space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,V.jsx)(Tu,{provider:i,className:`w-3.5 h-3.5`}),(0,V.jsx)(`span`,{className:`text-[10px] text-muted-foreground font-mono truncate`,children:a})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,V.jsx)(jp,{advisory:n}),s&&(0,V.jsx)(`span`,{className:`text-[9px] font-medium text-amber-400 bg-amber-500/10 border border-amber-500/20 rounded px-1 py-0.5`,children:`stale`}),c&&(0,V.jsx)(`span`,{className:`text-[9px] font-medium text-red-400 bg-red-500/10 border border-red-500/20 rounded px-1 py-0.5`,title:c.message,children:c.type===`rate_limited`?`429`:`err`})]})]}),o?(0,V.jsx)(`div`,{className:`space-y-1.5`,children:o.windows.map(n=>{let i=Math.round(n.utilization*100),a=i>=90?`bg-red-500`:i>=70?`bg-amber-500`:`bg-emerald-500`,o=n.resetsAt?yp(t,n.resetsAt):``,s=e.burn?.windows.find(e=>e.name===n.name);return(0,V.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,V.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground`,children:[(0,V.jsx)(`span`,{children:vp(n.name)}),(0,V.jsxs)(`span`,{children:[i,`%`,o?` · resets in ${o}`:``]})]}),(0,V.jsx)(`div`,{className:`h-1.5 rounded-full bg-muted overflow-hidden`,children:(0,V.jsx)(`div`,{className:`h-full ${a} transition-all duration-500`,style:{width:`${Math.max(0,Math.min(100,i))}%`}})}),(0,V.jsx)(Pp,{burnWindow:s,now:t}),r?.enabled&&(0,V.jsx)(Fp,{provider:e.provider,windowName:n.name,rangeHours:r.rangeHours})]},n.name)})}):(0,V.jsx)(`p`,{className:`text-[10px] text-muted-foreground italic`,children:c?c.message:`No quota data`}),(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-2 text-[10px] text-muted-foreground/60`,children:[(0,V.jsxs)(`div`,{className:`space-y-0.5 min-w-0`,children:[m&&(0,V.jsxs)(`div`,{children:[`Attempted `,M(t,u)]}),(0,V.jsx)(`div`,{children:l?`Updated ${M(t,l)}`:`Never updated`})]}),p!=null&&(0,V.jsx)(`span`,{className:`text-amber-400/70 shrink-0 mt-0.5`,children:p>0?`retry in ~${p>60?`${Math.ceil(p/60)}m`:`${p}s`}`:`retrying…`})]})]})}function Lp(e){return(0,B.lazy)(()=>er(e))}var Rp=Lp(()=>z(()=>import(`./overview-CXc2vQRQ.js`).then(e=>({default:e.OverviewView})),__vite__mapDeps([16,1,6,8,9,10,17,12,18]),import.meta.url)),zp=Lp(()=>z(()=>import(`./chat-yiXwg4kh.js`).then(e=>({default:e.ChatView})),__vite__mapDeps([19,1,6,20,8,9,10,21,22,23,24,25,11,12,17,26,13]),import.meta.url)),Bp=Lp(()=>z(()=>import(`./agents-CuEoaCLs.js`).then(e=>({default:e.AgentsView})),__vite__mapDeps([27,1,28,29,6,12,30,20,31,32,33,34,35,8,9,10,24,25,11,17,18]),import.meta.url)),Vp=Lp(()=>z(()=>import(`./managed-agents-pLThsagU.js`).then(e=>({default:e.ManagedAgentsView})),__vite__mapDeps([36,1,6,8,9,10,25,11,12,17]),import.meta.url)),Hp=Lp(()=>z(()=>import(`./teams-CQZ6a8A5.js`).then(e=>({default:e.TeamsView})),__vite__mapDeps([37,1,38,28,29,6,12,30,20,31,32,39,40,41,33,35,42,8,9,10,23,17,11,18,26]),import.meta.url)),Up=Lp(()=>z(()=>import(`./agent-profiles-v4CcpJWT.js`).then(e=>({default:e.AgentProfilesView})),__vite__mapDeps([43,1,6,8,9,10,17,12,11]),import.meta.url)),Wp=Lp(()=>z(()=>import(`./orchestrators-C2kC07Qm.js`).then(e=>({default:e.OrchestratorsView})),__vite__mapDeps([44,6,1,8,9,10,17,12,11,18]),import.meta.url)),Gp=Lp(()=>z(()=>import(`./workspaces-gPEVu-L5.js`).then(e=>({default:e.WorkspacesView})),__vite__mapDeps([45,1,6,8,9,10,25,11,12,17,18]),import.meta.url)),Kp=Lp(()=>z(()=>import(`./channels-Vl9YHoGK.js`).then(e=>({default:e.ChannelsView})),__vite__mapDeps([46,6,1,8,9,10,17,12,11,18]),import.meta.url)),qp=Lp(()=>z(()=>import(`./connectors-C33KsouZ.js`).then(e=>({default:e.ConnectorsView})),__vite__mapDeps([47,6,1,8,9,10,17,12,11,18]),import.meta.url)),Jp=Lp(()=>z(()=>import(`./integrations-DR3pboEG.js`).then(e=>({default:e.IntegrationsView})),__vite__mapDeps([48,6,1,8,9,10,17,12,11,18]),import.meta.url)),Yp=Lp(()=>z(()=>import(`./security-DcNNqoA4.js`).then(e=>({default:e.SecurityView})),__vite__mapDeps([49,1,6,25,11,12,17,18,26]),import.meta.url)),Xp=Lp(()=>z(()=>import(`./memory-CSzdP2o2.js`).then(e=>({default:e.MemoryView})),__vite__mapDeps([50,1,6,8,9,10,17,12,11,18,26]),import.meta.url)),Zp=Lp(()=>z(()=>import(`./activity-G-s2N4eU.js`).then(e=>({default:e.ActivityView})),__vite__mapDeps([51,1,6,8,9,10,21,22,17,12,11,18]),import.meta.url)),Qp=Lp(()=>z(()=>import(`./pairs-DLfFKNEf.js`).then(e=>({default:e.PairsView})),__vite__mapDeps([52,6,1,8,9,10,17,12,11,18]),import.meta.url)),$p=Lp(()=>z(()=>import(`./messages-1ton_JT5.js`).then(e=>({default:e.MessagesView})),__vite__mapDeps([53,1,6,8,9,10,17,12,11,18]),import.meta.url)),em=Lp(()=>z(()=>import(`./work-queue-IfxOcGe5.js`).then(e=>({default:e.WorkQueueView})),__vite__mapDeps([54,6,1,8,9,10,17,12,11,18]),import.meta.url)),tm=Lp(()=>z(()=>import(`./tasks-DuH_JQJM.js`).then(e=>({default:e.TasksView})),__vite__mapDeps([55,6,1,8,9,10,17,12,11,18]),import.meta.url)),nm=Lp(()=>z(()=>import(`./automation-wXSbBEei.js`).then(e=>({default:e.AutomationView})),__vite__mapDeps([56,1,6,8,9,10,17,12,11,18,26]),import.meta.url)),rm=Lp(()=>z(()=>import(`./analytics-Dvg0J33b.js`).then(e=>({default:e.AnalyticsView})),__vite__mapDeps([57,1,6,8,9,10,18,58]),import.meta.url)),im=Lp(()=>z(()=>import(`./insights-C5Ft13cw.js`).then(e=>({default:e.InsightsView})),__vite__mapDeps([59,1,6,17,12,11,18,26,9,10]),import.meta.url)),am=Lp(()=>z(()=>import(`./projects-TM20JuNI.js`).then(e=>({default:e.ProjectsView})),__vite__mapDeps([60,1,6,8,9,10,25,11,12,17,18]),import.meta.url)),om=Lp(()=>z(()=>import(`./prompt-settings-DWYbD9TA.js`).then(e=>({default:e.PromptSettingsView})),__vite__mapDeps([61,1,6,17,12,11,18,9,10]),import.meta.url)),sm=Lp(()=>z(()=>import(`./registry-BWRVKBhU.js`).then(e=>({default:e.RegistryView})),__vite__mapDeps([62,1,6,17,12,11,18,26,10]),import.meta.url)),cm=Lp(()=>z(()=>import(`./maintenance-Ddl6-McO.js`).then(e=>({default:e.MaintenanceView})),__vite__mapDeps([63,1,6,8,9,10,17,12,11]),import.meta.url)),lm=Lp(()=>z(()=>import(`./settings-C9-w25pF.js`).then(e=>({default:e.SettingsView})),__vite__mapDeps([64,1,38,28,29,6,12,30,20,31,32,39,40,41,33,35,42,8,9,10,22,17,11,18,26,58]),import.meta.url)),um=class extends B.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary]`,e.message,`
|
|
21
|
+
`)})]})]})}function Ld(e){if(!Ct(e)||typeof e.lastError!=`string`)return null;let t=Ct(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 Rd({className:e,children:t,...n}){return(0,V.jsxs)(ys,{"data-slot":`scroll-area`,className:k(`relative`,e),...n,children:[(0,V.jsx)(bs,{"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,V.jsx)(zd,{}),(0,V.jsx)(xs,{})]})}function zd({className:e,orientation:t=`vertical`,...n}){return(0,V.jsx)(qo,{"data-slot":`scroll-area-scrollbar`,"data-orientation":t,orientation:t,className:k(`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,V.jsx)(is,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}function Bd(){let e=j(e=>e.channelDetailOpen),t=j(e=>e.channelDetailId),n=j(e=>e.channels),r=j(e=>e.messages),i=j(e=>e.agentsById),a=yt(),o=j(e=>e.closeChannelDetail),s=n.find(e=>e.id===t)||null,c=Gt(s),l=(0,B.useMemo)(()=>s?r.filter(e=>Xt(e,s)).sort((e,t)=>t.id-e.id).slice(0,8):[],[r,s]);return(0,V.jsx)(cu,{open:e,onOpenChange:e=>!e&&o(),children:(0,V.jsxs)(fu,{className:`w-full max-w-[100dvw] sm:max-w-md lg:max-w-lg p-0`,children:[(0,V.jsx)(pu,{className:`shrink-0 p-4 border-b border-border`,children:(0,V.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,V.jsx)(I,{className:It(c.tone),children:c.label}),(0,V.jsx)(mu,{className:`text-base truncate`,children:s?.name||`Channel`})]})}),(0,V.jsx)(Rd,{className:`flex-1 min-h-0`,children:(0,V.jsxs)(`div`,{className:`p-4 space-y-4`,children:[s&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Route`}),(0,V.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,V.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Type`}),(0,V.jsx)(`span`,{className:`truncate`,children:s.type})]}),(0,V.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Direction`}),(0,V.jsx)(`span`,{className:`truncate`,children:s.direction})]}),s.target&&(0,V.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Target`}),(0,V.jsx)(`span`,{className:`truncate`,children:s.target})]}),(0,V.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Agent`}),(0,V.jsx)(`span`,{className:`truncate`,children:s.agentId})]}),(0,V.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Transport`}),(0,V.jsx)(`span`,{className:`truncate`,children:s.transport})]}),(0,V.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Last seen`}),(0,V.jsx)(`span`,{className:`shrink-0`,children:M(a,s.lastSeen)})]})]})]}),Ut(s.capabilities).length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Capabilities`}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Ut(s.capabilities).map(e=>(0,V.jsx)(I,{variant:`secondary`,className:`text-[10px]`,children:e},e))})]})]}),s.meta&&Object.keys(s.meta).length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Metadata`}),(0,V.jsx)(`div`,{className:`space-y-1 text-sm`,children:Object.entries(s.meta).map(([e,t])=>(0,V.jsxs)(`div`,{className:`flex justify-between gap-2 min-w-0`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e}),(0,V.jsx)(`span`,{className:`truncate`,children:String(t)})]},e))})]})]})]}),l.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Recent Messages`}),(0,V.jsx)(`div`,{className:`space-y-2`,children:l.map(e=>(0,V.jsxs)(`div`,{className:`rounded border border-border p-2 text-xs space-y-0.5 min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground min-w-0`,children:[(0,V.jsx)(`span`,{className:`font-medium text-foreground truncate shrink-0 max-w-[40%]`,children:qt(e.from,i)}),(0,V.jsx)(`span`,{className:`shrink-0`,children:`→`}),(0,V.jsx)(`span`,{className:`truncate max-w-[40%]`,children:qt(e.to,i)}),(0,V.jsxs)(`span`,{className:`ml-auto shrink-0 text-[10px]`,children:[(0,V.jsxs)(`span`,{className:`opacity-40 mr-1`,children:[`#`,e.id]}),M(a,e.createdAt)]})]}),(0,V.jsx)(`div`,{className:`text-foreground whitespace-pre-wrap break-words line-clamp-3`,children:Zt(e)})]},e.id))})]})]})]})})]})})}function Vd({className:e,...t}){return(0,V.jsx)(`textarea`,{"data-slot":`textarea`,className:k(`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 $({className:e,...t}){return(0,V.jsx)(Io,{"data-slot":`label`,className:k(`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})}var Hd=(0,B.lazy)(()=>z(()=>import(`./formatted-body-impl-CBHoD82a.js`).then(e=>({default:e.FormattedBody})),__vite__mapDeps([15,1,5,3,6,8,9,10]),import.meta.url));function Ud(e){return(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(`span`,{className:e.className,children:e.text}),children:(0,V.jsx)(Hd,{...e})})}var Wd={none:`None`,uncommitted:`Uncommitted`,"committed-on-branch":`On Branch`,"landed-on-main":`Landed`,deploying:`Deploying`,deployed:`Deployed`},Gd={open:`bg-blue-500/10 text-blue-400 border-blue-500/20`,claimed:`bg-purple-500/10 text-purple-300 border-purple-500/20`,in_progress:`bg-purple-500/10 text-purple-400 border-purple-500/20`,blocked:`bg-yellow-500/10 text-yellow-400 border-yellow-500/20`,orphaned:`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`,done:`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`,failed:`bg-red-500/10 text-red-400 border-red-500/20`,canceled:`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`},Kd={none:`bg-zinc-500/10 text-zinc-400`,uncommitted:`bg-yellow-500/10 text-yellow-400`,"committed-on-branch":`bg-blue-500/10 text-blue-400`,"landed-on-main":`bg-emerald-500/10 text-emerald-400`,deploying:`bg-purple-500/10 text-purple-400`,deployed:`bg-teal-500/10 text-teal-400`};function qd(e){let t=e.dispatch;return{title:e.title??``,intent:e.intent??``,latestSteer:e.latestSteer??``,doneWhen:e.doneWhen??``,teamId:e.teamId??``,dispatchComplexity:t?.complexity??``,dispatchType:t?.type??``,dispatchFootprint:t?.contextFootprint??``,dispatchCriticality:t?.criticality??``}}function Jd(){let e=yt(),t=j(e=>e.taskDetailOpen),n=j(e=>e.taskDetailId),r=j(e=>e.taskDetailById),i=j(e=>e.taskMemoryById),a=j(e=>e.taskHistoryById),o=j(e=>e.taskDispatchResultById),s=j(e=>e.taskDispatchLoadingId),c=j(e=>e.agentsById),l=j(e=>e.providerCatalog),u=j(e=>e.closeTaskDetail),d=j(e=>e.doEditTask),f=j(e=>e.doDispatchTask),p=j(e=>e.doSpawnWithTask),m=l.map(e=>e.provider),[g,_]=(0,B.useState)(!1),[v,y]=(0,B.useState)(null),[b,x]=(0,B.useState)(``),[S,C]=(0,B.useState)(``),[ee,te]=(0,B.useState)(``),w=n==null?null:r[n]??null,T=n==null?null:i[n]??null,re=n==null?[]:a[n]??[],ie=n==null?null:o[n]??null,ae=n!=null&&s===n,oe=w?Gd[w.status]??`bg-zinc-500/10 text-zinc-400`:``,E=w?.deliverableStage?Kd[w.deliverableStage]??`bg-zinc-500/10 text-zinc-400`:``;function D(e){e||(u(),_(!1),y(null))}function se(){w&&(y(qd(w)),_(!0))}function ce(){_(!1),y(null)}async function le(){if(!w||!v)return;let e={};v.dispatchComplexity&&(e.complexity=v.dispatchComplexity),v.dispatchType&&(e.type=v.dispatchType),v.dispatchFootprint&&(e.contextFootprint=v.dispatchFootprint),v.dispatchCriticality&&(e.criticality=v.dispatchCriticality);let t={...v.title===w.title?{}:{title:v.title},...v.intent===(w.intent??``)?{}:{intent:v.intent},...v.latestSteer===(w.latestSteer??``)?{}:{latestSteer:v.latestSteer},...v.doneWhen===(w.doneWhen??``)?{}:{doneWhen:v.doneWhen},...v.teamId===(w.teamId??``)?{}:{teamId:v.teamId},...Object.keys(e).length||w.dispatch?{dispatch:Object.keys(e).length?e:null}:{}};if(!Object.keys(t).length){ce();return}await d(w.id,t),_(!1),y(null)}function ue(){if(!w)return;let e={};b&&(e.provider=b),S&&(e.model=S),ee&&(e.effort=ee),f(w.id,Object.keys(e).length?e:void 0)}return(0,V.jsx)(cu,{open:t,onOpenChange:D,children:(0,V.jsxs)(fu,{className:`w-full max-w-[100dvw] sm:max-w-lg lg:max-w-xl p-0 flex flex-col`,showCloseButton:!1,children:[(0,V.jsx)(pu,{className:`shrink-0 p-4 border-b border-border`,children:(0,V.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`div`,{className:`flex items-center gap-2 flex-wrap mb-1`,children:w&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(I,{variant:`outline`,className:`text-xs border ${oe}`,children:w.status}),w.deliverableStage&&(0,V.jsx)(I,{variant:`secondary`,className:`text-xs ${E}`,children:Wd[w.deliverableStage]??w.deliverableStage}),(0,V.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`T`,w.id]})]})}),(0,V.jsx)(mu,{className:`text-base leading-snug`,children:w?.title??`Task`})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[w&&!g&&(0,V.jsx)(L,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,onClick:se,title:`Edit task`,children:(0,V.jsx)(h,{className:`w-3.5 h-3.5`})}),(0,V.jsx)(lu,{asChild:!0,children:(0,V.jsxs)(L,{size:`icon-sm`,variant:`ghost`,title:`Close`,children:[(0,V.jsx)(ye,{className:`w-4 h-4`}),(0,V.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}),(0,V.jsx)(Rd,{className:`flex-1 min-h-0 overflow-x-hidden`,children:(0,V.jsxs)(`div`,{className:`p-4 space-y-5 min-w-0`,children:[!w&&(0,V.jsx)(`div`,{className:`text-sm text-muted-foreground text-center py-8`,children:`Loading…`}),w&&g&&v&&(0,V.jsx)(Yd,{form:v,onChange:e=>y(t=>t&&{...t,...e}),onSave:()=>void le(),onCancel:ce}),w&&!g&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Status`}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-sm`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground mb-0.5`,children:`Execution`}),(0,V.jsx)(I,{variant:`outline`,className:`text-xs border ${oe}`,children:w.status})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground mb-0.5`,children:`Deliverable stage`}),(0,V.jsx)(I,{variant:`secondary`,className:`text-xs ${E}`,children:Wd[w.deliverableStage??`none`]??w.deliverableStage??`none`})]})]}),w.blockedBy&&w.blockedBy.length>0&&(0,V.jsx)(`div`,{className:`mt-2 space-y-1`,children:w.blockedBy.map((e,t)=>(0,V.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-yellow-400 min-w-0`,children:[(0,V.jsx)(`span`,{className:`font-medium capitalize shrink-0`,children:e.type}),e.ref&&(0,V.jsxs)(`span`,{className:`text-muted-foreground truncate min-w-0`,children:[`→ `,e.ref]}),e.note&&(0,V.jsx)(`span`,{className:`text-muted-foreground truncate min-w-0`,children:e.note})]},t))})]}),(0,V.jsx)(fl,{}),(w.intent||w.doneWhen)&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`section`,{className:`space-y-2`,children:[w.intent&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1`,children:`Intent`}),(0,V.jsx)(Ud,{text:w.intent,className:`text-sm min-w-0 break-words [overflow-wrap:anywhere]`})]}),w.doneWhen&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1`,children:`Done when`}),(0,V.jsx)(Ud,{text:w.doneWhen,className:`text-sm min-w-0 break-words [overflow-wrap:anywhere]`})]})]}),(0,V.jsx)(fl,{})]}),(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Ownership`}),(0,V.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[w.ownerAgentId&&(0,V.jsxs)(`div`,{className:`flex gap-2 min-w-0`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Owner`}),(0,V.jsx)(`span`,{className:`min-w-0 break-words [overflow-wrap:anywhere]`,title:w.ownerAgentId,children:c[w.ownerAgentId]?N(c[w.ownerAgentId]):w.ownerAgentId})]}),w.createdBy&&(0,V.jsxs)(`div`,{className:`flex gap-2 min-w-0`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Created by`}),(0,V.jsx)(`span`,{className:`min-w-0 break-words [overflow-wrap:anywhere]`,title:w.createdBy,children:w.createdBy})]}),w.teamId&&(0,V.jsxs)(`div`,{className:`flex gap-2 min-w-0`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Team`}),(0,V.jsx)(`span`,{className:`min-w-0 break-words [overflow-wrap:anywhere] font-mono text-xs`,title:w.teamId,children:w.teamId})]}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Created`}),(0,V.jsx)(`span`,{title:Jt(w.createdAt),children:M(e,w.createdAt)})]}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Updated`}),(0,V.jsx)(`span`,{title:Jt(w.updatedAt),children:M(e,w.updatedAt)})]})]})]}),(w.dispatchWorkShape?.specified||w.dispatchDecision||w.boundWorkerModel)&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsx)(Xd,{detail:w})]}),(w.branch||w.commits&&w.commits.length>0)&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Code`}),w.branch&&(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm mb-1 min-w-0`,children:[(0,V.jsx)(ne,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,V.jsx)(`span`,{className:`font-mono text-xs truncate min-w-0`,title:w.branch,children:w.branch})]}),w.commits?.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm ml-1 min-w-0`,children:[(0,V.jsx)(Re,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,V.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground shrink-0`,children:e.sha.slice(0,8)}),e.subject&&(0,V.jsx)(`span`,{className:`text-xs truncate min-w-0`,children:e.subject})]},e.sha))]})]}),w.issues&&w.issues.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsx)(Qd,{issues:w.issues})]}),(w.dependsOn&&w.dependsOn.length>0||w.dependents&&w.dependents.length>0)&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsx)($d,{dependsOn:w.dependsOn??[],dependents:w.dependents??[]})]}),w.gates&&w.gates.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsx)(ef,{gates:w.gates,now:e})]}),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsx)(Zd,{taskId:w.id,pinProvider:b,pinModel:S,pinEffort:ee,onPinProvider:x,onPinModel:C,onPinEffort:te,onDispatch:ue,onSpawn:e=>void p(w.id,e),loading:ae,result:ie,providers:m})]}),T&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsx)(tf,{memory:T,now:e})]}),re.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fl,{}),(0,V.jsx)(nf,{history:re,now:e})]})]})]})})]})})}function Yd({form:e,onChange:t,onSave:n,onCancel:r}){return(0,V.jsxs)(`section`,{className:`space-y-4`,children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Edit Task fields`}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)($,{htmlFor:`edit-title`,children:`Title`}),(0,V.jsx)(R,{id:`edit-title`,value:e.title,onChange:e=>t({title:e.target.value})})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)($,{htmlFor:`edit-intent`,children:`Intent`}),(0,V.jsx)(Vd,{id:`edit-intent`,value:e.intent,onChange:e=>t({intent:e.target.value}),rows:3})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)($,{htmlFor:`edit-steer`,children:`Latest steer`}),(0,V.jsx)(Vd,{id:`edit-steer`,value:e.latestSteer,onChange:e=>t({latestSteer:e.target.value}),rows:2,placeholder:`Redirect or re-scope in-flight work`})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)($,{htmlFor:`edit-done-when`,children:`Done when`}),(0,V.jsx)(Vd,{id:`edit-done-when`,value:e.doneWhen,onChange:e=>t({doneWhen:e.target.value}),rows:2})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)($,{htmlFor:`edit-team`,children:`Team ID`}),(0,V.jsx)(R,{id:`edit-team`,value:e.teamId,onChange:e=>t({teamId:e.target.value})})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)($,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Dispatch work-shape`}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`edit-complexity`,className:`text-xs`,children:`Complexity`}),(0,V.jsxs)(`select`,{id:`edit-complexity`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchComplexity,onChange:e=>t({dispatchComplexity:e.target.value}),children:[(0,V.jsx)(`option`,{value:``,children:`—`}),Dt.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`edit-type`,className:`text-xs`,children:`Type`}),(0,V.jsxs)(`select`,{id:`edit-type`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchType,onChange:e=>t({dispatchType:e.target.value}),children:[(0,V.jsx)(`option`,{value:``,children:`—`}),St.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`edit-footprint`,className:`text-xs`,children:`Context footprint`}),(0,V.jsxs)(`select`,{id:`edit-footprint`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchFootprint,onChange:e=>t({dispatchFootprint:e.target.value}),children:[(0,V.jsx)(`option`,{value:``,children:`—`}),Et.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`edit-criticality`,className:`text-xs`,children:`Criticality`}),(0,V.jsxs)(`select`,{id:`edit-criticality`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchCriticality,onChange:e=>t({dispatchCriticality:e.target.value}),children:[(0,V.jsx)(`option`,{value:``,children:`—`}),kt.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]})]})]}),(0,V.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,V.jsx)(L,{size:`sm`,onClick:n,children:`Save`}),(0,V.jsx)(L,{size:`sm`,variant:`outline`,onClick:r,children:`Cancel`})]})]})}function Xd({detail:e}){let t=e.dispatchWorkShape,n=e.dispatchDecision,r=e.boundWorkerModel;return(0,V.jsxs)(`section`,{className:`space-y-3`,children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Dispatch`}),t&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Work shape`}),t.specified?(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[t.complexity&&(0,V.jsx)(I,{variant:`secondary`,className:`text-xs`,children:t.complexity}),t.type&&(0,V.jsx)(I,{variant:`secondary`,className:`text-xs`,children:t.type}),t.contextFootprint&&(0,V.jsx)(I,{variant:`secondary`,className:`text-xs`,children:t.contextFootprint}),t.criticality&&(0,V.jsx)(I,{variant:`secondary`,className:`text-xs`,children:t.criticality})]}):(0,V.jsx)(`span`,{className:`text-xs italic text-muted-foreground`,children:`Not specified`})]}),n&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Decision`}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[n.target.provider&&(0,V.jsx)(I,{variant:`secondary`,className:`text-xs font-mono`,children:n.target.provider}),n.target.model&&(0,V.jsx)(I,{variant:`outline`,className:`text-xs font-mono`,children:n.target.model}),n.target.effort&&(0,V.jsx)(I,{variant:`outline`,className:`text-xs`,children:n.target.effort}),n.pinned&&(0,V.jsx)(I,{variant:`outline`,className:`text-xs text-yellow-400 border-yellow-500/30`,children:`pinned`})]}),n.rationale&&(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.rationale}),n.warnings?.map((e,t)=>(0,V.jsxs)(`div`,{className:`flex items-start gap-1 text-xs text-yellow-400 mt-0.5`,children:[(0,V.jsx)(je,{className:`w-3 h-3 shrink-0 mt-0.5`}),(0,V.jsx)(`span`,{children:e})]},t))]}),r&&(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Bound worker`}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[r.provider&&(0,V.jsx)(I,{variant:`secondary`,className:`text-xs font-mono`,children:r.provider}),r.model&&(0,V.jsx)(I,{variant:`outline`,className:`text-xs font-mono`,children:r.model}),r.effort&&(0,V.jsx)(I,{variant:`outline`,className:`text-xs`,children:r.effort})]}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground font-mono truncate min-w-0`,title:r.agentId,children:r.agentId})]})]})}function Zd({taskId:e,pinProvider:t,pinModel:n,pinEffort:r,onPinProvider:i,onPinModel:a,onPinEffort:o,onDispatch:s,onSpawn:c,loading:l,result:u,providers:d}){return(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-3`,children:`Spawn with task`}),(0,V.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 mb-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`spawn-provider-${e}`,className:`text-xs`,children:`Provider pin`}),(0,V.jsxs)(`select`,{id:`spawn-provider-${e}`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-xs`,value:t,onChange:e=>i(e.target.value),children:[(0,V.jsx)(`option`,{value:``,children:`auto`}),d.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`spawn-model-${e}`,className:`text-xs`,children:`Model pin`}),(0,V.jsx)(R,{id:`spawn-model-${e}`,className:`mt-1 h-8 text-xs`,value:n,onChange:e=>a(e.target.value),placeholder:`auto`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`spawn-effort-${e}`,className:`text-xs`,children:`Effort pin`}),(0,V.jsx)(R,{id:`spawn-effort-${e}`,className:`mt-1 h-8 text-xs`,value:r,onChange:e=>o(e.target.value),placeholder:`auto`})]})]}),(0,V.jsxs)(L,{size:`sm`,onClick:s,disabled:l,className:`gap-1.5`,children:[(0,V.jsx)(Fe,{className:`w-3.5 h-3.5`}),l?`Planning…`:`Plan dispatch`]}),u&&(0,V.jsxs)(`div`,{className:`mt-3 rounded-md border border-border bg-muted/20 p-3 space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,V.jsx)(Fe,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0 mt-0.5`}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,V.jsx)(I,{variant:`secondary`,className:`text-xs font-mono`,children:u.decision.target.provider}),u.decision.target.model&&(0,V.jsx)(I,{variant:`outline`,className:`text-xs font-mono`,children:u.decision.target.model}),u.decision.target.effort&&(0,V.jsx)(I,{variant:`outline`,className:`text-xs`,children:u.decision.target.effort}),u.decision.pinned&&(0,V.jsx)(I,{variant:`outline`,className:`text-xs text-yellow-400 border-yellow-500/30`,children:`pinned`})]}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u.decision.rationale}),u.decision.factors.band&&(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Band: `,u.decision.factors.band,u.decision.factors.contextWindowTokens?` · ${(u.decision.factors.contextWindowTokens/1e3).toFixed(0)}k ctx`:``]}),u.decision.warnings.length>0&&(0,V.jsx)(`div`,{className:`space-y-0.5`,children:u.decision.warnings.map((e,t)=>(0,V.jsxs)(`div`,{className:`flex items-start gap-1 text-xs text-yellow-400`,children:[(0,V.jsx)(je,{className:`w-3 h-3 shrink-0 mt-0.5`}),(0,V.jsx)(`span`,{children:e})]},t))}),u.decision.review&&(0,V.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Auto-review: `,u.decision.review.reason,` → `,u.decision.review.target.provider,`/`,u.decision.review.target.model??`default`,u.reviewTaskId&&(0,V.jsxs)(`span`,{className:`ml-1`,children:[`(task T`,u.reviewTaskId,`)`]})]})]})]}),(0,V.jsx)(`div`,{className:`pt-1 border-t border-border/50`,children:(0,V.jsxs)(L,{size:`sm`,className:`gap-1.5 w-full`,onClick:()=>c(u.decision.target),children:[(0,V.jsx)(Fe,{className:`w-3.5 h-3.5`}),`Spawn worker with task T`,e]})})]})]})}function Qd({issues:e}){return(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Linked Issues`}),(0,V.jsx)(`div`,{className:`space-y-1.5`,children:e.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-sm min-w-0`,children:[(0,V.jsxs)(`span`,{className:`font-mono text-xs text-muted-foreground shrink-0`,children:[e.provider,`/`,e.externalKey]}),e.title&&(0,V.jsx)(`span`,{className:`truncate flex-1 min-w-0`,children:e.title}),(0,V.jsx)(I,{variant:`secondary`,className:`text-xs shrink-0`,children:e.status}),e.url&&(0,V.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,V.jsx)(me,{className:`w-3.5 h-3.5`})})]},e.issueRefId))})]})}function $d({dependsOn:e,dependents:t}){return(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Dependencies`}),(0,V.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[e.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Depends on: `}),e.map((t,n)=>(0,V.jsxs)(`span`,{className:`font-mono text-xs`,children:[`T`,t,n<e.length-1?`, `:``]},t))]}),t.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Blocks: `}),t.map((e,n)=>(0,V.jsxs)(`span`,{className:`font-mono text-xs`,children:[`T`,e,n<t.length-1?`, `:``]},e))]})]})]})}function ef({gates:e,now:t}){return(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Gate Ledger`}),(0,V.jsx)(`div`,{className:`space-y-2`,children:[...e].sort((e,t)=>t.ranAt-e.ranAt).map(e=>(0,V.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[e.status===`pass`?(0,V.jsx)(ot,{className:`w-4 h-4 text-emerald-400 shrink-0 mt-0.5`}):(0,V.jsx)(Ee,{className:`w-4 h-4 text-red-400 shrink-0 mt-0.5`}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,V.jsx)(`span`,{className:`font-mono text-xs font-medium truncate min-w-0`,children:e.gate}),(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto shrink-0`,title:Jt(e.ranAt),children:M(t,e.ranAt)})]}),e.detail&&(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 truncate`,children:e.detail}),e.commitSha&&(0,V.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.commitSha.slice(0,8)})]})]},e.gate+e.ranAt))})]})}function tf({memory:e,now:t}){return(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Task Memory`}),(0,V.jsxs)(`div`,{className:`space-y-3`,children:[e.workingState&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Working state`}),(0,V.jsx)(`p`,{className:`text-xs whitespace-pre-wrap [overflow-wrap:anywhere] bg-muted/30 rounded p-2`,children:e.workingState})]}),e.ledger.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:[`Ruled out (`,e.ledger.length,`)`]}),(0,V.jsx)(`div`,{className:`space-y-1`,children:e.ledger.map((e,t)=>(0,V.jsxs)(`div`,{className:`text-xs bg-muted/20 rounded p-1.5`,children:[(0,V.jsx)(`span`,{className:`font-medium`,children:e.ruledOut}),e.why&&(0,V.jsxs)(`span`,{className:`text-muted-foreground`,children:[` — `,e.why]})]},t))})]}),e.decisions.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:[`Decisions (`,e.decisions.length,`)`]}),(0,V.jsx)(`div`,{className:`space-y-1.5`,children:e.decisions.map((e,n)=>(0,V.jsxs)(`div`,{className:`text-xs`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0`,children:[(0,V.jsx)(`span`,{className:`font-medium truncate min-w-0`,children:e.decision}),(0,V.jsx)(`span`,{className:`text-muted-foreground ml-auto shrink-0`,title:Jt(e.at),children:M(t,e.at)})]}),e.rationale&&(0,V.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:e.rationale}),e.by&&(0,V.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`by `,e.by]})]},n))})]})]})]})}function nf({history:e,now:t}){return(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`History`}),(0,V.jsx)(`div`,{className:`space-y-2`,children:[...e].reverse().slice(0,30).map(e=>(0,V.jsxs)(`div`,{className:`flex items-start gap-2 text-xs`,children:[(0,V.jsx)(Se,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0 mt-0.5`}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,V.jsx)(`span`,{className:`font-mono text-muted-foreground shrink-0`,children:e.type}),(0,V.jsx)(`span`,{className:`ml-auto text-muted-foreground shrink-0`,title:Jt(e.createdAt),children:M(t,e.createdAt)})]}),e.title&&e.title!==e.type&&(0,V.jsx)(`p`,{className:`text-foreground mt-0.5 truncate`,children:e.title})]})]},e.id))})]})}var rf=!1;function af(e,t){let n=B.useRef(!1),r=B.useRef(t);r.current=t,B.useEffect(()=>{if(!e||!r.current)return;rf=!1,window.history.pushState({dialogGuard:!0},``),n.current=!0;function t(){if(rf){rf=!1;return}n.current&&(n.current=!1,r.current?.(!1))}return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t),n.current&&(n.current=!1,rf=!0,window.history.back())}},[e])}function of({...e}){return af(e.open,e.onOpenChange),(0,V.jsx)(zr,{"data-slot":`dialog`,...e})}function sf({...e}){return(0,V.jsx)(Br,{"data-slot":`dialog-portal`,...e})}function cf({className:e,blur:t=!0,...n}){return(0,V.jsx)(Vr,{"data-slot":`dialog-overlay`,className:k(`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 lf({className:e,children:t,showCloseButton:n=!0,blurOverlay:r=!0,...i}){return(0,V.jsxs)(sf,{children:[(0,V.jsx)(cf,{blur:r}),(0,V.jsxs)(Hr,{"data-slot":`dialog-content`,className:k(`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,V.jsx)(Gr,{"data-slot":`dialog-close`,asChild:!0,children:(0,V.jsxs)(L,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`,children:[(0,V.jsx)(ye,{}),(0,V.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function uf({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`dialog-header`,className:k(`flex flex-col gap-2`,e),...t})}function df({className:e,showCloseButton:t=!1,children:n,...r}){return(0,V.jsxs)(`div`,{"data-slot":`dialog-footer`,className:k(`-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,V.jsx)(Gr,{asChild:!0,children:(0,V.jsx)(L,{variant:`outline`,children:`Close`})})]})}function ff({className:e,...t}){return(0,V.jsx)(Ur,{"data-slot":`dialog-title`,className:k(`font-heading text-base leading-none font-medium`,e),...t})}function pf({className:e,...t}){return(0,V.jsx)(Wr,{"data-slot":`dialog-description`,className:k(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function mf(){let e=j(e=>e.composeOpen),t=j(e=>e.compose),n=j(e=>e.replyTo),r=j(e=>e.set),i=j(e=>e.doSend),a=j(e=>e.cancelReply),o=al();function s(){r({composeOpen:!1}),a()}function c(e){r({compose:{...t,...e}})}return(0,V.jsx)(of,{open:e,onOpenChange:e=>!e&&s(),children:(0,V.jsxs)(lf,{className:`max-w-lg`,children:[(0,V.jsx)(uf,{children:(0,V.jsx)(ff,{children:n?`Reply to #${n.id}`:`Compose Message`})}),(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`From`}),(0,V.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,V.jsx)(`option`,{value:``,children:`Select agent...`}),o.map(e=>(0,V.jsx)(`option`,{value:e.id,children:N(e)},e.id))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`To`}),(0,V.jsx)(R,{value:t.to,onChange:e=>c({to:e.target.value}),placeholder:`agent-id, tag:name, cap:name, or broadcast`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Subject`}),(0,V.jsx)(R,{value:t.subject,onChange:e=>c({subject:e.target.value}),placeholder:`Optional subject...`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Channel`}),(0,V.jsx)(R,{value:t.channel,onChange:e=>c({channel:e.target.value}),placeholder:`Optional channel...`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Message`}),(0,V.jsx)(Vd,{value:t.body,onChange:e=>c({body:e.target.value}),rows:4,placeholder:`Message body...`,autoFocus:!0})]}),(0,V.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(dl,{checked:t.claimable,onCheckedChange:e=>c({claimable:e})}),(0,V.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Claimable task`})]})]}),(0,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:s,children:`Cancel`}),(0,V.jsx)(L,{onClick:i,children:`Send`})]})]})})}function hf(){let e=j(e=>e.confirmModal),t=j(e=>e.set);function n(){t({confirmModal:{show:!1,title:``,message:``,action:null}})}return(0,V.jsx)(of,{open:e.show,onOpenChange:e=>!e&&n(),children:(0,V.jsxs)(lf,{className:`sm:max-w-sm`,children:[(0,V.jsxs)(uf,{children:[(0,V.jsx)(ff,{children:e.title}),(0,V.jsx)(pf,{children:e.message})]}),(0,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:n,children:`Cancel`}),(0,V.jsx)(L,{variant:`destructive`,onClick:()=>{e.action?.(),n()},children:`Confirm`})]})]})})}function gf(){let e=j(e=>e.errorModal),t=j(e=>e.set);function n(){t({errorModal:{show:!1,title:``,message:``}})}return(0,V.jsx)(of,{open:e.show,onOpenChange:e=>!e&&n(),children:(0,V.jsxs)(lf,{className:`sm:max-w-sm`,children:[(0,V.jsxs)(uf,{children:[(0,V.jsx)(ff,{children:e.title}),(0,V.jsx)(pf,{children:e.message})]}),(0,V.jsx)(df,{children:(0,V.jsx)(L,{onClick:n,children:`OK`})})]})})}function _f(){let e=j(e=>e.renameModal),t=j(e=>e.set),n=j(e=>e.doRename);function r(){t({renameModal:{show:!1,agentId:``,label:``}})}return(0,V.jsx)(of,{open:e.show,onOpenChange:e=>!e&&r(),children:(0,V.jsxs)(lf,{className:`sm:max-w-sm`,children:[(0,V.jsx)(uf,{children:(0,V.jsx)(ff,{children:`Rename Agent`})}),(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsx)($,{children:`Label`}),(0,V.jsx)(R,{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,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Leave empty to clear the label.`})]}),(0,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:r,children:`Cancel`}),(0,V.jsx)(L,{onClick:n,children:`Save`})]})]})})}function vf(){let e=j(e=>e.pairInviteOpen),t=j(e=>e.pairInvite),n=j(e=>e.set),r=j(e=>e.closePairInvite),i=j(e=>e.doCreatePair),a=al();function o(e){n({pairInvite:{...t,...e}})}return(0,V.jsx)(of,{open:e,onOpenChange:e=>!e&&r(),children:(0,V.jsxs)(lf,{className:`sm:max-w-sm`,children:[(0,V.jsx)(uf,{children:(0,V.jsx)(ff,{children:`Pair Agents`})}),(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Requester`}),(0,V.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,V.jsx)(`option`,{value:``,children:`Select agent...`}),a.map(e=>(0,V.jsx)(`option`,{value:e.id,children:N(e)},e.id))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Target`}),(0,V.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,V.jsx)(`option`,{value:``,children:`Select agent...`}),a.map(e=>(0,V.jsx)(`option`,{value:e.id,children:N(e)},e.id))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Objective`}),(0,V.jsx)(R,{value:t.objective,onChange:e=>o({objective:e.target.value}),placeholder:`What should they work on?`})]})]}),(0,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:r,children:`Cancel`}),(0,V.jsx)(L,{onClick:i,children:`Create Pair`})]})]})})}function yf(){let e=j(e=>e.pairMessageOpen),t=j(e=>e.pairMessage),n=j(e=>e.set),r=j(e=>e.closePairMessage),i=j(e=>e.doSendPairMessage);function a(e){n({pairMessage:{...t,...e}})}return(0,V.jsx)(of,{open:e,onOpenChange:e=>!e&&r(),children:(0,V.jsxs)(lf,{className:`sm:max-w-sm`,children:[(0,V.jsx)(uf,{children:(0,V.jsx)(ff,{children:`Pair Message`})}),(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Subject`}),(0,V.jsx)(R,{value:t.subject,onChange:e=>a({subject:e.target.value}),placeholder:`Optional subject...`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Message`}),(0,V.jsx)(Vd,{value:t.body,onChange:e=>a({body:e.target.value}),rows:4,placeholder:`Message body...`,autoFocus:!0})]})]}),(0,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:r,children:`Cancel`}),(0,V.jsx)(L,{onClick:i,children:`Send`})]})]})})}function bf(){let e=j(e=>e.threadOpen),t=j(e=>e.threadMessages),n=j(e=>e.agentsById),r=yt(),i=j(e=>e.set);return(0,V.jsx)(of,{open:e,onOpenChange:e=>!e&&i({threadOpen:!1}),children:(0,V.jsxs)(lf,{className:`max-w-2xl max-h-[80vh]`,children:[(0,V.jsx)(uf,{children:(0,V.jsxs)(ff,{children:[`Thread (`,t.length,` messages)`]})}),(0,V.jsx)(Rd,{className:`max-h-[60vh]`,children:(0,V.jsx)(`div`,{className:`space-y-3 pr-4`,children:t.map(e=>(0,V.jsxs)(`div`,{className:`rounded-lg border border-border p-3 space-y-1`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,V.jsx)(`span`,{className:`font-medium`,children:qt(e.from,n)}),(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:qt(e.to,n)}),(0,V.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:M(r,e.createdAt)})]}),e.subject&&(0,V.jsx)(`div`,{className:`text-sm font-medium`,children:e.subject}),(0,V.jsx)(Ud,{text:Zt(e),rawBody:e.body,issueRepo:n[e.from===`user`?e.to:e.from]?.issueRepo,className:`text-sm text-muted-foreground`}),(0,V.jsxs)(`div`,{className:`flex gap-1.5 flex-wrap`,children:[e.channel&&(0,V.jsx)(I,{variant:`secondary`,className:`text-[10px]`,children:e.channel}),e.claimedBy&&(0,V.jsxs)(I,{variant:`secondary`,className:`text-[10px]`,children:[`claimed by `,qt(e.claimedBy,n)]})]})]},e.id))})})]})})}function xf(){let e=j(e=>e.taskEventsOpen),t=j(e=>e.taskEvents),n=j(e=>e.set),r=j(e=>e.switchView);function i(e){n({selectedMemoryId:e,taskEventsOpen:!1}),r(`memory`)}return(0,V.jsx)(of,{open:e,onOpenChange:e=>!e&&n({taskEventsOpen:!1}),children:(0,V.jsxs)(lf,{className:`max-w-2xl max-h-[80vh]`,children:[(0,V.jsx)(uf,{children:(0,V.jsxs)(ff,{children:[`Task Events (`,t.length,`)`]})}),(0,V.jsx)(Rd,{className:`max-h-[60vh]`,children:(0,V.jsxs)(`div`,{className:`space-y-2 pr-4`,children:[t.map(e=>(0,V.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-border p-3`,children:[(0,V.jsx)(I,{className:Kt[e.severity]||Kt.info,children:e.severity}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`text-sm font-medium`,children:e.title}),(0,V.jsx)(I,{variant:`outline`,className:`text-[10px]`,children:e.type})]}),e.body&&(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 whitespace-pre-wrap`,children:e.body}),(0,V.jsx)(Sf,{event:e,onOpen:i}),(0,V.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[Jt(e.createdAt),` · `,e.source]})]})]},e.id)),t.length===0&&(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-8`,children:`No events recorded.`})]})})]})})}function Sf({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,V.jsx)(`div`,{className:`mt-2 rounded-md border border-border bg-muted/20 p-2 text-xs`,children:(0,V.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,V.jsx)(ie,{className:`w-3.5 h-3.5 mt-0.5 text-muted-foreground shrink-0`}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[(0,V.jsx)(I,{variant:`secondary`,className:`text-[10px]`,children:o}),a&&(0,V.jsx)(I,{variant:`outline`,className:`text-[10px] font-mono`,children:a}),s&&(0,V.jsx)(I,{variant:`outline`,className:`text-[10px]`,children:s})]}),(0,V.jsx)(`div`,{className:`font-medium truncate`,children:i}),n&&(0,V.jsx)(`div`,{className:`font-mono text-[10px] text-muted-foreground truncate`,children:n})]}),n&&(0,V.jsx)(L,{size:`sm`,variant:`outline`,className:`h-7 text-xs shrink-0`,onClick:()=>t(n),children:`Open`})]})})}function Cf(){let e=j(e=>e.taskCreateOpen),t=j(e=>e.taskCreateForm),n=j(e=>e.closeTaskCreate),r=j(e=>e.setTaskCreateForm),i=j(e=>e.doCreateTask);return(0,V.jsx)(of,{open:e,onOpenChange:e=>!e&&n(),children:(0,V.jsxs)(lf,{className:`max-w-lg`,children:[(0,V.jsx)(uf,{children:(0,V.jsx)(ff,{children:`New Task`})}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsxs)($,{htmlFor:`task-title`,children:[`Title `,(0,V.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,V.jsx)(R,{id:`task-title`,value:t.title,onChange:e=>r({title:e.target.value}),placeholder:`Short description of the work`,autoFocus:!0})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)($,{htmlFor:`task-intent`,children:`Intent`}),(0,V.jsx)(Vd,{id:`task-intent`,value:t.intent,onChange:e=>r({intent:e.target.value}),placeholder:`What is this task trying to accomplish?`,rows:3})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)($,{htmlFor:`task-done-when`,children:`Done when`}),(0,V.jsx)(Vd,{id:`task-done-when`,value:t.doneWhen,onChange:e=>r({doneWhen:e.target.value}),placeholder:`Acceptance criteria`,rows:2})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsxs)($,{htmlFor:`task-issue-refs`,children:[`Issue refs `,(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(comma-separated, e.g. owner/repo#123)`})]}),(0,V.jsx)(R,{id:`task-issue-refs`,value:t.issueRefs,onChange:e=>r({issueRefs:e.target.value}),placeholder:`owner/repo#123, owner/repo#456`})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsxs)($,{htmlFor:`task-depends-on`,children:[`Depends on `,(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(comma-separated task IDs)`})]}),(0,V.jsx)(R,{id:`task-depends-on`,value:t.dependsOn,onChange:e=>r({dependsOn:e.target.value}),placeholder:`42, 43`})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)($,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Dispatch work-shape (optional)`}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`dispatch-complexity`,className:`text-xs`,children:`Complexity`}),(0,V.jsxs)(`select`,{id:`dispatch-complexity`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchComplexity,onChange:e=>r({dispatchComplexity:e.target.value}),children:[(0,V.jsx)(`option`,{value:``,children:`—`}),Dt.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`dispatch-type`,className:`text-xs`,children:`Type`}),(0,V.jsxs)(`select`,{id:`dispatch-type`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchType,onChange:e=>r({dispatchType:e.target.value}),children:[(0,V.jsx)(`option`,{value:``,children:`—`}),St.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`dispatch-footprint`,className:`text-xs`,children:`Context footprint`}),(0,V.jsxs)(`select`,{id:`dispatch-footprint`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchFootprint,onChange:e=>r({dispatchFootprint:e.target.value}),children:[(0,V.jsx)(`option`,{value:``,children:`—`}),Et.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{htmlFor:`dispatch-criticality`,className:`text-xs`,children:`Criticality`}),(0,V.jsxs)(`select`,{id:`dispatch-criticality`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchCriticality,onChange:e=>r({dispatchCriticality:e.target.value}),children:[(0,V.jsx)(`option`,{value:``,children:`—`}),kt.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]})]})]})]}),(0,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:n,children:`Cancel`}),(0,V.jsx)(L,{onClick:()=>void i(),disabled:!t.title.trim(),children:`Create`})]})]})})}function wf({open:e,onOpenChange:t,onSelect:n,orchestratorId:r,initialPath:i,title:a=`Select Directory`}){let o=j(e=>e.apiCall),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(null),[d,f]=(0,B.useState)(null),[p,h]=(0,B.useState)(!1),[g,_]=(0,B.useState)(``),[v,y]=(0,B.useState)(null),b=l?.path||i||``,x=(0,B.useMemo)(()=>b.split(`/`).filter(Boolean),[b]),S=(0,B.useCallback)(async e=>{if(r){c(!0),f(null),h(!1);try{let t=e?`?path=${encodeURIComponent(e)}`:``;u(await o(`GET`,`/orchestrators/${encodeURIComponent(r)}/directories${t}`))}catch(e){f(At(e))}finally{c(!1)}}},[r,o]);(0,B.useEffect)(()=>{e&&r&&(u(null),f(null),h(!1),S(i||void 0))},[e,r]);async function C(){if(!(!g.trim()||!l)){y(null);try{u(await o(`POST`,`/orchestrators/${encodeURIComponent(r)}/directories`,{path:l.path,name:g.trim()})),h(!1),_(``)}catch(e){y(At(e))}}}function te(){b&&(n(b),t(!1))}function ne(e){S(`/`+x.slice(0,e+1).join(`/`))}return(0,V.jsx)(of,{open:e,onOpenChange:t,children:(0,V.jsxs)(lf,{className:`max-w-lg max-h-[85dvh] flex flex-col`,children:[(0,V.jsx)(uf,{children:(0,V.jsxs)(ff,{className:`flex items-center gap-2`,children:[(0,V.jsx)(E,{className:`h-4 w-4`}),a]})}),(0,V.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,V.jsx)(`button`,{type:`button`,className:`font-mono text-muted-foreground hover:text-foreground shrink-0`,onClick:()=>l?.baseDir&&S(l.baseDir),children:`/`}),x.map((e,t)=>(0,V.jsxs)(`span`,{className:`shrink-0`,children:[(0,V.jsx)(`button`,{type:`button`,className:`font-mono text-muted-foreground hover:text-foreground`,onClick:()=>ne(t),children:e}),t<x.length-1&&(0,V.jsx)(`span`,{className:`text-muted-foreground/50 mx-0.5`,children:`/`})]},`${e}-${t}`))]}),(0,V.jsxs)(`div`,{className:`flex-1 min-h-0 rounded-md border border-border bg-background overflow-y-auto`,style:{maxHeight:`40dvh`},children:[s&&(0,V.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,V.jsx)(A,{className:`h-5 w-5 animate-spin text-muted-foreground`})}),!s&&d&&(0,V.jsx)(`div`,{className:`px-3 py-4 text-sm text-destructive`,children:d}),!s&&l&&(0,V.jsxs)(`div`,{className:`p-1`,children:[l.parent&&(0,V.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:()=>S(l.parent),children:[(0,V.jsx)(Ze,{className:`h-4 w-4 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`..`})]}),l.entries.map(e=>(0,V.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:()=>S(e.path),children:[(0,V.jsx)(m,{className:`h-4 w-4 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)),l.entries.length===0&&!l.parent&&(0,V.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground text-center`,children:`Empty directory`}),l.entries.length===0&&l.parent&&(0,V.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground text-center`,children:`No subdirectories`})]})]}),p?(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(R,{autoFocus:!0,value:g,onChange:e=>{_(e.target.value),y(null)},onKeyDown:e=>{e.key===`Enter`&&C(),e.key===`Escape`&&(h(!1),_(``))},placeholder:`New directory name...`,className:`flex-1 font-mono text-sm`}),(0,V.jsx)(L,{type:`button`,size:`icon`,variant:`outline`,onClick:C,disabled:!g.trim(),children:(0,V.jsx)(ce,{className:`h-4 w-4`})}),(0,V.jsx)(L,{type:`button`,size:`icon`,variant:`ghost`,onClick:()=>{h(!1),_(``),y(null)},children:(0,V.jsx)(ye,{className:`h-4 w-4`})})]}):(0,V.jsxs)(L,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>h(!0),disabled:!l||s,children:[(0,V.jsx)(ee,{className:`h-4 w-4 mr-1.5`}),`New Directory`]}),v&&(0,V.jsx)(`p`,{className:`text-xs text-destructive`,children:v}),(0,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,V.jsx)(L,{onClick:te,disabled:!b,children:`Select`})]})]})})}function Tf({value:e,onChange:t,orchestratorId:n,placeholder:r,disabled:i}){let[a,o]=(0,B.useState)(!1);return(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(R,{value:e,onChange:e=>t(e.target.value),placeholder:r,disabled:i,className:`flex-1 font-mono text-sm`}),(0,V.jsx)(L,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>o(!0),disabled:i||!n,title:`Browse directories`,children:(0,V.jsx)(E,{className:`h-4 w-4`})}),n&&(0,V.jsx)(wf,{open:a,onOpenChange:o,onSelect:t,orchestratorId:n,initialPath:e||void 0})]})}function Ef({model:e}){if(!e)return null;let t=Df(e);return t.length===0?null:(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>(0,V.jsxs)(I,{variant:`outline`,className:`gap-1 text-[10px]`,children:[(0,V.jsx)(e.Icon,{className:`h-3 w-3`}),e.label]},e.label))})}function Df(e){let t=[],n=e.limits?.contextWindowTokens?.value;return n&&t.push({label:Of(n),Icon:b}),e.capabilities?.modalities.input.image&&t.push({label:`Image input`,Icon:f}),(e.capabilities?.modalities.output.image||e.capabilities?.tools?.imageGeneration)&&t.push({label:`Image output`,Icon:f}),e.capabilities?.tools?.code&&t.push({label:`Code`,Icon:et}),t}function Of(e){return e>=1e6?`${e/1e6}M ctx`:e>=1e3?`${Math.round(e/1e3)}K ctx`:`${e} ctx`}function kf(){let e=j(e=>e.orchestratorSpawnOpen),t=j(e=>e.orchestrators),n=j(e=>e.spawnOrchId),r=j(e=>e.spawnProvider),i=j(e=>e.spawnModel),a=j(e=>e.spawnEffort),o=j(e=>e.spawnProfile),s=j(e=>e.spawnCwd),c=j(e=>e.spawnLabel),l=j(e=>e.spawnApproval),u=j(e=>e.spawnWorkspaceMode),d=j(e=>e.spawnPrompt),f=j(e=>e.spawnSystemPromptAppend),p=j(e=>e.spawnCount),m=j(e=>e.spawnCwdHistory),h=j(e=>e.isSpawning),g=j(e=>!!e.pendingForkImport),_=j(e=>e.set),v=j(e=>e.submitOrchestratorSpawn),y=j(e=>e.selectSpawnHistory),b=j(e=>e.agentProfiles),x=j(e=>e.providerCatalog),S=t.find(e=>e.id===n),C=S?.providers||[],ee=xt(r,x),te=ee.find(e=>e.alias===i),ne=te?.efforts||[],w=!!(S&&C.length>0&&s.trim())&&!h,T=t.filter(e=>e.status===`online`),re=T.length>1,ie=m.filter(e=>T.some(t=>t.id===e.orchId)).slice(0,5);function ae(e){let n=t.find(t=>t.id===e),r=n?.providers[0]||``;_({spawnOrchId:e,spawnProvider:r,spawnModel:r?_t(r,x):``,spawnEffort:``,spawnCwd:n?.baseDir||``})}function oe(e){_({spawnProvider:e,spawnModel:_t(e,x),spawnEffort:``})}function E(e){_({spawnModel:e,spawnEffort:``})}return(0,V.jsx)(of,{open:e,onOpenChange:e=>!e&&_({orchestratorSpawnOpen:!1}),children:(0,V.jsxs)(lf,{className:`max-w-lg max-h-[90dvh] flex flex-col`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,V.jsx)(uf,{children:(0,V.jsx)(ff,{children:`Spawn Agent`})}),(0,V.jsxs)(`div`,{className:`space-y-3 overflow-y-auto flex-1 min-h-0 -mx-4 px-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Orchestrator`}),(0,V.jsx)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:n,onChange:e=>ae(e.target.value),children:t.filter(e=>e.status===`online`).map(e=>(0,V.jsxs)(`option`,{value:e.id,children:[e.hostname,` (`,e.id.slice(-8),`)`]},e.id))})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Provider`}),(0,V.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:r,onChange:e=>oe(e.target.value),disabled:!C.length,children:[!C.length&&(0,V.jsx)(`option`,{value:r,children:`No providers available`}),C.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Model`}),(0,V.jsx)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:i,onChange:e=>E(e.target.value),disabled:!ee.length,children:ee.map(e=>(0,V.jsx)(`option`,{value:e.alias,children:e.label},e.alias))})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Effort`}),(0,V.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:!ne.length,children:[(0,V.jsx)(`option`,{value:``,children:`Default`}),ne.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,V.jsx)(Ef,{model:te}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Agent Profile`}),(0,V.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,V.jsx)(`option`,{value:`default-relay`,children:`default-relay`}),b.map(e=>(0,V.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Approval Mode`}),(0,V.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,V.jsx)(`option`,{value:`open`,children:`Open`}),(0,V.jsx)(`option`,{value:`guarded`,children:`Guarded`}),(0,V.jsx)(`option`,{value:`read-only`,children:`Read-only`})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Workspace`}),(0,V.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,V.jsx)(`option`,{value:`inherit`,children:`Default`}),(0,V.jsx)(`option`,{value:`isolated`,children:`Isolated worktree`}),(0,V.jsx)(`option`,{value:`shared`,children:`Shared cwd`})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Working Directory`}),(0,V.jsx)(`div`,{className:`mt-1`,children:(0,V.jsx)(Tf,{value:s,onChange:e=>_({spawnCwd:e}),orchestratorId:n,placeholder:`Select a project directory`})}),ie.length>0&&(0,V.jsxs)(`div`,{className:`mt-2`,children:[(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground mb-1`,children:`Recent`}),(0,V.jsx)(`div`,{className:`flex gap-1.5 overflow-x-auto pb-1 sm:flex-wrap sm:overflow-x-visible sm:pb-0`,children:ie.map(e=>{let t=e.cwd.replace(/\/+$/,``).split(`/`).pop()||e.cwd,r=T.find(t=>t.id===e.orchId)?.hostname,i=e.orchId===n&&e.cwd===s;return(0,V.jsx)(`button`,{type:`button`,title:re&&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:re&&r?`${r}: ${t}`:t},`${e.orchId}:${e.cwd}`)})})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Label`}),(0,V.jsx)(R,{value:c,onChange:e=>_({spawnLabel:e.target.value}),placeholder:`Optional label...`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Initial Prompt`}),(0,V.jsx)(Vd,{value:d,onChange:e=>_({spawnPrompt:e.target.value}),rows:3,placeholder:`Optional initial task...`}),(0,V.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,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`System Prompt Append`}),(0,V.jsx)(Vd,{value:f,onChange:e=>_({spawnSystemPromptAppend:e.target.value}),rows:5,placeholder:`Optional launch context...`}),(0,V.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,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)($,{children:`Number of Agents`}),(0,V.jsx)(`span`,{className:`text-sm font-mono tabular-nums text-muted-foreground`,children:p})]}),(0,V.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,V.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,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:()=>_({orchestratorSpawnOpen:!1}),disabled:h,children:`Cancel`}),(0,V.jsx)(L,{onClick:v,disabled:!w,children:h?`Spawning…`:C.length?p>1?`Spawn ${p}`:`Spawn`:`No providers`})]})]})})}function Af(){return`host-${Math.random().toString(36).slice(2,8)}`}function jf(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function Mf(){let e=j(e=>e.orchestratorInstallOpen),t=j(e=>e.set),n=j(e=>e.showError),r=j(e=>e.showNotification),i=(0,B.useMemo)(()=>new URL(Ce()).origin,[]),[a,o]=(0,B.useState)(Af),[s,l]=(0,B.useState)(`$HOME/projects`),[u,d]=(0,B.useState)(Ot()),[f,p]=(0,B.useState)(`4860`),[m,h]=(0,B.useState)(``),[g,_]=(0,B.useState)(``),[v,y]=(0,B.useState)(),[b,x]=(0,B.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(!u.length){n(`Validation`,`Select at least one provider`);return}x(!0);try{let e=await Qe(`POST`,`/orchestrators/bootstrap`,{id:a.trim(),relayUrl:i,baseDir:s.trim(),providers:u,apiPort:Number(f)||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,V.jsx)(of,{open:e,onOpenChange:e=>!e&&t({orchestratorInstallOpen:!1}),children:(0,V.jsxs)(lf,{className:`max-w-2xl overflow-hidden`,children:[(0,V.jsx)(uf,{children:(0,V.jsxs)(ff,{className:`flex items-center gap-2`,children:[(0,V.jsx)(c,{className:`w-4 h-4`}),`Add Orchestrator`]})}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Orchestrator ID`}),(0,V.jsx)(R,{value:a,onChange:e=>o(e.target.value)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Relay URL`}),(0,V.jsx)(R,{value:i,readOnly:!0})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Base Directory`}),(0,V.jsx)(R,{value:s,onChange:e=>l(e.target.value)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`API Port`}),(0,V.jsx)(R,{value:f,onChange:e=>p(e.target.value),inputMode:`numeric`})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Providers`}),(0,V.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-2`,children:Ot().map(e=>(0,V.jsx)(L,{type:`button`,size:`sm`,variant:u.includes(e)?`default`:`outline`,onClick:()=>d(jf(u,e)),children:Tt(e)},e))})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Extra PATH Prefix`}),(0,V.jsx)(R,{value:m,onChange:e=>h(e.target.value),placeholder:`/opt/homebrew/bin:/custom/bin`})]}),g&&(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,V.jsx)($,{children:`Install Command`}),v&&(0,V.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`Install token expires `,new Date(v*1e3).toLocaleString()]})]}),(0,V.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,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:()=>t({orchestratorInstallOpen:!1}),children:`Close`}),g&&(0,V.jsx)(Un,{value:g,label:`Copy`,showText:!0,size:`default`,variant:`outline`,className:`gap-1`,onCopied:()=>r(`Install command copied`)}),(0,V.jsxs)(L,{className:`gap-1`,onClick:S,disabled:b,children:[(0,V.jsx)(_e,{className:`w-3.5 h-3.5`}),b?`Generating...`:`Generate Command`]})]})]})})}function Nf(){let e=j(e=>e.policyModal),t=j(e=>e.orchestrators),n=j(e=>e.agentProfiles),r=j(e=>e.set),i=j(e=>e.submitPolicy),a=j(e=>e.providerCatalog),o=t.find(t=>t.id===e.orchestratorId),s=o?.providers||[],c=xt(e.provider,a),l=c.find(t=>t.alias===e.model),u=l?.efforts||[],d=!!e.editing,f=o?.providerStatus?.find(t=>t.name===e.provider)?.features?.rig===!0;function p(t){r({policyModal:{...e,...t}})}function m(n){let r=t.find(e=>e.id===n)?.providers[0]||e.provider;p({orchestratorId:n,provider:r,model:_t(r,a),effort:``})}function h(e){p({provider:e,rig:``,model:_t(e,a),effort:``})}return(0,V.jsx)(of,{open:e.open,onOpenChange:e=>!e&&p({open:!1}),children:(0,V.jsxs)(lf,{className:`max-w-lg max-h-[90vh] overflow-y-auto`,children:[(0,V.jsx)(uf,{children:(0,V.jsx)(ff,{children:d?`Edit Policy`:`Create Managed Agent`})}),(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Policy Name`}),(0,V.jsx)(R,{value:e.name,onChange:e=>p({name:e.target.value}),placeholder:`my-agent`,disabled:d})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Label`}),(0,V.jsx)(R,{value:e.label,onChange:e=>p({label:e.target.value}),placeholder:`Human-friendly name...`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Description`}),(0,V.jsx)(R,{value:e.description,onChange:e=>p({description:e.target.value}),placeholder:`What does this agent do?`})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Orchestrator`}),(0,V.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=>m(e.target.value),children:t.filter(e=>e.status===`online`).map(e=>(0,V.jsxs)(`option`,{value:e.id,children:[e.hostname,` (`,e.id.slice(-8),`)`]},e.id))})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Provider`}),(0,V.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=>h(e.target.value),disabled:!s.length,children:[!s.length&&(0,V.jsx)(`option`,{value:e.provider,children:`No providers available`}),s.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]})]}),f&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Rig`}),(0,V.jsx)(R,{value:e.rig,onChange:e=>p({rig:e.target.value}),placeholder:`Leave empty to auto-detect from .claude-rig`}),(0,V.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,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Model`}),(0,V.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=>p({model:e.target.value,effort:``}),children:c.map(e=>(0,V.jsx)(`option`,{value:e.alias,children:e.label},e.alias))})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Effort`}),(0,V.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=>p({effort:e.target.value}),disabled:!u.length,children:[(0,V.jsx)(`option`,{value:``,children:`Default`}),u.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,V.jsx)(Ef,{model:l}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Agent Profile`}),(0,V.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=>p({profile:e.target.value}),children:[!n.length&&(0,V.jsx)(`option`,{value:`default-relay`,children:`default-relay`}),n.map(e=>(0,V.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Working Directory`}),(0,V.jsx)(`div`,{className:`mt-1`,children:(0,V.jsx)(Tf,{value:e.cwd,onChange:e=>p({cwd:e}),orchestratorId:e.orchestratorId,placeholder:o?.baseDir||`/path/to/project`})})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Mode`}),(0,V.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=>p({mode:e.target.value}),children:[(0,V.jsx)(`option`,{value:`always-on`,children:`Always On`}),(0,V.jsx)(`option`,{value:`on-demand`,children:`On Demand`})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Permission Mode`}),(0,V.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=>p({permissionMode:e.target.value}),children:[(0,V.jsx)(`option`,{value:`open`,children:`Open`}),(0,V.jsx)(`option`,{value:`guarded`,children:`Guarded`}),(0,V.jsx)(`option`,{value:`read-only`,children:`Read-only`})]})]})]}),e.mode===`on-demand`&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Keepalive (seconds)`}),(0,V.jsx)(R,{type:`number`,value:e.keepaliveSeconds,onChange:e=>p({keepaliveSeconds:e.target.value}),placeholder:`300`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Seconds to keep agent alive after last activity.`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Initial Prompt`}),(0,V.jsx)(Vd,{value:e.prompt,onChange:e=>p({prompt:e.target.value}),rows:3,placeholder:`Optional initial task or instructions...`}),(0,V.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,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Tags`}),(0,V.jsx)(R,{value:e.tags,onChange:e=>p({tags:e.target.value}),placeholder:`tag1, tag2`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Capabilities`}),(0,V.jsx)(R,{value:e.capabilities,onChange:e=>p({capabilities:e.target.value}),placeholder:`chat, review`})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Provider Args`}),(0,V.jsx)(R,{value:e.providerArgs,onChange:e=>p({providerArgs:e.target.value}),placeholder:`--flag value`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Space-separated args passed to the provider CLI.`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Channel Binding`}),(0,V.jsx)(R,{value:e.channelId,onChange:e=>p({channelId:e.target.value}),placeholder:`Channel ID (optional)`})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Backoff Schedule (seconds)`}),(0,V.jsx)(R,{value:e.backoffSchedule,onChange:e=>p({backoffSchedule:e.target.value}),placeholder:`5, 15, 60, 300`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Backoff Reset After (s)`}),(0,V.jsx)(R,{type:`number`,value:e.backoffResetAfterSeconds,onChange:e=>p({backoffResetAfterSeconds:e.target.value}),placeholder:`600`})]})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)($,{htmlFor:`restartOnUpdate`,children:`Restart on policy update`}),(0,V.jsx)(dl,{id:`restartOnUpdate`,checked:e.restartOnUpdate,onCheckedChange:e=>p({restartOnUpdate:e})})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)($,{htmlFor:`dailyRestart`,children:`Scheduled daily restart`}),(0,V.jsx)(dl,{id:`dailyRestart`,checked:e.scheduledDailyRestart,onCheckedChange:e=>p({scheduledDailyRestart:e})})]})]}),(0,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:()=>p({open:!1}),children:`Cancel`}),(0,V.jsx)(L,{onClick:i,children:d?`Save`:`Create`})]})]})})}function Pf({children:e}){return(0,V.jsxs)(qc,{children:[(0,V.jsx)(Jc,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":`More info`,className:`inline-flex shrink-0 text-muted-foreground transition-colors hover:text-foreground`,children:(0,V.jsx)(lt,{className:`h-3 w-3`})})}),(0,V.jsx)(Yc,{className:`max-w-xs leading-relaxed`,children:e})]})}function Ff({children:e,tip:t,className:n}){return(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)($,{className:n,children:e}),(0,V.jsx)(Pf,{children:t})]})}var If=[`core`,`workspace`,`memory`,`artifacts`,`blackboard`,`subscriptions`,`spawn-lifecycle`,`plans`,`teams`,`project`,`issues`],Lf=[{value:``,label:`Off`},{value:`all`,label:`All`}],Rf=[{value:``,label:`Off`},{value:`all`,label:`All safe settings`}],zf=[{value:``,label:`Instance default`},{value:`direct`,label:`Direct`},{value:`pr`,label:`Pull request`}],Bf=[{value:`any`,label:`Any provider`},...Ot().map(e=>({value:e,label:Tt(e)}))],Vf={relay:`bg-blue-500/10 text-blue-400 border-blue-500/30`,repo:`bg-emerald-500/10 text-emerald-400 border-emerald-500/30`,inline:`bg-amber-500/10 text-amber-400 border-amber-500/30`,provider:`bg-fuchsia-500/10 text-fuchsia-400 border-fuchsia-500/30`,profile:`bg-slate-500/10 text-slate-400 border-slate-500/30`};function Hf(e){return e?e.policy??`all`:``}function Uf(e){if(e)return e===`all`?{policy:`all`}:{}}function Wf({value:e,onChange:t,options:n,disabled:r}){return(0,V.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,V.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function Gf(e,t){return`${e.source}:${e.provider??`any`}:${e.ref}:${t}`}function Kf({source:e}){return(0,V.jsx)(I,{variant:`outline`,className:`text-[10px] ${Vf[e]}`,children:e})}function qf({skills:e,plugins:t,mcp:n,onChangeSkills:r,onChangePlugins:i,onChangeMcp:a,projectMcp:o,projectSkills:s,projectSettings:c,sharedMcp:l,readOnly:u}){let[d,f]=(0,B.useState)([]),[p,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)(!1),[_,v]=(0,B.useState)(null),[y,b]=(0,B.useState)(null),[x,S]=(0,B.useState)(`repo`),[C,ee]=(0,B.useState)(``),[te,ne]=(0,B.useState)(`any`);async function w(e){if(b(e),!p){g(!0),v(null);try{f((await Qe(`GET`,`/provisioning/capabilities`)).capabilities),m(!0)}catch(e){v(At(e))}finally{g(!1)}}}function T(n){let a=C.trim();if(!a)return;let o={source:x,ref:a,enabled:!0,...te===`any`?{}:{provider:te}};n===`skill`?r([...e,o]):i([...t,o]),ee(``),b(null)}function re(n,a){let o=n===`skill`?e:t;if(o.some(e=>e.source===`relay`&&e.ref===a))return;let s=[...o,{source:`relay`,ref:a,enabled:!0}];n===`skill`?r(s):i(s),b(null)}function ie(e){let t=e.variants.find(e=>e.enabled);if(!t)return;let r=t.definition;a({...n,servers:{...n.servers??{},[e.capability.slug]:r?.server??{}}}),b(null)}function ae(t,n){r(e.map((e,r)=>r===t?{...e,...n}:e))}function oe(e,n){i(t.map((t,r)=>r===e?{...t,...n}:t))}function E(e){let t={...n.servers??{}};delete t[e],a({...n,servers:t})}let D=d.filter(e=>e.capability.kind===`skill`),se=d.filter(e=>e.capability.kind===`plugin`),ce=d.filter(e=>e.capability.kind===`mcp`);return(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsx)(Jf,{projectMcp:o,projectSkills:s,projectSettings:c,sharedMcp:l}),(0,V.jsx)(Xf,{title:`Skills from registry`,kind:`skill`,refs:e,readOnly:u,adding:y===`skill`,caps:D,loading:h,fetchError:_,empty:`No skills assigned`,manualRef:C,manualSource:x,manualProvider:te,onAddClick:()=>void w(`skill`),onCancel:()=>b(null),onManualRef:ee,onManualSource:S,onManualProvider:ne,onAddManual:()=>T(`skill`),onAddRelay:e=>re(`skill`,e),onUpdate:ae,onRemove:t=>r(e.filter((e,n)=>n!==t))}),(0,V.jsx)(Xf,{title:`Plugins from registry`,kind:`plugin`,refs:t,readOnly:u,adding:y===`plugin`,caps:se,loading:h,fetchError:_,empty:`No plugins assigned`,manualRef:C,manualSource:x,manualProvider:te,onAddClick:()=>void w(`plugin`),onCancel:()=>b(null),onManualRef:ee,onManualSource:S,onManualProvider:ne,onAddManual:()=>T(`plugin`),onAddRelay:e=>re(`plugin`,e),onUpdate:oe,onRemove:e=>i(t.filter((t,n)=>n!==e))}),(0,V.jsx)($f,{mcpKeys:Object.keys(n.servers??{}),caps:ce,adding:y===`mcp`,loading:h,fetchError:_,readOnly:u,onAddClick:()=>void w(`mcp`),onAddMcp:ie,onCancel:()=>b(null),onRemove:E})]})}function Jf(e){return(0,V.jsxs)(`div`,{className:`rounded border border-border bg-muted/20 p-2`,children:[(0,V.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[`Project and shared injection`,(0,V.jsxs)(Pf,{children:[`Read-only mirror of the Provisioning Policies above — what this profile injects from the project's `,(0,V.jsx)(`code`,{children:`.mcp.json`}),`/`,(0,V.jsx)(`code`,{children:`.claude`}),` and how its MCP is routed.`]})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,V.jsxs)(I,{variant:e.projectMcp?`default`:`outline`,className:`text-[10px]`,children:[`project MCP: `,Hf(e.projectMcp)||`off`]}),(0,V.jsxs)(I,{variant:e.projectSkills?`default`:`outline`,className:`text-[10px]`,children:[`project skills: `,Hf(e.projectSkills)||`off`]}),(0,V.jsxs)(I,{variant:e.projectSettings?`default`:`outline`,className:`text-[10px]`,children:[`project settings: `,Hf(e.projectSettings)||`off`]}),(0,V.jsxs)(I,{variant:e.sharedMcp?`default`:`outline`,className:`text-[10px]`,children:[`shared MCP: `,Hf(e.sharedMcp)||`off`]})]})]})}function Yf(e){return[...new Set(e.variants.map(e=>e.sourceType||`relay`))].join(`, `)}function Xf(e){return(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,V.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:e.title}),!e.readOnly&&(0,V.jsxs)(L,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 gap-1 text-xs`,onClick:e.onAddClick,children:[(0,V.jsx)(de,{className:`h-3 w-3`}),`Add `,e.kind]})]}),e.refs.length===0&&!e.adding&&(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.empty}),e.refs.map((t,n)=>(0,V.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 rounded border border-border bg-card/60 px-2 py-1`,children:[(0,V.jsx)(I,{variant:`outline`,className:`text-[10px] ${e.kind===`skill`?`bg-blue-500/10 text-blue-400 border-blue-500/30`:`bg-violet-500/10 text-violet-400 border-violet-500/30`}`,children:e.kind}),(0,V.jsx)(Kf,{source:t.source}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:t.ref}),t.provider&&t.provider!==`any`&&(0,V.jsx)(I,{variant:`secondary`,className:`text-[10px]`,children:t.provider}),(0,V.jsx)(dl,{checked:t.enabled,onCheckedChange:t=>e.onUpdate(n,{enabled:t}),disabled:e.readOnly,size:`sm`}),!e.readOnly&&(0,V.jsx)(L,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-5 w-5`,onClick:()=>e.onRemove(n),children:(0,V.jsx)(Oe,{className:`h-3 w-3`})})]},Gf(t,n))),e.adding&&(0,V.jsxs)(`div`,{className:`mt-1.5 space-y-2 rounded border border-border bg-card/60 p-2`,children:[e.loading&&(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Loading...`}),e.fetchError&&(0,V.jsx)(`div`,{className:`text-xs text-destructive`,children:e.fetchError}),!e.loading&&e.caps.length===0&&!e.fetchError&&(0,V.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`No `,e.kind,` capabilities in registry`]}),e.caps.length>0&&(0,V.jsx)(`div`,{className:`max-h-44 space-y-0.5 overflow-y-auto rounded border border-border/60 bg-background/40 p-1`,children:e.caps.map(t=>(0,V.jsxs)(`button`,{type:`button`,onClick:()=>e.onAddRelay(t.capability.slug),className:`w-full rounded px-2 py-1 text-left font-mono text-xs hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:[t.capability.slug,t.capability.title?` - ${t.capability.title}`:``,t.variants.length>0&&(0,V.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,Yf(t),`)`]})]},t.capability.id))}),(0,V.jsx)(Zf,{}),(0,V.jsx)(Qf,{...e}),(0,V.jsx)(L,{type:`button`,variant:`ghost`,size:`sm`,className:`mt-1 h-6 text-xs`,onClick:e.onCancel,children:`Cancel`})]})]})}function Zf(){return(0,V.jsxs)(`div`,{className:`flex items-center gap-2 pt-0.5`,children:[(0,V.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,V.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:`or add manually`}),(0,V.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function Qf(e){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-[1fr_1fr] gap-1.5`,children:[(0,V.jsx)(Wf,{value:e.manualSource,onChange:t=>e.onManualSource(t),options:[{value:`repo`,label:`Repo ref`},{value:`inline`,label:`Inline ref`},{value:`provider`,label:`Provider ref`},{value:`relay`,label:`Relay ref`}]}),(0,V.jsx)(Wf,{value:e.manualProvider,onChange:t=>e.onManualProvider(t),options:Bf})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(R,{value:e.manualRef,onChange:t=>e.onManualRef(t.target.value),placeholder:e.kind===`skill`?`.claude/skills/name or registry slug`:`.relay/plugins/name or registry slug`,className:`font-mono text-xs`}),(0,V.jsx)(L,{type:`button`,variant:`outline`,size:`sm`,className:`h-8 text-xs`,onClick:e.onAddManual,children:`Add ref`})]})]})}function $f(e){return(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,V.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`MCP from registry`}),!e.readOnly&&(0,V.jsxs)(L,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 gap-1 text-xs`,onClick:e.onAddClick,children:[(0,V.jsx)(de,{className:`h-3 w-3`}),`Add MCP`]})]}),e.mcpKeys.length===0&&!e.adding&&(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No MCP servers from registry`}),e.mcpKeys.map(t=>(0,V.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 rounded border border-border bg-card/60 px-2 py-1`,children:[(0,V.jsx)(I,{variant:`outline`,className:`border-emerald-500/30 bg-emerald-500/10 text-[10px] text-emerald-400`,children:`mcp`}),(0,V.jsx)(Kf,{source:`profile`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:t}),!e.readOnly&&(0,V.jsx)(L,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-5 w-5`,onClick:()=>e.onRemove(t),children:(0,V.jsx)(Oe,{className:`h-3 w-3`})})]},t)),e.adding&&(0,V.jsxs)(`div`,{className:`mt-1.5 space-y-2 rounded border border-border bg-card/60 p-2`,children:[e.loading&&(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Loading...`}),e.fetchError&&(0,V.jsx)(`div`,{className:`text-xs text-destructive`,children:e.fetchError}),!e.loading&&e.caps.length===0&&!e.fetchError&&(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No MCP capabilities in registry`}),e.caps.length>0&&(0,V.jsx)(`div`,{className:`max-h-44 space-y-0.5 overflow-y-auto rounded border border-border/60 bg-background/40 p-1`,children:e.caps.map(t=>(0,V.jsxs)(`button`,{type:`button`,onClick:()=>e.onAddMcp(t),className:`w-full rounded px-2 py-1 text-left font-mono text-xs hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:[t.capability.slug,t.capability.title?` - ${t.capability.title}`:``,t.variants.length>0&&(0,V.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,Yf(t),`)`]})]},t.capability.id))}),(0,V.jsx)(L,{type:`button`,variant:`ghost`,size:`sm`,className:`mt-1 h-6 text-xs`,onClick:e.onCancel,children:`Cancel`})]})]})}function ep(e){let t=Ot();return e&&e!==`any`&&t.includes(e)?e:t[0]??``}function tp({profile:e}){let[t,n]=(0,B.useState)(()=>ep(e.provider)),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(null);async function l(r=t){if(e.name.trim()){o(!0),c(null);try{let t=await Qe(`GET`,`/agent-profiles/${encodeURIComponent(e.name)}/resolved?provider=${encodeURIComponent(r)}`);n(t.provider),i(t.profile.provisioning??{skills:[],plugins:[],mcpServers:{}})}catch(e){c(At(e)),i(null)}finally{o(!1)}}}let u=e.relay.tools?.groups??[],d=u.length?u.join(`, `):`all groups`,f=Object.keys(r?.mcpServers??{});return(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)($,{children:`Provider`}),(0,V.jsx)(Wf,{value:t,onChange:e=>{n(e),l(e)},options:Ot().map(e=>({value:e,label:Tt(e)}))})]}),(0,V.jsx)(L,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void l(),disabled:a||!e.name.trim(),children:a?`Resolving...`:`Resolve`})]}),s&&(0,V.jsx)(`div`,{className:`rounded border border-destructive/40 bg-destructive/10 px-2 py-1 text-xs text-destructive`,children:s}),(0,V.jsxs)(`div`,{className:`rounded border border-border bg-muted/20 p-2`,children:[(0,V.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:`Relay tool surface`}),(0,V.jsx)(`div`,{className:`mt-1 font-mono text-xs`,children:d})]}),!r&&!s&&(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Resolve this profile to inspect materialized provisioning.`}),r&&(0,V.jsxs)(`div`,{className:`grid gap-2`,children:[(0,V.jsx)(np,{title:`Skills`,values:r.skills.map(e=>e.name),empty:`No resolved skills`}),(0,V.jsx)(np,{title:`Plugins`,values:r.plugins.map(e=>e.name),empty:`No resolved plugins`}),(0,V.jsx)(np,{title:`MCP Servers`,values:f,empty:`No resolved MCP servers`}),(r.skipped?.length??0)>0&&(0,V.jsxs)(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 p-2`,children:[(0,V.jsx)(`div`,{className:`text-xs font-medium text-amber-300`,children:`Skipped`}),(0,V.jsx)(`div`,{className:`mt-1 space-y-1`,children:r.skipped.map(e=>(0,V.jsxs)(`div`,{className:`text-xs`,children:[(0,V.jsxs)(`span`,{className:`font-mono`,children:[e.kind,`:`,e.ref]}),(0,V.jsxs)(`span`,{className:`text-muted-foreground`,children:[` - `,e.detail]})]},`${e.kind}:${e.ref}:${e.reason}`))})]})]})]})}function np({title:e,values:t,empty:n}){return(0,V.jsxs)(`div`,{className:`rounded border border-border bg-card/60 p-2`,children:[(0,V.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:e}),t.length===0?(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n}):(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map((e,t)=>(0,V.jsx)(I,{variant:`outline`,className:`font-mono text-[10px]`,children:e},`${e}:${t}`))})]})}function rp({title:e,children:t,defaultOpen:n=!0}){let[r,i]=(0,B.useState)(n);return(0,V.jsxs)(`div`,{className:`border border-border rounded-md`,children:[(0,V.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,V.jsx)(ct,{className:`h-3.5 w-3.5`}):(0,V.jsx)(D,{className:`h-3.5 w-3.5`}),e]}),r&&(0,V.jsx)(`div`,{className:`space-y-3 border-t border-border px-3 py-3`,children:t})]})}function ip({value:e,onChange:t,options:n,disabled:r}){return(0,V.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,V.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function ap({env:e,onChange:t,disabled:n}){let r=Object.entries(e),[i,a]=(0,B.useState)(``),[o,s]=(0,B.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,V.jsxs)(`div`,{className:`space-y-1.5`,children:[r.map(([e,t])=>(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsxs)(`code`,{className:`min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 text-xs`,children:[e,`=`,t]}),!n&&(0,V.jsx)(L,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-6 w-6 shrink-0`,onClick:()=>l(e),children:(0,V.jsx)(Oe,{className:`h-3 w-3`})})]},e)),!n&&(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(R,{value:i,onChange:e=>a(e.target.value),placeholder:`KEY`,className:`flex-1 text-xs font-mono`}),(0,V.jsx)(R,{value:o,onChange:e=>s(e.target.value),placeholder:`value`,className:`flex-1 text-xs font-mono`,onKeyDown:e=>e.key===`Enter`&&c()}),(0,V.jsx)(L,{type:`button`,variant:`outline`,size:`icon-sm`,className:`h-8 w-8 shrink-0`,onClick:c,children:(0,V.jsx)(de,{className:`h-3 w-3`})})]}),r.length===0&&n&&(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No environment variables`})]})}var op=[{value:`host`,label:`Host — full access, relay-aware`},{value:`minimal`,label:`Minimal — relay disabled, repo-scoped`},{value:`isolated`,label:`Isolated — strict isolation`},{value:`vanilla`,label:`Vanilla — zero host bleed (plugins/skills/hooks/MCP/CLAUDE.md off)`}],sp=[{value:`any`,label:`Any provider`},...Ot().map(e=>({value:e,label:Tt(e)}))],cp=[{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`}],lp=[{value:`host`,label:`Host — full filesystem`},{value:`workspace`,label:`Workspace — working directory tree`},{value:`repo`,label:`Repo — repository root only`}],up=[{value:`allow`,label:`Allow`},{value:`ignore`,label:`Ignore`}],dp=[{value:``,label:`Default`},{value:`open`,label:`Open — allow all`},{value:`guarded`,label:`Guarded — prompt for risky`},{value:`read-only`,label:`Read-only`}],fp={context:`Injects relay's context preamble each turn (memory + situational awareness).`,skills:`Makes the bundled Agent Relay skills available to the agent.`,plugins:`Loads the bundled Agent Relay Claude plugin (session registration, approval hooks).`,statusLine:`Enables the relay status-line probe (quota + context-window reporting).`,mcp:`Master switch for relay's own MCP tools (relay_* — messaging, memory, spawn, etc.). One of three independent MCP sources, alongside Project MCP (the project's .mcp.json) and MCP Mode (the host's ambient MCP).`},pp={context:`Context`,skills:`Skills`,plugins:`Plugins`,statusLine:`Status Line`,mcp:`MCP Tools`};function mp({values:e,onChange:t,disabled:n,placeholder:r}){let[i,a]=(0,B.useState)(``);function o(){let n=i.trim();n&&(t([...e,n]),a(``))}function s(n,r){t(e.map((e,t)=>t===n?r:e))}function c(n){t(e.filter((e,t)=>t!==n))}return(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[e.map((e,t)=>(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(R,{value:e,onChange:e=>s(t,e.target.value),disabled:n,className:`flex-1 text-xs`}),!n&&(0,V.jsx)(L,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-6 w-6 shrink-0`,onClick:()=>c(t),children:(0,V.jsx)(Oe,{className:`h-3 w-3`})})]},`${e}-${t}`)),!n&&(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(R,{value:i,onChange:e=>a(e.target.value),placeholder:r,className:`flex-1 text-xs`,onKeyDown:e=>e.key===`Enter`&&o()}),(0,V.jsx)(L,{type:`button`,variant:`outline`,size:`icon-sm`,className:`h-8 w-8 shrink-0`,onClick:o,children:(0,V.jsx)(de,{className:`h-3 w-3`})})]}),e.length===0&&n&&(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`None`})]})}function hp(){let{open:e,mode:t,profile:n}=j(e=>e.profileModal),r=j(e=>e.closeProfileModal),i=j(e=>e.updateProfileModal),a=j(e=>e.saveProfile),o=t===`view`,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,t){let r=n.relay.tools?.groups??[],i=t?[...new Set([...r,e])]:r.filter(t=>t!==e);u({tools:i.length?{groups:i}:void 0})}function f(e){i({projectMcp:Uf(e)})}function p(e){i({projectSkills:Uf(e)})}function m(e){i({projectSettings:Uf(e)})}function h(e){i({sharedMcp:Uf(e)})}function g(e){i({permissions:{...n.permissions,...e}})}function _(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 v(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 y(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 b=n.providerOptions?.codex&&typeof n.providerOptions.codex==`object`&&!Array.isArray(n.providerOptions.codex)?n.providerOptions.codex:{},x=Number.isSafeInteger(b.toolOutputTokenLimit)?String(b.toolOutputTokenLimit):``;return(0,V.jsx)(of,{open:e,onOpenChange:e=>!e&&r(),children:(0,V.jsxs)(lf,{className:`max-w-2xl max-h-[90vh] overflow-y-auto`,children:[(0,V.jsx)(uf,{children:(0,V.jsxs)(ff,{className:`flex items-center gap-2`,children:[c,n.builtIn&&(0,V.jsx)(I,{variant:`secondary`,className:`text-[10px]`,children:`Built-in`})]})}),(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(rp,{title:`General`,defaultOpen:!0,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Name`}),(0,V.jsx)(R,{value:n.name,onChange:e=>i({name:e.target.value}),placeholder:`my-profile`,disabled:o||t===`edit`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Description`}),(0,V.jsx)(R,{value:n.description||``,onChange:e=>i({description:e.target.value}),placeholder:`What this profile configures`,disabled:o})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(Ff,{tip:`Emoji shown across the dashboard wherever an agent on this profile appears (conversation rows, agent cards, chat header). A single emoji; leave blank for a neutral marker.`,children:`Icon`}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(R,{value:n.icon||``,onChange:e=>i({icon:e.target.value}),placeholder:`🤖`,maxLength:8,disabled:o,className:`w-24 text-center text-base`}),(0,V.jsx)(`span`,{className:`text-2xl leading-none`,"aria-hidden":!0,children:n.icon?.trim()||`•`})]})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Base`}),(0,V.jsx)(ip,{value:n.base,onChange:e=>y(e),options:op,disabled:o})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Provider`}),(0,V.jsx)(ip,{value:n.provider||`any`,onChange:e=>i({provider:e}),options:sp,disabled:o})]})]})]}),(0,V.jsxs)(rp,{title:`Instructions`,defaultOpen:!1,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`System Prompt`}),(0,V.jsx)(Vd,{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,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Append Instructions`}),(0,V.jsx)(mp,{values:n.instructions.append??[],onChange:e=>l({append:e}),disabled:o,placeholder:`Append instruction fragment`})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Repo Instructions`}),(0,V.jsx)(ip,{value:n.instructions.repoInstructions,onChange:e=>l({repoInstructions:e}),options:up,disabled:o})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Global Instructions`}),(0,V.jsx)(ip,{value:n.instructions.globalInstructions,onChange:e=>l({globalInstructions:e}),options:up,disabled:o})]})]})]}),(0,V.jsxs)(rp,{title:`Relay Integration`,defaultOpen:!1,children:[(0,V.jsxs)(`p`,{className:`rounded border border-border bg-muted/20 px-2 py-1.5 text-xs text-muted-foreground`,children:[`MCP comes from three independent sources — relay (`,(0,V.jsx)(`span`,{className:`font-medium text-foreground`,children:`MCP Tools`}),` below), the project (`,(0,V.jsx)(`span`,{className:`font-medium text-foreground`,children:`Project MCP`}),` in Provisioning Policies), and the host (`,(0,V.jsx)(`span`,{className:`font-medium text-foreground`,children:`MCP Mode`}),` in MCP & Hooks). Toggle each separately and mix freely.`]}),(0,V.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[`context`,`skills`,`plugins`,`statusLine`,`mcp`].map(e=>(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsx)(Ff,{tip:fp[e],children:pp[e]}),(0,V.jsx)(dl,{checked:n.relay[e]??!0,onCheckedChange:t=>u({[e]:t}),disabled:o})]},e))}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(Ff,{tip:`Pick which subsets of relay's MCP tools the agent gets. No groups selected = the full relay tool surface.`,children:`Relay Tool Groups`}),(0,V.jsx)(`div`,{className:`mt-1 grid grid-cols-2 gap-1.5`,children:If.map(e=>(0,V.jsxs)(`label`,{className:`flex items-center gap-2 rounded border border-border px-2 py-1 text-xs`,children:[(0,V.jsx)(`input`,{type:`checkbox`,className:`rounded`,checked:(n.relay.tools?.groups??[]).includes(e),onChange:t=>d(e,t.target.checked),disabled:o}),(0,V.jsx)(`span`,{className:`font-mono`,children:e})]},e))}),(0,V.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`No groups selected means full relay MCP tool surface.`})]})]}),(0,V.jsx)(rp,{title:`MCP & Hooks`,defaultOpen:!1,children:(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(Ff,{tip:`The host's ambient MCP servers (your rig's configured MCP). Host = inherit them; None = no host MCP (clean, no bleed). Separate from relay's own MCP and the project's MCP.`,children:`MCP Mode`}),(0,V.jsx)(ip,{value:n.mcp.mode,onChange:e=>i({mcp:{...n.mcp,mode:e}}),options:cp,disabled:o})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(Ff,{tip:`The host's hook configuration. Host = inherit it; None = no host hooks.`,children:`Hooks Mode`}),(0,V.jsx)(ip,{value:n.hooks.mode,onChange:e=>i({hooks:{mode:e}}),options:cp,disabled:o})]})]})}),(0,V.jsx)(rp,{title:`Provisioning Policies`,defaultOpen:!1,children:(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(Ff,{tip:`Injects the MCP servers declared in the spawn directory's project .mcp.json, via relay's controlled config path (survives --strict-mcp-config, no trust modal). All = every declared server. This is the project's MCP source — distinct from relay's MCP Tools and the host's MCP Mode.`,children:`Project MCP`}),(0,V.jsx)(ip,{value:Hf(n.projectMcp),onChange:f,options:Lf,disabled:o})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(Ff,{tip:`Injects skills committed under the project's .claude/skills.`,children:`Project Skills`}),(0,V.jsx)(ip,{value:Hf(n.projectSkills),onChange:p,options:Lf,disabled:o})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(Ff,{tip:`Injects the project's .claude/settings.json (permission/security keys stripped).`,children:`Project Settings`}),(0,V.jsx)(ip,{value:Hf(n.projectSettings),onChange:m,options:Rf,disabled:o})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(Ff,{tip:`Routes the agent's non-identity MCP through one shared orchestrator listener so the MCP session survives restarts and keeps correct worktree-cwd routing. A transport choice, not a source selector.`,children:`Shared MCP`}),(0,V.jsx)(ip,{value:Hf(n.sharedMcp),onChange:h,options:Lf,disabled:o})]}),(0,V.jsxs)(`div`,{className:`col-span-2`,children:[(0,V.jsx)(Ff,{tip:`How the agent's isolated branch lands: Direct (rebase/FF), Pull request, or the instance default.`,children:`Landing Strategy`}),(0,V.jsx)(ip,{value:n.landingStrategy??``,onChange:e=>i({landingStrategy:e||void 0}),options:zf,disabled:o})]})]})}),(0,V.jsx)(rp,{title:`Permissions`,defaultOpen:!1,children:(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Approval Mode`}),(0,V.jsx)(ip,{value:n.permissions.mode||``,onChange:e=>g({mode:e||void 0}),options:dp,disabled:o})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Filesystem Scope`}),(0,V.jsx)(ip,{value:n.permissions.filesystem,onChange:e=>g({filesystem:e}),options:lp,disabled:o})]})]})}),(0,V.jsx)(rp,{title:`Spawning`,defaultOpen:!1,children:(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Spawn Quota`}),(0,V.jsx)(R,{type:`number`,min:0,max:100,step:1,value:n.maxSpawnedAgents===void 0?``:String(n.maxSpawnedAgents),onChange:e=>v(e.target.value),placeholder:`0`,disabled:o}),(0,V.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,V.jsx)(rp,{title:`Environment Variables`,defaultOpen:!1,children:(0,V.jsx)(ap,{env:n.env||{},onChange:e=>i({env:e}),disabled:o})}),(0,V.jsx)(rp,{title:`Registry Capabilities`,defaultOpen:!1,children:(0,V.jsx)(qf,{skills:n.skills??[],plugins:n.plugins??[],mcp:n.mcp,onChangeSkills:e=>i({skills:e}),onChangePlugins:e=>i({plugins:e}),onChangeMcp:e=>i({mcp:e}),projectMcp:n.projectMcp,projectSkills:n.projectSkills,projectSettings:n.projectSettings,sharedMcp:n.sharedMcp,readOnly:o})}),(0,V.jsx)(rp,{title:`Resolved Provisioning`,defaultOpen:t===`view`,children:(0,V.jsx)(tp,{profile:n})}),(0,V.jsxs)(rp,{title:`Provider Options`,defaultOpen:!1,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)($,{children:`Codex Tool Output Limit`}),(0,V.jsx)(R,{type:`number`,min:1e3,max:2e5,value:x,onChange:e=>_(e.target.value),placeholder:`12000`,disabled:o})]}),(0,V.jsx)(Vd,{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,V.jsxs)(df,{children:[(0,V.jsx)(L,{variant:`outline`,onClick:r,children:`Cancel`}),(0,V.jsx)(L,{onClick:a,children:s?`Create`:`Save`})]})]})})}function gp(){let e=j(e=>e.commandPaletteOpen),t=j(e=>e.commandQuery),n=j(e=>e.set),r=j(e=>e.closeCommandPalette),i=j(e=>e.runCommand),a=ll(),o=(0,B.useRef)(null);return(0,B.useEffect)(()=>{e&&setTimeout(()=>o.current?.focus(),50)},[e]),e?(0,V.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,onClick:e=>{e.target===e.currentTarget&&r()},children:[(0,V.jsx)(`div`,{className:`fixed inset-0 bg-black/60`}),(0,V.jsxs)(`div`,{className:`relative w-full max-w-lg bg-card border border-border rounded-xl shadow-2xl overflow-hidden`,children:[(0,V.jsx)(`div`,{className:`p-3 border-b border-border`,children:(0,V.jsx)(R,{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,V.jsxs)(`div`,{className:`max-h-80 overflow-y-auto p-2`,children:[a.map(e=>(0,V.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,V.jsx)(nt[e.icon]||D,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-sm`,children:e.title}),e.subtitle&&(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:e.subtitle})]})]},e.id)),a.length===0&&(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`No matching commands.`})]})]})]}):null}function _p(){let e=j(e=>e.set),t=j(e=>e.connected);return(0,V.jsxs)(`div`,{className:`xl:hidden shrink-0 sticky top-0 z-30 bg-card border-b border-border px-4 h-[var(--header-h)] flex items-center gap-3`,children:[(0,V.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,V.jsx)(Ge,{className:`w-5 h-5`})}),(0,V.jsx)(oe,{className:`w-4 h-4 text-primary`}),(0,V.jsx)(`span`,{className:`font-bold text-sm`,children:`Agent Relay`}),(0,V.jsx)(`span`,{className:`ml-auto w-2 h-2 rounded-full ${t?`bg-emerald-500`:`bg-red-500 animate-pulse`}`})]})}function vp(e){return e===`five_hour`?`5h burst`:e===`seven_day`?`7-day`:e===`seven_day_sonnet`?`7-day Sonnet`:e===`seven_day_opus`?`7-day Opus`:e===`primary`?`Primary`:e===`secondary`?`Secondary`:e}function yp(e,t){if(!t)return``;let n=Math.max(0,(t-e)/1e3);if(n<60)return`${Math.floor(n)}s`;if(n<3600)return`${Math.floor(n/60)}m`;if(n<86400){let e=Math.floor(n/3600),t=Math.round(n%3600/60);return t===60?`${e+1}h`:t>0?`${e}h ${t}m`:`${e}h`}let r=Math.floor(n/86400),i=Math.round(n%86400/3600);return i===24?`${r+1}d`:i>0?`${r}d ${i}h`:`${r}d`}var bp=`agent-relay:quota-widget`,xp=300*1e3,Sp=8;function Cp(e){return!e.quota&&e.lastError?.type===`unavailable`}function wp(e,t){let n=t===`5h`?[`five_hour`,`primary`]:[`seven_day`,`secondary`];return e.quota?.windows.find(e=>n.includes(e.name))}function Tp(e,t){if(!t)return``;let n=Math.max(0,(t-e)/1e3);return n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.round(n/3600)}h`:`${(n/86400).toFixed(1).replace(/\.0$/,``)}d`}function Ep({record:e,now:t,advisory:n}){let r=(0,V.jsx)(Tu,{provider:e.provider,className:`w-3.5 h-3.5`});if(Cp(e))return(0,V.jsxs)(`span`,{className:`flex items-center gap-1 shrink-0 text-muted-foreground`,children:[r,(0,V.jsx)(`span`,{className:`italic`,children:`unavailable`})]});if(!e.quota){let n=e.lastAttemptAt?M(t,e.lastAttemptAt):``,i=e.lastError?.retryAfterMs,a=i==null?null:Math.ceil(Math.max(0,(e.lastAttemptAt+i-t)/1e3));return(0,V.jsxs)(`span`,{className:`flex items-center gap-1 shrink-0 text-muted-foreground`,children:[r,n&&(0,V.jsx)(`span`,{children:n}),a!=null&&a>0&&(0,V.jsxs)(`span`,{className:`text-amber-400/70`,children:[`~`,a,`s`]})]})}let i=wp(e,`5h`),a=wp(e,`7d`);function o(e){if(!e)return null;let n=Math.round(e.utilization*100),r=Tp(t,e.resetsAt);return(0,V.jsxs)(`span`,{className:`tabular-nums`,children:[n,`%`,r?`/${r}`:``]})}let s=(e.stale||e.lastError)&&e.lastAttemptAt?M(t,e.lastAttemptAt):``;return(0,V.jsxs)(`span`,{className:`flex items-center gap-1.5 shrink-0 text-foreground/70`,children:[r,(0,V.jsx)(Mp,{advisory:n}),o(i),o(a),s&&(0,V.jsx)(`span`,{className:`text-muted-foreground/70`,children:s})]})}function Dp(){try{let e=localStorage.getItem(bp);return{open:!0,pinned:!1,...e?JSON.parse(e):{}}}catch{return{open:!0,pinned:!1}}}function Op(e){try{localStorage.setItem(bp,JSON.stringify(e))}catch{}}function kp(){let[{open:e,pinned:t},n]=(0,B.useState)(Dp),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(`loading`),d=yt(),f=j(e=>e.connected);(0,B.useEffect)(()=>{if(!f)return;let e=!1;async function t(){try{let[t,n,r]=await Promise.all([Qe(`GET`,`/provider-quotas`),Qe(`GET`,`/providers/quota-config`).catch(()=>null),Qe(`GET`,`/provider-quotas/advisory`).catch(()=>null)]);e||(i(t),o(n),c(r),u(`ok`))}catch{e||u(`error`)}}t();let n=setInterval(()=>void t(),xp);return()=>{e=!0,clearInterval(n)}},[f,j(e=>e.quotaSeq)]);let p=e||t,m=(r?.quotas??[]).filter(e=>a?.[e.provider]?.showInWidget!==!1),h=m.some(e=>e.stale&&!Cp(e)),g=m.some(e=>e.lastError&&!Cp(e));function _(){if(t)return;let r={open:!e,pinned:t};n(r),Op(r)}function v(){let r=t?{open:e,pinned:!1}:{open:!0,pinned:!0};n(r),Op(r)}return(0,V.jsxs)(`div`,{className:`shrink-0 border-b border-border`,children:[(0,V.jsxs)(`div`,{className:`w-full flex items-center gap-2 px-4 py-2 text-xs hover:bg-muted/30 transition-colors`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:_,"aria-expanded":p,className:`min-w-0 flex flex-1 items-center gap-2 text-left`,children:[(0,V.jsx)(D,{className:`w-3.5 h-3.5 shrink-0 text-muted-foreground transition-transform ${p?`rotate-90`:``}`}),(0,V.jsx)(`span`,{className:`font-semibold text-foreground/80 shrink-0 ${p?``:`hidden sm:inline`}`,children:`Provider Quotas`}),l===`loading`&&(0,V.jsx)(A,{className:`w-3 h-3 text-muted-foreground animate-spin`}),l===`error`&&(0,V.jsx)(`span`,{className:`text-amber-400 text-[10px]`,children:`● unavailable`}),!p&&l===`ok`&&m.length>0&&(0,V.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-0.5 text-[10px]`,children:m.map(e=>(0,V.jsx)(Ep,{record:e,now:d,advisory:s?.advisories[e.provider]},`${e.provider}:${e.accountKey}`))}),p&&h&&(0,V.jsx)(`span`,{className:`text-amber-400 text-[10px]`,children:`● stale`}),p&&g&&(0,V.jsx)(`span`,{className:`text-red-400 text-[10px]`,children:`● error`})]}),(0,V.jsx)(`button`,{type:`button`,onClick:v,"aria-pressed":t,title:t?`Unpin`:`Pin always-on`,className:`p-0.5 rounded hover:bg-muted transition-colors ${t?`text-primary`:`text-muted-foreground/50 hover:text-muted-foreground`}`,children:(0,V.jsx)(fe,{className:`w-3 h-3`})})]}),p&&(0,V.jsxs)(`div`,{className:`px-4 py-3`,children:[l===`loading`&&(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-1.5`,children:[(0,V.jsx)(A,{className:`w-3 h-3 animate-spin`}),`Loading quota data…`]}),l===`error`&&(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Quota data unavailable — check that you are authenticated and the server is reachable.`}),l===`ok`&&r!==null&&m.length===0&&(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No quota data yet — waiting for runner to report.`}),l===`ok`&&r!==null&&m.length>0&&(0,V.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3`,children:m.map(e=>{let t=a?.[e.provider],n={enabled:t?.sparklineEnabled??!0,rangeHours:t?.sparklineRangeHours??Sp};return(0,V.jsx)(Ip,{record:e,now:d,advisory:s?.advisories[e.provider],sparklineCfg:n},`${e.provider}:${e.accountKey}`)})})]})]})}var Ap={prefer:{icon:ut,badge:`text-emerald-400 bg-emerald-500/10 border-emerald-500/20`,dot:`bg-emerald-400`},caution:{icon:s,badge:`text-amber-400 bg-amber-500/10 border-amber-500/20`,dot:`bg-amber-400`},"avoid-large":{icon:s,badge:`text-orange-400 bg-orange-500/10 border-orange-500/20`,dot:`bg-orange-400`},"hard-avoid":{icon:je,badge:`text-red-400 bg-red-500/10 border-red-500/20`,dot:`bg-red-400`}};function jp({advisory:e}){if(!e)return null;if(e.blockedNow)return(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[9px] font-medium text-red-400 bg-red-500/10 border border-red-500/20 rounded px-1 py-0.5 shrink-0`,children:[(0,V.jsx)(je,{className:`w-2.5 h-2.5`}),`at capacity`]});let t=e.quotaPenaltyBand;if(t===`normal`)return null;let n=Ap[t],r=n.icon;return(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[9px] font-medium ${n.badge} border rounded px-1 py-0.5 shrink-0`,children:[(0,V.jsx)(r,{className:`w-2.5 h-2.5`}),t]})}function Mp({advisory:e}){if(!e)return null;if(e.blockedNow)return(0,V.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-red-500 shrink-0`,title:`at capacity`});let t=e.quotaPenaltyBand;return t===`normal`?null:(0,V.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${Ap[t].dot} shrink-0`,title:t})}function Np(e,t){if(!e||e.confidence===`low`||e.burnRatio===null)return null;let n=e.burnRatio.toFixed(1);return!e.earlyWallMs||e.earlyWallMs<=0?`${n}× rate`:`${n}× · ~${yp(t,t+e.earlyWallMs)} before reset`}function Pp({burnWindow:e,now:t}){if(!e)return null;if(e.confidence===`low`||e.burnRatio===null)return(0,V.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-muted-foreground/50`,children:[(0,V.jsx)(Se,{className:`w-2.5 h-2.5 shrink-0`}),(0,V.jsx)(`span`,{className:`italic`,children:`building burn history…`})]});let n=Np(e,t);return n?(0,V.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-muted-foreground/70 tabular-nums`,children:[(0,V.jsx)(s,{className:`w-2.5 h-2.5 shrink-0`}),(0,V.jsx)(`span`,{children:n})]}):null}function Fp({provider:e,windowName:t,rangeHours:n}){let[r,i]=(0,B.useState)([]);yt(),(0,B.useEffect)(()=>{let r=!1,a=Date.now()-n*36e5;return Qe(`GET`,`/provider-quotas/history?provider=${encodeURIComponent(e)}&sinceMs=${a}&limit=500`).then(e=>{r||i(e.filter(e=>!!e.quota).map(e=>{let n=e.quota.windows.find(e=>e.name===t);return n?{t:e.capturedAt,v:n.utilization}:null}).filter(Boolean))}).catch(()=>{}),()=>{r=!0}},[e,t,n]);let a=(0,B.useMemo)(()=>{if(r.length<2)return null;let e=r[0].t,t=r[r.length-1].t-e||1;return r.map(n=>{let r=1+(n.t-e)/t*118,i=1+(1-n.v)*22;return`${r.toFixed(1)},${i.toFixed(1)}`}).join(` `)},[r]);if(!a)return null;let o=r.length>0?Math.round(r[r.length-1].v*100):0;return(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(`svg`,{width:120,height:24,viewBox:`0 0 120 24`,className:`shrink-0`,children:(0,V.jsx)(`polyline`,{points:a,fill:`none`,stroke:o>=90?`#ef4444`:o>=70?`#f59e0b`:`#10b981`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,opacity:.8})}),(0,V.jsxs)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums`,children:[n,`h`]})]})}function Ip({record:e,now:t,advisory:n,sparklineCfg:r}){let{provider:i,accountKey:a,quota:o,stale:s,lastError:c,lastUpdatedAt:l,lastAttemptAt:u}=e;if(Cp(e))return(0,V.jsxs)(`div`,{className:`rounded border border-border bg-muted/20 p-3 space-y-1.5 opacity-70`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,V.jsx)(Tu,{provider:i,className:`w-3.5 h-3.5 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground bg-muted border border-border rounded px-1 py-0.5 shrink-0`,children:`unavailable`})]}),(0,V.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[`Quota unavailable — `,c?.message??`no readable credentials`]})]});let d=c?.retryAfterMs,f=d==null?null:Math.max(0,u+d-t),p=f==null?null:Math.ceil(f/1e3),m=(s||!!c)&&u>0;return(0,V.jsxs)(`div`,{className:`rounded border ${c?`border-red-500/30`:s?`border-amber-500/30`:`border-border`} bg-card p-3 space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,V.jsx)(Tu,{provider:i,className:`w-3.5 h-3.5`}),(0,V.jsx)(`span`,{className:`text-[10px] text-muted-foreground font-mono truncate`,children:a})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,V.jsx)(jp,{advisory:n}),s&&(0,V.jsx)(`span`,{className:`text-[9px] font-medium text-amber-400 bg-amber-500/10 border border-amber-500/20 rounded px-1 py-0.5`,children:`stale`}),c&&(0,V.jsx)(`span`,{className:`text-[9px] font-medium text-red-400 bg-red-500/10 border border-red-500/20 rounded px-1 py-0.5`,title:c.message,children:c.type===`rate_limited`?`429`:`err`})]})]}),o?(0,V.jsx)(`div`,{className:`space-y-1.5`,children:o.windows.map(n=>{let i=Math.round(n.utilization*100),a=i>=90?`bg-red-500`:i>=70?`bg-amber-500`:`bg-emerald-500`,o=n.resetsAt?yp(t,n.resetsAt):``,s=e.burn?.windows.find(e=>e.name===n.name);return(0,V.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,V.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground`,children:[(0,V.jsx)(`span`,{children:vp(n.name)}),(0,V.jsxs)(`span`,{children:[i,`%`,o?` · resets in ${o}`:``]})]}),(0,V.jsx)(`div`,{className:`h-1.5 rounded-full bg-muted overflow-hidden`,children:(0,V.jsx)(`div`,{className:`h-full ${a} transition-all duration-500`,style:{width:`${Math.max(0,Math.min(100,i))}%`}})}),(0,V.jsx)(Pp,{burnWindow:s,now:t}),r?.enabled&&(0,V.jsx)(Fp,{provider:e.provider,windowName:n.name,rangeHours:r.rangeHours})]},n.name)})}):(0,V.jsx)(`p`,{className:`text-[10px] text-muted-foreground italic`,children:c?c.message:`No quota data`}),(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-2 text-[10px] text-muted-foreground/60`,children:[(0,V.jsxs)(`div`,{className:`space-y-0.5 min-w-0`,children:[m&&(0,V.jsxs)(`div`,{children:[`Attempted `,M(t,u)]}),(0,V.jsx)(`div`,{children:l?`Updated ${M(t,l)}`:`Never updated`})]}),p!=null&&(0,V.jsx)(`span`,{className:`text-amber-400/70 shrink-0 mt-0.5`,children:p>0?`retry in ~${p>60?`${Math.ceil(p/60)}m`:`${p}s`}`:`retrying…`})]})]})}function Lp(e){return(0,B.lazy)(()=>er(e))}var Rp=Lp(()=>z(()=>import(`./overview-DyiH9eVP.js`).then(e=>({default:e.OverviewView})),__vite__mapDeps([16,1,6,8,9,10,17,12,18]),import.meta.url)),zp=Lp(()=>z(()=>import(`./chat-CP4x6Gcr.js`).then(e=>({default:e.ChatView})),__vite__mapDeps([19,1,6,20,8,9,10,21,22,23,24,25,11,12,17,26,13]),import.meta.url)),Bp=Lp(()=>z(()=>import(`./agents-Bu1i1jH-.js`).then(e=>({default:e.AgentsView})),__vite__mapDeps([27,1,28,29,6,12,30,20,31,32,33,34,35,8,9,10,24,25,11,17,18]),import.meta.url)),Vp=Lp(()=>z(()=>import(`./managed-agents-YKqARLQn.js`).then(e=>({default:e.ManagedAgentsView})),__vite__mapDeps([36,1,6,8,9,10,25,11,12,17]),import.meta.url)),Hp=Lp(()=>z(()=>import(`./teams-CIqsg55S.js`).then(e=>({default:e.TeamsView})),__vite__mapDeps([37,1,38,28,29,6,12,30,20,31,32,39,40,41,33,35,42,8,9,10,23,17,11,18,26]),import.meta.url)),Up=Lp(()=>z(()=>import(`./agent-profiles-DzkjQaCS.js`).then(e=>({default:e.AgentProfilesView})),__vite__mapDeps([43,1,6,8,9,10,17,12,11]),import.meta.url)),Wp=Lp(()=>z(()=>import(`./orchestrators-CW00iA0W.js`).then(e=>({default:e.OrchestratorsView})),__vite__mapDeps([44,6,1,8,9,10,17,12,11,18]),import.meta.url)),Gp=Lp(()=>z(()=>import(`./workspaces-EI4N2N7L.js`).then(e=>({default:e.WorkspacesView})),__vite__mapDeps([45,1,6,8,9,10,25,11,12,17,18]),import.meta.url)),Kp=Lp(()=>z(()=>import(`./channels-IdC7jyLt.js`).then(e=>({default:e.ChannelsView})),__vite__mapDeps([46,6,1,8,9,10,17,12,11,18]),import.meta.url)),qp=Lp(()=>z(()=>import(`./connectors-Dngl_FJz.js`).then(e=>({default:e.ConnectorsView})),__vite__mapDeps([47,6,1,8,9,10,17,12,11,18]),import.meta.url)),Jp=Lp(()=>z(()=>import(`./integrations-BlSadMFC.js`).then(e=>({default:e.IntegrationsView})),__vite__mapDeps([48,6,1,8,9,10,17,12,11,18]),import.meta.url)),Yp=Lp(()=>z(()=>import(`./security-B0FTbGXU.js`).then(e=>({default:e.SecurityView})),__vite__mapDeps([49,1,6,25,11,12,17,18,26]),import.meta.url)),Xp=Lp(()=>z(()=>import(`./memory-BlftQACU.js`).then(e=>({default:e.MemoryView})),__vite__mapDeps([50,1,6,8,9,10,17,12,11,18,26]),import.meta.url)),Zp=Lp(()=>z(()=>import(`./activity-CBjg7NSP.js`).then(e=>({default:e.ActivityView})),__vite__mapDeps([51,1,6,8,9,10,21,22,17,12,11,18]),import.meta.url)),Qp=Lp(()=>z(()=>import(`./pairs-Ee8Npq67.js`).then(e=>({default:e.PairsView})),__vite__mapDeps([52,6,1,8,9,10,17,12,11,18]),import.meta.url)),$p=Lp(()=>z(()=>import(`./messages-DQu0Np7r.js`).then(e=>({default:e.MessagesView})),__vite__mapDeps([53,1,6,8,9,10,17,12,11,18]),import.meta.url)),em=Lp(()=>z(()=>import(`./work-queue-XWcDwe8G.js`).then(e=>({default:e.WorkQueueView})),__vite__mapDeps([54,6,1,8,9,10,17,12,11,18]),import.meta.url)),tm=Lp(()=>z(()=>import(`./tasks-BvDfBcxZ.js`).then(e=>({default:e.TasksView})),__vite__mapDeps([55,1,6,8,9,10,17,12,11,18]),import.meta.url)),nm=Lp(()=>z(()=>import(`./automation-CcMveyvi.js`).then(e=>({default:e.AutomationView})),__vite__mapDeps([56,1,6,8,9,10,17,12,11,18,26]),import.meta.url)),rm=Lp(()=>z(()=>import(`./analytics-Cc2GoEq_.js`).then(e=>({default:e.AnalyticsView})),__vite__mapDeps([57,1,6,8,9,10,18,58]),import.meta.url)),im=Lp(()=>z(()=>import(`./insights-Du9X-nwA.js`).then(e=>({default:e.InsightsView})),__vite__mapDeps([59,1,6,17,12,11,18,26,9,10]),import.meta.url)),am=Lp(()=>z(()=>import(`./projects-CqeJsfB6.js`).then(e=>({default:e.ProjectsView})),__vite__mapDeps([60,1,6,8,9,10,25,11,12,17,18]),import.meta.url)),om=Lp(()=>z(()=>import(`./prompt-settings-0fHJtGD5.js`).then(e=>({default:e.PromptSettingsView})),__vite__mapDeps([61,1,6,17,12,11,18,9,10]),import.meta.url)),sm=Lp(()=>z(()=>import(`./registry-QTLN8Jy-.js`).then(e=>({default:e.RegistryView})),__vite__mapDeps([62,1,6,17,12,11,18,26,10]),import.meta.url)),cm=Lp(()=>z(()=>import(`./maintenance-KeCPGZG4.js`).then(e=>({default:e.MaintenanceView})),__vite__mapDeps([63,1,6,8,9,10,17,12,11]),import.meta.url)),lm=Lp(()=>z(()=>import(`./settings-B2UEpdBi.js`).then(e=>({default:e.SettingsView})),__vite__mapDeps([64,1,38,28,29,6,12,30,20,31,32,39,40,41,33,35,42,8,9,10,22,17,11,18,26,58]),import.meta.url)),um=class extends B.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary]`,e.message,`
|
|
22
22
|
`,t.componentStack)}render(){return this.state.error?Zn(this.state.error)?(0,V.jsxs)(`div`,{className:`p-6 text-sm`,children:[(0,V.jsx)(`h2`,{className:`text-foreground text-lg mb-2`,children:`A new version was deployed`}),(0,V.jsx)(`p`,{className:`text-muted-foreground mb-4`,children:`Reload to pick up the latest dashboard.`}),(0,V.jsx)(`button`,{className:`px-3 py-1 bg-primary text-primary-foreground rounded text-sm`,onClick:()=>window.location.reload(),children:`Reload`})]}):(0,V.jsxs)(`div`,{className:`p-6 text-sm font-mono whitespace-pre-wrap`,children:[(0,V.jsx)(`h2`,{className:`text-red-400 text-lg mb-2`,children:`Dashboard Error`}),(0,V.jsx)(`p`,{className:`text-foreground mb-4`,children:this.state.error.message}),(0,V.jsx)(`pre`,{className:`text-muted-foreground text-xs overflow-auto`,children:this.state.error.stack}),(0,V.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}},dm={overview:Rp,chat:zp,agents:Bp,managed:Vp,teams:Hp,profiles:Up,orchestrators:Wp,workspaces:Gp,files:au,channels:Kp,connectors:qp,integrations:Jp,security:Yp,memory:Xp,activity:Zp,pairs:Qp,messages:$p,work:em,tasks:tm,automation:nm,analytics:rm,insights:im,projects:am,prompts:om,registry:sm,maintenance:cm,settings:lm},fm=`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 pm(){return(0,V.jsxs)(`div`,{className:`flex items-center justify-center py-16 text-muted-foreground text-sm`,children:[(0,V.jsx)(`span`,{className:`inline-block w-3 h-3 mr-2 rounded-full bg-muted-foreground/60 animate-pulse`}),`Loading…`]})}function mm(){let e=j(e=>e.notification),t=j(e=>e.toastNotification),n=j(e=>e.openNotification),r=j(e=>e.dismissToast);if(t){let e=t;return(0,V.jsxs)(`div`,{className:`${fm} 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,V.jsxs)(`button`,{type:`button`,onClick:()=>{n(e),r()},className:`flex-1 min-w-0 text-left cursor-pointer`,children:[(0,V.jsx)(`div`,{className:`font-medium truncate`,children:e.title}),(0,V.jsx)(`div`,{className:`text-xs text-zinc-300 line-clamp-2 mt-0.5`,children:e.body}),(0,V.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-zinc-400 mt-1`,children:`Tap to open`})]}),(0,V.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,V.jsx)(`div`,{className:`${fm} px-4 py-2 bg-zinc-800 text-zinc-100 text-sm rounded-md shadow-lg border border-zinc-700`,children:e}):null}function hm(){let e=j(e=>e.init),t=j(e=>e.destroy),n=j(e=>e.theme),r=j(e=>e.view),i=j(e=>e.authNeeded),a=j(e=>e.connectionError),o=j(e=>e.authToken),s=j(e=>e.set),c=j(e=>e.saveTokenAndRefresh),l=j(e=>e.openCommandPalette),u=j(e=>e.commandPaletteOpen),d=j(e=>e.closeCommandPalette);(0,B.useEffect)(()=>{fn(n)},[n]),(0,B.useEffect)(()=>(e(),()=>t()),[]),(0,B.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=dm[r]||Rp;return(0,V.jsx)(um,{children:(0,V.jsx)(Kc,{children:(0,V.jsxs)(`div`,{className:`flex min-h-[calc(100dvh-var(--sat))] mt-[var(--sat)]`,children:[(0,V.jsx)(Tl,{}),(0,V.jsx)(El,{}),(0,V.jsxs)(`main`,{className:`flex-1 min-w-0 h-[calc(100dvh-var(--sat))] flex flex-col overflow-y-auto`,children:[(0,V.jsx)(_p,{}),!i&&a&&(0,V.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 p-3 bg-amber-950/40 border-b border-amber-800/60 text-amber-200 text-sm`,children:[(0,V.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,V.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 p-3 bg-card border-b border-border`,children:[(0,V.jsx)(Te,{className:`w-4 h-4 text-muted-foreground`}),(0,V.jsx)(R,{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,V.jsx)(L,{size:`sm`,onClick:c,children:`Connect`})]}),(0,V.jsx)(kp,{}),(0,V.jsx)(`div`,{className:r===`chat`?`flex min-h-0 flex-1 flex-col`:`p-4 md:p-6`,children:(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(pm,{}),children:(0,V.jsx)(f,{})})})]}),(0,V.jsx)(wd,{}),(0,V.jsx)(Bd,{}),(0,V.jsx)(Jd,{}),(0,V.jsx)(mf,{}),(0,V.jsx)(hf,{}),(0,V.jsx)(gf,{}),(0,V.jsx)(_f,{}),(0,V.jsx)(vf,{}),(0,V.jsx)(yf,{}),(0,V.jsx)(bf,{}),(0,V.jsx)(xf,{}),(0,V.jsx)(Cf,{}),(0,V.jsx)(kf,{}),(0,V.jsx)(Mf,{}),(0,V.jsx)(Nf,{}),(0,V.jsx)(hp,{}),(0,V.jsx)(ou,{}),(0,V.jsx)(gp,{}),(0,V.jsx)(mm,{})]})})})}if((0,Jn.createRoot)(document.getElementById(`root`)).render((0,V.jsx)(B.StrictMode,{children:(0,V.jsx)(hm,{})})),`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{nu as A,dl as B,ju as C,Fu as D,Lu as E,hl as F,al as G,tl as H,gl as I,Qc as J,rl as K,vl as L,J as M,Ll as N,Ou as O,pl as P,tr as Q,ml as R,Au as S,Ru as T,nl as U,Zc as V,il as W,sl as X,ol as Y,cl as Z,Qu as _,uf as a,X as b,$ as c,Cd as d,Q as f,sd as g,bd as h,df as i,ru as j,bu as k,Vd as l,xd as m,lf as n,ff as o,yd as p,Xc as q,pf as r,Ud as s,of as t,Rd as u,qu as v,Bu as w,ku as x,Ku as y,fl as z};
|
|
23
|
-
//# sourceMappingURL=index-
|
|
23
|
+
//# sourceMappingURL=index-DocqZ4Q0.js.map
|