@openscout/scout 0.2.72 → 0.2.73

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 (46) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +41 -7
  3. package/bin/scout +34 -0
  4. package/bin/scout.mjs +195 -18
  5. package/bin/scoutd +0 -0
  6. package/dist/client/apple-touch-icon.png +0 -0
  7. package/dist/client/assets/RepoDiffViewer-D8gg36W3.js +56 -0
  8. package/dist/client/assets/{addon-fit-C5ueiijZ.js → addon-fit-D4KdY-pj.js} +1 -1
  9. package/dist/client/assets/{addon-webgl-Cm7sl8RO.js → addon-webgl-Bo_tmKBp.js} +1 -1
  10. package/dist/client/assets/arc.es-D0gujIKy.js +188 -0
  11. package/dist/client/assets/embed-entry-CUVNwyB_.js +1 -0
  12. package/dist/client/assets/index-CRkjiso5.js +257 -0
  13. package/dist/client/assets/index-D_RX2cRb.css +1 -0
  14. package/dist/client/assets/{xterm-FFux-PdF.js → xterm-RfflDFod.js} +1 -1
  15. package/dist/client/favicon-16.png +0 -0
  16. package/dist/client/favicon-32.png +0 -0
  17. package/dist/client/favicon.ico +0 -0
  18. package/dist/client/favicon.svg +48 -0
  19. package/dist/client/index.html +8 -2
  20. package/dist/client/openscout-icon.png +0 -0
  21. package/dist/client/site.webmanifest +19 -0
  22. package/dist/client/web-app-icon-192.png +0 -0
  23. package/dist/client/web-app-icon-512.png +0 -0
  24. package/dist/drizzle/0000_curly_iron_monger.sql +592 -0
  25. package/dist/drizzle/0001_invocation-status-columns.sql +7 -0
  26. package/dist/drizzle/0002_invocation-flight-metadata.sql +21 -0
  27. package/dist/drizzle/README.md +81 -0
  28. package/dist/drizzle/meta/0000_snapshot.json +4575 -0
  29. package/dist/drizzle/meta/0001_snapshot.json +4624 -0
  30. package/dist/drizzle/meta/0002_snapshot.json +4631 -0
  31. package/dist/drizzle/meta/_journal.json +27 -0
  32. package/dist/main.mjs +72583 -60970
  33. package/dist/node/main.mjs +7607 -0
  34. package/dist/openscout-terminal-relay.mjs +3819 -158
  35. package/dist/{pair-supervisor.mjs → pairing-runtime-controller.mjs} +51525 -46801
  36. package/dist/runtime/base-daemon.mjs +2153 -502
  37. package/dist/runtime/broker-daemon.mjs +34730 -27036
  38. package/dist/runtime/broker-process-manager.mjs +2038 -421
  39. package/dist/runtime/mesh-discover.mjs +2002 -420
  40. package/dist/scout-control-plane-web.mjs +54522 -39921
  41. package/dist/scout-web-server.mjs +54522 -39921
  42. package/dist/statusline.mjs +287 -0
  43. package/package.json +7 -3
  44. package/dist/client/assets/RepoDiffViewer-DRzXs-TP.js +0 -1
  45. package/dist/client/assets/index-CYs6TkOv.js +0 -191
  46. package/dist/client/assets/index-n_fpvwq8.css +0 -1
@@ -1,191 +0,0 @@
1
- function t6(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in e)){const o=Object.getOwnPropertyDescriptor(r,a);o&&Object.defineProperty(e,a,o.get?o:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();function x2(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ay={exports:{}},Hu={};var LC;function n6(){if(LC)return Hu;LC=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,a,o){var c=null;if(o!==void 0&&(c=""+o),a.key!==void 0&&(c=""+a.key),"key"in a){o={};for(var u in a)u!=="key"&&(o[u]=a[u])}else o=a;return a=o.ref,{$$typeof:e,type:r,key:c,ref:a!==void 0?a:null,props:o}}return Hu.Fragment=t,Hu.jsx=n,Hu.jsxs=n,Hu}var PC;function s6(){return PC||(PC=1,ay.exports=n6()),ay.exports}var s=s6(),iy={exports:{}},gt={};var DC;function r6(){if(DC)return gt;DC=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),x=Symbol.for("react.activity"),v=Symbol.iterator;function y(P){return P===null||typeof P!="object"?null:(P=v&&P[v]||P["@@iterator"],typeof P=="function"?P:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function A(P,H,B){this.props=P,this.context=H,this.refs=E,this.updater=B||b}A.prototype.isReactComponent={},A.prototype.setState=function(P,H){if(typeof P!="object"&&typeof P!="function"&&P!=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,P,H,"setState")},A.prototype.forceUpdate=function(P){this.updater.enqueueForceUpdate(this,P,"forceUpdate")};function S(){}S.prototype=A.prototype;function k(P,H,B){this.props=P,this.context=H,this.refs=E,this.updater=B||b}var N=k.prototype=new S;N.constructor=k,C(N,A.prototype),N.isPureReactComponent=!0;var T=Array.isArray;function R(){}var O={H:null,A:null,T:null,S:null},L=Object.prototype.hasOwnProperty;function I(P,H,B){var Q=B.ref;return{$$typeof:e,type:P,key:H,ref:Q!==void 0?Q:null,props:B}}function z(P,H){return I(P.type,H,P.props)}function _(P){return typeof P=="object"&&P!==null&&P.$$typeof===e}function U(P){var H={"=":"=0",":":"=2"};return"$"+P.replace(/[=:]/g,function(B){return H[B]})}var D=/\/+/g;function q(P,H){return typeof P=="object"&&P!==null&&P.key!=null?U(""+P.key):H.toString(36)}function Z(P){switch(P.status){case"fulfilled":return P.value;case"rejected":throw P.reason;default:switch(typeof P.status=="string"?P.then(R,R):(P.status="pending",P.then(function(H){P.status==="pending"&&(P.status="fulfilled",P.value=H)},function(H){P.status==="pending"&&(P.status="rejected",P.reason=H)})),P.status){case"fulfilled":return P.value;case"rejected":throw P.reason}}throw P}function $(P,H,B,Q,oe){var ne=typeof P;(ne==="undefined"||ne==="boolean")&&(P=null);var X=!1;if(P===null)X=!0;else switch(ne){case"bigint":case"string":case"number":X=!0;break;case"object":switch(P.$$typeof){case e:case t:X=!0;break;case p:return X=P._init,$(X(P._payload),H,B,Q,oe)}}if(X)return oe=oe(P),X=Q===""?"."+q(P,0):Q,T(oe)?(B="",X!=null&&(B=X.replace(D,"$&/")+"/"),$(oe,H,B,"",function(_e){return _e})):oe!=null&&(_(oe)&&(oe=z(oe,B+(oe.key==null||P&&P.key===oe.key?"":(""+oe.key).replace(D,"$&/")+"/")+X)),H.push(oe)),1;X=0;var ae=Q===""?".":Q+":";if(T(P))for(var be=0;be<P.length;be++)Q=P[be],ne=ae+q(Q,be),X+=$(Q,H,B,ne,oe);else if(be=y(P),typeof be=="function")for(P=be.call(P),be=0;!(Q=P.next()).done;)Q=Q.value,ne=ae+q(Q,be++),X+=$(Q,H,B,ne,oe);else if(ne==="object"){if(typeof P.then=="function")return $(Z(P),H,B,Q,oe);throw H=String(P),Error("Objects are not valid as a React child (found: "+(H==="[object Object]"?"object with keys {"+Object.keys(P).join(", ")+"}":H)+"). If you meant to render a collection of children, use an array instead.")}return X}function G(P,H,B){if(P==null)return P;var Q=[],oe=0;return $(P,Q,"","",function(ne){return H.call(B,ne,oe++)}),Q}function V(P){if(P._status===-1){var H=P._result;H=H(),H.then(function(B){(P._status===0||P._status===-1)&&(P._status=1,P._result=B)},function(B){(P._status===0||P._status===-1)&&(P._status=2,P._result=B)}),P._status===-1&&(P._status=0,P._result=H)}if(P._status===1)return P._result.default;throw P._result}var Y=typeof reportError=="function"?reportError:function(P){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var H=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof P=="object"&&P!==null&&typeof P.message=="string"?String(P.message):String(P),error:P});if(!window.dispatchEvent(H))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",P);return}console.error(P)},K={map:G,forEach:function(P,H,B){G(P,function(){H.apply(this,arguments)},B)},count:function(P){var H=0;return G(P,function(){H++}),H},toArray:function(P){return G(P,function(H){return H})||[]},only:function(P){if(!_(P))throw Error("React.Children.only expected to receive a single React element child.");return P}};return gt.Activity=x,gt.Children=K,gt.Component=A,gt.Fragment=n,gt.Profiler=a,gt.PureComponent=k,gt.StrictMode=r,gt.Suspense=f,gt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=O,gt.__COMPILER_RUNTIME={__proto__:null,c:function(P){return O.H.useMemoCache(P)}},gt.cache=function(P){return function(){return P.apply(null,arguments)}},gt.cacheSignal=function(){return null},gt.cloneElement=function(P,H,B){if(P==null)throw Error("The argument must be a React element, but you passed "+P+".");var Q=C({},P.props),oe=P.key;if(H!=null)for(ne in H.key!==void 0&&(oe=""+H.key),H)!L.call(H,ne)||ne==="key"||ne==="__self"||ne==="__source"||ne==="ref"&&H.ref===void 0||(Q[ne]=H[ne]);var ne=arguments.length-2;if(ne===1)Q.children=B;else if(1<ne){for(var X=Array(ne),ae=0;ae<ne;ae++)X[ae]=arguments[ae+2];Q.children=X}return I(P.type,oe,Q)},gt.createContext=function(P){return P={$$typeof:c,_currentValue:P,_currentValue2:P,_threadCount:0,Provider:null,Consumer:null},P.Provider=P,P.Consumer={$$typeof:o,_context:P},P},gt.createElement=function(P,H,B){var Q,oe={},ne=null;if(H!=null)for(Q in H.key!==void 0&&(ne=""+H.key),H)L.call(H,Q)&&Q!=="key"&&Q!=="__self"&&Q!=="__source"&&(oe[Q]=H[Q]);var X=arguments.length-2;if(X===1)oe.children=B;else if(1<X){for(var ae=Array(X),be=0;be<X;be++)ae[be]=arguments[be+2];oe.children=ae}if(P&&P.defaultProps)for(Q in X=P.defaultProps,X)oe[Q]===void 0&&(oe[Q]=X[Q]);return I(P,ne,oe)},gt.createRef=function(){return{current:null}},gt.forwardRef=function(P){return{$$typeof:u,render:P}},gt.isValidElement=_,gt.lazy=function(P){return{$$typeof:p,_payload:{_status:-1,_result:P},_init:V}},gt.memo=function(P,H){return{$$typeof:h,type:P,compare:H===void 0?null:H}},gt.startTransition=function(P){var H=O.T,B={};O.T=B;try{var Q=P(),oe=O.S;oe!==null&&oe(B,Q),typeof Q=="object"&&Q!==null&&typeof Q.then=="function"&&Q.then(R,Y)}catch(ne){Y(ne)}finally{H!==null&&B.types!==null&&(H.types=B.types),O.T=H}},gt.unstable_useCacheRefresh=function(){return O.H.useCacheRefresh()},gt.use=function(P){return O.H.use(P)},gt.useActionState=function(P,H,B){return O.H.useActionState(P,H,B)},gt.useCallback=function(P,H){return O.H.useCallback(P,H)},gt.useContext=function(P){return O.H.useContext(P)},gt.useDebugValue=function(){},gt.useDeferredValue=function(P,H){return O.H.useDeferredValue(P,H)},gt.useEffect=function(P,H){return O.H.useEffect(P,H)},gt.useEffectEvent=function(P){return O.H.useEffectEvent(P)},gt.useId=function(){return O.H.useId()},gt.useImperativeHandle=function(P,H,B){return O.H.useImperativeHandle(P,H,B)},gt.useInsertionEffect=function(P,H){return O.H.useInsertionEffect(P,H)},gt.useLayoutEffect=function(P,H){return O.H.useLayoutEffect(P,H)},gt.useMemo=function(P,H){return O.H.useMemo(P,H)},gt.useOptimistic=function(P,H){return O.H.useOptimistic(P,H)},gt.useReducer=function(P,H,B){return O.H.useReducer(P,H,B)},gt.useRef=function(P){return O.H.useRef(P)},gt.useState=function(P){return O.H.useState(P)},gt.useSyncExternalStore=function(P,H,B){return O.H.useSyncExternalStore(P,H,B)},gt.useTransition=function(){return O.H.useTransition()},gt.version="19.2.3",gt}var zC;function uf(){return zC||(zC=1,iy.exports=r6()),iy.exports}var m=uf();const y2=x2(m),b2=t6({__proto__:null,default:y2},[m]);var oy={exports:{}},Wu={},ly={exports:{}},cy={};var BC;function a6(){return BC||(BC=1,(function(e){function t($,G){var V=$.length;$.push(G);e:for(;0<V;){var Y=V-1>>>1,K=$[Y];if(0<a(K,G))$[Y]=G,$[V]=K,V=Y;else break e}}function n($){return $.length===0?null:$[0]}function r($){if($.length===0)return null;var G=$[0],V=$.pop();if(V!==G){$[0]=V;e:for(var Y=0,K=$.length,P=K>>>1;Y<P;){var H=2*(Y+1)-1,B=$[H],Q=H+1,oe=$[Q];if(0>a(B,V))Q<K&&0>a(oe,B)?($[Y]=oe,$[Q]=V,Y=Q):($[Y]=B,$[H]=V,Y=H);else if(Q<K&&0>a(oe,V))$[Y]=oe,$[Q]=V,Y=Q;else break e}}return G}function a($,G){var V=$.sortIndex-G.sortIndex;return V!==0?V:$.id-G.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,u=c.now();e.unstable_now=function(){return c.now()-u}}var f=[],h=[],p=1,x=null,v=3,y=!1,b=!1,C=!1,E=!1,A=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function N($){for(var G=n(h);G!==null;){if(G.callback===null)r(h);else if(G.startTime<=$)r(h),G.sortIndex=G.expirationTime,t(f,G);else break;G=n(h)}}function T($){if(C=!1,N($),!b)if(n(f)!==null)b=!0,R||(R=!0,U());else{var G=n(h);G!==null&&Z(T,G.startTime-$)}}var R=!1,O=-1,L=5,I=-1;function z(){return E?!0:!(e.unstable_now()-I<L)}function _(){if(E=!1,R){var $=e.unstable_now();I=$;var G=!0;try{e:{b=!1,C&&(C=!1,S(O),O=-1),y=!0;var V=v;try{t:{for(N($),x=n(f);x!==null&&!(x.expirationTime>$&&z());){var Y=x.callback;if(typeof Y=="function"){x.callback=null,v=x.priorityLevel;var K=Y(x.expirationTime<=$);if($=e.unstable_now(),typeof K=="function"){x.callback=K,N($),G=!0;break t}x===n(f)&&r(f),N($)}else r(f);x=n(f)}if(x!==null)G=!0;else{var P=n(h);P!==null&&Z(T,P.startTime-$),G=!1}}break e}finally{x=null,v=V,y=!1}G=void 0}}finally{G?U():R=!1}}}var U;if(typeof k=="function")U=function(){k(_)};else if(typeof MessageChannel<"u"){var D=new MessageChannel,q=D.port2;D.port1.onmessage=_,U=function(){q.postMessage(null)}}else U=function(){A(_,0)};function Z($,G){O=A(function(){$(e.unstable_now())},G)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function($){$.callback=null},e.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<$?Math.floor(1e3/$):5},e.unstable_getCurrentPriorityLevel=function(){return v},e.unstable_next=function($){switch(v){case 1:case 2:case 3:var G=3;break;default:G=v}var V=v;v=G;try{return $()}finally{v=V}},e.unstable_requestPaint=function(){E=!0},e.unstable_runWithPriority=function($,G){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var V=v;v=$;try{return G()}finally{v=V}},e.unstable_scheduleCallback=function($,G,V){var Y=e.unstable_now();switch(typeof V=="object"&&V!==null?(V=V.delay,V=typeof V=="number"&&0<V?Y+V:Y):V=Y,$){case 1:var K=-1;break;case 2:K=250;break;case 5:K=1073741823;break;case 4:K=1e4;break;default:K=5e3}return K=V+K,$={id:p++,callback:G,priorityLevel:$,startTime:V,expirationTime:K,sortIndex:-1},V>Y?($.sortIndex=V,t(h,$),n(f)===null&&$===n(h)&&(C?(S(O),O=-1):C=!0,Z(T,V-Y))):($.sortIndex=K,t(f,$),b||y||(b=!0,R||(R=!0,U()))),$},e.unstable_shouldYield=z,e.unstable_wrapCallback=function($){var G=v;return function(){var V=v;v=G;try{return $.apply(this,arguments)}finally{v=V}}}})(cy)),cy}var UC;function i6(){return UC||(UC=1,ly.exports=a6()),ly.exports}var uy={exports:{}},us={};var FC;function o6(){if(FC)return us;FC=1;var e=uf();function t(f){var h="https://react.dev/errors/"+f;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)h+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+f+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},a=Symbol.for("react.portal");function o(f,h,p){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:x==null?null:""+x,children:f,containerInfo:h,implementation:p}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(f,h){if(f==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return us.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,us.createPortal=function(f,h){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(t(299));return o(f,h,null,p)},us.flushSync=function(f){var h=c.T,p=r.p;try{if(c.T=null,r.p=2,f)return f()}finally{c.T=h,r.p=p,r.d.f()}},us.preconnect=function(f,h){typeof f=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,r.d.C(f,h))},us.prefetchDNS=function(f){typeof f=="string"&&r.d.D(f)},us.preinit=function(f,h){if(typeof f=="string"&&h&&typeof h.as=="string"){var p=h.as,x=u(p,h.crossOrigin),v=typeof h.integrity=="string"?h.integrity:void 0,y=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;p==="style"?r.d.S(f,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:x,integrity:v,fetchPriority:y}):p==="script"&&r.d.X(f,{crossOrigin:x,integrity:v,fetchPriority:y,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},us.preinitModule=function(f,h){if(typeof f=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var p=u(h.as,h.crossOrigin);r.d.M(f,{crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&r.d.M(f)},us.preload=function(f,h){if(typeof f=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var p=h.as,x=u(p,h.crossOrigin);r.d.L(f,p,{crossOrigin:x,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},us.preloadModule=function(f,h){if(typeof f=="string")if(h){var p=u(h.as,h.crossOrigin);r.d.m(f,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else r.d.m(f)},us.requestFormReset=function(f){r.d.r(f)},us.unstable_batchedUpdates=function(f,h){return f(h)},us.useFormState=function(f,h,p){return c.H.useFormState(f,h,p)},us.useFormStatus=function(){return c.H.useHostTransitionStatus()},us.version="19.2.3",us}var VC;function w2(){if(VC)return uy.exports;VC=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),uy.exports=o6(),uy.exports}var HC;function l6(){if(HC)return Wu;HC=1;var e=i6(),t=uf(),n=w2();function r(i){var l="https://react.dev/errors/"+i;if(1<arguments.length){l+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)l+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+i+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function o(i){var l=i,d=i;if(i.alternate)for(;l.return;)l=l.return;else{i=l;do l=i,(l.flags&4098)!==0&&(d=l.return),i=l.return;while(i)}return l.tag===3?d:null}function c(i){if(i.tag===13){var l=i.memoizedState;if(l===null&&(i=i.alternate,i!==null&&(l=i.memoizedState)),l!==null)return l.dehydrated}return null}function u(i){if(i.tag===31){var l=i.memoizedState;if(l===null&&(i=i.alternate,i!==null&&(l=i.memoizedState)),l!==null)return l.dehydrated}return null}function f(i){if(o(i)!==i)throw Error(r(188))}function h(i){var l=i.alternate;if(!l){if(l=o(i),l===null)throw Error(r(188));return l!==i?null:i}for(var d=i,g=l;;){var w=d.return;if(w===null)break;var j=w.alternate;if(j===null){if(g=w.return,g!==null){d=g;continue}break}if(w.child===j.child){for(j=w.child;j;){if(j===d)return f(w),i;if(j===g)return f(w),l;j=j.sibling}throw Error(r(188))}if(d.return!==g.return)d=w,g=j;else{for(var M=!1,F=w.child;F;){if(F===d){M=!0,d=w,g=j;break}if(F===g){M=!0,g=w,d=j;break}F=F.sibling}if(!M){for(F=j.child;F;){if(F===d){M=!0,d=j,g=w;break}if(F===g){M=!0,g=j,d=w;break}F=F.sibling}if(!M)throw Error(r(189))}}if(d.alternate!==g)throw Error(r(190))}if(d.tag!==3)throw Error(r(188));return d.stateNode.current===d?i:l}function p(i){var l=i.tag;if(l===5||l===26||l===27||l===6)return i;for(i=i.child;i!==null;){if(l=p(i),l!==null)return l;i=i.sibling}return null}var x=Object.assign,v=Symbol.for("react.element"),y=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),k=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),I=Symbol.for("react.activity"),z=Symbol.for("react.memo_cache_sentinel"),_=Symbol.iterator;function U(i){return i===null||typeof i!="object"?null:(i=_&&i[_]||i["@@iterator"],typeof i=="function"?i:null)}var D=Symbol.for("react.client.reference");function q(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===D?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case C:return"Fragment";case A:return"Profiler";case E:return"StrictMode";case T:return"Suspense";case R:return"SuspenseList";case I:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case b:return"Portal";case k:return i.displayName||"Context";case S:return(i._context.displayName||"Context")+".Consumer";case N:var l=i.render;return i=i.displayName,i||(i=l.displayName||l.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case O:return l=i.displayName||null,l!==null?l:q(i.type)||"Memo";case L:l=i._payload,i=i._init;try{return q(i(l))}catch{}}return null}var Z=Array.isArray,$=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V={pending:!1,data:null,method:null,action:null},Y=[],K=-1;function P(i){return{current:i}}function H(i){0>K||(i.current=Y[K],Y[K]=null,K--)}function B(i,l){K++,Y[K]=i.current,i.current=l}var Q=P(null),oe=P(null),ne=P(null),X=P(null);function ae(i,l){switch(B(ne,l),B(oe,i),B(Q,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?aC(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=aC(l),i=iC(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}H(Q),B(Q,i)}function be(){H(Q),H(oe),H(ne)}function _e(i){i.memoizedState!==null&&B(X,i);var l=Q.current,d=iC(l,i.type);l!==d&&(B(oe,i),B(Q,d))}function xe(i){oe.current===i&&(H(Q),H(oe)),X.current===i&&(H(X),Bu._currentValue=V)}var pe,te;function ve(i){if(pe===void 0)try{throw Error()}catch(d){var l=d.stack.trim().match(/\n( *(at )?)/);pe=l&&l[1]||"",te=-1<d.stack.indexOf(`
2
- at`)?" (<anonymous>)":-1<d.stack.indexOf("@")?"@unknown:0:0":""}return`
3
- `+pe+i+te}var he=!1;function ke(i,l){if(!i||he)return"";he=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var g={DetermineComponentFrameRoot:function(){try{if(l){var Ce=function(){throw Error()};if(Object.defineProperty(Ce.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ce,[])}catch(ye){var ge=ye}Reflect.construct(i,[],Ce)}else{try{Ce.call()}catch(ye){ge=ye}i.call(Ce.prototype)}}else{try{throw Error()}catch(ye){ge=ye}(Ce=i())&&typeof Ce.catch=="function"&&Ce.catch(function(){})}}catch(ye){if(ye&&ge&&typeof ye.stack=="string")return[ye.stack,ge.stack]}return[null,null]}};g.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var w=Object.getOwnPropertyDescriptor(g.DetermineComponentFrameRoot,"name");w&&w.configurable&&Object.defineProperty(g.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var j=g.DetermineComponentFrameRoot(),M=j[0],F=j[1];if(M&&F){var J=M.split(`
4
- `),me=F.split(`
5
- `);for(w=g=0;g<J.length&&!J[g].includes("DetermineComponentFrameRoot");)g++;for(;w<me.length&&!me[w].includes("DetermineComponentFrameRoot");)w++;if(g===J.length||w===me.length)for(g=J.length-1,w=me.length-1;1<=g&&0<=w&&J[g]!==me[w];)w--;for(;1<=g&&0<=w;g--,w--)if(J[g]!==me[w]){if(g!==1||w!==1)do if(g--,w--,0>w||J[g]!==me[w]){var we=`
6
- `+J[g].replace(" at new "," at ");return i.displayName&&we.includes("<anonymous>")&&(we=we.replace("<anonymous>",i.displayName)),we}while(1<=g&&0<=w);break}}}finally{he=!1,Error.prepareStackTrace=d}return(d=i?i.displayName||i.name:"")?ve(d):""}function Ne(i,l){switch(i.tag){case 26:case 27:case 5:return ve(i.type);case 16:return ve("Lazy");case 13:return i.child!==l&&l!==null?ve("Suspense Fallback"):ve("Suspense");case 19:return ve("SuspenseList");case 0:case 15:return ke(i.type,!1);case 11:return ke(i.type.render,!1);case 1:return ke(i.type,!0);case 31:return ve("Activity");default:return""}}function Fe(i){try{var l="",d=null;do l+=Ne(i,d),d=i,i=i.return;while(i);return l}catch(g){return`
7
- Error generating stack: `+g.message+`
8
- `+g.stack}}var Ee=Object.prototype.hasOwnProperty,Le=e.unstable_scheduleCallback,Te=e.unstable_cancelCallback,Pe=e.unstable_shouldYield,De=e.unstable_requestPaint,ze=e.unstable_now,$e=e.unstable_getCurrentPriorityLevel,st=e.unstable_ImmediatePriority,rt=e.unstable_UserBlockingPriority,Xe=e.unstable_NormalPriority,dt=e.unstable_LowPriority,jt=e.unstable_IdlePriority,At=e.log,mt=e.unstable_setDisableYieldValue,Ht=null,ie=null;function ce(i){if(typeof At=="function"&&mt(i),ie&&typeof ie.setStrictMode=="function")try{ie.setStrictMode(Ht,i)}catch{}}var Ae=Math.clz32?Math.clz32:at,Be=Math.log,tt=Math.LN2;function at(i){return i>>>=0,i===0?32:31-(Be(i)/tt|0)|0}var Oe=256,He=262144,ot=4194304;function nt(i){var l=i&42;if(l!==0)return l;switch(i&-i){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 i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function $t(i,l,d){var g=i.pendingLanes;if(g===0)return 0;var w=0,j=i.suspendedLanes,M=i.pingedLanes;i=i.warmLanes;var F=g&134217727;return F!==0?(g=F&~j,g!==0?w=nt(g):(M&=F,M!==0?w=nt(M):d||(d=F&~i,d!==0&&(w=nt(d))))):(F=g&~j,F!==0?w=nt(F):M!==0?w=nt(M):d||(d=g&~i,d!==0&&(w=nt(d)))),w===0?0:l!==0&&l!==w&&(l&j)===0&&(j=w&-w,d=l&-l,j>=d||j===32&&(d&4194048)!==0)?l:w}function Tn(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function fn(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+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 l+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 Gt(){var i=ot;return ot<<=1,(ot&62914560)===0&&(ot=4194304),i}function Rt(i){for(var l=[],d=0;31>d;d++)l.push(i);return l}function Gn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function On(i,l,d,g,w,j){var M=i.pendingLanes;i.pendingLanes=d,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=d,i.entangledLanes&=d,i.errorRecoveryDisabledLanes&=d,i.shellSuspendCounter=0;var F=i.entanglements,J=i.expirationTimes,me=i.hiddenUpdates;for(d=M&~d;0<d;){var we=31-Ae(d),Ce=1<<we;F[we]=0,J[we]=-1;var ge=me[we];if(ge!==null)for(me[we]=null,we=0;we<ge.length;we++){var ye=ge[we];ye!==null&&(ye.lane&=-536870913)}d&=~Ce}g!==0&&re(i,g,0),j!==0&&w===0&&i.tag!==0&&(i.suspendedLanes|=j&~(M&~l))}function re(i,l,d){i.pendingLanes|=l,i.suspendedLanes&=~l;var g=31-Ae(l);i.entangledLanes|=l,i.entanglements[g]=i.entanglements[g]|1073741824|d&261930}function Re(i,l){var d=i.entangledLanes|=l;for(i=i.entanglements;d;){var g=31-Ae(d),w=1<<g;w&l|i[g]&l&&(i[g]|=l),d&=~w}}function Ve(i,l){var d=l&-l;return d=(d&42)!==0?1:Ct(d),(d&(i.suspendedLanes|l))!==0?0:d}function Ct(i){switch(i){case 2:i=1;break;case 8:i=4;break;case 32:i=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:i=128;break;case 268435456:i=134217728;break;default:i=0}return i}function Ft(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function $n(){var i=G.p;return i!==0?i:(i=window.event,i===void 0?32:TC(i.type))}function tn(i,l){var d=G.p;try{return G.p=i,l()}finally{G.p=d}}var Lt=Math.random().toString(36).slice(2),Et="__reactFiber$"+Lt,Tt="__reactProps$"+Lt,Jn="__reactContainer$"+Lt,sr="__reactEvents$"+Lt,ga="__reactListeners$"+Lt,so="__reactHandles$"+Lt,ps="__reactResources$"+Lt,Es="__reactMarker$"+Lt;function va(i){delete i[Et],delete i[Tt],delete i[sr],delete i[ga],delete i[so]}function Bs(i){var l=i[Et];if(l)return l;for(var d=i.parentNode;d;){if(l=d[Jn]||d[Et]){if(d=l.alternate,l.child!==null||d!==null&&d.child!==null)for(i=hC(i);i!==null;){if(d=i[Et])return d;i=hC(i)}return l}i=d,d=i.parentNode}return null}function rr(i){if(i=i[Et]||i[Jn]){var l=i.tag;if(l===5||l===6||l===13||l===31||l===26||l===27||l===3)return i}return null}function Cr(i){var l=i.tag;if(l===5||l===26||l===27||l===6)return i.stateNode;throw Error(r(33))}function ar(i){var l=i[ps];return l||(l=i[ps]={hoistableStyles:new Map,hoistableScripts:new Map}),l}function un(i){i[Es]=!0}var As=new Set,fl={};function ir(i,l){Vr(i,l),Vr(i+"Capture",l)}function Vr(i,l){for(fl[i]=l,i=0;i<l.length;i++)As.add(l[i])}var Er=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]*$"),xa={},ya={};function nu(i){return Ee.call(ya,i)?!0:Ee.call(xa,i)?!1:Er.test(i)?ya[i]=!0:(xa[i]=!0,!1)}function gs(i,l,d){if(nu(l))if(d===null)i.removeAttribute(l);else{switch(typeof d){case"undefined":case"function":case"symbol":i.removeAttribute(l);return;case"boolean":var g=l.toLowerCase().slice(0,5);if(g!=="data-"&&g!=="aria-"){i.removeAttribute(l);return}}i.setAttribute(l,""+d)}}function ba(i,l,d){if(d===null)i.removeAttribute(l);else{switch(typeof d){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(l);return}i.setAttribute(l,""+d)}}function Us(i,l,d,g){if(g===null)i.removeAttribute(d);else{switch(typeof g){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(d);return}i.setAttributeNS(l,d,""+g)}}function W(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function ee(i){var l=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function de(i,l,d){var g=Object.getOwnPropertyDescriptor(i.constructor.prototype,l);if(!i.hasOwnProperty(l)&&typeof g<"u"&&typeof g.get=="function"&&typeof g.set=="function"){var w=g.get,j=g.set;return Object.defineProperty(i,l,{configurable:!0,get:function(){return w.call(this)},set:function(M){d=""+M,j.call(this,M)}}),Object.defineProperty(i,l,{enumerable:g.enumerable}),{getValue:function(){return d},setValue:function(M){d=""+M},stopTracking:function(){i._valueTracker=null,delete i[l]}}}}function Me(i){if(!i._valueTracker){var l=ee(i)?"checked":"value";i._valueTracker=de(i,l,""+i[l])}}function We(i){if(!i)return!1;var l=i._valueTracker;if(!l)return!0;var d=l.getValue(),g="";return i&&(g=ee(i)?i.checked?"true":"false":i.value),i=g,i!==d?(l.setValue(i),!0):!1}function Qe(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var lt=/[\n"\\]/g;function ft(i){return i.replace(lt,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function Wt(i,l,d,g,w,j,M,F){i.name="",M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"?i.type=M:i.removeAttribute("type"),l!=null?M==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+W(l)):i.value!==""+W(l)&&(i.value=""+W(l)):M!=="submit"&&M!=="reset"||i.removeAttribute("value"),l!=null?kt(i,M,W(l)):d!=null?kt(i,M,W(d)):g!=null&&i.removeAttribute("value"),w==null&&j!=null&&(i.defaultChecked=!!j),w!=null&&(i.checked=w&&typeof w!="function"&&typeof w!="symbol"),F!=null&&typeof F!="function"&&typeof F!="symbol"&&typeof F!="boolean"?i.name=""+W(F):i.removeAttribute("name")}function Zt(i,l,d,g,w,j,M,F){if(j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(i.type=j),l!=null||d!=null){if(!(j!=="submit"&&j!=="reset"||l!=null)){Me(i);return}d=d!=null?""+W(d):"",l=l!=null?""+W(l):d,F||l===i.value||(i.value=l),i.defaultValue=l}g=g??w,g=typeof g!="function"&&typeof g!="symbol"&&!!g,i.checked=F?i.checked:!!g,i.defaultChecked=!!g,M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"&&(i.name=M),Me(i)}function kt(i,l,d){l==="number"&&Qe(i.ownerDocument)===i||i.defaultValue===""+d||(i.defaultValue=""+d)}function yt(i,l,d,g){if(i=i.options,l){l={};for(var w=0;w<d.length;w++)l["$"+d[w]]=!0;for(d=0;d<i.length;d++)w=l.hasOwnProperty("$"+i[d].value),i[d].selected!==w&&(i[d].selected=w),w&&g&&(i[d].defaultSelected=!0)}else{for(d=""+W(d),l=null,w=0;w<i.length;w++){if(i[w].value===d){i[w].selected=!0,g&&(i[w].defaultSelected=!0);return}l!==null||i[w].disabled||(l=i[w])}l!==null&&(l.selected=!0)}}function Cn(i,l,d){if(l!=null&&(l=""+W(l),l!==i.value&&(i.value=l),d==null)){i.defaultValue!==l&&(i.defaultValue=l);return}i.defaultValue=d!=null?""+W(d):""}function wa(i,l,d,g){if(l==null){if(g!=null){if(d!=null)throw Error(r(92));if(Z(g)){if(1<g.length)throw Error(r(93));g=g[0]}d=g}d==null&&(d=""),l=d}d=W(l),i.defaultValue=d,g=i.textContent,g===d&&g!==""&&g!==null&&(i.value=g),Me(i)}function jn(i,l){if(l){var d=i.firstChild;if(d&&d===i.lastChild&&d.nodeType===3){d.nodeValue=l;return}}i.textContent=l}var Y4=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 nN(i,l,d){var g=l.indexOf("--")===0;d==null||typeof d=="boolean"||d===""?g?i.setProperty(l,""):l==="float"?i.cssFloat="":i[l]="":g?i.setProperty(l,d):typeof d!="number"||d===0||Y4.has(l)?l==="float"?i.cssFloat=d:i[l]=(""+d).trim():i[l]=d+"px"}function sN(i,l,d){if(l!=null&&typeof l!="object")throw Error(r(62));if(i=i.style,d!=null){for(var g in d)!d.hasOwnProperty(g)||l!=null&&l.hasOwnProperty(g)||(g.indexOf("--")===0?i.setProperty(g,""):g==="float"?i.cssFloat="":i[g]="");for(var w in l)g=l[w],l.hasOwnProperty(w)&&d[w]!==g&&nN(i,w,g)}else for(var j in l)l.hasOwnProperty(j)&&nN(i,j,l[j])}function tv(i){if(i.indexOf("-")===-1)return!1;switch(i){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 X4=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"]]),Q4=/^[\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 If(i){return Q4.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function ja(){}var nv=null;function sv(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var hl=null,ml=null;function rN(i){var l=rr(i);if(l&&(i=l.stateNode)){var d=i[Tt]||null;e:switch(i=l.stateNode,l.type){case"input":if(Wt(i,d.value,d.defaultValue,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name),l=d.name,d.type==="radio"&&l!=null){for(d=i;d.parentNode;)d=d.parentNode;for(d=d.querySelectorAll('input[name="'+ft(""+l)+'"][type="radio"]'),l=0;l<d.length;l++){var g=d[l];if(g!==i&&g.form===i.form){var w=g[Tt]||null;if(!w)throw Error(r(90));Wt(g,w.value,w.defaultValue,w.defaultValue,w.checked,w.defaultChecked,w.type,w.name)}}for(l=0;l<d.length;l++)g=d[l],g.form===i.form&&We(g)}break e;case"textarea":Cn(i,d.value,d.defaultValue);break e;case"select":l=d.value,l!=null&&yt(i,!!d.multiple,l,!1)}}}var rv=!1;function aN(i,l,d){if(rv)return i(l,d);rv=!0;try{var g=i(l);return g}finally{if(rv=!1,(hl!==null||ml!==null)&&(yh(),hl&&(l=hl,i=ml,ml=hl=null,rN(l),i)))for(l=0;l<i.length;l++)rN(i[l])}}function su(i,l){var d=i.stateNode;if(d===null)return null;var g=d[Tt]||null;if(g===null)return null;d=g[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(g=!g.disabled)||(i=i.type,g=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!g;break e;default:i=!1}if(i)return null;if(d&&typeof d!="function")throw Error(r(231,l,typeof d));return d}var ka=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),av=!1;if(ka)try{var ru={};Object.defineProperty(ru,"passive",{get:function(){av=!0}}),window.addEventListener("test",ru,ru),window.removeEventListener("test",ru,ru)}catch{av=!1}var Ga=null,iv=null,_f=null;function iN(){if(_f)return _f;var i,l=iv,d=l.length,g,w="value"in Ga?Ga.value:Ga.textContent,j=w.length;for(i=0;i<d&&l[i]===w[i];i++);var M=d-i;for(g=1;g<=M&&l[d-g]===w[j-g];g++);return _f=w.slice(i,1<g?1-g:void 0)}function Of(i){var l=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&l===13&&(i=13)):i=l,i===10&&(i=13),32<=i||i===13?i:0}function $f(){return!0}function oN(){return!1}function Ts(i){function l(d,g,w,j,M){this._reactName=d,this._targetInst=w,this.type=g,this.nativeEvent=j,this.target=M,this.currentTarget=null;for(var F in i)i.hasOwnProperty(F)&&(d=i[F],this[F]=d?d(j):j[F]);return this.isDefaultPrevented=(j.defaultPrevented!=null?j.defaultPrevented:j.returnValue===!1)?$f:oN,this.isPropagationStopped=oN,this}return x(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var d=this.nativeEvent;d&&(d.preventDefault?d.preventDefault():typeof d.returnValue!="unknown"&&(d.returnValue=!1),this.isDefaultPrevented=$f)},stopPropagation:function(){var d=this.nativeEvent;d&&(d.stopPropagation?d.stopPropagation():typeof d.cancelBubble!="unknown"&&(d.cancelBubble=!0),this.isPropagationStopped=$f)},persist:function(){},isPersistent:$f}),l}var ro={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Lf=Ts(ro),au=x({},ro,{view:0,detail:0}),J4=Ts(au),ov,lv,iu,Pf=x({},au,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:uv,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==iu&&(iu&&i.type==="mousemove"?(ov=i.screenX-iu.screenX,lv=i.screenY-iu.screenY):lv=ov=0,iu=i),ov)},movementY:function(i){return"movementY"in i?i.movementY:lv}}),lN=Ts(Pf),ez=x({},Pf,{dataTransfer:0}),tz=Ts(ez),nz=x({},au,{relatedTarget:0}),cv=Ts(nz),sz=x({},ro,{animationName:0,elapsedTime:0,pseudoElement:0}),rz=Ts(sz),az=x({},ro,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),iz=Ts(az),oz=x({},ro,{data:0}),cN=Ts(oz),lz={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},cz={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"},uz={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function dz(i){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(i):(i=uz[i])?!!l[i]:!1}function uv(){return dz}var fz=x({},au,{key:function(i){if(i.key){var l=lz[i.key]||i.key;if(l!=="Unidentified")return l}return i.type==="keypress"?(i=Of(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?cz[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:uv,charCode:function(i){return i.type==="keypress"?Of(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Of(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),hz=Ts(fz),mz=x({},Pf,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),uN=Ts(mz),pz=x({},au,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:uv}),gz=Ts(pz),vz=x({},ro,{propertyName:0,elapsedTime:0,pseudoElement:0}),xz=Ts(vz),yz=x({},Pf,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),bz=Ts(yz),wz=x({},ro,{newState:0,oldState:0}),jz=Ts(wz),kz=[9,13,27,32],dv=ka&&"CompositionEvent"in window,ou=null;ka&&"documentMode"in document&&(ou=document.documentMode);var Nz=ka&&"TextEvent"in window&&!ou,dN=ka&&(!dv||ou&&8<ou&&11>=ou),fN=" ",hN=!1;function mN(i,l){switch(i){case"keyup":return kz.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function pN(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var pl=!1;function Sz(i,l){switch(i){case"compositionend":return pN(l);case"keypress":return l.which!==32?null:(hN=!0,fN);case"textInput":return i=l.data,i===fN&&hN?null:i;default:return null}}function Cz(i,l){if(pl)return i==="compositionend"||!dv&&mN(i,l)?(i=iN(),_f=iv=Ga=null,pl=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return dN&&l.locale!=="ko"?null:l.data;default:return null}}var Ez={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 gN(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l==="input"?!!Ez[i.type]:l==="textarea"}function vN(i,l,d,g){hl?ml?ml.push(g):ml=[g]:hl=g,l=Ch(l,"onChange"),0<l.length&&(d=new Lf("onChange","change",null,d,g),i.push({event:d,listeners:l}))}var lu=null,cu=null;function Az(i){JS(i,0)}function Df(i){var l=Cr(i);if(We(l))return i}function xN(i,l){if(i==="change")return l}var yN=!1;if(ka){var fv;if(ka){var hv="oninput"in document;if(!hv){var bN=document.createElement("div");bN.setAttribute("oninput","return;"),hv=typeof bN.oninput=="function"}fv=hv}else fv=!1;yN=fv&&(!document.documentMode||9<document.documentMode)}function wN(){lu&&(lu.detachEvent("onpropertychange",jN),cu=lu=null)}function jN(i){if(i.propertyName==="value"&&Df(cu)){var l=[];vN(l,cu,i,sv(i)),aN(Az,l)}}function Tz(i,l,d){i==="focusin"?(wN(),lu=l,cu=d,lu.attachEvent("onpropertychange",jN)):i==="focusout"&&wN()}function Mz(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Df(cu)}function Rz(i,l){if(i==="click")return Df(l)}function Iz(i,l){if(i==="input"||i==="change")return Df(l)}function _z(i,l){return i===l&&(i!==0||1/i===1/l)||i!==i&&l!==l}var Fs=typeof Object.is=="function"?Object.is:_z;function uu(i,l){if(Fs(i,l))return!0;if(typeof i!="object"||i===null||typeof l!="object"||l===null)return!1;var d=Object.keys(i),g=Object.keys(l);if(d.length!==g.length)return!1;for(g=0;g<d.length;g++){var w=d[g];if(!Ee.call(l,w)||!Fs(i[w],l[w]))return!1}return!0}function kN(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function NN(i,l){var d=kN(i);i=0;for(var g;d;){if(d.nodeType===3){if(g=i+d.textContent.length,i<=l&&g>=l)return{node:d,offset:l-i};i=g}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=kN(d)}}function SN(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?SN(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function CN(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=Qe(i.document);l instanceof i.HTMLIFrameElement;){try{var d=typeof l.contentWindow.location.href=="string"}catch{d=!1}if(d)i=l.contentWindow;else break;l=Qe(i.document)}return l}function mv(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var Oz=ka&&"documentMode"in document&&11>=document.documentMode,gl=null,pv=null,du=null,gv=!1;function EN(i,l,d){var g=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;gv||gl==null||gl!==Qe(g)||(g=gl,"selectionStart"in g&&mv(g)?g={start:g.selectionStart,end:g.selectionEnd}:(g=(g.ownerDocument&&g.ownerDocument.defaultView||window).getSelection(),g={anchorNode:g.anchorNode,anchorOffset:g.anchorOffset,focusNode:g.focusNode,focusOffset:g.focusOffset}),du&&uu(du,g)||(du=g,g=Ch(pv,"onSelect"),0<g.length&&(l=new Lf("onSelect","select",null,l,d),i.push({event:l,listeners:g}),l.target=gl)))}function ao(i,l){var d={};return d[i.toLowerCase()]=l.toLowerCase(),d["Webkit"+i]="webkit"+l,d["Moz"+i]="moz"+l,d}var vl={animationend:ao("Animation","AnimationEnd"),animationiteration:ao("Animation","AnimationIteration"),animationstart:ao("Animation","AnimationStart"),transitionrun:ao("Transition","TransitionRun"),transitionstart:ao("Transition","TransitionStart"),transitioncancel:ao("Transition","TransitionCancel"),transitionend:ao("Transition","TransitionEnd")},vv={},AN={};ka&&(AN=document.createElement("div").style,"AnimationEvent"in window||(delete vl.animationend.animation,delete vl.animationiteration.animation,delete vl.animationstart.animation),"TransitionEvent"in window||delete vl.transitionend.transition);function io(i){if(vv[i])return vv[i];if(!vl[i])return i;var l=vl[i],d;for(d in l)if(l.hasOwnProperty(d)&&d in AN)return vv[i]=l[d];return i}var TN=io("animationend"),MN=io("animationiteration"),RN=io("animationstart"),$z=io("transitionrun"),Lz=io("transitionstart"),Pz=io("transitioncancel"),IN=io("transitionend"),_N=new Map,xv="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(" ");xv.push("scrollEnd");function Ar(i,l){_N.set(i,l),ir(l,[i])}var zf=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var l=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(l))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},or=[],xl=0,yv=0;function Bf(){for(var i=xl,l=yv=xl=0;l<i;){var d=or[l];or[l++]=null;var g=or[l];or[l++]=null;var w=or[l];or[l++]=null;var j=or[l];if(or[l++]=null,g!==null&&w!==null){var M=g.pending;M===null?w.next=w:(w.next=M.next,M.next=w),g.pending=w}j!==0&&ON(d,w,j)}}function Uf(i,l,d,g){or[xl++]=i,or[xl++]=l,or[xl++]=d,or[xl++]=g,yv|=g,i.lanes|=g,i=i.alternate,i!==null&&(i.lanes|=g)}function bv(i,l,d,g){return Uf(i,l,d,g),Ff(i)}function oo(i,l){return Uf(i,null,null,l),Ff(i)}function ON(i,l,d){i.lanes|=d;var g=i.alternate;g!==null&&(g.lanes|=d);for(var w=!1,j=i.return;j!==null;)j.childLanes|=d,g=j.alternate,g!==null&&(g.childLanes|=d),j.tag===22&&(i=j.stateNode,i===null||i._visibility&1||(w=!0)),i=j,j=j.return;return i.tag===3?(j=i.stateNode,w&&l!==null&&(w=31-Ae(d),i=j.hiddenUpdates,g=i[w],g===null?i[w]=[l]:g.push(l),l.lane=d|536870912),j):null}function Ff(i){if(50<_u)throw _u=0,Tx=null,Error(r(185));for(var l=i.return;l!==null;)i=l,l=i.return;return i.tag===3?i.stateNode:null}var yl={};function Dz(i,l,d,g){this.tag=i,this.key=d,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=g,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Vs(i,l,d,g){return new Dz(i,l,d,g)}function wv(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Na(i,l){var d=i.alternate;return d===null?(d=Vs(i.tag,l,i.key,i.mode),d.elementType=i.elementType,d.type=i.type,d.stateNode=i.stateNode,d.alternate=i,i.alternate=d):(d.pendingProps=l,d.type=i.type,d.flags=0,d.subtreeFlags=0,d.deletions=null),d.flags=i.flags&65011712,d.childLanes=i.childLanes,d.lanes=i.lanes,d.child=i.child,d.memoizedProps=i.memoizedProps,d.memoizedState=i.memoizedState,d.updateQueue=i.updateQueue,l=i.dependencies,d.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},d.sibling=i.sibling,d.index=i.index,d.ref=i.ref,d.refCleanup=i.refCleanup,d}function $N(i,l){i.flags&=65011714;var d=i.alternate;return d===null?(i.childLanes=0,i.lanes=l,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=d.childLanes,i.lanes=d.lanes,i.child=d.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=d.memoizedProps,i.memoizedState=d.memoizedState,i.updateQueue=d.updateQueue,i.type=d.type,l=d.dependencies,i.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),i}function Vf(i,l,d,g,w,j){var M=0;if(g=i,typeof i=="function")wv(i)&&(M=1);else if(typeof i=="string")M=V3(i,d,Q.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case I:return i=Vs(31,d,l,w),i.elementType=I,i.lanes=j,i;case C:return lo(d.children,w,j,l);case E:M=8,w|=24;break;case A:return i=Vs(12,d,l,w|2),i.elementType=A,i.lanes=j,i;case T:return i=Vs(13,d,l,w),i.elementType=T,i.lanes=j,i;case R:return i=Vs(19,d,l,w),i.elementType=R,i.lanes=j,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case k:M=10;break e;case S:M=9;break e;case N:M=11;break e;case O:M=14;break e;case L:M=16,g=null;break e}M=29,d=Error(r(130,i===null?"null":typeof i,"")),g=null}return l=Vs(M,d,l,w),l.elementType=i,l.type=g,l.lanes=j,l}function lo(i,l,d,g){return i=Vs(7,i,g,l),i.lanes=d,i}function jv(i,l,d){return i=Vs(6,i,null,l),i.lanes=d,i}function LN(i){var l=Vs(18,null,null,0);return l.stateNode=i,l}function kv(i,l,d){return l=Vs(4,i.children!==null?i.children:[],i.key,l),l.lanes=d,l.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},l}var PN=new WeakMap;function lr(i,l){if(typeof i=="object"&&i!==null){var d=PN.get(i);return d!==void 0?d:(l={value:i,source:l,stack:Fe(l)},PN.set(i,l),l)}return{value:i,source:l,stack:Fe(l)}}var bl=[],wl=0,Hf=null,fu=0,cr=[],ur=0,Za=null,Hr=1,Wr="";function Sa(i,l){bl[wl++]=fu,bl[wl++]=Hf,Hf=i,fu=l}function DN(i,l,d){cr[ur++]=Hr,cr[ur++]=Wr,cr[ur++]=Za,Za=i;var g=Hr;i=Wr;var w=32-Ae(g)-1;g&=~(1<<w),d+=1;var j=32-Ae(l)+w;if(30<j){var M=w-w%5;j=(g&(1<<M)-1).toString(32),g>>=M,w-=M,Hr=1<<32-Ae(l)+w|d<<w|g,Wr=j+i}else Hr=1<<j|d<<w|g,Wr=i}function Nv(i){i.return!==null&&(Sa(i,1),DN(i,1,0))}function Sv(i){for(;i===Hf;)Hf=bl[--wl],bl[wl]=null,fu=bl[--wl],bl[wl]=null;for(;i===Za;)Za=cr[--ur],cr[ur]=null,Wr=cr[--ur],cr[ur]=null,Hr=cr[--ur],cr[ur]=null}function zN(i,l){cr[ur++]=Hr,cr[ur++]=Wr,cr[ur++]=Za,Hr=l.id,Wr=l.overflow,Za=i}var es=null,hn=null,zt=!1,Ya=null,dr=!1,Cv=Error(r(519));function Xa(i){var l=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw hu(lr(l,i)),Cv}function BN(i){var l=i.stateNode,d=i.type,g=i.memoizedProps;switch(l[Et]=i,l[Tt]=g,d){case"dialog":_t("cancel",l),_t("close",l);break;case"iframe":case"object":case"embed":_t("load",l);break;case"video":case"audio":for(d=0;d<$u.length;d++)_t($u[d],l);break;case"source":_t("error",l);break;case"img":case"image":case"link":_t("error",l),_t("load",l);break;case"details":_t("toggle",l);break;case"input":_t("invalid",l),Zt(l,g.value,g.defaultValue,g.checked,g.defaultChecked,g.type,g.name,!0);break;case"select":_t("invalid",l);break;case"textarea":_t("invalid",l),wa(l,g.value,g.defaultValue,g.children)}d=g.children,typeof d!="string"&&typeof d!="number"&&typeof d!="bigint"||l.textContent===""+d||g.suppressHydrationWarning===!0||sC(l.textContent,d)?(g.popover!=null&&(_t("beforetoggle",l),_t("toggle",l)),g.onScroll!=null&&_t("scroll",l),g.onScrollEnd!=null&&_t("scrollend",l),g.onClick!=null&&(l.onclick=ja),l=!0):l=!1,l||Xa(i,!0)}function UN(i){for(es=i.return;es;)switch(es.tag){case 5:case 31:case 13:dr=!1;return;case 27:case 3:dr=!0;return;default:es=es.return}}function jl(i){if(i!==es)return!1;if(!zt)return UN(i),zt=!0,!1;var l=i.tag,d;if((d=l!==3&&l!==27)&&((d=l===5)&&(d=i.type,d=!(d!=="form"&&d!=="button")||Hx(i.type,i.memoizedProps)),d=!d),d&&hn&&Xa(i),UN(i),l===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));hn=fC(i)}else if(l===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));hn=fC(i)}else l===27?(l=hn,di(i.type)?(i=Zx,Zx=null,hn=i):hn=l):hn=es?hr(i.stateNode.nextSibling):null;return!0}function co(){hn=es=null,zt=!1}function Ev(){var i=Ya;return i!==null&&(_s===null?_s=i:_s.push.apply(_s,i),Ya=null),i}function hu(i){Ya===null?Ya=[i]:Ya.push(i)}var Av=P(null),uo=null,Ca=null;function Qa(i,l,d){B(Av,l._currentValue),l._currentValue=d}function Ea(i){i._currentValue=Av.current,H(Av)}function Tv(i,l,d){for(;i!==null;){var g=i.alternate;if((i.childLanes&l)!==l?(i.childLanes|=l,g!==null&&(g.childLanes|=l)):g!==null&&(g.childLanes&l)!==l&&(g.childLanes|=l),i===d)break;i=i.return}}function Mv(i,l,d,g){var w=i.child;for(w!==null&&(w.return=i);w!==null;){var j=w.dependencies;if(j!==null){var M=w.child;j=j.firstContext;e:for(;j!==null;){var F=j;j=w;for(var J=0;J<l.length;J++)if(F.context===l[J]){j.lanes|=d,F=j.alternate,F!==null&&(F.lanes|=d),Tv(j.return,d,i),g||(M=null);break e}j=F.next}}else if(w.tag===18){if(M=w.return,M===null)throw Error(r(341));M.lanes|=d,j=M.alternate,j!==null&&(j.lanes|=d),Tv(M,d,i),M=null}else M=w.child;if(M!==null)M.return=w;else for(M=w;M!==null;){if(M===i){M=null;break}if(w=M.sibling,w!==null){w.return=M.return,M=w;break}M=M.return}w=M}}function kl(i,l,d,g){i=null;for(var w=l,j=!1;w!==null;){if(!j){if((w.flags&524288)!==0)j=!0;else if((w.flags&262144)!==0)break}if(w.tag===10){var M=w.alternate;if(M===null)throw Error(r(387));if(M=M.memoizedProps,M!==null){var F=w.type;Fs(w.pendingProps.value,M.value)||(i!==null?i.push(F):i=[F])}}else if(w===X.current){if(M=w.alternate,M===null)throw Error(r(387));M.memoizedState.memoizedState!==w.memoizedState.memoizedState&&(i!==null?i.push(Bu):i=[Bu])}w=w.return}i!==null&&Mv(l,i,d,g),l.flags|=262144}function Wf(i){for(i=i.firstContext;i!==null;){if(!Fs(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function fo(i){uo=i,Ca=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function ts(i){return FN(uo,i)}function qf(i,l){return uo===null&&fo(i),FN(i,l)}function FN(i,l){var d=l._currentValue;if(l={context:l,memoizedValue:d,next:null},Ca===null){if(i===null)throw Error(r(308));Ca=l,i.dependencies={lanes:0,firstContext:l},i.flags|=524288}else Ca=Ca.next=l;return d}var zz=typeof AbortController<"u"?AbortController:function(){var i=[],l=this.signal={aborted:!1,addEventListener:function(d,g){i.push(g)}};this.abort=function(){l.aborted=!0,i.forEach(function(d){return d()})}},Bz=e.unstable_scheduleCallback,Uz=e.unstable_NormalPriority,zn={$$typeof:k,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Rv(){return{controller:new zz,data:new Map,refCount:0}}function mu(i){i.refCount--,i.refCount===0&&Bz(Uz,function(){i.controller.abort()})}var pu=null,Iv=0,Nl=0,Sl=null;function Fz(i,l){if(pu===null){var d=pu=[];Iv=0,Nl=$x(),Sl={status:"pending",value:void 0,then:function(g){d.push(g)}}}return Iv++,l.then(VN,VN),l}function VN(){if(--Iv===0&&pu!==null){Sl!==null&&(Sl.status="fulfilled");var i=pu;pu=null,Nl=0,Sl=null;for(var l=0;l<i.length;l++)(0,i[l])()}}function Vz(i,l){var d=[],g={status:"pending",value:null,reason:null,then:function(w){d.push(w)}};return i.then(function(){g.status="fulfilled",g.value=l;for(var w=0;w<d.length;w++)(0,d[w])(l)},function(w){for(g.status="rejected",g.reason=w,w=0;w<d.length;w++)(0,d[w])(void 0)}),g}var HN=$.S;$.S=function(i,l){ES=ze(),typeof l=="object"&&l!==null&&typeof l.then=="function"&&Fz(i,l),HN!==null&&HN(i,l)};var ho=P(null);function _v(){var i=ho.current;return i!==null?i:an.pooledCache}function Kf(i,l){l===null?B(ho,ho.current):B(ho,l.pool)}function WN(){var i=_v();return i===null?null:{parent:zn._currentValue,pool:i}}var Cl=Error(r(460)),Ov=Error(r(474)),Gf=Error(r(542)),Zf={then:function(){}};function qN(i){return i=i.status,i==="fulfilled"||i==="rejected"}function KN(i,l,d){switch(d=i[d],d===void 0?i.push(l):d!==l&&(l.then(ja,ja),l=d),l.status){case"fulfilled":return l.value;case"rejected":throw i=l.reason,ZN(i),i;default:if(typeof l.status=="string")l.then(ja,ja);else{if(i=an,i!==null&&100<i.shellSuspendCounter)throw Error(r(482));i=l,i.status="pending",i.then(function(g){if(l.status==="pending"){var w=l;w.status="fulfilled",w.value=g}},function(g){if(l.status==="pending"){var w=l;w.status="rejected",w.reason=g}})}switch(l.status){case"fulfilled":return l.value;case"rejected":throw i=l.reason,ZN(i),i}throw po=l,Cl}}function mo(i){try{var l=i._init;return l(i._payload)}catch(d){throw d!==null&&typeof d=="object"&&typeof d.then=="function"?(po=d,Cl):d}}var po=null;function GN(){if(po===null)throw Error(r(459));var i=po;return po=null,i}function ZN(i){if(i===Cl||i===Gf)throw Error(r(483))}var El=null,gu=0;function Yf(i){var l=gu;return gu+=1,El===null&&(El=[]),KN(El,i,l)}function vu(i,l){l=l.props.ref,i.ref=l!==void 0?l:null}function Xf(i,l){throw l.$$typeof===v?Error(r(525)):(i=Object.prototype.toString.call(l),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":i)))}function YN(i){function l(le,se){if(i){var fe=le.deletions;fe===null?(le.deletions=[se],le.flags|=16):fe.push(se)}}function d(le,se){if(!i)return null;for(;se!==null;)l(le,se),se=se.sibling;return null}function g(le){for(var se=new Map;le!==null;)le.key!==null?se.set(le.key,le):se.set(le.index,le),le=le.sibling;return se}function w(le,se){return le=Na(le,se),le.index=0,le.sibling=null,le}function j(le,se,fe){return le.index=fe,i?(fe=le.alternate,fe!==null?(fe=fe.index,fe<se?(le.flags|=67108866,se):fe):(le.flags|=67108866,se)):(le.flags|=1048576,se)}function M(le){return i&&le.alternate===null&&(le.flags|=67108866),le}function F(le,se,fe,Se){return se===null||se.tag!==6?(se=jv(fe,le.mode,Se),se.return=le,se):(se=w(se,fe),se.return=le,se)}function J(le,se,fe,Se){var it=fe.type;return it===C?we(le,se,fe.props.children,Se,fe.key):se!==null&&(se.elementType===it||typeof it=="object"&&it!==null&&it.$$typeof===L&&mo(it)===se.type)?(se=w(se,fe.props),vu(se,fe),se.return=le,se):(se=Vf(fe.type,fe.key,fe.props,null,le.mode,Se),vu(se,fe),se.return=le,se)}function me(le,se,fe,Se){return se===null||se.tag!==4||se.stateNode.containerInfo!==fe.containerInfo||se.stateNode.implementation!==fe.implementation?(se=kv(fe,le.mode,Se),se.return=le,se):(se=w(se,fe.children||[]),se.return=le,se)}function we(le,se,fe,Se,it){return se===null||se.tag!==7?(se=lo(fe,le.mode,Se,it),se.return=le,se):(se=w(se,fe),se.return=le,se)}function Ce(le,se,fe){if(typeof se=="string"&&se!==""||typeof se=="number"||typeof se=="bigint")return se=jv(""+se,le.mode,fe),se.return=le,se;if(typeof se=="object"&&se!==null){switch(se.$$typeof){case y:return fe=Vf(se.type,se.key,se.props,null,le.mode,fe),vu(fe,se),fe.return=le,fe;case b:return se=kv(se,le.mode,fe),se.return=le,se;case L:return se=mo(se),Ce(le,se,fe)}if(Z(se)||U(se))return se=lo(se,le.mode,fe,null),se.return=le,se;if(typeof se.then=="function")return Ce(le,Yf(se),fe);if(se.$$typeof===k)return Ce(le,qf(le,se),fe);Xf(le,se)}return null}function ge(le,se,fe,Se){var it=se!==null?se.key:null;if(typeof fe=="string"&&fe!==""||typeof fe=="number"||typeof fe=="bigint")return it!==null?null:F(le,se,""+fe,Se);if(typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case y:return fe.key===it?J(le,se,fe,Se):null;case b:return fe.key===it?me(le,se,fe,Se):null;case L:return fe=mo(fe),ge(le,se,fe,Se)}if(Z(fe)||U(fe))return it!==null?null:we(le,se,fe,Se,null);if(typeof fe.then=="function")return ge(le,se,Yf(fe),Se);if(fe.$$typeof===k)return ge(le,se,qf(le,fe),Se);Xf(le,fe)}return null}function ye(le,se,fe,Se,it){if(typeof Se=="string"&&Se!==""||typeof Se=="number"||typeof Se=="bigint")return le=le.get(fe)||null,F(se,le,""+Se,it);if(typeof Se=="object"&&Se!==null){switch(Se.$$typeof){case y:return le=le.get(Se.key===null?fe:Se.key)||null,J(se,le,Se,it);case b:return le=le.get(Se.key===null?fe:Se.key)||null,me(se,le,Se,it);case L:return Se=mo(Se),ye(le,se,fe,Se,it)}if(Z(Se)||U(Se))return le=le.get(fe)||null,we(se,le,Se,it,null);if(typeof Se.then=="function")return ye(le,se,fe,Yf(Se),it);if(Se.$$typeof===k)return ye(le,se,fe,qf(se,Se),it);Xf(se,Se)}return null}function Ze(le,se,fe,Se){for(var it=null,qt=null,Je=se,Nt=se=0,Dt=null;Je!==null&&Nt<fe.length;Nt++){Je.index>Nt?(Dt=Je,Je=null):Dt=Je.sibling;var Kt=ge(le,Je,fe[Nt],Se);if(Kt===null){Je===null&&(Je=Dt);break}i&&Je&&Kt.alternate===null&&l(le,Je),se=j(Kt,se,Nt),qt===null?it=Kt:qt.sibling=Kt,qt=Kt,Je=Dt}if(Nt===fe.length)return d(le,Je),zt&&Sa(le,Nt),it;if(Je===null){for(;Nt<fe.length;Nt++)Je=Ce(le,fe[Nt],Se),Je!==null&&(se=j(Je,se,Nt),qt===null?it=Je:qt.sibling=Je,qt=Je);return zt&&Sa(le,Nt),it}for(Je=g(Je);Nt<fe.length;Nt++)Dt=ye(Je,le,Nt,fe[Nt],Se),Dt!==null&&(i&&Dt.alternate!==null&&Je.delete(Dt.key===null?Nt:Dt.key),se=j(Dt,se,Nt),qt===null?it=Dt:qt.sibling=Dt,qt=Dt);return i&&Je.forEach(function(gi){return l(le,gi)}),zt&&Sa(le,Nt),it}function ct(le,se,fe,Se){if(fe==null)throw Error(r(151));for(var it=null,qt=null,Je=se,Nt=se=0,Dt=null,Kt=fe.next();Je!==null&&!Kt.done;Nt++,Kt=fe.next()){Je.index>Nt?(Dt=Je,Je=null):Dt=Je.sibling;var gi=ge(le,Je,Kt.value,Se);if(gi===null){Je===null&&(Je=Dt);break}i&&Je&&gi.alternate===null&&l(le,Je),se=j(gi,se,Nt),qt===null?it=gi:qt.sibling=gi,qt=gi,Je=Dt}if(Kt.done)return d(le,Je),zt&&Sa(le,Nt),it;if(Je===null){for(;!Kt.done;Nt++,Kt=fe.next())Kt=Ce(le,Kt.value,Se),Kt!==null&&(se=j(Kt,se,Nt),qt===null?it=Kt:qt.sibling=Kt,qt=Kt);return zt&&Sa(le,Nt),it}for(Je=g(Je);!Kt.done;Nt++,Kt=fe.next())Kt=ye(Je,le,Nt,Kt.value,Se),Kt!==null&&(i&&Kt.alternate!==null&&Je.delete(Kt.key===null?Nt:Kt.key),se=j(Kt,se,Nt),qt===null?it=Kt:qt.sibling=Kt,qt=Kt);return i&&Je.forEach(function(e6){return l(le,e6)}),zt&&Sa(le,Nt),it}function rn(le,se,fe,Se){if(typeof fe=="object"&&fe!==null&&fe.type===C&&fe.key===null&&(fe=fe.props.children),typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case y:e:{for(var it=fe.key;se!==null;){if(se.key===it){if(it=fe.type,it===C){if(se.tag===7){d(le,se.sibling),Se=w(se,fe.props.children),Se.return=le,le=Se;break e}}else if(se.elementType===it||typeof it=="object"&&it!==null&&it.$$typeof===L&&mo(it)===se.type){d(le,se.sibling),Se=w(se,fe.props),vu(Se,fe),Se.return=le,le=Se;break e}d(le,se);break}else l(le,se);se=se.sibling}fe.type===C?(Se=lo(fe.props.children,le.mode,Se,fe.key),Se.return=le,le=Se):(Se=Vf(fe.type,fe.key,fe.props,null,le.mode,Se),vu(Se,fe),Se.return=le,le=Se)}return M(le);case b:e:{for(it=fe.key;se!==null;){if(se.key===it)if(se.tag===4&&se.stateNode.containerInfo===fe.containerInfo&&se.stateNode.implementation===fe.implementation){d(le,se.sibling),Se=w(se,fe.children||[]),Se.return=le,le=Se;break e}else{d(le,se);break}else l(le,se);se=se.sibling}Se=kv(fe,le.mode,Se),Se.return=le,le=Se}return M(le);case L:return fe=mo(fe),rn(le,se,fe,Se)}if(Z(fe))return Ze(le,se,fe,Se);if(U(fe)){if(it=U(fe),typeof it!="function")throw Error(r(150));return fe=it.call(fe),ct(le,se,fe,Se)}if(typeof fe.then=="function")return rn(le,se,Yf(fe),Se);if(fe.$$typeof===k)return rn(le,se,qf(le,fe),Se);Xf(le,fe)}return typeof fe=="string"&&fe!==""||typeof fe=="number"||typeof fe=="bigint"?(fe=""+fe,se!==null&&se.tag===6?(d(le,se.sibling),Se=w(se,fe),Se.return=le,le=Se):(d(le,se),Se=jv(fe,le.mode,Se),Se.return=le,le=Se),M(le)):d(le,se)}return function(le,se,fe,Se){try{gu=0;var it=rn(le,se,fe,Se);return El=null,it}catch(Je){if(Je===Cl||Je===Gf)throw Je;var qt=Vs(29,Je,null,le.mode);return qt.lanes=Se,qt.return=le,qt}}}var go=YN(!0),XN=YN(!1),Ja=!1;function $v(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Lv(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ei(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function ti(i,l,d){var g=i.updateQueue;if(g===null)return null;if(g=g.shared,(Yt&2)!==0){var w=g.pending;return w===null?l.next=l:(l.next=w.next,w.next=l),g.pending=l,l=Ff(i),ON(i,null,d),l}return Uf(i,g,l,d),Ff(i)}function xu(i,l,d){if(l=l.updateQueue,l!==null&&(l=l.shared,(d&4194048)!==0)){var g=l.lanes;g&=i.pendingLanes,d|=g,l.lanes=d,Re(i,d)}}function Pv(i,l){var d=i.updateQueue,g=i.alternate;if(g!==null&&(g=g.updateQueue,d===g)){var w=null,j=null;if(d=d.firstBaseUpdate,d!==null){do{var M={lane:d.lane,tag:d.tag,payload:d.payload,callback:null,next:null};j===null?w=j=M:j=j.next=M,d=d.next}while(d!==null);j===null?w=j=l:j=j.next=l}else w=j=l;d={baseState:g.baseState,firstBaseUpdate:w,lastBaseUpdate:j,shared:g.shared,callbacks:g.callbacks},i.updateQueue=d;return}i=d.lastBaseUpdate,i===null?d.firstBaseUpdate=l:i.next=l,d.lastBaseUpdate=l}var Dv=!1;function yu(){if(Dv){var i=Sl;if(i!==null)throw i}}function bu(i,l,d,g){Dv=!1;var w=i.updateQueue;Ja=!1;var j=w.firstBaseUpdate,M=w.lastBaseUpdate,F=w.shared.pending;if(F!==null){w.shared.pending=null;var J=F,me=J.next;J.next=null,M===null?j=me:M.next=me,M=J;var we=i.alternate;we!==null&&(we=we.updateQueue,F=we.lastBaseUpdate,F!==M&&(F===null?we.firstBaseUpdate=me:F.next=me,we.lastBaseUpdate=J))}if(j!==null){var Ce=w.baseState;M=0,we=me=J=null,F=j;do{var ge=F.lane&-536870913,ye=ge!==F.lane;if(ye?(Pt&ge)===ge:(g&ge)===ge){ge!==0&&ge===Nl&&(Dv=!0),we!==null&&(we=we.next={lane:0,tag:F.tag,payload:F.payload,callback:null,next:null});e:{var Ze=i,ct=F;ge=l;var rn=d;switch(ct.tag){case 1:if(Ze=ct.payload,typeof Ze=="function"){Ce=Ze.call(rn,Ce,ge);break e}Ce=Ze;break e;case 3:Ze.flags=Ze.flags&-65537|128;case 0:if(Ze=ct.payload,ge=typeof Ze=="function"?Ze.call(rn,Ce,ge):Ze,ge==null)break e;Ce=x({},Ce,ge);break e;case 2:Ja=!0}}ge=F.callback,ge!==null&&(i.flags|=64,ye&&(i.flags|=8192),ye=w.callbacks,ye===null?w.callbacks=[ge]:ye.push(ge))}else ye={lane:ge,tag:F.tag,payload:F.payload,callback:F.callback,next:null},we===null?(me=we=ye,J=Ce):we=we.next=ye,M|=ge;if(F=F.next,F===null){if(F=w.shared.pending,F===null)break;ye=F,F=ye.next,ye.next=null,w.lastBaseUpdate=ye,w.shared.pending=null}}while(!0);we===null&&(J=Ce),w.baseState=J,w.firstBaseUpdate=me,w.lastBaseUpdate=we,j===null&&(w.shared.lanes=0),ii|=M,i.lanes=M,i.memoizedState=Ce}}function QN(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function JN(i,l){var d=i.callbacks;if(d!==null)for(i.callbacks=null,i=0;i<d.length;i++)QN(d[i],l)}var Al=P(null),Qf=P(0);function e1(i,l){i=La,B(Qf,i),B(Al,l),La=i|l.baseLanes}function zv(){B(Qf,La),B(Al,Al.current)}function Bv(){La=Qf.current,H(Al),H(Qf)}var Hs=P(null),fr=null;function ni(i){var l=i.alternate;B(Ln,Ln.current&1),B(Hs,i),fr===null&&(l===null||Al.current!==null||l.memoizedState!==null)&&(fr=i)}function Uv(i){B(Ln,Ln.current),B(Hs,i),fr===null&&(fr=i)}function t1(i){i.tag===22?(B(Ln,Ln.current),B(Hs,i),fr===null&&(fr=i)):si()}function si(){B(Ln,Ln.current),B(Hs,Hs.current)}function Ws(i){H(Hs),fr===i&&(fr=null),H(Ln)}var Ln=P(0);function Jf(i){for(var l=i;l!==null;){if(l.tag===13){var d=l.memoizedState;if(d!==null&&(d=d.dehydrated,d===null||Kx(d)||Gx(d)))return l}else if(l.tag===19&&(l.memoizedProps.revealOrder==="forwards"||l.memoizedProps.revealOrder==="backwards"||l.memoizedProps.revealOrder==="unstable_legacy-backwards"||l.memoizedProps.revealOrder==="together")){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===i)break;for(;l.sibling===null;){if(l.return===null||l.return===i)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var Aa=0,bt=null,nn=null,Bn=null,eh=!1,Tl=!1,vo=!1,th=0,wu=0,Ml=null,Hz=0;function Mn(){throw Error(r(321))}function Fv(i,l){if(l===null)return!1;for(var d=0;d<l.length&&d<i.length;d++)if(!Fs(i[d],l[d]))return!1;return!0}function Vv(i,l,d,g,w,j){return Aa=j,bt=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,$.H=i===null||i.memoizedState===null?D1:rx,vo=!1,j=d(g,w),vo=!1,Tl&&(j=s1(l,d,g,w)),n1(i),j}function n1(i){$.H=Nu;var l=nn!==null&&nn.next!==null;if(Aa=0,Bn=nn=bt=null,eh=!1,wu=0,Ml=null,l)throw Error(r(300));i===null||Un||(i=i.dependencies,i!==null&&Wf(i)&&(Un=!0))}function s1(i,l,d,g){bt=i;var w=0;do{if(Tl&&(Ml=null),wu=0,Tl=!1,25<=w)throw Error(r(301));if(w+=1,Bn=nn=null,i.updateQueue!=null){var j=i.updateQueue;j.lastEffect=null,j.events=null,j.stores=null,j.memoCache!=null&&(j.memoCache.index=0)}$.H=z1,j=l(d,g)}while(Tl);return j}function Wz(){var i=$.H,l=i.useState()[0];return l=typeof l.then=="function"?ju(l):l,i=i.useState()[0],(nn!==null?nn.memoizedState:null)!==i&&(bt.flags|=1024),l}function Hv(){var i=th!==0;return th=0,i}function Wv(i,l,d){l.updateQueue=i.updateQueue,l.flags&=-2053,i.lanes&=~d}function qv(i){if(eh){for(i=i.memoizedState;i!==null;){var l=i.queue;l!==null&&(l.pending=null),i=i.next}eh=!1}Aa=0,Bn=nn=bt=null,Tl=!1,wu=th=0,Ml=null}function vs(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Bn===null?bt.memoizedState=Bn=i:Bn=Bn.next=i,Bn}function Pn(){if(nn===null){var i=bt.alternate;i=i!==null?i.memoizedState:null}else i=nn.next;var l=Bn===null?bt.memoizedState:Bn.next;if(l!==null)Bn=l,nn=i;else{if(i===null)throw bt.alternate===null?Error(r(467)):Error(r(310));nn=i,i={memoizedState:nn.memoizedState,baseState:nn.baseState,baseQueue:nn.baseQueue,queue:nn.queue,next:null},Bn===null?bt.memoizedState=Bn=i:Bn=Bn.next=i}return Bn}function nh(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ju(i){var l=wu;return wu+=1,Ml===null&&(Ml=[]),i=KN(Ml,i,l),l=bt,(Bn===null?l.memoizedState:Bn.next)===null&&(l=l.alternate,$.H=l===null||l.memoizedState===null?D1:rx),i}function sh(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return ju(i);if(i.$$typeof===k)return ts(i)}throw Error(r(438,String(i)))}function Kv(i){var l=null,d=bt.updateQueue;if(d!==null&&(l=d.memoCache),l==null){var g=bt.alternate;g!==null&&(g=g.updateQueue,g!==null&&(g=g.memoCache,g!=null&&(l={data:g.data.map(function(w){return w.slice()}),index:0})))}if(l==null&&(l={data:[],index:0}),d===null&&(d=nh(),bt.updateQueue=d),d.memoCache=l,d=l.data[l.index],d===void 0)for(d=l.data[l.index]=Array(i),g=0;g<i;g++)d[g]=z;return l.index++,d}function Ta(i,l){return typeof l=="function"?l(i):l}function rh(i){var l=Pn();return Gv(l,nn,i)}function Gv(i,l,d){var g=i.queue;if(g===null)throw Error(r(311));g.lastRenderedReducer=d;var w=i.baseQueue,j=g.pending;if(j!==null){if(w!==null){var M=w.next;w.next=j.next,j.next=M}l.baseQueue=w=j,g.pending=null}if(j=i.baseState,w===null)i.memoizedState=j;else{l=w.next;var F=M=null,J=null,me=l,we=!1;do{var Ce=me.lane&-536870913;if(Ce!==me.lane?(Pt&Ce)===Ce:(Aa&Ce)===Ce){var ge=me.revertLane;if(ge===0)J!==null&&(J=J.next={lane:0,revertLane:0,gesture:null,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null}),Ce===Nl&&(we=!0);else if((Aa&ge)===ge){me=me.next,ge===Nl&&(we=!0);continue}else Ce={lane:0,revertLane:me.revertLane,gesture:null,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null},J===null?(F=J=Ce,M=j):J=J.next=Ce,bt.lanes|=ge,ii|=ge;Ce=me.action,vo&&d(j,Ce),j=me.hasEagerState?me.eagerState:d(j,Ce)}else ge={lane:Ce,revertLane:me.revertLane,gesture:me.gesture,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null},J===null?(F=J=ge,M=j):J=J.next=ge,bt.lanes|=Ce,ii|=Ce;me=me.next}while(me!==null&&me!==l);if(J===null?M=j:J.next=F,!Fs(j,i.memoizedState)&&(Un=!0,we&&(d=Sl,d!==null)))throw d;i.memoizedState=j,i.baseState=M,i.baseQueue=J,g.lastRenderedState=j}return w===null&&(g.lanes=0),[i.memoizedState,g.dispatch]}function Zv(i){var l=Pn(),d=l.queue;if(d===null)throw Error(r(311));d.lastRenderedReducer=i;var g=d.dispatch,w=d.pending,j=l.memoizedState;if(w!==null){d.pending=null;var M=w=w.next;do j=i(j,M.action),M=M.next;while(M!==w);Fs(j,l.memoizedState)||(Un=!0),l.memoizedState=j,l.baseQueue===null&&(l.baseState=j),d.lastRenderedState=j}return[j,g]}function r1(i,l,d){var g=bt,w=Pn(),j=zt;if(j){if(d===void 0)throw Error(r(407));d=d()}else d=l();var M=!Fs((nn||w).memoizedState,d);if(M&&(w.memoizedState=d,Un=!0),w=w.queue,Qv(o1.bind(null,g,w,i),[i]),w.getSnapshot!==l||M||Bn!==null&&Bn.memoizedState.tag&1){if(g.flags|=2048,Rl(9,{destroy:void 0},i1.bind(null,g,w,d,l),null),an===null)throw Error(r(349));j||(Aa&127)!==0||a1(g,l,d)}return d}function a1(i,l,d){i.flags|=16384,i={getSnapshot:l,value:d},l=bt.updateQueue,l===null?(l=nh(),bt.updateQueue=l,l.stores=[i]):(d=l.stores,d===null?l.stores=[i]:d.push(i))}function i1(i,l,d,g){l.value=d,l.getSnapshot=g,l1(l)&&c1(i)}function o1(i,l,d){return d(function(){l1(l)&&c1(i)})}function l1(i){var l=i.getSnapshot;i=i.value;try{var d=l();return!Fs(i,d)}catch{return!0}}function c1(i){var l=oo(i,2);l!==null&&Os(l,i,2)}function Yv(i){var l=vs();if(typeof i=="function"){var d=i;if(i=d(),vo){ce(!0);try{d()}finally{ce(!1)}}}return l.memoizedState=l.baseState=i,l.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ta,lastRenderedState:i},l}function u1(i,l,d,g){return i.baseState=d,Gv(i,nn,typeof g=="function"?g:Ta)}function qz(i,l,d,g,w){if(oh(i))throw Error(r(485));if(i=l.action,i!==null){var j={payload:w,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(M){j.listeners.push(M)}};$.T!==null?d(!0):j.isTransition=!1,g(j),d=l.pending,d===null?(j.next=l.pending=j,d1(l,j)):(j.next=d.next,l.pending=d.next=j)}}function d1(i,l){var d=l.action,g=l.payload,w=i.state;if(l.isTransition){var j=$.T,M={};$.T=M;try{var F=d(w,g),J=$.S;J!==null&&J(M,F),f1(i,l,F)}catch(me){Xv(i,l,me)}finally{j!==null&&M.types!==null&&(j.types=M.types),$.T=j}}else try{j=d(w,g),f1(i,l,j)}catch(me){Xv(i,l,me)}}function f1(i,l,d){d!==null&&typeof d=="object"&&typeof d.then=="function"?d.then(function(g){h1(i,l,g)},function(g){return Xv(i,l,g)}):h1(i,l,d)}function h1(i,l,d){l.status="fulfilled",l.value=d,m1(l),i.state=d,l=i.pending,l!==null&&(d=l.next,d===l?i.pending=null:(d=d.next,l.next=d,d1(i,d)))}function Xv(i,l,d){var g=i.pending;if(i.pending=null,g!==null){g=g.next;do l.status="rejected",l.reason=d,m1(l),l=l.next;while(l!==g)}i.action=null}function m1(i){i=i.listeners;for(var l=0;l<i.length;l++)(0,i[l])()}function p1(i,l){return l}function g1(i,l){if(zt){var d=an.formState;if(d!==null){e:{var g=bt;if(zt){if(hn){t:{for(var w=hn,j=dr;w.nodeType!==8;){if(!j){w=null;break t}if(w=hr(w.nextSibling),w===null){w=null;break t}}j=w.data,w=j==="F!"||j==="F"?w:null}if(w){hn=hr(w.nextSibling),g=w.data==="F!";break e}}Xa(g)}g=!1}g&&(l=d[0])}}return d=vs(),d.memoizedState=d.baseState=l,g={pending:null,lanes:0,dispatch:null,lastRenderedReducer:p1,lastRenderedState:l},d.queue=g,d=$1.bind(null,bt,g),g.dispatch=d,g=Yv(!1),j=sx.bind(null,bt,!1,g.queue),g=vs(),w={state:l,dispatch:null,action:i,pending:null},g.queue=w,d=qz.bind(null,bt,w,j,d),w.dispatch=d,g.memoizedState=i,[l,d,!1]}function v1(i){var l=Pn();return x1(l,nn,i)}function x1(i,l,d){if(l=Gv(i,l,p1)[0],i=rh(Ta)[0],typeof l=="object"&&l!==null&&typeof l.then=="function")try{var g=ju(l)}catch(M){throw M===Cl?Gf:M}else g=l;l=Pn();var w=l.queue,j=w.dispatch;return d!==l.memoizedState&&(bt.flags|=2048,Rl(9,{destroy:void 0},Kz.bind(null,w,d),null)),[g,j,i]}function Kz(i,l){i.action=l}function y1(i){var l=Pn(),d=nn;if(d!==null)return x1(l,d,i);Pn(),l=l.memoizedState,d=Pn();var g=d.queue.dispatch;return d.memoizedState=i,[l,g,!1]}function Rl(i,l,d,g){return i={tag:i,create:d,deps:g,inst:l,next:null},l=bt.updateQueue,l===null&&(l=nh(),bt.updateQueue=l),d=l.lastEffect,d===null?l.lastEffect=i.next=i:(g=d.next,d.next=i,i.next=g,l.lastEffect=i),i}function b1(){return Pn().memoizedState}function ah(i,l,d,g){var w=vs();bt.flags|=i,w.memoizedState=Rl(1|l,{destroy:void 0},d,g===void 0?null:g)}function ih(i,l,d,g){var w=Pn();g=g===void 0?null:g;var j=w.memoizedState.inst;nn!==null&&g!==null&&Fv(g,nn.memoizedState.deps)?w.memoizedState=Rl(l,j,d,g):(bt.flags|=i,w.memoizedState=Rl(1|l,j,d,g))}function w1(i,l){ah(8390656,8,i,l)}function Qv(i,l){ih(2048,8,i,l)}function Gz(i){bt.flags|=4;var l=bt.updateQueue;if(l===null)l=nh(),bt.updateQueue=l,l.events=[i];else{var d=l.events;d===null?l.events=[i]:d.push(i)}}function j1(i){var l=Pn().memoizedState;return Gz({ref:l,nextImpl:i}),function(){if((Yt&2)!==0)throw Error(r(440));return l.impl.apply(void 0,arguments)}}function k1(i,l){return ih(4,2,i,l)}function N1(i,l){return ih(4,4,i,l)}function S1(i,l){if(typeof l=="function"){i=i();var d=l(i);return function(){typeof d=="function"?d():l(null)}}if(l!=null)return i=i(),l.current=i,function(){l.current=null}}function C1(i,l,d){d=d!=null?d.concat([i]):null,ih(4,4,S1.bind(null,l,i),d)}function Jv(){}function E1(i,l){var d=Pn();l=l===void 0?null:l;var g=d.memoizedState;return l!==null&&Fv(l,g[1])?g[0]:(d.memoizedState=[i,l],i)}function A1(i,l){var d=Pn();l=l===void 0?null:l;var g=d.memoizedState;if(l!==null&&Fv(l,g[1]))return g[0];if(g=i(),vo){ce(!0);try{i()}finally{ce(!1)}}return d.memoizedState=[g,l],g}function ex(i,l,d){return d===void 0||(Aa&1073741824)!==0&&(Pt&261930)===0?i.memoizedState=l:(i.memoizedState=d,i=TS(),bt.lanes|=i,ii|=i,d)}function T1(i,l,d,g){return Fs(d,l)?d:Al.current!==null?(i=ex(i,d,g),Fs(i,l)||(Un=!0),i):(Aa&42)===0||(Aa&1073741824)!==0&&(Pt&261930)===0?(Un=!0,i.memoizedState=d):(i=TS(),bt.lanes|=i,ii|=i,l)}function M1(i,l,d,g,w){var j=G.p;G.p=j!==0&&8>j?j:8;var M=$.T,F={};$.T=F,sx(i,!1,l,d);try{var J=w(),me=$.S;if(me!==null&&me(F,J),J!==null&&typeof J=="object"&&typeof J.then=="function"){var we=Vz(J,g);ku(i,l,we,Gs(i))}else ku(i,l,g,Gs(i))}catch(Ce){ku(i,l,{then:function(){},status:"rejected",reason:Ce},Gs())}finally{G.p=j,M!==null&&F.types!==null&&(M.types=F.types),$.T=M}}function Zz(){}function tx(i,l,d,g){if(i.tag!==5)throw Error(r(476));var w=R1(i).queue;M1(i,w,l,V,d===null?Zz:function(){return I1(i),d(g)})}function R1(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:V,baseState:V,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ta,lastRenderedState:V},next:null};var d={};return l.next={memoizedState:d,baseState:d,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ta,lastRenderedState:d},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function I1(i){var l=R1(i);l.next===null&&(l=i.alternate.memoizedState),ku(i,l.next.queue,{},Gs())}function nx(){return ts(Bu)}function _1(){return Pn().memoizedState}function O1(){return Pn().memoizedState}function Yz(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var d=Gs();i=ei(d);var g=ti(l,i,d);g!==null&&(Os(g,l,d),xu(g,l,d)),l={cache:Rv()},i.payload=l;return}l=l.return}}function Xz(i,l,d){var g=Gs();d={lane:g,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},oh(i)?L1(l,d):(d=bv(i,l,d,g),d!==null&&(Os(d,i,g),P1(d,l,g)))}function $1(i,l,d){var g=Gs();ku(i,l,d,g)}function ku(i,l,d,g){var w={lane:g,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null};if(oh(i))L1(l,w);else{var j=i.alternate;if(i.lanes===0&&(j===null||j.lanes===0)&&(j=l.lastRenderedReducer,j!==null))try{var M=l.lastRenderedState,F=j(M,d);if(w.hasEagerState=!0,w.eagerState=F,Fs(F,M))return Uf(i,l,w,0),an===null&&Bf(),!1}catch{}if(d=bv(i,l,w,g),d!==null)return Os(d,i,g),P1(d,l,g),!0}return!1}function sx(i,l,d,g){if(g={lane:2,revertLane:$x(),gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},oh(i)){if(l)throw Error(r(479))}else l=bv(i,d,g,2),l!==null&&Os(l,i,2)}function oh(i){var l=i.alternate;return i===bt||l!==null&&l===bt}function L1(i,l){Tl=eh=!0;var d=i.pending;d===null?l.next=l:(l.next=d.next,d.next=l),i.pending=l}function P1(i,l,d){if((d&4194048)!==0){var g=l.lanes;g&=i.pendingLanes,d|=g,l.lanes=d,Re(i,d)}}var Nu={readContext:ts,use:sh,useCallback:Mn,useContext:Mn,useEffect:Mn,useImperativeHandle:Mn,useLayoutEffect:Mn,useInsertionEffect:Mn,useMemo:Mn,useReducer:Mn,useRef:Mn,useState:Mn,useDebugValue:Mn,useDeferredValue:Mn,useTransition:Mn,useSyncExternalStore:Mn,useId:Mn,useHostTransitionStatus:Mn,useFormState:Mn,useActionState:Mn,useOptimistic:Mn,useMemoCache:Mn,useCacheRefresh:Mn};Nu.useEffectEvent=Mn;var D1={readContext:ts,use:sh,useCallback:function(i,l){return vs().memoizedState=[i,l===void 0?null:l],i},useContext:ts,useEffect:w1,useImperativeHandle:function(i,l,d){d=d!=null?d.concat([i]):null,ah(4194308,4,S1.bind(null,l,i),d)},useLayoutEffect:function(i,l){return ah(4194308,4,i,l)},useInsertionEffect:function(i,l){ah(4,2,i,l)},useMemo:function(i,l){var d=vs();l=l===void 0?null:l;var g=i();if(vo){ce(!0);try{i()}finally{ce(!1)}}return d.memoizedState=[g,l],g},useReducer:function(i,l,d){var g=vs();if(d!==void 0){var w=d(l);if(vo){ce(!0);try{d(l)}finally{ce(!1)}}}else w=l;return g.memoizedState=g.baseState=w,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:w},g.queue=i,i=i.dispatch=Xz.bind(null,bt,i),[g.memoizedState,i]},useRef:function(i){var l=vs();return i={current:i},l.memoizedState=i},useState:function(i){i=Yv(i);var l=i.queue,d=$1.bind(null,bt,l);return l.dispatch=d,[i.memoizedState,d]},useDebugValue:Jv,useDeferredValue:function(i,l){var d=vs();return ex(d,i,l)},useTransition:function(){var i=Yv(!1);return i=M1.bind(null,bt,i.queue,!0,!1),vs().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,d){var g=bt,w=vs();if(zt){if(d===void 0)throw Error(r(407));d=d()}else{if(d=l(),an===null)throw Error(r(349));(Pt&127)!==0||a1(g,l,d)}w.memoizedState=d;var j={value:d,getSnapshot:l};return w.queue=j,w1(o1.bind(null,g,j,i),[i]),g.flags|=2048,Rl(9,{destroy:void 0},i1.bind(null,g,j,d,l),null),d},useId:function(){var i=vs(),l=an.identifierPrefix;if(zt){var d=Wr,g=Hr;d=(g&~(1<<32-Ae(g)-1)).toString(32)+d,l="_"+l+"R_"+d,d=th++,0<d&&(l+="H"+d.toString(32)),l+="_"}else d=Hz++,l="_"+l+"r_"+d.toString(32)+"_";return i.memoizedState=l},useHostTransitionStatus:nx,useFormState:g1,useActionState:g1,useOptimistic:function(i){var l=vs();l.memoizedState=l.baseState=i;var d={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return l.queue=d,l=sx.bind(null,bt,!0,d),d.dispatch=l,[i,l]},useMemoCache:Kv,useCacheRefresh:function(){return vs().memoizedState=Yz.bind(null,bt)},useEffectEvent:function(i){var l=vs(),d={impl:i};return l.memoizedState=d,function(){if((Yt&2)!==0)throw Error(r(440));return d.impl.apply(void 0,arguments)}}},rx={readContext:ts,use:sh,useCallback:E1,useContext:ts,useEffect:Qv,useImperativeHandle:C1,useInsertionEffect:k1,useLayoutEffect:N1,useMemo:A1,useReducer:rh,useRef:b1,useState:function(){return rh(Ta)},useDebugValue:Jv,useDeferredValue:function(i,l){var d=Pn();return T1(d,nn.memoizedState,i,l)},useTransition:function(){var i=rh(Ta)[0],l=Pn().memoizedState;return[typeof i=="boolean"?i:ju(i),l]},useSyncExternalStore:r1,useId:_1,useHostTransitionStatus:nx,useFormState:v1,useActionState:v1,useOptimistic:function(i,l){var d=Pn();return u1(d,nn,i,l)},useMemoCache:Kv,useCacheRefresh:O1};rx.useEffectEvent=j1;var z1={readContext:ts,use:sh,useCallback:E1,useContext:ts,useEffect:Qv,useImperativeHandle:C1,useInsertionEffect:k1,useLayoutEffect:N1,useMemo:A1,useReducer:Zv,useRef:b1,useState:function(){return Zv(Ta)},useDebugValue:Jv,useDeferredValue:function(i,l){var d=Pn();return nn===null?ex(d,i,l):T1(d,nn.memoizedState,i,l)},useTransition:function(){var i=Zv(Ta)[0],l=Pn().memoizedState;return[typeof i=="boolean"?i:ju(i),l]},useSyncExternalStore:r1,useId:_1,useHostTransitionStatus:nx,useFormState:y1,useActionState:y1,useOptimistic:function(i,l){var d=Pn();return nn!==null?u1(d,nn,i,l):(d.baseState=i,[i,d.queue.dispatch])},useMemoCache:Kv,useCacheRefresh:O1};z1.useEffectEvent=j1;function ax(i,l,d,g){l=i.memoizedState,d=d(g,l),d=d==null?l:x({},l,d),i.memoizedState=d,i.lanes===0&&(i.updateQueue.baseState=d)}var ix={enqueueSetState:function(i,l,d){i=i._reactInternals;var g=Gs(),w=ei(g);w.payload=l,d!=null&&(w.callback=d),l=ti(i,w,g),l!==null&&(Os(l,i,g),xu(l,i,g))},enqueueReplaceState:function(i,l,d){i=i._reactInternals;var g=Gs(),w=ei(g);w.tag=1,w.payload=l,d!=null&&(w.callback=d),l=ti(i,w,g),l!==null&&(Os(l,i,g),xu(l,i,g))},enqueueForceUpdate:function(i,l){i=i._reactInternals;var d=Gs(),g=ei(d);g.tag=2,l!=null&&(g.callback=l),l=ti(i,g,d),l!==null&&(Os(l,i,d),xu(l,i,d))}};function B1(i,l,d,g,w,j,M){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(g,j,M):l.prototype&&l.prototype.isPureReactComponent?!uu(d,g)||!uu(w,j):!0}function U1(i,l,d,g){i=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(d,g),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(d,g),l.state!==i&&ix.enqueueReplaceState(l,l.state,null)}function xo(i,l){var d=l;if("ref"in l){d={};for(var g in l)g!=="ref"&&(d[g]=l[g])}if(i=i.defaultProps){d===l&&(d=x({},d));for(var w in i)d[w]===void 0&&(d[w]=i[w])}return d}function F1(i){zf(i)}function V1(i){console.error(i)}function H1(i){zf(i)}function lh(i,l){try{var d=i.onUncaughtError;d(l.value,{componentStack:l.stack})}catch(g){setTimeout(function(){throw g})}}function W1(i,l,d){try{var g=i.onCaughtError;g(d.value,{componentStack:d.stack,errorBoundary:l.tag===1?l.stateNode:null})}catch(w){setTimeout(function(){throw w})}}function ox(i,l,d){return d=ei(d),d.tag=3,d.payload={element:null},d.callback=function(){lh(i,l)},d}function q1(i){return i=ei(i),i.tag=3,i}function K1(i,l,d,g){var w=d.type.getDerivedStateFromError;if(typeof w=="function"){var j=g.value;i.payload=function(){return w(j)},i.callback=function(){W1(l,d,g)}}var M=d.stateNode;M!==null&&typeof M.componentDidCatch=="function"&&(i.callback=function(){W1(l,d,g),typeof w!="function"&&(oi===null?oi=new Set([this]):oi.add(this));var F=g.stack;this.componentDidCatch(g.value,{componentStack:F!==null?F:""})})}function Qz(i,l,d,g,w){if(d.flags|=32768,g!==null&&typeof g=="object"&&typeof g.then=="function"){if(l=d.alternate,l!==null&&kl(l,d,w,!0),d=Hs.current,d!==null){switch(d.tag){case 31:case 13:return fr===null?bh():d.alternate===null&&Rn===0&&(Rn=3),d.flags&=-257,d.flags|=65536,d.lanes=w,g===Zf?d.flags|=16384:(l=d.updateQueue,l===null?d.updateQueue=new Set([g]):l.add(g),Ix(i,g,w)),!1;case 22:return d.flags|=65536,g===Zf?d.flags|=16384:(l=d.updateQueue,l===null?(l={transitions:null,markerInstances:null,retryQueue:new Set([g])},d.updateQueue=l):(d=l.retryQueue,d===null?l.retryQueue=new Set([g]):d.add(g)),Ix(i,g,w)),!1}throw Error(r(435,d.tag))}return Ix(i,g,w),bh(),!1}if(zt)return l=Hs.current,l!==null?((l.flags&65536)===0&&(l.flags|=256),l.flags|=65536,l.lanes=w,g!==Cv&&(i=Error(r(422),{cause:g}),hu(lr(i,d)))):(g!==Cv&&(l=Error(r(423),{cause:g}),hu(lr(l,d))),i=i.current.alternate,i.flags|=65536,w&=-w,i.lanes|=w,g=lr(g,d),w=ox(i.stateNode,g,w),Pv(i,w),Rn!==4&&(Rn=2)),!1;var j=Error(r(520),{cause:g});if(j=lr(j,d),Iu===null?Iu=[j]:Iu.push(j),Rn!==4&&(Rn=2),l===null)return!0;g=lr(g,d),d=l;do{switch(d.tag){case 3:return d.flags|=65536,i=w&-w,d.lanes|=i,i=ox(d.stateNode,g,i),Pv(d,i),!1;case 1:if(l=d.type,j=d.stateNode,(d.flags&128)===0&&(typeof l.getDerivedStateFromError=="function"||j!==null&&typeof j.componentDidCatch=="function"&&(oi===null||!oi.has(j))))return d.flags|=65536,w&=-w,d.lanes|=w,w=q1(w),K1(w,i,d,g),Pv(d,w),!1}d=d.return}while(d!==null);return!1}var lx=Error(r(461)),Un=!1;function ns(i,l,d,g){l.child=i===null?XN(l,null,d,g):go(l,i.child,d,g)}function G1(i,l,d,g,w){d=d.render;var j=l.ref;if("ref"in g){var M={};for(var F in g)F!=="ref"&&(M[F]=g[F])}else M=g;return fo(l),g=Vv(i,l,d,M,j,w),F=Hv(),i!==null&&!Un?(Wv(i,l,w),Ma(i,l,w)):(zt&&F&&Nv(l),l.flags|=1,ns(i,l,g,w),l.child)}function Z1(i,l,d,g,w){if(i===null){var j=d.type;return typeof j=="function"&&!wv(j)&&j.defaultProps===void 0&&d.compare===null?(l.tag=15,l.type=j,Y1(i,l,j,g,w)):(i=Vf(d.type,null,g,l,l.mode,w),i.ref=l.ref,i.return=l,l.child=i)}if(j=i.child,!gx(i,w)){var M=j.memoizedProps;if(d=d.compare,d=d!==null?d:uu,d(M,g)&&i.ref===l.ref)return Ma(i,l,w)}return l.flags|=1,i=Na(j,g),i.ref=l.ref,i.return=l,l.child=i}function Y1(i,l,d,g,w){if(i!==null){var j=i.memoizedProps;if(uu(j,g)&&i.ref===l.ref)if(Un=!1,l.pendingProps=g=j,gx(i,w))(i.flags&131072)!==0&&(Un=!0);else return l.lanes=i.lanes,Ma(i,l,w)}return cx(i,l,d,g,w)}function X1(i,l,d,g){var w=g.children,j=i!==null?i.memoizedState:null;if(i===null&&l.stateNode===null&&(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.mode==="hidden"){if((l.flags&128)!==0){if(j=j!==null?j.baseLanes|d:d,i!==null){for(g=l.child=i.child,w=0;g!==null;)w=w|g.lanes|g.childLanes,g=g.sibling;g=w&~j}else g=0,l.child=null;return Q1(i,l,j,d,g)}if((d&536870912)!==0)l.memoizedState={baseLanes:0,cachePool:null},i!==null&&Kf(l,j!==null?j.cachePool:null),j!==null?e1(l,j):zv(),t1(l);else return g=l.lanes=536870912,Q1(i,l,j!==null?j.baseLanes|d:d,d,g)}else j!==null?(Kf(l,j.cachePool),e1(l,j),si(),l.memoizedState=null):(i!==null&&Kf(l,null),zv(),si());return ns(i,l,w,d),l.child}function Su(i,l){return i!==null&&i.tag===22||l.stateNode!==null||(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.sibling}function Q1(i,l,d,g,w){var j=_v();return j=j===null?null:{parent:zn._currentValue,pool:j},l.memoizedState={baseLanes:d,cachePool:j},i!==null&&Kf(l,null),zv(),t1(l),i!==null&&kl(i,l,g,!0),l.childLanes=w,null}function ch(i,l){return l=dh({mode:l.mode,children:l.children},i.mode),l.ref=i.ref,i.child=l,l.return=i,l}function J1(i,l,d){return go(l,i.child,null,d),i=ch(l,l.pendingProps),i.flags|=2,Ws(l),l.memoizedState=null,i}function Jz(i,l,d){var g=l.pendingProps,w=(l.flags&128)!==0;if(l.flags&=-129,i===null){if(zt){if(g.mode==="hidden")return i=ch(l,g),l.lanes=536870912,Su(null,i);if(Uv(l),(i=hn)?(i=dC(i,dr),i=i!==null&&i.data==="&"?i:null,i!==null&&(l.memoizedState={dehydrated:i,treeContext:Za!==null?{id:Hr,overflow:Wr}:null,retryLane:536870912,hydrationErrors:null},d=LN(i),d.return=l,l.child=d,es=l,hn=null)):i=null,i===null)throw Xa(l);return l.lanes=536870912,null}return ch(l,g)}var j=i.memoizedState;if(j!==null){var M=j.dehydrated;if(Uv(l),w)if(l.flags&256)l.flags&=-257,l=J1(i,l,d);else if(l.memoizedState!==null)l.child=i.child,l.flags|=128,l=null;else throw Error(r(558));else if(Un||kl(i,l,d,!1),w=(d&i.childLanes)!==0,Un||w){if(g=an,g!==null&&(M=Ve(g,d),M!==0&&M!==j.retryLane))throw j.retryLane=M,oo(i,M),Os(g,i,M),lx;bh(),l=J1(i,l,d)}else i=j.treeContext,hn=hr(M.nextSibling),es=l,zt=!0,Ya=null,dr=!1,i!==null&&zN(l,i),l=ch(l,g),l.flags|=4096;return l}return i=Na(i.child,{mode:g.mode,children:g.children}),i.ref=l.ref,l.child=i,i.return=l,i}function uh(i,l){var d=l.ref;if(d===null)i!==null&&i.ref!==null&&(l.flags|=4194816);else{if(typeof d!="function"&&typeof d!="object")throw Error(r(284));(i===null||i.ref!==d)&&(l.flags|=4194816)}}function cx(i,l,d,g,w){return fo(l),d=Vv(i,l,d,g,void 0,w),g=Hv(),i!==null&&!Un?(Wv(i,l,w),Ma(i,l,w)):(zt&&g&&Nv(l),l.flags|=1,ns(i,l,d,w),l.child)}function eS(i,l,d,g,w,j){return fo(l),l.updateQueue=null,d=s1(l,g,d,w),n1(i),g=Hv(),i!==null&&!Un?(Wv(i,l,j),Ma(i,l,j)):(zt&&g&&Nv(l),l.flags|=1,ns(i,l,d,j),l.child)}function tS(i,l,d,g,w){if(fo(l),l.stateNode===null){var j=yl,M=d.contextType;typeof M=="object"&&M!==null&&(j=ts(M)),j=new d(g,j),l.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,j.updater=ix,l.stateNode=j,j._reactInternals=l,j=l.stateNode,j.props=g,j.state=l.memoizedState,j.refs={},$v(l),M=d.contextType,j.context=typeof M=="object"&&M!==null?ts(M):yl,j.state=l.memoizedState,M=d.getDerivedStateFromProps,typeof M=="function"&&(ax(l,d,M,g),j.state=l.memoizedState),typeof d.getDerivedStateFromProps=="function"||typeof j.getSnapshotBeforeUpdate=="function"||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(M=j.state,typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount(),M!==j.state&&ix.enqueueReplaceState(j,j.state,null),bu(l,g,j,w),yu(),j.state=l.memoizedState),typeof j.componentDidMount=="function"&&(l.flags|=4194308),g=!0}else if(i===null){j=l.stateNode;var F=l.memoizedProps,J=xo(d,F);j.props=J;var me=j.context,we=d.contextType;M=yl,typeof we=="object"&&we!==null&&(M=ts(we));var Ce=d.getDerivedStateFromProps;we=typeof Ce=="function"||typeof j.getSnapshotBeforeUpdate=="function",F=l.pendingProps!==F,we||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(F||me!==M)&&U1(l,j,g,M),Ja=!1;var ge=l.memoizedState;j.state=ge,bu(l,g,j,w),yu(),me=l.memoizedState,F||ge!==me||Ja?(typeof Ce=="function"&&(ax(l,d,Ce,g),me=l.memoizedState),(J=Ja||B1(l,d,J,g,ge,me,M))?(we||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount()),typeof j.componentDidMount=="function"&&(l.flags|=4194308)):(typeof j.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=g,l.memoizedState=me),j.props=g,j.state=me,j.context=M,g=J):(typeof j.componentDidMount=="function"&&(l.flags|=4194308),g=!1)}else{j=l.stateNode,Lv(i,l),M=l.memoizedProps,we=xo(d,M),j.props=we,Ce=l.pendingProps,ge=j.context,me=d.contextType,J=yl,typeof me=="object"&&me!==null&&(J=ts(me)),F=d.getDerivedStateFromProps,(me=typeof F=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(M!==Ce||ge!==J)&&U1(l,j,g,J),Ja=!1,ge=l.memoizedState,j.state=ge,bu(l,g,j,w),yu();var ye=l.memoizedState;M!==Ce||ge!==ye||Ja||i!==null&&i.dependencies!==null&&Wf(i.dependencies)?(typeof F=="function"&&(ax(l,d,F,g),ye=l.memoizedState),(we=Ja||B1(l,d,we,g,ge,ye,J)||i!==null&&i.dependencies!==null&&Wf(i.dependencies))?(me||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(g,ye,J),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(g,ye,J)),typeof j.componentDidUpdate=="function"&&(l.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof j.componentDidUpdate!="function"||M===i.memoizedProps&&ge===i.memoizedState||(l.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||M===i.memoizedProps&&ge===i.memoizedState||(l.flags|=1024),l.memoizedProps=g,l.memoizedState=ye),j.props=g,j.state=ye,j.context=J,g=we):(typeof j.componentDidUpdate!="function"||M===i.memoizedProps&&ge===i.memoizedState||(l.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||M===i.memoizedProps&&ge===i.memoizedState||(l.flags|=1024),g=!1)}return j=g,uh(i,l),g=(l.flags&128)!==0,j||g?(j=l.stateNode,d=g&&typeof d.getDerivedStateFromError!="function"?null:j.render(),l.flags|=1,i!==null&&g?(l.child=go(l,i.child,null,w),l.child=go(l,null,d,w)):ns(i,l,d,w),l.memoizedState=j.state,i=l.child):i=Ma(i,l,w),i}function nS(i,l,d,g){return co(),l.flags|=256,ns(i,l,d,g),l.child}var ux={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function dx(i){return{baseLanes:i,cachePool:WN()}}function fx(i,l,d){return i=i!==null?i.childLanes&~d:0,l&&(i|=Ks),i}function sS(i,l,d){var g=l.pendingProps,w=!1,j=(l.flags&128)!==0,M;if((M=j)||(M=i!==null&&i.memoizedState===null?!1:(Ln.current&2)!==0),M&&(w=!0,l.flags&=-129),M=(l.flags&32)!==0,l.flags&=-33,i===null){if(zt){if(w?ni(l):si(),(i=hn)?(i=dC(i,dr),i=i!==null&&i.data!=="&"?i:null,i!==null&&(l.memoizedState={dehydrated:i,treeContext:Za!==null?{id:Hr,overflow:Wr}:null,retryLane:536870912,hydrationErrors:null},d=LN(i),d.return=l,l.child=d,es=l,hn=null)):i=null,i===null)throw Xa(l);return Gx(i)?l.lanes=32:l.lanes=536870912,null}var F=g.children;return g=g.fallback,w?(si(),w=l.mode,F=dh({mode:"hidden",children:F},w),g=lo(g,w,d,null),F.return=l,g.return=l,F.sibling=g,l.child=F,g=l.child,g.memoizedState=dx(d),g.childLanes=fx(i,M,d),l.memoizedState=ux,Su(null,g)):(ni(l),hx(l,F))}var J=i.memoizedState;if(J!==null&&(F=J.dehydrated,F!==null)){if(j)l.flags&256?(ni(l),l.flags&=-257,l=mx(i,l,d)):l.memoizedState!==null?(si(),l.child=i.child,l.flags|=128,l=null):(si(),F=g.fallback,w=l.mode,g=dh({mode:"visible",children:g.children},w),F=lo(F,w,d,null),F.flags|=2,g.return=l,F.return=l,g.sibling=F,l.child=g,go(l,i.child,null,d),g=l.child,g.memoizedState=dx(d),g.childLanes=fx(i,M,d),l.memoizedState=ux,l=Su(null,g));else if(ni(l),Gx(F)){if(M=F.nextSibling&&F.nextSibling.dataset,M)var me=M.dgst;M=me,g=Error(r(419)),g.stack="",g.digest=M,hu({value:g,source:null,stack:null}),l=mx(i,l,d)}else if(Un||kl(i,l,d,!1),M=(d&i.childLanes)!==0,Un||M){if(M=an,M!==null&&(g=Ve(M,d),g!==0&&g!==J.retryLane))throw J.retryLane=g,oo(i,g),Os(M,i,g),lx;Kx(F)||bh(),l=mx(i,l,d)}else Kx(F)?(l.flags|=192,l.child=i.child,l=null):(i=J.treeContext,hn=hr(F.nextSibling),es=l,zt=!0,Ya=null,dr=!1,i!==null&&zN(l,i),l=hx(l,g.children),l.flags|=4096);return l}return w?(si(),F=g.fallback,w=l.mode,J=i.child,me=J.sibling,g=Na(J,{mode:"hidden",children:g.children}),g.subtreeFlags=J.subtreeFlags&65011712,me!==null?F=Na(me,F):(F=lo(F,w,d,null),F.flags|=2),F.return=l,g.return=l,g.sibling=F,l.child=g,Su(null,g),g=l.child,F=i.child.memoizedState,F===null?F=dx(d):(w=F.cachePool,w!==null?(J=zn._currentValue,w=w.parent!==J?{parent:J,pool:J}:w):w=WN(),F={baseLanes:F.baseLanes|d,cachePool:w}),g.memoizedState=F,g.childLanes=fx(i,M,d),l.memoizedState=ux,Su(i.child,g)):(ni(l),d=i.child,i=d.sibling,d=Na(d,{mode:"visible",children:g.children}),d.return=l,d.sibling=null,i!==null&&(M=l.deletions,M===null?(l.deletions=[i],l.flags|=16):M.push(i)),l.child=d,l.memoizedState=null,d)}function hx(i,l){return l=dh({mode:"visible",children:l},i.mode),l.return=i,i.child=l}function dh(i,l){return i=Vs(22,i,null,l),i.lanes=0,i}function mx(i,l,d){return go(l,i.child,null,d),i=hx(l,l.pendingProps.children),i.flags|=2,l.memoizedState=null,i}function rS(i,l,d){i.lanes|=l;var g=i.alternate;g!==null&&(g.lanes|=l),Tv(i.return,l,d)}function px(i,l,d,g,w,j){var M=i.memoizedState;M===null?i.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:g,tail:d,tailMode:w,treeForkCount:j}:(M.isBackwards=l,M.rendering=null,M.renderingStartTime=0,M.last=g,M.tail=d,M.tailMode=w,M.treeForkCount=j)}function aS(i,l,d){var g=l.pendingProps,w=g.revealOrder,j=g.tail;g=g.children;var M=Ln.current,F=(M&2)!==0;if(F?(M=M&1|2,l.flags|=128):M&=1,B(Ln,M),ns(i,l,g,d),g=zt?fu:0,!F&&i!==null&&(i.flags&128)!==0)e:for(i=l.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&rS(i,d,l);else if(i.tag===19)rS(i,d,l);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===l)break e;for(;i.sibling===null;){if(i.return===null||i.return===l)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(w){case"forwards":for(d=l.child,w=null;d!==null;)i=d.alternate,i!==null&&Jf(i)===null&&(w=d),d=d.sibling;d=w,d===null?(w=l.child,l.child=null):(w=d.sibling,d.sibling=null),px(l,!1,w,d,j,g);break;case"backwards":case"unstable_legacy-backwards":for(d=null,w=l.child,l.child=null;w!==null;){if(i=w.alternate,i!==null&&Jf(i)===null){l.child=w;break}i=w.sibling,w.sibling=d,d=w,w=i}px(l,!0,d,null,j,g);break;case"together":px(l,!1,null,null,void 0,g);break;default:l.memoizedState=null}return l.child}function Ma(i,l,d){if(i!==null&&(l.dependencies=i.dependencies),ii|=l.lanes,(d&l.childLanes)===0)if(i!==null){if(kl(i,l,d,!1),(d&l.childLanes)===0)return null}else return null;if(i!==null&&l.child!==i.child)throw Error(r(153));if(l.child!==null){for(i=l.child,d=Na(i,i.pendingProps),l.child=d,d.return=l;i.sibling!==null;)i=i.sibling,d=d.sibling=Na(i,i.pendingProps),d.return=l;d.sibling=null}return l.child}function gx(i,l){return(i.lanes&l)!==0?!0:(i=i.dependencies,!!(i!==null&&Wf(i)))}function e3(i,l,d){switch(l.tag){case 3:ae(l,l.stateNode.containerInfo),Qa(l,zn,i.memoizedState.cache),co();break;case 27:case 5:_e(l);break;case 4:ae(l,l.stateNode.containerInfo);break;case 10:Qa(l,l.type,l.memoizedProps.value);break;case 31:if(l.memoizedState!==null)return l.flags|=128,Uv(l),null;break;case 13:var g=l.memoizedState;if(g!==null)return g.dehydrated!==null?(ni(l),l.flags|=128,null):(d&l.child.childLanes)!==0?sS(i,l,d):(ni(l),i=Ma(i,l,d),i!==null?i.sibling:null);ni(l);break;case 19:var w=(i.flags&128)!==0;if(g=(d&l.childLanes)!==0,g||(kl(i,l,d,!1),g=(d&l.childLanes)!==0),w){if(g)return aS(i,l,d);l.flags|=128}if(w=l.memoizedState,w!==null&&(w.rendering=null,w.tail=null,w.lastEffect=null),B(Ln,Ln.current),g)break;return null;case 22:return l.lanes=0,X1(i,l,d,l.pendingProps);case 24:Qa(l,zn,i.memoizedState.cache)}return Ma(i,l,d)}function iS(i,l,d){if(i!==null)if(i.memoizedProps!==l.pendingProps)Un=!0;else{if(!gx(i,d)&&(l.flags&128)===0)return Un=!1,e3(i,l,d);Un=(i.flags&131072)!==0}else Un=!1,zt&&(l.flags&1048576)!==0&&DN(l,fu,l.index);switch(l.lanes=0,l.tag){case 16:e:{var g=l.pendingProps;if(i=mo(l.elementType),l.type=i,typeof i=="function")wv(i)?(g=xo(i,g),l.tag=1,l=tS(null,l,i,g,d)):(l.tag=0,l=cx(null,l,i,g,d));else{if(i!=null){var w=i.$$typeof;if(w===N){l.tag=11,l=G1(null,l,i,g,d);break e}else if(w===O){l.tag=14,l=Z1(null,l,i,g,d);break e}}throw l=q(i)||i,Error(r(306,l,""))}}return l;case 0:return cx(i,l,l.type,l.pendingProps,d);case 1:return g=l.type,w=xo(g,l.pendingProps),tS(i,l,g,w,d);case 3:e:{if(ae(l,l.stateNode.containerInfo),i===null)throw Error(r(387));g=l.pendingProps;var j=l.memoizedState;w=j.element,Lv(i,l),bu(l,g,null,d);var M=l.memoizedState;if(g=M.cache,Qa(l,zn,g),g!==j.cache&&Mv(l,[zn],d,!0),yu(),g=M.element,j.isDehydrated)if(j={element:g,isDehydrated:!1,cache:M.cache},l.updateQueue.baseState=j,l.memoizedState=j,l.flags&256){l=nS(i,l,g,d);break e}else if(g!==w){w=lr(Error(r(424)),l),hu(w),l=nS(i,l,g,d);break e}else for(i=l.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,hn=hr(i.firstChild),es=l,zt=!0,Ya=null,dr=!0,d=XN(l,null,g,d),l.child=d;d;)d.flags=d.flags&-3|4096,d=d.sibling;else{if(co(),g===w){l=Ma(i,l,d);break e}ns(i,l,g,d)}l=l.child}return l;case 26:return uh(i,l),i===null?(d=vC(l.type,null,l.pendingProps,null))?l.memoizedState=d:zt||(d=l.type,i=l.pendingProps,g=Eh(ne.current).createElement(d),g[Et]=l,g[Tt]=i,ss(g,d,i),un(g),l.stateNode=g):l.memoizedState=vC(l.type,i.memoizedProps,l.pendingProps,i.memoizedState),null;case 27:return _e(l),i===null&&zt&&(g=l.stateNode=mC(l.type,l.pendingProps,ne.current),es=l,dr=!0,w=hn,di(l.type)?(Zx=w,hn=hr(g.firstChild)):hn=w),ns(i,l,l.pendingProps.children,d),uh(i,l),i===null&&(l.flags|=4194304),l.child;case 5:return i===null&&zt&&((w=g=hn)&&(g=M3(g,l.type,l.pendingProps,dr),g!==null?(l.stateNode=g,es=l,hn=hr(g.firstChild),dr=!1,w=!0):w=!1),w||Xa(l)),_e(l),w=l.type,j=l.pendingProps,M=i!==null?i.memoizedProps:null,g=j.children,Hx(w,j)?g=null:M!==null&&Hx(w,M)&&(l.flags|=32),l.memoizedState!==null&&(w=Vv(i,l,Wz,null,null,d),Bu._currentValue=w),uh(i,l),ns(i,l,g,d),l.child;case 6:return i===null&&zt&&((i=d=hn)&&(d=R3(d,l.pendingProps,dr),d!==null?(l.stateNode=d,es=l,hn=null,i=!0):i=!1),i||Xa(l)),null;case 13:return sS(i,l,d);case 4:return ae(l,l.stateNode.containerInfo),g=l.pendingProps,i===null?l.child=go(l,null,g,d):ns(i,l,g,d),l.child;case 11:return G1(i,l,l.type,l.pendingProps,d);case 7:return ns(i,l,l.pendingProps,d),l.child;case 8:return ns(i,l,l.pendingProps.children,d),l.child;case 12:return ns(i,l,l.pendingProps.children,d),l.child;case 10:return g=l.pendingProps,Qa(l,l.type,g.value),ns(i,l,g.children,d),l.child;case 9:return w=l.type._context,g=l.pendingProps.children,fo(l),w=ts(w),g=g(w),l.flags|=1,ns(i,l,g,d),l.child;case 14:return Z1(i,l,l.type,l.pendingProps,d);case 15:return Y1(i,l,l.type,l.pendingProps,d);case 19:return aS(i,l,d);case 31:return Jz(i,l,d);case 22:return X1(i,l,d,l.pendingProps);case 24:return fo(l),g=ts(zn),i===null?(w=_v(),w===null&&(w=an,j=Rv(),w.pooledCache=j,j.refCount++,j!==null&&(w.pooledCacheLanes|=d),w=j),l.memoizedState={parent:g,cache:w},$v(l),Qa(l,zn,w)):((i.lanes&d)!==0&&(Lv(i,l),bu(l,null,null,d),yu()),w=i.memoizedState,j=l.memoizedState,w.parent!==g?(w={parent:g,cache:g},l.memoizedState=w,l.lanes===0&&(l.memoizedState=l.updateQueue.baseState=w),Qa(l,zn,g)):(g=j.cache,Qa(l,zn,g),g!==w.cache&&Mv(l,[zn],d,!0))),ns(i,l,l.pendingProps.children,d),l.child;case 29:throw l.pendingProps}throw Error(r(156,l.tag))}function Ra(i){i.flags|=4}function vx(i,l,d,g,w){if((l=(i.mode&32)!==0)&&(l=!1),l){if(i.flags|=16777216,(w&335544128)===w)if(i.stateNode.complete)i.flags|=8192;else if(_S())i.flags|=8192;else throw po=Zf,Ov}else i.flags&=-16777217}function oS(i,l){if(l.type!=="stylesheet"||(l.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!jC(l))if(_S())i.flags|=8192;else throw po=Zf,Ov}function fh(i,l){l!==null&&(i.flags|=4),i.flags&16384&&(l=i.tag!==22?Gt():536870912,i.lanes|=l,$l|=l)}function Cu(i,l){if(!zt)switch(i.tailMode){case"hidden":l=i.tail;for(var d=null;l!==null;)l.alternate!==null&&(d=l),l=l.sibling;d===null?i.tail=null:d.sibling=null;break;case"collapsed":d=i.tail;for(var g=null;d!==null;)d.alternate!==null&&(g=d),d=d.sibling;g===null?l||i.tail===null?i.tail=null:i.tail.sibling=null:g.sibling=null}}function mn(i){var l=i.alternate!==null&&i.alternate.child===i.child,d=0,g=0;if(l)for(var w=i.child;w!==null;)d|=w.lanes|w.childLanes,g|=w.subtreeFlags&65011712,g|=w.flags&65011712,w.return=i,w=w.sibling;else for(w=i.child;w!==null;)d|=w.lanes|w.childLanes,g|=w.subtreeFlags,g|=w.flags,w.return=i,w=w.sibling;return i.subtreeFlags|=g,i.childLanes=d,l}function t3(i,l,d){var g=l.pendingProps;switch(Sv(l),l.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return mn(l),null;case 1:return mn(l),null;case 3:return d=l.stateNode,g=null,i!==null&&(g=i.memoizedState.cache),l.memoizedState.cache!==g&&(l.flags|=2048),Ea(zn),be(),d.pendingContext&&(d.context=d.pendingContext,d.pendingContext=null),(i===null||i.child===null)&&(jl(l)?Ra(l):i===null||i.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,Ev())),mn(l),null;case 26:var w=l.type,j=l.memoizedState;return i===null?(Ra(l),j!==null?(mn(l),oS(l,j)):(mn(l),vx(l,w,null,g,d))):j?j!==i.memoizedState?(Ra(l),mn(l),oS(l,j)):(mn(l),l.flags&=-16777217):(i=i.memoizedProps,i!==g&&Ra(l),mn(l),vx(l,w,i,g,d)),null;case 27:if(xe(l),d=ne.current,w=l.type,i!==null&&l.stateNode!=null)i.memoizedProps!==g&&Ra(l);else{if(!g){if(l.stateNode===null)throw Error(r(166));return mn(l),null}i=Q.current,jl(l)?BN(l):(i=mC(w,g,d),l.stateNode=i,Ra(l))}return mn(l),null;case 5:if(xe(l),w=l.type,i!==null&&l.stateNode!=null)i.memoizedProps!==g&&Ra(l);else{if(!g){if(l.stateNode===null)throw Error(r(166));return mn(l),null}if(j=Q.current,jl(l))BN(l);else{var M=Eh(ne.current);switch(j){case 1:j=M.createElementNS("http://www.w3.org/2000/svg",w);break;case 2:j=M.createElementNS("http://www.w3.org/1998/Math/MathML",w);break;default:switch(w){case"svg":j=M.createElementNS("http://www.w3.org/2000/svg",w);break;case"math":j=M.createElementNS("http://www.w3.org/1998/Math/MathML",w);break;case"script":j=M.createElement("div"),j.innerHTML="<script><\/script>",j=j.removeChild(j.firstChild);break;case"select":j=typeof g.is=="string"?M.createElement("select",{is:g.is}):M.createElement("select"),g.multiple?j.multiple=!0:g.size&&(j.size=g.size);break;default:j=typeof g.is=="string"?M.createElement(w,{is:g.is}):M.createElement(w)}}j[Et]=l,j[Tt]=g;e:for(M=l.child;M!==null;){if(M.tag===5||M.tag===6)j.appendChild(M.stateNode);else if(M.tag!==4&&M.tag!==27&&M.child!==null){M.child.return=M,M=M.child;continue}if(M===l)break e;for(;M.sibling===null;){if(M.return===null||M.return===l)break e;M=M.return}M.sibling.return=M.return,M=M.sibling}l.stateNode=j;e:switch(ss(j,w,g),w){case"button":case"input":case"select":case"textarea":g=!!g.autoFocus;break e;case"img":g=!0;break e;default:g=!1}g&&Ra(l)}}return mn(l),vx(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,d),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==g&&Ra(l);else{if(typeof g!="string"&&l.stateNode===null)throw Error(r(166));if(i=ne.current,jl(l)){if(i=l.stateNode,d=l.memoizedProps,g=null,w=es,w!==null)switch(w.tag){case 27:case 5:g=w.memoizedProps}i[Et]=l,i=!!(i.nodeValue===d||g!==null&&g.suppressHydrationWarning===!0||sC(i.nodeValue,d)),i||Xa(l,!0)}else i=Eh(i).createTextNode(g),i[Et]=l,l.stateNode=i}return mn(l),null;case 31:if(d=l.memoizedState,i===null||i.memoizedState!==null){if(g=jl(l),d!==null){if(i===null){if(!g)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[Et]=l}else co(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;mn(l),i=!1}else d=Ev(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=d),i=!0;if(!i)return l.flags&256?(Ws(l),l):(Ws(l),null);if((l.flags&128)!==0)throw Error(r(558))}return mn(l),null;case 13:if(g=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(w=jl(l),g!==null&&g.dehydrated!==null){if(i===null){if(!w)throw Error(r(318));if(w=l.memoizedState,w=w!==null?w.dehydrated:null,!w)throw Error(r(317));w[Et]=l}else co(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;mn(l),w=!1}else w=Ev(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=w),w=!0;if(!w)return l.flags&256?(Ws(l),l):(Ws(l),null)}return Ws(l),(l.flags&128)!==0?(l.lanes=d,l):(d=g!==null,i=i!==null&&i.memoizedState!==null,d&&(g=l.child,w=null,g.alternate!==null&&g.alternate.memoizedState!==null&&g.alternate.memoizedState.cachePool!==null&&(w=g.alternate.memoizedState.cachePool.pool),j=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(j=g.memoizedState.cachePool.pool),j!==w&&(g.flags|=2048)),d!==i&&d&&(l.child.flags|=8192),fh(l,l.updateQueue),mn(l),null);case 4:return be(),i===null&&zx(l.stateNode.containerInfo),mn(l),null;case 10:return Ea(l.type),mn(l),null;case 19:if(H(Ln),g=l.memoizedState,g===null)return mn(l),null;if(w=(l.flags&128)!==0,j=g.rendering,j===null)if(w)Cu(g,!1);else{if(Rn!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(j=Jf(i),j!==null){for(l.flags|=128,Cu(g,!1),i=j.updateQueue,l.updateQueue=i,fh(l,i),l.subtreeFlags=0,i=d,d=l.child;d!==null;)$N(d,i),d=d.sibling;return B(Ln,Ln.current&1|2),zt&&Sa(l,g.treeForkCount),l.child}i=i.sibling}g.tail!==null&&ze()>vh&&(l.flags|=128,w=!0,Cu(g,!1),l.lanes=4194304)}else{if(!w)if(i=Jf(j),i!==null){if(l.flags|=128,w=!0,i=i.updateQueue,l.updateQueue=i,fh(l,i),Cu(g,!0),g.tail===null&&g.tailMode==="hidden"&&!j.alternate&&!zt)return mn(l),null}else 2*ze()-g.renderingStartTime>vh&&d!==536870912&&(l.flags|=128,w=!0,Cu(g,!1),l.lanes=4194304);g.isBackwards?(j.sibling=l.child,l.child=j):(i=g.last,i!==null?i.sibling=j:l.child=j,g.last=j)}return g.tail!==null?(i=g.tail,g.rendering=i,g.tail=i.sibling,g.renderingStartTime=ze(),i.sibling=null,d=Ln.current,B(Ln,w?d&1|2:d&1),zt&&Sa(l,g.treeForkCount),i):(mn(l),null);case 22:case 23:return Ws(l),Bv(),g=l.memoizedState!==null,i!==null?i.memoizedState!==null!==g&&(l.flags|=8192):g&&(l.flags|=8192),g?(d&536870912)!==0&&(l.flags&128)===0&&(mn(l),l.subtreeFlags&6&&(l.flags|=8192)):mn(l),d=l.updateQueue,d!==null&&fh(l,d.retryQueue),d=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(d=i.memoizedState.cachePool.pool),g=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(g=l.memoizedState.cachePool.pool),g!==d&&(l.flags|=2048),i!==null&&H(ho),null;case 24:return d=null,i!==null&&(d=i.memoizedState.cache),l.memoizedState.cache!==d&&(l.flags|=2048),Ea(zn),mn(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function n3(i,l){switch(Sv(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return Ea(zn),be(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return xe(l),null;case 31:if(l.memoizedState!==null){if(Ws(l),l.alternate===null)throw Error(r(340));co()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(Ws(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));co()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return H(Ln),null;case 4:return be(),null;case 10:return Ea(l.type),null;case 22:case 23:return Ws(l),Bv(),i!==null&&H(ho),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return Ea(zn),null;case 25:return null;default:return null}}function lS(i,l){switch(Sv(l),l.tag){case 3:Ea(zn),be();break;case 26:case 27:case 5:xe(l);break;case 4:be();break;case 31:l.memoizedState!==null&&Ws(l);break;case 13:Ws(l);break;case 19:H(Ln);break;case 10:Ea(l.type);break;case 22:case 23:Ws(l),Bv(),i!==null&&H(ho);break;case 24:Ea(zn)}}function Eu(i,l){try{var d=l.updateQueue,g=d!==null?d.lastEffect:null;if(g!==null){var w=g.next;d=w;do{if((d.tag&i)===i){g=void 0;var j=d.create,M=d.inst;g=j(),M.destroy=g}d=d.next}while(d!==w)}}catch(F){Jt(l,l.return,F)}}function ri(i,l,d){try{var g=l.updateQueue,w=g!==null?g.lastEffect:null;if(w!==null){var j=w.next;g=j;do{if((g.tag&i)===i){var M=g.inst,F=M.destroy;if(F!==void 0){M.destroy=void 0,w=l;var J=d,me=F;try{me()}catch(we){Jt(w,J,we)}}}g=g.next}while(g!==j)}}catch(we){Jt(l,l.return,we)}}function cS(i){var l=i.updateQueue;if(l!==null){var d=i.stateNode;try{JN(l,d)}catch(g){Jt(i,i.return,g)}}}function uS(i,l,d){d.props=xo(i.type,i.memoizedProps),d.state=i.memoizedState;try{d.componentWillUnmount()}catch(g){Jt(i,l,g)}}function Au(i,l){try{var d=i.ref;if(d!==null){switch(i.tag){case 26:case 27:case 5:var g=i.stateNode;break;case 30:g=i.stateNode;break;default:g=i.stateNode}typeof d=="function"?i.refCleanup=d(g):d.current=g}}catch(w){Jt(i,l,w)}}function qr(i,l){var d=i.ref,g=i.refCleanup;if(d!==null)if(typeof g=="function")try{g()}catch(w){Jt(i,l,w)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof d=="function")try{d(null)}catch(w){Jt(i,l,w)}else d.current=null}function dS(i){var l=i.type,d=i.memoizedProps,g=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":d.autoFocus&&g.focus();break e;case"img":d.src?g.src=d.src:d.srcSet&&(g.srcset=d.srcSet)}}catch(w){Jt(i,i.return,w)}}function xx(i,l,d){try{var g=i.stateNode;N3(g,i.type,d,l),g[Tt]=l}catch(w){Jt(i,i.return,w)}}function fS(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&di(i.type)||i.tag===4}function yx(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||fS(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&di(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function bx(i,l,d){var g=i.tag;if(g===5||g===6)i=i.stateNode,l?(d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d).insertBefore(i,l):(l=d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d,l.appendChild(i),d=d._reactRootContainer,d!=null||l.onclick!==null||(l.onclick=ja));else if(g!==4&&(g===27&&di(i.type)&&(d=i.stateNode,l=null),i=i.child,i!==null))for(bx(i,l,d),i=i.sibling;i!==null;)bx(i,l,d),i=i.sibling}function hh(i,l,d){var g=i.tag;if(g===5||g===6)i=i.stateNode,l?d.insertBefore(i,l):d.appendChild(i);else if(g!==4&&(g===27&&di(i.type)&&(d=i.stateNode),i=i.child,i!==null))for(hh(i,l,d),i=i.sibling;i!==null;)hh(i,l,d),i=i.sibling}function hS(i){var l=i.stateNode,d=i.memoizedProps;try{for(var g=i.type,w=l.attributes;w.length;)l.removeAttributeNode(w[0]);ss(l,g,d),l[Et]=i,l[Tt]=d}catch(j){Jt(i,i.return,j)}}var Ia=!1,Fn=!1,wx=!1,mS=typeof WeakSet=="function"?WeakSet:Set,Xn=null;function s3(i,l){if(i=i.containerInfo,Fx=Oh,i=CN(i),mv(i)){if("selectionStart"in i)var d={start:i.selectionStart,end:i.selectionEnd};else e:{d=(d=i.ownerDocument)&&d.defaultView||window;var g=d.getSelection&&d.getSelection();if(g&&g.rangeCount!==0){d=g.anchorNode;var w=g.anchorOffset,j=g.focusNode;g=g.focusOffset;try{d.nodeType,j.nodeType}catch{d=null;break e}var M=0,F=-1,J=-1,me=0,we=0,Ce=i,ge=null;t:for(;;){for(var ye;Ce!==d||w!==0&&Ce.nodeType!==3||(F=M+w),Ce!==j||g!==0&&Ce.nodeType!==3||(J=M+g),Ce.nodeType===3&&(M+=Ce.nodeValue.length),(ye=Ce.firstChild)!==null;)ge=Ce,Ce=ye;for(;;){if(Ce===i)break t;if(ge===d&&++me===w&&(F=M),ge===j&&++we===g&&(J=M),(ye=Ce.nextSibling)!==null)break;Ce=ge,ge=Ce.parentNode}Ce=ye}d=F===-1||J===-1?null:{start:F,end:J}}else d=null}d=d||{start:0,end:0}}else d=null;for(Vx={focusedElem:i,selectionRange:d},Oh=!1,Xn=l;Xn!==null;)if(l=Xn,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,Xn=i;else for(;Xn!==null;){switch(l=Xn,j=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(d=0;d<i.length;d++)w=i[d],w.ref.impl=w.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&j!==null){i=void 0,d=l,w=j.memoizedProps,j=j.memoizedState,g=d.stateNode;try{var Ze=xo(d.type,w);i=g.getSnapshotBeforeUpdate(Ze,j),g.__reactInternalSnapshotBeforeUpdate=i}catch(ct){Jt(d,d.return,ct)}}break;case 3:if((i&1024)!==0){if(i=l.stateNode.containerInfo,d=i.nodeType,d===9)qx(i);else if(d===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":qx(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(r(163))}if(i=l.sibling,i!==null){i.return=l.return,Xn=i;break}Xn=l.return}}function pS(i,l,d){var g=d.flags;switch(d.tag){case 0:case 11:case 15:Oa(i,d),g&4&&Eu(5,d);break;case 1:if(Oa(i,d),g&4)if(i=d.stateNode,l===null)try{i.componentDidMount()}catch(M){Jt(d,d.return,M)}else{var w=xo(d.type,l.memoizedProps);l=l.memoizedState;try{i.componentDidUpdate(w,l,i.__reactInternalSnapshotBeforeUpdate)}catch(M){Jt(d,d.return,M)}}g&64&&cS(d),g&512&&Au(d,d.return);break;case 3:if(Oa(i,d),g&64&&(i=d.updateQueue,i!==null)){if(l=null,d.child!==null)switch(d.child.tag){case 27:case 5:l=d.child.stateNode;break;case 1:l=d.child.stateNode}try{JN(i,l)}catch(M){Jt(d,d.return,M)}}break;case 27:l===null&&g&4&&hS(d);case 26:case 5:Oa(i,d),l===null&&g&4&&dS(d),g&512&&Au(d,d.return);break;case 12:Oa(i,d);break;case 31:Oa(i,d),g&4&&xS(i,d);break;case 13:Oa(i,d),g&4&&yS(i,d),g&64&&(i=d.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(d=f3.bind(null,d),I3(i,d))));break;case 22:if(g=d.memoizedState!==null||Ia,!g){l=l!==null&&l.memoizedState!==null||Fn,w=Ia;var j=Fn;Ia=g,(Fn=l)&&!j?$a(i,d,(d.subtreeFlags&8772)!==0):Oa(i,d),Ia=w,Fn=j}break;case 30:break;default:Oa(i,d)}}function gS(i){var l=i.alternate;l!==null&&(i.alternate=null,gS(l)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(l=i.stateNode,l!==null&&va(l)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var kn=null,Ms=!1;function _a(i,l,d){for(d=d.child;d!==null;)vS(i,l,d),d=d.sibling}function vS(i,l,d){if(ie&&typeof ie.onCommitFiberUnmount=="function")try{ie.onCommitFiberUnmount(Ht,d)}catch{}switch(d.tag){case 26:Fn||qr(d,l),_a(i,l,d),d.memoizedState?d.memoizedState.count--:d.stateNode&&(d=d.stateNode,d.parentNode.removeChild(d));break;case 27:Fn||qr(d,l);var g=kn,w=Ms;di(d.type)&&(kn=d.stateNode,Ms=!1),_a(i,l,d),Pu(d.stateNode),kn=g,Ms=w;break;case 5:Fn||qr(d,l);case 6:if(g=kn,w=Ms,kn=null,_a(i,l,d),kn=g,Ms=w,kn!==null)if(Ms)try{(kn.nodeType===9?kn.body:kn.nodeName==="HTML"?kn.ownerDocument.body:kn).removeChild(d.stateNode)}catch(j){Jt(d,l,j)}else try{kn.removeChild(d.stateNode)}catch(j){Jt(d,l,j)}break;case 18:kn!==null&&(Ms?(i=kn,cC(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,d.stateNode),Vl(i)):cC(kn,d.stateNode));break;case 4:g=kn,w=Ms,kn=d.stateNode.containerInfo,Ms=!0,_a(i,l,d),kn=g,Ms=w;break;case 0:case 11:case 14:case 15:ri(2,d,l),Fn||ri(4,d,l),_a(i,l,d);break;case 1:Fn||(qr(d,l),g=d.stateNode,typeof g.componentWillUnmount=="function"&&uS(d,l,g)),_a(i,l,d);break;case 21:_a(i,l,d);break;case 22:Fn=(g=Fn)||d.memoizedState!==null,_a(i,l,d),Fn=g;break;default:_a(i,l,d)}}function xS(i,l){if(l.memoizedState===null&&(i=l.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{Vl(i)}catch(d){Jt(l,l.return,d)}}}function yS(i,l){if(l.memoizedState===null&&(i=l.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{Vl(i)}catch(d){Jt(l,l.return,d)}}function r3(i){switch(i.tag){case 31:case 13:case 19:var l=i.stateNode;return l===null&&(l=i.stateNode=new mS),l;case 22:return i=i.stateNode,l=i._retryCache,l===null&&(l=i._retryCache=new mS),l;default:throw Error(r(435,i.tag))}}function mh(i,l){var d=r3(i);l.forEach(function(g){if(!d.has(g)){d.add(g);var w=h3.bind(null,i,g);g.then(w,w)}})}function Rs(i,l){var d=l.deletions;if(d!==null)for(var g=0;g<d.length;g++){var w=d[g],j=i,M=l,F=M;e:for(;F!==null;){switch(F.tag){case 27:if(di(F.type)){kn=F.stateNode,Ms=!1;break e}break;case 5:kn=F.stateNode,Ms=!1;break e;case 3:case 4:kn=F.stateNode.containerInfo,Ms=!0;break e}F=F.return}if(kn===null)throw Error(r(160));vS(j,M,w),kn=null,Ms=!1,j=w.alternate,j!==null&&(j.return=null),w.return=null}if(l.subtreeFlags&13886)for(l=l.child;l!==null;)bS(l,i),l=l.sibling}var Tr=null;function bS(i,l){var d=i.alternate,g=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:Rs(l,i),Is(i),g&4&&(ri(3,i,i.return),Eu(3,i),ri(5,i,i.return));break;case 1:Rs(l,i),Is(i),g&512&&(Fn||d===null||qr(d,d.return)),g&64&&Ia&&(i=i.updateQueue,i!==null&&(g=i.callbacks,g!==null&&(d=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=d===null?g:d.concat(g))));break;case 26:var w=Tr;if(Rs(l,i),Is(i),g&512&&(Fn||d===null||qr(d,d.return)),g&4){var j=d!==null?d.memoizedState:null;if(g=i.memoizedState,d===null)if(g===null)if(i.stateNode===null){e:{g=i.type,d=i.memoizedProps,w=w.ownerDocument||w;t:switch(g){case"title":j=w.getElementsByTagName("title")[0],(!j||j[Es]||j[Et]||j.namespaceURI==="http://www.w3.org/2000/svg"||j.hasAttribute("itemprop"))&&(j=w.createElement(g),w.head.insertBefore(j,w.querySelector("head > title"))),ss(j,g,d),j[Et]=i,un(j),g=j;break e;case"link":var M=bC("link","href",w).get(g+(d.href||""));if(M){for(var F=0;F<M.length;F++)if(j=M[F],j.getAttribute("href")===(d.href==null||d.href===""?null:d.href)&&j.getAttribute("rel")===(d.rel==null?null:d.rel)&&j.getAttribute("title")===(d.title==null?null:d.title)&&j.getAttribute("crossorigin")===(d.crossOrigin==null?null:d.crossOrigin)){M.splice(F,1);break t}}j=w.createElement(g),ss(j,g,d),w.head.appendChild(j);break;case"meta":if(M=bC("meta","content",w).get(g+(d.content||""))){for(F=0;F<M.length;F++)if(j=M[F],j.getAttribute("content")===(d.content==null?null:""+d.content)&&j.getAttribute("name")===(d.name==null?null:d.name)&&j.getAttribute("property")===(d.property==null?null:d.property)&&j.getAttribute("http-equiv")===(d.httpEquiv==null?null:d.httpEquiv)&&j.getAttribute("charset")===(d.charSet==null?null:d.charSet)){M.splice(F,1);break t}}j=w.createElement(g),ss(j,g,d),w.head.appendChild(j);break;default:throw Error(r(468,g))}j[Et]=i,un(j),g=j}i.stateNode=g}else wC(w,i.type,i.stateNode);else i.stateNode=yC(w,g,i.memoizedProps);else j!==g?(j===null?d.stateNode!==null&&(d=d.stateNode,d.parentNode.removeChild(d)):j.count--,g===null?wC(w,i.type,i.stateNode):yC(w,g,i.memoizedProps)):g===null&&i.stateNode!==null&&xx(i,i.memoizedProps,d.memoizedProps)}break;case 27:Rs(l,i),Is(i),g&512&&(Fn||d===null||qr(d,d.return)),d!==null&&g&4&&xx(i,i.memoizedProps,d.memoizedProps);break;case 5:if(Rs(l,i),Is(i),g&512&&(Fn||d===null||qr(d,d.return)),i.flags&32){w=i.stateNode;try{jn(w,"")}catch(Ze){Jt(i,i.return,Ze)}}g&4&&i.stateNode!=null&&(w=i.memoizedProps,xx(i,w,d!==null?d.memoizedProps:w)),g&1024&&(wx=!0);break;case 6:if(Rs(l,i),Is(i),g&4){if(i.stateNode===null)throw Error(r(162));g=i.memoizedProps,d=i.stateNode;try{d.nodeValue=g}catch(Ze){Jt(i,i.return,Ze)}}break;case 3:if(Mh=null,w=Tr,Tr=Ah(l.containerInfo),Rs(l,i),Tr=w,Is(i),g&4&&d!==null&&d.memoizedState.isDehydrated)try{Vl(l.containerInfo)}catch(Ze){Jt(i,i.return,Ze)}wx&&(wx=!1,wS(i));break;case 4:g=Tr,Tr=Ah(i.stateNode.containerInfo),Rs(l,i),Is(i),Tr=g;break;case 12:Rs(l,i),Is(i);break;case 31:Rs(l,i),Is(i),g&4&&(g=i.updateQueue,g!==null&&(i.updateQueue=null,mh(i,g)));break;case 13:Rs(l,i),Is(i),i.child.flags&8192&&i.memoizedState!==null!=(d!==null&&d.memoizedState!==null)&&(gh=ze()),g&4&&(g=i.updateQueue,g!==null&&(i.updateQueue=null,mh(i,g)));break;case 22:w=i.memoizedState!==null;var J=d!==null&&d.memoizedState!==null,me=Ia,we=Fn;if(Ia=me||w,Fn=we||J,Rs(l,i),Fn=we,Ia=me,Is(i),g&8192)e:for(l=i.stateNode,l._visibility=w?l._visibility&-2:l._visibility|1,w&&(d===null||J||Ia||Fn||yo(i)),d=null,l=i;;){if(l.tag===5||l.tag===26){if(d===null){J=d=l;try{if(j=J.stateNode,w)M=j.style,typeof M.setProperty=="function"?M.setProperty("display","none","important"):M.display="none";else{F=J.stateNode;var Ce=J.memoizedProps.style,ge=Ce!=null&&Ce.hasOwnProperty("display")?Ce.display:null;F.style.display=ge==null||typeof ge=="boolean"?"":(""+ge).trim()}}catch(Ze){Jt(J,J.return,Ze)}}}else if(l.tag===6){if(d===null){J=l;try{J.stateNode.nodeValue=w?"":J.memoizedProps}catch(Ze){Jt(J,J.return,Ze)}}}else if(l.tag===18){if(d===null){J=l;try{var ye=J.stateNode;w?uC(ye,!0):uC(J.stateNode,!1)}catch(Ze){Jt(J,J.return,Ze)}}}else if((l.tag!==22&&l.tag!==23||l.memoizedState===null||l===i)&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===i)break e;for(;l.sibling===null;){if(l.return===null||l.return===i)break e;d===l&&(d=null),l=l.return}d===l&&(d=null),l.sibling.return=l.return,l=l.sibling}g&4&&(g=i.updateQueue,g!==null&&(d=g.retryQueue,d!==null&&(g.retryQueue=null,mh(i,d))));break;case 19:Rs(l,i),Is(i),g&4&&(g=i.updateQueue,g!==null&&(i.updateQueue=null,mh(i,g)));break;case 30:break;case 21:break;default:Rs(l,i),Is(i)}}function Is(i){var l=i.flags;if(l&2){try{for(var d,g=i.return;g!==null;){if(fS(g)){d=g;break}g=g.return}if(d==null)throw Error(r(160));switch(d.tag){case 27:var w=d.stateNode,j=yx(i);hh(i,j,w);break;case 5:var M=d.stateNode;d.flags&32&&(jn(M,""),d.flags&=-33);var F=yx(i);hh(i,F,M);break;case 3:case 4:var J=d.stateNode.containerInfo,me=yx(i);bx(i,me,J);break;default:throw Error(r(161))}}catch(we){Jt(i,i.return,we)}i.flags&=-3}l&4096&&(i.flags&=-4097)}function wS(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var l=i;wS(l),l.tag===5&&l.flags&1024&&l.stateNode.reset(),i=i.sibling}}function Oa(i,l){if(l.subtreeFlags&8772)for(l=l.child;l!==null;)pS(i,l.alternate,l),l=l.sibling}function yo(i){for(i=i.child;i!==null;){var l=i;switch(l.tag){case 0:case 11:case 14:case 15:ri(4,l,l.return),yo(l);break;case 1:qr(l,l.return);var d=l.stateNode;typeof d.componentWillUnmount=="function"&&uS(l,l.return,d),yo(l);break;case 27:Pu(l.stateNode);case 26:case 5:qr(l,l.return),yo(l);break;case 22:l.memoizedState===null&&yo(l);break;case 30:yo(l);break;default:yo(l)}i=i.sibling}}function $a(i,l,d){for(d=d&&(l.subtreeFlags&8772)!==0,l=l.child;l!==null;){var g=l.alternate,w=i,j=l,M=j.flags;switch(j.tag){case 0:case 11:case 15:$a(w,j,d),Eu(4,j);break;case 1:if($a(w,j,d),g=j,w=g.stateNode,typeof w.componentDidMount=="function")try{w.componentDidMount()}catch(me){Jt(g,g.return,me)}if(g=j,w=g.updateQueue,w!==null){var F=g.stateNode;try{var J=w.shared.hiddenCallbacks;if(J!==null)for(w.shared.hiddenCallbacks=null,w=0;w<J.length;w++)QN(J[w],F)}catch(me){Jt(g,g.return,me)}}d&&M&64&&cS(j),Au(j,j.return);break;case 27:hS(j);case 26:case 5:$a(w,j,d),d&&g===null&&M&4&&dS(j),Au(j,j.return);break;case 12:$a(w,j,d);break;case 31:$a(w,j,d),d&&M&4&&xS(w,j);break;case 13:$a(w,j,d),d&&M&4&&yS(w,j);break;case 22:j.memoizedState===null&&$a(w,j,d),Au(j,j.return);break;case 30:break;default:$a(w,j,d)}l=l.sibling}}function jx(i,l){var d=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(d=i.memoizedState.cachePool.pool),i=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(i=l.memoizedState.cachePool.pool),i!==d&&(i!=null&&i.refCount++,d!=null&&mu(d))}function kx(i,l){i=null,l.alternate!==null&&(i=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==i&&(l.refCount++,i!=null&&mu(i))}function Mr(i,l,d,g){if(l.subtreeFlags&10256)for(l=l.child;l!==null;)jS(i,l,d,g),l=l.sibling}function jS(i,l,d,g){var w=l.flags;switch(l.tag){case 0:case 11:case 15:Mr(i,l,d,g),w&2048&&Eu(9,l);break;case 1:Mr(i,l,d,g);break;case 3:Mr(i,l,d,g),w&2048&&(i=null,l.alternate!==null&&(i=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==i&&(l.refCount++,i!=null&&mu(i)));break;case 12:if(w&2048){Mr(i,l,d,g),i=l.stateNode;try{var j=l.memoizedProps,M=j.id,F=j.onPostCommit;typeof F=="function"&&F(M,l.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(J){Jt(l,l.return,J)}}else Mr(i,l,d,g);break;case 31:Mr(i,l,d,g);break;case 13:Mr(i,l,d,g);break;case 23:break;case 22:j=l.stateNode,M=l.alternate,l.memoizedState!==null?j._visibility&2?Mr(i,l,d,g):Tu(i,l):j._visibility&2?Mr(i,l,d,g):(j._visibility|=2,Il(i,l,d,g,(l.subtreeFlags&10256)!==0||!1)),w&2048&&jx(M,l);break;case 24:Mr(i,l,d,g),w&2048&&kx(l.alternate,l);break;default:Mr(i,l,d,g)}}function Il(i,l,d,g,w){for(w=w&&((l.subtreeFlags&10256)!==0||!1),l=l.child;l!==null;){var j=i,M=l,F=d,J=g,me=M.flags;switch(M.tag){case 0:case 11:case 15:Il(j,M,F,J,w),Eu(8,M);break;case 23:break;case 22:var we=M.stateNode;M.memoizedState!==null?we._visibility&2?Il(j,M,F,J,w):Tu(j,M):(we._visibility|=2,Il(j,M,F,J,w)),w&&me&2048&&jx(M.alternate,M);break;case 24:Il(j,M,F,J,w),w&&me&2048&&kx(M.alternate,M);break;default:Il(j,M,F,J,w)}l=l.sibling}}function Tu(i,l){if(l.subtreeFlags&10256)for(l=l.child;l!==null;){var d=i,g=l,w=g.flags;switch(g.tag){case 22:Tu(d,g),w&2048&&jx(g.alternate,g);break;case 24:Tu(d,g),w&2048&&kx(g.alternate,g);break;default:Tu(d,g)}l=l.sibling}}var Mu=8192;function _l(i,l,d){if(i.subtreeFlags&Mu)for(i=i.child;i!==null;)kS(i,l,d),i=i.sibling}function kS(i,l,d){switch(i.tag){case 26:_l(i,l,d),i.flags&Mu&&i.memoizedState!==null&&H3(d,Tr,i.memoizedState,i.memoizedProps);break;case 5:_l(i,l,d);break;case 3:case 4:var g=Tr;Tr=Ah(i.stateNode.containerInfo),_l(i,l,d),Tr=g;break;case 22:i.memoizedState===null&&(g=i.alternate,g!==null&&g.memoizedState!==null?(g=Mu,Mu=16777216,_l(i,l,d),Mu=g):_l(i,l,d));break;default:_l(i,l,d)}}function NS(i){var l=i.alternate;if(l!==null&&(i=l.child,i!==null)){l.child=null;do l=i.sibling,i.sibling=null,i=l;while(i!==null)}}function Ru(i){var l=i.deletions;if((i.flags&16)!==0){if(l!==null)for(var d=0;d<l.length;d++){var g=l[d];Xn=g,CS(g,i)}NS(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)SS(i),i=i.sibling}function SS(i){switch(i.tag){case 0:case 11:case 15:Ru(i),i.flags&2048&&ri(9,i,i.return);break;case 3:Ru(i);break;case 12:Ru(i);break;case 22:var l=i.stateNode;i.memoizedState!==null&&l._visibility&2&&(i.return===null||i.return.tag!==13)?(l._visibility&=-3,ph(i)):Ru(i);break;default:Ru(i)}}function ph(i){var l=i.deletions;if((i.flags&16)!==0){if(l!==null)for(var d=0;d<l.length;d++){var g=l[d];Xn=g,CS(g,i)}NS(i)}for(i=i.child;i!==null;){switch(l=i,l.tag){case 0:case 11:case 15:ri(8,l,l.return),ph(l);break;case 22:d=l.stateNode,d._visibility&2&&(d._visibility&=-3,ph(l));break;default:ph(l)}i=i.sibling}}function CS(i,l){for(;Xn!==null;){var d=Xn;switch(d.tag){case 0:case 11:case 15:ri(8,d,l);break;case 23:case 22:if(d.memoizedState!==null&&d.memoizedState.cachePool!==null){var g=d.memoizedState.cachePool.pool;g!=null&&g.refCount++}break;case 24:mu(d.memoizedState.cache)}if(g=d.child,g!==null)g.return=d,Xn=g;else e:for(d=i;Xn!==null;){g=Xn;var w=g.sibling,j=g.return;if(gS(g),g===d){Xn=null;break e}if(w!==null){w.return=j,Xn=w;break e}Xn=j}}}var a3={getCacheForType:function(i){var l=ts(zn),d=l.data.get(i);return d===void 0&&(d=i(),l.data.set(i,d)),d},cacheSignal:function(){return ts(zn).controller.signal}},i3=typeof WeakMap=="function"?WeakMap:Map,Yt=0,an=null,It=null,Pt=0,Qt=0,qs=null,ai=!1,Ol=!1,Nx=!1,La=0,Rn=0,ii=0,bo=0,Sx=0,Ks=0,$l=0,Iu=null,_s=null,Cx=!1,gh=0,ES=0,vh=1/0,xh=null,oi=null,Zn=0,li=null,Ll=null,Pa=0,Ex=0,Ax=null,AS=null,_u=0,Tx=null;function Gs(){return(Yt&2)!==0&&Pt!==0?Pt&-Pt:$.T!==null?$x():$n()}function TS(){if(Ks===0)if((Pt&536870912)===0||zt){var i=He;He<<=1,(He&3932160)===0&&(He=262144),Ks=i}else Ks=536870912;return i=Hs.current,i!==null&&(i.flags|=32),Ks}function Os(i,l,d){(i===an&&(Qt===2||Qt===9)||i.cancelPendingCommit!==null)&&(Pl(i,0),ci(i,Pt,Ks,!1)),Gn(i,d),((Yt&2)===0||i!==an)&&(i===an&&((Yt&2)===0&&(bo|=d),Rn===4&&ci(i,Pt,Ks,!1)),Kr(i))}function MS(i,l,d){if((Yt&6)!==0)throw Error(r(327));var g=!d&&(l&127)===0&&(l&i.expiredLanes)===0||Tn(i,l),w=g?c3(i,l):Rx(i,l,!0),j=g;do{if(w===0){Ol&&!g&&ci(i,l,0,!1);break}else{if(d=i.current.alternate,j&&!o3(d)){w=Rx(i,l,!1),j=!1;continue}if(w===2){if(j=l,i.errorRecoveryDisabledLanes&j)var M=0;else M=i.pendingLanes&-536870913,M=M!==0?M:M&536870912?536870912:0;if(M!==0){l=M;e:{var F=i;w=Iu;var J=F.current.memoizedState.isDehydrated;if(J&&(Pl(F,M).flags|=256),M=Rx(F,M,!1),M!==2){if(Nx&&!J){F.errorRecoveryDisabledLanes|=j,bo|=j,w=4;break e}j=_s,_s=w,j!==null&&(_s===null?_s=j:_s.push.apply(_s,j))}w=M}if(j=!1,w!==2)continue}}if(w===1){Pl(i,0),ci(i,l,0,!0);break}e:{switch(g=i,j=w,j){case 0:case 1:throw Error(r(345));case 4:if((l&4194048)!==l)break;case 6:ci(g,l,Ks,!ai);break e;case 2:_s=null;break;case 3:case 5:break;default:throw Error(r(329))}if((l&62914560)===l&&(w=gh+300-ze(),10<w)){if(ci(g,l,Ks,!ai),$t(g,0,!0)!==0)break e;Pa=l,g.timeoutHandle=oC(RS.bind(null,g,d,_s,xh,Cx,l,Ks,bo,$l,ai,j,"Throttled",-0,0),w);break e}RS(g,d,_s,xh,Cx,l,Ks,bo,$l,ai,j,null,-0,0)}}break}while(!0);Kr(i)}function RS(i,l,d,g,w,j,M,F,J,me,we,Ce,ge,ye){if(i.timeoutHandle=-1,Ce=l.subtreeFlags,Ce&8192||(Ce&16785408)===16785408){Ce={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:ja},kS(l,j,Ce);var Ze=(j&62914560)===j?gh-ze():(j&4194048)===j?ES-ze():0;if(Ze=W3(Ce,Ze),Ze!==null){Pa=j,i.cancelPendingCommit=Ze(zS.bind(null,i,l,j,d,g,w,M,F,J,we,Ce,null,ge,ye)),ci(i,j,M,!me);return}}zS(i,l,j,d,g,w,M,F,J)}function o3(i){for(var l=i;;){var d=l.tag;if((d===0||d===11||d===15)&&l.flags&16384&&(d=l.updateQueue,d!==null&&(d=d.stores,d!==null)))for(var g=0;g<d.length;g++){var w=d[g],j=w.getSnapshot;w=w.value;try{if(!Fs(j(),w))return!1}catch{return!1}}if(d=l.child,l.subtreeFlags&16384&&d!==null)d.return=l,l=d;else{if(l===i)break;for(;l.sibling===null;){if(l.return===null||l.return===i)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function ci(i,l,d,g){l&=~Sx,l&=~bo,i.suspendedLanes|=l,i.pingedLanes&=~l,g&&(i.warmLanes|=l),g=i.expirationTimes;for(var w=l;0<w;){var j=31-Ae(w),M=1<<j;g[j]=-1,w&=~M}d!==0&&re(i,d,l)}function yh(){return(Yt&6)===0?(Ou(0),!1):!0}function Mx(){if(It!==null){if(Qt===0)var i=It.return;else i=It,Ca=uo=null,qv(i),El=null,gu=0,i=It;for(;i!==null;)lS(i.alternate,i),i=i.return;It=null}}function Pl(i,l){var d=i.timeoutHandle;d!==-1&&(i.timeoutHandle=-1,E3(d)),d=i.cancelPendingCommit,d!==null&&(i.cancelPendingCommit=null,d()),Pa=0,Mx(),an=i,It=d=Na(i.current,null),Pt=l,Qt=0,qs=null,ai=!1,Ol=Tn(i,l),Nx=!1,$l=Ks=Sx=bo=ii=Rn=0,_s=Iu=null,Cx=!1,(l&8)!==0&&(l|=l&32);var g=i.entangledLanes;if(g!==0)for(i=i.entanglements,g&=l;0<g;){var w=31-Ae(g),j=1<<w;l|=i[w],g&=~j}return La=l,Bf(),d}function IS(i,l){bt=null,$.H=Nu,l===Cl||l===Gf?(l=GN(),Qt=3):l===Ov?(l=GN(),Qt=4):Qt=l===lx?8:l!==null&&typeof l=="object"&&typeof l.then=="function"?6:1,qs=l,It===null&&(Rn=1,lh(i,lr(l,i.current)))}function _S(){var i=Hs.current;return i===null?!0:(Pt&4194048)===Pt?fr===null:(Pt&62914560)===Pt||(Pt&536870912)!==0?i===fr:!1}function OS(){var i=$.H;return $.H=Nu,i===null?Nu:i}function $S(){var i=$.A;return $.A=a3,i}function bh(){Rn=4,ai||(Pt&4194048)!==Pt&&Hs.current!==null||(Ol=!0),(ii&134217727)===0&&(bo&134217727)===0||an===null||ci(an,Pt,Ks,!1)}function Rx(i,l,d){var g=Yt;Yt|=2;var w=OS(),j=$S();(an!==i||Pt!==l)&&(xh=null,Pl(i,l)),l=!1;var M=Rn;e:do try{if(Qt!==0&&It!==null){var F=It,J=qs;switch(Qt){case 8:Mx(),M=6;break e;case 3:case 2:case 9:case 6:Hs.current===null&&(l=!0);var me=Qt;if(Qt=0,qs=null,Dl(i,F,J,me),d&&Ol){M=0;break e}break;default:me=Qt,Qt=0,qs=null,Dl(i,F,J,me)}}l3(),M=Rn;break}catch(we){IS(i,we)}while(!0);return l&&i.shellSuspendCounter++,Ca=uo=null,Yt=g,$.H=w,$.A=j,It===null&&(an=null,Pt=0,Bf()),M}function l3(){for(;It!==null;)LS(It)}function c3(i,l){var d=Yt;Yt|=2;var g=OS(),w=$S();an!==i||Pt!==l?(xh=null,vh=ze()+500,Pl(i,l)):Ol=Tn(i,l);e:do try{if(Qt!==0&&It!==null){l=It;var j=qs;t:switch(Qt){case 1:Qt=0,qs=null,Dl(i,l,j,1);break;case 2:case 9:if(qN(j)){Qt=0,qs=null,PS(l);break}l=function(){Qt!==2&&Qt!==9||an!==i||(Qt=7),Kr(i)},j.then(l,l);break e;case 3:Qt=7;break e;case 4:Qt=5;break e;case 7:qN(j)?(Qt=0,qs=null,PS(l)):(Qt=0,qs=null,Dl(i,l,j,7));break;case 5:var M=null;switch(It.tag){case 26:M=It.memoizedState;case 5:case 27:var F=It;if(M?jC(M):F.stateNode.complete){Qt=0,qs=null;var J=F.sibling;if(J!==null)It=J;else{var me=F.return;me!==null?(It=me,wh(me)):It=null}break t}}Qt=0,qs=null,Dl(i,l,j,5);break;case 6:Qt=0,qs=null,Dl(i,l,j,6);break;case 8:Mx(),Rn=6;break e;default:throw Error(r(462))}}u3();break}catch(we){IS(i,we)}while(!0);return Ca=uo=null,$.H=g,$.A=w,Yt=d,It!==null?0:(an=null,Pt=0,Bf(),Rn)}function u3(){for(;It!==null&&!Pe();)LS(It)}function LS(i){var l=iS(i.alternate,i,La);i.memoizedProps=i.pendingProps,l===null?wh(i):It=l}function PS(i){var l=i,d=l.alternate;switch(l.tag){case 15:case 0:l=eS(d,l,l.pendingProps,l.type,void 0,Pt);break;case 11:l=eS(d,l,l.pendingProps,l.type.render,l.ref,Pt);break;case 5:qv(l);default:lS(d,l),l=It=$N(l,La),l=iS(d,l,La)}i.memoizedProps=i.pendingProps,l===null?wh(i):It=l}function Dl(i,l,d,g){Ca=uo=null,qv(l),El=null,gu=0;var w=l.return;try{if(Qz(i,w,l,d,Pt)){Rn=1,lh(i,lr(d,i.current)),It=null;return}}catch(j){if(w!==null)throw It=w,j;Rn=1,lh(i,lr(d,i.current)),It=null;return}l.flags&32768?(zt||g===1?i=!0:Ol||(Pt&536870912)!==0?i=!1:(ai=i=!0,(g===2||g===9||g===3||g===6)&&(g=Hs.current,g!==null&&g.tag===13&&(g.flags|=16384))),DS(l,i)):wh(l)}function wh(i){var l=i;do{if((l.flags&32768)!==0){DS(l,ai);return}i=l.return;var d=t3(l.alternate,l,La);if(d!==null){It=d;return}if(l=l.sibling,l!==null){It=l;return}It=l=i}while(l!==null);Rn===0&&(Rn=5)}function DS(i,l){do{var d=n3(i.alternate,i);if(d!==null){d.flags&=32767,It=d;return}if(d=i.return,d!==null&&(d.flags|=32768,d.subtreeFlags=0,d.deletions=null),!l&&(i=i.sibling,i!==null)){It=i;return}It=i=d}while(i!==null);Rn=6,It=null}function zS(i,l,d,g,w,j,M,F,J){i.cancelPendingCommit=null;do jh();while(Zn!==0);if((Yt&6)!==0)throw Error(r(327));if(l!==null){if(l===i.current)throw Error(r(177));if(j=l.lanes|l.childLanes,j|=yv,On(i,d,j,M,F,J),i===an&&(It=an=null,Pt=0),Ll=l,li=i,Pa=d,Ex=j,Ax=w,AS=g,(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,m3(Xe,function(){return HS(),null})):(i.callbackNode=null,i.callbackPriority=0),g=(l.flags&13878)!==0,(l.subtreeFlags&13878)!==0||g){g=$.T,$.T=null,w=G.p,G.p=2,M=Yt,Yt|=4;try{s3(i,l,d)}finally{Yt=M,G.p=w,$.T=g}}Zn=1,BS(),US(),FS()}}function BS(){if(Zn===1){Zn=0;var i=li,l=Ll,d=(l.flags&13878)!==0;if((l.subtreeFlags&13878)!==0||d){d=$.T,$.T=null;var g=G.p;G.p=2;var w=Yt;Yt|=4;try{bS(l,i);var j=Vx,M=CN(i.containerInfo),F=j.focusedElem,J=j.selectionRange;if(M!==F&&F&&F.ownerDocument&&SN(F.ownerDocument.documentElement,F)){if(J!==null&&mv(F)){var me=J.start,we=J.end;if(we===void 0&&(we=me),"selectionStart"in F)F.selectionStart=me,F.selectionEnd=Math.min(we,F.value.length);else{var Ce=F.ownerDocument||document,ge=Ce&&Ce.defaultView||window;if(ge.getSelection){var ye=ge.getSelection(),Ze=F.textContent.length,ct=Math.min(J.start,Ze),rn=J.end===void 0?ct:Math.min(J.end,Ze);!ye.extend&&ct>rn&&(M=rn,rn=ct,ct=M);var le=NN(F,ct),se=NN(F,rn);if(le&&se&&(ye.rangeCount!==1||ye.anchorNode!==le.node||ye.anchorOffset!==le.offset||ye.focusNode!==se.node||ye.focusOffset!==se.offset)){var fe=Ce.createRange();fe.setStart(le.node,le.offset),ye.removeAllRanges(),ct>rn?(ye.addRange(fe),ye.extend(se.node,se.offset)):(fe.setEnd(se.node,se.offset),ye.addRange(fe))}}}}for(Ce=[],ye=F;ye=ye.parentNode;)ye.nodeType===1&&Ce.push({element:ye,left:ye.scrollLeft,top:ye.scrollTop});for(typeof F.focus=="function"&&F.focus(),F=0;F<Ce.length;F++){var Se=Ce[F];Se.element.scrollLeft=Se.left,Se.element.scrollTop=Se.top}}Oh=!!Fx,Vx=Fx=null}finally{Yt=w,G.p=g,$.T=d}}i.current=l,Zn=2}}function US(){if(Zn===2){Zn=0;var i=li,l=Ll,d=(l.flags&8772)!==0;if((l.subtreeFlags&8772)!==0||d){d=$.T,$.T=null;var g=G.p;G.p=2;var w=Yt;Yt|=4;try{pS(i,l.alternate,l)}finally{Yt=w,G.p=g,$.T=d}}Zn=3}}function FS(){if(Zn===4||Zn===3){Zn=0,De();var i=li,l=Ll,d=Pa,g=AS;(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?Zn=5:(Zn=0,Ll=li=null,VS(i,i.pendingLanes));var w=i.pendingLanes;if(w===0&&(oi=null),Ft(d),l=l.stateNode,ie&&typeof ie.onCommitFiberRoot=="function")try{ie.onCommitFiberRoot(Ht,l,void 0,(l.current.flags&128)===128)}catch{}if(g!==null){l=$.T,w=G.p,G.p=2,$.T=null;try{for(var j=i.onRecoverableError,M=0;M<g.length;M++){var F=g[M];j(F.value,{componentStack:F.stack})}}finally{$.T=l,G.p=w}}(Pa&3)!==0&&jh(),Kr(i),w=i.pendingLanes,(d&261930)!==0&&(w&42)!==0?i===Tx?_u++:(_u=0,Tx=i):_u=0,Ou(0)}}function VS(i,l){(i.pooledCacheLanes&=l)===0&&(l=i.pooledCache,l!=null&&(i.pooledCache=null,mu(l)))}function jh(){return BS(),US(),FS(),HS()}function HS(){if(Zn!==5)return!1;var i=li,l=Ex;Ex=0;var d=Ft(Pa),g=$.T,w=G.p;try{G.p=32>d?32:d,$.T=null,d=Ax,Ax=null;var j=li,M=Pa;if(Zn=0,Ll=li=null,Pa=0,(Yt&6)!==0)throw Error(r(331));var F=Yt;if(Yt|=4,SS(j.current),jS(j,j.current,M,d),Yt=F,Ou(0,!1),ie&&typeof ie.onPostCommitFiberRoot=="function")try{ie.onPostCommitFiberRoot(Ht,j)}catch{}return!0}finally{G.p=w,$.T=g,VS(i,l)}}function WS(i,l,d){l=lr(d,l),l=ox(i.stateNode,l,2),i=ti(i,l,2),i!==null&&(Gn(i,2),Kr(i))}function Jt(i,l,d){if(i.tag===3)WS(i,i,d);else for(;l!==null;){if(l.tag===3){WS(l,i,d);break}else if(l.tag===1){var g=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(oi===null||!oi.has(g))){i=lr(d,i),d=q1(2),g=ti(l,d,2),g!==null&&(K1(d,g,l,i),Gn(g,2),Kr(g));break}}l=l.return}}function Ix(i,l,d){var g=i.pingCache;if(g===null){g=i.pingCache=new i3;var w=new Set;g.set(l,w)}else w=g.get(l),w===void 0&&(w=new Set,g.set(l,w));w.has(d)||(Nx=!0,w.add(d),i=d3.bind(null,i,l,d),l.then(i,i))}function d3(i,l,d){var g=i.pingCache;g!==null&&g.delete(l),i.pingedLanes|=i.suspendedLanes&d,i.warmLanes&=~d,an===i&&(Pt&d)===d&&(Rn===4||Rn===3&&(Pt&62914560)===Pt&&300>ze()-gh?(Yt&2)===0&&Pl(i,0):Sx|=d,$l===Pt&&($l=0)),Kr(i)}function qS(i,l){l===0&&(l=Gt()),i=oo(i,l),i!==null&&(Gn(i,l),Kr(i))}function f3(i){var l=i.memoizedState,d=0;l!==null&&(d=l.retryLane),qS(i,d)}function h3(i,l){var d=0;switch(i.tag){case 31:case 13:var g=i.stateNode,w=i.memoizedState;w!==null&&(d=w.retryLane);break;case 19:g=i.stateNode;break;case 22:g=i.stateNode._retryCache;break;default:throw Error(r(314))}g!==null&&g.delete(l),qS(i,d)}function m3(i,l){return Le(i,l)}var kh=null,zl=null,_x=!1,Nh=!1,Ox=!1,ui=0;function Kr(i){i!==zl&&i.next===null&&(zl===null?kh=zl=i:zl=zl.next=i),Nh=!0,_x||(_x=!0,g3())}function Ou(i,l){if(!Ox&&Nh){Ox=!0;do for(var d=!1,g=kh;g!==null;){if(i!==0){var w=g.pendingLanes;if(w===0)var j=0;else{var M=g.suspendedLanes,F=g.pingedLanes;j=(1<<31-Ae(42|i)+1)-1,j&=w&~(M&~F),j=j&201326741?j&201326741|1:j?j|2:0}j!==0&&(d=!0,YS(g,j))}else j=Pt,j=$t(g,g===an?j:0,g.cancelPendingCommit!==null||g.timeoutHandle!==-1),(j&3)===0||Tn(g,j)||(d=!0,YS(g,j));g=g.next}while(d);Ox=!1}}function p3(){KS()}function KS(){Nh=_x=!1;var i=0;ui!==0&&C3()&&(i=ui);for(var l=ze(),d=null,g=kh;g!==null;){var w=g.next,j=GS(g,l);j===0?(g.next=null,d===null?kh=w:d.next=w,w===null&&(zl=d)):(d=g,(i!==0||(j&3)!==0)&&(Nh=!0)),g=w}Zn!==0&&Zn!==5||Ou(i),ui!==0&&(ui=0)}function GS(i,l){for(var d=i.suspendedLanes,g=i.pingedLanes,w=i.expirationTimes,j=i.pendingLanes&-62914561;0<j;){var M=31-Ae(j),F=1<<M,J=w[M];J===-1?((F&d)===0||(F&g)!==0)&&(w[M]=fn(F,l)):J<=l&&(i.expiredLanes|=F),j&=~F}if(l=an,d=Pt,d=$t(i,i===l?d:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),g=i.callbackNode,d===0||i===l&&(Qt===2||Qt===9)||i.cancelPendingCommit!==null)return g!==null&&g!==null&&Te(g),i.callbackNode=null,i.callbackPriority=0;if((d&3)===0||Tn(i,d)){if(l=d&-d,l===i.callbackPriority)return l;switch(g!==null&&Te(g),Ft(d)){case 2:case 8:d=rt;break;case 32:d=Xe;break;case 268435456:d=jt;break;default:d=Xe}return g=ZS.bind(null,i),d=Le(d,g),i.callbackPriority=l,i.callbackNode=d,l}return g!==null&&g!==null&&Te(g),i.callbackPriority=2,i.callbackNode=null,2}function ZS(i,l){if(Zn!==0&&Zn!==5)return i.callbackNode=null,i.callbackPriority=0,null;var d=i.callbackNode;if(jh()&&i.callbackNode!==d)return null;var g=Pt;return g=$t(i,i===an?g:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),g===0?null:(MS(i,g,l),GS(i,ze()),i.callbackNode!=null&&i.callbackNode===d?ZS.bind(null,i):null)}function YS(i,l){if(jh())return null;MS(i,l,!0)}function g3(){A3(function(){(Yt&6)!==0?Le(st,p3):KS()})}function $x(){if(ui===0){var i=Nl;i===0&&(i=Oe,Oe<<=1,(Oe&261888)===0&&(Oe=256)),ui=i}return ui}function XS(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:If(""+i)}function QS(i,l){var d=l.ownerDocument.createElement("input");return d.name=l.name,d.value=l.value,i.id&&d.setAttribute("form",i.id),l.parentNode.insertBefore(d,l),i=new FormData(i),d.parentNode.removeChild(d),i}function v3(i,l,d,g,w){if(l==="submit"&&d&&d.stateNode===w){var j=XS((w[Tt]||null).action),M=g.submitter;M&&(l=(l=M[Tt]||null)?XS(l.formAction):M.getAttribute("formAction"),l!==null&&(j=l,M=null));var F=new Lf("action","action",null,g,w);i.push({event:F,listeners:[{instance:null,listener:function(){if(g.defaultPrevented){if(ui!==0){var J=M?QS(w,M):new FormData(w);tx(d,{pending:!0,data:J,method:w.method,action:j},null,J)}}else typeof j=="function"&&(F.preventDefault(),J=M?QS(w,M):new FormData(w),tx(d,{pending:!0,data:J,method:w.method,action:j},j,J))},currentTarget:w}]})}}for(var Lx=0;Lx<xv.length;Lx++){var Px=xv[Lx],x3=Px.toLowerCase(),y3=Px[0].toUpperCase()+Px.slice(1);Ar(x3,"on"+y3)}Ar(TN,"onAnimationEnd"),Ar(MN,"onAnimationIteration"),Ar(RN,"onAnimationStart"),Ar("dblclick","onDoubleClick"),Ar("focusin","onFocus"),Ar("focusout","onBlur"),Ar($z,"onTransitionRun"),Ar(Lz,"onTransitionStart"),Ar(Pz,"onTransitionCancel"),Ar(IN,"onTransitionEnd"),Vr("onMouseEnter",["mouseout","mouseover"]),Vr("onMouseLeave",["mouseout","mouseover"]),Vr("onPointerEnter",["pointerout","pointerover"]),Vr("onPointerLeave",["pointerout","pointerover"]),ir("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ir("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ir("onBeforeInput",["compositionend","keypress","textInput","paste"]),ir("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ir("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ir("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var $u="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(" "),b3=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat($u));function JS(i,l){l=(l&4)!==0;for(var d=0;d<i.length;d++){var g=i[d],w=g.event;g=g.listeners;e:{var j=void 0;if(l)for(var M=g.length-1;0<=M;M--){var F=g[M],J=F.instance,me=F.currentTarget;if(F=F.listener,J!==j&&w.isPropagationStopped())break e;j=F,w.currentTarget=me;try{j(w)}catch(we){zf(we)}w.currentTarget=null,j=J}else for(M=0;M<g.length;M++){if(F=g[M],J=F.instance,me=F.currentTarget,F=F.listener,J!==j&&w.isPropagationStopped())break e;j=F,w.currentTarget=me;try{j(w)}catch(we){zf(we)}w.currentTarget=null,j=J}}}}function _t(i,l){var d=l[sr];d===void 0&&(d=l[sr]=new Set);var g=i+"__bubble";d.has(g)||(eC(l,i,2,!1),d.add(g))}function Dx(i,l,d){var g=0;l&&(g|=4),eC(d,i,g,l)}var Sh="_reactListening"+Math.random().toString(36).slice(2);function zx(i){if(!i[Sh]){i[Sh]=!0,As.forEach(function(d){d!=="selectionchange"&&(b3.has(d)||Dx(d,!1,i),Dx(d,!0,i))});var l=i.nodeType===9?i:i.ownerDocument;l===null||l[Sh]||(l[Sh]=!0,Dx("selectionchange",!1,l))}}function eC(i,l,d,g){switch(TC(l)){case 2:var w=G3;break;case 8:w=Z3;break;default:w=ey}d=w.bind(null,l,d,i),w=void 0,!av||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(w=!0),g?w!==void 0?i.addEventListener(l,d,{capture:!0,passive:w}):i.addEventListener(l,d,!0):w!==void 0?i.addEventListener(l,d,{passive:w}):i.addEventListener(l,d,!1)}function Bx(i,l,d,g,w){var j=g;if((l&1)===0&&(l&2)===0&&g!==null)e:for(;;){if(g===null)return;var M=g.tag;if(M===3||M===4){var F=g.stateNode.containerInfo;if(F===w)break;if(M===4)for(M=g.return;M!==null;){var J=M.tag;if((J===3||J===4)&&M.stateNode.containerInfo===w)return;M=M.return}for(;F!==null;){if(M=Bs(F),M===null)return;if(J=M.tag,J===5||J===6||J===26||J===27){g=j=M;continue e}F=F.parentNode}}g=g.return}aN(function(){var me=j,we=sv(d),Ce=[];e:{var ge=_N.get(i);if(ge!==void 0){var ye=Lf,Ze=i;switch(i){case"keypress":if(Of(d)===0)break e;case"keydown":case"keyup":ye=hz;break;case"focusin":Ze="focus",ye=cv;break;case"focusout":Ze="blur",ye=cv;break;case"beforeblur":case"afterblur":ye=cv;break;case"click":if(d.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ye=lN;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ye=tz;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ye=gz;break;case TN:case MN:case RN:ye=rz;break;case IN:ye=xz;break;case"scroll":case"scrollend":ye=J4;break;case"wheel":ye=bz;break;case"copy":case"cut":case"paste":ye=iz;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ye=uN;break;case"toggle":case"beforetoggle":ye=jz}var ct=(l&4)!==0,rn=!ct&&(i==="scroll"||i==="scrollend"),le=ct?ge!==null?ge+"Capture":null:ge;ct=[];for(var se=me,fe;se!==null;){var Se=se;if(fe=Se.stateNode,Se=Se.tag,Se!==5&&Se!==26&&Se!==27||fe===null||le===null||(Se=su(se,le),Se!=null&&ct.push(Lu(se,Se,fe))),rn)break;se=se.return}0<ct.length&&(ge=new ye(ge,Ze,null,d,we),Ce.push({event:ge,listeners:ct}))}}if((l&7)===0){e:{if(ge=i==="mouseover"||i==="pointerover",ye=i==="mouseout"||i==="pointerout",ge&&d!==nv&&(Ze=d.relatedTarget||d.fromElement)&&(Bs(Ze)||Ze[Jn]))break e;if((ye||ge)&&(ge=we.window===we?we:(ge=we.ownerDocument)?ge.defaultView||ge.parentWindow:window,ye?(Ze=d.relatedTarget||d.toElement,ye=me,Ze=Ze?Bs(Ze):null,Ze!==null&&(rn=o(Ze),ct=Ze.tag,Ze!==rn||ct!==5&&ct!==27&&ct!==6)&&(Ze=null)):(ye=null,Ze=me),ye!==Ze)){if(ct=lN,Se="onMouseLeave",le="onMouseEnter",se="mouse",(i==="pointerout"||i==="pointerover")&&(ct=uN,Se="onPointerLeave",le="onPointerEnter",se="pointer"),rn=ye==null?ge:Cr(ye),fe=Ze==null?ge:Cr(Ze),ge=new ct(Se,se+"leave",ye,d,we),ge.target=rn,ge.relatedTarget=fe,Se=null,Bs(we)===me&&(ct=new ct(le,se+"enter",Ze,d,we),ct.target=fe,ct.relatedTarget=rn,Se=ct),rn=Se,ye&&Ze)t:{for(ct=w3,le=ye,se=Ze,fe=0,Se=le;Se;Se=ct(Se))fe++;Se=0;for(var it=se;it;it=ct(it))Se++;for(;0<fe-Se;)le=ct(le),fe--;for(;0<Se-fe;)se=ct(se),Se--;for(;fe--;){if(le===se||se!==null&&le===se.alternate){ct=le;break t}le=ct(le),se=ct(se)}ct=null}else ct=null;ye!==null&&tC(Ce,ge,ye,ct,!1),Ze!==null&&rn!==null&&tC(Ce,rn,Ze,ct,!0)}}e:{if(ge=me?Cr(me):window,ye=ge.nodeName&&ge.nodeName.toLowerCase(),ye==="select"||ye==="input"&&ge.type==="file")var qt=xN;else if(gN(ge))if(yN)qt=Iz;else{qt=Mz;var Je=Tz}else ye=ge.nodeName,!ye||ye.toLowerCase()!=="input"||ge.type!=="checkbox"&&ge.type!=="radio"?me&&tv(me.elementType)&&(qt=xN):qt=Rz;if(qt&&(qt=qt(i,me))){vN(Ce,qt,d,we);break e}Je&&Je(i,ge,me),i==="focusout"&&me&&ge.type==="number"&&me.memoizedProps.value!=null&&kt(ge,"number",ge.value)}switch(Je=me?Cr(me):window,i){case"focusin":(gN(Je)||Je.contentEditable==="true")&&(gl=Je,pv=me,du=null);break;case"focusout":du=pv=gl=null;break;case"mousedown":gv=!0;break;case"contextmenu":case"mouseup":case"dragend":gv=!1,EN(Ce,d,we);break;case"selectionchange":if(Oz)break;case"keydown":case"keyup":EN(Ce,d,we)}var Nt;if(dv)e:{switch(i){case"compositionstart":var Dt="onCompositionStart";break e;case"compositionend":Dt="onCompositionEnd";break e;case"compositionupdate":Dt="onCompositionUpdate";break e}Dt=void 0}else pl?mN(i,d)&&(Dt="onCompositionEnd"):i==="keydown"&&d.keyCode===229&&(Dt="onCompositionStart");Dt&&(dN&&d.locale!=="ko"&&(pl||Dt!=="onCompositionStart"?Dt==="onCompositionEnd"&&pl&&(Nt=iN()):(Ga=we,iv="value"in Ga?Ga.value:Ga.textContent,pl=!0)),Je=Ch(me,Dt),0<Je.length&&(Dt=new cN(Dt,i,null,d,we),Ce.push({event:Dt,listeners:Je}),Nt?Dt.data=Nt:(Nt=pN(d),Nt!==null&&(Dt.data=Nt)))),(Nt=Nz?Sz(i,d):Cz(i,d))&&(Dt=Ch(me,"onBeforeInput"),0<Dt.length&&(Je=new cN("onBeforeInput","beforeinput",null,d,we),Ce.push({event:Je,listeners:Dt}),Je.data=Nt)),v3(Ce,i,me,d,we)}JS(Ce,l)})}function Lu(i,l,d){return{instance:i,listener:l,currentTarget:d}}function Ch(i,l){for(var d=l+"Capture",g=[];i!==null;){var w=i,j=w.stateNode;if(w=w.tag,w!==5&&w!==26&&w!==27||j===null||(w=su(i,d),w!=null&&g.unshift(Lu(i,w,j)),w=su(i,l),w!=null&&g.push(Lu(i,w,j))),i.tag===3)return g;i=i.return}return[]}function w3(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function tC(i,l,d,g,w){for(var j=l._reactName,M=[];d!==null&&d!==g;){var F=d,J=F.alternate,me=F.stateNode;if(F=F.tag,J!==null&&J===g)break;F!==5&&F!==26&&F!==27||me===null||(J=me,w?(me=su(d,j),me!=null&&M.unshift(Lu(d,me,J))):w||(me=su(d,j),me!=null&&M.push(Lu(d,me,J)))),d=d.return}M.length!==0&&i.push({event:l,listeners:M})}var j3=/\r\n?/g,k3=/\u0000|\uFFFD/g;function nC(i){return(typeof i=="string"?i:""+i).replace(j3,`
9
- `).replace(k3,"")}function sC(i,l){return l=nC(l),nC(i)===l}function sn(i,l,d,g,w,j){switch(d){case"children":typeof g=="string"?l==="body"||l==="textarea"&&g===""||jn(i,g):(typeof g=="number"||typeof g=="bigint")&&l!=="body"&&jn(i,""+g);break;case"className":ba(i,"class",g);break;case"tabIndex":ba(i,"tabindex",g);break;case"dir":case"role":case"viewBox":case"width":case"height":ba(i,d,g);break;case"style":sN(i,g,j);break;case"data":if(l!=="object"){ba(i,"data",g);break}case"src":case"href":if(g===""&&(l!=="a"||d!=="href")){i.removeAttribute(d);break}if(g==null||typeof g=="function"||typeof g=="symbol"||typeof g=="boolean"){i.removeAttribute(d);break}g=If(""+g),i.setAttribute(d,g);break;case"action":case"formAction":if(typeof g=="function"){i.setAttribute(d,"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 j=="function"&&(d==="formAction"?(l!=="input"&&sn(i,l,"name",w.name,w,null),sn(i,l,"formEncType",w.formEncType,w,null),sn(i,l,"formMethod",w.formMethod,w,null),sn(i,l,"formTarget",w.formTarget,w,null)):(sn(i,l,"encType",w.encType,w,null),sn(i,l,"method",w.method,w,null),sn(i,l,"target",w.target,w,null)));if(g==null||typeof g=="symbol"||typeof g=="boolean"){i.removeAttribute(d);break}g=If(""+g),i.setAttribute(d,g);break;case"onClick":g!=null&&(i.onclick=ja);break;case"onScroll":g!=null&&_t("scroll",i);break;case"onScrollEnd":g!=null&&_t("scrollend",i);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(r(61));if(d=g.__html,d!=null){if(w.children!=null)throw Error(r(60));i.innerHTML=d}}break;case"multiple":i.multiple=g&&typeof g!="function"&&typeof g!="symbol";break;case"muted":i.muted=g&&typeof g!="function"&&typeof g!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(g==null||typeof g=="function"||typeof g=="boolean"||typeof g=="symbol"){i.removeAttribute("xlink:href");break}d=If(""+g),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",d);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":g!=null&&typeof g!="function"&&typeof g!="symbol"?i.setAttribute(d,""+g):i.removeAttribute(d);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":g&&typeof g!="function"&&typeof g!="symbol"?i.setAttribute(d,""):i.removeAttribute(d);break;case"capture":case"download":g===!0?i.setAttribute(d,""):g!==!1&&g!=null&&typeof g!="function"&&typeof g!="symbol"?i.setAttribute(d,g):i.removeAttribute(d);break;case"cols":case"rows":case"size":case"span":g!=null&&typeof g!="function"&&typeof g!="symbol"&&!isNaN(g)&&1<=g?i.setAttribute(d,g):i.removeAttribute(d);break;case"rowSpan":case"start":g==null||typeof g=="function"||typeof g=="symbol"||isNaN(g)?i.removeAttribute(d):i.setAttribute(d,g);break;case"popover":_t("beforetoggle",i),_t("toggle",i),gs(i,"popover",g);break;case"xlinkActuate":Us(i,"http://www.w3.org/1999/xlink","xlink:actuate",g);break;case"xlinkArcrole":Us(i,"http://www.w3.org/1999/xlink","xlink:arcrole",g);break;case"xlinkRole":Us(i,"http://www.w3.org/1999/xlink","xlink:role",g);break;case"xlinkShow":Us(i,"http://www.w3.org/1999/xlink","xlink:show",g);break;case"xlinkTitle":Us(i,"http://www.w3.org/1999/xlink","xlink:title",g);break;case"xlinkType":Us(i,"http://www.w3.org/1999/xlink","xlink:type",g);break;case"xmlBase":Us(i,"http://www.w3.org/XML/1998/namespace","xml:base",g);break;case"xmlLang":Us(i,"http://www.w3.org/XML/1998/namespace","xml:lang",g);break;case"xmlSpace":Us(i,"http://www.w3.org/XML/1998/namespace","xml:space",g);break;case"is":gs(i,"is",g);break;case"innerText":case"textContent":break;default:(!(2<d.length)||d[0]!=="o"&&d[0]!=="O"||d[1]!=="n"&&d[1]!=="N")&&(d=X4.get(d)||d,gs(i,d,g))}}function Ux(i,l,d,g,w,j){switch(d){case"style":sN(i,g,j);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(r(61));if(d=g.__html,d!=null){if(w.children!=null)throw Error(r(60));i.innerHTML=d}}break;case"children":typeof g=="string"?jn(i,g):(typeof g=="number"||typeof g=="bigint")&&jn(i,""+g);break;case"onScroll":g!=null&&_t("scroll",i);break;case"onScrollEnd":g!=null&&_t("scrollend",i);break;case"onClick":g!=null&&(i.onclick=ja);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!fl.hasOwnProperty(d))e:{if(d[0]==="o"&&d[1]==="n"&&(w=d.endsWith("Capture"),l=d.slice(2,w?d.length-7:void 0),j=i[Tt]||null,j=j!=null?j[d]:null,typeof j=="function"&&i.removeEventListener(l,j,w),typeof g=="function")){typeof j!="function"&&j!==null&&(d in i?i[d]=null:i.hasAttribute(d)&&i.removeAttribute(d)),i.addEventListener(l,g,w);break e}d in i?i[d]=g:g===!0?i.setAttribute(d,""):gs(i,d,g)}}}function ss(i,l,d){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":_t("error",i),_t("load",i);var g=!1,w=!1,j;for(j in d)if(d.hasOwnProperty(j)){var M=d[j];if(M!=null)switch(j){case"src":g=!0;break;case"srcSet":w=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,l));default:sn(i,l,j,M,d,null)}}w&&sn(i,l,"srcSet",d.srcSet,d,null),g&&sn(i,l,"src",d.src,d,null);return;case"input":_t("invalid",i);var F=j=M=w=null,J=null,me=null;for(g in d)if(d.hasOwnProperty(g)){var we=d[g];if(we!=null)switch(g){case"name":w=we;break;case"type":M=we;break;case"checked":J=we;break;case"defaultChecked":me=we;break;case"value":j=we;break;case"defaultValue":F=we;break;case"children":case"dangerouslySetInnerHTML":if(we!=null)throw Error(r(137,l));break;default:sn(i,l,g,we,d,null)}}Zt(i,j,F,J,me,M,w,!1);return;case"select":_t("invalid",i),g=M=j=null;for(w in d)if(d.hasOwnProperty(w)&&(F=d[w],F!=null))switch(w){case"value":j=F;break;case"defaultValue":M=F;break;case"multiple":g=F;default:sn(i,l,w,F,d,null)}l=j,d=M,i.multiple=!!g,l!=null?yt(i,!!g,l,!1):d!=null&&yt(i,!!g,d,!0);return;case"textarea":_t("invalid",i),j=w=g=null;for(M in d)if(d.hasOwnProperty(M)&&(F=d[M],F!=null))switch(M){case"value":g=F;break;case"defaultValue":w=F;break;case"children":j=F;break;case"dangerouslySetInnerHTML":if(F!=null)throw Error(r(91));break;default:sn(i,l,M,F,d,null)}wa(i,g,w,j);return;case"option":for(J in d)d.hasOwnProperty(J)&&(g=d[J],g!=null)&&(J==="selected"?i.selected=g&&typeof g!="function"&&typeof g!="symbol":sn(i,l,J,g,d,null));return;case"dialog":_t("beforetoggle",i),_t("toggle",i),_t("cancel",i),_t("close",i);break;case"iframe":case"object":_t("load",i);break;case"video":case"audio":for(g=0;g<$u.length;g++)_t($u[g],i);break;case"image":_t("error",i),_t("load",i);break;case"details":_t("toggle",i);break;case"embed":case"source":case"link":_t("error",i),_t("load",i);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(me in d)if(d.hasOwnProperty(me)&&(g=d[me],g!=null))switch(me){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,l));default:sn(i,l,me,g,d,null)}return;default:if(tv(l)){for(we in d)d.hasOwnProperty(we)&&(g=d[we],g!==void 0&&Ux(i,l,we,g,d,void 0));return}}for(F in d)d.hasOwnProperty(F)&&(g=d[F],g!=null&&sn(i,l,F,g,d,null))}function N3(i,l,d,g){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var w=null,j=null,M=null,F=null,J=null,me=null,we=null;for(ye in d){var Ce=d[ye];if(d.hasOwnProperty(ye)&&Ce!=null)switch(ye){case"checked":break;case"value":break;case"defaultValue":J=Ce;default:g.hasOwnProperty(ye)||sn(i,l,ye,null,g,Ce)}}for(var ge in g){var ye=g[ge];if(Ce=d[ge],g.hasOwnProperty(ge)&&(ye!=null||Ce!=null))switch(ge){case"type":j=ye;break;case"name":w=ye;break;case"checked":me=ye;break;case"defaultChecked":we=ye;break;case"value":M=ye;break;case"defaultValue":F=ye;break;case"children":case"dangerouslySetInnerHTML":if(ye!=null)throw Error(r(137,l));break;default:ye!==Ce&&sn(i,l,ge,ye,g,Ce)}}Wt(i,M,F,J,me,we,j,w);return;case"select":ye=M=F=ge=null;for(j in d)if(J=d[j],d.hasOwnProperty(j)&&J!=null)switch(j){case"value":break;case"multiple":ye=J;default:g.hasOwnProperty(j)||sn(i,l,j,null,g,J)}for(w in g)if(j=g[w],J=d[w],g.hasOwnProperty(w)&&(j!=null||J!=null))switch(w){case"value":ge=j;break;case"defaultValue":F=j;break;case"multiple":M=j;default:j!==J&&sn(i,l,w,j,g,J)}l=F,d=M,g=ye,ge!=null?yt(i,!!d,ge,!1):!!g!=!!d&&(l!=null?yt(i,!!d,l,!0):yt(i,!!d,d?[]:"",!1));return;case"textarea":ye=ge=null;for(F in d)if(w=d[F],d.hasOwnProperty(F)&&w!=null&&!g.hasOwnProperty(F))switch(F){case"value":break;case"children":break;default:sn(i,l,F,null,g,w)}for(M in g)if(w=g[M],j=d[M],g.hasOwnProperty(M)&&(w!=null||j!=null))switch(M){case"value":ge=w;break;case"defaultValue":ye=w;break;case"children":break;case"dangerouslySetInnerHTML":if(w!=null)throw Error(r(91));break;default:w!==j&&sn(i,l,M,w,g,j)}Cn(i,ge,ye);return;case"option":for(var Ze in d)ge=d[Ze],d.hasOwnProperty(Ze)&&ge!=null&&!g.hasOwnProperty(Ze)&&(Ze==="selected"?i.selected=!1:sn(i,l,Ze,null,g,ge));for(J in g)ge=g[J],ye=d[J],g.hasOwnProperty(J)&&ge!==ye&&(ge!=null||ye!=null)&&(J==="selected"?i.selected=ge&&typeof ge!="function"&&typeof ge!="symbol":sn(i,l,J,ge,g,ye));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 ct in d)ge=d[ct],d.hasOwnProperty(ct)&&ge!=null&&!g.hasOwnProperty(ct)&&sn(i,l,ct,null,g,ge);for(me in g)if(ge=g[me],ye=d[me],g.hasOwnProperty(me)&&ge!==ye&&(ge!=null||ye!=null))switch(me){case"children":case"dangerouslySetInnerHTML":if(ge!=null)throw Error(r(137,l));break;default:sn(i,l,me,ge,g,ye)}return;default:if(tv(l)){for(var rn in d)ge=d[rn],d.hasOwnProperty(rn)&&ge!==void 0&&!g.hasOwnProperty(rn)&&Ux(i,l,rn,void 0,g,ge);for(we in g)ge=g[we],ye=d[we],!g.hasOwnProperty(we)||ge===ye||ge===void 0&&ye===void 0||Ux(i,l,we,ge,g,ye);return}}for(var le in d)ge=d[le],d.hasOwnProperty(le)&&ge!=null&&!g.hasOwnProperty(le)&&sn(i,l,le,null,g,ge);for(Ce in g)ge=g[Ce],ye=d[Ce],!g.hasOwnProperty(Ce)||ge===ye||ge==null&&ye==null||sn(i,l,Ce,ge,g,ye)}function rC(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function S3(){if(typeof performance.getEntriesByType=="function"){for(var i=0,l=0,d=performance.getEntriesByType("resource"),g=0;g<d.length;g++){var w=d[g],j=w.transferSize,M=w.initiatorType,F=w.duration;if(j&&F&&rC(M)){for(M=0,F=w.responseEnd,g+=1;g<d.length;g++){var J=d[g],me=J.startTime;if(me>F)break;var we=J.transferSize,Ce=J.initiatorType;we&&rC(Ce)&&(J=J.responseEnd,M+=we*(J<F?1:(F-me)/(J-me)))}if(--g,l+=8*(j+M)/(w.duration/1e3),i++,10<i)break}}if(0<i)return l/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var Fx=null,Vx=null;function Eh(i){return i.nodeType===9?i:i.ownerDocument}function aC(i){switch(i){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function iC(i,l){if(i===0)switch(l){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&l==="foreignObject"?0:i}function Hx(i,l){return i==="textarea"||i==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.children=="bigint"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var Wx=null;function C3(){var i=window.event;return i&&i.type==="popstate"?i===Wx?!1:(Wx=i,!0):(Wx=null,!1)}var oC=typeof setTimeout=="function"?setTimeout:void 0,E3=typeof clearTimeout=="function"?clearTimeout:void 0,lC=typeof Promise=="function"?Promise:void 0,A3=typeof queueMicrotask=="function"?queueMicrotask:typeof lC<"u"?function(i){return lC.resolve(null).then(i).catch(T3)}:oC;function T3(i){setTimeout(function(){throw i})}function di(i){return i==="head"}function cC(i,l){var d=l,g=0;do{var w=d.nextSibling;if(i.removeChild(d),w&&w.nodeType===8)if(d=w.data,d==="/$"||d==="/&"){if(g===0){i.removeChild(w),Vl(l);return}g--}else if(d==="$"||d==="$?"||d==="$~"||d==="$!"||d==="&")g++;else if(d==="html")Pu(i.ownerDocument.documentElement);else if(d==="head"){d=i.ownerDocument.head,Pu(d);for(var j=d.firstChild;j;){var M=j.nextSibling,F=j.nodeName;j[Es]||F==="SCRIPT"||F==="STYLE"||F==="LINK"&&j.rel.toLowerCase()==="stylesheet"||d.removeChild(j),j=M}}else d==="body"&&Pu(i.ownerDocument.body);d=w}while(d);Vl(l)}function uC(i,l){var d=i;i=0;do{var g=d.nextSibling;if(d.nodeType===1?l?(d._stashedDisplay=d.style.display,d.style.display="none"):(d.style.display=d._stashedDisplay||"",d.getAttribute("style")===""&&d.removeAttribute("style")):d.nodeType===3&&(l?(d._stashedText=d.nodeValue,d.nodeValue=""):d.nodeValue=d._stashedText||""),g&&g.nodeType===8)if(d=g.data,d==="/$"){if(i===0)break;i--}else d!=="$"&&d!=="$?"&&d!=="$~"&&d!=="$!"||i++;d=g}while(d)}function qx(i){var l=i.firstChild;for(l&&l.nodeType===10&&(l=l.nextSibling);l;){var d=l;switch(l=l.nextSibling,d.nodeName){case"HTML":case"HEAD":case"BODY":qx(d),va(d);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(d.rel.toLowerCase()==="stylesheet")continue}i.removeChild(d)}}function M3(i,l,d,g){for(;i.nodeType===1;){var w=d;if(i.nodeName.toLowerCase()!==l.toLowerCase()){if(!g&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(g){if(!i[Es])switch(l){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(j=i.getAttribute("rel"),j==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(j!==w.rel||i.getAttribute("href")!==(w.href==null||w.href===""?null:w.href)||i.getAttribute("crossorigin")!==(w.crossOrigin==null?null:w.crossOrigin)||i.getAttribute("title")!==(w.title==null?null:w.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(j=i.getAttribute("src"),(j!==(w.src==null?null:w.src)||i.getAttribute("type")!==(w.type==null?null:w.type)||i.getAttribute("crossorigin")!==(w.crossOrigin==null?null:w.crossOrigin))&&j&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(l==="input"&&i.type==="hidden"){var j=w.name==null?null:""+w.name;if(w.type==="hidden"&&i.getAttribute("name")===j)return i}else return i;if(i=hr(i.nextSibling),i===null)break}return null}function R3(i,l,d){if(l==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!d||(i=hr(i.nextSibling),i===null))return null;return i}function dC(i,l){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!l||(i=hr(i.nextSibling),i===null))return null;return i}function Kx(i){return i.data==="$?"||i.data==="$~"}function Gx(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function I3(i,l){var d=i.ownerDocument;if(i.data==="$~")i._reactRetry=l;else if(i.data!=="$?"||d.readyState!=="loading")l();else{var g=function(){l(),d.removeEventListener("DOMContentLoaded",g)};d.addEventListener("DOMContentLoaded",g),i._reactRetry=g}}function hr(i){for(;i!=null;i=i.nextSibling){var l=i.nodeType;if(l===1||l===3)break;if(l===8){if(l=i.data,l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"||l==="F!"||l==="F")break;if(l==="/$"||l==="/&")return null}}return i}var Zx=null;function fC(i){i=i.nextSibling;for(var l=0;i;){if(i.nodeType===8){var d=i.data;if(d==="/$"||d==="/&"){if(l===0)return hr(i.nextSibling);l--}else d!=="$"&&d!=="$!"&&d!=="$?"&&d!=="$~"&&d!=="&"||l++}i=i.nextSibling}return null}function hC(i){i=i.previousSibling;for(var l=0;i;){if(i.nodeType===8){var d=i.data;if(d==="$"||d==="$!"||d==="$?"||d==="$~"||d==="&"){if(l===0)return i;l--}else d!=="/$"&&d!=="/&"||l++}i=i.previousSibling}return null}function mC(i,l,d){switch(l=Eh(d),i){case"html":if(i=l.documentElement,!i)throw Error(r(452));return i;case"head":if(i=l.head,!i)throw Error(r(453));return i;case"body":if(i=l.body,!i)throw Error(r(454));return i;default:throw Error(r(451))}}function Pu(i){for(var l=i.attributes;l.length;)i.removeAttributeNode(l[0]);va(i)}var mr=new Map,pC=new Set;function Ah(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Da=G.d;G.d={f:_3,r:O3,D:$3,C:L3,L:P3,m:D3,X:B3,S:z3,M:U3};function _3(){var i=Da.f(),l=yh();return i||l}function O3(i){var l=rr(i);l!==null&&l.tag===5&&l.type==="form"?I1(l):Da.r(i)}var Bl=typeof document>"u"?null:document;function gC(i,l,d){var g=Bl;if(g&&typeof l=="string"&&l){var w=ft(l);w='link[rel="'+i+'"][href="'+w+'"]',typeof d=="string"&&(w+='[crossorigin="'+d+'"]'),pC.has(w)||(pC.add(w),i={rel:i,crossOrigin:d,href:l},g.querySelector(w)===null&&(l=g.createElement("link"),ss(l,"link",i),un(l),g.head.appendChild(l)))}}function $3(i){Da.D(i),gC("dns-prefetch",i,null)}function L3(i,l){Da.C(i,l),gC("preconnect",i,l)}function P3(i,l,d){Da.L(i,l,d);var g=Bl;if(g&&i&&l){var w='link[rel="preload"][as="'+ft(l)+'"]';l==="image"&&d&&d.imageSrcSet?(w+='[imagesrcset="'+ft(d.imageSrcSet)+'"]',typeof d.imageSizes=="string"&&(w+='[imagesizes="'+ft(d.imageSizes)+'"]')):w+='[href="'+ft(i)+'"]';var j=w;switch(l){case"style":j=Ul(i);break;case"script":j=Fl(i)}mr.has(j)||(i=x({rel:"preload",href:l==="image"&&d&&d.imageSrcSet?void 0:i,as:l},d),mr.set(j,i),g.querySelector(w)!==null||l==="style"&&g.querySelector(Du(j))||l==="script"&&g.querySelector(zu(j))||(l=g.createElement("link"),ss(l,"link",i),un(l),g.head.appendChild(l)))}}function D3(i,l){Da.m(i,l);var d=Bl;if(d&&i){var g=l&&typeof l.as=="string"?l.as:"script",w='link[rel="modulepreload"][as="'+ft(g)+'"][href="'+ft(i)+'"]',j=w;switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":j=Fl(i)}if(!mr.has(j)&&(i=x({rel:"modulepreload",href:i},l),mr.set(j,i),d.querySelector(w)===null)){switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(d.querySelector(zu(j)))return}g=d.createElement("link"),ss(g,"link",i),un(g),d.head.appendChild(g)}}}function z3(i,l,d){Da.S(i,l,d);var g=Bl;if(g&&i){var w=ar(g).hoistableStyles,j=Ul(i);l=l||"default";var M=w.get(j);if(!M){var F={loading:0,preload:null};if(M=g.querySelector(Du(j)))F.loading=5;else{i=x({rel:"stylesheet",href:i,"data-precedence":l},d),(d=mr.get(j))&&Yx(i,d);var J=M=g.createElement("link");un(J),ss(J,"link",i),J._p=new Promise(function(me,we){J.onload=me,J.onerror=we}),J.addEventListener("load",function(){F.loading|=1}),J.addEventListener("error",function(){F.loading|=2}),F.loading|=4,Th(M,l,g)}M={type:"stylesheet",instance:M,count:1,state:F},w.set(j,M)}}}function B3(i,l){Da.X(i,l);var d=Bl;if(d&&i){var g=ar(d).hoistableScripts,w=Fl(i),j=g.get(w);j||(j=d.querySelector(zu(w)),j||(i=x({src:i,async:!0},l),(l=mr.get(w))&&Xx(i,l),j=d.createElement("script"),un(j),ss(j,"link",i),d.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},g.set(w,j))}}function U3(i,l){Da.M(i,l);var d=Bl;if(d&&i){var g=ar(d).hoistableScripts,w=Fl(i),j=g.get(w);j||(j=d.querySelector(zu(w)),j||(i=x({src:i,async:!0,type:"module"},l),(l=mr.get(w))&&Xx(i,l),j=d.createElement("script"),un(j),ss(j,"link",i),d.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},g.set(w,j))}}function vC(i,l,d,g){var w=(w=ne.current)?Ah(w):null;if(!w)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof d.precedence=="string"&&typeof d.href=="string"?(l=Ul(d.href),d=ar(w).hoistableStyles,g=d.get(l),g||(g={type:"style",instance:null,count:0,state:null},d.set(l,g)),g):{type:"void",instance:null,count:0,state:null};case"link":if(d.rel==="stylesheet"&&typeof d.href=="string"&&typeof d.precedence=="string"){i=Ul(d.href);var j=ar(w).hoistableStyles,M=j.get(i);if(M||(w=w.ownerDocument||w,M={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},j.set(i,M),(j=w.querySelector(Du(i)))&&!j._p&&(M.instance=j,M.state.loading=5),mr.has(i)||(d={rel:"preload",as:"style",href:d.href,crossOrigin:d.crossOrigin,integrity:d.integrity,media:d.media,hrefLang:d.hrefLang,referrerPolicy:d.referrerPolicy},mr.set(i,d),j||F3(w,i,d,M.state))),l&&g===null)throw Error(r(528,""));return M}if(l&&g!==null)throw Error(r(529,""));return null;case"script":return l=d.async,d=d.src,typeof d=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=Fl(d),d=ar(w).hoistableScripts,g=d.get(l),g||(g={type:"script",instance:null,count:0,state:null},d.set(l,g)),g):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function Ul(i){return'href="'+ft(i)+'"'}function Du(i){return'link[rel="stylesheet"]['+i+"]"}function xC(i){return x({},i,{"data-precedence":i.precedence,precedence:null})}function F3(i,l,d,g){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?g.loading=1:(l=i.createElement("link"),g.preload=l,l.addEventListener("load",function(){return g.loading|=1}),l.addEventListener("error",function(){return g.loading|=2}),ss(l,"link",d),un(l),i.head.appendChild(l))}function Fl(i){return'[src="'+ft(i)+'"]'}function zu(i){return"script[async]"+i}function yC(i,l,d){if(l.count++,l.instance===null)switch(l.type){case"style":var g=i.querySelector('style[data-href~="'+ft(d.href)+'"]');if(g)return l.instance=g,un(g),g;var w=x({},d,{"data-href":d.href,"data-precedence":d.precedence,href:null,precedence:null});return g=(i.ownerDocument||i).createElement("style"),un(g),ss(g,"style",w),Th(g,d.precedence,i),l.instance=g;case"stylesheet":w=Ul(d.href);var j=i.querySelector(Du(w));if(j)return l.state.loading|=4,l.instance=j,un(j),j;g=xC(d),(w=mr.get(w))&&Yx(g,w),j=(i.ownerDocument||i).createElement("link"),un(j);var M=j;return M._p=new Promise(function(F,J){M.onload=F,M.onerror=J}),ss(j,"link",g),l.state.loading|=4,Th(j,d.precedence,i),l.instance=j;case"script":return j=Fl(d.src),(w=i.querySelector(zu(j)))?(l.instance=w,un(w),w):(g=d,(w=mr.get(j))&&(g=x({},d),Xx(g,w)),i=i.ownerDocument||i,w=i.createElement("script"),un(w),ss(w,"link",g),i.head.appendChild(w),l.instance=w);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(g=l.instance,l.state.loading|=4,Th(g,d.precedence,i));return l.instance}function Th(i,l,d){for(var g=d.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),w=g.length?g[g.length-1]:null,j=w,M=0;M<g.length;M++){var F=g[M];if(F.dataset.precedence===l)j=F;else if(j!==w)break}j?j.parentNode.insertBefore(i,j.nextSibling):(l=d.nodeType===9?d.head:d,l.insertBefore(i,l.firstChild))}function Yx(i,l){i.crossOrigin==null&&(i.crossOrigin=l.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=l.referrerPolicy),i.title==null&&(i.title=l.title)}function Xx(i,l){i.crossOrigin==null&&(i.crossOrigin=l.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=l.referrerPolicy),i.integrity==null&&(i.integrity=l.integrity)}var Mh=null;function bC(i,l,d){if(Mh===null){var g=new Map,w=Mh=new Map;w.set(d,g)}else w=Mh,g=w.get(d),g||(g=new Map,w.set(d,g));if(g.has(i))return g;for(g.set(i,null),d=d.getElementsByTagName(i),w=0;w<d.length;w++){var j=d[w];if(!(j[Es]||j[Et]||i==="link"&&j.getAttribute("rel")==="stylesheet")&&j.namespaceURI!=="http://www.w3.org/2000/svg"){var M=j.getAttribute(l)||"";M=i+M;var F=g.get(M);F?F.push(j):g.set(M,[j])}}return g}function wC(i,l,d){i=i.ownerDocument||i,i.head.insertBefore(d,l==="title"?i.querySelector("head > title"):null)}function V3(i,l,d){if(d===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function jC(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function H3(i,l,d,g){if(d.type==="stylesheet"&&(typeof g.media!="string"||matchMedia(g.media).matches!==!1)&&(d.state.loading&4)===0){if(d.instance===null){var w=Ul(g.href),j=l.querySelector(Du(w));if(j){l=j._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=Rh.bind(i),l.then(i,i)),d.state.loading|=4,d.instance=j,un(j);return}j=l.ownerDocument||l,g=xC(g),(w=mr.get(w))&&Yx(g,w),j=j.createElement("link"),un(j);var M=j;M._p=new Promise(function(F,J){M.onload=F,M.onerror=J}),ss(j,"link",g),d.instance=j}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(d,l),(l=d.state.preload)&&(d.state.loading&3)===0&&(i.count++,d=Rh.bind(i),l.addEventListener("load",d),l.addEventListener("error",d))}}var Qx=0;function W3(i,l){return i.stylesheets&&i.count===0&&_h(i,i.stylesheets),0<i.count||0<i.imgCount?function(d){var g=setTimeout(function(){if(i.stylesheets&&_h(i,i.stylesheets),i.unsuspend){var j=i.unsuspend;i.unsuspend=null,j()}},6e4+l);0<i.imgBytes&&Qx===0&&(Qx=62500*S3());var w=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&_h(i,i.stylesheets),i.unsuspend)){var j=i.unsuspend;i.unsuspend=null,j()}},(i.imgBytes>Qx?50:800)+l);return i.unsuspend=d,function(){i.unsuspend=null,clearTimeout(g),clearTimeout(w)}}:null}function Rh(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)_h(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Ih=null;function _h(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Ih=new Map,l.forEach(q3,i),Ih=null,Rh.call(i))}function q3(i,l){if(!(l.state.loading&4)){var d=Ih.get(i);if(d)var g=d.get(null);else{d=new Map,Ih.set(i,d);for(var w=i.querySelectorAll("link[data-precedence],style[data-precedence]"),j=0;j<w.length;j++){var M=w[j];(M.nodeName==="LINK"||M.getAttribute("media")!=="not all")&&(d.set(M.dataset.precedence,M),g=M)}g&&d.set(null,g)}w=l.instance,M=w.getAttribute("data-precedence"),j=d.get(M)||g,j===g&&d.set(null,w),d.set(M,w),this.count++,g=Rh.bind(this),w.addEventListener("load",g),w.addEventListener("error",g),j?j.parentNode.insertBefore(w,j.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(w,i.firstChild)),l.state.loading|=4}}var Bu={$$typeof:k,Provider:null,Consumer:null,_currentValue:V,_currentValue2:V,_threadCount:0};function K3(i,l,d,g,w,j,M,F,J){this.tag=1,this.containerInfo=i,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=Rt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Rt(0),this.hiddenUpdates=Rt(null),this.identifierPrefix=g,this.onUncaughtError=w,this.onCaughtError=j,this.onRecoverableError=M,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=J,this.incompleteTransitions=new Map}function kC(i,l,d,g,w,j,M,F,J,me,we,Ce){return i=new K3(i,l,d,M,J,me,we,Ce,F),l=1,j===!0&&(l|=24),j=Vs(3,null,null,l),i.current=j,j.stateNode=i,l=Rv(),l.refCount++,i.pooledCache=l,l.refCount++,j.memoizedState={element:g,isDehydrated:d,cache:l},$v(j),i}function NC(i){return i?(i=yl,i):yl}function SC(i,l,d,g,w,j){w=NC(w),g.context===null?g.context=w:g.pendingContext=w,g=ei(l),g.payload={element:d},j=j===void 0?null:j,j!==null&&(g.callback=j),d=ti(i,g,l),d!==null&&(Os(d,i,l),xu(d,i,l))}function CC(i,l){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var d=i.retryLane;i.retryLane=d!==0&&d<l?d:l}}function Jx(i,l){CC(i,l),(i=i.alternate)&&CC(i,l)}function EC(i){if(i.tag===13||i.tag===31){var l=oo(i,67108864);l!==null&&Os(l,i,67108864),Jx(i,67108864)}}function AC(i){if(i.tag===13||i.tag===31){var l=Gs();l=Ct(l);var d=oo(i,l);d!==null&&Os(d,i,l),Jx(i,l)}}var Oh=!0;function G3(i,l,d,g){var w=$.T;$.T=null;var j=G.p;try{G.p=2,ey(i,l,d,g)}finally{G.p=j,$.T=w}}function Z3(i,l,d,g){var w=$.T;$.T=null;var j=G.p;try{G.p=8,ey(i,l,d,g)}finally{G.p=j,$.T=w}}function ey(i,l,d,g){if(Oh){var w=ty(g);if(w===null)Bx(i,l,g,$h,d),MC(i,g);else if(X3(w,i,l,d,g))g.stopPropagation();else if(MC(i,g),l&4&&-1<Y3.indexOf(i)){for(;w!==null;){var j=rr(w);if(j!==null)switch(j.tag){case 3:if(j=j.stateNode,j.current.memoizedState.isDehydrated){var M=nt(j.pendingLanes);if(M!==0){var F=j;for(F.pendingLanes|=2,F.entangledLanes|=2;M;){var J=1<<31-Ae(M);F.entanglements[1]|=J,M&=~J}Kr(j),(Yt&6)===0&&(vh=ze()+500,Ou(0))}}break;case 31:case 13:F=oo(j,2),F!==null&&Os(F,j,2),yh(),Jx(j,2)}if(j=ty(g),j===null&&Bx(i,l,g,$h,d),j===w)break;w=j}w!==null&&g.stopPropagation()}else Bx(i,l,g,null,d)}}function ty(i){return i=sv(i),ny(i)}var $h=null;function ny(i){if($h=null,i=Bs(i),i!==null){var l=o(i);if(l===null)i=null;else{var d=l.tag;if(d===13){if(i=c(l),i!==null)return i;i=null}else if(d===31){if(i=u(l),i!==null)return i;i=null}else if(d===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;i=null}else l!==i&&(i=null)}}return $h=i,null}function TC(i){switch(i){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($e()){case st:return 2;case rt:return 8;case Xe:case dt:return 32;case jt:return 268435456;default:return 32}default:return 32}}var sy=!1,fi=null,hi=null,mi=null,Uu=new Map,Fu=new Map,pi=[],Y3="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 MC(i,l){switch(i){case"focusin":case"focusout":fi=null;break;case"dragenter":case"dragleave":hi=null;break;case"mouseover":case"mouseout":mi=null;break;case"pointerover":case"pointerout":Uu.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":Fu.delete(l.pointerId)}}function Vu(i,l,d,g,w,j){return i===null||i.nativeEvent!==j?(i={blockedOn:l,domEventName:d,eventSystemFlags:g,nativeEvent:j,targetContainers:[w]},l!==null&&(l=rr(l),l!==null&&EC(l)),i):(i.eventSystemFlags|=g,l=i.targetContainers,w!==null&&l.indexOf(w)===-1&&l.push(w),i)}function X3(i,l,d,g,w){switch(l){case"focusin":return fi=Vu(fi,i,l,d,g,w),!0;case"dragenter":return hi=Vu(hi,i,l,d,g,w),!0;case"mouseover":return mi=Vu(mi,i,l,d,g,w),!0;case"pointerover":var j=w.pointerId;return Uu.set(j,Vu(Uu.get(j)||null,i,l,d,g,w)),!0;case"gotpointercapture":return j=w.pointerId,Fu.set(j,Vu(Fu.get(j)||null,i,l,d,g,w)),!0}return!1}function RC(i){var l=Bs(i.target);if(l!==null){var d=o(l);if(d!==null){if(l=d.tag,l===13){if(l=c(d),l!==null){i.blockedOn=l,tn(i.priority,function(){AC(d)});return}}else if(l===31){if(l=u(d),l!==null){i.blockedOn=l,tn(i.priority,function(){AC(d)});return}}else if(l===3&&d.stateNode.current.memoizedState.isDehydrated){i.blockedOn=d.tag===3?d.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Lh(i){if(i.blockedOn!==null)return!1;for(var l=i.targetContainers;0<l.length;){var d=ty(i.nativeEvent);if(d===null){d=i.nativeEvent;var g=new d.constructor(d.type,d);nv=g,d.target.dispatchEvent(g),nv=null}else return l=rr(d),l!==null&&EC(l),i.blockedOn=d,!1;l.shift()}return!0}function IC(i,l,d){Lh(i)&&d.delete(l)}function Q3(){sy=!1,fi!==null&&Lh(fi)&&(fi=null),hi!==null&&Lh(hi)&&(hi=null),mi!==null&&Lh(mi)&&(mi=null),Uu.forEach(IC),Fu.forEach(IC)}function Ph(i,l){i.blockedOn===l&&(i.blockedOn=null,sy||(sy=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Q3)))}var Dh=null;function _C(i){Dh!==i&&(Dh=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Dh===i&&(Dh=null);for(var l=0;l<i.length;l+=3){var d=i[l],g=i[l+1],w=i[l+2];if(typeof g!="function"){if(ny(g||d)===null)continue;break}var j=rr(d);j!==null&&(i.splice(l,3),l-=3,tx(j,{pending:!0,data:w,method:d.method,action:g},g,w))}}))}function Vl(i){function l(J){return Ph(J,i)}fi!==null&&Ph(fi,i),hi!==null&&Ph(hi,i),mi!==null&&Ph(mi,i),Uu.forEach(l),Fu.forEach(l);for(var d=0;d<pi.length;d++){var g=pi[d];g.blockedOn===i&&(g.blockedOn=null)}for(;0<pi.length&&(d=pi[0],d.blockedOn===null);)RC(d),d.blockedOn===null&&pi.shift();if(d=(i.ownerDocument||i).$$reactFormReplay,d!=null)for(g=0;g<d.length;g+=3){var w=d[g],j=d[g+1],M=w[Tt]||null;if(typeof j=="function")M||_C(d);else if(M){var F=null;if(j&&j.hasAttribute("formAction")){if(w=j,M=j[Tt]||null)F=M.formAction;else if(ny(w)!==null)continue}else F=M.action;typeof F=="function"?d[g+1]=F:(d.splice(g,3),g-=3),_C(d)}}}function OC(){function i(j){j.canIntercept&&j.info==="react-transition"&&j.intercept({handler:function(){return new Promise(function(M){return w=M})},focusReset:"manual",scroll:"manual"})}function l(){w!==null&&(w(),w=null),g||setTimeout(d,20)}function d(){if(!g&&!navigation.transition){var j=navigation.currentEntry;j&&j.url!=null&&navigation.navigate(j.url,{state:j.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var g=!1,w=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",l),navigation.addEventListener("navigateerror",l),setTimeout(d,100),function(){g=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",l),navigation.removeEventListener("navigateerror",l),w!==null&&(w(),w=null)}}}function ry(i){this._internalRoot=i}zh.prototype.render=ry.prototype.render=function(i){var l=this._internalRoot;if(l===null)throw Error(r(409));var d=l.current,g=Gs();SC(d,g,i,l,null,null)},zh.prototype.unmount=ry.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var l=i.containerInfo;SC(i.current,2,null,i,null,null),yh(),l[Jn]=null}};function zh(i){this._internalRoot=i}zh.prototype.unstable_scheduleHydration=function(i){if(i){var l=$n();i={blockedOn:null,target:i,priority:l};for(var d=0;d<pi.length&&l!==0&&l<pi[d].priority;d++);pi.splice(d,0,i),d===0&&RC(i)}};var $C=t.version;if($C!=="19.2.3")throw Error(r(527,$C,"19.2.3"));G.findDOMNode=function(i){var l=i._reactInternals;if(l===void 0)throw typeof i.render=="function"?Error(r(188)):(i=Object.keys(i).join(","),Error(r(268,i)));return i=h(l),i=i!==null?p(i):null,i=i===null?null:i.stateNode,i};var J3={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:$,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Bh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Bh.isDisabled&&Bh.supportsFiber)try{Ht=Bh.inject(J3),ie=Bh}catch{}}return Wu.createRoot=function(i,l){if(!a(i))throw Error(r(299));var d=!1,g="",w=F1,j=V1,M=H1;return l!=null&&(l.unstable_strictMode===!0&&(d=!0),l.identifierPrefix!==void 0&&(g=l.identifierPrefix),l.onUncaughtError!==void 0&&(w=l.onUncaughtError),l.onCaughtError!==void 0&&(j=l.onCaughtError),l.onRecoverableError!==void 0&&(M=l.onRecoverableError)),l=kC(i,1,!1,null,null,d,g,null,w,j,M,OC),i[Jn]=l.current,zx(i),new ry(l)},Wu.hydrateRoot=function(i,l,d){if(!a(i))throw Error(r(299));var g=!1,w="",j=F1,M=V1,F=H1,J=null;return d!=null&&(d.unstable_strictMode===!0&&(g=!0),d.identifierPrefix!==void 0&&(w=d.identifierPrefix),d.onUncaughtError!==void 0&&(j=d.onUncaughtError),d.onCaughtError!==void 0&&(M=d.onCaughtError),d.onRecoverableError!==void 0&&(F=d.onRecoverableError),d.formState!==void 0&&(J=d.formState)),l=kC(i,1,!0,l,d??null,g,w,J,j,M,F,OC),l.context=NC(null),d=l.current,g=Gs(),g=Ct(g),w=ei(g),w.callback=null,ti(d,w,g),d=g,l.current.lanes=d,Gn(l,d),Kr(l),i[Jn]=l.current,zx(i),new zh(l)},Wu.version="19.2.3",Wu}var WC;function c6(){if(WC)return oy.exports;WC=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),oy.exports=l6(),oy.exports}var u6=c6();const j2=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();const d6=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const f6=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase());const qC=e=>{const t=f6(e);return t.charAt(0).toUpperCase()+t.slice(1)};var h6={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"};const m6=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const p6=m.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:a="",children:o,iconNode:c,...u},f)=>m.createElement("svg",{ref:f,...h6,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:j2("lucide",a),...!o&&!m6(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,p])=>m.createElement(h,p)),...Array.isArray(o)?o:[o]]));const Ke=(e,t)=>{const n=m.forwardRef(({className:r,...a},o)=>m.createElement(p6,{ref:o,iconNode:t,className:j2(`lucide-${d6(qC(e))}`,`lucide-${e}`,r),...a}));return n.displayName=qC(e),n};const g6=[["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"}]],k2=Ke("activity",g6);const v6=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],x6=Ke("archive",v6);const y6=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],b6=Ke("arrow-left",y6);const w6=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],j6=Ke("arrow-right",w6);const k6=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],N6=Ke("book-open",k6);const S6=[["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"}]],dg=Ke("bot",S6);const C6=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],fg=Ke("check",C6);const E6=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Xo=Ke("chevron-down",E6);const A6=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],hg=Ke("chevron-right",A6);const T6=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Ww=Ke("chevron-up",T6);const M6=[["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"}]],R6=Ke("circle-alert",M6);const I6=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Dm=Ke("circle-check",I6);const _6=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6h4",key:"135r8i"}]],O6=Ke("clock-3",_6);const $6=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],L6=Ke("clock",$6);const P6=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],D6=Ke("code-xml",P6);const z6=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]],Zb=Ke("compass",z6);const B6=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],mg=Ke("copy",B6);const U6=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],F6=Ke("corner-down-left",U6);const V6=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],H6=Ke("cpu",V6);const W6=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]],q6=Ke("crosshair",W6);const K6=[["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"}]],Ei=Ke("database",K6);const G6=[["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"}]],wr=Ke("external-link",G6);const Z6=[["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"}]],Y6=Ke("eye",Z6);const X6=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],dy=Ke("file-braces",X6);const Q6=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]],Yb=Ke("file-search",Q6);const J6=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Dd=Ke("file-text",J6);const eB=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],tB=Ke("folder-open",eB);const nB=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],fy=Ke("folder-tree",nB);const sB=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],N2=Ke("folder",sB);const rB=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],aB=Ke("git-branch",rB);const iB=[["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"}]],oB=Ke("hash",iB);const lB=[["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"}]],cB=Ke("history",lB);const uB=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],dB=Ke("image",uB);const fB=[["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"}]],S2=Ke("key-round",fB);const hB=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Kn=Ke("loader-circle",hB);const mB=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]],pB=Ke("map",mB);const gB=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],qw=Ke("maximize-2",gB);const vB=[["path",{d:"M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",key:"q8bfy3"}],["path",{d:"M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14",key:"1853fq"}],["path",{d:"M8 6v8",key:"15ugcq"}]],xB=Ke("megaphone",vB);const yB=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],bB=Ke("message-circle",yB);const wB=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]],Xb=Ke("message-square-text",wB);const jB=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],pg=Ke("message-square",jB);const kB=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],Kw=Ke("mic",kB);const NB=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],C2=Ke("minimize-2",NB);const SB=[["path",{d:"M5 12h14",key:"1ays0h"}]],CB=Ke("minus",SB);const EB=[["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"}]],AB=Ke("panel-left-close",EB);const TB=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],MB=Ke("panel-left-open",TB);const RB=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],IB=Ke("panel-right-close",RB);const _B=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],OB=Ke("panel-right-open",_B);const $B=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],LB=Ke("paperclip",$B);const PB=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]],DB=Ke("pin-off",PB);const zB=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],BB=Ke("pin",zB);const UB=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],FB=Ke("plus",UB);const VB=[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]],E2=Ke("radio-tower",VB);const HB=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],WB=Ke("radio",HB);const qB=[["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"}]],zd=Ke("refresh-cw",qB);const KB=[["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}],["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09",key:"u4xsad"}],["path",{d:"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z",key:"676m9"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05",key:"92ym6u"}]],KC=Ke("rocket",KB);const GB=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],A2=Ke("scroll-text",GB);const ZB=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Tc=Ke("search",ZB);const YB=[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]],XB=Ke("send-horizontal",YB);const QB=[["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"}]],JB=Ke("send",QB);const e8=[["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"}]],t8=Ke("server",e8);const n8=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],gg=Ke("settings",n8);const s8=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],r8=Ke("sliders-horizontal",s8);const a8=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Gw=Ke("sparkles",a8);const i8=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],df=Ke("square",i8);const o8=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Zw=Ke("terminal",o8);const l8=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],c8=Ke("trash-2",l8);const u8=[["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"}]],d8=Ke("user-plus",u8);const f8=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],T2=Ke("volume-2",f8);const h8=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]],M2=Ke("volume-x",h8);const m8=[["path",{d:"m10.586 5.414-5.172 5.172",key:"4mc350"}],["path",{d:"m18.586 13.414-5.172 5.172",key:"8c96vv"}],["path",{d:"M6 12h12",key:"8npq4p"}],["circle",{cx:"12",cy:"20",r:"2",key:"144qzu"}],["circle",{cx:"12",cy:"4",r:"2",key:"muu5ef"}],["circle",{cx:"20",cy:"12",r:"2",key:"1xzzfp"}],["circle",{cx:"4",cy:"12",r:"2",key:"1hvhnz"}]],GC=Ke("waypoints",m8);const p8=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],g8=Ke("wrench",p8);const v8=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Bi=Ke("x",v8);function R2(e="h",t=12){const n=globalThis.crypto;if(n&&typeof n.randomUUID=="function"){const a=n.randomUUID().replace(/-/g,"").slice(0,t);return e?`${e}_${a}`:a}if(n&&typeof n.getRandomValues=="function"){const a=new Uint8Array(Math.ceil(t/2));n.getRandomValues(a);const o=Array.from(a,c=>c.toString(16).padStart(2,"0")).join("").slice(0,t);return e?`${e}_${o}`:o}const r=Math.random().toString(36).slice(2,2+t);return e?`${e}_${r}`:r}var x8=200,y8=()=>Date.now(),b8=()=>R2("h",12),w8=e=>e instanceof Error?{name:e.name,message:e.message}:{message:String(e)},j8=()=>{const e=globalThis;return e.H_OBSERVABILITY===!0||e.H_DEBUG===!0},k8=class{constructor(){this.sinks=new Map}get size(){return this.sinks.size}add(e,t={}){const n=t.kinds?new Set(t.kinds):null;return this.sinks.set(e,{kinds:n}),()=>{this.sinks.delete(e)}}emit(e){for(const[t,n]of this.sinks)if(!(n.kinds&&!n.kinds.has(e.kind)))try{t(e)}catch{}}},N8=class{constructor(e){this.owner=e}log(e,t,n={}){const r={id:this.owner.createId(),kind:"log",timestamp:this.owner.now(),level:e,message:t,category:n.category,data:n.data};return this.owner.emit(r),r}debug(e,t){return this.log("debug",e,t)}info(e,t){return this.log("info",e,t)}warn(e,t){return this.log("warn",e,t)}error(e,t){return this.log("error",e,t)}},S8=class{constructor(e){this.owner=e}counter(e,t=1,n={}){return this.record("counter",e,t,n)}gauge(e,t,n={}){return this.record("gauge",e,t,n)}timing(e,t,n={}){return this.record("timing",e,t,{...n,unit:n.unit??"ms"})}record(e,t,n,r){const a={id:this.owner.createId(),kind:"metric",timestamp:this.owner.now(),metricType:e,name:t,value:n,category:r.category,unit:r.unit,tags:r.tags,data:r.data};return this.owner.emit(a),a}},C8=class{constructor(e,t){this.owner=e,this.event=t,this.ended=!1,this.owner.emit({...t})}end(e){if(this.ended)return this.event;const t=this.owner.now();return this.ended=!0,this.event.endTime=t,this.event.durationMs=Math.max(0,t-this.event.startTime),this.event.status="ok",e&&(this.event.data={...this.event.data,...e}),this.owner.emit({...this.event}),this.event}error(e,t){if(this.ended)return this.event;const n=this.owner.now();return this.ended=!0,this.event.endTime=n,this.event.durationMs=Math.max(0,n-this.event.startTime),this.event.status="error",this.event.error=w8(e),t&&(this.event.data={...this.event.data,...t}),this.owner.emit({...this.event}),this.event}},E8=class{constructor(e){this.owner=e}start(e,t={}){const n=this.owner.createId(),r=this.owner.now(),a={id:n,kind:"span",timestamp:r,name:e,traceId:t.traceId??n,parentId:t.parentId,startTime:r,status:"active",category:t.category,data:t.data};return new C8(this.owner,a)}},A8=class I2{constructor(t={}){this.logger=new N8(this),this.metrics=new S8(this),this.trace=new E8(this),this.sinks=new k8,this.buffer=[],this.enabled=t.enabled??!0,this.maxBufferSize=Math.max(0,t.maxBufferSize??x8),this.nowFn=t.now??y8,this.createIdFn=t.createId??b8}static global(t={}){return new I2({...t,enabled:t.enabled??j8()})}get isEnabled(){return this.enabled}setEnabled(t){this.enabled=t}subscribe(t,n={}){const r=this.sinks.add(t,n);if(n.replay)for(const a of this.buffer)n.kinds&&!n.kinds.includes(a.kind)||t(a);return r}flush(){const t=this.buffer.slice();return this.buffer.length=0,t}snapshot(){return this.buffer.slice()}emit(t){return this.enabled&&(this.remember(t),this.sinks.size>0&&this.sinks.emit(t)),t}now(){return this.nowFn()}createId(){return this.createIdFn()}remember(t){this.maxBufferSize!==0&&(this.buffer.push(t),this.buffer.length>this.maxBufferSize&&this.buffer.splice(0,this.buffer.length-this.maxBufferSize))}},Qb=A8.global(),T8=m.createContext(null);function M8(){return m.useContext(T8)}function R8(e){const t=M8();return!t||e.startsWith("inst:")||e.startsWith("hudson.ws.")?e:`inst:${t.instanceId}:${e}`}function I8(e){try{const t=localStorage.getItem(e);if(t)return JSON.parse(t)}catch{}}function _8(e,t){try{localStorage.setItem(e,JSON.stringify(t)),window.dispatchEvent(new CustomEvent("hudson:saved",{detail:{key:e}}))}catch{}}var O8=()=>()=>{},$8=()=>!0,L8=()=>!1;function P8(){return m.useSyncExternalStore(O8,$8,L8)}function Lr(e,t){const n=P8(),r=R8(e),[a,o]=m.useState(t),c=m.useRef(!1);if(n&&!c.current){c.current=!0;const u=I8(r);u!==void 0&&o(u)}return m.useEffect(()=>{n&&_8(r,a)},[r,a,n]),[a,o]}function _2(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function D8(e,t){const n=e.toLowerCase();return n.includes("secret")||n.includes("token")||n.includes("password")||n.includes("apikey")||n.includes("api_key")||t[0]==="set_environment_variable"&&n==="value"}function Bd(e,t=[]){if(Array.isArray(e))return e.map(r=>Bd(r,t));if(!_2(e))return e;const n={};for(const[r,a]of Object.entries(e))n[r]=D8(r,t)?"[redacted]":Bd(a,[...t,r]);return n}function z8(e){if(e)return e instanceof Error?{name:e.name,message:e.message}:_2(e)?Bd(e):{message:String(e)}}function B8(e,t=Qb){const n=e.status??"started",r=n==="failed"?"error":"info";return t.logger[r]("hudson.agent.action",{category:"agent-action",data:{triggeredBy:"agent",source:e.source??"external",origin:e.origin,actor:e.actor,status:n,toolset:e.toolset,chatId:e.chatId,action:e.action,commandId:e.commandId,appId:e.appId,appName:e.appName,workspaceId:e.workspaceId,workspaceName:e.workspaceName,traceId:e.traceId,parentTraceId:e.parentTraceId,args:e.args?Bd(e.args,[e.action??""]):void 0,metadata:e.metadata?Bd(e.metadata):void 0,error:z8(e.error)}})}const U8="modulepreload",F8=function(e){return"/"+e},ZC={},zm=function(t,n,r){let a=Promise.resolve();if(n&&n.length>0){let f=function(h){return Promise.all(h.map(p=>Promise.resolve(p).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),u=c?.nonce||c?.getAttribute("nonce");a=f(n.map(h=>{if(h=F8(h),h in ZC)return;ZC[h]=!0;const p=h.endsWith(".css"),x=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${x}`))return;const v=document.createElement("link");if(v.rel=p?"stylesheet":U8,p||(v.as="script"),v.crossOrigin="",v.href=h,u&&v.setAttribute("nonce",u),document.head.appendChild(v),p)return new Promise((y,b)=>{v.addEventListener("load",y),v.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(c){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=c,window.dispatchEvent(u),!u.defaultPrevented)throw c}return a.then(c=>{for(const u of c||[])u.status==="rejected"&&o(u.reason);return t().catch(o)})};var V8=m.createContext(null);function H8(){return m.useContext(V8)}var O2=["local","url","sharedConfig","env"];function $2(e){const t=W8(e),n=e.audienceIncludes??q8(e.audienceOrder),r=new Set;function a(u){!e.warnOnUnknown||r.has(u)||(r.add(u),typeof console<"u"&&typeof console.warn=="function"&&console.warn(`[hudsonkit/flags] Unknown feature flag "${u}" resolved false.`))}const o=e.registry;function c(u){const f=o[u];if(!f)return a(u),{key:u,enabled:!1,value:!1,layer:"default",audience:t,reason:"unknown-flag"};const h=K8(e.layers,u);return h?{key:u,enabled:h.value,value:h.value,layer:h.layer,audience:t,requiredTier:f.tier,reason:"override",definition:f}:f.defaultEnabled?f.tier&&!n(t,f.tier)?{key:u,enabled:!1,value:!1,layer:"default",audience:t,requiredTier:f.tier,reason:"audience-denied",definition:f}:{key:u,enabled:!0,value:!0,layer:"default",audience:t,requiredTier:f.tier,reason:"default",definition:f}:{key:u,enabled:!1,value:!1,layer:"default",audience:t,requiredTier:f.tier,reason:"default",definition:f}}return{registry:e.registry,isEnabled:u=>c(String(u)).enabled,explain:u=>c(String(u)),all:()=>Object.keys(e.registry).sort().map(c),audience:()=>t}}function W8(e){let t=e.audience.tier;for(const n of O2.slice().reverse()){const r=e.layers?.[n]?.audience;r&&(t=r)}return{...e.audience,tier:t}}function q8(e){return(t,n)=>{if(t.tier===n)return!0;if(!e||e.length===0)return!1;const r=e.indexOf(t.tier),a=e.indexOf(n);return r<0||a<0?!1:r>=a}}function K8(e,t){for(const n of O2){const r=G8(e?.[n]?.flags?.[t]);if(r!==null)return{layer:n,value:r}}return null}function G8(e){return e===!0||e==="on"?!0:e===!1||e==="off"?!1:null}function Z8(e){if(e===!0||e===!1)return e;if(typeof e=="number"){if(e===1)return!0;if(e===0)return!1}if(typeof e!="string")return;const t=e.trim().toLowerCase();if(["1","true","on","yes","enabled","enable"].includes(t))return!0;if(["0","false","off","no","disabled","disable"].includes(t))return!1;if(["default","null","unset","clear"].includes(t))return"default"}function Y8(e,t={}){const n=t.paramPrefix??"ff.",r=t.audienceParam??"ffAudience",a=typeof e=="string"?new URL(e,"http://hudson.local"):e,o={};let c;for(const[u,f]of a.searchParams.entries()){if(u===r&&f.trim()&&(c=f.trim()),!u.startsWith(n))continue;const h=u.slice(n.length),p=Z8(f);h&&p!==void 0&&(o[h]=p)}return{flags:o,audience:c}}var vc=1;function L2(e){if(typeof window>"u")return{version:vc};try{const t=window.localStorage?.getItem(e);return X8(t)}catch{return{version:vc}}}function hy(e,t){if(typeof window>"u")return;const n=P2(t),r=JSON.stringify(n);try{window.localStorage?.setItem(e,r)}catch{}Q8(e,r)}function X8(e){if(!e)return{version:vc};try{const t=JSON.parse(e);return!t||typeof t!="object"?{version:vc}:P2(t)}catch{return{version:vc}}}function P2(e){const t={version:vc};if(e.audience&&(t.audience=e.audience),e.flags&&typeof e.flags=="object"){t.flags={};for(const[n,r]of Object.entries(e.flags))(r===!0||r===!1)&&(t.flags[n]=r);Object.keys(t.flags).length===0&&delete t.flags}return t}function Q8(e,t){if(!(typeof document>"u"))try{const n=encodeURIComponent(t);document.cookie=`${encodeURIComponent(e)}=${n}; Path=/; SameSite=Lax; Max-Age=31536000`}catch{}}var J8="hudson.flags",D2=m.createContext(null);function eU({registry:e,audience:t,audienceOrder:n,audienceIncludes:r,initialLayers:a,storageKey:o=J8,warnOnUnknown:c=!1,children:u}){const[f,h]=m.useState(()=>{const y=a?.local;return{version:1,audience:y?.audience??void 0,flags:tU(y)}});m.useEffect(()=>{const y=L2(o);(y.audience||Object.keys(y.flags??{}).length>0)&&h(y)},[o]);const p=m.useMemo(()=>({...a,local:{...a?.local,audience:f.audience??a?.local?.audience,flags:{...a?.local?.flags??{},...f.flags??{}}}}),[a,f]),x=m.useMemo(()=>$2({registry:e,audience:t,audienceOrder:n,audienceIncludes:r,layers:p,warnOnUnknown:c}),[e,t,n,r,p,c]),v=m.useMemo(()=>({...x,layers:p,storageKey:o,setLocalOverride:(y,b)=>{h(C=>{const E={...C.flags??{}};b===null?delete E[y]:E[y]=b;const A={...C,version:1,flags:E};return hy(o,A),A})},setLocalAudienceOverride:y=>{h(b=>{const C={...b,version:1,audience:y??void 0};return hy(o,C),C})},resetLocalOverrides:()=>{const y={version:1};hy(o,y),h(y)}}),[x,p,o]);return s.jsx(D2.Provider,{value:v,children:u})}function z2(){return m.useContext(D2)}function la(e,t=!0){return z2()?.isEnabled(e)??t}function tU(e){if(!e?.flags)return;const t={};for(const[n,r]of Object.entries(e.flags))(r===!0||r===!1)&&(t[n]=r);return Object.keys(t).length>0?t:void 0}function nU({isOpen:e,onClose:t,audienceOptions:n}){const r=z2(),a=m.useMemo(()=>r?.all()??[],[r]);if(!e||!r)return null;const o=r.audience(),c=r.layers.local?.audience??"",u=n??rU(a,o.tier);return s.jsx("div",{className:"fixed inset-0 z-[110] flex items-start justify-center bg-background/45 pt-[10vh] backdrop-blur-[2px]",onClick:t,children:s.jsxs("div",{className:"max-h-[78vh] w-[780px] max-w-[94vw] overflow-hidden rounded-lg border border-border bg-popover shadow-2xl",onClick:f=>f.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-[12px] font-semibold uppercase tracking-[0.18em] text-foreground",children:"Feature Flags"}),s.jsxs("div",{className:"mt-1 text-[11px] font-mono text-muted-foreground",children:["Audience: ",s.jsx("span",{className:"text-foreground",children:o.tier})]})]}),s.jsx("button",{type:"button",className:"rounded border border-border px-2 py-1 text-[11px] text-muted-foreground hover:text-foreground",onClick:t,children:"Close"})]}),s.jsx("div",{className:"border-b border-border px-4 py-3",children:s.jsxs("label",{className:"flex items-center gap-2 text-[11px] font-mono text-muted-foreground",children:["Local audience override",s.jsxs("select",{className:"rounded border border-border bg-background px-2 py-1 text-foreground",value:c,onChange:f=>r.setLocalAudienceOverride(f.target.value||null),children:[s.jsxs("option",{value:"",children:["Default (",o.tier,")"]}),u.map(f=>s.jsx("option",{value:f,children:f},f))]})]})}),s.jsx("div",{className:"max-h-[52vh] overflow-auto",children:s.jsxs("table",{className:"w-full border-collapse text-left text-[11px]",children:[s.jsx("thead",{className:"sticky top-0 bg-card text-muted-foreground",children:s.jsxs("tr",{children:[s.jsx("th",{className:"border-b border-border px-3 py-2 font-mono",children:"Key"}),s.jsx("th",{className:"border-b border-border px-3 py-2 font-mono",children:"Value"}),s.jsx("th",{className:"border-b border-border px-3 py-2 font-mono",children:"Layer"}),s.jsx("th",{className:"border-b border-border px-3 py-2 font-mono",children:"Tier"}),s.jsx("th",{className:"border-b border-border px-3 py-2 font-mono",children:"Local"})]})}),s.jsx("tbody",{children:a.map(f=>s.jsxs("tr",{className:"border-b border-border/60",children:[s.jsxs("td",{className:"px-3 py-2",children:[s.jsx("div",{className:"font-mono text-foreground",children:f.key}),s.jsx("div",{className:"text-muted-foreground",children:f.definition?.label??f.reason})]}),s.jsx("td",{className:f.enabled?"px-3 py-2 font-mono text-emerald-500":"px-3 py-2 font-mono text-muted-foreground",children:f.enabled?"on":"off"}),s.jsxs("td",{className:"px-3 py-2 font-mono text-muted-foreground",children:[f.layer," · ",f.reason]}),s.jsx("td",{className:"px-3 py-2 font-mono text-muted-foreground",children:f.requiredTier??"—"}),s.jsx("td",{className:"px-3 py-2",children:s.jsxs("select",{className:"rounded border border-border bg-background px-2 py-1 font-mono text-foreground",value:sU(r.layers.local?.flags?.[f.key]),onChange:h=>{const p=h.target.value;r.setLocalOverride(f.key,p==="default"?null:p==="on")},children:[s.jsx("option",{value:"default",children:"default"}),s.jsx("option",{value:"on",children:"on"}),s.jsx("option",{value:"off",children:"off"})]})})]},f.key))})]})}),s.jsxs("div",{className:"flex items-center justify-between border-t border-border px-4 py-2 text-[10px] font-mono uppercase tracking-[0.14em] text-muted-foreground",children:[s.jsxs("span",{children:[a.length," flags"]}),s.jsx("button",{type:"button",className:"rounded border border-border px-2 py-1 hover:text-foreground",onClick:()=>r.resetLocalOverrides(),children:"Reset local overrides"})]})]})})}function sU(e){return e===!0?"on":e===!1?"off":"default"}function rU(e,t){const n=new Set([t]);for(const r of e)r.requiredTier&&n.add(String(r.requiredTier));return[...n]}var aU=m.createContext({});function iU(){return m.useContext(aU)}var oU={titleBarInset:0,dragRegionProps:{},onInteractiveMouseDown:void 0,isSSR:!0,apiBaseUrl:"",serviceApiUrl:""},lU=m.createContext(oU);function vg(){return m.useContext(lU)}var B2="vercel.ai.error",cU=Symbol.for(B2),YC,XC,ca=class U2 extends(XC=Error,YC=cU,XC){constructor({name:t,message:n,cause:r}){super(n),this[YC]=!0,this.name=t,this.cause=r}static isInstance(t){return U2.hasMarker(t,B2)}static hasMarker(t,n){const r=Symbol.for(n);return t!=null&&typeof t=="object"&&r in t&&typeof t[r]=="boolean"&&t[r]===!0}};function F2(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var V2="AI_InvalidArgumentError",H2=`vercel.ai.error.${V2}`,uU=Symbol.for(H2),QC,JC,dU=class extends(JC=ca,QC=uU,JC){constructor({message:e,cause:t,argument:n}){super({name:V2,message:e,cause:t}),this[QC]=!0,this.argument=n}static isInstance(e){return ca.hasMarker(e,H2)}},W2="AI_JSONParseError",q2=`vercel.ai.error.${W2}`,fU=Symbol.for(q2),eE,tE,nE=class extends(tE=ca,eE=fU,tE){constructor({text:e,cause:t}){super({name:W2,message:`JSON parsing failed: Text: ${e}.
10
- Error message: ${F2(t)}`,cause:t}),this[eE]=!0,this.text=e}static isInstance(e){return ca.hasMarker(e,q2)}},K2="AI_TypeValidationError",G2=`vercel.ai.error.${K2}`,hU=Symbol.for(G2),sE,rE,Mc=class Jb extends(rE=ca,sE=hU,rE){constructor({value:t,cause:n,context:r}){let a="Type validation failed";if(r?.field&&(a+=` for ${r.field}`),r?.entityName||r?.entityId){a+=" (";const o=[];r.entityName&&o.push(r.entityName),r.entityId&&o.push(`id: "${r.entityId}"`),a+=o.join(", "),a+=")"}super({name:K2,message:`${a}: Value: ${JSON.stringify(t)}.
11
- Error message: ${F2(n)}`,cause:n}),this[sE]=!0,this.value=t,this.context=r}static isInstance(t){return ca.hasMarker(t,G2)}static wrap({value:t,cause:n,context:r}){var a,o,c;return Jb.isInstance(n)&&n.value===t&&((a=n.context)==null?void 0:a.field)===r?.field&&((o=n.context)==null?void 0:o.entityName)===r?.entityName&&((c=n.context)==null?void 0:c.entityId)===r?.entityId?n:new Jb({value:t,cause:n,context:r})}};function je(e,t,n){function r(u,f){if(u._zod||Object.defineProperty(u,"_zod",{value:{def:f,constr:c,traits:new Set},enumerable:!1}),u._zod.traits.has(e))return;u._zod.traits.add(e),t(u,f);const h=c.prototype,p=Object.keys(h);for(let x=0;x<p.length;x++){const v=p[x];v in u||(u[v]=h[v].bind(u))}}const a=n?.Parent??Object;class o extends a{}Object.defineProperty(o,"name",{value:e});function c(u){var f;const h=n?.Parent?new o:this;r(h,u),(f=h._zod).deferred??(f.deferred=[]);for(const p of h._zod.deferred)p();return h}return Object.defineProperty(c,"init",{value:r}),Object.defineProperty(c,Symbol.hasInstance,{value:u=>n?.Parent&&u instanceof n.Parent?!0:u?._zod?.traits?.has(e)}),Object.defineProperty(c,"name",{value:e}),c}class xc extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Z2 extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Y2={};function Ui(e){return Y2}function X2(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,a])=>t.indexOf(+r)===-1).map(([r,a])=>a)}function e0(e,t){return typeof t=="bigint"?t.toString():t}function xg(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Yw(e){return e==null}function Xw(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function mU(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let a=(r.split(".")[1]||"").length;if(a===0&&/\d?e-\d?/.test(r)){const f=r.match(/\d?e-(\d?)/);f?.[1]&&(a=Number.parseInt(f[1]))}const o=n>a?n:a,c=Number.parseInt(e.toFixed(o).replace(".","")),u=Number.parseInt(t.toFixed(o).replace(".",""));return c%u/10**o}const aE=Symbol("evaluating");function Bt(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==aE)return r===void 0&&(r=aE,r=n()),r},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function rl(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ki(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function iE(e){return JSON.stringify(e)}function pU(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Q2="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ud(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const gU=xg(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Rc(e){if(Ud(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Ud(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function J2(e){return Rc(e)?{...e}:Array.isArray(e)?[...e]:e}const vU=new Set(["string","number","symbol"]);function Ic(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Gi(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function et(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function xU(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const yU={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function bU(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o=Ki(e._zod.def,{get shape(){const c={};for(const u in t){if(!(u in n.shape))throw new Error(`Unrecognized key: "${u}"`);t[u]&&(c[u]=n.shape[u])}return rl(this,"shape",c),c},checks:[]});return Gi(e,o)}function wU(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=Ki(e._zod.def,{get shape(){const c={...e._zod.def.shape};for(const u in t){if(!(u in n.shape))throw new Error(`Unrecognized key: "${u}"`);t[u]&&delete c[u]}return rl(this,"shape",c),c},checks:[]});return Gi(e,o)}function jU(e,t){if(!Rc(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const o=e._zod.def.shape;for(const c in t)if(Object.getOwnPropertyDescriptor(o,c)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const a=Ki(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return rl(this,"shape",o),o}});return Gi(e,a)}function kU(e,t){if(!Rc(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Ki(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return rl(this,"shape",r),r}});return Gi(e,n)}function NU(e,t){const n=Ki(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return rl(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return Gi(e,n)}function SU(e,t,n){const a=t._zod.def.checks;if(a&&a.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const c=Ki(t._zod.def,{get shape(){const u=t._zod.def.shape,f={...u};if(n)for(const h in n){if(!(h in u))throw new Error(`Unrecognized key: "${h}"`);n[h]&&(f[h]=e?new e({type:"optional",innerType:u[h]}):u[h])}else for(const h in u)f[h]=e?new e({type:"optional",innerType:u[h]}):u[h];return rl(this,"shape",f),f},checks:[]});return Gi(t,c)}function CU(e,t,n){const r=Ki(t._zod.def,{get shape(){const a=t._zod.def.shape,o={...a};if(n)for(const c in n){if(!(c in o))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(o[c]=new e({type:"nonoptional",innerType:a[c]}))}else for(const c in a)o[c]=new e({type:"nonoptional",innerType:a[c]});return rl(this,"shape",o),o}});return Gi(t,r)}function oc(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function lc(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Uh(e){return typeof e=="string"?e:e?.message}function Fi(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const a=Uh(e.inst?._zod.def?.error?.(e))??Uh(t?.error?.(e))??Uh(n.customError?.(e))??Uh(n.localeError?.(e))??"Invalid input";r.message=a}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Qw(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Fd(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const e_=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,e0,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},t_=je("$ZodError",e_),n_=je("$ZodError",e_,{Parent:Error});function EU(e,t=n=>n.message){const n={},r=[];for(const a of e.issues)a.path.length>0?(n[a.path[0]]=n[a.path[0]]||[],n[a.path[0]].push(t(a))):r.push(t(a));return{formErrors:r,fieldErrors:n}}function AU(e,t=n=>n.message){const n={_errors:[]},r=a=>{for(const o of a.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(c=>r({issues:c}));else if(o.code==="invalid_key")r({issues:o.issues});else if(o.code==="invalid_element")r({issues:o.issues});else if(o.path.length===0)n._errors.push(t(o));else{let c=n,u=0;for(;u<o.path.length;){const f=o.path[u];u===o.path.length-1?(c[f]=c[f]||{_errors:[]},c[f]._errors.push(t(o))):c[f]=c[f]||{_errors:[]},c=c[f],u++}}};return r(e),n}const Jw=e=>(t,n,r,a)=>{const o=r?Object.assign(r,{async:!1}):{async:!1},c=t._zod.run({value:n,issues:[]},o);if(c instanceof Promise)throw new xc;if(c.issues.length){const u=new(a?.Err??e)(c.issues.map(f=>Fi(f,o,Ui())));throw Q2(u,a?.callee),u}return c.value},ej=e=>async(t,n,r,a)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let c=t._zod.run({value:n,issues:[]},o);if(c instanceof Promise&&(c=await c),c.issues.length){const u=new(a?.Err??e)(c.issues.map(f=>Fi(f,o,Ui())));throw Q2(u,a?.callee),u}return c.value},yg=e=>(t,n,r)=>{const a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new xc;return o.issues.length?{success:!1,error:new(e??t_)(o.issues.map(c=>Fi(c,a,Ui())))}:{success:!0,data:o.value}},TU=yg(n_),bg=e=>async(t,n,r)=>{const a=r?Object.assign(r,{async:!0}):{async:!0};let o=t._zod.run({value:n,issues:[]},a);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(c=>Fi(c,a,Ui())))}:{success:!0,data:o.value}},MU=bg(n_),RU=e=>(t,n,r)=>{const a=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Jw(e)(t,n,a)},IU=e=>(t,n,r)=>Jw(e)(t,n,r),_U=e=>async(t,n,r)=>{const a=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ej(e)(t,n,a)},OU=e=>async(t,n,r)=>ej(e)(t,n,r),$U=e=>(t,n,r)=>{const a=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return yg(e)(t,n,a)},LU=e=>(t,n,r)=>yg(e)(t,n,r),PU=e=>async(t,n,r)=>{const a=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return bg(e)(t,n,a)},DU=e=>async(t,n,r)=>bg(e)(t,n,r),zU=/^[cC][^\s-]{8,}$/,BU=/^[0-9a-z]+$/,UU=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,FU=/^[0-9a-vA-V]{20}$/,VU=/^[A-Za-z0-9]{27}$/,HU=/^[a-zA-Z0-9_-]{21}$/,WU=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,qU=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,oE=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,KU=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,GU="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function ZU(){return new RegExp(GU,"u")}const YU=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,XU=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,QU=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,JU=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,eF=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,s_=/^[A-Za-z0-9_-]*$/,tF=/^\+[1-9]\d{6,14}$/,r_="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",nF=new RegExp(`^${r_}$`);function a_(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function sF(e){return new RegExp(`^${a_(e)}$`)}function rF(e){const t=a_({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${r_}T(?:${r})$`)}const aF=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},iF=/^-?\d+$/,i_=/^-?\d+(?:\.\d+)?$/,oF=/^(?:true|false)$/i,lF=/^null$/i,cF=/^[^A-Z]*$/,uF=/^[^a-z]*$/,Ds=je("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),o_={number:"number",bigint:"bigint",object:"date"},l_=je("$ZodCheckLessThan",(e,t)=>{Ds.init(e,t);const n=o_[typeof t.value];e._zod.onattach.push(r=>{const a=r._zod.bag,o=(t.inclusive?a.maximum:a.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?a.maximum=t.value:a.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),c_=je("$ZodCheckGreaterThan",(e,t)=>{Ds.init(e,t);const n=o_[typeof t.value];e._zod.onattach.push(r=>{const a=r._zod.bag,o=(t.inclusive?a.minimum:a.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?a.minimum=t.value:a.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),dF=je("$ZodCheckMultipleOf",(e,t)=>{Ds.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):mU(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),fF=je("$ZodCheckNumberFormat",(e,t)=>{Ds.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[a,o]=yU[t.format];e._zod.onattach.push(c=>{const u=c._zod.bag;u.format=t.format,u.minimum=a,u.maximum=o,n&&(u.pattern=iF)}),e._zod.check=c=>{const u=c.value;if(n){if(!Number.isInteger(u)){c.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:u,inst:e});return}if(!Number.isSafeInteger(u)){u>0?c.issues.push({input:u,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):c.issues.push({input:u,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}u<a&&c.issues.push({origin:"number",input:u,code:"too_small",minimum:a,inclusive:!0,inst:e,continue:!t.abort}),u>o&&c.issues.push({origin:"number",input:u,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),hF=je("$ZodCheckMaxLength",(e,t)=>{var n;Ds.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!Yw(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const a=r.value;if(a.length<=t.maximum)return;const c=Qw(a);r.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),mF=je("$ZodCheckMinLength",(e,t)=>{var n;Ds.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!Yw(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const a=r.value;if(a.length>=t.minimum)return;const c=Qw(a);r.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),pF=je("$ZodCheckLengthEquals",(e,t)=>{var n;Ds.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!Yw(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=r=>{const a=r.value,o=a.length;if(o===t.length)return;const c=Qw(a),u=o>t.length;r.issues.push({origin:c,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),wg=je("$ZodCheckStringFormat",(e,t)=>{var n,r;Ds.init(e,t),e._zod.onattach.push(a=>{const o=a._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=a=>{t.pattern.lastIndex=0,!t.pattern.test(a.value)&&a.issues.push({origin:"string",code:"invalid_format",format:t.format,input:a.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),gF=je("$ZodCheckRegex",(e,t)=>{wg.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),vF=je("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=cF),wg.init(e,t)}),xF=je("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=uF),wg.init(e,t)}),yF=je("$ZodCheckIncludes",(e,t)=>{Ds.init(e,t);const n=Ic(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(a=>{const o=a._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=a=>{a.value.includes(t.includes,t.position)||a.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:a.value,inst:e,continue:!t.abort})}}),bF=je("$ZodCheckStartsWith",(e,t)=>{Ds.init(e,t);const n=new RegExp(`^${Ic(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const a=r._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),wF=je("$ZodCheckEndsWith",(e,t)=>{Ds.init(e,t);const n=new RegExp(`.*${Ic(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const a=r._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),jF=je("$ZodCheckOverwrite",(e,t)=>{Ds.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class kF{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
12
- `).filter(c=>c),a=Math.min(...r.map(c=>c.length-c.trimStart().length)),o=r.map(c=>c.slice(a)).map(c=>" ".repeat(this.indent*2)+c);for(const c of o)this.content.push(c)}compile(){const t=Function,n=this?.args,a=[...(this?.content??[""]).map(o=>` ${o}`)];return new t(...n,a.join(`
13
- `))}}const NF={major:4,minor:3,patch:6},bn=je("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=NF;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const a of r)for(const o of a._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const a=(c,u,f)=>{let h=oc(c),p;for(const x of u){if(x._zod.def.when){if(!x._zod.def.when(c))continue}else if(h)continue;const v=c.issues.length,y=x._zod.check(c);if(y instanceof Promise&&f?.async===!1)throw new xc;if(p||y instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await y,c.issues.length!==v&&(h||(h=oc(c,v)))});else{if(c.issues.length===v)continue;h||(h=oc(c,v))}}return p?p.then(()=>c):c},o=(c,u,f)=>{if(oc(c))return c.aborted=!0,c;const h=a(u,r,f);if(h instanceof Promise){if(f.async===!1)throw new xc;return h.then(p=>e._zod.parse(p,f))}return e._zod.parse(h,f)};e._zod.run=(c,u)=>{if(u.skipChecks)return e._zod.parse(c,u);if(u.direction==="backward"){const h=e._zod.parse({value:c.value,issues:[]},{...u,skipChecks:!0});return h instanceof Promise?h.then(p=>o(p,c,u)):o(h,c,u)}const f=e._zod.parse(c,u);if(f instanceof Promise){if(u.async===!1)throw new xc;return f.then(h=>a(h,r,u))}return a(f,r,u)}}Bt(e,"~standard",()=>({validate:a=>{try{const o=TU(e,a);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return MU(e,a).then(c=>c.success?{value:c.data}:{issues:c.error?.issues})}},vendor:"zod",version:1}))}),tj=je("$ZodString",(e,t)=>{bn.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??aF(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Sn=je("$ZodStringFormat",(e,t)=>{wg.init(e,t),tj.init(e,t)}),SF=je("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=qU),Sn.init(e,t)}),CF=je("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=oE(r))}else t.pattern??(t.pattern=oE());Sn.init(e,t)}),EF=je("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=KU),Sn.init(e,t)}),AF=je("$ZodURL",(e,t)=>{Sn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),a=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(a.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(a.protocol.endsWith(":")?a.protocol.slice(0,-1):a.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=a.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),TF=je("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ZU()),Sn.init(e,t)}),MF=je("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=HU),Sn.init(e,t)}),RF=je("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=zU),Sn.init(e,t)}),IF=je("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=BU),Sn.init(e,t)}),_F=je("$ZodULID",(e,t)=>{t.pattern??(t.pattern=UU),Sn.init(e,t)}),OF=je("$ZodXID",(e,t)=>{t.pattern??(t.pattern=FU),Sn.init(e,t)}),$F=je("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=VU),Sn.init(e,t)}),LF=je("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=rF(t)),Sn.init(e,t)}),PF=je("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=nF),Sn.init(e,t)}),DF=je("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=sF(t)),Sn.init(e,t)}),zF=je("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=WU),Sn.init(e,t)}),BF=je("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=YU),Sn.init(e,t),e._zod.bag.format="ipv4"}),UF=je("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=XU),Sn.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),FF=je("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=QU),Sn.init(e,t)}),VF=je("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=JU),Sn.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[a,o]=r;if(!o)throw new Error;const c=Number(o);if(`${c}`!==o)throw new Error;if(c<0||c>128)throw new Error;new URL(`http://[${a}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function u_(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const HF=je("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=eF),Sn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{u_(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function WF(e){if(!s_.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return u_(n)}const qF=je("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=s_),Sn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{WF(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),KF=je("$ZodE164",(e,t)=>{t.pattern??(t.pattern=tF),Sn.init(e,t)});function GF(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const a=JSON.parse(atob(r));return!("typ"in a&&a?.typ!=="JWT"||!a.alg||t&&(!("alg"in a)||a.alg!==t))}catch{return!1}}const ZF=je("$ZodJWT",(e,t)=>{Sn.init(e,t),e._zod.check=n=>{GF(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),d_=je("$ZodNumber",(e,t)=>{bn.init(e,t),e._zod.pattern=e._zod.bag.pattern??i_,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const a=n.value;if(typeof a=="number"&&!Number.isNaN(a)&&Number.isFinite(a))return n;const o=typeof a=="number"?Number.isNaN(a)?"NaN":Number.isFinite(a)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:a,inst:e,...o?{received:o}:{}}),n}}),YF=je("$ZodNumberFormat",(e,t)=>{fF.init(e,t),d_.init(e,t)}),XF=je("$ZodBoolean",(e,t)=>{bn.init(e,t),e._zod.pattern=oF,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const a=n.value;return typeof a=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:a,inst:e}),n}}),QF=je("$ZodNull",(e,t)=>{bn.init(e,t),e._zod.pattern=lF,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const a=n.value;return a===null||n.issues.push({expected:"null",code:"invalid_type",input:a,inst:e}),n}}),JF=je("$ZodUnknown",(e,t)=>{bn.init(e,t),e._zod.parse=n=>n}),eV=je("$ZodNever",(e,t)=>{bn.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function lE(e,t,n){e.issues.length&&t.issues.push(...lc(n,e.issues)),t.value[n]=e.value}const tV=je("$ZodArray",(e,t)=>{bn.init(e,t),e._zod.parse=(n,r)=>{const a=n.value;if(!Array.isArray(a))return n.issues.push({expected:"array",code:"invalid_type",input:a,inst:e}),n;n.value=Array(a.length);const o=[];for(let c=0;c<a.length;c++){const u=a[c],f=t.element._zod.run({value:u,issues:[]},r);f instanceof Promise?o.push(f.then(h=>lE(h,n,c))):lE(f,n,c)}return o.length?Promise.all(o).then(()=>n):n}});function pp(e,t,n,r,a){if(e.issues.length){if(a&&!(n in r))return;t.issues.push(...lc(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function f_(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=xU(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function h_(e,t,n,r,a,o){const c=[],u=a.keySet,f=a.catchall._zod,h=f.def.type,p=f.optout==="optional";for(const x in t){if(u.has(x))continue;if(h==="never"){c.push(x);continue}const v=f.run({value:t[x],issues:[]},r);v instanceof Promise?e.push(v.then(y=>pp(y,n,x,t,p))):pp(v,n,x,t,p)}return c.length&&n.issues.push({code:"unrecognized_keys",keys:c,input:t,inst:o}),e.length?Promise.all(e).then(()=>n):n}const nV=je("$ZodObject",(e,t)=>{if(bn.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const u=t.shape;Object.defineProperty(t,"shape",{get:()=>{const f={...u};return Object.defineProperty(t,"shape",{value:f}),f}})}const r=xg(()=>f_(t));Bt(e._zod,"propValues",()=>{const u=t.shape,f={};for(const h in u){const p=u[h]._zod;if(p.values){f[h]??(f[h]=new Set);for(const x of p.values)f[h].add(x)}}return f});const a=Ud,o=t.catchall;let c;e._zod.parse=(u,f)=>{c??(c=r.value);const h=u.value;if(!a(h))return u.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),u;u.value={};const p=[],x=c.shape;for(const v of c.keys){const y=x[v],b=y._zod.optout==="optional",C=y._zod.run({value:h[v],issues:[]},f);C instanceof Promise?p.push(C.then(E=>pp(E,u,v,h,b))):pp(C,u,v,h,b)}return o?h_(p,h,u,f,r.value,e):p.length?Promise.all(p).then(()=>u):u}}),sV=je("$ZodObjectJIT",(e,t)=>{nV.init(e,t);const n=e._zod.parse,r=xg(()=>f_(t)),a=v=>{const y=new kF(["shape","payload","ctx"]),b=r.value,C=k=>{const N=iE(k);return`shape[${N}]._zod.run({ value: input[${N}], issues: [] }, ctx)`};y.write("const input = payload.value;");const E=Object.create(null);let A=0;for(const k of b.keys)E[k]=`key_${A++}`;y.write("const newResult = {};");for(const k of b.keys){const N=E[k],T=iE(k),O=v[k]?._zod?.optout==="optional";y.write(`const ${N} = ${C(k)};`),O?y.write(`
14
- if (${N}.issues.length) {
15
- if (${T} in input) {
16
- payload.issues = payload.issues.concat(${N}.issues.map(iss => ({
17
- ...iss,
18
- path: iss.path ? [${T}, ...iss.path] : [${T}]
19
- })));
20
- }
21
- }
22
-
23
- if (${N}.value === undefined) {
24
- if (${T} in input) {
25
- newResult[${T}] = undefined;
26
- }
27
- } else {
28
- newResult[${T}] = ${N}.value;
29
- }
30
-
31
- `):y.write(`
32
- if (${N}.issues.length) {
33
- payload.issues = payload.issues.concat(${N}.issues.map(iss => ({
34
- ...iss,
35
- path: iss.path ? [${T}, ...iss.path] : [${T}]
36
- })));
37
- }
38
-
39
- if (${N}.value === undefined) {
40
- if (${T} in input) {
41
- newResult[${T}] = undefined;
42
- }
43
- } else {
44
- newResult[${T}] = ${N}.value;
45
- }
46
-
47
- `)}y.write("payload.value = newResult;"),y.write("return payload;");const S=y.compile();return(k,N)=>S(v,k,N)};let o;const c=Ud,u=!Y2.jitless,h=u&&gU.value,p=t.catchall;let x;e._zod.parse=(v,y)=>{x??(x=r.value);const b=v.value;return c(b)?u&&h&&y?.async===!1&&y.jitless!==!0?(o||(o=a(t.shape)),v=o(v,y),p?h_([],b,v,y,x,e):v):n(v,y):(v.issues.push({expected:"object",code:"invalid_type",input:b,inst:e}),v)}});function cE(e,t,n,r){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const a=e.filter(o=>!oc(o));return a.length===1?(t.value=a[0].value,a[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(c=>Fi(c,r,Ui())))}),t)}const m_=je("$ZodUnion",(e,t)=>{bn.init(e,t),Bt(e._zod,"optin",()=>t.options.some(a=>a._zod.optin==="optional")?"optional":void 0),Bt(e._zod,"optout",()=>t.options.some(a=>a._zod.optout==="optional")?"optional":void 0),Bt(e._zod,"values",()=>{if(t.options.every(a=>a._zod.values))return new Set(t.options.flatMap(a=>Array.from(a._zod.values)))}),Bt(e._zod,"pattern",()=>{if(t.options.every(a=>a._zod.pattern)){const a=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${a.map(o=>Xw(o.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(a,o)=>{if(n)return r(a,o);let c=!1;const u=[];for(const f of t.options){const h=f._zod.run({value:a.value,issues:[]},o);if(h instanceof Promise)u.push(h),c=!0;else{if(h.issues.length===0)return h;u.push(h)}}return c?Promise.all(u).then(f=>cE(f,a,e,o)):cE(u,a,e,o)}}),rV=je("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,m_.init(e,t);const n=e._zod.parse;Bt(e._zod,"propValues",()=>{const a={};for(const o of t.options){const c=o._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const[u,f]of Object.entries(c)){a[u]||(a[u]=new Set);for(const h of f)a[u].add(h)}}return a});const r=xg(()=>{const a=t.options,o=new Map;for(const c of a){const u=c._zod.propValues?.[t.discriminator];if(!u||u.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(c)}"`);for(const f of u){if(o.has(f))throw new Error(`Duplicate discriminator value "${String(f)}"`);o.set(f,c)}}return o});e._zod.parse=(a,o)=>{const c=a.value;if(!Ud(c))return a.issues.push({code:"invalid_type",expected:"object",input:c,inst:e}),a;const u=r.value.get(c?.[t.discriminator]);return u?u._zod.run(a,o):t.unionFallback?n(a,o):(a.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:c,path:[t.discriminator],inst:e}),a)}}),aV=je("$ZodIntersection",(e,t)=>{bn.init(e,t),e._zod.parse=(n,r)=>{const a=n.value,o=t.left._zod.run({value:a,issues:[]},r),c=t.right._zod.run({value:a,issues:[]},r);return o instanceof Promise||c instanceof Promise?Promise.all([o,c]).then(([f,h])=>uE(n,f,h)):uE(n,o,c)}});function t0(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Rc(e)&&Rc(t)){const n=Object.keys(t),r=Object.keys(e).filter(o=>n.indexOf(o)!==-1),a={...e,...t};for(const o of r){const c=t0(e[o],t[o]);if(!c.valid)return{valid:!1,mergeErrorPath:[o,...c.mergeErrorPath]};a[o]=c.data}return{valid:!0,data:a}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const a=e[r],o=t[r],c=t0(a,o);if(!c.valid)return{valid:!1,mergeErrorPath:[r,...c.mergeErrorPath]};n.push(c.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function uE(e,t,n){const r=new Map;let a;for(const u of t.issues)if(u.code==="unrecognized_keys"){a??(a=u);for(const f of u.keys)r.has(f)||r.set(f,{}),r.get(f).l=!0}else e.issues.push(u);for(const u of n.issues)if(u.code==="unrecognized_keys")for(const f of u.keys)r.has(f)||r.set(f,{}),r.get(f).r=!0;else e.issues.push(u);const o=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(o.length&&a&&e.issues.push({...a,keys:o}),oc(e))return e;const c=t0(t.value,n.value);if(!c.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`);return e.value=c.data,e}const iV=je("$ZodRecord",(e,t)=>{bn.init(e,t),e._zod.parse=(n,r)=>{const a=n.value;if(!Rc(a))return n.issues.push({expected:"record",code:"invalid_type",input:a,inst:e}),n;const o=[],c=t.keyType._zod.values;if(c){n.value={};const u=new Set;for(const h of c)if(typeof h=="string"||typeof h=="number"||typeof h=="symbol"){u.add(typeof h=="number"?h.toString():h);const p=t.valueType._zod.run({value:a[h],issues:[]},r);p instanceof Promise?o.push(p.then(x=>{x.issues.length&&n.issues.push(...lc(h,x.issues)),n.value[h]=x.value})):(p.issues.length&&n.issues.push(...lc(h,p.issues)),n.value[h]=p.value)}let f;for(const h in a)u.has(h)||(f=f??[],f.push(h));f&&f.length>0&&n.issues.push({code:"unrecognized_keys",input:a,inst:e,keys:f})}else{n.value={};for(const u of Reflect.ownKeys(a)){if(u==="__proto__")continue;let f=t.keyType._zod.run({value:u,issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&i_.test(u)&&f.issues.length){const x=t.keyType._zod.run({value:Number(u),issues:[]},r);if(x instanceof Promise)throw new Error("Async schemas not supported in object keys currently");x.issues.length===0&&(f=x)}if(f.issues.length){t.mode==="loose"?n.value[u]=a[u]:n.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(x=>Fi(x,r,Ui())),input:u,path:[u],inst:e});continue}const p=t.valueType._zod.run({value:a[u],issues:[]},r);p instanceof Promise?o.push(p.then(x=>{x.issues.length&&n.issues.push(...lc(u,x.issues)),n.value[f.value]=x.value})):(p.issues.length&&n.issues.push(...lc(u,p.issues)),n.value[f.value]=p.value)}}return o.length?Promise.all(o).then(()=>n):n}}),oV=je("$ZodEnum",(e,t)=>{bn.init(e,t);const n=X2(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(a=>vU.has(typeof a)).map(a=>typeof a=="string"?Ic(a):a.toString()).join("|")})$`),e._zod.parse=(a,o)=>{const c=a.value;return r.has(c)||a.issues.push({code:"invalid_value",values:n,input:c,inst:e}),a}}),lV=je("$ZodLiteral",(e,t)=>{if(bn.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Ic(r):r?Ic(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,a)=>{const o=r.value;return n.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}}),cV=je("$ZodTransform",(e,t)=>{bn.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Z2(e.constructor.name);const a=t.transform(n.value,n);if(r.async)return(a instanceof Promise?a:Promise.resolve(a)).then(c=>(n.value=c,n));if(a instanceof Promise)throw new xc;return n.value=a,n}});function dE(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const p_=je("$ZodOptional",(e,t)=>{bn.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Bt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Bt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Xw(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const a=t.innerType._zod.run(n,r);return a instanceof Promise?a.then(o=>dE(o,n.value)):dE(a,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),uV=je("$ZodExactOptional",(e,t)=>{p_.init(e,t),Bt(e._zod,"values",()=>t.innerType._zod.values),Bt(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),dV=je("$ZodNullable",(e,t)=>{bn.init(e,t),Bt(e._zod,"optin",()=>t.innerType._zod.optin),Bt(e._zod,"optout",()=>t.innerType._zod.optout),Bt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Xw(n.source)}|null)$`):void 0}),Bt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),fV=je("$ZodDefault",(e,t)=>{bn.init(e,t),e._zod.optin="optional",Bt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const a=t.innerType._zod.run(n,r);return a instanceof Promise?a.then(o=>fE(o,t)):fE(a,t)}});function fE(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const hV=je("$ZodPrefault",(e,t)=>{bn.init(e,t),e._zod.optin="optional",Bt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),mV=je("$ZodNonOptional",(e,t)=>{bn.init(e,t),Bt(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const a=t.innerType._zod.run(n,r);return a instanceof Promise?a.then(o=>hE(o,e)):hE(a,e)}});function hE(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const pV=je("$ZodCatch",(e,t)=>{bn.init(e,t),Bt(e._zod,"optin",()=>t.innerType._zod.optin),Bt(e._zod,"optout",()=>t.innerType._zod.optout),Bt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const a=t.innerType._zod.run(n,r);return a instanceof Promise?a.then(o=>(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(c=>Fi(c,r,Ui()))},input:n.value}),n.issues=[]),n)):(n.value=a.value,a.issues.length&&(n.value=t.catchValue({...n,error:{issues:a.issues.map(o=>Fi(o,r,Ui()))},input:n.value}),n.issues=[]),n)}}),gV=je("$ZodPipe",(e,t)=>{bn.init(e,t),Bt(e._zod,"values",()=>t.in._zod.values),Bt(e._zod,"optin",()=>t.in._zod.optin),Bt(e._zod,"optout",()=>t.out._zod.optout),Bt(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const o=t.out._zod.run(n,r);return o instanceof Promise?o.then(c=>Fh(c,t.in,r)):Fh(o,t.in,r)}const a=t.in._zod.run(n,r);return a instanceof Promise?a.then(o=>Fh(o,t.out,r)):Fh(a,t.out,r)}});function Fh(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const vV=je("$ZodReadonly",(e,t)=>{bn.init(e,t),Bt(e._zod,"propValues",()=>t.innerType._zod.propValues),Bt(e._zod,"values",()=>t.innerType._zod.values),Bt(e._zod,"optin",()=>t.innerType?._zod?.optin),Bt(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const a=t.innerType._zod.run(n,r);return a instanceof Promise?a.then(mE):mE(a)}});function mE(e){return e.value=Object.freeze(e.value),e}const xV=je("$ZodLazy",(e,t)=>{bn.init(e,t),Bt(e._zod,"innerType",()=>t.getter()),Bt(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),Bt(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),Bt(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),Bt(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),yV=je("$ZodCustom",(e,t)=>{Ds.init(e,t),bn.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,a=t.fn(r);if(a instanceof Promise)return a.then(o=>pE(o,n,r,e));pE(a,n,r,e)}});function pE(e,t,n,r){if(!e){const a={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(a.params=r._zod.def.params),t.issues.push(Fd(a))}}var gE;class bV{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const a={...r,...this._map.get(t)};return Object.keys(a).length?a:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function wV(){return new bV}(gE=globalThis).__zod_globalRegistry??(gE.__zod_globalRegistry=wV());const ud=globalThis.__zod_globalRegistry;function jV(e,t){return new e({type:"string",...et(t)})}function kV(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...et(t)})}function vE(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...et(t)})}function NV(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...et(t)})}function SV(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...et(t)})}function CV(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...et(t)})}function EV(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...et(t)})}function AV(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...et(t)})}function TV(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...et(t)})}function MV(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...et(t)})}function RV(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...et(t)})}function IV(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...et(t)})}function _V(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...et(t)})}function OV(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...et(t)})}function $V(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...et(t)})}function LV(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...et(t)})}function PV(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...et(t)})}function DV(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...et(t)})}function zV(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...et(t)})}function BV(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...et(t)})}function UV(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...et(t)})}function FV(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...et(t)})}function VV(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...et(t)})}function HV(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...et(t)})}function WV(e,t){return new e({type:"string",format:"date",check:"string_format",...et(t)})}function qV(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...et(t)})}function KV(e,t){return new e({type:"string",format:"duration",check:"string_format",...et(t)})}function GV(e,t){return new e({type:"number",checks:[],...et(t)})}function ZV(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...et(t)})}function YV(e,t){return new e({type:"boolean",...et(t)})}function XV(e,t){return new e({type:"null",...et(t)})}function QV(e){return new e({type:"unknown"})}function JV(e,t){return new e({type:"never",...et(t)})}function xE(e,t){return new l_({check:"less_than",...et(t),value:e,inclusive:!1})}function my(e,t){return new l_({check:"less_than",...et(t),value:e,inclusive:!0})}function yE(e,t){return new c_({check:"greater_than",...et(t),value:e,inclusive:!1})}function py(e,t){return new c_({check:"greater_than",...et(t),value:e,inclusive:!0})}function bE(e,t){return new dF({check:"multiple_of",...et(t),value:e})}function g_(e,t){return new hF({check:"max_length",...et(t),maximum:e})}function gp(e,t){return new mF({check:"min_length",...et(t),minimum:e})}function v_(e,t){return new pF({check:"length_equals",...et(t),length:e})}function e9(e,t){return new gF({check:"string_format",format:"regex",...et(t),pattern:e})}function t9(e){return new vF({check:"string_format",format:"lowercase",...et(e)})}function n9(e){return new xF({check:"string_format",format:"uppercase",...et(e)})}function s9(e,t){return new yF({check:"string_format",format:"includes",...et(t),includes:e})}function r9(e,t){return new bF({check:"string_format",format:"starts_with",...et(t),prefix:e})}function a9(e,t){return new wF({check:"string_format",format:"ends_with",...et(t),suffix:e})}function Vc(e){return new jF({check:"overwrite",tx:e})}function i9(e){return Vc(t=>t.normalize(e))}function o9(){return Vc(e=>e.trim())}function l9(){return Vc(e=>e.toLowerCase())}function c9(){return Vc(e=>e.toUpperCase())}function u9(){return Vc(e=>pU(e))}function d9(e,t,n){return new e({type:"array",element:t,...et(n)})}function f9(e,t,n){const r=et(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function h9(e,t,n){return new e({type:"custom",check:"custom",fn:t,...et(n)})}function m9(e){const t=p9(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Fd(r,n.value,t._zod.def));else{const a=r;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=t),a.continue??(a.continue=!t._zod.def.abort),n.issues.push(Fd(a))}},e(n.value,n)));return t}function p9(e,t){const n=new Ds({check:"custom",...et(t)});return n._zod.check=e,n}function vp(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??ud,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function dn(e,t,n={path:[],schemaPath:[]}){var r;const a=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;const c={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,c);const u=e._zod.toJSONSchema?.();if(u)c.schema=u;else{const p={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,c.schema,p);else{const v=c.schema,y=t.processors[a.type];if(!y)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${a.type}`);y(e,t,v,p)}const x=e._zod.parent;x&&(c.ref||(c.ref=x),dn(x,t,p),t.seen.get(x).isParent=!0)}const f=t.metadataRegistry.get(e);return f&&Object.assign(c.schema,f),t.io==="input"&&bs(e)&&(delete c.schema.examples,delete c.schema.default),t.io==="input"&&c.schema._prefault&&((r=c.schema).default??(r.default=c.schema._prefault)),delete c.schema._prefault,t.seen.get(e).schema}function xp(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const c of e.seen.entries()){const u=e.metadataRegistry.get(c[0])?.id;if(u){const f=r.get(u);if(f&&f!==c[0])throw new Error(`Duplicate schema id "${u}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(u,c[0])}}const a=c=>{const u=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const x=e.external.registry.get(c[0])?.id,v=e.external.uri??(b=>b);if(x)return{ref:v(x)};const y=c[1].defId??c[1].schema.id??`schema${e.counter++}`;return c[1].defId=y,{defId:y,ref:`${v("__shared")}#/${u}/${y}`}}if(c[1]===n)return{ref:"#"};const h=`#/${u}/`,p=c[1].schema.id??`__schema${e.counter++}`;return{defId:p,ref:h+p}},o=c=>{if(c[1].schema.$ref)return;const u=c[1],{ref:f,defId:h}=a(c);u.def={...u.schema},h&&(u.defId=h);const p=u.schema;for(const x in p)delete p[x];p.$ref=f};if(e.cycles==="throw")for(const c of e.seen.entries()){const u=c[1];if(u.cycle)throw new Error(`Cycle detected: #/${u.cycle?.join("/")}/<root>
48
-
49
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const c of e.seen.entries()){const u=c[1];if(t===c[0]){o(c);continue}if(e.external){const h=e.external.registry.get(c[0])?.id;if(t!==c[0]&&h){o(c);continue}}if(e.metadataRegistry.get(c[0])?.id){o(c);continue}if(u.cycle){o(c);continue}if(u.count>1&&e.reused==="ref"){o(c);continue}}}function yp(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=c=>{const u=e.seen.get(c);if(u.ref===null)return;const f=u.def??u.schema,h={...f},p=u.ref;if(u.ref=null,p){r(p);const v=e.seen.get(p),y=v.schema;if(y.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(y)):Object.assign(f,y),Object.assign(f,h),c._zod.parent===p)for(const C in f)C==="$ref"||C==="allOf"||C in h||delete f[C];if(y.$ref&&v.def)for(const C in f)C==="$ref"||C==="allOf"||C in v.def&&JSON.stringify(f[C])===JSON.stringify(v.def[C])&&delete f[C]}const x=c._zod.parent;if(x&&x!==p){r(x);const v=e.seen.get(x);if(v?.schema.$ref&&(f.$ref=v.schema.$ref,v.def))for(const y in f)y==="$ref"||y==="allOf"||y in v.def&&JSON.stringify(f[y])===JSON.stringify(v.def[y])&&delete f[y]}e.override({zodSchema:c,jsonSchema:f,path:u.path??[]})};for(const c of[...e.seen.entries()].reverse())r(c[0]);const a={};if(e.target==="draft-2020-12"?a.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?a.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?a.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const c=e.external.registry.get(t)?.id;if(!c)throw new Error("Schema is missing an `id` property");a.$id=e.external.uri(c)}Object.assign(a,n.def??n.schema);const o=e.external?.defs??{};for(const c of e.seen.entries()){const u=c[1];u.def&&u.defId&&(o[u.defId]=u.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?a.$defs=o:a.definitions=o);try{const c=JSON.parse(JSON.stringify(a));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:bp(t,"input",e.processors),output:bp(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function bs(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return bs(r.element,n);if(r.type==="set")return bs(r.valueType,n);if(r.type==="lazy")return bs(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return bs(r.innerType,n);if(r.type==="intersection")return bs(r.left,n)||bs(r.right,n);if(r.type==="record"||r.type==="map")return bs(r.keyType,n)||bs(r.valueType,n);if(r.type==="pipe")return bs(r.in,n)||bs(r.out,n);if(r.type==="object"){for(const a in r.shape)if(bs(r.shape[a],n))return!0;return!1}if(r.type==="union"){for(const a of r.options)if(bs(a,n))return!0;return!1}if(r.type==="tuple"){for(const a of r.items)if(bs(a,n))return!0;return!!(r.rest&&bs(r.rest,n))}return!1}const g9=(e,t={})=>n=>{const r=vp({...n,processors:t});return dn(e,r),xp(r,e),yp(r,e)},bp=(e,t,n={})=>r=>{const{libraryOptions:a,target:o}=r??{},c=vp({...a??{},target:o,io:t,processors:n});return dn(e,c),xp(c,e),yp(c,e)},v9={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},x_=(e,t,n,r)=>{const a=n;a.type="string";const{minimum:o,maximum:c,format:u,patterns:f,contentEncoding:h}=e._zod.bag;if(typeof o=="number"&&(a.minLength=o),typeof c=="number"&&(a.maxLength=c),u&&(a.format=v9[u]??u,a.format===""&&delete a.format,u==="time"&&delete a.format),h&&(a.contentEncoding=h),f&&f.size>0){const p=[...f];p.length===1?a.pattern=p[0].source:p.length>1&&(a.allOf=[...p.map(x=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:x.source}))])}},y_=(e,t,n,r)=>{const a=n,{minimum:o,maximum:c,format:u,multipleOf:f,exclusiveMaximum:h,exclusiveMinimum:p}=e._zod.bag;typeof u=="string"&&u.includes("int")?a.type="integer":a.type="number",typeof p=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(a.minimum=p,a.exclusiveMinimum=!0):a.exclusiveMinimum=p),typeof o=="number"&&(a.minimum=o,typeof p=="number"&&t.target!=="draft-04"&&(p>=o?delete a.minimum:delete a.exclusiveMinimum)),typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(a.maximum=h,a.exclusiveMaximum=!0):a.exclusiveMaximum=h),typeof c=="number"&&(a.maximum=c,typeof h=="number"&&t.target!=="draft-04"&&(h<=c?delete a.maximum:delete a.exclusiveMaximum)),typeof f=="number"&&(a.multipleOf=f)},b_=(e,t,n,r)=>{n.type="boolean"},x9=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},y9=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},w_=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},b9=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},w9=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},j_=(e,t,n,r)=>{n.not={}},j9=(e,t,n,r)=>{},k_=(e,t,n,r)=>{},k9=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},N_=(e,t,n,r)=>{const a=e._zod.def,o=X2(a.entries);o.every(c=>typeof c=="number")&&(n.type="number"),o.every(c=>typeof c=="string")&&(n.type="string"),n.enum=o},S_=(e,t,n,r)=>{const a=e._zod.def,o=[];for(const c of a.values)if(c===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof c=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(c))}else o.push(c);if(o.length!==0)if(o.length===1){const c=o[0];n.type=c===null?"null":typeof c,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[c]:n.const=c}else o.every(c=>typeof c=="number")&&(n.type="number"),o.every(c=>typeof c=="string")&&(n.type="string"),o.every(c=>typeof c=="boolean")&&(n.type="boolean"),o.every(c=>c===null)&&(n.type="null"),n.enum=o},N9=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},S9=(e,t,n,r)=>{const a=n,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");a.type="string",a.pattern=o.source},C9=(e,t,n,r)=>{const a=n,o={type:"string",format:"binary",contentEncoding:"binary"},{minimum:c,maximum:u,mime:f}=e._zod.bag;c!==void 0&&(o.minLength=c),u!==void 0&&(o.maxLength=u),f?f.length===1?(o.contentMediaType=f[0],Object.assign(a,o)):(Object.assign(a,o),a.anyOf=f.map(h=>({contentMediaType:h}))):Object.assign(a,o)},E9=(e,t,n,r)=>{n.type="boolean"},C_=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},A9=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},E_=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},T9=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},M9=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},A_=(e,t,n,r)=>{const a=n,o=e._zod.def,{minimum:c,maximum:u}=e._zod.bag;typeof c=="number"&&(a.minItems=c),typeof u=="number"&&(a.maxItems=u),a.type="array",a.items=dn(o.element,t,{...r,path:[...r.path,"items"]})},T_=(e,t,n,r)=>{const a=n,o=e._zod.def;a.type="object",a.properties={};const c=o.shape;for(const h in c)a.properties[h]=dn(c[h],t,{...r,path:[...r.path,"properties",h]});const u=new Set(Object.keys(c)),f=new Set([...u].filter(h=>{const p=o.shape[h]._zod;return t.io==="input"?p.optin===void 0:p.optout===void 0}));f.size>0&&(a.required=Array.from(f)),o.catchall?._zod.def.type==="never"?a.additionalProperties=!1:o.catchall?o.catchall&&(a.additionalProperties=dn(o.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(a.additionalProperties=!1)},M_=(e,t,n,r)=>{const a=e._zod.def,o=a.inclusive===!1,c=a.options.map((u,f)=>dn(u,t,{...r,path:[...r.path,o?"oneOf":"anyOf",f]}));o?n.oneOf=c:n.anyOf=c},R_=(e,t,n,r)=>{const a=e._zod.def,o=dn(a.left,t,{...r,path:[...r.path,"allOf",0]}),c=dn(a.right,t,{...r,path:[...r.path,"allOf",1]}),u=h=>"allOf"in h&&Object.keys(h).length===1,f=[...u(o)?o.allOf:[o],...u(c)?c.allOf:[c]];n.allOf=f},R9=(e,t,n,r)=>{const a=n,o=e._zod.def;a.type="array";const c=t.target==="draft-2020-12"?"prefixItems":"items",u=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",f=o.items.map((v,y)=>dn(v,t,{...r,path:[...r.path,c,y]})),h=o.rest?dn(o.rest,t,{...r,path:[...r.path,u,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null;t.target==="draft-2020-12"?(a.prefixItems=f,h&&(a.items=h)):t.target==="openapi-3.0"?(a.items={anyOf:f},h&&a.items.anyOf.push(h),a.minItems=f.length,h||(a.maxItems=f.length)):(a.items=f,h&&(a.additionalItems=h));const{minimum:p,maximum:x}=e._zod.bag;typeof p=="number"&&(a.minItems=p),typeof x=="number"&&(a.maxItems=x)},I_=(e,t,n,r)=>{const a=n,o=e._zod.def;a.type="object";const c=o.keyType,f=c._zod.bag?.patterns;if(o.mode==="loose"&&f&&f.size>0){const p=dn(o.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});a.patternProperties={};for(const x of f)a.patternProperties[x.source]=p}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(a.propertyNames=dn(o.keyType,t,{...r,path:[...r.path,"propertyNames"]})),a.additionalProperties=dn(o.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const h=c._zod.values;if(h){const p=[...h].filter(x=>typeof x=="string"||typeof x=="number");p.length>0&&(a.required=p)}},__=(e,t,n,r)=>{const a=e._zod.def,o=dn(a.innerType,t,r),c=t.seen.get(e);t.target==="openapi-3.0"?(c.ref=a.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},O_=(e,t,n,r)=>{const a=e._zod.def;dn(a.innerType,t,r);const o=t.seen.get(e);o.ref=a.innerType},$_=(e,t,n,r)=>{const a=e._zod.def;dn(a.innerType,t,r);const o=t.seen.get(e);o.ref=a.innerType,n.default=JSON.parse(JSON.stringify(a.defaultValue))},L_=(e,t,n,r)=>{const a=e._zod.def;dn(a.innerType,t,r);const o=t.seen.get(e);o.ref=a.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(a.defaultValue)))},P_=(e,t,n,r)=>{const a=e._zod.def;dn(a.innerType,t,r);const o=t.seen.get(e);o.ref=a.innerType;let c;try{c=a.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=c},D_=(e,t,n,r)=>{const a=e._zod.def,o=t.io==="input"?a.in._zod.def.type==="transform"?a.out:a.in:a.out;dn(o,t,r);const c=t.seen.get(e);c.ref=o},z_=(e,t,n,r)=>{const a=e._zod.def;dn(a.innerType,t,r);const o=t.seen.get(e);o.ref=a.innerType,n.readOnly=!0},I9=(e,t,n,r)=>{const a=e._zod.def;dn(a.innerType,t,r);const o=t.seen.get(e);o.ref=a.innerType},nj=(e,t,n,r)=>{const a=e._zod.def;dn(a.innerType,t,r);const o=t.seen.get(e);o.ref=a.innerType},B_=(e,t,n,r)=>{const a=e._zod.innerType;dn(a,t,r);const o=t.seen.get(e);o.ref=a},wE={string:x_,number:y_,boolean:b_,bigint:x9,symbol:y9,null:w_,undefined:b9,void:w9,never:j_,any:j9,unknown:k_,date:k9,enum:N_,literal:S_,nan:N9,template_literal:S9,file:C9,success:E9,custom:C_,function:A9,transform:E_,map:T9,set:M9,array:A_,object:T_,union:M_,intersection:R_,tuple:R9,record:I_,nullable:__,nonoptional:O_,default:$_,prefault:L_,catch:P_,pipe:D_,readonly:z_,promise:I9,optional:nj,lazy:B_};function _9(e,t){if("_idmap"in e){const r=e,a=vp({...t,processors:wE}),o={};for(const f of r._idmap.entries()){const[h,p]=f;dn(p,a)}const c={},u={registry:r,uri:t?.uri,defs:o};a.external=u;for(const f of r._idmap.entries()){const[h,p]=f;xp(a,p),c[h]=yp(a,p)}if(Object.keys(o).length>0){const f=a.target==="draft-2020-12"?"$defs":"definitions";c.__shared={[f]:o}}return{schemas:c}}const n=vp({...t,processors:wE});return dn(e,n),xp(n,e),yp(n,e)}const O9=je("ZodISODateTime",(e,t)=>{LF.init(e,t),An.init(e,t)});function $9(e){return HV(O9,e)}const L9=je("ZodISODate",(e,t)=>{PF.init(e,t),An.init(e,t)});function P9(e){return WV(L9,e)}const D9=je("ZodISOTime",(e,t)=>{DF.init(e,t),An.init(e,t)});function z9(e){return qV(D9,e)}const B9=je("ZodISODuration",(e,t)=>{zF.init(e,t),An.init(e,t)});function U9(e){return KV(B9,e)}const F9=(e,t)=>{t_.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>AU(e,n)},flatten:{value:n=>EU(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,e0,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,e0,2)}},isEmpty:{get(){return e.issues.length===0}}})},Sr=je("ZodError",F9,{Parent:Error}),V9=Jw(Sr),H9=ej(Sr),W9=yg(Sr),U_=bg(Sr),q9=RU(Sr),K9=IU(Sr),G9=_U(Sr),Z9=OU(Sr),Y9=$U(Sr),X9=LU(Sr),Q9=PU(Sr),J9=DU(Sr),wn=je("ZodType",(e,t)=>(bn.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:bp(e,"input"),output:bp(e,"output")}}),e.toJSONSchema=g9(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(Ki(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),e.with=e.check,e.clone=(n,r)=>Gi(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>V9(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>W9(e,n,r),e.parseAsync=async(n,r)=>H9(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>U_(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>q9(e,n,r),e.decode=(n,r)=>K9(e,n,r),e.encodeAsync=async(n,r)=>G9(e,n,r),e.decodeAsync=async(n,r)=>Z9(e,n,r),e.safeEncode=(n,r)=>Y9(e,n,r),e.safeDecode=(n,r)=>X9(e,n,r),e.safeEncodeAsync=async(n,r)=>Q9(e,n,r),e.safeDecodeAsync=async(n,r)=>J9(e,n,r),e.refine=(n,r)=>e.check(ZH(n,r)),e.superRefine=n=>e.check(YH(n)),e.overwrite=n=>e.check(Vc(n)),e.optional=()=>NE(e),e.exactOptional=()=>$H(e),e.nullable=()=>SE(e),e.nullish=()=>NE(SE(e)),e.nonoptional=n=>UH(e,n),e.array=()=>Hc(e),e.or=n=>Cs([e,n]),e.and=n=>TH(e,n),e.transform=n=>CE(e,_H(n)),e.default=n=>DH(e,n),e.prefault=n=>BH(e,n),e.catch=n=>VH(e,n),e.pipe=n=>CE(e,n),e.readonly=()=>qH(e),e.describe=n=>{const r=e.clone();return ud.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return ud.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return ud.get(e);const r=e.clone();return ud.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),F_=je("_ZodString",(e,t)=>{tj.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(r,a,o)=>x_(e,r,a);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(e9(...r)),e.includes=(...r)=>e.check(s9(...r)),e.startsWith=(...r)=>e.check(r9(...r)),e.endsWith=(...r)=>e.check(a9(...r)),e.min=(...r)=>e.check(gp(...r)),e.max=(...r)=>e.check(g_(...r)),e.length=(...r)=>e.check(v_(...r)),e.nonempty=(...r)=>e.check(gp(1,...r)),e.lowercase=r=>e.check(t9(r)),e.uppercase=r=>e.check(n9(r)),e.trim=()=>e.check(o9()),e.normalize=(...r)=>e.check(i9(...r)),e.toLowerCase=()=>e.check(l9()),e.toUpperCase=()=>e.check(c9()),e.slugify=()=>e.check(u9())}),eH=je("ZodString",(e,t)=>{tj.init(e,t),F_.init(e,t),e.email=n=>e.check(kV(tH,n)),e.url=n=>e.check(AV(nH,n)),e.jwt=n=>e.check(VV(vH,n)),e.emoji=n=>e.check(TV(sH,n)),e.guid=n=>e.check(vE(jE,n)),e.uuid=n=>e.check(NV(Vh,n)),e.uuidv4=n=>e.check(SV(Vh,n)),e.uuidv6=n=>e.check(CV(Vh,n)),e.uuidv7=n=>e.check(EV(Vh,n)),e.nanoid=n=>e.check(MV(rH,n)),e.guid=n=>e.check(vE(jE,n)),e.cuid=n=>e.check(RV(aH,n)),e.cuid2=n=>e.check(IV(iH,n)),e.ulid=n=>e.check(_V(oH,n)),e.base64=n=>e.check(BV(mH,n)),e.base64url=n=>e.check(UV(pH,n)),e.xid=n=>e.check(OV(lH,n)),e.ksuid=n=>e.check($V(cH,n)),e.ipv4=n=>e.check(LV(uH,n)),e.ipv6=n=>e.check(PV(dH,n)),e.cidrv4=n=>e.check(DV(fH,n)),e.cidrv6=n=>e.check(zV(hH,n)),e.e164=n=>e.check(FV(gH,n)),e.datetime=n=>e.check($9(n)),e.date=n=>e.check(P9(n)),e.time=n=>e.check(z9(n)),e.duration=n=>e.check(U9(n))});function Ue(e){return jV(eH,e)}const An=je("ZodStringFormat",(e,t)=>{Sn.init(e,t),F_.init(e,t)}),tH=je("ZodEmail",(e,t)=>{EF.init(e,t),An.init(e,t)}),jE=je("ZodGUID",(e,t)=>{SF.init(e,t),An.init(e,t)}),Vh=je("ZodUUID",(e,t)=>{CF.init(e,t),An.init(e,t)}),nH=je("ZodURL",(e,t)=>{AF.init(e,t),An.init(e,t)}),sH=je("ZodEmoji",(e,t)=>{TF.init(e,t),An.init(e,t)}),rH=je("ZodNanoID",(e,t)=>{MF.init(e,t),An.init(e,t)}),aH=je("ZodCUID",(e,t)=>{RF.init(e,t),An.init(e,t)}),iH=je("ZodCUID2",(e,t)=>{IF.init(e,t),An.init(e,t)}),oH=je("ZodULID",(e,t)=>{_F.init(e,t),An.init(e,t)}),lH=je("ZodXID",(e,t)=>{OF.init(e,t),An.init(e,t)}),cH=je("ZodKSUID",(e,t)=>{$F.init(e,t),An.init(e,t)}),uH=je("ZodIPv4",(e,t)=>{BF.init(e,t),An.init(e,t)}),dH=je("ZodIPv6",(e,t)=>{UF.init(e,t),An.init(e,t)}),fH=je("ZodCIDRv4",(e,t)=>{FF.init(e,t),An.init(e,t)}),hH=je("ZodCIDRv6",(e,t)=>{VF.init(e,t),An.init(e,t)}),mH=je("ZodBase64",(e,t)=>{HF.init(e,t),An.init(e,t)}),pH=je("ZodBase64URL",(e,t)=>{qF.init(e,t),An.init(e,t)}),gH=je("ZodE164",(e,t)=>{KF.init(e,t),An.init(e,t)}),vH=je("ZodJWT",(e,t)=>{ZF.init(e,t),An.init(e,t)}),V_=je("ZodNumber",(e,t)=>{d_.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(r,a,o)=>y_(e,r,a),e.gt=(r,a)=>e.check(yE(r,a)),e.gte=(r,a)=>e.check(py(r,a)),e.min=(r,a)=>e.check(py(r,a)),e.lt=(r,a)=>e.check(xE(r,a)),e.lte=(r,a)=>e.check(my(r,a)),e.max=(r,a)=>e.check(my(r,a)),e.int=r=>e.check(kE(r)),e.safe=r=>e.check(kE(r)),e.positive=r=>e.check(yE(0,r)),e.nonnegative=r=>e.check(py(0,r)),e.negative=r=>e.check(xE(0,r)),e.nonpositive=r=>e.check(my(0,r)),e.multipleOf=(r,a)=>e.check(bE(r,a)),e.step=(r,a)=>e.check(bE(r,a)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function xH(e){return GV(V_,e)}const yH=je("ZodNumberFormat",(e,t)=>{YF.init(e,t),V_.init(e,t)});function kE(e){return ZV(yH,e)}const bH=je("ZodBoolean",(e,t)=>{XF.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>b_(e,n,r)});function ws(e){return YV(bH,e)}const wH=je("ZodNull",(e,t)=>{QF.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>w_(e,n,r)});function jH(e){return XV(wH,e)}const kH=je("ZodUnknown",(e,t)=>{JF.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>k_()});function ea(){return QV(kH)}const NH=je("ZodNever",(e,t)=>{eV.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>j_(e,n,r)});function H_(e){return JV(NH,e)}const SH=je("ZodArray",(e,t)=>{tV.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>A_(e,n,r,a),e.element=t.element,e.min=(n,r)=>e.check(gp(n,r)),e.nonempty=n=>e.check(gp(1,n)),e.max=(n,r)=>e.check(g_(n,r)),e.length=(n,r)=>e.check(v_(n,r)),e.unwrap=()=>e.element});function Hc(e,t){return d9(SH,e,t)}const W_=je("ZodObject",(e,t)=>{sV.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>T_(e,n,r,a),Bt(e,"shape",()=>t.shape),e.keyof=()=>K_(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:ea()}),e.loose=()=>e.clone({...e._zod.def,catchall:ea()}),e.strict=()=>e.clone({...e._zod.def,catchall:H_()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>jU(e,n),e.safeExtend=n=>kU(e,n),e.merge=n=>NU(e,n),e.pick=n=>bU(e,n),e.omit=n=>wU(e,n),e.partial=(...n)=>SU(G_,e,n[0]),e.required=(...n)=>CU(Z_,e,n[0])});function on(e,t){const n={type:"object",shape:e??{},...et(t)};return new W_(n)}function pn(e,t){return new W_({type:"object",shape:e,catchall:H_(),...et(t)})}const q_=je("ZodUnion",(e,t)=>{m_.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>M_(e,n,r,a),e.options=t.options});function Cs(e,t){return new q_({type:"union",options:e,...et(t)})}const CH=je("ZodDiscriminatedUnion",(e,t)=>{q_.init(e,t),rV.init(e,t)});function EH(e,t,n){return new CH({type:"union",options:t,discriminator:e,...et(n)})}const AH=je("ZodIntersection",(e,t)=>{aV.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>R_(e,n,r,a)});function TH(e,t){return new AH({type:"intersection",left:e,right:t})}const MH=je("ZodRecord",(e,t)=>{iV.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>I_(e,n,r,a),e.keyType=t.keyType,e.valueType=t.valueType});function Vd(e,t,n){return new MH({type:"record",keyType:e,valueType:t,...et(n)})}const n0=je("ZodEnum",(e,t)=>{oV.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(r,a,o)=>N_(e,r,a),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,a)=>{const o={};for(const c of r)if(n.has(c))o[c]=t.entries[c];else throw new Error(`Key ${c} not found in enum`);return new n0({...t,checks:[],...et(a),entries:o})},e.exclude=(r,a)=>{const o={...t.entries};for(const c of r)if(n.has(c))delete o[c];else throw new Error(`Key ${c} not found in enum`);return new n0({...t,checks:[],...et(a),entries:o})}});function K_(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new n0({type:"enum",entries:n,...et(t)})}const RH=je("ZodLiteral",(e,t)=>{lV.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>S_(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function ut(e,t){return new RH({type:"literal",values:Array.isArray(e)?e:[e],...et(t)})}const IH=je("ZodTransform",(e,t)=>{cV.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>E_(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Z2(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(Fd(o,n.value,t));else{const c=o;c.fatal&&(c.continue=!1),c.code??(c.code="custom"),c.input??(c.input=n.value),c.inst??(c.inst=e),n.issues.push(Fd(c))}};const a=t.transform(n.value,n);return a instanceof Promise?a.then(o=>(n.value=o,n)):(n.value=a,n)}});function _H(e){return new IH({type:"transform",transform:e})}const G_=je("ZodOptional",(e,t)=>{p_.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>nj(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function NE(e){return new G_({type:"optional",innerType:e})}const OH=je("ZodExactOptional",(e,t)=>{uV.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>nj(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function $H(e){return new OH({type:"optional",innerType:e})}const LH=je("ZodNullable",(e,t)=>{dV.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>__(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function SE(e){return new LH({type:"nullable",innerType:e})}const PH=je("ZodDefault",(e,t)=>{fV.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>$_(e,n,r,a),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function DH(e,t){return new PH({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():J2(t)}})}const zH=je("ZodPrefault",(e,t)=>{hV.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>L_(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function BH(e,t){return new zH({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():J2(t)}})}const Z_=je("ZodNonOptional",(e,t)=>{mV.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>O_(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function UH(e,t){return new Z_({type:"nonoptional",innerType:e,...et(t)})}const FH=je("ZodCatch",(e,t)=>{pV.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>P_(e,n,r,a),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function VH(e,t){return new FH({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const HH=je("ZodPipe",(e,t)=>{gV.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>D_(e,n,r,a),e.in=t.in,e.out=t.out});function CE(e,t){return new HH({type:"pipe",in:e,out:t})}const WH=je("ZodReadonly",(e,t)=>{vV.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>z_(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function qH(e){return new WH({type:"readonly",innerType:e})}const KH=je("ZodLazy",(e,t)=>{xV.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>B_(e,n,r,a),e.unwrap=()=>e._zod.def.getter()});function GH(e){return new KH({type:"lazy",getter:e})}const sj=je("ZodCustom",(e,t)=>{yV.init(e,t),wn.init(e,t),e._zod.processJSONSchema=(n,r,a)=>C_(e,n)});function Y_(e,t){return f9(sj,e??(()=>!0),t)}function ZH(e,t={}){return h9(sj,e,t)}function YH(e){return m9(e)}function wp(e,t={}){const n=new sj({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...et(t)});return n._zod.bag.Class=e,n._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:n,path:[...n._zod.def.path??[]]})},n}var Hd;(function(e){e.assertEqual=a=>{};function t(a){}e.assertIs=t;function n(a){throw new Error}e.assertNever=n,e.arrayToEnum=a=>{const o={};for(const c of a)o[c]=c;return o},e.getValidEnumValues=a=>{const o=e.objectKeys(a).filter(u=>typeof a[a[u]]!="number"),c={};for(const u of o)c[u]=a[u];return e.objectValues(c)},e.objectValues=a=>e.objectKeys(a).map(function(o){return a[o]}),e.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const o=[];for(const c in a)Object.prototype.hasOwnProperty.call(a,c)&&o.push(c);return o},e.find=(a,o)=>{for(const c of a)if(o(c))return c},e.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function r(a,o=" | "){return a.map(c=>typeof c=="string"?`'${c}'`:c).join(o)}e.joinValues=r,e.jsonStringifyReplacer=(a,o)=>typeof o=="bigint"?o.toString():o})(Hd||(Hd={}));var EE;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(EE||(EE={}));Hd.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);Hd.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class jp extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(o){return o.message},r={_errors:[]},a=o=>{for(const c of o.issues)if(c.code==="invalid_union")c.unionErrors.map(a);else if(c.code==="invalid_return_type")a(c.returnTypeError);else if(c.code==="invalid_arguments")a(c.argumentsError);else if(c.path.length===0)r._errors.push(n(c));else{let u=r,f=0;for(;f<c.path.length;){const h=c.path[f];f===c.path.length-1?(u[h]=u[h]||{_errors:[]},u[h]._errors.push(n(c))):u[h]=u[h]||{_errors:[]},u=u[h],f++}}};return a(this),r}static assert(t){if(!(t instanceof jp))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Hd.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n=Object.create(null),r=[];for(const a of this.issues)if(a.path.length>0){const o=a.path[0];n[o]=n[o]||[],n[o].push(t(a))}else r.push(t(a));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}jp.create=e=>new jp(e);var AE;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(AE||(AE={}));var xt;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(xt||(xt={}));class TE extends Error{constructor(t,n){super(t),this.name="ParseError",this.type=n.type,this.field=n.field,this.value=n.value,this.line=n.line}}const ME=10,XH=13,wo=32;function gy(e){}function QH(e){if(typeof e=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=gy,onError:n=gy,onRetry:r=gy,onComment:a}=e;let o="",c=!0,u,f="",h=0,p;function x(S){if(c){c=!1,v(S);return}const k=o===""?S:o+S;o=y(k)}function v(S){S.charCodeAt(0)===239&&S.charCodeAt(1)===187&&S.charCodeAt(2)===191&&(S=S.slice(3));const k=o===""?S:o+S;o=y(k)}function y(S){let k=0;if(S.indexOf("\r")===-1){let N=S.indexOf(`
50
- `,k);for(;N!==-1;){if(k===N){h>0&&t({id:u,event:p,data:f}),u=void 0,f="",h=0,p=void 0,k=N+1,N=S.indexOf(`
51
- `,k);continue}const T=S.charCodeAt(k);if(RE(S,k,T)){const R=S.charCodeAt(k+5)===wo?k+6:k+5,O=S.slice(R,N);if(h===0&&S.charCodeAt(N+1)===ME){t({id:u,event:p,data:O}),u=void 0,f="",p=void 0,k=N+2,N=S.indexOf(`
52
- `,k);continue}f=h===0?O:`${f}
53
- ${O}`,h++}else IE(S,k,T)?p=S.slice(S.charCodeAt(k+6)===wo?k+7:k+6,N)||void 0:b(S,k,N);k=N+1,N=S.indexOf(`
54
- `,k)}return S.slice(k)}for(;k<S.length;){const N=S.indexOf("\r",k),T=S.indexOf(`
55
- `,k);let R=-1;if(N!==-1&&T!==-1?R=N<T?N:T:N!==-1?N===S.length-1?R=-1:R=N:T!==-1&&(R=T),R===-1)break;b(S,k,R),k=R+1,S.charCodeAt(k-1)===XH&&S.charCodeAt(k)===ME&&k++}return S.slice(k)}function b(S,k,N){if(k===N){E();return}const T=S.charCodeAt(k);if(RE(S,k,T)){const _=S.charCodeAt(k+5)===wo?k+6:k+5,U=S.slice(_,N);f=h===0?U:`${f}
56
- ${U}`,h++;return}if(IE(S,k,T)){p=S.slice(S.charCodeAt(k+6)===wo?k+7:k+6,N)||void 0;return}if(T===105&&S.charCodeAt(k+1)===100&&S.charCodeAt(k+2)===58){const _=S.slice(S.charCodeAt(k+3)===wo?k+4:k+3,N);u=_.includes("\0")?void 0:_;return}if(T===58){if(a){const _=S.slice(k,N);a(_.slice(S.charCodeAt(k+1)===wo?2:1))}return}const R=S.slice(k,N),O=R.indexOf(":");if(O===-1){C(R,"",R);return}const L=R.slice(0,O),I=R.charCodeAt(O+1)===wo?2:1,z=R.slice(O+I);C(L,z,R)}function C(S,k,N){switch(S){case"event":p=k||void 0;break;case"data":f=h===0?k:`${f}
57
- ${k}`,h++;break;case"id":u=k.includes("\0")?void 0:k;break;case"retry":/^\d+$/.test(k)?r(parseInt(k,10)):n(new TE(`Invalid \`retry\` value: "${k}"`,{type:"invalid-retry",value:k,line:N}));break;default:n(new TE(`Unknown field "${S.length>20?`${S.slice(0,20)}…`:S}"`,{type:"unknown-field",field:S,value:k,line:N}));break}}function E(){h>0&&t({id:u,event:p,data:f}),u=void 0,f="",h=0,p=void 0}function A(S={}){o&&S.consume&&b(o,0,o.length),c=!0,u=void 0,f="",h=0,p=void 0,o=""}return{feed:x,reset:A}}function RE(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function IE(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}class JH extends TransformStream{constructor({onError:t,onRetry:n,onComment:r}={}){let a;super({start(o){a=QH({onEvent:c=>{o.enqueue(c)},onError(c){t==="terminate"?o.error(c):typeof t=="function"&&t(c)},onRetry:n,onComment:r})},transform(o){a.feed(o)}})}}var ff=({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:r="-"}={})=>{const a=()=>{const o=n.length,c=new Array(t);for(let u=0;u<t;u++)c[u]=n[Math.random()*o|0];return c.join("")};if(e==null)return a;if(n.includes(r))throw new dU({argument:"separator",message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${a()}`},eW=ff();function Hl(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((n,r)=>{t[r.toLowerCase()]=n});else{Array.isArray(e)||(e=Object.entries(e));for(const[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}var tW=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,nW=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function _E(e){const t=JSON.parse(e);return t===null||typeof t!="object"||tW.test(e)===!1&&nW.test(e)===!1?t:sW(t)}function sW(e){let t=[e];for(;t.length;){const n=t;t=[];for(const r of n){if(Object.prototype.hasOwnProperty.call(r,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(r,"constructor")&&r.constructor!==null&&typeof r.constructor=="object"&&Object.prototype.hasOwnProperty.call(r.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const a in r){const o=r[a];o&&typeof o=="object"&&t.push(o)}}}return e}function rW(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return _E(e)}try{return _E(e)}finally{Error.stackTraceLimit=t}}function rj(e){if(e.type==="object"||Array.isArray(e.type)&&e.type.includes("object")){e.additionalProperties=!1;const{properties:n}=e;if(n!=null)for(const r of Object.keys(n))n[r]=jo(n[r])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(jo):jo(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(jo)),e.allOf!=null&&(e.allOf=e.allOf.map(jo)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(jo));const{definitions:t}=e;if(t!=null)for(const n of Object.keys(t))t[n]=jo(t[n]);return e}function jo(e){return typeof e=="boolean"?e:rj(e)}var aW=Symbol("Let zodToJsonSchema decide on which parser to use"),OE={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},iW=e=>typeof e=="string"?{...OE,name:e}:{...OE,...e};function tr(){return{}}function oW(e,t){var n,r,a;const o={type:"array"};return(n=e.type)!=null&&n._def&&((a=(r=e.type)==null?void 0:r._def)==null?void 0:a.typeName)!==xt.ZodAny&&(o.items=en(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(o.minItems=e.minLength.value),e.maxLength&&(o.maxItems=e.maxLength.value),e.exactLength&&(o.minItems=e.exactLength.value,o.maxItems=e.exactLength.value),o}function lW(e){const t={type:"integer",format:"int64"};if(!e.checks)return t;for(const n of e.checks)switch(n.kind){case"min":n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case"max":n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case"multipleOf":t.multipleOf=n.value;break}return t}function cW(){return{type:"boolean"}}function X_(e,t){return en(e.type._def,t)}var uW=(e,t)=>en(e.innerType._def,t);function Q_(e,t,n){const r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((a,o)=>Q_(e,t,a))};switch(r){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return dW(e)}}var dW=e=>{const t={type:"integer",format:"unix-time"};for(const n of e.checks)switch(n.kind){case"min":t.minimum=n.value;break;case"max":t.maximum=n.value;break}return t};function fW(e,t){return{...en(e.innerType._def,t),default:e.defaultValue()}}function hW(e,t){return t.effectStrategy==="input"?en(e.schema._def,t):tr()}function mW(e){return{type:"string",enum:Array.from(e.values)}}var pW=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function gW(e,t){const n=[en(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),en(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(a=>!!a),r=[];return n.forEach(a=>{if(pW(a))r.push(...a.allOf);else{let o=a;if("additionalProperties"in a&&a.additionalProperties===!1){const{additionalProperties:c,...u}=a;o=u}r.push(o)}}),r.length?{allOf:r}:void 0}function vW(e){const t=typeof e.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(e.value)?"array":"object"}:{type:t==="bigint"?"integer":t,const:e.value}}var vy=void 0,Rr={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(vy===void 0&&(vy=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),vy),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function J_(e,t){const n={type:"string"};if(e.checks)for(const r of e.checks)switch(r.kind){case"min":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value;break;case"max":n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value;break;case"email":switch(t.emailStrategy){case"format:email":Ir(n,"email",r.message,t);break;case"format:idn-email":Ir(n,"idn-email",r.message,t);break;case"pattern:zod":xs(n,Rr.email,r.message,t);break}break;case"url":Ir(n,"uri",r.message,t);break;case"uuid":Ir(n,"uuid",r.message,t);break;case"regex":xs(n,r.regex,r.message,t);break;case"cuid":xs(n,Rr.cuid,r.message,t);break;case"cuid2":xs(n,Rr.cuid2,r.message,t);break;case"startsWith":xs(n,RegExp(`^${xy(r.value,t)}`),r.message,t);break;case"endsWith":xs(n,RegExp(`${xy(r.value,t)}$`),r.message,t);break;case"datetime":Ir(n,"date-time",r.message,t);break;case"date":Ir(n,"date",r.message,t);break;case"time":Ir(n,"time",r.message,t);break;case"duration":Ir(n,"duration",r.message,t);break;case"length":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value,n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value;break;case"includes":{xs(n,RegExp(xy(r.value,t)),r.message,t);break}case"ip":{r.version!=="v6"&&Ir(n,"ipv4",r.message,t),r.version!=="v4"&&Ir(n,"ipv6",r.message,t);break}case"base64url":xs(n,Rr.base64url,r.message,t);break;case"jwt":xs(n,Rr.jwt,r.message,t);break;case"cidr":{r.version!=="v6"&&xs(n,Rr.ipv4Cidr,r.message,t),r.version!=="v4"&&xs(n,Rr.ipv6Cidr,r.message,t);break}case"emoji":xs(n,Rr.emoji(),r.message,t);break;case"ulid":{xs(n,Rr.ulid,r.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{Ir(n,"binary",r.message,t);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{xs(n,Rr.base64,r.message,t);break}}break}case"nanoid":xs(n,Rr.nanoid,r.message,t)}return n}function xy(e,t){return t.patternStrategy==="escape"?yW(e):e}var xW=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function yW(e){let t="";for(let n=0;n<e.length;n++)xW.has(e[n])||(t+="\\"),t+=e[n];return t}function Ir(e,t,n,r){var a;e.format||(a=e.anyOf)!=null&&a.some(o=>o.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function xs(e,t,n,r){var a;e.pattern||(a=e.allOf)!=null&&a.some(o=>o.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:$E(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=$E(t,r)}function $E(e,t){var n;if(!t.applyRegexFlags||!e.flags)return e.source;const r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},a=r.i?e.source.toLowerCase():e.source;let o="",c=!1,u=!1,f=!1;for(let h=0;h<a.length;h++){if(c){o+=a[h],c=!1;continue}if(r.i){if(u){if(a[h].match(/[a-z]/)){f?(o+=a[h],o+=`${a[h-2]}-${a[h]}`.toUpperCase(),f=!1):a[h+1]==="-"&&((n=a[h+2])!=null&&n.match(/[a-z]/))?(o+=a[h],f=!0):o+=`${a[h]}${a[h].toUpperCase()}`;continue}}else if(a[h].match(/[a-z]/)){o+=`[${a[h]}${a[h].toUpperCase()}]`;continue}}if(r.m){if(a[h]==="^"){o+=`(^|(?<=[\r
58
- ]))`;continue}else if(a[h]==="$"){o+=`($|(?=[\r
59
- ]))`;continue}}if(r.s&&a[h]==="."){o+=u?`${a[h]}\r
60
- `:`[${a[h]}\r
61
- ]`;continue}o+=a[h],a[h]==="\\"?c=!0:u&&a[h]==="]"?u=!1:!u&&a[h]==="["&&(u=!0)}try{new RegExp(o)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return o}function eO(e,t){var n,r,a,o,c,u;const f={type:"object",additionalProperties:(n=en(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((r=e.keyType)==null?void 0:r._def.typeName)===xt.ZodString&&((a=e.keyType._def.checks)!=null&&a.length)){const{type:h,...p}=J_(e.keyType._def,t);return{...f,propertyNames:p}}else{if(((o=e.keyType)==null?void 0:o._def.typeName)===xt.ZodEnum)return{...f,propertyNames:{enum:e.keyType._def.values}};if(((c=e.keyType)==null?void 0:c._def.typeName)===xt.ZodBranded&&e.keyType._def.type._def.typeName===xt.ZodString&&((u=e.keyType._def.type._def.checks)!=null&&u.length)){const{type:h,...p}=X_(e.keyType._def,t);return{...f,propertyNames:p}}}return f}function bW(e,t){if(t.mapStrategy==="record")return eO(e,t);const n=en(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||tr(),r=en(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||tr();return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function wW(e){const t=e.values,r=Object.keys(e.values).filter(o=>typeof t[t[o]]!="number").map(o=>t[o]),a=Array.from(new Set(r.map(o=>typeof o)));return{type:a.length===1?a[0]==="string"?"string":"number":["string","number"],enum:r}}function jW(){return{not:tr()}}function kW(){return{type:"null"}}var s0={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function NW(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(r=>r._def.typeName in s0&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((a,o)=>{const c=s0[o._def.typeName];return c&&!a.includes(c)?[...a,c]:a},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){const r=n.reduce((a,o)=>{const c=typeof o._def.value;switch(c){case"string":case"number":case"boolean":return[...a,c];case"bigint":return[...a,"integer"];case"object":if(o._def.value===null)return[...a,"null"];default:return a}},[]);if(r.length===n.length){const a=r.filter((o,c,u)=>u.indexOf(o)===c);return{type:a.length>1?a:a[0],enum:n.reduce((o,c)=>o.includes(c._def.value)?o:[...o,c._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,a)=>[...r,...a._def.values.filter(o=>!r.includes(o))],[])};return SW(e,t)}var SW=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((r,a)=>en(r._def,{...t,currentPath:[...t.currentPath,"anyOf",`${a}`]})).filter(r=>!!r&&(!t.strictUnions||typeof r=="object"&&Object.keys(r).length>0));return n.length?{anyOf:n}:void 0};function CW(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[s0[e.innerType._def.typeName],"null"]};const n=en(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function EW(e){const t={type:"number"};if(!e.checks)return t;for(const n of e.checks)switch(n.kind){case"int":t.type="integer";break;case"min":n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case"max":n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case"multipleOf":t.multipleOf=n.value;break}return t}function AW(e,t){const n={type:"object",properties:{}},r=[],a=e.shape();for(const c in a){let u=a[c];if(u===void 0||u._def===void 0)continue;const f=MW(u),h=en(u._def,{...t,currentPath:[...t.currentPath,"properties",c],propertyPath:[...t.currentPath,"properties",c]});h!==void 0&&(n.properties[c]=h,f||r.push(c))}r.length&&(n.required=r);const o=TW(e,t);return o!==void 0&&(n.additionalProperties=o),n}function TW(e,t){if(e.catchall._def.typeName!=="ZodNever")return en(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function MW(e){try{return e.isOptional()}catch{return!0}}var RW=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return en(e.innerType._def,t);const r=en(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:tr()},r]}:tr()},IW=(e,t)=>{if(t.pipeStrategy==="input")return en(e.in._def,t);if(t.pipeStrategy==="output")return en(e.out._def,t);const n=en(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),r=en(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(a=>a!==void 0)}};function _W(e,t){return en(e.type._def,t)}function OW(e,t){const r={type:"array",uniqueItems:!0,items:en(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(r.minItems=e.minSize.value),e.maxSize&&(r.maxItems=e.maxSize.value),r}function $W(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,r)=>en(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:en(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,r)=>en(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function LW(){return{not:tr()}}function PW(){return tr()}var DW=(e,t)=>en(e.innerType._def,t),zW=(e,t,n)=>{switch(t){case xt.ZodString:return J_(e,n);case xt.ZodNumber:return EW(e);case xt.ZodObject:return AW(e,n);case xt.ZodBigInt:return lW(e);case xt.ZodBoolean:return cW();case xt.ZodDate:return Q_(e,n);case xt.ZodUndefined:return LW();case xt.ZodNull:return kW();case xt.ZodArray:return oW(e,n);case xt.ZodUnion:case xt.ZodDiscriminatedUnion:return NW(e,n);case xt.ZodIntersection:return gW(e,n);case xt.ZodTuple:return $W(e,n);case xt.ZodRecord:return eO(e,n);case xt.ZodLiteral:return vW(e);case xt.ZodEnum:return mW(e);case xt.ZodNativeEnum:return wW(e);case xt.ZodNullable:return CW(e,n);case xt.ZodOptional:return RW(e,n);case xt.ZodMap:return bW(e,n);case xt.ZodSet:return OW(e,n);case xt.ZodLazy:return()=>e.getter()._def;case xt.ZodPromise:return _W(e,n);case xt.ZodNaN:case xt.ZodNever:return jW();case xt.ZodEffects:return hW(e,n);case xt.ZodAny:return tr();case xt.ZodUnknown:return PW();case xt.ZodDefault:return fW(e,n);case xt.ZodBranded:return X_(e,n);case xt.ZodReadonly:return DW(e,n);case xt.ZodCatch:return uW(e,n);case xt.ZodPipeline:return IW(e,n);case xt.ZodFunction:case xt.ZodVoid:case xt.ZodSymbol:return;default:return(r=>{})()}},BW=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join("/")};function en(e,t,n=!1){var r;const a=t.seen.get(e);if(t.override){const f=(r=t.override)==null?void 0:r.call(t,e,t,a,n);if(f!==aW)return f}if(a&&!n){const f=UW(a,t);if(f!==void 0)return f}const o={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,o);const c=zW(e,e.typeName,t),u=typeof c=="function"?en(c(),t):c;if(u&&FW(e,t,u),t.postProcess){const f=t.postProcess(u,e,t);return o.jsonSchema=u,f}return o.jsonSchema=u,u}var UW=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:BW(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((n,r)=>t.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),tr()):t.$refStrategy==="seen"?tr():void 0}},FW=(e,t,n)=>(e.description&&(n.description=e.description),n),VW=e=>{const t=iW(e),n=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([r,a])=>[a._def,{def:a._def,path:[...t.basePath,t.definitionPath,r],jsonSchema:void 0}]))}},HW=(e,t)=>{var n;const r=VW(t);let a=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((h,[p,x])=>{var v;return{...h,[p]:(v=en(x._def,{...r,currentPath:[...r.basePath,r.definitionPath,p]},!0))!=null?v:tr()}},{}):void 0;const o=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,c=(n=en(e._def,o===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,o]},!1))!=null?n:tr(),u=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;u!==void 0&&(c.title=u);const f=o===void 0?a?{...c,[r.definitionPath]:a}:c:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,o].join("/"),[r.definitionPath]:{...a,[o]:c}};return f.$schema="http://json-schema.org/draft-07/schema#",f},r0=Symbol.for("vercel.ai.schema");function WW(e){let t;return()=>(t==null&&(t=e()),t)}function jg(e,{validate:t}={}){return{[r0]:!0,_type:void 0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function qW(e){return typeof e=="object"&&e!==null&&r0 in e&&e[r0]===!0&&"jsonSchema"in e&&"validate"in e}function aj(e){return e==null?jg({properties:{},additionalProperties:!1}):qW(e)?e:"~standard"in e?e["~standard"].vendor==="zod"?tO(e):KW(e):e()}function KW(e){return jg(()=>rj(e["~standard"].jsonSchema.input({target:"draft-07"})),{validate:async t=>{const n=await e["~standard"].validate(t);return"value"in n?{success:!0,value:n.value}:{success:!1,error:new Mc({value:t,cause:n.issues})}}})}function GW(e,t){var n;const r=(n=void 0)!=null?n:!1;return jg(()=>HW(e,{$refStrategy:r?"root":"none"}),{validate:async a=>{const o=await e.safeParseAsync(a);return o.success?{success:!0,value:o.data}:{success:!1,error:o.error}}})}function ZW(e,t){var n;const r=(n=void 0)!=null?n:!1;return jg(()=>rj(_9(e,{target:"draft-7",io:"input",reused:r?"ref":"inline"})),{validate:async a=>{const o=await U_(e,a);return o.success?{success:!0,value:o.data}:{success:!1,error:o.error}}})}function YW(e){return"_zod"in e}function tO(e,t){return YW(e)?ZW(e):GW(e)}async function LE({value:e,schema:t,context:n}){const r=await Wd({value:e,schema:t,context:n});if(!r.success)throw Mc.wrap({value:e,cause:r.error,context:n});return r.value}async function Wd({value:e,schema:t,context:n}){const r=aj(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};const a=await r.validate(e);return a.success?{success:!0,value:a.value,rawValue:e}:{success:!1,error:Mc.wrap({value:e,cause:a.error,context:n}),rawValue:e}}catch(a){return{success:!1,error:Mc.wrap({value:e,cause:a,context:n}),rawValue:e}}}async function Qo({text:e,schema:t}){try{const n=rW(e);return t==null?{success:!0,value:n,rawValue:n}:await Wd({value:n,schema:t})}catch(n){return{success:!1,error:nE.isInstance(n)?n:new nE({text:e,cause:n}),rawValue:void 0}}}function XW({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new JH).pipeThrough(new TransformStream({async transform({data:n},r){n!=="[DONE]"&&r.enqueue(await Qo({text:n,schema:t}))}}))}async function Ni(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var QW=Object.defineProperty,JW=(e,t)=>{for(var n in t)QW(e,n,{get:t[n],enumerable:!0})},nO="AI_NoObjectGeneratedError",sO=`vercel.ai.error.${nO}`,eq=Symbol.for(sO),rO,_i=class extends ca{constructor({message:e="No object generated.",cause:t,text:n,response:r,usage:a,finishReason:o}){super({name:nO,message:e,cause:t}),this[rO]=!0,this.text=n,this.response=r,this.usage=a,this.finishReason=o}static isInstance(e){return ca.hasMarker(e,sO)}};rO=eq;var aO="AI_UIMessageStreamError",iO=`vercel.ai.error.${aO}`,tq=Symbol.for(iO),oO,Wl=class extends ca{constructor({chunkType:e,chunkId:t,message:n}){super({name:aO,message:n}),this[oO]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return ca.hasMarker(e,iO)}};oO=tq;var lO=Cs([Ue(),wp(Uint8Array),wp(ArrayBuffer),Y_(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]),qd=GH(()=>Cs([jH(),Ue(),xH(),ws(),Vd(Ue(),qd.optional()),Hc(qd)])),Ot=Vd(Ue(),Vd(Ue(),qd.optional())),cO=on({type:ut("text"),text:Ue(),providerOptions:Ot.optional()}),nq=on({type:ut("image"),image:Cs([lO,wp(URL)]),mediaType:Ue().optional(),providerOptions:Ot.optional()}),uO=on({type:ut("file"),data:Cs([lO,wp(URL)]),filename:Ue().optional(),mediaType:Ue(),providerOptions:Ot.optional()}),sq=on({type:ut("reasoning"),text:Ue(),providerOptions:Ot.optional()}),rq=on({type:ut("tool-call"),toolCallId:Ue(),toolName:Ue(),input:ea(),providerOptions:Ot.optional(),providerExecuted:ws().optional()}),aq=EH("type",[on({type:ut("text"),value:Ue(),providerOptions:Ot.optional()}),on({type:ut("json"),value:qd,providerOptions:Ot.optional()}),on({type:ut("execution-denied"),reason:Ue().optional(),providerOptions:Ot.optional()}),on({type:ut("error-text"),value:Ue(),providerOptions:Ot.optional()}),on({type:ut("error-json"),value:qd,providerOptions:Ot.optional()}),on({type:ut("content"),value:Hc(Cs([on({type:ut("text"),text:Ue(),providerOptions:Ot.optional()}),on({type:ut("media"),data:Ue(),mediaType:Ue()}),on({type:ut("file-data"),data:Ue(),mediaType:Ue(),filename:Ue().optional(),providerOptions:Ot.optional()}),on({type:ut("file-url"),url:Ue(),providerOptions:Ot.optional()}),on({type:ut("file-id"),fileId:Cs([Ue(),Vd(Ue(),Ue())]),providerOptions:Ot.optional()}),on({type:ut("image-data"),data:Ue(),mediaType:Ue(),providerOptions:Ot.optional()}),on({type:ut("image-url"),url:Ue(),providerOptions:Ot.optional()}),on({type:ut("image-file-id"),fileId:Cs([Ue(),Vd(Ue(),Ue())]),providerOptions:Ot.optional()}),on({type:ut("custom"),providerOptions:Ot.optional()})]))})]),dO=on({type:ut("tool-result"),toolCallId:Ue(),toolName:Ue(),output:aq,providerOptions:Ot.optional()}),iq=on({type:ut("tool-approval-request"),approvalId:Ue(),toolCallId:Ue()}),oq=on({type:ut("tool-approval-response"),approvalId:Ue(),approved:ws(),reason:Ue().optional()}),lq=on({role:ut("system"),content:Ue(),providerOptions:Ot.optional()}),cq=on({role:ut("user"),content:Cs([Ue(),Hc(Cs([cO,nq,uO]))]),providerOptions:Ot.optional()}),uq=on({role:ut("assistant"),content:Cs([Ue(),Hc(Cs([cO,uO,sq,rq,dO,iq]))]),providerOptions:Ot.optional()}),dq=on({role:ut("tool"),content:Hc(Cs([dO,oq])),providerOptions:Ot.optional()});Cs([lq,cq,uq,dq]);function fO(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const n={...e};for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const a=t[r];if(a===void 0)continue;const o=r in e?e[r]:void 0,c=a!==null&&typeof a=="object"&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp),u=o!=null&&typeof o=="object"&&!Array.isArray(o)&&!(o instanceof Date)&&!(o instanceof RegExp);c&&u?n[r]=fO(o,a):n[r]=a}return n}var fq={};JW(fq,{array:()=>gq,choice:()=>vq,json:()=>xq,object:()=>pq,text:()=>mq});function hq(e){const t=["ROOT"];let n=-1,r=null;function a(f,h,p){switch(f){case'"':{n=h,t.pop(),t.push(p),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=h,r=h,t.pop(),t.push(p),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(p),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=h,t.pop(),t.push(p),t.push("INSIDE_NUMBER");break}case"{":{n=h,t.pop(),t.push(p),t.push("INSIDE_OBJECT_START");break}case"[":{n=h,t.pop(),t.push(p),t.push("INSIDE_ARRAY_START");break}}}function o(f,h){switch(f){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=h,t.pop();break}}}function c(f,h){switch(f){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=h,t.pop();break}}}for(let f=0;f<e.length;f++){const h=e[f];switch(t[t.length-1]){case"ROOT":a(h,f,"FINISH");break;case"INSIDE_OBJECT_START":{switch(h){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=f,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{h==='"'&&(t.pop(),t.push("INSIDE_OBJECT_KEY"));break}case"INSIDE_OBJECT_KEY":{h==='"'&&(t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY"));break}case"INSIDE_OBJECT_AFTER_KEY":{h===":"&&(t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE"));break}case"INSIDE_OBJECT_BEFORE_VALUE":{a(h,f,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{o(h,f);break}case"INSIDE_STRING":{switch(h){case'"':{t.pop(),n=f;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=f}break}case"INSIDE_ARRAY_START":{h==="]"?(n=f,t.pop()):(n=f,a(h,f,"INSIDE_ARRAY_AFTER_VALUE"));break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(h){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=f,t.pop();break}default:{n=f;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{a(h,f,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=f;break}case"INSIDE_NUMBER":{switch(h){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=f;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&c(h,f),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&o(h,f);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&o(h,f);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&c(h,f);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const x=e.substring(r,f+1);!"false".startsWith(x)&&!"true".startsWith(x)&&!"null".startsWith(x)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?o(h,f):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&c(h,f)):n=f;break}}}let u=e.slice(0,n+1);for(let f=t.length-1;f>=0;f--)switch(t[f]){case"INSIDE_STRING":{u+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{u+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{u+="]";break}case"INSIDE_LITERAL":{const p=e.substring(r,e.length);"true".startsWith(p)?u+="true".slice(p.length):"false".startsWith(p)?u+="false".slice(p.length):"null".startsWith(p)&&(u+="null".slice(p.length))}}return u}async function hf(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await Qo({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await Qo({text:hq(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var mq=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),pq=({schema:e,name:t,description:n})=>{const r=aj(e);return{name:"object",responseFormat:Ni(r.jsonSchema).then(a=>({type:"json",schema:a,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:a},o){const c=await Qo({text:a});if(!c.success)throw new _i({message:"No object generated: could not parse the response.",cause:c.error,text:a,response:o.response,usage:o.usage,finishReason:o.finishReason});const u=await Wd({value:c.value,schema:r});if(!u.success)throw new _i({message:"No object generated: response did not match schema.",cause:u.error,text:a,response:o.response,usage:o.usage,finishReason:o.finishReason});return u.value},async parsePartialOutput({text:a}){const o=await hf(a);switch(o.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:o.value}}},createElementStreamTransform(){}}},gq=({element:e,name:t,description:n})=>{const r=aj(e);return{name:"array",responseFormat:Ni(r.jsonSchema).then(a=>{const{$schema:o,...c}=a;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:c}},required:["elements"],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}}),async parseCompleteOutput({text:a},o){const c=await Qo({text:a});if(!c.success)throw new _i({message:"No object generated: could not parse the response.",cause:c.error,text:a,response:o.response,usage:o.usage,finishReason:o.finishReason});const u=c.value;if(u==null||typeof u!="object"||!("elements"in u)||!Array.isArray(u.elements))throw new _i({message:"No object generated: response did not match schema.",cause:new Mc({value:u,cause:"response must be an object with an elements array"}),text:a,response:o.response,usage:o.usage,finishReason:o.finishReason});for(const f of u.elements){const h=await Wd({value:f,schema:r});if(!h.success)throw new _i({message:"No object generated: response did not match schema.",cause:h.error,text:a,response:o.response,usage:o.usage,finishReason:o.finishReason})}return u.elements},async parsePartialOutput({text:a}){const o=await hf(a);switch(o.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const c=o.value;if(c==null||typeof c!="object"||!("elements"in c)||!Array.isArray(c.elements))return;const u=o.state==="repaired-parse"&&c.elements.length>0?c.elements.slice(0,-1):c.elements,f=[];for(const h of u){const p=await Wd({value:h,schema:r});p.success&&f.push(p.value)}return{partial:f}}}},createElementStreamTransform(){let a=0;return new TransformStream({transform({partialOutput:o},c){if(o!=null)for(;a<o.length;a++)c.enqueue(o[a])}})}}},vq=({options:e,name:t,description:n})=>({name:"choice",responseFormat:Promise.resolve({type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:e}},required:["result"],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}),async parseCompleteOutput({text:r},a){const o=await Qo({text:r});if(!o.success)throw new _i({message:"No object generated: could not parse the response.",cause:o.error,text:r,response:a.response,usage:a.usage,finishReason:a.finishReason});const c=o.value;if(c==null||typeof c!="object"||!("result"in c)||typeof c.result!="string"||!e.includes(c.result))throw new _i({message:"No object generated: response did not match schema.",cause:new Mc({value:c,cause:"response must be an object that contains a choice value."}),text:r,response:a.response,usage:a.usage,finishReason:a.finishReason});return c.result},async parsePartialOutput({text:r}){const a=await hf(r);switch(a.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const o=a.value;if(o==null||typeof o!="object"||!("result"in o)||typeof o.result!="string")return;const c=e.filter(u=>u.startsWith(o.result));return a.state==="successful-parse"?c.includes(o.result)?{partial:o.result}:void 0:c.length===1?{partial:c[0]}:void 0}}},createElementStreamTransform(){}}),xq=({name:e,description:t}={})=>({name:"json",responseFormat:Promise.resolve({type:"json",...e!=null&&{name:e},...t!=null&&{description:t}}),async parseCompleteOutput({text:n},r){const a=await Qo({text:n});if(!a.success)throw new _i({message:"No object generated: could not parse the response.",cause:a.error,text:n,response:r.response,usage:r.usage,finishReason:r.finishReason});return a.value},async parsePartialOutput({text:n}){const r=await hf(n);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return r.value===void 0?void 0:{partial:r.value}}},createElementStreamTransform(){}});ff({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
62
-
63
- `)},flush(e){e.enqueue(`data: [DONE]
64
-
65
- `)}})}});var yq=WW(()=>tO(Cs([pn({type:ut("text-start"),id:Ue(),providerMetadata:Ot.optional()}),pn({type:ut("text-delta"),id:Ue(),delta:Ue(),providerMetadata:Ot.optional()}),pn({type:ut("text-end"),id:Ue(),providerMetadata:Ot.optional()}),pn({type:ut("error"),errorText:Ue()}),pn({type:ut("tool-input-start"),toolCallId:Ue(),toolName:Ue(),providerExecuted:ws().optional(),providerMetadata:Ot.optional(),dynamic:ws().optional(),title:Ue().optional()}),pn({type:ut("tool-input-delta"),toolCallId:Ue(),inputTextDelta:Ue()}),pn({type:ut("tool-input-available"),toolCallId:Ue(),toolName:Ue(),input:ea(),providerExecuted:ws().optional(),providerMetadata:Ot.optional(),dynamic:ws().optional(),title:Ue().optional()}),pn({type:ut("tool-input-error"),toolCallId:Ue(),toolName:Ue(),input:ea(),providerExecuted:ws().optional(),providerMetadata:Ot.optional(),dynamic:ws().optional(),errorText:Ue(),title:Ue().optional()}),pn({type:ut("tool-approval-request"),approvalId:Ue(),toolCallId:Ue()}),pn({type:ut("tool-output-available"),toolCallId:Ue(),output:ea(),providerExecuted:ws().optional(),providerMetadata:Ot.optional(),dynamic:ws().optional(),preliminary:ws().optional()}),pn({type:ut("tool-output-error"),toolCallId:Ue(),errorText:Ue(),providerExecuted:ws().optional(),providerMetadata:Ot.optional(),dynamic:ws().optional()}),pn({type:ut("tool-output-denied"),toolCallId:Ue()}),pn({type:ut("reasoning-start"),id:Ue(),providerMetadata:Ot.optional()}),pn({type:ut("reasoning-delta"),id:Ue(),delta:Ue(),providerMetadata:Ot.optional()}),pn({type:ut("reasoning-end"),id:Ue(),providerMetadata:Ot.optional()}),pn({type:ut("source-url"),sourceId:Ue(),url:Ue(),title:Ue().optional(),providerMetadata:Ot.optional()}),pn({type:ut("source-document"),sourceId:Ue(),mediaType:Ue(),title:Ue(),filename:Ue().optional(),providerMetadata:Ot.optional()}),pn({type:ut("file"),url:Ue(),mediaType:Ue(),providerMetadata:Ot.optional()}),pn({type:Y_(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:Ue().optional(),data:ea(),transient:ws().optional()}),pn({type:ut("start-step")}),pn({type:ut("finish-step")}),pn({type:ut("start"),messageId:Ue().optional(),messageMetadata:ea().optional()}),pn({type:ut("finish"),finishReason:K_(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:ea().optional()}),pn({type:ut("abort"),reason:Ue().optional()}),pn({type:ut("message-metadata"),messageMetadata:ea()})])));function bq(e){return e.type.startsWith("data-")}function a0(e){return e.type.startsWith("tool-")}function hO(e){return e.type==="dynamic-tool"}function Kd(e){return a0(e)||hO(e)}function i0(e){return e.type.split("-").slice(1).join("-")}function wq(e){return hO(e)?e.toolName:i0(e)}function jq({lastMessage:e,messageId:t}){return{message:e?.role==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function kq({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:a,onToolCall:o,onData:c}){return e.pipeThrough(new TransformStream({async transform(u,f){await r(async({state:h,write:p})=>{var x,v,y,b;function C(k){const T=h.message.parts.filter(Kd).find(R=>R.toolCallId===k);if(T==null)throw new Wl({chunkType:"tool-invocation",chunkId:k,message:`No tool invocation found for tool call ID "${k}".`});return T}function E(k){var N;const T=h.message.parts.find(L=>a0(L)&&L.toolCallId===k.toolCallId),R=k,O=T;if(T!=null){T.state=k.state,O.input=R.input,O.output=R.output,O.errorText=R.errorText,O.rawInput=R.rawInput,O.preliminary=R.preliminary,k.title!==void 0&&(O.title=k.title),O.providerExecuted=(N=R.providerExecuted)!=null?N:T.providerExecuted;const L=R.providerMetadata;if(L!=null)if(k.state==="output-available"||k.state==="output-error"){const I=T;I.resultProviderMetadata=L}else T.callProviderMetadata=L}else h.message.parts.push({type:`tool-${k.toolName}`,toolCallId:k.toolCallId,state:k.state,title:k.title,input:R.input,output:R.output,rawInput:R.rawInput,errorText:R.errorText,providerExecuted:R.providerExecuted,preliminary:R.preliminary,...R.providerMetadata!=null&&(k.state==="output-available"||k.state==="output-error")?{resultProviderMetadata:R.providerMetadata}:{},...R.providerMetadata!=null&&!(k.state==="output-available"||k.state==="output-error")?{callProviderMetadata:R.providerMetadata}:{}})}function A(k){var N,T;const R=h.message.parts.find(I=>I.type==="dynamic-tool"&&I.toolCallId===k.toolCallId),O=k,L=R;if(R!=null){R.state=k.state,L.toolName=k.toolName,L.input=O.input,L.output=O.output,L.errorText=O.errorText,L.rawInput=(N=O.rawInput)!=null?N:L.rawInput,L.preliminary=O.preliminary,k.title!==void 0&&(L.title=k.title),L.providerExecuted=(T=O.providerExecuted)!=null?T:R.providerExecuted;const I=O.providerMetadata;if(I!=null)if(k.state==="output-available"||k.state==="output-error"){const z=R;z.resultProviderMetadata=I}else R.callProviderMetadata=I}else h.message.parts.push({type:"dynamic-tool",toolName:k.toolName,toolCallId:k.toolCallId,state:k.state,input:O.input,output:O.output,errorText:O.errorText,preliminary:O.preliminary,providerExecuted:O.providerExecuted,title:k.title,...O.providerMetadata!=null&&(k.state==="output-available"||k.state==="output-error")?{resultProviderMetadata:O.providerMetadata}:{},...O.providerMetadata!=null&&!(k.state==="output-available"||k.state==="output-error")?{callProviderMetadata:O.providerMetadata}:{}})}async function S(k){if(k!=null){const N=h.message.metadata!=null?fO(h.message.metadata,k):k;t!=null&&await LE({value:N,schema:t,context:{field:"message.metadata",entityId:h.message.id}}),h.message.metadata=N}}switch(u.type){case"text-start":{const k={type:"text",text:"",providerMetadata:u.providerMetadata,state:"streaming"};h.activeTextParts[u.id]=k,h.message.parts.push(k),p();break}case"text-delta":{const k=h.activeTextParts[u.id];if(k==null)throw new Wl({chunkType:"text-delta",chunkId:u.id,message:`Received text-delta for missing text part with ID "${u.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});k.text+=u.delta,k.providerMetadata=(x=u.providerMetadata)!=null?x:k.providerMetadata,p();break}case"text-end":{const k=h.activeTextParts[u.id];if(k==null)throw new Wl({chunkType:"text-end",chunkId:u.id,message:`Received text-end for missing text part with ID "${u.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});k.state="done",k.providerMetadata=(v=u.providerMetadata)!=null?v:k.providerMetadata,delete h.activeTextParts[u.id],p();break}case"reasoning-start":{const k={type:"reasoning",text:"",providerMetadata:u.providerMetadata,state:"streaming"};h.activeReasoningParts[u.id]=k,h.message.parts.push(k),p();break}case"reasoning-delta":{const k=h.activeReasoningParts[u.id];if(k==null)throw new Wl({chunkType:"reasoning-delta",chunkId:u.id,message:`Received reasoning-delta for missing reasoning part with ID "${u.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});k.text+=u.delta,k.providerMetadata=(y=u.providerMetadata)!=null?y:k.providerMetadata,p();break}case"reasoning-end":{const k=h.activeReasoningParts[u.id];if(k==null)throw new Wl({chunkType:"reasoning-end",chunkId:u.id,message:`Received reasoning-end for missing reasoning part with ID "${u.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});k.providerMetadata=(b=u.providerMetadata)!=null?b:k.providerMetadata,k.state="done",delete h.activeReasoningParts[u.id],p();break}case"file":{h.message.parts.push({type:"file",mediaType:u.mediaType,url:u.url,...u.providerMetadata!=null?{providerMetadata:u.providerMetadata}:{}}),p();break}case"source-url":{h.message.parts.push({type:"source-url",sourceId:u.sourceId,url:u.url,title:u.title,providerMetadata:u.providerMetadata}),p();break}case"source-document":{h.message.parts.push({type:"source-document",sourceId:u.sourceId,mediaType:u.mediaType,title:u.title,filename:u.filename,providerMetadata:u.providerMetadata}),p();break}case"tool-input-start":{const k=h.message.parts.filter(a0);h.partialToolCalls[u.toolCallId]={text:"",toolName:u.toolName,index:k.length,dynamic:u.dynamic,title:u.title},u.dynamic?A({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-streaming",input:void 0,providerExecuted:u.providerExecuted,title:u.title,providerMetadata:u.providerMetadata}):E({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-streaming",input:void 0,providerExecuted:u.providerExecuted,title:u.title,providerMetadata:u.providerMetadata}),p();break}case"tool-input-delta":{const k=h.partialToolCalls[u.toolCallId];if(k==null)throw new Wl({chunkType:"tool-input-delta",chunkId:u.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${u.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});k.text+=u.inputTextDelta;const{value:N}=await hf(k.text);k.dynamic?A({toolCallId:u.toolCallId,toolName:k.toolName,state:"input-streaming",input:N,title:k.title}):E({toolCallId:u.toolCallId,toolName:k.toolName,state:"input-streaming",input:N,title:k.title}),p();break}case"tool-input-available":{u.dynamic?A({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-available",input:u.input,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata,title:u.title}):E({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-available",input:u.input,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata,title:u.title}),p(),o&&!u.providerExecuted&&await o({toolCall:u});break}case"tool-input-error":{const k=h.message.parts.filter(Kd).find(T=>T.toolCallId===u.toolCallId);(k!=null?k.type==="dynamic-tool":!!u.dynamic)?A({toolCallId:u.toolCallId,toolName:u.toolName,state:"output-error",input:u.input,errorText:u.errorText,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata}):E({toolCallId:u.toolCallId,toolName:u.toolName,state:"output-error",input:void 0,rawInput:u.input,errorText:u.errorText,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata}),p();break}case"tool-approval-request":{const k=C(u.toolCallId);k.state="approval-requested",k.approval={id:u.approvalId},p();break}case"tool-output-denied":{const k=C(u.toolCallId);k.state="output-denied",p();break}case"tool-output-available":{const k=C(u.toolCallId);k.type==="dynamic-tool"?A({toolCallId:u.toolCallId,toolName:k.toolName,state:"output-available",input:k.input,output:u.output,preliminary:u.preliminary,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata,title:k.title}):E({toolCallId:u.toolCallId,toolName:i0(k),state:"output-available",input:k.input,output:u.output,providerExecuted:u.providerExecuted,preliminary:u.preliminary,providerMetadata:u.providerMetadata,title:k.title}),p();break}case"tool-output-error":{const k=C(u.toolCallId);k.type==="dynamic-tool"?A({toolCallId:u.toolCallId,toolName:k.toolName,state:"output-error",input:k.input,errorText:u.errorText,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata,title:k.title}):E({toolCallId:u.toolCallId,toolName:i0(k),state:"output-error",input:k.input,rawInput:k.rawInput,errorText:u.errorText,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata,title:k.title}),p();break}case"start-step":{h.message.parts.push({type:"step-start"});break}case"finish-step":{h.activeTextParts={},h.activeReasoningParts={};break}case"start":{u.messageId!=null&&(h.message.id=u.messageId),await S(u.messageMetadata),(u.messageId!=null||u.messageMetadata!=null)&&p();break}case"finish":{u.finishReason!=null&&(h.finishReason=u.finishReason),await S(u.messageMetadata),u.messageMetadata!=null&&p();break}case"message-metadata":{await S(u.messageMetadata),u.messageMetadata!=null&&p();break}case"error":{a?.(new Error(u.errorText));break}default:if(bq(u)){if(n?.[u.type]!=null){const T=h.message.parts.findIndex(O=>"id"in O&&"data"in O&&O.id===u.id&&O.type===u.type),R=T>=0?T:h.message.parts.length;await LE({value:u.data,schema:n[u.type],context:{field:`message.parts[${R}].data`,entityName:u.type,entityId:u.id}})}const k=u;if(k.transient){c?.(k);break}const N=k.id!=null?h.message.parts.find(T=>k.type===T.type&&k.id===T.id):void 0;N!=null?N.data=k.data:h.message.parts.push(k),c?.(k),p()}}f.enqueue(u)})}}))}async function Nq({stream:e,onError:t}){const n=e.getReader();try{for(;;){const{done:r}=await n.read();if(r)break}}catch(r){t?.(r)}finally{n.releaseLock()}}ff({prefix:"aitxt",size:24});ff({prefix:"aiobj",size:24});var Sq=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(r){n(r)}}),this.processQueue()})}};ff({prefix:"aiobj",size:24});async function Cq(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(e).map(async t=>{const{name:n,type:r}=t,a=await new Promise((o,c)=>{const u=new FileReader;u.onload=f=>{var h;o((h=f.target)==null?void 0:h.result)},u.onerror=f=>c(f),u.readAsDataURL(t)});return{type:"file",mediaType:r,filename:n,url:a}}))}var Eq=class{constructor({api:e="/api/chat",credentials:t,headers:n,body:r,fetch:a,prepareSendMessagesRequest:o,prepareReconnectToStreamRequest:c}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=a,this.prepareSendMessagesRequest=o,this.prepareReconnectToStreamRequest=c}async sendMessages({abortSignal:e,...t}){var n,r,a,o,c;const u=await Ni(this.body),f=await Ni(this.headers),h=await Ni(this.credentials),p={...Hl(f),...Hl(t.headers)},x=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...u,...t.body},headers:p,credentials:h,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),v=(r=x?.api)!=null?r:this.api,y=x?.headers!==void 0?Hl(x.headers):p,b=x?.body!==void 0?x.body:{...u,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},C=(a=x?.credentials)!=null?a:h,A=await((o=this.fetch)!=null?o:globalThis.fetch)(v,{method:"POST",headers:{"Content-Type":"application/json",...y},body:JSON.stringify(b),credentials:C,signal:e});if(!A.ok)throw new Error((c=await A.text())!=null?c:"Failed to fetch the chat response.");if(!A.body)throw new Error("The response body is empty.");return this.processResponseStream(A.body)}async reconnectToStream(e){var t,n,r,a,o;const c=await Ni(this.body),u=await Ni(this.headers),f=await Ni(this.credentials),h={...Hl(u),...Hl(e.headers)},p=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...c,...e.body},headers:h,credentials:f,requestMetadata:e.metadata})),x=(n=p?.api)!=null?n:`${this.api}/${e.chatId}/stream`,v=p?.headers!==void 0?Hl(p.headers):h,y=(r=p?.credentials)!=null?r:f,C=await((a=this.fetch)!=null?a:globalThis.fetch)(x,{method:"GET",headers:v,credentials:y});if(C.status===204)return null;if(!C.ok)throw new Error((o=await C.text())!=null?o:"Failed to fetch the chat response.");if(!C.body)throw new Error("The response body is empty.");return this.processResponseStream(C.body)}},mO=class extends Eq{constructor(e={}){super(e)}processResponseStream(e){return XW({stream:e,schema:yq}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},Aq=class{constructor({generateId:e=eW,id:t=e(),transport:n=new mO,messageMetadataSchema:r,dataPartSchemas:a,state:o,onError:c,onToolCall:u,onFinish:f,onData:h,sendAutomaticallyWhen:p}){this.activeResponse=void 0,this.jobExecutor=new Sq,this.sendMessage=async(x,v)=>{var y,b,C,E;if(x==null){await this.makeRequest({trigger:"submit-message",messageId:(y=this.lastMessage)==null?void 0:y.id,...v});return}let A;if("text"in x||"files"in x?A={parts:[...Array.isArray(x.files)?x.files:await Cq(x.files),..."text"in x&&x.text!=null?[{type:"text",text:x.text}]:[]]}:A=x,x.messageId!=null){const S=this.state.messages.findIndex(k=>k.id===x.messageId);if(S===-1)throw new Error(`message with id ${x.messageId} not found`);if(this.state.messages[S].role!=="user")throw new Error(`message with id ${x.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,S+1),this.state.replaceMessage(S,{...A,id:x.messageId,role:(b=A.role)!=null?b:"user",metadata:x.metadata})}else this.state.pushMessage({...A,id:(C=A.id)!=null?C:this.generateId(),role:(E=A.role)!=null?E:"user",metadata:x.metadata});await this.makeRequest({trigger:"submit-message",messageId:x.messageId,...v})},this.regenerate=async({messageId:x,...v}={})=>{const y=x==null?this.state.messages.length-1:this.state.messages.findIndex(b=>b.id===x);if(y===-1)throw new Error(`message ${x} not found`);this.state.messages=this.state.messages.slice(0,this.messages[y].role==="assistant"?y:y+1),await this.makeRequest({trigger:"regenerate-message",messageId:x,...v})},this.resumeStream=async(x={})=>{await this.makeRequest({trigger:"resume-stream",...x})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:x,approved:v,reason:y,options:b})=>this.jobExecutor.run(async()=>{const C=this.state.messages,E=C[C.length-1],A=S=>Kd(S)&&S.state==="approval-requested"&&S.approval.id===x?{...S,state:"approval-responded",approval:{id:x,approved:v,reason:y}}:S;this.state.replaceMessage(C.length-1,{...E,parts:E.parts.map(A)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(A)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(S=>{var k;S&&this.makeRequest({trigger:"submit-message",messageId:(k=this.lastMessage)==null?void 0:k.id,...b})})}),this.addToolOutput=async({state:x="output-available",toolCallId:v,output:y,errorText:b,options:C})=>this.jobExecutor.run(async()=>{const E=this.state.messages,A=E[E.length-1],S=k=>Kd(k)&&k.toolCallId===v?{...k,state:x,output:y,errorText:b}:k;this.state.replaceMessage(E.length-1,{...A,parts:A.parts.map(S)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(S)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(k=>{var N;k&&this.makeRequest({trigger:"submit-message",messageId:(N=this.lastMessage)==null?void 0:N.id,...C})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var x;this.status!=="streaming"&&this.status!=="submitted"||(x=this.activeResponse)!=null&&x.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=a,this.state=o,this.onError=c,this.onToolCall=u,this.onFinish=f,this.onData=h,this.sendAutomaticallyWhen=p}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;const e=this.sendAutomaticallyWhen({messages:this.state.messages});return e&&typeof e=="object"&&"then"in e?await e:e}async makeRequest({trigger:e,metadata:t,headers:n,body:r,messageId:a}){var o,c,u;let f;if(e==="resume-stream")try{const y=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:r});if(y==null)return;f=y}catch(y){this.onError&&y instanceof Error&&this.onError(y),this.setStatus({status:"error",error:y});return}this.setStatus({status:"submitted",error:void 0});const h=this.lastMessage;let p=!1,x=!1,v=!1;try{const y={state:jq({lastMessage:this.state.snapshot(h),messageId:this.generateId()}),abortController:new AbortController};y.abortController.signal.addEventListener("abort",()=>{p=!0}),this.activeResponse=y;let b;e==="resume-stream"?b=f:b=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:y.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:a});const C=E=>this.jobExecutor.run(()=>E({state:y.state,write:()=>{var A;this.setStatus({status:"streaming"}),y.state.message.id===((A=this.lastMessage)==null?void 0:A.id)?this.state.replaceMessage(this.state.messages.length-1,y.state.message):this.state.pushMessage(y.state.message)}}));await Nq({stream:kq({stream:b,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:C,onError:E=>{throw E}}),onError:E=>{throw E}}),this.setStatus({status:"ready"})}catch(y){if(p||y.name==="AbortError")return p=!0,this.setStatus({status:"ready"}),null;v=!0,y instanceof TypeError&&(y.message.toLowerCase().includes("fetch")||y.message.toLowerCase().includes("network"))&&(x=!0),this.onError&&y instanceof Error&&this.onError(y),this.setStatus({status:"error",error:y})}finally{try{(c=this.onFinish)==null||c.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:p,isDisconnect:x,isError:v,finishReason:(o=this.activeResponse)==null?void 0:o.state.finishReason})}catch(y){console.error(y)}this.activeResponse=void 0}!v&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:"submit-message",messageId:(u=this.lastMessage)==null?void 0:u.id,metadata:t,headers:n,body:r})}},yy,PE;function Tq(){if(PE)return yy;PE=1;function e(t,n){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let r,a=0;return function(...c){clearTimeout(r);const u=Date.now(),f=u-a,h=n-f;h<=0?(a=u,t.apply(this,c)):r=setTimeout(()=>{a=Date.now(),t.apply(this,c)},h)}}return yy=e,yy}var Mq=Tq();const Rq=x2(Mq);var by={exports:{}},wy={};var DE;function Iq(){if(DE)return wy;DE=1;var e=uf();function t(x,v){return x===v&&(x!==0||1/x===1/v)||x!==x&&v!==v}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,a=e.useEffect,o=e.useLayoutEffect,c=e.useDebugValue;function u(x,v){var y=v(),b=r({inst:{value:y,getSnapshot:v}}),C=b[0].inst,E=b[1];return o(function(){C.value=y,C.getSnapshot=v,f(C)&&E({inst:C})},[x,y,v]),a(function(){return f(C)&&E({inst:C}),x(function(){f(C)&&E({inst:C})})},[x]),c(y),y}function f(x){var v=x.getSnapshot;x=x.value;try{var y=v();return!n(x,y)}catch{return!0}}function h(x,v){return v()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:u;return wy.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,wy}var zE;function pO(){return zE||(zE=1,by.exports=Iq()),by.exports}var _q=pO(),gO=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},gn=(e,t,n)=>(gO(e,t,"read from private field"),n?n.call(e):t.get(e)),Xr=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},ji=(e,t,n,r)=>(gO(e,t,"write to private field"),t.set(e,n),n);function Oq(e,t){return t!=null?Rq(e,t):e}var pr,Bm,Um,dd,fd,hd,tc,o0,l0,$q=class{constructor(e=[]){Xr(this,pr,void 0),Xr(this,Bm,"ready"),Xr(this,Um,void 0),Xr(this,dd,new Set),Xr(this,fd,new Set),Xr(this,hd,new Set),this.pushMessage=t=>{ji(this,pr,gn(this,pr).concat(t)),gn(this,tc).call(this)},this.popMessage=()=>{ji(this,pr,gn(this,pr).slice(0,-1)),gn(this,tc).call(this)},this.replaceMessage=(t,n)=>{ji(this,pr,[...gn(this,pr).slice(0,t),this.snapshot(n),...gn(this,pr).slice(t+1)]),gn(this,tc).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const r=n?Oq(t,n):t;return gn(this,dd).add(r),()=>{gn(this,dd).delete(r)}},this["~registerStatusCallback"]=t=>(gn(this,fd).add(t),()=>{gn(this,fd).delete(t)}),this["~registerErrorCallback"]=t=>(gn(this,hd).add(t),()=>{gn(this,hd).delete(t)}),Xr(this,tc,()=>{gn(this,dd).forEach(t=>t())}),Xr(this,o0,()=>{gn(this,fd).forEach(t=>t())}),Xr(this,l0,()=>{gn(this,hd).forEach(t=>t())}),ji(this,pr,e)}get status(){return gn(this,Bm)}set status(e){ji(this,Bm,e),gn(this,o0).call(this)}get error(){return gn(this,Um)}set error(e){ji(this,Um,e),gn(this,l0).call(this)}get messages(){return gn(this,pr)}set messages(e){ji(this,pr,[...e]),gn(this,tc).call(this)}};pr=new WeakMap;Bm=new WeakMap;Um=new WeakMap;dd=new WeakMap;fd=new WeakMap;hd=new WeakMap;tc=new WeakMap;o0=new WeakMap;l0=new WeakMap;var nc,BE=class extends Aq{constructor({messages:e,...t}){const n=new $q(e);super({...t,state:n}),Xr(this,nc,void 0),this["~registerMessagesCallback"]=(r,a)=>gn(this,nc)["~registerMessagesCallback"](r,a),this["~registerStatusCallback"]=r=>gn(this,nc)["~registerStatusCallback"](r),this["~registerErrorCallback"]=r=>gn(this,nc)["~registerErrorCallback"](r),ji(this,nc,n)}};nc=new WeakMap;function Lq({experimental_throttle:e,resume:t=!1,...n}={}){const r=m.useRef("chat"in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});"chat"in n||(r.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});const a={...n,onToolCall:v=>{var y,b;return(b=(y=r.current).onToolCall)==null?void 0:b.call(y,v)},onData:v=>{var y,b;return(b=(y=r.current).onData)==null?void 0:b.call(y,v)},onFinish:v=>{var y,b;return(b=(y=r.current).onFinish)==null?void 0:b.call(y,v)},onError:v=>{var y,b;return(b=(y=r.current).onError)==null?void 0:b.call(y,v)},sendAutomaticallyWhen:v=>{var y,b,C;return(C=(b=(y=r.current).sendAutomaticallyWhen)==null?void 0:b.call(y,v))!=null?C:!1}},o=m.useRef("chat"in n?n.chat:new BE(a));("chat"in n&&n.chat!==o.current||"id"in n&&o.current.id!==n.id)&&(o.current="chat"in n?n.chat:new BE(a));const u=m.useCallback(v=>o.current["~registerMessagesCallback"](v,e),[e,o.current.id]),f=m.useSyncExternalStore(u,()=>o.current.messages,()=>o.current.messages),h=m.useSyncExternalStore(o.current["~registerStatusCallback"],()=>o.current.status,()=>o.current.status),p=m.useSyncExternalStore(o.current["~registerErrorCallback"],()=>o.current.error,()=>o.current.error),x=m.useCallback(v=>{typeof v=="function"&&(v=v(o.current.messages)),o.current.messages=v},[o]);return m.useEffect(()=>{t&&o.current.resumeStream()},[t,o]),{id:o.current.id,messages:f,setMessages:x,sendMessage:o.current.sendMessage,regenerate:o.current.regenerate,clearError:o.current.clearError,stop:o.current.stop,error:p,resumeStream:o.current.resumeStream,status:h,addToolResult:o.current.addToolOutput,addToolOutput:o.current.addToolOutput,addToolApprovalResponse:o.current.addToolApprovalResponse}}var Pq="about:blank";function Dq(e){const t={};for(const n of e.attachmentsRef.current??[])if(e.activeAttachmentsRef.current.has(n.label)){const r=n.content();r!==null&&(t[n.label.toLowerCase()]=r)}return{toolset:e.toolsetRef.current,context:{...e.contextRef.current,...t},mode:e.modeRef.current,provider:e.providerRef.current,model:e.modelRef.current}}function zq(e,t){e.current?.(t)}function jy(e,t){e.current?.(t)}function wd(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function js(e){return typeof e=="string"&&e.trim()?e:void 0}function Bq(e,t){if(!(!t||!wd(e)||!Array.isArray(e.commands)))return e.commands.find(n=>wd(n)&&n.id===t)}function Uq(e){if(!wd(e))return{};const t=wd(e.scope)?e.scope:void 0,n=wd(e.workspace)?e.workspace:void 0;return{workspaceId:js(t?.workspaceId)??js(n?.id),workspaceName:js(t?.workspaceName)??js(n?.name)}}function Fq(e){const t=e?.parentTraceId;return js(typeof t=="function"?t():t)}function ky(e){const t=Bq(e.context,js(e.args.commandId)),n=Uq(e.context),r=e.trace?.appId??js(e.args.appId)??js(e.args.targetAppId)??js(t?.appId),a=e.trace?.appName??js(e.args.appName)??js(e.args.targetAppName)??js(t?.appName),o=e.trace?.workspaceId??js(e.args.workspaceId)??n.workspaceId,c=e.trace?.workspaceName??n.workspaceName;B8({source:e.trace?.source??"useHudsonAI",status:e.status,toolset:e.toolset,chatId:e.chatId,action:e.toolName,commandId:js(e.args.commandId),appId:r,appName:a,workspaceId:o,workspaceName:c,traceId:e.traceId,parentTraceId:Fq(e.trace),args:e.args,error:e.error})}function Vq({api:e,toolset:t,chatId:n,initialMessages:r,context:a,onToolCall:o,mode:c,attachments:u,provider:f,model:h,onFinish:p,onError:x,agentTrace:v}){const y=iU(),b=e??y.aiChat,C=m.useRef(o),E=m.useRef(p),A=m.useRef(x),S=m.useRef(v),[k,N]=m.useState(new Set),T=m.useCallback(P=>{N(H=>{const B=new Set(H);return B.has(P)?B.delete(P):B.add(P),B})},[]),[R]=Lr("hudson.settings",{}),O=c??R.aiMode??"api",L=m.useRef(k),I=m.useRef(u),z=m.useRef(a),_=m.useRef(t),U=m.useRef(O),D=m.useRef(f),q=m.useRef(h);m.useEffect(()=>{C.current=o},[o]),m.useEffect(()=>{E.current=p},[p]),m.useEffect(()=>{A.current=x},[x]),m.useEffect(()=>{S.current=v},[v]),m.useEffect(()=>{L.current=k},[k]),m.useEffect(()=>{I.current=u},[u]),m.useEffect(()=>{z.current=a},[a]),m.useEffect(()=>{_.current=t},[t]),m.useEffect(()=>{U.current=O},[O]),m.useEffect(()=>{D.current=f},[f]),m.useEffect(()=>{q.current=h},[h]);const Z=m.useMemo(()=>new mO({api:b??Pq,body:()=>Dq({activeAttachmentsRef:L,attachmentsRef:I,contextRef:z,toolsetRef:_,modeRef:U,providerRef:D,modelRef:q})}),[b]),$=m.useCallback(async({toolCall:P})=>{if(!C.current)return;const H=P.input&&typeof P.input=="object"&&!Array.isArray(P.input)?P.input:{},B=R2("tr");try{ky({toolset:_.current,chatId:n,toolName:P.toolName,args:H,context:z.current,trace:S.current,status:"started",traceId:B}),await C.current(P.toolName,H),ky({toolset:_.current,chatId:n,toolName:P.toolName,args:H,context:z.current,trace:S.current,status:"completed",traceId:B})}catch(Q){const oe=Q instanceof Error?Q:new Error(String(Q));throw ky({toolset:_.current,chatId:n,toolName:P.toolName,args:H,context:z.current,trace:S.current,status:"failed",traceId:B,error:oe}),jy(A,oe),oe}},[n]),G=Lq({id:n,messages:r,transport:Z,onToolCall:$,onFinish:P=>zq(E,P),onError:P=>jy(A,P)}),V=m.useCallback(()=>{G.setMessages([])},[G]),Y=m.useCallback((...P)=>{if(b)return G.sendMessage(...P);const H=new Error("Hudson AI is not configured for this host. Provide useHudsonAI({ api }) or WorkspaceShell environment.routes.aiChat.");return jy(A,H),Promise.reject(H)},[G,b]),{messages:K}=G;return{messages:K,sendMessage:Y,stop:G.stop,status:G.status,setMessages:G.setMessages,clearChat:V,error:G.error,mode:O,attachments:u??[],activeAttachments:k,toggleAttachment:T}}function Hq({app:e,commands:t,state:n,provider:r,model:a,onFinish:o}){const c=m.useMemo(()=>(e.intents??[]).map(h=>({commandId:h.commandId,title:h.title,description:h.description,category:h.category,keywords:h.keywords,shortcut:h.shortcut,dangerous:h.dangerous,params:h.params?.map(p=>({name:p.name,description:p.description,type:p.type,optional:p.optional,enum:p.enum}))})),[e.intents]),u=m.useMemo(()=>({appId:e.id,appName:e.name,appDescription:e.description,intents:c,state:n}),[e.id,e.name,e.description,c,n]),f=m.useCallback(h=>{const p=t.find(x=>x.id===h);if(!p){console.warn(`[useAssistant] no command for id "${h}"`);return}p.action()},[t]);return Vq({toolset:"intents",context:u,provider:r,model:a,onFinish:o,onToolCall:(h,p)=>{if(h!=="dispatch")return;const x=p.commandId;typeof x=="string"&&f(x)}})}function ij(e={}){const{url:t="ws://localhost:3600",healthUrl:n,systemPrompt:r,cwd:a,workspaceFiles:o,autoConnect:c=!1,sessionKey:u,orphanTTL:f,backend:h,tmuxSession:p,agent:x,provider:v,model:y}=e,b=u?`hudson.relay.${u}`:null,C=()=>{if(!b)return null;try{return localStorage.getItem(b)}catch{return null}},E=he=>{if(b)try{he?localStorage.setItem(b,he):localStorage.removeItem(b)}catch{}},[A,S]=m.useState("disconnected"),[k,N]=m.useState(null),[T,R]=m.useState(null),[O,L]=m.useState(null),[I,z]=m.useState(a||"~"),_=m.useRef(null),U=m.useRef(null),D=m.useRef({cols:80,rows:24}),q=m.useRef(!1),Z=m.useRef(""),$=m.useRef(0),G=m.useRef(I);G.current=I;const V=m.useRef(C()),Y=m.useRef(null),K=m.useRef(new Set),P=512*1024,H=m.useCallback(he=>{if(he&&(Y.current?Y.current(he):(Z.current+=he,Z.current.length>P&&(Z.current=Z.current.slice(-P))),K.current.size>0))for(const ke of K.current)try{ke(he)}catch{}},[]),B=m.useCallback(he=>{const ke=_.current;ke&&ke.readyState===WebSocket.OPEN&&ke.send(JSON.stringify(he))},[]),Q=m.useCallback(()=>{const he=_.current;he&&(he.close(),_.current=null)},[]),oe=m.useCallback(()=>{$.current+=1,U.current&&(clearTimeout(U.current),U.current=null),Q(),q.current=!1,S("disconnected")},[Q]),ne=m.useCallback(()=>{const he=G.current;return{type:"session:init",cols:D.current.cols,rows:D.current.rows,...r?{systemPrompt:r}:{},...he?{cwd:he}:{},...o?{workspaceFiles:o}:{},...f?{orphanTTL:f}:{},...h?{backend:h}:{},...p?{tmuxSession:p}:{},...x?{agent:x}:{},...v?{provider:v}:{},...y?{model:y}:{}}},[r,o,f,h,p,x,v,y]),X=m.useCallback(()=>{q.current||(q.current=!0,V.current?B({type:"session:reconnect",sessionId:V.current,cols:D.current.cols,rows:D.current.rows}):B(ne()))},[B,ne]),ae=m.useCallback(async()=>{const he=$.current+1;$.current=he,Q(),q.current=!1,S("connecting"),R(null),L(null);const ke=n||`${t.replace(/^ws(s?):\/\//,"http$1://")}/health`;try{await fetch(ke,{signal:AbortSignal.timeout(2e3)})}catch{if($.current!==he)return;S("error"),R("Relay service is not running");return}if($.current!==he)return;Q();const Ne=new WebSocket(t);_.current=Ne;const Fe=()=>$.current===he&&_.current===Ne;Ne.onopen=()=>{if(!Fe()){Ne.close();return}X()},Ne.onmessage=Ee=>{if(Fe())try{const Le=JSON.parse(Ee.data);switch(Le.type){case"session:ready":V.current=Le.sessionId,E(Le.sessionId),N(Le.sessionId),S("connected"),R(null),L(null);break;case"session:expired":{V.current=null,E(null),q.current=!1,H("\x1B[2J\x1B[H"),B(ne()),q.current=!0;break}case"session:error":S("error"),R(Le.error||"Session failed to start");break;case"terminal:data":Le.data&&H(Le.data);break;case"session:exit":V.current=null,E(null),N(null),L(Le.exitCode??null),Le.exitCode!==0?(S("error"),R(Le.reason||`Process exited with code ${Le.exitCode}`)):S("disconnected");break;case"session:detached":V.current=null,E(null),N(null);break}}catch{}},Ne.onclose=()=>{Fe()&&(_.current=null,q.current=!1,S(Ee=>Ee==="error"?Ee:"disconnected"))},Ne.onerror=()=>{Fe()&&(S("error"),R("Could not connect to relay"))}},[t,n,X,Q,B,r,o]),be=m.useCallback(he=>{B({type:"terminal:input",data:he})},[B]),_e=m.useCallback(he=>{B({type:"terminal:input",data:he+"\r"})},[B]),xe=m.useCallback((he,ke)=>{D.current={cols:he,rows:ke},q.current&&B({type:"terminal:resize",cols:he,rows:ke})},[B]),pe=m.useCallback(he=>{Y.current=he,!(!he||Z.current.length===0)&&(he(Z.current),Z.current="")},[]),te=m.useCallback(he=>(K.current.add(he),()=>{K.current.delete(he)}),[]);m.useEffect(()=>(c&&ae(),()=>{oe()}),[]);const ve=m.useCallback(()=>{oe(),V.current=null,N(null),E(null),R(null),L(null),setTimeout(()=>ae(),200)},[oe,ae]);return{status:A,sessionId:k,error:T,exitCode:O,cwd:I,setCwd:z,onData:pe,subscribeData:te,sendInput:be,sendLine:_e,resize:xe,connect:ae,disconnect:oe,restart:ve}}function Wq({chat:e,placeholder:t="Ask AI",inputExtras:n,inputStatus:r,inputValue:a,onInputChange:o}){const{messages:c,sendMessage:u,stop:f,status:h,clearChat:p,error:x,attachments:v,activeAttachments:y,toggleAttachment:b}=e,[C,E]=m.useState(""),A=a!==void 0,S=A?a:C,k=z=>{A?o?.(z):E(z)},N=m.useRef(null),T=m.useRef(null),R=h==="streaming"||h==="submitted",O=v.length>0;m.useEffect(()=>{const z=N.current;z&&(z.scrollTop=z.scrollHeight)},[c]),m.useEffect(()=>{T.current?.focus()},[]);const L=z=>{z.preventDefault();const _=S.trim();!_||R||(k(""),u({text:_}))},I=z=>{z.stopPropagation(),z.key==="Enter"&&!z.shiftKey&&(z.preventDefault(),L(z))};return s.jsxs("div",{className:"flex flex-col h-full font-mono text-[12px]",children:[s.jsxs("div",{ref:N,className:"flex-1 overflow-y-auto frame-scrollbar p-3 space-y-3",children:[c.length===0&&s.jsx("div",{className:"text-muted-foreground/80 text-center py-8 select-none",children:t}),c.map(z=>s.jsx("div",{className:`flex ${z.role==="user"?"justify-end":"justify-start"}`,children:s.jsx("div",{className:`max-w-[85%] rounded-lg px-3 py-2 whitespace-pre-wrap break-words leading-relaxed ${z.role==="user"?"bg-accent/10 text-foreground border border-accent/20":"bg-muted/50 text-foreground border border-border/50"}`,children:(z.parts??[]).map((_,U)=>{if(!_)return null;if(_.type==="text")return s.jsx("span",{children:_.text},U);if(Kd(_)){const D=wq(_),q=Object.entries(_.input??{}).map(([Z,$])=>`${Z}: ${JSON.stringify($)}`).join(", ");return s.jsxs("div",{className:"text-[11px] text-info/80 mt-1 font-mono",children:[s.jsx("span",{className:"text-muted-foreground/80",children:"↳ "}),D,"(",q,")"]},U)}return null})})},z.id)),R&&c[c.length-1]?.role!=="assistant"&&s.jsx("div",{className:"flex justify-start",children:s.jsx("div",{className:"bg-muted/50 border border-border/50 rounded-lg px-3 py-2 text-muted-foreground",children:s.jsx("span",{className:"animate-pulse",children:"Thinking"})})})]}),x&&s.jsxs("div",{className:"px-3 py-2 bg-destructive/10 border-t border-destructive/30 text-destructive text-[11px] flex items-center gap-2",children:[s.jsx(R6,{size:12}),s.jsx("span",{className:"truncate",children:x.message||"An error occurred"})]}),s.jsxs("div",{className:"px-3 py-2.5 border-t border-border/50 bg-background/60",children:[r&&s.jsx("div",{className:"mb-2",children:r}),O&&s.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[s.jsx(LB,{size:11,className:"text-muted-foreground/80 shrink-0"}),v.map(z=>{const _=y.has(z.label);return s.jsx("button",{type:"button",onClick:()=>b(z.label),className:`text-[10px] px-2 py-0.5 rounded-full border transition-colors ${_?"bg-info/10 text-info border-info/30":"text-muted-foreground/80 border-border hover:text-foreground hover:border-foreground/30"}`,children:z.label},z.label)}),y.size>0&&s.jsx("span",{className:"text-[10px] text-muted-foreground/60 ml-1",children:"attached"})]}),s.jsxs("form",{onSubmit:L,className:"flex items-center gap-2 rounded-lg border border-border bg-muted/60 px-3 py-2 focus-within:border-accent/40 transition-colors",children:[n,c.length>0&&s.jsx("button",{type:"button",onClick:()=>p(),className:"p-1 rounded text-muted-foreground/80 hover:text-foreground hover:bg-muted transition-colors",title:"Clear",children:s.jsx(c8,{size:12})}),s.jsx("input",{ref:T,type:"text",value:S,onChange:z=>k(z.target.value),onKeyDown:I,placeholder:t,className:"flex-1 bg-transparent outline-none text-foreground placeholder:text-muted-foreground/80 caret-accent",disabled:R}),R?s.jsx("button",{type:"button",onClick:()=>f(),className:"p-1.5 rounded text-warning hover:bg-warning/10 transition-colors",title:"Stop",children:s.jsx(df,{size:12})}):s.jsx("button",{type:"submit",disabled:!S.trim(),className:"text-[11px] px-2 py-1 rounded bg-accent/10 text-accent border border-accent/30 hover:bg-accent/20 disabled:opacity-30 disabled:cursor-default transition-colors",children:"Send"})]})]})]})}var UE="hudson:terminal:voice-transcript",FE="hudson:terminal:voice-submit",qq={background:"#091112",foreground:"#d7e5e2",cursor:"#35d7d0",cursorAccent:"#091112",selectionBackground:"#173739",selectionForeground:"#f3fbf9",black:"#091112",red:"#ff6b6b",green:"#35d07f",yellow:"#f5c451",blue:"#62b4ff",magenta:"#ff7ab6",cyan:"#32d5ca",white:"#d7e5e2",brightBlack:"#667777",brightRed:"#ff8f8f",brightGreen:"#5ee79f",brightYellow:"#ffd36e",brightBlue:"#8dccff",brightMagenta:"#ff9fca",brightCyan:"#67eee3",brightWhite:"#ffffff"},Kq={background:"#f7faf9",foreground:"#111a19",cursor:"#006f6a",cursorAccent:"#f7faf9",selectionBackground:"#c0e7e2",selectionForeground:"#0d1716",black:"#111a19",red:"#9f1f18",green:"#006c46",yellow:"#704600",blue:"#075985",magenta:"#9d174d",cyan:"#006f6a",white:"#dbe5e2",brightBlack:"#52635f",brightRed:"#c2271f",brightGreen:"#007f55",brightYellow:"#865b00",brightBlue:"#0369a1",brightMagenta:"#be185d",brightCyan:"#007f89",brightWhite:"#ffffff"},Gq=`
66
- .xterm { cursor: text; position: relative; user-select: none; -ms-user-select: none; -webkit-user-select: none; }
67
- .xterm.focus, .xterm:focus { outline: none; }
68
- .xterm .xterm-helpers { position: absolute; top: 0; z-index: 5; }
69
- .xterm .xterm-helper-textarea { padding: 0; border: 0; margin: 0; position: absolute; opacity: 0; left: -9999em; top: 0; width: 0; height: 0; z-index: -5; white-space: nowrap; overflow: hidden; resize: none; }
70
- .xterm .composition-view { background: var(--hud-terminal-bg, #091112); color: var(--hud-terminal-fg, #d7e5e2); display: none; position: absolute; white-space: nowrap; z-index: 1; }
71
- .xterm .composition-view.active { display: block; }
72
- .xterm .xterm-viewport { background-color: var(--hud-terminal-bg, transparent); overflow-y: scroll; cursor: default; position: absolute; right: 0; left: 0; top: 0; bottom: 0; }
73
- .xterm .xterm-screen { position: relative; }
74
- .xterm .xterm-screen canvas { position: absolute; left: 0; top: 0; }
75
- .xterm-char-measure-element { display: inline-block; visibility: hidden; position: absolute; top: 0; left: -9999em; line-height: normal; }
76
- .xterm.enable-mouse-events { cursor: default; }
77
- .xterm.xterm-cursor-pointer, .xterm .xterm-cursor-pointer { cursor: pointer; }
78
- .xterm.column-select.focus { cursor: crosshair; }
79
- .xterm .xterm-accessibility:not(.debug), .xterm .xterm-message { position: absolute; left: 0; top: 0; bottom: 0; right: 0; z-index: 10; color: transparent; pointer-events: none; }
80
- .xterm .xterm-accessibility-tree:not(.debug) *::selection { color: transparent; }
81
- .xterm .xterm-accessibility-tree { font-family: monospace; user-select: text; white-space: pre; }
82
- .xterm .xterm-accessibility-tree > div { transform-origin: left; width: fit-content; }
83
- .xterm .live-region { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
84
- .xterm-dim { opacity: 1 !important; }
85
- .xterm-underline-1 { text-decoration: underline; }
86
- .xterm-underline-2 { text-decoration: double underline; }
87
- .xterm-underline-3 { text-decoration: wavy underline; }
88
- .xterm-underline-4 { text-decoration: dotted underline; }
89
- .xterm-underline-5 { text-decoration: dashed underline; }
90
- .xterm-overline { text-decoration: overline; }
91
- .xterm-overline.xterm-underline-1 { text-decoration: overline underline; }
92
- .xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }
93
- .xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }
94
- .xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }
95
- .xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }
96
- .xterm-strikethrough { text-decoration: line-through; }
97
- .xterm-screen .xterm-decoration-container .xterm-decoration { z-index: 6; position: absolute; }
98
- .xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer { z-index: 7; }
99
- .xterm-decoration-overview-ruler { z-index: 8; position: absolute; top: 0; right: 0; pointer-events: none; }
100
- .xterm-decoration-top { z-index: 2; position: relative; }
101
- .xterm .xterm-scrollable-element > .scrollbar { cursor: default; }
102
- .xterm .xterm-scrollable-element > .scrollbar > .scra { cursor: pointer; font-size: 11px !important; }
103
- .xterm .xterm-scrollable-element > .visible { opacity: 1; background: rgba(0,0,0,0); transition: opacity 100ms linear; z-index: 11; }
104
- .xterm .xterm-scrollable-element > .invisible { opacity: 0; pointer-events: none; }
105
- .xterm .xterm-scrollable-element > .invisible.fade { transition: opacity 800ms linear; }
106
- .xterm .xterm-scrollable-element > .shadow { position: absolute; display: none; }
107
- .xterm .xterm-scrollable-element > .shadow.top { display: block; top: 0; left: 3px; height: 3px; width: 100%; }
108
- .xterm .xterm-scrollable-element > .shadow.left { display: block; top: 3px; left: 0; height: 100%; width: 3px; }
109
- `;function Zq(){if(typeof document>"u"||document.querySelector("[data-xterm-css]"))return;const e=document.createElement("style");e.setAttribute("data-xterm-css",""),e.textContent=Gq,document.head.appendChild(e)}function VE(e){if(!e||!e.closest('[data-hudson-terminal-drawer-content="true"]'))return!1;const t=e.getBoundingClientRect();if(t.width<=0||t.height<=0)return!1;const n=window.getComputedStyle(e);return n.display!=="none"&&n.visibility!=="hidden"}var Yq="\x1B[13;2u",HE="\r";function Xq(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{const a=r.result;t(a.split(",")[1])},r.onerror=n,r.readAsDataURL(e)})}function oj({relay:e,fontSize:t=12,fontFamily:n="'JetBrains Mono', 'Hack Nerd Font', monospace",colorScheme:r="auto",configItems:a,onOpenSettings:o,onStartService:c,quiet:u=!1}){const{status:f,error:h,exitCode:p,cwd:x,setCwd:v,sendInput:y,resize:b,onData:C,connect:E,disconnect:A}=e,[S,k]=m.useState(!1),{apiBaseUrl:N}=vg(),T=H8(),R=r==="auto"?T?.resolvedTheme==="light"?"light":"dark":r,O=R==="light"?Kq:qq,L=R==="light"?4.5:3,I=m.useRef(null),z=m.useRef(null),_=m.useRef(null),U=m.useRef(null),D=m.useRef(null),q=m.useRef(!1),[Z,$]=m.useState(!1),[G,V]=m.useState(!1),Y=m.useRef(0);m.useEffect(()=>{const pe=I.current;if(!pe)return;const te=ve=>{ve.key===" "&&!ve.metaKey&&!ve.ctrlKey&&!ve.altKey&&ve.stopPropagation()};return pe.addEventListener("keydown",te),()=>pe.removeEventListener("keydown",te)},[]);const K=`${N}/api/relay/upload`,P=m.useCallback(pe=>{const te=pe.transcript.replace(/\s+/g," ").trim();te&&y(pe.submit?`${te}${HE}`:te)},[y]),H=m.useCallback(()=>{y(HE)},[y]);m.useEffect(()=>{const pe=te=>{if(!VE(I.current))return;const ve=te.detail;if(!(!ve||typeof ve.transcript!="string")){if(f==="connected"){P(ve);return}D.current=ve,f!=="connecting"&&E()}};return window.addEventListener(UE,pe),()=>window.removeEventListener(UE,pe)},[E,P,f]),m.useEffect(()=>{if(f!=="connected"||!D.current)return;const pe=D.current;D.current=null,P(pe)},[P,f]),m.useEffect(()=>{const pe=()=>{if(VE(I.current)){if(f==="connected"){H();return}q.current=!0,f!=="connecting"&&E()}};return window.addEventListener(FE,pe),()=>window.removeEventListener(FE,pe)},[E,H,f]),m.useEffect(()=>{f!=="connected"||!q.current||(q.current=!1,H())},[H,f]);const B=m.useCallback(async pe=>{try{const te=await Xq(pe),ve=await fetch(K,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:pe.name,data:te})}),{path:he}=await ve.json();return he||null}catch(te){return console.error("File upload failed:",te),null}},[K]);m.useEffect(()=>{const pe=I.current;if(!pe)return;const te=async ve=>{if(!ve.clipboardData)return;const he=Array.from(ve.clipboardData.items).filter(ke=>ke.type.startsWith("image/"));if(he.length!==0){ve.preventDefault(),ve.stopPropagation();for(const ke of he){const Ne=ke.getAsFile();if(!Ne)continue;const Fe=await B(Ne);Fe&&y(Fe)}}};return pe.addEventListener("paste",te),()=>pe.removeEventListener("paste",te)},[y,B]);const Q=m.useCallback(pe=>{pe.preventDefault(),pe.dataTransfer.dropEffect="copy"},[]),oe=m.useCallback(pe=>{pe.preventDefault(),Y.current++,pe.dataTransfer.types.includes("Files")&&V(!0)},[]),ne=m.useCallback(pe=>{pe.preventDefault(),Y.current--,Y.current===0&&V(!1)},[]),X=m.useCallback(async pe=>{pe.preventDefault(),Y.current=0,V(!1);const te=Array.from(pe.dataTransfer.files).filter(ve=>ve.type.startsWith("image/"));if(te.length!==0)for(const ve of te){const he=await B(ve);he&&y(he)}},[y,B]);m.useEffect(()=>{let pe=!1,te=null;async function ve(){const[he,ke,Ne]=await Promise.all([zm(()=>import("./xterm-FFux-PdF.js").then(Pe=>Pe.x),[]),zm(()=>import("./addon-fit-C5ueiijZ.js").then(Pe=>Pe.a),[]),zm(()=>import("./addon-webgl-Cm7sl8RO.js").then(Pe=>Pe.a),[]).catch(()=>null)]),Fe=he.Terminal??he.default?.Terminal,Ee=ke.FitAddon??ke.default?.FitAddon,Le=Ne?Ne.WebglAddon??Ne.default?.WebglAddon:void 0;if(!Fe||!Ee){console.error("[TerminalRelay] @xterm/xterm or @xterm/addon-fit missing constructors",{xtermMod:he,fitMod:ke});return}if(Zq(),pe||!z.current)return;te=new Fe({fontSize:t,fontFamily:n,theme:O,minimumContrastRatio:L,cursorBlink:!0,cursorStyle:"bar",allowTransparency:!0,scrollback:5e3,convertEol:!1,allowProposedApi:!0});const Te=new Ee;if(te.loadAddon(Te),te.open(z.current),Le)try{const Pe=new Le;Pe.onContextLoss(()=>{Pe.dispose()}),te.loadAddon(Pe)}catch{}try{Te.fit()}catch{}_.current=te,U.current=Te,b(te.cols,te.rows),te.attachCustomKeyEventHandler(Pe=>Pe.type==="keydown"&&Pe.key==="Enter"&&Pe.shiftKey&&!Pe.ctrlKey&&!Pe.altKey&&!Pe.metaKey?(Pe.preventDefault(),Pe.stopPropagation(),y(Yq),!1):!0),te.onData(Pe=>{y(Pe)}),$(!0)}return ve(),()=>{pe=!0,te&&(te.dispose(),_.current=null,U.current=null)}},[]),m.useEffect(()=>{const pe=_.current;if(pe){pe.options.fontSize=t,pe.options.fontFamily=n;try{U.current?.fit()}catch{}}},[t,n]),m.useEffect(()=>{const pe=_.current;pe&&(pe.options.theme=O,pe.options.minimumContrastRatio=L)},[L,O]),m.useEffect(()=>{if(Z)return C(pe=>{_.current?.write(pe)}),()=>{C(null)}},[Z,C]),m.useEffect(()=>{const pe=z.current;if(!pe||!Z)return;const te=new ResizeObserver(()=>{const ve=U.current,he=_.current;if(!(!ve||!he))try{ve.fit(),b(he.cols,he.rows)}catch{}});return te.observe(pe),()=>te.disconnect()},[Z,b]),m.useEffect(()=>{f==="connected"&&_.current&&_.current.focus()},[f]);const ae=m.useCallback(()=>{f==="connected"&&_.current&&_.current.focus()},[f]),be=f==="error"&&h==="Relay service is not running",_e=m.useCallback(async()=>{if(c){k(!0);try{await c()&&setTimeout(()=>E(),500)}finally{k(!1)}}},[c,E]);let xe=null;return be?xe=s.jsxs("div",{className:"flex flex-col items-center gap-4 max-w-xs text-center px-4",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/10 border border-amber-500/20 flex items-center justify-center",children:s.jsx("span",{className:"text-amber-400 text-[14px]",children:"!"})}),s.jsxs("div",{children:[s.jsx("div",{className:"text-[12px] text-foreground font-medium mb-1",children:"Relay service not running"}),s.jsx("div",{className:"text-[11px] text-muted-foreground/80 leading-relaxed",children:c?"Start the relay service to open a terminal session.":"Start the relay service from the Workspace Manager."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[c&&s.jsx("button",{type:"button",onClick:_e,disabled:S,className:"text-[11px] px-4 py-1.5 rounded-full border border-accent/30 text-accent hover:bg-accent/10 transition-colors font-medium disabled:opacity-50",children:S?"Starting":"Start Service"}),s.jsx("button",{type:"button",onClick:()=>E(),className:"text-[11px] px-3 py-1.5 rounded-full border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:"Retry"}),o&&s.jsx("button",{type:"button",onClick:o,className:"text-[11px] px-3 py-1.5 rounded-full border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:"Settings"})]})]}):f==="error"&&h?xe=s.jsxs("div",{className:"flex flex-col items-center gap-3 max-w-md text-center px-4",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-red-500/10 flex items-center justify-center",children:s.jsx("span",{className:"text-red-400 text-sm",children:"!"})}),s.jsx("span",{className:"text-red-400 text-[12px] font-medium",children:"Session failed"}),s.jsx("code",{className:"text-[11px] text-muted-foreground bg-muted/80 px-3 py-2 rounded-md whitespace-pre-wrap leading-relaxed max-h-32 overflow-y-auto w-full text-left",children:h}),p!==null&&p!==0&&s.jsxs("span",{className:"text-[10px] text-muted-foreground/60",children:["Exit code ",p]}),s.jsx("button",{type:"button",onClick:()=>E(),className:"text-[11px] px-3 py-1 rounded-full border border-cyan-500/30 text-cyan-400 hover:bg-cyan-500/10 transition-colors",children:"Retry"})]}):f==="disconnected"&&!u?xe=s.jsxs("div",{className:"flex flex-col items-center gap-4 max-w-xs text-center px-4",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-muted border border-border flex items-center justify-center",children:s.jsx("span",{className:"text-muted-foreground/80 text-[14px]",children:"▷"})}),s.jsxs("div",{children:[s.jsx("div",{className:"text-[12px] text-foreground font-medium mb-1",children:"Terminal relay disconnected"}),s.jsx("div",{className:"text-[11px] text-muted-foreground/80 leading-relaxed",children:"Set working directory and connect."})]}),s.jsxs("form",{className:"w-full",onSubmit:pe=>{pe.preventDefault(),E()},children:[s.jsx("label",{className:"text-[10px] font-mono text-muted-foreground/80 uppercase tracking-wider mb-1 block text-left",children:"Working Directory"}),s.jsx("input",{type:"text",value:x,onChange:pe=>v(pe.target.value),placeholder:"~/dev/my-project",className:"w-full bg-muted/80 border border-border/50 rounded px-3 py-1.5 text-[11px] font-mono text-foreground placeholder:text-muted-foreground/60 outline-none focus:border-accent/40 transition-colors",spellCheck:!1,autoComplete:"off"})]}),a&&a.length>0&&s.jsx("div",{className:"w-full grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-[10px] font-mono bg-muted/60 border border-border/40 rounded-md px-3 py-2",children:a.map(pe=>s.jsxs("div",{className:"contents",children:[s.jsx("span",{className:"text-muted-foreground/80",children:pe.label}),s.jsx("span",{className:"text-muted-foreground truncate text-left",children:pe.value})]},pe.label))}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>E(),className:"text-[11px] px-4 py-1.5 rounded-full border border-cyan-500/30 text-cyan-400 hover:bg-cyan-500/10 transition-colors font-medium",children:"Connect"}),o&&s.jsx("button",{type:"button",onClick:o,className:"text-[11px] px-3 py-1.5 rounded-full border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:"Settings"})]})]}):f==="connecting"&&!u&&(xe=s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[s.jsx("div",{className:"w-6 h-6 border-2 border-muted-foreground/30 border-t-cyan-500 rounded-full animate-spin"}),s.jsx("span",{className:"text-[12px] text-muted-foreground",children:"Connecting to relay"}),s.jsx("button",{type:"button",onClick:()=>{A()},className:"text-[10px] px-3 py-1 rounded-full border border-border text-muted-foreground/80 hover:text-foreground hover:bg-muted transition-colors",children:"Cancel"})]})),s.jsxs("div",{ref:I,className:"relative flex flex-col h-full overflow-hidden",onClick:ae,onDragOver:Q,onDragEnter:oe,onDragLeave:ne,onDrop:X,children:[xe&&s.jsx("div",{className:"flex items-center justify-center h-full font-mono text-[12px] absolute inset-0 z-10 bg-background/95",children:xe}),G&&s.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-cyan-500/10 border-2 border-dashed border-cyan-500/50 rounded pointer-events-none",children:s.jsx("span",{className:"text-cyan-400 font-mono text-sm",children:"Drop image to get path"})}),s.jsx("div",{ref:z,className:"flex-1 min-h-0 min-w-0 overflow-hidden",style:{visibility:xe?"hidden":"visible",backgroundColor:O.background,"--hud-terminal-bg":O.background,"--hud-terminal-fg":O.foreground}})]})}function Qq({app:e,commands:t,state:n,relayUrl:r="ws://localhost:3600",cwd:a,agent:o="claude",provider:c,model:u,backend:f="pty",tmuxSession:h,workspaceFiles:p,onOpenSettings:x,onStartService:v,voiceKit:y}){const[b,C]=Lr(`assistant.${e.id}.mode`,"relay"),[E,A]=m.useState(""),[S,k]=Lr(`assistant.${e.id}.voice.speakReplies`,y?.settings.speakReplies??!1),{serviceApiUrl:N}=vg(),T=m.useMemo(()=>e7(e),[e]),R=ij({url:r,systemPrompt:T,cwd:a,workspaceFiles:p,sessionKey:`assistant-${e.id}`,backend:f,tmuxSession:h,agent:o,provider:o==="pi"?c:void 0,model:o==="pi"?u:void 0}),O=m.useCallback(async()=>{if(v)return v();try{return(await(await fetch(`${N}/api/services/execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serviceId:"relay",action:"start",triggeredBy:"assistant"})})).json()).success===!0}catch{return!1}},[v,N]),L=m.useMemo(()=>{const V=[{label:"Relay",value:r},{label:"Agent",value:o}];return a&&V.push({label:"CWD",value:a}),o==="pi"&&u&&V.push({label:"Model",value:u}),V},[r,o,a,u]),[I,z]=m.useState("text"),_=Hq({app:e,commands:t,state:n,provider:c,model:u,onFinish:({message:V,isAbort:Y,isDisconnect:K,isError:P})=>{!y||!S||Y||K||P||V.role==="assistant"&&y.speakReply(V,{surface:"hudson-assistant",appId:e.id,source:I})}}),U=m.useCallback(V=>{if(!y)return;const Y=[E.trim(),V].filter(Boolean).join(" ");y.settings.autoSend&&_.status!=="streaming"&&_.status!=="submitted"?(A(""),z("voice"),_.sendMessage({text:Y})):A(Y)},[y,E,_]),D=m.useCallback(()=>{y&&(y.input.status==="recording"?y.input.stop():y.input.start(U))},[y,U]),q=e.intents?.length??0,Z=!!y,$=y?.input.status==="transcribing",G=y?.input.status==="recording";return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 border-b border-border/50 bg-background/60",children:[s.jsx(Gw,{size:11,className:"text-cyan-400/60"}),s.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wider text-muted-foreground/80",children:"Assistant"}),s.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground/60",children:["· ",e.name]}),s.jsx("div",{className:"flex-1"}),Z&&b==="chat"&&s.jsx("button",{type:"button",onClick:()=>{S&&y?.output.stop(),k(!S)},className:`p-1 rounded transition-colors ${S?"text-cyan-300 hover:text-cyan-200":"text-muted-foreground/80 hover:text-foreground"}`,title:S?"Speaker on (click to mute)":"Speaker off (click to enable)",children:y?.output.isPlaying?s.jsx(Kn,{size:12,className:"animate-spin"}):S?s.jsx(T2,{size:12}):s.jsx(M2,{size:12})}),s.jsxs("div",{className:"flex items-center gap-1 rounded-full border border-border p-0.5",children:[s.jsx(qE,{active:b==="relay",onClick:()=>C("relay"),children:"Relay"}),s.jsx(qE,{active:b==="chat",onClick:()=>C("chat"),children:"Chat"})]}),b==="relay"&&R.status==="connected"&&s.jsx("button",{type:"button",onClick:()=>R.restart(),className:"text-[10px] px-2 py-0.5 rounded-full border text-cyan-400 border-cyan-500/30 hover:bg-cyan-500/10 transition-colors",title:"Kill session and start fresh",children:"Restart"}),b==="relay"&&R.status==="connected"&&s.jsx("button",{type:"button",onClick:()=>R.disconnect(),className:"text-[10px] px-2 py-0.5 rounded-full border text-red-400 border-red-500/30 hover:bg-red-500/10 transition-colors",children:"Disconnect"}),b==="relay"&&R.status!=="connected"&&R.status!=="connecting"&&s.jsx("button",{type:"button",onClick:()=>R.connect(),className:"text-[10px] px-2 py-0.5 rounded-full border text-accent border-accent/30 hover:bg-accent/10 transition-colors",children:"Connect"})]}),s.jsx("div",{className:"flex-1 min-h-0",children:b==="relay"?s.jsx(oj,{relay:R,configItems:L,onOpenSettings:x,onStartService:O}):s.jsx(Wq,{chat:_,placeholder:q===0?`Ask about ${e.name} — no intents declared, conversation only.`:`Ask ${e.name} to do something… (${q} intent${q===1?"":"s"})`,inputValue:E,onInputChange:V=>{I==="voice"&&V.length===0&&z("text"),A(V)},inputExtras:Z&&y?.input.isSupported?s.jsx("button",{type:"button",onClick:D,disabled:$,className:`p-1 rounded transition-colors disabled:opacity-30 ${G?"bg-red-500/15 text-red-300 hover:bg-red-500/20":"text-muted-foreground/80 hover:text-cyan-400"}`,title:G?"Stop recording":"Record voice prompt",children:$?s.jsx(Kn,{size:12,className:"animate-spin"}):G?s.jsx(df,{size:11}):s.jsx(Kw,{size:12})}):void 0,inputStatus:Z&&y?s.jsx(Jq,{inputStatus:y.input.status,inputError:y.input.error,outputStatus:y.output.status,outputError:y.output.error}):void 0})})]})}function Jq({inputStatus:e,inputError:t,outputStatus:n,outputError:r}){const a=WE(e)??WE(n),o=t??r;return!a&&!o?null:s.jsxs("div",{className:"flex items-center gap-2",children:[a&&s.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full border font-mono ${a.className}`,children:a.label}),o&&s.jsx("span",{className:"text-[10px] text-muted-foreground/80 truncate flex-1",title:o,children:o})]})}function WE(e){switch(e){case"recording":return{label:"listening",className:"border-red-500/20 bg-red-500/10 text-red-300"};case"transcribing":return{label:"transcribing",className:"border-amber-500/20 bg-amber-500/10 text-amber-300"};case"ready":return{label:"draft ready",className:"border-cyan-500/20 bg-cyan-500/10 text-cyan-300"};case"synthesizing":return{label:"voicing",className:"border-cyan-500/20 bg-cyan-500/10 text-cyan-300"};case"speaking":return{label:"speaking",className:"border-accent/20 bg-accent/10 text-accent"};case"unavailable":return{label:"voice offline",className:"border-amber-500/20 bg-amber-500/10 text-amber-300"};case"error":return{label:"voice error",className:"border-red-500/20 bg-red-500/10 text-red-300"};default:return null}}function qE({active:e,onClick:t,children:n}){return s.jsx("button",{type:"button",onClick:t,className:`text-[10px] px-2 py-0.5 rounded-full transition-colors ${e?"bg-cyan-500/15 text-cyan-300":"text-muted-foreground/80 hover:text-foreground"}`,children:n})}function e7(e){const t=[`You are working alongside the user inside the **${e.name}** Hudson app.`];e.description&&t.push(e.description);const n=e.intents??[];if(n.length>0){t.push("","## What this app can do (for context)");for(const r of n)t.push(`- ${r.title} — ${r.description}`);t.push("","These actions live inside the running app. You can describe them to the user, but you do not invoke them yourself — the user can trigger any of them via the command palette (Cmd+K).")}return t.push("","## How to behave","- Be terse. The user is in a terminal; respect their attention.","- Use your own tools (file ops, shell, etc.) freely if it helps.","- When asked to change something inside the app itself, prefer guiding the user to the matching command rather than hacking around it."),t.join(`
110
- `)}var kg={panels:{statusBar:"bg-card/95 backdrop-blur-xl border-t border-[var(--hud-chrome-border-subtle)] shadow-[var(--hud-shadow-bar)] fixed bottom-0 left-0 right-0 z-[60]"},zIndex:{drawer:70},layout:{navHeight:48,statusBarHeight:28}},t7=kg.panels;const n7={...b2};let KE=0;function s7(e,t="mui"){const[n,r]=m.useState(e),a=e||n;return m.useEffect(()=>{n==null&&(KE+=1,r(`${t}-${KE}`))},[n,t]),a}const GE=n7.useId;function Zi(e,t){if(GE!==void 0){const n=GE();return e??(t?`${t}-${n}`:n)}return s7(e,t)}function al(e,...t){const n=new URL(`https://base-ui.com/production-error/${e}`);return t.forEach(r=>n.searchParams.append("args[]",r)),`Base UI error #${e}; visit ${n} for the full message.`}const vO=m.createContext(void 0);function Ng(e=!0){const t=m.useContext(vO);if(t===void 0&&!e)throw new Error(al(25));return t}const xO=m.createContext(void 0);function yO(e){const t=m.useContext(xO);if(t===void 0&&!e)throw new Error(al(33));return t}const lj=m.createContext(void 0);function Wc(e){const t=m.useContext(lj);if(t===void 0&&!e)throw new Error(al(36));return t}const ZE={};function Nr(e,t){const n=m.useRef(ZE);return n.current===ZE&&(n.current=e(t)),n}function Gd(e,t,n,r){const a=Nr(bO).current;return a7(a,e,t,n,r)&&wO(a,[e,t,n,r]),a.callback}function r7(e){const t=Nr(bO).current;return i7(t,e)&&wO(t,e),t.callback}function bO(){return{callback:null,cleanup:null,refs:[]}}function a7(e,t,n,r,a){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==a}function i7(e,t){return e.refs.length!==t.length||e.refs.some((n,r)=>n!==t[r])}function wO(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const r=Array(t.length).fill(null);for(let a=0;a<t.length;a+=1){const o=t[a];if(o!=null)switch(typeof o){case"function":{const c=o(n);typeof c=="function"&&(r[a]=c);break}case"object":{o.current=n;break}}}e.cleanup=()=>{for(let a=0;a<t.length;a+=1){const o=t[a];if(o!=null)switch(typeof o){case"function":{const c=r[a];typeof c=="function"?c():o(null);break}case"object":{o.current=null;break}}}}}}}const o7=parseInt(m.version,10);function cj(e){return o7>=e}function YE(e){if(!m.isValidElement(e))return null;const t=e,n=t.props;return(cj(19)?n?.ref:t.ref)??null}function c0(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function l7(e,t){const n={};for(const r in e){const a=e[r];if(t?.hasOwnProperty(r)){const o=t[r](a);o!=null&&Object.assign(n,o);continue}a===!0?n[`data-${r.toLowerCase()}`]="":a&&(n[`data-${r.toLowerCase()}`]=a.toString())}return n}function c7(e,t){return typeof e=="function"?e(t):e}function u7(e,t){return typeof e=="function"?e(t):e}const jd={};function Sg(e,t,n,r,a){let o={...u0(e,jd)};return t&&(o=Fm(o,t)),n&&(o=Fm(o,n)),r&&(o=Fm(o,r)),o}function d7(e){if(e.length===0)return jd;if(e.length===1)return u0(e[0],jd);let t={...u0(e[0],jd)};for(let n=1;n<e.length;n+=1)t=Fm(t,e[n]);return t}function Fm(e,t){return jO(t)?t(e):f7(e,t)}function f7(e,t){if(!t)return e;for(const n in t){const r=t[n];switch(n){case"style":{e[n]=c0(e.style,r);break}case"className":{e[n]=kO(e.className,r);break}default:h7(n,r)?e[n]=m7(e[n],r):e[n]=r}}return e}function h7(e,t){const n=e.charCodeAt(0),r=e.charCodeAt(1),a=e.charCodeAt(2);return n===111&&r===110&&a>=65&&a<=90&&(typeof t=="function"||typeof t>"u")}function jO(e){return typeof e=="function"}function u0(e,t){return jO(e)?e(t):e??jd}function m7(e,t){return t?e?n=>{if(p7(n)){const a=n;d0(a);const o=t(a);return a.baseUIHandlerPrevented||e?.(a),o}const r=t(n);return e?.(n),r}:t:e}function d0(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function kO(e,t){return t?e?t+" "+e:t:e}function p7(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}function NO(){}const SO=Object.freeze([]),Ps=Object.freeze({}),g7=500,v7={style:{transition:"none"}},x7="data-base-ui-click-trigger",y7={fallbackAxisSide:"none"},b7={clipPath:"inset(50%)",position:"fixed",top:0,left:0};function Yi(e,t,n={}){const r=t.render,a=w7(t,n);if(n.enabled===!1)return null;const o=n.state??Ps;return j7(e,r,a,o)}function w7(e,t={}){const{className:n,style:r,render:a}=e,{state:o=Ps,ref:c,props:u,stateAttributesMapping:f,enabled:h=!0}=t,p=h?c7(n,o):void 0,x=h?u7(r,o):void 0,v=h?l7(o,f):Ps,y=h?c0(v,Array.isArray(u)?d7(u):u)??Ps:Ps;return typeof document<"u"&&(h?Array.isArray(c)?y.ref=r7([y.ref,YE(a),...c]):y.ref=Gd(y.ref,YE(a),c):Gd(null,null)),h?(p!==void 0&&(y.className=kO(y.className,p)),x!==void 0&&(y.style=c0(y.style,x)),y):Ps}function j7(e,t,n,r){if(t){if(typeof t=="function")return t(n,r);const a=Sg(n,t.props);return a.ref=n.ref,m.cloneElement(t,a)}return k7(e,n)}function k7(e,t){return m.createElement(e,t)}let kp=(function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e})({});const N7={[kp.startingStyle]:""},S7={[kp.endingStyle]:""},C7={transitionStatus(e){return e==="starting"?N7:e==="ending"?S7:null}};let uj=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=kp.startingStyle]="startingStyle",e[e.endingStyle=kp.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e})({}),XE=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const E7={[XE.popupOpen]:"",[XE.pressed]:""},A7={[uj.open]:""},T7={[uj.closed]:""},M7={[uj.anchorHidden]:""},R7={open(e){return e?E7:null}},CO={open(e){return e?A7:T7},anchorHidden(e){return e?M7:null}},I7="none",Np="trigger-press",Vo="trigger-hover",QE="trigger-focus",dj="outside-press",EO="item-press",Cg="focus-out",AO="escape-key",Vm="list-navigation",_7="cancel-open",md="sibling-open",O7="imperative-action",Ny=b2[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],$7=Ny&&Ny!==m.useLayoutEffect?Ny:e=>e();function vt(e){const t=Nr(L7).current;return t.next=e,$7(t.effect),t.trampoline}function L7(){const e={next:void 0,callback:P7,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function P7(){}function Eg(){return typeof window<"u"}function Xi(e){return fj(e)?(e.nodeName||"").toLowerCase():"#document"}function ls(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ma(e){var t;return(t=(fj(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function fj(e){return Eg()?e instanceof Node||e instanceof ls(e).Node:!1}function xn(e){return Eg()?e instanceof Element||e instanceof ls(e).Element:!1}function Wn(e){return Eg()?e instanceof HTMLElement||e instanceof ls(e).HTMLElement:!1}function f0(e){return!Eg()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ls(e).ShadowRoot}function il(e){const{overflow:t,overflowX:n,overflowY:r,display:a}=nr(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&a!=="inline"&&a!=="contents"}function D7(e){return/^(table|td|th)$/.test(Xi(e))}function Ag(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const z7=/transform|translate|scale|rotate|perspective|filter/,B7=/paint|layout|strict|content/,ko=e=>!!e&&e!=="none";let Sy;function hj(e){const t=xn(e)?nr(e):e;return ko(t.transform)||ko(t.translate)||ko(t.scale)||ko(t.rotate)||ko(t.perspective)||!Tg()&&(ko(t.backdropFilter)||ko(t.filter))||z7.test(t.willChange||"")||B7.test(t.contain||"")}function U7(e){let t=ua(e);for(;Wn(t)&&!ra(t);){if(hj(t))return t;if(Ag(t))return null;t=ua(t)}return null}function Tg(){return Sy==null&&(Sy=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Sy}function ra(e){return/^(html|body|#document)$/.test(Xi(e))}function nr(e){return ls(e).getComputedStyle(e)}function Mg(e){return xn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ua(e){if(Xi(e)==="html")return e;const t=e.assignedSlot||e.parentNode||f0(e)&&e.host||ma(e);return f0(t)?t.host:t}function TO(e){const t=ua(e);return ra(t)?e.ownerDocument?e.ownerDocument.body:e.body:Wn(t)&&il(t)?t:TO(t)}function Oi(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const a=TO(e),o=a===((r=e.ownerDocument)==null?void 0:r.body),c=ls(a);if(o){const u=h0(c);return t.concat(c,c.visualViewport||[],il(a)?a:[],u&&n?Oi(u):[])}else return t.concat(a,Oi(a,[],n))}function h0(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const F7=()=>{},pt=typeof document<"u"?m.useLayoutEffect:F7,V7=m.createContext(void 0);function H7(e=!1){const t=m.useContext(V7);if(t===void 0&&!e)throw new Error(al(16));return t}function W7(e){const{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:a=0,isNativeButton:o}=e,c=r&&t!==!1,u=r&&t===!1;return{props:m.useMemo(()=>{const h={onKeyDown(p){n&&t&&p.key!=="Tab"&&p.preventDefault()}};return r||(h.tabIndex=a,!o&&n&&(h.tabIndex=t?a:-1)),(o&&(t||c)||!o&&n)&&(h["aria-disabled"]=n),o&&(!t||u)&&(h.disabled=n),h},[r,n,t,c,u,o,a])}}function q7(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:a=!0}=e,o=m.useRef(null),c=H7(!0)!==void 0,u=vt(()=>{const v=o.current;return!!(v?.tagName==="A"&&v?.href)}),{props:f}=W7({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:a}),h=m.useCallback(()=>{const v=o.current;K7(v)&&c&&t&&f.disabled===void 0&&v.disabled&&(v.disabled=!1)},[t,f.disabled,c]);pt(h,[h]);const p=m.useCallback((v={})=>{const{onClick:y,onMouseDown:b,onKeyUp:C,onKeyDown:E,onPointerDown:A,...S}=v;return Sg({type:a?"button":void 0,onClick(N){if(t){N.preventDefault();return}y?.(N)},onMouseDown(N){t||b?.(N)},onKeyDown(N){if(t||(d0(N),E?.(N)),N.baseUIHandlerPrevented)return;const T=N.target===N.currentTarget&&!a&&!u()&&!t,R=N.key==="Enter",O=N.key===" ";T&&((O||R)&&N.preventDefault(),R&&y?.(N))},onKeyUp(N){t||(d0(N),C?.(N)),!N.baseUIHandlerPrevented&&N.target===N.currentTarget&&!a&&!t&&N.key===" "&&y?.(N)},onPointerDown(N){if(t){N.preventDefault();return}A?.(N)}},a?void 0:{role:"button"},f,S)},[t,f,a,u]),x=vt(v=>{o.current=v,h()});return{getButtonProps:p,buttonRef:x}}function K7(e){return Wn(e)&&e.tagName==="BUTTON"}const G7={type:"regular-item"};function Z7(e){const{closeOnClick:t,disabled:n=!1,highlighted:r,id:a,store:o,nativeButton:c,itemMetadata:u,nodeId:f}=e,h=m.useRef(null),p=Ng(!0),x=p!==void 0,{events:v}=o.useState("floatingTreeRoot"),{getButtonProps:y,buttonRef:b}=q7({disabled:n,focusableWhenDisabled:!0,native:c}),C=m.useCallback(A=>Sg({id:a,role:"menuitem",tabIndex:r?0:-1,onMouseMove(S){f&&v.emit("itemhover",{nodeId:f,target:S.currentTarget})},onMouseEnter(){u.type==="submenu-trigger"&&u.setActive()},onKeyUp(S){S.key===" "&&o.context.typingRef.current&&S.preventBaseUIHandler()},onClick(S){t&&v.emit("close",{domEvent:S,reason:EO})},onMouseUp(S){if(p){const k=p.initialCursorPointRef.current;if(p.initialCursorPointRef.current=null,x&&k&&Math.abs(S.clientX-k.x)<=1&&Math.abs(S.clientY-k.y)<=1)return}h.current&&o.context.allowMouseUpTriggerRef.current&&(!x||S.button===2)&&u.type==="regular-item"&&h.current.click()}},A,y),[a,r,y,t,v,o,x,p,u,f]),E=Gd(h,b);return m.useMemo(()=>({getItemProps:C,itemRef:E}),[C,E])}const MO=m.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function Y7(){return m.useContext(MO)}let X7=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function Q7(e={}){const{label:t,metadata:n,textRef:r,indexGuessBehavior:a,index:o}=e,{register:c,unregister:u,subscribeMapChange:f,elementsRef:h,labelsRef:p,nextIndexRef:x}=Y7(),v=m.useRef(-1),[y,b]=m.useState(o??(a===X7.GuessFromOrder?()=>{if(v.current===-1){const A=x.current;x.current+=1,v.current=A}return v.current}:-1)),C=m.useRef(null),E=m.useCallback(A=>{if(C.current=A,y!==-1&&A!==null&&(h.current[y]=A,p)){const S=t!==void 0;p.current[y]=S?t:r?.current?.textContent??A.textContent}},[y,h,p,t,r]);return pt(()=>{if(o!=null)return;const A=C.current;if(A)return c(A,n),()=>{u(A)}},[o,c,u,n]),pt(()=>{if(o==null)return f(A=>{const S=C.current?A.get(C.current)?.index:null;S!=null&&b(S)})},[o,f,b]),m.useMemo(()=>({ref:E,index:y}),[y,E])}function RO(e){return Zi(e,"base-ui")}function qn(e,t,n,r){let a=!1,o=!1;const c=Ps;return{reason:e,event:t??new Event("base-ui"),cancel(){a=!0},allowPropagation(){o=!0},get isCanceled(){return a},get isPropagationAllowed(){return o},trigger:n,...c}}var da=w2();const J7=[];function IO(e){m.useEffect(e,J7)}const Hh=null;class eK{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=t=>{this.isScheduled=!1;const n=this.callbacks,r=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,r>0)for(let a=0;a<n.length;a+=1)n[a]?.(t)};request(t){const n=this.nextId;return this.nextId+=1,this.callbacks.push(t),this.callbacksCount+=1,!this.isScheduled&&(requestAnimationFrame(this.tick),this.isScheduled=!0),n}cancel(t){const n=t-this.startId;n<0||n>=this.callbacks.length||(this.callbacks[n]=null,this.callbacksCount-=1)}}const Wh=new eK;class na{static create(){return new na}static request(t){return Wh.request(t)}static cancel(t){return Wh.cancel(t)}currentId=Hh;request(t){this.cancel(),this.currentId=Wh.request(()=>{this.currentId=Hh,t()})}cancel=()=>{this.currentId!==Hh&&(Wh.cancel(this.currentId),this.currentId=Hh)};disposeEffect=()=>this.cancel}function mj(){const e=Nr(na.create).current;return IO(e.disposeEffect),e}function tK(e,t=!1,n=!1){const[r,a]=m.useState(e&&t?"idle":void 0),[o,c]=m.useState(e);return e&&!o&&(c(!0),a("starting")),!e&&o&&r!=="ending"&&!n&&a("ending"),!e&&!o&&r==="ending"&&a(void 0),pt(()=>{if(!e&&o&&r!=="ending"&&n){const u=na.request(()=>{a("ending")});return()=>{na.cancel(u)}}},[e,o,r,n]),pt(()=>{if(!e||t)return;const u=na.request(()=>{da.flushSync(()=>{a(void 0)})});return()=>{na.cancel(u)}},[t,e]),pt(()=>{if(!e||!t)return;e&&o&&r!=="idle"&&a("starting");const u=na.request(()=>{a("idle")});return()=>{na.cancel(u)}},[t,e,o,a,r]),m.useMemo(()=>({mounted:o,setMounted:c,transitionStatus:r}),[o,r])}function $s(e){const t=Nr(nK,e).current;return t.next=e,pt(t.effect),t}function nK(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}function Io(e){return e==null?e:"current"in e?e.current:e}function sK(e,t=!1,n=!0){const r=mj();return vt((a,o=null)=>{r.cancel();const c=Io(e);c!=null&&(typeof c.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED?a():r.request(()=>{function u(){c&&Promise.all(c.getAnimations().map(f=>f.finished)).then(()=>{o!=null&&o.aborted||da.flushSync(a)}).catch(()=>{if(n){if(o!=null&&o.aborted)return;da.flushSync(a)}else c.getAnimations().length>0&&c.getAnimations().some(f=>f.pending||f.playState!=="finished")&&u()})}t?r.request(u):u()}))})}function _O(e){const{enabled:t=!0,open:n,ref:r,onComplete:a}=e,o=$s(n),c=vt(a),u=sK(r,n);m.useEffect(()=>{t&&u(()=>{n===o.current&&c()})},[t,n,c,u,o])}const OO=m.createContext(void 0);function rK(){const e=m.useContext(OO);if(e===void 0)throw new Error(al(31));return e}const aK=m.forwardRef(function(t,n){const{render:r,className:a,...o}=t,[c,u]=m.useState(void 0),f=m.useMemo(()=>({setLabelId:u}),[u]),h=Yi("div",t,{ref:n,props:{role:"group","aria-labelledby":c,...o}});return s.jsx(OO.Provider,{value:f,children:h})}),iK=m.forwardRef(function(t,n){const{className:r,render:a,id:o,...c}=t,u=RO(o),{setLabelId:f}=rK();return pt(()=>(f(u),()=>{f(void 0)}),[f,u]),Yi("div",t,{ref:n,props:{id:u,role:"presentation",...c}})}),oK=m.forwardRef(function(t,n){const{render:r,className:a,id:o,label:c,nativeButton:u=!1,disabled:f=!1,closeOnClick:h=!0,...p}=t,x=Q7({label:c}),v=yO(!0),y=RO(o),{store:b}=Wc(),C=b.useState("isActive",x.index),E=b.useState("itemProps"),{getItemProps:A,itemRef:S}=Z7({closeOnClick:h,disabled:f,highlighted:C,id:y,store:b,nativeButton:u,nodeId:v?.nodeId,itemMetadata:G7}),k=m.useMemo(()=>({disabled:f,highlighted:C}),[f,C]);return Yi("div",t,{state:k,props:[E,p,A],ref:[S,n,x.ref]})}),qu=0;class _c{static create(){return new _c}currentId=qu;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=qu,n()},t)}isStarted(){return this.currentId!==qu}clear=()=>{this.currentId!==qu&&(clearTimeout(this.currentId),this.currentId=qu)};disposeEffect=()=>this.clear}function Br(){const e=Nr(_c.create).current;return IO(e.disposeEffect),e}const qc=typeof navigator<"u",Cy=fK(),$O=mK(),LO=hK(),lK=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),cK=Cy.platform==="MacIntel"&&Cy.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(Cy.platform),uK=qc&&/apple/i.test(navigator.vendor),m0=qc&&/android/i.test($O)||/android/i.test(LO);qc&&$O.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const dK=LO.includes("jsdom/");function fK(){if(!qc)return{platform:"",maxTouchPoints:-1};const e=navigator.userAgentData;return e?.platform?{platform:e.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??-1}}function hK(){if(!qc)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "):navigator.userAgent}function mK(){if(!qc)return"";const e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??""}const p0="data-base-ui-focusable",PO="active",DO="selected",zO="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",$i="ArrowLeft",Li="ArrowRight",pj="ArrowUp",mf="ArrowDown";function Ci(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function vn(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&f0(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function Ls(e){return"composedPath"in e?e.composedPath()[0]:e.target}function _r(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function pK(e){return e.matches("html,body")}function as(e){return e?.ownerDocument||document}function gK(e){return Wn(e)&&e.matches(zO)}function g0(e){return e?e.getAttribute("role")==="combobox"&&gK(e):!1}function Sp(e){return e?e.hasAttribute(p0)?e:e.querySelector(`[${p0}]`)||e:null}function yc(e,t,n=!0){return e.filter(a=>a.parentId===t&&(!n||a.context?.open)).flatMap(a=>[a,...yc(e,a.id,n)])}function JE(e,t){let n=[],r=e.find(a=>a.id===t)?.parentId;for(;r;){const a=e.find(o=>o.id===r);r=a?.parentId,a&&(n=n.concat(a))}return n}function is(e){e.preventDefault(),e.stopPropagation()}function vK(e){return"nativeEvent"in e}function BO(e){return e.mozInputSource===0&&e.isTrusted?!0:m0&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function UO(e){return dK?!1:!m0&&e.width===0&&e.height===0||m0&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function xK(e,t){const n=["mouse","pen"];return n.push("",void 0),n.includes(e)}function yK(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const bK=["top","right","bottom","left"],Oc=Math.min,Xs=Math.max,Cp=Math.round,cc=Math.floor,aa=e=>({x:e,y:e}),wK={left:"right",right:"left",bottom:"top",top:"bottom"};function v0(e,t,n){return Xs(e,Oc(t,n))}function qa(e,t){return typeof e=="function"?e(t):e}function Js(e){return e.split("-")[0]}function Qi(e){return e.split("-")[1]}function gj(e){return e==="x"?"y":"x"}function vj(e){return e==="y"?"height":"width"}function vr(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function xj(e){return gj(vr(e))}function jK(e,t,n){n===void 0&&(n=!1);const r=Qi(e),a=xj(e),o=vj(a);let c=a==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(c=Ep(c)),[c,Ep(c)]}function kK(e){const t=Ep(e);return[x0(e),t,x0(t)]}function x0(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const eA=["left","right"],tA=["right","left"],NK=["top","bottom"],SK=["bottom","top"];function CK(e,t,n){switch(e){case"top":case"bottom":return n?t?tA:eA:t?eA:tA;case"left":case"right":return t?NK:SK;default:return[]}}function EK(e,t,n,r){const a=Qi(e);let o=CK(Js(e),n==="start",r);return a&&(o=o.map(c=>c+"-"+a),t&&(o=o.concat(o.map(x0)))),o}function Ep(e){const t=Js(e);return wK[t]+e.slice(t.length)}function AK(e){return{top:0,right:0,bottom:0,left:0,...e}}function FO(e){return typeof e!="number"?AK(e):{top:e,right:e,bottom:e,left:e}}function Ap(e){const{x:t,y:n,width:r,height:a}=e;return{width:r,height:a,top:n,left:t,right:t+r,bottom:n+a,x:t,y:n}}function qh(e,t,n){return Math.floor(e/t)!==n}function kd(e,t){return t<0||t>=e.current.length}function Ey(e,t){return fs(e,{disabledIndices:t})}function nA(e,t){return fs(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function fs(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:a=1}={}){let o=t;do o+=n?-a:a;while(o>=0&&o<=e.current.length-1&&Nd(e,o,r));return o}function TK(e,{event:t,orientation:n,loopFocus:r,rtl:a,cols:o,disabledIndices:c,minIndex:u,maxIndex:f,prevIndex:h,stopEvent:p=!1}){let x=h;const v=[],y={};let b=!1;{let A=null,S=-1;e.current.forEach((k,N)=>{if(k==null)return;const T=k.closest('[role="row"]');T&&(b=!0),(T!==A||S===-1)&&(A=T,S+=1,v[S]=[]),v[S].push(N),y[N]=S})}const C=b&&v.length>0&&v.some(A=>A.length!==o);function E(A){if(!C||h===-1)return;const S=y[h];if(S==null)return;const k=v[S].indexOf(h);let N=A==="up"?S-1:S+1;r&&(N<0?N=v.length-1:N>=v.length&&(N=0));const T=new Set;for(;N>=0&&N<v.length&&!T.has(N);){T.add(N);const R=v[N];if(R.length===0){N=A==="up"?N-1:N+1;continue}const O=Math.min(k,R.length-1);for(let L=O;L>=0;L-=1){const I=R[L];if(!Nd(e,I,c))return I}N=A==="up"?N-1:N+1,r&&(N<0?N=v.length-1:N>=v.length&&(N=0))}}if(t.key===pj){const A=E("up");if(A!==void 0)p&&is(t),x=A;else{if(p&&is(t),h===-1)x=f;else if(x=fs(e,{startingIndex:x,amount:o,decrement:!0,disabledIndices:c}),r&&(h-o<u||x<0)){const S=h%o,k=f%o,N=f-(k-S);k===S?x=f:x=k>S?N:N-o}kd(e,x)&&(x=h)}}if(t.key===mf){const A=E("down");A!==void 0?(p&&is(t),x=A):(p&&is(t),h===-1?x=u:(x=fs(e,{startingIndex:h,amount:o,disabledIndices:c}),r&&h+o>f&&(x=fs(e,{startingIndex:h%o-o,amount:o,disabledIndices:c}))),kd(e,x)&&(x=h))}if(n==="both"){const A=cc(h/o);t.key===(a?$i:Li)&&(p&&is(t),h%o!==o-1?(x=fs(e,{startingIndex:h,disabledIndices:c}),r&&qh(x,o,A)&&(x=fs(e,{startingIndex:h-h%o-1,disabledIndices:c}))):r&&(x=fs(e,{startingIndex:h-h%o-1,disabledIndices:c})),qh(x,o,A)&&(x=h)),t.key===(a?Li:$i)&&(p&&is(t),h%o!==0?(x=fs(e,{startingIndex:h,decrement:!0,disabledIndices:c}),r&&qh(x,o,A)&&(x=fs(e,{startingIndex:h+(o-h%o),decrement:!0,disabledIndices:c}))):r&&(x=fs(e,{startingIndex:h+(o-h%o),decrement:!0,disabledIndices:c})),qh(x,o,A)&&(x=h));const S=cc(f/o)===A;kd(e,x)&&(r&&S?x=t.key===(a?Li:$i)?f:fs(e,{startingIndex:h-h%o-1,disabledIndices:c}):x=h)}return x}function MK(e,t,n){const r=[];let a=0;return e.forEach(({width:o,height:c},u)=>{let f=!1;for(n&&(a=0);!f;){const h=[];for(let p=0;p<o;p+=1)for(let x=0;x<c;x+=1)h.push(a+p+x*t);a%t+o<=t&&h.every(p=>r[p]==null)?(h.forEach(p=>{r[p]=u}),f=!0):a+=1}}),[...r]}function RK(e,t,n,r,a){if(e===-1)return-1;const o=n.indexOf(e),c=t[e];switch(a){case"tl":return o;case"tr":return c?o+c.width-1:o;case"bl":return c?o+(c.height-1)*r:o;case"br":return n.lastIndexOf(e);default:return-1}}function IK(e,t){return t.flatMap((n,r)=>e.includes(n)?[r]:[])}function Nd(e,t,n){if(typeof n=="function")return n(t);if(n)return n.includes(t);const r=e.current[t];return r?r.hasAttribute("disabled")||r.getAttribute("aria-disabled")==="true":!1}var _K=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],Tp=_K.join(","),VO=typeof Element>"u",$c=VO?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Mp=!VO&&Element.prototype.getRootNode?function(e){var t;return e==null||(t=e.getRootNode)===null||t===void 0?void 0:t.call(e)}:function(e){return e?.ownerDocument},Rp=function(t,n){var r;n===void 0&&(n=!0);var a=t==null||(r=t.getAttribute)===null||r===void 0?void 0:r.call(t,"inert"),o=a===""||a==="true",c=o||n&&t&&(typeof t.closest=="function"?t.closest("[inert]"):Rp(t.parentNode));return c},OK=function(t){var n,r=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return r===""||r==="true"},HO=function(t,n,r){if(Rp(t))return[];var a=Array.prototype.slice.apply(t.querySelectorAll(Tp));return n&&$c.call(t,Tp)&&a.unshift(t),a=a.filter(r),a},Ip=function(t,n,r){for(var a=[],o=Array.from(t);o.length;){var c=o.shift();if(!Rp(c,!1))if(c.tagName==="SLOT"){var u=c.assignedElements(),f=u.length?u:c.children,h=Ip(f,!0,r);r.flatten?a.push.apply(a,h):a.push({scopeParent:c,candidates:h})}else{var p=$c.call(c,Tp);p&&r.filter(c)&&(n||!t.includes(c))&&a.push(c);var x=c.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(c),v=!Rp(x,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(c));if(x&&v){var y=Ip(x===!0?c.children:x.children,!0,r);r.flatten?a.push.apply(a,y):a.push({scopeParent:c,candidates:y})}else o.unshift.apply(o,c.children)}}return a},WO=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},qO=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||OK(t))&&!WO(t)?0:t.tabIndex},$K=function(t,n){var r=qO(t);return r<0&&n&&!WO(t)?0:r},LK=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},KO=function(t){return t.tagName==="INPUT"},PK=function(t){return KO(t)&&t.type==="hidden"},DK=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(r){return r.tagName==="SUMMARY"});return n},zK=function(t,n){for(var r=0;r<t.length;r++)if(t[r].checked&&t[r].form===n)return t[r]},BK=function(t){if(!t.name)return!0;var n=t.form||Mp(t),r=function(u){return n.querySelectorAll('input[type="radio"][name="'+u+'"]')},a;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")a=r(window.CSS.escape(t.name));else try{a=r(t.name)}catch(c){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",c.message),!1}var o=zK(a,t.form);return!o||o===t},UK=function(t){return KO(t)&&t.type==="radio"},FK=function(t){return UK(t)&&!BK(t)},VK=function(t){var n,r=t&&Mp(t),a=(n=r)===null||n===void 0?void 0:n.host,o=!1;if(r&&r!==t){var c,u,f;for(o=!!((c=a)!==null&&c!==void 0&&(u=c.ownerDocument)!==null&&u!==void 0&&u.contains(a)||t!=null&&(f=t.ownerDocument)!==null&&f!==void 0&&f.contains(t));!o&&a;){var h,p,x;r=Mp(a),a=(h=r)===null||h===void 0?void 0:h.host,o=!!((p=a)!==null&&p!==void 0&&(x=p.ownerDocument)!==null&&x!==void 0&&x.contains(a))}}return o},sA=function(t){var n=t.getBoundingClientRect(),r=n.width,a=n.height;return r===0&&a===0},HK=function(t,n){var r=n.displayCheck,a=n.getShadowRoot;if(r==="full-native"&&"checkVisibility"in t){var o=t.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!o}if(getComputedStyle(t).visibility==="hidden")return!0;var c=$c.call(t,"details>summary:first-of-type"),u=c?t.parentElement:t;if($c.call(u,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof a=="function"){for(var f=t;t;){var h=t.parentElement,p=Mp(t);if(h&&!h.shadowRoot&&a(h)===!0)return sA(t);t.assignedSlot?t=t.assignedSlot:!h&&p!==t.ownerDocument?t=p.host:t=h}t=f}if(VK(t))return!t.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return sA(t);return!1},WK=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var n=t.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var a=n.children.item(r);if(a.tagName==="LEGEND")return $c.call(n,"fieldset[disabled] *")?!0:!a.contains(t)}return!0}n=n.parentElement}return!1},y0=function(t,n){return!(n.disabled||PK(n)||HK(n,t)||DK(n)||WK(n))},b0=function(t,n){return!(FK(n)||qO(n)<0||!y0(t,n))},qK=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},GO=function(t){var n=[],r=[];return t.forEach(function(a,o){var c=!!a.scopeParent,u=c?a.scopeParent:a,f=$K(u,c),h=c?GO(a.candidates):u;f===0?c?n.push.apply(n,h):n.push(u):r.push({documentOrder:o,tabIndex:f,item:a,isScope:c,content:h})}),r.sort(LK).reduce(function(a,o){return o.isScope?a.push.apply(a,o.content):a.push(o.content),a},[]).concat(n)},Rg=function(t,n){n=n||{};var r;return n.getShadowRoot?r=Ip([t],n.includeContainer,{filter:b0.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:qK}):r=HO(t,n.includeContainer,b0.bind(null,n)),GO(r)},KK=function(t,n){n=n||{};var r;return n.getShadowRoot?r=Ip([t],n.includeContainer,{filter:y0.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):r=HO(t,n.includeContainer,y0.bind(null,n)),r},ZO=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return $c.call(t,Tp)===!1?!1:b0(n,t)};const pf=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function YO(e,t){const n=Rg(e,pf()),r=n.length;if(r===0)return;const a=Ci(as(e)),o=n.indexOf(a),c=o===-1?t===1?0:r-1:o+t;return n[c]}function XO(e){return YO(as(e).body,1)||e}function QO(e){return YO(as(e).body,-1)||e}function Sd(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!vn(n,r)}function GK(e){Rg(e,pf()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function rA(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}function JO(){const e=new Map;return{emit(t,n){e.get(t)?.forEach(r=>r(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}class e${nodesRef={current:[]};events=JO();addNode(t){this.nodesRef.current.push(t)}removeNode(t){const n=this.nodesRef.current.findIndex(r=>r===t);n!==-1&&this.nodesRef.current.splice(n,1)}}const t$=m.createContext(null),n$=m.createContext(null),Ji=()=>m.useContext(t$)?.id||null,Kc=e=>{const t=m.useContext(n$);return e??t};function ZK(e){const t=Zi(),n=Kc(e),r=Ji();return pt(()=>{if(!t)return;const a={id:t,parentId:r};return n?.addNode(a),()=>{n?.removeNode(a)}},[n,t,r]),t}function YK(e){const{children:t,id:n}=e,r=Ji();return s.jsx(t$.Provider,{value:m.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function XK(e){const{children:t,externalTree:n}=e,r=Nr(()=>n??new e$).current;return s.jsx(n$.Provider,{value:r,children:t})}function Zd(e){return`data-base-ui-${e}`}const s$={clip:"rect(0 0 0 0)",overflow:"hidden",whiteSpace:"nowrap",position:"fixed",top:0,left:0,border:0,padding:0,width:1,height:1,margin:-1};function Jo(e){return e?.ownerDocument||document}const _p=m.forwardRef(function(t,n){const[r,a]=m.useState();pt(()=>{uK&&a("button")},[]);const o={tabIndex:0,role:r};return s.jsx("span",{...t,ref:n,style:s$,"aria-hidden":r?void 0:!0,...o,"data-base-ui-focus-guard":""})});let aA=0;function Hm(e,t={}){const{preventScroll:n=!1,cancelPrevious:r=!0,sync:a=!1}=t;r&&cancelAnimationFrame(aA);const o=()=>e?.focus({preventScroll:n});a?o():aA=requestAnimationFrame(o)}const bc={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function iA(e){return e==="inert"?bc.inert:e==="aria-hidden"?bc["aria-hidden"]:bc.none}let Kh=new WeakSet,Gh={},Ay=0;const r$=e=>e&&(e.host||r$(e.parentNode)),QK=(e,t)=>t.map(n=>{if(e.contains(n))return n;const r=r$(n);return e.contains(r)?r:null}).filter(n=>n!=null);function JK(e,t,n,r){const a="data-base-ui-inert",o=r?"inert":n?"aria-hidden":null,c=QK(t,e),u=new Set,f=new Set(c),h=[];Gh[a]||(Gh[a]=new WeakMap);const p=Gh[a];c.forEach(x),v(t),u.clear();function x(y){!y||u.has(y)||(u.add(y),y.parentNode&&x(y.parentNode))}function v(y){!y||f.has(y)||[].forEach.call(y.children,b=>{if(Xi(b)!=="script")if(u.has(b))v(b);else{const C=o?b.getAttribute(o):null,E=C!==null&&C!=="false",A=iA(o),S=(A.get(b)||0)+1,k=(p.get(b)||0)+1;A.set(b,S),p.set(b,k),h.push(b),S===1&&E&&Kh.add(b),k===1&&b.setAttribute(a,""),!E&&o&&b.setAttribute(o,o==="inert"?"":"true")}})}return Ay+=1,()=>{h.forEach(y=>{const b=iA(o),E=(b.get(y)||0)-1,A=(p.get(y)||0)-1;b.set(y,E),p.set(y,A),E||(!Kh.has(y)&&o&&y.removeAttribute(o),Kh.delete(y)),A||y.removeAttribute(a)}),Ay-=1,Ay||(bc.inert=new WeakMap,bc["aria-hidden"]=new WeakMap,bc.none=new WeakMap,Kh=new WeakSet,Gh={})}}function eG(e,t=!1,n=!1){const r=as(e[0]).body;return JK(e.concat(Array.from(r.querySelectorAll("[aria-live]"))),r,t,n)}const a$=m.createContext(null),i$=()=>m.useContext(a$),tG=Zd("portal");function nG(e={}){const{ref:t,container:n,componentProps:r=Ps,elementProps:a,elementState:o}=e,c=Zi(),f=i$()?.portalNode,[h,p]=m.useState(null),[x,v]=m.useState(null),y=m.useRef(null);pt(()=>{if(n===null){y.current&&(y.current=null,v(null),p(null));return}if(c==null)return;const E=(n&&(fj(n)?n:n.current))??f??document.body;if(E==null){y.current&&(y.current=null,v(null),p(null));return}y.current!==E&&(y.current=E,v(null),p(E))},[n,f,c]);const b=Yi("div",r,{ref:[t,v],state:o,props:[{id:c,[tG]:""},a]});return{portalNode:x,portalSubtree:h&&b?da.createPortal(b,h):null}}const sG=m.forwardRef(function(t,n){const{children:r,container:a,className:o,render:c,renderGuards:u,...f}=t,{portalNode:h,portalSubtree:p}=nG({container:a,ref:n,componentProps:t,elementProps:f}),x=m.useRef(null),v=m.useRef(null),y=m.useRef(null),b=m.useRef(null),[C,E]=m.useState(null),A=C?.modal,S=C?.open,k=typeof u=="boolean"?u:!!C&&!C.modal&&C.open&&!!h;m.useEffect(()=>{if(!h||A)return;function T(R){h&&Sd(R)&&(R.type==="focusin"?rA:GK)(h)}return h.addEventListener("focusin",T,!0),h.addEventListener("focusout",T,!0),()=>{h.removeEventListener("focusin",T,!0),h.removeEventListener("focusout",T,!0)}},[h,A]),m.useEffect(()=>{!h||S||rA(h)},[S,h]);const N=m.useMemo(()=>({beforeOutsideRef:x,afterOutsideRef:v,beforeInsideRef:y,afterInsideRef:b,portalNode:h,setFocusManagerState:E}),[h]);return s.jsxs(m.Fragment,{children:[p,s.jsxs(a$.Provider,{value:N,children:[k&&h&&s.jsx(_p,{"data-type":"outside",ref:x,onFocus:T=>{if(Sd(T,h))y.current?.focus();else{const R=C?C.domReference:null;QO(R)?.focus()}}}),k&&h&&s.jsx("span",{"aria-owns":h.id,style:b7}),h&&da.createPortal(r,h),k&&h&&s.jsx(_p,{"data-type":"outside",ref:v,onFocus:T=>{if(Sd(T,h))b.current?.focus();else{const R=C?C.domReference:null;XO(R)?.focus(),C?.closeOnFocusOut&&C?.onOpenChange(!1,qn(Cg,T.nativeEvent))}}})]})]})});function rG(e,t){const n=ls(e.target);return e instanceof n.KeyboardEvent?"keyboard":e instanceof n.FocusEvent?t||"keyboard":"pointerType"in e?e.pointerType||"keyboard":"touches"in e?"touch":e instanceof n.MouseEvent?t||(e.detail===0?"keyboard":"mouse"):""}const oA=20;let Ai=[];function yj(){Ai=Ai.filter(e=>e.isConnected)}function aG(e){yj(),e&&Xi(e)!=="body"&&(Ai.push(e),Ai.length>oA&&(Ai=Ai.slice(-oA)))}function Ty(){return yj(),Ai[Ai.length-1]}function iG(e){if(!e)return null;const t=pf();return ZO(e,t)?e:Rg(e,t)[0]||e}function oG(e){return!e||!e.isConnected?!1:typeof e.checkVisibility=="function"?e.checkVisibility():nr(e).display!=="none"}function lA(e,t){if(!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const n=pf(),a=KK(e,n).filter(c=>{const u=c.getAttribute("data-tabindex")||"";return ZO(c,n)||c.hasAttribute("data-tabindex")&&!u.startsWith("-")}),o=e.getAttribute("tabindex");t.current.includes("floating")||a.length===0?o!=="0"&&e.setAttribute("tabindex","0"):(o!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function lG(e){const{context:t,children:n,disabled:r=!1,order:a=["content"],initialFocus:o=!0,returnFocus:c=!0,restoreFocus:u=!1,modal:f=!0,closeOnFocusOut:h=!0,openInteractionType:p="",getInsideElements:x=()=>[],nextFocusableElement:v,previousFocusableElement:y,beforeContentFocusGuardRef:b,externalTree:C}=e,E="rootStore"in t?t.rootStore:t,A=E.useState("open"),S=E.useState("domReferenceElement"),k=E.useState("floatingElement"),{events:N,dataRef:T}=E.context,R=vt(()=>T.current.floatingContext?.nodeId),O=vt(x),L=o===!1,I=g0(S)&&L,z=$s(a),_=$s(o),U=$s(c),D=$s(p),q=Kc(C),Z=i$(),$=m.useRef(null),G=m.useRef(null),V=m.useRef(!1),Y=m.useRef(!1),K=m.useRef(!1),P=m.useRef(-1),H=m.useRef(""),B=m.useRef(""),Q=Br(),oe=Br(),ne=mj(),X=Z!=null,ae=Sp(k),be=vt((ke=ae)=>ke?Rg(ke,pf()):[]),_e=vt(ke=>{const Ne=be(ke);return z.current.map(()=>Ne).filter(Boolean).flat()});m.useEffect(()=>{if(r||!f)return;function ke(Fe){Fe.key==="Tab"&&vn(ae,Ci(as(ae)))&&be().length===0&&!I&&is(Fe)}const Ne=as(ae);return Ne.addEventListener("keydown",ke),()=>{Ne.removeEventListener("keydown",ke)}},[r,S,ae,f,z,I,be,_e]),m.useEffect(()=>{if(r||!k)return;function ke(Ne){const Fe=Ls(Ne),Le=be().indexOf(Fe);Le!==-1&&(P.current=Le)}return k.addEventListener("focusin",ke),()=>{k.removeEventListener("focusin",ke)}},[r,k,be]),m.useEffect(()=>{if(r||!A)return;const ke=as(ae);function Ne(){K.current=!1}function Fe(Le){const Te=Ls(Le),Pe=vn(k,Te)||vn(S,Te)||vn(Z?.portalNode,Te);K.current=!Pe,B.current=Le.pointerType||"keyboard"}function Ee(){B.current="keyboard"}return ke.addEventListener("pointerdown",Fe,!0),ke.addEventListener("pointerup",Ne,!0),ke.addEventListener("pointercancel",Ne,!0),ke.addEventListener("keydown",Ee,!0),()=>{ke.removeEventListener("pointerdown",Fe,!0),ke.removeEventListener("pointerup",Ne,!0),ke.removeEventListener("pointercancel",Ne,!0),ke.removeEventListener("keydown",Ee,!0)}},[r,k,S,ae,A,Z]),m.useEffect(()=>{if(r||!h)return;function ke(){Y.current=!0,oe.start(0,()=>{Y.current=!1})}function Ne(Te){const Pe=Te.relatedTarget,De=Te.currentTarget,ze=Ls(Te);queueMicrotask(()=>{const $e=R(),st=E.context.triggerElements,rt=!(vn(S,Pe)||vn(k,Pe)||vn(Pe,k)||vn(Z?.portalNode,Pe)||Pe!=null&&st.hasElement(Pe)||st.hasMatchingElement(Xe=>vn(Xe,Pe))||Pe?.hasAttribute(Zd("focus-guard"))||q&&(yc(q.nodesRef.current,$e).find(Xe=>vn(Xe.context?.elements.floating,Pe)||vn(Xe.context?.elements.domReference,Pe))||JE(q.nodesRef.current,$e).find(Xe=>[Xe.context?.elements.floating,Sp(Xe.context?.elements.floating)].includes(Pe)||Xe.context?.elements.domReference===Pe)));if(De===S&&ae&&lA(ae,z),u&&De!==S&&!oG(ze)&&Ci(as(ae))===as(ae).body){if(Wn(ae)&&(ae.focus(),u==="popup")){ne.request(()=>{ae.focus()});return}const Xe=P.current,dt=be(),jt=dt[Xe]||dt[dt.length-1]||ae;Wn(jt)&&jt.focus()}if(T.current.insideReactTree){T.current.insideReactTree=!1;return}(I||!f)&&Pe&&rt&&!Y.current&&(I||Pe!==Ty())&&(V.current=!0,E.setOpen(!1,qn(Cg,Te)))})}function Fe(){K.current||(T.current.insideReactTree=!0,Q.start(0,()=>{T.current.insideReactTree=!1}))}const Ee=Wn(S)?S:null,Le=[];if(!(!k&&!Ee))return Ee&&(Ee.addEventListener("focusout",Ne),Ee.addEventListener("pointerdown",ke),Le.push(()=>{Ee.removeEventListener("focusout",Ne),Ee.removeEventListener("pointerdown",ke)})),k&&(k.addEventListener("focusout",Ne),Z&&(k.addEventListener("focusout",Fe,!0),Le.push(()=>{k.removeEventListener("focusout",Fe,!0)})),Le.push(()=>{k.removeEventListener("focusout",Ne)})),()=>{Le.forEach(Te=>{Te()})}},[r,S,k,ae,f,q,Z,E,h,u,be,I,R,z,T,Q,oe,ne]);const xe=m.useRef(null),pe=m.useRef(null),te=Gd(xe,b,Z?.beforeInsideRef),ve=Gd(pe,Z?.afterInsideRef);m.useEffect(()=>{if(r||!k||!A)return;const ke=Array.from(Z?.portalNode?.querySelectorAll(`[${Zd("portal")}]`)||[]),Fe=(q?JE(q.nodesRef.current,R()):[]).find(Te=>g0(Te.context?.elements.domReference||null))?.context?.elements.domReference,Ee=[k,Fe,...ke,...O(),$.current,G.current,xe.current,pe.current,Z?.beforeOutsideRef.current,Z?.afterOutsideRef.current,Io(y),Io(v),I?S:null].filter(Te=>Te!=null),Le=eG(Ee,f||I);return()=>{Le()}},[A,r,S,k,f,z,Z,I,q,R,O,v,y]),pt(()=>{if(!A||r||!Wn(ae))return;const ke=as(ae),Ne=Ci(ke);queueMicrotask(()=>{const Fe=_e(ae),Ee=_.current,Le=typeof Ee=="function"?Ee(D.current||""):Ee;if(Le===void 0||Le===!1)return;let Te;Le===!0||Le===null?Te=Fe[0]||ae:Te=Io(Le),Te=Te||Fe[0]||ae,!vn(ae,Ne)&&Hm(Te,{preventScroll:Te===ae})})},[r,A,ae,L,_e,_,D]),pt(()=>{if(r||!ae)return;const ke=as(ae),Ne=Ci(ke);aG(Ne);function Fe(Te){if(Te.open||(H.current=rG(Te.nativeEvent,B.current)),Te.reason===Vo&&Te.nativeEvent.type==="mouseleave"&&(V.current=!0),Te.reason===dj)if(Te.nested)V.current=!1;else if(BO(Te.nativeEvent)||UO(Te.nativeEvent))V.current=!1;else{let Pe=!1;document.createElement("div").focus({get preventScroll(){return Pe=!0,!1}}),Pe?V.current=!1:V.current=!0}}N.on("openchange",Fe);const Ee=ke.createElement("span");Ee.setAttribute("tabindex","-1"),Ee.setAttribute("aria-hidden","true"),Object.assign(Ee.style,s$),X&&S&&S.insertAdjacentElement("afterend",Ee);function Le(){const Te=U.current;let Pe=typeof Te=="function"?Te(H.current):Te;if(Pe===void 0||Pe===!1)return null;if(Pe===null&&(Pe=!0),typeof Pe=="boolean"){const ze=S||Ty();return ze&&ze.isConnected?ze:Ee}const De=S||Ty()||Ee;return Io(Pe)||De}return()=>{N.off("openchange",Fe);const Te=Ci(ke),Pe=vn(k,Te)||q&&yc(q.nodesRef.current,R(),!1).some(ze=>vn(ze.context?.elements.floating,Te)),De=Le();queueMicrotask(()=>{const ze=iG(De),$e=typeof U.current!="boolean";U.current&&!V.current&&Wn(ze)&&(!(!$e&&ze!==Te&&Te!==ke.body)||Pe)&&ze.focus({preventScroll:!0}),Ee.remove()})}},[r,k,ae,U,T,N,q,X,S,R]),m.useEffect(()=>{queueMicrotask(()=>{V.current=!1})},[r]),m.useEffect(()=>{if(r||!A)return;function ke(Fe){Ls(Fe)?.closest(`[${x7}]`)&&(Y.current=!0)}const Ne=as(ae);return Ne.addEventListener("pointerdown",ke,!0),()=>{Ne.removeEventListener("pointerdown",ke,!0)}},[r,A,ae]),pt(()=>{if(!r&&Z)return Z.setFocusManagerState({modal:f,closeOnFocusOut:h,open:A,onOpenChange:E.setOpen,domReference:S}),()=>{Z.setFocusManagerState(null)}},[r,Z,f,A,E,h,S]),pt(()=>{if(!(r||!ae))return lA(ae,z),()=>{queueMicrotask(yj)}},[r,ae,z]);const he=!r&&(f?!I:!0)&&(X||f);return s.jsxs(m.Fragment,{children:[he&&s.jsx(_p,{"data-type":"inside",ref:te,onFocus:ke=>{if(f){const Ne=_e();Hm(Ne[Ne.length-1])}else Z?.portalNode&&(V.current=!1,Sd(ke,Z.portalNode)?XO(S)?.focus():Io(y??Z.beforeOutsideRef)?.focus())}}),n,he&&s.jsx(_p,{"data-type":"inside",ref:ve,onFocus:ke=>{f?Hm(_e()[0]):Z?.portalNode&&(h&&(V.current=!0),Sd(ke,Z.portalNode)?QO(S)?.focus():Io(v??Z.afterOutsideRef)?.focus())}})]})}function cA(e,t,n){let{reference:r,floating:a}=e;const o=vr(t),c=xj(t),u=vj(c),f=Js(t),h=o==="y",p=r.x+r.width/2-a.width/2,x=r.y+r.height/2-a.height/2,v=r[u]/2-a[u]/2;let y;switch(f){case"top":y={x:p,y:r.y-a.height};break;case"bottom":y={x:p,y:r.y+r.height};break;case"right":y={x:r.x+r.width,y:x};break;case"left":y={x:r.x-a.width,y:x};break;default:y={x:r.x,y:r.y}}switch(Qi(t)){case"start":y[c]-=v*(n&&h?-1:1);break;case"end":y[c]+=v*(n&&h?-1:1);break}return y}async function cG(e,t){var n;t===void 0&&(t={});const{x:r,y:a,platform:o,rects:c,elements:u,strategy:f}=e,{boundary:h="clippingAncestors",rootBoundary:p="viewport",elementContext:x="floating",altBoundary:v=!1,padding:y=0}=qa(t,e),b=FO(y),E=u[v?x==="floating"?"reference":"floating":x],A=Ap(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(E)))==null||n?E:E.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(u.floating)),boundary:h,rootBoundary:p,strategy:f})),S=x==="floating"?{x:r,y:a,width:c.floating.width,height:c.floating.height}:c.reference,k=await(o.getOffsetParent==null?void 0:o.getOffsetParent(u.floating)),N=await(o.isElement==null?void 0:o.isElement(k))?await(o.getScale==null?void 0:o.getScale(k))||{x:1,y:1}:{x:1,y:1},T=Ap(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:S,offsetParent:k,strategy:f}):S);return{top:(A.top-T.top+b.top)/N.y,bottom:(T.bottom-A.bottom+b.bottom)/N.y,left:(A.left-T.left+b.left)/N.x,right:(T.right-A.right+b.right)/N.x}}const uG=50,dG=async(e,t,n)=>{const{placement:r="bottom",strategy:a="absolute",middleware:o=[],platform:c}=n,u=c.detectOverflow?c:{...c,detectOverflow:cG},f=await(c.isRTL==null?void 0:c.isRTL(t));let h=await c.getElementRects({reference:e,floating:t,strategy:a}),{x:p,y:x}=cA(h,r,f),v=r,y=0;const b={};for(let C=0;C<o.length;C++){const E=o[C];if(!E)continue;const{name:A,fn:S}=E,{x:k,y:N,data:T,reset:R}=await S({x:p,y:x,initialPlacement:r,placement:v,strategy:a,middlewareData:b,rects:h,platform:u,elements:{reference:e,floating:t}});p=k??p,x=N??x,b[A]={...b[A],...T},R&&y<uG&&(y++,typeof R=="object"&&(R.placement&&(v=R.placement),R.rects&&(h=R.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:a}):R.rects),{x:p,y:x}=cA(h,v,f)),C=-1)}return{x:p,y:x,placement:v,strategy:a,middlewareData:b}},fG=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:a,middlewareData:o,rects:c,initialPlacement:u,platform:f,elements:h}=t,{mainAxis:p=!0,crossAxis:x=!0,fallbackPlacements:v,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:C=!0,...E}=qa(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const A=Js(a),S=vr(u),k=Js(u)===u,N=await(f.isRTL==null?void 0:f.isRTL(h.floating)),T=v||(k||!C?[Ep(u)]:kK(u)),R=b!=="none";!v&&R&&T.push(...EK(u,C,b,N));const O=[u,...T],L=await f.detectOverflow(t,E),I=[];let z=((r=o.flip)==null?void 0:r.overflows)||[];if(p&&I.push(L[A]),x){const q=jK(a,c,N);I.push(L[q[0]],L[q[1]])}if(z=[...z,{placement:a,overflows:I}],!I.every(q=>q<=0)){var _,U;const q=(((_=o.flip)==null?void 0:_.index)||0)+1,Z=O[q];if(Z&&(!(x==="alignment"?S!==vr(Z):!1)||z.every(V=>vr(V.placement)===S?V.overflows[0]>0:!0)))return{data:{index:q,overflows:z},reset:{placement:Z}};let $=(U=z.filter(G=>G.overflows[0]<=0).sort((G,V)=>G.overflows[1]-V.overflows[1])[0])==null?void 0:U.placement;if(!$)switch(y){case"bestFit":{var D;const G=(D=z.filter(V=>{if(R){const Y=vr(V.placement);return Y===S||Y==="y"}return!0}).map(V=>[V.placement,V.overflows.filter(Y=>Y>0).reduce((Y,K)=>Y+K,0)]).sort((V,Y)=>V[1]-Y[1])[0])==null?void 0:D[0];G&&($=G);break}case"initialPlacement":$=u;break}if(a!==$)return{reset:{placement:$}}}return{}}}};function uA(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function dA(e){return bK.some(t=>e[t]>=0)}const hG=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:a="referenceHidden",...o}=qa(e,t);switch(a){case"referenceHidden":{const c=await r.detectOverflow(t,{...o,elementContext:"reference"}),u=uA(c,n.reference);return{data:{referenceHiddenOffsets:u,referenceHidden:dA(u)}}}case"escaped":{const c=await r.detectOverflow(t,{...o,altBoundary:!0}),u=uA(c,n.floating);return{data:{escapedOffsets:u,escaped:dA(u)}}}default:return{}}}}},o$=new Set(["left","top"]);async function mG(e,t){const{placement:n,platform:r,elements:a}=e,o=await(r.isRTL==null?void 0:r.isRTL(a.floating)),c=Js(n),u=Qi(n),f=vr(n)==="y",h=o$.has(c)?-1:1,p=o&&f?-1:1,x=qa(t,e);let{mainAxis:v,crossAxis:y,alignmentAxis:b}=typeof x=="number"?{mainAxis:x,crossAxis:0,alignmentAxis:null}:{mainAxis:x.mainAxis||0,crossAxis:x.crossAxis||0,alignmentAxis:x.alignmentAxis};return u&&typeof b=="number"&&(y=u==="end"?b*-1:b),f?{x:y*p,y:v*h}:{x:v*h,y:y*p}}const pG=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:a,y:o,placement:c,middlewareData:u}=t,f=await mG(t,e);return c===((n=u.offset)==null?void 0:n.placement)&&(r=u.arrow)!=null&&r.alignmentOffset?{}:{x:a+f.x,y:o+f.y,data:{...f,placement:c}}}}},gG=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:a,platform:o}=t,{mainAxis:c=!0,crossAxis:u=!1,limiter:f={fn:A=>{let{x:S,y:k}=A;return{x:S,y:k}}},...h}=qa(e,t),p={x:n,y:r},x=await o.detectOverflow(t,h),v=vr(Js(a)),y=gj(v);let b=p[y],C=p[v];if(c){const A=y==="y"?"top":"left",S=y==="y"?"bottom":"right",k=b+x[A],N=b-x[S];b=v0(k,b,N)}if(u){const A=v==="y"?"top":"left",S=v==="y"?"bottom":"right",k=C+x[A],N=C-x[S];C=v0(k,C,N)}const E=f.fn({...t,[y]:b,[v]:C});return{...E,data:{x:E.x-n,y:E.y-r,enabled:{[y]:c,[v]:u}}}}}},vG=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:a,rects:o,middlewareData:c}=t,{offset:u=0,mainAxis:f=!0,crossAxis:h=!0}=qa(e,t),p={x:n,y:r},x=vr(a),v=gj(x);let y=p[v],b=p[x];const C=qa(u,t),E=typeof C=="number"?{mainAxis:C,crossAxis:0}:{mainAxis:0,crossAxis:0,...C};if(f){const k=v==="y"?"height":"width",N=o.reference[v]-o.floating[k]+E.mainAxis,T=o.reference[v]+o.reference[k]-E.mainAxis;y<N?y=N:y>T&&(y=T)}if(h){var A,S;const k=v==="y"?"width":"height",N=o$.has(Js(a)),T=o.reference[x]-o.floating[k]+(N&&((A=c.offset)==null?void 0:A[x])||0)+(N?0:E.crossAxis),R=o.reference[x]+o.reference[k]+(N?0:((S=c.offset)==null?void 0:S[x])||0)-(N?E.crossAxis:0);b<T?b=T:b>R&&(b=R)}return{[v]:y,[x]:b}}}},xG=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:a,rects:o,platform:c,elements:u}=t,{apply:f=()=>{},...h}=qa(e,t),p=await c.detectOverflow(t,h),x=Js(a),v=Qi(a),y=vr(a)==="y",{width:b,height:C}=o.floating;let E,A;x==="top"||x==="bottom"?(E=x,A=v===(await(c.isRTL==null?void 0:c.isRTL(u.floating))?"start":"end")?"left":"right"):(A=x,E=v==="end"?"top":"bottom");const S=C-p.top-p.bottom,k=b-p.left-p.right,N=Oc(C-p[E],S),T=Oc(b-p[A],k),R=!t.middlewareData.shift;let O=N,L=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(L=k),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(O=S),R&&!v){const z=Xs(p.left,0),_=Xs(p.right,0),U=Xs(p.top,0),D=Xs(p.bottom,0);y?L=b-2*(z!==0||_!==0?z+_:Xs(p.left,p.right)):O=C-2*(U!==0||D!==0?U+D:Xs(p.top,p.bottom))}await f({...t,availableWidth:L,availableHeight:O});const I=await c.getDimensions(u.floating);return b!==I.width||C!==I.height?{reset:{rects:!0}}:{}}}};function l$(e){const t=nr(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const a=Wn(e),o=a?e.offsetWidth:n,c=a?e.offsetHeight:r,u=Cp(n)!==o||Cp(r)!==c;return u&&(n=o,r=c),{width:n,height:r,$:u}}function bj(e){return xn(e)?e:e.contextElement}function wc(e){const t=bj(e);if(!Wn(t))return aa(1);const n=t.getBoundingClientRect(),{width:r,height:a,$:o}=l$(t);let c=(o?Cp(n.width):n.width)/r,u=(o?Cp(n.height):n.height)/a;return(!c||!Number.isFinite(c))&&(c=1),(!u||!Number.isFinite(u))&&(u=1),{x:c,y:u}}const yG=aa(0);function c$(e){const t=ls(e);return!Tg()||!t.visualViewport?yG:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function bG(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ls(e)?!1:t}function el(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect(),o=bj(e);let c=aa(1);t&&(r?xn(r)&&(c=wc(r)):c=wc(e));const u=bG(o,n,r)?c$(o):aa(0);let f=(a.left+u.x)/c.x,h=(a.top+u.y)/c.y,p=a.width/c.x,x=a.height/c.y;if(o){const v=ls(o),y=r&&xn(r)?ls(r):r;let b=v,C=h0(b);for(;C&&r&&y!==b;){const E=wc(C),A=C.getBoundingClientRect(),S=nr(C),k=A.left+(C.clientLeft+parseFloat(S.paddingLeft))*E.x,N=A.top+(C.clientTop+parseFloat(S.paddingTop))*E.y;f*=E.x,h*=E.y,p*=E.x,x*=E.y,f+=k,h+=N,b=ls(C),C=h0(b)}}return Ap({width:p,height:x,x:f,y:h})}function Ig(e,t){const n=Mg(e).scrollLeft;return t?t.left+n:el(ma(e)).left+n}function u$(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Ig(e,n),a=n.top+t.scrollTop;return{x:r,y:a}}function wG(e){let{elements:t,rect:n,offsetParent:r,strategy:a}=e;const o=a==="fixed",c=ma(r),u=t?Ag(t.floating):!1;if(r===c||u&&o)return n;let f={scrollLeft:0,scrollTop:0},h=aa(1);const p=aa(0),x=Wn(r);if((x||!x&&!o)&&((Xi(r)!=="body"||il(c))&&(f=Mg(r)),x)){const y=el(r);h=wc(r),p.x=y.x+r.clientLeft,p.y=y.y+r.clientTop}const v=c&&!x&&!o?u$(c,f):aa(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-f.scrollLeft*h.x+p.x+v.x,y:n.y*h.y-f.scrollTop*h.y+p.y+v.y}}function jG(e){return Array.from(e.getClientRects())}function kG(e){const t=ma(e),n=Mg(e),r=e.ownerDocument.body,a=Xs(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=Xs(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let c=-n.scrollLeft+Ig(e);const u=-n.scrollTop;return nr(r).direction==="rtl"&&(c+=Xs(t.clientWidth,r.clientWidth)-a),{width:a,height:o,x:c,y:u}}const fA=25;function NG(e,t){const n=ls(e),r=ma(e),a=n.visualViewport;let o=r.clientWidth,c=r.clientHeight,u=0,f=0;if(a){o=a.width,c=a.height;const p=Tg();(!p||p&&t==="fixed")&&(u=a.offsetLeft,f=a.offsetTop)}const h=Ig(r);if(h<=0){const p=r.ownerDocument,x=p.body,v=getComputedStyle(x),y=p.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,b=Math.abs(r.clientWidth-x.clientWidth-y);b<=fA&&(o-=b)}else h<=fA&&(o+=h);return{width:o,height:c,x:u,y:f}}function SG(e,t){const n=el(e,!0,t==="fixed"),r=n.top+e.clientTop,a=n.left+e.clientLeft,o=Wn(e)?wc(e):aa(1),c=e.clientWidth*o.x,u=e.clientHeight*o.y,f=a*o.x,h=r*o.y;return{width:c,height:u,x:f,y:h}}function hA(e,t,n){let r;if(t==="viewport")r=NG(e,n);else if(t==="document")r=kG(ma(e));else if(xn(t))r=SG(t,n);else{const a=c$(e);r={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return Ap(r)}function d$(e,t){const n=ua(e);return n===t||!xn(n)||ra(n)?!1:nr(n).position==="fixed"||d$(n,t)}function CG(e,t){const n=t.get(e);if(n)return n;let r=Oi(e,[],!1).filter(u=>xn(u)&&Xi(u)!=="body"),a=null;const o=nr(e).position==="fixed";let c=o?ua(e):e;for(;xn(c)&&!ra(c);){const u=nr(c),f=hj(c);!f&&u.position==="fixed"&&(a=null),(o?!f&&!a:!f&&u.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||il(c)&&!f&&d$(e,c))?r=r.filter(p=>p!==c):a=u,c=ua(c)}return t.set(e,r),r}function EG(e){let{element:t,boundary:n,rootBoundary:r,strategy:a}=e;const c=[...n==="clippingAncestors"?Ag(t)?[]:CG(t,this._c):[].concat(n),r],u=hA(t,c[0],a);let f=u.top,h=u.right,p=u.bottom,x=u.left;for(let v=1;v<c.length;v++){const y=hA(t,c[v],a);f=Xs(y.top,f),h=Oc(y.right,h),p=Oc(y.bottom,p),x=Xs(y.left,x)}return{width:h-x,height:p-f,x,y:f}}function AG(e){const{width:t,height:n}=l$(e);return{width:t,height:n}}function TG(e,t,n){const r=Wn(t),a=ma(t),o=n==="fixed",c=el(e,!0,o,t);let u={scrollLeft:0,scrollTop:0};const f=aa(0);function h(){f.x=Ig(a)}if(r||!r&&!o)if((Xi(t)!=="body"||il(a))&&(u=Mg(t)),r){const y=el(t,!0,o,t);f.x=y.x+t.clientLeft,f.y=y.y+t.clientTop}else a&&h();o&&!r&&a&&h();const p=a&&!r&&!o?u$(a,u):aa(0),x=c.left+u.scrollLeft-f.x-p.x,v=c.top+u.scrollTop-f.y-p.y;return{x,y:v,width:c.width,height:c.height}}function My(e){return nr(e).position==="static"}function mA(e,t){if(!Wn(e)||nr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ma(e)===n&&(n=n.ownerDocument.body),n}function f$(e,t){const n=ls(e);if(Ag(e))return n;if(!Wn(e)){let a=ua(e);for(;a&&!ra(a);){if(xn(a)&&!My(a))return a;a=ua(a)}return n}let r=mA(e,t);for(;r&&D7(r)&&My(r);)r=mA(r,t);return r&&ra(r)&&My(r)&&!hj(r)?n:r||U7(e)||n}const MG=async function(e){const t=this.getOffsetParent||f$,n=this.getDimensions,r=await n(e.floating);return{reference:TG(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function RG(e){return nr(e).direction==="rtl"}const IG={convertOffsetParentRelativeRectToViewportRelativeRect:wG,getDocumentElement:ma,getClippingRect:EG,getOffsetParent:f$,getElementRects:MG,getClientRects:jG,getDimensions:AG,getScale:wc,isElement:xn,isRTL:RG};function h$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function _G(e,t){let n=null,r;const a=ma(e);function o(){var u;clearTimeout(r),(u=n)==null||u.disconnect(),n=null}function c(u,f){u===void 0&&(u=!1),f===void 0&&(f=1),o();const h=e.getBoundingClientRect(),{left:p,top:x,width:v,height:y}=h;if(u||t(),!v||!y)return;const b=cc(x),C=cc(a.clientWidth-(p+v)),E=cc(a.clientHeight-(x+y)),A=cc(p),k={rootMargin:-b+"px "+-C+"px "+-E+"px "+-A+"px",threshold:Xs(0,Oc(1,f))||1};let N=!0;function T(R){const O=R[0].intersectionRatio;if(O!==f){if(!N)return c();O?c(!1,O):r=setTimeout(()=>{c(!1,1e-7)},1e3)}O===1&&!h$(h,e.getBoundingClientRect())&&c(),N=!1}try{n=new IntersectionObserver(T,{...k,root:a.ownerDocument})}catch{n=new IntersectionObserver(T,k)}n.observe(e)}return c(!0),o}function pA(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:a=!0,ancestorResize:o=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:f=!1}=r,h=bj(e),p=a||o?[...h?Oi(h):[],...t?Oi(t):[]]:[];p.forEach(A=>{a&&A.addEventListener("scroll",n,{passive:!0}),o&&A.addEventListener("resize",n)});const x=h&&u?_G(h,n):null;let v=-1,y=null;c&&(y=new ResizeObserver(A=>{let[S]=A;S&&S.target===h&&y&&t&&(y.unobserve(t),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var k;(k=y)==null||k.observe(t)})),n()}),h&&!f&&y.observe(h),t&&y.observe(t));let b,C=f?el(e):null;f&&E();function E(){const A=el(e);C&&!h$(C,A)&&n(),C=A,b=requestAnimationFrame(E)}return n(),()=>{var A;p.forEach(S=>{a&&S.removeEventListener("scroll",n),o&&S.removeEventListener("resize",n)}),x?.(),(A=y)==null||A.disconnect(),y=null,f&&cancelAnimationFrame(b)}}const OG=pG,$G=gG,LG=fG,PG=xG,DG=hG,zG=vG,BG=(e,t,n)=>{const r=new Map,a={platform:IG,...n},o={...a.platform,_c:r};return dG(e,t,{...a,platform:o})};var UG=typeof document<"u",FG=function(){},Wm=UG?m.useLayoutEffect:FG;function Op(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Op(e[r],t[r]))return!1;return!0}if(a=Object.keys(e),n=a.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,a[r]))return!1;for(r=n;r--!==0;){const o=a[r];if(!(o==="_owner"&&e.$$typeof)&&!Op(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function m$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function gA(e,t){const n=m$(e);return Math.round(t*n)/n}function Ry(e){const t=m.useRef(e);return Wm(()=>{t.current=e}),t}function VG(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:a,elements:{reference:o,floating:c}={},transform:u=!0,whileElementsMounted:f,open:h}=e,[p,x]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[v,y]=m.useState(r);Op(v,r)||y(r);const[b,C]=m.useState(null),[E,A]=m.useState(null),S=m.useCallback(V=>{V!==R.current&&(R.current=V,C(V))},[]),k=m.useCallback(V=>{V!==O.current&&(O.current=V,A(V))},[]),N=o||b,T=c||E,R=m.useRef(null),O=m.useRef(null),L=m.useRef(p),I=f!=null,z=Ry(f),_=Ry(a),U=Ry(h),D=m.useCallback(()=>{if(!R.current||!O.current)return;const V={placement:t,strategy:n,middleware:v};_.current&&(V.platform=_.current),BG(R.current,O.current,V).then(Y=>{const K={...Y,isPositioned:U.current!==!1};q.current&&!Op(L.current,K)&&(L.current=K,da.flushSync(()=>{x(K)}))})},[v,t,n,_,U]);Wm(()=>{h===!1&&L.current.isPositioned&&(L.current.isPositioned=!1,x(V=>({...V,isPositioned:!1})))},[h]);const q=m.useRef(!1);Wm(()=>(q.current=!0,()=>{q.current=!1}),[]),Wm(()=>{if(N&&(R.current=N),T&&(O.current=T),N&&T){if(z.current)return z.current(N,T,D);D()}},[N,T,D,z,I]);const Z=m.useMemo(()=>({reference:R,floating:O,setReference:S,setFloating:k}),[S,k]),$=m.useMemo(()=>({reference:N,floating:T}),[N,T]),G=m.useMemo(()=>{const V={position:n,left:0,top:0};if(!$.floating)return V;const Y=gA($.floating,p.x),K=gA($.floating,p.y);return u?{...V,transform:"translate("+Y+"px, "+K+"px)",...m$($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Y,top:K}},[n,u,$.floating,p.x,p.y]);return m.useMemo(()=>({...p,update:D,refs:Z,elements:$,floatingStyles:G}),[p,D,Z,$,G])}const HG=(e,t)=>{const n=OG(e);return{name:n.name,fn:n.fn,options:[e,t]}},WG=(e,t)=>{const n=$G(e);return{name:n.name,fn:n.fn,options:[e,t]}},qG=(e,t)=>({fn:zG(e).fn,options:[e,t]}),KG=(e,t)=>{const n=LG(e);return{name:n.name,fn:n.fn,options:[e,t]}},GG=(e,t)=>{const n=PG(e);return{name:n.name,fn:n.fn,options:[e,t]}},ZG=(e,t)=>{const n=DG(e);return{name:n.name,fn:n.fn,options:[e,t]}},YG={intentional:"onClick",sloppy:"onPointerDown"};function XG(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function QG(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),a=n.useState("floatingElement"),o=n.useState("referenceElement"),c=n.useState("domReferenceElement"),{onOpenChange:u,dataRef:f}=n.context,{enabled:h=!0,escapeKey:p=!0,outsidePress:x=!0,outsidePressEvent:v="sloppy",referencePress:y=!1,referencePressEvent:b="sloppy",ancestorScroll:C=!1,bubbles:E,externalTree:A}=t,S=Kc(A),k=vt(typeof x=="function"?x:()=>!1),N=typeof x=="function"?k:x,T=m.useRef(!1),{escapeKey:R,outsidePress:O}=XG(E),L=m.useRef(null),I=Br(),z=Br(),_=vt(()=>{z.clear(),f.current.insideReactTree=!1}),U=m.useRef(!1),D=m.useRef(""),q=vt(xe=>{D.current=xe.pointerType}),Z=vt(()=>{const xe=D.current,pe=xe==="pen"||!xe?"mouse":xe,te=typeof v=="function"?v():v;return typeof te=="string"?te:te[pe]}),$=vt(xe=>{if(!r||!h||!p||xe.key!=="Escape"||U.current)return;const pe=f.current.floatingContext?.nodeId,te=S?yc(S.nodesRef.current,pe):[];if(!R&&te.length>0){let ke=!0;if(te.forEach(Ne=>{Ne.context?.open&&!Ne.context.dataRef.current.__escapeKeyBubbles&&(ke=!1)}),!ke)return}const ve=vK(xe)?xe.nativeEvent:xe,he=qn(AO,ve);n.setOpen(!1,he),!R&&!he.isPropagationAllowed&&xe.stopPropagation()}),G=vt(xe=>{const pe=Z();return pe==="intentional"&&xe.type!=="click"||pe==="sloppy"&&xe.type==="click"}),V=vt(()=>{f.current.insideReactTree=!0,z.start(0,_)}),Y=vt((xe,pe=!1)=>{if(G(xe)){_();return}if(f.current.insideReactTree){_();return}if(Z()==="intentional"&&pe||typeof N=="function"&&!N(xe))return;const te=Ls(xe),ve=`[${Zd("inert")}]`,he=as(n.select("floatingElement")).querySelectorAll(ve),ke=n.context.triggerElements;if(te&&(ke.hasElement(te)||ke.hasMatchingElement(Te=>vn(Te,te))))return;let Ne=xn(te)?te:null;for(;Ne&&!ra(Ne);){const Te=ua(Ne);if(ra(Te)||!xn(Te))break;Ne=Te}if(he.length&&xn(te)&&!pK(te)&&!vn(te,n.select("floatingElement"))&&Array.from(he).every(Te=>!vn(Ne,Te)))return;if(Wn(te)&&!("touches"in xe)){const Te=ra(te),Pe=nr(te),De=/auto|scroll/,ze=Te||De.test(Pe.overflowX),$e=Te||De.test(Pe.overflowY),st=ze&&te.clientWidth>0&&te.scrollWidth>te.clientWidth,rt=$e&&te.clientHeight>0&&te.scrollHeight>te.clientHeight,Xe=Pe.direction==="rtl",dt=rt&&(Xe?xe.offsetX<=te.offsetWidth-te.clientWidth:xe.offsetX>te.clientWidth),jt=st&&xe.offsetY>te.clientHeight;if(dt||jt)return}const Fe=f.current.floatingContext?.nodeId,Ee=S&&yc(S.nodesRef.current,Fe).some(Te=>_r(xe,Te.context?.elements.floating));if(_r(xe,n.select("floatingElement"))||_r(xe,n.select("domReferenceElement"))||Ee)return;const Le=S?yc(S.nodesRef.current,Fe):[];if(Le.length>0){let Te=!0;if(Le.forEach(Pe=>{Pe.context?.open&&!Pe.context.dataRef.current.__outsidePressBubbles&&(Te=!1)}),!Te)return}n.setOpen(!1,qn(dj,xe)),_()}),K=vt(xe=>{Z()!=="sloppy"||xe.pointerType==="touch"||!n.select("open")||!h||_r(xe,n.select("floatingElement"))||_r(xe,n.select("domReferenceElement"))||Y(xe)}),P=vt(xe=>{if(Z()!=="sloppy"||!n.select("open")||!h||_r(xe,n.select("floatingElement"))||_r(xe,n.select("domReferenceElement")))return;const pe=xe.touches[0];pe&&(L.current={startTime:Date.now(),startX:pe.clientX,startY:pe.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},I.start(1e3,()=>{L.current&&(L.current.dismissOnTouchEnd=!1,L.current.dismissOnMouseDown=!1)}))}),H=vt(xe=>{const pe=Ls(xe);function te(){P(xe),pe?.removeEventListener(xe.type,te)}pe?.addEventListener(xe.type,te)}),B=vt(xe=>{const pe=T.current;if(T.current=!1,I.clear(),xe.type==="mousedown"&&L.current&&!L.current.dismissOnMouseDown)return;const te=Ls(xe);function ve(){xe.type==="pointerdown"?K(xe):Y(xe,pe),te?.removeEventListener(xe.type,ve)}te?.addEventListener(xe.type,ve)}),Q=vt(xe=>{if(Z()!=="sloppy"||!L.current||_r(xe,n.select("floatingElement"))||_r(xe,n.select("domReferenceElement")))return;const pe=xe.touches[0];if(!pe)return;const te=Math.abs(pe.clientX-L.current.startX),ve=Math.abs(pe.clientY-L.current.startY),he=Math.sqrt(te*te+ve*ve);he>5&&(L.current.dismissOnTouchEnd=!0),he>10&&(Y(xe),I.clear(),L.current=null)}),oe=vt(xe=>{const pe=Ls(xe);function te(){Q(xe),pe?.removeEventListener(xe.type,te)}pe?.addEventListener(xe.type,te)}),ne=vt(xe=>{Z()!=="sloppy"||!L.current||_r(xe,n.select("floatingElement"))||_r(xe,n.select("domReferenceElement"))||(L.current.dismissOnTouchEnd&&Y(xe),I.clear(),L.current=null)}),X=vt(xe=>{const pe=Ls(xe);function te(){ne(xe),pe?.removeEventListener(xe.type,te)}pe?.addEventListener(xe.type,te)});m.useEffect(()=>{if(!r||!h)return;f.current.__escapeKeyBubbles=R,f.current.__outsidePressBubbles=O;const xe=new _c;function pe(Ne){n.setOpen(!1,qn(I7,Ne))}function te(){xe.clear(),U.current=!0}function ve(){xe.start(Tg()?5:0,()=>{U.current=!1})}const he=as(a);he.addEventListener("pointerdown",q,!0),p&&(he.addEventListener("keydown",$),he.addEventListener("compositionstart",te),he.addEventListener("compositionend",ve)),N&&(he.addEventListener("click",B,!0),he.addEventListener("pointerdown",B,!0),he.addEventListener("touchstart",H,!0),he.addEventListener("touchmove",oe,!0),he.addEventListener("touchend",X,!0),he.addEventListener("mousedown",B,!0));let ke=[];return C&&(xn(c)&&(ke=Oi(c)),xn(a)&&(ke=ke.concat(Oi(a))),!xn(o)&&o&&o.contextElement&&(ke=ke.concat(Oi(o.contextElement)))),ke=ke.filter(Ne=>Ne!==he.defaultView?.visualViewport),ke.forEach(Ne=>{Ne.addEventListener("scroll",pe,{passive:!0})}),()=>{he.removeEventListener("pointerdown",q,!0),p&&(he.removeEventListener("keydown",$),he.removeEventListener("compositionstart",te),he.removeEventListener("compositionend",ve)),N&&(he.removeEventListener("click",B,!0),he.removeEventListener("pointerdown",B,!0),he.removeEventListener("touchstart",H,!0),he.removeEventListener("touchmove",oe,!0),he.removeEventListener("touchend",X,!0),he.removeEventListener("mousedown",B,!0)),ke.forEach(Ne=>{Ne.removeEventListener("scroll",pe)}),xe.clear()}},[f,a,o,c,p,N,r,u,C,h,R,O,$,Y,B,K,H,oe,X,q,n]),m.useEffect(_,[N,_]);const ae=m.useMemo(()=>({onKeyDown:$,...y&&{[YG[b]]:xe=>{n.setOpen(!1,qn(Np,xe.nativeEvent))},...b!=="intentional"&&{onClick(xe){n.setOpen(!1,qn(Np,xe.nativeEvent))}}}}),[$,n,y,b]),be=vt(xe=>{const pe=Ls(xe.nativeEvent);!vn(n.select("floatingElement"),pe)||xe.button!==0||(T.current=!0)}),_e=m.useMemo(()=>({onKeyDown:$,onPointerDown:be,onMouseDown:be,onMouseUp:be,onClickCapture:V,onMouseDownCapture:V,onPointerDownCapture:V,onMouseUpCapture:V,onTouchEndCapture:V,onTouchMoveCapture:V}),[$,be,V]);return m.useMemo(()=>h?{reference:ae,floating:_e,trigger:ae}:{},[h,ae,_e])}var $p=Symbol("NOT_FOUND");function JG(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function eZ(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function tZ(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${t}[${n}]`)}}var vA=e=>Array.isArray(e)?e:[e];function nZ(e){const t=Array.isArray(e[0])?e[0]:e;return tZ(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function sZ(e,t){const n=[],{length:r}=e;for(let a=0;a<r;a++)n.push(e[a].apply(null,t));return n}function rZ(e){let t;return{get(n){return t&&e(t.key,n)?t.value:$p},put(n,r){t={key:n,value:r}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function aZ(e,t){let n=[];function r(u){const f=n.findIndex(h=>t(u,h.key));if(f>-1){const h=n[f];return f>0&&(n.splice(f,1),n.unshift(h)),h.value}return $p}function a(u,f){r(u)===$p&&(n.unshift({key:u,value:f}),n.length>e&&n.pop())}function o(){return n}function c(){n=[]}return{get:r,put:a,getEntries:o,clear:c}}var iZ=(e,t)=>e===t;function oZ(e){return function(n,r){if(n===null||r===null||n.length!==r.length)return!1;const{length:a}=n;for(let o=0;o<a;o++)if(!e(n[o],r[o]))return!1;return!0}}function lZ(e,t){const n=typeof t=="object"?t:{equalityCheck:t},{equalityCheck:r=iZ,maxSize:a=1,resultEqualityCheck:o}=n,c=oZ(r);let u=0;const f=a<=1?rZ(c):aZ(a,c);function h(){let p=f.get(arguments);if(p===$p){if(p=e.apply(null,arguments),u++,o){const v=f.getEntries().find(y=>o(y.value,p));v&&(p=v.value,u!==0&&u--)}f.put(arguments,p)}return p}return h.clearCache=()=>{f.clear(),h.resetResultsCount()},h.resultsCount=()=>u,h.resetResultsCount=()=>{u=0},h}var cZ=class{constructor(e){this.value=e}deref(){return this.value}},uZ=typeof WeakRef<"u"?WeakRef:cZ,dZ=0,xA=1;function Zh(){return{s:dZ,v:void 0,o:null,p:null}}function p$(e,t={}){let n=Zh();const{resultEqualityCheck:r}=t;let a,o=0;function c(){let u=n;const{length:f}=arguments;for(let x=0,v=f;x<v;x++){const y=arguments[x];if(typeof y=="function"||typeof y=="object"&&y!==null){let b=u.o;b===null&&(u.o=b=new WeakMap);const C=b.get(y);C===void 0?(u=Zh(),b.set(y,u)):u=C}else{let b=u.p;b===null&&(u.p=b=new Map);const C=b.get(y);C===void 0?(u=Zh(),b.set(y,u)):u=C}}const h=u;let p;if(u.s===xA)p=u.v;else if(p=e.apply(null,arguments),o++,r){const x=a?.deref?.()??a;x!=null&&r(x,p)&&(p=x,o!==0&&o--),a=typeof p=="object"&&p!==null||typeof p=="function"?new uZ(p):p}return h.s=xA,h.v=p,p}return c.clearCache=()=>{n=Zh(),c.resetResultsCount()},c.resultsCount=()=>o,c.resetResultsCount=()=>{o=0},c}function g$(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,r=(...a)=>{let o=0,c=0,u,f={},h=a.pop();typeof h=="object"&&(f=h,h=a.pop()),JG(h,`createSelector expects an output function after the inputs, but received: [${typeof h}]`);const p={...n,...f},{memoize:x,memoizeOptions:v=[],argsMemoize:y=p$,argsMemoizeOptions:b=[]}=p,C=vA(v),E=vA(b),A=nZ(a),S=x(function(){return o++,h.apply(null,arguments)},...C),k=y(function(){c++;const T=sZ(A,arguments);return u=S.apply(null,T),u},...E);return Object.assign(k,{resultFunc:h,memoizedResultFunc:S,dependencies:A,dependencyRecomputations:()=>c,resetDependencyRecomputations:()=>{c=0},lastResult:()=>u,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:x,argsMemoize:y})};return Object.assign(r,{withTypes:()=>r}),r}var fZ=g$(p$),hZ=Object.assign((e,t=fZ)=>{eZ(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);const n=Object.keys(e),r=n.map(o=>e[o]);return t(r,(...o)=>o.reduce((c,u,f)=>(c[n[f]]=u,c),{}))},{withTypes:()=>hZ});g$({memoize:lZ,memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const Mt=(e,t,n,r,a,o,...c)=>{if(c.length>0)throw new Error(al(1));let u;if(e)u=e;else throw new Error("Missing arguments");return u};var Iy={exports:{}},_y={};var yA;function mZ(){if(yA)return _y;yA=1;var e=uf(),t=pO();function n(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var r=typeof Object.is=="function"?Object.is:n,a=t.useSyncExternalStore,o=e.useRef,c=e.useEffect,u=e.useMemo,f=e.useDebugValue;return _y.useSyncExternalStoreWithSelector=function(h,p,x,v,y){var b=o(null);if(b.current===null){var C={hasValue:!1,value:null};b.current=C}else C=b.current;b=u(function(){function A(R){if(!S){if(S=!0,k=R,R=v(R),y!==void 0&&C.hasValue){var O=C.value;if(y(O,R))return N=O}return N=R}if(O=N,r(k,R))return O;var L=v(R);return y!==void 0&&y(O,L)?(k=R,O):(k=R,N=L)}var S=!1,k,N,T=x===void 0?null:x;return[function(){return A(p())},T===null?void 0:function(){return A(T())}]},[p,x,v,y]);var E=a(h,b[0],b[1]);return c(function(){C.hasValue=!0,C.value=E},[E]),f(E),E},_y}var bA;function pZ(){return bA||(bA=1,Iy.exports=mZ()),Iy.exports}var gZ=pZ();const vZ=cj(19),xZ=vZ?bZ:wZ;function yZ(e,t,n,r,a){return xZ(e,t,n,r,a)}function bZ(e,t,n,r,a){const o=m.useCallback(()=>t(e.getSnapshot(),n,r,a),[e,t,n,r,a]);return _q.useSyncExternalStore(e.subscribe,o,o)}function wZ(e,t,n,r,a){return gZ.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,o=>t(o,n,r,a))}class Cd{constructor(t){this.state=t,this.listeners=new Set,this.updateTick=0}subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});getSnapshot=()=>this.state;setState(t){if(this.state===t)return;this.state=t,this.updateTick+=1;const n=this.updateTick;for(const r of this.listeners){if(n!==this.updateTick)return;r(t)}}update(t){for(const n in t)if(!Object.is(this.state[n],t[n])){Cd.prototype.setState.call(this,{...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||Cd.prototype.setState.call(this,{...this.state,[t]:n})}notifyAll(){const t={...this.state};Cd.prototype.setState.call(this,t)}}class v$ extends Cd{constructor(t,n={},r){super(t),this.context=n,this.selectors=r}controlledValues=new Map;useSyncedValue(t,n){m.useDebugValue(t),pt(()=>{this.state[t]!==n&&this.set(t,n)},[t,n])}useSyncedValueWithCleanup(t,n){pt(()=>(this.state[t]!==n&&this.set(t,n),()=>{this.set(t,void 0)}),[t,n])}useSyncedValues(t){const n=Object.values(t);pt(()=>{this.update(t)},n)}useControlledProp(t,n,r){m.useDebugValue(t);const a=n!==void 0;this.controlledValues.has(t)||(this.controlledValues.set(t,a),!a&&!Object.is(this.state[t],r)&&super.setState({...this.state,[t]:r})),pt(()=>{a&&!Object.is(this.state[t],n)&&super.setState({...this.state,[t]:n})},[t,n,r,a])}set(t,n){this.controlledValues.get(t)!==!0&&super.set(t,n)}update(t){const n={...t};for(const r in n)if(Object.hasOwn(n,r)&&this.controlledValues.get(r)===!0){delete n[r];continue}super.update(n)}setState(t){const n={...t};for(const r in n)if(Object.hasOwn(n,r)&&this.controlledValues.get(r)===!0){delete n[r];continue}super.setState({...this.state,...n})}select=(t,n,r,a)=>{const o=this.selectors[t];return o(this.state,n,r,a)};useState=(t,n,r,a)=>{m.useDebugValue(t);const o=this.selectors[t];return yZ(this,o,n,r,a)};useContextCallback(t,n){m.useDebugValue(t);const r=vt(n??NO);this.context[t]=r}useStateSetter(t){const n=m.useRef(void 0);return n.current===void 0&&(n.current=r=>{this.set(t,r)}),n.current}observe(t,n){let r;typeof t=="function"?r=t:r=this.selectors[t];let a=r(this.state);return n(a,a,this),this.subscribe(o=>{const c=r(o);if(!Object.is(a,c)){const u=a;a=c,n(c,u,this)}})}}const jZ={open:Mt(e=>e.open),domReferenceElement:Mt(e=>e.domReferenceElement),referenceElement:Mt(e=>e.positionReference??e.referenceElement),floatingElement:Mt(e=>e.floatingElement),floatingId:Mt(e=>e.floatingId)};class wj extends v${constructor(t){const{nested:n,noEmit:r,onOpenChange:a,triggerElements:o,...c}=t;super({...c,positionReference:c.referenceElement,domReferenceElement:c.referenceElement},{onOpenChange:a,dataRef:{current:{}},events:JO(),nested:n,noEmit:r,triggerElements:o},jZ)}setOpen=(t,n)=>{if((!t||!this.state.open||yK(n.event))&&(this.context.dataRef.current.openEvent=t?n.event:void 0),!this.context.noEmit){const r={open:t,reason:n.reason,nativeEvent:n.event,nested:this.context.nested,triggerElement:n.trigger};this.context.events.emit("openchange",r)}this.context.onOpenChange?.(t,n)}}function kZ(e){const t=e.useState("open");pt(()=>{if(t&&!e.select("activeTriggerId")&&e.context.triggerElements.size===1){const n=e.context.triggerElements.entries().next();if(!n.done){const[r,a]=n.value;e.update({activeTriggerId:r,activeTriggerElement:a})}}},[t,e])}function NZ(e,t,n){const{mounted:r,setMounted:a,transitionStatus:o}=tK(e);t.useSyncedValues({mounted:r,transitionStatus:o});const c=vt(()=>{a(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}),u=t.useState("preventUnmountingOnClose");return _O({enabled:!u,open:e,ref:t.context.popupRef,onComplete(){e||c()}}),{forceUnmount:c,transitionStatus:o}}class jj{constructor(){this.elements=new Set,this.idMap=new Map}add(t,n){const r=this.idMap.get(t);r!==n&&(r!==void 0&&this.elements.delete(r),this.elements.add(n),this.idMap.set(t,n))}delete(t){const n=this.idMap.get(t);n&&(this.elements.delete(n),this.idMap.delete(t))}hasElement(t){return this.elements.has(t)}hasMatchingElement(t){for(const n of this.elements)if(t(n))return!0;return!1}getById(t){return this.idMap.get(t)}entries(){return this.idMap.entries()}get size(){return this.idMap.size}}function SZ(){return new wj({open:!1,floatingElement:null,referenceElement:null,triggerElements:new jj,floatingId:"",nested:!1,noEmit:!1,onOpenChange:void 0})}function CZ(){return{open:!1,mounted:!1,transitionStatus:"idle",floatingRootContext:SZ(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,popupElement:null,positionerElement:null,activeTriggerProps:Ps,inactiveTriggerProps:Ps,popupProps:Ps}}const EZ={open:Mt(e=>e.open),mounted:Mt(e=>e.mounted),transitionStatus:Mt(e=>e.transitionStatus),floatingRootContext:Mt(e=>e.floatingRootContext),preventUnmountingOnClose:Mt(e=>e.preventUnmountingOnClose),payload:Mt(e=>e.payload),activeTriggerId:Mt(e=>e.activeTriggerId),activeTriggerElement:Mt(e=>e.mounted?e.activeTriggerElement:null),isTriggerActive:Mt((e,t)=>t!==void 0&&e.activeTriggerId===t),isOpenedByTrigger:Mt((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.open),isMountedByTrigger:Mt((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.mounted),triggerProps:Mt((e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps),popupProps:Mt(e=>e.popupProps),popupElement:Mt(e=>e.popupElement),positionerElement:Mt(e=>e.positionerElement)};function AZ(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,a=Zi(),o=Ji()!=null,c=Nr(()=>new wj({open:t,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:r.triggers??new jj,floatingId:a,nested:o,noEmit:e.noEmit||!1})).current;return pt(()=>{const u={open:t,floatingId:a};r.reference!==void 0&&(u.referenceElement=r.reference,u.domReferenceElement=xn(r.reference)?r.reference:null),r.floating!==void 0&&(u.floatingElement=r.floating),c.update(u)},[t,a,r.reference,r.floating,c]),c.context.onOpenChange=n,c.context.nested=o,c.context.noEmit=e.noEmit||!1,c}function TZ(e={}){const{nodeId:t,externalTree:n}=e,r=AZ(e),a=e.rootContext||r,o={reference:a.useState("referenceElement"),floating:a.useState("floatingElement"),domReference:a.useState("domReferenceElement")},[c,u]=m.useState(null),f=m.useRef(null),h=Kc(n);pt(()=>{o.domReference&&(f.current=o.domReference)},[o.domReference]);const p=VG({...e,elements:{...o,...c&&{reference:c}}}),x=m.useCallback(O=>{const L=xn(O)?{getBoundingClientRect:()=>O.getBoundingClientRect(),getClientRects:()=>O.getClientRects(),contextElement:O}:O;u(L),p.refs.setReference(L)},[p.refs]),[v,y]=m.useState(null),[b,C]=m.useState(null);a.useSyncedValue("referenceElement",v),a.useSyncedValue("domReferenceElement",xn(v)?v:null),a.useSyncedValue("floatingElement",b);const E=m.useCallback(O=>{(xn(O)||O===null)&&(f.current=O,y(O)),(xn(p.refs.reference.current)||p.refs.reference.current===null||O!==null&&!xn(O))&&p.refs.setReference(O)},[p.refs,y]),A=m.useCallback(O=>{C(O),p.refs.setFloating(O)},[p.refs]),S=m.useMemo(()=>({...p.refs,setReference:E,setFloating:A,setPositionReference:x,domReference:f}),[p.refs,E,A,x]),k=m.useMemo(()=>({...p.elements,domReference:o.domReference}),[p.elements,o.domReference]),N=a.useState("open"),T=a.useState("floatingId"),R=m.useMemo(()=>({...p,dataRef:a.context.dataRef,open:N,onOpenChange:a.setOpen,events:a.context.events,floatingId:T,refs:S,elements:k,nodeId:t,rootStore:a}),[p,S,k,t,a,N,T]);return pt(()=>{a.context.dataRef.current.floatingContext=R;const O=h?.nodesRef.current.find(L=>L.id===t);O&&(O.context=R)}),m.useMemo(()=>({...p,context:R,refs:S,elements:k,rootStore:a}),[p,S,k,R,a])}function MZ(e){const{popupStore:t,noEmit:n=!1,treatPopupAsFloatingElement:r=!1,onOpenChange:a}=e,o=Zi(),c=Ji()!=null,u=t.useState("open"),f=t.useState("activeTriggerElement"),h=t.useState(r?"popupElement":"positionerElement"),p=t.context.triggerElements,x=Nr(()=>new wj({open:u,referenceElement:f,floatingElement:h,triggerElements:p,onOpenChange:a,floatingId:o,nested:c,noEmit:n})).current;return pt(()=>{const v={open:u,floatingId:o,referenceElement:f,floatingElement:h};xn(f)&&(v.domReferenceElement=f),x.update(v)},[u,o,f,h,x]),x.context.onOpenChange=a,x.context.nested=c,x.context.noEmit=n,x}const wA=Zd("safe-polygon"),RZ=`button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${zO}`;function IZ(e){return e?!!e.closest(RZ):!1}function _Z(e){const t=m.useRef(void 0),n=m.useRef(!1),r=m.useRef(void 0),a=m.useRef(!0),o=m.useRef(!1),c=m.useRef(()=>{}),u=m.useRef(!1),f=Br(),h=Br(),p=m.useRef(void 0);return m.useMemo(()=>{const x=e.context.dataRef.current;return x.hoverInteractionState||(x.hoverInteractionState={pointerTypeRef:t,interactedInsideRef:n,handlerRef:r,blockMouseMoveRef:a,performedPointerEventsMutationRef:o,unbindMouseMoveRef:c,restTimeoutPendingRef:u,openChangeTimeout:f,restTimeout:h,handleCloseOptionsRef:p}),x.hoverInteractionState},[e,t,n,r,a,o,c,u,f,h,p])}const OZ=new Set(["click","mousedown"]);function $Z(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),a=n.useState("floatingElement"),o=n.useState("domReferenceElement"),{dataRef:c}=n.context,{enabled:u=!0,closeDelay:f=0,externalTree:h}=t,{pointerTypeRef:p,interactedInsideRef:x,handlerRef:v,performedPointerEventsMutationRef:y,unbindMouseMoveRef:b,restTimeoutPendingRef:C,openChangeTimeout:E,handleCloseOptionsRef:A}=_Z(n),S=Kc(h),k=Ji(),N=vt(()=>x.current?!0:c.current.openEvent?OZ.has(c.current.openEvent.type):!1),T=vt(()=>{const z=c.current.openEvent?.type;return z?.includes("mouse")&&z!=="mousedown"}),R=m.useCallback((z,_=!0)=>{const U=LZ(f,p.current);U&&!v.current?E.start(U,()=>n.setOpen(!1,qn(Vo,z))):_&&(E.clear(),n.setOpen(!1,qn(Vo,z)))},[f,v,n,p,E]),O=vt(()=>{b.current(),v.current=void 0}),L=vt(()=>{if(y.current){const z=as(a).body;z.style.pointerEvents="",z.removeAttribute(wA),y.current=!1}}),I=vt(z=>{const _=Ls(z);if(!IZ(_)){x.current=!1;return}x.current=!0});pt(()=>{r||(p.current=void 0,C.current=!1,x.current=!1,O(),L())},[r,p,C,x,O,L]),m.useEffect(()=>()=>{O()},[O]),m.useEffect(()=>L,[L]),pt(()=>{if(u&&r&&A.current?.blockPointerEvents&&T()&&xn(o)&&a){y.current=!0;const z=as(a).body;z.setAttribute(wA,"");const _=o,U=a,D=S?.nodesRef.current.find(q=>q.id===k)?.context?.elements.floating;return D&&(D.style.pointerEvents=""),z.style.pointerEvents="none",_.style.pointerEvents="auto",U.style.pointerEvents="auto",()=>{z.style.pointerEvents="",_.style.pointerEvents="",U.style.pointerEvents=""}}},[u,r,o,a,A,T,S,k,y]),m.useEffect(()=>{if(!u)return;function z(q){if(N()||!c.current.floatingContext)return;const Z=n.context.triggerElements;q.relatedTarget&&Z.hasElement(q.relatedTarget)||(L(),O(),N()||R(q))}function _(q){E.clear(),L(),v.current?.(q),O()}function U(q){N()||R(q,!1)}const D=a;return D&&(D.addEventListener("mouseleave",z),D.addEventListener("mouseenter",_),D.addEventListener("mouseleave",U),D.addEventListener("pointerdown",I,!0)),()=>{D&&(D.removeEventListener("mouseleave",z),D.removeEventListener("mouseenter",_),D.removeEventListener("mouseleave",U),D.removeEventListener("pointerdown",I,!0))}})}function LZ(e,t){return t&&!xK(t)?0:typeof e=="function"?e():e}function PZ(e=[]){const t=e.map(h=>h?.reference),n=e.map(h=>h?.floating),r=e.map(h=>h?.item),a=e.map(h=>h?.trigger),o=m.useCallback(h=>Yh(h,e,"reference"),t),c=m.useCallback(h=>Yh(h,e,"floating"),n),u=m.useCallback(h=>Yh(h,e,"item"),r),f=m.useCallback(h=>Yh(h,e,"trigger"),a);return m.useMemo(()=>({getReferenceProps:o,getFloatingProps:c,getItemProps:u,getTriggerProps:f}),[o,c,u,f])}function Yh(e,t,n){const r=new Map,a=n==="item",o={};n==="floating"&&(o.tabIndex=-1,o[p0]="");for(const c in e)a&&e&&(c===PO||c===DO)||(o[c]=e[c]);for(let c=0;c<t.length;c+=1){let u;const f=t[c]?.[n];typeof f=="function"?u=e?f(e):null:u=f,u&&jA(o,u,a,r)}return jA(o,e,a,r),o}function jA(e,t,n,r){for(const a in t){const o=t[a];n&&(a===PO||a===DO)||(a.startsWith("on")?(r.has(a)||r.set(a,[]),typeof o=="function"&&(r.get(a)?.push(o),e[a]=(...c)=>r.get(a)?.map(u=>u(...c)).find(u=>u!==void 0))):e[a]=o)}}const DZ="Escape";function _g(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Xh(e,t){return _g(t,e===pj||e===mf,e===$i||e===Li)}function Oy(e,t,n){return _g(t,e===mf,n?e===$i:e===Li)||e==="Enter"||e===" "||e===""}function zZ(e,t,n){return _g(t,n?e===$i:e===Li,e===mf)}function BZ(e,t,n,r){const a=n?e===Li:e===$i,o=e===pj;return t==="both"||t==="horizontal"&&r&&r>1?e===DZ:_g(t,a,o)}function UZ(e,t){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),a=n.useState("floatingElement"),o=n.useState("domReferenceElement"),c=n.context.dataRef,{listRef:u,activeIndex:f,onNavigate:h=()=>{},enabled:p=!0,selectedIndex:x=null,allowEscape:v=!1,loopFocus:y=!1,nested:b=!1,rtl:C=!1,virtual:E=!1,focusItemOnOpen:A="auto",focusItemOnHover:S=!0,openOnArrowKeyDown:k=!0,disabledIndices:N=void 0,orientation:T="vertical",parentOrientation:R,cols:O=1,scrollItemIntoView:L=!0,itemSizes:I,dense:z=!1,id:_,resetOnPointerLeave:U=!0,externalTree:D}=t,q=Sp(a),Z=$s(q),$=Ji(),G=Kc(D);pt(()=>{c.current.orientation=T},[c,T]);const V=g0(o),Y=m.useRef(A),K=m.useRef(x??-1),P=m.useRef(null),H=m.useRef(!0),B=vt(De=>{h(K.current===-1?null:K.current,De)}),Q=m.useRef(B),oe=m.useRef(!!a),ne=m.useRef(r),X=m.useRef(!1),ae=m.useRef(!1),be=$s(N),_e=$s(r),xe=$s(L),pe=$s(x),te=$s(U),ve=vt(()=>{function De(rt){E?G?.events.emit("virtualfocus",rt):Hm(rt,{sync:X.current,preventScroll:!0})}const ze=u.current[K.current],$e=ae.current;ze&&De(ze),(X.current?rt=>rt():requestAnimationFrame)(()=>{const rt=u.current[K.current]||ze;if(!rt)return;ze||De(rt);const Xe=xe.current;Xe&&ke&&($e||!H.current)&&rt.scrollIntoView?.(typeof Xe=="boolean"?{block:"nearest",inline:"nearest"}:Xe)})});pt(()=>{p&&(r&&a?(K.current=x??-1,Y.current&&x!=null&&(ae.current=!0,B())):oe.current&&(K.current=-1,Q.current()))},[p,r,a,x,B]),pt(()=>{if(p){if(!r){X.current=!1;return}if(a)if(f==null){if(X.current=!1,pe.current!=null)return;if(oe.current&&(K.current=-1,ve()),(!ne.current||!oe.current)&&Y.current&&(P.current!=null||Y.current===!0&&P.current==null)){let De=0;const ze=()=>{u.current[0]==null?(De<2&&(De?requestAnimationFrame:queueMicrotask)(ze),De+=1):(K.current=P.current==null||Oy(P.current,T,C)||b?Ey(u):nA(u),P.current=null,B())};ze()}}else kd(u,f)||(K.current=f,ve(),ae.current=!1)}},[p,r,a,f,pe,b,u,T,C,B,ve,be]),pt(()=>{if(!p||a||!G||E||!oe.current)return;const De=G.nodesRef.current,ze=De.find(rt=>rt.id===$)?.context?.elements.floating,$e=Ci(as(a)),st=De.some(rt=>rt.context&&vn(rt.context.elements.floating,$e));ze&&!st&&H.current&&ze.focus({preventScroll:!0})},[p,a,G,$,E]),pt(()=>{Q.current=B,ne.current=r,oe.current=!!a}),pt(()=>{r||(P.current=null,Y.current=A)},[r,A]);const he=f!=null,ke=m.useMemo(()=>{function De($e){if(!_e.current)return;const st=u.current.indexOf($e.currentTarget);st!==-1&&K.current!==st&&(K.current=st,B($e))}return{onFocus($e){X.current=!0,De($e)},onClick:({currentTarget:$e})=>$e.focus({preventScroll:!0}),onMouseMove($e){X.current=!0,ae.current=!1,S&&De($e)},onPointerLeave($e){if(!_e.current||!H.current||$e.pointerType==="touch")return;X.current=!0;const st=$e.relatedTarget;!S||u.current.includes(st)||te.current&&(K.current=-1,B($e),E||Z.current?.focus({preventScroll:!0}))}}},[_e,Z,S,u,B,te,E]),Ne=m.useCallback(()=>R??G?.nodesRef.current.find(De=>De.id===$)?.context?.dataRef?.current.orientation,[$,G,R]),Fe=vt(De=>{if(H.current=!1,X.current=!0,De.which===229||!_e.current&&De.currentTarget===Z.current)return;if(b&&BZ(De.key,T,C,O)){Xh(De.key,Ne())||is(De),n.setOpen(!1,qn(Vm,De.nativeEvent)),Wn(o)&&(E?G?.events.emit("virtualfocus",o):o.focus());return}const ze=K.current,$e=Ey(u,N),st=nA(u,N);if(V||(De.key==="Home"&&(is(De),K.current=$e,B(De)),De.key==="End"&&(is(De),K.current=st,B(De))),O>1){const rt=I||Array.from({length:u.current.length},()=>({width:1,height:1})),Xe=MK(rt,O,z),dt=Xe.findIndex(mt=>mt!=null&&!Nd(u,mt,N)),jt=Xe.reduce((mt,Ht,ie)=>Ht!=null&&!Nd(u,Ht,N)?ie:mt,-1),At=Xe[TK({current:Xe.map(mt=>mt!=null?u.current[mt]:null)},{event:De,orientation:T,loopFocus:y,rtl:C,cols:O,disabledIndices:IK([...(typeof N!="function"?N:null)||u.current.map((mt,Ht)=>Nd(u,Ht,N)?Ht:void 0),void 0],Xe),minIndex:dt,maxIndex:jt,prevIndex:RK(K.current>st?$e:K.current,rt,Xe,O,De.key===mf?"bl":De.key===(C?$i:Li)?"tr":"tl"),stopEvent:!0})];if(At!=null&&(K.current=At,B(De)),T==="both")return}if(Xh(De.key,T)){if(is(De),r&&!E&&Ci(De.currentTarget.ownerDocument)===De.currentTarget){K.current=Oy(De.key,T,C)?$e:st,B(De);return}Oy(De.key,T,C)?y?ze>=st?v&&ze!==u.current.length?K.current=-1:(X.current=!1,K.current=$e):K.current=fs(u,{startingIndex:ze,disabledIndices:N}):K.current=Math.min(st,fs(u,{startingIndex:ze,disabledIndices:N})):y?ze<=$e?v&&ze!==-1?K.current=u.current.length:(X.current=!1,K.current=st):K.current=fs(u,{startingIndex:ze,decrement:!0,disabledIndices:N}):K.current=Math.max($e,fs(u,{startingIndex:ze,decrement:!0,disabledIndices:N})),kd(u,K.current)&&(K.current=-1),B(De)}}),Ee=m.useMemo(()=>E&&r&&he&&{"aria-activedescendant":`${_}-${f}`},[E,r,he,_,f]),Le=m.useMemo(()=>({"aria-orientation":T==="both"?void 0:T,...V?{}:Ee,onKeyDown(De){if(De.key==="Tab"&&De.shiftKey&&r&&!E){const ze=Ls(De.nativeEvent);if(ze&&!vn(Z.current,ze))return;is(De),n.setOpen(!1,qn(Cg,De.nativeEvent)),Wn(o)&&o.focus();return}Fe(De)},onPointerMove(){H.current=!0}}),[Ee,Fe,Z,T,V,n,r,E,o]),Te=m.useMemo(()=>{function De($e){A==="auto"&&BO($e.nativeEvent)&&(Y.current=!E)}function ze($e){Y.current=A,A==="auto"&&UO($e.nativeEvent)&&(Y.current=!0)}return{onKeyDown($e){const st=n.select("open");H.current=!1;const rt=$e.key.startsWith("Arrow"),Xe=zZ($e.key,Ne(),C),dt=Xh($e.key,T),jt=(b?Xe:dt)||$e.key==="Enter"||$e.key.trim()==="";if(E&&st)return Fe($e);if(!(!st&&!k&&rt)){if(jt){const At=Xh($e.key,Ne());P.current=b&&At?null:$e.key}if(b){Xe&&(is($e),st?(K.current=Ey(u,be.current),B($e)):n.setOpen(!0,qn(Vm,$e.nativeEvent,$e.currentTarget)));return}dt&&(pe.current!=null&&(K.current=pe.current),is($e),!st&&k?n.setOpen(!0,qn(Vm,$e.nativeEvent,$e.currentTarget)):Fe($e),st&&B($e))}},onFocus($e){n.select("open")&&!E&&(K.current=-1,B($e))},onPointerDown:ze,onPointerEnter:ze,onMouseDown:De,onClick:De}},[Fe,be,A,u,b,B,n,k,T,Ne,C,pe,E]),Pe=m.useMemo(()=>({...Ee,...Te}),[Ee,Te]);return m.useMemo(()=>p?{reference:Pe,floating:Le,item:ke,trigger:Te}:{},[p,Pe,Le,Te,ke])}const FZ=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function VZ(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),a=n.useState("floatingId"),o=n.useState("domReferenceElement"),c=n.useState("floatingElement"),{enabled:u=!0,role:f="dialog"}=t,h=Zi(),p=o?.id||h,x=m.useMemo(()=>Sp(c)?.id||a,[c,a]),v=FZ.get(f)??f,b=Ji()!=null,C=m.useMemo(()=>v==="tooltip"||f==="label"?Ps:{"aria-haspopup":v==="alertdialog"?"dialog":v,"aria-expanded":"false",...v==="listbox"&&{role:"combobox"},...v==="menu"&&b&&{role:"menuitem"},...f==="select"&&{"aria-autocomplete":"none"},...f==="combobox"&&{"aria-autocomplete":"list"}},[v,b,f]),E=m.useMemo(()=>v==="tooltip"||f==="label"?{[`aria-${f==="label"?"labelledby":"describedby"}`]:r?x:void 0}:{...C,"aria-expanded":r?"true":"false","aria-controls":r?x:void 0,...v==="menu"&&{id:p}},[v,x,r,p,f,C]),A=m.useMemo(()=>{const k={id:x,...v&&{role:v}};return v==="tooltip"||f==="label"?k:{...k,...v==="menu"&&{"aria-labelledby":p}}},[v,x,p,f]),S=m.useCallback(({active:k,selected:N})=>{const T={role:"option",...k&&{id:`${x}-fui-option`}};switch(f){case"select":case"combobox":return{...T,"aria-selected":N}}return{}},[x,f]);return m.useMemo(()=>u?{reference:E,floating:A,item:S,trigger:C}:{},[u,E,A,C,S])}function HZ(e,t){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),a=n.context.dataRef,{listRef:o,activeIndex:c,onMatch:u,onTypingChange:f,enabled:h=!0,findMatch:p=null,resetMs:x=750,ignoreKeys:v=SO,selectedIndex:y=null}=t,b=Br(),C=m.useRef(""),E=m.useRef(y??c??-1),A=m.useRef(null);pt(()=>{r&&(b.clear(),A.current=null,C.current="")},[r,b]),pt(()=>{r&&C.current===""&&(E.current=y??c??-1)},[r,y,c]);const S=vt(R=>{R?a.current.typing||(a.current.typing=R,f?.(R)):a.current.typing&&(a.current.typing=R,f?.(R))}),k=vt(R=>{function O(U,D,q){const Z=p?p(D,q):D.find($=>$?.toLocaleLowerCase().indexOf(q.toLocaleLowerCase())===0);return Z?U.indexOf(Z):-1}const L=o.current;if(C.current.length>0&&C.current[0]!==" "&&(O(L,L,C.current)===-1?S(!1):R.key===" "&&is(R)),L==null||v.includes(R.key)||R.key.length!==1||R.ctrlKey||R.metaKey||R.altKey)return;r&&R.key!==" "&&(is(R),S(!0)),L.every(U=>U?U[0]?.toLocaleLowerCase()!==U[1]?.toLocaleLowerCase():!0)&&C.current===R.key&&(C.current="",E.current=A.current),C.current+=R.key,b.start(x,()=>{C.current="",E.current=A.current,S(!1)});const z=E.current,_=O(L,[...L.slice((z||0)+1),...L.slice(0,(z||0)+1)],C.current);_!==-1?(u?.(_),A.current=_):R.key!==" "&&(C.current="",S(!1))}),N=m.useMemo(()=>({onKeyDown:k}),[k]),T=m.useMemo(()=>({onKeyDown:k,onKeyUp(R){R.key===" "&&S(!1)}}),[k,S]);return m.useMemo(()=>h?{reference:N,floating:T}:{},[h,N,T])}const WZ=m.createContext(void 0);function qZ(e){return m.useContext(WZ)}const x$="ArrowUp",y$="ArrowDown",b$="ArrowLeft",w$="ArrowRight",j$="Home",k$="End",KZ=new Set([b$,w$]),GZ=new Set([x$,y$]),ZZ=new Set([...KZ,...GZ]);[...ZZ];const YZ=new Set([x$,y$,b$,w$,j$,k$]);function XZ(e){return e==="starting"?v7:Ps}const QZ={...CO,...C7},JZ=m.forwardRef(function(t,n){const{render:r,className:a,finalFocus:o,...c}=t,{store:u}=Wc(),{side:f,align:h}=yO(),p=qZ()!=null,x=u.useState("open"),v=u.useState("transitionStatus"),y=u.useState("popupProps"),b=u.useState("mounted"),C=u.useState("instantType"),E=u.useState("activeTriggerElement"),A=u.useState("parent"),S=u.useState("lastOpenChangeReason"),k=u.useState("rootId"),N=u.useState("floatingRootContext"),T=u.useState("floatingTreeRoot"),R=u.useState("closeDelay"),O=u.useState("activeTriggerElement");_O({open:x,ref:u.context.popupRef,onComplete(){x&&u.context.onOpenChangeComplete?.(!0)}}),m.useEffect(()=>{function D(q){u.setOpen(!1,qn(q.reason,q.domEvent))}return T.events.on("close",D),()=>{T.events.off("close",D)}},[T.events,u]);const L=u.useState("hoverEnabled"),I=u.useState("disabled");$Z(N,{enabled:L&&!I&&A.type!=="context-menu"&&A.type!=="menubar",closeDelay:R});const z=m.useMemo(()=>({transitionStatus:v,side:f,align:h,open:x,nested:A.type==="menu",instant:C}),[v,f,h,x,A.type,C]),_=Yi("div",t,{state:z,ref:[n,u.context.popupRef],stateAttributesMapping:QZ,props:[y,{onKeyDown(D){p&&YZ.has(D.key)&&D.stopPropagation()}},XZ(v),c,{"data-rootownerid":k}]});let U=A.type===void 0||A.type==="context-menu";return(E||A.type==="menubar"&&S!==dj)&&(U=!0),s.jsx(lG,{context:N,modal:!1,disabled:!b,returnFocus:o===void 0?U:o,initialFocus:A.type!=="menu",restoreFocus:!0,externalTree:A.type!=="menubar"?T:void 0,previousFocusableElement:O,nextFocusableElement:A.type===void 0?u.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:A.type===void 0?u.context.beforeContentFocusGuardRef:void 0,children:_})}),N$=m.createContext(void 0);function eY(){const e=m.useContext(N$);if(e===void 0)throw new Error(al(32));return e}const tY=m.forwardRef(function(t,n){const{keepMounted:r=!1,...a}=t,{store:o}=Wc();return o.useState("mounted")||r?s.jsx(N$.Provider,{value:r,children:s.jsx(sG,{ref:n,...a})}):null});function nY(e){return cj(19)?e:e?"true":void 0}const sY=m.createContext(void 0);function S$(){return m.useContext(sY)?.direction??"ltr"}const rY=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:a,rects:o,platform:c,elements:u,middlewareData:f}=t,{element:h,padding:p=0,offsetParent:x="real"}=qa(e,t)||{};if(h==null)return{};const v=FO(p),y={x:n,y:r},b=xj(a),C=vj(b),E=await c.getDimensions(h),A=b==="y",S=A?"top":"left",k=A?"bottom":"right",N=A?"clientHeight":"clientWidth",T=o.reference[C]+o.reference[b]-y[b]-o.floating[C],R=y[b]-o.reference[b],O=x==="real"?await c.getOffsetParent?.(h):u.floating;let L=u.floating[N]||o.floating[C];(!L||!await c.isElement?.(O))&&(L=u.floating[N]||o.floating[C]);const I=T/2-R/2,z=L/2-E[C]/2-1,_=Math.min(v[S],z),U=Math.min(v[k],z),D=_,q=L-E[C]-U,Z=L/2-E[C]/2+I,$=v0(D,Z,q),G=!f.arrow&&Qi(a)!=null&&Z!==$&&o.reference[C]/2-(Z<D?_:U)-E[C]/2<0,V=G?Z<D?Z-D:Z-q:0;return{[b]:y[b]+V,data:{[b]:$,centerOffset:Z-$-V,...G&&{alignmentOffset:V}},reset:G}}}),aY=(e,t)=>({...rY(e),options:[e,t]}),iY={name:"hide",async fn(e){const{width:t,height:n,x:r,y:a}=e.rects.reference,o=t===0&&n===0&&r===0&&a===0;return{data:{referenceHidden:(await ZG().fn(e)).data?.referenceHidden||o}}}},oY={sideX:"left",sideY:"top"};function C$(e,t,n){const r=e==="inline-start"||e==="inline-end";return{top:"top",right:r?n?"inline-start":"inline-end":"right",bottom:"bottom",left:r?n?"inline-end":"inline-start":"left"}[t]}function kA(e,t,n){const{rects:r,placement:a}=e;return{side:C$(t,Js(a),n),align:Qi(a)||"center",anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function lY(e){const{anchor:t,positionMethod:n="absolute",side:r="bottom",sideOffset:a=0,align:o="center",alignOffset:c=0,collisionBoundary:u,collisionPadding:f=5,sticky:h=!1,arrowPadding:p=5,disableAnchorTracking:x=!1,keepMounted:v=!1,floatingRootContext:y,mounted:b,collisionAvoidance:C,shiftCrossAxis:E=!1,nodeId:A,adaptiveOrigin:S,lazyFlip:k=!1,externalTree:N}=e,[T,R]=m.useState(null);!b&&T!==null&&R(null);const O=C.side||"flip",L=C.align||"flip",I=C.fallbackAxisSide||"end",z=typeof t=="function"?t:void 0,_=vt(z),U=z?_:t,D=$s(t),Z=S$()==="rtl",$=T||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":Z?"left":"right","inline-start":Z?"right":"left"}[r],G=o==="center"?$:`${$}-${o}`;let V=f;const Y=1,K=r==="bottom"?Y:0,P=r==="top"?Y:0,H=r==="right"?Y:0,B=r==="left"?Y:0;typeof V=="number"?V={top:V+K,right:V+B,bottom:V+P,left:V+H}:V&&(V={top:(V.top||0)+K,right:(V.right||0)+B,bottom:(V.bottom||0)+P,left:(V.left||0)+H});const Q={boundary:u==="clipping-ancestors"?"clippingAncestors":u,padding:V},oe=m.useRef(null),ne=$s(a),X=$s(c),_e=[HG(Be=>{const tt=kA(Be,r,Z),at=typeof ne.current=="function"?ne.current(tt):ne.current,Oe=typeof X.current=="function"?X.current(tt):X.current;return{mainAxis:at,crossAxis:Oe,alignmentAxis:Oe}},[typeof a!="function"?a:0,typeof c!="function"?c:0,Z,r])],xe=L==="none"&&O!=="shift",pe=!xe&&(h||E||O==="shift"),te=O==="none"?null:KG({...Q,padding:{top:V.top+Y,right:V.right+Y,bottom:V.bottom+Y,left:V.left+Y},mainAxis:!E&&O==="flip",crossAxis:L==="flip"?"alignment":!1,fallbackAxisSideDirection:I}),ve=xe?null:WG(Be=>{const tt=Jo(Be.elements.floating).documentElement;return{...Q,rootBoundary:E?{x:0,y:0,width:tt.clientWidth,height:tt.clientHeight}:void 0,mainAxis:L!=="none",crossAxis:pe,limiter:h||E?void 0:qG(at=>{if(!oe.current)return{};const{width:Oe,height:He}=oe.current.getBoundingClientRect(),ot=vr(Js(at.placement)),nt=ot==="y"?Oe:He,$t=ot==="y"?V.left+V.right:V.top+V.bottom;return{offset:nt/2+$t/2}})}},[Q,h,E,V,L]);O==="shift"||L==="shift"||o==="center"?_e.push(ve,te):_e.push(te,ve),_e.push(GG({...Q,apply({elements:{floating:Be},rects:{reference:tt},availableWidth:at,availableHeight:Oe}){Object.entries({"--available-width":`${at}px`,"--available-height":`${Oe}px`,"--anchor-width":`${tt.width}px`,"--anchor-height":`${tt.height}px`}).forEach(([He,ot])=>{Be.style.setProperty(He,ot)})}}),aY(()=>({element:oe.current||document.createElement("div"),padding:p,offsetParent:"floating"}),[p]),{name:"transformOrigin",fn(Be){const{elements:tt,middlewareData:at,placement:Oe,rects:He,y:ot}=Be,nt=Js(Oe),$t=vr(nt),Tn=oe.current,fn=at.arrow?.x||0,Gt=at.arrow?.y||0,Rt=Tn?.clientWidth||0,Gn=Tn?.clientHeight||0,On=fn+Rt/2,re=Gt+Gn/2,Re=Math.abs(at.shift?.y||0),Ve=He.reference.height/2,Ct=typeof a=="function"?a(kA(Be,r,Z)):a,Ft=Re>Ct,$n={top:`${On}px calc(100% + ${Ct}px)`,bottom:`${On}px ${-Ct}px`,left:`calc(100% + ${Ct}px) ${re}px`,right:`${-Ct}px ${re}px`}[nt],tn=`${On}px ${He.reference.y+Ve-ot}px`;return tt.floating.style.setProperty("--transform-origin",pe&&$t==="y"&&Ft?tn:$n),{}}},iY,S),pt(()=>{!b&&y&&y.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[b,y]);const he=m.useMemo(()=>({elementResize:!x&&typeof ResizeObserver<"u",layoutShift:!x&&typeof IntersectionObserver<"u"}),[x]),{refs:ke,elements:Ne,x:Fe,y:Ee,middlewareData:Le,update:Te,placement:Pe,context:De,isPositioned:ze,floatingStyles:$e}=TZ({rootContext:y,placement:G,middleware:_e,strategy:n,whileElementsMounted:v?void 0:(...Be)=>pA(...Be,he),nodeId:A,externalTree:N}),{sideX:st,sideY:rt}=Le.adaptiveOrigin||oY,Xe=ze?n:"fixed",dt=m.useMemo(()=>S?{position:Xe,[st]:Fe,[rt]:Ee}:{position:Xe,...$e},[S,Xe,st,Fe,rt,Ee,$e]),jt=m.useRef(null);pt(()=>{if(!b)return;const Be=D.current,tt=typeof Be=="function"?Be():Be,Oe=(NA(tt)?tt.current:tt)||null||null;Oe!==jt.current&&(ke.setPositionReference(Oe),jt.current=Oe)},[b,ke,U,D]),m.useEffect(()=>{if(!b)return;const Be=D.current;typeof Be!="function"&&NA(Be)&&Be.current!==jt.current&&(ke.setPositionReference(Be.current),jt.current=Be.current)},[b,ke,U,D]),m.useEffect(()=>{if(v&&b&&Ne.domReference&&Ne.floating)return pA(Ne.domReference,Ne.floating,Te,he)},[v,b,Ne,Te,he]);const At=Js(Pe),mt=C$(r,At,Z),Ht=Qi(Pe)||"center",ie=!!Le.hide?.referenceHidden;pt(()=>{k&&b&&ze&&R(At)},[k,b,ze,At]);const ce=m.useMemo(()=>({position:"absolute",top:Le.arrow?.y,left:Le.arrow?.x}),[Le.arrow]),Ae=Le.arrow?.centerOffset!==0;return m.useMemo(()=>({positionerStyles:dt,arrowStyles:ce,arrowRef:oe,arrowUncentered:Ae,side:mt,align:Ht,physicalSide:At,anchorHidden:ie,refs:ke,context:De,isPositioned:ze,update:Te}),[dt,ce,oe,Ae,mt,Ht,At,ie,ke,De,ze,Te])}function NA(e){return e!=null&&"current"in e}function cY(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:a}=e,o=vt(a),c=m.useRef(0),u=Nr(dY).current,f=Nr(uY).current,[h,p]=m.useState(0),x=m.useRef(h),v=vt((A,S)=>{f.set(A,S??null),x.current+=1,p(x.current)}),y=vt(A=>{f.delete(A),x.current+=1,p(x.current)}),b=m.useMemo(()=>{const A=new Map;return Array.from(f.keys()).filter(k=>k.isConnected).sort(fY).forEach((k,N)=>{const T=f.get(k)??{};A.set(k,{...T,index:N})}),A},[f,h]);pt(()=>{if(typeof MutationObserver!="function"||b.size===0)return;const A=new MutationObserver(S=>{const k=new Set,N=T=>k.has(T)?k.delete(T):k.add(T);S.forEach(T=>{T.removedNodes.forEach(N),T.addedNodes.forEach(N)}),k.size===0&&(x.current+=1,p(x.current))});return b.forEach((S,k)=>{k.parentElement&&A.observe(k.parentElement,{childList:!0})}),()=>{A.disconnect()}},[b]),pt(()=>{x.current===h&&(n.current.length!==b.size&&(n.current.length=b.size),r&&r.current.length!==b.size&&(r.current.length=b.size),c.current=b.size),o(b)},[o,b,n,r,h]),pt(()=>()=>{n.current=[]},[n]),pt(()=>()=>{r&&(r.current=[])},[r]);const C=vt(A=>(u.add(A),()=>{u.delete(A)}));pt(()=>{u.forEach(A=>A(b))},[u,b]);const E=m.useMemo(()=>({register:v,unregister:y,subscribeMapChange:C,elementsRef:n,labelsRef:r,nextIndexRef:c}),[v,y,C,n,r,c]);return s.jsx(MO.Provider,{value:E,children:t})}function uY(){return new Map}function dY(){return new Set}function fY(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const hY=m.forwardRef(function(t,n){const{cutout:r,...a}=t;let o;if(r){const c=r?.getBoundingClientRect();o=`polygon(
111
- 0% 0%,
112
- 100% 0%,
113
- 100% 100%,
114
- 0% 100%,
115
- 0% 0%,
116
- ${c.left}px ${c.top}px,
117
- ${c.left}px ${c.bottom}px,
118
- ${c.right}px ${c.bottom}px,
119
- ${c.right}px ${c.top}px,
120
- ${c.left}px ${c.top}px
121
- )`}return s.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...a,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:o}})}),mY=m.forwardRef(function(t,n){const{anchor:r,positionMethod:a="absolute",className:o,render:c,side:u,align:f,sideOffset:h=0,alignOffset:p=0,collisionBoundary:x="clipping-ancestors",collisionPadding:v=5,arrowPadding:y=5,sticky:b=!1,disableAnchorTracking:C=!1,collisionAvoidance:E=y7,...A}=t,{store:S}=Wc(),k=eY(),N=Ng(!0),T=S.useState("parent"),R=S.useState("floatingRootContext"),O=S.useState("floatingTreeRoot"),L=S.useState("mounted"),I=S.useState("open"),z=S.useState("modal"),_=S.useState("activeTriggerElement"),U=S.useState("lastOpenChangeReason"),D=S.useState("floatingNodeId"),q=S.useState("floatingParentNodeId");let Z=r,$=h,G=p,V=f;T.type==="context-menu"&&(Z=r??T.context?.anchor,V=V??"start",!u&&V!=="center"&&(G=t.alignOffset??2,$=t.sideOffset??-5));let Y=u,K=V;T.type==="menu"?(Y=Y??"inline-end",K=K??"start"):T.type==="menubar"&&(Y=Y??"bottom",K=K??"start");const P=T.type==="context-menu",H=lY({anchor:Z,floatingRootContext:R,positionMethod:N?"fixed":a,mounted:L,side:Y,sideOffset:$,align:K,alignOffset:G,arrowPadding:P?0:y,collisionBoundary:x,collisionPadding:v,sticky:b,nodeId:D,keepMounted:k,disableAnchorTracking:C,collisionAvoidance:E,shiftCrossAxis:P,externalTree:O}),B=m.useMemo(()=>{const be={};return I||(be.pointerEvents="none"),{role:"presentation",hidden:!L,style:{...H.positionerStyles,...be}}},[I,L,H.positionerStyles]);m.useEffect(()=>{function be(_e){_e.open?(_e.parentNodeId===D&&S.set("hoverEnabled",!1),_e.nodeId!==D&&_e.parentNodeId===S.select("floatingParentNodeId")&&S.setOpen(!1,qn(md))):_e.parentNodeId===D&&_e.reason!==md&&S.set("hoverEnabled",!0)}return O.events.on("menuopenchange",be),()=>{O.events.off("menuopenchange",be)}},[S,O.events,D]),m.useEffect(()=>{if(S.select("floatingParentNodeId")==null)return;function be(_e){if(_e.open||_e.nodeId!==S.select("floatingParentNodeId"))return;const xe=_e.reason??md;S.setOpen(!1,qn(xe))}return O.events.on("menuopenchange",be),()=>{O.events.off("menuopenchange",be)}},[O.events,S]),m.useEffect(()=>{function be(_e){!I||_e.nodeId!==S.select("floatingParentNodeId")||_e.target&&_&&_!==_e.target&&S.setOpen(!1,qn(md))}return O.events.on("itemhover",be),()=>{O.events.off("itemhover",be)}},[O.events,I,_,S]),m.useEffect(()=>{const be={open:I,nodeId:D,parentNodeId:q,reason:S.select("lastOpenChangeReason")};O.events.emit("menuopenchange",be)},[O.events,I,S,D,q]);const Q=m.useMemo(()=>({open:I,side:H.side,align:H.align,anchorHidden:H.anchorHidden,nested:T.type==="menu"}),[I,H.side,H.align,H.anchorHidden,T.type]),oe=m.useMemo(()=>({side:H.side,align:H.align,arrowRef:H.arrowRef,arrowUncentered:H.arrowUncentered,arrowStyles:H.arrowStyles,nodeId:H.context.nodeId}),[H.side,H.align,H.arrowRef,H.arrowUncentered,H.arrowStyles,H.context.nodeId]),ne=Yi("div",t,{state:Q,stateAttributesMapping:CO,ref:[n,S.useStateSetter("positionerElement")],props:[B,A]}),X=L&&T.type!=="menu"&&(T.type!=="menubar"&&z&&U!==Vo||T.type==="menubar"&&T.context.modal);let ae=null;return T.type==="menubar"?ae=T.context.contentElement:T.type===void 0&&(ae=_),s.jsxs(xO.Provider,{value:oe,children:[X&&s.jsx(hY,{ref:T.type==="context-menu"||T.type==="nested-context-menu"?T.context.internalBackdropRef:null,inert:nY(!I),cutout:ae}),s.jsx(YK,{id:D,children:s.jsx(cY,{elementsRef:S.context.itemDomElements,labelsRef:S.context.itemLabels,children:ne})})]})});let SA={},CA={},EA="";function pY(e){if(typeof document>"u")return!1;const t=Jo(e);return ls(t).innerWidth-t.documentElement.clientWidth>0}function gY(e){const t=Jo(e),n=t.documentElement,r=t.body,a=il(n)?n:r,o=a.style.overflow;return a.style.overflow="hidden",()=>{a.style.overflow=o}}function vY(e){const t=Jo(e),n=t.documentElement,r=t.body,a=ls(n);let o=0,c=0;const u=na.create(),f=typeof CSS<"u"&&CSS.supports?.("scrollbar-gutter","stable");if(lK&&(a.visualViewport?.scale??1)!==1)return()=>{};function h(){const v=a.getComputedStyle(n),y=a.getComputedStyle(r),E=(v.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";o=n.scrollTop,c=n.scrollLeft,SA={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},EA=n.style.scrollBehavior,CA={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const A=n.scrollHeight>n.clientHeight,S=n.scrollWidth>n.clientWidth,k=v.overflowY==="scroll"||y.overflowY==="scroll",N=v.overflowX==="scroll"||y.overflowX==="scroll",T=Math.max(0,a.innerWidth-n.clientWidth),R=Math.max(0,a.innerHeight-n.clientHeight),O=parseFloat(y.marginTop)+parseFloat(y.marginBottom),L=parseFloat(y.marginLeft)+parseFloat(y.marginRight),I=il(n)?n:r;if(f){n.style.scrollbarGutter=E,I.style.overflowY="hidden",I.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:E,overflowY:"hidden",overflowX:"hidden"}),(A||k)&&(n.style.overflowY="scroll"),(S||N)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:O||R?`calc(100dvh - ${O+R}px)`:"100dvh",width:L||T?`calc(100vw - ${L+T}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),r.scrollTop=o,r.scrollLeft=c,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function p(){Object.assign(n.style,SA),Object.assign(r.style,CA),f||(n.scrollTop=o,n.scrollLeft=c,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=EA)}function x(){p(),u.request(h)}return h(),a.addEventListener("resize",x),()=>{u.cancel(),p(),typeof a.removeEventListener=="function"&&a.removeEventListener("resize",x)}}class xY{lockCount=0;restore=null;timeoutLock=_c.create();timeoutUnlock=_c.create();acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(t){if(this.lockCount===0||this.restore!==null)return;const r=Jo(t).documentElement,a=ls(r).getComputedStyle(r).overflowY;if(a==="hidden"||a==="clip"){this.restore=NO;return}const o=cK||!pY(t);this.restore=o?gY(t):vY(t)}}const yY=new xY;function bY(e=!0,t=null){pt(()=>{if(e)return yY.acquire(t)},[e,t])}const wY=m.createContext(null);function jY(e){return m.useContext(wY)}function kY(e){const t=m.useRef(""),n=m.useCallback(a=>{a.defaultPrevented||(t.current=a.pointerType,e(a,a.pointerType))},[e]);return{onClick:m.useCallback(a=>{if(a.detail===0){e(a,"keyboard");return}"pointerType"in a&&e(a,a.pointerType),e(a,t.current),t.current=""},[e]),onPointerDown:n}}function NY(e){const[t,n]=m.useState(null),r=vt((u,f)=>{e||n(f)}),a=m.useCallback(()=>{n(null)},[]),{onClick:o,onPointerDown:c}=kY(r);return m.useMemo(()=>({openMethod:t,reset:a,triggerProps:{onClick:o,onPointerDown:c}}),[t,a,o,c])}const SY={...EZ,disabled:Mt(e=>e.parent.type==="menubar"&&e.parent.context.disabled||e.disabled),modal:Mt(e=>(e.parent.type===void 0||e.parent.type==="context-menu")&&(e.modal??!0)),allowMouseEnter:Mt(e=>e.parent.type==="menu"?e.parent.store.select("allowMouseEnter"):e.allowMouseEnter),stickIfOpen:Mt(e=>e.stickIfOpen),parent:Mt(e=>e.parent),rootId:Mt(e=>e.parent.type==="menu"?e.parent.store.select("rootId"):e.parent.type!==void 0?e.parent.context.rootId:e.rootId),activeIndex:Mt(e=>e.activeIndex),isActive:Mt((e,t)=>e.activeIndex===t),hoverEnabled:Mt(e=>e.hoverEnabled),instantType:Mt(e=>e.instantType),lastOpenChangeReason:Mt(e=>e.openChangeReason),floatingTreeRoot:Mt(e=>e.parent.type==="menu"?e.parent.store.select("floatingTreeRoot"):e.floatingTreeRoot),floatingNodeId:Mt(e=>e.floatingNodeId),floatingParentNodeId:Mt(e=>e.floatingParentNodeId),itemProps:Mt(e=>e.itemProps),closeDelay:Mt(e=>e.closeDelay),keyboardEventRelay:Mt(e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type==="menu")return e.parent.store.select("keyboardEventRelay")})};class kj extends v${constructor(t){super({...CY(),...t},{positionerRef:m.createRef(),popupRef:m.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:m.createRef(),beforeContentFocusGuardRef:m.createRef(),onOpenChangeComplete:void 0,triggerElements:new jj},SY),this.observe(Mt(n=>n.allowMouseEnter),(n,r)=>{this.state.parent.type==="menu"&&n!==r&&this.state.parent.store.set("allowMouseEnter",n)}),this.unsubscribeParentListener=this.observe("parent",n=>{if(this.unsubscribeParentListener?.(),n.type==="menu"){this.unsubscribeParentListener=n.store.subscribe(()=>{this.notifyAll()}),this.context.allowMouseUpTriggerRef=n.store.context.allowMouseUpTriggerRef;return}n.type!==void 0&&(this.context.allowMouseUpTriggerRef=n.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(t,n){this.state.floatingRootContext.context.events.emit("setOpen",{open:t,eventDetails:n})}static useStore(t,n){return Nr(()=>t??new kj(n)).current}unsubscribeParentListener=null}function CY(){return{...CZ(),disabled:!1,modal:!0,allowMouseEnter:!0,stickIfOpen:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new e$,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Ps,keyboardEventRelay:void 0,closeDelay:0}}const EY=m.createContext(void 0);function AY(){return m.useContext(EY)}function TY(e){const{children:t,open:n,onOpenChange:r,onOpenChangeComplete:a,defaultOpen:o=!1,disabled:c=!1,modal:u,loopFocus:f=!0,orientation:h="vertical",actionsRef:p,closeParentOnEsc:x=!0,handle:v,triggerId:y,defaultTriggerId:b=null,highlightItemOnHover:C=!0}=e,E=Ng(!0),A=Wc(!0),S=jY(),k=AY(),N=m.useMemo(()=>k&&A?{type:"menu",store:A.store}:S?{type:"menubar",context:S}:E&&!A?{type:"context-menu",context:E}:{type:void 0},[E,A,S,k]),T=kj.useStore(v?.store,{parent:N}),R=T.useState("floatingTreeRoot"),O=ZK(R),L=Ji();pt(()=>{E&&!A?T.update({parent:{type:"context-menu",context:E},floatingNodeId:O,floatingParentNodeId:L}):A&&T.update({floatingNodeId:O,floatingParentNodeId:L})},[E,A,O,L,T]),T.useControlledProp("open",n,o),T.useControlledProp("activeTriggerId",y,b),T.useContextCallback("onOpenChangeComplete",a);const I=T.useState("open"),z=T.useState("activeTriggerElement"),_=T.useState("positionerElement"),U=T.useState("hoverEnabled"),D=T.useState("modal"),q=T.useState("disabled"),Z=T.useState("lastOpenChangeReason"),$=T.useState("parent"),G=T.useState("activeIndex"),V=T.useState("payload"),Y=T.useState("floatingParentNodeId"),K=m.useRef(null),P=Y!=null;let H;T.useSyncedValues({disabled:c,modal:$.type===void 0?u:void 0,rootId:Zi()});const{openMethod:B,triggerProps:Q,reset:oe}=NY(I);kZ(T);const{forceUnmount:ne}=NZ(I,T,()=>{T.update({allowMouseEnter:!1,stickIfOpen:!0}),oe()}),X=m.useRef($.type!=="context-menu"),ae=Br();m.useEffect(()=>{if(I||(K.current=null),$.type==="context-menu"){if(!I){ae.clear(),X.current=!1;return}ae.start(500,()=>{X.current=!0})}},[ae,I,$.type]),bY(I&&D&&Z!==Vo&&B!=="touch",_),pt(()=>{!I&&!U&&T.set("hoverEnabled",!0)},[I,U,T]);const be=m.useRef(!0),_e=Br(),xe=vt((ie,ce)=>{const Ae=ce.reason;if(I===ie&&ce.trigger===z||(ce.preventUnmountOnClose=()=>{T.set("preventUnmountingOnClose",!0)},!ie&&ce.trigger==null&&(ce.trigger=z??void 0),r?.(ie,ce),ce.isCanceled))return;const Be={open:ie,nativeEvent:ce.event,reason:ce.reason,nested:P};H?.emit("openchange",Be);const tt=ce.event;if(ie===!1&&tt?.type==="click"&&tt.pointerType==="touch"&&!be.current)return;if(!ie&&G!==null){const ot=T.context.itemDomElements.current[G];queueMicrotask(()=>{ot?.setAttribute("tabindex","-1")})}ie&&Ae===QE?(be.current=!1,_e.start(300,()=>{be.current=!0})):(be.current=!0,_e.clear());const at=(Ae===Np||Ae===EO)&&tt.detail===0&&tt?.isTrusted,Oe=!ie&&(Ae===AO||Ae==null);function He(){const ot={open:ie,openChangeReason:Ae};K.current=ce.event??null;const nt=ce.trigger?.id??null;(nt||ie)&&(ot.activeTriggerId=nt,ot.activeTriggerElement=ce.trigger??null),T.update(ot)}Ae===Vo?da.flushSync(He):He(),$.type==="menubar"&&(Ae===QE||Ae===Cg||Ae===Vo||Ae===Vm||Ae===md)?T.set("instantType","group"):at||Oe?T.set("instantType",at?"click":"dismiss"):T.set("instantType",void 0)}),pe=m.useCallback(ie=>{const ce=qn(ie);return ce.preventUnmountOnClose=()=>{T.set("preventUnmountingOnClose",!0)},ce},[T]),te=m.useCallback(()=>{T.setOpen(!1,pe(O7))},[T,pe]);m.useImperativeHandle(p,()=>({unmount:ne,close:te}),[ne,te]);let ve;$.type==="context-menu"&&(ve=$.context),m.useImperativeHandle(ve?.positionerRef,()=>_,[_]),m.useImperativeHandle(ve?.actionsRef,()=>({setOpen:xe}),[xe]);const he=MZ({popupStore:T,onOpenChange:xe});H=he.context.events,m.useEffect(()=>{const ie=({open:ce,eventDetails:Ae})=>xe(ce,Ae);return H.on("setOpen",ie),()=>{H?.off("setOpen",ie)}},[H,xe]);const ke=QG(he,{enabled:!q,bubbles:x&&$.type==="menu",outsidePress(){return $.type!=="context-menu"||K.current?.type==="contextmenu"?!0:X.current},externalTree:P?R:void 0}),Ne=VZ(he,{role:"menu"}),Fe=S$(),Ee=m.useCallback(ie=>{T.select("activeIndex")!==ie&&T.set("activeIndex",ie)},[T]),Le=UZ(he,{enabled:!q,listRef:T.context.itemDomElements,activeIndex:G,nested:$.type!==void 0,loopFocus:f,orientation:h,parentOrientation:$.type==="menubar"?$.context.orientation:void 0,rtl:Fe==="rtl",disabledIndices:SO,onNavigate:Ee,openOnArrowKeyDown:$.type!=="context-menu",externalTree:P?R:void 0,focusItemOnHover:C}),Te=m.useCallback(ie=>{T.context.typingRef.current=ie},[T]),Pe=HZ(he,{listRef:T.context.itemLabels,activeIndex:G,resetMs:g7,onMatch:ie=>{I&&ie!==G&&T.set("activeIndex",ie)},onTypingChange:Te}),{getReferenceProps:De,getFloatingProps:ze,getItemProps:$e,getTriggerProps:st}=PZ([ke,Ne,Le,Pe]),rt=m.useMemo(()=>{const ie=Sg(De(),{onMouseEnter(){T.set("hoverEnabled",!0)},onMouseMove(){T.set("allowMouseEnter",!0)}},Q);return delete ie.role,ie},[De,T,Q]),Xe=m.useMemo(()=>{const ie=st();if(!ie)return ie;const{role:ce,["aria-controls"]:Ae,...Be}=ie;return Be},[st]),dt=mj(),jt=m.useMemo(()=>ze({onMouseEnter(){$.type==="menu"&&dt.request(()=>T.set("hoverEnabled",!1))},onMouseMove(){T.set("allowMouseEnter",!0)},onClick(){T.select("hoverEnabled")&&T.set("hoverEnabled",!1)},onKeyDown(ie){const ce=T.select("keyboardEventRelay");ce&&!ie.isPropagationStopped()&&ce(ie)}}),[ze,$.type,dt,T]),At=m.useMemo(()=>$e(),[$e]);T.useSyncedValues({floatingRootContext:he,activeTriggerProps:rt,inactiveTriggerProps:Xe,popupProps:jt,itemProps:At});const mt=m.useMemo(()=>({store:T,parent:N}),[T,N]),Ht=s.jsx(lj.Provider,{value:mt,children:typeof t=="function"?t({payload:V}):t});return $.type===void 0||$.type==="context-menu"?s.jsx(XK,{externalTree:R,children:Ht}):Ht}function E$(e){if(Wn(e)&&e.hasAttribute("data-rootownerid"))return e.getAttribute("data-rootownerid")??void 0;if(!ra(e))return E$(ua(e))}const MY=m.forwardRef(function(t,n){const{className:r,render:a,orientation:o="horizontal",...c}=t,u=m.useMemo(()=>({orientation:o}),[o]);return Yi("div",t,{state:u,ref:n,props:[{role:"separator","aria-orientation":o},c]})});function RY(e){const[t,n]=m.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),r=m.useRef(null),a=m.useRef(null),o=m.useRef(null),c=m.useRef(null),u=m.useRef(!0),f=m.useRef(null),h=Zi(),p=m.useMemo(()=>({anchor:t,setAnchor:n,actionsRef:o,backdropRef:r,internalBackdropRef:a,positionerRef:c,allowMouseUpTriggerRef:u,initialCursorPointRef:f,rootId:h}),[t,h]);return s.jsx(vO.Provider,{value:p,children:s.jsx(lj.Provider,{value:void 0,children:s.jsx(TY,{...e})})})}const AA=500,IY=m.forwardRef(function(t,n){const{render:r,className:a,...o}=t,{setAnchor:c,actionsRef:u,internalBackdropRef:f,backdropRef:h,positionerRef:p,allowMouseUpTriggerRef:x,initialCursorPointRef:v,rootId:y}=Ng(!1),{store:b}=Wc(!1),C=b.useState("open"),E=m.useRef(null),A=m.useRef(null),S=Br(),k=Br(),N=m.useRef(!1);function T(U,D,q){const Z=q.type.startsWith("touch");v.current={x:U,y:D},c({getBoundingClientRect(){return DOMRect.fromRect({width:Z?10:0,height:Z?10:0,x:U,y:D})}}),N.current=!1,u.current?.setOpen(!0,qn(Np,q)),k.start(AA,()=>{N.current=!0})}function R(U){x.current=!0,is(U),T(U.clientX,U.clientY,U.nativeEvent),Jo(E.current).addEventListener("mouseup",q=>{if(x.current=!1,!N.current)return;k.clear(),N.current=!1;const Z=Ls(q);vn(p.current,Z)||y&&Z&&E$(Z)===y||u.current?.setOpen(!1,qn(_7,q))},{once:!0})}function O(U){if(x.current=!1,U.touches.length===1){U.stopPropagation();const D=U.touches[0];A.current={x:D.clientX,y:D.clientY},S.start(AA,()=>{A.current&&T(A.current.x,A.current.y,U.nativeEvent)})}}function L(U){if(S.isStarted()&&A.current&&U.touches.length===1){const D=U.touches[0],q=10,Z=Math.abs(D.clientX-A.current.x),$=Math.abs(D.clientY-A.current.y);(Z>q||$>q)&&S.clear()}}function I(){S.clear(),A.current=null}m.useEffect(()=>{function U(q){const $=Ls(q);(vn(E.current,$)||vn(f.current,$)||vn(h.current,$))&&q.preventDefault()}const D=Jo(E.current);return D.addEventListener("contextmenu",U),()=>{D.removeEventListener("contextmenu",U)}},[h,f]);const z=m.useMemo(()=>({open:C}),[C]);return Yi("div",t,{state:z,ref:[E,n],props:[{onContextMenu:R,onTouchStart:O,onTouchMove:L,onTouchEnd:I,onTouchCancel:I,style:{WebkitTouchCallout:"none"}},o],stateAttributesMapping:R7})}),Nj=m.createContext({});function Sj(e){const t=m.useRef(null);return t.current===null&&(t.current=e()),t.current}const _Y=typeof window<"u",A$=_Y?m.useLayoutEffect:m.useEffect,Og=m.createContext(null);function Cj(e,t){e.indexOf(t)===-1&&e.push(t)}function Lp(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const fa=(e,t,n)=>n>t?t:n<e?e:n;let Ej=()=>{};const Vi={},T$=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),M$=e=>typeof e=="object"&&e!==null,R$=e=>/^0[^.\s]+$/u.test(e);function I$(e){let t;return()=>(t===void 0&&(t=e()),t)}const jr=e=>e,gf=(...e)=>e.reduce((t,n)=>r=>n(t(r))),Yd=(e,t,n)=>{const r=t-e;return r?(n-e)/r:1};class Aj{constructor(){this.subscriptions=[]}add(t){return Cj(this.subscriptions,t),()=>Lp(this.subscriptions,t)}notify(t,n,r){const a=this.subscriptions.length;if(a)if(a===1)this.subscriptions[0](t,n,r);else for(let o=0;o<a;o++){const c=this.subscriptions[o];c&&c(t,n,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const er=e=>e*1e3,xr=e=>e/1e3,_$=(e,t)=>t?e*(1e3/t):0,O$=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,OY=1e-7,$Y=12;function LY(e,t,n,r,a){let o,c,u=0;do c=t+(n-t)/2,o=O$(c,r,a)-e,o>0?n=c:t=c;while(Math.abs(o)>OY&&++u<$Y);return c}function vf(e,t,n,r){if(e===t&&n===r)return jr;const a=o=>LY(o,0,1,e,n);return o=>o===0||o===1?o:O$(a(o),t,r)}const $$=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,L$=e=>t=>1-e(1-t),P$=vf(.33,1.53,.69,.99),Tj=L$(P$),D$=$$(Tj),z$=e=>e>=1?1:(e*=2)<1?.5*Tj(e):.5*(2-Math.pow(2,-10*(e-1))),Mj=e=>1-Math.sin(Math.acos(e)),B$=L$(Mj),U$=$$(Mj),PY=vf(.42,0,1,1),DY=vf(0,0,.58,1),F$=vf(.42,0,.58,1),zY=e=>Array.isArray(e)&&typeof e[0]!="number",V$=e=>Array.isArray(e)&&typeof e[0]=="number",BY={linear:jr,easeIn:PY,easeInOut:F$,easeOut:DY,circIn:Mj,circInOut:U$,circOut:B$,backIn:Tj,backInOut:D$,backOut:P$,anticipate:z$},UY=e=>typeof e=="string",TA=e=>{if(V$(e)){Ej(e.length===4);const[t,n,r,a]=e;return vf(t,n,r,a)}else if(UY(e))return BY[e];return e},Qh=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function FY(e,t){let n=new Set,r=new Set,a=!1,o=!1;const c=new WeakSet;let u={delta:0,timestamp:0,isProcessing:!1};function f(p){c.has(p)&&(h.schedule(p),e()),p(u)}const h={schedule:(p,x=!1,v=!1)=>{const b=v&&a?n:r;return x&&c.add(p),b.add(p),p},cancel:p=>{r.delete(p),c.delete(p)},process:p=>{if(u=p,a){o=!0;return}a=!0;const x=n;n=r,r=x,n.forEach(f),n.clear(),a=!1,o&&(o=!1,h.process(p))}};return h}const VY=40;function H$(e,t){let n=!1,r=!0;const a={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,c=Qh.reduce((k,N)=>(k[N]=FY(o),k),{}),{setup:u,read:f,resolveKeyframes:h,preUpdate:p,update:x,preRender:v,render:y,postRender:b}=c,C=()=>{const k=Vi.useManualTiming,N=k?a.timestamp:performance.now();n=!1,k||(a.delta=r?1e3/60:Math.max(Math.min(N-a.timestamp,VY),1)),a.timestamp=N,a.isProcessing=!0,u.process(a),f.process(a),h.process(a),p.process(a),x.process(a),v.process(a),y.process(a),b.process(a),a.isProcessing=!1,n&&t&&(r=!1,e(C))},E=()=>{n=!0,r=!0,a.isProcessing||e(C)};return{schedule:Qh.reduce((k,N)=>{const T=c[N];return k[N]=(R,O=!1,L=!1)=>(n||E(),T.schedule(R,O,L)),k},{}),cancel:k=>{for(let N=0;N<Qh.length;N++)c[Qh[N]].cancel(k)},state:a,steps:c}}const{schedule:cn,cancel:Hi,state:rs,steps:$y}=H$(typeof requestAnimationFrame<"u"?requestAnimationFrame:jr,!0);let qm;function HY(){qm=void 0}const Ns={now:()=>(qm===void 0&&Ns.set(rs.isProcessing||Vi.useManualTiming?rs.timestamp:performance.now()),qm),set:e=>{qm=e,queueMicrotask(HY)}},W$=e=>t=>typeof t=="string"&&t.startsWith(e),q$=W$("--"),WY=W$("var(--"),Rj=e=>WY(e)?qY.test(e.split("/*")[0].trim()):!1,qY=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function MA(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const Gc={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Xd={...Gc,transform:e=>fa(0,1,e)},Jh={...Gc,default:1},Ed=e=>Math.round(e*1e5)/1e5,Ij=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function KY(e){return e==null}const GY=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,_j=(e,t)=>n=>!!(typeof n=="string"&&GY.test(n)&&n.startsWith(e)||t&&!KY(n)&&Object.prototype.hasOwnProperty.call(n,t)),K$=(e,t,n)=>r=>{if(typeof r!="string")return r;const[a,o,c,u]=r.match(Ij);return{[e]:parseFloat(a),[t]:parseFloat(o),[n]:parseFloat(c),alpha:u!==void 0?parseFloat(u):1}},ZY=e=>fa(0,255,e),Ly={...Gc,transform:e=>Math.round(ZY(e))},zo={test:_j("rgb","red"),parse:K$("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:r=1})=>"rgba("+Ly.transform(e)+", "+Ly.transform(t)+", "+Ly.transform(n)+", "+Ed(Xd.transform(r))+")"};function YY(e){let t="",n="",r="",a="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),a=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),a=e.substring(4,5),t+=t,n+=n,r+=r,a+=a),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:a?parseInt(a,16)/255:1}}const w0={test:_j("#"),parse:YY,transform:zo.transform},xf=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Fa=xf("deg"),ia=xf("%"),Ye=xf("px"),XY=xf("vh"),QY=xf("vw"),RA={...ia,parse:e=>ia.parse(e)/100,transform:e=>ia.transform(e*100)},uc={test:_j("hsl","hue"),parse:K$("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(e)+", "+ia.transform(Ed(t))+", "+ia.transform(Ed(n))+", "+Ed(Xd.transform(r))+")"},Hn={test:e=>zo.test(e)||w0.test(e)||uc.test(e),parse:e=>zo.test(e)?zo.parse(e):uc.test(e)?uc.parse(e):w0.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?zo.transform(e):uc.transform(e),getAnimatableNone:e=>{const t=Hn.parse(e);return t.alpha=0,Hn.transform(t)}},JY=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function eX(e){return isNaN(e)&&typeof e=="string"&&(e.match(Ij)?.length||0)+(e.match(JY)?.length||0)>0}const G$="number",Z$="color",tX="var",nX="var(",IA="${}",sX=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Lc(e){const t=e.toString(),n=[],r={color:[],number:[],var:[]},a=[];let o=0;const u=t.replace(sX,f=>(Hn.test(f)?(r.color.push(o),a.push(Z$),n.push(Hn.parse(f))):f.startsWith(nX)?(r.var.push(o),a.push(tX),n.push(f)):(r.number.push(o),a.push(G$),n.push(parseFloat(f))),++o,IA)).split(IA);return{values:n,split:u,indexes:r,types:a}}function rX(e){return Lc(e).values}function Y$({split:e,types:t}){const n=e.length;return r=>{let a="";for(let o=0;o<n;o++)if(a+=e[o],r[o]!==void 0){const c=t[o];c===G$?a+=Ed(r[o]):c===Z$?a+=Hn.transform(r[o]):a+=r[o]}return a}}function aX(e){return Y$(Lc(e))}const iX=e=>typeof e=="number"?0:Hn.test(e)?Hn.getAnimatableNone(e):e,oX=(e,t)=>typeof e=="number"?t?.trim().endsWith("/")?e:0:iX(e);function lX(e){const t=Lc(e);return Y$(t)(t.values.map((r,a)=>oX(r,t.split[a])))}const Dr={test:eX,parse:rX,createTransformer:aX,getAnimatableNone:lX};function Py(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function cX({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let a=0,o=0,c=0;if(!t)a=o=c=n;else{const u=n<.5?n*(1+t):n+t-n*t,f=2*n-u;a=Py(f,u,e+1/3),o=Py(f,u,e),c=Py(f,u,e-1/3)}return{red:Math.round(a*255),green:Math.round(o*255),blue:Math.round(c*255),alpha:r}}function Pp(e,t){return n=>n>0?t:e}const ln=(e,t,n)=>e+(t-e)*n,Dy=(e,t,n)=>{const r=e*e,a=n*(t*t-r)+r;return a<0?0:Math.sqrt(a)},uX=[w0,zo,uc],dX=e=>uX.find(t=>t.test(e));function _A(e){const t=dX(e);if(!t)return!1;let n=t.parse(e);return t===uc&&(n=cX(n)),n}const OA=(e,t)=>{const n=_A(e),r=_A(t);if(!n||!r)return Pp(e,t);const a={...n};return o=>(a.red=Dy(n.red,r.red,o),a.green=Dy(n.green,r.green,o),a.blue=Dy(n.blue,r.blue,o),a.alpha=ln(n.alpha,r.alpha,o),zo.transform(a))},j0=new Set(["none","hidden"]);function fX(e,t){return j0.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function hX(e,t){return n=>ln(e,t,n)}function Oj(e){return typeof e=="number"?hX:typeof e=="string"?Rj(e)?Pp:Hn.test(e)?OA:gX:Array.isArray(e)?X$:typeof e=="object"?Hn.test(e)?OA:mX:Pp}function X$(e,t){const n=[...e],r=n.length,a=e.map((o,c)=>Oj(o)(o,t[c]));return o=>{for(let c=0;c<r;c++)n[c]=a[c](o);return n}}function mX(e,t){const n={...e,...t},r={};for(const a in n)e[a]!==void 0&&t[a]!==void 0&&(r[a]=Oj(e[a])(e[a],t[a]));return a=>{for(const o in r)n[o]=r[o](a);return n}}function pX(e,t){const n=[],r={color:0,var:0,number:0};for(let a=0;a<t.values.length;a++){const o=t.types[a],c=e.indexes[o][r[o]],u=e.values[c]??0;n[a]=u,r[o]++}return n}const gX=(e,t)=>{const n=Dr.createTransformer(t),r=Lc(e),a=Lc(t);return r.indexes.var.length===a.indexes.var.length&&r.indexes.color.length===a.indexes.color.length&&r.indexes.number.length>=a.indexes.number.length?j0.has(e)&&!a.values.length||j0.has(t)&&!r.values.length?fX(e,t):gf(X$(pX(r,a),a.values),n):Pp(e,t)};function Q$(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?ln(e,t,n):Oj(e)(e,t)}const vX=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>cn.update(t,n),stop:()=>Hi(t),now:()=>rs.isProcessing?rs.timestamp:Ns.now()}},J$=(e,t,n=10)=>{let r="";const a=Math.max(Math.round(t/n),2);for(let o=0;o<a;o++)r+=Math.round(e(o/(a-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`},Dp=2e4;function $j(e){let t=0;const n=50;let r=e.next(t);for(;!r.done&&t<Dp;)t+=n,r=e.next(t);return t>=Dp?1/0:t}function xX(e,t=100,n){const r=n({...e,keyframes:[0,t]}),a=Math.min($j(r),Dp);return{type:"keyframes",ease:o=>r.next(a*o).value/t,duration:xr(a)}}const In={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function k0(e,t){return e*Math.sqrt(1-t*t)}const yX=12;function bX(e,t,n){let r=n;for(let a=1;a<yX;a++)r=r-e(r)/t(r);return r}const zy=.001;function wX({duration:e=In.duration,bounce:t=In.bounce,velocity:n=In.velocity,mass:r=In.mass}){let a,o,c=1-t;c=fa(In.minDamping,In.maxDamping,c),e=fa(In.minDuration,In.maxDuration,xr(e)),c<1?(a=h=>{const p=h*c,x=p*e,v=p-n,y=k0(h,c),b=Math.exp(-x);return zy-v/y*b},o=h=>{const x=h*c*e,v=x*n+n,y=Math.pow(c,2)*Math.pow(h,2)*e,b=Math.exp(-x),C=k0(Math.pow(h,2),c);return(-a(h)+zy>0?-1:1)*((v-y)*b)/C}):(a=h=>{const p=Math.exp(-h*e),x=(h-n)*e+1;return-zy+p*x},o=h=>{const p=Math.exp(-h*e),x=(n-h)*(e*e);return p*x});const u=5/e,f=bX(a,o,u);if(e=er(e),isNaN(f))return{stiffness:In.stiffness,damping:In.damping,duration:e};{const h=Math.pow(f,2)*r;return{stiffness:h,damping:c*2*Math.sqrt(r*h),duration:e}}}const jX=["duration","bounce"],kX=["stiffness","damping","mass"];function $A(e,t){return t.some(n=>e[n]!==void 0)}function NX(e){let t={velocity:In.velocity,stiffness:In.stiffness,damping:In.damping,mass:In.mass,isResolvedFromDuration:!1,...e};if(!$A(e,kX)&&$A(e,jX))if(t.velocity=0,e.visualDuration){const n=e.visualDuration,r=2*Math.PI/(n*1.2),a=r*r,o=2*fa(.05,1,1-(e.bounce||0))*Math.sqrt(a);t={...t,mass:In.mass,stiffness:a,damping:o}}else{const n=wX({...e,velocity:0});t={...t,...n,mass:In.mass},t.isResolvedFromDuration=!0}return t}function zp(e=In.visualDuration,t=In.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:r,restDelta:a}=n;const o=n.keyframes[0],c=n.keyframes[n.keyframes.length-1],u={done:!1,value:o},{stiffness:f,damping:h,mass:p,duration:x,velocity:v,isResolvedFromDuration:y}=NX({...n,velocity:-xr(n.velocity||0)}),b=v||0,C=h/(2*Math.sqrt(f*p)),E=c-o,A=xr(Math.sqrt(f/p)),S=Math.abs(E)<5;r||(r=S?In.restSpeed.granular:In.restSpeed.default),a||(a=S?In.restDelta.granular:In.restDelta.default);let k,N,T,R,O,L;if(C<1)T=k0(A,C),R=(b+C*A*E)/T,k=z=>{const _=Math.exp(-C*A*z);return c-_*(R*Math.sin(T*z)+E*Math.cos(T*z))},O=C*A*R+E*T,L=C*A*E-R*T,N=z=>Math.exp(-C*A*z)*(O*Math.sin(T*z)+L*Math.cos(T*z));else if(C===1){k=_=>c-Math.exp(-A*_)*(E+(b+A*E)*_);const z=b+A*E;N=_=>Math.exp(-A*_)*(A*z*_-b)}else{const z=A*Math.sqrt(C*C-1);k=q=>{const Z=Math.exp(-C*A*q),$=Math.min(z*q,300);return c-Z*((b+C*A*E)*Math.sinh($)+z*E*Math.cosh($))/z};const _=(b+C*A*E)/z,U=C*A*_-E*z,D=C*A*E-_*z;N=q=>{const Z=Math.exp(-C*A*q),$=Math.min(z*q,300);return Z*(U*Math.sinh($)+D*Math.cosh($))}}const I={calculatedDuration:y&&x||null,velocity:z=>er(N(z)),next:z=>{if(!y&&C<1){const U=Math.exp(-C*A*z),D=Math.sin(T*z),q=Math.cos(T*z),Z=c-U*(R*D+E*q),$=er(U*(O*D+L*q));return u.done=Math.abs($)<=r&&Math.abs(c-Z)<=a,u.value=u.done?c:Z,u}const _=k(z);if(y)u.done=z>=x;else{const U=er(N(z));u.done=Math.abs(U)<=r&&Math.abs(c-_)<=a}return u.value=u.done?c:_,u},toString:()=>{const z=Math.min($j(I),Dp),_=J$(U=>I.next(z*U).value,z,30);return z+"ms "+_},toTransition:()=>{}};return I}zp.applyToOptions=e=>{const t=xX(e,100,zp);return e.ease=t.ease,e.duration=er(t.duration),e.type="keyframes",e};const SX=5;function eL(e,t,n){const r=Math.max(t-SX,0);return _$(n-e(r),t-r)}function N0({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:a=10,bounceStiffness:o=500,modifyTarget:c,min:u,max:f,restDelta:h=.5,restSpeed:p}){const x=e[0],v={done:!1,value:x},y=L=>u!==void 0&&L<u||f!==void 0&&L>f,b=L=>u===void 0?f:f===void 0||Math.abs(u-L)<Math.abs(f-L)?u:f;let C=n*t;const E=x+C,A=c===void 0?E:c(E);A!==E&&(C=A-x);const S=L=>-C*Math.exp(-L/r),k=L=>A+S(L),N=L=>{const I=S(L),z=k(L);v.done=Math.abs(I)<=h,v.value=v.done?A:z};let T,R;const O=L=>{y(v.value)&&(T=L,R=zp({keyframes:[v.value,b(v.value)],velocity:eL(k,L,v.value),damping:a,stiffness:o,restDelta:h,restSpeed:p}))};return O(0),{calculatedDuration:null,next:L=>{let I=!1;return!R&&T===void 0&&(I=!0,N(L),O(L)),T!==void 0&&L>=T?R.next(L-T):(!I&&N(L),v)}}}function CX(e,t,n){const r=[],a=n||Vi.mix||Q$,o=e.length-1;for(let c=0;c<o;c++){let u=a(e[c],e[c+1]);if(t){const f=Array.isArray(t)?t[c]||jr:t;u=gf(f,u)}r.push(u)}return r}function EX(e,t,{clamp:n=!0,ease:r,mixer:a}={}){const o=e.length;if(Ej(o===t.length),o===1)return()=>t[0];if(o===2&&t[0]===t[1])return()=>t[1];const c=e[0]===e[1];e[0]>e[o-1]&&(e=[...e].reverse(),t=[...t].reverse());const u=CX(t,r,a),f=u.length,h=p=>{if(c&&p<e[0])return t[0];let x=0;if(f>1)for(;x<e.length-2&&!(p<e[x+1]);x++);const v=Yd(e[x],e[x+1],p);return u[x](v)};return n?p=>h(fa(e[0],e[o-1],p)):h}function AX(e,t){const n=e[e.length-1];for(let r=1;r<=t;r++){const a=Yd(0,t,r);e.push(ln(n,1,a))}}function TX(e){const t=[0];return AX(t,e.length-1),t}function MX(e,t){return e.map(n=>n*t)}function RX(e,t){return e.map(()=>t||F$).splice(0,e.length-1)}function Ad({duration:e=300,keyframes:t,times:n,ease:r="easeInOut"}){const a=zY(r)?r.map(TA):TA(r),o={done:!1,value:t[0]},c=MX(n&&n.length===t.length?n:TX(t),e),u=EX(c,t,{ease:Array.isArray(a)?a:RX(t,a)});return{calculatedDuration:e,next:f=>(o.value=u(f),o.done=f>=e,o)}}const IX=e=>e!==null;function $g(e,{repeat:t,repeatType:n="loop"},r,a=1){const o=e.filter(IX),u=a<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!u||r===void 0?o[u]:r}const _X={decay:N0,inertia:N0,tween:Ad,keyframes:Ad,spring:zp};function tL(e){typeof e.type=="string"&&(e.type=_X[e.type])}class Lj{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const OX=e=>e/100;class Bp extends Lj{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==Ns.now()&&this.tick(Ns.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;tL(t);const{type:n=Ad,repeat:r=0,repeatDelay:a=0,repeatType:o,velocity:c=0}=t;let{keyframes:u}=t;const f=n||Ad;f!==Ad&&typeof u[0]!="number"&&(this.mixKeyframes=gf(OX,Q$(u[0],u[1])),u=[0,100]);const h=f({...t,keyframes:u});o==="mirror"&&(this.mirroredGenerator=f({...t,keyframes:[...u].reverse(),velocity:-c})),h.calculatedDuration===null&&(h.calculatedDuration=$j(h));const{calculatedDuration:p}=h;this.calculatedDuration=p,this.resolvedDuration=p+a,this.totalDuration=this.resolvedDuration*(r+1)-a,this.generator=h}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:r,totalDuration:a,mixKeyframes:o,mirroredGenerator:c,resolvedDuration:u,calculatedDuration:f}=this;if(this.startTime===null)return r.next(0);const{delay:h=0,keyframes:p,repeat:x,repeatType:v,repeatDelay:y,type:b,onUpdate:C,finalKeyframe:E}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-a/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const A=this.currentTime-h*(this.playbackSpeed>=0?1:-1),S=this.playbackSpeed>=0?A<0:A>a;this.currentTime=Math.max(A,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let k=this.currentTime,N=r;if(x){const L=Math.min(this.currentTime,a)/u;let I=Math.floor(L),z=L%1;!z&&L>=1&&(z=1),z===1&&I--,I=Math.min(I,x+1),I%2&&(v==="reverse"?(z=1-z,y&&(z-=y/u)):v==="mirror"&&(N=c)),k=fa(0,1,z)*u}let T;S?(this.delayState.value=p[0],T=this.delayState):T=N.next(k),o&&!S&&(T.value=o(T.value));let{done:R}=T;!S&&f!==null&&(R=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const O=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&R);return O&&b!==N0&&(T.value=$g(p,this.options,E,this.speed)),C&&C(T.value),O&&this.finish(),T}then(t,n){return this.finished.then(t,n)}get duration(){return xr(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+xr(t)}get time(){return xr(this.currentTime)}set time(t){t=er(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=t,this.tick(t))}getGeneratorVelocity(){const t=this.currentTime;if(t<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(t);const n=this.generator.next(t).value;return eL(r=>this.generator.next(r).value,t,n)}get speed(){return this.playbackSpeed}set speed(t){const n=this.playbackSpeed!==t;n&&this.driver&&this.updateTime(Ns.now()),this.playbackSpeed=t,n&&this.driver&&(this.time=xr(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=vX,startTime:n}=this.options;this.driver||(this.driver=t(a=>this.tick(a))),this.options.onPlay?.();const r=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=r):this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime||(this.startTime=n??r),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Ns.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),t.observe(this)}}function $X(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Bo=e=>e*180/Math.PI,S0=e=>{const t=Bo(Math.atan2(e[1],e[0]));return C0(t)},LX={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:S0,rotateZ:S0,skewX:e=>Bo(Math.atan(e[1])),skewY:e=>Bo(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},C0=e=>(e=e%360,e<0&&(e+=360),e),LA=S0,PA=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),DA=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),PX={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:PA,scaleY:DA,scale:e=>(PA(e)+DA(e))/2,rotateX:e=>C0(Bo(Math.atan2(e[6],e[5]))),rotateY:e=>C0(Bo(Math.atan2(-e[2],e[0]))),rotateZ:LA,rotate:LA,skewX:e=>Bo(Math.atan(e[4])),skewY:e=>Bo(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function E0(e){return e.includes("scale")?1:0}function A0(e,t){if(!e||e==="none")return E0(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,a;if(n)r=PX,a=n;else{const u=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=LX,a=u}if(!a)return E0(t);const o=r[t],c=a[1].split(",").map(zX);return typeof o=="function"?o(c):c[o]}const DX=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return A0(n,t)};function zX(e){return parseFloat(e.trim())}const Zc=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Yc=new Set([...Zc,"pathRotation"]),zA=e=>e===Gc||e===Ye,BX=new Set(["x","y","z"]),UX=Zc.filter(e=>!BX.has(e));function FX(e){const t=[];return UX.forEach(n=>{const r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),t}const Ti={width:({x:e},{paddingLeft:t="0",paddingRight:n="0",boxSizing:r})=>{const a=e.max-e.min;return r==="border-box"?a:a-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t="0",paddingBottom:n="0",boxSizing:r})=>{const a=e.max-e.min;return r==="border-box"?a:a-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>A0(t,"x"),y:(e,{transform:t})=>A0(t,"y")};Ti.translateX=Ti.x;Ti.translateY=Ti.y;const Ho=new Set;let T0=!1,M0=!1,R0=!1;function nL(){if(M0){const e=Array.from(Ho).filter(r=>r.needsMeasurement),t=new Set(e.map(r=>r.element)),n=new Map;t.forEach(r=>{const a=FX(r);a.length&&(n.set(r,a),r.render())}),e.forEach(r=>r.measureInitialState()),t.forEach(r=>{r.render();const a=n.get(r);a&&a.forEach(([o,c])=>{r.getValue(o)?.set(c)})}),e.forEach(r=>r.measureEndState()),e.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}M0=!1,T0=!1,Ho.forEach(e=>e.complete(R0)),Ho.clear()}function sL(){Ho.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(M0=!0)})}function VX(){R0=!0,sL(),nL(),R0=!1}class Pj{constructor(t,n,r,a,o,c=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=r,this.motionValue=a,this.element=o,this.isAsync=c}scheduleResolve(){this.state="scheduled",this.isAsync?(Ho.add(this),T0||(T0=!0,cn.read(sL),cn.resolveKeyframes(nL))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:r,motionValue:a}=this;if(t[0]===null){const o=a?.get(),c=t[t.length-1];if(o!==void 0)t[0]=o;else if(r&&n){const u=r.readValue(n,c);u!=null&&(t[0]=u)}t[0]===void 0&&(t[0]=c),a&&o===void 0&&a.set(t[0])}$X(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Ho.delete(this)}cancel(){this.state==="scheduled"&&(Ho.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const HX=e=>e.startsWith("--");function rL(e,t,n){HX(t)?e.style.setProperty(t,n):e.style[t]=n}const WX={};function aL(e,t){const n=I$(e);return()=>WX[t]??n()}const qX=aL(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),iL=aL(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),pd=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,BA={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:pd([0,.65,.55,1]),circOut:pd([.55,0,1,.45]),backIn:pd([.31,.01,.66,-.59]),backOut:pd([.33,1.53,.69,.99])};function oL(e,t){if(e)return typeof e=="function"?iL()?J$(e,t):"ease-out":V$(e)?pd(e):Array.isArray(e)?e.map(n=>oL(n,t)||BA.easeOut):BA[e]}function KX(e,t,n,{delay:r=0,duration:a=300,repeat:o=0,repeatType:c="loop",ease:u="easeOut",times:f}={},h=void 0){const p={[t]:n};f&&(p.offset=f);const x=oL(u,a);Array.isArray(x)&&(p.easing=x);const v={delay:r,duration:a,easing:Array.isArray(x)?"linear":x,fill:"both",iterations:o+1,direction:c==="reverse"?"alternate":"normal"};return h&&(v.pseudoElement=h),e.animate(p,v)}function lL(e){return typeof e=="function"&&"applyToOptions"in e}function GX({type:e,...t}){return lL(e)&&iL()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class cL extends Lj{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:n,name:r,keyframes:a,pseudoElement:o,allowFlatten:c=!1,finalKeyframe:u,onComplete:f}=t;this.isPseudoElement=!!o,this.allowFlatten=c,this.options=t,Ej(typeof t.type!="string");const h=GX(t);this.animation=KX(n,r,a,h,o),h.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const p=$g(a,this.options,u,this.speed);this.updateMotionValue&&this.updateMotionValue(p),rL(n,r,p),this.animation.cancel()}f?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){const t=this.options?.element;!this.isPseudoElement&&t?.isConnected&&this.animation.commitStyles?.()}get duration(){const t=this.animation.effect?.getComputedTiming?.().duration||0;return xr(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+xr(t)}get time(){return xr(Number(this.animation.currentTime)||0)}set time(t){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=er(t),n&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(t){this.manualStartTime=this.animation.startTime=t}attachTimeline({timeline:t,rangeStart:n,rangeEnd:r,observe:a}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,t&&qX()?(this.animation.timeline=t,n&&(this.animation.rangeStart=n),r&&(this.animation.rangeEnd=r),jr):a(this)}}const uL={anticipate:z$,backInOut:D$,circInOut:U$};function ZX(e){return e in uL}function YX(e){typeof e.ease=="string"&&ZX(e.ease)&&(e.ease=uL[e.ease])}const By=10;class XX extends cL{constructor(t){YX(t),tL(t),super(t),t.startTime!==void 0&&t.autoplay!==!1&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:r,onComplete:a,element:o,...c}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const u=new Bp({...c,autoplay:!1}),f=Math.max(By,Ns.now()-this.startTime),h=fa(0,By,f-By),p=u.sample(f).value,{name:x}=this.options;o&&x&&rL(o,x,p),n.setWithVelocity(u.sample(Math.max(0,f-h)).value,p,h),u.stop()}}const UA=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Dr.test(e)||e==="0")&&!e.startsWith("url("));function QX(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function JX(e,t,n,r){const a=e[0];if(a===null)return!1;if(t==="display"||t==="visibility")return!0;const o=e[e.length-1],c=UA(a,t),u=UA(o,t);return!c||!u?!1:QX(e)||(n==="spring"||lL(n))&&r}function I0(e){e.duration=0,e.type="keyframes"}const dL=new Set(["opacity","clipPath","filter","transform"]),eQ=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function tQ(e){for(let t=0;t<e.length;t++)if(typeof e[t]=="string"&&eQ.test(e[t]))return!0;return!1}const nQ=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),sQ=I$(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function rQ(e){const{motionValue:t,name:n,repeatDelay:r,repeatType:a,damping:o,type:c,keyframes:u}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:h,transformTemplate:p}=t.owner.getProps();return sQ()&&n&&(dL.has(n)||nQ.has(n)&&tQ(u))&&(n!=="transform"||!p)&&!h&&!r&&a!=="mirror"&&o!==0&&c!=="inertia"}const aQ=40;class iQ extends Lj{constructor({autoplay:t=!0,delay:n=0,type:r="keyframes",repeat:a=0,repeatDelay:o=0,repeatType:c="loop",keyframes:u,name:f,motionValue:h,element:p,...x}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Ns.now();const v={autoplay:t,delay:n,type:r,repeat:a,repeatDelay:o,repeatType:c,name:f,motionValue:h,element:p,...x},y=p?.KeyframeResolver||Pj;this.keyframeResolver=new y(u,(b,C,E)=>this.onKeyframesResolved(b,C,v,!E),f,h,p),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,n,r,a){this.keyframeResolver=void 0;const{name:o,type:c,velocity:u,delay:f,isHandoff:h,onUpdate:p}=r;this.resolvedAt=Ns.now();let x=!0;JX(t,o,c,u)||(x=!1,(Vi.instantAnimations||!f)&&p?.($g(t,r,n)),t[0]=t[t.length-1],I0(r),r.repeat=0);const y={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>aQ?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:t},b=x&&!h&&rQ(y),C=y.motionValue?.owner?.current;let E;if(b)try{E=new XX({...y,element:C})}catch{E=new Bp(y)}else E=new Bp(y);E.finished.then(()=>{this.notifyFinished()}).catch(jr),this.pendingTimeline&&(this.stopTimeline=E.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=E}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),VX()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}function fL(e,t,n,r=0,a=1){const o=Array.from(e).sort((h,p)=>h.sortNodePosition(p)).indexOf(t),c=e.size,u=(c-1)*r;return typeof n=="function"?n(o,c):a===1?o*r:u-o*r}const FA=30,oQ=e=>!isNaN(parseFloat(e));class lQ{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{const a=Ns.now();if(this.updatedAt!==a&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Ns.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=oQ(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new Aj);const r=this.events[t].add(n);return t==="change"?()=>{r(),cn.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-r}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=Ns.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>FA)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,FA);return _$(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Pc(e,t){return new lQ(e,t)}function hL(e,t){if(e?.inherit&&t){const{inherit:n,...r}=e;return{...t,...r}}return e}function Dj(e,t){const n=e?.[t]??e?.default??e;return n!==e?hL(n,e):n}const cQ={type:"spring",stiffness:500,damping:25,restSpeed:10},uQ=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),dQ={type:"keyframes",duration:.8},fQ={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},hQ=(e,{keyframes:t})=>t.length>2?dQ:Yc.has(e)?e.startsWith("scale")?uQ(t[1]):cQ:fQ,mQ=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function pQ(e){for(const t in e)if(!mQ.has(t))return!0;return!1}const zj=(e,t,n,r={},a,o)=>c=>{const u=Dj(r,e)||{},f=u.delay||r.delay||0;let{elapsed:h=0}=r;h=h-er(f);const p={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...u,delay:-h,onUpdate:v=>{t.set(v),u.onUpdate&&u.onUpdate(v)},onComplete:()=>{c(),u.onComplete&&u.onComplete()},name:e,motionValue:t,element:o?void 0:a};pQ(u)||Object.assign(p,hQ(e,p)),p.duration&&(p.duration=er(p.duration)),p.repeatDelay&&(p.repeatDelay=er(p.repeatDelay)),p.from!==void 0&&(p.keyframes[0]=p.from);let x=!1;if((p.type===!1||p.duration===0&&!p.repeatDelay)&&(I0(p),p.delay===0&&(x=!0)),(Vi.instantAnimations||Vi.skipAnimations||a?.shouldSkipAnimations||u.skipAnimations)&&(x=!0,I0(p),p.delay=0),p.allowFlatten=!u.type&&!u.ease,x&&!o&&t.get()!==void 0){const v=$g(p.keyframes,u);if(v!==void 0){cn.update(()=>{p.onUpdate(v),p.onComplete()});return}}return u.isSync?new Bp(p):new iQ(p)},gQ=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function vQ(e){const t=gQ.exec(e);if(!t)return[,];const[,n,r,a]=t;return[`--${n??r}`,a]}function mL(e,t,n=1){const[r,a]=vQ(e);if(!r)return;const o=window.getComputedStyle(t).getPropertyValue(r);if(o){const c=o.trim();return T$(c)?parseFloat(c):c}return Rj(a)?mL(a,t,n+1):a}function VA(e){const t=[{},{}];return e?.values.forEach((n,r)=>{t[0][r]=n.get(),t[1][r]=n.getVelocity()}),t}function Bj(e,t,n,r){if(typeof t=="function"){const[a,o]=VA(r);t=t(n!==void 0?n:e.custom,a,o)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[a,o]=VA(r);t=t(n!==void 0?n:e.custom,a,o)}return t}function Wo(e,t,n){const r=e.getProps();return Bj(r,t,n!==void 0?n:r.custom,e)}const pL=new Set(["width","height","top","left","right","bottom",...Zc]),_0=e=>Array.isArray(e);function xQ(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Pc(n))}function yQ(e){return _0(e)?e[e.length-1]||0:e}function bQ(e,t){const n=Wo(e,t);let{transitionEnd:r={},transition:a={},...o}=n||{};o={...o,...r};for(const c in o){const u=yQ(o[c]);xQ(e,c,u)}}const os=e=>!!(e&&e.getVelocity);function wQ(e){return!!(os(e)&&e.add)}function O0(e,t){const n=e.getValue("willChange");if(wQ(n))return n.add(t);if(!n&&Vi.WillChange){const r=new Vi.WillChange("auto");e.addValue("willChange",r),r.add(t)}}function Uj(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const jQ="framerAppearId",gL="data-"+Uj(jQ);function vL(e){return e.props[gL]}function kQ({protectedKeys:e,needsAnimating:t},n){const r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function xL(e,t,{delay:n=0,transitionOverride:r,type:a}={}){let{transition:o,transitionEnd:c,...u}=t;const f=e.getDefaultTransition();o=o?hL(o,f):f;const h=o?.reduceMotion,p=o?.skipAnimations;r&&(o=r);const x=[],v=a&&e.animationState&&e.animationState.getState()[a],y=o?.path;y&&y.animateVisualElement(e,u,o,n,x);for(const b in u){const C=e.getValue(b,e.latestValues[b]??null),E=u[b];if(E===void 0||v&&kQ(v,b))continue;const A={delay:n,...Dj(o||{},b)};p&&(A.skipAnimations=!0);const S=C.get();if(S!==void 0&&!C.isAnimating()&&!Array.isArray(E)&&E===S&&!A.velocity){cn.update(()=>C.set(E));continue}let k=!1;if(window.MotionHandoffAnimation){const R=vL(e);if(R){const O=window.MotionHandoffAnimation(R,b,cn);O!==null&&(A.startTime=O,k=!0)}}O0(e,b);const N=h??e.shouldReduceMotion;C.start(zj(b,C,E,N&&pL.has(b)?{type:!1}:A,e,k));const T=C.animation;T&&x.push(T)}if(c){const b=()=>cn.update(()=>{c&&bQ(e,c)});x.length?Promise.all(x).then(b):b()}return x}function $0(e,t,n={}){const r=Wo(e,t,n.type==="exit"?e.presenceContext?.custom:void 0);let{transition:a=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(a=n.transitionOverride);const o=r?()=>Promise.all(xL(e,r,n)):()=>Promise.resolve(),c=e.variantChildren&&e.variantChildren.size?(f=0)=>{const{delayChildren:h=0,staggerChildren:p,staggerDirection:x}=a;return NQ(e,t,f,h,p,x,n)}:()=>Promise.resolve(),{when:u}=a;if(u){const[f,h]=u==="beforeChildren"?[o,c]:[c,o];return f().then(()=>h())}else return Promise.all([o(),c(n.delay)])}function NQ(e,t,n=0,r=0,a=0,o=1,c){const u=[];for(const f of e.variantChildren)f.notify("AnimationStart",t),u.push($0(f,t,{...c,delay:n+(typeof r=="function"?0:r)+fL(e.variantChildren,f,r,a,o)}).then(()=>f.notify("AnimationComplete",t)));return Promise.all(u)}function SQ(e,t,n={}){e.notify("AnimationStart",t);let r;if(Array.isArray(t)){const a=t.map(o=>$0(e,o,n));r=Promise.all(a)}else if(typeof t=="string")r=$0(e,t,n);else{const a=typeof t=="function"?Wo(e,t,n.custom):t;r=Promise.all(xL(e,a,n))}return r.then(()=>{e.notify("AnimationComplete",t)})}const CQ={test:e=>e==="auto",parse:e=>e},yL=e=>t=>t.test(e),bL=[Gc,Ye,ia,Fa,QY,XY,CQ],HA=e=>bL.find(yL(e));function EQ(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||R$(e):!0}const AQ=new Set(["brightness","contrast","saturate","opacity"]);function TQ(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[r]=n.match(Ij)||[];if(!r)return e;const a=n.replace(r,"");let o=AQ.has(t)?1:0;return r!==n&&(o*=100),t+"("+o+a+")"}const MQ=/\b([a-z-]*)\(.*?\)/gu,L0={...Dr,getAnimatableNone:e=>{const t=e.match(MQ);return t?t.map(TQ).join(" "):e}},P0={...Dr,getAnimatableNone:e=>{const t=Dr.parse(e);return Dr.createTransformer(e)(t.map(r=>typeof r=="number"?0:typeof r=="object"?{...r,alpha:1}:r))}},WA={...Gc,transform:Math.round},RQ={rotate:Fa,pathRotation:Fa,rotateX:Fa,rotateY:Fa,rotateZ:Fa,scale:Jh,scaleX:Jh,scaleY:Jh,scaleZ:Jh,skew:Fa,skewX:Fa,skewY:Fa,distance:Ye,translateX:Ye,translateY:Ye,translateZ:Ye,x:Ye,y:Ye,z:Ye,perspective:Ye,transformPerspective:Ye,opacity:Xd,originX:RA,originY:RA,originZ:Ye},Up={borderWidth:Ye,borderTopWidth:Ye,borderRightWidth:Ye,borderBottomWidth:Ye,borderLeftWidth:Ye,borderRadius:Ye,borderTopLeftRadius:Ye,borderTopRightRadius:Ye,borderBottomRightRadius:Ye,borderBottomLeftRadius:Ye,width:Ye,maxWidth:Ye,height:Ye,maxHeight:Ye,top:Ye,right:Ye,bottom:Ye,left:Ye,inset:Ye,insetBlock:Ye,insetBlockStart:Ye,insetBlockEnd:Ye,insetInline:Ye,insetInlineStart:Ye,insetInlineEnd:Ye,padding:Ye,paddingTop:Ye,paddingRight:Ye,paddingBottom:Ye,paddingLeft:Ye,paddingBlock:Ye,paddingBlockStart:Ye,paddingBlockEnd:Ye,paddingInline:Ye,paddingInlineStart:Ye,paddingInlineEnd:Ye,margin:Ye,marginTop:Ye,marginRight:Ye,marginBottom:Ye,marginLeft:Ye,marginBlock:Ye,marginBlockStart:Ye,marginBlockEnd:Ye,marginInline:Ye,marginInlineStart:Ye,marginInlineEnd:Ye,fontSize:Ye,backgroundPositionX:Ye,backgroundPositionY:Ye,...RQ,zIndex:WA,fillOpacity:Xd,strokeOpacity:Xd,numOctaves:WA},IQ={...Up,color:Hn,backgroundColor:Hn,outlineColor:Hn,fill:Hn,stroke:Hn,borderColor:Hn,borderTopColor:Hn,borderRightColor:Hn,borderBottomColor:Hn,borderLeftColor:Hn,filter:L0,WebkitFilter:L0,mask:P0,WebkitMask:P0},wL=e=>IQ[e],_Q=new Set([L0,P0]);function jL(e,t){let n=wL(e);return _Q.has(n)||(n=Dr),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const OQ=new Set(["auto","none","0"]);function $Q(e,t,n){let r=0,a;for(;r<e.length&&!a;){const o=e[r];typeof o=="string"&&!OQ.has(o)&&Lc(o).values.length&&(a=e[r]),r++}if(a&&n)for(const o of t)e[o]=jL(n,a)}class LQ extends Pj{constructor(t,n,r,a,o){super(t,n,r,a,o,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:r}=this;if(!n||!n.current)return;super.readKeyframes();for(let p=0;p<t.length;p++){let x=t[p];if(typeof x=="string"&&(x=x.trim(),Rj(x))){const v=mL(x,n.current);v!==void 0&&(t[p]=v),p===t.length-1&&(this.finalKeyframe=x)}}if(this.resolveNoneKeyframes(),!pL.has(r)||t.length!==2)return;const[a,o]=t,c=HA(a),u=HA(o),f=MA(a),h=MA(o);if(f!==h&&Ti[r]){this.needsMeasurement=!0;return}if(c!==u)if(zA(c)&&zA(u))for(let p=0;p<t.length;p++){const x=t[p];typeof x=="string"&&(t[p]=parseFloat(x))}else Ti[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,r=[];for(let a=0;a<t.length;a++)(t[a]===null||EQ(t[a]))&&r.push(a);r.length&&$Q(t,r,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:r}=this;if(!t||!t.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Ti[r](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const a=n[n.length-1];a!==void 0&&t.getValue(r,a).jump(a,!1)}measureEndState(){const{element:t,name:n,unresolvedKeyframes:r}=this;if(!t||!t.current)return;const a=t.getValue(n);a&&a.jump(this.measuredOrigin,!1);const o=r.length-1,c=r[o];r[o]=Ti[n](t.measureViewportBox(),window.getComputedStyle(t.current)),c!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=c),this.removedTransforms?.length&&this.removedTransforms.forEach(([u,f])=>{t.getValue(u).set(f)}),this.resolveNoneKeyframes()}}function kL(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){let r=document;const a=n?.[e]??r.querySelectorAll(e);return a?Array.from(a):[]}return Array.from(e).filter(r=>r!=null)}const D0=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function Km(e){return M$(e)&&"offsetHeight"in e&&!("ownerSVGElement"in e)}const{schedule:Fj}=H$(queueMicrotask,!1),$r={x:!1,y:!1};function NL(){return $r.x||$r.y}function PQ(e){return e==="x"||e==="y"?$r[e]?null:($r[e]=!0,()=>{$r[e]=!1}):$r.x||$r.y?null:($r.x=$r.y=!0,()=>{$r.x=$r.y=!1})}function SL(e,t){const n=kL(e),r=new AbortController,a={passive:!0,...t,signal:r.signal};return[n,a,()=>r.abort()]}function DQ(e){return!(e.pointerType==="touch"||NL())}function zQ(e,t,n={}){const[r,a,o]=SL(e,n);return r.forEach(c=>{let u=!1,f=!1,h;const p=()=>{c.removeEventListener("pointerleave",b)},x=E=>{h&&(h(E),h=void 0),p()},v=E=>{u=!1,window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v),f&&(f=!1,x(E))},y=()=>{u=!0,window.addEventListener("pointerup",v,a),window.addEventListener("pointercancel",v,a)},b=E=>{if(E.pointerType!=="touch"){if(u){f=!0;return}x(E)}},C=E=>{if(!DQ(E))return;f=!1;const A=t(c,E);typeof A=="function"&&(h=A,c.addEventListener("pointerleave",b,a))};c.addEventListener("pointerenter",C,a),c.addEventListener("pointerdown",y,a)}),o}const CL=(e,t)=>t?e===t?!0:CL(e,t.parentElement):!1,Vj=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,BQ=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function UQ(e){return BQ.has(e.tagName)||e.isContentEditable===!0}const FQ=new Set(["INPUT","SELECT","TEXTAREA"]);function VQ(e){return FQ.has(e.tagName)||e.isContentEditable===!0}const Gm=new WeakSet;function qA(e){return t=>{t.key==="Enter"&&e(t)}}function Uy(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const HQ=(e,t)=>{const n=e.currentTarget;if(!n)return;const r=qA(()=>{if(Gm.has(n))return;Uy(n,"down");const a=qA(()=>{Uy(n,"up")}),o=()=>Uy(n,"cancel");n.addEventListener("keyup",a,t),n.addEventListener("blur",o,t)});n.addEventListener("keydown",r,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),t)};function KA(e){return Vj(e)&&!NL()}const GA=new WeakSet;function WQ(e,t,n={}){const[r,a,o]=SL(e,n),c=u=>{const f=u.currentTarget;if(!KA(u)||GA.has(u))return;Gm.add(f),n.stopPropagation&&GA.add(u);const h=t(f,u),p=(y,b)=>{window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",v),Gm.has(f)&&Gm.delete(f),KA(y)&&typeof h=="function"&&h(y,{success:b})},x=y=>{p(y,f===window||f===document||n.useGlobalTarget||CL(f,y.target))},v=y=>{p(y,!1)};window.addEventListener("pointerup",x,a),window.addEventListener("pointercancel",v,a)};return r.forEach(u=>{(n.useGlobalTarget?window:u).addEventListener("pointerdown",c,a),Km(u)&&(u.addEventListener("focus",h=>HQ(h,a)),!UQ(u)&&!u.hasAttribute("tabindex")&&(u.tabIndex=0))}),o}function Hj(e){return M$(e)&&"ownerSVGElement"in e}const Zm=new WeakMap;let Ym;const EL=(e,t,n)=>(r,a)=>a&&a[0]?a[0][e+"Size"]:Hj(r)&&"getBBox"in r?r.getBBox()[t]:r[n],qQ=EL("inline","width","offsetWidth"),KQ=EL("block","height","offsetHeight");function GQ({target:e,borderBoxSize:t}){Zm.get(e)?.forEach(n=>{n(e,{get width(){return qQ(e,t)},get height(){return KQ(e,t)}})})}function ZQ(e){e.forEach(GQ)}function YQ(){typeof ResizeObserver>"u"||(Ym=new ResizeObserver(ZQ))}function XQ(e,t){Ym||YQ();const n=kL(e);return n.forEach(r=>{let a=Zm.get(r);a||(a=new Set,Zm.set(r,a)),a.add(t),Ym?.observe(r)}),()=>{n.forEach(r=>{const a=Zm.get(r);a?.delete(t),a?.size||Ym?.unobserve(r)})}}const Xm=new Set;let dc;function QQ(){dc=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Xm.forEach(t=>t(e))},window.addEventListener("resize",dc)}function JQ(e){return Xm.add(e),dc||QQ(),()=>{Xm.delete(e),!Xm.size&&typeof dc=="function"&&(window.removeEventListener("resize",dc),dc=void 0)}}function ZA(e,t){return typeof e=="function"?JQ(e):XQ(e,t)}function eJ(e){return Hj(e)&&e.tagName==="svg"}const tJ=[...bL,Hn,Dr],nJ=e=>tJ.find(yL(e)),YA=()=>({translate:0,scale:1,origin:0,originPoint:0}),fc=()=>({x:YA(),y:YA()}),XA=()=>({min:0,max:0}),Yn=()=>({x:XA(),y:XA()}),sJ=new WeakMap;function Lg(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function Qd(e){return typeof e=="string"||Array.isArray(e)}const Wj=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],qj=["initial",...Wj];function Pg(e){return Lg(e.animate)||qj.some(t=>Qd(e[t]))}function AL(e){return!!(Pg(e)||e.variants)}function rJ(e,t,n){for(const r in t){const a=t[r],o=n[r];if(os(a))e.addValue(r,a);else if(os(o))e.addValue(r,Pc(a,{owner:e}));else if(o!==a)if(e.hasValue(r)){const c=e.getValue(r);c.liveStyle===!0?c.jump(a):c.hasAnimated||c.set(a)}else{const c=e.getStaticValue(r);e.addValue(r,Pc(c!==void 0?c:a,{owner:e}))}}for(const r in n)t[r]===void 0&&e.removeValue(r);return t}const z0={current:null},TL={current:!1},aJ=typeof window<"u";function iJ(){if(TL.current=!0,!!aJ)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>z0.current=e.matches;e.addEventListener("change",t),t()}else z0.current=!1}const QA=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Fp={};function ML(e){Fp=e}function oJ(){return Fp}class lJ{scrapeMotionValuesFromProps(t,n,r){return{}}constructor({parent:t,props:n,presenceContext:r,reducedMotionConfig:a,skipAnimations:o,blockInitialAnimation:c,visualState:u},f={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=Pj,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const y=Ns.now();this.renderScheduledAt<y&&(this.renderScheduledAt=y,cn.render(this.render,!1,!0))};const{latestValues:h,renderState:p}=u;this.latestValues=h,this.baseTarget={...h},this.initialValues=n.initial?{...h}:{},this.renderState=p,this.parent=t,this.props=n,this.presenceContext=r,this.depth=t?t.depth+1:0,this.reducedMotionConfig=a,this.skipAnimationsConfig=o,this.options=f,this.blockInitialAnimation=!!c,this.isControllingVariants=Pg(n),this.isVariantNode=AL(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:x,...v}=this.scrapeMotionValuesFromProps(n,{},this);for(const y in v){const b=v[y];h[y]!==void 0&&os(b)&&b.set(h[y])}}mount(t){if(this.hasBeenMounted)for(const n in this.initialValues)this.values.get(n)?.jump(this.initialValues[n]),this.latestValues[n]=this.initialValues[n];this.current=t,sJ.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,r)=>this.bindToMotionValue(r,n)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(TL.current||iJ(),this.shouldReduceMotion=z0.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),Hi(this.notifyUpdate),Hi(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){if(this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)(),n.accelerate&&dL.has(t)&&this.current instanceof HTMLElement){const{factory:c,keyframes:u,times:f,ease:h,duration:p}=n.accelerate,x=new cL({element:this.current,name:t,keyframes:u,times:f,ease:h,duration:er(p)}),v=c(x);this.valueSubscriptions.set(t,()=>{v(),x.cancel()});return}const r=Yc.has(t);r&&this.onBindTransform&&this.onBindTransform();const a=n.on("change",c=>{this.latestValues[t]=c,this.props.onUpdate&&cn.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;typeof window<"u"&&window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{a(),o&&o()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Fp){const n=Fp[t];if(!n)continue;const{isEnabled:r,Feature:a}=n;if(!this.features[t]&&a&&r(this.props)&&(this.features[t]=new a(this)),this.features[t]){const o=this.features[t];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Yn()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<QA.length;r++){const a=QA[r];this.propEventSubscriptions[a]&&(this.propEventSubscriptions[a](),delete this.propEventSubscriptions[a]);const o="on"+a,c=t[o];c&&(this.propEventSubscriptions[a]=this.on(a,c))}this.prevMotionValues=rJ(this,this.scrapeMotionValuesFromProps(t,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const r=this.values.get(t);n!==r&&(r&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let r=this.values.get(t);return r===void 0&&n!==void 0&&(r=Pc(n===null?void 0:n,{owner:this}),this.addValue(t,r)),r}readValue(t,n){let r=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return r!=null&&(typeof r=="string"&&(T$(r)||R$(r))?r=parseFloat(r):!nJ(r)&&Dr.test(n)&&(r=jL(t,n)),this.setBaseTarget(t,os(r)?r.get():r)),os(r)?r.get():r}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){const{initial:n}=this.props;let r;if(typeof n=="string"||typeof n=="object"){const o=Bj(this.props,n,this.presenceContext?.custom);o&&(r=o[t])}if(n&&r!==void 0)return r;const a=this.getBaseTargetFromProps(this.props,t);return a!==void 0&&!os(a)?a:this.initialValues[t]!==void 0&&r===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new Aj),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){Fj.render(this.render)}}class RL extends lJ{constructor(){super(...arguments),this.KeyframeResolver=LQ}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){const r=t.style;return r?r[n]:void 0}removeValueFromRenderState(t,{vars:n,style:r}){delete n[t],delete r[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;os(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class eo{constructor(t){this.isMounted=!1,this.node=t}update(){}}function IL({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function cJ({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function uJ(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function Fy(e){return e===void 0||e===1}function B0({scale:e,scaleX:t,scaleY:n}){return!Fy(e)||!Fy(t)||!Fy(n)}function _o(e){return B0(e)||_L(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function _L(e){return JA(e.x)||JA(e.y)}function JA(e){return e&&e!=="0%"}function Vp(e,t,n){const r=e-n,a=t*r;return n+a}function eT(e,t,n,r,a){return a!==void 0&&(e=Vp(e,a,r)),Vp(e,n,r)+t}function U0(e,t=0,n=1,r,a){e.min=eT(e.min,t,n,r,a),e.max=eT(e.max,t,n,r,a)}function OL(e,{x:t,y:n}){U0(e.x,t.translate,t.scale,t.originPoint),U0(e.y,n.translate,n.scale,n.originPoint)}const tT=.999999999999,nT=1.0000000000001;function dJ(e,t,n,r=!1){const a=n.length;if(!a)return;t.x=t.y=1;let o,c;for(let u=0;u<a;u++){o=n[u],c=o.projectionDelta;const{visualElement:f}=o.options;f&&f.props.style&&f.props.style.display==="contents"||(r&&o.options.layoutScroll&&o.scroll&&o!==o.root&&(sa(e.x,-o.scroll.offset.x),sa(e.y,-o.scroll.offset.y)),c&&(t.x*=c.x.scale,t.y*=c.y.scale,OL(e,c)),r&&_o(o.latestValues)&&Qm(e,o.latestValues,o.layout?.layoutBox))}t.x<nT&&t.x>tT&&(t.x=1),t.y<nT&&t.y>tT&&(t.y=1)}function sa(e,t){e.min+=t,e.max+=t}function sT(e,t,n,r,a=.5){const o=ln(e.min,e.max,a);U0(e,t,n,o,r)}function rT(e,t){return typeof e=="string"?parseFloat(e)/100*(t.max-t.min):e}function Qm(e,t,n){const r=n??e;sT(e.x,rT(t.x,r.x),t.scaleX,t.scale,t.originX),sT(e.y,rT(t.y,r.y),t.scaleY,t.scale,t.originY)}function $L(e,t){return IL(uJ(e.getBoundingClientRect(),t))}function fJ(e,t,n){const r=$L(e,n),{scroll:a}=t;return a&&(sa(r.x,a.offset.x),sa(r.y,a.offset.y)),r}const hJ={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},mJ=Zc.length;function pJ(e,t,n){let r="",a=!0;for(let c=0;c<mJ;c++){const u=Zc[c],f=e[u];if(f===void 0)continue;let h=!0;if(typeof f=="number")h=f===(u.startsWith("scale")?1:0);else{const p=parseFloat(f);h=u.startsWith("scale")?p===1:p===0}if(!h||n){const p=D0(f,Up[u]);if(!h){a=!1;const x=hJ[u]||u;r+=`${x}(${p}) `}n&&(t[u]=p)}}const o=e.pathRotation;return o&&(a=!1,r+=`rotate(${D0(o,Up.pathRotation)}) `),r=r.trim(),n?r=n(t,a?"":r):a&&(r="none"),r}function Kj(e,t,n){const{style:r,vars:a,transformOrigin:o}=e;let c=!1,u=!1;for(const f in t){const h=t[f];if(Yc.has(f)){c=!0;continue}else if(q$(f)){a[f]=h;continue}else{const p=D0(h,Up[f]);f.startsWith("origin")?(u=!0,o[f]=p):r[f]=p}}if(t.transform||(c||n?r.transform=pJ(t,e.transform,n):r.transform&&(r.transform="none")),u){const{originX:f="50%",originY:h="50%",originZ:p=0}=o;r.transformOrigin=`${f} ${h} ${p}`}}function LL(e,{style:t,vars:n},r,a){const o=e.style;let c;for(c in t)o[c]=t[c];a?.applyProjectionStyles(o,r);for(c in n)o.setProperty(c,n[c])}function aT(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const Ku={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(Ye.test(e))e=parseFloat(e);else return e;const n=aT(e,t.target.x),r=aT(e,t.target.y);return`${n}% ${r}%`}},gJ={correct:(e,{treeScale:t,projectionDelta:n})=>{const r=e,a=Dr.parse(e);if(a.length>5)return r;const o=Dr.createTransformer(e),c=typeof a[0]!="number"?1:0,u=n.x.scale*t.x,f=n.y.scale*t.y;a[0+c]/=u,a[1+c]/=f;const h=ln(u,f,.5);return typeof a[2+c]=="number"&&(a[2+c]/=h),typeof a[3+c]=="number"&&(a[3+c]/=h),o(a)}},F0={borderRadius:{...Ku,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Ku,borderTopRightRadius:Ku,borderBottomLeftRadius:Ku,borderBottomRightRadius:Ku,boxShadow:gJ};function PL(e,{layout:t,layoutId:n}){return Yc.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!F0[e]||e==="opacity")}function Gj(e,t,n){const r=e.style,a=t?.style,o={};if(!r)return o;for(const c in r)(os(r[c])||a&&os(a[c])||PL(c,e)||n?.getValue(c)?.liveStyle!==void 0)&&(o[c]=r[c]);return o}function vJ(e){return window.getComputedStyle(e)}class xJ extends RL{constructor(){super(...arguments),this.type="html",this.renderInstance=LL}readValueFromInstance(t,n){if(Yc.has(n))return this.projection?.isProjecting?E0(n):DX(t,n);{const r=vJ(t),a=(q$(n)?r.getPropertyValue(n):r[n])||0;return typeof a=="string"?a.trim():a}}measureInstanceViewportBox(t,{transformPagePoint:n}){return $L(t,n)}build(t,n,r){Kj(t,n,r.transformTemplate)}scrapeMotionValuesFromProps(t,n,r){return Gj(t,n,r)}}const yJ={offset:"stroke-dashoffset",array:"stroke-dasharray"},bJ={offset:"strokeDashoffset",array:"strokeDasharray"};function wJ(e,t,n=1,r=0,a=!0){e.pathLength=1;const o=a?yJ:bJ;e[o.offset]=`${-r}`,e[o.array]=`${t} ${n}`}const jJ=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function DL(e,{attrX:t,attrY:n,attrScale:r,pathLength:a,pathSpacing:o=1,pathOffset:c=0,...u},f,h,p){if(Kj(e,u,h),f){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:x,style:v}=e;x.transform&&(v.transform=x.transform,delete x.transform),(v.transform||x.transformOrigin)&&(v.transformOrigin=x.transformOrigin??"50% 50%",delete x.transformOrigin),v.transform&&(v.transformBox=p?.transformBox??"fill-box",delete x.transformBox);for(const y of jJ)x[y]!==void 0&&(v[y]=x[y],delete x[y]);t!==void 0&&(x.x=t),n!==void 0&&(x.y=n),r!==void 0&&(x.scale=r),a!==void 0&&wJ(x,a,o,c,!1)}const zL=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),BL=e=>typeof e=="string"&&e.toLowerCase()==="svg";function kJ(e,t,n,r){LL(e,t,void 0,r);for(const a in t.attrs)e.setAttribute(zL.has(a)?a:Uj(a),t.attrs[a])}function UL(e,t,n){const r=Gj(e,t,n);for(const a in e)if(os(e[a])||os(t[a])){const o=Zc.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;r[o]=e[a]}return r}class NJ extends RL{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Yn}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Yc.has(n)){const r=wL(n);return r&&r.default||0}return n=zL.has(n)?n:Uj(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,r){return UL(t,n,r)}build(t,n,r){DL(t,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(t,n,r,a){kJ(t,n,r,a)}mount(t){this.isSVGTag=BL(t.tagName),super.mount(t)}}const SJ=qj.length;function FL(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?FL(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<SJ;n++){const r=qj[n],a=e.props[r];(Qd(a)||a===!1)&&(t[r]=a)}return t}function VL(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}const CJ=[...Wj].reverse(),EJ=Wj.length;function AJ(e){return t=>Promise.all(t.map(({animation:n,options:r})=>SQ(e,n,r)))}function TJ(e){let t=AJ(e),n=iT(),r=!0,a=!1;const o=h=>(p,x)=>{const v=Wo(e,x,h==="exit"?e.presenceContext?.custom:void 0);if(v){const{transition:y,transitionEnd:b,...C}=v;p={...p,...C,...b}}return p};function c(h){t=h(e)}function u(h){const{props:p}=e,x=FL(e.parent)||{},v=[],y=new Set;let b={},C=1/0;for(let A=0;A<EJ;A++){const S=CJ[A],k=n[S],N=p[S]!==void 0?p[S]:x[S],T=Qd(N),R=S===h?k.isActive:null;R===!1&&(C=A);let O=N===x[S]&&N!==p[S]&&T;if(O&&(r||a)&&e.manuallyAnimateOnMount&&(O=!1),k.protectedKeys={...b},!k.isActive&&R===null||!N&&!k.prevProp||Lg(N)||typeof N=="boolean")continue;if(S==="exit"&&k.isActive&&R!==!0){k.prevResolvedValues&&(b={...b,...k.prevResolvedValues});continue}const L=MJ(k.prevProp,N);let I=L||S===h&&k.isActive&&!O&&T||A>C&&T,z=!1;const _=Array.isArray(N)?N:[N];let U=_.reduce(o(S),{});R===!1&&(U={});const{prevResolvedValues:D={}}=k,q={...D,...U},Z=V=>{I=!0,y.has(V)&&(z=!0,y.delete(V)),k.needsAnimating[V]=!0;const Y=e.getValue(V);Y&&(Y.liveStyle=!1)};for(const V in q){const Y=U[V],K=D[V];if(b.hasOwnProperty(V))continue;let P=!1;_0(Y)&&_0(K)?P=!VL(Y,K)||L:P=Y!==K,P?Y!=null?Z(V):y.add(V):Y!==void 0&&y.has(V)?Z(V):k.protectedKeys[V]=!0}k.prevProp=N,k.prevResolvedValues=U,k.isActive&&(b={...b,...U}),(r||a)&&e.blockInitialAnimation&&(I=!1);const $=O&&L;I&&(!$||z)&&v.push(..._.map(V=>{const Y={type:S};if(typeof V=="string"&&(r||a)&&!$&&e.manuallyAnimateOnMount&&e.parent){const{parent:K}=e,P=Wo(K,V);if(K.enteringChildren&&P){const{delayChildren:H}=P.transition||{};Y.delay=fL(K.enteringChildren,e,H)}}return{animation:V,options:Y}}))}if(y.size){const A={};if(typeof p.initial!="boolean"){const S=Wo(e,Array.isArray(p.initial)?p.initial[0]:p.initial);S&&S.transition&&(A.transition=S.transition)}y.forEach(S=>{const k=e.getBaseTarget(S),N=e.getValue(S);N&&(N.liveStyle=!0),A[S]=k??null}),v.push({animation:A})}let E=!!v.length;return r&&(p.initial===!1||p.initial===p.animate)&&!e.manuallyAnimateOnMount&&(E=!1),r=!1,a=!1,E?t(v):Promise.resolve()}function f(h,p){if(n[h].isActive===p)return Promise.resolve();e.variantChildren?.forEach(v=>v.animationState?.setActive(h,p)),n[h].isActive=p;const x=u(h);for(const v in n)n[v].protectedKeys={};return x}return{animateChanges:u,setActive:f,setAnimateFunction:c,getState:()=>n,reset:()=>{n=iT(),a=!0}}}function MJ(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!VL(t,e):!1}function No(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function iT(){return{animate:No(!0),whileInView:No(),whileHover:No(),whileTap:No(),whileDrag:No(),whileFocus:No(),exit:No()}}function V0(e,t){e.min=t.min,e.max=t.max}function Or(e,t){V0(e.x,t.x),V0(e.y,t.y)}function oT(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const HL=1e-4,RJ=1-HL,IJ=1+HL,WL=.01,_J=0-WL,OJ=0+WL;function Ss(e){return e.max-e.min}function $J(e,t,n){return Math.abs(e-t)<=n}function lT(e,t,n,r=.5){e.origin=r,e.originPoint=ln(t.min,t.max,e.origin),e.scale=Ss(n)/Ss(t),e.translate=ln(n.min,n.max,e.origin)-e.originPoint,(e.scale>=RJ&&e.scale<=IJ||isNaN(e.scale))&&(e.scale=1),(e.translate>=_J&&e.translate<=OJ||isNaN(e.translate))&&(e.translate=0)}function Td(e,t,n,r){lT(e.x,t.x,n.x,r?r.originX:void 0),lT(e.y,t.y,n.y,r?r.originY:void 0)}function cT(e,t,n,r=0){const a=r?ln(n.min,n.max,r):n.min;e.min=a+t.min,e.max=e.min+Ss(t)}function LJ(e,t,n,r){cT(e.x,t.x,n.x,r?.x),cT(e.y,t.y,n.y,r?.y)}function uT(e,t,n,r=0){const a=r?ln(n.min,n.max,r):n.min;e.min=t.min-a,e.max=e.min+Ss(t)}function Hp(e,t,n,r){uT(e.x,t.x,n.x,r?.x),uT(e.y,t.y,n.y,r?.y)}function dT(e,t,n,r,a){return e-=t,e=Vp(e,1/n,r),a!==void 0&&(e=Vp(e,1/a,r)),e}function PJ(e,t=0,n=1,r=.5,a,o=e,c=e){if(ia.test(t)&&(t=parseFloat(t),t=ln(c.min,c.max,t/100)-c.min),typeof t!="number")return;let u=ln(o.min,o.max,r);e===o&&(u-=t),e.min=dT(e.min,t,n,u,a),e.max=dT(e.max,t,n,u,a)}function fT(e,t,[n,r,a],o,c){PJ(e,t[n],t[r],t[a],t.scale,o,c)}const DJ=["x","scaleX","originX"],zJ=["y","scaleY","originY"];function hT(e,t,n,r){fT(e.x,t,DJ,n?n.x:void 0,r?r.x:void 0),fT(e.y,t,zJ,n?n.y:void 0,r?r.y:void 0)}function mT(e){return e.translate===0&&e.scale===1}function qL(e){return mT(e.x)&&mT(e.y)}function pT(e,t){return e.min===t.min&&e.max===t.max}function BJ(e,t){return pT(e.x,t.x)&&pT(e.y,t.y)}function gT(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function KL(e,t){return gT(e.x,t.x)&&gT(e.y,t.y)}function vT(e){return Ss(e.x)/Ss(e.y)}function xT(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function Qr(e){return[e("x"),e("y")]}function UJ(e,t,n){let r="";const a=e.x.translate/t.x,o=e.y.translate/t.y,c=n?.z||0;if((a||o||c)&&(r=`translate3d(${a}px, ${o}px, ${c}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:h,rotate:p,pathRotation:x,rotateX:v,rotateY:y,skewX:b,skewY:C}=n;h&&(r=`perspective(${h}px) ${r}`),p&&(r+=`rotate(${p}deg) `),x&&(r+=`rotate(${x}deg) `),v&&(r+=`rotateX(${v}deg) `),y&&(r+=`rotateY(${y}deg) `),b&&(r+=`skewX(${b}deg) `),C&&(r+=`skewY(${C}deg) `)}const u=e.x.scale*t.x,f=e.y.scale*t.y;return(u!==1||f!==1)&&(r+=`scale(${u}, ${f})`),r||"none"}const GL=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],FJ=GL.length,yT=e=>typeof e=="string"?parseFloat(e):e,bT=e=>typeof e=="number"||Ye.test(e);function VJ(e,t,n,r,a,o){a?(e.opacity=ln(0,n.opacity??1,HJ(r)),e.opacityExit=ln(t.opacity??1,0,WJ(r))):o&&(e.opacity=ln(t.opacity??1,n.opacity??1,r));for(let c=0;c<FJ;c++){const u=GL[c];let f=wT(t,u),h=wT(n,u);if(f===void 0&&h===void 0)continue;f||(f=0),h||(h=0),f===0||h===0||bT(f)===bT(h)?(e[u]=Math.max(ln(yT(f),yT(h),r),0),(ia.test(h)||ia.test(f))&&(e[u]+="%")):e[u]=h}(t.rotate||n.rotate)&&(e.rotate=ln(t.rotate||0,n.rotate||0,r))}function wT(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const HJ=ZL(0,.5,B$),WJ=ZL(.5,.95,jr);function ZL(e,t,n){return r=>r<e?0:r>t?1:n(Yd(e,t,r))}function qJ(e,t,n){const r=os(e)?e:Pc(e);return r.start(zj("",r,t,n)),r.animation}function Jd(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}const KJ=(e,t)=>e.depth-t.depth;class GJ{constructor(){this.children=[],this.isDirty=!1}add(t){Cj(this.children,t),this.isDirty=!0}remove(t){Lp(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(KJ),this.isDirty=!1,this.children.forEach(t)}}function ZJ(e,t){const n=Ns.now(),r=({timestamp:a})=>{const o=a-n;o>=t&&(Hi(r),e(o-t))};return cn.setup(r,!0),()=>Hi(r)}function Jm(e){return os(e)?e.get():e}class YJ{constructor(){this.members=[]}add(t){Cj(this.members,t);for(let n=this.members.length-1;n>=0;n--){const r=this.members[n];if(r===t||r===this.lead||r===this.prevLead)continue;const a=r.instance;(!a||a.isConnected===!1)&&!r.snapshot&&(Lp(this.members,r),r.unmount())}t.scheduleRender()}remove(t){if(Lp(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){for(let n=this.members.indexOf(t)-1;n>=0;n--){const r=this.members[n];if(r.isPresent!==!1&&r.instance?.isConnected!==!1)return this.promote(r),!0}return!1}promote(t,n){const r=this.lead;if(t!==r&&(this.prevLead=r,this.lead=t,t.show(),r)){r.updateSnapshot(),t.scheduleRender();const{layoutDependency:a}=r.options,{layoutDependency:o}=t.options;(a===void 0||a!==o)&&(t.resumeFrom=r,n&&(r.preserveOpacity=!0),r.snapshot&&(t.snapshot=r.snapshot,t.snapshot.latestValues=r.animationValues||r.latestValues),t.root?.isUpdating&&(t.isLayoutDirty=!0)),t.options.crossfade===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(t=>{t.options.onExitComplete?.(),t.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(t=>t.instance&&t.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}}const ep={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Vy=["","X","Y","Z"],XJ=1e3;let QJ=0;function Hy(e,t,n,r){const{latestValues:a}=t;a[e]&&(n[e]=a[e],t.setStaticValue(e,0),r&&(r[e]=0))}function YL(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=vL(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:a,layoutId:o}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",cn,!(a||o))}const{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&YL(r)}function XL({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:a}){return class{constructor(c={},u=t?.()){this.id=QJ++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(tee),this.nodes.forEach(oee),this.nodes.forEach(lee),this.nodes.forEach(nee)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=c,this.root=u?u.root||u:this,this.path=u?[...u.path,u]:[],this.parent=u,this.depth=u?u.depth+1:0;for(let f=0;f<this.path.length;f++)this.path[f].shouldResetTransform=!0;this.root===this&&(this.nodes=new GJ)}addEventListener(c,u){return this.eventHandlers.has(c)||this.eventHandlers.set(c,new Aj),this.eventHandlers.get(c).add(u)}notifyListeners(c,...u){const f=this.eventHandlers.get(c);f&&f.notify(...u)}hasListeners(c){return this.eventHandlers.has(c)}mount(c){if(this.instance)return;this.isSVG=Hj(c)&&!eJ(c),this.instance=c;const{layoutId:u,layout:f,visualElement:h}=this.options;if(h&&!h.current&&h.mount(c),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(f||u)&&(this.isLayoutDirty=!0),e){let p,x=0;const v=()=>this.root.updateBlockedByResize=!1;cn.read(()=>{x=window.innerWidth}),e(c,()=>{const y=window.innerWidth;y!==x&&(x=y,this.root.updateBlockedByResize=!0,p&&p(),p=ZJ(v,250),ep.hasAnimatedSinceResize&&(ep.hasAnimatedSinceResize=!1,this.nodes.forEach(NT)))})}u&&this.root.registerSharedNode(u,this),this.options.animate!==!1&&h&&(u||f)&&this.addEventListener("didUpdate",({delta:p,hasLayoutChanged:x,hasRelativeLayoutChanged:v,layout:y})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const b=this.options.transition||h.getDefaultTransition()||hee,{onLayoutAnimationStart:C,onLayoutAnimationComplete:E}=h.getProps(),A=!this.targetLayout||!KL(this.targetLayout,y),S=!x&&v;if(this.options.layoutRoot||this.resumeFrom||S||x&&(A||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const k={...Dj(b,"layout"),onPlay:C,onComplete:E};(h.shouldReduceMotion||this.options.layoutRoot)&&(k.delay=0,k.type=!1),this.startAnimation(k),this.setAnimationOrigin(p,S,k.path)}else x||NT(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=y})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const c=this.getStack();c&&c.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Hi(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(cee),this.animationId++)}getTransformTemplate(){const{visualElement:c}=this.options;return c&&c.getProps().transformTemplate}willUpdate(c=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&YL(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let p=0;p<this.path.length;p++){const x=this.path[p];x.shouldResetTransform=!0,(typeof x.latestValues.x=="string"||typeof x.latestValues.y=="string")&&(x.isLayoutDirty=!0),x.updateScroll("snapshot"),x.options.layoutRoot&&x.willUpdate(!1)}const{layoutId:u,layout:f}=this.options;if(u===void 0&&!f)return;const h=this.getTransformTemplate();this.prevTransformTemplateValue=h?h(this.latestValues,""):void 0,this.updateSnapshot(),c&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){const f=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),f&&this.nodes.forEach(ree),this.nodes.forEach(jT);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(kT);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(aee),this.nodes.forEach(iee),this.nodes.forEach(JJ),this.nodes.forEach(eee)):this.nodes.forEach(kT),this.clearAllSnapshots();const u=Ns.now();rs.delta=fa(0,1e3/60,u-rs.timestamp),rs.timestamp=u,rs.isProcessing=!0,$y.update.process(rs),$y.preRender.process(rs),$y.render.process(rs),rs.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Fj.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(see),this.sharedNodes.forEach(uee)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,cn.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){cn.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Ss(this.snapshot.measuredBox.x)&&!Ss(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let f=0;f<this.path.length;f++)this.path[f].updateScroll();const c=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||(this.layoutCorrected=Yn()),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:u}=this.options;u&&u.notify("LayoutMeasure",this.layout.layoutBox,c?c.layoutBox:void 0)}updateScroll(c="measure"){let u=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===c&&(u=!1),u&&this.instance){const f=r(this.instance);this.scroll={animationId:this.root.animationId,phase:c,isRoot:f,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:f}}}resetTransform(){if(!a)return;const c=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,u=this.projectionDelta&&!qL(this.projectionDelta),f=this.getTransformTemplate(),h=f?f(this.latestValues,""):void 0,p=h!==this.prevTransformTemplateValue;c&&this.instance&&(u||_o(this.latestValues)||p)&&(a(this.instance,h),this.shouldResetTransform=!1,this.scheduleRender())}measure(c=!0){const u=this.measurePageBox();let f=this.removeElementScroll(u);return c&&(f=this.removeTransform(f)),mee(f),{animationId:this.root.animationId,measuredBox:u,layoutBox:f,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:c}=this.options;if(!c)return Yn();const u=c.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(pee))){const{scroll:h}=this.root;h&&(sa(u.x,h.offset.x),sa(u.y,h.offset.y))}return u}removeElementScroll(c){const u=Yn();if(Or(u,c),this.scroll?.wasRoot)return u;for(let f=0;f<this.path.length;f++){const h=this.path[f],{scroll:p,options:x}=h;h!==this.root&&p&&x.layoutScroll&&(p.wasRoot&&Or(u,c),sa(u.x,p.offset.x),sa(u.y,p.offset.y))}return u}applyTransform(c,u=!1,f){const h=f||Yn();Or(h,c);for(let p=0;p<this.path.length;p++){const x=this.path[p];!u&&x.options.layoutScroll&&x.scroll&&x!==x.root&&(sa(h.x,-x.scroll.offset.x),sa(h.y,-x.scroll.offset.y)),_o(x.latestValues)&&Qm(h,x.latestValues,x.layout?.layoutBox)}return _o(this.latestValues)&&Qm(h,this.latestValues,this.layout?.layoutBox),h}removeTransform(c){const u=Yn();Or(u,c);for(let f=0;f<this.path.length;f++){const h=this.path[f];if(!_o(h.latestValues))continue;let p;h.instance&&(B0(h.latestValues)&&h.updateSnapshot(),p=Yn(),Or(p,h.measurePageBox())),hT(u,h.latestValues,h.snapshot?.layoutBox,p)}return _o(this.latestValues)&&hT(u,this.latestValues),u}setTargetDelta(c){this.targetDelta=c,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(c){this.options={...this.options,...c,crossfade:c.crossfade!==void 0?c.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==rs.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(c=!1){const u=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=u.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=u.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=u.isSharedProjectionDirty);const f=!!this.resumingFrom||this!==u;if(!(c||f&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:p,layoutId:x}=this.options;if(!this.layout||!(p||x))return;this.resolvedRelativeTargetAt=rs.timestamp;const v=this.getClosestProjectingParent();v&&this.linkedParentVersion!==v.layoutVersion&&!v.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&v&&v.layout?this.createRelativeTarget(v,this.layout.layoutBox,v.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=Yn(),this.targetWithTransforms=Yn()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),LJ(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Or(this.target,this.layout.layoutBox),OL(this.target,this.targetDelta)):Or(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&v&&!!v.resumingFrom==!!this.resumingFrom&&!v.options.layoutScroll&&v.target&&this.animationProgress!==1?this.createRelativeTarget(v,this.target,v.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||B0(this.parent.latestValues)||_L(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(c,u,f){this.relativeParent=c,this.linkedParentVersion=c.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Yn(),this.relativeTargetOrigin=Yn(),Hp(this.relativeTargetOrigin,u,f,this.options.layoutAnchor||void 0),Or(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){const c=this.getLead(),u=!!this.resumingFrom||this!==c;let f=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(f=!1),u&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(f=!1),this.resolvedRelativeTargetAt===rs.timestamp&&(f=!1),f)return;const{layout:h,layoutId:p}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(h||p))return;Or(this.layoutCorrected,this.layout.layoutBox);const x=this.treeScale.x,v=this.treeScale.y;dJ(this.layoutCorrected,this.treeScale,this.path,u),c.layout&&!c.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(c.target=c.layout.layoutBox,c.targetWithTransforms=Yn());const{target:y}=c;if(!y){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(oT(this.prevProjectionDelta.x,this.projectionDelta.x),oT(this.prevProjectionDelta.y,this.projectionDelta.y)),Td(this.projectionDelta,this.layoutCorrected,y,this.latestValues),(this.treeScale.x!==x||this.treeScale.y!==v||!xT(this.projectionDelta.x,this.prevProjectionDelta.x)||!xT(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",y))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(c=!0){if(this.options.visualElement?.scheduleRender(),c){const u=this.getStack();u&&u.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=fc(),this.projectionDelta=fc(),this.projectionDeltaWithTransform=fc()}setAnimationOrigin(c,u=!1,f){const h=this.snapshot,p=h?h.latestValues:{},x={...this.latestValues},v=fc();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!u;const y=Yn(),b=h?h.source:void 0,C=this.layout?this.layout.source:void 0,E=b!==C,A=this.getStack(),S=!A||A.members.length<=1,k=!!(E&&!S&&this.options.crossfade===!0&&!this.path.some(fee));this.animationProgress=0;let N;const T=f?.interpolateProjection(c);this.mixTargetDelta=R=>{const O=R/1e3,L=T?.(O);L?(v.x.translate=L.x,v.x.scale=ln(c.x.scale,1,O),v.x.origin=c.x.origin,v.x.originPoint=c.x.originPoint,v.y.translate=L.y,v.y.scale=ln(c.y.scale,1,O),v.y.origin=c.y.origin,v.y.originPoint=c.y.originPoint):(ST(v.x,c.x,O),ST(v.y,c.y,O)),this.setTargetDelta(v),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Hp(y,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),dee(this.relativeTarget,this.relativeTargetOrigin,y,O),N&&BJ(this.relativeTarget,N)&&(this.isProjectionDirty=!1),N||(N=Yn()),Or(N,this.relativeTarget)),E&&(this.animationValues=x,VJ(x,p,this.latestValues,O,k,S)),L&&L.rotate!==void 0&&(this.animationValues||(this.animationValues=x),this.animationValues.pathRotation=L.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=O},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(c){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Hi(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=cn.update(()=>{ep.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Pc(0)),this.motionValue.jump(0,!1),this.currentAnimation=qJ(this.motionValue,[0,1e3],{...c,velocity:0,isSync:!0,onUpdate:u=>{this.mixTargetDelta(u),c.onUpdate&&c.onUpdate(u)},onStop:()=>{},onComplete:()=>{c.onComplete&&c.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const c=this.getStack();c&&c.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(XJ),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const c=this.getLead();let{targetWithTransforms:u,target:f,layout:h,latestValues:p}=c;if(!(!u||!f||!h)){if(this!==c&&this.layout&&h&&QL(this.options.animationType,this.layout.layoutBox,h.layoutBox)){f=this.target||Yn();const x=Ss(this.layout.layoutBox.x);f.x.min=c.target.x.min,f.x.max=f.x.min+x;const v=Ss(this.layout.layoutBox.y);f.y.min=c.target.y.min,f.y.max=f.y.min+v}Or(u,f),Qm(u,p),Td(this.projectionDeltaWithTransform,this.layoutCorrected,u,p)}}registerSharedNode(c,u){this.sharedNodes.has(c)||this.sharedNodes.set(c,new YJ),this.sharedNodes.get(c).add(u);const h=u.options.initialPromotionConfig;u.promote({transition:h?h.transition:void 0,preserveFollowOpacity:h&&h.shouldPreserveFollowOpacity?h.shouldPreserveFollowOpacity(u):void 0})}isLead(){const c=this.getStack();return c?c.lead===this:!0}getLead(){const{layoutId:c}=this.options;return c?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:c}=this.options;return c?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:c}=this.options;if(c)return this.root.sharedNodes.get(c)}promote({needsReset:c,transition:u,preserveFollowOpacity:f}={}){const h=this.getStack();h&&h.promote(this,f),c&&(this.projectionDelta=void 0,this.needsReset=!0),u&&this.setOptions({transition:u})}relegate(){const c=this.getStack();return c?c.relegate(this):!1}resetSkewAndRotation(){const{visualElement:c}=this.options;if(!c)return;let u=!1;const{latestValues:f}=c;if((f.z||f.rotate||f.rotateX||f.rotateY||f.rotateZ||f.skewX||f.skewY)&&(u=!0),!u)return;const h={};f.z&&Hy("z",c,h,this.animationValues);for(let p=0;p<Vy.length;p++)Hy(`rotate${Vy[p]}`,c,h,this.animationValues),Hy(`skew${Vy[p]}`,c,h,this.animationValues);c.render();for(const p in h)c.setStaticValue(p,h[p]),this.animationValues&&(this.animationValues[p]=h[p]);c.scheduleRender()}applyProjectionStyles(c,u){if(!this.instance||this.isSVG)return;if(!this.isVisible){c.visibility="hidden";return}const f=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,c.visibility="",c.opacity="",c.pointerEvents=Jm(u?.pointerEvents)||"",c.transform=f?f(this.latestValues,""):"none";return}const h=this.getLead();if(!this.projectionDelta||!this.layout||!h.target){this.options.layoutId&&(c.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,c.pointerEvents=Jm(u?.pointerEvents)||""),this.hasProjected&&!_o(this.latestValues)&&(c.transform=f?f({},""):"none",this.hasProjected=!1);return}c.visibility="";const p=h.animationValues||h.latestValues;this.applyTransformsToTarget();let x=UJ(this.projectionDeltaWithTransform,this.treeScale,p);f&&(x=f(p,x)),c.transform=x;const{x:v,y}=this.projectionDelta;c.transformOrigin=`${v.origin*100}% ${y.origin*100}% 0`,h.animationValues?c.opacity=h===this?p.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:p.opacityExit:c.opacity=h===this?p.opacity!==void 0?p.opacity:"":p.opacityExit!==void 0?p.opacityExit:0;for(const b in F0){if(p[b]===void 0)continue;const{correct:C,applyTo:E,isCSSVariable:A}=F0[b],S=x==="none"?p[b]:C(p[b],h);if(E){const k=E.length;for(let N=0;N<k;N++)c[E[N]]=S}else A?this.options.visualElement.renderState.vars[b]=S:c[b]=S}this.options.layoutId&&(c.pointerEvents=h===this?Jm(u?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(c=>c.currentAnimation?.stop()),this.root.nodes.forEach(jT),this.root.sharedNodes.clear()}}}function JJ(e){e.updateLayout()}function eee(e){const t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:r}=e.layout,{animationType:a}=e.options,o=t.source!==e.layout.source;if(a==="size")Qr(p=>{const x=o?t.measuredBox[p]:t.layoutBox[p],v=Ss(x);x.min=n[p].min,x.max=x.min+v});else if(a==="x"||a==="y"){const p=a==="x"?"y":"x";V0(o?t.measuredBox[p]:t.layoutBox[p],n[p])}else QL(a,t.layoutBox,n)&&Qr(p=>{const x=o?t.measuredBox[p]:t.layoutBox[p],v=Ss(n[p]);x.max=x.min+v,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[p].max=e.relativeTarget[p].min+v)});const c=fc();Td(c,n,t.layoutBox);const u=fc();o?Td(u,e.applyTransform(r,!0),t.measuredBox):Td(u,n,t.layoutBox);const f=!qL(c);let h=!1;if(!e.resumeFrom){const p=e.getClosestProjectingParent();if(p&&!p.resumeFrom){const{snapshot:x,layout:v}=p;if(x&&v){const y=e.options.layoutAnchor||void 0,b=Yn();Hp(b,t.layoutBox,x.layoutBox,y);const C=Yn();Hp(C,n,v.layoutBox,y),KL(b,C)||(h=!0),p.options.layoutRoot&&(e.relativeTarget=C,e.relativeTargetOrigin=b,e.relativeParent=p)}}}e.notifyListeners("didUpdate",{layout:n,snapshot:t,delta:u,layoutDelta:c,hasLayoutChanged:f,hasRelativeLayoutChanged:h})}else if(e.isLead()){const{onExitComplete:n}=e.options;n&&n()}e.options.transition=void 0}function tee(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function nee(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function see(e){e.clearSnapshot()}function jT(e){e.clearMeasurements()}function ree(e){e.isLayoutDirty=!0,e.updateLayout()}function kT(e){e.isLayoutDirty=!1}function aee(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function iee(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function NT(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function oee(e){e.resolveTargetDelta()}function lee(e){e.calcProjection()}function cee(e){e.resetSkewAndRotation()}function uee(e){e.removeLeadSnapshot()}function ST(e,t,n){e.translate=ln(t.translate,0,n),e.scale=ln(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function CT(e,t,n,r){e.min=ln(t.min,n.min,r),e.max=ln(t.max,n.max,r)}function dee(e,t,n,r){CT(e.x,t.x,n.x,r),CT(e.y,t.y,n.y,r)}function fee(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const hee={duration:.45,ease:[.4,0,.1,1]},ET=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),AT=ET("applewebkit/")&&!ET("chrome/")?Math.round:jr;function TT(e){e.min=AT(e.min),e.max=AT(e.max)}function mee(e){TT(e.x),TT(e.y)}function QL(e,t,n){return e==="position"||e==="preserve-aspect"&&!$J(vT(t),vT(n),.2)}function pee(e){return e!==e.root&&e.scroll?.wasRoot}const gee=XL({attachResizeListener:(e,t)=>Jd(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),Wy={current:void 0},JL=XL({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Wy.current){const e=new gee({});e.mount(window),e.setOptions({layoutScroll:!0}),Wy.current=e}return Wy.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),Zj=m.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function MT(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function vee(...e){return t=>{let n=!1;const r=e.map(a=>{const o=MT(a,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let a=0;a<r.length;a++){const o=r[a];typeof o=="function"?o():MT(e[a],null)}}}}function xee(...e){return m.useCallback(vee(...e),e)}class yee extends m.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(Km(n)&&t.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const r=n.offsetParent,a=Km(r)&&r.offsetWidth||0,o=Km(r)&&r.offsetHeight||0,c=getComputedStyle(n),u=this.props.sizeRef.current;u.height=parseFloat(c.height),u.width=parseFloat(c.width),u.top=n.offsetTop,u.left=n.offsetLeft,u.right=a-u.width-u.left,u.bottom=o-u.height-u.top,u.direction=c.direction}return null}componentDidUpdate(){}render(){return this.props.children}}function bee({children:e,isPresent:t,anchorX:n,anchorY:r,root:a,pop:o}){const c=m.useId(),u=m.useRef(null),f=m.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:"ltr"}),{nonce:h}=m.useContext(Zj),p=e.props?.ref??e?.ref,x=xee(u,p);return m.useInsertionEffect(()=>{const{width:v,height:y,top:b,left:C,right:E,bottom:A,direction:S}=f.current;if(t||o===!1||!u.current||!v||!y)return;const k=S==="rtl",N=n==="left"?k?`right: ${E}`:`left: ${C}`:k?`left: ${C}`:`right: ${E}`,T=r==="bottom"?`bottom: ${A}`:`top: ${b}`;u.current.dataset.motionPopId=c;const R=document.createElement("style");h&&(R.nonce=h);const O=a??document.head;return O.appendChild(R),R.sheet&&R.sheet.insertRule(`
122
- [data-motion-pop-id="${c}"] {
123
- position: absolute !important;
124
- width: ${v}px !important;
125
- height: ${y}px !important;
126
- ${N}px !important;
127
- ${T}px !important;
128
- }
129
- `),()=>{u.current?.removeAttribute("data-motion-pop-id"),O.contains(R)&&O.removeChild(R)}},[t]),s.jsx(yee,{isPresent:t,childRef:u,sizeRef:f,pop:o,children:o===!1?e:m.cloneElement(e,{ref:x})})}const wee=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:a,presenceAffectsLayout:o,mode:c,anchorX:u,anchorY:f,root:h})=>{const p=Sj(jee),x=m.useId();let v=!0,y=m.useMemo(()=>(v=!1,{id:x,initial:t,isPresent:n,custom:a,onExitComplete:b=>{p.set(b,!0);for(const C of p.values())if(!C)return;r&&r()},register:b=>(p.set(b,!1),()=>p.delete(b))}),[n,p,r]);return o&&v&&(y={...y}),m.useMemo(()=>{p.forEach((b,C)=>p.set(C,!1))},[n]),m.useEffect(()=>{!n&&!p.size&&r&&r()},[n]),e=s.jsx(bee,{pop:c==="popLayout",isPresent:n,anchorX:u,anchorY:f,root:h,children:e}),s.jsx(Og.Provider,{value:y,children:e})};function jee(){return new Map}function eP(e=!0){const t=m.useContext(Og);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:a}=t,o=m.useId();m.useEffect(()=>{if(e)return a(o)},[e]);const c=m.useCallback(()=>e&&r&&r(o),[o,r,e]);return!n&&r?[!1,c]:[!0]}const em=e=>e.key||"";function RT(e){const t=[];return m.Children.forEach(e,n=>{m.isValidElement(n)&&t.push(n)}),t}const kee=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:a=!0,mode:o="sync",propagate:c=!1,anchorX:u="left",anchorY:f="top",root:h})=>{const[p,x]=eP(c),v=m.useMemo(()=>RT(e),[e]),y=c&&!p?[]:v.map(em),b=m.useRef(!0),C=m.useRef(v),E=Sj(()=>new Map),A=m.useRef(new Set),[S,k]=m.useState(v),[N,T]=m.useState(v);A$(()=>{b.current=!1,C.current=v;for(let L=0;L<N.length;L++){const I=em(N[L]);y.includes(I)?(E.delete(I),A.current.delete(I)):E.get(I)!==!0&&E.set(I,!1)}},[N,y.length,y.join("-")]);const R=[];if(v!==S){let L=[...v];for(let I=0;I<N.length;I++){const z=N[I],_=em(z);y.includes(_)||(L.splice(I,0,z),R.push(z))}return o==="wait"&&R.length&&(L=R),T(RT(L)),k(v),null}const{forceRender:O}=m.useContext(Nj);return s.jsx(s.Fragment,{children:N.map(L=>{const I=em(L),z=c&&!p?!1:v===N||y.includes(I),_=()=>{if(A.current.has(I))return;if(E.has(I))A.current.add(I),E.set(I,!0);else return;let U=!0;E.forEach(D=>{D||(U=!1)}),U&&(O?.(),T(C.current),c&&x?.(),r&&r())};return s.jsx(wee,{isPresent:z,initial:!b.current||n?void 0:!1,custom:t,presenceAffectsLayout:a,mode:o,root:h,onExitComplete:z?void 0:_,anchorX:u,anchorY:f,children:L},I)})})},tP=m.createContext({strict:!1}),IT={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let _T=!1;function Nee(){if(_T)return;const e={};for(const t in IT)e[t]={isEnabled:n=>IT[t].some(r=>!!n[r])};ML(e),_T=!0}function nP(){return Nee(),oJ()}function See(e){const t=nP();for(const n in e)t[n]={...t[n],...e[n]};ML(t)}const Cee=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function Wp(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||Cee.has(e)}let sP=e=>!Wp(e);function Eee(e){typeof e=="function"&&(sP=t=>t.startsWith("on")?!Wp(t):e(t))}try{Eee(require("@emotion/is-prop-valid").default)}catch{}function Aee(e,t,n){const r={};for(const a in e)a==="values"&&typeof e.values=="object"||os(e[a])||(sP(a)||n===!0&&Wp(a)||!t&&!Wp(a)||e.draggable&&a.startsWith("onDrag"))&&(r[a]=e[a]);return r}const Dg=m.createContext({});function Tee(e,t){if(Pg(e)){const{initial:n,animate:r}=e;return{initial:n===!1||Qd(n)?n:void 0,animate:Qd(r)?r:void 0}}return e.inherit!==!1?t:{}}function Mee(e){const{initial:t,animate:n}=Tee(e,m.useContext(Dg));return m.useMemo(()=>({initial:t,animate:n}),[OT(t),OT(n)])}function OT(e){return Array.isArray(e)?e.join(" "):e}const Yj=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function rP(e,t,n){for(const r in t)!os(t[r])&&!PL(r,n)&&(e[r]=t[r])}function Ree({transformTemplate:e},t){return m.useMemo(()=>{const n=Yj();return Kj(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Iee(e,t){const n=e.style||{},r={};return rP(r,n,e),Object.assign(r,Ree(e,t)),r}function _ee(e,t){const n={},r=Iee(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}const aP=()=>({...Yj(),attrs:{}});function Oee(e,t,n,r){const a=m.useMemo(()=>{const o=aP();return DL(o,t,BL(r),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};rP(o,e.style,e),a.style={...o,...a.style}}return a}const $ee=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Xj(e){return typeof e!="string"||e.includes("-")?!1:!!($ee.indexOf(e)>-1||/[A-Z]/u.test(e))}function Lee(e,t,n,{latestValues:r},a,o=!1,c){const f=(c??Xj(e)?Oee:_ee)(t,r,a,e),h=Aee(t,typeof e=="string",o),p=e!==m.Fragment?{...h,...f,ref:n}:{},{children:x}=t,v=m.useMemo(()=>os(x)?x.get():x,[x]);return m.createElement(e,{...p,children:v})}function Pee({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,a){return{latestValues:Dee(n,r,a,e),renderState:t()}}function Dee(e,t,n,r){const a={},o=r(e,{});for(const v in o)a[v]=Jm(o[v]);let{initial:c,animate:u}=e;const f=Pg(e),h=AL(e);t&&h&&!f&&e.inherit!==!1&&(c===void 0&&(c=t.initial),u===void 0&&(u=t.animate));let p=n?n.initial===!1:!1;p=p||c===!1;const x=p?u:c;if(x&&typeof x!="boolean"&&!Lg(x)){const v=Array.isArray(x)?x:[x];for(let y=0;y<v.length;y++){const b=Bj(e,v[y]);if(b){const{transitionEnd:C,transition:E,...A}=b;for(const S in A){let k=A[S];if(Array.isArray(k)){const N=p?k.length-1:0;k=k[N]}k!==null&&(a[S]=k)}for(const S in C)a[S]=C[S]}}}return a}const iP=e=>(t,n)=>{const r=m.useContext(Dg),a=m.useContext(Og),o=()=>Pee(e,t,r,a);return n?o():Sj(o)},zee=iP({scrapeMotionValuesFromProps:Gj,createRenderState:Yj}),Bee=iP({scrapeMotionValuesFromProps:UL,createRenderState:aP}),Uee=Symbol.for("motionComponentSymbol");function Fee(e,t,n){const r=m.useRef(n);m.useInsertionEffect(()=>{r.current=n});const a=m.useRef(null);return m.useCallback(o=>{o&&e.onMount?.(o),t&&(o?t.mount(o):t.unmount());const c=r.current;if(typeof c=="function")if(o){const u=c(o);typeof u=="function"&&(a.current=u)}else a.current?(a.current(),a.current=null):c(o);else c&&(c.current=o)},[t])}const oP=m.createContext({});function sc(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Vee(e,t,n,r,a,o){const{visualElement:c}=m.useContext(Dg),u=m.useContext(tP),f=m.useContext(Og),h=m.useContext(Zj),p=h.reducedMotion,x=h.skipAnimations,v=m.useRef(null),y=m.useRef(!1);r=r||u.renderer,!v.current&&r&&(v.current=r(e,{visualState:t,parent:c,props:n,presenceContext:f,blockInitialAnimation:f?f.initial===!1:!1,reducedMotionConfig:p,skipAnimations:x,isSVG:o}),y.current&&v.current&&(v.current.manuallyAnimateOnMount=!0));const b=v.current,C=m.useContext(oP);b&&!b.projection&&a&&(b.type==="html"||b.type==="svg")&&Hee(v.current,n,a,C);const E=m.useRef(!1);m.useInsertionEffect(()=>{b&&E.current&&b.update(n,f)});const A=n[gL],S=m.useRef(!!A&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(A)&&window.MotionHasOptimisedAnimation?.(A));return A$(()=>{y.current=!0,b&&(E.current=!0,window.MotionIsMounted=!0,b.updateFeatures(),b.scheduleRenderMicrotask(),S.current&&b.animationState&&b.animationState.animateChanges())}),m.useEffect(()=>{b&&(!S.current&&b.animationState&&b.animationState.animateChanges(),S.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(A)}),S.current=!1),b.enteringChildren=void 0)}),b}function Hee(e,t,n,r){const{layoutId:a,layout:o,drag:c,dragConstraints:u,layoutScroll:f,layoutRoot:h,layoutAnchor:p,layoutCrossfade:x}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:lP(e.parent)),e.projection.setOptions({layoutId:a,layout:o,alwaysMeasureLayout:!!c||u&&sc(u),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:r,crossfade:x,layoutScroll:f,layoutRoot:h,layoutAnchor:p})}function lP(e){if(e)return e.options.allowProjection!==!1?e.projection:lP(e.parent)}function qy(e,{forwardMotionProps:t=!1,type:n}={},r,a){r&&See(r);const o=n?n==="svg":Xj(e),c=o?Bee:zee;function u(h,p){let x;const v={...m.useContext(Zj),...h,layoutId:Wee(h)},{isStatic:y}=v,b=Mee(h),C=c(h,y);if(!y&&typeof window<"u"){qee();const E=Kee(v);x=E.MeasureLayout,b.visualElement=Vee(e,C,v,a,E.ProjectionNode,o)}return s.jsxs(Dg.Provider,{value:b,children:[x&&b.visualElement?s.jsx(x,{visualElement:b.visualElement,...v}):null,Lee(e,h,Fee(C,b.visualElement,p),C,y,t,o)]})}u.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const f=m.forwardRef(u);return f[Uee]=e,f}function Wee({layoutId:e}){const t=m.useContext(Nj).id;return t&&e!==void 0?t+"-"+e:e}function qee(e,t){m.useContext(tP).strict}function Kee(e){const t=nP(),{drag:n,layout:r}=t;if(!n&&!r)return{};const a={...n,...r};return{MeasureLayout:n?.isEnabled(e)||r?.isEnabled(e)?a.MeasureLayout:void 0,ProjectionNode:a.ProjectionNode}}function Gee(e,t){if(typeof Proxy>"u")return qy;const n=new Map,r=(o,c)=>qy(o,c,e,t),a=(o,c)=>r(o,c);return new Proxy(a,{get:(o,c)=>c==="create"?r:(n.has(c)||n.set(c,qy(c,void 0,e,t)),n.get(c))})}const Zee=(e,t)=>t.isSVG??Xj(e)?new NJ(t):new xJ(t,{allowProjection:e!==m.Fragment});class Yee extends eo{constructor(t){super(t),t.animationState||(t.animationState=TJ(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Lg(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let Xee=0;class Qee extends eo{constructor(){super(...arguments),this.id=Xee++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===r)return;if(t&&r===!1){if(this.isExitComplete){const{initial:o,custom:c}=this.node.getProps();if(typeof o=="string"||typeof o=="object"&&o!==null&&!Array.isArray(o)){const u=Wo(this.node,o,c);if(u){const{transition:f,transitionEnd:h,...p}=u;for(const x in p)this.node.getValue(x)?.jump(p[x])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const a=this.node.animationState.setActive("exit",!t);n&&!t&&a.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const Jee={animation:{Feature:Yee},exit:{Feature:Qee}};function yf(e){return{point:{x:e.pageX,y:e.pageY}}}const ete=e=>t=>Vj(t)&&e(t,yf(t));function Md(e,t,n,r){return Jd(e,t,ete(n),r)}const cP=({current:e})=>e?e.ownerDocument.defaultView:null,$T=(e,t)=>Math.abs(e-t);function tte(e,t){const n=$T(e.x,t.x),r=$T(e.y,t.y);return Math.sqrt(n**2+r**2)}const LT=new Set(["auto","scroll"]);class uP{constructor(t,n,{transformPagePoint:r,contextWindow:a=window,dragSnapToOrigin:o=!1,distanceThreshold:c=3,element:u}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=y=>{this.handleScroll(y.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=tm(this.lastRawMoveEventInfo,this.transformPagePoint));const y=Ky(this.lastMoveEventInfo,this.history),b=this.startEvent!==null,C=tte(y.offset,{x:0,y:0})>=this.distanceThreshold;if(!b&&!C)return;const{point:E}=y,{timestamp:A}=rs;this.history.push({...E,timestamp:A});const{onStart:S,onMove:k}=this.handlers;b||(S&&S(this.lastMoveEvent,y),this.startEvent=this.lastMoveEvent),k&&k(this.lastMoveEvent,y)},this.handlePointerMove=(y,b)=>{this.lastMoveEvent=y,this.lastRawMoveEventInfo=b,this.lastMoveEventInfo=tm(b,this.transformPagePoint),cn.update(this.updatePoint,!0)},this.handlePointerUp=(y,b)=>{this.end();const{onEnd:C,onSessionEnd:E,resumeAnimation:A}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&A&&A(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const S=Ky(y.type==="pointercancel"?this.lastMoveEventInfo:tm(b,this.transformPagePoint),this.history);this.startEvent&&C&&C(y,S),E&&E(y,S)},!Vj(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=c,this.contextWindow=a||window;const f=yf(t),h=tm(f,this.transformPagePoint),{point:p}=h,{timestamp:x}=rs;this.history=[{...p,timestamp:x}];const{onSessionStart:v}=n;v&&v(t,Ky(h,this.history)),this.removeListeners=gf(Md(this.contextWindow,"pointermove",this.handlePointerMove),Md(this.contextWindow,"pointerup",this.handlePointerUp),Md(this.contextWindow,"pointercancel",this.handlePointerUp)),u&&this.startScrollTracking(u)}startScrollTracking(t){let n=t.parentElement;for(;n;){const r=getComputedStyle(n);(LT.has(r.overflowX)||LT.has(r.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const n=this.scrollPositions.get(t);if(!n)return;const r=t===window,a=r?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},o={x:a.x-n.x,y:a.y-n.y};o.x===0&&o.y===0||(r?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=o.x,this.lastMoveEventInfo.point.y+=o.y):this.history.length>0&&(this.history[0].x-=o.x,this.history[0].y-=o.y),this.scrollPositions.set(t,a),cn.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Hi(this.updatePoint)}}function tm(e,t){return t?{point:t(e.point)}:e}function PT(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ky({point:e},t){return{point:e,delta:PT(e,dP(t)),offset:PT(e,nte(t)),velocity:ste(t,.1)}}function nte(e){return e[0]}function dP(e){return e[e.length-1]}function ste(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const a=dP(e);for(;n>=0&&(r=e[n],!(a.timestamp-r.timestamp>er(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&a.timestamp-r.timestamp>er(t)*2&&(r=e[1]);const o=xr(a.timestamp-r.timestamp);if(o===0)return{x:0,y:0};const c={x:(a.x-r.x)/o,y:(a.y-r.y)/o};return c.x===1/0&&(c.x=0),c.y===1/0&&(c.y=0),c}function rte(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?ln(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?ln(n,e,r.max):Math.min(e,n)),e}function DT(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function ate(e,{top:t,left:n,bottom:r,right:a}){return{x:DT(e.x,n,a),y:DT(e.y,t,r)}}function zT(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function ite(e,t){return{x:zT(e.x,t.x),y:zT(e.y,t.y)}}function ote(e,t){let n=.5;const r=Ss(e),a=Ss(t);return a>r?n=Yd(t.min,t.max-r,e.min):r>a&&(n=Yd(e.min,e.max-a,t.min)),fa(0,1,n)}function lte(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const H0=.35;function cte(e=H0){return e===!1?e=0:e===!0&&(e=H0),{x:BT(e,"left","right"),y:BT(e,"top","bottom")}}function BT(e,t,n){return{min:UT(e,t),max:UT(e,n)}}function UT(e,t){return typeof e=="number"?e:e[t]||0}const ute=new WeakMap;class dte{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Yn(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:r}={}){const{presenceContext:a}=this.visualElement;if(a&&a.isPresent===!1)return;const o=x=>{n&&this.snapToCursor(yf(x).point),this.stopAnimation()},c=(x,v)=>{const{drag:y,dragPropagation:b,onDragStart:C}=this.getProps();if(y&&!b&&(this.openDragLock&&this.openDragLock(),this.openDragLock=PQ(y),!this.openDragLock))return;this.latestPointerEvent=x,this.latestPanInfo=v,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Qr(A=>{let S=this.getAxisMotionValue(A).get()||0;if(ia.test(S)){const{projection:k}=this.visualElement;if(k&&k.layout){const N=k.layout.layoutBox[A];N&&(S=Ss(N)*(parseFloat(S)/100))}}this.originPoint[A]=S}),C&&cn.update(()=>C(x,v),!1,!0),O0(this.visualElement,"transform");const{animationState:E}=this.visualElement;E&&E.setActive("whileDrag",!0)},u=(x,v)=>{this.latestPointerEvent=x,this.latestPanInfo=v;const{dragPropagation:y,dragDirectionLock:b,onDirectionLock:C,onDrag:E}=this.getProps();if(!y&&!this.openDragLock)return;const{offset:A}=v;if(b&&this.currentDirection===null){this.currentDirection=hte(A),this.currentDirection!==null&&C&&C(this.currentDirection);return}this.updateAxis("x",v.point,A),this.updateAxis("y",v.point,A),this.visualElement.render(),E&&cn.update(()=>E(x,v),!1,!0)},f=(x,v)=>{this.latestPointerEvent=x,this.latestPanInfo=v,this.stop(x,v),this.latestPointerEvent=null,this.latestPanInfo=null},h=()=>{const{dragSnapToOrigin:x}=this.getProps();(x||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:p}=this.getProps();this.panSession=new uP(t,{onSessionStart:o,onStart:c,onMove:u,onSessionEnd:f,resumeAnimation:h},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,distanceThreshold:r,contextWindow:cP(this.visualElement),element:this.visualElement.current})}stop(t,n){const r=t||this.latestPointerEvent,a=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!a||!r)return;const{velocity:c}=a;this.startAnimation(c);const{onDragEnd:u}=this.getProps();u&&cn.postRender(()=>u(r,a))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,r){const{drag:a}=this.getProps();if(!r||!nm(t,a,this.currentDirection))return;const o=this.getAxisMotionValue(t);let c=this.originPoint[t]+r[t];this.constraints&&this.constraints[t]&&(c=rte(c,this.constraints[t],this.elastic[t])),o.set(c)}resolveConstraints(){const{dragConstraints:t,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,a=this.constraints;t&&sc(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&r?this.constraints=ate(r.layoutBox,t):this.constraints=!1,this.elastic=cte(n),a!==this.constraints&&!sc(t)&&r&&this.constraints&&!this.hasMutatedConstraints&&Qr(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=lte(r.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!sc(t))return!1;const r=t.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;a.root&&(a.root.scroll=void 0,a.root.updateScroll());const o=fJ(r,a.root,this.visualElement.getTransformPagePoint());let c=ite(a.layout.layoutBox,o);if(n){const u=n(cJ(c));this.hasMutatedConstraints=!!u,u&&(c=IL(u))}return c}startAnimation(t){const{drag:n,dragMomentum:r,dragElastic:a,dragTransition:o,dragSnapToOrigin:c,onDragTransitionEnd:u}=this.getProps(),f=this.constraints||{},h=Qr(p=>{if(!nm(p,n,this.currentDirection))return;let x=f&&f[p]||{};(c===!0||c===p)&&(x={min:0,max:0});const v=a?200:1e6,y=a?40:1e7,b={type:"inertia",velocity:r?t[p]:0,bounceStiffness:v,bounceDamping:y,timeConstant:750,restDelta:1,restSpeed:10,...o,...x};return this.startAxisValueAnimation(p,b)});return Promise.all(h).then(u)}startAxisValueAnimation(t,n){const r=this.getAxisMotionValue(t);return O0(this.visualElement,t),r.start(zj(t,r,0,n,this.visualElement,!1))}stopAnimation(){Qr(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,a=this.visualElement.getProps()[n];return a||this.visualElement.getValue(t,this.visualElement.latestValues[t]??0)}snapToCursor(t){Qr(n=>{const{drag:r}=this.getProps();if(!nm(n,r,this.currentDirection))return;const{projection:a}=this.visualElement,o=this.getAxisMotionValue(n);if(a&&a.layout){const{min:c,max:u}=a.layout.layoutBox[n],f=o.get()||0;o.set(t[n]-ln(c,u,.5)+f)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!sc(n)||!r||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};Qr(c=>{const u=this.getAxisMotionValue(c);if(u&&this.constraints!==!1){const f=u.get();a[c]=ote({min:f,max:f},this.constraints[c])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.constraints=!1,this.resolveConstraints(),Qr(c=>{if(!nm(c,t,null))return;const u=this.getAxisMotionValue(c),{min:f,max:h}=this.constraints[c];u.set(ln(f,h,a[c]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;ute.set(this.visualElement,this);const t=this.visualElement.current,n=Md(t,"pointerdown",h=>{const{drag:p,dragListener:x=!0}=this.getProps(),v=h.target,y=v!==t&&VQ(v);p&&x&&!y&&this.start(h)});let r;const a=()=>{const{dragConstraints:h}=this.getProps();sc(h)&&h.current&&(this.constraints=this.resolveRefConstraints(),r||(r=fte(t,h.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,c=o.addEventListener("measure",a);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),cn.read(a);const u=Jd(window,"resize",()=>this.scalePositionWithinConstraints()),f=o.addEventListener("didUpdate",(({delta:h,hasLayoutChanged:p})=>{this.isDragging&&p&&(Qr(x=>{const v=this.getAxisMotionValue(x);v&&(this.originPoint[x]+=h[x].translate,v.set(v.get()+h[x].translate))}),this.visualElement.render())}));return()=>{u(),n(),c(),f&&f(),r&&r()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:a=!1,dragConstraints:o=!1,dragElastic:c=H0,dragMomentum:u=!0}=t;return{...t,drag:n,dragDirectionLock:r,dragPropagation:a,dragConstraints:o,dragElastic:c,dragMomentum:u}}}function FT(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function fte(e,t,n){const r=ZA(e,FT(n)),a=ZA(t,FT(n));return()=>{r(),a()}}function nm(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function hte(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class mte extends eo{constructor(t){super(t),this.removeGroupControls=jr,this.removeListeners=jr,this.controls=new dte(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||jr}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const Gy=e=>(t,n)=>{e&&cn.update(()=>e(t,n),!1,!0)};class pte extends eo{constructor(){super(...arguments),this.removePointerDownListener=jr}onPointerDown(t){this.session=new uP(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:cP(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:r,onPanEnd:a}=this.node.getProps();return{onSessionStart:Gy(t),onStart:Gy(n),onMove:Gy(r),onEnd:(o,c)=>{delete this.session,a&&cn.postRender(()=>a(o,c))}}}mount(){this.removePointerDownListener=Md(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let Zy=!1;class gte extends m.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r,layoutId:a}=this.props,{projection:o}=t;o&&(n.group&&n.group.add(o),r&&r.register&&a&&r.register(o),Zy&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),ep.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:r,drag:a,isPresent:o}=this.props,{projection:c}=r;return c&&(c.isPresent=o,t.layoutDependency!==n&&c.setOptions({...c.options,layoutDependency:n}),Zy=!0,a||t.layoutDependency!==n||n===void 0||t.isPresent!==o?c.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?c.promote():c.relegate()||cn.postRender(()=>{const u=c.getStack();(!u||!u.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:r}=t;r&&(r.options.layoutAnchor=n,r.root.didUpdate(),Fj.postRender(()=>{!r.currentAnimation&&r.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:a}=t;Zy=!0,a&&(a.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(a),r&&r.deregister&&r.deregister(a))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function fP(e){const[t,n]=eP(),r=m.useContext(Nj);return s.jsx(gte,{...e,layoutGroup:r,switchLayoutGroup:m.useContext(oP),isPresent:t,safeToRemove:n})}const vte={pan:{Feature:pte},drag:{Feature:mte,ProjectionNode:JL,MeasureLayout:fP}};function VT(e,t,n){const{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");const a="onHover"+n,o=r[a];o&&cn.postRender(()=>o(t,yf(t)))}class xte extends eo{mount(){const{current:t}=this.node;t&&(this.unmount=zQ(t,(n,r)=>(VT(this.node,r,"Start"),a=>VT(this.node,a,"End"))))}unmount(){}}class yte extends eo{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=gf(Jd(this.node.current,"focus",()=>this.onFocus()),Jd(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function HT(e,t,n){const{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive("whileTap",n==="Start");const a="onTap"+(n==="End"?"":n),o=r[a];o&&cn.postRender(()=>o(t,yf(t)))}class bte extends eo{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:r}=this.node.props;this.unmount=WQ(t,(a,o)=>(HT(this.node,o,"Start"),(c,{success:u})=>HT(this.node,c,u?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:r?.tap===!1})}unmount(){}}const W0=new WeakMap,Yy=new WeakMap,wte=e=>{const t=W0.get(e.target);t&&t(e)},jte=e=>{e.forEach(wte)};function kte({root:e,...t}){const n=e||document;Yy.has(n)||Yy.set(n,{});const r=Yy.get(n),a=JSON.stringify(t);return r[a]||(r[a]=new IntersectionObserver(jte,{root:e,...t})),r[a]}function Nte(e,t,n){const r=kte(t);return W0.set(e,n),r.observe(e),()=>{W0.delete(e),r.unobserve(e)}}const Ste={some:0,all:1};class Cte extends eo{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();const{viewport:t={}}=this.node.getProps(),{root:n,margin:r,amount:a="some",once:o}=t,c={root:n?n.current:void 0,rootMargin:r,threshold:typeof a=="number"?a:Ste[a]},u=f=>{const{isIntersecting:h}=f;if(this.isInView===h||(this.isInView=h,o&&!h&&this.hasEnteredView))return;h&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",h);const{onViewportEnter:p,onViewportLeave:x}=this.node.getProps(),v=h?p:x;v&&v(f)};this.stopObserver=Nte(this.node.current,c,u)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(Ete(t,n))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}}function Ete({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const Ate={inView:{Feature:Cte},tap:{Feature:bte},focus:{Feature:yte},hover:{Feature:xte}},Tte={layout:{ProjectionNode:JL,MeasureLayout:fP}},Mte={...Jee,...Ate,...vte,...Tte},Rte=Gee(Mte,Zee);function Ite(e){return"type"in e&&e.type==="separator"}function _te(e){return"type"in e&&e.type==="group"}var Ote={borderColor:"var(--hud-chrome-border, oklch(var(--border)))"},$te={backgroundColor:"var(--hud-chrome-border, oklch(var(--border)))"};function WT({item:e}){return s.jsxs(oK,{disabled:e.disabled,onClick:e.action,className:"flex items-center gap-3 px-3 py-1.5 text-[12px] font-mono text-popover-foreground outline-none select-none data-[highlighted]:bg-accent/10 data-[highlighted]:text-accent data-[disabled]:opacity-40 data-[disabled]:pointer-events-none cursor-default",children:[e.icon&&s.jsx("span",{className:"w-4 h-4 flex items-center justify-center text-muted-foreground",children:e.icon}),s.jsx("span",{className:"flex-1",children:e.label}),e.shortcut&&s.jsx("span",{className:"text-muted-foreground text-[10px] ml-4 tracking-wider",children:e.shortcut})]})}var hP=y2.forwardRef(({items:e},t)=>s.jsx(Rte.div,{ref:t,initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.1,ease:"easeOut"},children:s.jsx(JZ,{className:"bg-popover/95 backdrop-blur-xl border rounded-lg shadow-2xl py-1 min-w-[180px] z-[200] outline-none",style:Ote,children:e.map((n,r)=>Ite(n)?s.jsx(MY,{className:"h-px my-1",style:$te},`sep-${r}`):_te(n)?s.jsxs(aK,{children:[s.jsx(iK,{className:"px-3 py-1 text-[10px] font-mono uppercase tracking-widest text-muted-foreground",children:n.label}),n.items.map(a=>s.jsx(WT,{item:a},a.id))]},`grp-${r}`):s.jsx(WT,{item:n},n.id))})}));hP.displayName="PopupContent";function Lte(e,t){switch(t){case"alt":return e.altKey;case"meta":return e.metaKey;case"ctrl":return e.ctrlKey;default:return e.shiftKey}}function Pte({items:e,children:t,nativeMenuModifier:n="alt",activationMode:r="default"}){return e.length===0?s.jsx(s.Fragment,{children:t}):s.jsxs(RY,{children:[s.jsx(IY,{render:s.jsx("div",{style:{display:"contents"},onContextMenuCapture:a=>{const o=Lte(a,n);(r==="modifier"?!o:o)&&a.stopPropagation()}}),children:t}),s.jsx(tY,{children:s.jsx(mY,{className:"z-[200]",sideOffset:4,children:s.jsx(kee,{children:s.jsx(hP,{items:e})})})})]})}var Dte=({panOffset:e,scale:t,onPan:n,onPanStart:r,onPanEnd:a,isPanLocked:o=!1,onClick:c,showGuides:u=!1,onGuidesChange:f,gridOpacity:h=1})=>{const[p,x]=m.useState(u),[v,y]=m.useState(!1),b=m.useRef(!1),C=m.useRef({x:0,y:0}),E=m.useRef({active:!1,startX:0,startY:0}),A=m.useRef(null),S=m.useRef(null),k=m.useRef(null),N=4,T=m.useRef({x:0,y:0}),R=m.useRef(0),O=m.useRef(!1);m.useEffect(()=>{x(u)},[u]);const L=m.useCallback(B=>{const Q=B;return Q?Q.tagName==="INPUT"||Q.tagName==="TEXTAREA"||Q.isContentEditable:!1},[]),I=m.useCallback(B=>{const Q=B;return Q?!!Q.closest('button, [role="button"], a, input, textarea, select, [data-interactive="true"]'):!1},[]),z=m.useCallback(B=>{b.current=B,y(B)},[]);m.useEffect(()=>{const B=X=>{if(R.current=X.buttons,E.current.active&&(X.buttons&1)!==1&&(E.current.active=!1),b.current&&(X.buttons&1)!==1){z(!1),E.current.active=!1,a?.(),document.body.style.cursor="";return}if(o&&b.current){z(!1),E.current.active=!1,a?.(),document.body.style.cursor="";return}const ae=A.current?.getBoundingClientRect(),be=ae?X.clientX-ae.left:X.clientX,_e=ae?X.clientY-ae.top:X.clientY;if(T.current={x:be,y:_e},S.current&&(S.current.style.left=`${be}px`),k.current&&(k.current.style.top=`${_e}px`),E.current.active&&!b.current){const xe=X.clientX-E.current.startX,pe=X.clientY-E.current.startY;Math.hypot(xe,pe)>=N&&(E.current.active=!1,z(!0),O.current=!0,r?.(),C.current={x:X.clientX,y:X.clientY},document.body.style.cursor="grabbing")}b.current&&(n({x:(X.clientX-C.current.x)/t,y:(X.clientY-C.current.y)/t}),C.current={x:X.clientX,y:X.clientY})},Q=X=>{R.current=X.buttons,E.current.active=!1,b.current&&(z(!1),a?.(),document.body.style.cursor="")},oe=X=>{(X.metaKey||X.ctrlKey)&&X.key==="\\"&&(X.preventDefault(),x(ae=>{const be=!ae;return f?.(be),be}))},ne=()=>{E.current.active=!1,Q(new MouseEvent("mouseup"))};return window.addEventListener("mousemove",B),window.addEventListener("mouseup",Q),window.addEventListener("keydown",oe),window.addEventListener("blur",ne),document.addEventListener("visibilitychange",ne),()=>{window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",Q),window.removeEventListener("keydown",oe),window.removeEventListener("blur",ne),document.removeEventListener("visibilitychange",ne)}},[n,a,r,t,L,I,o,z,f]),m.useEffect(()=>{!o||!b.current||(z(!1),a?.(),document.body.style.cursor="")},[o,a,z]);const _=B=>{O.current=!1,!(o||B.button!==0)&&(L(B.target)||I(B.target)||(R.current=B.buttons,E.current={active:!0,startX:B.clientX,startY:B.clientY},B.preventDefault()))},U=B=>{!O.current&&c&&c(B),O.current=!1},[D,q]=m.useState({w:0,h:0});m.useEffect(()=>{const B=()=>q({w:window.innerWidth,h:window.innerHeight});return B(),window.addEventListener("resize",B),()=>window.removeEventListener("resize",B)},[]);const Z=Math.max(.4,Math.min(2,t)),$=100*Z,G=20*Z,V="var(--hud-canvas-dot-minor)",Y="var(--hud-canvas-dot-major)",K="color-mix(in srgb, oklch(var(--accent)) 18%, transparent)",P=(D.w/2+e.x*t)%$,H=(D.h/2+e.y*t)%$;return s.jsxs("div",{ref:A,className:`absolute inset-0 z-0 overflow-hidden bg-background ${v?"cursor-grabbing":"cursor-grab"}`,onMouseDown:_,onClick:U,children:[s.jsx("div",{className:"absolute pointer-events-none",style:{inset:"-100px",opacity:.8*h,transition:"opacity 1s ease",backgroundImage:`radial-gradient(circle, ${V} 1px, transparent 1px)`,backgroundSize:`${G}px ${G}px`,backgroundPosition:`${P+100}px ${H+100}px`}}),s.jsx("div",{className:"absolute pointer-events-none",style:{inset:"-100px",opacity:.45*h,transition:"opacity 1s ease",backgroundImage:`radial-gradient(circle, ${Y} 1.5px, transparent 1.5px)`,backgroundSize:`${$}px ${$}px`,backgroundPosition:`${P+100}px ${H+100}px`}}),p&&s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:S,className:"absolute top-0 bottom-0 w-px pointer-events-none",style:{left:0,backgroundColor:K}}),s.jsx("div",{ref:k,className:"absolute left-0 right-0 h-px pointer-events-none",style:{top:0,backgroundColor:K}})]})]})},mP=Dte,qT={borderColor:"var(--hud-chrome-border, oklch(var(--border)))"},zte=({scale:e,onZoom:t,min:n=.2,max:r=3,step:a=.1})=>{const[o,c]=m.useState(!1),[u,f]=m.useState(""),h=m.useRef(null),p=m.useCallback(E=>Math.min(r,Math.max(n,E)),[n,r]),x=m.useCallback(()=>{t(p(e+a))},[e,a,t,p]),v=m.useCallback(()=>{t(p(e-a))},[e,a,t,p]),y=m.useCallback(()=>{f(Math.round(e*100).toString()),c(!0)},[e]),b=m.useCallback(()=>{c(!1);const E=parseInt(u,10);!isNaN(E)&&E>0&&t(p(E/100))},[u,t,p]),C=m.useCallback(E=>{E.key==="Enter"?b():E.key==="Escape"&&c(!1)},[b]);return m.useEffect(()=>{o&&h.current&&(h.current.focus(),h.current.select())},[o]),s.jsxs("div",{className:"pointer-events-auto flex flex-col items-center bg-card/95 border rounded-none shadow-[var(--hud-shadow-panel)] overflow-hidden",style:qT,children:[s.jsx("button",{onClick:x,className:"w-9 h-8 flex items-center justify-center hover:bg-accent/10 text-muted-foreground hover:text-foreground transition-colors",title:"Zoom in",children:s.jsx(FB,{size:14})}),s.jsx("div",{className:"w-full border-t border-b",style:qT,children:o?s.jsx("input",{ref:h,type:"text",value:u,onChange:E=>f(E.target.value.replace(/[^0-9]/g,"")),onBlur:b,onKeyDown:C,className:"w-9 py-1.5 text-center text-[11px] font-mono text-foreground bg-background/60 outline-none tabular-nums"}):s.jsxs("button",{onClick:y,className:"w-9 py-1.5 text-center text-[11px] font-mono text-foreground hover:bg-accent/10 transition-colors cursor-text tabular-nums",title:"Click to set zoom",children:[Math.round(e*100),"%"]})}),s.jsx("button",{onClick:v,className:"w-9 h-8 flex items-center justify-center hover:bg-accent/10 text-muted-foreground hover:text-foreground transition-colors",title:"Zoom out",children:s.jsx(CB,{size:14})})]})},Bte=zte;function Qj(){const{titleBarInset:e}=vg();return m.useMemo(()=>{const t=kg.layout.navHeight+e;return{navTotalHeight:t,panelTopOffset:t}},[e])}var KT=()=>{},Ute={x:0,y:0},Fte=({children:e,hud:t,mode:n="canvas",panOffset:r=Ute,scale:a=1,onPan:o=KT,onZoom:c=KT,onPanStart:u,onPanEnd:f,isTransitioning:h=!1,onViewportChange:p,onCanvasClick:x,canvasProps:v,zoomSensitivity:y,zoomControlsRightOffset:b,zoomControlsBottomOffset:C,showZoomControls:E=!0,viewportShiftX:A=0,canvasContextMenuItems:S,canvasContextMenuActivationMode:k})=>{const N=m.useRef(null),T=m.useRef(a);T.current=a;const R=m.useRef(c);R.current=c;const O=m.useRef(o);O.current=o;const L=m.useRef(u);L.current=u;const I=m.useRef(f);I.current=f;const z=m.useRef(y);z.current=y;const[_,U]=m.useState(!1),D=m.useRef(!1),[q,Z]=m.useState(!1),$=m.useRef(!1),G=m.useRef({x:0,y:0}),V=m.useRef(K=>{const P=K.target||document.activeElement;if(!P)return!1;const H=P.tagName;return!!(H==="INPUT"||H==="TEXTAREA"||P.isContentEditable||P.closest?.(".xterm"))});m.useEffect(()=>{if(n!=="canvas")return;const K=B=>{B.key!==" "||B.repeat||V.current(B)||h||(B.preventDefault(),D.current=!0,U(!0))},P=B=>{B.key===" "&&D.current&&(D.current=!1,U(!1),$.current&&($.current=!1,Z(!1),I.current?.()))},H=()=>{D.current&&(D.current=!1,U(!1),$.current&&($.current=!1,Z(!1),I.current?.()))};return window.addEventListener("keydown",K),window.addEventListener("keyup",P),window.addEventListener("blur",H),()=>{window.removeEventListener("keydown",K),window.removeEventListener("keyup",P),window.removeEventListener("blur",H)}},[n,h]);const Y=m.useCallback(K=>{K.button===0&&(K.preventDefault(),$.current=!0,Z(!0),G.current={x:K.clientX,y:K.clientY},L.current?.())},[]);return m.useEffect(()=>{if(!_)return;const K=H=>{if(!$.current)return;const B=(H.clientX-G.current.x)/T.current,Q=(H.clientY-G.current.y)/T.current;G.current={x:H.clientX,y:H.clientY},O.current({x:B,y:Q})},P=()=>{$.current&&($.current=!1,Z(!1),I.current?.())};return window.addEventListener("mousemove",K),window.addEventListener("mouseup",P),()=>{window.removeEventListener("mousemove",K),window.removeEventListener("mouseup",P)}},[_]),m.useEffect(()=>{if(n!=="canvas")return;const K=P=>{if(P.ctrlKey||P.metaKey){P.preventDefault();const H=T.current,B=-P.deltaY*.001*(z.current??1),Q=Math.min(Math.max(.2,H+B),3);T.current=Q,R.current(Q)}};return window.addEventListener("wheel",K,{passive:!1}),()=>window.removeEventListener("wheel",K)},[n]),m.useEffect(()=>{if(!p)return;let K=null;const P=()=>{K&&cancelAnimationFrame(K),K=requestAnimationFrame(()=>{p({width:window.innerWidth,height:window.innerHeight})})};return P(),window.addEventListener("resize",P),()=>{window.removeEventListener("resize",P),K&&cancelAnimationFrame(K)}},[p]),n==="panel"?s.jsxs("div",{ref:N,className:"fixed inset-0 bg-background text-foreground overflow-hidden font-sans select-none z-0",children:[s.jsx("div",{className:"absolute inset-0 z-10 overflow-auto frame-scrollbar",children:e}),s.jsx("div",{className:"fixed inset-0 z-50 pointer-events-none overflow-hidden",children:t})]}):s.jsxs("div",{ref:N,className:"fixed inset-0 bg-background text-foreground overflow-hidden font-sans select-none z-0",children:[s.jsx(Pte,{items:S??[],activationMode:k,children:s.jsx(mP,{panOffset:r,scale:a,onPan:o,onPanStart:u,onPanEnd:f,isPanLocked:h,onClick:x,showGuides:v?.showGuides,onGuidesChange:v?.onGuidesChange,gridOpacity:v?.gridOpacity})}),s.jsx("div",{className:"absolute z-10 pointer-events-none",style:{left:"50%",top:"50%",zoom:a,transform:A?`translateX(${A}px)`:void 0,transition:"transform 240ms cubic-bezier(0.34, 1.7, 0.64, 1)"},children:s.jsx("div",{style:{position:"absolute",left:r.x,top:r.y},children:e})}),_&&s.jsx("div",{className:`fixed inset-0 z-20 ${q?"cursor-grabbing":"cursor-grab"}`,onMouseDown:Y}),E&&s.jsx("div",{className:"absolute z-30 transition-[bottom,right] duration-200",style:{bottom:`calc(${44+(C??0)}px + var(--hud-player-panel-offset, 0px))`,right:16+(b??0)},children:s.jsx(Bte,{scale:a,onZoom:K=>c(K)})}),s.jsx("div",{className:"fixed inset-0 z-50 pointer-events-none overflow-hidden",children:t})]})},Vte=Fte,Hte=({title:e})=>s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"0.75",strokeLinecap:"square","aria-hidden":"true",focusable:"false",role:"img",style:{flex:"none"},children:[s.jsx("title",{children:e}),s.jsx("rect",{x:"1",y:"1",width:"12",height:"12"}),s.jsx("line",{x1:"7",y1:"3.25",x2:"7",y2:"10.75"}),s.jsx("line",{x1:"3.25",y1:"7",x2:"10.75",y2:"7"}),s.jsx("circle",{cx:"7",cy:"7",r:"0.9",fill:"var(--hud-accent, currentColor)",stroke:"none"}),s.jsx("line",{x1:"1",y1:"11.25",x2:"13",y2:"11.25",strokeWidth:"0.5",opacity:"0.55"})]}),Wte=({title:e,subtitle:t,center:n,actions:r,onTitleClick:a,search:o})=>{const{dragRegionProps:c,onInteractiveMouseDown:u}=vg(),{navTotalHeight:f}=Qj(),h=o&&o.value&&o.value.length>0;return s.jsx("div",{"data-frame-panel":"navigation",className:"fixed top-0 left-0 right-0 z-50 pointer-events-auto",...c,children:s.jsxs("div",{className:"bg-background/95 border-b shadow-[var(--hud-shadow-nav)] flex items-end px-4",style:{height:f,borderColor:"var(--hud-chrome-border, oklch(var(--border) / 0.8))"},children:[s.jsxs("div",{className:"absolute left-4 bottom-0 h-12 z-10 flex items-center gap-3 select-none",onMouseDown:u,children:[s.jsxs("button",{onClick:a,"aria-label":e,className:"group flex items-center gap-[7px] text-foreground/85 hover:text-foreground transition-colors bg-transparent border-none cursor-pointer focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none rounded-sm px-0.5 -mx-0.5 leading-none",children:[s.jsx(Hte,{title:e}),s.jsx("span",{className:"font-mono text-[11px] tracking-[0.06em] lowercase leading-none",children:e})]}),t&&s.jsx("span",{className:"text-xs font-mono font-light text-muted-foreground",children:t})]}),n&&s.jsx("div",{className:"flex-1 flex justify-center h-12 items-center",onMouseDown:u,children:n}),s.jsxs("div",{className:"absolute right-4 bottom-0 h-12 z-10 flex items-center gap-3",onMouseDown:u,children:[r,o&&s.jsxs("div",{className:"hidden sm:block relative w-[220px] max-w-[34vw] bg-card border border-input rounded px-2.5 shadow-[inset_0_1px_0_oklch(var(--foreground)/0.02)] hover:border-ring/60 focus-within:border-ring focus-within:bg-card transition-colors duration-200",children:[s.jsx(Tc,{size:11,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{type:"text",value:o.value,onChange:p=>o.onChange(p.target.value),placeholder:o.placeholder??"Search",className:`
130
- w-full h-7 pl-5 pr-6 bg-transparent text-[11px] font-mono font-normal tracking-[0.02em]
131
- placeholder:text-muted-foreground/80 placeholder:font-light text-foreground
132
- focus:outline-none transition-all duration-200
133
- ${h?"text-accent":""}
134
- `}),h&&s.jsx("button",{onClick:()=>o.onChange(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none rounded-sm",children:s.jsx(Bi,{size:12})})]})]})]})})},qte=Wte,Kte=({side:e,title:t,icon:n,isCollapsed:r=!1,onToggleCollapse:a,headerActions:o,footer:c,style:u,width:f,onResizeStart:h,children:p})=>{const x="var(--hud-chrome-border, oklch(var(--border) / 0.8))";if(r){const S=e==="left"?MB:OB;return s.jsx("button",{onClick:a,className:`fixed top-1/2 -translate-y-1/2 z-40 ${e==="left"?"left-3":"right-3"} p-2.5 rounded bg-card/95 border hover:border-accent/60 shadow-[var(--hud-shadow-panel)] hover:shadow-[var(--hud-shadow-panel-hover,var(--hud-shadow-panel))] transition-all duration-200 group pointer-events-auto focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background focus-visible:outline-none`,style:{borderColor:"var(--hud-chrome-border, oklch(var(--border) / 0.8))"},title:`Expand ${t||"panel"}`,children:s.jsx(S,{size:14,className:"text-muted-foreground group-hover:text-accent transition-colors",strokeWidth:1.5})})}const v=e==="left"?AB:IB,{panelTopOffset:y}=Qj(),E=`bg-card/95 border shadow-[var(--hud-shadow-panel)] fixed z-40 rounded-none border-t-0 overflow-hidden ${e==="left"?"border-l-0 border-r-0":"border-r-0 border-l-0"}`,A={position:"fixed",top:y,bottom:28,left:e==="left"?0:void 0,right:e==="right"?0:void 0,width:`${f||280}px`,borderColor:x,...u};return s.jsxs("div",{"data-frame-panel":e==="left"?"manifest":"inspector",className:`${E} pointer-events-none select-none font-mono text-[11px] flex flex-col`,style:A,children:[h&&s.jsxs("div",{className:`absolute top-0 ${e==="left"?"right-0":"left-0"} bottom-0 w-[7px] cursor-ew-resize z-50 pointer-events-auto group flex items-center justify-center`,onMouseDown:h,children:[s.jsx("div",{className:`absolute top-0 bottom-0 ${e==="left"?"right-0":"left-0"} w-px transition-colors group-hover:bg-accent/30`,style:{backgroundColor:x}}),s.jsxs("div",{className:"flex flex-col gap-[3px] opacity-0 group-hover:opacity-100 transition-opacity",children:[s.jsx("div",{className:"w-[3px] h-[3px] rounded-full bg-muted-foreground/70 group-hover:bg-accent/70"}),s.jsx("div",{className:"w-[3px] h-[3px] rounded-full bg-muted-foreground/70 group-hover:bg-accent/70"}),s.jsx("div",{className:"w-[3px] h-[3px] rounded-full bg-muted-foreground/70 group-hover:bg-accent/70"})]})]}),!h&&s.jsx("div",{className:`absolute top-0 ${e==="left"?"right-0":"left-0"} bottom-0 w-px`,style:{backgroundColor:x}}),s.jsx("div",{className:"absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-foreground/4 to-transparent z-10"}),s.jsxs("div",{className:"pointer-events-auto flex-1 flex flex-col overflow-hidden",children:[t&&s.jsx("div",{className:"shrink-0 p-4",style:{borderBottom:`1px dashed ${x}`},children:s.jsxs("div",{className:"flex items-center justify-between text-foreground text-[10px]",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[n&&s.jsx("span",{className:"text-muted-foreground",children:n}),s.jsx("span",{className:"tracking-[0.18em] font-normal uppercase text-muted-foreground",children:t})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[o,a&&s.jsx("button",{onClick:a,className:"p-1 hover:bg-accent/10 rounded transition-colors text-muted-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",title:"Collapse panel",children:s.jsx(v,{size:12})})]})]})}),s.jsx("div",{className:"flex-1 overflow-y-auto frame-scrollbar",children:p}),c&&s.jsx("div",{className:"shrink-0",children:c})]})]})},GT=Kte,Gte={emerald:{dot:"bg-success",ping:"bg-success",text:"text-success"},amber:{dot:"bg-warning",ping:"bg-warning",text:"text-warning"},red:{dot:"bg-destructive",ping:"bg-destructive",text:"text-destructive"},neutral:{dot:"bg-muted-foreground",ping:"bg-muted-foreground",text:"text-muted-foreground"}},Zte={borderColor:"var(--hud-chrome-border, oklch(var(--border)))"},Yte=({left:e,viewport:t,right:n,isMinimapCollapsed:r=!1,onExpandMinimap:a,status:o={label:"READY",color:"emerald"},onToggleTerminal:c,isTerminalOpen:u=!1})=>{const[f,h]=m.useState(new Date),[p,x]=m.useState(!1),[v,y]=m.useState(!1);m.useEffect(()=>{y(!0);const E=setInterval(()=>h(new Date),1e3);return()=>clearInterval(E)},[]);const b=Gte[o.color],C=async()=>{if(!t)return;const E=`PAN: ${t.pan.x.toFixed(0)},${t.pan.y.toFixed(0)} | SIZE: ${t.canvasSize?.w??1024}x${t.canvasSize?.h??1024} | ZOOM: ${(t.zoom*100).toFixed(0)}%`;try{await navigator.clipboard.writeText(E),x(!0),setTimeout(()=>x(!1),1500)}catch{}};return s.jsxs("div",{"data-frame-panel":"status-bar",className:`${t7.statusBar} h-7 flex items-center justify-between gap-3 px-3 select-none font-mono text-[9px] md:text-[10px] text-foreground pointer-events-auto overflow-hidden`,style:Zte,children:[s.jsxs("div",{className:"min-w-0 flex items-center gap-3 md:gap-4 overflow-hidden",children:[r&&a&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:a,className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none rounded",title:"Expand minimap",children:[s.jsx(pB,{size:10}),s.jsx("span",{className:"text-[9px] font-light tracking-[0.18em] uppercase",children:"Map"})]}),s.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground/40 select-none",children:"·"})]}),s.jsxs("div",{className:`shrink-0 flex items-center gap-2 ${b.text}`,children:[s.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${b.dot}`}),s.jsx("span",{className:"font-light tracking-[0.18em] uppercase text-[9px]",children:o.label})]}),e&&s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground/40 select-none",children:"·"}),e]})]}),t&&s.jsx("div",{className:"hidden lg:flex absolute -translate-x-1/2 items-center gap-3 opacity-70 hover:opacity-100 transition-[left,opacity] duration-200",style:{left:"calc(50% - var(--hud-player-status-inline-offset, 0px))"},children:s.jsxs("button",{onClick:C,className:"flex items-center gap-3 hover:text-foreground transition-colors cursor-pointer focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none rounded",title:"Copy viewport data",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-muted-foreground tracking-[0.18em] text-[9px] uppercase",children:"Pan"}),s.jsxs("span",{className:`tabular-nums ${p?"text-accent":""}`,children:[t.pan.x.toFixed(0),",",t.pan.y.toFixed(0)]})]}),s.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground/40 select-none",children:"·"}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-muted-foreground tracking-[0.18em] text-[9px] uppercase",children:"Size"}),s.jsxs("span",{className:`tabular-nums ${p?"text-accent":""}`,children:[t.canvasSize?.w??1024,"x",t.canvasSize?.h??1024]})]}),s.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground/40 select-none",children:"·"}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-muted-foreground tracking-[0.18em] text-[9px] uppercase",children:"Zoom"}),s.jsxs("span",{className:`tabular-nums ${p?"text-accent":""}`,children:[(t.zoom*100).toFixed(0),"%"]})]})]})}),s.jsxs("div",{className:"shrink-0 flex items-center gap-3 md:gap-4",children:[c&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:c,className:`flex items-center gap-1.5 transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none rounded ${u?"text-accent":"text-muted-foreground hover:text-foreground"}`,title:"Toggle Terminal (Ctrl+`)",children:[s.jsxs("span",{className:"text-[10px]",children:[">","_"]}),s.jsx("span",{className:"uppercase text-[9px] font-light tracking-[0.18em]",children:"Console"})]}),s.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground/40 select-none",children:"·"})]}),n,n&&s.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground/40 select-none",children:"·"}),s.jsxs("div",{className:"flex items-center gap-1.5 text-foreground min-w-[60px] justify-end",children:[s.jsx(L6,{size:11,className:"text-muted-foreground"}),s.jsx("span",{children:v?f.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"--:--"})]})]})]})},Xte=Yte,Qte=({onOpenCommandPalette:e,extraControls:t})=>s.jsx("div",{className:"select-none font-mono text-[11px]",style:{borderTop:"1px dashed var(--hud-chrome-border, oklch(var(--border) / 0.6))"},children:s.jsxs("div",{className:"px-3 py-2 flex items-center justify-between",children:[s.jsxs("button",{onClick:e,className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none rounded",children:[s.jsx(Tc,{size:10}),s.jsx("span",{className:"tracking-[0.18em] font-normal uppercase text-[10px]",children:"Command Palette"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[t,s.jsx("kbd",{className:"text-[10px] text-muted-foreground font-mono",children:"⌘K"})]})]})}),Jte=Qte,{statusBarHeight:sm}=kg.layout,ZT=120,YT={borderColor:"var(--hud-chrome-border, oklch(var(--border)))"},ene={backgroundColor:"var(--hud-chrome-border, oklch(var(--border)))"},tne=({isOpen:e,onClose:t,onToggleMaximize:n,isMaximized:r=!1,height:a=320,onHeightChange:o,title:c,headerActions:u,contentOverlay:f,children:h})=>{const p=m.useRef(!1),x=m.useRef(null),v=m.useCallback(b=>{if(!o)return;b.preventDefault(),p.current=!0;const C=b.clientY,E=a;x.current&&(x.current.style.transition="none");const A=k=>{const N=C-k.clientY,T=window.innerHeight-sm,R=Math.max(ZT,Math.min(T,E+N));x.current&&(x.current.style.height=`${R}px`)},S=k=>{p.current=!1,document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",S),x.current&&(x.current.style.transition="");const N=C-k.clientY,T=window.innerHeight-sm;o(Math.max(ZT,Math.min(T,E+N)))};document.addEventListener("mousemove",A),document.addEventListener("mouseup",S)},[a,o]),y=r?`calc(100vh - ${sm}px)`:`${a}px`;return s.jsxs("div",{ref:x,"data-hudson-template":"hudson",className:`
135
- fixed left-0 right-0 shadow-[0_-2px_12px_rgba(0,0,0,0.16)] flex flex-col border-t text-card-foreground
136
- bg-card
137
- ${e?"translate-y-0 opacity-100 pointer-events-auto":"translate-y-full opacity-0 pointer-events-none"}
138
- transition-all duration-300 ease-in-out
139
- `,style:{bottom:sm,height:y,zIndex:kg.zIndex.drawer,...YT},children:[s.jsxs("div",{className:"h-9 bg-card/80 border-b flex items-center justify-between px-3 shrink-0 select-none backdrop-blur-sm",style:YT,children:[s.jsxs("div",{className:"flex items-center gap-3",children:[c||s.jsxs("div",{className:"flex items-center gap-2 text-accent",children:[s.jsx(Zw,{size:14}),s.jsx("span",{className:"text-[10px] font-light tracking-[0.18em] font-mono uppercase",children:"TERMINAL"})]}),u]}),s.jsx("div",{className:"flex-1 flex items-center justify-center h-full cursor-ns-resize text-muted-foreground hover:text-foreground transition-colors group",title:"Drag to Resize",onMouseDown:v,children:s.jsx("div",{className:"w-16 h-1 rounded-full group-hover:bg-muted-foreground transition-colors",style:ene})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:n,className:"p-1.5 rounded hover:bg-accent/10 text-muted-foreground hover:text-foreground transition-colors",title:r?"Restore":"Maximize",children:r?s.jsx(C2,{size:14}):s.jsx(qw,{size:14})}),s.jsx("button",{onClick:t,className:"p-1.5 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors",title:"Close",children:s.jsx(Bi,{size:14})})]})]}),s.jsxs("div",{"data-hudson-terminal-drawer-content":"true",className:"flex-1 relative overflow-hidden flex flex-col bg-transparent",children:[h,f&&s.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-3 z-30 flex justify-center px-4",children:s.jsx("div",{className:"pointer-events-auto",children:f})})]})]})},nne=tne,Gu={borderColor:"var(--hud-chrome-border, oklch(var(--border)))"},sne={"--tw-ring-color":"color-mix(in srgb, var(--hud-accent, currentColor) 34%, transparent)"},rne=({isOpen:e,onClose:t,commands:n})=>{const[r,a]=m.useState(""),[o,c]=m.useState(0),u=m.useRef(null),f=m.useRef(null),h=n.filter(v=>v.label.toLowerCase().includes(r.toLowerCase()));m.useEffect(()=>{e&&(Qb.logger.info("hudson.command_palette.open",{category:"command",data:{commandCount:n.length}}),setTimeout(()=>u.current?.focus(),10),a(""),c(0))},[n.length,e]),m.useEffect(()=>{c(0)},[r]),m.useEffect(()=>{f.current?.scrollIntoView({behavior:"smooth",block:"nearest"})},[o]);const p=(v,y)=>{const b=Qb.trace.start("hudson.command.execute",{category:"command",data:{commandId:v.id,surface:"command_palette",source:y,queryLength:r.length,resultCount:h.length}});try{v.action(),b.end(),t()}catch(C){throw b.error(C),C}},x=v=>{if((v.key==="ArrowDown"||v.key==="ArrowUp")&&h.length===0){v.preventDefault();return}v.key==="ArrowDown"?(v.preventDefault(),c(y=>(y+1)%h.length)):v.key==="ArrowUp"?(v.preventDefault(),c(y=>(y-1+h.length)%h.length)):v.key==="Enter"?(v.preventDefault(),h[o]&&p(h[o],"keyboard")):v.key==="Escape"&&t()};return e?s.jsx("div",{className:"fixed inset-0 z-[100] flex items-start justify-center pt-[15vh] bg-background/45 backdrop-blur-[2px] pointer-events-auto",onClick:t,children:s.jsxs("div",{className:"w-[640px] max-w-[90vw] bg-popover border shadow-2xl rounded-lg overflow-hidden flex flex-col animate-in fade-in zoom-in-95 duration-100",style:Gu,onClick:v=>v.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center px-4 py-3 border-b gap-3 focus-within:ring-2 focus-within:outline-none",style:{...Gu,...sne},children:[s.jsx(Tc,{className:"text-muted-foreground",size:16,strokeWidth:1.5}),s.jsx("input",{ref:u,className:"flex-1 bg-transparent border-none outline-none text-popover-foreground placeholder:text-muted-foreground font-mono text-[12px] font-normal",style:{boxShadow:"none"},placeholder:"Type a command or search",value:r,onChange:v=>a(v.target.value),onKeyDown:x,autoFocus:!0}),s.jsx("div",{className:"px-1.5 py-0.5 rounded bg-muted border text-[10px] text-muted-foreground font-mono tracking-[0.12em]",style:Gu,children:"ESC"})]}),s.jsxs("div",{className:"max-h-[300px] overflow-y-auto py-2 relative",children:[s.jsx("div",{className:"pb-2",children:h.length===0?s.jsx("div",{className:"px-4 py-8 text-center text-muted-foreground text-[11px] font-mono",children:"No matching commands"}):h.map((v,y)=>s.jsxs("div",{ref:y===o?f:null,tabIndex:0,className:`px-4 py-2.5 flex items-center gap-3 cursor-pointer transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none focus-visible:bg-muted ${y===o?"bg-accent/10 border-l-2 border-accent":"border-l-2 border-transparent hover:bg-muted/70"}`,onClick:()=>p(v,"pointer"),onMouseEnter:()=>c(y),children:[v.icon&&s.jsx("div",{className:`${y===o?"text-accent":"text-muted-foreground"}`,children:v.icon}),s.jsx("div",{className:"flex-1",children:s.jsx("div",{className:`text-[12px] ${y===o?"text-accent font-medium":"text-foreground/80 font-normal"}`,children:v.label})}),v.shortcut&&s.jsx("div",{className:"text-[10px] font-mono text-muted-foreground bg-muted px-1.5 py-0.5 rounded border tracking-[0.04em]",style:Gu,children:v.shortcut}),y===o&&s.jsx(F6,{size:14,className:"text-accent ml-2"})]},v.id))}),h.length>6&&s.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-8 bg-gradient-to-t from-popover to-transparent pointer-events-none"})]}),s.jsxs("div",{className:"px-4 py-1.5 bg-card/90 backdrop-blur-sm border-t flex justify-between items-center text-[10px] text-muted-foreground font-mono relative z-10 tracking-[0.18em] uppercase",style:Gu,children:[s.jsx("span",{children:"Command Palette"}),s.jsxs("span",{className:"tracking-[0.04em] normal-case",children:[h.length," matches"]})]})]})}):null},ane=rne;const pP=m.createContext(null),gP=m.createContext(null);function ine({children:e}){const[t,n]=m.useState(null);return s.jsx(pP.Provider,{value:t,children:s.jsx(gP.Provider,{value:n,children:e})})}function one(){return m.useContext(pP)}function lne(e){const t=m.useContext(gP);m.useEffect(()=>{if(t)return t(e),()=>{t(n=>n?.id===e?.id?null:n)}},[e,t])}const Jj="/api",cne=`${Jj}/health`,une=`${Jj}/terminal/run`,dne=`${Jj}/vantage/open`,vP="/ws/terminal",fne=`${vP}/health`,hne="/ws/hmr";function mne(e,t){if(typeof e!="string")return t;const n=e.trim();return n&&`${n.startsWith("/")?"":"/"}${n}`.replace(/\/{2,}/g,"/").replace(/\/+$/g,"")||t}const pne={healthPath:cne,terminalRunPath:une,vantageOpenPath:dne,terminalRelayPath:vP,terminalRelayHealthPath:fne,viteHmrPath:hne};function ek(){return typeof window>"u"?null:window.__OPENSCOUT_WEB_BOOTSTRAP__??null}function gne(){const e=ek()?.theme;return typeof e=="string"?e:null}function vne(){const e=ek()?.featureFlags?.bundle;return typeof e=="string"?e:null}function zg(e){return mne(ek()?.routes?.[e],pne[e])}function xP(){const e=zg("terminalRelayPath");return typeof window>"u"?`ws://localhost:3200${e}`:`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${e}`}function yP(){const e=zg("terminalRelayHealthPath");return typeof window>"u"?`http://localhost:3200${e}`:`${window.location.protocol}//${window.location.host}${e}`}const tk=["everyone","internal","power"],bP="openscout.flags",q0="openscout.flagBundle",wP={tier:"power"},XT=["ops.control","ops.mesh","ops.runtime","ops.plans","ops.terminal"],QT=["surface.search","surface.sessions","surface.briefings","surface.work","surface.activity","surface.follow","surface.scoutbot","surface.workflows"],jP={"nav.clean":{label:"Nav · Clean",description:"Lean launch nav — Home · Agents · Chat · Tail · Dispatch · Repos (mirrors the macOS core). Promotes Tail/Dispatch/Repos to top level; drops Search + the rest of Ops off the primary bar (still reachable via the Ops subnav + command palette).",defaultEnabled:!1,tier:"everyone",owner:"scout-web",tags:["nav","launch"]},"ops.control":{label:"Ops · Control",description:"Mission control, issues, and the Ops section shell.",defaultEnabled:!0,tier:"power",owner:"scout-web",tags:["ops","nav"]},"ops.mesh":{label:"Ops · Mesh",description:"Mesh topology and peer status.",defaultEnabled:!0,tier:"power",owner:"scout-web",tags:["ops"]},"ops.runtime":{label:"Ops · Runtime",description:"Runtime / atop process telemetry.",defaultEnabled:!0,tier:"power",owner:"scout-web",tags:["ops"]},"ops.plans":{label:"Ops · Plans",description:"Plan documents and plan-mode review.",defaultEnabled:!0,tier:"power",owner:"scout-web",tags:["ops"]},"ops.terminal":{label:"Ops · Terminal",description:"Observe / takeover terminal sessions.",defaultEnabled:!0,tier:"power",owner:"scout-web",tags:["ops"]},"surface.search":{label:"Surface · Search",description:"Knowledge + indexer search as a top-level nav entry.",defaultEnabled:!1,tier:"everyone",owner:"scout-web",tags:["surface","nav"]},"surface.sessions":{label:"Surface · Sessions",description:"Standalone top-level Sessions entry (still reachable under Agents).",defaultEnabled:!1,tier:"everyone",owner:"scout-web",tags:["surface","nav"]},"surface.briefings":{label:"Surface · Briefings",description:"Briefings list + detail.",defaultEnabled:!1,tier:"everyone",owner:"scout-web",tags:["surface"]},"surface.work":{label:"Surface · Work",description:"Work item detail.",defaultEnabled:!1,tier:"everyone",owner:"scout-web",tags:["surface"]},"surface.activity":{label:"Surface · Activity",description:"Activity stream.",defaultEnabled:!1,tier:"everyone",owner:"scout-web",tags:["surface"]},"surface.follow":{label:"Surface · Follow",description:"Follow view.",defaultEnabled:!1,tier:"everyone",owner:"scout-web",tags:["surface"]},"surface.scoutbot":{label:"Surface · Scoutbot",description:"Scoutbot assistant — the inspector panel, the status-bar broadcast chip, and the Ask-Scout command-palette actions.",defaultEnabled:!0,tier:"everyone",owner:"scout-web",tags:["surface","assistant"]},"surface.workflows":{label:"Surface · Workflows",description:"Observed harness families / workflow topology telemetry on the Agents directory. Off in the lean view — the directory is just the project-grouped agent board.",defaultEnabled:!1,tier:"everyone",owner:"scout-web",tags:["surface","observability"]}},xne={a:"light-prod",control:"light-prod",light:"light-prod","light-prod":"light-prod",prod:"light-prod",production:"light-prod",b:"max-pro",max:"max-pro","max-pro":"max-pro",pro:"max-pro",treatment:"max-pro"},JT=new Set(["clear","default","none","reset","unset"]);function rm(e,t){return Object.fromEntries(e.map(n=>[n,t]))}function kP(...e){const t={};for(const n of e)n.audience&&(t.audience=n.audience),n.flags&&Object.keys(n.flags).length>0&&(t.flags={...t.flags??{},...n.flags});return t}function nk(e){switch(e){case"light-prod":return{audience:"everyone",flags:{"nav.clean":!0,...rm(XT,!1),...rm(QT,!1)}};case"max-pro":return{audience:"power",flags:{"nav.clean":!1,...rm(XT,!0),...rm(QT,!0)}}}}function ef(e){return e?xne[e.trim().toLowerCase()]??null:null}function NP(e){const t=e.get("ffBundle")??e.get("ffVariant")??e.get("scoutBundle")??e.get("scoutExperience")??e.get("ab");return ef(t)}function yne(e){const t=e.get("ffGlobal")??e.get("scoutGlobalBundle");if(t){const c=t.trim().toLowerCase();if(JT.has(c))return{action:"clear"};const u=ef(t);return u?{action:"set",bundle:u}:null}const n=e.get("ffPersist")??e.get("persistBundle");if(!n)return null;const r=n.trim().toLowerCase();if(JT.has(r))return{action:"clear"};if(["0","false","no"].includes(r))return null;const a=ef(n);if(a)return{action:"set",bundle:a};const o=NP(e);return o?{action:"set",bundle:o}:null}function bne(){if(typeof window>"u")return null;try{return ef(window.localStorage.getItem(q0))}catch{return null}}function wne(e){if(!(typeof window>"u"))try{e.action==="clear"?window.localStorage.removeItem(q0):window.localStorage.setItem(q0,e.bundle)}catch{}}function SP(){const e=bne();return e?nk(e):{}}const jne="light-prod";function CP(){const e=ef(vne())??jne;return nk(e)}function kne(e){const t=yne(e);t&&wne(t)}function EP(e=new URLSearchParams(window.location.search)){const t=Y8(window.location.href),n=NP(e),r=n?nk(n):{},a={audience:t.audience??r.audience,flags:{...r.flags??{},...t.flags??{}}};return e.has("no-ops")&&(a.flags={...a.flags,"ops.control":!1}),a}function Nne(){const e=L2(bP);return{flags:e.flags,audience:e.audience??void 0}}function Sne(){if(typeof window>"u")return{};const e=new URLSearchParams(window.location.search);return kne(e),{sharedConfig:kP(CP(),SP()),url:EP(e)}}function AP(e){const t=typeof window>"u"?{}:{sharedConfig:kP(CP(),SP()),url:EP(),local:Nne()};return $2({registry:jP,audience:wP,audienceOrder:tk,layers:t,warnOnUnknown:!1}).isEnabled(e)}const Xy=new Map;function Cne(e){const t=e.replace(/\s+/g," ").trim();return t?t.length>180?`${t.slice(0,180)}...`:t:"empty body"}function Qy(e,t,n){if(t)try{return JSON.parse(t)}catch{const r=n?.trim()||"non-JSON";throw new Error(`Expected JSON from ${e} but received ${r}: ${Cne(t)}`)}}function Ene(e){return e?JSON.stringify([...new Headers(e).entries()].sort(([t],[n])=>t.localeCompare(n))):""}function Ane(e,t){return`${(t?.method??"GET").toUpperCase()}:${e}:${Ene(t?.headers)}`}async function eM(e,t){const n=await fetch(e,{...t,headers:{...t?.headers??{},...t?.body?{"content-type":"application/json"}:{}}});if(!n.ok){const r=await n.text();let a=r||`HTTP ${n.status}`;try{const o=JSON.parse(r);o?.error&&(a=o.error)}catch{}throw new Error(a)}return{text:await n.text(),contentType:n.headers.get("content-type")}}async function ue(e,t){if(!((t?.method??"GET").toUpperCase()==="GET"&&!t?.body)){const u=await eM(e,t);return Qy(e,u.text,u.contentType)}const a=Ane(e,t),o=Xy.get(a);if(o){const u=await o;return Qy(e,u.text,u.contentType)}const c=eM(e,t);Xy.set(a,c);try{const u=await c;return Qy(e,u.text,u.contentType)}finally{Xy.delete(a)}}function TP(){return AP("ops.control")}function Tne(e){switch(e){case"profile":case"observe":case"message":return e;default:return}}function Mne(e){switch(e){case"control":case"mission":case"command":case"warroom":case"conduct":case"conductor":return"mission";case"plan":return"plan";case"issues":case"errors":case"warnings":return"issues";case"agents":case"tail":case"atop":return e;default:return}}function Rne(e){return e==="dm"||e==="channel"||e==="all"?e:void 0}function Ine(e){return e==="recent"||e==="name"||e==="unread"?e:void 0}function _ne(e){return e==="indexer"||e==="knowledge"?e:void 0}function One(e){switch(e){case"tail":case"session":case"chat":case"work":return e;default:return}}function $ne(e){const t=e?.trim().replace(/\.+$/u,"");return t==="observe"||t==="takeover"?t:void 0}function tM(e){return e==="mission"?"control":e}function Lne(e){return e.searchParams.has("no-ops")?!1:typeof window>"u"?!0:TP()}function MP(e){return e==="tail"&&AP("nav.clean")}const RP="machineId",IP=new Set(["inbox","conversation","agents","fleet","conversations","messages","sessions","repos","harnesses","channels","mesh","activity","work"]);function Pne(e){return e.searchParams.get(RP)?.trim()||void 0}function Dne(e,t){return!t||!IP.has(e.view)?e:{...e,machineId:t}}function tf(e){return IP.has(e.view)}function zs(e){return"machineId"in e&&e.machineId?e.machineId:null}function K0(e,t){if(!tf(e))return e;const n={...e},r=t?.trim();return r?n.machineId=r:delete n.machineId,n}function zne(e){return tf(e)?{...e,machineId:""}:e}function Bne(e,t){return tf(e)?"machineId"in e?K0(e,e.machineId??null):K0(e,zs(t)):e}function tp(e,t){"machineId"in t&&t.machineId&&e.set(RP,t.machineId)}function rc(e){const t=e.toString();return t?`?${t}`:""}function Gr(e,t){const n=new URLSearchParams;return tp(n,t),`${e}${rc(n)}`}function Une(e){return"machineId"in e&&e.machineId?`:machine:${e.machineId}`:""}function Fne(e){const t=new URL(e.toString()),n=t.pathname.replace(/^\/+/,"").split("/").filter(Boolean),r=Pne(t),a=f=>Dne(f,r),o=t.searchParams.get("compose")==="ask"?"ask":void 0,c=Tne(t.searchParams.get("tab")),u=t.searchParams.get("project")?.trim()||void 0;if(n[0]==="agent"&&n[1])return{view:"agent-info",conversationId:decodeURIComponent(n[1])};if(n[0]==="agents"&&n[1]&&n[2]==="c"&&n[3])return a({view:"agents",agentId:decodeURIComponent(n[1]),conversationId:decodeURIComponent(n[3]),tab:c??"message"});if(n[0]==="agents"&&n[1]){const f=decodeURIComponent(n[1]);return a(c==="message"?{view:"agents",agentId:f,conversationId:Qn(f),tab:"message"}:{view:"agents",agentId:f,...c?{tab:c}:{}})}if(n[0]==="agents")return a({view:"agents",...u?{projectKey:u}:{}});if(n[0]==="fleet")return a({view:"fleet"});if(n[0]==="c"&&n[1])return a({view:"conversation",conversationId:decodeURIComponent(n[1]),...o?{composeMode:o}:{}});if(n[0]==="sessions"&&n[1])return a({view:"sessions",sessionId:decodeURIComponent(n[1])});if(n[0]==="conversations")return a({view:"conversations"});if(n[0]==="messages"){const f=Rne(t.searchParams.get("filter")),h=Ine(t.searchParams.get("sort")),p={view:"messages",...n[1]?{conversationId:decodeURIComponent(n[1])}:{},...f?{filter:f}:{},...h?{sort:h}:{}};return a(p)}if(n[0]==="sessions")return a({view:"sessions"});if(n[0]==="repos")return a({view:"repos"});if(n[0]==="harnesses")return a({view:"harnesses"});if(n[0]==="repo-diff"){const f=t.searchParams.get("path")?.trim();if(f){const h=t.searchParams.getAll("layer").filter(p=>p==="unstaged"||p==="staged"||p==="branch");return{view:"repo-diff",path:f,...h.length>0?{layers:h}:{}}}}if(n[0]==="search"){const f=_ne(n[1]);return{view:"search",...f&&f!=="knowledge"?{mode:f}:{}}}if(n[0]==="channels"&&n[1])return a({view:"channels",channelId:decodeURIComponent(n[1])});if(n[0]==="channels")return a({view:"channels"});if(n[0]==="mesh")return a({view:"mesh"});if(n[0]==="broker")return{view:"broker"};if(n[0]==="briefings"&&n[1])return{view:"briefings",briefingId:decodeURIComponent(n[1])};if(n[0]==="briefings")return{view:"briefings"};if(n[0]==="activity")return a({view:"activity"});if(n[0]==="work"&&n[1])return a({view:"work",workId:decodeURIComponent(n[1])});if(n[0]==="follow"){const f=One(t.searchParams.get("view")),h={view:"follow",...f?{preferredView:f}:{}},p=n[1],x=n[2]?decodeURIComponent(n[2]):"";p==="flight"&&x&&(h.flightId=x),p==="invocation"&&x&&(h.invocationId=x),p==="conversation"&&x&&(h.conversationId=x),p==="work"&&x&&(h.workId=x),p==="session"&&x&&(h.sessionId=x),p==="agent"&&x&&(h.targetAgentId=x);const v=t.searchParams.get("flightId"),y=t.searchParams.get("invocationId"),b=t.searchParams.get("conversationId"),C=t.searchParams.get("workId"),E=t.searchParams.get("sessionId"),A=t.searchParams.get("targetAgentId");return v&&(h.flightId=v),y&&(h.invocationId=y),b&&(h.conversationId=b),C&&(h.workId=C),E&&(h.sessionId=E),A&&(h.targetAgentId=A),h}if(n[0]==="settings")return n[1]==="agents"?{view:"settings",section:"agents",...n[2]?{agentId:decodeURIComponent(n[2])}:{}}:{view:"settings"};if(n[0]==="terminal"){const f=$ne(t.searchParams.get("mode"));return{view:"terminal",...n[1]?{agentId:decodeURIComponent(n[1])}:{},...f?{mode:f}:{}}}if(n[0]==="ops"){const f=Mne(n[1])??"mission";if(!MP(f)&&!Lne(t))return a({view:"inbox"});const h=f==="tail"?t.searchParams.get("q")?.trim():"",p=f==="plan"?t.searchParams.get("plan")?.trim():"";return{view:"ops",mode:f,...h?{tailQuery:h}:{},...p?{planDocumentId:p}:{}}}return a({view:"inbox"})}function Jy(){return Fne(window.location.href)}function Vne(e){switch(e.view){case"inbox":return Gr("/",e);case"conversation":{const t=new URLSearchParams;return e.composeMode==="ask"&&t.set("compose","ask"),tp(t,e),`/c/${encodeURIComponent(e.conversationId)}${rc(t)}`}case"agent-info":return`/agent/${encodeURIComponent(e.conversationId)}`;case"agents":{const t=new URLSearchParams,n=!!e.agentId&&!!e.conversationId&&e.conversationId===Qn(e.agentId),r=n?"profile":e.conversationId?"message":"profile";return n?t.set("tab",e.tab??"message"):e.tab&&e.tab!==r&&t.set("tab",e.tab),!e.agentId&&e.projectKey&&t.set("project",e.projectKey),tp(t,e),`${e.agentId?n?`/agents/${encodeURIComponent(e.agentId)}`:e.conversationId?`/agents/${encodeURIComponent(e.agentId)}/c/${encodeURIComponent(e.conversationId)}`:`/agents/${encodeURIComponent(e.agentId)}`:"/agents"}${rc(t)}`}case"fleet":return Gr("/fleet",e);case"conversations":return Gr("/conversations",e);case"messages":{const t=new URLSearchParams;return e.filter&&e.filter!=="all"&&t.set("filter",e.filter),e.sort&&e.sort!=="recent"&&t.set("sort",e.sort),tp(t,e),`${e.conversationId?`/messages/${encodeURIComponent(e.conversationId)}`:"/messages"}${rc(t)}`}case"sessions":return Gr(e.sessionId?`/sessions/${encodeURIComponent(e.sessionId)}`:"/sessions",e);case"repos":return Gr("/repos",e);case"harnesses":return Gr("/harnesses",e);case"repo-diff":{const t=new URLSearchParams;t.set("path",e.path);for(const n of e.layers??[])t.append("layer",n);return`/repo-diff${rc(t)}`}case"search":return e.mode==="indexer"?"/search/indexer":"/search";case"channels":return Gr(e.channelId?`/channels/${encodeURIComponent(e.channelId)}`:"/channels",e);case"mesh":return Gr("/mesh",e);case"broker":return"/broker";case"briefings":return e.briefingId?`/briefings/${encodeURIComponent(e.briefingId)}`:"/briefings";case"activity":return Gr("/activity",e);case"work":return Gr(`/work/${encodeURIComponent(e.workId)}`,e);case"settings":return e.section==="agents"?e.agentId?`/settings/agents/${encodeURIComponent(e.agentId)}`:"/settings/agents":"/settings";case"ops":if(!e.mode)return"/ops";if(e.mode==="tail"||e.mode==="plan"){const t=new URLSearchParams;return e.mode==="tail"&&e.tailQuery&&t.set("q",e.tailQuery),e.mode==="plan"&&e.planDocumentId&&t.set("plan",e.planDocumentId),`/ops/${tM(e.mode)}${rc(t)}`}return`/ops/${tM(e.mode)}`;case"follow":{const t=new URLSearchParams;e.preferredView&&t.set("view",e.preferredView),e.flightId&&t.set("flightId",e.flightId),e.invocationId&&t.set("invocationId",e.invocationId),e.conversationId&&t.set("conversationId",e.conversationId),e.workId&&t.set("workId",e.workId),e.sessionId&&t.set("sessionId",e.sessionId),e.targetAgentId&&t.set("targetAgentId",e.targetAgentId);const n=t.toString();return`/follow${n?`?${n}`:""}`}case"terminal":return e.mode?`${e.agentId?`/terminal/${encodeURIComponent(e.agentId)}`:"/terminal"}?mode=${e.mode}`:e.agentId?`/terminal/${encodeURIComponent(e.agentId)}`:"/terminal"}}function eb(e){const t=Une(e);switch(e.view){case"conversation":return`conv:${e.conversationId}${t}`;case"agent-info":return`agent-info:${e.conversationId}`;case"settings":return e.section==="agents"?`settings:agents:${e.agentId??""}`:"settings";case"agents":return e.conversationId?`agent-conv:${e.conversationId}:${e.tab??"message"}${t}`:e.agentId?`agent:${e.agentId}:${e.tab??"profile"}${t}`:e.projectKey?`agents-project:${e.projectKey}${t}`:`agents${t}`;case"sessions":return e.sessionId?`session:${e.sessionId}${t}`:`sessions${t}`;case"messages":return e.conversationId?`messages:${e.conversationId}${t}`:`messages${t}`;case"channels":return e.channelId?`channel:${e.channelId}${t}`:`channels${t}`;case"work":return`work:${e.workId}${t}`;case"ops":return`ops:${e.mode??"plan"}:${e.tailQuery??""}:${e.planDocumentId??""}`;case"search":return`search:${e.mode??"knowledge"}`;case"follow":return`follow:${e.flightId??e.invocationId??e.conversationId??e.workId??e.sessionId??e.targetAgentId??""}:${e.preferredView??""}`;case"terminal":return`terminal:${e.agentId??""}:${e.mode??"takeover"}`;case"repo-diff":return`repo-diff:${e.path}`;default:return`${e.view}${t}`}}function Hne(){const[e,t]=m.useState(Jy),n=m.useRef({});m.useEffect(()=>{const a=()=>{const o=Jy();t(o),requestAnimationFrame(()=>{window.scrollTo(0,n.current[eb(o)]??0)})};return window.addEventListener("popstate",a),()=>window.removeEventListener("popstate",a)},[]);const r=m.useCallback(a=>{const o=a.view==="ops"&&!TP()&&!MP(a.mode)?{view:"inbox"}:a,c=Jy(),u=Bne(o,c);n.current[eb(c)]=window.scrollY,window.history.pushState(null,"",Vne(u)),t(u),requestAnimationFrame(()=>{window.scrollTo(0,n.current[eb(u)]??0)})},[]);return{route:e,navigate:r}}function Bg(e){const t=e.match(/^dm\.operator\.(.+)$/);return t?t[1]:null}function Qn(e){return`dm.operator.${e}`}var Wne=Object.create,_P=Object.defineProperty,qne=Object.getOwnPropertyDescriptor,OP=Object.getOwnPropertyNames,Kne=Object.getPrototypeOf,Gne=Object.prototype.hasOwnProperty,pa=(e,t)=>function(){return t||(0,e[OP(e)[0]])((t={exports:{}}).exports,t),t.exports},Zne=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=OP(t),o=0,c=a.length,u;o<c;o++)u=a[o],!Gne.call(e,u)&&u!==n&&_P(e,u,{get:(f=>t[f]).bind(null,u),enumerable:!(r=qne(t,u))||r.enumerable});return e},Dn=(e,t,n)=>(n=e!=null?Wne(Kne(e)):{},Zne(_P(n,"default",{value:e,enumerable:!0}),e)),$P=pa({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e,t){function n(r){"@babel/helpers - typeof";return t.exports=n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},t.exports.__esModule=!0,t.exports.default=t.exports,n(r)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),Yne=pa({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e,t){var n=$P().default;function r(a,o){if(n(a)!="object"||!a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var u=c.call(a,o||"default");if(n(u)!="object")return u;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(a)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),Xne=pa({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e,t){var n=$P().default,r=Yne();function a(o){var c=r(o,"string");return n(c)=="symbol"?c:c+""}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports}}),ol=pa({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e,t){var n=Xne();function r(a,o,c){return(o=n(o))in a?Object.defineProperty(a,o,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[o]=c,a}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),Ur=pa({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e,t){var n=ol();function r(o,c){var u=Object.keys(o);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(o);c&&(f=f.filter(function(h){return Object.getOwnPropertyDescriptor(o,h).enumerable})),u.push.apply(u,f)}return u}function a(o){for(var c=1;c<arguments.length;c++){var u=arguments[c]!=null?arguments[c]:{};c%2?r(Object(u),!0).forEach(function(f){n(o,f,u[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(u)):r(Object(u)).forEach(function(f){Object.defineProperty(o,f,Object.getOwnPropertyDescriptor(u,f))})}return o}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports}});function bf(e){const t={subscribe(n){let r=null,a=!1,o=!1,c=!1;function u(){if(r===null){c=!0;return}o||(o=!0,typeof r=="function"?r():r&&r.unsubscribe())}return r=e({next(f){var h;a||(h=n.next)===null||h===void 0||h.call(n,f)},error(f){var h;a||(a=!0,(h=n.error)===null||h===void 0||h.call(n,f),u())},complete(){var f;a||(a=!0,(f=n.complete)===null||f===void 0||f.call(n),u())}}),c&&u(),{unsubscribe:u}},pipe(...n){return n.reduce(Qne,t)}};return t}function Qne(e,t){return t(e)}function Jne(e){const t=new AbortController;return new Promise((r,a)=>{let o=!1;function c(){o||(o=!0,u.unsubscribe())}t.signal.addEventListener("abort",()=>{a(t.signal.reason)});const u=e.subscribe({next(f){o=!0,r(f),c()},error(f){a(f)},complete(){t.abort(),c()}})})}function ese(e){return t=>{let n=0,r=null;const a=[];function o(){r||(r=t.subscribe({next(u){for(const h of a){var f;(f=h.next)===null||f===void 0||f.call(h,u)}},error(u){for(const h of a){var f;(f=h.error)===null||f===void 0||f.call(h,u)}},complete(){for(const f of a){var u;(u=f.complete)===null||u===void 0||u.call(f)}}}))}function c(){if(n===0&&r){const u=r;r=null,u.unsubscribe()}}return bf(u=>(n++,a.push(u),o(),{unsubscribe(){n--,c();const f=a.findIndex(h=>h===u);f>-1&&a.splice(f,1)}}))}}function LP(e){let t=e;const n=[],r=c=>{t!==void 0&&c.next(t),n.push(c)},a=c=>{n.splice(n.indexOf(c),1)},o=bf(c=>(r(c),()=>{a(c)}));return o.next=c=>{if(t!==c){t=c;for(const u of n)u.next(c)}},o.get=()=>t,o}function tse(e){return bf(t=>{function n(a=0,o=e.op){const c=e.links[a];if(!c)throw new Error("No more links to execute - did you forget to add an ending link?");return c({op:o,next(f){return n(a+1,f)}})}return n().subscribe(t)})}function nf(e){return!!e&&!Array.isArray(e)&&typeof e=="object"}function nse(){return Object.create(null)}const nM=e=>e();function sM(e=0){return new Promise(t=>setTimeout(t,e))}var sse=Object.create,PP=Object.defineProperty,rse=Object.getOwnPropertyDescriptor,DP=Object.getOwnPropertyNames,ase=Object.getPrototypeOf,ise=Object.prototype.hasOwnProperty,wf=(e,t)=>function(){return t||(0,e[DP(e)[0]])((t={exports:{}}).exports,t),t.exports},ose=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=DP(t),o=0,c=a.length,u;o<c;o++)u=a[o],!ise.call(e,u)&&u!==n&&PP(e,u,{get:(f=>t[f]).bind(null,u),enumerable:!(r=rse(t,u))||r.enumerable});return e},Ug=(e,t,n)=>(n=e!=null?sse(ase(e)):{},ose(PP(n,"default",{value:e,enumerable:!0}),e));const zP=()=>{},rM=e=>{Object.freeze&&Object.freeze(e)};function BP(e,t,n){var r;const a=t.join(".");return(r=n[a])!==null&&r!==void 0||(n[a]=new Proxy(zP,{get(o,c){if(!(typeof c!="string"||c==="then"))return BP(e,[...t,c],n)},apply(o,c,u){const f=t[t.length-1];let h={args:u,path:t};return f==="call"?h={args:u.length>=2?[u[1]]:[],path:t.slice(0,-1)}:f==="apply"&&(h={args:u.length>=2?u[1]:[],path:t.slice(0,-1)}),rM(h.args),rM(h.path),e(h)}})),n[a]}const lse=e=>BP(e,[],nse()),cse=e=>new Proxy(zP,{get(t,n){if(n!=="then")return e(n)}});var UP=wf({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e,t){function n(r){"@babel/helpers - typeof";return t.exports=n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},t.exports.__esModule=!0,t.exports.default=t.exports,n(r)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),use=wf({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e,t){var n=UP().default;function r(a,o){if(n(a)!="object"||!a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var u=c.call(a,o||"default");if(n(u)!="object")return u;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(a)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),dse=wf({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e,t){var n=UP().default,r=use();function a(o){var c=r(o,"string");return n(c)=="symbol"?c:c+""}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports}}),FP=wf({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e,t){var n=dse();function r(a,o,c){return(o=n(o))in a?Object.defineProperty(a,o,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[o]=c,a}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),sk=wf({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e,t){var n=FP();function r(o,c){var u=Object.keys(o);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(o);c&&(f=f.filter(function(h){return Object.getOwnPropertyDescriptor(o,h).enumerable})),u.push.apply(u,f)}return u}function a(o){for(var c=1;c<arguments.length;c++){var u=arguments[c]!=null?arguments[c]:{};c%2?r(Object(u),!0).forEach(function(f){n(o,f,u[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(u)):r(Object(u)).forEach(function(f){Object.defineProperty(o,f,Object.getOwnPropertyDescriptor(u,f))})}return o}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports}});Ug(sk());Ug(FP());var am=Ug(sk());function fse(e,t){if("error"in e){const r=t.deserialize(e.error);return{ok:!1,error:(0,am.default)((0,am.default)({},e),{},{error:r})}}return{ok:!0,result:(0,am.default)((0,am.default)({},e.result),(!e.result.type||e.result.type==="data")&&{type:"data",data:t.deserialize(e.result.data)})}}var tb=class extends Error{constructor(){super("Unable to transform response from server")}};function hse(e,t){let n;try{n=fse(e,t)}catch{throw new tb}if(!n.ok&&(!nf(n.error.error)||typeof n.error.error.code!="number"))throw new tb;if(n.ok&&!nf(n.result))throw new tb;return n}Ug(sk());var im=Dn(ol()),ql=Dn(Ur());function mse(e){return e instanceof Po}function pse(e){return nf(e)&&nf(e.error)&&typeof e.error.code=="number"&&typeof e.error.message=="string"}function gse(e,t){return typeof e=="string"?e:nf(e)&&typeof e.message=="string"?e.message:t}var Po=class np extends Error{constructor(t,n){var r,a;const o=n?.cause;super(t,{cause:o}),(0,im.default)(this,"cause",void 0),(0,im.default)(this,"shape",void 0),(0,im.default)(this,"data",void 0),(0,im.default)(this,"meta",void 0),this.meta=n?.meta,this.cause=o,this.shape=n==null||(r=n.result)===null||r===void 0?void 0:r.error,this.data=n==null||(a=n.result)===null||a===void 0?void 0:a.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,np.prototype)}static from(t,n={}){const r=t;return mse(r)?(n.meta&&(r.meta=(0,ql.default)((0,ql.default)({},r.meta),n.meta)),r):pse(r)?new np(r.error.message,(0,ql.default)((0,ql.default)({},n),{},{result:r,cause:n.cause})):new np(gse(r,"Unknown error"),(0,ql.default)((0,ql.default)({},n),{},{cause:r}))}};function vse(e){const t=e;return t?"input"in t?t:{input:t,output:t}:{input:{serialize:n=>n,deserialize:n=>n},output:{serialize:n=>n,deserialize:n=>n}}}Dn(Ur());Dn(Ur());Dn(Ur());Dn(Ur());const xse={encode:e=>JSON.stringify(e),decode:e=>{if(typeof e!="string")throw new Error("jsonEncoder received binary data. JSON uses text frames. Use a binary encoder for binary data.");return JSON.parse(e)}},yse={enabled:!1,closeMs:0},bse={enabled:!1,pongTimeoutMs:1e3,intervalMs:5e3},wse=e=>e===0?0:Math.min(1e3*2**e,3e4),VP=(e,...t)=>typeof e=="function"?e(...t):e;var jse=Dn(ol()),Kl=class HP extends Error{constructor(t){super(t.message,{cause:t.cause}),this.name="TRPCWebSocketClosedError",Object.setPrototypeOf(this,HP.prototype)}},kse=class{constructor(e,t){this.onTimeout=e,this.timeoutMs=t,(0,jse.default)(this,"timeout",void 0)}reset(){this.timeout&&(clearTimeout(this.timeout),this.timeout=setTimeout(this.onTimeout,this.timeoutMs))}start(){clearTimeout(this.timeout),this.timeout=setTimeout(this.onTimeout,this.timeoutMs)}stop(){clearTimeout(this.timeout),this.timeout=void 0}};function WP(){let e,t;return{promise:new Promise((r,a)=>{e=r,t=a}),resolve:e,reject:t}}async function Nse(e){const t=await VP(e.url);if(!e.connectionParams)return t;const r=`${t.includes("?")?"&":"?"}connectionParams=1`;return t+r}async function Sse(e,t){const n={method:"connectionParams",data:await VP(e)};return t.encode(n)}var aM=Dn(ol()),Cse=class{constructor(){(0,aM.default)(this,"outgoingRequests",new Array),(0,aM.default)(this,"pendingRequests",{})}register(e,t){const{promise:n,resolve:r}=WP();return this.outgoingRequests.push({id:String(e.id),message:e,end:n,callbacks:{next:t.next,complete:()=>{t.complete(),r()},error:a=>{t.error(a),r()}}}),()=>{this.delete(e.id),t.complete(),r()}}delete(e){e!==null&&(this.outgoingRequests=this.outgoingRequests.filter(({id:t})=>t!==String(e)),delete this.pendingRequests[String(e)])}flush(){const e=this.outgoingRequests;this.outgoingRequests=[];for(const t of e)this.pendingRequests[t.id]=t;return e}getPendingRequests(){return Object.values(this.pendingRequests)}getPendingRequest(e){return e===null?null:this.pendingRequests[String(e)]}getOutgoingRequests(){return this.outgoingRequests}getRequests(){return[...this.getOutgoingRequests().map(e=>({state:"outgoing",message:e.message,end:e.end,callbacks:e.callbacks})),...this.getPendingRequests().map(e=>({state:"pending",message:e.message,end:e.end,callbacks:e.callbacks}))]}hasPendingRequests(){return this.getPendingRequests().length>0}hasPendingSubscriptions(){return this.getPendingRequests().some(e=>e.message.method==="subscription")}hasOutgoingRequests(){return this.outgoingRequests.length>0}},ki=Dn(ol());function Ese(e){const{promise:t,resolve:n,reject:r}=WP();return e.addEventListener("open",()=>{e.removeEventListener("error",r),n()}),e.addEventListener("error",r),t}function Ase(e,{intervalMs:t,pongTimeoutMs:n}){let r,a;function o(){r=setTimeout(()=>{e.send("PING"),a=setTimeout(()=>{e.close()},n)},t)}function c(){clearTimeout(r),o()}function u(){clearTimeout(a),c()}e.addEventListener("open",o),e.addEventListener("message",({data:f})=>{clearTimeout(r),o(),f==="PONG"&&u()}),e.addEventListener("close",()=>{clearTimeout(r),clearTimeout(a)})}var qP=class G0{constructor(t){var n;if((0,ki.default)(this,"id",++G0.connectCount),(0,ki.default)(this,"WebSocketPonyfill",void 0),(0,ki.default)(this,"urlOptions",void 0),(0,ki.default)(this,"keepAliveOpts",void 0),(0,ki.default)(this,"encoder",void 0),(0,ki.default)(this,"wsObservable",LP(null)),(0,ki.default)(this,"openPromise",null),this.WebSocketPonyfill=(n=t.WebSocketPonyfill)!==null&&n!==void 0?n:WebSocket,!this.WebSocketPonyfill)throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");this.urlOptions=t.urlOptions,this.keepAliveOpts=t.keepAlive,this.encoder=t.encoder}get ws(){return this.wsObservable.get()}set ws(t){this.wsObservable.next(t)}isOpen(){return!!this.ws&&this.ws.readyState===this.WebSocketPonyfill.OPEN&&!this.openPromise}isClosed(){return!!this.ws&&(this.ws.readyState===this.WebSocketPonyfill.CLOSING||this.ws.readyState===this.WebSocketPonyfill.CLOSED)}async open(){var t=this;if(t.openPromise)return t.openPromise;t.id=++G0.connectCount;const n=Nse(t.urlOptions).then(r=>new t.WebSocketPonyfill(r));t.openPromise=n.then(async r=>{t.ws=r,r.binaryType="arraybuffer",r.addEventListener("message",function({data:a}){a==="PING"&&this.send("PONG")}),t.keepAliveOpts.enabled&&Ase(r,t.keepAliveOpts),r.addEventListener("close",()=>{t.ws===r&&(t.ws=null)}),await Ese(r),t.urlOptions.connectionParams&&r.send(await Sse(t.urlOptions.connectionParams,t.encoder))});try{await t.openPromise}finally{t.openPromise=null}}async close(){var t=this;try{await t.openPromise}finally{var n;(n=t.ws)===null||n===void 0||n.close()}}};(0,ki.default)(qP,"connectCount",0);function Tse(e){return e.isOpen()?{id:e.id,state:"open",ws:e.ws}:e.isClosed()?{id:e.id,state:"closed",ws:e.ws}:e.ws?{id:e.id,state:"connecting",ws:e.ws}:null}var Zr=Dn(ol()),Gl=Dn(Ur()),Mse=class{constructor(e){var t,n;(0,Zr.default)(this,"connectionState",void 0),(0,Zr.default)(this,"allowReconnect",!1),(0,Zr.default)(this,"requestManager",new Cse),(0,Zr.default)(this,"activeConnection",void 0),(0,Zr.default)(this,"reconnectRetryDelay",void 0),(0,Zr.default)(this,"inactivityTimeout",void 0),(0,Zr.default)(this,"callbacks",void 0),(0,Zr.default)(this,"lazyMode",void 0),(0,Zr.default)(this,"encoder",void 0),(0,Zr.default)(this,"reconnecting",null),this.encoder=(t=e.experimental_encoder)!==null&&t!==void 0?t:xse,this.callbacks={onOpen:e.onOpen,onClose:e.onClose,onError:e.onError};const r=(0,Gl.default)((0,Gl.default)({},yse),e.lazy);this.inactivityTimeout=new kse(()=>{if(this.requestManager.hasOutgoingRequests()||this.requestManager.hasPendingRequests()){this.inactivityTimeout.reset();return}this.close().catch(()=>null)},r.closeMs),this.activeConnection=new qP({WebSocketPonyfill:e.WebSocket,urlOptions:e,keepAlive:(0,Gl.default)((0,Gl.default)({},bse),e.keepAlive),encoder:this.encoder}),this.activeConnection.wsObservable.subscribe({next:a=>{a&&this.setupWebSocketListeners(a)}}),this.reconnectRetryDelay=(n=e.retryDelayMs)!==null&&n!==void 0?n:wse,this.lazyMode=r.enabled,this.connectionState=LP({type:"state",state:r.enabled?"idle":"connecting",error:null}),this.lazyMode||this.open().catch(()=>null)}async open(){var e=this;e.allowReconnect=!0,e.connectionState.get().state==="idle"&&e.connectionState.next({type:"state",state:"connecting",error:null});try{await e.activeConnection.open()}catch(t){return e.reconnect(new Kl({message:"Initialization error",cause:t})),e.reconnecting}}async close(){var e=this;e.allowReconnect=!1,e.inactivityTimeout.stop();const t=[];for(const n of e.requestManager.getRequests())n.message.method==="subscription"?n.callbacks.complete():n.state==="outgoing"?n.callbacks.error(Po.from(new Kl({message:"Closed before connection was established"}))):t.push(n.end);await Promise.all(t).catch(()=>null),await e.activeConnection.close().catch(()=>null),e.connectionState.next({type:"state",state:"idle",error:null})}request({op:{id:e,type:t,path:n,input:r,signal:a},transformer:o,lastEventId:c}){return bf(u=>{const f=this.batchSend({id:e,method:t,params:{input:o.input.serialize(r),path:n,lastEventId:c}},(0,Gl.default)((0,Gl.default)({},u),{},{next(h){const p=hse(h,o.output);if(!p.ok){u.error(Po.from(p.error));return}u.next({result:p.result})}}));return()=>{f(),t==="subscription"&&this.activeConnection.isOpen()&&this.send({id:e,method:"subscription.stop"}),a?.removeEventListener("abort",f)}})}get connection(){return Tse(this.activeConnection)}reconnect(e){var t=this;if(this.connectionState.next({type:"state",state:"connecting",error:Po.from(e)}),this.reconnecting)return;const n=async r=>{try{await sM(t.reconnectRetryDelay(r)),t.allowReconnect&&(await t.activeConnection.close(),await t.activeConnection.open(),t.requestManager.hasPendingRequests()&&t.send(t.requestManager.getPendingRequests().map(({message:a})=>a))),t.reconnecting=null}catch{await n(r+1)}};this.reconnecting=n(0)}setupWebSocketListeners(e){var t=this;const n=r=>{const a=this.requestManager.getPendingRequests();for(const{message:o,callbacks:c}of a)o.method!=="subscription"&&(c.error(Po.from(r??new Kl({message:"WebSocket closed",cause:r}))),this.requestManager.delete(o.id))};e.addEventListener("open",()=>{nM(async()=>{var r,a;t.lazyMode&&t.inactivityTimeout.start(),(r=(a=t.callbacks).onOpen)===null||r===void 0||r.call(a),t.connectionState.next({type:"state",state:"pending",error:null})}).catch(r=>{e.close(3e3),n(r)})}),e.addEventListener("message",({data:r})=>{if(this.inactivityTimeout.reset(),["PING","PONG"].includes(r))return;const a=this.encoder.decode(r);if("method"in a){this.handleIncomingRequest(a);return}this.handleResponseMessage(a)}),e.addEventListener("close",r=>{var a,o;n(r),(a=(o=this.callbacks).onClose)===null||a===void 0||a.call(o,r),(!this.lazyMode||this.requestManager.hasPendingSubscriptions())&&this.reconnect(new Kl({message:"WebSocket closed",cause:r}))}),e.addEventListener("error",r=>{var a,o;n(r),(a=(o=this.callbacks).onError)===null||a===void 0||a.call(o,r),this.reconnect(new Kl({message:"WebSocket closed",cause:r}))})}handleResponseMessage(e){const t=this.requestManager.getPendingRequest(e.id);if(!t)return;t.callbacks.next(e);let n=!0;"result"in e&&t.message.method==="subscription"&&(e.result.type==="data"&&(t.message.params.lastEventId=e.result.id),e.result.type!=="stopped"&&(n=!1)),n&&(t.callbacks.complete(),this.requestManager.delete(e.id))}handleIncomingRequest(e){e.method==="reconnect"&&this.reconnect(new Kl({message:"Server requested reconnect"}))}send(e){if(!this.activeConnection.isOpen())throw new Error("Active connection is not open");const t=e instanceof Array?e:[e];this.activeConnection.ws.send(this.encoder.encode(t.length===1?t[0]:t))}batchSend(e,t){var n=this;return this.inactivityTimeout.reset(),nM(async()=>{n.activeConnection.isOpen()||await n.open(),await sM(0),n.requestManager.hasOutgoingRequests()&&n.send(n.requestManager.flush().map(({message:r})=>r))}).catch(r=>{this.requestManager.delete(e.id),t.error(Po.from(r))}),this.requestManager.register(e,t)}};function KP(e){return new Mse(e)}function GP(e){const{client:t}=e,n=vse(e.transformer);return()=>({op:r})=>bf(a=>{const o=r.type==="subscription"?t.connectionState.subscribe({next(u){a.next({result:u,context:r.context})}}):null,c=t.request({op:r,transformer:n}).subscribe(a);return()=>{c.unsubscribe(),o?.unsubscribe()}})}var nb=Dn(ol()),iM=Dn(Ur()),Rse=class{constructor(e){(0,nb.default)(this,"links",void 0),(0,nb.default)(this,"runtime",void 0),(0,nb.default)(this,"requestId",void 0),this.requestId=0,this.runtime={},this.links=e.links.map(t=>t(this.runtime))}$request(e){var t;return tse({links:this.links,op:(0,iM.default)((0,iM.default)({},e),{},{context:(t=e.context)!==null&&t!==void 0?t:{},id:++this.requestId})}).pipe(ese())}async requestAsPromise(e){var t=this;try{const n=t.$request(e);return(await Jne(n)).result.data}catch(n){throw Po.from(n)}}query(e,t,n){return this.requestAsPromise({type:"query",path:e,input:t,context:n?.context,signal:n?.signal})}mutation(e,t,n){return this.requestAsPromise({type:"mutation",path:e,input:t,context:n?.context,signal:n?.signal})}subscription(e,t,n){return this.$request({type:"subscription",path:e,input:t,context:n.context,signal:n.signal}).subscribe({next(a){switch(a.result.type){case"state":{var o;(o=n.onConnectionStateChange)===null||o===void 0||o.call(n,a.result);break}case"started":{var c;(c=n.onStarted)===null||c===void 0||c.call(n,{context:a.context});break}case"stopped":{var u;(u=n.onStopped)===null||u===void 0||u.call(n);break}case"data":case void 0:{var f;(f=n.onData)===null||f===void 0||f.call(n,a.result.data);break}}},error(a){var o;(o=n.onError)===null||o===void 0||o.call(n,a)},complete(){var a;(a=n.onComplete)===null||a===void 0||a.call(n)}})}};const Ise=Symbol.for("trpc_untypedClient"),_se={query:"query",mutate:"mutation",subscribe:"subscription"},Ose=e=>_se[e];function $se(e){const t=lse(({path:n,args:r})=>{const a=[...n],o=Ose(a.pop()),c=a.join(".");return e[o](c,...r)});return cse(n=>n===Ise?e:t[n])}function ZP(e){const t=new Rse(e);return $se(t)}Dn(Ur());Dn(Ur());var Lse=pa({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(e,t){function n(a){var o,c,u,f=2;for(typeof Symbol<"u"&&(c=Symbol.asyncIterator,u=Symbol.iterator);f--;){if(c&&(o=a[c])!=null)return o.call(a);if(u&&(o=a[u])!=null)return new r(o.call(a));c="@@asyncIterator",u="@@iterator"}throw new TypeError("Object is not async iterable")}function r(a){function o(c){if(Object(c)!==c)return Promise.reject(new TypeError(c+" is not an object."));var u=c.done;return Promise.resolve(c.value).then(function(f){return{value:f,done:u}})}return r=function(u){this.s=u,this.n=u.next},r.prototype={s:null,n:null,next:function(){return o(this.n.apply(this.s,arguments))},return:function(u){var f=this.s.return;return f===void 0?Promise.resolve({value:u,done:!0}):o(f.apply(this.s,arguments))},throw:function(u){var f=this.s.return;return f===void 0?Promise.reject(u):o(f.apply(this.s,arguments))}},new r(a)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}});Dn(Lse());Dn(Ur());var Pse=pa({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(e,t){function n(){var r=typeof SuppressedError=="function"?SuppressedError:function(u,f){var h=Error();return h.name="SuppressedError",h.error=u,h.suppressed=f,h},a={},o=[];function c(u,f){if(f!=null){if(Object(f)!==f)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(u)var h=f[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(h===void 0&&(h=f[Symbol.dispose||Symbol.for("Symbol.dispose")],u))var p=h;if(typeof h!="function")throw new TypeError("Object is not disposable.");p&&(h=function(){try{p.call(f)}catch(v){return Promise.reject(v)}}),o.push({v:f,d:h,a:u})}else u&&o.push({d:f,a:u});return f}return{e:a,u:c.bind(null,!1),a:c.bind(null,!0),d:function(){var f,h=this.e,p=0;function x(){for(;f=o.pop();)try{if(!f.a&&p===1)return p=0,o.push(f),Promise.resolve().then(x);if(f.d){var y=f.d.call(f.v);if(f.a)return p|=2,Promise.resolve(y).then(x,v)}else p|=1}catch(b){return v(b)}if(p===1)return h!==a?Promise.reject(h):Promise.resolve();if(h!==a)throw h}function v(y){return h=h!==a?new r(y,h):y,x()}return x()}}}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),YP=pa({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(e,t){function n(r,a){this.v=r,this.k=a}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),Dse=pa({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(e,t){var n=YP();function r(a){return new n(a,0)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),zse=pa({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(e,t){var n=YP();function r(o){return function(){return new a(o.apply(this,arguments))}}function a(o){var c,u;function f(p,x){try{var v=o[p](x),y=v.value,b=y instanceof n;Promise.resolve(b?y.v:y).then(function(C){if(b){var E=p==="return"?"return":"next";if(!y.k||C.done)return f(E,C);C=o[E](C).value}h(v.done?"return":"normal",C)},function(C){f("throw",C)})}catch(C){h("throw",C)}}function h(p,x){switch(p){case"return":c.resolve({value:x,done:!0});break;case"throw":c.reject(x);break;default:c.resolve({value:x,done:!1})}(c=c.next)?f(c.key,c.arg):u=null}this._invoke=function(p,x){return new Promise(function(v,y){var b={key:p,arg:x,resolve:v,reject:y,next:null};u?u=u.next=b:(c=u=b,f(p,x))})},typeof o.return!="function"&&(this.return=void 0)}a.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},a.prototype.next=function(o){return this._invoke("next",o)},a.prototype.throw=function(o){return this._invoke("throw",o)},a.prototype.return=function(o){return this._invoke("return",o)},t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}});Dn(Pse());Dn(Dse());Dn(zse());Dn(Ur());const jc=new Set;let sb=null,oM=null,Rd=null,kc=null;function Bse(){return`ws://${typeof window<"u"?window.location.hostname:"127.0.0.1"}:65535/trpc`}function Use(e){for(const t of[...jc])t(e)}function Fse(){kc||jc.size===0||(kc=setTimeout(()=>{kc=null,XP()},2e3))}function XP(){Rd||jc.size===0||(sb||(sb=KP({url:Bse()}),oM=ZP({links:[GP({client:sb})]})),Rd=oM.control.events.subscribe(void 0,{onData:e=>{const t=e.data;t&&Use(t)},onError:()=>{Rd=null,Fse()}}))}function Vse(){kc&&(clearTimeout(kc),kc=null),Rd?.unsubscribe(),Rd=null}function Hse(e){return jc.add(e),XP(),()=>{jc.delete(e),!(jc.size>0)&&Vse()}}function Vt(e){const t=m.useRef(e);t.current=e,m.useEffect(()=>Hse(n=>{t.current(n)}),[])}function Ge(e){const t=e?.trim().toLowerCase();return t==="working"||t==="active"?"working":!t||t==="offline"||t==="not_ready"||t==="unready"||t==="unavailable"||t==="error"||t==="missing"?"not_ready":"ready"}function ll(e){switch(Ge(e)){case"working":return"working";case"ready":return"available";case"not_ready":return"offline"}}function ha(e){return Ge(e)!=="not_ready"}function cs(e){switch(Ge(e)){case"working":return"Working";case"ready":return"Ready";case"not_ready":return"Not ready"}}const rk="scoutbot",Wse=new Set([rk,"scoutbot","@scoutbot"]),qse=new Set(["plan","conductor","conduct","warroom","command","mission","control","issues","errors","warnings","agents","tail","atop"]),Kse=new Set(["available","working","active","idle","waiting","registered"]);function QP(e){return[e.id,e.name,e.handle??"",e.selector??"",e.role??""].map(n=>n.trim().toLowerCase()).some(n=>Wse.has(n)||n==="scoutbot"||n.startsWith("scoutbot.")||n.includes(".scoutbot.")||n.includes(" scoutbot"))}function Gse(e){return Kse.has(e.state?.trim().toLowerCase()??"")}function lM(e){if(!QP(e))return Number.NEGATIVE_INFINITY;let t=0;return Gse(e)&&(t+=100),e.handle?.trim().toLowerCase()==="scoutbot"&&(t+=20),e.selector?.trim().toLowerCase()==="@scoutbot"&&(t+=20),e.role?.trim().toLowerCase()==="scoutbot"&&(t+=10),e.id===rk&&(t+=1),t}function Zse(e){return e.filter(QP).sort((t,n)=>{const r=lM(n)-lM(t);return r!==0?r:(n.updatedAt??0)-(t.updatedAt??0)})[0]??null}function Yse(e){return Zse(e)?.id??rk}function Xse(e){return`dm.operator.${e}`}const Qse=new Set(["scout-ui","scout-ui-action","scoutbot-ui"]),cM=/```([a-zA-Z0-9_-]*)\s*([\s\S]*?)```/g;function JP(e){const t=[];let n="",r=0;cM.lastIndex=0;let a;for(;(a=cM.exec(e))!==null;){const[o,c,u]=a,f=(c??"").toLowerCase(),h=u??"";let p=[],x=!1;Qse.has(f)?(x=!0,p=uM(h)):(f==="json"||f==="")&&(p=uM(h),p.length>0&&(x=!0)),x&&(t.push(...p),n+=e.slice(r,a.index),r=a.index+o.length)}return n+=e.slice(r),{stripped:n.replace(/\n{3,}/g,`
140
-
141
- `).trim(),actions:t}}function Jse(e){return JP(e).actions}function gd(e){return JP(e).stripped}function uM(e){const t=e.trim();if(!t)return[];try{const n=JSON.parse(t);return(Array.isArray(n)?n:[n]).map(a=>ak(a)).filter(a=>!!a)}catch{return[]}}function ak(e){if(!e||typeof e!="object")return null;const t=e,n=t.scoutUi??t.scout_ui??t.scoutbotUi??t.scoutbot_ui;if(n)return ak(n);const r=typeof t.type=="string"?t.type:typeof t.action=="string"?t.action:"",a=typeof t.reason=="string"?t.reason:void 0;if(r==="open-scoutbot"||r==="open_scoutbot"){const c=t.mode==="tell"?"tell":t.mode==="ask"?"ask":void 0;return{type:"open-scoutbot",...c?{mode:c}:{},...a?{reason:a}:{}}}if(r==="refresh")return{type:"refresh",...a?{reason:a}:{}};if(r==="ask-agent"||r==="ask_agent"||r==="scout-ask"||r==="scout_ask"){const c=So(t.targetLabel,t.target_label,t.target,t.to,t.agent,t.handle),u=So(t.targetAgentId,t.target_agent_id,t.agentId,t.agent_id),f=So(t.body,t.message,t.prompt,t.task,t.question),h=So(t.channel);return!f?.trim()||!c?.trim()&&!u?.trim()?null:{type:"ask-agent",targetLabel:(c??u??"").trim(),body:f.trim(),...u?.trim()?{targetAgentId:u.trim()}:{},...h?.trim()?{channel:h.trim()}:{},...a?{reason:a}:{}}}if(r==="view-file"||r==="view_file"||r==="open-file"||r==="open_file"){const c=So(t.path,t.file,t.target);return c?.trim()?{type:"view-file",path:c.trim(),...a?{reason:a}:{}}:null}if(r==="reminder"||r==="set-reminder"||r==="set_reminder"||r==="remind"){const c=So(t.body,t.text,t.prompt,t.message);if(!c?.trim())return null;const u=So(t.title,t.label),f=ere(t.dueAt??t.due_at),h=Z0(t.delayMs??t.delay_ms),p=Z0(t.delayMinutes??t.delay_minutes);return{type:"reminder",body:c.trim(),...u?.trim()?{title:u.trim()}:{},...f!==null?{dueAt:f}:{},...h!==null?{delayMs:h}:{},...p!==null?{delayMinutes:p}:{},...a?{reason:a}:{}}}if(r!=="navigate"&&r!=="open")return null;const o=tre(t.route??t);return o?{type:"navigate",route:o,...a?{reason:a}:{}}:null}function So(...e){for(const t of e)if(typeof t=="string"&&t.trim())return t;return null}function Z0(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e!="string")return null;const t=Number(e.trim());return Number.isFinite(t)?t:null}function ere(e){const t=Z0(e);if(t!==null)return t;if(typeof e!="string")return null;const n=Date.parse(e);return Number.isFinite(n)?n:null}function tre(e){if(!e||typeof e!="object")return null;const t=e;switch(typeof t.view=="string"?t.view:""){case"inbox":return{view:"inbox"};case"fleet":return{view:"fleet"};case"agents":return{view:"agents",...typeof t.agentId=="string"?{agentId:t.agentId}:{},...typeof t.conversationId=="string"?{conversationId:t.conversationId}:{},...t.tab==="profile"||t.tab==="observe"||t.tab==="message"?{tab:t.tab}:{}};case"sessions":return{view:"sessions",...typeof t.sessionId=="string"?{sessionId:t.sessionId}:{}};case"mesh":return{view:"mesh"};case"broker":return{view:"broker"};case"activity":return{view:"activity"};case"settings":return{view:"settings"};case"terminal":return{view:"terminal",...typeof t.agentId=="string"?{agentId:t.agentId}:{}};case"work":return typeof t.workId=="string"?{view:"work",workId:t.workId}:null;case"conversation":return typeof t.conversationId=="string"?{view:"conversation",conversationId:t.conversationId,...t.composeMode==="ask"||t.composeMode==="tell"?{composeMode:t.composeMode}:{}}:null;case"ops":{const r=typeof t.mode=="string"&&qse.has(t.mode)?nre(t.mode):void 0;return{view:"ops",...r?{mode:r}:{}}}default:return null}}function nre(e){switch(e){case"control":case"mission":case"command":case"warroom":case"conduct":case"conductor":return"mission";case"plan":return"plan";case"issues":case"errors":case"warnings":return"issues";case"agents":case"tail":case"atop":return e;default:return}}const eD={current:null,setMenu:null};function Xc(){return m.useCallback((e,t)=>{e.preventDefault(),e.stopPropagation(),eD.setMenu?.({position:{x:e.clientX,y:e.clientY},items:t})},[])}function sre({children:e}){const[t,n]=m.useState(null),r=m.useRef(null);eD.setMenu=n;const a=m.useCallback(()=>{n(null)},[]);return m.useEffect(()=>{if(!t)return;const o=h=>{h.target instanceof Node&&r.current?.contains(h.target)||a()},c=h=>{h.key==="Escape"&&a()},u=()=>a(),f=h=>{h.defaultPrevented||a()};return window.addEventListener("mousedown",o,!0),window.addEventListener("keydown",c),window.addEventListener("wheel",u,!0),window.addEventListener("contextmenu",f),()=>{window.removeEventListener("mousedown",o,!0),window.removeEventListener("keydown",c),window.removeEventListener("wheel",u,!0),window.removeEventListener("contextmenu",f)}},[t,a]),m.useLayoutEffect(()=>{if(!t||!r.current)return;const o=r.current,c=o.getBoundingClientRect(),u=window.innerWidth,f=window.innerHeight;let h=t.position.x,p=t.position.y;h+c.width>u-8&&(h=u-c.width-8),p+c.height>f-8&&(p=f-c.height-8),h<8&&(h=8),p<8&&(p=8),o.style.left=`${h}px`,o.style.top=`${p}px`,o.style.visibility="visible"},[t]),s.jsxs(s.Fragment,{children:[e,t&&s.jsx("div",{ref:r,className:"s-context-menu",style:{left:t.position.x,top:t.position.y,visibility:"hidden"},role:"menu",onMouseDown:o=>o.stopPropagation(),children:t.items.map((o,c)=>o.kind==="separator"?s.jsx("div",{className:"s-context-menu-sep",role:"separator"},c):s.jsxs("button",{type:"button",className:"s-context-menu-item",role:"menuitem",onClick:()=>{o.onSelect(),a()},children:[s.jsx("span",{className:"s-context-menu-label",children:o.label}),o.shortcut&&s.jsx("span",{className:"s-context-menu-shortcut",children:o.shortcut})]},c))})]})}const rre={cjs:"javascript",css:"css",htm:"html",html:"html",js:"javascript",jsx:"javascript",json:"json",mjs:"javascript",md:"markdown",mdx:"markdown",sh:"shell",ts:"typescript",tsx:"typescript",txt:"plain"},are=new Set(["cjs","css","htm","html","js","jsx","json","mjs","sh","ts","tsx"]);function tD(e){const n=(e.filename??e.title??e.uri??"").split(/[?#]/)[0],r=n.split("/").pop()??n,a=r.lastIndexOf(".");return a>=0?r.slice(a+1).toLowerCase():""}function ire(e){const t=e.mediaType?.toLowerCase()??"";return t.includes("json")?"json":t.includes("markdown")?"markdown":t.includes("javascript")?"javascript":t.includes("typescript")?"typescript":t.includes("html")?"html":t.includes("css")?"css":t.includes("shell")||t.includes("x-sh")?"shell":rre[tD(e)]??"plain"}function ore(e){const t=e.mediaType?.toLowerCase()??"",n=tD(e);if(t.includes("markdown")||n==="md"||n==="mdx")return"markdown";if(t.includes("json")||t.includes("javascript")||t.includes("typescript")||t.includes("html")||t.includes("xml")||t.includes("css")||are.has(n))return"code";if(t.startsWith("text/")||n==="txt")return"text";const r=e.value.trim();return/^#{1,6}\s+/m.test(r)||/```[\s\S]*```/.test(r)?"markdown":"text"}function Qc(e){const t=e.title??e.filename??e.uri?.split("/").pop()??"Untitled",n=e.language??ire(e);return{id:e.id??e.uri??t,title:t,uri:e.uri,mediaType:e.mediaType,language:n,kind:e.kind??ore(e),value:e.value,readOnly:e.readOnly}}function jf({document:e,mode:t,className:n}){const r=t??(e.kind==="markdown"?"preview":"read"),a=e.kind==="markdown"&&r==="preview"?s.jsx(cre,{markdown:e.value}):s.jsx(lre,{document:e});return s.jsx("div",{className:`s-text-document-surface s-text-document-surface-${e.kind}${n?` ${n}`:""}`,children:a})}function lre({document:e}){const t=m.useMemo(()=>nD(e.value,e.language??e.kind),[e.language,e.kind,e.value]);return s.jsx("pre",{className:"s-text-document-code","data-language":e.language??e.kind,children:s.jsx("code",{children:t})})}function cre({markdown:e}){const t=ure(e);return s.jsx("div",{className:"s-text-document-markdown",children:t.length>0?t:s.jsx("p",{})})}function ure(e){const t=e.replace(/\r\n/g,`
142
- `).split(`
143
- `),n=[];let r=0;for(;r<t.length;){const a=t[r]??"";if(!a.trim()){r+=1;continue}const o=/^```(\S*)\s*$/.exec(a);if(o){const h=[];for(r+=1;r<t.length&&!/^```\s*$/.test(t[r]??"");)h.push(t[r]??""),r+=1;r<t.length&&(r+=1),n.push({kind:"code",content:h.join(`
144
- `),language:o[1]||void 0});continue}const c=/^(#{1,6})\s+(.+)$/.exec(a);if(c){n.push({kind:"heading",depth:dre(c[1].length),content:c[2].trim()}),r+=1;continue}if(/^ {0,3}([-*_])(?:\s*\1){2,}\s*$/.test(a)){n.push({kind:"hr"}),r+=1;continue}if(/^>\s?/.test(a)){const h=[];for(;r<t.length&&/^>\s?/.test(t[r]??"");)h.push((t[r]??"").replace(/^>\s?/,"")),r+=1;n.push({kind:"blockquote",content:h.join(" ")});continue}const u=/^(\s*)([-*+]|\d+[.)])\s+(.+)$/.exec(a);if(u){const h=/\d/.test(u[2]),p=[];for(;r<t.length;){const x=/^(\s*)([-*+]|\d+[.)])\s+(.+)$/.exec(t[r]??"");if(!x||/\d/.test(x[2])!==h)break;p.push(x[3]),r+=1}n.push({kind:"list",ordered:h,items:p});continue}const f=[];for(;r<t.length;){const h=t[r]??"";if(!h.trim()||/^```/.test(h)||/^(#{1,6})\s+/.test(h)||/^ {0,3}([-*_])(?:\s*\1){2,}\s*$/.test(h)||/^>\s?/.test(h)||/^(\s*)([-*+]|\d+[.)])\s+/.test(h))break;f.push(h.trim()),r+=1}n.push({kind:"paragraph",content:f.join(" ")})}return n.map((a,o)=>fre(a,o))}function dre(e){return e<=1?1:e===2?2:e===3?3:e===4?4:e===5?5:6}function fre(e,t){switch(e.kind){case"heading":{const r=`h${e.depth}`;return s.jsx(r,{children:om(e.content)},t)}case"paragraph":return s.jsx("p",{children:om(e.content)},t);case"blockquote":return s.jsx("blockquote",{children:om(e.content)},t);case"list":{const r=e.ordered?"ol":"ul";return s.jsx(r,{children:e.items.map((a,o)=>s.jsx("li",{children:om(a)},`${t}:${o}`))},t)}case"code":const n=sD(e.language);return s.jsx("pre",{className:"s-text-document-fenced-code","data-language":n,children:s.jsx("code",{children:nD(e.content,n)})},t);case"hr":return s.jsx("hr",{},t)}}const hre=/\/\/[^\n]*|\/\*[\s\S]*?\*\/|`(?:\\[\s\S]|[^`\\])*`|'(?:\\.|[^'\\\n])*'|"(?:\\.|[^"\\\n])*"|\b\d+(?:\.\d+)?(?:e[+-]?\d+)?n?\b|\b[A-Za-z_$][\w$]*\b|=>|[{}()[\].,;:?]|[-+*/%=&|!<>~^]+/giu,mre=/"(?:\\.|[^"\\])*"|-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b|\b(?:true|false|null)\b|[{}\[\]:,]/giu,pre=/\/\*[\s\S]*?\*\/|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|#[0-9a-f]{3,8}\b|@[a-z-]+|--[a-z0-9-]+|[a-z-]+(?=\s*:)|\b\d+(?:\.\d+)?(?:%|px|r?em|vh|vw|vmin|vmax|s|ms|deg|fr)?\b|[{}():;,]|\.[a-z_][\w-]*|#[a-z_][\w-]*|[a-z_][\w-]*/giu,gre=/<!--[\s\S]*?-->|<!doctype[^>]*>|<\/?[a-z][\w:-]*|\/?>|[a-z_:][\w:.-]*(?==)|=|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|&[a-z0-9#]+;/giu,vre=/#[^\n]*|"(?:\\.|[^"\\])*"|'[^']*'|\$\{?[\w?@#$!-]+\}?|--?[A-Za-z0-9][\w-]*(?:=[^\s]+)?|\b(?:case|cd|do|done|echo|elif|else|esac|exit|export|fi|for|function|if|in|local|return|set|source|test|then|unset|while)\b|\b\d+\b|[|&;(){}<>]/giu,xre=new Set(["abstract","as","async","await","break","case","catch","class","const","continue","declare","default","delete","do","else","enum","export","extends","finally","for","from","function","get","if","implements","import","in","infer","interface","is","keyof","let","new","of","private","protected","public","readonly","return","satisfies","set","static","switch","throw","try","type","typeof","var","void","while","with","yield"]),yre=new Set(["false","null","super","this","true","undefined"]);function nD(e,t){switch(sD(t)){case"css":return Zu(e,pre,jre);case"html":return Zu(e,gre,kre);case"javascript":case"typescript":return Zu(e,hre,bre);case"json":return Zu(e,mre,wre);case"shell":return Zu(e,vre,Nre);default:return[e]}}function Zu(e,t,n){const r=[];let a=0,o=0;t.lastIndex=0;let c;for(;(c=t.exec(e))!==null;){const u=c[0];if(!u){t.lastIndex+=1;continue}c.index>a&&r.push(e.slice(a,c.index));const f=n(u,c.index,c.index+u.length,e);r.push(f?s.jsx("span",{className:`s-syntax s-syntax-${f}`,children:u},`syntax-${o++}`):u),a=c.index+u.length}return a<e.length&&r.push(e.slice(a)),r.length>0?r:[e]}function sD(e){const t=String(e??"").toLowerCase().replace(/^\./,"");return t==="bash"||t==="sh"||t==="shell"||t==="zsh"?"shell":t==="css"||t==="scss"?"css":t==="html"||t==="htm"||t==="xml"||t==="svg"?"html":t==="js"||t==="jsx"||t==="javascript"||t==="mjs"||t==="cjs"?"javascript":t==="json"||t==="jsonc"?"json":t==="markdown"||t==="md"||t==="mdx"?"markdown":t==="ts"||t==="tsx"||t==="typescript"?"typescript":"plain"}function bre(e,t,n,r){return e.startsWith("//")||e.startsWith("/*")?"comment":kf(e)?"string":/^\d/u.test(e)?"number":xre.has(e)?"keyword":yre.has(e)?"literal":/^[A-Z][\w$]*$/u.test(e)?"type":/^[A-Za-z_$][\w$]*$/u.test(e)&&r.slice(n).trimStart().startsWith("(")?"function":/^[{}()[\].,;:?]$/u.test(e)?"punctuation":/^(?:=>|[-+*/%=&|!<>~^]+)$/u.test(e)?"operator":null}function wre(e,t,n,r){return kf(e)?r.slice(n).trimStart().startsWith(":")?"property":"string":/^-?\d/u.test(e)?"number":e==="true"||e==="false"||e==="null"?"literal":"punctuation"}function jre(e,t,n,r){return e.startsWith("/*")?"comment":kf(e)?"string":e.startsWith("@")?"keyword":e.startsWith("#")&&/^#[0-9a-f]/iu.test(e)||/^\d/u.test(e)?"number":e.startsWith(".")||e.startsWith("#")?"tag":/^--/u.test(e)||r.slice(n).trimStart().startsWith(":")?"property":/^[{}():;,]$/u.test(e)?"punctuation":null}function kre(e){return e.startsWith("<!--")?"comment":/^<!doctype/iu.test(e)||e.startsWith("&")?"meta":e.startsWith("<")?"tag":kf(e)?"string":e==="="?"operator":e===">"||e==="/>"?"punctuation":"attribute"}function Nre(e){return e.startsWith("#")?"comment":kf(e)?"string":e.startsWith("$")?"property":e.startsWith("-")?"attribute":/^\d/u.test(e)?"number":/^[|&;(){}<>]$/u.test(e)?"operator":Sre.has(e)?"keyword":null}const Sre=new Set(["case","cd","do","done","echo","elif","else","esac","exit","export","fi","for","function","if","in","local","return","set","source","test","then","unset","while"]);function kf(e){return e.startsWith('"')||e.startsWith("'")||e.startsWith("`")}function om(e){const t=[],n=/(`[^`]+`|\[([^\]]+)\]\(([^)\s]+)\))/g;let r=0,a;for(;(a=n.exec(e))!==null;){a.index>r&&t.push(e.slice(r,a.index));const o=a[0];if(o.startsWith("`"))t.push(s.jsx("code",{children:o.slice(1,-1)},t.length));else{const c=Cre(a[3]);t.push(c?s.jsx("a",{href:c,target:"_blank",rel:"noreferrer",children:a[2]},t.length):a[2])}r=n.lastIndex}return r<e.length&&t.push(e.slice(r)),t}function Cre(e){if(!e)return null;try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"||t.protocol==="mailto:"?e:null}catch{return null}}function Fg({open:e=!0,focusable:t=!0,kind:n,document:r,title:a,eyebrow:o,subtitle:c,meta:u=[],mode:f,actions:h=[],state:p,error:x,notice:v,body:y,onClose:b}){const[C,E]=m.useState(!1),[A,S]=m.useState({}),k=m.useRef(null);if(m.useEffect(()=>{e||E(!1)},[e]),m.useEffect(()=>{if(!e)return;let O=null;const I=k.current?.closest(".frame-scrollbar, .s-content")??null,z=()=>{if(!I){S({});return}const D=I.getBoundingClientRect();S({"--doc-focus-layer-top":`${Math.max(0,D.top)}px`,"--doc-focus-layer-right":`${Math.max(0,window.innerWidth-D.right)}px`,"--doc-focus-layer-bottom":`${Math.max(0,window.innerHeight-D.bottom)}px`,"--doc-focus-layer-left":`${Math.max(0,D.left)}px`})},_=()=>{O!==null&&cancelAnimationFrame(O),O=requestAnimationFrame(z)};z();const U=I?new ResizeObserver(_):null;return I&&U?.observe(I),window.addEventListener("resize",_),()=>{O!==null&&cancelAnimationFrame(O),U?.disconnect(),window.removeEventListener("resize",_)}},[e]),m.useEffect(()=>{if(!e)return;const O=L=>{L.key==="Escape"&&(L.preventDefault(),C?E(!1):b?.())};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[C,b,e]),!e)return null;const N=a??r?.title??"Document",T=f??(r?.kind==="markdown"?"preview":"read"),R=t&&!!(r||y);return s.jsxs("div",{ref:k,className:`s-doc-focus-layer${C?" s-doc-focus-layer-focused":""}`,style:A,children:[b&&s.jsx("button",{type:"button",className:"s-doc-focus-scrim","aria-label":"Dismiss document viewer",tabIndex:-1,onClick:b}),s.jsxs("section",{className:`s-doc-focus-viewer s-doc-focus-viewer-${n}${C?" s-doc-focus-viewer-focused":""}`,"aria-label":N,role:"dialog","aria-modal":"true",children:[s.jsxs("div",{className:"s-doc-focus-viewer-head",children:[s.jsxs("div",{className:"s-doc-focus-viewer-title-wrap",children:[s.jsx("div",{className:"s-doc-focus-viewer-icon","aria-hidden":"true",children:s.jsx(Dd,{size:15,strokeWidth:1.8})}),s.jsxs("div",{className:"s-doc-focus-viewer-title-main",children:[o&&s.jsx("div",{className:"s-doc-focus-viewer-eyebrow",children:o}),s.jsx("h3",{className:"s-doc-focus-viewer-title",children:N}),c&&s.jsx("div",{className:"s-doc-focus-viewer-subtitle",children:c})]})]}),s.jsxs("div",{className:"s-doc-focus-viewer-actions",children:[u.length>0&&s.jsx("div",{className:"s-doc-focus-viewer-meta","aria-label":"Document metadata",children:u.map(O=>s.jsx("span",{children:O},O))}),h.map(O=>s.jsxs("button",{type:"button",className:`s-doc-focus-viewer-action${O.hideLabel?" s-doc-focus-viewer-action-icon":""}`,onClick:O.onClick,title:O.title??O.label,disabled:O.disabled,"aria-label":O.hideLabel?O.label:void 0,children:[O.icon,!O.hideLabel&&s.jsx("span",{children:O.label})]},O.label)),R&&s.jsx("button",{type:"button",className:"s-doc-focus-viewer-close",onClick:()=>E(O=>!O),"aria-label":C?"Exit focus mode":"Enter focus mode",title:C?"Exit focus mode":"Focus",children:C?s.jsx(C2,{"aria-hidden":"true",size:14,strokeWidth:1.8}):s.jsx(qw,{"aria-hidden":"true",size:14,strokeWidth:1.8})}),b&&s.jsx("button",{type:"button",className:"s-doc-focus-viewer-close",onClick:b,"aria-label":"Close document viewer",title:"Close",children:s.jsx(Bi,{"aria-hidden":"true",size:14,strokeWidth:1.8})})]})]}),p&&!x&&!r&&!y&&s.jsx("div",{className:"s-doc-focus-viewer-state",children:p}),x&&s.jsx("div",{className:"s-doc-focus-viewer-state s-doc-focus-viewer-error",children:x}),!x&&y&&s.jsx("div",{className:"s-doc-focus-viewer-body",children:y}),!x&&!y&&r&&s.jsx(jf,{document:r,mode:T,showHeader:!1,className:"s-doc-focus-document"}),!x&&v&&s.jsx("div",{className:"s-doc-focus-viewer-notice",children:v})]})]})}const Ere={id:"audio",canHandle:e=>e.kind==="file"&&e.mediaType.startsWith("audio/"),render:({resource:e})=>{const t=e;return s.jsx("div",{className:"s-file-preview-media-wrap",children:s.jsx("div",{className:"s-file-preview-audio-stage",children:s.jsx("audio",{className:"s-file-preview-audio",src:t.rawUrl,controls:!0})})})}},Are={id:"binary",canHandle:()=>!0,render:({resource:e})=>{const t=e;return s.jsxs("div",{className:"s-file-preview-callout",children:[s.jsxs("div",{className:"s-file-preview-callout-title",children:[t.previewReason," — open in OS"]}),s.jsxs("div",{className:"s-file-preview-callout-copy",children:["Scout can resolve this file, but it does not have an inline preview for ",t.mediaType," yet."]})]})}},Tre=new Set(["text/typescript","text/javascript","text/css","text/html","application/json","text/yaml","text/toml","text/x-shellscript","text/plain"]),Mre={id:"code",canHandle:e=>e.kind==="file"&&e.previewable&&Tre.has(e.mediaType),render:({resource:e})=>{const t=e,n=Qc({id:t.realPath,title:t.title,uri:t.realPath,mediaType:t.mediaType,value:t.content,filename:t.title,kind:"code",readOnly:!0});return s.jsx(jf,{document:n,mode:"read",className:"s-doc-focus-document"})}},Rre={id:"directory",canHandle:e=>e.kind==="directory",render:({resource:e,openFilePreview:t})=>{const n=e,r=Ire(n.realPath,n.rootPath);return s.jsxs("div",{className:"s-file-preview-directory",children:[s.jsx("div",{className:"s-file-preview-breadcrumb","aria-label":"Directory breadcrumb",children:r.map((a,o)=>{const c=o===r.length-1;return s.jsxs("div",{className:"s-file-preview-breadcrumb-item",children:[o>0&&s.jsx(hg,{size:12,"aria-hidden":"true"}),c?s.jsx("span",{className:"s-file-preview-breadcrumb-current",children:a.label}):s.jsx("button",{type:"button",className:"s-file-preview-breadcrumb-link",onClick:()=>t(a.path),children:a.label})]},a.path)})}),s.jsxs("div",{className:"s-file-preview-directory-list",role:"list",children:[n.entries.map(a=>s.jsxs("button",{type:"button",className:"s-file-preview-entry",onClick:()=>t(a.path),children:[s.jsx("span",{className:"s-file-preview-entry-icon","aria-hidden":"true",children:a.kind==="directory"?s.jsx(N2,{size:14}):s.jsx(Dd,{size:14})}),s.jsx("span",{className:"s-file-preview-entry-name",children:a.name}),s.jsx("span",{className:"s-file-preview-entry-kind",children:a.kind==="directory"?"dir":"file"})]},a.realPath)),n.entries.length===0&&s.jsx("div",{className:"s-file-preview-directory-empty",children:"This directory is empty."})]})]})}};function Ire(e,t){const n=t==="/"?"/":t.replace(/\/+$/u,""),r=e==="/"?"/":e.replace(/\/+$/u,""),a=n.split("/").filter(Boolean),o=r.split("/").filter(Boolean),c=[{label:a[a.length-1]??"/",path:n||"/"}];let u=n||"/";for(let f=a.length;f<o.length;f+=1){const h=o[f];h&&(u=u==="/"?`/${h}`:`${u}/${h}`,c.push({label:h,path:u}))}return c}const _re={id:"image",canHandle:e=>e.kind==="file"&&e.mediaType.startsWith("image/"),render:({resource:e})=>s.jsx("div",{className:"s-file-preview-image-wrap",children:s.jsx("div",{className:"s-file-preview-image-stage",children:s.jsx("img",{className:"s-file-preview-image",src:e.kind==="file"?e.rawUrl:"",alt:e.title})})})},Ore={id:"markdown",canHandle:e=>e.kind==="file"&&e.previewable&&e.mediaType==="text/markdown",render:({resource:e})=>{const t=e,n=Qc({id:t.realPath,title:t.title,uri:t.realPath,mediaType:t.mediaType,value:t.content,filename:t.title,kind:"markdown",readOnly:!0});return s.jsx(jf,{document:n,mode:"preview",className:"s-doc-focus-document"})}},$re={id:"video",canHandle:e=>e.kind==="file"&&e.mediaType.startsWith("video/"),render:({resource:e})=>{const t=e;return s.jsx("div",{className:"s-file-preview-media-wrap",children:s.jsx("div",{className:"s-file-preview-media-stage",children:s.jsx("video",{className:"s-file-preview-video",src:t.rawUrl,controls:!0})})})}},Lre=[Rre,Ore,Mre,_re,$re,Ere,Are];function Pre({path:e,onOpenPath:t,onClose:n}){const[r,a]=m.useState(null),[o,c]=m.useState(null),[u,f]=m.useState(!1),[h,p]=m.useState(null),x=m.useRef(null);m.useEffect(()=>{x.current=h},[h]),m.useEffect(()=>{if(!e){a(null),c(null),f(!1);return}let T=!1;return f(!0),c(null),a(null),ue(`/api/file/preview?path=${encodeURIComponent(e)}`).then(R=>{T||(a(R),Dre(R,x.current,p))}).catch(R=>{T||c(R instanceof Error?R.message:"could not load file")}).finally(()=>{T||f(!1)}),()=>{T=!0}},[e]);const{currentIndex:v,prevPath:y,nextPath:b}=m.useMemo(()=>{if(!r||r.kind!=="file"||!h)return{currentIndex:-1,prevPath:null,nextPath:null};const T=h.files.findIndex(R=>R.realPath===r.realPath);return T<0?{currentIndex:-1,prevPath:null,nextPath:null}:{currentIndex:T,prevPath:T>0?h.files[T-1].path:null,nextPath:T<h.files.length-1?h.files[T+1].path:null}},[r,h]);if(m.useEffect(()=>{if(!e)return;const T=R=>{if(R.key==="Escape"){n();return}if(R.target instanceof HTMLElement){const O=R.target.tagName;if(O==="INPUT"||O==="TEXTAREA"||R.target.isContentEditable)return}R.metaKey||R.ctrlKey||R.altKey||(R.key==="ArrowLeft"&&y?(R.preventDefault(),t(y)):R.key==="ArrowRight"&&b?(R.preventDefault(),t(b)):R.key==="Backspace"&&h&&r?.kind==="file"&&(R.preventDefault(),t(h.dirPath)))};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[e,n,t,y,b,h,r]),!e)return null;const C=()=>{ue("/api/file/reveal",{method:"POST",body:JSON.stringify({path:r?.realPath??e})}).catch(T=>{c(T instanceof Error?T.message:"reveal failed")})},E=r?Lre.find(T=>T.canHandle(r))??null:null,A=!!(r&&r.kind==="file"&&h&&v>=0&&h.files.length>1),S=[];A&&h&&S.push({label:`Folder: ${h.dirTitle}`,icon:s.jsx(Ww,{size:12}),onClick:()=>t(h.dirPath),title:`Back to ${h.dirTitle} (Backspace)`}),S.push({label:"Open in OS",icon:s.jsx(wr,{size:12}),onClick:C,title:"Reveal this file in your operating system"});const k=r?Bre(r):[];A&&k.unshift(`${v+1} / ${h.files.length}`);const N=r&&E?E.render({resource:r,openFilePreview:t}):null;return s.jsx(Fg,{open:!0,kind:zre(r),document:null,title:r?.title??e.split("/").pop()??"File",eyebrow:"File preview",subtitle:r?.realPath??e,meta:k,state:u?"Loading…":null,error:o,body:N?s.jsxs("div",{className:`s-file-preview-shell${A?" s-file-preview-shell-nav":""}`,children:[A&&s.jsx("button",{type:"button",className:"s-file-preview-side-nav s-file-preview-side-nav-left",onClick:()=>y&&t(y),disabled:!y,"aria-label":"Previous file",title:"Previous file (←)",children:s.jsx(b6,{size:18,strokeWidth:1.8,"aria-hidden":"true"})}),s.jsx("div",{className:"s-file-preview-shell-body",children:N}),A&&s.jsx("button",{type:"button",className:"s-file-preview-side-nav s-file-preview-side-nav-right",onClick:()=>b&&t(b),disabled:!b,"aria-label":"Next file",title:"Next file (→)",children:s.jsx(j6,{size:18,strokeWidth:1.8,"aria-hidden":"true"})})]}):null,actions:S,onClose:n})}function Dre(e,t,n){if(e.kind==="directory"){const a=e.entries.filter(o=>o.kind==="file");n({dirPath:e.path,dirTitle:e.title,files:a});return}if(!t){n(null);return}t.files.some(a=>a.realPath===e.realPath)||n(null)}function zre(e){return!e||e.kind==="directory"||e.mediaType==="text/markdown"||e.mediaType==="text/plain"?"doc":"code"}function Bre(e){return e.kind==="directory"?[`${e.entries.length} ${e.entries.length===1?"entry":"entries"}`]:[...e.previewable&&e.truncated?["truncated"]:[],Ure(e.sizeBytes),e.mediaType]}function Ure(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const rD={activity:"idle",brief:{lastDeliveredAt:null},reminders:{dueCount:0,upcomingCount:0,due:[],next:null},voice:{available:null,setupBlocked:!1,replies:!1},error:null,session:{title:null,lastActivityAt:null}},vi=()=>{},aD={focusScoutbot:vi,triggerBrief:vi,triggerAskState:vi,toggleVoiceReplies:vi,openScoutbotSettings:vi,startNewChat:vi,dismissReminder:vi,askReminderStatus:vi},ik=m.createContext(null);function Fre({children:e}){const[t,n]=m.useState(rD),r=m.useRef(aD),a=m.useCallback(f=>{n(h=>Wre(h,f)?h:f)},[]),o=m.useCallback(f=>{r.current=f},[]),c=m.useMemo(()=>({focusScoutbot:()=>r.current.focusScoutbot(),triggerBrief:()=>r.current.triggerBrief(),triggerAskState:()=>r.current.triggerAskState(),toggleVoiceReplies:()=>r.current.toggleVoiceReplies(),openScoutbotSettings:()=>r.current.openScoutbotSettings(),startNewChat:()=>r.current.startNewChat(),dismissReminder:f=>r.current.dismissReminder(f),askReminderStatus:f=>r.current.askReminderStatus(f)}),[]),u=m.useMemo(()=>({state:t,actions:c,publishState:a,registerActions:o}),[t,c,a,o]);return s.jsx(ik.Provider,{value:u,children:e})}function Vre(){const e=m.useContext(ik);return e?{state:e.state,actions:e.actions}:{state:rD,actions:aD}}function Hre(){const e=m.useContext(ik);return e?{publishState:e.publishState,registerActions:e.registerActions}:null}function Wre(e,t){return e.activity===t.activity&&e.brief.lastDeliveredAt===t.brief.lastDeliveredAt&&e.reminders.dueCount===t.reminders.dueCount&&e.reminders.upcomingCount===t.reminders.upcomingCount&&qre(e.reminders.due,t.reminders.due)&&iD(e.reminders.next,t.reminders.next)&&e.voice.available===t.voice.available&&e.voice.setupBlocked===t.voice.setupBlocked&&e.voice.replies===t.voice.replies&&e.error===t.error&&e.session.title===t.session.title&&e.session.lastActivityAt===t.session.lastActivityAt}function qre(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(!iD(e[n],t[n]))return!1;return!0}function iD(e,t){return e===t?!0:!e||!t?!1:e.id===t.id&&e.body===t.body&&e.status===t.status&&e.dueAt===t.dueAt}class Yr extends Error{code;cause;constructor(t,n,r){super(n),this.name="HudVaultError",this.code=t,this.cause=r}}const Yu="items",lm="keys",dM="master";class Kre{service;dbPromise;cryptoKeyPromise;constructor(t){this.service=t.service}async set(t,n){const r=new TextEncoder().encode(n);await this.setBytes(t,r)}async get(t){const n=await this.getBytes(t);if(!n)return null;try{return new TextDecoder().decode(n)}catch(r){throw new Yr("encoding_failed","value is not valid UTF-8",r)}}async delete(t){await this.idbDelete(Yu,t)}async setBytes(t,n){const r=await this.getOrCreateCryptoKey(),a=crypto.getRandomValues(new Uint8Array(12));let o;try{o=await crypto.subtle.encrypt({name:"AES-GCM",iv:a},r,n)}catch(c){throw new Yr("crypto_failed","AES-GCM encrypt failed",c)}await this.idbWrite(Yu,t,{iv:a,ct:new Uint8Array(o)})}async getBytes(t){const n=await this.idbRead(Yu,t);if(!n)return null;const r=await this.getOrCreateCryptoKey();try{const a=await crypto.subtle.decrypt({name:"AES-GCM",iv:n.iv},r,n.ct);return new Uint8Array(a)}catch(a){throw new Yr("crypto_failed","AES-GCM decrypt failed",a)}}getOrCreateCryptoKey(){return this.cryptoKeyPromise?this.cryptoKeyPromise:(this.cryptoKeyPromise=(async()=>{if(typeof crypto>"u"||!crypto.subtle)throw new Yr("crypto_unsupported","crypto.subtle is not available");const t=await this.idbRead(lm,dM);if(t)return t;let n;try{n=await crypto.subtle.generateKey({name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}catch(r){throw new Yr("crypto_failed","AES-GCM key generation failed",r)}return await this.idbWrite(lm,dM,n),n})(),this.cryptoKeyPromise)}getDB(){return this.dbPromise?this.dbPromise:(this.dbPromise=new Promise((t,n)=>{if(typeof indexedDB>"u"){n(new Yr("idb_unsupported","IndexedDB is not available"));return}const r=indexedDB.open(`hudvault:${this.service}`,1);r.onupgradeneeded=()=>{const a=r.result;a.objectStoreNames.contains(Yu)||a.createObjectStore(Yu),a.objectStoreNames.contains(lm)||a.createObjectStore(lm)},r.onsuccess=()=>t(r.result),r.onerror=()=>n(new Yr("idb_failed",cm("open",r.error),r.error))}),this.dbPromise)}async idbRead(t,n){const r=await this.getDB();return new Promise((a,o)=>{const u=r.transaction(t,"readonly").objectStore(t).get(n);u.onsuccess=()=>a(u.result),u.onerror=()=>o(new Yr("idb_failed",cm("read",u.error),u.error))})}async idbWrite(t,n,r){const a=await this.getDB();await new Promise((o,c)=>{const u=a.transaction(t,"readwrite");u.oncomplete=()=>o(),u.onerror=()=>c(new Yr("idb_failed",cm("write",u.error),u.error)),u.objectStore(t).put(r,n)})}async idbDelete(t,n){const r=await this.getDB();await new Promise((a,o)=>{const c=r.transaction(t,"readwrite");c.oncomplete=()=>a(),c.onerror=()=>o(new Yr("idb_failed",cm("delete",c.error),c.error)),c.objectStore(t).delete(n)})}}function cm(e,t){return`IndexedDB ${e} failed${t?.message?`: ${t.message}`:""}`}const Gre="dev.openscout.credentials",ok="openai_api_key",lk=new Kre({service:Gre});async function oD(){const t=(await lk.get(ok))?.trim();return t&&t.startsWith("sk-")?t:null}async function Zre(e){const t=e.trim();if(!t.startsWith("sk-"))throw new Error("OpenAI API keys should start with sk-.");await lk.set(ok,t)}async function Yre(){await lk.delete(ok)}async function lD(e){return ue("/api/scoutbot/credentials/openai",{method:"POST",body:JSON.stringify({apiKey:e.trim()})})}async function Xre(){return ue("/api/scoutbot/credentials/openai",{method:"DELETE"})}async function cD(){return ue("/api/scoutbot/credentials")}async function Y0(){const e=await cD();if(e.openai.configured)return e;const t=await oD();return t?lD(t):null}async function Qre(){const e=await oD();return{configured:!!e,preview:e?Jre(e):null}}function Jre(e){return e.length<=10?"configured":`${e.slice(0,5)}...${e.slice(-4)}`}const eae=[195,125,300,45,355,210];function fM(e){return`oklch(0.80 0.14 ${e})`}function tae(e){return`oklch(0.18 0.08 ${e})`}function Pi({label:e,right:t}){return s.jsxs("div",{className:"s-settings-section-rule",children:[s.jsx("span",{className:"s-settings-section-label",children:e}),s.jsx("span",{className:"s-settings-section-line"}),t&&s.jsx("span",{className:"s-settings-section-right",children:t})]})}function Qs({label:e,hint:t,children:n}){return s.jsxs("div",{className:"s-settings-field",children:[s.jsx("label",{className:"s-settings-field-label",children:e}),n,t&&s.jsx("span",{className:"s-settings-field-hint",children:t})]})}function ac({value:e,onChange:t,mono:n}){return s.jsx("input",{className:`s-settings-input${n?" s-settings-input--mono":""}`,value:e,onChange:r=>t(r.target.value)})}function nae({value:e,onChange:t,rows:n=3}){return s.jsx("textarea",{className:"s-settings-textarea",value:e,onChange:r=>t(r.target.value),rows:n})}function sae({value:e,onChange:t,min:n,max:r,step:a=1,unit:o=""}){return s.jsxs("div",{className:"s-settings-slider-wrap",children:[s.jsx("input",{type:"range",min:n,max:r,step:a,value:e,onChange:c=>t(Number(c.target.value))}),s.jsxs("span",{className:"s-settings-slider-value",children:[e," ",o]})]})}function um({value:e,onChange:t,options:n,stacked:r,columns:a}){return s.jsx("div",{className:r?"s-settings-option-stacked":"s-settings-option-grid",style:r?void 0:{gridTemplateColumns:`repeat(${a??n.length}, 1fr)`},children:n.map(o=>s.jsxs("button",{className:`s-settings-option-btn${e===o.id?" s-settings-option-btn--active":""}`,onClick:()=>t(o.id),children:[s.jsx("span",{className:"s-settings-option-label",children:o.label}),s.jsx("span",{className:"s-settings-option-sub",children:o.sub})]},o.id))})}function rae({profile:e,update:t}){return s.jsxs("div",{className:"s-settings-col-gap",children:[s.jsx(Pi,{label:"Identity",right:"visible to every agent"}),s.jsxs("div",{className:"s-settings-identity-card",children:[s.jsx("span",{className:"s-settings-identity-dot",style:{background:fM(e.hue),color:tae(e.hue)},children:(e.name||"?")[0].toUpperCase()}),s.jsxs("div",{style:{flex:1},children:[s.jsx("div",{className:"s-settings-identity-name",children:e.name||"Unnamed"}),s.jsxs("div",{className:"s-settings-identity-meta",children:[e.handle||"@you"," · ",e.pronouns||"—"," · operator"]})]}),s.jsxs("div",{className:"s-settings-hue-wrap",children:[s.jsx("span",{className:"s-settings-field-label",children:"Identity hue"}),s.jsx("div",{className:"s-settings-hue-row",children:eae.map(n=>s.jsx("button",{onClick:()=>t({hue:n}),className:`s-settings-hue-dot${e.hue===n?" s-settings-hue-dot--active":""}`,style:{background:fM(n)}},n))})]})]}),s.jsx(Qs,{label:"Display name",hint:"Shown when agents address you.",children:s.jsx(ac,{value:e.name,onChange:n=>t({name:n})})}),s.jsx(Qs,{label:"Handle",hint:"Used in @mentions across threads.",children:s.jsx(ac,{value:e.handle,onChange:n=>t({handle:n}),mono:!0})}),s.jsx(Qs,{label:"Pronouns",children:s.jsx(ac,{value:e.pronouns,onChange:n=>t({pronouns:n})})}),s.jsx(Pi,{label:"How agents understand you",right:"shipped as system prompt context"}),s.jsx(Qs,{label:"Operator bio",hint:"How you want to be worked with. Agents read this before asking you things.",children:s.jsx(nae,{value:e.bio,onChange:n=>t({bio:n}),rows:4})}),s.jsxs("div",{className:"s-settings-two-col",children:[s.jsx(Qs,{label:"Timezone",children:s.jsx(ac,{value:e.timezone,onChange:n=>t({timezone:n}),mono:!0})}),s.jsx(Qs,{label:"Working hours",children:s.jsx(ac,{value:e.workingHours,onChange:n=>t({workingHours:n}),mono:!0})})]})]})}function aae({profile:e,update:t}){return s.jsxs("div",{className:"s-settings-col-gap",children:[s.jsx(Pi,{label:"Interrupt policy"}),s.jsx(Qs,{label:"When agents can ping you directly",hint:"Blocking-only means only asks that truly stall work. Others get batched.",children:s.jsx(um,{value:e.interruptThreshold,onChange:n=>t({interruptThreshold:n}),options:[{id:"always",label:"Always",sub:"any ask, any time"},{id:"blocking-only",label:"Blocking only",sub:"stuck agents · default"},{id:"batched",label:"Batched",sub:"grouped every 15m"},{id:"never",label:"Never",sub:"queue only, I'll check in"}]})}),s.jsxs("div",{className:"s-settings-two-col",children:[s.jsx(Qs,{label:"Batch window (min)",children:s.jsx(sae,{value:e.batchWindow,min:5,max:60,step:5,onChange:n=>t({batchWindow:n}),unit:"min"})}),s.jsx(Qs,{label:"Quiet hours",children:s.jsx(ac,{value:e.quietHours,onChange:n=>t({quietHours:n}),mono:!0})})]}),s.jsx(Pi,{label:"Where to reach you"}),s.jsx(Qs,{label:"Preferred channel",children:s.jsx(um,{value:e.channel,onChange:n=>t({channel:n}),options:[{id:"here",label:"Here only",sub:"desktop app"},{id:"mobile",label:"Mobile only",sub:"paired phone"},{id:"here+mobile",label:"Both",sub:"whichever is active"}]})}),s.jsx(Pi,{label:"Tone calibration",right:"how agents write to you"}),s.jsxs("div",{className:"s-settings-two-col",children:[s.jsx(Qs,{label:"Verbosity",children:s.jsx(um,{stacked:!0,value:e.verbosity,onChange:n=>t({verbosity:n}),options:[{id:"terse",label:"Terse",sub:"one-liners, answers only"},{id:"normal",label:"Normal",sub:"context + answer"},{id:"detailed",label:"Detailed",sub:"show reasoning"}]})}),s.jsx(Qs,{label:"Tone",children:s.jsx(um,{stacked:!0,value:e.tone,onChange:n=>t({tone:n}),options:[{id:"direct",label:"Direct",sub:"no hedging"},{id:"warm",label:"Warm",sub:"friendly, conversational"},{id:"formal",label:"Formal",sub:"business-like"}]})})]})]})}function iae({clientCredentials:e,serverCredentials:t,reloadCredentials:n}){const[r,a]=m.useState(""),[o,c]=m.useState(!1),[u,f]=m.useState(null),h=t?.openai??null,p=!!h?.configured,x=h?.source==="env"?"OPENAI_API_KEY":h?.source==="local-config"?"local Scout config":h?.source==="local-store"?"local OpenScout store":"missing",v=h?.source==="local-store"&&e?.configured?"local OpenScout store + HudVault mirror":x,y=h?.preview??e?.preview??null,b=async()=>{c(!0),f(null);try{const E=r.trim();await lD(E);let A=null;try{await Zre(E)}catch(S){A=S instanceof Error?S.message:"HudVault save failed."}a(""),await n(),f(A?`Saved to local OpenScout store. Browser mirror failed: ${A}`:"Saved to local OpenScout store and Hudson Vault.")}catch(E){f(E instanceof Error?E.message:"Could not save key.")}finally{c(!1)}},C=async()=>{c(!0),f(null);try{const[E,A]=await Promise.allSettled([Yre(),Xre()]);a(""),await n(),E.status==="rejected"||A.status==="rejected"?f("Cleared what I could; one credential store did not respond."):f(h?.source==="env"||h?.source==="local-config"?"Removed saved key. Server fallback is still configured.":"Removed saved key.")}catch(E){f(E instanceof Error?E.message:"Could not clear key.")}finally{c(!1)}};return s.jsxs("div",{className:"s-settings-col-gap",children:[s.jsx(Pi,{label:"Model providers",right:p?`configured · ${v}`:"missing"}),s.jsx("div",{className:"s-settings-relay-card",children:s.jsxs("div",{children:[s.jsxs("div",{className:"s-settings-relay-title",children:["OpenAI · ",s.jsxs("span",{className:"s-settings-device-status",style:{color:p?"var(--green)":"var(--dim)"},children:["●"," ",p?"ready":"missing"]})]}),s.jsxs("div",{className:"s-settings-relay-meta",children:[y??"No key stored"," · ",v]}),s.jsx("div",{className:"s-settings-relay-desc",children:"Scout stores user-entered keys in the local OpenScout credential store and keeps a HudVault mirror for this browser profile."})]})}),s.jsx(Qs,{label:"OpenAI API key",hint:"Saved locally. Existing keys are never shown again.",children:s.jsx("input",{className:"s-settings-input s-settings-input--mono",type:"password",value:r,placeholder:p?"Saved key configured":"sk-...",autoComplete:"off",spellCheck:!1,onChange:E=>a(E.target.value)})}),u&&s.jsx("div",{className:"s-settings-field-hint",children:u}),s.jsxs("div",{className:"s-settings-button-row",children:[s.jsx("button",{type:"button",className:"s-btn",disabled:o||!r.trim(),onClick:()=>{b()},children:o?"Saving":"Save key"}),s.jsx("button",{type:"button",className:"s-btn",disabled:o||!(e?.configured||h?.source==="local-store"),onClick:()=>{C()},children:"Clear saved key"})]})]})}const oae={desktop:"◻",mobile:"▯",tablet:"▭"};function lae({device:e}){const t=e.status==="this-device"?"var(--accent)":e.status==="online"?"var(--green)":"var(--dim)";return s.jsxs("div",{className:"s-settings-device-row",children:[s.jsx("span",{className:"s-settings-device-icon",children:oae[e.kind]??"□"}),s.jsxs("div",{children:[s.jsx("div",{className:"s-settings-device-name",children:e.name}),s.jsxs("div",{className:"s-settings-device-meta",children:[e.kind," · via ",e.relay," · ",e.lastSeen]})]}),s.jsxs("span",{className:"s-settings-device-status",style:{color:t},children:["●"," ",e.status==="this-device"?"this device":e.status]}),s.jsx("button",{className:"s-btn",disabled:e.status==="this-device",children:e.status==="this-device"?"—":"Unpair"})]})}function cae({pairing:e}){const t=[{id:"local",name:"This machine",kind:"desktop",status:"this-device",relay:"local",lastSeen:"now"}];if(e?.trustedPeers)for(const n of e.trustedPeers){const r=n.fingerprint===e.connectedPeerFingerprint;t.push({id:n.fingerprint,name:n.name??"Paired device",kind:"mobile",status:r?"online":"offline",relay:"tailscale",lastSeen:n.lastSeenLabel??"—"})}return s.jsxs("div",{className:"s-settings-col-gap",children:[s.jsx(Pi,{label:`Paired devices · ${t.length}`}),s.jsx("div",{className:"s-settings-col-gap",style:{gap:10},children:t.map(n=>s.jsx(lae,{device:n},n.id))}),s.jsx(Pi,{label:"Relay"}),s.jsxs("div",{className:"s-settings-relay-card",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"s-settings-relay-title",children:["Relay · ",s.jsxs("span",{className:"s-settings-device-status",style:{color:e?.isRunning?"var(--green)":"var(--dim)"},children:["●"," ",e?.isRunning?"connected":"offline"]})]}),s.jsxs("div",{className:"s-settings-relay-meta",children:[e?.relay??"not configured"," · tailscale"]}),s.jsx("div",{className:"s-settings-relay-desc",children:"Agents route through your relay to reach mobile when the app is backgrounded. End-to-end encrypted; keys never leave your devices."})]}),s.jsx("button",{className:"s-btn",children:"Configure"})]})]})}const uae=[{id:"operator",label:"Operator",sub:"identity · bio · hours"},{id:"comms",label:"Communication",sub:"how agents reach you"},{id:"credentials",label:"Credentials",sub:"model provider keys"},{id:"devices",label:"Paired devices",sub:"relay · connected"}],dae={operator:"Operator identity",comms:"Communication",credentials:"Credentials",devices:"Paired devices"},fae={name:"",handle:"",pronouns:"",hue:195,bio:"",timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,workingHours:"08:00 – 18:00",interruptThreshold:"blocking-only",batchWindow:15,channel:"here+mobile",verbosity:"terse",tone:"direct",quietHours:"22:00 – 07:00"};function hae({open:e,onClose:t}){const{refreshOnboarding:n}=qe(),[r,a]=m.useState("operator"),[o,c]=m.useState(fae),[u,f]=m.useState(null),[h,p]=m.useState(null),[x,v]=m.useState(null),[y,b]=m.useState(!1),C=m.useRef(null),E=m.useCallback(async()=>{const[N,T]=await Promise.allSettled([Qre(),cD()]),R=N.status==="fulfilled"?N.value:null;let O=T.status==="fulfilled"?T.value:null;R?.configured&&!O?.openai.configured&&(O=await Y0().catch(()=>O)),p(R),v(O)},[]),A=m.useCallback(async()=>{try{const N=ue("/api/user"),T=Promise.race([ue("/api/pairing-state"),new Promise((L,I)=>setTimeout(()=>I(new Error("timeout")),3e3))]),[R,O]=await Promise.allSettled([N,T]);R.status==="fulfilled"&&c(R.value),O.status==="fulfilled"&&f(O.value),await E()}finally{b(!0)}},[E]);m.useEffect(()=>{e&&A()},[e,A]),m.useEffect(()=>{if(!e)return;const N=T=>{T.key==="Escape"&&t()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e,t]);const S=m.useCallback(N=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{ue("/api/user",{method:"POST",body:JSON.stringify(N)}).then(()=>n()).catch(()=>{})},400)},[n]),k=m.useCallback(N=>{c(T=>{const R={...T,...N};return S(R),R})},[S]);return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:`s-settings-scrim ${e?"s-settings-scrim--open":"s-settings-scrim--closed"}`,onClick:t}),s.jsxs("div",{className:`s-settings-drawer ${e?"s-settings-drawer--open":"s-settings-drawer--closed"}`,children:[s.jsxs("div",{className:"s-settings-header",children:[s.jsxs("div",{className:"s-settings-header-title",children:["⚙"," SETTINGS"]}),s.jsx("span",{className:"s-settings-header-sep",children:"/"}),s.jsx("span",{className:"s-settings-header-section",children:dae[r]}),s.jsx("span",{style:{flex:1}}),s.jsx("span",{className:"s-settings-header-hint",children:"ESC to close"}),s.jsx("button",{className:"s-settings-close",onClick:t,children:"×"})]}),s.jsx("nav",{className:"s-settings-rail",children:uae.map(N=>s.jsxs("button",{onClick:()=>a(N.id),className:`s-settings-rail-btn${r===N.id?" s-settings-rail-btn--active":""}`,children:[s.jsx("span",{className:"s-settings-rail-label",children:N.label}),s.jsx("span",{className:"s-settings-rail-sub",children:N.sub})]},N.id))}),s.jsx("main",{className:"s-settings-content",children:y?s.jsxs(s.Fragment,{children:[r==="operator"&&s.jsx(rae,{profile:o,update:k}),r==="comms"&&s.jsx(aae,{profile:o,update:k}),r==="credentials"&&s.jsx(iae,{clientCredentials:h,serverCredentials:x,reloadCredentials:E}),r==="devices"&&s.jsx(cae,{pairing:u})]}):s.jsx("div",{style:{color:"var(--dim)",fontFamily:"var(--font-mono)",fontSize:12},children:"Loading..."})}),s.jsxs("div",{className:"s-settings-footer",children:[s.jsxs("span",{className:"s-settings-footer-sync",children:["●"," synced"]}),s.jsx("span",{children:"·"}),s.jsx("span",{children:"changes apply instantly to every agent in your fleet"}),s.jsx("span",{style:{flex:1}}),s.jsx("button",{className:"s-btn",onClick:t,children:"Done"})]})]})]})}const uD=m.createContext(null),mae=["hello","node.upserted","actor.registered","agent.registered","agent.endpoint.upserted","invocation.requested","flight.updated","delivery.state.changed","scout.dispatched"],pae=new Set(mae),gae=15e3;function vae(e,t){try{return JSON.stringify(e)===JSON.stringify(t)?e:t}catch{return t}}const xae={"--hud-bg":"oklch(0.14 0.008 80)","--hud-surface":"oklch(0.18 0.009 80)","--hud-ink":"oklch(0.96 0.008 80)","--hud-muted":"oklch(0.72 0.012 80)","--hud-dim":"oklch(0.58 0.012 80)","--hud-border":"oklch(0.96 0.008 80 / 0.035)","--hud-accent":"oklch(0.86 0.17 125)","--hud-accent-soft":"oklch(0.86 0.17 125 / 0.08)","--hud-shadow-soft":"oklch(0.10 0.006 75 / 0.4)","--hud-chrome-border":"oklch(0.96 0.008 80 / 0.009)","--hud-shadow-panel":"0 12px 34px oklch(0.08 0.006 75 / 0.45)","--hud-shadow-panel-hover":"0 14px 38px oklch(0.08 0.006 75 / 0.52)","--hud-shadow-bar":"0 -10px 28px oklch(0.08 0.006 75 / 0.38)","--hud-shadow-nav":"0 8px 24px oklch(0.08 0.006 75 / 0.32)","--hud-shadow-minimap":"0 10px 24px oklch(0.08 0.006 75 / 0.38)","--hud-status-ok":"oklch(0.80 0.15 155)","--hud-status-warn":"oklch(0.82 0.15 85)","--hud-status-error":"oklch(0.72 0.18 25)","--scrim":"rgba(0, 0, 0, 0.5)","--scrim-soft":"rgba(0, 0, 0, 0.3)","--info":"#62b6ff","--shadow-card":"0 8px 22px rgba(0, 0, 0, 0.22)","--shadow-card-hover":"0 14px 36px rgba(0, 0, 0, 0.30)","--cat-gold":"#d7a978","--cat-purple":"#c58cff","--cat-sky":"#38bdf8","--scout-chrome-ink-strong":"color-mix(in srgb, var(--hud-ink) 92%, transparent)","--scout-chrome-ink":"color-mix(in srgb, var(--hud-ink) 78%, transparent)","--scout-chrome-ink-soft":"color-mix(in srgb, var(--hud-ink) 58%, transparent)","--scout-chrome-ink-faint":"color-mix(in srgb, var(--hud-ink) 38%, transparent)","--scout-chrome-ink-ghost":"color-mix(in srgb, var(--hud-ink) 22%, transparent)","--scout-chrome-hover":"color-mix(in srgb, var(--hud-ink) 4%, transparent)","--scout-chrome-active":"color-mix(in srgb, var(--hud-ink) 8%, transparent)","--scout-chrome-border-soft":"color-mix(in srgb, var(--hud-ink) 4%, transparent)","--scout-chrome-avatar-ink":"#111111","--hud-font-sans":"'Inter Tight', 'Inter', ui-sans-serif, system-ui, sans-serif","--hud-font-mono":"'JetBrains Mono', ui-monospace, Menlo, monospace","--hud-font-serif":"'Play', 'Inter Tight', ui-sans-serif, system-ui, sans-serif","--hud-font-accent-title":"var(--hud-font-sans)"},yae={"--hud-bg":"oklch(0.978 0.004 85)","--hud-surface":"oklch(0.992 0.003 85)","--hud-ink":"oklch(0.24 0.01 80)","--hud-muted":"oklch(0.56 0.014 80)","--hud-dim":"oklch(0.72 0.01 80)","--hud-border":"oklch(0.88 0.008 82 / 0.95)","--hud-accent":"oklch(0.72 0.16 125)","--hud-accent-soft":"oklch(0.72 0.16 125 / 0.11)","--hud-shadow-soft":"oklch(0.42 0.01 80 / 0.12)","--hud-status-ok":"oklch(0.64 0.16 155)","--hud-status-warn":"oklch(0.72 0.15 85)","--hud-status-error":"oklch(0.62 0.19 25)","--scrim":"rgba(20, 22, 26, 0.32)","--scrim-soft":"rgba(20, 22, 26, 0.18)","--info":"#2f7fd6","--shadow-card":"0 8px 22px oklch(0.42 0.01 80 / 0.10)","--shadow-card-hover":"0 14px 36px oklch(0.42 0.01 80 / 0.14)","--cat-gold":"#a9824f","--cat-purple":"#8b5cf6","--cat-sky":"#0ea5e9","--scout-chrome-ink-strong":"color-mix(in srgb, var(--hud-ink) 94%, transparent)","--scout-chrome-ink":"color-mix(in srgb, var(--hud-ink) 78%, transparent)","--scout-chrome-ink-soft":"color-mix(in srgb, var(--hud-ink) 60%, transparent)","--scout-chrome-ink-faint":"color-mix(in srgb, var(--hud-ink) 40%, transparent)","--scout-chrome-ink-ghost":"color-mix(in srgb, var(--hud-ink) 24%, transparent)","--scout-chrome-hover":"color-mix(in srgb, var(--hud-ink) 4%, transparent)","--scout-chrome-active":"color-mix(in srgb, var(--hud-ink) 8%, transparent)","--scout-chrome-border-soft":"color-mix(in srgb, var(--hud-border) 80%, transparent)","--scout-chrome-avatar-ink":"#ffffff","--hud-font-sans":"'Inter Tight', 'Inter', ui-sans-serif, system-ui, sans-serif","--hud-font-mono":"'JetBrains Mono', ui-monospace, Menlo, monospace","--hud-font-serif":"'Play', 'Inter Tight', ui-sans-serif, system-ui, sans-serif","--hud-font-accent-title":"var(--hud-font-sans)"};function qe(){const e=m.useContext(uD);if(!e)throw new Error("useScout must be used inside ScoutProvider");return e}function bae({children:e,initialTheme:t="dark"}){const{route:n,navigate:r}=Hne(),[a,o]=m.useState([]),[c,u]=m.useState(null),[f,h]=m.useState(!1),[p,x]=m.useState(!1),[v,y]=m.useState(null),[b,C]=m.useState(null),[E,A]=m.useState(""),S=m.useCallback(()=>x(!0),[]),k=m.useCallback(()=>x(!1),[]),N=m.useCallback(B=>{y(B)},[]),T=m.useCallback(()=>y(null),[]),R=m.useCallback((B,Q)=>{C(B),typeof Q=="string"&&A(Q.trim())},[]),O=m.useCallback(()=>{C(null),A("")},[]),L=t==="light"?yae:xae,I=m.useMemo(()=>Yse(a),[a]),z=m.useMemo(()=>Xse(I),[I]),_=m.useRef(null),U=m.useCallback(async()=>{if(_.current)return _.current;const B=(async()=>{const Q=await ue("/api/agents").catch(()=>null);Q&&o(oe=>vae(oe,Q))})();_.current=B;try{await B}finally{_.current=null}},[]),D=m.useCallback(async()=>{try{const B=await ue("/api/onboarding/state");u(B)}catch{u({hasLocalConfig:!0,hasProjectConfig:!0,hasOperatorName:!0,localConfigPath:null,projectRoot:null,currentDirectory:null,operatorName:null,operatorNameSuggestion:null})}},[]),q=m.useCallback(()=>{h(!0),ue("/api/onboarding/skip",{method:"POST",body:"{}"}).then(()=>D()).catch(()=>null)},[D]);m.useEffect(()=>{U(),D()},[U,D]),m.useEffect(()=>{const B=()=>{document.visibilityState!=="hidden"&&U()},Q=window.setInterval(B,gae);return window.addEventListener("focus",B),document.addEventListener("visibilitychange",B),()=>{window.clearInterval(Q),window.removeEventListener("focus",B),document.removeEventListener("visibilitychange",B)}},[U]);const Z=m.useMemo(()=>a.filter(B=>ha(B.state)).length,[a]),[$,G]=m.useState(null),V=m.useCallback(B=>{B?.trim()&&G(B.trim())},[]),Y=m.useCallback(()=>G(null),[]),K=m.useCallback(B=>{switch(B.type){case"navigate":r(B.route);break;case"open-scoutbot":window.dispatchEvent(new CustomEvent("scout:scoutbot-panel-open",{detail:B}));break;case"refresh":U();break;case"view-file":V(B.path);break}},[r,V,U]),P=m.useRef({applyScoutbotUiAction:K});P.current={applyScoutbotUiAction:K},Vt(B=>{pae.has(B.kind)&&U()}),m.useEffect(()=>{const B=Q=>{const oe=Q.detail,ne=oe&&typeof oe=="object"&&"type"in oe?oe:null;ne&&P.current.applyScoutbotUiAction(ne)};return window.addEventListener("scout:scoutbot-ui-action",B),window.scoutScoutbot={applyUiAction:Q=>P.current.applyScoutbotUiAction(Q),navigate:Q=>P.current.applyScoutbotUiAction({type:"navigate",route:Q})},()=>{window.removeEventListener("scout:scoutbot-ui-action",B),window.scoutScoutbot?.applyUiAction&&delete window.scoutScoutbot}},[]);const H=m.useMemo(()=>({route:n,navigate:r,agents:a,onlineCount:Z,reload:U,onboarding:c,refreshOnboarding:D,onboardingSkipped:f,skipOnboarding:q,settingsOpen:p,openSettings:S,closeSettings:k,scoutbotAgentId:I,scoutbotConversationId:z,applyScoutbotUiAction:K,selectedBrokerAttempt:v,inspectBrokerAttempt:N,clearBrokerAttempt:T,selectedKnowledgeHit:b,selectedKnowledgeQuery:E,inspectKnowledgeHit:R,clearKnowledgeHit:O,openFilePreview:V,closeFilePreview:Y}),[n,r,a,Z,U,c,D,f,q,p,S,k,I,z,K,v,N,T,b,E,R,O,V,Y]);return s.jsx(uD.Provider,{value:H,children:s.jsx("div",{"data-scout-theme":t,"data-scout-theme-mode":t,style:{...L},children:s.jsx(sre,{children:s.jsxs(Fre,{children:[e,s.jsx(hae,{open:p,onClose:k}),s.jsx(Pre,{path:$,onOpenPath:V,onClose:Y})]})})})})}function wae(e){return e?e.replace(/^https?:\/\//,"").split("/")[0].split(":")[0].split(".")[0]||e:""}function hM(e){return wae(e?.hostName)||e?.name||"machine"}function Xu(e,t,n,r){const a=t?.trim();!a||e.has(a)||e.set(a,{id:a,label:n?.trim()||a,group:r})}function jae(e,t,n){const r=new Map;e?.localNode?.id&&Xu(r,e.localNode.id,hM(e.localNode),"local");for(const a of Object.values(e?.nodes??{}))Xu(r,a.id,hM(a),a.id===e?.localNode?.id?"local":"mesh");for(const a of t)Xu(r,a.authorityNodeId,a.authorityNodeName??a.authorityNodeId,"agent"),Xu(r,a.homeNodeId,a.homeNodeName??a.homeNodeId,"agent");return n&&Xu(r,n,n,"selected"),Array.from(r.values()).sort((a,o)=>{const c=a.group==="local"?0:a.group==="mesh"?1:a.group==="agent"?2:3,u=o.group==="local"?0:o.group==="mesh"?1:o.group==="agent"?2:3;return c!==u?c-u:a.label.localeCompare(o.label)})}function kae({variant:e="bar"}){const{route:t,navigate:n,agents:r}=qe(),[a,o]=m.useState(null),c=zs(t);m.useEffect(()=>{if(!tf(t))return;let f=!1;return ue("/api/mesh").then(h=>{f||o(h)}).catch(()=>{f||o(null)}),()=>{f=!0}},[t.view]);const u=m.useMemo(()=>jae(a,r,c),[r,a,c]);return tf(t)?s.jsxs("div",{className:`machine-scope machine-scope--${e}`,children:[s.jsx("label",{className:"machine-scope-label",htmlFor:"machine-scope-select",children:"Scope"}),s.jsxs("select",{id:"machine-scope-select",className:"machine-scope-select",value:c??"",onChange:f=>{const h=f.currentTarget.value;n(h?K0(t,h):zne(t))},children:[s.jsx("option",{value:"",children:"All machines"}),u.map(f=>s.jsx("option",{value:f.id,children:f.group==="local"?`${f.label} (this machine)`:f.label},f.id))]})]}):null}const mM=[{key:"home",label:"Home",route:{view:"inbox"}},{key:"agents",label:"Agents",route:{view:"agents"}},{key:"chat",label:"Chat",route:{view:"messages"}},{key:"search",label:"Search",route:{view:"search"}},{key:"ops",label:"Ops",route:{view:"ops"}}],Nae=[{key:"home",label:"Home",route:{view:"inbox"}},{key:"agents",label:"Agents",route:{view:"agents"}},{key:"chat",label:"Chat",route:{view:"messages"}},{key:"tail",label:"Tail",route:{view:"ops",mode:"tail"}},{key:"dispatch",label:"Dispatch",route:{view:"broker"}},{key:"repos",label:"Repos",route:{view:"repos"}}],Sae={inbox:"Home",conversation:"Conversation","agent-info":"Agent",agents:"Agents",fleet:"Home",conversations:"Chat",messages:"Chat",sessions:"Sessions",repos:"Repos",harnesses:"Providers",search:"Search",channels:"Channels",activity:"Activity",mesh:"Mesh",broker:"Dispatch",settings:"Settings",work:"Work",ops:"Ops"};function Cae(e,t=!1){return t?Nae:e?mM:mM.filter(n=>n.key!=="ops")}function Eae(e,t,n=!1){if(e.view==="settings"&&e.section==="agents")return"agents";switch(e.view){case"agents":case"agent-info":case"sessions":case"terminal":return"agents";case"conversation":case"conversations":case"messages":case"channels":return"chat";case"search":return n?"home":"search";case"broker":return n?"dispatch":t?"ops":"home";case"repos":return n?"repos":t?"ops":"home";case"harnesses":return n?"home":t?"ops":"home";case"ops":return n?e.mode==="tail"?"tail":"home":t?"ops":"home";case"mesh":case"work":case"follow":return n?"home":t?"ops":"home";default:return"home"}}function Aae(e){if(e.view==="settings"&&e.section==="agents")return"Configuration";switch(e.view){case"conversation":case"agent-info":case"sessions":case"repos":case"harnesses":case"channels":case"mesh":case"broker":case"work":return Sae[e.view]??e.view;default:return null}}function Tae(){const{navigate:e,agents:t,reload:n,openSettings:r,applyScoutbotUiAction:a}=qe(),o=la("ops.control",!0),c=la("surface.scoutbot",!0),u=m.useCallback(()=>{a({type:"open-scoutbot",mode:"ask"}),window.dispatchEvent(new CustomEvent("scout:scoutbot-submit",{detail:{body:"What's the state of things? Give me a terse ops summary, the biggest risk, and the next action you recommend."}}))},[a]),f=m.useCallback(async h=>{await ue(`/api/agents/${encodeURIComponent(h)}/interrupt`,{method:"POST",body:JSON.stringify({})})},[]);return m.useMemo(()=>{const h=[{id:"nav:home",label:"Go to Home",action:()=>e({view:"inbox"}),shortcut:"Cmd+1"},{id:"nav:agents",label:"Go to Agents",action:()=>e({view:"agents"}),shortcut:"Cmd+2"},{id:"nav:fleet",label:"Open Home Overview",action:()=>e({view:"fleet"})},{id:"nav:messages",label:"Go to Chat",action:()=>e({view:"messages"}),shortcut:"Cmd+3"},{id:"nav:messages-dms",label:"Go to Chat — Private",action:()=>e({view:"messages",filter:"dm"})},{id:"nav:messages-channels",label:"Go to Chat — Shared",action:()=>e({view:"messages",filter:"channel"})},{id:"nav:sessions",label:"Open Sessions",action:()=>e({view:"sessions"})},{id:"nav:search",label:"Go to Search",action:()=>e({view:"search"}),shortcut:"Cmd+4"},{id:"nav:activity",label:"Open Activity",action:()=>e({view:"activity"})},{id:"nav:mesh",label:"Open Mesh",action:()=>e({view:"mesh"})},{id:"nav:dispatch",label:"Open Dispatch",action:()=>e({view:"broker"})},{id:"nav:harnesses",label:"Open Providers",action:()=>e({view:"harnesses"})},...o?[{id:"nav:ops",label:"Go to Ops",action:()=>e({view:"ops"}),shortcut:"Cmd+5"},{id:"nav:ops-atop",label:"Open Runtime",action:()=>e({view:"ops",mode:"atop"})},{id:"nav:workflow-topology",label:"Open Workflow Topology",action:()=>e({view:"agents"})}]:[],{id:"nav:settings",label:"Open Settings",action:()=>r(),shortcut:"Cmd+,"},{id:"nav:agent-config",label:"Open Agent Configuration",action:()=>e({view:"settings",section:"agents"})},...c?[{id:"scoutbot:open",label:"Open Scout",action:()=>a({type:"open-scoutbot",mode:"ask"})},{id:"scoutbot:state",label:"Ask Scout for State",action:()=>u()},{id:"scoutbot:ops-tail",label:"Scout: Open Ops Tail",action:()=>a({type:"navigate",route:{view:"ops",mode:"tail"}})}]:[],{id:"nav:pair",label:"Pair Device",action:()=>r()},{id:"scout:reload",label:"Reload Agents",action:()=>{n()}}];for(const p of t)h.push({id:`scout:open:${p.id}`,label:`Open ${p.name}`,action:()=>e({view:"conversation",conversationId:Qn(p.id)})}),h.push({id:`scout:send:${p.id}`,label:`Tell ${p.name}`,action:()=>e({view:"conversation",conversationId:Qn(p.id)})}),h.push({id:`scout:ask:${p.id}`,label:`Ask ${p.name}`,action:()=>e({view:"conversation",conversationId:Qn(p.id),composeMode:"ask"})}),h.push({id:`scout:interrupt:${p.id}`,label:`Interrupt ${p.name}`,action:()=>{f(p.id)}});return h},[t,a,u,f,e,o,c,n,r])}function dD(){const{onlineCount:e}=qe(),[t,n]=m.useState(null),[r,a]=m.useState(null),o=m.useRef(0),c=m.useCallback(async()=>{const f=++o.current;try{const h=await ue("/api/mesh");if(f!==o.current)return;n(h)}catch{if(f!==o.current)return;n(null)}},[]);m.useEffect(()=>{c();const f=setInterval(()=>{c()},15e3);return()=>clearInterval(f)},[c]),m.useEffect(()=>{ue("/api/build").then(a).catch(()=>a(null))},[]);const u=(()=>{if(!r)return{label:"dev",title:"Build information unavailable"};const f=r.mode==="production"?"prod":"dev",h=r.branch??"unknown",p=r.commit?` @ ${r.commit}${r.dirty?"*":""}`:"";return{label:`${f} ${h}${p}`,title:[`Mode: ${r.mode}`,`Version: ${r.version??"unknown"}`,`Branch: ${r.branch??"unknown"}`,`Commit: ${r.commit??"unknown"}`,`Dirty: ${r.dirty===null?"unknown":r.dirty?"yes":"no"}`].join(`
145
- `)}})();return{status:t===null?{label:"Broker: …",color:"neutral"}:t.health.reachable?{label:"Broker: UP",color:"emerald"}:{label:"Broker: DOWN",color:"red"},activeAgents:{label:"Active Agents",count:e},mesh:t===null?{label:"Mesh",value:"checking",color:"neutral"}:t.health.reachable?Object.values(t.nodes).filter(h=>h.id!==t.localNode?.id).length>0?{label:"Mesh",value:"connected",color:"neutral"}:t.identity.discoverable?{label:"Mesh",value:"discoverable",color:"neutral"}:{label:"Mesh",value:"local",color:"amber"}:{label:"Mesh",value:"offline",color:"neutral"},build:u}}function Mae(){return dD().status}function Rae(){const{route:e,navigate:t}=qe(),n=la("ops.control",!0),r=la("nav.clean",!1),a=Eae(e,n,r),o=Aae(e);return m.createElement("div",{className:"scout-nav-tabs"},Cae(n,r).map(({key:c,label:u,route:f})=>m.createElement("button",{key:c,className:`scout-nav-tab${a===c?" active":""}`,onClick:()=>t(f)},u)),o&&m.createElement("span",{className:"scout-nav-slash"},"/"),o&&m.createElement("span",{className:"scout-nav-crumb"},o))}function Iae(){const{openSettings:e}=qe(),t=la("nav.clean",!1);return m.createElement("div",{className:"scout-nav-actions"},!t&&m.createElement(kae,{variant:"nav"}),m.createElement("button",{onClick:()=>e(),className:"scout-nav-action scout-nav-action--settings",title:"Settings"},m.createElement(gg,{size:12,strokeWidth:1.6,"aria-hidden":!0}),m.createElement("span",null,"Settings")))}function _ae(){return"panel"}function Oae(){const{onboarding:e,onboardingSkipped:t,skipOnboarding:n}=qe();if(!e)return null;if(t||e.needed===!1||e.skippedAt||e.completedAt)return{active:!1,dismissible:!0};const r=!e.hasLocalConfig,a=!e.hasProjectConfig,o=!e.hasOperatorName;return{active:r||o||a,dismissible:!0,onDismiss:n}}const X0=["a[href]","button:not([disabled])","textarea:not([disabled])","input:not([disabled])","select:not([disabled])","[tabindex]:not([tabindex='-1'])"].join(", ");function fD(e=!0){const t=m.useRef(null),n=m.useRef(null);m.useEffect(()=>{if(!e)return;n.current=document.activeElement;const a=t.current;return a?((a.querySelector(X0)??a).focus(),()=>{n.current?.focus?.()}):void 0},[e]);const r=m.useCallback(a=>{if(!e||a.key!=="Tab")return;const o=t.current;if(!o)return;const c=Array.from(o.querySelectorAll(X0));if(c.length===0){a.preventDefault(),o.focus();return}const u=c[0],f=c[c.length-1],h=document.activeElement;a.shiftKey?(h===u||!o.contains(h))&&(a.preventDefault(),f.focus()):h===f&&(a.preventDefault(),u.focus())},[e]);return{ref:t,onKeyDown:r}}function hD(e){return Array.from(e.querySelectorAll(":scope > button:not([disabled]), :scope > [role='button']:not([aria-disabled='true'])"))}function mD(e,t){e.forEach((n,r)=>{n.tabIndex=r===t?0:-1}),e[t]?.focus()}function pD(){return m.useCallback(e=>{const t=e.key==="ArrowDown"||e.key==="j",n=e.key==="ArrowUp"||e.key==="k",r=e.key==="Home"||e.key==="g"&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey,a=e.key==="End"||e.key==="G";if(!t&&!n&&!r&&!a)return;const o=hD(e.currentTarget);if(o.length===0)return;const c=document.activeElement,u=o.findIndex(h=>h===c);let f;t?f=u<0?0:Math.min(o.length-1,u+1):n?f=u<0?o.length-1:Math.max(0,u-1):r?f=0:f=o.length-1,e.preventDefault(),mD(o,f)},[])}function Q0(e,t,n){return e||!t&&n?0:-1}function $ae(){m.useEffect(()=>{const e=t=>{if(t.key!=="["&&t.key!=="]")return;const n=t.target;if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||(n?.isContentEditable??!1))return;const a=["left","center","right"],o=t.key==="]"?1:-1,c=a.findIndex(f=>{const h=document.querySelector(`[data-pane="${f}"]`);return h?h.contains(n):!1}),u=c<0?o>0?-1:a.length:c;for(let f=u+o;f>=0&&f<a.length;f+=o){const h=document.querySelector(`[data-pane="${a[f]}"]`);if(!h)continue;const p=h.querySelector(X0);if(p){t.preventDefault(),p.focus();return}}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[])}function gD(e){m.useEffect(()=>{const t=n=>{if(n.key!=="/")return;const r=n.target;if(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||(r?.isContentEditable??!1))return;const o=e();o&&(n.preventDefault(),o.focus(),o.select())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e])}function vD(e){return t=>{if(t.key!=="ArrowDown")return;const n=e();if(!n)return;const r=hD(n);if(r.length===0)return;const a=r.findIndex(c=>c.tabIndex===0),o=a>=0?a:0;t.preventDefault(),mD(r,o)}}const Lae=[{title:"Global",bindings:[{keys:["?"],label:"Toggle this help"},{keys:["Esc"],label:"Close dialog / clear search"},{keys:["Tab","⇧ Tab"],label:"Move focus"},{keys:["["],label:"Focus previous pane"},{keys:["]"],label:"Focus next pane"}]},{title:"Lists",bindings:[{keys:["↓","j"],label:"Next item"},{keys:["↑","k"],label:"Previous item"},{keys:["g","Home"],label:"First item"},{keys:["G","End"],label:"Last item"},{keys:["Enter"],label:"Open / activate"}]},{title:"Search",bindings:[{keys:["/"],label:"Focus filter input"},{keys:["↓"],label:"From filter → first match"},{keys:["Esc"],label:"Clear filter (while focused)"}]},{title:"Tail · Atop",bindings:[{keys:["/"],label:"Open filter (Tail)"},{keys:["G"],label:"Jump to live (Tail)"},{keys:["j","k"],label:"Walk rows (Atop)"}]},{title:"Session scrubber",bindings:[{keys:["←","→"],label:"Seek ±1%"},{keys:["⇧ ←","⇧ →"],label:"Seek ±5%"},{keys:["Home","End"],label:"Jump to start / end"}]}];function Pae({open:e,onClose:t}){const{ref:n,onKeyDown:r}=fD(e);return e?s.jsx("div",{className:"kb-help-backdrop",onClick:t,role:"presentation",children:s.jsxs("div",{ref:n,className:"kb-help-panel",role:"dialog","aria-modal":"true","aria-labelledby":"kb-help-title",onClick:a=>a.stopPropagation(),onKeyDown:r,tabIndex:-1,children:[s.jsxs("header",{className:"kb-help-head",children:[s.jsx("h2",{id:"kb-help-title",className:"kb-help-title",children:"Keyboard shortcuts"}),s.jsx("button",{type:"button",className:"kb-help-close",onClick:t,"aria-label":"Close (Esc)",children:"✕"})]}),s.jsx("div",{className:"kb-help-grid",children:Lae.map(a=>s.jsxs("section",{className:"kb-help-group",children:[s.jsx("h3",{className:"kb-help-group-title",children:a.title}),s.jsx("dl",{className:"kb-help-list",children:a.bindings.map((o,c)=>s.jsxs("div",{className:"kb-help-row",children:[s.jsx("dt",{className:"kb-help-keys",children:o.keys.map((u,f)=>s.jsxs("span",{children:[f>0&&s.jsx("span",{className:"kb-help-or",children:"or"}),s.jsx("kbd",{className:"kb-help-kbd",children:u})]},f))}),s.jsx("dd",{className:"kb-help-label",children:o.label})]},`${a.title}-${c}`))})]},a.title))}),s.jsxs("footer",{className:"kb-help-foot",children:["Press ",s.jsx("kbd",{className:"kb-help-kbd",children:"?"})," to toggle · ",s.jsx("kbd",{className:"kb-help-kbd",children:"Esc"})," to close"]})]})}):null}function Dae(){const[e,t]=m.useState(!1);return m.useEffect(()=>{const n=r=>{if(r.key==="Escape"&&e){r.preventDefault(),t(!1);return}if(r.key!=="?")return;const a=r.target;a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement||(a?.isContentEditable??!1)||(r.preventDefault(),t(c=>!c))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e]),{open:e,setOpen:t}}const tl=50,zae=3e4,Bae=5*6e4,J0="openscout:toggle-scoutbot",xD="openscout.broadcast.mute",sp={filter:"all",goDark:!1,muteUntil:0};let rp={history:[],latest:null,promotedId:null,dismissedId:null,now:Date.now(),mute:sp};const Mi=new Set;let hc=null,Nc=null,sf=0,Id=null,pM=!1,Sc=null;function yD(){if(typeof window>"u")return sp;try{const e=window.localStorage.getItem(xD);if(!e)return sp;const t=JSON.parse(e);return{filter:t.filter==="warn-plus"||t.filter==="errors-only"?t.filter:"all",goDark:t.goDark===!0,muteUntil:typeof t.muteUntil=="number"?t.muteUntil:0}}catch{return sp}}function Uae(e,t){return t==="all"?!0:t==="warn-plus"?e!=="info":e==="error"}function Fae(e,t){return!!(e.goDark||e.muteUntil>t)}function Vae(e,t,n){return Fae(t,n)?!1:Uae(e.tier,t.filter)}function Hae(){for(const e of[...Mi])e()}function to(e){const t=e(rp);t!==rp&&(rp=t,Hae())}function Wae(e){to(t=>{if(t.history.some(a=>a.id===e.id))return t;const n=[...t.history,e],r=n.length>tl?n.slice(n.length-tl):n;return{...t,history:r,latest:e,promotedId:e.id,dismissedId:null}})}function qae(e){to(t=>{const n=new Set(t.history.map(c=>c.id)),r=[...t.history];for(const c of e)n.has(c.id)||r.push(c);r.sort((c,u)=>c.ts-u.ts);const a=r.length>tl?r.slice(r.length-tl):r,o=a.length?a[a.length-1]:null;return{...t,history:a,latest:o,promotedId:t.promotedId??o?.id??null}})}function Kae(){if(Nc||Mi.size===0)return;sf++;const e=Math.min(2e3*2**(sf-1),3e4);Nc=setTimeout(()=>{Nc=null,Mi.size>0&&bD()},e)}function bD(){if(hc||Mi.size===0)return;const e=new EventSource("/api/broadcast/stream");hc=e,e.onopen=()=>{sf=0},e.onmessage=t=>{try{const n=JSON.parse(t.data);Wae(n)}catch{}},e.addEventListener("ready",()=>{sf=0}),e.onerror=()=>{hc===e&&(hc=null),e.close(),Kae()}}function Gae(){hc?.close(),hc=null,Nc&&(clearTimeout(Nc),Nc=null),sf=0}function Zae(){Id||(Id=setInterval(()=>{to(e=>({...e,now:Date.now()}))},1e3))}function Yae(){Id&&(clearInterval(Id),Id=null)}async function Xae(){if(!pM){pM=!0;try{const e=await ue(`/api/broadcast/recent?limit=${tl}`);e.broadcasts?.length&&qae(e.broadcasts)}catch{}}}function Qae(){Sc||typeof window>"u"||(Sc=e=>{if(e.key!==xD)return;const t=yD();to(n=>({...n,mute:t}))},window.addEventListener("storage",Sc))}function Jae(){!Sc||typeof window>"u"||(window.removeEventListener("storage",Sc),Sc=null)}function eie(e){return Mi.add(e),Mi.size===1&&(to(t=>({...t,mute:yD()})),bD(),Zae(),Qae(),Xae()),()=>{Mi.delete(e),Mi.size===0&&(Gae(),Yae(),Jae())}}function gM(){return rp}function wD(){return m.useSyncExternalStore(eie,gM,gM)}function tie(){to(e=>e.promotedId?{...e,dismissedId:e.promotedId,promotedId:null}:e)}function jD(e){if(!e.promotedId||e.dismissedId&&e.dismissedId===e.promotedId)return null;const t=e.history.find(n=>n.id===e.promotedId);return!t||e.now-t.ts>Bae||!Vae(t,e.mute,e.now)?null:t}function nie(e){const t=jD(e);return!t||e.now-t.ts>zae?null:t}function kD(e){return`client:${e}`}function rb(e){const t=kD(e.key);to(n=>{const r=Date.now(),a={id:t,tier:e.tier,text:e.text,ts:r,ruleId:`client.${e.key}`,key:e.key},o=n.history.findIndex(u=>u.id===t);let c;return o>=0?(c=[...n.history],c[o]=a):(c=[...n.history,a],c.length>tl&&(c=c.slice(c.length-tl))),{...n,history:c,latest:a,promotedId:t,dismissedId:n.dismissedId===t?null:n.dismissedId}})}function ab(e){const t=kD(e);to(n=>{const r=n.history.filter(u=>u.id!==t);if(r.length===n.history.length)return n;const a=n.promotedId===t?null:n.promotedId,o=n.dismissedId===t?null:n.dismissedId,c=n.latest?.id===t?r.length>0?r[r.length-1]:null:n.latest;return{...n,history:r,latest:c??null,promotedId:a,dismissedId:o}})}function sie(e){if(typeof window>"u")return;const t=e?{broadcastId:e.id}:{};window.dispatchEvent(new CustomEvent(J0,{detail:t}))}function rie(e){if(typeof window>"u")return()=>{};const t=n=>{const r=n.detail??{};e(r)};return window.addEventListener(J0,t),()=>window.removeEventListener(J0,t)}const aie=5*6e4,iie=15e3;function oie(e){return`s-scoutbot-chip-dot s-scoutbot-chip-dot--${e}`}function lie(e){switch(e){case"listening":return"listening";case"thinking":return"thinking";case"speaking":return"speaking";case"briefing":return"briefing";default:return""}}function cie(e){return e==="thinking"||e==="briefing"}function uie(e){const t=Math.floor(e/6e4);return t<1?"now":`${t}m`}function die(e,t,n){if(e.activity!=="idle")return{kind:"activity",activity:e.activity,label:lie(e.activity)};if(t)return{kind:"broadcast",tier:t.tier,text:t.text,clickTarget:t};if(e.brief.lastDeliveredAt){const r=Math.max(0,n-e.brief.lastDeliveredAt);if(r<=aie)return{kind:"brief-fresh",label:uie(r)}}return{kind:"idle"}}function fie(e,t){const n=t.session.title??null,r=[];switch(e.kind){case"activity":r.push(`Scout · ${e.label}`);break;case"broadcast":r.push(e.text);break;case"brief-fresh":r.push(`Brief delivered ${e.label} ago`);break;default:r.push("Toggle Scout");break}return n&&r.push(n),t.error&&e.kind!=="broadcast"&&r.push(t.error),r.join(`
146
- `)}function ND(){const e=wD(),t=nie(e),{state:n,actions:r}=Vre(),a=Xc(),[o,c]=m.useState(()=>Date.now());m.useEffect(()=>{const v=window.setInterval(()=>c(Date.now()),iie);return()=>window.clearInterval(v)},[]);const u=die(n,t,o),f=fie(u,n),h=(()=>{switch(u.kind){case"activity":return"s-scoutbot-chip--activity";case"broadcast":return"s-scoutbot-chip--active";case"brief-fresh":return"s-scoutbot-chip--fresh";default:return"s-scoutbot-chip--idle"}})(),p=()=>{sie(t??null)},x=v=>{a(v,[{kind:"action",label:"Brief me now",onSelect:()=>r.triggerBrief()},{kind:"action",label:"Ask state",onSelect:()=>r.triggerAskState()},{kind:"action",label:"New chat",onSelect:()=>r.startNewChat()},{kind:"separator"},{kind:"action",label:"Open chat",onSelect:()=>r.focusScoutbot()}])};return s.jsxs("button",{type:"button",className:`s-scoutbot-chip ${h}`,onClick:p,onContextMenu:x,title:f,children:[s.jsx(dg,{size:14,className:"s-scoutbot-chip-icon","aria-hidden":"true"}),u.kind==="activity"&&s.jsxs(s.Fragment,{children:[cie(u.activity)?s.jsx(Kn,{size:10,className:"s-scoutbot-chip-spinner","aria-hidden":"true"}):s.jsx("span",{className:"s-scoutbot-chip-dot s-scoutbot-chip-dot--pulse","aria-hidden":"true"}),s.jsx("span",{className:"s-scoutbot-chip-text",children:u.label})]}),u.kind==="broadcast"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:oie(u.tier),"aria-hidden":"true"}),s.jsx("span",{className:"s-scoutbot-chip-text",children:u.text})]}),u.kind==="brief-fresh"&&s.jsx("span",{className:"s-scoutbot-chip-text",children:u.label})]})}const dm=240,hie=900,mie=.45,pie=500,gie=420,vM=560;function xM(e){return Math.min(hie,Math.max(pie,Math.floor(e*mie)))}function vie({app:e,assistant:t=!0}){return s.jsx(eU,{registry:jP,audience:wP,audienceOrder:tk,storageKey:bP,initialLayers:Sne(),children:s.jsx(e.Provider,{children:s.jsx(ine,{children:s.jsx(bie,{app:e,assistantEnabled:t})})})})}function xie({statusBar:e}){const t=la("surface.scoutbot",!0),n=e.mesh.color==="amber"?"text-amber-400":e.mesh.color==="red"?"text-red-400":"text-foreground";return s.jsxs("div",{className:"flex items-center gap-3 font-mono leading-none",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[9px] font-normal uppercase tracking-[0.16em] text-muted-foreground",children:e.activeAgents.label}),s.jsx("span",{className:"text-[10px] tabular-nums text-foreground",children:e.activeAgents.count})]}),s.jsx("span",{"aria-hidden":"true",className:"select-none text-muted-foreground/40 text-[10px]",children:"·"}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[9px] font-normal uppercase tracking-[0.16em] text-muted-foreground",children:e.mesh.label}),s.jsx("span",{className:`text-[10px] ${n}`,children:e.mesh.value})]}),t&&s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":"true",className:"select-none text-muted-foreground/40 text-[10px]",children:"·"}),s.jsx(ND,{})]})]})}function yie({statusBar:e}){return s.jsx("div",{className:"max-w-[38vw] truncate font-mono text-[10px] leading-none text-muted-foreground",title:e.build.title,children:e.build.label})}function bie({app:e,assistantEnabled:t}){const{navTotalHeight:n}=Qj(),r=Dae();$ae();const a=e.hooks.useCommands(),o=e.hooks.useSearch?.()??null,c=e.hooks.useNavCenter?.()??null,u=e.hooks.useNavActions?.()??null,f=e.hooks.useLayoutMode?.()??e.mode,h=f==="focus"?"panel":f,p=e.hooks.useActiveToolHint?.()??null,x=e.hooks.useTakeover?.()??null,v=x?.active===!0,y=v&&x?.dismissible===!0,b=x?.onDismiss,C=e.slots.Takeover,E=dD(),A=one(),[S,k]=Lr(`appshell.${e.id}.left`,!1),[N,T]=Lr(`appshell.${e.id}.right`,!1),[R,O]=Lr(`appshell.${e.id}.rightOverlay`,!1),[L,I]=Lr(`appshell.${e.id}.leftW`,260),[z,_]=Lr(`appshell.${e.id}.rightW`,280),[U,D]=Lr("openscout.ops.minimap.collapsed",!1),[q,Z]=m.useState(()=>typeof window<"u"?window.innerWidth:1280),[$,G]=m.useState(()=>xM(typeof window<"u"?window.innerWidth:1280)),V=typeof window<"u"&&window.location.pathname==="/search";m.useEffect(()=>{const re=()=>{Z(window.innerWidth),G(xM(window.innerWidth))};return re(),window.addEventListener("resize",re),()=>window.removeEventListener("resize",re)},[]),m.useEffect(()=>{I(re=>Math.min($,Math.max(dm,re))),_(re=>Math.min($,Math.max(dm,re)))},[$,I,_]),m.useEffect(()=>{!V||N||R||_(re=>Math.max(re,Math.min($,gie)))},[V,N,R,_,$]);const[Y,K]=m.useState({x:0,y:0}),[P,H]=m.useState(1),B=m.useCallback(re=>{K(Re=>({x:Re.x+re.x,y:Re.y+re.y}))},[]),Q=m.useCallback(re=>{H(re)},[]),[oe,ne]=m.useState(!1),[X,ae]=m.useState(!1),[be,_e]=Lr(`appshell.${e.id}.termH`,320),xe=!!e.slots.Terminal,pe=m.useMemo(()=>{const re=[];return xe&&re.push("terminal"),t&&re.push("assistant"),re},[xe,t]),te=pe[0]??"terminal",[ve,he]=Lr(`appshell.${e.id}.drawerTab`,te),ke=pe.includes(ve)?ve:te,[Ne,Fe]=m.useState(!1),[Ee,Le]=m.useState(!1),[Te,Pe]=m.useState(new Set),De=m.useCallback(re=>{Pe(Re=>{const Ve=new Set(Re);return Ve.has(re)?Ve.delete(re):Ve.add(re),Ve})},[]),ze=m.useCallback(re=>Re=>{Re.preventDefault();const Ve=Re.clientX,Ct=re==="left"?L:z,Ft=re==="left"?I:_,$n=re==="left"?1:-1,tn=Et=>{const Tt=(Et.clientX-Ve)*$n;Ft(Math.max(dm,Math.min($,Ct+Tt)))},Lt=()=>{document.removeEventListener("mousemove",tn),document.removeEventListener("mouseup",Lt)};document.addEventListener("mousemove",tn),document.addEventListener("mouseup",Lt)},[L,z,I,_,$]),$e=m.useMemo(()=>{const re=[{id:"shell:toggle-left",label:"Toggle Left Panel",shortcut:"Cmd+[",action:()=>k(Re=>!Re)},{id:"shell:toggle-right",label:"Toggle Right Panel",shortcut:"Cmd+]",action:()=>T(Re=>!Re)},{id:"shell:toggle-right-overlay",label:"Toggle Inspector Overlay",shortcut:"Cmd+Shift+]",action:()=>O(Re=>!Re)},{id:"shell:toggle-terminal",label:"Toggle Terminal",shortcut:"Ctrl+`",action:()=>ne(Re=>!Re)},{id:"shell:feature-flags",label:"Feature Flags",action:()=>Le(!0)}];return t&&re.push({id:"shell:toggle-assistant",label:"Toggle Assistant",shortcut:"Cmd+J",action:()=>{he("assistant"),ne(Re=>!Re||ve!=="assistant")}}),re},[t,ve,he,k,T,O,Le]),st=m.useMemo(()=>[...a,...$e],[a,$e]);m.useEffect(()=>{const re=Re=>{v||((Re.metaKey||Re.ctrlKey)&&Re.key==="k"&&(Re.preventDefault(),Fe(!0)),(Re.metaKey||Re.ctrlKey)&&Re.key==="["&&(Re.preventDefault(),k(Ve=>!Ve)),(Re.metaKey||Re.ctrlKey)&&Re.key==="]"&&(Re.preventDefault(),Re.shiftKey?O(Ve=>!Ve):T(Ve=>!Ve)),Re.ctrlKey&&Re.key==="`"&&(Re.preventDefault(),ne(Ve=>!Ve)),t&&(Re.metaKey||Re.ctrlKey)&&Re.key==="j"&&(Re.preventDefault(),he("assistant"),ne(Ve=>!(Ve&&ke==="assistant"))))};return window.addEventListener("keydown",re),()=>window.removeEventListener("keydown",re)},[t,ke,he,k,T,O,v]),m.useEffect(()=>{const re=()=>{he("terminal"),ne(!0),_e(Re=>Re>window.innerHeight*.8?420:Re)};return window.addEventListener("scout:open-terminal",re),()=>window.removeEventListener("scout:open-terminal",re)},[he,_e]),m.useEffect(()=>{const re=Re=>{const Ve=Re.detail,Ct=typeof Ve?.width=="number"?Ve.width:420;T(!1),_(Ft=>Math.max(Ft,Math.min($,Math.max(dm,Ct))))};return window.addEventListener("scout:set-inspector-width",re),()=>window.removeEventListener("scout:set-inspector-width",re)},[T,_,$]);const rt=e.slots.Inspector,Xe=e.slots.RightPanel,dt=e.tools&&e.tools.length>0,jt=s.jsxs(s.Fragment,{children:[rt&&s.jsx(rt,{}),!rt&&Xe&&s.jsx(Xe,{}),dt&&s.jsx("div",{className:"border-t border-neutral-700/50",children:e.tools.map(re=>{const Re=Te.has(re.id);return s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>De(re.id),className:`w-full flex items-center gap-2 px-4 py-2.5 text-[11px] font-mono tracking-wider uppercase transition-colors hover:bg-white/5 ${p===re.id?"text-emerald-400":"text-neutral-300"}`,children:[Re?s.jsx(Xo,{size:10}):s.jsx(hg,{size:10}),s.jsx("span",{className:"text-neutral-400",children:re.icon}),s.jsx("span",{className:"font-bold",children:re.name})]}),Re&&s.jsx("div",{className:"px-4 pb-3",children:s.jsx(re.Component,{})})]},re.id)})})]}),At=s.jsx(Jte,{onOpenCommandPalette:()=>Fe(!0)}),mt=m.useMemo(()=>({isCollapsed:U,onToggleCollapse:()=>D(re=>!re)}),[U,D]),Ht=A?s.jsx("div",{className:`scout-canvas-minimap-shell${U?" scout-canvas-minimap-shell--collapsed":""}`,children:A.render(mt)}):null,ie=A?s.jsx("div",{className:`scout-canvas-minimap-shell scout-canvas-minimap-shell--floating${U?" scout-canvas-minimap-shell--collapsed":""}`,children:A.render(mt)}):null,ce=m.useRef(null),Ae=m.useRef(null);m.useEffect(()=>{const re=ce.current;re&&(v?re.setAttribute("inert",""):re.removeAttribute("inert"))},[v]),m.useEffect(()=>{if(!v)return;const re=Ae.current;if(re&&(re.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")??re).focus(),!y)return;const Re=Ve=>{Ve.key==="Escape"&&(Ve.preventDefault(),b?.())};return window.addEventListener("keydown",Re),()=>window.removeEventListener("keydown",Re)},[v,y,b]);const Be=S?0:L,tt=N||R?0:z,at=q-Be-tt,Oe=f==="panel"&&at<vM&&(Be>0||tt>0),He=Oe&&tt>0,nt=Oe&&Be>0&&q-Be<vM,$t=R||He,Tn=nt?0:Be,fn=$t?0:tt,Gt=f==="panel"?{position:"absolute",top:n,bottom:28,left:Tn,right:fn,overflow:"auto",transition:"left 200ms ease, right 200ms ease"}:{},Rt={display:"contents","--scout-shell-left-inset":`${f==="panel"?Tn:0}px`,"--scout-shell-right-inset":`${f==="panel"?fn:0}px`},Gn=R?"Pin inspector (push content)":He?"Keep inspector floating when there is room":"Float inspector (overlay content)",On=m.useCallback(re=>({backgroundColor:"rgba(13, 14, 16, 0.72)",backdropFilter:"blur(24px) saturate(140%)",WebkitBackdropFilter:"blur(24px) saturate(140%)",boxShadow:re==="left"?"18px 0 48px -12px rgba(0,0,0,0.7), inset -1px 0 0 0 rgba(255,255,255,0.06)":"-18px 0 48px -12px rgba(0,0,0,0.7), inset 1px 0 0 0 rgba(255,255,255,0.06)"}),[]);return s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:ce,"aria-hidden":v?!0:void 0,style:Rt,children:s.jsx(Vte,{mode:h,panOffset:Y,scale:P,onPan:B,onZoom:Q,hud:s.jsxs(s.Fragment,{children:[s.jsx(qte,{title:e.name.toUpperCase(),search:o??void 0,center:c,actions:u}),s.jsx(GT,{side:"left",title:e.leftPanel?.title??"Navigation",icon:e.leftPanel?.icon,isCollapsed:S,onToggleCollapse:()=>k(!S),width:L,onResizeStart:ze("left"),style:nt?On("left"):void 0,footer:S?void 0:Ht,headerActions:e.leftPanel?.headerActions&&s.jsx(e.leftPanel.headerActions,{}),children:s.jsx("div",{"data-pane":"left",style:{display:"contents"},children:e.slots.LeftPanel&&s.jsx(e.slots.LeftPanel,{})})}),S?ie:null,s.jsx(GT,{side:"right",title:e.rightPanel?.title??"Inspector",icon:e.rightPanel?.icon,isCollapsed:N,onToggleCollapse:()=>T(!N),width:z,onResizeStart:ze("right"),style:$t?On("right"):void 0,footer:At,headerActions:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:()=>O(re=>He&&!re?!0:!re),title:Gn,"aria-label":Gn,className:"p-1 hover:bg-accent/10 rounded transition-colors text-muted-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",children:$t?s.jsx(DB,{size:12}):s.jsx(BB,{size:12})}),e.rightPanel?.headerActions&&s.jsx(e.rightPanel.headerActions,{})]}),children:s.jsx("div",{"data-pane":"right",style:{display:"contents"},children:jt})}),s.jsx(Xte,{status:E.status,left:s.jsx(xie,{statusBar:E}),right:s.jsx(yie,{statusBar:E}),onToggleTerminal:()=>ne(re=>!re),isTerminalOpen:oe}),s.jsx("div",{className:"pointer-events-none",style:{position:"fixed",left:Tn,right:fn,bottom:0,top:0,zIndex:45,transition:"left 200ms ease, right 200ms ease",transform:"translateZ(0)"},children:s.jsxs(nne,{isOpen:oe,onClose:()=>ne(!1),onToggleMaximize:()=>ae(re=>!re),isMaximized:X,height:Math.min(be,window.innerHeight*.8),onHeightChange:re=>_e(Math.min(re,window.innerHeight*.8)),title:s.jsx(wie,{tabs:pe,active:ke,onSelect:he}),children:[oe&&ke==="terminal"&&(e.slots.Terminal?s.jsx(e.slots.Terminal,{}):s.jsx("div",{className:"p-4 font-mono text-[12px] text-neutral-400",children:"No terminal content"})),oe&&ke==="assistant"&&s.jsx(Qq,{app:e,commands:a})]})}),s.jsx(ane,{isOpen:Ne,onClose:()=>Fe(!1),commands:st})]}),children:s.jsx("div",{style:Gt,className:"frame-scrollbar","data-pane":"center",children:s.jsx(e.slots.Content,{})})})}),v&&C?s.jsx("div",{ref:Ae,tabIndex:-1,role:"dialog","aria-modal":"true",style:{position:"fixed",inset:0,zIndex:80,outline:"none"},children:s.jsx(C,{})}):null,s.jsx(Pae,{open:r.open,onClose:()=>r.setOpen(!1)}),s.jsx(nU,{isOpen:Ee,onClose:()=>Le(!1),audienceOptions:tk})]})}function wie({tabs:e,active:t,onSelect:n}){return e.length===0?null:s.jsx("div",{className:"flex items-center gap-0.5",children:e.map(r=>{const a=r===t,o=r==="terminal"?Zw:Gw,c=r==="terminal"?"TERMINAL":"ASSISTANT",u=r==="terminal"?"text-emerald-400":"text-cyan-400";return s.jsxs("button",{type:"button",onClick:()=>n(r),className:`flex items-center gap-1.5 px-2.5 py-1 rounded text-xs font-bold tracking-widest font-mono transition-colors ${a?`${u} bg-white/[0.04]`:"text-neutral-500 hover:text-neutral-300"}`,children:[s.jsx(o,{size:13}),s.jsx("span",{children:c})]},r)})})}async function Nn(e){if(navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),!0}catch{}const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.left="-9999px",document.body.appendChild(t),t.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(t)}}const yM=["#6366f1","#8b5cf6","#0ea5e9","#14b8a6","#f59e0b","#ef4444","#ec4899","#10b981"];function Xt(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return yM[Math.abs(t)%yM.length]}function yn(e){switch(Ge(e)){case"working":return"var(--green)";case"ready":return"var(--accent)";case"not_ready":return"var(--dim)"}}function ib(e,t){const n=t?.trim();n&&e.add(n)}function jie(e,t){const n=new Set;return ib(n,e.authorityNodeId),ib(n,e.homeNodeId),n.size===0&&ib(n,t),n}function SD(e,t,n){return t?jie(e,n).has(t):!0}function no(e,t,n){return t?e.filter(r=>SD(r,t,n)):e}function cl(e,t,n){return t?new Set(e.filter(r=>SD(r,t,n)).map(r=>r.id)):null}function qo(e,t,n){return!t&&!n||n&&e.authorityNodeId===n?!0:t?e.agentId&&t.has(e.agentId)||e.actorId&&t.has(e.actorId)||e.ownerId&&t.has(e.ownerId)||e.nextMoveOwnerId&&t.has(e.nextMoveOwnerId)?!0:!!e.participantIds?.some(r=>t.has(r)):!1}function kie(e,t,n){return qo(e,t,n)}function ck(e,t,n){return!t&&!n?e:e.filter(r=>kie(r,t,n))}function Nie(e,t){return qo(e,t)}function CD(e,t){return t?e.filter(n=>Nie(n,t)):e}function bM(e,t){return qo(e,t)}function ED(e,t){if(!e||!t)return e;const n=e.activeAsks.filter(c=>qo(c,t)),r=e.recentCompleted.filter(c=>qo(c,t)),a=e.needsAttention.filter(c=>qo(c,t)),o=CD(e.activity,t);return{...e,totals:{active:n.length,recentCompleted:r.length,needsAttention:a.length,activity:o.length},activeAsks:n,recentCompleted:r,needsAttention:a,activity:o}}function Sie(e,t){if(!t)return e;const n=e.activeFlights.filter(o=>qo(o,t)),r=e.childWork.filter(o=>bM(o,t));return bM(e,t)||n.length>0||r.length>0?{...e,activeFlights:n,childWork:r}:null}const Cie=1e12;function Eie(e){return Number.isFinite(e)&&e>0}function Aie(e){const t=typeof e=="number"?e:typeof e=="string"?Number(e):null;return t===null||!Eie(t)?null:Math.trunc(t<Cie?t*1e3:t)}const Tie={workspace:"workspace",worktree:"workspace",branch:"workspace",profile:"profile",persona:"profile",harness:"harness",runtime:"harness",model:"model",node:"node",host:"node"};function Mie(e){return e.trim().replace(/^@+/,"").replace(/[.,!?;)\]]+$/,"")}function Pr(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}const Rie="scout";function Iie(e){return Tie[Pr(e)]??null}function AD(e){const t=Pr(e.definitionId),n=e.workspaceQualifier?Pr(e.workspaceQualifier):void 0,r=e.profile?Pr(e.profile):void 0,a=e.harness?Pr(e.harness):void 0,o=e.model?Pr(e.model):void 0,c=e.nodeQualifier?Pr(e.nodeQualifier):void 0;return t?{definitionId:t,...n?{workspaceQualifier:n}:{},...r?{profile:r}:{},...a?{harness:a}:{},...o?{model:o}:{},...c?{nodeQualifier:c}:{}}:null}function TD(e){const t=e.split(".").filter(Boolean),n=t.shift();if(!n)return null;const r={definitionId:n},a=[];for(const o of t){if(o.includes(":")){const[c,u=""]=o.split(":",2),f=Iie(c),h=Pr(u);if(!f||!h)return null;f==="workspace"?r.workspaceQualifier=h:f==="profile"?r.profile=h:f==="harness"?r.harness=h:f==="model"?r.model=h:f==="node"&&(r.nodeQualifier=h);continue}a.push(o)}if(a.length===1){const o=Pr(a[0]);if(!o)return null;r.workspaceQualifier=o}else if(a.length===2){const o=Pr(a[0]),c=Pr(a[1]);if(!o||!c)return null;r.workspaceQualifier||(r.workspaceQualifier=o),r.nodeQualifier||(r.nodeQualifier=c)}else if(a.length>2)return null;return uk(r,{raw:e})}function _ie(e){const t=e.indexOf("#"),n=e.indexOf("?");if(t===-1&&n===-1||e.indexOf("#",t+1)!==-1||e.indexOf("?",n+1)!==-1||t!==-1&&n!==-1&&n<t)return null;const r=Math.min(...[t,n].filter(f=>f>=0)),a=e.slice(0,r);if(!a)return null;const o=TD(a);if(!o)return null;const c=t>=0?e.slice(t+1,n>=0?n:e.length):"",u=n>=0?e.slice(n+1):"";return t>=0&&!c||n>=0&&!u||c.includes("#")||c.includes("?")||u.includes("#")||u.includes("?")||o.harness&&c||o.model&&u?null:uk({definitionId:o.definitionId,nodeQualifier:o.nodeQualifier,workspaceQualifier:o.workspaceQualifier,profile:o.profile,harness:c||o.harness,model:u||o.model},{raw:e})}function Oie(e){const t=Mie(e);return!t||t.includes("@")?null:t.includes("#")||t.includes("?")?_ie(t):TD(t)}function wM(e,t={}){const n=AD(e);if(!n)return t.includeSigil===!1?"":"@";const a=[`${t.includeSigil===!1?"":"@"}${n.definitionId}`];return n.workspaceQualifier&&a.push(n.workspaceQualifier),n.profile&&a.push(`profile:${n.profile}`),n.harness&&a.push(`harness:${n.harness}`),n.model&&a.push(`model:${n.model}`),n.nodeQualifier&&a.push(`node:${n.nodeQualifier}`),a.join(".")}function uk(e,t={}){const n=AD(e);return n?{raw:t.raw??wM(n,{includeSigil:!1}),label:wM(n),definitionId:n.definitionId,...n.nodeQualifier?{nodeQualifier:n.nodeQualifier}:{},...n.workspaceQualifier?{workspaceQualifier:n.workspaceQualifier}:{},...n.profile?{profile:n.profile}:{},...n.harness?{harness:n.harness}:{},...n.model?{model:n.model}:{}}:null}function $ie(e){return Lie(e).parsed}function Lie(e){const t=Array.from(e.matchAll(/(^|[\s([{'"`])@([a-z0-9][a-z0-9._/:-]*(?:#[a-z0-9][a-z0-9._/:-]*)?(?:\?[a-z0-9][a-z0-9._/:-]*)?)(?=$|[\s)\]}",.!?:;'"`])/gi)),n=new Map,r=[];for(const a of t){const o=a[2]??"",c=Oie(o);if(!c){o&&r.push(`@${o}`);continue}n.set(c.label,c)}return{parsed:Array.from(n.values()),unparsed:Array.from(new Set(r))}}function St(e){return Aie(e)}function dk(e,t){return(St(e)??0)-(St(t)??0)}function ul(e,t){return dk(t,e)}function Ie(e,t=Date.now()){const n=St(e);if(n===null)return"";const r=Math.floor((t-n)/1e3);return r<5?"now":r<60?`${r}s`:r<3600?`${Math.floor(r/60)}m`:r<86400?`${Math.floor(r/3600)}h`:`${Math.floor(r/86400)}d`}function kr(e){const t=St(e);return t===null?"":new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"})}function Di(e){const t=St(e);return t===null?"":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(t)}async function Nf(e){if(Pie(e.agentId),!(await fetch(zg("terminalRunPath"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e.command,...e.cwd?{cwd:e.cwd}:{},...e.agentId?{agentId:e.agentId}:{}})})).ok)throw new Error("Failed to queue takeover")}function Pie(e){if(!(typeof window>"u"))try{window.localStorage.removeItem("hudson.relay.scout-takeover"),e&&window.localStorage.removeItem(`hudson.relay.scout-takeover-${e}`)}catch{}}const Die="openscout.navReturn.v1.",qp=new Map;function fk(e){return Die+e}function zie(e){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&typeof t.view=="string")return t}catch{}return null}function MD(e,t){if(qp.set(e,t),!(typeof window>"u"))try{window.sessionStorage.setItem(fk(e),JSON.stringify(t))}catch{}}function Bie(e){const t=qp.get(e);if(t)return t;if(typeof window>"u")return null;try{const n=window.sessionStorage.getItem(fk(e));if(n){const r=zie(n);return r&&qp.set(e,r),r}}catch{}return null}function Uie(e){if(qp.delete(e),!(typeof window>"u"))try{window.sessionStorage.removeItem(fk(e))}catch{}}const Fie={agents:"agents",conversation:"conversation",work:"work",terminal:"terminal",sessions:"sessions","agent-info":"agent-info",channels:"channels"};function Vie(e){return Fie[e.view]??null}function wt(e,t,n={}){if(n.returnTo){const r=Vie(t);r&&MD(r,n.returnTo)}e(t)}function jM(e){return e?e.length>18?`${e.slice(0,8)}...${e.slice(-6)}`:e:null}function Sf({agent:e,catalog:t,navigate:n,returnTo:r,variant:a="default",className:o,onNavigate:c}){const u=qe(),[f,h]=m.useState(null),[p,x]=m.useState(!1),v=n??u.navigate,y=r??u.route;m.useEffect(()=>{x(!1)},[e.id]),m.useEffect(()=>{if(t!==void 0){h(null);return}let q=!1;return ue(`/api/agents/${encodeURIComponent(e.id)}/session-catalog`).then(Z=>{q||h(Z)}).catch(()=>{q||h(null)}),()=>{q=!0}},[e.id,t]);const b=t===void 0?f:t,C=b?.activeSessionId??(e.transport==="tmux"?e.harnessSessionId??null:null),E=m.useMemo(()=>b?.sessions.find(q=>q.id===C)??null,[C,b?.sessions]),A=Ge(e.state),S=e.transport==="tmux"&&!!C,k=S||!!b?.resumeCommand,N=A==="working",T=a==="compact",R=N?C?T?S?"Live terminal":"Live trace":`Live ${jM(C)}`:"Working":C?T?S?"Terminal":"Trace":`${S?"Terminal":"Trace"} ${jM(C)}`:A==="ready"?"Ready":"No live turn",O=E?.startedAt?Ie(E.startedAt):e.updatedAt?Ie(e.updatedAt):null,L=S?T?"Observe":"Observe terminal":T?"Trace":"Observe trace",I=S?"Observe the tmux terminal":"Open the web observe trace",z=q=>{c?.(),wt(v,{view:"terminal",agentId:e.id,mode:q},{returnTo:y})},_=()=>{c?.(),wt(v,{view:"agents",agentId:e.id,tab:"observe"},{returnTo:y})},U=()=>{if(S){z("takeover");return}const q=b?.resumeCommand;q&&(x(!0),Nf({command:q,cwd:b?.resumeCwd,agentId:e.id}).then(()=>z("takeover")))},D=["agent-live-actions",`agent-live-actions--${a}`,N?"agent-live-actions--live":"",o??""].filter(Boolean).join(" ");return s.jsxs("div",{className:D,children:[s.jsxs("div",{className:"agent-live-actions-status",children:[s.jsx("span",{className:"agent-live-actions-dot"}),s.jsx("span",{className:"agent-live-actions-status-main",children:R}),O&&s.jsx("span",{className:"agent-live-actions-status-detail",children:O})]}),s.jsxs("div",{className:"agent-live-actions-buttons",children:[s.jsxs("button",{type:"button",className:"agent-live-actions-button agent-live-actions-button--primary",onClick:()=>S?z("observe"):_(),title:I,"aria-label":I,children:[s.jsx(Y6,{size:13,strokeWidth:1.9,"aria-hidden":"true"}),s.jsx("span",{children:L})]}),S&&s.jsx("button",{type:"button",className:"agent-live-actions-button",onClick:_,title:"Open the web observe trace",children:s.jsx("span",{children:"Trace"})}),k&&s.jsxs("button",{type:"button",className:"agent-live-actions-button",onClick:U,title:b?.resumeCommand??"Open interactive terminal takeover",children:[s.jsx(Zw,{size:13,strokeWidth:1.9,"aria-hidden":"true"}),s.jsx("span",{children:p?"Going...":"Takeover"})]})]})]})}function kM(e){return e?e.replace(/^\/Users\/[^/]+/,"~"):null}const RD=m.forwardRef(function({agent:t,pinned:n,onOpen:r,onClose:a,onAction:o,style:c,className:u},f){const h=Ge(t.state),p=ll(t.state),x=kM(t.cwd)??kM(t.projectRoot),v=t.handle??t.name,y=t.authorityNodeName??t.homeNodeName??t.authorityNodeId??t.homeNodeId,b=cs(h);return s.jsxs("div",{ref:f,className:`agent-card${n?" agent-card--pinned":""}${u?` ${u}`:""}`,style:c,role:"dialog","aria-label":`${v} details`,children:[s.jsxs("header",{className:"agent-card-head",children:[s.jsx("div",{className:"agent-card-name",children:v}),s.jsxs("div",{className:"agent-card-meta",children:[s.jsx("span",{className:`agent-card-dot agent-card-dot--${p}`,style:h==="working"?{background:yn(t.state)}:void 0}),s.jsx("span",{className:`agent-card-state agent-card-state--${p}`,children:b}),t.updatedAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"agent-card-sep",children:"·"}),s.jsx("span",{className:"agent-card-time",children:Ie(t.updatedAt)})]})]})]}),s.jsxs("div",{className:"agent-card-body",children:[x&&s.jsx(Co,{label:"cwd",children:s.jsx("code",{className:"agent-card-mono",children:x})}),y&&s.jsx(Co,{label:"machine",children:s.jsx("span",{className:"agent-card-mono",children:y})}),(t.project||t.branch)&&s.jsx(Co,{label:"project",children:s.jsxs("span",{className:"agent-card-mono",children:[t.project??"—",t.branch&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"agent-card-sep agent-card-sep--inline",children:"·"}),s.jsx("span",{className:"agent-card-branch",children:t.branch})]})]})}),(t.harness||t.model)&&s.jsx(Co,{label:"harness",children:s.jsxs("span",{className:"agent-card-mono",children:[t.harness??"—",t.model&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"agent-card-sep agent-card-sep--inline",children:"·"}),s.jsx("span",{className:"agent-card-model",children:t.model})]})]})}),t.transport&&s.jsx(Co,{label:"transport",children:s.jsx("span",{className:"agent-card-mono",children:t.transport})}),t.role&&s.jsx(Co,{label:"role",children:s.jsx("span",{className:"agent-card-mono",children:t.role})}),t.capabilities&&t.capabilities.length>0&&s.jsx(Co,{label:"capabilities",children:s.jsxs("div",{className:"agent-card-caps",children:[t.capabilities.slice(0,8).map(C=>s.jsx("span",{className:"agent-card-cap",children:C},C)),t.capabilities.length>8&&s.jsxs("span",{className:"agent-card-cap agent-card-cap--more",children:["+",t.capabilities.length-8]})]})})]}),s.jsx(Sf,{agent:t,variant:"compact",onNavigate:o}),s.jsxs("footer",{className:"agent-card-foot",children:[s.jsxs("button",{type:"button",className:"agent-card-link",onClick:r,children:["Open agent ",s.jsx("span",{"aria-hidden":!0,children:"→"})]}),n&&s.jsx("button",{type:"button",className:"agent-card-close",onClick:a,"aria-label":"Close",children:"esc"})]})]})});function Co({label:e,children:t}){return s.jsxs("div",{className:"agent-card-field",children:[s.jsx("span",{className:"agent-card-label",children:e}),s.jsx("div",{className:"agent-card-value",children:t})]})}const Hie=280,Wie=120,ew=320,fm=8,hm=new Map,qie=1e4;function ds(e){const t=e?.trim().replace(/^@+/,"").toLowerCase();return t&&t.length>0?t:null}function ID(e){const t=new Set,n=r=>{const a=ds(r);a&&t.add(a)};return n(e.id),n(e.handle),n(e.name),n(e.selector),n(e.defaultSelector),n(e.definitionId),e.definitionId&&e.workspaceQualifier&&n(`${e.definitionId}.${e.workspaceQualifier}`),e.definitionId&&e.workspaceQualifier&&e.nodeQualifier&&(n(`${e.definitionId}.${e.workspaceQualifier}.${e.nodeQualifier}`),n(`${e.definitionId}.${e.workspaceQualifier}.node:${e.nodeQualifier}`)),e.definitionId&&e.nodeQualifier&&n(`${e.definitionId}.node:${e.nodeQualifier}`),t}function Kie(e,t){const n=ds(t.label),r=ds(t.raw),a=ID(e);return n&&a.has(n)||r&&a.has(r)?!0:t.definitionId&&ds(e.definitionId)!==ds(t.definitionId)||t.workspaceQualifier&&ds(e.workspaceQualifier)!==ds(t.workspaceQualifier)||t.nodeQualifier&&ds(e.nodeQualifier)!==ds(t.nodeQualifier)||t.harness&&ds(e.harness)!==ds(t.harness)||t.model&&ds(e.model)!==ds(t.model)?!1:!!t.definitionId}function NM(e,t){const n=ds(t.label),r=ds(t.raw),a=ID(e),o=n&&a.has(n)||r&&a.has(r)?1e3:0,c=[t.workspaceQualifier,t.nodeQualifier,t.harness,t.model,t.profile].filter(Boolean).length*100,u=Ge(e.state),f=u==="working"?30:u==="ready"?20:0;return o+c+f+Math.min(e.updatedAt??0,9999999999)/1e9}function Gie(e){const t=ds(e.raw);return t&&t.split(".").length>=3?t:null}function _D(e,t){const n=t.filter(r=>Kie(r,e)).sort((r,a)=>NM(a,e)-NM(r,e));return n[0]?n[0]:null}async function Zie(e,t){const n=_D(e,t),r=n?.id??Gie(e),a=r??e.label,o=hm.get(a);if(o&&Date.now()-o.fetchedAt<qie)return o.agent;if(!r)return hm.set(a,{agent:n,fetchedAt:Date.now()}),n;try{const c=await ue(`/api/agents/${encodeURIComponent(r)}`);return hm.set(a,{agent:c,fetchedAt:Date.now()}),c}catch{return hm.set(a,{agent:n,fetchedAt:Date.now()}),n}}function SM(e){const t=window.innerWidth,n=window.innerHeight,r=Math.max(fm,Math.min(t-ew-fm,e.left+e.width/2-ew/2)),a=e.top-fm;return a>200||e.bottom>n-200?{top:a,left:r,placement:"above"}:{top:e.bottom+fm,left:r,placement:"below"}}function Yie(e){let t=e;for(;t;){if(t instanceof HTMLElement&&t.dataset.scoutTheme)return t;t=t.parentElement??null}return document.body}function Xie({identity:e,agent:t,triggerEl:n,onRequestClose:r}){const{agents:a,navigate:o}=qe(),[c,u]=m.useState(()=>t??_D(e,a)),[f,h]=m.useState(!t),[p,x]=m.useState(()=>SM(n.getBoundingClientRect())),v=m.useRef(null),y=Yie(n);m.useEffect(()=>{if(t){u(t),h(!1);return}let S=!1;return h(!0),Zie(e,a).then(k=>{S||(u(k),h(!1))}),()=>{S=!0}},[e,a,t]),m.useEffect(()=>{const S=()=>{x(SM(n.getBoundingClientRect()))};return window.addEventListener("scroll",S,!0),window.addEventListener("resize",S),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S)}},[n]),m.useEffect(()=>{const S=k=>{k.key==="Escape"&&r()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[r]);const b=m.useCallback(()=>{c&&(o({view:"agents",agentId:c.id}),r())},[c,o,r]),C=p.placement==="above"?"bottom center":"top center",E=p.placement==="above"?"translateY(-100%)":"",A={position:"fixed",top:p.top,left:p.left,width:ew,transform:E,transformOrigin:C};return c?da.createPortal(s.jsx("div",{onMouseEnter:()=>{},onMouseLeave:r,children:s.jsx(RD,{ref:v,agent:c,pinned:!0,onOpen:b,onClose:r,onAction:r,style:A,className:"agent-card--mention"})}),y):da.createPortal(s.jsx("div",{ref:v,className:"agent-card agent-card--pinned agent-card--mention",role:"dialog","aria-label":`${e.label} snapshot`,style:A,onMouseEnter:()=>{},onMouseLeave:r,children:s.jsx("div",{style:{fontSize:"12px",color:"var(--dim)",padding:"4px 2px"},children:f?"loading…":s.jsxs(s.Fragment,{children:["No agent registered as ",s.jsx("code",{children:e.label}),"."]})})}),y)}function Qie(e){return uk({definitionId:e.definitionId,workspaceQualifier:e.workspaceQualifier??void 0,nodeQualifier:e.nodeQualifier??void 0,harness:e.harness??void 0,model:e.model??void 0})}function hk(e){const{agent:t,identity:n}=e,[r,a]=m.useState(!1),[o,c]=m.useState(!1),u=m.useRef(null),f=m.useRef(null),h=m.useRef(null),p=m.useCallback(()=>{f.current!==null&&(window.clearTimeout(f.current),f.current=null),h.current!==null&&(window.clearTimeout(h.current),h.current=null)},[]),x=m.useCallback(()=>{r||(p(),f.current=window.setTimeout(()=>a(!0),Hie))},[r,p]),v=m.useCallback(()=>{o||(p(),h.current=window.setTimeout(()=>a(!1),Wie))},[o,p]),y=m.useCallback(()=>{p(),a(!1),c(!1)},[p]);m.useEffect(()=>()=>p(),[p]);const b=m.useMemo(()=>n??(t?Qie(t):null),[n,t]),C=!!b,E=m.useCallback(N=>{if(N.preventDefault(),N.stopPropagation(),r&&o){y();return}p(),c(!0),a(!0)},[r,o,y,p]),A=m.useCallback(N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),c(!0),a(!0))},[]),S=C?{ref:u,onMouseEnter:x,onMouseLeave:v,onFocus:x,onBlur:v,onClick:E,onKeyDown:A,"data-hover-open":r?"true":void 0,"aria-haspopup":"dialog","aria-expanded":r}:{ref:u},k=r&&u.current&&b?s.jsx(Xie,{identity:b,agent:t??null,triggerEl:u.current,onRequestClose:()=>{o?y():v()}}):null;return{triggerProps:S,popover:k,open:r,pinned:o}}function Jie({identity:e,color:t}){const{triggerProps:n,popover:r}=hk({identity:e});return s.jsxs(s.Fragment,{children:[s.jsx("span",{...n,className:"s-mention",role:"button",tabIndex:0,style:{"--mention-color":t},children:e.label}),r]})}const eoe=["ts","tsx","js","jsx","mjs","cjs","md","mdx","txt","log","json","jsonc","yaml","yml","toml","css","scss","html","htm","sh","py","rb","go","rs","swift","kt","java","c","cpp","h","png","jpg","jpeg","gif","svg","webp","avif","env","conf","ini","gitignore","sql","xml"],toe=eoe.join("|"),CM=new RegExp(`\\.(?:${toe})(?:$|[?#])`,"i"),noe=/^(?:\/Users\/|\/home\/|\/Volumes\/|\/var\/|\/etc\/|\/opt\/|\/tmp\/|\/private\/|\/mnt\/|\/Applications\/|\/usr\/|\/Library\/)/u,soe=/(?:^|[\s(\[`'"])((?:~\/|\.\/|\.\.\/|\/)[A-Za-z0-9._/\-]+|[A-Za-z0-9._\-]+(?:\/[A-Za-z0-9._\-]+)+)/g;function roe(e){return e.startsWith("~/")||e.startsWith("./")||e.startsWith("../")?!0:e.startsWith("/")&&noe.test(e)||CM.test(e)}function EM(e){const t=[],n=new RegExp(soe.source,"g");let r;for(;(r=n.exec(e))!==null;){const a=r[1];if(!a)continue;const o=a.replace(/[.,;:!?]+$/u,"");if(!o||!roe(o))continue;const c=r[0].lastIndexOf(a);if(c<0)continue;const u=r.index+c;t.push({start:u,end:u+o.length,path:o})}return t}function aoe(e){return/\.(png|jpe?g|gif|svg|webp|avif)(?:$|[?#])/iu.test(e)}function ioe(e){return e.endsWith("/")?!0:!(e.split("/").pop()??"").includes(".")&&!e.startsWith("./")&&!e.startsWith("../")}function ooe({kind:e}){return e==="dir"?s.jsx("svg",{className:"s-path-token-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:s.jsx("path",{d:"M2 5a1 1 0 0 1 1-1h3.5l1.5 1.5h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1Z"})}):e==="image"?s.jsxs("svg",{className:"s-path-token-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),s.jsx("circle",{cx:"6",cy:"7",r:"1"}),s.jsx("path",{d:"m3 12 3.5-3 2.5 2 3-2.5L14 11"})]}):s.jsxs("svg",{className:"s-path-token-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M4 2h5l3 3v9a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1Z"}),s.jsx("path",{d:"M9 2v3h3"})]})}function AM({path:e}){const{openFilePreview:t}=qe(),n=aoe(e)?"image":ioe(e)?"dir":"file";return s.jsxs("button",{type:"button",className:"s-path-token",onClick:r=>{r.preventDefault(),r.stopPropagation(),t(e)},title:`Open ${e}`,children:[s.jsx(ooe,{kind:n}),e]})}function loe(e,t){if(t.length===0)return[{kind:"text",value:e}];const n=new Map;for(const c of t)n.set(c.label.toLowerCase(),c);const r=[];let a=e;const o=/@([a-z0-9][a-z0-9._/:-]*)/i;for(;a.length>0;){const c=o.exec(a);if(!c||c.index===void 0){r.push({kind:"text",value:a});break}c.index>0&&r.push({kind:"text",value:a.slice(0,c.index)});const u=c[0],f=u.toLowerCase(),h=n.get(f);h?r.push({kind:"mention",identity:h}):r.push({kind:"text",value:u}),a=a.slice(c.index+u.length)}return r}function coe(e,t){const n=[],r=/`([^`\n]+)`|\*\*(.+?)\*\*|\*([^*\s][^*]*?)\*|\[([^\]\n]+)\]\(([^)\s]+)\)|(https?:\/\/[^\s<>"')\]]+)/g;let a=0,o,c=0;const u=f=>{if(!f)return;const h=EM(f);if(h.length===0){n.push(s.jsx("span",{children:f},`${t}-${c++}`));return}let p=0;for(const x of h)x.start>p&&n.push(s.jsx("span",{children:f.slice(p,x.start)},`${t}-${c++}`)),n.push(s.jsx(AM,{path:x.path},`${t}-${c++}`)),p=x.end;p<f.length&&n.push(s.jsx("span",{children:f.slice(p)},`${t}-${c++}`))};for(;(o=r.exec(e))!==null;){if(o.index>a&&u(e.slice(a,o.index)),o[1]!==void 0){const f=o[1],h=EM(` ${f}`);h.length===1&&h[0].path===f?n.push(s.jsx(AM,{path:f},`${t}-${c++}`)):n.push(s.jsx("code",{className:"s-inline-code",children:f},`${t}-${c++}`))}else if(o[2]!==void 0)n.push(s.jsx("strong",{children:o[2]},`${t}-${c++}`));else if(o[3]!==void 0)n.push(s.jsx("em",{children:o[3]},`${t}-${c++}`));else if(o[4]!==void 0&&o[5]!==void 0&&TM(o[5]))n.push(s.jsx("a",{className:"s-inline-link",href:o[5],target:"_blank",rel:"noreferrer",children:o[4]},`${t}-${c++}`));else if(o[6]!==void 0&&TM(o[6])){const f=o[6].replace(/[.,;:!?]+$/u,""),h=o[6].slice(f.length);n.push(s.jsx("a",{className:"s-inline-link",href:f,target:"_blank",rel:"noreferrer",children:f},`${t}-${c++}`)),h&&n.push(s.jsx("span",{children:h},`${t}-${c++}`))}else n.push(s.jsx("span",{children:o[0]},`${t}-${c++}`));a=o.index+o[0].length}return a<e.length&&u(e.slice(a)),n.length>0?n:[s.jsx("span",{children:e},t)]}function TM(e){return/^(?:https?:\/\/|mailto:|\/|#)/iu.test(e)}function yr(e){if(!e)return e??"";const t=$ie(e);return loe(e,t).flatMap((r,a)=>{if(r.kind==="text")return coe(r.value,a*100);const{identity:o}=r,u=o.definitionId===Rie?"var(--accent)":Xt(o.definitionId);return s.jsx(Jie,{identity:o,color:u},a)})}function hs({title:e,body:t,icon:n,action:r,className:a}){const o=a?`sys-panel sys-state-card ${a}`:"sys-panel sys-state-card";return s.jsxs("div",{className:o,children:[n,s.jsx("h3",{className:"sys-state-title",children:e}),t!=null&&(typeof t=="string"?s.jsx("p",{className:"sys-state-body",children:t}):t),r&&s.jsx("div",{className:"sys-inline-actions",children:r})]})}const uoe={"agent.registered":"registered","agent.online":"came online","agent.offline":"went offline","flight.started":"started task","flight.completed":"completed task","flight.updated":"updated task","message.sent":"sent message","message.received":"received message","collaboration.ask":"asked a question","collaboration.answer":"answered",ask_sent:"asked",ask_replied:"replied",ask_working:"working",flight_created:"started task",flight_updated:"updated task",message_sent:"sent",message_received:"received"},doe={presence:{label:"Presence",tone:"notice"},work:{label:"Execution",tone:"working"},message:{label:"Delivery",tone:"completed"},collaboration:{label:"Coordination",tone:"working"},system:{label:"System",tone:"notice"}};function OD(e){return uoe[e]??e.replace(/[._]/g," ")}function foe(e){return e.startsWith("agent.")||e.includes("registered")||e.includes("online")||e.includes("offline")?"presence":e.startsWith("flight")||e.startsWith("ask_")?"work":e.startsWith("message")?"message":e.startsWith("collaboration")?"collaboration":"system"}function hoe(e){return(e??"system").charAt(0).toUpperCase()}function Oo(e){return e.length<=14?e:`${e.slice(0,8)}...${e.slice(-4)}`}function moe(e){if(!e)return null;const t=e.split("/").filter(Boolean);return t[t.length-1]??e}function poe(e){return`${e.actorName??"system"} ${OD(e.kind)}`}function goe(e){return e.workspaceRoot?`Recorded from ${e.workspaceRoot}.`:e.conversationId?`Linked to thread ${Oo(e.conversationId)}.`:"No additional detail was captured for this event."}function voe({navigate:e}){const{agents:t,route:n}=qe(),[r,a]=m.useState([]),[o,c]=m.useState(null),[u,f]=m.useState(!0),[h,p]=m.useState(!1),[x,v]=m.useState(null),[y,b]=m.useState(null),C=m.useRef([]),E=m.useRef(0),A=m.useRef(null),S=Xc(),k=zs(n),N=m.useMemo(()=>cl(t,k),[t,k]),T=m.useMemo(()=>CD(r,N),[r,N]);m.useEffect(()=>{C.current=r},[r]),m.useEffect(()=>{o&&!T.some(_=>_.id===o)&&c(null)},[o,T]);const R=m.useCallback(async(_="initial")=>{const U=++E.current;!(C.current.length>0)&&_!=="background"?(f(!0),v(null)):p(!0);try{const q=await ue("/api/activity");if(U!==E.current)return;a(q),v(null),b(Date.now()),c(Z=>q.some($=>$.id===Z)?Z:null)}catch(q){if(U!==E.current)return;v(q instanceof Error?q.message:String(q))}finally{U===E.current&&(f(!1),p(!1))}},[]),O=m.useCallback(()=>{A.current||(A.current=setTimeout(()=>{A.current=null,R("background")},250))},[R]);m.useEffect(()=>(R("initial"),()=>{A.current&&clearTimeout(A.current)}),[R]),Vt(O);const L=m.useMemo(()=>{const _=new Set(T.map(D=>D.actorName??"system")),U=new Set(T.map(D=>D.conversationId).filter(D=>!!D));return[{label:"Events",value:`${T.length}`,detail:T.length>0?`Latest ${Ie(T[0].ts)}`:"Waiting for records"},{label:"Actors",value:`${_.size}`,detail:_.size>0?"Distinct event owners":"No actors yet"},{label:"Threads",value:`${U.size}`,detail:U.size>0?"Conversation-linked records":"No linked threads"}]},[T]),I=!u&&T.length===0&&!!x,z=!u&&T.length===0&&!x;return s.jsxs("div",{className:"sys-surface-page",children:[s.jsxs("div",{className:"sys-page-head",children:[s.jsxs("div",{className:"sys-page-title-group",children:[s.jsx("h2",{className:"sys-page-title",children:"Activity"}),s.jsx("p",{className:"sys-page-subtitle",children:"Broker events, task execution, and collaboration handoffs."})]}),s.jsxs("div",{className:"sys-page-actions",children:[s.jsx("div",{className:"sys-sync-note",children:u?"Loading audit ledger...":x&&T.length>0?`Showing last confirmed snapshot from ${y?Ie(y):"earlier"}`:y?`Updated ${Ie(y)}`:"Waiting for first snapshot"}),s.jsx("button",{type:"button",className:"s-btn",disabled:u||h,onClick:()=>{R("manual")},children:h?"Refreshing...":"Refresh"})]})]}),s.jsx("div",{className:"sys-stat-grid",children:L.map(_=>s.jsxs("div",{className:"sys-stat-card",children:[s.jsx("span",{className:"sys-stat-label",children:_.label}),s.jsx("strong",{className:"sys-stat-value",children:_.value}),s.jsx("span",{className:"sys-stat-detail",children:_.detail})]},_.label))}),x&&T.length>0&&s.jsxs("div",{className:"sys-banner sys-banner-warning",children:[s.jsx("strong",{children:"Refresh failed."}),s.jsx("span",{children:x})]}),u&&T.length===0&&s.jsx(hs,{title:"Loading activity",body:"Pulling the latest records from the broker database."}),I&&s.jsx(hs,{className:"sys-state-card-error",title:"Activity is unavailable",body:x,action:s.jsx("button",{type:"button",className:"s-btn",onClick:()=>{R("manual")},children:"Try again"})}),z&&s.jsx(hs,{title:"No activity yet",body:"Events appear here after agents register, send messages, or advance work."}),T.length>0&&s.jsx("div",{className:"sys-audit-list",children:T.map(_=>{const U=o===_.id,D=foe(_.kind),q=doe[D],Z=moe(_.workspaceRoot),$=_.summary&&_.summary!==_.title?_.summary:goe(_),G=[];if(_.conversationId&&G.push({key:"thread",label:"Thread",title:`Open thread ${Oo(_.conversationId)}`,route:{view:"conversation",conversationId:_.conversationId}}),_.recordId&&G.push({key:"work",label:"Work",title:"Open work item",route:{view:"work",workId:_.recordId}}),_.agentId){const Y=_.agentName??"Agent";G.push({key:"agent",label:Y,title:`Open agent ${Y}`,route:{view:"agents",agentId:_.agentId}})}_.sessionId&&G.push({key:"session",label:"Session",title:"Open session",route:{view:"sessions",sessionId:_.sessionId}}),(_.flightId||_.invocationId)&&G.push({key:"follow",label:"Follow",title:"Follow live execution",route:{view:"follow",..._.flightId?{flightId:_.flightId}:{},..._.invocationId?{invocationId:_.invocationId}:{},..._.conversationId?{conversationId:_.conversationId}:{}}});const V=()=>c(U?null:_.id);return s.jsxs("article",{className:`sys-audit-entry${U?" sys-audit-entry-expanded":""}`,onContextMenu:Y=>{const K=window.getSelection()?.toString().trim(),P=[];K&&(P.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>{Nn(K)}}),P.push({kind:"separator"}));const H=_.title??_.summary??"";if(H&&P.push({kind:"action",label:"Copy Details",onSelect:()=>{Nn(H)}}),_.actorName&&P.push({kind:"action",label:"Copy Actor",onSelect:()=>{Nn(_.actorName)}}),P.push({kind:"action",label:"Copy Event ID",onSelect:()=>{Nn(_.id)}}),G.length>0){P.push({kind:"separator"});for(const B of G)P.push({kind:"action",label:`Open ${B.label}`,onSelect:()=>e(B.route)})}S(Y,P)},children:[s.jsxs("div",{className:"sys-audit-toggle",role:"button",tabIndex:0,"aria-expanded":U,onClick:V,onKeyDown:Y=>{(Y.key==="Enter"||Y.key===" ")&&(Y.preventDefault(),V())},children:[s.jsxs("div",{className:"sys-audit-stamp",children:[s.jsx("span",{className:"sys-audit-time",children:Ie(_.ts)}),s.jsx("span",{className:"sys-audit-date",children:kr(_.ts)})]}),s.jsx("div",{className:`sys-audit-marker sys-audit-marker-${q.tone}`,children:s.jsx("span",{})}),s.jsxs("div",{className:"sys-audit-body",children:[s.jsxs("div",{className:"sys-audit-topline",children:[s.jsx("span",{className:"sys-audit-category",children:q.label}),s.jsx("span",{className:"sys-audit-kind",children:OD(_.kind)})]}),s.jsx("h3",{className:"sys-audit-title",children:yr(_.title??poe(_))}),s.jsx("p",{className:"sys-audit-summary",children:yr($)}),s.jsxs("div",{className:"sys-audit-meta",children:[s.jsxs("span",{className:"sys-audit-meta-item",children:[s.jsx("span",{className:"sys-audit-avatar",style:{background:Xt(_.actorName??"system")},children:hoe(_.actorName)}),_.actorName??"system"]}),Z&&s.jsxs("span",{className:"sys-audit-meta-item",children:["Workspace ",Z]})]}),G.length>0&&s.jsxs("div",{className:"sys-audit-jumps",children:[s.jsx("span",{className:"sys-audit-jumps-label",children:"Open"}),G.map(Y=>s.jsx("button",{type:"button",className:"sys-audit-jump",title:Y.title,onClick:K=>{K.stopPropagation(),e(Y.route)},children:Y.label},Y.key))]})]}),s.jsx("div",{className:"sys-audit-expand",children:U?"Close":"Details"})]}),U&&s.jsxs("div",{className:"sys-audit-details",children:[s.jsxs("div",{className:"sys-detail-grid",children:[s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Event"}),s.jsx("code",{className:"sys-detail-value",children:_.kind})]}),s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Recorded"}),s.jsx("span",{className:"sys-detail-value",children:kr(_.ts)})]}),s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Actor"}),s.jsx("span",{className:"sys-detail-value",children:_.actorName??"system"})]}),_.agentName&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Agent"}),s.jsx("span",{className:"sys-detail-value",children:_.agentName})]}),s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Workspace"}),s.jsx("span",{className:"sys-detail-value",children:_.workspaceRoot??"Not attached"})]}),s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Thread"}),s.jsx("span",{className:"sys-detail-value",children:_.conversationId?Oo(_.conversationId):"Not attached"})]}),_.recordId&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Work"}),s.jsx("span",{className:"sys-detail-value",children:Oo(_.recordId)})]}),_.sessionId&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Session"}),s.jsx("span",{className:"sys-detail-value",children:Oo(_.sessionId)})]}),_.flightId&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Flight"}),s.jsx("span",{className:"sys-detail-value",children:Oo(_.flightId)})]}),_.invocationId&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Invocation"}),s.jsx("span",{className:"sys-detail-value",children:Oo(_.invocationId)})]}),s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Record id"}),s.jsx("code",{className:"sys-detail-value",children:_.id})]})]}),G.length>0&&s.jsx("div",{className:"sys-inline-actions",children:G.map(Y=>s.jsxs("button",{type:"button",className:"s-btn s-btn-sm",onClick:()=>e(Y.route),children:["Open ",Y.label]},Y.key))})]})]},_.id)})})]})}function oa(e){const t=e?.trim();if(!t)return null;const[n]=t.split(".");return n?.trim()||t}function $D(e){const t=e.handle?.trim().replace(/^@+/,"");if(t)return`@${t}`;const n=e.selector?.trim();if(n)return n;const r=oa(e.id);return r?`@${r}`:null}function LD(e){return e.name?.trim()||e.agentName?.trim()||oa(e.id)||e.title?.trim()||"Conversation"}function ob(e){if(!e)return null;const t=e.replace(/_/g," ");return t.toLowerCase()==="relay agent"?"agent":t}function xoe(e){switch(e.view){case"mesh":return"Back to mesh";case"ops":return"Back to ops";case"agents":return e.agentId?"Back to agent":"All agents";case"messages":return"Back to conversations";case"conversation":return"Back to conversation";case"inbox":return"Back to inbox";case"sessions":return"Back to sessions";case"channels":return"Back to conversations";case"fleet":return"Back to fleet";case"work":return"Back to work";case"broker":return"Back to broker";case"activity":return"Back to activity";default:return"Back"}}function zr({slot:e,fallback:t,navigate:n,className:r,label:a}){const c=m.useMemo(()=>Bie(e),[e])??t,u=a??xoe(c);return s.jsxs("button",{type:"button",className:`s-back-pill${r?` ${r}`:""}`,onClick:()=>{Uie(e),n(c)},children:[s.jsx("span",{"aria-hidden":!0,className:"s-back-pill-glyph",children:"←"}),s.jsx("span",{children:u})]})}function PD(e){if(!e)return null;const t=Date.parse(e);return Number.isFinite(t)?t:null}function DD(e){return e?e.length<=12?e:e.slice(0,12):null}function MM(e){if(!e)return null;const t=Math.max(0,Date.now()-e);return t<6e4?"just now":t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}function yoe(e){return e.includes("workflow")?"Claude Workflows":e.includes("codex")?"Codex":e.includes("claude")?"Claude Code":e.replace(/[-_]/g," ")}function ap(e){return e.name??DD(e.externalSessionId)??e.id.replace(/^.*:/,"")}function boe(e){return e.status??e.role??e.type??"observed"}function rf(e,t){const n=e?.[t];return typeof n=="string"&&n.trim()?n.trim():null}function woe(e,t){const n=e?.[t];return typeof n=="number"&&Number.isFinite(n)?n:null}function mk(e){return rf(e,"claudeWorkflowRunId")??rf(e,"workflowRunId")}function joe(e,t,n){return t.filter(r=>r.kind==="spawned"&&r.toId===e.id).map(r=>n.get(r.fromId)).filter(r=>!!r).map(ap)}function koe(e,t){return t.find(n=>n.assigneeId===e.id)??null}function Noe(e,t){return mk(e.providerMeta)===t||e.id.includes(t)}function Soe(e,t){return mk(e.providerMeta)===t||e.id.includes(t)}function Coe(e){const t=rf(e.providerMeta,"latestTimestamp");if(!t)return null;const n=Date.parse(t);return Number.isFinite(n)?n:null}function Eoe(e,t){return e.some(n=>n.state&&mc(n.state)===0)||t.some(n=>n.status&&mc(n.status)===0)?"running":e.some(n=>n.state==="failed"||n.state==="error")||t.some(n=>n.status==="failed"||n.status==="error")?"failed":e.length>0&&e.every(n=>n.state==="completed"||n.state==="done")||t.length>0&&t.every(n=>n.status==="completed"||n.status==="done")?"completed":e.length>0?"observed":"workflow"}function Aoe(e,t){return e.groups.filter(r=>r.kind==="workflow").map(r=>{const a=mk(r.providerMeta)??r.id,o=e.tasks.filter(v=>Noe(v,a)),c=e.agents.filter(v=>v.role!=="lead"&&Soe(v,a)),u=o.filter(v=>v.state!=="completed"&&v.state!=="done"),f=o.filter(v=>v.state==="completed"||v.state==="done"),h=c.map(Coe).filter(v=>!!v).sort((v,y)=>y-v)[0]??null,p=c.reduce((v,y)=>v+(woe(y.providerMeta,"eventCount")??0),0),x=(u.length>0?u:o).slice(0,3);return{id:r.id,label:r.name??a,description:rf(r.providerMeta,"description"),runId:a,parentSessionId:rf(r.providerMeta,"parentSessionId"),status:Eoe(o,c),workerCount:c.length,taskCount:o.length,activeTaskCount:u.length,completedTaskCount:f.length,eventCount:p,latestAt:h??t,taskPreview:x}}).sort((r,a)=>{const o=(a.activeTaskCount>0?1:0)-(r.activeTaskCount>0?1:0);return o!==0?o:(a.latestAt??0)-(r.latestAt??0)||r.label.localeCompare(a.label)})}function mc(e){return e==="running"||e==="in_progress"||e==="working"?0:e==="queued"||e==="pending"||e==="materialized"?1:e==="failed"||e==="error"?2:e==="completed"||e==="done"?3:4}function Toe(e){return e?e.observations.map(t=>({source:t.source,observedAt:PD(t.observedAt),topology:t.topology})):[]}function Vg({topology:e,size:t="full",title:n="Internal topology",maxAgents:r=t==="rail"?5:8,maxTasks:a=t==="rail"?3:5,showEmpty:o=!1}){const[c,u]=m.useState(null),[f,h]=m.useState(!1);m.useEffect(()=>{if(e)return;let v=!1;return ue("/api/topology/snapshot").then(y=>{v||(u(y),h(!1))}).catch(()=>{v||h(!0)}),()=>{v=!0}},[e]);const p=m.useMemo(()=>e?[{source:e.source,observedAt:PD(e.observedAt),topology:e}]:Toe(c),[c,e]),x=m.useMemo(()=>p.reduce((v,y)=>(v.sources+=1,v.workflows+=y.topology.groups.filter(b=>b.kind==="workflow").length,v.agents+=y.topology.agents.length,v.subagents+=y.topology.agents.filter(b=>b.role==="subagent").length,v.tasks+=y.topology.tasks.length,v.activeTasks+=y.topology.tasks.filter(b=>b.state!=="completed").length,v.spawned+=y.topology.relationships.filter(b=>b.kind==="spawned").length,v),{sources:0,workflows:0,agents:0,subagents:0,tasks:0,activeTasks:0,spawned:0}),[p]);return p.length===0?!o&&!f?null:s.jsxs("section",{className:`s-observed-topology s-observed-topology--${t}`,children:[s.jsx("header",{className:"s-observed-topology-head",children:s.jsxs("div",{children:[s.jsx("div",{className:"s-observed-topology-kicker",children:"Harness observed"}),s.jsx("h3",{children:n})]})}),s.jsx("div",{className:"s-observed-topology-empty",children:f?"Topology is unavailable right now.":"No Codex or Claude Code internal agent family observed yet."})]}):s.jsxs("section",{className:`s-observed-topology s-observed-topology--${t}`,children:[s.jsxs("header",{className:"s-observed-topology-head",children:[s.jsxs("div",{children:[s.jsx("div",{className:"s-observed-topology-kicker",children:"Harness observed"}),s.jsx("h3",{children:n})]}),s.jsxs("div",{className:"s-observed-topology-counts",children:[x.workflows>0&&s.jsxs("span",{children:[x.workflows," workflows"]}),s.jsxs("span",{children:[x.subagents," workers"]}),s.jsxs("span",{children:[x.tasks," tasks"]}),x.activeTasks>0?s.jsxs("span",{children:[x.activeTasks," active"]}):s.jsxs("span",{children:[x.spawned," spawn links"]})]})]}),s.jsx("div",{className:"s-observed-topology-sources",children:p.map(v=>s.jsx(Moe,{source:v,maxAgents:r,maxTasks:a},`${v.source}:${v.topology.observedAt}`))})]})}function Moe({source:e,maxAgents:t,maxTasks:n}){const{topology:r}=e,a=new Map(r.agents.map(b=>[b.id,b])),o=Aoe(r,e.observedAt),c=o.slice(0,t),u=o.length-c.length,f=(b,C)=>mc(b.status)-mc(C.status)||ap(b).localeCompare(ap(C)),h=r.agents.filter(b=>b.role==="subagent").sort(f),p=r.agents.filter(b=>b.role==="lead").sort(f),x=r.agents.filter(b=>b.role!=="subagent"&&b.role!=="lead").sort(f),v=[...p,...h,...x].slice(0,t),y=r.tasks.filter(b=>b.state!=="completed").sort((b,C)=>mc(b.state)-mc(C.state)||(b.title??b.id).localeCompare(C.title??C.id)).slice(0,n);return s.jsxs("div",{className:"s-observed-topology-source",children:[s.jsxs("div",{className:"s-observed-topology-source-head",children:[s.jsx("span",{children:yoe(e.source)}),s.jsx("span",{children:MM(e.observedAt)??"observed"})]}),o.length>0?s.jsxs("div",{className:"s-observed-topology-workflow-list",children:[c.map(b=>s.jsxs("div",{className:"s-observed-topology-workflow",children:[s.jsxs("div",{className:"s-observed-topology-workflow-main",children:[s.jsx("span",{className:`s-observed-topology-workflow-state s-observed-topology-workflow-state--${b.status}`,children:b.status}),s.jsx("span",{className:"s-observed-topology-workflow-name",title:b.label,children:b.label}),s.jsx("span",{className:"s-observed-topology-workflow-age",children:MM(b.latestAt)??"observed"})]}),s.jsxs("div",{className:"s-observed-topology-workflow-meta",children:[s.jsxs("span",{children:[b.workerCount," workers"]}),b.taskCount>0&&s.jsxs("span",{children:[b.completedTaskCount,"/",b.taskCount," tasks"]}),b.eventCount>0&&s.jsxs("span",{children:[b.eventCount," events"]}),b.parentSessionId&&s.jsxs("span",{children:["parent ",DD(b.parentSessionId)]})]}),b.description&&s.jsx("div",{className:"s-observed-topology-workflow-description",children:b.description}),b.taskPreview.length>0&&s.jsx("div",{className:"s-observed-topology-workflow-tasks",children:b.taskPreview.map(C=>s.jsx("span",{children:C.title??C.id.replace(/^.*:/,"")},C.id))})]},b.id)),u>0&&s.jsxs("div",{className:"s-observed-topology-more",children:[u," more workflow",u===1?"":"s"," in project rows"]})]}):s.jsx("div",{className:"s-observed-topology-agent-list",children:v.map(b=>{const C=joe(b,r.relationships,a),E=koe(b,r.tasks);return s.jsxs("div",{className:"s-observed-topology-agent",children:[s.jsxs("div",{className:"s-observed-topology-agent-main",children:[s.jsx("span",{className:`s-observed-topology-agent-role s-observed-topology-agent-role--${b.role??"observed"}`,children:b.role??"observed"}),s.jsx("span",{className:"s-observed-topology-agent-name",children:ap(b)}),s.jsx("span",{className:"s-observed-topology-agent-status",children:boe(b)})]}),(C.length>0||E?.title)&&s.jsxs("div",{className:"s-observed-topology-agent-detail",children:[C.length>0&&s.jsxs("span",{children:["spawned by ",C.join(", ")]}),E?.title&&s.jsx("span",{children:E.title})]})]},b.id)})}),o.length===0&&y.length>0&&s.jsx("div",{className:"s-observed-topology-task-list",children:y.map(b=>s.jsxs("div",{className:"s-observed-topology-task",children:[s.jsx("span",{children:b.state??"task"}),s.jsx("strong",{children:b.title??b.id.replace(/^.*:/,"")})]},b.id))})]})}function Roe({values:e}){return s.jsx("span",{className:"s-agent-token-list",children:e.map(t=>s.jsx("span",{className:"s-agent-token",children:t},t))})}function Zs({value:e}){return s.jsx("span",{className:"s-agent-code-value",children:e})}function Qu({title:e,items:t}){return t.length===0?null:s.jsxs("section",{className:"s-agent-profile-card",children:[s.jsx("div",{className:"s-agent-profile-card-header",children:s.jsx("div",{className:"s-agent-profile-card-title",children:e})}),s.jsx("div",{className:"s-agent-meta-card-body",children:t.map(n=>s.jsxs("div",{className:"s-agent-meta-row",children:[s.jsx("span",{className:"s-agent-meta-label",children:n.label}),s.jsx("span",{className:"s-agent-meta-value",children:n.value})]},n.label))})]})}function Ioe({conversationId:e,navigate:t}){const{agents:n,route:r}=qe(),[a,o]=m.useState(null),[c,u]=m.useState(null),[f,h]=m.useState(null),p=Bg(e),x=m.useCallback(async()=>{h(null);try{const L=await ue(`/api/session/${encodeURIComponent(e)}`).catch(()=>null);o(L)}catch(L){h(L instanceof Error?L.message:String(L)),o(null)}},[e]);m.useEffect(()=>{x()},[x]),Vt(()=>{x()});const v=a?.agentId??p;m.useEffect(()=>{if(!v||n.some(I=>I.id===v)){u(null);return}let L=!1;return ue(`/api/agents/${encodeURIComponent(v)}`).then(I=>{L||u(I)}).catch(()=>{L||u(null)}),()=>{L=!0}},[n,v]);const y=m.useMemo(()=>v?n.find(L=>L.id===v)??(c?.id===v?c:null):null,[c,n,v]);if(!y)return s.jsxs("div",{children:[s.jsx(zr,{slot:"agent-info",fallback:{view:"conversation",conversationId:e},navigate:t}),f&&s.jsx("p",{className:"s-error",children:f}),s.jsx("div",{className:"s-empty",children:s.jsx("p",{children:"Agent not found"})})]});const b=$D(y),C=y.handle?`@${y.handle.replace(/^@+/,"")}`:null,E=y.selector??y.defaultSelector??C,A=y.authorityNodeName?`${y.authorityNodeName} (${y.authorityNodeId??"unknown"})`:y.authorityNodeId,S=y.homeNodeName?`${y.homeNodeName} (${y.homeNodeId??"unknown"})`:y.homeNodeId,k=[{label:"Fully qualified ID",value:s.jsx(Zs,{value:y.id})},{label:"Definition",value:s.jsx(Zs,{value:y.definitionId})},...C?[{label:"Handle",value:s.jsx(Zs,{value:C})}]:[],...y.selector?[{label:"Selector",value:s.jsx(Zs,{value:y.selector})}]:[],...y.defaultSelector&&y.defaultSelector!==y.selector?[{label:"Default selector",value:s.jsx(Zs,{value:y.defaultSelector})}]:[],...y.workspaceQualifier?[{label:"Workspace qualifier",value:s.jsx(Zs,{value:y.workspaceQualifier})}]:[],...y.nodeQualifier?[{label:"Node qualifier",value:s.jsx(Zs,{value:y.nodeQualifier})}]:[],{label:"Class",value:ob(y.agentClass)??"—"},...y.role?[{label:"Role",value:y.role}]:[],...y.staleLocalRegistration?[{label:"Registration",value:y.replacedByAgentId?`Superseded by ${y.replacedByAgentId}`:"Historical registration"}]:[],...y.retiredFromFleet?[{label:"Fleet state",value:"Retired"}]:[]],N=[...A?[{label:"Authority node",value:s.jsx(Zs,{value:A})}]:[],...S?[{label:"Home node",value:s.jsx(Zs,{value:S})}]:[],...y.ownerId?[{label:"Owner",value:y.ownerName?`${y.ownerName} (${y.ownerId})`:y.ownerId}]:[],...y.conversationId?[{label:"Direct conversation",value:s.jsx(Zs,{value:y.conversationId})}]:[]],T=[...y.project?[{label:"Project",value:y.project}]:[],...y.branch?[{label:"Branch",value:y.branch}]:[],...y.projectRoot?[{label:"Path",value:y.projectRoot}]:[],...y.cwd?[{label:"Working dir",value:y.cwd}]:[]],R=[...y.harness?[{label:"Harness",value:y.harness}]:[],...y.model?[{label:"Model",value:y.model}]:[],...y.transport?[{label:"Transport",value:ob(y.transport)??y.transport}]:[],...y.wakePolicy?[{label:"Wake policy",value:ob(y.wakePolicy)??y.wakePolicy}]:[],...y.capabilities.length>0?[{label:"Capabilities",value:s.jsx(Roe,{values:y.capabilities})}]:[]],O=[{label:"Conversation UID",value:e},...a?.workspaceRoot?[{label:"Workspace",value:a.workspaceRoot}]:[],...a?.currentBranch?[{label:"Session branch",value:a.currentBranch}]:[],...a?.messageCount!=null?[{label:"Messages",value:String(a.messageCount)}]:[],...a?.lastMessageAt?[{label:"Last message",value:kr(a.lastMessageAt)}]:[],...y.harnessSessionId?[{label:"Harness session",value:y.harnessSessionId}]:[],...y.harnessLogPath?[{label:"Harness log",value:y.harnessLogPath}]:[]];return s.jsxs("div",{className:"s-agent-profile-page",children:[s.jsxs("div",{className:"s-agent-profile-page-topbar",children:[s.jsx(zr,{slot:"agent-info",fallback:{view:"conversation",conversationId:e},navigate:t}),s.jsx("button",{type:"button",className:"s-btn",onClick:()=>t({view:"agents",agentId:y.id}),children:"Open in Agents"})]}),f&&s.jsx("p",{className:"s-error",children:f}),s.jsxs("section",{className:"s-agent-profile-hero",children:[s.jsx("div",{className:"s-agent-profile-hero-main",children:s.jsxs("div",{className:"s-agent-profile-hero-title-row",children:[s.jsx("div",{className:"s-avatar s-agent-profile-hero-avatar",style:{background:Xt(y.name)},children:y.name[0].toUpperCase()}),s.jsxs("div",{className:"s-agent-profile-hero-copy",children:[s.jsxs("div",{className:"s-agent-casefile-title-meta",children:[s.jsx("span",{className:"s-agent-casefile-record",children:E??b??oa(y.id)??y.id}),s.jsxs("span",{className:`s-agent-state-chip s-agent-state-chip-${ll(y.state)}`,children:[s.jsx("span",{className:"s-dot",style:{background:yn(y.state)}}),cs(y.state)]}),y.staleLocalRegistration&&s.jsx("span",{className:"s-agent-state-chip s-agent-state-chip-offline",children:"Superseded registration"})]}),s.jsx("h1",{className:"s-agent-profile-hero-title",children:y.name}),s.jsxs("div",{className:"s-agent-profile-hero-tags",children:[s.jsx(Zs,{value:y.id}),y.selector&&s.jsx(Zs,{value:y.selector}),y.defaultSelector&&y.defaultSelector!==y.selector&&s.jsx(Zs,{value:y.defaultSelector})]}),s.jsxs("p",{className:"s-agent-profile-hero-context",children:[a?.title?`Conversation: ${a.title}.`:"Attached to the current conversation.",y.updatedAt?` Updated ${Ie(y.updatedAt)}.`:""]})]})]})}),s.jsxs("div",{className:"s-agent-profile-hero-actions",children:[s.jsx(Sf,{agent:y,navigate:t,returnTo:r}),s.jsx("button",{type:"button",className:"s-btn s-btn-primary",onClick:()=>wt(t,{view:"conversation",conversationId:e},{returnTo:r}),children:"Open conversation"})]})]}),s.jsxs("div",{className:"s-agent-profile-grid",children:[s.jsx(Qu,{title:"Identity",items:k}),s.jsx(Qu,{title:"Topology",items:N}),s.jsx(Qu,{title:"Workspace",items:T}),s.jsx(Qu,{title:"Runtime",items:R}),s.jsx(Qu,{title:"Conversation context",items:O})]}),s.jsx(Vg,{title:"Observed harness families",size:"compact",maxAgents:8,maxTasks:4,showEmpty:!0})]})}function _oe(e){switch(e){case"success":return"completed";case"danger":return"failed";case"working":return"working";default:return"updated"}}function zD(e){return e.attention==="interrupt"?"danger":e.state==="done"?"success":e.attention==="badge"||e.state==="waiting"||e.state==="review"?"warning":"working"}function Ooe(e){return e.attention==="interrupt"?"danger":"warning"}function $oe(e,t){return e==="success"||t==="sent"||t==="acknowledged"||t==="completed"?"success":e==="failed_query"||e==="failed_delivery"||t==="failed"||t==="cancelled"?"danger":t==="running"||t==="accepted"||t==="deferred"||t==="pending"?"working":"neutral"}function Loe(e){return e?e.status==="paired"||e.status==="connected"?"success":e.status==="error"||e.status==="closed"?"danger":"warning":"warning"}function Wa({tone:e,children:t,variant:n="chip",className:r,title:a}){const o=n==="pill"?"s-pill":"sys-chip",c=n==="pill"?`s-pill-${_oe(e)}`:`sys-chip-${e}`,u=r?`${o} ${c} ${r}`:`${o} ${c}`;return s.jsx("span",{className:u,title:a,children:t})}function Poe(e){switch(e){case"review":return"In review";case"waiting":return"Waiting";case"working":return"Working";case"done":return"Done";default:return e.replace(/_/g," ")}}function Doe(e){switch(e){case"badge":return"Noteworthy";case"interrupt":return"Blocked signal";default:return null}}function RM({items:e,navigate:t,emptyTitle:n,emptyDetail:r}){const{route:a}=qe();if(e.length===0){const o=[{titleWidth:"56%",metaWidths:["18%","14%","16%"],summaryWidth:"74%"},{titleWidth:"48%",metaWidths:["16%","20%","12%"],summaryWidth:"62%"}];return s.jsxs("div",{className:"s-work-empty-state",children:[s.jsxs("div",{className:"s-work-empty-copy",children:[s.jsx("p",{className:"s-work-empty-kicker",children:"Quiet for now"}),s.jsx("p",{className:"s-work-empty-title",children:n}),r&&s.jsx("p",{className:"s-work-empty-detail",children:r})]}),s.jsx("div",{className:"s-work-empty-skeleton","aria-hidden":"true",children:o.map((c,u)=>s.jsxs("div",{className:"s-work-empty-row",children:[s.jsxs("div",{className:"s-work-empty-row-header",children:[s.jsx("span",{className:"s-work-empty-line s-work-empty-line-title",style:{width:c.titleWidth}}),s.jsx("span",{className:"s-work-empty-pill"})]}),s.jsx("div",{className:"s-work-empty-row-meta",children:c.metaWidths.map(f=>s.jsx("span",{className:"s-work-empty-line s-work-empty-line-meta",style:{width:f}},f))}),s.jsx("span",{className:"s-work-empty-line s-work-empty-line-summary",style:{width:c.summaryWidth}})]},u))})]})}return s.jsx("div",{className:"s-work-list",children:e.map(o=>{const c=!!o.id||!!o.conversationId,u=Doe(o.attention),f=o.ownerName??o.ownerId??"Unassigned",h=o.id?()=>wt(t,{view:"work",workId:o.id},{returnTo:a}):o.conversationId?()=>wt(t,{view:"conversation",conversationId:o.conversationId},{returnTo:a}):void 0;return s.jsxs("div",{className:`s-work-row${c?" s-work-row-clickable":""}`,onClick:h,children:[s.jsxs("div",{className:"s-work-row-header",children:[s.jsxs("div",{className:"s-work-row-title-wrap",children:[s.jsx("span",{className:"s-work-row-title",children:o.title}),o.priority&&s.jsx("span",{className:"s-badge",children:o.priority})]}),s.jsx(Wa,{tone:zD(o),variant:"pill",children:o.currentPhase})]}),s.jsxs("div",{className:"s-work-row-meta",children:[s.jsx("span",{children:f}),s.jsx("span",{children:Poe(o.state)}),o.activeChildWorkCount>0&&s.jsxs("span",{children:[o.activeChildWorkCount," child",o.activeChildWorkCount===1?"":"ren"]}),o.activeFlightCount>0&&s.jsxs("span",{children:[o.activeFlightCount," flight",o.activeFlightCount===1?"":"s"]}),u&&s.jsx("span",{children:u}),s.jsx("span",{children:Ie(o.lastMeaningfulAt)})]}),o.lastMeaningfulSummary&&s.jsx("p",{className:"s-work-row-summary",children:yr(o.lastMeaningfulSummary)})]},o.id)})})}async function ip(e){await ue("/api/operator-attention/dismiss",{method:"POST",body:JSON.stringify(e)})}function zoe(e){const t=e?.trim();return t?t.replace(/^handoff-/,"").slice(0,18):null}function BD(e){const t=e.plan.manifest.workspaceID?.trim(),n=zoe(e.plan.manifest.handoffId??e.handoffId);return[t,n].filter(Boolean).join(" · ")}async function UD(e={}){return await ue(zg("vantageOpenPath"),{method:"POST",body:JSON.stringify({agentId:e.agentId??null,agentIds:e.agentIds??[],nativeSessionIds:e.nativeSessionIds??[],launch:e.launch??!0})})}function Hg({agentId:e,agentIds:t,nativeSessionIds:n,className:r,statusClassName:a,label:o="Vantage",openingLabel:c="Opening",title:u="Open this session context in the native Vantage canvas",disabled:f=!1}){const[h,p]=m.useState({state:"idle"}),x=()=>{p({state:"opening"}),UD({agentId:e??null,agentIds:t,nativeSessionIds:n,launch:!0}).then(v=>{const y=v.plan.manifest.nodes.length,b=BD(v);if(y===0){const E=v.plan.diagnostics.find(A=>A.severity==="warning")??v.plan.diagnostics[0];p({state:"failed",error:E?`${b} · no windows: ${E.message}`:`${b} · no Vantage windows.`});return}if(!v.launch.ok&&v.launch.error){p({state:"failed",error:v.launch.error});return}const C=v.launch.ok?"launch requested":"handoff written";p({state:"opened",detail:`${b} · ${y} node${y===1?"":"s"} · ${C}`})}).catch(v=>{p({state:"failed",error:v instanceof Error?v.message:String(v)})})};return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:r,onClick:x,disabled:f||h.state==="opening",title:u,children:h.state==="opening"?c:o}),h.state==="opened"&&a&&s.jsx("span",{className:`${a} ${a}--ok`,children:h.detail}),h.state==="failed"&&a&&s.jsx("span",{className:`${a} ${a}--error`,children:h.error})]})}function FD(e,t){const n=St(e),r=St(t);if(n===null||r===null)return!1;const a=new Date(n),o=new Date(r);return a.getFullYear()===o.getFullYear()&&a.getMonth()===o.getMonth()&&a.getDate()===o.getDate()}function tw(e){const t=St(e);if(t===null)return"";const n=new Date(t),r=new Date,a=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),o=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),c=1440*60*1e3;return o===a?"Today":o===a-c?"Yesterday":new Intl.DateTimeFormat(void 0,{weekday:"short",month:"short",day:"numeric"}).format(t)}const Boe=30*6e4;function Uoe(e){return e.kind==="direct"}function Cc(e){return e.kind==="channel"||e.kind==="group_direct"||e.id.startsWith("channel.")}function br(e){return e.title&&e.title!==e.id?e.title:e.id.startsWith("channel.")?e.id.replace(/^channel\./,""):e.agentName??e.id}function pk(e){return e.id.startsWith("channel.")?e.id.replace(/^channel\./,""):br(e)}const VD=new Set(["completed","failed","cancelled"]);function Jc(e){return!!(e&&!VD.has(e.state))}function Foe(e){return Jc(e)&&!HD(e)}function HD(e){return!!(e?.summary?.includes("Scout stopped waiting for a synchronous result")||e?.summary?.includes("the requester stopped waiting after"))}function WD(e,t=Date.now(),n=Boe){if(!Jc(e))return!1;const r=St(e?.startedAt);return r!==null&&t-r>n}function Voe(e,t,n=Date.now()){if(!WD(e,n))return!1;const r=St(e?.startedAt),a=St(t);return r!==null&&a!==null&&a>r}function Hoe(e){return!Jc(e)}const nw=/^```([a-z0-9_-]+)?\s*$/iu,qD=/^(#{1,6})\s+(.+)$/u,Woe=/^(?:-{3,}|\*{3,}|_{3,})$/u,qoe=/^\s*[-*]\s+(.+)$/u,Koe=/^\s*\d+[.)]\s+(.+)$/u,Goe=/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?$/u;function Zoe(e){const t=e.replace(/\r\n?/gu,`
147
- `).trim();return t?t.replace(/([^\n])\s+---\s+(?=(?:#{1,6}\s|\*\*|[A-Z0-9]))/gu,`$1
148
-
149
- ---
150
-
151
- `).replace(/([^\n])\s+(#{1,6}\s+)/gu,`$1
152
-
153
- $2`).replace(/\n{3,}/gu,`
154
-
155
- `):""}function KD(e){return e.trim().length===0}function Yoe(e){return qD.test(e.trim())}function GD(e){return Woe.test(e.trim())}function sw(e){return e.match(qoe)?.[1]?.trim()??null}function rw(e){return e.match(Koe)?.[1]?.trim()??null}function Xoe(e){return sw(e)!==null||rw(e)!==null}function IM(e){return e.trim().replace(/^\|/u,"").replace(/\|$/u,"").split("|").map(n=>n.trim())}function ZD(e,t){const n=e[t]?.trim(),r=e[t+1]?.trim();return!!(n&&r&&n.includes("|")&&Goe.test(r))}function Qoe(e,t){const n=e[t]??"",r=n.trim();return!!(KD(n)||nw.test(r)||Yoe(n)||GD(n)||Xoe(n)||r.startsWith(">")||ZD(e,t))}function Joe(e){const t=Zoe(e);if(!t)return[];const n=t.split(`
156
- `),r=[];let a=0;for(;a<n.length;){const o=n[a]??"",c=o.trim();if(!c){a+=1;continue}const u=c.match(nw);if(u){const v=[];for(a+=1;a<n.length&&!nw.test(n[a].trim());)v.push(n[a]),a+=1;a<n.length&&(a+=1),r.push({type:"code",language:u[1]??null,text:v.join(`
157
- `)});continue}if(GD(o)){r.push({type:"hr"}),a+=1;continue}const f=c.match(qD);if(f){r.push({type:"heading",depth:f[1].length,text:f[2].trim()}),a+=1;continue}if(ZD(n,a)){const v=IM(n[a]);a+=2;const y=[];for(;a<n.length&&n[a].includes("|")&&!KD(n[a]);)y.push(IM(n[a])),a+=1;r.push({type:"table",headers:v,rows:y});continue}const h=sw(o),p=rw(o);if(h!==null||p!==null){const v=p!==null,y=[];for(;a<n.length;){const b=v?rw(n[a]):sw(n[a]);if(b===null)break;y.push(b),a+=1}r.push({type:"list",ordered:v,items:y});continue}if(c.startsWith(">")){const v=[];for(;a<n.length&&n[a].trim().startsWith(">");)v.push(n[a].trim().replace(/^>\s?/u,"")),a+=1;r.push({type:"blockquote",text:v.join(`
158
- `).trim()});continue}const x=[];for(;a<n.length&&!Qoe(n,a);)x.push(n[a].trimEnd()),a+=1;r.push({type:"paragraph",text:x.join(`
159
- `).trim()})}return r}function ele(e,t){const n=Math.min(6,Math.max(2,e.depth+1));return s.jsx("div",{role:"heading","aria-level":n,className:`s-message-markup-heading s-message-markup-heading-${e.depth}`,children:yr(e.text)},t)}function tle(e,t){return s.jsx("div",{className:"s-message-markup-table-wrap",children:s.jsxs("table",{className:"s-message-markup-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:e.headers.map((n,r)=>s.jsx("th",{children:yr(n)},`${t}:h:${r}`))})}),s.jsx("tbody",{children:e.rows.map((n,r)=>s.jsx("tr",{children:e.headers.map((a,o)=>s.jsx("td",{children:yr(n[o]??"")},`${t}:c:${r}:${o}`))},`${t}:r:${r}`))})]})},t)}function nle(e,t){switch(e.type){case"paragraph":return s.jsx("p",{className:"s-message-markup-paragraph",children:yr(e.text)},t);case"heading":return ele(e,t);case"hr":return s.jsx("hr",{className:"s-message-markup-rule"},t);case"list":return e.ordered?s.jsx("ol",{className:"s-message-markup-list",children:e.items.map((n,r)=>s.jsx("li",{children:yr(n)},`${t}:${r}`))},t):s.jsx("ul",{className:"s-message-markup-list",children:e.items.map((n,r)=>s.jsx("li",{children:yr(n)},`${t}:${r}`))},t);case"blockquote":return s.jsx("blockquote",{className:"s-message-markup-quote",children:yr(e.text)},t);case"code":return s.jsx("pre",{className:"s-message-markup-code",children:s.jsx("code",{children:e.text})},t);case"table":return tle(e,t)}}function gk({text:e,className:t}){const n=Joe(e??"");return n.length===0?e??"":s.jsx("div",{className:["s-message-markup",t].filter(Boolean).join(" "),children:n.map(nle)})}function aw(e){return e.class!=="status"||e.actorId!=="system"?!1:e.body.includes("failed to respond")&&e.body.includes("snapshot.messages")}const YD="scout:sessions:lastViewed";function vk(){if(typeof localStorage>"u")return{};try{const e=localStorage.getItem(YD);if(!e)return{};const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function xk(e,t=Date.now()){const n=vk();n[e]=t;try{localStorage.setItem(YD,JSON.stringify(n))}catch{}return n}function op(e,t,n){return e?e>(n[t]??0):!1}const sle={defaultPort:43115},rle=sle.defaultPort,ale="127.0.0.1",ile=2e3,ole=500;function lle(e){return new cle(e)}class cle{base;clientId;probeTimeout;pollInterval;_state="unknown";constructor(t){if(t?.baseUrl)this.base=t.baseUrl.replace(/\/$/,"");else{const n=t?.host??ale,r=t?.port??rle;this.base=`http://${n}:${r}`}this.clientId=t?.clientId??"vox-web",this.probeTimeout=t?.probeTimeout??ile,this.pollInterval=t?.pollInterval??ole}get state(){return this._state}get isConnected(){return this._state==="connected"}async probe(){this._state="probing";try{const n=await(await this.fetch("/health",{timeout:this.probeTimeout})).json();return this._state=n.ok?"connected":"unavailable",n.ok}catch{return this._state="unavailable",!1}}async health(){return(await this.fetch("/health")).json()}async capabilities(){return(await this.fetch("/capabilities")).json()}async transcribe(t){const{audio:n,modelId:r,format:a,language:o,timestamps:c,metadata:u}=t,f=new FormData;if(n instanceof Blob){const p=a??fle(n.type)??"wav";f.append("audio",n,`audio.${p}`)}else{const p=a??"wav",x=new Blob([n],{type:hle(p)});f.append("audio",x,`audio.${p}`)}return a&&f.append("format",a),r&&f.append("modelId",r),o&&f.append("language",o),c&&f.append("timestamps","true"),f.append("metadata",JSON.stringify(this.withClientMetadata(u))),(await this.fetch("/transcribe",{method:"POST",body:f})).json()}async createJob(t){return(await this.fetch("/jobs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,metadata:this.withClientMetadata(t.metadata)})})).json()}async getJob(t){return(await this.fetch(`/jobs/${t}`)).json()}async align(t){const{jobId:n}=await this.createJob({...t,type:"alignment"});return this.waitForJob(n)}createLiveSession(){return new ule(t=>this.openLiveSession(t),t=>this.stopLiveSession(t),t=>this.cancelLiveSession(t))}async getLiveSessionStatus(){const r=(await(await this.fetch("/live")).json()).session;return!r||typeof r!="object"?null:{sessionId:String(r.sessionId??""),connectionId:String(r.connectionId??""),clientId:String(r.clientId??""),modelId:String(r.modelId??""),startedAt:String(r.startedAt??""),state:String(r.state??"error")}}async stopLiveSession(t){const r=await(await this.fetch("/live/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{sessionId:t}:{})})).json();return{stopped:!!r.stopped,sessionId:String(r.sessionId??t??"")}}async cancelLiveSession(t){const r=await(await this.fetch("/live/cancel",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{sessionId:t}:{})})).json();return{cancelled:!!r.cancelled,sessionId:String(r.sessionId??t??"")}}launch(){window.location.href="vox://launch"}openSettings(){window.location.href="vox://settings"}async waitForJob(t){for(let r=0;r<600;r++){const a=await this.getJob(t);if(a.status==="completed"){if(!a.result?.alignment)throw new gr("Job completed but no alignment result","no_result");return a.result.alignment}if(a.status==="failed")throw new gr(a.error??"Job failed","job_failed");await dle(this.pollInterval)}throw new gr("Job timed out","timeout")}async openLiveSession(t){const n={clientId:this.clientId};return t?.modelId&&(n.modelId=t.modelId),this.fetch("/live",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}withClientMetadata(t){const n=t?{...t}:{};return n.clientId==null&&n.surface==null&&(n.clientId=this.clientId),n}async fetch(t,n){const{timeout:r,...a}=n??{},o=new AbortController,c=r?setTimeout(()=>o.abort(),r):void 0;try{const u=await globalThis.fetch(`${this.base}${t}`,{...a,signal:o.signal});if(!u.ok){const f=await u.text().catch(()=>"");throw new gr(`${u.status} ${u.statusText}: ${f}`,"http_error")}return u}catch(u){throw u instanceof gr?u:new gr(u instanceof Error?u.message:"Companion unreachable","network_error")}finally{c&&clearTimeout(c)}}}class gr extends Error{code;constructor(t,n){super(t),this.code=n,this.name="VoxDError"}}class ule{open;stopRequest;cancelRequest;sessionId=null;runPromise=null;finalEvent=null;stateListeners=new Set;partialListeners=new Set;finalListeners=new Set;errorListeners=new Set;constructor(t,n,r){this.open=t,this.stopRequest=n,this.cancelRequest=r}get id(){return this.sessionId}start(t){return this.runPromise||(this.runPromise=this.run(t)),this.runPromise}async stop(){await this.stopRequest(this.sessionId??void 0)}async cancel(){await this.cancelRequest(this.sessionId??void 0)}onState(t){return this.stateListeners.add(t),()=>this.stateListeners.delete(t)}onPartial(t){return this.partialListeners.add(t),()=>this.partialListeners.delete(t)}onFinal(t){return this.finalListeners.add(t),()=>this.finalListeners.delete(t)}onError(t){return this.errorListeners.add(t),()=>this.errorListeners.delete(t)}close(){this.cancel().catch(t=>{this.emitError(t instanceof Error?t:new Error(String(t)))})}async run(t){try{const n=await this.open(t);if(!n.body)throw new gr("Live session stream did not include a response body.","protocol_error");let r=null;await mle(n.body,o=>{if(typeof o.error=="string"&&o.error)throw new gr(o.error,"live_session_error");if(typeof o.event=="string"){this.handleEvent(o.event,_M(o.data));return}o.result&&typeof o.result=="object"&&(r=_M(o.result))});const a=this.finalEvent??this.parseResult(r);if(!a)throw new gr("Live session ended without a final result.","protocol_error");return a}catch(n){const r=n instanceof Error?n:new Error(String(n));throw this.emitError(r),r}}handleEvent(t,n){switch(t){case"session.state":{const r={sessionId:String(n.sessionId??this.sessionId??""),state:String(n.state??"error"),previous:n.previous??null,reason:typeof n.reason=="string"?n.reason:void 0};r.sessionId&&(this.sessionId=r.sessionId);for(const a of this.stateListeners)a(r);break}case"session.partial":{const r={sessionId:String(n.sessionId??this.sessionId??""),text:String(n.text??"")};r.sessionId&&(this.sessionId=r.sessionId);for(const a of this.partialListeners)a(r);break}case"session.final":{const r=this.parseResult(n);if(!r)return;this.finalEvent=r,this.sessionId=r.sessionId||this.sessionId;for(const a of this.finalListeners)a(r);break}}}parseResult(t){if(!t)return null;if(t.cancelled)throw new gr(`Live session ${String(t.sessionId??this.sessionId??"")} was cancelled.`,"session_cancelled");return{sessionId:String(t.sessionId??this.sessionId??""),text:String(t.text??""),durationMs:Number(t.durationMs??t.elapsedMs??0),words:Array.isArray(t.words)?t.words:void 0,metrics:gle(t.metrics)?t.metrics:void 0}}emitError(t){for(const n of this.errorListeners)n(t)}}function dle(e){return new Promise(t=>setTimeout(t,e))}function fle(e){if(e.includes("mp3")||e.includes("mpeg"))return"mp3";if(e.includes("wav"))return"wav";if(e.includes("aac")||e.includes("mp4"))return"aac";if(e.includes("opus")||e.includes("ogg"))return"opus"}function hle(e){switch(e){case"mp3":return"audio/mpeg";case"wav":return"audio/wav";case"aac":return"audio/aac";case"opus":return"audio/ogg; codecs=opus";case"pcm16":return"audio/pcm";default:return"application/octet-stream"}}async function mle(e,t){const n=e.getReader(),r=new TextDecoder;let a="";try{for(;;){const{value:c,done:u}=await n.read();if(u)break;a+=r.decode(c,{stream:!0}),a=ple(a,t)}a+=r.decode();const o=a.trim();o&&t(XD(o))}finally{n.releaseLock()}}function ple(e,t){let n=e;for(;;){const r=n.indexOf(`
160
- `);if(r===-1)return n;const a=n.slice(0,r).trim();n=n.slice(r+1),a&&t(XD(a))}}function XD(e){try{return JSON.parse(e)}catch{throw new gr("Live session stream returned invalid JSON.","protocol_error")}}function _M(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function gle(e){return!!(e&&typeof e=="object")}const Wg={lowCutHz:350,highCutHz:2800,bandQ:.85,saturationAmount:.25,bitcrushAmount:.12,hissGain:.045,hissCutoffHz:1200,presencePeakDb:4,presenceCenterHz:1500,presenceQ:1,compressorThresholdDb:-22,compressorRatio:5,clickEnabled:!0,clickGain:.35,clickDurationMs:70,squelchTailEnabled:!0,squelchTailGain:.07,squelchTailDurationMs:180,playbackRate:1,outputGain:1.1,wetMix:1},af=[{id:"chill-dispatcher",label:"Chill Dispatcher",family:"dispatch",description:"Warm, friendly, takes its time. Like the calmest voice on the channel.",params:{lowCutHz:280,highCutHz:3200,bandQ:.7,saturationAmount:.2,bitcrushAmount:.08,hissGain:.035,hissCutoffHz:1400,presencePeakDb:3.5,presenceCenterHz:1500,presenceQ:1,compressorThresholdDb:-20,compressorRatio:4,clickEnabled:!0,clickGain:.3,clickDurationMs:60,squelchTailEnabled:!0,squelchTailGain:.06,squelchTailDurationMs:160,playbackRate:.97,outputGain:1.1,wetMix:1}},{id:"tower-control",label:"Tower Control",family:"dispatch",description:"Crisp, clipped, all-business. Pushes you out the door a little faster.",params:{lowCutHz:500,highCutHz:2400,bandQ:1,saturationAmount:.42,bitcrushAmount:.22,hissGain:.06,hissCutoffHz:1800,presencePeakDb:6,presenceCenterHz:1700,presenceQ:1.3,compressorThresholdDb:-28,compressorRatio:8,clickEnabled:!0,clickGain:.5,clickDurationMs:80,squelchTailEnabled:!0,squelchTailGain:.1,squelchTailDurationMs:200,playbackRate:1.08,outputGain:1.15,wetMix:1}},{id:"carrier-wave",label:"Carrier Wave",family:"dispatch",description:"Always-on hiss like someone's holding the mic just to keep you company.",params:{lowCutHz:320,highCutHz:3e3,bandQ:.55,saturationAmount:.15,bitcrushAmount:.06,hissGain:.11,hissCutoffHz:900,presencePeakDb:2,presenceCenterHz:1300,presenceQ:.8,compressorThresholdDb:-18,compressorRatio:3,clickEnabled:!0,clickGain:.18,clickDurationMs:50,squelchTailEnabled:!0,squelchTailGain:.12,squelchTailDurationMs:300,playbackRate:.95,outputGain:1.05,wetMix:1}},{id:"pocket-walkie",label:"Pocket Walkie",family:"walkie",description:"That nostalgic kid-radio crunch. Narrow, snappy, just-this-side-of-toy.",params:{lowCutHz:600,highCutHz:2300,bandQ:1.2,saturationAmount:.5,bitcrushAmount:.35,hissGain:.08,hissCutoffHz:1700,presencePeakDb:7,presenceCenterHz:1800,presenceQ:1.5,compressorThresholdDb:-26,compressorRatio:7,clickEnabled:!0,clickGain:.6,clickDurationMs:50,squelchTailEnabled:!0,squelchTailGain:.09,squelchTailDurationMs:120,playbackRate:1.05,outputGain:1.15,wetMix:1}},{id:"trail-buddy",label:"Trail Buddy",family:"walkie",description:"Breezy handheld vibe — wider, hissier, like your hiking partner two ridges over.",params:{lowCutHz:380,highCutHz:2900,bandQ:.75,saturationAmount:.32,bitcrushAmount:.18,hissGain:.14,hissCutoffHz:1100,presencePeakDb:4,presenceCenterHz:1500,presenceQ:1,compressorThresholdDb:-22,compressorRatio:5,clickEnabled:!0,clickGain:.35,clickDurationMs:65,squelchTailEnabled:!0,squelchTailGain:.1,squelchTailDurationMs:180,playbackRate:.98,outputGain:1.1,wetMix:1}},{id:"am-broadcast",label:"AM Broadcast",family:"other",description:"Vintage lo-fi, no PTT click. The voice on a radio left on in the next room.",params:{lowCutHz:250,highCutHz:2200,bandQ:.9,saturationAmount:.55,bitcrushAmount:.4,hissGain:.05,hissCutoffHz:700,presencePeakDb:3,presenceCenterHz:1200,presenceQ:1.2,compressorThresholdDb:-24,compressorRatio:6,clickEnabled:!1,clickGain:0,clickDurationMs:60,squelchTailEnabled:!1,squelchTailGain:0,squelchTailDurationMs:120,playbackRate:.96,outputGain:1.05,wetMix:1}},{id:"clean-mic",label:"Clean Mic",family:"other",description:"Almost no FX — just a tiny click. A/B reference for everything else.",params:{lowCutHz:150,highCutHz:5e3,bandQ:.4,saturationAmount:.03,bitcrushAmount:0,hissGain:0,hissCutoffHz:1200,presencePeakDb:1,presenceCenterHz:1500,presenceQ:.6,compressorThresholdDb:-16,compressorRatio:2,clickEnabled:!0,clickGain:.22,clickDurationMs:45,squelchTailEnabled:!1,squelchTailGain:0,squelchTailDurationMs:80,playbackRate:1,outputGain:1,wetMix:1}}];let Ju=null;function yk(){if(Ju&&Ju.state!=="closed")return Ju;const e=window.AudioContext??window.webkitAudioContext;if(!e)throw new Error("Web Audio API is not available in this browser.");return Ju=new e,Ju}async function QD(e,t="audio/wav"){const n=atob(e),r=new Uint8Array(n.length);for(let a=0;a<n.length;a+=1)r[a]=n.charCodeAt(a);return await JD(r.buffer,t)}async function JD(e,t="audio/wav"){const n=yk();return n.state==="suspended"&&await n.resume(),await n.decodeAudioData(e.slice(0))}async function vle(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to load audio (${t.status}): ${e}`);const n=await t.arrayBuffer(),r=t.headers.get("content-type")??"audio/wav";return await JD(n,r)}function xle(e){return{...Wg,...e??{}}}function yle(e){const t=1+Math.max(0,Math.min(1,e))*14,n=2048,r=new Float32Array(new ArrayBuffer(n*4)),a=Math.tanh(t);for(let o=0;o<n;o+=1){const c=o/(n-1)*2-1;r[o]=Math.tanh(t*c)/a}return r}function ble(e){const t=Math.max(0,Math.min(1,e)),n=Math.max(4,Math.round(256*Math.pow(1-t,2.5))),r=4096,a=new Float32Array(new ArrayBuffer(r*4));for(let o=0;o<r;o+=1){const c=o/(r-1)*2-1;a[o]=Math.round(c*n)/n}return a}function OM(e){const t=e.sampleRate,n=Math.floor(2*t),r=e.createBuffer(1,n,t),a=r.getChannelData(0);let o=0;for(let c=0;c<n;c+=1){const u=Math.random()*2-1;o=o*.78+u*.22,a[c]=o}return r}function wle(e,t){const n=e.sampleRate,r=Math.max(16,Math.floor(t/1e3*n)),a=e.createBuffer(1,r,n),o=a.getChannelData(0);let c=0;for(let u=0;u<r;u+=1){const f=u/r,h=Math.pow(1-f,2.4)+(u<32?Math.pow(1-u/32,3)*.6:0),p=Math.random()*2-1;c=c*.6+p*.4,o[u]=c*h}return a}function $M(e,t,n,r,a){const o=e.createBufferSource();o.buffer=n;const c=e.createGain();return c.gain.value=a,o.connect(c).connect(t),o.start(r),{source:o,startsAt:r}}function bk(e,t={}){const n=xle(t.params),r=yk();r.state==="suspended"&&r.resume();const a=r.createBiquadFilter();a.type="highpass",a.frequency.value=n.lowCutHz,a.Q.value=n.bandQ;const o=r.createBiquadFilter();o.type="lowpass",o.frequency.value=n.highCutHz,o.Q.value=n.bandQ;const c=r.createWaveShaper();c.curve=yle(n.saturationAmount),c.oversample="2x";const u=r.createWaveShaper();u.curve=ble(n.bitcrushAmount);const f=r.createBiquadFilter();f.type="peaking",f.frequency.value=n.presenceCenterHz,f.Q.value=n.presenceQ,f.gain.value=n.presencePeakDb;const h=r.createDynamicsCompressor();h.threshold.value=n.compressorThresholdDb,h.ratio.value=n.compressorRatio,h.attack.value=.003,h.release.value=.08,h.knee.value=6;const p=r.createGain();p.gain.value=n.wetMix;const x=r.createGain();x.gain.value=1-n.wetMix;const v=r.createGain();v.gain.value=n.outputGain;const y=r.createBufferSource();y.buffer=e;const b=Math.max(.5,Math.min(2,n.playbackRate));y.playbackRate.value=b;const C=e.duration/b;y.connect(a),a.connect(o),o.connect(c),c.connect(u),u.connect(f),f.connect(h),h.connect(p),p.connect(v),y.connect(x),x.connect(v),v.connect(r.destination);const E=r.currentTime,S=40/1e3,k=n.clickEnabled?wle(r,n.clickDurationMs):null,N=E+(n.clickEnabled?S+n.clickDurationMs/1e3:0);y.start(N);let T=null;if(n.hissGain>0&&n.wetMix>0){const G=OM(r);T=r.createBufferSource(),T.buffer=G,T.loop=!0;const V=r.createBiquadFilter();V.type="highpass",V.frequency.value=n.hissCutoffHz,V.Q.value=.7;const Y=r.createGain();Y.gain.value=n.hissGain,T.connect(V).connect(Y).connect(p);const K=E,P=N+C+.18;Y.gain.setValueAtTime(0,K),Y.gain.linearRampToValueAtTime(n.hissGain,K+.03),Y.gain.setValueAtTime(n.hissGain,P-.08),Y.gain.linearRampToValueAtTime(0,P),T.start(K),T.stop(P+.02)}const R=N+C,O=n.squelchTailEnabled&&n.squelchTailGain>0&&n.wetMix>0,L=n.squelchTailDurationMs/1e3,I=R+.005,z=O?I+L:R;let _=null;if(O){const G=OM(r);_=r.createBufferSource(),_.buffer=G,_.loop=!0;const V=r.createBiquadFilter();V.type="highpass",V.frequency.value=1e3,V.Q.value=.7;const Y=r.createGain();Y.gain.value=0,_.connect(V).connect(Y).connect(p),Y.gain.setValueAtTime(0,I),Y.gain.linearRampToValueAtTime(n.squelchTailGain,I+.008),Y.gain.exponentialRampToValueAtTime(.001,z),_.start(I),_.stop(z+.02)}const U=[];if(k&&n.clickEnabled){U.push($M(r,v,k,E,n.clickGain));const G=(O?z:R)+.02;U.push($M(r,v,k,G,n.clickGain*.85))}let D=!1,q=!1;const Z=()=>{q||(q=!0,t.onEnded?.())};return{promise:new Promise(G=>{const V=O?L+.02:0,Y=(n.clickEnabled?S+n.clickDurationMs/1e3:0)+C+V+(n.clickEnabled?n.clickDurationMs/1e3+.04:0)+.02,K=setTimeout(()=>{Z(),G()},Math.ceil(Y*1e3)),P=()=>{if(!D){D=!0,clearTimeout(K);try{y.stop()}catch{}if(T)try{T.stop()}catch{}if(_)try{_.stop()}catch{}for(const H of U)try{H.source.stop()}catch{}try{y.disconnect()}catch{}try{v.disconnect()}catch{}Z(),G()}};t.signal&&(t.signal.aborted?P():t.signal.addEventListener("abort",P,{once:!0}))}),stop:()=>{try{y.stop()}catch{}if(T)try{T.stop()}catch{}if(_)try{_.stop()}catch{}for(const G of U)try{G.source.stop()}catch{}}}}function jle(e,t={}){const n=yk();n.state==="suspended"&&n.resume();const r=n.createBufferSource();r.buffer=e,r.connect(n.destination),r.start(n.currentTime);let a=!1;const o=()=>{a||(a=!0,t.onEnded?.())};return{promise:new Promise(u=>{const f=setTimeout(()=>{o(),u()},Math.ceil(e.duration*1e3)+20),h=()=>{clearTimeout(f);try{r.stop()}catch{}try{r.disconnect()}catch{}o(),u()};t.signal&&(t.signal.aborted?h():t.signal.addEventListener("abort",h,{once:!0}))}),stop:()=>{try{r.stop()}catch{}}}}const kle="http://127.0.0.1:43115",Nle="openscout-web";function iw(){return typeof window>"u"?!1:window.location.protocol!=="https:"}class vd{constructor(t=kle){this.baseUrl=t,this.client=this.createClient()}baseUrl;state="unknown";unavailableReason=null;client;get connectionState(){return this.state}get lastUnavailableReason(){return this.unavailableReason}async probe(t=1200){this.state="probing",this.unavailableReason=null,this.client=this.createClient(t);try{return await this.client.probe()?(await this.client.capabilities(),this.state="connected",!0):(this.state="unavailable",!1)}catch(n){return this.state="unavailable",this.unavailableReason=zM(n),!1}}launch(t={}){window.location.href=LM("launch",{source:t.source,returnTo:t.returnTo??DM(),context:PM(t.context)})}openSettings(t={}){window.location.href=LM("settings",{source:t.source,returnTo:t.returnTo??DM(),context:PM(t.context)})}async startLive(t={}){const n=this.client.createLiveSession();let r=null;Tle(n,t,o=>{r=o});const a=n.start({modelId:"parakeet:v3"}).then(o=>(r??=s5(o),r)).catch(o=>{throw new Error(zM(o))});return{get sessionId(){return n.id},result:a,stop:async()=>{await n.stop()},cancel:async()=>{await n.cancel().catch(()=>{})}}}createClient(t=1200){return lle({baseUrl:this.baseUrl,clientId:Nle,probeTimeout:t})}}function e5(){const e=new Error("Speech stopped.");return e.name="AbortError",e}function ed(e){return e instanceof Error&&e.name==="AbortError"}async function t5(e,t={}){const n={text:e,speed:Ale(t.speed)};t.originAppId&&(n.originAppId=t.originAppId),t.utteranceId&&(n.utteranceId=t.utteranceId),t.instructions&&(n.instructions=t.instructions),t.speechTiming?.enabled&&(n.speechTiming=t.speechTiming);const r=await fetch("/api/voice/speak",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:t.signal});if(!r.ok){const a=await r.text().catch(()=>"");try{const o=JSON.parse(a);throw new Error(o.error??`Voice returned HTTP ${r.status}`)}catch(o){throw o instanceof SyntaxError?new Error(a||`Voice returned HTTP ${r.status}`):o}}return await r.json()}function n5(e,t){const n=e?af.find(r=>r.id===e)?.params:void 0;return{...Wg,...n??{},...t??{}}}async function Sle(e,t={}){const n=await t5(e,t);if(t.signal?.aborted)throw e5();const r=await QD(n.audioBase64,n.contentType),a=n5(t.presetId,t.params);return await bk(r,{params:a,signal:t.signal}).promise,n}async function Cle(e,t={}){if(t.signal?.aborted)throw e5();const n=await QD(e.audioBase64,e.contentType),r=n5(t.presetId,t.params),a=bk(n,{params:r,signal:t.signal});return t.onPlaybackStart?.(),await a.promise,e}function Ele(e,t={}){const n=new AbortController;return{promise:Sle(e,{...t,signal:n.signal}),stop:()=>n.abort()}}function Ale(e){if(!(e===void 0||!Number.isFinite(e)))return Math.min(2,Math.max(.5,Number(e.toFixed(2))))}function Tle(e,t,n){e.onState(r=>t.onState?.(r.state)),e.onPartial(r=>t.onPartial?.(r.text)),e.onFinal(r=>{const a=s5(r);n(a),t.onFinal?.(a)})}function s5(e){return{sessionId:e.sessionId,text:e.text.trim(),durationMs:e.durationMs}}function LM(e,t){const n=new URLSearchParams;for(const[a,o]of Object.entries(t))o&&n.set(a,o);const r=n.toString();return r?`vox://${e}?${r}`:`vox://${e}`}function PM(e){if(e)return JSON.stringify(e)}function DM(){try{return window.location.origin}catch{return}}function zM(e){const t=e instanceof Error?e.message:String(e);return e instanceof gr&&e.code==="http_error"&&/origin not allowed/i.test(t)||/origin not allowed/i.test(t)?"Vox blocked this OpenScout URL. Restart OpenScout so it can register its Vox browser origin, then try again.":t||"Vox request failed."}function wk({onAppend:e,disabled:t,className:n}){const r=m.useRef(null),a=m.useRef(null),[o,c]=m.useState(()=>iw()?"probing":"idle"),[u,f]=m.useState(null);m.useEffect(()=>{let S=!1;const k=new vd;return r.current=k,iw()?(k.probe().then(N=>{S||(N?(c("idle"),f(null)):(c("unavailable"),f(k.lastUnavailableReason??"Voice unavailable — open Ranger to launch Vox.")))}),()=>{S=!0;const N=a.current;N&&(N.cancel().catch(()=>{}),a.current=null)}):()=>{S=!0;const N=a.current;N&&(N.cancel().catch(()=>{}),a.current=null)}},[]);const h=m.useCallback(async()=>{const S=r.current;if(!S)return;c("starting");let k=null;try{k=await S.startLive({onState:()=>{},onPartial:()=>{}}),a.current=k,c("recording");const N=await k.result;a.current=null,c("idle");const T=N.text?.trim();T&&e(T)}catch{a.current=null,c("idle")}},[e]),p=m.useCallback(async()=>{const S=a.current;if(S){c("processing");try{await S.stop()}catch{try{await S.cancel()}catch{}a.current=null,c("idle")}}},[]),x=m.useCallback(()=>{o==="recording"?p():o==="idle"&&h()},[o,h,p]),v=o==="starting"||o==="processing",y=o==="unavailable"||o==="probing",b=o==="unavailable"?u??"Voice unavailable":o==="probing"?"Checking voice…":o==="recording"?"Stop dictation":v?"Working…":"Dictate",C=o==="recording"?"s-dictation-mic--recording":v?"s-dictation-mic--busy":"",E=v?Kn:o==="recording"?df:Kw,A=o==="recording"?12:14;return s.jsx("button",{type:"button",title:b,"aria-label":b,"aria-pressed":o==="recording",onClick:x,disabled:t||y||v,className:["s-dictation-mic",C,n].filter(Boolean).join(" "),children:s.jsx(E,{size:A,className:v?"s-dictation-mic-spin":o==="recording"?"fill-current":""})})}const Mle=/\.(?:apng|avif|gif|jpe?g|png|svg|webp)(?:$|[?#])/iu,Rle=/\bhttps?:\/\/[^\s<>"')\]]+/giu;function _d(e){if(typeof e!="string")return null;try{const t=new URL(e.trim());return t.protocol==="http:"||t.protocol==="https:"?t.toString():null}catch{return null}}function ta(e,t){const n=e?.[t];return typeof n=="string"&&n.trim()?n.trim():null}function Ile(e){return e.mediaType.toLowerCase().startsWith("image/")}function r5(e){return Mle.test(e)}function a5(e){try{const t=new URL(e),n=[t.pathname==="/"?"":t.pathname,t.search].join("").trim();return{host:t.hostname.replace(/^www\./iu,""),detail:n||t.hostname}}catch{return{host:e,detail:e}}}function _le(e){const t=new Set,n=[];for(const r of e.matchAll(Rle)){const a=r[0]?.replace(/[.,;:!?]+$/u,""),o=_d(a);!o||t.has(o)||(t.add(o),n.push(o))}return n}function ow(e){return _d(e.url)??_d(ta(e.metadata,"url"))??_d(ta(e.metadata,"href"))}function Ole(e){const t=e.metadata??null,n=ta(t,"kind")??ta(t,"type"),r=ow(e);if(!r||n!=="link_preview"&&n!=="link-preview"&&e.mediaType!=="text/x-uri")return null;const a=a5(r);return{id:e.id,url:r,title:ta(t,"title")??a.host,description:ta(t,"description"),imageUrl:_d(ta(t,"imageUrl")??ta(t,"image")),siteName:ta(t,"siteName")??a.host}}function $le(e){const t=a5(e);return{id:e,url:e,title:t.host,description:t.detail===t.host?null:t.detail,imageUrl:r5(e)?e:null,siteName:t.host}}function Lle({src:e,alt:t}){return s.jsx("a",{className:"s-message-embed s-message-embed--image",href:e,target:"_blank",rel:"noreferrer",children:s.jsx("img",{src:e,alt:t,loading:"lazy",decoding:"async"})})}function Ple({preview:e}){return s.jsxs("a",{className:"s-message-embed s-message-embed--link",href:e.url,target:"_blank",rel:"noreferrer",children:[e.imageUrl&&s.jsx("span",{className:"s-message-embed-thumb",children:s.jsx("img",{src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"})}),s.jsxs("span",{className:"s-message-embed-copy",children:[e.siteName&&s.jsx("span",{className:"s-message-embed-site",children:e.siteName}),s.jsx("span",{className:"s-message-embed-title",children:e.title}),e.description&&s.jsx("span",{className:"s-message-embed-description",children:e.description})]})]})}function i5({message:e}){const t=e.attachments??[],n=new Set,r=[],a=[];for(const u of t){const f=ow(u);if(f&&Ile(u)){n.add(u.id),r.push({id:u.id,src:f,alt:u.fileName??"Image attachment"});continue}const h=Ole(u);h&&(n.add(u.id),a.push(h))}const o=new Set(a.map(u=>u.url));for(const u of _le(e.body))o.has(u)||(r5(u)?r.push({id:u,src:u,alt:"Embedded image"}):a.length===0&&a.push($le(u)));const c=t.filter(u=>!n.has(u.id));return r.length===0&&a.length===0&&c.length===0?null:s.jsxs("div",{className:"s-message-embeds",children:[r.map(u=>s.jsx(Lle,{src:u.src,alt:u.alt},u.id)),a.slice(0,1).map(u=>s.jsx(Ple,{preview:u},u.id)),c.map(u=>{const f=ow(u),h=u.fileName??ta(u.metadata,"title")??u.mediaType;return f?s.jsxs("a",{className:"s-message-embed s-message-embed--file",href:f,target:"_blank",rel:"noreferrer",children:[s.jsx("span",{className:"s-message-embed-title",children:h}),s.jsx("span",{className:"s-message-embed-description",children:u.mediaType})]},u.id):s.jsxs("div",{className:"s-message-embed s-message-embed--file",children:[s.jsx("span",{className:"s-message-embed-title",children:h}),s.jsx("span",{className:"s-message-embed-description",children:u.mediaType})]},u.id)})]})}const BM=[{command:"/ask",label:"/ask",description:"Ask the agent owned work with a reply",insert:"/ask "},{command:"/tell",label:"/tell",description:"Send a heads-up or quick message",insert:"/tell "},{command:"/steer",label:"/steer",description:"Steer the active turn mid-flight",insert:"/steer "},{command:"/route",label:"/route",description:"Route this to another agent",insert:"/route @"},{command:"/inbox",label:"/inbox",description:"Go to the inbox",insert:"/inbox"},{command:"/agents",label:"/agents",description:"Open the agents list",insert:"/agents"},{command:"/fleet",label:"/fleet",description:"Open the fleet view",insert:"/fleet"},{command:"/sessions",label:"/sessions",description:"Browse sessions",insert:"/sessions"},{command:"/mesh",label:"/mesh",description:"Open the mesh view",insert:"/mesh"},{command:"/activity",label:"/activity",description:"Open activity feed",insert:"/activity"},{command:"/settings",label:"/settings",description:"Open settings",insert:"/settings"}];function o5(e,t){if(t<=0)return!0;const n=e[t-1];return!n||/\s/.test(n)}function Dle(e,t){if(t===0)return null;let n=t-1;for(;n>=0;){const a=e[n];if(a==="/")break;if(!a||/\s/.test(a))return null;n-=1}if(n<0||e[n]!=="/"||!o5(e,n))return null;const r=e.slice(n+1,t);return/[^a-zA-Z0-9_-]/.test(r)?null:{start:n,query:r}}function zle(e,t){if(t===0)return null;let n=t-1;for(;n>=0;){const a=e[n];if(a==="@")break;if(!a||/\s/.test(a))return null;n-=1}if(n<0||e[n]!=="@"||!o5(e,n))return null;const r=e.slice(n+1,t);return/[^a-zA-Z0-9._/:-]/.test(r)?null:{start:n,query:r}}function Ble(e){if(!e)return null;const t=e.replace(/[\\/]+$/,"");return t?t.split(/[\\/]/).filter(Boolean).at(-1)??t:null}function Ule(e){return e.kind==="direct"&&e.agentName?e.agentName:e.kind==="direct"&&e.agentId?oa(e.agentId)??e.agentId:e.title.replace(/\s*<>\s*/g," · ")}function Fle(e){switch(e){case"status":return"Status";case"system":return"System";case"scout.dispatch":return"Dispatch";default:return null}}function mm(e){return[...e].sort((t,n)=>dk(t.createdAt,n.createdAt))}function Vle(e){return e.filter(Jc).sort((t,n)=>ul(t.startedAt,n.startedAt))[0]??null}function Zl(e,t){try{return JSON.stringify(e)===JSON.stringify(t)?e:t}catch{return t}}function UM(e,t){if(e.size!==t.size)return t;for(const n of t)if(!e.has(n))return t;return e}function FM(e,t,n){return{id:e.id,invocationId:e.invocationId,agentId:e.targetAgentId||n,agentName:null,conversationId:t,collaborationRecordId:null,state:e.state,summary:e.summary??null,startedAt:e.startedAt??null,completedAt:e.completedAt??null}}function VM(e){const t=new Set;for(const n of e.needsAttention)n.conversationId&&t.add(n.conversationId),n.agentId&&t.add(n.agentId);for(const n of e.activeAsks)n.status==="needs_attention"&&n.conversationId&&t.add(n.conversationId);return t}function Hle(){return{generatedAt:Date.now(),totals:{active:0,recentCompleted:0,needsAttention:0,activity:0},activeAsks:[],recentCompleted:[],needsAttention:[],activity:[]}}function Wle(e,t,n,r){if(!t)return[];const a=St(t.startedAt)??0,o=new Set;return e.filter(c=>c.flightId===t.id||c.invocationId===t.invocationId?!0:!r||c.agentId!==r||c.conversationId!==n?!1:(St(c.ts)??0)>=a).filter(c=>o.has(c.id)?!1:(o.add(c.id),!0)).sort((c,u)=>ul(c.ts,u.ts))}function qle(e,t,n,r){return t?e.find(a=>a.flightId===t.id||a.invocationId===t.invocationId)??e.find(a=>a.conversationId===n&&(!r||a.agentId===r)&&(a.status==="queued"||a.status==="working"))??null:null}function HM(e){const t=e.summary?.trim();if(t)return t;const n=e.title?.trim();return n||null}function Kle(e){return e===1?"1 update":`${e} updates`}function Gle(e){const{currentFlight:t,presence:n,turnActivity:r,turnAsk:a,nowMs:o}=e,c=r.find(x=>HM(x)),u=(c?HM(c):null)??a?.summary?.trim()??t?.summary?.trim()??n.detail,f=St(t?.startedAt)??St(a?.startedAt),h=St(c?.ts)??St(a?.updatedAt)??f,p=Math.max(r.length,a?.acknowledgedAt?1:0,t?1:0);return{latest:u,activityLabel:Kle(p),elapsedLabel:f?Ie(f,o):"now",lastActivityLabel:h?Ie(h,o):"now"}}function Zle(e){const t=e.metadata?.scoutDispatch;if(!t||typeof t!="object")return null;const n=t;return!n.id||!n.kind||!Array.isArray(n.candidates)?null:n}function lw(e,t){if(e.class==="operator"||e.actorId==="operator")return!0;const n=e.actorName?.toLowerCase()??"";return n===t.toLowerCase()||n==="operator"||n==="you"}function Yle(e){const t=e.metadata?.returnAddress;if(!t||typeof t!="object")return null;const n=t.actorId;return typeof n=="string"&&n.trim().length>0?n.trim():null}function lb(e,t){const n=e.metadata?.returnAddress;if(!n||typeof n!="object")return null;const r=n[t];return typeof r=="string"&&r.trim().length>0?r.trim():null}function l5(e){const t=e?.trim();return t?t.replace(/^@+/,"").toLowerCase():null}function Xle(e){return new Set([e.id,e.handle,e.selector,e.defaultSelector,e.conversationId].map(l5).filter(t=>t!==null))}function cw(e,t){for(const n of t){const r=l5(n);if(!r)continue;const a=e.filter(o=>Xle(o).has(r));if(a.length===1)return a[0]}return null}function Qle(e,t,n){const r=e.actorId??Yle(e),a=cw(t,[r,lb(e,"selector"),lb(e,"defaultSelector"),lb(e,"handle")]);if(a)return a;if(n){const c=cw(t,[n]);if(c)return c}if(!e.actorName)return null;const o=t.filter(c=>c.name===e.actorName);return o.length===1?o[0]:null}function Jle(e,t){return e.reduce((n,r)=>{if(lw(r,t))return n;const a=St(r.createdAt);return a===null?n:n===null||a>n?a:n},null)}function ece(e,t){switch(t){case"queued":return`${e} has your message and is waiting to start.`;case"waking":return`${e} is waking up now.`;case"waiting":return`${e} is thinking through the request.`;case"running":return`${e} is working on your request.`;default:return`${e} is working on it.`}}function tce(e,t,n){return!e||e==="operator"?n:t.find(a=>a.id===e)?.name??oa(e)??e}function nce(e){const{agentName:t,agentState:n,sending:r,currentFlight:a,showWorkingTurn:o,workingTurnIsGone:c,workingTurnHasNoRecentUpdate:u,nowMs:f}=e;if(r&&!a)return{label:"Sending",detail:`Handing your message to ${t}.`,tone:"pending",showStrip:!0,showTyping:!1};if(a&&o&&u){const h=Ie(a.startedAt,f),p=h?`No update from ${t} for ${h}.`:`No recent update from ${t}.`;return{label:c?"Gone":"No recent update",detail:c?`${p} Agent is offline.`:p,tone:"quiet",showStrip:!0,showTyping:!0}}if(a&&o){const h=a.summary?.trim()||ece(t,a.state);switch(a.state){case"queued":return{label:"Queued",detail:h,tone:"pending",showStrip:!0,showTyping:!0};case"waking":return{label:"Coming online",detail:h,tone:"working",showStrip:!0,showTyping:!0};case"waiting":return{label:"Thinking",detail:h,tone:"working",showStrip:!0,showTyping:!0};default:return{label:"Working",detail:h,tone:"working",showStrip:!0,showTyping:!0}}}return ha(n)?{label:"Ready",detail:`${t} is ready.`,tone:"idle",showStrip:!1,showTyping:!1}:{label:"Not ready",detail:`${t} is not ready right now. Sending a message will try to wake it up.`,tone:"offline",showStrip:!0,showTyping:!1}}function sce(e,t){switch(e.tone){case"pending":return"var(--accent)";case"working":return"var(--green)";case"quiet":return"var(--amber)";case"offline":return"var(--dim)";default:return yn(t)}}function rce(){return s.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("path",{d:"m3 11 18-8-8 18-2.8-7.2L3 11Z"}),s.jsx("path",{d:"M10.2 13.8 21 3"})]})}function ace(){return s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})}function ice(){return s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:[s.jsx("path",{d:"M4 4l8 8"}),s.jsx("path",{d:"M12 4l-8 8"})]})}function oce(e){return e.startsWith("conv.")?`conv.${e.slice(5,13)}`:e.startsWith("channel.")?`#${e.slice(8)}`:e.startsWith("dm.")?"legacy DM":e.length>22?`${e.slice(0,10)}...${e.slice(-7)}`:e}function lce(e){return e.startsWith("conv.")?"UID":"ID"}function eu({conversationId:e,initialComposeMode:t,initialDraft:n,navigate:r,embedded:a,showBackNav:o=!0}){const{agents:c,route:u}=qe(),f=zs(u),h=m.useMemo(()=>no(c,f),[c,f]),[p,x]=m.useState(null),[v,y]=m.useState([]),[b,C]=m.useState(null),[E,A]=m.useState([]),[S,k]=m.useState(null),[N,T]=m.useState(new Set),[R,O]=m.useState([]),[L,I]=m.useState(null),z=m.useRef(null),_=m.useRef(null),U=m.useRef(new Set),D=m.useRef(null),q=m.useRef(0),Z=m.useRef(null),$=m.useRef(null),G=Bg(e),V=p?p.agentId:G,Y=p?p.kind==="direct":G!==null,K=m.useMemo(()=>V?h.find(W=>W.id===V)??null:null,[h,V]),[P,H]=m.useState(new Set),[B]=m.useState(()=>vk());m.useEffect(()=>{ue("/api/fleet").then(W=>{const ee=VM(W);H(de=>UM(de,ee))}).catch(()=>{})},[]);const Q=m.useCallback(async()=>{I(null);try{const W=await ue(`/api/session/${encodeURIComponent(e)}`).catch(()=>null);x(jn=>Zl(jn,W));const ee=W?.agentId??G,de=W?.id&&W.id!==e?W.id:W?.kind==="direct"&&ee&&ee.startsWith("local-session-agent-")?Qn(ee):e;if(de!==e){r({view:"conversation",conversationId:de,...t?{composeMode:t}:{}});return}const[Me,We,Qe]=await Promise.all([ue(`/api/messages?conversationId=${encodeURIComponent(de)}&limit=300`),ue(`/api/flights?conversationId=${encodeURIComponent(de)}`),ue("/api/fleet?limit=24&activityLimit=160").catch(()=>Hle())]),lt=mm(Me),ft=lt.filter(jn=>!aw(jn));y(jn=>Zl(jn,ft)),xk(de);const Wt=lt.at(-1);Wt&&$.current!==Wt.id&&($.current=Wt.id,ue(`/api/conversations/${encodeURIComponent(de)}/read-cursor`,{method:"POST",body:JSON.stringify({lastReadMessageId:Wt.id})}).catch(()=>{$.current===Wt.id&&($.current=null)})),O(jn=>Zl(jn,We)),U.current=new Set(We.map(jn=>jn.invocationId));const Zt=Vle(We),kt=Zt?.agentId??ee??null,yt=Wle(Qe.activity,Zt,de,kt),Cn=qle(Qe.activeAsks,Zt,de,kt);C(jn=>Zl(jn,Zt)),A(jn=>Zl(jn,yt)),k(jn=>Zl(jn,Cn));const wa=VM(Qe);H(jn=>UM(jn,wa))}catch(W){I(W instanceof Error?W.message:String(W))}},[e,t,G,r]);m.useEffect(()=>{Q()},[Q]),m.useEffect(()=>{$.current=null},[e]),m.useEffect(()=>{D.current=b},[b]);const oe=m.useCallback(()=>{b?.id&&T(W=>{const ee=new Set(W);return ee.add(b.id),ee})},[b?.id]),[ne,X]=m.useState(()=>n??""),[ae,be]=m.useState(!1),[_e,xe]=m.useState("operator"),[pe,te]=m.useState({open:!1,query:"",triggerStart:-1,index:0}),[ve,he]=m.useState({open:!1,query:"",triggerStart:-1,index:0}),[ke,Ne]=m.useState(null),[Fe,Ee]=m.useState(t==="ask"?"ask":"tell"),[Le,Te]=m.useState(!1),[Pe,De]=m.useState(""),[ze,$e]=m.useState(null),[st,rt]=m.useState(!1);m.useEffect(()=>{Ee(Y&&t==="ask"?"ask":"tell")},[e,t,Y]),m.useEffect(()=>{Te(!1),De(""),$e(null),rt(!1)},[e]),m.useEffect(()=>{if(!n)return;const W=`${e}:${n}`;Z.current!==W&&(Z.current=W,X(n),requestAnimationFrame(()=>_.current?.focus()))},[e,n]);const Xe=m.useMemo(()=>{const W=new Set,ee=[];for(const de of h){const Me=de.handle?.trim().replace(/^@+/,"")??oa(de.id)??de.id;if(!Me)continue;const We=Me.toLowerCase();W.has(We)||(W.add(We),ee.push({id:de.id,label:Me,name:de.name??Me,handle:Me}))}return ee.sort((de,Me)=>de.handle.localeCompare(Me.handle))},[h]),dt=m.useMemo(()=>{if(!pe.open)return[];const W=pe.query.toLowerCase();return W?BM.filter(ee=>ee.command.toLowerCase().startsWith("/"+W)||ee.command.toLowerCase().includes(W)):BM},[pe.open,pe.query]),jt=m.useMemo(()=>{if(!ve.open)return[];const W=ve.query.toLowerCase();return W?Xe.filter(ee=>ee.handle.toLowerCase().includes(W)||ee.name.toLowerCase().includes(W)).slice(0,8):Xe.slice(0,8)},[ve.open,ve.query,Xe]),At=m.useCallback(()=>{te(W=>W.open?{...W,open:!1}:W),he(W=>W.open?{...W,open:!1}:W)},[]),mt=m.useCallback((W,ee)=>{const de=Dle(W,ee);te(de?We=>({open:!0,query:de.query,triggerStart:de.start,index:We.open&&We.triggerStart===de.start?We.index:0}):We=>We.open?{...We,open:!1}:We);const Me=zle(W,ee);he(Me?We=>({open:!0,query:Me.query,triggerStart:Me.start,index:We.open&&We.triggerStart===Me.start?We.index:0}):We=>We.open?{...We,open:!1}:We)},[]),Ht=m.useCallback(W=>{const ee=_.current,de=pe.triggerStart;if(de<0)return;const Me=ee?.selectionStart??ne.length,We=ne.slice(0,de),Qe=ne.slice(Me),lt=W.insert,ft=`${We}${lt}${Qe}`;X(ft),te(Wt=>({...Wt,open:!1})),requestAnimationFrame(()=>{const Wt=_.current;if(!Wt)return;const Zt=We.length+lt.length;Wt.focus(),Wt.setSelectionRange(Zt,Zt)})},[ne,pe.triggerStart]),ie=m.useCallback(W=>{const ee=_.current,de=ve.triggerStart;if(de<0)return;const Me=ee?.selectionStart??ne.length,We=ne.slice(0,de),Qe=ne.slice(Me),lt=Qe.length===0||!Qe.startsWith(" "),ft=`@${W.handle}${lt?" ":""}`,Wt=`${We}${ft}${Qe}`;X(Wt),he(Zt=>({...Zt,open:!1})),requestAnimationFrame(()=>{const Zt=_.current;if(!Zt)return;const kt=We.length+ft.length;Zt.focus(),Zt.setSelectionRange(kt,kt)})},[ne,ve.triggerStart]);m.useEffect(()=>{const W=_.current;if(!W)return;W.style.height="0px";const ee=Math.min(Math.max(W.scrollHeight,40),160);W.style.height=`${ee}px`,W.style.overflowY=W.scrollHeight>ee?"auto":"hidden"},[ne]),m.useEffect(()=>{ue("/api/user").then(W=>xe(W.name)).catch(()=>{})},[]);const ce=m.useMemo(()=>Jle(v,_e),[v,_e]);m.useEffect(()=>{ke===null||ce===null||ce>=ke&&Ne(null)},[ke,ce]);const Ae=m.useMemo(()=>Foe(b),[b]),Be=Date.now(),tt=WD(b,Be),at=Voe(b,ce,Be),Oe=b?N.has(b.id):!1,He=Ae&&!at&&!Oe,ot=He&&tt,nt=ot&&Ge(K?.state??null)==="not_ready",$t=Y&&(ae||ke!==null||He),Tn=Y&&(ae||ke!==null||He&&!ot),fn=LD({name:K?.name,agentName:p?.agentName,id:V,title:p?.title}),Gt=m.useMemo(()=>Y?nce({agentName:fn,agentState:K?.state??null,sending:ae,currentFlight:b,showWorkingTurn:He,workingTurnIsGone:nt,workingTurnHasNoRecentUpdate:ot,nowMs:Be}):{label:"Open",detail:"",tone:"idle",showStrip:!1,showTyping:!1},[K?.state,fn,b,Be,Y,ae,He,nt,ot]),Rt=Gt.tone==="quiet",Gn=Rt?Gt.label:"Live",On=m.useMemo(()=>Gle({currentFlight:b,presence:Gt,turnActivity:E,turnAsk:S,nowMs:Be}),[b,Be,Gt,E,S]),re=["s-thread-msg-card","s-thread-msg-working-card","s-thread-msg-card--avatar-row",Rt?"s-thread-msg-working-card--quiet":null].filter(Boolean).join(" "),Re=["s-thread-msg-kind",Rt?"s-thread-msg-kind--quiet":null,nt?"s-thread-msg-kind--gone":null].filter(Boolean).join(" "),Ve=["s-thread-no-recent-update-indicator",nt?"s-thread-no-recent-update-indicator--gone":null].filter(Boolean).join(" "),Ct=["s-thread-turn-snapshot",Rt?"s-thread-turn-snapshot--quiet":null].filter(Boolean).join(" "),Ft=["s-thread-turn-snapshot-pulse",Rt?"s-thread-turn-snapshot-pulse--quiet":null].filter(Boolean).join(" "),$n=["s-thread-presence-line",Rt?"s-thread-presence-line--quiet":null].filter(Boolean).join(" "),tn=["s-thread-presence-strip",Rt?"s-thread-presence-strip--quiet":null].filter(Boolean).join(" "),Lt=Rt?Gt.detail:`${fn}: ${On.latest}`,Et=p?Ule(p):fn,Tt=p?.id??e,Jn=p?.alias?.trim()||null,sr=Ble(p?.workspaceRoot),ga=m.useMemo(()=>{const W=[{id:"operator",name:"You",title:_e,agent:null,operator:!0}],ee=p?p.participantIds.filter(de=>de!=="operator"):V?[V]:[];for(const de of ee){const Me=cw(h,[de]);W.push({id:de,name:Me?.name??oa(de)??de,title:Me?.id??de,agent:Me})}return W},[V,_e,h,p]),so=ga.slice(0,4),ps=Math.max(ga.length-so.length,0),Es=m.useMemo(()=>(!P.has(e)&&!(V&&P.has(V)),null),[e,V,P]);Vt(m.useCallback(W=>{if(W.kind==="message.posted"){const ee=W.payload?.message;if(!ee||ee.conversationId!==e)return;const de=ee.actorId==="operator",Me=Y&&ee.actorId===V,We={id:ee.id,conversationId:ee.conversationId,actorId:ee.actorId,actorName:Me?fn:tce(ee.actorId,h,_e),body:ee.body,createdAt:ee.createdAt,class:de?"operator":ee.class,attachments:ee.attachments,metadata:ee.metadata};if(aw(We))return;if(y(Qe=>{if(Qe.some(lt=>lt.id===ee.id))return Qe;if(de){const lt=Qe.findIndex(ft=>ft.id.startsWith("optimistic-")&&ft.body===ee.body&&Math.abs((St(ft.createdAt)??0)-(St(ee.createdAt)??0))<=6e4);if(lt!==-1){const ft=[...Qe];return ft[lt]=We,mm(ft)}}return mm([...Qe,We])}),Me){const Qe=St(ee.createdAt)??Date.now();Ne(lt=>lt===null||Qe<lt||Jc(D.current)?lt:null),C(lt=>Hoe(lt)?null:lt)}return}if(W.kind==="invocation.requested"){const ee=W.payload?.invocation;if(!ee||ee.targetAgentId!==V||ee.conversationId!==e)return;U.current.add(ee.id),A([]),k(null),Ne(de=>de??Date.now());return}if(W.kind==="flight.updated"){const ee=W.payload?.flight;if(!ee||ee.targetAgentId!==V||!(U.current.has(ee.invocationId)||D.current?.id===ee.id))return;if(VD.has(ee.state)){C(Qe=>Qe?.id===ee.id?null:Qe),A([]),k(null),Ne(null),Q();return}U.current.add(ee.invocationId);const Me=D.current?.id===ee.id,We=FM(ee,e,V??"");HD(We)&&Ne(null),C(We),Me||(A([]),k(null));return}W.kind!=="agent.endpoint.upserted"&&W.kind==="unknown"&&Q()},[V,fn,e,Y,Q,_e,h])),m.useEffect(()=>{if(!$t)return;const W=setInterval(()=>{Q()},5e3);return()=>clearInterval(W)},[$t,Q]),m.useEffect(()=>{const W=()=>{if(document.visibilityState!=="visible")return;const ee=Date.now();ee-q.current<1e3||(q.current=ee,Q())};return window.addEventListener("focus",W),document.addEventListener("visibilitychange",W),()=>{window.removeEventListener("focus",W),document.removeEventListener("visibilitychange",W)}},[Q]);const va=v.length+(Gt.showTyping?1:0),Bs=m.useRef(0),rr=m.useRef(!1);m.useEffect(()=>{if(va>Bs.current){const W=rr.current?"smooth":"instant";z.current?.scrollIntoView({behavior:W}),rr.current=!0}Bs.current=va},[va]);const[,Cr]=m.useState(0);m.useEffect(()=>{const W=setInterval(()=>Cr(ee=>ee+1),15e3);return()=>clearInterval(W)},[]);const ar=async(W,ee)=>{const de=W.trim();if(!de||ae)return;const Me=ee?.forceMode??Fe,We=Y?Tn?"steer":Me:"tell",Qe=Date.now(),lt={id:`optimistic-${Qe}`,conversationId:e,actorId:"operator",actorName:_e,body:de,createdAt:Qe,class:"operator"};be(!0),Y&&Ne(Qe),I(null),y(ft=>mm([...ft,lt]));try{const ft=await ue(We==="ask"?"/api/ask":"/api/send",{method:"POST",body:JSON.stringify({body:de,conversationId:e})}),Wt=ft.conversationId?.trim();if(Wt&&Wt!==e){y(Zt=>Zt.filter(kt=>kt.id!==lt.id)),Ne(null),r({view:"conversation",conversationId:Wt});return}ft.flight&&(U.current.add(ft.flight.invocationId),C(FM(ft.flight,e,V??"")),A([]),k(null))}catch(ft){y(Wt=>Wt.filter(Zt=>Zt.id!==lt.id)),Ne(null),I(ft instanceof Error?ft.message:String(ft))}finally{be(!1)}},un=async()=>{const W=ne.trim();W&&(X(""),await ar(W))},As=async()=>{if(V)try{await ue("/api/agents/"+encodeURIComponent(V)+"/interrupt",{method:"POST",body:JSON.stringify({})})}catch{}},fl=Gt.tone==="working"||Gt.tone==="pending",ir=Y?Tn?"steer":Fe:"tell",Vr=Y?"Reply — or type / to route, @ to mention an agent, ? to ask a question":p?.kind==="channel"?`Message #${pk(p)}...`:`Message ${Et}...`,Er=!ne.trim()&&fl,xa=Xc(),ya=m.useCallback((W,ee)=>{const de=window.getSelection()?.toString().trim(),Me=[];de&&(Me.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>{Nn(de)}}),Me.push({kind:"separator"})),Me.push({kind:"action",label:"Copy Message",onSelect:()=>{Nn(ee.body)}}),ee.actorName&&!lw(ee,_e)&&Me.push({kind:"action",label:"Copy Agent ID",onSelect:()=>{Nn(ee.actorName??"")}}),Me.push({kind:"separator"}),Me.push({kind:"action",label:"Copy Message ID",onSelect:()=>{Nn(ee.id)}}),xa(W,Me)},[_e,xa]),nu=async(W,ee)=>{const de=`@${ee.agentId} `,Me=ne.trim();if(Me){X(""),await ar(`${de}${Me}`,{forceMode:"tell"});return}X(de),_.current?.focus()},gs=m.useMemo(()=>{if(!p)return[];const W=new Set(p.participantIds);return h.filter(ee=>!W.has(ee.id)&&!ee.retiredFromFleet).sort((ee,de)=>ee.name.localeCompare(de.name))},[p,h]);m.useEffect(()=>{Le&&De(W=>W&&gs.some(ee=>ee.id===W)?W:gs[0]?.id??"")},[Le,gs]);const ba=!!(p&&["direct","group_direct","channel"].includes(p.kind)&&gs.length>0),Us=m.useCallback(async()=>{if(!p)return;const W=Pe.trim();if(W){rt(!0),$e(null);try{const ee=await ue(`/api/conversations/${encodeURIComponent(p.id)}/members`,{method:"POST",body:JSON.stringify({actorId:W})});ee.session?x(ee.session):x(de=>de&&{...de,kind:ee.kind,participantIds:ee.participantIds}),Te(!1),De(""),await Q()}catch(ee){$e(ee instanceof Error?ee.message:String(ee))}finally{rt(!1)}}},[Pe,Q,p]);return s.jsx("div",{className:`s-thread-layout${a?" s-thread-layout--embedded":""}`,children:s.jsxs("div",{className:"s-thread-center",children:[!a&&s.jsxs("div",{className:"s-thread-center-header",onClick:W=>{W.target?.closest("button,a,input,select,textarea")||Y&&wt(r,{view:"agent-info",conversationId:Tt},{returnTo:u})},style:Y?{cursor:"pointer"}:void 0,onContextMenu:W=>{const ee=[{kind:"action",label:"Copy Title",onSelect:()=>{Nn(Et)}}];V&&ee.push({kind:"action",label:"Copy Agent ID",onSelect:()=>{Nn(V)}}),ee.push({kind:"action",label:"Copy Conversation ID",onSelect:()=>{Nn(Tt)}}),xa(W,ee)},children:[o&&s.jsx(zr,{slot:"conversation",fallback:{view:"inbox"},navigate:r,label:"Back",className:"s-thread-header-back"}),s.jsx("div",{className:"s-thread-center-header-info",children:s.jsx("span",{className:"s-thread-center-header-name",children:Et})}),s.jsxs("div",{className:"s-thread-center-header-right",children:[so.length>0&&s.jsxs("div",{className:"s-thread-participants","aria-label":"Conversation participants",children:[so.map(W=>{const ee={background:Xt(W.name)},de=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"s-thread-participant-avatar",style:ee,"aria-hidden":"true",children:W.name[0]?.toUpperCase()??"?"}),s.jsx("span",{className:"s-thread-participant-name",children:W.name})]});return W.agent?s.jsx("button",{type:"button",className:"s-thread-participant-pill s-thread-participant-pill--button",title:`Open ${W.name} profile`,onClick:()=>wt(r,{view:"agent-info",conversationId:Qn(W.agent.id)},{returnTo:u}),children:de},W.id):s.jsx("span",{className:"s-thread-participant-pill",title:W.title,children:de},W.id)}),ps>0&&s.jsxs("span",{className:"s-thread-participant-overflow",children:["+",ps]})]}),!a&&ba&&s.jsx("button",{type:"button",className:"s-thread-add-participant-trigger",onClick:()=>{$e(null),Te(W=>!W)},title:"Add participant","aria-label":"Add participant",children:s.jsx(d8,{size:14,strokeWidth:1.9,"aria-hidden":"true"})})]})]}),!a&&p&&s.jsxs("div",{className:"s-thread-identity-row",children:[s.jsxs("button",{type:"button",className:"s-thread-identity-chip",title:Tt,onClick:()=>{Nn(Tt)},children:[s.jsx("span",{children:lce(Tt)}),s.jsx("strong",{children:oce(Tt)})]}),Jn&&s.jsxs("span",{className:"s-thread-identity-chip",title:Jn,children:[s.jsx("span",{children:"Alias"}),s.jsx("strong",{children:Jn})]})]}),!a&&Le&&ba&&s.jsxs("form",{className:"s-thread-add-participant",onSubmit:W=>{W.preventDefault(),Us()},children:[s.jsxs("div",{className:"s-thread-add-participant-row",children:[s.jsxs("div",{className:"s-thread-add-participant-field",children:[s.jsx("label",{className:"s-thread-add-participant-label",htmlFor:"thread-add-participant-select",children:"Agent"}),s.jsx("select",{id:"thread-add-participant-select",className:"s-thread-add-participant-select",value:Pe,onChange:W=>De(W.target.value),autoFocus:!0,children:gs.map(W=>s.jsx("option",{value:W.id,children:W.name},W.id))})]}),s.jsxs("div",{className:"s-thread-add-participant-actions",children:[s.jsx("button",{type:"button",className:"s-btn s-btn-sm",onClick:()=>{Te(!1),$e(null)},disabled:st,children:"Cancel"}),s.jsx("button",{type:"submit",className:"s-btn s-btn-primary s-btn-sm",disabled:st||Pe.trim().length===0,children:st?"Adding...":"Add"})]})]}),ze&&s.jsx("div",{className:"s-thread-add-participant-error",children:ze})]}),Es&&s.jsxs("div",{className:"s-thread-pinned-ask",children:[s.jsx("div",{className:"s-thread-pinned-ask-label",children:"Pinned ask · Awaiting operator"}),s.jsx("div",{className:"s-thread-pinned-ask-body",children:Es.task}),s.jsxs("div",{className:"s-thread-pinned-ask-routing",children:[s.jsx("span",{children:Es.agentName??oa(Es.agentId)??Es.agentId}),s.jsx("span",{className:"s-thread-pinned-ask-routing-arrow",children:"→"}),s.jsx("span",{children:"You"})]}),s.jsxs("div",{className:"s-thread-pinned-ask-actions",children:[s.jsx("button",{type:"button",className:"s-ops-btn s-ops-btn--primary",onClick:()=>{_.current?.focus()},children:"Answer"}),s.jsx("button",{type:"button",className:"s-ops-btn",children:"Defer"}),s.jsx("button",{type:"button",className:"s-ops-btn",children:"Route"})]}),s.jsx("div",{className:"s-thread-pinned-ask-strip"})]}),Gt.showStrip&&s.jsxs("div",{className:`s-thread-status s-thread-status--${Gt.tone}`,"aria-live":"polite",children:[s.jsx("span",{className:"s-thread-status-dot",style:{background:sce(Gt,K?.state??null)}}),s.jsxs("div",{className:"s-thread-status-copy",children:[s.jsx("span",{className:"s-thread-status-label",children:Gt.label}),s.jsx("span",{className:"s-thread-status-detail",children:Gt.detail})]})]}),L&&s.jsx("p",{className:"s-thread-error",children:L}),s.jsxs("div",{className:"s-thread-feed",children:[s.jsx("div",{className:"s-thread-feed-spacer"}),v.length===0?s.jsxs("div",{className:"s-thread-empty",children:[s.jsx("div",{className:"s-thread-empty-glyph","aria-hidden":"true",children:Y?"@":"#"}),s.jsx("p",{children:Et}),s.jsx("p",{children:Y?"No messages yet. Use Tell for quick updates or Ask to create owned work with a reply.":"No messages yet. Start the conversation below."}),(sr||p?.currentBranch)&&s.jsxs("div",{className:"s-thread-empty-chips",children:[sr&&s.jsx("span",{className:"s-thread-empty-chip",children:sr}),p?.currentBranch&&s.jsx("span",{className:"s-thread-empty-chip",children:p.currentBranch})]})]}):v.map((W,ee)=>{const de=lw(W,_e),Me=Zle(W),We=Me?"scout.dispatch":W.class,Qe=Fle(We),lt=We==="status",ft=ee===0||!FD(v[ee-1]?.createdAt,W.createdAt),Wt=Di(W.createdAt),Zt=de?null:Qle(W,h,V),kt=de?_e.toLowerCase():Zt?.handle??null;return s.jsxs("div",{className:["s-thread-feed-block",de&&"s-thread-feed-block--you",ft&&"s-thread-feed-block--full-width"].filter(Boolean).join(" "),children:[ft&&s.jsxs("div",{className:"s-thread-day-divider","aria-label":tw(W.createdAt),children:[s.jsx("span",{className:"s-thread-day-line","aria-hidden":"true"}),s.jsx("span",{className:"s-thread-day-label",children:tw(W.createdAt)}),s.jsx("span",{className:"s-thread-day-line","aria-hidden":"true"})]}),s.jsx("article",{id:`msg-${W.id}`,className:["s-thread-msg",de&&"s-thread-msg--you",lt&&"s-thread-msg--tool"].filter(Boolean).join(" "),"data-class":We,onContextMenu:yt=>ya(yt,W),children:s.jsx("div",{className:"s-thread-msg-card",children:s.jsxs("div",{className:"s-thread-msg-card-content",children:[s.jsxs("div",{className:"s-thread-msg-header",children:[s.jsxs("div",{className:"s-thread-msg-meta",children:[(()=>{const yt=!de&&Zt?()=>wt(r,{view:"agent-info",conversationId:Qn(Zt.id)},{returnTo:u}):null,Cn=(de?_e[0]:W.actorName?.[0]??"?").toUpperCase(),wa={"--size":"24px",background:Xt(de?_e:W.actorName??"?")};return yt?s.jsx("button",{type:"button",className:"s-ops-avatar s-thread-msg-avatar s-thread-msg-avatar--nav",style:wa,onClick:yt,"aria-label":`View profile for ${W.actorName??"agent"}`,title:`View profile for ${W.actorName??"agent"}`,children:Cn}):s.jsx("div",{className:"s-ops-avatar s-thread-msg-avatar",style:wa,children:Cn})})(),!de&&Zt?s.jsx("button",{type:"button",className:"s-thread-msg-actor s-thread-msg-actor--nav",onClick:()=>wt(r,{view:"agent-info",conversationId:Qn(Zt.id)},{returnTo:u}),title:`View profile for ${W.actorName}`,children:W.actorName}):s.jsx("span",{className:"s-thread-msg-actor",children:de?_e:W.actorName}),kt&&s.jsxs("span",{className:"s-thread-msg-handle",children:["@",kt]}),Qe&&s.jsx("span",{className:"s-thread-msg-kind",children:Qe})]}),s.jsx("span",{className:"s-thread-msg-time",title:Wt,children:Ie(W.createdAt)}),s.jsx("button",{type:"button",className:"s-thread-msg-permalink","aria-label":"Copy link to message",title:"Copy link to message",onClick:()=>{const yt=`${window.location.origin}${window.location.pathname}#msg-${W.id}`;navigator.clipboard.writeText(yt)},children:s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("path",{d:"M6.5 9.5a2.5 2.5 0 0 0 3.54 0l2.12-2.12a2.5 2.5 0 0 0-3.54-3.54l-.7.7"}),s.jsx("path",{d:"M9.5 6.5a2.5 2.5 0 0 0-3.54 0L3.84 8.62a2.5 2.5 0 0 0 3.54 3.54l.7-.7"})]})})]}),s.jsx("div",{className:"s-thread-msg-body",title:Wt,children:s.jsx(gk,{text:W.body})}),s.jsx(i5,{message:W}),Me&&Me.candidates.length>0&&s.jsx("div",{className:"s-thread-dispatch",children:Me.candidates.map(yt=>s.jsxs("button",{type:"button",className:"s-thread-dispatch-tile",onClick:()=>{nu(Me,yt)},children:[s.jsxs("span",{className:"s-thread-dispatch-tile-id",children:["@",yt.agentId]}),s.jsx("span",{className:"s-thread-dispatch-tile-state",children:yt.endpointState}),s.jsx("span",{className:"s-thread-dispatch-tile-meta",children:[yt.workspace,yt.node,yt.projectRoot].filter(Boolean).join(" · ")||yt.displayName})]},yt.agentId))})]})})})]},W.id)}),Gt.showTyping&&s.jsx("div",{className:"s-thread-feed-block",children:s.jsx("div",{className:"s-thread-msg","aria-live":"polite",children:s.jsxs("div",{className:re,children:[s.jsx("div",{className:"s-ops-avatar s-thread-msg-avatar",style:{"--size":"28px",background:Xt(fn)},children:fn[0]?.toUpperCase()??"?"}),s.jsxs("div",{className:"s-thread-msg-card-content",children:[s.jsxs("div",{className:"s-thread-msg-header",children:[s.jsxs("div",{className:"s-thread-msg-meta",children:[s.jsx("span",{className:"s-thread-msg-actor",children:fn}),s.jsx("span",{className:Re,children:Gn})]}),s.jsx("span",{className:"s-thread-msg-time",title:b?.startedAt?Di(b.startedAt):"now",children:b?.startedAt?Ie(b.startedAt):"now"}),Rt&&s.jsx("button",{type:"button",className:"s-thread-msg-dismiss","aria-label":"Dismiss no recent update turn",title:"Dismiss no recent update turn",onClick:oe,children:s.jsx(ice,{})})]}),s.jsxs("div",{className:"s-thread-msg-working-body",children:[s.jsxs("div",{className:Ct,children:[Rt?s.jsx("span",{className:Ve,"aria-hidden":"true"}):s.jsx("span",{className:Ft,"aria-hidden":"true"}),s.jsxs("div",{className:"s-thread-turn-snapshot-main",children:[s.jsx("span",{className:"s-thread-turn-snapshot-label",children:"Latest"}),s.jsx("span",{className:"s-thread-msg-working-copy",children:On.latest})]})]}),s.jsxs("dl",{className:"s-thread-turn-snapshot-stats",children:[s.jsxs("div",{className:"s-thread-turn-snapshot-stat",children:[s.jsx("dt",{children:"Activity"}),s.jsx("dd",{children:On.activityLabel})]}),s.jsxs("div",{className:"s-thread-turn-snapshot-stat",children:[s.jsx("dt",{children:"Elapsed"}),s.jsx("dd",{children:On.elapsedLabel})]}),s.jsxs("div",{className:"s-thread-turn-snapshot-stat",children:[s.jsx("dt",{children:"Last"}),s.jsx("dd",{children:On.lastActivityLabel})]})]})]})]})]})})}),s.jsx("div",{ref:z})]}),Gt.showTyping&&s.jsxs("div",{className:$n,children:[s.jsx("div",{className:"s-thread-presence-line-avatars",children:s.jsx("div",{className:"s-ops-avatar",style:{"--size":"20px",background:Xt(fn)},children:fn[0]?.toUpperCase()??"?"})}),s.jsx("span",{className:"s-thread-presence-line-label",children:Lt}),s.jsx("div",{className:tn})]}),s.jsx("form",{className:"s-thread-compose",onSubmit:W=>{W.preventDefault(),un()},children:s.jsxs("div",{className:"s-thread-compose-shell",children:[pe.open&&dt.length>0&&s.jsxs("div",{className:"s-thread-compose-suggest",role:"listbox","aria-label":"Slash commands",children:[s.jsx("div",{className:"s-thread-compose-suggest-label",children:"Slash commands"}),dt.map((W,ee)=>s.jsxs("button",{type:"button",role:"option","aria-selected":ee===pe.index,className:["s-thread-compose-suggest-item",ee===pe.index&&"s-thread-compose-suggest-item--active"].filter(Boolean).join(" "),onMouseDown:de=>{de.preventDefault(),Ht(W)},onMouseEnter:()=>te(de=>({...de,index:ee})),children:[s.jsx("span",{className:"s-thread-compose-suggest-cmd",children:W.label}),s.jsx("span",{className:"s-thread-compose-suggest-desc",children:W.description})]},W.command))]}),ve.open&&jt.length>0&&s.jsxs("div",{className:"s-thread-compose-suggest",role:"listbox","aria-label":"Mention agents",children:[s.jsx("div",{className:"s-thread-compose-suggest-label",children:"Mention agent"}),jt.map((W,ee)=>s.jsxs("button",{type:"button",role:"option","aria-selected":ee===ve.index,className:["s-thread-compose-suggest-item",ee===ve.index&&"s-thread-compose-suggest-item--active"].filter(Boolean).join(" "),onMouseDown:de=>{de.preventDefault(),ie(W)},onMouseEnter:()=>he(de=>({...de,index:ee})),children:[s.jsx("span",{className:"s-ops-avatar s-thread-compose-suggest-avatar",style:{"--size":"20px",background:Xt(W.name)},children:W.name[0]?.toUpperCase()??"?"}),s.jsxs("span",{className:"s-thread-compose-suggest-cmd",children:["@",W.handle]}),s.jsx("span",{className:"s-thread-compose-suggest-desc",children:W.name})]},W.id))]}),s.jsxs("div",{className:"s-thread-compose-row",children:[s.jsx("textarea",{ref:_,className:"s-thread-compose-input",placeholder:Vr,value:ne,onChange:W=>{const ee=W.target.value;X(ee),mt(ee,W.target.selectionStart)},onSelect:W=>{const ee=W.currentTarget;mt(ee.value,ee.selectionStart)},onBlur:()=>{setTimeout(At,120)},onKeyDown:W=>{if(pe.open&&dt.length>0||ve.open&&jt.length>0){if(W.key==="ArrowDown"){W.preventDefault(),pe.open?te(de=>({...de,index:(de.index+1)%dt.length})):ve.open&&he(de=>({...de,index:(de.index+1)%jt.length}));return}if(W.key==="ArrowUp"){W.preventDefault(),pe.open?te(de=>({...de,index:(de.index-1+dt.length)%dt.length})):ve.open&&he(de=>({...de,index:(de.index-1+jt.length)%jt.length}));return}if(W.key==="Escape"){W.preventDefault(),At();return}if(W.key==="Enter"||W.key==="Tab"){if(W.shiftKey)return;if(W.preventDefault(),pe.open){const de=dt[pe.index]??dt[0];de&&Ht(de)}else if(ve.open){const de=jt[ve.index]??jt[0];de&&ie(de)}return}}W.key!=="Enter"||W.shiftKey||W.nativeEvent.isComposing||(W.preventDefault(),!ae&&ne.trim()&&un())},rows:1}),s.jsx(wk,{onAppend:W=>X(ee=>ee.trim()?`${ee.trimEnd()} ${W}`:W)}),Er?s.jsx("button",{type:"button",className:"s-thread-compose-send s-thread-compose-send--stop",onClick:()=>{As()},"aria-label":"Stop agent",children:s.jsx(ace,{})}):s.jsx("button",{type:"submit",className:"s-thread-compose-send",disabled:ae||!ne.trim(),"aria-label":ir==="ask"?"Ask agent":ir==="steer"?"Steer agent":Y?"Tell agent":"Send message",children:s.jsx(rce,{})})]})]})})]})})}async function cce(e){await ue("/api/local-path/reveal",{method:"POST",body:JSON.stringify({path:e.path,...e.basePath?{basePath:e.basePath}:{},...e.agentId?{agentId:e.agentId}:{},...e.sessionId?{sessionId:e.sessionId}:{}})})}const c5={think:"var(--dim)",tool:"var(--accent)",ask:"var(--amber)",message:"var(--muted)",note:"var(--green)",system:"var(--dim)",boot:"var(--dim)"},uce={read:"◎",edit:"✎",bash:"$",grep:"⌕",write:"✎",think:"∿"},dce=20,u5=new Intl.NumberFormat("en-US"),fce=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1});function hce(e){const t=Math.floor(e/60),n=Math.floor(e%60);return`${String(t).padStart(2,"0")}:${String(n).padStart(2,"0")}`}function WM(e,t){return e>=Math.max(0,t-dce)}function td(e){return typeof e!="number"||!Number.isFinite(e)?null:u5.format(e)}function xi(e){return typeof e!="number"||!Number.isFinite(e)?"—":Math.abs(e)<1e3?u5.format(e):fce.format(e).toLowerCase()}function mce(e){if(!Number.isFinite(e)||e<=0)return"0s";if(e<60)return`${Math.round(e)}s`;const t=Math.round(e),n=Math.floor(t/3600),r=Math.floor(t%3600/60),a=t%60;return n>0?`${n}h ${r}m`:r>=10||a===0?`${r}m`:`${r}m ${a}s`}function qM(e){return!!e&&Object.keys(e).length>0}function cb(e){return e.filter(t=>!!t)}function pce(e){const n=e.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean);return n[n.length-1]??e}function gce(e){cce(e).catch(t=>{console.warn("Failed to reveal local path",t)})}function dl({text:e,label:t="Copy",className:n}){const[r,a]=m.useState(!1),o=m.useRef(null);m.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]);const c=m.useCallback(u=>{u.preventDefault(),u.stopPropagation();const f=e,h=()=>{a(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>a(!1),1100)};navigator.clipboard?.writeText?navigator.clipboard.writeText(f).then(h).catch(()=>{KM(f),h()}):(KM(f),h())},[e]);return s.jsx("button",{type:"button",className:`s-observe-copy-btn${r?" s-observe-copy-btn--copied":""}${n?` ${n}`:""}`,onClick:c,"aria-label":t,title:r?"Copied":t,children:r?s.jsx("svg",{width:"11",height:"11",viewBox:"0 0 11 11",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:"M2 5.5l2.4 2.4L9 3.4"})}):s.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 11 11",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("rect",{x:"3.4",y:"3.4",width:"6.1",height:"6.1",rx:"1.2"}),s.jsx("path",{d:"M7.6 3.4V2.2a.8.8 0 0 0-.8-.8H2.2a.8.8 0 0 0-.8.8v4.6a.8.8 0 0 0 .8.8h1.2"})]})})}function KM(e){try{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}catch(t){console.warn("Clipboard copy failed",t)}}function vce(e){const t=[],n=[e.tool,e.arg].filter(Boolean).join(" ");return n&&t.push(n),e.result&&t.push(Object.entries(e.result).map(([r,a])=>`${r}: ${a}`).join(" · ")),e.diff&&(t.push(`+${e.diff.add}${e.diff.del>0?` -${e.diff.del}`:""}`),e.diff.preview&&t.push(e.diff.preview)),e.stream&&e.stream.length>0&&t.push(e.stream.join(`
161
- `)),t.join(`
162
- `)}function xce({event:e}){return s.jsxs("div",{className:"s-observe-block",children:[s.jsx("div",{className:"s-observe-think-label",children:"thinking"}),s.jsxs("div",{className:"s-observe-think-text",children:[s.jsx("span",{className:"s-observe-quoted",children:e.text}),e.live&&s.jsx("span",{className:"s-observe-cursor"})]}),s.jsx(dl,{text:e.text??"",label:"Copy thought"})]})}function yce({preview:e}){const t=e.split(`
163
- `);return s.jsx("pre",{className:"s-observe-tool-diff-preview",children:t.map((n,r)=>{const a=n[0],o=a==="+"?"add":a==="-"||a==="−"?"del":n.startsWith("@@")?"hunk":"ctx";return s.jsxs("span",{className:`s-observe-diff-line s-observe-diff-line--${o}`,children:[n,r<t.length-1?`
164
- `:null]},r)})})}function bce({event:e}){const t=uce[e.tool??""]??"▸",n=!!(e.result||e.diff||e.stream);return s.jsxs("div",{className:"s-observe-tool s-observe-block",children:[s.jsxs("div",{className:`s-observe-tool-header${n?" s-observe-tool-header--has-body":""}`,children:[s.jsx("span",{className:"s-observe-tool-glyph",children:t}),s.jsxs("span",{className:"s-observe-tool-cmd",children:[s.jsx("span",{className:"s-observe-tool-cmd-name",children:e.tool})," ",e.arg]})]}),e.result&&s.jsx("div",{className:"s-observe-tool-result",children:Object.entries(e.result).map(([r,a])=>`${r}: ${a}`).join(" · ")}),e.diff&&s.jsxs("div",{className:"s-observe-tool-diff",children:[s.jsxs("div",{className:"s-observe-tool-diff-stats",children:[s.jsxs("span",{className:"s-observe-tool-diff-add",children:["+",e.diff.add]}),e.diff.del>0&&s.jsxs(s.Fragment,{children:[" ",s.jsxs("span",{className:"s-observe-tool-diff-del",children:["−",e.diff.del]})]})]}),s.jsx(yce,{preview:e.diff.preview})]}),e.stream&&s.jsx("pre",{className:"s-observe-tool-stream",children:e.stream.join(`
165
- `)}),s.jsx(dl,{text:vce(e),label:"Copy tool call"})]})}function wce({event:e}){const t=e.to==="human"?"you":e.to??"?",n=e.answer?`${e.text}
166
-
167
- ↳ ${e.to??"you"}: ${e.answer}`:e.text??"";return s.jsxs("div",{className:"s-observe-ask s-observe-block",children:[s.jsxs("div",{className:"s-observe-ask-label",children:["↗ ask → ",t]}),s.jsx("div",{className:"s-observe-ask-text",children:s.jsx("span",{className:"s-observe-quoted",children:e.text})}),e.answer&&s.jsxs("div",{className:"s-observe-ask-answer",children:[s.jsxs("span",{className:"s-observe-ask-answer-meta",children:["↳ @",e.to??"you"," · +",(e.answerT??e.t)-e.t,"s"]}),s.jsx("div",{className:"s-observe-ask-answer-text",children:e.answer})]}),s.jsx(dl,{text:n,label:"Copy ask"})]})}function jce({event:e}){const t=e.to==="human"?"you":e.to??"?";return s.jsxs("div",{className:"s-observe-block",children:[s.jsxs("div",{className:"s-observe-message-label",children:["→ message → ",t]}),s.jsx("div",{className:"s-observe-message-text",children:s.jsx(gk,{text:e.text})}),s.jsx(dl,{text:e.text??"",label:"Copy message"})]})}function kce({event:e}){return s.jsxs("div",{className:"s-observe-note s-observe-block s-observe-block--inline",children:[s.jsx("span",{className:"s-observe-note-icon",children:"✓"}),s.jsx("span",{className:"s-observe-note-text",children:e.text}),s.jsx(dl,{text:e.text??"",label:"Copy note"})]})}function Nce({event:e}){const t=e.detail?`${e.text}
168
- ${e.detail}`:e.text??"";return s.jsxs("div",{className:"s-observe-system s-observe-block",children:[s.jsx("span",{className:"s-observe-system-arrow",children:"▸ "}),e.text,e.detail&&s.jsx("div",{className:"s-observe-system-detail",children:e.detail}),s.jsx(dl,{text:t,label:"Copy system event"})]})}function Sce({isFollowing:e,isLive:t,onToggle:n}){return s.jsxs("button",{className:`s-observe-follow-btn${e?" s-observe-follow-btn--on":""}`,onClick:n,title:e?"Pause auto-scroll":"Jump to latest and follow",children:[e?s.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:[s.jsx("rect",{x:"1.5",y:"1",width:"3",height:"8",rx:"1"}),s.jsx("rect",{x:"5.5",y:"1",width:"3",height:"8",rx:"1"})]}):s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:s.jsx("path",{d:"M2 1.5l7 3.5-7 3.5V1.5z"})}),s.jsx("span",{children:e?t?"Live":"Latest":"Follow"})]})}function Cce({event:e,prevT:t}){const n=e.t-t,r=c5[e.kind]??"var(--dim)";return s.jsxs("div",{className:"s-observe-row",children:[n>15&&s.jsxs("div",{className:"s-observe-row-gap",children:["+",n,"s"]}),s.jsx("div",{className:"s-observe-row-time",children:hce(e.t)}),s.jsx("span",{className:"s-observe-row-bead",style:{background:r}}),e.kind==="think"&&s.jsx(xce,{event:e}),e.kind==="tool"&&s.jsx(bce,{event:e}),e.kind==="ask"&&s.jsx(wce,{event:e}),e.kind==="message"&&s.jsx(jce,{event:e}),e.kind==="note"&&s.jsx(kce,{event:e}),(e.kind==="system"||e.kind==="boot")&&s.jsx(Nce,{event:e})]})}function Ece({events:e,followEnd:t}){const n=m.useRef(null),r=m.useRef(t);return m.useLayoutEffect(()=>{if(!t){r.current=!1;return}const a=!r.current;r.current=!0,n.current?.scrollIntoView({behavior:a?"instant":"smooth"})},[e.length,t]),s.jsxs("div",{className:"s-observe-stream",children:[s.jsx("div",{className:"s-observe-spine"}),e.map((a,o)=>s.jsx(Cce,{event:a,prevT:o>0?e[o-1].t:0},a.id)),s.jsx("div",{ref:n})]})}function Ace({data:e,cursor:t}){const a=e.length;if(a<2)return null;const o=276/(a-1),c=e.map((f,h)=>`${h===0?"M":"L"} ${(h*o).toFixed(1)} ${((1-f)*44).toFixed(1)}`).join(" "),u=t*276;return s.jsxs("svg",{viewBox:"0 0 276 44",style:{width:"100%",height:44,display:"block"},children:[s.jsx("defs",{children:s.jsxs("linearGradient",{id:"observeCtxFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[s.jsx("stop",{offset:"0%",stopColor:"var(--accent)",stopOpacity:.25}),s.jsx("stop",{offset:"100%",stopColor:"var(--accent)",stopOpacity:0})]})}),s.jsx("path",{d:`${c} L 276 44 L 0 44 Z`,fill:"url(#observeCtxFill)"}),s.jsx("path",{d:c,fill:"none",stroke:"var(--accent)",strokeWidth:1.2}),s.jsx("line",{x1:u,y1:0,x2:u,y2:44,stroke:"var(--accent)",strokeWidth:1,opacity:.6,strokeDasharray:"2 3"})]})}function Tce({state:e}){const t=e==="created"?"var(--green)":e==="modified"?"var(--accent)":"var(--dim)",n=e==="created"?"+":e==="modified"?"~":"◎";return s.jsx("span",{className:"s-observe-file-glyph",style:{background:"color-mix(in srgb, var(--bg) 70%, black)",border:`1px solid color-mix(in srgb, ${t} 40%, var(--border))`,color:t},children:n})}function za({label:e,value:t,detail:n}){return s.jsxs("div",{className:"s-observe-stat",children:[s.jsx("div",{className:"s-observe-stat-label",children:e}),s.jsx("div",{className:"s-observe-stat-value",children:t}),n&&s.jsx("div",{className:"s-observe-stat-detail",children:n})]})}function jk({path:e,basePath:t,agentId:n,sessionId:r,className:a,children:o}){const{openFilePreview:c}=qe(),u=e.startsWith("/")||e.startsWith("~/")?e:t?`${t.replace(/\/$/,"")}/${e}`:e;return s.jsxs("span",{className:"s-observe-path-link-group",children:[s.jsx("button",{type:"button",className:a,title:`Preview ${e} in Scout`,onClick:()=>c(u),children:o}),s.jsx("button",{type:"button",className:"s-observe-path-link-external",title:`Reveal ${e} in OS`,"aria-label":"Reveal in OS",onClick:()=>gce({path:e,basePath:t,agentId:n,sessionId:r}),children:s.jsx(wr,{size:11,strokeWidth:1.6})})]})}function Mce({path:e,basePath:t,agentId:n,sessionId:r}){return s.jsxs("div",{className:"s-observe-source",children:[s.jsx("span",{className:"s-observe-source-label",children:"Source"}),s.jsx(jk,{path:e,basePath:t,agentId:n,sessionId:r,className:"s-observe-source-link",children:pce(e)})]})}function ub({rows:e,agentId:t,sessionId:n}){return e.length===0?null:s.jsx("div",{className:"s-observe-detail-list",children:e.map(r=>{const a=`s-observe-detail-value s-observe-detail-value--${r.tone??"default"}${r.wrap?" s-observe-detail-value--wrap":""}`;return s.jsxs("div",{className:"s-observe-detail-row",children:[s.jsx("div",{className:"s-observe-detail-label",children:r.label}),s.jsxs("div",{className:"s-observe-detail-value-wrap",children:[r.actionPath?s.jsx(jk,{path:r.actionPath,basePath:r.actionBasePath,agentId:t,sessionId:n,className:`${a} s-observe-detail-link`,children:r.value}):s.jsx("div",{className:a,title:r.title,children:r.value}),s.jsx(dl,{text:r.actionPath??r.value,label:`Copy ${r.label.toLowerCase()}`,className:"s-observe-copy-btn--inline"})]})]},r.label)})})}function Rce({events:e,duration:t,cursor:n,onCursor:r}){const a=m.useRef(null),o=m.useCallback(u=>{const f=a.current.getBoundingClientRect(),h=u.clientX-f.left;r(Math.max(0,Math.min(t,h/f.width*t)))},[t,r]),c=m.useCallback(u=>{if(t<=0)return;const f=t*.01,h=t*.05;let p=n;switch(u.key){case"ArrowLeft":p=n-(u.shiftKey?h:f);break;case"ArrowRight":p=n+(u.shiftKey?h:f);break;case"PageDown":p=n-h;break;case"PageUp":p=n+h;break;case"Home":p=0;break;case"End":p=t;break;default:return}u.preventDefault(),r(Math.max(0,Math.min(t,p)))},[n,t,r]);return s.jsx("div",{className:"s-observe-track-wrap",children:s.jsxs("div",{ref:a,className:"s-observe-track",onClick:o,onKeyDown:c,role:"slider",tabIndex:t>0?0:-1,"aria-label":"Session timeline","aria-valuemin":0,"aria-valuemax":t,"aria-valuenow":Math.max(0,Math.min(t,n)),children:[e.map(u=>{const f=u.kind==="tool"?6:u.kind==="think"?4:5;return s.jsx("span",{className:"s-observe-track-tick",style:{left:`${u.t/t*100}%`,top:f===6?-2:-1,height:f,background:c5[u.kind]??"var(--dim)"}},u.id)}),s.jsx("div",{className:"s-observe-track-played",style:{width:`${n/t*100}%`}}),s.jsx("span",{className:"s-observe-track-cursor",style:{left:`${n/t*100}%`}})]})})}function GM(e){const t=Date.now()-e;return t<6e4?"just now":t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}function Ice(e,t){const n=t-e;return n<6e4?`${Math.floor(n/1e3)}s`:n<36e5?`${Math.floor(n/6e4)}m`:`${Math.floor(n/36e5)}h ${Math.floor(n%36e5/6e4)}m`}function _ce({catalog:e,sessionId:t,agentId:n}){const{navigate:r,route:a}=qe(),[o,c]=m.useState(!1),u=e.sessions.find(y=>y.id===e.activeSessionId),f=e.sessions.filter(y=>y.id!==e.activeSessionId&&y.endedAt).sort((y,b)=>(b.endedAt??0)-(y.endedAt??0)).slice(0,5),h=e.activeSessionId??t,p=h?h.slice(0,8):null,x=m.useCallback(()=>{e.resumeCommand&&(Nf({command:e.resumeCommand,cwd:e.resumeCwd,agentId:n}).then(()=>{wt(r,{view:"terminal",agentId:n},{returnTo:a})}),c(!0))},[e.resumeCommand,e.resumeCwd,r,a,n]),v=m.useCallback(()=>{r({view:"messages",conversationId:`dm.operator.${n}`})},[r,n]);return s.jsxs("div",{className:"s-observe-session-header",children:[s.jsx("div",{className:"s-observe-session-active",children:s.jsxs("div",{className:"s-observe-session-row",children:[p&&s.jsx("span",{className:"s-observe-session-id",title:h??void 0,children:p}),u&&s.jsxs("span",{className:"s-observe-session-time",children:["started ",GM(u.startedAt)]}),s.jsx("button",{className:"s-observe-pair-btn",onClick:v,title:"Send messages into the live session without taking the terminal",children:"Pair"}),e.resumeCommand&&s.jsx("button",{className:"s-observe-takeover-btn",onClick:x,title:e.resumeCommand,children:o?"Sent":"Takeover"}),s.jsx(Hg,{agentId:n,className:"s-observe-vantage-btn",statusClassName:"s-observe-vantage-status"})]})}),f.length>0&&s.jsxs("div",{className:"s-observe-session-history",children:[s.jsxs("div",{className:"s-observe-session-history-label",children:[e.sessions.length," session",e.sessions.length!==1?"s":""," total"]}),f.map(y=>s.jsxs("div",{className:"s-observe-session-past",children:[s.jsx("span",{className:"s-observe-session-id",children:y.id.slice(0,8)}),s.jsxs("span",{className:"s-observe-session-time",children:[GM(y.startedAt),y.endedAt?` · ${Ice(y.startedAt,y.endedAt)}`:""]})]},y.id))]})]})}const Oce={events:[{id:"observe:empty",t:0,kind:"system",text:"No session trace is available for this agent yet.",detail:"Waiting for a live session or readable history file."}],files:[],contextUsage:[],live:!1};function qg({data:e,agentId:t,sessionId:n,showRail:r=!0}){const a=e??Oce,{events:o,files:c,contextUsage:u}=a,f=a.live===!0,[h,p]=m.useState(null);m.useEffect(()=>{if(!t)return;let X=!1;return ue(`/api/agents/${encodeURIComponent(t)}/session-catalog`).then(ae=>{X||p(ae)}).catch(()=>{}),()=>{X=!0}},[t]);const x=o.length>0?o[o.length-1].t+30:60,[v,y]=m.useState(x),[b,C]=m.useState(!1),[E,A]=m.useState(1),[S,k]=m.useState(!0),N=m.useRef(x);m.useEffect(()=>{y(X=>{const ae=N.current;N.current=x;const be=WM(X,ae);return X>x||be&&S?x:X})},[x,S]),m.useEffect(()=>{if(!b)return;const X=setInterval(()=>{y(ae=>{const be=ae+E;return be>=x?(C(!1),x):be})},100);return()=>clearInterval(X)},[b,x,E]);const T=o.filter(X=>X.t<=v),O=WM(v,x)&&S,L=f&&O,I=m.useCallback(()=>{O?k(!1):(y(x),k(!0))},[O,x]),z=a.metadata,_=z?.session,U=_?.threadPath??null,D=z?.usage,q=o.filter(X=>X.kind==="tool").length,Z=o.filter(X=>X.kind==="think").length,$=o.filter(X=>X.kind==="ask").length,G=o.filter(X=>X.kind==="tool"&&X.tool==="read").length,V=o.filter(X=>X.kind==="tool"&&(X.tool==="edit"||X.tool==="write")).length,Y=o.length>0?o[o.length-1].t:0,K=u&&u.length>0?Math.round((u[u.length-1]??0)*100):null,P=[{label:"Input",value:D?.inputTokens},{label:"Output",value:D?.outputTokens},{label:"Cache hit",value:D?.cacheReadInputTokens},{label:"Cache write",value:D?.cacheCreationInputTokens},{label:"Total",value:D?.totalTokens},{label:"Reasoning",value:D?.reasoningOutputTokens}].filter(X=>typeof X.value=="number"),H=cb([typeof D?.assistantMessages=="number"?{label:"Assistant msgs",value:td(D.assistantMessages)??"0",tone:"accent"}:null,typeof D?.webSearchRequests=="number"?{label:"Web search",value:td(D.webSearchRequests)??"0"}:null,typeof D?.webFetchRequests=="number"?{label:"Web fetch",value:td(D.webFetchRequests)??"0"}:null,D?.serviceTier?{label:"Service tier",value:D.serviceTier,tone:"good"}:null,D?.speed?{label:"Speed",value:D.speed}:null,D?.planType?{label:"Plan",value:D.planType}:null]),B=cb([typeof D?.contextWindowTokens=="number"?{label:"Model window",value:`${td(D.contextWindowTokens)} tokens`,title:td(D.contextWindowTokens)??void 0,tone:"accent"}:null,K!==null?{label:"Derived load",value:`${K}%`,tone:K>=80?"warn":"default"}:null]),Q=cb([_?.model?{label:"Model",value:_.model,tone:"accent"}:null,_?.adapterType?{label:"Adapter",value:_.adapterType}:null,_?.gitBranch?{label:"Branch",value:_.gitBranch}:null,_?.cwd?{label:"Workspace",value:_.cwd,title:_.cwd,wrap:!0,actionPath:_.cwd}:null,_?.entrypoint?{label:"Entrypoint",value:_.entrypoint}:null,_?.cliVersion?{label:"CLI",value:_.cliVersion}:null,_?.permissionMode?{label:"Permissions",value:_.permissionMode}:null,_?.approvalPolicy?{label:"Approval",value:_.approvalPolicy}:null,_?.sandbox?{label:"Sandbox",value:_.sandbox}:null,_?.userType?{label:"User type",value:_.userType}:null,_?.originator?{label:"Originator",value:_.originator}:null,_?.modelProvider?{label:"Provider",value:_.modelProvider}:null,_?.effort?{label:"Effort",value:_.effort}:null,_?.timezone?{label:"Timezone",value:_.timezone}:null,_?.externalSessionId?{label:"External session",value:_.externalSessionId,title:_.externalSessionId,wrap:!0}:null,_?.threadId?{label:"Thread",value:_.threadId,title:_.threadId,wrap:!0}:null,_?.threadPath?{label:"Thread path",value:_.threadPath,title:_.threadPath,wrap:!0,actionPath:_.threadPath,actionBasePath:_.cwd??null}:null,_?.source?{label:"Runtime source",value:_.source}:null]),oe=qM(D),ne=qM(_);return s.jsxs("div",{className:`s-observe${r?"":" s-observe--content-only"}`,children:[s.jsxs("main",{className:"s-observe-main",children:[U&&s.jsx(Mce,{path:U,basePath:_?.cwd??null,agentId:t??null,sessionId:n??null}),s.jsx("div",{className:"s-observe-live-sticky",children:s.jsx(Sce,{isFollowing:O,isLive:L,onToggle:I})}),s.jsx(Ece,{events:T,followEnd:O})]}),r&&s.jsxs("aside",{className:"s-observe-rail",children:[h&&h.sessions.length>0&&s.jsxs("div",{children:[s.jsx("div",{className:"s-observe-rail-label",children:"Session"}),s.jsx(_ce,{catalog:h,sessionId:n??null,agentId:t})]}),s.jsxs("div",{children:[s.jsx("div",{className:"s-observe-rail-label",children:"Trace stats"}),s.jsxs("div",{className:"s-observe-stats",children:[s.jsx(za,{label:"Turns",value:xi(_?.turnCount??0)}),s.jsx(za,{label:"Tools",value:xi(q)}),s.jsx(za,{label:"Thinks",value:xi(Z)}),s.jsx(za,{label:"Asks",value:xi($)}),s.jsx(za,{label:"Reads",value:xi(G)}),s.jsx(za,{label:"Edits",value:xi(V)}),s.jsx(za,{label:"Files",value:xi(c.length)}),s.jsx(za,{label:"Window",value:mce(Y)})]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"s-observe-rail-label",children:"Agent family"}),s.jsx(Vg,{topology:z?.topology??null,title:"Internal agents",size:"rail"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"s-observe-rail-label",children:"Context window"}),s.jsx(ub,{rows:B,agentId:t??null,sessionId:n??null}),u&&u.length>=2?s.jsxs(s.Fragment,{children:[s.jsx(Ace,{data:u,cursor:v/x}),s.jsx("div",{className:"s-observe-ctx-detail",children:"Sparkline shows derived session load across the observed trace."})]}):B.length===0?s.jsx("div",{className:"s-observe-ctx-detail",children:"Unavailable for this session"}):s.jsx("div",{className:"s-observe-ctx-detail",children:"Exact window metadata is available, but no derived load trace was captured."})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"s-observe-rail-label",children:["Files touched · ",c.length]}),s.jsx("div",{className:"s-observe-files",children:c.map(X=>s.jsxs("div",{className:`s-observe-file${X.lastT<=v?" s-observe-file--visible":" s-observe-file--hidden"}`,children:[s.jsx(Tce,{state:X.state}),s.jsx(jk,{path:X.path,basePath:_?.cwd??null,agentId:t??null,sessionId:n??null,className:"s-observe-file-path",children:X.path}),s.jsxs("span",{className:"s-observe-file-touches",children:["×",X.touches]})]},X.path))})]}),s.jsxs("div",{children:[s.jsx("div",{className:"s-observe-rail-label",children:"Usage"}),P.length>0&&s.jsx("div",{className:"s-observe-stats s-observe-stats--usage",children:P.map(X=>s.jsx(za,{label:X.label,value:xi(X.value)},X.label))}),H.length>0?s.jsx(ub,{rows:H,agentId:t??null,sessionId:n??null}):oe?null:s.jsx("div",{className:"s-observe-ctx-detail",children:"Unavailable for this session"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"s-observe-rail-label",children:"Metadata"}),Q.length>0?s.jsx(ub,{rows:Q,agentId:t??null,sessionId:n??null}):ne?null:s.jsx("div",{className:"s-observe-ctx-detail",children:"Unavailable for this session"})]})]}),s.jsxs("footer",{className:"s-observe-scrubber",children:[s.jsx("button",{className:"s-observe-play-btn",onClick:()=>C(!b),children:b?"❚❚":"▶"}),s.jsx("button",{className:"s-observe-rewind-btn",onClick:()=>{y(0),C(!1)},children:"⏮"}),s.jsx(Rce,{events:o,duration:x,cursor:v,onCursor:y}),s.jsx("div",{className:"s-observe-speed-group",children:[.5,1,2,4].map(X=>s.jsxs("button",{className:`s-observe-speed-btn${E===X?" s-observe-speed-btn--active":""}`,onClick:()=>A(X),children:[X,"×"]},X))})]})]})}function Kg({ariaLabel:e,activeRoute:t,groups:n,navigate:r,className:a=""}){const o=la("nav.clean",!1),c=o?n.map(f=>({...f,items:f.items.filter(h=>!h.hideInLean)})).filter(f=>f.items.length>0):n,u=c.reduce((f,h)=>f+h.items.length,0);return o&&u<=1?null:s.jsx("nav",{className:`s-secondary-nav${a?` ${a}`:""}`,"aria-label":e,children:c.map((f,h)=>s.jsxs("div",{className:"s-secondary-nav-group",children:[f.label&&s.jsx("span",{className:"s-secondary-nav-label",children:f.label}),s.jsx("div",{className:"s-secondary-nav-switch",children:f.items.map(p=>{const x=p.active(t);return s.jsx("button",{type:"button","aria-pressed":x,className:`s-secondary-nav-button${x?" s-secondary-nav-button--active":""}`,onClick:()=>r(p.route),children:p.label},p.id)})})]},f.label??h))})}const $ce=[{items:[{id:"directory",label:"Directory",route:{view:"agents"},active:e=>e.view==="agents"||e.view==="agent-info"},{id:"sessions",label:"Sessions",route:{view:"sessions"},active:e=>e.view==="sessions"||e.view==="terminal",hideInLean:!0},{id:"config",label:"Config",route:{view:"settings",section:"agents"},active:e=>e.view==="settings"&&e.section==="agents",hideInLean:!0}]}],Lce=[{items:[{id:"messages",label:"Messages",route:{view:"messages"},active:e=>e.view==="messages"||e.view==="conversations"||e.view==="conversation"},{id:"channels",label:"Channels",route:{view:"channels"},active:e=>e.view==="channels",hideInLean:!0}]}],Pce=[{items:[{id:"knowledge",label:"Knowledge",route:{view:"search",mode:"knowledge"},active:e=>e.view==="search"&&(e.mode===void 0||e.mode==="knowledge")},{id:"indexer",label:"Indexer",route:{view:"search",mode:"indexer"},active:e=>e.view==="search"&&e.mode==="indexer"}]}],Dce=[{items:[{id:"control",label:"Control",route:{view:"ops",mode:"mission"},active:e=>e.view==="ops"&&(e.mode===void 0||e.mode==="mission"||e.mode==="issues"),hideInLean:!0},{id:"dispatch",label:"Dispatch",route:{view:"broker"},active:e=>e.view==="broker",hideInLean:!0},{id:"repos",label:"Repos",route:{view:"repos"},active:e=>e.view==="repos",hideInLean:!0},{id:"harnesses",label:"Providers",route:{view:"harnesses"},active:e=>e.view==="harnesses",hideInLean:!0},{id:"mesh",label:"Mesh",route:{view:"mesh"},active:e=>e.view==="mesh",hideInLean:!0},{id:"tail",label:"Tail",route:{view:"ops",mode:"tail"},active:e=>e.view==="ops"&&e.mode==="tail",hideInLean:!0},{id:"runtime",label:"Runtime",route:{view:"ops",mode:"atop"},active:e=>e.view==="ops"&&e.mode==="atop",hideInLean:!0},{id:"plans",label:"Plans",route:{view:"ops",mode:"plan"},active:e=>e.view==="ops"&&e.mode==="plan",hideInLean:!0}]}];function kk({activeRoute:e,navigate:t}){return s.jsx(Kg,{ariaLabel:"Agents sections",activeRoute:e,groups:$ce,navigate:t})}function zce(e,t){if(t.filter(a=>a.name===e.name).length<=1)return{name:e.name,qualifier:null};const r=e.project??e.branch??e.id.replace(/^.*\./,"");return{name:e.name,qualifier:r}}function Wi(e){if(!e)return null;const t=e.replace(/_/g," ");return t.toLowerCase()==="relay agent"?"agent":t}function lp(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function Bce(e){return e.handle?`@${e.handle.replace(/^@+/,"")}`:null}function Nk(e){return e.selector??e.defaultSelector??Bce(e)}function Uce(e){const t=[...e].filter(a=>a.kind==="direct"&&!!a.agentId).sort((a,o)=>(o.lastMessageAt??0)-(a.lastMessageAt??0)),n=new Map,r=new Map;for(const a of t){const o=r.get(a.agentId);(!o||Fce(a,o))&&(n.set(a.agentId,a.id),r.set(a.agentId,a))}return{conversationByAgentId:n,sessionByAgentId:r}}function Fce(e,t){const n=Qn(e.agentId),r=e.id===n,a=t.id===n;if(r!==a)return r;const o=e.id.startsWith("dm.operator."),c=t.id.startsWith("dm.operator.");if(o!==c)return o;const u=e.lastMessageAt??0,f=t.lastMessageAt??0;return u!==f?u>f:e.id<t.id}const db="24h",Vce=8,Hce=3,Wce=[{key:"1h",label:"1h"},{key:"24h",label:"24h"},{key:"7d",label:"7d"},{key:"all",label:"all"}],pc={working:0,ready:1,not_ready:2};function Dc(e){switch(e){case"working":return"working";case"ready":return"available";case"not_ready":return"offline"}}function qce(e){switch(e){case"working":return"working";case"ready":return"ready";case"not_ready":return"not ready"}}const Kce=6e4;function zi(e){if(!e)return null;const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function of(e){const t=e?.trim();return t&&t.replace(/\/+$/,"")||null}function Gce(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(0,n)||"/":null}function Zce(e){return e.split(/[-_\s]+/).filter(Boolean).map(t=>t.slice(0,1).toUpperCase()+t.slice(1)).join(" ")}function Yce(e){const t=zi(e)?.trim().toLowerCase();if(!e||!t||t==="~")return null;const r=t.match(/^(.+?)(?:-(?:parity|codex))?-c\d+$/)?.[1];if(!r)return null;const a=Gce(e);return{title:Zce(r),root:a?`${a}/${r}`:r}}function Xce(e,t){const n=t.trim().toLowerCase();return n&&n!=="unscoped"&&n!=="unknown"?`project:${n}`:e?`root:${e}`:`project:${n||"unscoped"}`}function ZM(e){return!!e?.startsWith("/tmp/")}function YM(e,t){const n=of(t),r=e?.trim()||zi(n)||"Unscoped";return{key:Xce(n,r),title:r,root:n}}function Cf(e,t){const n=of(t),r=Yce(n);return r?YM(r.title,r.root):YM(e,n)}function d5(e){const t=of(e.agent.projectRoot??e.agent.cwd),n=e.agent.project??e.project;return Cf(n,t)}function Qce(e){return Cf(e.project,e.cwd)}function Jce(e){return Cf(e.agentName??e.title,e.workspaceRoot)}function eue(e){return e.includes("claude")?"claude":e.includes("codex")?"codex":Wi(e)??"workflow"}function tue(e){const t=e?.trim();if(!t)return null;const n=t.match(/^(\/Users\/[^/]+\/dev\/[^/]+)/);if(n?.[1])return n[1];const r=t.match(/^(~\/dev\/[^/]+)/);if(r?.[1])return r[1];const a=t.match(/\.claude\/projects\/-Users-([^-]+)-dev-([^/]+)/);if(a?.[1]&&a[2]){const o=a[2].split("-packages-")[0]??a[2];return`/Users/${a[1]}/dev/${o}`}return null}function Ba(e,t){const n=e?.[t];return typeof n=="string"&&n.trim()?n.trim():null}function nue(e){return Cf(e.project.title,e.project.root)}function Kp(e){const t=e?.trim();if(!t)return null;const n=zi(t)??t;return n.endsWith(".jsonl")?n.slice(0,-6):n}function Eo(e,t){const n=t?.trim();n&&e.add(n.toLowerCase());const r=Kp(n);r&&e.add(r.toLowerCase())}function f5(e){const t=new Set;return Eo(t,e.agent.conversationId),Eo(t,Qn(e.agent.id)),Eo(t,e.agent.harnessSessionId),Eo(t,e.agent.harnessLogPath),Eo(t,e.session?.id),Eo(t,e.session?.harnessSessionId),Eo(t,e.session?.harnessLogPath),t}function Ec(e,t){const n=t?.trim();if(n&&e.has(n.toLowerCase()))return!0;const r=Kp(n);return!!(r&&e.has(r.toLowerCase()))}function sue(e,t){if(e.agentId&&e.agentId===t.agent.id)return!0;const n=f5(t);return Ec(n,e.id)||Ec(n,e.harnessSessionId)||Ec(n,e.harnessLogPath)}function rue(e,t){const n=e?.command?.toLowerCase();return n?[t.agent.id,t.agent.selector?.replace(/^@/,"").replace(/\.node:.+$/,""),t.agent.defaultSelector?.replace(/^@/,"").replace(/\.node:.+$/,""),t.agent.harnessSessionId].filter(a=>!!(a&&a.length>=8)).some(a=>n.includes(a.toLowerCase())):!1}function aue(e,t){const n=f5(t);return Ec(n,e.refId)||Ec(n,e.sessionId)||Ec(n,e.transcriptPath)||rue(e.process,t)}function iue(e,t){if(!e)return[];const n=[];for(const r of e.transcripts??[]){const a=r.source||"unknown",o=Kp(r.sessionId)??Kp(r.transcriptPath);if(!o)continue;const c=r.mtimeMs||null;n.push({key:`transcript:${r.transcriptPath}`,refId:o,source:a,project:r.project?.trim()||zi(r.cwd)||zi(r.transcriptPath)||"unknown",cwd:of(r.cwd),transcriptPath:r.transcriptPath,sessionId:r.sessionId,mtimeMs:r.mtimeMs,size:r.size,status:c&&t-c<=Kce?"active":"idle",process:null,lastActivityAt:c})}for(const r of e.processes??[]){const a=r.source||"unknown",o=of(r.cwd);n.push({key:`process:${a}:${r.pid}`,refId:`pid-${r.pid}`,source:a,project:zi(o)??"unknown",cwd:o,transcriptPath:null,sessionId:null,mtimeMs:null,size:null,status:"active",process:r,lastActivityAt:null})}return n.sort((r,a)=>{const o=(r.status==="active"?0:1)-(a.status==="active"?0:1);return o!==0?o:(a.lastActivityAt??0)-(r.lastActivityAt??0)||r.project.localeCompare(a.project)})}function oue(e){if(!e)return[];const t=[];for(const n of e.observations){const r=n.topology,a=eue(n.source),o=new Map((r.sourceRefs??[]).map(c=>[c.id,c.ref]));for(const c of r.groups){if(c.kind!=="workflow")continue;const u=Ba(c.providerMeta,"claudeWorkflowRunId")??c.id,f=r.tasks.filter(A=>Ba(A.providerMeta,"claudeWorkflowRunId")===u),h=r.agents.filter(A=>Ba(A.providerMeta,"claudeWorkflowRunId")===u&&A.role!=="lead"),p=f.filter(A=>A.state!=="completed"),x=f.filter(A=>A.state==="completed"),y=[Ba(c.providerMeta,"workspaceRoot"),Ba(c.providerMeta,"cwd"),Ba(c.providerMeta,"transcriptDir"),Ba(c.providerMeta,"scriptPath"),c.sourceRef?o.get(c.sourceRef):null,...r.agents.map(A=>A.cwd)].map(tue).find(A=>!!A)??null,b=Cf(zi(y)??c.name??"Workflows",y),C=Date.parse(r.observedAt),E=Math.max(Number.isFinite(C)?C:0,n.changedAt??0)||null;t.push({key:c.id,source:a,label:c.name??u,project:b,status:p.length>0?"running":f.length>0?"completed":"observed",description:Ba(c.providerMeta,"description"),parentSessionId:Ba(c.providerMeta,"parentSessionId"),workerCount:h.length,taskCount:f.length,activeTaskCount:p.length,completedTaskCount:x.length,lastActivityAt:E})}}return t.sort((n,r)=>{const a=(r.activeTaskCount>0?1:0)-(n.activeTaskCount>0?1:0);return a!==0?a:(r.lastActivityAt??0)-(n.lastActivityAt??0)||n.label.localeCompare(r.label)})}function uw(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function Sk(e){return`s-atop-chip s-atop-chip--harness s-atop-chip--harness-${uw(e)}`}function Ck(e){if(!e)return"—";const t=e.replace(/^session[_:-]?/i,"");return t.length>10?t.slice(0,8):t}function lue(e){if(e.length===0)return null;const t={working:0,needs_attention:1,queued:2,failed:3,completed:4},n=[...e].sort((r,a)=>{const o=t[r.status]-t[a.status];return o!==0?o:(a.updatedAt??0)-(r.updatedAt??0)})[0];return(n.summary??n.task??n.statusLabel??"").trim()||null}function cue(e,t,n){const r=Ge(e.state),a=e.project??zi(e.projectRoot)??"Unscoped",o=e.branch??"—",c=Wi(e.harness)??Wi(e.agentClass)??"agent";return{agent:e,status:r,stateLabel:cs(e.state),project:a,branch:o,harness:c,session:t,activeTask:lue(n),activeAskCount:n.length,lastActivityAt:Math.max(0,t?.lastMessageAt??0,e.updatedAt??0)||null}}function uue(e){return{...e,agents:[],scoutSessions:[],nativeSessions:[],workflows:[],status:"not_ready",lastActivityAt:null}}function pm(e,t){const n=e.get(t.key);if(n)return t.root&&(!n.root||ZM(n.root)&&!ZM(t.root))&&(n.root=t.root),n;const r=uue(t);return e.set(t.key,r),r}function due(e){const t=e.agents.some(p=>p.status==="working"),n=e.nativeSessions.some(p=>p.status==="active"),r=e.workflows.some(p=>p.activeTaskCount>0||p.status==="running"),a=e.agents.some(p=>p.status==="ready");e.status=t||n||r?"working":a?"ready":"not_ready";const o=e.agents.map(p=>p.lastActivityAt??0),c=e.scoutSessions.map(p=>p.lastMessageAt??0),u=e.nativeSessions.map(p=>p.lastActivityAt??0),f=e.workflows.map(p=>p.lastActivityAt??0),h=Math.max(0,...o,...c,...u,...f);e.lastActivityAt=h||null}function XM(e,t,n,r){const a=new Map,o=new Map;for(const u of e){const f=d5(u);pm(a,f).agents.push(u),o.set(u.agent.id,f.key)}for(const u of n)pm(a,Qce(u)).nativeSessions.push(u);for(const u of r)pm(a,nue(u)).workflows.push(u);const c=new Map;for(const u of t){const f=u.agentId?o.get(u.agentId):void 0,h=f?a.get(f)??null:u.workspaceRoot?pm(a,Jce(u)):null;if(!h)continue;const p=h,x=c.get(p.key)??new Set;x.has(u.id)||(x.add(u.id),c.set(p.key,x),p.scoutSessions.push(u))}for(const u of a.values())u.agents.sort((f,h)=>{const p=pc[f.status]-pc[h.status];return p!==0?p:(h.lastActivityAt??0)-(f.lastActivityAt??0)||f.agent.name.localeCompare(h.agent.name)}),u.scoutSessions.sort((f,h)=>(h.lastMessageAt??0)-(f.lastMessageAt??0)),u.nativeSessions.sort((f,h)=>{const p=(f.status==="active"?0:1)-(h.status==="active"?0:1);return p!==0?p:(h.lastActivityAt??0)-(f.lastActivityAt??0)}),u.workflows.sort((f,h)=>{const p=(h.activeTaskCount>0?1:0)-(f.activeTaskCount>0?1:0);return p!==0?p:(h.lastActivityAt??0)-(f.lastActivityAt??0)||f.label.localeCompare(h.label)}),due(u);return[...a.values()].sort((u,f)=>{const h=pc[u.status]-pc[f.status];return h!==0?h:(f.lastActivityAt??0)-(u.lastActivityAt??0)||u.title.localeCompare(f.title)})}function QM(e){const t=Wi(e.harness)??"scout";return{key:`scout:${e.id}`,kind:"scout",status:e.kind,harness:t,label:e.title||e.agentName||e.id,detail:e.preview??e.id,lastActivityAt:e.lastMessageAt,route:{view:"conversation",conversationId:e.id}}}function JM(e){return{key:`native:${e.key}`,kind:"native",status:e.status,harness:e.source,label:Ck(e.sessionId??e.refId),detail:e.transcriptPath??e.process?.command??e.cwd,lastActivityAt:e.lastActivityAt,route:e.sessionId||e.transcriptPath?{view:"sessions",sessionId:e.refId}:null}}function h5(e){const t=e.taskCount>0?`${e.completedTaskCount}/${e.taskCount} tasks`:"workflow",n=e.activeTaskCount>0?`${e.activeTaskCount} active`:t,r=e.parentSessionId?`parent session ${Ck(e.parentSessionId)}`:null;return{key:`workflow:${e.key}`,kind:"workflow",status:"workflow",harness:e.source,label:e.label,detail:e.description&&r?`${e.description} · ${r}`:e.description??(r?`Claude workflow observed from ${r}`:`${e.workerCount} workers · ${n}`),subLabel:`${e.workerCount} workers · ${n}`,lastActivityAt:e.lastActivityAt,route:e.parentSessionId?{view:"sessions",sessionId:e.parentSessionId}:null}}function fue(e,t){return e.agent.name.localeCompare(t.agent.name)||e.agent.id.localeCompare(t.agent.id)}function Gp(e){const t={workflow:0,native:1,scout:2};return[...e].sort((n,r)=>{const a=t[n.kind]-t[r.kind];return a!==0?a:n.harness.localeCompare(r.harness)||n.key.localeCompare(r.key)})}function m5(e){return e.kind==="workflow"||e.kind==="native"&&e.status==="active"}function hue(e,t){switch(e){case"1h":return t-3600*1e3;case"24h":return t-1440*60*1e3;case"7d":return t-10080*60*1e3;case"all":return null}}function gm(e,t,n,r=!1){if(t==="all"||r)return!0;const a=hue(t,n);return!!(a!==null&&e&&e>=a)}function p5(e){const t=new Set,n=new Set,r=[...e.agents].sort(fue).map(o=>{const c=[];for(const u of e.scoutSessions)t.has(u.id)||sue(u,o)&&(t.add(u.id),c.push(QM(u)));for(const u of e.nativeSessions)n.has(u.key)||aue(u,o)&&(n.add(u.key),c.push(JM(u)));return{key:o.agent.id,row:o,sessions:Gp(c)}}),a=Gp([...e.nativeSessions.filter(o=>!n.has(o.key)).map(JM),...e.scoutSessions.filter(o=>!t.has(o.id)).map(QM)]);return{agents:r,unassignedSessions:a}}function mue(e,t){return t?[e.agent.name,e.agent.handle,e.agent.id,e.agent.selector,e.agent.defaultSelector,e.project,e.agent.projectRoot,e.branch,e.harness,e.activeTask,e.session?.preview,e.session?.id,e.agent.harnessSessionId].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function pue(e,t,n){return n.size>0&&!n.has(e.source)?!1:t?[e.refId,e.sessionId,e.source,e.project,e.cwd,e.transcriptPath,e.process?.command].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function gue(e,t,n){const r=Wi(e.harness)??"scout";return n.size>0&&!n.has(r)?!1:t?[e.id,e.kind,e.title,e.agentName,e.harness,e.harnessSessionId,e.currentBranch,e.preview,e.workspaceRoot].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function vue(e,t,n){return n.size>0&&!n.has(e.source)?!1:t?[e.label,e.source,e.status,e.description,e.project.title,e.project.root].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function xue(e,t){if(!t)return null;const n=t.trim().replace(/^@+/,"");if(!n)return null;const r=e.find(u=>u.id===n);if(r)return r;if(n.split(".").filter(Boolean).length>=3)return null;const o=e.filter(u=>u.handle===n||u.selector===`@${n}`||u.defaultSelector===`@${n}`||u.id.startsWith(`${n}.`)),c=Array.from(new Map(o.map(u=>[u.id,u])).values());return c.length===1?c[0]:null}function yue({catalog:e,agentId:t}){const{navigate:n,route:r}=qe(),[a,o]=m.useState(!1),c=e.activeSessionId?.slice(0,8)??null,u=e.sessions.find(p=>p.id===e.activeSessionId),f=()=>{e.resumeCommand&&(Nf({command:e.resumeCommand,cwd:e.resumeCwd,agentId:t}).then(()=>wt(n,{view:"terminal",agentId:t},{returnTo:r})),o(!0))},h=()=>{n({view:"messages",conversationId:Qn(t)})};return s.jsxs("div",{className:"s-profile-facet",children:[s.jsx("div",{className:"s-profile-facet-label",children:"Session"}),s.jsxs("div",{className:"s-profile-facet-value s-profile-facet-value--mono",title:e.activeSessionId??void 0,children:[c,s.jsx("button",{type:"button",className:"s-profile-facet-action s-profile-facet-action--pair",onClick:h,title:"Send messages into the live session without taking the terminal",children:"Pair"}),e.resumeCommand&&s.jsx("button",{type:"button",className:"s-profile-facet-action",onClick:f,title:e.resumeCommand,children:a?"Going…":"Takeover"}),s.jsx(Hg,{agentId:t,className:"s-profile-facet-action s-profile-facet-action--vantage",statusClassName:"s-profile-facet-handoff"})]}),u&&s.jsxs("div",{className:"s-profile-facet-detail",children:[e.sessions.length," session",e.sessions.length!==1?"s":""," · started ",Ie(u.startedAt)]})]})}function bue(e){if(e===null)return"age unknown";const t=Math.max(0,Math.round(e/6e4));if(t<60)return`${t}m old`;const n=Math.floor(t/60),r=t%60;return r>0?`${n}h ${r}m old`:`${n}h old`}function wue(e){const t=e.policy.maxTurns>0?e.turnCount/e.policy.maxTurns:0;return Math.max(0,Math.min(100,Math.round(t*100)))}function jue(e){return e.policy.maxTurns<=0?`${e.turnCount} turn${e.turnCount===1?"":"s"}`:`${e.turnCount} / ${e.policy.maxTurns} turns`}function kue(e,t){if(e){const n=Ie(e);return n==="now"?"last activity now":`last activity ${n} ago`}return t!==null?`session ${bue(t)}`:"last activity unknown"}function Nue({context:e,lastActivityAt:t,resetting:n,onReset:r}){const a=wue(e),o=jue(e),c=kue(t,e.sessionAgeMs),u=n||e.currentTurnActive;return s.jsxs("div",{className:"s-profile-facet s-profile-context",children:[s.jsx("div",{className:"s-profile-facet-label",children:"Context"}),s.jsxs("div",{className:"s-profile-context-head",children:[s.jsxs("span",{className:"s-profile-context-metric",children:[a,"% used"]}),s.jsx("button",{type:"button",className:"s-profile-facet-action",disabled:u,onClick:r,title:e.currentTurnActive?"Agent is currently working":"Start a fresh session",children:n?"Starting...":"New"})]}),s.jsx("div",{className:"s-profile-context-gauge","aria-label":`Context load ${a}%`,children:s.jsx("div",{className:"s-profile-context-gauge-fill",style:{width:`${a}%`}})}),s.jsxs("div",{className:"s-profile-facet-detail",title:`${o} · ${c}`,children:[o," · ",c]})]})}function Sue({agent:e,fleet:t,navigate:n}){const r=m.useMemo(()=>t?t.activity.filter(o=>o.agentId===e.id||o.actorId===e.id).slice(0,6):[],[t,e.id]),a=m.useMemo(()=>t?t.recentCompleted.filter(o=>o.agentId===e.id).slice(0,4):[],[t,e.id]);return r.length===0&&a.length===0?null:s.jsxs(s.Fragment,{children:[s.jsx(Od,{label:"Activity"}),s.jsx("div",{className:"s-profile-work",children:s.jsxs("div",{className:"s-profile-activity-feed",children:[a.map(o=>s.jsxs("div",{className:"s-profile-activity-row",onClick:()=>{o.conversationId&&n({view:"agents",agentId:e.id,conversationId:o.conversationId})},children:[s.jsx("div",{className:"s-profile-activity-dot s-profile-activity-dot--done"}),s.jsxs("div",{className:"s-profile-activity-body",children:[s.jsx("div",{className:"s-profile-activity-title",children:o.summary??o.task}),s.jsxs("div",{className:"s-profile-activity-meta",children:[o.status==="completed"?"completed":o.status,o.completedAt&&` · ${Ie(o.completedAt)}`]})]})]},o.invocationId)),r.map(o=>s.jsxs("div",{className:"s-profile-activity-row",onClick:()=>{o.conversationId&&n({view:"agents",agentId:e.id,conversationId:o.conversationId})},children:[s.jsx("div",{className:"s-profile-activity-dot"}),s.jsxs("div",{className:"s-profile-activity-body",children:[s.jsx("div",{className:"s-profile-activity-title",children:o.title??o.summary??o.kind}),s.jsxs("div",{className:"s-profile-activity-meta",children:[o.kind.replace(/_/g," "),o.actorName&&` · ${o.actorName}`,` · ${Ie(o.ts)}`]})]})]},o.id))]})})]})}function Od({label:e,right:t,rightClassName:n}){return s.jsxs("div",{className:"s-profile-section-rule",children:[s.jsx("span",{className:"s-profile-section-rule-label",children:e}),s.jsx("span",{className:"s-profile-section-rule-line"}),t&&s.jsx("span",{className:`s-profile-section-rule-right${n?` ${n}`:""}`,children:t})]})}function Cue({messages:e,navigate:t,conversationId:n,agentId:r}){const a=e.slice(-8).reverse();return a.length===0?null:s.jsxs("div",{className:"s-profile-signals",children:[s.jsx(Od,{label:"Recent signal",right:"last 1h"}),s.jsx("div",{className:"s-profile-signal-list",children:a.map(o=>{const u=o.class==="ask"||o.body?.toLowerCase().startsWith("@")?"ASK":"MESSAGE";return s.jsxs("div",{className:"s-profile-signal",onClick:()=>{n&&t({view:"agents",agentId:r,conversationId:n})},children:[s.jsx("div",{className:"s-profile-signal-avatar",style:{background:Xt(o.actorName??"?")},children:(o.actorName??"?")[0].toUpperCase()}),s.jsxs("div",{className:"s-profile-signal-body",children:[s.jsxs("div",{className:"s-profile-signal-header",children:[s.jsx("span",{className:"s-profile-signal-kind",children:u}),s.jsx("span",{className:"s-profile-signal-sep",children:"·"}),s.jsx("span",{className:"s-profile-signal-routing",children:o.actorName}),s.jsx("span",{className:"s-profile-signal-time",children:Ie(o.createdAt)})]}),s.jsx("div",{className:"s-profile-signal-text",children:o.body})]})]},o.id)})})]})}function Eue({agent:e,allAgents:t,session:n,conversationId:r,navigate:a,activeTab:o}){const{name:c,qualifier:u}=zce(e,t),[f,h]=m.useState([]),[p,x]=m.useState([]),[v,y]=m.useState(null),[b,C]=m.useState(null),[E,A]=m.useState(!1),[S,k]=m.useState(null),[N,T]=m.useState(null),[R,O]=m.useState(!1),[L,I]=m.useState(null),z=Ge(e.state),_=Xc(),{route:U}=qe(),D=m.useCallback(async()=>{const[Ee,Le]=await Promise.allSettled([ue(`/api/work?agentId=${encodeURIComponent(e.id)}&active=false&limit=12`),ue("/api/fleet")]);Ee.status==="fulfilled"&&h(Ee.value),Le.status==="fulfilled"&&y(Le.value)},[e.id]),q=m.useCallback(async Ee=>{I(Ee.id);try{await ip({recordKind:"work_item",recordId:Ee.id,itemUpdatedAt:Ee.updatedAt}),await D()}finally{I(null)}},[D]),Z=m.useCallback(async()=>{if(!r){x([]);return}try{const Ee=await ue(`/api/messages?conversationId=${encodeURIComponent(r)}&limit=20`);x(Ee)}catch{x([])}},[r]),$=m.useCallback(async()=>{A(!0);try{const Ee=await ue(`/api/agents/${encodeURIComponent(e.id)}/observe`);C(Ee)}catch{C({agentId:e.id,source:"unavailable",fidelity:"synthetic",historyPath:null,sessionId:null,updatedAt:Date.now(),data:{events:[{id:`${e.id}:observe-error`,t:0,kind:"system",text:"Observer data is temporarily unavailable.",detail:"Retrying will resume once the session source becomes reachable."}],files:[],contextUsage:[],live:!1}})}finally{A(!1)}},[e.id]),G=m.useCallback(async()=>{if(!e.transport){T(null);return}try{const Ee=await ue(`/api/agents/${encodeURIComponent(e.id)}/session/context`);T(Ee)}catch{T(null)}},[e.id,e.transport]),V=m.useCallback(async()=>{O(!0);try{const Ee=await ue(`/api/agents/${encodeURIComponent(e.id)}/session/reset`,{method:"POST"});k(Ee.catalog),await G(),o==="observe"&&await $()}catch{await G()}finally{O(!1)}},[o,e.id,G,$]);m.useEffect(()=>{D(),Z(),G(),ue(`/api/agents/${encodeURIComponent(e.id)}/session-catalog`).then(k).catch(()=>{})},[D,Z,G,e.id]),m.useEffect(()=>{C(null),A(!1),T(null)},[e.id]),m.useEffect(()=>{o==="observe"&&$()},[o,$]),Vt(()=>{D(),Z(),G(),o==="observe"&&$()}),m.useEffect(()=>{if(o!=="observe"||!b?.data.live)return;const Ee=setInterval(()=>{$()},2500);return()=>clearInterval(Ee)},[o,b?.data.live,$]);const Y=f.find(Ee=>Ee.state==="working"||Ee.state==="review"),K=f.filter(Ee=>(Ee.state==="working"||Ee.state==="review"||Ee.state==="waiting")&&Ee.id!==Y?.id),P=f.filter(Ee=>Ee.state==="done").slice(0,5),H=Wi(e.role)??Wi(e.agentClass),B=e.harness,Q=e.authorityNodeName??e.homeNodeName??e.authorityNodeId??e.homeNodeId,oe=e.authorityNodeId&&e.homeNodeId&&e.authorityNodeId!==e.homeNodeId?`home ${e.homeNodeName??e.homeNodeId}`:null,ne=Nk(e),X=e.authorityNodeName&&e.authorityNodeId?`${e.authorityNodeName} (${e.authorityNodeId})`:e.authorityNodeName??e.authorityNodeId,ae=e.homeNodeName&&e.homeNodeId?`${e.homeNodeName} (${e.homeNodeId})`:e.homeNodeName??e.homeNodeId,be=[e.workspaceQualifier?`workspace ${e.workspaceQualifier}`:null,e.nodeQualifier?`node ${e.nodeQualifier}`:null].filter(Boolean),_e=[H,B].filter(Boolean).filter((Ee,Le,Te)=>Te.indexOf(Ee)===Le),xe=m.useMemo(()=>t.filter(Ee=>Ee.project===e.project).length,[t,e.project]),pe=Y?.currentPhase==="review"?85:Y?.currentPhase==="working"?50:20,ve=(Y?Date.now()-Y.lastMeaningfulAt:0)>30*6e4,he=Y?ve?`no recent signal · ${Ie(Y.lastMeaningfulAt)}`:`${pe}% · live`:"",ke=[{key:"profile",label:"Profile"},{key:"observe",label:"Observe"},{key:"message",label:"Message",disabled:!r}],Ne=Ee=>{a({view:"agents",agentId:e.id,...r?{conversationId:r}:{},tab:Ee})},Fe=(Ee="")=>s.jsx("nav",{className:`s-profile-tabs${Ee?` ${Ee}`:""}`,children:ke.map(Le=>s.jsx("button",{type:"button",className:`s-profile-tab${o===Le.key?" s-profile-tab--active":""}`,disabled:Le.disabled,onClick:()=>Ne(Le.key),children:Le.label},Le.key))});return s.jsxs("div",{className:`s-profile-center${o!=="profile"?" s-profile-center--tabbed":""}`,children:[s.jsx("div",{className:"s-profile-return-row",children:s.jsx(zr,{slot:"agents",fallback:{view:"agents"},navigate:a,className:"s-profile-back-position"})}),o==="profile"?s.jsx("section",{className:"s-profile-identity",onContextMenu:Ee=>{const Le=window.getSelection()?.toString().trim(),Te=[];Le&&(Te.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>{Nn(Le)}}),Te.push({kind:"separator"})),Te.push({kind:"action",label:"Copy Agent Name",onSelect:()=>{Nn(c)}}),Te.push({kind:"action",label:"Copy Agent ID",onSelect:()=>{Nn(e.id)}}),e.handle&&Te.push({kind:"action",label:`Copy @${e.handle}`,onSelect:()=>{Nn(`@${e.handle}`)}}),e.selector&&Te.push({kind:"action",label:"Copy Selector",onSelect:()=>{Nn(e.selector??"")}}),e.defaultSelector&&e.defaultSelector!==e.selector&&Te.push({kind:"action",label:"Copy Default Selector",onSelect:()=>{Nn(e.defaultSelector??"")}}),_(Ee,Te)},children:s.jsxs("div",{className:"s-profile-identity-top",children:[s.jsxs("div",{className:"s-profile-identity-avatar-wrap",children:[s.jsx("div",{className:"s-profile-identity-avatar",style:{background:Xt(e.name)},children:e.name[0].toUpperCase()}),s.jsx("span",{className:`s-profile-identity-pulse s-profile-identity-pulse--${ll(z)}`,style:{background:yn(e.state)}})]}),s.jsxs("div",{className:"s-profile-identity-copy",children:[_e.length>0&&s.jsx("div",{className:"s-profile-identity-eyebrow",children:_e.join(" · ")}),s.jsxs("h1",{className:"s-profile-identity-name",children:[c,u&&s.jsx("span",{className:"s-profile-identity-name-qualifier",children:u}),e.handle&&s.jsxs("span",{className:"s-profile-identity-name-handle",children:["@",e.handle]})]}),s.jsx("div",{className:"s-profile-identity-state-row",children:s.jsxs("span",{className:"s-profile-identity-state",children:[s.jsx("span",{className:`s-profile-identity-state-dot${z==="working"?" s-profile-identity-state-dot--pulse":""}`,style:{background:yn(e.state)}}),s.jsx("span",{className:"s-profile-identity-state-label",children:cs(e.state)}),e.updatedAt&&s.jsxs("span",{className:"s-profile-identity-state-detail",children:["— ",Ie(e.updatedAt)]}),e.staleLocalRegistration&&s.jsx("span",{className:"s-profile-identity-state-detail",children:"superseded registration"})]})}),s.jsxs("div",{className:"s-profile-identity-qualified",children:[s.jsx("span",{children:e.id}),ne&&s.jsx("span",{children:ne}),e.defaultSelector&&e.defaultSelector!==ne&&s.jsx("span",{children:e.defaultSelector})]}),s.jsx(Sf,{agent:e,catalog:S,navigate:a,returnTo:U,variant:"inline"})]}),Fe()]})}):s.jsx("div",{className:"s-profile-compact-tabs",children:Fe("s-profile-tabs--compact")}),o==="profile"&&s.jsxs("div",{className:"s-profile-tab-content",children:[(e.id||ne||Q||e.project||e.branch||e.cwd||S?.activeSessionId||N)&&s.jsxs("div",{className:"s-profile-facets",children:[s.jsxs("div",{className:"s-profile-facet s-profile-facet--identity",children:[s.jsx("div",{className:"s-profile-facet-label",children:"Agent ID"}),s.jsx("div",{className:"s-profile-facet-value s-profile-facet-value--mono",children:e.id}),s.jsxs("div",{className:"s-profile-facet-detail",children:["definition ",e.definitionId]})]}),ne&&s.jsxs("div",{className:"s-profile-facet",children:[s.jsx("div",{className:"s-profile-facet-label",children:"Selector"}),s.jsx("div",{className:"s-profile-facet-value s-profile-facet-value--mono",children:ne}),e.defaultSelector&&e.defaultSelector!==ne&&s.jsxs("div",{className:"s-profile-facet-detail",children:["default ",e.defaultSelector]})]}),(be.length>0||X||ae)&&s.jsxs("div",{className:"s-profile-facet",children:[s.jsx("div",{className:"s-profile-facet-label",children:"Authority"}),s.jsx("div",{className:"s-profile-facet-value",children:X??Q??"local"}),s.jsx("div",{className:"s-profile-facet-detail",children:be.length>0?be.join(" · "):ae&&ae!==X?`home ${ae}`:"qualified route"})]}),Q&&s.jsxs("div",{className:"s-profile-facet",children:[s.jsx("div",{className:"s-profile-facet-label",children:"Machine"}),s.jsx("div",{className:"s-profile-facet-value",children:Q}),oe&&s.jsx("div",{className:"s-profile-facet-detail",children:oe})]}),e.project&&s.jsxs("div",{className:"s-profile-facet",children:[s.jsx("div",{className:"s-profile-facet-label",children:"Workspace"}),s.jsx("div",{className:"s-profile-facet-value",children:e.project}),xe>1&&s.jsxs("div",{className:"s-profile-facet-detail",children:[xe," teammates"]})]}),(e.branch||e.projectRoot)&&s.jsxs("div",{className:"s-profile-facet",children:[s.jsx("div",{className:"s-profile-facet-label",children:"Repo / Branch"}),s.jsx("div",{className:"s-profile-facet-value",children:e.projectRoot?e.projectRoot.split("/").pop():e.project??"—"}),e.branch&&s.jsxs("div",{className:"s-profile-facet-detail",children:[s.jsx("span",{className:"s-profile-facet-accent",children:"⎇"})," ",e.branch]})]}),e.cwd&&s.jsxs("div",{className:"s-profile-facet",children:[s.jsx("div",{className:"s-profile-facet-label",children:"Working Dir"}),s.jsx("div",{className:"s-profile-facet-value",children:e.cwd.startsWith("/Users/")?"~/"+e.cwd.split("/").slice(3).join("/"):e.cwd}),e.updatedAt&&s.jsxs("div",{className:"s-profile-facet-detail",children:["uptime ",Ie(e.updatedAt)]})]}),S?.activeSessionId&&s.jsx(yue,{catalog:S,agentId:e.id}),N&&s.jsx(Nue,{context:N,lastActivityAt:e.updatedAt??null,resetting:R,onReset:()=>{V()}})]}),Y&&z==="working"&&s.jsxs(s.Fragment,{children:[s.jsx(Od,{label:"Current task",right:he}),s.jsxs("div",{className:"s-profile-task",children:[s.jsx("div",{className:"s-profile-task-title",children:Y.title}),Y.lastMeaningfulSummary&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"s-profile-task-progress",children:s.jsx("div",{className:"s-profile-task-progress-bar",style:{width:`${pe}%`}})}),s.jsxs("div",{className:"s-profile-task-action",children:[s.jsx("span",{className:"s-profile-task-action-chevron",children:"›"}),s.jsx("span",{children:Y.lastMeaningfulSummary}),s.jsx("span",{className:"s-profile-task-cursor"})]})]}),s.jsxs("div",{className:"s-profile-task-meta",children:[s.jsx("span",{children:Y.currentPhase}),s.jsx("span",{children:Ie(Y.lastMeaningfulAt)})]}),s.jsxs("div",{className:"s-profile-task-controls","aria-label":"Current task actions",children:[s.jsx("button",{type:"button",className:"s-profile-task-btn s-profile-task-btn--primary",onClick:()=>wt(a,{view:"work",workId:Y.id},{returnTo:U}),children:"Open work"}),s.jsx("button",{type:"button",className:"s-profile-task-btn",onClick:()=>Ne("observe"),children:"Observe"}),r&&s.jsx("button",{type:"button",className:"s-profile-task-btn",onClick:()=>Ne("message"),children:"Message"})]})]})]}),K.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(Od,{label:"Active work",right:`${K.length} in flight`}),s.jsx("div",{className:"s-profile-work",children:s.jsx(RM,{items:K,navigate:a,emptyTitle:"Nothing in flight",onDismissAttention:Ee=>{q(Ee)},dismissingId:L})})]}),P.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(Od,{label:K.length>0?"Recently completed":"Recent work",right:`${P.length}`}),s.jsx("div",{className:"s-profile-work",children:s.jsx(RM,{items:P,navigate:a,emptyTitle:""})})]}),s.jsx(Sue,{agent:e,fleet:v,navigate:a}),s.jsx(Cue,{messages:p,navigate:a,conversationId:r,agentId:e.id})]}),o==="observe"&&s.jsx("div",{className:"s-profile-tab-conversation",children:E&&!b?s.jsxs("div",{className:"s-profile-activity-empty",children:[s.jsx("div",{className:"s-profile-activity-empty-title",children:"Loading trace"}),s.jsx("div",{className:"s-profile-activity-empty-detail",children:"Resolving the best available live or history-backed session stream for this agent."})]}):s.jsx(qg,{data:b?.data,agentId:e.id,sessionId:b?.sessionId,showRail:!1})}),o==="message"&&r&&s.jsx("div",{className:"s-profile-tab-conversation",children:s.jsx(eu,{conversationId:r,navigate:a,embedded:!0})})]})}function Aue({navigate:e,selectedAgentId:t,conversationId:n,tab:r,activeRoute:a}){const{agents:o,route:c}=qe(),[u,f]=m.useState([]),[h,p]=m.useState(null),[x,v]=m.useState(null),[y,b]=m.useState(null),C=zs(c),E=m.useMemo(()=>no(o,C),[o,C]),A=m.useCallback(async()=>{const[R,O,L,I]=await Promise.allSettled([ue("/api/conversations"),ue("/api/fleet"),ue("/api/tail/discover"),ue("/api/topology/snapshot?force=1")]);R.status==="fulfilled"&&f(R.value),O.status==="fulfilled"&&p(O.value),L.status==="fulfilled"&&v(L.value),I.status==="fulfilled"&&b(I.value)},[]);m.useEffect(()=>{A()},[A]),m.useEffect(()=>{const R=window.setInterval(()=>{A()},1e4);return()=>window.clearInterval(R)},[A]),Vt(()=>{A()});const S=xue(E,t),k=!!(t&&S&&S.id!==t),{conversationByAgentId:N,sessionByAgentId:T}=Uce(u);if(m.useEffect(()=>{if(!t||!S||!k)return;const R=Qn(t),O=n===R?S.conversationId:n;e({view:"agents",agentId:S.id,...O?{conversationId:O}:{},...r?{tab:r}:{}})},[n,r,e,S,t,k]),S){const R=k&&t?Qn(t):null,O=n===R?S.conversationId:n??N.get(S.id)??S.conversationId??null,L=r??(n?"message":"profile");return s.jsx(eR,{activeRoute:a??c,navigate:e,children:s.jsx(Eue,{agent:S,allAgents:E,session:T.get(S.id)??null,conversationId:O,navigate:e,activeTab:L})})}return s.jsx(eR,{activeRoute:a??c,navigate:e,children:s.jsx(Tue,{agents:E,fleet:h,sessionByAgentId:T,conversationByAgentId:N,sessions:u,discovery:x,topologySnapshot:y,navigate:e})})}function eR({activeRoute:e,children:t,navigate:n}){return s.jsxs("div",{className:"s-secondary-nav-shell",children:[s.jsx("div",{className:"s-secondary-nav-bar",children:s.jsx(kk,{activeRoute:e,navigate:n})}),s.jsx("div",{className:"s-secondary-nav-body",children:t})]})}function Tue({agents:e,fleet:t,sessionByAgentId:n,conversationByAgentId:r,sessions:a,discovery:o,topologySnapshot:c,navigate:u}){const{route:f}=qe(),h=la("surface.workflows",!1),[p,x]=m.useState(""),[v,y]=m.useState(()=>new Set),[b,C]=m.useState(()=>new Set),[E,A]=m.useState("cards"),[S,k]=m.useState(db),[N,T]=m.useState(Date.now()),[R,O]=m.useState({key:"status",dir:1});m.useEffect(()=>{const te=window.setInterval(()=>T(Date.now()),15e3);return()=>window.clearInterval(te)},[]);const L=m.useMemo(()=>{const te=new Map;for(const ve of t?.activeAsks??[]){const he=te.get(ve.agentId)??[];he.push(ve),te.set(ve.agentId,he)}return te},[t?.activeAsks]),I=m.useMemo(()=>e.map(te=>cue(te,n.get(te.id)??null,L.get(te.id)??[])),[L,e,n]),z=m.useMemo(()=>iue(o,N),[o,N]),_=m.useMemo(()=>oue(c),[c]),U=m.useMemo(()=>I.filter(te=>gm(te.lastActivityAt,S,N,te.status==="working")),[N,I,S]),D=m.useMemo(()=>z.filter(te=>gm(te.lastActivityAt,S,N,te.status==="active")),[z,N,S]),q=m.useMemo(()=>a.filter(te=>gm(te.lastMessageAt,S,N,!1)),[N,a,S]),Z=m.useMemo(()=>_.filter(te=>gm(te.lastActivityAt,S,N,te.activeTaskCount>0||te.status==="running")),[N,S,_]),$=m.useMemo(()=>XM(U,q,D,Z),[D,U,q,Z]),G=m.useMemo(()=>({total:U.length,online:U.filter(te=>te.status!=="not_ready").length,working:U.filter(te=>te.status==="working").length,ready:U.filter(te=>te.status==="ready").length,notReady:U.filter(te=>te.status==="not_ready").length,projects:$.length,scoutSessions:$.reduce((te,ve)=>te+ve.scoutSessions.length,0),nativeSessions:D.length,activeNativeSessions:D.filter(te=>te.status==="active").length}),[$,D,U]),V=m.useMemo(()=>{const te=new Map;for(const ve of U)te.set(ve.harness,(te.get(ve.harness)??0)+1);for(const ve of D)te.set(ve.source,(te.get(ve.source)??0)+1);for(const ve of Z)te.set(ve.source,(te.get(ve.source)??0)+1);for(const ve of q){const he=Wi(ve.harness)??"scout";te.set(he,(te.get(he)??0)+1)}return[...te.entries()].sort((ve,he)=>he[1]-ve[1]||ve[0].localeCompare(he[0]))},[D,U,q,Z]),Y=m.useMemo(()=>{const te=new Set(U.map(ve=>ve.status));return["working","ready","not_ready"].filter(ve=>te.has(ve))},[U]),K=m.useMemo(()=>{const te=p.trim().toLowerCase();return U.filter(ve=>v.size>0&&!v.has(ve.harness)||b.size>0&&!b.has(ve.status)?!1:mue(ve,te))},[v,U,p,b]),P=m.useMemo(()=>{const te=p.trim().toLowerCase();return D.filter(ve=>pue(ve,te,v))},[v,D,p]),H=m.useMemo(()=>{const te=p.trim().toLowerCase();return q.filter(ve=>gue(ve,te,v))},[v,q,p]),B=m.useMemo(()=>{const te=p.trim().toLowerCase();return Z.filter(ve=>vue(ve,te,v))},[v,Z,p]),Q=m.useMemo(()=>XM(K,H,P,B),[P,K,H,B]),oe=f.view==="agents"&&!f.agentId?f.projectKey:void 0,ne=m.useMemo(()=>oe?$.find(te=>te.key===oe)??null:null,[$,oe]),X=m.useMemo(()=>oe?Q.filter(te=>te.key===oe):Q,[Q,oe]);m.useMemo(()=>oe?K.filter(te=>d5(te).key===oe):K,[K,oe]),m.useMemo(()=>R.key==="status"?void 0:(te,ve)=>pc[te.status]-pc[ve.status],[R.key]);const ae=te=>{const ve=r.get(te.agent.id);u({view:"agents",agentId:te.agent.id,...ve?{conversationId:ve}:{}})},be=te=>{A("tree"),u({view:"agents",projectKey:te.key})},_e=()=>{u({view:"agents"})},xe=te=>{y(ve=>{const he=new Set(ve);return he.has(te)?he.delete(te):he.add(te),he})},pe=te=>{C(ve=>{const he=new Set(ve);return he.has(te)?he.delete(te):he.add(te),he})};return s.jsx("div",{className:"s-agents-library s-agents-library--inventory",children:s.jsxs("div",{className:"s-agents-inventory",children:[s.jsxs("div",{className:"s-atop-fbar",children:[s.jsxs("div",{className:"s-atop-search",children:[s.jsx("span",{className:"s-atop-search-prompt",children:"▸"}),s.jsx("input",{className:"s-atop-search-input",value:p,onChange:te=>x(te.target.value),placeholder:"filter projects · agents · sessions"}),s.jsx("span",{className:"s-atop-search-kbd",children:"/"})]}),s.jsxs("div",{className:"s-agents-library-view",role:"group","aria-label":"Agents view",children:[s.jsx("button",{type:"button",className:"s-agents-library-view-btn","data-active":E==="cards",onClick:()=>A("cards"),children:"cards"}),s.jsx("button",{type:"button",className:"s-agents-library-view-btn","data-active":E==="tree",onClick:()=>A("tree"),children:"tree"})]}),s.jsx("span",{className:"s-atop-fbar-label",children:"time"}),Wce.map(te=>s.jsx("button",{type:"button",className:`s-atop-pill s-atop-pill--time${S===te.key?" s-atop-pill--on":""}`,onClick:()=>k(te.key),children:te.label},te.key)),oe&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"s-atop-fbar-label",children:"project"}),s.jsxs("button",{type:"button",className:"s-atop-pill s-atop-pill--on s-atop-pill--project",onClick:_e,title:"Return to all project overviews",children:[s.jsx("span",{className:"s-atop-pill-main",children:ne?.title??"selected project"}),s.jsx("span",{className:"s-atop-pill-ct",children:"clear"})]})]}),V.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"s-atop-fbar-label",children:"harness"}),V.map(([te,ve])=>{const he=v.has(te);return s.jsxs("button",{type:"button",className:`s-atop-pill s-atop-pill--harness${he?" s-atop-pill--on":""}`,onClick:()=>xe(te),children:[te,s.jsx("span",{className:"s-atop-pill-ct",children:ve})]},te)})]}),Y.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"s-atop-fbar-label",children:"status"}),Y.map(te=>{const ve=b.has(te),he=U.filter(ke=>ke.status===te).length;return s.jsxs("button",{type:"button",className:`s-atop-pill s-agents-inventory-pill--status-${Dc(te)}${ve?" s-atop-pill--on":""}`,onClick:()=>pe(te),children:[qce(te),s.jsx("span",{className:"s-atop-pill-ct",children:he})]},te)})]}),s.jsx("div",{className:"s-atop-fbar-spacer"}),(v.size>0||b.size>0||p||oe||S!==db)&&s.jsx("button",{type:"button",className:"s-atop-pill",onClick:()=>{x(""),y(new Set),C(new Set),k(db),oe&&_e()},children:"clear"})]}),h&&s.jsx("div",{className:"s-agents-library-topology",children:s.jsx(Vg,{title:"Observed harness families",size:"compact",maxAgents:8,maxTasks:4,showEmpty:!0})}),s.jsx(Mue,{projects:X,totalProjects:G.projects,query:p,selectedProject:ne,selectedProjectKey:oe,navigate:u,route:f,openAgent:ae,onSelectProject:be,mode:E}),s.jsxs("div",{className:"s-atop-keys",children:[s.jsx("span",{className:"s-atop-keys-count",children:E==="cards"?s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:X.length})," / ",G.projects," project",G.projects===1?"":"s",oe?" selected":""]}):s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:X.length})," / ",G.projects," project tree",G.projects===1?"":"s"]})}),s.jsx("span",{className:"s-atop-keys-spacer"}),s.jsx("span",{children:S==="all"?"all time":`last ${S}`}),s.jsxs("span",{children:[G.notReady," not ready"]}),s.jsxs("span",{children:[G.nativeSessions," harness session",G.nativeSessions===1?"":"s"]})]})]})})}function Mue({projects:e,totalProjects:t,query:n,selectedProject:r,selectedProjectKey:a,navigate:o,route:c,openAgent:u,onSelectProject:f,mode:h}){return e.length===0?s.jsx("div",{className:"s-agent-projects s-agent-projects--empty",children:s.jsxs("div",{className:"s-agent-project-empty",children:[s.jsx("div",{className:"s-agent-project-empty-title",children:a?r?"selected project hidden":"project no longer visible":t===0?"no projects visible":"no projects match"}),s.jsx("div",{className:"s-agent-project-empty-body",children:a&&r?"Adjust the current filters to bring this project overview back into view.":a?"Return to all projects or select another project from the current project set.":n.trim()?"Adjust the current project, agent, or session filter.":"Projects appear when agents, Scout sessions, or harness sessions are discovered."})]})}):s.jsx("div",{className:"s-agent-projects",children:e.map(p=>s.jsx(Rue,{project:p,navigate:o,route:c,openAgent:u,selected:p.key===a,onSelectProject:f,mode:h},p.key))})}function Rue({project:e,navigate:t,route:n,openAgent:r,selected:a,onSelectProject:o,mode:c}){const u=e.agents.filter(v=>v.status!=="not_ready").length,f=e.agents.reduce((v,y)=>v+y.activeAskCount,0),h=e.nativeSessions.length+e.scoutSessions.length,p=e.workflows.length,x=[`${u}/${e.agents.length} agents`,lp(h,"session"),p>0?lp(p,"workflow"):null,f>0?lp(f,"active task"):null,e.lastActivityAt?`last ${Ie(e.lastActivityAt)}`:null].filter(v=>!!v);return s.jsxs("section",{className:`s-agent-project s-agent-project--${Dc(e.status)}${a?" s-agent-project--selected":""}`,children:[s.jsxs("div",{className:"s-agent-project-head",children:[s.jsx("button",{type:"button",className:"s-agent-project-select","data-selected":a,onClick:()=>o(e),"aria-pressed":a,title:`Open ${e.title} project overview`,children:s.jsxs("span",{className:"s-agent-project-title-block",children:[s.jsx("span",{className:"s-agent-project-title",children:e.title}),e.root&&s.jsx("span",{className:"s-agent-project-root",title:e.root,children:e.root})]})}),s.jsx("div",{className:"s-agent-project-summary","aria-label":`${e.title} project summary`,children:x.join(" · ")})]}),a||c==="tree"?s.jsx(Oue,{project:e,navigate:t,route:n,openAgent:r}):s.jsx(Iue,{project:e,navigate:t,route:n,openAgent:r,onOpenProject:()=>o(e)})]})}function Iue({project:e,navigate:t,route:n,openAgent:r,onOpenProject:a}){const o=m.useMemo(()=>p5(e),[e]),c=o.agents.slice(0,Vce),u=o.agents.length-c.length,f=m.useMemo(()=>Gp([...e.workflows.map(h5),...o.unassignedSessions].filter(m5)),[e.workflows,o.unassignedSessions]),h=e.workflows.length,p=f.slice(0,Hce),x=f.length-p.length;return e.agents.length===0&&f.length===0?s.jsx("div",{className:"s-agent-project-empty-inline",children:"No agents or sessions."}):s.jsx("div",{className:"s-agent-project-labeled-list",children:s.jsx("section",{className:`s-agent-project-labeled s-agent-project-labeled--${Dc(e.status)}`,children:s.jsxs("div",{className:"s-agent-project-labeled-body",children:[s.jsxs("div",{className:"s-agent-project-labeled-pane",children:[s.jsxs("div",{className:"s-agent-project-section-head",children:[s.jsx("span",{children:"Agents"}),s.jsx("strong",{children:u>0?`${c.length}/${o.agents.length}`:o.agents.length})]}),e.agents.length===0?s.jsx("div",{className:"s-agent-project-empty-inline",children:"No agent cards registered."}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"s-agent-project-card-grid s-agent-project-card-grid--compact",children:c.map(v=>s.jsx($ue,{row:v.row,attachedSessionCount:v.sessions.length,onOpen:()=>r(v.row)},v.row.agent.id))}),u>0&&s.jsxs("button",{type:"button",className:"s-agent-project-more",onClick:a,children:["show ",u," more in tree"]})]})]}),s.jsxs("div",{className:"s-agent-project-labeled-pane",children:[s.jsxs("div",{className:"s-agent-project-section-head",children:[s.jsx("span",{children:h>0?"Workflows + unattached":"Unattached sessions"}),s.jsx("strong",{children:x>0?`${p.length}/${f.length}`:f.length})]}),s.jsx(_ue,{sessions:p,navigate:t,route:n}),x>0&&s.jsxs("button",{type:"button",className:"s-agent-project-more",onClick:a,children:["show ",x," more in tree"]})]})]})})})}function _ue({sessions:e,navigate:t,route:n}){return e.length===0?s.jsx("div",{className:"s-agent-project-empty-inline",children:"No sessions."}):s.jsx("div",{className:"s-agent-project-session-list",children:e.map(r=>s.jsxs("button",{type:"button",className:`s-agent-project-session s-agent-project-session--${r.kind}`,disabled:!r.route,onClick:()=>{r.route&&wt(t,r.route,{returnTo:n})},title:r.detail??r.label,children:[s.jsx("span",{className:"s-agent-project-session-status",children:r.status}),s.jsx("span",{className:Sk(r.harness),children:r.harness}),s.jsx("span",{className:"s-agent-project-session-main",children:r.label}),s.jsx("span",{className:"s-agent-project-session-sub",children:r.subLabel??(r.lastActivityAt?Ie(r.lastActivityAt):r.kind)})]},r.key))})}function Oue({project:e,navigate:t,route:n,openAgent:r}){const a=m.useMemo(()=>p5(e),[e]),o=m.useMemo(()=>Gp([...e.workflows.map(h5),...a.unassignedSessions].filter(m5)),[e.workflows,a.unassignedSessions]),c=u=>{u.route&&wt(t,u.route,{returnTo:n})};return s.jsx("div",{className:"s-agent-project-tree s-agent-project-tree--compact",role:"treegrid","aria-label":`${e.title} agent and session outline`,children:s.jsxs("div",{className:"s-agent-project-tree-grid",children:[a.agents.map(u=>{const f=u.row,h=u.sessions.length;return s.jsxs(m.Fragment,{children:[s.jsxs("div",{className:`s-agent-project-tree-row s-agent-project-tree-row--agent s-agent-project-tree-row--${Dc(f.status)}`,role:"row",children:[s.jsxs("div",{className:"s-agent-project-tree-target",children:[s.jsx("span",{className:"s-agent-project-tree-branch","aria-hidden":!0}),s.jsxs("button",{type:"button",className:"s-agent-project-tree-link",onClick:()=>r(f),title:Nk(f.agent)??f.agent.id,children:[s.jsxs("span",{className:"s-agent-project-tree-primary",children:[s.jsx("span",{className:"s-agent-project-tree-dot",style:{background:yn(f.agent.state)},"aria-hidden":!0}),f.agent.name]}),s.jsx("span",{className:"s-agent-project-tree-secondary",children:f.activeTask??f.session?.preview??f.agent.id})]})]}),s.jsx("span",{className:`s-agent-project-tree-state s-agent-project-tree-state--${Dc(f.status)}`,children:f.stateLabel.toLowerCase()}),s.jsx("span",{className:"s-agent-project-tree-mono",title:f.agent.cwd??f.agent.projectRoot??void 0,children:f.branch!=="—"?f.branch:"—"}),s.jsx("span",{className:"s-agent-project-tree-mono",children:h||"—"}),s.jsx("span",{className:"s-agent-project-tree-mono",children:f.lastActivityAt?Ie(f.lastActivityAt):"—"})]}),u.sessions.map(p=>s.jsx(tR,{session:p,compact:!0,onOpen:()=>c(p)},p.key))]},u.key)}),o.map(u=>s.jsx(tR,{session:u,compact:!0,onOpen:()=>c(u)},u.key))]})})}function tR({session:e,onOpen:t,compact:n=!1}){const r=`s-agent-project-tree-row s-agent-project-tree-row--session s-agent-project-tree-row--${e.kind}`,a=s.jsxs("div",{className:"s-agent-project-tree-target",children:[s.jsx("span",{className:"s-agent-project-tree-branch","aria-hidden":!0}),s.jsxs("button",{type:"button",className:"s-agent-project-tree-link",disabled:!e.route,onClick:t,title:e.detail??e.label,children:[s.jsx("span",{className:"s-agent-project-tree-primary",children:e.label}),s.jsx("span",{className:"s-agent-project-tree-secondary",children:e.detail??e.kind})]})]});return n?s.jsxs("div",{className:r,role:"row",children:[a,s.jsx("span",{className:`s-agent-project-tree-state s-agent-project-tree-state--${uw(e.status)}`,children:e.status}),s.jsx("span",{className:"s-agent-project-tree-muted",children:e.kind}),s.jsx("span",{className:"s-agent-project-tree-muted",children:"—"}),s.jsx("span",{className:"s-agent-project-tree-mono",children:e.lastActivityAt?Ie(e.lastActivityAt):"live"})]}):s.jsxs("div",{className:r,role:"row",children:[a,s.jsx("span",{className:`s-agent-project-tree-state s-agent-project-tree-state--${uw(e.status)}`,children:e.status}),s.jsx("span",{className:Sk(e.harness),children:e.harness}),s.jsx("span",{className:"s-agent-project-tree-muted",children:e.kind}),s.jsx("span",{className:"s-agent-project-tree-muted",children:"—"}),s.jsx("span",{className:"s-agent-project-tree-mono",children:e.lastActivityAt?Ie(e.lastActivityAt):"live"}),s.jsx("span",{className:"s-agent-project-tree-actions",children:s.jsx("button",{type:"button",className:"s-agent-project-tree-action",disabled:!e.route,onClick:t,children:e.kind==="native"?"observe":e.kind==="workflow"?"trace":"open"})})]})}function $ue({row:e,attachedSessionCount:t=0,onOpen:n}){const r=Nk(e.agent),a=e.activeTask??e.session?.preview??e.stateLabel,o=!e.activeTask&&!e.session?.preview;return s.jsxs("button",{type:"button",className:"s-agent-project-card","data-state":Dc(e.status),onClick:n,title:r??e.agent.id,children:[s.jsxs("span",{className:"s-agent-project-card-top",children:[s.jsx("span",{className:"s-agent-project-card-dot",style:{background:yn(e.agent.state)},"aria-hidden":"true"}),s.jsx("span",{className:"s-agent-project-card-name",children:e.agent.name}),e.lastActivityAt&&s.jsx("span",{className:"s-agent-project-card-time",children:Ie(e.lastActivityAt)})]}),s.jsx("span",{className:`s-agent-project-card-signal${o?" s-agent-project-card-signal--quiet":""}`,children:a}),s.jsxs("span",{className:"s-agent-project-card-chips",children:[s.jsx("span",{className:`${Sk(e.harness)} s-agent-project-card-harness`,children:e.harness}),e.branch!=="—"&&s.jsx("span",{className:"s-agent-project-chip",children:e.branch}),t>0?s.jsx("span",{className:"s-agent-project-chip s-agent-project-chip--attached-session",children:lp(t,"session")}):(e.session?.id||e.agent.harnessSessionId)&&s.jsxs("span",{className:"s-agent-project-chip s-agent-project-chip--session",children:["session ",Ck(e.session?.id??e.agent.harnessSessionId)]}),e.activeAskCount>0&&s.jsxs("span",{className:"s-agent-project-chip s-agent-project-chip--active",children:[e.activeAskCount," active"]})]})]})}const nR=new RegExp("(?:^|(?<=[\\s(`'\"<>]))(?:~\\/|\\/(?:Users|home|opt|var|etc|tmp|private)\\/)[^\\s)`'\"<>]+\\.[A-Za-z0-9]{1,8}\\b","g");function Lue(e){const t=e.replace(/\r\n?/g,`
169
- `).split(`
170
- `),n=[];let r=0;for(;r<t.length;){const a=t[r];if(a.trim()===""){r+=1;continue}if(a.startsWith("```")){const u=[];for(r+=1;r<t.length&&!t[r].startsWith("```");)u.push(t[r]),r+=1;r<t.length&&(r+=1),n.push({kind:"code",body:u.join(`
171
- `)});continue}const o=a.match(/^(#{1,3})\s+(.*\S)\s*$/);if(o){const u=o[1].length;n.push({kind:"heading",level:u,tokens:hb(o[2])}),r+=1;continue}if(fb(a)){const u=[];for(;r<t.length&&fb(t[r]);)u.push(hb(Pue(t[r]))),r+=1;n.push({kind:"list",items:u});continue}const c=[];for(;r<t.length&&t[r].trim()!==""&&!t[r].startsWith("```")&&!fb(t[r])&&!/^#{1,3}\s+\S/.test(t[r]);)c.push(hb(t[r])),r+=1;n.push({kind:"paragraph",lines:c})}return n}const g5=/^\s*[-*]\s+/;function fb(e){return g5.test(e)}function Pue(e){return e.replace(g5,"")}function hb(e){const t=[];let n=0,r="";const a=()=>{r&&(t.push({kind:"text",body:r}),r="")};for(;n<e.length;){const o=e[n];if(o==="`"){const c=e.indexOf("`",n+1);if(c!==-1&&c>n+1){a(),t.push({kind:"code",body:e.slice(n+1,c)}),n=c+1;continue}}else if(o==="*"&&e[n+1]==="*"){const c=e.indexOf("**",n+2);if(c!==-1&&c>n+2){a(),t.push({kind:"bold",body:e.slice(n+2,c)}),n=c+2;continue}}else if(o==="*"||o==="_"){const c=Bue(e,n+1,o);if(c!==-1){a(),t.push({kind:"italic",body:e.slice(n+1,c)}),n=c+1;continue}}r+=o,n+=1}return a(),Due(t)}function Due(e){const t=[];for(const n of e){if(n.kind!=="text"){t.push(n);continue}const r=zue(n.body);r.length===1&&r[0].kind==="text"?t.push(n):t.push(...r)}return t}function zue(e){if(!e)return[];const t=[];let n=0;nR.lastIndex=0;let r;for(;(r=nR.exec(e))!==null;){const a=r.index,o=a+r[0].length;a>n&&t.push({kind:"text",body:e.slice(n,a)}),t.push({kind:"file-path",body:r[0]}),n=o}return n===0?[{kind:"text",body:e}]:(n<e.length&&t.push({kind:"text",body:e.slice(n)}),t)}function Bue(e,t,n){if(e[t]===void 0||/\s/.test(e[t]))return-1;for(let r=t;r<e.length;r+=1){const a=e[r];if(a===n){const o=e[r-1];if(o&&!/\s/.test(o)&&e[r+1]!==n)return r}if(a===`
172
- `)return-1}return-1}function v5({text:e}){const t=Lue(e);return t.length===0?null:s.jsx("div",{className:"flex flex-col gap-1.5 text-[11px] leading-relaxed text-[var(--scout-chrome-ink)]",children:t.map((n,r)=>s.jsx(Uue,{block:n},r))})}function Uue({block:e}){switch(e.kind){case"paragraph":return s.jsx("p",{className:"whitespace-pre-wrap break-words",children:e.lines.map((t,n)=>s.jsxs(m.Fragment,{children:[n>0&&`
173
- `,s.jsx(nd,{tokens:t})]},n))});case"list":return s.jsx("ul",{className:"ml-3 flex list-disc flex-col gap-1 marker:text-[var(--scout-chrome-ink-ghost)]",children:e.items.map((t,n)=>s.jsx("li",{className:"break-words pl-0.5",children:s.jsx(nd,{tokens:t})},n))});case"code":return s.jsx("pre",{className:"overflow-x-auto rounded border border-[var(--scout-chrome-border-soft)] bg-black/25 px-2 py-1.5 text-[10px] leading-relaxed text-lime-100/90",children:e.body});case"heading":{const t="font-mono text-[var(--scout-chrome-ink-strong)] mt-2 first:mt-0";return e.level===1?s.jsx("h2",{className:`${t} text-[13px] font-bold uppercase tracking-[0.12em]`,children:s.jsx(nd,{tokens:e.tokens})}):e.level===2?s.jsx("h3",{className:`${t} text-[11px] font-bold uppercase tracking-[0.14em] text-[var(--scout-chrome-ink)]`,children:s.jsx(nd,{tokens:e.tokens})}):s.jsx("h4",{className:`${t} text-[10px] font-bold uppercase tracking-[0.16em] text-[var(--scout-chrome-ink-faint)]`,children:s.jsx(nd,{tokens:e.tokens})})}}}function nd({tokens:e}){return s.jsx(s.Fragment,{children:e.map((t,n)=>{switch(t.kind){case"text":return s.jsx(m.Fragment,{children:t.body},n);case"code":return s.jsx("code",{className:"rounded bg-black/25 px-1 text-[10px] text-lime-100/90",children:t.body},n);case"bold":return s.jsx("strong",{className:"font-bold text-[var(--scout-chrome-ink-strong)]",children:t.body},n);case"italic":return s.jsx("em",{className:"italic",children:t.body},n);case"file-path":return s.jsx(Fue,{path:t.body},n)}})})}function Fue({path:e}){const{openFilePreview:t}=qe(),n=Vue(e),r=a=>{a.stopPropagation(),ue("/api/file/reveal",{method:"POST",body:JSON.stringify({path:e})}).catch(()=>{})};return s.jsxs("span",{className:"inline-flex items-center gap-1 align-baseline",children:[s.jsx("button",{type:"button",onClick:()=>t(e),title:`Preview ${e} in Scout`,className:"inline-flex items-center gap-1 rounded border border-lime-300/30 bg-lime-300/[0.05] px-1.5 py-[1px] font-mono text-[10px] text-lime-200 transition-colors hover:bg-lime-300/[0.12] hover:text-lime-100",children:s.jsx("span",{className:"truncate",children:n})}),s.jsx("button",{type:"button",onClick:r,title:`Open ${e} in your OS`,"aria-label":"Open in OS",className:"inline-flex items-center justify-center rounded border border-[var(--scout-chrome-border-soft)] p-[2px] text-[var(--scout-chrome-ink-faint)] transition-colors hover:bg-[var(--scout-chrome-hover)] hover:text-[var(--scout-chrome-ink)]",children:s.jsx(wr,{size:10})})]})}function Vue(e){const t=e.split("/").filter(Boolean);return t.length<=3?e:`…/${t.slice(-2).join("/")}`}const Hue={"fleet-home":"fleet briefing",tour:"tour briefing"};function Wue({briefingId:e,navigate:t}){const[n,r]=m.useState(null),[a,o]=m.useState(null),c=m.useCallback(async()=>{try{const u=await ue(`/api/briefings/${encodeURIComponent(e)}`);r(u),o(null)}catch(u){o(u instanceof Error?u.message:"Failed to load briefing")}},[e]);return m.useEffect(()=>{c()},[c]),a?s.jsxs("div",{className:"sys-surface-page sys-surface-page-wide",children:[s.jsx("button",{type:"button",className:"briefing-detail-back",onClick:()=>t({view:"briefings"}),children:"← back to briefings"}),s.jsx(hs,{title:"Couldn't load briefing",body:a})]}):n?s.jsxs("div",{className:"sys-surface-page sys-surface-page-wide briefing-detail",children:[s.jsx("button",{type:"button",className:"briefing-detail-back",onClick:()=>t({view:"briefings"}),children:"← back to briefings"}),s.jsxs("header",{className:"briefing-detail-header",children:[s.jsx("h2",{children:n.title}),s.jsxs("div",{className:"briefing-detail-header-meta",children:[s.jsx("span",{className:`briefing-kind briefing-kind-${n.kind}`,children:Hue[n.kind]}),s.jsx("span",{children:kr(n.preparedAt)}),s.jsxs("span",{children:["· ",Ie(n.preparedAt)]})]}),s.jsx("p",{className:"briefing-detail-summary",children:n.summary}),n.recommendation?s.jsx("div",{className:"briefing-detail-recommendation",children:n.recommendation}):null]}),n.markdown?s.jsx(que,{markdown:n.markdown}):null,n.brief?.presented?s.jsx(Gue,{presented:n.brief.presented}):null,s.jsx(Kue,{call:n.call}),s.jsx(Zue,{brief:n.brief,navigate:t}),s.jsx(Yue,{observations:n.observations,navigate:t}),s.jsx(Que,{snapshot:n.snapshot,call:n.call})]}):s.jsx("div",{className:"sys-surface-page sys-surface-page-wide",children:s.jsx("div",{className:"briefings-placeholder",children:"Loading briefing..."})})}function que({markdown:e}){return s.jsxs("section",{className:"briefing-layer briefing-layer-markdown",children:[s.jsx(nl,{eyebrow:"Layer 0",title:"Brief (markdown)"}),s.jsx("div",{className:"briefing-markdown",children:s.jsx(v5,{text:e})})]})}function Kue({call:e}){return!e||!e.telemetry&&!e.presenter?null:s.jsxs("section",{className:"briefing-layer briefing-layer-telemetry",children:[s.jsx(nl,{eyebrow:"Telemetry",title:"Calls & usage"}),s.jsxs("dl",{className:"briefing-telemetry",children:[s.jsx(sR,{label:"Analyst",model:e.model,responseId:e.responseId,telemetry:e.telemetry??null}),e.presenter?s.jsx(sR,{label:"Presenter",model:e.presenter.model,responseId:e.presenter.responseId,telemetry:e.presenter,note:e.presenter.skipped==="rate-guard"?"skipped — rate-guard hit":e.presenter.skipped==="error"?`failed — ${e.presenter.errorMessage??"unknown"}`:null}):null]})]})}function sR({label:e,model:t,responseId:n,telemetry:r,note:a}){const o=r?.usage??null;return s.jsxs("div",{className:"briefing-telemetry-row",children:[s.jsxs("div",{className:"briefing-telemetry-row-head",children:[s.jsx("span",{className:"briefing-telemetry-label",children:e}),s.jsx("span",{className:"briefing-telemetry-model",children:t}),a?s.jsx("span",{className:"briefing-telemetry-note",children:a}):null]}),s.jsxs("div",{className:"briefing-telemetry-stats",children:[s.jsx("span",{children:r&&r.elapsedMs>0?`${(r.elapsedMs/1e3).toFixed(2)}s`:"—"}),s.jsxs("span",{children:["in ",o?.inputTokens??"—"]}),s.jsxs("span",{children:["out ",o?.outputTokens??"—"]}),s.jsxs("span",{children:["total ",o?.totalTokens??"—"]}),n?s.jsx("span",{className:"briefing-telemetry-response",children:n}):null]})]})}function Gue({presented:e}){return s.jsxs("section",{className:"briefing-layer briefing-layer-presented",children:[s.jsx(nl,{eyebrow:"Spoken",title:`Presented as · ${e.voiceSpec.persona}, ~${e.voiceSpec.targetWords} words`}),s.jsx("ol",{className:"briefing-presented-sentences",children:e.sentences.map((t,n)=>s.jsx("li",{className:"briefing-presented-sentence",children:t},n))}),s.jsxs("div",{className:"briefing-presented-meta",children:["model: ",e.model,e.responseId?` · response: ${e.responseId}`:""]})]})}function Zue({brief:e,navigate:t}){return e?s.jsxs("section",{className:"briefing-layer",children:[s.jsx(nl,{eyebrow:"Layer 3",title:"Brief"}),e.steps.length>0?s.jsx("ol",{className:"briefing-steps",children:e.steps.map((n,r)=>s.jsxs("li",{className:"briefing-step",children:[s.jsxs("div",{className:"briefing-step-label",children:[r+1,". ",n.label]}),n.narration?s.jsx("p",{className:"briefing-step-narration",children:n.narration}):null]},n.id??r))}):null,e.actions.length>0?s.jsx("div",{className:"briefing-actions",children:e.actions.map((n,r)=>s.jsx("button",{type:"button",className:"s-btn",onClick:()=>{n.route&&t(n.route)},children:n.label},`${n.label}-${r}`))}):null]}):s.jsxs("section",{className:"briefing-layer",children:[s.jsx(nl,{eyebrow:"Layer 3",title:"Brief & call"}),s.jsx("p",{className:"briefings-placeholder",children:"No brief body persisted."})]})}function Yue({observations:e,navigate:t}){return s.jsxs("section",{className:"briefing-layer",children:[s.jsx(nl,{eyebrow:"Layer 2",title:`Observations (${e.length})`}),e.length===0?s.jsx("p",{className:"briefings-placeholder",children:"No observations on this brief."}):s.jsx("div",{className:"briefing-observations",children:e.map((n,r)=>{const a=n.tone==="warn"?"briefing-observation-warn":n.tone==="err"||n.tone==="error"?"briefing-observation-err":"";return s.jsxs("div",{className:`briefing-observation ${a}`.trim(),children:[s.jsx("div",{className:"briefing-observation-text",children:n.text}),n.references.length>0?s.jsx("div",{className:"briefing-observation-refs",children:n.references.map((o,c)=>s.jsx(Xue,{reference:o,navigate:t},`${o.label}-${c}`))}):null]},r)})})]})}function Xue({reference:e,navigate:t}){const n=!!e.route,r=e.detail?`${e.label} · ${e.detail}`:e.label;return n?s.jsx("button",{type:"button",className:"briefing-ref-chip",onClick:()=>t(e.route),children:r}):s.jsx("span",{className:"briefing-ref-chip briefing-ref-chip-static",children:r})}function Que({snapshot:e,call:t}){const n=m.useMemo(()=>Jue(e),[e]),[r,a]=m.useState(!1);return s.jsxs("section",{className:"briefing-layer",children:[s.jsx(nl,{eyebrow:"Layer 1",title:"Read snapshot"}),n.length>0?s.jsx("div",{className:"briefing-snapshot-counts",children:n.map(o=>s.jsxs("span",{className:"briefing-snapshot-count",children:[s.jsx("strong",{children:o.value})," ",o.label]},o.label))}):null,t?s.jsxs("details",{className:"briefing-snapshot-section",children:[s.jsx("summary",{className:"briefing-snapshot-section-head",children:"Call metadata"}),s.jsxs("dl",{className:"briefing-call-grid",children:[s.jsx("dt",{children:"Model"}),s.jsx("dd",{children:t.model}),s.jsx("dt",{children:"Response ID"}),s.jsx("dd",{children:t.responseId??"—"}),s.jsx("dt",{children:"System prompt"}),s.jsx("dd",{children:s.jsx("pre",{className:"briefing-call-prompt",children:t.systemPrompt})}),s.jsx("dt",{children:"Operator request"}),s.jsx("dd",{children:s.jsx("pre",{className:"briefing-call-prompt",children:t.operatorRequest})})]})]}):null,s.jsxs("div",{className:"briefing-snapshot-section",children:[s.jsx("button",{type:"button",className:"briefing-detail-back",onClick:()=>a(o=>!o),children:r?"Hide raw snapshot":"Show raw snapshot JSON"}),r?s.jsx("pre",{className:"briefing-snapshot-raw",children:JSON.stringify(e??{},null,2)}):null]})]})}function nl({eyebrow:e,title:t}){return s.jsxs("div",{className:"briefing-layer-head",children:[s.jsx("span",{className:"briefing-layer-eyebrow",children:e}),s.jsx("span",{className:"briefing-layer-title",children:t})]})}function Jue(e){if(!e?.state)return[];const t=e.state,n=[],r=(a,o)=>{Array.isArray(o)&&n.push({label:a,value:o.length})};if(r("agents",t.agents),t.fleet&&typeof t.fleet=="object"){const a=t.fleet;r("active asks",a.activeAsks),r("attention",a.needsAttention),r("recent",a.recentCompleted)}if(t.broker&&typeof t.broker=="object"){const a=t.broker;r("broker msgs",a.recentMessages)}if(r("scout chatter",t.scoutChatter),r("tail events",t.agentLogMessages),t.operatorAttention&&typeof t.operatorAttention=="object"){const a=t.operatorAttention;r("operator items",a.items)}return n}const ede={"fleet-home":"fleet",tour:"tour"};function tde({navigate:e}){const[t,n]=m.useState(null),[r,a]=m.useState(null),[o,c]=m.useState(!1),u=m.useCallback(async()=>{c(!0);try{const f=await ue("/api/briefings?limit=50");n(f.briefings),a(null)}catch(f){a(f instanceof Error?f.message:"Failed to load briefings")}finally{c(!1)}},[]);return m.useEffect(()=>{u()},[u]),s.jsxs("div",{className:"sys-surface-page sys-surface-page-wide",children:[s.jsxs("div",{className:"sys-page-head",children:[s.jsxs("div",{className:"sys-page-title-group",children:[s.jsx("h2",{className:"sys-page-title",children:"Briefings"}),s.jsx("p",{className:"sys-page-subtitle",children:"Scoutbot's archived fleet briefs — what it told you, when, and what it saw. Rolling 100."})]}),s.jsx("div",{className:"sys-page-actions",children:s.jsx("button",{type:"button",className:"s-btn",disabled:o,onClick:()=>{u()},children:o?"Refreshing...":"Refresh"})})]}),r?s.jsx(hs,{title:"Couldn't load briefings",body:r}):t===null?s.jsx("div",{className:"briefings-placeholder",children:"Loading briefings..."}):t.length===0?s.jsx(hs,{title:"No briefings yet",body:"Scoutbot writes here when it generates a fleet brief — either on Home or via tour. Briefs land in this archive automatically."}):s.jsx("ul",{className:"briefings-list",children:t.map(f=>s.jsx("li",{children:s.jsxs("button",{type:"button",className:"briefing-row",onClick:()=>e({view:"briefings",briefingId:f.id}),children:[s.jsxs("div",{className:"briefing-row-head",children:[s.jsx("span",{className:`briefing-kind briefing-kind-${f.kind}`,children:ede[f.kind]}),s.jsx("span",{className:"briefing-row-title",children:f.title}),s.jsx("span",{className:"briefing-row-time",children:Ie(f.preparedAt)})]}),s.jsx("div",{className:"briefing-row-summary",children:f.summary}),s.jsxs("div",{className:"briefing-row-meta",children:[s.jsxs("span",{children:[f.observationCount," observations"]}),f.recommendation?s.jsxs("span",{children:["· ",f.recommendation]}):null]})]})},f.id))})]})}function Ef({activeRoute:e,navigate:t}){return s.jsx(Kg,{ariaLabel:"Ops sections",activeRoute:e,groups:Dce,navigate:t})}const rR={attempts:"Dispatch",dialogue:"Dialogue",failed_queries:"Failed queries",failed_deliveries:"Failed deliveries"};function aR(e){return e?e.length<=18?e:`${e.slice(0,10)}...${e.slice(-5)}`:"none"}const nde=92;function sde(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-3)).trimEnd()}...`}function x5(e){switch(e){case"success":return"sent";case"failed_query":return"query";case"failed_delivery":return"delivery";default:return"attempt"}}function rde(e){return e.messageId??e.deliveryId??e.invocationId??e.id}function ade(e){switch(e){case"dm":return"Direct message";case"channel":return"Channel";case"broadcast":return"Broadcast";case null:return"No route";default:return e}}function ide({route:e}){const t=ade(e);return e==="dm"?s.jsx("span",{className:"sys-route-glyph sys-route-glyph-dm",title:t,"aria-label":t,children:s.jsx(bB,{size:13,"aria-hidden":"true"})}):e==="channel"?s.jsx("span",{className:"sys-route-glyph sys-route-glyph-channel",title:t,"aria-label":t,children:s.jsx(oB,{size:13,"aria-hidden":"true"})}):e==="broadcast"?s.jsx("span",{className:"sys-route-glyph sys-route-glyph-broadcast",title:t,"aria-label":t,children:s.jsx(xB,{size:13,"aria-hidden":"true"})}):s.jsx("span",{className:"sys-route-glyph sys-route-glyph-none",title:t,"aria-label":t,children:e??"none"})}function ode({navigate:e}){const{selectedBrokerAttempt:t,inspectBrokerAttempt:n}=qe(),[r,a]=m.useState(null),[o,c]=m.useState("attempts"),[u,f]=m.useState(!0),[h,p]=m.useState(!1),[x,v]=m.useState(null),y=m.useRef(null),b=m.useRef(0),C=m.useRef(null),E=m.useCallback(async(N="initial")=>{const T=++b.current;!y.current&&N!=="background"?(f(!0),v(null)):p(!0);try{const R=await ue("/api/broker?limit=160");if(T!==b.current)return;y.current=R,a(R),v(null)}catch(R){if(T!==b.current)return;v(R instanceof Error?R.message:String(R))}finally{T===b.current&&(f(!1),p(!1))}},[]),A=m.useCallback(()=>{C.current||(C.current=setTimeout(()=>{C.current=null,E("background")},250))},[E]);m.useEffect(()=>(E("initial"),()=>{C.current&&clearTimeout(C.current)}),[E]),Vt(N=>{(N.kind==="message.posted"||N.kind==="delivery.planned"||N.kind==="delivery.attempted"||N.kind==="delivery.state.changed"||N.kind==="scout.dispatched")&&A()});const S=m.useMemo(()=>{if(!r)return[];switch(o){case"failed_queries":return r.failedQueries;case"failed_deliveries":return r.failedDeliveries;case"dialogue":return r.dialogue;default:return r.attempts}},[o,r]),k=m.useMemo(()=>!r||!t?null:r.attempts.find(N=>N.id===t.id)??r.failedQueries.find(N=>N.id===t.id)??r.failedDeliveries.find(N=>N.id===t.id)??null,[r,t]);return m.useEffect(()=>{k&&k!==t&&n(k)},[n,k,t]),s.jsxs("div",{className:"s-ops",children:[s.jsx("div",{className:"s-ops-header",children:s.jsx(Ef,{activeRoute:{view:"broker"},navigate:e})}),s.jsx("div",{className:"s-ops-body",children:s.jsxs("div",{className:"sys-surface-page sys-surface-page-wide sys-surface-page-fluid sys-broker-page",children:[s.jsxs("div",{className:"sys-ledger-toolbar","aria-label":"Dispatch controls",children:[r?s.jsx("div",{className:"sys-tab-row sys-tab-row--toolbar",role:"tablist","aria-label":"Dispatch diagnostics",children:Object.keys(rR).map(N=>s.jsx("button",{type:"button",role:"tab","aria-selected":o===N,className:`sys-tab${o===N?" sys-tab-active":""}`,onClick:()=>c(N),children:rR[N]},N))}):s.jsx("div",{className:"sys-ledger-kicker",children:"Dispatch ledger"}),s.jsxs("div",{className:"sys-page-actions sys-ledger-actions",children:[s.jsx("div",{className:"sys-sync-note",children:u?"Loading dispatch ledger...":r?`Updated ${Ie(r.generatedAt)}`:"Waiting for dispatch data"}),s.jsx("button",{type:"button",className:"s-btn",disabled:u||h,onClick:()=>{E("manual")},children:h?"Refreshing...":"Refresh"})]})]}),x&&s.jsxs("div",{className:"sys-banner sys-banner-warning",children:[s.jsx("strong",{children:"Refresh failed."}),s.jsx("span",{children:x})]}),u&&!r&&s.jsx(hs,{title:"Loading dispatch",body:"Reading the dispatch database snapshot."}),!u&&!r&&!x&&s.jsx(hs,{title:"No dispatch data",body:"No dispatch records are available yet."}),r&&s.jsx(s.Fragment,{children:o==="dialogue"?s.jsx(hde,{items:S,navigate:e}):s.jsx(lde,{attempts:S,navigate:e,selectedAttemptId:t?.id??null,onInspect:n})})]})})]})}function lde({attempts:e,navigate:t,selectedAttemptId:n,onInspect:r}){const{route:a}=qe();return e.length===0?s.jsx(hs,{title:"No records",body:"This dispatch slice is empty for the selected window."}):s.jsxs("div",{className:"sys-broker-table",role:"table","aria-label":"Dispatch ledger",children:[s.jsxs("div",{className:"sys-broker-table-head",role:"row",children:[s.jsx("span",{role:"columnheader",children:"State"}),s.jsx("span",{role:"columnheader",children:"Age"}),s.jsx("span",{role:"columnheader",children:"Detail"}),s.jsx("span",{role:"columnheader",children:"From"}),s.jsx("span",{role:"columnheader",children:"To"}),s.jsx("span",{role:"columnheader",children:"Route"}),s.jsx("span",{role:"columnheader",children:"Action"})]}),s.jsx("div",{className:"sys-broker-table-body",role:"rowgroup",children:e.map(o=>{const c=$oe(o.kind,o.status),u=x5(o.kind),f=sde(o.detail,nde),h=()=>{r(o),window.dispatchEvent(new CustomEvent("scout:set-inspector-width",{detail:{width:420}}))};return s.jsxs("article",{role:"row",className:`sys-broker-row sys-broker-row--ledger${n===o.id?" sys-broker-row-selected":""}`,tabIndex:0,"aria-label":`Inspect ${o.detail}`,onClick:h,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),h())},children:[s.jsxs("div",{className:"sys-broker-cell sys-broker-cell-state",role:"cell",children:[s.jsx(Wa,{tone:c,children:u}),o.status!==u&&s.jsx("span",{className:"sys-broker-status",children:o.status})]}),s.jsx("div",{className:"sys-broker-cell sys-broker-cell-time",role:"cell",children:s.jsx("span",{title:kr(o.ts),children:Ie(o.ts)})}),s.jsx("div",{className:"sys-broker-cell sys-broker-cell-detail",role:"cell",children:s.jsx("h3",{className:"sys-broker-title",title:o.detail,children:f})}),s.jsx("div",{className:"sys-broker-cell sys-broker-cell-party",role:"cell",children:s.jsx("span",{title:o.actorName??"unknown",children:o.actorName??"unknown"})}),s.jsx("div",{className:"sys-broker-cell sys-broker-cell-party",role:"cell",children:s.jsx("span",{title:o.target??"none",children:o.target??"none"})}),s.jsx("div",{className:"sys-broker-cell sys-broker-cell-route",role:"cell",children:s.jsx(ide,{route:o.route})}),s.jsx("div",{className:"sys-broker-cell sys-broker-cell-action",role:"cell",children:o.conversationId&&s.jsxs("button",{type:"button",className:"s-btn s-btn-sm sys-broker-thread-button",onClick:p=>{p.stopPropagation(),wt(t,{view:"conversation",conversationId:o.conversationId},{returnTo:a})},children:[s.jsx(wr,{size:12,"aria-hidden":"true"}),"Thread"]})})]},o.id)})})]})}function cde(e){const t=rde(e);return[{label:"Status",value:e.status},{label:"Kind",value:x5(e.kind)},{label:"Time",value:kr(e.ts)},{label:"Actor",value:e.actorName},{label:"Target",value:e.target},{label:"Route",value:e.route},{label:"Conversation",value:e.conversationId},{label:"Reference",value:t},{label:"Message",value:e.messageId===t?null:e.messageId},{label:"Delivery",value:e.deliveryId===t?null:e.deliveryId},{label:"Invocation",value:e.invocationId===t?null:e.invocationId}].filter(n=>n.value)}function ude(e){return!e||Object.keys(e).length===0?"{}":JSON.stringify(e,null,2)}function dde({value:e}){const[t,n]=m.useState("idle"),r=m.useRef(null);m.useEffect(()=>{n("idle")},[e]),m.useEffect(()=>()=>{r.current&&clearTimeout(r.current)},[]);const a=m.useCallback(async()=>{const u=await Nn(e);r.current&&clearTimeout(r.current),n(u?"copied":"failed"),r.current=setTimeout(()=>{n("idle"),r.current=null},1500)},[e]),o=t==="copied",c=t==="failed";return s.jsx("button",{type:"button",className:`sys-copy-btn sys-broker-metadata-copy${o?" sys-copy-btn--copied":""}${c?" sys-copy-btn--failed":""}`,onClick:()=>{a()},title:o?"Copied metadata":c?"Copy failed":"Copy metadata","aria-label":o?"Copied metadata":c?"Copy metadata failed":"Copy metadata",children:o?s.jsx(fg,{size:14,"aria-hidden":"true"}):s.jsx(mg,{size:14,"aria-hidden":"true"})})}function fde({attempt:e,navigate:t,onClose:n}){const{route:r}=qe(),a=cde(e),o=ude(e.metadata);return s.jsxs("aside",{className:"sys-panel sys-broker-inspector","aria-label":"Dispatch route inspector",children:[s.jsxs("div",{className:"sys-broker-inspector-head",children:[s.jsxs("div",{children:[s.jsx("div",{className:"sys-kicker",children:"Inspector"}),s.jsx("h3",{className:"sys-state-title",children:e.detail})]}),s.jsxs("div",{className:"sys-inline-actions",children:[e.conversationId&&s.jsx("button",{type:"button",className:"s-btn s-btn-sm",onClick:()=>wt(t,{view:"conversation",conversationId:e.conversationId},{returnTo:r}),children:"Open thread"}),s.jsx("button",{type:"button",className:"s-btn s-btn-sm",onClick:n,children:"Close"})]})]}),s.jsx("div",{className:"sys-detail-grid sys-broker-inspector-grid",children:a.map(c=>s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:c.label}),s.jsx("code",{className:"sys-detail-value",children:c.value})]},c.label))}),s.jsxs("div",{className:"sys-broker-metadata",children:[s.jsxs("div",{className:"sys-broker-metadata-head",children:[s.jsx("span",{className:"sys-detail-label",children:"Metadata"}),s.jsx(dde,{value:o})]}),s.jsx("pre",{children:o})]})]})}function hde({items:e,navigate:t}){const{route:n}=qe();return e.length===0?s.jsx(hs,{title:"No dialogue",body:"No messages were recorded in the selected window."}):s.jsx("div",{className:"sys-audit-list",children:e.map(r=>s.jsxs("article",{className:"sys-broker-row",children:[s.jsxs("div",{className:"sys-broker-row-main",children:[s.jsxs("div",{className:"sys-broker-row-head",children:[s.jsx(Wa,{tone:"neutral",children:r.class}),s.jsx("span",{className:"sys-broker-status",children:r.actorName??"unknown"}),s.jsx("span",{className:"sys-broker-time",children:kr(r.ts)})]}),s.jsx("h3",{className:"sys-broker-title",children:r.body}),s.jsx("div",{className:"sys-broker-meta",children:s.jsxs("span",{children:["thread ",aR(r.conversationId)]})})]}),s.jsxs("div",{className:"sys-broker-row-side",children:[s.jsx("code",{children:aR(r.id)}),s.jsx("button",{type:"button",className:"s-btn s-btn-sm",onClick:()=>wt(t,{view:"conversation",conversationId:r.conversationId},{returnTo:n}),children:"Open thread"})]})]},r.id))})}function Ek(e){return e.handle??e.id}function mde(e,t){if(!t)return!0;const n=t.toLowerCase();return e.name.toLowerCase().includes(n)||Ek(e).toLowerCase().includes(n)||e.id.toLowerCase().includes(n)}function y5({agents:e,query:t,excludeIds:n,maxResults:r=50}){const a=m.useMemo(()=>new Set(n??[]),[n]),o=m.useMemo(()=>e.filter(x=>!a.has(x.id)&&mde(x,t.trim())).slice(0,r),[e,a,t,r]),[c,u]=m.useState(0);m.useEffect(()=>{u(p=>o.length===0?0:Math.min(p,o.length-1))},[o]);const f=m.useCallback(p=>{u(x=>o.length===0?0:(x+p+o.length)%o.length)},[o.length]),h=m.useCallback(()=>u(0),[]);return{filtered:o,highlightedIndex:c,setHighlightedIndex:u,moveHighlight:f,resetHighlight:h}}function b5({agents:e,highlightedIndex:t,onSelect:n,onHover:r,emptyHint:a,pendingId:o,className:c,id:u}){return e.length===0?s.jsx("div",{className:`agent-autocomplete ${c??""}`,id:u,children:s.jsx("div",{className:"agent-autocomplete-empty",children:a??"No matches."})}):s.jsx("div",{className:`agent-autocomplete ${c??""}`,role:"listbox",id:u,children:e.map((f,h)=>{const p=Ek(f),x=h===t;return s.jsxs("button",{type:"button",role:"option","aria-selected":x,className:`agent-autocomplete-item${x?" is-active":""}`,onMouseDown:v=>{v.preventDefault(),n(f)},onMouseEnter:()=>r?.(h),disabled:o===f.id,children:[s.jsx("div",{className:"agent-autocomplete-avatar",style:{background:Xt(f.name)},children:f.name[0]?.toUpperCase()??"?"}),s.jsxs("div",{className:"agent-autocomplete-info",children:[s.jsx("span",{className:"agent-autocomplete-name",children:f.name}),s.jsxs("span",{className:"agent-autocomplete-handle",children:["@",p]})]})]},f.id)})})}function pde({agents:e,excludeIds:t,open:n,onClose:r,onSelect:a,placeholder:o="Search agents…",emptyHint:c,pendingId:u,anchor:f="below-right",className:h,triggerRef:p}){const[x,v]=m.useState(""),y=m.useRef(null),b=m.useRef(null),{filtered:C,highlightedIndex:E,setHighlightedIndex:A,moveHighlight:S}=y5({agents:e,query:x,excludeIds:t});if(m.useEffect(()=>{if(!n){v("");return}queueMicrotask(()=>y.current?.focus());const N=R=>{const O=R.target;b.current?.contains(O)||p?.current?.contains(O)||r()},T=R=>{R.key==="Escape"&&r()};return document.addEventListener("mousedown",N),document.addEventListener("keydown",T),()=>{document.removeEventListener("mousedown",N),document.removeEventListener("keydown",T)}},[n,r,p]),!n)return null;const k=N=>{if(N.key==="ArrowDown")N.preventDefault(),S(1);else if(N.key==="ArrowUp")N.preventDefault(),S(-1);else if(N.key==="Enter"){const T=C[E];T&&(N.preventDefault(),a(T))}};return s.jsxs("div",{ref:b,className:`agent-picker agent-picker--${f} ${h??""}`,children:[s.jsx("input",{ref:y,className:"agent-picker-search",placeholder:o,value:x,onChange:N=>v(N.target.value),onKeyDown:k,"aria-autocomplete":"list"}),s.jsx(b5,{agents:C,highlightedIndex:E,onSelect:N=>{a(N)},onHover:A,emptyHint:c,pendingId:u})]})}const gde=/(^|\s)@([a-zA-Z0-9_.-]*)$/,vm=4,vde=254;function xde(e,t){if(t<=0)return null;const n=e.slice(0,t),r=gde.exec(n);if(!r)return null;r[1];const a=r[2]??"",o=n.length-a.length-1;return o<0?null:(e.slice(t,t+1),{start:o,end:t,query:a})}const yde=["boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize","whiteSpace","wordWrap","wordBreak"];function bde(e,t){const n=document.createElement("div");document.body.appendChild(n);const r=n.style,a=window.getComputedStyle(e);r.position="absolute",r.visibility="hidden",r.whiteSpace="pre-wrap",r.wordWrap="break-word",r.top="0",r.left="-9999px";for(const h of yde)r[h]=a[h];n.textContent=e.value.slice(0,t);const o=document.createElement("span");o.textContent=e.value.slice(t)||".",n.appendChild(o);const c=o.offsetTop,u=o.offsetLeft,f=parseInt(a.lineHeight,10)||o.offsetHeight;return document.body.removeChild(n),{top:c,left:u,height:f}}const wde=m.forwardRef(function({agents:t,excludeIds:n,value:r,onChange:a,onSubmit:o,placeholder:c,rows:u=1,disabled:f,className:h,textareaClassName:p,emptyHint:x,onMention:v},y){const b=m.useRef(null),C=m.useRef(null),[E,A]=m.useState(null),[S,k]=m.useState(null);m.useImperativeHandle(y,()=>({focus:()=>b.current?.focus(),blur:()=>b.current?.blur(),get textarea(){return b.current}}),[]);const N=E?.query??"",{filtered:T,highlightedIndex:R,setHighlightedIndex:O,moveHighlight:L}=y5({agents:t,query:N,excludeIds:n}),I=m.useCallback(()=>{const U=b.current;if(!U)return;const D=xde(U.value,U.selectionStart??0);A(D)},[]);m.useLayoutEffect(()=>{const U=b.current;if(!U||!E){k(null);return}const{top:D,left:q,height:Z}=bde(U,E.start),$=U.getBoundingClientRect(),G=U.parentElement?.getBoundingClientRect(),V=G?$.top-G.top:0,Y=G?$.left-G.left:0,K=C.current?.offsetHeight||vde,P=window.visualViewport,H=P?.offsetTop??0,B=H+(P?.height??window.innerHeight),Q=$.top+D-U.scrollTop,oe=Q+Z,ne=B-oe-vm,X=Q-H-vm,ae=ne<K&&X>ne;k({top:ae?V+D-U.scrollTop-K-vm:V+D+Z-U.scrollTop+vm,left:Y+q-U.scrollLeft})},[E,r,T.length]);const z=m.useCallback(U=>{const D=b.current,q=E;if(!D||!q)return;const Z=Ek(U),$=r.slice(0,q.start),G=r.slice(q.end),V=`@${Z} `,Y=`${$}${V}${G}`;a(Y),v?.(U),A(null);const K=q.start+V.length;queueMicrotask(()=>{const P=b.current;P&&(P.focus(),P.setSelectionRange(K,K))})},[E,r,a,v]),_=U=>{if(E&&T.length>0){if(U.key==="ArrowDown"){U.preventDefault(),L(1);return}if(U.key==="ArrowUp"){U.preventDefault(),L(-1);return}if(U.key==="Enter"||U.key==="Tab"){const D=T[R];if(D){U.preventDefault(),z(D);return}}if(U.key==="Escape"){U.preventDefault(),A(null);return}}U.key==="Enter"&&!U.shiftKey&&!E&&(U.preventDefault(),o?.())};return s.jsxs("div",{className:`agent-mention-wrap ${h??""}`,children:[s.jsx("textarea",{ref:b,className:p,value:r,rows:u,placeholder:c,disabled:f,onChange:U=>{a(U.target.value),queueMicrotask(I)},onKeyUp:I,onClick:I,onBlur:()=>A(null),onKeyDown:_,"aria-autocomplete":"list"}),E&&s.jsx("div",{ref:C,className:"agent-mention-popover",style:{top:`${S?.top??0}px`,left:`${S?.left??0}px`,visibility:S?void 0:"hidden"},children:s.jsx(b5,{agents:T,highlightedIndex:R,onSelect:z,onHover:O,emptyHint:x??"No matches."})})]})});function Zp({activeRoute:e,navigate:t}){return s.jsx(Kg,{ariaLabel:"Chat sections",activeRoute:e,groups:Lce,navigate:t})}function iR(e){return[...e].sort((t,n)=>t.createdAt-n.createdAt)}function jde(e,t){if(e.actorId){const r=t.find(a=>a.id===e.actorId);if(r)return r}if(!e.actorName)return null;const n=t.filter(r=>r.name===e.actorName);return n.length===1?n[0]:null}function kde(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n].id!==t[n].id||e[n].name!==t[n].name)return!1;return!0}function Nde({channel:e,agents:t,extraActors:n}){const r=m.useMemo(()=>e.participantIds.filter(S=>S!=="operator"),[e.participantIds]),a=m.useMemo(()=>{const S=new Map,k=new Set(r),N=(T,R,O)=>{if(S.has(T))return;const L=t.find(I=>I.id===T)??null;S.set(T,L?{id:L.id,name:L.name,handle:L.handle??L.id,state:Ge(L.state),isMember:O,agent:L}:{id:T,name:R,handle:T,state:Ge(null),isMember:O,agent:null})};for(const T of r)N(T,T,!0);for(const T of n)T.id!=="operator"&&N(T.id,T.name,k.has(T.id));return Array.from(S.values())},[r,n,t]),o=a.filter(S=>S.state!=="not_ready").length,c=a.filter(S=>!S.isMember).length,[u,f]=m.useState(!1),[h,p]=m.useState(!1),[x,v]=m.useState(null),y=m.useRef(null),b=m.useRef(null),C=m.useRef(null);m.useEffect(()=>{if(!u)return;const S=N=>{const T=N.target;y.current?.contains(T)||b.current?.contains(T)||f(!1)},k=N=>{N.key==="Escape"&&f(!1)};return document.addEventListener("mousedown",S),document.addEventListener("keydown",k),()=>{document.removeEventListener("mousedown",S),document.removeEventListener("keydown",k)}},[u]);const E=async S=>{v(S);try{await ue(`/api/conversations/${encodeURIComponent(e.id)}/members`,{method:"POST",body:JSON.stringify({actorId:S})}),p(!1)}finally{v(null)}},A=async S=>{v(S);try{await ue(`/api/conversations/${encodeURIComponent(e.id)}/members/${encodeURIComponent(S)}`,{method:"DELETE"})}finally{v(null)}};return s.jsxs("div",{className:"ch-members-control",children:[s.jsxs("button",{ref:b,type:"button",className:"ch-members-trigger",onClick:()=>f(S=>!S),"aria-label":`${a.length} members${o?`, ${o} online`:""}`,"aria-expanded":u,title:"View members",children:[s.jsxs("div",{className:"ch-members-stack",children:[a.slice(0,4).map(S=>s.jsx("div",{className:"ch-members-pip",style:{background:Xt(S.name)},children:S.name[0]?.toUpperCase()??"?"},S.id)),a.length>4&&s.jsxs("span",{className:"ch-members-overflow",children:["+",a.length-4]})]}),s.jsxs("span",{className:"ch-members-count",children:[a.length,o>0&&s.jsx("span",{className:"ch-members-online-dot","aria-hidden":!0})]})]}),u&&s.jsxs("div",{ref:y,className:"ch-members-roster",role:"dialog","aria-label":"Members",children:[s.jsxs("div",{className:"ch-members-roster-header",children:[s.jsxs("span",{className:"ch-members-roster-title",children:[a.length," member",a.length!==1?"s":""]}),o>0&&s.jsxs("span",{className:"ch-members-roster-online",children:[o," online"]})]}),s.jsx("div",{className:"ch-members-roster-list",children:a.length===0?s.jsx("div",{className:"ch-members-roster-empty",children:"No agents in this channel yet."}):a.map(S=>s.jsx(Sde,{member:S,removeBusy:x===S.id,onRemove:()=>{A(S.id)}},S.id))}),c>0&&s.jsxs("div",{className:"ch-members-roster-footnote",children:[c," ",c===1?"guest is":"guests are"," posting without being formally added."]})]}),s.jsx("button",{ref:C,type:"button",className:"ch-members-add",onClick:()=>p(S=>!S),"aria-label":"Add member","aria-expanded":h,children:"+"}),s.jsx(pde,{agents:t,excludeIds:r,open:h,onClose:()=>p(!1),onSelect:S=>{E(S.id)},pendingId:x,emptyHint:"All agents already in channel.",triggerRef:C})]})}function Sde({member:e,removeBusy:t,onRemove:n}){const{triggerProps:r,popover:a}=hk({agent:e.agent}),o=e.name[0]?.toUpperCase()??"?";return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"ch-members-roster-row","data-guest":e.isMember?void 0:"true",children:[s.jsxs("button",{type:"button",className:"ch-members-roster-trigger",...r,"aria-label":`Open ${e.name} profile`,children:[s.jsxs("div",{className:"ch-members-roster-avatar-wrap",children:[s.jsx("div",{className:"ch-members-roster-avatar",style:{background:Xt(e.name)},children:o}),s.jsx("span",{className:"ch-members-roster-dot",style:{background:yn(e.state)}})]}),s.jsxs("div",{className:"ch-members-roster-info",children:[s.jsx("span",{className:"ch-members-roster-name",children:e.name}),s.jsxs("span",{className:"ch-members-roster-handle",children:["@",e.handle,!e.isMember&&s.jsx("span",{className:"ch-members-roster-guest-tag",children:"guest"})]})]}),e.state==="working"&&s.jsx("span",{className:"ch-members-roster-state",children:"working"})]}),e.isMember&&s.jsx("button",{type:"button",className:"ch-members-roster-remove",onClick:n,disabled:t,"aria-label":`Remove ${e.name}`,title:`Remove ${e.name}`,children:"×"})]}),a]})}function Cde({message:e,agent:t,isYou:n,operatorName:r,showAvatar:a,showDay:o}){const{triggerProps:c,popover:u}=hk({agent:n?null:t}),f=kr(e.createdAt),h=n?r:e.actorName??"?",p=(n?r[0]:e.actorName?.[0]??"?").toUpperCase(),x=Xt(n?r:e.actorName??"?"),v=n?r.toLowerCase():t?.handle??null,y=!n&&t!==null;return s.jsxs("div",{className:"ch-msg-group",children:[o&&s.jsxs("div",{className:"s-thread-day-divider",children:[s.jsx("span",{className:"s-thread-day-line"}),s.jsx("span",{className:"s-thread-day-label",children:tw(e.createdAt)}),s.jsx("span",{className:"s-thread-day-line"})]}),s.jsxs("article",{id:`msg-${e.id}`,className:["ch-msg",a&&"ch-msg--with-meta"].filter(Boolean).join(" "),children:[s.jsx("div",{className:"ch-msg-meta",children:a?s.jsxs(s.Fragment,{children:[y?s.jsxs("button",{type:"button",className:"ch-msg-meta-top ch-msg-meta-top--trigger",...c,"aria-label":`Open ${h} profile`,children:[s.jsx("div",{className:"ch-msg-avatar",style:{background:x},children:p}),s.jsx("span",{className:"ch-msg-author",style:{color:x},children:h})]}):s.jsxs("div",{className:"ch-msg-meta-top",children:[s.jsx("div",{className:"ch-msg-avatar",style:{background:x},children:p}),s.jsx("span",{className:"ch-msg-author",style:{color:x},children:h})]}),s.jsxs("div",{className:"ch-msg-meta-detail",children:[v&&s.jsxs("span",{className:"ch-msg-handle",children:["@",v]}),s.jsx("span",{className:"ch-msg-time",title:f,children:Ie(e.createdAt)})]})]}):s.jsx("span",{className:"ch-msg-inline-time",title:f,children:Ie(e.createdAt)})}),s.jsxs("div",{className:"ch-msg-body-col",children:[s.jsx("div",{className:"ch-msg-body",children:s.jsx(gk,{text:e.body})}),s.jsx(i5,{message:e})]})]}),u]})}function Ede({channelId:e,channelName:t,agents:n,operatorName:r,onMessageCountChange:a,onSeenActorsChange:o}){const[c,u]=m.useState([]),[f,h]=m.useState(""),[p,x]=m.useState(!1),[v,y]=m.useState(null),b=m.useRef(null),C=m.useRef(0),E=m.useRef(!1),A=m.useCallback(async()=>{try{const N=await ue(`/api/messages?conversationId=${encodeURIComponent(e)}&limit=300`),T=iR(N);u(T),xk(e);const R=T.at(-1);R&&ue(`/api/conversations/${encodeURIComponent(e)}/read-cursor`,{method:"POST",body:JSON.stringify({lastReadMessageId:R.id})}).catch(()=>{}),T.length!==C.current&&(C.current=T.length,a(T.length))}catch{}},[e,a]);m.useEffect(()=>{A()},[A]),Vt(N=>{N.kind==="message.posted"&&N.payload?.message?.conversationId===e&&A()}),m.useEffect(()=>{if(c.length===0)return;const N=E.current?"smooth":"instant";b.current?.scrollIntoView({behavior:N}),E.current=!0},[c.length]);const S=m.useRef([]);m.useEffect(()=>{if(!o)return;const N=new Map;for(const R of c)!R.actorId||R.actorId==="operator"||N.has(R.actorId)||N.set(R.actorId,R.actorName);const T=Array.from(N,([R,O])=>({id:R,name:O})).sort((R,O)=>R.id.localeCompare(O.id));kde(S.current,T)||(S.current=T,o(T))},[c,o]);const k=async()=>{const N=f.trim();if(!N||p)return;x(!0),h(""),y(null);const T={id:`optimistic-${Date.now()}`,conversationId:e,actorId:"operator",actorName:r,body:N,createdAt:Date.now(),class:"operator"};u(R=>iR([...R,T]));try{await ue("/api/send",{method:"POST",body:JSON.stringify({body:N,conversationId:e})})}catch(R){u(O=>O.filter(L=>L.id!==T.id)),y(R instanceof Error?R.message:"Failed to send")}finally{x(!1)}};return s.jsxs("div",{className:"ch-feed-shell",children:[s.jsxs("div",{className:"ch-feed",children:[s.jsx("div",{className:"ch-feed-spacer"}),c.length===0&&s.jsxs("div",{className:"ch-empty-feed",children:[s.jsx("div",{className:"ch-empty-feed-hash",children:"#"}),s.jsxs("p",{className:"ch-empty-feed-title",children:["Welcome to #",t]}),s.jsx("p",{className:"ch-empty-feed-sub",children:"This is the beginning of the channel. Be the first to post."})]}),c.map((N,T)=>{const R=N.actorName===r||N.class==="operator",O=T===0||!FD(c[T-1]?.createdAt,N.createdAt),L=T===0||c[T-1]?.actorName!==N.actorName||O,I=R?null:jde(N,n);return s.jsx(Cde,{message:N,agent:I,isYou:R,operatorName:r,showAvatar:L,showDay:O},N.id)}),s.jsx("div",{ref:b})]}),v&&s.jsx("div",{className:"ch-compose-error",children:v}),s.jsx("div",{className:"ch-compose-wrap",children:s.jsxs("form",{className:"ch-compose",onSubmit:N=>{N.preventDefault(),k()},children:[s.jsx(wde,{agents:n,value:f,onChange:h,onSubmit:()=>{k()},placeholder:`Message #${t}…`,rows:1,disabled:p,textareaClassName:"ch-compose-input"}),s.jsx(wk,{onAppend:N=>h(T=>T.trim()?`${T.trimEnd()} ${N}`:N)}),s.jsx("button",{type:"submit",className:"ch-compose-send",disabled:!f.trim()||p,"aria-label":"Send message",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8"}),s.jsx("polyline",{points:"8 2 14 8 8 14"})]})})]})})]})}const Ade=[{slug:"releases",description:"Coordinate deploys across agents working different repos."},{slug:"triage",description:"Route incoming issues to the right agent automatically."},{slug:"reviews",description:"All PR feedback and review requests in one thread."}];function Tde({count:e}){return s.jsxs("div",{className:"ch-overview",children:[s.jsxs("div",{className:"ch-overview-header",children:[s.jsx("div",{className:"ch-overview-hash",children:"#"}),s.jsxs("div",{className:"ch-overview-heading",children:[s.jsx("h2",{className:"ch-overview-title",children:"Channels"}),s.jsx("p",{className:"ch-overview-tagline",children:"Shared spaces where agents and operators coordinate over a common thread."})]})]}),s.jsxs("div",{className:"ch-overview-body",children:[s.jsxs("div",{className:"ch-overview-block",children:[s.jsx("div",{className:"ch-overview-block-label",children:"How it works"}),s.jsxs("p",{className:"ch-overview-block-text",children:["A channel is a broker-backed conversation anyone on the mesh can join. Send a message to any ",s.jsx("code",{className:"ch-overview-code",children:"channel.*"})," address and the broker creates it automatically. Agents, bridges, and operators all share the same thread."]})]}),s.jsxs("div",{className:"ch-overview-block",children:[s.jsx("div",{className:"ch-overview-block-label",children:e===0?"Start your first channel":`${e} channel${e!==1?"s":""} — pick one from the left`}),s.jsx("div",{className:"ch-overview-examples",children:Ade.map(t=>s.jsxs("div",{className:"ch-overview-example",children:[s.jsxs("span",{className:"ch-overview-example-name",children:[s.jsx("span",{className:"ch-overview-example-hash",children:"#"}),t.slug]}),s.jsx("span",{className:"ch-overview-example-desc",children:t.description})]},t.slug))}),e===0&&s.jsxs("div",{className:"ch-overview-hint",children:["From any agent: ",s.jsx("code",{className:"ch-overview-code",children:'send --to channel.releases "deploy ready"'})]})]})]})]})}function Mde({channelId:e,navigate:t}){const{agents:n,route:r}=qe(),[a,o]=m.useState([]),[c,u]=m.useState("operator"),f=zs(r),h=m.useMemo(()=>cl(n,f),[n,f]),p=m.useMemo(()=>no(n,f),[n,f]),x=m.useMemo(()=>ck(a,h,f).filter(Cc),[a,h,f]),v=e?x.find(A=>A.id===e)??null:null,[y,b]=m.useState([]);m.useEffect(()=>{b([])},[e]);const C=m.useCallback(async()=>{const A=await ue("/api/conversations").catch(()=>[]);o(A)},[]);if(m.useEffect(()=>{C()},[C]),m.useEffect(()=>{ue("/api/user").then(A=>{A?.name&&u(A.name)}).catch(()=>{})},[]),Vt(A=>{(A.kind==="message.posted"||A.kind==="conversation.upserted")&&C()}),e){const A=s.jsx(eu,{conversationId:e,navigate:t,showBackNav:!1});return s.jsxs("div",{className:"s-secondary-nav-shell",children:[s.jsx("div",{className:"s-secondary-nav-bar",children:s.jsx(Zp,{activeRoute:r,navigate:t})}),s.jsx("div",{className:"s-secondary-nav-body",children:A})]})}const E=s.jsx("div",{className:"ch-screen",children:v?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"ch-center-header",children:[s.jsxs("div",{className:"ch-center-header-left",children:[s.jsx("span",{className:"ch-center-hash",children:"#"}),s.jsx("span",{className:"ch-center-title",children:br(v)}),s.jsx("span",{className:"ch-center-slug",children:pk(v)})]}),s.jsx("div",{className:"ch-center-header-right",children:s.jsx(Nde,{channel:v,agents:p,extraActors:y})})]}),s.jsx("div",{className:"ch-body",children:s.jsx(Ede,{channelId:e,channelName:br(v),agents:p,operatorName:c,onMessageCountChange:()=>{},onSeenActorsChange:b},e)})]}):s.jsx(Tde,{count:x.length})});return s.jsxs("div",{className:"s-secondary-nav-shell",children:[s.jsx("div",{className:"s-secondary-nav-bar",children:s.jsx(Zp,{activeRoute:r,navigate:t})}),s.jsx("div",{className:"s-secondary-nav-body",children:E})]})}const oR=["direct","channel","group_direct","thread","system"],Rde={direct:"Direct messages",channel:"Channels",group_direct:"Group DMs",thread:"Threads",system:"System"};function lR(e){const t=oR.indexOf(e);return t===-1?oR.length:t}function Ide(e){const t=[e.agentName,e.currentBranch,e.workspaceRoot].filter(Boolean);return t.length>0?t.join(" · "):`${e.participantIds.length} participant${e.participantIds.length===1?"":"s"}`}function _de({navigate:e}){const{agents:t,route:n}=qe(),[r,a]=m.useState([]),[o,c]=m.useState(!0),[u,f]=m.useState(null),[h,p]=m.useState(""),x=zs(n),v=m.useMemo(()=>cl(t,x),[t,x]),y=m.useCallback(async()=>{try{const A=await ue("/api/conversations");a(A),f(null)}catch(A){f(A instanceof Error?A.message:"Failed to load conversations")}finally{c(!1)}},[]);m.useEffect(()=>{y()},[y]),Vt(A=>{(A.kind==="message.posted"||A.kind==="conversation.upserted"||A.kind==="agent.endpoint.upserted")&&y()});const b=m.useMemo(()=>{const A=h.trim().toLowerCase(),S=ck(r,v,x);return A?S.filter(k=>[k.title,k.kind,k.agentName??"",k.preview??"",k.workspaceRoot??"",...k.participantIds].some(N=>N.toLowerCase().includes(A))):S},[r,v,x,h]),C=m.useMemo(()=>{const A=new Map;for(const S of b){const k=A.get(S.kind)??[];k.push(S),A.set(S.kind,k)}return[...A.entries()].sort((S,k)=>lR(S[0])-lR(k[0])).map(([S,k])=>({key:S,label:Rde[S]??S,items:k}))},[b]),E=s.jsxs("div",{className:"s-conversations",children:[s.jsxs("div",{className:"s-conversations__hero",children:[s.jsxs("div",{children:[s.jsx("div",{className:"s-conversations__eyebrow",children:"Playground"}),s.jsx("h1",{children:"Conversations"}),s.jsx("p",{children:"Unified, normalized conversation summaries from the broker service — no direct web DB reads in this view."})]}),s.jsx("button",{type:"button",className:"s-conversations__refresh",onClick:()=>{c(!0),y()},children:"Refresh"})]}),s.jsxs("div",{className:"s-conversations__toolbar",children:[s.jsx("input",{type:"text",className:"s-conversations__search",placeholder:"Filter conversations…",value:h,onChange:A=>p(A.target.value)}),s.jsxs("div",{className:"s-conversations__meta",children:[s.jsxs("span",{children:[b.length," shown"]}),s.jsxs("span",{children:[r.length," total"]})]})]}),u?s.jsx("div",{className:"s-conversations__state s-conversations__state--error",children:u}):null,!u&&o?s.jsx("div",{className:"s-conversations__state",children:"Loading conversations…"}):null,!o&&!u&&C.length===0?s.jsx("div",{className:"s-conversations__state",children:"No conversations yet."}):null,s.jsx("div",{className:"s-conversations__sections",children:C.map(A=>s.jsxs("section",{className:"s-conversations__section",children:[s.jsxs("div",{className:"s-conversations__section-header",children:[s.jsx("h2",{children:A.label}),s.jsx("span",{children:A.items.length})]}),s.jsx("div",{className:"s-conversations__list",children:A.items.map(S=>s.jsxs("button",{type:"button",className:"s-conversations__row",onClick:()=>wt(e,{view:"conversation",conversationId:S.id},{returnTo:n}),children:[s.jsxs("div",{className:"s-conversations__row-main",children:[s.jsxs("div",{className:"s-conversations__row-titleline",children:[s.jsx("strong",{children:S.title}),s.jsx("span",{className:`s-conversations__kind s-conversations__kind--${S.kind.replace(/_/g,"-")}`,children:S.kind})]}),s.jsx("div",{className:"s-conversations__row-sub",children:Ide(S)}),s.jsx("div",{className:"s-conversations__row-preview",children:S.preview?.trim()||"No preview yet"})]}),s.jsxs("div",{className:"s-conversations__row-side",children:[s.jsxs("span",{children:[S.messageCount," msg"]}),s.jsx("span",{children:S.lastMessageAt?Ie(S.lastMessageAt):"—"})]})]},S.id))})]},A.key))})]});return s.jsxs("div",{className:"s-secondary-nav-shell",children:[s.jsx("div",{className:"s-secondary-nav-bar",children:s.jsx(Zp,{activeRoute:n,navigate:e})}),s.jsx("div",{className:"s-secondary-nav-body s-secondary-nav-body--scroll",children:E})]})}function Ode(e){const t=e?.trim();return t||null}function Yl(...e){return e.find(t=>t&&t.trim().length>0)?.trim()??null}function $de(e,t){return{flightId:Yl(e.flightId,t.flightId),invocationId:Yl(e.invocationId,t.invocationId),conversationId:Yl(e.conversationId,t.conversationId),workId:Yl(e.workId,t.workId),sessionId:Yl(e.sessionId,t.sessionId),targetAgentId:Yl(e.targetAgentId,t.targetAgentId)}}function Lde(e){const t=[e.sessionId,e.flightId,e.invocationId,e.targetAgentId,e.conversationId,e.workId].map(Ode).filter(r=>!!r),n=[...new Set(t)];return n.length?n.join("|"):null}function cR(e){const t=Lde(e);return{view:"ops",mode:"tail",...t?{tailQuery:t}:{}}}function uR(e,t){return t==="work"&&e.workId?{view:"work",workId:e.workId}:t==="session"&&e.sessionId?{view:"sessions",sessionId:e.sessionId}:t==="chat"&&e.conversationId?{view:"conversation",conversationId:e.conversationId}:t==="tail"?cR(e):e.workId?{view:"work",workId:e.workId}:e.sessionId?{view:"sessions",sessionId:e.sessionId}:e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.flightId||e.invocationId||e.targetAgentId?cR(e):{view:"inbox"}}function Pde(e){return{flightId:e.flightId??null,invocationId:e.invocationId??null,conversationId:e.conversationId??null,workId:e.workId??null,sessionId:e.sessionId??null,targetAgentId:e.targetAgentId??null}}function Dde({route:e,navigate:t}){const[n,r]=m.useState(null),a=m.useMemo(()=>Pde(e),[e]);return m.useEffect(()=>{let o=!1;const c=new URLSearchParams;return e.flightId&&c.set("flightId",e.flightId),e.invocationId&&c.set("invocationId",e.invocationId),e.conversationId&&c.set("conversationId",e.conversationId),e.workId&&c.set("workId",e.workId),e.sessionId&&c.set("sessionId",e.sessionId),e.targetAgentId&&c.set("targetAgentId",e.targetAgentId),(async()=>{try{const u=c.toString(),f=u?await ue(`/api/follow?${u}`):a;if(o)return;t(uR($de(f,a),e.preferredView))}catch(u){if(o)return;r(u instanceof Error?u.message:String(u)),t(uR(a,e.preferredView))}})(),()=>{o=!0}},[a,t,e]),s.jsx("div",{className:"s-sessions-screen s-inbox-thread-redesign",children:s.jsx("section",{className:"s-thread-overview",children:s.jsxs("div",{className:"s-thread-overview-copy",children:[s.jsxs("div",{className:"s-sessions-header s-thread-overview-heading",children:[s.jsx("h2",{className:"s-page-title",children:"Follow"}),s.jsx("span",{className:"s-meta s-tabular",children:e.preferredView??"auto"})]}),s.jsx("p",{className:"s-thread-overview-summary",children:n?"Opening the closest available Scout view.":"Resolving Scout context..."})]})})})}const zde=["codex","claude","cursor","native","worker","bridge","http","pi","flue"],Bde={codex:"Codex",claude:"Claude",cursor:"Cursor",native:"Native",worker:"Worker",bridge:"Bridge",http:"HTTP",pi:"Pi",flue:"Flue",github:"GitHub",unknown:"Unknown"};function gc(e){const t=(e??"").trim().toLowerCase();return t?t.includes("claude")?"claude":t.includes("codex")?"codex":t.includes("cursor")?"cursor":t.includes("github")?"github":t.replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown":"unknown"}function w5(e){return Bde[e]??e.replace(/[-_]/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function mb(e){return[...new Set(e.map(t=>t?.trim()).filter(t=>!!t))]}function dR(e){const t=e?.trim();return t?t.split("/").filter(Boolean).pop()??t:null}function pb(e,t=3){if(e.length===0)return"-";const n=e.slice(0,t),r=e.length>n.length?` +${e.length-n.length}`:"";return`${n.join(", ")}${r}`}function Ude(e){switch(e){case"weekly":return"7d";case"req/h":return"1h";default:return e||"quota"}}function j5(e){return e.windows&&e.windows.length>0?e.windows:[{label:Ude(e.unitLabel),fill:e.fill,usedLabel:e.usedLabel,capLabel:e.capLabel,unitLabel:e.unitLabel,resetAt:e.resetAt}]}function Fde(e){return e.capLabel==="100%"&&e.usedLabel.endsWith("%")?e.usedLabel:`${e.usedLabel}/${e.capLabel}`}function k5(e){return e>=.9?"err":e>=.75?"warn":"ok"}function Vde(e,t=30){const n=e??[];if(n.length<=t)return n;if(t<=1)return[n[n.length-1]];const r=(n.length-1)/(t-1);return Array.from({length:t},(a,o)=>n[Math.round(o*r)])}function Hde(e){const t=Math.max(0,Math.floor((e-Date.now())/1e3));if(t>=86400){const n=Math.floor(t/86400),r=Math.floor(t%86400/3600);return r>0?`${n}d ${r}h`:`${n}d`}if(t>=3600){const n=Math.floor(t/3600),r=Math.floor(t%3600/60);return r>0?`${n}h ${r}m`:`${n}h`}return`${Math.max(1,Math.floor(t/60))}m`}function dw(e){if(!e)return"-";const t=Math.max(0,Date.now()-e);return t<6e4?"now":t<36e5?`${Math.floor(t/6e4)}m`:t<864e5?`${Math.floor(t/36e5)}h`:`${Math.floor(t/864e5)}d`}function Wde(e){return!e||e.kind!=="quota"?null:j5(e).flatMap(t=>t.history??[]).reduce((t,n)=>Math.max(t??0,n.capturedAt),null)}function fR(e){return gc(e.source||e.topology.source)}function N5(e){const t=Date.parse(e.observedAt),n=Number.isFinite(t)?t:0;return Math.max(n,e.changedAt??0)||null}function qde(e){return e.includes("workflow")?"Claude workflow":w5(gc(e))}function Kde(e,t,n){const r=new Set(zde);for(const c of e)r.add(gc(c.harness));for(const c of t)r.add(gc(c.id));for(const c of n?.observations??[])r.add(fR(c));const a=new Map(t.map(c=>[gc(c.id),c])),o=new Map;for(const c of n?.observations??[]){const u=fR(c),f=o.get(u)??[];f.push(c),o.set(u,f)}return[...r].map(c=>{const u=e.filter(b=>gc(b.harness)===c),f=o.get(c)??[],h=u.reduce((b,C)=>(b[Ge(C.state)]+=1,b),{working:0,ready:0,not_ready:0}),p=u.reduce((b,C)=>Math.max(b??0,C.updatedAt??C.createdAt??0)||b,null),x=f.reduce((b,C)=>Math.max(b??0,N5(C)??0)||b,null),v=a.get(c)??null,y=Wde(v);return{id:c,label:w5(c),agents:u,gauge:v,observations:f,transports:mb(u.map(b=>b.transport)),models:mb(u.map(b=>b.model)),projects:mb(u.map(b=>dR(b.projectRoot)??b.project??dR(b.cwd))),working:h.working,ready:h.ready,notReady:h.not_ready,latestSeen:Math.max(p??0,x??0,y??0)||null}}).sort((c,u)=>{const f=c.agents.length>0?0:c.gauge?1:c.observations.length>0?2:3,h=u.agents.length>0?0:u.gauge?1:u.observations.length>0?2:3;return f-h||u.working-c.working||u.ready-c.ready||(u.latestSeen??0)-(c.latestSeen??0)||c.label.localeCompare(u.label)})}function Gde({points:e}){const t=Vde(e);return t.length===0?s.jsx("span",{className:"hs-history hs-history-empty",children:"live"}):s.jsx("span",{className:"hs-history","aria-label":`${t.length} budget samples`,children:t.map((n,r)=>{const a=Math.max(.06,Math.min(1,n.fill));return s.jsx("span",{className:`hs-history-bar hs-history-bar--${k5(n.fill)}`,style:{height:`${Math.round(a*100)}%`},title:`${new Date(n.capturedAt).toLocaleString()} ${n.usedLabel}`},`${n.capturedAt}:${r}`)})})}function Zde({gauge:e}){return e?e.kind==="status"?s.jsxs("div",{className:"hs-budget-status",children:[s.jsx("span",{children:e.windowLabel??"usage"}),s.jsx("strong",{children:e.statusLabel}),s.jsx("span",{children:e.detailLabel??"quota n/a"})]}):s.jsx("div",{className:"hs-budget-windows",children:j5(e).map(t=>{const n=Math.round(t.fill*100),r=k5(t.fill);return s.jsxs("div",{className:"hs-budget-window",children:[s.jsxs("div",{className:"hs-budget-window-top",children:[s.jsx("span",{className:"hs-budget-label",children:t.label}),s.jsx("strong",{className:`hs-budget-value hs-budget-value--${r}`,children:Fde(t)}),s.jsx("span",{className:"hs-budget-reset",children:Hde(t.resetAt)})]}),s.jsx("div",{className:"hs-budget-meter","aria-hidden":"true",children:s.jsx("span",{className:`hs-budget-meter-fill hs-budget-meter-fill--${r}`,style:{width:`${n}%`}})}),s.jsx(Gde,{points:t.history})]},`${e.id}:${t.label}`)})}):s.jsx("span",{className:"hs-muted",children:"-"})}function Yde({rows:e}){return s.jsxs("div",{className:"hs-ledger",role:"table","aria-label":"Provider ledger",children:[s.jsxs("div",{className:"hs-ledger-head",role:"row",children:[s.jsx("span",{children:"provider"}),s.jsx("span",{children:"agents"}),s.jsx("span",{children:"runtime"}),s.jsx("span",{children:"budget"}),s.jsx("span",{children:"topology"}),s.jsx("span",{children:"projects"}),s.jsx("span",{children:"seen"})]}),s.jsx("div",{className:"hs-ledger-rows",children:e.map(t=>{const n=t.working+t.ready,r=t.observations.reduce((a,o)=>(a.groups+=o.summary.groups,a.agents+=o.summary.agents,a.tasks+=o.summary.tasks,a),{groups:0,agents:0,tasks:0});return s.jsxs("div",{className:"hs-ledger-row",role:"row",children:[s.jsxs("div",{className:"hs-harness-cell",children:[s.jsx("span",{className:`hs-harness-mark${n>0?" hs-harness-mark--live":""}`,"aria-hidden":"true"}),s.jsxs("span",{className:"hs-harness-main",children:[s.jsx("strong",{children:t.label}),s.jsx("span",{children:t.gauge?"budget feed":t.observations.length>0?"observed":"catalog"})]})]}),s.jsxs("div",{className:"hs-agent-cell",children:[s.jsx("strong",{children:t.agents.length}),s.jsxs("span",{children:[t.working," working / ",t.ready," ready"]})]}),s.jsxs("div",{className:"hs-runtime-cell",children:[s.jsx("span",{title:t.transports.join(", "),children:pb(t.transports)}),s.jsx("span",{title:t.models.join(", "),children:pb(t.models,2)})]}),s.jsx(Zde,{gauge:t.gauge}),s.jsx("div",{className:"hs-topology-cell",children:t.observations.length>0?s.jsxs(s.Fragment,{children:[s.jsxs("strong",{children:[t.observations.length," sources"]}),s.jsxs("span",{children:[r.agents," agents / ",r.tasks," tasks"]}),s.jsxs("span",{children:[r.groups," groups"]})]}):s.jsx("span",{className:"hs-muted",children:"-"})}),s.jsx("div",{className:"hs-project-cell",title:t.projects.join(", "),children:pb(t.projects,3)}),s.jsx("div",{className:"hs-seen-cell",children:dw(t.latestSeen)})]},t.id)})})]})}function Xde({snapshot:e}){const t=e?.observations??[];return s.jsxs("section",{className:"hs-section",children:[s.jsxs("div",{className:"hs-section-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"Observed topology"}),s.jsxs("p",{children:[t.length," sources / ",e?.totals.agents??0," observed agents / ",e?.totals.tasks??0," tasks"]})]}),s.jsx("span",{className:"hs-section-meta",children:e?dw(e.generatedAt):"-"})]}),t.length===0?s.jsx("div",{className:"hs-empty",children:"No observed topology snapshot."}):s.jsx("div",{className:"hs-topology-grid",children:t.map(n=>{const r=n.topology,a=r.groups.filter(u=>u.kind==="workflow").length,o=r.tasks.filter(u=>u.state!=="completed"&&u.state!=="done").length,c=r.agents.slice(0,4);return s.jsxs("article",{className:"hs-topology-card",children:[s.jsxs("div",{className:"hs-topology-card-head",children:[s.jsx("strong",{children:qde(n.source)}),s.jsx("span",{children:dw(N5(n))})]}),s.jsxs("div",{className:"hs-topology-counts",children:[s.jsxs("span",{children:[s.jsx("strong",{children:r.groups.length})," groups"]}),s.jsxs("span",{children:[s.jsx("strong",{children:r.agents.length})," agents"]}),s.jsxs("span",{children:[s.jsx("strong",{children:r.tasks.length})," tasks"]}),s.jsxs("span",{children:[s.jsx("strong",{children:r.relationships.length})," edges"]})]}),s.jsxs("div",{className:"hs-topology-card-detail",children:[s.jsxs("span",{children:[a," workflows"]}),s.jsxs("span",{children:[o," active tasks"]})]}),s.jsx("div",{className:"hs-topology-agent-strip",children:c.length>0?c.map(u=>s.jsx("span",{title:u.id,children:u.name??u.role??u.type??"agent"},u.id)):s.jsx("span",{className:"hs-muted",children:"-"})})]},n.id)})})]})}function Qde({navigate:e}){const{agents:t,route:n}=qe(),r=zs(n),a=m.useMemo(()=>no(t,r),[t,r]),[o,c]=m.useState([]),[u,f]=m.useState(null),[h,p]=m.useState(!0),[x,v]=m.useState(!1),[y,b]=m.useState(null),C=m.useRef(0),E=m.useCallback(async(N=!1,T=!1)=>{const R=++C.current;T&&p(!0),v(!0),b(null);try{const[O,L]=await Promise.allSettled([ue(`/api/service-budgets${N?"?refresh=1":""}`),ue(`/api/topology/snapshot${N?"?force=1":""}`)]);if(R!==C.current)return;O.status==="fulfilled"&&c(O.value.gauges??[]),L.status==="fulfilled"&&f(L.value);const I=[O,L].filter(z=>z.status==="rejected").map(z=>z.reason instanceof Error?z.reason.message:String(z.reason));b(I.length>0?I.join(" / "):null)}finally{R===C.current&&(p(!1),v(!1))}},[]);m.useEffect(()=>{E(!0,!0)},[E]),m.useEffect(()=>{const N=window.setInterval(()=>{E(!1)},3e4);return()=>window.clearInterval(N)},[E]);const A=m.useMemo(()=>Kde(a,o,u),[a,o,u]),S=A.filter(N=>N.agents.length>0||N.gauge||N.observations.length>0).length,k=a.filter(N=>Ge(N.state)==="working").length;return s.jsxs("div",{className:"s-ops",children:[s.jsx("div",{className:"s-ops-header",children:s.jsx(Ef,{activeRoute:{view:"harnesses",...r?{machineId:r}:{}},navigate:e})}),s.jsx("div",{className:"s-ops-body hs-body",children:s.jsxs("div",{className:"hs-page",children:[s.jsxs("header",{className:"hs-page-head",children:[s.jsxs("div",{className:"hs-title-group",children:[s.jsx("span",{className:"hs-kicker",children:"ops / provider central"}),s.jsx("h2",{children:"Providers"}),s.jsxs("p",{children:[S," active providers / ",a.length," registered agents / ",o.length," budget feeds"]})]}),s.jsxs("button",{type:"button",className:"hs-refresh",disabled:x,onClick:()=>{E(!0)},children:[s.jsx(zd,{size:14,className:x?"hs-refresh-icon-spinning":"","aria-hidden":"true"}),s.jsx("span",{children:x?"Refreshing":"Refresh"})]})]}),s.jsxs("div",{className:"hs-stat-grid","aria-label":"Provider summary",children:[s.jsxs("div",{className:"hs-stat",children:[s.jsx("span",{children:"Providers"}),s.jsx("strong",{children:A.length}),s.jsxs("em",{children:[S," active"]})]}),s.jsxs("div",{className:"hs-stat",children:[s.jsx("span",{children:"Agents"}),s.jsx("strong",{children:a.length}),s.jsxs("em",{children:[k," working"]})]}),s.jsxs("div",{className:"hs-stat",children:[s.jsx("span",{children:"Topology"}),s.jsx("strong",{children:u?.totals.sources??0}),s.jsxs("em",{children:[u?.totals.relationships??0," edges"]})]}),s.jsxs("div",{className:"hs-stat",children:[s.jsx("span",{children:"Budgets"}),s.jsx("strong",{children:o.length}),s.jsxs("em",{children:[o.filter(N=>N.kind==="quota").length," quota feeds"]})]})]}),y&&s.jsxs("div",{className:"hs-error",children:["refresh: ",y]}),h?s.jsx("div",{className:"hs-empty",children:"Loading providers."}):s.jsx(Yde,{rows:A}),s.jsx(Xde,{snapshot:u})]})})]})}const Jde=3,efe=2;function S5(e){return e>=.9?"err":e>=.75?"warn":"ok"}const tfe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function C5(e,t){const n=e-t.getTime(),r=new Date(e).toDateString()===t.toDateString(),a=new Date(e),o=String(a.getHours()).padStart(2,"0"),c=String(a.getMinutes()).padStart(2,"0"),u=n>0&&n<6*3600*1e3;return r?{label:`${o}:${c}`,imminent:u}:{label:`${tfe[a.getDay()]} ${o}:${c}`,imminent:u}}function E5(e,t){const n=Math.max(0,Math.floor((e-t.getTime())/1e3));if(n>=86400){const r=Math.floor(n/86400),a=Math.floor(n%86400/3600);return a>0?`${r}d ${a}h`:`${r}d`}if(n>=3600){const r=Math.floor(n/3600),a=Math.floor(n%3600/60);return a>0?`${r}h ${a}m`:`${r}h`}return`${Math.max(1,Math.floor(n/60))}m`}function Ak(e){return e.windows&&e.windows.length>0?e.windows:[{label:nfe(e.unitLabel),fill:e.fill,usedLabel:e.usedLabel,capLabel:e.capLabel,unitLabel:e.unitLabel,resetAt:e.resetAt}]}function nfe(e){switch(e){case"weekly":return"7d";case"req/h":return"1h";default:return e||"quota"}}function sfe(e,t){return Ak(e).map(n=>{const r=C5(n.resetAt,t),a=E5(n.resetAt,t);return`${n.label}: ${n.usedLabel} / ${n.capLabel} ${n.unitLabel} · resets ${r.label} (in ${a})`}).join(" · ")}function gb(e){const t=e.trim().match(/^(\d+(?:\.\d+)?)([mhd])$/i);if(!t)return null;const n=Number(t[1]);if(!Number.isFinite(n))return null;switch(t[2]?.toLowerCase()){case"m":return n;case"h":return n*60;case"d":return n*24*60;default:return null}}function rfe(e){const t=[...e].sort((a,o)=>(gb(a.label)??Number.MAX_SAFE_INTEGER)-(gb(o.label)??Number.MAX_SAFE_INTEGER)),n=t.find(a=>(gb(a.label)??0)>=1440)??(t.length>1?t[t.length-1]:null);return{shortWindow:t.find(a=>a!==n)??null,longWindow:n}}function afe(e){return e.capLabel==="100%"&&e.usedLabel.endsWith("%")?e.usedLabel:`${e.usedLabel}/${e.capLabel}`}function Yp(){return s.jsx("span",{className:"hd-gauge-cell hd-gauge-cell--empty",children:"—"})}function hR({window:e}){if(!e)return s.jsx(Yp,{});const t=Math.round(e.fill*100),n=S5(e.fill);return s.jsxs("span",{className:"hd-gauge-cell hd-gauge-cell--usage",children:[s.jsx("span",{className:"hd-gauge-window-name",children:e.label}),s.jsx("span",{className:"hd-gauge-bar","aria-hidden":"true",children:s.jsx("span",{className:`hd-gauge-bar-fill hd-gauge-bar-fill--${n}`,style:{width:`${t}%`}})}),s.jsx("span",{className:"hd-gauge-window-used",children:afe(e)})]})}function mR({window:e,now:t}){if(!e)return s.jsx(Yp,{});const n=C5(e.resetAt,t),r=E5(e.resetAt,t);return s.jsxs("span",{className:`hd-gauge-cell hd-gauge-reset${n.imminent?" hd-gauge-reset--imminent":""}`,children:["↻ ",r]})}function ife(e){if(e.length===0)return"";if(e.length===1)return`M ${e[0].x} ${e[0].y}`;const t=[`M ${e[0].x} ${e[0].y}`];for(let n=0;n<e.length-1;n++){const r=e[n-1]??e[n],a=e[n],o=e[n+1],c=e[n+2]??o,u=a.x+(o.x-r.x)/6,f=a.y+(o.y-r.y)/6,h=o.x-(c.x-a.x)/6,p=o.y-(c.y-a.y)/6;t.push(`C ${u} ${f}, ${h} ${p}, ${o.x} ${o.y}`)}return t.join(" ")}function ofe({buckets:e}){const c=e.length;if(c<2||e.every(v=>v.count===0))return s.jsx("svg",{viewBox:"0 0 372 70",style:{width:"100%",height:70,display:"block"},children:s.jsx("line",{x1:"0",y1:56,x2:372,y2:56,stroke:"var(--border)"})});const f=372/(c-1),h=e.map((v,y)=>({x:y*f,y:56-Math.max(0,Math.min(1,v.value))*50})),p=ife(h),x=`${p} L 372 56 L 0 56 Z`;return s.jsxs("svg",{viewBox:"0 0 372 70",style:{width:"100%",height:70,display:"block"},children:[s.jsx("defs",{children:s.jsxs("linearGradient",{id:"hrdFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[s.jsx("stop",{offset:"0%",stopColor:"var(--accent)",stopOpacity:"0.22"}),s.jsx("stop",{offset:"100%",stopColor:"var(--accent)",stopOpacity:"0"})]})}),s.jsx("line",{x1:"0",y1:6,x2:372,y2:6,stroke:"var(--border)",opacity:"0.18"}),s.jsx("line",{x1:"0",y1:62/2,x2:372,y2:62/2,stroke:"var(--border)",opacity:"0.22"}),s.jsx("line",{x1:"0",y1:56,x2:372,y2:56,stroke:"var(--border)"}),s.jsx("path",{d:x,fill:"url(#hrdFill)"}),s.jsx("path",{d:p,fill:"none",stroke:"var(--accent)",strokeWidth:"1.5",strokeLinecap:"round"}),s.jsx("circle",{cx:h[c-1].x,cy:h[c-1].y,r:"2.5",fill:"var(--accent)"}),s.jsx("text",{x:"0",y:67,fill:"var(--dim)",fontSize:"9",fontFamily:"var(--font-mono)",children:"7d"}),s.jsx("text",{x:372/2,y:67,textAnchor:"middle",fill:"var(--dim)",fontSize:"9",fontFamily:"var(--font-mono)",children:"3d"}),s.jsx("text",{x:372,y:67,textAnchor:"end",fill:"var(--dim)",fontSize:"9",fontFamily:"var(--font-mono)",children:"now"})]})}function pR(e){const t=e.toLocaleDateString([],{weekday:"short"}).toUpperCase(),n=e.toLocaleDateString([],{month:"short"}).toUpperCase(),r=String(e.getDate()).padStart(2,"0");return`${t} ${r} ${n}`}function lfe(e){const t=String(e.getHours()).padStart(2,"0"),n=String(e.getMinutes()).padStart(2,"0"),r=String(e.getSeconds()).padStart(2,"0");return`${t}:${n}:${r}`}function cfe({gauge:e,now:t,onClick:n}){const r=n?"button":"span",a=n?{type:"button",onClick:n}:{};if(e.kind==="status")return s.jsxs(r,{className:`hd-gauge hd-gauge--status hd-gauge--${e.tone}${n?" hd-gauge--interactive":""}`,"aria-label":`${e.label} subscription usage`,...a,children:[s.jsxs("span",{className:"hd-gauge-head",children:[s.jsx("span",{className:"hd-gauge-label",children:e.label}),s.jsx("span",{className:`hd-gauge-dot hd-gauge-dot--${e.tone}`,"aria-hidden":"true"})]}),s.jsx(Yp,{}),s.jsx(Yp,{}),s.jsxs("span",{className:"hd-gauge-cell hd-gauge-cell--usage hd-gauge-cell--status",children:[s.jsx("span",{className:"hd-gauge-window-name",children:e.windowLabel??"usage"}),s.jsx("span",{className:"hd-gauge-status",children:e.statusLabel})]}),s.jsx("span",{className:"hd-gauge-cell hd-gauge-reset",children:e.detailLabel??"quota n/a"})]});const o=Ak(e),{shortWindow:c,longWindow:u}=rfe(o),f=S5(Math.max(...o.map(p=>p.fill))),h=Math.round(Math.max(...o.map(p=>p.fill))*100);return s.jsxs(r,{className:`hd-gauge hd-gauge--${f}${n?" hd-gauge--interactive":""}`,title:sfe(e,t),"aria-label":`${e.label} subscription usage`,...a,children:[s.jsxs("span",{className:"hd-gauge-head",children:[s.jsx("span",{className:"hd-gauge-label",children:e.label}),s.jsxs("span",{className:`hd-gauge-pct hd-gauge-pct--${f}`,children:[h,"%"]})]}),s.jsx(hR,{window:c}),s.jsx(mR,{window:c,now:t}),s.jsx(hR,{window:u}),s.jsx(mR,{window:u,now:t})]})}function ufe(e){const t=e.trim().match(/^(\d+(?:\.\d+)?)([kKmM])?$/u);if(!t)return 0;const n=Number(t[1]);if(!Number.isFinite(n))return 0;switch(t[2]?.toLowerCase()){case"m":return n*1e6;case"k":return n*1e3;default:return n}}function dfe(e){return e.kind==="quota"?Math.max(e.fill,...Ak(e).map(t=>t.fill)):ufe(e.statusLabel)>0?.01:0}function ffe(e){return A5(e).slice(0,efe)}function A5(e){return e.map((t,n)=>({gauge:t,index:n,score:dfe(t)})).sort((t,n)=>n.score-t.score||t.index-n.index).map(({gauge:t})=>t)}function hfe(e){const{now:t,operatorName:n,syncLabel:r,error:a,loading:o,refreshing:c,onRefresh:u,totalOperatorQueue:f,narrativeParts:h,navigate:p,opsEnabled:x,onReviewQueue:v,heartrate:y,heartrateWindow:b,heartrateBucketLabel:C,heartrateVisibleEventThreshold:E=Jde,serviceGauges:A}=e,[S,k]=m.useState(!1),N=h.find(Z=>Z.includes("need"))??h[0]??"",T=N?`${N}.`:"Scout is waiting for a fresh snapshot.",R=h.filter(Z=>Z!==N),O=N.includes("need"),L=R.join(" · "),I=a?"err":"ok",z=A5(A),_=ffe(A),U=S?z:_,D=A.length>_.length,q=y.reduce((Z,$)=>Z+$.count,0)>=E;return s.jsxs("section",{className:"hd",children:[s.jsxs("div",{className:"hd-topbar",children:[s.jsxs("div",{className:"hd-topbar-l",children:[s.jsx("span",{className:"hd-path",children:"home"}),s.jsx("span",{className:"hd-path-sep",children:"/"}),s.jsx("span",{className:"hd-path",children:"fleet"}),s.jsx("span",{className:"hd-path-sep",children:"/"}),s.jsx("span",{className:"hd-path hd-path--muted",children:pR(t)})]}),s.jsxs("div",{className:"hd-topbar-r",children:[s.jsx("span",{className:"hd-meta-label",children:"operator"}),s.jsx("span",{className:"hd-meta hd-meta--operator",children:n.toLowerCase()}),s.jsx("span",{className:"hd-path-sep",children:"/"}),s.jsx("span",{className:"hd-meta",children:lfe(t)}),s.jsx("span",{className:`hd-dot hd-dot--${I}`,"aria-hidden":"true"}),s.jsx("span",{className:`hd-meta hd-meta--${I}`,children:r})]}),U.length>0&&s.jsxs("div",{className:"hd-topbar-c","aria-label":"service usage",children:[s.jsxs("div",{className:"hd-gauge-title-row",children:[s.jsx("span",{className:"hd-gauge-window",children:"SUBSCRIPTIONS"}),D&&s.jsxs("button",{type:"button",className:"hd-gauge-toggle","aria-expanded":S,onClick:()=>k(Z=>!Z),children:["[",S?"top 2":`all ${A.length}`,"]"]})]}),s.jsxs("div",{className:"hd-gauge-set",children:[s.jsxs("div",{className:"hd-gauge-table-head","aria-hidden":"true",children:[s.jsx("span",{children:"service"}),s.jsx("span",{children:"short window"}),s.jsx("span",{children:"resets"}),s.jsx("span",{children:"long window"}),s.jsx("span",{children:"resets"})]}),U.map(Z=>s.jsx("span",{className:"hd-gauge-wrap",children:s.jsx(cfe,{gauge:Z,now:t,onClick:()=>p({view:"harnesses"})})},Z.id))]})]})]}),s.jsxs("div",{className:`hd-grid${q?"":" hd-grid--single"}`,children:[s.jsxs("div",{className:"hd-panel hd-panel--lede",children:[s.jsxs("div",{className:"hd-panel-title",children:[s.jsx("span",{children:"STATUS"}),s.jsx("span",{className:"hd-sep",children:"·"}),s.jsx("span",{children:pR(t)})]}),s.jsx("p",{className:`hd-status-line${O?" hd-status-line--warn":""}`,children:T}),L.length>0&&s.jsxs("p",{className:"hd-sub",children:[L,"."]}),a&&s.jsxs("p",{className:"hd-sub hd-sub--err",children:["sync: ",a]}),s.jsxs("div",{className:"hd-actions",children:[f>0&&s.jsxs("button",{type:"button",className:"hd-btn hd-btn--primary",onClick:v,children:["[review queue · ",f,"]"]}),x&&s.jsx("button",{type:"button",className:"hd-btn",onClick:()=>p({view:"ops"}),children:"[open ops]"}),s.jsxs("button",{type:"button",className:"hd-btn",disabled:o||c,onClick:u,children:["[",c?"refreshing":"r refresh","]"]})]})]}),q&&s.jsxs("div",{className:"hd-panel hd-panel--hr",children:[s.jsxs("div",{className:"hd-panel-title",children:[s.jsx("span",{children:"HEART-RATE"}),s.jsx("span",{className:"hd-sep",children:"·"}),s.jsx("span",{children:b}),C?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"hd-sep",children:"·"}),s.jsx("span",{children:C})]}):null]}),s.jsx(ofe,{buckets:y})]})]})]})}const mfe=e=>e==="right"?"railOccupantRight":"railOccupantBottom";function pfe(e,t,n,r){m.useEffect(()=>{if(!n||typeof window>"u"||typeof document>"u")return;const a=mfe(e),o=document.body.dataset[a];document.body.dataset[a]=t,window.dispatchEvent(new CustomEvent("hudson:rail:claim",{detail:{owner:t,side:e}})),o&&o!==t&&window.dispatchEvent(new CustomEvent("hudson:rail:preempted",{detail:{owner:o,side:e,by:t}}));const c=f=>{const h=f.detail;h&&h.side===e&&h.owner!==t&&r?.()},u=f=>{const h=f.detail;h&&h.side===e&&h.owner===t&&r?.()};return window.addEventListener("hudson:rail:claim",c),window.addEventListener("hudson:rail:preempted",u),()=>{window.removeEventListener("hudson:rail:claim",c),window.removeEventListener("hudson:rail:preempted",u),document.body.dataset[a]===t&&delete document.body.dataset[a],window.dispatchEvent(new CustomEvent("hudson:rail:release",{detail:{owner:t,side:e}}))}},[e,t,n,r])}const gfe=620,vfe=360,xfe=280,yfe=900,bfe=720;function wfe(e,t,n,r){if(typeof window>"u")return t;try{const a=window.localStorage.getItem(e);if(a==null)return t;const o=Number(a);return Number.isFinite(o)?Math.min(r,Math.max(n,o)):t}catch{return t}}const gR=["a[href]","button:not([disabled])","textarea:not([disabled])","input:not([disabled])","select:not([disabled])","[tabindex]:not([tabindex='-1'])"].join(", ");function T5({open:e,onClose:t,side:n="right",owner:r,defaultSize:a,minSize:o=xfe,maxSize:c,resizable:u=!1,backdrop:f=!0,scrollLock:h=!1,focusTrap:p=!1,ariaLabel:x,className:v,children:y}){const b=a??(n==="right"?gfe:vfe),C=c??(n==="right"?yfe:bfe),E=`slidepanel.size.${r}.${n}`,[A,S]=m.useState(()=>wfe(E,b,o,C)),k=m.useRef(A);k.current=A;const[N,T]=m.useState(!1),R=m.useRef(null),O=m.useRef(null),L=m.useCallback(()=>t(),[t]);pfe(n,r,e,L),m.useEffect(()=>{if(!e)return;const _=U=>{U.key==="Escape"&&(U.preventDefault(),L())};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[e,L]),m.useEffect(()=>{if(!e||!h)return;const _=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=_}},[e,h]),m.useEffect(()=>{if(!e)return;O.current=document.activeElement;const _=R.current;return _?((_.querySelector(gR)??_).focus(),()=>{O.current?.focus?.()}):void 0},[e]),m.useEffect(()=>{if(!N)return;const _=D=>{if(n==="right"){const q=window.innerWidth-D.clientX;S(Math.min(C,Math.max(o,q)))}else{const q=window.innerHeight-D.clientY;S(Math.min(C,Math.max(o,q)))}},U=()=>{T(!1);try{window.localStorage.setItem(E,String(k.current))}catch{}};return window.addEventListener("pointermove",_),window.addEventListener("pointerup",U),window.addEventListener("pointercancel",U),()=>{window.removeEventListener("pointermove",_),window.removeEventListener("pointerup",U),window.removeEventListener("pointercancel",U)}},[N,n,o,C,E]);const I=_=>{if(!p||_.key!=="Tab")return;const U=R.current;if(!U)return;const D=Array.from(U.querySelectorAll(gR));if(D.length===0){_.preventDefault(),U.focus();return}const q=D[0],Z=D[D.length-1],$=document.activeElement;_.shiftKey?($===q||!U.contains($))&&(_.preventDefault(),Z.focus()):$===Z&&(_.preventDefault(),q.focus())};if(!e)return null;const z=n==="right"?{width:A}:{height:A};return s.jsxs(s.Fragment,{children:[f&&s.jsx("div",{className:"s-slide-backdrop","data-side":n,onClick:L,"aria-hidden":"true"}),s.jsxs("aside",{ref:R,className:`s-slide s-slide--${n}${N?" s-slide--resizing":""}${v?` ${v}`:""}`,role:"dialog","aria-modal":"true","aria-label":x,tabIndex:-1,onKeyDown:I,style:z,children:[u&&s.jsx("div",{className:`s-slide-resize s-slide-resize--${n}`,onPointerDown:_=>{_.preventDefault(),T(!0)},role:"separator","aria-orientation":n==="right"?"vertical":"horizontal","aria-label":"Resize panel"}),y]})]})}const cp=new Set;let vb=null,vR=null,Xp=null;function jfe(){return`ws://${typeof window<"u"?window.location.hostname:"127.0.0.1"}:65535/trpc`}function kfe(e){for(const t of[...cp])t(e)}function Nfe(){Xp||(vb||(vb=KP({url:jfe()}),vR=ZP({links:[GP({client:vb})]})),Xp=vR.tail.events.subscribe(void 0,{onData:e=>{const t=e.data;t&&kfe(t)}}))}function Sfe(){Xp?.unsubscribe(),Xp=null}function tu(e){const t=m.useRef(e);t.current=e,m.useEffect(()=>{const n=r=>t.current(r);return cp.add(n),Nfe(),()=>{cp.delete(n),cp.size===0&&Sfe()}},[])}const xR=5e3,Cfe=500,yR=5e3,Efe=3e4,M5={user:">",assistant:"<",tool:"*","tool-result":"=",system:"~",other:"·"},Af={"scout-managed":"scout","hudson-managed":"hudson",unattributed:"native"},R5={"scout-managed":"s-tail-chip--origin-scout","hudson-managed":"s-tail-chip--origin-hudson",unattributed:"s-tail-chip--origin-native"};function Tf(e){return e?.trim().toLowerCase()||"unknown"}function Afe(e,t){const n=new Map,r=e?.transcripts?.length?e.transcripts:e?.processes.length?e.processes:t;for(const a of r){const o=Tf(a.source);n.set(o,(n.get(o)??0)+1)}return[...n.entries()].map(([a,o])=>({source:a,count:o})).sort((a,o)=>o.count-a.count||a.source.localeCompare(o.source))}function Tfe(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0"),a=String(t.getSeconds()).padStart(2,"0"),o=String(t.getMilliseconds()).padStart(3,"0");return`${n}:${r}:${a}.${o}`}function I5(e){return e?(e.split(":")[0]??e).slice(0,8):"—"}function Mfe(e,t){return`${e.id}:${e.ts}:${t}`}const Rfe=/\b(error|failed|failure|exception|panic|timeout|timed out|refused|crash|fatal|non[- ]?zero|exit(?:ed)? with code [1-9])\b/i,Ife=/\b(warn(?:ing)?|deprecated|retry|rate limit|rate-limited|blocked|skipped|interrupted|aborted|stale|conflict|permission denied|denied)\b/i;function _5(e){const t=e.replace(/[_-]+/g," ");return Rfe.test(t)?"error":Ife.test(t)?"warn":null}function bR(e){return!(e==null||e===!1||typeof e=="string"&&!e.trim())}function fw(e,t=0){if(e==null||t>4||typeof e=="string"||typeof e!="object")return null;if(Array.isArray(e)){let r=null;for(const a of e.slice(0,40)){const o=fw(a,t+1);if(o==="error")return"error";r??=o}return r}let n=null;for(const[r,a]of Object.entries(e).slice(0,80)){const o=r.toLowerCase();if((o==="is_error"||o==="failed")&&a===!0||o==="error"&&bR(a))return"error";if((o==="warning"||o==="warn")&&bR(a)&&(n="warn"),typeof a=="string"&&(o==="level"||o==="severity"||o==="status"||o==="type"||o==="subtype")){const u=_5(a);if(u==="error")return"error";n??=u}const c=fw(a,t+1);if(c==="error")return"error";n??=c}return n}function O5(e){const t=fw(e.raw);if(t==="error")return"error";if(e.kind==="tool-result"||e.kind==="system"||e.kind==="other"){const n=_5(e.summary);return n==="error"?"error":t??n}return t}function _fe(e,t){return t==="all"?!0:t==="warn-plus"?e!=null:e==="error"}function Ofe(e){switch(e){case"errors-only":return"errors";case"warn-plus":return"warnings or errors";case"all":return"all session events"}}function $fe(e,t,n=null,r="all"){if(!t)return!0;const a=Af[e.harness],o=n==="error"?"error failed failure issue":n==="warn"?"warn warning issue":"",u=(r==="context"?[e.project,e.cwd,e.sessionId,e.source,e.harness,a,o]:[e.summary,e.project,e.cwd,e.sessionId,e.source,e.harness,a,o]).join(" ").toLowerCase(),f=t.toLowerCase().split("|").map(h=>h.trim()).filter(Boolean);return f.length===0?!0:f.some(h=>u.includes(h))}function Lfe(e){try{return JSON.stringify(e,null,2)??""}catch{return String(e)}}function Pfe(e){return[["time",eg(e.ts)],["kind",e.kind],["project",e.project],["cwd",e.cwd||"—"],["session",e.sessionId||"—"],["source",Tf(e.source)],["origin",Af[e.harness]],["pid",e.parentPid!=null?`${e.pid} <- ${e.parentPid}`:String(e.pid)]].map(([n,r])=>`${n}: ${r}`).join(`
174
- `)}function Dfe(e){const t=Tf(e.source),n=Af[e.harness],r=Lfe(e.raw??e),a=[{label:"Time",value:eg(e.ts)},{label:"Kind",value:e.kind},{label:"Project",value:e.project},{label:"Cwd",value:e.cwd||"—"},{label:"Session",value:e.sessionId||"—"},{label:"Source",value:t},{label:"Origin",value:n},{label:"Pid",value:e.parentPid!=null?`${e.pid} <- ${e.parentPid}`:String(e.pid)}];return{source:"tail",focus:"item",title:`${e.kind} · ${t}`,meta:`${eg(e.ts)} · ${e.project} · ${I5(e.sessionId)}`,body:e.summary,metadata:a,copy:[{label:"Copy message",value:e.summary},{label:"Copy metadata",value:Pfe(e)},{label:"Copy raw",value:r}],action:e.sessionId?{label:"Open session",route:{view:"sessions",sessionId:e.sessionId}}:null}}function wR(e){if(typeof window>"u")return;const t=window;t.scoutOpsDetailSnapshot=e,window.dispatchEvent(new CustomEvent("scout:ops-detail",{detail:e}))}function Qp({navigate:e,initialFilter:t,variant:n="tail",chrome:r="full",filterLabel:a,filterScope:o="all"}={}){const{route:c}=qe(),u=n==="issues",f=r==="embedded",[h,p]=m.useState([]),[x,v]=m.useState(null),[y,b]=m.useState(t??""),[C,E]=m.useState(!!t&&!f),[A,S]=m.useState("warn-plus"),[k,N]=m.useState(!1),[T,R]=m.useState(0),[O,L]=m.useState(0),[I,z]=m.useState(null),_=m.useRef(null),U=m.useRef(null),D=m.useRef(!0),q=m.useRef([]),Z=m.useCallback(X=>{q.current.push(Date.now()),p(ae=>ae.length>=xR?[...ae.slice(ae.length-xR+1),X]:[...ae,X])},[]);tu(Z),m.useEffect(()=>{b(t??""),E(!!t&&!f)},[f,t]),m.useEffect(()=>{let X=!1;return(async()=>{try{const ae=new URLSearchParams({limit:String(Cfe)});(f||t)&&ae.set("transcripts","true");const be=await ue(`/api/tail/recent?${ae.toString()}`);X||p(be.events??[])}catch{}})(),()=>{X=!0}},[f,t]),m.useEffect(()=>{if(!f)return wR(I?Dfe(I):null),()=>wR(null)},[f,I]);const $=m.useCallback(async()=>{try{const X=await ue("/api/tail/discover");v(X)}catch{}},[]);m.useEffect(()=>{$();const X=setInterval(()=>{$()},Efe);return()=>clearInterval(X)},[$]),m.useEffect(()=>{const X=setInterval(()=>{const be=Date.now()-yR,_e=q.current.filter(xe=>xe>=be);q.current=_e,L(_e.length/(yR/1e3))},1e3);return()=>clearInterval(X)},[]);const G=m.useMemo(()=>h.map(X=>({event:X,severity:O5(X)})),[h]),V=m.useMemo(()=>{let X=0,ae=0;for(const be of G)be.severity==="error"&&ae++,be.severity==="warn"&&X++;return{warn:X,error:ae,total:X+ae}},[G]),Y=m.useMemo(()=>G.filter(({event:X,severity:ae})=>u&&!_fe(ae,A)?!1:$fe(X,y,ae,o)),[G,y,o,A,u]);m.useLayoutEffect(()=>{const X=_.current;if(X){if(k){R(ae=>ae+1);return}X.scrollTop=X.scrollHeight}},[Y,k]);const K=m.useCallback(()=>{const X=_.current;if(!X)return;const be=X.scrollHeight-X.scrollTop-X.clientHeight<24;D.current=be,be?(N(!1),R(0)):k||N(!0)},[k]),P=m.useCallback(X=>{b(X),E(!0),requestAnimationFrame(()=>U.current?.focus())},[]),H=m.useCallback(X=>{!X||!e||wt(e,{view:"sessions",sessionId:X},{returnTo:c})},[e,c]),B=m.useCallback(()=>{const X=_.current;X&&(X.scrollTop=X.scrollHeight,N(!1),R(0))},[]);m.useEffect(()=>{if(f)return;const X=ae=>{const be=ae.target,_e=be instanceof HTMLInputElement||be instanceof HTMLTextAreaElement||(be?.isContentEditable??!1);if(ae.key==="/"&&!_e){ae.preventDefault(),E(!0),requestAnimationFrame(()=>U.current?.focus());return}if(ae.key==="Escape"&&C&&document.activeElement===U.current){ae.preventDefault(),E(!1),U.current?.blur(),b("");return}(ae.key==="g"||ae.key==="G")&&!_e&&(ae.preventDefault(),B())};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[f,C,B]);const Q=x?.totals,oe=Q?.transcripts??x?.transcripts?.length??0,ne=m.useMemo(()=>Afe(x,h),[x,h]);return s.jsxs("div",{className:`s-tail s-tail--${r}`,children:[s.jsxs("div",{className:`s-tail-status${u?" s-tail-status--issues":""}`,children:[s.jsxs("span",{className:"s-tail-status-cluster s-tail-status-cluster--metrics",children:[s.jsxs("span",{className:"s-tail-status-cell",children:[s.jsx("span",{className:"s-tail-rate-pulse"}),s.jsx("strong",{children:oe})," log",oe===1?"":"s"]}),s.jsxs("span",{className:"s-tail-status-cell",children:[s.jsx("strong",{children:Q?.total??0})," proc",(Q?.total??0)===1?"":"s"]}),s.jsxs("span",{className:"s-tail-status-cell",children:[s.jsx("strong",{children:O.toFixed(1)})," lines/s"]})]}),u&&s.jsxs("span",{className:"s-tail-status-cluster s-tail-status-cluster--issues",children:[s.jsx("span",{className:"s-tail-status-label",children:"alerts"}),s.jsxs("span",{className:"s-tail-issue-filter",role:"group","aria-label":"Alert severity filter",children:[s.jsxs("button",{type:"button",className:`s-tail-issue-filter-btn${A==="errors-only"?" s-tail-issue-filter-btn--active":""}`,onClick:()=>S("errors-only"),"aria-pressed":A==="errors-only",children:["Errors ",s.jsx("strong",{children:V.error})]}),s.jsxs("button",{type:"button",className:`s-tail-issue-filter-btn${A==="warn-plus"?" s-tail-issue-filter-btn--active":""}`,onClick:()=>S("warn-plus"),"aria-pressed":A==="warn-plus",children:["Warn+ ",s.jsx("strong",{children:V.total})]}),s.jsxs("button",{type:"button",className:`s-tail-issue-filter-btn${A==="all"?" s-tail-issue-filter-btn--active":""}`,onClick:()=>S("all"),"aria-pressed":A==="all",children:["All ",s.jsx("strong",{children:h.length})]})]})]}),s.jsx("span",{className:"s-tail-status-spacer"}),s.jsxs("span",{className:"s-tail-status-cluster s-tail-status-cluster--harnesses",children:[s.jsx("span",{className:"s-tail-status-label",children:"harness"}),s.jsx("span",{className:"s-tail-status-inline",children:ne.length>0?ne.slice(0,4).map(X=>s.jsxs("span",{children:[s.jsx("strong",{children:X.count})," ",X.source]},X.source)):s.jsx("strong",{children:"none"})})]}),y&&f&&s.jsx("span",{className:"s-tail-status-filter",title:y,children:a??"filtered"}),k&&s.jsx("span",{className:"s-tail-status-paused",children:"paused"})]}),C&&s.jsxs("div",{className:"s-tail-filter",children:[s.jsx("span",{className:"s-tail-filter-prompt",children:"/"}),s.jsx("input",{ref:U,className:"s-tail-filter-input",value:y,placeholder:"substring across summary · project · session",onChange:X=>b(X.target.value),onKeyDown:X=>{X.key==="Enter"&&(X.preventDefault(),U.current?.blur())},autoFocus:!0,spellCheck:!1}),s.jsx("span",{className:"s-tail-filter-hint",children:"esc to clear"})]}),s.jsxs("div",{className:"s-tail-body",ref:_,onScroll:K,children:[Y.length===0?s.jsxs("div",{className:"s-tail-empty",children:[s.jsxs("span",{className:"s-tail-empty-title",children:[u?"No alert events":"Waiting for events",s.jsx("span",{className:"s-tail-empty-cursor","aria-hidden":"true"})]}),s.jsx("span",{className:"s-tail-empty-body",children:y?f?s.jsxs(s.Fragment,{children:["no events match ",s.jsx("strong",{children:a??"this work filter"})]}):s.jsxs(s.Fragment,{children:["no events match filter ",s.jsx("strong",{children:y})]}):u?s.jsxs(s.Fragment,{children:["no ",Ofe(A)," in the buffered session tail"]}):oe?s.jsxs(s.Fragment,{children:["watching ",oe," transcript",oe===1?"":"s"," · no events yet"]}):s.jsx(s.Fragment,{children:"agent tool calls, messages, and system events stream here"})}),!oe&&!y&&s.jsxs("span",{className:"s-tail-empty-hint",children:["Start a session to see traffic",s.jsx("span",{className:"s-tail-empty-hint-sep",children:" · "}),s.jsx("code",{children:"scout watch --tail"})]})]}):Y.map(({event:X,severity:ae},be)=>s.jsx(zfe,{event:X,issueSeverity:ae,selected:I===X,onSelect:z,onProjectClick:P,onSessionClick:H},Mfe(X,be))),k&&T>0&&s.jsxs("div",{className:"s-tail-divider",onClick:B,onKeyDown:X=>{(X.key==="Enter"||X.key===" ")&&(X.preventDefault(),B())},role:"button",tabIndex:0,"aria-label":`Resume live tail · ${T} new`,children:["── paused · ",T," new · click or press G to jump back to live ──"]})]}),f?s.jsxs("div",{className:"s-tail-keys s-tail-keys--embedded",children:[s.jsxs("span",{children:[Y.length," / ",h.length," lines buffered"]}),k&&T>0&&s.jsxs("span",{children:[T," new"]})]}):s.jsxs("div",{className:"s-tail-keys",children:[s.jsxs("span",{children:[s.jsx("kbd",{children:"j"}),"/",s.jsx("kbd",{children:"k"})," scroll"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"/"})," filter"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"G"})," jump live"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"esc"})," close filter"]}),s.jsx("span",{className:"s-tail-keys-spacer"}),s.jsxs("span",{children:[Y.length," / ",h.length," lines buffered"]})]}),f&&I&&s.jsx(Ufe,{event:I,onClose:()=>z(null),onProjectClick:P,onSessionClick:H})]})}function zfe({event:e,issueSeverity:t,selected:n,onSelect:r,onProjectClick:a,onSessionClick:o}){const c=R5[e.harness],u=Af[e.harness],f=Tf(e.source),h=t?` s-tail-row--issue s-tail-row--issue-${t}`:"";return s.jsxs("div",{className:`s-tail-row s-tail-row--${e.kind}${h}${n?" s-tail-row--selected":""}`,role:"button",tabIndex:0,onClick:()=>r(e),onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),r(e))},children:[s.jsx("span",{className:"s-tail-cell-time",children:Tfe(e.ts)}),s.jsx("span",{className:"s-tail-gutter",children:"│"}),s.jsx("span",{className:"s-tail-chip s-tail-chip--harness",children:f}),s.jsx("span",{className:`s-tail-chip s-tail-chip--origin ${c}`,title:`origin: ${u}`,children:u}),s.jsxs("span",{className:"s-tail-cell-context",children:[s.jsx(Jp,{className:"s-tail-link s-tail-link--project",onClick:a?()=>a(e.project):void 0,title:`Filter to ${e.project}`,children:s.jsx("strong",{children:e.project})})," · ",s.jsx(Jp,{className:"s-tail-link s-tail-link--session",onClick:o&&e.sessionId?()=>o(e.sessionId):void 0,title:e.sessionId?`Open session ${e.sessionId}`:void 0,children:I5(e.sessionId)})," · ",s.jsx("span",{className:"s-tail-cell-pid",title:e.pid>0?`pid ${e.pid}`:"file-backed log",children:e.pid>0?e.pid:"log"})]}),s.jsx("span",{className:`s-tail-glyph s-tail-glyph--${e.kind}`,children:M5[e.kind]}),s.jsx("span",{className:"s-tail-summary",children:e.summary})]})}function Jp({className:e,onClick:t,title:n,children:r}){return t?s.jsx("span",{className:`${e} s-tail-link--active`,role:"link",tabIndex:0,title:n,onClick:a=>{a.stopPropagation(),t()},onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),a.stopPropagation(),t())},children:r}):s.jsx("span",{className:e,title:n,children:r})}function eg(e){const t=new Date(e),n=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),a=String(t.getDate()).padStart(2,"0"),o=String(t.getHours()).padStart(2,"0"),c=String(t.getMinutes()).padStart(2,"0"),u=String(t.getSeconds()).padStart(2,"0"),f=String(t.getMilliseconds()).padStart(3,"0");return`${n}-${r}-${a} ${o}:${c}:${u}.${f}`}function up(e){return(JSON.stringify(e,null,2)??"undefined").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/("(?:\\.|[^"\\])*"\s*:)|("(?:\\.|[^"\\])*")|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g,(r,a,o,c,u)=>a?`<span class="s-tail-jk">${a}</span>`:o?`<span class="s-tail-js">${o}</span>`:c?`<span class="s-tail-jl">${c}</span>`:u?`<span class="s-tail-jn">${u}</span>`:r)}function Bfe(e){if(!e||typeof e!="object")return null;const t=e,r=t.message?.content??t.content;return Array.isArray(r)?r:typeof r=="string"?[{type:"text",text:r}]:null}function Ufe({event:e,onClose:t,onProjectClick:n,onSessionClick:r}){const[a,o]=m.useState(!0),c=R5[e.harness],u=Af[e.harness],f=Tf(e.source),h=O5(e),p=Bfe(e.raw);return s.jsxs(T5,{open:!0,onClose:t,side:"right",owner:"openscout.tail",resizable:!0,defaultSize:620,minSize:400,maxSize:960,ariaLabel:"Tail event detail",children:[s.jsxs("div",{className:"s-slide-header s-tail-sheet-header",children:[s.jsx("span",{className:`s-tail-glyph s-tail-glyph--${e.kind}`,children:M5[e.kind]}),s.jsx("span",{className:"s-tail-sheet-kind",children:e.kind}),h&&s.jsx("span",{className:`s-tail-chip s-tail-chip--issue-${h}`,children:h}),s.jsx("span",{className:"s-tail-chip s-tail-chip--harness",children:f}),s.jsx("span",{className:`s-tail-chip s-tail-chip--origin ${c}`,title:`origin: ${u}`,children:u}),s.jsx("span",{className:"s-slide-spacer"}),s.jsx("span",{className:"s-tail-sheet-time",children:eg(e.ts)}),s.jsx("button",{type:"button",className:"s-slide-close",onClick:t,"aria-label":"Close",children:"×"})]}),s.jsxs("div",{className:"s-slide-body s-tail-sheet-body",children:[s.jsx("section",{className:"s-tail-sheet-section",children:s.jsxs("div",{className:"s-tail-sheet-grid",children:[s.jsx("span",{className:"s-tail-sheet-key",children:"project"}),s.jsx("span",{className:"s-tail-sheet-val",children:s.jsx(Jp,{className:"s-tail-link s-tail-link--project",onClick:n?()=>n(e.project):void 0,title:`Filter to ${e.project}`,children:e.project})}),s.jsx("span",{className:"s-tail-sheet-key",children:"cwd"}),s.jsx("span",{className:"s-tail-sheet-val s-tail-sheet-val--mono",children:e.cwd||"—"}),s.jsx("span",{className:"s-tail-sheet-key",children:"session"}),s.jsx("span",{className:"s-tail-sheet-val s-tail-sheet-val--mono",children:s.jsx(Jp,{className:"s-tail-link s-tail-link--session",onClick:r&&e.sessionId?()=>r(e.sessionId):void 0,title:e.sessionId?`Open session ${e.sessionId}`:void 0,children:e.sessionId||"—"})}),s.jsx("span",{className:"s-tail-sheet-key",children:"harness"}),s.jsx("span",{className:"s-tail-sheet-val s-tail-sheet-val--mono",children:f}),s.jsx("span",{className:"s-tail-sheet-key",children:"origin"}),s.jsx("span",{className:"s-tail-sheet-val s-tail-sheet-val--mono",children:u}),s.jsx("span",{className:"s-tail-sheet-key",children:"pid"}),s.jsxs("span",{className:"s-tail-sheet-val s-tail-sheet-val--mono",children:[e.pid,e.parentPid!=null?` ← ${e.parentPid}`:""]})]})}),s.jsxs("section",{className:"s-tail-sheet-section",children:[s.jsx("h4",{className:"s-tail-sheet-h",children:"summary"}),s.jsx("div",{className:"s-tail-sheet-summary",children:e.summary})]}),p&&p.length>0&&s.jsxs("section",{className:"s-tail-sheet-section",children:[s.jsx("h4",{className:"s-tail-sheet-h",children:"content"}),p.map((x,v)=>s.jsx(Ffe,{block:x},v))]}),s.jsxs("section",{className:"s-tail-sheet-section",children:[s.jsxs("button",{type:"button",className:"s-tail-sheet-toggle",onClick:()=>o(x=>!x),children:[a?"▾":"▸"," raw event"]}),a&&s.jsx("pre",{className:"s-tail-sheet-json",dangerouslySetInnerHTML:{__html:up(e.raw??e)}})]})]})]})}function Ffe({block:e}){if(e.type==="text"){const t=e.text??"";return s.jsx("div",{className:"s-tail-sheet-text",children:t})}if(e.type==="tool_use"){const t=e;return s.jsxs("div",{className:"s-tail-sheet-block s-tail-sheet-block--tool",children:[s.jsxs("div",{className:"s-tail-sheet-block-head",children:[s.jsx("span",{className:"s-tail-glyph s-tail-glyph--tool",children:"*"}),s.jsx("span",{className:"s-tail-sheet-block-title",children:t.name??"tool_use"})]}),s.jsx("pre",{className:"s-tail-sheet-json",dangerouslySetInnerHTML:{__html:up(t.input??{})}})]})}if(e.type==="tool_result"){const t=e,n=typeof t.content=="string";return s.jsxs("div",{className:`s-tail-sheet-block s-tail-sheet-block--tool-result${t.is_error?" s-tail-sheet-block--err":""}`,children:[s.jsxs("div",{className:"s-tail-sheet-block-head",children:[s.jsx("span",{className:"s-tail-glyph s-tail-glyph--tool-result",children:"="}),s.jsxs("span",{className:"s-tail-sheet-block-title",children:["tool_result",t.is_error?" · error":""]})]}),n?s.jsx("pre",{className:"s-tail-sheet-pre",children:t.content}):s.jsx("pre",{className:"s-tail-sheet-json",dangerouslySetInnerHTML:{__html:up(t.content??{})}})]})}return s.jsxs("div",{className:"s-tail-sheet-block",children:[s.jsxs("div",{className:"s-tail-sheet-block-head",children:[s.jsx("span",{className:"s-tail-glyph s-tail-glyph--other",children:"·"}),s.jsx("span",{className:"s-tail-sheet-block-title",children:e.type})]}),s.jsx("pre",{className:"s-tail-sheet-json",dangerouslySetInnerHTML:{__html:up(e)}})]})}const hw="openscout:persistent-state-change";function Vfe(e,t){typeof window>"u"||window.dispatchEvent(new CustomEvent(hw,{detail:{key:e,value:t}}))}function jR(e){try{return window.localStorage.getItem(e)}catch{return null}}function Tk(e,t){try{window.localStorage.setItem(e,t)}catch{}Vfe(e,t)}function Mk(e){const[t,n]=m.useState(()=>typeof window>"u"?null:jR(e));return m.useEffect(()=>{n(jR(e));const r=o=>{const c=o.detail;!c||c.key!==e||n(c.value)},a=o=>{o.key===e&&n(o.newValue)};return window.addEventListener(hw,r),window.addEventListener("storage",a),()=>{window.removeEventListener(hw,r),window.removeEventListener("storage",a)}},[e]),t}function mw(e,t){const n=Mk(e),r=n===null?t:n==="true",a=m.useCallback(o=>{Tk(e,o?"true":"false")},[e]);return[r,a]}function Rk(e,t){const n=Mk(e),r=n===null?Number.NaN:Number(n),a=Number.isFinite(r)?r:t,o=m.useCallback(c=>{Tk(e,String(c))},[e]);return[a,o]}function $5(e,t){const r=Mk(e)??t,a=m.useCallback(o=>{Tk(e,o)},[e]);return[r,a]}const Si=[{label:"30m",value:30*6e4,activityLimit:80},{label:"6h",value:360*6e4,activityLimit:250},{label:"24h",value:1440*6e4,activityLimit:800}],kR=Si[2].value,Hfe="openscout.home.lookbackMs.v1",Wfe=60*6e4,L5=30*6e4,qfe="openscout.home.noRecentSignalInactive.v1",Kfe=200,Gfe=1e3,Zfe=3e4,Yfe=3;function Ko(e,t){const n=St(e);if(n===null)return"—";const r=Math.max(0,Math.floor((t-n)/1e3));if(r<60)return`${r}s`;const a=Math.floor(r/60);if(a<60)return`${a}m`;const o=Math.floor(a/60);return o<48?`${o}h`:`${Math.floor(o/24)}d`}function Gg(e,t=140){const n=(e??"").replace(/\s+/g," ").trim();return n?n.length>t?`${n.slice(0,t-1)}…`:n:""}function P5(e){return{handoff_sent:"handed off",handoff_received:"received handoff",flight_updated:"replied",ask_sent:"asked",ask_replied:"answered",message_sent:"said",message_received:"received"}[e]??e.replace(/[._]/g," ")}function Xfe(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.recordId?{view:"work",workId:e.recordId}:e.agentId?{view:"agents",agentId:e.agentId}:null}function D5(e){const t=Math.round(e/6e4);if(t<60)return`${t}m`;const n=t/60;return`${Number.isInteger(n)?n:n.toFixed(1)}h`}function pw(e){if(!Number.isFinite(e)||e<=0)return"now";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60);if(n<60)return`${n}m`;const r=Math.floor(n/60);return r<48?`${r}h`:`${Math.floor(r/24)}d`}function Qfe(e,t,n){if(e.length===0)return null;const r=e.map(f=>St(f.ts)).filter(f=>f!==null).sort((f,h)=>h-f);if(r.length===0)return null;const a=r[0],o=r[r.length-1];let c=0;for(let f=1;f<r.length;f++)c=Math.max(c,r[f-1]-r[f]);const u=n-t;return c=Math.max(c,o-u),{count:e.length,lastAgoMs:Math.max(0,n-a),longestGapMs:Math.max(0,c)}}function Jfe(e){const t=e.map(r=>Math.sqrt(r)),n=[.56,.28,.11,.05];return t.map((r,a)=>{let o=0,c=0;for(let u=-3;u<=3;u++){const f=a+u;if(f<0||f>=t.length)continue;const h=n[Math.abs(u)]??0;o+=t[f]*h,c+=h}return c>0?o/c:0})}function ehe(e,t,n){if(e.length<2||t.length===0)return e;const r=Math.max(1,e[1].ts-e[0].ts),a=e[0].ts,o=e[e.length-1].ts+r,c=e.map(h=>h.count);for(const h of t){const p=St(h.ts);if(p===null||p<a||p>n||p>=o)continue;const x=Math.floor((p-a)/r);x>=0&&x<c.length&&(c[x]=(c[x]??0)+1)}const u=Jfe(c),f=Math.max(1,...u);return e.map((h,p)=>({...h,count:c[p]??h.count,value:(u[p]??0)/f}))}function xb(e,t){const n=St(e);return n!==null&&t-n<=L5}function the(e){try{const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[r,a]of Object.entries(t)){const o=typeof a=="number"?a:Number(a);r&&Number.isFinite(o)&&(n[r]=o)}return n}catch{return{}}}function NR(e){const t=Object.entries(e).filter(n=>Number.isFinite(n[1])).sort((n,r)=>r[1]-n[1]).slice(0,Kfe);return JSON.stringify(Object.fromEntries(t))}function z5(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.collaborationRecordId?{view:"work",workId:e.collaborationRecordId}:{view:"agents",agentId:e.agentId}}function nhe(e,t=118){if(e.length<=t)return e;const n=Math.ceil((t-1)*.58),r=Math.floor((t-1)*.42);return`${e.slice(0,n).trimEnd()}…${e.slice(e.length-r).trimStart()}`}function she(e){return e?e.startsWith("/Users/")?`~/${e.split("/").slice(3).join("/")}`:e:null}function rhe(e){const t=e?.trim();if(!t)return null;const n=t.endsWith(".jsonl")?t.slice(0,-6):t,r=n.split(/[/:]/u).filter(Boolean).pop()??n;return/^[0-9a-f]{8}-[0-9a-f]{4}-/iu.test(r)?`${r.slice(0,8)}…${r.slice(-6)}`:nhe(r,22)}function ahe(e){const t=e?.trim();return t?t.replace(/^claude-/iu,"").replace(/^gpt-/iu,"gpt ").replace(/\s*\([^)]*\)\s*/u," ").replace(/\s+/g," ").trim():null}function ihe(e){const t=e?.trim();return t?t.replace(/\.local$/iu,"").replace(/-local$/iu,""):null}function ohe(e,t){e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),t())}function lhe(e,t){const n=e?.summary?.trim();if(!n)return null;const r=n.replace(/\s+/g," ");if(!r||r===t||/acknowledged via|queued for local execution|received the message/i.test(r))return null;const a=St(e?.updatedAt)??Date.now();return{line:Gg(r,120),at:a}}function che(e,t,n){const r=St(t?.startedAt)??St(t?.acknowledgedAt)??St(t?.updatedAt)??null,a=St(e.updatedAt),o=St(t?.startedAt)??St(e.createdAt),c=t?.task?.trim()||e.cwd||e.project||`Working in ${e.project??"workspace"}`,u=t?.status??"working",f=Ge(e.state)==="working",h=u==="completed"?"delivered":u==="failed"?"failed":u==="queued"?"queued":f?"working":"idle";return{agentId:e.id,agentName:e.name,agentHandle:e.handle,harness:t?.harness??e.harness,model:e.model,branch:e.branch??"main",cwd:e.cwd,task:{invocationId:t?.invocationId??null,title:c,summary:t?.summary??null,openedAt:r,status:u},execution:{state:h,lastEventAt:a,startedAt:o},checkpoint:lhe(t,c),reply:{state:u==="completed"?"delivered":"none",deliveredAt:St(t?.completedAt)}}}function uhe(e,t){if(e.reply.state==="delivered"){const r=e.reply.deliveredAt?Ko(e.reply.deliveredAt,t):null;return r?`delivered · ${r}`:"delivered"}if(e.execution.state==="queued")return"queued";if(e.execution.state==="failed")return"failed";const n=e.execution.lastEventAt?Ko(e.execution.lastEventAt,t):null;return e.execution.state==="idle"?n?`idle · ${n}`:"idle":n?`live · ${n}`:"live"}function dhe(e){const t=[];return e.hasAgentState&&t.push("agent state"),e.askCount>0&&t.push(`${e.askCount} ask${e.askCount===1?"":"s"}`),t.join(" + ")||"no recent signal"}function fhe(e){return e<5?"Still up":e<12?"Good morning":e<18?"Good afternoon":"Good evening"}function xm(e){return e.status==="fulfilled"?null:hhe(e.reason instanceof Error?e.reason.message:String(e.reason))}function hhe(e){return/failed to fetch|networkerror|load failed|couldn't connect|connection refused/i.test(e)?"Scout server is unreachable":e}function mhe(e){return e==="Scout server is unreachable"}function SR({navigate:e}){const{agents:t,onboarding:n,reload:r,route:a}=qe(),o=zs(a),c=m.useMemo(()=>cl(t,o),[t,o]),u=m.useMemo(()=>no(t,o),[t,o]),[f,h]=m.useState(null),[p,x]=m.useState(null),[v,y]=m.useState([]),[b,C]=m.useState("trailing 7d"),[E,A]=m.useState("3h buckets"),[S,k]=m.useState([]),[N,T]=m.useState([]),[R,O]=m.useState(!0),[L,I]=m.useState(!1),[z,_]=m.useState(null),[U,D]=m.useState(null),q=m.useRef(null),Z=m.useRef(0),$=m.useRef(0),G=m.useRef(null);m.useEffect(()=>{G.current=f},[f]);const V=m.useCallback(async(re=!1)=>(await ue(`/api/service-budgets${re?"?refresh=1":""}`)).gauges??[],[]),Y=m.useMemo(()=>ED(f,c),[f,c]),[K,P]=Rk(Hfe,kR),H=m.useMemo(()=>Si.find(re=>re.value===K)??Si[Si.length-1],[K]),B=m.useCallback(async(re="initial")=>{const Re=++Z.current;!(G.current!==null)&&re!=="background"?(O(!0),_(null)):I(!0);const Ct=new URLSearchParams({activityLookbackMs:String(H.value),activityLimit:String(H.activityLimit)}).toString(),[Ft,$n,tn,Lt]=await Promise.allSettled([ue(`/api/fleet?${Ct}`),ue("/api/operator-attention"),ue("/api/heartrate"),r()]);if(Re!==Z.current)return;Ft.status==="fulfilled"&&(G.current=Ft.value,h(Ft.value)),$n.status==="fulfilled"&&x($n.value),tn.status==="fulfilled"&&(y(tn.value.buckets),C(tn.value.windowLabel),A(tn.value.bucketLabel??""));const Et=[xm(Ft),xm($n),xm(tn),xm(Lt)].filter(Tt=>!!Tt);_(Et[0]??null),Et.length<4&&D(Date.now()),O(!1),I(!1)},[r,H]),Q=m.useCallback(()=>{q.current||(q.current=setTimeout(()=>{q.current=null,B("background")},250))},[B]);m.useEffect(()=>(B(),()=>{q.current&&clearTimeout(q.current)}),[B]),Vt(Q),m.useEffect(()=>{let re=!1;const Re=async()=>{try{const Ct=await V();re||T(Ct)}catch{}};Re();const Ve=setInterval(Re,Wfe);return()=>{re=!0,clearInterval(Ve)}},[V]);const oe=m.useCallback(async()=>{try{const re=new URLSearchParams({limit:String(Gfe),transcripts:"true"}),Re=await ue(`/api/tail/recent?${re.toString()}`);k(Re.events??[])}catch{}},[]);m.useEffect(()=>{oe();const re=setInterval(()=>{oe()},Zfe);return()=>clearInterval(re)},[oe]),m.useEffect(()=>{const re=setInterval(()=>{document.visibilityState==="visible"&&B("background")},15e3);return()=>clearInterval(re)},[B]),m.useEffect(()=>{const re=()=>{if(document.visibilityState!=="visible")return;const Re=Date.now();Re-$.current<1e3||($.current=Re,B("background"))};return window.addEventListener("focus",re),document.addEventListener("visibilitychange",re),()=>{window.removeEventListener("focus",re),document.removeEventListener("visibilitychange",re)}},[B]);const[ne,X]=m.useState(()=>Date.now()),[ae,be]=$5(qfe,"{}"),_e=m.useMemo(()=>the(ae),[ae]);m.useEffect(()=>{const re=setInterval(()=>X(Date.now()),1e3);return()=>clearInterval(re)},[]);const xe=m.useMemo(()=>u.filter(re=>Ge(re.state)==="ready"),[u]),pe=m.useMemo(()=>[...Y?.activeAsks??[],...Y?.recentCompleted??[]].filter(re=>re.status==="needs_attention"||re.status==="failed"),[Y]),te=m.useMemo(()=>(Y?.activeAsks??[]).filter(re=>re.status==="queued"||re.status==="working"),[Y]),ve=m.useMemo(()=>te.filter(re=>xb(re.updatedAt,ne)),[te,ne]),he=m.useMemo(()=>Y?.needsAttention??[],[Y]),ke=m.useMemo(()=>{const re=new Map;for(const Re of ve){const Ve=re.get(Re.agentId),Ct=St(Re.updatedAt)??0,Ft=St(Ve?.updatedAt)??0;(!Ve||Ct>Ft)&&re.set(Re.agentId,Re)}return re},[ve]),Ne=m.useMemo(()=>u.filter(re=>Ge(re.state)==="working"&&(xb(re.updatedAt,ne)||ke.has(re.id))),[ke,u,ne]),Fe=m.useMemo(()=>new Set(Ne.map(re=>re.id)),[Ne]),Ee=m.useMemo(()=>Ne.map(re=>re.id).sort().join(","),[Ne]),[Le,Te]=m.useState({});m.useEffect(()=>{if(!Ee){Te({});return}let re=!1;const Re=async()=>{const Ct=await ue(`/api/observe/agents?ids=${encodeURIComponent(Ee)}`).catch(()=>null);if(re||!Ct)return;const Ft={};for(const $n of Ct){const tn=$n?.data?.metadata?.session,Lt=$n?.data?.metadata?.usage,Et=Lt?.totalTokens,Tt=Lt?.contextWindowTokens,Jn=typeof Et=="number"&&typeof Tt=="number"&&Tt>0?Math.min(100,Math.round(Et/Tt*100)):null;Ft[$n.agentId]={sessionId:tn?.externalSessionId??null,model:tn?.model??null,contextPct:Jn}}Te(Ft)};Re();const Ve=setInterval(Re,15e3);return()=>{re=!0,clearInterval(Ve)}},[Ee]);const Pe=m.useMemo(()=>u.filter(re=>Ge(re.state)==="working"&&!Fe.has(re.id)),[Fe,u]),De=m.useMemo(()=>te.filter(re=>!xb(re.updatedAt,ne)),[te,ne]),ze=m.useMemo(()=>{const re=new Map,Re=Ve=>{const Ct=re.get(Ve.agentId);if(!Ct){re.set(Ve.agentId,Ve);return}const Ft=Ve.updatedAtMs>=Ct.updatedAtMs;re.set(Ve.agentId,{agentId:Ve.agentId,agentName:Ct.agentName||Ve.agentName,updatedAtMs:Math.max(Ct.updatedAtMs,Ve.updatedAtMs),summary:Ft?Ve.summary:Ct.summary,route:Ft?Ve.route:Ct.route,hasAgentState:Ct.hasAgentState||Ve.hasAgentState,askCount:Ct.askCount+Ve.askCount})};for(const Ve of Pe)Re({agentId:Ve.id,agentName:Ve.name,updatedAtMs:St(Ve.updatedAt)??0,summary:Ve.cwd??Ve.projectRoot??Ve.project??Ve.branch??"Registered as working",route:{view:"agents",agentId:Ve.id,tab:"profile"},hasAgentState:!0,askCount:0});for(const Ve of De)Re({agentId:Ve.agentId,agentName:Ve.agentName??Ve.agentId,updatedAtMs:St(Ve.updatedAt)??0,summary:Ve.summary??Ve.task??Ve.statusLabel,route:z5(Ve),hasAgentState:!1,askCount:1});return[...re.values()].sort((Ve,Ct)=>Ct.updatedAtMs-Ve.updatedAtMs)},[De,Pe]),$e=m.useMemo(()=>ze.filter(re=>(_e[re.agentId]??-1)<re.updatedAtMs),[_e,ze]),st=m.useMemo(()=>ve.filter(re=>!Ne.some(Re=>Re.id===re.agentId)),[Ne,ve]),rt=pe.length+he.length,Xe=m.useMemo(()=>c?(p?.items??[]).filter(re=>re.agentId&&c.has(re.agentId)):p?.items??[],[p?.items,c]),dt=o?rt+Xe.length:p?.totals.all??rt,jt=m.useMemo(()=>{const re=[...pe.map(Re=>Re.updatedAt),...he.map(Re=>Re.updatedAt),...Xe.map(Re=>Re.updatedAt)].map(St).filter(Re=>Re!==null);return re.length>0?Math.min(...re):null},[Xe,pe,he]),At=ne-K,mt=m.useMemo(()=>(Y?.activity??[]).filter(Re=>(St(Re.ts)??0)>=At),[Y?.activity,At]),Ht=m.useMemo(()=>Qfe(mt,K,ne),[mt,K,ne]),ie=mt.length>=H.activityLimit,ce=m.useMemo(()=>{const re=Si.findIndex(Re=>Re.value===K);return re>=0&&re<Si.length-1?Si[re+1]:null},[K]),Ae=new Date,Be=fhe(Ae.getHours()),tt=la("ops.control",!0),at=n?.operatorName?.trim()||n?.operatorNameSuggestion?.trim()||"operator",Oe=m.useMemo(()=>ehe(v,S,ne),[v,S,ne]),He=m.useMemo(()=>{const Re=ne-6e5,Ve=Y?.activity??[],Ct=new Set(u.map(Lt=>Lt.name.toLowerCase())),Ft=new Set(u.map(Lt=>Lt.id)),$n=new Set(["agent_message","status_message","ask_opened","ask_working","ask_failed","handoff_sent","collaboration_event"]),tn=new Map;for(const Lt of Ve){const Et=St(Lt.ts);if(Et===null||Et<Re||!$n.has(Lt.kind))continue;const Tt=Lt.actorName?.trim();if(!Tt||Tt.toLowerCase()===at.toLowerCase()||Ct.has(Tt.toLowerCase())||Lt.agentId&&Ft.has(Lt.agentId))continue;const Jn=Tt.toLowerCase(),sr=tn.get(Jn),ga=St(sr?.ts)??0;(!sr||Et>ga)&&tn.set(Jn,Lt)}return[...tn.values()].sort((Lt,Et)=>ul(Lt.ts,Et.ts))},[Y?.activity,ne,u,at]),ot=m.useCallback(re=>{be(NR({..._e,[re.agentId]:re.updatedAtMs}))},[be,_e]),nt=m.useCallback(()=>{const re={..._e};for(const Re of $e)re[Re.agentId]=Re.updatedAtMs;be(NR(re))},[be,_e,$e]),$t=m.useMemo(()=>{const re=[];return Ne.length>0&&re.push(`${Ne.length} agent${Ne.length===1?" is":"s are"} working now`),xe.length>0&&re.push(`${xe.length} agent${xe.length===1?" is":"s are"} ready`),dt>0&&re.push(`${dt} thing${dt===1?"":"s"} need${dt===1?"s":""} you`),re.length===0&&u.length>0&&re.push(`${u.length} agent${u.length===1?" is":"s are"} registered`),re.length===0&&re.push("no agents are connected yet"),re},[Ne,xe,dt,u]),Tn=R?"syncing":z?`${mhe(z)?"offline":"sync issue"} · ${U?Ie(U):"waiting"}`:U?`updated ${Ie(U)}`:"waiting",fn=m.useCallback(()=>{B("manual"),V(!0).then(re=>T(re)).catch(()=>{})},[V,B]),Gt={now:Ae,greeting:Be,operatorName:at,syncLabel:Tn,error:z,loading:R,refreshing:L,onRefresh:fn,totalOperatorQueue:dt,narrativeParts:$t,navigate:e,opsEnabled:tt,onReviewQueue:()=>{document.getElementById("home-needs-you")?.scrollIntoView({behavior:"smooth",block:"start"})},heartrate:Oe,heartrateWindow:b,heartrateBucketLabel:E,heartrateVisibleEventThreshold:Yfe,serviceGauges:N},Rt=!R&&!z&&mt.length===0&&K>=kR,Gn=!R&&!z&&mt.length===0,On=R||mt.length>0||!!z||!Rt;return s.jsx("div",{className:"s-fleet-home",children:s.jsxs("div",{className:"s-fleet-home-inner",children:[s.jsx(hfe,{...Gt}),(Ne.length>0||He.length>0||st.length>0)&&s.jsxs("div",{className:"s-fleet-section",children:[s.jsx(ym,{label:`What's moving · ${Ne.length+He.length+st.length}`,right:s.jsx("button",{className:"s-link-btn",onClick:()=>e({view:"mesh"}),children:"open mesh ↗"})}),(Ne.length>0||He.length>0)&&s.jsxs("div",{className:"s-now-grid",style:{gridTemplateColumns:`repeat(${Math.min(Ne.length+He.length,3)}, 1fr)`},children:[Ne.map(re=>s.jsx(jhe,{agent:re,ask:ke.get(re.id)??null,context:Le[re.id]??null,nowMs:ne,navigate:e},re.id)),He.map(re=>s.jsx(Nhe,{actor:re,nowMs:ne,navigate:e},re.id))]}),st.length>0&&s.jsx("div",{className:"s-moving-ask-list",children:st.map(re=>s.jsx(Che,{ask:re,navigate:e},re.invocationId))})]}),$e.length>0&&s.jsxs("div",{className:"s-fleet-section",id:"home-no-recent-signal",children:[s.jsx(ym,{label:`No recent signal · ${$e.length}`,right:s.jsx("button",{type:"button",className:"s-link-btn",onClick:nt,children:"mark all inactive"})}),s.jsx("div",{className:"s-no-recent-signal-list",children:$e.map(re=>s.jsx(Ehe,{item:re,navigate:e,onMarkInactive:()=>ot(re)},re.agentId))})]}),On&&s.jsxs("div",{className:"s-fleet-section",children:[s.jsx(ym,{label:`Live activity · ${mt.length}${ie?"+":""}`,right:s.jsx(Ahe,{value:K,onChange:P,refreshing:L&&!R})}),Ht&&s.jsxs("div",{className:"s-fleet-live-shape",children:[s.jsxs("span",{children:["last ",pw(Ht.lastAgoMs)," ago"]}),s.jsx("span",{children:"·"}),s.jsxs("span",{children:["longest gap ",pw(Ht.longestGapMs)]}),ie&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsxs("span",{style:{color:"var(--amber)"},children:["showing ",Math.min(mt.length,30)," of ",H.activityLimit,"+ (capped)"]})]}),!ie&&mt.length>30&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsxs("span",{children:["showing 30 of ",mt.length]})]})]}),R&&mt.length===0?s.jsx(The,{}):mt.length===0?s.jsx(Mhe,{lookbackMs:K,nextOption:ce,onWiden:re=>P(re.value),loadedAt:U,nowMs:ne,error:z,onRetry:()=>{B("manual")}}):s.jsx("div",{className:"s-mc-stream s-fleet-live-stream",children:mt.slice(0,30).map(re=>s.jsx($he,{item:re,nowMs:ne,onOpen:()=>{const Re=Xfe(re);Re&&e(Re)}},re.id))})]}),Gn&&s.jsx("div",{className:"s-fleet-section s-fleet-section--quiet-start",children:s.jsx(Ohe,{agents:u,navigate:e})}),dt>0&&s.jsxs("div",{className:"s-fleet-section",id:"home-needs-you",children:[s.jsx(ym,{label:`Network signals · ${dt}`,right:jt!==null?s.jsxs("span",{style:{color:"var(--amber)"},children:["oldest ",Ie(jt)]}):null}),Xe.length>0?s.jsx(phe,{items:Xe,navigate:e,onResolved:re=>x(re)}):pe.length>0&&s.jsx("div",{className:"s-ask-grid",children:pe.slice(0,4).map(re=>s.jsx(bhe,{ask:re,agents:u,navigate:e,operatorName:at,pending:!0},re.invocationId))}),Xe.length===0&&he.length>0&&s.jsx("div",{className:"s-attention-list",children:he.map(re=>s.jsx(whe,{item:re,navigate:e},re.recordId))})]})]})})}function ym({label:e,right:t}){return s.jsxs("div",{className:"s-section-rule",children:[s.jsx("span",{className:"s-eyebrow",children:e}),s.jsx("span",{className:"s-section-rule-line"}),t&&s.jsx("span",{className:"s-section-rule-right",children:t})]})}function phe({items:e,navigate:t,onResolved:n}){return s.jsxs("div",{className:"s-operator-queue",children:[s.jsxs("div",{className:"s-operator-queue-head",children:[s.jsxs("div",{children:[s.jsx("div",{className:"s-operator-queue-title",children:"Operator queue"}),s.jsx("div",{className:"s-operator-queue-subtitle",children:"Permissions, questions, and setup blockers in one place."})]}),s.jsx("div",{className:"s-operator-queue-count",children:e.length})]}),s.jsx("div",{className:"s-operator-queue-list",children:e.map(r=>s.jsx(yhe,{item:r,navigate:t,onResolved:n},r.id))})]})}function ghe(e){switch(e){case"critical":return"blocked";case"warning":return"needs input";default:return"review"}}function vhe(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.agentId?{view:"agents",agentId:e.agentId}:null}function xhe(e){const t=e.actions.filter(r=>(r.kind==="open"||r.kind==="configure")&&!!r.route);if(t.length>0)return t;const n=vhe(e);return n?[{kind:"open",label:"Open",route:n}]:[]}function yhe({item:e,navigate:t,onResolved:n}){const[r,a]=m.useState(null),[o,c]=m.useState(!1),[u,f]=m.useState(null),h=e.actions.find(A=>A.kind==="copy"&&A.value),p=e.actions.find(A=>A.kind==="approve"),x=e.actions.find(A=>A.kind==="deny"),v=e.actions.find(A=>A.kind==="dismiss"),y=xhe(e),b=async A=>{if(e.approval){a(A),f(null);try{const S=await ue("/api/operator-attention/approvals/decide",{method:"POST",body:JSON.stringify({sessionId:e.approval.sessionId,turnId:e.approval.turnId,blockId:e.approval.blockId,version:e.approval.version,decision:A})});n(S)}catch(S){f(S instanceof Error?S.message:String(S))}finally{a(null)}}},C=()=>{h?.value&&navigator.clipboard.writeText(h.value).then(()=>{c(!0),window.setTimeout(()=>c(!1),1400)})},E=async()=>{if(!v?.unblockRequestId&&!v?.flightId&&(!v?.recordKind||!v.recordId)){f("This queue item cannot be dismissed from here yet.");return}a("dismiss"),f(null);try{if(v.unblockRequestId)await ip({unblockRequestId:v.unblockRequestId,itemUpdatedAt:e.updatedAt});else if(v.flightId)await ip({flightId:v.flightId,itemUpdatedAt:e.updatedAt});else{const S=v.recordKind,k=v.recordId;if(!S||!k)throw new Error("This queue item cannot be dismissed from here yet.");await ip({recordKind:S,recordId:k,itemUpdatedAt:e.updatedAt})}const A=await ue("/api/operator-attention");n(A)}catch(A){f(A instanceof Error?A.message:String(A))}finally{a(null)}};return s.jsxs("div",{className:`s-operator-card s-operator-card--${e.severity}`,children:[s.jsxs("div",{className:"s-operator-card-main",children:[s.jsxs("div",{className:"s-operator-card-top",children:[s.jsx("span",{className:"s-eyebrow",children:e.sourceLabel}),s.jsx("span",{className:"s-operator-card-severity",children:ghe(e.severity)}),s.jsx("span",{className:"s-operator-card-age",children:Ie(e.updatedAt)})]}),s.jsx("div",{className:"s-operator-card-title",children:e.title}),e.summary&&s.jsx("div",{className:"s-operator-card-summary",children:e.summary}),e.detail&&s.jsx("div",{className:"s-operator-card-detail",children:e.detail}),e.agentName&&s.jsx("div",{className:"s-operator-card-meta",children:e.agentName}),u&&s.jsx("div",{className:"s-operator-card-error",children:u})]}),s.jsxs("div",{className:"s-operator-card-actions",children:[p&&s.jsxs("button",{type:"button",className:"s-icon-btn s-icon-btn--primary",disabled:!!r,title:"Approve",onClick:()=>{b("approve")},children:[s.jsx(fg,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:r==="approve"?"Approving":p.label})]}),x&&s.jsxs("button",{type:"button",className:"s-icon-btn",disabled:!!r,title:"Deny",onClick:()=>{b("deny")},children:[s.jsx(Bi,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:r==="deny"?"Denying":x.label})]}),h&&s.jsxs("button",{type:"button",className:"s-icon-btn",title:h.label,onClick:C,children:[s.jsx(mg,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:o?"Copied":h.label})]}),y.map((A,S)=>s.jsxs("button",{type:"button",className:"s-icon-btn",title:A.label,onClick:()=>t(A.route),children:[A.kind==="configure"?s.jsx(gg,{size:14,"aria-hidden":"true"}):s.jsx(wr,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:A.label})]},`${A.kind}:${A.label}:${S}`)),v&&s.jsxs("button",{type:"button",className:"s-icon-btn",disabled:!!r,title:"Dismiss from queue",onClick:()=>{E()},children:[s.jsx(Bi,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:r==="dismiss"?"Dismissing":v.label})]})]})]})}function bhe({ask:e,agents:t,navigate:n,operatorName:r,pending:a}){const c=t.find(f=>f.id===e.agentId)?.name??e.agentName??e.agentId,u=e.conversationId?{view:"conversation",conversationId:e.conversationId}:{view:"agents",agentId:e.agentId};return s.jsxs("div",{className:`s-ask-block${a?" s-ask-block--pending":""}`,style:{cursor:"pointer"},onClick:()=>n(u),children:[s.jsxs("div",{className:"s-ask-header",children:[s.jsx("span",{className:"s-eyebrow s-ask-label",children:a?"◌ ASK — ATTENTION":"● ASK"}),s.jsx("span",{style:{flex:1}}),s.jsx("span",{className:"s-eyebrow",children:Ie(e.updatedAt)})]}),s.jsxs("div",{className:"s-ask-body",children:[s.jsx("div",{className:"s-avatar s-avatar-sm",style:{background:Xt(c)},children:c[0]?.toUpperCase()??"?"}),s.jsxs("div",{className:"s-ask-body-copy",children:[s.jsxs("div",{className:"s-ask-route",children:[s.jsx("span",{className:"s-ask-route-name",children:c}),s.jsx("span",{children:" → "}),s.jsx("span",{style:{color:"var(--accent)"},children:r})]}),s.jsxs("div",{className:"s-ask-text",children:['"',e.summary??e.task,'"']})]})]}),a&&s.jsxs("div",{className:"s-ask-actions",children:[s.jsx("button",{className:"s-btn-fleet s-btn-fleet--primary",children:"Answer"}),s.jsx("button",{className:"s-btn-fleet",children:"Defer"}),s.jsx("button",{className:"s-btn-fleet",children:"Route…"}),s.jsx("span",{className:"s-ask-thinking",children:s.jsx("span",{className:"s-thinking-strip"})})]})]})}function whe({item:e,navigate:t}){const n=e.kind==="work_item"&&e.recordId?{view:"work",workId:e.recordId}:e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.agentId?{view:"agents",agentId:e.agentId}:null,r=e.kind==="question"?"question":e.state.replace(/_/g," "),a=e.acceptanceState!=="none"?e.kind==="question"?e.acceptanceState.replace(/_/g," "):"agent-owned":e.kind==="question"?"awaiting answer":"surfaced",o=e.kind==="question"?"answer":e.state==="review"?"view plan":e.acceptanceState==="pending"?"view signal":"open work";return s.jsxs("div",{className:`s-attention-row${n?" s-attention-row--clickable":""}`,onClick:n?()=>t(n):void 0,children:[s.jsx("div",{className:"s-attention-row-title",children:e.title}),s.jsxs("div",{className:"s-attention-row-meta",children:[s.jsx("span",{className:"s-eyebrow",children:e.kind==="work_item"?"WORK ITEM":"QUESTION"}),e.agentName&&s.jsx("span",{children:e.agentName}),s.jsx("span",{children:r}),s.jsx("span",{style:{color:"var(--amber)"},children:a}),s.jsx("span",{style:{marginLeft:"auto"},children:Ie(e.updatedAt)}),n&&s.jsxs("span",{className:"s-attention-row-action",children:[o," ↗"]})]}),e.summary&&s.jsx("p",{className:"s-attention-row-summary",children:e.summary})]})}function jhe({agent:e,ask:t,context:n,nowMs:r,navigate:a}){const o=che(e,t),c=e.projectRoot??e.cwd??void 0,u=she(c)??"no workspace",f=o.branch??"no branch",h=o.harness??null,p=ahe(n?.model??o.model),x=rhe(n?.sessionId??e.harnessSessionId),v=n?.contextPct??null,y=ihe(e.homeNodeName??e.nodeQualifier),b=e.createdAt?Ko(e.createdAt,r):null,C=o.task.openedAt?Ko(o.task.openedAt,r):"new";uhe(o,r);const E=o.execution.state==="failed"?"failed":o.reply.state==="delivered"?"delivered":o.execution.state==="queued"?"queued":o.execution.state==="idle"?"idle":"live",A=o.reply.state==="delivered"&&o.reply.deliveredAt?`reply ready · ${Ko(o.reply.deliveredAt,r)}`:o.checkpoint?.line??null,S=[{key:"root",text:u,title:c,mono:!0},{key:"branch",text:f,title:f,mono:!0}];h&&S.push({key:"runtime",text:h}),e.role&&S.push({key:"role",text:e.role}),p&&S.push({key:"model",text:p});const k=[{key:"turn",label:"turn",value:C,tone:o.task.openedAt?"work":"dim"}];v!==null?k.push({key:"context",label:"context",value:`${v}%`,tone:v>=80?"warn":"work"}):b&&k.push({key:"uptime",label:"up",value:b}),x&&k.push({key:"session",label:"session",value:x}),y&&k.push({key:"machine",label:"machine",value:y});const N=()=>a({view:"agents",agentId:e.id,conversationId:Qn(e.id),tab:"observe"});return s.jsxs("div",{role:"button",tabIndex:0,className:`s-now-card s-now-card--${E}`,onClick:N,onKeyDown:T=>ohe(T,N),children:[s.jsxs("div",{className:"s-now-card-top",children:[s.jsx("span",{className:`s-now-card-pulse s-now-card-pulse--${E}`,"aria-hidden":"true"}),s.jsx("span",{className:"s-now-card-name",title:o.agentName,children:o.agentName})]}),s.jsx("div",{className:"s-now-card-idline",children:S.map((T,R)=>s.jsxs("span",{className:"s-now-card-idgroup",children:[R>0&&s.jsx("span",{className:"s-now-card-idsep","aria-hidden":"true",children:"·"}),s.jsx("span",{className:`s-now-card-idpart${T.mono?" s-now-card-idpart--mono":""}`,title:T.title,children:T.text})]},T.key))}),s.jsx("div",{className:"s-now-card-task",children:o.task.title}),A&&s.jsxs("div",{className:"s-now-card-checkpoint",children:[s.jsx("span",{"aria-hidden":"true",children:"↳"}),s.jsx("span",{children:A})]}),s.jsx("div",{className:"s-now-card-metrics",style:{gridTemplateColumns:`repeat(${k.length}, minmax(0, 1fr))`},"aria-label":`${o.agentName} signals`,children:k.map(T=>s.jsx(khe,{label:T.label,value:T.value,tone:T.tone},T.key))})]})}function khe({label:e,value:t,tone:n="dim"}){return s.jsxs("span",{className:`s-metric-tile s-metric-tile--${n}`,children:[s.jsx("strong",{children:t}),s.jsx("span",{children:e})]})}function Nhe({actor:e,nowMs:t,navigate:n}){const r=e.actorName??"—",a=r[0]?.toUpperCase()??"?",o=P5(e.kind),c=Gg(e.title??e.summary,140),u=e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.recordId?{view:"work",workId:e.recordId}:e.agentId?{view:"agents",agentId:e.agentId}:null,f=She(r);return s.jsxs("div",{className:"s-now-card s-now-card--observed",style:{cursor:u?"pointer":"default"},onClick:()=>{u&&n(u)},children:[s.jsxs("div",{className:"s-now-card-head",children:[s.jsx("div",{className:"s-avatar s-avatar-sm",style:{background:Xt(r)},children:a}),s.jsxs("div",{className:"s-now-card-copy",children:[s.jsx("div",{className:"s-now-card-name",children:r}),s.jsxs("div",{className:"s-now-card-meta",children:["observed",f?` · ${f}`:""," · ",o]})]}),s.jsxs("span",{className:"s-now-card-live s-now-card-live--observed",children:[s.jsx("span",{className:"s-now-card-live-dot","aria-hidden":"true"}),"live"]})]}),s.jsx("div",{className:"s-now-card-task",children:c||"(no recent text)"}),s.jsxs("div",{className:"s-now-card-ticker",children:[s.jsx("span",{className:"s-now-card-ticker-prompt",children:"›"}),s.jsx("span",{className:"s-now-card-ticker-text",children:e.kind.replace(/[._]/g," ")}),s.jsxs("span",{className:"s-now-card-ticker-dots","aria-hidden":"true",children:[s.jsx("span",{}),s.jsx("span",{}),s.jsx("span",{})]})]}),s.jsxs("div",{className:"s-now-card-footer",children:[s.jsxs("span",{children:["updated ",Ko(e.ts,t)]}),s.jsx("span",{children:"unmanaged"})]})]})}function She(e){const t=e.toLowerCase();return t.includes("claude")?"claude":t.includes("codex")?"codex":t.includes("gemini")?"gemini":t.includes("hudson")?"hudson":null}function Che({ask:e,navigate:t}){const n=z5(e);return s.jsxs("button",{className:"s-moving-ask-row",onClick:()=>t(n),children:[s.jsx("span",{className:"s-moving-ask-agent",children:e.agentName??e.agentId}),s.jsx("span",{className:"s-moving-ask-title",children:e.summary??e.task}),s.jsx("span",{className:"s-moving-ask-state",children:e.statusLabel}),s.jsx("span",{className:"s-moving-ask-time",children:Ie(e.updatedAt)})]})}function Ehe({item:e,navigate:t,onMarkInactive:n}){const r=e.updatedAtMs>0?Ie(e.updatedAtMs):"unknown",a=dhe(e),o=Gg(e.summary,180);return s.jsxs("div",{className:"s-no-recent-signal-row",children:[s.jsxs("button",{type:"button",className:"s-no-recent-signal-main",onClick:()=>t(e.route),children:[s.jsx("span",{className:"s-avatar s-avatar-sm",style:{background:Xt(e.agentName)},children:e.agentName[0]?.toUpperCase()??"?"}),s.jsxs("span",{className:"s-no-recent-signal-copy",children:[s.jsx("span",{className:"s-no-recent-signal-name",children:e.agentName}),s.jsxs("span",{className:"s-no-recent-signal-meta",children:[s.jsxs("span",{children:["last signal ",r]}),s.jsx("span",{children:a}),s.jsxs("span",{children:["hidden after ",D5(L5)," idle"]})]}),o&&s.jsx("span",{className:"s-no-recent-signal-summary",children:o})]})]}),s.jsxs("div",{className:"s-no-recent-signal-actions",children:[s.jsxs("button",{type:"button",className:"s-icon-btn",title:"Open source",onClick:()=>t(e.route),children:[s.jsx(wr,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:"Open"})]}),s.jsxs("button",{type:"button",className:"s-icon-btn",title:"Mark inactive",onClick:n,children:[s.jsx(fg,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:"Mark inactive"})]})]})]})}function Ahe({value:e,onChange:t,refreshing:n}){return s.jsxs("div",{className:"s-mc-window",role:"group","aria-label":"Lookback window",children:[s.jsxs("span",{className:"s-mc-window-label",children:["Lookback",n&&s.jsx("span",{className:"s-mc-window-refreshing","aria-label":"refreshing"})]}),s.jsx("div",{className:"s-mc-window-tabs",children:Si.map(r=>s.jsx("button",{type:"button",className:`s-mc-window-tab${r.value===e?" is-active":""}`,onClick:()=>t(r.value),children:r.label},r.value))})]})}function The(){return s.jsx("div",{className:"s-mc-stream s-fleet-live-stream s-fleet-live-stream--skeleton","aria-hidden":"true",children:[0,1,2,3,4].map(e=>s.jsxs("div",{className:"s-fleet-live-skeleton-row",children:[s.jsx("span",{className:"s-fleet-live-skeleton-time"}),s.jsx("span",{className:"s-fleet-live-skeleton-actor"}),s.jsx("span",{className:"s-fleet-live-skeleton-text"})]},e))})}function Mhe({lookbackMs:e,nextOption:t,onWiden:n,loadedAt:r,nowMs:a,error:o,onRetry:c}){if(o)return s.jsxs("div",{className:"s-mc-empty s-fleet-live-empty",children:[s.jsx("div",{className:"s-fleet-live-empty-title",children:"Couldn’t load activity."}),s.jsx("div",{className:"s-fleet-live-empty-detail",children:o}),s.jsx("div",{className:"s-fleet-live-empty-actions",children:s.jsx("button",{type:"button",className:"s-link-btn",onClick:c,children:"Try again"})})]});const u=r?`Polled ${pw(Math.max(0,a-r))} ago.`:"Polling…";return s.jsxs("div",{className:"s-mc-empty s-fleet-live-empty",children:[s.jsxs("div",{className:"s-fleet-live-empty-title",children:["Quiet — no activity in the last ",D5(e),"."]}),s.jsx("div",{className:"s-fleet-live-empty-detail",children:u}),t&&s.jsx("div",{className:"s-fleet-live-empty-actions",children:s.jsxs("button",{type:"button",className:"s-link-btn",onClick:()=>n(t),children:["Widen to ",t.label," →"]})})]})}function Rhe(e){return[...e].sort((t,n)=>{const r=Ge(t.state),a=Ge(n.state);return(r==="ready"?0:r==="working"?1:2)-(a==="ready"?0:a==="working"?1:2)||t.name.localeCompare(n.name)})}function Ihe(e){const t=new Set,n=e?.harness?.trim();return n&&t.add(n),t.add("claude"),t.add("codex"),t.add("pi"),[...t]}function _he(e){const t=new Set,n=e?.model?.trim();return n&&t.add(n),[...t]}function Ohe({agents:e,navigate:t}){const n=m.useMemo(()=>Rhe(e),[e]),[r,a]=m.useState(()=>n[0]?.id??""),o=n.find(k=>k.id===r)??null,c=m.useMemo(()=>Ihe(o),[o]),u=m.useMemo(()=>_he(o),[o]),[f,h]=m.useState(""),[p,x]=m.useState(o?.harness?.trim()??""),[v,y]=m.useState(o?.model?.trim()??""),[b,C]=m.useState(!1),[E,A]=m.useState(null);m.useEffect(()=>{n.some(k=>k.id===r)||a(n[0]?.id??"")},[r,n]),m.useEffect(()=>{x(o?.harness?.trim()??""),y(o?.model?.trim()??"")},[o?.id]);const S=async k=>{k.preventDefault();const N=f.trim();if(!(!o||!N)){C(!0),A(null);try{const T=await ue("/api/ask",{method:"POST",body:JSON.stringify({body:N,targetAgentId:o.id,targetLabel:o.name,execution:{harness:p||void 0,model:v||void 0}})});t({view:"conversation",conversationId:T.conversationId??o.conversationId??Qn(o.id)})}catch(T){A(T instanceof Error?T.message:String(T))}finally{C(!1)}}};return s.jsxs("div",{className:"s-quiet-start",children:[s.jsxs("div",{className:"s-quiet-panel s-quiet-panel--tail",children:[s.jsxs("div",{className:"s-quiet-panel-head",children:[s.jsx("span",{className:"s-eyebrow",children:"Local tail"}),s.jsxs("button",{type:"button",className:"s-icon-btn",title:"Open tail",onClick:()=>t({view:"ops",mode:"tail"}),children:[s.jsx(wr,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:"Open tail"})]})]}),s.jsx("div",{className:"s-quiet-tail-frame",children:s.jsx(Qp,{navigate:t,chrome:"embedded"})})]}),s.jsxs("form",{className:"s-quiet-panel s-quiet-panel--ask",onSubmit:S,children:[s.jsxs("div",{className:"s-quiet-panel-head",children:[s.jsx("span",{className:"s-eyebrow",children:"Ask"}),s.jsxs("button",{type:"submit",className:"s-icon-btn s-icon-btn--primary",title:"Ask selected agent",disabled:b||!o||!f.trim(),children:[s.jsx(JB,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:b?"Asking":"Ask"})]})]}),s.jsxs("div",{className:"s-quiet-target-row",children:[s.jsx("label",{className:"s-quiet-label",htmlFor:"home-catchup-agent",children:"To"}),s.jsx("select",{id:"home-catchup-agent",className:"s-quiet-select s-quiet-select--target",value:r,onChange:k=>a(k.target.value),disabled:n.length===0||b,children:n.length===0?s.jsx("option",{value:"",children:"No registered agents"}):n.map(k=>s.jsx("option",{value:k.id,children:k.name},k.id))})]}),s.jsx("textarea",{className:"s-quiet-textarea",value:f,onChange:k=>h(k.target.value),placeholder:"Type a message...","aria-label":"Message",rows:4,disabled:b||!o}),s.jsxs("div",{className:"s-quiet-controls",children:[s.jsxs("select",{className:"s-quiet-select",value:p,onChange:k=>x(k.target.value),disabled:b||!o,"aria-label":"Harness",children:[s.jsx("option",{value:"",children:"default harness"}),c.map(k=>s.jsx("option",{value:k,children:k},k))]}),s.jsxs("select",{className:"s-quiet-select",value:v,onChange:k=>y(k.target.value),disabled:b||!o,"aria-label":"Model",children:[s.jsx("option",{value:"",children:"default model"}),u.map(k=>s.jsx("option",{value:k,children:k},k))]})]}),E&&s.jsx("div",{className:"s-quiet-error",children:E})]})]})}function $he({item:e,nowMs:t,onOpen:n}){const r=e.actorName??"—",a=P5(e.kind),o=Gg(e.title??e.summary,110);return s.jsxs("button",{type:"button",className:"s-mc-stream-row",onClick:n,children:[s.jsx("span",{className:"s-mc-stream-time",children:Ko(e.ts,t)}),s.jsx("span",{className:"s-mc-stream-actor",children:r}),s.jsx("span",{className:"s-mc-stream-verb",children:a}),s.jsx("span",{className:"s-mc-stream-text",children:o})]})}function Lhe({activeRoute:e,navigate:t}){return s.jsx(Kg,{ariaLabel:"Search sections",activeRoute:e,groups:Pce,navigate:t})}function Ri(e){return e.root==="HOME"?`~/${e.relPath}`:e.root==="ABSOLUTE"?e.relPath:`$${e.root}/${e.relPath}`}function CR(e){const t=e?.trim();if(!t)return null;const n=t.replace(/[\\/]+$/,""),r=n.split(/[\\/]/).filter(Boolean).at(-1)??n;return r.endsWith(".jsonl")?r.slice(0,-6):r}function B5(e){return e.sourceRefs.find(t=>t.kind==="harness_transcript")??null}function U5(e){return e.sourceRefs.find(t=>t.kind==="file")??null}function Ik(e){return e?CR(e.sessionId)??CR(Ri(e.path)):null}function F5(e){const t=Ik(e);if(!t)return null;const n=e?.recordRange;return n?`${t}|records ${n[0]}..${n[1]}`:t}function Va(e,t){const n=e.facets[t];return Array.isArray(n)?n.filter(Boolean).join(", "):typeof n=="string"?n:""}function Mf(e){const t=new Set;return e.split(/[^A-Za-z0-9_./-]+/u).map(n=>n.trim()).filter(n=>n.length>1).filter(n=>{const r=n.toLowerCase();return t.has(r)?!1:(t.add(r),!0)}).slice(0,12)}function Phe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function V5(e,t){const n=Mf(t);if(n.length===0||e.length===0)return[{text:e,match:!1}];const r=new RegExp(`(${n.map(Phe).join("|")})`,"giu"),a=[];let o=0;for(const c of e.matchAll(r)){const u=c.index??0;u>o&&a.push({text:e.slice(o,u),match:!1}),a.push({text:c[0],match:!0}),o=u+c[0].length}return o<e.length&&a.push({text:e.slice(o),match:!1}),a.length>0?a:[{text:e,match:!1}]}const Dhe=["QMD","embeddings","search surface","raw log drilldown","MCP","context pack","API"];function $o(e){return new Intl.NumberFormat("en-US").format(e||0)}function zhe(e){if(!Number.isFinite(e)||e<=0)return"0 B";const t=["B","KB","MB","GB"];let n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n>=10||r===0?n.toFixed(0):n.toFixed(1)} ${t[r]}`}function Bhe(){const[e,t]=m.useState(null),[n,r]=m.useState(null),a=async()=>{try{r(null),t(await ue("/api/knowledge/status"))}catch(o){r(o instanceof Error?o.message:String(o))}};return m.useEffect(()=>{a()},[]),{status:e,setStatus:t,error:n,setError:r,refresh:a}}function Uhe({text:e,query:t}){return s.jsx(s.Fragment,{children:V5(e,t).map((n,r)=>n.match?s.jsx("mark",{children:n.text},r):s.jsx("span",{children:n.text},r))})}function gw(e){const t=e.replace(/\\/g,"/");if(!t.includes("/"))return t;const n=t.split("/").filter(Boolean),r=n.at(-1)??t;return t.startsWith("~/")?`~/.../${r}`:t.startsWith("/")?`/.../${r}`:n.length>2?`${n[0]}/.../${r}`:t}function Fhe(e,t){const n=e.title.toLowerCase(),r=e.snippet.toLowerCase();return Mf(t).filter(a=>{const o=a.toLowerCase();return n.includes(o)||r.includes(o)})}function Vhe(e,t){const n=Fhe(e,t);return n.length===1?`Matched "${n[0]}" in indexed QMD`:n.length>1?`Matched ${n.length} query terms in indexed QMD`:"Matched indexed QMD session knowledge"}function Hhe(e,t){const n=e.snippet.replace(/\s+/g," ").trim(),r=/\s-\s\[\d{3,}\]\s`[^`]+`(?:\s\([^)]*\))?\s-\s/u.exec(n);if(!r)return n;const a=n.slice(0,r.index).trim(),o=n.slice(r.index+r[0].length).trim(),u=Mf(t).map(f=>f.toLowerCase()).some(f=>a.toLowerCase().includes(f));return a&&(u||o.startsWith("{")||o.startsWith("["))?a:o||a||n}function Whe(e,t){e.target===e.currentTarget&&(e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),t()))}function yb(e,t){e.stopPropagation(),t()}function qhe({buildIndex:e,buildWorktreeIndex:t,indexing:n,status:r}){const a=r?new Date(r.generatedAt).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):"Not loaded";return s.jsxs("section",{className:"ks-panel ks-conversation-panel",children:[s.jsxs("div",{className:"ks-panel-head",children:[s.jsxs("div",{children:[s.jsx("p",{className:"ks-panel-eyebrow",children:"Indexer"}),s.jsx("h2",{children:"Session knowledge index"})]}),s.jsx(Ei,{size:18,strokeWidth:1.7,"aria-hidden":"true"})]}),s.jsxs("div",{className:"ks-indexer-panel",children:[s.jsxs("div",{className:"ks-indexer-actions",children:[s.jsxs("button",{type:"button",className:"ks-primary-button",onClick:()=>{e(!1)},disabled:n,children:[n?s.jsx(Kn,{size:14,className:"ks-spin","aria-hidden":"true"}):s.jsx(Ei,{size:14,"aria-hidden":"true"}),"Build 3-day index"]}),s.jsxs("button",{type:"button",className:"ks-primary-button",onClick:()=>{e(!0)},disabled:n,children:[n?s.jsx(Kn,{size:14,className:"ks-spin","aria-hidden":"true"}):s.jsx(Ei,{size:14,"aria-hidden":"true"}),"Rebuild"]}),s.jsxs("button",{type:"button",className:"ks-primary-button",onClick:()=>{t(!0)},disabled:n,children:[n?s.jsx(Kn,{size:14,className:"ks-spin","aria-hidden":"true"}):s.jsx(Yb,{size:14,"aria-hidden":"true"}),"Index worktree diffs"]})]}),s.jsxs("div",{className:"ks-indexer-metrics",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Collections"}),s.jsx("strong",{children:r?`${$o(r.readyCollections)} / ${$o(r.collections)}`:"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Chunks"}),s.jsx("strong",{children:r?$o(r.chunks):"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Jobs"}),s.jsx("strong",{children:r?$o(r.activeJobs.length):"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Store"}),s.jsx("strong",{children:r?zhe(r.sqliteBytes):"—"})]})]}),s.jsxs("div",{className:"ks-indexer-facts",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Updated"}),s.jsx("strong",{children:a})]}),s.jsxs("div",{children:[s.jsx("span",{children:"QMD root"}),s.jsx("strong",{children:r?gw(r.paths.qmdRoot):"Not loaded"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"SQLite"}),s.jsx("strong",{children:r?gw(r.paths.sqlitePath):"Not loaded"})]})]}),r?.activeJobs.map(o=>s.jsxs("div",{className:"ks-empty-state",children:[s.jsx(Ei,{size:18,strokeWidth:1.7,"aria-hidden":"true"}),s.jsxs("strong",{children:[o.source," · ",o.state]}),s.jsxs("span",{children:[$o(o.progress.indexed??0)," indexed,"," ",$o(o.progress.failed??0)," failed"]})]},o.id))]})]})}function Khe({navigate:e,mode:t}){const{selectedKnowledgeHit:n,inspectKnowledgeHit:r,clearKnowledgeHit:a,openFilePreview:o}=qe(),{status:c,setStatus:u,error:f,setError:h}=Bhe(),[p,x]=m.useState("QMD search"),[v,y]=m.useState([]),[b,C]=m.useState(!1),[E,A]=m.useState(!1),S=(c?.chunks??0)>0,k=async(L=p)=>{const I=L.trim();if(!I||!S){y([]);return}C(!0);try{h(null);const z=new URLSearchParams({q:I,limit:"30"}),_=await ue(`/api/knowledge/search?${z.toString()}`);y(_.hits),u(_.status),_.hits[0]?r(_.hits[0],I):a()}catch(z){h(z instanceof Error?z.message:String(z))}finally{C(!1)}};m.useEffect(()=>{if(!S)return;const L=window.setTimeout(()=>{k(p)},250);return()=>window.clearTimeout(L)},[p,S]);const N=async(L=!1)=>{A(!0);try{h(null);const I=await ue("/api/knowledge/sessions/index",{method:"POST",body:JSON.stringify({days:3,limit:260,force:L})});u(I.status),await k(p)}catch(I){h(I instanceof Error?I.message:String(I))}finally{A(!1)}},T=async(L=!1)=>{A(!0);try{h(null);const I=await ue("/api/knowledge/worktree/index",{method:"POST",body:JSON.stringify({force:L,includeUntracked:!0})});u(I.status),await k(p)}catch(I){h(I instanceof Error?I.message:String(I))}finally{A(!1)}},R=L=>{L.preventDefault(),k(p)},O={view:"search",...t?{mode:t}:{}};return s.jsxs("div",{className:"s-secondary-nav-shell",children:[s.jsx("div",{className:"s-secondary-nav-bar",children:s.jsx(Lhe,{activeRoute:O,navigate:e})}),s.jsx("main",{className:"ks-page",children:s.jsx("section",{className:"ks-live-grid",children:t==="indexer"?s.jsx(qhe,{buildIndex:N,buildWorktreeIndex:T,indexing:E,status:c}):s.jsxs("section",{className:"ks-panel ks-conversation-panel",children:[s.jsxs("form",{className:"ks-search-form",onSubmit:R,children:[s.jsx(Tc,{size:16,strokeWidth:1.8,"aria-hidden":"true"}),s.jsx("input",{value:p,onChange:L=>x(L.target.value),placeholder:"Search QMD, embeddings, API work, raw log drilldown..."}),s.jsxs("button",{type:"submit","aria-label":"Search session knowledge",disabled:!S||b,children:[b?s.jsx(Kn,{size:14,className:"ks-spin","aria-hidden":"true"}):s.jsx(Yb,{size:14,"aria-hidden":"true"}),"Search"]})]}),f&&s.jsx("section",{className:"ks-error",role:"alert",children:f}),s.jsx("div",{className:"ks-query-tabs","aria-label":"Sample searches",children:Dhe.map(L=>s.jsxs("button",{type:"button",className:`ks-query-tab${p===L?" ks-query-tab--active":""}`,onClick:()=>x(L),children:[s.jsx(Tc,{size:13,strokeWidth:1.8,"aria-hidden":"true"}),s.jsx("span",{children:L})]},L))}),!S&&s.jsxs("div",{className:"ks-empty-state",children:[s.jsx(Ei,{size:18,strokeWidth:1.7,"aria-hidden":"true"}),s.jsx("strong",{children:"No session knowledge index yet"}),s.jsx("span",{children:"Build the last three days of sessions to replace the placeholder facts with real searchable QMD chunks."}),s.jsxs("button",{type:"button",className:"ks-primary-button",onClick:()=>{N(!1)},disabled:E,children:[E?s.jsx(Kn,{size:14,className:"ks-spin","aria-hidden":"true"}):s.jsx(Ei,{size:14,"aria-hidden":"true"}),"Build 3-day index"]})]}),S&&s.jsxs("div",{className:"ks-hit-list",children:[s.jsxs("div",{className:"ks-hit-list-head",children:[s.jsx("span",{children:b?"Searching derived QMD chunks...":`${v.length} matching chunks`}),s.jsx("strong",{children:c?`${$o(c.chunks)} indexed`:"index"})]}),v.length===0&&!b?s.jsx("div",{className:"ks-empty-hit",children:"No hits for this query. Try a project name, file path, tool name, or concept from recent work."}):v.map(L=>{const I=B5(L),z=U5(L),_=Va(L,"project"),U=Va(L,"harness"),D=Va(L,"source"),q=Va(L,"state"),Z=n?.id===L.id,$=I?Ri(I.path):z?Ri(z.path):"",G=Hhe(L,p),V=Ik(I),Y=F5(I),K=()=>r(L,p);return s.jsxs("article",{className:`ks-hit${Z?" ks-hit--selected":""}`,role:"button",tabIndex:0,"aria-current":Z?"true":void 0,onClick:K,onKeyDown:P=>Whe(P,K),children:[s.jsxs("div",{className:"ks-hit-title",children:[s.jsx(Yb,{size:14,strokeWidth:1.8,"aria-hidden":"true"}),s.jsx("strong",{children:L.title})]}),s.jsx("p",{children:s.jsx(Uhe,{text:G,query:p})}),s.jsx("div",{className:"ks-hit-reason",children:s.jsx("span",{children:Vhe(L,p)})}),s.jsxs("div",{className:"ks-hit-meta",children:[_&&s.jsx("span",{children:_}),U&&s.jsx("span",{children:U}),D==="git_worktree"&&s.jsx("span",{children:"worktree diff"}),q&&s.jsx("span",{children:q}),I?.recordRange&&s.jsxs("span",{children:["records ",I.recordRange[0],"..",I.recordRange[1]]})]}),$&&s.jsx("code",{className:"ks-hit-source",title:$,children:gw($)}),(V||Y||z)&&s.jsxs("div",{className:"ks-hit-actions","aria-label":"Search result actions",children:[V&&s.jsxs("button",{type:"button",onClick:P=>yb(P,()=>e({view:"sessions",sessionId:V})),children:[s.jsx(Xb,{size:13,"aria-hidden":"true"}),"Open session"]}),Y&&s.jsxs("button",{type:"button",onClick:P=>yb(P,()=>e({view:"ops",mode:"tail",tailQuery:Y})),children:[s.jsx(E2,{size:13,"aria-hidden":"true"}),"Observe window"]}),!I&&z&&s.jsxs("button",{type:"button",onClick:P=>yb(P,()=>{r(L,p),o(Ri(z.path))}),children:[s.jsx(wr,{size:13,"aria-hidden":"true"}),"Open file"]})]})]},L.id)})]})]})})})]})}const Ghe=new Set(["working","ready","not_ready"]),H5="openscout.mesh.machinePositions.v1";function Zhe(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(H5);if(!e)return{};const t=JSON.parse(e);if(t&&typeof t=="object"){const n={};for(const[r,a]of Object.entries(t))a&&typeof a=="object"&&typeof a.x=="number"&&typeof a.y=="number"&&(n[r]={x:a.x,y:a.y});return n}}catch{}return{}}function W5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(H5,JSON.stringify(e))}catch{}}let ht={mode:"map",density:"comfortable",selectedId:null,selectedType:null,meshSnapshot:null,probeCache:{},query:"",stateFilter:"all",agentStateFilters:Ghe,hiddenMachineIds:new Set,collapsedMachineIds:new Set,treeFullMachineIds:new Set,scrollTargetMachineId:null,machinePositions:Zhe()};const vw=new Set;function ms(){for(const e of vw)e()}function ER(e){ht.mode!==e&&(ht={...ht,mode:e},ms())}function bb(e){ht.density!==e&&(ht={...ht,density:e},ms())}function Go(e,t){ht.selectedId===e&&ht.selectedType===t||(ht={...ht,selectedId:e,selectedType:t},ms())}function tg(e){ht={...ht,meshSnapshot:e},ms()}function q5(e){ht.query!==e&&(ht={...ht,query:e},ms())}function wb(e){ht.stateFilter!==e&&(ht={...ht,stateFilter:e},ms())}function Yhe(e){const t=new Set(ht.agentStateFilters);t.has(e)?t.delete(e):t.add(e),ht={...ht,agentStateFilters:t},ms()}function AR(e){const t=new Set(ht.treeFullMachineIds);t.has(e)?t.delete(e):t.add(e),ht={...ht,treeFullMachineIds:t},ms()}function K5(e){const t=new Set(ht.hiddenMachineIds);t.has(e)?t.delete(e):t.add(e),ht={...ht,hiddenMachineIds:t},ms()}function Xhe(e,t){const n=new Set;for(const r of t)r!==e&&n.add(r);ht={...ht,hiddenMachineIds:n},ms()}function Qhe(){ht.hiddenMachineIds.size!==0&&(ht={...ht,hiddenMachineIds:new Set},ms())}function Jhe(e){const t=new Set(ht.collapsedMachineIds);t.has(e)?t.delete(e):t.add(e),ht={...ht,collapsedMachineIds:t},ms()}function eme(e,t){const n={...ht.machinePositions,[e]:t};ht={...ht,machinePositions:n},W5(n),ms()}function tme(){if(Object.keys(ht.machinePositions).length===0)return;const e={};ht={...ht,machinePositions:e},W5(e),ms()}function xw(e){ht={...ht,scrollTargetMachineId:e},ms(),queueMicrotask(()=>{ht.scrollTargetMachineId===e&&(ht={...ht,scrollTargetMachineId:null},ms())})}function nme(e){return vw.add(e),()=>{vw.delete(e)}}function sme(){return ht}function zc(){return m.useSyncExternalStore(nme,sme)}const $d=340,yw=16,rme=180,ame=100,TR=$d+yw;function ime(e,t){const n=window.innerWidth,r=window.innerHeight,a=12,o=n-e.right,c=e.left;if(o<TR&&c<TR)return{top:Math.max(a,Math.min(r/2-t/2,r-t-a)),left:Math.max(a,n/2-$d/2),side:"center"};const u=o>=c?"right":"left",f=u==="right"?Math.min(e.right+yw,n-$d-a):Math.max(e.left-yw-$d,a),p=e.top+e.height/2-t/2;return{top:Math.max(a,Math.min(p,r-t-a)),left:f,side:u}}function _k({agents:e,orderedIds:t,navigate:n,selectMode:r="preview"}){const[a,o]=m.useState(null),[c,u]=m.useState(null),[f,h]=m.useState(null),p=m.useRef(new Map),x=m.useRef(null),v=m.useRef(null),y=m.useRef(null),b=m.useRef(null),C=c??a,E=m.useMemo(()=>C?e.find(D=>D.id===C)??null:null,[C,e]),A=m.useMemo(()=>c?e.find(D=>D.id===c)??null:null,[c,e]),S=m.useCallback(()=>{x.current&&(window.clearTimeout(x.current),x.current=null),v.current&&(window.clearTimeout(v.current),v.current=null)},[]);m.useEffect(()=>()=>S(),[S]),m.useEffect(()=>{if(!C){h(null);return}const D=p.current.get(C);if(!D)return;const q=()=>{const $=D.getBoundingClientRect(),G=y.current?.offsetHeight??260;h(ime($,G))};q(),window.addEventListener("scroll",q,!0),window.addEventListener("resize",q);const Z=new ResizeObserver(q);return y.current&&Z.observe(y.current),()=>{window.removeEventListener("scroll",q,!0),window.removeEventListener("resize",q),Z.disconnect()}},[C]),m.useEffect(()=>{if(!c)return;const D=Z=>{Z.key==="Escape"&&(u(null),o(null))},q=Z=>{const $=Z.target;if(!y.current?.contains($)){for(const G of p.current.values())if(G.contains($))return;u(null)}};return window.addEventListener("keydown",D),window.addEventListener("mousedown",q),()=>{window.removeEventListener("keydown",D),window.removeEventListener("mousedown",q)}},[c]);const k=m.useCallback(D=>{if(!D)return;const q=p.current.get(D);q&&(typeof q.focus=="function"&&q.focus({preventScroll:!1}),q.scrollIntoView({block:"nearest",behavior:"smooth"}))},[]);m.useEffect(()=>{const D=b.current;if(!D)return;const q=Z=>{const $=document.activeElement,G=$?.dataset?.agentId??null,V=t;if(!(V.length===0||!D.contains($)&&Z.key!=="Escape")){if(Z.key==="ArrowDown"||Z.key==="ArrowUp"){Z.preventDefault();const K=G?V.indexOf(G):-1,P=Z.key==="ArrowDown"?K<0?0:Math.min(K+1,V.length-1):K<=0?0:K-1;k(V[P]);return}if(Z.key==="Home"){Z.preventDefault(),k(V[0]);return}if(Z.key==="End"){Z.preventDefault(),k(V[V.length-1]);return}Z.key.toLowerCase()==="o"&&G&&!Z.metaKey&&!Z.ctrlKey&&!Z.altKey&&(Z.preventDefault(),n({view:"agents",agentId:G}))}};return D.addEventListener("keydown",q),()=>D.removeEventListener("keydown",q)},[t,k,n]);const N=m.useCallback(D=>{if(S(),!(c&&c!==D)){if(a||c===D){o(D);return}x.current=window.setTimeout(()=>{o(D),x.current=null},rme)}},[S,a,c]),T=m.useCallback(()=>{c||(x.current&&(window.clearTimeout(x.current),x.current=null),v.current=window.setTimeout(()=>{o(null),v.current=null},ame))},[c]),R=m.useCallback(D=>{if(r==="navigate"){n({view:"agents",agentId:D});return}S(),u(q=>q===D?null:D),o(D)},[r,n,S]),O=m.useCallback(()=>{E&&n({view:"agents",agentId:E.id})},[E,n]),L=m.useCallback(()=>{S(),u(null),o(null)},[S]),I=m.useCallback(D=>({ref:q=>{q?p.current.set(D,q):p.current.delete(D)},onMouseEnter:()=>N(D),onMouseLeave:()=>T(),onFocus:()=>N(D),onBlur:()=>T(),onClick:()=>R(D),"data-agent-id":D,tabIndex:0}),[N,T,R]),z=m.useCallback(D=>({isActive:C===D,isPinned:c===D}),[C,c]),_=f?{position:"fixed",top:f.top,left:f.left,width:$d}:void 0,U=E&&f&&typeof document<"u"?da.createPortal(s.jsx(RD,{ref:y,agent:E,pinned:c===E.id,onOpen:O,onClose:L,onAction:L,style:_,className:`agent-card--side-${f.side}${c===E.id?"":" agent-card--preview"}`}),document.querySelector("[data-scout-theme]")??document.body):null;return{bind:I,getState:z,activeAgent:E,pinnedAgent:A,clear:L,card:U,containerRef:b}}function Bc(e){return e?e.replace(/^https?:\/\//,"").split("/")[0].split(":")[0].split(".")[0]||e.slice(0,8):""}function MR(e){return e&&((e.hostName?Bc(e.hostName):null)||e.name)||"this host"}function ome(e){return Bc(e.hostName)||e.name||"tailnet peer"}function lme(e){return Bc(e.dnsName)||Bc(e.hostName)||(e.name??"").toLowerCase()}function cme(e){return Bc(e.hostName)||(e.name?Bc(e.name):"")}function Ok(e,t){const n=new Map,r=t.localNode?.id??"local",a=MR(t.localNode),o=(t.localNode&&t.nodes?.[t.localNode.id]?.host)??t.nodes?.[r]?.host;n.set(r,{machineId:r,machineLabel:a,reachability:"this",online:!0,host:o,agents:[]});for(const f of e){const h=f.authorityNodeId??f.homeNodeId??r;let p=n.get(h);if(!p){const x=t.nodes?.[h];p={machineId:h,machineLabel:MR(x)||f.authorityNodeName||f.homeNodeName||h,reachability:"peer",online:!0,host:x?.host,agents:[]},n.set(h,p)}p.agents.push(f)}const c=new Set;for(const f of n.values()){c.add(f.machineLabel.toLowerCase());const h=t.nodes?.[f.machineId];if(h){const p=cme(h);p&&c.add(p.toLowerCase())}}for(const f of t.tailscale?.peers??[]){const h=ome(f),p=lme(f).toLowerCase();if(p&&c.has(p)||c.has(h.toLowerCase()))continue;const x=`tailnet:${f.id}`;n.has(x)||(n.set(x,{machineId:x,machineLabel:h,reachability:"tailnet",online:!!(f.online&&t.tailscale?.running),agents:[]}),p&&c.add(p),c.add(h.toLowerCase()))}const u=f=>f.reachability==="this"?0:f.reachability==="peer"?1:2;return Array.from(n.values()).sort((f,h)=>{const p=u(f)-u(h);return p!==0?p:f.machineLabel.localeCompare(h.machineLabel)})}function ume(e,t){if(t.type==="pan")return{...e,pan:{x:e.pan.x+t.delta.x,y:e.pan.y+t.delta.y}};if(t.type==="zoom"){const n=Math.max(.25,Math.min(4,e.scale*t.factor)),{mx:r,my:a,cx:o,cy:c}=t,u=(r-o)/e.scale-e.pan.x,f=(a-c)/e.scale-e.pan.y;return{scale:n,pan:{x:(r-o)/n-u,y:(a-c)/n-f}}}return e}const G5="openscout.mesh.canvas.viewport.v1";function dme(){const e={pan:{x:0,y:0},scale:1};if(typeof window>"u")return e;try{const t=window.sessionStorage.getItem(G5);if(!t)return e;const n=JSON.parse(t);if(n&&typeof n=="object"&&typeof n.scale=="number"&&n.pan&&typeof n.pan.x=="number"&&typeof n.pan.y=="number")return{pan:{x:n.pan.x,y:n.pan.y},scale:n.scale}}catch{}return e}function fme(e){const t=e.name&&e.name.trim()||e.handle&&e.handle.trim()||e.harness&&e.harness.trim()||"agent";return{key:t.toLowerCase(),label:t}}function hme(e){const t=new Map;for(const n of e){const{key:r,label:a}=fme(n);let o=t.get(r);o||(o={key:r,label:a,instances:[]},t.set(r,o)),o.instances.push(n)}return Array.from(t.values()).map(n=>(n.instances.sort((r,a)=>r.id.localeCompare(a.id)),n)).sort((n,r)=>{const a=n.label.localeCompare(r.label);return a!==0?a:r.instances.length-n.instances.length})}function mme(e){switch(e){case"compact":return{density:e,instanceW:138,instanceH:32,stepX:144,stepY:38,clusterPadX:12,clusterPadY:12,labelH:22,clusterGap:16};case"spacious":return{density:e,instanceW:260,instanceH:68,stepX:268,stepY:76,clusterPadX:14,clusterPadY:14,labelH:26,clusterGap:16};default:return{density:"comfortable",instanceW:210,instanceH:52,stepX:218,stepY:60,clusterPadX:12,clusterPadY:12,labelH:24,clusterGap:14}}}function pme(e,t){return Math.max(1,Math.round(Math.sqrt(e*t)))}function gme(e,t,n){if(e.length===0)return[];const r=e.map(A=>{const S=A.instances.length,k=pme(S,Math.max(.6,Math.min(n,2))),N=Math.ceil(S/k),T=k*t.stepX-(t.stepX-t.instanceW),R=N*t.stepY-(t.stepY-t.instanceH);return{cluster:A,cols:k,width:T+t.clusterPadX*2,height:R+t.clusterPadY*2+t.labelH}}),a=r.reduce((A,S)=>A+S.width*S.height,0),o=Math.max(Math.max(...r.map(A=>A.width)),Math.sqrt(a*n)),c=t.clusterGap,u=[];let f=0,h=0,p=0;for(const A of r)f>0&&f+A.width>o&&(h+=p+c,f=0,p=0),u.push({cluster:A.cluster,x:f,y:h,width:A.width,height:A.height,cols:A.cols}),f+=A.width+c,p=Math.max(p,A.height);const x=Math.min(...u.map(A=>A.x)),v=Math.max(...u.map(A=>A.x+A.width)),y=Math.min(...u.map(A=>A.y)),b=Math.max(...u.map(A=>A.y+A.height)),C=-((x+v)/2),E=-((y+b)/2);return u.map(A=>({...A,x:A.x+C,y:A.y+E}))}function vme(e,t,n){const r=e%t,a=Math.floor(e/t);return{x:n.clusterPadX+r*n.stepX,y:n.labelH+n.clusterPadY+a*n.stepY}}function $k(e){const t=e.harness?.trim(),n=e.model?.trim();return t&&n?`${t}/${n}`:t||n||"—"}function Lk(e){const t=e.project?.trim(),n=e.branch?.trim();return t&&n?`${t}/${n}`:t||n||"—"}function ng(e){return e.cwd||e.projectRoot||"—"}function Pk({onClick:e}){return s.jsx("button",{type:"button",className:"mesh-sheet-open",title:"Open agent view","aria-label":"Open agent view",onClick:t=>{t.stopPropagation(),e()},children:"↗"})}function xme({agent:e,onOpen:t,bindings:n,active:r}){const a=Ge(e.state),o=e.agentClass==="organic",c=e.updatedAt?Ie(e.updatedAt):"",u=$k(e),f=Lk(e);return s.jsxs("div",{...n??{},className:`mesh-instance-spec mesh-instance-spec--${a}${o?" mesh-instance-spec--organic":""}${r?" mesh-instance--active":""}`,style:{"--state-stripe":yn(e.state)},title:`${u} — ${f}`,children:[s.jsxs("span",{className:"mesh-instance-spec-row",children:[s.jsx("span",{className:"mesh-instance-spec-primary",children:u}),c&&s.jsx("span",{className:"mesh-instance-spec-time",children:c})]}),s.jsxs("span",{className:"mesh-instance-spec-row",children:[s.jsx("span",{className:"mesh-instance-spec-secondary",children:f}),s.jsx(Pk,{onClick:t})]})]})}function yme({agent:e,onOpen:t,bindings:n,active:r}){const a=Ge(e.state),o=e.agentClass==="organic",c=e.updatedAt?Ie(e.updatedAt):"—",u=`${$k(e)} · ${Lk(e)}`;return s.jsxs("div",{...n??{},className:`mesh-instance-sheet mesh-instance-sheet--${a}${o?" mesh-instance-sheet--organic":""}${r?" mesh-instance--active":""}`,style:{"--state-stripe":yn(e.state)},title:`${u}
175
- ${ng(e)}`,children:[s.jsxs("span",{className:"mesh-sheet-line mesh-sheet-line--head",children:[s.jsx("span",{className:"mesh-sheet-id",children:u}),s.jsx("span",{className:"mesh-sheet-time",children:c}),s.jsx(Pk,{onClick:t})]}),s.jsxs("span",{className:"mesh-sheet-line",children:[s.jsx("span",{className:"mesh-sheet-path",children:ng(e)}),s.jsxs("span",{className:"mesh-sheet-ctx",children:[s.jsx("span",{className:"mesh-sheet-ctx-label",children:"CTX"})," —"]})]})]})}function bme({agent:e,onOpen:t,bindings:n,active:r}){const a=Ge(e.state),o=e.agentClass==="organic",c=e.updatedAt?Ie(e.updatedAt):"—",u=`${$k(e)} · ${Lk(e)}`,f=e.agentClass?.trim();return s.jsxs("div",{...n??{},className:`mesh-instance-sheet mesh-instance-sheet--spacious mesh-instance-sheet--${a}${o?" mesh-instance-sheet--organic":""}${r?" mesh-instance--active":""}`,style:{"--state-stripe":yn(e.state)},title:`${u}
176
- ${ng(e)}`,children:[s.jsxs("span",{className:"mesh-sheet-line mesh-sheet-line--head",children:[s.jsx("span",{className:"mesh-sheet-id",children:u}),s.jsx("span",{className:"mesh-sheet-time",children:c}),s.jsx(Pk,{onClick:t})]}),s.jsx("span",{className:"mesh-sheet-line",children:s.jsx("span",{className:"mesh-sheet-path",children:ng(e)})}),s.jsxs("span",{className:"mesh-sheet-line",children:[s.jsxs("span",{className:"mesh-sheet-ctx",children:[s.jsx("span",{className:"mesh-sheet-ctx-label",children:"CTX"})," —"]}),f&&s.jsx("span",{className:"mesh-sheet-tag",children:f})]})]})}function wme({layout:e,metrics:t,onAgentOpen:n,bindFor:r,activeId:a}){const{cluster:o,x:c,y:u,width:f,height:h,cols:p}=e,x=m.useMemo(()=>{const v={working:0,ready:0,notReady:0};for(const y of o.instances){const b=Ge(y.state);b==="working"?v.working+=1:b==="ready"?v.ready+=1:v.notReady+=1}return v},[o.instances]);return s.jsxs("div",{className:"mesh-cluster",style:{position:"absolute",left:c,top:u,width:f,height:h},children:[s.jsxs("div",{className:"mesh-cluster-header",style:{height:t.labelH},children:[s.jsx("span",{className:"mesh-cluster-name",children:o.label}),s.jsx("span",{className:"mesh-cluster-count",children:o.instances.length}),s.jsxs("span",{className:"mesh-cluster-states",children:[x.working>0&&s.jsxs("span",{className:"mesh-cluster-state mesh-cluster-state--working",children:[s.jsx("span",{className:"mesh-cluster-state-dot"}),x.working]}),x.ready>0&&s.jsxs("span",{className:"mesh-cluster-state mesh-cluster-state--available",children:[s.jsx("span",{className:"mesh-cluster-state-dot"}),x.ready]}),x.notReady>0&&s.jsxs("span",{className:"mesh-cluster-state mesh-cluster-state--offline",children:[s.jsx("span",{className:"mesh-cluster-state-dot"}),x.notReady]})]})]}),o.instances.map((v,y)=>{const b=vme(y,p,t);return s.jsx("div",{style:{position:"absolute",left:b.x,top:b.y,width:t.instanceW,height:t.instanceH},children:t.density==="compact"?s.jsx(xme,{agent:v,onOpen:()=>n(v),bindings:r(v.id),active:a===v.id}):t.density==="spacious"?s.jsx(bme,{agent:v,onOpen:()=>n(v),bindings:r(v.id),active:a===v.id}):s.jsx(yme,{agent:v,onOpen:()=>n(v),bindings:r(v.id),active:a===v.id})},v.id)})]})}const bw=34,Z5=22,jme=6,RR=28,IR=10,jb=12,_R=380,kme=240,kb=38;function Nme(e,t,n,r,a,o){const c=[],u=[],f=[];for(const C of e)r[C.machineId]?f.push(C):u.push(C);let h=0,p=_R;const x=(C,E)=>{const S=t.has(C.machineId)||!C.online,k=n.has(C.machineId);let N=0,T=0,R=0;for(const G of C.agents){const V=Ge(G.state);V==="working"?N+=1:V==="ready"?T+=1:R+=1}const O=C.online?N>0?"working":T>0?"available":"offline":"offline";if(S)return{machineId:C.machineId,machineLabel:C.machineLabel,reachability:C.reachability,online:C.online,agentCount:C.agents.length,workingCount:N,availableCount:T,offlineCount:R,dominantState:O,host:C.host,collapsed:!1,ghost:!0,pinned:E,x:0,y:0,width:kme,height:kb,headerHeight:kb,chromeHeight:kb,layouts:[]};const L=k?[]:hme(C.agents),I=k?[]:gme(L,a,o),z=k?Ame():0,_=k?Y5+z*Z5+jme:0,U=bw+_;let D=0,q=0;if(!k&&I.length>0){const G=Math.min(...I.map(B=>B.x)),V=Math.max(...I.map(B=>B.x+B.width)),Y=Math.min(...I.map(B=>B.y)),K=Math.max(...I.map(B=>B.y+B.height));D=V-G,q=K-Y;const P=-G+jb,H=-Y+U+IR;for(const B of I)B.x+=P,B.y+=H}const Z=Math.max(_R,D+jb*2),$=k?U:U+IR+q+jb;return{machineId:C.machineId,machineLabel:C.machineLabel,reachability:C.reachability,online:C.online,agentCount:C.agents.length,workingCount:N,availableCount:T,offlineCount:R,dominantState:O,host:C.host,collapsed:k,ghost:!1,pinned:E,x:0,y:0,width:Z,height:$,headerHeight:bw,chromeHeight:U,layouts:I}};for(const C of u){const E=x(C,!1);E.x=0,E.y=h,c.push(E),p=Math.max(p,E.width),h+=E.height+RR}const v=Math.max(0,h-RR),y=-p/2,b=-v/2;for(const C of c)C.ghost||(C.width=p),C.x=y,C.y+=b;for(const C of f){const E=x(C,!0),A=r[C.machineId];E.x=A.x,E.y=A.y,c.push(E)}return c}function Sme({section:e,metrics:t,onAgentOpen:n,bindFor:r,activeId:a,onHeaderPointerDown:o,onHeaderClick:c,onGhostActivate:u}){const f=e.reachability==="this"?"this node":e.reachability==="peer"?"peer":e.reachability==="tailnet"?"tailnet":"",h=e.online?e.agentCount===0?"idle":"standby":"unreachable";if(e.ghost)return s.jsx("div",{"data-machine-id":e.machineId,className:"mesh-machine-ghost",style:{position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,pointerEvents:"all"},title:`${e.machineLabel} · ${h} — click to show`,children:s.jsxs("button",{type:"button",className:"mesh-machine-ghost-body",onPointerDown:x=>o(x,e),onClick:()=>u(e.machineId),children:[s.jsx("span",{className:"mesh-machine-ghost-led","aria-hidden":!0}),s.jsx("span",{className:"mesh-machine-ghost-name",children:e.machineLabel}),s.jsx("span",{className:"mesh-machine-ghost-stamp",children:h}),f&&s.jsx("span",{className:`mesh-machine-chip mesh-machine-chip--${e.reachability} mesh-machine-chip--ghost`,children:f}),s.jsxs("span",{className:"mesh-machine-ghost-counts",children:[s.jsx("span",{className:"mesh-machine-count",children:e.agentCount}),e.workingCount>0&&s.jsxs("span",{className:"mesh-machine-count mesh-machine-count--working",children:[e.workingCount,"W"]})]})]})});const p=e.collapsed?Cme(e):[];return s.jsxs("div",{"data-machine-id":e.machineId,className:`mesh-machine-section${e.collapsed?" mesh-machine-section--collapsed":""}${e.pinned?" mesh-machine-section--pinned":""}`,style:{position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,pointerEvents:"all"},children:[s.jsxs("button",{type:"button",className:"mesh-machine-header",style:{height:e.headerHeight},onPointerDown:x=>o(x,e),onClick:()=>c(e.machineId),"aria-expanded":!e.collapsed,children:[s.jsx("span",{className:`mesh-machine-led mesh-machine-led--${e.dominantState}`,style:{color:yn(e.dominantState)},"aria-hidden":!0}),s.jsx("span",{className:"mesh-machine-caret","aria-hidden":!0,children:e.collapsed?"▸":"▾"}),s.jsx("span",{className:"mesh-machine-grip","aria-hidden":!0,children:"⠿"}),s.jsx("span",{className:"mesh-machine-name",children:e.machineLabel}),f&&s.jsx("span",{className:`mesh-machine-chip mesh-machine-chip--${e.reachability}`,children:f})]}),e.collapsed&&s.jsxs("div",{className:"mesh-machine-spec",children:[s.jsxs("div",{className:"mesh-machine-state-strip",style:{height:Y5},children:[s.jsxs("div",{className:"mesh-machine-state-cell mesh-machine-state-cell--working",children:[s.jsx("span",{className:"mesh-machine-state-num",children:e.workingCount}),s.jsx("span",{className:"mesh-machine-state-label",children:"working"})]}),s.jsxs("div",{className:"mesh-machine-state-cell",children:[s.jsx("span",{className:"mesh-machine-state-num",children:e.availableCount}),s.jsx("span",{className:"mesh-machine-state-label",children:"ready"})]}),s.jsxs("div",{className:"mesh-machine-state-cell",children:[s.jsx("span",{className:"mesh-machine-state-num",children:e.agentCount}),s.jsx("span",{className:"mesh-machine-state-label",children:"total"})]})]}),p.map(x=>s.jsxs("div",{className:"mesh-machine-spec-row",style:{height:Z5},children:[s.jsx("span",{className:"mesh-machine-spec-label",children:x.label}),s.jsx("span",{className:"mesh-machine-spec-value",title:x.value,children:x.value})]},x.label))]}),!e.collapsed&&e.layouts.map(x=>s.jsx(wme,{layout:x,metrics:t,onAgentOpen:n,bindFor:r,activeId:a},x.cluster.key))]})}function Cme(e){const t=e.host;return[{label:"os",value:t?.os??"—"},{label:"arch",value:t?.arch??"—"},{label:"cpu",value:t?.cpuCores?`${t.cpuCores}c`:"—"},{label:"ram",value:t?.memoryGb?`${t.memoryGb} G`:"—"},{label:"disk",value:t?.storageCapacityGb?`${t.storageCapacityGb} G`:"—"},{label:"network",value:t?.network??"—"},{label:"scout",value:t?.scoutVersion?`v${t.scoutVersion}`:"—"}]}const Eme=7,Y5=54;function Ame(e,t,n,r){return Eme}function Tme({mesh:e,agents:t=[]}){const n=m.useRef(null),[r,a]=m.useState({w:0,h:0}),[o,c]=m.useReducer(ume,void 0,dme);m.useEffect(()=>{if(!(typeof window>"u"))try{window.sessionStorage.setItem(G5,JSON.stringify({pan:o.pan,scale:o.scale}))}catch{}},[o.pan,o.scale]);const{density:u,query:f,agentStateFilters:h,hiddenMachineIds:p,collapsedMachineIds:x,scrollTargetMachineId:v}=zc(),{navigate:y}=qe();m.useLayoutEffect(()=>{const H=n.current;if(!H)return;const B=()=>a({w:H.clientWidth,h:H.clientHeight});B();const Q=new ResizeObserver(B);return Q.observe(H),()=>Q.disconnect()},[]),m.useLayoutEffect(()=>{const H=n.current;if(!H)return;const B=Q=>{Q.preventDefault();const oe=Q.deltaY<0?1.12:1/1.12,ne=H.getBoundingClientRect();c({type:"zoom",factor:oe,mx:Q.clientX-ne.left,my:Q.clientY-ne.top,cx:ne.width/2,cy:ne.height/2})};return H.addEventListener("wheel",B,{passive:!1}),()=>H.removeEventListener("wheel",B)},[]);const{machinePositions:b}=zc(),C=m.useMemo(()=>mme(u),[u]),E=m.useMemo(()=>{const H=f.trim().toLowerCase();return t.filter(B=>{const oe=Ge(B.state);return h.has(oe)?H?`${B.name??""} ${B.handle??""} ${B.harness??""} ${B.project??""} ${B.branch??""}`.toLowerCase().includes(H):!0:!1})},[t,f,h]),A=m.useMemo(()=>Ok(E,e),[E,e]),S=r.w>0&&r.h>0?r.w/r.h:1.6,k=m.useMemo(()=>Nme(A,p,x,b,C,S),[A,p,x,b,C,S]),N=m.useRef(null),[T,R]=m.useState(null),O=m.useCallback((H,B)=>{if(H.button!==0)return;H.stopPropagation(),H.currentTarget.setPointerCapture(H.pointerId),N.current={machineId:B.machineId,startClientX:H.clientX,startClientY:H.clientY,startSectionX:B.x,startSectionY:B.y,pointerId:H.pointerId,moved:!1}},[]);m.useEffect(()=>{const H=Q=>{const oe=N.current;if(!oe||Q.pointerId!==oe.pointerId)return;const ne=Q.clientX-oe.startClientX,X=Q.clientY-oe.startClientY;if(!oe.moved&&Math.hypot(ne,X)<4)return;oe.moved=!0;const ae=ne/o.scale,be=X/o.scale;R({machineId:oe.machineId,x:oe.startSectionX+ae,y:oe.startSectionY+be})},B=Q=>{const oe=N.current;if(!(!oe||Q.pointerId!==oe.pointerId)){if(N.current=null,oe.moved){const ne=(Q.clientX-oe.startClientX)/o.scale,X=(Q.clientY-oe.startClientY)/o.scale;eme(oe.machineId,{x:oe.startSectionX+ne,y:oe.startSectionY+X})}R(null)}};return window.addEventListener("pointermove",H),window.addEventListener("pointerup",B),window.addEventListener("pointercancel",B),()=>{window.removeEventListener("pointermove",H),window.removeEventListener("pointerup",B),window.removeEventListener("pointercancel",B)}},[o.scale]);const L=m.useRef(!1);m.useEffect(()=>{if(T)L.current=!0;else{const H=setTimeout(()=>{L.current=!1},50);return()=>clearTimeout(H)}},[T]);const I=m.useCallback(H=>{L.current||K5(H)},[]),z=m.useCallback(H=>{L.current||Jhe(H)},[]),_=m.useMemo(()=>T?k.map(H=>H.machineId===T.machineId?{...H,x:T.x,y:T.y,pinned:!0}:H):k,[k,T]);m.useEffect(()=>{if(!v)return;const H=_.find(B=>B.machineId===v);H&&c({type:"pan",delta:{x:-H.x-o.pan.x-H.width/2,y:-H.y-o.pan.y+r.h/4-bw}})},[v,_,o.pan.x,o.pan.y,r.h]);const U=m.useCallback(H=>{H.agentClass!=="organic"&&y({view:"agents",agentId:H.id})},[y]),D=m.useMemo(()=>E.filter(H=>H.agentClass!=="organic"),[E]),q=m.useMemo(()=>D.map(H=>H.id),[D]),Z=_k({agents:D,orderedIds:q,navigate:y,selectMode:"preview"}),$=m.useCallback(H=>q.includes(H)?Z.bind(H):null,[Z,q]),G=Z.activeAgent?.id??null,{pan:V,scale:Y}=o,K=r.w/2,P=r.h/2;return s.jsxs("div",{ref:n,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[r.w>0&&s.jsx(mP,{panOffset:V,scale:Y,onPan:H=>c({type:"pan",delta:H}),gridOpacity:.7}),s.jsx("div",{style:{position:"absolute",left:0,top:0,width:0,height:0,transform:`translate(${K}px, ${P}px) translate(${V.x*Y}px, ${V.y*Y}px) scale(${Y})`,transformOrigin:"0 0",pointerEvents:"none"},children:_.length===0?s.jsx("div",{style:{position:"absolute",left:-120,top:-20,width:240,textAlign:"center",pointerEvents:"none"},children:s.jsx("div",{className:"mesh-empty-pill",children:"no machines visible"})}):_.map(H=>s.jsx(Sme,{section:H,metrics:C,onAgentOpen:U,bindFor:$,activeId:G,onHeaderPointerDown:O,onHeaderClick:z,onGhostActivate:I},H.machineId))}),s.jsx("div",{className:"mesh-canvas-hint",children:"scroll to zoom · drag to pan"}),Z.card]})}function Mme(e){const t=new Map,n=new Map;for(const o of e){const c=o.project??"Unassigned",u=c.toLowerCase(),f=o.branch??"—";let h=t.get(u);h||(h=new Map,t.set(u,h));const p=h.get(f)??[];p.push(o),h.set(f,p);let x=n.get(u);x||(x=new Map,n.set(u,x)),x.set(c,(x.get(c)??0)+1)}const r=o=>{const c=n.get(o);if(!c)return o;let u=null,f=-1;for(const[h,p]of c)p>f&&(u=h,f=p);return u??o},a=[];for(const[o,c]of t){const u=r(o),f=[];let h=0;const p={working:0,ready:0,not_ready:0},x=[];for(const[v,y]of c){const b=[...y].sort((E,A)=>(A.updatedAt??0)-(E.updatedAt??0)),C=b.reduce((E,A)=>Math.max(E,A.updatedAt??0),0);h=Math.max(h,C);for(const E of b)p[Ge(E.state)]+=1,x.push(E);f.push({branch:v,agents:b,latest:C})}f.sort((v,y)=>y.latest-v.latest),a.push({project:u,branches:f,agents:x,latest:h,counts:p})}return a.sort((o,c)=>c.latest-o.latest),a}function OR(e){return e?e.replace(/^\/Users\/[^/]+/,"~"):null}function Rme({agents:e,emptyTitle:t="No agents registered",emptyBody:n="Agents connected to this broker will appear here.",selectMode:r="preview"}){const{navigate:a}=qe(),o=m.useMemo(()=>Mme(e),[e]),[c,u]=m.useState(()=>new Set),f=m.useMemo(()=>{const x=[];for(const v of o)if(!c.has(v.project))for(const y of v.branches)for(const b of y.agents)x.push(b.id);return x},[o,c]),h=_k({agents:e,orderedIds:f,navigate:a,selectMode:r});if(e.length===0)return s.jsxs("div",{className:"sys-list-empty",children:[s.jsx("h3",{children:t}),s.jsx("p",{children:n})]});const p=x=>{u(v=>{const y=new Set(v);return y.has(x)?y.delete(x):y.add(x),y})};return s.jsxs("div",{className:"mesh-tree",ref:h.containerRef,children:[o.map(x=>{const v=c.has(x.project);return s.jsxs("div",{className:`mesh-tree-group${v?" mesh-tree-group--collapsed":""}`,children:[s.jsxs("button",{type:"button",className:"mesh-tree-project",onClick:()=>p(x.project),"aria-expanded":!v,children:[s.jsx("span",{className:`mesh-tree-caret${v?"":" mesh-tree-caret--open"}`,"aria-hidden":!0,children:"›"}),s.jsx("span",{className:"mesh-tree-project-name",children:x.project}),s.jsx("span",{className:"mesh-tree-project-count",children:x.agents.length}),s.jsxs("span",{className:"mesh-tree-counts",children:[x.counts.working>0&&s.jsxs("span",{className:"mesh-tree-count mesh-tree-count--working",children:[s.jsx("span",{className:"mesh-tree-count-dot"}),x.counts.working]}),x.counts.ready>0&&s.jsxs("span",{className:"mesh-tree-count mesh-tree-count--available",children:[s.jsx("span",{className:"mesh-tree-count-dot"}),x.counts.ready]}),x.counts.not_ready>0&&s.jsxs("span",{className:"mesh-tree-count mesh-tree-count--offline",children:[s.jsx("span",{className:"mesh-tree-count-dot"}),x.counts.not_ready]})]}),s.jsx("span",{className:"mesh-tree-project-time",children:x.latest?Ie(x.latest):""})]}),!v&&s.jsx("div",{className:"mesh-tree-branches",children:x.branches.map(y=>s.jsxs("div",{className:"mesh-tree-branch",children:[s.jsxs("div",{className:"mesh-tree-branch-head",children:[s.jsx("span",{className:"mesh-tree-branch-elbow","aria-hidden":!0,children:"└"}),s.jsx("span",{className:"mesh-tree-branch-name",children:y.branch})]}),s.jsx("div",{className:"mesh-tree-agents",children:y.agents.map(b=>{const C=Ge(b.state),E=ll(b.state),A=b.agentClass==="organic",S=h.getState(b.id),k=OR(b.cwd)??OR(b.projectRoot),N=b.harnessSessionId?b.harnessSessionId.slice(0,8):null,T=[];k&&T.push({kind:"cwd",text:k}),b.harness&&T.push({kind:"harness",text:b.harness}),b.model&&T.push({kind:"model",text:b.model}),N&&T.push({kind:"sess",text:`sess:${N}`});const R=h.bind(b.id);return s.jsxs("button",{type:"button",className:`mesh-tree-agent${A?" mesh-tree-agent--organic":""}${S.isActive?" mesh-tree-agent--active":""}${S.isPinned?" mesh-tree-agent--pinned":""}`,title:A?`${b.harness??b.name} · organic session`:void 0,...R,children:[s.jsx("span",{className:`mesh-tree-agent-dot mesh-tree-agent-dot--${E}`,style:{background:yn(b.state)}}),s.jsx("span",{className:"mesh-tree-agent-name",children:b.handle??b.name}),A&&s.jsx("span",{className:"mesh-tree-agent-organic","aria-label":"organic session",children:"○"}),s.jsx("span",{className:"mesh-tree-agent-inline",children:T.map((O,L)=>s.jsxs("span",{className:`mesh-tree-agent-inline-part mesh-tree-agent-inline-part--${O.kind}`,children:[L>0&&s.jsx("span",{className:"mesh-tree-agent-inline-sep",children:"·"}),O.text]},O.kind))}),s.jsx("span",{className:`mesh-tree-agent-state mesh-tree-agent-state--${E}`,children:cs(C)}),s.jsx("span",{className:"mesh-tree-agent-time",children:b.updatedAt?Ie(b.updatedAt):""})]},b.id)})})]},y.branch))})]},x.project)}),h.card]})}function Ime(e){if(!e)return null;const t=e.split("/").filter(Boolean);return t[t.length-1]??null}function _me(e,t){if(!e)return[];const n=new Set;for(const o of t)o.cwd&&n.add(o.cwd),o.projectRoot&&n.add(o.projectRoot);const r=new Map;for(const o of e.transcripts){if(!o.cwd)continue;const c=r.get(o.cwd);(!c||o.mtimeMs>c.mtimeMs)&&r.set(o.cwd,o)}const a=[];for(const o of e.processes){if(o.harness==="scout-managed"||o.cwd&&n.has(o.cwd))continue;const c=o.cwd?r.get(o.cwd):void 0,u=c?.project??Ime(o.cwd)??null,f=c?.mtimeMs??e.generatedAt,h=c?.sessionId??null;a.push({id:`harness:${o.source}:${o.pid}`,name:o.source,handle:null,agentClass:"organic",harness:o.source,state:"working",projectRoot:o.cwd,cwd:o.cwd,updatedAt:f,createdAt:null,transport:null,selector:null,wakePolicy:null,capabilities:[],project:u,branch:null,role:null,model:null,harnessSessionId:h,harnessLogPath:c?.transcriptPath??null,conversationId:h??`harness:${o.pid}`,homeNodeId:null,homeNodeName:null,ownerId:null,ownerName:null,ownerHandle:null})}return a}function X5(){const{agents:e}=qe(),[t,n]=m.useState(null);m.useEffect(()=>{let o=!1;const c=async()=>{const f=await ue("/api/tail/discover").catch(()=>null);o||n(f)};c();const u=setInterval(()=>{c()},1e4);return()=>{o=!0,clearInterval(u)}},[]);const r=m.useMemo(()=>_me(t,e),[t,e]);return{agents:m.useMemo(()=>[...e,...r],[e,r]),scoutAgents:e,organicAgents:r,discovery:t}}function $R({mode:e,density:t,query:n,stateFilter:r,loading:a,refreshing:o,error:c,lastLoadedAt:u,hasMesh:f,onRefresh:h}){return s.jsxs("div",{className:`mesh-hud mesh-hud--${e}`,children:[s.jsxs("div",{className:"mesh-hud-left",children:[s.jsxs("div",{className:"mesh-mode-toggle",children:[s.jsx("button",{type:"button",className:`mesh-mode-btn${e==="map"?" mesh-mode-btn--active":""}`,onClick:()=>ER("map"),children:"Map"}),s.jsx("button",{type:"button",className:`mesh-mode-btn${e==="tree"?" mesh-mode-btn--active":""}`,onClick:()=>ER("tree"),children:"Tree"})]}),s.jsxs("div",{className:"mesh-mode-toggle mesh-density-toggle",role:"group","aria-label":"Density","aria-hidden":e!=="map","data-mode-only":"map",children:[s.jsx("button",{type:"button",className:`mesh-mode-btn${t==="compact"?" mesh-mode-btn--active":""}`,onClick:()=>bb("compact"),disabled:e!=="map",title:"Compact — dots",children:"Compact"}),s.jsx("button",{type:"button",className:`mesh-mode-btn${t==="comfortable"?" mesh-mode-btn--active":""}`,onClick:()=>bb("comfortable"),disabled:e!=="map",title:"Comfortable — chips",children:"Comfortable"}),s.jsx("button",{type:"button",className:`mesh-mode-btn${t==="spacious"?" mesh-mode-btn--active":""}`,onClick:()=>bb("spacious"),disabled:e!=="map",title:"Spacious — cards",children:"Spacious"})]})]}),f&&s.jsxs("div",{className:"mesh-hud-filters",children:[s.jsx("input",{type:"search",className:"mesh-hud-search",placeholder:"Filter agents…",value:n,onChange:p=>q5(p.target.value),spellCheck:!1,autoCorrect:"off",autoCapitalize:"off"}),s.jsxs("div",{className:"mesh-mode-toggle",role:"group","aria-label":"State",children:[s.jsx("button",{type:"button",className:`mesh-mode-btn${r==="all"?" mesh-mode-btn--active":""}`,onClick:()=>wb("all"),children:"All"}),s.jsx("button",{type:"button",className:`mesh-mode-btn${r==="working"?" mesh-mode-btn--active":""}`,onClick:()=>wb("working"),children:"Working"}),s.jsx("button",{type:"button",className:`mesh-mode-btn${r==="ready"?" mesh-mode-btn--active":""}`,onClick:()=>wb("ready"),children:"Ready"})]})]}),s.jsxs("div",{className:"mesh-hud-right",children:[s.jsx("span",{className:"mesh-hud-sync",children:a?"Loading…":c&&f?`Last sync old — ${u?Ie(u):"unknown"}`:u?Ie(u):"—"}),s.jsx("button",{type:"button",className:"s-btn",disabled:a||o,onClick:h,children:o?"Refreshing…":"Refresh"})]})]})}function Ome({navigate:e}){const[t,n]=m.useState(!0),[r,a]=m.useState(!1),[o,c]=m.useState(null),[u,f]=m.useState(null),{mode:h,density:p,query:x,stateFilter:v,meshSnapshot:y}=zc(),{agents:b}=X5(),{route:C}=qe(),E=zs(C),A=m.useMemo(()=>no(b,E,y?.localNode?.id),[b,E,y?.localNode?.id]),S=m.useRef(null),k=m.useRef(0);m.useEffect(()=>{S.current=y},[y]),m.useEffect(()=>{E&&Go(E,"node")},[E]);const N=m.useCallback(async(L="initial")=>{const I=++k.current;!(S.current!==null)&&L!=="background"?(n(!0),c(null)):a(!0);try{const _=await ue("/api/mesh");if(I!==k.current)return;tg(_),c(null),f(Date.now())}catch(_){if(I!==k.current)return;c(_ instanceof Error?_.message:String(_))}finally{I===k.current&&(n(!1),a(!1))}},[]);m.useEffect(()=>{N("initial")},[N]),m.useEffect(()=>{const L=setInterval(()=>{N("background")},1e4);return()=>clearInterval(L)},[N]);const T=m.useMemo(()=>{const L=x.trim().toLowerCase();return A.filter(I=>v!=="all"&&Ge(I.state)!==v?!1:L?`${I.name??""} ${I.handle??""} ${I.harness??""} ${I.project??""} ${I.branch??""}`.toLowerCase().includes(L):!0)},[x,A,v]),R={mode:h,density:p,query:x,stateFilter:v,loading:t,refreshing:r,error:o,lastLoadedAt:u,hasMesh:!!y,onRefresh:()=>{N("manual")}},O=h==="map"?s.jsxs("div",{className:"mesh-map-canvas",children:[y&&s.jsx(Tme,{mesh:y,agents:T}),t&&!y&&s.jsx("div",{className:"mesh-canvas-center",children:s.jsx("p",{className:"mesh-canvas-center-label",children:"Loading mesh…"})}),!t&&!y&&o&&s.jsxs("div",{className:"mesh-canvas-center",children:[s.jsx("p",{className:"mesh-canvas-center-label",children:o}),s.jsx("button",{type:"button",className:"s-btn",onClick:()=>{N("manual")},children:"Try again"})]}),s.jsx($R,{...R})]}):s.jsxs("div",{className:"mesh-tree-page",children:[s.jsx($R,{...R}),t&&!y&&s.jsxs("div",{className:"sys-panel sys-state-card mesh-tree-state",children:[s.jsx("h3",{className:"sys-state-title",children:"Loading mesh status"}),s.jsx("p",{className:"sys-state-body",children:"Inspecting broker reachability and peer discovery inputs."})]}),!t&&!y&&o&&s.jsxs("div",{className:"sys-panel sys-state-card sys-state-card-error mesh-tree-state",children:[s.jsx("h3",{className:"sys-state-title",children:"Mesh status is unavailable"}),s.jsx("p",{className:"sys-state-body",children:o}),s.jsx("div",{className:"sys-inline-actions",children:s.jsx("button",{type:"button",className:"s-btn",onClick:()=>{N("manual")},children:"Try again"})})]}),y&&s.jsxs("section",{className:"mesh-tree-panel",children:[s.jsxs("div",{className:"mesh-tree-hint","aria-hidden":!0,children:[s.jsx("kbd",{children:"↑"}),s.jsx("kbd",{children:"↓"}),s.jsx("span",{children:"navigate"}),s.jsx("span",{className:"mesh-tree-hint-sep",children:"·"}),s.jsx("kbd",{children:"enter"}),s.jsx("span",{children:"pin"}),s.jsx("span",{className:"mesh-tree-hint-sep",children:"·"}),s.jsx("kbd",{children:"o"}),s.jsx("span",{children:"open"}),s.jsx("span",{className:"mesh-tree-hint-sep",children:"·"}),s.jsx("kbd",{children:"esc"}),s.jsx("span",{children:"clear"})]}),s.jsx(Rme,{agents:T,emptyTitle:A.length===0?E?"No agents on this machine":"No agents registered":"No agents match your filter",emptyBody:A.length===0?"Agents connected to this broker will appear here.":"Try clearing the search or switching the state pill back to All."})]})]});return s.jsxs("div",{className:"s-ops",children:[s.jsx("div",{className:"s-ops-header",children:s.jsx(Ef,{activeRoute:C,navigate:e})}),s.jsx("div",{className:"s-ops-body",children:O})]})}function $me({conversationId:e,navigate:t}){const{route:n}=qe(),r=e?s.jsx(eu,{conversationId:e,navigate:t,showBackNav:!1}):s.jsx(Lme,{});return s.jsxs("div",{className:"s-secondary-nav-shell",children:[s.jsx("div",{className:"s-secondary-nav-bar",children:s.jsx(Zp,{activeRoute:n,navigate:t})}),s.jsx("div",{className:"s-secondary-nav-body",children:r})]})}function Lme(){return s.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:32,color:"var(--muted)",fontFamily:"var(--font-mono)",fontSize:12,letterSpacing:"0.04em"},children:s.jsxs("div",{style:{textAlign:"center",maxWidth:360},children:[s.jsx("div",{style:{textTransform:"uppercase",letterSpacing:"0.18em",fontSize:10,color:"color-mix(in srgb, var(--accent) 70%, var(--muted))",marginBottom:8},children:"Conversations"}),s.jsx("p",{style:{lineHeight:1.6,margin:0},children:"Select a conversation from the rail."})]})})}const En=e=>e.toLocaleString("en-US"),Pme={critical:{label:"CRITICAL",tone:"error",fg:"var(--status-error-fg)",bg:"var(--status-error-bg)",rank:0,glyph:"●",gloss:"Merge conflicts or unmerged status — work is stuck."},attention:{label:"ATTENTION",tone:"warn",fg:"var(--studio-ink)",bg:"var(--status-neutral-bg)",rank:1,glyph:"▲",gloss:"Dirty main, diverged branch, or status couldn't be read."},active:{label:"ACTIVE",tone:"accent",fg:"var(--scout-accent)",bg:"var(--scout-accent-soft)",rank:2,glyph:"◆",gloss:"Live work — dirty, ahead/behind, or an agent is attached."},quiet:{label:"QUIET",tone:"neutral",fg:"var(--studio-ink-faint)",bg:"var(--status-neutral-bg)",rank:3,glyph:"·",gloss:"Clean and idle — nothing pulling for attention."},unknown:{label:"UNKNOWN",tone:"neutral",fg:"var(--studio-ink-faint)",bg:"var(--status-neutral-bg)",rank:4,glyph:"?",gloss:"Discovered but couldn't be scanned enough to classify."}};function Ac(e){return Pme[e].rank}function sl(e){return(e.state??"").toLowerCase()==="active"}function qi(e){return e.name&&e.name.trim()?"@"+e.name.trim().toLowerCase().replace(/\s+/g,"-"):e.id}function Dk(e){const t=new Set,n=[];for(const r of[...e.agents].sort((a,o)=>Number(sl(o))-Number(sl(a)))){const a=qi(r);t.has(a)||(t.add(a),n.push(r))}return n}function Dme(e){const t=e.replace(/\/+$/,"").split("/");return t[t.length-1]||e}function Q5(e,t=3){const n=e.replace(/\/+$/,"").split("/").filter(Boolean);return n.length<=t?e:"…/"+n.slice(-t).join("/")}function zme(e,t){if(e==null)return"—";const n=Math.max(0,Math.round((t-e)/1e3));if(n<60)return`${n}s`;const r=Math.round(n/60);if(r<60)return`${r}m`;const a=Math.round(r/60);return a<24?`${a}h`:`${Math.round(a/24)}d`}function Bme(e){const t=e.toLowerCase();return t.includes("conflict")?"error":t==="untracked"?"info":t==="staged"?"ok":(t.includes("unstaged")||t==="changed"||t==="modified","warn")}function Ume(e){const t=e.toLowerCase();return t.includes("conflict")?"U":t==="untracked"?"?":t==="staged+unstaged"?"±":t==="staged"?"S":t==="unstaged"?"M":t==="changed"||t==="modified"?"~":"•"}function Fme(e){return e==="accent"?"var(--scout-accent)":`var(--status-${e}-fg)`}function Vme(e){return e==="accent"?"var(--scout-accent-soft)":`var(--status-${e}-bg)`}function zk(e){return e.error!=null?"error":e.agents.some(sl)?"live":!e.status.clean||e.branch.ahead>0||e.branch.behind>0?"dirty":"clean"}function LR(e){if(!e)return null;const t=/(\d+)\s+files?\s+changed/.exec(e),n=/(\d+)\s+insertions?\(\+\)/.exec(e),r=/(\d+)\s+deletions?\(-\)/.exec(e);return!t&&!n&&!r?null:{files:t?Number(t[1]):0,ins:n?Number(n[1]):0,del:r?Number(r[1]):0}}function Bk(e){const t=LR(e.diff.stagedShortstat),n=LR(e.diff.unstagedShortstat),r=(t?.ins??0)+(n?.ins??0),a=(t?.del??0)+(n?.del??0);return{add:r,del:a,total:r+a,has:r>0||a>0}}function Hme(e,t){if(e.detached)return{detached:!0,sha:e.head?e.head.slice(0,7):null,prefix:"",leaf:""};const n=e.name??t,r=n.lastIndexOf("/");return r>=0?{detached:!1,sha:null,prefix:n.slice(0,r+1),leaf:n.slice(r+1)}:{detached:!1,sha:null,prefix:"",leaf:n}}function Uk({branch:e,fallback:t}){const n=Hme(e,t);return n.detached?s.jsx("span",{className:"pre",children:n.sha??"detached"}):n.prefix?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"pre",children:n.prefix}),n.leaf]}):s.jsx(s.Fragment,{children:n.leaf})}const PR={attention:"desc",name:"asc",churn:"desc",files:"desc",drift:"desc",agents:"desc"},DR="attention";function Wme(e){return!e.status.clean||e.branch.ahead>0||e.branch.behind>0||e.agents.some(sl)||e.sessions.length>0||e.error!=null}function qme(e,t){const{add:n,del:r,total:a}=Bk(e),o=Dk(e);return{wt:e,project:t,state:zk(e),add:n,del:r,churn:a,live:o.filter(sl).length,agentsUnique:o}}function Kme({snapshot:e,selectedId:t,onSelect:n,onViewDiff:r,scanDepth:a,scanMorePending:o,onScanMore:c}){const[u,f]=m.useState(DR),[h,p]=m.useState(PR[DR]),[x,v]=m.useState(!1),{liveRows:y,cleanRows:b,stats:C}=m.useMemo(()=>{const k=[],N=[];let T=0,R=0;for(const I of e.projects)for(const z of I.worktrees){const _=qme(z,I);_.live>0&&T++,Ac(z.attention)<=1&&R++,(Wme(z)?k:N).push(_)}const O=e.totals,L={repos:O.projects,worktrees:O.worktrees,dirty:O.dirtyWorktrees,live:T,attn:R,agents:O.attachedAgents};return{liveRows:k,cleanRows:N,stats:L}},[e.projects,e.totals]),E=m.useMemo(()=>{const k=spe(y,u,h),N=new Map;for(const T of k){const R=N.get(T.project.id);R?R.push(T):N.set(T.project.id,[T])}return[...N.values()]},[y,u,h]);function A(k){k===u?p(N=>N==="asc"?"desc":"asc"):(f(k),p(PR[k]))}const S=y.length===0&&b.length===0;return s.jsxs("section",{className:"rw-table",children:[s.jsxs("div",{className:"rw-head",children:[s.jsxs("div",{className:"rw-head-top",children:[s.jsx("span",{className:"rw-eyebrow",children:"STATE OF REPOS"}),b.length>0?s.jsxs("button",{type:"button",className:"rw-clean",style:{marginLeft:"auto"},onClick:()=>v(k=>!k),"aria-pressed":x,children:[x?"hide":"show"," clean & idle (",b.length,")"]}):null]}),s.jsxs("div",{className:"stats",children:[s.jsx(Xl,{v:C.repos,k:"REPOS"}),s.jsx(Xl,{v:C.worktrees,k:"WORKTREES"}),s.jsx(Xl,{v:C.dirty,k:"DIRTY"}),s.jsx(Xl,{v:C.live,k:"LIVE",tone:"mint"}),C.attn>0?s.jsx(Xl,{v:C.attn,k:"NEEDS ATTN",tone:"coral"}):null,s.jsx(Xl,{v:C.agents,k:"AGENTS"})]})]}),s.jsxs("div",{className:"tbl-wrap",children:[s.jsxs("div",{className:"tbl-head",children:[s.jsx(sd,{label:"REPO / BRANCH · WORKTREE",k:"name",sortKey:u,dir:h,onSort:A}),s.jsx(sd,{label:"CHURN",k:"churn",sortKey:u,dir:h,onSort:A,align:"r"}),s.jsx(sd,{label:"FILES",k:"files",sortKey:u,dir:h,onSort:A,align:"c"}),s.jsx(sd,{label:"DRIFT",k:"drift",sortKey:u,dir:h,onSort:A,align:"c"}),s.jsx(sd,{label:"AGENTS",k:"agents",sortKey:u,dir:h,onSort:A})]}),S?s.jsx("div",{className:"rw-empty",children:"No repositories discovered yet."}):E.map(k=>k.length>1?s.jsx(Yme,{group:k,selectedId:t,onSelect:n,onViewDiff:r},k[0].project.id):s.jsx(ww,{row:k[0],top:!0,selected:t===k[0].wt.id,onSelect:()=>n(k[0].wt.id),onViewDiff:r},k[0].wt.id)),x&&b.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"tbl-head",style:{position:"static"},children:s.jsxs("span",{children:["CLEAN & IDLE · ",b.length]})}),b.map(k=>s.jsx(ww,{row:k,top:!0,clean:!0,selected:t===k.wt.id,onSelect:()=>n(k.wt.id),onViewDiff:r},k.wt.id))]}):null,s.jsx(Gme,{snapshot:e,scanDepth:a,scanMorePending:o,onScanMore:c})]})]})}function Gme({snapshot:e,scanDepth:t,scanMorePending:n,onScanMore:r}){const a=Zme(e);return s.jsxs("div",{className:"scan-coverage",children:[s.jsxs("div",{className:"scan-coverage-row",children:[s.jsx("b",{children:"SCAN"}),s.jsx("span",{className:"scan-main",children:a.summary}),a.canScanMore&&t==="standard"?s.jsx("button",{type:"button",onClick:r,disabled:n,children:n?"Scanning":"Scan more"}):s.jsx("span",{className:"scan-chip",children:t==="expanded"?"expanded":"standard"})]}),e.warnings.length>0?s.jsxs("details",{className:"scan-details",children:[s.jsxs("summary",{children:[En(e.warnings.length)," diagnostic",e.warnings.length===1?"":"s"]}),s.jsx("ul",{children:e.warnings.map((o,c)=>s.jsx("li",{children:o},`${c}:${o}`))})]}):null]})}function Zme(e){let t=null,n=0,r=0,a=0,o=0,c=0,u=0;for(const h of e.warnings){const p=/limited discovery to (\d+) repositories/i.exec(h);if(p){t=`discovery capped at ${p[1]}`;continue}if(/limited .* to \d+ worktrees/i.test(h)){n++;continue}if(/skipped unreadable worktree/i.test(h)){r++;continue}if(/skipped missing repo-watch path/i.test(h)){a++;continue}if(/scan budget|stopped discovery|stopped scanning/i.test(h)){o++;continue}if(/could not resolve git common directory/i.test(h)){c++;continue}u++}const f=[`${En(e.totals.projects)} repo${e.totals.projects===1?"":"s"}`,`${En(e.totals.worktrees)} worktree${e.totals.worktrees===1?"":"s"}`];return t&&f.push(t),n&&f.push(`${En(n)} repo${n===1?"":"s"} at worktree cap`),r&&f.push(`${En(r)} unreadable worktree${r===1?"":"s"} skipped`),a&&f.push(`${En(a)} missing path${a===1?"":"s"}`),c&&f.push(`${En(c)} unresolved git dir${c===1?"":"s"}`),o&&f.push("scan budget reached"),u&&f.push(`${En(u)} other diagnostic${u===1?"":"s"}`),{summary:f.join(" · "),canScanMore:t!==null||n>0||o>0}}function Yme({group:e,selectedId:t,onSelect:n,onViewDiff:r}){const a=e[0].project,o=e.some(h=>h.state==="error"),c=e.reduce((h,p)=>h+p.add,0),u=e.reduce((h,p)=>h+p.del,0),f=e.reduce((h,p)=>h+(p.live?1:0),0);return s.jsxs("div",{children:[s.jsxs("div",{className:"repo-grp"+(o?" attn":""),children:[s.jsxs("div",{className:"rg-name",children:[s.jsx("span",{className:"rg-tw","aria-hidden":!0,children:s.jsx("svg",{width:"11",height:"11",viewBox:"0 0 11 11",fill:"none",style:{transform:"rotate(90deg)"},children:s.jsx("path",{d:"M3 2l4 3.5L3 9",stroke:"currentColor",strokeWidth:"1.3",fill:"none"})})}),s.jsx("span",{className:"dot "+npe(e)}),s.jsx("span",{className:"rg-nm",children:a.name}),s.jsx("span",{className:"rg-path",children:Q5(a.root,3)}),s.jsxs("span",{className:"rg-badge",children:[a.worktrees.length," worktrees"]})]}),s.jsx("div",{className:"rg-agg",children:c||u?s.jsxs("span",{children:[s.jsxs("span",{style:{color:"var(--mint-dim)"},children:["+",En(c)]})," ",s.jsxs("span",{style:{color:"var(--coral-dim)"},children:["−",En(u)]})]}):"—"}),s.jsx("div",{}),s.jsx("div",{}),s.jsx("div",{className:"rg-agg",style:{textAlign:"left"},children:f?`${f} live`:""})]}),e.map((h,p)=>s.jsx(ww,{row:h,guide:!0,last:p===e.length-1,selected:t===h.wt.id,onSelect:()=>n(h.wt.id),onViewDiff:r},h.wt.id))]})}function ww({row:e,top:t,guide:n,last:r,clean:a,selected:o,onSelect:c,onViewDiff:u}){const{wt:f,project:h}=e,p=f.branch,x=!!u&&f.status.changedFiles>0;return s.jsx(s.Fragment,{children:s.jsxs("div",{className:["wt",o?"sel":"",e.state==="error"?"attn":""].join(" "),style:t&&!a?{borderTop:"1px solid var(--line)"}:void 0,onClick:c,role:"button",tabIndex:0,onKeyDown:c?v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),c())}:void 0,children:[s.jsxs("div",{className:"wt-name",children:[n?s.jsx("span",{className:"tw-guide"+(r?" last":"")}):null,s.jsxs("div",{className:"inner",children:[s.jsx("span",{className:"dot "+e.state}),s.jsxs("span",{className:"br",children:[t&&!n?s.jsxs("span",{className:"lead",children:[h.name,"  "]}):null,s.jsx(Uk,{branch:f.branch,fallback:f.name})]}),s.jsx(tpe,{wt:f})]})]}),s.jsx(Xme,{add:e.add,del:e.del}),s.jsx("div",{className:"files",children:f.status.changedFiles>0?s.jsxs("span",{children:[f.status.changedFiles,f.status.conflicts>0?s.jsxs("span",{className:"conf",children:[" ⚠",f.status.conflicts]}):null]}):s.jsx("span",{className:"dash",children:"—"})}),s.jsx(Qme,{ahead:p.ahead,behind:p.behind}),s.jsxs("div",{className:"agents-cell",children:[s.jsx(epe,{row:e}),x?s.jsx("button",{type:"button",className:"wt-diff",title:`View diff · ${f.status.changedFiles} changed file${f.status.changedFiles===1?"":"s"}`,"aria-label":"View diff",onClick:v=>{v.stopPropagation(),u?.(f.path)},children:"diff"}):null]})]})})}function Xl({v:e,k:t,tone:n}){return s.jsxs("div",{className:"stat",children:[s.jsx("span",{className:"v"+(n?" "+n:""),children:En(e)}),s.jsx("span",{className:"k",children:t})]})}function sd({label:e,k:t,sortKey:n,dir:r,onSort:a,align:o}){const c=n===t;return s.jsx("div",{className:o==="r"?"r":o==="c"?"c":"",children:s.jsxs("button",{type:"button",className:c?"on":"",onClick:()=>a(t),children:[s.jsx("span",{children:e}),s.jsx("span",{className:"caret","aria-hidden":!0,children:r==="asc"?"▲":"▼"})]})})}function Xme({add:e,del:t}){if(!e&&!t)return s.jsx("div",{className:"churn",children:s.jsx("span",{className:"dash",children:"—"})});const n=e+t||1;return s.jsxs("div",{className:"churn",children:[s.jsxs("span",{className:"nums",children:[s.jsxs("span",{className:"add",children:["+",En(e)]}),s.jsx("span",{className:"sl",children:"/"}),s.jsxs("span",{className:"del",children:["−",En(t)]})]}),s.jsxs("span",{className:"cbar",title:`+${En(e)} −${En(t)}`,children:[s.jsx("span",{className:"g",style:{width:e/n*100+"%"}}),s.jsx("span",{className:"r",style:{width:t/n*100+"%"}})]})]})}function Qme({ahead:e,behind:t}){return!e&&!t?s.jsx("div",{className:"drift",children:s.jsx("span",{className:"dash",children:"—"})}):s.jsxs("div",{className:"drift",children:[e?s.jsxs("span",{className:"dp ahead",children:["↑",e]}):null,t?s.jsxs("span",{className:"dp behind",children:["↓",t]}):null]})}const Jme=2;function epe({row:e}){const t=e.agentsUnique;if(t.length===0)return s.jsx("div",{className:"agents",children:s.jsx("span",{className:"dash",children:"—"})});const n=t.slice(0,Jme),r=t.length-n.length;return s.jsxs("div",{className:"agents",title:t.map(a=>`${qi(a)} (${a.state??"—"})`).join(`
177
- `),children:[e.live>0?s.jsxs("span",{className:"alive",children:[s.jsx("span",{className:"d"}),e.live]}):null,s.jsx("span",{className:"ahandle",children:n.map(a=>qi(a)).join(" ")}),r>0?s.jsxs("span",{className:"amore",children:["+",r]}):null]})}function tpe({wt:e}){const t=[];return e.branch.detached?t.push({label:"DETACHED",cls:""}):e.branch.upstream||t.push({label:"LOCAL",cls:""}),e.error!=null&&t.push({label:"SCAN ERR",cls:"err"}),e.isBare&&t.push({label:"BARE",cls:""}),s.jsx(s.Fragment,{children:t.map(n=>s.jsx("span",{className:"tag "+n.cls,children:n.label},n.label))})}const zR={error:3,live:2,dirty:1,clean:0};function npe(e){return e.reduce((t,n)=>zR[n.state]>zR[t]?n.state:t,"clean")}function spe(e,t,n){const r=n==="asc"?1:-1,a=p=>{switch(t){case"attention":return-Ac(p.wt.attention);case"churn":return p.churn;case"files":return p.wt.status.changedFiles;case"drift":return p.wt.branch.ahead+p.wt.branch.behind;case"agents":return p.live*1e6+p.agentsUnique.length;default:return 0}},o=new Map;for(const p of e){const x=o.get(p.project.id);x?x.push(p):o.set(p.project.id,[p])}const c=(p,x)=>{if(t==="name"){const b=p.project.id===x.project.id?BR(p.wt,p.project):p.project.name,C=p.project.id===x.project.id?BR(x.wt,x.project):x.project.name;return b.localeCompare(C)*r}const v=(a(p)-a(x))*r;if(v!==0)return v;const y=Ac(p.wt.attention)-Ac(x.wt.attention);return y!==0?y:p.wt.name.localeCompare(x.wt.name)},u=p=>p.reduce((x,v)=>Math.max(x,a(v)),-1/0),f=[...o.values()].sort((p,x)=>{if(t==="name")return p[0].project.name.localeCompare(x[0].project.name)*r;const v=(u(p)-u(x))*r;return v!==0?v:p[0].project.name.localeCompare(x[0].project.name)}),h=[];for(const p of f)h.push(...[...p].sort(c));return h}function BR(e,t){const n=Dme(e.path);return n===t.name?n:n.startsWith(t.name+"-")?n.slice(t.name.length+1):n}const bm=8;function UR(e){if(e.error!=null)return 0;const{ahead:t,behind:n}=e.branch;return t>0&&n>0?1:n>0||t>0?2:3}function rpe(e){const t=(e.name??"").trim();if(t){const a=t.split(/[\s_\-/]+/).filter(Boolean);if(a.length>=2)return(a[0][0]+a[1][0]).toUpperCase();if(a.length===1)return a[0].slice(0,2).toUpperCase()}return(qi(e).replace(/^@/,"").replace(/[^a-z0-9]/gi,"").slice(0,2)||"··").toUpperCase()}function ape({snapshot:e,selectedId:t,onSelect:n}){return s.jsxs("section",{className:"bd",children:[s.jsx("div",{className:"bd-head",children:"BRANCH DRIFT — distance from each worktree's base · behind ← origin → ahead · flags call out what needs a rebase"}),s.jsxs("div",{className:"bd-axis",children:[s.jsx("div",{}),s.jsxs("div",{className:"bd-axis-track",children:[s.jsx("span",{className:"bd-axis-lbl",style:{left:"0%"},children:"−8"}),s.jsx("span",{className:"bd-axis-lbl",style:{left:"25%"},children:"−4"}),s.jsx("span",{className:"bd-axis-lbl bd-origin-lbl",style:{left:"50%"},children:"origin"}),s.jsx("span",{className:"bd-axis-lbl",style:{left:"75%"},children:"+4"}),s.jsx("span",{className:"bd-axis-lbl",style:{left:"100%"},children:"+8"}),s.jsx("span",{className:"bd-axis-cap",children:"COMMITS ←"})]}),s.jsx("div",{}),s.jsx("div",{}),s.jsx("div",{})]}),e.projects.map(r=>s.jsx(ipe,{project:r,selectedId:t,onSelect:n},r.id))]})}function ipe({project:e,selectedId:t,onSelect:n}){const r=[...e.worktrees].sort((a,o)=>UR(a)-UR(o));return s.jsxs("div",{className:"bd-grp",children:[s.jsxs("div",{className:"bd-grp-h",children:[s.jsx("span",{className:"bd-grp-nm",children:e.name}),s.jsx("span",{className:"bd-grp-path",children:Q5(e.root,3)})]}),r.map(a=>s.jsx(ope,{wt:a,selected:t===a.id,onSelect:()=>n(a.id)},a.id))]})}function ope({wt:e,selected:t,onSelect:n}){const r=zk(e),{ahead:a,behind:o}=e.branch,c=e.error!=null,u=Dk(e);return s.jsxs("div",{className:["bd-row",t?"sel":""].join(" "),role:"button",tabIndex:0,onClick:n,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),n())},children:[s.jsxs("div",{className:"bd-id",children:[s.jsx("span",{className:"dot "+r}),s.jsx("span",{className:"bd-br",children:s.jsx(Uk,{branch:e.branch,fallback:e.name})})]}),s.jsx(lpe,{ahead:a,behind:o,hasError:c}),s.jsx(cpe,{wt:e,hasError:c}),s.jsx(dpe,{agents:u}),s.jsx(fpe,{ahead:a,behind:o,hasError:c})]})}function lpe({ahead:e,behind:t,hasError:n}){const r=e===0&&t===0;return s.jsxs("div",{className:"bd-track",children:[s.jsx("span",{className:"bd-tick",style:{left:"0%"}}),s.jsx("span",{className:"bd-tick",style:{left:"25%"}}),s.jsx("span",{className:"bd-tick bd-tick-origin",style:{left:"50%"}}),s.jsx("span",{className:"bd-tick",style:{left:"75%"}}),s.jsx("span",{className:"bd-tick",style:{left:"100%"}}),n||r?s.jsx("span",{className:"bd-origin-ring"}):s.jsxs(s.Fragment,{children:[t>0?s.jsxs("span",{className:"bd-bar bd-behind",style:{right:"50%",width:Math.min(t,bm)/bm*50+"%"},children:[s.jsx("span",{className:"bd-cap bd-cap-l"}),s.jsxs("span",{className:"bd-lbl bd-lbl-l",children:["↓",t]})]}):null,e>0?s.jsxs("span",{className:"bd-bar bd-ahead",style:{left:"50%",width:Math.min(e,bm)/bm*50+"%"},children:[s.jsx("span",{className:"bd-cap bd-cap-r"}),s.jsxs("span",{className:"bd-lbl bd-lbl-r",children:["↑",e]})]}):null]})]})}function cpe({wt:e,hasError:t}){const{add:n,del:r,has:a}=Bk(e);if(t||!a)return s.jsx("div",{className:"bd-churn",children:s.jsx("span",{className:"dash",children:"—"})});const o=n+r||1;return s.jsxs("div",{className:"bd-churn",children:[s.jsxs("span",{className:"bd-churn-nums",children:[s.jsxs("span",{className:"add",children:["+",En(n)]}),s.jsx("span",{className:"sl",children:"/"}),s.jsxs("span",{className:"del",children:["−",En(r)]})]}),s.jsxs("span",{className:"bd-cbar",title:`+${En(n)} −${En(r)}`,children:[s.jsx("span",{className:"g",style:{width:n/o*100+"%"}}),s.jsx("span",{className:"r",style:{width:r/o*100+"%"}})]})]})}const upe=2;function dpe({agents:e}){if(e.length===0)return s.jsx("div",{className:"bd-agents",children:s.jsx("span",{className:"dash",children:"—"})});const t=e.slice(0,upe),n=e.length-t.length;return s.jsxs("div",{className:"bd-agents",title:e.map(r=>`${qi(r)} (${r.state??"—"})`).join(`
178
- `),children:[t.map(r=>s.jsx("span",{className:"bd-av"+(sl(r)?" live":""),children:rpe(r)},qi(r))),n>0?s.jsxs("span",{className:"bd-av-more",children:["+",n]}):null]})}function fpe({ahead:e,behind:t,hasError:n}){return n?s.jsx("div",{className:"bd-flag err",children:"SCAN ERR"}):e>0&&t>0?s.jsx("div",{className:"bd-flag rebase",children:"DIVERGED ▸"}):t>0?s.jsx("div",{className:"bd-flag rebase",children:"REBASE ▸"}):e>0?s.jsxs("div",{className:"bd-flag ahead",children:["AHEAD ",e]}):s.jsx("div",{className:"bd-flag sync",children:"IN SYNC"})}function hpe(e){return e.error!=null?{label:"SCAN ERR",cls:"err"}:e.status.conflicts>0?{label:"CONFLICT",cls:"conflict"}:e.status.clean?{label:"CLEAN",cls:"clean"}:{label:"DIRTY",cls:"dirty"}}function mpe(e){const t=(e.state??"").toLowerCase();return t==="active"?"ACTIVE":t==="idle"?"IDLE":t==="waiting"?"WAITING":"—"}function ppe(e){const t=e.lastIndexOf("/");return t<0?{dir:"",file:e}:{dir:e.slice(0,t+1),file:e.slice(t+1)}}function gpe({worktree:e,project:t,generatedAt:n}){if(!e||!t)return s.jsx("aside",{className:"rw-ctx","aria-label":"Worktree detail",children:s.jsxs("div",{className:"rw-ctx-empty",children:[s.jsx("span",{className:"eb",children:"CONTEXT · WORKTREE"}),s.jsx("span",{className:"msg",children:"Select a worktree to inspect"})]})});const r=e,a=r.branch,o=hpe(r),{add:c,del:u,has:f}=Bk(r),h=c+u||1,p=Dk(r),x=[{label:"staged",n:r.status.staged},{label:"unstaged",n:r.status.unstaged},{label:"untracked",n:r.status.untracked},{label:"conflicts",n:r.status.conflicts,cls:"conf"}].filter(v=>v.n>0);return s.jsxs("aside",{className:"rw-ctx","aria-label":"Worktree detail",children:[s.jsxs("div",{className:"ctx-h",children:[s.jsx("div",{className:"ctx-eyebrow",children:s.jsx("span",{children:"CONTEXT · WORKTREE"})}),s.jsxs("div",{className:"ctx-repo",children:[s.jsx("span",{className:"dot "+zk(r)}),s.jsx("span",{className:"rn",children:t.name}),s.jsx("span",{className:"ctx-state "+o.cls,children:o.label})]}),s.jsx("div",{className:"ctx-branch",children:s.jsx(Uk,{branch:a,fallback:r.name})}),s.jsxs("div",{className:"ctx-path",children:[r.path,a.upstream?s.jsxs("span",{className:"ref",children:[" · ",a.upstream]}):null]})]}),s.jsxs("div",{className:"ctx-stats",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"v"+(a.ahead>0?" mint":" dim"),children:["↑",a.ahead]}),s.jsx("div",{className:"k",children:"AHEAD"})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"v"+(a.behind>0?" amber":" dim"),children:["↓",a.behind]}),s.jsx("div",{className:"k",children:"BEHIND"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"v"+(r.status.changedFiles>0?"":" dim"),children:r.status.changedFiles}),s.jsx("div",{className:"k",children:"FILES"})]})]}),x.length>0?s.jsx("div",{className:"ctx-breakdown",children:x.map(v=>s.jsxs("span",{className:"ctx-chip"+(v.cls?" "+v.cls:""),children:[s.jsx("span",{className:"n",children:v.n}),v.label]},v.label))}):null,s.jsxs("div",{className:"ctx-body",children:[r.attentionReasons.length>0?s.jsxs("div",{className:"ctx-sec",children:[s.jsxs("div",{className:"ctx-sec-h",children:[s.jsx("span",{children:"ATTENTION"}),s.jsx("span",{className:"n",children:r.attentionReasons.length})]}),s.jsx("div",{className:"ctx-why",children:r.attentionReasons.map((v,y)=>s.jsx("span",{className:"pill",children:v},y))})]}):null,r.error?s.jsxs("div",{className:"ctx-sec",children:[s.jsx("div",{className:"ctx-sec-h",children:s.jsx("span",{children:"SCAN ERROR"})}),s.jsx("div",{className:"ctx-err",children:r.error})]}):null,s.jsxs("div",{className:"ctx-sec",children:[s.jsxs("div",{className:"ctx-sec-h",children:[s.jsx("span",{children:"CHURN"}),s.jsx("span",{className:"n",children:"working tree"})]}),f?s.jsxs("div",{className:"ctx-churn",children:[s.jsxs("span",{className:"nums",children:[s.jsxs("span",{className:"add",children:["+",En(c)]}),s.jsx("span",{className:"sl",children:"/"}),s.jsxs("span",{className:"del",children:["−",En(u)]})]}),s.jsxs("span",{className:"cbar",title:`+${En(c)} −${En(u)}`,children:[s.jsx("span",{className:"g",style:{width:c/h*100+"%"}}),s.jsx("span",{className:"r",style:{width:u/h*100+"%"}})]})]}):s.jsx("div",{className:"ctx-churn-clean",children:r.status.clean?"working tree clean":"no line changes"})]}),r.status.files.length>0?s.jsxs("div",{className:"ctx-sec",children:[s.jsxs("div",{className:"ctx-sec-h",children:[s.jsx("span",{children:"FILES CHANGED"}),s.jsx("span",{className:"n",children:r.status.files.length})]}),r.status.files.map(v=>{const y=Bme(v.status),{dir:b,file:C}=ppe(v.path);return s.jsxs("div",{className:"ctx-fchg",children:[s.jsx("span",{className:"badge",style:{color:Fme(y),background:Vme(y)},title:v.status,children:Ume(v.status)}),s.jsxs("span",{className:"fp",title:v.path,children:[s.jsx("span",{className:"dir",children:b}),C]})]},v.path)})]}):null,s.jsxs("div",{className:"ctx-sec",children:[s.jsx("div",{className:"ctx-sec-h",children:s.jsx("span",{children:"LAST COMMIT"})}),s.jsx("div",{className:"ctx-commit",children:r.lastCommitAt!=null||a.head?s.jsxs(s.Fragment,{children:[a.head?s.jsx("span",{className:"hash",children:a.head.slice(0,7)}):null,s.jsxs("span",{className:"t",children:[zme(r.lastCommitAt,n)," ago"]})]}):s.jsx("span",{className:"none",children:"no commit data"})})]}),s.jsxs("div",{className:"ctx-sec",children:[s.jsxs("div",{className:"ctx-sec-h",children:[s.jsx("span",{children:"AGENTS ON TREE"}),s.jsxs("span",{className:"n",children:[p.length,r.sessions.length>0?` · ${r.sessions.length} session${r.sessions.length===1?"":"s"}`:""]})]}),p.length>0?p.map(v=>s.jsxs("div",{className:"ctx-agent",children:[s.jsx("span",{className:"d "+(sl(v)?"on":"off")}),s.jsx("span",{className:"h",children:qi(v)}),s.jsx("span",{className:"role",children:mpe(v)})]},qi(v))):s.jsx("div",{className:"ctx-none",children:"no agents attached"})]})]}),s.jsxs("div",{className:"ctx-actions",children:[s.jsx("button",{className:"ctx-btn primary",type:"button",disabled:!0,title:"not wired yet",children:"Open diff"}),s.jsx("button",{className:"ctx-btn",type:"button",disabled:!0,title:"not wired yet",children:"Checkout"}),s.jsx("button",{className:"ctx-btn",type:"button",style:{flex:"0 0 auto",padding:"9px 12px"},title:"Copy worktree path",onClick:()=>{navigator.clipboard?.writeText(r.path)},children:"Copy path"})]})]})}const vpe=m.lazy(()=>zm(()=>import("./RepoDiffViewer-DRzXs-TP.js"),[]).then(e=>({default:e.RepoDiffViewer})));function xpe(){return s.jsx("div",{className:"rd-viewer","data-scout-theme":!0,children:s.jsx("div",{className:"rd-center",children:s.jsxs("div",{className:"rd-center-card",children:[s.jsx("div",{className:"rd-spinner","aria-hidden":!0}),s.jsx("div",{className:"rd-center-title",children:"Opening diff viewer…"})]})})})}function Fk(e){return s.jsx(m.Suspense,{fallback:s.jsx(xpe,{}),children:s.jsx(vpe,{...e})})}const Rf=["unstaged","staged"],J5=3e4,ype=24,bpe=4,Zo=new Map,dp=new Map,Nb=new Set;let FR=Promise.resolve();function wpe(e,t=Rf){const n=new URLSearchParams;n.set("path",e);for(const r of t)n.append("layer",r);return`/api/repo-diff/worktree?${n.toString()}`}function Vk(e,t){return wpe(e,t)}function jpe(){for(;Zo.size>ype;){const e=Zo.keys().next().value;if(!e)break;Zo.delete(e)}}function kpe(e,t=Rf,n=J5){const r=Zo.get(Vk(e,t));if(!r)return null;const a=Math.max(0,Date.now()-r.fetchedAt);return{...r,ageMs:a,fresh:a<=n}}async function Npe(e,t=Rf,n={}){const r=Vk(e,t);if(!n.force){const o=Zo.get(r);if(o&&Date.now()-o.fetchedAt<=J5)return{...o,cacheHit:!0};const c=dp.get(r);if(c)return c}const a=ue(r).then(o=>{const c={snapshot:o,fetchedAt:Date.now()};return Zo.delete(r),Zo.set(r,c),jpe(),{...c,cacheHit:!1}});dp.set(r,a);try{return await a}finally{dp.delete(r)}}function Spe(e,t=Rf){const n=Vk(e,t);kpe(e,t)?.fresh||dp.has(n)||Nb.has(n)||(Nb.add(n),FR=FR.catch(()=>{}).then(()=>Npe(e,t).then(()=>{},()=>{})).finally(()=>{Nb.delete(n)}))}function Cpe(e,t=Rf){for(const n of e.slice(0,bpe))Spe(n,t)}function lke(e){if(e<5e3)return"just now";const t=Math.round(e/1e3);if(t<60)return`${t}s ago`;const n=Math.round(t/60);return n<60?`${n}m ago`:`${Math.round(n/60)}h ago`}const Epe=1e4,Ape="openscout.repos.tone",VR=["warm","cool","mono"],Tpe="openscout.repos.view",HR=["table","drift"];function Mpe(e,t){const n=new URLSearchParams({includeDiff:"1",includeLastCommit:"1",native:"1"});return t&&n.set("force","1"),e==="expanded"&&(n.set("maxRoots","32"),n.set("maxWorktrees","12"),n.set("scanBudgetMs","12000")),`/api/repo-watch?${n.toString()}`}function WR(e,t,n){const[r,a]=m.useState(()=>{if(typeof window>"u")return n;try{const c=window.localStorage.getItem(e);return c&&t.includes(c)?c:n}catch{return n}}),o=m.useCallback(c=>{a(c);try{window.localStorage.setItem(e,c)}catch{}},[e]);return[r,o]}function Rpe(e){let t=null,n=-1/0;for(const r of e.projects)for(const a of r.worktrees){const o=a.agents.filter(u=>(u.state??"").toLowerCase()==="active").length,c=(4-Ac(a.attention))*1e6+o*1e4+a.status.changedFiles;c>n&&(n=c,t=a)}return t}function Ipe(e,t){if(!e||!t)return{worktree:null,project:null};for(const n of e.projects)for(const r of n.worktrees)if(r.id===t)return{worktree:r,project:n};return{worktree:null,project:null}}function _pe(e,t){const n=[];for(const r of e.projects)for(const a of r.worktrees){const o=a.status.staged+a.status.unstaged+a.status.untracked+a.status.conflicts,c=a.agents.filter(u=>(u.state??"").toLowerCase()==="active").length;o===0&&c===0||n.push({path:a.path,score:(a.id===t?1e7:0)+(4-Ac(a.attention))*1e5+c*1e4+o*100+a.status.changedFiles})}return n.sort((r,a)=>a.score-r.score).map(r=>r.path)}function rd({navigate:e,children:t}){return s.jsxs("div",{className:"s-ops",children:[s.jsx("div",{className:"s-ops-header",children:s.jsx(Ef,{activeRoute:{view:"repos"},navigate:e})}),s.jsx("div",{className:"s-ops-body",style:{overflowY:"auto"},children:t})]})}function Ope({navigate:e}){const[t,n]=m.useState(null),[r,a]=m.useState("loading"),[o,c]=m.useState(null),u=m.useRef(!1),f=m.useRef(0),[h,p]=WR(Ape,VR,"warm"),[x,v]=WR(Tpe,HR,"table"),[y,b]=m.useState(null),[C,E]=m.useState("standard"),[A,S]=m.useState(!1),[k,N]=m.useState(null),T=m.useCallback(async(L={})=>{const I=L.depth??C;L.scanMore&&S(!0);try{const z=await ue(Mpe(I,L.force??!1));if(z.projects.length===0&&u.current&&f.current<3){f.current+=1,a("ready");return}f.current=0,u.current=!0,n(z),c(null),a("ready")}catch(z){const _=z instanceof Error?z.message:String(z);c(_),u.current||a("error")}finally{L.scanMore&&S(!1)}},[C]);m.useEffect(()=>{T();const L=setInterval(()=>{T()},Epe);return()=>clearInterval(L)},[T]),m.useEffect(()=>{if(!t)return;t.projects.some(I=>I.worktrees.some(z=>z.id===y))||b(Rpe(t)?.id??null)},[t,y]),m.useEffect(()=>{!t||t.projects.length===0||Cpe(_pe(t,y))},[t,y]);const R=m.useMemo(()=>Ipe(t,y),[t,y]),O=m.useCallback(()=>{E("expanded"),T({depth:"expanded",force:!0,scanMore:!0})},[T]);return r==="loading"?s.jsx(rd,{navigate:e,children:s.jsx("div",{className:"repo-watch-scope",style:{padding:"24px"},children:s.jsx(hs,{title:"Scanning repositories…",body:"Reading worktree state from the broker."})})}):r==="error"&&!t?s.jsx(rd,{navigate:e,children:s.jsx("div",{className:"repo-watch-scope",style:{padding:"24px"},children:s.jsx(hs,{className:"sys-state-card-error",title:"Couldn’t load Repo Watch",body:o??"The broker did not return a snapshot.",action:s.jsx("button",{type:"button",className:"s-btn",onClick:()=>{a("loading"),T()},children:"Retry"})})})}):t&&t.projects.length===0?s.jsx(rd,{navigate:e,children:s.jsx("div",{className:"repo-watch-scope",style:{padding:"24px"},children:s.jsx(hs,{title:"No repositories in view",body:"Nothing active was discovered. Start an agent inside a git repo, or set OPENSCOUT_REPO_WATCH_ROOTS."})})}):t?s.jsx(rd,{navigate:e,children:s.jsxs("div",{className:"repo-watch-scope",children:[s.jsx("div",{className:"rw-scope tone-"+h,children:s.jsxs("div",{className:"mx-auto max-w-[1560px] px-6 py-6",children:[s.jsxs("div",{className:"rw-toolbar",children:[s.jsx("div",{className:"rw-tone",role:"group","aria-label":"View",children:HR.map(L=>s.jsx("button",{type:"button",className:L===x?"on":"","aria-pressed":L===x,onClick:()=>v(L),children:L},L))}),s.jsx("div",{className:"rw-tone",style:{marginLeft:"auto"},role:"group","aria-label":"Console tone",children:VR.map(L=>s.jsx("button",{type:"button",className:L===h?"on":"","aria-pressed":L===h,onClick:()=>p(L),children:L},L))})]}),s.jsxs("div",{className:"flex items-start gap-6",children:[s.jsx("div",{className:"min-w-0 flex-1",children:x==="drift"?s.jsx(ape,{snapshot:t,selectedId:y,onSelect:b}):s.jsx(Kme,{snapshot:t,selectedId:y,onSelect:b,onViewDiff:N,scanDepth:C,scanMorePending:A,onScanMore:O})}),s.jsx("div",{className:"hidden w-[340px] flex-none lg:block sticky top-6 self-start",children:s.jsx(gpe,{worktree:R.worktree,project:R.project,generatedAt:t.generatedAt})})]})]})}),s.jsx(T5,{open:k!=null,onClose:()=>N(null),side:"right",owner:"openscout.repos-diff-viewer",resizable:!0,defaultSize:840,maxSize:1280,minSize:420,ariaLabel:"Worktree diff",children:k!=null?s.jsx(Fk,{path:k,onClose:()=>N(null),onOpenAsPage:()=>{k&&(e({view:"repo-diff",path:k}),N(null))}},k):null})]})}):s.jsx(rd,{navigate:e})}function $pe({path:e,layers:t,navigate:n}){const r=e.trim();return r?s.jsx(Fk,{path:r,layers:t,onClose:()=>n({view:"repos"})},r):s.jsx("div",{className:"rd-viewer",children:s.jsx("div",{className:"rd-center",children:s.jsxs("div",{className:"rd-center-card",children:[s.jsx("div",{className:"rd-center-title",children:"No worktree path"}),s.jsxs("div",{className:"rd-center-body",children:["This page needs a ",s.jsx("code",{children:"?path=<absolute-path>"})," query parameter."]})]})})})}const qR=48,KR=720;function Lpe(e){if(!e||typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=JSON.parse(t);if(!n||typeof n!="object")return null;const r={};for(const[a,o]of Object.entries(n))typeof o=="number"&&Number.isFinite(o)&&o>0&&(r[a]=o);return r}catch{return null}}function Sb(e,t){if(e&&!(typeof window>"u"))try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function Ppe({storageKey:e,columns:t}){const n=m.useMemo(()=>{const v=Lpe(e)??{},y={};for(const b of t)y[b.key]=v[b.key]??b.defaultWidth;return y},[e,t]),[r,a]=m.useState(n);m.useEffect(()=>{a(v=>{let y=!1;const b={...v};for(const C of t)b[C.key]==null&&(b[C.key]=C.defaultWidth,y=!0);return y?b:v})},[t]);const o=m.useMemo(()=>{const v=new Map;for(const y of t)v.set(y.key,y);return v},[t]),c=m.useRef(null),u=m.useCallback(v=>{const y=c.current;if(!y)return;const b=v.clientX-y.startX,C=Math.min(y.max,Math.max(y.min,y.startWidth+b));a(E=>E[y.key]===C?E:{...E,[y.key]:C})},[]),f=m.useCallback(()=>{c.current&&(c.current=null,document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",f),a(v=>(Sb(e,v),v)))},[u,e]);m.useEffect(()=>()=>{window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",f)},[u,f]);const h=m.useCallback(v=>{const y=r[v],b=o.get(v),C=b?.minWidth??qR,E=b?.maxWidth??KR;return{style:{width:y,minWidth:C,maxWidth:E},"data-resize-key":v}},[r,o]),p=m.useCallback(v=>({onPointerDown:E=>{if(E.button!==0)return;E.preventDefault(),E.stopPropagation();const A=o.get(v),S=A?.minWidth??qR,k=A?.maxWidth??KR,N=r[v]??A?.defaultWidth??S;c.current={key:v,startX:E.clientX,startWidth:N,min:S,max:k},document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("pointermove",u),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",f)},onClick:E=>{E.stopPropagation()},onDoubleClick:E=>{E.preventDefault(),E.stopPropagation();const A=o.get(v);A&&a(S=>{const k={...S,[v]:A.defaultWidth};return Sb(e,k),k})},role:"separator","aria-orientation":"vertical","aria-label":"Resize column",className:"s-resize-handle"}),[r,o,u,f,e]),x=m.useCallback(()=>{a(()=>{const v={};for(const y of t)v[y.key]=y.defaultWidth;return Sb(e,v),v})},[t,e]);return{widths:r,getColumnProps:h,getResizeHandleProps:p,resetAll:x}}function Dpe(e){return e==="number"||e==="time"?"right":"left"}function GR(e){return e==="number"||e==="time"?-1:1}function e4(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"||typeof e=="bigint"?String(e):Array.isArray(e)?e.map(t=>e4(t)).join(""):""}function ZR(e,t){if(e.sortValue)return e.sortValue(t);const n=e.render(t),r=e4(n).trim();return r||null}function YR(e){if(typeof e=="number")return e;const t=Date.parse(e);return Number.isFinite(t)?t:Number.NaN}function zpe(e,t,n,r){const a=ZR(n,e),o=ZR(n,t);return a==null&&o==null?0:a==null?1:o==null?-1:n.kind==="number"?((Number(a)||0)-(Number(o)||0))*r:n.kind==="time"?(YR(a)-YR(o))*r:String(a).localeCompare(String(o),void 0,{numeric:!0,sensitivity:"base"})*r}function Bpe(e,t){return n=>{typeof e=="function"&&e(n),n.defaultPrevented||t?.(n)}}function Upe(e,t){return n=>{typeof e=="function"&&e(n),n.defaultPrevented||t?.(n)}}function Hk({rows:e,columns:t,rowId:n,storageKey:r,initialSort:a,sort:o,onSortChange:c,secondarySort:u,onRowClick:f,rowBindings:h,rowState:p,empty:x={title:"No rows"},rowClassName:v,density:y="comfortable",className:b,ariaLabel:C="Data table"}){const E=m.useMemo(()=>t.map(I=>{const z=I.kind??"text";return{...I,kind:z,align:I.align??Dpe(z),sortable:I.sortable??z!=="custom",resizable:I.resizable??!0}}),[t]),A=m.useMemo(()=>new Map(E.map(I=>[I.key,I])),[E]),[S,k]=m.useState(()=>{if(!a)return null;const z=t.find(_=>_.key===a.key)?.kind??"text";return{key:a.key,dir:a.dir??GR(z)}}),N=o??S,{getColumnProps:T,getResizeHandleProps:R}=Ppe({storageKey:r,columns:E.map(I=>({key:I.key,defaultWidth:I.defaultWidth,minWidth:I.minWidth,maxWidth:I.maxWidth}))}),O=m.useMemo(()=>{const I=e.map((_,U)=>({row:_,index:U}));if(!N)return I.map(_=>_.row);const z=A.get(N.key);return z?.sortable?I.slice().sort((_,U)=>{const D=zpe(_.row,U.row,z,N.dir);if(D!==0)return D;const q=u?.(_.row,U.row)??0;return q!==0?q:_.index-U.index}).map(_=>_.row):I.map(_=>_.row)},[e,N,A,u]),L=I=>{o==null&&k(I),c?.(I)};return s.jsx("div",{className:`dt-wrap dt-wrap--${y}${b?` ${b}`:""}`,children:s.jsxs("table",{className:"dt-table","aria-label":C,children:[s.jsx("thead",{children:s.jsx("tr",{children:E.map(I=>{const z=N?.key===I.key,_=z?N.dir===1?"ascending":"descending":"none",U=["dt-th",`dt-align-${I.align}`,I.cls,z?"dt-th--sorted":""].filter(Boolean).join(" ");return s.jsxs("th",{className:U,title:I.tip,"aria-sort":_,...T(I.key),children:[I.sortable?s.jsxs("button",{type:"button",className:"dt-th-sort",onClick:()=>{if(N?.key===I.key){L({key:I.key,dir:N.dir===1?-1:1});return}L({key:I.key,dir:GR(I.kind)})},children:[s.jsx("span",{className:"dt-th-label",children:I.label}),s.jsx("span",{className:`dt-th-arrow${z?" dt-th-arrow--active":""}`,"aria-hidden":"true",children:z?N?.dir===1?"↑":"↓":"↕"})]}):s.jsx("div",{className:"dt-th-static",children:s.jsx("span",{className:"dt-th-label",children:I.label})}),I.resizable?s.jsx("span",{...R(I.key)}):null]},I.key)})})}),s.jsx("tbody",{children:O.length===0?s.jsx("tr",{className:"dt-empty-row",children:s.jsx("td",{colSpan:E.length,children:s.jsxs("div",{className:"dt-empty",children:[s.jsx("div",{className:"dt-empty-title",children:x.title}),x.body?s.jsx("div",{children:x.body}):null]})})}):O.map(I=>{const z=n(I),_=h?.(z)??{},U=p?.(z)??{isActive:!1,isPinned:!1},D=!!(f||h),q=["dt-row",D?"dt-row--interactive":"",U.isActive?"dt-row--active":"",U.isPinned?"dt-row--pinned":"",v?.(I),typeof _.className=="string"?_.className:""].filter(Boolean).join(" "),Z=f?()=>f(I):void 0,$=D?Upe(_.onKeyDown,V=>{f&&(V.key==="Enter"||V.key===" ")&&(V.preventDefault(),f(I))}):typeof _.onKeyDown=="function"?_.onKeyDown:void 0,G={..._,className:q,onClick:Bpe(_.onClick,Z),onKeyDown:$};return D&&G.tabIndex==null&&(G.tabIndex=0),s.jsx("tr",{...G,children:E.map(V=>s.jsx("td",{className:["dt-td",`dt-align-${V.align}`,V.cls].filter(Boolean).join(" "),children:V.render(I)},V.key))},z)})})]})})}const Fpe=1e4,Vpe=500,XR=1e3,Hpe=6e4,Wpe=[{key:"status",label:"status",cls:"s-atop-col-status",kind:"text",sortable:!1,defaultWidth:96,minWidth:70,render:e=>s.jsxs("span",{className:`s-atop-status s-atop-status--${e.status}`,children:[s.jsx("span",{className:"s-atop-status-dot","aria-hidden":"true"}),e.statusLabel]})},{key:"session",label:"session",cls:"s-atop-col-agent",kind:"text",sortable:!1,defaultWidth:168,minWidth:110,maxWidth:280,render:e=>s.jsxs("div",{className:"s-atop-agent-cell",title:e.sessionId??e.refId,children:[s.jsx("span",{className:`s-atop-chip s-atop-chip--harness s-atop-chip--harness-${Kpe(e.source)}`,children:e.source}),s.jsx("span",{className:"s-atop-agent-id",children:e.refId.slice(0,8)})]})},{key:"project",label:"project",cls:"s-atop-col-project",kind:"text",sortable:!1,defaultWidth:200,minWidth:96,maxWidth:360,render:e=>s.jsx("span",{title:e.cwd??e.project,children:e.project})},{key:"updated",label:"updated",cls:"s-atop-col-last",kind:"time",sortable:!1,defaultWidth:86,minWidth:64,render:e=>s.jsx("span",{title:Ype(e.mtimeMs),children:Zpe(Math.max(e.mtimeMs,e.lastEvent?.ts??0),Date.now())})},{key:"size",label:"size",cls:"s-atop-col-runtime",kind:"number",sortable:!1,defaultWidth:80,minWidth:64,render:e=>Gpe(e.size)},{key:"path",label:"path",kind:"text",sortable:!1,defaultWidth:360,minWidth:160,maxWidth:800,render:e=>s.jsx("span",{title:e.transcriptPath,children:e.cwd??e.transcriptPath})}];function QR(e){const t=e?.trim();if(!t)return null;const n=t4(t);return n.endsWith(".jsonl")?n.slice(0,-6):n}function t4(e){const t=e.replace(/[\\/]+$/,"");return t.split(/[\\/]/).filter(Boolean).at(-1)??t}function qpe(e){const n=e.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean);return n.pop(),n.at(-1)??""}function Kpe(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function Gpe(e){if(!Number.isFinite(e)||e<0)return"-";if(e<1024)return`${e} B`;const t=e/1024;if(t<1024)return`${t.toFixed(t>=10?0:1)} KiB`;const n=t/1024;return`${n.toFixed(n>=10?0:1)} MiB`}function Zpe(e,t){if(!e)return"-";const n=Math.max(0,Math.round((t-e)/1e3));return n<2?"now":n<60?`${n}s`:n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}d`}function Ype(e){return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(e))}function Xpe(e,t){return t?[e.refId,e.sessionId??"",e.source,e.project,e.cwd??"",e.transcriptPath,e.lastEvent?.summary??"",e.process?.command??""].join(" ").toLowerCase().includes(t.toLowerCase()):!0}function JR(e){return`${e.source}\0${e.cwd??""}`}function Qpe(e){return`${e.source}\0${e.cwd??""}`}function Jpe(e,t,n){if(!e?.transcripts?.length)return[];const r=new Map;for(const o of t){const c=r.get(o.sessionId);(!c||o.ts>c.ts)&&r.set(o.sessionId,o)}const a=new Map;for(const o of e.processes){if(!o.cwd)continue;const c=a.get(JR(o));(!c||o.pid<c.pid)&&a.set(JR(o),o)}return e.transcripts.map(o=>{const c=QR(o.sessionId)??QR(o.transcriptPath);if(!c)return null;const u=o.sessionId?r.get(o.sessionId)??null:null,f=a.get(Qpe(o))??null,h=Math.max(o.mtimeMs,u?.ts??0),p=!!f||n-h<=Hpe,x=o.project?.trim()||(o.cwd?t4(o.cwd):qpe(o.transcriptPath))||"unknown";return{refId:c,source:o.source||"unknown",project:x,cwd:o.cwd,transcriptPath:o.transcriptPath,sessionId:o.sessionId,mtimeMs:o.mtimeMs,size:o.size,status:p?"run":"idle",statusLabel:p?"active":"idle",lastEvent:u,process:f}}).filter(o=>o!==null).sort((o,c)=>{const u=Math.max(o.mtimeMs,o.lastEvent?.ts??0);return Math.max(c.mtimeMs,c.lastEvent?.ts??0)-u||o.project.localeCompare(c.project)})}function ege({navigate:e}){const{route:t}=qe(),[n,r]=m.useState(null),[a,o]=m.useState([]),[c,u]=m.useState(""),[f,h]=m.useState("all"),[p,x]=m.useState(0),[v,y]=m.useState(null),[b,C]=m.useState(Date.now()),E=m.useRef(null),A=m.useCallback(async()=>{y(null);try{r(await ue("/api/tail/discover"))}catch(I){y(I instanceof Error?I.message:String(I))}},[]);m.useEffect(()=>{A();const I=setInterval(()=>{A()},Fpe);return()=>clearInterval(I)},[A]),m.useEffect(()=>{let I=!1;return(async()=>{try{const z=await ue(`/api/tail/recent?limit=${Vpe}`);I||o(z.events??[])}catch{}})(),()=>{I=!0}},[]),tu(I=>{o(z=>z.length>=XR?[...z.slice(z.length-XR+1),I]:[...z,I])}),m.useEffect(()=>{const I=setInterval(()=>C(Date.now()),15e3);return()=>clearInterval(I)},[]);const S=m.useMemo(()=>Jpe(n,a,b),[n,a,b]),k=m.useMemo(()=>[...new Set(S.map(I=>I.source))].sort(),[S]),N=m.useMemo(()=>S.filter(I=>(f==="all"||I.source===f)&&Xpe(I,c.trim())),[S,f,c]);m.useEffect(()=>{p>=N.length&&x(Math.max(0,N.length-1))},[N.length,p]);const T=m.useCallback(I=>{I&&wt(e,{view:"sessions",sessionId:I.refId},{returnTo:t})},[e,t]);m.useEffect(()=>{const I=z=>{const _=z.target,U=_ instanceof HTMLInputElement||_ instanceof HTMLTextAreaElement||(_?.isContentEditable??!1);if(z.key==="/"&&!U){z.preventDefault(),E.current?.focus();return}if(U){z.key==="Escape"&&_===E.current&&(u(""),E.current?.blur());return}if(z.key==="ArrowDown"||z.key==="j"){z.preventDefault(),x(D=>N.length===0?0:Math.min(N.length-1,D+1));return}if(z.key==="ArrowUp"||z.key==="k"){z.preventDefault(),x(D=>Math.max(0,D-1));return}(z.key==="Enter"||z.key==="o")&&(z.preventDefault(),T(N[p]))};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[N,p,T]);const R=v?[]:N,O=m.useCallback(I=>`${I.source}:${I.transcriptPath}`,[]),L=m.useMemo(()=>new Map(N.map((I,z)=>[O(I),z])),[N,O]);return s.jsxs("div",{className:"s-secondary-nav-shell",children:[s.jsx("div",{className:"s-secondary-nav-bar",children:s.jsx(kk,{activeRoute:t,navigate:e})}),s.jsx("div",{className:"s-secondary-nav-body",children:s.jsxs("div",{className:"s-atop s-atop--sessions",children:[s.jsxs("div",{className:"s-atop-fbar",children:[s.jsxs("label",{className:"s-atop-search",children:[s.jsx("span",{className:"s-atop-search-prompt",children:"/"}),s.jsx("input",{ref:E,className:"s-atop-search-input",placeholder:"filter sessions",value:c,onChange:I=>u(I.target.value)}),s.jsx("kbd",{className:"s-atop-search-kbd",children:"/"})]}),s.jsx("span",{className:"s-atop-fbar-label",children:"source"}),s.jsxs("button",{type:"button",className:`s-atop-pill${f==="all"?" s-atop-pill--on":""}`,onClick:()=>h("all"),children:["all",s.jsx("span",{className:"s-atop-pill-ct",children:S.length})]}),k.map(I=>s.jsxs("button",{type:"button",className:`s-atop-pill${f===I?" s-atop-pill--on":""}`,onClick:()=>h(I),children:[I,s.jsx("span",{className:"s-atop-pill-ct",children:S.filter(z=>z.source===I).length})]},I)),s.jsx("div",{className:"s-atop-fbar-spacer"})]}),s.jsx(Hk,{rows:R,columns:Wpe,rowId:O,storageKey:"openscout.sessions.cols",rowBindings:I=>({onMouseEnter:()=>{const z=L.get(I);z!=null&&x(z)},onFocus:()=>{const z=L.get(I);z!=null&&x(z)}}),onRowClick:I=>T(I),rowClassName:I=>L.get(O(I))===p?"s-atop-row--selected":void 0,empty:v?{title:"Discovery failed",body:v}:{title:"No raw sessions",body:c?"No sessions match the current filter.":"No transcript sessions were discovered."},density:"compact",className:"s-atop-data-table",ariaLabel:"Raw sessions"}),s.jsxs("div",{className:"s-atop-keys",children:[s.jsxs("span",{children:[s.jsx("kbd",{children:"/"}),"filter"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"j/k"}),"select"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"enter"}),"open"]}),s.jsx("span",{className:"s-atop-keys-spacer"}),s.jsxs("span",{className:"s-atop-keys-count",children:[s.jsx("strong",{children:N.length})," sessions"]})]})]})})]})}function wm(e){const t=e?.trim()??"",n=t.split(/[\\/]/).filter(Boolean).at(-1)??t;return n.endsWith(".jsonl")?n.slice(0,-6):n}function tge({sessionRef:e,navigate:t}){const[n,r]=m.useState(null),[a,o]=m.useState(!0),[c,u]=m.useState(null),f=m.useRef(null),h=m.useCallback(async()=>{u(null);try{const p=await ue(`/api/session-ref/${encodeURIComponent(e)}`);r(p)}catch(p){r(null),u(p instanceof Error?p.message:String(p))}finally{o(!1)}},[e]);return m.useEffect(()=>{o(!0),h()},[h]),Vt(()=>{h()}),tu(p=>{const x=wm(p.sessionId),v=wm(e),y=n?.kind==="observe"?wm(n.observe.sessionId??n.observe.refId):"",b=n?.kind==="observe"?wm(n.observe.data.metadata?.session?.externalSessionId):"";x!==v&&(!y||x!==y)&&(!b||x!==b)||(f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,h()},150))}),m.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]),n?.kind==="conversation"?s.jsx(eu,{conversationId:n.conversationId,navigate:t}):n?.kind==="observe"?s.jsx(qg,{data:n.observe.data,agentId:n.observe.agentId??n.session?.agentId??void 0,sessionId:n.observe.sessionId??n.observe.refId}):a?s.jsx("div",{className:"s-sessions-screen s-inbox-thread-redesign",children:s.jsx("section",{className:"s-thread-overview",children:s.jsxs("div",{className:"s-thread-overview-copy",children:[s.jsxs("div",{className:"s-sessions-header s-thread-overview-heading",children:[s.jsx("h2",{className:"s-page-title",children:"Session"}),s.jsx("span",{className:"s-meta s-tabular",children:e.slice(0,8)})]}),s.jsxs("p",{className:"s-thread-overview-summary s-session-ref-loading",children:[s.jsx("span",{className:"s-session-ref-loading-dot"}),s.jsx("span",{className:"s-session-ref-loading-dot"}),s.jsx("span",{className:"s-session-ref-loading-dot"}),"Resolving session reference"]})]})})}):s.jsx("div",{className:"s-sessions-screen s-inbox-thread-redesign",children:s.jsx("section",{className:"s-thread-overview",children:s.jsxs("div",{className:"s-thread-overview-copy",children:[s.jsxs("div",{className:"s-sessions-header s-thread-overview-heading",children:[s.jsx("h2",{className:"s-page-title",children:"Session not found"}),s.jsx("span",{className:"s-meta s-tabular",children:e.slice(0,8)})]}),s.jsx("p",{className:"s-thread-overview-summary",children:"This session may have ended or the archive is not available on this machine."}),c&&s.jsx("p",{className:"s-session-ref-error-detail",children:c}),s.jsx("div",{className:"s-session-ref-nav-hint",children:s.jsx(zr,{slot:"sessions",fallback:{view:"sessions"},navigate:t})})]})})})}var Do=(e=>(e[e.Border=-1]="Border",e[e.Data=0]="Data",e[e.Function=1]="Function",e[e.Position=2]="Position",e[e.Timing=3]="Timing",e[e.Alignment=4]="Alignment",e))(Do||{});const nge=[0,1],n4=[1,0],s4=[2,3],r4=[3,2],sge={L:nge,M:n4,Q:s4,H:r4},rge=/^\d*$/,age=/^[A-Z0-9 $%*+./:-]*$/,Cb="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Wk=1,qk=40,eI=3,ige=3,jm=40,oge=10,a4=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],i4=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]];class lge{constructor(t,n,r,a){if(this.version=t,this.ecc=n,t<Wk||t>qk)throw new RangeError("Version value out of range");if(a<-1||a>7)throw new RangeError("Mask value out of range");this.size=t*4+17;const o=Array.from({length:this.size}).fill(!1);for(let u=0;u<this.size;u++)this.modules.push(o.slice()),this.types.push(o.map(()=>0));this.drawFunctionPatterns();const c=this.addEccAndInterleave(r);if(this.drawCodewords(c),a===-1){let u=1e9;for(let f=0;f<8;f++){this.applyMask(f),this.drawFormatBits(f);const h=this.getPenaltyScore();h<u&&(a=f,u=h),this.applyMask(f)}}this.mask=a,this.applyMask(a),this.drawFormatBits(a)}size;mask;modules=[];types=[];getModule(t,n){return t>=0&&t<this.size&&n>=0&&n<this.size&&this.modules[n][t]}drawFunctionPatterns(){for(let r=0;r<this.size;r++)this.setFunctionModule(6,r,r%2===0,Do.Timing),this.setFunctionModule(r,6,r%2===0,Do.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const t=this.getAlignmentPatternPositions(),n=t.length;for(let r=0;r<n;r++)for(let a=0;a<n;a++)r===0&&a===0||r===0&&a===n-1||r===n-1&&a===0||this.drawAlignmentPattern(t[r],t[a]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){const n=this.ecc[1]<<3|t;let r=n;for(let o=0;o<10;o++)r=r<<1^(r>>>9)*1335;const a=(n<<10|r)^21522;for(let o=0;o<=5;o++)this.setFunctionModule(8,o,Ua(a,o));this.setFunctionModule(8,7,Ua(a,6)),this.setFunctionModule(8,8,Ua(a,7)),this.setFunctionModule(7,8,Ua(a,8));for(let o=9;o<15;o++)this.setFunctionModule(14-o,8,Ua(a,o));for(let o=0;o<8;o++)this.setFunctionModule(this.size-1-o,8,Ua(a,o));for(let o=8;o<15;o++)this.setFunctionModule(8,this.size-15+o,Ua(a,o));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let r=0;r<12;r++)t=t<<1^(t>>>11)*7973;const n=this.version<<12|t;for(let r=0;r<18;r++){const a=Ua(n,r),o=this.size-11+r%3,c=Math.floor(r/3);this.setFunctionModule(o,c,a),this.setFunctionModule(c,o,a)}}drawFinderPattern(t,n){for(let r=-4;r<=4;r++)for(let a=-4;a<=4;a++){const o=Math.max(Math.abs(a),Math.abs(r)),c=t+a,u=n+r;c>=0&&c<this.size&&u>=0&&u<this.size&&this.setFunctionModule(c,u,o!==2&&o!==4,Do.Position)}}drawAlignmentPattern(t,n){for(let r=-2;r<=2;r++)for(let a=-2;a<=2;a++)this.setFunctionModule(t+a,n+r,Math.max(Math.abs(a),Math.abs(r))!==1,Do.Alignment)}setFunctionModule(t,n,r,a=Do.Function){this.modules[n][t]=r,this.types[n][t]=a}addEccAndInterleave(t){const n=this.version,r=this.ecc;if(t.length!==fp(n,r))throw new RangeError("Invalid argument");const a=i4[r[0]][n],o=a4[r[0]][n],c=Math.floor(jw(n)/8),u=a-c%a,f=Math.floor(c/a),h=[],p=vge(o);for(let v=0,y=0;v<a;v++){const b=t.slice(y,y+f-o+(v<u?0:1));y+=b.length;const C=xge(b,p);v<u&&b.push(0),h.push(b.concat(C))}const x=[];for(let v=0;v<h[0].length;v++)h.forEach((y,b)=>{(v!==f-o||b>=u)&&x.push(y[v])});return x}drawCodewords(t){if(t.length!==Math.floor(jw(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let r=this.size-1;r>=1;r-=2){r===6&&(r=5);for(let a=0;a<this.size;a++)for(let o=0;o<2;o++){const c=r-o,f=(r+1&2)===0?this.size-1-a:a;!this.types[f][c]&&n<t.length*8&&(this.modules[f][c]=Ua(t[n>>>3],7-(n&7)),n++)}}}applyMask(t){if(t<0||t>7)throw new RangeError("Mask value out of range");for(let n=0;n<this.size;n++)for(let r=0;r<this.size;r++){let a;switch(t){case 0:a=(r+n)%2===0;break;case 1:a=n%2===0;break;case 2:a=r%3===0;break;case 3:a=(r+n)%3===0;break;case 4:a=(Math.floor(r/3)+Math.floor(n/2))%2===0;break;case 5:a=r*n%2+r*n%3===0;break;case 6:a=(r*n%2+r*n%3)%2===0;break;case 7:a=((r+n)%2+r*n%3)%2===0;break;default:throw new Error("Unreachable")}!this.types[n][r]&&a&&(this.modules[n][r]=!this.modules[n][r])}}getPenaltyScore(){let t=0;for(let o=0;o<this.size;o++){let c=!1,u=0;const f=[0,0,0,0,0,0,0];for(let h=0;h<this.size;h++)this.modules[o][h]===c?(u++,u===5?t+=eI:u>5&&t++):(this.finderPenaltyAddHistory(u,f),c||(t+=this.finderPenaltyCountPatterns(f)*jm),c=this.modules[o][h],u=1);t+=this.finderPenaltyTerminateAndCount(c,u,f)*jm}for(let o=0;o<this.size;o++){let c=!1,u=0;const f=[0,0,0,0,0,0,0];for(let h=0;h<this.size;h++)this.modules[h][o]===c?(u++,u===5?t+=eI:u>5&&t++):(this.finderPenaltyAddHistory(u,f),c||(t+=this.finderPenaltyCountPatterns(f)*jm),c=this.modules[h][o],u=1);t+=this.finderPenaltyTerminateAndCount(c,u,f)*jm}for(let o=0;o<this.size-1;o++)for(let c=0;c<this.size-1;c++){const u=this.modules[o][c];u===this.modules[o][c+1]&&u===this.modules[o+1][c]&&u===this.modules[o+1][c+1]&&(t+=ige)}let n=0;for(const o of this.modules)n=o.reduce((c,u)=>c+(u?1:0),n);const r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return t+=a*oge,t}getAlignmentPatternPositions(){if(this.version===1)return[];{const t=Math.floor(this.version/7)+2,n=this.version===32?26:Math.ceil((this.version*4+4)/(t*2-2))*2,r=[6];for(let a=this.size-7;r.length<t;a-=n)r.splice(1,0,a);return r}}finderPenaltyCountPatterns(t){const n=t[1],r=n>0&&t[2]===n&&t[3]===n*3&&t[4]===n&&t[5]===n;return(r&&t[0]>=n*4&&t[6]>=n?1:0)+(r&&t[6]>=n*4&&t[0]>=n?1:0)}finderPenaltyTerminateAndCount(t,n,r){return t&&(this.finderPenaltyAddHistory(n,r),n=0),n+=this.size,this.finderPenaltyAddHistory(n,r),this.finderPenaltyCountPatterns(r)}finderPenaltyAddHistory(t,n){n[0]===0&&(t+=this.size),n.pop(),n.unshift(t)}}function Ha(e,t,n){if(t<0||t>31||e>>>t)throw new RangeError("Value out of range");for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function Ua(e,t){return(e>>>t&1)!==0}class Kk{constructor(t,n,r){if(this.mode=t,this.numChars=n,this.bitData=r,n<0)throw new RangeError("Invalid argument");this.bitData=r.slice()}getData(){return this.bitData.slice()}}const cge=[1,10,12,14],uge=[2,9,11,13],dge=[4,8,16,16];function o4(e,t){return e[Math.floor((t+7)/17)+1]}function l4(e){const t=[];for(const n of e)Ha(n,8,t);return new Kk(dge,e.length,t)}function fge(e){if(!c4(e))throw new RangeError("String contains non-numeric characters");const t=[];for(let n=0;n<e.length;){const r=Math.min(e.length-n,3);Ha(Number.parseInt(e.substring(n,n+r),10),r*3+1,t),n+=r}return new Kk(cge,e.length,t)}function hge(e){if(!u4(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");const t=[];let n;for(n=0;n+2<=e.length;n+=2){let r=Cb.indexOf(e.charAt(n))*45;r+=Cb.indexOf(e.charAt(n+1)),Ha(r,11,t)}return n<e.length&&Ha(Cb.indexOf(e.charAt(n)),6,t),new Kk(uge,e.length,t)}function mge(e){return e===""?[]:c4(e)?[fge(e)]:u4(e)?[hge(e)]:[l4(gge(e))]}function c4(e){return rge.test(e)}function u4(e){return age.test(e)}function pge(e,t){let n=0;for(const r of e){const a=o4(r.mode,t);if(r.numChars>=1<<a)return Number.POSITIVE_INFINITY;n+=4+a+r.bitData.length}return n}function gge(e){e=encodeURI(e);const t=[];for(let n=0;n<e.length;n++)e.charAt(n)!=="%"?t.push(e.charCodeAt(n)):(t.push(Number.parseInt(e.substring(n+1,n+3),16)),n+=2);return t}function jw(e){if(e<Wk||e>qk)throw new RangeError("Version number out of range");let t=(16*e+128)*e+64;if(e>=2){const n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t}function fp(e,t){return Math.floor(jw(e)/8)-a4[t[0]][e]*i4[t[0]][e]}function vge(e){if(e<1||e>255)throw new RangeError("Degree out of range");const t=[];for(let r=0;r<e-1;r++)t.push(0);t.push(1);let n=1;for(let r=0;r<e;r++){for(let a=0;a<t.length;a++)t[a]=kw(t[a],n),a+1<t.length&&(t[a]^=t[a+1]);n=kw(n,2)}return t}function xge(e,t){const n=t.map(r=>0);for(const r of e){const a=r^n.shift();n.push(0),t.forEach((o,c)=>n[c]^=kw(o,a))}return n}function kw(e,t){if(e>>>8||t>>>8)throw new RangeError("Byte out of range");let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n}function yge(e,t,n=1,r=40,a=-1,o=!0){if(!(Wk<=n&&n<=r&&r<=qk)||a<-1||a>7)throw new RangeError("Invalid value");let c,u;for(c=n;;c++){const x=fp(c,t)*8,v=pge(e,c);if(v<=x){u=v;break}if(c>=r)throw new RangeError("Data too long")}for(const x of[n4,s4,r4])o&&u<=fp(c,x)*8&&(t=x);const f=[];for(const x of e){Ha(x.mode[0],4,f),Ha(x.numChars,o4(x.mode,c),f);for(const v of x.getData())f.push(v)}const h=fp(c,t)*8;Ha(0,Math.min(4,h-f.length),f),Ha(0,(8-f.length%8)%8,f);for(let x=236;f.length<h;x^=253)Ha(x,8,f);const p=Array.from({length:Math.ceil(f.length/8)},()=>0);return f.forEach((x,v)=>p[v>>>3]|=x<<7-(v&7)),new lge(c,t,p,a)}function bge(e,t){const{ecc:n="L",boostEcc:r=!1,minVersion:a=1,maxVersion:o=40,maskPattern:c=-1,border:u=1}=t||{},f=typeof e=="string"?mge(e):Array.isArray(e)?[l4(e)]:void 0;if(!f)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);const h=yge(f,sge[n],a,o,c,r),p=wge({version:h.version,maskPattern:h.mask,size:h.size,data:h.modules,types:h.types},u);return t?.invert&&(p.data=p.data.map(x=>x.map(v=>!v))),t?.onEncoded?.(p),p}function wge(e,t=1){if(!t)return e;const{size:n}=e,r=n+t*2;e.size=r,e.data.forEach(o=>{for(let c=0;c<t;c++)o.unshift(!1),o.push(!1)});for(let o=0;o<t;o++)e.data.unshift(Array.from({length:r},c=>!1)),e.data.push(Array.from({length:r},c=>!1));const a=Do.Border;e.types.forEach(o=>{for(let c=0;c<t;c++)o.unshift(a),o.push(a)});for(let o=0;o<t;o++)e.types.unshift(Array.from({length:r},c=>a)),e.types.push(Array.from({length:r},c=>a));return e}function tI(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function jge(e,t={}){const n=bge(e,t),{pixelSize:r=10,whiteColor:a="white",blackColor:o="black"}=t,c=n.size*r,u=n.size*r;let f=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${u} ${c}">`;const h=[];for(let p=0;p<n.size;p++)for(let x=0;x<n.size;x++){const v=x*r,y=p*r;n.data[p][x]&&h.push(`M${v},${y}h${r}v${r}h-${r}z`)}return f+=`<rect fill="${tI(a)}" width="${u}" height="${c}"/>`,f+=`<path fill="${tI(o)}" d="${h.join("")}"/>`,f+="</svg>",f}function Zg(e){switch(e){case"ready":case"running":case"available":case"enabled":return"sys-chip-success";case"configured":case"installed":case"working":return"sys-chip-warning";case"missing":case"offline":case"not_ready":case"error":return"sys-chip-danger";default:return"sys-chip-neutral"}}function Gk(e){switch(e){case"available":case"ready":return"ready";case"offline":case"not_ready":return"not ready";default:return e}}function d4(e){return e?e.replace(/^\/Users\/[^/]+/,"~"):"Not reported"}function kge(e){return e.length>0?e.join(", "):"No capabilities reported"}function Nge({runtime:e}){return s.jsxs("div",{className:"agent-config-row",children:[s.jsxs("div",{className:"agent-config-row-main",children:[s.jsx("span",{className:"agent-config-icon",children:s.jsx(H6,{size:14})}),s.jsxs("div",{className:"agent-config-row-copy",children:[s.jsx("div",{className:"agent-config-row-title",children:e.label}),s.jsx("div",{className:"agent-config-row-detail",children:e.description}),s.jsx("div",{className:"agent-config-row-meta",children:e.detail})]})]}),s.jsxs("div",{className:"agent-config-row-side",children:[s.jsx("span",{className:`sys-chip ${Zg(e.state)}`,children:e.state}),s.jsx("span",{className:"agent-config-row-meta",children:e.binaryPath??e.loginCommand??e.source})]})]})}function Sge({provider:e}){return s.jsxs("div",{className:"agent-config-row",children:[s.jsxs("div",{className:"agent-config-row-main",children:[s.jsx("span",{className:"agent-config-icon",children:s.jsx(S2,{size:14})}),s.jsxs("div",{className:"agent-config-row-copy",children:[s.jsx("div",{className:"agent-config-row-title",children:e.name}),s.jsx("div",{className:"agent-config-row-detail",children:e.protocol}),s.jsx("code",{className:"agent-config-code",children:e.baseUrl}),s.jsxs("div",{className:"agent-config-row-meta",children:["Keys: ",e.envKeys.join(", ")]}),s.jsx("div",{className:"agent-config-row-meta",children:e.note})]})]}),s.jsxs("div",{className:"agent-config-row-side",children:[s.jsx("span",{className:`sys-chip ${Zg(e.status)}`,children:e.status}),s.jsx("a",{className:"agent-config-link",href:e.docsUrl,target:"_blank",rel:"noreferrer",children:"Docs"})]})]})}function Cge({agent:e,selected:t,navigate:n}){return s.jsxs("button",{type:"button",className:`agent-config-row agent-config-row-button${t?" agent-config-row-selected":""}`,onClick:()=>n({view:"settings",section:"agents",agentId:e.id}),children:[s.jsxs("div",{className:"agent-config-row-main",children:[s.jsx("span",{className:"agent-config-icon",children:s.jsx(dg,{size:14})}),s.jsxs("div",{className:"agent-config-row-copy",children:[s.jsx("div",{className:"agent-config-row-title",children:e.name}),s.jsx("div",{className:"agent-config-row-detail",children:e.id}),s.jsxs("div",{className:"agent-config-row-meta",children:[e.harness??"unknown harness"," / ",e.transport??"unknown transport",e.model?` / ${e.model}`:""]})]})]}),s.jsxs("div",{className:"agent-config-row-side",children:[s.jsx("span",{className:`sys-chip ${Zg(e.status)}`,children:Gk(e.status)}),s.jsx("span",{className:"agent-config-row-meta",children:d4(e.projectRoot??e.cwd)})]})]})}function Ege({agent:e,navigate:t}){const{route:n}=qe();return e?s.jsxs("div",{className:"sys-panel agent-config-detail-panel",children:[s.jsxs("div",{className:"sys-section-head",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"sys-section-title",children:e.name}),s.jsx("p",{className:"sys-section-subtitle",children:e.id})]}),s.jsxs("div",{className:"sys-page-actions",children:[s.jsx("button",{type:"button",className:"s-btn",onClick:()=>t({view:"agents",agentId:e.id}),children:"Open Agent"}),s.jsx("button",{type:"button",className:"s-btn",onClick:()=>wt(t,{view:"conversation",conversationId:e.conversationId},{returnTo:n}),children:"Open DM"})]})]}),s.jsxs("div",{className:"agent-config-detail-grid",children:[s.jsxs("div",{children:[s.jsx("span",{className:"agent-config-label",children:"Status"}),s.jsx("span",{className:`sys-chip ${Zg(e.status)}`,children:Gk(e.status)})]}),s.jsxs("div",{children:[s.jsx("span",{className:"agent-config-label",children:"Harness"}),s.jsx("strong",{children:e.harness??"Not reported"})]}),s.jsxs("div",{children:[s.jsx("span",{className:"agent-config-label",children:"Transport"}),s.jsx("strong",{children:e.transport??"Not reported"})]}),s.jsxs("div",{children:[s.jsx("span",{className:"agent-config-label",children:"Model"}),s.jsx("strong",{children:e.model??"Not reported"})]}),s.jsxs("div",{className:"agent-config-detail-wide",children:[s.jsx("span",{className:"agent-config-label",children:"Project"}),s.jsx("code",{children:d4(e.projectRoot)})]}),s.jsxs("div",{className:"agent-config-detail-wide",children:[s.jsx("span",{className:"agent-config-label",children:"Capabilities"}),s.jsx("span",{children:kge(e.capabilities)})]})]})]}):s.jsxs("div",{className:"sys-panel agent-config-detail-panel",children:[s.jsx("div",{className:"sys-section-head",children:s.jsxs("div",{children:[s.jsx("h3",{className:"sys-section-title",children:"Agent Details"}),s.jsx("p",{className:"sys-section-subtitle",children:"Select an agent to inspect runtime, model, and tool context."})]})}),s.jsxs("div",{className:"sys-list-empty",children:[s.jsx("h3",{children:"No agent selected"}),s.jsx("p",{children:"Choose an agent from the configuration roster."})]})]})}function Age({navigate:e,selectedAgentId:t}){const{route:n}=qe(),[r,a]=m.useState(null),[o,c]=m.useState(!0),[u,f]=m.useState(!1),[h,p]=m.useState(null),x=m.useRef(0),v=m.useCallback(async(E="initial")=>{const A=++x.current;E==="initial"?c(!0):f(!0),p(null);try{const S=await ue("/api/agent-config/snapshot");if(A!==x.current)return;a(S)}catch(S){if(A!==x.current)return;p(S instanceof Error?S.message:String(S))}finally{A===x.current&&(c(!1),f(!1))}},[]);m.useEffect(()=>{v()},[v]);const y=m.useMemo(()=>r?r.agents.find(E=>E.id===t)??r.agents[0]??null:null,[t,r]),b=r?.providers??[],C=r?[{label:"Runtimes",value:String(r.runtimes.length),detail:`${r.runtimes.filter(E=>E.state==="ready").length} ready`},{label:"BYOK",value:String(b.length),detail:`${b.filter(E=>E.status==="configured").length} configured`},{label:"Agents",value:String(r.agents.length),detail:`${r.agents.filter(E=>Gk(E.status)!=="not ready").length} ready`},{label:"Broker",value:r.broker.label,detail:r.broker.nodeId??"No node id"}]:[];return s.jsxs("div",{className:"s-secondary-nav-shell",children:[s.jsx("div",{className:"s-secondary-nav-bar",children:s.jsx(kk,{activeRoute:n,navigate:e})}),s.jsx("div",{className:"s-secondary-nav-body s-secondary-nav-body--scroll",children:s.jsxs("div",{className:"sys-surface-page sys-surface-page-wide",children:[s.jsxs("div",{className:"sys-page-head",children:[s.jsxs("div",{className:"sys-page-title-group",children:[s.jsx("h2",{className:"sys-page-title",children:"Agent Configuration"}),s.jsx("p",{className:"sys-page-subtitle",children:"Runtimes, agents, project inventory, delivery bridges, and the missing tool/provider surfaces in one control plane."})]}),s.jsxs("div",{className:"sys-page-actions",children:[r&&s.jsxs("div",{className:"sys-sync-note",children:["Updated ",new Date(r.generatedAt).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})]}),s.jsxs("button",{type:"button",className:"s-btn",disabled:o||u,onClick:()=>{v("manual")},children:[s.jsx(zd,{size:13}),u?"Refreshing...":"Refresh"]})]})]}),r&&s.jsx("div",{className:"sys-stat-grid",children:C.map(E=>s.jsxs("div",{className:"sys-stat-card",children:[s.jsx("span",{className:"sys-stat-label",children:E.label}),s.jsx("strong",{className:"sys-stat-value",children:E.value}),s.jsx("span",{className:"sys-stat-detail",children:E.detail})]},E.label))}),h&&s.jsxs("div",{className:"sys-banner sys-banner-warning",children:[s.jsx("strong",{children:"Configuration snapshot failed."}),s.jsx("span",{children:h})]}),o&&!r&&s.jsx(hs,{title:"Loading configuration",body:"Reading Scout settings, runtime readiness, broker agents, and project inventory."}),r&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"agent-config-layout",children:[s.jsxs("div",{className:"sys-panel",children:[s.jsxs("div",{className:"sys-section-head",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"sys-section-title",children:"Runtimes"}),s.jsx("p",{className:"sys-section-subtitle",children:"Harness readiness replaces provider auth for the current local-first posture."})]}),s.jsx(gg,{size:15})]}),s.jsx("div",{className:"agent-config-list",children:r.runtimes.map(E=>s.jsx(Nge,{runtime:E},E.id))})]}),s.jsxs("div",{className:"sys-panel",children:[s.jsxs("div",{className:"sys-section-head",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"sys-section-title",children:"BYOK Providers"}),s.jsx("p",{className:"sys-section-subtitle",children:"OpenAI-compatible vendors OpenScout can discover from local environment configuration."})]}),s.jsx(S2,{size:15})]}),s.jsx("div",{className:"agent-config-list",children:b.map(E=>s.jsx(Sge,{provider:E},E.id))})]})]}),s.jsxs("div",{className:"agent-config-layout agent-config-layout-primary",children:[s.jsxs("div",{className:"sys-panel",children:[s.jsxs("div",{className:"sys-section-head",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"sys-section-title",children:"Agents"}),s.jsx("p",{className:"sys-section-subtitle",children:"Broker-visible endpoints with runtime, model, and source state."})]}),s.jsx(dg,{size:15})]}),s.jsx("div",{className:"agent-config-list agent-config-list-scroll",children:r.agents.length===0?s.jsxs("div",{className:"sys-list-empty",children:[s.jsx("h3",{children:"No agents registered"}),s.jsx("p",{children:"Run setup or start a local agent to populate this roster."})]}):r.agents.map(E=>s.jsx(Cge,{agent:E,selected:E.id===y?.id,navigate:e},E.id))})]}),s.jsx(Ege,{agent:y,navigate:e})]}),s.jsxs("div",{className:"agent-config-layout",children:[s.jsxs("div",{className:"sys-panel",children:[s.jsxs("div",{className:"sys-section-head",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"sys-section-title",children:"Tools & Context"}),s.jsx("p",{className:"sys-section-subtitle",children:"The next model boundary to make first-class."})]}),s.jsx(g8,{size:15})]}),s.jsx("p",{className:"agent-config-copy",children:r.toolContext.note}),s.jsxs("div",{className:"agent-config-chip-row",children:[s.jsxs("span",{className:"sys-chip sys-chip-neutral",children:[r.toolContext.mcpServerCount," MCP servers"]}),s.jsx("span",{className:"sys-chip sys-chip-warning",children:"loadouts pending"})]})]}),s.jsxs("div",{className:"sys-panel",children:[s.jsxs("div",{className:"sys-section-head",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"sys-section-title",children:"Broker & Delivery"}),s.jsx("p",{className:"sys-section-subtitle",children:"Control-plane state and bridges that route attention back to you."})]}),s.jsx(t8,{size:15})]}),s.jsxs("div",{className:"agent-config-detail-grid",children:[s.jsxs("div",{children:[s.jsx("span",{className:"agent-config-label",children:"Broker"}),s.jsx("span",{className:`sys-chip ${r.broker.healthy?"sys-chip-success":"sys-chip-danger"}`,children:r.broker.label})]}),s.jsxs("div",{children:[s.jsx("span",{className:"agent-config-label",children:"Messages"}),s.jsx("strong",{children:r.broker.messageCount})]}),r.integrations.map(E=>s.jsxs("div",{className:"agent-config-detail-wide",children:[s.jsx("span",{className:"agent-config-label",children:E.name}),s.jsx("span",{children:E.detail})]},E.id))]})]})]}),s.jsxs("div",{className:"sys-panel",children:[s.jsx("div",{className:"sys-section-head",children:s.jsxs("div",{children:[s.jsx("h3",{className:"sys-section-title",children:"Known Missing Pieces"}),s.jsx("p",{className:"sys-section-subtitle",children:"The configuration model is now visible; these are the next root-cause surfaces to build."})]})}),s.jsx("div",{className:"agent-config-gap-list",children:r.gaps.map(E=>s.jsx("span",{children:E},E))})]})]})]})})]})}function Tge(e){return e?e.replace(/^wss?:\/\//,"").replace(/:\d+$/,""):null}function nI(e){return e?e.length<=18?e:`${e.slice(0,10)}...${e.slice(-6)}`:null}function Mge(e,t){if(!e)return null;const n=Math.max(0,Math.floor((e-t)/1e3));if(n===0)return null;if(n<60)return`${n}s`;const r=Math.floor(n/60),a=n%60;return a>0?`${r}m ${a}s`:`${r}m`}function Rge(e){const t=e?.trim();return t?`scoutnext://pair?payload=${encodeURIComponent(t)}`:null}function Eb({value:e}){const[t,n]=m.useState(!1),r=m.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})},[e]);return s.jsx("button",{type:"button",className:"sys-copy-btn",onClick:r,title:"Copy",children:t?s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}):s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),s.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})}function Ige({navigate:e,section:t,agentId:n}){return t==="agents"?s.jsx(Age,{navigate:e,selectedAgentId:n}):s.jsx(_ge,{})}function _ge(){const[e,t]=m.useState(null),[n,r]=m.useState(""),[a,o]=m.useState(""),[c,u]=m.useState(!0),[f,h]=m.useState(!1),[p,x]=m.useState(!1),[v,y]=m.useState(null),[b,C]=m.useState(null),[E,A]=m.useState(null),[S,k]=m.useState(null),[N,T]=m.useState(()=>Date.now()),[R,O]=m.useState(null),L=m.useRef(null),I=m.useRef(0),z=m.useRef(null);m.useEffect(()=>{L.current=e},[e]),m.useEffect(()=>{z.current=v},[v]);const _=m.useCallback(async(ne="initial")=>{if(ne==="background"&&z.current)return;const X=++I.current;!(L.current!==null)&&ne!=="background"?(u(!0),C(null)):h(!0);try{const be=await ue(ne==="manual"?"/api/pairing-state/refresh":"/api/pairing-state");if(X!==I.current)return;t(be),C(null),k(Date.now())}catch(be){if(X!==I.current)return;C(be instanceof Error?be.message:String(be))}finally{X===I.current&&(u(!1),h(!1))}},[]),U=m.useCallback(async()=>{try{const ne=await ue("/api/user");o(ne.name),r(ne.name),A(null)}catch(ne){A(ne instanceof Error?ne.message:String(ne))}},[]),D=m.useRef(!1);m.useEffect(()=>{_("initial"),U()},[_,U]),m.useEffect(()=>{const ne=setInterval(()=>{_("background")},1e4);return()=>clearInterval(ne)},[_]),m.useEffect(()=>{if(!e?.pairing?.expiresAt)return;T(Date.now());const ne=setInterval(()=>{T(Date.now())},1e3);return()=>clearInterval(ne)},[e?.pairing?.expiresAt]);const q=m.useCallback(async()=>{x(!0),A(null);try{const ne=await ue("/api/user",{method:"POST",body:JSON.stringify({name:n})});o(ne.name),r(ne.name)}catch(ne){A(ne instanceof Error?ne.message:String(ne))}finally{x(!1)}},[n]),Z=m.useCallback(async ne=>{const X=++I.current;y(ne),C(null);try{const ae=await ue("/api/pairing/control",{method:"POST",body:JSON.stringify({action:ne})});if(X!==I.current)return;t(ae),k(Date.now())}catch(ae){if(X!==I.current)return;C(ae instanceof Error?ae.message:String(ae))}finally{X===I.current&&y(null)}},[]);m.useEffect(()=>{!e||e.isRunning||D.current||(D.current=!0,Z("start"))},[e,Z]);const $=m.useCallback(async ne=>{O(ne);try{await ue(`/api/pairing/peers/${encodeURIComponent(ne)}`,{method:"DELETE"}),_("manual")}catch{}finally{O(null)}},[_]),G=m.useMemo(()=>{const ne=e?.pairing?.qrValue?.trim();return ne?jge(ne,{border:2,ecc:"M",pixelSize:8}):null},[e?.pairing?.qrValue]),V=m.useMemo(()=>Rge(e?.pairing?.qrValue),[e?.pairing?.qrValue]),Y=Tge(e?.pairing?.relay??e?.relay??null),K=Mge(e?.pairing?.expiresAt,N),H=(e?.trustedPeers.find(ne=>ne.fingerprint===e.connectedPeerFingerprint)??null)?.name??nI(e?.connectedPeerFingerprint??null),B=Loe(e),Q=n.trim()!==a,oe=!c&&!e&&!!b;return s.jsxs("div",{className:"sys-surface-page sys-settings-page",children:[s.jsxs("div",{className:"sys-page-head",children:[s.jsxs("div",{className:"sys-page-title-group",children:[s.jsx("h2",{className:"sys-page-title",children:"Settings"}),s.jsx("p",{className:"sys-page-subtitle",children:"Identity, pairing, and trusted devices."})]}),s.jsxs("div",{className:"sys-page-actions",children:[e&&s.jsx(Wa,{tone:B,children:e.statusLabel}),s.jsx("div",{className:"sys-sync-note",children:c?"Loading...":b&&e?`Snapshot from ${S?Ie(S):"earlier"}`:S?`Updated ${Ie(S)}`:""}),s.jsx("button",{type:"button",className:"s-btn",disabled:c||f||!!v,onClick:()=>{_("manual")},children:f?"Refreshing...":"Refresh"})]})]}),b&&e&&s.jsxs("div",{className:"sys-banner sys-banner-warning",children:[s.jsx("strong",{children:"Refresh failed."}),s.jsx("span",{children:b})]}),E&&s.jsxs("div",{className:"sys-banner sys-banner-warning",children:[s.jsx("strong",{children:"Identity error."}),s.jsx("span",{children:E})]}),c&&!e&&s.jsx(hs,{title:"Loading settings",body:"Checking relay status and trusted peers."}),oe&&s.jsx(hs,{className:"sys-state-card-error",title:"Pairing unavailable",body:b,action:s.jsx("button",{type:"button",className:"s-btn",onClick:()=>{_("manual")},children:"Try again"})}),s.jsxs("div",{className:"sys-settings-hero",children:[s.jsx("div",{className:"sys-settings-qr-col",children:G?s.jsxs("div",{className:"sys-settings-qr-frame",children:[s.jsx("div",{className:"s-qr",dangerouslySetInnerHTML:{__html:G}}),K&&s.jsxs("span",{className:"sys-settings-qr-expires",children:["Expires in ",K]})]}):s.jsx("div",{className:"sys-settings-qr-empty",children:s.jsx("span",{className:"sys-settings-qr-empty-label",children:"Generating QR..."})})}),s.jsxs("div",{className:"sys-settings-info-col",children:[s.jsxs("div",{className:"sys-input-row",children:[s.jsx("input",{className:"sys-input",type:"text",placeholder:"Your name",value:n,onChange:ne=>r(ne.target.value),onKeyDown:ne=>{ne.key==="Enter"&&Q&&!p&&q()}}),s.jsx("button",{type:"button",className:"s-btn s-btn-primary",disabled:!Q||p,onClick:()=>{q()},children:p?"Saving...":"Save"})]}),s.jsxs("div",{className:"sys-settings-kv-list",children:[e?.identityFingerprint&&s.jsxs("div",{className:"sys-settings-kv",children:[s.jsx("span",{className:"sys-settings-kv-label",children:"Fingerprint"}),s.jsxs("span",{className:"sys-settings-kv-value",children:[s.jsx("code",{children:e.identityFingerprint}),s.jsx(Eb,{value:e.identityFingerprint})]})]}),Y&&s.jsxs("div",{className:"sys-settings-kv",children:[s.jsx("span",{className:"sys-settings-kv-label",children:"Relay"}),s.jsxs("span",{className:"sys-settings-kv-value",children:[s.jsx("code",{children:Y}),s.jsx(Eb,{value:Y})]})]}),V&&s.jsxs("div",{className:"sys-settings-kv",children:[s.jsx("span",{className:"sys-settings-kv-label",children:"Link"}),s.jsxs("span",{className:"sys-settings-kv-value",children:[s.jsx("a",{className:"sys-settings-link",href:V,title:V,"aria-label":"Open ScoutNext pairing link",children:s.jsx("code",{children:"scoutnext://pair"})}),s.jsx(Eb,{value:V})]})]}),e?.statusDetail&&s.jsxs("div",{className:"sys-settings-kv",children:[s.jsx("span",{className:"sys-settings-kv-label",children:"Status"}),s.jsx("span",{className:"sys-settings-kv-value sys-settings-kv-nowrap",children:e.statusDetail})]}),H&&s.jsxs("div",{className:"sys-settings-kv",children:[s.jsx("span",{className:"sys-settings-kv-label",children:"Connected"}),s.jsx("span",{className:"sys-settings-kv-value",children:H})]}),e?.secure&&s.jsxs("div",{className:"sys-settings-kv",children:[s.jsx("span",{className:"sys-settings-kv-label",children:"Security"}),s.jsx("span",{className:"sys-settings-kv-value",children:s.jsx(Wa,{tone:"success",children:"Noise XX"})})]})]}),e&&s.jsx("div",{className:"sys-inline-actions sys-settings-controls",children:e.isRunning?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"s-btn",disabled:!!v,onClick:()=>{Z("restart")},children:v==="restart"?"Restarting...":"Restart"}),s.jsx("button",{type:"button",className:"s-btn",disabled:!!v,onClick:()=>{Z("stop")},children:v==="stop"?"Stopping...":"Stop"})]}):s.jsx("button",{type:"button",className:"s-btn s-btn-primary",disabled:!!v,onClick:()=>{Z("start")},children:v==="start"?"Starting...":"Start pairing"})})]})]}),e&&s.jsxs("section",{className:"sys-settings-peers",children:[s.jsx("div",{className:"sys-section-head",children:s.jsxs("div",{children:[s.jsx("h3",{className:"sys-section-title",children:"Trusted peers"}),s.jsxs("p",{className:"sys-section-subtitle",children:[e.trustedPeers.length," device",e.trustedPeers.length!==1?"s":""," paired with this broker."]})]})}),e.trustedPeers.length===0?s.jsxs("div",{className:"sys-list-empty",children:[s.jsx("h3",{children:"No trusted peers"}),s.jsx("p",{children:"Devices appear here after completing pairing."})]}):s.jsxs("table",{className:"sys-peers-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Device"}),s.jsx("th",{children:"Fingerprint"}),s.jsx("th",{children:"Paired"}),s.jsx("th",{children:"Last seen"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:e.trustedPeers.map(ne=>{const X=ne.fingerprint===e.connectedPeerFingerprint;return s.jsxs("tr",{className:X?"sys-peers-row-connected":"",children:[s.jsx("td",{children:s.jsxs("span",{className:"sys-peers-name",children:[ne.name??nI(ne.fingerprint)??"Peer",X&&s.jsx(Wa,{tone:"success",className:"sys-peers-badge",children:"Connected"})]})}),s.jsx("td",{children:s.jsx("code",{className:"sys-peers-fp",children:ne.fingerprint})}),s.jsx("td",{children:ne.pairedAtLabel??"—"}),s.jsx("td",{children:ne.lastSeenLabel??"—"}),s.jsx("td",{children:s.jsx("button",{type:"button",className:"sys-peers-remove",disabled:R===ne.fingerprint,onClick:()=>{$(ne.fingerprint)},title:"Remove peer",children:R===ne.fingerprint?"...":"Remove"})})]},ne.fingerprint)})})]})]})]})}let Ld={hover:null,content:null};const Nw=new Set;function Oge(){for(const e of Nw)e()}function $ge(e){return Nw.add(e),()=>{Nw.delete(e)}}function sI(){return Ld}function Lge(){return m.useSyncExternalStore($ge,sI,sI)}function rI(e){Ld.hover!==e&&(Ld={...Ld,hover:e},Oge())}function Yo(e){return!e||!e.route&&!e.label?{onPointerEnter:void 0,onPointerLeave:void 0}:{onPointerEnter:()=>rI(e),onPointerLeave:()=>{Ld.hover===e&&rI(null)}}}const Pge=220;function Dge(){const e=Lge(),t=!!(e.hover||e.content),[n,r]=m.useState(t?{hover:e.hover,content:e.content}:null),[a,o]=m.useState(t?"enter":"hidden"),c=m.useRef(null);if(m.useEffect(()=>{if(t){c.current&&(clearTimeout(c.current),c.current=null),r({hover:e.hover,content:e.content}),o(p=>p==="show"?"show":"enter");const h=requestAnimationFrame(()=>o("show"));return()=>cancelAnimationFrame(h)}return o("leave"),c.current=setTimeout(()=>{o("hidden"),r(null),c.current=null},Pge),()=>{c.current&&(clearTimeout(c.current),c.current=null)}},[t,e.hover,e.content]),a==="hidden"||!n)return null;const u=n.hover?.label??n.hover?.route??null,f=n.hover?.label&&n.hover?.route?n.hover.route:null;return s.jsxs("div",{className:`s-page-status s-page-status--${a}`,role:"status","aria-live":"polite",children:[s.jsx("div",{className:"s-page-status-left",children:u&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"s-page-status-arrow","aria-hidden":!0,children:"→"}),s.jsx("span",{className:"s-page-status-target",children:u}),f&&s.jsx("span",{className:"s-page-status-route",children:f})]})}),s.jsx("div",{className:"s-page-status-right",children:n.content&&s.jsx("span",{className:"s-page-status-content",children:n.content})})]})}const sg=[{label:"15m",value:15*6e4},{label:"1h",value:60*6e4},{label:"24h",value:1440*6e4}];let Ut={activityFilter:"all",sourceFilter:"all",recentWindowMs:sg[1].value,groupMode:"activity",query:"",focusedId:null,canvasFocusRequest:null,visibleAgents:[],selectedIds:[]};const Sw=new Set;let aI=0;function Fr(){for(const e of Sw)e()}function f4(e){Ut.activityFilter!==e&&(Ut={...Ut,activityFilter:e},Fr())}function h4(e){Ut.sourceFilter!==e&&(Ut={...Ut,sourceFilter:e},Fr())}function m4(e){Ut.recentWindowMs!==e&&(Ut={...Ut,recentWindowMs:e},Fr())}function zge(e){Ut.groupMode!==e&&(Ut={...Ut,groupMode:e},Fr())}function rg(e){Ut.query!==e&&(Ut={...Ut,query:e},Fr())}function Bge(e){Ut.focusedId!==e&&(Ut={...Ut,focusedId:e},Fr())}function Uge(e){aI+=1,Ut={...Ut,canvasFocusRequest:{id:e,serial:aI}},Fr()}function Fge(e){Ut.canvasFocusRequest?.serial===e&&(Ut={...Ut,canvasFocusRequest:null},Fr())}function Vge(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const r=e[n],a=t[n];if(r.id!==a.id||r.state!==a.state||r.updatedAt!==a.updatedAt||r.activity!==a.activity||r.lastActiveAt!==a.lastActiveAt)return!1}return!0}function Hge(e){Vge(Ut.visibleAgents,e)||(Ut={...Ut,visibleAgents:e},Fr())}function ic(e){const t=Ut.selectedIds.includes(e);Ut={...Ut,selectedIds:t?Ut.selectedIds.filter(n=>n!==e):[...Ut.selectedIds,e]},Fr()}function hp(){Ut.selectedIds.length!==0&&(Ut={...Ut,selectedIds:[]},Fr())}function Wge(e){return Sw.add(e),()=>{Sw.delete(e)}}function qge(){return Ut}function p4(){return m.useSyncExternalStore(Wge,qge)}function iI(e,t){if(!t)return!0;const n=t.trim().toLowerCase();return n?[e.name,e.handle,e.project,e.branch,e.harness,e.id].filter(a=>!!a).map(a=>a.toLowerCase()).some(a=>a.includes(n)):!0}const Kge=2500,Gge=1e4;function Zge(e){const[t,n]=m.useState({}),r=m.useRef(!0),a=m.useRef(!1),o=m.useRef(!1),c=e.map(h=>h.id.trim()).filter(h=>h.length>0).join(","),u=e.some(h=>Ge(h.state)==="working")?Kge:Gge,f=m.useCallback(async()=>{if(e.length===0){n({});return}if(a.current){o.current=!0;return}a.current=!0;try{const h=c?`?ids=${encodeURIComponent(c)}`:"",p=await ue(`/api/observe/agents${h}`);if(!r.current)return;n(x=>{const v={};for(const y of e)v[y.id]=x[y.id];for(const y of p){const{agentId:b,...C}=y;v[b]=C}return v})}finally{a.current=!1,o.current&&(o.current=!1,f())}},[c,e]);return m.useEffect(()=>{if(r.current=!0,e.length===0)return n({}),()=>{r.current=!1};f();const h=setInterval(()=>{f()},u);return()=>{r.current=!1,clearInterval(h)}},[e.length,f,u]),t}function Yge(e){switch(e.kind){case"tool":return`${e.tool??"tool"} ${e.arg??""}`.trim();case"think":return e.text.slice(0,120);case"ask":return`ask: ${e.text}`.slice(0,120);case"message":return e.text.slice(0,100);case"note":return e.text.slice(0,100);case"system":case"boot":return e.text.slice(0,100)}}const Uo=420,Uc=320,Ql=20,Xge=48,Qge=36,oI=28,km=40,lI=72,Jge=.35,eve=1.15,tve=244,nve=160,sve=6e4;function rve(e,t,n){return Math.max(t,Math.min(n,e))}const g4="scout_mc_vp";function ave(e){try{localStorage.setItem(g4,JSON.stringify(e))}catch{}}function ive(){try{const e=localStorage.getItem(g4);if(!e)return null;const t=JSON.parse(e);if(typeof t?.zoom=="number"&&typeof t?.pan?.x=="number"&&typeof t?.pan?.y=="number")return t}catch{}return null}function ove(e,t,n){const r=uve(e,t,n);if(r.length===0)return{groups:[],canvasW:0,canvasH:0};const a=Math.max(1,Math.round(Math.sqrt(r.length*1.2))),o=[],c=new Array(a).fill(km),u=Array.from({length:a},(p,x)=>km+x*(Uo*2+Ql+Xge));for(const p of r){const x=c.indexOf(Math.min(...c)),v=u[x],y=c[x],b=Math.min(2,p.subjects.length),C=Math.ceil(p.subjects.length/b),E=b*Uo+(b-1)*Ql,A=oI+C*Uc+(C-1)*Ql,S=p.subjects.map((k,N)=>({agentId:k.id,x:v+N%b*(Uo+Ql),y:y+oI+Math.floor(N/b)*(Uc+Ql)}));o.push({label:p.label,x:v,y,w:E,h:A,tiles:S}),c[x]=y+A+Qge}const f=Math.max(...u.map(p=>p+Uo*2+Ql))+km,h=Math.max(...c)+km;return{groups:o,canvasW:f,canvasH:h}}function lf(e){switch(e){case"active":return 0;case"recent":return 1;default:return 2}}function lve(e,t,n){return t==="workspace"?e.group:e.activity==="active"?"Active now":e.activity==="recent"?`Recent ${n}`:e.group}function cve(e,t){const n=lf(e.activity),r=lf(t.activity);return n!==r?n-r:e.lastActiveAt!==t.lastActiveAt?t.lastActiveAt-e.lastActiveAt:e.stateRank!==t.stateRank?e.stateRank-t.stateRank:e.name.localeCompare(t.name)}function cI(e,t){if(t==="activity"){if(e.label==="Active now")return 0;if(e.label.startsWith("Recent "))return 1}return Math.min(...e.subjects.map(n=>lf(n.activity)))}function uve(e,t,n){const r=[...e].sort((c,u)=>cve(c,u)),a=new Map;for(const c of r){const u=lve(c,t,n);a.has(u)||a.set(u,[]),a.get(u).push(c)}const o=[];for(const[c,u]of a)o.push({label:c,subjects:u});return o.sort((c,u)=>{const f=cI(c,t)-cI(u,t);if(f!==0)return f;const h=Math.max(...u.subjects.map(p=>p.lastActiveAt))-Math.max(...c.subjects.map(p=>p.lastActiveAt));return h!==0?h:u.subjects.length!==c.subjects.length?u.subjects.length-c.subjects.length:c.label.localeCompare(u.label)}),o}function dve(e,t){const n={working:0,ready:1,not_ready:2},r=Ge(e.state),a=t?.current?"active":t?.recent?"recent":"idle";return{id:e.id,name:e.name,group:e.project??"unassigned",stateRank:n[r]??1,activity:a,lastActiveAt:t?.lastActiveAt??e.updatedAt??0}}function fve(e){return{id:e.id,name:e.agent.name,group:`native ${e.transcript.source}`,stateRank:e.current?0:1,activity:e.current?"active":e.recent?"recent":"idle",lastActiveAt:e.lastActiveAt}}function hve(e){const t=new Map;for(const n of e)n.agentId&&t.set(n.agentId,(t.get(n.agentId)??0)+1);return t}function mve(e){const t=new Map;for(const n of e)!n.agentId||!n.lastMessageAt||t.set(n.agentId,Math.max(t.get(n.agentId)??0,n.lastMessageAt));return t}function pve(e){const t=e?.data.metadata?.session?.sessionStart;if(typeof t!="number"||!Number.isFinite(t))return 0;const n=Math.max(0,...(e?.data.events??[]).map(r=>r.t));return n>0?t+n*1e3:t}function gve(e,t,n){return Math.max(n.get(e.id)??0,pve(t),Ge(e.state)==="working"?e.updatedAt??0:0)}function vve(e,t){return Ge(e.state)==="working"||t?.data.live===!0||(t?.data.events??[]).some(n=>n.live===!0)}function Cw(e){return e?.current?"active":e?.recent?"recent":"idle"}function Zk(e,t){const n=lf(Cw(e))-lf(Cw(t));return n!==0?n:(t?.lastActiveAt??0)-(e?.lastActiveAt??0)}function xve(e,t,n){const r=Zk(n.get(e.id),n.get(t.id));if(r!==0)return r;const a={working:0,ready:1,not_ready:2},o=(a[Ge(e.state)]??1)-(a[Ge(t.state)]??1);return o!==0?o:e.name.localeCompare(t.name)}function yve(e,t){const n=Zk(e,t);return n!==0?n:e.agent.name.localeCompare(t.agent.name)}function bve(e){return e?e.replace(/\.jsonl$/u,"").slice(0,8):"session"}function wve(e){return e?`${e[0]?.toUpperCase()}${e.slice(1)}`:"Native"}function jve(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function ag(e){const t=e.sessionId?.trim()||"session";return`native:${e.source}:${t}:${jve(e.transcriptPath)}`}function kve(e){switch(e){case"assistant":return"message";case"tool":case"tool-result":return"tool";case"user":return"ask";case"system":return"system";default:return"note"}}const Nve=5*6e4;function Sve(e,t,n){const r=t.slice(-12),a=r.map((c,u)=>({id:c.id,t:u,kind:kve(c.kind),text:c.summary,tool:c.kind==="tool"||c.kind==="tool-result"?c.source:void 0,detail:`${c.source} · ${c.harness}`,live:n&&u===r.length-1}));return{events:a.length>0?a:Date.now()-e.mtimeMs<=Nve?[{id:`${ag(e)}:discovered`,t:0,kind:"system",text:`Native ${e.source} transcript discovered.`,detail:e.cwd??e.transcriptPath}]:[],files:[],live:n,metadata:{session:{adapterType:e.source,externalSessionId:e.sessionId??void 0,threadPath:e.transcriptPath,cwd:e.cwd??void 0,originator:e.harness,source:"tail"}}}}function Cve(e,t,n){return{id:ag(e),name:`${wve(e.source)} · ${e.project}`,handle:bve(e.sessionId),agentClass:"native-session",harness:e.source,state:n?"working":"ready",projectRoot:e.cwd,cwd:e.cwd,updatedAt:t,createdAt:null,transport:"tail",selector:null,wakePolicy:null,capabilities:[],project:e.project,branch:e.harness==="unattributed"?"native session":e.harness,role:"native session",model:null,harnessSessionId:e.sessionId,harnessLogPath:e.transcriptPath,conversationId:ag(e),homeNodeId:null,homeNodeName:null,ownerId:null,ownerName:null,ownerHandle:null}}const Eve={think:"var(--dim)",tool:"var(--accent)",ask:"var(--amber)",message:"var(--muted)",note:"var(--green)",system:"var(--dim)",boot:"var(--dim)"},Yk={think:"think",tool:"tool",ask:"ask",message:"msg",note:"note",system:"sys",boot:"boot"};function Ave({navigate:e,agents:t}){const n=p4(),{activityFilter:r,sourceFilter:a,recentWindowMs:o,groupMode:c,query:u,focusedId:f,canvasFocusRequest:h}=n,p=f4,x=h4,v=m4,y=zge,b=Bge,[C,E]=m.useState([]),[A,S]=m.useState(null),[k,N]=m.useState([]),[T,R]=m.useState(Date.now()),O=Zge(t);tu(ie=>{N(ce=>ce.length>=500?[...ce.slice(ce.length-499),ie]:[...ce,ie])}),m.useEffect(()=>{const ie=setInterval(()=>R(Date.now()),1e4);return()=>clearInterval(ie)},[]),m.useEffect(()=>{let ie=!1;const ce=async()=>{try{const[Be,tt,at]=await Promise.allSettled([ue("/api/conversations"),ue("/api/tail/discover"),ue("/api/tail/recent?limit=500")]);if(ie)return;Be.status==="fulfilled"?E(Be.value):E([]),tt.status==="fulfilled"&&S(tt.value),at.status==="fulfilled"&&N(at.value.events??[])}catch{ie||(E([]),S(null))}};ce();const Ae=setInterval(()=>{ce()},3e4);return()=>{ie=!0,clearInterval(Ae)}},[]);const L=m.useRef(null),[I,z]=m.useState({w:0,h:0}),[_,U]=m.useState({x:0,y:0}),[D,q]=m.useState(1),[Z,$]=m.useState(!1),G=m.useRef(!1),V=m.useRef({x:0,y:0,panX:0,panY:0}),Y=m.useRef(!1);m.useEffect(()=>{const ie=L.current;if(!ie)return;const ce=new ResizeObserver(([Ae])=>{z({w:Ae.contentRect.width,h:Ae.contentRect.height})});return ce.observe(ie),()=>ce.disconnect()},[]);const K=m.useMemo(()=>hve(C),[C]),P=m.useMemo(()=>mve(C),[C]),H=m.useMemo(()=>{const ie=new Map;for(const ce of t){const Ae=O[ce.id],Be=gve(ce,Ae,P),tt=vve(ce,Ae);ie.set(ce.id,{lastActiveAt:Be,current:tt,recent:tt||Be>0&&T-Be<=o})}return ie},[t,T,O,o,P]),B=m.useMemo(()=>{const ie=new Set(t.map(Ae=>Ae.harnessSessionId?.trim()).filter(Ae=>!!Ae)),ce=new Map;for(const Ae of k){const Be=ce.get(Ae.sessionId)??[];Be.push(Ae),ce.set(Ae.sessionId,Be)}return(A?.transcripts??[]).filter(Ae=>Ae.harness!=="scout-managed").filter(Ae=>{const Be=Ae.sessionId?.trim();return!Be||!ie.has(Be)}).slice(0,80).map(Ae=>{const Be=Ae.sessionId?ce.get(Ae.sessionId)??[]:[],tt=Math.max(0,...Be.map(nt=>nt.ts)),at=Math.max(tt,Ae.mtimeMs),Oe=at>0&&T-at<=sve,He=Oe||at>0&&T-at<=o,ot=Sve(Ae,Be,Oe);return{id:ag(Ae),transcript:Ae,events:Be,agent:Cve(Ae,at,Oe),observe:ot,lastActiveAt:at,current:Oe,recent:He}})},[t,T,o,A?.transcripts,k]),Q=m.useMemo(()=>{if(a==="native")return[];let ie=t;return r!=="all"&&(ie=ie.filter(ce=>{const Ae=H.get(ce.id);return r==="active"?Ae?.current:Ae?.recent})),u.trim()&&(ie=ie.filter(ce=>iI({name:ce.name,handle:ce.handle,project:ce.project,branch:ce.branch,harness:ce.harness,id:ce.id},u))),[...ie].sort((ce,Ae)=>xve(ce,Ae,H))},[H,r,t,u,a]),oe=m.useMemo(()=>{if(a==="scout")return[];let ie=B;return r!=="all"&&(ie=ie.filter(ce=>r==="active"?ce.current:ce.recent)),u.trim()&&(ie=ie.filter(ce=>iI({name:ce.agent.name,handle:ce.agent.handle,project:ce.agent.project,branch:ce.agent.branch,harness:ce.agent.harness,id:ce.agent.id},u))),[...ie].sort(yve)},[r,B,u,a]);m.useEffect(()=>{const ie=[...Q.map(ce=>({activity:Cw(H.get(ce.id)),lastActiveAt:H.get(ce.id)?.lastActiveAt??null,id:ce.id,name:ce.name,handle:ce.handle,harness:ce.harness,branch:ce.branch,project:ce.project,model:ce.model,state:ce.state,agentClass:ce.agentClass,updatedAt:ce.updatedAt,source:"scout"})),...oe.map(ce=>({activity:ce.current?"active":ce.recent?"recent":"idle",lastActiveAt:ce.lastActiveAt,id:ce.agent.id,name:ce.agent.name,handle:ce.agent.handle,harness:ce.agent.harness,branch:ce.agent.branch,project:ce.agent.project,model:ce.agent.model,state:ce.agent.state,agentClass:ce.agent.agentClass,updatedAt:ce.agent.updatedAt,source:"native"}))].sort((ce,Ae)=>{const Be=Zk({current:ce.activity==="active",recent:ce.activity!=="idle",lastActiveAt:ce.lastActiveAt??0},{current:Ae.activity==="active",recent:Ae.activity!=="idle",lastActiveAt:Ae.lastActiveAt??0});return Be!==0?Be:ce.name.localeCompare(Ae.name)});Hge(ie)},[H,Q,oe]);const ne=m.useMemo(()=>sg.find(ie=>ie.value===o)?.label??"recent",[o]),X=m.useMemo(()=>[...Q.map(ie=>dve(ie,H.get(ie.id))),...oe.map(fve)],[H,Q,oe]),ae=m.useMemo(()=>ove(X,c,ne),[X,c,ne]),be=m.useRef([]),[_e,xe]=m.useState(null),pe=m.useRef(null),te=m.useCallback((ie=!0)=>{if(ae.canvasW===0||I.w===0)return;be.current.forEach(clearTimeout),xe(null);const ce=Math.min(1,I.w/ae.canvasW,I.h/ae.canvasH),Ae=Math.max(.15,Math.min(1,ce*.92));$(!1),q(Ae),U({x:(I.w-ae.canvasW*Ae)/2,y:Math.max(8,(I.h-ae.canvasH*Ae)/2)});const Be=setTimeout(()=>{$(!0);const at=ie?ive():null;at?(U(at.pan),q(at.zoom)):(U({x:24,y:24}),q(.55))},700),tt=setTimeout(()=>$(!1),1700);be.current=[Be,tt]},[ae,I]),ve=m.useCallback(()=>{if(ae.canvasW===0||I.w===0)return;be.current.forEach(clearTimeout),xe(null);const ie=Math.min(1,I.w/ae.canvasW,I.h/ae.canvasH),ce=Math.max(.15,Math.min(1,ie*.92));$(!0),q(ce),U({x:(I.w-ae.canvasW*ce)/2,y:Math.max(8,(I.h-ae.canvasH*ce)/2)});const Ae=setTimeout(()=>$(!1),500);be.current=[Ae]},[ae,I]);m.useEffect(()=>{ae.canvasW===0||I.w===0||Y.current||(Y.current=!0,te(!1))},[ae,I,te]),m.useEffect(()=>{const ie=setInterval(()=>{ave({pan:_,zoom:D})},3e4);return()=>clearInterval(ie)},[_,D]);const he=m.useCallback(ie=>{ie.target.closest(".s-mission-tile")||(G.current=!0,V.current={x:ie.clientX,y:ie.clientY,panX:_.x,panY:_.y})},[_]),ke=m.useCallback(ie=>{G.current&&U({x:V.current.panX+(ie.clientX-V.current.x),y:V.current.panY+(ie.clientY-V.current.y)})},[]),Ne=m.useCallback(()=>{G.current=!1},[]);m.useEffect(()=>{const ie=L.current;if(!ie)return;const ce=Ae=>{Ae.preventDefault();const Be=ie.getBoundingClientRect(),tt=Ae.clientX-Be.left,at=Ae.clientY-Be.top,Oe=Ae.deltaY>0?.92:1.08,He=Math.max(.2,Math.min(2,D*Oe)),ot=He/D;U(nt=>({x:tt-(tt-nt.x)*ot,y:at-(at-nt.y)*ot})),q(He)};return ie.addEventListener("wheel",ce,{passive:!1}),()=>ie.removeEventListener("wheel",ce)},[D]);const Fe=f?t.find(ie=>ie.id===f)??oe.find(ie=>ie.agent.id===f)?.agent??null:null;m.useEffect(()=>{const ie=ce=>{const Ae=ce.target;if(!(Ae.tagName==="INPUT"||Ae.tagName==="TEXTAREA"||Ae.isContentEditable)){if(ce.key==="Escape"){f?b(null):n.selectedIds.length>0&&hp();return}if((ce.metaKey||ce.ctrlKey)&&ce.key==="a"){if(n.visibleAgents.length===0)return;ce.preventDefault();const tt=n.visibleAgents.map(Oe=>Oe.id);if(tt.length>0&&tt.every(Oe=>n.selectedIds.includes(Oe)))hp();else for(const Oe of tt)n.selectedIds.includes(Oe)||ic(Oe);return}(ce.key==="h"||ce.key==="H")&&te(!1)}};return window.addEventListener("keydown",ie),()=>window.removeEventListener("keydown",ie)},[Fe,f,n.selectedIds,n.visibleAgents,te]);const Ee=m.useCallback(ie=>{const ce=L.current;ce&&(be.current.forEach(clearTimeout),xe(null),U({x:ce.clientWidth/2-ie.x*D,y:ce.clientHeight/2-ie.y*D}))},[D]),Le=m.useMemo(()=>{const ie={};for(const ce of ae.groups)for(const Ae of ce.tiles)ie[Ae.agentId]={x:Ae.x,y:Ae.y};return ie},[ae]),Te=m.useCallback(ie=>{const ce=Le[ie];if(!ce||I.w===0||I.h===0)return!1;be.current.forEach(clearTimeout);const Ae=(I.w-lI*2)/Uo,Be=(I.h-lI*2)/Uc,tt=rve(Math.min(Ae,Be),Jge,eve),at={x:I.w/2-(ce.x+Uo/2)*tt,y:I.h/2-(ce.y+Uc/2)*tt};$(!0),q(tt),U(at),xe(ie);const Oe=setTimeout(()=>$(!1),650),He=setTimeout(()=>xe(null),1800);return be.current=[Oe,He],!0},[Le,I]);m.useEffect(()=>{h&&pe.current!==h.serial&&Te(h.id)&&(pe.current=h.serial,Fge(h.serial))},[h,Te]);const Pe=Q.filter(ie=>H.get(ie.id)?.current).length+oe.filter(ie=>ie.current).length,De=(a==="native"?0:t.filter(ie=>H.get(ie.id)?.recent).length)+(a==="scout"?0:B.filter(ie=>ie.recent).length),ze=Q.reduce((ie,ce)=>ie+(K.get(ce.id)??0),0)+oe.length,$e=Q.length+oe.length,st=t.length+B.length,rt=m.useMemo(()=>[...Q,...oe.map(ie=>ie.agent)],[Q,oe]),Xe=m.useMemo(()=>$e>0?{id:"ops-control",render:({isCollapsed:ie,onToggleCollapse:ce})=>s.jsx(Pve,{layout:ae,agents:rt,pan:_,zoom:D,viewportRef:L,isCollapsed:ie,onToggleCollapse:ce,onFitAll:ve,onHome:()=>te(!1),onClick:Ee})}:null,[ve,ae,rt,Ee,_,te,$e,D]);lne(Xe);const dt=m.useMemo(()=>{const ie=new Set(t.map(ce=>ce.id));return n.selectedIds.filter(ce=>ie.has(ce))},[t,n.selectedIds]),jt=m.useMemo(()=>{const ie=new Set(oe.map(ce=>ce.id));return n.selectedIds.filter(ce=>ie.has(ce))},[n.selectedIds,oe]),At=jt.length,mt=dt.length+jt.length,Ht=c==="activity"?"group":"workspace";return s.jsxs("div",{className:"s-mission",children:[s.jsxs("div",{className:"s-mission-bar",children:[s.jsxs("span",{className:"s-mission-bar-label",children:[$e,"/",st," tile",st!==1?"s":""," ·"," ",ze," session",ze!==1?"s":""," ·"," ",ae.groups.length," ",Ht,ae.groups.length!==1?"s":""]}),s.jsxs("span",{className:`s-mission-bar-live${Pe===0?" s-mission-bar-live--idle":""}`,children:[s.jsx("span",{className:"s-mission-bar-live-dot"}),Pe," active now"]}),s.jsx("div",{className:"s-mission-bar-search",children:s.jsx("input",{type:"text",className:"s-mission-bar-search-input",placeholder:"Search agents… (press /)",value:u,onChange:ie=>rg(ie.target.value),onKeyDown:ie=>{ie.key==="Escape"&&(u?rg(""):ie.target.blur())}})}),s.jsxs("div",{className:"s-mission-controls",role:"group","aria-label":"Agent activity filter",children:[s.jsx("button",{type:"button",className:`s-mission-filter${r==="all"?" s-mission-filter--active":""}`,onClick:()=>p("all"),children:"All"}),s.jsx("button",{type:"button",className:`s-mission-filter${r==="active"?" s-mission-filter--active":""}`,onClick:()=>p("active"),children:"Active now"}),s.jsxs("button",{type:"button",className:`s-mission-filter${r==="recent"?" s-mission-filter--active":""}`,onClick:()=>p("recent"),children:["Recent ",De]})]}),s.jsxs("div",{className:"s-mission-controls",role:"group","aria-label":"Session source filter",children:[s.jsx("button",{type:"button",className:`s-mission-filter${a==="all"?" s-mission-filter--active":""}`,onClick:()=>x("all"),children:"All sources"}),s.jsx("button",{type:"button",className:`s-mission-filter${a==="scout"?" s-mission-filter--active":""}`,onClick:()=>x("scout"),children:"Scout"}),s.jsxs("button",{type:"button",className:`s-mission-filter${a==="native"?" s-mission-filter--active":""}`,onClick:()=>x("native"),children:["Native ",B.length]})]}),s.jsxs("div",{className:"s-mission-controls",role:"group","aria-label":"Canvas grouping",children:[s.jsx("button",{type:"button",className:`s-mission-filter${c==="activity"?" s-mission-filter--active":""}`,onClick:()=>y("activity"),children:"Activity first"}),s.jsx("button",{type:"button",className:`s-mission-filter${c==="workspace"?" s-mission-filter--active":""}`,onClick:()=>y("workspace"),children:"Workspace"})]}),r==="recent"&&s.jsx("div",{className:"s-mission-controls",role:"group","aria-label":"Recent activity window",children:sg.map(ie=>s.jsx("button",{type:"button",className:`s-mission-filter s-mission-filter--compact${o===ie.value?" s-mission-filter--active":""}`,onClick:()=>v(ie.value),children:ie.label},ie.value))}),s.jsxs("div",{className:"s-mission-hotkeys",children:[n.selectedIds.length>0&&s.jsxs("div",{className:"s-mission-selection",role:"group","aria-label":"Selected agent actions",children:[s.jsxs("span",{className:"s-mission-selection-count",children:[n.selectedIds.length," selected"]}),At>0&&s.jsxs("span",{className:"s-mission-selection-note",children:[dt.length," Scout · ",At," native"]}),s.jsx(Hg,{agentIds:dt,nativeSessionIds:jt,className:"s-mission-selection-action s-mission-selection-action--vantage",statusClassName:"s-mission-selection-status",label:"Open in Vantage",openingLabel:"Opening...",disabled:mt===0,title:mt>0?"Open selected sessions in the native Vantage canvas":"Select Scout agents or native sessions to open in Vantage"}),s.jsx("button",{type:"button",className:"s-mission-selection-action",onClick:hp,children:"Clear"})]}),s.jsxs("button",{className:"s-mission-hotkey s-mission-hotkey--btn",onClick:()=>te(!1),title:"Reset to overview",children:[s.jsx("kbd",{children:"H"})," Home"]}),s.jsxs("span",{className:"s-mission-hotkey",children:[s.jsx("kbd",{children:"Esc"})," Close focus"]})]})]}),s.jsx("div",{ref:L,className:"s-mission-viewport",onMouseDown:he,onMouseMove:ke,onMouseUp:Ne,onMouseLeave:Ne,children:st===0?s.jsxs("div",{className:"s-mission-empty",children:[s.jsx("div",{className:"s-mission-empty-title",children:"No agents connected"}),s.jsx("div",{className:"s-mission-empty-sub",children:"Agents appear here as they join the mesh."}),s.jsx("div",{className:"s-mission-empty-hint",children:s.jsx("code",{children:"scout watch --as myagent"})})]}):$e===0?s.jsxs("div",{className:"s-mission-empty",children:[s.jsx("div",{className:"s-mission-empty-title",children:"No matching sessions"}),s.jsx("div",{className:"s-mission-empty-sub",children:"Try another activity filter or recent window."})]}):s.jsxs("div",{className:"s-mission-canvas",style:{transform:`translate(${_.x}px, ${_.y}px) scale(${D})`,transition:Z?"transform 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94)":"none"},children:[ae.groups.map(ie=>s.jsx("div",{className:["s-mission-group-label",ie.label==="Active now"&&"s-mission-group-label--active",ie.label.startsWith("Recent ")&&"s-mission-group-label--recent"].filter(Boolean).join(" "),style:{left:ie.x,top:ie.y},children:ie.label},ie.label)),Q.map(ie=>{const ce=Le[ie.id];if(!ce)return null;const Ae=O[ie.id],Be=n.selectedIds.includes(ie.id);return s.jsx(uI,{agent:ie,observe:Ae?.data??null,x:ce.x,y:ce.y,selected:Be,canvasFocused:_e===ie.id,onToggleSelected:()=>ic(ie.id),onClick:tt=>{tt.metaKey||tt.ctrlKey||tt.shiftKey?ic(ie.id):b(ie.id)}},ie.id)}),oe.map(ie=>{const ce=Le[ie.id];if(!ce)return null;const Ae=n.selectedIds.includes(ie.id);return s.jsx(uI,{agent:ie.agent,observe:ie.observe,x:ce.x,y:ce.y,selected:Ae,canvasFocused:_e===ie.id,onToggleSelected:()=>ic(ie.id),onClick:Be=>{Be.metaKey||Be.ctrlKey||Be.shiftKey?ic(ie.id):b(ie.id)}},ie.id)})]})}),Fe&&s.jsx(Tve,{agent:Fe,observe:O[Fe.id]?.data??null,onClose:()=>b(null),onSend:async(ie,ce)=>{await ue(ce==="ask"?"/api/ask":"/api/send",{method:"POST",body:JSON.stringify({body:ie,conversationId:Qn(Fe.id)})})},onOpenConversation:()=>{b(null),e({view:"conversation",conversationId:Qn(Fe.id)})},onTail:()=>{b(null),e({view:"ops",mode:"tail",tailQuery:Fe.handle??Fe.name})},onProfile:()=>{b(null),e({view:"agents",agentId:Fe.id})}})]})}function uI({agent:e,observe:t,x:n,y:r,selected:a=!1,canvasFocused:o=!1,onToggleSelected:c,onClick:u}){const f=m.useRef(null),h=Ge(e.state),p=Xt(e.name),x=t?.events??[],v=x.slice(-8),y=t?.live===!0,b=x.some(N=>N.kind==="ask"&&!N.answer),C=t?.contextUsage,E=C&&C.length>0?Math.round(C[C.length-1]*100):null,A=x.filter(N=>N.kind==="tool").length,S=x.filter(N=>N.kind==="tool"&&N.tool==="edit").length,k=Yo({label:`Focus ${e.handle??e.name}`,route:`/ops/control · ${e.id}`});return m.useEffect(()=>{f.current&&(f.current.scrollTop=f.current.scrollHeight)},[x.length]),s.jsxs("div",{className:["s-mission-tile",h==="working"?"s-mission-tile--working":null,b?"s-mission-tile--asking":null,a?"s-mission-tile--selected":null,o?"s-mission-tile--canvas-focused":null].filter(Boolean).join(" "),style:{left:n,top:r,height:Uc},onClick:N=>{N.stopPropagation(),u(N)},onPointerEnter:k.onPointerEnter,onPointerLeave:k.onPointerLeave,children:[s.jsxs("div",{className:"s-mission-tile-header",children:[s.jsx("button",{type:"button",className:`s-mission-select${a?" s-mission-select--selected":""}`,"aria-pressed":a,title:a?"Remove from selection":"Select for batch actions",onClick:N=>{N.stopPropagation(),c()}}),s.jsx("div",{className:"s-ops-avatar",style:{"--size":"22px",background:p},children:e.name[0]?.toUpperCase()}),s.jsxs("div",{className:"s-mission-tile-identity",children:[s.jsxs("div",{className:"s-mission-tile-name",children:[e.name,s.jsx("span",{className:"s-mission-tile-handle",children:e.handle?`@${e.handle}`:""})]}),s.jsxs("div",{className:"s-mission-tile-meta",children:[e.project??"—"," · ",e.branch??"main"]})]}),s.jsx("span",{className:"s-ops-state-chip",style:{color:Dve(h)},children:cs(e.state).toUpperCase()})]}),s.jsx("div",{className:"s-mission-tile-stream",ref:f,children:v.length===0?s.jsx("div",{className:"s-mission-tile-stream-inner",children:s.jsxs("div",{className:"s-mission-evt",children:[s.jsx("span",{className:"s-mission-evt-bead",style:{background:"var(--dim)"}}),s.jsx("span",{className:"s-mission-evt-text",style:{color:"var(--dim)"},children:h==="not_ready"?"No session data":"Waiting for events…"})]})}):s.jsx("div",{className:"s-mission-tile-stream-inner",children:v.map(N=>s.jsxs("div",{className:"s-mission-evt",children:[s.jsx("span",{className:"s-mission-evt-bead",style:{background:Eve[N.kind]??"var(--dim)"}}),s.jsx("span",{className:"s-mission-evt-kind",children:Yk[N.kind]??N.kind}),s.jsxs("span",{className:`s-mission-evt-text s-mission-evt-text--${N.kind}`,children:[Yge(N),N.live&&s.jsx("span",{className:"s-observe-cursor"})]})]},N.id))})}),s.jsxs("div",{className:"s-mission-tile-footer",children:[E!==null&&s.jsx("div",{className:"s-mission-tile-ctx",title:`Context: ${E}%`,children:s.jsx("div",{className:"s-mission-tile-ctx-fill",style:{width:`${E}%`}})}),s.jsxs("div",{className:"s-mission-tile-stats",children:[A>0&&s.jsxs("span",{children:[A," tools"]}),S>0&&s.jsxs("span",{children:[S," edits"]})]}),y&&s.jsxs("span",{className:"s-mission-tile-live",children:[s.jsx("span",{className:"s-mission-tile-live-dot"}),"LIVE"]})]})]})}function Tve({agent:e,observe:t,onClose:n,onSend:r,onOpenConversation:a,onTail:o,onProfile:c}){const u=Xt(e.name),{ref:f,onKeyDown:h}=fD(),[p,x]=m.useState("profile"),v=y=>{if(h(y),y.defaultPrevented)return;const b=y.target;b instanceof HTMLInputElement||b instanceof HTMLTextAreaElement||(b?.isContentEditable??!1)||(y.key==="1"?(y.preventDefault(),x("profile")):y.key==="2"?(y.preventDefault(),x("activity")):y.key==="3"&&(y.preventDefault(),x("message")))};return s.jsx("div",{className:"s-mission-overlay",onClick:n,children:s.jsxs("div",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"mission-overlay-title",onClick:y=>y.stopPropagation(),onKeyDown:v,tabIndex:-1,className:"s-mission-overlay-dialog",children:[s.jsxs("div",{className:"s-mission-overlay-header",children:[s.jsx("div",{className:"s-ops-avatar",style:{"--size":"28px",background:u},children:e.name[0]?.toUpperCase()}),s.jsxs("div",{className:"s-mission-overlay-identity",children:[s.jsxs("div",{className:"s-mission-overlay-name",id:"mission-overlay-title",children:[e.name," ",s.jsx("span",{className:"s-mission-overlay-handle",children:e.handle?`@${e.handle}`:""})]}),s.jsxs("div",{className:"s-mission-overlay-meta",children:[e.project??"—"," · ",e.branch??"main"," · ",cs(e.state)]})]}),s.jsx("button",{className:"s-mission-overlay-close",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"✕"})]}),s.jsxs("div",{className:"s-mission-overlay-tabs",role:"tablist",children:[s.jsxs("div",{className:"s-mission-overlay-tabs-group",children:[s.jsx("button",{type:"button",role:"tab","aria-selected":p==="profile",className:`s-mission-overlay-tab${p==="profile"?" s-mission-overlay-tab--active":""}`,onClick:()=>x("profile"),children:"Profile"}),s.jsx("button",{type:"button",role:"tab","aria-selected":p==="activity",className:`s-mission-overlay-tab${p==="activity"?" s-mission-overlay-tab--active":""}`,onClick:()=>x("activity"),children:"Activity"}),s.jsx("button",{type:"button",role:"tab","aria-selected":p==="message",className:`s-mission-overlay-tab${p==="message"?" s-mission-overlay-tab--active":""}`,onClick:()=>x("message"),children:"Message"})]}),s.jsxs("div",{className:"s-mission-overlay-tabs-action",children:[p==="profile"&&s.jsx("button",{type:"button",className:"s-mission-overlay-jump",onClick:c,...Yo({label:`Open profile · ${e.handle??e.name}`,route:`/agents/${e.id}`}),children:"Open profile ↗"}),p==="activity"&&s.jsx("button",{type:"button",className:"s-mission-overlay-jump",onClick:o,...Yo({label:`Tail · ${e.handle??e.name}`,route:`/ops/tail?q=${encodeURIComponent(e.handle??e.name)}`}),children:"Open in Tail ↗"}),p==="message"&&s.jsx("button",{type:"button",className:"s-mission-overlay-jump",onClick:a,...Yo({label:`Open conversation with ${e.handle??e.name}`,route:`/c/${e.conversationId}`}),children:"Open conversation ↗"})]})]}),s.jsxs("div",{className:"s-mission-overlay-body",children:[p==="profile"&&s.jsx(Mve,{agent:e}),p==="activity"&&s.jsx(Ove,{agent:e,observe:t,onOpenConversation:a,onMessage:()=>x("message")}),p==="message"&&s.jsx(Lve,{agent:e,onSend:r,onOpenConversation:a})]})]})})}function Mve({agent:e}){const t=[["MODEL",[e.harness,e.model].filter(Boolean).join("/")||"—"],["AT",[e.project,e.branch].filter(Boolean).join("/")||"—"],["CWD",e.cwd||e.projectRoot||"—"],["AGENT",e.agentClass||"—"],["ROLE",e.role||e.transport||"—"],["MACHINE",e.authorityNodeName??e.homeNodeName??e.authorityNodeId??e.homeNodeId??"—"],["OWNER",e.ownerHandle??e.ownerName??e.ownerId??"—"],["SPAWNED",e.createdAt?Ie(e.createdAt):"—"],["STATE",cs(e.state)]];return s.jsx("div",{className:"s-focus-tab",children:s.jsx("dl",{className:"s-focus-spec",children:t.map(([n,r])=>s.jsxs("div",{className:"s-focus-spec-row",children:[s.jsx("dt",{className:"s-focus-spec-label",children:n}),s.jsx("dd",{className:"s-focus-spec-value",title:r,children:r})]},n))})})}const Rve={tool:"▸",think:"·",ask:"?",message:"✉",note:"•",system:"◇",boot:"↑"};function Ive(e,t){if(t){const r=Date.now()-(t+e*1e3);return r<6e4?`${Math.max(0,Math.round(r/1e3))}s`:r<36e5?`${Math.round(r/6e4)}m`:r<864e5?`${Math.round(r/36e5)}h`:`${Math.round(r/864e5)}d`}const n=Math.max(0,Math.round(e));return n<60?`${n}s`:n<3600?`${Math.round(n/60)}m`:`${Math.round(n/3600)}h`}function _ve(e){if(e.kind==="tool"){const t=e.tool??"tool";return e.arg?`${t} · ${e.arg}`:t}return e.kind==="ask"?e.text||"asked something":e.text||e.detail||Yk[e.kind]||e.kind}function Ove({agent:e,observe:t,onOpenConversation:n,onMessage:r}){const a=t?.events??[],o=t?.metadata?.usage,c=typeof t?.metadata?.session?.sessionStart=="number"?(t?.metadata?.session).sessionStart:null,u=a.slice(-14).reverse(),f=o?.assistantMessages??a.filter(y=>y.kind==="message").length,h=a.filter(y=>y.kind==="tool").length,p=a.filter(y=>y.kind==="tool"&&(y.tool==="edit"||y.tool==="write")).length,x=t?.contextUsage&&t.contextUsage.length>0?Math.round(t.contextUsage[t.contextUsage.length-1]*100):null,v=x!==null?`${x}%`:o?.contextWindowTokens&&o?.totalTokens?`${Math.round(o.totalTokens/o.contextWindowTokens*100)}%`:"—";return s.jsxs("div",{className:"s-focus-tab s-focus-tab--activity-preview",children:[s.jsxs("dl",{className:"s-focus-stats",children:[s.jsx(Nm,{label:"Turns",value:f||"—"}),s.jsx(Nm,{label:"Tools",value:h||"—"}),s.jsx(Nm,{label:"Edits",value:p||"—"}),s.jsx(Nm,{label:"Context",value:v})]}),u.length===0?s.jsx($ve,{agent:e,onOpenConversation:n,onMessage:r}):s.jsx("ul",{className:"s-focus-activity-list",children:u.map(y=>s.jsxs("li",{className:`s-focus-activity-row s-focus-activity-row--${y.kind}`,children:[s.jsx("span",{className:"s-focus-activity-time",children:Ive(y.t,c)}),s.jsx("span",{className:"s-focus-activity-glyph","aria-hidden":!0,children:Rve[y.kind]??"·"}),s.jsx("span",{className:"s-focus-activity-kind",children:Yk[y.kind]??y.kind}),s.jsx("span",{className:"s-focus-activity-text",children:_ve(y)})]},y.id))})]})}function $ve({agent:e,onOpenConversation:t,onMessage:n}){const r=e.role?.trim(),a=[e.harness,e.model].filter(Boolean).join("/"),o=[e.project,e.branch].filter(Boolean).join("/"),c=Ge(e.state),u=cs(c),f=e.createdAt?Ie(e.createdAt):null,h=e.updatedAt?Ie(e.updatedAt):null,p=e.homeNodeName??e.homeNodeId,x=e.ownerHandle??e.ownerName??e.ownerId,v=[];return r&&v.push({label:"Role",value:r}),a&&v.push({label:"Stack",value:a}),o&&v.push({label:"At",value:o}),p&&v.push({label:"Home",value:p}),x&&v.push({label:"Owner",value:x}),f&&v.push({label:"Spawned",value:f}),v.push({label:"State",value:u}),h&&v.push({label:"Last seen",value:h}),s.jsxs("div",{className:"s-focus-activity-empty s-focus-activity-empty--rich",children:[s.jsxs("div",{className:"s-focus-activity-empty-head",children:[s.jsx("span",{className:"s-focus-activity-empty-eyebrow",children:"No tool or turn events recorded"}),s.jsx("span",{className:"s-focus-activity-empty-title",children:e.handle??e.name})]}),s.jsx("dl",{className:"s-focus-activity-empty-facts",children:v.map(y=>s.jsxs("div",{className:"s-focus-activity-empty-fact",children:[s.jsx("dt",{children:y.label}),s.jsx("dd",{title:y.value,children:y.value})]},y.label))}),s.jsxs("div",{className:"s-focus-activity-empty-actions",children:[s.jsx("button",{type:"button",className:"s-focus-activity-empty-btn",onClick:t,...Yo({label:`Open conversation with ${e.handle??e.name}`,route:`/c/${e.conversationId}`}),children:"Open conversation ↗"}),s.jsx("button",{type:"button",className:"s-focus-activity-empty-btn s-focus-activity-empty-btn--primary",onClick:n,...Yo({label:`Compose message · ${e.handle??e.name}`}),children:"Send a message"})]})]})}function Nm({label:e,value:t}){return s.jsxs("div",{className:"s-focus-stat",children:[s.jsx("dt",{className:"s-focus-stat-label",children:e}),s.jsx("dd",{className:"s-focus-stat-value",children:t})]})}function Lve({agent:e,onSend:t,onOpenConversation:n}){const[r,a]=m.useState(""),[o,c]=m.useState(!1),[u,f]=m.useState(null),[h,p]=m.useState(null),x=m.useRef(null);m.useEffect(()=>{x.current?.focus()},[]);const v=async E=>{const A=r.trim();if(!(!A||o)){c(!0),p(null);try{await t(A,E),a(""),f(E),setTimeout(()=>f(null),1800)}catch(S){p(S instanceof Error?S.message:String(S))}finally{c(!1)}}},y=E=>{(E.metaKey||E.ctrlKey)&&E.key==="Enter"&&(E.preventDefault(),E.shiftKey?v("ask"):v("tell"))},b=e.handle??e.name,C=r.trim().length>0&&!o;return s.jsx("div",{className:"s-focus-tab",children:s.jsxs("div",{className:"s-focus-compose",children:[s.jsxs("label",{className:"s-focus-compose-label",htmlFor:"s-focus-compose-input",children:["Message ",s.jsxs("span",{className:"s-focus-compose-target",children:["@",b]})]}),s.jsx("textarea",{id:"s-focus-compose-input",ref:x,className:"s-focus-compose-input",placeholder:`Steer @${b}… (⌘↩ to Steer · ⌘⇧↩ to Ask)`,rows:6,value:r,onChange:E=>a(E.target.value),onKeyDown:y,disabled:o}),s.jsxs("div",{className:"s-focus-compose-foot",children:[s.jsx("div",{className:"s-focus-compose-hint",children:h?s.jsxs("span",{className:"s-focus-compose-error",children:["Send failed: ",h]}):u==="tell"?s.jsxs("span",{className:"s-focus-compose-ok",children:["Steered ↗ ",s.jsx("button",{type:"button",className:"s-focus-compose-link",onClick:n,children:"Open thread"})]}):u==="ask"?s.jsxs("span",{className:"s-focus-compose-ok",children:["Asked ↗ ",s.jsx("button",{type:"button",className:"s-focus-compose-link",onClick:n,children:"Open thread"})]}):s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:"Steer"})," redirects what they're doing. ",s.jsx("strong",{children:"Ask"})," waits for a structured answer."]})}),s.jsxs("div",{className:"s-focus-compose-actions",children:[s.jsx(wk,{onAppend:E=>a(A=>A.trim()?`${A.trimEnd()} ${E}`:E)}),s.jsx("button",{type:"button",className:"s-ops-btn",onClick:()=>{v("ask")},disabled:!C,children:"Ask"}),s.jsx("button",{type:"button",className:"s-ops-btn s-ops-btn--primary",onClick:()=>{v("tell")},disabled:!C,children:"Steer"})]})]})]})})}function Pve({layout:e,agents:t,pan:n,zoom:r,viewportRef:a,isCollapsed:o,onToggleCollapse:c,onFitAll:u,onHome:f,onClick:h}){const p=m.useRef(null),[x,v]=m.useState(0);if(m.useEffect(()=>{const z=p.current;if(!z)return;const _=()=>v(z.getBoundingClientRect().width);_();const U=new ResizeObserver(_);return U.observe(z),()=>U.disconnect()},[]),e.canvasW===0)return null;const y=x||tve,b=Math.min(y/e.canvasW,nve/e.canvasH),C=e.canvasW*b,E=e.canvasH*b,A=Math.max(0,(y-C)/2),S=a.current,k=S?.clientWidth??0,N=S?.clientHeight??0,T=-n.x/r*b,R=-n.y/r*b,O=k/r*b,L=N/r*b,I=m.useCallback(z=>{const _=z.currentTarget.getBoundingClientRect(),U=Math.max(0,Math.min(C,z.clientX-_.left-A)),D=Math.max(0,Math.min(E,z.clientY-_.top));h({x:U/b,y:D/b})},[A,E,b,C,h]);return o?s.jsx("div",{className:"s-mission-minimap s-mission-minimap--collapsed",children:s.jsxs("div",{className:"s-mission-minimap-header",children:[s.jsxs("span",{className:"s-mission-minimap-title",children:[s.jsx("span",{className:"s-mission-minimap-title-mark","aria-hidden":!0}),"MAP"]}),s.jsx("button",{type:"button",className:"s-mission-minimap-action",title:"Expand map","aria-label":"Expand map",onClick:c,children:s.jsx(Ww,{size:12,strokeWidth:1.5})})]})}):s.jsxs("div",{className:"s-mission-minimap",children:[s.jsxs("div",{className:"s-mission-minimap-header",children:[s.jsxs("span",{className:"s-mission-minimap-title",children:[s.jsx("span",{className:"s-mission-minimap-title-mark","aria-hidden":!0}),"MAP"]}),s.jsxs("div",{className:"s-mission-minimap-actions",children:[s.jsx("button",{type:"button",className:"s-mission-minimap-action",title:"Fit all","aria-label":"Fit all",onClick:u,children:s.jsx(qw,{size:12,strokeWidth:1.5})}),s.jsx("button",{type:"button",className:"s-mission-minimap-action",title:"Recenter","aria-label":"Recenter",onClick:f,children:s.jsx(q6,{size:12,strokeWidth:1.5})}),s.jsx("button",{type:"button",className:"s-mission-minimap-action",title:"Minimize map","aria-label":"Minimize map",onClick:c,children:s.jsx(Xo,{size:12,strokeWidth:1.5})})]})]}),s.jsxs("div",{ref:p,className:"s-mission-minimap-canvas",style:{height:E},onClick:I,"aria-hidden":"true",children:[e.groups.flatMap(z=>z.tiles.map(_=>{const U=t.find(D=>D.id===_.agentId);return s.jsx("div",{className:"s-mission-minimap-tile",style:{left:A+_.x*b,top:_.y*b,width:Uo*b,height:Uc*b,background:U?Xt(U.name):"var(--dim)",opacity:U&&Ge(U.state)==="working"?.8:.35}},_.agentId)})),s.jsx("div",{className:"s-mission-minimap-viewport",style:{left:A+Math.max(0,T),top:Math.max(0,R),width:Math.min(O,C),height:Math.min(L,E)}})]})]})}function Dve(e){switch(e){case"working":return"var(--green)";case"ready":return"var(--accent)";default:return"var(--dim)"}}const zve=["openai","codex","codex_app_server"],Bve=["anthropic","claude","claude-code","claude_stream_json"],Ao={"openai:gpt-5.5":{provider:"openai",model:"gpt-5.5",inputPerM:5,cachedInputPerM:.5,cacheWritePerM:null,outputPerM:30,webSearchPer1K:10},"openai:gpt-5.5-pro":{provider:"openai",model:"gpt-5.5-pro",inputPerM:30,cachedInputPerM:null,cacheWritePerM:null,outputPerM:180,webSearchPer1K:10},"openai:gpt-5.4":{provider:"openai",model:"gpt-5.4",inputPerM:2.5,cachedInputPerM:.25,cacheWritePerM:null,outputPerM:15,webSearchPer1K:10},"openai:gpt-5.4-mini":{provider:"openai",model:"gpt-5.4-mini",inputPerM:.75,cachedInputPerM:.075,cacheWritePerM:null,outputPerM:4.5,webSearchPer1K:10},"openai:gpt-5.4-nano":{provider:"openai",model:"gpt-5.4-nano",inputPerM:.2,cachedInputPerM:.02,cacheWritePerM:null,outputPerM:1.25,webSearchPer1K:10},"openai:gpt-5.4-pro":{provider:"openai",model:"gpt-5.4-pro",inputPerM:30,cachedInputPerM:null,cacheWritePerM:null,outputPerM:180,webSearchPer1K:10},"openai:gpt-5.3-codex":{provider:"openai",model:"gpt-5.3-codex",inputPerM:1.75,cachedInputPerM:.175,cacheWritePerM:null,outputPerM:14,webSearchPer1K:10},"openai:gpt-5.3-chat-latest":{provider:"openai",model:"gpt-5.3-chat-latest",inputPerM:1.75,cachedInputPerM:.175,cacheWritePerM:null,outputPerM:14,webSearchPer1K:10},"openai:gpt-5.2":{provider:"openai",model:"gpt-5.2",inputPerM:1.75,cachedInputPerM:.175,cacheWritePerM:null,outputPerM:14,webSearchPer1K:10},"openai:gpt-5.2-codex":{provider:"openai",model:"gpt-5.2-codex",inputPerM:1.75,cachedInputPerM:.175,cacheWritePerM:null,outputPerM:14,webSearchPer1K:10},"openai:gpt-5.2-chat-latest":{provider:"openai",model:"gpt-5.2-chat-latest",inputPerM:1.75,cachedInputPerM:.175,cacheWritePerM:null,outputPerM:14,webSearchPer1K:10},"openai:gpt-5.2-pro":{provider:"openai",model:"gpt-5.2-pro",inputPerM:21,cachedInputPerM:null,cacheWritePerM:null,outputPerM:168,webSearchPer1K:10},"openai:gpt-5.1":{provider:"openai",model:"gpt-5.1",inputPerM:1.25,cachedInputPerM:.125,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-5.1-codex":{provider:"openai",model:"gpt-5.1-codex",inputPerM:1.25,cachedInputPerM:.125,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-5.1-codex-max":{provider:"openai",model:"gpt-5.1-codex-max",inputPerM:1.25,cachedInputPerM:.125,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-5.1-chat-latest":{provider:"openai",model:"gpt-5.1-chat-latest",inputPerM:1.25,cachedInputPerM:.125,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-5":{provider:"openai",model:"gpt-5",inputPerM:1.25,cachedInputPerM:.125,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-5-codex":{provider:"openai",model:"gpt-5-codex",inputPerM:1.25,cachedInputPerM:.125,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-5-chat-latest":{provider:"openai",model:"gpt-5-chat-latest",inputPerM:1.25,cachedInputPerM:.125,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-5-mini":{provider:"openai",model:"gpt-5-mini",inputPerM:.25,cachedInputPerM:.025,cacheWritePerM:null,outputPerM:2,webSearchPer1K:10},"openai:gpt-5-nano":{provider:"openai",model:"gpt-5-nano",inputPerM:.05,cachedInputPerM:.005,cacheWritePerM:null,outputPerM:.4,webSearchPer1K:10},"openai:gpt-5-pro":{provider:"openai",model:"gpt-5-pro",inputPerM:15,cachedInputPerM:null,cacheWritePerM:null,outputPerM:120,webSearchPer1K:10},"openai:gpt-4.1":{provider:"openai",model:"gpt-4.1",inputPerM:2,cachedInputPerM:.5,cacheWritePerM:null,outputPerM:8,webSearchPer1K:10},"openai:gpt-4.1-mini":{provider:"openai",model:"gpt-4.1-mini",inputPerM:.4,cachedInputPerM:.1,cacheWritePerM:null,outputPerM:1.6,webSearchPer1K:10},"openai:gpt-4.1-nano":{provider:"openai",model:"gpt-4.1-nano",inputPerM:.1,cachedInputPerM:.025,cacheWritePerM:null,outputPerM:.4,webSearchPer1K:10},"openai:gpt-4o":{provider:"openai",model:"gpt-4o",inputPerM:2.5,cachedInputPerM:1.25,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-4o-mini":{provider:"openai",model:"gpt-4o-mini",inputPerM:.15,cachedInputPerM:.075,cacheWritePerM:null,outputPerM:.6,webSearchPer1K:10},"anthropic:claude-opus-4.6":{provider:"anthropic",model:"claude-opus-4.6",inputPerM:5,cachedInputPerM:.5,cacheWritePerM:6.25,outputPerM:25,webSearchPer1K:10},"anthropic:claude-opus-4.5":{provider:"anthropic",model:"claude-opus-4.5",inputPerM:5,cachedInputPerM:.5,cacheWritePerM:6.25,outputPerM:25,webSearchPer1K:10},"anthropic:claude-opus-4.1":{provider:"anthropic",model:"claude-opus-4.1",inputPerM:15,cachedInputPerM:1.5,cacheWritePerM:18.75,outputPerM:75,webSearchPer1K:10},"anthropic:claude-opus-4":{provider:"anthropic",model:"claude-opus-4",inputPerM:15,cachedInputPerM:1.5,cacheWritePerM:18.75,outputPerM:75,webSearchPer1K:10},"anthropic:claude-sonnet-4.6":{provider:"anthropic",model:"claude-sonnet-4.6",inputPerM:3,cachedInputPerM:.3,cacheWritePerM:3.75,outputPerM:15,webSearchPer1K:10},"anthropic:claude-sonnet-4.5":{provider:"anthropic",model:"claude-sonnet-4.5",inputPerM:3,cachedInputPerM:.3,cacheWritePerM:3.75,outputPerM:15,webSearchPer1K:10},"anthropic:claude-sonnet-4":{provider:"anthropic",model:"claude-sonnet-4",inputPerM:3,cachedInputPerM:.3,cacheWritePerM:3.75,outputPerM:15,webSearchPer1K:10},"anthropic:claude-3-7-sonnet":{provider:"anthropic",model:"claude-3-7-sonnet",inputPerM:3,cachedInputPerM:.3,cacheWritePerM:3.75,outputPerM:15,webSearchPer1K:10},"anthropic:claude-haiku-4.5":{provider:"anthropic",model:"claude-haiku-4.5",inputPerM:1,cachedInputPerM:.1,cacheWritePerM:1.25,outputPerM:5,webSearchPer1K:10}},Uve={"claude-sonnet-4-5":"anthropic:claude-sonnet-4.5","claude-sonnet-4-6":"anthropic:claude-sonnet-4.6","claude-opus-4-5":"anthropic:claude-opus-4.5","claude-opus-4-6":"anthropic:claude-opus-4.6","claude-haiku-4-5":"anthropic:claude-haiku-4.5"};function Fve(e){const t=e.provider?.trim().toLowerCase()??"",n=e.adapterType?.trim().toLowerCase()??"",r=v4(e.model)??"",a=[t,n].filter(Boolean);return a.some(o=>zve.some(c=>o.includes(c)))?"openai":a.some(o=>Bve.some(c=>o.includes(c)))?"anthropic":r.startsWith("gpt-")||r.startsWith("o")||r.includes("codex")?"openai":r.startsWith("claude-")?"anthropic":"unknown"}function v4(e){return e?e.trim().toLowerCase().replace(/^(openai|anthropic)\//,"").replace(/_/g,"-").replace(/-\d{8}$/,""):null}function Vve(e){const t=yi(e?.inputTokens),n=yi(e?.cacheReadInputTokens),r=yi(e?.cacheCreationInputTokens),a=yi(e?.outputTokens),o=yi(e?.reasoningOutputTokens),c=[t,a].reduce((f,h)=>f+(h??0),0),u=yi(e?.totalTokens)??(c||null);return{input:t,uncachedInput:t==null?null:Math.max(0,t-(n??0)-(r??0)),cachedInput:n,cacheWrite:r,output:a,reasoningOutput:o,total:u,webSearchRequests:yi(e?.webSearchRequests),webFetchRequests:yi(e?.webFetchRequests)}}function Hve(e){const t=Fve(e),n=v4(e.model),r=Vve(e.usage),a=Wve(t,n),o=qve(e);if(!a.rateCard)return{provider:t,model:n,rateCard:null,rateCardSource:"unknown",capturedAt:e.capturedAt??Date.now(),usage:r,lineItems:[],totalUsd:null,billedTotalUsd:null,billingMode:o,subscriptionWindows:e.subscriptionWindows??[]};const c=a.rateCard,u=r.uncachedInput??r.input??0,f=r.cachedInput??0,h=r.cacheWrite??0,p=r.output??0,x=r.webSearchRequests??0,v=[Sm("input","Input",u,c.inputPerM,o),Sm("cached_input","Cached input",f,c.cachedInputPerM??c.inputPerM,o),Sm("cache_write","Cache write",h,c.cacheWritePerM??c.inputPerM,o),Sm("output","Output",p,c.outputPerM,o),{key:"web_search",label:"Web search",quantity:x,unit:"requests",rate:c.webSearchPer1K??0,billedRate:o==="subscription"?0:c.webSearchPer1K??0,costUsd:x/1e3*(c.webSearchPer1K??0),billedCostUsd:o==="subscription"?0:x/1e3*(c.webSearchPer1K??0)}].filter(y=>y.quantity>0);return{provider:t,model:n,rateCard:c,rateCardSource:a.source,capturedAt:e.capturedAt??Date.now(),usage:r,lineItems:v,totalUsd:v.reduce((y,b)=>y+b.costUsd,0),billedTotalUsd:v.reduce((y,b)=>y+b.billedCostUsd,0),billingMode:o,subscriptionWindows:e.subscriptionWindows??[]}}function Wve(e,t){if(e==="unknown")return{rateCard:null,source:"unknown"};const n=t?`${e}:${t}`:null;if(n&&Ao[n])return{rateCard:Ao[n],source:"exact"};const r=t?Uve[t]:null;if(r&&Ao[r])return{rateCard:Ao[r],source:"alias"};if(e==="anthropic"){if(t?.includes("opus"))return{rateCard:Ao["anthropic:claude-opus-4.5"],source:"provider-default"};if(t?.includes("haiku"))return{rateCard:Ao["anthropic:claude-haiku-4.5"],source:"provider-default"};if(t?.includes("sonnet")||!t)return{rateCard:Ao["anthropic:claude-sonnet-4.5"],source:"provider-default"}}return{rateCard:null,source:"unknown"}}function Sm(e,t,n,r,a){const o=a==="subscription"?0:r;return{key:e,label:t,quantity:n,unit:"tokens",rate:r,billedRate:o,costUsd:n/1e6*r,billedCostUsd:n/1e6*o}}function yi(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function qve(e){if(e.billingMode)return e.billingMode;const t=e.adapterType?.trim().toLowerCase();if(t==="claude-code"||t==="claude_stream_json")return"subscription";const n=e.usage?.planType?.trim().toLowerCase();return!n||n==="api"||n.includes("api")?"api":"subscription"}const Ew=1440*6e4,Kve=90*6e4,dI={working:0,ready:1,not_ready:2},Gve=[{key:"agent",label:"Agent",kind:"custom",sortable:!0,sortValue:e=>e.agent.name.toLowerCase(),defaultWidth:220,minWidth:160,render:e=>s.jsxs("div",{className:"s-ops-agents-agent-cell",children:[s.jsx("span",{className:"s-ops-agents-dot",style:{background:yn(e.state)},"aria-hidden":!0}),s.jsx("span",{className:"s-ops-agents-agent-name",title:e.agent.name,children:e.agent.handle??e.agent.name})]})},{key:"task",label:"Active task",kind:"custom",sortable:!0,sortValue:e=>(e.activeTask??"").toLowerCase()||null,defaultWidth:240,minWidth:140,render:e=>e.activeTask?s.jsx("span",{className:"s-ops-agents-task",title:e.activeTask,children:e.activeTask}):s.jsx("span",{className:"s-ops-agents-task s-ops-agents-task--idle",children:"—"})},{key:"team",label:"Project",kind:"text",defaultWidth:140,minWidth:90,cls:"s-ops-agents-meta",render:e=>s.jsx("span",{className:"s-ops-agents-meta-cell",children:e.team}),sortValue:e=>e.team.toLowerCase()},{key:"machine",label:"Machine",kind:"text",defaultWidth:120,minWidth:88,cls:"s-ops-agents-meta",render:e=>s.jsx("span",{className:"s-ops-agents-meta-cell",children:e.machine}),sortValue:e=>e.machine.toLowerCase()},{key:"active",label:"Active",kind:"number",defaultWidth:90,minWidth:64,cls:"s-ops-agents-num",render:e=>e.activeFlights,sortValue:e=>e.activeFlights},{key:"sessions24h",label:"24h sessions",kind:"number",defaultWidth:108,minWidth:78,cls:"s-ops-agents-num",render:e=>e.sessions24h,sortValue:e=>e.sessions24h},{key:"throughput",label:"Throughput",kind:"custom",sortable:!1,defaultWidth:110,minWidth:90,render:e=>s.jsx(Xve,{values:e.throughput,warn:e.errors>0})},{key:"avgLatency",label:"Avg latency",kind:"number",defaultWidth:108,minWidth:80,cls:"s-ops-agents-num",render:e=>x4(e.avgLatencyMs),sortValue:e=>e.avgLatencyMs},{key:"input",label:"Input",kind:"number",defaultWidth:88,minWidth:64,cls:"s-ops-agents-num",render:e=>xd(e.usage.uncachedInput??e.usage.input),sortValue:e=>e.usage.uncachedInput??e.usage.input??null},{key:"cacheRead",label:"Cache read",kind:"number",defaultWidth:98,minWidth:72,cls:"s-ops-agents-num",render:e=>xd(e.usage.cachedInput),sortValue:e=>e.usage.cachedInput??null},{key:"cacheWrite",label:"Cache write",kind:"number",defaultWidth:98,minWidth:72,cls:"s-ops-agents-num",render:e=>xd(e.usage.cacheWrite),sortValue:e=>e.usage.cacheWrite??null},{key:"output",label:"Output",kind:"number",defaultWidth:88,minWidth:64,cls:"s-ops-agents-num",render:e=>xd(e.usage.output),sortValue:e=>e.usage.output??null},{key:"apiEquiv",label:"API equiv",kind:"number",defaultWidth:92,minWidth:72,cls:"s-ops-agents-num",render:e=>s.jsx("span",{className:e.cost.rateCardSource==="unknown"?"s-ops-agents-num--dim":void 0,children:ig(e.cost.totalUsd)}),sortValue:e=>e.cost.totalUsd??null},{key:"billed",label:"Billed",kind:"number",defaultWidth:92,minWidth:72,cls:"s-ops-agents-num",render:e=>s.jsx("span",{className:e.cost.billingMode==="subscription"?"s-ops-agents-num--covered":void 0,children:ig(e.cost.billedTotalUsd)}),sortValue:e=>e.cost.billedTotalUsd??null},{key:"errors",label:"Errors",kind:"number",defaultWidth:72,minWidth:58,cls:"s-ops-agents-num",render:e=>s.jsx("span",{className:e.errors>0?"s-ops-agents-num--warn":void 0,children:e.errors}),sortValue:e=>e.errors},{key:"lastActive",label:"Last active",kind:"time",defaultWidth:104,minWidth:78,cls:"s-ops-agents-last",render:e=>e.lastActiveAt?Ie(e.lastActiveAt):"—",sortValue:e=>e.lastActiveAt}];function fI(e){if(!e)return null;const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function xd(e){return e==null?"—":e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}K`:String(e)}function x4(e){return e==null?"—":e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(2)}s`}function ig(e){return e==null?"$—":e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function Zve(e,t){if(!e)return null;const n=e.data.events.filter(a=>a.kind==="message"||a.kind==="tool").filter(a=>t-a.t<=Kve).sort((a,o)=>a.t-o.t);if(n.length<2)return null;const r=[];for(let a=1;a<n.length;a+=1){const o=n[a].t-n[a-1].t;o>0&&o<12e4&&r.push(o)}return r.length===0?null:Math.round(r.reduce((a,o)=>a+o,0)/r.length)}function Yve(e,t){const n=new Array(24).fill(0),r=t-Ew;for(const a of e){if(a.ts<r||a.ts>t)continue;const o=Math.min(23,Math.max(0,Math.floor((a.ts-r)/Ew*n.length)));n[o]+=1}return n}function Xve({values:e,warn:t=!1}){const a=Math.max(1,...e),o=e.map((c,u)=>{const f=u/Math.max(1,e.length-1)*92,h=22-c/a*19-1.5;return`${f.toFixed(1)},${h.toFixed(1)}`}).join(" ");return s.jsx("svg",{className:`s-ops-agents-spark${t?" s-ops-agents-spark--warn":""}`,viewBox:"0 0 92 22","aria-hidden":"true",children:s.jsx("polyline",{points:o,fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function Qve(e){return e.authorityNodeName??e.homeNodeName??e.authorityNodeId??e.homeNodeId??e.transport??fI(e.cwd)??fI(e.projectRoot)??"local"}function Jve(e){return e.project??e.role??e.agentClass??"Unassigned"}function exe(e){if(e.length===0)return null;const t={working:0,needs_attention:1,queued:2,failed:3,completed:4},r=[...e].sort((o,c)=>{const u=t[o.status]-t[c.status];return u!==0?u:(c.updatedAt??0)-(o.updatedAt??0)})[0];return(r.task??r.summary??"").trim()||null}function txe(e,t,n,r,a,o){const c=t.filter(b=>b.agentId===e.id),u=c.filter(b=>{const C=b.lastMessageAt??0;return C>0&&o-C<=Ew}),f=n.filter(b=>b.actorName===e.name||b.conversationId===e.conversationId),h=a.get(e.id),p=h?.data.metadata?.session?.model??null,x=h?.data.metadata?.session?.modelProvider??null,v=Hve({adapterType:h?.data.metadata?.session?.adapterType,capturedAt:h?.updatedAt??o,model:p,provider:x,usage:h?.data.metadata?.usage}),y=r.filter(b=>b.agentId===e.id);return{agent:e,team:Jve(e),machine:Qve(e),model:p,provider:x,state:Ge(e.state),activeFlights:y.length,activeTask:exe(y),sessions24h:u.length,throughput:Yve(f,o),avgLatencyMs:Zve(h,o),usage:v.usage,cost:v,errors:y.filter(b=>b.status==="failed"||b.status==="needs_attention").length,lastActiveAt:Math.max(0,...c.map(b=>b.lastMessageAt??0),...f.map(b=>b.ts),e.updatedAt??0)||null}}function nxe({navigate:e,agents:t}){const[n,r]=m.useState(null),[a,o]=m.useState([]),[c,u]=m.useState([]),[f,h]=m.useState([]),[p,x]=m.useState(""),[v,y]=m.useState(()=>Date.now()),b=m.useCallback(async()=>{const q=t.map(Y=>Y.id).join(","),[Z,$,G,V]=await Promise.allSettled([ue("/api/fleet"),ue("/api/conversations"),ue("/api/activity"),q?ue(`/api/observe/agents?ids=${encodeURIComponent(q)}`):Promise.resolve([])]);Z.status==="fulfilled"&&r(Z.value),$.status==="fulfilled"&&o($.value),G.status==="fulfilled"&&u(G.value),V.status==="fulfilled"&&h(V.value),y(Date.now())},[t]);m.useEffect(()=>{b()},[b]),Vt(()=>{b()}),m.useEffect(()=>{const q=setInterval(()=>y(Date.now()),1e3);return()=>clearInterval(q)},[]);const C=m.useMemo(()=>new Map(f.map(q=>[q.agentId,q])),[f]),E=m.useMemo(()=>{const q=n?.activeAsks??[];return t.map(Z=>txe(Z,a,c,q,C,v))},[c,t,n?.activeAsks,v,C,a]),A=m.useMemo(()=>{const q=p.trim().toLowerCase();return q?E.filter(Z=>`${Z.agent.name} ${Z.team} ${Z.machine} ${Z.agent.handle??""} ${Z.agent.harness??""} ${Z.activeTask??""}`.toLowerCase().includes(q)):E},[p,E]),[S,k]=m.useState({key:"lastActive",dir:-1}),N=m.useMemo(()=>S?.key==="agent"?void 0:(q,Z)=>dI[q.state]-dI[Z.state],[S?.key]),T=m.useMemo(()=>A.map(q=>q.agent),[A]),R=m.useMemo(()=>A.map(q=>q.agent.id),[A]),O=_k({agents:T,orderedIds:R,navigate:e,selectMode:"preview"}),L=E.filter(q=>q.state==="working").length,I=E.filter(q=>q.state!=="not_ready").length,z=E.reduce((q,Z)=>q+(Z.usage.total??0),0),_=E.some(q=>q.cost.totalUsd!=null)?E.reduce((q,Z)=>q+(Z.cost.totalUsd??0),0):null,U=E.some(q=>q.cost.billedTotalUsd!=null)?E.reduce((q,Z)=>q+(Z.cost.billedTotalUsd??0),0):null,D=(()=>{const q=E.map(Z=>Z.avgLatencyMs).filter(Z=>Z!=null);return q.length===0?null:Math.round(q.reduce((Z,$)=>Z+$,0)/q.length)})();return s.jsxs("div",{className:"s-ops-agents",children:[s.jsxs("main",{className:"s-ops-agents-main",children:[s.jsxs("div",{className:"s-ops-agents-toolbar",children:[s.jsxs("div",{className:"s-ops-agents-breadcrumb",children:["Agents ",s.jsx("span",{children:"/"})," Directory"]}),s.jsxs("div",{className:"s-ops-agents-live",children:[s.jsx("span",{className:"s-ops-agents-live-dot"}),I," active"]}),s.jsxs("div",{className:"s-ops-agents-search",children:[s.jsx(Tc,{size:13}),s.jsx("input",{value:p,onChange:q=>x(q.target.value),placeholder:"Search agents, tasks, projects, machines…"})]}),s.jsx("button",{className:"s-ops-agents-icon-btn",type:"button",title:"Filters",children:s.jsx(r8,{size:14})})]}),s.jsx("section",{className:"s-ops-agents-hero",children:s.jsxs("div",{children:[s.jsx("div",{className:"s-ops-agents-kicker",children:"Agents"}),s.jsx("h1",{children:"All agents"}),s.jsx("p",{children:"Every registered agent across the local fleet, sorted by live status."})]})}),s.jsxs("section",{className:"s-ops-agents-stats",children:[s.jsx(Cm,{label:"Running",value:String(L),sub:`of ${t.length} total`}),s.jsx(Cm,{label:"Tokens",value:xd(z||null),sub:_==null?"usage metadata pending":`${ig(_)} API equiv`}),s.jsx(Cm,{label:"Avg latency",value:x4(D),sub:"recent observe events"}),s.jsx(Cm,{label:"Billed",value:ig(U),sub:"subscription usage can mark this down"})]}),s.jsxs("section",{className:"s-ops-agents-table-panel",children:[s.jsxs("div",{className:"s-ops-agents-table-title",children:["Agents ",s.jsx("span",{children:A.length}),s.jsxs("span",{className:"s-ops-agents-hint","aria-hidden":!0,children:[s.jsx("kbd",{children:"↑"}),s.jsx("kbd",{children:"↓"})," navigate · ",s.jsx("kbd",{children:"enter"})," pin · ",s.jsx("kbd",{children:"o"})," open · ",s.jsx("kbd",{children:"esc"})," clear"]})]}),s.jsx("div",{className:"s-ops-agents-table-wrap",ref:O.containerRef,children:s.jsx(Hk,{rows:A,columns:Gve,rowId:q=>q.agent.id,storageKey:"openscout.opsAgents.cols",sort:S,onSortChange:k,secondarySort:N,density:"compact",rowBindings:q=>{const Z=O.bind(q);return{...Z,onKeyDown:$=>{$.key!=="Enter"&&$.key!==" "||($.preventDefault(),Z.onClick())}}},rowState:q=>O.getState(q),empty:{title:"No agents match",body:"Adjust the search to find a different slice of the fleet."},className:"s-ops-agents-data-table",ariaLabel:"Agents directory"})})]})]}),O.card]})}function Cm({label:e,value:t,sub:n,tone:r="default"}){return s.jsxs("div",{className:`s-ops-agents-metric s-ops-agents-metric--${r}`,children:[s.jsx("div",{className:"s-ops-agents-metric-label",children:e}),s.jsx("div",{className:"s-ops-agents-metric-value",children:t}),s.jsx("div",{className:"s-ops-agents-metric-sub",children:n})]})}const sxe={active:"Active",archived:"Archived",blocked:"Blocked",completed:"Complete",draft:"Draft",unknown:"Unknown"},rxe={active:"var(--green)",archived:"var(--dim)",blocked:"var(--amber)",completed:"var(--muted)",draft:"var(--accent)",unknown:"var(--dim)"};function axe(e){switch(e.source){case"claude":return"Claude";case"codex":return"Codex";case"openscout":return"OpenScout";case"workspace":return"Workspace";case"unknown":return"Other"}}function ixe({navigate:e,agents:t,selectedPlanDocumentId:n}){const[r,a]=m.useState(null),[o,c]=m.useState(!0),[u,f]=m.useState(null),h=m.useRef(0),p=m.useCallback(async()=>{const C=++h.current;c(!0);const E=await Promise.resolve(ue("/api/plan-documents")).then(S=>({status:"fulfilled",value:S})).catch(S=>({status:"rejected",reason:S}));if(C!==h.current)return;E.status==="fulfilled"&&a(E.value);const A=[E.status==="rejected"?`plans: ${E.reason instanceof Error?E.reason.message:String(E.reason)}`:null].filter(S=>!!S);f(A.length>0?A.join(" · "):null),c(!1)},[]);m.useEffect(()=>{p()},[p]),Vt(()=>{p()});const x=m.useMemo(()=>Object.fromEntries(t.map(C=>[C.id,C])),[t]),v=r?.documents??[],y=m.useMemo(()=>v.find(C=>C.id===n)??v[0]??null,[v,n]);m.useEffect(()=>{v.length>0&&(!n||!v.some(C=>C.id===n))&&e({view:"ops",mode:"plan",planDocumentId:v[0].id})},[v,e,n]);const b=m.useMemo(()=>{const C={claude:0,codex:0,openscout:0,workspace:0,unknown:0};for(const E of v)C[E.source]+=1;return C},[v]);return s.jsx("div",{className:"s-plan",children:s.jsxs("div",{className:"s-plan-inner s-plan-inner--documents",children:[s.jsxs("header",{className:"s-plan-banner",children:[s.jsx("span",{className:"s-plan-banner-badge",children:"Plan Documents"}),s.jsx("span",{className:"s-plan-banner-meta",children:o&&v.length===0?"indexing plan documents...":`${v.length} document${v.length===1?"":"s"} · ${b.claude} Claude · ${b.codex} Codex · ${b.openscout} OpenScout · ${b.workspace} workspace`}),r&&s.jsxs("span",{className:"s-plan-banner-meta",children:[r.roots.length," roots · updated ",Ie(r.generatedAt)]}),u&&s.jsxs("span",{className:"s-plan-banner-meta s-plan-banner-meta--error",children:["partial data · ",u]}),s.jsx("span",{className:"s-plan-banner-spacer"}),s.jsx("button",{className:"s-ops-btn",onClick:()=>{p()},disabled:o,children:o?"Indexing...":"Refresh"})]}),s.jsx("main",{className:"s-plan-col s-plan-col--canvas",children:y?s.jsx(oxe,{document:y,agentsById:x}):s.jsxs("div",{className:"s-plan-empty-card",children:[s.jsx("div",{className:"s-plan-empty-title",children:"No plan document selected"}),s.jsx("div",{className:"s-plan-empty-copy",children:"The plan inventory will appear here once the index finds documents."})]})})]})})}function oxe({document:e,agentsById:t}){const[n,r]=m.useState("preview"),a=e.agentId?t[e.agentId]:null,o=m.useMemo(()=>Qc({id:e.id,title:e.title,uri:e.path,filename:e.path,mediaType:"text/markdown",kind:"markdown",value:e.body||e.rawText,readOnly:!0}),[e]);return m.useEffect(()=>{r("preview")},[e.id]),s.jsxs("div",{className:"s-plan-document",children:[s.jsxs("div",{className:"s-plan-readonly-head",children:[s.jsxs("div",{children:[s.jsx("div",{className:"s-ops-eyebrow",children:"Plan document"}),s.jsx("h1",{className:"s-plan-title",children:e.title}),e.summary&&s.jsx("p",{className:"s-plan-goal",children:e.summary})]}),s.jsx("span",{className:"s-ops-state-chip",style:{color:rxe[e.status]},children:sxe[e.status]})]}),s.jsxs("section",{className:"s-plan-doc-section s-plan-doc-section--primary",children:[s.jsxs("div",{className:"s-plan-tree-header",children:[s.jsx("div",{className:"s-ops-eyebrow",style:{marginBottom:0},children:"Document"}),s.jsxs("span",{className:"s-plan-tree-stats",children:[e.body.length.toLocaleString()," chars · ",e.path]}),s.jsxs("div",{className:"s-plan-tree-toggle s-plan-doc-mode-toggle",children:[s.jsx("button",{type:"button",className:`s-plan-tree-toggle-btn${n==="preview"?" s-plan-tree-toggle-btn--active":""}`,onClick:()=>r("preview"),children:"Preview"}),s.jsx("button",{type:"button",className:`s-plan-tree-toggle-btn${n==="source"?" s-plan-tree-toggle-btn--active":""}`,onClick:()=>r("source"),children:"Source"})]})]}),n==="preview"?s.jsx(jf,{document:o,mode:"preview",className:"s-plan-doc-preview s-plan-doc-body--primary"}):s.jsx("pre",{className:"s-plan-doc-body s-plan-doc-body--primary",children:e.body||e.rawText})]}),s.jsxs("section",{className:"s-plan-doc-section",children:[s.jsx("div",{className:"s-ops-eyebrow",children:"Provenance"}),s.jsxs("dl",{className:"s-plan-doc-meta",children:[s.jsx(ad,{label:"Source",value:`${axe(e)} · ${e.confidence}`}),s.jsx(ad,{label:"Path",value:e.path}),s.jsx(ad,{label:"Workspace",value:e.workspaceName??e.provenance.root}),s.jsx(ad,{label:"Agent",value:e.agentName??a?.name??e.agentId??"unassigned"}),s.jsx(ad,{label:"Updated",value:new Date(e.updatedAt).toLocaleString()})]})]})]})}function ad({label:e,value:t}){return s.jsxs("div",{className:"s-plan-doc-meta-row",children:[s.jsx("dt",{children:e}),s.jsx("dd",{title:t,children:t})]})}const hI=4e3,lxe=500,cxe=5e3,uxe=5e3,dxe=6e4,og={"scout-managed":"scout","hudson-managed":"hudson",unattributed:"native"},Xk={tool:"working",run:"active",idle:"idle"};function Aw(e){const t=e.split(/\s+/)[0]??"",n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function fxe(e,t=60){const n=e.split(/\s+/);if(n.length===0)return e;n[0]=Aw(n[0]);const r=n.join(" ");return r.length<=t?r:r.slice(0,t-1)+"…"}function hxe(e){for(const t of e){const n=Aw(t.command);if(n&&!(n==="sh"||n==="zsh"||n==="bash"||n==="login"))return n}return e[0]?.command?Aw(e[0].command):"—"}function mxe(e){const t=e.match(/^(?:(\d+)-)?(?:(\d+):)?(\d+):(\d+)$/);if(!t){const u=e.match(/^(\d+)$/);return u?Number.parseInt(u[1],10):0}const[,n,r,a,o]=t;let c=Number.parseInt(o,10)+Number.parseInt(a,10)*60;return r&&(c+=Number.parseInt(r,10)*3600),n&&(c+=Number.parseInt(n,10)*86400),c}function y4(e){if(e<60)return`${e}s`;if(e<3600)return`${Math.floor(e/60)}m${String(e%60).padStart(2,"0")}`;if(e<86400){const r=Math.floor(e/3600),a=Math.floor(e%3600/60);return`${r}h${String(a).padStart(2,"0")}`}const t=Math.floor(e/86400),n=Math.floor(e%86400/3600);return`${t}d${String(n).padStart(2,"0")}h`}function b4(e,t){if(e==null)return"—";const n=Math.max(0,Math.round((t-e)/1e3));return n<2?"just now":n<60?`${n}s ago`:n<3600?`${Math.floor(n/60)}m ago`:`${Math.floor(n/3600)}h ago`}function pxe(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`}function Tw(e){return e?e.slice(0,8):"—"}function w4(e){return e?.trim().toLowerCase()||"unknown"}function gxe(e){return w4(e).replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function Qk(e){return`s-atop-chip s-atop-chip--harness s-atop-chip--harness-${gxe(e)}`}const vxe=/permission-mode/i;function mI(e){return e.kind!=="system"?!1:vxe.test(e.summary)}function Mw(e){return e.kind==="assistant"}function xxe(e,t,n){if(!e)return[];const r=new Map,a=new Map;for(const v of t){let y=r.get(v.pid);if(y||(y={firstEventAt:v.ts,lastEventAt:v.ts,lastKind:v.kind,lastSummary:v.summary,reqCount:0,toolCount:0,permCount:0,eventCount:0,sessionId:v.sessionId||null,model:null,tokIn:null,tokOut:null,cacheReadIn:null,cacheWriteIn:null},r.set(v.pid,y)),v.ts<y.firstEventAt&&(y.firstEventAt=v.ts),v.ts>=y.lastEventAt&&(y.lastEventAt=v.ts,y.lastKind=v.kind,y.lastSummary=v.summary),y.eventCount++,v.kind==="tool"&&y.toolCount++,Mw(v)&&y.reqCount++,mI(v)&&y.permCount++,v.sessionId&&!y.sessionId&&(y.sessionId=v.sessionId),v.sessionId){let b=a.get(v.sessionId);b||(b={firstEventAt:v.ts,lastEventAt:v.ts,lastKind:v.kind,lastSummary:v.summary,reqCount:0,toolCount:0,permCount:0,eventCount:0,sessionId:v.sessionId,model:null,tokIn:null,tokOut:null,cacheReadIn:null,cacheWriteIn:null},a.set(v.sessionId,b)),v.ts<b.firstEventAt&&(b.firstEventAt=v.ts),v.ts>=b.lastEventAt&&(b.lastEventAt=v.ts,b.lastKind=v.kind,b.lastSummary=v.summary),b.eventCount++,v.kind==="tool"&&b.toolCount++,Mw(v)&&b.reqCount++,mI(v)&&b.permCount++}}const o=new Map;for(const v of e.processes){if(!v.cwd)continue;const y=Ab(v.source,v.cwd),b=o.get(y);(!b||v.pid<b.pid)&&o.set(y,v)}const c=new Map,u=new Map;for(const v of e.transcripts??[]){const y=Ab(v.source,v.cwd),b=pI(v),C=u.get(y)??Number.NEGATIVE_INFINITY,E=c.get(y)??"";(v.mtimeMs>C||v.mtimeMs===C&&b>E)&&(u.set(y,v.mtimeMs),c.set(y,b))}const f=new Set,h=(v,y,b,C)=>{y&&f.add(y.pid);let E="idle";const A=Math.max(b?.lastEventAt??0,C?.mtimeMs??0);b&&n-b.lastEventAt<uxe&&(E=b.lastKind==="tool"?"tool":"run"),E==="idle"&&n-A<6e4&&(E="run");const S=y?mxe(y.etime):0,k=b?.firstEventAt??null,N=b&&b.firstEventAt<b.lastEventAt?Math.min(Math.max(0,Math.round((b.lastEventAt-b.firstEventAt)/1e3)),S||Number.POSITIVE_INFINITY):0,T=y?.pid??wxe(v),R=C?.cwd??y?.cwd??"";return{key:v,pid:T,ppid:y?.ppid??0,sessionId:C?.sessionId??b?.sessionId??null,transcriptPath:C?.transcriptPath??null,harness:w4(C?.source??y?.source),attribution:y?.harness??C?.harness??"unattributed",project:C?.project?.trim()||(R?yxe(R):"(unknown)"),cwd:R,command:y?.command??`${C?.source??"unknown"} transcript`,parentLabel:y?hxe(y.parentChain??[]):"transcript",procRuntimeSec:S,procEtime:y?.etime??"0",sessionStartAt:k,sessionRuntimeSec:N,status:E,lastEventAt:A||null,lastEventKind:b?.lastKind??null,lastSummary:b?.lastSummary??null,reqCount:b?.reqCount??0,toolCount:b?.toolCount??0,permCount:b?.permCount??0,eventCount:b?.eventCount??0,model:b?.model??null,tokIn:b?.tokIn??null,tokOut:b?.tokOut??null,cacheReadIn:b?.cacheReadIn??null,cacheWriteIn:b?.cacheWriteIn??null}},p=(e.transcripts??[]).map(v=>{const y=pI(v),b=Ab(v.source,v.cwd),C=c.get(b)===y?o.get(b)??null:null,E=v.sessionId?a.get(v.sessionId):void 0;return h(y,C,E,v)}),x=e.processes.filter(v=>!f.has(v.pid)).map(v=>h(bxe(v),v,r.get(v.pid),null));return[...p,...x]}function Fc(e){if(e.cacheReadIn==null||e.tokIn==null)return null;const t=e.cacheReadIn+e.tokIn;return t===0?null:e.cacheReadIn/t}function Lo(e){return e==null?"—":e===0?"0":e>=1e6?(e/1e6).toFixed(e>=1e7?0:1)+"M":e>=1e3?(e/1e3).toFixed(e>=1e4?0:1)+"k":String(e)}function j4(e){return e==null?"—":`${Math.round(e*100)}%`}function yxe(e){if(!e)return"";const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function pI(e){return`session:${e.source}:${e.sessionId??e.transcriptPath}`}function bxe(e){return`process:${e.source}:${e.pid}`}function wxe(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return-((t>>>0)%9e5+1e3)}function Ab(e,t){return`${e}\0${t??""}`}function jxe(e,t,n){const r=n-dxe;let a=0;for(const u of t)Mw(u)&&u.ts>=r&&a++;const o={total:e.length,running:0,tooling:0,idle:0,harnesses:[],reqsPerMin:a},c=new Map;for(const u of e)u.status==="tool"?(o.tooling++,o.running++):u.status==="run"?o.running++:o.idle++,c.set(u.harness,(c.get(u.harness)??0)+1);return o.harnesses=[...c.entries()].map(([u,f])=>({harness:u,count:f})).sort((u,f)=>f.count-u.count||u.harness.localeCompare(f.harness)),o}const cf={tool:0,run:1,idle:2};function Jl(e){return e??-1}function kxe(e,t,n,r){switch(n){case"status":return(cf[e.status]-cf[t.status])*r;case"agent":{const a=e.harness.localeCompare(t.harness);return a!==0?a*r:(e.sessionId??"").localeCompare(t.sessionId??"")*r}case"project":return e.project.localeCompare(t.project)*r;case"reqs":return(e.reqCount-t.reqCount)*r;case"tokIn":return(Jl(e.tokIn)-Jl(t.tokIn))*r;case"tokOut":return(Jl(e.tokOut)-Jl(t.tokOut))*r;case"cache":return(Jl(Fc(e))-Jl(Fc(t)))*r;case"tools":return(e.toolCount-t.toolCount)*r;case"perms":return(e.permCount-t.permCount)*r;case"last":{const a=e.lastEventAt??0,o=t.lastEventAt??0;return(a-o)*r}case"runtime":return(e.sessionRuntimeSec-t.sessionRuntimeSec)*r}}function gI({values:e,color:t}){if(e.length<2)return s.jsx("svg",{className:"s-atop-spark",width:88,height:18,viewBox:"0 0 88 18"});const a=Math.max(1,...e),o=88/(e.length-1),c=e.map((u,f)=>`${(f*o).toFixed(1)},${(18-u/a*18).toFixed(1)}`).join(" ");return s.jsx("svg",{className:"s-atop-spark",width:88,height:18,viewBox:"0 0 88 18",children:s.jsx("polyline",{fill:"none",stroke:t,strokeWidth:"1.25",points:c})})}function Nxe(){const[e,t]=m.useState([]),[n,r]=m.useState(null),[a,o]=m.useState(()=>Date.now()),[c,u]=m.useState(""),[f,h]=m.useState(()=>new Set),[p,x]=m.useState(()=>new Set),[v,y]=m.useState({key:"status",dir:1}),[b,C]=m.useState(null),E=m.useRef([]),A=m.useRef([]),[S,k]=m.useState([]),[N,T]=m.useState([]),R=m.useCallback(K=>{t(P=>P.length>=hI?[...P.slice(P.length-hI+1),K]:[...P,K])},[]);tu(R),m.useEffect(()=>{let K=!1;return(async()=>{try{const P=await ue(`/api/tail/recent?limit=${lxe}`);K||t(P.events??[])}catch{}})(),()=>{K=!0}},[]);const O=m.useCallback(async()=>{try{const K=await ue("/api/tail/discover");r(K)}catch{}},[]);m.useEffect(()=>{O();const K=setInterval(()=>{O()},cxe);return()=>clearInterval(K)},[O]),m.useEffect(()=>{const K=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(K)},[]);const L=m.useMemo(()=>xxe(n,e,a),[n,e,a]),I=m.useMemo(()=>jxe(L,e,a),[L,e,a]);m.useEffect(()=>{E.current=[...E.current,I.running].slice(-24),A.current=[...A.current,I.tooling].slice(-24),k(E.current),T(A.current)},[I.running,I.tooling]);const z=m.useMemo(()=>{const K=new Set;return L.forEach(P=>K.add(P.harness)),[...K]},[L]),_=m.useMemo(()=>{const K=new Set;return L.forEach(P=>K.add(P.status)),[...K]},[L]),U=m.useMemo(()=>{const K=c.trim().toLowerCase();return L.filter(P=>{if(f.size>0&&!f.has(P.harness)||p.size>0&&!p.has(P.status))return!1;if(!K)return!0;const H=og[P.attribution];return`${P.pid} ${P.project} ${P.command} ${P.harness} ${P.attribution} ${H} ${P.sessionId??""} ${P.transcriptPath??""} ${P.lastSummary??""}`.toLowerCase().includes(K)})},[L,c,f,p]),D=m.useMemo(()=>v.key==="status"?void 0:(K,P)=>cf[K.status]-cf[P.status],[v.key]),q=m.useMemo(()=>U.map((K,P)=>({row:K,index:P})).sort((K,P)=>{const H=kxe(K.row,P.row,v.key,v.dir);if(H!==0)return H;const B=D?.(K.row,P.row)??0;return B!==0?B:K.index-P.index}).map(K=>K.row),[U,v,D]);m.useEffect(()=>{b!=null&&(L.some(K=>K.key===b)||C(null))},[L,b]),m.useEffect(()=>{const K=P=>{const H=P.target,B=H instanceof HTMLInputElement||H instanceof HTMLTextAreaElement||(H?.isContentEditable??!1);if(P.key==="Escape"&&b!=null){P.preventDefault(),C(null);return}if(B)return;const Q=P.key==="j"||P.key==="ArrowDown",oe=P.key==="k"||P.key==="ArrowUp";if(Q||oe){if(q.length===0)return;P.preventDefault();const ne=q.findIndex(ae=>ae.key===b),X=Q?q[Math.min(q.length-1,ne<0?0:ne+1)]:q[Math.max(0,ne<0?0:ne-1)];X&&C(X.key);return}if(P.key==="Enter"&&b!=null){P.preventDefault();return}};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[q,b]);const Z=K=>{h(P=>{const H=new Set(P);return H.has(K)?H.delete(K):H.add(K),H})},$=K=>{x(P=>{const H=new Set(P);return H.has(K)?H.delete(K):H.add(K),H})},G=m.useMemo(()=>b!=null?L.find(K=>K.key===b)??null:null,[L,b]),V=m.useMemo(()=>G?n?.processes.find(K=>K.pid===G.pid)??null:null,[n,G]),Y=m.useMemo(()=>G?e.filter(K=>G.sessionId?K.sessionId===G.sessionId:K.pid===G.pid).slice(-40):[],[e,G]);return s.jsxs("div",{className:"s-atop",children:[s.jsx(Sxe,{summary:I,runHistory:S,toolHistory:N}),s.jsx(Vg,{title:"Harness families",size:"compact",maxAgents:6,maxTasks:3,showEmpty:!0}),s.jsx(Cxe,{search:c,onSearch:u,harnessOptions:z,harnessFilter:f,onToggleHarness:Z,statusOptions:_,statusFilter:p,onToggleStatus:$,summary:I}),s.jsx(Hk,{rows:U,columns:Exe,rowId:K=>K.key,storageKey:"openscout.atop.cols",sort:v,onSortChange:y,secondarySort:D,onRowClick:K=>C(K.key),rowClassName:K=>b===K.key?"s-atop-row--selected":void 0,empty:{title:"no agents match",body:"adjust filters or start a session to populate"},density:"compact",className:"s-atop-data-table",ariaLabel:"Agent activity inventory"}),s.jsx(Txe,{shown:q.length,total:L.length,hasSelection:b!=null}),G&&s.jsx(Mxe,{row:G,process:V,events:Y,now:a,onClose:()=>C(null)})]})}function Sxe({summary:e,runHistory:t,toolHistory:n}){return s.jsxs("div",{className:"s-atop-summary",children:[s.jsxs("div",{className:"s-atop-summary-cell s-atop-summary-cell--primary",children:[s.jsxs("div",{className:"s-atop-summary-num",children:[s.jsx("strong",{children:e.running}),s.jsxs("span",{className:"s-atop-summary-of",children:["/ ",e.total]})]}),s.jsx("span",{className:"s-atop-summary-lbl",children:"active"}),s.jsx(gI,{values:t,color:"var(--green)"})]}),s.jsxs("div",{className:"s-atop-summary-cell",children:[s.jsx("div",{className:"s-atop-summary-num",children:s.jsx("strong",{children:e.tooling})}),s.jsx("span",{className:"s-atop-summary-lbl",children:"working"}),s.jsx(gI,{values:n,color:"var(--accent)"})]}),s.jsxs("div",{className:"s-atop-summary-cell",children:[s.jsx("div",{className:"s-atop-summary-num",children:s.jsx("strong",{children:e.idle})}),s.jsx("span",{className:"s-atop-summary-lbl",children:"idle"})]}),s.jsxs("div",{className:"s-atop-summary-cell s-atop-summary-cell--breakdown",children:[s.jsx("span",{className:"s-atop-summary-lbl",children:"harness"}),s.jsx("div",{className:"s-atop-summary-row",children:e.harnesses.length>0?e.harnesses.slice(0,4).map(r=>s.jsxs("span",{className:Qk(r.harness),children:[r.harness," ",r.count]},r.harness)):s.jsx("span",{className:"s-atop-chip s-atop-chip--mute",children:"none"})})]}),s.jsx("div",{className:"s-atop-summary-spacer"}),s.jsxs("div",{className:"s-atop-summary-cell s-atop-summary-cell--rate",children:[s.jsxs("div",{className:"s-atop-summary-num",children:[s.jsx("strong",{children:e.reqsPerMin}),s.jsx("span",{className:"s-atop-summary-of",children:"/ min"})]}),s.jsx("span",{className:"s-atop-summary-lbl",children:"requests"})]})]})}function Cxe({search:e,onSearch:t,harnessOptions:n,harnessFilter:r,onToggleHarness:a,statusOptions:o,statusFilter:c,onToggleStatus:u,summary:f}){const h=v=>f.harnesses.find(y=>y.harness===v)?.count??0,p=v=>v==="tool"?f.tooling:v==="run"?f.running-f.tooling:f.idle,x=m.useRef(null);return m.useEffect(()=>{const v=y=>{if(y.key!=="/")return;const b=y.target;b instanceof HTMLInputElement||b instanceof HTMLTextAreaElement||(b?.isContentEditable??!1)||(y.preventDefault(),x.current?.focus())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[]),s.jsxs("div",{className:"s-atop-fbar",children:[s.jsxs("div",{className:"s-atop-search",children:[s.jsx("span",{className:"s-atop-search-prompt",children:"▸"}),s.jsx("input",{ref:x,className:"s-atop-search-input",value:e,onChange:v=>t(v.target.value),placeholder:"filter by pid · project · command · summary",spellCheck:!1}),s.jsx("span",{className:"s-atop-search-kbd",children:"/"})]}),n.length>1&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"s-atop-fbar-label",children:"harness"}),n.map(v=>{const y=r.has(v);return s.jsxs("button",{className:`s-atop-pill s-atop-pill--harness${y?" s-atop-pill--on":""}`,onClick:()=>a(v),children:[v,s.jsx("span",{className:"s-atop-pill-ct",children:h(v)})]},v)})]}),o.length>1&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"s-atop-fbar-label",children:"status"}),["tool","run","idle"].filter(v=>o.includes(v)).map(v=>{const y=c.has(v);return s.jsxs("button",{className:`s-atop-pill s-atop-pill--status-${v}${y?" s-atop-pill--on":""}`,onClick:()=>u(v),children:[Xk[v],s.jsx("span",{className:"s-atop-pill-ct",children:p(v)})]},v)})]}),s.jsx("div",{className:"s-atop-fbar-spacer"})]})}const Exe=[{key:"status",label:"Status",cls:"s-atop-col-status",kind:"text",defaultWidth:96,minWidth:70,sortValue:e=>cf[e.status],render:e=>s.jsxs("span",{className:`s-atop-status s-atop-status--${e.status}`,children:[s.jsx("span",{className:"s-atop-status-dot"}),Xk[e.status]]})},{key:"agent",label:"Agent",cls:"s-atop-col-agent",kind:"text",tip:"Harness · short session id",defaultWidth:168,minWidth:110,sortValue:e=>`${e.harness}\0${e.sessionId??""}`,render:e=>s.jsxs("div",{className:"s-atop-agent-cell",children:[s.jsx("span",{className:Qk(e.harness),title:`origin: ${og[e.attribution]}`,children:e.harness}),s.jsx("span",{className:"s-atop-agent-id",title:e.sessionId??`pid ${e.pid}`,children:Tw(e.sessionId)})]})},{key:"project",label:"Project",cls:"s-atop-col-project",kind:"text",defaultWidth:200,minWidth:96,maxWidth:480,sortValue:e=>e.project,render:e=>s.jsx("span",{title:e.cwd,children:e.project})},{key:"reqs",label:"Reqs",cls:"s-atop-col-num",kind:"number",tip:"Model invocations (assistant turns) for this session",defaultWidth:64,minWidth:56,sortValue:e=>e.reqCount,render:e=>s.jsx(id,{value:e.reqCount||null})},{key:"tokIn",label:"Tok ↓",cls:"s-atop-col-num",kind:"number",tip:"Input tokens — populated when backend emits usage",defaultWidth:64,minWidth:56,sortValue:e=>e.tokIn,render:e=>s.jsx(id,{value:e.tokIn})},{key:"tokOut",label:"Tok ↑",cls:"s-atop-col-num",kind:"number",tip:"Output tokens — populated when backend emits usage",defaultWidth:64,minWidth:56,sortValue:e=>e.tokOut,render:e=>s.jsx(id,{value:e.tokOut})},{key:"cache",label:"Cache",cls:"s-atop-col-num",kind:"number",tip:"Cache hit rate — populated when backend emits usage",defaultWidth:64,minWidth:56,sortValue:e=>Fc(e),render:e=>s.jsx(Axe,{value:Fc(e)})},{key:"tools",label:"Tools",cls:"s-atop-col-num",kind:"number",defaultWidth:64,minWidth:56,sortValue:e=>e.toolCount,render:e=>s.jsx(id,{value:e.toolCount||null})},{key:"perms",label:"Perms",cls:"s-atop-col-num",kind:"number",tip:"Permission requests — heuristic count of permission-mode events",defaultWidth:64,minWidth:56,sortValue:e=>e.permCount,render:e=>s.jsx(id,{value:e.permCount||null,accent:e.permCount>0?"amber":void 0})},{key:"last",label:"Last",cls:"s-atop-col-last",kind:"time",defaultWidth:86,minWidth:64,sortValue:e=>e.lastEventAt,render:e=>b4(e.lastEventAt,Date.now())},{key:"runtime",label:"Runtime",cls:"s-atop-col-runtime",kind:"number",tip:"Session duration (active period in current buffer)",defaultWidth:80,minWidth:64,sortValue:e=>e.sessionRuntimeSec,render:e=>y4(e.sessionRuntimeSec)}];function id({value:e,accent:t}){const n=e==null?"s-atop-col-num s-atop-col-num--dim":`s-atop-col-num${t?` s-atop-col-num--${t}`:""}`;return s.jsx("span",{className:n,children:Lo(e)})}function Axe({value:e}){const t=e==null?"s-atop-col-num s-atop-col-num--dim":"s-atop-col-num";return s.jsx("span",{className:t,children:j4(e)})}function Txe({shown:e,total:t,hasSelection:n}){return s.jsxs("div",{className:"s-atop-keys",children:[s.jsxs("span",{className:"s-atop-keys-count",children:[s.jsx("strong",{children:e})," / ",t," agents"]}),s.jsx("span",{className:"s-atop-keys-spacer"}),s.jsxs("span",{children:[s.jsx("kbd",{children:"/"})," filter"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"j"}),"/",s.jsx("kbd",{children:"k"})," select"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"click"})," drill in"]}),n&&s.jsxs("span",{children:[s.jsx("kbd",{children:"esc"})," close"]})]})}function Mxe({row:e,process:t,events:n,now:r,onClose:a}){const o=m.useMemo(()=>{const u={};for(const p of n){if(p.kind!=="tool")continue;const x=p.summary.match(/^([a-z_][a-z0-9_]*)/i),v=x?x[1]:"(tool)";u[v]=(u[v]??0)+1}const f=Object.entries(u).sort((p,x)=>x[1]-p[1]).slice(0,6),h=Math.max(1,...f.map(p=>p[1]));return f.map(([p,x])=>({name:p,count:x,frac:x/h}))},[n]),c=n.slice(-40).reverse();return s.jsxs("aside",{className:"s-atop-drawer","aria-label":`Agent ${e.key}`,children:[s.jsxs("header",{className:"s-atop-drawer-head",children:[s.jsxs("div",{className:"s-atop-drawer-head-meta",children:[s.jsxs("span",{className:`s-atop-status s-atop-status--${e.status}`,children:[s.jsx("span",{className:"s-atop-status-dot"}),Xk[e.status]]}),s.jsx("span",{className:"s-atop-drawer-pid",children:e.pid>0?`pid ${e.pid}`:"transcript"}),s.jsx("span",{className:Qk(e.harness),title:`origin: ${og[e.attribution]}`,children:e.harness}),s.jsxs("span",{className:"s-atop-drawer-session",children:["session ",Tw(e.sessionId)]})]}),s.jsx("h2",{className:"s-atop-drawer-title",children:e.project}),s.jsxs("p",{className:"s-atop-drawer-sub",children:["session ",Tw(e.sessionId)," · runtime ",y4(e.sessionRuntimeSec)," · last activity ",b4(e.lastEventAt,r)]}),s.jsx("button",{className:"s-atop-drawer-close",onClick:a,"aria-label":"Close (Esc)",children:"✕"})]}),s.jsxs("div",{className:"s-atop-drawer-body",children:[s.jsxs("section",{children:[s.jsx("h3",{className:"s-atop-drawer-h3",children:"Activity"}),s.jsxs("div",{className:"s-atop-metrics",children:[s.jsx(bi,{label:"Requests",value:Lo(e.reqCount||null)}),s.jsx(bi,{label:"Tools",value:Lo(e.toolCount||null)}),s.jsx(bi,{label:"Permissions",value:Lo(e.permCount||null),accent:e.permCount>0?"amber":void 0}),s.jsx(bi,{label:"Tok in",value:Lo(e.tokIn),dim:e.tokIn==null}),s.jsx(bi,{label:"Tok out",value:Lo(e.tokOut),dim:e.tokOut==null}),s.jsx(bi,{label:"Cache hit",value:j4(Fc(e)),dim:Fc(e)==null}),s.jsx(bi,{label:"Model",value:e.model??"—",dim:e.model==null}),s.jsx(bi,{label:"Events",value:Lo(e.eventCount||null)})]})]}),o.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"s-atop-drawer-h3",children:"Tool calls"}),s.jsx("ul",{className:"s-atop-histo",children:o.map(u=>s.jsxs("li",{children:[s.jsx("span",{className:"s-atop-histo-name",children:u.name}),s.jsx("span",{className:"s-atop-histo-bar",children:s.jsx("span",{className:"s-atop-histo-fill",style:{width:`${(u.frac*100).toFixed(1)}%`}})}),s.jsx("span",{className:"s-atop-histo-count",children:u.count})]},u.name))})]}),s.jsxs("section",{children:[s.jsxs("h3",{className:"s-atop-drawer-h3",children:["Recent activity",s.jsxs("span",{className:"s-atop-drawer-h3-aside",children:[n.length," buffered"]})]}),c.length===0?s.jsx("div",{className:"s-atop-peek-empty",children:"no events buffered for this agent yet"}):s.jsx("ol",{className:"s-atop-peek",children:c.map(u=>s.jsxs("li",{className:`s-atop-peek-row s-atop-peek-row--${u.kind}`,children:[s.jsx("span",{className:"s-atop-peek-time",children:pxe(u.ts)}),s.jsx("span",{className:"s-atop-peek-kind",children:u.kind}),s.jsx("span",{className:"s-atop-peek-text",children:u.summary})]},u.id))})]}),s.jsxs("section",{className:"s-atop-drawer-section--secondary",children:[s.jsx("h3",{className:"s-atop-drawer-h3",children:"Process"}),s.jsx("code",{className:"s-atop-codeblock",children:e.command}),s.jsxs("dl",{className:"s-atop-kvs",children:[s.jsx("dt",{children:"PID"}),s.jsx("dd",{children:e.pid>0?e.pid:"transcript-only"}),s.jsx("dt",{children:"Parent"}),s.jsxs("dd",{children:[e.parentLabel," (ppid ",e.ppid,")"]}),s.jsx("dt",{children:"Process etime"}),s.jsx("dd",{children:e.procEtime}),e.transcriptPath&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Transcript"}),s.jsx("dd",{children:e.transcriptPath})]}),s.jsx("dt",{children:"Origin"}),s.jsx("dd",{children:og[e.attribution]}),s.jsx("dt",{children:"CWD"}),s.jsx("dd",{children:e.cwd||"(none)"})]}),t?.parentChain&&t.parentChain.length>0&&s.jsx("ol",{className:"s-atop-chain",children:t.parentChain.map(u=>s.jsxs("li",{children:[s.jsx("span",{className:"s-atop-chain-pid",children:u.pid}),s.jsx("span",{className:"s-atop-chain-cmd",children:fxe(u.command,80)})]},u.pid))})]})]})]})}function bi({label:e,value:t,dim:n,accent:r}){const a=`s-atop-metric${n?" s-atop-metric--dim":""}${r?` s-atop-metric--${r}`:""}`;return s.jsxs("div",{className:a,children:[s.jsx("span",{className:"s-atop-metric-lbl",children:e}),s.jsx("span",{className:"s-atop-metric-val",children:t})]})}function Rxe({navigate:e,mode:t="mission",tailQuery:n}){const{agents:r,route:a}=qe(),o=a.view==="ops"&&a.mode==="plan"?a.planDocumentId:void 0;return s.jsxs("div",{className:"s-ops",children:[s.jsx("div",{className:"s-ops-header",children:s.jsx(Ef,{activeRoute:a,navigate:e})}),s.jsxs("div",{className:"s-ops-body",children:[t==="mission"&&s.jsx(Ave,{navigate:e,agents:r}),t==="agents"&&s.jsx(nxe,{navigate:e,agents:r}),t==="plan"&&s.jsx(ixe,{navigate:e,agents:r,selectedPlanDocumentId:o}),t==="issues"&&s.jsx(Qp,{navigate:e,initialFilter:n,variant:"issues"}),t==="tail"&&s.jsx(Qp,{navigate:e,initialFilter:n}),t==="atop"&&s.jsx(Nxe,{})]}),s.jsx(Dge,{})]})}function Ixe(e){return e==="pi"?"pi":void 0}function _xe(e,t){return`scout-tmux-${e}-${t}`}function Oxe(e,t){if(!t)return e;try{const n=new URL(e);return n.searchParams.set("agentId",t),n.toString()}catch{const n=e.includes("?")?"&":"?";return`${e}${n}agentId=${encodeURIComponent(t)}`}}function $xe(e,t){return t==="takeover"&&!!e&&e?.transport!=="tmux"}const Lxe=132,Pxe=44,Dxe=typeof window>"u"?m.useEffect:m.useLayoutEffect;function zxe({agentId:e,mode:t,navigate:n}){const{agents:r}=qe(),a=e?r.find(u=>u.id===e):null;if(e&&!a)return s.jsx("div",{className:"s-term",children:s.jsxs("div",{className:"s-term-bar",children:[s.jsx(zr,{slot:"terminal",fallback:{view:"agents"},navigate:n,className:"s-term-back"}),s.jsx("span",{className:"s-term-label",children:"Terminal"}),s.jsx("div",{className:"s-term-status",children:"Resolving agent..."})]})});const o=a?.transport==="tmux"?a.harnessSessionId:null,c=a&&o?`tmux:${a.id}:${o}`:e?`takeover:${e}`:"takeover";return s.jsx(Bxe,{agentId:e,agent:a,mode:t,navigate:n,children:s.jsx(Fxe,{agentId:e,agent:a,mode:t,navigate:n})},c)}function Bxe({agentId:e,agent:t,mode:n,navigate:r,children:a}){const o=$xe(t,n),[c,u]=m.useState(o?{state:"preparing"}:{state:"ready"}),[f,h]=m.useState(0);return m.useEffect(()=>{if(!o||!e){u({state:"ready"});return}let p=!1;return u({state:"preparing"}),ue(`/api/agents/${encodeURIComponent(e)}/session-catalog`).then(x=>{if(x.resumeCommand)return Nf({command:x.resumeCommand,cwd:x.resumeCwd,agentId:e})}).then(()=>{p||u({state:"ready"})}).catch(x=>{p||u({state:"failed",error:x instanceof Error?x.message:String(x)})}),()=>{p=!0}},[e,o,f]),c.state==="ready"?s.jsx(s.Fragment,{children:a}):s.jsx(Uxe,{agent:t,agentId:e,navigate:r,label:c.state==="failed"?"TAKEOVER FAILED":"PREPARING TAKEOVER",status:c.state==="failed"?c.error:"Resolving live session...",onRetry:c.state==="failed"?()=>h(p=>p+1):void 0})}function Uxe({agent:e,agentId:t,navigate:n,label:r,status:a,onRetry:o}){const c=e?Xt(e.name):"var(--accent)";return s.jsxs("div",{className:"s-term",children:[s.jsxs("div",{className:"s-term-bar",children:[s.jsx(zr,{slot:"terminal",fallback:t?{view:"agents",agentId:t}:{view:"inbox"},navigate:n,className:"s-term-back"}),e&&s.jsxs("div",{className:"s-term-agent",children:[s.jsx("div",{className:"s-ops-avatar",style:{"--size":"18px",background:c},children:e.name[0]?.toUpperCase()}),s.jsx("span",{className:"s-term-agent-name",children:e.name}),e.handle&&s.jsxs("span",{className:"s-term-agent-handle",children:["@",e.handle]})]}),s.jsx("span",{className:"s-term-label",children:r}),s.jsxs("div",{className:"s-term-status",children:[s.jsx("span",{className:"s-term-dot s-term-dot--connecting"}),o?"OFFLINE":"CONNECTING"]})]}),s.jsx("div",{className:"s-term-body s-term-body--placeholder",children:s.jsxs("div",{className:"s-term-placeholder",children:[s.jsx("span",{children:a}),o&&s.jsx("button",{type:"button",onClick:o,children:"Retry"})]})})]})}function Fxe({agentId:e,agent:t,mode:n,navigate:r}){const a=t?Xt(t.name):"var(--accent)",o=t?.transport==="tmux"?t.harnessSessionId:null,c=n==="observe",u=t?.cwd??t?.projectRoot??void 0,f=Ixe(t?.harness),[h,p]=m.useState({state:"idle"}),x=xP(),v=yP(),y=Oxe(x,e),b=ij({url:y,healthUrl:v,autoConnect:!0,sessionKey:t&&o?_xe(t.id,o):e?`scout-takeover-${e}`:"scout-takeover",...o?{backend:"tmux",tmuxSession:o}:{},...u?{cwd:u}:{},...f?{agent:f}:{}});Dxe(()=>{b.resize(Lxe,Pxe)},[b.resize]);const C=m.useMemo(()=>c?{...b,sendInput:()=>{},sendLine:()=>{},restart:()=>{}}:b,[c,b]),E=()=>{p({state:"opening"}),UD({agentId:e??null,launch:!0}).then(A=>{const S=A.plan.manifest.nodes.length,k=BD(A);if(S===0){const T=A.plan.diagnostics.find(R=>R.severity==="warning")??A.plan.diagnostics[0];p({state:"failed",error:T?`${k} · no windows: ${T.message}`:`${k} · no Vantage windows.`});return}if(!A.launch.ok&&A.launch.error){p({state:"failed",error:A.launch.error});return}const N=A.launch.ok?"Vantage launch requested":"Vantage handoff written";p({state:"opened",detail:`${k} · ${S} node${S===1?"":"s"} · ${N}`})}).catch(A=>{p({state:"failed",error:A instanceof Error?A.message:String(A)})})};return s.jsxs("div",{className:"s-term",children:[s.jsxs("div",{className:"s-term-bar s-term-bar--takeover",children:[s.jsxs("div",{className:"s-term-bar-left",children:[s.jsx(zr,{slot:"terminal",fallback:e?{view:"agents",agentId:e}:{view:"inbox"},navigate:r,className:"s-term-back"}),t&&s.jsxs("div",{className:"s-term-agent",children:[s.jsx("div",{className:"s-ops-avatar",style:{"--size":"18px",background:a},children:t.name[0]?.toUpperCase()}),s.jsx("span",{className:"s-term-agent-name",children:t.name}),t.handle&&s.jsxs("span",{className:"s-term-agent-handle",children:["@",t.handle]})]})]}),s.jsxs("div",{className:"s-term-bar-meta",children:[s.jsx("span",{className:"s-term-label",children:o?c?"TMUX OBSERVE":"TMUX TAKEOVER":"TAKEOVER"}),o&&s.jsx("span",{className:"s-term-session",title:o,children:o})]}),s.jsxs("div",{className:"s-term-bar-actions",children:[o&&s.jsx("button",{type:"button",className:"s-term-vantage",onClick:()=>r({view:"terminal",agentId:e,mode:c?"takeover":"observe"}),title:c?"Switch to interactive takeover":"Switch to read-only terminal observe",children:c?"Takeover":"Observe"}),s.jsx("button",{type:"button",className:"s-term-vantage",onClick:E,disabled:h.state==="opening",title:"Open this terminal context in the native Vantage canvas",children:h.state==="opening"?"Opening...":"Open in Vantage"}),h.state==="opened"&&s.jsx("span",{className:"s-term-handoff s-term-handoff--ok",children:h.detail}),h.state==="failed"&&s.jsx("span",{className:"s-term-handoff s-term-handoff--error",children:h.error}),s.jsxs("div",{className:"s-term-status",children:[s.jsx("span",{className:`s-term-dot${b.status==="connected"?" s-term-dot--live":b.status==="connecting"?" s-term-dot--connecting":""}`}),b.status==="connected"?"LIVE":b.status==="connecting"?"CONNECTING":"OFFLINE"]})]})]}),s.jsx("div",{className:"s-term-body",children:s.jsx(oj,{relay:C,fontSize:13,quiet:!0,configItems:[...o?[{label:"backend",value:"tmux"},{label:"session",value:o},{label:"mode",value:c?"read-only":"takeover"}]:[],{label:"ws",value:y},{label:"health",value:v}]})})]})}const Vxe=new Set(["png","jpg","jpeg","gif","webp","avif","svg"]),vI=[{value:"all",label:"All"},{value:"plan",label:"Plans"},{value:"doc",label:"Docs"},{value:"code",label:"Code"},{value:"test",label:"Tests"},{value:"config",label:"Config"},{value:"asset",label:"Assets"}];function Hxe(e){const t=e.split("/").pop()??e,n=t.lastIndexOf(".");return n>=0?t.slice(n+1).toLowerCase():""}function k4(e){return Vxe.has(Hxe(e.path))}function Wxe(e){const t={type:"dir",children:[]};for(const n of e){const r=n.path.split("/").filter(Boolean);if(r.length===0)continue;let a=t;for(let o=0;o<r.length-1;o+=1){const c=r[o],u=r.slice(0,o+1).join("/");let f=a.children.find(h=>h.type==="dir"&&h.name===c);f||(f={type:"dir",name:c,path:u,children:[]},a.children.push(f)),a=f}a.children.push({type:"file",name:r[r.length-1],path:n.path,material:n})}return N4(t),S4(t.children)}function N4(e){if(e.type==="dir"){e.children.sort((t,n)=>t.type!==n.type?t.type==="dir"?-1:1:t.name.localeCompare(n.name));for(const t of e.children)N4(t)}}function S4(e){return e.map(t=>{if(t.type!=="dir")return t;let n=t;for(;n.children.length===1&&n.children[0].type==="dir";){const r=n.children[0];n={type:"dir",name:`${n.name}/${r.name}`,path:r.path,children:r.children}}return{...n,children:S4(n.children)}})}function qxe(e){switch(e){case"added":return"A";case"modified":return"M";case"deleted":return"D";case"renamed":return"R";case"untracked":return"?";case"observed":return null}}function C4({node:e,depth:t,selectedId:n,collapsed:r,onToggle:a,onSelect:o}){if(e.type==="dir"){const p=r.has(e.path);return s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:"s-work-files-tree-row s-work-files-tree-dir",style:{paddingLeft:`${8+t*12}px`},onClick:()=>a(e.path),children:[s.jsx("span",{className:"s-work-files-tree-chevron","aria-hidden":"true",children:p?s.jsx(hg,{size:12,strokeWidth:1.8}):s.jsx(Xo,{size:12,strokeWidth:1.8})}),s.jsx("span",{className:"s-work-files-tree-icon","aria-hidden":"true",children:p?s.jsx(N2,{size:12,strokeWidth:1.8}):s.jsx(tB,{size:12,strokeWidth:1.8})}),s.jsx("span",{className:"s-work-files-tree-name",children:e.name||"/"})]}),!p&&e.children.map(x=>s.jsx(C4,{node:x,depth:t+1,selectedId:n,collapsed:r,onToggle:a,onSelect:o},x.type==="dir"?`d:${x.path}`:`f:${x.material.id}`))]})}const c=e.material.id===n,u=k4(e.material),f=qxe(e.material.status),h=e.material.status==="deleted";return s.jsxs("button",{type:"button",className:`s-work-files-tree-row s-work-files-tree-file${c?" s-work-files-tree-file-selected":""}`,style:{paddingLeft:`${8+t*12}px`},onClick:()=>o(e.material),disabled:h,title:e.path,children:[s.jsx("span",{className:"s-work-files-tree-chevron","aria-hidden":"true"}),s.jsx("span",{className:"s-work-files-tree-icon","aria-hidden":"true",children:u?s.jsx(dB,{size:12,strokeWidth:1.8}):s.jsx(Dd,{size:12,strokeWidth:1.8})}),s.jsx("span",{className:"s-work-files-tree-name",children:e.name}),f&&s.jsx("span",{className:`s-work-files-tree-status s-work-files-tree-status-${e.material.status}`,"aria-label":e.material.status,children:f})]})}function Kxe({path:e}){const t=e.split("/").filter(Boolean);if(t.length===0)return s.jsx("span",{className:"s-work-files-breadcrumb",children:e});const n=t[t.length-1],r=t.slice(0,-1).join("/");return s.jsxs("span",{className:"s-work-files-breadcrumb",children:[r&&s.jsxs("span",{className:"s-work-files-breadcrumb-folder",children:[r,"/"]}),s.jsx("span",{className:"s-work-files-breadcrumb-name",children:n})]})}function Gxe({workId:e,material:t}){const n=k4(t),[r,a]=m.useState(null),[o,c]=m.useState(null),[u,f]=m.useState(!1);if(m.useEffect(()=>{if(n){a(null),c(null),f(!1);return}let p=!1;return f(!0),c(null),a(null),ue(`/api/work/${encodeURIComponent(e)}/material?materialId=${encodeURIComponent(t.id)}`).then(x=>{p||a(x)}).catch(x=>{p||c(x instanceof Error?x.message:String(x))}).finally(()=>{p||f(!1)}),()=>{p=!0}},[n,t.id,e]),n){const p=`/api/work/${encodeURIComponent(e)}/material/raw?materialId=${encodeURIComponent(t.id)}`;return s.jsx("div",{className:"s-work-files-pane s-work-files-pane-image",children:s.jsx("img",{src:p,alt:t.path,className:"s-work-files-image"})})}if(u&&!r)return s.jsx("div",{className:"s-work-files-pane-state",children:"Loading file…"});if(o)return s.jsx("div",{className:"s-work-files-pane-state s-work-files-pane-error",children:o});if(!r)return s.jsx("div",{className:"s-work-files-pane-state",children:"No content."});const h=Qc({id:r.materialId,title:r.title,uri:r.uri,mediaType:r.mediaType,value:r.content,readOnly:!0});return s.jsxs("div",{className:"s-work-files-pane",children:[s.jsx(jf,{document:h,mode:h.kind==="markdown"?"preview":"read"}),r.truncated&&s.jsxs("div",{className:"s-work-files-pane-notice",children:["Preview truncated at ",Math.round(r.content.length/1024)," KB."]})]})}function Zxe({workId:e,workTitle:t,materials:n,open:r,initialKind:a="all",onClose:o}){const c=m.useMemo(()=>n.filter(k=>k.status!=="deleted"),[n]),[u,f]=m.useState(a),[h,p]=m.useState(null),[x,v]=m.useState(()=>new Set);m.useEffect(()=>{r&&f(a)},[a,r]);const y=m.useMemo(()=>u==="all"?c:u==="plan"?c.filter(k=>k.kind==="plan"||k.kind==="spec"):c.filter(k=>k.kind===u),[c,u]),b=m.useMemo(()=>Wxe(y),[y]);m.useEffect(()=>{if(!h&&y.length>0){p(y[0].id);return}h&&!y.some(k=>k.id===h)&&p(y[0]?.id??null)},[y,h]);const C=m.useCallback(k=>{p(k.id)},[]),E=m.useCallback(k=>{v(N=>{const T=new Set(N);return T.has(k)?T.delete(k):T.add(k),T})},[]),A=y.find(k=>k.id===h)??null,S=m.useMemo(()=>{const k={all:c.length};for(const N of vI)N.value!=="all"&&(k[N.value]=c.filter(T=>N.value==="plan"?T.kind==="plan"||T.kind==="spec":T.kind===N.value).length);return k},[c]);return s.jsx(Fg,{open:r,kind:"code",document:null,title:`Files · ${c.length}`,eyebrow:"Work materials",subtitle:t,focusable:!0,onClose:o,body:s.jsxs("div",{className:"s-work-files-layout",children:[s.jsxs("aside",{className:"s-work-files-tree","aria-label":"File tree",children:[s.jsx("div",{className:"s-work-files-tree-filters",role:"tablist",children:vI.map(k=>{const N=S[k.value]??0;if(k.value!=="all"&&N===0)return null;const T=k.value===u;return s.jsxs("button",{type:"button",role:"tab","aria-selected":T,className:`s-work-files-tree-filter${T?" s-work-files-tree-filter-active":""}`,onClick:()=>f(k.value),children:[s.jsx("span",{children:k.label}),s.jsx("span",{className:"s-work-files-tree-filter-count",children:N})]},k.value)})}),s.jsx("div",{className:"s-work-files-tree-list",children:b.length===0?s.jsx("div",{className:"s-work-files-tree-empty",children:"No files match this filter."}):b.map(k=>s.jsx(C4,{node:k,depth:0,selectedId:h,collapsed:x,onToggle:E,onSelect:C},k.type==="dir"?`d:${k.path}`:`f:${k.material.id}`))})]}),s.jsx("section",{className:"s-work-files-content","aria-label":"File preview",children:A?s.jsxs(s.Fragment,{children:[s.jsxs("header",{className:"s-work-files-content-head",children:[s.jsx(Kxe,{path:A.path}),s.jsxs("div",{className:"s-work-files-content-meta",children:[s.jsx("span",{children:A.kind}),s.jsx("span",{children:A.status}),A.diffStat&&s.jsxs("span",{children:["+",A.diffStat.additions," -",A.diffStat.deletions]})]})]}),s.jsx(Gxe,{workId:e,material:A})]}):s.jsx("div",{className:"s-work-files-pane-state",children:"Select a file to preview."})})]})})}function xI(e){switch(e){case"review":return"In review";case"waiting":return"Waiting";case"working":return"Working";case"done":return"Done";default:return e.replace(/_/g," ")}}function Yxe(e){switch(e){case"badge":return"Noteworthy";case"interrupt":return"Blocked signal";default:return null}}function Xxe({detail:e,signal:t,ownerLabel:n,nextMoveLabel:r}){const a=r==="—"?n:r;return e.attention==="interrupt"?{eyebrow:"Network signal",title:`Blocker surfaced for ${a}`,body:e.conversationId?"Open the thread if you want the blocking context.":"No thread is attached; the record and timeline hold the current context.",tone:"blocked"}:t?{eyebrow:"Network signal",title:`Plan activity from ${a}`,body:e.conversationId?"A plan or spec discussion is active in the agent network. Open the thread only if you want context.":"A plan or spec discussion is active in the agent network, but no thread is attached yet.",tone:"attention"}:e.activeFlights.length>0||e.state==="working"?{eyebrow:"Next move",title:`${n} is working`,body:e.conversationId?"The thread has the freshest working context.":"Watch the flight list and timeline for the next update.",tone:"active"}:e.state==="waiting"||e.state==="review"?{eyebrow:"Next move",title:`Waiting on ${r}`,body:e.conversationId?"The thread has the current unblock context.":"No thread is attached; ownership and timeline are the best context.",tone:"quiet"}:e.state==="done"?{eyebrow:"Outcome",title:"Work is done",body:e.conversationId?"The thread keeps the handoff and final context.":"The record and timeline are preserved here.",tone:"quiet"}:{eyebrow:"Next move",title:r==="—"?"No next owner set":`Next move: ${r}`,body:e.conversationId?"The thread has the latest context.":"Use the record and timeline to decide where this should go next.",tone:"quiet"}}function E4({children:e,icon:t,onClick:n,primary:r=!1,disabled:a=!1}){return s.jsxs("button",{type:"button",className:`s-work-action-button${r?" s-work-action-button-primary":""}`,onClick:n,disabled:a,children:[t,s.jsx("span",{children:e})]})}function Qxe({detail:e,navigate:t}){const n=!!e.conversationId,r=e.inventory??tye(e),a=r.materials.filter(D=>D.kind==="plan"||D.kind==="spec"),o=r.materials.filter(D=>D.kind==="doc"),c=r.materials.filter(D=>D.kind==="code"||D.kind==="test"||D.kind==="config"||D.kind==="asset"||D.kind==="other"),u=a.length>0,f=o.length>0,h=eye(e),p=a[0]?sye(a[0]):h??"No plan or spec file detected yet.",x=[...a,...o,...c].filter(D=>D.status!=="deleted"),[v,y]=m.useState(!1),[b,C]=m.useState(null),[E,A]=m.useState(null),[S,k]=m.useState(null),[N,T]=m.useState(null),[R,O]=m.useState(!1),[L,I]=m.useState("all"),z=m.useCallback(D=>{y(!1),C(D)},[]),_=m.useCallback(()=>{C(null),y(!0)},[]),U=m.useCallback(D=>{y(!1),C(null),I(D),O(!0)},[]);return m.useEffect(()=>{b&&!x.some(D=>D.id===b)&&C(null)},[b,x]),m.useEffect(()=>{if(!b){A(null),k(null),T(null);return}let D=!1;return T(b),k(null),ue(`/api/work/${encodeURIComponent(e.id)}/material?materialId=${encodeURIComponent(b)}`).then(q=>{D||A(q)}).catch(q=>{D||(A(null),k(q instanceof Error?q.message:String(q)))}).finally(()=>{D||T(null)}),()=>{D=!0}},[e.id,b]),s.jsxs("section",{className:"s-work-casefile-section s-work-materials-section",children:[s.jsxs("div",{className:"s-agent-section-heading",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"s-agent-section-title",children:"Work materials"}),s.jsxs("p",{className:"s-work-section-note",children:[nye(r.mode)," · ",r.source," evidence · ",r.confidence," confidence"]})]}),s.jsxs("div",{className:"s-work-inventory-meta","aria-label":"Inventory totals",children:[s.jsxs("span",{children:[r.totals.materials," files"]}),s.jsxs("span",{children:[r.totals.agents," agents"]}),s.jsxs("span",{children:[r.totals.sessions," sessions"]})]})]}),s.jsxs("div",{className:"s-work-material-grid",children:[s.jsxs("article",{className:"s-work-material-card s-work-material-card-primary",children:[s.jsxs("div",{className:"s-work-material-head",children:[s.jsx("span",{className:"s-work-material-icon","aria-hidden":"true",children:s.jsx(Dd,{size:15,strokeWidth:1.8})}),s.jsxs("div",{children:[s.jsx("div",{className:"s-work-material-kicker",children:u?"Plans & specs":"Brief"}),s.jsx("div",{className:"s-work-material-title",children:u?`${a.length} surfaced`:h?"Original ask":"No plan file yet"})]})]}),s.jsx("p",{className:"s-work-material-copy",children:p}),s.jsx(Tb,{materials:a.slice(0,3),empty:"No plan or spec files detected yet.",selectedId:b,onOpen:z}),s.jsxs("div",{className:"s-work-material-card-actions",children:[h&&s.jsxs("button",{type:"button",className:`s-work-material-link${v?" s-work-material-link-active":""}`,onClick:_,children:[s.jsx(Dd,{"aria-hidden":"true",size:13,strokeWidth:1.8}),"View ask"]}),a.length>3&&s.jsxs("button",{type:"button",className:"s-work-material-link",onClick:()=>U("plan"),children:[s.jsx(fy,{"aria-hidden":"true",size:13,strokeWidth:1.8}),"View all ",a.length]})]})]}),s.jsxs("div",{className:`s-work-material-evidence-stack${f?"":" s-work-material-evidence-stack-single"}`,children:[f&&s.jsxs("article",{className:"s-work-material-card s-work-material-card-docs",children:[s.jsxs("div",{className:"s-work-material-head",children:[s.jsx("span",{className:"s-work-material-icon","aria-hidden":"true",children:s.jsx(N6,{size:15,strokeWidth:1.8})}),s.jsxs("div",{children:[s.jsx("div",{className:"s-work-material-kicker",children:"Docs"}),s.jsxs("div",{className:"s-work-material-title",children:[o.length," documents"]})]})]}),s.jsx(Tb,{materials:o.slice(0,3),empty:"Docs from git or trace evidence will appear here.",selectedId:b,onOpen:z}),o.length>3&&s.jsx("div",{className:"s-work-material-card-actions",children:s.jsxs("button",{type:"button",className:"s-work-material-link",onClick:()=>U("doc"),children:[s.jsx(fy,{"aria-hidden":"true",size:13,strokeWidth:1.8}),"View all ",o.length]})})]}),s.jsxs("article",{className:"s-work-material-card s-work-material-card-code",children:[s.jsxs("div",{className:"s-work-material-head",children:[s.jsx("span",{className:"s-work-material-icon","aria-hidden":"true",children:s.jsx(D6,{size:15,strokeWidth:1.8})}),s.jsxs("div",{children:[s.jsx("div",{className:"s-work-material-kicker",children:"Code"}),s.jsx("div",{className:"s-work-material-title",children:c.length>0?`${c.length} related files`:"No code yet"})]})]}),s.jsx(Tb,{materials:c.slice(0,5),empty:"Changed code from git or session traces will appear here.",selectedId:b,onOpen:z}),c.length>5&&s.jsx("div",{className:"s-work-material-card-actions",children:s.jsxs("button",{type:"button",className:"s-work-material-link",onClick:()=>U("code"),children:[s.jsx(fy,{"aria-hidden":"true",size:13,strokeWidth:1.8}),"View all ",c.length]})})]})]})]}),s.jsx(Jxe,{detail:e,summary:h,open:v,hasThread:n,navigate:t,onClose:()=>y(!1)}),s.jsx(rye,{material:x.find(D=>D.id===b)??null,content:E,loading:!!N,error:S,onClose:()=>C(null)}),s.jsx(Zxe,{workId:e.id,workTitle:e.title,materials:x,open:R,initialKind:L,onClose:()=>O(!1)}),r.limitations.length>0&&s.jsx("div",{className:"s-work-inventory-note",children:r.limitations[0]})]})}function Jxe({detail:e,summary:t,open:n,hasThread:r,navigate:a,onClose:o}){const{route:c}=qe();if(!n||!t)return null;const u=Qc({id:`${e.id}:brief`,title:"Original ask",uri:`scout://work/${e.id}/brief`,mediaType:"text/markdown",value:`# Original ask
179
-
180
- ${t}`,readOnly:!0});return s.jsx(Fg,{kind:"ask",document:u,title:"Original ask",eyebrow:"Brief",subtitle:e.title,meta:["ask",r?"thread linked":"threadless"],mode:"preview",actions:r&&e.conversationId?[{label:"Thread",icon:s.jsx(pg,{"aria-hidden":"true",size:13,strokeWidth:1.8}),onClick:()=>wt(a,{view:"conversation",conversationId:e.conversationId},{returnTo:c}),title:"Open source thread"}]:[],onClose:o})}function eye(e){const t=[...e.timeline].sort((a,o)=>a.at-o.at),n=t.find(a=>a.kind==="collaboration_event"&&a.detailKind==="created"&&a.summary),r=t.find(a=>a.kind==="message"&&a.summary);return n?.summary??r?.summary??null}function tye(e){return{workId:e.id,generatedAt:Date.now(),mode:"trace-only",source:"broker",confidence:"low",agents:[],sessions:[],materials:[],totals:{materials:0,plans:0,specs:0,docs:0,code:0,tests:0,config:0,assets:0,agents:0,sessions:0},limitations:["Inventory is not available from this server yet."]}}function nye(e){switch(e){case"isolated-git-worktree":return"Isolated git worktree";case"shared-git-repo":return"Shared git repo";case"explicit-artifacts":return"Explicit artifacts";default:return"Trace-only"}}function sye(e){const t=e.diffStat?`+${e.diffStat.additions} / -${e.diffStat.deletions}`:e.status;return`${e.path} · ${t} · ${e.confidence} confidence`}function Tb({materials:e,empty:t,selectedId:n,onOpen:r}){return e.length===0?s.jsx("div",{className:"s-work-material-empty",children:t}):s.jsx("div",{className:"s-work-material-list",children:e.map(a=>s.jsxs("button",{type:"button",className:`s-work-material-row${n===a.id?" s-work-material-row-active":""}`,title:a.path,onClick:()=>r?.(a.id),disabled:!r||a.status==="deleted",children:[s.jsx("div",{className:"s-work-material-path",children:a.path}),s.jsxs("div",{className:"s-work-material-row-meta",children:[s.jsx("span",{children:a.status}),a.diffStat&&s.jsxs("span",{children:["+",a.diffStat.additions," -",a.diffStat.deletions]}),s.jsx("span",{children:a.confidence})]})]},a.id))})}function rye({material:e,content:t,loading:n,error:r,onClose:a}){if(!e)return null;const o=t?Qc({id:t.materialId,title:t.title,uri:t.uri,mediaType:t.mediaType,value:t.content,readOnly:!0}):null;return s.jsx(Fg,{kind:aye(e),document:o,title:e.path,eyebrow:e.kind==="spec"?"Spec":e.kind,subtitle:t?.uri??e.worktreeRoot??void 0,meta:[e.status,e.confidence,...t?[yI(t.sizeBytes)]:[]],mode:o?.kind==="markdown"?"preview":"read",state:n||!t&&!r?"Loading file...":null,error:n?null:r,notice:t?.truncated?`Preview truncated at ${yI(t.content.length)}.`:null,onClose:a})}function aye(e){return e.kind==="plan"||e.kind==="spec"?"plan":e.kind==="doc"?"doc":"code"}function yI(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function A4(e){const t=e.split(".");return t[t.length-1]||e}function Vn(e,t){const n=t?.trim();!n||n.length<3||e.add(n)}function Mb(e,t){Vn(e,t);const r=t?.trim().replace(/\/+$/,"")?.split("/").filter(Boolean).at(-1);r&&r.length>=3&&e.add(r)}function iye(e){return e.replace(/^\/Users\/[^/]+/,"~")}function oye(e){const t=new Set,n=[],r=e.ownerName??e.ownerId??e.nextMoveOwnerName??e.nextMoveOwnerId;Vn(t,e.id),Vn(t,e.conversationId),Vn(t,e.ownerId),Vn(t,e.nextMoveOwnerId),Vn(t,e.ownerName),Vn(t,e.nextMoveOwnerName);for(const o of e.activeFlights)Vn(t,o.id),Vn(t,o.invocationId),Vn(t,o.agentId),Vn(t,o.agentName),Vn(t,o.conversationId),Vn(t,o.collaborationRecordId);for(const o of e.inventory?.agents??[])Vn(t,o.id),Vn(t,o.name),Vn(t,o.sessionId),Mb(t,o.cwd),Mb(t,o.projectRoot);const a=e.inventory?.sessions.find(o=>o.cwd)??e.inventory?.sessions[0]??null;for(const o of e.inventory?.sessions??[])Vn(t,o.id),Vn(t,o.conversationId),Vn(t,o.agentId),Vn(t,o.agentName),Mb(t,o.cwd);return r&&n.push(r),a?.cwd&&n.push(iye(a.cwd)),{query:[...t].slice(0,20).join("|"),label:n.length>0?n.join(" · "):`Case ${A4(e.id)}`}}function lye({detail:e,navigate:t}){const{route:n}=qe(),r=oye(e);return s.jsxs("section",{className:"s-work-casefile-section s-work-tail-section",children:[s.jsxs("div",{className:"s-agent-section-heading s-work-tail-heading",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"s-agent-section-title s-work-tail-title",children:[s.jsx(k2,{"aria-hidden":"true",size:15,strokeWidth:1.8}),"Live tail"]}),s.jsxs("p",{className:"s-work-section-note",children:["Filtered to ",r.label]})]}),s.jsx(E4,{icon:s.jsx(wr,{"aria-hidden":"true",size:13,strokeWidth:1.8}),onClick:()=>wt(t,{view:"ops",mode:"tail",tailQuery:r.query||void 0},{returnTo:n}),children:"Open Tail"})]}),s.jsx("div",{className:"s-work-tail-frame",children:s.jsx(Qp,{navigate:t,initialFilter:r.query,filterLabel:r.label,filterScope:"context",chrome:"embedded"})})]})}function cye({workId:e,navigate:t}){const{agents:n,route:r}=qe(),[a,o]=m.useState(null),[c,u]=m.useState(null),[f,h]=m.useState(!1),p=m.useCallback(async()=>{u(null);try{const N=await ue(`/api/work/${encodeURIComponent(e)}`);o(N)}catch(N){u(N instanceof Error?N.message:String(N)),o(null)}finally{h(!0)}},[e]);m.useEffect(()=>{h(!1),p()},[p]),Vt(()=>{p()});const x=zs(r),v=m.useMemo(()=>cl(n,x),[n,x]),y=m.useMemo(()=>a?Sie(a,v):null,[a,v]);if(!f)return s.jsxs("div",{children:[s.jsx(zr,{slot:"work",fallback:{view:"inbox"},navigate:t}),s.jsx("div",{className:"s-empty",children:s.jsx("p",{children:"Loading…"})})]});if(!a||!y)return s.jsxs("div",{className:"s-work-not-found",children:[s.jsx(zr,{slot:"work",fallback:{view:"inbox"},navigate:t}),s.jsxs("div",{className:"s-work-not-found-body",children:[s.jsx("div",{className:"s-work-not-found-glyph","aria-hidden":"true",children:"□"}),s.jsx("h2",{className:"s-work-not-found-title",children:a?"Work item outside this machine scope":"Work item not found"}),s.jsx("p",{className:"s-work-not-found-sub",children:a?"Clear the machine scope or switch machines to inspect this work item.":"This work item may have been removed or does not exist on this broker."}),c&&s.jsx("p",{className:"s-work-not-found-detail",children:c})]})]});const b=y,C=Yxe(b.attention),E=b.ownerName??b.ownerId??"Unassigned",A=b.nextMoveOwnerName??b.nextMoveOwnerId??"—",S=Xxe({detail:b,signal:C,ownerLabel:E,nextMoveLabel:A}),k=b.activeFlights.length>0||b.childWork.length>0;return s.jsxs("div",{className:"s-work-detail s-work-casefile",children:[s.jsxs("div",{className:"s-work-casefile-topbar",children:[s.jsx(zr,{slot:"work",fallback:{view:"inbox"},navigate:t}),s.jsxs("span",{className:"s-work-casefile-record",children:["Case ",A4(b.id)]})]}),c&&s.jsx("p",{className:"s-error",children:c}),s.jsxs("section",{className:"s-work-casefile-hero",children:[s.jsxs("div",{className:"s-work-casefile-hero-main",children:[s.jsxs("div",{className:"s-work-casefile-title-row",children:[s.jsx("h1",{className:"s-work-casefile-title",children:b.title}),s.jsx(Wa,{tone:zD(b),variant:"pill",children:b.currentPhase})]}),b.lastMeaningfulSummary&&s.jsx("div",{className:"s-work-casefile-summary",children:yr(b.lastMeaningfulSummary)}),s.jsxs("div",{className:"s-work-casefile-meta",children:[s.jsxs("span",{children:["Updated ",Ie(b.updatedAt)]}),s.jsx("span",{children:E}),s.jsx("span",{children:xI(b.state)}),C&&s.jsx("span",{children:C}),b.priority&&s.jsxs("span",{children:["Priority ",b.priority]})]})]}),s.jsxs("aside",{className:`s-work-next-move s-work-next-move-${S.tone}`,children:[s.jsx("div",{className:"s-work-next-move-kicker",children:S.eyebrow}),s.jsx("div",{className:"s-work-next-move-title",children:S.title}),s.jsx("p",{className:"s-work-next-move-copy",children:S.body}),s.jsx("div",{className:"s-work-next-move-actions",children:b.conversationId&&s.jsx(E4,{primary:!0,icon:s.jsx(pg,{"aria-hidden":"true",size:14,strokeWidth:1.8}),onClick:()=>wt(t,{view:"conversation",conversationId:b.conversationId},{returnTo:r}),children:"Open thread"})})]})]}),s.jsxs("div",{className:"s-work-casefile-layout s-work-casefile-layout-main",children:[s.jsx("div",{className:"s-work-casefile-main s-work-casefile-main-materials",children:s.jsx(Qxe,{detail:b,navigate:t})}),s.jsx(lye,{detail:b,navigate:t}),k&&s.jsxs("div",{className:"s-work-casefile-main s-work-casefile-main-lower",children:[b.activeFlights.length>0&&s.jsxs("section",{className:"s-work-casefile-section",children:[s.jsx("div",{className:"s-agent-section-heading",children:s.jsx("h2",{className:"s-agent-section-title",children:"Flights"})}),s.jsx("div",{className:"s-work-flight-list",children:b.activeFlights.map(N=>s.jsxs("button",{type:"button",className:"s-work-flight-card",onClick:N.conversationId?()=>wt(t,{view:"conversation",conversationId:N.conversationId},{returnTo:r}):void 0,disabled:!N.conversationId,children:[s.jsxs("div",{className:"s-work-flight-card-header",children:[s.jsx("span",{className:"s-work-flight-card-title",children:N.agentName??N.agentId}),s.jsx(Wa,{tone:"working",variant:"pill",children:N.state})]}),s.jsxs("div",{className:"s-work-flight-card-meta",children:[s.jsx("span",{children:N.startedAt?`Started ${Ie(N.startedAt)}`:"Start time unavailable"}),N.completedAt&&s.jsxs("span",{children:["Completed ",Ie(N.completedAt)]})]}),N.summary&&s.jsx("div",{className:"s-work-flight-card-copy",children:N.summary})]},N.id))})]}),b.childWork.length>0&&s.jsxs("section",{className:"s-work-casefile-section",children:[s.jsx("div",{className:"s-agent-section-heading",children:s.jsx("h2",{className:"s-agent-section-title",children:"Child work"})}),s.jsx("div",{className:"s-work-related-list",children:b.childWork.map(N=>s.jsxs("button",{type:"button",className:"s-work-related-card",onClick:()=>wt(t,{view:"work",workId:N.id},{returnTo:r}),children:[s.jsxs("div",{className:"s-work-related-card-header",children:[s.jsx("span",{className:"s-work-related-card-title",children:N.title}),s.jsx(Wa,{tone:Ooe(N),variant:"pill",children:N.currentPhase})]}),s.jsxs("div",{className:"s-work-related-card-meta",children:[s.jsx("span",{children:N.ownerName??N.ownerId??"Unassigned"}),s.jsx("span",{children:xI(N.state)}),s.jsx("span",{children:Ie(N.lastMeaningfulAt)})]}),N.lastMeaningfulSummary&&s.jsx("div",{className:"s-work-related-card-copy",children:yr(N.lastMeaningfulSummary)})]},N.id))})]})]})]})]})}function uye(){const{route:e,navigate:t}=qe();return s.jsx(dye,{children:fye(e,t)})}function dye({children:e}){return s.jsx("div",{style:{background:"var(--bg)",color:"var(--ink)",minHeight:"100%",height:"100%",display:"flex",flexDirection:"column"},children:s.jsx("div",{className:"scout-surface-body",children:e})})}function fye(e,t){switch(e.view){case"conversation":return s.jsx(eu,{conversationId:e.conversationId,initialComposeMode:e.composeMode,initialDraft:e.composeDraft,navigate:t});case"agent-info":return s.jsx(Ioe,{conversationId:e.conversationId,navigate:t});case"settings":return s.jsx(Ige,{navigate:t,section:e.section,agentId:e.agentId});case"agents":return s.jsx(Aue,{navigate:t,selectedAgentId:e.agentId,conversationId:e.conversationId,tab:e.tab,activeRoute:e});case"fleet":return s.jsx(SR,{navigate:t});case"conversations":return s.jsx(_de,{navigate:t});case"messages":return s.jsx($me,{conversationId:e.conversationId,navigate:t});case"sessions":return e.sessionId?s.jsx(tge,{sessionRef:e.sessionId,navigate:t}):s.jsx(ege,{navigate:t});case"search":return s.jsx(Khe,{navigate:t,mode:e.mode});case"channels":return s.jsx(Mde,{channelId:e.channelId,navigate:t});case"mesh":return s.jsx(Ome,{navigate:t});case"broker":return s.jsx(ode,{navigate:t});case"repos":return s.jsx(Ope,{navigate:t});case"harnesses":return s.jsx(Qde,{navigate:t});case"repo-diff":return s.jsx($pe,{path:e.path,layers:e.layers,navigate:t});case"briefings":return e.briefingId?s.jsx(Wue,{briefingId:e.briefingId,navigate:t}):s.jsx(tde,{navigate:t});case"activity":return s.jsx(voe,{navigate:t});case"ops":return s.jsx(Rxe,{navigate:t,mode:e.mode,tailQuery:e.tailQuery});case"terminal":return s.jsx(zxe,{agentId:e.agentId,mode:e.mode,navigate:t});case"work":return s.jsx(cye,{workId:e.workId,navigate:t});case"follow":return s.jsx(Dde,{route:e,navigate:t});default:return s.jsx(SR,{navigate:t})}}function Ka(e,t,n={}){n.returnTo&&MD("agents",n.returnTo),e({view:"agents",agentId:t.id,...n.observe?{conversationId:t.conversationId,tab:"observe"}:{}})}const hye=44,mye=132,bI=3500,Rb=7e3;function pye(e,t){return!!(e&&e.available===t.available&&e.sessionId===t.sessionId&&e.body===t.body&&e.lineCount===t.lineCount&&e.columnCount===t.columnCount&&e.truncated===t.truncated&&e.reason===t.reason)}function T4({agentId:e,enabled:t=!0,lines:n=hye,columns:r=mye,className:a}){const[o,c]=m.useState(null),[u,f]=m.useState(!1),[h,p]=m.useState(null);if(m.useEffect(()=>{if(c(null),p(null),!t||!e){f(!1);return}let O=!1,L,I=!0;const z=D=>{window.clearTimeout(L),L=window.setTimeout(()=>{_()},D)},_=async()=>{if(O)return;if(document.visibilityState!=="visible"){z(Rb);return}I&&f(!0);let D=bI;try{const q=new URLSearchParams({lines:String(n),cols:String(r)}),Z=await ue(`/api/agents/${encodeURIComponent(e)}/tmux-peek?${q.toString()}`);if(O)return;p(null),c($=>$&&pye($.payload,Z)?$.steady?$:{...$,steady:!0}:{payload:Z,observedAt:$?.observedAt??Z.capturedAt,changedAt:$?Z.capturedAt:null,steady:!1}),D=Z.available?bI:Rb}catch(q){if(O)return;p(q instanceof Error?q.message:String(q)),D=Rb}finally{O||(I&&f(!1),I=!1,z(D))}},U=()=>{document.visibilityState==="visible"&&(window.clearTimeout(L),_())};return _(),document.addEventListener("visibilitychange",U),()=>{O=!0,window.clearTimeout(L),document.removeEventListener("visibilitychange",U)}},[e,r,t,n]),!t||!e)return null;const x=o?.payload??null,v=x?.body??"",y=x?.lineCount??n,b=x?.columnCount??r,C=6,E=1.32,A={"--tmux-peek-columns":String(b),"--tmux-peek-rows":String(y),"--tmux-peek-font-size":`${C}px`,"--tmux-peek-line-height":String(E),"--tmux-peek-height":`${Math.ceil(y*C*E+18)}px`},S=!!(x?.available&&v),k=h||(u&&!o?"Sampling tmux...":x?.available===!1?x.reason??"No tmux pane is available.":S?null:x?.available?"Pane is empty.":"Sampling tmux..."),N=o?o.changedAt&&!o.steady?"Changed":o.steady?"At rest":"Sampled":null,T=o?.changedAt??o?.observedAt??null,R=o?o.changedAt?o.steady?`No terminal content change since ${Di(o.changedAt)}`:`Terminal content changed ${Di(o.changedAt)}`:`First terminal sample observed ${Di(o.observedAt)}`:void 0;return s.jsxs("div",{className:`ctx-panel-tmux-peek${a?` ${a}`:""}`,style:A,children:[s.jsxs("div",{className:"ctx-panel-tmux-peek-head",children:[s.jsx("span",{children:"Terminal sample"}),s.jsxs("span",{className:"ctx-panel-tmux-peek-grid",children:[b,"x",y]}),x?.sessionId&&s.jsx("span",{className:"ctx-panel-tmux-peek-session",title:x.sessionId,children:x.sessionId.length>12?x.sessionId.slice(0,10):x.sessionId}),N&&T&&s.jsx("time",{className:"ctx-panel-tmux-peek-state",dateTime:new Date(T).toISOString(),title:R,children:N})]}),S?s.jsx("pre",{className:"ctx-panel-tmux-peek-screen",children:v}):s.jsx("div",{className:"ctx-panel-tmux-peek-empty",children:k}),x?.truncated&&v&&s.jsxs("div",{className:"ctx-panel-tmux-peek-foot",children:["Last ",y," rows from tmux pane"]})]})}const gye=new Intl.NumberFormat("en-US"),vye=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1});function To(e){return typeof e!="number"||!Number.isFinite(e)?"-":Math.abs(e)<1e3?gye.format(e):vye.format(e).toLowerCase()}function xye(e){if(!Number.isFinite(e)||e<=0)return"0s";if(e<60)return`${Math.round(e)}s`;const t=Math.round(e),n=Math.floor(t/3600),r=Math.floor(t%3600/60),a=t%60;return n>0?`${n}h ${r}m`:r>=10||a===0?`${r}m`:`${r}m ${a}s`}function yye(e){return e.replace(/\.local$/i,"").replace(/-local-openscout$/i,"")}function lg(e){const n=e.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean);return n[n.length-1]??e}function Ib(e){return e.project?.trim()||(e.projectRoot?lg(e.projectRoot):null)||(e.cwd?lg(e.cwd):null)||"unassigned"}function wI(e){return e.harness?.trim()||e.transport?.trim()||e.agentClass?.trim()||"unknown"}function jI(e,t=4){const n=new Map;for(const r of e){const a=r.trim()||"unknown";n.set(a,(n.get(a)??0)+1)}return[...n.entries()].map(([r,a])=>({label:r,count:a})).sort((r,a)=>a.count-r.count||r.label.localeCompare(a.label)).slice(0,t)}async function bye(e){await ue("/api/local-path/reveal",{method:"POST",body:JSON.stringify({path:e.path,agentId:e.agentId,...e.basePath?{basePath:e.basePath}:{},...e.sessionId?{sessionId:e.sessionId}:{}})})}function M4(e){bye(e).catch(t=>{console.warn("Failed to reveal local path",t)})}function wye(){const{route:e,agents:t,navigate:n}=qe();if(e.view==="agent-info")return s.jsx(kye,{conversationId:e.conversationId,agents:t,navigate:n,route:e});if(e.view!=="agents")return null;const r=e.agentId?t.find(a=>a.id===e.agentId)??null:null;return r?s.jsx(R4,{agent:r,agents:t,navigate:n,route:e,observeMode:e.tab==="observe"}):s.jsx(jye,{agents:t,navigate:n,route:e})}function jye({agents:e,navigate:t,route:n}){const r=m.useMemo(()=>e.filter(v=>Ge(v.state)==="working"),[e]),a=m.useMemo(()=>e.filter(v=>ha(v.state)),[e]),o=Math.max(0,a.length-r.length),c=m.useMemo(()=>jI(e.map(Ib),5),[e]),u=m.useMemo(()=>jI(e.map(wI),5),[e]),f=m.useMemo(()=>e.filter(v=>v.updatedAt).slice().sort((v,y)=>ul(v.updatedAt,y.updatedAt)).slice(0,5),[e]),h=r.slice(0,5),p=new Set(e.map(Ib)).size,x=r.length>0?"Live routing surface":"Quiet routing surface";return s.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[s.jsxs("div",{className:"rounded border border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-hover)] p-2.5",children:[s.jsx("div",{className:"text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:"Directory context"}),s.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-1",children:[s.jsx(_b,{label:"Agents",value:`${e.length}`}),s.jsx(_b,{label:"Projects",value:`${p}`}),s.jsx(_b,{label:"Working",value:`${r.length}`})]}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 border-t border-[var(--scout-chrome-border-soft)] pt-2 font-mono text-[9px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-ghost)]",children:[s.jsx("span",{children:x}),s.jsxs("span",{children:[o," ready"]})]})]}),s.jsx(ks,{label:"Project mix",children:s.jsx(kI,{items:c,empty:"No projects visible"})}),s.jsx(ks,{label:"Harness mix",children:s.jsx(kI,{items:u,empty:"No harnesses visible"})}),s.jsx(ks,{label:"Active now",children:h.length===0?s.jsx("div",{className:"text-[10px] font-mono uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-ghost)]",children:"No agents are currently marked working."}):s.jsx("div",{className:"flex flex-col gap-1.5",children:h.map(v=>s.jsxs("button",{type:"button",className:"rounded border border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-hover)] px-2 py-1.5 text-left transition-colors hover:border-[var(--scout-chrome-border)]",onClick:()=>Ka(t,v,{returnTo:n}),children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:yn(v.state)}}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] text-[var(--scout-chrome-ink)]",children:v.name}),v.updatedAt&&s.jsx("span",{className:"shrink-0 font-mono text-[9px] text-[var(--scout-chrome-ink-faint)]",children:Ie(v.updatedAt)})]}),s.jsxs("div",{className:"mt-0.5 truncate pl-3.5 font-mono text-[9px] text-[var(--scout-chrome-ink-ghost)]",children:[Ib(v)," · ",wI(v)]})]},v.id))})}),s.jsx(ks,{label:"Recent",children:f.length===0?s.jsx("div",{className:"text-[10px] font-mono uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-ghost)]",children:"No recent agent activity in this scope."}):s.jsx("div",{className:"flex flex-col gap-1",children:f.map(v=>s.jsxs("button",{type:"button",className:"flex items-center gap-2 bg-transparent px-0 py-0.5 text-left",onClick:()=>Ka(t,v,{returnTo:n}),children:[s.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:yn(v.state),opacity:ha(v.state)?1:.45}}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] text-[var(--scout-chrome-ink-soft)]",children:v.name}),s.jsx("span",{className:"shrink-0 font-mono text-[9px] text-[var(--scout-chrome-ink-faint)]",children:v.updatedAt?Ie(v.updatedAt):"-"})]},v.id))})})]})}function _b({label:e,value:t}){return s.jsxs("div",{className:"min-w-0 rounded-sm border border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-bg)] px-1.5 py-1",children:[s.jsx("div",{className:"font-mono text-[9px] uppercase tracking-[0.1em] text-[var(--scout-chrome-ink-faint)]",children:e}),s.jsx("div",{className:"mt-0.5 truncate font-mono text-[13px] text-[var(--scout-chrome-ink-strong)]",children:t})]})}function kI({items:e,empty:t}){return e.length===0?s.jsx("div",{className:"text-[10px] font-mono uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-ghost)]",children:t}):s.jsx("div",{className:"flex flex-wrap gap-1",children:e.map(n=>s.jsxs("span",{className:"rounded-sm border border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-hover)] px-1.5 py-0.5 font-mono text-[10px] text-[var(--scout-chrome-ink-soft)]",title:`${n.count} ${n.label}`,children:[n.label," ",n.count]},n.label))})}function kye({conversationId:e,agents:t,navigate:n,route:r}){const a=Bg(e),[o,c]=m.useState(null),[u,f]=m.useState(null),[h,p]=m.useState(!1),x=m.useCallback(async()=>{const b=await ue(`/api/session/${encodeURIComponent(e)}`).catch(()=>null);c(b),p(!0)},[e]);m.useEffect(()=>{p(!1),x()},[x]),Vt(()=>{x()});const v=o?.agentId??a;m.useEffect(()=>{if(!v||t.some(C=>C.id===v)){f(null);return}let b=!1;return ue(`/api/agents/${encodeURIComponent(v)}`).then(C=>{b||f(C)}).catch(()=>{b||f(null)}),()=>{b=!0}},[t,v]);const y=m.useMemo(()=>v?t.find(b=>b.id===v)??(u?.id===v?u:null):null,[u,t,v]);return h?y?s.jsx(R4,{agent:y,agents:t,navigate:n,route:r,observeMode:!1}):s.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[s.jsx(Jr,{label:"Conversation",value:e}),s.jsx("div",{className:"mt-2 text-[10px] font-mono uppercase tracking-[0.15em] leading-relaxed text-[var(--scout-chrome-ink-ghost)]",children:"No live agent registration matches this profile."})]}):s.jsx("div",{className:"flex h-full items-center justify-center p-4 text-center text-[11px] italic text-[var(--scout-chrome-ink-faint)]",children:"Loading agent context..."})}function R4({agent:e,agents:t,navigate:n,route:r,observeMode:a}){const o=ha(e.state),[c,u]=m.useState(null),[f,h]=m.useState(null),p=m.useCallback(async()=>{const[x,v]=await Promise.all([ue("/api/fleet").catch(()=>null),ue(`/api/agents/${encodeURIComponent(e.id)}/session-catalog`).catch(()=>null)]);x&&u(x),h(v)},[e.id]);return m.useEffect(()=>{p()},[p]),m.useEffect(()=>{h(null)},[e.id]),Vt(()=>{p()}),s.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[s.jsxs("div",{className:"flex items-center gap-3 border-b border-[var(--scout-chrome-border-soft)] pb-3",children:[s.jsxs("div",{className:"relative flex h-10 w-10 shrink-0 items-center justify-center rounded-full text-[13px] font-mono text-[var(--scout-chrome-avatar-ink)]",style:{background:Xt(e.name)},children:[e.name[0]?.toUpperCase()??"?",o&&s.jsx("span",{className:"absolute -right-0.5 -bottom-0.5 h-2.5 w-2.5 rounded-full ring-2 ring-[var(--hud-bg)]",style:{background:yn(e.state),opacity:Ge(e.state)==="working"?.85:.6}})]}),s.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[s.jsx("span",{className:"truncate text-[13px] text-[var(--scout-chrome-ink-strong)]",children:e.name}),e.handle&&s.jsxs("span",{className:"text-[10px] font-mono text-cyan-400/70",children:["@",e.handle]})]})]}),s.jsx(Sf,{agent:e,catalog:f,navigate:n,returnTo:r,variant:"compact"}),e.transport==="tmux"&&s.jsx(T4,{agentId:e.id,lines:44,columns:132}),s.jsxs(ks,{label:"State",children:[s.jsxs("div",{className:"flex items-baseline gap-2",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:yn(e.state),opacity:o?1:.4}}),s.jsx("span",{className:"text-[12px] capitalize text-[var(--scout-chrome-ink)]",children:cs(e.state)})]}),e.updatedAt&&s.jsxs("div",{className:"mt-1 text-[10px] font-mono text-[var(--scout-chrome-ink-faint)]",children:["Updated ",Ie(e.updatedAt)]})]}),s.jsx(ks,{label:"Presence",children:s.jsx(Tye,{focusAgent:e,agents:t,onOpenAgent:x=>Ka(n,x,{returnTo:r})})}),a&&s.jsx(Eye,{agentId:e.id}),c&&s.jsx(Mye,{asks:c.activeAsks,agentId:e.id,navigate:n}),s.jsxs(ks,{label:"Identity",children:[s.jsx(Jr,{label:"Class",value:e.agentClass}),e.role&&s.jsx(Jr,{label:"Role",value:e.role}),e.harness&&s.jsx(Jr,{label:"Harness",value:e.harness}),e.transport&&s.jsx(Jr,{label:"Transport",value:e.transport}),(e.homeNodeName||e.homeNodeId)&&s.jsx(Jr,{label:"Host",value:yye(e.homeNodeName??e.homeNodeId??"")})]}),(e.project||e.branch||e.cwd)&&s.jsxs(ks,{label:"Project",children:[e.project&&s.jsx(Jr,{label:"Name",value:e.project}),e.branch&&s.jsx(Jr,{label:"Branch",value:e.branch}),e.cwd&&s.jsx(Jr,{label:"Cwd",value:e.cwd})]}),e.capabilities.length>0&&s.jsx(ks,{label:`Capabilities · ${e.capabilities.length}`,children:s.jsx("div",{className:"flex flex-wrap gap-1",children:e.capabilities.map(x=>s.jsx("span",{className:"rounded-sm bg-[var(--scout-chrome-hover)] px-1.5 py-0.5 text-[10px] font-mono text-[var(--scout-chrome-ink-soft)]",children:x},x))})}),s.jsx(Nye,{agent:e,catalog:f,navigate:n,returnTo:r})]})}function Nye({agent:e,catalog:t,navigate:n,returnTo:r}){const a=Xc(),o=t?.activeSessionId??(e.transport==="tmux"?e.harnessSessionId:null),u=m.useMemo(()=>Sye(e,t,o),[e,t,o]).filter(y=>y.id===o||!y.endedAt),f=u.slice(0,5);if(f.length===0)return null;const h=y=>wt(n,{view:"terminal",agentId:e.id,mode:y},{returnTo:r}),p=()=>{if(e.transport==="tmux"){h("takeover");return}t?.resumeCommand&&Nf({command:t.resumeCommand,cwd:t.resumeCwd,agentId:e.id}).then(()=>h("takeover"))},x=y=>wt(n,{view:"sessions",sessionId:y},{returnTo:r}),v=(y,b,C)=>{const E=[];return b&&E.push({kind:"action",label:"Observe in terminal",onSelect:()=>h("observe")}),C&&E.push({kind:"action",label:"Takeover terminal",onSelect:p}),E.length>0&&E.push({kind:"separator"}),E.push({kind:"action",label:"Open session detail",onSelect:()=>x(y.id)}),E.push({kind:"action",label:"Open agent profile",onSelect:()=>Ka(n,e,{returnTo:r})}),E};return s.jsx(ks,{label:`Running sessions · ${u.length}`,children:s.jsxs("div",{className:"flex flex-col gap-1.5",children:[f.map(y=>{const b=y.id===o,C=b&&e.transport==="tmux",E=b&&(e.transport==="tmux"||!!t?.resumeCommand),A=Ie(y.startedAt)||"recent",S=y.transport??y.harness??e.transport??e.harness??"session",k=b?A:y.endedAt?`${Ie(y.endedAt)||A} ended`:S,N=v(y,C,E);return s.jsxs("div",{onContextMenu:T=>a(T,N),className:`rounded border px-2 py-1.5 transition-colors ${b?"border-cyan-400/40 bg-cyan-400/[0.08]":"border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-hover)]"}`,children:[s.jsxs("button",{type:"button",title:C?`Observe tmux terminal ${y.id}`:`Open session ${y.id}`,onClick:()=>C?h("observe"):x(y.id),className:"flex w-full items-center justify-between gap-2 bg-transparent p-0 text-left",children:[s.jsxs("span",{className:"flex min-w-0 flex-col",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[b&&s.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-cyan-300"}),s.jsx("span",{className:"truncate font-mono text-[10.5px] text-[var(--scout-chrome-ink)]",children:Cye(y.id)}),s.jsx("span",{className:"shrink-0 rounded-sm bg-[var(--scout-chrome-hover)] px-1 py-0.5 font-mono text-[8px] uppercase tracking-[0.08em] text-[var(--scout-chrome-ink-faint)]",children:S})]}),s.jsx("span",{className:"mt-0.5 truncate font-mono text-[9px] text-[var(--scout-chrome-ink-faint)]",children:y.cwd?lg(y.cwd):"workspace"})]}),s.jsxs("span",{className:"flex shrink-0 flex-col items-end",children:[s.jsx("span",{className:"font-mono text-[9px] uppercase tracking-[0.12em] text-cyan-400/70",children:b?"active":"running"}),s.jsx("span",{className:"mt-0.5 max-w-[78px] truncate font-mono text-[9px] text-[var(--scout-chrome-ink-ghost)]",children:k})]})]}),s.jsx("button",{type:"button",title:"Session actions",onClick:T=>a(T,N),className:"mt-1.5 h-5 rounded border border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-hover)] px-1.5 font-mono text-[8.5px] uppercase tracking-[0.08em] text-[var(--scout-chrome-ink-faint)] hover:bg-[var(--scout-chrome-active)] hover:text-[var(--scout-chrome-ink)]",children:"..."})]},y.id)}),u.length>f.length&&s.jsxs("div",{className:"px-1 pt-0.5 font-mono text-[9px] text-[var(--scout-chrome-ink-ghost)]",children:[u.length-f.length," more running"]})]})})}function Sye(e,t,n){const r=[...t?.sessions??[]];return e.transport==="tmux"&&n&&!r.some(a=>a.id===n)&&r.unshift({id:n,startedAt:e.createdAt??e.updatedAt??Date.now(),cwd:e.cwd??e.projectRoot??".",...e.harness?{harness:e.harness}:{},...e.transport?{transport:e.transport}:{},model:e.model}),r.sort((a,o)=>{const c=a.endedAt??a.startedAt,u=o.endedAt??o.startedAt;return ul(c,u)})}function Cye(e){const t=e.replace(/^session[_:-]?/i,"");return t.length>10?t.slice(0,8):t}function Eye({agentId:e}){const[t,n]=m.useState(null),r=m.useCallback(async()=>{const a=await ue(`/api/agents/${encodeURIComponent(e)}/observe`).catch(()=>null);n(a)},[e]);return m.useEffect(()=>{r()},[r]),Vt(()=>{r()}),t?.data?s.jsx(Aye,{agentId:e,data:t.data,sessionId:t.sessionId}):s.jsx(ks,{label:"Trace",children:s.jsx("div",{className:"text-[10px] leading-relaxed text-[var(--scout-chrome-ink-faint)]",children:"Resolving session trace."})})}function Aye({agentId:e,data:t,sessionId:n}){const r=t.metadata?.session,a=t.events,o=t.files,c=a.filter(y=>y.kind==="tool").length,u=a.filter(y=>y.kind==="think").length,f=a.filter(y=>y.kind==="ask").length,h=a.filter(y=>y.kind==="tool"&&y.tool==="read").length,p=a.filter(y=>y.kind==="tool"&&(y.tool==="edit"||y.tool==="write")).length,x=a.length>0?a[a.length-1].t:0,v=r?.threadPath;return s.jsxs(s.Fragment,{children:[s.jsxs(ks,{label:"Session",children:[n&&s.jsx(Jr,{label:"Active",value:n.slice(0,8)}),v&&s.jsx(NI,{label:"Source",path:v,basePath:r?.cwd??null,value:lg(v),agentId:e,sessionId:n}),r?.cwd&&s.jsx(NI,{label:"Workspace",path:r.cwd,value:r.cwd,agentId:e,sessionId:n})]}),s.jsx(ks,{label:"Trace stats",children:s.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[s.jsx(wi,{label:"Turns",value:To(r?.turnCount??0)}),s.jsx(wi,{label:"Tools",value:To(c)}),s.jsx(wi,{label:"Thinks",value:To(u)}),s.jsx(wi,{label:"Asks",value:To(f)}),s.jsx(wi,{label:"Reads",value:To(h)}),s.jsx(wi,{label:"Edits",value:To(p)}),s.jsx(wi,{label:"Files",value:To(o.length)}),s.jsx(wi,{label:"Window",value:xye(x)})]})}),o.length>0&&s.jsx(ks,{label:`Files touched · ${o.length}`,children:s.jsx("div",{className:"flex flex-col gap-1",children:o.slice(0,8).map(y=>s.jsxs("button",{type:"button",title:y.path,onClick:()=>M4({path:y.path,basePath:r?.cwd??null,agentId:e,sessionId:n}),className:"flex items-center justify-between gap-2 rounded border border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-hover)] px-2 py-1 text-left hover:border-[var(--accent)]",children:[s.jsx("span",{className:"min-w-0 truncate font-mono text-[10px] text-[var(--scout-chrome-ink-soft)]",children:y.path}),s.jsxs("span",{className:"shrink-0 font-mono text-[9px] text-[var(--scout-chrome-ink-faint)]",children:["x",y.touches]})]},y.path))})})]})}function NI({label:e,path:t,basePath:n,value:r,agentId:a,sessionId:o}){return s.jsxs("div",{className:"flex items-baseline justify-between py-0.5 gap-2",children:[s.jsx("span",{className:"shrink-0 text-[10px] font-mono uppercase tracking-wider text-[var(--scout-chrome-ink-faint)]",children:e}),s.jsx("button",{type:"button",title:`Reveal ${t}`,onClick:()=>M4({path:t,basePath:n,agentId:a,sessionId:o}),className:"min-w-0 truncate bg-transparent p-0 text-right font-mono text-[11px] text-cyan-400/80 hover:text-[var(--scout-chrome-ink)] hover:underline",children:r})]})}function wi({label:e,value:t}){return s.jsxs("div",{className:"rounded border border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-hover)] px-2 py-1.5",children:[s.jsx("div",{className:"font-mono text-[8.5px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:e}),s.jsx("div",{className:"mt-0.5 font-mono text-[12px] text-[var(--scout-chrome-ink)]",children:t})]})}function Tye({focusAgent:e,agents:t,onOpenAgent:n}){const f=m.useMemo(()=>{const p=t.filter(v=>v.id!==e.id),x=v=>{const y=Ge(v);return y==="working"?0:y==="ready"?1:2};return p.slice().sort((v,y)=>{const b=x(v.state??""),C=x(y.state??"");return b!==C?b-C:ul(v.updatedAt,y.updatedAt)}).slice(0,8)},[t,e.id]),h=m.useMemo(()=>{const p=[{agent:e,x:120,y:90,focused:!0}];return f.forEach((x,v)=>{const y=2*Math.PI*v/Math.max(f.length,1)-Math.PI/2;p.push({agent:x,x:120+68*Math.cos(y),y:90+68*Math.sin(y),focused:!1})}),p},[e,f,120,90,68]);return s.jsxs("div",{className:"@container flex flex-wrap items-start gap-3",children:[s.jsxs("svg",{viewBox:"0 0 240 180",className:"block mx-auto shrink-0 w-full",style:{maxWidth:240},xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("defs",{children:s.jsxs("radialGradient",{id:"inspMeshGlow",cx:"50%",cy:"50%",r:"50%",children:[s.jsx("stop",{offset:"0%",stopColor:"var(--accent)",stopOpacity:"0.06"}),s.jsx("stop",{offset:"100%",stopColor:"var(--accent)",stopOpacity:"0"})]})}),s.jsx("circle",{cx:120,cy:90,r:82,fill:"url(#inspMeshGlow)"}),s.jsx("circle",{cx:120,cy:90,r:68,fill:"none",stroke:"var(--border)",strokeDasharray:"2 4"}),h.slice(1).map((p,x)=>s.jsxs("g",{children:[s.jsx("line",{x1:120,y1:90,x2:p.x,y2:p.y,stroke:"var(--accent)",strokeWidth:1,opacity:.6}),s.jsx("circle",{r:2,fill:"var(--accent)",children:s.jsx("animateMotion",{dur:`${2+x*.3}s`,repeatCount:"indefinite",path:`M 120,90 L ${p.x},${p.y}`})})]},`e-${p.agent.id}`)),h.map(p=>{const x=Ge(p.agent.state),v=x==="working"||x==="ready",y=p.focused?14:9;return s.jsxs("g",{style:{cursor:"pointer"},onClick:()=>n(p.agent),children:[v&&s.jsxs("circle",{cx:p.x,cy:p.y,r:y+5,fill:"none",stroke:Xt(p.agent.name),strokeWidth:.8,opacity:.3,children:[s.jsx("animate",{attributeName:"r",values:`${y};${y+8};${y}`,dur:"2.5s",repeatCount:"indefinite"}),s.jsx("animate",{attributeName:"opacity",values:"0.3;0;0.3",dur:"2.5s",repeatCount:"indefinite"})]}),s.jsx("circle",{cx:p.x,cy:p.y,r:y,fill:Xt(p.agent.name),stroke:p.focused?"var(--accent)":"var(--surface)",strokeWidth:p.focused?1.5:1}),s.jsx("text",{x:p.x,y:p.y,dy:"0.35em",textAnchor:"middle",fontFamily:"var(--font-mono)",fontSize:p.focused?10:8,fontWeight:600,fill:"var(--scout-chrome-avatar-ink)",children:p.agent.name[0].toUpperCase()}),s.jsx("text",{x:p.x,y:p.y+y+10,textAnchor:"middle",fontFamily:"var(--font-mono)",fontSize:8,fill:"var(--dim)",letterSpacing:"0.04em",children:p.agent.name.length>9?p.agent.name.slice(0,8)+"...":p.agent.name})]},p.agent.id)})]}),f.length>0&&s.jsx("ul",{className:"@max-[380px]:hidden flex-1 min-w-[120px] flex flex-col gap-1 m-0 p-0 list-none",children:f.map(p=>{const x=Ge(p.state);return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>n(p),className:"w-full flex items-center gap-2 py-1 px-1.5 rounded hover:bg-[var(--surface-hover)] text-left",children:[s.jsx("span",{"aria-hidden":!0,className:"shrink-0 w-2 h-2 rounded-full",style:{background:Xt(p.name)}}),s.jsx("span",{className:"flex-1 truncate text-[11px] font-mono text-[var(--scout-chrome-ink)]",children:p.name}),s.jsx("span",{"aria-hidden":!0,title:cs(p.state),className:"shrink-0 w-1.5 h-1.5 rounded-full",style:{background:yn(x)}})]})},p.id)})})]})}function Mye({asks:e,agentId:t,navigate:n}){const r=e.filter(a=>a.agentId===t&&(a.status==="needs_attention"||a.status==="queued"));return r.length===0?null:s.jsx(ks,{label:`Incoming asks · ${r.length}`,children:s.jsx("div",{className:"flex flex-col gap-2",children:r.map(a=>s.jsxs("div",{className:"p-2.5 rounded-md border border-amber-500/30 bg-amber-500/[0.04] cursor-pointer hover:bg-amber-500/[0.08] transition-colors",onClick:()=>{a.conversationId&&n({view:"agents",agentId:t,conversationId:a.conversationId})},children:[s.jsx("div",{className:"text-[9px] font-mono uppercase tracking-[0.12em] text-amber-500/80 mb-1",children:"awaiting"}),s.jsx("div",{className:"line-clamp-2 text-[11px] leading-relaxed text-[var(--scout-chrome-ink)]",children:a.summary??a.task}),s.jsxs("div",{className:"mt-1.5 text-[9px] font-mono text-[var(--scout-chrome-ink-ghost)]",children:[a.harness??"operator"," → ",a.agentName??"agent"]})]},a.invocationId))})})}function ks({label:e,children:t}){return s.jsxs("div",{className:"flex flex-col",children:[s.jsx("div",{className:"mb-1.5 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),t]})}function Jr({label:e,value:t}){return s.jsxs("div",{className:"flex items-baseline justify-between py-0.5 gap-2",children:[s.jsx("span",{className:"shrink-0 text-[10px] font-mono uppercase tracking-wider text-[var(--scout-chrome-ink-faint)]",children:e}),s.jsx("span",{className:"truncate text-[11px] font-mono text-[var(--scout-chrome-ink)]",children:t})]})}const Rye=20;function Ob(e){if(!e)return null;const t=e.replace(/[\\/]+$/,"");return t?t.split(/[\\/]/).filter(Boolean).at(-1)??t:null}function $b(e){const t=e?.trim();return t?t.length>18?`${t.slice(0,8)}...${t.slice(-6)}`:t:null}function Fo(e){const t=new Set,n=[];for(const r of e){const a=r?.trim();if(!a)continue;const o=a.toLowerCase();t.has(o)||(t.add(o),n.push(a))}return n}function I4(e,t){const n=e?.trim().replace(/[\\/]+$/,""),r=t.trim().replace(/[\\/]+$/,"");if(!n||!r)return!1;if(n===r)return!0;if(r.startsWith("~/")){const a=r.slice(1);if(n.endsWith(a)||n.includes(`${a}/`))return!0}if(n.startsWith("~/")){const a=n.slice(1);if(r.endsWith(a)||r.includes(`${a}/`))return!0}return n.startsWith(`${r}/`)||r.startsWith(`${n}/`)}function _4(e,t){const n=e?.trim().toLowerCase(),r=t.trim().toLowerCase();return!n||!r?!1:n.includes(r)||r.includes(n)}function O4(e,t){const n=e?.trim().toLowerCase(),r=t.trim().toLowerCase();return!n||!r?!1:n===r}function Iye(e){const{activeSessionId:t,agent:n,sessionMeta:r}=e,a=Fo([t,n?.harnessSessionId]),o=Fo([n?.cwd,n?.projectRoot,r?.workspaceRoot]),c=Fo([n?.project,Ob(n?.cwd),Ob(n?.projectRoot),Ob(r?.workspaceRoot)]).filter(f=>f.length>2),u=Fo([...a.slice(0,2),...c.slice(0,2)]).join("|");return{sessionIds:a,paths:o,projects:c,query:u}}function Rw(e,t){return!!(t.sessionIds.some(n=>_4(e.sessionId,n))||t.paths.some(n=>I4(e.cwd,n))||t.projects.some(n=>O4(e.project,n)))}function _ye(e,t){const n=t.filter(c=>Rw(c,e)),r=Fo(n.filter(c=>e.sessionIds.some(u=>_4(c.sessionId,u))).map(c=>c.sessionId));if(r[0])return r[0];const a=Fo(n.filter(c=>e.paths.some(u=>I4(c.cwd,u))).map(c=>c.sessionId));if(a[0])return a[0];const o=Fo(n.filter(c=>e.projects.some(u=>O4(c.project,u))).map(c=>c.sessionId));return o[0]?o[0]:e.paths[0]?e.paths[0]:e.sessionIds[0]?e.sessionIds[0]:e.projects[0]?e.projects[0]:e.query}function Em(e,t){const n=new Map;for(const r of[...t,...e])n.set(r.id,r);return[...n.values()].sort((r,a)=>ul(r.ts,a.ts)).slice(0,Rye)}function Oye(e){return e==="tool-result"?"tool result":e}function $ye(e){const t=e.replace(/\s+/g," ").trim();return t.length<=180?t:`${t.slice(0,177)}...`}const Lye={direct:"Conversation",channel:"Conversation",group_direct:"Conversation",thread:"Thread"},Pye=1800,Dye=4800,SI=2,zye=120,Bye=650,Uye=1800;function Lb(e,t){try{return JSON.stringify(e)===JSON.stringify(t)?e:t}catch{return t}}function CI(e){if(!e)return null;const t=e.replace(/[\\/]+$/,"");return t?t.split(/[\\/]/).filter(Boolean).at(-1)??t:null}function Fye(e){if(!e)return null;const t=e.replace(/[\\/]+$/,"");return t?t.replace(/^\/Users\/[^/]+(?=\/|$)/,"~"):null}function Pb(e){switch(e){case"queued":return"Queued";case"waking":return"Waking";case"waiting":return"Thinking";case"running":return"Working";default:return e.replace(/_/g," ")}}function Vye(){const{route:e,agents:t,navigate:n}=qe(),r=e.view==="conversation"?e.conversationId:null,[a,o]=m.useState(null),[c,u]=m.useState([]),[f,h]=m.useState(null),[p,x]=m.useState(!1),v=m.useCallback(async()=>{if(!r){o(null),u([]),h(null),x(!0);return}try{const[Oe,He,ot]=await Promise.all([ue(`/api/session/${encodeURIComponent(r)}`).catch(()=>null),ue(`/api/flights?conversationId=${encodeURIComponent(r)}`).catch(()=>[]),ue(`/api/messages?conversationId=${encodeURIComponent(r)}&limit=8`).catch(()=>[])]);o(nt=>Lb(nt,Oe)),u(nt=>Lb(nt,He??[])),h(nt=>Lb(nt,ot?.filter($t=>!aw($t)).sort(($t,Tn)=>dk($t.createdAt,Tn.createdAt)).at(-1)??null)),x(!0)}catch{x(!0)}},[r]);m.useEffect(()=>{x(!1),v()},[v]);const y=a?.agentId??Bg(r??""),b=m.useMemo(()=>y?t.find(Oe=>Oe.id===y)??null:null,[t,y]),[C,E]=m.useState(null),[A,S]=m.useState([]),[k,N]=m.useState([]),T=m.useRef([]),R=m.useRef(null),O=m.useRef(null),L=m.useRef([]),I=m.useRef(null),z=m.useRef(null),_=m.useRef(new Set),U=m.useCallback(()=>{R.current!==null&&(window.clearTimeout(R.current),R.current=null),O.current=null},[]),D=m.useCallback(()=>{if(!r)return;const Oe=Date.now(),He=O.current??Oe;O.current=He;const nt=Oe-He>=Dye?0:Pye;R.current!==null&&window.clearTimeout(R.current),R.current=window.setTimeout(()=>{R.current=null,O.current=null,v()},nt)},[r,v]);m.useEffect(()=>U,[U]),m.useEffect(()=>{if(E(null),!y)return;let Oe=!1;return ue(`/api/agents/${encodeURIComponent(y)}/session-catalog`).then(He=>{Oe||E(He)}).catch(()=>{}),()=>{Oe=!0}},[y]);const q=LD({name:b?.name,agentName:a?.agentName,id:y,title:a?.title}),Z=b?$D(b)??oa(b.id)??b.id:y?oa(y)??y:null,$=m.useMemo(()=>c.filter(Jc).sort((Oe,He)=>(He.startedAt??0)-(Oe.startedAt??0))[0]??null,[c]);m.useEffect(()=>{_.current=new Set(c.map(Oe=>Oe.invocationId))},[c]),m.useEffect(()=>{U(),_.current.clear()},[U,r]),Vt(Oe=>{if(r){if(Oe.kind==="message.posted"){Oe.payload?.message?.conversationId===r&&D();return}if(Oe.kind==="conversation.upserted"){Oe.payload?.conversation?.id===r&&D();return}if(Oe.kind==="invocation.requested"){const He=Oe.payload?.invocation;if(He?.conversationId===r){_.current.add(He.id),D();return}!He?.conversationId&&y&&He?.targetAgentId===y&&(_.current.add(He.id),D());return}if(Oe.kind==="flight.updated"){const He=Oe.payload?.flight;if(!He)return;($?.id===He.id||$?.invocationId===He.invocationId||_.current.has(He.invocationId)||c.some(nt=>nt.id===He.id||nt.invocationId===He.invocationId))&&D()}}});const G=C?.activeSessionId??b?.harnessSessionId??a?.harnessSessionId??null,V=b?.harnessSessionId??a?.harnessSessionId??null,Y=b?.harnessLogPath??null,K=m.useMemo(()=>Iye({activeSessionId:G,agent:b,sessionMeta:a}),[G,b,a]),P=JSON.stringify({sessionIds:K.sessionIds,paths:K.paths,projects:K.projects}),H=K.sessionIds.length>0||K.paths.length>0||K.projects.length>0,B=m.useCallback(()=>{I.current!==null&&(window.clearTimeout(I.current),I.current=null),z.current!==null&&(window.clearInterval(z.current),z.current=null),L.current=[]},[]),Q=m.useCallback(()=>{B()},[B]),oe=m.useCallback(()=>{if(z.current!==null||(I.current!==null&&(window.clearTimeout(I.current),I.current=null),L.current.length===0))return;const He=()=>{const ot=L.current.slice(0,SI);L.current=L.current.slice(SI),ot.length>0&&N(nt=>Em(nt,ot)),!(L.current.length>0)&&z.current!==null&&(window.clearInterval(z.current),z.current=null)};He(),L.current.length>0&&(z.current=window.setInterval(He,zye))},[]),ne=m.useCallback(Oe=>{z.current===null&&I.current===null&&(I.current=window.setTimeout(()=>{I.current=null,oe()},Oe))},[oe]);if(m.useEffect(()=>{T.current=k},[k]),m.useEffect(()=>B,[B]),m.useEffect(()=>{Q(),S([]),N([])},[Q,P]),m.useEffect(()=>{if(!H)return;let Oe=!1;const He=new URLSearchParams({limit:"180",transcripts:"true"});return ue(`/api/tail/recent?${He.toString()}`).then(ot=>{if(Oe)return;const nt=(ot.events??[]).filter($t=>Rw($t,K));S(Em([],nt))}).catch(()=>{}),()=>{Oe=!0}},[H,P]),tu(m.useCallback(Oe=>{H&&Rw(Oe,K)&&S(He=>Em(He,[Oe]))},[H,P])),m.useEffect(()=>{if(A.length===0){Q(),N([]);return}const Oe=T.current,He=new Set([...Oe.map(nt=>nt.id),...L.current.map(nt=>nt.id)]),ot=A.filter(nt=>!He.has(nt.id));ot.length!==0&&(L.current=Em(L.current,ot),L.current.length>0&&ne(Oe.length===0?Bye:Uye))},[ne,Q,A]),!r)return null;if(!p)return s.jsx("div",{className:"ctx-panel ctx-panel--conversation",children:s.jsx("div",{className:"ctx-panel-empty-state",children:s.jsx("div",{className:"ctx-panel-empty-hint",children:"Loading conversation…"})})});const X=a?.kind?Lye[a.kind]??a.kind:"Conversation",ae=a?.workspaceRoot??null,be=CI(ae),_e=Fye(ae),xe=a?.currentBranch??null,pe=b?.harness??a?.harness??null,te=a?.lastMessageAt??f?.createdAt??null,ve=a?.messageCount??null,he=a?a.participantIds.filter(Oe=>Oe!=="operator").length+1:null,ke=b?.state??null,Ne=Ge(ke),Fe=f?.body?.trim()||a?.preview?.trim()||null,Ee=f?.actorName??null,Le=$b(G),Te=G??V,Pe=$b(Te),De=$b(V),ze=!!(V&&V!==Te),$e=[pe,b?.transport].filter(Boolean).join(" · "),st=!!(G||V||Y),rt=!!(b&&b.transport==="tmux"),Xe=!!($||Ne==="working"),dt=Xe?$?Pb($.state):"In motion":"At rest",jt=$?.summary?.trim()??(te?`Last update ${Ie(te)??"recently"}`:"No recent activity recorded"),At=[xe?`branch ${xe}`:null,pe,b?.transport].filter(Boolean),mt=!!(be||_e||At.length>0),Ht=Xe?"Live activity":rt?"Terminal":"Activity",ie=$?.summary?.trim()??(G&&!rt?"Terminal session is live.":k.length>0&&!rt?"Streaming matching Tail events.":null),ce=_ye(K,A),Ae=!!(b&&($||G||A.length>0||rt)),Be=!rt,tt=()=>{y&&wt(n,{view:"agent-info",conversationId:r},{returnTo:e})},at=()=>{wt(n,{view:"ops",mode:"tail",...ce?{tailQuery:ce}:{}},{returnTo:e})};return s.jsxs("div",{className:"ctx-panel ctx-panel--conversation",children:[s.jsxs("section",{className:"ctx-panel-section ctx-panel-conversation-summary",children:[s.jsx("div",{className:"ctx-panel-section-label",children:X}),s.jsxs("div",{className:"ctx-panel-conversation-card",children:[s.jsx("div",{className:"ctx-panel-conversation-title",children:q}),Z&&s.jsxs("div",{className:"ctx-panel-conversation-handle",children:["@",Z]}),s.jsxs("div",{className:"ctx-panel-conversation-state",children:[s.jsx("span",{className:"ctx-panel-conversation-state-dot",style:{background:yn(ke)}}),s.jsx("span",{children:cs(ke)})]})]})]}),$&&s.jsxs("section",{className:"ctx-panel-section",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Now"}),s.jsxs("div",{className:"ctx-panel-conversation-flight",children:[s.jsxs("div",{className:"ctx-panel-conversation-flight-row",children:[s.jsx("span",{className:"ctx-panel-conversation-flight-label",children:Pb($.state)}),$.startedAt&&s.jsx("span",{className:"ctx-panel-conversation-flight-time",children:Ie($.startedAt)})]}),$.summary&&s.jsx("div",{className:"ctx-panel-conversation-flight-summary",children:$.summary})]})]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Workspace"}),mt?s.jsxs("div",{className:"ctx-panel-workspace-card",children:[s.jsxs("div",{className:"ctx-panel-workspace-head",children:[s.jsx("div",{className:"ctx-panel-workspace-kicker",children:"Project"}),s.jsx("div",{className:"ctx-panel-workspace-title",title:ae??be??void 0,children:be??"Unscoped workspace"})]}),_e&&s.jsx("div",{className:"ctx-panel-workspace-path",title:ae??_e,children:_e}),At.length>0&&s.jsx("div",{className:"ctx-panel-workspace-strip",children:At.map(Oe=>s.jsx("span",{className:"ctx-panel-workspace-chip",children:Oe},Oe))})]}):s.jsx("div",{className:"ctx-panel-empty",children:"No workspace metadata yet"})]}),st&&s.jsxs("section",{className:"ctx-panel-section",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Session"}),s.jsxs("div",{className:"ctx-panel-session-card",children:[s.jsxs("div",{className:"ctx-panel-session-head",children:[s.jsxs("div",{className:"ctx-panel-session-primary",children:[$e&&s.jsx("div",{className:"ctx-panel-session-kind",children:$e}),Te&&s.jsx("div",{className:"ctx-panel-session-id",title:Te,children:Pe??Te})]}),y&&Te&&s.jsx(Hg,{agentId:y,className:"ctx-panel-vantage-button",statusClassName:"ctx-panel-vantage-status",label:"Open",openingLabel:"Opening..."})]}),(ze||Y)&&s.jsxs("div",{className:"ctx-panel-session-meta",children:[ze&&V&&s.jsxs("div",{className:"ctx-panel-session-meta-item",children:[s.jsx("span",{children:"Harness session"}),s.jsx("strong",{title:V,children:De??V})]}),Y&&s.jsxs("div",{className:"ctx-panel-session-meta-item",children:[s.jsx("span",{children:"Harness log"}),s.jsx("strong",{title:Y,children:CI(Y)??Y})]})]})]})]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Activity"}),s.jsxs("div",{className:`ctx-panel-activity-card${Xe?" ctx-panel-activity-card--active":""}`,children:[s.jsxs("div",{className:"ctx-panel-activity-head",children:[s.jsx("span",{className:"ctx-panel-activity-dot",style:{background:Xe?"var(--green)":yn(ke)}}),s.jsxs("div",{className:"ctx-panel-activity-main",children:[s.jsx("div",{className:"ctx-panel-activity-title",children:dt}),s.jsx("div",{className:"ctx-panel-activity-sub",title:te?Di(te):void 0,children:jt})]})]}),$&&s.jsxs("div",{className:"ctx-panel-activity-ledger",children:[s.jsx("span",{className:"ctx-panel-activity-ledger-label",children:Pb($.state)}),$.startedAt&&s.jsx("span",{className:"ctx-panel-activity-ledger-time",title:Di($.startedAt),children:Ie($.startedAt)})]}),s.jsxs("div",{className:"ctx-panel-activity-facts",children:[typeof ve=="number"&&s.jsx(Db,{label:"Messages",value:`${ve}`}),typeof he=="number"&&s.jsx(Db,{label:"People",value:`${he}`}),Ne&&s.jsx(Db,{label:"Agent",value:cs(ke)})]})]})]}),Fe&&s.jsxs("section",{className:"ctx-panel-section ctx-panel-conversation-preview",children:[s.jsx("div",{className:"ctx-panel-section-label",children:Ee?`Latest · ${Ee}`:"Latest"}),s.jsx("div",{className:"ctx-panel-conversation-preview-body",children:Fe})]}),Ae&&b&&s.jsxs("section",{className:"ctx-panel-section ctx-panel-conversation-live-section",children:[s.jsxs("div",{className:"ctx-panel-section-label",children:[s.jsx("span",{children:Ht}),Le&&s.jsx("span",{className:"ctx-panel-live-session",title:G??void 0,children:Le})]}),s.jsxs("div",{className:`ctx-panel-live-card${Xe?" ctx-panel-live-card--active":""}`,children:[s.jsx(Sf,{agent:b,catalog:C,navigate:n,returnTo:e,variant:"compact",className:"ctx-panel-live-actions"}),ie&&s.jsx("div",{className:"ctx-panel-live-summary",children:ie}),rt&&s.jsx(T4,{agentId:b.id,lines:44,columns:132}),Be&&s.jsx("div",{className:"ctx-panel-live-stream","aria-live":"polite",children:k.length>0?s.jsx("ol",{className:"ctx-panel-live-events",children:k.map(Oe=>s.jsxs("li",{className:"ctx-panel-live-event",children:[s.jsx("span",{className:"ctx-panel-live-event-kind",children:Oye(Oe.kind)}),s.jsx("span",{className:"ctx-panel-live-event-summary",children:$ye(Oe.summary)}),s.jsx("span",{className:"ctx-panel-live-event-time",title:Di(Oe.ts),children:Ie(Oe.ts)})]},Oe.id))}):s.jsx("div",{className:"ctx-panel-live-stream-empty",children:"Waiting for matching Tail events"})}),H&&s.jsxs("button",{type:"button",className:"ctx-panel-live-tail-button",onClick:at,title:ce?`Tail filter: ${ce}`:"Open Tail",children:[s.jsx(A2,{size:13,strokeWidth:1.9,"aria-hidden":"true"}),s.jsx("span",{children:"Tail"})]})]})]}),y&&s.jsx("section",{className:"ctx-panel-section ctx-panel-conversation-profile-section",children:s.jsxs("button",{type:"button",className:"ctx-panel-roster-button ctx-panel-conversation-profile-button",onClick:tt,children:[s.jsx("span",{className:"ctx-panel-roster-label",children:"Open agent profile"}),s.jsx("span",{className:"ctx-panel-roster-count",children:s.jsx("span",{children:"→"})})]})})]})}function Db({label:e,value:t}){return s.jsxs("div",{className:"ctx-panel-fact",children:[s.jsx("span",{className:"ctx-panel-fact-value",children:t}),s.jsx("span",{className:"ctx-panel-fact-label",children:e})]})}function Hye(){const{agents:e,navigate:t,route:n}=qe(),r=c=>Ka(t,c,{returnTo:n});if(e.length===0)return s.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center font-mono text-[11px] leading-relaxed text-[var(--scout-chrome-ink-faint)]",children:[s.jsx("div",{className:"mb-1 uppercase tracking-[0.15em]",children:"No agents"}),s.jsx("div",{children:"Connect an agent to see your roster here."})]});const a=e.filter(c=>ha(c.state)),o=e.filter(c=>!ha(c.state));return s.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[a.length>0&&s.jsx(EI,{label:"Ready",count:a.length,children:a.map(c=>s.jsx(AI,{agent:c,onOpen:r},c.id))}),o.length>0&&s.jsx(EI,{label:"Not ready",count:o.length,children:o.map(c=>s.jsx(AI,{agent:c,onOpen:r,dim:!0},c.id))})]})}function EI({label:e,count:t,children:n}){return s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("div",{className:"flex items-baseline justify-between mb-1.5",children:[s.jsx("span",{className:"text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),s.jsx("span",{className:"text-[9px] font-mono tabular-nums text-[var(--scout-chrome-ink-ghost)]",children:t})]}),s.jsx("div",{className:"flex flex-col gap-0.5",children:n})]})}function AI({agent:e,onOpen:t,dim:n}){const r=ha(e.state);return s.jsxs("button",{onClick:()=>t(e),className:`group flex items-center gap-2.5 px-2 py-1.5 rounded-sm text-left transition-colors ${n?"opacity-60 hover:opacity-100 hover:bg-[var(--scout-chrome-hover)]":"hover:bg-[var(--scout-chrome-hover)]"}`,children:[s.jsxs("div",{className:"relative h-6 w-6 shrink-0 rounded-full text-[10px] font-mono flex items-center justify-center text-[var(--scout-chrome-avatar-ink)]",style:{background:Xt(e.name)},children:[e.name[0]?.toUpperCase()??"?",r&&s.jsx("span",{className:"absolute -right-0.5 -bottom-0.5 h-2 w-2 rounded-full bg-emerald-400 ring-2 ring-[var(--hud-bg)]"})]}),s.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[s.jsx("span",{className:"truncate text-[12px] text-[var(--scout-chrome-ink)] transition-colors group-hover:text-[var(--scout-chrome-ink-strong)]",children:e.name}),s.jsx("span",{className:"truncate text-[10px] font-mono text-[var(--scout-chrome-ink-faint)]",children:cs(e.state)})]}),e.updatedAt&&s.jsx("span",{className:"shrink-0 text-[9px] font-mono tabular-nums text-[var(--scout-chrome-ink-ghost)]",children:Ie(e.updatedAt)})]})}function Yg(e){const n=e.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean);return n[n.length-1]??e}function TI(e){const t=e?.trim();if(!t)return null;const n=Yg(t);return n.endsWith(".jsonl")?n.slice(0,-6):n}function Wye(e){return e.workspaceRoot?Yg(e.workspaceRoot):e.agentName??"unassigned"}function qye(e){return e.harness?.trim()||e.kind?.trim()||"scout"}function MI(e){return e.project?.trim()||(e.cwd?Yg(e.cwd):null)||"unknown"}function RI(e,t=4){const n=new Map;for(const r of e){const a=r.trim()||"unknown";n.set(a,(n.get(a)??0)+1)}return[...n.entries()].map(([r,a])=>({label:r,count:a})).sort((r,a)=>a.count-r.count||r.label.localeCompare(a.label)).slice(0,t)}function Kye(){const{route:e,navigate:t}=qe(),[n,r]=m.useState([]),[a,o]=m.useState(null),c=m.useCallback(async()=>{const[f,h]=await Promise.allSettled([ue("/api/sessions"),ue("/api/tail/discover")]);f.status==="fulfilled"&&r(f.value),h.status==="fulfilled"&&o(h.value)},[]);if(m.useEffect(()=>{c()},[c]),Vt(()=>{c()}),e.view!=="sessions")return null;const u=e.sessionId?n.find(f=>f.id===e.sessionId)??null:null;return u?s.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[s.jsxs("div",{className:"border-b border-[var(--scout-chrome-border-soft)] pb-3",children:[s.jsx("div",{className:"text-[13px] leading-snug text-[var(--scout-chrome-ink-strong)]",children:u.title}),s.jsx("div",{className:"text-[10px] font-mono uppercase tracking-wider text-cyan-400/70 mt-1",children:u.kind})]}),u.agentName&&s.jsxs(Ii,{label:"Agent",children:[s.jsx(Mo,{label:"Name",value:u.agentName}),u.harness&&s.jsx(Mo,{label:"Harness",value:u.harness})]}),(u.currentBranch||u.workspaceRoot)&&s.jsxs(Ii,{label:"Workspace",children:[u.currentBranch&&s.jsx(Mo,{label:"Branch",value:u.currentBranch}),u.workspaceRoot&&s.jsx(Mo,{label:"Root",value:u.workspaceRoot})]}),s.jsxs(Ii,{label:"Activity",children:[s.jsx(Mo,{label:"Messages",value:`${u.messageCount}`}),u.lastMessageAt&&s.jsx(Mo,{label:"Last",value:Ie(u.lastMessageAt)}),u.participantIds.length>0&&s.jsx(Mo,{label:"Participants",value:`${u.participantIds.length}`})]}),u.preview&&s.jsx(Ii,{label:"Preview",children:s.jsxs("div",{className:"text-[11px] italic leading-relaxed text-[var(--scout-chrome-ink-soft)]",children:['"',u.preview,'"']})})]}):s.jsx(Gye,{sessions:n,discovery:a,navigate:t,route:e})}function Gye({sessions:e,discovery:t,navigate:n,route:r}){const a=t?.transcripts??[],o=m.useMemo(()=>RI([...e.map(qye),...a.map(v=>v.source||"unknown")],5),[e,a]),c=m.useMemo(()=>RI([...e.map(Wye),...a.map(MI)],5),[e,a]),u=m.useMemo(()=>a.slice().sort((v,y)=>y.mtimeMs-v.mtimeMs).slice(0,5),[a]),f=m.useMemo(()=>e.filter(v=>v.lastMessageAt).slice().sort((v,y)=>(y.lastMessageAt??0)-(v.lastMessageAt??0)).slice(0,5),[e]),h=t?.processes?.length??0,p=t?.totals.transcripts??a.length,x=h>0?"Live harness activity":"Quiet session surface";return s.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[s.jsxs("div",{className:"rounded border border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-hover)] p-2.5",children:[s.jsx("div",{className:"text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:"Sessions context"}),s.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-1",children:[s.jsx(zb,{label:"Scout",value:`${e.length}`}),s.jsx(zb,{label:"Raw",value:`${p}`}),s.jsx(zb,{label:"Live",value:`${h}`})]}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 border-t border-[var(--scout-chrome-border-soft)] pt-2 font-mono text-[9px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-ghost)]",children:[s.jsx("span",{children:x}),s.jsxs("span",{children:[o.length," sources"]})]})]}),s.jsx(Ii,{label:"Sources",children:s.jsx(II,{items:o,empty:"No sources visible"})}),s.jsx(Ii,{label:"Project mix",children:s.jsx(II,{items:c,empty:"No projects visible"})}),s.jsx(Ii,{label:"Recent raw",children:u.length===0?s.jsx(Iw,{children:"No raw transcripts discovered."}):s.jsx("div",{className:"flex flex-col gap-1.5",children:u.map(v=>{const y=TI(v.sessionId)??TI(v.transcriptPath);return s.jsxs("button",{type:"button",className:"rounded border border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-hover)] px-2 py-1.5 text-left transition-colors hover:border-[var(--scout-chrome-border)]",onClick:()=>{y&&wt(n,{view:"sessions",sessionId:y},{returnTo:r})},disabled:!y,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"shrink-0 rounded-sm bg-[var(--scout-chrome-bg)] px-1 py-0.5 font-mono text-[8px] uppercase tracking-[0.08em] text-[var(--scout-chrome-ink-faint)]",children:v.source||"raw"}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] text-[var(--scout-chrome-ink)]",children:MI(v)}),s.jsx("span",{className:"shrink-0 font-mono text-[9px] text-[var(--scout-chrome-ink-faint)]",children:Ie(v.mtimeMs)})]}),s.jsx("div",{className:"mt-0.5 truncate font-mono text-[9px] text-[var(--scout-chrome-ink-ghost)]",children:y??Yg(v.transcriptPath)})]},`${v.source}:${v.transcriptPath}`)})})}),s.jsx(Ii,{label:"Recent Scout sessions",children:f.length===0?s.jsx(Iw,{children:"No recent Scout session messages."}):s.jsx("div",{className:"flex flex-col gap-1",children:f.map(v=>s.jsxs("button",{type:"button",className:"flex items-center gap-2 bg-transparent px-0 py-0.5 text-left",onClick:()=>wt(n,{view:"sessions",sessionId:v.id},{returnTo:r}),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] text-[var(--scout-chrome-ink-soft)]",children:v.title}),s.jsx("span",{className:"shrink-0 font-mono text-[9px] text-[var(--scout-chrome-ink-faint)]",children:v.lastMessageAt?Ie(v.lastMessageAt):"-"})]},v.id))})})]})}function zb({label:e,value:t}){return s.jsxs("div",{className:"min-w-0 rounded-sm border border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-bg)] px-1.5 py-1",children:[s.jsx("div",{className:"font-mono text-[9px] uppercase tracking-[0.1em] text-[var(--scout-chrome-ink-faint)]",children:e}),s.jsx("div",{className:"mt-0.5 truncate font-mono text-[13px] text-[var(--scout-chrome-ink-strong)]",children:t})]})}function II({items:e,empty:t}){return e.length===0?s.jsx(Iw,{children:t}):s.jsx("div",{className:"flex flex-wrap gap-1",children:e.map(n=>s.jsxs("span",{className:"rounded-sm border border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-hover)] px-1.5 py-0.5 font-mono text-[10px] text-[var(--scout-chrome-ink-soft)]",title:`${n.count} ${n.label}`,children:[n.label," ",n.count]},n.label))})}function Iw({children:e}){return s.jsx("div",{className:"text-[10px] font-mono uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-ghost)]",children:e})}function Ii({label:e,children:t}){return s.jsxs("div",{className:"flex flex-col",children:[s.jsx("div",{className:"mb-1.5 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),t]})}function Mo({label:e,value:t}){return s.jsxs("div",{className:"flex items-baseline justify-between py-0.5 gap-2",children:[s.jsx("span",{className:"shrink-0 text-[10px] font-mono uppercase tracking-wider text-[var(--scout-chrome-ink-faint)]",children:e}),s.jsx("span",{className:"truncate text-[11px] font-mono text-[var(--scout-chrome-ink)]",children:t})]})}function Zye(){const{route:e,agents:t,navigate:n}=qe();if(e.view!=="terminal")return null;const r=e.agentId?t.find(c=>c.id===e.agentId)??null:null,a=e.mode??"takeover";if(!r)return s.jsx("div",{className:"flex h-full flex-col overflow-y-auto p-4 text-[11px]",children:s.jsxs(Tm,{label:"Terminal",children:[s.jsx(ys,{label:"Mode",value:OI(a)}),e.agentId&&s.jsx(ys,{label:"Agent",value:e.agentId})]})});const o=r.transport==="tmux"?r.harnessSessionId:null;return s.jsxs("div",{className:"flex h-full flex-col gap-4 overflow-y-auto p-4 text-[11px] frame-scrollbar",children:[s.jsx(Yye,{agent:r}),s.jsxs(Tm,{label:"Terminal",children:[s.jsx(ys,{label:"Mode",value:OI(a)}),s.jsx(ys,{label:"Backend",value:o?"tmux":"pty"}),o&&s.jsx(ys,{label:"Session",value:o}),s.jsx(ys,{label:"State",value:cs(r.state)})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[o&&s.jsx(Am,{active:a==="observe",label:"Observe",onClick:()=>n(_I(r.id,"observe"))}),s.jsx(Am,{active:a==="takeover",label:"Takeover",onClick:()=>n(_I(r.id,"takeover"))}),s.jsx(Am,{label:"Profile",onClick:()=>n({view:"agents",agentId:r.id,tab:"profile"})}),s.jsx(Am,{label:"Trace",onClick:()=>n({view:"agents",agentId:r.id,tab:"observe"})})]}),s.jsxs(Tm,{label:"Agent",children:[s.jsx(ys,{label:"Harness",value:r.harness??"-"}),s.jsx(ys,{label:"Transport",value:r.transport??"-"}),r.role&&s.jsx(ys,{label:"Role",value:r.role}),r.handle&&s.jsx(ys,{label:"Handle",value:`@${r.handle}`}),r.updatedAt&&s.jsx(ys,{label:"Updated",value:Ie(r.updatedAt)})]}),(r.project||r.branch||r.cwd||r.projectRoot)&&s.jsxs(Tm,{label:"Workspace",children:[r.project&&s.jsx(ys,{label:"Name",value:r.project}),r.branch&&s.jsx(ys,{label:"Branch",value:r.branch}),r.cwd&&s.jsx(ys,{label:"Cwd",value:r.cwd}),!r.cwd&&r.projectRoot&&s.jsx(ys,{label:"Root",value:r.projectRoot})]})]})}function _I(e,t){return{view:"terminal",agentId:e,mode:t}}function OI(e){return e==="observe"?"Read-only observe":"Interactive takeover"}function Yye({agent:e}){return s.jsx("div",{className:"border-b border-[var(--scout-chrome-border-soft)] pb-3",children:s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full font-mono text-[12px] text-[var(--scout-chrome-avatar-ink)]",style:{background:Xt(e.name)},children:e.name[0]?.toUpperCase()??"?"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-[13px] leading-snug text-[var(--scout-chrome-ink-strong)]",children:e.name}),e.handle&&s.jsxs("div",{className:"truncate font-mono text-[10px] text-cyan-400/70",children:["@",e.handle]})]})]})})}function Am({active:e,label:t,onClick:n}){return s.jsx("button",{type:"button",onClick:n,className:`h-7 rounded border px-2 font-mono text-[9px] uppercase tracking-[0.1em] transition-colors ${e?"border-cyan-400/35 bg-cyan-400/[0.12] text-cyan-200":"border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-hover)] text-[var(--scout-chrome-ink-soft)] hover:bg-[var(--scout-chrome-active)] hover:text-[var(--scout-chrome-ink)]"}`,children:t})}function Tm({label:e,children:t}){return s.jsxs("div",{className:"flex flex-col",children:[s.jsx("div",{className:"mb-1.5 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),t]})}function ys({label:e,value:t}){return s.jsxs("div",{className:"flex items-baseline justify-between gap-2 py-0.5",children:[s.jsx("span",{className:"shrink-0 text-[10px] font-mono uppercase tracking-wider text-[var(--scout-chrome-ink-faint)]",children:e}),s.jsx("span",{className:"truncate text-right text-[11px] font-mono text-[var(--scout-chrome-ink)]",children:t})]})}const Xye=5;function Qye(){const{route:e,navigate:t}=qe(),n=e.view==="work"?e.workId:null,[r,a]=m.useState(null),o=m.useCallback(async()=>{if(!n){a(null);return}try{a(await ue(`/api/work/${encodeURIComponent(n)}`))}catch{a(null)}},[n]);if(m.useEffect(()=>{o()},[o]),Vt(()=>{n&&o()}),e.view!=="work")return null;if(!r)return s.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-[11px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-ghost)]",children:"Loading work item…"});const c=tbe(r.state),u=ebe(r.attention),f=r.ownerName??r.ownerId??"Unassigned",h=r.nextMoveOwnerName??r.nextMoveOwnerId??null,p=h!==null&&(r.ownerId??null)!==(r.nextMoveOwnerId??null)&&h!==f,x=1+(p?1:0)+(r.priority?1:0)+2+(r.parentId?1:0)+(r.conversationId?1:0);return s.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar text-[11px]",children:[s.jsx("div",{className:"sticky top-0 z-10 border-b border-[var(--scout-chrome-border-soft)] bg-black/55 px-4 py-2 backdrop-blur",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${c.dot}`}),s.jsx("span",{className:`font-mono text-[10px] uppercase tracking-[0.15em] ${c.text}`,children:Jye(r.state)}),s.jsxs("span",{className:"min-w-0 flex-1 truncate text-[10px] text-[var(--scout-chrome-ink-faint)]",children:[s.jsx("span",{className:"text-[var(--scout-chrome-ink)]",children:f}),p&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"px-1 text-[var(--scout-chrome-ink-ghost)]",children:"→"}),s.jsx("span",{className:"text-[var(--scout-chrome-ink)]",children:h})]})]}),u&&s.jsx("span",{className:"shrink-0 rounded border border-amber-400/30 bg-amber-400/10 px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-[0.12em] text-amber-300/90",children:u})]})}),s.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[s.jsxs(od,{label:"Case facts",children:[s.jsx(Ys,{label:"Phase",value:r.currentPhase}),s.jsx(Ys,{label:"Acceptance",value:r.acceptanceState.replace(/_/g," ")}),r.priority&&s.jsx(Ys,{label:"Priority",value:r.priority})]}),s.jsx(od,{label:"Timeline",children:r.timeline.length===0?s.jsx("div",{className:"text-[10px] text-[var(--scout-chrome-ink-faint)]",children:"No activity yet."}):s.jsx("div",{className:"flex flex-col gap-1.5",children:r.timeline.slice(0,Xye).map(v=>s.jsx(nbe,{item:v,onOpen:v.conversationId?()=>wt(t,{view:"conversation",conversationId:v.conversationId},{returnTo:e}):void 0},v.id))})}),s.jsxs(od,{label:"Routing",collapsible:!0,defaultOpen:!1,count:x,children:[s.jsx(Ys,{label:"Owner",value:f}),p&&h&&s.jsx(Ys,{label:"Next move",value:h}),r.priority&&s.jsx(Ys,{label:"Priority",value:r.priority}),s.jsx(Ys,{label:"Children",value:`${r.activeChildWorkCount}`}),s.jsx(Ys,{label:"Flights",value:`${r.activeFlightCount}`}),r.lastMeaningfulAt&&s.jsx(Ys,{label:"Last update",value:Ie(r.lastMeaningfulAt)}),(r.conversationId||r.parentId)&&s.jsxs("div",{className:"mt-2 flex flex-col gap-1.5",children:[r.conversationId&&s.jsx($I,{label:"Open thread",onClick:()=>wt(t,{view:"conversation",conversationId:r.conversationId},{returnTo:e})}),r.parentId&&r.parentTitle&&s.jsx($I,{label:r.parentTitle,eyebrow:"Parent",onClick:()=>wt(t,{view:"work",workId:r.parentId},{returnTo:e})})]})]}),s.jsxs(od,{label:"Record",collapsible:!0,defaultOpen:!1,children:[s.jsx(Ys,{label:"Case ID",value:r.id}),s.jsx(Ys,{label:"Created",value:kr(r.createdAt)}),s.jsx(Ys,{label:"Updated",value:kr(r.updatedAt)}),s.jsx(Ys,{label:"Last activity",value:kr(r.lastMeaningfulAt)})]}),r.lastMeaningfulSummary&&s.jsxs(od,{label:"Hudson context",collapsible:!0,defaultOpen:!1,children:[s.jsx("div",{className:"text-[11px] italic leading-relaxed text-[var(--scout-chrome-ink-soft)]",children:r.lastMeaningfulSummary}),s.jsxs("div",{className:"mt-2 flex gap-1.5",children:[s.jsx("span",{className:"rounded border border-[var(--scout-chrome-border-soft)] px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:"Plan"}),s.jsx("span",{className:"rounded border border-[var(--scout-chrome-border-soft)] px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:"Docs"}),s.jsx("span",{className:"rounded border border-[var(--scout-chrome-border-soft)] px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:"Code"})]})]})]})]})}function Jye(e){switch(e){case"review":return"In review";case"waiting":return"Waiting";case"working":return"Working";case"done":return"Done";default:return e.replace(/_/g," ")}}function ebe(e){switch(e){case"badge":return"Noteworthy";case"interrupt":return"Blocked";default:return null}}function tbe(e){return/complete|done|finished/i.test(e)?{dot:"bg-emerald-400",text:"text-emerald-300/90"}:/fail|error/i.test(e)?{dot:"bg-red-400",text:"text-red-300/90"}:/block|wait|pause/i.test(e)?{dot:"bg-amber-400",text:"text-amber-300/90"}:/active|working|in[_-]?progress/i.test(e)?{dot:"bg-cyan-400",text:"text-cyan-300/90"}:{dot:"bg-[var(--scout-chrome-ink-faint)]",text:"text-[var(--scout-chrome-ink)]"}}function od({label:e,children:t,collapsible:n=!1,defaultOpen:r=!0,count:a}){const[o,c]=m.useState(r);return n?s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("button",{type:"button",onClick:()=>c(u=>!u),className:"flex items-center gap-1.5 text-left text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)] hover:text-[var(--scout-chrome-ink)]",children:[o?s.jsx(Xo,{"aria-hidden":"true",size:10,strokeWidth:2}):s.jsx(hg,{"aria-hidden":"true",size:10,strokeWidth:2}),s.jsx("span",{children:e}),typeof a=="number"&&a>0&&s.jsx("span",{className:"rounded border border-[var(--scout-chrome-border-soft)] px-1 py-0 font-mono text-[8px] tracking-[0.1em] text-[var(--scout-chrome-ink-faint)]",children:a})]}),o&&s.jsx("div",{className:"mt-1.5",children:t})]}):s.jsxs("div",{className:"flex flex-col",children:[s.jsx("div",{className:"mb-1.5 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),t]})}function $I({label:e,eyebrow:t,onClick:n}){return s.jsxs("button",{type:"button",onClick:n,className:"flex items-center justify-between gap-2 rounded border border-[var(--scout-chrome-border-soft)] bg-white/[0.025] px-2 py-1.5 text-left hover:border-cyan-400/25 hover:bg-cyan-400/10",children:[s.jsxs("span",{className:"min-w-0",children:[t&&s.jsx("span",{className:"block font-mono text-[9px] uppercase tracking-[0.14em] text-[var(--scout-chrome-ink-faint)]",children:t}),s.jsx("span",{className:"block truncate font-mono text-[10px] text-[var(--scout-chrome-ink)]",children:e})]}),s.jsx(pg,{"aria-hidden":"true",size:11,strokeWidth:1.8,className:"shrink-0 text-cyan-300/75"})]})}function nbe({item:e,onOpen:t}){const n=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`mt-1 h-1.5 w-1.5 shrink-0 rounded-full ${rbe(e)}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"font-mono text-[9px] text-[var(--scout-chrome-ink-faint)]",children:Ie(e.at)}),s.jsx("span",{className:"shrink-0 rounded border border-[var(--scout-chrome-border-soft)] px-1 py-0.5 font-mono text-[8px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:sbe(e)})]}),s.jsx("span",{className:"mt-0.5 block truncate text-[10px] font-semibold text-[var(--scout-chrome-ink-strong)]",children:e.actorName??"system"}),e.title&&s.jsx("span",{className:"mt-0.5 block truncate text-[10px] leading-snug text-[var(--scout-chrome-ink)]",children:e.title}),e.summary&&s.jsx("span",{className:"mt-0.5 block text-[10px] leading-relaxed text-[var(--scout-chrome-ink-faint)]",style:{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:2,overflow:"hidden"},children:e.summary})]})]}),r="flex gap-2 border-t border-[var(--scout-chrome-border-soft)] pt-1.5 first:border-t-0 first:pt-0",a=kr(e.at);return t?s.jsx("button",{type:"button",onClick:t,title:a,className:`${r} text-left hover:text-cyan-300/90`,children:n}):s.jsx("div",{className:r,title:a,children:n})}function sbe(e){switch(e.kind){case"flight_started":return"flight started";case"flight_completed":return e.detailKind?`flight ${e.detailKind}`:"flight ended";case"message":return"message";default:return e.title??e.detailKind??"event"}}function rbe(e){return e.kind==="message"?"bg-cyan-400":e.kind==="flight_started"?"bg-lime-400":e.kind==="flight_completed"?e.detailKind?.includes("fail")?"bg-red-400":"bg-emerald-400":e.detailKind?.includes("interrupt")||e.detailKind?.includes("block")?"bg-amber-400":"bg-[var(--scout-chrome-ink-faint)]"}function Ys({label:e,value:t}){return s.jsxs("div",{className:"flex items-baseline justify-between py-0.5 gap-2",children:[s.jsx("span",{className:"shrink-0 text-[10px] font-mono uppercase tracking-wider text-[var(--scout-chrome-ink-faint)]",children:e}),s.jsx("span",{className:"truncate text-[11px] font-mono text-[var(--scout-chrome-ink)]",children:t})]})}function abe(e){return e.issues.some(t=>t.code==="mesh_loopback")?"loopback":e.identity.discoverable?"discoverable":e.tailscale.available?e.tailscale.running?"local-only":"tailnet-stopped":"unavailable"}function ibe(e){const t=new Map;for(const n of e){const r=(n.harness??n.agentClass??"agent").toLowerCase(),a=t.get(r)??{total:0,working:0};a.total+=1,Ge(n.state)==="working"&&(a.working+=1),t.set(r,a)}return Array.from(t.entries()).map(([n,r])=>({label:n,total:r.total,working:r.working})).sort((n,r)=>r.total-n.total).slice(0,6)}function LI(e){return e?e.replace(/^https?:\/\//,"").split("/")[0]??e:"Unavailable"}function obe(e){return e.split("/")[0]}function lbe(e){return new Promise(t=>window.setTimeout(t,e))}async function PI(e,t){let n=null,r=null;for(let a=0;a<=t.attempts;a+=1){try{if(n=await ue("/api/mesh"),tg(n),e(n))return n}catch(o){r=o}a<t.attempts&&await lbe(t.intervalMs)}if(n)return n;throw r instanceof Error?r:new Error("Mesh status is temporarily unavailable.")}function cbe(e){return e.issues.find(t=>t.code==="local_only"||t.code==="mesh_loopback"||t.code==="tailscale_stopped")?.summary??null}function ube(){const{meshSnapshot:e,selectedId:t,selectedType:n,probeCache:r}=zc(),{agents:a}=X5(),[o,c]=m.useState(!1),[u,f]=m.useState(!1),[h,p]=m.useState(null),x=m.useCallback(async()=>{c(!0),p({tone:"info",text:"Restarting broker with mesh discovery enabled..."});try{const N=await ue("/api/mesh/announce",{method:"POST",body:"{}"});tg(N);const T=N.identity.discoverable?N:await PI(R=>R.identity.discoverable,{attempts:6,intervalMs:750});T.identity.discoverable?p({tone:"success",text:`Discoverable at ${LI(T.identity.announceUrl??T.brokerUrl)}.`}):p({tone:"warning",text:cbe(T)??"Scout restarted the broker, but it is not discoverable yet."})}catch(N){p({tone:"error",text:N instanceof Error?N.message:String(N)})}finally{c(!1)}},[]),v=m.useCallback(async()=>{f(!0),p({tone:"info",text:"Opening Tailscale and waiting for the backend..."});try{const N=await ue("/api/mesh/tailscale",{method:"POST",body:JSON.stringify({action:"open_app"})});tg(N);const T=N.tailscale.running?N:await PI(R=>R.tailscale.running,{attempts:12,intervalMs:1e3});T.tailscale.running?p({tone:"success",text:`Tailscale is running with ${T.tailscale.onlineCount} online peer${T.tailscale.onlineCount===1?"":"s"}.`}):p({tone:"warning",text:`Tailscale opened, but the backend is still ${T.tailscale.backendState??"not running"}. Finish startup or sign-in in Tailscale.app.`})}catch(N){p({tone:"error",text:N instanceof Error?N.message:String(N)})}finally{f(!1)}},[]),y=m.useMemo(()=>{const N={total:a.length,working:0,ready:0,notReady:0};for(const T of a){const R=Ge(T.state);R==="working"?N.working+=1:R==="ready"?N.ready+=1:N.notReady+=1}return N},[a]),b=m.useMemo(()=>ibe(a),[a]);if(!e)return s.jsx("div",{className:"sys-inspector-empty",children:s.jsx("p",{children:"Loading mesh…"})});if(t?.startsWith("tailnet:")&&n==="node"){const N=t.slice(8),T=e.tailscale.peers.find(I=>I.id===N),R=r[t]??null,O=T?.addresses?.[0]?obe(T.addresses[0]):null,L=T?.hostName?.split(".")[0]??T?.hostName??"Tailnet peer";return s.jsxs("div",{className:"sys-inspector-content",children:[s.jsxs("div",{className:"sys-inspector-head",children:[s.jsx("h3",{className:"sys-inspector-title",children:L}),s.jsx("span",{className:`sys-chip sys-chip-${T?.online?"success":"failed"}`,children:T?.online?"Online":"Offline"})]}),s.jsxs("div",{className:"sys-detail-grid",children:[O&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Address"}),s.jsx("code",{className:"sys-detail-value",children:O})]}),T?.os&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Platform"}),s.jsx("span",{className:"sys-detail-value",children:T.os})]}),R?.result?.node?.meshId&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Mesh ID"}),s.jsxs("code",{className:"sys-detail-value",children:[R.result.node.meshId.slice(0,14),"…"]})]}),R?.result?.node?.name&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Node name"}),s.jsx("span",{className:"sys-detail-value",children:R.result.node.name})]})]}),(!R||R.status==="loading")&&s.jsx("div",{className:"sys-banner sys-banner-muted",style:{marginTop:8},children:s.jsx("span",{children:"Connecting to Scout broker…"})}),R?.status==="error"&&s.jsxs("div",{className:"sys-banner sys-banner-warning",style:{marginTop:8},children:[s.jsx("strong",{children:"Broker unreachable."}),s.jsx("span",{children:R.result?.error??"Could not reach the remote broker."})]}),R?.status==="done"&&R.result?.node?.capabilities?.length&&s.jsxs("div",{style:{marginTop:10},children:[s.jsx("div",{className:"sys-inspector-section-label",children:"Capabilities"}),s.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:R.result.node.capabilities.map(I=>s.jsx("span",{className:"sys-chip sys-chip-neutral",children:I},I))})]}),R?.status==="done"&&R.result?.home&&s.jsxs("div",{style:{marginTop:14},children:[s.jsxs("div",{className:"sys-inspector-section-label",children:["Agents — ",R.result.home.agents.length," registered"]}),R.result.home.agents.length===0?s.jsx("div",{className:"sys-list-empty",style:{marginTop:4},children:s.jsx("p",{children:"No agents registered on this broker."})}):s.jsx("div",{className:"mesh-agent-table",style:{marginTop:4},children:R.result.home.agents.map(I=>{const z=ll(I.state);return s.jsxs("div",{className:"mesh-detail-agent",style:{padding:"4px 0"},children:[s.jsx("span",{className:`mesh-detail-dot mesh-detail-dot--${z}`}),s.jsxs("div",{className:"mesh-detail-agent-body",children:[s.jsx("span",{className:"mesh-detail-agent-name",style:{fontSize:12},children:I.title}),I.activeTask&&s.jsx("span",{className:"mesh-detail-agent-task",children:I.activeTask})]}),s.jsx("span",{className:`mesh-detail-agent-state mesh-detail-agent-state--${z}`,children:I.statusLabel||z})]},I.id)})})]}),s.jsx("button",{type:"button",className:"s-btn",style:{marginTop:14},onClick:()=>Go(null,null),children:"Clear selection"})]})}if(t&&n==="node"){const T=Object.values(e.nodes).find(O=>O.id===t)??(e.localNode?.id===t?e.localNode:null),R=e.localNode?.id===t;return T?s.jsxs("div",{className:"sys-inspector-content",children:[s.jsxs("div",{className:"sys-inspector-head",children:[s.jsx("h3",{className:"sys-inspector-title",children:T.hostName?.split(".")[0]??T.name??"Node"}),R&&s.jsx("span",{className:"sys-chip sys-chip-neutral",children:"this broker"})]}),s.jsxs("div",{className:"sys-detail-grid",children:[s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Node ID"}),s.jsxs("code",{className:"sys-detail-value",children:[T.id.slice(0,16),"…"]})]}),T.brokerUrl&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Broker URL"}),s.jsx("code",{className:"sys-detail-value",children:LI(T.brokerUrl)})]}),T.hostName&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Host"}),s.jsx("span",{className:"sys-detail-value",children:T.hostName})]}),!R&&"lastSeenAt"in T&&typeof T.lastSeenAt=="number"&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Last seen"}),s.jsx("span",{className:"sys-detail-value",children:Ie(T.lastSeenAt)})]}),!R&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Scope"}),s.jsx("span",{className:"sys-detail-value",children:T.advertiseScope==="mesh"?"Announced to mesh":"Local only"})]})]}),R&&e.issues.length>0&&s.jsx("div",{className:"sys-issue-grid",style:{marginTop:12},children:e.issues.map((O,L)=>s.jsxs("article",{className:`sys-issue-card sys-issue-card-${O.severity==="error"?"error":"warning"}`,children:[s.jsx("div",{className:"sys-issue-head",children:s.jsx("h3",{className:"sys-issue-title",children:O.title})}),s.jsx("p",{className:"sys-issue-body",children:O.summary}),O.actionCommand&&s.jsx("div",{className:"sys-issue-action",children:s.jsx("code",{className:"sys-code-inline",children:O.actionCommand})})]},L))}),s.jsx("button",{type:"button",className:"s-btn",style:{marginTop:12},onClick:()=>Go(null,null),children:"Clear selection"})]}):s.jsxs("div",{className:"sys-inspector-empty",children:[s.jsx("p",{children:"Node not found."}),s.jsx("button",{type:"button",className:"s-btn",onClick:()=>Go(null,null),children:"Clear"})]})}const C=e,E=abe(C),A=Object.values(C.nodes).filter(N=>N.id!==C.localNode?.id).length,S=C.tailscale.onlineCount??0,k=C.localNode?.hostName?.split(".")[0]??C.localNode?.name??C.identity.name??"this broker";return s.jsxs("div",{className:"sys-inspector-content mesh-summary",children:[s.jsxs("div",{className:"sys-inspector-head",children:[s.jsx("h3",{className:"sys-inspector-title",children:k}),s.jsx("span",{className:"mesh-summary-mode",children:C.identity.modeLabel})]}),s.jsx("section",{className:"mesh-summary-section",children:s.jsxs("div",{className:"mesh-summary-counts",children:[s.jsxs("div",{className:"mesh-summary-count",children:[s.jsx("span",{className:"mesh-summary-count-value",children:y.total}),s.jsx("span",{className:"mesh-summary-count-label",children:"agents"})]}),s.jsxs("div",{className:"mesh-summary-count mesh-summary-count--working",children:[s.jsx("span",{className:"mesh-summary-count-value",children:y.working}),s.jsx("span",{className:"mesh-summary-count-label",children:"working"})]}),s.jsxs("div",{className:"mesh-summary-count",children:[s.jsx("span",{className:"mesh-summary-count-value",children:y.ready}),s.jsx("span",{className:"mesh-summary-count-label",children:"ready"})]}),s.jsxs("div",{className:"mesh-summary-count mesh-summary-count--offline",children:[s.jsx("span",{className:"mesh-summary-count-value",children:y.notReady}),s.jsx("span",{className:"mesh-summary-count-label",children:"not ready"})]})]})}),b.length>0&&s.jsxs("section",{className:"mesh-summary-section",children:[s.jsx("div",{className:"sys-inspector-section-label",children:"By harness"}),s.jsx("div",{className:"mesh-summary-harness",children:b.map(N=>s.jsxs("div",{className:"mesh-summary-harness-row",children:[s.jsx("span",{className:"mesh-summary-harness-name",children:N.label}),s.jsx("span",{className:"mesh-summary-harness-count",children:N.total}),N.working>0&&s.jsxs("span",{className:"mesh-summary-harness-working",children:[N.working," working"]})]},N.label))})]}),s.jsxs("section",{className:"mesh-summary-section",children:[s.jsx("div",{className:"sys-inspector-section-label",children:"Peers"}),s.jsxs("div",{className:"mesh-summary-peers",children:[s.jsxs("div",{className:"mesh-summary-peer-row",children:[s.jsx("span",{className:"mesh-summary-peer-label",children:"Mesh"}),s.jsx("span",{className:"mesh-summary-peer-value",children:A})]}),C.tailscale.available&&s.jsxs("div",{className:"mesh-summary-peer-row",children:[s.jsx("span",{className:"mesh-summary-peer-label",children:"Tailnet"}),s.jsx("span",{className:`mesh-summary-peer-value${C.tailscale.running?"":" mesh-summary-peer-value--dim"}`,children:C.tailscale.running?`${S} online`:"stopped"})]})]})]}),s.jsxs("section",{className:"mesh-summary-section mesh-summary-reach",children:[s.jsx("div",{className:"sys-inspector-section-label",children:"Reach"}),s.jsx(dbe,{state:E,tailscaleAvailable:C.tailscale.available,announcing:o,tailscaleBusy:u,onAnnounce:()=>{x()},onStartTailscale:()=>{v()}}),h&&s.jsx("div",{className:`sys-banner mesh-action-message sys-banner-${h.tone}`,children:s.jsx("span",{children:h.text})})]})]})}function dbe({state:e,tailscaleAvailable:t,announcing:n,tailscaleBusy:r,onAnnounce:a,onStartTailscale:o}){return e==="discoverable"?s.jsxs("div",{className:"mesh-reach mesh-reach--on",children:[s.jsx("span",{className:"mesh-reach-dot"}),s.jsx("span",{className:"mesh-reach-label",children:"Discoverable on mesh"})]}):e==="tailnet-stopped"?s.jsxs("div",{className:"mesh-reach",children:[s.jsxs("div",{className:"mesh-reach-row",children:[s.jsx("span",{className:"mesh-reach-dot mesh-reach-dot--off"}),s.jsx("span",{className:"mesh-reach-label",children:"Tailscale stopped"})]}),s.jsx("button",{type:"button",className:"s-btn mesh-reach-action",disabled:r,onClick:o,children:r?"Opening…":"Start Tailscale"})]}):e==="loopback"?s.jsxs("div",{className:"mesh-reach",children:[s.jsxs("div",{className:"mesh-reach-row",children:[s.jsx("span",{className:"mesh-reach-dot mesh-reach-dot--off"}),s.jsx("span",{className:"mesh-reach-label",children:"Announcement broken"})]}),s.jsx("button",{type:"button",className:"s-btn mesh-reach-action",disabled:n,onClick:a,children:n?"Fixing…":"Fix announcement"})]}):e==="unavailable"?s.jsxs("div",{className:"mesh-reach mesh-reach--neutral",children:[s.jsx("span",{className:"mesh-reach-dot mesh-reach-dot--off"}),s.jsx("span",{className:"mesh-reach-label",children:"Local only — no tailnet on this host"})]}):s.jsxs("div",{className:"mesh-reach",children:[s.jsxs("div",{className:"mesh-reach-row",children:[s.jsx("span",{className:"mesh-reach-dot mesh-reach-dot--off"}),s.jsx("span",{className:"mesh-reach-label",children:"Local only"})]}),s.jsx("button",{type:"button",className:"s-btn s-btn-primary mesh-reach-action",disabled:n||!t,onClick:a,children:n?"Announcing…":"Make discoverable"})]})}const fbe=new Map([["a",1],["an",1],["one",1],["two",2],["three",3],["four",4],["five",5],["six",6],["seven",7],["eight",8],["nine",9],["ten",10],["eleven",11],["twelve",12],["fifteen",15],["twenty",20],["thirty",30],["forty",40],["forty-five",45],["sixty",60]]),Mm=String.raw`(\d+(?:\.\d+)?|a|an|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|fifteen|twenty|thirty|forty|forty-five|sixty)`,Rm=String.raw`(seconds?|secs?|minutes?|mins?|hours?|hrs?)`,hbe=[new RegExp(String.raw`\b(?:please\s+)?(?:can\s+you\s+|could\s+you\s+)?(?:set\s+(?:a\s+)?reminder|remind\s+me|ping\s+me|nudge\s+me)(?:\s+for\s+(?:me|you|us))?\s+(?:in|after|for)\s+${Mm}\s+${Rm}\b(?:\s+(?:to|about|on|for)\s+(.+))?`,"i"),new RegExp(String.raw`\b(?:please\s+)?(?:check\s+back|follow\s+up)(?:\s+with\s+(?:me|us))?\s+(?:in|after)\s+${Mm}\s+${Rm}\b(?:\s+(?:to|about|on|for)\s+(.+))?`,"i"),new RegExp(String.raw`\b(?:please\s+)?(?:can\s+i\s+get|can\s+you\s+give\s+me|give\s+me|send\s+me|get\s+me)\s+(?:a\s+|an\s+)?(?:quick\s+|short\s+)?(?:status\s+)?update\s+(?:in|after)\s+${Mm}\s+${Rm}\b(?:\s+(?:to|about|on|for)\s+(.+))?`,"i"),new RegExp(String.raw`\bin\s+${Mm}\s+${Rm}\s+(?:remind\s+me|ping\s+me|nudge\s+me)(?:\s+(?:to|about|on|for)\s+(.+))?`,"i")];function mbe(e,t=Date.now()){const n=e.replace(/\s+/g," ").trim();if(!n)return null;for(const r of hbe){const a=n.match(r);if(!a)continue;const o=pbe(a[1]??""),c=a[2]??"";if(o===null)continue;const u=gbe(o,c);if(u===null)continue;const f=vbe(a[3]??"",n);return{body:f,title:xbe(f),delayMs:u,dueAt:t+u}}return null}function pbe(e){const t=e.trim().toLowerCase();if(!t)return null;const n=fbe.get(t);if(n!==void 0)return n;const r=Number(t);return Number.isFinite(r)&&r>=0?r:null}function gbe(e,t){const n=t.trim().toLowerCase();return n.startsWith("sec")?Math.round(e*1e3):n.startsWith("min")?Math.round(e*6e4):n.startsWith("hr")||n.startsWith("hour")?Math.round(e*60*6e4):null}function vbe(e,t){const n=e.replace(/[.?!]+$/g,"").replace(/^(?:please\s+)?(?:that\s+)?/i,"").trim();return n||(/\bcheck\s+back\b/i.test(t)?"check back":/\bupdate\b/i.test(t)?"give me an update":"follow up")}function xbe(e){const t=e.replace(/\s+/g," ").trim();return t.length<=42?t:`${t.slice(0,39).trim()}...`}const ybe=new Set(["air-local","local","mini","node"]),bbe=new Set(["main","master","trunk"]);function _w(e){return e.replace(/```[\s\S]*?```/g," code omitted ").replace(/\*\*([^*\n]+)\*\*/g,"$1").replace(/(^|[\s(])\*([^\s*][^*\n]*?[^\s*]|[^\s*])\*(?=[\s)\].,!?;:]|$)/g,"$1$2").replace(/(^|[\s(])_([^\s_][^_\n]*?[^\s_]|[^\s_])_(?=[\s)\].,!?;:]|$)/g,"$1$2").replace(/^\s*[-*]\s+/gm,"").replace(/\bhttps?:\/\/[^\s)]+/gi,t=>wbe(t)).replace(/\b(session|conversation|message|flight|invocation|work)(?:\s+(?:id|ref))?\s*[:#]?\s+([a-z0-9][a-z0-9._:-]{9,})\b/gi,(t,n,r)=>`${n.toLowerCase()} ending in ${Ow(r)}`).replace(/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi,t=>`ID ending in ${Ow(t)}`).replace(/@?([a-z][a-z0-9-]*(?:\.[a-z0-9][a-z0-9-]*){2,})\b/gi,(t,n)=>jbe(t)?t:kbe(n)).replace(/`([^`]+)`/g,(t,n)=>Nbe(n)).replace(/\s+/g," ").trim()}function wbe(e){try{return new URL(e).hostname.replace(/^www\./,"").replace(/\./g," dot ")}catch{return"link"}}function jbe(e){const t=e.replace(/^@/,"").toLowerCase();return/\.(com|app|dev|org|net|io|local)(?:\b|\/)/.test(t)&&!t.endsWith(".air-local")}function kbe(e){const t=e.split(".").filter(Boolean);if(t.length<2)return e;const n=[...t];for(;n.length>1&&ybe.has(n.at(-1).toLowerCase());)n.pop();const[r,...a]=n,o=a.filter(c=>!bbe.has(c.toLowerCase())).map($w).filter(Boolean);return[$w(r),...o].filter(Boolean).join(", ")}function Nbe(e){return/^[a-z0-9][a-z0-9._:-]{12,}$/i.test(e)?`ID ending in ${Ow(e)}`:$w(e)}function Ow(e){return(e.replace(/[^a-z0-9]/gi,"").slice(-4)||e.slice(-4)).split("").join(" ")}function $w(e){return e.replace(/^@/,"").replace(/[_./:-]+/g," ").replace(/\s+/g," ").trim()}const Sbe="chill-dispatcher",Cbe=100,Ebe=6e4,Abe=2500,Tbe={lowCutHz:160,highCutHz:5200,bandQ:.35,saturationAmount:.035,bitcrushAmount:0,hissGain:0,hissCutoffHz:1800,presencePeakDb:1.5,presenceCenterHz:1500,presenceQ:.65,compressorThresholdDb:-15,compressorRatio:2.2,clickEnabled:!0,clickGain:.24,clickDurationMs:45,squelchTailEnabled:!0,squelchTailGain:.018,squelchTailDurationMs:95,outputGain:1,wetMix:.38};function Mbe(e){const t=Math.min(1,e/8);return{saturationAmount:.035+t*.025,presencePeakDb:1.5+t*1.5}}function DI(e,t){return{...e==="chill-dispatcher"?Tbe:{},...Mbe(t)}}function $4(e,t,n){return new Promise((r,a)=>{const o=window.setTimeout(()=>a(new Error(n)),t);e.then(r,a).finally(()=>window.clearTimeout(o))})}async function zI(e,t={}){!e.sessionId&&!t.allowCurrentSession||await $4(e.cancel(),Abe,"Timed out releasing Vox live session.").catch(()=>{})}function Rbe(e){const t=e instanceof Error?e.message:String(e);return/session_cancelled|was cancelled|cancelled/i.test(t)}const Ibe="What's the state of things? Give me a terse ops summary, the biggest risk, and the next action you recommend.",Im=[1,1.2,1.35],_be=1.2,Obe=`
181
-
182
- `,$be=["Read as a calm local operations briefer.","Use the paragraph breaks as short breath moments so the operator can look at the screen.","Keep the tone warm, focused, and unhurried; do not sound like an advertisement."].join(" ");function Lbe(e){let t="";const n=[];for(const r of e){const a=_w(r.narration);if(!a)continue;t&&(t+=Obe);const o=t.length;t+=a,n.push({id:r.cueId,textStart:o,textEnd:t.length})}return{text:t,cues:n}}function Pbe(e,t){const n=e.speechTiming?.cues;if(!n?.length)return null;const r=new globalThis.Map(n.map(o=>[o.id,o])),a=[];for(let o=0;o<t.length;o+=1){const c=t[o],u=r.get(c.cueId);if(!u||!Number.isFinite(u.startMs))return null;a.push({cueId:c.cueId,segmentIndex:o,activateMs:Math.max(0,u.startMs-Cbe)})}return a}function Dbe({height:e}={}){const{applyScoutbotUiAction:t,route:n,onlineCount:r}=qe(),a=Hre(),[o,c]=mw("openscout.scoutbot.collapsed",!0),[u,f]=m.useState(""),[h,p]=m.useState(!1),[x,v]=m.useState(null),[y,b]=m.useState(null),[C,E]=m.useState(null),[A,S]=m.useState("idle"),[k,N]=mw("openscout.scoutbot.voiceReplies",!1),[T,R]=Rk("openscout.scoutbot.voiceSpeed",_be),[O,L]=$5("openscout.scoutbot.voicePresetId",Sbe),[I,z]=m.useState(!1),[_,U]=m.useState(null),[D,q]=m.useState(null),[Z,$]=m.useState(!1),[G,V]=m.useState(null),[Y,K]=m.useState(""),[P,H]=m.useState(!1),[B,Q]=m.useState(null),[oe,ne]=m.useState(null),[X,ae]=m.useState(null),[be,_e]=m.useState(!1),[xe,pe]=m.useState(null),[te,ve]=m.useState(!1),[he,ke]=m.useState(null),[Ne,Fe]=m.useState(!1),[Ee,Le]=m.useState(!1),[Te,Pe]=m.useState(null),[De,ze]=m.useState(null),[$e,st]=m.useState(""),[rt,Xe]=m.useState(""),[dt,jt]=m.useState(null),[At,mt]=m.useState(null),[Ht,ie]=m.useState(!1),[ce,Ae]=m.useState(!1),[Be,tt]=m.useState(null),at=m.useRef(null),Oe=m.useRef(null),He=m.useRef(null),ot=m.useRef(null),nt=m.useRef(null),$t=m.useRef(null),Tn=m.useRef(!1),fn=m.useRef(new Set),Gt=m.useRef(k);Gt.current=k;const Rt=m.useCallback(()=>{nt.current?.abort(),nt.current=null,ot.current?.stop(),ot.current=null,H(!1)},[]),Gn=m.useCallback(W=>{if(!W)return;Rt();const ee=Ele(_w(W),{speed:T,presetId:O,params:DI(O,r)});ot.current=ee,H(!0),ee.promise.catch(de=>{ed(de)||v(de instanceof Error?de.message:"Vox speech failed.")}).finally(()=>{ot.current===ee&&(ot.current=null,H(!1))})},[Rt,T,r,O]),On=m.useCallback(W=>{Gt.current&&Gn(W)},[Gn]),re=m.useCallback(W=>{Gn(gd(W))},[Gn]),{openFilePreview:Re}=qe(),Ve=Xc(),Ct=m.useCallback((W,ee)=>{const de=window.getSelection()?.toString().trim(),Me=gd(ee),We=zbe(Me),Qe=[];if(de&&(Qe.push({kind:"action",label:"Copy selection",shortcut:"⌘C",onSelect:()=>{Nn(de)}}),Qe.push({kind:"separator"})),Qe.push({kind:"action",label:"Copy message",onSelect:()=>{Nn(Me)}}),We.length>0){Qe.push({kind:"separator"});for(const lt of We.slice(0,5)){const ft=UI(lt);Qe.push({kind:"action",label:`Preview ${ft}`,onSelect:()=>Re(lt)})}for(const lt of We.slice(0,5)){const ft=UI(lt);Qe.push({kind:"action",label:`Open ${ft} in OS`,onSelect:()=>{ue("/api/file/reveal",{method:"POST",body:JSON.stringify({path:lt})}).catch(()=>{})}})}Qe.push({kind:"action",label:We.length===1?"Copy path":"Copy first path",onSelect:()=>{Nn(We[0])}})}Qe.push({kind:"separator"}),Qe.push({kind:"action",label:P?"Say again (stop current)":"Say",onSelect:()=>re(ee)}),Ve(W,Qe)},[Re,re,Ve,P]);m.useEffect(()=>()=>{$t.current=null,Rt()},[Rt]);const Ft=m.useCallback(W=>{const ee=[...W.messages].reverse().find(Me=>Me.role==="user"),de=[...W.messages].reverse().find(Me=>Me.role==="assistant");Q(ee?.body??null),ne(de?gd(de.body):null)},[]),$n=m.useCallback(async()=>{try{const W=await ue("/api/scoutbot/session");pe(W),Ft(W.session)}catch{pe(null)}},[Ft]);m.useEffect(()=>{$n()},[$n]);const tn=m.useCallback(async()=>{try{mt(await ue("/api/scoutbot/reminders"))}catch{mt(null)}},[]);m.useEffect(()=>{tn();const W=window.setInterval(()=>{tn()},15e3);return window.addEventListener("focus",tn),()=>{window.clearInterval(W),window.removeEventListener("focus",tn)}},[tn]);const Lt=m.useCallback(async W=>{const ee=await ue("/api/scoutbot/reminders",{method:"POST",body:JSON.stringify({...W,source:"scoutbot"})});return mt({generatedAt:ee.generatedAt,reminders:ee.reminders,due:ee.due,scheduled:ee.scheduled}),ee.reminder},[]),Et=m.useCallback(async W=>{const ee=await ue(`/api/scoutbot/reminders/${encodeURIComponent(W)}/dismiss`,{method:"POST"});mt(ee)},[]),Tt=m.useCallback(async()=>{Fe(!0),Pe(null);try{const W=await ue("/api/scoutbot/config");st(W.model),Xe(W.systemPrompt),ze(null)}catch(W){Pe(W instanceof Error?W.message:"Could not load settings.")}finally{Fe(!1)}},[]);m.useEffect(()=>{be&&Tt()},[Tt,be]),m.useEffect(()=>{if(!be)return;let W=!1;return ue("/api/voice/defaults").then(ee=>{W||jt(ee)}).catch(()=>{W||jt(null)}),()=>{W=!0}},[be]);const Jn=m.useCallback(async()=>{Le(!0),Pe(null),ze(null);try{const W=await ue("/api/scoutbot/config",{method:"POST",body:JSON.stringify({model:$e,systemPrompt:rt})});st(W.config.model),Xe(W.config.systemPrompt),ze("Saved")}catch(W){Pe(W instanceof Error?W.message:"Could not save settings.")}finally{Le(!1)}},[$e,rt]),sr=m.useCallback(async W=>{if(!(!W||Be)){tt(W),v(null),Rt();try{const ee=await ue("/api/scoutbot/session/switch",{method:"POST",body:JSON.stringify({id:W})});pe(ee),Ft(ee.session),Ae(!1),ie(!1)}catch(ee){v(ee instanceof Error?ee.message:"Could not switch session.")}finally{tt(null)}}},[Rt,Be,Ft]),ga=m.useCallback(async()=>{ve(!0),v(null),ae("Starting fresh session"),Rt();try{const W=await ue("/api/scoutbot/session/reset",{method:"POST"});pe(W),Q(null),ne(null),ie(!1),Ae(!1),ae("Fresh session ready")}catch(W){ae(null),v(W instanceof Error?W.message:"Could not start a fresh session.")}finally{ve(!1)}},[Rt]),so=m.useCallback(async W=>{if(!(!W||he)){ke(W),v(null),Rt();try{const ee=await ue("/api/scoutbot/session/archive",{method:"POST",body:JSON.stringify({id:W})});pe(ee),Ft(ee.session),ie(!1),ae("session archived")}catch(ee){v(ee instanceof Error?ee.message:"Could not archive session.")}finally{ke(null)}}},[he,Rt,Ft]),ps=m.useCallback(async()=>{const W=at.current??new vd;at.current=W,S("probing");const ee=await W.probe();return b(ee),E(ee?null:W.lastUnavailableReason??"Vox Companion is not reachable."),S("idle"),ee},[]);m.useEffect(()=>{if(!iw()){S("idle");return}ps();const W=()=>{ps()},ee=()=>{document.visibilityState==="visible"&&ps()};return window.addEventListener("focus",W),document.addEventListener("visibilitychange",ee),()=>{window.removeEventListener("focus",W),document.removeEventListener("visibilitychange",ee)}},[ps]);const Es=m.useCallback(()=>{const W=at.current??new vd;at.current=W,v(null),S("launching"),W.launch({source:"openscout",context:FI()}),window.setTimeout(()=>{ps()},2400)},[ps]),va=m.useCallback(()=>{const W=at.current??new vd;at.current=W,W.openSettings({source:"openscout",context:FI()})},[]),Bs=m.useCallback(W=>{const ee=gd(W);ne(ee);for(const de of Jse(W))de.type==="ask-agent"?(ae(`Asking ${de.targetLabel}`),ue("/api/scoutbot/actions/ask",{method:"POST",body:JSON.stringify({targetLabel:de.targetLabel,targetAgentId:de.targetAgentId,body:de.body,channel:de.channel})}).then(Me=>{ae(Me.flightId?`Asked ${Me.targetAgentId??Me.targetLabel} · flight ${Me.flightId}`:`Asked ${Me.targetAgentId??Me.targetLabel}`)}).catch(Me=>{ae(null),v(Me instanceof Error?Me.message:"Could not ask agent.")})):de.type==="reminder"?Lt({title:de.title,body:de.body,dueAt:de.dueAt,delayMs:de.delayMs,delayMinutes:de.delayMinutes,context:{route:n,reason:de.reason}}).then(Me=>{ae(`Reminder set for ${VI(Me.dueAt)}`)}).catch(Me=>{v(Me instanceof Error?Me.message:"Could not set reminder.")}):t(de);On(ee)},[t,Lt,n,On]);m.useEffect(()=>{const W=At?.due??[];if(!Tn.current){for(const Me of W)fn.current.add(Me.id);Tn.current=!0;return}const ee=W.find(Me=>!fn.current.has(Me.id));if(!ee)return;for(const Me of W)fn.current.add(Me.id);const de=`Reminder due: ${ee.body}`;ae("Reminder due"),ne(de),On(de)},[At,On]),m.useCallback(()=>{const W=Im.reduce((ee,de,Me)=>Math.abs(de-T)<Math.abs(Im[ee]-T)?Me:ee,0);R(Im[(W+1)%Im.length])},[R,T]);const rr=m.useCallback((W,ee,de)=>{if(!Gt.current)return{promise:Promise.resolve(null),abort:()=>{}};nt.current?.abort();const Me=new AbortController;nt.current=Me;const We=()=>{Me.abort(),nt.current===Me&&(nt.current=null)};return{promise:t5(W,{speed:T,instructions:$be,signal:Me.signal,originAppId:"openscout.scoutbot",utteranceId:`scoutbot-brief:${de}`,...ee.length>0?{speechTiming:{enabled:!0,cues:ee}}:{}}).catch(lt=>(ed(lt)||v(lt instanceof Error?lt.message:"Vox speech failed."),null)).finally(()=>{nt.current===Me&&(nt.current=null)}),abort:We}},[T]),Cr=m.useCallback(async(W,ee,de={})=>{const Me=await W;if(!Me||$t.current!==ee||!Gt.current)return!1;const We=new AbortController,Qe=[],lt=DI(O,r),ft=Math.min(2,Math.max(.5,lt.playbackRate??1)),Wt=()=>{for(const Cn of Qe)window.clearTimeout(Cn);Qe.length=0},Zt=()=>{if(de.cueSchedule?.length)for(const Cn of de.cueSchedule){const wa=Math.max(0,Cn.activateMs/ft);Qe.push(window.setTimeout(()=>{We.signal.aborted||$t.current!==ee||de.onCue?.(Cn)},wa))}},kt=Cle(Me,{signal:We.signal,presetId:O,params:lt,onPlaybackStart:Zt}),yt={promise:kt,stop:()=>{Wt(),We.abort()}};ot.current?.stop(),ot.current=yt,H(!0);try{await kt}catch(Cn){if(!ed(Cn))throw Cn}finally{Wt(),ot.current===yt&&(ot.current=null,H(!1))}return!0},[r,O]),ar=m.useCallback(async(W,ee)=>{const de=[...W.steps.map(kt=>({id:kt.id,cueId:`step:${kt.id}`,label:kt.label,route:kt.route,narration:kt.narration,durationMs:kt.durationMs})),{id:"recommendation",cueId:"recommendation",label:"Recommendation",route:null,narration:`Recommendation: ${W.recommendation}`,durationMs:Bbe(W.recommendation)}],Me=[],We=Lbe(de);let Qe=null,lt=null;const ft=(kt,yt)=>{if(q(Math.min(yt,W.steps.length-1)),ae(`Brief ${Math.min(yt+1,W.steps.length)}/${W.steps.length}: ${kt.label}`),kt.route){const Cn=ak({type:"navigate",route:kt.route});Cn?.type==="navigate"&&t(Cn)}Me.push(`${kt.label}: ${kt.narration}`)},Wt=async()=>{for(let kt=0;kt<de.length;kt+=1){if($t.current!==ee)return;if(Date.now()>W.expiresAt){ae("Brief expired; refresh before acting");break}const yt=de[kt];ft(yt,kt),await Hbe(Math.min(yt.durationMs,2400))}};if(Gt.current&&(ae("Preparing brief audio"),Qe=rr(We.text||_w(W.summary),We.cues,ee),lt=await Qe.promise,$t.current!==ee)){Qe.abort();return}const Zt=lt?Pbe(lt,de):null;if(lt&&Zt){const kt=new Set;try{!await Cr(Promise.resolve(lt),ee,{cueSchedule:Zt,onCue:Cn=>{if(!kt.has(Cn.segmentIndex)){if(Date.now()>W.expiresAt){ae("Brief expired; refresh before acting");return}kt.add(Cn.segmentIndex),ft(de[Cn.segmentIndex],Cn.segmentIndex)}}})&&$t.current===ee&&await Wt()}catch(yt){ed(yt)||v(yt instanceof Error?yt.message:"Vox speech failed.")}}else{const kt=lt&&Gt.current?Cr(Promise.resolve(lt),ee):null;if(await Wt(),kt)try{await kt}catch(yt){ed(yt)||v(yt instanceof Error?yt.message:"Vox speech failed.")}}$t.current===ee&&(ne([W.summary,"",...Me].join(`
183
- `)),ae(Date.now()>W.expiresAt?"Brief expired":"Brief complete"),z(!1),q(null),$t.current=null)},[t,Cr,rr]),un=m.useCallback(async()=>{if(I||h)return;const W=`brief-${Date.now()}`;$t.current=W,z(!0),U(null),q(null),v(null),Q("One-minute brief"),ne(null),ae("Preparing one-minute brief"),Rt();try{await Y0().catch(()=>null);const ee=await ue("/api/scoutbot/brief",{method:"POST",body:JSON.stringify({route:n,ttlMs:2*6e4})});if($t.current!==W)return;U(ee),await ar(ee,W)}catch(ee){$t.current===W&&(ae(null),v(ee instanceof Error?ee.message:"Could not prepare brief."),z(!1),q(null),$t.current=null)}},[I,n,ar,h,Rt]),As=m.useCallback(async W=>{const ee=W.trim();if(!(!ee||h)){p(!0),v(null),Q(ee),ne(null),ae("Sending"),f(de=>de.trim()===ee?"":de);try{const de=mbe(ee);if(de){ae("Setting reminder");const We=await Lt({title:de.title,body:de.body,delayMs:de.delayMs,context:{route:n,naturalLanguage:ee}}),Qe=`Reminder set for ${VI(We.dueAt)}: ${We.body}`;ae("Reminder set"),Bs(Qe);return}await Y0().catch(()=>null);const Me=await ue("/api/scoutbot/chat",{method:"POST",body:JSON.stringify({body:ee,route:n})});pe({session:Me.session,sessions:Me.sessions,config:Me.config}),ae("Reply received"),Bs(Me.reply.body)}catch(de){ae(null),v(de instanceof Error?de.message:"Could not send.")}finally{p(!1)}}},[Lt,Bs,n,h]),fl=m.useCallback(async()=>{if(Z)return;const W=at.current??new vd;if(at.current=W,He.current=null,v(null),K(""),V("starting"),y!==!0&&!await ps()){V(null);return}let ee=null,de=!1;const Me=async()=>{!ee||de||(de=!0,await zI(ee,{allowCurrentSession:Oe.current===ee}),Oe.current===ee&&(Oe.current=null))};try{ee=await W.startLive({onState:V,onPartial:K}),Oe.current=ee,$(!0);const We=await ee.result;if(await Me(),$(!1),K(""),He.current)return;V("done"),We.text&&await As(We.text)}catch(We){const Qe=He.current,lt=!!Qe||Rbe(We);if(await Me(),$(!1),K(""),Qe==="stop-failed")return;V(lt?null:"error"),lt||v(We instanceof Error?We.message:"Vox recording failed.")}finally{await Me(),He.current=null}},[As,ps,Z,y]),ir=m.useCallback(async()=>{const W=Oe.current;if(W){V("processing");try{await $4(W.stop(),Ebe,"Vox did not finish processing the recording.")}catch(ee){He.current="stop-failed",await zI(W,{allowCurrentSession:!0}),Oe.current===W&&(Oe.current=null,$(!1),K(""),V("error")),v(ee instanceof Error?`Vox recording did not finish: ${ee.message}`:"Vox recording did not finish.")}}},[]);m.useEffect(()=>{const W=()=>c(!1);return window.addEventListener("scout:scoutbot-panel-open",W),()=>window.removeEventListener("scout:scoutbot-panel-open",W)},[c]),m.useEffect(()=>rie(()=>c(!o)),[o,c]);const Vr=wD(),Er=jD(Vr);m.useEffect(()=>{const W=ee=>{const de=ee.detail,Me=de&&typeof de=="object"&&"body"in de?de.body:null;typeof Me=="string"&&Me.trim()&&(c(!1),As(Me))};return window.addEventListener("scout:scoutbot-submit",W),()=>window.removeEventListener("scout:scoutbot-submit",W)},[As,c]),m.useEffect(()=>{const W=()=>{c(!1),!I&&!h&&un()};return window.addEventListener("scout:scoutbot-brief-now",W),()=>window.removeEventListener("scout:scoutbot-brief-now",W)},[I,h,c,un]);const xa=m.useMemo(()=>{const W=P?"speaking":I?"briefing":h?"thinking":Z?"listening":"idle",ee=xe?.session??null,de=ee&&ee.messages.length>0?ee.messages[ee.messages.length-1]:null,Me=(At?.due??[]).slice(0,5).map(Qe=>({id:Qe.id,body:Qe.body,status:Qe.status,dueAt:Qe.dueAt})),We=At?.scheduled[0];return{activity:W,brief:{lastDeliveredAt:_&&!I?_.preparedAt:null},reminders:{dueCount:At?.due.length??0,upcomingCount:At?.scheduled.length??0,due:Me,next:We?{id:We.id,body:We.body,status:We.status,dueAt:We.dueAt}:null},voice:{available:y,setupBlocked:y===!1,replies:k},error:x,session:{title:ee?.title??null,lastActivityAt:de?.createdAt??ee?.updatedAt??null}}},[P,I,h,Z,_,At,y,k,x,xe]);m.useEffect(()=>{a?.publishState(xa)},[a,xa]),m.useEffect(()=>{if(!a)return;const W={focusScoutbot:()=>c(!1),triggerBrief:()=>{c(!1),!I&&!h&&un()},triggerAskState:()=>{c(!1),As(Ibe)},toggleVoiceReplies:()=>{const ee=!k;N(ee),ee||Rt()},openScoutbotSettings:()=>{c(!1),_e(!0)},startNewChat:()=>{c(!1),te||ga()},dismissReminder:ee=>{Et(ee)},askReminderStatus:({body:ee})=>{c(!1),As(`Reminder due: ${ee}. Check the current Scout control-plane state and give me the shortest useful status update.`)}};a.registerActions(W)},[a,c,I,h,un,As,k,N,Rt,_e,te,ga,Et]);const ya=At?.due.length??0;m.useEffect(()=>{ya>0?rb({key:"reminder.due",tier:"warn",text:`${ya} reminder${ya===1?"":"s"} due`}):ab("reminder.due")},[ya]),m.useEffect(()=>{y===!1?rb({key:"voice.offline",tier:"warn",text:"Voice setup needed"}):y===!0&&ab("voice.offline")},[y]),m.useEffect(()=>{x?rb({key:"scoutbot.error",tier:"error",text:x}):ab("scoutbot.error")},[x]);const nu=Z?G==="processing"?"Sending":"Stop":A==="probing"?"Checking Vox":A==="launching"?"Opening Vox":y===!1?"Launch Vox":"Start Talking",gs=xe?.session??null;if(gs?.id,gs?.createdAt&&new Date(gs.createdAt).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),gs?.model??xe?.config.model,o)return s.jsx("div",{className:"flex shrink-0 items-center border-t border-[var(--scout-chrome-border-soft)] px-3 py-1.5",children:s.jsx(ND,{})});const ba=e===void 0?"flex max-h-[60vh] shrink-0 flex-col overflow-hidden border-t border-[var(--scout-chrome-border-soft)]":"flex shrink-0 flex-col overflow-hidden border-t border-[var(--scout-chrome-border-soft)]",Us=e===void 0?void 0:{height:`${e}px`};return s.jsxs("section",{className:ba,style:Us,children:[s.jsxs("div",{className:"flex shrink-0 flex-col gap-2 px-3 pt-2.5 pb-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"flex min-w-0 items-center gap-2",children:s.jsx(dg,{size:20,className:"shrink-0 text-lime-300","aria-hidden":"true"})}),s.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[s.jsx(WI,{icon:k?s.jsx(T2,{size:11}):s.jsx(M2,{size:11}),title:k?"Voice replies on (click to mute)":"Voice replies off (click to enable)",onClick:()=>{const W=!k;N(W),W||Rt()},active:k}),s.jsx(WI,{icon:s.jsx(Xo,{size:11}),title:"Minimize",onClick:()=>c(!0)})]})]}),Er&&s.jsx("div",{className:`rounded border px-2.5 py-1.5 font-mono text-[10px] leading-relaxed ${Er.tier==="error"?"border-rose-300/30 bg-rose-300/[0.07] text-rose-50":Er.tier==="warn"?"border-amber-300/30 bg-amber-300/[0.07] text-amber-50":"border-lime-300/20 bg-lime-300/[0.05] text-[var(--scout-chrome-ink)]"}`,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Gw,{size:11,className:`shrink-0 ${Er.tier==="error"?"text-rose-200":Er.tier==="warn"?"text-amber-200":"text-lime-200"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--scout-chrome-ink)]",children:Er.text}),s.jsx("button",{type:"button",title:"Ask about this","aria-label":"Ask about this",onClick:()=>{As(`Tell me about this broadcast: ${Er.text}`)},disabled:h||I,className:"shrink-0 rounded border border-[var(--scout-chrome-border-soft)] p-1 text-[var(--scout-chrome-ink-faint)] hover:bg-[var(--scout-chrome-hover)] hover:text-[var(--scout-chrome-ink)] disabled:opacity-40",children:s.jsx(WB,{size:11})}),s.jsx("button",{type:"button",title:"Dismiss","aria-label":"Dismiss broadcast",onClick:()=>tie(),className:"shrink-0 rounded border border-[var(--scout-chrome-border-soft)] p-1 text-[var(--scout-chrome-ink-faint)] hover:bg-[var(--scout-chrome-hover)] hover:text-[var(--scout-chrome-ink)]",children:s.jsx(Bi,{size:11})})]})}),be&&s.jsx("div",{className:"rounded border border-[var(--scout-chrome-border-soft)] bg-black/10 p-3",children:s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs("label",{className:"flex flex-col gap-1 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:["Voice FX",s.jsx("select",{value:O,onChange:W=>L(W.target.value),className:"rounded border border-[var(--scout-chrome-border-soft)] bg-black/20 px-2 py-1.5 font-mono text-[11px] normal-case tracking-normal text-[var(--scout-chrome-ink)]",children:af.map(W=>s.jsxs("option",{value:W.id,children:[W.label," — ",W.family]},W.id))}),s.jsx("span",{className:"font-mono text-[9px] normal-case leading-relaxed tracking-normal text-[var(--scout-chrome-ink-ghost)]",children:af.find(W=>W.id===O)?.description??"Custom voice mood for spoken replies."})]}),s.jsxs("div",{className:"flex flex-col gap-1 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:["Vox Voice",s.jsx("div",{className:"rounded border border-[var(--scout-chrome-border-soft)] bg-black/20 px-2 py-1.5 font-mono text-[11px] normal-case tracking-normal text-[var(--scout-chrome-ink)]",children:dt?`${dt.modelId}${dt.voiceId?` / ${dt.voiceId}`:""}`:"Unavailable"})]}),s.jsxs("label",{className:"flex flex-col gap-1 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:["Model",s.jsx("input",{value:$e,onChange:W=>st(W.target.value),placeholder:"gpt-4.1-mini",className:"rounded border border-[var(--scout-chrome-border-soft)] bg-black/20 px-2 py-1.5 font-mono text-[11px] normal-case tracking-normal text-[var(--scout-chrome-ink)] placeholder:text-[var(--scout-chrome-ink-ghost)]",disabled:Ne||Ee})]}),s.jsxs("label",{className:"flex flex-col gap-1 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:["System Prompt",s.jsx("textarea",{value:rt,onChange:W=>Xe(W.target.value),rows:6,className:"w-full resize-y rounded border border-[var(--scout-chrome-border-soft)] bg-black/20 px-2 py-1.5 font-mono text-[10px] normal-case leading-relaxed tracking-normal text-[var(--scout-chrome-ink)]",disabled:Ne||Ee})]}),Te&&s.jsx("div",{className:"font-mono text-[10px] leading-relaxed text-red-300",children:Te}),De&&s.jsx("div",{className:"font-mono text-[10px] leading-relaxed text-lime-200",children:De}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>{Jn()},disabled:Ne||Ee||!rt.trim(),className:"flex items-center justify-center gap-2 rounded bg-lime-300/90 px-2.5 py-2 font-mono text-[10px] font-bold uppercase tracking-[0.12em] text-black transition-opacity disabled:cursor-not-allowed disabled:opacity-40",children:[(Ne||Ee)&&s.jsx(Kn,{size:13,className:"animate-spin"}),Ee?"Saving":"Save"]}),s.jsx("button",{type:"button",onClick:()=>{Tt()},disabled:Ne||Ee,className:"rounded border border-[var(--scout-chrome-border-soft)] px-2.5 py-2 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)] hover:bg-[var(--scout-chrome-hover)] disabled:cursor-not-allowed disabled:opacity-40",children:"Reload"})]})]})})]}),s.jsx("div",{className:"flex min-h-0 flex-1 flex-col px-3 pb-1.5",children:xe&&s.jsx(Wbe,{state:xe,chatExpanded:Ht,onToggleExpanded:()=>ie(W=>!W),sessionPickerOpen:ce,onToggleSessionPicker:()=>Ae(W=>!W),onSwitchSession:W=>{sr(W)},switchingSessionId:Be,sending:h,briefing:I,pendingAsk:h?B:null,onArchiveSession:W=>{so(W)},archivingSessionId:he,onAssistantContextMenu:Ct})}),s.jsxs("div",{className:"flex shrink-0 flex-col gap-1.5 border-t border-[var(--scout-chrome-border-soft)] bg-black/10 px-3 pt-2 pb-2.5",children:[y===!1&&s.jsx(Kbe,{issue:C,probeState:A,onLaunch:Es,onRetry:()=>{ps()},onSettings:va}),(Y||P)&&s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded border border-[var(--scout-chrome-border-soft)] bg-black/10 px-2.5 py-2 font-mono text-[10px] leading-relaxed text-[var(--scout-chrome-ink-faint)]",children:[s.jsx("span",{className:"min-w-0 truncate",children:P?"Speaking reply…":Y}),P&&s.jsx("button",{type:"button",title:"Stop spoken reply",onClick:Rt,className:"shrink-0 rounded border border-[var(--scout-chrome-border-soft)] p-1 text-[var(--scout-chrome-ink)] hover:bg-[var(--scout-chrome-hover)]",children:s.jsx(df,{size:11,className:"fill-current"})})]}),X&&!h&&s.jsx("div",{className:"font-mono text-[9px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-ghost)]",children:X}),s.jsx(qbe,{draft:u,onDraftChange:f,onSubmit:()=>{As(u)},sending:h,recording:Z,voiceLabel:nu,voiceBusy:G==="processing"||A==="probing"||A==="launching",voiceUnavailable:y===!1,onMicClick:()=>{if(y===!1){Es();return}Z?ir():fl()}}),x&&s.jsx("div",{className:"rounded border border-red-400/30 bg-red-400/10 px-2.5 py-2 font-mono text-[10px] leading-relaxed text-red-200",children:x})]})]})}const BI=new RegExp("(?:^|(?<=[\\s(`'\"<>]))(?:~\\/|\\/(?:Users|home|opt|var|etc|tmp|private)\\/)[^\\s)`'\"<>]+\\.[A-Za-z0-9]{1,8}\\b","g");function zbe(e){const t=[],n=new Set;BI.lastIndex=0;let r;for(;(r=BI.exec(e))!==null;)n.has(r[0])||(n.add(r[0]),t.push(r[0]));return t}function UI(e){const t=e.split("/").filter(Boolean);return t.length<=2?e:`…/${t.slice(-2).join("/")}`}function FI(){return{requesterName:"OpenScout",productName:"Scout Audio",headline:"Turn on local voice",body:"Scout Audio uses Vox for local speech capture and spoken replies. Start Vox, then return here to talk with your workspace.",actionLabel:"Return to OpenScout",logo:{url:new URL("/openscout-icon.png",window.location.href).toString(),symbolName:"sparkles"}}}function Bbe(e){const t=e.split(/\s+/).filter(Boolean).length;return Math.min(12e3,Math.max(3500,t*360))}function VI(e){return new Date(e).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}const Ube=5*6e4;function Fbe(e,t){return!e||!Lw(e.createdAt,t.createdAt)?!0:Math.abs(t.createdAt-e.createdAt)>=Ube}function Lw(e,t){const n=new Date(e),r=new Date(t);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate()}function Vbe(e){const t=new Date(e),n=new Date,r=new Date(n);r.setDate(n.getDate()-1);const a=t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return Lw(e,n.getTime())?`Today ${a}`:Lw(e,r.getTime())?`Yesterday ${a}`:t.getFullYear()===n.getFullYear()?`${t.toLocaleDateString([],{month:"short",day:"numeric"})} ${a}`:`${t.toLocaleDateString([],{month:"short",day:"numeric",year:"numeric"})} ${a}`}function Hbe(e){return new Promise(t=>window.setTimeout(t,e))}function Wbe({state:e,chatExpanded:t,onToggleExpanded:n,sessionPickerOpen:r,onToggleSessionPicker:a,onSwitchSession:o,switchingSessionId:c,sending:u,briefing:f,pendingAsk:h,onArchiveSession:p,archivingSessionId:x,onAssistantContextMenu:v}){const b=e.session.messages,C=t?b:b.slice(-4),E=t?0:Math.max(0,b.length-C.length),A=b.length,S=e.sessions.length,k=e.retention,N=e.session.createdAt?new Date(e.session.createdAt).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):null,T=e.session.title&&e.session.title!=="New Scout Session"?e.session.title:`Session ${e.session.id.slice(0,8)}`,R=m.useRef(null),O=b[b.length-1]?.id??null,L=b[b.length-1]?.body??"";return m.useEffect(()=>{const I=R.current;I&&(I.scrollTop=I.scrollHeight)},[O,L,h,u,t,e.session.id]),s.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col overflow-hidden rounded border border-[var(--scout-chrome-border-soft)] bg-black/10 font-mono text-[10px] text-[var(--scout-chrome-ink-faint)]",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-[var(--scout-chrome-border-soft)] px-2.5 py-1.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("span",{className:"min-w-0 truncate text-[var(--scout-chrome-ink)]",title:e.session.id,children:T}),N&&s.jsxs("span",{className:"shrink-0 text-[var(--scout-chrome-ink-ghost)]",children:["· ",N]}),s.jsxs("span",{className:"shrink-0 text-[var(--scout-chrome-ink-ghost)]",children:["· ",A," msg",A===1?"":"s"]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsxs("button",{type:"button",title:`Switch session (${S} total)`,"aria-label":"Switch session",onClick:a,className:`flex items-center gap-1 rounded border px-1.5 py-0.5 text-[9px] uppercase tracking-[0.1em] transition-colors ${r?"border-lime-300/40 bg-lime-300/10 text-lime-100":"border-[var(--scout-chrome-border-soft)] text-[var(--scout-chrome-ink-faint)] hover:bg-[var(--scout-chrome-hover)] hover:text-[var(--scout-chrome-ink)]"}`,children:[s.jsx(cB,{size:10}),s.jsx("span",{children:"Sessions"}),s.jsx("span",{className:"text-[var(--scout-chrome-ink-ghost)]",children:S}),s.jsx(Xo,{size:9,className:r?"rotate-180 transition-transform":"transition-transform"})]}),A>4&&s.jsxs("button",{type:"button",title:t?"Collapse chat":"View full session","aria-label":t?"Collapse chat":"View full session",onClick:n,className:"flex items-center gap-1 rounded border border-[var(--scout-chrome-border-soft)] px-1.5 py-0.5 text-[9px] uppercase tracking-[0.1em] text-[var(--scout-chrome-ink-faint)] transition-colors hover:bg-[var(--scout-chrome-hover)] hover:text-[var(--scout-chrome-ink)]",children:[s.jsx("span",{children:t?"Collapse":"Full"}),t?s.jsx(Ww,{size:9}):s.jsx(Xo,{size:9})]})]})]}),r&&s.jsxs("div",{className:"shrink-0 border-b border-[var(--scout-chrome-border-soft)] px-2 py-1.5",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 px-0.5 text-[9px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-ghost)]",children:[s.jsx("span",{children:"Recent sessions"}),k&&k.archivedCount>0&&s.jsxs("span",{children:[k.archivedCount," archived"]})]}),s.jsx("div",{className:"flex max-h-40 flex-col gap-0.5 overflow-y-auto pr-0.5",children:e.sessions.map(I=>{const z=I.id===e.session.id,_=c===I.id,U=x===I.id,D=new Date(I.updatedAt).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),q=I.title&&I.title!=="New Scout Session"?I.title:`Session ${I.id.slice(0,8)}`;return s.jsxs("div",{className:`flex items-center gap-2 rounded border px-2 py-1 text-left transition-colors ${z?"border-lime-300/40 bg-lime-300/[0.06] text-lime-100":"border-transparent text-[var(--scout-chrome-ink-faint)] hover:border-[var(--scout-chrome-border-soft)] hover:bg-[var(--scout-chrome-hover)] hover:text-[var(--scout-chrome-ink)]"}`,children:[s.jsxs("button",{type:"button",onClick:()=>{z||o(I.id)},disabled:z||!!c||!!x,className:"flex min-w-0 flex-1 items-center gap-2 text-left disabled:cursor-not-allowed disabled:opacity-40",children:[s.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${z?"bg-lime-300":"bg-[var(--scout-chrome-ink-ghost)]"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[10px] text-[var(--scout-chrome-ink)]",children:q}),s.jsxs("span",{className:"shrink-0 text-[9px] text-[var(--scout-chrome-ink-ghost)]",children:[I.messageCount," msg"]}),s.jsx("span",{className:"shrink-0 text-[9px] text-[var(--scout-chrome-ink-ghost)]",children:D}),_&&s.jsx(Kn,{size:10,className:"shrink-0 animate-spin text-lime-200"})]}),s.jsx("button",{type:"button",title:"Archive chat","aria-label":`Archive chat ${q}`,onClick:()=>p(I.id),disabled:!!c||!!x,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded border border-transparent text-[var(--scout-chrome-ink-ghost)] transition-colors hover:border-[var(--scout-chrome-border-soft)] hover:bg-black/20 hover:text-[var(--scout-chrome-ink)] disabled:cursor-not-allowed disabled:opacity-30",children:U?s.jsx(Kn,{size:10,className:"animate-spin"}):s.jsx(x6,{size:10})})]},I.id)})})]}),s.jsxs("div",{ref:R,className:"flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto px-2.5 py-2",children:[E>0&&s.jsxs("button",{type:"button",onClick:n,className:"self-start text-[9px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-ghost)] hover:text-[var(--scout-chrome-ink)]",children:["↑ ",E," earlier message",E===1?"":"s"]}),C.length===0&&!h&&s.jsx("p",{className:"text-[var(--scout-chrome-ink-ghost)]",children:"No messages yet — ask anything below."}),C.map((I,z)=>{const _=Fbe(C[z-1],I),U=Vbe(I.createdAt);return s.jsxs("div",{className:"flex flex-col gap-1",children:[_&&s.jsx("div",{className:"self-center rounded-full bg-white/[0.06] px-2.5 py-0.5 font-mono text-[9px] font-medium text-[var(--scout-chrome-ink-ghost)]",title:new Date(I.createdAt).toLocaleString(),"aria-label":U,children:U}),s.jsx(HI,{role:I.role,body:I.body,onContextMenu:I.role==="assistant"&&v?D=>v(D,I.body):void 0})]},I.id)}),h&&s.jsx(HI,{role:"user",body:h,pending:!0}),u&&!h&&s.jsx("p",{className:"text-[var(--scout-chrome-ink-ghost)]",children:"Reading the control plane…"}),f&&s.jsxs("div",{className:"flex items-center gap-2 rounded border border-lime-300/30 bg-lime-300/[0.06] px-2.5 py-2 font-mono text-[10px] leading-relaxed text-lime-100",children:[s.jsx(Kn,{size:12,className:"shrink-0 animate-spin text-lime-300","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex flex-col gap-0.5",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-[0.14em] text-lime-300",children:"Briefing"}),s.jsx("span",{className:"text-[var(--scout-chrome-ink)]",children:"Codex is reviewing the control-plane snapshot. Voice will pick up when it lands."})]})]})]})]})}function qbe({draft:e,onDraftChange:t,onSubmit:n,sending:r,recording:a,voiceLabel:o,voiceBusy:c,voiceUnavailable:u,onMicClick:f}){let h="Start talking";u&&(h="Launch Vox"),a&&(h="Stop talking"),c&&(h=o);const p=u||c||a;return s.jsxs("form",{className:"grid grid-cols-[auto_1fr_auto] gap-2",onSubmit:x=>{x.preventDefault(),n()},children:[s.jsxs("button",{type:"button",title:h,"aria-label":h,onClick:f,disabled:r||c,className:`flex items-center justify-center self-stretch rounded border transition-colors disabled:cursor-not-allowed disabled:opacity-40 ${a?"border-lime-300/50 bg-lime-300/10 text-lime-200":"border-[var(--scout-chrome-border-soft)] text-[var(--scout-chrome-ink-faint)] hover:bg-[var(--scout-chrome-hover)] hover:text-[var(--scout-chrome-ink)]"} ${p?"min-w-[7.5rem] gap-1.5 px-2.5 font-mono text-[10px] uppercase tracking-[0.12em]":"w-9"}`,children:[c?s.jsx(Kn,{size:13,className:"animate-spin"}):a?s.jsx(df,{size:12,className:"fill-current"}):s.jsx(Kw,{size:13}),p&&s.jsx("span",{className:"truncate",children:o})]}),s.jsx("textarea",{value:e,onChange:x=>t(x.target.value),placeholder:"Ask to inspect state or move the UI…",rows:2,className:"w-full resize-none rounded border border-[var(--scout-chrome-border-soft)] bg-black/20 px-2 py-1.5 font-mono text-[11px] leading-relaxed text-[var(--scout-chrome-ink)] placeholder:text-[var(--scout-chrome-ink-ghost)]",onKeyDown:x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),e.trim()&&!r&&n())}}),s.jsx("button",{type:"submit",title:"Send","aria-label":"Send",disabled:!e.trim()||r,className:"flex w-9 items-center justify-center self-stretch rounded bg-lime-300/90 px-0 text-black transition-opacity disabled:cursor-not-allowed disabled:opacity-40",children:r?s.jsx(Kn,{size:13,className:"animate-spin"}):s.jsx(XB,{size:13})})]})}function HI({role:e,body:t,pending:n=!1,onContextMenu:r}){const a=e==="user",o=a?t:gd(t),[c,u]=m.useState(!1),f=m.useCallback(()=>{Nn(o).then(()=>{u(!0),window.setTimeout(()=>u(!1),1200)}).catch(()=>{})},[o]);return s.jsxs("div",{className:"group flex flex-col gap-0.5",onContextMenu:r,children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:`text-[9px] uppercase tracking-[0.12em] ${a?"text-[var(--scout-chrome-ink-ghost)]":"text-lime-300"}`,children:[a?"You":"Reply",n&&" · sending"]}),s.jsx("button",{type:"button",title:c?"Copied":"Copy message","aria-label":c?"Copied message":"Copy message",disabled:n||!o.trim(),onClick:f,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded border border-[var(--scout-chrome-border-soft)] text-[var(--scout-chrome-ink-ghost)] opacity-70 transition hover:bg-[var(--scout-chrome-hover)] hover:text-[var(--scout-chrome-ink)] disabled:cursor-not-allowed disabled:opacity-20 group-hover:opacity-100",children:c?s.jsx(Dm,{size:11}):s.jsx(mg,{size:11})})]}),a?s.jsx("p",{className:`whitespace-pre-wrap break-words text-[11px] leading-relaxed text-[var(--scout-chrome-ink)] ${n?"opacity-60":""}`,children:o}):s.jsx("div",{className:n?"opacity-60":"",children:s.jsx(v5,{text:o})})]})}function WI({icon:e,title:t,onClick:n,disabled:r,active:a,badge:o}){return s.jsxs("button",{type:"button",title:t,"aria-label":t,onClick:n,disabled:r,className:`flex shrink-0 items-center gap-1 rounded border p-1 text-[10px] transition-colors disabled:cursor-not-allowed disabled:opacity-40 ${a?"border-lime-300/50 bg-lime-300/10 text-lime-200":"border-[var(--scout-chrome-border-soft)] text-[var(--scout-chrome-ink-faint)] hover:bg-[var(--scout-chrome-hover)] hover:text-[var(--scout-chrome-ink)]"}`,children:[e,o&&s.jsx("span",{className:"font-mono text-[8.5px] tracking-tight",children:o})]})}function Kbe({issue:e,probeState:t,onLaunch:n,onRetry:r,onSettings:a}){const o=t==="probing"||t==="launching";return s.jsxs("div",{className:"rounded border border-lime-300/25 bg-lime-300/[0.06] px-3 py-3 font-mono text-[10px] text-[var(--scout-chrome-ink)]",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(KC,{size:14,className:"mt-0.5 shrink-0 text-lime-300"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"uppercase tracking-[0.14em] text-lime-200",children:"Connect Vox"}),s.jsx("p",{className:"mt-1 leading-relaxed text-[var(--scout-chrome-ink-faint)]",children:"Start Vox, then retry once the menu bar icon is visible."}),e&&s.jsx("p",{className:"mt-2 break-words leading-relaxed text-[var(--scout-chrome-ink-ghost)]",children:e})]})]}),s.jsxs("div",{className:"mt-3 grid grid-cols-3 gap-2",children:[s.jsx(Bb,{icon:t==="launching"?s.jsx(Kn,{size:12,className:"animate-spin"}):s.jsx(KC,{size:12}),label:t==="launching"?"Opening":"Launch Vox",onClick:n,disabled:t==="probing",title:"Launch Vox"}),s.jsx(Bb,{icon:t==="probing"?s.jsx(Kn,{size:12,className:"animate-spin"}):s.jsx(zd,{size:12}),label:"Retry",onClick:r,disabled:o,title:"Check Vox again"}),s.jsx(Bb,{icon:s.jsx(gg,{size:12}),label:"Settings",onClick:a,disabled:t==="probing",title:"Open Vox settings"})]})]})}function Bb({icon:e,label:t,onClick:n,disabled:r,title:a}){return s.jsxs("button",{type:"button",title:a,onClick:n,disabled:r,className:"flex min-h-8 items-center justify-center gap-1.5 rounded border border-lime-300/20 px-2 text-[9px] uppercase tracking-[0.12em] text-lime-100 transition-colors hover:bg-lime-300/10 disabled:cursor-not-allowed disabled:opacity-45",children:[e,t]})}function Gbe(e){if(!Number.isFinite(e)||e<=0)return"0 B";const t=["B","KB","MB","GB"];let n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r++;return`${n>=10||r===0?n.toFixed(0):n.toFixed(1)} ${t[r]}`}function Ro(e){return new Intl.NumberFormat("en-US").format(e||0)}function Zbe(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):"unknown"}function Ub({text:e,query:t}){return s.jsx(s.Fragment,{children:V5(e,t).map((n,r)=>n.match?s.jsx("mark",{children:n.text},r):s.jsx("span",{children:n.text},r))})}function Ybe(e){return Number.isFinite(e)?e.toFixed(3):"0.000"}function Xbe(e){const t=Mf(e.query);if(t.length===0)return[];const n=a=>{const o=a.toLowerCase();return t.some(c=>o.includes(c.toLowerCase()))},r=[];return n(e.title)&&r.push("title"),n(e.snippet)&&r.push("indexed snippet"),e.preview?.records.some(a=>a.matched)&&r.push("source records"),r}function Qbe(e){return e.renderedText||e.summary||e.raw}function L4(e){return e.kind||e.role||e.type||"record"}function Jbe(e){const t=L4(e);return t==="assistant_turn"||t==="assistant"?"assistant":t==="user_turn"||t==="user"?"user":t==="system_record"||t==="system"?"system":t==="command_or_tool"||t==="tool_use"?"tool":t==="response_item"?"tool output":t}function qI(e){const t=L4(e);return t==="assistant"||t==="assistant_turn"||t==="user"||t==="user_turn"||t==="last-prompt"||t==="ai-title"?0:t==="system"||t==="system_record"?1:2}function e0e(){const{selectedKnowledgeHit:e,selectedKnowledgeQuery:t,clearKnowledgeHit:n,openFilePreview:r,navigate:a}=qe(),[o,c]=m.useState("preview"),[u,f]=m.useState(null),[h,p]=m.useState(null),[x,v]=m.useState(null),[y,b]=m.useState(!1),[C,E]=m.useState(!1),[A,S]=m.useState(null),k=e?B5(e):null,N=e?U5(e):null,T=e?Va(e,"project"):"",R=e?Va(e,"harness"):"",O=t.trim(),L=u?.activeJobs[0]??null,I=m.useMemo(()=>h?.records.filter(B=>B.matched).sort((B,Q)=>{const oe=qI(B)-qI(Q);return oe!==0?oe:(Q.matchCount??0)-(B.matchCount??0)}).slice(0,4)??[],[h]),z=e?Xbe({title:e.title,snippet:e.snippet,preview:h,query:O}):[],_=Mf(O),U=h?.records.find(B=>B.matched)?.index??k?.recordRange?.[0],D=Ik(k),q=F5(k),Z=m.useMemo(()=>[{label:"Collections",value:Ro(u?.readyCollections??0)},{label:"Chunks",value:Ro(u?.chunks??0)},{label:"Index",value:Gbe(u?.sqliteBytes??0)},{label:"Updated",value:u?Zbe(u.generatedAt):"loading"}],[u]),$=async()=>{try{S(null),f(await ue("/api/knowledge/status"))}catch(B){S(B instanceof Error?B.message:String(B))}};m.useEffect(()=>{$()},[]),m.useEffect(()=>{e&&c("preview")},[e?.id]),m.useEffect(()=>{let B=!1;return(async()=>{if(!e||!k){p(null);return}b(!0);try{S(null);const oe=await ue("/api/knowledge/source-preview",{method:"POST",body:JSON.stringify({sourceRef:k,contextRecords:4,maxRecords:80,q:O})});B||p(oe)}catch(oe){B||(p(null),S(oe instanceof Error?oe.message:String(oe)))}finally{B||b(!1)}})(),()=>{B=!0}},[e?.id,k?.recordRange?.[0],k?.recordRange?.[1],O]);const G=async(B=!1)=>{E(!0);try{S(null);const Q=await ue("/api/knowledge/sessions/index",{method:"POST",body:JSON.stringify({days:3,limit:260,force:B})});v(Q.result),f(Q.status),c("indexer")}catch(Q){S(Q instanceof Error?Q.message:String(Q))}finally{E(!1)}},V=async(B=!1)=>{E(!0);try{S(null);const Q=await ue("/api/knowledge/worktree/index",{method:"POST",body:JSON.stringify({force:B,includeUntracked:!0})});v(null),f(Q.status),c("indexer")}catch(Q){S(Q instanceof Error?Q.message:String(Q))}finally{E(!1)}},Y=()=>{k&&r(Ri(k.path))},K=()=>{const B=k??N;B&&r(Ri(B.path))},P=()=>{D&&a({view:"sessions",sessionId:D})},H=()=>{q&&a({view:"ops",mode:"tail",tailQuery:q})};return s.jsxs("div",{className:"ks-inspector",children:[s.jsxs("div",{className:"ks-inspector-tabs",role:"tablist","aria-label":"Search context",children:[s.jsxs("button",{type:"button",role:"tab","aria-selected":o==="preview",className:o==="preview"?"ks-inspector-tab active":"ks-inspector-tab",onClick:()=>c("preview"),children:[s.jsx(dy,{size:13,"aria-hidden":"true"}),"Preview"]}),s.jsxs("button",{type:"button",role:"tab","aria-selected":o==="indexer",className:o==="indexer"?"ks-inspector-tab active":"ks-inspector-tab",onClick:()=>c("indexer"),children:[s.jsx(GC,{size:13,"aria-hidden":"true"}),"Indexer"]})]}),A&&s.jsx("div",{className:"ks-inspector-error",role:"alert",children:A}),o==="preview"?s.jsx("section",{className:"ks-preview-panel","aria-label":"Selected search result preview",children:e?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"ks-preview-head",children:[s.jsxs("div",{children:[s.jsx("span",{className:"ks-panel-eyebrow",children:"Selected result"}),s.jsx("h2",{children:e.title})]}),s.jsx("button",{type:"button","aria-label":"Clear selected result",onClick:n,children:s.jsx(Bi,{size:14,"aria-hidden":"true"})})]}),s.jsxs("div",{className:"ks-preview-meta",children:[T&&s.jsx("span",{children:T}),R&&s.jsx("span",{children:R}),Va(e,"source")==="git_worktree"&&s.jsx("span",{children:"worktree diff"}),Va(e,"state")&&s.jsx("span",{children:Va(e,"state")}),k?.recordRange&&s.jsxs("span",{children:["records ",k.recordRange[0],"..",k.recordRange[1]]})]}),(D||q||k||N)&&s.jsxs("div",{className:"ks-preview-actions","aria-label":"Selected result actions",children:[D&&s.jsxs("button",{type:"button",onClick:P,children:[s.jsx(Xb,{size:13,"aria-hidden":"true"}),"Open session"]}),q&&s.jsxs("button",{type:"button",onClick:H,children:[s.jsx(E2,{size:13,"aria-hidden":"true"}),"Observe window"]}),(k||N)&&s.jsxs("button",{type:"button",onClick:K,children:[s.jsx(wr,{size:13,"aria-hidden":"true"}),"Open file"]})]}),I.length>0&&s.jsxs("section",{className:"ks-rendered-matches","aria-label":"Rendered message matches",children:[s.jsxs("div",{className:"ks-rendered-head",children:[s.jsx(Xb,{size:14,"aria-hidden":"true"}),s.jsx("strong",{children:"Rendered message hits"}),s.jsxs("span",{children:[I.length," source record",I.length===1?"":"s"]})]}),I.map(B=>s.jsxs("article",{className:"ks-rendered-record",children:[s.jsxs("header",{children:[s.jsx("span",{children:String(B.index).padStart(4,"0")}),s.jsx("strong",{children:Jbe(B)}),s.jsxs("em",{children:[B.matchCount??0," match",B.matchCount===1?"":"es"]})]}),s.jsx("p",{children:s.jsx(Ub,{text:Qbe(B),query:O})})]},`rendered:${B.index}`))]}),s.jsxs("section",{className:"ks-indexed-snippet","aria-label":"Indexed snippet",children:[s.jsx("span",{children:"Indexed snippet"}),s.jsx("p",{children:s.jsx(Ub,{text:e.snippet,query:O})})]}),s.jsxs("section",{className:"ks-rank-explainer","aria-label":"Why this result ranked here",children:[s.jsxs("div",{className:"ks-rendered-head",children:[s.jsx(GC,{size:14,"aria-hidden":"true"}),s.jsx("strong",{children:"Why ranked here"})]}),s.jsxs("div",{className:"ks-score-panel",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Index rank"}),s.jsx("strong",{children:Ybe(e.score)}),s.jsx("em",{children:"lower values sort earlier in lexical search"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Matched terms"}),s.jsx("strong",{children:_.length>0?_.join(", "):"none"}),s.jsx("em",{children:O?`query "${O}"`:"no active query captured"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Matched in"}),s.jsx("strong",{children:z.length>0?z.join(", "):"indexed chunk"}),s.jsx("em",{children:e.scoreSource==="fts"?"lexical index over QMD title/body":`${e.scoreSource} over QMD title/body`})]})]})]}),k&&s.jsxs("div",{className:"ks-preview-source",children:[s.jsx("span",{children:"Transcript"}),s.jsx("code",{children:Ri(k.path)}),s.jsxs("button",{type:"button",onClick:Y,children:[s.jsx(wr,{size:13,"aria-hidden":"true"}),"Open file"]})]}),!k&&N&&s.jsxs("div",{className:"ks-preview-source",children:[s.jsx("span",{children:"Source file"}),s.jsx("code",{children:Ri(N.path)}),s.jsxs("button",{type:"button",onClick:K,children:[s.jsx(wr,{size:13,"aria-hidden":"true"}),"Open file"]})]}),y?s.jsxs("div",{className:"ks-preview-loading",children:[s.jsx(Kn,{size:15,className:"ks-spin","aria-hidden":"true"}),"Loading source records..."]}):h?s.jsxs("div",{className:"ks-jsonl-window",children:[s.jsxs("div",{className:"ks-jsonl-window-head",children:[s.jsx("strong",{children:"Raw JSONL evidence"}),s.jsxs("span",{children:["records ",h.previewRange[0],"..",h.previewRange[1],h.truncatedBefore?" · earlier records hidden":"",h.truncatedAfter?" · later records hidden":""]})]}),h.records.map(B=>s.jsxs("details",{className:`ks-jsonl-record${B.matched?" ks-jsonl-record--matched":""}`,open:B.index===U,children:[s.jsxs("summary",{children:[s.jsx("span",{children:String(B.index).padStart(4,"0")}),s.jsx("strong",{children:B.kind||B.role||B.type||"record"}),s.jsx("em",{children:s.jsx(Ub,{text:B.summary||"no summary",query:O})})]}),s.jsx("pre",{children:B.raw})]},`${h.path}:${B.index}`))]}):s.jsx("div",{className:"ks-inspector-empty",children:s.jsx("span",{children:"No JSONL preview is available for this result."})})]}):s.jsxs("div",{className:"ks-inspector-empty",children:[s.jsx(dy,{size:18,"aria-hidden":"true"}),s.jsx("strong",{children:"Select a result"}),s.jsx("span",{children:"Click a search result to inspect its QMD chunk, source record window, and raw JSONL evidence here."})]})}):s.jsxs("section",{className:"ks-indexer-panel","aria-label":"Session indexer",children:[s.jsxs("div",{className:"ks-preview-head",children:[s.jsxs("div",{children:[s.jsx("span",{className:"ks-panel-eyebrow",children:"Indexer"}),s.jsx("h2",{children:"Three-day session pipeline"})]}),s.jsx("button",{type:"button","aria-label":"Refresh index status",onClick:()=>{$()},children:s.jsx(zd,{size:14,"aria-hidden":"true"})})]}),s.jsxs("div",{className:"ks-indexer-actions",children:[s.jsxs("button",{type:"button",className:"ks-primary-button",onClick:()=>{G(!1)},disabled:C,children:[C?s.jsx(Kn,{size:14,className:"ks-spin","aria-hidden":"true"}):s.jsx(Ei,{size:14,"aria-hidden":"true"}),"Build 3-day index"]}),s.jsxs("button",{type:"button",className:"ks-primary-button",onClick:()=>{V(!0)},disabled:C,children:[C?s.jsx(Kn,{size:14,className:"ks-spin","aria-hidden":"true"}):s.jsx(dy,{size:14,"aria-hidden":"true"}),"Index worktree diffs"]}),s.jsxs("button",{type:"button",className:"ks-icon-button",onClick:()=>{G(!0)},disabled:C,children:[s.jsx(zd,{size:14,"aria-hidden":"true"}),"Rebuild"]})]}),s.jsx("div",{className:"ks-indexer-metrics",children:Z.map(B=>s.jsxs("div",{children:[s.jsx("span",{children:B.label}),s.jsx("strong",{children:B.value})]},B.label))}),s.jsxs("div",{className:"ks-indexer-facts",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Frequency"}),s.jsx("strong",{children:"Manual refresh"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Window"}),s.jsx("strong",{children:"Last 3 days, up to 260 sessions"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Embedding stage"}),s.jsx("strong",{children:"Optional next phase"})]})]}),s.jsxs("div",{className:"ks-pipeline-compact",children:[s.jsxs("div",{children:[s.jsx(Dm,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:"JSONL discovery"})]}),s.jsxs("div",{children:[s.jsx(Dm,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:"Mechanical QMD"})]}),s.jsxs("div",{children:[s.jsx(Dm,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:"SQLite FTS"})]}),s.jsxs("div",{children:[s.jsx(O6,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:"Embeddings optional"})]})]}),L&&s.jsxs("div",{className:"ks-job",children:[s.jsxs("strong",{children:[L.source," ",L.state]}),s.jsxs("span",{children:[Ro(L.progress.indexed??0)," indexed of ",Ro(L.progress.discovered??0)," discovered"]})]}),x&&s.jsxs("div",{className:"ks-job",children:[s.jsx("strong",{children:"Last run"}),s.jsxs("span",{children:[Ro(x.indexed)," indexed, ",Ro(x.failed)," failed, ",Ro(x.discovered)," discovered"]})]}),s.jsxs("div",{className:"ks-paths",children:[s.jsxs("div",{children:[s.jsx("span",{children:"QMD root"}),s.jsx("code",{children:u?.paths.qmdRoot??"not initialized"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"SQLite"}),s.jsx("code",{children:u?.paths.sqlitePath??"not initialized"})]})]})]})]})}function t0e({onResizeStart:e}){const t=m.useCallback(n=>{n.preventDefault(),e(n)},[e]);return s.jsxs("div",{role:"separator","aria-orientation":"horizontal",onMouseDown:t,className:"group relative flex h-[7px] shrink-0 cursor-ns-resize items-center justify-center",children:[s.jsx("div",{className:"absolute inset-x-0 top-0 h-px bg-[var(--scout-chrome-border-soft)] transition-colors group-hover:bg-[var(--scout-chrome-ink-faint)]"}),s.jsxs("div",{className:"flex flex-row gap-[3px] opacity-0 transition-opacity group-hover:opacity-100",children:[s.jsx("div",{className:"h-[3px] w-[3px] rounded-full bg-[var(--scout-chrome-ink-faint)]"}),s.jsx("div",{className:"h-[3px] w-[3px] rounded-full bg-[var(--scout-chrome-ink-faint)]"}),s.jsx("div",{className:"h-[3px] w-[3px] rounded-full bg-[var(--scout-chrome-ink-faint)]"})]})]})}const KI=180,n0e=.7,s0e=260;function Fb(e,t){const n=Math.max(KI,Math.floor(t*n0e));return Math.min(n,Math.max(KI,Math.round(e)))}function r0e(){const e=la("surface.scoutbot",!0),{route:t,navigate:n,agents:r,selectedBrokerAttempt:a,clearBrokerAttempt:o}=qe(),[c]=mw("openscout.scoutbot.collapsed",!0),[u,f]=Rk("openscout.scoutbot.height",s0e),h=m.useRef(null),[p,x]=m.useState(0);m.useLayoutEffect(()=>{const C=h.current;if(!C)return;x(C.getBoundingClientRect().height);const E=new ResizeObserver(A=>{const S=A[0];S&&x(S.contentRect.height)});return E.observe(C),()=>E.disconnect()},[]),m.useEffect(()=>{if(p<=0)return;const C=Fb(u,p);C!==u&&f(C)},[p,u,f]);const v=m.useCallback(C=>{const E=C.clientY,A=u,S=h.current?.getBoundingClientRect().height??p,k=T=>{const R=T.clientY-E;f(Fb(A-R,S))},N=()=>{document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",N),document.body.style.removeProperty("cursor"),document.body.style.removeProperty("user-select")};document.body.style.cursor="ns-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",k),document.addEventListener("mouseup",N)},[p,u,f]);let y=null;switch(t.view){case"inbox":case"fleet":y=s.jsx(Hye,{});break;case"agents":case"agent-info":y=s.jsx(wye,{});break;case"sessions":y=s.jsx(Kye,{});break;case"search":y=s.jsx(e0e,{});break;case"conversation":y=s.jsx(Vye,{});break;case"terminal":y=s.jsx(Zye,{});break;case"channels":y=s.jsx(b0e,{channelId:t.channelId,agents:r,navigate:n,returnRoute:t});break;case"work":y=s.jsx(Qye,{});break;case"mesh":y=s.jsx(ube,{});break;case"ops":y=s.jsx(A0e,{mode:t.mode??"mission",agents:r,navigate:n,returnRoute:t});break;case"broker":y=a?s.jsx(fde,{attempt:a,navigate:n,onClose:o}):s.jsx(c0e,{});break;default:y=null}const b=p>0?Fb(u,p):u;return s.jsxs("div",{ref:h,className:"flex h-full flex-col overflow-hidden",children:[s.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:y}),e&&!c&&s.jsx(t0e,{onResizeStart:v}),e&&s.jsx(Dbe,{height:c?void 0:b})]})}function a0e(e){return`${Math.round(e*100)}%`}function i0e(e){switch(e){case"success":return"sent";case"failed_query":return"query";case"failed_delivery":return"delivery";default:return"attempt"}}function o0e(e){switch(e){case"dm":return"direct";case"channel":return"channel";case"broadcast":return"broadcast";case null:return"no route";default:return e}}function l0e(e){const t=new Map;for(const n of e){const r=o0e(n.route);t.set(r,(t.get(r)??0)+1)}return[...t.entries()].map(([n,r])=>({label:n,count:r})).sort((n,r)=>r.count-n.count||n.label.localeCompare(r.label)).slice(0,5)}function c0e(){const{inspectBrokerAttempt:e}=qe(),[t,n]=m.useState(null),[r,a]=m.useState(null),o=m.useCallback(async()=>{try{const v=await ue("/api/broker?limit=160");n(v),a(null)}catch(v){a(v instanceof Error?v.message:String(v))}},[]);m.useEffect(()=>{o()},[o]),Vt(v=>{(v.kind==="message.posted"||v.kind==="delivery.planned"||v.kind==="delivery.attempted"||v.kind==="delivery.state.changed"||v.kind==="scout.dispatched")&&o()});const c=m.useMemo(()=>t?[...t.failedQueries,...t.failedDeliveries].sort((v,y)=>y.ts-v.ts).slice(0,4):[],[t]),u=m.useMemo(()=>t?t.attempts.slice().sort((v,y)=>y.ts-v.ts).slice(0,5):[],[t]),f=m.useMemo(()=>t?l0e([...t.attempts,...t.failedQueries,...t.failedDeliveries]):[],[t]),h=m.useCallback(v=>{e(v),window.dispatchEvent(new CustomEvent("scout:set-inspector-width",{detail:{width:420}}))},[e]);if(!t&&!r)return s.jsx("div",{className:"flex h-full flex-col overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:s.jsx(Vb,{title:"Dispatch context",status:"Loading broker ledger..."})});if(!t)return s.jsxs("div",{className:"flex h-full flex-col overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[s.jsx(Vb,{title:"Dispatch context",status:"Broker diagnostics unavailable"}),s.jsx("div",{className:"rounded border border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-hover)] p-2.5 text-[11px] leading-relaxed text-[var(--scout-chrome-ink-soft)]",children:r})]});const p=t.totals.failedDeliveries+t.totals.failedDeliveryAttempts,x=t.totals.successfulDispatches+t.totals.failedQueries+p;return s.jsxs("div",{className:"flex h-full flex-col overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[s.jsxs(Vb,{title:"Dispatch context",status:`${x} routes in window`,children:[s.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-1",children:[s.jsx(Hb,{label:"Sent",value:`${t.totals.successfulDispatches}`}),s.jsx(Hb,{label:"Query",value:`${t.totals.failedQueries}`}),s.jsx(Hb,{label:"Delivery",value:`${p}`})]}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 border-t border-[var(--scout-chrome-border-soft)] pt-2 font-mono text-[9px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-ghost)]",children:[s.jsxs("span",{children:[a0e(t.rates.failureRate)," failed"]}),s.jsx("span",{children:Ie(t.generatedAt)})]})]}),s.jsx(Wb,{label:"Route mix",children:s.jsx(u0e,{items:f,empty:"No route records visible"})}),s.jsx(Wb,{label:"Needs attention",children:c.length===0?s.jsx(Pw,{children:"No failed routes in this window."}):s.jsx("div",{className:"flex flex-col gap-1.5",children:c.map(v=>s.jsx(GI,{attempt:v,onOpen:h},v.id))})}),s.jsx(Wb,{label:"Recent dispatch",children:u.length===0?s.jsx(Pw,{children:"No recent dispatch rows."}):s.jsx("div",{className:"flex flex-col gap-1",children:u.map(v=>s.jsx(GI,{attempt:v,onOpen:h,compact:!0},v.id))})})]})}function Vb({title:e,status:t,children:n}){return s.jsxs("div",{className:"rounded border border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-hover)] p-2.5",children:[s.jsx("div",{className:"text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),s.jsx("div",{className:"mt-1 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-soft)]",children:t}),n]})}function Hb({label:e,value:t}){return s.jsxs("div",{className:"min-w-0 rounded-sm border border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-bg)] px-1.5 py-1",children:[s.jsx("div",{className:"font-mono text-[9px] uppercase tracking-[0.1em] text-[var(--scout-chrome-ink-faint)]",children:e}),s.jsx("div",{className:"mt-0.5 truncate font-mono text-[13px] text-[var(--scout-chrome-ink-strong)]",children:t})]})}function Wb({label:e,children:t}){return s.jsxs("div",{className:"flex flex-col",children:[s.jsx("div",{className:"mb-1.5 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),t]})}function u0e({items:e,empty:t}){return e.length===0?s.jsx(Pw,{children:t}):s.jsx("div",{className:"flex flex-wrap gap-1",children:e.map(n=>s.jsxs("span",{className:"rounded-sm border border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-hover)] px-1.5 py-0.5 font-mono text-[10px] text-[var(--scout-chrome-ink-soft)]",title:`${n.count} ${n.label}`,children:[n.label," ",n.count]},n.label))})}function Pw({children:e}){return s.jsx("div",{className:"text-[10px] font-mono uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-ghost)]",children:e})}function GI({attempt:e,onOpen:t,compact:n=!1}){return s.jsxs("button",{type:"button",className:"rounded border border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-hover)] px-2 py-1.5 text-left transition-colors hover:border-[var(--scout-chrome-border)]",onClick:()=>t(e),children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"shrink-0 rounded-sm bg-[var(--scout-chrome-bg)] px-1 py-0.5 font-mono text-[8px] uppercase tracking-[0.08em] text-[var(--scout-chrome-ink-faint)]",children:i0e(e.kind)}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] text-[var(--scout-chrome-ink)]",children:e.detail}),s.jsx("span",{className:"shrink-0 font-mono text-[9px] text-[var(--scout-chrome-ink-faint)]",children:Ie(e.ts)})]}),!n&&s.jsxs("div",{className:"mt-0.5 flex items-center gap-2 font-mono text-[9px] text-[var(--scout-chrome-ink-ghost)]",children:[s.jsx("span",{className:"truncate",children:e.actorName??"unknown"}),s.jsx("span",{className:"shrink-0",children:"->"}),s.jsx("span",{className:"truncate",children:e.target??"none"})]})]})}const d0e=new Set(["completed","failed","cancelled"]);function f0e(e){return e.startsWith("channel.")?`#${e.slice(8)}`:e.startsWith("dm.")?"Direct message":e}function h0e(e,t){return e&&typeof e=="object"&&!Array.isArray(e)?e[t]:void 0}function cg(e,t){const n=h0e(e,t);return typeof n=="string"&&n.trim()?n.trim():null}function P4(e,t,n){return t?.trim()?t.trim():(e?n.find(a=>a.id===e):null)?.name??e??"Unassigned"}function Jk(e){return cg(e.input,"task")??cg(e.input,"action")}function ug(e){return cg(e.output,"summary")??cg(e.output,"text")}function Dw(e){return!d0e.has(e.state)}function m0e(e){return e.updatedAt??e.completedAt??e.startedAt??e.createdAt??Date.now()}function p0e(e){return e.replace(/_/g," ")}function g0e(e){if(e.workId)return{view:"work",workId:e.workId};const t=e.flightIds?.[0]??null;return t?{view:"follow",flightId:t,preferredView:"chat"}:e.invocationId?{view:"follow",invocationId:e.invocationId,preferredView:"chat"}:null}function v0e(e,t){const n=e.nextMoveOwnerId??e.ownerId,r=P4(n,e.nextMoveOwnerName??e.ownerName,t),a=e.activeFlightCount>0?`${e.activeFlightCount} active flight${e.activeFlightCount===1?"":"s"}`:null;return{id:`work:${e.id}`,kind:"work",actorId:n,actorName:r,status:a??e.currentPhase,title:e.title,detail:e.lastMeaningfulSummary??e.summary,updatedAt:e.lastMeaningfulAt||e.updatedAt,active:!0,route:{view:"work",workId:e.id}}}function x0e(e,t){const n=Dw(e),r=ug(e);return{id:`run:${e.id}`,kind:"run",actorId:e.agentId,actorName:P4(e.agentId,e.agentName,t),status:p0e(e.state),title:Jk(e)??r??"Agent run",detail:n?r:null,updatedAt:m0e(e),active:n,route:g0e(e)}}function y0e(e,t,n){const r=new Set(e.map(f=>f.id)),a=e.map(f=>v0e(f,n)),o=t.filter(f=>Dw(f)),c=t.filter(f=>!Dw(f)).slice(0,6),u=[...o,...c].filter(f=>!f.workId||!r.has(f.workId)).map(f=>x0e(f,n));return[...a,...u].sort((f,h)=>f.active!==h.active?f.active?-1:1:h.updatedAt-f.updatedAt).slice(0,12)}function b0e({channelId:e,agents:t,navigate:n,returnRoute:r}){const[a,o]=m.useState([]),[c,u]=m.useState([]),[f,h]=m.useState(!1),p=m.useCallback(async()=>{if(!e){h(!0),o([]),u([]);return}try{const[b,C]=await Promise.all([ue(`/api/work?conversationId=${encodeURIComponent(e)}&active=true&limit=12`),ue(`/api/runs?conversationId=${encodeURIComponent(e)}&active=false&limit=24`)]);o(b),u(C),h(!0)}catch{h(!0)}},[e]);m.useEffect(()=>{h(!1),p()},[p]),Vt(b=>{if(e){if(b.kind==="message.posted"){b.payload?.message?.conversationId===e&&p();return}(b.kind==="invocation.requested"||b.kind==="flight.updated"||b.kind==="collaboration.event.appended")&&p()}});const x=m.useMemo(()=>y0e(a,c,t),[a,c,t]),v=x.filter(b=>b.active),y=x.filter(b=>!b.active);return e?s.jsxs("div",{className:"ctx-panel ctx-panel--channel",children:[s.jsxs("section",{className:"ctx-panel-section ctx-panel-channel-summary",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Channel"}),s.jsxs("div",{className:"ctx-panel-channel-card",children:[s.jsx("span",{className:"ctx-panel-hash",children:"#"}),s.jsxs("div",{className:"ctx-panel-body",children:[s.jsx("span",{className:"ctx-panel-name",children:f0e(e)}),s.jsx("span",{className:"ctx-panel-preview",children:f?`${x.length} related item${x.length===1?"":"s"}`:"Loading context"})]})]})]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsxs("div",{className:"ctx-panel-section-label",children:["Doing",s.jsx("span",{className:"ctx-panel-count",children:v.length})]}),v.length===0?s.jsx("div",{className:"ctx-panel-empty",children:"No active channel work"}):s.jsx("div",{className:"ctx-panel-list",children:v.map(b=>s.jsx(ZI,{item:b,navigate:n,returnRoute:r},b.id))})]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsxs("div",{className:"ctx-panel-section-label",children:["Recent",s.jsx("span",{className:"ctx-panel-count",children:y.length})]}),y.length===0?s.jsx("div",{className:"ctx-panel-empty",children:f?"No recent channel runs":"Loading context"}):s.jsx("div",{className:"ctx-panel-list ctx-panel-list--scroll",children:y.map(b=>s.jsx(ZI,{item:b,navigate:n,returnRoute:r},b.id))})]})]}):s.jsx("div",{className:"ctx-panel ctx-panel--empty",children:s.jsx("div",{className:"ctx-panel-empty-state",children:s.jsx("div",{className:"ctx-panel-empty-hint",children:"Select a channel to see related work."})})})}function ZI({item:e,navigate:t,returnRoute:n}){const r=s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"ctx-panel-avatar",style:{background:Xt(e.actorName)},children:e.actorName[0]?.toUpperCase()??"?"}),s.jsxs("div",{className:"ctx-panel-body",children:[s.jsx("span",{className:"ctx-panel-name",children:e.actorName}),s.jsxs("span",{className:"ctx-panel-sub",children:[e.kind," · ",e.status]}),s.jsx("span",{className:"ctx-panel-preview",children:e.title}),e.detail&&s.jsx("span",{className:"ctx-panel-preview",children:e.detail})]}),s.jsxs("div",{className:"ctx-panel-trailing",children:[s.jsx("span",{className:"ctx-panel-time",children:Ie(e.updatedAt)}),e.active&&s.jsx("span",{className:"ctx-panel-dot"})]})]});return e.route?s.jsx("button",{type:"button",className:["ctx-panel-item","ctx-panel-channel-item",e.active&&"ctx-panel-item--active"].filter(Boolean).join(" "),onClick:()=>wt(t,e.route,{returnTo:n}),children:r}):s.jsx("div",{className:"ctx-panel-item ctx-panel-channel-item",children:r})}const w0e={mission:"Control",plan:"Plans",issues:"Alerts",tail:"Tail",atop:"Runtime",agents:"Agents"},j0e={blocked:"blocked",completed:"done",in_progress:"active",pending:"todo",unknown:"step"},k0e={blocked:"!",completed:"x",in_progress:">",pending:" ",unknown:"-"};function D4(e){const t=e.replace(/\\/g,"/").replace(/\/+$/g,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function N0e(e,t=180){const n=e.replace(/\s+/g," ").trim();return n.length<=t?n:`${n.slice(0,Math.max(0,t-1)).trimEnd()}...`}function YI(e){return e.toLowerCase().replace(/[^a-z0-9_/-]+/g," ").split(/\s+/).map(t=>t.trim()).filter(t=>t.length>=4).filter(t=>!["plan","plans","todo","work","task","docs","markdown"].includes(t)).slice(0,8)}function yd(e,t){const n=t.filter(Boolean).join(" ").toLowerCase();if(!n)return 0;const r=e.path.toLowerCase(),a=D4(r).toLowerCase(),o=e.title.toLowerCase();let c=0;r&&n.includes(r)&&(c+=8),a&&n.includes(a)&&(c+=6),o.length>8&&n.includes(o)&&(c+=6);for(const u of e.tags)u.length>=3&&n.includes(u.toLowerCase())&&(c+=2);for(const u of YI(e.title))n.includes(u)&&(c+=1);for(const u of e.steps.slice(0,8))for(const f of YI(u.text).slice(0,3))n.includes(f)&&(c+=1);return c}function S0e(e,t){let n=yd(e,[t.id,t.title,t.preview,t.agentName,t.harness,t.harnessSessionId,t.harnessLogPath,t.currentBranch,t.workspaceRoot,t.participantIds.join(" ")]);return e.agentId&&t.agentId===e.agentId&&(n+=4),e.agentName&&t.agentName&&e.agentName===t.agentName&&(n+=2),e.workspaceName&&t.workspaceRoot&&D4(t.workspaceRoot).toLowerCase()===e.workspaceName.toLowerCase()&&(n+=3),n}function C0e(e){const t=new Map;for(const n of e)if(n.status==="fulfilled")for(const r of n.value)t.set(r.id,r);return[...t.values()]}function E0e(e,t){if(!e)return{asks:[],runs:[],sessions:[],workItems:[],attention:[]};const n=6,r=[...t.fleet?.activeAsks??[],...t.fleet?.recentCompleted??[]].filter(p=>yd(e,[p.task,p.summary,p.agentName,p.collaborationRecordId])>=n).slice(0,8),a=t.runs.filter(p=>yd(e,[Jk(p),ug(p),p.agentName,p.workId,p.collaborationRecordId])>=n).slice(0,8),o=t.workItems.filter(p=>yd(e,[p.title,p.summary,p.lastMeaningfulSummary,p.parentTitle,p.ownerName,p.nextMoveOwnerName])>=n).slice(0,8),c=(t.fleet?.needsAttention??[]).filter(p=>yd(e,[p.title,p.summary,p.agentName])>=n).slice(0,6),u=new Set,f=new Set;for(const p of r)p.conversationId&&u.add(p.conversationId);for(const p of a){p.conversationId&&u.add(p.conversationId);for(const x of p.traceSessionIds??[])f.add(x)}for(const p of o)p.conversationId&&u.add(p.conversationId);for(const p of c)p.conversationId&&u.add(p.conversationId);const h=t.sessions.filter(p=>u.has(p.id)||(p.harnessSessionId?f.has(p.harnessSessionId):!1)||S0e(e,p)>=n).slice(0,8);return{asks:r,runs:a,sessions:h,workItems:o,attention:c}}function A0e({mode:e,agents:t,navigate:n,returnRoute:r}){const[a,o]=m.useState(null),[c,u]=m.useState(()=>typeof window>"u"?null:QI(window.scoutOpsDetailSnapshot)),f=m.useCallback(async()=>{const b=await ue("/api/fleet").catch(()=>null);o(b)},[]);if(m.useEffect(()=>{f()},[f]),m.useEffect(()=>{const b=C=>{u(QI(C.detail))};return window.addEventListener("scout:ops-detail",b),()=>window.removeEventListener("scout:ops-detail",b)},[]),Vt(b=>{(b.kind==="message.posted"||b.kind==="flight.updated"||b.kind==="collaboration.event.appended")&&f()}),e==="plan")return s.jsx(R0e,{navigate:n,returnRoute:r});if(e==="tail"||e==="issues")return s.jsx(M0e,{detail:c?.source==="tail"?c:null,mode:e,navigate:n});const h=(a?.activeAsks??[]).filter(b=>b.status!=="needs_attention"),p=a?.needsAttention??[],x=t.filter(b=>Ge(b.state)==="working"),v=t.filter(b=>Ge(b.state)!=="not_ready"),y=[...t].sort((b,C)=>(C.updatedAt??0)-(b.updatedAt??0)).slice(0,7);return s.jsxs("div",{className:"ctx-panel ctx-panel--ops-inspector",children:[c&&s.jsxs("section",{className:"ctx-panel-section ctx-panel-selected-detail",children:[s.jsx("div",{className:"ctx-panel-section-label",children:c.focus==="flow"?"Message":"Selection"}),s.jsxs("div",{className:"ctx-panel-selected-card",children:[s.jsx("div",{className:"ctx-panel-selected-title",children:c.title}),s.jsx("div",{className:"ctx-panel-selected-meta",children:c.meta}),s.jsx("div",{className:"ctx-panel-selected-body",children:c.body}),c.action&&s.jsx("button",{type:"button",className:"ctx-panel-selected-action",onClick:()=>n(c.action.route),children:c.action.label})]})]}),s.jsxs("section",{className:"ctx-panel-section ctx-panel-ops-summary",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Ops Context"}),s.jsxs("div",{className:"ctx-panel-ops-mode-card",children:[s.jsx("span",{children:"Current"}),s.jsx("strong",{children:w0e[e]}),s.jsx("small",{children:a?`${Ie(a.generatedAt)} refresh`:"loading"})]}),s.jsxs("div",{className:"ctx-panel-stat-grid",children:[s.jsx(_m,{label:"Needs",value:p.length,tone:p.length>0?"warn":"ok"}),s.jsx(_m,{label:"Active",value:h.length}),s.jsx(_m,{label:"Online",value:`${v.length}/${t.length}`}),s.jsx(_m,{label:"Working",value:x.length})]})]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsxs("div",{className:"ctx-panel-section-label",children:["Queue",p.length>0&&s.jsx("span",{className:"ctx-panel-count",children:p.length})]}),p.length===0?s.jsx("div",{className:"ctx-panel-empty",children:"No operator cues"}):s.jsx("div",{className:"ctx-panel-list",children:p.slice(0,5).map(b=>s.jsx($0e,{item:b,navigate:n},b.recordId))})]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsxs("div",{className:"ctx-panel-section-label",children:["Runs",h.length>0&&s.jsx("span",{className:"ctx-panel-count",children:h.length})]}),h.length===0?s.jsx("div",{className:"ctx-panel-empty",children:"No active asks"}):s.jsx("div",{className:"ctx-panel-list",children:h.slice(0,5).map(b=>s.jsx(L0e,{ask:b,navigate:n},b.invocationId))})]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Agent Pulse"}),s.jsx("div",{className:"ctx-panel-pulse-list",children:y.map(b=>s.jsxs("button",{type:"button",className:"ctx-panel-pulse-row",onClick:()=>Ka(n,b,{returnTo:r}),children:[s.jsx("span",{className:`ctx-panel-pulse-dot ctx-panel-pulse-dot--${ll(b.state)}`}),s.jsx("span",{children:b.name}),s.jsxs("small",{children:[cs(b.state)," · ",b.updatedAt?Ie(b.updatedAt):"unknown"]})]},b.id))})]})]})}function T0e(){if(typeof window>"u")return;const e=window;e.scoutOpsDetailSnapshot=null,window.dispatchEvent(new CustomEvent("scout:ops-detail",{detail:null}))}function M0e({detail:e,mode:t,navigate:n}){const r=t==="issues"?"Alert detail":"Tail detail",a=e?.copy?.find(c=>c.label==="Copy message")?.value??e?.body??"",o=e?.copy?.find(c=>c.label==="Copy metadata")?.value??e?.metadata?.map(c=>`${c.label}: ${c.value}`).join(`
184
- `)??"";return s.jsx("div",{className:"ctx-panel ctx-panel--ops-inspector ctx-panel--tail-inspector",children:s.jsxs("section",{className:"ctx-panel-section ctx-panel-tail-detail",children:[s.jsxs("div",{className:"ctx-panel-section-label ctx-panel-tail-detail-label",children:[s.jsx("span",{children:r}),e&&s.jsx("button",{type:"button",className:"ctx-panel-tail-icon-button",onClick:T0e,"aria-label":"Clear Tail detail",title:"Clear",children:s.jsx(Bi,{size:13,strokeWidth:2,"aria-hidden":"true"})})]}),e?s.jsxs("div",{className:"ctx-panel-tail-card",children:[s.jsxs("div",{className:"ctx-panel-tail-card-head",children:[s.jsx("div",{className:"ctx-panel-tail-card-title",children:e.title}),s.jsx("div",{className:"ctx-panel-tail-card-meta",children:e.meta})]}),e.metadata&&e.metadata.length>0&&s.jsxs("div",{className:"ctx-panel-tail-copy-scope",children:[s.jsx("dl",{className:"ctx-panel-tail-metadata",children:e.metadata.map(c=>s.jsxs("div",{className:"ctx-panel-tail-metadata-row",children:[s.jsx("dt",{children:c.label}),s.jsx("dd",{title:c.value,children:c.value})]},c.label))}),o&&s.jsx(XI,{label:"Copy metadata",value:o})]}),e.action&&s.jsx("div",{className:"ctx-panel-tail-actions",children:s.jsx("button",{type:"button",className:"ctx-panel-tail-action-button",onClick:()=>n(e.action.route),children:e.action.label})}),s.jsxs("div",{className:"ctx-panel-tail-copy-scope ctx-panel-tail-copy-scope--message",children:[s.jsx("div",{className:"ctx-panel-tail-message",children:e.body}),a&&s.jsx(XI,{label:"Copy message",value:a})]})]}):s.jsxs("div",{className:"ctx-panel-tail-empty-card",children:[s.jsx("span",{children:"Tail"}),s.jsx("strong",{children:"No log selected"})]})]})})}function XI({label:e,value:t}){const[n,r]=m.useState(!1),a=m.useRef(null);m.useEffect(()=>()=>{a.current!=null&&window.clearTimeout(a.current)},[]);const o=m.useCallback(async()=>{await Nn(t)&&(r(!0),a.current!=null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>r(!1),1200))},[t]);return s.jsxs("button",{type:"button",className:`ctx-panel-tail-hover-copy${n?" ctx-panel-tail-hover-copy--copied":""}`,onClick:()=>{o()},title:e,children:[n?s.jsx(fg,{size:13,strokeWidth:2,"aria-hidden":"true"}):s.jsx(mg,{size:13,strokeWidth:1.9,"aria-hidden":"true"}),s.jsx("span",{children:n?"Copied":e})]})}function R0e({navigate:e,returnRoute:t}){const[n,r]=m.useState(null),[a,o]=m.useState(null),[c,u]=m.useState([]),[f,h]=m.useState([]),[p,x]=m.useState([]),[v,y]=m.useState(!1),b=t.view==="ops"&&t.mode==="plan"?t.planDocumentId:void 0,C=m.useCallback(async()=>{const[N,T,R,O,L,I]=await Promise.allSettled([ue("/api/plan-documents"),ue("/api/fleet"),ue("/api/work?limit=250"),ue("/api/work?active=false&limit=250"),ue("/api/runs?active=false&limit=500"),ue("/api/conversations?limit=250")]);N.status==="fulfilled"&&r(N.value),T.status==="fulfilled"&&o(T.value),(R.status==="fulfilled"||O.status==="fulfilled")&&u(C0e([R,O])),L.status==="fulfilled"&&h(L.value),I.status==="fulfilled"&&x(I.value),y(!0)},[]);m.useEffect(()=>{y(!1),C()},[C]),Vt(N=>{(N.kind==="message.posted"||N.kind==="flight.updated"||N.kind==="collaboration.event.appended")&&C()});const E=n?.documents??[],A=m.useMemo(()=>E.find(N=>N.id===b)??E[0]??null,[E,b]),S=m.useMemo(()=>E0e(A,{fleet:a,runs:f,sessions:p,workItems:c}),[a,f,A,p,c]),k=S.attention.length+S.workItems.length+S.asks.length+S.runs.length+S.sessions.length;return A?s.jsxs("div",{className:"ctx-panel ctx-panel--ops-inspector ctx-panel--plan-inspector",children:[s.jsxs("section",{className:"ctx-panel-section ctx-panel-plan-summary",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Plan Context"}),s.jsxs("div",{className:"ctx-panel-plan-card",children:[s.jsx("span",{children:"Current"}),s.jsx("strong",{children:A.title}),s.jsxs("small",{children:[A.path," · ",Ie(A.updatedAt)]}),A.summary&&s.jsx("p",{children:A.summary})]})]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsxs("div",{className:"ctx-panel-section-label",children:["Steps",s.jsx("span",{className:"ctx-panel-count",children:A.steps.length})]}),A.steps.length===0?s.jsx("div",{className:"ctx-panel-empty",children:"No checklist steps parsed"}):s.jsx("div",{className:"ctx-panel-plan-step-list",children:A.steps.map(N=>s.jsxs("div",{className:`ctx-panel-plan-step ctx-panel-plan-step--${N.status}`,children:[s.jsx("span",{className:"ctx-panel-plan-step-marker",children:k0e[N.status]}),s.jsx("span",{className:"ctx-panel-plan-step-text",children:N.text}),s.jsx("span",{className:"ctx-panel-plan-step-state",children:j0e[N.status]})]},N.id))})]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsxs("div",{className:"ctx-panel-section-label",children:["Around This Plan",s.jsx("span",{className:"ctx-panel-count",children:k})]}),k===0?s.jsx("div",{className:"ctx-panel-empty",children:"No nearby activity matched yet"}):null]}),s.jsx(ld,{title:"Sessions",count:S.sessions.length,children:S.sessions.map(N=>s.jsx("button",{type:"button",className:"ctx-panel-item ctx-panel-plan-context-item",onClick:()=>wt(e,{view:"conversation",conversationId:N.id},{returnTo:t}),children:s.jsxs("div",{className:"ctx-panel-body",children:[s.jsx("span",{className:"ctx-panel-name",children:N.title||N.agentName||N.id}),s.jsxs("span",{className:"ctx-panel-sub",children:[N.kind," · ",N.agentName??N.harness??"session"," · ",N.messageCount," msg"]}),s.jsx("span",{className:"ctx-panel-preview",children:N.preview?.trim()||N.workspaceRoot||N.id})]})},N.id))}),s.jsx(ld,{title:"Work Items",count:S.workItems.length,children:S.workItems.map(N=>s.jsx("button",{type:"button",className:"ctx-panel-item ctx-panel-plan-context-item",onClick:()=>wt(e,{view:"work",workId:N.id},{returnTo:t}),children:s.jsxs("div",{className:"ctx-panel-body",children:[s.jsx("span",{className:"ctx-panel-name",children:N.title}),s.jsxs("span",{className:"ctx-panel-sub",children:[N.currentPhase||N.state," · ",Ie(N.lastMeaningfulAt||N.updatedAt)]}),(N.summary||N.lastMeaningfulSummary)&&s.jsx("span",{className:"ctx-panel-preview",children:N.summary??N.lastMeaningfulSummary})]})},N.id))}),s.jsx(ld,{title:"Runs",count:S.runs.length,children:S.runs.map(N=>s.jsx("button",{type:"button",className:"ctx-panel-item ctx-panel-plan-context-item",onClick:()=>e(_0e(N)),children:s.jsxs("div",{className:"ctx-panel-body",children:[s.jsx("span",{className:"ctx-panel-name",children:N0e(Jk(N)??N.agentName??N.id,120)}),s.jsxs("span",{className:"ctx-panel-sub",children:[N.agentName??N.agentId," · ",N.state," · ",Ie(N.updatedAt)]}),ug(N)&&s.jsx("span",{className:"ctx-panel-preview",children:ug(N)})]})},N.id))}),s.jsx(ld,{title:"Asks",count:S.asks.length,children:S.asks.map(N=>s.jsx("button",{type:"button",className:"ctx-panel-item ctx-panel-plan-context-item",onClick:()=>e(I0e(N)),children:s.jsxs("div",{className:"ctx-panel-body",children:[s.jsx("span",{className:"ctx-panel-name",children:N.task}),s.jsxs("span",{className:"ctx-panel-sub",children:[N.agentName??N.agentId," · ",N.statusLabel," · ",Ie(N.updatedAt)]}),N.summary&&s.jsx("span",{className:"ctx-panel-preview",children:N.summary})]})},N.invocationId))}),s.jsx(ld,{title:"Attention",count:S.attention.length,children:S.attention.map(N=>{const T=O0e(N);return s.jsx("button",{type:"button",className:"ctx-panel-item ctx-panel-item--attention ctx-panel-plan-context-item",onClick:()=>T&&e(T),disabled:!T,children:s.jsxs("div",{className:"ctx-panel-body",children:[s.jsx("span",{className:"ctx-panel-name",children:N.title}),s.jsxs("span",{className:"ctx-panel-sub",children:[N.kind," · ",Ie(N.updatedAt)]}),N.summary&&s.jsx("span",{className:"ctx-panel-preview",children:N.summary})]})},N.recordId)})})]}):s.jsx("div",{className:"ctx-panel ctx-panel--ops-inspector ctx-panel--plan-inspector",children:s.jsxs("section",{className:"ctx-panel-section ctx-panel-ops-summary",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Plan Context"}),s.jsx("div",{className:"ctx-panel-empty",children:v?"No plan document selected":"Indexing plan documents"})]})})}function ld({title:e,count:t,children:n}){return s.jsxs("section",{className:"ctx-panel-section",children:[s.jsxs("div",{className:"ctx-panel-section-label",children:[e,s.jsx("span",{className:"ctx-panel-count",children:t})]}),t===0?s.jsx("div",{className:"ctx-panel-empty",children:"None matched"}):s.jsx("div",{className:"ctx-panel-list",children:n})]})}function I0e(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.collaborationRecordId?{view:"work",workId:e.collaborationRecordId}:{view:"agents",agentId:e.agentId}}function _0e(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.workId?{view:"work",workId:e.workId}:{view:"agents",agentId:e.agentId}}function O0e(e){return e.recordId?{view:"work",workId:e.recordId}:e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.agentId?{view:"agents",agentId:e.agentId}:null}function _m({label:e,value:t,tone:n}){return s.jsxs("div",{className:`ctx-panel-stat${n?` ctx-panel-stat--${n}`:""}`,children:[s.jsx("span",{children:e}),s.jsx("strong",{children:t})]})}function QI(e){if(!e||typeof e!="object")return null;const t=e;if(t.focus!=="flow"&&t.focus!=="item"||typeof t.title!="string"||typeof t.meta!="string"||typeof t.body!="string")return null;const n=Array.isArray(t.metadata)?t.metadata.filter(a=>a!=null&&typeof a=="object"&&typeof a.label=="string"&&typeof a.value=="string"):void 0,r=Array.isArray(t.copy)?t.copy.filter(a=>a!=null&&typeof a=="object"&&typeof a.label=="string"&&typeof a.value=="string"):void 0;return{source:t.source==="tail"?"tail":"generic",focus:t.focus,title:t.title,meta:t.meta,body:t.body,metadata:n,copy:r,action:t.action&&typeof t.action=="object"?t.action:null}}function $0e({item:e,navigate:t}){const{route:n}=qe();return s.jsx("button",{type:"button",className:"ctx-panel-item ctx-panel-item--attention",onClick:()=>{e.conversationId?wt(t,{view:"conversation",conversationId:e.conversationId},{returnTo:n}):t({view:"ops",mode:"mission"})},children:s.jsxs("div",{className:"ctx-panel-body",children:[s.jsx("span",{className:"ctx-panel-name",children:e.title}),s.jsxs("span",{className:"ctx-panel-sub",children:[e.agentName??e.agentId??"operator"," · ",Ie(e.updatedAt)]})]})})}function L0e({ask:e,navigate:t}){const{route:n}=qe();return s.jsx("button",{type:"button",className:"ctx-panel-item",onClick:()=>{e.conversationId?wt(t,{view:"conversation",conversationId:e.conversationId},{returnTo:n}):t({view:"ops",mode:"mission"})},children:s.jsxs("div",{className:"ctx-panel-body",children:[s.jsx("span",{className:"ctx-panel-name",children:e.task}),s.jsxs("span",{className:"ctx-panel-sub",children:[e.agentName??e.agentId," · ",e.statusLabel]})]})})}const P0e=new Set(["working","queued","needs_attention"]);function Xg(){const[e,t]=m.useState(null),n=m.useCallback(async()=>{const r=await ue("/api/fleet").catch(()=>null);t(r)},[]);return m.useEffect(()=>{n()},[n]),Vt(r=>{(r.kind==="message.posted"||r.kind==="flight.updated"||r.kind==="collaboration.event.appended")&&n()}),m.useMemo(()=>{const r=new Map;for(const a of e?.activeAsks??[]){if(!P0e.has(a.status))continue;const o=r.get(a.agentId);(!o||a.updatedAt>o.updatedAt)&&r.set(a.agentId,a)}return r},[e])}function JI({name:e,kind:t="user",presence:n,className:r,channelClassName:a,background:o,style:c,title:u}){if(t==="channel")return s.jsx("span",{className:a??r,style:c,title:u,children:"#"});const f=e&&e.length>0?e[0].toUpperCase():"?",h=o??Xt(e),p=n!=null?s.jsx(z4,{state:n}):null;return p?s.jsxs("span",{className:"oc-avatar-wrap",children:[s.jsx("span",{className:r,style:{background:h,...c},title:u,children:f}),p]}):s.jsx("span",{className:r,style:{background:h,...c},title:u,children:f})}function z4({state:e,className:t,style:n}){const r=Ge(typeof e=="string"?e:e??null),a=r==="working"?"working":r==="ready"?"available":null;return s.jsx("span",{className:t,style:{background:yn(a),...n}})}function _n({name:e,meta:t,sub:n,tone:r="neutral",avatarName:a,avatarKind:o="user",leadingIcon:c,caret:u,active:f,selected:h,unread:p,depth:x=0,detail:v,expanded:y,onClick:b,onKeyDown:C,onPointerEnter:E,onPointerLeave:A,title:S,tabIndex:k}){const N=u?u==="open":v!==void 0?!!y:void 0,T=["rr-row",x===1&&"rr-row--child",f&&"rr-row--active",h&&"rr-row--selected",p&&"rr-row--unread",y&&"rr-row--expanded"].filter(Boolean).join(" ");return s.jsxs("div",{className:T,children:[s.jsxs("button",{type:"button",className:"rr-row-head",onClick:b,onKeyDown:C,onPointerEnter:E,onPointerLeave:A,title:S,tabIndex:k,"aria-expanded":N,children:[s.jsx(D0e,{icon:c,tone:r,caret:u,avatarName:a,avatarKind:o}),s.jsxs("span",{className:"rr-row-body",children:[s.jsx("span",{className:"rr-row-name",children:e}),n&&s.jsx("span",{className:"rr-row-sub",children:n})]}),t&&s.jsx("span",{className:"rr-row-meta",children:t})]}),y&&v&&s.jsx("div",{className:"rr-row-detail",children:v})]})}function D0e({icon:e,tone:t,caret:n,avatarName:r,avatarKind:a}){if(n)return s.jsx("span",{className:`rr-row-caret rr-row-caret--leading rr-row-caret--${n}`,"aria-hidden":!0,children:s.jsx(z0e,{open:n==="open"})});if(r){if(a==="channel")return s.jsx(JI,{kind:"channel",name:r,channelClassName:"rr-row-hash"});const c=e2(t),u=c==="working"||c==="available";return s.jsxs("span",{className:"rr-row-avatar-wrap","aria-hidden":!0,children:[s.jsx(JI,{className:"rr-row-avatar",name:r}),u&&s.jsx(z4,{state:c,className:`rr-row-presence rr-row-presence--${c}`})]})}if(e)return s.jsx("span",{className:"rr-row-icon","aria-hidden":!0,children:e});const o=e2(t);return s.jsx("span",{className:`rr-row-dot rr-row-dot--${o}`,style:o==="working"||o==="available"?{background:yn(o)}:void 0,"aria-hidden":!0})}function z0e({open:e}){return s.jsx("svg",{className:`rr-chevron${e?" rr-chevron--open":""}`,viewBox:"0 0 12 12",width:"12",height:"12",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:"M4.25 3L7.75 6L4.25 9",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function e2(e){return e==="channel"||e==="dm"||e==="neutral"?e:ll(e)}const B0e=new Set(["message.posted","flight.updated","collaboration.event.appended","agent.updated"]),U0e=4,F0e=4,V0e=3;function H0e({prepend:e}){const{agents:t,navigate:n,route:r}=qe(),[a,o]=m.useState(null),c=zs(r),u=m.useMemo(()=>cl(t,c),[t,c]),f=m.useMemo(()=>no(t,c),[t,c]),h=m.useMemo(()=>ED(a,u),[a,u]),p=m.useCallback(async()=>{const b=await ue("/api/fleet").catch(()=>null);o(b)},[]);m.useEffect(()=>{p()},[p]),Vt(b=>{B0e.has(b.kind)&&p()});const x=m.useMemo(()=>Z0e(f).slice(0,U0e),[f]),v=m.useMemo(()=>(h?.activity??[]).slice(0,F0e),[h]),y=m.useMemo(()=>(h?.needsAttention??[]).slice(0,V0e),[h]);return s.jsxs("div",{className:"ctx-panel base-rail",children:[e?s.jsx("div",{className:"base-rail-prepend",children:e}):null,s.jsx(W0e,{agents:x,totalCount:f.length,readyCount:f.filter(b=>ha(b.state)).length,onSelect:b=>Ka(n,b,{returnTo:r}),onSeeAll:()=>n({view:"agents"})}),s.jsx(K0e,{items:v,onSelect:b=>n(Y0e(b)),onSeeAll:()=>n({view:"activity"})}),s.jsx(G0e,{items:y,onSelect:b=>n(b.conversationId?{view:"conversation",conversationId:b.conversationId}:{view:"ops",mode:"mission"})})]})}function W0e({agents:e,totalCount:t,readyCount:n,onSelect:r,onSeeAll:a}){return s.jsxs("section",{className:"ctx-panel-section base-rail-section",children:[s.jsx(eN,{title:"Recent agents",meta:t>0?`${n} ready · ${t}`:void 0,onSeeAll:t>0?a:void 0}),e.length===0?s.jsx("div",{className:"ctx-panel-empty",children:"No agents yet"}):e.map(o=>s.jsx(_n,{name:o.name||o.id,meta:o.updatedAt?Ie(o.updatedAt):void 0,tone:Ge(o.state),title:q0e(o),onClick:()=>r(o)},o.id))]})}function q0e(e){const t=[];return e.project&&t.push(`project: ${e.project}`),e.branch&&t.push(`branch: ${e.branch}`),e.harness&&t.push(`harness: ${e.harness}`),t.join(`
185
- `)}function K0e({items:e,onSelect:t,onSeeAll:n}){return s.jsxs("section",{className:"ctx-panel-section base-rail-section",children:[s.jsx(eN,{title:"Recent activity",meta:(e.length>0,void 0),onSeeAll:e.length>0?n:void 0}),e.length===0?s.jsx("div",{className:"ctx-panel-empty",children:"Quiet so far"}):e.map(r=>{const a=r.actorName??r.agentName??r.agentId??"system",o=r.title??r.summary??t2(r.kind);return s.jsx(_n,{name:o,meta:r.ts?Ie(r.ts):void 0,tone:"neutral",title:`${a} · ${t2(r.kind)}`,onClick:()=>t(r)},r.id)})]})}function G0e({items:e,onSelect:t}){return s.jsxs("section",{className:"ctx-panel-section base-rail-section",children:[s.jsx(eN,{title:"Needs attention",meta:e.length>0?`${e.length}`:void 0}),e.length===0?s.jsx("div",{className:"ctx-panel-empty",children:"All clear"}):e.map(n=>{const r=n.agentName??n.agentId??"operator";return s.jsx(_n,{name:n.title,meta:Ie(n.updatedAt),tone:"working",unread:!0,title:`${r} · ${n.kind}`,onClick:()=>t(n)},n.recordId)})]})}function eN({title:e,meta:t,onSeeAll:n}){return s.jsxs("div",{className:"ctx-panel-section-label base-rail-section-label",children:[s.jsx("span",{children:e}),s.jsxs("span",{className:"base-rail-section-trailing",children:[t?s.jsx("span",{className:"ctx-panel-count",children:t}):null,n?s.jsx("button",{type:"button",className:"base-rail-see-all",onClick:n,children:"all"}):null]})]})}function Z0e(e){return[...e].sort((t,n)=>(n.updatedAt??0)-(t.updatedAt??0))}function t2(e){switch(e){case"message":return"Message";case"invocation":return"Invocation";case"flight":return"Flight update";case"collaboration":return"Collaboration";default:return e.replace(/_/g," ")}}function Y0e(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.agentId?{view:"agents",agentId:e.agentId}:{view:"activity"}}function X0e(){const[e,t]=m.useState("rack"),{agents:n}=qe(),{meshSnapshot:r,selectedId:a,selectedType:o,hiddenMachineIds:c,machinePositions:u}=zc(),f=m.useMemo(()=>r?Ok(n,r):[],[n,r]);if(!r||f.length===0)return null;const h=f.filter(y=>!c.has(y.machineId)).length,p=f.length,x=Object.keys(u).length,v=y=>{Go(y,"node"),xw(y)};return s.jsxs("div",{className:"mesh-rail",children:[s.jsxs("div",{className:"mesh-rail-head",children:[s.jsx("span",{className:"mesh-rail-ear","aria-hidden":!0}),s.jsxs("div",{className:"mesh-rail-mode",role:"group","aria-label":"Bottom view",children:[s.jsx("button",{type:"button",className:`mesh-rail-mode-btn${e==="map"?" mesh-rail-mode-btn--active":""}`,onClick:()=>t("map"),"aria-pressed":e==="map",children:"map"}),s.jsx("button",{type:"button",className:`mesh-rail-mode-btn${e==="rack"?" mesh-rail-mode-btn--active":""}`,onClick:()=>t("rack"),"aria-pressed":e==="rack",children:"rack"})]}),s.jsx("span",{className:"mesh-rail-title-count",children:p}),s.jsx("span",{className:"mesh-rail-ear","aria-hidden":!0})]}),e==="rack"?s.jsx(Q0e,{buckets:f,hiddenMachineIds:c,selectedId:a,selectedType:o,onFocus:v}):s.jsx(J0e,{buckets:f,selectedId:a,selectedType:o,onFocus:v}),s.jsxs("div",{className:"mesh-rail-foot",children:[s.jsx("span",{className:"mesh-rail-foot-mark","aria-hidden":!0}),s.jsx("span",{className:"mesh-rail-foot-meta",children:e==="map"?`${p} machines`:`${h}/${p} shown`}),x>0&&e==="rack"?s.jsx("button",{type:"button",className:"mesh-rail-foot-reset",onClick:()=>tme(),title:"Reset machine layout",children:"reset"}):s.jsx("span",{className:"mesh-rail-foot-mark","aria-hidden":!0})]})]})}function Q0e({buckets:e,hiddenMachineIds:t,selectedId:n,selectedType:r,onFocus:a}){return s.jsx("div",{className:"mesh-rail-body",children:e.map((o,c)=>{const u=t.has(o.machineId),f=n===o.machineId&&r==="node",h=o.agents.filter(E=>Ge(E.state)==="working").length,p=o.agents.filter(E=>Ge(E.state)==="ready").length,x=o.online?o.agents.length===0?"offline":h>0?"working":"available":"offline",v=u||!o.online?void 0:yn(x),y=o.reachability==="this"?"L":o.reachability==="peer"?"P":o.reachability==="tailnet"?"T":"·",b=String(c+1).padStart(2,"0"),C=o.online?o.agents.length===0?"idle":`${h}w · ${p}r`:"unreachable";return s.jsxs("div",{className:["mesh-rail-unit",u&&"mesh-rail-unit--off",!o.online&&"mesh-rail-unit--unreachable",f&&"mesh-rail-unit--active"].filter(Boolean).join(" "),children:[s.jsxs("button",{type:"button",className:"mesh-rail-unit-body",onClick:()=>a(o.machineId),title:`Focus ${o.machineLabel} on the map`,children:[s.jsx("span",{className:"mesh-rail-slot",children:b}),s.jsx("span",{className:`mesh-rail-led${u||!o.online?"":" mesh-rail-led--on"}`,style:v?{background:v,color:v}:void 0,"aria-hidden":!0}),s.jsxs("span",{className:"mesh-rail-unit-text",children:[s.jsx("span",{className:"mesh-rail-unit-name",title:o.machineLabel,children:o.machineLabel}),s.jsxs("span",{className:"mesh-rail-unit-sub",children:[s.jsx("span",{className:`mesh-rail-reach mesh-rail-reach--${o.reachability}`,children:y}),s.jsx("span",{className:"mesh-rail-unit-stamp",children:C})]})]}),s.jsx("span",{className:"mesh-rail-unit-count",children:o.agents.length})]}),s.jsx("div",{className:"mesh-rail-unit-actions",children:s.jsx("button",{type:"button",className:`mesh-rail-unit-eye${u?" mesh-rail-unit-eye--off":""}`,onClick:E=>{E.stopPropagation(),K5(o.machineId)},title:u?"Show in workspace":"Hide from workspace","aria-pressed":!u,children:u?"○":"●"})}),s.jsx("span",{className:"mesh-rail-vent","aria-hidden":!0})]},o.machineId)})})}function J0e({buckets:e,selectedId:t,selectedType:n,onFocus:r}){return s.jsx("div",{className:"mesh-rail-body mesh-rail-body--map",children:s.jsx("div",{className:"mesh-mini-map",children:e.map(a=>{const o=t===a.machineId&&n==="node",c=a.agents.filter(h=>Ge(h.state)==="working").length,u=a.online?a.agents.length===0?"offline":c>0?"working":"available":"offline",f=a.online?yn(u):void 0;return s.jsxs("button",{type:"button",className:`mesh-mini-node mesh-mini-node--${u}${o?" mesh-mini-node--active":""}${a.online?"":" mesh-mini-node--off"}`,onClick:()=>r(a.machineId),title:`${a.machineLabel} — ${a.agents.length} agents`,children:[s.jsx("span",{className:"mesh-mini-led",style:f?{background:f}:void 0,"aria-hidden":!0}),s.jsx("span",{className:"mesh-mini-label",children:a.machineLabel}),a.agents.length>0&&s.jsx("span",{className:"mesh-mini-count",children:a.agents.length})]},a.machineId)})})})}const B4="openscout.globalJumpDock.mode.v1";function ewe(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(B4);return e==="jump"||e==="minimap"?e:null}catch{return null}}function twe(e){try{window.localStorage.setItem(B4,e)}catch{}}function nwe(){const{route:e,navigate:t}=qe(),n=e.view==="mesh",[r,a]=m.useState(()=>{const c=ewe();return c==="minimap"&&n?"minimap":c==="jump"?"jump":n?"minimap":"jump"});m.useEffect(()=>{r==="minimap"&&!n&&a("jump")},[r,n]);const o=c=>{a(c),twe(c)};return s.jsxs("div",{className:"gjd",children:[s.jsxs("div",{className:"gjd-head",children:[s.jsx("span",{className:"gjd-ear","aria-hidden":!0}),s.jsxs("div",{className:"gjd-mode",role:"group","aria-label":"Bottom dock mode",children:[s.jsx("button",{type:"button",className:`gjd-mode-btn${r==="jump"?" gjd-mode-btn--active":""}`,onClick:()=>o("jump"),"aria-pressed":r==="jump",children:"jump"}),n&&s.jsx("button",{type:"button",className:`gjd-mode-btn${r==="minimap"?" gjd-mode-btn--active":""}`,onClick:()=>o("minimap"),"aria-pressed":r==="minimap",children:"minimap"})]}),s.jsx("span",{className:"gjd-ear","aria-hidden":!0})]}),s.jsx("div",{className:"gjd-body",children:r==="minimap"&&n?s.jsx(X0e,{}):s.jsx(rwe,{navigate:t})})]})}const swe=[{id:"sessions",label:"Sessions",icon:s.jsx(pg,{size:13,strokeWidth:1.6}),route:{view:"sessions"}},{id:"repos",label:"Repos",icon:s.jsx(aB,{size:13,strokeWidth:1.6}),route:{view:"repos"}},{id:"search",label:"Search",icon:s.jsx(Ei,{size:13,strokeWidth:1.6}),route:{view:"search"}},{id:"tail",label:"Tail",icon:s.jsx(A2,{size:13,strokeWidth:1.6}),route:{view:"ops",mode:"tail"}},{id:"ops",label:"Ops",icon:s.jsx(Zb,{size:13,strokeWidth:1.6}),route:{view:"ops",mode:"mission"}},{id:"home",label:"Home",icon:s.jsx(k2,{size:13,strokeWidth:1.6}),route:{view:"inbox"}},{id:"dispatch",label:"Dispatch",icon:s.jsx(Zb,{size:13,strokeWidth:1.6}),route:{view:"broker"}}];function rwe({navigate:e}){return s.jsx("div",{className:"gjd-jumps",children:swe.map(t=>s.jsxs("button",{type:"button",className:"gjd-jump",onClick:()=>e(t.route),children:[s.jsx("span",{className:"gjd-jump-icon",children:t.icon}),s.jsx("span",{className:"gjd-jump-label",children:t.label})]},t.id))})}function tN({value:e,onChange:t,placeholder:n="Search…",onKeyDown:r}){return s.jsx("input",{type:"search",className:"fleet-search",placeholder:n,value:e,onChange:a=>t(a.target.value),onKeyDown:r,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off"})}const awe=["working","ready","not_ready"],iwe={working:"working",ready:"ready",not_ready:"not ready"},owe={working:"working",ready:"available",not_ready:"offline"};function U4({active:e,onToggle:t}){return s.jsx("div",{className:"fleet-pills",role:"group","aria-label":"State filters",children:awe.map(n=>{const r=e.has(n);return s.jsx("button",{type:"button",className:`fleet-pill fleet-pill--${owe[n]}${r?" fleet-pill--on":""}`,onClick:()=>t(n),"aria-pressed":r,children:iwe[n]},n)})})}const n2=10;function lwe(e){return Ge(e.state)}function s2(e){return e.updatedAt??e.createdAt??0}function cwe(){const{agents:e,navigate:t}=qe(),{meshSnapshot:n,selectedId:r,selectedType:a,query:o,agentStateFilters:c,hiddenMachineIds:u,treeFullMachineIds:f}=zc(),h=Xg(),p=m.useMemo(()=>n?Ok(e,n):[],[e,n]),x=m.useMemo(()=>{const S=o.trim().toLowerCase();return p.filter(k=>!u.has(k.machineId)).map(k=>{const N=k.agents.filter(T=>c.has(lwe(T))?S?`${T.name??""} ${T.project??""} ${T.branch??""} ${T.harness??""}`.toLowerCase().includes(S):!0:!1);return{...k,agents:N}})},[p,o,c,u]),v=m.useMemo(()=>{const S=new Map([["this",[]],["peer",[]],["tailnet",[]]]);for(const k of x){const N=k.reachability==="this"?"this":k.reachability==="peer"?"peer":"tailnet";S.get(N)?.push(k)}return S},[x]);if(!n)return s.jsx("div",{className:"ctx-panel ctx-panel--empty",children:s.jsx("div",{className:"ctx-panel-empty-state",children:s.jsx("div",{className:"ctx-panel-empty-hint",children:"Loading mesh…"})})});const y=S=>{const k=p.map(N=>N.machineId);Xhe(S,k),Go(S,"node"),xw(S)},b=u.size,C=p.length,E=S=>{Go(S.id,"agent");const k=S.authorityNodeId??S.homeNodeId;k&&xw(k),Ka(t,S,{returnTo:{view:"mesh"}})},A=(S,k)=>k.length===0?null:s.jsxs("section",{className:"mesh-nav-group",children:[s.jsx("div",{className:"mesh-nav-group-label",children:S}),k.map(N=>{const T=f.has(N.machineId),R=[...N.agents].sort((U,D)=>s2(D)-s2(U)),O=T?R:R.slice(0,n2),L=R.length-O.length,I=r===N.machineId&&a==="node",z=N.agents.filter(U=>Ge(U.state)==="working").length,_=N.agents.length>0?`${z}/${N.agents.length}`:N.online?"—":"not ready";return s.jsxs("div",{className:"mesh-nav-machine",children:[s.jsx(_n,{name:N.machineLabel,meta:_,tone:"neutral",active:I,onClick:()=>y(N.machineId),title:`Focus ${N.machineLabel} on the map`}),O.map(U=>{const D=r===U.id&&a==="agent",q=h.has(U.id);return s.jsx(_n,{name:U.name,tone:Ge(U.state),depth:1,active:D,unread:q,onClick:()=>E(U),title:U.name},U.id)}),!T&&L>0&&s.jsx(_n,{name:`see ${L} more`,depth:1,tone:"neutral",onClick:()=>AR(N.machineId),title:"Show all agents on this machine"}),T&&R.length>n2&&s.jsx(_n,{name:"see less",depth:1,tone:"neutral",onClick:()=>AR(N.machineId),title:"Show recent agents only"})]},N.machineId)})]},S);return s.jsxs("div",{className:"ctx-panel mesh-nav",children:[s.jsxs("div",{className:"mesh-nav-head",children:[s.jsx(tN,{value:o,onChange:q5,placeholder:"Find machines or agents…"}),s.jsx(U4,{active:c,onToggle:Yhe}),b>0&&b<C&&s.jsxs("button",{type:"button",className:"mesh-nav-focus-chip",onClick:Qhe,title:"Show all machines",children:[s.jsxs("span",{className:"mesh-nav-focus-chip-label",children:["focused · ",C-b,"/",C]}),s.jsx("span",{className:"mesh-nav-focus-chip-clear","aria-hidden":!0,children:"×"})]})]}),s.jsxs("div",{className:"mesh-nav-tree",children:[A("this host",v.get("this")??[]),A("peers",v.get("peer")??[]),A("tailnet",v.get("tailnet")??[])]})]})}const r2={working:0,ready:1,not_ready:2},uwe=["all","dm","channel"],dwe={all:"All",dm:"Private",channel:"Shared"},fwe=["recent","name","unread"],a2={recent:"Recent",name:"Name",unread:"Unread"};function hwe(){const{route:e,navigate:t,agents:n}=qe(),[r,a]=m.useState([]),[o,c]=m.useState(()=>vk()),[u,f]=m.useState(""),[h,p]=m.useState(()=>new Set),x=Xg(),v=zs(e),y=m.useMemo(()=>cl(n,v),[n,v]),b=m.useMemo(()=>{const D=new Map,q=y?n.filter(Z=>y.has(Z.id)):n;for(const Z of q)D.set(Z.id,Z);return D},[n,y]),C=e.view==="messages"&&e.filter?e.filter:"all",E=e.view==="messages"&&e.sort?e.sort:"recent",A=e.view==="messages"||e.view==="conversation"?e.conversationId:e.view==="channels"?e.channelId:e.view==="agent-info"||e.view==="agents"?e.conversationId:void 0,S=m.useCallback(async()=>{const D=await ue("/api/conversations").catch(()=>[]);a(D)},[]);m.useEffect(()=>{S()},[S]),Vt(D=>{(D.kind==="message.posted"||D.kind==="conversation.upserted")&&S()});const k=m.useMemo(()=>{let D=ck(r,y,v);if(C==="dm"?D=D.filter(Uoe):C==="channel"&&(D=D.filter(Cc)),u){const Z=u.toLowerCase();D=D.filter($=>br($).toLowerCase().includes(Z)||$.id.toLowerCase().includes(Z)||($.preview??"").toLowerCase().includes(Z))}const q=[...D];switch(E){case"name":q.sort((Z,$)=>br(Z).toLowerCase().localeCompare(br($).toLowerCase()));break;case"unread":{const Z=$=>op($.lastMessageAt,$.id,o)?0:1;q.sort(($,G)=>{const V=Z($),Y=Z(G);return V!==Y?V-Y:(G.lastMessageAt??0)-($.lastMessageAt??0)});break}default:q.sort((Z,$)=>($.lastMessageAt??0)-(Z.lastMessageAt??0));break}return q},[r,y,C,E,u,o]),N=D=>{t({view:"messages",...A?{conversationId:A}:{},...D!=="all"?{filter:D}:{},...E!=="recent"?{sort:E}:{}})},T=D=>{t({view:"messages",...A?{conversationId:A}:{},...C!=="all"?{filter:C}:{},...D!=="recent"?{sort:D}:{}})},R=D=>{if(c(xk(D.id)),Cc(D)&&e.view==="channels"){t({view:"channels",channelId:D.id});return}t({view:"messages",conversationId:D.id,...C!=="all"?{filter:C}:{},...E!=="recent"?{sort:E}:{}})},O=D=>{p(q=>{const Z=new Set(q);return Z.has(D)?Z.delete(D):Z.add(D),Z})},L=m.useMemo(()=>mwe(k,b,o,E),[k,b,o,E]),I=m.useRef(null),z=m.useRef(null),_=pD(),U=vD(()=>I.current);return gD(m.useCallback(()=>z.current,[])),s.jsxs("div",{className:"ctx-panel",children:[s.jsx("div",{className:"ctx-panel-tabs",children:uwe.map(D=>s.jsx("button",{type:"button",className:["ctx-panel-tab",C===D&&"ctx-panel-tab--active"].filter(Boolean).join(" "),onClick:()=>N(D),children:dwe[D]},D))}),s.jsxs("div",{className:"ctx-panel-toolbar",children:[s.jsx("input",{ref:z,type:"text",className:"ctx-panel-search-input",placeholder:"Filter… (/)",value:u,onChange:D=>f(D.target.value),onKeyDown:U}),s.jsx("div",{className:"ctx-panel-sort",role:"group","aria-label":"Sort",children:fwe.map(D=>s.jsx("button",{type:"button",title:`Sort by ${a2[D].toLowerCase()}`,className:["ctx-panel-sort-option",E===D&&"ctx-panel-sort-option--active"].filter(Boolean).join(" "),onClick:()=>T(D),children:a2[D]},D))})]}),s.jsx("div",{ref:I,className:"ctx-panel-list ctx-panel-list--scroll",onKeyDown:_,children:L.length===0?s.jsx("div",{className:"ctx-panel-empty",children:u?"No match":"Nothing yet"}):(()=>{const D=L.flatMap($=>$.conversations),q=D[0]?.id,Z=A!=null&&D.some($=>$.id===A);return L.map($=>{const G=$.conversations.length===1,V=!!u||h.has($.key),Y=$.conversations.some(K=>K.id===A);if(G){const K=$.conversations[0],P=K.id===A,H=op(K.lastMessageAt,K.id,o),B=br(K),Q=Cc(K),oe=K.agentId?b.get(K.agentId):void 0,ne=o2(K,oe),X=ne.toLowerCase()===B.toLowerCase()?void 0:ne;return s.jsx(_n,{name:B,sub:X,meta:K.lastMessageAt?Ie(K.lastMessageAt):void 0,tone:Q?"channel":oe?Ge(oe.state):"dm",avatarName:B,active:P,unread:H,tabIndex:Q0(P,Z,K.id===q),onClick:()=>R(K)},$.key)}return s.jsxs("div",{children:[s.jsx(_n,{name:$.label,meta:vwe($),tone:$.bestState,caret:V?"open":"closed",active:Y&&!V,unread:$.unreadCount>0&&!V,onClick:()=>O($.key)}),V&&$.conversations.map(K=>{const P=K.id===A,H=op(K.lastMessageAt,K.id,o),B=K.agentId?b.get(K.agentId):void 0,Q=K.agentId?x.get(K.agentId):void 0;return s.jsx(_n,{depth:1,name:i2(K,B,Q),sub:o2(K,B),meta:K.lastMessageAt?Ie(K.lastMessageAt):void 0,tone:B?Ge(B.state):"dm",avatarName:B?.name??i2(K,B,Q),active:P,unread:H,title:pwe(K,B,Q),tabIndex:Q0(P,Z,K.id===q),onClick:()=>R(K)},K.id)})]},$.key)})})()})]})}function mwe(e,t,n,r){const a=new Map;for(const c of e){const u=Cc(c);let f,h;if(u)f=`channel:${c.id}`,h=br(c);else{const v=(c.agentId?t.get(c.agentId):void 0)?.project??null;if(v)f=`project:${v.toLowerCase()}`,h=v;else{const y=(c.agentName??br(c)).trim();y?(f=`name:${y.toLowerCase()}`,h=y):(f=`dm:${c.id}`,h=br(c))}}let p=a.get(f);if(p||(p={key:f,label:h,isChannel:u,conversations:[],bestState:"not_ready",latestUpdate:0,unreadCount:0},a.set(f,p)),p.conversations.push(c),p.latestUpdate=Math.max(p.latestUpdate,c.lastMessageAt??0),op(c.lastMessageAt,c.id,n)&&(p.unreadCount+=1),!u){const x=c.agentId?t.get(c.agentId):void 0;if(x){const v=Ge(x.state);(r2[v]??9)<(r2[p.bestState]??9)&&(p.bestState=v)}}}for(const c of a.values())c.conversations.sort((u,f)=>(f.lastMessageAt??0)-(u.lastMessageAt??0));const o=Array.from(a.values());switch(r){case"name":o.sort((c,u)=>c.label.toLowerCase().localeCompare(u.label.toLowerCase()));break;case"unread":o.sort((c,u)=>c.unreadCount>0!=u.unreadCount>0?c.unreadCount>0?-1:1:u.latestUpdate-c.latestUpdate);break;default:o.sort((c,u)=>u.latestUpdate-c.latestUpdate);break}return o}function i2(e,t,n){const r=n?.task??gwe(e.preview)??e.currentBranch??t?.branch??"",a=t?.name??e.agentName??br(e);return r?`${a} · ${r}`:a}function pwe(e,t,n){const r=[];return n&&r.push(`task: ${n.task}`),e.preview&&r.push(`preview: ${e.preview}`),(e.currentBranch??t?.branch)&&r.push(`branch: ${e.currentBranch??t?.branch}`),t?.harness&&r.push(`harness: ${t.harness}`),r.length>0?r.join(`
186
- `):void 0}function o2(e,t){if(Cc(e))return pk(e);const n=t?.handle?.trim().replace(/^@+/,"");return n||(e.agentId?e.agentId.split(".")[0]??e.agentId:br(e))}function gwe(e){if(!e)return null;const t=e.replace(/\s+/g," ").trim();return t?t.length>60?`${t.slice(0,57)}…`:t:null}function vwe(e){const t=e.latestUpdate?Ie(e.latestUpdate):"",n=e.unreadCount>0?`${e.unreadCount}/${e.conversations.length}`:`${e.conversations.length}`;return t?`${n} · ${t}`:n}function xwe(){const{navigate:e}=qe(),t=p4(),n=t.visibleAgents,r=m.useRef(null),a=m.useRef(null),o=pD(),c=vD(()=>r.current);gD(m.useCallback(()=>a.current,[]));const[u,f]=m.useState(null),h=t.activityFilter==="recent",p=t.selectedIds.length,x=y=>{f(b=>b===y?null:y)},v=()=>{if(p===0)return;const b=n.filter(C=>t.selectedIds.includes(C.id)).map(C=>C.handle??C.name).filter(Boolean).join("|");b&&e({view:"ops",mode:"tail",tailQuery:b})};return s.jsxs("div",{className:"ctx-panel ml-panel",children:[s.jsxs("div",{className:"ml-section",children:[s.jsx("div",{className:"ml-section-label",children:"Source"}),s.jsx("div",{className:"ml-chips ml-chips--primary",children:["all","scout","native"].map(y=>s.jsx("button",{type:"button",className:["ml-chip",t.sourceFilter===y&&"ml-chip--active"].filter(Boolean).join(" "),onClick:()=>h4(y),children:y==="all"?"All":y==="scout"?"Scout":"Native"},y))})]}),s.jsx("div",{className:"ctx-panel-search",children:s.jsx("input",{ref:a,type:"text",className:"ctx-panel-search-input",placeholder:"Filter agents… (press /)",value:t.query,onChange:y=>rg(y.target.value),onKeyDown:y=>{c(y),y.key==="Escape"&&t.query&&rg("")}})}),s.jsx("div",{className:"ml-section ml-section--secondary",children:s.jsxs("div",{className:"ml-chips ml-chips--secondary",children:[["all","active","recent"].map(y=>s.jsx("button",{type:"button",className:["ml-chip ml-chip--ghost",t.activityFilter===y&&"ml-chip--ghost-active"].filter(Boolean).join(" "),onClick:()=>f4(y),children:y==="all"?"Any":y==="active"?"Active":"Recent"},y)),h&&s.jsx("span",{className:"ml-divider","aria-hidden":!0}),h&&sg.map(y=>s.jsx("button",{type:"button",className:["ml-chip ml-chip--ghost",t.recentWindowMs===y.value&&"ml-chip--ghost-active"].filter(Boolean).join(" "),onClick:()=>m4(y.value),children:y.label},y.value))]})}),p>0?s.jsxs("div",{className:"ml-selection",children:[s.jsxs("span",{className:"ml-selection-label",children:[p," selected"]}),s.jsxs("div",{className:"ml-selection-actions",children:[s.jsx("button",{type:"button",className:"ml-selection-btn ml-selection-btn--primary",onClick:v,children:"Tail ↗"}),s.jsx("button",{type:"button",className:"ml-selection-btn",onClick:hp,children:"Clear"})]})]}):s.jsxs("div",{className:"ml-count",children:[n.length," visible",s.jsx("span",{className:"ml-count-hint",children:"⌘-click · ⌘A all"})]}),s.jsx("div",{ref:r,className:"ctx-panel-list ctx-panel-list--scroll",onKeyDown:o,children:n.length===0?s.jsx("div",{className:"ctx-panel-empty",children:t.query?"No match":"Nothing visible"}):n.map((y,b)=>{const C=y.id===u,E=n.some(k=>k.id===u),A=t.selectedIds.includes(y.id),S=Ge(y.state);return s.jsx(ywe,{agent:y,state:S,isExpanded:C,isSelected:A,tabIndex:Q0(C,E,b===0),onToggle:k=>{k.metaKey||k.ctrlKey||k.shiftKey?ic(y.id):x(y.id)},onFocusOnCanvas:()=>Uge(y.id),onOpen:()=>e({view:"agents",agentId:y.id})},y.id)})})]})}function ywe({agent:e,state:t,isExpanded:n,isSelected:r,tabIndex:a,onToggle:o,onFocusOnCanvas:c,onOpen:u}){const f=Yo({label:`Focus ${e.handle??e.name}`,route:`/ops/control · ${e.id}`}),h=s.jsxs(s.Fragment,{children:[s.jsxs("dl",{className:"rr-spec-list",children:[s.jsx(cd,{label:"MODEL",value:[e.harness,e.model].filter(Boolean).join("/")||"—"}),s.jsx(cd,{label:"AT",value:[e.project,e.branch].filter(Boolean).join("/")||"—"}),s.jsx(cd,{label:"STATE",value:cs(t)}),s.jsx(cd,{label:"ACTIVITY",value:e.activity}),s.jsx(cd,{label:"SOURCE",value:e.source})]}),s.jsxs("div",{className:"ml-detail-actions",children:[s.jsx("button",{type:"button",className:"ml-detail-btn",onClick:c,children:"Focus on canvas"}),s.jsx("button",{type:"button",className:"ml-detail-btn ml-detail-btn--primary",onClick:u,children:"Open ↗"})]})]});return s.jsx(_n,{name:e.handle??e.name,meta:e.lastActiveAt?Ie(e.lastActiveAt):e.updatedAt?Ie(e.updatedAt):void 0,tone:t,caret:n?"open":"closed",selected:r,expanded:n,detail:h,tabIndex:a,onClick:p=>o(p),onPointerEnter:f.onPointerEnter,onPointerLeave:f.onPointerLeave})}function cd({label:e,value:t}){return s.jsxs("div",{className:"rr-spec",children:[s.jsx("dt",{className:"rr-spec-label",children:e}),s.jsx("dd",{className:"rr-spec-value",title:t,children:t})]})}const bwe=new Set(["message.posted","conversation.upserted","agent.updated"]);function wwe(e){const t=l2(e.cwd),n=l2(e.projectRoot);return e.authorityNodeName??e.homeNodeName??e.authorityNodeId??e.homeNodeId??e.transport??t??n??"local"}function jwe(e){return e.project??e.role??e.agentClass??"Unassigned"}function l2(e){if(!e)return null;const t=e.split("/").filter(Boolean);return t[t.length-1]??null}function kwe(){const{agents:e,navigate:t}=qe(),[n,r]=m.useState([]),a=Xg(),o=m.useCallback(async()=>{const p=await ue("/api/conversations").catch(()=>[]);r(p)},[]);m.useEffect(()=>{o()},[o]),Vt(p=>{bwe.has(p.kind)&&o()});const c=m.useMemo(()=>e.filter(p=>ha(p.state)).length,[e]),u=m.useMemo(()=>{let p=0;for(const x of a.values())(x.status==="failed"||x.status==="needs_attention")&&(p+=1);return p},[a]),f=m.useMemo(()=>{const p=new Map;for(const x of e){const v=jwe(x);p.set(v,(p.get(v)??0)+1)}return[...p.entries()].sort((x,v)=>v[1]-x[1]).slice(0,8)},[e]),h=m.useMemo(()=>{const p=new Map;for(const x of e){const v=wwe(x);p.set(v,(p.get(v)??0)+1)}return[...p.entries()].sort((x,v)=>v[1]-x[1]).slice(0,8)},[e]);return s.jsxs("div",{className:"ctx-panel",children:[s.jsxs("section",{className:"ctx-panel-section",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Agents"}),s.jsx(_n,{name:"Overview",meta:`${e.length}`,tone:"neutral",onClick:()=>t({view:"fleet"})}),s.jsx(_n,{name:"Agents",meta:`${c}`,tone:"ready",active:!0,onClick:()=>t({view:"ops",mode:"agents"})}),s.jsx(_n,{name:"Sessions",meta:`${n.length}`,tone:"neutral",onClick:()=>t({view:"sessions"})}),s.jsx(_n,{name:"Alerts",meta:`${u}`,tone:u>0?"working":"neutral",unread:u>0,onClick:()=>t({view:"activity"})})]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Projects"}),f.length===0?s.jsx("div",{className:"ctx-panel-empty",children:"No projects"}):f.map(([p,x])=>s.jsx(_n,{name:p,meta:`${x}`,tone:"neutral",title:`${x} agent${x===1?"":"s"} on ${p}`},p))]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Machines"}),h.length===0?s.jsx("div",{className:"ctx-panel-empty",children:"No machines"}):h.map(([p,x])=>s.jsx(_n,{name:p,meta:`${x}`,tone:"neutral",title:`${x} agent${x===1?"":"s"} on ${p}`},p))]})]})}const Nwe=[{name:"Control",route:{view:"ops",mode:"mission"},active:e=>e.view==="ops"&&(e.mode===void 0||e.mode==="mission")},{name:"Dispatch",route:{view:"broker"},active:e=>e.view==="broker"},{name:"Mesh",route:{view:"mesh"},active:e=>e.view==="mesh"},{name:"Tail",route:{view:"ops",mode:"tail"},active:e=>e.view==="ops"&&e.mode==="tail"},{name:"Runtime",route:{view:"ops",mode:"atop"},active:e=>e.view==="ops"&&e.mode==="atop"}];function Swe(){const{navigate:e,route:t}=qe(),[n,r]=m.useState(null),a=m.useCallback(async()=>{const h=await ue("/api/fleet").catch(()=>null);r(h)},[]);m.useEffect(()=>{a()},[a]),Vt(h=>{(h.kind==="message.posted"||h.kind==="flight.updated"||h.kind==="collaboration.event.appended")&&a()});const o=n?.needsAttention??[],c=(n?.activeAsks??[]).filter(h=>h.status!=="needs_attention"),u=h=>{h.conversationId?wt(e,{view:"conversation",conversationId:h.conversationId},{returnTo:t}):e({view:"ops",mode:"mission"})},f=h=>{h.conversationId?wt(e,{view:"conversation",conversationId:h.conversationId},{returnTo:t}):e({view:"ops",mode:"mission"})};return s.jsxs("div",{className:"ctx-panel ctx-panel--ops",children:[s.jsxs("section",{className:"ctx-panel-section",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Surfaces"}),Nwe.map(h=>s.jsx(_n,{name:h.name,tone:"neutral",active:h.active(t),onClick:()=>e(h.route)},h.name))]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsxs("div",{className:"ctx-panel-section-label",children:["Needs you",o.length>0&&s.jsx("span",{className:"ctx-panel-count",children:o.length})]}),o.length===0?s.jsx("div",{className:"ctx-panel-empty",children:"All clear"}):o.slice(0,4).map(h=>{const p=h.agentName??h.agentId??"operator";return s.jsx(_n,{name:h.title,meta:Ie(h.updatedAt),tone:"working",unread:!0,title:`${p} · ${h.kind}`,onClick:()=>u(h)},h.recordId)})]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsxs("div",{className:"ctx-panel-section-label",children:["Active",c.length>0&&s.jsx("span",{className:"ctx-panel-count",children:c.length})]}),c.length===0?s.jsx("div",{className:"ctx-panel-empty",children:"No active asks"}):c.slice(0,10).map(h=>s.jsx(_n,{name:h.task,meta:Ie(h.updatedAt),tone:Ge(h.agentState),title:`${h.agentName??h.agentId} · ${h.statusLabel}`,onClick:()=>f(h)},h.invocationId))]})]})}function Cwe(e){if(e.view==="ops")return e.mode==="mission"?{mode:"takeover",render:()=>s.jsx(xwe,{})}:e.mode==="agents"?{mode:"takeover",render:()=>s.jsx(kwe,{})}:e.mode==="plan"?{mode:"takeover",render:()=>s.jsx(zwe,{})}:{mode:"takeover",render:()=>s.jsx(Swe,{})};switch(e.view){case"agents":case"agent-info":return{mode:"takeover",render:()=>s.jsx(Uwe,{})};case"messages":case"channels":case"conversation":return{mode:"takeover",render:()=>s.jsx(hwe,{})};case"mesh":return{mode:"takeover",render:()=>s.jsx(cwe,{})};default:return null}}const ec={working:0,ready:1,not_ready:2};function F4(e){const t=e?.trim().replace(/\/+$/,"");if(!t)return null;const n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function zw(e){const t=e?.trim();return t?t.toLowerCase():null}function Ewe(e){const t=zw(F4(e));return!t||t==="~"?null:t.match(/^(.+?)(?:-(?:parity|codex))?-c\d+$/)?.[1]??null}function Awe(e){return Ewe(e.projectRoot??e.cwd)??zw(e.project)??zw(F4(e.projectRoot??e.cwd))??"other"}function Twe(e){return`project:${e.key||"unscoped"}`}function Mwe(e){const t=new Map;for(const r of e){const a=Awe(r),o=t.get(a);o?o.push(r):t.set(a,[r])}const n=[];for(const[r,a]of t){a.sort((u,f)=>{const h=(ec[Ge(u.state)]??9)-(ec[Ge(f.state)]??9);return h!==0?h:(f.updatedAt??0)-(u.updatedAt??0)});const o=a.reduce((u,f)=>{const h=Ge(f.state);return(ec[h]??9)<(ec[u]??9)?h:u},"not_ready"),c=Math.max(...a.map(u=>u.updatedAt??0));n.push({key:r,label:r,agents:a,bestState:o,latestUpdate:c})}return n.sort((r,a)=>{const o=(ec[r.bestState]??9)-(ec[a.bestState]??9);return o!==0?o:a.latestUpdate-r.latestUpdate}),n}function Rwe(e){return e.trim().toLowerCase()}function Iwe(e){return[e.id,e.name,e.handle??"",e.selector??"",e.project??"",e.branch??"",e.role??"",e.harness??"",e.harnessSessionId??"",e.conversationId,e.harnessLogPath??""]}function _we(e,t){return t?Iwe(e).some(n=>n.toLowerCase().includes(t)):!0}function c2(e,t){return t?[e.harnessSessionId,e.conversationId].find(r=>r?.toLowerCase().includes(t))??null:null}function u2(e,t,n={}){Ka(e,t,{...n,returnTo:{view:"agents"}})}function Owe(){const{route:e}=qe(),t=Cwe(e),n=t?.mode==="takeover"?t.render():s.jsx(H0e,{prepend:t?.mode==="prepend"?t.render():void 0});return s.jsxs("div",{className:"scout-left-shell",children:[s.jsx("div",{className:"scout-left-shell-rail",children:n}),s.jsx(nwe,{})]})}const d2={all:"All",claude:"Claude",codex:"Codex",openscout:"OpenScout",workspace:"Workspace",unknown:"Other"},$we={active:"Active",archived:"Archived",blocked:"Blocked",completed:"Complete",draft:"Draft",unknown:"Unknown"};function Lwe(e){const t=e.replace(/\\/g,"/").replace(/\/+$/g,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function Pwe(e){return e.steps.length===0?"No steps":`${e.steps.filter(n=>n.status==="completed").length}/${e.steps.length} steps`}function Dwe(e){return[e.title,e.summary,e.source,e.documentKind,e.status,e.path,e.workspaceName,e.agentName,e.tags.join(" "),e.steps.map(t=>t.text).join(" ")].filter(Boolean).join(" ").toLowerCase()}function zwe(){const{route:e,navigate:t}=qe(),[n,r]=m.useState(null),[a,o]=m.useState(""),[c,u]=m.useState("all"),[f,h]=m.useState(!0),p=m.useCallback(async()=>{const E=await ue("/api/plan-documents").catch(()=>null);r(E),h(!1)},[]);m.useEffect(()=>{p()},[p]),Vt(E=>{(E.kind==="message.posted"||E.kind==="flight.updated"||E.kind==="collaboration.event.appended")&&p()});const x=n?.documents??[],v=e.view==="ops"&&e.mode==="plan"?e.planDocumentId:void 0,y=a.trim().toLowerCase(),b=m.useMemo(()=>{const E={all:x.length,claude:0,codex:0,openscout:0,workspace:0,unknown:0};for(const A of x)E[A.source]+=1;return E},[x]),C=m.useMemo(()=>x.filter(E=>c==="all"||E.source===c).filter(E=>!y||Dwe(E).includes(y)),[x,y,c]);return s.jsxs("div",{className:"s-plan-left-nav",children:[s.jsx("div",{className:"s-left-roster-search",children:s.jsx(tN,{value:a,onChange:o,placeholder:"Search plan documents...",onKeyDown:E=>{E.key==="Escape"&&(a?o(""):E.target.blur())}})}),s.jsx("div",{className:"s-plan-left-source-grid",children:["all","claude","codex","openscout","workspace"].map(E=>s.jsxs("button",{type:"button",className:`s-plan-left-source${c===E?" s-plan-left-source--active":""}`,onClick:()=>u(E),children:[s.jsx("span",{children:d2[E]}),s.jsx("strong",{children:b[E]})]},E))}),s.jsx("div",{className:"s-plan-left-list",children:f&&x.length===0?s.jsx("div",{className:"s-left-roster-empty",children:"Indexing plan documents..."}):C.length===0?s.jsx("div",{className:"s-left-roster-empty",children:x.length===0?"No plan documents found":"No plans match"}):C.map(E=>s.jsxs("button",{type:"button",className:`s-plan-left-document${E.id===v?" s-plan-left-document--active":""}`,onClick:()=>t({view:"ops",mode:"plan",planDocumentId:E.id}),title:`${E.path}
187
- ${E.summary??""}`,children:[s.jsxs("div",{className:"s-plan-left-document-top",children:[s.jsx("span",{className:`s-plan-left-status s-plan-left-status--${E.status}`,children:$we[E.status]}),s.jsx("span",{children:d2[E.source]}),s.jsx("time",{children:Ie(E.updatedAt)})]}),s.jsx("div",{className:"s-plan-left-document-title",children:E.title}),E.summary&&s.jsx("div",{className:"s-plan-left-document-summary",children:E.summary}),s.jsxs("div",{className:"s-plan-left-document-foot",children:[s.jsx("span",{children:Pwe(E)}),s.jsx("span",{children:Lwe(E.path)})]})]},E.id))})]})}const Bwe=new Set(["working","ready","not_ready"]);function Uwe(){const{agents:e,route:t,navigate:n}=qe(),[r,a]=m.useState(()=>new Set),[o,c]=m.useState(""),[u,f]=m.useState(Bwe),h=Xg(),p=zs(t),x=m.useMemo(()=>no(e,p),[e,p]),v=Rwe(o),y=v.length>0,b=T=>{f(R=>{const O=new Set(R);return O.has(T)?O.delete(T):O.add(T),O})},C=m.useMemo(()=>x.filter(T=>{const O=Ge(T.state);return u.has(O)?_we(T,v):!1}),[v,x,u]),E=m.useMemo(()=>Mwe(C),[C]),A=C[0]??null,S=t.view==="agents"?t.agentId:void 0,k=t.view==="agents"&&!t.agentId?t.projectKey:void 0,N=(T,R,O)=>{a(L=>{const I=new Set(L);return y?I.add(T):I.has(T)&&O?I.delete(T):I.add(T),I}),n({view:"agents",projectKey:R})};return s.jsxs("div",{className:"s-left-roster",children:[s.jsxs("div",{className:"s-left-roster-search",children:[s.jsx(tN,{value:o,onChange:c,placeholder:"Search agents or session IDs…",onKeyDown:T=>{T.key==="Escape"&&(o?c(""):T.target.blur()),T.key==="Enter"&&A&&u2(n,A,{observe:!!c2(A,v)})}}),s.jsx(U4,{active:u,onToggle:b})]}),s.jsx("div",{style:{flex:1,overflow:"auto"},children:x.length===0?s.jsx("div",{className:"s-left-roster-empty",children:p?"No agents on this machine":"No agents registered"}):C.length===0?s.jsx("div",{className:"s-left-roster-empty",children:"No agents match this session or agent search."}):E.map(T=>{const R=y||r.has(T.key),O=T.agents.some(_=>_.id===S),L=Twe(T),I=k===L,z=qwe(T.agents);return s.jsxs("div",{children:[s.jsx(_n,{name:T.label,meta:Gwe(T.agents),sub:`${T.agents.length} agents`,tone:T.bestState,caret:R?"open":"closed",active:I||O&&!R,selected:O&&!I,title:`${R&&I&&!y?"Collapse":"Open"} ${T.label}`,onClick:()=>{N(T.key,L,I)}}),R&&T.agents.map(_=>{const U=h.get(_.id),D=c2(_,v),q=z.has(_.id);return s.jsx(_n,{depth:1,name:_.name,meta:_.updatedAt?Ie(_.updatedAt):void 0,sub:Wwe(_,U,D,q),tone:Ge(_.state),avatarName:_.name,active:_.id===S,title:Kwe(_,U,D),onClick:()=>u2(n,_,{observe:!!D})},_.id)})]},T.key)})})]})}const Fwe="⎇";function Vwe(e){return(e.conversationId??e.harnessSessionId??"").slice(-5)}function Hwe(e){return e.branch?`${Fwe} ${e.branch}`:null}function Wwe(e,t,n,r){if(n)return`session · ${n}`;if(t)return t.task;const a=[],o=Hwe(e);if(o&&a.push(o),r){const c=Vwe(e);c&&a.push(`#${c}`)}return a.length>0?a.join(" · "):void 0}function qwe(e){const t=new Map;for(const r of e){const a=`${r.name}::${r.branch??""}`;t.set(a,(t.get(a)??0)+1)}const n=new Set;for(const r of e){const a=`${r.name}::${r.branch??""}`;(t.get(a)??0)>1&&n.add(r.id)}return n}function Kwe(e,t,n){const r=[];return t&&r.push(`task: ${t.task}`),e.branch&&r.push(`branch: ${e.branch}`),e.harness&&r.push(`harness: ${e.harness}`),n&&r.push(`session: ${n}`),r.length>0?r.join(`
188
- `):void 0}function Gwe(e){let t=0,n=0,r=0;for(const o of e){const c=Ge(o.state);c==="working"?t+=1:c==="ready"?n+=1:r+=1}const a=[];return t&&a.push(`${t}w`),n&&a.push(`${n}r`),r&&!t&&!n&&a.push(`${r}nr`),a.length===0?`${e.length}`:a.join(" · ")}function Zwe(){const e=xP(),t=yP(),n=ij({url:e,healthUrl:t,autoConnect:!0,sessionKey:"scout-terminal"});return s.jsx("div",{style:{height:"100%",background:"#0d0d0d",overflow:"hidden"},children:s.jsx(oj,{relay:n,fontSize:13,configItems:[{label:"ws",value:e},{label:"health",value:t}]})})}function Ywe(){const{onboarding:e}=qe();return e?e.hasLocalConfig?e.hasOperatorName?e.hasProjectConfig?e.needed!==!1&&(!e.brokerReachable||!e.hasReadyRuntime)?s.jsx(Om,{children:s.jsx(eje,{})}):null:s.jsx(Om,{children:s.jsx(Jwe,{})}):s.jsx(Om,{children:s.jsx(Qwe,{})}):s.jsx(Om,{children:s.jsx(Xwe,{})}):null}function Om({children:e}){return s.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",overflow:"auto",background:"var(--bg)",color:"var(--ink)"},children:s.jsx("div",{style:{width:"100%",maxWidth:720,padding:"80px 72px",display:"flex",flexDirection:"column",gap:40},children:e})})}function Qg({eyebrow:e,title:t,description:n}){return s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[s.jsx("div",{style:tje,children:e}),s.jsx("div",{style:nje,children:t}),s.jsx("div",{style:sje,children:n})]})}function Jg({primary:e,onPrimary:t,primaryDisabled:n,busy:r}){const{skipOnboarding:a}=qe();return s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:24,paddingTop:8},children:[s.jsx("button",{type:"button",onClick:t,disabled:n||r,style:{...aje,opacity:n||r?.5:1,cursor:n||r?"default":"pointer"},children:r?"Working…":e}),s.jsx("button",{type:"button",onClick:a,style:ije,onMouseEnter:o=>{o.currentTarget.style.color="rgba(255,255,255,0.8)"},onMouseLeave:o=>{o.currentTarget.style.color="rgba(255,255,255,0.45)"},children:"Skip for now"})]})}function ev({message:e}){return e?s.jsx("div",{style:{borderRadius:8,border:"1px solid rgba(239,68,68,0.35)",backgroundColor:"rgba(239,68,68,0.08)",color:"rgba(252,165,165,0.95)",padding:"12px 16px",fontSize:12,lineHeight:1.5},children:e}):null}function Xwe(){const{onboarding:e,refreshOnboarding:t}=qe(),[n,r]=m.useState(!1),[a,o]=m.useState(null),c=async()=>{r(!0),o(null);try{await ue("/api/onboarding/init",{method:"POST",body:"{}"}),await t()}catch(u){o(u instanceof Error?u.message:String(u))}finally{r(!1)}};return s.jsxs(s.Fragment,{children:[s.jsx(Qg,{eyebrow:"First-run setup",title:"Welcome to Scout",description:s.jsxs(s.Fragment,{children:["Scout needs a local config before it can talk to the broker, the web app, and paired devices. This writes"," ",s.jsx("code",{style:Uw,children:"~/.openscout/config.json"})," with sensible defaults — you can edit it any time."]})}),s.jsxs("ul",{style:V4,children:[s.jsx(Pd,{label:"Local config (~/.openscout/config.json)",done:!1,hint:"missing"}),s.jsx(Pd,{label:".openscout/project.json in a repo",done:!!e?.hasProjectConfig,hint:e?.hasProjectConfig?e.projectRoot??void 0:"checked after setup"})]}),s.jsx(ev,{message:a}),s.jsx(Jg,{primary:"Initialize Scout",onPrimary:()=>{c()},busy:n})]})}function Qwe(){const{onboarding:e,refreshOnboarding:t}=qe(),n=e?.operatorNameSuggestion??"",[r,a]=m.useState(n),[o,c]=m.useState(!1),[u,f]=m.useState(null);m.useEffect(()=>{!r&&n&&a(n)},[n,r]);const h=async()=>{const p=r.trim();if(!p){f("Name is required.");return}c(!0),f(null);try{await ue("/api/user",{method:"POST",body:JSON.stringify({name:p})}),await t()}catch(x){f(x instanceof Error?x.message:String(x))}finally{c(!1)}};return s.jsxs(s.Fragment,{children:[s.jsx(Qg,{eyebrow:"Identity",title:"What should we call you?",description:"Your name shows up on messages you send and in any agent that speaks for you. You can change it later in Settings."}),s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[s.jsx("label",{style:mp,children:"Your name"}),s.jsx("input",{autoFocus:!0,value:r,onChange:p=>{a(p.target.value),f(null)},onKeyDown:p=>{p.key==="Enter"&&h()},placeholder:n||"Operator",style:Bw}),n?s.jsx("div",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",fontFamily:"var(--hud-font-mono)"},children:"Prefilled from your machine."}):null]}),s.jsx(ev,{message:u}),s.jsx(Jg,{primary:"Continue",onPrimary:()=>{h()},busy:o,primaryDisabled:!r.trim()})]})}function Jwe(){const{onboarding:e,refreshOnboarding:t}=qe(),n=e?.currentDirectory??"",[r,a]=m.useState([n||"~/dev"]),[o,c]=m.useState(n),[u,f]=m.useState("claude"),[h,p]=m.useState(!1),[x,v]=m.useState(null),y=(A,S)=>{a(k=>k.map((N,T)=>T===A?S:N))},b=()=>a(A=>[...A,""]),C=A=>a(S=>S.filter((k,N)=>N!==A)),E=async()=>{const A=r.map(k=>k.trim()).filter(Boolean),S=o.trim();if(!S){v("Pick where Scout should anchor this context.");return}p(!0),v(null);try{await ue("/api/onboarding/project",{method:"POST",body:JSON.stringify({contextRoot:S,sourceRoots:A,defaultHarness:u})}),await t()}catch(k){v(k instanceof Error?k.message:String(k))}finally{p(!1)}};return s.jsxs(s.Fragment,{children:[s.jsx(Qg,{eyebrow:"Project",title:"Where do your repos live?",description:s.jsxs(s.Fragment,{children:["Scout scans these folders for projects and anchors this context at"," ",s.jsx("code",{style:Uw,children:"<context>/.openscout/project.json"}),"."]})}),s.jsxs("div",{style:qb,children:[s.jsx("label",{style:mp,children:"Scan folders"}),s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[r.map((A,S)=>s.jsxs("div",{style:{display:"flex",gap:8},children:[s.jsx("input",{value:A,onChange:k=>y(S,k.target.value),placeholder:S===0?"~/dev":"Add another folder",style:{...Bw,flex:1}}),s.jsx("button",{type:"button",onClick:()=>C(S),disabled:r.length<=1,style:{...f2,opacity:r.length<=1?.4:1,cursor:r.length<=1?"default":"pointer"},"aria-label":`Remove folder ${S+1}`,children:"−"})]},S)),s.jsx("button",{type:"button",onClick:b,style:{...f2,alignSelf:"flex-start"},children:"+ Add folder"})]})]}),s.jsxs("div",{style:qb,children:[s.jsx("label",{style:mp,children:"Context root"}),s.jsx("input",{value:o,onChange:A=>c(A.target.value),placeholder:"~/dev",style:Bw}),s.jsxs("div",{style:rje,children:["Scout writes ",s.jsx("code",{style:Uw,children:".openscout/project.json"})," ","inside this folder."]})]}),s.jsxs("div",{style:qb,children:[s.jsx("label",{style:mp,children:"Default harness"}),s.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:["claude","codex"].map(A=>{const S=u===A;return s.jsxs("button",{type:"button",onClick:()=>f(A),style:{...oje,borderColor:S?"var(--accent, #2dd4bf)":"rgba(255,255,255,0.12)",backgroundColor:S?"rgba(45,212,191,0.08)":"rgba(255,255,255,0.02)"},children:[s.jsx("div",{style:{fontSize:15,fontWeight:600,textTransform:"capitalize"},children:A}),s.jsx("div",{style:{fontSize:12,color:"rgba(255,255,255,0.55)",marginTop:6,lineHeight:1.5},children:A==="claude"?"Anthropic Claude Code — local CLI agent.":"OpenAI Codex — cloud agentic sandbox."})]},A)})})]}),s.jsx(ev,{message:x}),s.jsx(Jg,{primary:"Create project",onPrimary:()=>{E()},busy:h,primaryDisabled:!o.trim()})]})}function eje(){const{onboarding:e,refreshOnboarding:t}=qe(),[n,r]=m.useState(!1),[a,o]=m.useState(null),c=async()=>{r(!0),o(null);try{const u=await ue("/api/onboarding/setup",{method:"POST",body:"{}"});await t(),u.brokerWarning?o(u.brokerWarning):u.hasReadyRuntime===!1&&o("Setup ran, but no ready runtime was found yet. Install or sign into Claude Code or Codex, then run this again.")}catch(u){o(u instanceof Error?u.message:String(u))}finally{r(!1)}};return s.jsxs(s.Fragment,{children:[s.jsx(Qg,{eyebrow:"Setup",title:"Finish setup",description:"Scout will install its harness skills, start the local broker, refresh discovery, and check for a ready agent runtime."}),s.jsxs("ul",{style:V4,children:[s.jsx(Pd,{label:".openscout/project.json",done:!!e?.hasProjectConfig,hint:e?.projectConfigPath??e?.projectRoot??void 0}),s.jsx(Pd,{label:"Broker reachable",done:!!e?.brokerReachable,hint:e?.brokerReachable?"ready":"needs setup"}),s.jsx(Pd,{label:"Claude or Codex runtime",done:!!e?.hasReadyRuntime,hint:e?.hasReadyRuntime?"ready":"missing or not signed in"})]}),s.jsx(ev,{message:a}),s.jsx(Jg,{primary:"Run setup",onPrimary:()=>{c()},busy:n})]})}function Pd({label:e,done:t,hint:n}){return s.jsxs("li",{style:{display:"flex",alignItems:"flex-start",gap:16},children:[s.jsx("span",{style:{marginTop:2,width:20,height:20,borderRadius:999,display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:700,flexShrink:0,backgroundColor:t?"rgba(34,197,94,0.15)":"rgba(239,68,68,0.12)",color:t?"#4ade80":"#f87171"},children:t?"✓":"•"}),s.jsxs("div",{style:{minWidth:0},children:[s.jsx("div",{style:{fontSize:13,lineHeight:1.5,color:t?"rgba(255,255,255,0.75)":"rgba(255,255,255,0.9)"},children:e}),n?s.jsx("div",{style:{fontSize:11,fontFamily:"var(--hud-font-mono)",color:"rgba(255,255,255,0.35)",marginTop:4,wordBreak:"break-all"},children:n}):null]})]})}const tje={fontSize:11,fontFamily:"var(--hud-font-mono)",textTransform:"uppercase",letterSpacing:"0.18em",color:"rgba(255,255,255,0.4)"},nje={fontSize:36,fontWeight:600,letterSpacing:"-0.01em",lineHeight:1.15},sje={fontSize:15,lineHeight:1.75,color:"rgba(255,255,255,0.6)",maxWidth:580},qb={display:"flex",flexDirection:"column",gap:10},mp={fontSize:11,fontFamily:"var(--hud-font-mono)",textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255,255,255,0.5)"},Bw={width:"100%",padding:"10px 14px",fontSize:14,fontFamily:"var(--hud-font-mono)",color:"rgba(255,255,255,0.92)",backgroundColor:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,outline:"none",boxSizing:"border-box"},rje={fontSize:12,color:"rgba(255,255,255,0.45)",lineHeight:1.6},Uw={fontFamily:"var(--hud-font-mono)",fontSize:12,padding:"2px 6px",borderRadius:4,backgroundColor:"rgba(255,255,255,0.06)"},aje={fontSize:13,fontWeight:600,padding:"12px 24px",borderRadius:10,backgroundColor:"var(--accent, #2dd4bf)",color:"#0b0d12",border:"none",transition:"opacity 0.15s ease"},f2={fontSize:13,fontWeight:500,padding:"10px 14px",borderRadius:8,backgroundColor:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.12)",color:"rgba(255,255,255,0.85)",transition:"all 0.15s ease"},ije={fontSize:12,color:"rgba(255,255,255,0.45)",textDecoration:"underline dotted rgba(255,255,255,0.25)",textUnderlineOffset:4,background:"none",border:"none",cursor:"pointer",padding:"4px 2px",transition:"color 0.15s ease"},V4={display:"flex",flexDirection:"column",gap:20,margin:0,padding:0,listStyle:"none"},oje={textAlign:"left",padding:"16px 18px",borderRadius:12,border:"1px solid rgba(255,255,255,0.12)",color:"rgba(255,255,255,0.9)",cursor:"pointer",transition:"all 0.15s ease"},lje=[{commandId:"nav:home",title:"Go to Home",description:"Navigate to the home overview showing queue, threads, signal, and activity",category:"navigation",keywords:["home","inbox","dashboard"],shortcut:"Cmd+1"},{commandId:"nav:agents",title:"Go to Agents",description:"Navigate to the agents roster showing all registered agents",category:"navigation",keywords:["agents","roster","list"],shortcut:"Cmd+2"},{commandId:"nav:fleet",title:"Open Home Overview",description:"Navigate to the home overview with agent status summary",category:"navigation",keywords:["home","fleet","overview","status"]},{commandId:"nav:messages",title:"Go to Chat",description:"Navigate to the unified chat surface backed by the normalized conversations service",category:"navigation",keywords:["conversations","comms","chat","threads"],shortcut:"Cmd+3"},{commandId:"nav:sessions",title:"Open Sessions",description:"Navigate to the sessions list showing all active conversations",category:"navigation",keywords:["sessions","conversations","threads"]},{commandId:"nav:search",title:"Go to Search",description:"Navigate to the session knowledge search surface for extraction, search, and raw-log drilldown planning",category:"navigation",keywords:["search","knowledge","qmd","history"],shortcut:"Cmd+4"},{commandId:"nav:messages-channels",title:"Go to Chat - Shared",description:"Navigate to the shared-channel chat browser",category:"navigation",keywords:["channels","channel","group","broadcast"]},{commandId:"nav:activity",title:"Open Activity",description:"Navigate to the activity feed showing recent events",category:"navigation",keywords:["activity","feed","events","log"]},{commandId:"nav:mesh",title:"Open Mesh",description:"Navigate to the mesh network view showing nodes and topology",category:"navigation",keywords:["mesh","network","nodes","peers","topology"]},{commandId:"nav:dispatch",title:"Open Dispatch",description:"Navigate to the dispatch ledger for routing, delivery attempts, and failed queries",category:"navigation",keywords:["dispatch","broker","routing","delivery","messages"]},{commandId:"nav:harnesses",title:"Open Providers",description:"Open the central view for providers, harnesses, observed topology, and budget feeds",category:"navigation",keywords:["provider","providers","harness","harnesses","claude","codex","budget","usage","topology"]},{commandId:"nav:ops",title:"Go to Ops",description:"Navigate to the operator workspace for dispatch, mesh, tail, runtime, alerts, and agent operations",category:"navigation",keywords:["ops","operator","control","tail","runtime","services","atop","dispatch","mesh"],shortcut:"Cmd+5"},{commandId:"nav:ops-atop",title:"Open Runtime",description:"Open the live agent/process view with observed harness families",category:"navigation",keywords:["runtime","services","atop","process","session","agent","topology"]},{commandId:"nav:workflow-topology",title:"Open Workflow Topology",description:"Open the observed Claude workflow hierarchy and worker topology",category:"navigation",keywords:["workflow","workflows","topology","subagents","claude"]},{commandId:"nav:settings",title:"Open Settings",description:"Open the settings screen for pairing, identity, and relay config",category:"settings",keywords:["settings","preferences","config","pair"],shortcut:"Cmd+,"},{commandId:"nav:agent-config",title:"Open Agent Configuration",description:"Open the unified agent configuration surface for runtimes, agents, tools, delivery, and broker state",category:"settings",keywords:["agent config","runtimes","providers","mcp","tools"]},{commandId:"nav:pair",title:"Pair Device",description:"Open the device pairing flow to connect a mobile device",category:"settings",keywords:["pair","qr","device","phone","mobile"]},{commandId:"scout:reload",title:"Reload Agents",description:"Refresh the agent list and message state from the broker",category:"workspace",keywords:["reload","refresh","sync"]},{commandId:"scout:open:*",title:"Open Agent Conversation",description:"Open the DM lane for one specific agent. One agent maps to a DM; group work belongs in an explicit channel and broadcasts belong in the shared channel.",category:"navigation",keywords:["open","chat","conversation","dm","message"],params:[{name:"agentId",description:"The agent identifier to open",type:"string"}]},{commandId:"scout:send:*",title:"Tell Agent",description:"Open or compose the DM tell/update path for one specific agent. Use Tell for heads-up, replies, status, and steering an active turn inside the same DM.",category:"workspace",keywords:["tell","message","update","dm","reply","steer"],params:[{name:"agentId",description:"The agent identifier to tell",type:"string"},{name:"message",description:"The message body to send",type:"string"}]},{commandId:"scout:ask:*",title:"Ask Agent",description:"Open the DM ask path for one specific agent. Use Ask when the meaning is 'own this work and get back to me' and keep follow-up in the same DM.",category:"workspace",keywords:["ask","assign","task","dm","work","reply"],params:[{name:"agentId",description:"The agent identifier to ask",type:"string"},{name:"message",description:"The message body to send",type:"string"}]},{commandId:"scout:interrupt:*",title:"Interrupt Agent",description:"Send Ctrl-C to interrupt a working agent. The commandId is scout:interrupt:{agentId}.",category:"workspace",keywords:["stop","interrupt","cancel","halt","kill"],dangerous:!0,params:[{name:"agentId",description:"The agent identifier to interrupt",type:"string"}]}];function H4(e={}){const{initialTheme:t="dark"}=e;return{id:"openscout",name:"Scout",description:"All your agents, one message away. Scout is a control plane for managing coding agents: one agent means a DM, group work means an explicit channel, Tell stays conversational, Ask is owned work with a reply path, and shared updates mean broadcast.",mode:"panel",icon:m.createElement(Zb,{size:14,strokeWidth:1.2}),Provider:({children:n})=>m.createElement(bae,{initialTheme:t,children:n}),leftPanel:{title:"Navigation"},rightPanel:{title:"Context"},slots:{Content:uye,LeftPanel:Owe,Inspector:r0e,Takeover:Ywe,Terminal:Zwe},intents:lje,hooks:{useCommands:Tae,useStatus:Mae,useNavCenter:Rae,useNavActions:Iae,useLayoutMode:_ae,useTakeover:Oae}}}H4();const cje=2500;function uje(e){return e?e.length>18?`${e.slice(0,8)}...${e.slice(-6)}`:e:"no session"}function dje({agentId:e}){const[t,n]=m.useState(null),[r,a]=m.useState(!0),[o,c]=m.useState(null),u=m.useCallback(async(f=!1)=>{f||a(!0),c(null);try{const h=await ue(`/api/agents/${encodeURIComponent(e)}/observe`);n(h)}catch(h){f||n(null),c(h instanceof Error?h.message:String(h))}finally{a(!1)}},[e]);return m.useEffect(()=>{u();const f=window.setInterval(()=>{u(!0)},cje);return()=>window.clearInterval(f)},[u]),Vt(()=>{u(!0)}),o&&!t?s.jsx("div",{className:"s-observe-embed-page",children:s.jsxs("div",{className:"s-observe-embed-empty",children:[s.jsx("div",{className:"s-observe-embed-empty-title",children:"Observe unavailable"}),s.jsx("div",{className:"s-observe-embed-empty-detail",children:o})]})}):r&&!t?s.jsx("div",{className:"s-observe-embed-page",children:s.jsxs("div",{className:"s-observe-embed-empty",children:[s.jsx("div",{className:"s-observe-embed-empty-title",children:"Resolving trace"}),s.jsx("div",{className:"s-observe-embed-empty-detail",children:e})]})}):s.jsxs("div",{className:"s-observe-embed-page",children:[t&&s.jsxs("div",{className:"s-observe-embed-status",children:[s.jsx("span",{className:"s-observe-embed-status-source",children:t.source}),s.jsx("span",{children:t.fidelity}),s.jsx("span",{title:t.sessionId??void 0,children:uje(t.sessionId)}),s.jsxs("span",{children:[t.data.events.length," events"]}),t.data.live&&s.jsx("span",{className:"s-observe-embed-status-live",children:"Live"})]}),s.jsx(qg,{data:t?.data,agentId:e,sessionId:t?.sessionId,showRail:!1})]})}const fje=["unstaged","staged","branch"];function hje(e){const t=e.getAll("layer").filter(n=>fje.includes(n));return t.length>0?t:void 0}function mje(){const e=typeof window>"u"?new URLSearchParams:new URLSearchParams(window.location.search),t=e.get("path")?.trim()??"";return t?s.jsx(Fk,{path:t,layers:hje(e),className:"rd-embed"}):s.jsx("div",{className:"rd-viewer rd-embed","data-scout-theme":!0,children:s.jsx("div",{className:"rd-center",children:s.jsxs("div",{className:"rd-center-card",children:[s.jsx("div",{className:"rd-center-title",children:"No worktree path"}),s.jsxs("div",{className:"rd-center-body",children:["This embed needs a ",s.jsx("code",{children:"?path=<absolute-path>"})," query parameter."]})]})})})}const pje=2500;function gje(e){return e?e.length>18?`${e.slice(0,8)}...${e.slice(-6)}`:e:"no session"}function Fw({children:e}){return s.jsx("div",{className:"s-observe-embed-page",children:e})}function $m({title:e,detail:t}){return s.jsx(Fw,{children:s.jsxs("div",{className:"s-observe-embed-empty",children:[s.jsx("div",{className:"s-observe-embed-empty-title",children:e}),t&&s.jsx("div",{className:"s-observe-embed-empty-detail",children:t})]})})}function vje(){const e=typeof window>"u"?"":new URLSearchParams(window.location.search).get("ref")?.trim()??"",[t,n]=m.useState(null),[r,a]=m.useState(!0),[o,c]=m.useState(null),u=m.useCallback(async(f=!1)=>{if(!e){a(!1);return}f||a(!0),c(null);try{const h=await ue(`/api/session-ref/${encodeURIComponent(e)}`);n(h)}catch(h){f||n(null),c(h instanceof Error?h.message:String(h))}finally{a(!1)}},[e]);return m.useEffect(()=>{u();const f=window.setInterval(()=>{u(!0)},pje);return()=>window.clearInterval(f)},[u]),Vt(()=>{u(!0)}),e?o&&!t?s.jsx($m,{title:"Session unavailable",detail:o}):r&&!t?s.jsx($m,{title:"Resolving session",detail:e}):t?t.kind==="conversation"?s.jsx(Fw,{children:s.jsx(eu,{conversationId:t.conversationId,navigate:()=>{},embedded:!0,showBackNav:!1})}):s.jsxs(Fw,{children:[s.jsxs("div",{className:"s-observe-embed-status",children:[s.jsx("span",{className:"s-observe-embed-status-source",children:t.observe.source}),s.jsx("span",{children:t.observe.fidelity}),s.jsx("span",{title:t.observe.sessionId??void 0,children:gje(t.observe.sessionId??t.observe.refId)}),s.jsxs("span",{children:[t.observe.data.events.length," events"]}),t.observe.data.live&&s.jsx("span",{className:"s-observe-embed-status-live",children:"Live"})]}),s.jsx(qg,{data:t.observe.data,agentId:t.observe.agentId??t.session?.agentId??void 0,sessionId:t.observe.sessionId??t.observe.refId,showRail:!1})]}):s.jsx($m,{title:"Session not found",detail:"This session may have ended or its archive is not on this machine."}):s.jsx($m,{title:"No session reference",detail:"This embed needs a ?ref=<sessionId> query parameter."})}function h2(e){return e==="dark"||e==="light"?e:null}function xje(){if(typeof window>"u")return"dark";const e=h2(gne());if(e)return e;const t=h2(new URLSearchParams(window.location.search).get("theme"));return t||"dark"}function yje(e){typeof document>"u"||(document.documentElement.dataset.scoutThemeMode=e,document.documentElement.style.colorScheme=e)}const bje=[{title:"Tone (band-pass)",sliders:[{key:"lowCutHz",label:"Low cut",min:80,max:1200,step:10,format:e=>`${e.toFixed(0)} Hz`},{key:"highCutHz",label:"High cut",min:1500,max:6e3,step:50,format:e=>`${e.toFixed(0)} Hz`},{key:"bandQ",label:"Filter Q",min:.2,max:2,step:.05,format:e=>e.toFixed(2)}]},{title:"Grit (saturation + bit-crush)",sliders:[{key:"saturationAmount",label:"Saturation",min:0,max:1,step:.01,format:e=>e.toFixed(2)},{key:"bitcrushAmount",label:"Bit-crush",min:0,max:1,step:.01,format:e=>e.toFixed(2)}]},{title:"Carrier hiss",sliders:[{key:"hissGain",label:"Hiss level",min:0,max:.25,step:.005,format:e=>e.toFixed(3)},{key:"hissCutoffHz",label:"Hiss high-pass",min:300,max:4e3,step:50,format:e=>`${e.toFixed(0)} Hz`}]},{title:"Presence (mid-band peak — comm intelligibility)",sliders:[{key:"presencePeakDb",label:"Boost",min:0,max:12,step:.5,format:e=>`${e.toFixed(1)} dB`},{key:"presenceCenterHz",label:"Center",min:600,max:3e3,step:50,format:e=>`${e.toFixed(0)} Hz`},{key:"presenceQ",label:"Q (narrowness)",min:.3,max:3,step:.1,format:e=>e.toFixed(1)}]},{title:"Squelch tail (channel-drop noise)",sliders:[{key:"squelchTailGain",label:"Tail gain",min:0,max:.3,step:.005,format:e=>e.toFixed(3)},{key:"squelchTailDurationMs",label:"Tail length",min:40,max:500,step:10,format:e=>`${e.toFixed(0)} ms`}]},{title:"Compressor",sliders:[{key:"compressorThresholdDb",label:"Threshold",min:-60,max:0,step:1,format:e=>`${e.toFixed(0)} dB`},{key:"compressorRatio",label:"Ratio",min:1,max:12,step:.5,format:e=>`${e.toFixed(1)} : 1`}]},{title:"Delivery",sliders:[{key:"playbackRate",label:"Speed (pitch-shifts)",min:.75,max:1.35,step:.01,format:e=>`${e.toFixed(2)}×`}]},{title:"Kerchunk / output",sliders:[{key:"clickGain",label:"Click gain",min:0,max:1,step:.01,format:e=>e.toFixed(2)},{key:"clickDurationMs",label:"Click length",min:20,max:200,step:5,format:e=>`${e.toFixed(0)} ms`},{key:"outputGain",label:"Output gain",min:0,max:2,step:.05,format:e=>e.toFixed(2)},{key:"wetMix",label:"Wet mix",min:0,max:1,step:.01,format:e=>e.toFixed(2)}]}],m2=.12,wje=e=>Math.max(.7,Math.min(1.45,e)),jje=220,Vw={...Wg,lowCutHz:160,highCutHz:5200,bandQ:.35,saturationAmount:.035,bitcrushAmount:0,hissGain:0,hissCutoffHz:1800,presencePeakDb:1.5,presenceCenterHz:1500,presenceQ:.65,compressorThresholdDb:-15,compressorRatio:2.2,clickEnabled:!0,clickGain:.24,clickDurationMs:45,squelchTailEnabled:!0,squelchTailGain:.018,squelchTailDurationMs:95,playbackRate:1,outputGain:1,wetMix:.38},kje={...Vw,lowCutHz:190,highCutHz:5e3,saturationAmount:.055,bitcrushAmount:.01,hissGain:.006,presencePeakDb:2.5,compressorThresholdDb:-17,compressorRatio:2.8,clickGain:.28,squelchTailGain:.024,squelchTailDurationMs:105,wetMix:.44};function Nje(e){return`const SCOUTBOT_VOICE_FX: Partial<VoiceFxParams> = {
189
- ${Object.entries(e).map(([n,r])=>` ${n}: ${typeof r=="number"?Number(r.toFixed(3)):String(r)},`).join(`
190
- `)}
191
- };`}function Sje(){const[e,t]=m.useState(null),[n,r]=m.useState(null),[a,o]=m.useState({}),[c,u]=m.useState(Vw),[f,h]=m.useState(null),[p,x]=m.useState(null),[v,y]=m.useState(null),[b,C]=m.useState(!1),[E,A]=m.useState(!1),S=m.useRef(null),k=m.useRef(null),N=m.useRef(c),T=m.useRef(b),R=m.useRef(E);m.useEffect(()=>{N.current=c},[c]),m.useEffect(()=>{T.current=b},[b]),m.useEffect(()=>{R.current=E},[E]),m.useEffect(()=>{let $=!1;return(async()=>{try{const G=await fetch("/api/dev/scoutbot-fx/fixtures");if(!G.ok)throw new Error(`HTTP ${G.status}`);const V=await G.json();$||t(V)}catch(G){$||r(G instanceof Error?G.message:String(G))}})(),()=>{$=!0}},[]);const O=m.useCallback(async $=>{if(a[$.slug])return a[$.slug].buffer;const G=await vle(`/api/dev/scoutbot-fx/audio/${encodeURIComponent($.file)}`);return o(V=>({...V,[$.slug]:{fixture:$,buffer:G}})),G},[a]),L=m.useCallback(()=>{k.current=null,S.current?.stop(),S.current=null,x(null)},[]),I=m.useCallback($=>{const G=af.find(V=>V.id===$);G&&(u(G.params),h($))},[]),z=m.useCallback(async()=>{try{await navigator.clipboard.writeText(Nje(c)),y("Copied"),window.setTimeout(()=>y(null),1600)}catch($){y($ instanceof Error?$.message:"Copy failed")}},[c]),_=m.useCallback(async($,G)=>{L();const V=Symbol(`${G}:${$.slug}`);k.current=V;const Y=`${G}:${$.slug}`;try{const K=await O($);for(;k.current===V;){const P=R.current?{...N.current,playbackRate:wje(N.current.playbackRate+(Math.random()*2-1)*m2)}:N.current,H=G==="fx"?bk(K,{params:P}):jle(K);if(S.current=H,x(Y),await H.promise,k.current!==V||!T.current)break;await new Promise(B=>{const Q=setTimeout(B,jje),oe=setInterval(()=>{k.current!==V&&(clearTimeout(Q),clearInterval(oe),B())},40)})}}catch(K){console.error(`[scoutbot-fx] ${G} playback failed`,K)}finally{k.current===V&&(k.current=null),S.current=null,x(K=>K===Y?null:K)}},[O,L]),U=m.useCallback($=>_($,"fx"),[_]),D=m.useCallback($=>_($,"dry"),[_]),q=m.useMemo(()=>bje.map($=>({title:$.title,rows:$.sliders.map(G=>({spec:G,value:c[G.key]}))})),[c]),Z=e?.fixtures??[];return s.jsxs("div",{style:Cje,children:[s.jsxs("header",{style:Eje,children:[s.jsxs("div",{children:[s.jsx("h1",{style:Aje,children:"Scoutbot FX Lab"}),s.jsxs("p",{style:Tje,children:["Dispatcher-radio FX prototyping. Generate fixtures with"," ",s.jsx("code",{style:p2,children:"node packages/web/scripts/generate-scoutbot-fx-fixtures.mjs"}),"."]})]}),s.jsxs("div",{style:Mje,children:[e?.generatedAt?s.jsxs("span",{children:["Fixtures generated ",new Date(e.generatedAt).toLocaleString()]}):null,e?.note?s.jsx("span",{style:Rje,children:e.note}):null,n?s.jsxs("span",{style:Ije,children:["Could not load fixtures: ",n]}):null]})]}),s.jsxs("section",{style:_je,children:[s.jsxs("div",{style:Kb,children:[s.jsx("h2",{style:Gb,children:"Presets"}),s.jsx("div",{style:Oje,children:"Click to load. Tweaking any slider clears the active preset."})]}),s.jsx("div",{style:$je,children:af.map($=>{const G=f===$.id;return s.jsxs("button",{type:"button",style:G?Lje:W4,onClick:V=>{I($.id),V.currentTarget.blur()},title:$.description,children:[s.jsxs("div",{style:G?Pje:q4,children:[$.label,s.jsx("span",{style:zje,children:$.family})]}),s.jsx("div",{style:G?Dje:K4,children:$.description})]},$.id)})})]}),s.jsxs("section",{style:Bje,children:[s.jsxs("div",{style:Kb,children:[s.jsx("h2",{style:Gb,children:"FX chain"}),s.jsxs("div",{style:{display:"flex",gap:8},children:[s.jsxs("label",{style:Lm,children:[s.jsx("input",{type:"checkbox",checked:c.clickEnabled,onChange:$=>{const G=$.target.checked;h(null),u(V=>({...V,clickEnabled:G}))}}),"Kerchunk click"]}),s.jsxs("label",{style:Lm,children:[s.jsx("input",{type:"checkbox",checked:c.squelchTailEnabled,onChange:$=>{const G=$.target.checked;h(null),u(V=>({...V,squelchTailEnabled:G}))}}),"Squelch tail"]}),s.jsx("button",{type:"button",style:bd,onClick:()=>{h("scoutbot-clean-dispatch"),u(Vw)},children:"Scoutbot default"}),s.jsx("button",{type:"button",style:bd,onClick:()=>{h("codex-clean-dispatch"),u(kje)},children:"Codex take"}),s.jsx("button",{type:"button",style:bd,onClick:()=>{h(null),u(Wg)},children:"Raw default"}),s.jsx("button",{type:"button",style:Hw,onClick:()=>{z()},children:v??"Copy params"})]})]}),s.jsx("div",{style:Uje,children:q.map($=>s.jsxs("div",{style:Fje,children:[s.jsx("div",{style:Vje,children:$.title}),s.jsx("div",{style:Hje,children:$.rows.map(({spec:G,value:V})=>s.jsxs("label",{style:Wje,children:[s.jsxs("div",{style:qje,children:[s.jsx("span",{children:G.label}),s.jsx("span",{style:Kje,children:G.format(V)})]}),s.jsx("input",{type:"range",min:G.min,max:G.max,step:G.step,value:V,onChange:Y=>{const K=Number(Y.target.value);h(null),u(P=>({...P,[G.key]:K}))}})]},G.key))})]},$.title))})]}),s.jsxs("section",{style:Gje,children:[s.jsxs("div",{style:Kb,children:[s.jsx("h2",{style:Gb,children:"Fixtures"}),s.jsxs("div",{style:{display:"flex",gap:16},children:[s.jsxs("label",{style:Lm,children:[s.jsx("input",{type:"checkbox",checked:b,onChange:$=>C($.target.checked)}),"Loop playback",b?" (tweaks apply next iteration)":""]}),s.jsxs("label",{style:Lm,children:[s.jsx("input",{type:"checkbox",checked:E,onChange:$=>A($.target.checked)}),"Vary speed ±",Math.round(m2*100),"%"]})]})]}),e?Z.length===0?s.jsxs("p",{style:g2,children:["No fixtures yet. Run"," ",s.jsx("code",{style:p2,children:"node packages/web/scripts/generate-scoutbot-fx-fixtures.mjs"})," ","(Vox must be running) and reload."]}):s.jsx("ul",{style:Zje,children:Z.map($=>{const G=p===`dry:${$.slug}`,V=p===`fx:${$.slug}`;return s.jsxs("li",{style:Yje,children:[s.jsxs("div",{style:Xje,children:[s.jsx("div",{style:Qje,children:$.slug}),s.jsx("div",{style:Jje,children:$.text}),s.jsxs("div",{style:eke,children:[$.voiceId?`voice ${$.voiceId}`:null,$.voiceId&&$.bytes?" · ":null,$.bytes?`${Math.round($.bytes/1024)} KB`:null]})]}),s.jsxs("div",{style:tke,children:[s.jsx("button",{type:"button",style:G?nke:bd,onClick:()=>G?L():D($),children:G?"Stop":"Play dry"}),s.jsx("button",{type:"button",style:V?ske:Hw,onClick:()=>V?L():U($),children:V?"Stop":"Play with FX"})]})]},$.slug)})}):s.jsx("p",{style:g2,children:"Loading…"})]})]})}const Cje={minHeight:"100vh",background:"#0b0d10",color:"#e6e8eb",padding:"32px 40px 64px",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"},Eje={display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:24,marginBottom:28},Aje={fontSize:22,fontWeight:600,margin:0},Tje={color:"#9aa1ab",fontSize:13,marginTop:6,marginBottom:0},Mje={display:"flex",flexDirection:"column",gap:4,fontSize:12,color:"#9aa1ab",alignItems:"flex-end"},Rje={color:"#f5b342"},Ije={color:"#ef6b6b"},p2={fontFamily:"ui-monospace, SFMono-Regular, monospace",background:"#181b20",padding:"1px 6px",borderRadius:4,fontSize:12},_je={background:"#121519",border:"1px solid #1f242b",borderRadius:10,padding:20,marginBottom:18},Oje={fontSize:11,color:"#6b727d"},$je={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:10,marginTop:12},W4={textAlign:"left",background:"#0f1216",border:"1px solid #1f242b",borderRadius:8,padding:"12px 14px",color:"#c5cad2",cursor:"pointer",display:"flex",flexDirection:"column",gap:6,fontFamily:"inherit",outline:"none",WebkitAppearance:"none",appearance:"none",transition:"border-color 80ms ease, background 80ms ease, color 80ms ease"},Lje={...W4,background:"#1a1f26",borderColor:"#f1f3f5",color:"#ffffff",boxShadow:"0 0 0 1px rgba(241,243,245,0.18)"},q4={fontSize:13,fontWeight:600,display:"flex",alignItems:"center",gap:8},Pje={...q4,color:"#ffffff"},K4={fontSize:11,color:"#9aa1ab",lineHeight:1.4},Dje={...K4,color:"#c5cad2"},zje={fontSize:9,fontWeight:500,letterSpacing:.6,textTransform:"uppercase",padding:"2px 6px",borderRadius:4,background:"rgba(255,255,255,0.06)",color:"#9aa1ab"},Bje={background:"#121519",border:"1px solid #1f242b",borderRadius:10,padding:20,marginBottom:28},Kb={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},Gb={fontSize:14,textTransform:"uppercase",letterSpacing:.6,color:"#9aa1ab",margin:0},Uje={display:"flex",flexDirection:"column",gap:18},Fje={display:"flex",flexDirection:"column",gap:10},Vje={fontSize:11,textTransform:"uppercase",letterSpacing:.8,color:"#6b727d",fontWeight:600},Hje={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},Wje={display:"flex",flexDirection:"column",gap:6,fontSize:12},qje={display:"flex",justifyContent:"space-between",color:"#c5cad2"},Kje={color:"#7f8693",fontFamily:"ui-monospace, SFMono-Regular, monospace"},Gje={background:"#121519",border:"1px solid #1f242b",borderRadius:10,padding:20},Zje={listStyle:"none",padding:0,margin:"16px 0 0",display:"flex",flexDirection:"column",gap:12},Yje={display:"flex",alignItems:"center",gap:16,background:"#0f1216",border:"1px solid #1f242b",borderRadius:8,padding:"14px 16px"},Xje={flex:1,display:"flex",flexDirection:"column",gap:4},Qje={fontFamily:"ui-monospace, SFMono-Regular, monospace",color:"#9aa1ab",fontSize:12},Jje={color:"#e6e8eb",fontSize:14},eke={color:"#6b727d",fontSize:11},tke={display:"flex",gap:8},bd={background:"#1c2128",color:"#e6e8eb",border:"1px solid #2a3038",padding:"6px 12px",borderRadius:6,fontSize:12,cursor:"pointer"},nke={...bd,background:"#2a3038",borderColor:"#3c4350"},Hw={background:"#2e6cdf",color:"#fff",border:"1px solid #2e6cdf",padding:"6px 12px",borderRadius:6,fontSize:12,cursor:"pointer"},ske={...Hw,background:"#1f57bf",borderColor:"#1f57bf"},Lm={display:"flex",alignItems:"center",gap:6,fontSize:12,color:"#c5cad2",cursor:"pointer"},g2={color:"#9aa1ab",fontSize:13,margin:"12px 0 0"},G4=document.getElementById("root");if(!G4)throw new Error("missing #root");const Z4=xje();yje(Z4);const rke=window.location.pathname==="/dev/scoutbot-fx",v2=window.location.pathname.match(/^\/embed\/observe\/([^/]+)$/),ake=window.location.pathname==="/embed/repo-diff",ike=window.location.pathname==="/embed/session",Pm=H4({initialTheme:Z4});u6.createRoot(G4).render(s.jsx(m.StrictMode,{children:rke?s.jsx(Sje,{}):v2?s.jsx(Pm.Provider,{children:s.jsx(dje,{agentId:decodeURIComponent(v2[1])})}):ake?s.jsx(Pm.Provider,{children:s.jsx(mje,{})}):ike?s.jsx(Pm.Provider,{children:s.jsx(vje,{})}):s.jsx(vie,{app:Pm})}));export{kpe as a,lke as b,Npe as f,x2 as g,s as j,m as r};