apteva 0.4.53 → 0.4.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/{ActivityPage.sw9p594m.js → ActivityPage.k33hj12v.js} +1 -1
  2. package/dist/{ApiDocsPage.90e03bz7.js → ApiDocsPage.q37747gr.js} +1 -1
  3. package/dist/{App.9t1zc5r7.js → App.3hp80jc2.js} +13 -13
  4. package/dist/{App.pse0pzar.js → App.5ebcd85d.js} +1 -1
  5. package/dist/{App.p7jjw1zf.js → App.6fefs2d5.js} +1 -1
  6. package/dist/{App.tm3k7h4b.js → App.794kjn6a.js} +1 -1
  7. package/dist/{App.ysxy7akk.js → App.c5ebgvec.js} +1 -1
  8. package/dist/App.cb1np6f0.js +20 -0
  9. package/dist/{App.jhb45d7r.js → App.ccs4g85x.js} +1 -1
  10. package/dist/{App.9sryp183.js → App.g1qhcmpc.js} +1 -1
  11. package/dist/{App.r43t58w6.js → App.jemr4v3a.js} +2 -2
  12. package/dist/{App.vkg121c6.js → App.kpyf0grm.js} +1 -1
  13. package/dist/{App.stgng5bx.js → App.p7zc1bv2.js} +1 -1
  14. package/dist/{App.xva0tfzh.js → App.qx4wdtjg.js} +1 -1
  15. package/dist/{App.yzkh4gq2.js → App.wjxmwjrp.js} +1 -1
  16. package/dist/{App.3vnrera5.js → App.wq1f2jke.js} +1 -1
  17. package/dist/{App.pfbdzrhh.js → App.zx6x0gk2.js} +1 -1
  18. package/dist/ConnectionsPage.8b2v07qp.js +3 -0
  19. package/dist/McpPage.3800a82c.js +3 -0
  20. package/dist/SettingsPage.88nj3hbv.js +3 -0
  21. package/dist/SkillsPage.b8pxj5mb.js +3 -0
  22. package/dist/TasksPage.6b3y4b1n.js +3 -0
  23. package/dist/TelemetryPage.7q4d69wj.js +3 -0
  24. package/dist/TestsPage.dpevv5xb.js +3 -0
  25. package/dist/ThreadsPage.1h15363y.js +3 -0
  26. package/dist/index.html +1 -1
  27. package/package.json +1 -1
  28. package/src/mcp-platform.ts +75 -9
  29. package/src/routes/api/telemetry.ts +0 -7
  30. package/src/web/components/telemetry/TelemetryPage.tsx +13 -10
  31. package/src/web/context/TelemetryContext.tsx +4 -1
  32. package/dist/App.94x6mh7f.js +0 -20
  33. package/dist/ConnectionsPage.q5f9fd37.js +0 -3
  34. package/dist/McpPage.f3ccrezb.js +0 -3
  35. package/dist/SettingsPage.zmzm1pp6.js +0 -3
  36. package/dist/SkillsPage.whxnez67.js +0 -3
  37. package/dist/TasksPage.zp4jfevw.js +0 -3
  38. package/dist/TelemetryPage.an0ky78c.js +0 -3
  39. package/dist/TestsPage.18krj0d1.js +0 -3
  40. package/dist/ThreadsPage.nnphgy98.js +0 -3
