nestor-sh 3.2.1 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +1 -1
  2. package/dist/nestor.mjs +254234 -104522
  3. package/dist/prompts/BOOTSTRAP.md +37 -0
  4. package/dist/prompts/ROLE_SWITCH.md +23 -0
  5. package/dist/prompts/SHARED_SOUL.md +37 -0
  6. package/dist/prompts/USER.md +20 -0
  7. package/dist/prompts/agents/ATLAS.md +40 -0
  8. package/dist/prompts/agents/FORGE.md +40 -0
  9. package/dist/prompts/agents/NEXUS.md +42 -0
  10. package/dist/prompts/agents/SENTINEL.md +40 -0
  11. package/dist/prompts/agents/SHADOW.md +41 -0
  12. package/dist/prompts/heartbeat/DEFAULT.md +12 -0
  13. package/dist/prompts/heartbeat/NEXUS_HEARTBEAT.md +33 -0
  14. package/dist/studio/assets/index-B5zLCypy.js +607 -0
  15. package/dist/studio/assets/index-BL3Mp7Cu.css +1 -0
  16. package/dist/studio/index.html +2 -2
  17. package/package.json +15 -10
  18. package/dist/studio/assets/index-0-6dEh2X.js +0 -597
  19. package/dist/studio/assets/index-B6rRdi4P.js +0 -594
  20. package/dist/studio/assets/index-BCVaIJnX.js +0 -596
  21. package/dist/studio/assets/index-BFlEVRQQ.js +0 -596
  22. package/dist/studio/assets/index-BYMzxJZS.css +0 -1
  23. package/dist/studio/assets/index-BbuSTZoY.js +0 -596
  24. package/dist/studio/assets/index-BetEyTVL.js +0 -597
  25. package/dist/studio/assets/index-BngOpby7.css +0 -1
  26. package/dist/studio/assets/index-CGns5m54.css +0 -1
  27. package/dist/studio/assets/index-CTXjJlEy.js +0 -597
  28. package/dist/studio/assets/index-CY_pWEqy.js +0 -594
  29. package/dist/studio/assets/index-CgYCHAo_.js +0 -596
  30. package/dist/studio/assets/index-Ch3VZ_6a.css +0 -1
  31. package/dist/studio/assets/index-CqlwLAqD.js +0 -596
  32. package/dist/studio/assets/index-CsqKxaaM.js +0 -592
  33. package/dist/studio/assets/index-Cw42VG9E.js +0 -596
  34. package/dist/studio/assets/index-DByWC64z.css +0 -1
  35. package/dist/studio/assets/index-DC96fYgh.css +0 -1
  36. package/dist/studio/assets/index-DyMdwDBt.css +0 -1
  37. package/dist/studio/assets/index-uxcAlR2S.js +0 -596
@@ -0,0 +1,607 @@
1
+ var bb=Object.defineProperty;var yb=(n,i,d)=>i in n?bb(n,i,{enumerable:!0,configurable:!0,writable:!0,value:d}):n[i]=d;var Ad=(n,i,d)=>yb(n,typeof i!="symbol"?i+"":i,d);(function(){const i=document.createElement("link").relList;if(i&&i.supports&&i.supports("modulepreload"))return;for(const m of document.querySelectorAll('link[rel="modulepreload"]'))c(m);new MutationObserver(m=>{for(const f of m)if(f.type==="childList")for(const h of f.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&c(h)}).observe(document,{childList:!0,subtree:!0});function d(m){const f={};return m.integrity&&(f.integrity=m.integrity),m.referrerPolicy&&(f.referrerPolicy=m.referrerPolicy),m.crossOrigin==="use-credentials"?f.credentials="include":m.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function c(m){if(m.ep)return;m.ep=!0;const f=d(m);fetch(m.href,f)}})();var Ed={exports:{}},si={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var vh;function vb(){if(vh)return si;vh=1;var n=Symbol.for("react.transitional.element"),i=Symbol.for("react.fragment");function d(c,m,f){var h=null;if(f!==void 0&&(h=""+f),m.key!==void 0&&(h=""+m.key),"key"in m){f={};for(var b in m)b!=="key"&&(f[b]=m[b])}else f=m;return m=f.ref,{$$typeof:n,type:c,key:h,ref:m!==void 0?m:null,props:f}}return si.Fragment=i,si.jsx=d,si.jsxs=d,si}var jh;function jb(){return jh||(jh=1,Ed.exports=vb()),Ed.exports}var e=jb(),Td={exports:{}},Ne={};/**
10
+ * @license React
11
+ * react.production.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var Nh;function Nb(){if(Nh)return Ne;Nh=1;var n=Symbol.for("react.transitional.element"),i=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),c=Symbol.for("react.strict_mode"),m=Symbol.for("react.profiler"),f=Symbol.for("react.consumer"),h=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),v=Symbol.iterator;function k(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,N={};function z(T,P,de){this.props=T,this.context=P,this.refs=N,this.updater=de||C}z.prototype.isReactComponent={},z.prototype.setState=function(T,P){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,P,"setState")},z.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function R(){}R.prototype=z.prototype;function D(T,P,de){this.props=T,this.context=P,this.refs=N,this.updater=de||C}var O=D.prototype=new R;O.constructor=D,w(O,z.prototype),O.isPureReactComponent=!0;var se=Array.isArray;function Z(){}var U={H:null,A:null,T:null,S:null},A=Object.prototype.hasOwnProperty;function F(T,P,de){var G=de.ref;return{$$typeof:n,type:T,key:P,ref:G!==void 0?G:null,props:de}}function $(T,P){return F(T.type,P,T.props)}function Q(T){return typeof T=="object"&&T!==null&&T.$$typeof===n}function ce(T){var P={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(de){return P[de]})}var I=/\/+/g;function le(T,P){return typeof T=="object"&&T!==null&&T.key!=null?ce(""+T.key):P.toString(36)}function Y(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(Z,Z):(T.status="pending",T.then(function(P){T.status==="pending"&&(T.status="fulfilled",T.value=P)},function(P){T.status==="pending"&&(T.status="rejected",T.reason=P)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function B(T,P,de,G,oe){var fe=typeof T;(fe==="undefined"||fe==="boolean")&&(T=null);var be=!1;if(T===null)be=!0;else switch(fe){case"bigint":case"string":case"number":be=!0;break;case"object":switch(T.$$typeof){case n:case i:be=!0;break;case S:return be=T._init,B(be(T._payload),P,de,G,oe)}}if(be)return oe=oe(T),be=G===""?"."+le(T,0):G,se(oe)?(de="",be!=null&&(de=be.replace(I,"$&/")+"/"),B(oe,P,de,"",function(tt){return tt})):oe!=null&&(Q(oe)&&(oe=$(oe,de+(oe.key==null||T&&T.key===oe.key?"":(""+oe.key).replace(I,"$&/")+"/")+be)),P.push(oe)),1;be=0;var Ce=G===""?".":G+":";if(se(T))for(var ve=0;ve<T.length;ve++)G=T[ve],fe=Ce+le(G,ve),be+=B(G,P,de,fe,oe);else if(ve=k(T),typeof ve=="function")for(T=ve.call(T),ve=0;!(G=T.next()).done;)G=G.value,fe=Ce+le(G,ve++),be+=B(G,P,de,fe,oe);else if(fe==="object"){if(typeof T.then=="function")return B(Y(T),P,de,G,oe);throw P=String(T),Error("Objects are not valid as a React child (found: "+(P==="[object Object]"?"object with keys {"+Object.keys(T).join(", ")+"}":P)+"). If you meant to render a collection of children, use an array instead.")}return be}function ne(T,P,de){if(T==null)return T;var G=[],oe=0;return B(T,G,"","",function(fe){return P.call(de,fe,oe++)}),G}function me(T){if(T._status===-1){var P=T._result;P=P(),P.then(function(de){(T._status===0||T._status===-1)&&(T._status=1,T._result=de)},function(de){(T._status===0||T._status===-1)&&(T._status=2,T._result=de)}),T._status===-1&&(T._status=0,T._result=P)}if(T._status===1)return T._result.default;throw T._result}var ue=typeof reportError=="function"?reportError:function(T){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var P=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof T=="object"&&T!==null&&typeof T.message=="string"?String(T.message):String(T),error:T});if(!window.dispatchEvent(P))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",T);return}console.error(T)},je={map:ne,forEach:function(T,P,de){ne(T,function(){P.apply(this,arguments)},de)},count:function(T){var P=0;return ne(T,function(){P++}),P},toArray:function(T){return ne(T,function(P){return P})||[]},only:function(T){if(!Q(T))throw Error("React.Children.only expected to receive a single React element child.");return T}};return Ne.Activity=y,Ne.Children=je,Ne.Component=z,Ne.Fragment=d,Ne.Profiler=m,Ne.PureComponent=D,Ne.StrictMode=c,Ne.Suspense=g,Ne.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=U,Ne.__COMPILER_RUNTIME={__proto__:null,c:function(T){return U.H.useMemoCache(T)}},Ne.cache=function(T){return function(){return T.apply(null,arguments)}},Ne.cacheSignal=function(){return null},Ne.cloneElement=function(T,P,de){if(T==null)throw Error("The argument must be a React element, but you passed "+T+".");var G=w({},T.props),oe=T.key;if(P!=null)for(fe in P.key!==void 0&&(oe=""+P.key),P)!A.call(P,fe)||fe==="key"||fe==="__self"||fe==="__source"||fe==="ref"&&P.ref===void 0||(G[fe]=P[fe]);var fe=arguments.length-2;if(fe===1)G.children=de;else if(1<fe){for(var be=Array(fe),Ce=0;Ce<fe;Ce++)be[Ce]=arguments[Ce+2];G.children=be}return F(T.type,oe,G)},Ne.createContext=function(T){return T={$$typeof:h,_currentValue:T,_currentValue2:T,_threadCount:0,Provider:null,Consumer:null},T.Provider=T,T.Consumer={$$typeof:f,_context:T},T},Ne.createElement=function(T,P,de){var G,oe={},fe=null;if(P!=null)for(G in P.key!==void 0&&(fe=""+P.key),P)A.call(P,G)&&G!=="key"&&G!=="__self"&&G!=="__source"&&(oe[G]=P[G]);var be=arguments.length-2;if(be===1)oe.children=de;else if(1<be){for(var Ce=Array(be),ve=0;ve<be;ve++)Ce[ve]=arguments[ve+2];oe.children=Ce}if(T&&T.defaultProps)for(G in be=T.defaultProps,be)oe[G]===void 0&&(oe[G]=be[G]);return F(T,fe,oe)},Ne.createRef=function(){return{current:null}},Ne.forwardRef=function(T){return{$$typeof:b,render:T}},Ne.isValidElement=Q,Ne.lazy=function(T){return{$$typeof:S,_payload:{_status:-1,_result:T},_init:me}},Ne.memo=function(T,P){return{$$typeof:p,type:T,compare:P===void 0?null:P}},Ne.startTransition=function(T){var P=U.T,de={};U.T=de;try{var G=T(),oe=U.S;oe!==null&&oe(de,G),typeof G=="object"&&G!==null&&typeof G.then=="function"&&G.then(Z,ue)}catch(fe){ue(fe)}finally{P!==null&&de.types!==null&&(P.types=de.types),U.T=P}},Ne.unstable_useCacheRefresh=function(){return U.H.useCacheRefresh()},Ne.use=function(T){return U.H.use(T)},Ne.useActionState=function(T,P,de){return U.H.useActionState(T,P,de)},Ne.useCallback=function(T,P){return U.H.useCallback(T,P)},Ne.useContext=function(T){return U.H.useContext(T)},Ne.useDebugValue=function(){},Ne.useDeferredValue=function(T,P){return U.H.useDeferredValue(T,P)},Ne.useEffect=function(T,P){return U.H.useEffect(T,P)},Ne.useEffectEvent=function(T){return U.H.useEffectEvent(T)},Ne.useId=function(){return U.H.useId()},Ne.useImperativeHandle=function(T,P,de){return U.H.useImperativeHandle(T,P,de)},Ne.useInsertionEffect=function(T,P){return U.H.useInsertionEffect(T,P)},Ne.useLayoutEffect=function(T,P){return U.H.useLayoutEffect(T,P)},Ne.useMemo=function(T,P){return U.H.useMemo(T,P)},Ne.useOptimistic=function(T,P){return U.H.useOptimistic(T,P)},Ne.useReducer=function(T,P,de){return U.H.useReducer(T,P,de)},Ne.useRef=function(T){return U.H.useRef(T)},Ne.useState=function(T){return U.H.useState(T)},Ne.useSyncExternalStore=function(T,P,de){return U.H.useSyncExternalStore(T,P,de)},Ne.useTransition=function(){return U.H.useTransition()},Ne.version="19.2.4",Ne}var wh;function au(){return wh||(wh=1,Td.exports=Nb()),Td.exports}var u=au(),Rd={exports:{}},ai={},Md={exports:{}},Dd={};/**
18
+ * @license React
19
+ * scheduler.production.js
20
+ *
21
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */var Sh;function wb(){return Sh||(Sh=1,(function(n){function i(B,ne){var me=B.length;B.push(ne);e:for(;0<me;){var ue=me-1>>>1,je=B[ue];if(0<m(je,ne))B[ue]=ne,B[me]=je,me=ue;else break e}}function d(B){return B.length===0?null:B[0]}function c(B){if(B.length===0)return null;var ne=B[0],me=B.pop();if(me!==ne){B[0]=me;e:for(var ue=0,je=B.length,T=je>>>1;ue<T;){var P=2*(ue+1)-1,de=B[P],G=P+1,oe=B[G];if(0>m(de,me))G<je&&0>m(oe,de)?(B[ue]=oe,B[G]=me,ue=G):(B[ue]=de,B[P]=me,ue=P);else if(G<je&&0>m(oe,me))B[ue]=oe,B[G]=me,ue=G;else break e}}return ne}function m(B,ne){var me=B.sortIndex-ne.sortIndex;return me!==0?me:B.id-ne.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var f=performance;n.unstable_now=function(){return f.now()}}else{var h=Date,b=h.now();n.unstable_now=function(){return h.now()-b}}var g=[],p=[],S=1,y=null,v=3,k=!1,C=!1,w=!1,N=!1,z=typeof setTimeout=="function"?setTimeout:null,R=typeof clearTimeout=="function"?clearTimeout:null,D=typeof setImmediate<"u"?setImmediate:null;function O(B){for(var ne=d(p);ne!==null;){if(ne.callback===null)c(p);else if(ne.startTime<=B)c(p),ne.sortIndex=ne.expirationTime,i(g,ne);else break;ne=d(p)}}function se(B){if(w=!1,O(B),!C)if(d(g)!==null)C=!0,Z||(Z=!0,ce());else{var ne=d(p);ne!==null&&Y(se,ne.startTime-B)}}var Z=!1,U=-1,A=5,F=-1;function $(){return N?!0:!(n.unstable_now()-F<A)}function Q(){if(N=!1,Z){var B=n.unstable_now();F=B;var ne=!0;try{e:{C=!1,w&&(w=!1,R(U),U=-1),k=!0;var me=v;try{t:{for(O(B),y=d(g);y!==null&&!(y.expirationTime>B&&$());){var ue=y.callback;if(typeof ue=="function"){y.callback=null,v=y.priorityLevel;var je=ue(y.expirationTime<=B);if(B=n.unstable_now(),typeof je=="function"){y.callback=je,O(B),ne=!0;break t}y===d(g)&&c(g),O(B)}else c(g);y=d(g)}if(y!==null)ne=!0;else{var T=d(p);T!==null&&Y(se,T.startTime-B),ne=!1}}break e}finally{y=null,v=me,k=!1}ne=void 0}}finally{ne?ce():Z=!1}}}var ce;if(typeof D=="function")ce=function(){D(Q)};else if(typeof MessageChannel<"u"){var I=new MessageChannel,le=I.port2;I.port1.onmessage=Q,ce=function(){le.postMessage(null)}}else ce=function(){z(Q,0)};function Y(B,ne){U=z(function(){B(n.unstable_now())},ne)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(B){B.callback=null},n.unstable_forceFrameRate=function(B){0>B||125<B?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):A=0<B?Math.floor(1e3/B):5},n.unstable_getCurrentPriorityLevel=function(){return v},n.unstable_next=function(B){switch(v){case 1:case 2:case 3:var ne=3;break;default:ne=v}var me=v;v=ne;try{return B()}finally{v=me}},n.unstable_requestPaint=function(){N=!0},n.unstable_runWithPriority=function(B,ne){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var me=v;v=B;try{return ne()}finally{v=me}},n.unstable_scheduleCallback=function(B,ne,me){var ue=n.unstable_now();switch(typeof me=="object"&&me!==null?(me=me.delay,me=typeof me=="number"&&0<me?ue+me:ue):me=ue,B){case 1:var je=-1;break;case 2:je=250;break;case 5:je=1073741823;break;case 4:je=1e4;break;default:je=5e3}return je=me+je,B={id:S++,callback:ne,priorityLevel:B,startTime:me,expirationTime:je,sortIndex:-1},me>ue?(B.sortIndex=me,i(p,B),d(g)===null&&B===d(p)&&(w?(R(U),U=-1):w=!0,Y(se,me-ue))):(B.sortIndex=je,i(g,B),C||k||(C=!0,Z||(Z=!0,ce()))),B},n.unstable_shouldYield=$,n.unstable_wrapCallback=function(B){var ne=v;return function(){var me=v;v=ne;try{return B.apply(this,arguments)}finally{v=me}}}})(Dd)),Dd}var kh;function Sb(){return kh||(kh=1,Md.exports=wb()),Md.exports}var Od={exports:{}},Et={};/**
26
+ * @license React
27
+ * react-dom.production.js
28
+ *
29
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */var zh;function kb(){if(zh)return Et;zh=1;var n=au();function i(g){var p="https://react.dev/errors/"+g;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var S=2;S<arguments.length;S++)p+="&args[]="+encodeURIComponent(arguments[S])}return"Minified React error #"+g+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function d(){}var c={d:{f:d,r:function(){throw Error(i(522))},D:d,C:d,L:d,m:d,X:d,S:d,M:d},p:0,findDOMNode:null},m=Symbol.for("react.portal");function f(g,p,S){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:m,key:y==null?null:""+y,children:g,containerInfo:p,implementation:S}}var h=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function b(g,p){if(g==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return Et.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=c,Et.createPortal=function(g,p){var S=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)throw Error(i(299));return f(g,p,null,S)},Et.flushSync=function(g){var p=h.T,S=c.p;try{if(h.T=null,c.p=2,g)return g()}finally{h.T=p,c.p=S,c.d.f()}},Et.preconnect=function(g,p){typeof g=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,c.d.C(g,p))},Et.prefetchDNS=function(g){typeof g=="string"&&c.d.D(g)},Et.preinit=function(g,p){if(typeof g=="string"&&p&&typeof p.as=="string"){var S=p.as,y=b(S,p.crossOrigin),v=typeof p.integrity=="string"?p.integrity:void 0,k=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;S==="style"?c.d.S(g,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:y,integrity:v,fetchPriority:k}):S==="script"&&c.d.X(g,{crossOrigin:y,integrity:v,fetchPriority:k,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},Et.preinitModule=function(g,p){if(typeof g=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var S=b(p.as,p.crossOrigin);c.d.M(g,{crossOrigin:S,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0})}}else p==null&&c.d.M(g)},Et.preload=function(g,p){if(typeof g=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var S=p.as,y=b(S,p.crossOrigin);c.d.L(g,S,{crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0,type:typeof p.type=="string"?p.type:void 0,fetchPriority:typeof p.fetchPriority=="string"?p.fetchPriority:void 0,referrerPolicy:typeof p.referrerPolicy=="string"?p.referrerPolicy:void 0,imageSrcSet:typeof p.imageSrcSet=="string"?p.imageSrcSet:void 0,imageSizes:typeof p.imageSizes=="string"?p.imageSizes:void 0,media:typeof p.media=="string"?p.media:void 0})}},Et.preloadModule=function(g,p){if(typeof g=="string")if(p){var S=b(p.as,p.crossOrigin);c.d.m(g,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:S,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else c.d.m(g)},Et.requestFormReset=function(g){c.d.r(g)},Et.unstable_batchedUpdates=function(g,p){return g(p)},Et.useFormState=function(g,p,S){return h.H.useFormState(g,p,S)},Et.useFormStatus=function(){return h.H.useHostTransitionStatus()},Et.version="19.2.4",Et}var Ch;function zb(){if(Ch)return Od.exports;Ch=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(i){console.error(i)}}return n(),Od.exports=kb(),Od.exports}/**
34
+ * @license React
35
+ * react-dom-client.production.js
36
+ *
37
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
38
+ *
39
+ * This source code is licensed under the MIT license found in the
40
+ * LICENSE file in the root directory of this source tree.
41
+ */var Ah;function Cb(){if(Ah)return ai;Ah=1;var n=Sb(),i=au(),d=zb();function c(t){var s="https://react.dev/errors/"+t;if(1<arguments.length){s+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)s+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+t+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function m(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function f(t){var s=t,a=t;if(t.alternate)for(;s.return;)s=s.return;else{t=s;do s=t,(s.flags&4098)!==0&&(a=s.return),t=s.return;while(t)}return s.tag===3?a:null}function h(t){if(t.tag===13){var s=t.memoizedState;if(s===null&&(t=t.alternate,t!==null&&(s=t.memoizedState)),s!==null)return s.dehydrated}return null}function b(t){if(t.tag===31){var s=t.memoizedState;if(s===null&&(t=t.alternate,t!==null&&(s=t.memoizedState)),s!==null)return s.dehydrated}return null}function g(t){if(f(t)!==t)throw Error(c(188))}function p(t){var s=t.alternate;if(!s){if(s=f(t),s===null)throw Error(c(188));return s!==t?null:t}for(var a=t,l=s;;){var r=a.return;if(r===null)break;var o=r.alternate;if(o===null){if(l=r.return,l!==null){a=l;continue}break}if(r.child===o.child){for(o=r.child;o;){if(o===a)return g(r),t;if(o===l)return g(r),s;o=o.sibling}throw Error(c(188))}if(a.return!==l.return)a=r,l=o;else{for(var x=!1,j=r.child;j;){if(j===a){x=!0,a=r,l=o;break}if(j===l){x=!0,l=r,a=o;break}j=j.sibling}if(!x){for(j=o.child;j;){if(j===a){x=!0,a=o,l=r;break}if(j===l){x=!0,l=o,a=r;break}j=j.sibling}if(!x)throw Error(c(189))}}if(a.alternate!==l)throw Error(c(190))}if(a.tag!==3)throw Error(c(188));return a.stateNode.current===a?t:s}function S(t){var s=t.tag;if(s===5||s===26||s===27||s===6)return t;for(t=t.child;t!==null;){if(s=S(t),s!==null)return s;t=t.sibling}return null}var y=Object.assign,v=Symbol.for("react.element"),k=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),N=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),R=Symbol.for("react.consumer"),D=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),se=Symbol.for("react.suspense"),Z=Symbol.for("react.suspense_list"),U=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),F=Symbol.for("react.activity"),$=Symbol.for("react.memo_cache_sentinel"),Q=Symbol.iterator;function ce(t){return t===null||typeof t!="object"?null:(t=Q&&t[Q]||t["@@iterator"],typeof t=="function"?t:null)}var I=Symbol.for("react.client.reference");function le(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===I?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case w:return"Fragment";case z:return"Profiler";case N:return"StrictMode";case se:return"Suspense";case Z:return"SuspenseList";case F:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case C:return"Portal";case D:return t.displayName||"Context";case R:return(t._context.displayName||"Context")+".Consumer";case O:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case U:return s=t.displayName||null,s!==null?s:le(t.type)||"Memo";case A:s=t._payload,t=t._init;try{return le(t(s))}catch{}}return null}var Y=Array.isArray,B=i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne=d.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,me={pending:!1,data:null,method:null,action:null},ue=[],je=-1;function T(t){return{current:t}}function P(t){0>je||(t.current=ue[je],ue[je]=null,je--)}function de(t,s){je++,ue[je]=t.current,t.current=s}var G=T(null),oe=T(null),fe=T(null),be=T(null);function Ce(t,s){switch(de(fe,s),de(oe,t),de(G,null),s.nodeType){case 9:case 11:t=(t=s.documentElement)&&(t=t.namespaceURI)?Kf(t):0;break;default:if(t=s.tagName,s=s.namespaceURI)s=Kf(s),t=Vf(s,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}P(G),de(G,t)}function ve(){P(G),P(oe),P(fe)}function tt(t){t.memoizedState!==null&&de(be,t);var s=G.current,a=Vf(s,t.type);s!==a&&(de(oe,t),de(G,a))}function Xe(t){oe.current===t&&(P(G),P(oe)),be.current===t&&(P(be),Pl._currentValue=me)}var Lt,Ns;function At(t){if(Lt===void 0)try{throw Error()}catch(a){var s=a.stack.trim().match(/\n( *(at )?)/);Lt=s&&s[1]||"",Ns=-1<a.stack.indexOf(`
42
+ at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
43
+ `+Lt+t+Ns}var Kt=!1;function qe(t,s){if(!t||Kt)return"";Kt=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(s){var ee=function(){throw Error()};if(Object.defineProperty(ee.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ee,[])}catch(X){var V=X}Reflect.construct(t,[],ee)}else{try{ee.call()}catch(X){V=X}t.call(ee.prototype)}}else{try{throw Error()}catch(X){V=X}(ee=t())&&typeof ee.catch=="function"&&ee.catch(function(){})}}catch(X){if(X&&V&&typeof X.stack=="string")return[X.stack,V.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var r=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");r&&r.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var o=l.DetermineComponentFrameRoot(),x=o[0],j=o[1];if(x&&j){var E=x.split(`
44
+ `),q=j.split(`
45
+ `);for(r=l=0;l<E.length&&!E[l].includes("DetermineComponentFrameRoot");)l++;for(;r<q.length&&!q[r].includes("DetermineComponentFrameRoot");)r++;if(l===E.length||r===q.length)for(l=E.length-1,r=q.length-1;1<=l&&0<=r&&E[l]!==q[r];)r--;for(;1<=l&&0<=r;l--,r--)if(E[l]!==q[r]){if(l!==1||r!==1)do if(l--,r--,0>r||E[l]!==q[r]){var J=`
46
+ `+E[l].replace(" at new "," at ");return t.displayName&&J.includes("<anonymous>")&&(J=J.replace("<anonymous>",t.displayName)),J}while(1<=l&&0<=r);break}}}finally{Kt=!1,Error.prepareStackTrace=a}return(a=t?t.displayName||t.name:"")?At(a):""}function nt(t,s){switch(t.tag){case 26:case 27:case 5:return At(t.type);case 16:return At("Lazy");case 13:return t.child!==s&&s!==null?At("Suspense Fallback"):At("Suspense");case 19:return At("SuspenseList");case 0:case 15:return qe(t.type,!1);case 11:return qe(t.type.render,!1);case 1:return qe(t.type,!0);case 31:return At("Activity");default:return""}}function L(t){try{var s="",a=null;do s+=nt(t,a),a=t,t=t.return;while(t);return s}catch(l){return`
47
+ Error generating stack: `+l.message+`
48
+ `+l.stack}}var te=Object.prototype.hasOwnProperty,ye=n.unstable_scheduleCallback,We=n.unstable_cancelCallback,fs=n.unstable_shouldYield,hs=n.unstable_requestPaint,yt=n.unstable_now,dn=n.unstable_getCurrentPriorityLevel,$a=n.unstable_ImmediatePriority,Ba=n.unstable_UserBlockingPriority,Os=n.unstable_NormalPriority,Si=n.unstable_LowPriority,K=n.unstable_IdlePriority,re=n.log,we=n.unstable_setDisableYieldValue,Se=null,Oe=null;function ct(t){if(typeof re=="function"&&we(t),Oe&&typeof Oe.setStrictMode=="function")try{Oe.setStrictMode(Se,t)}catch{}}var Rt=Math.clz32?Math.clz32:ki,fc=Math.log,Ha=Math.LN2;function ki(t){return t>>>=0,t===0?32:31-(fc(t)/Ha|0)|0}var dl=256,Ls=262144,ra=4194304;function ws(t){var s=t&42;if(s!==0)return s;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function un(t,s,a){var l=t.pendingLanes;if(l===0)return 0;var r=0,o=t.suspendedLanes,x=t.pingedLanes;t=t.warmLanes;var j=l&134217727;return j!==0?(l=j&~o,l!==0?r=ws(l):(x&=j,x!==0?r=ws(x):a||(a=j&~t,a!==0&&(r=ws(a))))):(j=l&~o,j!==0?r=ws(j):x!==0?r=ws(x):a||(a=l&~t,a!==0&&(r=ws(a)))),r===0?0:s!==0&&s!==r&&(s&o)===0&&(o=r&-r,a=s&-s,o>=a||o===32&&(a&4194048)!==0)?s:r}function ul(t,s){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&s)===0}function lp(t,s){switch(t){case 1:case 2:case 4:case 8:case 64:return s+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function wu(){var t=ra;return ra<<=1,(ra&62914560)===0&&(ra=4194304),t}function hc(t){for(var s=[],a=0;31>a;a++)s.push(t);return s}function ml(t,s){t.pendingLanes|=s,s!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function ip(t,s,a,l,r,o){var x=t.pendingLanes;t.pendingLanes=a,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=a,t.entangledLanes&=a,t.errorRecoveryDisabledLanes&=a,t.shellSuspendCounter=0;var j=t.entanglements,E=t.expirationTimes,q=t.hiddenUpdates;for(a=x&~a;0<a;){var J=31-Rt(a),ee=1<<J;j[J]=0,E[J]=-1;var V=q[J];if(V!==null)for(q[J]=null,J=0;J<V.length;J++){var X=V[J];X!==null&&(X.lane&=-536870913)}a&=~ee}l!==0&&Su(t,l,0),o!==0&&r===0&&t.tag!==0&&(t.suspendedLanes|=o&~(x&~s))}function Su(t,s,a){t.pendingLanes|=s,t.suspendedLanes&=~s;var l=31-Rt(s);t.entangledLanes|=s,t.entanglements[l]=t.entanglements[l]|1073741824|a&261930}function ku(t,s){var a=t.entangledLanes|=s;for(t=t.entanglements;a;){var l=31-Rt(a),r=1<<l;r&s|t[l]&s&&(t[l]|=s),a&=~r}}function zu(t,s){var a=s&-s;return a=(a&42)!==0?1:pc(a),(a&(t.suspendedLanes|s))!==0?0:a}function pc(t){switch(t){case 2:t=1;break;case 8:t=4;break;case 32:t=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:t=128;break;case 268435456:t=134217728;break;default:t=0}return t}function gc(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function Cu(){var t=ne.p;return t!==0?t:(t=window.event,t===void 0?32:xh(t.type))}function Au(t,s){var a=ne.p;try{return ne.p=t,s()}finally{ne.p=a}}var ca=Math.random().toString(36).slice(2),wt="__reactFiber$"+ca,_t="__reactProps$"+ca,mn="__reactContainer$"+ca,bc="__reactEvents$"+ca,rp="__reactListeners$"+ca,cp="__reactHandles$"+ca,Eu="__reactResources$"+ca,xl="__reactMarker$"+ca;function yc(t){delete t[wt],delete t[_t],delete t[bc],delete t[rp],delete t[cp]}function xn(t){var s=t[wt];if(s)return s;for(var a=t.parentNode;a;){if(s=a[mn]||a[wt]){if(a=s.alternate,s.child!==null||a!==null&&a.child!==null)for(t=If(t);t!==null;){if(a=t[wt])return a;t=If(t)}return s}t=a,a=t.parentNode}return null}function fn(t){if(t=t[wt]||t[mn]){var s=t.tag;if(s===5||s===6||s===13||s===31||s===26||s===27||s===3)return t}return null}function fl(t){var s=t.tag;if(s===5||s===26||s===27||s===6)return t.stateNode;throw Error(c(33))}function hn(t){var s=t[Eu];return s||(s=t[Eu]={hoistableStyles:new Map,hoistableScripts:new Map}),s}function vt(t){t[xl]=!0}var Tu=new Set,Ru={};function qa(t,s){pn(t,s),pn(t+"Capture",s)}function pn(t,s){for(Ru[t]=s,t=0;t<s.length;t++)Tu.add(s[t])}var op=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Mu={},Du={};function dp(t){return te.call(Du,t)?!0:te.call(Mu,t)?!1:op.test(t)?Du[t]=!0:(Mu[t]=!0,!1)}function zi(t,s,a){if(dp(s))if(a===null)t.removeAttribute(s);else{switch(typeof a){case"undefined":case"function":case"symbol":t.removeAttribute(s);return;case"boolean":var l=s.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){t.removeAttribute(s);return}}t.setAttribute(s,""+a)}}function Ci(t,s,a){if(a===null)t.removeAttribute(s);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(s);return}t.setAttribute(s,""+a)}}function _s(t,s,a,l){if(l===null)t.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(a);return}t.setAttributeNS(s,a,""+l)}}function es(t){switch(typeof t){case"bigint":case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Ou(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function up(t,s,a){var l=Object.getOwnPropertyDescriptor(t.constructor.prototype,s);if(!t.hasOwnProperty(s)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var r=l.get,o=l.set;return Object.defineProperty(t,s,{configurable:!0,get:function(){return r.call(this)},set:function(x){a=""+x,o.call(this,x)}}),Object.defineProperty(t,s,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(x){a=""+x},stopTracking:function(){t._valueTracker=null,delete t[s]}}}}function vc(t){if(!t._valueTracker){var s=Ou(t)?"checked":"value";t._valueTracker=up(t,s,""+t[s])}}function Lu(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var a=s.getValue(),l="";return t&&(l=Ou(t)?t.checked?"true":"false":t.value),t=l,t!==a?(s.setValue(t),!0):!1}function Ai(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var mp=/[\n"\\]/g;function ts(t){return t.replace(mp,function(s){return"\\"+s.charCodeAt(0).toString(16)+" "})}function jc(t,s,a,l,r,o,x,j){t.name="",x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"?t.type=x:t.removeAttribute("type"),s!=null?x==="number"?(s===0&&t.value===""||t.value!=s)&&(t.value=""+es(s)):t.value!==""+es(s)&&(t.value=""+es(s)):x!=="submit"&&x!=="reset"||t.removeAttribute("value"),s!=null?Nc(t,x,es(s)):a!=null?Nc(t,x,es(a)):l!=null&&t.removeAttribute("value"),r==null&&o!=null&&(t.defaultChecked=!!o),r!=null&&(t.checked=r&&typeof r!="function"&&typeof r!="symbol"),j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?t.name=""+es(j):t.removeAttribute("name")}function _u(t,s,a,l,r,o,x,j){if(o!=null&&typeof o!="function"&&typeof o!="symbol"&&typeof o!="boolean"&&(t.type=o),s!=null||a!=null){if(!(o!=="submit"&&o!=="reset"||s!=null)){vc(t);return}a=a!=null?""+es(a):"",s=s!=null?""+es(s):a,j||s===t.value||(t.value=s),t.defaultValue=s}l=l??r,l=typeof l!="function"&&typeof l!="symbol"&&!!l,t.checked=j?t.checked:!!l,t.defaultChecked=!!l,x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"&&(t.name=x),vc(t)}function Nc(t,s,a){s==="number"&&Ai(t.ownerDocument)===t||t.defaultValue===""+a||(t.defaultValue=""+a)}function gn(t,s,a,l){if(t=t.options,s){s={};for(var r=0;r<a.length;r++)s["$"+a[r]]=!0;for(a=0;a<t.length;a++)r=s.hasOwnProperty("$"+t[a].value),t[a].selected!==r&&(t[a].selected=r),r&&l&&(t[a].defaultSelected=!0)}else{for(a=""+es(a),s=null,r=0;r<t.length;r++){if(t[r].value===a){t[r].selected=!0,l&&(t[r].defaultSelected=!0);return}s!==null||t[r].disabled||(s=t[r])}s!==null&&(s.selected=!0)}}function Uu(t,s,a){if(s!=null&&(s=""+es(s),s!==t.value&&(t.value=s),a==null)){t.defaultValue!==s&&(t.defaultValue=s);return}t.defaultValue=a!=null?""+es(a):""}function $u(t,s,a,l){if(s==null){if(l!=null){if(a!=null)throw Error(c(92));if(Y(l)){if(1<l.length)throw Error(c(93));l=l[0]}a=l}a==null&&(a=""),s=a}a=es(s),t.defaultValue=a,l=t.textContent,l===a&&l!==""&&l!==null&&(t.value=l),vc(t)}function bn(t,s){if(s){var a=t.firstChild;if(a&&a===t.lastChild&&a.nodeType===3){a.nodeValue=s;return}}t.textContent=s}var xp=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Bu(t,s,a){var l=s.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?t.setProperty(s,""):s==="float"?t.cssFloat="":t[s]="":l?t.setProperty(s,a):typeof a!="number"||a===0||xp.has(s)?s==="float"?t.cssFloat=a:t[s]=(""+a).trim():t[s]=a+"px"}function Hu(t,s,a){if(s!=null&&typeof s!="object")throw Error(c(62));if(t=t.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||s!=null&&s.hasOwnProperty(l)||(l.indexOf("--")===0?t.setProperty(l,""):l==="float"?t.cssFloat="":t[l]="");for(var r in s)l=s[r],s.hasOwnProperty(r)&&a[r]!==l&&Bu(t,r,l)}else for(var o in s)s.hasOwnProperty(o)&&Bu(t,o,s[o])}function wc(t){if(t.indexOf("-")===-1)return!1;switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var fp=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),hp=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Ei(t){return hp.test(""+t)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":t}function Us(){}var Sc=null;function kc(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var yn=null,vn=null;function qu(t){var s=fn(t);if(s&&(t=s.stateNode)){var a=t[_t]||null;e:switch(t=s.stateNode,s.type){case"input":if(jc(t,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),s=a.name,a.type==="radio"&&s!=null){for(a=t;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+ts(""+s)+'"][type="radio"]'),s=0;s<a.length;s++){var l=a[s];if(l!==t&&l.form===t.form){var r=l[_t]||null;if(!r)throw Error(c(90));jc(l,r.value,r.defaultValue,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name)}}for(s=0;s<a.length;s++)l=a[s],l.form===t.form&&Lu(l)}break e;case"textarea":Uu(t,a.value,a.defaultValue);break e;case"select":s=a.value,s!=null&&gn(t,!!a.multiple,s,!1)}}}var zc=!1;function Gu(t,s,a){if(zc)return t(s,a);zc=!0;try{var l=t(s);return l}finally{if(zc=!1,(yn!==null||vn!==null)&&(pr(),yn&&(s=yn,t=vn,vn=yn=null,qu(s),t)))for(s=0;s<t.length;s++)qu(t[s])}}function hl(t,s){var a=t.stateNode;if(a===null)return null;var l=a[_t]||null;if(l===null)return null;a=l[s];e:switch(s){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(t=t.type,l=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!l;break e;default:t=!1}if(t)return null;if(a&&typeof a!="function")throw Error(c(231,s,typeof a));return a}var $s=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Cc=!1;if($s)try{var pl={};Object.defineProperty(pl,"passive",{get:function(){Cc=!0}}),window.addEventListener("test",pl,pl),window.removeEventListener("test",pl,pl)}catch{Cc=!1}var oa=null,Ac=null,Ti=null;function Ku(){if(Ti)return Ti;var t,s=Ac,a=s.length,l,r="value"in oa?oa.value:oa.textContent,o=r.length;for(t=0;t<a&&s[t]===r[t];t++);var x=a-t;for(l=1;l<=x&&s[a-l]===r[o-l];l++);return Ti=r.slice(t,1<l?1-l:void 0)}function Ri(t){var s=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&s===13&&(t=13)):t=s,t===10&&(t=13),32<=t||t===13?t:0}function Mi(){return!0}function Vu(){return!1}function Ut(t){function s(a,l,r,o,x){this._reactName=a,this._targetInst=r,this.type=l,this.nativeEvent=o,this.target=x,this.currentTarget=null;for(var j in t)t.hasOwnProperty(j)&&(a=t[j],this[j]=a?a(o):o[j]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?Mi:Vu,this.isPropagationStopped=Vu,this}return y(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Mi)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Mi)},persist:function(){},isPersistent:Mi}),s}var Ga={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Di=Ut(Ga),gl=y({},Ga,{view:0,detail:0}),pp=Ut(gl),Ec,Tc,bl,Oi=y({},gl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Mc,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==bl&&(bl&&t.type==="mousemove"?(Ec=t.screenX-bl.screenX,Tc=t.screenY-bl.screenY):Tc=Ec=0,bl=t),Ec)},movementY:function(t){return"movementY"in t?t.movementY:Tc}}),Yu=Ut(Oi),gp=y({},Oi,{dataTransfer:0}),bp=Ut(gp),yp=y({},gl,{relatedTarget:0}),Rc=Ut(yp),vp=y({},Ga,{animationName:0,elapsedTime:0,pseudoElement:0}),jp=Ut(vp),Np=y({},Ga,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),wp=Ut(Np),Sp=y({},Ga,{data:0}),Xu=Ut(Sp),kp={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},zp={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Cp={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Ap(t){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(t):(t=Cp[t])?!!s[t]:!1}function Mc(){return Ap}var Ep=y({},gl,{key:function(t){if(t.key){var s=kp[t.key]||t.key;if(s!=="Unidentified")return s}return t.type==="keypress"?(t=Ri(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?zp[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Mc,charCode:function(t){return t.type==="keypress"?Ri(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Ri(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),Tp=Ut(Ep),Rp=y({},Oi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Qu=Ut(Rp),Mp=y({},gl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Mc}),Dp=Ut(Mp),Op=y({},Ga,{propertyName:0,elapsedTime:0,pseudoElement:0}),Lp=Ut(Op),_p=y({},Oi,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),Up=Ut(_p),$p=y({},Ga,{newState:0,oldState:0}),Bp=Ut($p),Hp=[9,13,27,32],Dc=$s&&"CompositionEvent"in window,yl=null;$s&&"documentMode"in document&&(yl=document.documentMode);var qp=$s&&"TextEvent"in window&&!yl,Fu=$s&&(!Dc||yl&&8<yl&&11>=yl),Zu=" ",Ju=!1;function Iu(t,s){switch(t){case"keyup":return Hp.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Pu(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var jn=!1;function Gp(t,s){switch(t){case"compositionend":return Pu(s);case"keypress":return s.which!==32?null:(Ju=!0,Zu);case"textInput":return t=s.data,t===Zu&&Ju?null:t;default:return null}}function Kp(t,s){if(jn)return t==="compositionend"||!Dc&&Iu(t,s)?(t=Ku(),Ti=Ac=oa=null,jn=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return Fu&&s.locale!=="ko"?null:s.data;default:return null}}var Vp={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Wu(t){var s=t&&t.nodeName&&t.nodeName.toLowerCase();return s==="input"?!!Vp[t.type]:s==="textarea"}function em(t,s,a,l){yn?vn?vn.push(l):vn=[l]:yn=l,s=wr(s,"onChange"),0<s.length&&(a=new Di("onChange","change",null,a,l),t.push({event:a,listeners:s}))}var vl=null,jl=null;function Yp(t){Uf(t,0)}function Li(t){var s=fl(t);if(Lu(s))return t}function tm(t,s){if(t==="change")return s}var sm=!1;if($s){var Oc;if($s){var Lc="oninput"in document;if(!Lc){var am=document.createElement("div");am.setAttribute("oninput","return;"),Lc=typeof am.oninput=="function"}Oc=Lc}else Oc=!1;sm=Oc&&(!document.documentMode||9<document.documentMode)}function nm(){vl&&(vl.detachEvent("onpropertychange",lm),jl=vl=null)}function lm(t){if(t.propertyName==="value"&&Li(jl)){var s=[];em(s,jl,t,kc(t)),Gu(Yp,s)}}function Xp(t,s,a){t==="focusin"?(nm(),vl=s,jl=a,vl.attachEvent("onpropertychange",lm)):t==="focusout"&&nm()}function Qp(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return Li(jl)}function Fp(t,s){if(t==="click")return Li(s)}function Zp(t,s){if(t==="input"||t==="change")return Li(s)}function Jp(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var Vt=typeof Object.is=="function"?Object.is:Jp;function Nl(t,s){if(Vt(t,s))return!0;if(typeof t!="object"||t===null||typeof s!="object"||s===null)return!1;var a=Object.keys(t),l=Object.keys(s);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var r=a[l];if(!te.call(s,r)||!Vt(t[r],s[r]))return!1}return!0}function im(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function rm(t,s){var a=im(t);t=0;for(var l;a;){if(a.nodeType===3){if(l=t+a.textContent.length,t<=s&&l>=s)return{node:a,offset:s-t};t=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=im(a)}}function cm(t,s){return t&&s?t===s?!0:t&&t.nodeType===3?!1:s&&s.nodeType===3?cm(t,s.parentNode):"contains"in t?t.contains(s):t.compareDocumentPosition?!!(t.compareDocumentPosition(s)&16):!1:!1}function om(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var s=Ai(t.document);s instanceof t.HTMLIFrameElement;){try{var a=typeof s.contentWindow.location.href=="string"}catch{a=!1}if(a)t=s.contentWindow;else break;s=Ai(t.document)}return s}function _c(t){var s=t&&t.nodeName&&t.nodeName.toLowerCase();return s&&(s==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||s==="textarea"||t.contentEditable==="true")}var Ip=$s&&"documentMode"in document&&11>=document.documentMode,Nn=null,Uc=null,wl=null,$c=!1;function dm(t,s,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;$c||Nn==null||Nn!==Ai(l)||(l=Nn,"selectionStart"in l&&_c(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),wl&&Nl(wl,l)||(wl=l,l=wr(Uc,"onSelect"),0<l.length&&(s=new Di("onSelect","select",null,s,a),t.push({event:s,listeners:l}),s.target=Nn)))}function Ka(t,s){var a={};return a[t.toLowerCase()]=s.toLowerCase(),a["Webkit"+t]="webkit"+s,a["Moz"+t]="moz"+s,a}var wn={animationend:Ka("Animation","AnimationEnd"),animationiteration:Ka("Animation","AnimationIteration"),animationstart:Ka("Animation","AnimationStart"),transitionrun:Ka("Transition","TransitionRun"),transitionstart:Ka("Transition","TransitionStart"),transitioncancel:Ka("Transition","TransitionCancel"),transitionend:Ka("Transition","TransitionEnd")},Bc={},um={};$s&&(um=document.createElement("div").style,"AnimationEvent"in window||(delete wn.animationend.animation,delete wn.animationiteration.animation,delete wn.animationstart.animation),"TransitionEvent"in window||delete wn.transitionend.transition);function Va(t){if(Bc[t])return Bc[t];if(!wn[t])return t;var s=wn[t],a;for(a in s)if(s.hasOwnProperty(a)&&a in um)return Bc[t]=s[a];return t}var mm=Va("animationend"),xm=Va("animationiteration"),fm=Va("animationstart"),Pp=Va("transitionrun"),Wp=Va("transitionstart"),eg=Va("transitioncancel"),hm=Va("transitionend"),pm=new Map,Hc="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");Hc.push("scrollEnd");function ps(t,s){pm.set(t,s),qa(s,[t])}var _i=typeof reportError=="function"?reportError:function(t){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var s=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof t=="object"&&t!==null&&typeof t.message=="string"?String(t.message):String(t),error:t});if(!window.dispatchEvent(s))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)},ss=[],Sn=0,qc=0;function Ui(){for(var t=Sn,s=qc=Sn=0;s<t;){var a=ss[s];ss[s++]=null;var l=ss[s];ss[s++]=null;var r=ss[s];ss[s++]=null;var o=ss[s];if(ss[s++]=null,l!==null&&r!==null){var x=l.pending;x===null?r.next=r:(r.next=x.next,x.next=r),l.pending=r}o!==0&&gm(a,r,o)}}function $i(t,s,a,l){ss[Sn++]=t,ss[Sn++]=s,ss[Sn++]=a,ss[Sn++]=l,qc|=l,t.lanes|=l,t=t.alternate,t!==null&&(t.lanes|=l)}function Gc(t,s,a,l){return $i(t,s,a,l),Bi(t)}function Ya(t,s){return $i(t,null,null,s),Bi(t)}function gm(t,s,a){t.lanes|=a;var l=t.alternate;l!==null&&(l.lanes|=a);for(var r=!1,o=t.return;o!==null;)o.childLanes|=a,l=o.alternate,l!==null&&(l.childLanes|=a),o.tag===22&&(t=o.stateNode,t===null||t._visibility&1||(r=!0)),t=o,o=o.return;return t.tag===3?(o=t.stateNode,r&&s!==null&&(r=31-Rt(a),t=o.hiddenUpdates,l=t[r],l===null?t[r]=[s]:l.push(s),s.lane=a|536870912),o):null}function Bi(t){if(50<Yl)throw Yl=0,Po=null,Error(c(185));for(var s=t.return;s!==null;)t=s,s=t.return;return t.tag===3?t.stateNode:null}var kn={};function tg(t,s,a,l){this.tag=t,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Yt(t,s,a,l){return new tg(t,s,a,l)}function Kc(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Bs(t,s){var a=t.alternate;return a===null?(a=Yt(t.tag,s,t.key,t.mode),a.elementType=t.elementType,a.type=t.type,a.stateNode=t.stateNode,a.alternate=t,t.alternate=a):(a.pendingProps=s,a.type=t.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=t.flags&65011712,a.childLanes=t.childLanes,a.lanes=t.lanes,a.child=t.child,a.memoizedProps=t.memoizedProps,a.memoizedState=t.memoizedState,a.updateQueue=t.updateQueue,s=t.dependencies,a.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},a.sibling=t.sibling,a.index=t.index,a.ref=t.ref,a.refCleanup=t.refCleanup,a}function bm(t,s){t.flags&=65011714;var a=t.alternate;return a===null?(t.childLanes=0,t.lanes=s,t.child=null,t.subtreeFlags=0,t.memoizedProps=null,t.memoizedState=null,t.updateQueue=null,t.dependencies=null,t.stateNode=null):(t.childLanes=a.childLanes,t.lanes=a.lanes,t.child=a.child,t.subtreeFlags=0,t.deletions=null,t.memoizedProps=a.memoizedProps,t.memoizedState=a.memoizedState,t.updateQueue=a.updateQueue,t.type=a.type,s=a.dependencies,t.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),t}function Hi(t,s,a,l,r,o){var x=0;if(l=t,typeof t=="function")Kc(t)&&(x=1);else if(typeof t=="string")x=ib(t,a,G.current)?26:t==="html"||t==="head"||t==="body"?27:5;else e:switch(t){case F:return t=Yt(31,a,s,r),t.elementType=F,t.lanes=o,t;case w:return Xa(a.children,r,o,s);case N:x=8,r|=24;break;case z:return t=Yt(12,a,s,r|2),t.elementType=z,t.lanes=o,t;case se:return t=Yt(13,a,s,r),t.elementType=se,t.lanes=o,t;case Z:return t=Yt(19,a,s,r),t.elementType=Z,t.lanes=o,t;default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case D:x=10;break e;case R:x=9;break e;case O:x=11;break e;case U:x=14;break e;case A:x=16,l=null;break e}x=29,a=Error(c(130,t===null?"null":typeof t,"")),l=null}return s=Yt(x,a,s,r),s.elementType=t,s.type=l,s.lanes=o,s}function Xa(t,s,a,l){return t=Yt(7,t,l,s),t.lanes=a,t}function Vc(t,s,a){return t=Yt(6,t,null,s),t.lanes=a,t}function ym(t){var s=Yt(18,null,null,0);return s.stateNode=t,s}function Yc(t,s,a){return s=Yt(4,t.children!==null?t.children:[],t.key,s),s.lanes=a,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}var vm=new WeakMap;function as(t,s){if(typeof t=="object"&&t!==null){var a=vm.get(t);return a!==void 0?a:(s={value:t,source:s,stack:L(s)},vm.set(t,s),s)}return{value:t,source:s,stack:L(s)}}var zn=[],Cn=0,qi=null,Sl=0,ns=[],ls=0,da=null,Ss=1,ks="";function Hs(t,s){zn[Cn++]=Sl,zn[Cn++]=qi,qi=t,Sl=s}function jm(t,s,a){ns[ls++]=Ss,ns[ls++]=ks,ns[ls++]=da,da=t;var l=Ss;t=ks;var r=32-Rt(l)-1;l&=~(1<<r),a+=1;var o=32-Rt(s)+r;if(30<o){var x=r-r%5;o=(l&(1<<x)-1).toString(32),l>>=x,r-=x,Ss=1<<32-Rt(s)+r|a<<r|l,ks=o+t}else Ss=1<<o|a<<r|l,ks=t}function Xc(t){t.return!==null&&(Hs(t,1),jm(t,1,0))}function Qc(t){for(;t===qi;)qi=zn[--Cn],zn[Cn]=null,Sl=zn[--Cn],zn[Cn]=null;for(;t===da;)da=ns[--ls],ns[ls]=null,ks=ns[--ls],ns[ls]=null,Ss=ns[--ls],ns[ls]=null}function Nm(t,s){ns[ls++]=Ss,ns[ls++]=ks,ns[ls++]=da,Ss=s.id,ks=s.overflow,da=t}var St=null,Qe=null,De=!1,ua=null,is=!1,Fc=Error(c(519));function ma(t){var s=Error(c(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw kl(as(s,t)),Fc}function wm(t){var s=t.stateNode,a=t.type,l=t.memoizedProps;switch(s[wt]=t,s[_t]=l,a){case"dialog":Ee("cancel",s),Ee("close",s);break;case"iframe":case"object":case"embed":Ee("load",s);break;case"video":case"audio":for(a=0;a<Ql.length;a++)Ee(Ql[a],s);break;case"source":Ee("error",s);break;case"img":case"image":case"link":Ee("error",s),Ee("load",s);break;case"details":Ee("toggle",s);break;case"input":Ee("invalid",s),_u(s,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":Ee("invalid",s);break;case"textarea":Ee("invalid",s),$u(s,l.value,l.defaultValue,l.children)}a=l.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||s.textContent===""+a||l.suppressHydrationWarning===!0||qf(s.textContent,a)?(l.popover!=null&&(Ee("beforetoggle",s),Ee("toggle",s)),l.onScroll!=null&&Ee("scroll",s),l.onScrollEnd!=null&&Ee("scrollend",s),l.onClick!=null&&(s.onclick=Us),s=!0):s=!1,s||ma(t,!0)}function Sm(t){for(St=t.return;St;)switch(St.tag){case 5:case 31:case 13:is=!1;return;case 27:case 3:is=!0;return;default:St=St.return}}function An(t){if(t!==St)return!1;if(!De)return Sm(t),De=!0,!1;var s=t.tag,a;if((a=s!==3&&s!==27)&&((a=s===5)&&(a=t.type,a=!(a!=="form"&&a!=="button")||xd(t.type,t.memoizedProps)),a=!a),a&&Qe&&ma(t),Sm(t),s===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(c(317));Qe=Jf(t)}else if(s===31){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(c(317));Qe=Jf(t)}else s===27?(s=Qe,za(t.type)?(t=bd,bd=null,Qe=t):Qe=s):Qe=St?cs(t.stateNode.nextSibling):null;return!0}function Qa(){Qe=St=null,De=!1}function Zc(){var t=ua;return t!==null&&(qt===null?qt=t:qt.push.apply(qt,t),ua=null),t}function kl(t){ua===null?ua=[t]:ua.push(t)}var Jc=T(null),Fa=null,qs=null;function xa(t,s,a){de(Jc,s._currentValue),s._currentValue=a}function Gs(t){t._currentValue=Jc.current,P(Jc)}function Ic(t,s,a){for(;t!==null;){var l=t.alternate;if((t.childLanes&s)!==s?(t.childLanes|=s,l!==null&&(l.childLanes|=s)):l!==null&&(l.childLanes&s)!==s&&(l.childLanes|=s),t===a)break;t=t.return}}function Pc(t,s,a,l){var r=t.child;for(r!==null&&(r.return=t);r!==null;){var o=r.dependencies;if(o!==null){var x=r.child;o=o.firstContext;e:for(;o!==null;){var j=o;o=r;for(var E=0;E<s.length;E++)if(j.context===s[E]){o.lanes|=a,j=o.alternate,j!==null&&(j.lanes|=a),Ic(o.return,a,t),l||(x=null);break e}o=j.next}}else if(r.tag===18){if(x=r.return,x===null)throw Error(c(341));x.lanes|=a,o=x.alternate,o!==null&&(o.lanes|=a),Ic(x,a,t),x=null}else x=r.child;if(x!==null)x.return=r;else for(x=r;x!==null;){if(x===t){x=null;break}if(r=x.sibling,r!==null){r.return=x.return,x=r;break}x=x.return}r=x}}function En(t,s,a,l){t=null;for(var r=s,o=!1;r!==null;){if(!o){if((r.flags&524288)!==0)o=!0;else if((r.flags&262144)!==0)break}if(r.tag===10){var x=r.alternate;if(x===null)throw Error(c(387));if(x=x.memoizedProps,x!==null){var j=r.type;Vt(r.pendingProps.value,x.value)||(t!==null?t.push(j):t=[j])}}else if(r===be.current){if(x=r.alternate,x===null)throw Error(c(387));x.memoizedState.memoizedState!==r.memoizedState.memoizedState&&(t!==null?t.push(Pl):t=[Pl])}r=r.return}t!==null&&Pc(s,t,a,l),s.flags|=262144}function Gi(t){for(t=t.firstContext;t!==null;){if(!Vt(t.context._currentValue,t.memoizedValue))return!0;t=t.next}return!1}function Za(t){Fa=t,qs=null,t=t.dependencies,t!==null&&(t.firstContext=null)}function kt(t){return km(Fa,t)}function Ki(t,s){return Fa===null&&Za(t),km(t,s)}function km(t,s){var a=s._currentValue;if(s={context:s,memoizedValue:a,next:null},qs===null){if(t===null)throw Error(c(308));qs=s,t.dependencies={lanes:0,firstContext:s},t.flags|=524288}else qs=qs.next=s;return a}var sg=typeof AbortController<"u"?AbortController:function(){var t=[],s=this.signal={aborted:!1,addEventListener:function(a,l){t.push(l)}};this.abort=function(){s.aborted=!0,t.forEach(function(a){return a()})}},ag=n.unstable_scheduleCallback,ng=n.unstable_NormalPriority,ot={$$typeof:D,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Wc(){return{controller:new sg,data:new Map,refCount:0}}function zl(t){t.refCount--,t.refCount===0&&ag(ng,function(){t.controller.abort()})}var Cl=null,eo=0,Tn=0,Rn=null;function lg(t,s){if(Cl===null){var a=Cl=[];eo=0,Tn=nd(),Rn={status:"pending",value:void 0,then:function(l){a.push(l)}}}return eo++,s.then(zm,zm),s}function zm(){if(--eo===0&&Cl!==null){Rn!==null&&(Rn.status="fulfilled");var t=Cl;Cl=null,Tn=0,Rn=null;for(var s=0;s<t.length;s++)(0,t[s])()}}function ig(t,s){var a=[],l={status:"pending",value:null,reason:null,then:function(r){a.push(r)}};return t.then(function(){l.status="fulfilled",l.value=s;for(var r=0;r<a.length;r++)(0,a[r])(s)},function(r){for(l.status="rejected",l.reason=r,r=0;r<a.length;r++)(0,a[r])(void 0)}),l}var Cm=B.S;B.S=function(t,s){uf=yt(),typeof s=="object"&&s!==null&&typeof s.then=="function"&&lg(t,s),Cm!==null&&Cm(t,s)};var Ja=T(null);function to(){var t=Ja.current;return t!==null?t:Ye.pooledCache}function Vi(t,s){s===null?de(Ja,Ja.current):de(Ja,s.pool)}function Am(){var t=to();return t===null?null:{parent:ot._currentValue,pool:t}}var Mn=Error(c(460)),so=Error(c(474)),Yi=Error(c(542)),Xi={then:function(){}};function Em(t){return t=t.status,t==="fulfilled"||t==="rejected"}function Tm(t,s,a){switch(a=t[a],a===void 0?t.push(s):a!==s&&(s.then(Us,Us),s=a),s.status){case"fulfilled":return s.value;case"rejected":throw t=s.reason,Mm(t),t;default:if(typeof s.status=="string")s.then(Us,Us);else{if(t=Ye,t!==null&&100<t.shellSuspendCounter)throw Error(c(482));t=s,t.status="pending",t.then(function(l){if(s.status==="pending"){var r=s;r.status="fulfilled",r.value=l}},function(l){if(s.status==="pending"){var r=s;r.status="rejected",r.reason=l}})}switch(s.status){case"fulfilled":return s.value;case"rejected":throw t=s.reason,Mm(t),t}throw Pa=s,Mn}}function Ia(t){try{var s=t._init;return s(t._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(Pa=a,Mn):a}}var Pa=null;function Rm(){if(Pa===null)throw Error(c(459));var t=Pa;return Pa=null,t}function Mm(t){if(t===Mn||t===Yi)throw Error(c(483))}var Dn=null,Al=0;function Qi(t){var s=Al;return Al+=1,Dn===null&&(Dn=[]),Tm(Dn,t,s)}function El(t,s){s=s.props.ref,t.ref=s!==void 0?s:null}function Fi(t,s){throw s.$$typeof===v?Error(c(525)):(t=Object.prototype.toString.call(s),Error(c(31,t==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":t)))}function Dm(t){function s(_,M){if(t){var H=_.deletions;H===null?(_.deletions=[M],_.flags|=16):H.push(M)}}function a(_,M){if(!t)return null;for(;M!==null;)s(_,M),M=M.sibling;return null}function l(_){for(var M=new Map;_!==null;)_.key!==null?M.set(_.key,_):M.set(_.index,_),_=_.sibling;return M}function r(_,M){return _=Bs(_,M),_.index=0,_.sibling=null,_}function o(_,M,H){return _.index=H,t?(H=_.alternate,H!==null?(H=H.index,H<M?(_.flags|=67108866,M):H):(_.flags|=67108866,M)):(_.flags|=1048576,M)}function x(_){return t&&_.alternate===null&&(_.flags|=67108866),_}function j(_,M,H,W){return M===null||M.tag!==6?(M=Vc(H,_.mode,W),M.return=_,M):(M=r(M,H),M.return=_,M)}function E(_,M,H,W){var pe=H.type;return pe===w?J(_,M,H.props.children,W,H.key):M!==null&&(M.elementType===pe||typeof pe=="object"&&pe!==null&&pe.$$typeof===A&&Ia(pe)===M.type)?(M=r(M,H.props),El(M,H),M.return=_,M):(M=Hi(H.type,H.key,H.props,null,_.mode,W),El(M,H),M.return=_,M)}function q(_,M,H,W){return M===null||M.tag!==4||M.stateNode.containerInfo!==H.containerInfo||M.stateNode.implementation!==H.implementation?(M=Yc(H,_.mode,W),M.return=_,M):(M=r(M,H.children||[]),M.return=_,M)}function J(_,M,H,W,pe){return M===null||M.tag!==7?(M=Xa(H,_.mode,W,pe),M.return=_,M):(M=r(M,H),M.return=_,M)}function ee(_,M,H){if(typeof M=="string"&&M!==""||typeof M=="number"||typeof M=="bigint")return M=Vc(""+M,_.mode,H),M.return=_,M;if(typeof M=="object"&&M!==null){switch(M.$$typeof){case k:return H=Hi(M.type,M.key,M.props,null,_.mode,H),El(H,M),H.return=_,H;case C:return M=Yc(M,_.mode,H),M.return=_,M;case A:return M=Ia(M),ee(_,M,H)}if(Y(M)||ce(M))return M=Xa(M,_.mode,H,null),M.return=_,M;if(typeof M.then=="function")return ee(_,Qi(M),H);if(M.$$typeof===D)return ee(_,Ki(_,M),H);Fi(_,M)}return null}function V(_,M,H,W){var pe=M!==null?M.key:null;if(typeof H=="string"&&H!==""||typeof H=="number"||typeof H=="bigint")return pe!==null?null:j(_,M,""+H,W);if(typeof H=="object"&&H!==null){switch(H.$$typeof){case k:return H.key===pe?E(_,M,H,W):null;case C:return H.key===pe?q(_,M,H,W):null;case A:return H=Ia(H),V(_,M,H,W)}if(Y(H)||ce(H))return pe!==null?null:J(_,M,H,W,null);if(typeof H.then=="function")return V(_,M,Qi(H),W);if(H.$$typeof===D)return V(_,M,Ki(_,H),W);Fi(_,H)}return null}function X(_,M,H,W,pe){if(typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint")return _=_.get(H)||null,j(M,_,""+W,pe);if(typeof W=="object"&&W!==null){switch(W.$$typeof){case k:return _=_.get(W.key===null?H:W.key)||null,E(M,_,W,pe);case C:return _=_.get(W.key===null?H:W.key)||null,q(M,_,W,pe);case A:return W=Ia(W),X(_,M,H,W,pe)}if(Y(W)||ce(W))return _=_.get(H)||null,J(M,_,W,pe,null);if(typeof W.then=="function")return X(_,M,H,Qi(W),pe);if(W.$$typeof===D)return X(_,M,H,Ki(M,W),pe);Fi(M,W)}return null}function xe(_,M,H,W){for(var pe=null,Le=null,he=M,ze=M=0,Re=null;he!==null&&ze<H.length;ze++){he.index>ze?(Re=he,he=null):Re=he.sibling;var _e=V(_,he,H[ze],W);if(_e===null){he===null&&(he=Re);break}t&&he&&_e.alternate===null&&s(_,he),M=o(_e,M,ze),Le===null?pe=_e:Le.sibling=_e,Le=_e,he=Re}if(ze===H.length)return a(_,he),De&&Hs(_,ze),pe;if(he===null){for(;ze<H.length;ze++)he=ee(_,H[ze],W),he!==null&&(M=o(he,M,ze),Le===null?pe=he:Le.sibling=he,Le=he);return De&&Hs(_,ze),pe}for(he=l(he);ze<H.length;ze++)Re=X(he,_,ze,H[ze],W),Re!==null&&(t&&Re.alternate!==null&&he.delete(Re.key===null?ze:Re.key),M=o(Re,M,ze),Le===null?pe=Re:Le.sibling=Re,Le=Re);return t&&he.forEach(function(Ra){return s(_,Ra)}),De&&Hs(_,ze),pe}function ge(_,M,H,W){if(H==null)throw Error(c(151));for(var pe=null,Le=null,he=M,ze=M=0,Re=null,_e=H.next();he!==null&&!_e.done;ze++,_e=H.next()){he.index>ze?(Re=he,he=null):Re=he.sibling;var Ra=V(_,he,_e.value,W);if(Ra===null){he===null&&(he=Re);break}t&&he&&Ra.alternate===null&&s(_,he),M=o(Ra,M,ze),Le===null?pe=Ra:Le.sibling=Ra,Le=Ra,he=Re}if(_e.done)return a(_,he),De&&Hs(_,ze),pe;if(he===null){for(;!_e.done;ze++,_e=H.next())_e=ee(_,_e.value,W),_e!==null&&(M=o(_e,M,ze),Le===null?pe=_e:Le.sibling=_e,Le=_e);return De&&Hs(_,ze),pe}for(he=l(he);!_e.done;ze++,_e=H.next())_e=X(he,_,ze,_e.value,W),_e!==null&&(t&&_e.alternate!==null&&he.delete(_e.key===null?ze:_e.key),M=o(_e,M,ze),Le===null?pe=_e:Le.sibling=_e,Le=_e);return t&&he.forEach(function(gb){return s(_,gb)}),De&&Hs(_,ze),pe}function Ve(_,M,H,W){if(typeof H=="object"&&H!==null&&H.type===w&&H.key===null&&(H=H.props.children),typeof H=="object"&&H!==null){switch(H.$$typeof){case k:e:{for(var pe=H.key;M!==null;){if(M.key===pe){if(pe=H.type,pe===w){if(M.tag===7){a(_,M.sibling),W=r(M,H.props.children),W.return=_,_=W;break e}}else if(M.elementType===pe||typeof pe=="object"&&pe!==null&&pe.$$typeof===A&&Ia(pe)===M.type){a(_,M.sibling),W=r(M,H.props),El(W,H),W.return=_,_=W;break e}a(_,M);break}else s(_,M);M=M.sibling}H.type===w?(W=Xa(H.props.children,_.mode,W,H.key),W.return=_,_=W):(W=Hi(H.type,H.key,H.props,null,_.mode,W),El(W,H),W.return=_,_=W)}return x(_);case C:e:{for(pe=H.key;M!==null;){if(M.key===pe)if(M.tag===4&&M.stateNode.containerInfo===H.containerInfo&&M.stateNode.implementation===H.implementation){a(_,M.sibling),W=r(M,H.children||[]),W.return=_,_=W;break e}else{a(_,M);break}else s(_,M);M=M.sibling}W=Yc(H,_.mode,W),W.return=_,_=W}return x(_);case A:return H=Ia(H),Ve(_,M,H,W)}if(Y(H))return xe(_,M,H,W);if(ce(H)){if(pe=ce(H),typeof pe!="function")throw Error(c(150));return H=pe.call(H),ge(_,M,H,W)}if(typeof H.then=="function")return Ve(_,M,Qi(H),W);if(H.$$typeof===D)return Ve(_,M,Ki(_,H),W);Fi(_,H)}return typeof H=="string"&&H!==""||typeof H=="number"||typeof H=="bigint"?(H=""+H,M!==null&&M.tag===6?(a(_,M.sibling),W=r(M,H),W.return=_,_=W):(a(_,M),W=Vc(H,_.mode,W),W.return=_,_=W),x(_)):a(_,M)}return function(_,M,H,W){try{Al=0;var pe=Ve(_,M,H,W);return Dn=null,pe}catch(he){if(he===Mn||he===Yi)throw he;var Le=Yt(29,he,null,_.mode);return Le.lanes=W,Le.return=_,Le}finally{}}}var Wa=Dm(!0),Om=Dm(!1),fa=!1;function ao(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function no(t,s){t=t.updateQueue,s.updateQueue===t&&(s.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function ha(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function pa(t,s,a){var l=t.updateQueue;if(l===null)return null;if(l=l.shared,(Ue&2)!==0){var r=l.pending;return r===null?s.next=s:(s.next=r.next,r.next=s),l.pending=s,s=Bi(t),gm(t,null,a),s}return $i(t,l,s,a),Bi(t)}function Tl(t,s,a){if(s=s.updateQueue,s!==null&&(s=s.shared,(a&4194048)!==0)){var l=s.lanes;l&=t.pendingLanes,a|=l,s.lanes=a,ku(t,a)}}function lo(t,s){var a=t.updateQueue,l=t.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var r=null,o=null;if(a=a.firstBaseUpdate,a!==null){do{var x={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};o===null?r=o=x:o=o.next=x,a=a.next}while(a!==null);o===null?r=o=s:o=o.next=s}else r=o=s;a={baseState:l.baseState,firstBaseUpdate:r,lastBaseUpdate:o,shared:l.shared,callbacks:l.callbacks},t.updateQueue=a;return}t=a.lastBaseUpdate,t===null?a.firstBaseUpdate=s:t.next=s,a.lastBaseUpdate=s}var io=!1;function Rl(){if(io){var t=Rn;if(t!==null)throw t}}function Ml(t,s,a,l){io=!1;var r=t.updateQueue;fa=!1;var o=r.firstBaseUpdate,x=r.lastBaseUpdate,j=r.shared.pending;if(j!==null){r.shared.pending=null;var E=j,q=E.next;E.next=null,x===null?o=q:x.next=q,x=E;var J=t.alternate;J!==null&&(J=J.updateQueue,j=J.lastBaseUpdate,j!==x&&(j===null?J.firstBaseUpdate=q:j.next=q,J.lastBaseUpdate=E))}if(o!==null){var ee=r.baseState;x=0,J=q=E=null,j=o;do{var V=j.lane&-536870913,X=V!==j.lane;if(X?(Te&V)===V:(l&V)===V){V!==0&&V===Tn&&(io=!0),J!==null&&(J=J.next={lane:0,tag:j.tag,payload:j.payload,callback:null,next:null});e:{var xe=t,ge=j;V=s;var Ve=a;switch(ge.tag){case 1:if(xe=ge.payload,typeof xe=="function"){ee=xe.call(Ve,ee,V);break e}ee=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=ge.payload,V=typeof xe=="function"?xe.call(Ve,ee,V):xe,V==null)break e;ee=y({},ee,V);break e;case 2:fa=!0}}V=j.callback,V!==null&&(t.flags|=64,X&&(t.flags|=8192),X=r.callbacks,X===null?r.callbacks=[V]:X.push(V))}else X={lane:V,tag:j.tag,payload:j.payload,callback:j.callback,next:null},J===null?(q=J=X,E=ee):J=J.next=X,x|=V;if(j=j.next,j===null){if(j=r.shared.pending,j===null)break;X=j,j=X.next,X.next=null,r.lastBaseUpdate=X,r.shared.pending=null}}while(!0);J===null&&(E=ee),r.baseState=E,r.firstBaseUpdate=q,r.lastBaseUpdate=J,o===null&&(r.shared.lanes=0),ja|=x,t.lanes=x,t.memoizedState=ee}}function Lm(t,s){if(typeof t!="function")throw Error(c(191,t));t.call(s)}function _m(t,s){var a=t.callbacks;if(a!==null)for(t.callbacks=null,t=0;t<a.length;t++)Lm(a[t],s)}var On=T(null),Zi=T(0);function Um(t,s){t=Is,de(Zi,t),de(On,s),Is=t|s.baseLanes}function ro(){de(Zi,Is),de(On,On.current)}function co(){Is=Zi.current,P(On),P(Zi)}var Xt=T(null),rs=null;function ga(t){var s=t.alternate;de(lt,lt.current&1),de(Xt,t),rs===null&&(s===null||On.current!==null||s.memoizedState!==null)&&(rs=t)}function oo(t){de(lt,lt.current),de(Xt,t),rs===null&&(rs=t)}function $m(t){t.tag===22?(de(lt,lt.current),de(Xt,t),rs===null&&(rs=t)):ba()}function ba(){de(lt,lt.current),de(Xt,Xt.current)}function Qt(t){P(Xt),rs===t&&(rs=null),P(lt)}var lt=T(0);function Ji(t){for(var s=t;s!==null;){if(s.tag===13){var a=s.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||pd(a)||gd(a)))return s}else if(s.tag===19&&(s.memoizedProps.revealOrder==="forwards"||s.memoizedProps.revealOrder==="backwards"||s.memoizedProps.revealOrder==="unstable_legacy-backwards"||s.memoizedProps.revealOrder==="together")){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var Ks=0,ke=null,Ge=null,dt=null,Ii=!1,Ln=!1,en=!1,Pi=0,Dl=0,_n=null,rg=0;function st(){throw Error(c(321))}function uo(t,s){if(s===null)return!1;for(var a=0;a<s.length&&a<t.length;a++)if(!Vt(t[a],s[a]))return!1;return!0}function mo(t,s,a,l,r,o){return Ks=o,ke=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,B.H=t===null||t.memoizedState===null?jx:Co,en=!1,o=a(l,r),en=!1,Ln&&(o=Hm(s,a,l,r)),Bm(t),o}function Bm(t){B.H=_l;var s=Ge!==null&&Ge.next!==null;if(Ks=0,dt=Ge=ke=null,Ii=!1,Dl=0,_n=null,s)throw Error(c(300));t===null||ut||(t=t.dependencies,t!==null&&Gi(t)&&(ut=!0))}function Hm(t,s,a,l){ke=t;var r=0;do{if(Ln&&(_n=null),Dl=0,Ln=!1,25<=r)throw Error(c(301));if(r+=1,dt=Ge=null,t.updateQueue!=null){var o=t.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}B.H=Nx,o=s(a,l)}while(Ln);return o}function cg(){var t=B.H,s=t.useState()[0];return s=typeof s.then=="function"?Ol(s):s,t=t.useState()[0],(Ge!==null?Ge.memoizedState:null)!==t&&(ke.flags|=1024),s}function xo(){var t=Pi!==0;return Pi=0,t}function fo(t,s,a){s.updateQueue=t.updateQueue,s.flags&=-2053,t.lanes&=~a}function ho(t){if(Ii){for(t=t.memoizedState;t!==null;){var s=t.queue;s!==null&&(s.pending=null),t=t.next}Ii=!1}Ks=0,dt=Ge=ke=null,Ln=!1,Dl=Pi=0,_n=null}function Mt(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return dt===null?ke.memoizedState=dt=t:dt=dt.next=t,dt}function it(){if(Ge===null){var t=ke.alternate;t=t!==null?t.memoizedState:null}else t=Ge.next;var s=dt===null?ke.memoizedState:dt.next;if(s!==null)dt=s,Ge=t;else{if(t===null)throw ke.alternate===null?Error(c(467)):Error(c(310));Ge=t,t={memoizedState:Ge.memoizedState,baseState:Ge.baseState,baseQueue:Ge.baseQueue,queue:Ge.queue,next:null},dt===null?ke.memoizedState=dt=t:dt=dt.next=t}return dt}function Wi(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ol(t){var s=Dl;return Dl+=1,_n===null&&(_n=[]),t=Tm(_n,t,s),s=ke,(dt===null?s.memoizedState:dt.next)===null&&(s=s.alternate,B.H=s===null||s.memoizedState===null?jx:Co),t}function er(t){if(t!==null&&typeof t=="object"){if(typeof t.then=="function")return Ol(t);if(t.$$typeof===D)return kt(t)}throw Error(c(438,String(t)))}function po(t){var s=null,a=ke.updateQueue;if(a!==null&&(s=a.memoCache),s==null){var l=ke.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(s={data:l.data.map(function(r){return r.slice()}),index:0})))}if(s==null&&(s={data:[],index:0}),a===null&&(a=Wi(),ke.updateQueue=a),a.memoCache=s,a=s.data[s.index],a===void 0)for(a=s.data[s.index]=Array(t),l=0;l<t;l++)a[l]=$;return s.index++,a}function Vs(t,s){return typeof s=="function"?s(t):s}function tr(t){var s=it();return go(s,Ge,t)}function go(t,s,a){var l=t.queue;if(l===null)throw Error(c(311));l.lastRenderedReducer=a;var r=t.baseQueue,o=l.pending;if(o!==null){if(r!==null){var x=r.next;r.next=o.next,o.next=x}s.baseQueue=r=o,l.pending=null}if(o=t.baseState,r===null)t.memoizedState=o;else{s=r.next;var j=x=null,E=null,q=s,J=!1;do{var ee=q.lane&-536870913;if(ee!==q.lane?(Te&ee)===ee:(Ks&ee)===ee){var V=q.revertLane;if(V===0)E!==null&&(E=E.next={lane:0,revertLane:0,gesture:null,action:q.action,hasEagerState:q.hasEagerState,eagerState:q.eagerState,next:null}),ee===Tn&&(J=!0);else if((Ks&V)===V){q=q.next,V===Tn&&(J=!0);continue}else ee={lane:0,revertLane:q.revertLane,gesture:null,action:q.action,hasEagerState:q.hasEagerState,eagerState:q.eagerState,next:null},E===null?(j=E=ee,x=o):E=E.next=ee,ke.lanes|=V,ja|=V;ee=q.action,en&&a(o,ee),o=q.hasEagerState?q.eagerState:a(o,ee)}else V={lane:ee,revertLane:q.revertLane,gesture:q.gesture,action:q.action,hasEagerState:q.hasEagerState,eagerState:q.eagerState,next:null},E===null?(j=E=V,x=o):E=E.next=V,ke.lanes|=ee,ja|=ee;q=q.next}while(q!==null&&q!==s);if(E===null?x=o:E.next=j,!Vt(o,t.memoizedState)&&(ut=!0,J&&(a=Rn,a!==null)))throw a;t.memoizedState=o,t.baseState=x,t.baseQueue=E,l.lastRenderedState=o}return r===null&&(l.lanes=0),[t.memoizedState,l.dispatch]}function bo(t){var s=it(),a=s.queue;if(a===null)throw Error(c(311));a.lastRenderedReducer=t;var l=a.dispatch,r=a.pending,o=s.memoizedState;if(r!==null){a.pending=null;var x=r=r.next;do o=t(o,x.action),x=x.next;while(x!==r);Vt(o,s.memoizedState)||(ut=!0),s.memoizedState=o,s.baseQueue===null&&(s.baseState=o),a.lastRenderedState=o}return[o,l]}function qm(t,s,a){var l=ke,r=it(),o=De;if(o){if(a===void 0)throw Error(c(407));a=a()}else a=s();var x=!Vt((Ge||r).memoizedState,a);if(x&&(r.memoizedState=a,ut=!0),r=r.queue,jo(Vm.bind(null,l,r,t),[t]),r.getSnapshot!==s||x||dt!==null&&dt.memoizedState.tag&1){if(l.flags|=2048,Un(9,{destroy:void 0},Km.bind(null,l,r,a,s),null),Ye===null)throw Error(c(349));o||(Ks&127)!==0||Gm(l,s,a)}return a}function Gm(t,s,a){t.flags|=16384,t={getSnapshot:s,value:a},s=ke.updateQueue,s===null?(s=Wi(),ke.updateQueue=s,s.stores=[t]):(a=s.stores,a===null?s.stores=[t]:a.push(t))}function Km(t,s,a,l){s.value=a,s.getSnapshot=l,Ym(s)&&Xm(t)}function Vm(t,s,a){return a(function(){Ym(s)&&Xm(t)})}function Ym(t){var s=t.getSnapshot;t=t.value;try{var a=s();return!Vt(t,a)}catch{return!0}}function Xm(t){var s=Ya(t,2);s!==null&&Gt(s,t,2)}function yo(t){var s=Mt();if(typeof t=="function"){var a=t;if(t=a(),en){ct(!0);try{a()}finally{ct(!1)}}}return s.memoizedState=s.baseState=t,s.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Vs,lastRenderedState:t},s}function Qm(t,s,a,l){return t.baseState=a,go(t,Ge,typeof l=="function"?l:Vs)}function og(t,s,a,l,r){if(nr(t))throw Error(c(485));if(t=s.action,t!==null){var o={payload:r,action:t,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(x){o.listeners.push(x)}};B.T!==null?a(!0):o.isTransition=!1,l(o),a=s.pending,a===null?(o.next=s.pending=o,Fm(s,o)):(o.next=a.next,s.pending=a.next=o)}}function Fm(t,s){var a=s.action,l=s.payload,r=t.state;if(s.isTransition){var o=B.T,x={};B.T=x;try{var j=a(r,l),E=B.S;E!==null&&E(x,j),Zm(t,s,j)}catch(q){vo(t,s,q)}finally{o!==null&&x.types!==null&&(o.types=x.types),B.T=o}}else try{o=a(r,l),Zm(t,s,o)}catch(q){vo(t,s,q)}}function Zm(t,s,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){Jm(t,s,l)},function(l){return vo(t,s,l)}):Jm(t,s,a)}function Jm(t,s,a){s.status="fulfilled",s.value=a,Im(s),t.state=a,s=t.pending,s!==null&&(a=s.next,a===s?t.pending=null:(a=a.next,s.next=a,Fm(t,a)))}function vo(t,s,a){var l=t.pending;if(t.pending=null,l!==null){l=l.next;do s.status="rejected",s.reason=a,Im(s),s=s.next;while(s!==l)}t.action=null}function Im(t){t=t.listeners;for(var s=0;s<t.length;s++)(0,t[s])()}function Pm(t,s){return s}function Wm(t,s){if(De){var a=Ye.formState;if(a!==null){e:{var l=ke;if(De){if(Qe){t:{for(var r=Qe,o=is;r.nodeType!==8;){if(!o){r=null;break t}if(r=cs(r.nextSibling),r===null){r=null;break t}}o=r.data,r=o==="F!"||o==="F"?r:null}if(r){Qe=cs(r.nextSibling),l=r.data==="F!";break e}}ma(l)}l=!1}l&&(s=a[0])}}return a=Mt(),a.memoizedState=a.baseState=s,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Pm,lastRenderedState:s},a.queue=l,a=bx.bind(null,ke,l),l.dispatch=a,l=yo(!1),o=zo.bind(null,ke,!1,l.queue),l=Mt(),r={state:s,dispatch:null,action:t,pending:null},l.queue=r,a=og.bind(null,ke,r,o,a),r.dispatch=a,l.memoizedState=t,[s,a,!1]}function ex(t){var s=it();return tx(s,Ge,t)}function tx(t,s,a){if(s=go(t,s,Pm)[0],t=tr(Vs)[0],typeof s=="object"&&s!==null&&typeof s.then=="function")try{var l=Ol(s)}catch(x){throw x===Mn?Yi:x}else l=s;s=it();var r=s.queue,o=r.dispatch;return a!==s.memoizedState&&(ke.flags|=2048,Un(9,{destroy:void 0},dg.bind(null,r,a),null)),[l,o,t]}function dg(t,s){t.action=s}function sx(t){var s=it(),a=Ge;if(a!==null)return tx(s,a,t);it(),s=s.memoizedState,a=it();var l=a.queue.dispatch;return a.memoizedState=t,[s,l,!1]}function Un(t,s,a,l){return t={tag:t,create:a,deps:l,inst:s,next:null},s=ke.updateQueue,s===null&&(s=Wi(),ke.updateQueue=s),a=s.lastEffect,a===null?s.lastEffect=t.next=t:(l=a.next,a.next=t,t.next=l,s.lastEffect=t),t}function ax(){return it().memoizedState}function sr(t,s,a,l){var r=Mt();ke.flags|=t,r.memoizedState=Un(1|s,{destroy:void 0},a,l===void 0?null:l)}function ar(t,s,a,l){var r=it();l=l===void 0?null:l;var o=r.memoizedState.inst;Ge!==null&&l!==null&&uo(l,Ge.memoizedState.deps)?r.memoizedState=Un(s,o,a,l):(ke.flags|=t,r.memoizedState=Un(1|s,o,a,l))}function nx(t,s){sr(8390656,8,t,s)}function jo(t,s){ar(2048,8,t,s)}function ug(t){ke.flags|=4;var s=ke.updateQueue;if(s===null)s=Wi(),ke.updateQueue=s,s.events=[t];else{var a=s.events;a===null?s.events=[t]:a.push(t)}}function lx(t){var s=it().memoizedState;return ug({ref:s,nextImpl:t}),function(){if((Ue&2)!==0)throw Error(c(440));return s.impl.apply(void 0,arguments)}}function ix(t,s){return ar(4,2,t,s)}function rx(t,s){return ar(4,4,t,s)}function cx(t,s){if(typeof s=="function"){t=t();var a=s(t);return function(){typeof a=="function"?a():s(null)}}if(s!=null)return t=t(),s.current=t,function(){s.current=null}}function ox(t,s,a){a=a!=null?a.concat([t]):null,ar(4,4,cx.bind(null,s,t),a)}function No(){}function dx(t,s){var a=it();s=s===void 0?null:s;var l=a.memoizedState;return s!==null&&uo(s,l[1])?l[0]:(a.memoizedState=[t,s],t)}function ux(t,s){var a=it();s=s===void 0?null:s;var l=a.memoizedState;if(s!==null&&uo(s,l[1]))return l[0];if(l=t(),en){ct(!0);try{t()}finally{ct(!1)}}return a.memoizedState=[l,s],l}function wo(t,s,a){return a===void 0||(Ks&1073741824)!==0&&(Te&261930)===0?t.memoizedState=s:(t.memoizedState=a,t=xf(),ke.lanes|=t,ja|=t,a)}function mx(t,s,a,l){return Vt(a,s)?a:On.current!==null?(t=wo(t,a,l),Vt(t,s)||(ut=!0),t):(Ks&42)===0||(Ks&1073741824)!==0&&(Te&261930)===0?(ut=!0,t.memoizedState=a):(t=xf(),ke.lanes|=t,ja|=t,s)}function xx(t,s,a,l,r){var o=ne.p;ne.p=o!==0&&8>o?o:8;var x=B.T,j={};B.T=j,zo(t,!1,s,a);try{var E=r(),q=B.S;if(q!==null&&q(j,E),E!==null&&typeof E=="object"&&typeof E.then=="function"){var J=ig(E,l);Ll(t,s,J,Jt(t))}else Ll(t,s,l,Jt(t))}catch(ee){Ll(t,s,{then:function(){},status:"rejected",reason:ee},Jt())}finally{ne.p=o,x!==null&&j.types!==null&&(x.types=j.types),B.T=x}}function mg(){}function So(t,s,a,l){if(t.tag!==5)throw Error(c(476));var r=fx(t).queue;xx(t,r,s,me,a===null?mg:function(){return hx(t),a(l)})}function fx(t){var s=t.memoizedState;if(s!==null)return s;s={memoizedState:me,baseState:me,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Vs,lastRenderedState:me},next:null};var a={};return s.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Vs,lastRenderedState:a},next:null},t.memoizedState=s,t=t.alternate,t!==null&&(t.memoizedState=s),s}function hx(t){var s=fx(t);s.next===null&&(s=t.alternate.memoizedState),Ll(t,s.next.queue,{},Jt())}function ko(){return kt(Pl)}function px(){return it().memoizedState}function gx(){return it().memoizedState}function xg(t){for(var s=t.return;s!==null;){switch(s.tag){case 24:case 3:var a=Jt();t=ha(a);var l=pa(s,t,a);l!==null&&(Gt(l,s,a),Tl(l,s,a)),s={cache:Wc()},t.payload=s;return}s=s.return}}function fg(t,s,a){var l=Jt();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},nr(t)?yx(s,a):(a=Gc(t,s,a,l),a!==null&&(Gt(a,t,l),vx(a,s,l)))}function bx(t,s,a){var l=Jt();Ll(t,s,a,l)}function Ll(t,s,a,l){var r={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(nr(t))yx(s,r);else{var o=t.alternate;if(t.lanes===0&&(o===null||o.lanes===0)&&(o=s.lastRenderedReducer,o!==null))try{var x=s.lastRenderedState,j=o(x,a);if(r.hasEagerState=!0,r.eagerState=j,Vt(j,x))return $i(t,s,r,0),Ye===null&&Ui(),!1}catch{}finally{}if(a=Gc(t,s,r,l),a!==null)return Gt(a,t,l),vx(a,s,l),!0}return!1}function zo(t,s,a,l){if(l={lane:2,revertLane:nd(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},nr(t)){if(s)throw Error(c(479))}else s=Gc(t,a,l,2),s!==null&&Gt(s,t,2)}function nr(t){var s=t.alternate;return t===ke||s!==null&&s===ke}function yx(t,s){Ln=Ii=!0;var a=t.pending;a===null?s.next=s:(s.next=a.next,a.next=s),t.pending=s}function vx(t,s,a){if((a&4194048)!==0){var l=s.lanes;l&=t.pendingLanes,a|=l,s.lanes=a,ku(t,a)}}var _l={readContext:kt,use:er,useCallback:st,useContext:st,useEffect:st,useImperativeHandle:st,useLayoutEffect:st,useInsertionEffect:st,useMemo:st,useReducer:st,useRef:st,useState:st,useDebugValue:st,useDeferredValue:st,useTransition:st,useSyncExternalStore:st,useId:st,useHostTransitionStatus:st,useFormState:st,useActionState:st,useOptimistic:st,useMemoCache:st,useCacheRefresh:st};_l.useEffectEvent=st;var jx={readContext:kt,use:er,useCallback:function(t,s){return Mt().memoizedState=[t,s===void 0?null:s],t},useContext:kt,useEffect:nx,useImperativeHandle:function(t,s,a){a=a!=null?a.concat([t]):null,sr(4194308,4,cx.bind(null,s,t),a)},useLayoutEffect:function(t,s){return sr(4194308,4,t,s)},useInsertionEffect:function(t,s){sr(4,2,t,s)},useMemo:function(t,s){var a=Mt();s=s===void 0?null:s;var l=t();if(en){ct(!0);try{t()}finally{ct(!1)}}return a.memoizedState=[l,s],l},useReducer:function(t,s,a){var l=Mt();if(a!==void 0){var r=a(s);if(en){ct(!0);try{a(s)}finally{ct(!1)}}}else r=s;return l.memoizedState=l.baseState=r,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:r},l.queue=t,t=t.dispatch=fg.bind(null,ke,t),[l.memoizedState,t]},useRef:function(t){var s=Mt();return t={current:t},s.memoizedState=t},useState:function(t){t=yo(t);var s=t.queue,a=bx.bind(null,ke,s);return s.dispatch=a,[t.memoizedState,a]},useDebugValue:No,useDeferredValue:function(t,s){var a=Mt();return wo(a,t,s)},useTransition:function(){var t=yo(!1);return t=xx.bind(null,ke,t.queue,!0,!1),Mt().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,s,a){var l=ke,r=Mt();if(De){if(a===void 0)throw Error(c(407));a=a()}else{if(a=s(),Ye===null)throw Error(c(349));(Te&127)!==0||Gm(l,s,a)}r.memoizedState=a;var o={value:a,getSnapshot:s};return r.queue=o,nx(Vm.bind(null,l,o,t),[t]),l.flags|=2048,Un(9,{destroy:void 0},Km.bind(null,l,o,a,s),null),a},useId:function(){var t=Mt(),s=Ye.identifierPrefix;if(De){var a=ks,l=Ss;a=(l&~(1<<32-Rt(l)-1)).toString(32)+a,s="_"+s+"R_"+a,a=Pi++,0<a&&(s+="H"+a.toString(32)),s+="_"}else a=rg++,s="_"+s+"r_"+a.toString(32)+"_";return t.memoizedState=s},useHostTransitionStatus:ko,useFormState:Wm,useActionState:Wm,useOptimistic:function(t){var s=Mt();s.memoizedState=s.baseState=t;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return s.queue=a,s=zo.bind(null,ke,!0,a),a.dispatch=s,[t,s]},useMemoCache:po,useCacheRefresh:function(){return Mt().memoizedState=xg.bind(null,ke)},useEffectEvent:function(t){var s=Mt(),a={impl:t};return s.memoizedState=a,function(){if((Ue&2)!==0)throw Error(c(440));return a.impl.apply(void 0,arguments)}}},Co={readContext:kt,use:er,useCallback:dx,useContext:kt,useEffect:jo,useImperativeHandle:ox,useInsertionEffect:ix,useLayoutEffect:rx,useMemo:ux,useReducer:tr,useRef:ax,useState:function(){return tr(Vs)},useDebugValue:No,useDeferredValue:function(t,s){var a=it();return mx(a,Ge.memoizedState,t,s)},useTransition:function(){var t=tr(Vs)[0],s=it().memoizedState;return[typeof t=="boolean"?t:Ol(t),s]},useSyncExternalStore:qm,useId:px,useHostTransitionStatus:ko,useFormState:ex,useActionState:ex,useOptimistic:function(t,s){var a=it();return Qm(a,Ge,t,s)},useMemoCache:po,useCacheRefresh:gx};Co.useEffectEvent=lx;var Nx={readContext:kt,use:er,useCallback:dx,useContext:kt,useEffect:jo,useImperativeHandle:ox,useInsertionEffect:ix,useLayoutEffect:rx,useMemo:ux,useReducer:bo,useRef:ax,useState:function(){return bo(Vs)},useDebugValue:No,useDeferredValue:function(t,s){var a=it();return Ge===null?wo(a,t,s):mx(a,Ge.memoizedState,t,s)},useTransition:function(){var t=bo(Vs)[0],s=it().memoizedState;return[typeof t=="boolean"?t:Ol(t),s]},useSyncExternalStore:qm,useId:px,useHostTransitionStatus:ko,useFormState:sx,useActionState:sx,useOptimistic:function(t,s){var a=it();return Ge!==null?Qm(a,Ge,t,s):(a.baseState=t,[t,a.queue.dispatch])},useMemoCache:po,useCacheRefresh:gx};Nx.useEffectEvent=lx;function Ao(t,s,a,l){s=t.memoizedState,a=a(l,s),a=a==null?s:y({},s,a),t.memoizedState=a,t.lanes===0&&(t.updateQueue.baseState=a)}var Eo={enqueueSetState:function(t,s,a){t=t._reactInternals;var l=Jt(),r=ha(l);r.payload=s,a!=null&&(r.callback=a),s=pa(t,r,l),s!==null&&(Gt(s,t,l),Tl(s,t,l))},enqueueReplaceState:function(t,s,a){t=t._reactInternals;var l=Jt(),r=ha(l);r.tag=1,r.payload=s,a!=null&&(r.callback=a),s=pa(t,r,l),s!==null&&(Gt(s,t,l),Tl(s,t,l))},enqueueForceUpdate:function(t,s){t=t._reactInternals;var a=Jt(),l=ha(a);l.tag=2,s!=null&&(l.callback=s),s=pa(t,l,a),s!==null&&(Gt(s,t,a),Tl(s,t,a))}};function wx(t,s,a,l,r,o,x){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(l,o,x):s.prototype&&s.prototype.isPureReactComponent?!Nl(a,l)||!Nl(r,o):!0}function Sx(t,s,a,l){t=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(a,l),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(a,l),s.state!==t&&Eo.enqueueReplaceState(s,s.state,null)}function tn(t,s){var a=s;if("ref"in s){a={};for(var l in s)l!=="ref"&&(a[l]=s[l])}if(t=t.defaultProps){a===s&&(a=y({},a));for(var r in t)a[r]===void 0&&(a[r]=t[r])}return a}function kx(t){_i(t)}function zx(t){console.error(t)}function Cx(t){_i(t)}function lr(t,s){try{var a=t.onUncaughtError;a(s.value,{componentStack:s.stack})}catch(l){setTimeout(function(){throw l})}}function Ax(t,s,a){try{var l=t.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:s.tag===1?s.stateNode:null})}catch(r){setTimeout(function(){throw r})}}function To(t,s,a){return a=ha(a),a.tag=3,a.payload={element:null},a.callback=function(){lr(t,s)},a}function Ex(t){return t=ha(t),t.tag=3,t}function Tx(t,s,a,l){var r=a.type.getDerivedStateFromError;if(typeof r=="function"){var o=l.value;t.payload=function(){return r(o)},t.callback=function(){Ax(s,a,l)}}var x=a.stateNode;x!==null&&typeof x.componentDidCatch=="function"&&(t.callback=function(){Ax(s,a,l),typeof r!="function"&&(Na===null?Na=new Set([this]):Na.add(this));var j=l.stack;this.componentDidCatch(l.value,{componentStack:j!==null?j:""})})}function hg(t,s,a,l,r){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(s=a.alternate,s!==null&&En(s,a,r,!0),a=Xt.current,a!==null){switch(a.tag){case 31:case 13:return rs===null?gr():a.alternate===null&&at===0&&(at=3),a.flags&=-257,a.flags|=65536,a.lanes=r,l===Xi?a.flags|=16384:(s=a.updateQueue,s===null?a.updateQueue=new Set([l]):s.add(l),td(t,l,r)),!1;case 22:return a.flags|=65536,l===Xi?a.flags|=16384:(s=a.updateQueue,s===null?(s={transitions:null,markerInstances:null,retryQueue:new Set([l])},a.updateQueue=s):(a=s.retryQueue,a===null?s.retryQueue=new Set([l]):a.add(l)),td(t,l,r)),!1}throw Error(c(435,a.tag))}return td(t,l,r),gr(),!1}if(De)return s=Xt.current,s!==null?((s.flags&65536)===0&&(s.flags|=256),s.flags|=65536,s.lanes=r,l!==Fc&&(t=Error(c(422),{cause:l}),kl(as(t,a)))):(l!==Fc&&(s=Error(c(423),{cause:l}),kl(as(s,a))),t=t.current.alternate,t.flags|=65536,r&=-r,t.lanes|=r,l=as(l,a),r=To(t.stateNode,l,r),lo(t,r),at!==4&&(at=2)),!1;var o=Error(c(520),{cause:l});if(o=as(o,a),Vl===null?Vl=[o]:Vl.push(o),at!==4&&(at=2),s===null)return!0;l=as(l,a),a=s;do{switch(a.tag){case 3:return a.flags|=65536,t=r&-r,a.lanes|=t,t=To(a.stateNode,l,t),lo(a,t),!1;case 1:if(s=a.type,o=a.stateNode,(a.flags&128)===0&&(typeof s.getDerivedStateFromError=="function"||o!==null&&typeof o.componentDidCatch=="function"&&(Na===null||!Na.has(o))))return a.flags|=65536,r&=-r,a.lanes|=r,r=Ex(r),Tx(r,t,a,l),lo(a,r),!1}a=a.return}while(a!==null);return!1}var Ro=Error(c(461)),ut=!1;function zt(t,s,a,l){s.child=t===null?Om(s,null,a,l):Wa(s,t.child,a,l)}function Rx(t,s,a,l,r){a=a.render;var o=s.ref;if("ref"in l){var x={};for(var j in l)j!=="ref"&&(x[j]=l[j])}else x=l;return Za(s),l=mo(t,s,a,x,o,r),j=xo(),t!==null&&!ut?(fo(t,s,r),Ys(t,s,r)):(De&&j&&Xc(s),s.flags|=1,zt(t,s,l,r),s.child)}function Mx(t,s,a,l,r){if(t===null){var o=a.type;return typeof o=="function"&&!Kc(o)&&o.defaultProps===void 0&&a.compare===null?(s.tag=15,s.type=o,Dx(t,s,o,l,r)):(t=Hi(a.type,null,l,s,s.mode,r),t.ref=s.ref,t.return=s,s.child=t)}if(o=t.child,!Bo(t,r)){var x=o.memoizedProps;if(a=a.compare,a=a!==null?a:Nl,a(x,l)&&t.ref===s.ref)return Ys(t,s,r)}return s.flags|=1,t=Bs(o,l),t.ref=s.ref,t.return=s,s.child=t}function Dx(t,s,a,l,r){if(t!==null){var o=t.memoizedProps;if(Nl(o,l)&&t.ref===s.ref)if(ut=!1,s.pendingProps=l=o,Bo(t,r))(t.flags&131072)!==0&&(ut=!0);else return s.lanes=t.lanes,Ys(t,s,r)}return Mo(t,s,a,l,r)}function Ox(t,s,a,l){var r=l.children,o=t!==null?t.memoizedState:null;if(t===null&&s.stateNode===null&&(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((s.flags&128)!==0){if(o=o!==null?o.baseLanes|a:a,t!==null){for(l=s.child=t.child,r=0;l!==null;)r=r|l.lanes|l.childLanes,l=l.sibling;l=r&~o}else l=0,s.child=null;return Lx(t,s,o,a,l)}if((a&536870912)!==0)s.memoizedState={baseLanes:0,cachePool:null},t!==null&&Vi(s,o!==null?o.cachePool:null),o!==null?Um(s,o):ro(),$m(s);else return l=s.lanes=536870912,Lx(t,s,o!==null?o.baseLanes|a:a,a,l)}else o!==null?(Vi(s,o.cachePool),Um(s,o),ba(),s.memoizedState=null):(t!==null&&Vi(s,null),ro(),ba());return zt(t,s,r,a),s.child}function Ul(t,s){return t!==null&&t.tag===22||s.stateNode!==null||(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.sibling}function Lx(t,s,a,l,r){var o=to();return o=o===null?null:{parent:ot._currentValue,pool:o},s.memoizedState={baseLanes:a,cachePool:o},t!==null&&Vi(s,null),ro(),$m(s),t!==null&&En(t,s,l,!0),s.childLanes=r,null}function ir(t,s){return s=cr({mode:s.mode,children:s.children},t.mode),s.ref=t.ref,t.child=s,s.return=t,s}function _x(t,s,a){return Wa(s,t.child,null,a),t=ir(s,s.pendingProps),t.flags|=2,Qt(s),s.memoizedState=null,t}function pg(t,s,a){var l=s.pendingProps,r=(s.flags&128)!==0;if(s.flags&=-129,t===null){if(De){if(l.mode==="hidden")return t=ir(s,l),s.lanes=536870912,Ul(null,t);if(oo(s),(t=Qe)?(t=Zf(t,is),t=t!==null&&t.data==="&"?t:null,t!==null&&(s.memoizedState={dehydrated:t,treeContext:da!==null?{id:Ss,overflow:ks}:null,retryLane:536870912,hydrationErrors:null},a=ym(t),a.return=s,s.child=a,St=s,Qe=null)):t=null,t===null)throw ma(s);return s.lanes=536870912,null}return ir(s,l)}var o=t.memoizedState;if(o!==null){var x=o.dehydrated;if(oo(s),r)if(s.flags&256)s.flags&=-257,s=_x(t,s,a);else if(s.memoizedState!==null)s.child=t.child,s.flags|=128,s=null;else throw Error(c(558));else if(ut||En(t,s,a,!1),r=(a&t.childLanes)!==0,ut||r){if(l=Ye,l!==null&&(x=zu(l,a),x!==0&&x!==o.retryLane))throw o.retryLane=x,Ya(t,x),Gt(l,t,x),Ro;gr(),s=_x(t,s,a)}else t=o.treeContext,Qe=cs(x.nextSibling),St=s,De=!0,ua=null,is=!1,t!==null&&Nm(s,t),s=ir(s,l),s.flags|=4096;return s}return t=Bs(t.child,{mode:l.mode,children:l.children}),t.ref=s.ref,s.child=t,t.return=s,t}function rr(t,s){var a=s.ref;if(a===null)t!==null&&t.ref!==null&&(s.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(c(284));(t===null||t.ref!==a)&&(s.flags|=4194816)}}function Mo(t,s,a,l,r){return Za(s),a=mo(t,s,a,l,void 0,r),l=xo(),t!==null&&!ut?(fo(t,s,r),Ys(t,s,r)):(De&&l&&Xc(s),s.flags|=1,zt(t,s,a,r),s.child)}function Ux(t,s,a,l,r,o){return Za(s),s.updateQueue=null,a=Hm(s,l,a,r),Bm(t),l=xo(),t!==null&&!ut?(fo(t,s,o),Ys(t,s,o)):(De&&l&&Xc(s),s.flags|=1,zt(t,s,a,o),s.child)}function $x(t,s,a,l,r){if(Za(s),s.stateNode===null){var o=kn,x=a.contextType;typeof x=="object"&&x!==null&&(o=kt(x)),o=new a(l,o),s.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,o.updater=Eo,s.stateNode=o,o._reactInternals=s,o=s.stateNode,o.props=l,o.state=s.memoizedState,o.refs={},ao(s),x=a.contextType,o.context=typeof x=="object"&&x!==null?kt(x):kn,o.state=s.memoizedState,x=a.getDerivedStateFromProps,typeof x=="function"&&(Ao(s,a,x,l),o.state=s.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof o.getSnapshotBeforeUpdate=="function"||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(x=o.state,typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount(),x!==o.state&&Eo.enqueueReplaceState(o,o.state,null),Ml(s,l,o,r),Rl(),o.state=s.memoizedState),typeof o.componentDidMount=="function"&&(s.flags|=4194308),l=!0}else if(t===null){o=s.stateNode;var j=s.memoizedProps,E=tn(a,j);o.props=E;var q=o.context,J=a.contextType;x=kn,typeof J=="object"&&J!==null&&(x=kt(J));var ee=a.getDerivedStateFromProps;J=typeof ee=="function"||typeof o.getSnapshotBeforeUpdate=="function",j=s.pendingProps!==j,J||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(j||q!==x)&&Sx(s,o,l,x),fa=!1;var V=s.memoizedState;o.state=V,Ml(s,l,o,r),Rl(),q=s.memoizedState,j||V!==q||fa?(typeof ee=="function"&&(Ao(s,a,ee,l),q=s.memoizedState),(E=fa||wx(s,a,E,l,V,q,x))?(J||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(s.flags|=4194308)):(typeof o.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=l,s.memoizedState=q),o.props=l,o.state=q,o.context=x,l=E):(typeof o.componentDidMount=="function"&&(s.flags|=4194308),l=!1)}else{o=s.stateNode,no(t,s),x=s.memoizedProps,J=tn(a,x),o.props=J,ee=s.pendingProps,V=o.context,q=a.contextType,E=kn,typeof q=="object"&&q!==null&&(E=kt(q)),j=a.getDerivedStateFromProps,(q=typeof j=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(x!==ee||V!==E)&&Sx(s,o,l,E),fa=!1,V=s.memoizedState,o.state=V,Ml(s,l,o,r),Rl();var X=s.memoizedState;x!==ee||V!==X||fa||t!==null&&t.dependencies!==null&&Gi(t.dependencies)?(typeof j=="function"&&(Ao(s,a,j,l),X=s.memoizedState),(J=fa||wx(s,a,J,l,V,X,E)||t!==null&&t.dependencies!==null&&Gi(t.dependencies))?(q||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(l,X,E),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(l,X,E)),typeof o.componentDidUpdate=="function"&&(s.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof o.componentDidUpdate!="function"||x===t.memoizedProps&&V===t.memoizedState||(s.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||x===t.memoizedProps&&V===t.memoizedState||(s.flags|=1024),s.memoizedProps=l,s.memoizedState=X),o.props=l,o.state=X,o.context=E,l=J):(typeof o.componentDidUpdate!="function"||x===t.memoizedProps&&V===t.memoizedState||(s.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||x===t.memoizedProps&&V===t.memoizedState||(s.flags|=1024),l=!1)}return o=l,rr(t,s),l=(s.flags&128)!==0,o||l?(o=s.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:o.render(),s.flags|=1,t!==null&&l?(s.child=Wa(s,t.child,null,r),s.child=Wa(s,null,a,r)):zt(t,s,a,r),s.memoizedState=o.state,t=s.child):t=Ys(t,s,r),t}function Bx(t,s,a,l){return Qa(),s.flags|=256,zt(t,s,a,l),s.child}var Do={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Oo(t){return{baseLanes:t,cachePool:Am()}}function Lo(t,s,a){return t=t!==null?t.childLanes&~a:0,s&&(t|=Zt),t}function Hx(t,s,a){var l=s.pendingProps,r=!1,o=(s.flags&128)!==0,x;if((x=o)||(x=t!==null&&t.memoizedState===null?!1:(lt.current&2)!==0),x&&(r=!0,s.flags&=-129),x=(s.flags&32)!==0,s.flags&=-33,t===null){if(De){if(r?ga(s):ba(),(t=Qe)?(t=Zf(t,is),t=t!==null&&t.data!=="&"?t:null,t!==null&&(s.memoizedState={dehydrated:t,treeContext:da!==null?{id:Ss,overflow:ks}:null,retryLane:536870912,hydrationErrors:null},a=ym(t),a.return=s,s.child=a,St=s,Qe=null)):t=null,t===null)throw ma(s);return gd(t)?s.lanes=32:s.lanes=536870912,null}var j=l.children;return l=l.fallback,r?(ba(),r=s.mode,j=cr({mode:"hidden",children:j},r),l=Xa(l,r,a,null),j.return=s,l.return=s,j.sibling=l,s.child=j,l=s.child,l.memoizedState=Oo(a),l.childLanes=Lo(t,x,a),s.memoizedState=Do,Ul(null,l)):(ga(s),_o(s,j))}var E=t.memoizedState;if(E!==null&&(j=E.dehydrated,j!==null)){if(o)s.flags&256?(ga(s),s.flags&=-257,s=Uo(t,s,a)):s.memoizedState!==null?(ba(),s.child=t.child,s.flags|=128,s=null):(ba(),j=l.fallback,r=s.mode,l=cr({mode:"visible",children:l.children},r),j=Xa(j,r,a,null),j.flags|=2,l.return=s,j.return=s,l.sibling=j,s.child=l,Wa(s,t.child,null,a),l=s.child,l.memoizedState=Oo(a),l.childLanes=Lo(t,x,a),s.memoizedState=Do,s=Ul(null,l));else if(ga(s),gd(j)){if(x=j.nextSibling&&j.nextSibling.dataset,x)var q=x.dgst;x=q,l=Error(c(419)),l.stack="",l.digest=x,kl({value:l,source:null,stack:null}),s=Uo(t,s,a)}else if(ut||En(t,s,a,!1),x=(a&t.childLanes)!==0,ut||x){if(x=Ye,x!==null&&(l=zu(x,a),l!==0&&l!==E.retryLane))throw E.retryLane=l,Ya(t,l),Gt(x,t,l),Ro;pd(j)||gr(),s=Uo(t,s,a)}else pd(j)?(s.flags|=192,s.child=t.child,s=null):(t=E.treeContext,Qe=cs(j.nextSibling),St=s,De=!0,ua=null,is=!1,t!==null&&Nm(s,t),s=_o(s,l.children),s.flags|=4096);return s}return r?(ba(),j=l.fallback,r=s.mode,E=t.child,q=E.sibling,l=Bs(E,{mode:"hidden",children:l.children}),l.subtreeFlags=E.subtreeFlags&65011712,q!==null?j=Bs(q,j):(j=Xa(j,r,a,null),j.flags|=2),j.return=s,l.return=s,l.sibling=j,s.child=l,Ul(null,l),l=s.child,j=t.child.memoizedState,j===null?j=Oo(a):(r=j.cachePool,r!==null?(E=ot._currentValue,r=r.parent!==E?{parent:E,pool:E}:r):r=Am(),j={baseLanes:j.baseLanes|a,cachePool:r}),l.memoizedState=j,l.childLanes=Lo(t,x,a),s.memoizedState=Do,Ul(t.child,l)):(ga(s),a=t.child,t=a.sibling,a=Bs(a,{mode:"visible",children:l.children}),a.return=s,a.sibling=null,t!==null&&(x=s.deletions,x===null?(s.deletions=[t],s.flags|=16):x.push(t)),s.child=a,s.memoizedState=null,a)}function _o(t,s){return s=cr({mode:"visible",children:s},t.mode),s.return=t,t.child=s}function cr(t,s){return t=Yt(22,t,null,s),t.lanes=0,t}function Uo(t,s,a){return Wa(s,t.child,null,a),t=_o(s,s.pendingProps.children),t.flags|=2,s.memoizedState=null,t}function qx(t,s,a){t.lanes|=s;var l=t.alternate;l!==null&&(l.lanes|=s),Ic(t.return,s,a)}function $o(t,s,a,l,r,o){var x=t.memoizedState;x===null?t.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:r,treeForkCount:o}:(x.isBackwards=s,x.rendering=null,x.renderingStartTime=0,x.last=l,x.tail=a,x.tailMode=r,x.treeForkCount=o)}function Gx(t,s,a){var l=s.pendingProps,r=l.revealOrder,o=l.tail;l=l.children;var x=lt.current,j=(x&2)!==0;if(j?(x=x&1|2,s.flags|=128):x&=1,de(lt,x),zt(t,s,l,a),l=De?Sl:0,!j&&t!==null&&(t.flags&128)!==0)e:for(t=s.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&qx(t,a,s);else if(t.tag===19)qx(t,a,s);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===s)break e;for(;t.sibling===null;){if(t.return===null||t.return===s)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}switch(r){case"forwards":for(a=s.child,r=null;a!==null;)t=a.alternate,t!==null&&Ji(t)===null&&(r=a),a=a.sibling;a=r,a===null?(r=s.child,s.child=null):(r=a.sibling,a.sibling=null),$o(s,!1,r,a,o,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,r=s.child,s.child=null;r!==null;){if(t=r.alternate,t!==null&&Ji(t)===null){s.child=r;break}t=r.sibling,r.sibling=a,a=r,r=t}$o(s,!0,a,null,o,l);break;case"together":$o(s,!1,null,null,void 0,l);break;default:s.memoizedState=null}return s.child}function Ys(t,s,a){if(t!==null&&(s.dependencies=t.dependencies),ja|=s.lanes,(a&s.childLanes)===0)if(t!==null){if(En(t,s,a,!1),(a&s.childLanes)===0)return null}else return null;if(t!==null&&s.child!==t.child)throw Error(c(153));if(s.child!==null){for(t=s.child,a=Bs(t,t.pendingProps),s.child=a,a.return=s;t.sibling!==null;)t=t.sibling,a=a.sibling=Bs(t,t.pendingProps),a.return=s;a.sibling=null}return s.child}function Bo(t,s){return(t.lanes&s)!==0?!0:(t=t.dependencies,!!(t!==null&&Gi(t)))}function gg(t,s,a){switch(s.tag){case 3:Ce(s,s.stateNode.containerInfo),xa(s,ot,t.memoizedState.cache),Qa();break;case 27:case 5:tt(s);break;case 4:Ce(s,s.stateNode.containerInfo);break;case 10:xa(s,s.type,s.memoizedProps.value);break;case 31:if(s.memoizedState!==null)return s.flags|=128,oo(s),null;break;case 13:var l=s.memoizedState;if(l!==null)return l.dehydrated!==null?(ga(s),s.flags|=128,null):(a&s.child.childLanes)!==0?Hx(t,s,a):(ga(s),t=Ys(t,s,a),t!==null?t.sibling:null);ga(s);break;case 19:var r=(t.flags&128)!==0;if(l=(a&s.childLanes)!==0,l||(En(t,s,a,!1),l=(a&s.childLanes)!==0),r){if(l)return Gx(t,s,a);s.flags|=128}if(r=s.memoizedState,r!==null&&(r.rendering=null,r.tail=null,r.lastEffect=null),de(lt,lt.current),l)break;return null;case 22:return s.lanes=0,Ox(t,s,a,s.pendingProps);case 24:xa(s,ot,t.memoizedState.cache)}return Ys(t,s,a)}function Kx(t,s,a){if(t!==null)if(t.memoizedProps!==s.pendingProps)ut=!0;else{if(!Bo(t,a)&&(s.flags&128)===0)return ut=!1,gg(t,s,a);ut=(t.flags&131072)!==0}else ut=!1,De&&(s.flags&1048576)!==0&&jm(s,Sl,s.index);switch(s.lanes=0,s.tag){case 16:e:{var l=s.pendingProps;if(t=Ia(s.elementType),s.type=t,typeof t=="function")Kc(t)?(l=tn(t,l),s.tag=1,s=$x(null,s,t,l,a)):(s.tag=0,s=Mo(null,s,t,l,a));else{if(t!=null){var r=t.$$typeof;if(r===O){s.tag=11,s=Rx(null,s,t,l,a);break e}else if(r===U){s.tag=14,s=Mx(null,s,t,l,a);break e}}throw s=le(t)||t,Error(c(306,s,""))}}return s;case 0:return Mo(t,s,s.type,s.pendingProps,a);case 1:return l=s.type,r=tn(l,s.pendingProps),$x(t,s,l,r,a);case 3:e:{if(Ce(s,s.stateNode.containerInfo),t===null)throw Error(c(387));l=s.pendingProps;var o=s.memoizedState;r=o.element,no(t,s),Ml(s,l,null,a);var x=s.memoizedState;if(l=x.cache,xa(s,ot,l),l!==o.cache&&Pc(s,[ot],a,!0),Rl(),l=x.element,o.isDehydrated)if(o={element:l,isDehydrated:!1,cache:x.cache},s.updateQueue.baseState=o,s.memoizedState=o,s.flags&256){s=Bx(t,s,l,a);break e}else if(l!==r){r=as(Error(c(424)),s),kl(r),s=Bx(t,s,l,a);break e}else{switch(t=s.stateNode.containerInfo,t.nodeType){case 9:t=t.body;break;default:t=t.nodeName==="HTML"?t.ownerDocument.body:t}for(Qe=cs(t.firstChild),St=s,De=!0,ua=null,is=!0,a=Om(s,null,l,a),s.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(Qa(),l===r){s=Ys(t,s,a);break e}zt(t,s,l,a)}s=s.child}return s;case 26:return rr(t,s),t===null?(a=th(s.type,null,s.pendingProps,null))?s.memoizedState=a:De||(a=s.type,t=s.pendingProps,l=Sr(fe.current).createElement(a),l[wt]=s,l[_t]=t,Ct(l,a,t),vt(l),s.stateNode=l):s.memoizedState=th(s.type,t.memoizedProps,s.pendingProps,t.memoizedState),null;case 27:return tt(s),t===null&&De&&(l=s.stateNode=Pf(s.type,s.pendingProps,fe.current),St=s,is=!0,r=Qe,za(s.type)?(bd=r,Qe=cs(l.firstChild)):Qe=r),zt(t,s,s.pendingProps.children,a),rr(t,s),t===null&&(s.flags|=4194304),s.child;case 5:return t===null&&De&&((r=l=Qe)&&(l=Qg(l,s.type,s.pendingProps,is),l!==null?(s.stateNode=l,St=s,Qe=cs(l.firstChild),is=!1,r=!0):r=!1),r||ma(s)),tt(s),r=s.type,o=s.pendingProps,x=t!==null?t.memoizedProps:null,l=o.children,xd(r,o)?l=null:x!==null&&xd(r,x)&&(s.flags|=32),s.memoizedState!==null&&(r=mo(t,s,cg,null,null,a),Pl._currentValue=r),rr(t,s),zt(t,s,l,a),s.child;case 6:return t===null&&De&&((t=a=Qe)&&(a=Fg(a,s.pendingProps,is),a!==null?(s.stateNode=a,St=s,Qe=null,t=!0):t=!1),t||ma(s)),null;case 13:return Hx(t,s,a);case 4:return Ce(s,s.stateNode.containerInfo),l=s.pendingProps,t===null?s.child=Wa(s,null,l,a):zt(t,s,l,a),s.child;case 11:return Rx(t,s,s.type,s.pendingProps,a);case 7:return zt(t,s,s.pendingProps,a),s.child;case 8:return zt(t,s,s.pendingProps.children,a),s.child;case 12:return zt(t,s,s.pendingProps.children,a),s.child;case 10:return l=s.pendingProps,xa(s,s.type,l.value),zt(t,s,l.children,a),s.child;case 9:return r=s.type._context,l=s.pendingProps.children,Za(s),r=kt(r),l=l(r),s.flags|=1,zt(t,s,l,a),s.child;case 14:return Mx(t,s,s.type,s.pendingProps,a);case 15:return Dx(t,s,s.type,s.pendingProps,a);case 19:return Gx(t,s,a);case 31:return pg(t,s,a);case 22:return Ox(t,s,a,s.pendingProps);case 24:return Za(s),l=kt(ot),t===null?(r=to(),r===null&&(r=Ye,o=Wc(),r.pooledCache=o,o.refCount++,o!==null&&(r.pooledCacheLanes|=a),r=o),s.memoizedState={parent:l,cache:r},ao(s),xa(s,ot,r)):((t.lanes&a)!==0&&(no(t,s),Ml(s,null,null,a),Rl()),r=t.memoizedState,o=s.memoizedState,r.parent!==l?(r={parent:l,cache:l},s.memoizedState=r,s.lanes===0&&(s.memoizedState=s.updateQueue.baseState=r),xa(s,ot,l)):(l=o.cache,xa(s,ot,l),l!==r.cache&&Pc(s,[ot],a,!0))),zt(t,s,s.pendingProps.children,a),s.child;case 29:throw s.pendingProps}throw Error(c(156,s.tag))}function Xs(t){t.flags|=4}function Ho(t,s,a,l,r){if((s=(t.mode&32)!==0)&&(s=!1),s){if(t.flags|=16777216,(r&335544128)===r)if(t.stateNode.complete)t.flags|=8192;else if(gf())t.flags|=8192;else throw Pa=Xi,so}else t.flags&=-16777217}function Vx(t,s){if(s.type!=="stylesheet"||(s.state.loading&4)!==0)t.flags&=-16777217;else if(t.flags|=16777216,!ih(s))if(gf())t.flags|=8192;else throw Pa=Xi,so}function or(t,s){s!==null&&(t.flags|=4),t.flags&16384&&(s=t.tag!==22?wu():536870912,t.lanes|=s,qn|=s)}function $l(t,s){if(!De)switch(t.tailMode){case"hidden":s=t.tail;for(var a=null;s!==null;)s.alternate!==null&&(a=s),s=s.sibling;a===null?t.tail=null:a.sibling=null;break;case"collapsed":a=t.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?s||t.tail===null?t.tail=null:t.tail.sibling=null:l.sibling=null}}function Fe(t){var s=t.alternate!==null&&t.alternate.child===t.child,a=0,l=0;if(s)for(var r=t.child;r!==null;)a|=r.lanes|r.childLanes,l|=r.subtreeFlags&65011712,l|=r.flags&65011712,r.return=t,r=r.sibling;else for(r=t.child;r!==null;)a|=r.lanes|r.childLanes,l|=r.subtreeFlags,l|=r.flags,r.return=t,r=r.sibling;return t.subtreeFlags|=l,t.childLanes=a,s}function bg(t,s,a){var l=s.pendingProps;switch(Qc(s),s.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Fe(s),null;case 1:return Fe(s),null;case 3:return a=s.stateNode,l=null,t!==null&&(l=t.memoizedState.cache),s.memoizedState.cache!==l&&(s.flags|=2048),Gs(ot),ve(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(t===null||t.child===null)&&(An(s)?Xs(s):t===null||t.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,Zc())),Fe(s),null;case 26:var r=s.type,o=s.memoizedState;return t===null?(Xs(s),o!==null?(Fe(s),Vx(s,o)):(Fe(s),Ho(s,r,null,l,a))):o?o!==t.memoizedState?(Xs(s),Fe(s),Vx(s,o)):(Fe(s),s.flags&=-16777217):(t=t.memoizedProps,t!==l&&Xs(s),Fe(s),Ho(s,r,t,l,a)),null;case 27:if(Xe(s),a=fe.current,r=s.type,t!==null&&s.stateNode!=null)t.memoizedProps!==l&&Xs(s);else{if(!l){if(s.stateNode===null)throw Error(c(166));return Fe(s),null}t=G.current,An(s)?wm(s):(t=Pf(r,l,a),s.stateNode=t,Xs(s))}return Fe(s),null;case 5:if(Xe(s),r=s.type,t!==null&&s.stateNode!=null)t.memoizedProps!==l&&Xs(s);else{if(!l){if(s.stateNode===null)throw Error(c(166));return Fe(s),null}if(o=G.current,An(s))wm(s);else{var x=Sr(fe.current);switch(o){case 1:o=x.createElementNS("http://www.w3.org/2000/svg",r);break;case 2:o=x.createElementNS("http://www.w3.org/1998/Math/MathML",r);break;default:switch(r){case"svg":o=x.createElementNS("http://www.w3.org/2000/svg",r);break;case"math":o=x.createElementNS("http://www.w3.org/1998/Math/MathML",r);break;case"script":o=x.createElement("div"),o.innerHTML="<script><\/script>",o=o.removeChild(o.firstChild);break;case"select":o=typeof l.is=="string"?x.createElement("select",{is:l.is}):x.createElement("select"),l.multiple?o.multiple=!0:l.size&&(o.size=l.size);break;default:o=typeof l.is=="string"?x.createElement(r,{is:l.is}):x.createElement(r)}}o[wt]=s,o[_t]=l;e:for(x=s.child;x!==null;){if(x.tag===5||x.tag===6)o.appendChild(x.stateNode);else if(x.tag!==4&&x.tag!==27&&x.child!==null){x.child.return=x,x=x.child;continue}if(x===s)break e;for(;x.sibling===null;){if(x.return===null||x.return===s)break e;x=x.return}x.sibling.return=x.return,x=x.sibling}s.stateNode=o;e:switch(Ct(o,r,l),r){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&Xs(s)}}return Fe(s),Ho(s,s.type,t===null?null:t.memoizedProps,s.pendingProps,a),null;case 6:if(t&&s.stateNode!=null)t.memoizedProps!==l&&Xs(s);else{if(typeof l!="string"&&s.stateNode===null)throw Error(c(166));if(t=fe.current,An(s)){if(t=s.stateNode,a=s.memoizedProps,l=null,r=St,r!==null)switch(r.tag){case 27:case 5:l=r.memoizedProps}t[wt]=s,t=!!(t.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||qf(t.nodeValue,a)),t||ma(s,!0)}else t=Sr(t).createTextNode(l),t[wt]=s,s.stateNode=t}return Fe(s),null;case 31:if(a=s.memoizedState,t===null||t.memoizedState!==null){if(l=An(s),a!==null){if(t===null){if(!l)throw Error(c(318));if(t=s.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(c(557));t[wt]=s}else Qa(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Fe(s),t=!1}else a=Zc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=a),t=!0;if(!t)return s.flags&256?(Qt(s),s):(Qt(s),null);if((s.flags&128)!==0)throw Error(c(558))}return Fe(s),null;case 13:if(l=s.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(r=An(s),l!==null&&l.dehydrated!==null){if(t===null){if(!r)throw Error(c(318));if(r=s.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(c(317));r[wt]=s}else Qa(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Fe(s),r=!1}else r=Zc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=r),r=!0;if(!r)return s.flags&256?(Qt(s),s):(Qt(s),null)}return Qt(s),(s.flags&128)!==0?(s.lanes=a,s):(a=l!==null,t=t!==null&&t.memoizedState!==null,a&&(l=s.child,r=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(r=l.alternate.memoizedState.cachePool.pool),o=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(o=l.memoizedState.cachePool.pool),o!==r&&(l.flags|=2048)),a!==t&&a&&(s.child.flags|=8192),or(s,s.updateQueue),Fe(s),null);case 4:return ve(),t===null&&cd(s.stateNode.containerInfo),Fe(s),null;case 10:return Gs(s.type),Fe(s),null;case 19:if(P(lt),l=s.memoizedState,l===null)return Fe(s),null;if(r=(s.flags&128)!==0,o=l.rendering,o===null)if(r)$l(l,!1);else{if(at!==0||t!==null&&(t.flags&128)!==0)for(t=s.child;t!==null;){if(o=Ji(t),o!==null){for(s.flags|=128,$l(l,!1),t=o.updateQueue,s.updateQueue=t,or(s,t),s.subtreeFlags=0,t=a,a=s.child;a!==null;)bm(a,t),a=a.sibling;return de(lt,lt.current&1|2),De&&Hs(s,l.treeForkCount),s.child}t=t.sibling}l.tail!==null&&yt()>fr&&(s.flags|=128,r=!0,$l(l,!1),s.lanes=4194304)}else{if(!r)if(t=Ji(o),t!==null){if(s.flags|=128,r=!0,t=t.updateQueue,s.updateQueue=t,or(s,t),$l(l,!0),l.tail===null&&l.tailMode==="hidden"&&!o.alternate&&!De)return Fe(s),null}else 2*yt()-l.renderingStartTime>fr&&a!==536870912&&(s.flags|=128,r=!0,$l(l,!1),s.lanes=4194304);l.isBackwards?(o.sibling=s.child,s.child=o):(t=l.last,t!==null?t.sibling=o:s.child=o,l.last=o)}return l.tail!==null?(t=l.tail,l.rendering=t,l.tail=t.sibling,l.renderingStartTime=yt(),t.sibling=null,a=lt.current,de(lt,r?a&1|2:a&1),De&&Hs(s,l.treeForkCount),t):(Fe(s),null);case 22:case 23:return Qt(s),co(),l=s.memoizedState!==null,t!==null?t.memoizedState!==null!==l&&(s.flags|=8192):l&&(s.flags|=8192),l?(a&536870912)!==0&&(s.flags&128)===0&&(Fe(s),s.subtreeFlags&6&&(s.flags|=8192)):Fe(s),a=s.updateQueue,a!==null&&or(s,a.retryQueue),a=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),l=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(l=s.memoizedState.cachePool.pool),l!==a&&(s.flags|=2048),t!==null&&P(Ja),null;case 24:return a=null,t!==null&&(a=t.memoizedState.cache),s.memoizedState.cache!==a&&(s.flags|=2048),Gs(ot),Fe(s),null;case 25:return null;case 30:return null}throw Error(c(156,s.tag))}function yg(t,s){switch(Qc(s),s.tag){case 1:return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return Gs(ot),ve(),t=s.flags,(t&65536)!==0&&(t&128)===0?(s.flags=t&-65537|128,s):null;case 26:case 27:case 5:return Xe(s),null;case 31:if(s.memoizedState!==null){if(Qt(s),s.alternate===null)throw Error(c(340));Qa()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 13:if(Qt(s),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(c(340));Qa()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return P(lt),null;case 4:return ve(),null;case 10:return Gs(s.type),null;case 22:case 23:return Qt(s),co(),t!==null&&P(Ja),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 24:return Gs(ot),null;case 25:return null;default:return null}}function Yx(t,s){switch(Qc(s),s.tag){case 3:Gs(ot),ve();break;case 26:case 27:case 5:Xe(s);break;case 4:ve();break;case 31:s.memoizedState!==null&&Qt(s);break;case 13:Qt(s);break;case 19:P(lt);break;case 10:Gs(s.type);break;case 22:case 23:Qt(s),co(),t!==null&&P(Ja);break;case 24:Gs(ot)}}function Bl(t,s){try{var a=s.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var r=l.next;a=r;do{if((a.tag&t)===t){l=void 0;var o=a.create,x=a.inst;l=o(),x.destroy=l}a=a.next}while(a!==r)}}catch(j){Be(s,s.return,j)}}function ya(t,s,a){try{var l=s.updateQueue,r=l!==null?l.lastEffect:null;if(r!==null){var o=r.next;l=o;do{if((l.tag&t)===t){var x=l.inst,j=x.destroy;if(j!==void 0){x.destroy=void 0,r=s;var E=a,q=j;try{q()}catch(J){Be(r,E,J)}}}l=l.next}while(l!==o)}}catch(J){Be(s,s.return,J)}}function Xx(t){var s=t.updateQueue;if(s!==null){var a=t.stateNode;try{_m(s,a)}catch(l){Be(t,t.return,l)}}}function Qx(t,s,a){a.props=tn(t.type,t.memoizedProps),a.state=t.memoizedState;try{a.componentWillUnmount()}catch(l){Be(t,s,l)}}function Hl(t,s){try{var a=t.ref;if(a!==null){switch(t.tag){case 26:case 27:case 5:var l=t.stateNode;break;case 30:l=t.stateNode;break;default:l=t.stateNode}typeof a=="function"?t.refCleanup=a(l):a.current=l}}catch(r){Be(t,s,r)}}function zs(t,s){var a=t.ref,l=t.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(r){Be(t,s,r)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(r){Be(t,s,r)}else a.current=null}function Fx(t){var s=t.type,a=t.memoizedProps,l=t.stateNode;try{e:switch(s){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(r){Be(t,t.return,r)}}function qo(t,s,a){try{var l=t.stateNode;qg(l,t.type,a,s),l[_t]=s}catch(r){Be(t,t.return,r)}}function Zx(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&za(t.type)||t.tag===4}function Go(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Zx(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&za(t.type)||t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Ko(t,s,a){var l=t.tag;if(l===5||l===6)t=t.stateNode,s?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(t,s):(s=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,s.appendChild(t),a=a._reactRootContainer,a!=null||s.onclick!==null||(s.onclick=Us));else if(l!==4&&(l===27&&za(t.type)&&(a=t.stateNode,s=null),t=t.child,t!==null))for(Ko(t,s,a),t=t.sibling;t!==null;)Ko(t,s,a),t=t.sibling}function dr(t,s,a){var l=t.tag;if(l===5||l===6)t=t.stateNode,s?a.insertBefore(t,s):a.appendChild(t);else if(l!==4&&(l===27&&za(t.type)&&(a=t.stateNode),t=t.child,t!==null))for(dr(t,s,a),t=t.sibling;t!==null;)dr(t,s,a),t=t.sibling}function Jx(t){var s=t.stateNode,a=t.memoizedProps;try{for(var l=t.type,r=s.attributes;r.length;)s.removeAttributeNode(r[0]);Ct(s,l,a),s[wt]=t,s[_t]=a}catch(o){Be(t,t.return,o)}}var Qs=!1,mt=!1,Vo=!1,Ix=typeof WeakSet=="function"?WeakSet:Set,jt=null;function vg(t,s){if(t=t.containerInfo,ud=Rr,t=om(t),_c(t)){if("selectionStart"in t)var a={start:t.selectionStart,end:t.selectionEnd};else e:{a=(a=t.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var r=l.anchorOffset,o=l.focusNode;l=l.focusOffset;try{a.nodeType,o.nodeType}catch{a=null;break e}var x=0,j=-1,E=-1,q=0,J=0,ee=t,V=null;t:for(;;){for(var X;ee!==a||r!==0&&ee.nodeType!==3||(j=x+r),ee!==o||l!==0&&ee.nodeType!==3||(E=x+l),ee.nodeType===3&&(x+=ee.nodeValue.length),(X=ee.firstChild)!==null;)V=ee,ee=X;for(;;){if(ee===t)break t;if(V===a&&++q===r&&(j=x),V===o&&++J===l&&(E=x),(X=ee.nextSibling)!==null)break;ee=V,V=ee.parentNode}ee=X}a=j===-1||E===-1?null:{start:j,end:E}}else a=null}a=a||{start:0,end:0}}else a=null;for(md={focusedElem:t,selectionRange:a},Rr=!1,jt=s;jt!==null;)if(s=jt,t=s.child,(s.subtreeFlags&1028)!==0&&t!==null)t.return=s,jt=t;else for(;jt!==null;){switch(s=jt,o=s.alternate,t=s.flags,s.tag){case 0:if((t&4)!==0&&(t=s.updateQueue,t=t!==null?t.events:null,t!==null))for(a=0;a<t.length;a++)r=t[a],r.ref.impl=r.nextImpl;break;case 11:case 15:break;case 1:if((t&1024)!==0&&o!==null){t=void 0,a=s,r=o.memoizedProps,o=o.memoizedState,l=a.stateNode;try{var xe=tn(a.type,r);t=l.getSnapshotBeforeUpdate(xe,o),l.__reactInternalSnapshotBeforeUpdate=t}catch(ge){Be(a,a.return,ge)}}break;case 3:if((t&1024)!==0){if(t=s.stateNode.containerInfo,a=t.nodeType,a===9)hd(t);else if(a===1)switch(t.nodeName){case"HEAD":case"HTML":case"BODY":hd(t);break;default:t.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((t&1024)!==0)throw Error(c(163))}if(t=s.sibling,t!==null){t.return=s.return,jt=t;break}jt=s.return}}function Px(t,s,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:Zs(t,a),l&4&&Bl(5,a);break;case 1:if(Zs(t,a),l&4)if(t=a.stateNode,s===null)try{t.componentDidMount()}catch(x){Be(a,a.return,x)}else{var r=tn(a.type,s.memoizedProps);s=s.memoizedState;try{t.componentDidUpdate(r,s,t.__reactInternalSnapshotBeforeUpdate)}catch(x){Be(a,a.return,x)}}l&64&&Xx(a),l&512&&Hl(a,a.return);break;case 3:if(Zs(t,a),l&64&&(t=a.updateQueue,t!==null)){if(s=null,a.child!==null)switch(a.child.tag){case 27:case 5:s=a.child.stateNode;break;case 1:s=a.child.stateNode}try{_m(t,s)}catch(x){Be(a,a.return,x)}}break;case 27:s===null&&l&4&&Jx(a);case 26:case 5:Zs(t,a),s===null&&l&4&&Fx(a),l&512&&Hl(a,a.return);break;case 12:Zs(t,a);break;case 31:Zs(t,a),l&4&&tf(t,a);break;case 13:Zs(t,a),l&4&&sf(t,a),l&64&&(t=a.memoizedState,t!==null&&(t=t.dehydrated,t!==null&&(a=Eg.bind(null,a),Zg(t,a))));break;case 22:if(l=a.memoizedState!==null||Qs,!l){s=s!==null&&s.memoizedState!==null||mt,r=Qs;var o=mt;Qs=l,(mt=s)&&!o?Js(t,a,(a.subtreeFlags&8772)!==0):Zs(t,a),Qs=r,mt=o}break;case 30:break;default:Zs(t,a)}}function Wx(t){var s=t.alternate;s!==null&&(t.alternate=null,Wx(s)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(s=t.stateNode,s!==null&&yc(s)),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}var Ie=null,$t=!1;function Fs(t,s,a){for(a=a.child;a!==null;)ef(t,s,a),a=a.sibling}function ef(t,s,a){if(Oe&&typeof Oe.onCommitFiberUnmount=="function")try{Oe.onCommitFiberUnmount(Se,a)}catch{}switch(a.tag){case 26:mt||zs(a,s),Fs(t,s,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:mt||zs(a,s);var l=Ie,r=$t;za(a.type)&&(Ie=a.stateNode,$t=!1),Fs(t,s,a),Zl(a.stateNode),Ie=l,$t=r;break;case 5:mt||zs(a,s);case 6:if(l=Ie,r=$t,Ie=null,Fs(t,s,a),Ie=l,$t=r,Ie!==null)if($t)try{(Ie.nodeType===9?Ie.body:Ie.nodeName==="HTML"?Ie.ownerDocument.body:Ie).removeChild(a.stateNode)}catch(o){Be(a,s,o)}else try{Ie.removeChild(a.stateNode)}catch(o){Be(a,s,o)}break;case 18:Ie!==null&&($t?(t=Ie,Qf(t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,a.stateNode),Zn(t)):Qf(Ie,a.stateNode));break;case 4:l=Ie,r=$t,Ie=a.stateNode.containerInfo,$t=!0,Fs(t,s,a),Ie=l,$t=r;break;case 0:case 11:case 14:case 15:ya(2,a,s),mt||ya(4,a,s),Fs(t,s,a);break;case 1:mt||(zs(a,s),l=a.stateNode,typeof l.componentWillUnmount=="function"&&Qx(a,s,l)),Fs(t,s,a);break;case 21:Fs(t,s,a);break;case 22:mt=(l=mt)||a.memoizedState!==null,Fs(t,s,a),mt=l;break;default:Fs(t,s,a)}}function tf(t,s){if(s.memoizedState===null&&(t=s.alternate,t!==null&&(t=t.memoizedState,t!==null))){t=t.dehydrated;try{Zn(t)}catch(a){Be(s,s.return,a)}}}function sf(t,s){if(s.memoizedState===null&&(t=s.alternate,t!==null&&(t=t.memoizedState,t!==null&&(t=t.dehydrated,t!==null))))try{Zn(t)}catch(a){Be(s,s.return,a)}}function jg(t){switch(t.tag){case 31:case 13:case 19:var s=t.stateNode;return s===null&&(s=t.stateNode=new Ix),s;case 22:return t=t.stateNode,s=t._retryCache,s===null&&(s=t._retryCache=new Ix),s;default:throw Error(c(435,t.tag))}}function ur(t,s){var a=jg(t);s.forEach(function(l){if(!a.has(l)){a.add(l);var r=Tg.bind(null,t,l);l.then(r,r)}})}function Bt(t,s){var a=s.deletions;if(a!==null)for(var l=0;l<a.length;l++){var r=a[l],o=t,x=s,j=x;e:for(;j!==null;){switch(j.tag){case 27:if(za(j.type)){Ie=j.stateNode,$t=!1;break e}break;case 5:Ie=j.stateNode,$t=!1;break e;case 3:case 4:Ie=j.stateNode.containerInfo,$t=!0;break e}j=j.return}if(Ie===null)throw Error(c(160));ef(o,x,r),Ie=null,$t=!1,o=r.alternate,o!==null&&(o.return=null),r.return=null}if(s.subtreeFlags&13886)for(s=s.child;s!==null;)af(s,t),s=s.sibling}var gs=null;function af(t,s){var a=t.alternate,l=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:Bt(s,t),Ht(t),l&4&&(ya(3,t,t.return),Bl(3,t),ya(5,t,t.return));break;case 1:Bt(s,t),Ht(t),l&512&&(mt||a===null||zs(a,a.return)),l&64&&Qs&&(t=t.updateQueue,t!==null&&(l=t.callbacks,l!==null&&(a=t.shared.hiddenCallbacks,t.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var r=gs;if(Bt(s,t),Ht(t),l&512&&(mt||a===null||zs(a,a.return)),l&4){var o=a!==null?a.memoizedState:null;if(l=t.memoizedState,a===null)if(l===null)if(t.stateNode===null){e:{l=t.type,a=t.memoizedProps,r=r.ownerDocument||r;t:switch(l){case"title":o=r.getElementsByTagName("title")[0],(!o||o[xl]||o[wt]||o.namespaceURI==="http://www.w3.org/2000/svg"||o.hasAttribute("itemprop"))&&(o=r.createElement(l),r.head.insertBefore(o,r.querySelector("head > title"))),Ct(o,l,a),o[wt]=t,vt(o),l=o;break e;case"link":var x=nh("link","href",r).get(l+(a.href||""));if(x){for(var j=0;j<x.length;j++)if(o=x[j],o.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&o.getAttribute("rel")===(a.rel==null?null:a.rel)&&o.getAttribute("title")===(a.title==null?null:a.title)&&o.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){x.splice(j,1);break t}}o=r.createElement(l),Ct(o,l,a),r.head.appendChild(o);break;case"meta":if(x=nh("meta","content",r).get(l+(a.content||""))){for(j=0;j<x.length;j++)if(o=x[j],o.getAttribute("content")===(a.content==null?null:""+a.content)&&o.getAttribute("name")===(a.name==null?null:a.name)&&o.getAttribute("property")===(a.property==null?null:a.property)&&o.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&o.getAttribute("charset")===(a.charSet==null?null:a.charSet)){x.splice(j,1);break t}}o=r.createElement(l),Ct(o,l,a),r.head.appendChild(o);break;default:throw Error(c(468,l))}o[wt]=t,vt(o),l=o}t.stateNode=l}else lh(r,t.type,t.stateNode);else t.stateNode=ah(r,l,t.memoizedProps);else o!==l?(o===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):o.count--,l===null?lh(r,t.type,t.stateNode):ah(r,l,t.memoizedProps)):l===null&&t.stateNode!==null&&qo(t,t.memoizedProps,a.memoizedProps)}break;case 27:Bt(s,t),Ht(t),l&512&&(mt||a===null||zs(a,a.return)),a!==null&&l&4&&qo(t,t.memoizedProps,a.memoizedProps);break;case 5:if(Bt(s,t),Ht(t),l&512&&(mt||a===null||zs(a,a.return)),t.flags&32){r=t.stateNode;try{bn(r,"")}catch(xe){Be(t,t.return,xe)}}l&4&&t.stateNode!=null&&(r=t.memoizedProps,qo(t,r,a!==null?a.memoizedProps:r)),l&1024&&(Vo=!0);break;case 6:if(Bt(s,t),Ht(t),l&4){if(t.stateNode===null)throw Error(c(162));l=t.memoizedProps,a=t.stateNode;try{a.nodeValue=l}catch(xe){Be(t,t.return,xe)}}break;case 3:if(Cr=null,r=gs,gs=kr(s.containerInfo),Bt(s,t),gs=r,Ht(t),l&4&&a!==null&&a.memoizedState.isDehydrated)try{Zn(s.containerInfo)}catch(xe){Be(t,t.return,xe)}Vo&&(Vo=!1,nf(t));break;case 4:l=gs,gs=kr(t.stateNode.containerInfo),Bt(s,t),Ht(t),gs=l;break;case 12:Bt(s,t),Ht(t);break;case 31:Bt(s,t),Ht(t),l&4&&(l=t.updateQueue,l!==null&&(t.updateQueue=null,ur(t,l)));break;case 13:Bt(s,t),Ht(t),t.child.flags&8192&&t.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(xr=yt()),l&4&&(l=t.updateQueue,l!==null&&(t.updateQueue=null,ur(t,l)));break;case 22:r=t.memoizedState!==null;var E=a!==null&&a.memoizedState!==null,q=Qs,J=mt;if(Qs=q||r,mt=J||E,Bt(s,t),mt=J,Qs=q,Ht(t),l&8192)e:for(s=t.stateNode,s._visibility=r?s._visibility&-2:s._visibility|1,r&&(a===null||E||Qs||mt||sn(t)),a=null,s=t;;){if(s.tag===5||s.tag===26){if(a===null){E=a=s;try{if(o=E.stateNode,r)x=o.style,typeof x.setProperty=="function"?x.setProperty("display","none","important"):x.display="none";else{j=E.stateNode;var ee=E.memoizedProps.style,V=ee!=null&&ee.hasOwnProperty("display")?ee.display:null;j.style.display=V==null||typeof V=="boolean"?"":(""+V).trim()}}catch(xe){Be(E,E.return,xe)}}}else if(s.tag===6){if(a===null){E=s;try{E.stateNode.nodeValue=r?"":E.memoizedProps}catch(xe){Be(E,E.return,xe)}}}else if(s.tag===18){if(a===null){E=s;try{var X=E.stateNode;r?Ff(X,!0):Ff(E.stateNode,!1)}catch(xe){Be(E,E.return,xe)}}}else if((s.tag!==22&&s.tag!==23||s.memoizedState===null||s===t)&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break e;for(;s.sibling===null;){if(s.return===null||s.return===t)break e;a===s&&(a=null),s=s.return}a===s&&(a=null),s.sibling.return=s.return,s=s.sibling}l&4&&(l=t.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,ur(t,a))));break;case 19:Bt(s,t),Ht(t),l&4&&(l=t.updateQueue,l!==null&&(t.updateQueue=null,ur(t,l)));break;case 30:break;case 21:break;default:Bt(s,t),Ht(t)}}function Ht(t){var s=t.flags;if(s&2){try{for(var a,l=t.return;l!==null;){if(Zx(l)){a=l;break}l=l.return}if(a==null)throw Error(c(160));switch(a.tag){case 27:var r=a.stateNode,o=Go(t);dr(t,o,r);break;case 5:var x=a.stateNode;a.flags&32&&(bn(x,""),a.flags&=-33);var j=Go(t);dr(t,j,x);break;case 3:case 4:var E=a.stateNode.containerInfo,q=Go(t);Ko(t,q,E);break;default:throw Error(c(161))}}catch(J){Be(t,t.return,J)}t.flags&=-3}s&4096&&(t.flags&=-4097)}function nf(t){if(t.subtreeFlags&1024)for(t=t.child;t!==null;){var s=t;nf(s),s.tag===5&&s.flags&1024&&s.stateNode.reset(),t=t.sibling}}function Zs(t,s){if(s.subtreeFlags&8772)for(s=s.child;s!==null;)Px(t,s.alternate,s),s=s.sibling}function sn(t){for(t=t.child;t!==null;){var s=t;switch(s.tag){case 0:case 11:case 14:case 15:ya(4,s,s.return),sn(s);break;case 1:zs(s,s.return);var a=s.stateNode;typeof a.componentWillUnmount=="function"&&Qx(s,s.return,a),sn(s);break;case 27:Zl(s.stateNode);case 26:case 5:zs(s,s.return),sn(s);break;case 22:s.memoizedState===null&&sn(s);break;case 30:sn(s);break;default:sn(s)}t=t.sibling}}function Js(t,s,a){for(a=a&&(s.subtreeFlags&8772)!==0,s=s.child;s!==null;){var l=s.alternate,r=t,o=s,x=o.flags;switch(o.tag){case 0:case 11:case 15:Js(r,o,a),Bl(4,o);break;case 1:if(Js(r,o,a),l=o,r=l.stateNode,typeof r.componentDidMount=="function")try{r.componentDidMount()}catch(q){Be(l,l.return,q)}if(l=o,r=l.updateQueue,r!==null){var j=l.stateNode;try{var E=r.shared.hiddenCallbacks;if(E!==null)for(r.shared.hiddenCallbacks=null,r=0;r<E.length;r++)Lm(E[r],j)}catch(q){Be(l,l.return,q)}}a&&x&64&&Xx(o),Hl(o,o.return);break;case 27:Jx(o);case 26:case 5:Js(r,o,a),a&&l===null&&x&4&&Fx(o),Hl(o,o.return);break;case 12:Js(r,o,a);break;case 31:Js(r,o,a),a&&x&4&&tf(r,o);break;case 13:Js(r,o,a),a&&x&4&&sf(r,o);break;case 22:o.memoizedState===null&&Js(r,o,a),Hl(o,o.return);break;case 30:break;default:Js(r,o,a)}s=s.sibling}}function Yo(t,s){var a=null;t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),t=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(t=s.memoizedState.cachePool.pool),t!==a&&(t!=null&&t.refCount++,a!=null&&zl(a))}function Xo(t,s){t=null,s.alternate!==null&&(t=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==t&&(s.refCount++,t!=null&&zl(t))}function bs(t,s,a,l){if(s.subtreeFlags&10256)for(s=s.child;s!==null;)lf(t,s,a,l),s=s.sibling}function lf(t,s,a,l){var r=s.flags;switch(s.tag){case 0:case 11:case 15:bs(t,s,a,l),r&2048&&Bl(9,s);break;case 1:bs(t,s,a,l);break;case 3:bs(t,s,a,l),r&2048&&(t=null,s.alternate!==null&&(t=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==t&&(s.refCount++,t!=null&&zl(t)));break;case 12:if(r&2048){bs(t,s,a,l),t=s.stateNode;try{var o=s.memoizedProps,x=o.id,j=o.onPostCommit;typeof j=="function"&&j(x,s.alternate===null?"mount":"update",t.passiveEffectDuration,-0)}catch(E){Be(s,s.return,E)}}else bs(t,s,a,l);break;case 31:bs(t,s,a,l);break;case 13:bs(t,s,a,l);break;case 23:break;case 22:o=s.stateNode,x=s.alternate,s.memoizedState!==null?o._visibility&2?bs(t,s,a,l):ql(t,s):o._visibility&2?bs(t,s,a,l):(o._visibility|=2,$n(t,s,a,l,(s.subtreeFlags&10256)!==0||!1)),r&2048&&Yo(x,s);break;case 24:bs(t,s,a,l),r&2048&&Xo(s.alternate,s);break;default:bs(t,s,a,l)}}function $n(t,s,a,l,r){for(r=r&&((s.subtreeFlags&10256)!==0||!1),s=s.child;s!==null;){var o=t,x=s,j=a,E=l,q=x.flags;switch(x.tag){case 0:case 11:case 15:$n(o,x,j,E,r),Bl(8,x);break;case 23:break;case 22:var J=x.stateNode;x.memoizedState!==null?J._visibility&2?$n(o,x,j,E,r):ql(o,x):(J._visibility|=2,$n(o,x,j,E,r)),r&&q&2048&&Yo(x.alternate,x);break;case 24:$n(o,x,j,E,r),r&&q&2048&&Xo(x.alternate,x);break;default:$n(o,x,j,E,r)}s=s.sibling}}function ql(t,s){if(s.subtreeFlags&10256)for(s=s.child;s!==null;){var a=t,l=s,r=l.flags;switch(l.tag){case 22:ql(a,l),r&2048&&Yo(l.alternate,l);break;case 24:ql(a,l),r&2048&&Xo(l.alternate,l);break;default:ql(a,l)}s=s.sibling}}var Gl=8192;function Bn(t,s,a){if(t.subtreeFlags&Gl)for(t=t.child;t!==null;)rf(t,s,a),t=t.sibling}function rf(t,s,a){switch(t.tag){case 26:Bn(t,s,a),t.flags&Gl&&t.memoizedState!==null&&rb(a,gs,t.memoizedState,t.memoizedProps);break;case 5:Bn(t,s,a);break;case 3:case 4:var l=gs;gs=kr(t.stateNode.containerInfo),Bn(t,s,a),gs=l;break;case 22:t.memoizedState===null&&(l=t.alternate,l!==null&&l.memoizedState!==null?(l=Gl,Gl=16777216,Bn(t,s,a),Gl=l):Bn(t,s,a));break;default:Bn(t,s,a)}}function cf(t){var s=t.alternate;if(s!==null&&(t=s.child,t!==null)){s.child=null;do s=t.sibling,t.sibling=null,t=s;while(t!==null)}}function Kl(t){var s=t.deletions;if((t.flags&16)!==0){if(s!==null)for(var a=0;a<s.length;a++){var l=s[a];jt=l,df(l,t)}cf(t)}if(t.subtreeFlags&10256)for(t=t.child;t!==null;)of(t),t=t.sibling}function of(t){switch(t.tag){case 0:case 11:case 15:Kl(t),t.flags&2048&&ya(9,t,t.return);break;case 3:Kl(t);break;case 12:Kl(t);break;case 22:var s=t.stateNode;t.memoizedState!==null&&s._visibility&2&&(t.return===null||t.return.tag!==13)?(s._visibility&=-3,mr(t)):Kl(t);break;default:Kl(t)}}function mr(t){var s=t.deletions;if((t.flags&16)!==0){if(s!==null)for(var a=0;a<s.length;a++){var l=s[a];jt=l,df(l,t)}cf(t)}for(t=t.child;t!==null;){switch(s=t,s.tag){case 0:case 11:case 15:ya(8,s,s.return),mr(s);break;case 22:a=s.stateNode,a._visibility&2&&(a._visibility&=-3,mr(s));break;default:mr(s)}t=t.sibling}}function df(t,s){for(;jt!==null;){var a=jt;switch(a.tag){case 0:case 11:case 15:ya(8,a,s);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var l=a.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:zl(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,jt=l;else e:for(a=t;jt!==null;){l=jt;var r=l.sibling,o=l.return;if(Wx(l),l===a){jt=null;break e}if(r!==null){r.return=o,jt=r;break e}jt=o}}}var Ng={getCacheForType:function(t){var s=kt(ot),a=s.data.get(t);return a===void 0&&(a=t(),s.data.set(t,a)),a},cacheSignal:function(){return kt(ot).controller.signal}},wg=typeof WeakMap=="function"?WeakMap:Map,Ue=0,Ye=null,Ae=null,Te=0,$e=0,Ft=null,va=!1,Hn=!1,Qo=!1,Is=0,at=0,ja=0,an=0,Fo=0,Zt=0,qn=0,Vl=null,qt=null,Zo=!1,xr=0,uf=0,fr=1/0,hr=null,Na=null,gt=0,wa=null,Gn=null,Ps=0,Jo=0,Io=null,mf=null,Yl=0,Po=null;function Jt(){return(Ue&2)!==0&&Te!==0?Te&-Te:B.T!==null?nd():Cu()}function xf(){if(Zt===0)if((Te&536870912)===0||De){var t=Ls;Ls<<=1,(Ls&3932160)===0&&(Ls=262144),Zt=t}else Zt=536870912;return t=Xt.current,t!==null&&(t.flags|=32),Zt}function Gt(t,s,a){(t===Ye&&($e===2||$e===9)||t.cancelPendingCommit!==null)&&(Kn(t,0),Sa(t,Te,Zt,!1)),ml(t,a),((Ue&2)===0||t!==Ye)&&(t===Ye&&((Ue&2)===0&&(an|=a),at===4&&Sa(t,Te,Zt,!1)),Cs(t))}function ff(t,s,a){if((Ue&6)!==0)throw Error(c(327));var l=!a&&(s&127)===0&&(s&t.expiredLanes)===0||ul(t,s),r=l?zg(t,s):ed(t,s,!0),o=l;do{if(r===0){Hn&&!l&&Sa(t,s,0,!1);break}else{if(a=t.current.alternate,o&&!Sg(a)){r=ed(t,s,!1),o=!1;continue}if(r===2){if(o=s,t.errorRecoveryDisabledLanes&o)var x=0;else x=t.pendingLanes&-536870913,x=x!==0?x:x&536870912?536870912:0;if(x!==0){s=x;e:{var j=t;r=Vl;var E=j.current.memoizedState.isDehydrated;if(E&&(Kn(j,x).flags|=256),x=ed(j,x,!1),x!==2){if(Qo&&!E){j.errorRecoveryDisabledLanes|=o,an|=o,r=4;break e}o=qt,qt=r,o!==null&&(qt===null?qt=o:qt.push.apply(qt,o))}r=x}if(o=!1,r!==2)continue}}if(r===1){Kn(t,0),Sa(t,s,0,!0);break}e:{switch(l=t,o=r,o){case 0:case 1:throw Error(c(345));case 4:if((s&4194048)!==s)break;case 6:Sa(l,s,Zt,!va);break e;case 2:qt=null;break;case 3:case 5:break;default:throw Error(c(329))}if((s&62914560)===s&&(r=xr+300-yt(),10<r)){if(Sa(l,s,Zt,!va),un(l,0,!0)!==0)break e;Ps=s,l.timeoutHandle=Yf(hf.bind(null,l,a,qt,hr,Zo,s,Zt,an,qn,va,o,"Throttled",-0,0),r);break e}hf(l,a,qt,hr,Zo,s,Zt,an,qn,va,o,null,-0,0)}}break}while(!0);Cs(t)}function hf(t,s,a,l,r,o,x,j,E,q,J,ee,V,X){if(t.timeoutHandle=-1,ee=s.subtreeFlags,ee&8192||(ee&16785408)===16785408){ee={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Us},rf(s,o,ee);var xe=(o&62914560)===o?xr-yt():(o&4194048)===o?uf-yt():0;if(xe=cb(ee,xe),xe!==null){Ps=o,t.cancelPendingCommit=xe(wf.bind(null,t,s,o,a,l,r,x,j,E,J,ee,null,V,X)),Sa(t,o,x,!q);return}}wf(t,s,o,a,l,r,x,j,E)}function Sg(t){for(var s=t;;){var a=s.tag;if((a===0||a===11||a===15)&&s.flags&16384&&(a=s.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var r=a[l],o=r.getSnapshot;r=r.value;try{if(!Vt(o(),r))return!1}catch{return!1}}if(a=s.child,s.subtreeFlags&16384&&a!==null)a.return=s,s=a;else{if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function Sa(t,s,a,l){s&=~Fo,s&=~an,t.suspendedLanes|=s,t.pingedLanes&=~s,l&&(t.warmLanes|=s),l=t.expirationTimes;for(var r=s;0<r;){var o=31-Rt(r),x=1<<o;l[o]=-1,r&=~x}a!==0&&Su(t,a,s)}function pr(){return(Ue&6)===0?(Xl(0),!1):!0}function Wo(){if(Ae!==null){if($e===0)var t=Ae.return;else t=Ae,qs=Fa=null,ho(t),Dn=null,Al=0,t=Ae;for(;t!==null;)Yx(t.alternate,t),t=t.return;Ae=null}}function Kn(t,s){var a=t.timeoutHandle;a!==-1&&(t.timeoutHandle=-1,Vg(a)),a=t.cancelPendingCommit,a!==null&&(t.cancelPendingCommit=null,a()),Ps=0,Wo(),Ye=t,Ae=a=Bs(t.current,null),Te=s,$e=0,Ft=null,va=!1,Hn=ul(t,s),Qo=!1,qn=Zt=Fo=an=ja=at=0,qt=Vl=null,Zo=!1,(s&8)!==0&&(s|=s&32);var l=t.entangledLanes;if(l!==0)for(t=t.entanglements,l&=s;0<l;){var r=31-Rt(l),o=1<<r;s|=t[r],l&=~o}return Is=s,Ui(),a}function pf(t,s){ke=null,B.H=_l,s===Mn||s===Yi?(s=Rm(),$e=3):s===so?(s=Rm(),$e=4):$e=s===Ro?8:s!==null&&typeof s=="object"&&typeof s.then=="function"?6:1,Ft=s,Ae===null&&(at=1,lr(t,as(s,t.current)))}function gf(){var t=Xt.current;return t===null?!0:(Te&4194048)===Te?rs===null:(Te&62914560)===Te||(Te&536870912)!==0?t===rs:!1}function bf(){var t=B.H;return B.H=_l,t===null?_l:t}function yf(){var t=B.A;return B.A=Ng,t}function gr(){at=4,va||(Te&4194048)!==Te&&Xt.current!==null||(Hn=!0),(ja&134217727)===0&&(an&134217727)===0||Ye===null||Sa(Ye,Te,Zt,!1)}function ed(t,s,a){var l=Ue;Ue|=2;var r=bf(),o=yf();(Ye!==t||Te!==s)&&(hr=null,Kn(t,s)),s=!1;var x=at;e:do try{if($e!==0&&Ae!==null){var j=Ae,E=Ft;switch($e){case 8:Wo(),x=6;break e;case 3:case 2:case 9:case 6:Xt.current===null&&(s=!0);var q=$e;if($e=0,Ft=null,Vn(t,j,E,q),a&&Hn){x=0;break e}break;default:q=$e,$e=0,Ft=null,Vn(t,j,E,q)}}kg(),x=at;break}catch(J){pf(t,J)}while(!0);return s&&t.shellSuspendCounter++,qs=Fa=null,Ue=l,B.H=r,B.A=o,Ae===null&&(Ye=null,Te=0,Ui()),x}function kg(){for(;Ae!==null;)vf(Ae)}function zg(t,s){var a=Ue;Ue|=2;var l=bf(),r=yf();Ye!==t||Te!==s?(hr=null,fr=yt()+500,Kn(t,s)):Hn=ul(t,s);e:do try{if($e!==0&&Ae!==null){s=Ae;var o=Ft;t:switch($e){case 1:$e=0,Ft=null,Vn(t,s,o,1);break;case 2:case 9:if(Em(o)){$e=0,Ft=null,jf(s);break}s=function(){$e!==2&&$e!==9||Ye!==t||($e=7),Cs(t)},o.then(s,s);break e;case 3:$e=7;break e;case 4:$e=5;break e;case 7:Em(o)?($e=0,Ft=null,jf(s)):($e=0,Ft=null,Vn(t,s,o,7));break;case 5:var x=null;switch(Ae.tag){case 26:x=Ae.memoizedState;case 5:case 27:var j=Ae;if(x?ih(x):j.stateNode.complete){$e=0,Ft=null;var E=j.sibling;if(E!==null)Ae=E;else{var q=j.return;q!==null?(Ae=q,br(q)):Ae=null}break t}}$e=0,Ft=null,Vn(t,s,o,5);break;case 6:$e=0,Ft=null,Vn(t,s,o,6);break;case 8:Wo(),at=6;break e;default:throw Error(c(462))}}Cg();break}catch(J){pf(t,J)}while(!0);return qs=Fa=null,B.H=l,B.A=r,Ue=a,Ae!==null?0:(Ye=null,Te=0,Ui(),at)}function Cg(){for(;Ae!==null&&!fs();)vf(Ae)}function vf(t){var s=Kx(t.alternate,t,Is);t.memoizedProps=t.pendingProps,s===null?br(t):Ae=s}function jf(t){var s=t,a=s.alternate;switch(s.tag){case 15:case 0:s=Ux(a,s,s.pendingProps,s.type,void 0,Te);break;case 11:s=Ux(a,s,s.pendingProps,s.type.render,s.ref,Te);break;case 5:ho(s);default:Yx(a,s),s=Ae=bm(s,Is),s=Kx(a,s,Is)}t.memoizedProps=t.pendingProps,s===null?br(t):Ae=s}function Vn(t,s,a,l){qs=Fa=null,ho(s),Dn=null,Al=0;var r=s.return;try{if(hg(t,r,s,a,Te)){at=1,lr(t,as(a,t.current)),Ae=null;return}}catch(o){if(r!==null)throw Ae=r,o;at=1,lr(t,as(a,t.current)),Ae=null;return}s.flags&32768?(De||l===1?t=!0:Hn||(Te&536870912)!==0?t=!1:(va=t=!0,(l===2||l===9||l===3||l===6)&&(l=Xt.current,l!==null&&l.tag===13&&(l.flags|=16384))),Nf(s,t)):br(s)}function br(t){var s=t;do{if((s.flags&32768)!==0){Nf(s,va);return}t=s.return;var a=bg(s.alternate,s,Is);if(a!==null){Ae=a;return}if(s=s.sibling,s!==null){Ae=s;return}Ae=s=t}while(s!==null);at===0&&(at=5)}function Nf(t,s){do{var a=yg(t.alternate,t);if(a!==null){a.flags&=32767,Ae=a;return}if(a=t.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!s&&(t=t.sibling,t!==null)){Ae=t;return}Ae=t=a}while(t!==null);at=6,Ae=null}function wf(t,s,a,l,r,o,x,j,E){t.cancelPendingCommit=null;do yr();while(gt!==0);if((Ue&6)!==0)throw Error(c(327));if(s!==null){if(s===t.current)throw Error(c(177));if(o=s.lanes|s.childLanes,o|=qc,ip(t,a,o,x,j,E),t===Ye&&(Ae=Ye=null,Te=0),Gn=s,wa=t,Ps=a,Jo=o,Io=r,mf=l,(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?(t.callbackNode=null,t.callbackPriority=0,Rg(Os,function(){return Af(),null})):(t.callbackNode=null,t.callbackPriority=0),l=(s.flags&13878)!==0,(s.subtreeFlags&13878)!==0||l){l=B.T,B.T=null,r=ne.p,ne.p=2,x=Ue,Ue|=4;try{vg(t,s,a)}finally{Ue=x,ne.p=r,B.T=l}}gt=1,Sf(),kf(),zf()}}function Sf(){if(gt===1){gt=0;var t=wa,s=Gn,a=(s.flags&13878)!==0;if((s.subtreeFlags&13878)!==0||a){a=B.T,B.T=null;var l=ne.p;ne.p=2;var r=Ue;Ue|=4;try{af(s,t);var o=md,x=om(t.containerInfo),j=o.focusedElem,E=o.selectionRange;if(x!==j&&j&&j.ownerDocument&&cm(j.ownerDocument.documentElement,j)){if(E!==null&&_c(j)){var q=E.start,J=E.end;if(J===void 0&&(J=q),"selectionStart"in j)j.selectionStart=q,j.selectionEnd=Math.min(J,j.value.length);else{var ee=j.ownerDocument||document,V=ee&&ee.defaultView||window;if(V.getSelection){var X=V.getSelection(),xe=j.textContent.length,ge=Math.min(E.start,xe),Ve=E.end===void 0?ge:Math.min(E.end,xe);!X.extend&&ge>Ve&&(x=Ve,Ve=ge,ge=x);var _=rm(j,ge),M=rm(j,Ve);if(_&&M&&(X.rangeCount!==1||X.anchorNode!==_.node||X.anchorOffset!==_.offset||X.focusNode!==M.node||X.focusOffset!==M.offset)){var H=ee.createRange();H.setStart(_.node,_.offset),X.removeAllRanges(),ge>Ve?(X.addRange(H),X.extend(M.node,M.offset)):(H.setEnd(M.node,M.offset),X.addRange(H))}}}}for(ee=[],X=j;X=X.parentNode;)X.nodeType===1&&ee.push({element:X,left:X.scrollLeft,top:X.scrollTop});for(typeof j.focus=="function"&&j.focus(),j=0;j<ee.length;j++){var W=ee[j];W.element.scrollLeft=W.left,W.element.scrollTop=W.top}}Rr=!!ud,md=ud=null}finally{Ue=r,ne.p=l,B.T=a}}t.current=s,gt=2}}function kf(){if(gt===2){gt=0;var t=wa,s=Gn,a=(s.flags&8772)!==0;if((s.subtreeFlags&8772)!==0||a){a=B.T,B.T=null;var l=ne.p;ne.p=2;var r=Ue;Ue|=4;try{Px(t,s.alternate,s)}finally{Ue=r,ne.p=l,B.T=a}}gt=3}}function zf(){if(gt===4||gt===3){gt=0,hs();var t=wa,s=Gn,a=Ps,l=mf;(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?gt=5:(gt=0,Gn=wa=null,Cf(t,t.pendingLanes));var r=t.pendingLanes;if(r===0&&(Na=null),gc(a),s=s.stateNode,Oe&&typeof Oe.onCommitFiberRoot=="function")try{Oe.onCommitFiberRoot(Se,s,void 0,(s.current.flags&128)===128)}catch{}if(l!==null){s=B.T,r=ne.p,ne.p=2,B.T=null;try{for(var o=t.onRecoverableError,x=0;x<l.length;x++){var j=l[x];o(j.value,{componentStack:j.stack})}}finally{B.T=s,ne.p=r}}(Ps&3)!==0&&yr(),Cs(t),r=t.pendingLanes,(a&261930)!==0&&(r&42)!==0?t===Po?Yl++:(Yl=0,Po=t):Yl=0,Xl(0)}}function Cf(t,s){(t.pooledCacheLanes&=s)===0&&(s=t.pooledCache,s!=null&&(t.pooledCache=null,zl(s)))}function yr(){return Sf(),kf(),zf(),Af()}function Af(){if(gt!==5)return!1;var t=wa,s=Jo;Jo=0;var a=gc(Ps),l=B.T,r=ne.p;try{ne.p=32>a?32:a,B.T=null,a=Io,Io=null;var o=wa,x=Ps;if(gt=0,Gn=wa=null,Ps=0,(Ue&6)!==0)throw Error(c(331));var j=Ue;if(Ue|=4,of(o.current),lf(o,o.current,x,a),Ue=j,Xl(0,!1),Oe&&typeof Oe.onPostCommitFiberRoot=="function")try{Oe.onPostCommitFiberRoot(Se,o)}catch{}return!0}finally{ne.p=r,B.T=l,Cf(t,s)}}function Ef(t,s,a){s=as(a,s),s=To(t.stateNode,s,2),t=pa(t,s,2),t!==null&&(ml(t,2),Cs(t))}function Be(t,s,a){if(t.tag===3)Ef(t,t,a);else for(;s!==null;){if(s.tag===3){Ef(s,t,a);break}else if(s.tag===1){var l=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(Na===null||!Na.has(l))){t=as(a,t),a=Ex(2),l=pa(s,a,2),l!==null&&(Tx(a,l,s,t),ml(l,2),Cs(l));break}}s=s.return}}function td(t,s,a){var l=t.pingCache;if(l===null){l=t.pingCache=new wg;var r=new Set;l.set(s,r)}else r=l.get(s),r===void 0&&(r=new Set,l.set(s,r));r.has(a)||(Qo=!0,r.add(a),t=Ag.bind(null,t,s,a),s.then(t,t))}function Ag(t,s,a){var l=t.pingCache;l!==null&&l.delete(s),t.pingedLanes|=t.suspendedLanes&a,t.warmLanes&=~a,Ye===t&&(Te&a)===a&&(at===4||at===3&&(Te&62914560)===Te&&300>yt()-xr?(Ue&2)===0&&Kn(t,0):Fo|=a,qn===Te&&(qn=0)),Cs(t)}function Tf(t,s){s===0&&(s=wu()),t=Ya(t,s),t!==null&&(ml(t,s),Cs(t))}function Eg(t){var s=t.memoizedState,a=0;s!==null&&(a=s.retryLane),Tf(t,a)}function Tg(t,s){var a=0;switch(t.tag){case 31:case 13:var l=t.stateNode,r=t.memoizedState;r!==null&&(a=r.retryLane);break;case 19:l=t.stateNode;break;case 22:l=t.stateNode._retryCache;break;default:throw Error(c(314))}l!==null&&l.delete(s),Tf(t,a)}function Rg(t,s){return ye(t,s)}var vr=null,Yn=null,sd=!1,jr=!1,ad=!1,ka=0;function Cs(t){t!==Yn&&t.next===null&&(Yn===null?vr=Yn=t:Yn=Yn.next=t),jr=!0,sd||(sd=!0,Dg())}function Xl(t,s){if(!ad&&jr){ad=!0;do for(var a=!1,l=vr;l!==null;){if(t!==0){var r=l.pendingLanes;if(r===0)var o=0;else{var x=l.suspendedLanes,j=l.pingedLanes;o=(1<<31-Rt(42|t)+1)-1,o&=r&~(x&~j),o=o&201326741?o&201326741|1:o?o|2:0}o!==0&&(a=!0,Of(l,o))}else o=Te,o=un(l,l===Ye?o:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(o&3)===0||ul(l,o)||(a=!0,Of(l,o));l=l.next}while(a);ad=!1}}function Mg(){Rf()}function Rf(){jr=sd=!1;var t=0;ka!==0&&Kg()&&(t=ka);for(var s=yt(),a=null,l=vr;l!==null;){var r=l.next,o=Mf(l,s);o===0?(l.next=null,a===null?vr=r:a.next=r,r===null&&(Yn=a)):(a=l,(t!==0||(o&3)!==0)&&(jr=!0)),l=r}gt!==0&&gt!==5||Xl(t),ka!==0&&(ka=0)}function Mf(t,s){for(var a=t.suspendedLanes,l=t.pingedLanes,r=t.expirationTimes,o=t.pendingLanes&-62914561;0<o;){var x=31-Rt(o),j=1<<x,E=r[x];E===-1?((j&a)===0||(j&l)!==0)&&(r[x]=lp(j,s)):E<=s&&(t.expiredLanes|=j),o&=~j}if(s=Ye,a=Te,a=un(t,t===s?a:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),l=t.callbackNode,a===0||t===s&&($e===2||$e===9)||t.cancelPendingCommit!==null)return l!==null&&l!==null&&We(l),t.callbackNode=null,t.callbackPriority=0;if((a&3)===0||ul(t,a)){if(s=a&-a,s===t.callbackPriority)return s;switch(l!==null&&We(l),gc(a)){case 2:case 8:a=Ba;break;case 32:a=Os;break;case 268435456:a=K;break;default:a=Os}return l=Df.bind(null,t),a=ye(a,l),t.callbackPriority=s,t.callbackNode=a,s}return l!==null&&l!==null&&We(l),t.callbackPriority=2,t.callbackNode=null,2}function Df(t,s){if(gt!==0&&gt!==5)return t.callbackNode=null,t.callbackPriority=0,null;var a=t.callbackNode;if(yr()&&t.callbackNode!==a)return null;var l=Te;return l=un(t,t===Ye?l:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),l===0?null:(ff(t,l,s),Mf(t,yt()),t.callbackNode!=null&&t.callbackNode===a?Df.bind(null,t):null)}function Of(t,s){if(yr())return null;ff(t,s,!0)}function Dg(){Yg(function(){(Ue&6)!==0?ye($a,Mg):Rf()})}function nd(){if(ka===0){var t=Tn;t===0&&(t=dl,dl<<=1,(dl&261888)===0&&(dl=256)),ka=t}return ka}function Lf(t){return t==null||typeof t=="symbol"||typeof t=="boolean"?null:typeof t=="function"?t:Ei(""+t)}function _f(t,s){var a=s.ownerDocument.createElement("input");return a.name=s.name,a.value=s.value,t.id&&a.setAttribute("form",t.id),s.parentNode.insertBefore(a,s),t=new FormData(t),a.parentNode.removeChild(a),t}function Og(t,s,a,l,r){if(s==="submit"&&a&&a.stateNode===r){var o=Lf((r[_t]||null).action),x=l.submitter;x&&(s=(s=x[_t]||null)?Lf(s.formAction):x.getAttribute("formAction"),s!==null&&(o=s,x=null));var j=new Di("action","action",null,l,r);t.push({event:j,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(ka!==0){var E=x?_f(r,x):new FormData(r);So(a,{pending:!0,data:E,method:r.method,action:o},null,E)}}else typeof o=="function"&&(j.preventDefault(),E=x?_f(r,x):new FormData(r),So(a,{pending:!0,data:E,method:r.method,action:o},o,E))},currentTarget:r}]})}}for(var ld=0;ld<Hc.length;ld++){var id=Hc[ld],Lg=id.toLowerCase(),_g=id[0].toUpperCase()+id.slice(1);ps(Lg,"on"+_g)}ps(mm,"onAnimationEnd"),ps(xm,"onAnimationIteration"),ps(fm,"onAnimationStart"),ps("dblclick","onDoubleClick"),ps("focusin","onFocus"),ps("focusout","onBlur"),ps(Pp,"onTransitionRun"),ps(Wp,"onTransitionStart"),ps(eg,"onTransitionCancel"),ps(hm,"onTransitionEnd"),pn("onMouseEnter",["mouseout","mouseover"]),pn("onMouseLeave",["mouseout","mouseover"]),pn("onPointerEnter",["pointerout","pointerover"]),pn("onPointerLeave",["pointerout","pointerover"]),qa("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),qa("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),qa("onBeforeInput",["compositionend","keypress","textInput","paste"]),qa("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),qa("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),qa("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ql="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Ug=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Ql));function Uf(t,s){s=(s&4)!==0;for(var a=0;a<t.length;a++){var l=t[a],r=l.event;l=l.listeners;e:{var o=void 0;if(s)for(var x=l.length-1;0<=x;x--){var j=l[x],E=j.instance,q=j.currentTarget;if(j=j.listener,E!==o&&r.isPropagationStopped())break e;o=j,r.currentTarget=q;try{o(r)}catch(J){_i(J)}r.currentTarget=null,o=E}else for(x=0;x<l.length;x++){if(j=l[x],E=j.instance,q=j.currentTarget,j=j.listener,E!==o&&r.isPropagationStopped())break e;o=j,r.currentTarget=q;try{o(r)}catch(J){_i(J)}r.currentTarget=null,o=E}}}}function Ee(t,s){var a=s[bc];a===void 0&&(a=s[bc]=new Set);var l=t+"__bubble";a.has(l)||($f(s,t,2,!1),a.add(l))}function rd(t,s,a){var l=0;s&&(l|=4),$f(a,t,l,s)}var Nr="_reactListening"+Math.random().toString(36).slice(2);function cd(t){if(!t[Nr]){t[Nr]=!0,Tu.forEach(function(a){a!=="selectionchange"&&(Ug.has(a)||rd(a,!1,t),rd(a,!0,t))});var s=t.nodeType===9?t:t.ownerDocument;s===null||s[Nr]||(s[Nr]=!0,rd("selectionchange",!1,s))}}function $f(t,s,a,l){switch(xh(s)){case 2:var r=ub;break;case 8:r=mb;break;default:r=wd}a=r.bind(null,s,a,t),r=void 0,!Cc||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(r=!0),l?r!==void 0?t.addEventListener(s,a,{capture:!0,passive:r}):t.addEventListener(s,a,!0):r!==void 0?t.addEventListener(s,a,{passive:r}):t.addEventListener(s,a,!1)}function od(t,s,a,l,r){var o=l;if((s&1)===0&&(s&2)===0&&l!==null)e:for(;;){if(l===null)return;var x=l.tag;if(x===3||x===4){var j=l.stateNode.containerInfo;if(j===r)break;if(x===4)for(x=l.return;x!==null;){var E=x.tag;if((E===3||E===4)&&x.stateNode.containerInfo===r)return;x=x.return}for(;j!==null;){if(x=xn(j),x===null)return;if(E=x.tag,E===5||E===6||E===26||E===27){l=o=x;continue e}j=j.parentNode}}l=l.return}Gu(function(){var q=o,J=kc(a),ee=[];e:{var V=pm.get(t);if(V!==void 0){var X=Di,xe=t;switch(t){case"keypress":if(Ri(a)===0)break e;case"keydown":case"keyup":X=Tp;break;case"focusin":xe="focus",X=Rc;break;case"focusout":xe="blur",X=Rc;break;case"beforeblur":case"afterblur":X=Rc;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":X=Yu;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":X=bp;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":X=Dp;break;case mm:case xm:case fm:X=jp;break;case hm:X=Lp;break;case"scroll":case"scrollend":X=pp;break;case"wheel":X=Up;break;case"copy":case"cut":case"paste":X=wp;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":X=Qu;break;case"toggle":case"beforetoggle":X=Bp}var ge=(s&4)!==0,Ve=!ge&&(t==="scroll"||t==="scrollend"),_=ge?V!==null?V+"Capture":null:V;ge=[];for(var M=q,H;M!==null;){var W=M;if(H=W.stateNode,W=W.tag,W!==5&&W!==26&&W!==27||H===null||_===null||(W=hl(M,_),W!=null&&ge.push(Fl(M,W,H))),Ve)break;M=M.return}0<ge.length&&(V=new X(V,xe,null,a,J),ee.push({event:V,listeners:ge}))}}if((s&7)===0){e:{if(V=t==="mouseover"||t==="pointerover",X=t==="mouseout"||t==="pointerout",V&&a!==Sc&&(xe=a.relatedTarget||a.fromElement)&&(xn(xe)||xe[mn]))break e;if((X||V)&&(V=J.window===J?J:(V=J.ownerDocument)?V.defaultView||V.parentWindow:window,X?(xe=a.relatedTarget||a.toElement,X=q,xe=xe?xn(xe):null,xe!==null&&(Ve=f(xe),ge=xe.tag,xe!==Ve||ge!==5&&ge!==27&&ge!==6)&&(xe=null)):(X=null,xe=q),X!==xe)){if(ge=Yu,W="onMouseLeave",_="onMouseEnter",M="mouse",(t==="pointerout"||t==="pointerover")&&(ge=Qu,W="onPointerLeave",_="onPointerEnter",M="pointer"),Ve=X==null?V:fl(X),H=xe==null?V:fl(xe),V=new ge(W,M+"leave",X,a,J),V.target=Ve,V.relatedTarget=H,W=null,xn(J)===q&&(ge=new ge(_,M+"enter",xe,a,J),ge.target=H,ge.relatedTarget=Ve,W=ge),Ve=W,X&&xe)t:{for(ge=$g,_=X,M=xe,H=0,W=_;W;W=ge(W))H++;W=0;for(var pe=M;pe;pe=ge(pe))W++;for(;0<H-W;)_=ge(_),H--;for(;0<W-H;)M=ge(M),W--;for(;H--;){if(_===M||M!==null&&_===M.alternate){ge=_;break t}_=ge(_),M=ge(M)}ge=null}else ge=null;X!==null&&Bf(ee,V,X,ge,!1),xe!==null&&Ve!==null&&Bf(ee,Ve,xe,ge,!0)}}e:{if(V=q?fl(q):window,X=V.nodeName&&V.nodeName.toLowerCase(),X==="select"||X==="input"&&V.type==="file")var Le=tm;else if(Wu(V))if(sm)Le=Zp;else{Le=Qp;var he=Xp}else X=V.nodeName,!X||X.toLowerCase()!=="input"||V.type!=="checkbox"&&V.type!=="radio"?q&&wc(q.elementType)&&(Le=tm):Le=Fp;if(Le&&(Le=Le(t,q))){em(ee,Le,a,J);break e}he&&he(t,V,q),t==="focusout"&&q&&V.type==="number"&&q.memoizedProps.value!=null&&Nc(V,"number",V.value)}switch(he=q?fl(q):window,t){case"focusin":(Wu(he)||he.contentEditable==="true")&&(Nn=he,Uc=q,wl=null);break;case"focusout":wl=Uc=Nn=null;break;case"mousedown":$c=!0;break;case"contextmenu":case"mouseup":case"dragend":$c=!1,dm(ee,a,J);break;case"selectionchange":if(Ip)break;case"keydown":case"keyup":dm(ee,a,J)}var ze;if(Dc)e:{switch(t){case"compositionstart":var Re="onCompositionStart";break e;case"compositionend":Re="onCompositionEnd";break e;case"compositionupdate":Re="onCompositionUpdate";break e}Re=void 0}else jn?Iu(t,a)&&(Re="onCompositionEnd"):t==="keydown"&&a.keyCode===229&&(Re="onCompositionStart");Re&&(Fu&&a.locale!=="ko"&&(jn||Re!=="onCompositionStart"?Re==="onCompositionEnd"&&jn&&(ze=Ku()):(oa=J,Ac="value"in oa?oa.value:oa.textContent,jn=!0)),he=wr(q,Re),0<he.length&&(Re=new Xu(Re,t,null,a,J),ee.push({event:Re,listeners:he}),ze?Re.data=ze:(ze=Pu(a),ze!==null&&(Re.data=ze)))),(ze=qp?Gp(t,a):Kp(t,a))&&(Re=wr(q,"onBeforeInput"),0<Re.length&&(he=new Xu("onBeforeInput","beforeinput",null,a,J),ee.push({event:he,listeners:Re}),he.data=ze)),Og(ee,t,q,a,J)}Uf(ee,s)})}function Fl(t,s,a){return{instance:t,listener:s,currentTarget:a}}function wr(t,s){for(var a=s+"Capture",l=[];t!==null;){var r=t,o=r.stateNode;if(r=r.tag,r!==5&&r!==26&&r!==27||o===null||(r=hl(t,a),r!=null&&l.unshift(Fl(t,r,o)),r=hl(t,s),r!=null&&l.push(Fl(t,r,o))),t.tag===3)return l;t=t.return}return[]}function $g(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5&&t.tag!==27);return t||null}function Bf(t,s,a,l,r){for(var o=s._reactName,x=[];a!==null&&a!==l;){var j=a,E=j.alternate,q=j.stateNode;if(j=j.tag,E!==null&&E===l)break;j!==5&&j!==26&&j!==27||q===null||(E=q,r?(q=hl(a,o),q!=null&&x.unshift(Fl(a,q,E))):r||(q=hl(a,o),q!=null&&x.push(Fl(a,q,E)))),a=a.return}x.length!==0&&t.push({event:s,listeners:x})}var Bg=/\r\n?/g,Hg=/\u0000|\uFFFD/g;function Hf(t){return(typeof t=="string"?t:""+t).replace(Bg,`
49
+ `).replace(Hg,"")}function qf(t,s){return s=Hf(s),Hf(t)===s}function Ke(t,s,a,l,r,o){switch(a){case"children":typeof l=="string"?s==="body"||s==="textarea"&&l===""||bn(t,l):(typeof l=="number"||typeof l=="bigint")&&s!=="body"&&bn(t,""+l);break;case"className":Ci(t,"class",l);break;case"tabIndex":Ci(t,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":Ci(t,a,l);break;case"style":Hu(t,l,o);break;case"data":if(s!=="object"){Ci(t,"data",l);break}case"src":case"href":if(l===""&&(s!=="a"||a!=="href")){t.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){t.removeAttribute(a);break}l=Ei(""+l),t.setAttribute(a,l);break;case"action":case"formAction":if(typeof l=="function"){t.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof o=="function"&&(a==="formAction"?(s!=="input"&&Ke(t,s,"name",r.name,r,null),Ke(t,s,"formEncType",r.formEncType,r,null),Ke(t,s,"formMethod",r.formMethod,r,null),Ke(t,s,"formTarget",r.formTarget,r,null)):(Ke(t,s,"encType",r.encType,r,null),Ke(t,s,"method",r.method,r,null),Ke(t,s,"target",r.target,r,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){t.removeAttribute(a);break}l=Ei(""+l),t.setAttribute(a,l);break;case"onClick":l!=null&&(t.onclick=Us);break;case"onScroll":l!=null&&Ee("scroll",t);break;case"onScrollEnd":l!=null&&Ee("scrollend",t);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(c(61));if(a=l.__html,a!=null){if(r.children!=null)throw Error(c(60));t.innerHTML=a}}break;case"multiple":t.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":t.muted=l&&typeof l!="function"&&typeof l!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(l==null||typeof l=="function"||typeof l=="boolean"||typeof l=="symbol"){t.removeAttribute("xlink:href");break}a=Ei(""+l),t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":l!=null&&typeof l!="function"&&typeof l!="symbol"?t.setAttribute(a,""+l):t.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":l&&typeof l!="function"&&typeof l!="symbol"?t.setAttribute(a,""):t.removeAttribute(a);break;case"capture":case"download":l===!0?t.setAttribute(a,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?t.setAttribute(a,l):t.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?t.setAttribute(a,l):t.removeAttribute(a);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?t.removeAttribute(a):t.setAttribute(a,l);break;case"popover":Ee("beforetoggle",t),Ee("toggle",t),zi(t,"popover",l);break;case"xlinkActuate":_s(t,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":_s(t,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":_s(t,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":_s(t,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":_s(t,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":_s(t,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":_s(t,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":_s(t,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":_s(t,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":zi(t,"is",l);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=fp.get(a)||a,zi(t,a,l))}}function dd(t,s,a,l,r,o){switch(a){case"style":Hu(t,l,o);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(c(61));if(a=l.__html,a!=null){if(r.children!=null)throw Error(c(60));t.innerHTML=a}}break;case"children":typeof l=="string"?bn(t,l):(typeof l=="number"||typeof l=="bigint")&&bn(t,""+l);break;case"onScroll":l!=null&&Ee("scroll",t);break;case"onScrollEnd":l!=null&&Ee("scrollend",t);break;case"onClick":l!=null&&(t.onclick=Us);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ru.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(r=a.endsWith("Capture"),s=a.slice(2,r?a.length-7:void 0),o=t[_t]||null,o=o!=null?o[a]:null,typeof o=="function"&&t.removeEventListener(s,o,r),typeof l=="function")){typeof o!="function"&&o!==null&&(a in t?t[a]=null:t.hasAttribute(a)&&t.removeAttribute(a)),t.addEventListener(s,l,r);break e}a in t?t[a]=l:l===!0?t.setAttribute(a,""):zi(t,a,l)}}}function Ct(t,s,a){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ee("error",t),Ee("load",t);var l=!1,r=!1,o;for(o in a)if(a.hasOwnProperty(o)){var x=a[o];if(x!=null)switch(o){case"src":l=!0;break;case"srcSet":r=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(c(137,s));default:Ke(t,s,o,x,a,null)}}r&&Ke(t,s,"srcSet",a.srcSet,a,null),l&&Ke(t,s,"src",a.src,a,null);return;case"input":Ee("invalid",t);var j=o=x=r=null,E=null,q=null;for(l in a)if(a.hasOwnProperty(l)){var J=a[l];if(J!=null)switch(l){case"name":r=J;break;case"type":x=J;break;case"checked":E=J;break;case"defaultChecked":q=J;break;case"value":o=J;break;case"defaultValue":j=J;break;case"children":case"dangerouslySetInnerHTML":if(J!=null)throw Error(c(137,s));break;default:Ke(t,s,l,J,a,null)}}_u(t,o,j,E,q,x,r,!1);return;case"select":Ee("invalid",t),l=x=o=null;for(r in a)if(a.hasOwnProperty(r)&&(j=a[r],j!=null))switch(r){case"value":o=j;break;case"defaultValue":x=j;break;case"multiple":l=j;default:Ke(t,s,r,j,a,null)}s=o,a=x,t.multiple=!!l,s!=null?gn(t,!!l,s,!1):a!=null&&gn(t,!!l,a,!0);return;case"textarea":Ee("invalid",t),o=r=l=null;for(x in a)if(a.hasOwnProperty(x)&&(j=a[x],j!=null))switch(x){case"value":l=j;break;case"defaultValue":r=j;break;case"children":o=j;break;case"dangerouslySetInnerHTML":if(j!=null)throw Error(c(91));break;default:Ke(t,s,x,j,a,null)}$u(t,l,r,o);return;case"option":for(E in a)if(a.hasOwnProperty(E)&&(l=a[E],l!=null))switch(E){case"selected":t.selected=l&&typeof l!="function"&&typeof l!="symbol";break;default:Ke(t,s,E,l,a,null)}return;case"dialog":Ee("beforetoggle",t),Ee("toggle",t),Ee("cancel",t),Ee("close",t);break;case"iframe":case"object":Ee("load",t);break;case"video":case"audio":for(l=0;l<Ql.length;l++)Ee(Ql[l],t);break;case"image":Ee("error",t),Ee("load",t);break;case"details":Ee("toggle",t);break;case"embed":case"source":case"link":Ee("error",t),Ee("load",t);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(q in a)if(a.hasOwnProperty(q)&&(l=a[q],l!=null))switch(q){case"children":case"dangerouslySetInnerHTML":throw Error(c(137,s));default:Ke(t,s,q,l,a,null)}return;default:if(wc(s)){for(J in a)a.hasOwnProperty(J)&&(l=a[J],l!==void 0&&dd(t,s,J,l,a,void 0));return}}for(j in a)a.hasOwnProperty(j)&&(l=a[j],l!=null&&Ke(t,s,j,l,a,null))}function qg(t,s,a,l){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var r=null,o=null,x=null,j=null,E=null,q=null,J=null;for(X in a){var ee=a[X];if(a.hasOwnProperty(X)&&ee!=null)switch(X){case"checked":break;case"value":break;case"defaultValue":E=ee;default:l.hasOwnProperty(X)||Ke(t,s,X,null,l,ee)}}for(var V in l){var X=l[V];if(ee=a[V],l.hasOwnProperty(V)&&(X!=null||ee!=null))switch(V){case"type":o=X;break;case"name":r=X;break;case"checked":q=X;break;case"defaultChecked":J=X;break;case"value":x=X;break;case"defaultValue":j=X;break;case"children":case"dangerouslySetInnerHTML":if(X!=null)throw Error(c(137,s));break;default:X!==ee&&Ke(t,s,V,X,l,ee)}}jc(t,x,j,E,q,J,o,r);return;case"select":X=x=j=V=null;for(o in a)if(E=a[o],a.hasOwnProperty(o)&&E!=null)switch(o){case"value":break;case"multiple":X=E;default:l.hasOwnProperty(o)||Ke(t,s,o,null,l,E)}for(r in l)if(o=l[r],E=a[r],l.hasOwnProperty(r)&&(o!=null||E!=null))switch(r){case"value":V=o;break;case"defaultValue":j=o;break;case"multiple":x=o;default:o!==E&&Ke(t,s,r,o,l,E)}s=j,a=x,l=X,V!=null?gn(t,!!a,V,!1):!!l!=!!a&&(s!=null?gn(t,!!a,s,!0):gn(t,!!a,a?[]:"",!1));return;case"textarea":X=V=null;for(j in a)if(r=a[j],a.hasOwnProperty(j)&&r!=null&&!l.hasOwnProperty(j))switch(j){case"value":break;case"children":break;default:Ke(t,s,j,null,l,r)}for(x in l)if(r=l[x],o=a[x],l.hasOwnProperty(x)&&(r!=null||o!=null))switch(x){case"value":V=r;break;case"defaultValue":X=r;break;case"children":break;case"dangerouslySetInnerHTML":if(r!=null)throw Error(c(91));break;default:r!==o&&Ke(t,s,x,r,l,o)}Uu(t,V,X);return;case"option":for(var xe in a)if(V=a[xe],a.hasOwnProperty(xe)&&V!=null&&!l.hasOwnProperty(xe))switch(xe){case"selected":t.selected=!1;break;default:Ke(t,s,xe,null,l,V)}for(E in l)if(V=l[E],X=a[E],l.hasOwnProperty(E)&&V!==X&&(V!=null||X!=null))switch(E){case"selected":t.selected=V&&typeof V!="function"&&typeof V!="symbol";break;default:Ke(t,s,E,V,l,X)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var ge in a)V=a[ge],a.hasOwnProperty(ge)&&V!=null&&!l.hasOwnProperty(ge)&&Ke(t,s,ge,null,l,V);for(q in l)if(V=l[q],X=a[q],l.hasOwnProperty(q)&&V!==X&&(V!=null||X!=null))switch(q){case"children":case"dangerouslySetInnerHTML":if(V!=null)throw Error(c(137,s));break;default:Ke(t,s,q,V,l,X)}return;default:if(wc(s)){for(var Ve in a)V=a[Ve],a.hasOwnProperty(Ve)&&V!==void 0&&!l.hasOwnProperty(Ve)&&dd(t,s,Ve,void 0,l,V);for(J in l)V=l[J],X=a[J],!l.hasOwnProperty(J)||V===X||V===void 0&&X===void 0||dd(t,s,J,V,l,X);return}}for(var _ in a)V=a[_],a.hasOwnProperty(_)&&V!=null&&!l.hasOwnProperty(_)&&Ke(t,s,_,null,l,V);for(ee in l)V=l[ee],X=a[ee],!l.hasOwnProperty(ee)||V===X||V==null&&X==null||Ke(t,s,ee,V,l,X)}function Gf(t){switch(t){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Gg(){if(typeof performance.getEntriesByType=="function"){for(var t=0,s=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var r=a[l],o=r.transferSize,x=r.initiatorType,j=r.duration;if(o&&j&&Gf(x)){for(x=0,j=r.responseEnd,l+=1;l<a.length;l++){var E=a[l],q=E.startTime;if(q>j)break;var J=E.transferSize,ee=E.initiatorType;J&&Gf(ee)&&(E=E.responseEnd,x+=J*(E<j?1:(j-q)/(E-q)))}if(--l,s+=8*(o+x)/(r.duration/1e3),t++,10<t)break}}if(0<t)return s/t/1e6}return navigator.connection&&(t=navigator.connection.downlink,typeof t=="number")?t:5}var ud=null,md=null;function Sr(t){return t.nodeType===9?t:t.ownerDocument}function Kf(t){switch(t){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Vf(t,s){if(t===0)switch(s){case"svg":return 1;case"math":return 2;default:return 0}return t===1&&s==="foreignObject"?0:t}function xd(t,s){return t==="textarea"||t==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.children=="bigint"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var fd=null;function Kg(){var t=window.event;return t&&t.type==="popstate"?t===fd?!1:(fd=t,!0):(fd=null,!1)}var Yf=typeof setTimeout=="function"?setTimeout:void 0,Vg=typeof clearTimeout=="function"?clearTimeout:void 0,Xf=typeof Promise=="function"?Promise:void 0,Yg=typeof queueMicrotask=="function"?queueMicrotask:typeof Xf<"u"?function(t){return Xf.resolve(null).then(t).catch(Xg)}:Yf;function Xg(t){setTimeout(function(){throw t})}function za(t){return t==="head"}function Qf(t,s){var a=s,l=0;do{var r=a.nextSibling;if(t.removeChild(a),r&&r.nodeType===8)if(a=r.data,a==="/$"||a==="/&"){if(l===0){t.removeChild(r),Zn(s);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")Zl(t.ownerDocument.documentElement);else if(a==="head"){a=t.ownerDocument.head,Zl(a);for(var o=a.firstChild;o;){var x=o.nextSibling,j=o.nodeName;o[xl]||j==="SCRIPT"||j==="STYLE"||j==="LINK"&&o.rel.toLowerCase()==="stylesheet"||a.removeChild(o),o=x}}else a==="body"&&Zl(t.ownerDocument.body);a=r}while(a);Zn(s)}function Ff(t,s){var a=t;t=0;do{var l=a.nextSibling;if(a.nodeType===1?s?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(s?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),l&&l.nodeType===8)if(a=l.data,a==="/$"){if(t===0)break;t--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||t++;a=l}while(a)}function hd(t){var s=t.firstChild;for(s&&s.nodeType===10&&(s=s.nextSibling);s;){var a=s;switch(s=s.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":hd(a),yc(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}t.removeChild(a)}}function Qg(t,s,a,l){for(;t.nodeType===1;){var r=a;if(t.nodeName.toLowerCase()!==s.toLowerCase()){if(!l&&(t.nodeName!=="INPUT"||t.type!=="hidden"))break}else if(l){if(!t[xl])switch(s){case"meta":if(!t.hasAttribute("itemprop"))break;return t;case"link":if(o=t.getAttribute("rel"),o==="stylesheet"&&t.hasAttribute("data-precedence"))break;if(o!==r.rel||t.getAttribute("href")!==(r.href==null||r.href===""?null:r.href)||t.getAttribute("crossorigin")!==(r.crossOrigin==null?null:r.crossOrigin)||t.getAttribute("title")!==(r.title==null?null:r.title))break;return t;case"style":if(t.hasAttribute("data-precedence"))break;return t;case"script":if(o=t.getAttribute("src"),(o!==(r.src==null?null:r.src)||t.getAttribute("type")!==(r.type==null?null:r.type)||t.getAttribute("crossorigin")!==(r.crossOrigin==null?null:r.crossOrigin))&&o&&t.hasAttribute("async")&&!t.hasAttribute("itemprop"))break;return t;default:return t}}else if(s==="input"&&t.type==="hidden"){var o=r.name==null?null:""+r.name;if(r.type==="hidden"&&t.getAttribute("name")===o)return t}else return t;if(t=cs(t.nextSibling),t===null)break}return null}function Fg(t,s,a){if(s==="")return null;for(;t.nodeType!==3;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!a||(t=cs(t.nextSibling),t===null))return null;return t}function Zf(t,s){for(;t.nodeType!==8;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!s||(t=cs(t.nextSibling),t===null))return null;return t}function pd(t){return t.data==="$?"||t.data==="$~"}function gd(t){return t.data==="$!"||t.data==="$?"&&t.ownerDocument.readyState!=="loading"}function Zg(t,s){var a=t.ownerDocument;if(t.data==="$~")t._reactRetry=s;else if(t.data!=="$?"||a.readyState!=="loading")s();else{var l=function(){s(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),t._reactRetry=l}}function cs(t){for(;t!=null;t=t.nextSibling){var s=t.nodeType;if(s===1||s===3)break;if(s===8){if(s=t.data,s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"||s==="F!"||s==="F")break;if(s==="/$"||s==="/&")return null}}return t}var bd=null;function Jf(t){t=t.nextSibling;for(var s=0;t;){if(t.nodeType===8){var a=t.data;if(a==="/$"||a==="/&"){if(s===0)return cs(t.nextSibling);s--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||s++}t=t.nextSibling}return null}function If(t){t=t.previousSibling;for(var s=0;t;){if(t.nodeType===8){var a=t.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(s===0)return t;s--}else a!=="/$"&&a!=="/&"||s++}t=t.previousSibling}return null}function Pf(t,s,a){switch(s=Sr(a),t){case"html":if(t=s.documentElement,!t)throw Error(c(452));return t;case"head":if(t=s.head,!t)throw Error(c(453));return t;case"body":if(t=s.body,!t)throw Error(c(454));return t;default:throw Error(c(451))}}function Zl(t){for(var s=t.attributes;s.length;)t.removeAttributeNode(s[0]);yc(t)}var os=new Map,Wf=new Set;function kr(t){return typeof t.getRootNode=="function"?t.getRootNode():t.nodeType===9?t:t.ownerDocument}var Ws=ne.d;ne.d={f:Jg,r:Ig,D:Pg,C:Wg,L:eb,m:tb,X:ab,S:sb,M:nb};function Jg(){var t=Ws.f(),s=pr();return t||s}function Ig(t){var s=fn(t);s!==null&&s.tag===5&&s.type==="form"?hx(s):Ws.r(t)}var Xn=typeof document>"u"?null:document;function eh(t,s,a){var l=Xn;if(l&&typeof s=="string"&&s){var r=ts(s);r='link[rel="'+t+'"][href="'+r+'"]',typeof a=="string"&&(r+='[crossorigin="'+a+'"]'),Wf.has(r)||(Wf.add(r),t={rel:t,crossOrigin:a,href:s},l.querySelector(r)===null&&(s=l.createElement("link"),Ct(s,"link",t),vt(s),l.head.appendChild(s)))}}function Pg(t){Ws.D(t),eh("dns-prefetch",t,null)}function Wg(t,s){Ws.C(t,s),eh("preconnect",t,s)}function eb(t,s,a){Ws.L(t,s,a);var l=Xn;if(l&&t&&s){var r='link[rel="preload"][as="'+ts(s)+'"]';s==="image"&&a&&a.imageSrcSet?(r+='[imagesrcset="'+ts(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(r+='[imagesizes="'+ts(a.imageSizes)+'"]')):r+='[href="'+ts(t)+'"]';var o=r;switch(s){case"style":o=Qn(t);break;case"script":o=Fn(t)}os.has(o)||(t=y({rel:"preload",href:s==="image"&&a&&a.imageSrcSet?void 0:t,as:s},a),os.set(o,t),l.querySelector(r)!==null||s==="style"&&l.querySelector(Jl(o))||s==="script"&&l.querySelector(Il(o))||(s=l.createElement("link"),Ct(s,"link",t),vt(s),l.head.appendChild(s)))}}function tb(t,s){Ws.m(t,s);var a=Xn;if(a&&t){var l=s&&typeof s.as=="string"?s.as:"script",r='link[rel="modulepreload"][as="'+ts(l)+'"][href="'+ts(t)+'"]',o=r;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":o=Fn(t)}if(!os.has(o)&&(t=y({rel:"modulepreload",href:t},s),os.set(o,t),a.querySelector(r)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Il(o)))return}l=a.createElement("link"),Ct(l,"link",t),vt(l),a.head.appendChild(l)}}}function sb(t,s,a){Ws.S(t,s,a);var l=Xn;if(l&&t){var r=hn(l).hoistableStyles,o=Qn(t);s=s||"default";var x=r.get(o);if(!x){var j={loading:0,preload:null};if(x=l.querySelector(Jl(o)))j.loading=5;else{t=y({rel:"stylesheet",href:t,"data-precedence":s},a),(a=os.get(o))&&yd(t,a);var E=x=l.createElement("link");vt(E),Ct(E,"link",t),E._p=new Promise(function(q,J){E.onload=q,E.onerror=J}),E.addEventListener("load",function(){j.loading|=1}),E.addEventListener("error",function(){j.loading|=2}),j.loading|=4,zr(x,s,l)}x={type:"stylesheet",instance:x,count:1,state:j},r.set(o,x)}}}function ab(t,s){Ws.X(t,s);var a=Xn;if(a&&t){var l=hn(a).hoistableScripts,r=Fn(t),o=l.get(r);o||(o=a.querySelector(Il(r)),o||(t=y({src:t,async:!0},s),(s=os.get(r))&&vd(t,s),o=a.createElement("script"),vt(o),Ct(o,"link",t),a.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},l.set(r,o))}}function nb(t,s){Ws.M(t,s);var a=Xn;if(a&&t){var l=hn(a).hoistableScripts,r=Fn(t),o=l.get(r);o||(o=a.querySelector(Il(r)),o||(t=y({src:t,async:!0,type:"module"},s),(s=os.get(r))&&vd(t,s),o=a.createElement("script"),vt(o),Ct(o,"link",t),a.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},l.set(r,o))}}function th(t,s,a,l){var r=(r=fe.current)?kr(r):null;if(!r)throw Error(c(446));switch(t){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(s=Qn(a.href),a=hn(r).hoistableStyles,l=a.get(s),l||(l={type:"style",instance:null,count:0,state:null},a.set(s,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){t=Qn(a.href);var o=hn(r).hoistableStyles,x=o.get(t);if(x||(r=r.ownerDocument||r,x={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},o.set(t,x),(o=r.querySelector(Jl(t)))&&!o._p&&(x.instance=o,x.state.loading=5),os.has(t)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},os.set(t,a),o||lb(r,t,a,x.state))),s&&l===null)throw Error(c(528,""));return x}if(s&&l!==null)throw Error(c(529,""));return null;case"script":return s=a.async,a=a.src,typeof a=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(s=Fn(a),a=hn(r).hoistableScripts,l=a.get(s),l||(l={type:"script",instance:null,count:0,state:null},a.set(s,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(c(444,t))}}function Qn(t){return'href="'+ts(t)+'"'}function Jl(t){return'link[rel="stylesheet"]['+t+"]"}function sh(t){return y({},t,{"data-precedence":t.precedence,precedence:null})}function lb(t,s,a,l){t.querySelector('link[rel="preload"][as="style"]['+s+"]")?l.loading=1:(s=t.createElement("link"),l.preload=s,s.addEventListener("load",function(){return l.loading|=1}),s.addEventListener("error",function(){return l.loading|=2}),Ct(s,"link",a),vt(s),t.head.appendChild(s))}function Fn(t){return'[src="'+ts(t)+'"]'}function Il(t){return"script[async]"+t}function ah(t,s,a){if(s.count++,s.instance===null)switch(s.type){case"style":var l=t.querySelector('style[data-href~="'+ts(a.href)+'"]');if(l)return s.instance=l,vt(l),l;var r=y({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(t.ownerDocument||t).createElement("style"),vt(l),Ct(l,"style",r),zr(l,a.precedence,t),s.instance=l;case"stylesheet":r=Qn(a.href);var o=t.querySelector(Jl(r));if(o)return s.state.loading|=4,s.instance=o,vt(o),o;l=sh(a),(r=os.get(r))&&yd(l,r),o=(t.ownerDocument||t).createElement("link"),vt(o);var x=o;return x._p=new Promise(function(j,E){x.onload=j,x.onerror=E}),Ct(o,"link",l),s.state.loading|=4,zr(o,a.precedence,t),s.instance=o;case"script":return o=Fn(a.src),(r=t.querySelector(Il(o)))?(s.instance=r,vt(r),r):(l=a,(r=os.get(o))&&(l=y({},a),vd(l,r)),t=t.ownerDocument||t,r=t.createElement("script"),vt(r),Ct(r,"link",l),t.head.appendChild(r),s.instance=r);case"void":return null;default:throw Error(c(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(l=s.instance,s.state.loading|=4,zr(l,a.precedence,t));return s.instance}function zr(t,s,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),r=l.length?l[l.length-1]:null,o=r,x=0;x<l.length;x++){var j=l[x];if(j.dataset.precedence===s)o=j;else if(o!==r)break}o?o.parentNode.insertBefore(t,o.nextSibling):(s=a.nodeType===9?a.head:a,s.insertBefore(t,s.firstChild))}function yd(t,s){t.crossOrigin==null&&(t.crossOrigin=s.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=s.referrerPolicy),t.title==null&&(t.title=s.title)}function vd(t,s){t.crossOrigin==null&&(t.crossOrigin=s.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=s.referrerPolicy),t.integrity==null&&(t.integrity=s.integrity)}var Cr=null;function nh(t,s,a){if(Cr===null){var l=new Map,r=Cr=new Map;r.set(a,l)}else r=Cr,l=r.get(a),l||(l=new Map,r.set(a,l));if(l.has(t))return l;for(l.set(t,null),a=a.getElementsByTagName(t),r=0;r<a.length;r++){var o=a[r];if(!(o[xl]||o[wt]||t==="link"&&o.getAttribute("rel")==="stylesheet")&&o.namespaceURI!=="http://www.w3.org/2000/svg"){var x=o.getAttribute(s)||"";x=t+x;var j=l.get(x);j?j.push(o):l.set(x,[o])}}return l}function lh(t,s,a){t=t.ownerDocument||t,t.head.insertBefore(a,s==="title"?t.querySelector("head > title"):null)}function ib(t,s,a){if(a===1||s.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;switch(s.rel){case"stylesheet":return t=s.disabled,typeof s.precedence=="string"&&t==null;default:return!0}case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function ih(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function rb(t,s,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var r=Qn(l.href),o=s.querySelector(Jl(r));if(o){s=o._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(t.count++,t=Ar.bind(t),s.then(t,t)),a.state.loading|=4,a.instance=o,vt(o);return}o=s.ownerDocument||s,l=sh(l),(r=os.get(r))&&yd(l,r),o=o.createElement("link"),vt(o);var x=o;x._p=new Promise(function(j,E){x.onload=j,x.onerror=E}),Ct(o,"link",l),a.instance=o}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(a,s),(s=a.state.preload)&&(a.state.loading&3)===0&&(t.count++,a=Ar.bind(t),s.addEventListener("load",a),s.addEventListener("error",a))}}var jd=0;function cb(t,s){return t.stylesheets&&t.count===0&&Tr(t,t.stylesheets),0<t.count||0<t.imgCount?function(a){var l=setTimeout(function(){if(t.stylesheets&&Tr(t,t.stylesheets),t.unsuspend){var o=t.unsuspend;t.unsuspend=null,o()}},6e4+s);0<t.imgBytes&&jd===0&&(jd=62500*Gg());var r=setTimeout(function(){if(t.waitingForImages=!1,t.count===0&&(t.stylesheets&&Tr(t,t.stylesheets),t.unsuspend)){var o=t.unsuspend;t.unsuspend=null,o()}},(t.imgBytes>jd?50:800)+s);return t.unsuspend=a,function(){t.unsuspend=null,clearTimeout(l),clearTimeout(r)}}:null}function Ar(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Tr(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var Er=null;function Tr(t,s){t.stylesheets=null,t.unsuspend!==null&&(t.count++,Er=new Map,s.forEach(ob,t),Er=null,Ar.call(t))}function ob(t,s){if(!(s.state.loading&4)){var a=Er.get(t);if(a)var l=a.get(null);else{a=new Map,Er.set(t,a);for(var r=t.querySelectorAll("link[data-precedence],style[data-precedence]"),o=0;o<r.length;o++){var x=r[o];(x.nodeName==="LINK"||x.getAttribute("media")!=="not all")&&(a.set(x.dataset.precedence,x),l=x)}l&&a.set(null,l)}r=s.instance,x=r.getAttribute("data-precedence"),o=a.get(x)||l,o===l&&a.set(null,r),a.set(x,r),this.count++,l=Ar.bind(this),r.addEventListener("load",l),r.addEventListener("error",l),o?o.parentNode.insertBefore(r,o.nextSibling):(t=t.nodeType===9?t.head:t,t.insertBefore(r,t.firstChild)),s.state.loading|=4}}var Pl={$$typeof:D,Provider:null,Consumer:null,_currentValue:me,_currentValue2:me,_threadCount:0};function db(t,s,a,l,r,o,x,j,E){this.tag=1,this.containerInfo=t,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=hc(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=hc(0),this.hiddenUpdates=hc(null),this.identifierPrefix=l,this.onUncaughtError=r,this.onCaughtError=o,this.onRecoverableError=x,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=E,this.incompleteTransitions=new Map}function rh(t,s,a,l,r,o,x,j,E,q,J,ee){return t=new db(t,s,a,x,E,q,J,ee,j),s=1,o===!0&&(s|=24),o=Yt(3,null,null,s),t.current=o,o.stateNode=t,s=Wc(),s.refCount++,t.pooledCache=s,s.refCount++,o.memoizedState={element:l,isDehydrated:a,cache:s},ao(o),t}function ch(t){return t?(t=kn,t):kn}function oh(t,s,a,l,r,o){r=ch(r),l.context===null?l.context=r:l.pendingContext=r,l=ha(s),l.payload={element:a},o=o===void 0?null:o,o!==null&&(l.callback=o),a=pa(t,l,s),a!==null&&(Gt(a,t,s),Tl(a,t,s))}function dh(t,s){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var a=t.retryLane;t.retryLane=a!==0&&a<s?a:s}}function Nd(t,s){dh(t,s),(t=t.alternate)&&dh(t,s)}function uh(t){if(t.tag===13||t.tag===31){var s=Ya(t,67108864);s!==null&&Gt(s,t,67108864),Nd(t,67108864)}}function mh(t){if(t.tag===13||t.tag===31){var s=Jt();s=pc(s);var a=Ya(t,s);a!==null&&Gt(a,t,s),Nd(t,s)}}var Rr=!0;function ub(t,s,a,l){var r=B.T;B.T=null;var o=ne.p;try{ne.p=2,wd(t,s,a,l)}finally{ne.p=o,B.T=r}}function mb(t,s,a,l){var r=B.T;B.T=null;var o=ne.p;try{ne.p=8,wd(t,s,a,l)}finally{ne.p=o,B.T=r}}function wd(t,s,a,l){if(Rr){var r=Sd(l);if(r===null)od(t,s,l,Mr,a),fh(t,l);else if(fb(r,t,s,a,l))l.stopPropagation();else if(fh(t,l),s&4&&-1<xb.indexOf(t)){for(;r!==null;){var o=fn(r);if(o!==null)switch(o.tag){case 3:if(o=o.stateNode,o.current.memoizedState.isDehydrated){var x=ws(o.pendingLanes);if(x!==0){var j=o;for(j.pendingLanes|=2,j.entangledLanes|=2;x;){var E=1<<31-Rt(x);j.entanglements[1]|=E,x&=~E}Cs(o),(Ue&6)===0&&(fr=yt()+500,Xl(0))}}break;case 31:case 13:j=Ya(o,2),j!==null&&Gt(j,o,2),pr(),Nd(o,2)}if(o=Sd(l),o===null&&od(t,s,l,Mr,a),o===r)break;r=o}r!==null&&l.stopPropagation()}else od(t,s,l,null,a)}}function Sd(t){return t=kc(t),kd(t)}var Mr=null;function kd(t){if(Mr=null,t=xn(t),t!==null){var s=f(t);if(s===null)t=null;else{var a=s.tag;if(a===13){if(t=h(s),t!==null)return t;t=null}else if(a===31){if(t=b(s),t!==null)return t;t=null}else if(a===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;t=null}else s!==t&&(t=null)}}return Mr=t,null}function xh(t){switch(t){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(dn()){case $a:return 2;case Ba:return 8;case Os:case Si:return 32;case K:return 268435456;default:return 32}default:return 32}}var zd=!1,Ca=null,Aa=null,Ea=null,Wl=new Map,ei=new Map,Ta=[],xb="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function fh(t,s){switch(t){case"focusin":case"focusout":Ca=null;break;case"dragenter":case"dragleave":Aa=null;break;case"mouseover":case"mouseout":Ea=null;break;case"pointerover":case"pointerout":Wl.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":ei.delete(s.pointerId)}}function ti(t,s,a,l,r,o){return t===null||t.nativeEvent!==o?(t={blockedOn:s,domEventName:a,eventSystemFlags:l,nativeEvent:o,targetContainers:[r]},s!==null&&(s=fn(s),s!==null&&uh(s)),t):(t.eventSystemFlags|=l,s=t.targetContainers,r!==null&&s.indexOf(r)===-1&&s.push(r),t)}function fb(t,s,a,l,r){switch(s){case"focusin":return Ca=ti(Ca,t,s,a,l,r),!0;case"dragenter":return Aa=ti(Aa,t,s,a,l,r),!0;case"mouseover":return Ea=ti(Ea,t,s,a,l,r),!0;case"pointerover":var o=r.pointerId;return Wl.set(o,ti(Wl.get(o)||null,t,s,a,l,r)),!0;case"gotpointercapture":return o=r.pointerId,ei.set(o,ti(ei.get(o)||null,t,s,a,l,r)),!0}return!1}function hh(t){var s=xn(t.target);if(s!==null){var a=f(s);if(a!==null){if(s=a.tag,s===13){if(s=h(a),s!==null){t.blockedOn=s,Au(t.priority,function(){mh(a)});return}}else if(s===31){if(s=b(a),s!==null){t.blockedOn=s,Au(t.priority,function(){mh(a)});return}}else if(s===3&&a.stateNode.current.memoizedState.isDehydrated){t.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Dr(t){if(t.blockedOn!==null)return!1;for(var s=t.targetContainers;0<s.length;){var a=Sd(t.nativeEvent);if(a===null){a=t.nativeEvent;var l=new a.constructor(a.type,a);Sc=l,a.target.dispatchEvent(l),Sc=null}else return s=fn(a),s!==null&&uh(s),t.blockedOn=a,!1;s.shift()}return!0}function ph(t,s,a){Dr(t)&&a.delete(s)}function hb(){zd=!1,Ca!==null&&Dr(Ca)&&(Ca=null),Aa!==null&&Dr(Aa)&&(Aa=null),Ea!==null&&Dr(Ea)&&(Ea=null),Wl.forEach(ph),ei.forEach(ph)}function Or(t,s){t.blockedOn===s&&(t.blockedOn=null,zd||(zd=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,hb)))}var Lr=null;function gh(t){Lr!==t&&(Lr=t,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){Lr===t&&(Lr=null);for(var s=0;s<t.length;s+=3){var a=t[s],l=t[s+1],r=t[s+2];if(typeof l!="function"){if(kd(l||a)===null)continue;break}var o=fn(a);o!==null&&(t.splice(s,3),s-=3,So(o,{pending:!0,data:r,method:a.method,action:l},l,r))}}))}function Zn(t){function s(E){return Or(E,t)}Ca!==null&&Or(Ca,t),Aa!==null&&Or(Aa,t),Ea!==null&&Or(Ea,t),Wl.forEach(s),ei.forEach(s);for(var a=0;a<Ta.length;a++){var l=Ta[a];l.blockedOn===t&&(l.blockedOn=null)}for(;0<Ta.length&&(a=Ta[0],a.blockedOn===null);)hh(a),a.blockedOn===null&&Ta.shift();if(a=(t.ownerDocument||t).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var r=a[l],o=a[l+1],x=r[_t]||null;if(typeof o=="function")x||gh(a);else if(x){var j=null;if(o&&o.hasAttribute("formAction")){if(r=o,x=o[_t]||null)j=x.formAction;else if(kd(r)!==null)continue}else j=x.action;typeof j=="function"?a[l+1]=j:(a.splice(l,3),l-=3),gh(a)}}}function bh(){function t(o){o.canIntercept&&o.info==="react-transition"&&o.intercept({handler:function(){return new Promise(function(x){return r=x})},focusReset:"manual",scroll:"manual"})}function s(){r!==null&&(r(),r=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var o=navigation.currentEntry;o&&o.url!=null&&navigation.navigate(o.url,{state:o.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,r=null;return navigation.addEventListener("navigate",t),navigation.addEventListener("navigatesuccess",s),navigation.addEventListener("navigateerror",s),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",t),navigation.removeEventListener("navigatesuccess",s),navigation.removeEventListener("navigateerror",s),r!==null&&(r(),r=null)}}}function Cd(t){this._internalRoot=t}_r.prototype.render=Cd.prototype.render=function(t){var s=this._internalRoot;if(s===null)throw Error(c(409));var a=s.current,l=Jt();oh(a,l,t,s,null,null)},_r.prototype.unmount=Cd.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var s=t.containerInfo;oh(t.current,2,null,t,null,null),pr(),s[mn]=null}};function _r(t){this._internalRoot=t}_r.prototype.unstable_scheduleHydration=function(t){if(t){var s=Cu();t={blockedOn:null,target:t,priority:s};for(var a=0;a<Ta.length&&s!==0&&s<Ta[a].priority;a++);Ta.splice(a,0,t),a===0&&hh(t)}};var yh=i.version;if(yh!=="19.2.4")throw Error(c(527,yh,"19.2.4"));ne.findDOMNode=function(t){var s=t._reactInternals;if(s===void 0)throw typeof t.render=="function"?Error(c(188)):(t=Object.keys(t).join(","),Error(c(268,t)));return t=p(s),t=t!==null?S(t):null,t=t===null?null:t.stateNode,t};var pb={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:B,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ur=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ur.isDisabled&&Ur.supportsFiber)try{Se=Ur.inject(pb),Oe=Ur}catch{}}return ai.createRoot=function(t,s){if(!m(t))throw Error(c(299));var a=!1,l="",r=kx,o=zx,x=Cx;return s!=null&&(s.unstable_strictMode===!0&&(a=!0),s.identifierPrefix!==void 0&&(l=s.identifierPrefix),s.onUncaughtError!==void 0&&(r=s.onUncaughtError),s.onCaughtError!==void 0&&(o=s.onCaughtError),s.onRecoverableError!==void 0&&(x=s.onRecoverableError)),s=rh(t,1,!1,null,null,a,l,null,r,o,x,bh),t[mn]=s.current,cd(t),new Cd(s)},ai.hydrateRoot=function(t,s,a){if(!m(t))throw Error(c(299));var l=!1,r="",o=kx,x=zx,j=Cx,E=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(r=a.identifierPrefix),a.onUncaughtError!==void 0&&(o=a.onUncaughtError),a.onCaughtError!==void 0&&(x=a.onCaughtError),a.onRecoverableError!==void 0&&(j=a.onRecoverableError),a.formState!==void 0&&(E=a.formState)),s=rh(t,1,!0,s,a??null,l,r,E,o,x,j,bh),s.context=ch(null),a=s.current,l=Jt(),l=pc(l),r=ha(l),r.callback=null,pa(a,r,l),a=l,s.current.lanes=a,ml(s,a),Cs(s),t[mn]=s.current,cd(t),new _r(s)},ai.version="19.2.4",ai}var Eh;function Ab(){if(Eh)return Rd.exports;Eh=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(i){console.error(i)}}return n(),Rd.exports=Cb(),Rd.exports}var Eb=Ab();/**
50
+ * react-router v7.13.2
51
+ *
52
+ * Copyright (c) Remix Software Inc.
53
+ *
54
+ * This source code is licensed under the MIT license found in the
55
+ * LICENSE.md file in the root directory of this source tree.
56
+ *
57
+ * @license MIT
58
+ */var Th="popstate";function Rh(n){return typeof n=="object"&&n!=null&&"pathname"in n&&"search"in n&&"hash"in n&&"state"in n&&"key"in n}function Tb(n={}){function i(c,m){var p;let f=(p=m.state)==null?void 0:p.masked,{pathname:h,search:b,hash:g}=f||c.location;return Xd("",{pathname:h,search:b,hash:g},m.state&&m.state.usr||null,m.state&&m.state.key||"default",f?{pathname:c.location.pathname,search:c.location.search,hash:c.location.hash}:void 0)}function d(c,m){return typeof m=="string"?m:mi(m)}return Mb(i,d,null,n)}function Pe(n,i){if(n===!1||n===null||typeof n>"u")throw new Error(i)}function ms(n,i){if(!n){typeof console<"u"&&console.warn(i);try{throw new Error(i)}catch{}}}function Rb(){return Math.random().toString(36).substring(2,10)}function Mh(n,i){return{usr:n.state,key:n.key,idx:i,masked:n.unstable_mask?{pathname:n.pathname,search:n.search,hash:n.hash}:void 0}}function Xd(n,i,d=null,c,m){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof i=="string"?sl(i):i,state:d,key:i&&i.key||c||Rb(),unstable_mask:m}}function mi({pathname:n="/",search:i="",hash:d=""}){return i&&i!=="?"&&(n+=i.charAt(0)==="?"?i:"?"+i),d&&d!=="#"&&(n+=d.charAt(0)==="#"?d:"#"+d),n}function sl(n){let i={};if(n){let d=n.indexOf("#");d>=0&&(i.hash=n.substring(d),n=n.substring(0,d));let c=n.indexOf("?");c>=0&&(i.search=n.substring(c),n=n.substring(0,c)),n&&(i.pathname=n)}return i}function Mb(n,i,d,c={}){let{window:m=document.defaultView,v5Compat:f=!1}=c,h=m.history,b="POP",g=null,p=S();p==null&&(p=0,h.replaceState({...h.state,idx:p},""));function S(){return(h.state||{idx:null}).idx}function y(){b="POP";let N=S(),z=N==null?null:N-p;p=N,g&&g({action:b,location:w.location,delta:z})}function v(N,z){b="PUSH";let R=Rh(N)?N:Xd(w.location,N,z);p=S()+1;let D=Mh(R,p),O=w.createHref(R.unstable_mask||R);try{h.pushState(D,"",O)}catch(se){if(se instanceof DOMException&&se.name==="DataCloneError")throw se;m.location.assign(O)}f&&g&&g({action:b,location:w.location,delta:1})}function k(N,z){b="REPLACE";let R=Rh(N)?N:Xd(w.location,N,z);p=S();let D=Mh(R,p),O=w.createHref(R.unstable_mask||R);h.replaceState(D,"",O),f&&g&&g({action:b,location:w.location,delta:0})}function C(N){return Db(N)}let w={get action(){return b},get location(){return n(m,h)},listen(N){if(g)throw new Error("A history only accepts one active listener");return m.addEventListener(Th,y),g=N,()=>{m.removeEventListener(Th,y),g=null}},createHref(N){return i(m,N)},createURL:C,encodeLocation(N){let z=C(N);return{pathname:z.pathname,search:z.search,hash:z.hash}},push:v,replace:k,go(N){return h.go(N)}};return w}function Db(n,i=!1){let d="http://localhost";typeof window<"u"&&(d=window.location.origin!=="null"?window.location.origin:window.location.href),Pe(d,"No window.location.(origin|href) available to create URL");let c=typeof n=="string"?n:mi(n);return c=c.replace(/ $/,"%20"),!i&&c.startsWith("//")&&(c=d+c),new URL(c,d)}function i0(n,i,d="/"){return Ob(n,i,d,!1)}function Ob(n,i,d,c){let m=typeof i=="string"?sl(i):i,f=aa(m.pathname||"/",d);if(f==null)return null;let h=r0(n);Lb(h);let b=null;for(let g=0;b==null&&g<h.length;++g){let p=Xb(f);b=Vb(h[g],p,c)}return b}function r0(n,i=[],d=[],c="",m=!1){let f=(h,b,g=m,p)=>{let S={relativePath:p===void 0?h.path||"":p,caseSensitive:h.caseSensitive===!0,childrenIndex:b,route:h};if(S.relativePath.startsWith("/")){if(!S.relativePath.startsWith(c)&&g)return;Pe(S.relativePath.startsWith(c),`Absolute route path "${S.relativePath}" nested under path "${c}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),S.relativePath=S.relativePath.slice(c.length)}let y=As([c,S.relativePath]),v=d.concat(S);h.children&&h.children.length>0&&(Pe(h.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${y}".`),r0(h.children,i,v,y,g)),!(h.path==null&&!h.index)&&i.push({path:y,score:Gb(y,h.index),routesMeta:v})};return n.forEach((h,b)=>{var g;if(h.path===""||!((g=h.path)!=null&&g.includes("?")))f(h,b);else for(let p of c0(h.path))f(h,b,!0,p)}),i}function c0(n){let i=n.split("/");if(i.length===0)return[];let[d,...c]=i,m=d.endsWith("?"),f=d.replace(/\?$/,"");if(c.length===0)return m?[f,""]:[f];let h=c0(c.join("/")),b=[];return b.push(...h.map(g=>g===""?f:[f,g].join("/"))),m&&b.push(...h),b.map(g=>n.startsWith("/")&&g===""?"/":g)}function Lb(n){n.sort((i,d)=>i.score!==d.score?d.score-i.score:Kb(i.routesMeta.map(c=>c.childrenIndex),d.routesMeta.map(c=>c.childrenIndex)))}var _b=/^:[\w-]+$/,Ub=3,$b=2,Bb=1,Hb=10,qb=-2,Dh=n=>n==="*";function Gb(n,i){let d=n.split("/"),c=d.length;return d.some(Dh)&&(c+=qb),i&&(c+=$b),d.filter(m=>!Dh(m)).reduce((m,f)=>m+(_b.test(f)?Ub:f===""?Bb:Hb),c)}function Kb(n,i){return n.length===i.length&&n.slice(0,-1).every((c,m)=>c===i[m])?n[n.length-1]-i[i.length-1]:0}function Vb(n,i,d=!1){let{routesMeta:c}=n,m={},f="/",h=[];for(let b=0;b<c.length;++b){let g=c[b],p=b===c.length-1,S=f==="/"?i:i.slice(f.length)||"/",y=ec({path:g.relativePath,caseSensitive:g.caseSensitive,end:p},S),v=g.route;if(!y&&p&&d&&!c[c.length-1].route.index&&(y=ec({path:g.relativePath,caseSensitive:g.caseSensitive,end:!1},S)),!y)return null;Object.assign(m,y.params),h.push({params:m,pathname:As([f,y.pathname]),pathnameBase:Jb(As([f,y.pathnameBase])),route:v}),y.pathnameBase!=="/"&&(f=As([f,y.pathnameBase]))}return h}function ec(n,i){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[d,c]=Yb(n.path,n.caseSensitive,n.end),m=i.match(d);if(!m)return null;let f=m[0],h=f.replace(/(.)\/+$/,"$1"),b=m.slice(1);return{params:c.reduce((p,{paramName:S,isOptional:y},v)=>{if(S==="*"){let C=b[v]||"";h=f.slice(0,f.length-C.length).replace(/(.)\/+$/,"$1")}const k=b[v];return y&&!k?p[S]=void 0:p[S]=(k||"").replace(/%2F/g,"/"),p},{}),pathname:f,pathnameBase:h,pattern:n}}function Yb(n,i=!1,d=!0){ms(n==="*"||!n.endsWith("*")||n.endsWith("/*"),`Route path "${n}" will be treated as if it were "${n.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${n.replace(/\*$/,"/*")}".`);let c=[],m="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(h,b,g,p,S)=>{if(c.push({paramName:b,isOptional:g!=null}),g){let y=S.charAt(p+h.length);return y&&y!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return n.endsWith("*")?(c.push({paramName:"*"}),m+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):d?m+="\\/*$":n!==""&&n!=="/"&&(m+="(?:(?=\\/|$))"),[new RegExp(m,i?void 0:"i"),c]}function Xb(n){try{return n.split("/").map(i=>decodeURIComponent(i).replace(/\//g,"%2F")).join("/")}catch(i){return ms(!1,`The URL path "${n}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${i}).`),n}}function aa(n,i){if(i==="/")return n;if(!n.toLowerCase().startsWith(i.toLowerCase()))return null;let d=i.endsWith("/")?i.length-1:i.length,c=n.charAt(d);return c&&c!=="/"?null:n.slice(d)||"/"}var Qb=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Fb(n,i="/"){let{pathname:d,search:c="",hash:m=""}=typeof n=="string"?sl(n):n,f;return d?(d=d.replace(/\/\/+/g,"/"),d.startsWith("/")?f=Oh(d.substring(1),"/"):f=Oh(d,i)):f=i,{pathname:f,search:Ib(c),hash:Pb(m)}}function Oh(n,i){let d=i.replace(/\/+$/,"").split("/");return n.split("/").forEach(m=>{m===".."?d.length>1&&d.pop():m!=="."&&d.push(m)}),d.length>1?d.join("/"):"/"}function Ld(n,i,d,c){return`Cannot include a '${n}' character in a manually specified \`to.${i}\` field [${JSON.stringify(c)}]. Please separate it out to the \`to.${d}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Zb(n){return n.filter((i,d)=>d===0||i.route.path&&i.route.path.length>0)}function nu(n){let i=Zb(n);return i.map((d,c)=>c===i.length-1?d.pathname:d.pathnameBase)}function nc(n,i,d,c=!1){let m;typeof n=="string"?m=sl(n):(m={...n},Pe(!m.pathname||!m.pathname.includes("?"),Ld("?","pathname","search",m)),Pe(!m.pathname||!m.pathname.includes("#"),Ld("#","pathname","hash",m)),Pe(!m.search||!m.search.includes("#"),Ld("#","search","hash",m)));let f=n===""||m.pathname==="",h=f?"/":m.pathname,b;if(h==null)b=d;else{let y=i.length-1;if(!c&&h.startsWith("..")){let v=h.split("/");for(;v[0]==="..";)v.shift(),y-=1;m.pathname=v.join("/")}b=y>=0?i[y]:"/"}let g=Fb(m,b),p=h&&h!=="/"&&h.endsWith("/"),S=(f||h===".")&&d.endsWith("/");return!g.pathname.endsWith("/")&&(p||S)&&(g.pathname+="/"),g}var As=n=>n.join("/").replace(/\/\/+/g,"/"),Jb=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),Ib=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,Pb=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n,Wb=class{constructor(n,i,d,c=!1){this.status=n,this.statusText=i||"",this.internal=c,d instanceof Error?(this.data=d.toString(),this.error=d):this.data=d}};function ey(n){return n!=null&&typeof n.status=="number"&&typeof n.statusText=="string"&&typeof n.internal=="boolean"&&"data"in n}function ty(n){return n.map(i=>i.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var o0=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function d0(n,i){let d=n;if(typeof d!="string"||!Qb.test(d))return{absoluteURL:void 0,isExternal:!1,to:d};let c=d,m=!1;if(o0)try{let f=new URL(window.location.href),h=d.startsWith("//")?new URL(f.protocol+d):new URL(d),b=aa(h.pathname,i);h.origin===f.origin&&b!=null?d=b+h.search+h.hash:m=!0}catch{ms(!1,`<Link to="${d}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:c,isExternal:m,to:d}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var u0=["POST","PUT","PATCH","DELETE"];new Set(u0);var sy=["GET",...u0];new Set(sy);var al=u.createContext(null);al.displayName="DataRouter";var lc=u.createContext(null);lc.displayName="DataRouterState";var ay=u.createContext(!1),m0=u.createContext({isTransitioning:!1});m0.displayName="ViewTransition";var ny=u.createContext(new Map);ny.displayName="Fetchers";var ly=u.createContext(null);ly.displayName="Await";var Wt=u.createContext(null);Wt.displayName="Navigation";var vi=u.createContext(null);vi.displayName="Location";var xs=u.createContext({outlet:null,matches:[],isDataRoute:!1});xs.displayName="Route";var lu=u.createContext(null);lu.displayName="RouteError";var x0="REACT_ROUTER_ERROR",iy="REDIRECT",ry="ROUTE_ERROR_RESPONSE";function cy(n){if(n.startsWith(`${x0}:${iy}:{`))try{let i=JSON.parse(n.slice(28));if(typeof i=="object"&&i&&typeof i.status=="number"&&typeof i.statusText=="string"&&typeof i.location=="string"&&typeof i.reloadDocument=="boolean"&&typeof i.replace=="boolean")return i}catch{}}function oy(n){if(n.startsWith(`${x0}:${ry}:{`))try{let i=JSON.parse(n.slice(40));if(typeof i=="object"&&i&&typeof i.status=="number"&&typeof i.statusText=="string")return new Wb(i.status,i.statusText,i.data)}catch{}}function dy(n,{relative:i}={}){Pe(nl(),"useHref() may be used only in the context of a <Router> component.");let{basename:d,navigator:c}=u.useContext(Wt),{hash:m,pathname:f,search:h}=ji(n,{relative:i}),b=f;return d!=="/"&&(b=f==="/"?d:As([d,f])),c.createHref({pathname:b,search:h,hash:m})}function nl(){return u.useContext(vi)!=null}function js(){return Pe(nl(),"useLocation() may be used only in the context of a <Router> component."),u.useContext(vi).location}var f0="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function h0(n){u.useContext(Wt).static||u.useLayoutEffect(n)}function Dt(){let{isDataRoute:n}=u.useContext(xs);return n?ky():uy()}function uy(){Pe(nl(),"useNavigate() may be used only in the context of a <Router> component.");let n=u.useContext(al),{basename:i,navigator:d}=u.useContext(Wt),{matches:c}=u.useContext(xs),{pathname:m}=js(),f=JSON.stringify(nu(c)),h=u.useRef(!1);return h0(()=>{h.current=!0}),u.useCallback((g,p={})=>{if(ms(h.current,f0),!h.current)return;if(typeof g=="number"){d.go(g);return}let S=nc(g,JSON.parse(f),m,p.relative==="path");n==null&&i!=="/"&&(S.pathname=S.pathname==="/"?i:As([i,S.pathname])),(p.replace?d.replace:d.push)(S,p.state,p)},[i,d,f,m,n])}var my=u.createContext(null);function xy(n){let i=u.useContext(xs).outlet;return u.useMemo(()=>i&&u.createElement(my.Provider,{value:n},i),[i,n])}function ll(){let{matches:n}=u.useContext(xs),i=n[n.length-1];return i?i.params:{}}function ji(n,{relative:i}={}){let{matches:d}=u.useContext(xs),{pathname:c}=js(),m=JSON.stringify(nu(d));return u.useMemo(()=>nc(n,JSON.parse(m),c,i==="path"),[n,m,c,i])}function fy(n,i){return p0(n,i)}function p0(n,i,d){var N;Pe(nl(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:c}=u.useContext(Wt),{matches:m}=u.useContext(xs),f=m[m.length-1],h=f?f.params:{},b=f?f.pathname:"/",g=f?f.pathnameBase:"/",p=f&&f.route;{let z=p&&p.path||"";b0(b,!p||z.endsWith("*")||z.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${b}" (under <Route path="${z}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
59
+
60
+ Please change the parent <Route path="${z}"> to <Route path="${z==="/"?"*":`${z}/*`}">.`)}let S=js(),y;if(i){let z=typeof i=="string"?sl(i):i;Pe(g==="/"||((N=z.pathname)==null?void 0:N.startsWith(g)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${g}" but pathname "${z.pathname}" was given in the \`location\` prop.`),y=z}else y=S;let v=y.pathname||"/",k=v;if(g!=="/"){let z=g.replace(/^\//,"").split("/");k="/"+v.replace(/^\//,"").split("/").slice(z.length).join("/")}let C=i0(n,{pathname:k});ms(p||C!=null,`No routes matched location "${y.pathname}${y.search}${y.hash}" `),ms(C==null||C[C.length-1].route.element!==void 0||C[C.length-1].route.Component!==void 0||C[C.length-1].route.lazy!==void 0,`Matched leaf route at location "${y.pathname}${y.search}${y.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let w=yy(C&&C.map(z=>Object.assign({},z,{params:Object.assign({},h,z.params),pathname:As([g,c.encodeLocation?c.encodeLocation(z.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:z.pathname]),pathnameBase:z.pathnameBase==="/"?g:As([g,c.encodeLocation?c.encodeLocation(z.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:z.pathnameBase])})),m,d);return i&&w?u.createElement(vi.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...y},navigationType:"POP"}},w):w}function hy(){let n=Sy(),i=ey(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),d=n instanceof Error?n.stack:null,c="rgba(200,200,200, 0.5)",m={padding:"0.5rem",backgroundColor:c},f={padding:"2px 4px",backgroundColor:c},h=null;return console.error("Error handled by React Router default ErrorBoundary:",n),h=u.createElement(u.Fragment,null,u.createElement("p",null,"💿 Hey developer 👋"),u.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",u.createElement("code",{style:f},"ErrorBoundary")," or"," ",u.createElement("code",{style:f},"errorElement")," prop on your route.")),u.createElement(u.Fragment,null,u.createElement("h2",null,"Unexpected Application Error!"),u.createElement("h3",{style:{fontStyle:"italic"}},i),d?u.createElement("pre",{style:m},d):null,h)}var py=u.createElement(hy,null),g0=class extends u.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,i){return i.location!==n.location||i.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:i.error,location:i.location,revalidation:n.revalidation||i.revalidation}}componentDidCatch(n,i){this.props.onError?this.props.onError(n,i):console.error("React Router caught the following error during render",n)}render(){let n=this.state.error;if(this.context&&typeof n=="object"&&n&&"digest"in n&&typeof n.digest=="string"){const d=oy(n.digest);d&&(n=d)}let i=n!==void 0?u.createElement(xs.Provider,{value:this.props.routeContext},u.createElement(lu.Provider,{value:n,children:this.props.component})):this.props.children;return this.context?u.createElement(gy,{error:n},i):i}};g0.contextType=ay;var _d=new WeakMap;function gy({children:n,error:i}){let{basename:d}=u.useContext(Wt);if(typeof i=="object"&&i&&"digest"in i&&typeof i.digest=="string"){let c=cy(i.digest);if(c){let m=_d.get(i);if(m)throw m;let f=d0(c.location,d);if(o0&&!_d.get(i))if(f.isExternal||c.reloadDocument)window.location.href=f.absoluteURL||f.to;else{const h=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(f.to,{replace:c.replace}));throw _d.set(i,h),h}return u.createElement("meta",{httpEquiv:"refresh",content:`0;url=${f.absoluteURL||f.to}`})}}return n}function by({routeContext:n,match:i,children:d}){let c=u.useContext(al);return c&&c.static&&c.staticContext&&(i.route.errorElement||i.route.ErrorBoundary)&&(c.staticContext._deepestRenderedBoundaryId=i.route.id),u.createElement(xs.Provider,{value:n},d)}function yy(n,i=[],d){let c=d==null?void 0:d.state;if(n==null){if(!c)return null;if(c.errors)n=c.matches;else if(i.length===0&&!c.initialized&&c.matches.length>0)n=c.matches;else return null}let m=n,f=c==null?void 0:c.errors;if(f!=null){let S=m.findIndex(y=>y.route.id&&(f==null?void 0:f[y.route.id])!==void 0);Pe(S>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(f).join(",")}`),m=m.slice(0,Math.min(m.length,S+1))}let h=!1,b=-1;if(d&&c){h=c.renderFallback;for(let S=0;S<m.length;S++){let y=m[S];if((y.route.HydrateFallback||y.route.hydrateFallbackElement)&&(b=S),y.route.id){let{loaderData:v,errors:k}=c,C=y.route.loader&&!v.hasOwnProperty(y.route.id)&&(!k||k[y.route.id]===void 0);if(y.route.lazy||C){d.isStatic&&(h=!0),b>=0?m=m.slice(0,b+1):m=[m[0]];break}}}}let g=d==null?void 0:d.onError,p=c&&g?(S,y)=>{var v,k;g(S,{location:c.location,params:((k=(v=c.matches)==null?void 0:v[0])==null?void 0:k.params)??{},unstable_pattern:ty(c.matches),errorInfo:y})}:void 0;return m.reduceRight((S,y,v)=>{let k,C=!1,w=null,N=null;c&&(k=f&&y.route.id?f[y.route.id]:void 0,w=y.route.errorElement||py,h&&(b<0&&v===0?(b0("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),C=!0,N=null):b===v&&(C=!0,N=y.route.hydrateFallbackElement||null)));let z=i.concat(m.slice(0,v+1)),R=()=>{let D;return k?D=w:C?D=N:y.route.Component?D=u.createElement(y.route.Component,null):y.route.element?D=y.route.element:D=S,u.createElement(by,{match:y,routeContext:{outlet:S,matches:z,isDataRoute:c!=null},children:D})};return c&&(y.route.ErrorBoundary||y.route.errorElement||v===0)?u.createElement(g0,{location:c.location,revalidation:c.revalidation,component:w,error:k,children:R(),routeContext:{outlet:null,matches:z,isDataRoute:!0},onError:p}):R()},null)}function iu(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function vy(n){let i=u.useContext(al);return Pe(i,iu(n)),i}function jy(n){let i=u.useContext(lc);return Pe(i,iu(n)),i}function Ny(n){let i=u.useContext(xs);return Pe(i,iu(n)),i}function ru(n){let i=Ny(n),d=i.matches[i.matches.length-1];return Pe(d.route.id,`${n} can only be used on routes that contain a unique "id"`),d.route.id}function wy(){return ru("useRouteId")}function Sy(){var c;let n=u.useContext(lu),i=jy("useRouteError"),d=ru("useRouteError");return n!==void 0?n:(c=i.errors)==null?void 0:c[d]}function ky(){let{router:n}=vy("useNavigate"),i=ru("useNavigate"),d=u.useRef(!1);return h0(()=>{d.current=!0}),u.useCallback(async(m,f={})=>{ms(d.current,f0),d.current&&(typeof m=="number"?await n.navigate(m):await n.navigate(m,{fromRouteId:i,...f}))},[n,i])}var Lh={};function b0(n,i,d){!i&&!Lh[n]&&(Lh[n]=!0,ms(!1,d))}u.memo(zy);function zy({routes:n,future:i,state:d,isStatic:c,onError:m}){return p0(n,void 0,{state:d,isStatic:c,onError:m})}function _h({to:n,replace:i,state:d,relative:c}){Pe(nl(),"<Navigate> may be used only in the context of a <Router> component.");let{static:m}=u.useContext(Wt);ms(!m,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:f}=u.useContext(xs),{pathname:h}=js(),b=Dt(),g=nc(n,nu(f),h,c==="path"),p=JSON.stringify(g);return u.useEffect(()=>{b(JSON.parse(p),{replace:i,state:d,relative:c})},[b,p,c,i,d]),null}function Cy(n){return xy(n.context)}function Me(n){Pe(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Ay({basename:n="/",children:i=null,location:d,navigationType:c="POP",navigator:m,static:f=!1,unstable_useTransitions:h}){Pe(!nl(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let b=n.replace(/^\/*/,"/"),g=u.useMemo(()=>({basename:b,navigator:m,static:f,unstable_useTransitions:h,future:{}}),[b,m,f,h]);typeof d=="string"&&(d=sl(d));let{pathname:p="/",search:S="",hash:y="",state:v=null,key:k="default",unstable_mask:C}=d,w=u.useMemo(()=>{let N=aa(p,b);return N==null?null:{location:{pathname:N,search:S,hash:y,state:v,key:k,unstable_mask:C},navigationType:c}},[b,p,S,y,v,k,c,C]);return ms(w!=null,`<Router basename="${b}"> is not able to match the URL "${p}${S}${y}" because it does not start with the basename, so the <Router> won't render anything.`),w==null?null:u.createElement(Wt.Provider,{value:g},u.createElement(vi.Provider,{children:i,value:w}))}function y0({children:n,location:i}){return fy(Qd(n),i)}function Qd(n,i=[]){let d=[];return u.Children.forEach(n,(c,m)=>{if(!u.isValidElement(c))return;let f=[...i,m];if(c.type===u.Fragment){d.push.apply(d,Qd(c.props.children,f));return}Pe(c.type===Me,`[${typeof c.type=="string"?c.type:c.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Pe(!c.props.index||!c.props.children,"An index route cannot have child routes.");let h={id:c.props.id||f.join("-"),caseSensitive:c.props.caseSensitive,element:c.props.element,Component:c.props.Component,index:c.props.index,path:c.props.path,middleware:c.props.middleware,loader:c.props.loader,action:c.props.action,hydrateFallbackElement:c.props.hydrateFallbackElement,HydrateFallback:c.props.HydrateFallback,errorElement:c.props.errorElement,ErrorBoundary:c.props.ErrorBoundary,hasErrorBoundary:c.props.hasErrorBoundary===!0||c.props.ErrorBoundary!=null||c.props.errorElement!=null,shouldRevalidate:c.props.shouldRevalidate,handle:c.props.handle,lazy:c.props.lazy};c.props.children&&(h.children=Qd(c.props.children,f)),d.push(h)}),d}var Jr="get",Ir="application/x-www-form-urlencoded";function ic(n){return typeof HTMLElement<"u"&&n instanceof HTMLElement}function Ey(n){return ic(n)&&n.tagName.toLowerCase()==="button"}function Ty(n){return ic(n)&&n.tagName.toLowerCase()==="form"}function Ry(n){return ic(n)&&n.tagName.toLowerCase()==="input"}function My(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function Dy(n,i){return n.button===0&&(!i||i==="_self")&&!My(n)}function Fd(n=""){return new URLSearchParams(typeof n=="string"||Array.isArray(n)||n instanceof URLSearchParams?n:Object.keys(n).reduce((i,d)=>{let c=n[d];return i.concat(Array.isArray(c)?c.map(m=>[d,m]):[[d,c]])},[]))}function Oy(n,i){let d=Fd(n);return i&&i.forEach((c,m)=>{d.has(m)||i.getAll(m).forEach(f=>{d.append(m,f)})}),d}var $r=null;function Ly(){if($r===null)try{new FormData(document.createElement("form"),0),$r=!1}catch{$r=!0}return $r}var _y=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ud(n){return n!=null&&!_y.has(n)?(ms(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ir}"`),null):n}function Uy(n,i){let d,c,m,f,h;if(Ty(n)){let b=n.getAttribute("action");c=b?aa(b,i):null,d=n.getAttribute("method")||Jr,m=Ud(n.getAttribute("enctype"))||Ir,f=new FormData(n)}else if(Ey(n)||Ry(n)&&(n.type==="submit"||n.type==="image")){let b=n.form;if(b==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let g=n.getAttribute("formaction")||b.getAttribute("action");if(c=g?aa(g,i):null,d=n.getAttribute("formmethod")||b.getAttribute("method")||Jr,m=Ud(n.getAttribute("formenctype"))||Ud(b.getAttribute("enctype"))||Ir,f=new FormData(b,n),!Ly()){let{name:p,type:S,value:y}=n;if(S==="image"){let v=p?`${p}.`:"";f.append(`${v}x`,"0"),f.append(`${v}y`,"0")}else p&&f.append(p,y)}}else{if(ic(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');d=Jr,c=null,m=Ir,h=n}return f&&m==="text/plain"&&(h=f,f=void 0),{action:c,method:d.toLowerCase(),encType:m,formData:f,body:h}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function cu(n,i){if(n===!1||n===null||typeof n>"u")throw new Error(i)}function $y(n,i,d,c){let m=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return d?m.pathname.endsWith("/")?m.pathname=`${m.pathname}_.${c}`:m.pathname=`${m.pathname}.${c}`:m.pathname==="/"?m.pathname=`_root.${c}`:i&&aa(m.pathname,i)==="/"?m.pathname=`${i.replace(/\/$/,"")}/_root.${c}`:m.pathname=`${m.pathname.replace(/\/$/,"")}.${c}`,m}async function By(n,i){if(n.id in i)return i[n.id];try{let d=await import(n.module);return i[n.id]=d,d}catch(d){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(d),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Hy(n){return n==null?!1:n.href==null?n.rel==="preload"&&typeof n.imageSrcSet=="string"&&typeof n.imageSizes=="string":typeof n.rel=="string"&&typeof n.href=="string"}async function qy(n,i,d){let c=await Promise.all(n.map(async m=>{let f=i.routes[m.route.id];if(f){let h=await By(f,d);return h.links?h.links():[]}return[]}));return Yy(c.flat(1).filter(Hy).filter(m=>m.rel==="stylesheet"||m.rel==="preload").map(m=>m.rel==="stylesheet"?{...m,rel:"prefetch",as:"style"}:{...m,rel:"prefetch"}))}function Uh(n,i,d,c,m,f){let h=(g,p)=>d[p]?g.route.id!==d[p].route.id:!0,b=(g,p)=>{var S;return d[p].pathname!==g.pathname||((S=d[p].route.path)==null?void 0:S.endsWith("*"))&&d[p].params["*"]!==g.params["*"]};return f==="assets"?i.filter((g,p)=>h(g,p)||b(g,p)):f==="data"?i.filter((g,p)=>{var y;let S=c.routes[g.route.id];if(!S||!S.hasLoader)return!1;if(h(g,p)||b(g,p))return!0;if(g.route.shouldRevalidate){let v=g.route.shouldRevalidate({currentUrl:new URL(m.pathname+m.search+m.hash,window.origin),currentParams:((y=d[0])==null?void 0:y.params)||{},nextUrl:new URL(n,window.origin),nextParams:g.params,defaultShouldRevalidate:!0});if(typeof v=="boolean")return v}return!0}):[]}function Gy(n,i,{includeHydrateFallback:d}={}){return Ky(n.map(c=>{let m=i.routes[c.route.id];if(!m)return[];let f=[m.module];return m.clientActionModule&&(f=f.concat(m.clientActionModule)),m.clientLoaderModule&&(f=f.concat(m.clientLoaderModule)),d&&m.hydrateFallbackModule&&(f=f.concat(m.hydrateFallbackModule)),m.imports&&(f=f.concat(m.imports)),f}).flat(1))}function Ky(n){return[...new Set(n)]}function Vy(n){let i={},d=Object.keys(n).sort();for(let c of d)i[c]=n[c];return i}function Yy(n,i){let d=new Set;return new Set(i),n.reduce((c,m)=>{let f=JSON.stringify(Vy(m));return d.has(f)||(d.add(f),c.push({key:f,link:m})),c},[])}function v0(){let n=u.useContext(al);return cu(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function Xy(){let n=u.useContext(lc);return cu(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var ou=u.createContext(void 0);ou.displayName="FrameworkContext";function j0(){let n=u.useContext(ou);return cu(n,"You must render this element inside a <HydratedRouter> element"),n}function Qy(n,i){let d=u.useContext(ou),[c,m]=u.useState(!1),[f,h]=u.useState(!1),{onFocus:b,onBlur:g,onMouseEnter:p,onMouseLeave:S,onTouchStart:y}=i,v=u.useRef(null);u.useEffect(()=>{if(n==="render"&&h(!0),n==="viewport"){let w=z=>{z.forEach(R=>{h(R.isIntersecting)})},N=new IntersectionObserver(w,{threshold:.5});return v.current&&N.observe(v.current),()=>{N.disconnect()}}},[n]),u.useEffect(()=>{if(c){let w=setTimeout(()=>{h(!0)},100);return()=>{clearTimeout(w)}}},[c]);let k=()=>{m(!0)},C=()=>{m(!1),h(!1)};return d?n!=="intent"?[f,v,{}]:[f,v,{onFocus:ni(b,k),onBlur:ni(g,C),onMouseEnter:ni(p,k),onMouseLeave:ni(S,C),onTouchStart:ni(y,k)}]:[!1,v,{}]}function ni(n,i){return d=>{n&&n(d),d.defaultPrevented||i(d)}}function Fy({page:n,...i}){let{router:d}=v0(),c=u.useMemo(()=>i0(d.routes,n,d.basename),[d.routes,n,d.basename]);return c?u.createElement(Jy,{page:n,matches:c,...i}):null}function Zy(n){let{manifest:i,routeModules:d}=j0(),[c,m]=u.useState([]);return u.useEffect(()=>{let f=!1;return qy(n,i,d).then(h=>{f||m(h)}),()=>{f=!0}},[n,i,d]),c}function Jy({page:n,matches:i,...d}){let c=js(),{future:m,manifest:f,routeModules:h}=j0(),{basename:b}=v0(),{loaderData:g,matches:p}=Xy(),S=u.useMemo(()=>Uh(n,i,p,f,c,"data"),[n,i,p,f,c]),y=u.useMemo(()=>Uh(n,i,p,f,c,"assets"),[n,i,p,f,c]),v=u.useMemo(()=>{if(n===c.pathname+c.search+c.hash)return[];let w=new Set,N=!1;if(i.forEach(R=>{var O;let D=f.routes[R.route.id];!D||!D.hasLoader||(!S.some(se=>se.route.id===R.route.id)&&R.route.id in g&&((O=h[R.route.id])!=null&&O.shouldRevalidate)||D.hasClientLoader?N=!0:w.add(R.route.id))}),w.size===0)return[];let z=$y(n,b,m.unstable_trailingSlashAwareDataRequests,"data");return N&&w.size>0&&z.searchParams.set("_routes",i.filter(R=>w.has(R.route.id)).map(R=>R.route.id).join(",")),[z.pathname+z.search]},[b,m.unstable_trailingSlashAwareDataRequests,g,c,f,S,i,n,h]),k=u.useMemo(()=>Gy(y,f),[y,f]),C=Zy(y);return u.createElement(u.Fragment,null,v.map(w=>u.createElement("link",{key:w,rel:"prefetch",as:"fetch",href:w,...d})),k.map(w=>u.createElement("link",{key:w,rel:"modulepreload",href:w,...d})),C.map(({key:w,link:N})=>u.createElement("link",{key:w,nonce:d.nonce,...N,crossOrigin:N.crossOrigin??d.crossOrigin})))}function Iy(...n){return i=>{n.forEach(d=>{typeof d=="function"?d(i):d!=null&&(d.current=i)})}}var Py=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Py&&(window.__reactRouterVersion="7.13.2")}catch{}function Wy({basename:n,children:i,unstable_useTransitions:d,window:c}){let m=u.useRef();m.current==null&&(m.current=Tb({window:c,v5Compat:!0}));let f=m.current,[h,b]=u.useState({action:f.action,location:f.location}),g=u.useCallback(p=>{d===!1?b(p):u.startTransition(()=>b(p))},[d]);return u.useLayoutEffect(()=>f.listen(g),[f,g]),u.createElement(Ay,{basename:n,children:i,location:h.location,navigationType:h.action,navigator:f,unstable_useTransitions:d})}var N0=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ta=u.forwardRef(function({onClick:i,discover:d="render",prefetch:c="none",relative:m,reloadDocument:f,replace:h,unstable_mask:b,state:g,target:p,to:S,preventScrollReset:y,viewTransition:v,unstable_defaultShouldRevalidate:k,...C},w){let{basename:N,navigator:z,unstable_useTransitions:R}=u.useContext(Wt),D=typeof S=="string"&&N0.test(S),O=d0(S,N);S=O.to;let se=dy(S,{relative:m}),Z=js(),U=null;if(b){let Y=nc(b,[],Z.unstable_mask?Z.unstable_mask.pathname:"/",!0);N!=="/"&&(Y.pathname=Y.pathname==="/"?N:As([N,Y.pathname])),U=z.createHref(Y)}let[A,F,$]=Qy(c,C),Q=sv(S,{replace:h,unstable_mask:b,state:g,target:p,preventScrollReset:y,relative:m,viewTransition:v,unstable_defaultShouldRevalidate:k,unstable_useTransitions:R});function ce(Y){i&&i(Y),Y.defaultPrevented||Q(Y)}let I=!(O.isExternal||f),le=u.createElement("a",{...C,...$,href:(I?U:void 0)||O.absoluteURL||se,onClick:I?ce:i,ref:Iy(w,F),target:p,"data-discover":!D&&d==="render"?"true":void 0});return A&&!D?u.createElement(u.Fragment,null,le,u.createElement(Fy,{page:se})):le});ta.displayName="Link";var di=u.forwardRef(function({"aria-current":i="page",caseSensitive:d=!1,className:c="",end:m=!1,style:f,to:h,viewTransition:b,children:g,...p},S){let y=ji(h,{relative:p.relative}),v=js(),k=u.useContext(lc),{navigator:C,basename:w}=u.useContext(Wt),N=k!=null&&cv(y)&&b===!0,z=C.encodeLocation?C.encodeLocation(y).pathname:y.pathname,R=v.pathname,D=k&&k.navigation&&k.navigation.location?k.navigation.location.pathname:null;d||(R=R.toLowerCase(),D=D?D.toLowerCase():null,z=z.toLowerCase()),D&&w&&(D=aa(D,w)||D);const O=z!=="/"&&z.endsWith("/")?z.length-1:z.length;let se=R===z||!m&&R.startsWith(z)&&R.charAt(O)==="/",Z=D!=null&&(D===z||!m&&D.startsWith(z)&&D.charAt(z.length)==="/"),U={isActive:se,isPending:Z,isTransitioning:N},A=se?i:void 0,F;typeof c=="function"?F=c(U):F=[c,se?"active":null,Z?"pending":null,N?"transitioning":null].filter(Boolean).join(" ");let $=typeof f=="function"?f(U):f;return u.createElement(ta,{...p,"aria-current":A,className:F,ref:S,style:$,to:h,viewTransition:b},typeof g=="function"?g(U):g)});di.displayName="NavLink";var ev=u.forwardRef(({discover:n="render",fetcherKey:i,navigate:d,reloadDocument:c,replace:m,state:f,method:h=Jr,action:b,onSubmit:g,relative:p,preventScrollReset:S,viewTransition:y,unstable_defaultShouldRevalidate:v,...k},C)=>{let{unstable_useTransitions:w}=u.useContext(Wt),N=iv(),z=rv(b,{relative:p}),R=h.toLowerCase()==="get"?"get":"post",D=typeof b=="string"&&N0.test(b),O=se=>{if(g&&g(se),se.defaultPrevented)return;se.preventDefault();let Z=se.nativeEvent.submitter,U=(Z==null?void 0:Z.getAttribute("formmethod"))||h,A=()=>N(Z||se.currentTarget,{fetcherKey:i,method:U,navigate:d,replace:m,state:f,relative:p,preventScrollReset:S,viewTransition:y,unstable_defaultShouldRevalidate:v});w&&d!==!1?u.startTransition(()=>A()):A()};return u.createElement("form",{ref:C,method:R,action:z,onSubmit:c?g:O,...k,"data-discover":!D&&n==="render"?"true":void 0})});ev.displayName="Form";function tv(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function w0(n){let i=u.useContext(al);return Pe(i,tv(n)),i}function sv(n,{target:i,replace:d,unstable_mask:c,state:m,preventScrollReset:f,relative:h,viewTransition:b,unstable_defaultShouldRevalidate:g,unstable_useTransitions:p}={}){let S=Dt(),y=js(),v=ji(n,{relative:h});return u.useCallback(k=>{if(Dy(k,i)){k.preventDefault();let C=d!==void 0?d:mi(y)===mi(v),w=()=>S(n,{replace:C,unstable_mask:c,state:m,preventScrollReset:f,relative:h,viewTransition:b,unstable_defaultShouldRevalidate:g});p?u.startTransition(()=>w()):w()}},[y,S,v,d,c,m,i,n,f,h,b,g,p])}function av(n){ms(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let i=u.useRef(Fd(n)),d=u.useRef(!1),c=js(),m=u.useMemo(()=>Oy(c.search,d.current?null:i.current),[c.search]),f=Dt(),h=u.useCallback((b,g)=>{const p=Fd(typeof b=="function"?b(new URLSearchParams(m)):b);d.current=!0,f("?"+p,g)},[f,m]);return[m,h]}var nv=0,lv=()=>`__${String(++nv)}__`;function iv(){let{router:n}=w0("useSubmit"),{basename:i}=u.useContext(Wt),d=wy(),c=n.fetch,m=n.navigate;return u.useCallback(async(f,h={})=>{let{action:b,method:g,encType:p,formData:S,body:y}=Uy(f,i);if(h.navigate===!1){let v=h.fetcherKey||lv();await c(v,d,h.action||b,{unstable_defaultShouldRevalidate:h.unstable_defaultShouldRevalidate,preventScrollReset:h.preventScrollReset,formData:S,body:y,formMethod:h.method||g,formEncType:h.encType||p,flushSync:h.flushSync})}else await m(h.action||b,{unstable_defaultShouldRevalidate:h.unstable_defaultShouldRevalidate,preventScrollReset:h.preventScrollReset,formData:S,body:y,formMethod:h.method||g,formEncType:h.encType||p,replace:h.replace,state:h.state,fromRouteId:d,flushSync:h.flushSync,viewTransition:h.viewTransition})},[c,m,i,d])}function rv(n,{relative:i}={}){let{basename:d}=u.useContext(Wt),c=u.useContext(xs);Pe(c,"useFormAction must be used inside a RouteContext");let[m]=c.matches.slice(-1),f={...ji(n||".",{relative:i})},h=js();if(n==null){f.search=h.search;let b=new URLSearchParams(f.search),g=b.getAll("index");if(g.some(S=>S==="")){b.delete("index"),g.filter(y=>y).forEach(y=>b.append("index",y));let S=b.toString();f.search=S?`?${S}`:""}}return(!n||n===".")&&m.route.index&&(f.search=f.search?f.search.replace(/^\?/,"?index&"):"?index"),d!=="/"&&(f.pathname=f.pathname==="/"?d:As([d,f.pathname])),mi(f)}function cv(n,{relative:i}={}){let d=u.useContext(m0);Pe(d!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:c}=w0("useViewTransitionState"),m=ji(n,{relative:i});if(!d.isTransitioning)return!1;let f=aa(d.currentLocation.pathname,c)||d.currentLocation.pathname,h=aa(d.nextLocation.pathname,c)||d.nextLocation.pathname;return ec(m.pathname,h)!=null||ec(m.pathname,f)!=null}/**
61
+ * @license lucide-react v0.468.0 - ISC
62
+ *
63
+ * This source code is licensed under the ISC license.
64
+ * See the LICENSE file in the root directory of this source tree.
65
+ */const ov=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),S0=(...n)=>n.filter((i,d,c)=>!!i&&i.trim()!==""&&c.indexOf(i)===d).join(" ").trim();/**
66
+ * @license lucide-react v0.468.0 - ISC
67
+ *
68
+ * This source code is licensed under the ISC license.
69
+ * See the LICENSE file in the root directory of this source tree.
70
+ */var dv={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
71
+ * @license lucide-react v0.468.0 - ISC
72
+ *
73
+ * This source code is licensed under the ISC license.
74
+ * See the LICENSE file in the root directory of this source tree.
75
+ */const uv=u.forwardRef(({color:n="currentColor",size:i=24,strokeWidth:d=2,absoluteStrokeWidth:c,className:m="",children:f,iconNode:h,...b},g)=>u.createElement("svg",{ref:g,...dv,width:i,height:i,stroke:n,strokeWidth:c?Number(d)*24/Number(i):d,className:S0("lucide",m),...b},[...h.map(([p,S])=>u.createElement(p,S)),...Array.isArray(f)?f:[f]]));/**
76
+ * @license lucide-react v0.468.0 - ISC
77
+ *
78
+ * This source code is licensed under the ISC license.
79
+ * See the LICENSE file in the root directory of this source tree.
80
+ */const ie=(n,i)=>{const d=u.forwardRef(({className:c,...m},f)=>u.createElement(uv,{ref:f,iconNode:i,className:S0(`lucide-${ov(n)}`,c),...m}));return d.displayName=`${n}`,d};/**
81
+ * @license lucide-react v0.468.0 - ISC
82
+ *
83
+ * This source code is licensed under the ISC license.
84
+ * See the LICENSE file in the root directory of this source tree.
85
+ */const It=ie("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/**
86
+ * @license lucide-react v0.468.0 - ISC
87
+ *
88
+ * This source code is licensed under the ISC license.
89
+ * See the LICENSE file in the root directory of this source tree.
90
+ */const Wn=ie("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
91
+ * @license lucide-react v0.468.0 - ISC
92
+ *
93
+ * This source code is licensed under the ISC license.
94
+ * See the LICENSE file in the root directory of this source tree.
95
+ */const k0=ie("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
96
+ * @license lucide-react v0.468.0 - ISC
97
+ *
98
+ * This source code is licensed under the ISC license.
99
+ * See the LICENSE file in the root directory of this source tree.
100
+ */const mv=ie("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/**
101
+ * @license lucide-react v0.468.0 - ISC
102
+ *
103
+ * This source code is licensed under the ISC license.
104
+ * See the LICENSE file in the root directory of this source tree.
105
+ */const Ts=ie("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/**
106
+ * @license lucide-react v0.468.0 - ISC
107
+ *
108
+ * This source code is licensed under the ISC license.
109
+ * See the LICENSE file in the root directory of this source tree.
110
+ */const La=ie("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/**
111
+ * @license lucide-react v0.468.0 - ISC
112
+ *
113
+ * This source code is licensed under the ISC license.
114
+ * See the LICENSE file in the root directory of this source tree.
115
+ */const xv=ie("Briefcase",[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/**
116
+ * @license lucide-react v0.468.0 - ISC
117
+ *
118
+ * This source code is licensed under the ISC license.
119
+ * See the LICENSE file in the root directory of this source tree.
120
+ */const z0=ie("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);/**
121
+ * @license lucide-react v0.468.0 - ISC
122
+ *
123
+ * This source code is licensed under the ISC license.
124
+ * See the LICENSE file in the root directory of this source tree.
125
+ */const du=ie("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/**
126
+ * @license lucide-react v0.468.0 - ISC
127
+ *
128
+ * This source code is licensed under the ISC license.
129
+ * See the LICENSE file in the root directory of this source tree.
130
+ */const fv=ie("Calculator",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/**
131
+ * @license lucide-react v0.468.0 - ISC
132
+ *
133
+ * This source code is licensed under the ISC license.
134
+ * See the LICENSE file in the root directory of this source tree.
135
+ */const C0=ie("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/**
136
+ * @license lucide-react v0.468.0 - ISC
137
+ *
138
+ * This source code is licensed under the ISC license.
139
+ * See the LICENSE file in the root directory of this source tree.
140
+ */const Rs=ie("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/**
141
+ * @license lucide-react v0.468.0 - ISC
142
+ *
143
+ * This source code is licensed under the ISC license.
144
+ * See the LICENSE file in the root directory of this source tree.
145
+ */const bt=ie("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
146
+ * @license lucide-react v0.468.0 - ISC
147
+ *
148
+ * This source code is licensed under the ISC license.
149
+ * See the LICENSE file in the root directory of this source tree.
150
+ */const na=ie("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
151
+ * @license lucide-react v0.468.0 - ISC
152
+ *
153
+ * This source code is licensed under the ISC license.
154
+ * See the LICENSE file in the root directory of this source tree.
155
+ */const $h=ie("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
156
+ * @license lucide-react v0.468.0 - ISC
157
+ *
158
+ * This source code is licensed under the ISC license.
159
+ * See the LICENSE file in the root directory of this source tree.
160
+ */const ds=ie("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
161
+ * @license lucide-react v0.468.0 - ISC
162
+ *
163
+ * This source code is licensed under the ISC license.
164
+ * See the LICENSE file in the root directory of this source tree.
165
+ */const xi=ie("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
166
+ * @license lucide-react v0.468.0 - ISC
167
+ *
168
+ * This source code is licensed under the ISC license.
169
+ * See the LICENSE file in the root directory of this source tree.
170
+ */const fi=ie("CircleArrowRight",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]]);/**
171
+ * @license lucide-react v0.468.0 - ISC
172
+ *
173
+ * This source code is licensed under the ISC license.
174
+ * See the LICENSE file in the root directory of this source tree.
175
+ */const et=ie("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
176
+ * @license lucide-react v0.468.0 - ISC
177
+ *
178
+ * This source code is licensed under the ISC license.
179
+ * See the LICENSE file in the root directory of this source tree.
180
+ */const A0=ie("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
181
+ * @license lucide-react v0.468.0 - ISC
182
+ *
183
+ * This source code is licensed under the ISC license.
184
+ * See the LICENSE file in the root directory of this source tree.
185
+ */const hv=ie("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/**
186
+ * @license lucide-react v0.468.0 - ISC
187
+ *
188
+ * This source code is licensed under the ISC license.
189
+ * See the LICENSE file in the root directory of this source tree.
190
+ */const E0=ie("CircleStop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);/**
191
+ * @license lucide-react v0.468.0 - ISC
192
+ *
193
+ * This source code is licensed under the ISC license.
194
+ * See the LICENSE file in the root directory of this source tree.
195
+ */const ft=ie("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
196
+ * @license lucide-react v0.468.0 - ISC
197
+ *
198
+ * This source code is licensed under the ISC license.
199
+ * See the LICENSE file in the root directory of this source tree.
200
+ */const pv=ie("ClipboardList",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/**
201
+ * @license lucide-react v0.468.0 - ISC
202
+ *
203
+ * This source code is licensed under the ISC license.
204
+ * See the LICENSE file in the root directory of this source tree.
205
+ */const vs=ie("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
206
+ * @license lucide-react v0.468.0 - ISC
207
+ *
208
+ * This source code is licensed under the ISC license.
209
+ * See the LICENSE file in the root directory of this source tree.
210
+ */const gv=ie("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/**
211
+ * @license lucide-react v0.468.0 - ISC
212
+ *
213
+ * This source code is licensed under the ISC license.
214
+ * See the LICENSE file in the root directory of this source tree.
215
+ */const bv=ie("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/**
216
+ * @license lucide-react v0.468.0 - ISC
217
+ *
218
+ * This source code is licensed under the ISC license.
219
+ * See the LICENSE file in the root directory of this source tree.
220
+ */const T0=ie("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/**
221
+ * @license lucide-react v0.468.0 - ISC
222
+ *
223
+ * This source code is licensed under the ISC license.
224
+ * See the LICENSE file in the root directory of this source tree.
225
+ */const us=ie("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);/**
226
+ * @license lucide-react v0.468.0 - ISC
227
+ *
228
+ * This source code is licensed under the ISC license.
229
+ * See the LICENSE file in the root directory of this source tree.
230
+ */const hi=ie("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
231
+ * @license lucide-react v0.468.0 - ISC
232
+ *
233
+ * This source code is licensed under the ISC license.
234
+ * See the LICENSE file in the root directory of this source tree.
235
+ */const Pn=ie("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
236
+ * @license lucide-react v0.468.0 - ISC
237
+ *
238
+ * This source code is licensed under the ISC license.
239
+ * See the LICENSE file in the root directory of this source tree.
240
+ */const uu=ie("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
241
+ * @license lucide-react v0.468.0 - ISC
242
+ *
243
+ * This source code is licensed under the ISC license.
244
+ * See the LICENSE file in the root directory of this source tree.
245
+ */const el=ie("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
246
+ * @license lucide-react v0.468.0 - ISC
247
+ *
248
+ * This source code is licensed under the ISC license.
249
+ * See the LICENSE file in the root directory of this source tree.
250
+ */const Ua=ie("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
251
+ * @license lucide-react v0.468.0 - ISC
252
+ *
253
+ * This source code is licensed under the ISC license.
254
+ * See the LICENSE file in the root directory of this source tree.
255
+ */const R0=ie("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/**
256
+ * @license lucide-react v0.468.0 - ISC
257
+ *
258
+ * This source code is licensed under the ISC license.
259
+ * See the LICENSE file in the root directory of this source tree.
260
+ */const Bh=ie("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/**
261
+ * @license lucide-react v0.468.0 - ISC
262
+ *
263
+ * This source code is licensed under the ISC license.
264
+ * See the LICENSE file in the root directory of this source tree.
265
+ */const $d=ie("FlaskConical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]);/**
266
+ * @license lucide-react v0.468.0 - ISC
267
+ *
268
+ * This source code is licensed under the ISC license.
269
+ * See the LICENSE file in the root directory of this source tree.
270
+ */const yv=ie("FolderSearch",[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]);/**
271
+ * @license lucide-react v0.468.0 - ISC
272
+ *
273
+ * This source code is licensed under the ISC license.
274
+ * See the LICENSE file in the root directory of this source tree.
275
+ */const tc=ie("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/**
276
+ * @license lucide-react v0.468.0 - ISC
277
+ *
278
+ * This source code is licensed under the ISC license.
279
+ * See the LICENSE file in the root directory of this source tree.
280
+ */const mu=ie("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
281
+ * @license lucide-react v0.468.0 - ISC
282
+ *
283
+ * This source code is licensed under the ISC license.
284
+ * See the LICENSE file in the root directory of this source tree.
285
+ */const vv=ie("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);/**
286
+ * @license lucide-react v0.468.0 - ISC
287
+ *
288
+ * This source code is licensed under the ISC license.
289
+ * See the LICENSE file in the root directory of this source tree.
290
+ */const Hh=ie("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
291
+ * @license lucide-react v0.468.0 - ISC
292
+ *
293
+ * This source code is licensed under the ISC license.
294
+ * See the LICENSE file in the root directory of this source tree.
295
+ */const jv=ie("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/**
296
+ * @license lucide-react v0.468.0 - ISC
297
+ *
298
+ * This source code is licensed under the ISC license.
299
+ * See the LICENSE file in the root directory of this source tree.
300
+ */const Ni=ie("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/**
301
+ * @license lucide-react v0.468.0 - ISC
302
+ *
303
+ * This source code is licensed under the ISC license.
304
+ * See the LICENSE file in the root directory of this source tree.
305
+ */const Nv=ie("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/**
306
+ * @license lucide-react v0.468.0 - ISC
307
+ *
308
+ * This source code is licensed under the ISC license.
309
+ * See the LICENSE file in the root directory of this source tree.
310
+ */const wv=ie("Layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);/**
311
+ * @license lucide-react v0.468.0 - ISC
312
+ *
313
+ * This source code is licensed under the ISC license.
314
+ * See the LICENSE file in the root directory of this source tree.
315
+ */const xu=ie("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
316
+ * @license lucide-react v0.468.0 - ISC
317
+ *
318
+ * This source code is licensed under the ISC license.
319
+ * See the LICENSE file in the root directory of this source tree.
320
+ */const Zd=ie("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/**
321
+ * @license lucide-react v0.468.0 - ISC
322
+ *
323
+ * This source code is licensed under the ISC license.
324
+ * See the LICENSE file in the root directory of this source tree.
325
+ */const rt=ie("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
326
+ * @license lucide-react v0.468.0 - ISC
327
+ *
328
+ * This source code is licensed under the ISC license.
329
+ * See the LICENSE file in the root directory of this source tree.
330
+ */const Sv=ie("LockOpen",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);/**
331
+ * @license lucide-react v0.468.0 - ISC
332
+ *
333
+ * This source code is licensed under the ISC license.
334
+ * See the LICENSE file in the root directory of this source tree.
335
+ */const Jd=ie("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/**
336
+ * @license lucide-react v0.468.0 - ISC
337
+ *
338
+ * This source code is licensed under the ISC license.
339
+ * See the LICENSE file in the root directory of this source tree.
340
+ */const kv=ie("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/**
341
+ * @license lucide-react v0.468.0 - ISC
342
+ *
343
+ * This source code is licensed under the ISC license.
344
+ * See the LICENSE file in the root directory of this source tree.
345
+ */const zv=ie("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
346
+ * @license lucide-react v0.468.0 - ISC
347
+ *
348
+ * This source code is licensed under the ISC license.
349
+ * See the LICENSE file in the root directory of this source tree.
350
+ */const Cv=ie("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
351
+ * @license lucide-react v0.468.0 - ISC
352
+ *
353
+ * This source code is licensed under the ISC license.
354
+ * See the LICENSE file in the root directory of this source tree.
355
+ */const Pt=ie("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/**
356
+ * @license lucide-react v0.468.0 - ISC
357
+ *
358
+ * This source code is licensed under the ISC license.
359
+ * See the LICENSE file in the root directory of this source tree.
360
+ */const Av=ie("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
361
+ * @license lucide-react v0.468.0 - ISC
362
+ *
363
+ * This source code is licensed under the ISC license.
364
+ * See the LICENSE file in the root directory of this source tree.
365
+ */const Ev=ie("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
366
+ * @license lucide-react v0.468.0 - ISC
367
+ *
368
+ * This source code is licensed under the ISC license.
369
+ * See the LICENSE file in the root directory of this source tree.
370
+ */const Tv=ie("PanelLeftClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);/**
371
+ * @license lucide-react v0.468.0 - ISC
372
+ *
373
+ * This source code is licensed under the ISC license.
374
+ * See the LICENSE file in the root directory of this source tree.
375
+ */const Rv=ie("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);/**
376
+ * @license lucide-react v0.468.0 - ISC
377
+ *
378
+ * This source code is licensed under the ISC license.
379
+ * See the LICENSE file in the root directory of this source tree.
380
+ */const tl=ie("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/**
381
+ * @license lucide-react v0.468.0 - ISC
382
+ *
383
+ * This source code is licensed under the ISC license.
384
+ * See the LICENSE file in the root directory of this source tree.
385
+ */const Mv=ie("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);/**
386
+ * @license lucide-react v0.468.0 - ISC
387
+ *
388
+ * This source code is licensed under the ISC license.
389
+ * See the LICENSE file in the root directory of this source tree.
390
+ */const pi=ie("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
391
+ * @license lucide-react v0.468.0 - ISC
392
+ *
393
+ * This source code is licensed under the ISC license.
394
+ * See the LICENSE file in the root directory of this source tree.
395
+ */const Nt=ie("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
396
+ * @license lucide-react v0.468.0 - ISC
397
+ *
398
+ * This source code is licensed under the ISC license.
399
+ * See the LICENSE file in the root directory of this source tree.
400
+ */const ht=ie("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
401
+ * @license lucide-react v0.468.0 - ISC
402
+ *
403
+ * This source code is licensed under the ISC license.
404
+ * See the LICENSE file in the root directory of this source tree.
405
+ */const rc=ie("Puzzle",[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]]);/**
406
+ * @license lucide-react v0.468.0 - ISC
407
+ *
408
+ * This source code is licensed under the ISC license.
409
+ * See the LICENSE file in the root directory of this source tree.
410
+ */const M0=ie("Radio",[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]]);/**
411
+ * @license lucide-react v0.468.0 - ISC
412
+ *
413
+ * This source code is licensed under the ISC license.
414
+ * See the LICENSE file in the root directory of this source tree.
415
+ */const xt=ie("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
416
+ * @license lucide-react v0.468.0 - ISC
417
+ *
418
+ * This source code is licensed under the ISC license.
419
+ * See the LICENSE file in the root directory of this source tree.
420
+ */const D0=ie("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
421
+ * @license lucide-react v0.468.0 - ISC
422
+ *
423
+ * This source code is licensed under the ISC license.
424
+ * See the LICENSE file in the root directory of this source tree.
425
+ */const cc=ie("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/**
426
+ * @license lucide-react v0.468.0 - ISC
427
+ *
428
+ * This source code is licensed under the ISC license.
429
+ * See the LICENSE file in the root directory of this source tree.
430
+ */const _a=ie("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
431
+ * @license lucide-react v0.468.0 - ISC
432
+ *
433
+ * This source code is licensed under the ISC license.
434
+ * See the LICENSE file in the root directory of this source tree.
435
+ */const gi=ie("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
436
+ * @license lucide-react v0.468.0 - ISC
437
+ *
438
+ * This source code is licensed under the ISC license.
439
+ * See the LICENSE file in the root directory of this source tree.
440
+ */const fu=ie("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);/**
441
+ * @license lucide-react v0.468.0 - ISC
442
+ *
443
+ * This source code is licensed under the ISC license.
444
+ * See the LICENSE file in the root directory of this source tree.
445
+ */const il=ie("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
446
+ * @license lucide-react v0.468.0 - ISC
447
+ *
448
+ * This source code is licensed under the ISC license.
449
+ * See the LICENSE file in the root directory of this source tree.
450
+ */const Ms=ie("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/**
451
+ * @license lucide-react v0.468.0 - ISC
452
+ *
453
+ * This source code is licensed under the ISC license.
454
+ * See the LICENSE file in the root directory of this source tree.
455
+ */const hu=ie("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
456
+ * @license lucide-react v0.468.0 - ISC
457
+ *
458
+ * This source code is licensed under the ISC license.
459
+ * See the LICENSE file in the root directory of this source tree.
460
+ */const Ds=ie("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/**
461
+ * @license lucide-react v0.468.0 - ISC
462
+ *
463
+ * This source code is licensed under the ISC license.
464
+ * See the LICENSE file in the root directory of this source tree.
465
+ */const Dv=ie("SkipBack",[["polygon",{points:"19 20 9 12 19 4 19 20",key:"o2sva"}],["line",{x1:"5",x2:"5",y1:"19",y2:"5",key:"1ocqjk"}]]);/**
466
+ * @license lucide-react v0.468.0 - ISC
467
+ *
468
+ * This source code is licensed under the ISC license.
469
+ * See the LICENSE file in the root directory of this source tree.
470
+ */const Ov=ie("SkipForward",[["polygon",{points:"5 4 15 12 5 20 5 4",key:"16p6eg"}],["line",{x1:"19",x2:"19",y1:"5",y2:"19",key:"futhcm"}]]);/**
471
+ * @license lucide-react v0.468.0 - ISC
472
+ *
473
+ * This source code is licensed under the ISC license.
474
+ * See the LICENSE file in the root directory of this source tree.
475
+ */const Pr=ie("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/**
476
+ * @license lucide-react v0.468.0 - ISC
477
+ *
478
+ * This source code is licensed under the ISC license.
479
+ * See the LICENSE file in the root directory of this source tree.
480
+ */const Lv=ie("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
481
+ * @license lucide-react v0.468.0 - ISC
482
+ *
483
+ * This source code is licensed under the ISC license.
484
+ * See the LICENSE file in the root directory of this source tree.
485
+ */const _v=ie("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/**
486
+ * @license lucide-react v0.468.0 - ISC
487
+ *
488
+ * This source code is licensed under the ISC license.
489
+ * See the LICENSE file in the root directory of this source tree.
490
+ */const rn=ie("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/**
491
+ * @license lucide-react v0.468.0 - ISC
492
+ *
493
+ * This source code is licensed under the ISC license.
494
+ * See the LICENSE file in the root directory of this source tree.
495
+ */const O0=ie("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/**
496
+ * @license lucide-react v0.468.0 - ISC
497
+ *
498
+ * This source code is licensed under the ISC license.
499
+ * See the LICENSE file in the root directory of this source tree.
500
+ */const bi=ie("TestTube",[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]]);/**
501
+ * @license lucide-react v0.468.0 - ISC
502
+ *
503
+ * This source code is licensed under the ISC license.
504
+ * See the LICENSE file in the root directory of this source tree.
505
+ */const Id=ie("ThumbsDown",[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]]);/**
506
+ * @license lucide-react v0.468.0 - ISC
507
+ *
508
+ * This source code is licensed under the ISC license.
509
+ * See the LICENSE file in the root directory of this source tree.
510
+ */const yi=ie("ThumbsUp",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]);/**
511
+ * @license lucide-react v0.468.0 - ISC
512
+ *
513
+ * This source code is licensed under the ISC license.
514
+ * See the LICENSE file in the root directory of this source tree.
515
+ */const L0=ie("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/**
516
+ * @license lucide-react v0.468.0 - ISC
517
+ *
518
+ * This source code is licensed under the ISC license.
519
+ * See the LICENSE file in the root directory of this source tree.
520
+ */const Uv=ie("ToggleLeft",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]]);/**
521
+ * @license lucide-react v0.468.0 - ISC
522
+ *
523
+ * This source code is licensed under the ISC license.
524
+ * See the LICENSE file in the root directory of this source tree.
525
+ */const $v=ie("ToggleRight",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"16",cy:"12",r:"2",key:"4ma0v8"}]]);/**
526
+ * @license lucide-react v0.468.0 - ISC
527
+ *
528
+ * This source code is licensed under the ISC license.
529
+ * See the LICENSE file in the root directory of this source tree.
530
+ */const Ot=ie("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
531
+ * @license lucide-react v0.468.0 - ISC
532
+ *
533
+ * This source code is licensed under the ISC license.
534
+ * See the LICENSE file in the root directory of this source tree.
535
+ */const Bv=ie("TrendingDown",[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]]);/**
536
+ * @license lucide-react v0.468.0 - ISC
537
+ *
538
+ * This source code is licensed under the ISC license.
539
+ * See the LICENSE file in the root directory of this source tree.
540
+ */const oc=ie("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);/**
541
+ * @license lucide-react v0.468.0 - ISC
542
+ *
543
+ * This source code is licensed under the ISC license.
544
+ * See the LICENSE file in the root directory of this source tree.
545
+ */const pt=ie("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
546
+ * @license lucide-react v0.468.0 - ISC
547
+ *
548
+ * This source code is licensed under the ISC license.
549
+ * See the LICENSE file in the root directory of this source tree.
550
+ */const Jn=ie("Trophy",[["path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6",key:"17hqa7"}],["path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18",key:"lmptdp"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22",key:"1nw9bq"}],["path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22",key:"1np0yb"}],["path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z",key:"u46fv3"}]]);/**
551
+ * @license lucide-react v0.468.0 - ISC
552
+ *
553
+ * This source code is licensed under the ISC license.
554
+ * See the LICENSE file in the root directory of this source tree.
555
+ */const Hv=ie("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/**
556
+ * @license lucide-react v0.468.0 - ISC
557
+ *
558
+ * This source code is licensed under the ISC license.
559
+ * See the LICENSE file in the root directory of this source tree.
560
+ */const rl=ie("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/**
561
+ * @license lucide-react v0.468.0 - ISC
562
+ *
563
+ * This source code is licensed under the ISC license.
564
+ * See the LICENSE file in the root directory of this source tree.
565
+ */const qv=ie("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
566
+ * @license lucide-react v0.468.0 - ISC
567
+ *
568
+ * This source code is licensed under the ISC license.
569
+ * See the LICENSE file in the root directory of this source tree.
570
+ */const Gv=ie("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/**
571
+ * @license lucide-react v0.468.0 - ISC
572
+ *
573
+ * This source code is licensed under the ISC license.
574
+ * See the LICENSE file in the root directory of this source tree.
575
+ */const cl=ie("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/**
576
+ * @license lucide-react v0.468.0 - ISC
577
+ *
578
+ * This source code is licensed under the ISC license.
579
+ * See the LICENSE file in the root directory of this source tree.
580
+ */const Ze=ie("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
581
+ * @license lucide-react v0.468.0 - ISC
582
+ *
583
+ * This source code is licensed under the ISC license.
584
+ * See the LICENSE file in the root directory of this source tree.
585
+ */const sa=ie("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),Pd={en:"English",fr:"Français",es:"Español",de:"Deutsch",pt:"Português",ja:"日本語",zh:"中文",ko:"한국어",ar:"العربية",ru:"Русский",it:"Italiano",nl:"Nederlands"},Kv=["ar"],Vv=Object.keys(Pd);function Wd(n){return Vv.includes(n)}function Yv(n){if(!n)return"en";const i=n.toLowerCase();if(Wd(i))return i;const d=i.split("-")[0];return Wd(d)?d:"en"}const qh={en:{"nav.missions":"Missions","nav.chat":"Chat","nav.history":"History","nav.dashboard":"Dashboard","nav.agents":"Agents","nav.workflows":"Workflows","nav.skills":"Skills","nav.runs":"Runs","nav.approvals":"Approvals","nav.handoffs":"Handoffs","nav.apiKeys":"API Keys","nav.settings":"Settings","nav.users":"Users","nav.prompts":"Prompts","dashboard.title":"Dashboard","dashboard.activeAgents":"Active Agents","dashboard.runningTasks":"Running Tasks","dashboard.costToday":"Cost Today","dashboard.skillsInstalled":"Skills Installed","dashboard.recentActivity":"Recent Activity","dashboard.quickActions":"Quick Actions","dashboard.systemHealth":"System Health","dashboard.createAgent":"Create Agent","dashboard.runWorkflow":"Run Workflow","dashboard.installSkill":"Install Skill","agents.title":"Agents","agents.create":"Create Agent","agents.empty":"No agents configured yet.","agents.emptyDesc":"Create your first AI agent to get started with automated tasks.","agent.overview":"Overview","agent.runs":"Runs","agent.events":"Events","agent.configuration":"Configuration","agent.budget":"Budget","agent.recentRuns":"Recent Runs","agent.delete":"Delete Agent","agent.start":"Start","agent.stop":"Stop","agent.run":"Run","workflows.title":"Workflows","workflows.create":"Create Workflow","workflows.empty":"No workflows defined yet.","workflows.emptyDesc":"Design your first workflow to orchestrate multiple agents.","workflows.nodes":"{count} nodes","workflows.edit":"Edit","workflow.editor":"Workflow Editor","workflow.addNode":"Add Node","workflow.save":"Save","workflow.run":"Run Workflow","skills.title":"Skills","skills.install":"Install Skill","skills.empty":"No skills installed yet.","skills.emptyDesc":"Browse and install skills to extend your agents' capabilities.","skills.scan":"Scan Directory","skills.source":"Source URL or path","runs.title":"Runs","runs.empty":"No runs recorded yet.","runs.emptyDesc":"Run an agent or workflow to see execution history.","runs.filter":"Filter","run.events":"Events","run.output":"Output","run.cost":"Cost Breakdown","run.duration":"Duration","approvals.title":"Approval Queue","approvals.empty":"No pending approvals.","approvals.emptyDesc":"All clear. Dangerous actions will appear here for review.","approvals.approve":"Approve","approvals.deny":"Deny","approvals.pending":"Pending","nav.analytics":"Analytics","nav.budget":"Budget","nav.traces":"Traces","nav.memory":"Memory","nav.goals":"Goals","nav.plans":"Plans","nav.guardrails":"Guardrails","analytics.title":"Cost Analytics","analytics.description":"Track spending, token usage, and budget utilization across agents.","analytics.totalSpend":"Total Spend","analytics.totalRuns":"Total Runs","analytics.avgCostPerRun":"Avg Cost/Run","analytics.monthlyEstimate":"Monthly Estimate","analytics.dailyCosts":"Daily Costs (30 days)","analytics.agentBreakdown":"Cost by Agent","analytics.modelBreakdown":"Cost by Model","analytics.budgetUtilization":"Budget Utilization","analytics.runs":"Runs","analytics.totalCost":"Total Cost","analytics.avgCost":"Avg Cost","analytics.model":"Model","analytics.tokens":"Tokens","analytics.cost":"Cost","analytics.noAgentData":"No agent cost data yet.","analytics.noModelData":"No model cost data yet.","settings.title":"Settings","settings.general":"General","settings.security":"Security","settings.llm":"LLM","settings.budget":"Budget","settings.save":"Save Changes","settings.saved":"Settings saved successfully.","settings.language":"Language","common.loading":"Loading...","common.error":"An error occurred.","common.retry":"Retry","common.cancel":"Cancel","common.save":"Save","common.delete":"Delete","common.close":"Close","common.search":"Search...","common.noResults":"No results found.","common.name":"Name","common.description":"Description","common.status":"Status","common.type":"Type","common.actions":"Actions","common.created":"Created","common.updated":"Updated","status.running":"Running","status.completed":"Completed","status.failed":"Failed","status.pending":"Pending","status.paused":"Paused","status.cancelled":"Cancelled","status.idle":"Idle","trust.builtin":"Built-in","trust.official":"Official","trust.trusted":"Trusted","trust.community":"Community","trust.local":"Local","nav.messaging":"Messaging","messaging.title":"Messaging","messaging.empty":"No messaging adapters configured.","messaging.emptyDesc":"Configure Discord, Slack, or Telegram adapters to get started.","messaging.sendTest":"Send Test Message","messaging.adapter":"Adapter","messaging.channel":"Channel","messaging.selectChannel":"Select a channel","messaging.message":"Message","messaging.messagePlaceholder":"Type a test message...","messaging.send":"Send","messaging.sent":"Message sent successfully.","messaging.recentMessages":"Recent Messages","messaging.noMessages":"No messages yet.","nav.scheduler":"Scheduler","scheduler.title":"Scheduler","scheduler.addSchedule":"Add Schedule","scheduler.empty":"No scheduled agents.","scheduler.emptyDesc":"Schedule agents to run automatically on a cron expression.","scheduler.totalSchedules":"Total Schedules","scheduler.active":"Active","scheduler.paused":"Paused","scheduler.nextRun":"Next Run","scheduler.agent":"Agent","scheduler.schedule":"Schedule","scheduler.lastRun":"Last Run","scheduler.selectAgent":"Select an agent...","scheduler.usePreset":"Use preset","scheduler.useCustom":"Use custom cron","scheduler.pause":"Pause","scheduler.resume":"Resume","scheduler.runHistory":"Run History","nav.evolve":"Evolve","evolve.title":"Evolve","evolve.empty":"No skill candidates found.","evolve.emptyDesc":"Auto-extracted skills from missions will appear here.","evolve.totalCandidates":"Total Candidates","evolve.pending":"Pending","evolve.approved":"Approved","evolve.rejected":"Rejected","evolve.avgConfidence":"Avg Confidence","evolve.all":"All","evolve.source":"Source","evolve.confidence":"Confidence","evolve.preview":"Preview","evolve.edit":"Edit","evolve.approve":"Approve","evolve.reject":"Reject","workflows.run":"Run","workflows.running":"Running...","memory.browse":"Browse","memory.governance":"Governance","memory.governanceTypes":"Memory Types","memory.staleMemories":"Stale Memories","memory.flagged":"flagged","memory.noStale":"No stale memories detected.","memory.ttlEnforcement":"TTL Enforcement","memory.totalMemories":"Total Memories","memory.staleCount":"Stale (>30d)","memory.ttlCandidates":"TTL Candidates"},fr:{"nav.missions":"Missions","nav.chat":"Chat","nav.history":"Historique","nav.dashboard":"Tableau de bord","nav.agents":"Agents","nav.workflows":"Workflows","nav.skills":"Compétences","nav.runs":"Exécutions","nav.approvals":"Approbations","nav.handoffs":"Transferts","nav.apiKeys":"Clés API","nav.settings":"Paramètres","nav.users":"Utilisateurs","nav.prompts":"Prompts","dashboard.title":"Tableau de bord","dashboard.activeAgents":"Agents actifs","dashboard.runningTasks":"Tâches en cours","dashboard.costToday":"Coût aujourd'hui","dashboard.skillsInstalled":"Compétences installées","dashboard.recentActivity":"Activité récente","dashboard.quickActions":"Actions rapides","dashboard.systemHealth":"Santé système","dashboard.createAgent":"Créer un agent","dashboard.runWorkflow":"Lancer un workflow","dashboard.installSkill":"Installer une compétence","agents.title":"Agents","agents.create":"Créer un agent","agents.empty":"Aucun agent configuré.","agents.emptyDesc":"Créez votre premier agent IA pour automatiser vos tâches.","agent.overview":"Aperçu","agent.runs":"Exécutions","agent.events":"Événements","agent.configuration":"Configuration","agent.budget":"Budget","agent.recentRuns":"Exécutions récentes","agent.delete":"Supprimer l'agent","agent.start":"Démarrer","agent.stop":"Arrêter","agent.run":"Exécuter","workflows.title":"Workflows","workflows.create":"Créer un workflow","workflows.empty":"Aucun workflow défini.","workflows.emptyDesc":"Concevez votre premier workflow pour orchestrer vos agents.","workflows.nodes":"{count} nœuds","workflows.edit":"Modifier","workflow.editor":"Éditeur de workflow","workflow.addNode":"Ajouter un nœud","workflow.save":"Enregistrer","workflow.run":"Lancer le workflow","skills.title":"Compétences","skills.install":"Installer","skills.empty":"Aucune compétence installée.","skills.emptyDesc":"Parcourez et installez des compétences pour étendre les capacités de vos agents.","skills.scan":"Scanner un répertoire","skills.source":"URL ou chemin source","runs.title":"Exécutions","runs.empty":"Aucune exécution enregistrée.","runs.emptyDesc":"Lancez un agent ou un workflow pour voir l'historique.","runs.filter":"Filtrer","run.events":"Événements","run.output":"Sortie","run.cost":"Détail des coûts","run.duration":"Durée","approvals.title":"File d'approbation","approvals.empty":"Aucune approbation en attente.","approvals.emptyDesc":"Tout est clair. Les actions dangereuses apparaîtront ici.","approvals.approve":"Approuver","approvals.deny":"Refuser","approvals.pending":"En attente","nav.analytics":"Analytique","nav.budget":"Budget","nav.traces":"Traces","nav.memory":"Mémoire","nav.goals":"Objectifs","nav.plans":"Plans","nav.guardrails":"Garde-fous","analytics.title":"Analytique des coûts","analytics.description":"Suivez les dépenses, l'utilisation des tokens et le budget par agent.","analytics.totalSpend":"Dépense totale","analytics.totalRuns":"Total exécutions","analytics.avgCostPerRun":"Coût moyen/exéc.","analytics.monthlyEstimate":"Estimation mensuelle","analytics.dailyCosts":"Coûts quotidiens (30 jours)","analytics.agentBreakdown":"Coûts par agent","analytics.modelBreakdown":"Coûts par modèle","analytics.budgetUtilization":"Utilisation du budget","analytics.runs":"Exécutions","analytics.totalCost":"Coût total","analytics.avgCost":"Coût moyen","analytics.model":"Modèle","analytics.tokens":"Tokens","analytics.cost":"Coût","analytics.noAgentData":"Aucune donnée de coût par agent.","analytics.noModelData":"Aucune donnée de coût par modèle.","settings.title":"Paramètres","settings.general":"Général","settings.security":"Sécurité","settings.llm":"LLM","settings.budget":"Budget","settings.save":"Enregistrer","settings.saved":"Paramètres sauvegardés.","settings.language":"Langue","common.loading":"Chargement...","common.error":"Une erreur est survenue.","common.retry":"Réessayer","common.cancel":"Annuler","common.save":"Enregistrer","common.delete":"Supprimer","common.close":"Fermer","common.search":"Rechercher...","common.noResults":"Aucun résultat.","common.name":"Nom","common.description":"Description","common.status":"Statut","common.type":"Type","common.actions":"Actions","common.created":"Créé","common.updated":"Mis à jour","status.running":"En cours","status.completed":"Terminé","status.failed":"Échoué","status.pending":"En attente","status.paused":"En pause","status.cancelled":"Annulé","status.idle":"Inactif","trust.builtin":"Intégré","trust.official":"Officiel","trust.trusted":"Vérifié","trust.community":"Communautaire","trust.local":"Local","nav.messaging":"Messagerie","messaging.title":"Messagerie","messaging.empty":"Aucun adaptateur de messagerie configuré.","messaging.emptyDesc":"Configurez Discord, Slack ou Telegram pour commencer.","messaging.sendTest":"Envoyer un message test","messaging.adapter":"Adaptateur","messaging.channel":"Canal","messaging.selectChannel":"Sélectionner un canal","messaging.message":"Message","messaging.messagePlaceholder":"Tapez un message test...","messaging.send":"Envoyer","messaging.sent":"Message envoyé avec succès.","messaging.recentMessages":"Messages récents","messaging.noMessages":"Aucun message.","nav.scheduler":"Planificateur","scheduler.title":"Planificateur","scheduler.addSchedule":"Ajouter une planification","scheduler.empty":"Aucun agent planifié.","scheduler.emptyDesc":"Planifiez des agents pour s'exécuter automatiquement via une expression cron.","scheduler.totalSchedules":"Total planifications","scheduler.active":"Actif","scheduler.paused":"En pause","scheduler.nextRun":"Prochaine exéc.","scheduler.agent":"Agent","scheduler.schedule":"Planification","scheduler.lastRun":"Dernière exéc.","scheduler.selectAgent":"Sélectionner un agent...","scheduler.usePreset":"Utiliser un préréglage","scheduler.useCustom":"Cron personnalisé","scheduler.pause":"Mettre en pause","scheduler.resume":"Reprendre","scheduler.runHistory":"Historique des exécutions","nav.evolve":"Évolution","evolve.title":"Évolution","evolve.empty":"Aucun candidat de compétence trouvé.","evolve.emptyDesc":"Les compétences auto-extraites des missions apparaîtront ici.","evolve.totalCandidates":"Total candidats","evolve.pending":"En attente","evolve.approved":"Approuvés","evolve.rejected":"Rejetés","evolve.avgConfidence":"Confiance moy.","evolve.all":"Tous","evolve.source":"Source","evolve.confidence":"Confiance","evolve.preview":"Aperçu","evolve.edit":"Modifier","evolve.approve":"Approuver","evolve.reject":"Rejeter","workflows.run":"Lancer","workflows.running":"En cours...","memory.browse":"Parcourir","memory.governance":"Gouvernance","memory.governanceTypes":"Types de mémoire","memory.staleMemories":"Mémoires obsolètes","memory.flagged":"signalées","memory.noStale":"Aucune mémoire obsolète détectée.","memory.ttlEnforcement":"Application TTL","memory.totalMemories":"Total mémoires","memory.staleCount":"Obsolètes (>30j)","memory.ttlCandidates":"Candidats TTL"},es:{"nav.dashboard":"Panel","nav.agents":"Agentes","nav.workflows":"Flujos de trabajo","nav.skills":"Habilidades","nav.runs":"Ejecuciones","nav.approvals":"Aprobaciones","nav.handoffs":"Transferencias","nav.apiKeys":"Claves API","nav.settings":"Configuración","nav.users":"Usuarios","nav.prompts":"Prompts","dashboard.title":"Panel","dashboard.activeAgents":"Agentes activos","dashboard.runningTasks":"Tareas en ejecución","dashboard.costToday":"Coste hoy","dashboard.skillsInstalled":"Habilidades instaladas","dashboard.recentActivity":"Actividad reciente","dashboard.quickActions":"Acciones rápidas","dashboard.systemHealth":"Estado del sistema","dashboard.createAgent":"Crear agente","dashboard.runWorkflow":"Ejecutar flujo","dashboard.installSkill":"Instalar habilidad","agents.title":"Agentes","agents.create":"Crear agente","agents.empty":"No hay agentes configurados.","agents.emptyDesc":"Crea tu primer agente IA para empezar con tareas automatizadas.","agent.overview":"Resumen","agent.runs":"Ejecuciones","agent.events":"Eventos","agent.configuration":"Configuración","agent.budget":"Presupuesto","agent.recentRuns":"Ejecuciones recientes","agent.delete":"Eliminar agente","agent.start":"Iniciar","agent.stop":"Detener","agent.run":"Ejecutar","workflows.title":"Flujos de trabajo","workflows.create":"Crear flujo","workflows.empty":"No hay flujos definidos.","workflows.emptyDesc":"Diseña tu primer flujo de trabajo para orquestar múltiples agentes.","workflows.nodes":"{count} nodos","workflows.edit":"Editar","workflow.editor":"Editor de flujo","workflow.addNode":"Añadir nodo","workflow.save":"Guardar","workflow.run":"Ejecutar flujo","skills.title":"Habilidades","skills.install":"Instalar","skills.empty":"No hay habilidades instaladas.","skills.emptyDesc":"Explora e instala habilidades para ampliar las capacidades de tus agentes.","skills.scan":"Escanear directorio","skills.source":"URL o ruta de origen","runs.title":"Ejecuciones","runs.empty":"No hay ejecuciones registradas.","runs.emptyDesc":"Ejecuta un agente o flujo para ver el historial.","runs.filter":"Filtrar","run.events":"Eventos","run.output":"Salida","run.cost":"Desglose de costes","run.duration":"Duración","approvals.title":"Cola de aprobación","approvals.empty":"Sin aprobaciones pendientes.","approvals.emptyDesc":"Todo despejado. Las acciones peligrosas aparecerán aquí.","approvals.approve":"Aprobar","approvals.deny":"Denegar","approvals.pending":"Pendiente","nav.analytics":"Analíticas","nav.budget":"Presupuesto","nav.traces":"Trazas","nav.memory":"Memoria","nav.goals":"Objetivos","nav.plans":"Planes","nav.guardrails":"Salvaguardas","analytics.title":"Analíticas de coste","analytics.description":"Seguimiento de gastos, uso de tokens y presupuesto por agente.","analytics.totalSpend":"Gasto total","analytics.totalRuns":"Total ejecuciones","analytics.avgCostPerRun":"Coste medio/ejec.","analytics.monthlyEstimate":"Estimación mensual","analytics.dailyCosts":"Costes diarios (30 días)","analytics.agentBreakdown":"Coste por agente","analytics.modelBreakdown":"Coste por modelo","analytics.budgetUtilization":"Uso del presupuesto","analytics.runs":"Ejecuciones","analytics.totalCost":"Coste total","analytics.avgCost":"Coste medio","analytics.model":"Modelo","analytics.tokens":"Tokens","analytics.cost":"Coste","analytics.noAgentData":"Sin datos de coste por agente.","analytics.noModelData":"Sin datos de coste por modelo.","settings.title":"Configuración","settings.general":"General","settings.security":"Seguridad","settings.llm":"LLM","settings.budget":"Presupuesto","settings.save":"Guardar cambios","settings.saved":"Configuración guardada.","settings.language":"Idioma","common.loading":"Cargando...","common.error":"Se produjo un error.","common.retry":"Reintentar","common.cancel":"Cancelar","common.save":"Guardar","common.delete":"Eliminar","common.close":"Cerrar","common.search":"Buscar...","common.noResults":"Sin resultados.","common.name":"Nombre","common.description":"Descripción","common.status":"Estado","common.type":"Tipo","common.actions":"Acciones","common.created":"Creado","common.updated":"Actualizado","status.running":"En ejecución","status.completed":"Completado","status.failed":"Fallido","status.pending":"Pendiente","status.paused":"En pausa","status.cancelled":"Cancelado","status.idle":"Inactivo","trust.builtin":"Integrado","trust.official":"Oficial","trust.trusted":"Verificado","trust.community":"Comunidad","trust.local":"Local"},de:{"nav.dashboard":"Dashboard","nav.agents":"Agenten","nav.workflows":"Workflows","nav.skills":"Fähigkeiten","nav.runs":"Ausführungen","nav.approvals":"Genehmigungen","nav.handoffs":"Übergaben","nav.apiKeys":"API-Schlüssel","nav.settings":"Einstellungen","nav.users":"Benutzer","nav.prompts":"Prompts","dashboard.title":"Dashboard","dashboard.activeAgents":"Aktive Agenten","dashboard.runningTasks":"Laufende Aufgaben","dashboard.costToday":"Kosten heute","dashboard.skillsInstalled":"Installierte Fähigkeiten","dashboard.recentActivity":"Letzte Aktivität","dashboard.quickActions":"Schnellaktionen","dashboard.systemHealth":"Systemstatus","dashboard.createAgent":"Agent erstellen","dashboard.runWorkflow":"Workflow starten","dashboard.installSkill":"Fähigkeit installieren","agents.title":"Agenten","agents.create":"Agent erstellen","agents.empty":"Keine Agenten konfiguriert.","agents.emptyDesc":"Erstellen Sie Ihren ersten KI-Agenten für automatisierte Aufgaben.","agent.overview":"Übersicht","agent.runs":"Ausführungen","agent.events":"Ereignisse","agent.configuration":"Konfiguration","agent.budget":"Budget","agent.recentRuns":"Letzte Ausführungen","agent.delete":"Agent löschen","agent.start":"Starten","agent.stop":"Stoppen","agent.run":"Ausführen","workflows.title":"Workflows","workflows.create":"Workflow erstellen","workflows.empty":"Keine Workflows definiert.","workflows.emptyDesc":"Entwerfen Sie Ihren ersten Workflow zur Orchestrierung mehrerer Agenten.","workflows.nodes":"{count} Knoten","workflows.edit":"Bearbeiten","workflow.editor":"Workflow-Editor","workflow.addNode":"Knoten hinzufügen","workflow.save":"Speichern","workflow.run":"Workflow starten","skills.title":"Fähigkeiten","skills.install":"Installieren","skills.empty":"Keine Fähigkeiten installiert.","skills.emptyDesc":"Durchsuchen und installieren Sie Fähigkeiten, um die Möglichkeiten Ihrer Agenten zu erweitern.","skills.scan":"Verzeichnis scannen","skills.source":"Quell-URL oder -pfad","runs.title":"Ausführungen","runs.empty":"Keine Ausführungen aufgezeichnet.","runs.emptyDesc":"Starten Sie einen Agenten oder Workflow, um den Verlauf anzuzeigen.","runs.filter":"Filtern","run.events":"Ereignisse","run.output":"Ausgabe","run.cost":"Kostenaufschlüsselung","run.duration":"Dauer","approvals.title":"Genehmigungswarteschlange","approvals.empty":"Keine ausstehenden Genehmigungen.","approvals.emptyDesc":"Alles in Ordnung. Gefährliche Aktionen erscheinen hier zur Überprüfung.","approvals.approve":"Genehmigen","approvals.deny":"Ablehnen","approvals.pending":"Ausstehend","nav.analytics":"Analytik","nav.budget":"Budget","nav.traces":"Traces","nav.memory":"Speicher","nav.goals":"Ziele","nav.plans":"Pläne","nav.guardrails":"Leitplanken","analytics.title":"Kostenanalytik","analytics.description":"Ausgaben, Token-Nutzung und Budgetauslastung pro Agent verfolgen.","analytics.totalSpend":"Gesamtausgaben","analytics.totalRuns":"Gesamtausführungen","analytics.avgCostPerRun":"Ø Kosten/Ausf.","analytics.monthlyEstimate":"Monatliche Schätzung","analytics.dailyCosts":"Tägliche Kosten (30 Tage)","analytics.agentBreakdown":"Kosten pro Agent","analytics.modelBreakdown":"Kosten pro Modell","analytics.budgetUtilization":"Budgetauslastung","analytics.runs":"Ausführungen","analytics.totalCost":"Gesamtkosten","analytics.avgCost":"Ø Kosten","analytics.model":"Modell","analytics.tokens":"Tokens","analytics.cost":"Kosten","analytics.noAgentData":"Noch keine Kostendaten pro Agent.","analytics.noModelData":"Noch keine Kostendaten pro Modell.","settings.title":"Einstellungen","settings.general":"Allgemein","settings.security":"Sicherheit","settings.llm":"LLM","settings.budget":"Budget","settings.save":"Änderungen speichern","settings.saved":"Einstellungen gespeichert.","settings.language":"Sprache","common.loading":"Laden...","common.error":"Ein Fehler ist aufgetreten.","common.retry":"Erneut versuchen","common.cancel":"Abbrechen","common.save":"Speichern","common.delete":"Löschen","common.close":"Schließen","common.search":"Suchen...","common.noResults":"Keine Ergebnisse.","common.name":"Name","common.description":"Beschreibung","common.status":"Status","common.type":"Typ","common.actions":"Aktionen","common.created":"Erstellt","common.updated":"Aktualisiert","status.running":"Läuft","status.completed":"Abgeschlossen","status.failed":"Fehlgeschlagen","status.pending":"Ausstehend","status.paused":"Pausiert","status.cancelled":"Abgebrochen","status.idle":"Inaktiv","trust.builtin":"Integriert","trust.official":"Offiziell","trust.trusted":"Vertrauenswürdig","trust.community":"Community","trust.local":"Lokal"},pt:{"nav.dashboard":"Painel","nav.agents":"Agentes","nav.workflows":"Fluxos de trabalho","nav.skills":"Habilidades","nav.runs":"Execuções","nav.approvals":"Aprovações","nav.handoffs":"Transferências","nav.apiKeys":"Chaves API","nav.settings":"Configurações","nav.users":"Usuários","nav.prompts":"Prompts","dashboard.title":"Painel","dashboard.activeAgents":"Agentes ativos","dashboard.runningTasks":"Tarefas em execução","dashboard.costToday":"Custo hoje","dashboard.skillsInstalled":"Habilidades instaladas","dashboard.recentActivity":"Atividade recente","dashboard.quickActions":"Ações rápidas","dashboard.systemHealth":"Saúde do sistema","dashboard.createAgent":"Criar agente","dashboard.runWorkflow":"Executar fluxo","dashboard.installSkill":"Instalar habilidade","agents.title":"Agentes","agents.create":"Criar agente","agents.empty":"Nenhum agente configurado.","agents.emptyDesc":"Crie seu primeiro agente de IA para começar com tarefas automatizadas.","agent.overview":"Visão geral","agent.runs":"Execuções","agent.events":"Eventos","agent.configuration":"Configuração","agent.budget":"Orçamento","agent.recentRuns":"Execuções recentes","agent.delete":"Excluir agente","agent.start":"Iniciar","agent.stop":"Parar","agent.run":"Executar","workflows.title":"Fluxos de trabalho","workflows.create":"Criar fluxo","workflows.empty":"Nenhum fluxo definido.","workflows.emptyDesc":"Projete seu primeiro fluxo de trabalho para orquestrar múltiplos agentes.","workflows.nodes":"{count} nós","workflows.edit":"Editar","workflow.editor":"Editor de fluxo","workflow.addNode":"Adicionar nó","workflow.save":"Salvar","workflow.run":"Executar fluxo","skills.title":"Habilidades","skills.install":"Instalar","skills.empty":"Nenhuma habilidade instalada.","skills.emptyDesc":"Explore e instale habilidades para ampliar as capacidades dos seus agentes.","skills.scan":"Escanear diretório","skills.source":"URL ou caminho de origem","runs.title":"Execuções","runs.empty":"Nenhuma execução registrada.","runs.emptyDesc":"Execute um agente ou fluxo para ver o histórico.","runs.filter":"Filtrar","run.events":"Eventos","run.output":"Saída","run.cost":"Detalhamento de custos","run.duration":"Duração","approvals.title":"Fila de aprovação","approvals.empty":"Sem aprovações pendentes.","approvals.emptyDesc":"Tudo limpo. Ações perigosas aparecerão aqui para revisão.","approvals.approve":"Aprovar","approvals.deny":"Negar","approvals.pending":"Pendente","nav.analytics":"Análises","nav.budget":"Orçamento","nav.traces":"Rastros","nav.memory":"Memória","nav.goals":"Objetivos","nav.plans":"Planos","nav.guardrails":"Proteções","analytics.title":"Análise de custos","analytics.description":"Acompanhe gastos, uso de tokens e orçamento por agente.","analytics.totalSpend":"Gasto total","analytics.totalRuns":"Total de execuções","analytics.avgCostPerRun":"Custo médio/exec.","analytics.monthlyEstimate":"Estimativa mensal","analytics.dailyCosts":"Custos diários (30 dias)","analytics.agentBreakdown":"Custo por agente","analytics.modelBreakdown":"Custo por modelo","analytics.budgetUtilization":"Utilização do orçamento","analytics.runs":"Execuções","analytics.totalCost":"Custo total","analytics.avgCost":"Custo médio","analytics.model":"Modelo","analytics.tokens":"Tokens","analytics.cost":"Custo","analytics.noAgentData":"Sem dados de custo por agente.","analytics.noModelData":"Sem dados de custo por modelo.","settings.title":"Configurações","settings.general":"Geral","settings.security":"Segurança","settings.llm":"LLM","settings.budget":"Orçamento","settings.save":"Salvar alterações","settings.saved":"Configurações salvas.","settings.language":"Idioma","common.loading":"Carregando...","common.error":"Ocorreu um erro.","common.retry":"Tentar novamente","common.cancel":"Cancelar","common.save":"Salvar","common.delete":"Excluir","common.close":"Fechar","common.search":"Pesquisar...","common.noResults":"Nenhum resultado.","common.name":"Nome","common.description":"Descrição","common.status":"Status","common.type":"Tipo","common.actions":"Ações","common.created":"Criado","common.updated":"Atualizado","status.running":"Em execução","status.completed":"Concluído","status.failed":"Falhou","status.pending":"Pendente","status.paused":"Pausado","status.cancelled":"Cancelado","status.idle":"Inativo","trust.builtin":"Integrado","trust.official":"Oficial","trust.trusted":"Verificado","trust.community":"Comunidade","trust.local":"Local"},ja:{"nav.dashboard":"ダッシュボード","nav.agents":"エージェント","nav.workflows":"ワークフロー","nav.skills":"スキル","nav.runs":"実行履歴","nav.approvals":"承認","nav.handoffs":"引き継ぎ","nav.apiKeys":"APIキー","nav.settings":"設定","nav.users":"ユーザー","nav.prompts":"プロンプト","dashboard.title":"ダッシュボード","dashboard.activeAgents":"アクティブなエージェント","dashboard.runningTasks":"実行中のタスク","dashboard.costToday":"本日のコスト","dashboard.skillsInstalled":"インストール済みスキル","dashboard.recentActivity":"最近のアクティビティ","dashboard.quickActions":"クイックアクション","dashboard.systemHealth":"システム状態","dashboard.createAgent":"エージェント作成","dashboard.runWorkflow":"ワークフロー実行","dashboard.installSkill":"スキルインストール","agents.title":"エージェント","agents.create":"エージェント作成","agents.empty":"エージェントが構成されていません。","agents.emptyDesc":"最初のAIエージェントを作成して自動化タスクを始めましょう。","agent.overview":"概要","agent.runs":"実行履歴","agent.events":"イベント","agent.configuration":"構成","agent.budget":"予算","agent.recentRuns":"最近の実行","agent.delete":"エージェント削除","agent.start":"開始","agent.stop":"停止","agent.run":"実行","workflows.title":"ワークフロー","workflows.create":"ワークフロー作成","workflows.empty":"ワークフローが定義されていません。","workflows.emptyDesc":"最初のワークフローを設計して複数のエージェントをオーケストレーションしましょう。","workflows.nodes":"{count} ノード","workflows.edit":"編集","workflow.editor":"ワークフローエディタ","workflow.addNode":"ノード追加","workflow.save":"保存","workflow.run":"ワークフロー実行","skills.title":"スキル","skills.install":"インストール","skills.empty":"スキルがインストールされていません。","skills.emptyDesc":"スキルを参照・インストールしてエージェントの機能を拡張しましょう。","skills.scan":"ディレクトリスキャン","skills.source":"ソースURLまたはパス","runs.title":"実行履歴","runs.empty":"実行記録がありません。","runs.emptyDesc":"エージェントまたはワークフローを実行して履歴を確認しましょう。","runs.filter":"フィルター","run.events":"イベント","run.output":"出力","run.cost":"コスト内訳","run.duration":"所要時間","approvals.title":"承認キュー","approvals.empty":"保留中の承認はありません。","approvals.emptyDesc":"問題なし。危険なアクションはここに表示されます。","approvals.approve":"承認","approvals.deny":"拒否","approvals.pending":"保留中","nav.analytics":"アナリティクス","nav.budget":"予算","nav.traces":"トレース","nav.memory":"メモリ","nav.goals":"目標","nav.plans":"プラン","nav.guardrails":"ガードレール","analytics.title":"コスト分析","analytics.description":"エージェントごとの支出、トークン使用量、予算利用状況を追跡。","analytics.totalSpend":"総支出","analytics.totalRuns":"総実行数","analytics.avgCostPerRun":"平均コスト/実行","analytics.monthlyEstimate":"月間見積もり","analytics.dailyCosts":"日次コスト(30日間)","analytics.agentBreakdown":"エージェント別コスト","analytics.modelBreakdown":"モデル別コスト","analytics.budgetUtilization":"予算利用率","analytics.runs":"実行回数","analytics.totalCost":"総コスト","analytics.avgCost":"平均コスト","analytics.model":"モデル","analytics.tokens":"トークン","analytics.cost":"コスト","analytics.noAgentData":"エージェントコストデータがまだありません。","analytics.noModelData":"モデルコストデータがまだありません。","settings.title":"設定","settings.general":"一般","settings.security":"セキュリティ","settings.llm":"LLM","settings.budget":"予算","settings.save":"変更を保存","settings.saved":"設定が保存されました。","settings.language":"言語","common.loading":"読み込み中...","common.error":"エラーが発生しました。","common.retry":"再試行","common.cancel":"キャンセル","common.save":"保存","common.delete":"削除","common.close":"閉じる","common.search":"検索...","common.noResults":"結果が見つかりません。","common.name":"名前","common.description":"説明","common.status":"ステータス","common.type":"タイプ","common.actions":"アクション","common.created":"作成日","common.updated":"更新日","status.running":"実行中","status.completed":"完了","status.failed":"失敗","status.pending":"保留中","status.paused":"一時停止","status.cancelled":"キャンセル済み","status.idle":"アイドル","trust.builtin":"組み込み","trust.official":"公式","trust.trusted":"信頼済み","trust.community":"コミュニティ","trust.local":"ローカル"},zh:{"nav.dashboard":"仪表盘","nav.agents":"代理","nav.workflows":"工作流","nav.skills":"技能","nav.runs":"执行记录","nav.approvals":"审批","nav.handoffs":"交接","nav.apiKeys":"API密钥","nav.settings":"设置","nav.users":"用户","nav.prompts":"提示词","dashboard.title":"仪表盘","dashboard.activeAgents":"活跃代理","dashboard.runningTasks":"运行中的任务","dashboard.costToday":"今日费用","dashboard.skillsInstalled":"已安装技能","dashboard.recentActivity":"最近活动","dashboard.quickActions":"快捷操作","dashboard.systemHealth":"系统状态","dashboard.createAgent":"创建代理","dashboard.runWorkflow":"运行工作流","dashboard.installSkill":"安装技能","agents.title":"代理","agents.create":"创建代理","agents.empty":"尚无已配置的代理。","agents.emptyDesc":"创建您的第一个AI代理以开始自动化任务。","agent.overview":"概览","agent.runs":"执行记录","agent.events":"事件","agent.configuration":"配置","agent.budget":"预算","agent.recentRuns":"最近执行","agent.delete":"删除代理","agent.start":"启动","agent.stop":"停止","agent.run":"运行","workflows.title":"工作流","workflows.create":"创建工作流","workflows.empty":"尚无已定义的工作流。","workflows.emptyDesc":"设计您的第一个工作流以编排多个代理。","workflows.nodes":"{count} 个节点","workflows.edit":"编辑","workflow.editor":"工作流编辑器","workflow.addNode":"添加节点","workflow.save":"保存","workflow.run":"运行工作流","skills.title":"技能","skills.install":"安装","skills.empty":"尚无已安装的技能。","skills.emptyDesc":"浏览并安装技能以扩展代理的能力。","skills.scan":"扫描目录","skills.source":"源URL或路径","runs.title":"执行记录","runs.empty":"尚无执行记录。","runs.emptyDesc":"运行代理或工作流以查看执行历史。","runs.filter":"筛选","run.events":"事件","run.output":"输出","run.cost":"费用明细","run.duration":"持续时间","approvals.title":"审批队列","approvals.empty":"没有待审批项。","approvals.emptyDesc":"一切正常。危险操作将在此显示以供审查。","approvals.approve":"批准","approvals.deny":"拒绝","approvals.pending":"待处理","nav.analytics":"分析","nav.budget":"预算","nav.traces":"追踪","nav.memory":"记忆","nav.goals":"目标","nav.plans":"计划","nav.guardrails":"护栏","analytics.title":"费用分析","analytics.description":"追踪各代理的支出、令牌使用量和预算利用率。","analytics.totalSpend":"总支出","analytics.totalRuns":"总执行次数","analytics.avgCostPerRun":"平均费用/次","analytics.monthlyEstimate":"月度估算","analytics.dailyCosts":"每日费用(30天)","analytics.agentBreakdown":"按代理的费用","analytics.modelBreakdown":"按模型的费用","analytics.budgetUtilization":"预算利用率","analytics.runs":"执行次数","analytics.totalCost":"总费用","analytics.avgCost":"平均费用","analytics.model":"模型","analytics.tokens":"令牌","analytics.cost":"费用","analytics.noAgentData":"尚无代理费用数据。","analytics.noModelData":"尚无模型费用数据。","settings.title":"设置","settings.general":"通用","settings.security":"安全","settings.llm":"LLM","settings.budget":"预算","settings.save":"保存更改","settings.saved":"设置已保存。","settings.language":"语言","common.loading":"加载中...","common.error":"发生错误。","common.retry":"重试","common.cancel":"取消","common.save":"保存","common.delete":"删除","common.close":"关闭","common.search":"搜索...","common.noResults":"未找到结果。","common.name":"名称","common.description":"描述","common.status":"状态","common.type":"类型","common.actions":"操作","common.created":"创建时间","common.updated":"更新时间","status.running":"运行中","status.completed":"已完成","status.failed":"失败","status.pending":"待处理","status.paused":"已暂停","status.cancelled":"已取消","status.idle":"空闲","trust.builtin":"内置","trust.official":"官方","trust.trusted":"受信任","trust.community":"社区","trust.local":"本地"},ko:{"nav.dashboard":"대시보드","nav.agents":"에이전트","nav.workflows":"워크플로우","nav.skills":"스킬","nav.runs":"실행 기록","nav.approvals":"승인","nav.handoffs":"인수인계","nav.apiKeys":"API 키","nav.settings":"설정","nav.users":"사용자","nav.prompts":"프롬프트","dashboard.title":"대시보드","dashboard.activeAgents":"활성 에이전트","dashboard.runningTasks":"실행 중인 작업","dashboard.costToday":"오늘 비용","dashboard.skillsInstalled":"설치된 스킬","dashboard.recentActivity":"최근 활동","dashboard.quickActions":"빠른 작업","dashboard.systemHealth":"시스템 상태","dashboard.createAgent":"에이전트 생성","dashboard.runWorkflow":"워크플로우 실행","dashboard.installSkill":"스킬 설치","agents.title":"에이전트","agents.create":"에이전트 생성","agents.empty":"구성된 에이전트가 없습니다.","agents.emptyDesc":"첫 번째 AI 에이전트를 만들어 자동화 작업을 시작하세요.","agent.overview":"개요","agent.runs":"실행 기록","agent.events":"이벤트","agent.configuration":"구성","agent.budget":"예산","agent.recentRuns":"최근 실행","agent.delete":"에이전트 삭제","agent.start":"시작","agent.stop":"중지","agent.run":"실행","workflows.title":"워크플로우","workflows.create":"워크플로우 생성","workflows.empty":"정의된 워크플로우가 없습니다.","workflows.emptyDesc":"첫 번째 워크플로우를 설계하여 여러 에이전트를 조율하세요.","workflows.nodes":"{count}개 노드","workflows.edit":"편집","workflow.editor":"워크플로우 편집기","workflow.addNode":"노드 추가","workflow.save":"저장","workflow.run":"워크플로우 실행","skills.title":"스킬","skills.install":"설치","skills.empty":"설치된 스킬이 없습니다.","skills.emptyDesc":"스킬을 탐색하고 설치하여 에이전트의 기능을 확장하세요.","skills.scan":"디렉토리 스캔","skills.source":"소스 URL 또는 경로","runs.title":"실행 기록","runs.empty":"기록된 실행이 없습니다.","runs.emptyDesc":"에이전트 또는 워크플로우를 실행하여 실행 기록을 확인하세요.","runs.filter":"필터","run.events":"이벤트","run.output":"출력","run.cost":"비용 내역","run.duration":"소요 시간","approvals.title":"승인 대기열","approvals.empty":"대기 중인 승인이 없습니다.","approvals.emptyDesc":"문제 없음. 위험한 작업은 여기에 검토를 위해 표시됩니다.","approvals.approve":"승인","approvals.deny":"거부","approvals.pending":"대기 중","nav.analytics":"분석","nav.budget":"예산","nav.traces":"추적","nav.memory":"메모리","nav.goals":"목표","nav.plans":"계획","nav.guardrails":"가드레일","analytics.title":"비용 분석","analytics.description":"에이전트별 지출, 토큰 사용량 및 예산 활용도를 추적합니다.","analytics.totalSpend":"총 지출","analytics.totalRuns":"총 실행 수","analytics.avgCostPerRun":"평균 비용/실행","analytics.monthlyEstimate":"월간 추정","analytics.dailyCosts":"일별 비용 (30일)","analytics.agentBreakdown":"에이전트별 비용","analytics.modelBreakdown":"모델별 비용","analytics.budgetUtilization":"예산 활용률","analytics.runs":"실행 횟수","analytics.totalCost":"총 비용","analytics.avgCost":"평균 비용","analytics.model":"모델","analytics.tokens":"토큰","analytics.cost":"비용","analytics.noAgentData":"에이전트 비용 데이터가 없습니다.","analytics.noModelData":"모델 비용 데이터가 없습니다.","settings.title":"설정","settings.general":"일반","settings.security":"보안","settings.llm":"LLM","settings.budget":"예산","settings.save":"변경 사항 저장","settings.saved":"설정이 저장되었습니다.","settings.language":"언어","common.loading":"로딩 중...","common.error":"오류가 발생했습니다.","common.retry":"재시도","common.cancel":"취소","common.save":"저장","common.delete":"삭제","common.close":"닫기","common.search":"검색...","common.noResults":"결과를 찾을 수 없습니다.","common.name":"이름","common.description":"설명","common.status":"상태","common.type":"유형","common.actions":"작업","common.created":"생성일","common.updated":"수정일","status.running":"실행 중","status.completed":"완료","status.failed":"실패","status.pending":"대기 중","status.paused":"일시 중지","status.cancelled":"취소됨","status.idle":"유휴","trust.builtin":"내장","trust.official":"공식","trust.trusted":"신뢰됨","trust.community":"커뮤니티","trust.local":"로컬"},ar:{"nav.dashboard":"لوحة التحكم","nav.agents":"الوكلاء","nav.workflows":"مسارات العمل","nav.skills":"المهارات","nav.runs":"عمليات التنفيذ","nav.approvals":"الموافقات","nav.handoffs":"التسليمات","nav.apiKeys":"مفاتيح API","nav.settings":"الإعدادات","nav.users":"المستخدمون","nav.prompts":"التعليمات","dashboard.title":"لوحة التحكم","dashboard.activeAgents":"الوكلاء النشطون","dashboard.runningTasks":"المهام قيد التشغيل","dashboard.costToday":"تكلفة اليوم","dashboard.skillsInstalled":"المهارات المثبتة","dashboard.recentActivity":"النشاط الأخير","dashboard.quickActions":"إجراءات سريعة","dashboard.systemHealth":"حالة النظام","dashboard.createAgent":"إنشاء وكيل","dashboard.runWorkflow":"تشغيل مسار عمل","dashboard.installSkill":"تثبيت مهارة","agents.title":"الوكلاء","agents.create":"إنشاء وكيل","agents.empty":"لا توجد وكلاء مهيأة بعد.","agents.emptyDesc":"أنشئ أول وكيل ذكاء اصطناعي لبدء المهام الآلية.","agent.overview":"نظرة عامة","agent.runs":"عمليات التنفيذ","agent.events":"الأحداث","agent.configuration":"التكوين","agent.budget":"الميزانية","agent.recentRuns":"آخر عمليات التنفيذ","agent.delete":"حذف الوكيل","agent.start":"بدء","agent.stop":"إيقاف","agent.run":"تشغيل","workflows.title":"مسارات العمل","workflows.create":"إنشاء مسار عمل","workflows.empty":"لا توجد مسارات عمل معرّفة بعد.","workflows.emptyDesc":"صمّم أول مسار عمل لتنسيق عدة وكلاء.","workflows.nodes":"{count} عقدة","workflows.edit":"تعديل","workflow.editor":"محرر مسار العمل","workflow.addNode":"إضافة عقدة","workflow.save":"حفظ","workflow.run":"تشغيل مسار العمل","skills.title":"المهارات","skills.install":"تثبيت","skills.empty":"لا توجد مهارات مثبتة بعد.","skills.emptyDesc":"تصفّح وثبّت المهارات لتوسيع قدرات وكلائك.","skills.scan":"فحص المجلد","skills.source":"عنوان URL أو مسار المصدر","runs.title":"عمليات التنفيذ","runs.empty":"لا توجد عمليات تنفيذ مسجلة بعد.","runs.emptyDesc":"شغّل وكيلًا أو مسار عمل لعرض سجل التنفيذ.","runs.filter":"تصفية","run.events":"الأحداث","run.output":"المخرجات","run.cost":"تفصيل التكاليف","run.duration":"المدة","approvals.title":"قائمة الموافقات","approvals.empty":"لا توجد موافقات معلقة.","approvals.emptyDesc":"كل شيء على ما يرام. ستظهر الإجراءات الخطيرة هنا للمراجعة.","approvals.approve":"موافقة","approvals.deny":"رفض","approvals.pending":"معلّق","nav.analytics":"التحليلات","nav.budget":"الميزانية","nav.traces":"التتبع","nav.memory":"الذاكرة","nav.goals":"الأهداف","nav.plans":"الخطط","nav.guardrails":"الحواجز","analytics.title":"تحليل التكاليف","analytics.description":"تتبع الإنفاق واستخدام الرموز وميزانية كل وكيل.","analytics.totalSpend":"إجمالي الإنفاق","analytics.totalRuns":"إجمالي عمليات التنفيذ","analytics.avgCostPerRun":"متوسط التكلفة/تنفيذ","analytics.monthlyEstimate":"التقدير الشهري","analytics.dailyCosts":"التكاليف اليومية (30 يومًا)","analytics.agentBreakdown":"التكلفة حسب الوكيل","analytics.modelBreakdown":"التكلفة حسب النموذج","analytics.budgetUtilization":"استخدام الميزانية","analytics.runs":"عمليات التنفيذ","analytics.totalCost":"التكلفة الإجمالية","analytics.avgCost":"متوسط التكلفة","analytics.model":"النموذج","analytics.tokens":"الرموز","analytics.cost":"التكلفة","analytics.noAgentData":"لا توجد بيانات تكلفة للوكلاء بعد.","analytics.noModelData":"لا توجد بيانات تكلفة للنماذج بعد.","settings.title":"الإعدادات","settings.general":"عام","settings.security":"الأمان","settings.llm":"LLM","settings.budget":"الميزانية","settings.save":"حفظ التغييرات","settings.saved":"تم حفظ الإعدادات بنجاح.","settings.language":"اللغة","common.loading":"جارٍ التحميل...","common.error":"حدث خطأ.","common.retry":"إعادة المحاولة","common.cancel":"إلغاء","common.save":"حفظ","common.delete":"حذف","common.close":"إغلاق","common.search":"بحث...","common.noResults":"لم يتم العثور على نتائج.","common.name":"الاسم","common.description":"الوصف","common.status":"الحالة","common.type":"النوع","common.actions":"الإجراءات","common.created":"تاريخ الإنشاء","common.updated":"تاريخ التحديث","status.running":"قيد التشغيل","status.completed":"مكتمل","status.failed":"فشل","status.pending":"معلّق","status.paused":"متوقف مؤقتًا","status.cancelled":"ملغى","status.idle":"خامل","trust.builtin":"مدمج","trust.official":"رسمي","trust.trusted":"موثوق","trust.community":"مجتمعي","trust.local":"محلي"},ru:{"nav.dashboard":"Панель управления","nav.agents":"Агенты","nav.workflows":"Рабочие процессы","nav.skills":"Навыки","nav.runs":"Запуски","nav.approvals":"Одобрения","nav.handoffs":"Передачи","nav.apiKeys":"API-ключи","nav.settings":"Настройки","nav.users":"Пользователи","nav.prompts":"Промпты","dashboard.title":"Панель управления","dashboard.activeAgents":"Активные агенты","dashboard.runningTasks":"Запущенные задачи","dashboard.costToday":"Расходы сегодня","dashboard.skillsInstalled":"Установленные навыки","dashboard.recentActivity":"Последняя активность","dashboard.quickActions":"Быстрые действия","dashboard.systemHealth":"Состояние системы","dashboard.createAgent":"Создать агента","dashboard.runWorkflow":"Запустить процесс","dashboard.installSkill":"Установить навык","agents.title":"Агенты","agents.create":"Создать агента","agents.empty":"Нет настроенных агентов.","agents.emptyDesc":"Создайте первого ИИ-агента для автоматизации задач.","agent.overview":"Обзор","agent.runs":"Запуски","agent.events":"События","agent.configuration":"Конфигурация","agent.budget":"Бюджет","agent.recentRuns":"Последние запуски","agent.delete":"Удалить агента","agent.start":"Запустить","agent.stop":"Остановить","agent.run":"Выполнить","workflows.title":"Рабочие процессы","workflows.create":"Создать процесс","workflows.empty":"Нет определённых процессов.","workflows.emptyDesc":"Создайте первый рабочий процесс для оркестрации агентов.","workflows.nodes":"{count} узлов","workflows.edit":"Редактировать","workflow.editor":"Редактор процессов","workflow.addNode":"Добавить узел","workflow.save":"Сохранить","workflow.run":"Запустить процесс","skills.title":"Навыки","skills.install":"Установить","skills.empty":"Нет установленных навыков.","skills.emptyDesc":"Просматривайте и устанавливайте навыки для расширения возможностей агентов.","skills.scan":"Сканировать каталог","skills.source":"URL или путь к источнику","runs.title":"Запуски","runs.empty":"Нет записей о запусках.","runs.emptyDesc":"Запустите агента или процесс, чтобы увидеть историю выполнения.","runs.filter":"Фильтр","run.events":"События","run.output":"Вывод","run.cost":"Разбивка стоимости","run.duration":"Длительность","approvals.title":"Очередь одобрений","approvals.empty":"Нет ожидающих одобрений.","approvals.emptyDesc":"Всё в порядке. Опасные действия появятся здесь для проверки.","approvals.approve":"Одобрить","approvals.deny":"Отклонить","approvals.pending":"Ожидает","nav.analytics":"Аналитика","nav.budget":"Бюджет","nav.traces":"Трассировки","nav.memory":"Память","nav.goals":"Цели","nav.plans":"Планы","nav.guardrails":"Ограждения","analytics.title":"Аналитика расходов","analytics.description":"Отслеживание расходов, использования токенов и бюджета по агентам.","analytics.totalSpend":"Общие расходы","analytics.totalRuns":"Всего запусков","analytics.avgCostPerRun":"Ср. стоимость/запуск","analytics.monthlyEstimate":"Месячная оценка","analytics.dailyCosts":"Ежедневные расходы (30 дней)","analytics.agentBreakdown":"Расходы по агентам","analytics.modelBreakdown":"Расходы по моделям","analytics.budgetUtilization":"Использование бюджета","analytics.runs":"Запуски","analytics.totalCost":"Общая стоимость","analytics.avgCost":"Ср. стоимость","analytics.model":"Модель","analytics.tokens":"Токены","analytics.cost":"Стоимость","analytics.noAgentData":"Нет данных о расходах по агентам.","analytics.noModelData":"Нет данных о расходах по моделям.","settings.title":"Настройки","settings.general":"Общие","settings.security":"Безопасность","settings.llm":"LLM","settings.budget":"Бюджет","settings.save":"Сохранить изменения","settings.saved":"Настройки сохранены.","settings.language":"Язык","common.loading":"Загрузка...","common.error":"Произошла ошибка.","common.retry":"Повторить","common.cancel":"Отмена","common.save":"Сохранить","common.delete":"Удалить","common.close":"Закрыть","common.search":"Поиск...","common.noResults":"Результатов не найдено.","common.name":"Название","common.description":"Описание","common.status":"Статус","common.type":"Тип","common.actions":"Действия","common.created":"Создано","common.updated":"Обновлено","status.running":"Выполняется","status.completed":"Завершено","status.failed":"Ошибка","status.pending":"Ожидание","status.paused":"Пауза","status.cancelled":"Отменено","status.idle":"Простой","trust.builtin":"Встроенный","trust.official":"Официальный","trust.trusted":"Доверенный","trust.community":"Сообщество","trust.local":"Локальный"},it:{"nav.dashboard":"Pannello","nav.agents":"Agenti","nav.workflows":"Flussi di lavoro","nav.skills":"Competenze","nav.runs":"Esecuzioni","nav.approvals":"Approvazioni","nav.handoffs":"Passaggi","nav.apiKeys":"Chiavi API","nav.settings":"Impostazioni","nav.users":"Utenti","nav.prompts":"Prompt","dashboard.title":"Pannello","dashboard.activeAgents":"Agenti attivi","dashboard.runningTasks":"Attività in corso","dashboard.costToday":"Costo oggi","dashboard.skillsInstalled":"Competenze installate","dashboard.recentActivity":"Attività recente","dashboard.quickActions":"Azioni rapide","dashboard.systemHealth":"Stato del sistema","dashboard.createAgent":"Crea agente","dashboard.runWorkflow":"Esegui flusso","dashboard.installSkill":"Installa competenza","agents.title":"Agenti","agents.create":"Crea agente","agents.empty":"Nessun agente configurato.","agents.emptyDesc":"Crea il tuo primo agente IA per iniziare con le attività automatizzate.","agent.overview":"Panoramica","agent.runs":"Esecuzioni","agent.events":"Eventi","agent.configuration":"Configurazione","agent.budget":"Budget","agent.recentRuns":"Esecuzioni recenti","agent.delete":"Elimina agente","agent.start":"Avvia","agent.stop":"Arresta","agent.run":"Esegui","workflows.title":"Flussi di lavoro","workflows.create":"Crea flusso","workflows.empty":"Nessun flusso di lavoro definito.","workflows.emptyDesc":"Progetta il tuo primo flusso di lavoro per orchestrare più agenti.","workflows.nodes":"{count} nodi","workflows.edit":"Modifica","workflow.editor":"Editor del flusso","workflow.addNode":"Aggiungi nodo","workflow.save":"Salva","workflow.run":"Esegui flusso","skills.title":"Competenze","skills.install":"Installa","skills.empty":"Nessuna competenza installata.","skills.emptyDesc":"Esplora e installa competenze per ampliare le capacità dei tuoi agenti.","skills.scan":"Scansiona directory","skills.source":"URL o percorso sorgente","runs.title":"Esecuzioni","runs.empty":"Nessuna esecuzione registrata.","runs.emptyDesc":"Esegui un agente o un flusso per vedere la cronologia.","runs.filter":"Filtra","run.events":"Eventi","run.output":"Output","run.cost":"Dettaglio costi","run.duration":"Durata","approvals.title":"Coda di approvazione","approvals.empty":"Nessuna approvazione in sospeso.","approvals.emptyDesc":"Tutto a posto. Le azioni pericolose appariranno qui per la revisione.","approvals.approve":"Approva","approvals.deny":"Nega","approvals.pending":"In sospeso","nav.analytics":"Analisi","nav.budget":"Budget","nav.traces":"Tracce","nav.memory":"Memoria","nav.goals":"Obiettivi","nav.plans":"Piani","nav.guardrails":"Protezioni","analytics.title":"Analisi dei costi","analytics.description":"Monitora spese, utilizzo dei token e budget per agente.","analytics.totalSpend":"Spesa totale","analytics.totalRuns":"Esecuzioni totali","analytics.avgCostPerRun":"Costo medio/esec.","analytics.monthlyEstimate":"Stima mensile","analytics.dailyCosts":"Costi giornalieri (30 giorni)","analytics.agentBreakdown":"Costo per agente","analytics.modelBreakdown":"Costo per modello","analytics.budgetUtilization":"Utilizzo del budget","analytics.runs":"Esecuzioni","analytics.totalCost":"Costo totale","analytics.avgCost":"Costo medio","analytics.model":"Modello","analytics.tokens":"Token","analytics.cost":"Costo","analytics.noAgentData":"Nessun dato di costo per agente.","analytics.noModelData":"Nessun dato di costo per modello.","settings.title":"Impostazioni","settings.general":"Generale","settings.security":"Sicurezza","settings.llm":"LLM","settings.budget":"Budget","settings.save":"Salva modifiche","settings.saved":"Impostazioni salvate.","settings.language":"Lingua","common.loading":"Caricamento...","common.error":"Si è verificato un errore.","common.retry":"Riprova","common.cancel":"Annulla","common.save":"Salva","common.delete":"Elimina","common.close":"Chiudi","common.search":"Cerca...","common.noResults":"Nessun risultato.","common.name":"Nome","common.description":"Descrizione","common.status":"Stato","common.type":"Tipo","common.actions":"Azioni","common.created":"Creato","common.updated":"Aggiornato","status.running":"In esecuzione","status.completed":"Completato","status.failed":"Fallito","status.pending":"In sospeso","status.paused":"In pausa","status.cancelled":"Annullato","status.idle":"Inattivo","trust.builtin":"Integrato","trust.official":"Ufficiale","trust.trusted":"Affidabile","trust.community":"Comunità","trust.local":"Locale"},nl:{"nav.dashboard":"Dashboard","nav.agents":"Agents","nav.workflows":"Workflows","nav.skills":"Vaardigheden","nav.runs":"Uitvoeringen","nav.approvals":"Goedkeuringen","nav.handoffs":"Overdrachten","nav.apiKeys":"API-sleutels","nav.settings":"Instellingen","nav.users":"Gebruikers","nav.prompts":"Prompts","dashboard.title":"Dashboard","dashboard.activeAgents":"Actieve agents","dashboard.runningTasks":"Lopende taken","dashboard.costToday":"Kosten vandaag","dashboard.skillsInstalled":"Geïnstalleerde vaardigheden","dashboard.recentActivity":"Recente activiteit","dashboard.quickActions":"Snelle acties","dashboard.systemHealth":"Systeemstatus","dashboard.createAgent":"Agent aanmaken","dashboard.runWorkflow":"Workflow uitvoeren","dashboard.installSkill":"Vaardigheid installeren","agents.title":"Agents","agents.create":"Agent aanmaken","agents.empty":"Geen agents geconfigureerd.","agents.emptyDesc":"Maak uw eerste AI-agent aan om te beginnen met geautomatiseerde taken.","agent.overview":"Overzicht","agent.runs":"Uitvoeringen","agent.events":"Gebeurtenissen","agent.configuration":"Configuratie","agent.budget":"Budget","agent.recentRuns":"Recente uitvoeringen","agent.delete":"Agent verwijderen","agent.start":"Starten","agent.stop":"Stoppen","agent.run":"Uitvoeren","workflows.title":"Workflows","workflows.create":"Workflow aanmaken","workflows.empty":"Geen workflows gedefinieerd.","workflows.emptyDesc":"Ontwerp uw eerste workflow om meerdere agents te orkestreren.","workflows.nodes":"{count} knooppunten","workflows.edit":"Bewerken","workflow.editor":"Workflow-editor","workflow.addNode":"Knooppunt toevoegen","workflow.save":"Opslaan","workflow.run":"Workflow uitvoeren","skills.title":"Vaardigheden","skills.install":"Installeren","skills.empty":"Geen vaardigheden geïnstalleerd.","skills.emptyDesc":"Blader door en installeer vaardigheden om de mogelijkheden van uw agents uit te breiden.","skills.scan":"Map scannen","skills.source":"Bron-URL of pad","runs.title":"Uitvoeringen","runs.empty":"Geen uitvoeringen geregistreerd.","runs.emptyDesc":"Voer een agent of workflow uit om de uitvoeringsgeschiedenis te bekijken.","runs.filter":"Filteren","run.events":"Gebeurtenissen","run.output":"Uitvoer","run.cost":"Kostenoverzicht","run.duration":"Duur","approvals.title":"Goedkeuringswachtrij","approvals.empty":"Geen wachtende goedkeuringen.","approvals.emptyDesc":"Alles in orde. Gevaarlijke acties verschijnen hier ter beoordeling.","approvals.approve":"Goedkeuren","approvals.deny":"Weigeren","approvals.pending":"In afwachting","nav.analytics":"Analyse","nav.budget":"Budget","nav.traces":"Traces","nav.memory":"Geheugen","nav.goals":"Doelen","nav.plans":"Plannen","nav.guardrails":"Vangrails","analytics.title":"Kostenanalyse","analytics.description":"Volg uitgaven, tokengebruik en budgetbenutting per agent.","analytics.totalSpend":"Totale uitgaven","analytics.totalRuns":"Totaal uitvoeringen","analytics.avgCostPerRun":"Gem. kosten/uitv.","analytics.monthlyEstimate":"Maandelijkse schatting","analytics.dailyCosts":"Dagelijkse kosten (30 dagen)","analytics.agentBreakdown":"Kosten per agent","analytics.modelBreakdown":"Kosten per model","analytics.budgetUtilization":"Budgetbenutting","analytics.runs":"Uitvoeringen","analytics.totalCost":"Totale kosten","analytics.avgCost":"Gem. kosten","analytics.model":"Model","analytics.tokens":"Tokens","analytics.cost":"Kosten","analytics.noAgentData":"Nog geen kostengegevens per agent.","analytics.noModelData":"Nog geen kostengegevens per model.","settings.title":"Instellingen","settings.general":"Algemeen","settings.security":"Beveiliging","settings.llm":"LLM","settings.budget":"Budget","settings.save":"Wijzigingen opslaan","settings.saved":"Instellingen opgeslagen.","settings.language":"Taal","common.loading":"Laden...","common.error":"Er is een fout opgetreden.","common.retry":"Opnieuw proberen","common.cancel":"Annuleren","common.save":"Opslaan","common.delete":"Verwijderen","common.close":"Sluiten","common.search":"Zoeken...","common.noResults":"Geen resultaten gevonden.","common.name":"Naam","common.description":"Beschrijving","common.status":"Status","common.type":"Type","common.actions":"Acties","common.created":"Aangemaakt","common.updated":"Bijgewerkt","status.running":"Actief","status.completed":"Voltooid","status.failed":"Mislukt","status.pending":"In afwachting","status.paused":"Gepauzeerd","status.cancelled":"Geannuleerd","status.idle":"Inactief","trust.builtin":"Ingebouwd","trust.official":"Officieel","trust.trusted":"Vertrouwd","trust.community":"Community","trust.local":"Lokaal"}},_0=u.createContext({lang:"en",setLang:()=>{},t:n=>n,isRTL:!1});function Xv({children:n}){const[i,d]=u.useState(()=>{const h=localStorage.getItem("nestor_lang");return h&&Wd(h)?h:Yv(navigator.language)}),c=Kv.includes(i);u.useEffect(()=>{document.documentElement.dir=c?"rtl":"ltr",document.documentElement.lang=i},[i,c]);const m=u.useCallback(h=>{d(h),localStorage.setItem("nestor_lang",h)},[]),f=u.useCallback((h,b)=>{var p;let g=((p=qh[i])==null?void 0:p[h])??qh.en[h]??h;if(b)for(const[S,y]of Object.entries(b))g=g.replace(`{${S}}`,String(y));return g},[i]);return e.jsx(_0.Provider,{value:{lang:i,setLang:m,t:f,isRTL:c},children:n})}function Je(){return u.useContext(_0)}const Qv={admin:{agents:["create","read","update","delete","execute","admin"],workflows:["create","read","update","delete","execute","admin"],skills:["create","read","update","delete","admin"],settings:["read","update","admin"],users:["create","read","update","delete","admin"],prompts:["create","read","update","delete","admin"]},member:{agents:["create","read","update","execute"],workflows:["create","read","update","execute"],skills:["read","create"],settings:["read"],prompts:["read","create","update"]},viewer:{agents:["read"],workflows:["read"],skills:["read"],settings:["read"],prompts:["read"]}},U0=u.createContext({user:null,loading:!0,login:async()=>{},logout:async()=>{},register:async()=>{},isAdmin:!1,hasPermission:()=>!1,isSyntheticAdmin:!1}),Fv="/api";function Zv(){const n=document.cookie.match(/(?:^|; )nestor-csrf=([^;]*)/);return n?decodeURIComponent(n[1]):null}async function li(n,i){var h;const d={"Content-Type":"application/json",...(i==null?void 0:i.headers)||{}},c=((i==null?void 0:i.method)||"GET").toUpperCase();if(c!=="GET"&&c!=="HEAD"){const b=Zv();b&&(d["X-CSRF-Token"]=b)}const m=await fetch(`${Fv}${n}`,{credentials:"include",headers:d,...i}),f=await m.json().catch(()=>({}));if(!m.ok)throw new Error(((h=f==null?void 0:f.error)==null?void 0:h.message)||`Request failed (${m.status})`);return f}function Jv({children:n}){const[i,d]=u.useState(null),[c,m]=u.useState(!0),[f,h]=u.useState(!1);u.useEffect(()=>{li("/auth/me").then(v=>{var k;(k=v.data)!=null&&k.user&&typeof v.data.user=="object"&&(d(v.data.user),h(!1))}).catch(async()=>{try{(await li("/health")).status==="ok"&&(d({id:"local",email:"admin@localhost",name:"Admin",role:"admin"}),h(!0))}catch{}}).finally(()=>m(!1))},[]);const b=u.useCallback(async(v,k)=>{const C=await li("/auth/login",{method:"POST",body:JSON.stringify({email:v,password:k})});d(C.data.user),h(!1)},[]),g=u.useCallback(async()=>{await li("/auth/logout",{method:"POST"}).catch(()=>{}),d(null),h(!1)},[]),p=u.useCallback(async(v,k,C)=>{await li("/auth/register",{method:"POST",body:JSON.stringify({email:v,password:k,name:C})})},[]),S=(i==null?void 0:i.role)==="admin",y=u.useCallback((v,k)=>{if(!i)return!1;const C=Qv[i.role];if(!C)return!1;const w=C[v];return w?w.includes(k)||w.includes("admin"):!1},[i]);return e.jsx(U0.Provider,{value:{user:i,loading:c,login:b,logout:g,register:p,isAdmin:S,hasPermission:y,isSyntheticAdmin:f},children:n})}function ol(){return u.useContext(U0)}const Iv=[{to:"/missions",icon:sa,labelKey:"nav.missions"},{to:"/chat",icon:Pt,labelKey:"nav.chat"},{to:"/agents",icon:Ts,labelKey:"nav.agents"},{to:"/workflows",icon:tc,labelKey:"nav.workflows"},{to:"/runs",icon:Nt,labelKey:"nav.history"}],$0=[{key:"tools",label:"Tools",defaultOpen:!1,items:[{to:"/skills",icon:rc,labelKey:"nav.skills"},{to:"/memory",icon:La,labelKey:"nav.memory"},{to:"/messaging",icon:Pt,labelKey:"nav.messaging"},{to:"/scheduler",icon:vs,labelKey:"nav.scheduler"},{to:"/plans",icon:pv,labelKey:"nav.plans"},{to:"/guardrails",icon:Ds,labelKey:"nav.guardrails"}]},{key:"monitoring",label:"Monitoring",defaultOpen:!1,items:[{to:"/analytics",icon:Rs,labelKey:"nav.analytics"},{to:"/budget",icon:us,labelKey:"nav.budget"},{to:"/traces",icon:It,labelKey:"nav.traces"},{to:"/approvals",icon:hu,labelKey:"nav.approvals"}]},{key:"advanced",label:"Advanced",defaultOpen:!1,items:[{to:"/goals",icon:rn,labelKey:"nav.goals"},{to:"/handoffs",icon:fi,labelKey:"nav.handoffs"},{to:"/evolve",icon:Pr,labelKey:"nav.evolve"},{to:"/keys",icon:Ni,labelKey:"nav.apiKeys"},{to:"/settings",icon:il,labelKey:"nav.settings"}]}],Pv=[{to:"/users",icon:rl,labelKey:"nav.users"},{to:"/admin",icon:il,labelKey:"nav.admin"}],B0="nestor_sidebar_sections";function Wv(){try{const i=localStorage.getItem(B0);if(i)return JSON.parse(i)}catch{}const n={};for(const i of $0)n[i.key]=i.defaultOpen;return n}function ej(n){try{localStorage.setItem(B0,JSON.stringify(n))}catch{}}function tj({onNavigate:n}){const{t:i}=Je(),{user:d,isAdmin:c,logout:m}=ol(),[f,h]=u.useState(Wv);u.useEffect(()=>{ej(f)},[f]);const b=u.useCallback(p=>{h(S=>({...S,[p]:!S[p]}))},[]),g=({isActive:p})=>`flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors ${p?"bg-purple-500/10 text-purple-400":"text-zinc-400 hover:bg-surface-hover hover:text-zinc-200"}`;return e.jsxs("aside",{className:"fixed inset-y-0 left-0 z-30 flex w-60 flex-col border-r border-border bg-surface",children:[e.jsxs("div",{className:"flex h-14 items-center gap-2.5 px-5 border-b border-border",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-purple-600 text-white",children:e.jsx(sa,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-lg font-semibold text-white tracking-tight",children:["Nestor ",e.jsx("span",{className:"text-xs font-normal text-zinc-500",children:"Studio"})]})]}),e.jsxs("nav",{className:"flex-1 space-y-0.5 px-3 py-4 overflow-y-auto",children:[Iv.map(p=>{const S=p.icon;return e.jsxs(di,{to:p.to,end:p.to==="/chat",onClick:n,className:g,children:[e.jsx(S,{className:"h-4 w-4 flex-shrink-0"}),i(p.labelKey)]},p.to)}),$0.map(p=>e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{onClick:()=>b(p.key),className:"flex items-center gap-2 w-full px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-zinc-600 hover:text-zinc-400 transition-colors",children:[f[p.key]?e.jsx(na,{className:"h-3 w-3"}):e.jsx(ds,{className:"h-3 w-3"}),p.label]}),f[p.key]&&e.jsx("div",{className:"space-y-0.5",children:p.items.map(S=>{const y=S.icon;return e.jsxs(di,{to:S.to,onClick:n,className:g,children:[e.jsx(y,{className:"h-4 w-4 flex-shrink-0"}),i(S.labelKey)]},S.to)})})]},p.key)),c&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"my-2 border-t border-border/50"}),e.jsx("div",{className:"px-3 py-1 text-[10px] font-semibold uppercase tracking-wider text-zinc-600",children:"Admin"}),Pv.map(p=>{const S=p.icon;return e.jsxs(di,{to:p.to,onClick:n,className:g,children:[e.jsx(S,{className:"h-4 w-4 flex-shrink-0"}),i(p.labelKey)]},p.to)})]})]}),e.jsxs("div",{className:"border-t border-border px-4 py-3",children:[d&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-zinc-200",children:d.name}),e.jsx("p",{className:"truncate text-xs text-zinc-500",children:d.role})]}),e.jsx("button",{onClick:m,className:"rounded p-1.5 text-zinc-400 transition-colors hover:bg-surface-hover hover:text-zinc-200",title:"Sign out",children:e.jsx(zv,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"mt-2 text-xs text-zinc-600",children:"Nestor v3.4.0"})]})]})}const sj=["system","agents","runs","approvals"],aj=10,nj=1e3,lj=3e4,ij=3e4,rj=200;function cj(n,i,d){const c=Math.min(i*2**n,d),m=c*Math.random()*.25;return c+m}function oj(){const n=window.location.protocol==="https:"?"wss:":"ws:",i=window.location.host,d=localStorage.getItem("nestor_token"),c=d?`?token=${encodeURIComponent(d)}`:"";return`${n}//${i}/ws${c}`}function pu(n=sj,i){const{reconnect:d=!0,maxRetries:c=aj,baseDelay:m=nj,maxDelay:f=lj}={},[h,b]=u.useState([]),[g,p]=u.useState("disconnected"),[S,y]=u.useState(0),v=u.useRef(null),k=u.useRef(),C=u.useRef(),w=u.useRef(n),N=u.useRef(!1),z=u.useRef(0);w.current=n;const R=u.useCallback(()=>{k.current&&(clearTimeout(k.current),k.current=void 0)},[]),D=u.useCallback(()=>{C.current&&(clearInterval(C.current),C.current=void 0)},[]),O=u.useCallback(ce=>{D(),C.current=setInterval(()=>{ce.readyState===WebSocket.OPEN&&ce.send(JSON.stringify({type:"ping"}))},ij)},[D]),se=u.useCallback((ce,I)=>{for(const le of I)ce.readyState===WebSocket.OPEN&&ce.send(JSON.stringify({type:"subscribe",channel:le}))},[]),Z=u.useCallback(ce=>{if(!d||N.current)return;if(z.current>=c){console.warn(`[Nestor WS] Max retries (${c}) reached. Giving up.`),p("disconnected");return}const I=cj(z.current,m,f);console.info(`[Nestor WS] Reconnecting in ${Math.round(I)}ms (attempt ${z.current+1}/${c})`),p("reconnecting"),R(),k.current=setTimeout(()=>{z.current+=1,y(z.current),ce()},I)},[d,c,m,f,R]),U=u.useCallback(()=>{if(!(v.current&&(v.current.readyState===WebSocket.OPEN||v.current.readyState===WebSocket.CONNECTING)))try{const ce=oj(),I=new WebSocket(ce);v.current=I,p("connecting"),I.onopen=()=>{console.info("[Nestor WS] Connected"),p("connected"),z.current=0,y(0),N.current=!1,se(I,w.current),O(I)},I.onmessage=le=>{try{const Y=JSON.parse(le.data);if(Y.type==="ping"){I.send(JSON.stringify({type:"pong"}));return}if(Y.type==="pong")return;if(Y.type==="event"){const B=Y;b(ne=>[...ne.slice(-(rj-1)),B])}}catch{}},I.onclose=le=>{if(console.info(`[Nestor WS] Closed (code=${le.code}, reason=${le.reason||"none"})`),v.current=null,D(),N.current){p("disconnected");return}Z(U)},I.onerror=le=>{console.error("[Nestor WS] Error:",le),I.close()}}catch{Z(U)}},[se,O,D,Z]);u.useEffect(()=>(N.current=!1,U(),()=>{N.current=!0,R(),D(),v.current&&(v.current.close(1e3,"Component unmount"),v.current=null)}),[U,R,D]),u.useEffect(()=>{const ce=v.current;!ce||ce.readyState!==WebSocket.OPEN||se(ce,n)},[n,se]);const A=u.useCallback(ce=>{const I=v.current;I&&I.readyState===WebSocket.OPEN&&I.send(JSON.stringify({type:"subscribe",channel:ce}))},[]),F=u.useCallback(ce=>{const I=v.current;I&&I.readyState===WebSocket.OPEN&&I.send(JSON.stringify({type:"unsubscribe",channel:ce}))},[]),$=u.useCallback(()=>{b([])},[]),Q=u.useCallback(()=>{N.current=!0,R(),D(),v.current&&(v.current.close(1e3,"Manual close"),v.current=null),p("disconnected")},[R,D]);return{events:h,connected:g==="connected",status:g,retryCount:S,subscribe:A,unsubscribe:F,clearEvents:$,close:Q}}const dj="/api";class uj extends Error{constructor(i,d,c){super(`API Error ${i}: ${d}`),this.status=i,this.statusText=d,this.body=c,this.name="ApiError"}}function mj(n){const i=document.cookie.match(new RegExp(`(?:^|; )${n}=([^;]*)`));return i?decodeURIComponent(i[1]):null}async function ae(n,i={}){const d=`${dj}${n}`,c={"Content-Type":"application/json",...i.headers},m=localStorage.getItem("nestor_token");m&&(c.Authorization=`Bearer ${m}`);const f=(i.method||"GET").toUpperCase();if(f!=="GET"&&f!=="HEAD"){const g=mj("nestor-csrf");g&&(c["X-CSRF-Token"]=g)}const h=localStorage.getItem("nestor_tenant_id");h&&(c["X-Tenant-ID"]=h);const b=await fetch(d,{...i,headers:c});if(!b.ok){let g;try{g=await b.json()}catch{g=await b.text()}throw new uj(b.status,b.statusText,g)}if(b.status!==204)return b.json()}const la={list:n=>{const i=new URLSearchParams;n!=null&&n.limit&&i.set("limit",String(n.limit)),n!=null&&n.offset&&i.set("offset",String(n.offset));const d=i.toString();return ae(`/agents${d?`?${d}`:""}`)},get:n=>ae(`/agents/${n}`),create:n=>ae("/agents",{method:"POST",body:JSON.stringify(n)}),update:(n,i)=>ae(`/agents/${n}`,{method:"PATCH",body:JSON.stringify(i)}),delete:n=>ae(`/agents/${n}`,{method:"DELETE"}),run:(n,i)=>ae(`/agents/${n}/run`,{method:"POST",body:JSON.stringify({prompt:i})}),getStatus:n=>ae(`/agents/${n}/status`),start:(n,i="daemon")=>ae(`/agents/${n}/start`,{method:"POST",body:JSON.stringify({mode:i})}),stop:n=>ae(`/agents/${n}/stop`,{method:"POST"})},sc={list:n=>{const i=new URLSearchParams;n!=null&&n.limit&&i.set("limit",String(n.limit)),n!=null&&n.offset&&i.set("offset",String(n.offset));const d=i.toString();return ae(`/workflows${d?`?${d}`:""}`)},get:n=>ae(`/workflows/${n}`),create:n=>ae("/workflows",{method:"POST",body:JSON.stringify(n)}),run:(n,i={})=>ae(`/workflows/${n}/run`,{method:"POST",body:JSON.stringify({input:i})})},ln={list:n=>{const i=new URLSearchParams;n!=null&&n.limit&&i.set("limit",String(n.limit)),n!=null&&n.offset&&i.set("offset",String(n.offset)),n!=null&&n.status&&i.set("status",n.status),n!=null&&n.agentId&&i.set("agentId",n.agentId),n!=null&&n.workflowId&&i.set("workflowId",n.workflowId);const d=i.toString();return ae(`/runs${d?`?${d}`:""}`)},get:n=>ae(`/runs/${n}`),getEvents:n=>ae(`/runs/${n}/events`),abort:n=>ae(`/runs/${n}/abort`,{method:"POST"}),delete:n=>ae(`/runs/${n}`,{method:"DELETE"})},Wr={list:n=>{const i=new URLSearchParams;n!=null&&n.limit&&i.set("limit",String(n.limit)),n!=null&&n.offset&&i.set("offset",String(n.offset));const d=i.toString();return ae(`/skills${d?`?${d}`:""}`)},install:n=>ae("/skills/install",{method:"POST",body:JSON.stringify(n)}),scan:n=>ae("/skills/scan",{method:"POST",body:JSON.stringify({path:n})}),delete:n=>ae(`/skills/${n}`,{method:"DELETE"})},Es={stats:()=>ae("/system/stats"),health:()=>ae("/health"),getConfig:()=>ae("/system/config"),updateConfig:n=>ae("/system/config",{method:"PUT",body:JSON.stringify(n)})},In={summary:n=>{const i=new URLSearchParams;n!=null&&n.from&&i.set("from",String(n.from)),n!=null&&n.to&&i.set("to",String(n.to)),n!=null&&n.agentId&&i.set("agentId",n.agentId);const d=i.toString();return ae(`/analytics/summary${d?`?${d}`:""}`)},daily:(n=30)=>ae(`/analytics/daily?days=${n}`),budget:()=>ae("/analytics/budget"),estimate:()=>ae("/analytics/estimate"),agentBreakdown:n=>ae(`/analytics/agents/${n}`),qualityOverview:(n=30)=>ae(`/analytics/quality?days=${n}`),qualityAgent:(n,i=30)=>ae(`/analytics/quality/${n}?days=${i}`)},Bd={list:n=>{const i=new URLSearchParams;n!=null&&n.limit&&i.set("limit",String(n.limit)),n!=null&&n.status&&i.set("status",n.status);const d=i.toString();return ae(`/traces${d?`?${d}`:""}`)},get:n=>ae(`/traces/${n}`),clear:()=>ae("/traces",{method:"DELETE"})},Gh={list:()=>ae("/tenants"),get:n=>ae(`/tenants/${n}`),create:n=>ae("/tenants",{method:"POST",body:JSON.stringify(n)}),update:(n,i)=>ae(`/tenants/${n}`,{method:"PUT",body:JSON.stringify(i)}),delete:n=>ae(`/tenants/${n}`,{method:"DELETE"}),switch:n=>ae(`/tenants/${n}/switch`,{method:"POST"})},ii={tree:()=>ae("/goals"),get:n=>ae(`/goals/${n}`),create:n=>ae("/goals",{method:"POST",body:JSON.stringify(n)}),update:(n,i)=>ae(`/goals/${n}`,{method:"PUT",body:JSON.stringify(i)}),delete:n=>ae(`/goals/${n}`,{method:"DELETE"}),ancestry:n=>ae(`/goals/${n}/ancestry`),assign:(n,i)=>ae(`/goals/${n}/assign/${i}`,{method:"POST"}),agentGoals:n=>ae(`/agents/${n}/goals`)},ri={list:n=>{const i=new URLSearchParams;n!=null&&n.status&&i.set("status",n.status),n!=null&&n.agentId&&i.set("agentId",n.agentId),n!=null&&n.type&&i.set("type",n.type),n!=null&&n.limit&&i.set("limit",String(n.limit)),n!=null&&n.offset&&i.set("offset",String(n.offset));const d=i.toString();return ae(`/approvals${d?`?${d}`:""}`)},create:n=>ae("/approvals",{method:"POST",body:JSON.stringify(n)}),get:n=>ae(`/approvals/${n}`),approve:(n,i)=>ae(`/approvals/${n}/approve`,{method:"POST",body:JSON.stringify({decidedBy:(i==null?void 0:i.reviewerId)??"user",comment:i==null?void 0:i.comment})}),reject:(n,i)=>ae(`/approvals/${n}/reject`,{method:"POST",body:JSON.stringify({decidedBy:(i==null?void 0:i.reviewerId)??"user",reason:i==null?void 0:i.reason})}),history:n=>{const i=new URLSearchParams;n!=null&&n.limit&&i.set("limit",String(n.limit)),n!=null&&n.agentId&&i.set("agentId",n.agentId);const d=i.toString();return ae(`/approvals/history${d?`?${d}`:""}`)},stats:()=>ae("/approvals/stats")},Hd={forRun:n=>ae(`/runs/${n}/annotations`),create:(n,i)=>ae(`/runs/${n}/annotate`,{method:"POST",body:JSON.stringify(i)}),delete:n=>ae(`/annotations/${n}`,{method:"DELETE"})},ac={list:n=>{const i=new URLSearchParams;n!=null&&n.status&&i.set("status",n.status);const d=i.toString();return ae(`/handoffs${d?`?${d}`:""}`)},get:n=>ae(`/handoffs/${n}`),create:(n,i)=>ae(`/runs/${n}/handoff`,{method:"POST",body:JSON.stringify(i)}),resume:(n,i)=>ae(`/handoffs/${n}/resume`,{method:"POST",body:JSON.stringify({humanResolution:i})})},Tt={overview:()=>ae("/admin/overview"),tenants:{list:()=>ae("/tenants"),create:n=>ae("/tenants",{method:"POST",body:JSON.stringify(n)}),get:n=>ae(`/tenants/${n}`),update:(n,i)=>ae(`/tenants/${n}`,{method:"PUT",body:JSON.stringify(i)})},users:{list:n=>{const i=new URLSearchParams;n!=null&&n.tenantId&&i.set("tenantId",n.tenantId),n!=null&&n.role&&i.set("role",n.role);const d=i.toString();return ae(`/users${d?`?${d}`:""}`)},updateRole:(n,i)=>ae(`/users/${n}`,{method:"PATCH",body:JSON.stringify({role:i})}),lock:n=>ae(`/users/${n}`,{method:"PATCH",body:JSON.stringify({isActive:!1})}),unlock:n=>ae(`/users/${n}`,{method:"PATCH",body:JSON.stringify({isActive:!0})})},system:{info:()=>ae("/admin/system-info"),dbStats:()=>ae("/admin/db-stats"),rateLimitStats:()=>ae("/admin/rate-limit-stats")},audit:{query:n=>{const i=new URLSearchParams;n!=null&&n.userId&&i.set("userId",n.userId),n!=null&&n.resourceType&&i.set("resourceType",n.resourceType),n!=null&&n.action&&i.set("action",n.action),n!=null&&n.limit&&i.set("limit",String(n.limit));const d=i.toString();return ae(`/users/audit${d?`?${d}`:""}`)},export:n=>ae(`/users/audit?limit=10000&format=${n}`)},security:{failedLogins:(n=24)=>ae(`/admin/security/failed-logins?hours=${n}`),lockedAccounts:()=>ae("/admin/security/locked-accounts"),activeSessions:()=>ae("/admin/security/active-sessions"),rateLimitViolations:(n=100)=>ae(`/admin/security/rate-violations?limit=${n}`)}},Kh={status:()=>ae("/providers/status"),test:n=>ae("/providers/test",{method:"POST",body:JSON.stringify(n)})},ys={list:()=>ae("/keys"),set:(n,i,d)=>ae("/keys",{method:"POST",body:JSON.stringify({provider:n,key:i,label:d})}),remove:n=>ae(`/keys/${n}`,{method:"DELETE"}),test:n=>ae(`/keys/test/${n}`)},ea={plan:(n,i)=>ae("/missions/plan",{method:"POST",body:JSON.stringify({objective:n,...i})}),list:()=>ae("/missions"),get:n=>ae(`/missions/${n}`),getReport:(n,i)=>ae(`/missions/${n}/report${i==="md"?"?format=md":""}`),cancel:n=>ae(`/missions/${n}/cancel`,{method:"POST"}),templates:()=>ae("/missions/templates")},qd={status:()=>ae("/messaging/status"),channels:()=>ae("/messaging/channels"),send:(n,i,d)=>ae("/messaging/send",{method:"POST",body:JSON.stringify({adapter:n,channel:i,content:d})})},ci={list:()=>ae("/agents?scheduled=true"),setSchedule:(n,i)=>ae(`/agents/${n}/schedule`,{method:"POST",body:JSON.stringify(i)}),removeSchedule:n=>ae(`/agents/${n}/schedule`,{method:"DELETE"}),pauseSchedule:n=>ae(`/agents/${n}/schedule`,{method:"POST",body:JSON.stringify({enabled:!1})}),resumeSchedule:n=>ae(`/agents/${n}/schedule`,{method:"POST",body:JSON.stringify({enabled:!0})})},Br={candidates:n=>{const i=new URLSearchParams;n!=null&&n.status&&i.set("status",n.status),n!=null&&n.limit&&i.set("limit",String(n.limit)),n!=null&&n.offset&&i.set("offset",String(n.offset));const d=i.toString();return ae(`/evolve/candidates${d?`?${d}`:""}`)},approve:n=>ae(`/evolve/candidates/${n}/approve`,{method:"POST"}),reject:n=>ae(`/evolve/candidates/${n}/reject`,{method:"POST"}),update:(n,i)=>ae(`/evolve/candidates/${n}`,{method:"PATCH",body:JSON.stringify(i)})};function xj({onMenuClick:n,showMenu:i}){const{lang:d,setLang:c,t:m}=Je(),{connected:f}=pu(),[h,b]=u.useState([]),[g,p]=u.useState(()=>localStorage.getItem("nestor_tenant_id")??"default"),[S,y]=u.useState(!1),[v,k]=u.useState(!1),C=u.useRef(null),w=u.useRef(null),N=h.find(O=>O.id===g)??null,z=u.useCallback(async()=>{try{const O=await Gh.list();b(O.data)}catch{}},[]);u.useEffect(()=>{z()},[z]),u.useEffect(()=>{const O=se=>{C.current&&!C.current.contains(se.target)&&y(!1),w.current&&!w.current.contains(se.target)&&k(!1)};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[]);const R=async O=>{try{await Gh.switch(O.id),localStorage.setItem("nestor_tenant_id",O.id),p(O.id),y(!1),window.location.reload()}catch(se){console.error("Failed to switch tenant:",se)}},D=Object.keys(Pd);return e.jsxs("header",{className:"header sticky top-0 z-20 flex h-14 items-center justify-between border-b border-border bg-[#0a0a0f]/80 px-6 backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[i&&e.jsx("button",{onClick:n,className:"p-2 hover:bg-surface-hover rounded-lg transition-colors","aria-label":"Toggle menu",children:e.jsx(Cv,{className:"h-5 w-5 text-zinc-400"})}),e.jsxs("div",{className:"relative max-w-md flex-1",children:[e.jsx(_a,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-zinc-500"}),e.jsx("input",{type:"text",placeholder:m("common.search"),className:"input pl-9 max-w-sm"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[h.length>0&&e.jsxs("div",{className:"relative hidden sm:block",ref:C,children:[e.jsxs("button",{onClick:()=>y(!S),className:"flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-1.5 text-sm transition-colors hover:border-zinc-600",children:[e.jsx(du,{className:"h-3.5 w-3.5 text-indigo-400"}),e.jsx("span",{className:"text-zinc-200 max-w-[120px] truncate",children:(N==null?void 0:N.name)??"Default"}),e.jsx(na,{className:`h-3.5 w-3.5 text-zinc-500 transition-transform ${S?"rotate-180":""}`})]}),S&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 w-56 rounded-lg border border-border bg-surface shadow-xl z-50",children:[e.jsx("div",{className:"px-3 py-2 text-[10px] font-semibold uppercase tracking-wider text-zinc-600",children:"Switch Tenant"}),e.jsx("div",{className:"max-h-64 overflow-y-auto py-1",children:h.map(O=>e.jsxs("button",{onClick:()=>R(O),className:"flex w-full items-center gap-2 px-3 py-2 text-sm text-zinc-300 transition-colors hover:bg-surface-hover",children:[O.id===g?e.jsx(bt,{className:"h-3.5 w-3.5 text-indigo-400"}):e.jsx("div",{className:"h-3.5 w-3.5"}),e.jsxs("div",{className:"flex-1 text-left",children:[e.jsx("div",{className:"font-medium",children:O.name}),e.jsx("div",{className:"text-xs text-zinc-500",children:O.slug})]})]},O.id))})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[f?e.jsx(Gv,{className:"h-4 w-4 text-green-400"}):e.jsx(qv,{className:"h-4 w-4 text-zinc-500"}),e.jsx("span",{className:`text-xs hidden sm:inline ${f?"text-green-400":"text-zinc-500"}`,children:f?"Connected":"Offline"})]}),e.jsxs("div",{className:"relative",ref:w,children:[e.jsxs("button",{onClick:()=>k(!v),className:"btn-ghost btn-sm flex items-center gap-1.5",title:"Switch language",children:[e.jsx(mu,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs uppercase",children:d}),e.jsx(na,{className:`h-3 w-3 text-zinc-500 transition-transform ${v?"rotate-180":""}`})]}),v&&e.jsx("div",{className:"absolute right-0 top-full mt-1 w-48 rounded-lg border border-border bg-surface shadow-xl z-50 max-h-80 overflow-y-auto",children:D.map(O=>e.jsxs("button",{onClick:()=>{c(O),k(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-sm text-zinc-300 transition-colors hover:bg-surface-hover",children:[O===d?e.jsx(bt,{className:"h-3.5 w-3.5 text-indigo-400"}):e.jsx("div",{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"flex-1 text-left",children:Pd[O]}),e.jsx("span",{className:"text-xs text-zinc-500 uppercase",children:O})]},O))})]})]})]})}const fj=[{to:"/",icon:Pt,labelKey:"nav.chat"},{to:"/agents",icon:Ts,labelKey:"nav.agents"},{to:"/dashboard",icon:xu,labelKey:"nav.dashboard"},{to:"/runs",icon:Nt,labelKey:"nav.history"},{to:"/settings",icon:il,labelKey:"nav.settings"}];function hj(){const{t:n}=Je();return e.jsx("nav",{className:"mobile-bottom-nav",children:fj.map(i=>{const d=i.icon;return e.jsxs(di,{to:i.to,end:i.to==="/",className:({isActive:c})=>`mobile-bottom-nav-item ${c?"active":""}`,children:[e.jsx(d,{className:"h-5 w-5"}),e.jsx("span",{className:"mobile-bottom-nav-label",children:n(i.labelKey)})]},i.to)})})}function pj(){const[n,i]=u.useState(!1),[d,c]=u.useState(!1),{isSyntheticAdmin:m}=ol();u.useEffect(()=>{const h=()=>c(window.innerWidth<769);return h(),window.addEventListener("resize",h),()=>window.removeEventListener("resize",h)},[]);const f=()=>{d&&i(!1)};return e.jsxs("div",{className:"flex min-h-screen bg-[#0a0a0f]",children:[d&&n&&e.jsx("div",{className:"sidebar-overlay",onClick:()=>i(!1)}),e.jsx("div",{className:`sidebar ${d&&n?"open":""}`,children:e.jsx(tj,{onNavigate:f})}),e.jsxs("div",{className:`flex flex-1 flex-col ${d?"":"pl-60"}`,children:[e.jsx(xj,{onMenuClick:()=>i(!n),showMenu:d}),m&&e.jsxs("div",{role:"status",className:"bg-yellow-500/20 border-b border-yellow-500/40 text-yellow-200 text-sm px-4 py-2 text-center",children:[e.jsx("strong",{children:"Local admin mode"}),' — the auth server is unreachable, so a synthetic "Admin" user was created to keep the UI usable. Sign in to the real server to leave this mode.']}),e.jsx("main",{className:`main-content flex-1 p-6 ${d?"pb-20":""}`,children:e.jsx(Cy,{})}),d&&e.jsx(hj,{})]})]})}class gj extends u.Component{constructor(){super(...arguments);Ad(this,"state",{hasError:!1,error:null});Ad(this,"handleReset",()=>{this.setState({hasError:!1,error:null})})}static getDerivedStateFromError(d){return{hasError:!0,error:d}}componentDidCatch(d,c){var m,f;console.error("[Nestor] UI Error:",d,c),(f=(m=this.props).onError)==null||f.call(m,d,c)}render(){var d;return this.state.hasError?this.props.fallback?this.props.fallback:e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] p-8",children:[e.jsx("div",{className:"text-red-500 text-xl mb-4",children:"Something went wrong"}),e.jsx("pre",{className:"bg-gray-100 dark:bg-gray-800 p-4 rounded-lg text-sm max-w-lg overflow-auto mb-4",children:(d=this.state.error)==null?void 0:d.message}),e.jsx("button",{onClick:this.handleReset,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:"Try Again"})]}):this.props.children}}function bj(){const n=Dt();return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[60vh] p-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 mb-6 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z"})})}),e.jsx("h2",{className:"text-2xl font-semibold text-gray-900 dark:text-gray-100 mb-2",children:"Page Error"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-8 max-w-md",children:"An unexpected error occurred while rendering this page. The error has been logged for investigation."}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:"Reload Page"}),e.jsx("button",{onClick:()=>n("/"),className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:"Go Home"})]})]})}const yj={node_started:{icon:Nt,color:"text-blue-400"},node_completed:{icon:et,color:"text-green-400"},node_failed:{icon:ft,color:"text-red-400"},tool_call_requested:{icon:sa,color:"text-amber-400"},tool_call_approved:{icon:et,color:"text-green-400"},tool_call_denied:{icon:Ms,color:"text-red-400"},tool_call_completed:{icon:et,color:"text-emerald-400"},approval_requested:{icon:Ms,color:"text-amber-400"},approval_resolved:{icon:et,color:"text-green-400"},budget_warning:{icon:pt,color:"text-amber-400"},budget_exceeded:{icon:us,color:"text-red-400"},run_paused:{icon:tl,color:"text-blue-400"},run_resumed:{icon:D0,color:"text-blue-400"}};function vj(n){try{return new Date(n).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return n}}function jj(n,i){switch(n){case"node_started":return`Node started: ${i.nodeId??i.label??""}`;case"node_completed":return`Node completed: ${i.nodeId??i.label??""}`;case"node_failed":return`Node failed: ${i.error??i.nodeId??""}`;case"tool_call_requested":return`Tool call: ${i.toolName??""}`;case"tool_call_approved":return`Tool approved: ${i.toolName??""}`;case"tool_call_denied":return`Tool denied: ${i.toolName??""}`;case"tool_call_completed":return`Tool completed: ${i.toolName??""}`;case"approval_requested":return`Approval required: ${i.toolName??i.action??""}`;case"approval_resolved":return`Approval resolved: ${i.decision??""}`;case"budget_warning":return`Budget warning: ${i.percent??""}% used`;case"budget_exceeded":return"Budget exceeded";case"run_paused":return"Run paused";case"run_resumed":return"Run resumed";default:return n.replace(/_/g," ")}}function gu({events:n,maxHeight:i="400px"}){return n.length===0?e.jsxs("div",{className:"flex items-center justify-center py-8 text-sm text-zinc-500",children:[e.jsx(vs,{className:"mr-2 h-4 w-4"}),"Waiting for events..."]}):e.jsx("div",{className:"overflow-y-auto",style:{maxHeight:i},children:e.jsx("div",{className:"space-y-0.5",children:[...n].reverse().map(d=>{const c=yj[d.type]??{icon:sa,color:"text-zinc-400"},m=c.icon;return e.jsxs("div",{className:"flex items-start gap-3 rounded-lg px-3 py-2 hover:bg-surface-hover transition-colors",children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 ${c.color}`,children:e.jsx(m,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm text-zinc-300 truncate",children:jj(d.type,d.data)}),d.nodeId&&e.jsxs("p",{className:"text-xs text-zinc-500 truncate",children:["Node: ",d.nodeId]})]}),e.jsx("time",{className:"flex-shrink-0 text-xs text-zinc-500",children:vj(d.timestamp)})]},d.id)})})})}function Hr({label:n,value:i,icon:d,color:c,bgColor:m}){return e.jsx("div",{className:"card",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-zinc-400",children:n}),e.jsx("p",{className:"mt-1 text-2xl font-semibold text-white",children:i})]}),e.jsx("div",{className:`flex h-11 w-11 items-center justify-center rounded-xl ${m}`,children:e.jsx(d,{className:`h-5 w-5 ${c}`})})]})})}function Nj(){const{t:n}=Je(),{events:i}=pu(),[d,c]=u.useState(null),[m,f]=u.useState("healthy"),[h,b]=u.useState(!0),[g,p]=u.useState(null),[S,y]=u.useState(0);u.useEffect(()=>{Es.stats().then(z=>{c(z.data),f("healthy"),p(null)}).catch(z=>{f("down"),p(z instanceof Error?z.message:"Failed to connect to server")}).finally(()=>{b(!1)}),Es.health().then(z=>{f(z.status==="healthy"?"healthy":"degraded")}).catch(()=>{f("down")});const N=new Date;N.setHours(0,0,0,0),In.summary({from:N.getTime()}).then(z=>{var R;y(((R=z.data)==null?void 0:R.totalCostUsd)??0)}).catch(()=>{})},[]),u.useEffect(()=>{if(i.length===0)return;Es.stats().then(z=>c(z.data)).catch(()=>{});const N=new Date;N.setHours(0,0,0,0),In.summary({from:N.getTime()}).then(z=>{var R;y(((R=z.data)==null?void 0:R.totalCostUsd)??0)}).catch(()=>{})},[i.length]);const k={healthy:{icon:et,color:"text-green-400",bg:"bg-green-500/10",label:"All systems operational"},degraded:{icon:pt,color:"text-amber-400",bg:"bg-amber-500/10",label:"Some services degraded"},down:{icon:ft,color:"text-red-400",bg:"bg-red-500/10",label:"Services unavailable"}}[m],C=k.icon,w=i.map((N,z)=>{var R;return{id:String(z),type:typeof N.data=="object"&&N.data!==null&&"kind"in N.data?N.data.kind:N.channel,data:N.data??{},timestamp:((R=N.data)==null?void 0:R.timestamp)??new Date().toISOString()}});return h?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("h1",{className:"text-2xl font-semibold text-white",children:n("dashboard.title")}),g&&e.jsxs("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 p-4 text-sm text-red-400",children:["Unable to connect to the Nestor server. Make sure the server is running.",e.jsx("span",{className:"ml-2 text-xs text-red-500/70",children:g})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(Hr,{label:n("dashboard.activeAgents"),value:(d==null?void 0:d.agents.total)??0,icon:Ts,color:"text-indigo-400",bgColor:"bg-indigo-500/10"}),e.jsx(Hr,{label:n("dashboard.runningTasks"),value:(d==null?void 0:d.runs.running)??0,icon:Nt,color:"text-emerald-400",bgColor:"bg-emerald-500/10"}),e.jsx(Hr,{label:n("dashboard.costToday"),value:`$${S.toFixed(2)}`,icon:us,color:"text-amber-400",bgColor:"bg-amber-500/10"}),e.jsx(Hr,{label:n("dashboard.skillsInstalled"),value:(d==null?void 0:d.skills.total)??0,icon:rc,color:"text-violet-400",bgColor:"bg-violet-500/10"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"card lg:col-span-2",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-medium text-zinc-200",children:n("dashboard.recentActivity")}),e.jsx(It,{className:"h-4 w-4 text-zinc-500"})]}),e.jsx(gu,{events:w,maxHeight:"300px"})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"mb-4 text-lg font-medium text-zinc-200",children:n("dashboard.quickActions")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ta,{to:"/agents",className:"btn-secondary w-full justify-start",children:[e.jsx(ht,{className:"h-4 w-4"}),n("dashboard.createAgent")]}),e.jsxs(ta,{to:"/workflows",className:"btn-secondary w-full justify-start",children:[e.jsx(tc,{className:"h-4 w-4"}),n("dashboard.runWorkflow")]}),e.jsxs(ta,{to:"/skills",className:"btn-secondary w-full justify-start",children:[e.jsx(hi,{className:"h-4 w-4"}),n("dashboard.installSkill")]})]})]}),e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"mb-4 text-lg font-medium text-zinc-200",children:n("dashboard.systemHealth")}),e.jsxs("div",{className:`flex items-center gap-3 rounded-lg p-3 ${k.bg}`,children:[e.jsx(C,{className:`h-5 w-5 ${k.color}`}),e.jsxs("div",{children:[e.jsx("p",{className:`text-sm font-medium ${k.color}`,children:k.label}),e.jsx("p",{className:"text-xs text-zinc-500",children:d?`${d.agents.total} agents | ${d.workflows.total} workflows | ${d.runs.today} runs today`:"Loading..."})]})]}),(d==null?void 0:d.server)&&e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{className:"rounded bg-[#0a0a0f] p-2",children:[e.jsx("span",{className:"text-zinc-500",children:"Version"}),e.jsx("p",{className:"text-zinc-300 font-mono",children:d.server.version})]}),e.jsxs("div",{className:"rounded bg-[#0a0a0f] p-2",children:[e.jsx("span",{className:"text-zinc-500",children:"Uptime"}),e.jsxs("p",{className:"text-zinc-300 font-mono",children:[Math.floor(d.server.uptime/3600),"h ",Math.floor(d.server.uptime%3600/60),"m"]})]}),e.jsxs("div",{className:"rounded bg-[#0a0a0f] p-2",children:[e.jsx("span",{className:"text-zinc-500",children:"Memory (RSS)"}),e.jsxs("p",{className:"text-zinc-300 font-mono",children:[d.server.memoryUsage.rss," MB"]})]}),e.jsxs("div",{className:"rounded bg-[#0a0a0f] p-2",children:[e.jsx("span",{className:"text-zinc-500",children:"WS Connections"}),e.jsx("p",{className:"text-zinc-300 font-mono",children:d.websocket.connections})]})]})]})]})]})]})}function wj(){const[n,i]=u.useState([]),[d,c]=u.useState(!0),[m,f]=u.useState(null),h=u.useCallback(async()=>{c(!0),f(null);try{const b=await la.list({limit:200});i(b.data)}catch(b){f(b instanceof Error?b.message:"Failed to fetch agents")}finally{c(!1)}},[]);return u.useEffect(()=>{h()},[h]),{agents:n,loading:d,error:m,refetch:h}}function Sj(n){const[i,d]=u.useState(null),[c,m]=u.useState(!0),[f,h]=u.useState(null),b=u.useCallback(async()=>{if(n){m(!0),h(null);try{const g=await la.get(n);d(g.data)}catch(g){h(g instanceof Error?g.message:"Failed to fetch agent")}finally{m(!1)}}},[n]);return u.useEffect(()=>{b()},[b]),{agent:i,loading:c,error:f,refetch:b}}const Vh={running:{bg:"bg-emerald-500/10",text:"text-emerald-400",dot:"bg-emerald-400"},completed:{bg:"bg-green-500/10",text:"text-green-400",dot:"bg-green-400"},failed:{bg:"bg-red-500/10",text:"text-red-400",dot:"bg-red-400"},pending:{bg:"bg-amber-500/10",text:"text-amber-400",dot:"bg-amber-400"},paused:{bg:"bg-blue-500/10",text:"text-blue-400",dot:"bg-blue-400"},cancelled:{bg:"bg-zinc-500/10",text:"text-zinc-400",dot:"bg-zinc-400"},idle:{bg:"bg-zinc-500/10",text:"text-zinc-500",dot:"bg-zinc-500"}};function wi({status:n,pulse:i}){const{t:d}=Je(),c=Vh[n]??Vh.idle;return e.jsxs("span",{className:`badge ${c.bg} ${c.text}`,children:[e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${c.dot} ${i&&n==="running"?"animate-pulse":""}`}),d(`status.${n}`)]})}const kj={builtin:{bg:"bg-indigo-500/10",text:"text-indigo-400"},official:{bg:"bg-blue-500/10",text:"text-blue-400"},trusted:{bg:"bg-emerald-500/10",text:"text-emerald-400"},community:{bg:"bg-amber-500/10",text:"text-amber-400"},local:{bg:"bg-zinc-500/10",text:"text-zinc-400"}};function bu({level:n}){const{t:i}=Je(),d=kj[n];return e.jsxs("span",{className:`badge ${d.bg} ${d.text}`,children:[n==="builtin"||n==="official"?e.jsx("svg",{className:"h-3 w-3",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M6.267 3.455a3.066 3.066 0 001.745-.723 3.066 3.066 0 013.976 0 3.066 3.066 0 001.745.723 3.066 3.066 0 012.812 2.812c.051.643.304 1.254.723 1.745a3.066 3.066 0 010 3.976 3.066 3.066 0 00-.723 1.745 3.066 3.066 0 01-2.812 2.812 3.066 3.066 0 00-1.745.723 3.066 3.066 0 01-3.976 0 3.066 3.066 0 00-1.745-.723 3.066 3.066 0 01-2.812-2.812 3.066 3.066 0 00-.723-1.745 3.066 3.066 0 010-3.976 3.066 3.066 0 00.723-1.745 3.066 3.066 0 012.812-2.812zm7.44 5.252a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}):null,i(`trust.${n}`)]})}function H0({spent:n,limit:i,currency:d="$"}){const c=i>0?Math.min(n/i*100,100):0,m=c>=75,f=c>=90,h=f?"bg-red-500":m?"bg-amber-500":"bg-indigo-500";return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-zinc-400",children:[d,n.toFixed(2)," / ",d,i.toFixed(2)]}),e.jsxs("span",{className:`font-medium ${f?"text-red-400":m?"text-amber-400":"text-zinc-400"}`,children:[c.toFixed(0),"%"]})]}),e.jsx("div",{className:"h-1.5 w-full rounded-full bg-zinc-800",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${h}`,style:{width:`${c}%`}})})]})}const zj={anthropic:Ts,openai:Ts,local:bv};function Cj({agent:n,status:i="idle",budgetSpent:d=0,budgetLimit:c=10}){const m=zj[n.adapterType]??Ts;return e.jsxs(ta,{to:`/agents/${n.id}`,className:"card group hover:border-indigo-500/30 hover:bg-surface-hover transition-all duration-200",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-indigo-500/10 text-indigo-400 group-hover:bg-indigo-500/20 transition-colors",children:e.jsx(m,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-zinc-200 group-hover:text-white transition-colors",children:n.name}),e.jsxs("p",{className:"text-xs text-zinc-500",children:[n.adapterType," ",n.adapterConfig.model?`/ ${n.adapterConfig.model}`:""]})]})]}),e.jsx(wi,{status:i,pulse:!0})]}),n.description&&e.jsx("p",{className:"mt-3 text-sm text-zinc-400 line-clamp-2",children:n.description}),e.jsx("div",{className:"mt-4 flex items-center justify-between",children:e.jsx(bu,{level:n.trustLevel})}),e.jsx("div",{className:"mt-3",children:e.jsx(H0,{spent:d,limit:c})})]})}function cn({icon:n,title:i,description:d,action:c}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-4 text-center",children:[e.jsx("div",{className:"mb-4 rounded-2xl bg-surface p-4 text-zinc-500",children:n??e.jsx(jv,{className:"h-8 w-8"})}),e.jsx("h3",{className:"text-lg font-medium text-zinc-300",children:i}),d&&e.jsx("p",{className:"mt-1.5 max-w-sm text-sm text-zinc-500",children:d}),c&&e.jsx("div",{className:"mt-4",children:c})]})}function Aj(){const{t:n}=Je(),{agents:i,loading:d,error:c,refetch:m}=wj(),[f,h]=u.useState(!1),[b,g]=u.useState(!1),[p,S]=u.useState({name:"",description:"",adapterType:"claude",model:"",trustLevel:"community"}),y=async()=>{if(p.name.trim()){g(!0);try{await la.create({name:p.name,description:p.description||void 0,adapterType:p.adapterType,adapterConfig:p.model?{model:p.model}:{},trustLevel:p.trustLevel}),h(!1),S({name:"",description:"",adapterType:"claude",model:"",trustLevel:"community"}),m()}catch(v){console.error("Failed to create agent:",v)}finally{g(!1)}}};return d?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold text-white",children:n("agents.title")}),e.jsxs("button",{onClick:()=>h(!0),className:"btn-primary",children:[e.jsx(ht,{className:"h-4 w-4"}),n("agents.create")]})]}),c&&e.jsxs("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 p-4 text-sm text-red-400",children:[c,e.jsx("button",{onClick:m,className:"ml-3 underline",children:"Retry"})]}),i.length===0&&!c?e.jsx(cn,{icon:e.jsx(Ts,{className:"h-8 w-8"}),title:n("agents.empty"),description:n("agents.emptyDesc"),action:e.jsxs("button",{onClick:()=>h(!0),className:"btn-primary",children:[e.jsx(ht,{className:"h-4 w-4"}),n("agents.create")]})}):e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:i.map(v=>e.jsx(Cj,{agent:v},v.id))}),f&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"w-full max-w-lg rounded-2xl border border-border bg-surface p-6 shadow-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsx("h2",{className:"text-lg font-semibold text-white",children:n("agents.create")}),e.jsx("button",{onClick:()=>h(!1),className:"btn-ghost btn-sm",children:e.jsx(Ze,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:n("common.name")}),e.jsx("input",{className:"input",value:p.name,onChange:v=>S({...p,name:v.target.value}),placeholder:"My Agent"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:n("common.description")}),e.jsx("textarea",{className:"input min-h-[80px] resize-none",value:p.description,onChange:v=>S({...p,description:v.target.value}),placeholder:"What does this agent do?"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Adapter"}),e.jsxs("select",{className:"input",value:p.adapterType,onChange:v=>S({...p,adapterType:v.target.value}),children:[e.jsx("option",{value:"claude",children:"Anthropic (Claude)"}),e.jsx("option",{value:"openai",children:"OpenAI (GPT)"}),e.jsx("option",{value:"gemini",children:"Google (Gemini)"}),e.jsx("option",{value:"grok",children:"xAI (Grok)"}),e.jsx("option",{value:"mistral",children:"Mistral AI"}),e.jsx("option",{value:"ollama",children:"Ollama (Local)"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Model"}),e.jsx("input",{className:"input",value:p.model,onChange:v=>S({...p,model:v.target.value}),placeholder:"claude-sonnet-4-20250514"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Trust Level"}),e.jsxs("select",{className:"input",value:p.trustLevel,onChange:v=>S({...p,trustLevel:v.target.value}),children:[e.jsx("option",{value:"builtin",children:"Built-in"}),e.jsx("option",{value:"official",children:"Official"}),e.jsx("option",{value:"trusted",children:"Trusted"}),e.jsx("option",{value:"community",children:"Community"}),e.jsx("option",{value:"local",children:"Local"})]})]})]}),e.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>h(!1),className:"btn-secondary",children:n("common.cancel")}),e.jsx("button",{onClick:y,disabled:!p.name.trim()||b,className:"btn-primary",children:n(b?"common.loading":"agents.create")})]})]})})]})}const Ej="/api";async function Tj(n){const i=localStorage.getItem("nestor_token"),d={"Content-Type":"application/json"};i&&(d.Authorization=`Bearer ${i}`);const c=localStorage.getItem("nestor_tenant_id");c&&(d["X-Tenant-ID"]=c);try{const m=await fetch(`${Ej}/agents/${n}/quality`,{headers:d});return m.ok?(await m.json()).data??null:null}catch{return null}}function Yh(n){return`${(n*100).toFixed(0)}%`}function qr({icon:n,label:i,value:d,subtext:c,color:m}){return e.jsxs("div",{className:"rounded-lg bg-zinc-800/50 p-4 border border-zinc-700/50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(n,{className:`h-4 w-4 ${m}`}),e.jsx("span",{className:"text-xs text-zinc-500 uppercase tracking-wide",children:i})]}),e.jsx("p",{className:`text-2xl font-bold ${m}`,children:d}),c&&e.jsx("p",{className:"text-xs text-zinc-500 mt-1",children:c})]})}function Rj({agentId:n}){const[i,d]=u.useState(null),[c,m]=u.useState(!0),f=u.useCallback(async()=>{m(!0);const w=await Tj(n);d(w),m(!1)},[n]);if(u.useEffect(()=>{f()},[f]),c)return e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"mb-4 text-lg font-medium text-zinc-200",children:"Quality"}),e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent"})})]});if(!i)return e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"mb-4 text-lg font-medium text-zinc-200",children:"Quality"}),e.jsx("p",{className:"text-sm text-zinc-500",children:"No quality data available yet."})]});const h=i.satisfactionRate>=.8?"text-green-400":i.satisfactionRate>=.5?"text-yellow-400":"text-red-400",b=i.successRate>=.8?"text-green-400":i.successRate>=.5?"text-yellow-400":"text-red-400",g=i.recentFeedback.filter(w=>w.rating===1).length,p=i.recentFeedback.length,S=p>0?g/p:0,y=i.satisfactionRate,v=p<3?"stable":S>y+.1?"improving":S<y-.1?"declining":"stable",k=v==="improving"?oc:v==="declining"?Bv:Av,C=v==="improving"?"text-green-400":v==="declining"?"text-red-400":"text-zinc-400";return e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-medium text-zinc-200",children:"Quality"}),e.jsxs("div",{className:`flex items-center gap-1 text-xs ${C}`,children:[e.jsx(k,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"capitalize",children:v})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[e.jsx(qr,{icon:yi,label:"Satisfaction",value:Yh(i.satisfactionRate),subtext:`${i.positiveFeedback}/${i.totalFeedback} positive`,color:h}),e.jsx(qr,{icon:et,label:"Success Rate",value:Yh(i.successRate),subtext:`${i.completedRuns} completed, ${i.failedRuns} failed`,color:b}),e.jsx(qr,{icon:us,label:"Avg Cost / Run",value:`$${i.avgCostPerRun.toFixed(4)}`,subtext:`${i.totalRuns} total runs`,color:"text-blue-400"}),e.jsx(qr,{icon:Rs,label:"Total Runs",value:i.totalRuns.toString(),subtext:`${i.totalFeedback} rated`,color:"text-indigo-400"})]}),i.recentFeedback.length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsx("h3",{className:"text-xs font-medium text-zinc-500 uppercase tracking-wide mb-2",children:"Recent Feedback"}),e.jsx("div",{className:"space-y-1 max-h-40 overflow-y-auto",children:i.recentFeedback.slice(0,10).map((w,N)=>e.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[e.jsx("span",{className:w.rating===1?"text-green-400":"text-red-400",children:w.rating===1?"+":"-"}),e.jsx("span",{className:"text-zinc-400 flex-1",children:w.comment??(w.rating===1?"Positive":"Negative")}),e.jsx("span",{className:"text-zinc-600 shrink-0",children:new Date(w.createdAt).toLocaleDateString()})]},N))})]})]})}function Mj({event:n}){switch(n.type){case"tool_start":return e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-amber-500/20 bg-amber-500/5 px-3 py-1.5",children:[e.jsx(cl,{className:"h-3.5 w-3.5 text-amber-400"}),e.jsx("span",{className:"text-xs text-amber-300 font-medium",children:n.name}),e.jsx(rt,{className:"h-3 w-3 text-amber-400 animate-spin"})]});case"tool_result":return e.jsxs("div",{className:`flex items-center gap-2 rounded-md border px-3 py-1.5 ${n.success?"border-emerald-500/20 bg-emerald-500/5":"border-red-500/20 bg-red-500/5"}`,children:[n.success?e.jsx(et,{className:"h-3.5 w-3.5 text-emerald-400"}):e.jsx(ft,{className:"h-3.5 w-3.5 text-red-400"}),e.jsxs("span",{className:`text-xs font-medium ${n.success?"text-emerald-300":"text-red-300"}`,children:[n.name," ",n.success?"completed":"failed"]})]});case"reasoning":return e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-yellow-500/20 bg-yellow-500/5 px-3 py-1.5",children:[e.jsx(Zd,{className:"h-3.5 w-3.5 text-yellow-400 mt-0.5 shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[n.phase&&e.jsx("span",{className:"text-[10px] uppercase text-yellow-600 font-mono",children:n.phase}),e.jsx("p",{className:"text-xs text-yellow-200/80 break-words",children:n.reasoning}),n.confidence!=null&&e.jsxs("span",{className:"text-[10px] text-yellow-600",children:["confidence: ",(n.confidence*100).toFixed(0),"%"]})]})]});case"error":return e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-red-500/20 bg-red-500/5 px-3 py-1.5",children:[e.jsx(ft,{className:"h-3.5 w-3.5 text-red-400"}),e.jsx("span",{className:"text-xs text-red-300",children:n.text})]});default:return null}}function Dj({runId:n,onComplete:i}){const[d,c]=u.useState(""),[m,f]=u.useState([]),[h,b]=u.useState(!0),g=u.useRef(null),p=u.useRef(0),{subscribe:S,unsubscribe:y,events:v,connected:k}=pu([`run:${n}`]);return u.useEffect(()=>(k&&S(`run:${n}`),()=>{y(`run:${n}`)}),[k,n,S,y]),u.useEffect(()=>{for(const C of v){if(C.channel!==`run:${n}`)continue;const w=C.data;if(!w||w.runId!==n)continue;const N=w.type,z=++p.current;switch(N){case"token":c(R=>R+(w.text??""));break;case"tool_start":f(R=>[...R,{id:z,type:"tool_start",name:w.name,args:w.args,timestamp:Date.now()}]);break;case"tool_result":f(R=>[...R,{id:z,type:"tool_result",name:w.name,result:w.result,success:w.success,timestamp:Date.now()}]);break;case"reasoning":{const R=w.entry;f(D=>[...D,{id:z,type:"reasoning",reasoning:(R==null?void 0:R.reasoning)??w.reasoning??"",phase:(R==null?void 0:R.phase)??void 0,confidence:(R==null?void 0:R.confidence)??void 0,timestamp:Date.now()}]);break}case"error":f(R=>[...R,{id:z,type:"error",text:w.message,timestamp:Date.now()}]);break;case"done":b(!1),i==null||i();break}}},[v,n,i]),u.useEffect(()=>{g.current&&(g.current.scrollTop=g.current.scrollHeight)},[d]),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M0,{className:`h-3.5 w-3.5 ${h?"text-green-400 animate-pulse":"text-zinc-500"}`}),e.jsx("span",{className:"text-xs font-medium text-zinc-400",children:h?"Live Output":"Run Completed"}),!k&&e.jsx("span",{className:"text-[10px] text-red-400 ml-auto",children:"Disconnected"})]}),e.jsx("div",{ref:g,className:"bg-gray-900 p-4 rounded-lg max-h-96 overflow-y-auto whitespace-pre-wrap font-mono text-sm text-zinc-200 border border-zinc-700",children:d||e.jsx("span",{className:"text-zinc-500 italic",children:h?"Waiting for output...":"No output produced."})}),m.length>0&&e.jsx("div",{className:"space-y-2 max-h-60 overflow-y-auto",children:m.map(C=>e.jsx(Mj,{event:C},C.id))})]})}function Oj(){const{id:n}=ll(),i=Dt(),{t:d}=Je(),{agent:c,loading:m,error:f}=Sj(n),[h,b]=u.useState("overview"),[g,p]=u.useState(""),[S,y]=u.useState(!1),[v,k]=u.useState(null);if(m)return e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent"})});if(f||!c)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-20",children:[e.jsx("p",{className:"text-red-400",children:f??"Agent not found"}),e.jsxs("button",{onClick:()=>i("/agents"),className:"btn-secondary mt-4",children:[e.jsx(Wn,{className:"h-4 w-4"})," Back to Agents"]})]});const C=async()=>{var z;if(!(!g.trim()||!n)){y(!0);try{const R=await la.run(n,g),D=((z=R==null?void 0:R.data)==null?void 0:z.id)??null;k(D),p("")}catch(R){console.error("Run failed:",R)}finally{y(!1)}}},w=async()=>{if(n&&window.confirm(`Delete agent "${c.name}"?`))try{await la.delete(n),i("/agents")}catch(z){console.error("Delete failed:",z)}},N=[{key:"overview",label:d("agent.overview"),icon:Rs},{key:"quality",label:"Quality",icon:It},{key:"runs",label:d("agent.runs"),icon:Nt},{key:"events",label:d("agent.events"),icon:It},{key:"configuration",label:d("agent.configuration"),icon:il}];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>i("/agents"),className:"btn-ghost btn-sm",children:e.jsx(Wn,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-xl bg-indigo-500/10 text-indigo-400",children:e.jsx(Ts,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-semibold text-white",children:c.name}),e.jsx(wi,{status:"idle"})]}),e.jsxs("p",{className:"text-sm text-zinc-400",children:[c.adapterType,c.adapterConfig.model?` / ${c.adapterConfig.model}`:"",e.jsx("span",{className:"mx-2 text-zinc-600",children:"|"}),e.jsx(bu,{level:c.trustLevel})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{className:"btn-secondary btn-sm",children:[e.jsx(Nt,{className:"h-3.5 w-3.5"})," ",d("agent.start")]}),e.jsxs("button",{className:"btn-secondary btn-sm",children:[e.jsx(Lv,{className:"h-3.5 w-3.5"})," ",d("agent.stop")]}),e.jsxs("button",{onClick:w,className:"btn-danger btn-sm",children:[e.jsx(Ot,{className:"h-3.5 w-3.5"})," ",d("agent.delete")]})]})]}),e.jsx("div",{className:"card",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(O0,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-zinc-500"}),e.jsx("input",{className:"input pl-9",placeholder:"Enter a prompt to run this agent...",value:g,onChange:z=>p(z.target.value),onKeyDown:z=>z.key==="Enter"&&C()})]}),e.jsxs("button",{onClick:C,disabled:!g.trim()||S,className:"btn-primary",children:[e.jsx(Nt,{className:"h-4 w-4"}),d(S?"common.loading":"agent.run")]})]})}),v&&e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M0,{className:"h-4 w-4 text-green-400 animate-pulse"}),e.jsx("h3",{className:"text-sm font-medium text-zinc-200",children:"Live Output"}),e.jsxs("span",{className:"text-[10px] font-mono text-zinc-500",children:[v.slice(0,12),"..."]})]}),e.jsx("button",{onClick:()=>k(null),className:"text-xs text-zinc-500 hover:text-zinc-300 transition-colors",children:"Dismiss"})]}),e.jsx(Dj,{runId:v,onComplete:()=>{}})]}),e.jsx("div",{className:"flex gap-1 border-b border-border",children:N.map(({key:z,label:R,icon:D})=>e.jsxs("button",{onClick:()=>b(z),className:`flex items-center gap-2 px-4 py-2.5 text-sm font-medium transition-colors border-b-2 ${h===z?"border-indigo-500 text-indigo-400":"border-transparent text-zinc-400 hover:text-zinc-200"}`,children:[e.jsx(D,{className:"h-4 w-4"}),R]},z))}),h==="quality"&&n&&e.jsx(Rj,{agentId:n}),h==="overview"&&e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[e.jsxs("div",{className:"card",children:[e.jsx("h3",{className:"mb-4 text-lg font-medium text-zinc-200",children:d("agent.budget")}),e.jsx(H0,{spent:0,limit:10}),e.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"rounded-lg bg-[#0a0a0f] p-3",children:[e.jsx("p",{className:"text-xs text-zinc-500",children:"Total Spent"}),e.jsx("p",{className:"text-lg font-semibold text-white",children:"$0.00"})]}),e.jsxs("div",{className:"rounded-lg bg-[#0a0a0f] p-3",children:[e.jsx("p",{className:"text-xs text-zinc-500",children:"Runs Today"}),e.jsx("p",{className:"text-lg font-semibold text-white",children:"0"})]})]})]}),e.jsxs("div",{className:"card",children:[e.jsx("h3",{className:"mb-4 text-lg font-medium text-zinc-200",children:d("agent.recentRuns")}),e.jsx("p",{className:"text-sm text-zinc-500",children:"No runs recorded yet."})]}),c.description&&e.jsxs("div",{className:"card lg:col-span-2",children:[e.jsx("h3",{className:"mb-2 text-lg font-medium text-zinc-200",children:d("common.description")}),e.jsx("p",{className:"text-sm text-zinc-400",children:c.description})]})]}),h==="runs"&&e.jsx("div",{className:"card",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border text-left",children:[e.jsx("th",{className:"pb-3 pr-4 text-zinc-400 font-medium",children:"Run ID"}),e.jsx("th",{className:"pb-3 pr-4 text-zinc-400 font-medium",children:d("common.status")}),e.jsx("th",{className:"pb-3 pr-4 text-zinc-400 font-medium",children:d("run.duration")}),e.jsx("th",{className:"pb-3 pr-4 text-zinc-400 font-medium",children:"Cost"}),e.jsx("th",{className:"pb-3 text-zinc-400 font-medium",children:d("common.created")})]})}),e.jsx("tbody",{children:e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"py-8 text-center text-zinc-500",children:"No runs recorded for this agent."})})})]})})}),h==="events"&&e.jsx("div",{className:"card",children:e.jsx(gu,{events:[],maxHeight:"500px"})}),h==="configuration"&&e.jsxs("div",{className:"card",children:[e.jsx("h3",{className:"mb-4 text-lg font-medium text-zinc-200",children:"Agent Configuration"}),e.jsx("pre",{className:"overflow-auto rounded-lg bg-[#0a0a0f] p-4 text-sm text-zinc-300",children:JSON.stringify(c,null,2)})]})]})}function Lj(){const[n,i]=u.useState([]),[d,c]=u.useState(!0),[m,f]=u.useState(null),h=u.useCallback(async()=>{c(!0),f(null);try{const b=await sc.list({limit:200});i(b.data)}catch(b){f(b instanceof Error?b.message:"Failed to fetch workflows")}finally{c(!1)}},[]);return u.useEffect(()=>{h()},[h]),{workflows:n,loading:d,error:m,refetch:h}}function _j(n){const[i,d]=u.useState(null),[c,m]=u.useState(!0),[f,h]=u.useState(null),b=u.useCallback(async()=>{if(n){m(!0),h(null);try{const g=await sc.get(n);d(g.data)}catch(g){h(g instanceof Error?g.message:"Failed to fetch workflow")}finally{m(!1)}}},[n]);return u.useEffect(()=>{b()},[b]),{workflow:i,loading:c,error:f,refetch:b}}const Uj=[{id:"tdd-loop",name:"TDD Loop",description:"spec → code → test → fix → repeat",icon:e.jsx(xt,{className:"h-5 w-5"}),color:"text-green-400 bg-green-500/10",entryNodeId:"spec",nodes:[{id:"spec",type:"agent",label:"Write Spec",config:{role:"spec-writer",prompt:"Write a detailed specification for the feature"},next:["code"]},{id:"code",type:"agent",label:"Implement Code",config:{role:"developer",prompt:"Implement the code based on the specification"},next:["test"]},{id:"test",type:"agent",label:"Run Tests",config:{role:"tester",prompt:"Write and run tests against the implementation"},next:["check"]},{id:"check",type:"condition",label:"Tests Pass?",config:{},condition:"result.allPassed === true",next:["done","fix"]},{id:"fix",type:"agent",label:"Fix Issues",config:{role:"developer",prompt:"Fix the failing tests based on error output"},next:["test"]},{id:"done",type:"agent",label:"Complete",config:{role:"reporter",prompt:"Generate a summary of the implementation and test results"},next:[]}]},{id:"content-pipeline",name:"Content Pipeline",description:"research → draft → review → publish",icon:e.jsx(Ua,{className:"h-5 w-5"}),color:"text-amber-400 bg-amber-500/10",entryNodeId:"research",nodes:[{id:"research",type:"agent",label:"Research",config:{role:"researcher",prompt:"Research the topic and gather relevant sources and data"},next:["draft"]},{id:"draft",type:"agent",label:"Draft",config:{role:"writer",prompt:"Write a draft based on the research findings"},next:["review"]},{id:"review",type:"agent",label:"Review",config:{role:"editor",prompt:"Review the draft for accuracy, style, and completeness"},next:["publish"]},{id:"publish",type:"agent",label:"Publish",config:{role:"publisher",prompt:"Format and prepare the final content for publication"},next:[]}]},{id:"ralph-3phase",name:"Ralph 3-Phase",description:"spec-writer → planner → builder (with backpressure)",icon:e.jsx(wv,{className:"h-5 w-5"}),color:"text-purple-400 bg-purple-500/10",entryNodeId:"spec-writer",nodes:[{id:"spec-writer",type:"agent",label:"Spec Writer",config:{role:"spec-writer",prompt:"Analyze requirements and produce a detailed technical specification",backpressure:{validator:"spec",strictness:"strict"}},next:["planner"]},{id:"planner",type:"agent",label:"Planner",config:{role:"planner",prompt:"Break the specification into an ordered plan of implementation tasks",backpressure:{validator:"plan",strictness:"strict"}},next:["builder"]},{id:"builder",type:"agent",label:"Builder",config:{role:"builder",prompt:"Execute each task from the plan, implementing the specification",backpressure:{validator:"code",strictness:"normal"}},next:[]}]}];function $j(){const{t:n}=Je(),{workflows:i,loading:d,error:c,refetch:m}=Lj(),[f,h]=u.useState(!1),[b,g]=u.useState(!1),[p,S]=u.useState({name:"",description:""}),[y,v]=u.useState(null),[k,C]=u.useState(null),[w,N]=u.useState([]),[z,R]=u.useState(null),D=u.useRef(null),O=u.useCallback(async A=>{C(A),N([]),R(null);try{const $=(await sc.run(A)).data.id,Q=localStorage.getItem("nestor_token"),ce=localStorage.getItem("nestor_tenant_id"),I=new URLSearchParams;I.set("channels",`run:${$}`),Q&&I.set("token",Q),ce&&I.set("tenantId",ce);const le=new EventSource(`/api/events/stream?${I.toString()}`);D.current=le,le.onmessage=Y=>{var B;try{const ne=JSON.parse(Y.data);(ne.type==="run:progress"||ne.type==="node:start"||ne.type==="node:complete")&&N(me=>{var ue,je;return[...me,((ue=ne.data)==null?void 0:ue.message)||((je=ne.data)==null?void 0:je.node)||ne.type]}),(ne.type==="run:complete"||ne.type==="run:completed")&&(R({id:A,status:"completed",message:"Workflow completed successfully"}),le.close(),C(null),m()),(ne.type==="run:failed"||ne.type==="run:error")&&(R({id:A,status:"failed",message:((B=ne.data)==null?void 0:B.error)||"Workflow failed"}),le.close(),C(null))}catch{}},le.onerror=()=>{le.close(),setTimeout(()=>{C(null),z||R({id:A,status:"completed",message:"Run started (stream ended)"}),m()},2e3)}}catch(F){R({id:A,status:"failed",message:F instanceof Error?F.message:"Failed to start"}),C(null)}},[m,z]),se=A=>{v(A),S({name:A.name,description:A.description})},Z=()=>{v(null),S({name:"",description:""})},U=async()=>{if(p.name.trim()){g(!0);try{const A=y?y.nodes:[{id:"start",type:"agent",label:"Start",config:{},next:[]}],F=y?y.entryNodeId:"start";await sc.create({name:p.name,description:p.description||void 0,nodes:A,entryNodeId:F}),h(!1),S({name:"",description:""}),v(null),m()}catch(A){console.error("Failed to create workflow:",A)}finally{g(!1)}}};return d?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold text-white",children:n("workflows.title")}),e.jsxs("button",{onClick:()=>h(!0),className:"btn-primary",children:[e.jsx(ht,{className:"h-4 w-4"}),n("workflows.create")]})]}),c&&e.jsxs("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 p-4 text-sm text-red-400",children:[c,e.jsx("button",{onClick:m,className:"ml-3 underline",children:"Retry"})]}),i.length===0&&!c?e.jsx(cn,{icon:e.jsx(tc,{className:"h-8 w-8"}),title:n("workflows.empty"),description:n("workflows.emptyDesc"),action:e.jsxs("button",{onClick:()=>h(!0),className:"btn-primary",children:[e.jsx(ht,{className:"h-4 w-4"}),n("workflows.create")]})}):e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:i.map(A=>e.jsxs("div",{className:"card group hover:border-indigo-500/30 transition-colors",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-blue-500/10 text-blue-400",children:e.jsx(tc,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-zinc-200",children:A.name}),e.jsxs("p",{className:"text-xs text-zinc-500",children:["v",A.currentVersion]})]})]}),e.jsx(wi,{status:"idle"})]}),A.description&&e.jsx("p",{className:"mt-3 text-sm text-zinc-400 line-clamp-2",children:A.description}),k===A.id&&w.length>0&&e.jsxs("div",{className:"mt-3 rounded-md bg-purple-500/5 border border-purple-500/10 p-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(rt,{className:"h-3 w-3 animate-spin text-purple-400"}),e.jsx("span",{className:"text-xs font-medium text-purple-300",children:n("workflows.running")})]}),e.jsx("div",{className:"max-h-16 overflow-y-auto",children:w.slice(-3).map((F,$)=>e.jsx("p",{className:"text-[11px] text-zinc-400 truncate",children:F},$))})]}),z&&z.id===A.id&&e.jsxs("div",{className:`mt-3 flex items-center gap-2 rounded-md p-2 text-xs ${z.status==="completed"?"bg-green-500/5 border border-green-500/10 text-green-400":"bg-red-500/5 border border-red-500/10 text-red-400"}`,children:[z.status==="completed"?e.jsx(et,{className:"h-3.5 w-3.5 flex-shrink-0"}):e.jsx(ft,{className:"h-3.5 w-3.5 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:z.message}),e.jsx("button",{onClick:()=>R(null),className:"ml-auto flex-shrink-0 text-zinc-500 hover:text-zinc-300",children:e.jsx(Ze,{className:"h-3 w-3"})})]}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-zinc-500",children:[n("common.updated"),": ",new Date(A.updatedAt).toLocaleDateString()]}),e.jsxs("div",{className:"flex gap-1.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(ta,{to:`/workflows/${A.id}/edit`,className:"btn-ghost btn-sm",children:e.jsx(pi,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>O(A.id),disabled:k!==null,className:"btn-ghost btn-sm text-green-400 disabled:opacity-50",title:n("workflows.run"),children:k===A.id?e.jsx(rt,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Nt,{className:"h-3.5 w-3.5"})})]})]})]},A.id))}),f&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"w-full max-w-2xl rounded-2xl border border-border bg-surface p-6 shadow-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsx("h2",{className:"text-lg font-semibold text-white",children:n("workflows.create")}),e.jsx("button",{onClick:()=>{h(!1),Z()},className:"btn-ghost btn-sm",children:e.jsx(Ze,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"mb-5",children:[e.jsx("p",{className:"text-xs font-medium text-zinc-500 uppercase tracking-wider mb-3",children:"Start from a template"}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:Uj.map(A=>e.jsxs("button",{onClick:()=>se(A),className:`group text-left rounded-xl border p-3 transition-all ${(y==null?void 0:y.id)===A.id?"border-indigo-500/50 bg-indigo-500/10 ring-1 ring-indigo-500/30":"border-border/50 bg-zinc-900/60 hover:border-indigo-500/30 hover:bg-indigo-500/5"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx("span",{className:`flex h-7 w-7 items-center justify-center rounded-lg ${A.color}`,children:A.icon}),e.jsx("span",{className:"text-sm font-medium text-zinc-200",children:A.name})]}),e.jsx("p",{className:"text-[11px] text-zinc-500 leading-relaxed",children:A.description}),e.jsxs("p",{className:"text-[10px] text-zinc-600 mt-1.5",children:[A.nodes.length," nodes"]})]},A.id))}),y&&e.jsx("button",{onClick:Z,className:"mt-2 text-xs text-zinc-500 hover:text-zinc-300 underline",children:"Clear template selection"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:n("common.name")}),e.jsx("input",{className:"input",value:p.name,onChange:A=>S({...p,name:A.target.value}),placeholder:"My Workflow"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:n("common.description")}),e.jsx("textarea",{className:"input min-h-[80px] resize-none",value:p.description,onChange:A=>S({...p,description:A.target.value}),placeholder:"What does this workflow do?"})]})]}),e.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>{h(!1),Z()},className:"btn-secondary",children:n("common.cancel")}),e.jsx("button",{onClick:U,disabled:!p.name.trim()||b,className:"btn-primary",children:n(b?"common.loading":"workflows.create")})]})]})})]})}const Xh={agent:"border-indigo-500 bg-indigo-500/10",tool:"border-emerald-500 bg-emerald-500/10",condition:"border-amber-500 bg-amber-500/10",parallel:"border-blue-500 bg-blue-500/10",loop:"border-violet-500 bg-violet-500/10",human:"border-rose-500 bg-rose-500/10"},Gr={agent:"Agent",tool:"Tool",condition:"Condition",parallel:"Parallel",loop:"Loop",human:"Human"};function Bj(n,i){var g;const d=new Map;if(n.length===0)return d;const c=new Set,m=[],f=new Map,h=i??((g=n[0])==null?void 0:g.id);for(h&&m.push({id:h,depth:0,index:0});m.length>0;){const{id:p,depth:S}=m.shift();if(c.has(p))continue;c.add(p);const y=f.get(S)??0;f.set(S,y+1),d.set(p,{x:80+y*220,y:60+S*120});const v=n.find(k=>k.id===p);if(v)for(const k of v.next)c.has(k)||m.push({id:k,depth:S+1,index:0})}let b=(f.get(0)??0)*220+80;for(const p of n)c.has(p.id)||(d.set(p.id,{x:b,y:60}),b+=220);return d}function Hj(){const{id:n}=ll(),i=Dt(),{t:d}=Je(),{workflow:c,loading:m,error:f}=_j(n),[h,b]=u.useState([]),[g,p]=u.useState(),[S,y]=u.useState(null),[v,k]=u.useState(!1),[C,w]=u.useState({label:"",type:"agent"});u.useEffect(()=>{c!=null&&c.nodes&&(b(c.nodes),p(c.entryNodeId))},[c]);const N=u.useMemo(()=>Bj(h,g),[h,g]),z=Math.max(800,...Array.from(N.values()).map(U=>U.x+200)),R=Math.max(400,...Array.from(N.values()).map(U=>U.y+100)),D=u.useMemo(()=>{const U=[];for(const A of h){const F=N.get(A.id);if(F)for(const $ of A.next){const Q=N.get($);Q&&U.push({from:F,to:Q,fromId:A.id,toId:$})}}return U},[h,N]),O=u.useCallback(()=>{if(!C.label.trim())return;const U=`node_${Date.now()}`;b(A=>[...A,{id:U,type:C.type,label:C.label,config:{},next:[]}]),h.length===0&&p(U),w({label:"",type:"agent"}),k(!1)},[C,h.length]),se=u.useCallback(U=>{var A;b(F=>F.filter(Q=>Q.id!==U).map(Q=>({...Q,next:Q.next.filter(ce=>ce!==U)}))),S===U&&y(null),g===U&&p((A=h.find(F=>F.id!==U))==null?void 0:A.id)},[S,g,h]),Z=h.find(U=>U.id===S);return m?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent"})}):f?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20",children:[e.jsx("p",{className:"text-red-400",children:f}),e.jsxs("button",{onClick:()=>i("/workflows"),className:"btn-secondary mt-4",children:[e.jsx(Wn,{className:"h-4 w-4"})," Back to Workflows"]})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>i("/workflows"),className:"btn-ghost btn-sm",children:e.jsx(Wn,{className:"h-4 w-4"})}),e.jsx("h1",{className:"text-2xl font-semibold text-white",children:(c==null?void 0:c.name)??d("workflow.editor")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>k(!0),className:"btn-secondary btn-sm",children:[e.jsx(ht,{className:"h-3.5 w-3.5"})," ",d("workflow.addNode")]}),e.jsxs("button",{className:"btn-secondary btn-sm",children:[e.jsx(cc,{className:"h-3.5 w-3.5"})," ",d("workflow.save")]}),e.jsxs("button",{className:"btn-primary btn-sm",children:[e.jsx(Nt,{className:"h-3.5 w-3.5"})," ",d("workflow.run")]})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"card flex-1 overflow-auto p-0",style:{minHeight:"500px"},children:[e.jsxs("svg",{width:z,height:R,className:"w-full",children:[D.map((U,A)=>{const F=U.from.x+80,$=U.from.y+40,Q=U.to.x+80,ce=U.to.y,I=($+ce)/2;return e.jsx("path",{d:`M ${F} ${$} C ${F} ${I}, ${Q} ${I}, ${Q} ${ce}`,fill:"none",stroke:"#2a2a35",strokeWidth:"2",markerEnd:"url(#arrowhead)"},A)}),e.jsx("defs",{children:e.jsx("marker",{id:"arrowhead",markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto",children:e.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:"#2a2a35"})})})]}),e.jsx("div",{className:"absolute inset-0",style:{width:z,height:R},children:h.map(U=>{const A=N.get(U.id);if(!A)return null;const F=U.id===g,$=U.id===S;return e.jsxs("div",{className:`absolute cursor-pointer rounded-lg border-2 px-4 py-2.5 text-sm transition-all ${Xh[U.type]} ${$?"ring-2 ring-indigo-500 ring-offset-2 ring-offset-[#0a0a0f]":""} ${F?"shadow-lg":""}`,style:{left:A.x,top:A.y,width:160},onClick:()=>y(U.id),children:[e.jsx("div",{className:"font-medium text-zinc-200 truncate",children:U.label}),e.jsx("div",{className:"text-xs text-zinc-500 mt-0.5",children:Gr[U.type]}),F&&e.jsx("div",{className:"absolute -top-2 -right-2 h-4 w-4 rounded-full bg-indigo-500 border-2 border-[#0a0a0f]"})]},U.id)})}),h.length===0&&e.jsx("div",{className:"flex items-center justify-center h-full text-zinc-500 text-sm",children:"Add nodes to build your workflow DAG"})]}),Z&&e.jsxs("div",{className:"w-72 card space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-medium text-zinc-200",children:"Node Properties"}),e.jsx("button",{onClick:()=>y(null),className:"btn-ghost btn-sm",children:e.jsx(Ze,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Label"}),e.jsx("input",{className:"input",value:Z.label,onChange:U=>b(A=>A.map(F=>F.id===Z.id?{...F,label:U.target.value}:F))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:d("common.type")}),e.jsx("select",{className:"input",value:Z.type,onChange:U=>b(A=>A.map(F=>F.id===Z.id?{...F,type:U.target.value}:F)),children:Object.entries(Gr).map(([U,A])=>e.jsx("option",{value:U,children:A},U))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Agent ID"}),e.jsx("input",{className:"input",value:Z.agentId??"",onChange:U=>b(A=>A.map(F=>F.id===Z.id?{...F,agentId:U.target.value||void 0}:F)),placeholder:"Optional agent ID"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Connect to"}),e.jsxs("select",{className:"input",value:"",onChange:U=>{U.target.value&&b(A=>A.map(F=>F.id===Z.id&&!F.next.includes(U.target.value)?{...F,next:[...F.next,U.target.value]}:F))},children:[e.jsx("option",{value:"",children:"Select a node..."}),h.filter(U=>U.id!==Z.id&&!Z.next.includes(U.id)).map(U=>e.jsx("option",{value:U.id,children:U.label},U.id))]}),Z.next.length>0&&e.jsx("div",{className:"mt-2 space-y-1",children:Z.next.map(U=>{const A=h.find(F=>F.id===U);return e.jsxs("div",{className:"flex items-center justify-between rounded bg-[#0a0a0f] px-2 py-1 text-xs",children:[e.jsx("span",{className:"text-zinc-400",children:(A==null?void 0:A.label)??U}),e.jsx("button",{onClick:()=>b(F=>F.map($=>$.id===Z.id?{...$,next:$.next.filter(Q=>Q!==U)}:$)),className:"text-zinc-500 hover:text-red-400",children:e.jsx(Ze,{className:"h-3 w-3"})})]},U)})})]}),e.jsxs("button",{onClick:()=>se(Z.id),className:"btn-danger w-full",children:[e.jsx(Ot,{className:"h-3.5 w-3.5"}),"Delete Node"]})]})]}),v&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-border bg-surface p-6 shadow-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsx("h2",{className:"text-lg font-semibold text-white",children:d("workflow.addNode")}),e.jsx("button",{onClick:()=>k(!1),className:"btn-ghost btn-sm",children:e.jsx(Ze,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Label"}),e.jsx("input",{className:"input",value:C.label,onChange:U=>w({...C,label:U.target.value}),placeholder:"Node label"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:d("common.type")}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:Object.keys(Gr).map(U=>e.jsx("button",{onClick:()=>w({...C,type:U}),className:`rounded-lg border-2 p-2.5 text-center text-xs font-medium transition-colors ${C.type===U?Xh[U]:"border-border text-zinc-400 hover:border-zinc-600"}`,children:Gr[U]},U))})]})]}),e.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>k(!1),className:"btn-secondary",children:d("common.cancel")}),e.jsx("button",{onClick:O,disabled:!C.label.trim(),className:"btn-primary",children:d("workflow.addNode")})]})]})})]})}function qj(){const[n,i]=u.useState([]),[d,c]=u.useState(!0),[m,f]=u.useState(null),h=u.useCallback(async()=>{c(!0),f(null);try{const b=await Wr.list({limit:200});i(b.data)}catch(b){f(b instanceof Error?b.message:"Failed to fetch skills")}finally{c(!1)}},[]);return u.useEffect(()=>{h()},[h]),{skills:n,loading:d,error:m,refetch:h}}function Gj({skill:n,onDelete:i}){return e.jsxs("div",{className:"card group hover:border-indigo-500/30 transition-colors",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-violet-500/10 text-violet-400",children:e.jsx(rc,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-zinc-200",children:n.name}),e.jsxs("p",{className:"text-xs text-zinc-500",children:["v",n.version," by ",n.author]})]})]}),e.jsx(bu,{level:n.trustLevel})]}),n.description&&e.jsx("p",{className:"mt-3 text-sm text-zinc-400 line-clamp-2",children:n.description}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[n.tags.slice(0,3).map(d=>e.jsx("span",{className:"rounded-md bg-zinc-800 px-2 py-0.5 text-xs text-zinc-400",children:d},d)),n.tags.length>3&&e.jsxs("span",{className:"text-xs text-zinc-500",children:["+",n.tags.length-3]})]}),i&&e.jsx("button",{onClick:d=>{d.preventDefault(),i(n.id)},className:"btn-ghost btn-sm text-zinc-500 hover:text-red-400 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Ot,{className:"h-3.5 w-3.5"})})]})]})}function Kj(){const{t:n}=Je(),{skills:i,loading:d,error:c,refetch:m}=qj(),[f,h]=u.useState(!1),[b,g]=u.useState(!1),[p,S]=u.useState(""),[y,v]=u.useState({source:"",type:"local",name:"",trustLevel:"community"}),[k,C]=u.useState(null),w=async()=>{if(y.source.trim()){g(!0);try{await Wr.install({source:y.source,type:y.type,name:y.name||void 0,trustLevel:y.trustLevel}),h(!1),v({source:"",type:"local",name:"",trustLevel:"community"}),m()}catch(D){console.error("Failed to install skill:",D)}finally{g(!1)}}},N=async D=>{if(window.confirm("Remove this skill?"))try{await Wr.delete(D),m()}catch(O){console.error("Failed to delete skill:",O)}},z=async()=>{if(y.source.trim())try{const D=await Wr.scan(y.source);C(D)}catch(D){console.error("Scan failed:",D)}},R=i.filter(D=>!p||D.name.toLowerCase().includes(p.toLowerCase())||D.description.toLowerCase().includes(p.toLowerCase())||D.tags.some(O=>O.toLowerCase().includes(p.toLowerCase())));return d?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold text-white",children:n("skills.title")}),e.jsxs("button",{onClick:()=>h(!0),className:"btn-primary",children:[e.jsx(ht,{className:"h-4 w-4"}),n("skills.install")]})]}),i.length>0&&e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(_a,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-zinc-500"}),e.jsx("input",{type:"text",className:"input pl-9",placeholder:n("common.search"),value:p,onChange:D=>S(D.target.value)})]}),c&&e.jsxs("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 p-4 text-sm text-red-400",children:[c,e.jsx("button",{onClick:m,className:"ml-3 underline",children:"Retry"})]}),i.length===0&&!c?e.jsx(cn,{icon:e.jsx(rc,{className:"h-8 w-8"}),title:n("skills.empty"),description:n("skills.emptyDesc"),action:e.jsxs("button",{onClick:()=>h(!0),className:"btn-primary",children:[e.jsx(ht,{className:"h-4 w-4"}),n("skills.install")]})}):R.length===0?e.jsx("div",{className:"py-8 text-center text-sm text-zinc-500",children:n("common.noResults")}):e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:R.map(D=>e.jsx(Gj,{skill:D,onDelete:N},D.id))}),f&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"w-full max-w-lg rounded-2xl border border-border bg-surface p-6 shadow-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsx("h2",{className:"text-lg font-semibold text-white",children:n("skills.install")}),e.jsx("button",{onClick:()=>{h(!1),C(null)},className:"btn-ghost btn-sm",children:e.jsx(Ze,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:n("skills.source")}),e.jsx("input",{className:"input",value:y.source,onChange:D=>v({...y,source:D.target.value}),placeholder:"/path/to/skill or https://..."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:n("common.type")}),e.jsxs("select",{className:"input",value:y.type,onChange:D=>v({...y,type:D.target.value}),children:[e.jsx("option",{value:"local",children:"Local"}),e.jsx("option",{value:"npm",children:"NPM"}),e.jsx("option",{value:"git",children:"Git"}),e.jsx("option",{value:"url",children:"URL"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"label",children:[n("common.name")," (optional)"]}),e.jsx("input",{className:"input",value:y.name,onChange:D=>v({...y,name:D.target.value}),placeholder:"my-skill"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Trust Level"}),e.jsxs("select",{className:"input",value:y.trustLevel,onChange:D=>v({...y,trustLevel:D.target.value}),children:[e.jsx("option",{value:"builtin",children:"Built-in"}),e.jsx("option",{value:"official",children:"Official"}),e.jsx("option",{value:"trusted",children:"Trusted"}),e.jsx("option",{value:"community",children:"Community"}),e.jsx("option",{value:"local",children:"Local"})]})]}),k&&e.jsxs("div",{className:"rounded-lg bg-[#0a0a0f] p-4",children:[e.jsx("h4",{className:"text-sm font-medium text-zinc-300 mb-2",children:"Scan Results"}),e.jsx("pre",{className:"text-xs text-zinc-400 overflow-auto max-h-40",children:JSON.stringify(k,null,2)})]})]}),e.jsxs("div",{className:"mt-6 flex justify-between",children:[e.jsxs("button",{onClick:z,disabled:!y.source.trim(),className:"btn-secondary",children:[e.jsx(yv,{className:"h-4 w-4"}),n("skills.scan")]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>{h(!1),C(null)},className:"btn-secondary",children:n("common.cancel")}),e.jsx("button",{onClick:w,disabled:!y.source.trim()||b,className:"btn-primary",children:n(b?"common.loading":"skills.install")})]})]})]})})]})}function Vj(){const{t:n}=Je(),[i,d]=u.useState([]),[c,m]=u.useState(!0),[f,h]=u.useState(null),[b,g]=u.useState("all"),p=u.useCallback(async()=>{m(!0),h(null);try{const v={limit:100};b!=="all"&&(v.status=b);const k=await ln.list(v);d(k.data)}catch(v){h(v instanceof Error?v.message:"Failed to fetch runs"),d([])}finally{m(!1)}},[b]);u.useEffect(()=>{p()},[p]);const S=async v=>{try{await ln.abort(v),p()}catch(k){console.error("Abort failed:",k)}},y=async v=>{if(window.confirm("Delete this run record?"))try{await ln.delete(v),d(k=>k.filter(C=>C.id!==v))}catch(k){console.error("Delete failed:",k)}};return c?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold text-white",children:n("runs.title")}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:p,className:"btn-ghost btn-sm",children:e.jsx(xt,{className:"h-4 w-4"})}),e.jsx(R0,{className:"h-4 w-4 text-zinc-500"}),e.jsxs("select",{className:"input w-auto",value:b,onChange:v=>g(v.target.value),children:[e.jsx("option",{value:"all",children:"All Status"}),e.jsx("option",{value:"running",children:n("status.running")}),e.jsx("option",{value:"completed",children:n("status.completed")}),e.jsx("option",{value:"failed",children:n("status.failed")}),e.jsx("option",{value:"pending",children:n("status.pending")}),e.jsx("option",{value:"paused",children:n("status.paused")}),e.jsx("option",{value:"cancelled",children:n("status.cancelled")})]})]})]}),f&&e.jsxs("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 p-4 text-sm text-red-400",children:[f,e.jsx("button",{onClick:p,className:"ml-3 underline",children:n("common.retry")})]}),i.length===0&&!f?e.jsx(cn,{icon:e.jsx(Nt,{className:"h-8 w-8"}),title:n("runs.empty"),description:n("runs.emptyDesc")}):i.length>0?e.jsx("div",{className:"card overflow-hidden p-0",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border bg-surface",children:[e.jsx("th",{className:"px-5 py-3 text-left text-zinc-400 font-medium",children:"Run ID"}),e.jsx("th",{className:"px-5 py-3 text-left text-zinc-400 font-medium",children:"Workflow"}),e.jsx("th",{className:"px-5 py-3 text-left text-zinc-400 font-medium",children:n("common.status")}),e.jsx("th",{className:"px-5 py-3 text-left text-zinc-400 font-medium",children:"Started"}),e.jsx("th",{className:"px-5 py-3 text-left text-zinc-400 font-medium",children:n("run.duration")}),e.jsx("th",{className:"px-5 py-3 text-left text-zinc-400 font-medium",children:n("common.actions")})]})}),e.jsx("tbody",{children:i.map(v=>{var C;const k=v.completedAt&&v.startedAt?Math.round((new Date(v.completedAt).getTime()-new Date(v.startedAt).getTime())/1e3):null;return e.jsxs("tr",{className:"border-b border-border hover:bg-surface-hover transition-colors",children:[e.jsx("td",{className:"px-5 py-3",children:e.jsxs(ta,{to:`/runs/${v.id}`,className:"text-indigo-400 hover:text-indigo-300 font-mono text-xs",children:[v.id.slice(0,8),"..."]})}),e.jsxs("td",{className:"px-5 py-3 text-zinc-300 font-mono text-xs",children:[((C=v.workflowId)==null?void 0:C.slice(0,8))??"—","..."]}),e.jsx("td",{className:"px-5 py-3",children:e.jsx(wi,{status:v.status,pulse:!0})}),e.jsx("td",{className:"px-5 py-3 text-zinc-400 text-xs",children:new Date(v.startedAt).toLocaleString()}),e.jsx("td",{className:"px-5 py-3 text-zinc-400 text-xs",children:k!==null?`${k}s`:"—"}),e.jsx("td",{className:"px-5 py-3",children:e.jsxs("div",{className:"flex gap-1",children:[(v.status==="running"||v.status==="pending")&&e.jsx("button",{onClick:()=>S(v.id),className:"btn-ghost btn-sm text-amber-400",title:"Abort run",children:e.jsx(E0,{className:"h-3.5 w-3.5"})}),(v.status==="completed"||v.status==="failed"||v.status==="cancelled")&&e.jsx("button",{onClick:()=>y(v.id),className:"btn-ghost btn-sm text-zinc-400 hover:text-red-400",title:"Delete run",children:e.jsx(Ot,{className:"h-3.5 w-3.5"})})]})})]},v.id)})})]})})}):null]})}const q0="/api";async function Yj(n){const i=localStorage.getItem("nestor_token"),d={"Content-Type":"application/json"};i&&(d.Authorization=`Bearer ${i}`);const c=localStorage.getItem("nestor_tenant_id");c&&(d["X-Tenant-ID"]=c);const m=await fetch(`${q0}/runs/${n}/feedback`,{headers:d});return m.ok?(await m.json()).data??[]:[]}async function Qh(n,i,d,c){const m=localStorage.getItem("nestor_token"),f={"Content-Type":"application/json"};m&&(f.Authorization=`Bearer ${m}`);const h=localStorage.getItem("nestor_tenant_id");h&&(f["X-Tenant-ID"]=h),await fetch(`${q0}/runs/${n}/feedback`,{method:"POST",headers:f,body:JSON.stringify({rating:i,comment:d||void 0,agentId:c})})}function Xj({runId:n,agentId:i}){const[d,c]=u.useState([]),[m,f]=u.useState(!1),[h,b]=u.useState(null),[g,p]=u.useState(""),[S,y]=u.useState(!1),v=u.useCallback(async()=>{const w=await Yj(n);c(w),w.length>0&&(f(!0),b(w[0].rating))},[n]);u.useEffect(()=>{v()},[v]);const k=async w=>{m||(b(w),w===1?(await Qh(n,w,void 0,i),f(!0),v()):y(!0))},C=async()=>{h!==null&&(await Qh(n,h,g||void 0,i),f(!0),y(!1),v())};return e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-zinc-400",children:"Was this helpful?"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>k(1),disabled:m,className:`rounded-lg p-2 transition-colors ${h===1?"bg-green-500/20 text-green-400":m?"text-zinc-600 cursor-not-allowed":"text-zinc-400 hover:bg-green-500/10 hover:text-green-400"}`,title:"Helpful",children:e.jsx(yi,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>k(-1),disabled:m,className:`rounded-lg p-2 transition-colors ${h===-1?"bg-red-500/20 text-red-400":m?"text-zinc-600 cursor-not-allowed":"text-zinc-400 hover:bg-red-500/10 hover:text-red-400"}`,title:"Not helpful",children:e.jsx(Id,{className:"h-5 w-5"})})]})]}),S&&!m&&e.jsxs("div",{className:"mt-3 flex gap-2",children:[e.jsx("input",{type:"text",value:g,onChange:w=>p(w.target.value),placeholder:"What could be improved? (optional)",className:"flex-1 rounded-lg bg-zinc-800 px-3 py-2 text-sm text-zinc-200 placeholder-zinc-500 border border-zinc-700 focus:border-indigo-500 focus:outline-none",onKeyDown:w=>{w.key==="Enter"&&C()}}),e.jsx("button",{onClick:C,className:"rounded-lg bg-indigo-600 px-3 py-2 text-sm text-white hover:bg-indigo-500 transition-colors",children:e.jsx(gi,{className:"h-4 w-4"})})]}),m&&e.jsxs("p",{className:"mt-2 text-xs text-zinc-500",children:[h===1?"Thanks for the positive feedback!":"Thanks for your feedback.",d.length>0&&d[0].comment&&e.jsxs("span",{className:"text-zinc-600",children:[" — “",d[0].comment,"”"]})]})]})}const Qj={llm_request:{icon:La,color:"text-purple-400",bgColor:"bg-purple-500/10",label:"LLM Request"},llm_response:{icon:Pt,color:"text-blue-400",bgColor:"bg-blue-500/10",label:"LLM Response"},tool_call_requested:{icon:cl,color:"text-amber-400",bgColor:"bg-amber-500/10",label:"Tool Call"},tool_call_completed:{icon:et,color:"text-emerald-400",bgColor:"bg-emerald-500/10",label:"Tool Result"},tool_call_denied:{icon:ft,color:"text-red-400",bgColor:"bg-red-500/10",label:"Tool Denied"},node_started:{icon:Nt,color:"text-blue-400",bgColor:"bg-blue-500/10",label:"Step Started"},node_completed:{icon:et,color:"text-green-400",bgColor:"bg-green-500/10",label:"Step Completed"},node_failed:{icon:ft,color:"text-red-400",bgColor:"bg-red-500/10",label:"Step Failed"},thinking:{icon:Zd,color:"text-yellow-400",bgColor:"bg-yellow-500/10",label:"Thinking"},reasoning:{icon:Zd,color:"text-yellow-400",bgColor:"bg-yellow-500/10",label:"Reasoning"},approval_requested:{icon:Ms,color:"text-amber-400",bgColor:"bg-amber-500/10",label:"Approval Requested"},budget_warning:{icon:pt,color:"text-amber-400",bgColor:"bg-amber-500/10",label:"Budget Warning"},budget_exceeded:{icon:us,color:"text-red-400",bgColor:"bg-red-500/10",label:"Budget Exceeded"},error:{icon:pt,color:"text-red-400",bgColor:"bg-red-500/10",label:"Error"}},Fj={icon:Nt,color:"text-zinc-400",bgColor:"bg-zinc-500/10",label:"Event"};function Zj(n){try{return new Date(n).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3})}catch{return n}}function Fh(n,i){try{return new Date(i).getTime()-new Date(n).getTime()}catch{return 0}}function Jj(n){return n<1e3?`${n}ms`:n<6e4?`${(n/1e3).toFixed(1)}s`:`${Math.floor(n/6e4)}m ${Math.floor(n%6e4/1e3)}s`}function Ij(n){const i=n.data;if(!i)return"";if(typeof i.reasoning=="string")return i.reasoning;if(typeof i.content=="string")return i.content;if(typeof i.text=="string")return i.text;if(typeof i.output=="string")return i.output;if(typeof i.prompt=="string")return i.prompt;if(typeof i.error=="string")return i.error;if(typeof i.tool=="string"){const c=i.args?` (${JSON.stringify(i.args).slice(0,120)})`:"";return`${i.tool}${c}`}const d=JSON.stringify(i,null,2);return d.length>300?d.slice(0,300)+"...":d}function Pj(n,i){let d=0;for(let c=0;c<=i&&c<n.length;c++){const m=n[c].data;typeof m.estimatedCostUsd=="number"?d=m.estimatedCostUsd:typeof m.cost=="number"&&(d+=m.cost)}return d}function Wj({runId:n}){const[i,d]=u.useState([]),[c,m]=u.useState(!0),[f,h]=u.useState(null),[b,g]=u.useState(-1),[p,S]=u.useState(!1),[y,v]=u.useState(1),k=u.useRef(null),C=u.useRef(null),w=u.useRef(new Map);u.useEffect(()=>{let $=!1;return m(!0),h(null),ln.getEvents(n).then(Q=>{$||d(Q.data.sort((ce,I)=>new Date(ce.timestamp).getTime()-new Date(I.timestamp).getTime()))}).catch(Q=>{$||h(Q instanceof Error?Q.message:"Failed to load events")}).finally(()=>{$||m(!1)}),()=>{$=!0}},[n]);const N=u.useCallback(()=>{S(!1),k.current&&(clearTimeout(k.current),k.current=null)},[]),z=u.useCallback(()=>{g($=>{const Q=$+1;if(Q>=i.length)return N(),$;const ce=i[$]??i[0],I=i[Q];if(ce&&I){const le=Fh(ce.timestamp,I.timestamp),Y=Math.max(50,Math.min(le/y,2e3/y));k.current=setTimeout(z,Y)}return Q})},[i,y,N]),R=u.useCallback(()=>{i.length!==0&&(S(!0),g($=>{const Q=$>=i.length-1?0:$,ce=300/y;return k.current=setTimeout(z,ce),Q}))},[i,y,z]),D=u.useCallback(()=>{p?N():R()},[p,N,R]),O=u.useCallback(()=>{N(),g($=>Math.min($+1,i.length-1))},[i.length,N]),se=u.useCallback(()=>{N(),g($=>Math.max($-1,0))},[N]),Z=u.useCallback($=>{N(),g($)},[N]),U=u.useCallback(()=>{v($=>{const Q=[1,2,4,8],ce=Q.indexOf($);return Q[(ce+1)%Q.length]})},[]);if(u.useEffect(()=>{if(b>=0){const $=w.current.get(b);$==null||$.scrollIntoView({behavior:"smooth",block:"nearest"})}},[b]),u.useEffect(()=>()=>{k.current&&clearTimeout(k.current)},[]),c)return e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent"}),e.jsx("span",{className:"ml-3 text-sm text-zinc-400",children:"Loading events..."})]});if(f)return e.jsx("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 p-4",children:e.jsx("p",{className:"text-sm text-red-400",children:f})});if(i.length===0)return e.jsx("div",{className:"rounded-lg border border-zinc-700 bg-zinc-800/50 p-6 text-center",children:e.jsx("p",{className:"text-sm text-zinc-500",children:"No events recorded for this run."})});const A=i.length>0?(b+1)/i.length*100:0,F=b>=0?Pj(i,b):0;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-zinc-700 bg-zinc-800/80 px-4 py-3",children:[e.jsx("button",{onClick:se,disabled:b<=0,className:"rounded p-1.5 text-zinc-400 transition-colors hover:bg-zinc-700 hover:text-white disabled:opacity-30 disabled:cursor-not-allowed",title:"Step backward",children:e.jsx(Dv,{className:"h-4 w-4"})}),e.jsx("button",{onClick:D,className:"flex h-9 w-9 items-center justify-center rounded-full bg-indigo-600 text-white transition-colors hover:bg-indigo-500",title:p?"Pause":"Play",children:p?e.jsx(tl,{className:"h-4 w-4"}):e.jsx(Nt,{className:"h-4 w-4 ml-0.5"})}),e.jsx("button",{onClick:O,disabled:b>=i.length-1,className:"rounded p-1.5 text-zinc-400 transition-colors hover:bg-zinc-700 hover:text-white disabled:opacity-30 disabled:cursor-not-allowed",title:"Step forward",children:e.jsx(Ov,{className:"h-4 w-4"})}),e.jsxs("button",{onClick:U,className:"rounded border border-zinc-600 px-2 py-1 text-xs font-mono text-zinc-300 transition-colors hover:bg-zinc-700",title:"Cycle playback speed",children:[y,"x"]}),e.jsx("div",{className:"flex-1 mx-2",children:e.jsxs("div",{className:"relative h-2 rounded-full bg-zinc-700 cursor-pointer",onClick:$=>{const Q=$.currentTarget.getBoundingClientRect(),ce=($.clientX-Q.left)/Q.width,I=Math.round(ce*(i.length-1));Z(Math.max(0,Math.min(I,i.length-1)))},children:[e.jsx("div",{className:"absolute top-0 left-0 h-full rounded-full bg-indigo-500 transition-all duration-150",style:{width:`${A}%`}}),e.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 h-3.5 w-3.5 rounded-full border-2 border-indigo-400 bg-zinc-900 transition-all duration-150",style:{left:`calc(${A}% - 7px)`}})]})}),e.jsxs("span",{className:"text-xs font-mono text-zinc-500 whitespace-nowrap",children:[b+1," / ",i.length]}),F>0&&e.jsxs("span",{className:"flex items-center gap-1 text-xs font-mono text-amber-400 whitespace-nowrap",children:[e.jsx(us,{className:"h-3 w-3"}),F.toFixed(4)]})]}),e.jsx("div",{ref:C,className:"max-h-[600px] overflow-y-auto rounded-lg border border-zinc-700 bg-zinc-900/50",children:e.jsx("div",{className:"divide-y divide-zinc-800",children:i.map(($,Q)=>{const ce=Qj[$.type]??Fj,I=ce.icon,le=Q===b,Y=b<0||Q<=b,B=Ij($),ne=Q>0?Fh(i[Q-1].timestamp,$.timestamp):0;return e.jsxs("div",{ref:me=>{me&&w.current.set(Q,me)},className:`
586
+ flex items-start gap-3 px-4 py-3 cursor-pointer transition-all duration-200
587
+ ${le?"bg-indigo-500/10 border-l-2 border-l-indigo-500":"border-l-2 border-l-transparent"}
588
+ ${Y?"opacity-100":"opacity-30"}
589
+ hover:bg-zinc-800/50
590
+ `,onClick:()=>Z(Q),children:[e.jsx("span",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded text-[10px] font-mono text-zinc-600",children:Q+1}),e.jsx("div",{className:`mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-lg ${ce.bgColor}`,children:e.jsx(I,{className:`h-3.5 w-3.5 ${ce.color}`})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-xs font-medium ${ce.color}`,children:ce.label}),e.jsx("span",{className:"text-[10px] font-mono text-zinc-600",children:Zj($.timestamp)}),ne>0&&e.jsxs("span",{className:"text-[10px] text-zinc-600",children:["+",Jj(ne)]})]}),B&&Y&&e.jsx("pre",{className:`mt-1 text-xs whitespace-pre-wrap break-words ${le?"text-zinc-200":"text-zinc-500"} max-h-40 overflow-hidden`,children:B.length>500?B.slice(0,500)+"...":B})]}),le&&e.jsx(ds,{className:"mt-1.5 h-3.5 w-3.5 shrink-0 text-indigo-400"})]},$.id)})})})]})}function e1(){const{id:n}=ll(),i=Dt(),{t:d}=Je(),[c,m]=u.useState(null),[f,h]=u.useState([]),[b,g]=u.useState([]),[p,S]=u.useState([]),[y,v]=u.useState(!0),[k,C]=u.useState(null),[w,N]=u.useState(null),[z,R]=u.useState(""),[D,O]=u.useState("details"),se=u.useCallback(async()=>{if(n)try{const I=await ln.get(n);m(I.data)}catch(I){C(I instanceof Error?I.message:"Failed to load run")}},[n]),Z=u.useCallback(async()=>{if(n)try{const I=await ln.getEvents(n);h(I.data)}catch{}},[n]),U=u.useCallback(async()=>{if(n)try{const I=await Hd.forRun(n);g(I.data)}catch{}},[n]),A=u.useCallback(async()=>{if(n)try{const I=await ac.list();S(I.data.filter(le=>le.runId===n))}catch{}},[n]);u.useEffect(()=>{n&&(v(!0),C(null),Promise.all([se(),Z(),U(),A()]).finally(()=>{v(!1)}))},[n,se,Z,U,A]),u.useEffect(()=>{if(!c||c.status==="completed"||c.status==="failed"||c.status==="cancelled")return;const I=setInterval(()=>{se(),Z()},3e3);return()=>clearInterval(I)},[c==null?void 0:c.status,se,Z]);const F=async()=>{if(n)try{await ln.abort(n),se()}catch(I){console.error("Abort failed:",I)}};if(y)return e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent"})});if(k||!c)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-20",children:[e.jsx("p",{className:"text-red-400",children:k??"Run not found"}),e.jsxs("button",{onClick:()=>i("/runs"),className:"btn-secondary mt-4",children:[e.jsx(Wn,{className:"h-4 w-4"})," Back to Runs"]})]});const $=c.completedAt&&c.startedAt?Math.round((new Date(c.completedAt).getTime()-new Date(c.startedAt).getTime())/1e3):null,Q=c.status==="completed"?e.jsx(et,{className:"h-5 w-5 text-green-400"}):c.status==="failed"?e.jsx(ft,{className:"h-5 w-5 text-red-400"}):e.jsx(Nt,{className:"h-5 w-5 text-blue-400"}),ce=c.status==="running"||c.status==="pending";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>i("/runs"),className:"btn-ghost btn-sm",children:e.jsx(Wn,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex items-center gap-3",children:[Q,e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-semibold text-white",children:["Run ",e.jsxs("span",{className:"font-mono text-lg text-zinc-400",children:[c.id.slice(0,12),"..."]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[e.jsx(wi,{status:c.status,pulse:!0}),e.jsxs("span",{className:"text-xs text-zinc-500",children:["Started: ",new Date(c.startedAt).toLocaleString()]})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{se(),Z()},className:"btn-ghost btn-sm",children:e.jsx(xt,{className:"h-3.5 w-3.5"})}),ce&&e.jsxs("button",{onClick:F,className:"btn-danger btn-sm",children:[e.jsx(E0,{className:"h-3.5 w-3.5"})," Abort"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[e.jsx("div",{className:"card",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-blue-500/10",children:e.jsx(L0,{className:"h-4 w-4 text-blue-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500",children:d("run.duration")}),e.jsx("p",{className:"text-lg font-semibold text-white",children:$!==null?`${$}s`:"In progress..."})]})]})}),e.jsx("div",{className:"card",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-amber-500/10",children:e.jsx(us,{className:"h-4 w-4 text-amber-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500",children:d("run.cost")}),e.jsx("p",{className:"text-lg font-semibold text-white",children:"$0.00"})]})]})}),e.jsx("div",{className:"card",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-violet-500/10",children:e.jsx(vs,{className:"h-4 w-4 text-violet-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500",children:"Events"}),e.jsx("p",{className:"text-lg font-semibold text-white",children:f.length})]})]})})]}),e.jsxs("div",{className:"flex items-center gap-1 border-b border-zinc-700",children:[e.jsx("button",{onClick:()=>O("details"),className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${D==="details"?"border-indigo-500 text-indigo-400":"border-transparent text-zinc-500 hover:text-zinc-300"}`,children:"Details"}),e.jsxs("button",{onClick:()=>O("replay"),className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors flex items-center gap-1.5 ${D==="replay"?"border-indigo-500 text-indigo-400":"border-transparent text-zinc-500 hover:text-zinc-300"}`,children:[e.jsx(Nt,{className:"h-3.5 w-3.5"}),"Replay"]})]}),D==="replay"&&e.jsx(Wj,{runId:n}),D==="details"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[e.jsx(Xj,{runId:n}),e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"mb-4 text-lg font-medium text-zinc-200",children:d("run.events")}),e.jsx(gu,{events:f,maxHeight:"500px"})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"mb-4 text-lg font-medium text-zinc-200",children:d("run.output")}),c.output?e.jsx("pre",{className:"overflow-auto rounded-lg bg-[#0a0a0f] p-4 text-sm text-zinc-300 max-h-64",children:JSON.stringify(c.output,null,2)}):e.jsx("p",{className:"text-sm text-zinc-500",children:"No output available yet."})]}),c.error&&e.jsxs("div",{className:"card border-red-500/20",children:[e.jsx("h2",{className:"mb-2 text-lg font-medium text-red-400",children:"Error"}),e.jsx("pre",{className:"overflow-auto rounded-lg bg-red-500/5 p-4 text-sm text-red-300",children:c.error})]}),e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"mb-4 text-lg font-medium text-zinc-200",children:"Input"}),e.jsx("pre",{className:"overflow-auto rounded-lg bg-[#0a0a0f] p-4 text-sm text-zinc-300 max-h-40",children:JSON.stringify(c.input,null,2)})]})]})]}),p.filter(I=>I.status==="pending").map(I=>e.jsxs("div",{className:"card border-amber-500/30 bg-amber-500/5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(fi,{className:"h-5 w-5 text-amber-400"}),e.jsx("h2",{className:"text-lg font-semibold text-amber-300",children:"Handoff Pending"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500 mb-1",children:"Accomplished"}),e.jsx("p",{className:"text-zinc-300",children:I.accomplished})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500 mb-1",children:"Blocking"}),e.jsx("p",{className:"text-red-400",children:I.blocking})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500 mb-1",children:"Suggestions"}),e.jsx("p",{className:"text-zinc-300",children:I.suggestions})]})]}),e.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[e.jsx("input",{type:"text",className:"flex-1 rounded-lg border border-zinc-700 bg-zinc-800 px-3 py-2 text-sm text-zinc-200 placeholder-zinc-500 focus:border-indigo-500 focus:outline-none",placeholder:"Describe how you resolved the blocking issue...",value:z,onChange:le=>R(le.target.value)}),e.jsx("button",{className:"btn-primary btn-sm",disabled:!z.trim(),onClick:async()=>{try{await ac.resume(I.id,z),R(""),A()}catch(le){console.error("Resume failed:",le)}},children:"Resume"})]})]},I.id)),e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-medium text-zinc-200",children:"Annotations"}),e.jsx("button",{className:"btn-ghost btn-sm",onClick:()=>N(w?null:{type:"note",content:""}),children:w?"Cancel":"+ Add"})]}),w&&e.jsxs("div",{className:"mb-4 rounded-lg border border-zinc-700 p-3 space-y-2",children:[e.jsx("div",{className:"flex gap-2",children:["good","bad","wrong_approach","note"].map(I=>{const le={good:e.jsx(yi,{className:"h-3.5 w-3.5"}),bad:e.jsx(Id,{className:"h-3.5 w-3.5"}),wrong_approach:e.jsx(Bh,{className:"h-3.5 w-3.5"}),note:e.jsx(Pt,{className:"h-3.5 w-3.5"})},Y={good:"text-green-400 border-green-500/30",bad:"text-red-400 border-red-500/30",wrong_approach:"text-amber-400 border-amber-500/30",note:"text-blue-400 border-blue-500/30"};return e.jsxs("button",{className:`flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs ${w.type===I?Y[I]+" bg-zinc-800":"border-zinc-700 text-zinc-500 hover:text-zinc-300"}`,onClick:()=>N({...w,type:I}),children:[le[I]," ",I.replace("_"," ")]},I)})}),e.jsx("textarea",{className:"w-full rounded-lg border border-zinc-700 bg-zinc-800 px-3 py-2 text-sm text-zinc-200 placeholder-zinc-500 focus:border-indigo-500 focus:outline-none",rows:2,placeholder:"Add your annotation...",value:w.content,onChange:I=>N({...w,content:I.target.value})}),e.jsx("button",{className:"btn-primary btn-sm",disabled:!w.content.trim(),onClick:async()=>{if(!(!n||!w.content.trim()))try{await Hd.create(n,{type:w.type,content:w.content}),N(null),U()}catch(I){console.error("Failed to add annotation:",I)}},children:"Save Annotation"})]}),b.length===0?e.jsx("p",{className:"text-sm text-zinc-500",children:"No annotations yet."}):e.jsx("div",{className:"space-y-2",children:b.map(I=>{const le={good:"border-green-500/30 bg-green-500/5",bad:"border-red-500/30 bg-red-500/5",wrong_approach:"border-amber-500/30 bg-amber-500/5",note:"border-blue-500/30 bg-blue-500/5",handoff:"border-purple-500/30 bg-purple-500/5"},Y={good:e.jsx(yi,{className:"h-3.5 w-3.5 text-green-400"}),bad:e.jsx(Id,{className:"h-3.5 w-3.5 text-red-400"}),wrong_approach:e.jsx(Bh,{className:"h-3.5 w-3.5 text-amber-400"}),note:e.jsx(Pt,{className:"h-3.5 w-3.5 text-blue-400"}),handoff:e.jsx(fi,{className:"h-3.5 w-3.5 text-purple-400"})};return e.jsxs("div",{className:`flex items-start gap-2 rounded-lg border p-2 text-sm ${le[I.type]??"border-zinc-700"}`,children:[e.jsx("span",{className:"mt-0.5",children:Y[I.type]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-zinc-300",children:I.content}),e.jsxs("p",{className:"text-xs text-zinc-500 mt-1",children:[I.author," · ",new Date(I.createdAt).toLocaleString(),I.eventIndex!=null&&` &middot; Event #${I.eventIndex}`]})]}),e.jsx("button",{className:"text-zinc-600 hover:text-red-400 transition-colors",title:"Delete annotation",onClick:async()=>{try{await Hd.delete(I.id),U()}catch(B){console.error("Delete failed:",B)}},children:e.jsx(ft,{className:"h-3.5 w-3.5"})})]},I.id)})})]})]})]})}function t1(){const{t:n}=Je(),[i,d]=u.useState("general"),[c,m]=u.useState(null),[f,h]=u.useState(!0),[b,g]=u.useState(!1),[p,S]=u.useState(!1),[y,v]=u.useState(null);u.useEffect(()=>{Es.getConfig().then(z=>m(z.data)).catch(()=>{m({server:{host:"127.0.0.1",port:3100},security:{defaultTrustLevel:"community",approvalMode:"manual",maxConcurrentRuns:10},budget:{enabled:!1,defaultMaxCostPerRunUsd:1,defaultMaxTokensPerRun:1e5,warningThresholdPercent:80},logging:{level:"info",format:"pretty"}})}).finally(()=>h(!1))},[]);const k=async()=>{if(c){g(!0),S(!1),v(null);try{const z=await Es.updateConfig(c);m(z.data),S(!0),setTimeout(()=>S(!1),3e3)}catch(z){v(z instanceof Error?z.message:"Failed to save")}finally{g(!1)}}},C=async()=>{h(!0);try{const z=await Es.getConfig();m(z.data),v(null)}catch{v("Failed to refresh config")}finally{h(!1)}},w=(z,R,D)=>{c&&m({...c,[z]:{...c[z],[R]:D}})},N=[{key:"general",label:n("settings.general")},{key:"security",label:n("settings.security")},{key:"budget",label:n("settings.budget")},{key:"apikeys",label:"API Keys"},{key:"studio",label:"Studio"}];return f?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent"})}):c?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold text-white",children:n("settings.title")}),e.jsxs("div",{className:"flex items-center gap-3",children:[p&&e.jsxs("span",{className:"flex items-center gap-1.5 text-sm text-green-400",children:[e.jsx(bt,{className:"h-4 w-4"}),n("settings.saved")]}),y&&e.jsxs("span",{className:"flex items-center gap-1.5 text-sm text-red-400",children:[e.jsx(xi,{className:"h-4 w-4"}),y]}),e.jsx("button",{onClick:C,className:"btn-ghost btn-sm",children:e.jsx(xt,{className:"h-4 w-4"})}),e.jsxs("button",{onClick:k,disabled:b,className:"btn-primary",children:[e.jsx(cc,{className:"h-4 w-4"}),n(b?"common.loading":"settings.save")]})]})]}),e.jsx("div",{className:"flex gap-1 border-b border-border",children:N.map(({key:z,label:R})=>e.jsx("button",{onClick:()=>d(z),className:`px-4 py-2.5 text-sm font-medium transition-colors border-b-2 ${i===z?"border-indigo-500 text-indigo-400":"border-transparent text-zinc-400 hover:text-zinc-200"}`,children:R},z))}),i==="general"&&e.jsxs("div",{className:"card space-y-6",children:[e.jsx("h2",{className:"text-lg font-medium text-zinc-200",children:"Server Configuration"}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Host"}),e.jsx("input",{className:"input",value:c.server.host,onChange:z=>w("server","host",z.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Port"}),e.jsx("input",{className:"input",type:"number",value:c.server.port,onChange:z=>w("server","port",parseInt(z.target.value)||3100)})]})]}),e.jsx("h2",{className:"text-lg font-medium text-zinc-200 pt-4",children:"Logging"}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Level"}),e.jsxs("select",{className:"input",value:c.logging.level,onChange:z=>w("logging","level",z.target.value),children:[e.jsx("option",{value:"debug",children:"Debug"}),e.jsx("option",{value:"info",children:"Info"}),e.jsx("option",{value:"warn",children:"Warn"}),e.jsx("option",{value:"error",children:"Error"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Format"}),e.jsxs("select",{className:"input",value:c.logging.format,onChange:z=>w("logging","format",z.target.value),children:[e.jsx("option",{value:"json",children:"JSON"}),e.jsx("option",{value:"pretty",children:"Pretty"})]})]})]})]}),i==="security"&&e.jsxs("div",{className:"card space-y-6",children:[e.jsx("h2",{className:"text-lg font-medium text-zinc-200",children:"Security Settings"}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Default Trust Level"}),e.jsxs("select",{className:"input",value:c.security.defaultTrustLevel,onChange:z=>w("security","defaultTrustLevel",z.target.value),children:[e.jsx("option",{value:"builtin",children:"Built-in"}),e.jsx("option",{value:"official",children:"Official"}),e.jsx("option",{value:"trusted",children:"Trusted"}),e.jsx("option",{value:"community",children:"Community"}),e.jsx("option",{value:"local",children:"Local"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Approval Mode"}),e.jsxs("select",{className:"input",value:c.security.approvalMode,onChange:z=>w("security","approvalMode",z.target.value),children:[e.jsx("option",{value:"manual",children:"Manual"}),e.jsx("option",{value:"smart",children:"Smart"}),e.jsx("option",{value:"off",children:"Off"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Max Concurrent Runs"}),e.jsx("input",{className:"input",type:"number",value:c.security.maxConcurrentRuns,onChange:z=>w("security","maxConcurrentRuns",parseInt(z.target.value)||10)})]})]})]}),i==="budget"&&e.jsxs("div",{className:"card space-y-6",children:[e.jsx("h2",{className:"text-lg font-medium text-zinc-200",children:"Budget Configuration"}),e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsxs("label",{className:"relative inline-flex cursor-pointer items-center",children:[e.jsx("input",{type:"checkbox",checked:c.budget.enabled,onChange:z=>w("budget","enabled",z.target.checked),className:"peer sr-only"}),e.jsx("div",{className:"h-6 w-11 rounded-full bg-zinc-700 after:absolute after:left-[2px] after:top-0.5 after:h-5 after:w-5 after:rounded-full after:bg-white after:transition-all peer-checked:bg-indigo-600 peer-checked:after:translate-x-full"})]}),e.jsx("span",{className:"text-sm text-zinc-300",children:"Enable Budget Tracking"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Default Max Cost Per Run (USD)"}),e.jsx("input",{className:"input",type:"number",step:"0.01",value:c.budget.defaultMaxCostPerRunUsd,onChange:z=>w("budget","defaultMaxCostPerRunUsd",parseFloat(z.target.value)||1)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Default Max Tokens Per Run"}),e.jsx("input",{className:"input",type:"number",value:c.budget.defaultMaxTokensPerRun,onChange:z=>w("budget","defaultMaxTokensPerRun",parseInt(z.target.value)||1e5)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Warning Threshold (%)"}),e.jsx("input",{className:"input",type:"number",min:0,max:100,value:c.budget.warningThresholdPercent,onChange:z=>w("budget","warningThresholdPercent",parseInt(z.target.value)||80)})]})]})]}),i==="apikeys"&&e.jsx(s1,{}),i==="studio"&&e.jsxs("div",{className:"card space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ev,{className:"h-5 w-5 text-indigo-400"}),e.jsx("h2",{className:"text-lg font-medium text-zinc-200",children:"Studio Web UI"})]}),e.jsx("p",{className:"text-sm text-zinc-400",children:"The Studio web UI provides a browser-based dashboard for managing agents, workflows, and monitoring runs. You are currently viewing the Studio interface."}),e.jsxs("div",{className:"rounded-lg border border-border bg-zinc-900/50 p-4",children:[e.jsx("h3",{className:"text-sm font-medium text-zinc-200",children:"Current Configuration"}),e.jsx("pre",{className:"mt-2 text-xs text-zinc-400 overflow-auto max-h-40 rounded bg-[#0a0a0f] p-3",children:JSON.stringify(c,null,2)})]}),e.jsxs("div",{className:"text-xs text-zinc-500",children:["Changes are applied to the runtime config and take effect immediately. To persist changes across restarts, update the Nestor config file.",e.jsx("code",{className:"ml-1 rounded bg-zinc-800 px-1.5 py-0.5 text-zinc-300",children:"npx nestor-sh config edit"})]})]})]}):null}const Zh=[{id:"gemini",name:"Gemini",provider:"Google",emoji:"🔵",color:"text-blue-400",defaultModel:"gemini-2.5-flash",keyUrl:"https://aistudio.google.com/apikey",keyUrlLabel:"aistudio.google.com",needsKey:!0},{id:"claude",name:"Claude",provider:"Anthropic",emoji:"🟣",color:"text-purple-400",defaultModel:"claude-sonnet-4-6",keyUrl:"https://console.anthropic.com/settings/keys",keyUrlLabel:"console.anthropic.com",needsKey:!0},{id:"openai",name:"GPT-4o",provider:"OpenAI",emoji:"🟢",color:"text-green-400",defaultModel:"gpt-4o",keyUrl:"https://platform.openai.com/api-keys",keyUrlLabel:"platform.openai.com",needsKey:!0},{id:"grok",name:"Grok",provider:"xAI",emoji:"⚪",color:"text-zinc-300",defaultModel:"grok-3",keyUrl:"https://console.x.ai/",keyUrlLabel:"console.x.ai",needsKey:!0},{id:"mistral",name:"Mistral",provider:"Mistral AI",emoji:"🟠",color:"text-orange-400",defaultModel:"mistral-large-latest",keyUrl:"https://console.mistral.ai/api-keys",keyUrlLabel:"console.mistral.ai",needsKey:!0},{id:"ollama",name:"Ollama",provider:"Local",emoji:"🦙",color:"text-amber-400",defaultModel:"llama3.1",keyUrl:"https://ollama.ai/download",keyUrlLabel:"ollama.ai",needsKey:!1}];function s1(){const[n,i]=u.useState([]),[d,c]=u.useState(!0),[m,f]=u.useState(null),[h,b]=u.useState(""),[g,p]=u.useState(!1),[S,y]=u.useState(null),[v,k]=u.useState(null),[C,w]=u.useState({}),N=u.useCallback(async()=>{try{const A=await ys.list();i(A.data)}catch{}finally{c(!1)}},[]);u.useEffect(()=>{N()},[N]);const z=A=>n.find(F=>F.provider===A),R=A=>{f(A),b(""),p(!1)},D=()=>{f(null),b(""),p(!1)},O=async A=>{if(h.trim()){y(A);try{await ys.set(A,h.trim()),f(null),b(""),await N()}catch{}finally{y(null)}}},se=async A=>{k(A);try{const F=await ys.test(A);w($=>({...$,[A]:F.data}))}catch(F){w($=>({...$,[A]:{valid:!1,message:F instanceof Error?F.message:"Test failed"}}))}finally{k(null)}},Z=async A=>{try{await ys.remove(A),w(F=>{const $={...F};return delete $[A],$}),await N()}catch{}};if(d)return e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-purple-500 border-t-transparent"})});const U=n.filter(A=>A.configured).length;return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"rounded-xl border border-border bg-surface/50 p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ds,{className:"h-5 w-5 text-purple-400 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-xs text-zinc-400 space-y-1",children:[e.jsx("p",{children:"API keys are encrypted with AES-256-GCM and stored locally in the Nestor database. Keys set via environment variables take precedence over database-stored keys."}),e.jsxs("p",{className:"text-zinc-500",children:[U,"/",Zh.length," providers configured."]})]})]})}),e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:Zh.map(A=>{const F=z(A.id),$=(F==null?void 0:F.configured)??!1,Q=m===A.id,ce=v===A.id,I=S===A.id,le=C[A.id];return e.jsxs("div",{className:`rounded-xl border bg-surface p-5 transition-all hover:shadow-lg hover:shadow-black/20 ${$?"border-border":"border-border/50"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:A.emoji}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-white",children:A.name}),e.jsx("p",{className:"text-xs text-zinc-500",children:A.provider})]})]}),$?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-green-500/10 px-2.5 py-0.5 text-xs font-medium text-green-400",children:[e.jsx(bt,{className:"h-3 w-3"}),"Configured"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-red-500/10 px-2.5 py-0.5 text-xs font-medium text-red-400",children:[e.jsx(Ze,{className:"h-3 w-3"}),"Not set"]})]}),e.jsxs("p",{className:"text-xs text-zinc-500 mb-3",children:["Default model: ",e.jsx("code",{className:"text-zinc-400",children:A.defaultModel})]}),$&&(F==null?void 0:F.maskedKey)&&!Q&&e.jsxs("div",{className:"mb-3 rounded-lg bg-background/50 px-3 py-2",children:[e.jsx("p",{className:"font-mono text-xs text-zinc-400",children:F.maskedKey}),F.source==="env"&&e.jsx("p",{className:"text-[10px] text-yellow-500/80 mt-0.5",children:"From environment variable"}),F.source==="db"&&F.label&&e.jsx("p",{className:"text-[10px] text-zinc-600 mt-0.5",children:F.label})]}),Q&&e.jsxs("div",{className:"mb-3 space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:g?"text":"password",value:h,onChange:Y=>b(Y.target.value),placeholder:`Enter ${A.provider} API key`,className:"w-full rounded-lg border border-border bg-background px-3 py-2 pr-10 text-sm text-zinc-200 focus:border-purple-500 focus:outline-none placeholder:text-zinc-600",autoFocus:!0}),e.jsx("button",{type:"button",onClick:()=>p(!g),className:"absolute right-3 top-1/2 -translate-y-1/2 text-zinc-500 hover:text-zinc-300",children:g?e.jsx(uu,{className:"h-3.5 w-3.5"}):e.jsx(el,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>O(A.id),disabled:!h.trim()||I,className:"inline-flex items-center gap-1.5 rounded-lg bg-purple-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-purple-700 disabled:opacity-50 disabled:cursor-not-allowed",children:[I?e.jsx(rt,{className:"h-3 w-3 animate-spin"}):e.jsx(bt,{className:"h-3 w-3"}),"Save"]}),e.jsx("button",{onClick:D,className:"inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-zinc-400 transition-colors hover:bg-surface-hover",children:"Cancel"})]})]}),le&&e.jsxs("div",{className:`mb-3 rounded-lg border p-2.5 text-xs ${le.valid?"border-green-500/20 bg-green-500/5 text-green-400":"border-red-500/20 bg-red-500/5 text-red-400"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium",children:[le.valid?e.jsx(bt,{className:"h-3 w-3"}):e.jsx(xi,{className:"h-3 w-3"}),le.valid?"Working":"Failed"]}),e.jsx("p",{className:"mt-0.5 text-[10px] opacity-80",children:le.message}),le.models&&le.models.length>0&&e.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1",children:[le.models.slice(0,4).map(Y=>e.jsx("span",{className:"rounded bg-white/5 px-1.5 py-0.5 text-[9px] font-mono",children:Y},Y)),le.models.length>4&&e.jsxs("span",{className:"rounded bg-white/5 px-1.5 py-0.5 text-[9px]",children:["+",le.models.length-4]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:$&&!Q?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>se(A.id),disabled:ce,className:"inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-zinc-400 transition-colors hover:bg-surface-hover hover:text-zinc-200 disabled:opacity-50",children:[ce?e.jsx(rt,{className:"h-3 w-3 animate-spin"}):e.jsx(bi,{className:"h-3 w-3"}),"Test"]}),A.needsKey&&e.jsxs("button",{onClick:()=>R(A.id),className:"inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-zinc-400 transition-colors hover:bg-surface-hover hover:text-zinc-200",children:[e.jsx(Ni,{className:"h-3 w-3"}),"Edit"]}),(F==null?void 0:F.source)==="db"&&e.jsxs("button",{onClick:()=>Z(A.id),className:"inline-flex items-center gap-1.5 rounded-lg border border-red-500/20 px-3 py-1.5 text-xs font-medium text-red-400 transition-colors hover:bg-red-500/10",children:[e.jsx(Ot,{className:"h-3 w-3"}),"Remove"]})]}):Q?null:A.needsKey?e.jsxs("button",{onClick:()=>R(A.id),className:"inline-flex items-center gap-1.5 rounded-lg bg-purple-600 px-4 py-1.5 text-xs font-medium text-white transition-colors hover:bg-purple-700",children:[e.jsx(ht,{className:"h-3 w-3"}),"Add Key"]}):e.jsxs("button",{onClick:()=>se(A.id),disabled:ce,className:"inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-zinc-400 transition-colors hover:bg-surface-hover hover:text-zinc-200 disabled:opacity-50",children:[ce?e.jsx(rt,{className:"h-3 w-3 animate-spin"}):e.jsx(bi,{className:"h-3 w-3"}),"Test Connection"]})}),e.jsx("div",{className:"mt-3 border-t border-border/50 pt-2.5",children:e.jsxs("a",{href:A.keyUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-zinc-600 hover:text-zinc-400 transition-colors",children:[e.jsx(Pn,{className:"h-2.5 w-2.5"}),"Get API Key at ",A.keyUrlLabel]})})]},A.id)})})]})}const Jh={low:{bg:"bg-green-500/10",text:"text-green-400",icon:hu},medium:{bg:"bg-amber-500/10",text:"text-amber-400",icon:pt},high:{bg:"bg-orange-500/10",text:"text-orange-400",icon:Ms},critical:{bg:"bg-red-500/10",text:"text-red-400",icon:mv}},yu={command:"Command",budget:"Budget",config:"Config",hire:"Hire",strategy:"Strategy",deploy:"Deploy",custom:"Custom"},a1={pending:"bg-amber-500/10 text-amber-400",approved:"bg-green-500/10 text-green-400",rejected:"bg-red-500/10 text-red-400",expired:"bg-zinc-500/10 text-zinc-400"};function Ih({approval:n,onApprove:i,onReject:d,actionLoading:c,showActions:m}){const[f,h]=u.useState(""),b=Jh[n.riskLevel]??Jh.medium,g=b.icon,p=c===n.id;return e.jsx("div",{className:"card hover:border-amber-500/20 transition-colors",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1 min-w-0",children:[e.jsx("div",{className:`flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-lg ${b.bg}`,children:e.jsx(g,{className:`h-5 w-5 ${b.text}`})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium text-zinc-200",children:n.title}),e.jsx("span",{className:`badge ${b.bg} ${b.text} uppercase text-[10px]`,children:n.riskLevel}),e.jsx("span",{className:"badge bg-zinc-700/50 text-zinc-400 text-[10px]",children:yu[n.type]??n.type}),n.status!=="pending"&&e.jsx("span",{className:`badge ${a1[n.status]} uppercase text-[10px]`,children:n.status})]}),n.description&&e.jsx("p",{className:"mt-1 text-sm text-zinc-400",children:n.description}),e.jsxs("p",{className:"mt-1 text-sm text-zinc-500",children:["Agent: ",e.jsx("span",{className:"text-zinc-300",children:n.agentId})]}),Object.keys(n.payload).length>0&&e.jsx("pre",{className:"mt-2 max-h-24 overflow-auto rounded-lg bg-[#0a0a0f] p-3 text-xs text-zinc-400",children:JSON.stringify(n.payload,null,2)}),e.jsxs("div",{className:"mt-2 flex items-center gap-4 text-xs text-zinc-500",children:[e.jsx("span",{children:new Date(n.createdAt).toLocaleString()}),n.reviewerId&&e.jsxs("span",{children:["Reviewed by: ",e.jsx("span",{className:"text-zinc-400",children:n.reviewerId})]}),n.reviewComment&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Pt,{className:"h-3 w-3"}),n.reviewComment]})]})]})]}),m&&n.status==="pending"&&e.jsxs("div",{className:"flex flex-col gap-2 flex-shrink-0",children:[e.jsx("input",{type:"text",placeholder:"Comment...",value:f,onChange:S=>h(S.target.value),className:"input text-xs w-40"}),e.jsxs("button",{onClick:()=>i==null?void 0:i(n.id,f),disabled:p,className:"btn-primary btn-sm",children:[e.jsx(bt,{className:"h-3.5 w-3.5"}),"Approve"]}),e.jsxs("button",{onClick:()=>d==null?void 0:d(n.id,f),disabled:p,className:"btn-danger btn-sm",children:[e.jsx(Ze,{className:"h-3.5 w-3.5"}),"Reject"]})]})]})})}function n1({stats:n}){const d=n.pending+n.approved+n.rejected+n.expired>0?Math.round(n.approved/(n.approved+n.rejected||1)*100):0;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[e.jsxs("div",{className:"card text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-amber-400",children:n.pending}),e.jsx("p",{className:"text-xs text-zinc-500",children:"Pending"})]}),e.jsxs("div",{className:"card text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-green-400",children:n.approved}),e.jsx("p",{className:"text-xs text-zinc-500",children:"Approved"})]}),e.jsxs("div",{className:"card text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-red-400",children:n.rejected}),e.jsx("p",{className:"text-xs text-zinc-500",children:"Rejected"})]}),e.jsxs("div",{className:"card text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-zinc-400",children:n.expired}),e.jsx("p",{className:"text-xs text-zinc-500",children:"Expired"})]})]}),e.jsxs("div",{className:"card",children:[e.jsx("h3",{className:"text-sm font-medium text-zinc-300 mb-3",children:"Approval Rate"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-1 h-2 rounded-full bg-zinc-800",children:e.jsx("div",{className:"h-full rounded-full bg-green-500",style:{width:`${d}%`}})}),e.jsxs("span",{className:"text-sm font-medium text-zinc-300",children:[d,"%"]})]})]}),Object.keys(n.byType).length>0&&e.jsxs("div",{className:"card",children:[e.jsx("h3",{className:"text-sm font-medium text-zinc-300 mb-3",children:"By Type"}),e.jsx("div",{className:"space-y-2",children:Object.entries(n.byType).map(([c,m])=>e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-zinc-400",children:yu[c]??c}),e.jsx("span",{className:"font-medium text-zinc-200",children:m})]},c))})]})]})}function l1(){const{t:n}=Je(),[i,d]=u.useState("pending"),[c,m]=u.useState([]),[f,h]=u.useState([]),[b,g]=u.useState(null),[p,S]=u.useState(!0),[y,v]=u.useState(null),[k,C]=u.useState(null),[w,N]=u.useState(""),[z,R]=u.useState(""),D=u.useCallback(async()=>{try{v(null);const A={status:"pending"};w&&(A.type=w);let $=(await ri.list(A)).data;z&&($=$.filter(Q=>Q.riskLevel===z)),m($)}catch(A){v(A instanceof Error?A.message:"Failed to fetch approvals"),m([])}finally{S(!1)}},[w,z]),O=u.useCallback(async()=>{try{const A=await ri.history({limit:100});h(A.data)}catch{h([])}},[]),se=u.useCallback(async()=>{try{const A=await ri.stats();g(A.data)}catch{g(null)}},[]);u.useEffect(()=>{i==="pending"?D():i==="history"?O():i==="stats"&&se()},[i,D,O,se]),u.useEffect(()=>{if(i==="pending"){const A=setInterval(D,5e3);return()=>clearInterval(A)}},[i,D]);const Z=async(A,F)=>{C(A);try{await ri.approve(A,{comment:F||void 0}),m($=>$.filter(Q=>Q.id!==A))}catch($){console.error("Approve failed:",$)}finally{C(null)}},U=async(A,F)=>{C(A);try{await ri.reject(A,{reason:F||void 0}),m($=>$.filter(Q=>Q.id!==A))}catch($){console.error("Reject failed:",$)}finally{C(null)}};return p&&i==="pending"?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-semibold text-white",children:n("approvals.title")}),c.length>0&&i==="pending"&&e.jsxs("span",{className:"badge bg-amber-500/10 text-amber-400",children:[c.length," pending"]})]}),e.jsx("button",{onClick:()=>{i==="pending"?D():i==="history"?O():se()},className:"btn-ghost btn-sm",children:e.jsx(xt,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex items-center gap-1 border-b border-border",children:[{key:"pending",label:"Pending",icon:Ms},{key:"history",label:"History",icon:Hh},{key:"stats",label:"Stats",icon:Rs}].map(({key:A,label:F,icon:$})=>e.jsxs("button",{onClick:()=>d(A),className:`flex items-center gap-2 border-b-2 px-4 py-2.5 text-sm font-medium transition-colors ${i===A?"border-indigo-500 text-indigo-400":"border-transparent text-zinc-500 hover:text-zinc-300"}`,children:[e.jsx($,{className:"h-4 w-4"}),F]},A))}),i==="pending"&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(R0,{className:"h-4 w-4 text-zinc-500"}),e.jsxs("select",{value:w,onChange:A=>N(A.target.value),className:"input text-sm w-40",children:[e.jsx("option",{value:"",children:"All Types"}),Object.entries(yu).map(([A,F])=>e.jsx("option",{value:A,children:F},A))]}),e.jsxs("select",{value:z,onChange:A=>R(A.target.value),className:"input text-sm w-40",children:[e.jsx("option",{value:"",children:"All Risk Levels"}),e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"}),e.jsx("option",{value:"critical",children:"Critical"})]})]}),y&&e.jsxs("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 p-4 text-sm text-red-400",children:[y,e.jsx("button",{onClick:D,className:"ml-3 underline",children:"Retry"})]}),i==="pending"&&(c.length===0&&!y?e.jsx(cn,{icon:e.jsx(hu,{className:"h-8 w-8"}),title:n("approvals.empty"),description:n("approvals.emptyDesc"),action:e.jsxs("div",{className:"mt-2 space-y-3 text-left max-w-md",children:[e.jsx("p",{className:"text-sm text-zinc-400",children:"Approvals appear when an agent requests permission for a risky action (shell commands, file deletions, config changes, etc.)."}),e.jsxs("div",{className:"rounded-lg bg-zinc-900 border border-zinc-800 p-3",children:[e.jsx("p",{className:"text-xs text-zinc-500 mb-1.5 font-medium",children:"To enable approval mode:"}),e.jsx("code",{className:"text-xs text-indigo-400 font-mono",children:"npx nestor-sh config set security.approvalMode smart"})]}),e.jsxs("p",{className:"text-xs text-zinc-500",children:["Modes: ",e.jsx("span",{className:"text-zinc-400",children:"auto"})," (no approvals) ·"," ",e.jsx("span",{className:"text-zinc-400",children:"smart"})," (risky actions only) ·"," ",e.jsx("span",{className:"text-zinc-400",children:"manual"})," (all actions)"]})]})}):e.jsx("div",{className:"space-y-3",children:c.map(A=>e.jsx(Ih,{approval:A,onApprove:Z,onReject:U,actionLoading:k,showActions:!0},A.id))})),i==="history"&&(f.length===0?e.jsx(cn,{icon:e.jsx(Hh,{className:"h-8 w-8"}),title:"No history",description:"Approval history will appear here after decisions are made."}):e.jsx("div",{className:"space-y-3",children:f.map(A=>e.jsx(Ih,{approval:A,actionLoading:null,showActions:!1},A.id))})),i==="stats"&&b&&e.jsx(n1,{stats:b})]})}const i1="/api";async function r1(n=30){const i=localStorage.getItem("nestor_token"),d={"Content-Type":"application/json"};i&&(d.Authorization=`Bearer ${i}`);const c=localStorage.getItem("nestor_tenant_id");c&&(d["X-Tenant-ID"]=c);try{const m=await fetch(`${i1}/analytics/quality?days=${n}`,{headers:d});return m.ok?(await m.json()).data??null:null}catch{return null}}function dc(n){return`${(n*100).toFixed(0)}%`}function G0(n){return n>0?`+${(n*100).toFixed(0)}%`:`${(n*100).toFixed(0)}%`}function Kr({label:n,value:i,icon:d,color:c,bgColor:m,subtitle:f}){return e.jsx("div",{className:"card",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-zinc-400",children:n}),e.jsx("p",{className:"mt-1 text-2xl font-semibold text-white",children:i}),f&&e.jsx("p",{className:"mt-0.5 text-xs text-zinc-500",children:f})]}),e.jsx("div",{className:`flex h-11 w-11 items-center justify-center rounded-xl ${m}`,children:e.jsx(d,{className:`h-5 w-5 ${c}`})})]})})}function c1({data:n}){return n.length===0?e.jsx("div",{className:"flex h-48 items-center justify-center text-zinc-500 text-sm",children:"No data available"}):e.jsx("div",{className:"flex items-end gap-1 h-48",children:n.map(i=>{const d=Math.max(i.successRate*100,2),c=i.successRate>=.8?"bg-emerald-500 hover:bg-emerald-400":i.successRate>=.5?"bg-amber-500 hover:bg-amber-400":"bg-red-500 hover:bg-red-400";return e.jsxs("div",{className:"flex-1 flex flex-col items-center min-w-0",children:[e.jsx("div",{className:`w-full rounded-t transition-all cursor-default min-h-[2px] ${c}`,style:{height:`${d}%`},title:`${i.date}: ${dc(i.successRate)} (${i.completedRuns}/${i.totalRuns} runs)`}),e.jsx("span",{className:"text-[10px] text-zinc-500 mt-1 truncate w-full text-center",children:i.date.slice(5)})]},i.date)})})}function o1({agents:n}){return n.length===0?e.jsx("p",{className:"text-zinc-500 text-sm",children:"No agent data available"}):e.jsx("div",{className:"space-y-2",children:n.map((i,d)=>{const c=i.score>=70?"text-emerald-400":i.score>=50?"text-amber-400":"text-red-400",m=i.score>=70?"bg-emerald-500":i.score>=50?"bg-amber-500":"bg-red-500";return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"w-6 text-xs text-zinc-500 text-right font-mono",children:["#",d+1]}),e.jsx("span",{className:"text-sm text-zinc-300 w-32 truncate",title:i.name,children:i.name}),e.jsx("div",{className:"flex-1 h-2 bg-zinc-800 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all ${m}`,style:{width:`${Math.min(i.score,100)}%`}})}),e.jsx("span",{className:`text-xs font-medium w-12 text-right ${c}`,children:i.score.toFixed(0)}),e.jsx("span",{className:"text-xs text-zinc-500 w-16 text-right",children:dc(i.successRate)})]},i.agentId)})})}function d1({items:n}){return n.length===0?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-zinc-500",children:[e.jsx(et,{className:"h-4 w-4 text-emerald-500"}),"All agents performing well"]}):e.jsx("div",{className:"space-y-2",children:n.map(i=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg bg-red-500/5 border border-red-500/20",children:[e.jsx(pt,{className:"h-4 w-4 text-red-400 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-sm text-zinc-300 truncate block",children:i.name}),e.jsx("span",{className:"text-xs text-zinc-500",children:i.issue})]}),e.jsx("span",{className:"text-xs text-red-400 font-mono",children:typeof i.metric=="number"&&i.metric<=1?dc(i.metric):G0(i.metric)})]},i.agentId))})}function u1({tools:n}){if(n.length===0)return e.jsx("p",{className:"text-zinc-500 text-sm",children:"No tool usage data"});const i=Math.max(...n.map(d=>d.count),1);return e.jsx("div",{className:"space-y-2",children:n.slice(0,10).map(d=>{const c=d.failRate>=.3?"text-red-400":d.failRate>=.1?"text-amber-400":"text-zinc-500";return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(cl,{className:"h-3.5 w-3.5 text-zinc-500 shrink-0"}),e.jsx("span",{className:"text-xs text-zinc-300 w-32 truncate font-mono",title:d.name,children:d.name}),e.jsx("div",{className:"flex-1 h-1.5 bg-zinc-800 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-indigo-500 rounded-full",style:{width:`${d.count/i*100}%`}})}),e.jsx("span",{className:"text-xs text-zinc-500 w-10 text-right",children:d.count}),e.jsxs("span",{className:`text-xs w-12 text-right ${c}`,children:[(d.failRate*100).toFixed(0),"% fail"]})]},d.name)})})}function m1({errors:n}){return n.length===0?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-zinc-500",children:[e.jsx(et,{className:"h-4 w-4 text-emerald-500"}),"No recurring errors detected"]}):e.jsx("div",{className:"space-y-2",children:n.slice(0,8).map((i,d)=>e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-lg bg-zinc-800/50",children:[e.jsx(z0,{className:"h-3.5 w-3.5 text-red-400 shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs text-zinc-300 font-mono break-all line-clamp-2",children:i.pattern}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[e.jsxs("span",{className:"text-[10px] text-zinc-500",children:[i.count," occurrences"]}),i.lastSeen&&e.jsxs("span",{className:"text-[10px] text-zinc-600",children:["Last: ",new Date(i.lastSeen).toLocaleDateString()]})]})]})]},d))})}function x1(){const[n,i]=u.useState(null),[d,c]=u.useState(!0),[m,f]=u.useState(null),[h,b]=u.useState(30);if(u.useEffect(()=>{async function S(){c(!0),f(null);const y=await r1(h);y?i(y):f("Failed to load quality metrics"),c(!1)}S()},[h]),d)return e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent"})});if(m||!n)return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] gap-3",children:[e.jsx(pt,{className:"h-8 w-8 text-amber-500"}),e.jsx("p",{className:"text-zinc-400",children:m??"No data available"})]});const g=n.overallFeedbackScore>=0?"text-emerald-400":"text-red-400",p=n.overallSuccessRate>=.8?"text-emerald-400":n.overallSuccessRate>=.5?"text-amber-400":"text-red-400";return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center gap-2",children:[7,14,30,90].map(S=>e.jsxs("button",{onClick:()=>b(S),className:`px-3 py-1 text-xs rounded-lg transition-colors ${h===S?"bg-indigo-500/20 text-indigo-400 border border-indigo-500/30":"bg-zinc-800/50 text-zinc-500 border border-zinc-700/50 hover:border-zinc-600"}`,children:[S,"d"]},S))}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(Kr,{label:"Total Runs",value:String(n.totalRuns),icon:It,color:"text-blue-400",bgColor:"bg-blue-400/10",subtitle:`Last ${h} days`}),e.jsx(Kr,{label:"Success Rate",value:dc(n.overallSuccessRate),icon:et,color:p,bgColor:n.overallSuccessRate>=.8?"bg-emerald-400/10":"bg-amber-400/10"}),e.jsx(Kr,{label:"Feedback Score",value:G0(n.overallFeedbackScore),icon:yi,color:g,bgColor:n.overallFeedbackScore>=0?"bg-emerald-400/10":"bg-red-400/10"}),e.jsx(Kr,{label:"Active Agents",value:`${n.activeAgents} / ${n.totalAgents}`,icon:rl,color:"text-purple-400",bgColor:"bg-purple-400/10"})]}),e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Rs,{className:"h-4 w-4 text-zinc-400"}),e.jsx("h2",{className:"text-lg font-medium text-white",children:"Success Rate Trend"})]}),e.jsx(c1,{data:n.dailySuccessRates})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(oc,{className:"h-4 w-4 text-zinc-400"}),e.jsx("h2",{className:"text-lg font-medium text-white",children:"Top Performers"})]}),e.jsx(o1,{agents:n.topPerformers})]}),e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(pt,{className:"h-4 w-4 text-zinc-400"}),e.jsx("h2",{className:"text-lg font-medium text-white",children:"Needs Attention"})]}),e.jsx(d1,{items:n.needsAttention})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(cl,{className:"h-4 w-4 text-zinc-400"}),e.jsx("h2",{className:"text-lg font-medium text-white",children:"Tool Performance"})]}),e.jsx(u1,{tools:n.toolPerformance})]}),e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(z0,{className:"h-4 w-4 text-zinc-400"}),e.jsx("h2",{className:"text-lg font-medium text-white",children:"Error Patterns"})]}),e.jsx(m1,{errors:n.errorPatterns})]})]})]})}function Vr({label:n,value:i,icon:d,color:c,bgColor:m,subtitle:f}){return e.jsx("div",{className:"card",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-zinc-400",children:n}),e.jsx("p",{className:"mt-1 text-2xl font-semibold text-white",children:i}),f&&e.jsx("p",{className:"mt-0.5 text-xs text-zinc-500",children:f})]}),e.jsx("div",{className:`flex h-11 w-11 items-center justify-center rounded-xl ${m}`,children:e.jsx(d,{className:`h-5 w-5 ${c}`})})]})})}const ui={"7d":{label:"7 jours",days:7,aggregate:"day"},"30d":{label:"30 jours",days:30,aggregate:"day"},"90d":{label:"3 mois",days:90,aggregate:"week"},"6m":{label:"6 mois",days:180,aggregate:"week"},"1y":{label:"1 an",days:365,aggregate:"month"}};function f1(n,i){if(i==="day"){const c=n.filter(m=>m.costUsd>0);return c.length>0?c:n.slice(-7)}const d=new Map;for(const c of n){let m;const f=new Date(c.date);if(i==="week"){const b=new Date(f);b.setDate(f.getDate()-f.getDay()+1),m=b.toISOString().slice(0,10)}else m=c.date.slice(0,7);const h=d.get(m)||{costUsd:0,runs:0};h.costUsd+=c.costUsd,h.runs+=c.runs,d.set(m,h)}return Array.from(d.entries()).map(([c,m])=>({date:c,costUsd:m.costUsd,runs:m.runs})).sort((c,m)=>c.date.localeCompare(m.date))}function h1({data:n,period:i,onPeriodChange:d}){const c=ui[i],m=f1(n,c.aggregate);if(m.length===0)return e.jsx("div",{className:"flex h-48 items-center justify-center text-zinc-500 text-sm",children:"No cost data available"});const f=Math.max(...m.map(g=>g.costUsd),.01),h=m.reduce((g,p)=>g+p.costUsd,0),b=m.reduce((g,p)=>g+p.runs,0);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"flex gap-1",children:Object.keys(ui).map(g=>e.jsx("button",{onClick:()=>d(g),className:`px-3 py-1 rounded text-xs font-medium transition-colors ${i===g?"bg-indigo-600 text-white":"bg-zinc-800 text-zinc-400 hover:bg-zinc-700"}`,children:ui[g].label},g))}),e.jsxs("div",{className:"text-xs text-zinc-500",children:["$",h.toFixed(2)," · ",b," runs · ",m.length," ",c.aggregate==="day"?"jours":c.aggregate==="week"?"semaines":"mois"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"flex flex-col justify-between h-48 text-right pr-1 text-[10px] text-zinc-600 w-12 flex-shrink-0",children:[e.jsxs("span",{children:["$",f.toFixed(2)]}),e.jsxs("span",{children:["$",(f*.75).toFixed(2)]}),e.jsxs("span",{children:["$",(f*.5).toFixed(2)]}),e.jsxs("span",{children:["$",(f*.25).toFixed(2)]}),e.jsx("span",{children:"$0"})]}),e.jsx("div",{className:"flex items-end gap-1 h-48 flex-1",children:m.map(g=>{const p=Math.max(g.costUsd/f*100,3),S=g.costUsd===f;return e.jsxs("div",{className:"flex-1 flex flex-col items-center min-w-0 group relative",children:[e.jsxs("div",{className:"absolute bottom-full mb-1 hidden group-hover:block bg-zinc-800 text-white text-xs px-2 py-1 rounded whitespace-nowrap z-10 pointer-events-none",children:["$",g.costUsd.toFixed(4)," · ",g.runs," runs"]}),e.jsx("div",{className:`w-full rounded-t transition-all cursor-default ${S?"bg-indigo-400":"bg-indigo-500 hover:bg-indigo-400"}`,style:{height:`${p}%`}}),e.jsx("span",{className:"text-[10px] text-zinc-500 mt-1 truncate w-full text-center",children:(c.aggregate==="month",g.date.slice(5))})]},g.date)})})]})]})}function Ma(n){return n<.01?`$${n.toFixed(4)}`:n<1?`$${n.toFixed(3)}`:`$${n.toFixed(2)}`}function Ph(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:String(n)}function p1(){const{t:n}=Je(),[i,d]=u.useState(null),[c,m]=u.useState([]),[f,h]=u.useState([]),[b,g]=u.useState(null),[p,S]=u.useState("30d"),[y,v]=u.useState(!0),[k,C]=u.useState(null);if(u.useEffect(()=>{async function N(){try{v(!0),C(null);const[z,R,D,O]=await Promise.all([In.summary(),In.daily(ui[p].days),In.budget(),In.estimate()]);d(z.data),m(R.data),h(D.data),g(O.data)}catch(z){C(z instanceof Error?z.message:"Failed to load analytics")}finally{v(!1)}}N()},[p]),y)return e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("p",{className:"text-zinc-400",children:n("common.loading")})});if(k)return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] gap-3",children:[e.jsx(pt,{className:"h-8 w-8 text-amber-500"}),e.jsx("p",{className:"text-zinc-400",children:k})]});const w=i&&i.totalRuns>0?i.totalCostUsd/i.totalRuns:0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(Vr,{label:n("analytics.totalSpend"),value:Ma((i==null?void 0:i.totalCostUsd)??0),icon:us,color:"text-emerald-400",bgColor:"bg-emerald-400/10"}),e.jsx(Vr,{label:n("analytics.totalRuns"),value:String((i==null?void 0:i.totalRuns)??0),icon:It,color:"text-blue-400",bgColor:"bg-blue-400/10",subtitle:`${Ph((i==null?void 0:i.totalTokens)??0)} tokens`}),e.jsx(Vr,{label:n("analytics.avgCostPerRun"),value:Ma(w),icon:fv,color:"text-amber-400",bgColor:"bg-amber-400/10"}),e.jsx(Vr,{label:n("analytics.monthlyEstimate"),value:Ma((b==null?void 0:b.estimatedUsd)??0),icon:oc,color:"text-purple-400",bgColor:"bg-purple-400/10",subtitle:b?`${b.confidence} confidence`:void 0})]}),e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Rs,{className:"h-4 w-4 text-zinc-400"}),e.jsxs("h2",{className:"text-lg font-medium text-white",children:[n("analytics.dailyCosts")," (",ui[p].label,")"]})]}),e.jsx(h1,{data:c,period:p,onPeriodChange:N=>{S(N)}})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"text-lg font-medium text-white mb-4",children:n("analytics.agentBreakdown")}),i&&i.byAgent.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border text-zinc-400",children:[e.jsx("th",{className:"text-left pb-2 font-medium",children:n("common.name")}),e.jsx("th",{className:"text-right pb-2 font-medium",children:n("analytics.runs")}),e.jsx("th",{className:"text-right pb-2 font-medium",children:n("analytics.totalCost")}),e.jsx("th",{className:"text-right pb-2 font-medium",children:n("analytics.avgCost")})]})}),e.jsx("tbody",{children:i.byAgent.map(N=>e.jsxs("tr",{className:"border-b border-border/50 hover:bg-surface-hover",children:[e.jsx("td",{className:"py-2 text-white",children:N.agentName}),e.jsx("td",{className:"py-2 text-right text-zinc-300",children:N.runs}),e.jsx("td",{className:"py-2 text-right text-zinc-300",children:Ma(N.costUsd)}),e.jsx("td",{className:"py-2 text-right text-zinc-300",children:Ma(N.runs>0?N.costUsd/N.runs:0)})]},N.agentId))})]})}):e.jsx("p",{className:"text-zinc-500 text-sm",children:n("analytics.noAgentData")})]}),e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"text-lg font-medium text-white mb-4",children:n("analytics.modelBreakdown")}),i&&i.byModel.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border text-zinc-400",children:[e.jsx("th",{className:"text-left pb-2 font-medium",children:n("analytics.model")}),e.jsx("th",{className:"text-right pb-2 font-medium",children:n("analytics.tokens")}),e.jsx("th",{className:"text-right pb-2 font-medium",children:n("analytics.cost")})]})}),e.jsx("tbody",{children:i.byModel.map(N=>e.jsxs("tr",{className:"border-b border-border/50 hover:bg-surface-hover",children:[e.jsx("td",{className:"py-2 text-white font-mono text-xs",children:N.model}),e.jsx("td",{className:"py-2 text-right text-zinc-300",children:Ph(N.tokens)}),e.jsx("td",{className:"py-2 text-right text-zinc-300",children:Ma(N.costUsd)})]},N.model))})]})}):e.jsx("p",{className:"text-zinc-500 text-sm",children:n("analytics.noModelData")})]})]}),f.length>0&&e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"text-lg font-medium text-white mb-4",children:n("analytics.budgetUtilization")}),e.jsx("div",{className:"space-y-3",children:f.map(N=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"text-sm text-zinc-300 w-32 truncate",children:N.name}),e.jsx("div",{className:"flex-1 h-2 bg-zinc-800 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all ${N.percent>=90?"bg-red-500":N.percent>=70?"bg-amber-500":"bg-indigo-500"}`,style:{width:`${Math.min(N.percent,100)}%`}})}),e.jsxs("span",{className:"text-xs text-zinc-400 w-24 text-right",children:[Ma(N.spentUsd)," / ",Ma(N.budgetUsd)]}),e.jsxs("span",{className:`text-xs font-medium w-12 text-right ${N.percent>=90?"text-red-400":N.percent>=70?"text-amber-400":"text-zinc-400"}`,children:[N.percent.toFixed(0),"%"]})]},N.agentId))})]})]})}function g1(){const{t:n}=Je(),[i,d]=u.useState("costs");return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-white",children:n("analytics.title")}),e.jsx("p",{className:"mt-1 text-sm text-zinc-400",children:n("analytics.description")})]})}),e.jsxs("div",{className:"flex items-center gap-1 border-b border-border",children:[e.jsx("button",{onClick:()=>d("costs"),className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${i==="costs"?"border-indigo-500 text-indigo-400":"border-transparent text-zinc-400 hover:text-zinc-300 hover:border-zinc-600"}`,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(us,{className:"h-4 w-4"}),"Costs"]})}),e.jsx("button",{onClick:()=>d("quality"),className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${i==="quality"?"border-indigo-500 text-indigo-400":"border-transparent text-zinc-400 hover:text-zinc-300 hover:border-zinc-600"}`,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(et,{className:"h-4 w-4"}),"Quality"]})})]}),i==="costs"&&e.jsx(p1,{}),i==="quality"&&e.jsx(x1,{})]})}function K0(n){return new Date(n).toLocaleString()}function vu(n){return n===void 0?"--":n<1e3?`${n}ms`:n<6e4?`${(n/1e3).toFixed(1)}s`:`${(n/6e4).toFixed(1)}m`}function ju(n){switch(n){case"ok":return e.jsx(et,{className:"h-4 w-4 text-emerald-400"});case"error":return e.jsx(ft,{className:"h-4 w-4 text-red-400"});default:return e.jsx(pt,{className:"h-4 w-4 text-zinc-500"})}}function V0(n){const i={ok:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20",error:"bg-red-500/10 text-red-400 border-red-500/20",unset:"bg-zinc-500/10 text-zinc-400 border-zinc-500/20"};return e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-medium ${i[n]??i.unset}`,children:[ju(n),n]})}function b1({span:n,traceStart:i,traceDuration:d}){if(d===0)return null;const c=(n.startTime-i)/d*100,m=Math.max((n.durationMs??0)/d*100,.5),f=n.status==="error"?"bg-red-500":n.kind==="server"?"bg-indigo-500":n.kind==="client"?"bg-cyan-500":"bg-emerald-500";return e.jsx("div",{className:"relative h-5 w-full rounded bg-zinc-800/50",children:e.jsx("div",{className:`absolute top-0.5 h-4 rounded ${f} opacity-80`,style:{left:`${Math.min(c,99)}%`,width:`${Math.min(m,100-c)}%`}})})}function y1({span:n,depth:i,traceStart:d,traceDuration:c}){const[m,f]=u.useState(!1),h=Object.keys(n.attributes).length>0||n.events.length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"border-b border-zinc-800/50 hover:bg-zinc-800/30 cursor-pointer transition-colors",onClick:()=>h&&f(!m),children:[e.jsx("td",{className:"py-2 px-3 text-sm font-mono text-zinc-300 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-1",style:{paddingLeft:`${i*16}px`},children:[h?m?e.jsx(na,{className:"h-3 w-3 text-zinc-500"}):e.jsx(ds,{className:"h-3 w-3 text-zinc-500"}):e.jsx("span",{className:"w-3"}),ju(n.status),e.jsx("span",{className:"ml-1",children:n.name})]})}),e.jsx("td",{className:"py-2 px-3 text-xs text-zinc-500 whitespace-nowrap",children:n.kind}),e.jsx("td",{className:"py-2 px-3 text-xs text-zinc-400 font-mono whitespace-nowrap text-right",children:vu(n.durationMs)}),e.jsx("td",{className:"py-2 px-3 w-1/3",children:e.jsx(b1,{span:n,traceStart:d,traceDuration:c})})]}),m&&e.jsx("tr",{className:"border-b border-zinc-800/50",children:e.jsx("td",{colSpan:4,className:"px-6 py-3 bg-zinc-900/50",children:e.jsxs("div",{style:{paddingLeft:`${i*16+16}px`},children:[Object.keys(n.attributes).length>0&&e.jsxs("div",{className:"mb-2",children:[e.jsx("p",{className:"text-xs font-semibold text-zinc-500 uppercase mb-1",children:"Attributes"}),e.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5",children:Object.entries(n.attributes).map(([b,g])=>e.jsxs("div",{className:"text-xs",children:[e.jsxs("span",{className:"text-zinc-500",children:[b,":"]})," ",e.jsx("span",{className:"text-zinc-300 font-mono",children:String(g)})]},b))})]}),n.events.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-zinc-500 uppercase mb-1",children:"Events"}),n.events.map((b,g)=>e.jsxs("div",{className:"text-xs mb-1",children:[e.jsx("span",{className:"text-amber-400",children:b.name}),e.jsxs("span",{className:"text-zinc-600 ml-2",children:["+",b.time-n.startTime,"ms"]}),b.attributes&&Object.entries(b.attributes).map(([p,S])=>e.jsxs("span",{className:"text-zinc-500 ml-2",children:[p,"=",String(S)]},p))]},g))]})]})})})]})}function v1(n){const i=new Map,d=[];for(const c of n)i.set(c.spanId,{span:c,children:[]});for(const c of n){const m=i.get(c.spanId);c.parentSpanId&&i.has(c.parentSpanId)?i.get(c.parentSpanId).children.push(m):d.push(m)}return d}function Y0(n,i=0){const d=[];for(const c of n)d.push({span:c.span,depth:i}),d.push(...Y0(c.children,i+1));return d}function j1({trace:n}){const i=n.startTime,d=n.durationMs??1,c=v1(n.spans),m=Y0(c);return e.jsxs("div",{className:"rounded-lg border border-zinc-800 bg-zinc-900/50 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-white",children:n.rootSpanName}),e.jsxs("p",{className:"text-xs text-zinc-500 mt-0.5",children:[K0(n.startTime)," · ",n.spanCount," spans · ",vu(n.durationMs)]})]}),V0(n.status)]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[600px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-zinc-800 text-xs text-zinc-500 uppercase",children:[e.jsx("th",{className:"py-2 px-3 text-left font-medium",children:"Span"}),e.jsx("th",{className:"py-2 px-3 text-left font-medium w-16",children:"Kind"}),e.jsx("th",{className:"py-2 px-3 text-right font-medium w-20",children:"Duration"}),e.jsx("th",{className:"py-2 px-3 text-left font-medium w-1/3",children:"Timeline"})]})}),e.jsx("tbody",{children:m.map(({span:f,depth:h})=>e.jsx(y1,{span:f,depth:h,traceStart:i,traceDuration:d},f.spanId))})]})}),e.jsx("div",{className:"border-t border-zinc-800 px-4 py-2",children:e.jsxs("p",{className:"text-xs text-zinc-600 font-mono",children:["traceId: ",n.traceId]})})]})}function N1(){const[n,i]=u.useState([]),[d,c]=u.useState(null),[m,f]=u.useState(null),[h,b]=u.useState(!0),[g,p]=u.useState(!1),[S,y]=u.useState(null),v=u.useCallback(async()=>{b(!0),y(null);try{const w=await Bd.list();i(w.data),p(w.meta.tracingEnabled)}catch(w){y(w instanceof Error?w.message:"Failed to load traces")}finally{b(!1)}},[]);u.useEffect(()=>{v()},[v]);const k=u.useCallback(async w=>{if(m===w){f(null),c(null);return}f(w);try{const N=await Bd.get(w);c(N.data)}catch{c(null)}},[m]),C=async()=>{try{await Bd.clear(),i([]),c(null),f(null)}catch{}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-white",children:"Traces"}),e.jsx("p",{className:"mt-1 text-sm text-zinc-400",children:"Distributed tracing for agent runs, HTTP requests, and orchestrations."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!g&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-500/20 bg-amber-500/10 px-3 py-1 text-xs font-medium text-amber-400",children:[e.jsx(pt,{className:"h-3 w-3"}),"Tracing disabled"]}),e.jsxs("button",{onClick:v,className:"inline-flex items-center gap-1.5 rounded-lg border border-zinc-700 bg-zinc-800 px-3 py-1.5 text-sm text-zinc-300 hover:bg-zinc-700 transition-colors",children:[e.jsx(xt,{className:"h-3.5 w-3.5"}),"Refresh"]}),e.jsxs("button",{onClick:C,className:"inline-flex items-center gap-1.5 rounded-lg border border-zinc-700 bg-zinc-800 px-3 py-1.5 text-sm text-red-400 hover:bg-zinc-700 transition-colors",children:[e.jsx(Ot,{className:"h-3.5 w-3.5"}),"Clear"]})]})]}),S&&e.jsx("div",{className:"rounded-lg border border-red-500/20 bg-red-500/10 p-4",children:e.jsx("p",{className:"text-sm text-red-400",children:S})}),h&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin h-6 w-6 border-2 border-indigo-500 border-t-transparent rounded-full"})}),!h&&n.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"mb-4 rounded-2xl bg-surface p-4 text-zinc-500",children:e.jsx(It,{className:"h-8 w-8"})}),e.jsx("h3",{className:"text-lg font-medium text-zinc-300",children:"No traces recorded"}),e.jsx("p",{className:"mt-1.5 max-w-md text-sm text-zinc-500",children:g?"Traces will appear here as agents run and HTTP requests are processed.":"Distributed tracing records the full execution path of agent runs, tool calls, and HTTP requests."}),e.jsxs("div",{className:"mt-4 space-y-3 text-left max-w-md",children:[!g&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-lg bg-zinc-900 border border-zinc-800 p-3",children:[e.jsx("p",{className:"text-xs text-zinc-500 mb-1.5 font-medium",children:"Enable via CLI:"}),e.jsx("code",{className:"text-xs text-indigo-400 font-mono block",children:"npx nestor-sh config set observability.tracing.enabled true"})]}),e.jsxs("div",{className:"rounded-lg bg-zinc-900 border border-zinc-800 p-3",children:[e.jsx("p",{className:"text-xs text-zinc-500 mb-1.5 font-medium",children:"Or in nestor.config.json:"}),e.jsx("pre",{className:"text-xs text-zinc-400 font-mono",children:`{
591
+ "observability": {
592
+ "tracing": { "enabled": true }
593
+ }
594
+ }`})]})]}),g&&e.jsxs("div",{className:"rounded-lg bg-zinc-900 border border-zinc-800 p-3",children:[e.jsx("p",{className:"text-xs text-zinc-500 mb-1.5 font-medium",children:"Traces are recorded when:"}),e.jsxs("ul",{className:"text-xs text-zinc-400 space-y-1 list-disc list-inside",children:[e.jsx("li",{children:"An agent run executes (chat, mission, workflow)"}),e.jsx("li",{children:"Tool calls are made (shell, file, HTTP)"}),e.jsx("li",{children:"API requests are processed by the server"})]})]}),e.jsx("p",{className:"text-xs text-zinc-500",children:"Each trace shows a waterfall timeline of spans, durations, and errors."})]})]}),!h&&n.length>0&&e.jsx("div",{className:"space-y-2",children:n.map(w=>e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>k(w.traceId),className:`w-full flex items-center justify-between rounded-lg border px-4 py-3 text-left transition-colors ${m===w.traceId?"border-indigo-500/30 bg-indigo-500/5":"border-zinc-800 bg-zinc-900/50 hover:bg-zinc-800/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[m===w.traceId?e.jsx(na,{className:"h-4 w-4 text-zinc-500 flex-shrink-0"}):e.jsx(ds,{className:"h-4 w-4 text-zinc-500 flex-shrink-0"}),ju(w.status),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-white truncate",children:w.rootSpanName}),e.jsx("p",{className:"text-xs text-zinc-500",children:K0(w.startTime)})]})]}),e.jsxs("div",{className:"flex items-center gap-4 flex-shrink-0",children:[e.jsxs("span",{className:"text-xs text-zinc-500",children:[w.spanCount," span",w.spanCount!==1?"s":""]}),e.jsx("span",{className:"text-xs font-mono text-zinc-400 w-16 text-right",children:vu(w.durationMs)}),V0(w.status)]})]}),m===w.traceId&&d&&e.jsx("div",{className:"mt-2 ml-4",children:e.jsx(j1,{trace:d})})]},w.traceId))})]})}function X0(){const{login:n,register:i}=ol(),d=Dt(),[c,m]=u.useState("login"),[f,h]=u.useState(""),[b,g]=u.useState(""),[p,S]=u.useState(""),[y,v]=u.useState(""),[k,C]=u.useState(!1),w=async N=>{N.preventDefault(),v(""),C(!0);try{c==="register"?(await i(f,b,p),await n(f,b)):await n(f,b),d("/",{replace:!0})}catch(z){v(z.message||"An error occurred.")}finally{C(!1)}};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4",children:e.jsxs("div",{className:"w-full max-w-sm",children:[e.jsxs("div",{className:"mb-8 flex flex-col items-center gap-3",children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-xl bg-indigo-600 text-white",children:e.jsx(sa,{className:"h-6 w-6"})}),e.jsx("h1",{className:"text-2xl font-semibold text-white",children:"Nestor Studio"}),e.jsx("p",{className:"text-sm text-zinc-400",children:c==="login"?"Sign in to your account":"Create a new account"})]}),e.jsxs("form",{onSubmit:w,className:"space-y-4",children:[y&&e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-400",children:[e.jsx(xi,{className:"h-4 w-4 flex-shrink-0"}),y]}),c==="register"&&e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-sm font-medium text-zinc-300",children:"Name"}),e.jsx("input",{type:"text",value:p,onChange:N=>S(N.target.value),required:!0,className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-sm text-white placeholder:text-zinc-500 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500",placeholder:"Your name"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-sm font-medium text-zinc-300",children:"Email"}),e.jsx("input",{type:"email",value:f,onChange:N=>h(N.target.value),required:!0,className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-sm text-white placeholder:text-zinc-500 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500",placeholder:"you@example.com"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-sm font-medium text-zinc-300",children:"Password"}),e.jsx("input",{type:"password",value:b,onChange:N=>g(N.target.value),required:!0,minLength:c==="register"?6:1,className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-sm text-white placeholder:text-zinc-500 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500",placeholder:c==="register"?"At least 6 characters":"Your password"})]}),e.jsx("button",{type:"submit",disabled:k,className:"flex w-full items-center justify-center gap-2 rounded-lg bg-indigo-600 px-4 py-2.5 text-sm font-medium text-white transition-colors hover:bg-indigo-700 disabled:opacity-50",children:k?"Please wait...":c==="login"?e.jsxs(e.Fragment,{children:[e.jsx(kv,{className:"h-4 w-4"})," Sign In"]}):e.jsxs(e.Fragment,{children:[e.jsx(Hv,{className:"h-4 w-4"})," Create Account"]})})]}),e.jsx("div",{className:"mt-6 text-center",children:e.jsx("button",{type:"button",onClick:()=>{m(c==="login"?"register":"login"),v("")},className:"text-sm text-zinc-400 transition-colors hover:text-indigo-400",children:c==="login"?"Don't have an account? Register":"Already have an account? Sign in"})})]})})}function w1(){const{isAdmin:n}=ol(),[i,d]=u.useState([]),[c,m]=u.useState([]),[f,h]=u.useState("users"),[b,g]=u.useState(!0),[p,S]=u.useState(""),y=u.useCallback(async()=>{try{const w=await fetch("/api/users",{credentials:"include"}),N=await w.json();w.ok&&d(N.data||[])}catch{}},[]),v=u.useCallback(async()=>{try{const w=await fetch("/api/users/audit?limit=50",{credentials:"include"}),N=await w.json();w.ok&&m(N.data||[])}catch{}},[]);u.useEffect(()=>{g(!0),Promise.all([y(),v()]).finally(()=>g(!1))},[y,v]);const k=async(w,N)=>{var z;S("");try{const R=await fetch(`/api/users/${w}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({role:N})});if(!R.ok){const D=await R.json();throw new Error(((z=D.error)==null?void 0:z.message)||"Failed to update role.")}await y()}catch(R){S(R.message)}},C=async w=>{var N;if(confirm("Are you sure you want to delete this user?")){S("");try{const z=await fetch(`/api/users/${w}`,{method:"DELETE",credentials:"include"});if(!z.ok){const R=await z.json();throw new Error(((N=R.error)==null?void 0:N.message)||"Failed to delete user.")}await y()}catch(z){S(z.message)}}};return n?e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-white",children:"User Management"}),e.jsx("p",{className:"mt-1 text-sm text-zinc-400",children:"Manage users, roles, and view audit log."})]})}),p&&e.jsx("div",{className:"rounded-lg border border-red-500/30 bg-red-500/10 px-4 py-2 text-sm text-red-400",children:p}),e.jsxs("div",{className:"flex gap-1 border-b border-border",children:[e.jsxs("button",{onClick:()=>h("users"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium transition-colors ${f==="users"?"border-b-2 border-indigo-500 text-indigo-400":"text-zinc-400 hover:text-zinc-200"}`,children:[e.jsx(rl,{className:"h-4 w-4"})," Users (",i.length,")"]}),e.jsxs("button",{onClick:()=>h("audit"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium transition-colors ${f==="audit"?"border-b-2 border-indigo-500 text-indigo-400":"text-zinc-400 hover:text-zinc-200"}`,children:[e.jsx(Ua,{className:"h-4 w-4"})," Audit Log"]})]}),b?e.jsx("div",{className:"text-center text-zinc-400 py-8",children:"Loading..."}):f==="users"?e.jsx("div",{className:"overflow-x-auto rounded-lg border border-border",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border bg-surface",children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Name"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Email"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Role"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Provider"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Last Login"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium uppercase text-zinc-400",children:"Actions"})]})}),e.jsxs("tbody",{children:[i.map(w=>e.jsxs("tr",{className:"border-b border-border/50 hover:bg-surface-hover",children:[e.jsx("td",{className:"px-4 py-3 font-medium text-white",children:w.name}),e.jsx("td",{className:"px-4 py-3 text-zinc-300",children:w.email}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("select",{value:w.role,onChange:N=>k(w.id,N.target.value),className:"rounded border border-border bg-background px-2 py-1 text-xs text-white focus:outline-none",children:[e.jsx("option",{value:"admin",children:"Admin"}),e.jsx("option",{value:"member",children:"Member"}),e.jsx("option",{value:"viewer",children:"Viewer"})]})}),e.jsx("td",{className:"px-4 py-3 text-zinc-400",children:w.authProvider}),e.jsx("td",{className:"px-4 py-3 text-zinc-400",children:w.lastLoginAt?new Date(w.lastLoginAt*1e3).toLocaleString():"Never"}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx("button",{onClick:()=>C(w.id),className:"rounded p-1.5 text-zinc-400 transition-colors hover:bg-red-500/10 hover:text-red-400",title:"Delete user",children:e.jsx(Ot,{className:"h-4 w-4"})})})]},w.id)),i.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-4 py-8 text-center text-zinc-500",children:"No users found."})})]})]})}):e.jsx("div",{className:"overflow-x-auto rounded-lg border border-border",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border bg-surface",children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Time"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Action"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Resource"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"User"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Details"})]})}),e.jsxs("tbody",{children:[c.map(w=>{var N;return e.jsxs("tr",{className:"border-b border-border/50 hover:bg-surface-hover",children:[e.jsx("td",{className:"px-4 py-3 text-zinc-400 whitespace-nowrap",children:new Date(w.createdAt*1e3).toLocaleString()}),e.jsx("td",{className:"px-4 py-3 font-mono text-xs text-indigo-400",children:w.action}),e.jsx("td",{className:"px-4 py-3 text-zinc-300",children:w.resourceType&&e.jsxs("span",{children:[w.resourceType,w.resourceId?`/${w.resourceId.slice(0,8)}`:""]})}),e.jsx("td",{className:"px-4 py-3 text-zinc-400",children:((N=w.userId)==null?void 0:N.slice(0,8))||"-"}),e.jsx("td",{className:"px-4 py-3 text-xs text-zinc-500 max-w-xs truncate",children:w.details?JSON.stringify(w.details):"-"})]},w.id)}),c.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"px-4 py-8 text-center text-zinc-500",children:"No audit entries."})})]})]})})]}):e.jsxs("div",{className:"flex h-64 items-center justify-center text-zinc-400",children:[e.jsx(Ds,{className:"mr-2 h-5 w-5"})," Admin access required."]})}function Gd({label:n,valueA:i,valueB:d,format:c}){const m=Math.max(i,d,.001);return e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs text-zinc-400",children:n}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-12 text-right text-xs text-indigo-400",children:c(i)}),e.jsxs("div",{className:"flex-1 flex gap-0.5",children:[e.jsx("div",{className:"h-4 rounded-l bg-indigo-500/40",style:{width:`${i/m*50}%`}}),e.jsx("div",{className:"h-4 rounded-r bg-emerald-500/40",style:{width:`${d/m*50}%`}})]}),e.jsx("span",{className:"w-12 text-left text-xs text-emerald-400",children:c(d)})]})]})}function S1(){const{id:n}=ll(),[i,d]=u.useState([]),[c,m]=u.useState([]),[f,h]=u.useState(!0),[b,g]=u.useState(""),[p,S]=u.useState(!1),[y,v]=u.useState(""),[k,C]=u.useState(""),[w,N]=u.useState(""),[z,R]=u.useState(""),[D,O]=u.useState(null),[se,Z]=u.useState(!1),[U,A]=u.useState(""),[F,$]=u.useState(""),[Q,ce]=u.useState(""),[I,le]=u.useState(50),[Y,B]=u.useState([]),[ne,me]=u.useState({}),[ue,je]=u.useState(!1),[T,P]=u.useState(""),[de,G]=u.useState(""),[oe,fe]=u.useState(""),[be,Ce]=u.useState(.5),ve=u.useCallback(async()=>{if(n){try{const[L,te,ye]=await Promise.all([fetch(`/api/agents/${n}/prompts`,{credentials:"include"}),fetch(`/api/agents/${n}/prompts/ab-tests`,{credentials:"include"}),fetch(`/api/agents/${n}/experiments`,{credentials:"include"})]),We=await L.json(),fs=await te.json(),hs=await ye.json();if(L.ok&&d(We.data||[]),te.ok&&m(fs.data||[]),ye.ok){const yt=hs.data||[];B(yt);for(const dn of yt)try{const $a=await fetch(`/api/experiments/${dn.id}`,{credentials:"include"});if($a.ok){const Ba=await $a.json();me(Os=>({...Os,[dn.id]:Ba.data}))}}catch{}}}catch{}h(!1)}},[n]);u.useEffect(()=>{ve()},[ve]);const tt=async()=>{var L;if(!(!n||!y.trim())){g("");try{const te=await fetch(`/api/agents/${n}/prompts`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({systemPrompt:y,name:k||void 0})});if(!te.ok){const ye=await te.json();throw new Error(((L=ye.error)==null?void 0:L.message)||"Failed")}S(!1),v(""),C(""),await ve()}catch(te){g(te.message)}}},Xe=async L=>{var te;if(n){g("");try{const ye=await fetch(`/api/agents/${n}/prompts/${L}/activate`,{method:"PATCH",credentials:"include"});if(!ye.ok){const We=await ye.json();throw new Error(((te=We.error)==null?void 0:te.message)||"Failed")}await ve()}catch(ye){g(ye.message)}}},Lt=async()=>{if(!(!n||!w||!z))try{const L=await fetch(`/api/agents/${n}/prompts/compare?a=${w}&b=${z}`,{credentials:"include"}),te=await L.json();L.ok&&O(te.data)}catch{}},Ns=async()=>{var L;if(!(!n||!U||!F)){g("");try{const te=await fetch(`/api/agents/${n}/prompts/ab-tests`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({variantAId:U,variantBId:F,name:Q||void 0,splitPercent:I})});if(!te.ok){const ye=await te.json();throw new Error(((L=ye.error)==null?void 0:L.message)||"Failed")}Z(!1),await ve()}catch(te){g(te.message)}}},At=async(L,te)=>{if(n)try{(await fetch(`/api/agents/${n}/prompts/ab-tests/${L}/complete`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({winnerId:te})})).ok&&await ve()}catch{}},Kt=async()=>{if(n){g("");try{const L=i.find(We=>We.isActive);if(!L){g("No active version to rollback from.");return}const te=i.indexOf(L),ye=i[te+1];if(!ye){g("No previous version to rollback to.");return}await Xe(ye.id)}catch(L){g(L.message)}}},qe=async()=>{var L;if(!(!n||!T||!de)){g("");try{const te=await fetch(`/api/agents/${n}/experiments`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:oe||`Experiment ${new Date().toISOString().slice(0,10)}`,variantAId:T,variantBId:de,trafficSplit:be})});if(!te.ok){const ye=await te.json();throw new Error(((L=ye.error)==null?void 0:L.message)||"Failed")}je(!1),fe(""),P(""),G(""),await ve()}catch(te){g(te.message)}}},nt=async(L,te)=>{try{(await fetch(`/api/experiments/${L}/complete`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({winnerId:te})})).ok&&await ve()}catch{}};return f?e.jsx("div",{className:"flex h-64 items-center justify-center text-zinc-400",children:"Loading..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-white",children:"Prompt Versions"}),e.jsx("p",{className:"mt-1 text-sm text-zinc-400",children:"Manage, compare, and A/B test prompt versions for this agent."})]}),e.jsxs("div",{className:"flex gap-2",children:[i.length>=2&&e.jsxs("button",{onClick:Kt,className:"flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-2 text-sm text-zinc-300 hover:bg-surface-hover",children:[e.jsx(D0,{className:"h-4 w-4"})," Rollback"]}),e.jsxs("button",{onClick:()=>je(!0),className:"flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-2 text-sm text-zinc-300 hover:bg-surface-hover",children:[e.jsx(It,{className:"h-4 w-4"})," New Experiment"]}),e.jsxs("button",{onClick:()=>Z(!0),className:"flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-2 text-sm text-zinc-300 hover:bg-surface-hover",children:[e.jsx($d,{className:"h-4 w-4"})," New A/B Test"]}),e.jsxs("button",{onClick:()=>S(!0),className:"flex items-center gap-2 rounded-lg bg-indigo-600 px-3 py-2 text-sm font-medium text-white hover:bg-indigo-700",children:[e.jsx(ht,{className:"h-4 w-4"})," New Version"]})]})]}),b&&e.jsx("div",{className:"rounded-lg border border-red-500/30 bg-red-500/10 px-4 py-2 text-sm text-red-400",children:b}),p&&e.jsxs("div",{className:"rounded-lg border border-border bg-surface p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-white",children:"Create New Version"}),e.jsx("button",{onClick:()=>S(!1),className:"text-zinc-400 hover:text-white",children:e.jsx(Ze,{className:"h-4 w-4"})})]}),e.jsx("input",{type:"text",value:k,onChange:L=>C(L.target.value),placeholder:"Version name (optional)",className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-white"}),e.jsx("textarea",{value:y,onChange:L=>v(L.target.value),placeholder:"System prompt...",rows:8,className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-white font-mono"}),e.jsx("button",{onClick:tt,disabled:!y.trim(),className:"rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 disabled:opacity-50",children:"Create Version"})]}),e.jsxs("div",{className:"space-y-2",children:[i.map(L=>e.jsxs("div",{className:`rounded-lg border p-4 ${L.isActive?"border-indigo-500/50 bg-indigo-500/5":"border-border bg-surface"}`,children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-surface text-sm font-bold text-zinc-300",children:["v",L.version]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-white",children:L.name||`Version ${L.version}`}),L.isActive&&e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-green-500/20 px-2 py-0.5 text-xs text-green-400",children:[e.jsx(et,{className:"h-3 w-3"})," Active"]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-4 text-xs text-zinc-400",children:[e.jsxs("span",{children:[L.totalRuns," runs"]}),e.jsxs("span",{children:["Score: ",L.performanceScore!=null?`${(L.performanceScore*100).toFixed(0)}%`:"N/A"]}),e.jsxs("span",{children:["Avg cost: $",L.avgCostUsd.toFixed(4)]}),e.jsxs("span",{children:["Avg duration: ",L.avgDurationMs.toFixed(0),"ms"]})]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:!L.isActive&&e.jsx("button",{onClick:()=>Xe(L.id),className:"rounded-lg border border-border px-3 py-1.5 text-xs text-zinc-300 hover:bg-surface-hover",children:"Activate"})})]}),e.jsx("div",{className:"mt-3 rounded-lg bg-background p-3",children:e.jsxs("pre",{className:"max-h-24 overflow-y-auto text-xs text-zinc-400 font-mono whitespace-pre-wrap",children:[L.systemPrompt.slice(0,500),L.systemPrompt.length>500?"...":""]})})]},L.id)),i.length===0&&e.jsxs("div",{className:"rounded-lg border border-border bg-surface p-8 text-center text-zinc-400",children:[e.jsx(Ua,{className:"mx-auto mb-2 h-8 w-8"}),"No prompt versions yet. Create your first version."]})]}),i.length>=2&&e.jsxs("div",{className:"rounded-lg border border-border bg-surface p-4 space-y-3",children:[e.jsxs("h3",{className:"flex items-center gap-2 text-sm font-medium text-white",children:[e.jsx(Rs,{className:"h-4 w-4"})," Compare Versions"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("select",{value:w,onChange:L=>N(L.target.value),className:"flex-1 rounded-lg border border-border bg-background px-3 py-2 text-sm text-white",children:[e.jsx("option",{value:"",children:"Select version A"}),i.map(L=>e.jsxs("option",{value:L.id,children:["v",L.version," - ",L.name||`Version ${L.version}`]},L.id))]}),e.jsx(k0,{className:"h-4 w-4 text-zinc-400 flex-shrink-0"}),e.jsxs("select",{value:z,onChange:L=>R(L.target.value),className:"flex-1 rounded-lg border border-border bg-background px-3 py-2 text-sm text-white",children:[e.jsx("option",{value:"",children:"Select version B"}),i.map(L=>e.jsxs("option",{value:L.id,children:["v",L.version," - ",L.name||`Version ${L.version}`]},L.id))]}),e.jsx("button",{onClick:Lt,disabled:!w||!z||w===z,className:"rounded-lg bg-indigo-600 px-4 py-2 text-sm text-white hover:bg-indigo-700 disabled:opacity-50",children:"Compare"})]}),D&&e.jsxs("div",{className:"grid grid-cols-2 gap-4 mt-4",children:[e.jsxs("div",{className:"rounded-lg border border-border bg-background p-3",children:[e.jsxs("h4",{className:"text-sm font-medium text-indigo-400 mb-2",children:["Variant A (v",D.variantA.version,")"]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-zinc-400",children:"Success Rate"}),e.jsxs("span",{className:"text-white",children:[(D.aSuccessRate*100).toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-zinc-400",children:"Avg Cost"}),e.jsxs("span",{className:"text-white",children:["$",D.aCostAvg.toFixed(4)]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-zinc-400",children:"Avg Duration"}),e.jsxs("span",{className:"text-white",children:[D.aDurationAvg.toFixed(0),"ms"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-zinc-400",children:"Total Runs"}),e.jsx("span",{className:"text-white",children:D.variantA.totalRuns})]})]})]}),e.jsxs("div",{className:"rounded-lg border border-border bg-background p-3",children:[e.jsxs("h4",{className:"text-sm font-medium text-emerald-400 mb-2",children:["Variant B (v",D.variantB.version,")"]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-zinc-400",children:"Success Rate"}),e.jsxs("span",{className:"text-white",children:[(D.bSuccessRate*100).toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-zinc-400",children:"Avg Cost"}),e.jsxs("span",{className:"text-white",children:["$",D.bCostAvg.toFixed(4)]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-zinc-400",children:"Avg Duration"}),e.jsxs("span",{className:"text-white",children:[D.bDurationAvg.toFixed(0),"ms"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-zinc-400",children:"Total Runs"}),e.jsx("span",{className:"text-white",children:D.variantB.totalRuns})]})]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"flex items-center gap-2 text-lg font-medium text-white",children:[e.jsx($d,{className:"h-5 w-5"})," A/B Tests"]}),se&&e.jsxs("div",{className:"rounded-lg border border-border bg-surface p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-medium text-white",children:"New A/B Test"}),e.jsx("button",{onClick:()=>Z(!1),className:"text-zinc-400 hover:text-white",children:e.jsx(Ze,{className:"h-4 w-4"})})]}),e.jsx("input",{type:"text",value:Q,onChange:L=>ce(L.target.value),placeholder:"Test name (optional)",className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-white"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("select",{value:U,onChange:L=>A(L.target.value),className:"rounded-lg border border-border bg-background px-3 py-2 text-sm text-white",children:[e.jsx("option",{value:"",children:"Variant A"}),i.map(L=>e.jsxs("option",{value:L.id,children:["v",L.version," - ",L.name||`Version ${L.version}`]},L.id))]}),e.jsxs("select",{value:F,onChange:L=>$(L.target.value),className:"rounded-lg border border-border bg-background px-3 py-2 text-sm text-white",children:[e.jsx("option",{value:"",children:"Variant B"}),i.map(L=>e.jsxs("option",{value:L.id,children:["v",L.version," - ",L.name||`Version ${L.version}`]},L.id))]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs text-zinc-400",children:["Traffic split: ",I,"% A / ",100-I,"% B"]}),e.jsx("input",{type:"range",min:10,max:90,value:I,onChange:L=>le(Number(L.target.value)),className:"w-full"})]}),e.jsx("button",{onClick:Ns,disabled:!U||!F||U===F,className:"rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 disabled:opacity-50",children:"Start Test"})]}),c.map(L=>{const te=i.find(We=>We.id===L.variantAId),ye=i.find(We=>We.id===L.variantBId);return e.jsxs("div",{className:"rounded-lg border border-border bg-surface p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($d,{className:"h-4 w-4 text-indigo-400"}),e.jsx("span",{className:"font-medium text-white",children:L.name}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs ${L.status==="running"?"bg-green-500/20 text-green-400":L.status==="completed"?"bg-blue-500/20 text-blue-400":"bg-zinc-500/20 text-zinc-400"}`,children:L.status})]}),e.jsxs("span",{className:"text-xs text-zinc-400",children:[L.totalRuns," runs"]})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-3 text-xs",children:[e.jsxs("div",{className:"rounded bg-background p-2",children:[e.jsxs("div",{className:"text-zinc-400",children:["Variant A (",L.splitPercent,"%)"]}),e.jsxs("div",{className:"text-white mt-1",children:["v",(te==null?void 0:te.version)??"?"," - ",(te==null?void 0:te.name)||"unnamed"]}),te&&e.jsxs("div",{className:"text-zinc-400 mt-1",children:["Score: ",te.performanceScore!=null?`${(te.performanceScore*100).toFixed(0)}%`:"N/A"]})]}),e.jsxs("div",{className:"rounded bg-background p-2",children:[e.jsxs("div",{className:"text-zinc-400",children:["Variant B (",100-L.splitPercent,"%)"]}),e.jsxs("div",{className:"text-white mt-1",children:["v",(ye==null?void 0:ye.version)??"?"," - ",(ye==null?void 0:ye.name)||"unnamed"]}),ye&&e.jsxs("div",{className:"text-zinc-400 mt-1",children:["Score: ",ye.performanceScore!=null?`${(ye.performanceScore*100).toFixed(0)}%`:"N/A"]})]})]}),L.status==="running"&&te&&ye&&e.jsxs("div",{className:"mt-3 flex gap-2",children:[e.jsxs("button",{onClick:()=>At(L.id,L.variantAId),className:"flex items-center gap-1 rounded-lg border border-border px-3 py-1.5 text-xs text-indigo-400 hover:bg-surface-hover",children:[e.jsx(Jn,{className:"h-3 w-3"})," A wins"]}),e.jsxs("button",{onClick:()=>At(L.id,L.variantBId),className:"flex items-center gap-1 rounded-lg border border-border px-3 py-1.5 text-xs text-emerald-400 hover:bg-surface-hover",children:[e.jsx(Jn,{className:"h-3 w-3"})," B wins"]})]}),L.winnerId&&e.jsxs("div",{className:"mt-2 flex items-center gap-1 text-xs text-yellow-400",children:[e.jsx(Jn,{className:"h-3 w-3"}),"Winner: v",L.winnerId===L.variantAId?te==null?void 0:te.version:ye==null?void 0:ye.version]})]},L.id)}),c.length===0&&!se&&e.jsx("div",{className:"rounded-lg border border-border bg-surface p-6 text-center text-zinc-400 text-sm",children:"No A/B tests yet. Create one to compare prompt performance."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"flex items-center gap-2 text-lg font-medium text-white",children:[e.jsx(It,{className:"h-5 w-5"})," Experiments"]}),ue&&e.jsxs("div",{className:"rounded-lg border border-border bg-surface p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-medium text-white",children:"New Experiment"}),e.jsx("button",{onClick:()=>je(!1),className:"text-zinc-400 hover:text-white",children:e.jsx(Ze,{className:"h-4 w-4"})})]}),e.jsx("input",{type:"text",value:oe,onChange:L=>fe(L.target.value),placeholder:"Experiment name",className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-white"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("select",{value:T,onChange:L=>P(L.target.value),className:"rounded-lg border border-border bg-background px-3 py-2 text-sm text-white",children:[e.jsx("option",{value:"",children:"Variant A"}),i.map(L=>e.jsxs("option",{value:L.id,children:["v",L.version," - ",L.name||`Version ${L.version}`]},L.id))]}),e.jsxs("select",{value:de,onChange:L=>G(L.target.value),className:"rounded-lg border border-border bg-background px-3 py-2 text-sm text-white",children:[e.jsx("option",{value:"",children:"Variant B"}),i.map(L=>e.jsxs("option",{value:L.id,children:["v",L.version," - ",L.name||`Version ${L.version}`]},L.id))]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs text-zinc-400",children:["Traffic split: ",Math.round(be*100),"% A / ",Math.round((1-be)*100),"% B"]}),e.jsx("input",{type:"range",min:10,max:90,value:be*100,onChange:L=>Ce(Number(L.target.value)/100),className:"w-full"})]}),e.jsx("button",{onClick:qe,disabled:!T||!de||T===de,className:"rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 disabled:opacity-50",children:"Start Experiment"})]}),Y.map(L=>{const te=ne[L.id];return e.jsxs("div",{className:"rounded-lg border border-border bg-surface p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(It,{className:"h-4 w-4 text-indigo-400"}),e.jsx("span",{className:"font-medium text-white",children:L.name}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs ${L.status==="running"?"bg-green-500/20 text-green-400":L.status==="completed"?"bg-blue-500/20 text-blue-400":L.status==="paused"?"bg-yellow-500/20 text-yellow-400":"bg-zinc-500/20 text-zinc-400"}`,children:L.status})]}),e.jsxs("span",{className:"text-xs text-zinc-400",children:["Split: ",Math.round(L.trafficSplit*100),"% / ",Math.round((1-L.trafficSplit)*100),"%"]})]}),te&&e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"rounded-lg border border-indigo-500/20 bg-background p-3",children:[e.jsxs("h5",{className:"text-xs font-medium text-indigo-400 mb-2",children:["Variant A (v",te.variantA.version.version,")"]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-zinc-400",children:"Runs"}),e.jsx("span",{className:"text-white",children:te.variantA.runs})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-zinc-400",children:"Success Rate"}),e.jsxs("span",{className:"text-white",children:[(te.variantA.successRate*100).toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-zinc-400",children:"Avg Cost"}),e.jsxs("span",{className:"text-white",children:["$",te.variantA.avgCostUsd.toFixed(4)]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-zinc-400",children:"Avg Duration"}),e.jsxs("span",{className:"text-white",children:[te.variantA.avgDurationMs.toFixed(0),"ms"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-zinc-400",children:"Avg Feedback"}),e.jsx("span",{className:"text-white",children:te.variantA.avgFeedbackScore.toFixed(2)})]})]})]}),e.jsxs("div",{className:"rounded-lg border border-emerald-500/20 bg-background p-3",children:[e.jsxs("h5",{className:"text-xs font-medium text-emerald-400 mb-2",children:["Variant B (v",te.variantB.version.version,")"]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-zinc-400",children:"Runs"}),e.jsx("span",{className:"text-white",children:te.variantB.runs})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-zinc-400",children:"Success Rate"}),e.jsxs("span",{className:"text-white",children:[(te.variantB.successRate*100).toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-zinc-400",children:"Avg Cost"}),e.jsxs("span",{className:"text-white",children:["$",te.variantB.avgCostUsd.toFixed(4)]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-zinc-400",children:"Avg Duration"}),e.jsxs("span",{className:"text-white",children:[te.variantB.avgDurationMs.toFixed(0),"ms"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-zinc-400",children:"Avg Feedback"}),e.jsx("span",{className:"text-white",children:te.variantB.avgFeedbackScore.toFixed(2)})]})]})]})]}),e.jsxs("div",{className:"space-y-2 rounded-lg bg-background p-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs mb-2",children:[e.jsx("span",{className:"text-indigo-400",children:"Variant A"}),e.jsx("span",{className:"text-emerald-400",children:"Variant B"})]}),e.jsx(Gd,{label:"Success Rate",valueA:te.variantA.successRate,valueB:te.variantB.successRate,format:ye=>`${(ye*100).toFixed(0)}%`}),e.jsx(Gd,{label:"Avg Cost",valueA:te.variantA.avgCostUsd,valueB:te.variantB.avgCostUsd,format:ye=>`$${ye.toFixed(3)}`}),e.jsx(Gd,{label:"Duration",valueA:te.variantA.avgDurationMs,valueB:te.variantB.avgDurationMs,format:ye=>`${ye.toFixed(0)}ms`})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-background p-3 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rs,{className:"h-3.5 w-3.5 text-zinc-400"}),e.jsxs("span",{className:"text-zinc-400",children:["p-value: ",te.statisticalSignificance.toFixed(4)]}),te.statisticalSignificance<.05&&e.jsx("span",{className:"rounded-full bg-green-500/20 px-2 py-0.5 text-green-400",children:"Significant"})]}),e.jsx("span",{className:`font-medium ${te.recommendation==="A"?"text-indigo-400":te.recommendation==="B"?"text-emerald-400":"text-zinc-400"}`,children:te.recommendation==="insufficient_data"?"Need more data":`Recommendation: Variant ${te.recommendation}`})]}),L.status==="running"&&te.variantA.runs>0&&te.variantB.runs>0&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:()=>nt(L.id,L.variantAId),className:"flex items-center gap-1 rounded-lg border border-border px-3 py-1.5 text-xs text-indigo-400 hover:bg-surface-hover",children:[e.jsx(Jn,{className:"h-3 w-3"})," A wins"]}),e.jsxs("button",{onClick:()=>nt(L.id,L.variantBId),className:"flex items-center gap-1 rounded-lg border border-border px-3 py-1.5 text-xs text-emerald-400 hover:bg-surface-hover",children:[e.jsx(Jn,{className:"h-3 w-3"})," B wins"]})]}),L.winnerId&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-yellow-400",children:[e.jsx(Jn,{className:"h-3 w-3"}),"Winner: ",L.winnerId===L.variantAId?"Variant A":"Variant B"]})]}),!te&&e.jsx("div",{className:"mt-3 text-xs text-zinc-500",children:"No runs yet. Run the agent to start collecting data."})]},L.id)}),Y.length===0&&!ue&&e.jsx("div",{className:"rounded-lg border border-border bg-surface p-6 text-center text-zinc-400 text-sm",children:"No experiments yet. Create one to A/B test prompts with per-run metrics and statistical analysis."})]})]})}const Q0="/api";async function Yr(n){const i=localStorage.getItem("nestor_token"),d={"Content-Type":"application/json"};i&&(d.Authorization=`Bearer ${i}`);const c=await fetch(`${Q0}${n}`,{headers:d});if(!c.ok)throw new Error(`API error: ${c.status}`);return c.json()}async function k1(n){const i=localStorage.getItem("nestor_token"),d={"Content-Type":"application/json"};i&&(d.Authorization=`Bearer ${i}`);const c=await fetch(`${Q0}${n}`,{method:"DELETE",headers:d});if(!c.ok)throw new Error(`API error: ${c.status}`)}const z1={observation:"bg-blue-500/20 text-blue-400",fact:"bg-green-500/20 text-green-400",instruction:"bg-purple-500/20 text-purple-400",reflection:"bg-amber-500/20 text-amber-400"};function eu({type:n}){return e.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${z1[n]??"bg-zinc-500/20 text-zinc-400"}`,children:n})}function F0({value:n}){const i=Math.round(n*100),d=i>=80?"bg-red-500":i>=50?"bg-amber-500":"bg-green-500";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-1.5 w-16 rounded-full bg-zinc-700",children:e.jsx("div",{className:`h-full rounded-full ${d}`,style:{width:`${i}%`}})}),e.jsxs("span",{className:"text-xs text-zinc-500",children:[i,"%"]})]})}function Xr({label:n,value:i,icon:d}){return e.jsxs("div",{className:"rounded-lg border border-border bg-surface p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-zinc-400",children:[e.jsx(d,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider",children:n})]}),e.jsx("p",{className:"mt-2 text-2xl font-semibold text-white",children:i})]})}const C1=[{key:"preference",color:"bg-purple-500/20 text-purple-400",label:"Preference"},{key:"identity",color:"bg-blue-500/20 text-blue-400",label:"Identity"},{key:"fact",color:"bg-green-500/20 text-green-400",label:"Fact"},{key:"procedure",color:"bg-amber-500/20 text-amber-400",label:"Procedure"},{key:"blocker",color:"bg-red-500/20 text-red-400",label:"Blocker"},{key:"reference",color:"bg-cyan-500/20 text-cyan-400",label:"Reference"}];function A1({stats:n,memories:i}){const{t:d}=Je(),c=Date.now()/1e3-720*3600,m=i.filter(b=>b.accessedAt<c),f=Date.now()/1e3-2160*3600,h=i.filter(b=>b.createdAt<f&&b.importance<.3);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"rounded-lg border border-border bg-surface p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Ds,{className:"h-4 w-4 text-purple-400"}),e.jsx("h3",{className:"text-sm font-medium text-zinc-300",children:d("memory.governanceTypes")})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 md:grid-cols-3 lg:grid-cols-6",children:C1.map(b=>{const g=(n==null?void 0:n.byType[b.key])??0;return e.jsxs("div",{className:"rounded-lg bg-zinc-900/50 p-3 text-center",children:[e.jsx("span",{className:`inline-flex items-center rounded-full px-2.5 py-1 text-xs font-medium ${b.color}`,children:b.label}),e.jsx("p",{className:"mt-2 text-xl font-semibold text-white",children:g})]},b.key)})})]}),e.jsxs("div",{className:"rounded-lg border border-border bg-surface p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pt,{className:"h-4 w-4 text-amber-400"}),e.jsx("h3",{className:"text-sm font-medium text-zinc-300",children:d("memory.staleMemories")})]}),e.jsxs("span",{className:"rounded-full bg-amber-500/10 px-2.5 py-0.5 text-xs font-medium text-amber-400",children:[m.length," ",d("memory.flagged")]})]}),m.length===0?e.jsx("p",{className:"text-sm text-zinc-500",children:d("memory.noStale")}):e.jsxs("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:[m.slice(0,10).map(b=>e.jsxs("div",{className:"flex items-center justify-between rounded-md bg-zinc-900/40 px-3 py-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm text-zinc-300",children:b.content}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx(eu,{type:b.memoryType}),e.jsxs("span",{className:"text-[11px] text-zinc-500",children:["Last accessed: ",new Date(b.accessedAt*1e3).toLocaleDateString()]})]})]}),e.jsx(F0,{value:b.importance})]},b.id)),m.length>10&&e.jsxs("p",{className:"text-xs text-zinc-500 text-center pt-2",children:["+",m.length-10," more stale memories"]})]})]}),e.jsxs("div",{className:"rounded-lg border border-border bg-surface p-5",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vs,{className:"h-4 w-4 text-blue-400"}),e.jsx("h3",{className:"text-sm font-medium text-zinc-300",children:d("memory.ttlEnforcement")})]})}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg bg-zinc-900/50 p-3",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-zinc-500",children:d("memory.totalMemories")}),e.jsx("p",{className:"mt-1 text-xl font-semibold text-white",children:(n==null?void 0:n.total)??0})]}),e.jsxs("div",{className:"rounded-lg bg-zinc-900/50 p-3",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-zinc-500",children:d("memory.staleCount")}),e.jsx("p",{className:"mt-1 text-xl font-semibold text-amber-400",children:m.length})]}),e.jsxs("div",{className:"rounded-lg bg-zinc-900/50 p-3",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-zinc-500",children:d("memory.ttlCandidates")}),e.jsx("p",{className:"mt-1 text-xl font-semibold text-red-400",children:h.length}),e.jsx("p",{className:"mt-0.5 text-[10px] text-zinc-500",children:">90 days, importance <30%"})]})]})]})]})}function E1(){const{t:n}=Je(),[i,d]=u.useState([]),[c,m]=u.useState([]),[f,h]=u.useState(null),[b,g]=u.useState(!0),[p,S]=u.useState(""),[y,v]=u.useState(""),[k,C]=u.useState(""),[w,N]=u.useState(null),[z,R]=u.useState("browse");u.useEffect(()=>{Yr("/agents").then(Z=>m(Z.data)).catch(console.error)},[]);const D=u.useCallback(async()=>{g(!0);try{const Z=new URLSearchParams;p&&Z.set("q",p),y&&Z.set("agentId",y),k&&Z.set("type",k),Z.set("limit","100");const U=Z.toString(),A=await Yr(`/memory?${U}`);if(d(A.data),y){const F=await Yr(`/memory/stats/${y}`);h(F.data)}else if(c.length>0){let F=0,$=0;const Q={};let ce=!1;for(const I of c)try{const le=await Yr(`/memory/stats/${I.id}`);F+=le.data.total,$+=le.data.avgImportance*le.data.total;for(const[Y,B]of Object.entries(le.data.byType))Q[Y]=(Q[Y]??0)+B;le.data.fts5Available&&(ce=!0)}catch{}h({total:F,byType:Q,avgImportance:F>0?$/F:0,fts5Available:ce})}}catch(Z){console.error("Failed to load memories:",Z)}finally{g(!1)}},[p,y,k,c]);u.useEffect(()=>{(c.length>0||y)&&D()},[D,c.length,y]);const O=async Z=>{N(Z);try{await k1(`/memory/${Z}`),d(U=>U.filter(A=>A.id!==Z))}catch(U){console.error("Failed to delete memory:",U)}finally{N(null)}},se=Z=>{Z.preventDefault(),D()};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(La,{className:"h-6 w-6 text-indigo-400"}),e.jsx("h1",{className:"text-2xl font-semibold text-white",children:"Memory"})]}),(f==null?void 0:f.fts5Available)&&e.jsx("span",{className:"rounded-full bg-green-500/10 px-3 py-1 text-xs font-medium text-green-400",children:"FTS5 Active"})]}),e.jsxs("div",{className:"flex gap-1 rounded-lg bg-zinc-900/50 p-1 w-fit",children:[e.jsx("button",{onClick:()=>R("browse"),className:`rounded-md px-4 py-1.5 text-sm font-medium transition-colors ${z==="browse"?"bg-purple-500/20 text-purple-300":"text-zinc-400 hover:text-zinc-200"}`,children:n("memory.browse")}),e.jsxs("button",{onClick:()=>R("governance"),className:`rounded-md px-4 py-1.5 text-sm font-medium transition-colors ${z==="governance"?"bg-purple-500/20 text-purple-300":"text-zinc-400 hover:text-zinc-200"}`,children:[e.jsx(Ds,{className:"mr-1.5 inline h-3.5 w-3.5"}),n("memory.governance")]})]}),z==="governance"&&e.jsx(A1,{stats:f,memories:i}),z==="browse"&&f&&e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(Xr,{label:"Total Memories",value:f.total,icon:La}),e.jsx(Xr,{label:"Avg Importance",value:`${Math.round(f.avgImportance*100)}%`,icon:Rs}),e.jsx(Xr,{label:"Types",value:Object.keys(f.byType).length,icon:_v}),e.jsx(Xr,{label:"Observations",value:f.byType.observation??0,icon:vs})]}),z==="browse"&&f&&Object.keys(f.byType).length>0&&e.jsxs("div",{className:"rounded-lg border border-border bg-surface p-4",children:[e.jsx("h3",{className:"mb-3 text-sm font-medium text-zinc-400",children:"Distribution by Type"}),e.jsx("div",{className:"flex gap-4",children:Object.entries(f.byType).map(([Z,U])=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(eu,{type:Z}),e.jsx("span",{className:"text-sm text-white",children:U})]},Z))})]}),z==="browse"&&e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("form",{onSubmit:se,className:"flex flex-1 gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(_a,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-zinc-500"}),e.jsx("input",{type:"text",value:p,onChange:Z=>S(Z.target.value),placeholder:"Search memories...",className:"w-full rounded-lg border border-border bg-surface py-2 pl-10 pr-4 text-sm text-white placeholder:text-zinc-500 focus:border-indigo-500 focus:outline-none"})]}),e.jsx("button",{type:"submit",className:"rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-500",children:"Search"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("select",{value:y,onChange:Z=>v(Z.target.value),className:"rounded-lg border border-border bg-surface px-3 py-2 text-sm text-white focus:border-indigo-500 focus:outline-none",children:[e.jsx("option",{value:"",children:"All Agents"}),c.map(Z=>e.jsx("option",{value:Z.id,children:Z.name},Z.id))]}),e.jsxs("select",{value:k,onChange:Z=>C(Z.target.value),className:"rounded-lg border border-border bg-surface px-3 py-2 text-sm text-white focus:border-indigo-500 focus:outline-none",children:[e.jsx("option",{value:"",children:"All Types"}),e.jsx("option",{value:"observation",children:"Observation"}),e.jsx("option",{value:"fact",children:"Fact"}),e.jsx("option",{value:"instruction",children:"Instruction"}),e.jsx("option",{value:"reflection",children:"Reflection"})]})]})]}),z==="browse"&&(b?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent"})}):i.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-border bg-surface py-16",children:[e.jsx(La,{className:"h-12 w-12 text-zinc-600"}),e.jsx("p",{className:"mt-4 text-sm text-zinc-400",children:"No memories found"}),e.jsx("p",{className:"mt-1 text-xs text-zinc-500",children:"Memories are created when agents store observations, facts, and reflections."})]}):e.jsx("div",{className:"space-y-2",children:i.map(Z=>e.jsx("div",{className:"group rounded-lg border border-border bg-surface p-4 transition-colors hover:border-border/80",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(eu,{type:Z.memoryType}),e.jsx(F0,{value:Z.importance}),e.jsxs("span",{className:"text-xs text-zinc-500",children:[new Date(Z.createdAt*1e3).toLocaleDateString()," ",new Date(Z.createdAt*1e3).toLocaleTimeString()]}),Z.accessCount>0&&e.jsxs("span",{className:"text-xs text-zinc-600",children:["accessed ",Z.accessCount,"x"]})]}),e.jsx("p",{className:"mt-2 text-sm text-zinc-200 leading-relaxed",children:Z.content}),Z.tags.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:Z.tags.map(U=>e.jsxs("span",{className:"inline-flex items-center rounded bg-zinc-800 px-1.5 py-0.5 text-[10px] text-zinc-400",children:["#",U]},U))})]}),e.jsx("button",{onClick:()=>O(Z.id),disabled:w===Z.id,className:"rounded p-1.5 text-zinc-500 opacity-0 transition-all hover:bg-red-500/10 hover:text-red-400 group-hover:opacity-100 disabled:opacity-50",title:"Delete memory",children:w===Z.id?e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border border-red-400 border-t-transparent"}):e.jsx(Ot,{className:"h-4 w-4"})})]})},Z.id))}))]})}const T1="/api/budget";function R1(){const n={"Content-Type":"application/json"},i=localStorage.getItem("nestor_token");return i&&(n.Authorization=`Bearer ${i}`),n}async function Da(n,i){const d=await fetch(`${T1}${n}`,{...i,headers:R1()});if(!d.ok)throw new Error(`API error: ${d.status}`);if(d.status!==204)return d.json()}const nn={listPolicies:()=>Da("/policies"),createPolicy:n=>Da("/policies",{method:"POST",body:JSON.stringify(n)}),updatePolicy:(n,i)=>Da(`/policies/${n}`,{method:"PUT",body:JSON.stringify(i)}),deletePolicy:n=>Da(`/policies/${n}`,{method:"DELETE"}),utilization:()=>Da("/utilization"),incidents:(n=50)=>Da(`/incidents?limit=${n}`),pauseAgent:n=>Da(`/agents/${n}/pause`,{method:"POST",body:"{}"}),resumeAgent:n=>Da(`/agents/${n}/resume`,{method:"POST",body:"{}"})};function tu(n){return n<.01?`$${n.toFixed(4)}`:n<1?`$${n.toFixed(3)}`:`$${n.toFixed(2)}`}function Z0(n){return new Date(n*1e3).toLocaleString()}function J0(n){switch(n){case"warning":return"text-amber-400";case"breach":return"text-red-400";case"pause":return"text-orange-400";case"resume":return"text-emerald-400";default:return"text-zinc-400"}}function M1(n){return n>=90?"bg-red-500":n>=70?"bg-amber-500":"bg-emerald-500"}function Wh({initial:n,onSave:i,onCancel:d}){const[c,m]=u.useState((n==null?void 0:n.name)??""),[f,h]=u.useState((n==null?void 0:n.scope)??"global"),[b,g]=u.useState((n==null?void 0:n.scopeId)??""),[p,S]=u.useState((n==null?void 0:n.window)??"monthly"),[y,v]=u.useState(String((n==null?void 0:n.limitUsd)??10)),[k,C]=u.useState(String((n==null?void 0:n.warningThresholdPercent)??80)),[w,N]=u.useState((n==null?void 0:n.action)??"stop"),[z,R]=u.useState((n==null?void 0:n.enabled)!==!1),D=O=>{O.preventDefault(),i({name:c,scope:f,scopeId:b||null,window:p,limitUsd:parseFloat(y)||10,warningThresholdPercent:parseFloat(k)||80,action:w,enabled:z})};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:e.jsxs("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:n!=null&&n.id?"Edit Policy":"New Budget Policy"}),e.jsx("button",{onClick:d,className:"text-zinc-400 hover:text-white",children:e.jsx(Ze,{className:"h-5 w-5"})})]}),e.jsxs("form",{onSubmit:D,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-zinc-400 mb-1",children:"Name"}),e.jsx("input",{value:c,onChange:O=>m(O.target.value),required:!0,className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-white"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-zinc-400 mb-1",children:"Scope"}),e.jsxs("select",{value:f,onChange:O=>h(O.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-white",children:[e.jsx("option",{value:"global",children:"Global"}),e.jsx("option",{value:"agent",children:"Agent"}),e.jsx("option",{value:"workflow",children:"Workflow"}),e.jsx("option",{value:"tenant",children:"Tenant"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-zinc-400 mb-1",children:"Scope ID"}),e.jsx("input",{value:b,onChange:O=>g(O.target.value),placeholder:"(optional)",className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-white"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-zinc-400 mb-1",children:"Window"}),e.jsxs("select",{value:p,onChange:O=>S(O.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-white",children:[e.jsx("option",{value:"per_run",children:"Per Run"}),e.jsx("option",{value:"hourly",children:"Hourly"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"monthly",children:"Monthly"}),e.jsx("option",{value:"lifetime",children:"Lifetime"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-zinc-400 mb-1",children:"Limit (USD)"}),e.jsx("input",{type:"number",step:"0.01",min:"0",value:y,onChange:O=>v(O.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-white"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-zinc-400 mb-1",children:"Warning at (%)"}),e.jsx("input",{type:"number",step:"1",min:"0",max:"100",value:k,onChange:O=>C(O.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-zinc-400 mb-1",children:"Action"}),e.jsxs("select",{value:w,onChange:O=>N(O.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-white",children:[e.jsx("option",{value:"stop",children:"Stop"}),e.jsx("option",{value:"pause",children:"Pause"}),e.jsx("option",{value:"warn",children:"Warn"}),e.jsx("option",{value:"notify",children:"Notify"})]})]})]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-zinc-300",children:[e.jsx("input",{type:"checkbox",checked:z,onChange:O=>R(O.target.checked),className:"rounded border-border"}),"Enabled"]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx("button",{type:"button",onClick:d,className:"px-4 py-2 text-sm text-zinc-400 hover:text-white",children:"Cancel"}),e.jsx("button",{type:"submit",className:"rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-500",children:"Save"})]})]})]})})}function D1({report:n}){const i=n.policy;return e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-white",children:i.name}),e.jsxs("p",{className:"text-xs text-zinc-500",children:[i.scope,i.scopeId?` / ${i.scopeId}`:""," · ",i.window," · ",i.action]})]}),e.jsx("span",{className:`text-xs font-medium ${i.enabled?"text-emerald-400":"text-zinc-500"}`,children:i.enabled?"Active":"Disabled"})]}),e.jsxs("div",{className:"mb-1 flex items-center justify-between text-xs text-zinc-400",children:[e.jsxs("span",{children:[tu(n.spentUsd)," / ",tu(i.limitUsd)]}),e.jsxs("span",{children:[n.utilizationPercent.toFixed(1),"%"]})]}),e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-zinc-800",children:e.jsx("div",{className:`h-full rounded-full transition-all ${M1(n.utilizationPercent)}`,style:{width:`${Math.min(100,n.utilizationPercent)}%`}})}),n.incidents.length>0&&e.jsxs("div",{className:"mt-2 text-xs text-zinc-500",children:["Last incident: ",e.jsx("span",{className:J0(n.incidents[0].type),children:n.incidents[0].type})," ",Z0(n.incidents[0].createdAt)]})]})}function O1(){const{t:n}=Je(),[i,d]=u.useState([]),[c,m]=u.useState([]),[f,h]=u.useState([]),[b,g]=u.useState(!0),[p,S]=u.useState(null),[y,v]=u.useState(!1),[k,C]=u.useState(null),w=u.useCallback(async()=>{try{g(!0),S(null);const[O,se,Z]=await Promise.all([nn.listPolicies(),nn.utilization(),nn.incidents(50)]);d(O.data),m(se.data),h(Z.data)}catch(O){S(O instanceof Error?O.message:"Failed to load budget data")}finally{g(!1)}},[]);u.useEffect(()=>{w()},[w]);const N=async O=>{try{await nn.createPolicy(O),v(!1),await w()}catch(se){S(se instanceof Error?se.message:"Failed to create policy")}},z=async O=>{if(k)try{await nn.updatePolicy(k.id,O),C(null),await w()}catch(se){S(se instanceof Error?se.message:"Failed to update policy")}},R=async O=>{if(confirm("Delete this budget policy?"))try{await nn.deletePolicy(O),await w()}catch(se){S(se instanceof Error?se.message:"Failed to delete policy")}},D=async O=>{try{await nn.resumeAgent(O),await w()}catch(se){S(se instanceof Error?se.message:"Failed to resume agent")}};return b?e.jsx("div",{className:"flex h-64 items-center justify-center text-zinc-400",children:"Loading budget data..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-white",children:"Budget Management"}),e.jsx("p",{className:"text-sm text-zinc-400",children:"Scoped budget policies, utilization tracking, and cost control."})]}),e.jsxs("button",{onClick:()=>v(!0),className:"flex items-center gap-2 rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-500",children:[e.jsx(ht,{className:"h-4 w-4"})," New Policy"]})]}),p&&e.jsx("div",{className:"rounded-lg border border-red-500/30 bg-red-500/10 px-4 py-3 text-sm text-red-400",children:p}),c.length>0&&e.jsxs("section",{children:[e.jsx("h2",{className:"mb-3 text-lg font-semibold text-white",children:"Utilization"}),e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3",children:c.map(O=>e.jsx(D1,{report:O},O.policy.id))})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"mb-3 text-lg font-semibold text-white",children:"Policies"}),i.length===0?e.jsx("div",{className:"card text-center text-sm text-zinc-500 py-8",children:'No budget policies configured. Click "New Policy" to create one.'}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border text-zinc-500",children:[e.jsx("th",{className:"py-2 px-3 font-medium",children:"Name"}),e.jsx("th",{className:"py-2 px-3 font-medium",children:"Scope"}),e.jsx("th",{className:"py-2 px-3 font-medium",children:"Window"}),e.jsx("th",{className:"py-2 px-3 font-medium",children:"Limit"}),e.jsx("th",{className:"py-2 px-3 font-medium",children:"Action"}),e.jsx("th",{className:"py-2 px-3 font-medium",children:"Status"}),e.jsx("th",{className:"py-2 px-3 font-medium text-right",children:"Actions"})]})}),e.jsx("tbody",{children:i.map(O=>e.jsxs("tr",{className:"border-b border-border/50 hover:bg-surface-hover transition-colors",children:[e.jsx("td",{className:"py-2.5 px-3 text-white font-medium",children:O.name}),e.jsxs("td",{className:"py-2.5 px-3 text-zinc-300",children:[O.scope,O.scopeId?e.jsxs("span",{className:"text-zinc-500",children:[" / ",O.scopeId]}):""]}),e.jsx("td",{className:"py-2.5 px-3 text-zinc-300",children:O.window}),e.jsx("td",{className:"py-2.5 px-3 text-zinc-300",children:tu(O.limitUsd)}),e.jsx("td",{className:"py-2.5 px-3",children:e.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${O.action==="stop"?"bg-red-500/10 text-red-400":O.action==="pause"?"bg-orange-500/10 text-orange-400":O.action==="warn"?"bg-amber-500/10 text-amber-400":"bg-blue-500/10 text-blue-400"}`,children:O.action})}),e.jsx("td",{className:"py-2.5 px-3",children:e.jsx("span",{className:`text-xs ${O.enabled?"text-emerald-400":"text-zinc-500"}`,children:O.enabled?"Enabled":"Disabled"})}),e.jsx("td",{className:"py-2.5 px-3 text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx("button",{onClick:()=>C(O),className:"p-1 text-zinc-400 hover:text-white",title:"Edit",children:e.jsx(Mv,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>R(O.id),className:"p-1 text-zinc-400 hover:text-red-400",title:"Delete",children:e.jsx(Ot,{className:"h-3.5 w-3.5"})})]})})]},O.id))})]})})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"mb-3 text-lg font-semibold text-white",children:"Recent Incidents"}),f.length===0?e.jsx("div",{className:"card text-center text-sm text-zinc-500 py-6",children:"No budget incidents recorded."}):e.jsx("div",{className:"space-y-1",children:f.map(O=>e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border/30 bg-surface px-4 py-2.5 text-sm",children:[e.jsx("span",{className:`font-medium ${J0(O.type)}`,children:O.type.toUpperCase()}),e.jsx("span",{className:"flex-1 text-zinc-300 truncate",children:O.message}),O.agentId&&e.jsxs("span",{className:"text-xs text-zinc-500",children:["Agent: ",O.agentId.slice(0,8)]}),e.jsx("span",{className:"text-xs text-zinc-500",children:Z0(O.createdAt)}),O.type==="pause"&&O.agentId&&e.jsxs("button",{onClick:()=>D(O.agentId),className:"flex items-center gap-1 rounded bg-emerald-600/20 px-2 py-1 text-xs text-emerald-400 hover:bg-emerald-600/30",children:[e.jsx(hv,{className:"h-3 w-3"})," Resume"]})]},O.id))})]}),y&&e.jsx(Wh,{onSave:N,onCancel:()=>v(!1)}),k&&e.jsx(Wh,{initial:k,onSave:z,onCancel:()=>C(null)})]})}const I0={mission:"Mission",objective:"Objective",key_result:"Key Result",task:"Task"},L1={mission:"bg-purple-500/10 text-purple-400 border-purple-500/20",objective:"bg-blue-500/10 text-blue-400 border-blue-500/20",key_result:"bg-cyan-500/10 text-cyan-400 border-cyan-500/20",task:"bg-green-500/10 text-green-400 border-green-500/20"},_1={active:rn,completed:bt,paused:tl,cancelled:Ze},U1={active:"text-indigo-400",completed:"text-green-400",paused:"text-amber-400",cancelled:"text-zinc-500"};function P0({goal:n,depth:i,agents:d,onEdit:c,onDelete:m,onStatusChange:f}){const[h,b]=u.useState(i<2),g=n.children&&n.children.length>0,p=_1[n.status]??rn,S=d.find(y=>y.id===n.ownerAgentId);return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:`flex items-center gap-2 rounded-lg px-3 py-2.5 transition-colors hover:bg-surface-hover ${i===0?"bg-surface border border-border":""}`,style:{paddingLeft:`${i*24+12}px`},children:[e.jsx("button",{onClick:()=>b(!h),className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded transition-colors ${g?"text-zinc-400 hover:text-zinc-200":"text-transparent"}`,disabled:!g,children:g&&(h?e.jsx(na,{className:"h-3.5 w-3.5"}):e.jsx(ds,{className:"h-3.5 w-3.5"}))}),e.jsx(p,{className:`h-4 w-4 flex-shrink-0 ${U1[n.status]}`}),e.jsx("span",{className:`inline-flex items-center rounded-md border px-1.5 py-0.5 text-[10px] font-medium uppercase ${L1[n.type]}`,children:I0[n.type]}),e.jsx("span",{className:"flex-1 truncate text-sm font-medium text-zinc-200",children:n.title}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-1.5 w-20 rounded-full bg-zinc-800",children:e.jsx("div",{className:"h-full rounded-full bg-indigo-500 transition-all",style:{width:`${n.progressPercent}%`}})}),e.jsxs("span",{className:"w-8 text-right text-xs text-zinc-500",children:[n.progressPercent,"%"]})]}),S&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-zinc-500",children:[e.jsx(Ts,{className:"h-3 w-3"}),S.name]}),n.dueDate&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-zinc-500",children:[e.jsx(C0,{className:"h-3 w-3"}),new Date(n.dueDate).toLocaleDateString()]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[n.status==="active"&&e.jsx("button",{onClick:()=>f(n.id,"completed"),className:"rounded p-1 text-zinc-500 hover:bg-green-500/10 hover:text-green-400",title:"Mark completed",children:e.jsx(bt,{className:"h-3.5 w-3.5"})}),n.status==="active"&&e.jsx("button",{onClick:()=>f(n.id,"paused"),className:"rounded p-1 text-zinc-500 hover:bg-amber-500/10 hover:text-amber-400",title:"Pause",children:e.jsx(tl,{className:"h-3.5 w-3.5"})}),n.status==="paused"&&e.jsx("button",{onClick:()=>f(n.id,"active"),className:"rounded p-1 text-zinc-500 hover:bg-indigo-500/10 hover:text-indigo-400",title:"Resume",children:e.jsx(rn,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>c(n),className:"rounded p-1 text-zinc-500 hover:bg-surface-hover hover:text-zinc-200",title:"Edit",children:e.jsx(pi,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>m(n.id),className:"rounded p-1 text-zinc-500 hover:bg-red-500/10 hover:text-red-400",title:"Delete",children:e.jsx(Ot,{className:"h-3.5 w-3.5"})})]})]}),h&&g&&e.jsx("div",{children:n.children.map(y=>e.jsx(P0,{goal:y,depth:i+1,agents:d,onEdit:c,onDelete:m,onStatusChange:f},y.id))})]})}function $1({goal:n,parentGoals:i,agents:d,onSave:c,onClose:m}){const[f,h]=u.useState((n==null?void 0:n.title)??""),[b,g]=u.useState((n==null?void 0:n.description)??""),[p,S]=u.useState((n==null?void 0:n.type)??"task"),[y,v]=u.useState((n==null?void 0:n.parentId)??""),[k,C]=u.useState((n==null?void 0:n.ownerAgentId)??""),[w,N]=u.useState((n==null?void 0:n.priority)??5),[z,R]=u.useState((n==null?void 0:n.dueDate)??""),D=O=>{O.preventDefault(),c({title:f,description:b||void 0,type:p,parentId:y||null,ownerAgentId:k||void 0,priority:w,dueDate:z||void 0})};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"w-full max-w-lg rounded-xl border border-border bg-surface p-6 shadow-xl",children:[e.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:n?"Edit Goal":"Create Goal"}),e.jsxs("form",{onSubmit:D,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-zinc-300 mb-1",children:"Title"}),e.jsx("input",{type:"text",value:f,onChange:O=>h(O.target.value),className:"input w-full",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-zinc-300 mb-1",children:"Description"}),e.jsx("textarea",{value:b,onChange:O=>g(O.target.value),className:"input w-full h-20 resize-none"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-zinc-300 mb-1",children:"Type"}),e.jsxs("select",{value:p,onChange:O=>S(O.target.value),className:"input w-full",children:[e.jsx("option",{value:"mission",children:"Mission"}),e.jsx("option",{value:"objective",children:"Objective"}),e.jsx("option",{value:"key_result",children:"Key Result"}),e.jsx("option",{value:"task",children:"Task"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-zinc-300 mb-1",children:"Parent"}),e.jsxs("select",{value:y,onChange:O=>v(O.target.value),className:"input w-full",children:[e.jsx("option",{value:"",children:"None (root)"}),i.map(O=>e.jsxs("option",{value:O.id,children:["[",I0[O.type],"] ",O.title]},O.id))]})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-zinc-300 mb-1",children:"Priority (1-10)"}),e.jsx("input",{type:"number",min:1,max:10,value:w,onChange:O=>N(Number(O.target.value)),className:"input w-full"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-zinc-300 mb-1",children:"Assign Agent"}),e.jsxs("select",{value:k,onChange:O=>C(O.target.value),className:"input w-full",children:[e.jsx("option",{value:"",children:"Unassigned"}),d.map(O=>e.jsx("option",{value:O.id,children:O.name},O.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-zinc-300 mb-1",children:"Due Date"}),e.jsx("input",{type:"date",value:z,onChange:O=>R(O.target.value),className:"input w-full"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx("button",{type:"button",onClick:m,className:"btn-ghost",children:"Cancel"}),e.jsx("button",{type:"submit",className:"btn-primary",children:n?"Update":"Create"})]})]})]})})}function W0(n,i=[]){for(const d of n)i.push(d),d.children&&W0(d.children,i);return i}function B1(){const{t:n}=Je(),[i,d]=u.useState([]),[c,m]=u.useState([]),[f,h]=u.useState(!0),[b,g]=u.useState(null),[p,S]=u.useState(null),y=u.useCallback(async()=>{try{g(null);const[N,z]=await Promise.all([ii.tree(),la.list()]);d(N.data),m(z.data)}catch(N){g(N instanceof Error?N.message:"Failed to fetch goals")}finally{h(!1)}},[]);u.useEffect(()=>{y()},[y]);const v=async N=>{try{p&&p!=="new"?await ii.update(p.id,N):await ii.create(N),S(null),y()}catch(z){console.error("Save failed:",z)}},k=async N=>{if(confirm("Delete this goal and all its children?"))try{await ii.delete(N),y()}catch(z){console.error("Delete failed:",z)}},C=async(N,z)=>{try{await ii.update(N,{status:z}),y()}catch(R){console.error("Status change failed:",R)}};if(f)return e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent"})});const w=W0(i);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-semibold text-white",children:"Goals"}),i.length>0&&e.jsxs("span",{className:"badge bg-indigo-500/10 text-indigo-400",children:[w.length," total"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:y,className:"btn-ghost btn-sm",children:e.jsx(xt,{className:"h-4 w-4"})}),e.jsxs("button",{onClick:()=>S("new"),className:"btn-primary btn-sm",children:[e.jsx(ht,{className:"h-4 w-4"}),"New Goal"]})]})]}),b&&e.jsxs("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 p-4 text-sm text-red-400",children:[b,e.jsx("button",{onClick:y,className:"ml-3 underline",children:"Retry"})]}),i.length===0&&!b?e.jsx(cn,{icon:e.jsx(rn,{className:"h-8 w-8"}),title:"No goals yet",description:"Goals let you define objectives and track AI agent progress with an OKR-style hierarchy.",action:e.jsxs("div",{className:"mt-2 space-y-3 text-left max-w-md",children:[e.jsxs("div",{className:"rounded-lg bg-zinc-900 border border-zinc-800 p-3",children:[e.jsx("p",{className:"text-xs text-zinc-500 mb-1.5 font-medium",children:"Goal hierarchy:"}),e.jsxs("ul",{className:"text-xs text-zinc-400 space-y-1",children:[e.jsxs("li",{children:[e.jsx("span",{className:"text-purple-400 font-medium",children:"Mission"})," → High-level strategic goal"]}),e.jsxs("li",{children:[e.jsx("span",{className:"text-blue-400 font-medium",children:"Objective"})," → Measurable outcome"]}),e.jsxs("li",{children:[e.jsx("span",{className:"text-cyan-400 font-medium",children:"Key Result"})," → Quantifiable metric"]}),e.jsxs("li",{children:[e.jsx("span",{className:"text-green-400 font-medium",children:"Task"})," → Actionable work item"]})]})]}),e.jsxs("button",{onClick:()=>S("new"),className:"btn-primary btn-sm",children:[e.jsx(ht,{className:"h-4 w-4"}),"Create your first goal"]})]})}):e.jsx("div",{className:"space-y-1",children:i.map(N=>e.jsx(P0,{goal:N,depth:0,agents:c,onEdit:z=>S(z),onDelete:k,onStatusChange:C},N.id))}),p!==null&&e.jsx($1,{goal:p==="new"?null:p,parentGoals:w,agents:c,onSave:v,onClose:()=>S(null)})]})}function H1(){const n=Dt(),{t:i}=Je(),[d,c]=u.useState([]),[m,f]=u.useState(!0),[h,b]=u.useState("pending"),[g,p]=u.useState({}),[S,y]=u.useState(null),v=u.useCallback(async()=>{try{const N=h==="all"?void 0:{status:h},z=await ac.list(N);c(z.data)}catch{}finally{f(!1)}},[h]);u.useEffect(()=>{f(!0),v()},[v]);const k=async N=>{var R;const z=(R=g[N.id])==null?void 0:R.trim();if(z){y(N.id);try{await ac.resume(N.id,z),p(D=>{const O={...D};return delete O[N.id],O}),v()}catch(D){console.error("Resume failed:",D)}finally{y(null)}}},C=N=>{switch(N){case"pending":return e.jsx(vs,{className:"h-4 w-4 text-amber-400"});case"resumed":return e.jsx(et,{className:"h-4 w-4 text-green-400"});case"expired":return e.jsx(ft,{className:"h-4 w-4 text-zinc-500"});default:return e.jsx(vs,{className:"h-4 w-4 text-zinc-500"})}},w=N=>{const z={pending:"bg-amber-500/10 text-amber-400 border-amber-500/30",resumed:"bg-green-500/10 text-green-400 border-green-500/30",expired:"bg-zinc-500/10 text-zinc-400 border-zinc-500/30"};return e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-medium ${z[N]??z.expired}`,children:[C(N),N]})};return m?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fi,{className:"h-6 w-6 text-amber-400"}),e.jsx("h1",{className:"text-2xl font-semibold text-white",children:"Handoffs"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{onClick:v,className:"btn-ghost btn-sm",children:e.jsx(xt,{className:"h-3.5 w-3.5"})})})]}),e.jsx("div",{className:"flex gap-2",children:["pending","resumed","expired","all"].map(N=>e.jsx("button",{className:`rounded-lg px-3 py-1.5 text-sm font-medium transition-colors ${h===N?"bg-indigo-500/10 text-indigo-400 border border-indigo-500/30":"text-zinc-400 hover:text-zinc-200 border border-transparent"}`,onClick:()=>b(N),children:N.charAt(0).toUpperCase()+N.slice(1)},N))}),d.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-4 text-center",children:[e.jsx("div",{className:"mb-4 rounded-2xl bg-surface p-4 text-zinc-500",children:e.jsx(fi,{className:"h-8 w-8"})}),e.jsxs("h3",{className:"text-lg font-medium text-zinc-300",children:["No ",h==="all"?"":h+" ","handoffs"]}),e.jsx("p",{className:"mt-1.5 max-w-sm text-sm text-zinc-500",children:"Handoffs occur when an agent encounters a blocking issue and needs human help to continue."}),e.jsxs("div",{className:"mt-4 space-y-3 text-left max-w-md",children:[e.jsxs("div",{className:"rounded-lg bg-zinc-900 border border-zinc-800 p-3",children:[e.jsx("p",{className:"text-xs text-zinc-500 mb-1.5 font-medium",children:"Handoffs are created automatically when:"}),e.jsxs("ul",{className:"text-xs text-zinc-400 space-y-1 list-disc list-inside",children:[e.jsx("li",{children:"An agent needs credentials or access it doesn't have"}),e.jsx("li",{children:"A task requires human judgment or decision"}),e.jsx("li",{children:"An agent encounters an unrecoverable error"})]})]}),e.jsx("p",{className:"text-xs text-zinc-500",children:"Run a complex mission and the agent will hand off to you if it gets stuck."})]})]}):e.jsx("div",{className:"space-y-4",children:d.map(N=>{var z;return e.jsxs("div",{className:`card ${N.status==="pending"?"border-amber-500/20":""}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[w(N.status),e.jsxs("span",{className:"text-xs text-zinc-500 font-mono",children:[N.id.slice(0,12),"..."]})]}),e.jsx("button",{className:"text-xs text-indigo-400 hover:text-indigo-300",onClick:()=>n(`/runs/${N.runId}`),children:"View Run"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500 mb-1 font-medium",children:"Accomplished"}),e.jsx("p",{className:"text-sm text-zinc-300",children:N.accomplished})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500 mb-1 font-medium",children:"Blocking"}),e.jsx("p",{className:"text-sm text-red-400",children:N.blocking})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500 mb-1 font-medium",children:"Suggestions"}),e.jsx("p",{className:"text-sm text-zinc-300",children:N.suggestions})]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-3 text-xs text-zinc-500",children:[e.jsxs("span",{children:["Agent: ",N.agentId.slice(0,12),"..."]}),e.jsxs("span",{children:["Created: ",new Date(N.createdAt).toLocaleString()]}),N.resumedAt&&e.jsxs("span",{children:["Resumed: ",new Date(N.resumedAt).toLocaleString()]})]}),N.status==="pending"&&e.jsxs("div",{className:"mt-4 flex items-center gap-2 border-t border-zinc-800 pt-3",children:[e.jsx("input",{type:"text",className:"flex-1 rounded-lg border border-zinc-700 bg-zinc-800 px-3 py-2 text-sm text-zinc-200 placeholder-zinc-500 focus:border-indigo-500 focus:outline-none",placeholder:"Describe how you resolved the blocking issue...",value:g[N.id]??"",onChange:R=>p(D=>({...D,[N.id]:R.target.value}))}),e.jsx("button",{className:"btn-primary btn-sm",disabled:!((z=g[N.id])!=null&&z.trim())||S===N.id,onClick:()=>k(N),children:S===N.id?"Resuming...":"Resume"})]})]},N.id)})})]})}const e0={low:"bg-green-500/10 text-green-400 border-green-500/20",medium:"bg-yellow-500/10 text-yellow-400 border-yellow-500/20",high:"bg-orange-500/10 text-orange-400 border-orange-500/20",critical:"bg-red-500/10 text-red-400 border-red-500/20"};function q1({level:n}){return e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-medium ${e0[n]??e0.low}`,children:[n==="critical"&&e.jsx(pt,{className:"h-3 w-3"}),n==="high"&&e.jsx(pt,{className:"h-3 w-3"}),n.toUpperCase()]})}const uc="/api";async function Kd(n){const i=localStorage.getItem("nestor_token"),d={"Content-Type":"application/json"};i&&(d.Authorization=`Bearer ${i}`);const c=await fetch(`${uc}/plans/${n}`,{headers:d});if(!c.ok)throw new Error(`Failed to fetch plan: ${c.statusText}`);return(await c.json()).data}async function G1(n){const i=localStorage.getItem("nestor_token"),d={"Content-Type":"application/json"};i&&(d.Authorization=`Bearer ${i}`);const c=await fetch(`${uc}/plans/${n}/execute`,{method:"POST",headers:d});if(!c.ok)throw new Error(`Failed to execute plan: ${c.statusText}`)}async function K1(n){const i=localStorage.getItem("nestor_token"),d={"Content-Type":"application/json"};i&&(d.Authorization=`Bearer ${i}`);const c=await fetch(`${uc}/plans/${n}/cancel`,{method:"POST",headers:d});if(!c.ok)throw new Error(`Failed to cancel plan: ${c.statusText}`)}async function V1(){const n=localStorage.getItem("nestor_token"),i={"Content-Type":"application/json"};n&&(i.Authorization=`Bearer ${n}`);const d=await fetch(`${uc}/plans?limit=50`,{headers:i});if(!d.ok)throw new Error(`Failed to fetch plans: ${d.statusText}`);return(await d.json()).data}function Y1(){const[n,i]=u.useState([]),[d,c]=u.useState(!0),m=Dt();return u.useEffect(()=>{V1().then(i).catch(console.error).finally(()=>c(!1))},[]),d?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dry-Run Plans"})}),n.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-border bg-surface p-12 text-center",children:[e.jsx(Ds,{className:"mb-4 h-12 w-12 text-zinc-600"}),e.jsx("h3",{className:"text-lg font-medium text-zinc-300",children:"No dry-run plans yet"}),e.jsx("p",{className:"mt-1.5 max-w-md text-sm text-zinc-500",children:"Plans let you preview what an agent will do before it executes. The agent creates a step-by-step plan with cost estimates and risk levels."}),e.jsxs("div",{className:"mt-4 space-y-3 text-left max-w-md",children:[e.jsxs("div",{className:"rounded-lg bg-zinc-900 border border-zinc-800 p-3",children:[e.jsx("p",{className:"text-xs text-zinc-500 mb-1.5 font-medium",children:"Create a plan via CLI:"}),e.jsx("code",{className:"text-xs text-indigo-400 font-mono block",children:'npx nestor-sh plan "Audit the codebase for security issues"'})]}),e.jsxs("div",{className:"rounded-lg bg-zinc-900 border border-zinc-800 p-3",children:[e.jsx("p",{className:"text-xs text-zinc-500 mb-1.5 font-medium",children:"Or via API:"}),e.jsxs("code",{className:"text-xs text-indigo-400 font-mono block",children:["POST /api/plans ","{",' "agentId": "...", "prompt": "..." ',"}"]})]}),e.jsx("p",{className:"text-xs text-zinc-500",children:"Once created, you can review each step, approve or reject, then execute."})]})]}):e.jsx("div",{className:"space-y-3",children:n.map(f=>e.jsxs("button",{onClick:()=>m(`/plans/${f.id}`),className:"flex w-full items-center justify-between rounded-lg border border-border bg-surface p-4 text-left transition-colors hover:bg-surface-hover",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm font-medium text-white",children:[f.prompt.slice(0,80),f.prompt.length>80?"...":""]}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${f.status==="completed"?"bg-green-500/10 text-green-400":f.status==="executing"?"bg-blue-500/10 text-blue-400":f.status==="cancelled"?"bg-zinc-500/10 text-zinc-400":"bg-yellow-500/10 text-yellow-400"}`,children:f.status})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-4 text-xs text-zinc-500",children:[e.jsxs("span",{children:[f.steps.length," step(s)"]}),e.jsxs("span",{children:["$",f.estimatedCostUsd.toFixed(4)]}),e.jsx("span",{children:new Date(f.createdAt).toLocaleString()})]})]}),e.jsx(ds,{className:"h-4 w-4 text-zinc-600"})]},f.id))})]})}function X1(){const{id:n}=ll(),i=Dt(),[d,c]=u.useState(null),[m,f]=u.useState(!0),[h,b]=u.useState(!1),[g,p]=u.useState(-1);u.useEffect(()=>{n&&Kd(n).then(c).catch(console.error).finally(()=>f(!1))},[n]);const S=async()=>{if(d){b(!0);try{await G1(d.id);for(let C=0;C<d.steps.length;C++)p(C),await new Promise(w=>setTimeout(w,500));p(d.steps.length);const k=await Kd(d.id);c(k)}catch(k){console.error("Execute failed:",k)}finally{b(!1)}}},y=async()=>{if(d)try{await K1(d.id);const k=await Kd(d.id);c(k)}catch(k){console.error("Cancel failed:",k)}};if(m)return e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent"})});if(!d)return e.jsx("div",{className:"py-20 text-center text-zinc-400",children:"Plan not found."});const v=d.status==="pending"||d.status==="approved";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("button",{onClick:()=>i("/plans"),className:"text-sm text-zinc-500 hover:text-zinc-300",children:"← Back to Plans"}),e.jsxs("h1",{className:"mt-1 text-2xl font-bold text-white",children:["Plan: ",d.id]}),e.jsx("p",{className:"mt-1 text-sm text-zinc-400",children:d.prompt})]}),e.jsx("div",{className:"flex gap-2",children:v&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:S,disabled:h,className:"flex items-center gap-2 rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-500 disabled:opacity-50",children:[e.jsx(Nt,{className:"h-4 w-4"}),"Execute All"]}),e.jsxs("button",{onClick:y,className:"flex items-center gap-2 rounded-lg border border-border px-4 py-2 text-sm font-medium text-zinc-400 hover:text-white hover:border-zinc-600",children:[e.jsx(ft,{className:"h-4 w-4"}),"Cancel"]})]})})]}),e.jsxs("div",{className:"flex gap-4 rounded-lg border border-border bg-surface p-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-zinc-500",children:"Status:"})," ",e.jsx("span",{className:"font-medium text-white",children:d.status})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-zinc-500",children:"Steps:"})," ",e.jsx("span",{className:"font-medium text-white",children:d.steps.length})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-zinc-500",children:"Est. Cost:"})," ",e.jsxs("span",{className:"font-medium text-white",children:["$",d.estimatedCostUsd.toFixed(4)]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-zinc-500",children:"Iterations:"})," ",e.jsx("span",{className:"font-medium text-white",children:d.estimatedIterations})]})]}),e.jsx("div",{className:"space-y-2",children:d.steps.map((k,C)=>{const w=g===C,N=g>C,z=Object.entries(k.args).map(([R,D])=>`${R}: ${typeof D=="string"?D.slice(0,80):JSON.stringify(D).slice(0,80)}`).join(" | ");return e.jsxs("div",{className:`rounded-lg border p-4 transition-colors ${w?"border-indigo-500 bg-indigo-500/5":N?"border-green-500/30 bg-green-500/5":"border-border bg-surface"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`flex h-7 w-7 items-center justify-center rounded-full text-xs font-bold ${N?"bg-green-500/20 text-green-400":w?"bg-indigo-500/20 text-indigo-400":"bg-zinc-800 text-zinc-400"}`,children:N?e.jsx(et,{className:"h-4 w-4"}):C+1}),e.jsx("span",{className:"font-mono text-sm font-medium text-white",children:k.toolName}),e.jsx(q1,{level:k.riskLevel}),w&&e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent"})]}),e.jsx("div",{className:"mt-2 pl-10 text-xs text-zinc-500 font-mono",children:z}),e.jsx("div",{className:"mt-1 pl-10 text-xs text-zinc-600 italic",children:k.mockResult})]},k.index)})})]})}const Q1={file_pattern:"File Pattern",command_pattern:"Command Pattern",url_pattern:"URL Pattern",limit:"Limit"},F1={block:"bg-red-500/10 text-red-400 border-red-500/20",warn:"bg-yellow-500/10 text-yellow-400 border-yellow-500/20",approve:"bg-blue-500/10 text-blue-400 border-blue-500/20"},mc="/api";function xc(){const n={"Content-Type":"application/json"},i=localStorage.getItem("nestor_token");i&&(n.Authorization=`Bearer ${i}`);const d=localStorage.getItem("nestor_tenant_id");return d&&(n["X-Tenant-ID"]=d),n}async function Z1(){const n=await fetch(`${mc}/guardrails`,{headers:xc()});if(!n.ok)throw new Error(`Failed to fetch guardrails: ${n.statusText}`);return(await n.json()).data}async function J1(n){const i=await fetch(`${mc}/guardrails`,{method:"POST",headers:xc(),body:JSON.stringify(n)});if(!i.ok)throw new Error(`Failed to create guardrail: ${i.statusText}`);return(await i.json()).data}async function t0(n,i){const d=await fetch(`${mc}/guardrails/${n}`,{method:"PUT",headers:xc(),body:JSON.stringify(i)});if(!d.ok)throw new Error(`Failed to update guardrail: ${d.statusText}`)}async function I1(n){const i=await fetch(`${mc}/guardrails/${n}`,{method:"DELETE",headers:xc()});if(!i.ok)throw new Error(`Failed to delete guardrail: ${i.statusText}`)}function P1(){const[n,i]=u.useState([]),[d,c]=u.useState(!0),[m,f]=u.useState(!1),[h,b]=u.useState(null),[g,p]=u.useState({name:"",type:"command_pattern",pattern:"",action:"block",config:"{}",enabled:!0}),S=u.useCallback(()=>{c(!0),Z1().then(i).catch(console.error).finally(()=>c(!1))},[]);u.useEffect(()=>{S()},[S]);const y=()=>{p({name:"",type:"command_pattern",pattern:"",action:"block",config:"{}",enabled:!0}),b(null),f(!1)},v=async()=>{if(!g.name.trim()||!g.pattern.trim())return;let N={};try{N=JSON.parse(g.config)}catch{}try{h?await t0(h,{...g,config:N}):await J1({...g,config:N}),y(),S()}catch(z){console.error("Save failed:",z)}},k=async N=>{try{await t0(N.id,{enabled:!N.enabled}),S()}catch(z){console.error("Toggle failed:",z)}},C=async N=>{try{await I1(N),S()}catch(z){console.error("Delete failed:",z)}},w=N=>{p({name:N.name,type:N.type,pattern:N.pattern,action:N.action,config:JSON.stringify(N.config,null,2),enabled:N.enabled}),b(N.id),f(!0)};return d?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-bold text-white",children:"Guardrails"}),e.jsxs("button",{onClick:()=>{y(),f(!0)},className:"flex items-center gap-2 rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-500",children:[e.jsx(ht,{className:"h-4 w-4"}),"Add Rule"]})]}),m&&e.jsxs("div",{className:"rounded-lg border border-border bg-surface p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold text-white",children:h?"Edit Guardrail":"New Guardrail"}),e.jsx("button",{onClick:y,className:"text-zinc-500 hover:text-white",children:e.jsx(Ze,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-zinc-400 mb-1",children:"Name"}),e.jsx("input",{value:g.name,onChange:N=>p(z=>({...z,name:N.target.value})),placeholder:"e.g., Block production DB access",className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-white placeholder:text-zinc-600 focus:border-indigo-500 focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-zinc-400 mb-1",children:"Type"}),e.jsxs("select",{value:g.type,onChange:N=>p(z=>({...z,type:N.target.value})),className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-white focus:border-indigo-500 focus:outline-none",children:[e.jsx("option",{value:"command_pattern",children:"Command Pattern"}),e.jsx("option",{value:"file_pattern",children:"File Pattern"}),e.jsx("option",{value:"url_pattern",children:"URL Pattern"}),e.jsx("option",{value:"limit",children:"Limit"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-zinc-400 mb-1",children:"Pattern (regex or substring)"}),e.jsx("input",{value:g.pattern,onChange:N=>p(z=>({...z,pattern:N.target.value})),placeholder:g.type==="limit"?"shell_exec":"e.g., rm\\s+-rf|DROP\\s+TABLE",className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-white font-mono placeholder:text-zinc-600 focus:border-indigo-500 focus:outline-none"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-zinc-400 mb-1",children:"Action"}),e.jsxs("select",{value:g.action,onChange:N=>p(z=>({...z,action:N.target.value})),className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-white focus:border-indigo-500 focus:outline-none",children:[e.jsx("option",{value:"block",children:"Block"}),e.jsx("option",{value:"warn",children:"Warn"}),e.jsx("option",{value:"approve",children:"Require Approval"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-zinc-400 mb-1",children:"Config (JSON)"}),e.jsx("input",{value:g.config,onChange:N=>p(z=>({...z,config:N.target.value})),placeholder:'e.g., {"maxPerRun": 5}',className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-white font-mono placeholder:text-zinc-600 focus:border-indigo-500 focus:outline-none"})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm text-zinc-400",children:[e.jsx("input",{type:"checkbox",checked:g.enabled,onChange:N=>p(z=>({...z,enabled:N.target.checked})),className:"rounded border-border"}),"Enabled"]}),e.jsx("button",{onClick:v,className:"rounded-lg bg-indigo-600 px-6 py-2 text-sm font-medium text-white hover:bg-indigo-500",children:h?"Update":"Create"})]})]}),n.length===0&&!m?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-border bg-surface p-12 text-center",children:[e.jsx(Ds,{className:"mb-4 h-12 w-12 text-zinc-600"}),e.jsx("p",{className:"text-zinc-400",children:"No guardrails configured."}),e.jsx("p",{className:"mt-1 text-sm text-zinc-600",children:"Add rules to control what tools can do -- block dangerous patterns, enforce limits, or require approval."})]}):e.jsx("div",{className:"space-y-2",children:n.map(N=>e.jsxs("div",{className:`flex items-center justify-between rounded-lg border p-4 transition-colors ${N.enabled?"border-border bg-surface":"border-border/50 bg-surface/50 opacity-60"}`,children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium text-white",children:N.name}),e.jsx("span",{className:"rounded-full bg-zinc-800 px-2 py-0.5 text-[10px] font-medium text-zinc-400",children:Q1[N.type]??N.type}),e.jsx("span",{className:`rounded-full border px-2 py-0.5 text-[10px] font-medium ${F1[N.action]??""}`,children:N.action})]}),e.jsx("div",{className:"mt-1 font-mono text-xs text-zinc-500",children:N.pattern})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>k(N),className:"text-zinc-500 hover:text-white",title:N.enabled?"Disable":"Enable",children:N.enabled?e.jsx($v,{className:"h-5 w-5 text-green-400"}):e.jsx(Uv,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>w(N),className:"text-zinc-500 hover:text-white",title:"Edit",children:e.jsx(pi,{className:"h-4 w-4"})}),e.jsx("button",{onClick:()=>C(N.id),className:"text-zinc-500 hover:text-red-400",title:"Delete",children:e.jsx(Ot,{className:"h-4 w-4"})})]})]},N.id))})]})}const s0={agent:e.jsx(xv,{className:"h-3 w-3"}),project:e.jsx(T0,{className:"h-3 w-3"}),global:e.jsx(mu,{className:"h-3 w-3"})},a0={agent:"bg-blue-500/20 text-blue-400",project:"bg-purple-500/20 text-purple-400",global:"bg-amber-500/20 text-amber-400"};function W1(){const{id:n}=ll(),[i,d]=u.useState([]),[c,m]=u.useState(null),[f,h]=u.useState(!0),[b,g]=u.useState(""),[p,S]=u.useState(""),[y,v]=u.useState(""),[k,C]=u.useState(!1),[w,N]=u.useState(""),[z,R]=u.useState(""),[D,O]=u.useState("agent"),[se,Z]=u.useState(.5),U=u.useCallback(async()=>{if(n){h(!0);try{const Q=new URLSearchParams;b&&Q.set("q",b),p&&Q.set("scope",p),Q.set("limit","100");const[ce,I]=await Promise.all([fetch(`/api/agents/${n}/memory?${Q}`,{credentials:"include"}),fetch(`/api/agents/${n}/memory/stats`,{credentials:"include"})]);if(ce.ok){const le=await ce.json();d(le.data||[])}if(I.ok){const le=await I.json();m(le.data)}}catch{}h(!1)}},[n,b,p]);u.useEffect(()=>{U()},[U]);const A=Q=>{Q.preventDefault(),U()},F=async()=>{var Q;if(!(!n||!w.trim()||!z.trim())){v("");try{const ce=await fetch(`/api/agents/${n}/memory`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:w,value:z,scope:D,importance:se})});if(!ce.ok){const I=await ce.json();throw new Error(((Q=I.error)==null?void 0:Q.message)||"Failed")}C(!1),N(""),R(""),Z(.5),await U()}catch(ce){v(ce.message)}}},$=async Q=>{if(n)try{(await fetch(`/api/agents/${n}/memory/${encodeURIComponent(Q)}`,{method:"DELETE",credentials:"include"})).ok&&d(I=>I.filter(le=>le.key!==Q))}catch{}};return f?e.jsx("div",{className:"flex h-64 items-center justify-center text-zinc-400",children:"Loading..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(La,{className:"h-6 w-6 text-indigo-400"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-white",children:"Agent Memory Store"}),e.jsx("p",{className:"mt-1 text-sm text-zinc-400",children:"Key-value memory entries with scope, importance, and FTS5 search."})]})]}),e.jsxs("button",{onClick:()=>C(!0),className:"flex items-center gap-2 rounded-lg bg-indigo-600 px-3 py-2 text-sm font-medium text-white hover:bg-indigo-700",children:[e.jsx(ht,{className:"h-4 w-4"})," Add Memory"]})]}),y&&e.jsx("div",{className:"rounded-lg border border-red-500/30 bg-red-500/10 px-4 py-2 text-sm text-red-400",children:y}),c&&e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"rounded-lg border border-border bg-surface p-4",children:[e.jsx("div",{className:"text-xs font-medium uppercase tracking-wider text-zinc-400",children:"Total Entries"}),e.jsx("p",{className:"mt-2 text-2xl font-semibold text-white",children:c.total})]}),e.jsxs("div",{className:"rounded-lg border border-border bg-surface p-4",children:[e.jsx("div",{className:"text-xs font-medium uppercase tracking-wider text-zinc-400",children:"Total Size"}),e.jsx("p",{className:"mt-2 text-2xl font-semibold text-white",children:c.totalSize>1024?`${(c.totalSize/1024).toFixed(1)} KB`:`${c.totalSize} B`})]}),e.jsxs("div",{className:"rounded-lg border border-border bg-surface p-4",children:[e.jsx("div",{className:"text-xs font-medium uppercase tracking-wider text-zinc-400",children:"By Scope"}),e.jsx("div",{className:"mt-2 flex gap-2",children:Object.entries(c.byScope).map(([Q,ce])=>e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium ${a0[Q]??"bg-zinc-500/20 text-zinc-400"}`,children:[s0[Q]," ",Q,": ",ce]},Q))})]})]}),k&&e.jsxs("div",{className:"rounded-lg border border-border bg-surface p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-white",children:"Add Memory Entry"}),e.jsx("button",{onClick:()=>C(!1),className:"text-zinc-400 hover:text-white",children:e.jsx(Ze,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx("input",{type:"text",value:w,onChange:Q=>N(Q.target.value),placeholder:"Key (e.g. user_preference_language)",className:"rounded-lg border border-border bg-background px-3 py-2 text-sm text-white"}),e.jsxs("select",{value:D,onChange:Q=>O(Q.target.value),className:"rounded-lg border border-border bg-background px-3 py-2 text-sm text-white",children:[e.jsx("option",{value:"agent",children:"agent"}),e.jsx("option",{value:"project",children:"project"}),e.jsx("option",{value:"global",children:"global"})]})]}),e.jsx("textarea",{value:z,onChange:Q=>R(Q.target.value),placeholder:"Value...",rows:3,className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-white"}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs text-zinc-400",children:["Importance: ",se.toFixed(1)]}),e.jsx("input",{type:"range",min:0,max:100,value:se*100,onChange:Q=>Z(Number(Q.target.value)/100),className:"w-full"})]}),e.jsx("button",{onClick:F,disabled:!w.trim()||!z.trim(),className:"rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 disabled:opacity-50",children:"Store Memory"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("form",{onSubmit:A,className:"flex flex-1 gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(_a,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-zinc-500"}),e.jsx("input",{type:"text",value:b,onChange:Q=>g(Q.target.value),placeholder:"Search by key or value...",className:"w-full rounded-lg border border-border bg-surface py-2 pl-10 pr-4 text-sm text-white placeholder:text-zinc-500 focus:border-indigo-500 focus:outline-none"})]}),e.jsx("button",{type:"submit",className:"rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-500",children:"Search"})]}),e.jsxs("select",{value:p,onChange:Q=>S(Q.target.value),className:"rounded-lg border border-border bg-surface px-3 py-2 text-sm text-white",children:[e.jsx("option",{value:"",children:"All Scopes"}),e.jsx("option",{value:"agent",children:"Agent"}),e.jsx("option",{value:"project",children:"Project"}),e.jsx("option",{value:"global",children:"Global"})]})]}),i.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-border bg-surface py-16",children:[e.jsx(Nv,{className:"h-12 w-12 text-zinc-600"}),e.jsx("p",{className:"mt-4 text-sm text-zinc-400",children:"No memory entries found"}),e.jsx("p",{className:"mt-1 text-xs text-zinc-500",children:"Memory entries are key-value pairs that persist across agent runs."})]}):e.jsx("div",{className:"space-y-2",children:i.map(Q=>e.jsx("div",{className:"group rounded-lg border border-border bg-surface p-4 hover:border-border/80",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium ${a0[Q.scope]??"bg-zinc-500/20 text-zinc-400"}`,children:[s0[Q.scope]," ",Q.scope]}),e.jsx("span",{className:"font-mono text-sm font-medium text-indigo-400",children:Q.key}),e.jsxs("span",{className:"text-xs text-zinc-600",children:["importance: ",(Q.importance*100).toFixed(0),"%"]}),Q.accessCount>0&&e.jsxs("span",{className:"text-xs text-zinc-600",children:["accessed ",Q.accessCount,"x"]})]}),e.jsx("p",{className:"mt-2 text-sm text-zinc-200 leading-relaxed",children:Q.value}),e.jsxs("div",{className:"mt-1 flex items-center gap-3 text-xs text-zinc-500",children:[e.jsxs("span",{children:["Created: ",new Date(Q.createdAt).toLocaleString()]}),Q.expiresAt&&e.jsxs("span",{className:"text-yellow-500",children:["Expires: ",new Date(Q.expiresAt).toLocaleString()]})]})]}),e.jsx("button",{onClick:()=>$(Q.key),className:"rounded p-1.5 text-zinc-500 opacity-0 transition-all hover:bg-red-500/10 hover:text-red-400 group-hover:opacity-100",title:"Delete memory entry",children:e.jsx(Ot,{className:"h-4 w-4"})})]})},Q.id))})]})}function eN(n){return n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(1)} KB`:`${(n/(1024*1024)).toFixed(1)} MB`}function ep(n){const i=Math.floor(n/86400),d=Math.floor(n%86400/3600),c=Math.floor(n%3600/60);return i>0?`${i}d ${d}h ${c}m`:d>0?`${d}h ${c}m`:`${c}m`}function Oa({label:n,value:i,icon:d,color:c="indigo"}){const m={indigo:"bg-indigo-500/10 text-indigo-400",green:"bg-green-500/10 text-green-400",amber:"bg-amber-500/10 text-amber-400",red:"bg-red-500/10 text-red-400",blue:"bg-blue-500/10 text-blue-400",zinc:"bg-zinc-500/10 text-zinc-400"};return e.jsxs("div",{className:"card flex items-center gap-4 p-4",children:[e.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${m[c]??m.indigo}`,children:e.jsx(d,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-zinc-400",children:n}),e.jsx("p",{className:"text-xl font-semibold text-white",children:i})]})]})}function tN(){const[n,i]=u.useState(null),[d,c]=u.useState(null),[m,f]=u.useState(null),[h,b]=u.useState(!0),[g,p]=u.useState(""),S=u.useCallback(async()=>{b(!0),p("");try{const[y,v,k]=await Promise.allSettled([Tt.overview(),Es.health(),Es.stats()]);y.status==="fulfilled"&&i(y.value.data),v.status==="fulfilled"&&c(v.value),k.status==="fulfilled"&&f(k.value.data)}catch(y){p(y.message||"Failed to load overview")}finally{b(!1)}},[]);return u.useEffect(()=>{S()},[S]),h?e.jsx(on,{}):g?e.jsx(ia,{message:g,onRetry:S}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 lg:grid-cols-4",children:[e.jsx(Oa,{label:"Tenants",value:(n==null?void 0:n.tenants)??0,icon:du,color:"indigo"}),e.jsx(Oa,{label:"Users",value:(n==null?void 0:n.users)??0,icon:rl,color:"blue"}),e.jsx(Oa,{label:"Agents",value:(n==null?void 0:n.agents)??0,icon:It,color:"green"}),e.jsx(Oa,{label:"Total Runs",value:(n==null?void 0:n.runs)??0,icon:xu,color:"amber"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"card p-4 space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium text-zinc-300",children:"System Health"}),e.jsxs("div",{className:"flex items-center gap-2",children:[(d==null?void 0:d.status)==="healthy"?e.jsx(A0,{className:"h-5 w-5 text-green-400"}):e.jsx(pt,{className:"h-5 w-5 text-amber-400"}),e.jsx("span",{className:"text-sm text-zinc-200 capitalize",children:(d==null?void 0:d.status)??"Unknown"}),(d==null?void 0:d.uptime)!=null&&e.jsxs("span",{className:"ml-auto text-xs text-zinc-500",children:["Uptime: ",ep(d.uptime)]})]})]}),e.jsxs("div",{className:"card p-4 space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium text-zinc-300",children:"Cost Summary"}),e.jsxs("p",{className:"text-2xl font-semibold text-white",children:["$",((n==null?void 0:n.totalCostUsd)??0).toFixed(4)]}),e.jsx("p",{className:"text-xs text-zinc-500",children:"Total cost across all tenants"})]})]}),m&&e.jsxs("div",{className:"card p-4 space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium text-zinc-300",children:"Run Statistics"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500",children:"Running"}),e.jsx("p",{className:"text-lg font-semibold text-indigo-400",children:m.runs.running})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500",children:"Completed"}),e.jsx("p",{className:"text-lg font-semibold text-green-400",children:m.runs.completed})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500",children:"Failed"}),e.jsx("p",{className:"text-lg font-semibold text-red-400",children:m.runs.failed})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500",children:"Today"}),e.jsx("p",{className:"text-lg font-semibold text-amber-400",children:m.runs.today})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500",children:"Pending Approvals"}),e.jsx("p",{className:"text-lg font-semibold text-zinc-300",children:m.approvals.pending})]})]})]})]})}function sN(){const[n,i]=u.useState([]),[d,c]=u.useState(!0),[m,f]=u.useState(""),[h,b]=u.useState(!1),[g,p]=u.useState({name:"",slug:"",description:""}),[S,y]=u.useState(!1),v=u.useCallback(async()=>{c(!0),f("");try{const C=await Tt.tenants.list();i(C.data)}catch(C){f(C.message||"Failed to load tenants")}finally{c(!1)}},[]);u.useEffect(()=>{v()},[v]);const k=async()=>{if(!(!g.name||!g.slug)){y(!0);try{await Tt.tenants.create(g),b(!1),p({name:"",slug:"",description:""}),await v()}catch(C){f(C.message||"Failed to create tenant")}finally{y(!1)}}};return d?e.jsx(on,{}):m&&n.length===0?e.jsx(ia,{message:m,onRetry:v}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-zinc-400",children:[n.length," tenants"]}),e.jsxs("button",{onClick:()=>b(!0),className:"btn-primary btn-sm",children:[e.jsx(ht,{className:"h-4 w-4"})," Create Tenant"]})]}),m&&e.jsx(ia,{message:m}),h&&e.jsxs("div",{className:"card p-4 space-y-3 border-indigo-500/30",children:[e.jsx("h3",{className:"text-sm font-medium text-zinc-200",children:"New Tenant"}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsx("input",{className:"input",placeholder:"Tenant Name",value:g.name,onChange:C=>p({...g,name:C.target.value})}),e.jsx("input",{className:"input",placeholder:"slug (lowercase-with-dashes)",value:g.slug,onChange:C=>p({...g,slug:C.target.value})})]}),e.jsx("input",{className:"input",placeholder:"Description (optional)",value:g.description,onChange:C=>p({...g,description:C.target.value})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:k,disabled:S,className:"btn-primary btn-sm",children:S?"Creating...":"Create"}),e.jsx("button",{onClick:()=>b(!1),className:"btn-ghost btn-sm",children:"Cancel"})]})]}),e.jsx("div",{className:"overflow-x-auto rounded-lg border border-border",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border bg-surface",children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Name"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Slug"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Description"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Created"})]})}),e.jsxs("tbody",{children:[n.map(C=>e.jsxs("tr",{className:"border-b border-border/50 hover:bg-surface-hover",children:[e.jsx("td",{className:"px-4 py-3 font-medium text-white",children:C.name}),e.jsx("td",{className:"px-4 py-3 font-mono text-xs text-indigo-400",children:C.slug}),e.jsx("td",{className:"px-4 py-3 text-zinc-400 max-w-xs truncate",children:C.description||"-"}),e.jsx("td",{className:"px-4 py-3 text-zinc-500 text-xs",children:new Date(C.createdAt).toLocaleDateString()})]},C.id)),n.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-4 py-8 text-center text-zinc-500",children:"No tenants found."})})]})]})})]})}function aN(){const[n,i]=u.useState([]),[d,c]=u.useState(!0),[m,f]=u.useState(""),[h,b]=u.useState(""),[g,p]=u.useState(""),S=u.useCallback(async()=>{c(!0),f("");try{const C=await Tt.users.list(h?{role:h}:void 0);i(C.data)}catch(C){f(C.message||"Failed to load users")}finally{c(!1)}},[h]);u.useEffect(()=>{S()},[S]);const y=async(C,w)=>{f("");try{await Tt.users.updateRole(C,w),await S()}catch(N){f(N.message||"Failed to update role")}},v=async(C,w)=>{f("");try{w?await Tt.users.lock(C):await Tt.users.unlock(C),await S()}catch(N){f(N.message||"Failed to toggle lock status")}},k=n.filter(C=>{if(!g)return!0;const w=g.toLowerCase();return C.name.toLowerCase().includes(w)||C.email.toLowerCase().includes(w)});return d?e.jsx(on,{}):e.jsxs("div",{className:"space-y-4",children:[m&&e.jsx(ia,{message:m}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(_a,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-zinc-500"}),e.jsx("input",{className:"input pl-9",placeholder:"Search by name or email...",value:g,onChange:C=>p(C.target.value)})]}),e.jsxs("select",{className:"input w-auto",value:h,onChange:C=>b(C.target.value),children:[e.jsx("option",{value:"",children:"All Roles"}),e.jsx("option",{value:"admin",children:"Admin"}),e.jsx("option",{value:"manager",children:"Manager"}),e.jsx("option",{value:"member",children:"Member"}),e.jsx("option",{value:"viewer",children:"Viewer"})]}),e.jsx("button",{onClick:S,className:"btn-ghost btn-sm",children:e.jsx(xt,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"overflow-x-auto rounded-lg border border-border",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border bg-surface",children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Name"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Email"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Role"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Status"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Last Login"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium uppercase text-zinc-400",children:"Actions"})]})}),e.jsxs("tbody",{children:[k.map(C=>e.jsxs("tr",{className:"border-b border-border/50 hover:bg-surface-hover",children:[e.jsx("td",{className:"px-4 py-3 font-medium text-white",children:C.name}),e.jsx("td",{className:"px-4 py-3 text-zinc-300",children:C.email}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("select",{value:C.role,onChange:w=>y(C.id,w.target.value),className:"rounded border border-border bg-background px-2 py-1 text-xs text-white focus:outline-none",children:[e.jsx("option",{value:"admin",children:"Admin"}),e.jsx("option",{value:"manager",children:"Manager"}),e.jsx("option",{value:"member",children:"Member"}),e.jsx("option",{value:"viewer",children:"Viewer"})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium ${C.isActive?"bg-green-500/10 text-green-400":"bg-red-500/10 text-red-400"}`,children:C.isActive?"Active":"Locked"})}),e.jsx("td",{className:"px-4 py-3 text-zinc-400 text-xs",children:C.lastLoginAt?new Date(C.lastLoginAt*1e3).toLocaleString():"Never"}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx("div",{className:"flex items-center justify-end gap-1",children:e.jsx("button",{onClick:()=>v(C.id,C.isActive),className:"rounded p-1.5 text-zinc-400 transition-colors hover:bg-zinc-700",title:C.isActive?"Lock account":"Unlock account",children:C.isActive?e.jsx(Jd,{className:"h-3.5 w-3.5"}):e.jsx(Sv,{className:"h-3.5 w-3.5"})})})})]},C.id)),k.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-4 py-8 text-center text-zinc-500",children:"No users found."})})]})]})})]})}function nN(){const[n,i]=u.useState(null),[d,c]=u.useState(null),[m,f]=u.useState(null),[h,b]=u.useState(!0),[g,p]=u.useState(""),S=u.useCallback(async()=>{b(!0),p("");try{const[y,v,k]=await Promise.allSettled([Tt.system.info(),Tt.system.dbStats(),Tt.system.rateLimitStats()]);y.status==="fulfilled"&&i(y.value.data),v.status==="fulfilled"&&c(v.value.data),k.status==="fulfilled"&&f(k.value.data)}catch(y){p(y.message||"Failed to load system info")}finally{b(!1)}},[]);return u.useEffect(()=>{S()},[S]),h?e.jsx(on,{}):g?e.jsx(ia,{message:g,onRetry:S}):e.jsxs("div",{className:"space-y-6",children:[n&&e.jsxs("div",{className:"card p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fu,{className:"h-4 w-4 text-indigo-400"}),e.jsx("h3",{className:"text-sm font-medium text-zinc-200",children:"Server Information"}),e.jsx("button",{onClick:S,className:"ml-auto btn-ghost btn-sm",children:e.jsx(xt,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500",children:"Version"}),e.jsx("p",{className:"text-sm font-medium text-zinc-200",children:n.version})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500",children:"Node.js"}),e.jsx("p",{className:"text-sm font-medium text-zinc-200",children:n.nodeVersion})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500",children:"Platform"}),e.jsxs("p",{className:"text-sm font-medium text-zinc-200",children:[n.platform," / ",n.arch]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500",children:"Uptime"}),e.jsx("p",{className:"text-sm font-medium text-zinc-200",children:ep(n.uptime)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4 pt-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500",children:"RSS Memory"}),e.jsxs("p",{className:"text-sm font-medium text-zinc-200",children:[n.memory.rss," MB"]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500",children:"Heap Used"}),e.jsxs("p",{className:"text-sm font-medium text-zinc-200",children:[n.memory.heapUsed," MB"]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500",children:"Heap Total"}),e.jsxs("p",{className:"text-sm font-medium text-zinc-200",children:[n.memory.heapTotal," MB"]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-zinc-500",children:"PID"}),e.jsx("p",{className:"text-sm font-medium text-zinc-200",children:n.pid})]})]})]}),d&&e.jsxs("div",{className:"card p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T0,{className:"h-4 w-4 text-green-400"}),e.jsx("h3",{className:"text-sm font-medium text-zinc-200",children:"Database Statistics"}),e.jsx("span",{className:"ml-auto text-xs text-zinc-500",children:eN(d.totalSize)})]}),e.jsx("div",{className:"overflow-x-auto rounded border border-border/50",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/50 bg-background",children:[e.jsx("th",{className:"px-3 py-2 text-left font-medium text-zinc-400",children:"Table"}),e.jsx("th",{className:"px-3 py-2 text-right font-medium text-zinc-400",children:"Rows"})]})}),e.jsx("tbody",{children:d.tables.map(y=>e.jsxs("tr",{className:"border-b border-border/30",children:[e.jsx("td",{className:"px-3 py-1.5 font-mono text-zinc-300",children:y.name}),e.jsx("td",{className:"px-3 py-1.5 text-right text-zinc-400",children:y.rowCount.toLocaleString()})]},y.name))})]})})]}),m&&e.jsxs("div",{className:"card p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(It,{className:"h-4 w-4 text-amber-400"}),e.jsx("h3",{className:"text-sm font-medium text-zinc-200",children:"Rate Limit Counters"}),e.jsxs("span",{className:"ml-auto text-xs text-zinc-500",children:[m.totalKeys," active keys"]})]}),m.entries.length>0?e.jsx("div",{className:"overflow-x-auto rounded border border-border/50 max-h-60 overflow-y-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/50 bg-background sticky top-0",children:[e.jsx("th",{className:"px-3 py-2 text-left font-medium text-zinc-400",children:"Key"}),e.jsx("th",{className:"px-3 py-2 text-right font-medium text-zinc-400",children:"Count"}),e.jsx("th",{className:"px-3 py-2 text-right font-medium text-zinc-400",children:"Reset"})]})}),e.jsx("tbody",{children:m.entries.slice(0,50).map((y,v)=>e.jsxs("tr",{className:"border-b border-border/30",children:[e.jsx("td",{className:"px-3 py-1.5 font-mono text-zinc-300 max-w-xs truncate",children:y.key}),e.jsx("td",{className:"px-3 py-1.5 text-right text-zinc-400",children:y.count}),e.jsx("td",{className:"px-3 py-1.5 text-right text-zinc-500",children:new Date(y.resetAt).toLocaleTimeString()})]},v))})]})}):e.jsx("p",{className:"text-xs text-zinc-500",children:"No active rate limit counters."})]})]})}function lN(){const[n,i]=u.useState([]),[d,c]=u.useState(!0),[m,f]=u.useState(""),[h,b]=u.useState(""),[g,p]=u.useState(""),S=u.useCallback(async()=>{c(!0),f("");try{const v=await Tt.audit.query({action:h||void 0,userId:g||void 0,limit:200});i(v.data)}catch(v){f(v.message||"Failed to load audit log")}finally{c(!1)}},[h,g]);u.useEffect(()=>{S()},[S]);const y=async v=>{try{const k=await Tt.audit.export(v),C=v==="json"?JSON.stringify(k.data,null,2):iN(k.data),w=new Blob([C],{type:v==="json"?"application/json":"text/csv"}),N=URL.createObjectURL(w),z=document.createElement("a");z.href=N,z.download=`audit-log.${v}`,z.click(),URL.revokeObjectURL(N)}catch(k){f(k.message||"Export failed")}};return d?e.jsx(on,{}):e.jsxs("div",{className:"space-y-4",children:[m&&e.jsx(ia,{message:m}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("input",{className:"input flex-1 min-w-[150px]",placeholder:"Filter by action...",value:h,onChange:v=>b(v.target.value)}),e.jsx("input",{className:"input flex-1 min-w-[150px]",placeholder:"Filter by actor ID...",value:g,onChange:v=>p(v.target.value)}),e.jsx("button",{onClick:S,className:"btn-ghost btn-sm",children:e.jsx(xt,{className:"h-4 w-4"})}),e.jsxs("button",{onClick:()=>y("json"),className:"btn-ghost btn-sm",children:[e.jsx(hi,{className:"h-4 w-4"})," JSON"]}),e.jsxs("button",{onClick:()=>y("csv"),className:"btn-ghost btn-sm",children:[e.jsx(hi,{className:"h-4 w-4"})," CSV"]})]}),e.jsx("div",{className:"overflow-x-auto rounded-lg border border-border",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border bg-surface",children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Time"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Actor"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Action"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Resource"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"IP"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400",children:"Details"})]})}),e.jsxs("tbody",{children:[n.map(v=>{var k;return e.jsxs("tr",{className:"border-b border-border/50 hover:bg-surface-hover",children:[e.jsx("td",{className:"px-4 py-2.5 text-zinc-400 text-xs whitespace-nowrap",children:new Date(v.createdAt*1e3).toLocaleString()}),e.jsx("td",{className:"px-4 py-2.5 text-zinc-300 text-xs font-mono",children:((k=v.userId)==null?void 0:k.slice(0,8))||"-"}),e.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-indigo-400",children:v.action}),e.jsx("td",{className:"px-4 py-2.5 text-zinc-300 text-xs",children:v.resourceType?`${v.resourceType}${v.resourceId?`/${v.resourceId.slice(0,8)}`:""}`:"-"}),e.jsx("td",{className:"px-4 py-2.5 text-zinc-500 text-xs",children:v.ipAddress||"-"}),e.jsx("td",{className:"px-4 py-2.5 text-xs text-zinc-500 max-w-[200px] truncate",children:v.details?JSON.stringify(v.details):"-"})]},v.id)}),n.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-4 py-8 text-center text-zinc-500",children:"No audit entries found."})})]})]})})]})}function iN(n){const i="id,userId,action,resourceType,resourceId,ipAddress,createdAt,details",d=n.map(c=>[c.id,c.userId??"",c.action,c.resourceType??"",c.resourceId??"",c.ipAddress??"",new Date(c.createdAt*1e3).toISOString(),c.details?JSON.stringify(c.details).replace(/"/g,'""'):""].map(m=>`"${m}"`).join(","));return[i,...d].join(`
595
+ `)}function rN(){const[n,i]=u.useState([]),[d,c]=u.useState([]),[m,f]=u.useState([]),[h,b]=u.useState([]),[g,p]=u.useState(!0),[S,y]=u.useState(""),v=u.useCallback(async()=>{p(!0),y("");try{const[k,C,w,N]=await Promise.allSettled([Tt.security.failedLogins(24),Tt.security.lockedAccounts(),Tt.security.activeSessions(),Tt.security.rateLimitViolations(50)]);k.status==="fulfilled"&&i(k.value.data),C.status==="fulfilled"&&c(C.value.data),w.status==="fulfilled"&&f(w.value.data),N.status==="fulfilled"&&b(N.value.data)}catch(k){y(k.message||"Failed to load security data")}finally{p(!1)}},[]);return u.useEffect(()=>{v()},[v]),g?e.jsx(on,{}):S?e.jsx(ia,{message:S,onRetry:v}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 lg:grid-cols-4",children:[e.jsx(Oa,{label:"Failed Logins (24h)",value:n.reduce((k,C)=>k+C.count,0),icon:ft,color:"red"}),e.jsx(Oa,{label:"Locked Accounts",value:d.length,icon:Jd,color:"amber"}),e.jsx(Oa,{label:"Active Sessions",value:m.length,icon:rl,color:"green"}),e.jsx(Oa,{label:"Rate Violations",value:h.length,icon:Ms,color:"red"})]}),e.jsxs("div",{className:"card p-4 space-y-3",children:[e.jsxs("h3",{className:"text-sm font-medium text-zinc-200 flex items-center gap-2",children:[e.jsx(ft,{className:"h-4 w-4 text-red-400"})," Failed Login Attempts (Last 24h)"]}),n.length>0?e.jsx("div",{className:"overflow-x-auto rounded border border-border/50",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/50 bg-background",children:[e.jsx("th",{className:"px-3 py-2 text-left font-medium text-zinc-400",children:"Email"}),e.jsx("th",{className:"px-3 py-2 text-left font-medium text-zinc-400",children:"IP"}),e.jsx("th",{className:"px-3 py-2 text-right font-medium text-zinc-400",children:"Attempts"}),e.jsx("th",{className:"px-3 py-2 text-right font-medium text-zinc-400",children:"First Seen"})]})}),e.jsx("tbody",{children:n.map((k,C)=>e.jsxs("tr",{className:"border-b border-border/30",children:[e.jsx("td",{className:"px-3 py-1.5 text-zinc-300",children:k.email}),e.jsx("td",{className:"px-3 py-1.5 font-mono text-zinc-400",children:k.ip}),e.jsx("td",{className:"px-3 py-1.5 text-right font-semibold text-red-400",children:k.count}),e.jsx("td",{className:"px-3 py-1.5 text-right text-zinc-500",children:new Date(k.timestamp).toLocaleString()})]},C))})]})}):e.jsx("p",{className:"text-xs text-zinc-500",children:"No failed login attempts in the last 24 hours."})]}),e.jsxs("div",{className:"card p-4 space-y-3",children:[e.jsxs("h3",{className:"text-sm font-medium text-zinc-200 flex items-center gap-2",children:[e.jsx(Jd,{className:"h-4 w-4 text-amber-400"})," Locked Accounts"]}),d.length>0?e.jsx("div",{className:"overflow-x-auto rounded border border-border/50",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/50 bg-background",children:[e.jsx("th",{className:"px-3 py-2 text-left font-medium text-zinc-400",children:"Email"}),e.jsx("th",{className:"px-3 py-2 text-left font-medium text-zinc-400",children:"Reason"}),e.jsx("th",{className:"px-3 py-2 text-right font-medium text-zinc-400",children:"Locked At"})]})}),e.jsx("tbody",{children:d.map((k,C)=>e.jsxs("tr",{className:"border-b border-border/30",children:[e.jsx("td",{className:"px-3 py-1.5 text-zinc-300",children:k.email}),e.jsx("td",{className:"px-3 py-1.5 text-zinc-400",children:k.reason}),e.jsx("td",{className:"px-3 py-1.5 text-right text-zinc-500",children:new Date(k.lockedAt).toLocaleString()})]},C))})]})}):e.jsx("p",{className:"text-xs text-zinc-500",children:"No locked accounts."})]}),e.jsxs("div",{className:"card p-4 space-y-3",children:[e.jsxs("h3",{className:"text-sm font-medium text-zinc-200 flex items-center gap-2",children:[e.jsx(vs,{className:"h-4 w-4 text-green-400"})," Active Sessions (",m.length,")"]}),m.length>0?e.jsx("div",{className:"overflow-x-auto rounded border border-border/50 max-h-60 overflow-y-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/50 bg-background sticky top-0",children:[e.jsx("th",{className:"px-3 py-2 text-left font-medium text-zinc-400",children:"Email"}),e.jsx("th",{className:"px-3 py-2 text-left font-medium text-zinc-400",children:"IP"}),e.jsx("th",{className:"px-3 py-2 text-right font-medium text-zinc-400",children:"Created"}),e.jsx("th",{className:"px-3 py-2 text-right font-medium text-zinc-400",children:"Expires"})]})}),e.jsx("tbody",{children:m.map((k,C)=>e.jsxs("tr",{className:"border-b border-border/30",children:[e.jsx("td",{className:"px-3 py-1.5 text-zinc-300",children:k.email}),e.jsx("td",{className:"px-3 py-1.5 font-mono text-zinc-400",children:k.ip}),e.jsx("td",{className:"px-3 py-1.5 text-right text-zinc-500",children:new Date(k.createdAt).toLocaleString()}),e.jsx("td",{className:"px-3 py-1.5 text-right text-zinc-500",children:new Date(k.expiresAt).toLocaleString()})]},C))})]})}):e.jsx("p",{className:"text-xs text-zinc-500",children:"No active sessions."})]}),e.jsxs("div",{className:"card p-4 space-y-3",children:[e.jsxs("h3",{className:"text-sm font-medium text-zinc-200 flex items-center gap-2",children:[e.jsx(Ms,{className:"h-4 w-4 text-red-400"})," Recent Rate Limit Violations"]}),h.length>0?e.jsx("div",{className:"overflow-x-auto rounded border border-border/50 max-h-60 overflow-y-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/50 bg-background sticky top-0",children:[e.jsx("th",{className:"px-3 py-2 text-left font-medium text-zinc-400",children:"Time"}),e.jsx("th",{className:"px-3 py-2 text-left font-medium text-zinc-400",children:"Tier"}),e.jsx("th",{className:"px-3 py-2 text-left font-medium text-zinc-400",children:"IP"}),e.jsx("th",{className:"px-3 py-2 text-left font-medium text-zinc-400",children:"User"}),e.jsx("th",{className:"px-3 py-2 text-left font-medium text-zinc-400",children:"Endpoint"})]})}),e.jsx("tbody",{children:h.map((k,C)=>{var w;return e.jsxs("tr",{className:"border-b border-border/30",children:[e.jsx("td",{className:"px-3 py-1.5 text-zinc-400 whitespace-nowrap",children:new Date(k.timestamp).toLocaleString()}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx("span",{className:"rounded-full bg-red-500/10 px-1.5 py-0.5 text-red-400",children:k.tier})}),e.jsx("td",{className:"px-3 py-1.5 font-mono text-zinc-400",children:k.ip}),e.jsx("td",{className:"px-3 py-1.5 text-zinc-400",children:((w=k.userId)==null?void 0:w.slice(0,8))||"-"}),e.jsx("td",{className:"px-3 py-1.5 font-mono text-zinc-300 max-w-[200px] truncate",children:k.endpoint})]},C)})})]})}):e.jsx("p",{className:"text-xs text-zinc-500",children:"No rate limit violations recorded."})]})]})}function cN(){const[n,i]=u.useState(null),[d,c]=u.useState(null),[m,f]=u.useState(!0),[h,b]=u.useState(!1),[g,p]=u.useState(""),[S,y]=u.useState(""),[v,k]=u.useState(!1),C=u.useCallback(async()=>{f(!0),p(""),y("");try{const R=await Es.getConfig();i(R.data),c(R.data),k(!1)}catch(R){p(R.message||"Failed to load configuration")}finally{f(!1)}},[]);u.useEffect(()=>{C()},[C]);const w=(R,D,O)=>{d&&(c({...d,[R]:{...d[R],[D]:O}}),k(!0),y(""))},N=async()=>{if(d){b(!0),p(""),y("");try{const R=await Es.updateConfig(d);i(R.data),c(R.data),k(!1),y("Configuration saved successfully.")}catch(R){p(R.message||"Failed to save configuration")}finally{b(!1)}}},z=()=>{n&&(c({...n}),k(!1),y(""))};return m?e.jsx(on,{}):g&&!d?e.jsx(ia,{message:g,onRetry:C}):e.jsxs("div",{className:"space-y-6",children:[g&&e.jsx(ia,{message:g}),S&&e.jsxs("div",{className:"rounded-lg border border-green-500/30 bg-green-500/10 px-4 py-3 text-sm text-green-400 flex items-center gap-2",children:[e.jsx(A0,{className:"h-4 w-4 flex-shrink-0"}),S]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-zinc-400",children:"Runtime configuration (changes apply immediately)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:C,className:"btn-ghost btn-sm",children:e.jsx(xt,{className:"h-4 w-4"})}),e.jsx("button",{onClick:z,disabled:!v,className:"btn-secondary btn-sm",children:"Reset"}),e.jsxs("button",{onClick:N,disabled:!v||h,className:"btn-primary btn-sm",children:[e.jsx(cc,{className:"h-4 w-4"})," ",h?"Saving...":"Save"]})]})]}),d&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"card p-4 space-y-3",children:[e.jsxs("h3",{className:"text-sm font-medium text-zinc-200 flex items-center gap-2",children:[e.jsx(fu,{className:"h-4 w-4 text-indigo-400"})," Server"]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Host"}),e.jsx("input",{className:"input",value:d.server.host,onChange:R=>w("server","host",R.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Port"}),e.jsx("input",{className:"input",type:"number",value:d.server.port,onChange:R=>w("server","port",parseInt(R.target.value)||0)})]})]})]}),e.jsxs("div",{className:"card p-4 space-y-3",children:[e.jsxs("h3",{className:"text-sm font-medium text-zinc-200 flex items-center gap-2",children:[e.jsx(Ms,{className:"h-4 w-4 text-amber-400"})," Security"]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Default Trust Level"}),e.jsxs("select",{className:"input",value:d.security.defaultTrustLevel,onChange:R=>w("security","defaultTrustLevel",R.target.value),children:[e.jsx("option",{value:"builtin",children:"Builtin"}),e.jsx("option",{value:"official",children:"Official"}),e.jsx("option",{value:"trusted",children:"Trusted"}),e.jsx("option",{value:"community",children:"Community"}),e.jsx("option",{value:"local",children:"Local"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Approval Mode"}),e.jsxs("select",{className:"input",value:d.security.approvalMode,onChange:R=>w("security","approvalMode",R.target.value),children:[e.jsx("option",{value:"manual",children:"Manual"}),e.jsx("option",{value:"smart",children:"Smart"}),e.jsx("option",{value:"off",children:"Off"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Max Concurrent Runs"}),e.jsx("input",{className:"input",type:"number",min:1,max:100,value:d.security.maxConcurrentRuns,onChange:R=>w("security","maxConcurrentRuns",parseInt(R.target.value)||1)})]})]})]}),e.jsxs("div",{className:"card p-4 space-y-3",children:[e.jsxs("h3",{className:"text-sm font-medium text-zinc-200 flex items-center gap-2",children:[e.jsx(It,{className:"h-4 w-4 text-green-400"})," Budget"]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Enabled"}),e.jsxs("select",{className:"input",value:d.budget.enabled?"true":"false",onChange:R=>w("budget","enabled",R.target.value==="true"),children:[e.jsx("option",{value:"true",children:"Yes"}),e.jsx("option",{value:"false",children:"No"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Max Cost/Run (USD)"}),e.jsx("input",{className:"input",type:"number",step:"0.01",min:0,value:d.budget.defaultMaxCostPerRunUsd,onChange:R=>w("budget","defaultMaxCostPerRunUsd",parseFloat(R.target.value)||0)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Max Tokens/Run"}),e.jsx("input",{className:"input",type:"number",min:0,value:d.budget.defaultMaxTokensPerRun,onChange:R=>w("budget","defaultMaxTokensPerRun",parseInt(R.target.value)||0)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Warning Threshold %"}),e.jsx("input",{className:"input",type:"number",min:0,max:100,value:d.budget.warningThresholdPercent,onChange:R=>w("budget","warningThresholdPercent",parseInt(R.target.value)||0)})]})]})]}),e.jsxs("div",{className:"card p-4 space-y-3",children:[e.jsxs("h3",{className:"text-sm font-medium text-zinc-200 flex items-center gap-2",children:[e.jsx(Ua,{className:"h-4 w-4 text-blue-400"})," Logging"]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Level"}),e.jsxs("select",{className:"input",value:d.logging.level,onChange:R=>w("logging","level",R.target.value),children:[e.jsx("option",{value:"debug",children:"Debug"}),e.jsx("option",{value:"info",children:"Info"}),e.jsx("option",{value:"warn",children:"Warn"}),e.jsx("option",{value:"error",children:"Error"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Format"}),e.jsxs("select",{className:"input",value:d.logging.format,onChange:R=>w("logging","format",R.target.value),children:[e.jsx("option",{value:"json",children:"JSON"}),e.jsx("option",{value:"pretty",children:"Pretty"})]})]})]})]}),e.jsxs("div",{className:"card p-4 space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium text-zinc-200",children:"Current Configuration (JSON)"}),e.jsx("pre",{className:"overflow-x-auto rounded border border-border/50 bg-background p-3 text-xs text-zinc-400 max-h-60 overflow-y-auto",children:JSON.stringify(d,null,2)})]})]})]})}function on(){return e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent"})})}function ia({message:n,onRetry:i}){return e.jsx("div",{className:"rounded-lg border border-red-500/30 bg-red-500/10 px-4 py-3 text-sm text-red-400",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pt,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{children:n}),i&&e.jsx("button",{onClick:i,className:"ml-auto text-xs underline hover:text-red-300",children:"Retry"})]})})}const oN=[{key:"overview",label:"Overview",icon:xu},{key:"tenants",label:"Tenants",icon:du},{key:"users",label:"Users",icon:rl},{key:"system",label:"System",icon:fu},{key:"audit",label:"Audit Log",icon:Ua},{key:"security",label:"Security",icon:Ms},{key:"config",label:"Config",icon:il}];function dN(){const{isAdmin:n}=ol(),[i,d]=u.useState("overview");return n?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-white",children:"Admin Dashboard"}),e.jsx("p",{className:"mt-1 text-sm text-zinc-400",children:"Multi-tenant administration and system monitoring."})]}),e.jsx("div",{className:"flex gap-1 border-b border-border overflow-x-auto",children:oN.map(({key:c,label:m,icon:f})=>e.jsxs("button",{onClick:()=>d(c),className:`flex items-center gap-2 whitespace-nowrap px-4 py-2.5 text-sm font-medium transition-colors border-b-2 ${i===c?"border-indigo-500 text-indigo-400":"border-transparent text-zinc-400 hover:text-zinc-200"}`,children:[e.jsx(f,{className:"h-4 w-4"}),m]},c))}),i==="overview"&&e.jsx(tN,{}),i==="tenants"&&e.jsx(sN,{}),i==="users"&&e.jsx(aN,{}),i==="system"&&e.jsx(nN,{}),i==="audit"&&e.jsx(lN,{}),i==="security"&&e.jsx(rN,{}),i==="config"&&e.jsx(cN,{})]}):e.jsxs("div",{className:"flex h-64 items-center justify-center text-zinc-400",children:[e.jsx(Ms,{className:"mr-2 h-5 w-5"})," Admin access required."]})}function uN(n){switch(n){case"claude":return"claude-sonnet-4-20250514";case"openai":return"gpt-4o";case"gemini":return"gemini-2.5-flash";case"grok":return"grok-3";case"mistral":return"mistral-large-latest";case"ollama":return"llama3.1";default:return"claude-sonnet-4-20250514"}}function mN(n){return n.startsWith("file_")?e.jsx(Ua,{className:"h-3 w-3"}):n==="shell_exec"?e.jsx(O0,{className:"h-3 w-3"}):n==="web_fetch"?e.jsx(mu,{className:"h-3 w-3"}):e.jsx(cl,{className:"h-3 w-3"})}function tp(n,i){return n==="file_read"&&i.path?`Reading: ${i.path}`:n==="file_write"&&i.path?`Writing: ${i.path}`:n==="file_list"&&i.path?`Listing: ${i.path||"."}`:n==="shell_exec"&&i.command?`Running: ${String(i.command).substring(0,80)}`:n==="web_fetch"&&i.url?`Fetching: ${String(i.url).substring(0,80)}`:Object.entries(i).map(([c,m])=>`${c}=${JSON.stringify(m)}`).join(", ").substring(0,100)||"No arguments"}function xN(n,i=500){return n.length<=i?n:n.substring(0,i)+`
596
+ ... (${n.length} chars total)`}function fN({tc:n}){const[i,d]=u.useState(!1),c=n.pending&&!n.output;return e.jsxs("div",{className:"mb-2 rounded-lg text-xs border border-border/50 overflow-hidden",children:[e.jsxs("button",{onClick:()=>d(!i),className:"w-full flex items-center gap-2 px-3 py-2 bg-zinc-800/50 hover:bg-zinc-800/80 transition-colors text-left",children:[i?e.jsx(na,{className:"h-3 w-3 text-zinc-500 flex-shrink-0"}):e.jsx(ds,{className:"h-3 w-3 text-zinc-500 flex-shrink-0"}),e.jsx("span",{className:"text-amber-400 flex-shrink-0",children:mN(n.name)}),e.jsx("span",{className:"text-amber-300 font-mono font-medium",children:n.name}),e.jsx("span",{className:"text-zinc-500 truncate flex-1 ml-1",children:tp(n.name,n.args)}),c?e.jsx(rt,{className:"h-3 w-3 animate-spin text-blue-400 flex-shrink-0"}):n.success?e.jsx("span",{className:"text-green-400 flex-shrink-0 text-[10px] font-medium",children:"OK"}):e.jsx("span",{className:"text-red-400 flex-shrink-0 text-[10px] font-medium",children:"FAIL"})]}),i&&e.jsxs("div",{className:"px-3 py-2 bg-zinc-900/50 border-t border-border/30",children:[e.jsxs("div",{className:"mb-1.5",children:[e.jsx("span",{className:"text-zinc-500 text-[10px] uppercase tracking-wider",children:"Arguments"}),e.jsx("pre",{className:"mt-0.5 text-zinc-400 overflow-x-auto whitespace-pre-wrap text-[11px] font-mono",children:JSON.stringify(n.args,null,2)})]}),n.output&&e.jsxs("div",{children:[e.jsx("span",{className:"text-zinc-500 text-[10px] uppercase tracking-wider",children:"Output"}),e.jsx("pre",{className:`mt-0.5 overflow-x-auto whitespace-pre-wrap text-[11px] font-mono ${n.success?"text-zinc-400":"text-red-400"}`,children:xN(n.output)})]}),c&&e.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400 mt-1",children:[e.jsx(rt,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{className:"text-[11px]",children:"Executing..."})]})]})]})}function hN(n){return n==="critical"?"text-red-500 bg-red-500/10":n==="high"?"text-orange-400 bg-orange-400/10":n==="medium"?"text-yellow-400 bg-yellow-400/10":"text-green-400 bg-green-400/10"}function pN({steps:n}){const[i,d]=u.useState(!0);return e.jsxs("div",{className:"mb-3 rounded-lg border border-indigo-500/30 overflow-hidden",children:[e.jsxs("button",{onClick:()=>d(!i),className:"w-full flex items-center gap-2 px-3 py-2 bg-indigo-500/10 hover:bg-indigo-500/15 transition-colors text-left text-sm",children:[i?e.jsx(na,{className:"h-3 w-3 text-indigo-400"}):e.jsx(ds,{className:"h-3 w-3 text-indigo-400"}),e.jsx("span",{className:"text-indigo-300 font-medium",children:"Dry-Run Plan"}),e.jsxs("span",{className:"text-zinc-500 text-xs",children:[n.length," step",n.length!==1?"s":""]})]}),i&&e.jsx("div",{className:"px-3 py-2 space-y-1.5 bg-zinc-900/30",children:n.map(c=>e.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[e.jsxs("span",{className:"text-zinc-500 font-mono w-4 text-right flex-shrink-0",children:[c.index+1,"."]}),e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium flex-shrink-0 ${hN(c.riskLevel)}`,children:c.riskLevel.toUpperCase()}),e.jsx("span",{className:"text-amber-300 font-mono",children:c.toolName}),e.jsx("span",{className:"text-zinc-500 truncate",children:tp(c.toolName,c.args)})]},c.index))})]})}function gN({agent:n,onClose:i,onSave:d}){const[c,m]=u.useState(n.description||""),[f,h]=u.useState(!1),[b,g]=u.useState(""),p=u.useRef(null);u.useEffect(()=>{var y;(y=p.current)==null||y.focus()},[]);const S=async()=>{h(!0),g("");try{const y=await fetch(`/api/agents/${n.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:c})});if(!y.ok){const k=await y.json().catch(()=>({error:"Failed to save"}));throw new Error(k.error||`HTTP ${y.status}`)}const v=await y.json();d(v.data)}catch(y){g(y instanceof Error?y.message:"Failed to save")}h(!1)};return u.useEffect(()=>{const y=v=>{v.key==="Escape"&&i()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[i]),e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:i,children:e.jsxs("div",{className:"bg-surface border border-border rounded-xl shadow-2xl w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:y=>y.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-zinc-200",children:"System Prompt"}),e.jsxs("p",{className:"text-xs text-zinc-500 mt-0.5",children:[n.name," (",n.adapterType,")"]})]}),e.jsx("button",{onClick:i,className:"p-1.5 hover:bg-surface-hover rounded-lg transition-colors text-zinc-400 hover:text-zinc-200",children:e.jsx(Ze,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex-1 p-5 overflow-hidden",children:e.jsx("textarea",{ref:p,value:c,onChange:y=>m(y.target.value),className:"w-full h-full min-h-[300px] bg-background border border-border rounded-lg px-4 py-3 resize-none focus:outline-none focus:border-indigo-500 text-zinc-200 text-sm font-mono placeholder-zinc-600",placeholder:"You are a helpful AI assistant...",spellCheck:!1})}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-t border-border",children:[e.jsxs("div",{className:"text-xs text-zinc-500",children:[c.length.toLocaleString()," chars",b&&e.jsx("span",{className:"text-red-400 ml-3",children:b})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:i,className:"px-3 py-1.5 text-sm text-zinc-400 hover:text-zinc-200 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:S,disabled:f,className:"flex items-center gap-1.5 px-4 py-1.5 bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50 rounded-lg text-sm font-medium transition-colors text-white",children:[f?e.jsx(rt,{className:"h-3 w-3 animate-spin"}):e.jsx(cc,{className:"h-3 w-3"}),"Save"]})]})]})]})})}function bN(){var de;const n=Dt(),[i,d]=u.useState([]),[c,m]=u.useState(null),[f,h]=u.useState([]),[b,g]=u.useState(null),[p,S]=u.useState([]),[y,v]=u.useState(""),[k,C]=u.useState(!1),[w,N]=u.useState(!0),[z,R]=u.useState(!1),[D,O]=u.useState([]),[se,Z]=u.useState(!1),[U,A]=u.useState(null),[F,$]=u.useState(null),[Q,ce]=u.useState(""),I=u.useRef(null),le=u.useRef(null),Y=u.useRef(null);u.useEffect(()=>{var G;(G=I.current)==null||G.scrollIntoView({behavior:"smooth"})},[p]),u.useEffect(()=>{const G=le.current;G&&(G.style.height="48px",G.style.height=Math.min(G.scrollHeight,200)+"px")},[y]);const B=u.useCallback(G=>{const oe=G?`/api/chat/conversations?agentId=${encodeURIComponent(G)}`:"/api/chat/conversations";fetch(oe).then(fe=>fe.json()).then(fe=>h(fe.data||[])).catch(()=>{})},[]);u.useEffect(()=>{fetch("/api/agents").then(G=>G.json()).then(G=>{const oe=G.data||[];d(oe),oe.length>0&&!c?(m(oe[0]),B(oe[0].id)):B()}).catch(()=>{})},[]),u.useEffect(()=>{c&&B(c.id)},[c==null?void 0:c.id,B]);const ne=u.useCallback(G=>{g(G),fetch(`/api/chat/conversations/${G.id}`).then(oe=>oe.json()).then(oe=>{var be;S(((be=oe.data)==null?void 0:be.messages)||[]);const fe=i.find(Ce=>{var ve;return Ce.id===((ve=oe.data)==null?void 0:ve.agentId)});fe&&m(fe)}).catch(()=>{})},[i]),me=u.useCallback(()=>{var G;g(null),S([]),R(!1),O([]),(G=le.current)==null||G.focus()},[]),ue=u.useCallback((G,oe)=>{G.stopPropagation(),fetch(`/api/chat/conversations/${oe}`,{method:"DELETE"}).then(()=>{h(fe=>fe.filter(be=>be.id!==oe)),(b==null?void 0:b.id)===oe&&me()}).catch(()=>{})},[b,me]),je=u.useCallback(async()=>{var be;if(!y.trim()||!c||k)return;const G={role:"user",content:y.trim(),timestamp:Date.now()};ce(y.trim()),$(null),S(Ce=>[...Ce,G]),v(""),C(!0);const oe={role:"assistant",content:"",timestamp:Date.now(),isStreaming:!0,toolCalls:[]};S(Ce=>[...Ce,oe]);const fe=new AbortController;Y.current=fe;try{const Ce=await fetch(`/api/chat/${c.id}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:y.trim(),conversationId:b==null?void 0:b.id}),signal:fe.signal});if(!Ce.body)throw new Error("No response body");const ve=Ce.body.getReader(),tt=new TextDecoder;let Xe="";for(;;){const{done:Lt,value:Ns}=await ve.read();if(Lt)break;Xe+=tt.decode(Ns,{stream:!0});const At=Xe.split(`
597
+ `);Xe=At.pop()||"";for(const Kt of At){if(!Kt.startsWith("data: "))continue;let qe;try{qe=JSON.parse(Kt.slice(6))}catch{continue}switch(qe.type){case"system":R(!0),O(qe.tools||[]);break;case"token":S(nt=>{const L=[...nt],te=L[L.length-1];return te&&te.role==="assistant"&&(L[L.length-1]={...te,content:te.content+qe.text}),L});break;case"thinking":S(nt=>{const L=[...nt],te=L[L.length-1];return te&&te.role==="assistant"&&(L[L.length-1]={...te,thinking:(te.thinking||"")+qe.text}),L});break;case"tool_start":S(nt=>{const L=[...nt],te=L[L.length-1];return te&&te.role==="assistant"&&(L[L.length-1]={...te,toolCalls:[...te.toolCalls||[],{name:qe.name,args:qe.args||{},output:"",success:!0,pending:!0}]}),L});break;case"tool_result":S(nt=>{var ye;const L=[...nt],te=L[L.length-1];if(te&&te.role==="assistant"&&((ye=te.toolCalls)!=null&&ye.length)){const We=[...te.toolCalls];let fs=-1;for(let hs=We.length-1;hs>=0;hs--)if(We[hs].name===qe.name&&We[hs].pending){fs=hs;break}fs===-1&&(fs=We.length-1),We[fs]={...We[fs],output:qe.output,success:qe.success,pending:!1},L[L.length-1]={...te,toolCalls:We}}return L});break;case"done":S(nt=>{const L=[...nt],te=L[L.length-1];return te&&te.role==="assistant"&&(L[L.length-1]={...te,isStreaming:!1,usage:qe.usage}),L}),qe.conversationId&&!b&&(g({id:qe.conversationId}),B(c==null?void 0:c.id));break;case"plan":qe.plan&&qe.plan.steps&&A(qe.plan.steps);break;case"mission_suggestion":$({message:qe.message,objective:Q});break;case"error":S(nt=>{const L=[...nt],te=L[L.length-1];return te&&te.role==="assistant"&&(L[L.length-1]={...te,content:te.content?te.content+`
598
+
599
+ Error: ${qe.message}`:`Error: ${qe.message}`,isStreaming:!1}),L});break;case"reasoning":break}}}}catch(Ce){if(Ce instanceof DOMException&&Ce.name==="AbortError")S(ve=>{const tt=[...ve],Xe=tt[tt.length-1];return Xe&&Xe.role==="assistant"&&(tt[tt.length-1]={...Xe,isStreaming:!1}),tt});else{const ve=Ce instanceof Error?Ce.message:"Connection error";S(tt=>{const Xe=[...tt],Lt=Xe[Xe.length-1];return Lt&&Lt.role==="assistant"&&(Xe[Xe.length-1]={...Lt,content:`Connection error: ${ve}`,isStreaming:!1}),Xe})}}Y.current=null,C(!1),(be=le.current)==null||be.focus()},[y,c,k,b,B]),T=u.useCallback(()=>{var G;(G=Y.current)==null||G.abort()},[]),P=G=>{G.key==="Enter"&&!G.shiftKey&&(G.preventDefault(),je())};return e.jsxs("div",{className:"flex h-full bg-background",children:[w&&e.jsxs("div",{className:"w-64 border-r border-border flex flex-col bg-surface flex-shrink-0",children:[e.jsx("div",{className:"p-3 border-b border-border",children:e.jsxs("button",{onClick:me,className:"w-full flex items-center justify-center gap-2 px-3 py-2 bg-indigo-600 hover:bg-indigo-700 rounded-lg text-sm font-medium transition-colors text-white",children:[e.jsx(ht,{className:"h-4 w-4"}),"New Chat"]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[f.length===0&&e.jsx("p",{className:"px-3 py-4 text-xs text-zinc-500 text-center",children:"No conversations yet"}),f.map(G=>e.jsxs("button",{onClick:()=>ne(G),className:`group w-full text-left px-3 py-2.5 text-sm hover:bg-surface-hover transition-colors flex items-center gap-2 ${(b==null?void 0:b.id)===G.id?"bg-indigo-500/10 text-indigo-400":"text-zinc-400"}`,children:[e.jsx(Pt,{className:"h-3.5 w-3.5 flex-shrink-0"}),e.jsx("span",{className:"truncate flex-1",children:G.title||"Untitled"}),e.jsx("button",{onClick:oe=>ue(oe,G.id),className:"opacity-0 group-hover:opacity-100 p-0.5 hover:text-red-400 transition-opacity",title:"Delete conversation",children:e.jsx(Ot,{className:"h-3 w-3"})})]},G.id))]})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border bg-surface",children:[e.jsx("button",{onClick:()=>N(!w),className:"p-1.5 hover:bg-surface-hover rounded-lg transition-colors text-zinc-400 hover:text-zinc-200",title:w?"Hide sidebar":"Show sidebar",children:w?e.jsx(Tv,{className:"h-4 w-4"}):e.jsx(Rv,{className:"h-4 w-4"})}),e.jsx("select",{value:(c==null?void 0:c.id)||"",onChange:G=>{const oe=i.find(fe=>fe.id===G.target.value);oe&&m(oe)},className:"bg-background border border-border rounded-lg px-3 py-1.5 text-sm text-zinc-200 focus:outline-none focus:border-indigo-500",children:i.map(G=>e.jsxs("option",{value:G.id,children:[G.name," (",G.adapterType,")"]},G.id))}),c&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs text-zinc-500",children:((de=c.adapterConfig)==null?void 0:de.model)||uN(c.adapterType)}),e.jsx("button",{onClick:()=>Z(!0),className:"p-1.5 hover:bg-surface-hover rounded-lg transition-colors text-zinc-500 hover:text-zinc-200",title:"Edit system prompt",children:e.jsx(il,{className:"h-3.5 w-3.5"})})]}),z&&e.jsxs("div",{className:"ml-auto flex items-center gap-1.5 text-xs text-amber-400/80",title:`Available tools: ${D.join(", ")}`,children:[e.jsx(cl,{className:"h-3 w-3"}),e.jsxs("span",{children:[D.length," tools"]})]})]}),z&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5 bg-amber-500/10 border-b border-amber-500/20 text-amber-400 text-xs",children:[e.jsx(pt,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{children:"Tools are auto-approved in chat mode. Shell commands and file operations execute without confirmation."})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 space-y-4",children:[p.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-zinc-500",children:[e.jsx(Pt,{className:"h-12 w-12 mb-4 text-indigo-500/40"}),e.jsx("h2",{className:"text-xl font-semibold text-zinc-200 mb-2",children:"Start a conversation"}),e.jsxs("p",{className:"text-sm mb-6",children:["Type a message to chat with ",(c==null?void 0:c.name)||"your agent"]}),e.jsx("div",{className:"grid grid-cols-2 gap-2 max-w-md",children:["Review my code for bugs","Explain this codebase","Write unit tests","Help me refactor"].map(G=>e.jsx("button",{onClick:()=>v(G),className:"px-3 py-2 text-sm bg-surface hover:bg-surface-hover border border-border rounded-lg text-left text-zinc-300 transition-colors",children:G},G))})]}),p.map((G,oe)=>{var fe,be,Ce;return e.jsx("div",{className:`flex ${G.role==="user"?"justify-end":"justify-start"}`,children:e.jsxs("div",{className:`max-w-[80%] rounded-2xl px-4 py-3 ${G.role==="user"?"bg-indigo-600 text-white":"bg-surface border border-border text-zinc-100"}`,children:[G.thinking&&e.jsxs("div",{className:"mb-2 px-2 py-1.5 bg-zinc-800/30 rounded-lg text-[11px] text-zinc-500 italic border border-zinc-700/30",children:[e.jsx("span",{className:"text-zinc-600 text-[10px] uppercase tracking-wider block mb-0.5",children:"Thinking"}),G.thinking.substring(0,300),G.thinking.length>300&&"..."]}),(fe=G.toolCalls)==null?void 0:fe.map((ve,tt)=>e.jsx(fN,{tc:ve},tt)),G.content&&((/(?:API[_\s]?KEY|api[_\s]?key).*(?:not set|not configured|missing|invalid|required)/i.test(G.content)||/(?:ANTHROPIC|OPENAI|GEMINI|XAI|MISTRAL|GROK)_API_KEY/i.test(G.content))&&G.role==="assistant"?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"whitespace-pre-wrap break-words",children:G.content}),e.jsxs(ta,{to:"/keys",className:"inline-flex items-center gap-2 rounded-lg border border-purple-500/30 bg-purple-500/10 px-3 py-2 text-sm text-purple-400 hover:bg-purple-500/20 transition-colors",children:[e.jsx(Ni,{className:"h-4 w-4"}),"Set up your API key"]})]}):e.jsx("div",{className:"whitespace-pre-wrap break-words",children:G.content})),G.isStreaming&&!G.content&&!((be=G.toolCalls)!=null&&be.length)&&e.jsxs("div",{className:"flex items-center gap-1.5 text-zinc-400",children:[e.jsx(rt,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{className:"text-xs",children:"Thinking..."})]}),G.isStreaming&&!G.content&&(((Ce=G.toolCalls)==null?void 0:Ce.length)??0)>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-zinc-400 mt-1",children:[e.jsx(rt,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{className:"text-xs",children:"Processing tools..."})]}),G.isStreaming&&G.content&&e.jsx("span",{className:"inline-block w-1.5 h-4 bg-indigo-400 animate-pulse ml-0.5 rounded-sm"}),G.usage&&(G.usage.inputTokens>0||G.usage.outputTokens>0)&&e.jsxs("div",{className:"mt-1.5 text-[10px] text-zinc-500 flex items-center gap-2",children:[e.jsxs("span",{children:[G.usage.inputTokens+G.usage.outputTokens," tokens"]}),G.usage.costUsd>0&&e.jsxs("span",{children:["$",G.usage.costUsd.toFixed(4)]}),G.toolCalls&&G.toolCalls.length>0&&e.jsxs("span",{children:[G.toolCalls.length," tool call",G.toolCalls.length>1?"s":""]})]})]})},oe)}),U&&U.length>0&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"max-w-[80%]",children:e.jsx(pN,{steps:U})})}),F&&e.jsxs("div",{className:"mx-4 my-2 p-4 bg-purple-900/30 border border-purple-500/50 rounded-lg",children:[e.jsxs("p",{className:"text-sm text-purple-300",children:[e.jsx(rn,{className:"inline h-4 w-4 mr-1.5 -mt-0.5"}),F.message]}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx("button",{onClick:()=>n(`/missions?objective=${encodeURIComponent(F.objective)}`),className:"px-3 py-1.5 bg-purple-600 hover:bg-purple-500 rounded text-sm text-white transition-colors",children:"Run as Mission"}),e.jsx("button",{onClick:()=>$(null),className:"px-3 py-1.5 bg-gray-700 hover:bg-gray-600 rounded text-sm text-zinc-200 transition-colors",children:"Continue in Chat"})]})]}),e.jsx("div",{ref:I})]}),e.jsxs("div",{className:"border-t border-border px-4 py-3 bg-surface",children:[e.jsxs("div",{className:"flex gap-2 items-end max-w-4xl mx-auto",children:[e.jsx("textarea",{ref:le,value:y,onChange:G=>v(G.target.value),onKeyDown:P,placeholder:`Message ${(c==null?void 0:c.name)||"agent"}...`,rows:1,className:"flex-1 bg-background border border-border rounded-xl px-4 py-3 resize-none focus:outline-none focus:border-indigo-500 placeholder-zinc-500 text-zinc-200 text-sm",style:{minHeight:"48px",maxHeight:"200px"},disabled:k||!c}),k?e.jsx("button",{onClick:T,className:"px-4 py-3 bg-red-600 hover:bg-red-700 rounded-xl transition-colors text-white flex-shrink-0",title:"Stop generation",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})})}):e.jsx("button",{onClick:je,disabled:!y.trim()||!c,className:"px-4 py-3 bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-xl transition-colors text-white flex-shrink-0",title:"Send message",children:e.jsx(gi,{className:"h-5 w-5"})})]}),!c&&i.length===0&&e.jsx("p",{className:"text-xs text-yellow-500 mt-2 text-center",children:"No agents configured. Create one first in the Agents page."})]})]}),se&&c&&e.jsx(gN,{agent:c,onClose:()=>Z(!1),onSave:G=>{m(G),d(oe=>oe.map(fe=>fe.id===G.id?G:fe)),Z(!1)}})]})}let yN=0;function vN({message:n,type:i,onDismiss:d}){return u.useEffect(()=>{const c=setTimeout(d,4e3);return()=>clearTimeout(c)},[d]),e.jsxs("div",{className:`px-4 py-2.5 rounded-lg shadow-lg text-white text-sm font-medium flex items-center gap-2 animate-[fadeSlideIn_0.3s_ease-out]
600
+ ${i==="success"?"bg-green-600":i==="error"?"bg-red-600":"bg-blue-600"}`,children:[i==="success"&&e.jsx(bt,{className:"h-4 w-4"}),i==="error"&&e.jsx(ft,{className:"h-4 w-4"}),i==="info"&&e.jsx(rt,{className:"h-4 w-4"}),n]})}function jN({toasts:n,removeToast:i}){return n.length===0?null:e.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:n.map(d=>e.jsx(vN,{message:d.message,type:d.type,onDismiss:()=>i(d.id)},d.id))})}function Qr({onClick:n,loading:i,disabled:d,className:c,icon:m,loadingText:f,children:h}){return e.jsx("button",{onClick:n,disabled:i||d,className:`${c} ${i||d?"opacity-60 cursor-not-allowed":""}`,children:i?e.jsxs(e.Fragment,{children:[e.jsx(rt,{className:"h-3.5 w-3.5 animate-spin"}),f||h]}):e.jsxs(e.Fragment,{children:[m,h]})})}function n0(n){switch(n){case"osint":return e.jsx(el,{className:"h-4 w-4"});case"research":return e.jsx(_a,{className:"h-4 w-4"});case"code":return e.jsx(gv,{className:"h-4 w-4"});case"audit":return e.jsx(Ds,{className:"h-4 w-4"});case"analysis":return e.jsx(Rs,{className:"h-4 w-4"});case"creation":return e.jsx(Ua,{className:"h-4 w-4"});default:return e.jsx(La,{className:"h-4 w-4"})}}function Nu(n){return n>=.8?"text-green-400":n>=.6?"text-amber-400":"text-red-400"}function sp(n){return n>=.8?"bg-green-500/10 border-green-500/20":n>=.6?"bg-amber-500/10 border-amber-500/20":"bg-red-500/10 border-red-500/20"}function su(n){switch(n){case"search":return"bg-blue-500/10 text-blue-400 border-blue-500/20";case"scrape":return"bg-emerald-500/10 text-emerald-400 border-emerald-500/20";case"analyze":return"bg-purple-500/10 text-purple-400 border-purple-500/20";case"create":return"bg-amber-500/10 text-amber-400 border-amber-500/20";case"validate":return"bg-cyan-500/10 text-cyan-400 border-cyan-500/20";default:return"bg-zinc-500/10 text-zinc-400 border-zinc-500/20"}}const NN=[{label:"OSINT investigation",prompt:"OSINT investigation on "},{label:"Security audit",prompt:"Security audit of "},{label:"Market analysis",prompt:"Market analysis of "},{label:"Build a landing page",prompt:"Build a landing page for "},{label:"Competitive research",prompt:"Competitive research on "},{label:"Code review",prompt:"Review all PRs from this week on "}];function Fr({label:n,score:i}){const d=Math.round(i*100);return e.jsxs("div",{className:`flex flex-col items-center rounded-lg border px-4 py-3 ${sp(i)}`,children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-zinc-500 mb-1",children:n}),e.jsxs("span",{className:`text-2xl font-bold tabular-nums ${Nu(i)}`,children:[d,"%"]})]})}function wN({finding:n}){const[i,d]=u.useState(!1),c=Math.round(n.confidence*100);return e.jsxs("div",{className:"rounded-lg border border-border/50 bg-zinc-900/50 overflow-hidden",children:[e.jsxs("button",{onClick:()=>d(!i),className:"w-full flex items-start gap-2 px-3 py-2.5 text-left hover:bg-zinc-800/30 transition-colors",children:[e.jsx("span",{className:"mt-0.5 flex-shrink-0",children:i?e.jsx(na,{className:"h-3.5 w-3.5 text-zinc-500"}):e.jsx(ds,{className:"h-3.5 w-3.5 text-zinc-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded border font-medium ${su(n.type)}`,children:n.type}),e.jsx("span",{className:"text-sm font-medium text-zinc-200 truncate",children:n.title})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-[11px] text-zinc-500",children:[e.jsxs("span",{className:Nu(n.confidence),children:[c,"% confidence"]}),n.source&&e.jsxs("span",{children:["via ",n.source]})]})]})]}),i&&e.jsxs("div",{className:"px-3 pb-3 pt-0 border-t border-border/30",children:[e.jsx("p",{className:"text-xs text-zinc-400 whitespace-pre-wrap mt-2",children:n.content}),n.sourceUrl&&e.jsx("a",{href:n.sourceUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-block mt-2 text-[11px] text-purple-400 hover:text-purple-300 underline",children:n.sourceUrl})]})]})}function SN({content:n}){const i=n.split(`
601
+ `),d=[];for(let c=0;c<i.length;c++){const m=i[c];if(c===0&&m==="---"){const f=i.indexOf("---",1);if(f>0){c=f;continue}}if(m.startsWith("# "))d.push(e.jsx("h1",{className:"text-xl font-bold text-zinc-100 mt-6 mb-2",children:m.slice(2)},c));else if(m.startsWith("## "))d.push(e.jsx("h2",{className:"text-lg font-semibold text-zinc-200 mt-5 mb-2",children:m.slice(3)},c));else if(m.startsWith("### "))d.push(e.jsx("h3",{className:"text-base font-semibold text-zinc-300 mt-4 mb-1",children:m.slice(4)},c));else if(m.startsWith("#### "))d.push(e.jsx("h4",{className:"text-sm font-semibold text-zinc-300 mt-3 mb-1",children:m.slice(5)},c));else if(m.startsWith("- ")||m.startsWith("* "))d.push(e.jsxs("div",{className:"flex gap-2 text-sm text-zinc-400 ml-2 my-0.5",children:[e.jsx("span",{className:"text-zinc-600 flex-shrink-0",children:"-"}),e.jsx("span",{children:Vd(m.slice(2))})]},c));else if(/^\d+\.\s/.test(m)){const f=m.match(/^(\d+)\.\s(.*)$/);f&&d.push(e.jsxs("div",{className:"flex gap-2 text-sm text-zinc-400 ml-2 my-0.5",children:[e.jsxs("span",{className:"text-zinc-600 flex-shrink-0 tabular-nums",children:[f[1],"."]}),e.jsx("span",{children:Vd(f[2])})]},c))}else m.startsWith("---")||m.startsWith("***")?d.push(e.jsx("hr",{className:"border-border/50 my-4"},c)):m.trim()===""?d.push(e.jsx("div",{className:"h-2"},c)):d.push(e.jsx("p",{className:"text-sm text-zinc-400 my-1",children:Vd(m)},c))}return e.jsx("div",{className:"space-y-0",children:d})}function Vd(n){return n.split(/(\*\*[^*]+\*\*)/g).map((d,c)=>{if(d.startsWith("**")&&d.endsWith("**"))return e.jsx("strong",{className:"text-zinc-200 font-semibold",children:d.slice(2,-2)},c);const m=/\[([^\]]+)\]\(([^)]+)\)/g,f=[];let h=0,b;for(;(b=m.exec(d))!==null;)b.index>h&&f.push(d.slice(h,b.index)),f.push(e.jsx("a",{href:b[2],target:"_blank",rel:"noopener noreferrer",className:"text-purple-400 hover:text-purple-300 underline",children:b[1]},`${c}-${b.index}`)),h=b.index+b[0].length;return h<d.length&&f.push(d.slice(h)),f.length>0?e.jsx("span",{children:f},c):d})}function kN({missions:n,selectedId:i,onSelect:d}){const[c,m]=u.useState(""),[f,h]=u.useState("all"),[b,g]=u.useState("all"),[p,S]=u.useState("recent"),y=u.useMemo(()=>{let v=[...n];if(c){const k=c.toLowerCase();v=v.filter(C=>{var w,N,z;return((w=C.title)==null?void 0:w.toLowerCase().includes(k))||((N=C.objective)==null?void 0:N.toLowerCase().includes(k))||((z=C.type)==null?void 0:z.toLowerCase().includes(k))})}switch(f!=="all"&&(v=v.filter(k=>k.type===f)),b!=="all"&&(v=v.filter(k=>k.status===b)),p){case"recent":v.sort((k,C)=>(C.createdAt||0)-(k.createdAt||0));break;case"cost":v.sort((k,C)=>(C.spentUsd||0)-(k.spentUsd||0));break;case"quality":v.sort((k,C)=>{var w,N;return(((w=C.evaluation)==null?void 0:w.overall)||0)-(((N=k.evaluation)==null?void 0:N.overall)||0)});break;case"findings":v.sort((k,C)=>{var w,N;return(((w=C.findings)==null?void 0:w.length)||0)-(((N=k.findings)==null?void 0:N.length)||0)});break}return v},[n,c,f,b,p]);return n.length===0?null:e.jsxs("div",{className:"border-b border-border/50 pb-4 mb-4",children:[e.jsx("h3",{className:"text-[10px] uppercase tracking-wider text-zinc-600 px-1 mb-3",children:"Missions"}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 mb-4 text-center",children:[e.jsxs("div",{className:"bg-zinc-800/70 rounded p-2",children:[e.jsx("div",{className:"text-lg font-bold text-white",children:n.length}),e.jsx("div",{className:"text-[10px] text-zinc-500",children:"Total"})]}),e.jsxs("div",{className:"bg-zinc-800/70 rounded p-2",children:[e.jsx("div",{className:"text-lg font-bold text-green-400",children:n.filter(v=>v.status==="completed").length}),e.jsx("div",{className:"text-[10px] text-zinc-500",children:"Completed"})]}),e.jsxs("div",{className:"bg-zinc-800/70 rounded p-2",children:[e.jsxs("div",{className:"text-lg font-bold text-white",children:["$",n.reduce((v,k)=>v+(k.spentUsd||0),0).toFixed(2)]}),e.jsx("div",{className:"text-[10px] text-zinc-500",children:"Total Cost"})]}),e.jsxs("div",{className:"bg-zinc-800/70 rounded p-2",children:[e.jsx("div",{className:"text-lg font-bold text-white",children:n.reduce((v,k)=>{var C;return v+(((C=k.findings)==null?void 0:C.length)||0)},0)}),e.jsx("div",{className:"text-[10px] text-zinc-500",children:"Findings"})]})]}),e.jsx("div",{className:"mb-3",children:e.jsx("input",{type:"text",placeholder:"Search missions...",value:c,onChange:v=>m(v.target.value),className:"w-full px-3 py-2 bg-zinc-800 border border-zinc-700 rounded-lg text-sm text-white placeholder-zinc-500 focus:outline-none focus:border-purple-500"})}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-3",children:["all","osint","research","code","audit","creation","analysis"].map(v=>e.jsx("button",{onClick:()=>h(v),className:`px-2.5 py-1 rounded-full text-[10px] font-medium transition-colors ${f===v?"bg-purple-600 text-white":"bg-zinc-800 text-zinc-400 hover:bg-zinc-700"}`,children:v==="all"?"All":v.charAt(0).toUpperCase()+v.slice(1)},v))}),e.jsx("div",{className:"flex gap-1.5 mb-3",children:["all","completed","executing","failed","interrupted"].map(v=>e.jsxs("button",{onClick:()=>g(v),className:`px-2 py-1 rounded text-[10px] transition-colors ${b===v?"bg-zinc-700 text-white":"text-zinc-500 hover:text-zinc-300"}`,children:[v==="all"?"All":v,v!=="all"&&` (${n.filter(k=>k.status===v).length})`]},v))}),e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-[10px] text-zinc-500",children:[e.jsx("span",{children:"Sort:"}),["recent","cost","quality","findings"].map(v=>e.jsx("button",{onClick:()=>S(v),className:`transition-colors ${p===v?"text-purple-400":"hover:text-zinc-300"}`,children:v},v))]}),e.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[y.map(v=>{var k,C;return e.jsx("button",{onClick:()=>d(v),className:`w-full text-left rounded-lg transition-colors ${i===v.id?"bg-purple-500/10 border border-purple-500/20":"hover:bg-zinc-800/50"}`,children:e.jsxs("div",{className:"flex items-center gap-3 p-3",children:[e.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${v.status==="completed"?"bg-green-500":v.status==="executing"?"bg-blue-500 animate-pulse":v.status==="failed"?"bg-red-500":v.status==="interrupted"?"bg-yellow-500":"bg-gray-500"}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-white truncate",children:v.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-zinc-800 text-zinc-400",children:v.type}),e.jsxs("span",{className:"text-[10px] text-zinc-500",children:["$",(v.spentUsd||0).toFixed(2)]}),e.jsxs("span",{className:"text-[10px] text-zinc-500",children:[((k=v.findings)==null?void 0:k.length)||0," findings"]}),((C=v.evaluation)==null?void 0:C.overall)!=null&&e.jsxs("span",{className:`text-[10px] font-medium ${v.evaluation.overall>=.8?"text-green-400":v.evaluation.overall>=.5?"text-yellow-400":"text-red-400"}`,children:[Math.round(v.evaluation.overall*100),"%"]})]})]}),e.jsx("span",{className:"text-[10px] text-zinc-600 flex-shrink-0",children:new Date(v.createdAt).toLocaleDateString()})]})},v.id)}),y.length===0&&e.jsx("p",{className:"text-xs text-zinc-600 text-center py-4",children:"No missions match filters"})]})]})}function zN(){var Os,Si;const[n,i]=av(),[d,c]=u.useState("empty"),[m,f]=u.useState(""),[h,b]=u.useState(null),[g,p]=u.useState([]),[S,y]=u.useState(""),[v,k]=u.useState([]),[C,w]=u.useState(!1),[N,z]=u.useState(null),R=u.useRef(null),D=u.useRef(null),O=u.useRef(null),se=u.useRef(!1),[Z,U]=u.useState([]),[A,F]=u.useState([]),[$,Q]=u.useState(0),ce=u.useRef(null);u.useEffect(()=>{ea.templates().then(K=>{U(K.data||[])}).catch(()=>{})},[]),u.useEffect(()=>{ea.list().then(K=>{k(K.data||[])}).catch(()=>{})},[]),u.useEffect(()=>{D.current&&(D.current.scrollTop=D.current.scrollHeight)},[g]),u.useEffect(()=>{ce.current&&(ce.current.scrollTop=ce.current.scrollHeight)},[A]),u.useEffect(()=>()=>{var K;(K=R.current)==null||K.close()},[]);const I=u.useCallback(async K=>{var we,Se;const re=K??m;if(re.trim()){c("planning"),y(""),p([]),b(null),w(!1);try{const Oe=await ea.plan(re.trim());b(Oe.data),c("planned")}catch(Oe){y(((Se=(we=Oe==null?void 0:Oe.body)==null?void 0:we.error)==null?void 0:Se.message)||Oe.message||"Planning failed"),c("error")}}},[m]);u.useEffect(()=>{if(se.current)return;const K=n.get("objective");K&&!h&&(se.current=!0,f(K),i({},{replace:!0}),I(K))},[n,h,I,i]);const le=u.useCallback(async()=>{var Oe;if(!h)return;c("executing"),p([]),w(!1),z(null),F([]),Q(0);const K=localStorage.getItem("nestor_token"),re=(Oe=document.cookie.match(/(?:^|; )nestor-csrf=([^;]*)/))==null?void 0:Oe[1],we=localStorage.getItem("nestor_tenant_id"),Se={"Content-Type":"application/json"};K&&(Se.Authorization=`Bearer ${K}`),re&&(Se["X-CSRF-Token"]=decodeURIComponent(re)),we&&(Se["X-Tenant-ID"]=we);try{const ct=await fetch(`/api/missions/${h.id}/execute`,{method:"POST",headers:Se});if(!ct.ok||!ct.body){y("Failed to start execution"),c("error");return}const Rt=ct.body.getReader(),fc=new TextDecoder;let Ha="";const ki=Ls=>{if(Ls.startsWith("data: "))try{const ra=JSON.parse(Ls.slice(6));B(ra)}catch{}};await(async()=>{for(;;){const{done:Ls,value:ra}=await Rt.read();if(Ls)break;Ha+=fc.decode(ra,{stream:!0});const ws=Ha.split(`
602
+ `);Ha=ws.pop()||"";for(const un of ws)ki(un.trim())}Ha.trim()&&ki(Ha.trim())})()}catch(ct){y(ct.message||"Execution failed"),c("error")}},[h]),Y=u.useCallback((K,re)=>{F(we=>[...we,{id:`${Date.now()}-${Math.random().toString(36).slice(2,6)}`,timestamp:Date.now(),type:K,label:re}])},[]),B=u.useCallback(K=>{switch(K.type){case"status":b(re=>re&&{...re,status:K.status}),K.status==="evaluating"&&(c("evaluating"),Y("status","Evaluation phase started"));break;case"sub_objective_start":z(K.id),b(re=>{if(!re)return re;const we=re.subObjectives.map(Se=>Se.id===K.id?{...Se,status:"in_progress"}:Se);return{...re,subObjectives:we}}),Y("sub_objective_start",`Sub-objective "${K.name||K.id}" started`);break;case"sub_objective_complete":b(re=>{if(!re)return re;const we=re.subObjectives.map(Se=>Se.id===K.id?{...Se,status:K.status}:Se);return{...re,subObjectives:we}}),Y("sub_objective_complete",`Sub-objective "${K.name||K.id}" ${K.status}`);break;case"finding":p(re=>[...re,K]),Y("finding",`Finding: ${K.title||"New finding"}`);break;case"evaluation":b(re=>re&&{...re,evaluation:{completeness:K.completeness,accuracy:K.accuracy,depth:K.depth,relevance:K.relevance,overall:K.overall,gaps:K.gaps||[],recommendation:K.recommendation||"deliver",suggestedActions:K.suggestedActions||[]}}),Y("evaluation",`Evaluation complete: ${Math.round(K.overall*100)}% overall`);break;case"iteration":b(re=>re&&{...re,iteration:K.iteration}),Y("iteration",`Iteration ${K.iteration} started`);break;case"cost_update":typeof K.costUsd=="number"&&Q(K.costUsd);break;case"budget_exhausted":Y("budget","Budget exhausted");break;case"complete":b(re=>re&&{...re,status:K.status||"completed",spentUsd:K.cost||re.spentUsd,iteration:K.iterations||re.iteration}),typeof K.cost=="number"&&Q(K.cost),Y("complete",`Mission ${K.status||"completed"}`),K.missionId&&ea.get(K.missionId).then(re=>{b(re.data)}).catch(()=>{}),c("complete"),ea.list().then(re=>k(re.data||[])).catch(()=>{});break;case"error":y(K.message),c("error"),Y("error",`Error: ${K.message||"Unknown error"}`);break}},[Y]),ne=u.useCallback(async()=>{if(h)try{await ea.cancel(h.id),b(K=>K&&{...K,status:"cancelled"}),c("empty")}catch{}},[h]),me=u.useCallback(()=>{var K,re;c("empty"),f(""),b(null),p([]),y(""),w(!1),z(null),F([]),Q(0),(K=R.current)==null||K.close(),(re=O.current)==null||re.focus()},[]),ue=u.useCallback(K=>{b(K),f(K.objective),p((K.findings||[]).map(re=>({id:re.id,type:re.type,title:re.title,content:re.content,confidence:re.confidence,source:re.source,sourceUrl:re.sourceUrl}))),K.status==="completed"||K.status==="failed"?c("complete"):(K.status,c("planned"))},[]),je=u.useCallback(()=>{if(!(h!=null&&h.report))return;const K=new Blob([h.report],{type:"text/markdown"}),re=URL.createObjectURL(K),we=document.createElement("a");we.href=re,we.download=`${h.title.replace(/[^a-zA-Z0-9]/g,"_")}_report.md`,we.click(),URL.revokeObjectURL(re)},[h]),T=u.useCallback(K=>{var re;f(K),(re=O.current)==null||re.focus()},[]),P=Dt(),[de,G]=u.useState([]),oe=u.useCallback((K,re="info")=>{const we=++yN;G(Se=>[...Se,{id:we,message:K,type:re}])},[]),fe=u.useCallback(K=>{G(re=>re.filter(we=>we.id!==K))},[]),[be,Ce]=u.useState(!1),[ve,tt]=u.useState(!1),[Xe,Lt]=u.useState(!1),[Ns,At]=u.useState(!1),[Kt,qe]=u.useState(!1),nt=be||ve||Xe||Ns;u.useEffect(()=>{qe(!1)},[h==null?void 0:h.id]);const L=u.useCallback(()=>{var Oe;const K=localStorage.getItem("nestor_token"),re=(Oe=document.cookie.match(/(?:^|; )nestor-csrf=([^;]*)/))==null?void 0:Oe[1],we=localStorage.getItem("nestor_tenant_id"),Se={"Content-Type":"application/json"};return K&&(Se.Authorization=`Bearer ${K}`),re&&(Se["X-CSRF-Token"]=decodeURIComponent(re)),we&&(Se["X-Tenant-ID"]=we),Se},[]),te=u.useCallback(async K=>{var re;Ce(!0);try{const we=L(),Se=await fetch(`/api/missions/${K}/iterate`,{method:"POST",headers:we});if(!Se.ok){const ct=await Se.json().catch(()=>({}));oe(((re=ct==null?void 0:ct.error)==null?void 0:re.message)||"Iterate request failed","error");return}oe("Iterating on gaps...","info");const Oe=await ea.get(K);b(Oe.data),c("planned"),setTimeout(()=>{le()},500)}catch(we){oe(we instanceof Error?we.message:"Iterate failed","error")}finally{Ce(!1)}},[le,oe,L]),ye=u.useCallback(async K=>{var re;if(!(!((re=K.evaluation)!=null&&re.gaps)||K.evaluation.gaps.length===0)){tt(!0);try{const we=`Deep dive follow-up for mission "${K.title}". Focus ONLY on these gaps identified in the evaluation:
603
+ ${K.evaluation.gaps.map(Oe=>`- ${Oe}`).join(`
604
+ `)}
605
+
606
+ Previous findings are available in the knowledge graph. Do NOT repeat what was already found. Use different approaches and sources than the original mission.`,Se=await ea.plan(we,{maxBudget:3});Se.data&&(oe("Deep-dive mission created!","success"),b(Se.data),f(we),p([]),c("planned"))}catch(we){oe(we instanceof Error?we.message:"Deep dive planning failed","error")}finally{tt(!1)}}},[oe]),We=u.useCallback(async K=>{Lt(!0);try{const re=L();(await fetch(`/api/brain/reindex/${K}`,{method:"POST",headers:re})).ok?(oe("Archived to Knowledge Graph","success"),qe(!0)):oe("Archive failed — brain endpoint may not be available.","error")}catch{oe("Archive failed — brain endpoint may not be available.","error")}finally{Lt(!1)}},[oe,L]),fs=u.useCallback(async K=>{At(!0);try{oe("Re-running mission...","info");const re=await ea.plan(K.objective,{maxBudget:K.maxBudgetUsd});re.data&&(b(re.data),f(K.objective),p([]),c("planned"),oe("Fresh mission planned. Executing...","success"),setTimeout(()=>{le()},500))}catch(re){oe(re instanceof Error?re.message:"Re-run planning failed","error")}finally{At(!1)}},[oe,le]),hs=u.useCallback(K=>{const re=(K.findings||[]).sort((Oe,ct)=>(ct.confidence??0)-(Oe.confidence??0)).slice(0,3).map(Oe=>Oe.title).join(", "),we=re?`Key findings: ${re}`:"",Se=encodeURIComponent(`Mission: ${K.title}. ${we}`);P(`/chat?context=mission:${K.id}&prefill=${Se}`)},[P]),yt=u.useCallback(K=>{const re=new Blob([JSON.stringify(K,null,2)],{type:"application/json"}),we=URL.createObjectURL(re),Se=document.createElement("a");Se.href=we,Se.download=`mission-${K.id.substring(0,8)}-${(K.title||"export").replace(/[^a-z0-9]/gi,"-").substring(0,30)}.json`,Se.click(),URL.revokeObjectURL(we)},[]),dn=(h==null?void 0:h.subObjectives.filter(K=>K.status==="completed").length)||0,$a=(h==null?void 0:h.subObjectives.length)||1,Ba=Math.round(dn/$a*100);return e.jsxs("div",{className:"flex h-full",children:[e.jsx(jN,{toasts:de,removeToast:fe}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 h-14 px-6 border-b border-border bg-surface flex-shrink-0",children:[e.jsx(sa,{className:"h-5 w-5 text-purple-400"}),e.jsx("h1",{className:"text-lg font-semibold text-zinc-100",children:"Missions"}),h&&d!=="empty"&&e.jsxs("div",{className:"flex items-center gap-2 ml-auto text-xs text-zinc-500",children:[h.type&&e.jsxs("span",{className:`flex items-center gap-1 px-2 py-0.5 rounded border ${su(h.type)}`,children:[n0(h.type),h.type]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(us,{className:"h-3 w-3"}),"$",h.spentUsd.toFixed(4)," / $",h.maxBudgetUsd.toFixed(2)]}),h.iteration>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xt,{className:"h-3 w-3"}),"Iteration ",h.iteration,"/",h.maxIterations]}),e.jsx("button",{onClick:me,className:"ml-2 p-1 rounded text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800 transition-colors",title:"New mission",children:e.jsx(Ze,{className:"h-4 w-4"})})]})]}),d==="empty"&&e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center px-6",children:e.jsxs("div",{className:"w-full max-w-2xl",children:[e.jsx("div",{className:"flex items-center justify-center mb-6",children:e.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-purple-600/20 border border-purple-500/20",children:e.jsx(sa,{className:"h-8 w-8 text-purple-400"})})}),e.jsx("h2",{className:"text-2xl font-bold text-zinc-100 text-center mb-2",children:"What's your mission?"}),e.jsx("p",{className:"text-sm text-zinc-500 text-center mb-8",children:"Autonomous AI agents will plan, execute, and deliver results."}),e.jsx(kN,{missions:v,selectedId:null,onSelect:ue}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:O,type:"text",value:m,onChange:K=>f(K.target.value),onKeyDown:K=>K.key==="Enter"&&I(),placeholder:"Describe your mission objective...",className:"flex-1 rounded-lg border border-border bg-zinc-900 px-4 py-3 text-sm text-zinc-200 placeholder:text-zinc-600 focus:outline-none focus:ring-2 focus:ring-purple-500/40 focus:border-purple-500/40",autoFocus:!0}),e.jsxs("button",{onClick:()=>I(),disabled:!m.trim(),className:"flex items-center gap-2 rounded-lg bg-purple-600 px-5 py-3 text-sm font-medium text-white hover:bg-purple-500 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:[e.jsx(rn,{className:"h-4 w-4"}),"Plan"]})]}),Z.length>0?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 mt-6 w-full max-w-4xl mx-auto",children:Z.map(K=>e.jsxs("button",{onClick:()=>{var re;f(K.objective),(re=O.current)==null||re.focus()},className:"group text-left rounded-xl border border-border/50 bg-zinc-900/60 hover:border-purple-500/40 hover:bg-purple-500/5 p-4 transition-all",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-purple-500/10 text-purple-400 group-hover:bg-purple-500/20 transition-colors",children:n0(K.type)}),e.jsx("span",{className:"text-sm font-medium text-zinc-200 group-hover:text-white transition-colors",children:K.name})]}),e.jsx("p",{className:"text-xs text-zinc-500 line-clamp-2 mb-2",children:K.description}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-zinc-600",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(us,{className:"h-3 w-3"}),"$",K.suggestedBudget.toFixed(2)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xt,{className:"h-3 w-3"}),K.suggestedIterations," iter"]})]})]},K.id))}):e.jsx("div",{className:"flex flex-wrap gap-2 mt-4 justify-center",children:NN.map(K=>e.jsx("button",{onClick:()=>T(K.prompt),className:"px-3 py-1.5 rounded-full border border-border/50 text-xs text-zinc-500 hover:text-zinc-300 hover:border-purple-500/30 hover:bg-purple-500/5 transition-colors",children:K.label},K.label))})]})}),d==="planning"&&e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6",children:[e.jsx(rt,{className:"h-10 w-10 text-purple-400 animate-spin mb-4"}),e.jsx("h2",{className:"text-lg font-semibold text-zinc-200 mb-1",children:"Analyzing objective..."}),e.jsx("p",{className:"text-sm text-zinc-500",children:"Decomposing into sub-objectives"})]}),d==="error"&&e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6",children:[e.jsx(pt,{className:"h-10 w-10 text-red-400 mb-4"}),e.jsx("h2",{className:"text-lg font-semibold text-zinc-200 mb-1",children:"Something went wrong"}),e.jsx("p",{className:"text-sm text-red-400/80 mb-4 max-w-md text-center",children:S}),e.jsx("button",{onClick:me,className:"px-4 py-2 rounded-lg border border-border text-sm text-zinc-300 hover:bg-zinc-800 transition-colors",children:"Try again"})]}),h&&(d==="planned"||d==="executing"||d==="evaluating"||d==="complete")&&e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsxs("div",{className:"w-[420px] flex-shrink-0 border-r border-border overflow-y-auto p-4",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h2",{className:"text-base font-semibold text-zinc-100 mb-1",children:h.title}),e.jsx("p",{className:"text-xs text-zinc-500 leading-relaxed",children:h.objective})]}),(d==="executing"||d==="evaluating"||d==="complete")&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex justify-between text-[10px] text-zinc-500 mb-1",children:[e.jsx("span",{children:"Progress"}),e.jsxs("span",{children:[Ba,"%"]})]}),e.jsx("div",{className:"h-2 bg-zinc-800 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${d==="complete"?"bg-green-500":"bg-purple-500"}`,style:{width:`${Ba}%`}})})]}),(d==="executing"||d==="evaluating")&&$>0&&e.jsxs("div",{className:"mb-4 flex items-center gap-2 px-3 py-2 rounded-lg bg-amber-500/5 border border-amber-500/10",children:[e.jsx(us,{className:"h-3.5 w-3.5 text-amber-400"}),e.jsxs("span",{className:"text-xs text-amber-400 font-mono tabular-nums",children:["$",$.toFixed(4)]}),e.jsx("span",{className:"text-[10px] text-zinc-500",children:"spent so far"})]}),e.jsx("div",{className:"space-y-1",children:h.subObjectives.map((K,re)=>e.jsxs("div",{className:`flex items-start gap-3 px-3 py-2.5 rounded-lg transition-colors ${N===K.id?"bg-purple-500/10 border border-purple-500/20":"hover:bg-zinc-800/30"}`,children:[e.jsxs("div",{className:"flex flex-col items-center flex-shrink-0",children:[e.jsx("div",{className:"flex items-center justify-center h-5 w-5",children:e.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${K.status==="completed"?"bg-green-500":K.status==="in_progress"?"bg-blue-500 animate-pulse":K.status==="failed"?"bg-red-500":"bg-zinc-600"}`})}),re<h.subObjectives.length-1&&e.jsx("div",{className:"w-px h-6 bg-border/50 mt-1"})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-zinc-200 truncate",children:K.name}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded border ${su(K.type)}`,children:K.type})]}),e.jsx("p",{className:"text-[11px] text-zinc-500 mt-0.5 line-clamp-2",children:K.description}),K.findings.length>0&&e.jsxs("span",{className:"text-[10px] text-zinc-600 mt-1 inline-block",children:[K.findings.length," finding",K.findings.length!==1?"s":""]})]})]},K.id))}),A.length>0&&e.jsxs("div",{className:"mt-5",children:[e.jsx("h3",{className:"text-[10px] uppercase tracking-wider text-zinc-600 mb-2",children:"Event Timeline"}),e.jsx("div",{ref:ce,className:"max-h-48 overflow-y-auto space-y-0.5",children:A.map(K=>{const re=new Date(K.timestamp),we=`${String(re.getHours()).padStart(2,"0")}:${String(re.getMinutes()).padStart(2,"0")}:${String(re.getSeconds()).padStart(2,"0")}`,Se=K.type==="error"?"bg-red-500":K.type==="complete"?"bg-green-500":K.type==="finding"?"bg-emerald-400":K.type==="evaluation"?"bg-amber-400":K.type==="sub_objective_start"?"bg-blue-400":K.type==="sub_objective_complete"?"bg-green-400":K.type==="iteration"?"bg-purple-400":"bg-zinc-500";return e.jsxs("div",{className:"flex items-start gap-2 px-2 py-1 text-[11px] rounded hover:bg-zinc-800/30",children:[e.jsxs("span",{className:"text-zinc-600 font-mono flex-shrink-0",children:["[",we,"]"]}),e.jsx("div",{className:`h-1.5 w-1.5 rounded-full mt-1.5 flex-shrink-0 ${Se}`}),e.jsx("span",{className:"text-zinc-400 break-words",children:K.label})]},K.id)})})]}),e.jsxs("div",{className:"mt-6 space-y-2",children:[d==="planned"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:le,className:"flex-1 flex items-center justify-center gap-2 rounded-lg bg-purple-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-purple-500 transition-colors",children:[e.jsx(sa,{className:"h-4 w-4"}),"Execute Mission"]}),e.jsx("button",{onClick:ne,className:"rounded-lg border border-border px-4 py-2.5 text-sm text-zinc-400 hover:text-zinc-200 hover:bg-zinc-800 transition-colors",children:"Cancel"})]}),d==="executing"&&e.jsxs("button",{onClick:ne,className:"w-full flex items-center justify-center gap-2 rounded-lg border border-red-500/30 px-4 py-2.5 text-sm text-red-400 hover:bg-red-500/10 transition-colors",children:[e.jsx(ft,{className:"h-4 w-4"}),"Cancel Execution"]}),d==="evaluating"&&e.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm text-amber-400 py-2",children:[e.jsx(rt,{className:"h-4 w-4 animate-spin"}),"Evaluating results..."]})]}),h.evaluation&&(d==="complete"||d==="evaluating")&&e.jsxs("div",{className:"mt-6",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-500 mb-3",children:"Quality Evaluation"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(Fr,{label:"Completeness",score:h.evaluation.completeness}),e.jsx(Fr,{label:"Accuracy",score:h.evaluation.accuracy}),e.jsx(Fr,{label:"Depth",score:h.evaluation.depth}),e.jsx(Fr,{label:"Relevance",score:h.evaluation.relevance})]}),e.jsxs("div",{className:`mt-2 rounded-lg border p-3 text-center ${sp(h.evaluation.overall)}`,children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-zinc-500",children:"Overall"}),e.jsxs("div",{className:`text-3xl font-bold tabular-nums ${Nu(h.evaluation.overall)}`,children:[Math.round(h.evaluation.overall*100),"%"]}),e.jsxs("div",{className:"text-xs text-zinc-500 mt-1 capitalize",children:["Recommendation: ",e.jsx("span",{className:h.evaluation.recommendation==="deliver"?"text-green-400":h.evaluation.recommendation==="iterate"?"text-amber-400":"text-red-400",children:h.evaluation.recommendation})]})]}),h.evaluation.gaps.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-zinc-600 mb-1",children:"Gaps"}),h.evaluation.gaps.map((K,re)=>e.jsxs("p",{className:"text-[11px] text-zinc-500 flex items-start gap-1 mt-0.5",children:[e.jsx(pt,{className:"h-3 w-3 text-amber-500/60 flex-shrink-0 mt-0.5"}),K]},re))]})]}),d==="complete"&&h.report&&e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsxs("button",{onClick:()=>w(!C),className:"flex-1 flex items-center justify-center gap-2 rounded-lg border border-border px-3 py-2 text-sm text-zinc-300 hover:bg-zinc-800 transition-colors",children:[e.jsx(Ua,{className:"h-4 w-4"}),C?"Hide Report":"View Report"]}),e.jsx("button",{onClick:je,className:"flex items-center justify-center gap-2 rounded-lg border border-border px-3 py-2 text-sm text-zinc-300 hover:bg-zinc-800 transition-colors",title:"Download as Markdown",children:e.jsx(hi,{className:"h-4 w-4"})})]}),d==="complete"&&e.jsxs("button",{onClick:me,className:"mt-3 w-full flex items-center justify-center gap-2 rounded-lg bg-purple-600/20 border border-purple-500/20 px-4 py-2.5 text-sm text-purple-400 hover:bg-purple-600/30 transition-colors",children:[e.jsx(k0,{className:"h-4 w-4"}),"New Mission"]}),(d==="complete"||(h==null?void 0:h.status)==="completed"||(h==null?void 0:h.status)==="failed")&&h&&e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-4",children:[((Os=h.evaluation)==null?void 0:Os.recommendation)==="iterate"&&e.jsx(Qr,{onClick:()=>te(h.id),loading:be,disabled:nt&&!be,className:"flex items-center justify-center gap-2 px-3 py-2.5 bg-yellow-600 hover:bg-yellow-500 text-white rounded-lg text-xs font-medium transition-colors",icon:e.jsx(xt,{className:"h-3.5 w-3.5"}),loadingText:"Iterating...",children:"Iterate on Gaps"}),((Si=h.evaluation)==null?void 0:Si.gaps)&&h.evaluation.gaps.length>0&&e.jsx(Qr,{onClick:()=>ye(h),loading:ve,disabled:nt&&!ve,className:"flex items-center justify-center gap-2 px-3 py-2.5 bg-blue-600 hover:bg-blue-500 text-white rounded-lg text-xs font-medium transition-colors",icon:e.jsx(_a,{className:"h-3.5 w-3.5"}),loadingText:"Planning...",children:"Deep Dive Gaps"}),e.jsx(Qr,{onClick:()=>We(h.id),loading:Xe,disabled:Kt||nt&&!Xe,className:`flex items-center justify-center gap-2 px-3 py-2.5 text-white rounded-lg text-xs font-medium transition-colors ${Kt?"bg-green-800 cursor-default":"bg-green-600 hover:bg-green-500"}`,icon:Kt?e.jsx(bt,{className:"h-3.5 w-3.5"}):e.jsx(La,{className:"h-3.5 w-3.5"}),loadingText:"Archiving...",children:Kt?"Archived":"Archive to Brain"}),e.jsxs("button",{onClick:()=>hs(h),className:"flex items-center justify-center gap-2 px-3 py-2.5 bg-purple-600 hover:bg-purple-500 text-white rounded-lg text-xs font-medium transition-colors",children:[e.jsx(gi,{className:"h-3.5 w-3.5"}),"Chat About This"]}),e.jsx(Qr,{onClick:()=>fs(h),loading:Ns,disabled:nt&&!Ns,className:"flex items-center justify-center gap-2 px-3 py-2.5 bg-zinc-700 hover:bg-zinc-600 text-white rounded-lg text-xs font-medium transition-colors",icon:e.jsx(xt,{className:"h-3.5 w-3.5"}),loadingText:"Re-running...",children:"Re-run Fresh"}),e.jsxs("button",{onClick:()=>yt(h),className:"flex items-center justify-center gap-2 px-3 py-2.5 bg-zinc-700 hover:bg-zinc-600 text-white rounded-lg text-xs font-medium transition-colors",children:[e.jsx(hi,{className:"h-3.5 w-3.5"}),"Export Full Data"]})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",ref:D,children:C&&h.report?e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-zinc-300",children:"Mission Report"}),e.jsx("button",{onClick:()=>w(!1),className:"text-zinc-500 hover:text-zinc-300",children:e.jsx(Ze,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"rounded-lg border border-border bg-zinc-900/50 p-6",children:e.jsx(SN,{content:h.report})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-500 mb-3",children:["Findings",g.length>0&&e.jsxs("span",{className:"ml-2 text-zinc-600",children:["(",g.length,")"]})]}),g.length===0&&d==="planned"&&e.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-zinc-600",children:[e.jsx(_a,{className:"h-8 w-8 mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"Findings will appear here during execution"})]}),g.length===0&&d==="executing"&&e.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-zinc-600",children:[e.jsx(rt,{className:"h-8 w-8 mb-2 animate-spin opacity-40"}),e.jsx("p",{className:"text-sm",children:"Agents are working..."})]}),e.jsx("div",{className:"space-y-2",children:g.map(K=>e.jsx(wN,{finding:K},K.id))})]})})]})]})]})}const l0=[{id:"claude",name:"Claude",provider:"Anthropic",emoji:"🟣",color:"text-purple-400",bgColor:"bg-purple-500/10",borderColor:"border-purple-500/30",keyUrl:"https://console.anthropic.com/settings/keys",keyUrlLabel:"console.anthropic.com",envVar:"ANTHROPIC_API_KEY",needsKey:!0},{id:"openai",name:"OpenAI",provider:"OpenAI",emoji:"🟢",color:"text-green-400",bgColor:"bg-green-500/10",borderColor:"border-green-500/30",keyUrl:"https://platform.openai.com/api-keys",keyUrlLabel:"platform.openai.com",envVar:"OPENAI_API_KEY",needsKey:!0},{id:"gemini",name:"Google Gemini",provider:"Google",emoji:"🔵",color:"text-blue-400",bgColor:"bg-blue-500/10",borderColor:"border-blue-500/30",keyUrl:"https://aistudio.google.com/apikey",keyUrlLabel:"aistudio.google.com",envVar:"GEMINI_API_KEY",needsKey:!0},{id:"grok",name:"Grok",provider:"xAI",emoji:"⚪",color:"text-zinc-300",bgColor:"bg-zinc-500/10",borderColor:"border-zinc-500/30",keyUrl:"https://console.x.ai/team/default/api-keys",keyUrlLabel:"console.x.ai",envVar:"XAI_API_KEY",needsKey:!0},{id:"mistral",name:"Mistral AI",provider:"Mistral",emoji:"🟠",color:"text-orange-400",bgColor:"bg-orange-500/10",borderColor:"border-orange-500/30",keyUrl:"https://console.mistral.ai/api-keys",keyUrlLabel:"console.mistral.ai",envVar:"MISTRAL_API_KEY",needsKey:!0},{id:"ollama",name:"Ollama",provider:"Local",emoji:"🟤",color:"text-amber-400",bgColor:"bg-amber-500/10",borderColor:"border-amber-500/30",keyUrl:"https://ollama.ai/download",keyUrlLabel:"ollama.ai",envVar:"",needsKey:!1}];function CN(n){if(!n)return"";const i=Date.now()-new Date(n+"Z").getTime(),d=Math.floor(i/6e4);if(d<1)return"Just now";if(d<60)return`${d}m ago`;const c=Math.floor(d/60);if(c<24)return`${c}h ago`;const m=Math.floor(c/24);return m<30?`${m}d ago`:new Date(n).toLocaleDateString()}function AN({entry:n}){return n.configured&&n.source==="db"?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-green-500/10 px-2.5 py-0.5 text-xs font-medium text-green-400",children:[e.jsx(bt,{className:"h-3 w-3"}),"Configured"]}):n.configured&&n.source==="env"?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-yellow-500/10 px-2.5 py-0.5 text-xs font-medium text-yellow-400",children:[e.jsx(pt,{className:"h-3 w-3"}),"From env"]}):n.provider==="ollama"&&n.configured?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-blue-500/10 px-2.5 py-0.5 text-xs font-medium text-blue-400",children:[e.jsx(bt,{className:"h-3 w-3"}),"Local"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-red-500/10 px-2.5 py-0.5 text-xs font-medium text-red-400",children:[e.jsx(Ze,{className:"h-3 w-3"}),"Not configured"]})}function EN({provider:n,onClose:i,onSaved:d}){const[c,m]=u.useState(""),[f,h]=u.useState(""),[b,g]=u.useState(!1),[p,S]=u.useState(!1),[y,v]=u.useState(!1),[k,C]=u.useState(null),[w,N]=u.useState(null),z=async()=>{if(c.trim()){v(!0),C(null),N(null);try{await ys.set(n.id,c.trim(),f||void 0);const D=await ys.test(n.id);C(D.data)}catch(D){N(D instanceof Error?D.message:"Test failed")}finally{v(!1)}}},R=async()=>{if(c.trim()){S(!0),N(null);try{await ys.set(n.id,c.trim(),f||void 0),d()}catch(D){N(D instanceof Error?D.message:"Failed to save")}finally{S(!1)}}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"w-full max-w-lg rounded-2xl border border-border bg-surface p-6 shadow-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:n.emoji}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:n.name}),e.jsx("p",{className:"text-xs text-zinc-500",children:n.provider})]})]}),e.jsx("button",{onClick:i,className:"rounded-lg p-2 text-zinc-400 hover:bg-surface-hover hover:text-zinc-200",children:e.jsx(Ze,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-zinc-300 mb-1.5",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:b?"text":"password",value:c,onChange:D=>m(D.target.value),placeholder:`Enter your ${n.provider} API key`,className:"w-full rounded-lg border border-border bg-background px-4 py-2.5 pr-10 text-sm text-zinc-200 focus:border-purple-500 focus:outline-none placeholder:text-zinc-600",autoFocus:!0}),e.jsx("button",{type:"button",onClick:()=>g(!b),className:"absolute right-3 top-1/2 -translate-y-1/2 text-zinc-500 hover:text-zinc-300",children:b?e.jsx(uu,{className:"h-4 w-4"}):e.jsx(el,{className:"h-4 w-4"})})]}),n.envVar&&e.jsxs("p",{className:"mt-1 text-xs text-zinc-600",children:["Env var: ",e.jsx("code",{className:"text-zinc-500",children:n.envVar})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-zinc-300 mb-1.5",children:["Label ",e.jsx("span",{className:"text-zinc-600",children:"(optional)"})]}),e.jsx("input",{type:"text",value:f,onChange:D=>h(D.target.value),placeholder:"e.g. Production key, Personal key",className:"w-full rounded-lg border border-border bg-background px-4 py-2.5 text-sm text-zinc-200 focus:border-purple-500 focus:outline-none placeholder:text-zinc-600"})]}),k&&e.jsxs("div",{className:`rounded-lg border p-3 ${k.valid?"border-green-500/30 bg-green-500/5 text-green-400":"border-red-500/30 bg-red-500/5 text-red-400"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[k.valid?e.jsx(bt,{className:"h-4 w-4"}):e.jsx(Ze,{className:"h-4 w-4"}),k.valid?"Key is valid":"Key validation failed"]}),e.jsx("p",{className:"mt-1 text-xs opacity-80",children:k.message}),k.models&&k.models.length>0&&e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1",children:[k.models.slice(0,6).map(D=>e.jsx("span",{className:"rounded-md bg-white/5 px-2 py-0.5 text-[10px] font-mono",children:D},D)),k.models.length>6&&e.jsxs("span",{className:"rounded-md bg-white/5 px-2 py-0.5 text-[10px]",children:["+",k.models.length-6," more"]})]})]}),w&&e.jsx("div",{className:"rounded-lg border border-red-500/30 bg-red-500/5 p-3 text-sm text-red-400",children:w}),e.jsxs("a",{href:n.keyUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-xs text-purple-400 hover:text-purple-300 transition-colors",children:[e.jsx(Pn,{className:"h-3 w-3"}),"Get API key at ",n.keyUrlLabel]})]}),e.jsxs("div",{className:"mt-6 flex items-center justify-end gap-3",children:[e.jsxs("button",{onClick:z,disabled:!c.trim()||y,className:"inline-flex items-center gap-2 rounded-lg border border-border px-4 py-2 text-sm font-medium text-zinc-300 transition-colors hover:bg-surface-hover disabled:opacity-50 disabled:cursor-not-allowed",children:[y?e.jsx(rt,{className:"h-4 w-4 animate-spin"}):e.jsx(bi,{className:"h-4 w-4"}),"Test Key"]}),e.jsxs("button",{onClick:R,disabled:!c.trim()||p,className:"inline-flex items-center gap-2 rounded-lg bg-purple-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-purple-700 disabled:opacity-50 disabled:cursor-not-allowed",children:[p?e.jsx(rt,{className:"h-4 w-4 animate-spin"}):e.jsx(bt,{className:"h-4 w-4"}),"Save"]})]})]})})}function TN({meta:n,entry:i,onAdd:d,onTest:c,onRemove:m,testingProvider:f,testResult:h}){const b=(i==null?void 0:i.configured)??!1,g=f===n.id,p=(h==null?void 0:h.provider)===n.id?h.result:null;return e.jsxs("div",{className:`rounded-xl border ${b?n.borderColor:"border-border"} bg-surface p-5 transition-all hover:shadow-lg hover:shadow-black/20`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:n.emoji}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-white",children:n.name}),e.jsx("p",{className:"text-xs text-zinc-500",children:n.provider})]})]}),i&&e.jsx(AN,{entry:i})]}),b&&(i==null?void 0:i.maskedKey)&&e.jsxs("div",{className:"mb-3 rounded-lg bg-background/50 px-3 py-2",children:[e.jsx("p",{className:"font-mono text-xs text-zinc-400",children:i.maskedKey}),i.label&&i.source==="db"&&e.jsx("p",{className:"text-[10px] text-zinc-600 mt-0.5",children:i.label}),i.updatedAt&&i.source==="db"&&e.jsxs("p",{className:"text-[10px] text-zinc-600 mt-0.5",children:["Updated ",CN(i.updatedAt)]}),i.source==="env"&&e.jsxs("p",{className:"text-[10px] text-yellow-500/80 mt-0.5",children:["Set via ",e.jsx("code",{className:"font-mono",children:n.envVar})," environment variable"]})]}),p&&e.jsxs("div",{className:`mb-3 rounded-lg border p-2.5 text-xs ${p.valid?"border-green-500/20 bg-green-500/5 text-green-400":"border-red-500/20 bg-red-500/5 text-red-400"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium",children:[p.valid?e.jsx(bt,{className:"h-3 w-3"}):e.jsx(Ze,{className:"h-3 w-3"}),p.valid?"Working":"Failed"]}),e.jsx("p",{className:"mt-0.5 text-[10px] opacity-80",children:p.message}),p.models&&p.models.length>0&&e.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1",children:[p.models.slice(0,4).map(S=>e.jsx("span",{className:"rounded bg-white/5 px-1.5 py-0.5 text-[9px] font-mono",children:S},S)),p.models.length>4&&e.jsxs("span",{className:"rounded bg-white/5 px-1.5 py-0.5 text-[9px]",children:["+",p.models.length-4]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:b?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:c,disabled:g,className:"inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-zinc-400 transition-colors hover:bg-surface-hover hover:text-zinc-200 disabled:opacity-50",children:[g?e.jsx(rt,{className:"h-3 w-3 animate-spin"}):e.jsx(bi,{className:"h-3 w-3"}),"Test"]}),n.needsKey&&e.jsxs("button",{onClick:d,className:"inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-zinc-400 transition-colors hover:bg-surface-hover hover:text-zinc-200",children:[e.jsx(Ni,{className:"h-3 w-3"}),"Edit"]}),(i==null?void 0:i.source)==="db"&&e.jsxs("button",{onClick:m,className:"inline-flex items-center gap-1.5 rounded-lg border border-red-500/20 px-3 py-1.5 text-xs font-medium text-red-400 transition-colors hover:bg-red-500/10",children:[e.jsx(Ot,{className:"h-3 w-3"}),"Remove"]})]}):e.jsxs("button",{onClick:d,className:"inline-flex items-center gap-1.5 rounded-lg bg-purple-600 px-4 py-1.5 text-xs font-medium text-white transition-colors hover:bg-purple-700",children:[e.jsx(ht,{className:"h-3 w-3"}),"Add Key"]})}),e.jsx("div",{className:"mt-3 border-t border-border/50 pt-2.5",children:e.jsxs("a",{href:n.keyUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-zinc-600 hover:text-zinc-400 transition-colors",children:[e.jsx(Pn,{className:"h-2.5 w-2.5"}),n.keyUrlLabel]})})]})}function RN(){const[n,i]=u.useState([]),[d,c]=u.useState(!0),[m,f]=u.useState(null),[h,b]=u.useState(null),[g,p]=u.useState(null),S=u.useCallback(async()=>{try{const w=await ys.list();i(w.data)}catch{}finally{c(!1)}},[]);u.useEffect(()=>{S()},[S]);const y=async w=>{b(w),p(null);try{const N=await ys.test(w);p({provider:w,result:N.data})}catch(N){p({provider:w,result:{valid:!1,message:N instanceof Error?N.message:"Test failed"}})}finally{b(null)}},v=async w=>{try{await ys.remove(w),await S(),(g==null?void 0:g.provider)===w&&p(null)}catch{}},k=w=>n.find(N=>N.provider===w)||null,C=n.filter(w=>w.configured).length;return d?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-purple-500 border-t-transparent"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-purple-500/10",children:e.jsx(Ni,{className:"h-5 w-5 text-purple-400"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-white",children:"API Keys"}),e.jsx("p",{className:"text-sm text-zinc-500",children:"Manage your LLM provider credentials securely."})]})]})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-surface px-3 py-1.5 border border-border",children:[e.jsx(Ds,{className:"h-3.5 w-3.5 text-green-400"}),e.jsxs("span",{className:"text-xs text-zinc-400",children:[C,"/",l0.length," configured"]})]}),e.jsxs("button",{onClick:()=>{c(!0),S()},className:"inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs text-zinc-400 hover:bg-surface-hover hover:text-zinc-200 transition-colors",children:[e.jsx(xt,{className:"h-3 w-3"}),"Refresh"]})]})]}),e.jsx("div",{className:"rounded-xl border border-border bg-surface/50 p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ds,{className:"h-5 w-5 text-purple-400 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-xs text-zinc-400 space-y-1",children:[e.jsxs("p",{children:["API keys are encrypted with AES-256-GCM and stored locally in the Nestor database. The encryption key is derived from a master secret in ",e.jsx("code",{className:"text-zinc-300",children:"~/.nestor/.vault-key"}),"."]}),e.jsx("p",{children:"Keys set via environment variables take precedence over database-stored keys."})]})]})}),e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:l0.map(w=>e.jsx(TN,{meta:w,entry:k(w.id),onAdd:()=>f(w),onTest:()=>y(w.id),onRemove:()=>v(w.id),testingProvider:h,testResult:g},w.id))}),m&&e.jsx(EN,{provider:m,onClose:()=>f(null),onSaved:()=>{f(null),S()}})]})}const Yd=[{id:"gemini",name:"Gemini",provider:"Google",description:"Multimodal AI with large context window",defaultModel:"gemini-2.5-flash",keyUrl:"https://aistudio.google.com/apikey",keyUrlLabel:"aistudio.google.com",emoji:"🔵",needsApiKey:!0},{id:"claude",name:"Claude",provider:"Anthropic",description:"Best for reasoning, analysis, and code generation",defaultModel:"claude-sonnet-4-6",keyUrl:"https://console.anthropic.com/settings/keys",keyUrlLabel:"console.anthropic.com",emoji:"🟣",needsApiKey:!0},{id:"openai",name:"GPT-4o",provider:"OpenAI",description:"Versatile model with strong general capabilities",defaultModel:"gpt-4o",keyUrl:"https://platform.openai.com/api-keys",keyUrlLabel:"platform.openai.com",emoji:"🟢",needsApiKey:!0},{id:"grok",name:"Grok",provider:"xAI",description:"Real-time knowledge with web access",defaultModel:"grok-3",keyUrl:"https://console.x.ai/",keyUrlLabel:"console.x.ai",emoji:"⚪",needsApiKey:!0},{id:"mistral",name:"Mistral",provider:"Mistral AI",description:"Efficient European AI with strong multilingual support",defaultModel:"mistral-large-latest",keyUrl:"https://console.mistral.ai/api-keys",keyUrlLabel:"console.mistral.ai",emoji:"🟠",needsApiKey:!0},{id:"openrouter",name:"OpenRouter",provider:"OpenRouter",description:"Access 200+ models through a single API",defaultModel:"google/gemini-2.5-flash-preview",keyUrl:"https://openrouter.ai/keys",keyUrlLabel:"openrouter.ai",emoji:"🔀",needsApiKey:!0},{id:"ollama",name:"Ollama",provider:"Local",description:"Run open-source models locally, no API key needed",defaultModel:"llama3.1",keyUrl:"https://ollama.ai/download",keyUrlLabel:"ollama.ai",emoji:"🦙",needsApiKey:!1,note:"Free, runs on your machine"}];function MN(){var me;const n=Dt(),[i,d]=u.useState(0),[c,m]=u.useState("gemini"),[f,h]=u.useState("gemini-2.5-flash"),[b,g]=u.useState(""),[p,S]=u.useState(!1),[y,v]=u.useState({}),[k,C]=u.useState(!0),[w,N]=u.useState(!1),[z,R]=u.useState(null),[D,O]=u.useState("my-agent"),[se,Z]=u.useState("My first Nestor agent"),[U,A]=u.useState(!1),[F,$]=u.useState("");u.useEffect(()=>{Kh.status().then(ue=>{ue!=null&&ue.data&&typeof ue.data=="object"&&v(ue.data)}).catch(()=>{}).finally(()=>C(!1))},[]);const Q=u.useCallback(ue=>{m(ue);const je=Yd.find(T=>T.id===ue);je&&h(je.defaultModel),g(""),S(!1),R(null)},[]),ce=u.useCallback(()=>{d(ue=>Math.min(ue+1,2))},[]),I=u.useCallback(()=>{d(ue=>Math.max(ue-1,0))},[]),le=Yd.find(ue=>ue.id===c),Y=((me=y[c])==null?void 0:me.configured)??!1,B=u.useCallback(async()=>{N(!0),R(null);try{const ue=await Kh.test({provider:c,apiKey:b.trim()||void 0,model:f});R(ue)}catch(ue){R({success:!1,message:ue instanceof Error?ue.message:"Connection test failed"})}finally{N(!1)}},[c,b,f]),ne=u.useCallback(async()=>{if(!D.trim()){$("Please enter an agent name.");return}A(!0),$("");try{b.trim()&&(le!=null&&le.needsApiKey)&&await ys.set(c,b.trim(),"Onboarding key"),await la.create({name:D.trim(),description:se.trim()||void 0,adapterType:c,adapterConfig:{model:f},trustLevel:"trusted"}),localStorage.setItem("nestor_onboarding_complete","true"),n("/chat")}catch(ue){$(ue instanceof Error?ue.message:"Failed to create agent")}finally{A(!1)}},[D,se,c,f,b,le,n]);return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-2xl",children:[e.jsx("div",{className:"flex items-center justify-center gap-2 mb-8",children:[0,1,2].map(ue=>e.jsx("div",{className:`h-1.5 rounded-full transition-all duration-500 ${ue===i?"w-10 bg-purple-500":ue<i?"w-10 bg-purple-500/40":"w-10 bg-zinc-700"}`},ue))}),e.jsxs("div",{className:"relative",children:[i===0&&e.jsxs("div",{className:"text-center onboarding-fade-in",children:[e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx("div",{className:"flex h-20 w-20 items-center justify-center rounded-2xl bg-purple-600 text-white shadow-lg shadow-purple-500/30",children:e.jsx(sa,{className:"h-10 w-10"})})}),e.jsx("h1",{className:"text-4xl font-bold text-white mb-3",children:"Welcome to Nestor"}),e.jsx("p",{className:"text-zinc-400 text-lg mb-2",children:"Your AI agent platform is ready."}),e.jsx("p",{className:"text-zinc-500 mb-12",children:"Let's create your first agent in 30 seconds."}),e.jsxs("button",{onClick:ce,className:"inline-flex items-center gap-2 px-8 py-3.5 bg-purple-600 hover:bg-purple-700 text-white rounded-xl font-medium transition-all text-lg shadow-lg shadow-purple-500/25 hover:shadow-purple-500/40 hover:scale-[1.02] active:scale-[0.98]",children:["Get Started",e.jsx(ds,{className:"h-5 w-5"})]})]}),i===1&&e.jsxs("div",{className:"onboarding-fade-in",children:[e.jsx("h2",{className:"text-2xl font-bold text-white mb-1 text-center",children:"Choose your AI provider"}),e.jsx("p",{className:"text-zinc-500 mb-6 text-center text-sm",children:"Select which LLM to power your agent"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3 mb-6",children:Yd.map(ue=>{var P;const je=c===ue.id,T=((P=y[ue.id])==null?void 0:P.configured)??!1;return e.jsxs("button",{onClick:()=>Q(ue.id),className:`relative text-left p-4 rounded-xl border-2 transition-all duration-200 hover:scale-[1.02] ${je?"border-purple-500 bg-purple-500/10 shadow-lg shadow-purple-500/10":"border-border bg-surface hover:border-zinc-600 hover:bg-surface-hover"}`,children:[T&&e.jsx("span",{className:"absolute top-2 right-2 text-green-400",title:"API key configured",children:e.jsx(bt,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"text-lg mb-1",children:ue.emoji}),e.jsx("div",{className:"font-semibold text-sm text-zinc-100",children:ue.name}),e.jsx("div",{className:"text-[11px] text-zinc-500",children:ue.provider}),ue.note&&e.jsx("div",{className:"text-[10px] text-green-400/80 mt-1",children:ue.note}),ue.needsApiKey&&e.jsxs("a",{href:ue.keyUrl,target:"_blank",rel:"noopener noreferrer",onClick:de=>de.stopPropagation(),className:"inline-flex items-center gap-1 text-[10px] text-purple-400 hover:text-purple-300 mt-1.5 transition-colors",children:["Get API Key ",e.jsx(Pn,{className:"h-2.5 w-2.5"})]})]},ue.id)})}),e.jsxs("div",{className:"space-y-3",children:[(le==null?void 0:le.needsApiKey)&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-zinc-300 mb-1.5",children:["API Key",Y&&e.jsxs("span",{className:"ml-2 text-xs text-green-400 font-normal",children:[e.jsx(bt,{className:"inline h-3 w-3 mr-0.5"}),"Already configured"]})]}),Y?e.jsx("p",{className:"text-xs text-zinc-500 mb-2",children:"Your API key is already set. You can skip this field or enter a new key to update it."}):null,e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:p?"text":"password",value:b,onChange:ue=>{g(ue.target.value),R(null)},className:"w-full bg-background border border-border rounded-lg px-3 py-2.5 pr-10 text-sm text-zinc-200 focus:outline-none focus:border-purple-500 placeholder-zinc-600 transition-colors",placeholder:`Enter your ${le.provider} API key`}),e.jsx("button",{type:"button",onClick:()=>S(!p),className:"absolute right-3 top-1/2 -translate-y-1/2 text-zinc-500 hover:text-zinc-300 transition-colors",children:p?e.jsx(uu,{className:"h-4 w-4"}):e.jsx(el,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex items-center justify-between mt-1.5",children:e.jsxs("a",{href:le.keyUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-purple-400 hover:text-purple-300 transition-colors",children:["Get your API key ",e.jsx(Pn,{className:"h-3 w-3"})]})})]}),c==="ollama"&&e.jsxs("div",{className:"bg-surface border border-border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-zinc-300 font-medium mb-1",children:"No API key needed"}),e.jsxs("p",{className:"text-xs text-zinc-400",children:["Make sure Ollama is running on ",e.jsx("code",{className:"text-zinc-300",children:"localhost:11434"})]}),e.jsxs("a",{href:"https://ollama.ai/download",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-purple-400 hover:text-purple-300 mt-2 transition-colors",children:["Download Ollama ",e.jsx(Pn,{className:"h-3 w-3"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-zinc-300 mb-1",children:"Model"}),e.jsx("input",{type:"text",value:f,onChange:ue=>h(ue.target.value),className:"w-full bg-background border border-border rounded-lg px-3 py-2 text-sm text-zinc-200 focus:outline-none focus:border-purple-500 placeholder-zinc-600 transition-colors",placeholder:"e.g. gemini-2.5-flash"})]}),e.jsx("button",{onClick:B,disabled:w||!b.trim()&&(le==null?void 0:le.needsApiKey)&&!Y,className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg border border-border text-sm font-medium text-zinc-300 transition-all hover:bg-surface-hover hover:text-white disabled:opacity-40 disabled:cursor-not-allowed",children:w?e.jsxs(e.Fragment,{children:[e.jsx(rt,{className:"h-4 w-4 animate-spin"}),"Testing connection..."]}):e.jsxs(e.Fragment,{children:[e.jsx(bi,{className:"h-4 w-4"}),"Test Connection"]})}),z&&e.jsx("div",{className:`rounded-lg border p-3 text-sm transition-all ${z.success?"border-green-500/30 bg-green-500/5 text-green-400":"border-red-500/30 bg-red-500/5 text-red-400"}`,children:e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[z.success?e.jsx(bt,{className:"h-4 w-4"}):e.jsx(xi,{className:"h-4 w-4"}),z.message]})})]}),e.jsxs("div",{className:"flex justify-between mt-8",children:[e.jsxs("button",{onClick:I,className:"flex items-center gap-1 px-4 py-2 text-sm text-zinc-400 hover:text-zinc-200 transition-colors",children:[e.jsx($h,{className:"h-4 w-4"}),"Back"]}),e.jsxs("button",{onClick:ce,className:"flex items-center gap-2 px-6 py-2.5 bg-purple-600 hover:bg-purple-700 text-white rounded-xl font-medium transition-all text-sm hover:shadow-lg hover:shadow-purple-500/20",children:["Continue",e.jsx(ds,{className:"h-4 w-4"})]})]})]}),i===2&&e.jsxs("div",{className:"onboarding-fade-in",children:[e.jsx("h2",{className:"text-2xl font-bold text-white mb-1 text-center",children:"Name your agent"}),e.jsx("p",{className:"text-zinc-500 mb-6 text-center text-sm",children:"Almost there! Give your agent a name."}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-zinc-300 mb-1",children:"Agent name"}),e.jsx("input",{type:"text",value:D,onChange:ue=>O(ue.target.value),className:"w-full bg-background border border-border rounded-lg px-3 py-2.5 text-sm text-zinc-200 focus:outline-none focus:border-purple-500 placeholder-zinc-600 transition-colors",placeholder:"e.g. my-agent"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-zinc-300 mb-1",children:"Description"}),e.jsx("textarea",{value:se,onChange:ue=>Z(ue.target.value),rows:2,className:"w-full bg-background border border-border rounded-lg px-3 py-2.5 text-sm text-zinc-200 focus:outline-none focus:border-purple-500 placeholder-zinc-600 resize-none transition-colors",placeholder:"What does this agent do?"})]}),e.jsxs("div",{className:"bg-surface border border-border rounded-xl p-4",children:[e.jsx("p",{className:"text-xs text-zinc-500 mb-2 font-medium uppercase tracking-wider",children:"Summary"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-sm text-zinc-300",children:[e.jsx("span",{className:"text-zinc-500",children:"Agent:"})," ",e.jsx("span",{className:"font-medium text-zinc-100",children:D||"—"})]}),e.jsxs("p",{className:"text-sm text-zinc-300",children:[e.jsx("span",{className:"text-zinc-500",children:"Provider:"})," ",e.jsx("span",{className:"text-purple-400",children:le==null?void 0:le.name})," ",e.jsxs("span",{className:"text-zinc-500",children:["(",f,")"]})]}),b.trim()&&(le==null?void 0:le.needsApiKey)&&e.jsxs("p",{className:"text-sm text-zinc-300",children:[e.jsx("span",{className:"text-zinc-500",children:"API Key:"})," ",e.jsx("span",{className:"text-green-400",children:"Will be saved securely"})]})]})]}),F&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-red-400",children:[e.jsx(xi,{className:"h-4 w-4 flex-shrink-0"}),F]})]}),e.jsxs("div",{className:"flex justify-between mt-8",children:[e.jsxs("button",{onClick:I,className:"flex items-center gap-1 px-4 py-2 text-sm text-zinc-400 hover:text-zinc-200 transition-colors",children:[e.jsx($h,{className:"h-4 w-4"}),"Back"]}),e.jsx("button",{onClick:ne,disabled:U||!D.trim(),className:"flex items-center gap-2 px-6 py-2.5 bg-purple-600 hover:bg-purple-700 disabled:opacity-50 disabled:cursor-not-allowed text-white rounded-xl font-medium transition-all text-sm shadow-lg shadow-purple-500/20 hover:shadow-purple-500/40 hover:scale-[1.02] active:scale-[0.98]",children:U?e.jsxs(e.Fragment,{children:[e.jsx(rt,{className:"h-4 w-4 animate-spin"}),"Creating..."]}):e.jsxs(e.Fragment,{children:["Create & Start Chatting",e.jsx(ds,{className:"h-4 w-4"})]})})]})]})]}),e.jsx("div",{className:"text-center mt-12",children:e.jsx("p",{className:"text-xs text-zinc-600",children:"You can always add more agents and change settings later."})})]})})}const DN={discord:{color:"bg-indigo-500/20 text-indigo-400",envVar:"DISCORD_BOT_TOKEN"},slack:{color:"bg-green-500/20 text-green-400",envVar:"SLACK_BOT_TOKEN"},telegram:{color:"bg-blue-500/20 text-blue-400",envVar:"TELEGRAM_BOT_TOKEN"}};function ON({adapter:n}){const i=DN[n.adapter]??{color:"bg-zinc-500/20 text-zinc-400",envVar:"N/A"};return e.jsxs("div",{className:"rounded-lg border border-border bg-surface p-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${i.color}`,children:e.jsx(Pt,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium capitalize text-zinc-200",children:n.adapter}),e.jsx("p",{className:"text-xs text-zinc-500",children:n.envVar||i.envVar})]})]}),n.configured?e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-green-500/10 px-3 py-1 text-xs font-medium text-green-400",children:[e.jsx(et,{className:"h-3 w-3"})," Connected"]}):e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-zinc-500/10 px-3 py-1 text-xs font-medium text-zinc-400",children:[e.jsx(ft,{className:"h-3 w-3"})," Not configured"]})]}),e.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"rounded-md bg-zinc-900/50 p-2.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-zinc-500",children:"Channels"}),e.jsx("p",{className:"mt-1 text-lg font-semibold text-white",children:n.channelCount})]}),e.jsxs("div",{className:"rounded-md bg-zinc-900/50 p-2.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-zinc-500",children:"Last Message"}),e.jsx("p",{className:"mt-1 text-sm text-zinc-300",children:n.lastMessageAt?new Date(n.lastMessageAt).toLocaleTimeString():"--"})]})]})]})}function LN(){const{t:n}=Je(),[i,d]=u.useState([]),[c,m]=u.useState([]),[f,h]=u.useState([]),[b,g]=u.useState(!0),[p,S]=u.useState(null),[y,v]=u.useState(""),[k,C]=u.useState(""),[w,N]=u.useState(""),[z,R]=u.useState(!1),[D,O]=u.useState(null),se=u.useCallback(async()=>{g(!0),S(null);try{const[A,F]=await Promise.all([qd.status(),qd.channels()]);if(d(A.data.adapters),m(A.data.recentMessages),h(F.data),A.data.adapters.length>0&&!y){const $=A.data.adapters.find(Q=>Q.configured);$&&v($.adapter)}}catch(A){S(A instanceof Error?A.message:"Failed to load messaging status")}finally{g(!1)}},[y]);u.useEffect(()=>{se()},[se]);const Z=f.filter(A=>!y||A.adapter===y),U=async A=>{if(A.preventDefault(),!(!y||!k||!w.trim())){R(!0),O(null);try{await qd.send(y,k,w.trim()),O("success"),N(""),setTimeout(()=>se(),1e3)}catch(F){O(F instanceof Error?F.message:"Send failed")}finally{R(!1)}}};return b?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-purple-500 border-t-transparent"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Pt,{className:"h-6 w-6 text-purple-400"}),e.jsx("h1",{className:"text-2xl font-semibold text-white",children:n("messaging.title")})]}),e.jsxs("button",{onClick:se,className:"btn-ghost btn-sm",children:[e.jsx(xt,{className:"h-4 w-4"}),n("common.retry")]})]}),p&&e.jsx("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 p-4 text-sm text-red-400",children:p}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:[i.map(A=>e.jsx(ON,{adapter:A},A.adapter)),i.length===0&&e.jsxs("div",{className:"col-span-3 flex flex-col items-center justify-center rounded-lg border border-border bg-surface py-12",children:[e.jsx(Pt,{className:"h-12 w-12 text-zinc-600"}),e.jsx("p",{className:"mt-4 text-sm text-zinc-400",children:n("messaging.empty")}),e.jsx("p",{className:"mt-1 text-xs text-zinc-500",children:n("messaging.emptyDesc")})]})]}),i.some(A=>A.configured)&&e.jsxs("div",{className:"rounded-lg border border-border bg-surface p-5",children:[e.jsx("h2",{className:"mb-4 text-sm font-medium text-zinc-300",children:n("messaging.sendTest")}),e.jsxs("form",{onSubmit:U,className:"flex flex-col gap-3 sm:flex-row sm:items-end",children:[e.jsxs("div",{className:"flex-shrink-0",children:[e.jsx("label",{className:"label",children:n("messaging.adapter")}),e.jsx("select",{value:y,onChange:A=>{v(A.target.value),C("")},className:"rounded-lg border border-border bg-surface px-3 py-2 text-sm text-white focus:border-purple-500 focus:outline-none",children:i.filter(A=>A.configured).map(A=>e.jsx("option",{value:A.adapter,children:A.adapter},A.adapter))})]}),e.jsxs("div",{className:"flex-shrink-0",children:[e.jsx("label",{className:"label",children:n("messaging.channel")}),e.jsxs("select",{value:k,onChange:A=>C(A.target.value),className:"rounded-lg border border-border bg-surface px-3 py-2 text-sm text-white focus:border-purple-500 focus:outline-none",children:[e.jsx("option",{value:"",children:n("messaging.selectChannel")}),Z.map(A=>e.jsxs("option",{value:A.id,children:["#",A.name]},A.id))]})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"label",children:n("messaging.message")}),e.jsx("input",{type:"text",value:w,onChange:A=>N(A.target.value),placeholder:n("messaging.messagePlaceholder"),className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-sm text-white placeholder:text-zinc-500 focus:border-purple-500 focus:outline-none"})]}),e.jsxs("button",{type:"submit",disabled:!k||!w.trim()||z,className:"btn-primary flex-shrink-0",children:[e.jsx(gi,{className:"h-4 w-4"}),n(z?"common.loading":"messaging.send")]})]}),D&&e.jsx("p",{className:`mt-2 text-xs ${D==="success"?"text-green-400":"text-red-400"}`,children:D==="success"?n("messaging.sent"):D})]}),e.jsxs("div",{className:"rounded-lg border border-border bg-surface",children:[e.jsx("div",{className:"border-b border-border px-5 py-3",children:e.jsx("h2",{className:"text-sm font-medium text-zinc-300",children:n("messaging.recentMessages")})}),c.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(vs,{className:"h-8 w-8 text-zinc-600"}),e.jsx("p",{className:"mt-3 text-sm text-zinc-400",children:n("messaging.noMessages")})]}):e.jsx("div",{className:"divide-y divide-border",children:c.slice(0,20).map(A=>e.jsxs("div",{className:"flex items-center gap-4 px-5 py-3",children:[e.jsx("div",{className:`flex h-7 w-7 items-center justify-center rounded ${A.direction==="incoming"?"bg-blue-500/10 text-blue-400":"bg-green-500/10 text-green-400"}`,children:A.direction==="incoming"?e.jsx(Pt,{className:"h-3.5 w-3.5"}):e.jsx(gi,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium capitalize text-zinc-400",children:A.adapter}),e.jsxs("span",{className:"flex items-center gap-1 text-xs text-zinc-500",children:[e.jsx(vv,{className:"h-3 w-3"}),A.channel]})]}),e.jsx("p",{className:"mt-0.5 truncate text-sm text-zinc-200",children:A.content})]}),e.jsx("span",{className:"flex-shrink-0 text-xs text-zinc-500",children:new Date(A.timestamp).toLocaleTimeString()})]},A.id))})]})]})}const ap=[{label:"Every hour",cron:"0 * * * *"},{label:"Daily at 9am",cron:"0 9 * * *"},{label:"Weekly (Mon 9am)",cron:"0 9 * * 1"},{label:"Monthly (1st, 9am)",cron:"0 9 1 * *"},{label:"Every 15 minutes",cron:"*/15 * * * *"},{label:"Daily at midnight",cron:"0 0 * * *"}];function _N(n){const i=ap.find(d=>d.cron===n);return i?i.label:n}function Zr({label:n,value:i,icon:d}){return e.jsxs("div",{className:"rounded-lg border border-border bg-surface p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-zinc-400",children:[e.jsx(d,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider",children:n})]}),e.jsx("p",{className:"mt-2 text-2xl font-semibold text-white",children:i})]})}function UN(){var le;const{t:n}=Je(),[i,d]=u.useState([]),[c,m]=u.useState([]),[f,h]=u.useState(!0),[b,g]=u.useState(null),[p,S]=u.useState(!1),[y,v]=u.useState(""),[k,C]=u.useState("0 9 * * *"),[w,N]=u.useState(""),[z,R]=u.useState(!1),[D,O]=u.useState(!1),[se,Z]=u.useState(null),U=u.useCallback(async()=>{h(!0),g(null);try{const[Y,B]=await Promise.all([ci.list(),la.list({limit:200})]);d(Y.data),m(B.data.map(ne=>({id:ne.id,name:ne.name})))}catch(Y){g(Y instanceof Error?Y.message:"Failed to load scheduler data")}finally{h(!1)}},[]);u.useEffect(()=>{U()},[U]);const A=async()=>{if(!y)return;const Y=z?w:k;if(Y.trim()){O(!0);try{await ci.setSchedule(y,{cron:Y,enabled:!0}),S(!1),v(""),C("0 9 * * *"),N(""),R(!1),U()}catch(B){console.error("Failed to create schedule:",B)}finally{O(!1)}}},F=async Y=>{Z(Y);try{await ci.pauseSchedule(Y),U()}finally{Z(null)}},$=async Y=>{Z(Y);try{await ci.resumeSchedule(Y),U()}finally{Z(null)}},Q=async Y=>{Z(Y);try{await ci.removeSchedule(Y),U()}finally{Z(null)}},ce=i.filter(Y=>Y.status==="active").length,I=i.filter(Y=>Y.status==="paused").length;return f?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-purple-500 border-t-transparent"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(vs,{className:"h-6 w-6 text-purple-400"}),e.jsx("h1",{className:"text-2xl font-semibold text-white",children:n("scheduler.title")})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:U,className:"btn-ghost btn-sm",children:e.jsx(xt,{className:"h-4 w-4"})}),e.jsxs("button",{onClick:()=>S(!0),className:"btn-primary",children:[e.jsx(ht,{className:"h-4 w-4"}),n("scheduler.addSchedule")]})]})]}),b&&e.jsxs("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 p-4 text-sm text-red-400",children:[b,e.jsx("button",{onClick:U,className:"ml-3 underline",children:n("common.retry")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(Zr,{label:n("scheduler.totalSchedules"),value:i.length,icon:C0}),e.jsx(Zr,{label:n("scheduler.active"),value:ce,icon:Nt}),e.jsx(Zr,{label:n("scheduler.paused"),value:I,icon:tl}),e.jsx(Zr,{label:n("scheduler.nextRun"),value:(le=i.filter(Y=>Y.status==="active"&&Y.nextRun).sort((Y,B)=>new Date(Y.nextRun).getTime()-new Date(B.nextRun).getTime())[0])!=null&&le.nextRun?new Date(i.filter(Y=>Y.status==="active"&&Y.nextRun).sort((Y,B)=>new Date(Y.nextRun).getTime()-new Date(B.nextRun).getTime())[0].nextRun).toLocaleTimeString():"--",icon:L0})]}),i.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-border bg-surface py-16",children:[e.jsx(vs,{className:"h-12 w-12 text-zinc-600"}),e.jsx("p",{className:"mt-4 text-sm text-zinc-400",children:n("scheduler.empty")}),e.jsx("p",{className:"mt-1 text-xs text-zinc-500",children:n("scheduler.emptyDesc")}),e.jsxs("button",{onClick:()=>S(!0),className:"btn-primary mt-4",children:[e.jsx(ht,{className:"h-4 w-4"}),n("scheduler.addSchedule")]})]}):e.jsx("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:[e.jsx("th",{className:"px-5 py-3",children:n("scheduler.agent")}),e.jsx("th",{className:"px-5 py-3",children:n("scheduler.schedule")}),e.jsx("th",{className:"px-5 py-3",children:n("scheduler.lastRun")}),e.jsx("th",{className:"px-5 py-3",children:n("scheduler.nextRun")}),e.jsx("th",{className:"px-5 py-3",children:n("common.status")}),e.jsx("th",{className:"px-5 py-3 text-right",children:n("common.actions")})]})}),e.jsx("tbody",{className:"divide-y divide-border",children:i.map(Y=>e.jsxs("tr",{className:"group hover:bg-zinc-900/30",children:[e.jsx("td",{className:"px-5 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ts,{className:"h-4 w-4 text-purple-400"}),e.jsx("span",{className:"font-medium text-zinc-200",children:Y.agentName})]})}),e.jsxs("td",{className:"px-5 py-3",children:[e.jsx("code",{className:"rounded bg-zinc-800 px-2 py-0.5 text-xs text-purple-300",children:Y.cron}),e.jsx("p",{className:"mt-0.5 text-[11px] text-zinc-500",children:_N(Y.cron)})]}),e.jsx("td",{className:"px-5 py-3 text-zinc-400",children:Y.lastRun?e.jsxs("div",{children:[e.jsx("p",{className:"text-xs",children:new Date(Y.lastRun).toLocaleString()}),Y.lastDurationMs!==void 0&&e.jsxs("p",{className:"text-[11px] text-zinc-500",children:[(Y.lastDurationMs/1e3).toFixed(1),"s"]})]}):e.jsx("span",{className:"text-xs text-zinc-600",children:"--"})}),e.jsx("td",{className:"px-5 py-3 text-zinc-400 text-xs",children:Y.nextRun?new Date(Y.nextRun).toLocaleString():"--"}),e.jsx("td",{className:"px-5 py-3",children:e.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${Y.status==="active"?"bg-green-500/10 text-green-400":"bg-zinc-500/10 text-zinc-400"}`,children:Y.status==="active"?n("scheduler.active"):n("scheduler.paused")})}),e.jsx("td",{className:"px-5 py-3 text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[Y.status==="active"?e.jsx("button",{onClick:()=>F(Y.agentId),disabled:se===Y.agentId,className:"btn-ghost btn-sm text-amber-400",title:n("scheduler.pause"),children:e.jsx(tl,{className:"h-3.5 w-3.5"})}):e.jsx("button",{onClick:()=>$(Y.agentId),disabled:se===Y.agentId,className:"btn-ghost btn-sm text-green-400",title:n("scheduler.resume"),children:e.jsx(Nt,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>Q(Y.agentId),disabled:se===Y.agentId,className:"btn-ghost btn-sm text-red-400",title:n("common.delete"),children:e.jsx(Ot,{className:"h-3.5 w-3.5"})})]})})]},Y.id))})]})}),i.some(Y=>Y.runHistory&&Y.runHistory.length>0)&&e.jsxs("div",{className:"rounded-lg border border-border bg-surface",children:[e.jsx("div",{className:"border-b border-border px-5 py-3",children:e.jsx("h2",{className:"text-sm font-medium text-zinc-300",children:n("scheduler.runHistory")})}),e.jsx("div",{className:"divide-y divide-border",children:i.flatMap(Y=>(Y.runHistory||[]).map(B=>({...B,agentName:Y.agentName}))).sort((Y,B)=>new Date(B.startedAt).getTime()-new Date(Y.startedAt).getTime()).slice(0,10).map(Y=>e.jsxs("div",{className:"flex items-center gap-4 px-5 py-3",children:[e.jsx("span",{className:`inline-flex h-2 w-2 rounded-full ${Y.status==="completed"?"bg-green-400":Y.status==="failed"?"bg-red-400":"bg-amber-400"}`}),e.jsx("span",{className:"text-sm font-medium text-zinc-200",children:Y.agentName}),e.jsx("span",{className:"text-xs text-zinc-500",children:new Date(Y.startedAt).toLocaleString()}),e.jsxs("span",{className:"text-xs text-zinc-400",children:[(Y.durationMs/1e3).toFixed(1),"s"]}),Y.costUsd>0&&e.jsxs("span",{className:"text-xs text-zinc-500",children:["$",Y.costUsd.toFixed(4)]}),e.jsx("span",{className:`ml-auto text-xs font-medium ${Y.status==="completed"?"text-green-400":Y.status==="failed"?"text-red-400":"text-amber-400"}`,children:Y.status})]},Y.runId))})]}),p&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"w-full max-w-lg rounded-2xl border border-border bg-surface p-6 shadow-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsx("h2",{className:"text-lg font-semibold text-white",children:n("scheduler.addSchedule")}),e.jsx("button",{onClick:()=>S(!1),className:"btn-ghost btn-sm",children:e.jsx(Ze,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:n("scheduler.agent")}),e.jsxs("select",{value:y,onChange:Y=>v(Y.target.value),className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-sm text-white focus:border-purple-500 focus:outline-none",children:[e.jsx("option",{value:"",children:n("scheduler.selectAgent")}),c.map(Y=>e.jsx("option",{value:Y.id,children:Y.name},Y.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:n("scheduler.schedule")}),!z&&e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ap.map(Y=>e.jsxs("button",{onClick:()=>C(Y.cron),className:`rounded-lg border p-2 text-left text-xs transition-all ${k===Y.cron?"border-purple-500/50 bg-purple-500/10 text-purple-300":"border-border/50 bg-zinc-900/60 text-zinc-400 hover:border-purple-500/30"}`,children:[e.jsx("p",{className:"font-medium",children:Y.label}),e.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-zinc-500",children:Y.cron})]},Y.cron))}),e.jsx("button",{onClick:()=>R(!z),className:"mt-2 text-xs text-zinc-500 hover:text-zinc-300 underline",children:n(z?"scheduler.usePreset":"scheduler.useCustom")}),z&&e.jsx("input",{type:"text",value:w,onChange:Y=>N(Y.target.value),placeholder:"*/15 * * * *",className:"mt-2 w-full rounded-lg border border-border bg-surface px-3 py-2 font-mono text-sm text-white placeholder:text-zinc-500 focus:border-purple-500 focus:outline-none"})]})]}),e.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>S(!1),className:"btn-secondary",children:n("common.cancel")}),e.jsx("button",{onClick:A,disabled:!y||D,className:"btn-primary",children:n(D?"common.loading":"scheduler.addSchedule")})]})]})})]})}function $N({value:n}){const i=Math.round(n*100),d=i>=80?"bg-green-500":i>=50?"bg-amber-500":"bg-red-500";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-1.5 w-16 rounded-full bg-zinc-700",children:e.jsx("div",{className:`h-full rounded-full ${d}`,style:{width:`${i}%`}})}),e.jsxs("span",{className:"text-xs text-zinc-500",children:[i,"%"]})]})}function oi({label:n,value:i,icon:d,color:c}){return e.jsxs("div",{className:"rounded-lg border border-border bg-surface p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-zinc-400",children:[e.jsx(d,{className:`h-4 w-4 ${c??""}`}),e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider",children:n})]}),e.jsx("p",{className:"mt-2 text-2xl font-semibold text-white",children:i})]})}function BN(){const{t:n}=Je(),[i,d]=u.useState([]),[c,m]=u.useState(null),[f,h]=u.useState(!0),[b,g]=u.useState(null),[p,S]=u.useState(""),[y,v]=u.useState(null),[k,C]=u.useState(!1),[w,N]=u.useState(""),[z,R]=u.useState(""),[D,O]=u.useState(null),se=u.useCallback(async()=>{h(!0),g(null);try{const $=await Br.candidates({status:p||void 0,limit:100});d($.data),m($.meta)}catch($){g($ instanceof Error?$.message:"Failed to load evolve data")}finally{h(!1)}},[p]);u.useEffect(()=>{se()},[se]);const Z=async $=>{O($);try{await Br.approve($),se()}finally{O(null)}},U=async $=>{O($);try{await Br.reject($),se()}finally{O(null)}},A=async()=>{if(y){O(y.id);try{await Br.update(y.id,{name:z,skillContent:w}),C(!1),v(null),se()}finally{O(null)}}},F=$=>{v($),R($.name),N($.skillContent),C(!1)};return f?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-purple-500 border-t-transparent"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Pr,{className:"h-6 w-6 text-purple-400"}),e.jsx("h1",{className:"text-2xl font-semibold text-white",children:n("evolve.title")})]}),e.jsxs("button",{onClick:se,className:"btn-ghost btn-sm",children:[e.jsx(xt,{className:"h-4 w-4"}),n("common.retry")]})]}),b&&e.jsx("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 p-4 text-sm text-red-400",children:b}),c&&e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-5",children:[e.jsx(oi,{label:n("evolve.totalCandidates"),value:c.total,icon:Pr,color:"text-purple-400"}),e.jsx(oi,{label:n("evolve.pending"),value:c.pending,icon:el,color:"text-amber-400"}),e.jsx(oi,{label:n("evolve.approved"),value:c.approved,icon:et,color:"text-green-400"}),e.jsx(oi,{label:n("evolve.rejected"),value:c.rejected,icon:ft,color:"text-red-400"}),e.jsx(oi,{label:n("evolve.avgConfidence"),value:`${Math.round(c.avgConfidence*100)}%`,icon:oc,color:"text-blue-400"})]}),e.jsx("div",{className:"flex gap-2",children:["","pending","approved","rejected"].map($=>e.jsx("button",{onClick:()=>S($),className:`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors ${p===$?"bg-purple-500/20 text-purple-300":"bg-zinc-800/50 text-zinc-400 hover:text-zinc-200"}`,children:n($===""?"evolve.all":$==="pending"?"evolve.pending":$==="approved"?"evolve.approved":"evolve.rejected")},$))}),i.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-border bg-surface py-16",children:[e.jsx(Pr,{className:"h-12 w-12 text-zinc-600"}),e.jsx("p",{className:"mt-4 text-sm text-zinc-400",children:n("evolve.empty")}),e.jsx("p",{className:"mt-1 text-xs text-zinc-500",children:n("evolve.emptyDesc")})]}):e.jsx("div",{className:"space-y-3",children:i.map($=>e.jsx("div",{className:"group rounded-lg border border-border bg-surface p-4 transition-colors hover:border-purple-500/20",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("h3",{className:"font-medium text-zinc-200",children:$.name}),e.jsx($N,{value:$.confidence}),e.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${$.status==="pending"?"bg-amber-500/10 text-amber-400":$.status==="approved"?"bg-green-500/10 text-green-400":"bg-red-500/10 text-red-400"}`,children:$.status})]}),e.jsx("p",{className:"mt-1 text-sm text-zinc-400",children:$.description}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-[11px] text-zinc-500",children:[n("evolve.source"),": ",$.sourceMission]}),e.jsx("span",{className:"text-[11px] text-zinc-600",children:new Date($.createdAt).toLocaleDateString()}),$.tags.length>0&&e.jsx("div",{className:"flex gap-1",children:$.tags.map(Q=>e.jsx("span",{className:"rounded bg-zinc-800 px-1.5 py-0.5 text-[10px] text-zinc-400",children:Q},Q))})]})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:()=>F($),className:"btn-ghost btn-sm",title:n("evolve.preview"),children:e.jsx(el,{className:"h-3.5 w-3.5"})}),$.status==="pending"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{F($),C(!0)},className:"btn-ghost btn-sm text-blue-400",title:n("evolve.edit"),children:e.jsx(pi,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>Z($.id),disabled:D===$.id,className:"btn-ghost btn-sm text-green-400",title:n("evolve.approve"),children:e.jsx(et,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>U($.id),disabled:D===$.id,className:"btn-ghost btn-sm text-red-400",title:n("evolve.reject"),children:e.jsx(ft,{className:"h-3.5 w-3.5"})})]})]})]})},$.id))}),y&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"w-full max-w-3xl rounded-2xl border border-border bg-surface p-6 shadow-2xl max-h-[85vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[k?e.jsx("input",{value:z,onChange:$=>R($.target.value),className:"bg-transparent text-lg font-semibold text-white border-b border-purple-500 focus:outline-none"}):e.jsx("h2",{className:"text-lg font-semibold text-white",children:y.name}),e.jsxs("p",{className:"text-xs text-zinc-500 mt-1",children:[n("evolve.source"),": ",y.sourceMission," | ",n("evolve.confidence"),": ",Math.round(y.confidence*100),"%"]})]}),e.jsx("button",{onClick:()=>{v(null),C(!1)},className:"btn-ghost btn-sm",children:e.jsx(Ze,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"rounded-lg border border-border bg-zinc-900/50 p-4",children:[e.jsx("p",{className:"mb-2 text-xs font-medium uppercase tracking-wider text-zinc-500",children:"SKILL.md"}),k?e.jsx("textarea",{value:w,onChange:$=>N($.target.value),className:"w-full min-h-[300px] bg-transparent font-mono text-sm text-zinc-200 resize-y focus:outline-none"}):e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm text-zinc-200 leading-relaxed max-h-[400px] overflow-y-auto",children:y.skillContent})]}),e.jsx("div",{className:"mt-4 flex justify-end gap-3",children:k?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>C(!1),className:"btn-secondary",children:n("common.cancel")}),e.jsx("button",{onClick:A,disabled:D===y.id,className:"btn-primary",children:n("common.save")})]}):y.status==="pending"?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>C(!0),className:"btn-secondary",children:[e.jsx(pi,{className:"h-4 w-4"}),n("evolve.edit")]}),e.jsxs("button",{onClick:()=>U(y.id),disabled:D===y.id,className:"rounded-lg border border-red-500/30 bg-red-500/10 px-4 py-2 text-sm font-medium text-red-400 hover:bg-red-500/20",children:[e.jsx(ft,{className:"mr-1.5 inline h-4 w-4"}),n("evolve.reject")]}),e.jsxs("button",{onClick:()=>Z(y.id),disabled:D===y.id,className:"btn-primary",children:[e.jsx(et,{className:"mr-1.5 inline h-4 w-4"}),n("evolve.approve")]})]}):e.jsx("button",{onClick:()=>v(null),className:"btn-secondary",children:n("common.close")})})]})})]})}function HN({children:n}){const[i,d]=u.useState(!1),c=Dt(),m=js();return u.useEffect(()=>{if(m.pathname==="/onboarding"){d(!0);return}if(localStorage.getItem("nestor_onboarding_complete")==="true"||localStorage.getItem("nestor_onboarded")==="true"){d(!0);return}la.list().then(f=>{!f.data||f.data.length===0?c("/onboarding"):localStorage.setItem("nestor_onboarding_complete","true"),d(!0)}).catch(()=>d(!0))},[m.pathname,c]),i?e.jsx(e.Fragment,{children:n}):e.jsx("div",{className:"flex items-center justify-center h-screen bg-background",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-purple-500 border-t-transparent"})})}function He(n){return e.jsx(gj,{fallback:e.jsx(bj,{}),children:n})}function qN(){const{user:n,loading:i}=ol();return i?e.jsx("div",{className:"flex h-screen items-center justify-center bg-background text-zinc-400",children:"Loading..."}):n?e.jsx(HN,{children:e.jsxs(y0,{children:[e.jsx(Me,{path:"/onboarding",element:e.jsx(MN,{})}),e.jsxs(Me,{element:e.jsx(pj,{}),children:[e.jsx(Me,{path:"/",element:e.jsx(_h,{to:"/missions",replace:!0})}),e.jsx(Me,{path:"/missions",element:He(e.jsx(zN,{}))}),e.jsx(Me,{path:"/chat",element:He(e.jsx(bN,{}))}),e.jsx(Me,{path:"/dashboard",element:He(e.jsx(Nj,{}))}),e.jsx(Me,{path:"/agents",element:He(e.jsx(Aj,{}))}),e.jsx(Me,{path:"/agents/:id",element:He(e.jsx(Oj,{}))}),e.jsx(Me,{path:"/agents/:id/prompts",element:He(e.jsx(S1,{}))}),e.jsx(Me,{path:"/agents/:id/memory-store",element:He(e.jsx(W1,{}))}),e.jsx(Me,{path:"/workflows",element:He(e.jsx($j,{}))}),e.jsx(Me,{path:"/workflows/:id/edit",element:He(e.jsx(Hj,{}))}),e.jsx(Me,{path:"/skills",element:He(e.jsx(Kj,{}))}),e.jsx(Me,{path:"/runs",element:He(e.jsx(Vj,{}))}),e.jsx(Me,{path:"/runs/:id",element:He(e.jsx(e1,{}))}),e.jsx(Me,{path:"/goals",element:He(e.jsx(B1,{}))}),e.jsx(Me,{path:"/approvals",element:He(e.jsx(l1,{}))}),e.jsx(Me,{path:"/handoffs",element:He(e.jsx(H1,{}))}),e.jsx(Me,{path:"/analytics",element:He(e.jsx(g1,{}))}),e.jsx(Me,{path:"/budget",element:He(e.jsx(O1,{}))}),e.jsx(Me,{path:"/traces",element:He(e.jsx(N1,{}))}),e.jsx(Me,{path:"/memory",element:He(e.jsx(E1,{}))}),e.jsx(Me,{path:"/users",element:He(e.jsx(w1,{}))}),e.jsx(Me,{path:"/plans",element:He(e.jsx(Y1,{}))}),e.jsx(Me,{path:"/plans/:id",element:He(e.jsx(X1,{}))}),e.jsx(Me,{path:"/guardrails",element:He(e.jsx(P1,{}))}),e.jsx(Me,{path:"/messaging",element:He(e.jsx(LN,{}))}),e.jsx(Me,{path:"/scheduler",element:He(e.jsx(UN,{}))}),e.jsx(Me,{path:"/evolve",element:He(e.jsx(BN,{}))}),e.jsx(Me,{path:"/admin",element:He(e.jsx(dN,{}))}),e.jsx(Me,{path:"/settings",element:He(e.jsx(t1,{}))}),e.jsx(Me,{path:"/keys",element:He(e.jsx(RN,{}))}),e.jsx(Me,{path:"*",element:e.jsx(_h,{to:"/missions",replace:!0})})]})]})}):e.jsx(X0,{})}function GN(){return e.jsx(Xv,{children:e.jsx(Jv,{children:e.jsxs(y0,{children:[e.jsx(Me,{path:"/login",element:e.jsx(X0,{})}),e.jsx(Me,{path:"/*",element:e.jsx(qN,{})})]})})})}const np=document.getElementById("root");if(!np)throw new Error("Root element not found");Eb.createRoot(np).render(e.jsx(u.StrictMode,{children:e.jsx(Wy,{children:e.jsx(GN,{})})}));
607
+ //# sourceMappingURL=index-B5zLCypy.js.map