@@ -1,4 +1,4 @@
1
- import{a as Dr}from"./App.xva0tfzh.js";import"./App.pse0pzar.js";import{f as E9,g as R7,h as E5}from"./App.yzkh4gq2.js";import"./App.3vnrera5.js";import"./App.tm3k7h4b.js";import{A as g9,B as F9,C as A9,D as T9,E as X1,G as V9,H as D9,I as j9,J as n9,K as C9,k as Q1,l as it,m as H7,n as W7,o as U7,p as r0,q as Nm,r as v0,s as b0,t as wt,u as Y1,v as f0,w as P9,x as I9,y as i0,z as w0}from"./App.9sryp183.js";import"./App.stgng5bx.js";import"./App.pfbdzrhh.js";import{N as d7,O as s5}from"./App.vkg121c6.js";import{Q as x9,R as ur}from"./App.ysxy7akk.js";import"./App.9t1zc5r7.js";import{U as ct}from"./App.p7jjw1zf.js";import{V as uY}from"./App.jhb45d7r.js";import{$ as Do,X as Ga,Y as G7,_ as Mm,aa as vo,ba as pz,ca as u5,da as W1,ea as B1,fa as $1,ga as mz,ha as N9,ia as d9,ja as $o,ka as tz,la as M9,ma as vp,na as rz,oa as xr,pa as L7}from"./App.94x6mh7f.js";var B9=G7((SY)=>{(function(){function c(){if(oa=!1,V){var C=SY.unstable_now();ra=C;var T=!0;try{a:{ma=!1,wa&&(wa=!1,La(Ca),Ca=-1),qa=!0;var va=s;try{o:{y(C);for(P=_(k);P!==null&&!(P.expirationTime>C&&G());){var Pa=P.callback;if(typeof Pa==="function"){P.callback=null,s=P.priorityLevel;var xa=Pa(P.expirationTime<=C);if(C=SY.unstable_now(),typeof xa==="function"){P.callback=xa,y(C),T=!0;break o}P===_(k)&&U(k),y(C)}else U(k);P=_(k)}if(P!==null)T=!0;else{var So=_(x);So!==null&&N(H,So.startTime-C),T=!1}}break a}finally{P=null,s=va,qa=!1}T=void 0}}finally{T?O():V=!1}}}function Z(C,T){var va=C.length;C.push(T);a:for(;0<va;){var Pa=va-1>>>1,xa=C[Pa];if(0<h(xa,T))C[Pa]=T,C[va]=xa,va=Pa;else break a}}function _(C){return C.length===0?null:C[0]}function U(C){if(C.length===0)return null;var T=C[0],va=C.pop();if(va!==T){C[0]=va;a:for(var Pa=0,xa=C.length,So=xa>>>1;Pa<So;){var $p=2*(Pa+1)-1,S=C[$p],_a=$p+1,sa=C[_a];if(0>h(S,va))_a<xa&&0>h(sa,S)?(C[Pa]=sa,C[_a]=va,Pa=_a):(C[Pa]=S,C[$p]=va,Pa=$p);else if(_a<xa&&0>h(sa,va))C[Pa]=sa,C[_a]=va,Pa=_a;else break a}}return T}function h(C,T){var va=C.sortIndex-T.sortIndex;return va!==0?va:C.id-T.id}function y(C){for(var T=_(x);T!==null;){if(T.callback===null)U(x);else if(T.startTime<=C)U(x),T.sortIndex=T.expirationTime,Z(k,T);else break;T=_(x)}}function H(C){if(wa=!1,y(C),!ma)if(_(k)!==null)ma=!0,V||(V=!0,O());else{var T=_(x);T!==null&&N(H,T.startTime-C)}}function G(){return oa?!0:SY.unstable_now()-ra<L?!1:!0}function N(C,T){Ca=e(function(){C(SY.unstable_now())},T)}if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart==="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()),SY.unstable_now=void 0,typeof performance==="object"&&typeof performance.now==="function"){var I=performance;SY.unstable_now=function(){return I.now()}}else{var W=Date,A=W.now();SY.unstable_now=function(){return W.now()-A}}var k=[],x=[],M=1,P=null,s=3,qa=!1,ma=!1,wa=!1,oa=!1,e=typeof setTimeout==="function"?setTimeout:null,La=typeof clearTimeout==="function"?clearTimeout:null,ha=typeof setImmediate<"u"?setImmediate:null,V=!1,Ca=-1,L=5,ra=-1;if(typeof ha==="function")var O=function(){ha(c)};else if(typeof MessageChannel<"u"){var d=new MessageChannel,fa=d.port2;d.port1.onmessage=c,O=function(){fa.postMessage(null)}}else O=function(){e(c,0)};SY.unstable_IdlePriority=5,SY.unstable_ImmediatePriority=1,SY.unstable_LowPriority=4,SY.unstable_NormalPriority=3,SY.unstable_Profiling=null,SY.unstable_UserBlockingPriority=2,SY.unstable_cancelCallback=function(C){C.callback=null},SY.unstable_forceFrameRate=function(C){0>C||125<C?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<C?Math.floor(1000/C):5},SY.unstable_getCurrentPriorityLevel=function(){return s},SY.unstable_next=function(C){switch(s){case 1:case 2:case 3:var T=3;break;default:T=s}var va=s;s=T;try{return C()}finally{s=va}},SY.unstable_requestPaint=function(){oa=!0},SY.unstable_runWithPriority=function(C,T){switch(C){case 1:case 2:case 3:case 4:case 5:break;default:C=3}var va=s;s=C;try{return T()}finally{s=va}},SY.unstable_scheduleCallback=function(C,T,va){var Pa=SY.unstable_now();switch(typeof va==="object"&&va!==null?(va=va.delay,va=typeof va==="number"&&0<va?Pa+va:Pa):va=Pa,C){case 1:var xa=-1;break;case 2:xa=250;break;case 5:xa=1073741823;break;case 4:xa=1e4;break;default:xa=5000}return xa=va+xa,C={id:M++,callback:T,priorityLevel:C,startTime:va,expirationTime:xa,sortIndex:-1},va>Pa?(C.sortIndex=va,Z(x,C),_(k)===null&&C===_(x)&&(wa?(La(Ca),Ca=-1):wa=!0,N(H,va-Pa))):(C.sortIndex=xa,Z(k,C),ma||qa||(ma=!0,V||(V=!0,O()))),C},SY.unstable_shouldYield=G,SY.unstable_wrapCallback=function(C){var T=s;return function(){var va=s;s=T;try{return C.apply(this,arguments)}finally{s=va}}},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop==="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()});var K9=G7((xY)=>{var Fa=Ga(B9()),t0=Ga(Do()),_7=Ga(uY());(function(){function c(a,o){for(a=a.memoizedState;a!==null&&0<o;)a=a.next,o--;return a}function Z(a,o,p,m){if(p>=o.length)return m;var t=o[p],r=yo(a)?a.slice():da({},a);return r[t]=Z(a[t],o,p+1,m),r}function _(a,o,p){if(o.length!==p.length)console.warn("copyWithRename() expects paths of the same length");else{for(var m=0;m<p.length-1;m++)if(o[m]!==p[m]){console.warn("copyWithRename() expects paths to be the same except for the deepest key");return}return U(a,o,p,0)}}function U(a,o,p,m){var t=o[m],r=yo(a)?a.slice():da({},a);return m+1===o.length?(r[p[m]]=r[t],yo(r)?r.splice(t,1):delete r[t]):r[t]=U(a[t],o,p,m+1),r}function h(a,o,p){var m=o[p],t=yo(a)?a.slice():da({},a);if(p+1===o.length)return yo(t)?t.splice(m,1):delete t[m],t;return t[m]=h(a[m],o,p+1),t}function y(){return!1}function H(){return null}function G(){console.error("Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. You can only call Hooks at the top level of your React function. For more information, see https://react.dev/link/rules-of-hooks")}function N(){console.error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().")}function I(){}function W(){}function A(a){var o=[];return a.forEach(function(p){o.push(p)}),o.sort().join(", ")}function k(a,o,p,m){return new kz(a,o,p,m)}function x(a,o){a.context===ht&&(F3(a.current,2,o,a,null,null),Jv())}function M(a,o){if(gp!==null){var p=o.staleFamilies;o=o.updatedFamilies,P0(),R6(a.current,o,p),Jv()}}function P(a){gp=a}function s(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function qa(a){var o=a,p=a;if(a.alternate)for(;o.return;)o=o.return;else{a=o;do o=a,(o.flags&4098)!==0&&(p=o.return),a=o.return;while(a)}return o.tag===3?p:null}function ma(a){if(a.tag===13){var o=a.memoizedState;if(o===null&&(a=a.alternate,a!==null&&(o=a.memoizedState)),o!==null)return o.dehydrated}return null}function wa(a){if(a.tag===31){var o=a.memoizedState;if(o===null&&(a=a.alternate,a!==null&&(o=a.memoizedState)),o!==null)return o.dehydrated}return null}function oa(a){if(qa(a)!==a)throw Error("Unable to find node on an unmounted component.")}function e(a){var o=a.alternate;if(!o){if(o=qa(a),o===null)throw Error("Unable to find node on an unmounted component.");return o!==a?null:a}for(var p=a,m=o;;){var t=p.return;if(t===null)break;var r=t.alternate;if(r===null){if(m=t.return,m!==null){p=m;continue}break}if(t.child===r.child){for(r=t.child;r;){if(r===p)return oa(t),a;if(r===m)return oa(t),o;r=r.sibling}throw Error("Unable to find node on an unmounted component.")}if(p.return!==m.return)p=t,m=r;else{for(var v=!1,b=t.child;b;){if(b===p){v=!0,p=t,m=r;break}if(b===m){v=!0,m=t,p=r;break}b=b.sibling}if(!v){for(b=r.child;b;){if(b===p){v=!0,p=r,m=t;break}if(b===m){v=!0,m=r,p=t;break}b=b.sibling}if(!v)throw Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.")}}if(p.alternate!==m)throw Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.")}if(p.tag!==3)throw Error("Unable to find node on an unmounted component.");return p.stateNode.current===p?a:o}function La(a){var o=a.tag;if(o===5||o===26||o===27||o===6)return a;for(a=a.child;a!==null;){if(o=La(a),o!==null)return o;a=a.sibling}return null}function ha(a){if(a===null||typeof a!=="object")return null;return a=Mc&&a[Mc]||a["@@iterator"],typeof a==="function"?a:null}function V(a){if(a==null)return null;if(typeof a==="function")return a.$$typeof===oJ?null:a.displayName||a.name||null;if(typeof a==="string")return a;switch(a){case Qv:return"Fragment";case n3:return"Profiler";case fb:return"StrictMode";case u3:return"Suspense";case x3:return"SuspenseList";case V3:return"Activity"}if(typeof a==="object")switch(typeof a.tag==="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),a.$$typeof){case qv:return"Portal";case Km:return a.displayName||"Context";case S3:return(a._context.displayName||"Context")+".Consumer";case j0:var o=a.render;return a=a.displayName,a||(a=o.displayName||o.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case ib:return o=a.displayName||null,o!==null?o:V(a.type)||"Memo";case Bp:o=a._payload,a=a._init;try{return V(a(o))}catch(p){}}return null}function Ca(a){return typeof a.tag==="number"?L(a):typeof a.name==="string"?a.name:null}function L(a){var o=a.type;switch(a.tag){case 31:return"Activity";case 24:return"Cache";case 9:return(o._context.displayName||"Context")+".Consumer";case 10:return o.displayName||"Context";case 18:return"DehydratedFragment";case 11:return a=o.render,a=a.displayName||a.name||"",o.displayName||(a!==""?"ForwardRef("+a+")":"ForwardRef");case 7:return"Fragment";case 26:case 27:case 5:return o;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return V(o);case 8:return o===fb?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 14:case 15:if(typeof o==="function")return o.displayName||o.name||null;if(typeof o==="string")return o;break;case 29:if(o=a._debugInfo,o!=null){for(var p=o.length-1;0<=p;p--)if(typeof o[p].name==="string")return o[p].name}if(a.return!==null)return L(a.return)}return null}function ra(a){return{current:a}}function O(a,o){0>um?console.error("Unexpected pop."):(o!==j3[um]&&console.error("Unexpected Fiber popped."),a.current=D3[um],D3[um]=null,j3[um]=null,um--)}function d(a,o,p){um++,D3[um]=a.current,j3[um]=p,a.current=o}function fa(a){return a===null&&console.error("Expected host context to exist. This error is likely caused by a bug in React. Please file an issue."),a}function C(a,o){d(Ut,o,a),d(E0,a,a),d(Wt,null,a);var p=o.nodeType;switch(p){case 9:case 11:p=p===9?"#document":"#fragment",o=(o=o.documentElement)?(o=o.namespaceURI)?vc(o):vt:vt;break;default:if(p=o.tagName,o=o.namespaceURI)o=vc(o),o=bc(o,p);else switch(p){case"svg":o=p0;break;case"math":o=b1;break;default:o=vt}}p=p.toLowerCase(),p=a6(null,p),p={context:o,ancestorInfo:p},O(Wt,a),d(Wt,p,a)}function T(a){O(Wt,a),O(E0,a),O(Ut,a)}function va(){return fa(Wt.current)}function Pa(a){a.memoizedState!==null&&d(wb,a,a);var o=fa(Wt.current),p=a.type,m=bc(o.context,p);p=a6(o.ancestorInfo,p),m={context:m,ancestorInfo:p},o!==m&&(d(E0,a,a),d(Wt,m,a))}function xa(a){E0.current===a&&(O(Wt,a),O(E0,a)),wb.current===a&&(O(wb,a),A5._currentValue=Tr)}function So(){}function $p(){if(s0===0){gc=console.log,Fc=console.info,Cc=console.warn,Pc=console.error,Ic=console.group,Ac=console.groupCollapsed,Tc=console.groupEnd;var a={configurable:!0,enumerable:!0,value:So,writable:!0};Object.defineProperties(console,{info:a,log:a,warn:a,error:a,group:a,groupCollapsed:a,groupEnd:a})}s0++}function S(){if(s0--,s0===0){var a={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:da({},a,{value:gc}),info:da({},a,{value:Fc}),warn:da({},a,{value:Cc}),error:da({},a,{value:Pc}),group:da({},a,{value:Ic}),groupCollapsed:da({},a,{value:Ac}),groupEnd:da({},a,{value:Tc})})}0>s0&&console.error("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}function _a(a){var o=Error.prepareStackTrace;if(Error.prepareStackTrace=void 0,a=a.stack,Error.prepareStackTrace=o,a.startsWith(`Error: react-stack-top-frame
1
+ import{a as Dr}from"./App.qx4wdtjg.js";import"./App.5ebcd85d.js";import{f as E9,g as R7,h as E5}from"./App.wjxmwjrp.js";import"./App.wq1f2jke.js";import"./App.794kjn6a.js";import{A as g9,B as F9,C as A9,D as T9,E as X1,G as V9,H as D9,I as j9,J as n9,K as C9,k as Q1,l as it,m as H7,n as W7,o as U7,p as r0,q as Nm,r as v0,s as b0,t as wt,u as Y1,v as f0,w as P9,x as I9,y as i0,z as w0}from"./App.g1qhcmpc.js";import"./App.p7zc1bv2.js";import"./App.zx6x0gk2.js";import{N as d7,O as s5}from"./App.kpyf0grm.js";import{Q as x9,R as ur}from"./App.c5ebgvec.js";import"./App.3hp80jc2.js";import{U as ct}from"./App.6fefs2d5.js";import{V as uY}from"./App.ccs4g85x.js";import{$ as Do,X as Ga,Y as G7,_ as Mm,aa as vo,ba as pz,ca as u5,da as W1,ea as B1,fa as $1,ga as mz,ha as N9,ia as d9,ja as $o,ka as tz,la as M9,ma as vp,na as rz,oa as xr,pa as L7}from"./App.cb1np6f0.js";var B9=G7((SY)=>{(function(){function c(){if(oa=!1,V){var C=SY.unstable_now();ra=C;var T=!0;try{a:{ma=!1,wa&&(wa=!1,La(Ca),Ca=-1),qa=!0;var va=s;try{o:{y(C);for(P=_(k);P!==null&&!(P.expirationTime>C&&G());){var Pa=P.callback;if(typeof Pa==="function"){P.callback=null,s=P.priorityLevel;var xa=Pa(P.expirationTime<=C);if(C=SY.unstable_now(),typeof xa==="function"){P.callback=xa,y(C),T=!0;break o}P===_(k)&&U(k),y(C)}else U(k);P=_(k)}if(P!==null)T=!0;else{var So=_(x);So!==null&&N(H,So.startTime-C),T=!1}}break a}finally{P=null,s=va,qa=!1}T=void 0}}finally{T?O():V=!1}}}function Z(C,T){var va=C.length;C.push(T);a:for(;0<va;){var Pa=va-1>>>1,xa=C[Pa];if(0<h(xa,T))C[Pa]=T,C[va]=xa,va=Pa;else break a}}function _(C){return C.length===0?null:C[0]}function U(C){if(C.length===0)return null;var T=C[0],va=C.pop();if(va!==T){C[0]=va;a:for(var Pa=0,xa=C.length,So=xa>>>1;Pa<So;){var $p=2*(Pa+1)-1,S=C[$p],_a=$p+1,sa=C[_a];if(0>h(S,va))_a<xa&&0>h(sa,S)?(C[Pa]=sa,C[_a]=va,Pa=_a):(C[Pa]=S,C[$p]=va,Pa=$p);else if(_a<xa&&0>h(sa,va))C[Pa]=sa,C[_a]=va,Pa=_a;else break a}}return T}function h(C,T){var va=C.sortIndex-T.sortIndex;return va!==0?va:C.id-T.id}function y(C){for(var T=_(x);T!==null;){if(T.callback===null)U(x);else if(T.startTime<=C)U(x),T.sortIndex=T.expirationTime,Z(k,T);else break;T=_(x)}}function H(C){if(wa=!1,y(C),!ma)if(_(k)!==null)ma=!0,V||(V=!0,O());else{var T=_(x);T!==null&&N(H,T.startTime-C)}}function G(){return oa?!0:SY.unstable_now()-ra<L?!1:!0}function N(C,T){Ca=e(function(){C(SY.unstable_now())},T)}if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart==="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()),SY.unstable_now=void 0,typeof performance==="object"&&typeof performance.now==="function"){var I=performance;SY.unstable_now=function(){return I.now()}}else{var W=Date,A=W.now();SY.unstable_now=function(){return W.now()-A}}var k=[],x=[],M=1,P=null,s=3,qa=!1,ma=!1,wa=!1,oa=!1,e=typeof setTimeout==="function"?setTimeout:null,La=typeof clearTimeout==="function"?clearTimeout:null,ha=typeof setImmediate<"u"?setImmediate:null,V=!1,Ca=-1,L=5,ra=-1;if(typeof ha==="function")var O=function(){ha(c)};else if(typeof MessageChannel<"u"){var d=new MessageChannel,fa=d.port2;d.port1.onmessage=c,O=function(){fa.postMessage(null)}}else O=function(){e(c,0)};SY.unstable_IdlePriority=5,SY.unstable_ImmediatePriority=1,SY.unstable_LowPriority=4,SY.unstable_NormalPriority=3,SY.unstable_Profiling=null,SY.unstable_UserBlockingPriority=2,SY.unstable_cancelCallback=function(C){C.callback=null},SY.unstable_forceFrameRate=function(C){0>C||125<C?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<C?Math.floor(1000/C):5},SY.unstable_getCurrentPriorityLevel=function(){return s},SY.unstable_next=function(C){switch(s){case 1:case 2:case 3:var T=3;break;default:T=s}var va=s;s=T;try{return C()}finally{s=va}},SY.unstable_requestPaint=function(){oa=!0},SY.unstable_runWithPriority=function(C,T){switch(C){case 1:case 2:case 3:case 4:case 5:break;default:C=3}var va=s;s=C;try{return T()}finally{s=va}},SY.unstable_scheduleCallback=function(C,T,va){var Pa=SY.unstable_now();switch(typeof va==="object"&&va!==null?(va=va.delay,va=typeof va==="number"&&0<va?Pa+va:Pa):va=Pa,C){case 1:var xa=-1;break;case 2:xa=250;break;case 5:xa=1073741823;break;case 4:xa=1e4;break;default:xa=5000}return xa=va+xa,C={id:M++,callback:T,priorityLevel:C,startTime:va,expirationTime:xa,sortIndex:-1},va>Pa?(C.sortIndex=va,Z(x,C),_(k)===null&&C===_(x)&&(wa?(La(Ca),Ca=-1):wa=!0,N(H,va-Pa))):(C.sortIndex=xa,Z(k,C),ma||qa||(ma=!0,V||(V=!0,O()))),C},SY.unstable_shouldYield=G,SY.unstable_wrapCallback=function(C){var T=s;return function(){var va=s;s=T;try{return C.apply(this,arguments)}finally{s=va}}},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop==="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()});var K9=G7((xY)=>{var Fa=Ga(B9()),t0=Ga(Do()),_7=Ga(uY());(function(){function c(a,o){for(a=a.memoizedState;a!==null&&0<o;)a=a.next,o--;return a}function Z(a,o,p,m){if(p>=o.length)return m;var t=o[p],r=yo(a)?a.slice():da({},a);return r[t]=Z(a[t],o,p+1,m),r}function _(a,o,p){if(o.length!==p.length)console.warn("copyWithRename() expects paths of the same length");else{for(var m=0;m<p.length-1;m++)if(o[m]!==p[m]){console.warn("copyWithRename() expects paths to be the same except for the deepest key");return}return U(a,o,p,0)}}function U(a,o,p,m){var t=o[m],r=yo(a)?a.slice():da({},a);return m+1===o.length?(r[p[m]]=r[t],yo(r)?r.splice(t,1):delete r[t]):r[t]=U(a[t],o,p,m+1),r}function h(a,o,p){var m=o[p],t=yo(a)?a.slice():da({},a);if(p+1===o.length)return yo(t)?t.splice(m,1):delete t[m],t;return t[m]=h(a[m],o,p+1),t}function y(){return!1}function H(){return null}function G(){console.error("Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. You can only call Hooks at the top level of your React function. For more information, see https://react.dev/link/rules-of-hooks")}function N(){console.error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().")}function I(){}function W(){}function A(a){var o=[];return a.forEach(function(p){o.push(p)}),o.sort().join(", ")}function k(a,o,p,m){return new kz(a,o,p,m)}function x(a,o){a.context===ht&&(F3(a.current,2,o,a,null,null),Jv())}function M(a,o){if(gp!==null){var p=o.staleFamilies;o=o.updatedFamilies,P0(),R6(a.current,o,p),Jv()}}function P(a){gp=a}function s(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function qa(a){var o=a,p=a;if(a.alternate)for(;o.return;)o=o.return;else{a=o;do o=a,(o.flags&4098)!==0&&(p=o.return),a=o.return;while(a)}return o.tag===3?p:null}function ma(a){if(a.tag===13){var o=a.memoizedState;if(o===null&&(a=a.alternate,a!==null&&(o=a.memoizedState)),o!==null)return o.dehydrated}return null}function wa(a){if(a.tag===31){var o=a.memoizedState;if(o===null&&(a=a.alternate,a!==null&&(o=a.memoizedState)),o!==null)return o.dehydrated}return null}function oa(a){if(qa(a)!==a)throw Error("Unable to find node on an unmounted component.")}function e(a){var o=a.alternate;if(!o){if(o=qa(a),o===null)throw Error("Unable to find node on an unmounted component.");return o!==a?null:a}for(var p=a,m=o;;){var t=p.return;if(t===null)break;var r=t.alternate;if(r===null){if(m=t.return,m!==null){p=m;continue}break}if(t.child===r.child){for(r=t.child;r;){if(r===p)return oa(t),a;if(r===m)return oa(t),o;r=r.sibling}throw Error("Unable to find node on an unmounted component.")}if(p.return!==m.return)p=t,m=r;else{for(var v=!1,b=t.child;b;){if(b===p){v=!0,p=t,m=r;break}if(b===m){v=!0,m=t,p=r;break}b=b.sibling}if(!v){for(b=r.child;b;){if(b===p){v=!0,p=r,m=t;break}if(b===m){v=!0,m=r,p=t;break}b=b.sibling}if(!v)throw Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.")}}if(p.alternate!==m)throw Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.")}if(p.tag!==3)throw Error("Unable to find node on an unmounted component.");return p.stateNode.current===p?a:o}function La(a){var o=a.tag;if(o===5||o===26||o===27||o===6)return a;for(a=a.child;a!==null;){if(o=La(a),o!==null)return o;a=a.sibling}return null}function ha(a){if(a===null||typeof a!=="object")return null;return a=Mc&&a[Mc]||a["@@iterator"],typeof a==="function"?a:null}function V(a){if(a==null)return null;if(typeof a==="function")return a.$$typeof===oJ?null:a.displayName||a.name||null;if(typeof a==="string")return a;switch(a){case Qv:return"Fragment";case n3:return"Profiler";case fb:return"StrictMode";case u3:return"Suspense";case x3:return"SuspenseList";case V3:return"Activity"}if(typeof a==="object")switch(typeof a.tag==="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),a.$$typeof){case qv:return"Portal";case Km:return a.displayName||"Context";case S3:return(a._context.displayName||"Context")+".Consumer";case j0:var o=a.render;return a=a.displayName,a||(a=o.displayName||o.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case ib:return o=a.displayName||null,o!==null?o:V(a.type)||"Memo";case Bp:o=a._payload,a=a._init;try{return V(a(o))}catch(p){}}return null}function Ca(a){return typeof a.tag==="number"?L(a):typeof a.name==="string"?a.name:null}function L(a){var o=a.type;switch(a.tag){case 31:return"Activity";case 24:return"Cache";case 9:return(o._context.displayName||"Context")+".Consumer";case 10:return o.displayName||"Context";case 18:return"DehydratedFragment";case 11:return a=o.render,a=a.displayName||a.name||"",o.displayName||(a!==""?"ForwardRef("+a+")":"ForwardRef");case 7:return"Fragment";case 26:case 27:case 5:return o;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return V(o);case 8:return o===fb?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 14:case 15:if(typeof o==="function")return o.displayName||o.name||null;if(typeof o==="string")return o;break;case 29:if(o=a._debugInfo,o!=null){for(var p=o.length-1;0<=p;p--)if(typeof o[p].name==="string")return o[p].name}if(a.return!==null)return L(a.return)}return null}function ra(a){return{current:a}}function O(a,o){0>um?console.error("Unexpected pop."):(o!==j3[um]&&console.error("Unexpected Fiber popped."),a.current=D3[um],D3[um]=null,j3[um]=null,um--)}function d(a,o,p){um++,D3[um]=a.current,j3[um]=p,a.current=o}function fa(a){return a===null&&console.error("Expected host context to exist. This error is likely caused by a bug in React. Please file an issue."),a}function C(a,o){d(Ut,o,a),d(E0,a,a),d(Wt,null,a);var p=o.nodeType;switch(p){case 9:case 11:p=p===9?"#document":"#fragment",o=(o=o.documentElement)?(o=o.namespaceURI)?vc(o):vt:vt;break;default:if(p=o.tagName,o=o.namespaceURI)o=vc(o),o=bc(o,p);else switch(p){case"svg":o=p0;break;case"math":o=b1;break;default:o=vt}}p=p.toLowerCase(),p=a6(null,p),p={context:o,ancestorInfo:p},O(Wt,a),d(Wt,p,a)}function T(a){O(Wt,a),O(E0,a),O(Ut,a)}function va(){return fa(Wt.current)}function Pa(a){a.memoizedState!==null&&d(wb,a,a);var o=fa(Wt.current),p=a.type,m=bc(o.context,p);p=a6(o.ancestorInfo,p),m={context:m,ancestorInfo:p},o!==m&&(d(E0,a,a),d(Wt,m,a))}function xa(a){E0.current===a&&(O(Wt,a),O(E0,a)),wb.current===a&&(O(wb,a),A5._currentValue=Tr)}function So(){}function $p(){if(s0===0){gc=console.log,Fc=console.info,Cc=console.warn,Pc=console.error,Ic=console.group,Ac=console.groupCollapsed,Tc=console.groupEnd;var a={configurable:!0,enumerable:!0,value:So,writable:!0};Object.defineProperties(console,{info:a,log:a,warn:a,error:a,group:a,groupCollapsed:a,groupEnd:a})}s0++}function S(){if(s0--,s0===0){var a={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:da({},a,{value:gc}),info:da({},a,{value:Fc}),warn:da({},a,{value:Cc}),error:da({},a,{value:Pc}),group:da({},a,{value:Ic}),groupCollapsed:da({},a,{value:Ac}),groupEnd:da({},a,{value:Tc})})}0>s0&&console.error("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}function _a(a){var o=Error.prepareStackTrace;if(Error.prepareStackTrace=void 0,a=a.stack,Error.prepareStackTrace=o,a.startsWith(`Error: react-stack-top-frame
2
2
  `)&&(a=a.slice(29)),o=a.indexOf(`
3
3
  `),o!==-1&&(a=a.slice(o+1)),o=a.indexOf("react_stack_bottom_frame"),o!==-1&&(o=a.lastIndexOf(`
4
4
  `,o)),o!==-1)a=a.slice(0,o);else return"";return a}function sa(a){if(E3===void 0)try{throw Error()}catch(p){var o=p.stack.trim().match(/\n( *(at )?)/);E3=o&&o[1]||"",nc=-1<p.stack.indexOf(`
@@ -216,6 +216,6 @@ You might need to use a local HTTP server (instead of file://): https://react.de
216
216
  fixed inset-y-0 left-0 z-50 w-64 p-4 flex flex-col transform transition-transform duration-200 ease-in-out
217
217
  md:relative md:w-56 md:translate-x-0 md:z-auto
218
218
  ${h?"translate-x-0":"-translate-x-full"}
219
- `,style:{backgroundColor:"var(--color-bg)",borderRight:"1px solid var(--color-border)"},children:[$a.jsxDEV("div",{className:"flex items-center justify-between mb-4 md:hidden",children:[$a.jsxDEV("div",{className:"flex items-center gap-2",children:[$a.jsxDEV("span",{style:{color:"var(--color-accent)"},children:">_"},void 0,!1,void 0,this),$a.jsxDEV("span",{className:"text-lg tracking-wider",children:"apteva"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$a.jsxDEV("button",{onClick:y,className:"p-2 transition",style:{color:"var(--color-text-muted)"},children:$a.jsxDEV(it,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$a.jsxDEV("nav",{className:"space-y-1 flex-1",children:[$a.jsxDEV(xp,{icon:$a.jsxDEV(H7,{},void 0,!1,void 0,this),label:"Dashboard",active:c==="dashboard",onClick:()=>W("dashboard")},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(W7,{},void 0,!1,void 0,this),label:"Agents",active:c==="agents",onClick:()=>W("agents"),badge:Z>0?String(Z):void 0},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(n9,{},void 0,!1,void 0,this),label:"Threads",active:c==="threads",onClick:()=>W("threads")},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(X1,{},void 0,!1,void 0,this),label:"Activity",active:c==="activity",onClick:()=>W("activity")},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(Nm,{},void 0,!1,void 0,this),label:"Tasks",active:c==="tasks",onClick:()=>W("tasks"),badge:_&&_>0?String(_):void 0},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(wt,{},void 0,!1,void 0,this),label:"MCP",active:c==="mcp",onClick:()=>W("mcp")},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(Y1,{},void 0,!1,void 0,this),label:"Skills",active:c==="skills",onClick:()=>W("skills")},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(T9,{},void 0,!1,void 0,this),label:"Connections",active:c==="connections",onClick:()=>W("connections")},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(A9,{},void 0,!1,void 0,this),label:"Tests",active:c==="tests",onClick:()=>W("tests")},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(P9,{},void 0,!1,void 0,this),label:"Analytics",active:c==="analytics",onClick:()=>W("analytics")},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(I9,{},void 0,!1,void 0,this),label:"API",active:c==="api",onClick:()=>W("api")},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(U7,{},void 0,!1,void 0,this),label:"Settings",active:c==="settings",onClick:()=>W("settings")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H&&$a.jsxDEV("div",{className:"relative pt-3 mt-3",style:{borderTop:"1px solid var(--color-border)"},children:[$a.jsxDEV("button",{onClick:()=>I(!N),className:"w-full flex items-center gap-3 px-3 py-2 rounded transition",style:{color:"var(--color-text)"},onMouseEnter:(k)=>k.currentTarget.style.backgroundColor="var(--color-surface)",onMouseLeave:(k)=>k.currentTarget.style.backgroundColor="transparent",children:[$a.jsxDEV("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-black font-medium text-sm flex-shrink-0",style:{backgroundColor:"var(--color-accent)"},children:H.username.charAt(0).toUpperCase()},void 0,!1,void 0,this),$a.jsxDEV("div",{className:"flex-1 min-w-0 text-left",children:[$a.jsxDEV("p",{className:"text-sm font-medium truncate",children:H.username},void 0,!1,void 0,this),$a.jsxDEV("p",{className:"text-xs",style:{color:"var(--color-text-faint)"},children:H.role},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),N&&$a.jsxDEV($a.Fragment,{children:[$a.jsxDEV("div",{className:"fixed inset-0 z-40",onClick:()=>I(!1)},void 0,!1,void 0,this),$a.jsxDEV("div",{className:"absolute left-3 bottom-full mb-1 w-48 card shadow-xl z-50",style:{backgroundColor:"var(--color-surface)"},children:$a.jsxDEV("button",{onClick:A,className:"w-full px-4 py-2.5 text-left text-sm text-red-400 transition rounded-lg",onMouseEnter:(k)=>k.currentTarget.style.backgroundColor="var(--color-surface-raised)",onMouseLeave:(k)=>k.currentTarget.style.backgroundColor="transparent",children:"Sign out"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function xp({icon:c,label:Z,active:_,onClick:U,badge:h}){return $a.jsxDEV("button",{onClick:U,className:"w-full flex items-center gap-3 px-3 py-2 font-medium transition",style:{borderRadius:"var(--radius-button)",backgroundColor:_?"var(--color-surface)":"transparent",color:_?"var(--color-text)":"var(--color-text-muted)"},onMouseEnter:(y)=>{if(!_)y.currentTarget.style.backgroundColor="var(--color-surface)",y.currentTarget.style.color="var(--color-text-secondary)"},onMouseLeave:(y)=>{if(!_)y.currentTarget.style.backgroundColor="transparent",y.currentTarget.style.color="var(--color-text-muted)"},children:[c,Z,h&&$a.jsxDEV("span",{className:"ml-auto text-xs px-2 py-0.5 rounded-full",style:{backgroundColor:"var(--color-surface-raised)",color:"var(--color-text-secondary)"},children:h},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var x5=Ga(vo(),1);function G1({message:c,onDismiss:Z}){return x5.jsxDEV("div",{className:"bg-red-500/10 border-b border-red-500/30 px-6 py-3 text-red-400 text-sm flex items-center justify-between",children:[x5.jsxDEV("span",{children:c},void 0,!1,void 0,this),x5.jsxDEV("button",{onClick:Z,className:"hover:text-red-300",children:x5.jsxDEV(it,{className:"w-4 h-4"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var V5=Ga(Do(),1);var Ro=Ga(vo(),1);function _1(){let{login:c}=$o(),[Z,_]=V5.useState(""),[U,h]=V5.useState(""),[y,H]=V5.useState(null),[G,N]=V5.useState(!1);return Ro.jsxDEV("div",{className:"min-h-screen bg-[var(--color-bg)] text-[var(--color-text)] flex items-center justify-center p-8",children:Ro.jsxDEV("div",{className:"w-full max-w-md",children:[Ro.jsxDEV("div",{className:"text-center mb-8",children:[Ro.jsxDEV("div",{className:"flex items-center justify-center gap-2 mb-2",children:[Ro.jsxDEV("span",{className:"text-[var(--color-accent)] text-3xl",children:">_"},void 0,!1,void 0,this),Ro.jsxDEV("span",{className:"text-3xl tracking-wider",children:"apteva"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Ro.jsxDEV("p",{className:"text-[var(--color-text-muted)]",children:"Run AI agents locally"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Ro.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-8",children:[Ro.jsxDEV("h2",{className:"text-2xl font-semibold mb-2",children:"Welcome back"},void 0,!1,void 0,this),Ro.jsxDEV("p",{className:"text-[var(--color-text-muted)] mb-6",children:"Sign in to continue to apteva"},void 0,!1,void 0,this),Ro.jsxDEV("form",{onSubmit:async(W)=>{W.preventDefault(),H(null),N(!0);let A=await c(Z,U);if(!A.success)H(A.error||"Login failed");N(!1)},className:"space-y-4",children:[Ro.jsxDEV("div",{children:[Ro.jsxDEV("label",{htmlFor:"username",className:"block text-sm text-[var(--color-text-secondary)] mb-1",children:"Username"},void 0,!1,void 0,this),Ro.jsxDEV("input",{id:"username",type:"text",value:Z,onChange:(W)=>_(W.target.value),placeholder:"Enter your username",autoFocus:!0,required:!0,className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-4 py-3 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Ro.jsxDEV("div",{children:[Ro.jsxDEV("label",{htmlFor:"password",className:"block text-sm text-[var(--color-text-secondary)] mb-1",children:"Password"},void 0,!1,void 0,this),Ro.jsxDEV("input",{id:"password",type:"password",value:U,onChange:(W)=>h(W.target.value),placeholder:"Enter your password",required:!0,className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-4 py-3 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),y&&Ro.jsxDEV("div",{className:"p-3 bg-red-500/10 border border-red-500/30 rounded text-red-400 text-sm",children:y},void 0,!1,void 0,this),Ro.jsxDEV("button",{type:"submit",disabled:G||!Z||!U,className:"w-full bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 disabled:cursor-not-allowed text-black px-4 py-3 rounded font-medium transition",children:G?"Signing in...":"Sign In"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var or=Ga(Do(),1),oo=Ga(vo(),1);function q1({onComplete:c}){let[Z,_]=or.useState(""),[U,h]=or.useState(""),[y,H]=or.useState(""),[G,N]=or.useState(""),[I,W]=or.useState(!1),[A,k]=or.useState(null),[x,M]=or.useState(!1);return oo.jsxDEV(oo.Fragment,{children:[oo.jsxDEV("h2",{className:"text-2xl font-semibold mb-2",children:"Create your account"},void 0,!1,void 0,this),oo.jsxDEV("p",{className:"text-[var(--color-text-muted)] mb-6",children:"Set up your admin account to get started with apteva."},void 0,!1,void 0,this),oo.jsxDEV("form",{onSubmit:async(s)=>{if(s.preventDefault(),k(null),U!==y){k("Passwords do not match");return}M(!0);try{let qa=await fetch("/api/onboarding/user",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:Z,password:U,...G&&{email:G}})}),ma=await qa.json();if(!qa.ok){k(ma.error||"Failed to create account"),M(!1);return}let wa=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({username:Z,password:U})});if(!wa.ok){k("Account created but login failed. Please try logging in."),M(!1);return}let oa=await wa.json();if(oa.accessToken)sessionStorage.setItem("accessToken",oa.accessToken);c({username:Z})}catch(qa){k("Failed to create account"),M(!1)}},className:"space-y-4",children:[oo.jsxDEV("div",{children:[oo.jsxDEV("label",{htmlFor:"username",className:"block text-sm text-[var(--color-text-secondary)] mb-1",children:"Username"},void 0,!1,void 0,this),oo.jsxDEV("input",{id:"username",type:"text",value:Z,onChange:(s)=>_(s.target.value),placeholder:"Choose a username",autoFocus:!0,required:!0,className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-4 py-3 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this),oo.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] mt-1",children:"3-20 characters, letters, numbers, underscore"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),oo.jsxDEV("div",{children:[oo.jsxDEV("label",{htmlFor:"password",className:"block text-sm text-[var(--color-text-secondary)] mb-1",children:"Password"},void 0,!1,void 0,this),oo.jsxDEV("input",{id:"password",type:"password",value:U,onChange:(s)=>h(s.target.value),placeholder:"Enter a password",required:!0,className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-4 py-3 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this),oo.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] mt-1",children:"Min 8 characters, uppercase, lowercase, number"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),oo.jsxDEV("div",{children:[oo.jsxDEV("label",{htmlFor:"confirmPassword",className:"block text-sm text-[var(--color-text-secondary)] mb-1",children:"Confirm Password"},void 0,!1,void 0,this),oo.jsxDEV("input",{id:"confirmPassword",type:"password",value:y,onChange:(s)=>H(s.target.value),placeholder:"Confirm your password",required:!0,className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-4 py-3 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!I?oo.jsxDEV("button",{type:"button",onClick:()=>W(!0),className:"text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] transition",children:"+ Add email for password recovery (optional)"},void 0,!1,void 0,this):oo.jsxDEV("div",{children:[oo.jsxDEV("label",{htmlFor:"email",className:"block text-sm text-[var(--color-text-secondary)] mb-1",children:["Email ",oo.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"(optional)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),oo.jsxDEV("input",{id:"email",type:"email",value:G,onChange:(s)=>N(s.target.value),placeholder:"For password recovery only",className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-4 py-3 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this),oo.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] mt-1",children:"Only used for password recovery, never shared"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),A&&oo.jsxDEV("div",{className:"p-3 bg-red-500/10 border border-red-500/30 rounded text-red-400 text-sm",children:A},void 0,!1,void 0,this),oo.jsxDEV("button",{type:"submit",disabled:x||!Z||!U||!y,className:"w-full bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 disabled:cursor-not-allowed text-black px-4 py-3 rounded font-medium transition",children:x?"Creating account...":"Create Account"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),oo.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] mt-4 text-center",children:"This will be your admin account with full access to apteva."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Vp=Ga(Do(),1);var pa=Ga(vo(),1);function D5({onComplete:c,needsAccount:Z=!1}){let[_,U]=Vp.useState(Z?0:1),[h,y]=Vp.useState([]),[H,G]=Vp.useState(null),[N,I]=Vp.useState(""),[W,A]=Vp.useState(!1),[k,x]=Vp.useState(!1),[M,P]=Vp.useState(null),[s,qa]=Vp.useState(null),[ma,wa]=Vp.useState(!1),oa=()=>{let ra=sessionStorage.getItem("accessToken");return ra?{Authorization:`Bearer ${ra}`}:{}};Vp.useEffect(()=>{if(Z&&!ma&&_===0)return;fetch("/api/providers",{headers:oa()}).then((ra)=>ra.json()).then((ra)=>{let O=(ra.providers||[]).filter((d)=>d.type==="llm");y(O)})},[ma,_,Z]);let e=h.filter((ra)=>ra.hasKey),La=async()=>{if(!H||!N)return;A(!0),P(null),qa(null);try{x(!0);let O=await(await fetch(`/api/keys/${H}/test`,{method:"POST",headers:{"Content-Type":"application/json",...oa()},body:JSON.stringify({key:N})})).json();if(x(!1),!O.valid){P(O.error||"API key is invalid"),A(!1);return}let d=await fetch(`/api/keys/${H}`,{method:"POST",headers:{"Content-Type":"application/json",...oa()},body:JSON.stringify({key:N})}),fa=await d.json();if(!d.ok)P(fa.error||"Failed to save key");else{qa("API key saved successfully!"),I("");let T=await(await fetch("/api/providers",{headers:oa()})).json();y(T.providers||[]),G(null)}}catch(ra){P("Failed to save key")}A(!1)},ha=async()=>{try{let ra=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json",...oa()},body:JSON.stringify({name:"My Project",description:"Default project for organizing agents",color:"#f97316"})});if(ra.ok){let O=await ra.json();if(O.project?.id)localStorage.setItem("apteva_current_project",O.project.id)}}catch(ra){console.error("Failed to create default project:",ra)}await fetch("/api/onboarding/complete",{method:"POST",headers:oa()}),c()},V=()=>{wa(!0),U(1)},Ca=Z?3:2,L=Z?_:_-1;return pa.jsxDEV("div",{className:"min-h-screen bg-[var(--color-bg)] text-[var(--color-text)] flex items-center justify-center p-8",children:pa.jsxDEV("div",{className:"w-full max-w-2xl",children:[pa.jsxDEV("div",{className:"text-center mb-8",children:[pa.jsxDEV("div",{className:"flex items-center justify-center gap-2 mb-2",children:[pa.jsxDEV("span",{className:"text-[var(--color-accent)] text-3xl",children:">_"},void 0,!1,void 0,this),pa.jsxDEV("span",{className:"text-3xl tracking-wider",children:"apteva"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),pa.jsxDEV("p",{className:"text-[var(--color-text-muted)]",children:"Run AI agents locally"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),pa.jsxDEV("div",{className:"flex items-center justify-center gap-2 mb-8",children:[Z&&pa.jsxDEV(pa.Fragment,{children:[pa.jsxDEV("div",{className:`w-3 h-3 rounded-full ${_>=0?"bg-[var(--color-accent)]":"bg-[var(--color-surface-raised)]"}`},void 0,!1,void 0,this),pa.jsxDEV("div",{className:`w-16 h-0.5 ${_>=1?"bg-[var(--color-accent)]":"bg-[var(--color-surface-raised)]"}`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),pa.jsxDEV("div",{className:`w-3 h-3 rounded-full ${_>=1?"bg-[var(--color-accent)]":"bg-[var(--color-surface-raised)]"}`},void 0,!1,void 0,this),pa.jsxDEV("div",{className:`w-16 h-0.5 ${_>=2?"bg-[var(--color-accent)]":"bg-[var(--color-surface-raised)]"}`},void 0,!1,void 0,this),pa.jsxDEV("div",{className:`w-3 h-3 rounded-full ${_>=2?"bg-[var(--color-accent)]":"bg-[var(--color-surface-raised)]"}`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),pa.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-8",children:[_===0&&Z&&pa.jsxDEV(q1,{onComplete:V},void 0,!1,void 0,this),_===1&&pa.jsxDEV(EY,{providers:h,configuredProviders:e,selectedProvider:H,apiKey:N,saving:W,testing:k,error:M,success:s,onSelectProvider:G,onApiKeyChange:I,onSaveKey:La,onContinue:()=>U(2)},void 0,!1,void 0,this),_===2&&pa.jsxDEV(eY,{configuredProviders:e,onAddMore:()=>U(1),onComplete:ha},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function EY({providers:c,configuredProviders:Z,selectedProvider:_,apiKey:U,saving:h,testing:y,error:H,success:G,onSelectProvider:N,onApiKeyChange:I,onSaveKey:W,onContinue:A}){let k=c.find((x)=>x.id===_);if(_&&k)return pa.jsxDEV(pa.Fragment,{children:[pa.jsxDEV("h2",{className:"text-2xl font-semibold mb-2",children:["Add ",k.name," Key"]},void 0,!0,void 0,this),pa.jsxDEV("p",{className:"text-[var(--color-text-muted)] mb-6",children:"Enter your API key below. It will be encrypted and stored locally."},void 0,!1,void 0,this),pa.jsxDEV("div",{className:"mb-6",children:[pa.jsxDEV("div",{className:"p-4 rounded border border-[var(--color-accent)] bg-[var(--color-accent-5)] mb-4",children:pa.jsxDEV("div",{className:"flex items-center justify-between",children:[pa.jsxDEV("div",{children:[pa.jsxDEV("p",{className:"font-medium",children:k.name},void 0,!1,void 0,this),pa.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:[k.models.length," models available"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),pa.jsxDEV("a",{href:k.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:"Get API Key"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),pa.jsxDEV("div",{className:"space-y-3",children:[pa.jsxDEV("input",{type:"password",value:U,onChange:(x)=>I(x.target.value),placeholder:"Enter your API key...",autoFocus:!0,className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-4 py-3 focus:outline-none focus:border-[var(--color-accent)] text-lg"},void 0,!1,void 0,this),H&&pa.jsxDEV("p",{className:"text-red-400 text-sm",children:H},void 0,!1,void 0,this),G&&pa.jsxDEV("p",{className:"text-green-400 text-sm",children:G},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),pa.jsxDEV("div",{className:"flex gap-3",children:[pa.jsxDEV("button",{onClick:()=>{N(null),I("")},className:"flex-1 border border-[var(--color-border-light)] hover:border-[var(--color-text-muted)] px-4 py-3 rounded font-medium transition",children:"Back"},void 0,!1,void 0,this),pa.jsxDEV("button",{onClick:W,disabled:!U||h,className:"flex-1 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 disabled:cursor-not-allowed text-black px-4 py-3 rounded font-medium transition",children:y?"Testing...":h?"Saving...":"Save API Key"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);return pa.jsxDEV(pa.Fragment,{children:[pa.jsxDEV("h2",{className:"text-2xl font-semibold mb-2",children:"Welcome to apteva"},void 0,!1,void 0,this),pa.jsxDEV("p",{className:"text-[var(--color-text-muted)] mb-6",children:"To get started, you'll need to add at least one AI provider API key. Your keys are encrypted and stored locally."},void 0,!1,void 0,this),pa.jsxDEV("div",{className:"space-y-3 mb-6",children:c.map((x)=>pa.jsxDEV(sY,{provider:x,selected:!1,onSelect:()=>!x.hasKey&&N(x.id)},x.id,!1,void 0,this))},void 0,!1,void 0,this),pa.jsxDEV("button",{onClick:A,disabled:Z.length===0,className:"w-full bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] disabled:opacity-50 disabled:cursor-not-allowed px-4 py-3 rounded font-medium transition",children:Z.length===0?"Add at least one API key to continue":`Continue with ${Z.length} provider${Z.length>1?"s":""}`},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function sY({provider:c,selected:Z,onSelect:_}){return pa.jsxDEV("div",{onClick:_,className:`p-4 rounded border transition cursor-pointer ${c.hasKey?"border-green-500/30 bg-green-500/5":Z?"border-[var(--color-accent)] bg-[var(--color-accent-5)]":"border-[var(--color-border-light)] hover:border-[var(--color-border-light)]"}`,children:pa.jsxDEV("div",{className:"flex items-center justify-between",children:[pa.jsxDEV("div",{children:[pa.jsxDEV("p",{className:"font-medium",children:c.name},void 0,!1,void 0,this),pa.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:[c.models.length," models available"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),c.hasKey?pa.jsxDEV("span",{className:"text-green-400 text-sm flex items-center gap-1",children:[pa.jsxDEV(Q1,{},void 0,!1,void 0,this),"Configured (",c.keyHint,")"]},void 0,!0,void 0,this):pa.jsxDEV("a",{href:c.docsUrl,target:"_blank",rel:"noopener noreferrer",onClick:(U)=>U.stopPropagation(),className:"text-sm text-[#3b82f6] hover:underline",children:"Get API Key"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function eY({configuredProviders:c,onAddMore:Z,onComplete:_}){return pa.jsxDEV(pa.Fragment,{children:[pa.jsxDEV("h2",{className:"text-2xl font-semibold mb-2",children:"You're all set!"},void 0,!1,void 0,this),pa.jsxDEV("p",{className:"text-[var(--color-text-muted)] mb-6",children:["You've configured ",c.length," provider",c.length>1?"s":"",". You can add more providers later in Settings."]},void 0,!0,void 0,this),pa.jsxDEV("div",{className:"space-y-2 mb-6",children:c.map((U)=>pa.jsxDEV("div",{className:"flex items-center gap-3 p-3 bg-[var(--color-bg)] rounded",children:[pa.jsxDEV(Q1,{className:"w-5 h-5 text-green-400"},void 0,!1,void 0,this),pa.jsxDEV("span",{children:U.name},void 0,!1,void 0,this),pa.jsxDEV("span",{className:"text-[var(--color-text-muted)] text-sm",children:["(",U.keyHint,")"]},void 0,!0,void 0,this)]},U.id,!0,void 0,this))},void 0,!1,void 0,this),pa.jsxDEV("div",{className:"flex gap-3",children:[pa.jsxDEV("button",{onClick:Z,className:"flex-1 border border-[var(--color-border-light)] hover:border-[var(--color-accent)] px-4 py-3 rounded font-medium transition",children:"Add More"},void 0,!1,void 0,this),pa.jsxDEV("button",{onClick:_,className:"flex-1 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] text-black px-4 py-3 rounded font-medium transition",children:"Start Using apteva"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var u9=Ga(Do(),1);var bo=Ga(vo(),1),oX=[{key:"memory",icon:r0,label:"Memory"},{key:"tasks",icon:Nm,label:"Tasks"},{key:"files",icon:i0,label:"Files"},{key:"vision",icon:v0,label:"Vision"},{key:"operator",icon:b0,label:"Operator"},{key:"mcp",icon:wt,label:"MCP"},{key:"realtime",icon:f0,label:"Realtime"},{key:"agents",icon:w0,label:"Multi-Agent"}],K1=u9.default.memo(function({agent:Z,selected:_,onSelect:U,onToggle:h,showProject:y}){let H=oX.filter((M)=>Z.features?.[M.key]),G=Z.mcpServerDetails||[],N=Z.skillDetails||[],{isActive:I,label:W}=B1(Z.id),{projects:A}=vp(),k=Z.projectId?A.find((M)=>M.id===Z.projectId):null,x=Z.subscriptions||[];return bo.jsxDEV("div",{onClick:U,className:`bg-[var(--color-surface)] card p-5 transition cursor-pointer flex flex-col h-full ${_?"!border-[var(--color-accent)]":"hover:border-[var(--color-border-light)]"}`,children:[bo.jsxDEV("div",{className:"flex items-start justify-between mb-3",children:[bo.jsxDEV("div",{children:[bo.jsxDEV("h3",{className:"font-semibold text-lg",children:Z.name},void 0,!1,void 0,this),bo.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:[Z.provider," / ",Z.model,Z.port&&bo.jsxDEV("span",{className:"text-[var(--color-text-faint)]",children:[" · :",Z.port]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),y&&k&&bo.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] flex items-center gap-1.5 mt-1",children:[bo.jsxDEV("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:k.color}},void 0,!1,void 0,this),k.name]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),bo.jsxDEV(pX,{status:Z.status,isActive:I&&Z.status==="running",activityLabel:W},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H.length>0&&bo.jsxDEV("div",{className:"flex flex-wrap gap-1.5 mb-3",children:H.map(({key:M,icon:P,label:s})=>bo.jsxDEV("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-[var(--color-accent-10)] text-[var(--color-accent-70)] text-xs",style:{borderRadius:"var(--radius-badge)"},title:s,children:[bo.jsxDEV(P,{className:"w-3 h-3"},void 0,!1,void 0,this),s]},M,!0,void 0,this))},void 0,!1,void 0,this),G.length>0&&bo.jsxDEV("div",{className:"flex flex-wrap gap-1.5 mb-3",children:G.map((M)=>{let P=M.type==="http"&&M.url||M.status==="running";return bo.jsxDEV("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs ${P?"bg-green-500/10 text-green-400":"bg-[var(--color-surface-raised)] text-[var(--color-text-muted)]"}`,title:`MCP: ${M.name} (${P?"available":M.status})`,children:[bo.jsxDEV(wt,{className:"w-3 h-3"},void 0,!1,void 0,this),M.name]},M.id,!0,void 0,this)})},void 0,!1,void 0,this),N.length>0&&bo.jsxDEV("div",{className:"flex flex-wrap gap-1.5 mb-3",children:N.map((M)=>bo.jsxDEV("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs ${M.enabled?"bg-purple-500/10 text-purple-400":"bg-[var(--color-surface-raised)] text-[var(--color-text-muted)]"}`,title:`Skill: ${M.name} v${M.version}`,children:[bo.jsxDEV(Y1,{className:"w-3 h-3"},void 0,!1,void 0,this),M.name]},M.id,!0,void 0,this))},void 0,!1,void 0,this),x.length>0&&bo.jsxDEV("div",{className:"flex flex-wrap gap-1.5 mb-3",children:x.map((M)=>bo.jsxDEV("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs ${M.enabled?"bg-cyan-500/10 text-cyan-400":"bg-[var(--color-surface-raised)] text-[var(--color-text-muted)]"}`,title:`Trigger: ${M.trigger_slug.replace(/_/g," ")}`,children:[bo.jsxDEV(X1,{className:"w-3 h-3"},void 0,!1,void 0,this),M.trigger_slug.replace(/_/g," ")]},M.id,!0,void 0,this))},void 0,!1,void 0,this),bo.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] line-clamp-2 mb-4 flex-1",children:Z.systemPrompt},void 0,!1,void 0,this),bo.jsxDEV("button",{onClick:h,disabled:Z.status==="starting"||Z.status==="stopping",className:`w-full px-3 py-1.5 btn text-sm font-medium transition mt-auto ${Z.status==="starting"||Z.status==="stopping"?"bg-[var(--color-surface-raised)] text-[var(--color-text-muted)] cursor-wait":Z.status==="running"?"bg-red-500/15 text-red-500 hover:bg-red-500/25 border border-red-500/20":"bg-[#3b82f6]/20 text-[#3b82f6] hover:bg-[#3b82f6]/30"}`,children:Z.status==="starting"?"Starting...":Z.status==="stopping"?"Stopping...":Z.status==="running"?"Stop":"Start"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)});function pX({status:c,isActive:Z,activityLabel:_}){if(c==="running"&&Z&&_)return bo.jsxDEV("span",{className:"px-2 py-1 text-xs font-medium bg-green-500/20 text-green-400 animate-pulse",style:{borderRadius:"var(--radius-badge)"},children:_},void 0,!1,void 0,this);return bo.jsxDEV("span",{className:`px-2 py-1 text-xs font-medium ${c==="starting"||c==="stopping"?"bg-yellow-500/20 text-yellow-400 animate-pulse":c==="running"?"bg-[#3b82f6]/20 text-[#3b82f6]":"bg-[var(--color-surface-raised)] text-[var(--color-text-muted)]"}`,style:{borderRadius:"var(--radius-badge)"},children:c},void 0,!1,void 0,this)}var j5=Ga(Do(),1);var Xa=Ga(vo(),1),mX=[{key:"memory",label:"Memory",description:"Persistent recall",icon:r0},{key:"tasks",label:"Tasks",description:"Schedule and execute tasks",icon:Nm},{key:"files",label:"Files",description:"File storage and management",icon:i0},{key:"vision",label:"Vision",description:"Process images and PDFs",icon:v0},{key:"operator",label:"Operator",description:"Browser automation",icon:b0},{key:"mcp",label:"MCP",description:"External tools/services",icon:wt},{key:"realtime",label:"Realtime",description:"Voice conversations",icon:f0},{key:"agents",label:"Multi-Agent",description:"Communicate with peer agents",icon:w0}];function H1({form:c,providers:Z,configuredProviders:_,onFormChange:U,onProviderChange:h,onCreate:y,onClose:H,onGoToSettings:G}){let{projects:N,currentProjectId:I}=vp(),{authFetch:W}=$o(),A=Z.find((e)=>e.id===c.provider),[k,x]=j5.default.useState([]),[M,P]=j5.default.useState(!1);j5.default.useEffect(()=>{if(c.provider==="ollama")P(!0),W("/api/providers/ollama/models").then((e)=>e.json()).then((e)=>{if(e.models&&e.models.length>0){if(x(e.models.map((La)=>({value:La.value,label:La.label||La.value}))),!c.model&&e.models.length>0)U({...c,model:e.models[0].value})}}).catch(()=>x([])).finally(()=>P(!1))},[c.provider]);let s=_.filter((e)=>e.type==="llm").map((e)=>({value:e.id,label:e.name})),qa=c.provider==="ollama"&&k.length>0?k:A?.models.map((e)=>({value:e.value,label:e.label,recommended:e.recommended}))||[],ma=N.map((e)=>({value:e.id,label:e.name}));j5.default.useEffect(()=>{if(c.projectId===void 0&&I&&I!=="unassigned")U({...c,projectId:I})},[I]);let wa=(e)=>{if(e==="agents")if(typeof c.features.agents==="boolean"?c.features.agents:c.features.agents?.enabled??!1)U({...c,features:{...c.features,agents:!1}});else U({...c,features:{...c.features,agents:{enabled:!0,group:c.projectId||void 0}}});else U({...c,features:{...c.features,[e]:!c.features[e]}})},oa=()=>{let e=c.features.agents;if(typeof e==="boolean")return e;return e?.enabled??!1};return Xa.jsxDEV(d7,{children:[Xa.jsxDEV("h2",{className:"text-xl font-semibold mb-4",children:"Create New Agent"},void 0,!1,void 0,this),s.length===0?Xa.jsxDEV(tX,{onGoToSettings:G},void 0,!1,void 0,this):Xa.jsxDEV(Xa.Fragment,{children:[Xa.jsxDEV("div",{className:"space-y-4",children:[Xa.jsxDEV(Vr,{label:"Name",children:Xa.jsxDEV("input",{type:"text",value:c.name,onChange:(e)=>U({...c,name:e.target.value}),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)]",placeholder:"My Agent"},void 0,!1,void 0,this)},void 0,!1,void 0,this),N.length>0&&Xa.jsxDEV(Vr,{label:"Project",children:Xa.jsxDEV(ct,{value:c.projectId||"",options:ma,onChange:(e)=>U({...c,projectId:e||null}),placeholder:"Select project..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),Xa.jsxDEV(Vr,{label:"Provider",children:Xa.jsxDEV(ct,{value:c.provider,options:s,onChange:h,placeholder:"Select provider..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),Xa.jsxDEV(Vr,{label:"Model",children:M?Xa.jsxDEV("div",{className:"text-sm text-[var(--color-text-muted)] py-2",children:"Loading Ollama models..."},void 0,!1,void 0,this):c.provider==="ollama"&&qa.length===0?Xa.jsxDEV("div",{className:"text-sm text-yellow-400/80 py-2",children:["No models found. Run ",Xa.jsxDEV("code",{className:"bg-[var(--color-surface-raised)] px-1 rounded",children:"ollama pull llama3.3"},void 0,!1,void 0,this)," to download a model."]},void 0,!0,void 0,this):Xa.jsxDEV(ct,{value:c.model,options:qa,onChange:(e)=>U({...c,model:e}),placeholder:"Select model..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),Xa.jsxDEV(Vr,{label:"System Prompt",children:Xa.jsxDEV("textarea",{value:c.systemPrompt,onChange:(e)=>U({...c,systemPrompt:e.target.value}),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 h-24 resize-none focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)]"},void 0,!1,void 0,this)},void 0,!1,void 0,this),Xa.jsxDEV(Vr,{label:"Features",children:Xa.jsxDEV("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:mX.map(({key:e,label:La,description:ha,icon:V})=>{let Ca=e==="agents"?oa():!!c.features[e];return Xa.jsxDEV("button",{type:"button",onClick:()=>wa(e),className:`flex items-center gap-3 p-3 btn border text-left transition ${Ca?"border-[var(--color-accent)] bg-[var(--color-accent-10)]":"border-[var(--color-border-light)] hover:border-[var(--color-border-light)]"}`,children:[Xa.jsxDEV(V,{className:`w-5 h-5 flex-shrink-0 ${Ca?"text-[var(--color-accent)]":"text-[var(--color-text-muted)]"}`},void 0,!1,void 0,this),Xa.jsxDEV("div",{className:"flex-1 min-w-0",children:[Xa.jsxDEV("div",{className:`text-sm font-medium ${Ca?"text-[var(--color-accent)]":""}`,children:La},void 0,!1,void 0,this),Xa.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)]",children:ha},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},e,!0,void 0,this)})},void 0,!1,void 0,this)},void 0,!1,void 0,this),c.provider==="anthropic"&&Xa.jsxDEV(Vr,{label:"Agent Built-in Tools",children:[Xa.jsxDEV("div",{className:"flex flex-wrap gap-2",children:[Xa.jsxDEV("button",{type:"button",onClick:()=>U({...c,features:{...c.features,builtinTools:{...c.features.builtinTools,webSearch:!c.features.builtinTools?.webSearch}}}),className:`flex items-center gap-2 px-3 py-2 btn border transition ${c.features.builtinTools?.webSearch?"border-[var(--color-accent)] bg-[var(--color-accent-10)] text-[var(--color-accent)]":"border-[var(--color-border-light)] hover:border-[var(--color-border-light)] text-[var(--color-text-secondary)]"}`,children:[Xa.jsxDEV("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:Xa.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"},void 0,!1,void 0,this)},void 0,!1,void 0,this),Xa.jsxDEV("span",{className:"text-sm",children:"Web Search"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Xa.jsxDEV("button",{type:"button",onClick:()=>U({...c,features:{...c.features,builtinTools:{...c.features.builtinTools,webFetch:!c.features.builtinTools?.webFetch}}}),className:`flex items-center gap-2 px-3 py-2 btn border transition ${c.features.builtinTools?.webFetch?"border-[var(--color-accent)] bg-[var(--color-accent-10)] text-[var(--color-accent)]":"border-[var(--color-border-light)] hover:border-[var(--color-border-light)] text-[var(--color-text-secondary)]"}`,children:[Xa.jsxDEV("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:Xa.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"},void 0,!1,void 0,this)},void 0,!1,void 0,this),Xa.jsxDEV("span",{className:"text-sm",children:"Web Fetch"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Xa.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-2",children:"Provider-native tools for real-time web access"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Xa.jsxDEV("div",{className:"flex gap-3 mt-6",children:[Xa.jsxDEV("button",{onClick:H,className:"flex-1 border border-[var(--color-border-light)] hover:border-[var(--color-accent)] hover:text-[var(--color-accent)] px-4 py-2 btn font-medium transition",children:"Cancel"},void 0,!1,void 0,this),Xa.jsxDEV("button",{onClick:y,disabled:!c.name,className:"flex-1 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 text-black px-4 py-2 btn font-medium transition",children:"Create"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Vr({label:c,children:Z}){return Xa.jsxDEV("div",{children:[Xa.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:c},void 0,!1,void 0,this),Z]},void 0,!0,void 0,this)}function tX({onGoToSettings:c}){return Xa.jsxDEV("div",{className:"text-center py-6",children:[Xa.jsxDEV("p",{className:"text-[var(--color-text-muted)] mb-4",children:"No API keys configured. Add a provider key first."},void 0,!1,void 0,this),Xa.jsxDEV("button",{onClick:c,className:"bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] text-black px-4 py-2 rounded font-medium transition",children:"Go to Settings"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var aa=Ga(Do(),1);var w=Ga(vo(),1),rX=[{key:"memory",label:"Memory",description:"Persistent recall",icon:r0},{key:"tasks",label:"Tasks",description:"Schedule and execute tasks",icon:Nm},{key:"files",label:"Files",description:"File storage and management",icon:i0},{key:"vision",label:"Vision",description:"Process images and PDFs",icon:v0},{key:"operator",label:"Operator",description:"Browser automation",icon:b0},{key:"mcp",label:"MCP",description:"External tools/services",icon:wt},{key:"realtime",label:"Realtime",description:"Voice conversations",icon:f0},{key:"agents",label:"Multi-Agent",description:"Communicate with peer agents",icon:w0}];function U1({agent:c,providers:Z,onClose:_,onStartAgent:U,onUpdateAgent:h,onDeleteAgent:y}){let[H,G]=aa.useState("chat");return w.jsxDEV("div",{className:"w-full h-full flex flex-col overflow-hidden bg-[var(--color-bg)] border-l border-[var(--color-border)]",children:[w.jsxDEV("div",{className:"border-b border-[var(--color-border)] flex items-center",children:[w.jsxDEV("div",{className:"flex-1 overflow-x-auto scrollbar-hide px-2 md:px-4",children:w.jsxDEV("div",{className:"flex gap-1",children:[w.jsxDEV(c0,{active:H==="chat",onClick:()=>G("chat"),children:"Chat"},void 0,!1,void 0,this),w.jsxDEV(c0,{active:H==="threads",onClick:()=>G("threads"),children:"Threads"},void 0,!1,void 0,this),w.jsxDEV(c0,{active:H==="tasks",onClick:()=>G("tasks"),children:"Tasks"},void 0,!1,void 0,this),w.jsxDEV(c0,{active:H==="memory",onClick:()=>G("memory"),children:"Memory"},void 0,!1,void 0,this),w.jsxDEV(c0,{active:H==="files",onClick:()=>G("files"),children:"Files"},void 0,!1,void 0,this),w.jsxDEV(c0,{active:H==="settings",onClick:()=>G("settings"),children:"Settings"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:_,className:"text-[var(--color-text-muted)] hover:text-[var(--color-text)] transition p-2 flex-shrink-0 mr-2",children:w.jsxDEV(it,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[H==="chat"&&w.jsxDEV(vX,{agent:c,onStartAgent:U},void 0,!1,void 0,this),H==="threads"&&w.jsxDEV(bX,{agent:c},void 0,!1,void 0,this),H==="tasks"&&w.jsxDEV(fX,{agent:c},void 0,!1,void 0,this),H==="memory"&&w.jsxDEV(wX,{agent:c},void 0,!1,void 0,this),H==="files"&&w.jsxDEV(cX,{agent:c},void 0,!1,void 0,this),H==="settings"&&w.jsxDEV(lX,{agent:c,providers:Z,onUpdateAgent:h,onDeleteAgent:y},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function c0({active:c,onClick:Z,children:_}){return w.jsxDEV("button",{onClick:Z,className:`px-4 py-3 text-sm font-medium border-b-2 transition ${c?"border-[var(--color-accent)] text-[var(--color-text)]":"border-transparent text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)]"}`,children:_},void 0,!1,void 0,this)}function vX({agent:c,onStartAgent:Z}){let{theme:_}=xr();if(c.status==="running"&&c.port)return w.jsxDEV(ur,{agentId:"default",apiUrl:`/api/agents/${c.id}`,placeholder:"Message this agent...",context:c.systemPrompt,variant:"terminal",theme:_.id,headerTitle:c.name,enableVoice:!!c.features.realtime},void 0,!1,void 0,this);return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("div",{className:"text-center",children:[w.jsxDEV("p",{className:"text-lg mb-2",children:"Agent is not running"},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:Z,className:"bg-[#3b82f6]/20 text-[#3b82f6] hover:bg-[#3b82f6]/30 px-4 py-2 rounded font-medium transition",children:"Start Agent"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function bX({agent:c}){let{theme:Z}=xr(),[_,U]=aa.useState([]),[h,y]=aa.useState(!0),[H,G]=aa.useState(null),[N,I]=aa.useState(null),[W,A]=aa.useState([]),[k,x]=aa.useState(!1),{confirm:M,ConfirmDialog:P}=s5();aa.useEffect(()=>{U([]),I(null),G(null),y(!0)},[c.id]),aa.useEffect(()=>{if(c.status!=="running"){y(!1);return}(async()=>{try{let wa=await fetch(`/api/agents/${c.id}/threads`);if(!wa.ok)throw Error("Failed to fetch threads");let oa=await wa.json();U(oa.threads||[]),G(null)}catch(wa){G(wa instanceof Error?wa.message:"Failed to load threads")}finally{y(!1)}})()},[c.id,c.status]);let s=async(ma)=>{x(!0),I(ma);try{let wa=await fetch(`/api/agents/${c.id}/threads/${ma}/messages`);if(wa.ok){let oa=await wa.json();A(x9(oa.messages||[]))}else A([])}catch{A([])}x(!1)},qa=async(ma,wa)=>{if(wa.stopPropagation(),!await M("Delete this thread?",{confirmText:"Delete",title:"Delete Thread"}))return;try{if(await fetch(`/api/agents/${c.id}/threads/${ma}`,{method:"DELETE"}),U((e)=>e.filter((La)=>La.id!==ma)),N===ma)I(null)}catch{}};if(c.status!=="running")return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("p",{children:"Start the agent to view threads"},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(h)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("p",{children:"Loading threads..."},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(H)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-red-400",children:w.jsxDEV("p",{children:H},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(N)return w.jsxDEV(w.Fragment,{children:[P,w.jsxDEV("div",{className:"flex-1 flex flex-col overflow-hidden",children:k?w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:"Loading messages..."},void 0,!1,void 0,this):w.jsxDEV(ur,{agentId:"default",apiUrl:`/api/agents/${c.id}`,threadId:N,initialMessages:W,placeholder:"Continue this conversation...",context:c.systemPrompt,variant:"terminal",theme:Z.id,showHeader:!0,onHeaderBack:()=>{I(null),A([])}},N,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return w.jsxDEV(w.Fragment,{children:[P,w.jsxDEV("div",{className:"flex-1 overflow-auto",children:_.length===0?w.jsxDEV("div",{className:"flex items-center justify-center h-full text-[var(--color-text-muted)]",children:w.jsxDEV("p",{children:"No conversation threads yet"},void 0,!1,void 0,this)},void 0,!1,void 0,this):w.jsxDEV("div",{className:"divide-y divide-[var(--color-border)]",children:_.map((ma)=>w.jsxDEV("div",{onClick:()=>s(ma.id),className:"p-4 cursor-pointer hover:bg-[var(--color-surface)] transition flex items-center justify-between",children:[w.jsxDEV("div",{className:"flex-1 min-w-0",children:[w.jsxDEV("p",{className:"text-sm font-medium truncate",children:ma.title||`Thread ${ma.id.slice(0,8)}`},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] mt-1",children:[new Date(ma.updated_at||ma.created_at).toLocaleString(),ma.message_count!==void 0&&` • ${ma.message_count} messages`]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("button",{onClick:(wa)=>qa(ma.id,wa),className:"text-[var(--color-text-muted)] hover:text-red-400 text-lg ml-4",children:"×"},void 0,!1,void 0,this)]},ma.id,!0,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function fX({agent:c}){let{authFetch:Z}=$o(),[_,U]=aa.useState([]),[h,y]=aa.useState(!0),[H,G]=aa.useState(null),[N,I]=aa.useState("all"),[W,A]=aa.useState(null),[k,x]=aa.useState(!1),[M,P]=aa.useState(!1),[s,qa]=aa.useState(!1),[ma,wa]=aa.useState(!1),[oa,e]=aa.useState(!1),[La,ha]=aa.useState(!1),[V,Ca]=aa.useState({title:"",description:"",type:"once",priority:5,execute_at:"",recurrence:""}),{confirm:L,ConfirmDialog:ra}=s5(),{events:O}=W1({agent_id:c.id,category:"task"});aa.useEffect(()=>{U([]),G(null),y(!0),A(null)},[c.id]);let d=async()=>{if(c.status!=="running"){y(!1);return}try{let S=await fetch(`/api/agents/${c.id}/tasks?status=${N}`);if(!S.ok)throw Error("Failed to fetch tasks");let _a=await S.json();U(_a.tasks||[]),G(null)}catch(S){G(S instanceof Error?S.message:"Failed to load tasks")}finally{y(!1)}},fa=async(S)=>{A(S),x(!0);try{let _a=await Z(`/api/tasks/${S.agentId||c.id}/${S.id}`);if(_a.ok){let sa=await _a.json();if(sa.task)A({...sa.task,agentId:S.agentId||c.id,agentName:S.agentName||c.name})}}catch(_a){console.error("Failed to fetch task details:",_a)}finally{x(!1)}},C=async()=>{if(!W||s)return;qa(!0);try{await Z(`/api/tasks/${c.id}/${W.id}/execute`,{method:"POST"}),A(null),d()}catch(S){console.error("Failed to execute task:",S)}finally{qa(!1)}},T=async()=>{if(!W||ma)return;if(!await L(`Are you sure you want to delete "${W.title}"?`,{title:"Delete Task",confirmText:"Delete",confirmVariant:"danger"}))return;wa(!0);try{await Z(`/api/tasks/${c.id}/${W.id}`,{method:"DELETE"}),A(null),d()}catch(_a){console.error("Failed to delete task:",_a)}finally{wa(!1)}},va=async(S)=>{try{let _a={...S};if(S.execute_at)_a.execute_at=new Date(S.execute_at).toISOString();if((await Z(`/api/tasks/${c.id}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_a)})).ok)P(!1),d()}catch(_a){console.error("Failed to create task:",_a)}},Pa=(S)=>{Ca({title:S.title,description:S.description||"",type:S.type,priority:S.priority,execute_at:S.execute_at?new Date(S.execute_at).toISOString().slice(0,16):"",recurrence:S.recurrence||""}),e(!0)},xa=async()=>{if(!W||La)return;ha(!0);try{let S={title:V.title.trim(),description:V.description.trim()||void 0,type:V.type,priority:V.priority};if(V.type==="once"&&V.execute_at)S.execute_at=new Date(V.execute_at).toISOString();if(V.type==="recurring"&&V.recurrence.trim())S.recurrence=V.recurrence.trim();if((await Z(`/api/tasks/${c.id}/${W.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(S)})).ok)e(!1),A(null),d()}catch(S){console.error("Failed to update task:",S)}finally{ha(!1)}};aa.useEffect(()=>{y(!0),d()},[c.id,c.status,N,O.length]);let So={pending:"bg-yellow-500/20 text-yellow-400",running:"bg-blue-500/20 text-blue-400",completed:"bg-green-500/20 text-green-400",failed:"bg-red-500/20 text-red-400",cancelled:"bg-gray-500/20 text-gray-400"};if(c.status!=="running")return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("p",{children:"Start the agent to view tasks"},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(!c.features?.tasks)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("div",{className:"text-center",children:[w.jsxDEV("p",{className:"mb-2",children:"Tasks feature is not enabled"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-sm",children:"Enable it in Settings to schedule tasks"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);if(h)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("p",{children:"Loading tasks..."},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(H)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-red-400",children:w.jsxDEV("p",{children:H},void 0,!1,void 0,this)},void 0,!1,void 0,this);let $p=[{value:"all",label:"All"},{value:"pending",label:"Pending"},{value:"running",label:"Running"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}];if(W)return w.jsxDEV("div",{className:"flex-1 flex flex-col overflow-hidden",children:[ra,w.jsxDEV("div",{className:"px-4 pt-3 pb-2 border-b border-[var(--color-border)] shrink-0 flex items-center justify-between",children:[w.jsxDEV("button",{onClick:()=>{A(null),e(!1)},className:"text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text)] transition flex items-center gap-1",children:[w.jsxDEV("span",{children:"←"},void 0,!1,void 0,this)," ",oa?"Cancel":"Back to tasks"]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"flex items-center gap-2",children:oa?w.jsxDEV(w.Fragment,{children:[w.jsxDEV("button",{onClick:()=>e(!1),className:"text-[var(--color-text-muted)] hover:text-[var(--color-text)] text-sm transition",children:"Cancel"},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:xa,disabled:La||!V.title.trim(),className:"px-3 py-1 rounded text-sm bg-[var(--color-accent)] text-black hover:opacity-90 transition disabled:opacity-50",children:La?"Saving...":"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):w.jsxDEV(w.Fragment,{children:[(W.status==="pending"||W.status==="completed"||W.status==="failed")&&w.jsxDEV("button",{onClick:()=>Pa(W),title:"Edit task",className:"text-[var(--color-text-muted)] hover:text-[var(--color-accent)] transition",children:w.jsxDEV("svg",{className:"w-4.5 h-4.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:w.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),(W.status==="pending"||W.status==="completed")&&w.jsxDEV("button",{onClick:C,disabled:s,title:"Execute now",className:"text-[var(--color-accent)] hover:opacity-80 transition disabled:opacity-50",children:w.jsxDEV("svg",{className:"w-4.5 h-4.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[w.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"},void 0,!1,void 0,this),w.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:T,disabled:ma,title:"Delete task",className:"text-red-400 hover:text-red-300 transition disabled:opacity-50",children:w.jsxDEV("svg",{className:"w-4.5 h-4.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:w.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:(()=>{return w.jsxDEV(w.Fragment,{children:[w.jsxDEV("div",{children:w.jsxDEV("div",{className:"flex items-start justify-between gap-2 mb-1",children:[oa?w.jsxDEV("input",{type:"text",value:V.title,onChange:(_a)=>Ca({...V,title:_a.target.value}),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-2 py-1.5 text-sm focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)] text-lg font-medium",placeholder:"Task title"},void 0,!1,void 0,this):w.jsxDEV("h3",{className:"text-lg font-medium",children:W.title},void 0,!1,void 0,this),!oa&&w.jsxDEV("span",{className:`px-2 py-1 rounded text-xs font-medium flex-shrink-0 ${So[W.status]}`,children:W.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),oa?w.jsxDEV("div",{children:[w.jsxDEV("h4",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wider mb-1",children:"Description"},void 0,!1,void 0,this),w.jsxDEV("textarea",{value:V.description,onChange:(_a)=>Ca({...V,description:_a.target.value}),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-2 py-1.5 text-sm focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)] resize-none",rows:3,placeholder:"Task description..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):W.description?w.jsxDEV("div",{children:[w.jsxDEV("h4",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wider mb-1",children:"Description"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-sm text-[var(--color-text-secondary)] whitespace-pre-wrap",children:W.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null,oa?w.jsxDEV("div",{className:"grid grid-cols-2 gap-3",children:[w.jsxDEV("div",{children:[w.jsxDEV("label",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wider mb-1 block",children:"Type"},void 0,!1,void 0,this),w.jsxDEV("select",{value:V.type,onChange:(_a)=>Ca({...V,type:_a.target.value}),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-2 py-1.5 text-sm focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)]",children:[w.jsxDEV("option",{value:"once",children:"One-time"},void 0,!1,void 0,this),w.jsxDEV("option",{value:"recurring",children:"Recurring"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{children:[w.jsxDEV("label",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wider mb-1 block",children:"Priority"},void 0,!1,void 0,this),w.jsxDEV("input",{type:"number",min:1,max:10,value:V.priority,onChange:(_a)=>Ca({...V,priority:Number(_a.target.value)}),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-2 py-1.5 text-sm focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):w.jsxDEV("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[w.jsxDEV("div",{children:[w.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Type"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"capitalize",children:W.type},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{children:[w.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Priority"},void 0,!1,void 0,this),w.jsxDEV("p",{children:W.priority},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W.recurrence&&w.jsxDEV("div",{children:[w.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Recurrence"},void 0,!1,void 0,this),w.jsxDEV("p",{children:R7(W.recurrence)},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-0.5 font-mono",children:W.recurrence},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),oa&&V.type==="once"&&w.jsxDEV("div",{children:[w.jsxDEV("label",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wider mb-1 block",children:"Schedule"},void 0,!1,void 0,this),w.jsxDEV("input",{type:"datetime-local",value:V.execute_at,onChange:(_a)=>Ca({...V,execute_at:_a.target.value}),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-2 py-1.5 text-sm focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),oa&&V.type==="recurring"&&w.jsxDEV("div",{children:[w.jsxDEV("label",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wider mb-1 block",children:"Cron Schedule"},void 0,!1,void 0,this),w.jsxDEV("input",{type:"text",value:V.recurrence,onChange:(_a)=>Ca({...V,recurrence:_a.target.value}),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-2 py-1.5 text-sm focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)] font-mono",placeholder:"*/30 * * * *"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-1",children:"e.g. */30 * * * * = every 30 min"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!oa&&w.jsxDEV("div",{className:"space-y-2 text-sm",children:[w.jsxDEV("div",{className:"flex justify-between",children:[w.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Created"},void 0,!1,void 0,this),w.jsxDEV("span",{children:new Date(W.created_at).toLocaleString()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W.execute_at&&w.jsxDEV("div",{className:"flex justify-between",children:[w.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Scheduled"},void 0,!1,void 0,this),w.jsxDEV("span",{className:"text-[var(--color-accent)]",children:E5(W.execute_at)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W.executed_at&&w.jsxDEV("div",{className:"flex justify-between",children:[w.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Started"},void 0,!1,void 0,this),w.jsxDEV("span",{children:new Date(W.executed_at).toLocaleString()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W.completed_at&&w.jsxDEV("div",{className:"flex justify-between",children:[w.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Completed"},void 0,!1,void 0,this),w.jsxDEV("span",{children:new Date(W.completed_at).toLocaleString()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W.next_run&&w.jsxDEV("div",{className:"flex justify-between",children:[w.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Next Run"},void 0,!1,void 0,this),w.jsxDEV("span",{className:"text-[var(--color-accent)]",children:E5(W.next_run)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!oa&&W.status==="failed"&&W.error&&w.jsxDEV("div",{className:"min-w-0",children:[w.jsxDEV("h4",{className:"text-xs text-red-400 uppercase tracking-wider mb-1",children:"Error"},void 0,!1,void 0,this),w.jsxDEV("div",{className:"bg-red-500/10 border border-red-500/20 rounded p-3 overflow-x-auto",children:w.jsxDEV("pre",{className:"text-sm text-red-400 whitespace-pre-wrap break-words",children:W.error},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!oa&&W.status==="completed"&&W.result&&w.jsxDEV("div",{className:"min-w-0",children:[w.jsxDEV("h4",{className:"text-xs text-green-400 uppercase tracking-wider mb-1",children:"Result"},void 0,!1,void 0,this),w.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/20 rounded p-3 overflow-x-auto",children:w.jsxDEV("pre",{className:"text-sm text-green-400 whitespace-pre-wrap break-words",children:typeof W.result==="string"?W.result:JSON.stringify(W.result,null,2)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!oa&&k&&!W.trajectory&&w.jsxDEV("div",{children:[w.jsxDEV("h4",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wider mb-2",children:"Trajectory"},void 0,!1,void 0,this),w.jsxDEV("div",{className:"text-sm text-[var(--color-text-faint)]",children:"Loading trajectory..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!oa&&W.trajectory&&W.trajectory.length>0&&w.jsxDEV("div",{children:[w.jsxDEV("h4",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wider mb-2",children:["Trajectory (",W.trajectory.length," steps)"]},void 0,!0,void 0,this),w.jsxDEV(E9,{trajectory:W.trajectory},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)})()},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return w.jsxDEV("div",{className:"flex-1 overflow-auto p-4",children:[w.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[w.jsxDEV("div",{className:"flex gap-2",children:$p.map((S)=>w.jsxDEV("button",{onClick:()=>I(S.value),className:`px-3 py-1.5 rounded text-sm transition ${N===S.value?"bg-[var(--color-accent)] text-black":"bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)]"}`,children:S.label},S.value,!1,void 0,this))},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:()=>P(!M),className:"px-3 py-1.5 rounded text-sm bg-[var(--color-accent)] text-black hover:opacity-90 transition flex items-center gap-1 flex-shrink-0",children:[w.jsxDEV("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:w.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"},void 0,!1,void 0,this)},void 0,!1,void 0,this),"New"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),M&&w.jsxDEV(iX,{onSubmit:va,onCancel:()=>P(!1)},void 0,!1,void 0,this),_.length===0?w.jsxDEV("div",{className:"text-center py-10",children:[w.jsxDEV(Nm,{className:"w-10 h-10 mx-auto mb-3 text-[var(--color-border-light)]"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-[var(--color-text-muted)]",children:["No ",N==="all"?"":N+" ","tasks"]},void 0,!0,void 0,this),w.jsxDEV("p",{className:"text-sm text-[var(--color-text-faint)] mt-1",children:"Tasks will appear here when created"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):w.jsxDEV("div",{className:"space-y-3",children:_.map((S)=>w.jsxDEV("div",{onClick:()=>fa(S),className:"bg-[var(--color-surface)] card p-4 cursor-pointer hover:border-[var(--color-border-light)] transition",children:[w.jsxDEV("div",{className:"flex items-start justify-between mb-2",children:[w.jsxDEV("div",{className:"flex-1 min-w-0",children:w.jsxDEV("h3",{className:"font-medium",children:S.title||S.name},void 0,!1,void 0,this)},void 0,!1,void 0,this),w.jsxDEV("span",{className:`px-2 py-1 rounded text-xs font-medium ml-2 ${So[S.status]||So.pending}`,children:S.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this),S.description&&w.jsxDEV("p",{className:"text-sm text-[var(--color-text-secondary)] mb-2 line-clamp-2",children:S.description},void 0,!1,void 0,this),w.jsxDEV("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-[var(--color-text-faint)]",children:[w.jsxDEV("span",{className:"flex items-center gap-1",children:[S.type==="recurring"?w.jsxDEV(V9,{className:"w-3.5 h-3.5"},void 0,!1,void 0,this):S.execute_at?w.jsxDEV(D9,{className:"w-3.5 h-3.5"},void 0,!1,void 0,this):w.jsxDEV(j9,{className:"w-3.5 h-3.5"},void 0,!1,void 0,this),S.type==="recurring"&&S.recurrence?R7(S.recurrence):S.type||"once"]},void 0,!0,void 0,this),S.priority!==void 0&&w.jsxDEV("span",{children:["Priority: ",S.priority]},void 0,!0,void 0,this),S.next_run&&w.jsxDEV("span",{className:"text-[var(--color-accent)]",children:E5(S.next_run)},void 0,!1,void 0,this),!S.next_run&&S.execute_at&&w.jsxDEV("span",{className:"text-[var(--color-accent)]",children:E5(S.execute_at)},void 0,!1,void 0,this),w.jsxDEV("span",{children:["Created: ",new Date(S.created_at).toLocaleDateString()]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),S.status==="completed"&&S.result&&w.jsxDEV("div",{className:"mt-3 bg-green-500/10 border border-green-500/20 rounded p-3",children:[w.jsxDEV("h4",{className:"text-xs text-green-400 uppercase tracking-wider mb-1",children:"Result"},void 0,!1,void 0,this),w.jsxDEV("pre",{className:"text-sm text-green-400 whitespace-pre-wrap break-words",children:typeof S.result==="string"?S.result:JSON.stringify(S.result,null,2)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),S.status==="failed"&&S.error&&w.jsxDEV("div",{className:"mt-3 bg-red-500/10 border border-red-500/20 rounded p-3",children:[w.jsxDEV("h4",{className:"text-xs text-red-400 uppercase tracking-wider mb-1",children:"Error"},void 0,!1,void 0,this),w.jsxDEV("pre",{className:"text-sm text-red-400 whitespace-pre-wrap break-words",children:S.error},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},S.id,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function iX({onSubmit:c,onCancel:Z}){let[_,U]=aa.useState(""),[h,y]=aa.useState(""),[H,G]=aa.useState("once"),[N,I]=aa.useState(5),[W,A]=aa.useState(""),[k,x]=aa.useState("");return w.jsxDEV("div",{className:"bg-[var(--color-surface)] border border-[var(--color-accent)]/30 rounded-lg p-3 mb-4 space-y-3",children:[w.jsxDEV("input",{type:"text",value:_,onChange:(M)=>U(M.target.value),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-3 py-1.5 text-sm",placeholder:"Task title...",autoFocus:!0},void 0,!1,void 0,this),w.jsxDEV("textarea",{value:h,onChange:(M)=>y(M.target.value),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-3 py-1.5 text-sm resize-none",rows:2,placeholder:"Description (optional)..."},void 0,!1,void 0,this),w.jsxDEV("div",{className:"grid grid-cols-2 gap-2",children:[w.jsxDEV("select",{value:H,onChange:(M)=>G(M.target.value),className:"bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-2 py-1.5 text-sm",children:[w.jsxDEV("option",{value:"once",children:"One-time"},void 0,!1,void 0,this),w.jsxDEV("option",{value:"recurring",children:"Recurring"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("input",{type:"number",min:1,max:10,value:N,onChange:(M)=>I(Number(M.target.value)),className:"bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-2 py-1.5 text-sm",placeholder:"Priority"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H==="once"&&w.jsxDEV("input",{type:"datetime-local",value:W,onChange:(M)=>A(M.target.value),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-3 py-1.5 text-sm"},void 0,!1,void 0,this),H==="recurring"&&w.jsxDEV("input",{type:"text",value:k,onChange:(M)=>x(M.target.value),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-3 py-1.5 text-sm font-mono",placeholder:"*/30 * * * * (cron)"},void 0,!1,void 0,this),w.jsxDEV("div",{className:"flex justify-end gap-2",children:[w.jsxDEV("button",{onClick:Z,className:"px-3 py-1.5 rounded text-sm bg-[var(--color-surface-raised)] hover:bg-[var(--color-border)] transition",children:"Cancel"},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:()=>_.trim()&&c({title:_.trim(),description:h.trim(),type:H,priority:N,execute_at:W||void 0,recurrence:k||void 0}),disabled:!_.trim(),className:"px-3 py-1.5 rounded text-sm bg-[var(--color-accent)] text-black hover:opacity-90 transition disabled:opacity-50",children:"Create"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function wX({agent:c}){let[Z,_]=aa.useState([]),[U,h]=aa.useState(!0),[y,H]=aa.useState(null),[G,N]=aa.useState(!1),{confirm:I,ConfirmDialog:W}=s5();aa.useEffect(()=>{_([]),H(null),h(!0)},[c.id]);let A=async()=>{if(c.status!=="running"){h(!1);return}try{let M=await fetch(`/api/agents/${c.id}/memories`);if(!M.ok)throw Error("Failed to fetch memories");let P=await M.json();_(P.memories||[]),N(P.enabled??!1),H(null)}catch(M){H(M instanceof Error?M.message:"Failed to load memories")}finally{h(!1)}};aa.useEffect(()=>{A()},[c.id,c.status]);let k=async(M)=>{try{await fetch(`/api/agents/${c.id}/memories/${M}`,{method:"DELETE"}),_((P)=>P.filter((s)=>s.id!==M))}catch{}},x=async()=>{if(!await I("Clear all memories?",{confirmText:"Clear",title:"Clear Memories"}))return;try{await fetch(`/api/agents/${c.id}/memories`,{method:"DELETE"}),_([])}catch{}};if(!c.features?.memory)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("div",{className:"text-center",children:[w.jsxDEV("p",{className:"mb-2",children:"Memory feature is not enabled"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-sm",children:"Enable it in Settings to persist knowledge"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);if(c.status!=="running")return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("p",{children:"Start the agent to view memories"},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(U)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("p",{children:"Loading memories..."},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(y)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-red-400",children:w.jsxDEV("p",{children:y},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(!G)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("div",{className:"text-center",children:[w.jsxDEV("p",{className:"mb-2",children:"Memory system not initialized"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-sm",children:"Check OPENAI_API_KEY for embeddings"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);return w.jsxDEV(w.Fragment,{children:[W,w.jsxDEV("div",{className:"flex-1 overflow-auto p-4",children:[w.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[w.jsxDEV("h3",{className:"text-sm font-medium text-[var(--color-text-secondary)]",children:["Stored Memories (",Z.length,")"]},void 0,!0,void 0,this),Z.length>0&&w.jsxDEV("button",{onClick:x,className:"text-xs text-red-400 hover:text-red-300",children:"Clear All"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z.length===0?w.jsxDEV("div",{className:"text-center py-10 text-[var(--color-text-muted)]",children:[w.jsxDEV("p",{children:"No memories stored yet"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-sm mt-1",children:"The agent will remember important information from conversations"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):w.jsxDEV("div",{className:"space-y-3",children:Z.map((M)=>w.jsxDEV("div",{className:"bg-[var(--color-surface)] border border-[var(--color-border)] rounded p-3",children:[w.jsxDEV("div",{className:"flex items-start justify-between gap-2",children:[w.jsxDEV("p",{className:"text-sm text-[var(--color-text)] flex-1",children:M.content},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:()=>k(M.id),className:"text-[var(--color-text-muted)] hover:text-red-400 text-sm flex-shrink-0",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"flex items-center gap-3 mt-2",children:[w.jsxDEV("span",{className:`text-xs px-2 py-0.5 rounded ${M.type==="preference"?"bg-purple-500/20 text-purple-400":M.type==="fact"?"bg-green-500/20 text-green-400":"bg-blue-500/20 text-blue-400"}`,children:M.type},void 0,!1,void 0,this),w.jsxDEV("span",{className:"text-xs text-[var(--color-text-muted)]",children:new Date(M.created_at).toLocaleString()},void 0,!1,void 0,this),M.importance&&w.jsxDEV("span",{className:"text-xs text-[var(--color-text-faint)]",children:["importance: ",M.importance.toFixed(1)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},M.id,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function cX({agent:c}){let[Z,_]=aa.useState([]),[U,h]=aa.useState(!0),[y,H]=aa.useState(null),[G,N]=aa.useState(!1),[I,W]=aa.useState(null),[A,k]=aa.useState(!1),x=aa.default.useRef(null),{confirm:M,ConfirmDialog:P}=s5();aa.useEffect(()=>{_([]),H(null),h(!0)},[c.id]);let s=async()=>{if(c.status!=="running"){h(!1);return}try{let L=await fetch(`/api/agents/${c.id}/files`);if(!L.ok)throw Error("Failed to fetch files");let ra=await L.json();_(ra.files||[]),H(null)}catch(L){H(L instanceof Error?L.message:"Failed to load files")}finally{h(!1)}};aa.useEffect(()=>{s()},[c.id,c.status]);let qa=async(L)=>{if(!await M("Delete this file?",{confirmText:"Delete",title:"Delete File"}))return;try{await fetch(`/api/agents/${c.id}/files/${L}`,{method:"DELETE"}),_((O)=>O.filter((d)=>d.id!==L))}catch{}},ma=(L,ra)=>{let O=document.createElement("a");O.href=`/api/agents/${c.id}/files/${L}/download`,O.download=ra,O.click()},wa=(L)=>{if(L<1024)return`${L} B`;if(L<1048576)return`${(L/1024).toFixed(1)} KB`;return`${(L/1048576).toFixed(1)} MB`},oa=async(L)=>{N(!0),W(null);try{let ra=new FormData;ra.append("file",L);let O=await fetch(`/api/agents/${c.id}/files`,{method:"POST",body:ra});if(!O.ok){let d=await O.json();throw Error(d.error||"Upload failed")}await s()}catch(ra){W(ra instanceof Error?ra.message:"Upload failed")}finally{N(!1)}},e=(L)=>{let ra=L.target.files?.[0];if(ra)oa(ra);L.target.value=""},La=(L)=>{L.preventDefault(),k(!1);let ra=L.dataTransfer.files?.[0];if(ra)oa(ra)},ha=(L)=>{L.preventDefault(),k(!0)},V=(L)=>{L.preventDefault(),k(!1)},Ca=(L)=>{if(L.startsWith("image/"))return"\uD83D\uDDBC";if(L.includes("pdf"))return"\uD83D\uDCD5";if(L.includes("json"))return"{}";if(L.includes("javascript")||L.includes("typescript"))return"⚡";if(L.startsWith("text/"))return"\uD83D\uDCC4";if(L.startsWith("audio/"))return"\uD83C\uDFB5";if(L.startsWith("video/"))return"\uD83C\uDFAC";return"\uD83D\uDCC1"};if(!c.features?.files)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("div",{className:"text-center",children:[w.jsxDEV("p",{className:"mb-2",children:"Files feature is not enabled"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-sm",children:"Enable it in Settings to manage files"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);if(c.status!=="running")return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("p",{children:"Start the agent to view files"},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(U)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("p",{children:"Loading files..."},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(y)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-red-400",children:w.jsxDEV("p",{children:y},void 0,!1,void 0,this)},void 0,!1,void 0,this);return w.jsxDEV(w.Fragment,{children:[P,w.jsxDEV("div",{className:`flex-1 overflow-auto p-4 transition ${A?"bg-[var(--color-accent-5)]":""}`,onDrop:La,onDragOver:ha,onDragLeave:V,children:[w.jsxDEV("input",{ref:x,type:"file",className:"hidden",onChange:e},void 0,!1,void 0,this),w.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[w.jsxDEV("h3",{className:"text-sm font-medium text-[var(--color-text-secondary)]",children:["Agent Files (",Z.length,")"]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"flex items-center gap-2",children:[w.jsxDEV("button",{onClick:()=>x.current?.click(),disabled:G,className:"text-xs bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 text-black px-3 py-1 rounded font-medium transition",children:G?"Uploading...":"Upload"},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:s,className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)]",children:"Refresh"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),I&&w.jsxDEV("div",{className:"mb-4 text-sm bg-red-500/10 text-red-400 px-3 py-2 rounded",children:I},void 0,!1,void 0,this),A&&w.jsxDEV("div",{className:"mb-4 border-2 border-dashed border-[var(--color-accent)] rounded-lg p-8 text-center",children:w.jsxDEV("p",{className:"text-[var(--color-accent)]",children:"Drop file to upload"},void 0,!1,void 0,this)},void 0,!1,void 0,this),Z.length===0&&!A&&w.jsxDEV("div",{className:"text-center py-10 text-[var(--color-text-muted)]",children:[w.jsxDEV("p",{children:"No files stored yet"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-sm mt-1",children:"Drop files here, click Upload, or attach files in Chat"},void 0,!1,void 0,this),c.features?.memory&&w.jsxDEV("p",{className:"text-xs mt-2 text-[var(--color-text-faint)]",children:"Files will be auto-ingested into memory"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z.length>0&&w.jsxDEV("div",{className:"space-y-2",children:Z.map((L)=>w.jsxDEV("div",{className:"bg-[var(--color-surface)] border border-[var(--color-border)] rounded p-3 flex items-center gap-3",children:[w.jsxDEV("div",{className:"w-10 h-10 bg-[var(--color-surface-raised)] rounded flex items-center justify-center text-[var(--color-text-muted)]",children:Ca(L.mime_type)},void 0,!1,void 0,this),w.jsxDEV("div",{className:"flex-1 min-w-0",children:[w.jsxDEV("p",{className:"text-sm text-[var(--color-text)] truncate",children:L.filename},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)]",children:[wa(L.size_bytes)," • ",new Date(L.created_at).toLocaleString(),L.source&&L.source!=="upload"&&` • ${L.source}`]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"flex items-center gap-2",children:[w.jsxDEV("button",{onClick:()=>ma(L.id,L.filename),className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-accent)] px-2 py-1",children:"↓"},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:()=>qa(L.id),className:"text-[var(--color-text-muted)] hover:text-red-400 text-sm",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},L.id,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function lX({agent:c,providers:Z,onUpdateAgent:_,onDeleteAgent:U}){let{authFetch:h,isDev:y}=$o(),[H,G]=aa.useState({name:c.name,provider:c.provider,model:c.model,systemPrompt:c.systemPrompt,features:{...c.features,builtinTools:c.features.builtinTools||{webSearch:!1,webFetch:!1}},mcpServers:[...c.mcpServers||[]],skills:[...c.skills||[]]}),[N,I]=aa.useState(!1),[W,A]=aa.useState(!1),[k,x]=aa.useState(null),[M,P]=aa.useState([]),[s,qa]=aa.useState([]),[ma,wa]=aa.useState([]),[oa,e]=aa.useState(!1),[La,ha]=aa.useState(null),[V,Ca]=aa.useState(null),[L,ra]=aa.useState(!1),[O,d]=aa.useState([]),[fa,C]=aa.useState(null),[T,va]=aa.useState(!1);aa.useEffect(()=>{h(`/api/subscriptions?agent_id=${c.id}`).then((B)=>B.ok?B.json():{subscriptions:[]}).then((B)=>d(B.subscriptions||[])).catch(()=>{})},[c.id,h]),aa.useEffect(()=>{(async()=>{try{let ka=await(await h("/api/mcp/servers")).json();P(ka.servers||[])}catch(u){console.error("Failed to fetch MCP servers:",u)}})()},[h]),aa.useEffect(()=>{(async()=>{try{let u=await h(`/api/agents/${c.id}/api-key`);if(u.ok){let ka=await u.json();ha(ka.apiKey),Ca(ka.fullKey||null)}}catch(u){}})()},[c.id,h]),aa.useEffect(()=>{(async()=>{try{let u=await h(`/api/agents/${c.id}/share-token`);if(u.ok){let ka=await u.json();C(ka.token||null)}}catch{}})()},[c.id,h]),aa.useEffect(()=>{(async()=>{try{let ka=await(await h("/api/skills")).json();qa(ka.skills||[])}catch(u){console.error("Failed to fetch skills:",u)}})()},[h]),aa.useEffect(()=>{if(H.provider==="ollama")e(!0),h("/api/providers/ollama/models").then((B)=>B.json()).then((B)=>{if(B.models&&B.models.length>0)wa(B.models.map((u)=>({value:u.value,label:u.label||u.value})))}).catch(()=>wa([])).finally(()=>e(!1));else wa([])},[H.provider,h]),aa.useEffect(()=>{G({name:c.name,provider:c.provider,model:c.model,systemPrompt:c.systemPrompt,features:{...c.features,builtinTools:c.features.builtinTools||{webSearch:!1,webFetch:!1}},mcpServers:[...c.mcpServers||[]],skills:[...c.skills||[]]}),x(null)},[c.id]);let Pa=Z.find((B)=>B.id===H.provider),xa=Z.filter((B)=>B.hasKey&&B.type==="llm").map((B)=>({value:B.id,label:B.name})),So=H.provider==="ollama"&&ma.length>0?ma:Pa?.models.map((B)=>({value:B.value,label:B.label,recommended:B.recommended}))||[],$p=(B)=>{let u=Z.find((jo)=>jo.id===B),ka=u?.models.find((jo)=>jo.recommended)?.value||u?.models[0]?.value||"";G((jo)=>({...jo,provider:B,model:ka}))},S=(B)=>{if(B==="agents")G((u)=>{if(typeof u.features.agents==="boolean"?u.features.agents:u.features.agents?.enabled??!1)return{...u,features:{...u.features,agents:!1}};else return{...u,features:{...u.features,agents:{enabled:!0,group:c.projectId||void 0}}}});else if(B==="operator")G((u)=>{if(S5(u.features).enabled)return{...u,features:{...u.features,operator:!1}};else return{...u,features:{...u.features,operator:{enabled:!0}}}});else G((u)=>({...u,features:{...u.features,[B]:!u.features[B]}}))},_a=()=>{let B=H.features.agents;if(typeof B==="boolean")return B;return B?.enabled??!1},sa=()=>{return S5(H.features).enabled},pr=()=>{return S5(H.features)},jr=Z.filter((B)=>B.type==="browser"&&B.hasKey),Er=(B)=>{G((u)=>{let ka=S5(u.features);return{...u,features:{...u.features,operator:{...ka,enabled:!0,browser_provider:B}}}})},mr=(B)=>{G((u)=>({...u,mcpServers:u.mcpServers.includes(B)?u.mcpServers.filter((ka)=>ka!==B):[...u.mcpServers,B]}))},vm=(B)=>{G((u)=>({...u,skills:u.skills.includes(B)?u.skills.filter((ka)=>ka!==B):[...u.skills,B]}))},sr=async()=>{I(!0),x(null);let B=await _(H);if(I(!1),B.error)x({type:"error",text:B.error});else x({type:"success",text:"Settings saved"}),setTimeout(()=>x(null),2000)},F=H.name!==c.name||H.provider!==c.provider||H.model!==c.model||H.systemPrompt!==c.systemPrompt||JSON.stringify(H.features)!==JSON.stringify(c.features)||JSON.stringify(H.mcpServers.sort())!==JSON.stringify((c.mcpServers||[]).sort())||JSON.stringify(H.skills.sort())!==JSON.stringify((c.skills||[]).sort());return w.jsxDEV("div",{className:"flex-1 overflow-auto p-4",children:w.jsxDEV("div",{className:"space-y-4",children:[w.jsxDEV(lt,{label:"Name",children:w.jsxDEV("input",{type:"text",value:H.name,onChange:(B)=>G((u)=>({...u,name:B.target.value})),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)]"},void 0,!1,void 0,this)},void 0,!1,void 0,this),w.jsxDEV(lt,{label:"Provider",children:w.jsxDEV(ct,{value:H.provider,options:xa,onChange:$p},void 0,!1,void 0,this)},void 0,!1,void 0,this),w.jsxDEV(lt,{label:"Model",children:oa?w.jsxDEV("div",{className:"text-sm text-[var(--color-text-muted)] py-2",children:"Loading Ollama models..."},void 0,!1,void 0,this):H.provider==="ollama"&&So.length===0?w.jsxDEV("div",{className:"text-sm text-yellow-400/80 py-2",children:["No models found. Run ",w.jsxDEV("code",{className:"bg-[var(--color-surface-raised)] px-1 rounded",children:"ollama pull llama3.3"},void 0,!1,void 0,this)," to download a model."]},void 0,!0,void 0,this):w.jsxDEV(ct,{value:H.model,options:So,onChange:(B)=>G((u)=>({...u,model:B}))},void 0,!1,void 0,this)},void 0,!1,void 0,this),w.jsxDEV(lt,{label:"System Prompt",children:w.jsxDEV("textarea",{value:H.systemPrompt,onChange:(B)=>G((u)=>({...u,systemPrompt:B.target.value})),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 h-24 resize-none focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)]"},void 0,!1,void 0,this)},void 0,!1,void 0,this),w.jsxDEV(lt,{label:"Features",children:w.jsxDEV("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:rX.map(({key:B,label:u,description:ka,icon:jo})=>{let Ta=B==="agents"?_a():B==="operator"?sa():!!H.features[B];return w.jsxDEV("button",{type:"button",onClick:()=>S(B),className:`flex items-center gap-3 p-3 rounded border text-left transition ${Ta?"border-[var(--color-accent)] bg-[var(--color-accent-10)]":"border-[var(--color-border-light)] hover:border-[var(--color-border-light)]"}`,children:[w.jsxDEV(jo,{className:`w-5 h-5 flex-shrink-0 ${Ta?"text-[var(--color-accent)]":"text-[var(--color-text-muted)]"}`},void 0,!1,void 0,this),w.jsxDEV("div",{className:"flex-1 min-w-0",children:[w.jsxDEV("div",{className:`text-sm font-medium ${Ta?"text-[var(--color-accent)]":""}`,children:u},void 0,!1,void 0,this),w.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)]",children:ka},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},B,!0,void 0,this)})},void 0,!1,void 0,this)},void 0,!1,void 0,this),sa()&&w.jsxDEV(lt,{label:"Browser Provider",children:jr.length>0?w.jsxDEV(ct,{value:pr().browser_provider||"",options:[{value:"",label:"Auto (first available)"},...jr.map((B)=>({value:B.id,label:B.name}))],onChange:(B)=>Er(B)},void 0,!1,void 0,this):w.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] p-3 border border-[var(--color-border-light)] rounded bg-[var(--color-bg)]",children:"No browser providers configured. Go to Settings → Providers to add one."},void 0,!1,void 0,this)},void 0,!1,void 0,this),H.provider==="anthropic"&&w.jsxDEV(lt,{label:"Agent Built-in Tools",children:[w.jsxDEV("div",{className:"flex flex-wrap gap-2",children:[w.jsxDEV("button",{type:"button",onClick:()=>G((B)=>({...B,features:{...B.features,builtinTools:{...B.features.builtinTools,webSearch:!B.features.builtinTools?.webSearch}}})),className:`flex items-center gap-2 px-3 py-2 rounded border transition ${H.features.builtinTools?.webSearch?"border-[var(--color-accent)] bg-[var(--color-accent-10)] text-[var(--color-accent)]":"border-[var(--color-border-light)] hover:border-[var(--color-border-light)] text-[var(--color-text-secondary)]"}`,children:[w.jsxDEV("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:w.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"},void 0,!1,void 0,this)},void 0,!1,void 0,this),w.jsxDEV("span",{className:"text-sm",children:"Web Search"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("button",{type:"button",onClick:()=>G((B)=>({...B,features:{...B.features,builtinTools:{...B.features.builtinTools,webFetch:!B.features.builtinTools?.webFetch}}})),className:`flex items-center gap-2 px-3 py-2 rounded border transition ${H.features.builtinTools?.webFetch?"border-[var(--color-accent)] bg-[var(--color-accent-10)] text-[var(--color-accent)]":"border-[var(--color-border-light)] hover:border-[var(--color-border-light)] text-[var(--color-text-secondary)]"}`,children:[w.jsxDEV("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:w.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"},void 0,!1,void 0,this)},void 0,!1,void 0,this),w.jsxDEV("span",{className:"text-sm",children:"Web Fetch"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-2",children:"Provider-native tools for real-time web access"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H.features.mcp&&w.jsxDEV(lt,{label:"MCP Servers",children:M.length===0?w.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:"No MCP servers configured. Add servers in the MCP page first."},void 0,!1,void 0,this):w.jsxDEV("div",{className:"space-y-2",children:[M.filter((B)=>B.project_id===null||B.project_id===c.projectId).map((B)=>{let u=B.type==="http"&&B.url,ka=u||B.status==="running",jo=u?`${B.source||"remote"} • http`:`${B.type} • ${B.package||B.command||"custom"}${B.status==="running"&&B.port?` • :${B.port}`:""}`;return w.jsxDEV("button",{type:"button",onClick:()=>mr(B.id),className:`w-full flex items-center gap-3 p-3 rounded border text-left transition ${H.mcpServers.includes(B.id)?"border-[var(--color-accent)] bg-[var(--color-accent-10)]":"border-[var(--color-border-light)] hover:border-[var(--color-border-light)]"}`,children:[w.jsxDEV("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${ka?"bg-green-400":"bg-[var(--color-scrollbar)]"}`},void 0,!1,void 0,this),w.jsxDEV("div",{className:"flex-1 min-w-0",children:[w.jsxDEV("div",{className:"flex items-center gap-2",children:[w.jsxDEV("span",{className:`text-sm font-medium ${H.mcpServers.includes(B.id)?"text-[var(--color-accent)]":""}`,children:B.name},void 0,!1,void 0,this),B.project_id===null&&w.jsxDEV("span",{className:"text-[10px] text-[var(--color-text-muted)] bg-[var(--color-surface-raised)] px-1.5 py-0.5 rounded",children:"Global"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)]",children:jo},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:`text-xs px-2 py-0.5 rounded ${ka?"bg-green-500/20 text-green-400":"bg-[var(--color-surface-raised)] text-[var(--color-text-muted)]"}`,children:u?"remote":B.status},void 0,!1,void 0,this)]},B.id,!0,void 0,this)}),w.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] mt-2",children:"Remote servers are always available. Local servers must be running."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),w.jsxDEV(lt,{label:"Skills",children:s.length===0?w.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:"No skills configured. Add skills in the Skills page first."},void 0,!1,void 0,this):w.jsxDEV("div",{className:"space-y-2",children:[s.filter((B)=>B.enabled&&(B.project_id===null||B.project_id===c.projectId)).map((B)=>w.jsxDEV("button",{type:"button",onClick:()=>vm(B.id),className:`w-full flex items-center gap-3 p-3 rounded border text-left transition ${H.skills.includes(B.id)?"border-[var(--color-accent)] bg-[var(--color-accent-10)]":"border-[var(--color-border-light)] hover:border-[var(--color-border-light)]"}`,children:[w.jsxDEV("div",{className:"flex-1 min-w-0",children:[w.jsxDEV("div",{className:"flex items-center gap-2",children:[w.jsxDEV("span",{className:`text-sm font-medium ${H.skills.includes(B.id)?"text-[var(--color-accent)]":""}`,children:B.name},void 0,!1,void 0,this),B.project_id===null&&w.jsxDEV("span",{className:"text-[10px] text-[var(--color-text-muted)] bg-[var(--color-surface-raised)] px-1.5 py-0.5 rounded",children:"Global"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)]",children:B.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"text-xs px-2 py-0.5 rounded bg-[var(--color-surface-raised)] text-[var(--color-text-muted)]",children:["v",B.version]},void 0,!0,void 0,this)]},B.id,!0,void 0,this)),w.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] mt-2",children:"Skills provide reusable instructions for the agent."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),k&&w.jsxDEV("div",{className:`text-sm px-3 py-2 rounded ${k.type==="success"?"bg-green-500/10 text-green-400":"bg-red-500/10 text-red-400"}`,children:k.text},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:sr,disabled:!F||N||!H.name,className:"w-full bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 disabled:cursor-not-allowed text-black px-4 py-2 rounded font-medium transition",children:N?"Saving...":"Save Changes"},void 0,!1,void 0,this),c.status==="running"&&F&&w.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] text-center",children:"Changes will be applied to the running agent"},void 0,!1,void 0,this),w.jsxDEV("div",{className:"mt-8 pt-6 border-t border-[var(--color-border-light)]",children:[w.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] mb-3",children:"Subscriptions"},void 0,!1,void 0,this),O.length===0?w.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)]",children:"No subscriptions. Set up triggers in Connections to have this agent listen to external events."},void 0,!1,void 0,this):w.jsxDEV("div",{className:"space-y-2",children:O.map((B)=>w.jsxDEV("div",{className:"flex items-center gap-2 px-3 py-2 bg-[var(--color-surface)] rounded border border-[var(--color-border)]",children:[w.jsxDEV("span",{className:`w-2 h-2 rounded-full shrink-0 ${B.enabled?"bg-cyan-400":"bg-[var(--color-scrollbar)]"}`},void 0,!1,void 0,this),w.jsxDEV("span",{className:`text-sm flex-1 ${B.enabled?"text-cyan-400":"text-[var(--color-text-muted)]"}`,children:B.trigger_slug.replace(/_/g," ")},void 0,!1,void 0,this),w.jsxDEV("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${B.enabled?"bg-cyan-500/10 text-cyan-400":"bg-[var(--color-surface-raised)] text-[var(--color-text-faint)]"}`,children:B.enabled?"active":"disabled"},void 0,!1,void 0,this)]},B.id,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),La&&w.jsxDEV("div",{className:"mt-8 pt-6 border-t border-[var(--color-border-light)]",children:[w.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] mb-3",children:"Developer Info"},void 0,!1,void 0,this),w.jsxDEV("div",{className:"space-y-2",children:[w.jsxDEV("div",{className:"flex items-center justify-between",children:[w.jsxDEV("span",{className:"text-xs text-[var(--color-text-muted)]",children:"Agent ID"},void 0,!1,void 0,this),w.jsxDEV("code",{className:"text-xs bg-[var(--color-surface-raised)] px-2 py-1 rounded text-[var(--color-text-secondary)]",children:c.id},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"flex items-center justify-between",children:[w.jsxDEV("span",{className:"text-xs text-[var(--color-text-muted)]",children:"Port"},void 0,!1,void 0,this),w.jsxDEV("code",{className:"text-xs bg-[var(--color-surface-raised)] px-2 py-1 rounded text-[var(--color-text-secondary)]",children:c.port||"N/A"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"flex flex-col gap-1",children:[w.jsxDEV("div",{className:"flex items-center justify-between",children:[w.jsxDEV("span",{className:"text-xs text-[var(--color-text-muted)]",children:"API Key"},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:()=>ra(!L),className:"text-xs text-[var(--color-accent)] hover:text-[var(--color-accent-hover)]",children:L?"Hide":"Show"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("code",{className:"text-xs bg-[var(--color-surface-raised)] px-2 py-1 rounded text-[var(--color-text-secondary)] break-all",children:L?V||La:La},void 0,!1,void 0,this)]},void 0,!0,void 0,this),c.status==="running"&&c.port&&w.jsxDEV("div",{className:"flex flex-col gap-1 mt-2",children:[w.jsxDEV("span",{className:"text-xs text-[var(--color-text-muted)]",children:"Test with curl"},void 0,!1,void 0,this),w.jsxDEV("code",{className:"text-xs bg-[var(--color-surface-raised)] px-2 py-1.5 rounded text-[var(--color-text-muted)] break-all",children:['curl -H "X-API-Key: ',L?V||La:"***",'" http://localhost:',c.port,"/config"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),fa&&w.jsxDEV("div",{className:"mt-8 pt-6 border-t border-[var(--color-border-light)]",children:[w.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] mb-3",children:"Share Link"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mb-3",children:"Anyone with this link can chat with this agent. No login required. Regenerate the API key to invalidate."},void 0,!1,void 0,this),w.jsxDEV("div",{className:"flex gap-2",children:[w.jsxDEV("code",{className:"flex-1 text-xs bg-[var(--color-surface-raised)] px-3 py-2 rounded text-[var(--color-text-secondary)] break-all border border-[var(--color-border-light)]",children:`${window.location.origin}/share/${fa}`},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:()=>{navigator.clipboard.writeText(`${window.location.origin}/share/${fa}`),va(!0),setTimeout(()=>va(!1),2000)},className:"px-3 py-2 text-xs bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] border border-[var(--color-border-light)] rounded text-[var(--color-text-secondary)] hover:text-[var(--color-text)] transition flex-shrink-0",children:T?"Copied!":"Copy"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"mt-3",children:[w.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mb-1",children:"Embed"},void 0,!1,void 0,this),w.jsxDEV("code",{className:"block text-xs bg-[var(--color-surface-raised)] px-3 py-2 rounded text-[var(--color-text-muted)] break-all border border-[var(--color-border-light)]",children:`<iframe src="${window.location.origin}/share/${fa}" width="400" height="600" style="border:none; border-radius:12px;" />`},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"mt-8 pt-6 border-t border-[var(--color-border-light)]",children:[w.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] mb-3",children:"Danger Zone"},void 0,!1,void 0,this),W?w.jsxDEV("div",{className:"flex gap-2",children:[w.jsxDEV("button",{onClick:()=>A(!1),className:"flex-1 border border-[var(--color-border-light)] hover:border-[var(--color-scrollbar)] px-4 py-2 rounded font-medium transition",children:"Cancel"},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:U,className:"flex-1 bg-red-500/20 text-red-400 hover:bg-red-500/30 px-4 py-2 rounded font-medium transition",children:"Confirm Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):w.jsxDEV("button",{onClick:()=>A(!0),className:"w-full border border-red-500/30 text-red-400/70 hover:border-red-500/50 hover:text-red-400 px-4 py-2 rounded font-medium transition",children:"Delete Agent"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function lt({label:c,children:Z}){return w.jsxDEV("div",{children:[w.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:c},void 0,!1,void 0,this),Z]},void 0,!0,void 0,this)}var s9=Ga(Do(),1);var po=Ga(vo(),1);function d1({agents:c,loading:Z,selectedAgent:_,providers:U,onSelectAgent:h,onCloseAgent:y,onToggleAgent:H,onDeleteAgent:G,onUpdateAgent:N,onNewAgent:I,canCreateAgent:W=!0}){let{currentProjectId:A,currentProject:k}=vp(),x=s9.useMemo(()=>{if(A===null)return c;if(A==="unassigned")return c.filter((P)=>!P.projectId);return c.filter((P)=>P.projectId===A)},[c,A]),M=A===null?"Agents":A==="unassigned"?"Unassigned Agents":k?.name||"Agents";return po.jsxDEV("div",{className:"flex-1 flex overflow-hidden relative",children:[po.jsxDEV("div",{className:"flex-1 overflow-auto p-6",children:[po.jsxDEV("div",{className:"flex items-center justify-between mb-6",children:[po.jsxDEV("div",{className:"flex items-center gap-3",children:[k&&po.jsxDEV("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:k.color}},void 0,!1,void 0,this),po.jsxDEV("h1",{className:"text-xl font-semibold",children:M},void 0,!1,void 0,this),A!==null&&po.jsxDEV("span",{className:"text-sm text-[var(--color-text-muted)]",children:["(",x.length," agent",x.length!==1?"s":"",")"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),I&&po.jsxDEV("button",{onClick:I,disabled:!W,className:"bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 disabled:cursor-not-allowed text-black px-4 py-2 rounded font-medium transition",children:"+ New Agent"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z?po.jsxDEV(Dr,{message:"Loading agents..."},void 0,!1,void 0,this):x.length===0?po.jsxDEV(zX,{onNewAgent:I,canCreateAgent:W,hasProjectFilter:A!==null},void 0,!1,void 0,this):po.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3 auto-rows-fr",children:x.map((P)=>po.jsxDEV(K1,{agent:P,selected:_?.id===P.id,onSelect:()=>h(P),onToggle:(s)=>H(P,s),showProject:A===null},P.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_&&po.jsxDEV("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-[2px] z-10",onClick:y},void 0,!1,void 0,this),_&&po.jsxDEV("div",{className:"absolute right-0 top-0 bottom-0 w-full sm:w-[500px] lg:w-[600px] xl:w-[700px] z-20",children:po.jsxDEV(U1,{agent:_,providers:U,onClose:y,onStartAgent:(P)=>H(_,P),onUpdateAgent:(P)=>N(_.id,P),onDeleteAgent:()=>G(_.id)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function zX({onNewAgent:c,canCreateAgent:Z,hasProjectFilter:_}){return po.jsxDEV("div",{className:"text-center py-20 text-[var(--color-text-muted)]",children:[_?po.jsxDEV(po.Fragment,{children:[po.jsxDEV("p",{className:"text-lg",children:"No agents in this project"},void 0,!1,void 0,this),po.jsxDEV("p",{className:"text-sm mt-1",children:"Create an agent or assign existing agents to this project"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):po.jsxDEV(po.Fragment,{children:[po.jsxDEV("p",{className:"text-lg",children:"No agents yet"},void 0,!1,void 0,this),po.jsxDEV("p",{className:"text-sm mt-1",children:"Create your first agent to get started"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),c&&po.jsxDEV("button",{onClick:c,disabled:!Z,className:"mt-4 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 disabled:cursor-not-allowed text-black px-4 py-2 rounded font-medium transition",children:"+ New Agent"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var wo=Ga(Do(),1);var D=Ga(vo(),1);function y1({agents:c,loading:Z,runningCount:_,configuredProviders:U,onNavigate:h,onSelectAgent:y}){let{authFetch:H}=$o(),{currentProjectId:G}=vp(),{events:N,statusChangeCounter:I}=u5(),{events:W}=W1({category:"TASK"}),A=wo.useRef(null),[k,x]=wo.useState(null),[M,P]=wo.useState([]),[s,qa]=wo.useState([]),[ma,wa]=wo.useState(null),oa=wo.useMemo(()=>{if(!G)return c;if(G==="unassigned")return c.filter((O)=>!O.projectId);return c.filter((O)=>O.projectId===G)},[c,G]),e=wo.useMemo(()=>{return oa.filter((O)=>O.status==="running").length},[oa]),La=wo.useMemo(()=>{return new Set(oa.map((O)=>O.id))},[oa]),ha=wo.useCallback(async()=>{try{let O=G?`project_id=${encodeURIComponent(G)}`:"",[d,fa,C]=await Promise.all([H(`/api/dashboard${O?`?${O}`:""}`),H(`/api/tasks?status=all${O?`&${O}`:""}`),H(`/api/telemetry/events?type=thread_activity&limit=20${O?`&${O}`:""}`)]);if(d.ok){let T=await d.json();x(T)}if(fa.ok){let T=await fa.json();P(T.tasks||[])}if(C.ok){let T=await C.json();qa(T.events||[])}}catch(O){console.error("Failed to fetch dashboard data:",O)}},[H,G]);wo.useEffect(()=>{ha()},[ha,I]),wo.useEffect(()=>{if(!W.length)return;let O=W[0];if(!O||O.id===A.current)return;if(O.type==="task_created"||O.type==="task_updated"||O.type==="task_deleted")A.current=O.id,ha()},[W,ha]);let V=wo.useMemo(()=>{let O=G?M.filter((d)=>La.has(d.agentId)):M;return GX(O)},[M,G,La]),Ca=wo.useMemo(()=>{if(!G)return k?.tasks||{total:0,pending:0,running:0,completed:0};let O=V.length,d=V.filter((T)=>T.status==="pending").length,fa=V.filter((T)=>T.status==="running").length,C=V.filter((T)=>T.status==="completed").length;return{total:O,pending:d,running:fa,completed:C}},[k,G,V]),L=wo.useMemo(()=>{let O=N.filter((T)=>T.type==="thread_activity"&&!T.data?.parent_id),d=new Set(O.map((T)=>T.id)),fa=[...O];for(let T of s)if(!d.has(T.id)&&!T.data?.parent_id)fa.push(T),d.add(T.id);let C=fa;if(G)C=fa.filter((T)=>La.has(T.agent_id));return C.sort((T,va)=>new Date(va.timestamp).getTime()-new Date(T.timestamp).getTime()),C.slice(0,12)},[N,s,G,La]),ra=wo.useMemo(()=>{let O=new Map;for(let d of c)O.set(d.id,d.name);return O},[c]);return D.jsxDEV("div",{className:"flex-1 overflow-auto p-6",children:[D.jsxDEV("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 mb-6",children:[D.jsxDEV(R1,{label:"Agents",value:oa.length,subValue:`${e} running`},void 0,!1,void 0,this),D.jsxDEV(R1,{label:"Tasks",value:Ca.total,subValue:`${Ca.pending} pending`},void 0,!1,void 0,this),D.jsxDEV(R1,{label:"Completed",value:Ca.completed,color:"text-green-400"},void 0,!1,void 0,this),D.jsxDEV(R1,{label:"Providers",value:U.length,color:"text-[var(--color-accent)]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D.jsxDEV("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[D.jsxDEV(y7,{title:"Agents",actionLabel:"View All",onAction:()=>h("agents"),children:Z?D.jsxDEV("div",{className:"p-4 text-center text-[var(--color-text-muted)]",children:"Loading..."},void 0,!1,void 0,this):oa.length===0?D.jsxDEV("div",{className:"p-4 text-center text-[var(--color-text-muted)]",children:"No agents yet"},void 0,!1,void 0,this):D.jsxDEV("div",{className:"divide-y divide-[var(--color-border)]",children:oa.slice(0,5).map((O)=>D.jsxDEV($X,{agent:O,onSelect:()=>y(O),onMessage:O.status==="running"?()=>wa(O):void 0,showProject:!G},O.id,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),D.jsxDEV(y7,{title:"Activity",actionLabel:"Analytics",onAction:()=>h("analytics"),children:L.length===0?D.jsxDEV("div",{className:"p-4 text-center text-[var(--color-text-muted)]",children:[D.jsxDEV("p",{children:"No activity yet"},void 0,!1,void 0,this),D.jsxDEV("p",{className:"text-sm text-[var(--color-text-faint)] mt-1",children:"Agent activity will appear here in real-time"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):D.jsxDEV("div",{className:"divide-y divide-[var(--color-border)]",children:L.map((O)=>D.jsxDEV(YX,{activity:O.data?.activity||"Working...",agentName:ra.get(O.agent_id)||O.agent_id,timestamp:O.timestamp},O.id,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),D.jsxDEV(y7,{title:"Tasks",actionLabel:"View All",onAction:()=>h("tasks"),children:V.length===0?D.jsxDEV("div",{className:"p-4 text-center text-[var(--color-text-muted)]",children:[D.jsxDEV("p",{children:"No tasks yet"},void 0,!1,void 0,this),D.jsxDEV("p",{className:"text-sm text-[var(--color-text-faint)] mt-1",children:"Tasks will appear when agents create them"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):D.jsxDEV("div",{className:"divide-y divide-[var(--color-border)]",children:V.slice(0,5).map((O)=>D.jsxDEV("div",{className:"px-4 py-3 flex items-center justify-between",children:[D.jsxDEV("div",{className:"flex-1 min-w-0",children:[D.jsxDEV("p",{className:"font-medium truncate",children:O.title},void 0,!1,void 0,this),D.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:[O.agentName,O.recurrence&&D.jsxDEV("span",{className:"ml-1 text-[var(--color-text-faint)]",children:["· ",_X(O.recurrence)]},void 0,!0,void 0,this),O.next_run&&D.jsxDEV("span",{className:"ml-1 text-[var(--color-accent)]",children:["· ",az(O.next_run)]},void 0,!0,void 0,this),!O.next_run&&O.execute_at&&D.jsxDEV("span",{className:"ml-1 text-[var(--color-accent)]",children:["· ",az(O.execute_at)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),D.jsxDEV(XX,{status:O.status},void 0,!1,void 0,this)]},`${O.agentId}-${O.id}`,!0,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ma&&D.jsxDEV(ZX,{agent:ma,onClose:()=>wa(null)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function R1({label:c,value:Z,subValue:_,color:U}){return D.jsxDEV("div",{className:"bg-[var(--color-surface)] rounded p-4 border border-[var(--color-border)]",children:[D.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] mb-1",children:c},void 0,!1,void 0,this),D.jsxDEV("p",{className:`text-2xl font-semibold ${U||""}`,children:Z},void 0,!1,void 0,this),_&&D.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-1",children:_},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function y7({title:c,actionLabel:Z,onAction:_,children:U}){return D.jsxDEV("div",{className:"bg-[var(--color-surface)] rounded border border-[var(--color-border)] overflow-hidden",children:[D.jsxDEV("div",{className:"px-4 py-3 border-b border-[var(--color-border)] flex items-center justify-between",children:[D.jsxDEV("h3",{className:"font-semibold",children:c},void 0,!1,void 0,this),D.jsxDEV("button",{onClick:_,className:"text-sm text-[#3b82f6] hover:text-[#60a5fa]",children:Z},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U]},void 0,!0,void 0,this)}function $X({agent:c,onSelect:Z,onMessage:_,showProject:U}){let{isActive:h,label:y}=B1(c.id),{projects:H}=vp(),G=c.projectId?H.find((N)=>N.id===c.projectId):null;return D.jsxDEV("div",{onClick:Z,className:"px-4 py-3 hover:bg-[var(--color-surface-raised)] cursor-pointer flex items-center justify-between group",children:[D.jsxDEV("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[D.jsxDEV("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${c.status==="running"?h?"bg-green-400 animate-pulse":"bg-[#3b82f6]":"bg-[var(--color-scrollbar)]"}`},void 0,!1,void 0,this),D.jsxDEV("div",{className:"flex-1 min-w-0",children:[D.jsxDEV("p",{className:"font-medium truncate",children:c.name},void 0,!1,void 0,this),D.jsxDEV("div",{className:"flex items-center gap-2 text-sm text-[var(--color-text-muted)]",children:[h&&y?D.jsxDEV("span",{className:"text-green-400 truncate",children:y},void 0,!1,void 0,this):D.jsxDEV("span",{children:[c.provider," · ",c.status==="running"?"idle":"stopped"]},void 0,!0,void 0,this),U&&G&&D.jsxDEV(D.Fragment,{children:[D.jsxDEV("span",{className:"text-[var(--color-text-faint)]",children:"·"},void 0,!1,void 0,this),D.jsxDEV("span",{className:"flex items-center gap-1",children:[D.jsxDEV("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:G.color}},void 0,!1,void 0,this),G.name]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),_&&D.jsxDEV("button",{onClick:(N)=>{N.stopPropagation(),_()},className:"opacity-0 group-hover:opacity-100 transition px-2 py-1 text-xs text-[var(--color-accent)] hover:bg-[var(--color-accent-10)] rounded",title:"Send message",children:D.jsxDEV("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:D.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function JX(c){let Z=Math.floor((Date.now()-new Date(c).getTime())/1000);if(Z<5)return"just now";if(Z<60)return`${Z}s ago`;let _=Math.floor(Z/60);if(_<60)return`${_}m ago`;let U=Math.floor(_/60);if(U<24)return`${U}h ago`;return`${Math.floor(U/24)}d ago`}function YX({activity:c,agentName:Z,timestamp:_}){return D.jsxDEV("div",{className:"px-4 py-3",children:[D.jsxDEV("p",{className:"text-sm truncate",children:c},void 0,!1,void 0,this),D.jsxDEV("div",{className:"flex items-center gap-2 text-xs text-[var(--color-text-faint)] mt-1",children:[D.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:Z},void 0,!1,void 0,this),D.jsxDEV("span",{className:"text-[var(--color-text-faint)]",children:"·"},void 0,!1,void 0,this),D.jsxDEV("span",{children:JX(_)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function XX({status:c}){let Z={pending:"bg-yellow-500/20 text-yellow-400",running:"bg-blue-500/20 text-blue-400",completed:"bg-green-500/20 text-green-400",failed:"bg-red-500/20 text-red-400",cancelled:"bg-gray-500/20 text-gray-400"};return D.jsxDEV("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${Z[c]||Z.pending}`,children:c},void 0,!1,void 0,this)}function ZX({agent:c,onClose:Z}){let{authFetch:_}=$o(),[U,h]=wo.useState(""),[y,H]=wo.useState(!1),[G,N]=wo.useState(!1),I=wo.useRef(null);wo.useEffect(()=>{I.current?.focus()},[]);let W=async()=>{if(!U.trim()||y)return;H(!0);try{if((await _(`/api/agents/${c.id}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:U.trim(),agent_id:c.id})})).ok)N(!0),setTimeout(Z,1200)}catch{}finally{H(!1)}};return D.jsxDEV("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[D.jsxDEV("div",{className:"absolute inset-0 bg-black/60",onClick:Z},void 0,!1,void 0,this),D.jsxDEV("div",{className:"relative bg-[var(--color-surface)] border border-[var(--color-border-light)] rounded-xl shadow-2xl w-full max-w-md mx-4 p-5",children:[D.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[D.jsxDEV("div",{className:"flex items-center gap-3",children:[D.jsxDEV("span",{className:"w-2.5 h-2.5 rounded-full bg-green-400 animate-pulse"},void 0,!1,void 0,this),D.jsxDEV("h3",{className:"font-medium",children:c.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D.jsxDEV("button",{onClick:Z,className:"text-[var(--color-text-muted)] hover:text-[var(--color-text)] transition",children:D.jsxDEV(it,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G?D.jsxDEV("div",{className:"py-6 text-center",children:[D.jsxDEV("p",{className:"text-green-400 font-medium",children:"Message sent"},void 0,!1,void 0,this),D.jsxDEV("p",{className:"text-sm text-[var(--color-text-faint)] mt-1",children:"The agent will process your message"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):D.jsxDEV("div",{className:"flex gap-2",children:[D.jsxDEV("input",{ref:I,type:"text",value:U,onChange:(A)=>h(A.target.value),onKeyDown:(A)=>A.key==="Enter"&&W(),placeholder:`Message ${c.name}...`,disabled:y,className:"flex-1 bg-[var(--color-bg)] border border-[var(--color-border-light)] btn px-3 py-2.5 text-sm focus:outline-none focus:border-[var(--color-accent)] placeholder-[#444] disabled:opacity-50"},void 0,!1,void 0,this),D.jsxDEV("button",{onClick:W,disabled:y||!U.trim(),className:"px-4 py-2.5 bg-[var(--color-accent)] text-black btn text-sm font-medium hover:bg-[var(--color-accent-hover)] transition disabled:opacity-30",children:y?"...":"Send"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function e9(c){if(c.status==="running")return 0;if(c.status==="pending")return 1;if(c.status==="completed")return 2;if(c.status==="failed")return 3;return 4}function GX(c){return[...c].sort((Z,_)=>{let U=e9(Z),h=e9(_);if(U!==h)return U-h;if(U<=1){let G=Z.next_run||Z.execute_at||null,N=_.next_run||_.execute_at||null,I=G?new Date(G).getTime():1/0,W=N?new Date(N).getTime():1/0;return I-W}let y=Z.completed_at||Z.executed_at||Z.created_at,H=_.completed_at||_.executed_at||_.created_at;return new Date(H).getTime()-new Date(y).getTime()})}var oz=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function _X(c){try{let Z=c.trim().split(/\s+/);if(Z.length!==5)return c;let[_,U,h,y,H]=Z;if(_.startsWith("*/")&&U==="*"&&h==="*"&&y==="*"&&H==="*"){let N=parseInt(_.slice(2));return N===1?"Every min":`Every ${N}min`}if(_!=="*"&&!_.includes("/")&&U==="*"&&h==="*"&&y==="*"&&H==="*")return"Hourly";if(U.startsWith("*/")&&h==="*"&&y==="*"&&H==="*"){let N=parseInt(U.slice(2));return N===1?"Hourly":`Every ${N}h`}let G=(N,I)=>{let W=parseInt(N),A=parseInt(I);if(isNaN(W))return"";let k=W>=12?"PM":"AM";return`${W===0?12:W>12?W-12:W}:${A.toString().padStart(2,"0")} ${k}`};if(U!=="*"&&!U.includes("/")&&h==="*"&&y==="*"){let N=G(U,_);if(H==="*")return`Daily ${N}`;let I=H.split(",").map((W)=>oz[parseInt(W.trim())]||W);if(I.length===1)return`${I[0]} ${N}`;return`${I.join(" & ")} ${N}`}return c}catch{return c}}function az(c){let Z=new Date(c),_=new Date,U=Z.getTime()-_.getTime(),h=U>0,y=Math.abs(U),H=Math.floor(y/60000),G=Math.floor(y/3600000),N=Z.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),I=Z.toDateString()===_.toDateString(),W=new Date(_);W.setDate(W.getDate()+1);let A=Z.toDateString()===W.toDateString();if(I){if(H<1)return"now";if(H<60)return h?`in ${H}m`:`${H}m ago`;return h?`in ${G}h`:`${G}h ago`}if(A)return`Tomorrow ${N}`;return`${oz[Z.getDay()]} ${N}`}var Za=Ga(vo(),1),BX=ua.lazy(()=>import("./SettingsPage.zmzm1pp6.js").then((c)=>({default:c.SettingsPage}))),KX=ua.lazy(()=>import("./TasksPage.zp4jfevw.js").then((c)=>({default:c.TasksPage}))),HX=ua.lazy(()=>import("./McpPage.f3ccrezb.js").then((c)=>({default:c.McpPage}))),WX=ua.lazy(()=>import("./SkillsPage.whxnez67.js").then((c)=>({default:c.SkillsPage}))),UX=ua.lazy(()=>import("./TestsPage.18krj0d1.js").then((c)=>({default:c.TestsPage}))),dX=ua.lazy(()=>import("./ThreadsPage.nnphgy98.js").then((c)=>({default:c.ThreadsPage}))),RX=ua.lazy(()=>import("./TelemetryPage.an0ky78c.js").then((c)=>({default:c.TelemetryPage}))),yX=ua.lazy(()=>import("./ConnectionsPage.q5f9fd37.js").then((c)=>({default:c.ConnectionsPage}))),LX=ua.lazy(()=>import("./ActivityPage.sw9p594m.js").then((c)=>({default:c.ActivityPage}))),OX=ua.lazy(()=>import("./ApiDocsPage.90e03bz7.js").then((c)=>({default:c.ApiDocsPage})));function hX(){let{isAuthenticated:c,isLoading:Z,hasUsers:_,accessToken:U,checkAuth:h}=$o(),{currentProjectId:y,refreshProjects:H}=vp(),G=$1(),N=mz(),{isComplete:I,setIsComplete:W}=K7(),A=()=>{return U?{Authorization:`Bearer ${U}`}:{}},k=c&&I===!0,{agents:x,loading:M,runningCount:P,fetchAgents:s,createAgent:qa,updateAgent:ma,deleteAgent:wa,toggleAgent:oa}=Q7(k,y),{providers:e,configuredProviders:La,fetchProviders:ha}=B7(k),V=La.filter((F)=>F.type==="llm"),Ca=ua.useMemo(()=>{if(y===null)return x.length;if(y==="unassigned")return x.filter((F)=>!F.projectId).length;return x.filter((F)=>F.projectId===y).length},[x,y]),[L,ra]=ua.useState(!1),[O,d]=ua.useState(null),[fa,C]=ua.useState("dashboard"),[T,va]=ua.useState(null),[Pa,xa]=ua.useState(0),[So,$p]=ua.useState(!1);ua.useEffect(()=>{if(!k)return;(async()=>{try{let B="/api/tasks?status=pending";if(y!==null)B+=`&project_id=${encodeURIComponent(y)}`;let u=await fetch(B,{headers:A()});if(u.ok){let ka=await u.json();xa(ka.count??(ka.tasks||[]).length)}}catch{}})()},[k,U,y,G,N]);let[S,_a]=ua.useState({name:"",model:"",provider:"",systemPrompt:"You are a helpful assistant.",features:{...q7},mcpServers:[],skills:[]});ua.useEffect(()=>{if(V.length>0&&!S.provider){let F=V[0],B=F.models.find((u)=>u.recommended)?.value||F.models[0]?.value||"";_a((u)=>({...u,provider:F.id,model:B}))}},[V,S.provider]),ua.useEffect(()=>{if(O){let F=x.find((B)=>B.id===O.id);if(F)d(F);else d(null)}},[x,O]);let sa=(F)=>{let B=e.find((ka)=>ka.id===F),u=B?.models.find((ka)=>ka.recommended)?.value||B?.models[0]?.value||"";_a((ka)=>({...ka,provider:F,model:u}))},pr=async()=>{if(!S.name)return;await qa(S),await H();let F=V[0],B=F?.models.find((u)=>u.recommended)?.value||F?.models[0]?.value||"";_a({name:"",model:B,provider:F?.id||"",systemPrompt:"You are a helpful assistant.",features:{...q7},mcpServers:[],skills:[]}),ra(!1)},jr=async(F,B)=>{B?.stopPropagation(),va(null);let u=await oa(F);if(u.error)va(u.error)},Er=async(F,B)=>{if(B?.stopPropagation(),O?.id===F)d(null);await wa(F),await H()},mr=(F)=>{d(F),va(null),C("agents")},vm=(F)=>{C(F),d(null)},sr=()=>{W(!0),ha(),h()};if(Z||_===null)return Za.jsxDEV(Dr,{fullScreen:!0},void 0,!1,void 0,this);if(!_)return Za.jsxDEV(D5,{onComplete:sr,needsAccount:!0},void 0,!1,void 0,this);if(!c)return Za.jsxDEV(_1,{},void 0,!1,void 0,this);if(I===null)return Za.jsxDEV(Dr,{fullScreen:!0},void 0,!1,void 0,this);if(!I)return Za.jsxDEV(D5,{onComplete:sr,needsAccount:!1},void 0,!1,void 0,this);return Za.jsxDEV("div",{className:"h-screen flex flex-col overflow-hidden",style:{backgroundColor:"var(--color-bg)",color:"var(--color-text)"},children:[Za.jsxDEV(J1,{onMenuClick:()=>$p(!0),agents:x},void 0,!1,void 0,this),T&&Za.jsxDEV(G1,{message:T,onDismiss:()=>va(null)},void 0,!1,void 0,this),Za.jsxDEV("div",{className:"flex flex-1 overflow-hidden",children:[Za.jsxDEV(Z1,{route:fa,agentCount:Ca,taskCount:Pa,onNavigate:vm,isOpen:So,onClose:()=>$p(!1)},void 0,!1,void 0,this),Za.jsxDEV("main",{className:"flex-1 overflow-hidden flex",children:Za.jsxDEV(ua.Suspense,{fallback:Za.jsxDEV(Dr,{},void 0,!1,void 0,this),children:[fa==="settings"&&Za.jsxDEV(BX,{},void 0,!1,void 0,this),fa==="agents"&&Za.jsxDEV(d1,{agents:x,loading:M,selectedAgent:O,providers:e,onSelectAgent:mr,onCloseAgent:()=>d(null),onToggleAgent:jr,onDeleteAgent:Er,onUpdateAgent:ma,onNewAgent:()=>ra(!0),canCreateAgent:V.length>0},void 0,!1,void 0,this),fa==="dashboard"&&Za.jsxDEV(y1,{agents:x,loading:M,runningCount:P,configuredProviders:La,onNavigate:vm,onSelectAgent:mr},void 0,!1,void 0,this),fa==="threads"&&Za.jsxDEV(dX,{agents:x,onNavigate:C},void 0,!1,void 0,this),fa==="activity"&&Za.jsxDEV(LX,{agents:x,loading:M,onNavigate:vm},void 0,!1,void 0,this),fa==="tasks"&&Za.jsxDEV(KX,{},void 0,!1,void 0,this),fa==="connections"&&Za.jsxDEV(yX,{},void 0,!1,void 0,this),fa==="mcp"&&Za.jsxDEV(HX,{},void 0,!1,void 0,this),fa==="skills"&&Za.jsxDEV(WX,{},void 0,!1,void 0,this),fa==="tests"&&Za.jsxDEV(UX,{},void 0,!1,void 0,this),fa==="analytics"&&Za.jsxDEV(RX,{},void 0,!1,void 0,this),fa==="api"&&Za.jsxDEV(OX,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),L&&Za.jsxDEV(H1,{form:S,providers:e,configuredProviders:La,onFormChange:_a,onProviderChange:sa,onCreate:pr,onClose:()=>ra(!1),onGoToSettings:()=>{ra(!1),C("settings")}},void 0,!1,void 0,this),Za.jsxDEV(h9,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function kX({token:c}){let{theme:Z}=xr(),[_,U]=ua.useState("checking"),[h,y]=ua.useState("Agent");if(ua.useEffect(()=>{let H=async()=>{try{let N=await fetch(`/share/${c}/info`);if(N.ok){let I=await N.json();y(I.name||"Agent"),U(I.status==="running"?"online":"offline")}else U("offline")}catch{U("offline")}};H();let G=setInterval(H,15000);return()=>clearInterval(G)},[c]),_==="checking")return Za.jsxDEV("div",{className:"min-h-[100dvh] flex items-center justify-center",style:{backgroundColor:"var(--color-bg)"},children:Za.jsxDEV("div",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"Connecting..."},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(_==="offline")return Za.jsxDEV("div",{className:"min-h-[100dvh] flex items-center justify-center",style:{backgroundColor:"var(--color-bg)"},children:Za.jsxDEV("div",{className:"text-center",children:[Za.jsxDEV("div",{className:"w-2.5 h-2.5 rounded-full mx-auto mb-3",style:{backgroundColor:"var(--color-text-muted)"}},void 0,!1,void 0,this),Za.jsxDEV("div",{className:"text-base font-semibold mb-1.5",style:{color:"var(--color-text)"},children:h},void 0,!1,void 0,this),Za.jsxDEV("div",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"This agent is currently offline"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);return Za.jsxDEV("div",{className:"min-h-[100dvh] flex items-center justify-center p-0 md:p-4",style:{backgroundColor:"var(--color-bg)"},children:Za.jsxDEV("div",{className:"w-full max-w-[640px] h-[100dvh] md:h-[calc(100dvh-32px)] md:max-h-[800px] md:rounded-xl overflow-hidden md:border flex flex-col",style:{backgroundColor:"var(--color-bg)",borderColor:"var(--color-border)"},children:Za.jsxDEV(ur,{agentId:"default",apiUrl:`/share/${c}`,placeholder:"Type a message...",variant:"terminal",theme:Z.id,headerTitle:h,enableMarkdown:!0,enableWidgets:!0,availableWidgets:["form","kpi"]},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function NX(){let c=window.location.pathname.match(/^\/share\/([a-f0-9]{32})$/);if(c)return Za.jsxDEV(L7,{children:Za.jsxDEV(kX,{token:c[1]},void 0,!1,void 0,this)},void 0,!1,void 0,this);return Za.jsxDEV(L7,{children:Za.jsxDEV(tz,{children:Za.jsxDEV(rz,{children:Za.jsxDEV(L9,{children:Za.jsxDEV(pz,{children:Za.jsxDEV(hX,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}var MX=vz.createRoot(document.getElementById("root"));MX.render(Za.jsxDEV(NX,{},void 0,!1,void 0,this));
219
+ `,style:{backgroundColor:"var(--color-bg)",borderRight:"1px solid var(--color-border)"},children:[$a.jsxDEV("div",{className:"flex items-center justify-between mb-4 md:hidden",children:[$a.jsxDEV("div",{className:"flex items-center gap-2",children:[$a.jsxDEV("span",{style:{color:"var(--color-accent)"},children:">_"},void 0,!1,void 0,this),$a.jsxDEV("span",{className:"text-lg tracking-wider",children:"apteva"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$a.jsxDEV("button",{onClick:y,className:"p-2 transition",style:{color:"var(--color-text-muted)"},children:$a.jsxDEV(it,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$a.jsxDEV("nav",{className:"space-y-1 flex-1",children:[$a.jsxDEV(xp,{icon:$a.jsxDEV(H7,{},void 0,!1,void 0,this),label:"Dashboard",active:c==="dashboard",onClick:()=>W("dashboard")},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(W7,{},void 0,!1,void 0,this),label:"Agents",active:c==="agents",onClick:()=>W("agents"),badge:Z>0?String(Z):void 0},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(n9,{},void 0,!1,void 0,this),label:"Threads",active:c==="threads",onClick:()=>W("threads")},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(X1,{},void 0,!1,void 0,this),label:"Activity",active:c==="activity",onClick:()=>W("activity")},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(Nm,{},void 0,!1,void 0,this),label:"Tasks",active:c==="tasks",onClick:()=>W("tasks"),badge:_&&_>0?String(_):void 0},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(wt,{},void 0,!1,void 0,this),label:"MCP",active:c==="mcp",onClick:()=>W("mcp")},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(Y1,{},void 0,!1,void 0,this),label:"Skills",active:c==="skills",onClick:()=>W("skills")},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(T9,{},void 0,!1,void 0,this),label:"Connections",active:c==="connections",onClick:()=>W("connections")},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(A9,{},void 0,!1,void 0,this),label:"Tests",active:c==="tests",onClick:()=>W("tests")},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(P9,{},void 0,!1,void 0,this),label:"Analytics",active:c==="analytics",onClick:()=>W("analytics")},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(I9,{},void 0,!1,void 0,this),label:"API",active:c==="api",onClick:()=>W("api")},void 0,!1,void 0,this),$a.jsxDEV(xp,{icon:$a.jsxDEV(U7,{},void 0,!1,void 0,this),label:"Settings",active:c==="settings",onClick:()=>W("settings")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H&&$a.jsxDEV("div",{className:"relative pt-3 mt-3",style:{borderTop:"1px solid var(--color-border)"},children:[$a.jsxDEV("button",{onClick:()=>I(!N),className:"w-full flex items-center gap-3 px-3 py-2 rounded transition",style:{color:"var(--color-text)"},onMouseEnter:(k)=>k.currentTarget.style.backgroundColor="var(--color-surface)",onMouseLeave:(k)=>k.currentTarget.style.backgroundColor="transparent",children:[$a.jsxDEV("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-black font-medium text-sm flex-shrink-0",style:{backgroundColor:"var(--color-accent)"},children:H.username.charAt(0).toUpperCase()},void 0,!1,void 0,this),$a.jsxDEV("div",{className:"flex-1 min-w-0 text-left",children:[$a.jsxDEV("p",{className:"text-sm font-medium truncate",children:H.username},void 0,!1,void 0,this),$a.jsxDEV("p",{className:"text-xs",style:{color:"var(--color-text-faint)"},children:H.role},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),N&&$a.jsxDEV($a.Fragment,{children:[$a.jsxDEV("div",{className:"fixed inset-0 z-40",onClick:()=>I(!1)},void 0,!1,void 0,this),$a.jsxDEV("div",{className:"absolute left-3 bottom-full mb-1 w-48 card shadow-xl z-50",style:{backgroundColor:"var(--color-surface)"},children:$a.jsxDEV("button",{onClick:A,className:"w-full px-4 py-2.5 text-left text-sm text-red-400 transition rounded-lg",onMouseEnter:(k)=>k.currentTarget.style.backgroundColor="var(--color-surface-raised)",onMouseLeave:(k)=>k.currentTarget.style.backgroundColor="transparent",children:"Sign out"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function xp({icon:c,label:Z,active:_,onClick:U,badge:h}){return $a.jsxDEV("button",{onClick:U,className:"w-full flex items-center gap-3 px-3 py-2 font-medium transition",style:{borderRadius:"var(--radius-button)",backgroundColor:_?"var(--color-surface)":"transparent",color:_?"var(--color-text)":"var(--color-text-muted)"},onMouseEnter:(y)=>{if(!_)y.currentTarget.style.backgroundColor="var(--color-surface)",y.currentTarget.style.color="var(--color-text-secondary)"},onMouseLeave:(y)=>{if(!_)y.currentTarget.style.backgroundColor="transparent",y.currentTarget.style.color="var(--color-text-muted)"},children:[c,Z,h&&$a.jsxDEV("span",{className:"ml-auto text-xs px-2 py-0.5 rounded-full",style:{backgroundColor:"var(--color-surface-raised)",color:"var(--color-text-secondary)"},children:h},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var x5=Ga(vo(),1);function G1({message:c,onDismiss:Z}){return x5.jsxDEV("div",{className:"bg-red-500/10 border-b border-red-500/30 px-6 py-3 text-red-400 text-sm flex items-center justify-between",children:[x5.jsxDEV("span",{children:c},void 0,!1,void 0,this),x5.jsxDEV("button",{onClick:Z,className:"hover:text-red-300",children:x5.jsxDEV(it,{className:"w-4 h-4"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var V5=Ga(Do(),1);var Ro=Ga(vo(),1);function _1(){let{login:c}=$o(),[Z,_]=V5.useState(""),[U,h]=V5.useState(""),[y,H]=V5.useState(null),[G,N]=V5.useState(!1);return Ro.jsxDEV("div",{className:"min-h-screen bg-[var(--color-bg)] text-[var(--color-text)] flex items-center justify-center p-8",children:Ro.jsxDEV("div",{className:"w-full max-w-md",children:[Ro.jsxDEV("div",{className:"text-center mb-8",children:[Ro.jsxDEV("div",{className:"flex items-center justify-center gap-2 mb-2",children:[Ro.jsxDEV("span",{className:"text-[var(--color-accent)] text-3xl",children:">_"},void 0,!1,void 0,this),Ro.jsxDEV("span",{className:"text-3xl tracking-wider",children:"apteva"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Ro.jsxDEV("p",{className:"text-[var(--color-text-muted)]",children:"Run AI agents locally"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Ro.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-8",children:[Ro.jsxDEV("h2",{className:"text-2xl font-semibold mb-2",children:"Welcome back"},void 0,!1,void 0,this),Ro.jsxDEV("p",{className:"text-[var(--color-text-muted)] mb-6",children:"Sign in to continue to apteva"},void 0,!1,void 0,this),Ro.jsxDEV("form",{onSubmit:async(W)=>{W.preventDefault(),H(null),N(!0);let A=await c(Z,U);if(!A.success)H(A.error||"Login failed");N(!1)},className:"space-y-4",children:[Ro.jsxDEV("div",{children:[Ro.jsxDEV("label",{htmlFor:"username",className:"block text-sm text-[var(--color-text-secondary)] mb-1",children:"Username"},void 0,!1,void 0,this),Ro.jsxDEV("input",{id:"username",type:"text",value:Z,onChange:(W)=>_(W.target.value),placeholder:"Enter your username",autoFocus:!0,required:!0,className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-4 py-3 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Ro.jsxDEV("div",{children:[Ro.jsxDEV("label",{htmlFor:"password",className:"block text-sm text-[var(--color-text-secondary)] mb-1",children:"Password"},void 0,!1,void 0,this),Ro.jsxDEV("input",{id:"password",type:"password",value:U,onChange:(W)=>h(W.target.value),placeholder:"Enter your password",required:!0,className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-4 py-3 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),y&&Ro.jsxDEV("div",{className:"p-3 bg-red-500/10 border border-red-500/30 rounded text-red-400 text-sm",children:y},void 0,!1,void 0,this),Ro.jsxDEV("button",{type:"submit",disabled:G||!Z||!U,className:"w-full bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 disabled:cursor-not-allowed text-black px-4 py-3 rounded font-medium transition",children:G?"Signing in...":"Sign In"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var or=Ga(Do(),1),oo=Ga(vo(),1);function q1({onComplete:c}){let[Z,_]=or.useState(""),[U,h]=or.useState(""),[y,H]=or.useState(""),[G,N]=or.useState(""),[I,W]=or.useState(!1),[A,k]=or.useState(null),[x,M]=or.useState(!1);return oo.jsxDEV(oo.Fragment,{children:[oo.jsxDEV("h2",{className:"text-2xl font-semibold mb-2",children:"Create your account"},void 0,!1,void 0,this),oo.jsxDEV("p",{className:"text-[var(--color-text-muted)] mb-6",children:"Set up your admin account to get started with apteva."},void 0,!1,void 0,this),oo.jsxDEV("form",{onSubmit:async(s)=>{if(s.preventDefault(),k(null),U!==y){k("Passwords do not match");return}M(!0);try{let qa=await fetch("/api/onboarding/user",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:Z,password:U,...G&&{email:G}})}),ma=await qa.json();if(!qa.ok){k(ma.error||"Failed to create account"),M(!1);return}let wa=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({username:Z,password:U})});if(!wa.ok){k("Account created but login failed. Please try logging in."),M(!1);return}let oa=await wa.json();if(oa.accessToken)sessionStorage.setItem("accessToken",oa.accessToken);c({username:Z})}catch(qa){k("Failed to create account"),M(!1)}},className:"space-y-4",children:[oo.jsxDEV("div",{children:[oo.jsxDEV("label",{htmlFor:"username",className:"block text-sm text-[var(--color-text-secondary)] mb-1",children:"Username"},void 0,!1,void 0,this),oo.jsxDEV("input",{id:"username",type:"text",value:Z,onChange:(s)=>_(s.target.value),placeholder:"Choose a username",autoFocus:!0,required:!0,className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-4 py-3 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this),oo.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] mt-1",children:"3-20 characters, letters, numbers, underscore"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),oo.jsxDEV("div",{children:[oo.jsxDEV("label",{htmlFor:"password",className:"block text-sm text-[var(--color-text-secondary)] mb-1",children:"Password"},void 0,!1,void 0,this),oo.jsxDEV("input",{id:"password",type:"password",value:U,onChange:(s)=>h(s.target.value),placeholder:"Enter a password",required:!0,className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-4 py-3 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this),oo.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] mt-1",children:"Min 8 characters, uppercase, lowercase, number"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),oo.jsxDEV("div",{children:[oo.jsxDEV("label",{htmlFor:"confirmPassword",className:"block text-sm text-[var(--color-text-secondary)] mb-1",children:"Confirm Password"},void 0,!1,void 0,this),oo.jsxDEV("input",{id:"confirmPassword",type:"password",value:y,onChange:(s)=>H(s.target.value),placeholder:"Confirm your password",required:!0,className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-4 py-3 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!I?oo.jsxDEV("button",{type:"button",onClick:()=>W(!0),className:"text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] transition",children:"+ Add email for password recovery (optional)"},void 0,!1,void 0,this):oo.jsxDEV("div",{children:[oo.jsxDEV("label",{htmlFor:"email",className:"block text-sm text-[var(--color-text-secondary)] mb-1",children:["Email ",oo.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"(optional)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),oo.jsxDEV("input",{id:"email",type:"email",value:G,onChange:(s)=>N(s.target.value),placeholder:"For password recovery only",className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-4 py-3 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this),oo.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] mt-1",children:"Only used for password recovery, never shared"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),A&&oo.jsxDEV("div",{className:"p-3 bg-red-500/10 border border-red-500/30 rounded text-red-400 text-sm",children:A},void 0,!1,void 0,this),oo.jsxDEV("button",{type:"submit",disabled:x||!Z||!U||!y,className:"w-full bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 disabled:cursor-not-allowed text-black px-4 py-3 rounded font-medium transition",children:x?"Creating account...":"Create Account"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),oo.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] mt-4 text-center",children:"This will be your admin account with full access to apteva."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Vp=Ga(Do(),1);var pa=Ga(vo(),1);function D5({onComplete:c,needsAccount:Z=!1}){let[_,U]=Vp.useState(Z?0:1),[h,y]=Vp.useState([]),[H,G]=Vp.useState(null),[N,I]=Vp.useState(""),[W,A]=Vp.useState(!1),[k,x]=Vp.useState(!1),[M,P]=Vp.useState(null),[s,qa]=Vp.useState(null),[ma,wa]=Vp.useState(!1),oa=()=>{let ra=sessionStorage.getItem("accessToken");return ra?{Authorization:`Bearer ${ra}`}:{}};Vp.useEffect(()=>{if(Z&&!ma&&_===0)return;fetch("/api/providers",{headers:oa()}).then((ra)=>ra.json()).then((ra)=>{let O=(ra.providers||[]).filter((d)=>d.type==="llm");y(O)})},[ma,_,Z]);let e=h.filter((ra)=>ra.hasKey),La=async()=>{if(!H||!N)return;A(!0),P(null),qa(null);try{x(!0);let O=await(await fetch(`/api/keys/${H}/test`,{method:"POST",headers:{"Content-Type":"application/json",...oa()},body:JSON.stringify({key:N})})).json();if(x(!1),!O.valid){P(O.error||"API key is invalid"),A(!1);return}let d=await fetch(`/api/keys/${H}`,{method:"POST",headers:{"Content-Type":"application/json",...oa()},body:JSON.stringify({key:N})}),fa=await d.json();if(!d.ok)P(fa.error||"Failed to save key");else{qa("API key saved successfully!"),I("");let T=await(await fetch("/api/providers",{headers:oa()})).json();y(T.providers||[]),G(null)}}catch(ra){P("Failed to save key")}A(!1)},ha=async()=>{try{let ra=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json",...oa()},body:JSON.stringify({name:"My Project",description:"Default project for organizing agents",color:"#f97316"})});if(ra.ok){let O=await ra.json();if(O.project?.id)localStorage.setItem("apteva_current_project",O.project.id)}}catch(ra){console.error("Failed to create default project:",ra)}await fetch("/api/onboarding/complete",{method:"POST",headers:oa()}),c()},V=()=>{wa(!0),U(1)},Ca=Z?3:2,L=Z?_:_-1;return pa.jsxDEV("div",{className:"min-h-screen bg-[var(--color-bg)] text-[var(--color-text)] flex items-center justify-center p-8",children:pa.jsxDEV("div",{className:"w-full max-w-2xl",children:[pa.jsxDEV("div",{className:"text-center mb-8",children:[pa.jsxDEV("div",{className:"flex items-center justify-center gap-2 mb-2",children:[pa.jsxDEV("span",{className:"text-[var(--color-accent)] text-3xl",children:">_"},void 0,!1,void 0,this),pa.jsxDEV("span",{className:"text-3xl tracking-wider",children:"apteva"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),pa.jsxDEV("p",{className:"text-[var(--color-text-muted)]",children:"Run AI agents locally"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),pa.jsxDEV("div",{className:"flex items-center justify-center gap-2 mb-8",children:[Z&&pa.jsxDEV(pa.Fragment,{children:[pa.jsxDEV("div",{className:`w-3 h-3 rounded-full ${_>=0?"bg-[var(--color-accent)]":"bg-[var(--color-surface-raised)]"}`},void 0,!1,void 0,this),pa.jsxDEV("div",{className:`w-16 h-0.5 ${_>=1?"bg-[var(--color-accent)]":"bg-[var(--color-surface-raised)]"}`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),pa.jsxDEV("div",{className:`w-3 h-3 rounded-full ${_>=1?"bg-[var(--color-accent)]":"bg-[var(--color-surface-raised)]"}`},void 0,!1,void 0,this),pa.jsxDEV("div",{className:`w-16 h-0.5 ${_>=2?"bg-[var(--color-accent)]":"bg-[var(--color-surface-raised)]"}`},void 0,!1,void 0,this),pa.jsxDEV("div",{className:`w-3 h-3 rounded-full ${_>=2?"bg-[var(--color-accent)]":"bg-[var(--color-surface-raised)]"}`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),pa.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-8",children:[_===0&&Z&&pa.jsxDEV(q1,{onComplete:V},void 0,!1,void 0,this),_===1&&pa.jsxDEV(EY,{providers:h,configuredProviders:e,selectedProvider:H,apiKey:N,saving:W,testing:k,error:M,success:s,onSelectProvider:G,onApiKeyChange:I,onSaveKey:La,onContinue:()=>U(2)},void 0,!1,void 0,this),_===2&&pa.jsxDEV(eY,{configuredProviders:e,onAddMore:()=>U(1),onComplete:ha},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function EY({providers:c,configuredProviders:Z,selectedProvider:_,apiKey:U,saving:h,testing:y,error:H,success:G,onSelectProvider:N,onApiKeyChange:I,onSaveKey:W,onContinue:A}){let k=c.find((x)=>x.id===_);if(_&&k)return pa.jsxDEV(pa.Fragment,{children:[pa.jsxDEV("h2",{className:"text-2xl font-semibold mb-2",children:["Add ",k.name," Key"]},void 0,!0,void 0,this),pa.jsxDEV("p",{className:"text-[var(--color-text-muted)] mb-6",children:"Enter your API key below. It will be encrypted and stored locally."},void 0,!1,void 0,this),pa.jsxDEV("div",{className:"mb-6",children:[pa.jsxDEV("div",{className:"p-4 rounded border border-[var(--color-accent)] bg-[var(--color-accent-5)] mb-4",children:pa.jsxDEV("div",{className:"flex items-center justify-between",children:[pa.jsxDEV("div",{children:[pa.jsxDEV("p",{className:"font-medium",children:k.name},void 0,!1,void 0,this),pa.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:[k.models.length," models available"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),pa.jsxDEV("a",{href:k.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:"Get API Key"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),pa.jsxDEV("div",{className:"space-y-3",children:[pa.jsxDEV("input",{type:"password",value:U,onChange:(x)=>I(x.target.value),placeholder:"Enter your API key...",autoFocus:!0,className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-4 py-3 focus:outline-none focus:border-[var(--color-accent)] text-lg"},void 0,!1,void 0,this),H&&pa.jsxDEV("p",{className:"text-red-400 text-sm",children:H},void 0,!1,void 0,this),G&&pa.jsxDEV("p",{className:"text-green-400 text-sm",children:G},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),pa.jsxDEV("div",{className:"flex gap-3",children:[pa.jsxDEV("button",{onClick:()=>{N(null),I("")},className:"flex-1 border border-[var(--color-border-light)] hover:border-[var(--color-text-muted)] px-4 py-3 rounded font-medium transition",children:"Back"},void 0,!1,void 0,this),pa.jsxDEV("button",{onClick:W,disabled:!U||h,className:"flex-1 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 disabled:cursor-not-allowed text-black px-4 py-3 rounded font-medium transition",children:y?"Testing...":h?"Saving...":"Save API Key"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);return pa.jsxDEV(pa.Fragment,{children:[pa.jsxDEV("h2",{className:"text-2xl font-semibold mb-2",children:"Welcome to apteva"},void 0,!1,void 0,this),pa.jsxDEV("p",{className:"text-[var(--color-text-muted)] mb-6",children:"To get started, you'll need to add at least one AI provider API key. Your keys are encrypted and stored locally."},void 0,!1,void 0,this),pa.jsxDEV("div",{className:"space-y-3 mb-6",children:c.map((x)=>pa.jsxDEV(sY,{provider:x,selected:!1,onSelect:()=>!x.hasKey&&N(x.id)},x.id,!1,void 0,this))},void 0,!1,void 0,this),pa.jsxDEV("button",{onClick:A,disabled:Z.length===0,className:"w-full bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] disabled:opacity-50 disabled:cursor-not-allowed px-4 py-3 rounded font-medium transition",children:Z.length===0?"Add at least one API key to continue":`Continue with ${Z.length} provider${Z.length>1?"s":""}`},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function sY({provider:c,selected:Z,onSelect:_}){return pa.jsxDEV("div",{onClick:_,className:`p-4 rounded border transition cursor-pointer ${c.hasKey?"border-green-500/30 bg-green-500/5":Z?"border-[var(--color-accent)] bg-[var(--color-accent-5)]":"border-[var(--color-border-light)] hover:border-[var(--color-border-light)]"}`,children:pa.jsxDEV("div",{className:"flex items-center justify-between",children:[pa.jsxDEV("div",{children:[pa.jsxDEV("p",{className:"font-medium",children:c.name},void 0,!1,void 0,this),pa.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:[c.models.length," models available"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),c.hasKey?pa.jsxDEV("span",{className:"text-green-400 text-sm flex items-center gap-1",children:[pa.jsxDEV(Q1,{},void 0,!1,void 0,this),"Configured (",c.keyHint,")"]},void 0,!0,void 0,this):pa.jsxDEV("a",{href:c.docsUrl,target:"_blank",rel:"noopener noreferrer",onClick:(U)=>U.stopPropagation(),className:"text-sm text-[#3b82f6] hover:underline",children:"Get API Key"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function eY({configuredProviders:c,onAddMore:Z,onComplete:_}){return pa.jsxDEV(pa.Fragment,{children:[pa.jsxDEV("h2",{className:"text-2xl font-semibold mb-2",children:"You're all set!"},void 0,!1,void 0,this),pa.jsxDEV("p",{className:"text-[var(--color-text-muted)] mb-6",children:["You've configured ",c.length," provider",c.length>1?"s":"",". You can add more providers later in Settings."]},void 0,!0,void 0,this),pa.jsxDEV("div",{className:"space-y-2 mb-6",children:c.map((U)=>pa.jsxDEV("div",{className:"flex items-center gap-3 p-3 bg-[var(--color-bg)] rounded",children:[pa.jsxDEV(Q1,{className:"w-5 h-5 text-green-400"},void 0,!1,void 0,this),pa.jsxDEV("span",{children:U.name},void 0,!1,void 0,this),pa.jsxDEV("span",{className:"text-[var(--color-text-muted)] text-sm",children:["(",U.keyHint,")"]},void 0,!0,void 0,this)]},U.id,!0,void 0,this))},void 0,!1,void 0,this),pa.jsxDEV("div",{className:"flex gap-3",children:[pa.jsxDEV("button",{onClick:Z,className:"flex-1 border border-[var(--color-border-light)] hover:border-[var(--color-accent)] px-4 py-3 rounded font-medium transition",children:"Add More"},void 0,!1,void 0,this),pa.jsxDEV("button",{onClick:_,className:"flex-1 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] text-black px-4 py-3 rounded font-medium transition",children:"Start Using apteva"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var u9=Ga(Do(),1);var bo=Ga(vo(),1),oX=[{key:"memory",icon:r0,label:"Memory"},{key:"tasks",icon:Nm,label:"Tasks"},{key:"files",icon:i0,label:"Files"},{key:"vision",icon:v0,label:"Vision"},{key:"operator",icon:b0,label:"Operator"},{key:"mcp",icon:wt,label:"MCP"},{key:"realtime",icon:f0,label:"Realtime"},{key:"agents",icon:w0,label:"Multi-Agent"}],K1=u9.default.memo(function({agent:Z,selected:_,onSelect:U,onToggle:h,showProject:y}){let H=oX.filter((M)=>Z.features?.[M.key]),G=Z.mcpServerDetails||[],N=Z.skillDetails||[],{isActive:I,label:W}=B1(Z.id),{projects:A}=vp(),k=Z.projectId?A.find((M)=>M.id===Z.projectId):null,x=Z.subscriptions||[];return bo.jsxDEV("div",{onClick:U,className:`bg-[var(--color-surface)] card p-5 transition cursor-pointer flex flex-col h-full ${_?"!border-[var(--color-accent)]":"hover:border-[var(--color-border-light)]"}`,children:[bo.jsxDEV("div",{className:"flex items-start justify-between mb-3",children:[bo.jsxDEV("div",{children:[bo.jsxDEV("h3",{className:"font-semibold text-lg",children:Z.name},void 0,!1,void 0,this),bo.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:[Z.provider," / ",Z.model,Z.port&&bo.jsxDEV("span",{className:"text-[var(--color-text-faint)]",children:[" · :",Z.port]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),y&&k&&bo.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] flex items-center gap-1.5 mt-1",children:[bo.jsxDEV("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:k.color}},void 0,!1,void 0,this),k.name]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),bo.jsxDEV(pX,{status:Z.status,isActive:I&&Z.status==="running",activityLabel:W},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H.length>0&&bo.jsxDEV("div",{className:"flex flex-wrap gap-1.5 mb-3",children:H.map(({key:M,icon:P,label:s})=>bo.jsxDEV("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-[var(--color-accent-10)] text-[var(--color-accent-70)] text-xs",style:{borderRadius:"var(--radius-badge)"},title:s,children:[bo.jsxDEV(P,{className:"w-3 h-3"},void 0,!1,void 0,this),s]},M,!0,void 0,this))},void 0,!1,void 0,this),G.length>0&&bo.jsxDEV("div",{className:"flex flex-wrap gap-1.5 mb-3",children:G.map((M)=>{let P=M.type==="http"&&M.url||M.status==="running";return bo.jsxDEV("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs ${P?"bg-green-500/10 text-green-400":"bg-[var(--color-surface-raised)] text-[var(--color-text-muted)]"}`,title:`MCP: ${M.name} (${P?"available":M.status})`,children:[bo.jsxDEV(wt,{className:"w-3 h-3"},void 0,!1,void 0,this),M.name]},M.id,!0,void 0,this)})},void 0,!1,void 0,this),N.length>0&&bo.jsxDEV("div",{className:"flex flex-wrap gap-1.5 mb-3",children:N.map((M)=>bo.jsxDEV("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs ${M.enabled?"bg-purple-500/10 text-purple-400":"bg-[var(--color-surface-raised)] text-[var(--color-text-muted)]"}`,title:`Skill: ${M.name} v${M.version}`,children:[bo.jsxDEV(Y1,{className:"w-3 h-3"},void 0,!1,void 0,this),M.name]},M.id,!0,void 0,this))},void 0,!1,void 0,this),x.length>0&&bo.jsxDEV("div",{className:"flex flex-wrap gap-1.5 mb-3",children:x.map((M)=>bo.jsxDEV("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs ${M.enabled?"bg-cyan-500/10 text-cyan-400":"bg-[var(--color-surface-raised)] text-[var(--color-text-muted)]"}`,title:`Trigger: ${M.trigger_slug.replace(/_/g," ")}`,children:[bo.jsxDEV(X1,{className:"w-3 h-3"},void 0,!1,void 0,this),M.trigger_slug.replace(/_/g," ")]},M.id,!0,void 0,this))},void 0,!1,void 0,this),bo.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] line-clamp-2 mb-4 flex-1",children:Z.systemPrompt},void 0,!1,void 0,this),bo.jsxDEV("button",{onClick:h,disabled:Z.status==="starting"||Z.status==="stopping",className:`w-full px-3 py-1.5 btn text-sm font-medium transition mt-auto ${Z.status==="starting"||Z.status==="stopping"?"bg-[var(--color-surface-raised)] text-[var(--color-text-muted)] cursor-wait":Z.status==="running"?"bg-red-500/15 text-red-500 hover:bg-red-500/25 border border-red-500/20":"bg-[#3b82f6]/20 text-[#3b82f6] hover:bg-[#3b82f6]/30"}`,children:Z.status==="starting"?"Starting...":Z.status==="stopping"?"Stopping...":Z.status==="running"?"Stop":"Start"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)});function pX({status:c,isActive:Z,activityLabel:_}){if(c==="running"&&Z&&_)return bo.jsxDEV("span",{className:"px-2 py-1 text-xs font-medium bg-green-500/20 text-green-400 animate-pulse",style:{borderRadius:"var(--radius-badge)"},children:_},void 0,!1,void 0,this);return bo.jsxDEV("span",{className:`px-2 py-1 text-xs font-medium ${c==="starting"||c==="stopping"?"bg-yellow-500/20 text-yellow-400 animate-pulse":c==="running"?"bg-[#3b82f6]/20 text-[#3b82f6]":"bg-[var(--color-surface-raised)] text-[var(--color-text-muted)]"}`,style:{borderRadius:"var(--radius-badge)"},children:c},void 0,!1,void 0,this)}var j5=Ga(Do(),1);var Xa=Ga(vo(),1),mX=[{key:"memory",label:"Memory",description:"Persistent recall",icon:r0},{key:"tasks",label:"Tasks",description:"Schedule and execute tasks",icon:Nm},{key:"files",label:"Files",description:"File storage and management",icon:i0},{key:"vision",label:"Vision",description:"Process images and PDFs",icon:v0},{key:"operator",label:"Operator",description:"Browser automation",icon:b0},{key:"mcp",label:"MCP",description:"External tools/services",icon:wt},{key:"realtime",label:"Realtime",description:"Voice conversations",icon:f0},{key:"agents",label:"Multi-Agent",description:"Communicate with peer agents",icon:w0}];function H1({form:c,providers:Z,configuredProviders:_,onFormChange:U,onProviderChange:h,onCreate:y,onClose:H,onGoToSettings:G}){let{projects:N,currentProjectId:I}=vp(),{authFetch:W}=$o(),A=Z.find((e)=>e.id===c.provider),[k,x]=j5.default.useState([]),[M,P]=j5.default.useState(!1);j5.default.useEffect(()=>{if(c.provider==="ollama")P(!0),W("/api/providers/ollama/models").then((e)=>e.json()).then((e)=>{if(e.models&&e.models.length>0){if(x(e.models.map((La)=>({value:La.value,label:La.label||La.value}))),!c.model&&e.models.length>0)U({...c,model:e.models[0].value})}}).catch(()=>x([])).finally(()=>P(!1))},[c.provider]);let s=_.filter((e)=>e.type==="llm").map((e)=>({value:e.id,label:e.name})),qa=c.provider==="ollama"&&k.length>0?k:A?.models.map((e)=>({value:e.value,label:e.label,recommended:e.recommended}))||[],ma=N.map((e)=>({value:e.id,label:e.name}));j5.default.useEffect(()=>{if(c.projectId===void 0&&I&&I!=="unassigned")U({...c,projectId:I})},[I]);let wa=(e)=>{if(e==="agents")if(typeof c.features.agents==="boolean"?c.features.agents:c.features.agents?.enabled??!1)U({...c,features:{...c.features,agents:!1}});else U({...c,features:{...c.features,agents:{enabled:!0,group:c.projectId||void 0}}});else U({...c,features:{...c.features,[e]:!c.features[e]}})},oa=()=>{let e=c.features.agents;if(typeof e==="boolean")return e;return e?.enabled??!1};return Xa.jsxDEV(d7,{children:[Xa.jsxDEV("h2",{className:"text-xl font-semibold mb-4",children:"Create New Agent"},void 0,!1,void 0,this),s.length===0?Xa.jsxDEV(tX,{onGoToSettings:G},void 0,!1,void 0,this):Xa.jsxDEV(Xa.Fragment,{children:[Xa.jsxDEV("div",{className:"space-y-4",children:[Xa.jsxDEV(Vr,{label:"Name",children:Xa.jsxDEV("input",{type:"text",value:c.name,onChange:(e)=>U({...c,name:e.target.value}),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)]",placeholder:"My Agent"},void 0,!1,void 0,this)},void 0,!1,void 0,this),N.length>0&&Xa.jsxDEV(Vr,{label:"Project",children:Xa.jsxDEV(ct,{value:c.projectId||"",options:ma,onChange:(e)=>U({...c,projectId:e||null}),placeholder:"Select project..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),Xa.jsxDEV(Vr,{label:"Provider",children:Xa.jsxDEV(ct,{value:c.provider,options:s,onChange:h,placeholder:"Select provider..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),Xa.jsxDEV(Vr,{label:"Model",children:M?Xa.jsxDEV("div",{className:"text-sm text-[var(--color-text-muted)] py-2",children:"Loading Ollama models..."},void 0,!1,void 0,this):c.provider==="ollama"&&qa.length===0?Xa.jsxDEV("div",{className:"text-sm text-yellow-400/80 py-2",children:["No models found. Run ",Xa.jsxDEV("code",{className:"bg-[var(--color-surface-raised)] px-1 rounded",children:"ollama pull llama3.3"},void 0,!1,void 0,this)," to download a model."]},void 0,!0,void 0,this):Xa.jsxDEV(ct,{value:c.model,options:qa,onChange:(e)=>U({...c,model:e}),placeholder:"Select model..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),Xa.jsxDEV(Vr,{label:"System Prompt",children:Xa.jsxDEV("textarea",{value:c.systemPrompt,onChange:(e)=>U({...c,systemPrompt:e.target.value}),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 h-24 resize-none focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)]"},void 0,!1,void 0,this)},void 0,!1,void 0,this),Xa.jsxDEV(Vr,{label:"Features",children:Xa.jsxDEV("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:mX.map(({key:e,label:La,description:ha,icon:V})=>{let Ca=e==="agents"?oa():!!c.features[e];return Xa.jsxDEV("button",{type:"button",onClick:()=>wa(e),className:`flex items-center gap-3 p-3 btn border text-left transition ${Ca?"border-[var(--color-accent)] bg-[var(--color-accent-10)]":"border-[var(--color-border-light)] hover:border-[var(--color-border-light)]"}`,children:[Xa.jsxDEV(V,{className:`w-5 h-5 flex-shrink-0 ${Ca?"text-[var(--color-accent)]":"text-[var(--color-text-muted)]"}`},void 0,!1,void 0,this),Xa.jsxDEV("div",{className:"flex-1 min-w-0",children:[Xa.jsxDEV("div",{className:`text-sm font-medium ${Ca?"text-[var(--color-accent)]":""}`,children:La},void 0,!1,void 0,this),Xa.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)]",children:ha},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},e,!0,void 0,this)})},void 0,!1,void 0,this)},void 0,!1,void 0,this),c.provider==="anthropic"&&Xa.jsxDEV(Vr,{label:"Agent Built-in Tools",children:[Xa.jsxDEV("div",{className:"flex flex-wrap gap-2",children:[Xa.jsxDEV("button",{type:"button",onClick:()=>U({...c,features:{...c.features,builtinTools:{...c.features.builtinTools,webSearch:!c.features.builtinTools?.webSearch}}}),className:`flex items-center gap-2 px-3 py-2 btn border transition ${c.features.builtinTools?.webSearch?"border-[var(--color-accent)] bg-[var(--color-accent-10)] text-[var(--color-accent)]":"border-[var(--color-border-light)] hover:border-[var(--color-border-light)] text-[var(--color-text-secondary)]"}`,children:[Xa.jsxDEV("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:Xa.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"},void 0,!1,void 0,this)},void 0,!1,void 0,this),Xa.jsxDEV("span",{className:"text-sm",children:"Web Search"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Xa.jsxDEV("button",{type:"button",onClick:()=>U({...c,features:{...c.features,builtinTools:{...c.features.builtinTools,webFetch:!c.features.builtinTools?.webFetch}}}),className:`flex items-center gap-2 px-3 py-2 btn border transition ${c.features.builtinTools?.webFetch?"border-[var(--color-accent)] bg-[var(--color-accent-10)] text-[var(--color-accent)]":"border-[var(--color-border-light)] hover:border-[var(--color-border-light)] text-[var(--color-text-secondary)]"}`,children:[Xa.jsxDEV("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:Xa.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"},void 0,!1,void 0,this)},void 0,!1,void 0,this),Xa.jsxDEV("span",{className:"text-sm",children:"Web Fetch"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Xa.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-2",children:"Provider-native tools for real-time web access"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Xa.jsxDEV("div",{className:"flex gap-3 mt-6",children:[Xa.jsxDEV("button",{onClick:H,className:"flex-1 border border-[var(--color-border-light)] hover:border-[var(--color-accent)] hover:text-[var(--color-accent)] px-4 py-2 btn font-medium transition",children:"Cancel"},void 0,!1,void 0,this),Xa.jsxDEV("button",{onClick:y,disabled:!c.name,className:"flex-1 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 text-black px-4 py-2 btn font-medium transition",children:"Create"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Vr({label:c,children:Z}){return Xa.jsxDEV("div",{children:[Xa.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:c},void 0,!1,void 0,this),Z]},void 0,!0,void 0,this)}function tX({onGoToSettings:c}){return Xa.jsxDEV("div",{className:"text-center py-6",children:[Xa.jsxDEV("p",{className:"text-[var(--color-text-muted)] mb-4",children:"No API keys configured. Add a provider key first."},void 0,!1,void 0,this),Xa.jsxDEV("button",{onClick:c,className:"bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] text-black px-4 py-2 rounded font-medium transition",children:"Go to Settings"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var aa=Ga(Do(),1);var w=Ga(vo(),1),rX=[{key:"memory",label:"Memory",description:"Persistent recall",icon:r0},{key:"tasks",label:"Tasks",description:"Schedule and execute tasks",icon:Nm},{key:"files",label:"Files",description:"File storage and management",icon:i0},{key:"vision",label:"Vision",description:"Process images and PDFs",icon:v0},{key:"operator",label:"Operator",description:"Browser automation",icon:b0},{key:"mcp",label:"MCP",description:"External tools/services",icon:wt},{key:"realtime",label:"Realtime",description:"Voice conversations",icon:f0},{key:"agents",label:"Multi-Agent",description:"Communicate with peer agents",icon:w0}];function U1({agent:c,providers:Z,onClose:_,onStartAgent:U,onUpdateAgent:h,onDeleteAgent:y}){let[H,G]=aa.useState("chat");return w.jsxDEV("div",{className:"w-full h-full flex flex-col overflow-hidden bg-[var(--color-bg)] border-l border-[var(--color-border)]",children:[w.jsxDEV("div",{className:"border-b border-[var(--color-border)] flex items-center",children:[w.jsxDEV("div",{className:"flex-1 overflow-x-auto scrollbar-hide px-2 md:px-4",children:w.jsxDEV("div",{className:"flex gap-1",children:[w.jsxDEV(c0,{active:H==="chat",onClick:()=>G("chat"),children:"Chat"},void 0,!1,void 0,this),w.jsxDEV(c0,{active:H==="threads",onClick:()=>G("threads"),children:"Threads"},void 0,!1,void 0,this),w.jsxDEV(c0,{active:H==="tasks",onClick:()=>G("tasks"),children:"Tasks"},void 0,!1,void 0,this),w.jsxDEV(c0,{active:H==="memory",onClick:()=>G("memory"),children:"Memory"},void 0,!1,void 0,this),w.jsxDEV(c0,{active:H==="files",onClick:()=>G("files"),children:"Files"},void 0,!1,void 0,this),w.jsxDEV(c0,{active:H==="settings",onClick:()=>G("settings"),children:"Settings"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:_,className:"text-[var(--color-text-muted)] hover:text-[var(--color-text)] transition p-2 flex-shrink-0 mr-2",children:w.jsxDEV(it,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[H==="chat"&&w.jsxDEV(vX,{agent:c,onStartAgent:U},void 0,!1,void 0,this),H==="threads"&&w.jsxDEV(bX,{agent:c},void 0,!1,void 0,this),H==="tasks"&&w.jsxDEV(fX,{agent:c},void 0,!1,void 0,this),H==="memory"&&w.jsxDEV(wX,{agent:c},void 0,!1,void 0,this),H==="files"&&w.jsxDEV(cX,{agent:c},void 0,!1,void 0,this),H==="settings"&&w.jsxDEV(lX,{agent:c,providers:Z,onUpdateAgent:h,onDeleteAgent:y},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function c0({active:c,onClick:Z,children:_}){return w.jsxDEV("button",{onClick:Z,className:`px-4 py-3 text-sm font-medium border-b-2 transition ${c?"border-[var(--color-accent)] text-[var(--color-text)]":"border-transparent text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)]"}`,children:_},void 0,!1,void 0,this)}function vX({agent:c,onStartAgent:Z}){let{theme:_}=xr();if(c.status==="running"&&c.port)return w.jsxDEV(ur,{agentId:"default",apiUrl:`/api/agents/${c.id}`,placeholder:"Message this agent...",context:c.systemPrompt,variant:"terminal",theme:_.id,headerTitle:c.name,enableVoice:!!c.features.realtime},void 0,!1,void 0,this);return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("div",{className:"text-center",children:[w.jsxDEV("p",{className:"text-lg mb-2",children:"Agent is not running"},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:Z,className:"bg-[#3b82f6]/20 text-[#3b82f6] hover:bg-[#3b82f6]/30 px-4 py-2 rounded font-medium transition",children:"Start Agent"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function bX({agent:c}){let{theme:Z}=xr(),[_,U]=aa.useState([]),[h,y]=aa.useState(!0),[H,G]=aa.useState(null),[N,I]=aa.useState(null),[W,A]=aa.useState([]),[k,x]=aa.useState(!1),{confirm:M,ConfirmDialog:P}=s5();aa.useEffect(()=>{U([]),I(null),G(null),y(!0)},[c.id]),aa.useEffect(()=>{if(c.status!=="running"){y(!1);return}(async()=>{try{let wa=await fetch(`/api/agents/${c.id}/threads`);if(!wa.ok)throw Error("Failed to fetch threads");let oa=await wa.json();U(oa.threads||[]),G(null)}catch(wa){G(wa instanceof Error?wa.message:"Failed to load threads")}finally{y(!1)}})()},[c.id,c.status]);let s=async(ma)=>{x(!0),I(ma);try{let wa=await fetch(`/api/agents/${c.id}/threads/${ma}/messages`);if(wa.ok){let oa=await wa.json();A(x9(oa.messages||[]))}else A([])}catch{A([])}x(!1)},qa=async(ma,wa)=>{if(wa.stopPropagation(),!await M("Delete this thread?",{confirmText:"Delete",title:"Delete Thread"}))return;try{if(await fetch(`/api/agents/${c.id}/threads/${ma}`,{method:"DELETE"}),U((e)=>e.filter((La)=>La.id!==ma)),N===ma)I(null)}catch{}};if(c.status!=="running")return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("p",{children:"Start the agent to view threads"},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(h)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("p",{children:"Loading threads..."},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(H)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-red-400",children:w.jsxDEV("p",{children:H},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(N)return w.jsxDEV(w.Fragment,{children:[P,w.jsxDEV("div",{className:"flex-1 flex flex-col overflow-hidden",children:k?w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:"Loading messages..."},void 0,!1,void 0,this):w.jsxDEV(ur,{agentId:"default",apiUrl:`/api/agents/${c.id}`,threadId:N,initialMessages:W,placeholder:"Continue this conversation...",context:c.systemPrompt,variant:"terminal",theme:Z.id,showHeader:!0,onHeaderBack:()=>{I(null),A([])}},N,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return w.jsxDEV(w.Fragment,{children:[P,w.jsxDEV("div",{className:"flex-1 overflow-auto",children:_.length===0?w.jsxDEV("div",{className:"flex items-center justify-center h-full text-[var(--color-text-muted)]",children:w.jsxDEV("p",{children:"No conversation threads yet"},void 0,!1,void 0,this)},void 0,!1,void 0,this):w.jsxDEV("div",{className:"divide-y divide-[var(--color-border)]",children:_.map((ma)=>w.jsxDEV("div",{onClick:()=>s(ma.id),className:"p-4 cursor-pointer hover:bg-[var(--color-surface)] transition flex items-center justify-between",children:[w.jsxDEV("div",{className:"flex-1 min-w-0",children:[w.jsxDEV("p",{className:"text-sm font-medium truncate",children:ma.title||`Thread ${ma.id.slice(0,8)}`},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] mt-1",children:[new Date(ma.updated_at||ma.created_at).toLocaleString(),ma.message_count!==void 0&&` • ${ma.message_count} messages`]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("button",{onClick:(wa)=>qa(ma.id,wa),className:"text-[var(--color-text-muted)] hover:text-red-400 text-lg ml-4",children:"×"},void 0,!1,void 0,this)]},ma.id,!0,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function fX({agent:c}){let{authFetch:Z}=$o(),[_,U]=aa.useState([]),[h,y]=aa.useState(!0),[H,G]=aa.useState(null),[N,I]=aa.useState("all"),[W,A]=aa.useState(null),[k,x]=aa.useState(!1),[M,P]=aa.useState(!1),[s,qa]=aa.useState(!1),[ma,wa]=aa.useState(!1),[oa,e]=aa.useState(!1),[La,ha]=aa.useState(!1),[V,Ca]=aa.useState({title:"",description:"",type:"once",priority:5,execute_at:"",recurrence:""}),{confirm:L,ConfirmDialog:ra}=s5(),{events:O}=W1({agent_id:c.id,category:"task"});aa.useEffect(()=>{U([]),G(null),y(!0),A(null)},[c.id]);let d=async()=>{if(c.status!=="running"){y(!1);return}try{let S=await fetch(`/api/agents/${c.id}/tasks?status=${N}`);if(!S.ok)throw Error("Failed to fetch tasks");let _a=await S.json();U(_a.tasks||[]),G(null)}catch(S){G(S instanceof Error?S.message:"Failed to load tasks")}finally{y(!1)}},fa=async(S)=>{A(S),x(!0);try{let _a=await Z(`/api/tasks/${S.agentId||c.id}/${S.id}`);if(_a.ok){let sa=await _a.json();if(sa.task)A({...sa.task,agentId:S.agentId||c.id,agentName:S.agentName||c.name})}}catch(_a){console.error("Failed to fetch task details:",_a)}finally{x(!1)}},C=async()=>{if(!W||s)return;qa(!0);try{await Z(`/api/tasks/${c.id}/${W.id}/execute`,{method:"POST"}),A(null),d()}catch(S){console.error("Failed to execute task:",S)}finally{qa(!1)}},T=async()=>{if(!W||ma)return;if(!await L(`Are you sure you want to delete "${W.title}"?`,{title:"Delete Task",confirmText:"Delete",confirmVariant:"danger"}))return;wa(!0);try{await Z(`/api/tasks/${c.id}/${W.id}`,{method:"DELETE"}),A(null),d()}catch(_a){console.error("Failed to delete task:",_a)}finally{wa(!1)}},va=async(S)=>{try{let _a={...S};if(S.execute_at)_a.execute_at=new Date(S.execute_at).toISOString();if((await Z(`/api/tasks/${c.id}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_a)})).ok)P(!1),d()}catch(_a){console.error("Failed to create task:",_a)}},Pa=(S)=>{Ca({title:S.title,description:S.description||"",type:S.type,priority:S.priority,execute_at:S.execute_at?new Date(S.execute_at).toISOString().slice(0,16):"",recurrence:S.recurrence||""}),e(!0)},xa=async()=>{if(!W||La)return;ha(!0);try{let S={title:V.title.trim(),description:V.description.trim()||void 0,type:V.type,priority:V.priority};if(V.type==="once"&&V.execute_at)S.execute_at=new Date(V.execute_at).toISOString();if(V.type==="recurring"&&V.recurrence.trim())S.recurrence=V.recurrence.trim();if((await Z(`/api/tasks/${c.id}/${W.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(S)})).ok)e(!1),A(null),d()}catch(S){console.error("Failed to update task:",S)}finally{ha(!1)}};aa.useEffect(()=>{y(!0),d()},[c.id,c.status,N,O.length]);let So={pending:"bg-yellow-500/20 text-yellow-400",running:"bg-blue-500/20 text-blue-400",completed:"bg-green-500/20 text-green-400",failed:"bg-red-500/20 text-red-400",cancelled:"bg-gray-500/20 text-gray-400"};if(c.status!=="running")return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("p",{children:"Start the agent to view tasks"},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(!c.features?.tasks)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("div",{className:"text-center",children:[w.jsxDEV("p",{className:"mb-2",children:"Tasks feature is not enabled"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-sm",children:"Enable it in Settings to schedule tasks"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);if(h)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("p",{children:"Loading tasks..."},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(H)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-red-400",children:w.jsxDEV("p",{children:H},void 0,!1,void 0,this)},void 0,!1,void 0,this);let $p=[{value:"all",label:"All"},{value:"pending",label:"Pending"},{value:"running",label:"Running"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}];if(W)return w.jsxDEV("div",{className:"flex-1 flex flex-col overflow-hidden",children:[ra,w.jsxDEV("div",{className:"px-4 pt-3 pb-2 border-b border-[var(--color-border)] shrink-0 flex items-center justify-between",children:[w.jsxDEV("button",{onClick:()=>{A(null),e(!1)},className:"text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text)] transition flex items-center gap-1",children:[w.jsxDEV("span",{children:"←"},void 0,!1,void 0,this)," ",oa?"Cancel":"Back to tasks"]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"flex items-center gap-2",children:oa?w.jsxDEV(w.Fragment,{children:[w.jsxDEV("button",{onClick:()=>e(!1),className:"text-[var(--color-text-muted)] hover:text-[var(--color-text)] text-sm transition",children:"Cancel"},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:xa,disabled:La||!V.title.trim(),className:"px-3 py-1 rounded text-sm bg-[var(--color-accent)] text-black hover:opacity-90 transition disabled:opacity-50",children:La?"Saving...":"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):w.jsxDEV(w.Fragment,{children:[(W.status==="pending"||W.status==="completed"||W.status==="failed")&&w.jsxDEV("button",{onClick:()=>Pa(W),title:"Edit task",className:"text-[var(--color-text-muted)] hover:text-[var(--color-accent)] transition",children:w.jsxDEV("svg",{className:"w-4.5 h-4.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:w.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),(W.status==="pending"||W.status==="completed")&&w.jsxDEV("button",{onClick:C,disabled:s,title:"Execute now",className:"text-[var(--color-accent)] hover:opacity-80 transition disabled:opacity-50",children:w.jsxDEV("svg",{className:"w-4.5 h-4.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[w.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"},void 0,!1,void 0,this),w.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:T,disabled:ma,title:"Delete task",className:"text-red-400 hover:text-red-300 transition disabled:opacity-50",children:w.jsxDEV("svg",{className:"w-4.5 h-4.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:w.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:(()=>{return w.jsxDEV(w.Fragment,{children:[w.jsxDEV("div",{children:w.jsxDEV("div",{className:"flex items-start justify-between gap-2 mb-1",children:[oa?w.jsxDEV("input",{type:"text",value:V.title,onChange:(_a)=>Ca({...V,title:_a.target.value}),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-2 py-1.5 text-sm focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)] text-lg font-medium",placeholder:"Task title"},void 0,!1,void 0,this):w.jsxDEV("h3",{className:"text-lg font-medium",children:W.title},void 0,!1,void 0,this),!oa&&w.jsxDEV("span",{className:`px-2 py-1 rounded text-xs font-medium flex-shrink-0 ${So[W.status]}`,children:W.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),oa?w.jsxDEV("div",{children:[w.jsxDEV("h4",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wider mb-1",children:"Description"},void 0,!1,void 0,this),w.jsxDEV("textarea",{value:V.description,onChange:(_a)=>Ca({...V,description:_a.target.value}),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-2 py-1.5 text-sm focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)] resize-none",rows:3,placeholder:"Task description..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):W.description?w.jsxDEV("div",{children:[w.jsxDEV("h4",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wider mb-1",children:"Description"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-sm text-[var(--color-text-secondary)] whitespace-pre-wrap",children:W.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null,oa?w.jsxDEV("div",{className:"grid grid-cols-2 gap-3",children:[w.jsxDEV("div",{children:[w.jsxDEV("label",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wider mb-1 block",children:"Type"},void 0,!1,void 0,this),w.jsxDEV("select",{value:V.type,onChange:(_a)=>Ca({...V,type:_a.target.value}),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-2 py-1.5 text-sm focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)]",children:[w.jsxDEV("option",{value:"once",children:"One-time"},void 0,!1,void 0,this),w.jsxDEV("option",{value:"recurring",children:"Recurring"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{children:[w.jsxDEV("label",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wider mb-1 block",children:"Priority"},void 0,!1,void 0,this),w.jsxDEV("input",{type:"number",min:1,max:10,value:V.priority,onChange:(_a)=>Ca({...V,priority:Number(_a.target.value)}),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-2 py-1.5 text-sm focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):w.jsxDEV("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[w.jsxDEV("div",{children:[w.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Type"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"capitalize",children:W.type},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{children:[w.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Priority"},void 0,!1,void 0,this),w.jsxDEV("p",{children:W.priority},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W.recurrence&&w.jsxDEV("div",{children:[w.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Recurrence"},void 0,!1,void 0,this),w.jsxDEV("p",{children:R7(W.recurrence)},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-0.5 font-mono",children:W.recurrence},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),oa&&V.type==="once"&&w.jsxDEV("div",{children:[w.jsxDEV("label",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wider mb-1 block",children:"Schedule"},void 0,!1,void 0,this),w.jsxDEV("input",{type:"datetime-local",value:V.execute_at,onChange:(_a)=>Ca({...V,execute_at:_a.target.value}),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-2 py-1.5 text-sm focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),oa&&V.type==="recurring"&&w.jsxDEV("div",{children:[w.jsxDEV("label",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wider mb-1 block",children:"Cron Schedule"},void 0,!1,void 0,this),w.jsxDEV("input",{type:"text",value:V.recurrence,onChange:(_a)=>Ca({...V,recurrence:_a.target.value}),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-2 py-1.5 text-sm focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)] font-mono",placeholder:"*/30 * * * *"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-1",children:"e.g. */30 * * * * = every 30 min"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!oa&&w.jsxDEV("div",{className:"space-y-2 text-sm",children:[w.jsxDEV("div",{className:"flex justify-between",children:[w.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Created"},void 0,!1,void 0,this),w.jsxDEV("span",{children:new Date(W.created_at).toLocaleString()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W.execute_at&&w.jsxDEV("div",{className:"flex justify-between",children:[w.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Scheduled"},void 0,!1,void 0,this),w.jsxDEV("span",{className:"text-[var(--color-accent)]",children:E5(W.execute_at)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W.executed_at&&w.jsxDEV("div",{className:"flex justify-between",children:[w.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Started"},void 0,!1,void 0,this),w.jsxDEV("span",{children:new Date(W.executed_at).toLocaleString()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W.completed_at&&w.jsxDEV("div",{className:"flex justify-between",children:[w.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Completed"},void 0,!1,void 0,this),w.jsxDEV("span",{children:new Date(W.completed_at).toLocaleString()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W.next_run&&w.jsxDEV("div",{className:"flex justify-between",children:[w.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Next Run"},void 0,!1,void 0,this),w.jsxDEV("span",{className:"text-[var(--color-accent)]",children:E5(W.next_run)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!oa&&W.status==="failed"&&W.error&&w.jsxDEV("div",{className:"min-w-0",children:[w.jsxDEV("h4",{className:"text-xs text-red-400 uppercase tracking-wider mb-1",children:"Error"},void 0,!1,void 0,this),w.jsxDEV("div",{className:"bg-red-500/10 border border-red-500/20 rounded p-3 overflow-x-auto",children:w.jsxDEV("pre",{className:"text-sm text-red-400 whitespace-pre-wrap break-words",children:W.error},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!oa&&W.status==="completed"&&W.result&&w.jsxDEV("div",{className:"min-w-0",children:[w.jsxDEV("h4",{className:"text-xs text-green-400 uppercase tracking-wider mb-1",children:"Result"},void 0,!1,void 0,this),w.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/20 rounded p-3 overflow-x-auto",children:w.jsxDEV("pre",{className:"text-sm text-green-400 whitespace-pre-wrap break-words",children:typeof W.result==="string"?W.result:JSON.stringify(W.result,null,2)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!oa&&k&&!W.trajectory&&w.jsxDEV("div",{children:[w.jsxDEV("h4",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wider mb-2",children:"Trajectory"},void 0,!1,void 0,this),w.jsxDEV("div",{className:"text-sm text-[var(--color-text-faint)]",children:"Loading trajectory..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!oa&&W.trajectory&&W.trajectory.length>0&&w.jsxDEV("div",{children:[w.jsxDEV("h4",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wider mb-2",children:["Trajectory (",W.trajectory.length," steps)"]},void 0,!0,void 0,this),w.jsxDEV(E9,{trajectory:W.trajectory},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)})()},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return w.jsxDEV("div",{className:"flex-1 overflow-auto p-4",children:[w.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[w.jsxDEV("div",{className:"flex gap-2",children:$p.map((S)=>w.jsxDEV("button",{onClick:()=>I(S.value),className:`px-3 py-1.5 rounded text-sm transition ${N===S.value?"bg-[var(--color-accent)] text-black":"bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)]"}`,children:S.label},S.value,!1,void 0,this))},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:()=>P(!M),className:"px-3 py-1.5 rounded text-sm bg-[var(--color-accent)] text-black hover:opacity-90 transition flex items-center gap-1 flex-shrink-0",children:[w.jsxDEV("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:w.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"},void 0,!1,void 0,this)},void 0,!1,void 0,this),"New"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),M&&w.jsxDEV(iX,{onSubmit:va,onCancel:()=>P(!1)},void 0,!1,void 0,this),_.length===0?w.jsxDEV("div",{className:"text-center py-10",children:[w.jsxDEV(Nm,{className:"w-10 h-10 mx-auto mb-3 text-[var(--color-border-light)]"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-[var(--color-text-muted)]",children:["No ",N==="all"?"":N+" ","tasks"]},void 0,!0,void 0,this),w.jsxDEV("p",{className:"text-sm text-[var(--color-text-faint)] mt-1",children:"Tasks will appear here when created"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):w.jsxDEV("div",{className:"space-y-3",children:_.map((S)=>w.jsxDEV("div",{onClick:()=>fa(S),className:"bg-[var(--color-surface)] card p-4 cursor-pointer hover:border-[var(--color-border-light)] transition",children:[w.jsxDEV("div",{className:"flex items-start justify-between mb-2",children:[w.jsxDEV("div",{className:"flex-1 min-w-0",children:w.jsxDEV("h3",{className:"font-medium",children:S.title||S.name},void 0,!1,void 0,this)},void 0,!1,void 0,this),w.jsxDEV("span",{className:`px-2 py-1 rounded text-xs font-medium ml-2 ${So[S.status]||So.pending}`,children:S.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this),S.description&&w.jsxDEV("p",{className:"text-sm text-[var(--color-text-secondary)] mb-2 line-clamp-2",children:S.description},void 0,!1,void 0,this),w.jsxDEV("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-[var(--color-text-faint)]",children:[w.jsxDEV("span",{className:"flex items-center gap-1",children:[S.type==="recurring"?w.jsxDEV(V9,{className:"w-3.5 h-3.5"},void 0,!1,void 0,this):S.execute_at?w.jsxDEV(D9,{className:"w-3.5 h-3.5"},void 0,!1,void 0,this):w.jsxDEV(j9,{className:"w-3.5 h-3.5"},void 0,!1,void 0,this),S.type==="recurring"&&S.recurrence?R7(S.recurrence):S.type||"once"]},void 0,!0,void 0,this),S.priority!==void 0&&w.jsxDEV("span",{children:["Priority: ",S.priority]},void 0,!0,void 0,this),S.next_run&&w.jsxDEV("span",{className:"text-[var(--color-accent)]",children:E5(S.next_run)},void 0,!1,void 0,this),!S.next_run&&S.execute_at&&w.jsxDEV("span",{className:"text-[var(--color-accent)]",children:E5(S.execute_at)},void 0,!1,void 0,this),w.jsxDEV("span",{children:["Created: ",new Date(S.created_at).toLocaleDateString()]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),S.status==="completed"&&S.result&&w.jsxDEV("div",{className:"mt-3 bg-green-500/10 border border-green-500/20 rounded p-3",children:[w.jsxDEV("h4",{className:"text-xs text-green-400 uppercase tracking-wider mb-1",children:"Result"},void 0,!1,void 0,this),w.jsxDEV("pre",{className:"text-sm text-green-400 whitespace-pre-wrap break-words",children:typeof S.result==="string"?S.result:JSON.stringify(S.result,null,2)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),S.status==="failed"&&S.error&&w.jsxDEV("div",{className:"mt-3 bg-red-500/10 border border-red-500/20 rounded p-3",children:[w.jsxDEV("h4",{className:"text-xs text-red-400 uppercase tracking-wider mb-1",children:"Error"},void 0,!1,void 0,this),w.jsxDEV("pre",{className:"text-sm text-red-400 whitespace-pre-wrap break-words",children:S.error},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},S.id,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function iX({onSubmit:c,onCancel:Z}){let[_,U]=aa.useState(""),[h,y]=aa.useState(""),[H,G]=aa.useState("once"),[N,I]=aa.useState(5),[W,A]=aa.useState(""),[k,x]=aa.useState("");return w.jsxDEV("div",{className:"bg-[var(--color-surface)] border border-[var(--color-accent)]/30 rounded-lg p-3 mb-4 space-y-3",children:[w.jsxDEV("input",{type:"text",value:_,onChange:(M)=>U(M.target.value),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-3 py-1.5 text-sm",placeholder:"Task title...",autoFocus:!0},void 0,!1,void 0,this),w.jsxDEV("textarea",{value:h,onChange:(M)=>y(M.target.value),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-3 py-1.5 text-sm resize-none",rows:2,placeholder:"Description (optional)..."},void 0,!1,void 0,this),w.jsxDEV("div",{className:"grid grid-cols-2 gap-2",children:[w.jsxDEV("select",{value:H,onChange:(M)=>G(M.target.value),className:"bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-2 py-1.5 text-sm",children:[w.jsxDEV("option",{value:"once",children:"One-time"},void 0,!1,void 0,this),w.jsxDEV("option",{value:"recurring",children:"Recurring"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("input",{type:"number",min:1,max:10,value:N,onChange:(M)=>I(Number(M.target.value)),className:"bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-2 py-1.5 text-sm",placeholder:"Priority"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H==="once"&&w.jsxDEV("input",{type:"datetime-local",value:W,onChange:(M)=>A(M.target.value),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-3 py-1.5 text-sm"},void 0,!1,void 0,this),H==="recurring"&&w.jsxDEV("input",{type:"text",value:k,onChange:(M)=>x(M.target.value),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-3 py-1.5 text-sm font-mono",placeholder:"*/30 * * * * (cron)"},void 0,!1,void 0,this),w.jsxDEV("div",{className:"flex justify-end gap-2",children:[w.jsxDEV("button",{onClick:Z,className:"px-3 py-1.5 rounded text-sm bg-[var(--color-surface-raised)] hover:bg-[var(--color-border)] transition",children:"Cancel"},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:()=>_.trim()&&c({title:_.trim(),description:h.trim(),type:H,priority:N,execute_at:W||void 0,recurrence:k||void 0}),disabled:!_.trim(),className:"px-3 py-1.5 rounded text-sm bg-[var(--color-accent)] text-black hover:opacity-90 transition disabled:opacity-50",children:"Create"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function wX({agent:c}){let[Z,_]=aa.useState([]),[U,h]=aa.useState(!0),[y,H]=aa.useState(null),[G,N]=aa.useState(!1),{confirm:I,ConfirmDialog:W}=s5();aa.useEffect(()=>{_([]),H(null),h(!0)},[c.id]);let A=async()=>{if(c.status!=="running"){h(!1);return}try{let M=await fetch(`/api/agents/${c.id}/memories`);if(!M.ok)throw Error("Failed to fetch memories");let P=await M.json();_(P.memories||[]),N(P.enabled??!1),H(null)}catch(M){H(M instanceof Error?M.message:"Failed to load memories")}finally{h(!1)}};aa.useEffect(()=>{A()},[c.id,c.status]);let k=async(M)=>{try{await fetch(`/api/agents/${c.id}/memories/${M}`,{method:"DELETE"}),_((P)=>P.filter((s)=>s.id!==M))}catch{}},x=async()=>{if(!await I("Clear all memories?",{confirmText:"Clear",title:"Clear Memories"}))return;try{await fetch(`/api/agents/${c.id}/memories`,{method:"DELETE"}),_([])}catch{}};if(!c.features?.memory)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("div",{className:"text-center",children:[w.jsxDEV("p",{className:"mb-2",children:"Memory feature is not enabled"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-sm",children:"Enable it in Settings to persist knowledge"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);if(c.status!=="running")return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("p",{children:"Start the agent to view memories"},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(U)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("p",{children:"Loading memories..."},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(y)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-red-400",children:w.jsxDEV("p",{children:y},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(!G)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("div",{className:"text-center",children:[w.jsxDEV("p",{className:"mb-2",children:"Memory system not initialized"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-sm",children:"Check OPENAI_API_KEY for embeddings"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);return w.jsxDEV(w.Fragment,{children:[W,w.jsxDEV("div",{className:"flex-1 overflow-auto p-4",children:[w.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[w.jsxDEV("h3",{className:"text-sm font-medium text-[var(--color-text-secondary)]",children:["Stored Memories (",Z.length,")"]},void 0,!0,void 0,this),Z.length>0&&w.jsxDEV("button",{onClick:x,className:"text-xs text-red-400 hover:text-red-300",children:"Clear All"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z.length===0?w.jsxDEV("div",{className:"text-center py-10 text-[var(--color-text-muted)]",children:[w.jsxDEV("p",{children:"No memories stored yet"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-sm mt-1",children:"The agent will remember important information from conversations"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):w.jsxDEV("div",{className:"space-y-3",children:Z.map((M)=>w.jsxDEV("div",{className:"bg-[var(--color-surface)] border border-[var(--color-border)] rounded p-3",children:[w.jsxDEV("div",{className:"flex items-start justify-between gap-2",children:[w.jsxDEV("p",{className:"text-sm text-[var(--color-text)] flex-1",children:M.content},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:()=>k(M.id),className:"text-[var(--color-text-muted)] hover:text-red-400 text-sm flex-shrink-0",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"flex items-center gap-3 mt-2",children:[w.jsxDEV("span",{className:`text-xs px-2 py-0.5 rounded ${M.type==="preference"?"bg-purple-500/20 text-purple-400":M.type==="fact"?"bg-green-500/20 text-green-400":"bg-blue-500/20 text-blue-400"}`,children:M.type},void 0,!1,void 0,this),w.jsxDEV("span",{className:"text-xs text-[var(--color-text-muted)]",children:new Date(M.created_at).toLocaleString()},void 0,!1,void 0,this),M.importance&&w.jsxDEV("span",{className:"text-xs text-[var(--color-text-faint)]",children:["importance: ",M.importance.toFixed(1)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},M.id,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function cX({agent:c}){let[Z,_]=aa.useState([]),[U,h]=aa.useState(!0),[y,H]=aa.useState(null),[G,N]=aa.useState(!1),[I,W]=aa.useState(null),[A,k]=aa.useState(!1),x=aa.default.useRef(null),{confirm:M,ConfirmDialog:P}=s5();aa.useEffect(()=>{_([]),H(null),h(!0)},[c.id]);let s=async()=>{if(c.status!=="running"){h(!1);return}try{let L=await fetch(`/api/agents/${c.id}/files`);if(!L.ok)throw Error("Failed to fetch files");let ra=await L.json();_(ra.files||[]),H(null)}catch(L){H(L instanceof Error?L.message:"Failed to load files")}finally{h(!1)}};aa.useEffect(()=>{s()},[c.id,c.status]);let qa=async(L)=>{if(!await M("Delete this file?",{confirmText:"Delete",title:"Delete File"}))return;try{await fetch(`/api/agents/${c.id}/files/${L}`,{method:"DELETE"}),_((O)=>O.filter((d)=>d.id!==L))}catch{}},ma=(L,ra)=>{let O=document.createElement("a");O.href=`/api/agents/${c.id}/files/${L}/download`,O.download=ra,O.click()},wa=(L)=>{if(L<1024)return`${L} B`;if(L<1048576)return`${(L/1024).toFixed(1)} KB`;return`${(L/1048576).toFixed(1)} MB`},oa=async(L)=>{N(!0),W(null);try{let ra=new FormData;ra.append("file",L);let O=await fetch(`/api/agents/${c.id}/files`,{method:"POST",body:ra});if(!O.ok){let d=await O.json();throw Error(d.error||"Upload failed")}await s()}catch(ra){W(ra instanceof Error?ra.message:"Upload failed")}finally{N(!1)}},e=(L)=>{let ra=L.target.files?.[0];if(ra)oa(ra);L.target.value=""},La=(L)=>{L.preventDefault(),k(!1);let ra=L.dataTransfer.files?.[0];if(ra)oa(ra)},ha=(L)=>{L.preventDefault(),k(!0)},V=(L)=>{L.preventDefault(),k(!1)},Ca=(L)=>{if(L.startsWith("image/"))return"\uD83D\uDDBC";if(L.includes("pdf"))return"\uD83D\uDCD5";if(L.includes("json"))return"{}";if(L.includes("javascript")||L.includes("typescript"))return"⚡";if(L.startsWith("text/"))return"\uD83D\uDCC4";if(L.startsWith("audio/"))return"\uD83C\uDFB5";if(L.startsWith("video/"))return"\uD83C\uDFAC";return"\uD83D\uDCC1"};if(!c.features?.files)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("div",{className:"text-center",children:[w.jsxDEV("p",{className:"mb-2",children:"Files feature is not enabled"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-sm",children:"Enable it in Settings to manage files"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);if(c.status!=="running")return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("p",{children:"Start the agent to view files"},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(U)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:w.jsxDEV("p",{children:"Loading files..."},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(y)return w.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-red-400",children:w.jsxDEV("p",{children:y},void 0,!1,void 0,this)},void 0,!1,void 0,this);return w.jsxDEV(w.Fragment,{children:[P,w.jsxDEV("div",{className:`flex-1 overflow-auto p-4 transition ${A?"bg-[var(--color-accent-5)]":""}`,onDrop:La,onDragOver:ha,onDragLeave:V,children:[w.jsxDEV("input",{ref:x,type:"file",className:"hidden",onChange:e},void 0,!1,void 0,this),w.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[w.jsxDEV("h3",{className:"text-sm font-medium text-[var(--color-text-secondary)]",children:["Agent Files (",Z.length,")"]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"flex items-center gap-2",children:[w.jsxDEV("button",{onClick:()=>x.current?.click(),disabled:G,className:"text-xs bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 text-black px-3 py-1 rounded font-medium transition",children:G?"Uploading...":"Upload"},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:s,className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)]",children:"Refresh"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),I&&w.jsxDEV("div",{className:"mb-4 text-sm bg-red-500/10 text-red-400 px-3 py-2 rounded",children:I},void 0,!1,void 0,this),A&&w.jsxDEV("div",{className:"mb-4 border-2 border-dashed border-[var(--color-accent)] rounded-lg p-8 text-center",children:w.jsxDEV("p",{className:"text-[var(--color-accent)]",children:"Drop file to upload"},void 0,!1,void 0,this)},void 0,!1,void 0,this),Z.length===0&&!A&&w.jsxDEV("div",{className:"text-center py-10 text-[var(--color-text-muted)]",children:[w.jsxDEV("p",{children:"No files stored yet"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-sm mt-1",children:"Drop files here, click Upload, or attach files in Chat"},void 0,!1,void 0,this),c.features?.memory&&w.jsxDEV("p",{className:"text-xs mt-2 text-[var(--color-text-faint)]",children:"Files will be auto-ingested into memory"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z.length>0&&w.jsxDEV("div",{className:"space-y-2",children:Z.map((L)=>w.jsxDEV("div",{className:"bg-[var(--color-surface)] border border-[var(--color-border)] rounded p-3 flex items-center gap-3",children:[w.jsxDEV("div",{className:"w-10 h-10 bg-[var(--color-surface-raised)] rounded flex items-center justify-center text-[var(--color-text-muted)]",children:Ca(L.mime_type)},void 0,!1,void 0,this),w.jsxDEV("div",{className:"flex-1 min-w-0",children:[w.jsxDEV("p",{className:"text-sm text-[var(--color-text)] truncate",children:L.filename},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)]",children:[wa(L.size_bytes)," • ",new Date(L.created_at).toLocaleString(),L.source&&L.source!=="upload"&&` • ${L.source}`]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"flex items-center gap-2",children:[w.jsxDEV("button",{onClick:()=>ma(L.id,L.filename),className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-accent)] px-2 py-1",children:"↓"},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:()=>qa(L.id),className:"text-[var(--color-text-muted)] hover:text-red-400 text-sm",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},L.id,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function lX({agent:c,providers:Z,onUpdateAgent:_,onDeleteAgent:U}){let{authFetch:h,isDev:y}=$o(),[H,G]=aa.useState({name:c.name,provider:c.provider,model:c.model,systemPrompt:c.systemPrompt,features:{...c.features,builtinTools:c.features.builtinTools||{webSearch:!1,webFetch:!1}},mcpServers:[...c.mcpServers||[]],skills:[...c.skills||[]]}),[N,I]=aa.useState(!1),[W,A]=aa.useState(!1),[k,x]=aa.useState(null),[M,P]=aa.useState([]),[s,qa]=aa.useState([]),[ma,wa]=aa.useState([]),[oa,e]=aa.useState(!1),[La,ha]=aa.useState(null),[V,Ca]=aa.useState(null),[L,ra]=aa.useState(!1),[O,d]=aa.useState([]),[fa,C]=aa.useState(null),[T,va]=aa.useState(!1);aa.useEffect(()=>{h(`/api/subscriptions?agent_id=${c.id}`).then((B)=>B.ok?B.json():{subscriptions:[]}).then((B)=>d(B.subscriptions||[])).catch(()=>{})},[c.id,h]),aa.useEffect(()=>{(async()=>{try{let ka=await(await h("/api/mcp/servers")).json();P(ka.servers||[])}catch(u){console.error("Failed to fetch MCP servers:",u)}})()},[h]),aa.useEffect(()=>{(async()=>{try{let u=await h(`/api/agents/${c.id}/api-key`);if(u.ok){let ka=await u.json();ha(ka.apiKey),Ca(ka.fullKey||null)}}catch(u){}})()},[c.id,h]),aa.useEffect(()=>{(async()=>{try{let u=await h(`/api/agents/${c.id}/share-token`);if(u.ok){let ka=await u.json();C(ka.token||null)}}catch{}})()},[c.id,h]),aa.useEffect(()=>{(async()=>{try{let ka=await(await h("/api/skills")).json();qa(ka.skills||[])}catch(u){console.error("Failed to fetch skills:",u)}})()},[h]),aa.useEffect(()=>{if(H.provider==="ollama")e(!0),h("/api/providers/ollama/models").then((B)=>B.json()).then((B)=>{if(B.models&&B.models.length>0)wa(B.models.map((u)=>({value:u.value,label:u.label||u.value})))}).catch(()=>wa([])).finally(()=>e(!1));else wa([])},[H.provider,h]),aa.useEffect(()=>{G({name:c.name,provider:c.provider,model:c.model,systemPrompt:c.systemPrompt,features:{...c.features,builtinTools:c.features.builtinTools||{webSearch:!1,webFetch:!1}},mcpServers:[...c.mcpServers||[]],skills:[...c.skills||[]]}),x(null)},[c.id]);let Pa=Z.find((B)=>B.id===H.provider),xa=Z.filter((B)=>B.hasKey&&B.type==="llm").map((B)=>({value:B.id,label:B.name})),So=H.provider==="ollama"&&ma.length>0?ma:Pa?.models.map((B)=>({value:B.value,label:B.label,recommended:B.recommended}))||[],$p=(B)=>{let u=Z.find((jo)=>jo.id===B),ka=u?.models.find((jo)=>jo.recommended)?.value||u?.models[0]?.value||"";G((jo)=>({...jo,provider:B,model:ka}))},S=(B)=>{if(B==="agents")G((u)=>{if(typeof u.features.agents==="boolean"?u.features.agents:u.features.agents?.enabled??!1)return{...u,features:{...u.features,agents:!1}};else return{...u,features:{...u.features,agents:{enabled:!0,group:c.projectId||void 0}}}});else if(B==="operator")G((u)=>{if(S5(u.features).enabled)return{...u,features:{...u.features,operator:!1}};else return{...u,features:{...u.features,operator:{enabled:!0}}}});else G((u)=>({...u,features:{...u.features,[B]:!u.features[B]}}))},_a=()=>{let B=H.features.agents;if(typeof B==="boolean")return B;return B?.enabled??!1},sa=()=>{return S5(H.features).enabled},pr=()=>{return S5(H.features)},jr=Z.filter((B)=>B.type==="browser"&&B.hasKey),Er=(B)=>{G((u)=>{let ka=S5(u.features);return{...u,features:{...u.features,operator:{...ka,enabled:!0,browser_provider:B}}}})},mr=(B)=>{G((u)=>({...u,mcpServers:u.mcpServers.includes(B)?u.mcpServers.filter((ka)=>ka!==B):[...u.mcpServers,B]}))},vm=(B)=>{G((u)=>({...u,skills:u.skills.includes(B)?u.skills.filter((ka)=>ka!==B):[...u.skills,B]}))},sr=async()=>{I(!0),x(null);let B=await _(H);if(I(!1),B.error)x({type:"error",text:B.error});else x({type:"success",text:"Settings saved"}),setTimeout(()=>x(null),2000)},F=H.name!==c.name||H.provider!==c.provider||H.model!==c.model||H.systemPrompt!==c.systemPrompt||JSON.stringify(H.features)!==JSON.stringify(c.features)||JSON.stringify(H.mcpServers.sort())!==JSON.stringify((c.mcpServers||[]).sort())||JSON.stringify(H.skills.sort())!==JSON.stringify((c.skills||[]).sort());return w.jsxDEV("div",{className:"flex-1 overflow-auto p-4",children:w.jsxDEV("div",{className:"space-y-4",children:[w.jsxDEV(lt,{label:"Name",children:w.jsxDEV("input",{type:"text",value:H.name,onChange:(B)=>G((u)=>({...u,name:B.target.value})),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)]"},void 0,!1,void 0,this)},void 0,!1,void 0,this),w.jsxDEV(lt,{label:"Provider",children:w.jsxDEV(ct,{value:H.provider,options:xa,onChange:$p},void 0,!1,void 0,this)},void 0,!1,void 0,this),w.jsxDEV(lt,{label:"Model",children:oa?w.jsxDEV("div",{className:"text-sm text-[var(--color-text-muted)] py-2",children:"Loading Ollama models..."},void 0,!1,void 0,this):H.provider==="ollama"&&So.length===0?w.jsxDEV("div",{className:"text-sm text-yellow-400/80 py-2",children:["No models found. Run ",w.jsxDEV("code",{className:"bg-[var(--color-surface-raised)] px-1 rounded",children:"ollama pull llama3.3"},void 0,!1,void 0,this)," to download a model."]},void 0,!0,void 0,this):w.jsxDEV(ct,{value:H.model,options:So,onChange:(B)=>G((u)=>({...u,model:B}))},void 0,!1,void 0,this)},void 0,!1,void 0,this),w.jsxDEV(lt,{label:"System Prompt",children:w.jsxDEV("textarea",{value:H.systemPrompt,onChange:(B)=>G((u)=>({...u,systemPrompt:B.target.value})),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 h-24 resize-none focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)]"},void 0,!1,void 0,this)},void 0,!1,void 0,this),w.jsxDEV(lt,{label:"Features",children:w.jsxDEV("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:rX.map(({key:B,label:u,description:ka,icon:jo})=>{let Ta=B==="agents"?_a():B==="operator"?sa():!!H.features[B];return w.jsxDEV("button",{type:"button",onClick:()=>S(B),className:`flex items-center gap-3 p-3 rounded border text-left transition ${Ta?"border-[var(--color-accent)] bg-[var(--color-accent-10)]":"border-[var(--color-border-light)] hover:border-[var(--color-border-light)]"}`,children:[w.jsxDEV(jo,{className:`w-5 h-5 flex-shrink-0 ${Ta?"text-[var(--color-accent)]":"text-[var(--color-text-muted)]"}`},void 0,!1,void 0,this),w.jsxDEV("div",{className:"flex-1 min-w-0",children:[w.jsxDEV("div",{className:`text-sm font-medium ${Ta?"text-[var(--color-accent)]":""}`,children:u},void 0,!1,void 0,this),w.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)]",children:ka},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},B,!0,void 0,this)})},void 0,!1,void 0,this)},void 0,!1,void 0,this),sa()&&w.jsxDEV(lt,{label:"Browser Provider",children:jr.length>0?w.jsxDEV(ct,{value:pr().browser_provider||"",options:[{value:"",label:"Auto (first available)"},...jr.map((B)=>({value:B.id,label:B.name}))],onChange:(B)=>Er(B)},void 0,!1,void 0,this):w.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] p-3 border border-[var(--color-border-light)] rounded bg-[var(--color-bg)]",children:"No browser providers configured. Go to Settings → Providers to add one."},void 0,!1,void 0,this)},void 0,!1,void 0,this),H.provider==="anthropic"&&w.jsxDEV(lt,{label:"Agent Built-in Tools",children:[w.jsxDEV("div",{className:"flex flex-wrap gap-2",children:[w.jsxDEV("button",{type:"button",onClick:()=>G((B)=>({...B,features:{...B.features,builtinTools:{...B.features.builtinTools,webSearch:!B.features.builtinTools?.webSearch}}})),className:`flex items-center gap-2 px-3 py-2 rounded border transition ${H.features.builtinTools?.webSearch?"border-[var(--color-accent)] bg-[var(--color-accent-10)] text-[var(--color-accent)]":"border-[var(--color-border-light)] hover:border-[var(--color-border-light)] text-[var(--color-text-secondary)]"}`,children:[w.jsxDEV("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:w.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"},void 0,!1,void 0,this)},void 0,!1,void 0,this),w.jsxDEV("span",{className:"text-sm",children:"Web Search"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("button",{type:"button",onClick:()=>G((B)=>({...B,features:{...B.features,builtinTools:{...B.features.builtinTools,webFetch:!B.features.builtinTools?.webFetch}}})),className:`flex items-center gap-2 px-3 py-2 rounded border transition ${H.features.builtinTools?.webFetch?"border-[var(--color-accent)] bg-[var(--color-accent-10)] text-[var(--color-accent)]":"border-[var(--color-border-light)] hover:border-[var(--color-border-light)] text-[var(--color-text-secondary)]"}`,children:[w.jsxDEV("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:w.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"},void 0,!1,void 0,this)},void 0,!1,void 0,this),w.jsxDEV("span",{className:"text-sm",children:"Web Fetch"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-2",children:"Provider-native tools for real-time web access"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H.features.mcp&&w.jsxDEV(lt,{label:"MCP Servers",children:M.length===0?w.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:"No MCP servers configured. Add servers in the MCP page first."},void 0,!1,void 0,this):w.jsxDEV("div",{className:"space-y-2",children:[M.filter((B)=>B.project_id===null||B.project_id===c.projectId).map((B)=>{let u=B.type==="http"&&B.url,ka=u||B.status==="running",jo=u?`${B.source||"remote"} • http`:`${B.type} • ${B.package||B.command||"custom"}${B.status==="running"&&B.port?` • :${B.port}`:""}`;return w.jsxDEV("button",{type:"button",onClick:()=>mr(B.id),className:`w-full flex items-center gap-3 p-3 rounded border text-left transition ${H.mcpServers.includes(B.id)?"border-[var(--color-accent)] bg-[var(--color-accent-10)]":"border-[var(--color-border-light)] hover:border-[var(--color-border-light)]"}`,children:[w.jsxDEV("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${ka?"bg-green-400":"bg-[var(--color-scrollbar)]"}`},void 0,!1,void 0,this),w.jsxDEV("div",{className:"flex-1 min-w-0",children:[w.jsxDEV("div",{className:"flex items-center gap-2",children:[w.jsxDEV("span",{className:`text-sm font-medium ${H.mcpServers.includes(B.id)?"text-[var(--color-accent)]":""}`,children:B.name},void 0,!1,void 0,this),B.project_id===null&&w.jsxDEV("span",{className:"text-[10px] text-[var(--color-text-muted)] bg-[var(--color-surface-raised)] px-1.5 py-0.5 rounded",children:"Global"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)]",children:jo},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:`text-xs px-2 py-0.5 rounded ${ka?"bg-green-500/20 text-green-400":"bg-[var(--color-surface-raised)] text-[var(--color-text-muted)]"}`,children:u?"remote":B.status},void 0,!1,void 0,this)]},B.id,!0,void 0,this)}),w.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] mt-2",children:"Remote servers are always available. Local servers must be running."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),w.jsxDEV(lt,{label:"Skills",children:s.length===0?w.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:"No skills configured. Add skills in the Skills page first."},void 0,!1,void 0,this):w.jsxDEV("div",{className:"space-y-2",children:[s.filter((B)=>B.enabled&&(B.project_id===null||B.project_id===c.projectId)).map((B)=>w.jsxDEV("button",{type:"button",onClick:()=>vm(B.id),className:`w-full flex items-center gap-3 p-3 rounded border text-left transition ${H.skills.includes(B.id)?"border-[var(--color-accent)] bg-[var(--color-accent-10)]":"border-[var(--color-border-light)] hover:border-[var(--color-border-light)]"}`,children:[w.jsxDEV("div",{className:"flex-1 min-w-0",children:[w.jsxDEV("div",{className:"flex items-center gap-2",children:[w.jsxDEV("span",{className:`text-sm font-medium ${H.skills.includes(B.id)?"text-[var(--color-accent)]":""}`,children:B.name},void 0,!1,void 0,this),B.project_id===null&&w.jsxDEV("span",{className:"text-[10px] text-[var(--color-text-muted)] bg-[var(--color-surface-raised)] px-1.5 py-0.5 rounded",children:"Global"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)]",children:B.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"text-xs px-2 py-0.5 rounded bg-[var(--color-surface-raised)] text-[var(--color-text-muted)]",children:["v",B.version]},void 0,!0,void 0,this)]},B.id,!0,void 0,this)),w.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] mt-2",children:"Skills provide reusable instructions for the agent."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),k&&w.jsxDEV("div",{className:`text-sm px-3 py-2 rounded ${k.type==="success"?"bg-green-500/10 text-green-400":"bg-red-500/10 text-red-400"}`,children:k.text},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:sr,disabled:!F||N||!H.name,className:"w-full bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 disabled:cursor-not-allowed text-black px-4 py-2 rounded font-medium transition",children:N?"Saving...":"Save Changes"},void 0,!1,void 0,this),c.status==="running"&&F&&w.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] text-center",children:"Changes will be applied to the running agent"},void 0,!1,void 0,this),w.jsxDEV("div",{className:"mt-8 pt-6 border-t border-[var(--color-border-light)]",children:[w.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] mb-3",children:"Subscriptions"},void 0,!1,void 0,this),O.length===0?w.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)]",children:"No subscriptions. Set up triggers in Connections to have this agent listen to external events."},void 0,!1,void 0,this):w.jsxDEV("div",{className:"space-y-2",children:O.map((B)=>w.jsxDEV("div",{className:"flex items-center gap-2 px-3 py-2 bg-[var(--color-surface)] rounded border border-[var(--color-border)]",children:[w.jsxDEV("span",{className:`w-2 h-2 rounded-full shrink-0 ${B.enabled?"bg-cyan-400":"bg-[var(--color-scrollbar)]"}`},void 0,!1,void 0,this),w.jsxDEV("span",{className:`text-sm flex-1 ${B.enabled?"text-cyan-400":"text-[var(--color-text-muted)]"}`,children:B.trigger_slug.replace(/_/g," ")},void 0,!1,void 0,this),w.jsxDEV("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${B.enabled?"bg-cyan-500/10 text-cyan-400":"bg-[var(--color-surface-raised)] text-[var(--color-text-faint)]"}`,children:B.enabled?"active":"disabled"},void 0,!1,void 0,this)]},B.id,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),La&&w.jsxDEV("div",{className:"mt-8 pt-6 border-t border-[var(--color-border-light)]",children:[w.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] mb-3",children:"Developer Info"},void 0,!1,void 0,this),w.jsxDEV("div",{className:"space-y-2",children:[w.jsxDEV("div",{className:"flex items-center justify-between",children:[w.jsxDEV("span",{className:"text-xs text-[var(--color-text-muted)]",children:"Agent ID"},void 0,!1,void 0,this),w.jsxDEV("code",{className:"text-xs bg-[var(--color-surface-raised)] px-2 py-1 rounded text-[var(--color-text-secondary)]",children:c.id},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"flex items-center justify-between",children:[w.jsxDEV("span",{className:"text-xs text-[var(--color-text-muted)]",children:"Port"},void 0,!1,void 0,this),w.jsxDEV("code",{className:"text-xs bg-[var(--color-surface-raised)] px-2 py-1 rounded text-[var(--color-text-secondary)]",children:c.port||"N/A"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"flex flex-col gap-1",children:[w.jsxDEV("div",{className:"flex items-center justify-between",children:[w.jsxDEV("span",{className:"text-xs text-[var(--color-text-muted)]",children:"API Key"},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:()=>ra(!L),className:"text-xs text-[var(--color-accent)] hover:text-[var(--color-accent-hover)]",children:L?"Hide":"Show"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("code",{className:"text-xs bg-[var(--color-surface-raised)] px-2 py-1 rounded text-[var(--color-text-secondary)] break-all",children:L?V||La:La},void 0,!1,void 0,this)]},void 0,!0,void 0,this),c.status==="running"&&c.port&&w.jsxDEV("div",{className:"flex flex-col gap-1 mt-2",children:[w.jsxDEV("span",{className:"text-xs text-[var(--color-text-muted)]",children:"Test with curl"},void 0,!1,void 0,this),w.jsxDEV("code",{className:"text-xs bg-[var(--color-surface-raised)] px-2 py-1.5 rounded text-[var(--color-text-muted)] break-all",children:['curl -H "X-API-Key: ',L?V||La:"***",'" http://localhost:',c.port,"/config"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),fa&&w.jsxDEV("div",{className:"mt-8 pt-6 border-t border-[var(--color-border-light)]",children:[w.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] mb-3",children:"Share Link"},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mb-3",children:"Anyone with this link can chat with this agent. No login required. Regenerate the API key to invalidate."},void 0,!1,void 0,this),w.jsxDEV("div",{className:"flex gap-2",children:[w.jsxDEV("code",{className:"flex-1 text-xs bg-[var(--color-surface-raised)] px-3 py-2 rounded text-[var(--color-text-secondary)] break-all border border-[var(--color-border-light)]",children:`${window.location.origin}/share/${fa}`},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:()=>{navigator.clipboard.writeText(`${window.location.origin}/share/${fa}`),va(!0),setTimeout(()=>va(!1),2000)},className:"px-3 py-2 text-xs bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] border border-[var(--color-border-light)] rounded text-[var(--color-text-secondary)] hover:text-[var(--color-text)] transition flex-shrink-0",children:T?"Copied!":"Copy"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"mt-3",children:[w.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mb-1",children:"Embed"},void 0,!1,void 0,this),w.jsxDEV("code",{className:"block text-xs bg-[var(--color-surface-raised)] px-3 py-2 rounded text-[var(--color-text-muted)] break-all border border-[var(--color-border-light)]",children:`<iframe src="${window.location.origin}/share/${fa}" width="400" height="600" style="border:none; border-radius:12px;" />`},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),w.jsxDEV("div",{className:"mt-8 pt-6 border-t border-[var(--color-border-light)]",children:[w.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] mb-3",children:"Danger Zone"},void 0,!1,void 0,this),W?w.jsxDEV("div",{className:"flex gap-2",children:[w.jsxDEV("button",{onClick:()=>A(!1),className:"flex-1 border border-[var(--color-border-light)] hover:border-[var(--color-scrollbar)] px-4 py-2 rounded font-medium transition",children:"Cancel"},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:U,className:"flex-1 bg-red-500/20 text-red-400 hover:bg-red-500/30 px-4 py-2 rounded font-medium transition",children:"Confirm Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):w.jsxDEV("button",{onClick:()=>A(!0),className:"w-full border border-red-500/30 text-red-400/70 hover:border-red-500/50 hover:text-red-400 px-4 py-2 rounded font-medium transition",children:"Delete Agent"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function lt({label:c,children:Z}){return w.jsxDEV("div",{children:[w.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:c},void 0,!1,void 0,this),Z]},void 0,!0,void 0,this)}var s9=Ga(Do(),1);var po=Ga(vo(),1);function d1({agents:c,loading:Z,selectedAgent:_,providers:U,onSelectAgent:h,onCloseAgent:y,onToggleAgent:H,onDeleteAgent:G,onUpdateAgent:N,onNewAgent:I,canCreateAgent:W=!0}){let{currentProjectId:A,currentProject:k}=vp(),x=s9.useMemo(()=>{if(A===null)return c;if(A==="unassigned")return c.filter((P)=>!P.projectId);return c.filter((P)=>P.projectId===A)},[c,A]),M=A===null?"Agents":A==="unassigned"?"Unassigned Agents":k?.name||"Agents";return po.jsxDEV("div",{className:"flex-1 flex overflow-hidden relative",children:[po.jsxDEV("div",{className:"flex-1 overflow-auto p-6",children:[po.jsxDEV("div",{className:"flex items-center justify-between mb-6",children:[po.jsxDEV("div",{className:"flex items-center gap-3",children:[k&&po.jsxDEV("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:k.color}},void 0,!1,void 0,this),po.jsxDEV("h1",{className:"text-xl font-semibold",children:M},void 0,!1,void 0,this),A!==null&&po.jsxDEV("span",{className:"text-sm text-[var(--color-text-muted)]",children:["(",x.length," agent",x.length!==1?"s":"",")"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),I&&po.jsxDEV("button",{onClick:I,disabled:!W,className:"bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 disabled:cursor-not-allowed text-black px-4 py-2 rounded font-medium transition",children:"+ New Agent"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z?po.jsxDEV(Dr,{message:"Loading agents..."},void 0,!1,void 0,this):x.length===0?po.jsxDEV(zX,{onNewAgent:I,canCreateAgent:W,hasProjectFilter:A!==null},void 0,!1,void 0,this):po.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3 auto-rows-fr",children:x.map((P)=>po.jsxDEV(K1,{agent:P,selected:_?.id===P.id,onSelect:()=>h(P),onToggle:(s)=>H(P,s),showProject:A===null},P.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_&&po.jsxDEV("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-[2px] z-10",onClick:y},void 0,!1,void 0,this),_&&po.jsxDEV("div",{className:"absolute right-0 top-0 bottom-0 w-full sm:w-[500px] lg:w-[600px] xl:w-[700px] z-20",children:po.jsxDEV(U1,{agent:_,providers:U,onClose:y,onStartAgent:(P)=>H(_,P),onUpdateAgent:(P)=>N(_.id,P),onDeleteAgent:()=>G(_.id)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function zX({onNewAgent:c,canCreateAgent:Z,hasProjectFilter:_}){return po.jsxDEV("div",{className:"text-center py-20 text-[var(--color-text-muted)]",children:[_?po.jsxDEV(po.Fragment,{children:[po.jsxDEV("p",{className:"text-lg",children:"No agents in this project"},void 0,!1,void 0,this),po.jsxDEV("p",{className:"text-sm mt-1",children:"Create an agent or assign existing agents to this project"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):po.jsxDEV(po.Fragment,{children:[po.jsxDEV("p",{className:"text-lg",children:"No agents yet"},void 0,!1,void 0,this),po.jsxDEV("p",{className:"text-sm mt-1",children:"Create your first agent to get started"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),c&&po.jsxDEV("button",{onClick:c,disabled:!Z,className:"mt-4 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 disabled:cursor-not-allowed text-black px-4 py-2 rounded font-medium transition",children:"+ New Agent"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var wo=Ga(Do(),1);var D=Ga(vo(),1);function y1({agents:c,loading:Z,runningCount:_,configuredProviders:U,onNavigate:h,onSelectAgent:y}){let{authFetch:H}=$o(),{currentProjectId:G}=vp(),{events:N,statusChangeCounter:I}=u5(),{events:W}=W1({category:"TASK"}),A=wo.useRef(null),[k,x]=wo.useState(null),[M,P]=wo.useState([]),[s,qa]=wo.useState([]),[ma,wa]=wo.useState(null),oa=wo.useMemo(()=>{if(!G)return c;if(G==="unassigned")return c.filter((O)=>!O.projectId);return c.filter((O)=>O.projectId===G)},[c,G]),e=wo.useMemo(()=>{return oa.filter((O)=>O.status==="running").length},[oa]),La=wo.useMemo(()=>{return new Set(oa.map((O)=>O.id))},[oa]),ha=wo.useCallback(async()=>{try{let O=G?`project_id=${encodeURIComponent(G)}`:"",[d,fa,C]=await Promise.all([H(`/api/dashboard${O?`?${O}`:""}`),H(`/api/tasks?status=all${O?`&${O}`:""}`),H(`/api/telemetry/events?type=thread_activity&limit=20${O?`&${O}`:""}`)]);if(d.ok){let T=await d.json();x(T)}if(fa.ok){let T=await fa.json();P(T.tasks||[])}if(C.ok){let T=await C.json();qa(T.events||[])}}catch(O){console.error("Failed to fetch dashboard data:",O)}},[H,G]);wo.useEffect(()=>{ha()},[ha,I]),wo.useEffect(()=>{if(!W.length)return;let O=W[0];if(!O||O.id===A.current)return;if(O.type==="task_created"||O.type==="task_updated"||O.type==="task_deleted")A.current=O.id,ha()},[W,ha]);let V=wo.useMemo(()=>{let O=G?M.filter((d)=>La.has(d.agentId)):M;return GX(O)},[M,G,La]),Ca=wo.useMemo(()=>{if(!G)return k?.tasks||{total:0,pending:0,running:0,completed:0};let O=V.length,d=V.filter((T)=>T.status==="pending").length,fa=V.filter((T)=>T.status==="running").length,C=V.filter((T)=>T.status==="completed").length;return{total:O,pending:d,running:fa,completed:C}},[k,G,V]),L=wo.useMemo(()=>{let O=N.filter((T)=>T.type==="thread_activity"&&!T.data?.parent_id),d=new Set(O.map((T)=>T.id)),fa=[...O];for(let T of s)if(!d.has(T.id)&&!T.data?.parent_id)fa.push(T),d.add(T.id);let C=fa;if(G)C=fa.filter((T)=>La.has(T.agent_id));return C.sort((T,va)=>new Date(va.timestamp).getTime()-new Date(T.timestamp).getTime()),C.slice(0,12)},[N,s,G,La]),ra=wo.useMemo(()=>{let O=new Map;for(let d of c)O.set(d.id,d.name);return O},[c]);return D.jsxDEV("div",{className:"flex-1 overflow-auto p-6",children:[D.jsxDEV("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 mb-6",children:[D.jsxDEV(R1,{label:"Agents",value:oa.length,subValue:`${e} running`},void 0,!1,void 0,this),D.jsxDEV(R1,{label:"Tasks",value:Ca.total,subValue:`${Ca.pending} pending`},void 0,!1,void 0,this),D.jsxDEV(R1,{label:"Completed",value:Ca.completed,color:"text-green-400"},void 0,!1,void 0,this),D.jsxDEV(R1,{label:"Providers",value:U.length,color:"text-[var(--color-accent)]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D.jsxDEV("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[D.jsxDEV(y7,{title:"Agents",actionLabel:"View All",onAction:()=>h("agents"),children:Z?D.jsxDEV("div",{className:"p-4 text-center text-[var(--color-text-muted)]",children:"Loading..."},void 0,!1,void 0,this):oa.length===0?D.jsxDEV("div",{className:"p-4 text-center text-[var(--color-text-muted)]",children:"No agents yet"},void 0,!1,void 0,this):D.jsxDEV("div",{className:"divide-y divide-[var(--color-border)]",children:oa.slice(0,5).map((O)=>D.jsxDEV($X,{agent:O,onSelect:()=>y(O),onMessage:O.status==="running"?()=>wa(O):void 0,showProject:!G},O.id,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),D.jsxDEV(y7,{title:"Activity",actionLabel:"Analytics",onAction:()=>h("analytics"),children:L.length===0?D.jsxDEV("div",{className:"p-4 text-center text-[var(--color-text-muted)]",children:[D.jsxDEV("p",{children:"No activity yet"},void 0,!1,void 0,this),D.jsxDEV("p",{className:"text-sm text-[var(--color-text-faint)] mt-1",children:"Agent activity will appear here in real-time"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):D.jsxDEV("div",{className:"divide-y divide-[var(--color-border)]",children:L.map((O)=>D.jsxDEV(YX,{activity:O.data?.activity||"Working...",agentName:ra.get(O.agent_id)||O.agent_id,timestamp:O.timestamp},O.id,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),D.jsxDEV(y7,{title:"Tasks",actionLabel:"View All",onAction:()=>h("tasks"),children:V.length===0?D.jsxDEV("div",{className:"p-4 text-center text-[var(--color-text-muted)]",children:[D.jsxDEV("p",{children:"No tasks yet"},void 0,!1,void 0,this),D.jsxDEV("p",{className:"text-sm text-[var(--color-text-faint)] mt-1",children:"Tasks will appear when agents create them"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):D.jsxDEV("div",{className:"divide-y divide-[var(--color-border)]",children:V.slice(0,5).map((O)=>D.jsxDEV("div",{className:"px-4 py-3 flex items-center justify-between",children:[D.jsxDEV("div",{className:"flex-1 min-w-0",children:[D.jsxDEV("p",{className:"font-medium truncate",children:O.title},void 0,!1,void 0,this),D.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:[O.agentName,O.recurrence&&D.jsxDEV("span",{className:"ml-1 text-[var(--color-text-faint)]",children:["· ",_X(O.recurrence)]},void 0,!0,void 0,this),O.next_run&&D.jsxDEV("span",{className:"ml-1 text-[var(--color-accent)]",children:["· ",az(O.next_run)]},void 0,!0,void 0,this),!O.next_run&&O.execute_at&&D.jsxDEV("span",{className:"ml-1 text-[var(--color-accent)]",children:["· ",az(O.execute_at)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),D.jsxDEV(XX,{status:O.status},void 0,!1,void 0,this)]},`${O.agentId}-${O.id}`,!0,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ma&&D.jsxDEV(ZX,{agent:ma,onClose:()=>wa(null)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function R1({label:c,value:Z,subValue:_,color:U}){return D.jsxDEV("div",{className:"bg-[var(--color-surface)] rounded p-4 border border-[var(--color-border)]",children:[D.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] mb-1",children:c},void 0,!1,void 0,this),D.jsxDEV("p",{className:`text-2xl font-semibold ${U||""}`,children:Z},void 0,!1,void 0,this),_&&D.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-1",children:_},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function y7({title:c,actionLabel:Z,onAction:_,children:U}){return D.jsxDEV("div",{className:"bg-[var(--color-surface)] rounded border border-[var(--color-border)] overflow-hidden",children:[D.jsxDEV("div",{className:"px-4 py-3 border-b border-[var(--color-border)] flex items-center justify-between",children:[D.jsxDEV("h3",{className:"font-semibold",children:c},void 0,!1,void 0,this),D.jsxDEV("button",{onClick:_,className:"text-sm text-[#3b82f6] hover:text-[#60a5fa]",children:Z},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U]},void 0,!0,void 0,this)}function $X({agent:c,onSelect:Z,onMessage:_,showProject:U}){let{isActive:h,label:y}=B1(c.id),{projects:H}=vp(),G=c.projectId?H.find((N)=>N.id===c.projectId):null;return D.jsxDEV("div",{onClick:Z,className:"px-4 py-3 hover:bg-[var(--color-surface-raised)] cursor-pointer flex items-center justify-between group",children:[D.jsxDEV("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[D.jsxDEV("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${c.status==="running"?h?"bg-green-400 animate-pulse":"bg-[#3b82f6]":"bg-[var(--color-scrollbar)]"}`},void 0,!1,void 0,this),D.jsxDEV("div",{className:"flex-1 min-w-0",children:[D.jsxDEV("p",{className:"font-medium truncate",children:c.name},void 0,!1,void 0,this),D.jsxDEV("div",{className:"flex items-center gap-2 text-sm text-[var(--color-text-muted)]",children:[h&&y?D.jsxDEV("span",{className:"text-green-400 truncate",children:y},void 0,!1,void 0,this):D.jsxDEV("span",{children:[c.provider," · ",c.status==="running"?"idle":"stopped"]},void 0,!0,void 0,this),U&&G&&D.jsxDEV(D.Fragment,{children:[D.jsxDEV("span",{className:"text-[var(--color-text-faint)]",children:"·"},void 0,!1,void 0,this),D.jsxDEV("span",{className:"flex items-center gap-1",children:[D.jsxDEV("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:G.color}},void 0,!1,void 0,this),G.name]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),_&&D.jsxDEV("button",{onClick:(N)=>{N.stopPropagation(),_()},className:"opacity-0 group-hover:opacity-100 transition px-2 py-1 text-xs text-[var(--color-accent)] hover:bg-[var(--color-accent-10)] rounded",title:"Send message",children:D.jsxDEV("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:D.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function JX(c){let Z=Math.floor((Date.now()-new Date(c).getTime())/1000);if(Z<5)return"just now";if(Z<60)return`${Z}s ago`;let _=Math.floor(Z/60);if(_<60)return`${_}m ago`;let U=Math.floor(_/60);if(U<24)return`${U}h ago`;return`${Math.floor(U/24)}d ago`}function YX({activity:c,agentName:Z,timestamp:_}){return D.jsxDEV("div",{className:"px-4 py-3",children:[D.jsxDEV("p",{className:"text-sm truncate",children:c},void 0,!1,void 0,this),D.jsxDEV("div",{className:"flex items-center gap-2 text-xs text-[var(--color-text-faint)] mt-1",children:[D.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:Z},void 0,!1,void 0,this),D.jsxDEV("span",{className:"text-[var(--color-text-faint)]",children:"·"},void 0,!1,void 0,this),D.jsxDEV("span",{children:JX(_)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function XX({status:c}){let Z={pending:"bg-yellow-500/20 text-yellow-400",running:"bg-blue-500/20 text-blue-400",completed:"bg-green-500/20 text-green-400",failed:"bg-red-500/20 text-red-400",cancelled:"bg-gray-500/20 text-gray-400"};return D.jsxDEV("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${Z[c]||Z.pending}`,children:c},void 0,!1,void 0,this)}function ZX({agent:c,onClose:Z}){let{authFetch:_}=$o(),[U,h]=wo.useState(""),[y,H]=wo.useState(!1),[G,N]=wo.useState(!1),I=wo.useRef(null);wo.useEffect(()=>{I.current?.focus()},[]);let W=async()=>{if(!U.trim()||y)return;H(!0);try{if((await _(`/api/agents/${c.id}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:U.trim(),agent_id:c.id})})).ok)N(!0),setTimeout(Z,1200)}catch{}finally{H(!1)}};return D.jsxDEV("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[D.jsxDEV("div",{className:"absolute inset-0 bg-black/60",onClick:Z},void 0,!1,void 0,this),D.jsxDEV("div",{className:"relative bg-[var(--color-surface)] border border-[var(--color-border-light)] rounded-xl shadow-2xl w-full max-w-md mx-4 p-5",children:[D.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[D.jsxDEV("div",{className:"flex items-center gap-3",children:[D.jsxDEV("span",{className:"w-2.5 h-2.5 rounded-full bg-green-400 animate-pulse"},void 0,!1,void 0,this),D.jsxDEV("h3",{className:"font-medium",children:c.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D.jsxDEV("button",{onClick:Z,className:"text-[var(--color-text-muted)] hover:text-[var(--color-text)] transition",children:D.jsxDEV(it,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G?D.jsxDEV("div",{className:"py-6 text-center",children:[D.jsxDEV("p",{className:"text-green-400 font-medium",children:"Message sent"},void 0,!1,void 0,this),D.jsxDEV("p",{className:"text-sm text-[var(--color-text-faint)] mt-1",children:"The agent will process your message"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):D.jsxDEV("div",{className:"flex gap-2",children:[D.jsxDEV("input",{ref:I,type:"text",value:U,onChange:(A)=>h(A.target.value),onKeyDown:(A)=>A.key==="Enter"&&W(),placeholder:`Message ${c.name}...`,disabled:y,className:"flex-1 bg-[var(--color-bg)] border border-[var(--color-border-light)] btn px-3 py-2.5 text-sm focus:outline-none focus:border-[var(--color-accent)] placeholder-[#444] disabled:opacity-50"},void 0,!1,void 0,this),D.jsxDEV("button",{onClick:W,disabled:y||!U.trim(),className:"px-4 py-2.5 bg-[var(--color-accent)] text-black btn text-sm font-medium hover:bg-[var(--color-accent-hover)] transition disabled:opacity-30",children:y?"...":"Send"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function e9(c){if(c.status==="running")return 0;if(c.status==="pending")return 1;if(c.status==="completed")return 2;if(c.status==="failed")return 3;return 4}function GX(c){return[...c].sort((Z,_)=>{let U=e9(Z),h=e9(_);if(U!==h)return U-h;if(U<=1){let G=Z.next_run||Z.execute_at||null,N=_.next_run||_.execute_at||null,I=G?new Date(G).getTime():1/0,W=N?new Date(N).getTime():1/0;return I-W}let y=Z.completed_at||Z.executed_at||Z.created_at,H=_.completed_at||_.executed_at||_.created_at;return new Date(H).getTime()-new Date(y).getTime()})}var oz=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function _X(c){try{let Z=c.trim().split(/\s+/);if(Z.length!==5)return c;let[_,U,h,y,H]=Z;if(_.startsWith("*/")&&U==="*"&&h==="*"&&y==="*"&&H==="*"){let N=parseInt(_.slice(2));return N===1?"Every min":`Every ${N}min`}if(_!=="*"&&!_.includes("/")&&U==="*"&&h==="*"&&y==="*"&&H==="*")return"Hourly";if(U.startsWith("*/")&&h==="*"&&y==="*"&&H==="*"){let N=parseInt(U.slice(2));return N===1?"Hourly":`Every ${N}h`}let G=(N,I)=>{let W=parseInt(N),A=parseInt(I);if(isNaN(W))return"";let k=W>=12?"PM":"AM";return`${W===0?12:W>12?W-12:W}:${A.toString().padStart(2,"0")} ${k}`};if(U!=="*"&&!U.includes("/")&&h==="*"&&y==="*"){let N=G(U,_);if(H==="*")return`Daily ${N}`;let I=H.split(",").map((W)=>oz[parseInt(W.trim())]||W);if(I.length===1)return`${I[0]} ${N}`;return`${I.join(" & ")} ${N}`}return c}catch{return c}}function az(c){let Z=new Date(c),_=new Date,U=Z.getTime()-_.getTime(),h=U>0,y=Math.abs(U),H=Math.floor(y/60000),G=Math.floor(y/3600000),N=Z.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),I=Z.toDateString()===_.toDateString(),W=new Date(_);W.setDate(W.getDate()+1);let A=Z.toDateString()===W.toDateString();if(I){if(H<1)return"now";if(H<60)return h?`in ${H}m`:`${H}m ago`;return h?`in ${G}h`:`${G}h ago`}if(A)return`Tomorrow ${N}`;return`${oz[Z.getDay()]} ${N}`}var Za=Ga(vo(),1),BX=ua.lazy(()=>import("./SettingsPage.88nj3hbv.js").then((c)=>({default:c.SettingsPage}))),KX=ua.lazy(()=>import("./TasksPage.6b3y4b1n.js").then((c)=>({default:c.TasksPage}))),HX=ua.lazy(()=>import("./McpPage.3800a82c.js").then((c)=>({default:c.McpPage}))),WX=ua.lazy(()=>import("./SkillsPage.b8pxj5mb.js").then((c)=>({default:c.SkillsPage}))),UX=ua.lazy(()=>import("./TestsPage.dpevv5xb.js").then((c)=>({default:c.TestsPage}))),dX=ua.lazy(()=>import("./ThreadsPage.1h15363y.js").then((c)=>({default:c.ThreadsPage}))),RX=ua.lazy(()=>import("./TelemetryPage.7q4d69wj.js").then((c)=>({default:c.TelemetryPage}))),yX=ua.lazy(()=>import("./ConnectionsPage.8b2v07qp.js").then((c)=>({default:c.ConnectionsPage}))),LX=ua.lazy(()=>import("./ActivityPage.k33hj12v.js").then((c)=>({default:c.ActivityPage}))),OX=ua.lazy(()=>import("./ApiDocsPage.q37747gr.js").then((c)=>({default:c.ApiDocsPage})));function hX(){let{isAuthenticated:c,isLoading:Z,hasUsers:_,accessToken:U,checkAuth:h}=$o(),{currentProjectId:y,refreshProjects:H}=vp(),G=$1(),N=mz(),{isComplete:I,setIsComplete:W}=K7(),A=()=>{return U?{Authorization:`Bearer ${U}`}:{}},k=c&&I===!0,{agents:x,loading:M,runningCount:P,fetchAgents:s,createAgent:qa,updateAgent:ma,deleteAgent:wa,toggleAgent:oa}=Q7(k,y),{providers:e,configuredProviders:La,fetchProviders:ha}=B7(k),V=La.filter((F)=>F.type==="llm"),Ca=ua.useMemo(()=>{if(y===null)return x.length;if(y==="unassigned")return x.filter((F)=>!F.projectId).length;return x.filter((F)=>F.projectId===y).length},[x,y]),[L,ra]=ua.useState(!1),[O,d]=ua.useState(null),[fa,C]=ua.useState("dashboard"),[T,va]=ua.useState(null),[Pa,xa]=ua.useState(0),[So,$p]=ua.useState(!1);ua.useEffect(()=>{if(!k)return;(async()=>{try{let B="/api/tasks?status=pending";if(y!==null)B+=`&project_id=${encodeURIComponent(y)}`;let u=await fetch(B,{headers:A()});if(u.ok){let ka=await u.json();xa(ka.count??(ka.tasks||[]).length)}}catch{}})()},[k,U,y,G,N]);let[S,_a]=ua.useState({name:"",model:"",provider:"",systemPrompt:"You are a helpful assistant.",features:{...q7},mcpServers:[],skills:[]});ua.useEffect(()=>{if(V.length>0&&!S.provider){let F=V[0],B=F.models.find((u)=>u.recommended)?.value||F.models[0]?.value||"";_a((u)=>({...u,provider:F.id,model:B}))}},[V,S.provider]),ua.useEffect(()=>{if(O){let F=x.find((B)=>B.id===O.id);if(F)d(F);else d(null)}},[x,O]);let sa=(F)=>{let B=e.find((ka)=>ka.id===F),u=B?.models.find((ka)=>ka.recommended)?.value||B?.models[0]?.value||"";_a((ka)=>({...ka,provider:F,model:u}))},pr=async()=>{if(!S.name)return;await qa(S),await H();let F=V[0],B=F?.models.find((u)=>u.recommended)?.value||F?.models[0]?.value||"";_a({name:"",model:B,provider:F?.id||"",systemPrompt:"You are a helpful assistant.",features:{...q7},mcpServers:[],skills:[]}),ra(!1)},jr=async(F,B)=>{B?.stopPropagation(),va(null);let u=await oa(F);if(u.error)va(u.error)},Er=async(F,B)=>{if(B?.stopPropagation(),O?.id===F)d(null);await wa(F),await H()},mr=(F)=>{d(F),va(null),C("agents")},vm=(F)=>{C(F),d(null)},sr=()=>{W(!0),ha(),h()};if(Z||_===null)return Za.jsxDEV(Dr,{fullScreen:!0},void 0,!1,void 0,this);if(!_)return Za.jsxDEV(D5,{onComplete:sr,needsAccount:!0},void 0,!1,void 0,this);if(!c)return Za.jsxDEV(_1,{},void 0,!1,void 0,this);if(I===null)return Za.jsxDEV(Dr,{fullScreen:!0},void 0,!1,void 0,this);if(!I)return Za.jsxDEV(D5,{onComplete:sr,needsAccount:!1},void 0,!1,void 0,this);return Za.jsxDEV("div",{className:"h-screen flex flex-col overflow-hidden",style:{backgroundColor:"var(--color-bg)",color:"var(--color-text)"},children:[Za.jsxDEV(J1,{onMenuClick:()=>$p(!0),agents:x},void 0,!1,void 0,this),T&&Za.jsxDEV(G1,{message:T,onDismiss:()=>va(null)},void 0,!1,void 0,this),Za.jsxDEV("div",{className:"flex flex-1 overflow-hidden",children:[Za.jsxDEV(Z1,{route:fa,agentCount:Ca,taskCount:Pa,onNavigate:vm,isOpen:So,onClose:()=>$p(!1)},void 0,!1,void 0,this),Za.jsxDEV("main",{className:"flex-1 overflow-hidden flex",children:Za.jsxDEV(ua.Suspense,{fallback:Za.jsxDEV(Dr,{},void 0,!1,void 0,this),children:[fa==="settings"&&Za.jsxDEV(BX,{},void 0,!1,void 0,this),fa==="agents"&&Za.jsxDEV(d1,{agents:x,loading:M,selectedAgent:O,providers:e,onSelectAgent:mr,onCloseAgent:()=>d(null),onToggleAgent:jr,onDeleteAgent:Er,onUpdateAgent:ma,onNewAgent:()=>ra(!0),canCreateAgent:V.length>0},void 0,!1,void 0,this),fa==="dashboard"&&Za.jsxDEV(y1,{agents:x,loading:M,runningCount:P,configuredProviders:La,onNavigate:vm,onSelectAgent:mr},void 0,!1,void 0,this),fa==="threads"&&Za.jsxDEV(dX,{agents:x,onNavigate:C},void 0,!1,void 0,this),fa==="activity"&&Za.jsxDEV(LX,{agents:x,loading:M,onNavigate:vm},void 0,!1,void 0,this),fa==="tasks"&&Za.jsxDEV(KX,{},void 0,!1,void 0,this),fa==="connections"&&Za.jsxDEV(yX,{},void 0,!1,void 0,this),fa==="mcp"&&Za.jsxDEV(HX,{},void 0,!1,void 0,this),fa==="skills"&&Za.jsxDEV(WX,{},void 0,!1,void 0,this),fa==="tests"&&Za.jsxDEV(UX,{},void 0,!1,void 0,this),fa==="analytics"&&Za.jsxDEV(RX,{},void 0,!1,void 0,this),fa==="api"&&Za.jsxDEV(OX,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),L&&Za.jsxDEV(H1,{form:S,providers:e,configuredProviders:La,onFormChange:_a,onProviderChange:sa,onCreate:pr,onClose:()=>ra(!1),onGoToSettings:()=>{ra(!1),C("settings")}},void 0,!1,void 0,this),Za.jsxDEV(h9,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function kX({token:c}){let{theme:Z}=xr(),[_,U]=ua.useState("checking"),[h,y]=ua.useState("Agent");if(ua.useEffect(()=>{let H=async()=>{try{let N=await fetch(`/share/${c}/info`);if(N.ok){let I=await N.json();y(I.name||"Agent"),U(I.status==="running"?"online":"offline")}else U("offline")}catch{U("offline")}};H();let G=setInterval(H,15000);return()=>clearInterval(G)},[c]),_==="checking")return Za.jsxDEV("div",{className:"min-h-[100dvh] flex items-center justify-center",style:{backgroundColor:"var(--color-bg)"},children:Za.jsxDEV("div",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"Connecting..."},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(_==="offline")return Za.jsxDEV("div",{className:"min-h-[100dvh] flex items-center justify-center",style:{backgroundColor:"var(--color-bg)"},children:Za.jsxDEV("div",{className:"text-center",children:[Za.jsxDEV("div",{className:"w-2.5 h-2.5 rounded-full mx-auto mb-3",style:{backgroundColor:"var(--color-text-muted)"}},void 0,!1,void 0,this),Za.jsxDEV("div",{className:"text-base font-semibold mb-1.5",style:{color:"var(--color-text)"},children:h},void 0,!1,void 0,this),Za.jsxDEV("div",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"This agent is currently offline"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);return Za.jsxDEV("div",{className:"min-h-[100dvh] flex items-center justify-center p-0 md:p-4",style:{backgroundColor:"var(--color-bg)"},children:Za.jsxDEV("div",{className:"w-full max-w-[640px] h-[100dvh] md:h-[calc(100dvh-32px)] md:max-h-[800px] md:rounded-xl overflow-hidden md:border flex flex-col",style:{backgroundColor:"var(--color-bg)",borderColor:"var(--color-border)"},children:Za.jsxDEV(ur,{agentId:"default",apiUrl:`/share/${c}`,placeholder:"Type a message...",variant:"terminal",theme:Z.id,headerTitle:h,enableMarkdown:!0,enableWidgets:!0,availableWidgets:["form","kpi"]},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function NX(){let c=window.location.pathname.match(/^\/share\/([a-f0-9]{32})$/);if(c)return Za.jsxDEV(L7,{children:Za.jsxDEV(kX,{token:c[1]},void 0,!1,void 0,this)},void 0,!1,void 0,this);return Za.jsxDEV(L7,{children:Za.jsxDEV(tz,{children:Za.jsxDEV(rz,{children:Za.jsxDEV(L9,{children:Za.jsxDEV(pz,{children:Za.jsxDEV(hX,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}var MX=vz.createRoot(document.getElementById("root"));MX.render(Za.jsxDEV(NX,{},void 0,!1,void 0,this));
220
220
 
221
221
  //# debugId=3EFF65642A30579464756E2164756E21