@openscout/scout 0.2.65 → 0.2.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -3
- package/dist/client/assets/addon-fit_hudsonkit_false-DSvcGNZx.js +1 -0
- package/dist/client/assets/addon-webgl_hudsonkit_false-1rrLEmjL.js +1 -0
- package/dist/client/assets/index-R2y6GOWl.js +184 -0
- package/dist/client/assets/index-bOmc2x1_.css +1 -0
- package/dist/client/assets/xterm_hudsonkit_false-B2TbElXJ.js +1 -0
- package/dist/client/index.html +3 -3
- package/dist/main.mjs +17318 -7066
- package/dist/pair-supervisor.mjs +25352 -21619
- package/dist/runtime/base-daemon.mjs +84 -12
- package/dist/runtime/broker-daemon.mjs +5879 -850
- package/dist/runtime/broker-process-manager.mjs +68 -10
- package/dist/runtime/mesh-discover.mjs +68 -10
- package/dist/scout-control-plane-web.mjs +16464 -1652
- package/dist/scout-web-server.mjs +16464 -1652
- package/package.json +14 -2
- package/dist/client/assets/addon-fit-DX4qG4td.js +0 -1
- package/dist/client/assets/addon-webgl-DCtw1yLn.js +0 -64
- package/dist/client/assets/index-BOdG2WWL.css +0 -1
- package/dist/client/assets/index-TVkH_WDG.js +0 -1
- package/dist/client/assets/index-mL1LA8IG.js +0 -159
- package/dist/client/assets/xterm-B-qIQCd3.js +0 -16
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
function nO(e,t){for(var n=0;n<t.length;n++){const s=t[n];if(typeof s!="string"&&!Array.isArray(s)){for(const i in s)if(i!=="default"&&!(i in e)){const l=Object.getOwnPropertyDescriptor(s,i);l&&Object.defineProperty(e,i,l.get?l:{enumerable:!0,get:()=>s[i]})}}}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 i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const l of i)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function n(i){const l={};return i.integrity&&(l.integrity=i.integrity),i.referrerPolicy&&(l.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?l.credentials="include":i.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function s(i){if(i.ep)return;i.ep=!0;const l=n(i);fetch(i.href,l)}})();function xE(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Vp={exports:{}},ac={};var Bj;function sO(){if(Bj)return ac;Bj=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,i,l){var c=null;if(l!==void 0&&(c=""+l),i.key!==void 0&&(c=""+i.key),"key"in i){l={};for(var d in i)d!=="key"&&(l[d]=i[d])}else l=i;return i=l.ref,{$$typeof:e,type:s,key:c,ref:i!==void 0?i:null,props:l}}return ac.Fragment=t,ac.jsx=n,ac.jsxs=n,ac}var Vj;function aO(){return Vj||(Vj=1,Vp.exports=sO()),Vp.exports}var r=aO(),Fp={exports:{}},Je={};var Fj;function rO(){if(Fj)return Je;Fj=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),x=Symbol.iterator;function w($){return $===null||typeof $!="object"?null:($=x&&$[x]||$["@@iterator"],typeof $=="function"?$:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,k={};function E($,B,Y){this.props=$,this.context=B,this.refs=k,this.updater=Y||j}E.prototype.isReactComponent={},E.prototype.setState=function($,B){if(typeof $!="object"&&typeof $!="function"&&$!=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,$,B,"setState")},E.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function A(){}A.prototype=E.prototype;function S($,B,Y){this.props=$,this.context=B,this.refs=k,this.updater=Y||j}var M=S.prototype=new A;M.constructor=S,N(M,E.prototype),M.isPureReactComponent=!0;var C=Array.isArray;function I(){}var R={H:null,A:null,T:null,S:null},D=Object.prototype.hasOwnProperty;function z($,B,Y){var te=Y.ref;return{$$typeof:e,type:$,key:B,ref:te!==void 0?te:null,props:Y}}function O($,B){return z($.type,B,$.props)}function _($){return typeof $=="object"&&$!==null&&$.$$typeof===e}function U($){var B={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(Y){return B[Y]})}var q=/\/+/g;function G($,B){return typeof $=="object"&&$!==null&&$.key!=null?U(""+$.key):B.toString(36)}function X($){switch($.status){case"fulfilled":return $.value;case"rejected":throw $.reason;default:switch(typeof $.status=="string"?$.then(I,I):($.status="pending",$.then(function(B){$.status==="pending"&&($.status="fulfilled",$.value=B)},function(B){$.status==="pending"&&($.status="rejected",$.reason=B)})),$.status){case"fulfilled":return $.value;case"rejected":throw $.reason}}throw $}function L($,B,Y,te,ae){var ee=typeof $;(ee==="undefined"||ee==="boolean")&&($=null);var ie=!1;if($===null)ie=!0;else switch(ee){case"bigint":case"string":case"number":ie=!0;break;case"object":switch($.$$typeof){case e:case t:ie=!0;break;case p:return ie=$._init,L(ie($._payload),B,Y,te,ae)}}if(ie)return ae=ae($),ie=te===""?"."+G($,0):te,C(ae)?(Y="",ie!=null&&(Y=ie.replace(q,"$&/")+"/"),L(ae,B,Y,"",function(Ae){return Ae})):ae!=null&&(_(ae)&&(ae=O(ae,Y+(ae.key==null||$&&$.key===ae.key?"":(""+ae.key).replace(q,"$&/")+"/")+ie)),B.push(ae)),1;ie=0;var de=te===""?".":te+":";if(C($))for(var xe=0;xe<$.length;xe++)te=$[xe],ee=de+G(te,xe),ie+=L(te,B,Y,ee,ae);else if(xe=w($),typeof xe=="function")for($=xe.call($),xe=0;!(te=$.next()).done;)te=te.value,ee=de+G(te,xe++),ie+=L(te,B,Y,ee,ae);else if(ee==="object"){if(typeof $.then=="function")return L(X($),B,Y,te,ae);throw B=String($),Error("Objects are not valid as a React child (found: "+(B==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":B)+"). If you meant to render a collection of children, use an array instead.")}return ie}function F($,B,Y){if($==null)return $;var te=[],ae=0;return L($,te,"","",function(ee){return B.call(Y,ee,ae++)}),te}function H($){if($._status===-1){var B=$._result;B=B(),B.then(function(Y){($._status===0||$._status===-1)&&($._status=1,$._result=Y)},function(Y){($._status===0||$._status===-1)&&($._status=2,$._result=Y)}),$._status===-1&&($._status=0,$._result=B)}if($._status===1)return $._result.default;throw $._result}var V=typeof reportError=="function"?reportError:function($){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var B=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof $=="object"&&$!==null&&typeof $.message=="string"?String($.message):String($),error:$});if(!window.dispatchEvent(B))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",$);return}console.error($)},W={map:F,forEach:function($,B,Y){F($,function(){B.apply(this,arguments)},Y)},count:function($){var B=0;return F($,function(){B++}),B},toArray:function($){return F($,function(B){return B})||[]},only:function($){if(!_($))throw Error("React.Children.only expected to receive a single React element child.");return $}};return Je.Activity=y,Je.Children=W,Je.Component=E,Je.Fragment=n,Je.Profiler=i,Je.PureComponent=S,Je.StrictMode=s,Je.Suspense=h,Je.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=R,Je.__COMPILER_RUNTIME={__proto__:null,c:function($){return R.H.useMemoCache($)}},Je.cache=function($){return function(){return $.apply(null,arguments)}},Je.cacheSignal=function(){return null},Je.cloneElement=function($,B,Y){if($==null)throw Error("The argument must be a React element, but you passed "+$+".");var te=N({},$.props),ae=$.key;if(B!=null)for(ee in B.key!==void 0&&(ae=""+B.key),B)!D.call(B,ee)||ee==="key"||ee==="__self"||ee==="__source"||ee==="ref"&&B.ref===void 0||(te[ee]=B[ee]);var ee=arguments.length-2;if(ee===1)te.children=Y;else if(1<ee){for(var ie=Array(ee),de=0;de<ee;de++)ie[de]=arguments[de+2];te.children=ie}return z($.type,ae,te)},Je.createContext=function($){return $={$$typeof:c,_currentValue:$,_currentValue2:$,_threadCount:0,Provider:null,Consumer:null},$.Provider=$,$.Consumer={$$typeof:l,_context:$},$},Je.createElement=function($,B,Y){var te,ae={},ee=null;if(B!=null)for(te in B.key!==void 0&&(ee=""+B.key),B)D.call(B,te)&&te!=="key"&&te!=="__self"&&te!=="__source"&&(ae[te]=B[te]);var ie=arguments.length-2;if(ie===1)ae.children=Y;else if(1<ie){for(var de=Array(ie),xe=0;xe<ie;xe++)de[xe]=arguments[xe+2];ae.children=de}if($&&$.defaultProps)for(te in ie=$.defaultProps,ie)ae[te]===void 0&&(ae[te]=ie[te]);return z($,ee,ae)},Je.createRef=function(){return{current:null}},Je.forwardRef=function($){return{$$typeof:d,render:$}},Je.isValidElement=_,Je.lazy=function($){return{$$typeof:p,_payload:{_status:-1,_result:$},_init:H}},Je.memo=function($,B){return{$$typeof:m,type:$,compare:B===void 0?null:B}},Je.startTransition=function($){var B=R.T,Y={};R.T=Y;try{var te=$(),ae=R.S;ae!==null&&ae(Y,te),typeof te=="object"&&te!==null&&typeof te.then=="function"&&te.then(I,V)}catch(ee){V(ee)}finally{B!==null&&Y.types!==null&&(B.types=Y.types),R.T=B}},Je.unstable_useCacheRefresh=function(){return R.H.useCacheRefresh()},Je.use=function($){return R.H.use($)},Je.useActionState=function($,B,Y){return R.H.useActionState($,B,Y)},Je.useCallback=function($,B){return R.H.useCallback($,B)},Je.useContext=function($){return R.H.useContext($)},Je.useDebugValue=function(){},Je.useDeferredValue=function($,B){return R.H.useDeferredValue($,B)},Je.useEffect=function($,B){return R.H.useEffect($,B)},Je.useEffectEvent=function($){return R.H.useEffectEvent($)},Je.useId=function(){return R.H.useId()},Je.useImperativeHandle=function($,B,Y){return R.H.useImperativeHandle($,B,Y)},Je.useInsertionEffect=function($,B){return R.H.useInsertionEffect($,B)},Je.useLayoutEffect=function($,B){return R.H.useLayoutEffect($,B)},Je.useMemo=function($,B){return R.H.useMemo($,B)},Je.useOptimistic=function($,B){return R.H.useOptimistic($,B)},Je.useReducer=function($,B,Y){return R.H.useReducer($,B,Y)},Je.useRef=function($){return R.H.useRef($)},Je.useState=function($){return R.H.useState($)},Je.useSyncExternalStore=function($,B,Y){return R.H.useSyncExternalStore($,B,Y)},Je.useTransition=function(){return R.H.useTransition()},Je.version="19.2.3",Je}var Hj;function Gc(){return Hj||(Hj=1,Fp.exports=rO()),Fp.exports}var g=Gc();const Po=xE(g),bE=nO({__proto__:null,default:Po},[g]);var Hp={exports:{}},rc={},qp={exports:{}},Zp={};var qj;function iO(){return qj||(qj=1,(function(e){function t(L,F){var H=L.length;L.push(F);e:for(;0<H;){var V=H-1>>>1,W=L[V];if(0<i(W,F))L[V]=F,L[H]=W,H=V;else break e}}function n(L){return L.length===0?null:L[0]}function s(L){if(L.length===0)return null;var F=L[0],H=L.pop();if(H!==F){L[0]=H;e:for(var V=0,W=L.length,$=W>>>1;V<$;){var B=2*(V+1)-1,Y=L[B],te=B+1,ae=L[te];if(0>i(Y,H))te<W&&0>i(ae,Y)?(L[V]=ae,L[te]=H,V=te):(L[V]=Y,L[B]=H,V=B);else if(te<W&&0>i(ae,H))L[V]=ae,L[te]=H,V=te;else break e}}return F}function i(L,F){var H=L.sortIndex-F.sortIndex;return H!==0?H:L.id-F.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var h=[],m=[],p=1,y=null,x=3,w=!1,j=!1,N=!1,k=!1,E=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function M(L){for(var F=n(m);F!==null;){if(F.callback===null)s(m);else if(F.startTime<=L)s(m),F.sortIndex=F.expirationTime,t(h,F);else break;F=n(m)}}function C(L){if(N=!1,M(L),!j)if(n(h)!==null)j=!0,I||(I=!0,U());else{var F=n(m);F!==null&&X(C,F.startTime-L)}}var I=!1,R=-1,D=5,z=-1;function O(){return k?!0:!(e.unstable_now()-z<D)}function _(){if(k=!1,I){var L=e.unstable_now();z=L;var F=!0;try{e:{j=!1,N&&(N=!1,A(R),R=-1),w=!0;var H=x;try{t:{for(M(L),y=n(h);y!==null&&!(y.expirationTime>L&&O());){var V=y.callback;if(typeof V=="function"){y.callback=null,x=y.priorityLevel;var W=V(y.expirationTime<=L);if(L=e.unstable_now(),typeof W=="function"){y.callback=W,M(L),F=!0;break t}y===n(h)&&s(h),M(L)}else s(h);y=n(h)}if(y!==null)F=!0;else{var $=n(m);$!==null&&X(C,$.startTime-L),F=!1}}break e}finally{y=null,x=H,w=!1}F=void 0}}finally{F?U():I=!1}}}var U;if(typeof S=="function")U=function(){S(_)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,G=q.port2;q.port1.onmessage=_,U=function(){G.postMessage(null)}}else U=function(){E(_,0)};function X(L,F){R=E(function(){L(e.unstable_now())},F)}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(L){L.callback=null},e.unstable_forceFrameRate=function(L){0>L||125<L?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):D=0<L?Math.floor(1e3/L):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_next=function(L){switch(x){case 1:case 2:case 3:var F=3;break;default:F=x}var H=x;x=F;try{return L()}finally{x=H}},e.unstable_requestPaint=function(){k=!0},e.unstable_runWithPriority=function(L,F){switch(L){case 1:case 2:case 3:case 4:case 5:break;default:L=3}var H=x;x=L;try{return F()}finally{x=H}},e.unstable_scheduleCallback=function(L,F,H){var V=e.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?V+H:V):H=V,L){case 1:var W=-1;break;case 2:W=250;break;case 5:W=1073741823;break;case 4:W=1e4;break;default:W=5e3}return W=H+W,L={id:p++,callback:F,priorityLevel:L,startTime:H,expirationTime:W,sortIndex:-1},H>V?(L.sortIndex=H,t(m,L),n(h)===null&&L===n(m)&&(N?(A(R),R=-1):N=!0,X(C,H-V))):(L.sortIndex=W,t(h,L),j||w||(j=!0,I||(I=!0,U()))),L},e.unstable_shouldYield=O,e.unstable_wrapCallback=function(L){var F=x;return function(){var H=x;x=F;try{return L.apply(this,arguments)}finally{x=H}}}})(Zp)),Zp}var Zj;function oO(){return Zj||(Zj=1,qp.exports=iO()),qp.exports}var Wp={exports:{}},On={};var Wj;function lO(){if(Wj)return On;Wj=1;var e=Gc();function t(h){var m="https://react.dev/errors/"+h;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)m+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+h+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var s={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},i=Symbol.for("react.portal");function l(h,m,p){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:y==null?null:""+y,children:h,containerInfo:m,implementation:p}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(h,m){if(h==="font")return"";if(typeof m=="string")return m==="use-credentials"?m:""}return On.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,On.createPortal=function(h,m){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)throw Error(t(299));return l(h,m,null,p)},On.flushSync=function(h){var m=c.T,p=s.p;try{if(c.T=null,s.p=2,h)return h()}finally{c.T=m,s.p=p,s.d.f()}},On.preconnect=function(h,m){typeof h=="string"&&(m?(m=m.crossOrigin,m=typeof m=="string"?m==="use-credentials"?m:"":void 0):m=null,s.d.C(h,m))},On.prefetchDNS=function(h){typeof h=="string"&&s.d.D(h)},On.preinit=function(h,m){if(typeof h=="string"&&m&&typeof m.as=="string"){var p=m.as,y=d(p,m.crossOrigin),x=typeof m.integrity=="string"?m.integrity:void 0,w=typeof m.fetchPriority=="string"?m.fetchPriority:void 0;p==="style"?s.d.S(h,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:y,integrity:x,fetchPriority:w}):p==="script"&&s.d.X(h,{crossOrigin:y,integrity:x,fetchPriority:w,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},On.preinitModule=function(h,m){if(typeof h=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var p=d(m.as,m.crossOrigin);s.d.M(h,{crossOrigin:p,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0})}}else m==null&&s.d.M(h)},On.preload=function(h,m){if(typeof h=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var p=m.as,y=d(p,m.crossOrigin);s.d.L(h,p,{crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0,type:typeof m.type=="string"?m.type:void 0,fetchPriority:typeof m.fetchPriority=="string"?m.fetchPriority:void 0,referrerPolicy:typeof m.referrerPolicy=="string"?m.referrerPolicy:void 0,imageSrcSet:typeof m.imageSrcSet=="string"?m.imageSrcSet:void 0,imageSizes:typeof m.imageSizes=="string"?m.imageSizes:void 0,media:typeof m.media=="string"?m.media:void 0})}},On.preloadModule=function(h,m){if(typeof h=="string")if(m){var p=d(m.as,m.crossOrigin);s.d.m(h,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:p,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else s.d.m(h)},On.requestFormReset=function(h){s.d.r(h)},On.unstable_batchedUpdates=function(h,m){return h(m)},On.useFormState=function(h,m,p){return c.H.useFormState(h,m,p)},On.useFormStatus=function(){return c.H.useHostTransitionStatus()},On.version="19.2.3",On}var Yj;function wE(){if(Yj)return Wp.exports;Yj=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(),Wp.exports=lO(),Wp.exports}var Gj;function cO(){if(Gj)return rc;Gj=1;var e=oO(),t=Gc(),n=wE();function s(a){var o="https://react.dev/errors/"+a;if(1<arguments.length){o+="?args[]="+encodeURIComponent(arguments[1]);for(var u=2;u<arguments.length;u++)o+="&args[]="+encodeURIComponent(arguments[u])}return"Minified React error #"+a+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function l(a){var o=a,u=a;if(a.alternate)for(;o.return;)o=o.return;else{a=o;do o=a,(o.flags&4098)!==0&&(u=o.return),a=o.return;while(a)}return o.tag===3?u:null}function c(a){if(a.tag===13){var o=a.memoizedState;if(o===null&&(a=a.alternate,a!==null&&(o=a.memoizedState)),o!==null)return o.dehydrated}return null}function d(a){if(a.tag===31){var o=a.memoizedState;if(o===null&&(a=a.alternate,a!==null&&(o=a.memoizedState)),o!==null)return o.dehydrated}return null}function h(a){if(l(a)!==a)throw Error(s(188))}function m(a){var o=a.alternate;if(!o){if(o=l(a),o===null)throw Error(s(188));return o!==a?null:a}for(var u=a,f=o;;){var v=u.return;if(v===null)break;var b=v.alternate;if(b===null){if(f=v.return,f!==null){u=f;continue}break}if(v.child===b.child){for(b=v.child;b;){if(b===u)return h(v),a;if(b===f)return h(v),o;b=b.sibling}throw Error(s(188))}if(u.return!==f.return)u=v,f=b;else{for(var T=!1,P=v.child;P;){if(P===u){T=!0,u=v,f=b;break}if(P===f){T=!0,f=v,u=b;break}P=P.sibling}if(!T){for(P=b.child;P;){if(P===u){T=!0,u=b,f=v;break}if(P===f){T=!0,f=b,u=v;break}P=P.sibling}if(!T)throw Error(s(189))}}if(u.alternate!==f)throw Error(s(190))}if(u.tag!==3)throw Error(s(188));return u.stateNode.current===u?a:o}function p(a){var o=a.tag;if(o===5||o===26||o===27||o===6)return a;for(a=a.child;a!==null;){if(o=p(a),o!==null)return o;a=a.sibling}return null}var y=Object.assign,x=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),k=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),S=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),z=Symbol.for("react.activity"),O=Symbol.for("react.memo_cache_sentinel"),_=Symbol.iterator;function U(a){return a===null||typeof a!="object"?null:(a=_&&a[_]||a["@@iterator"],typeof a=="function"?a:null)}var q=Symbol.for("react.client.reference");function G(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===q?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case N:return"Fragment";case E:return"Profiler";case k:return"StrictMode";case C:return"Suspense";case I:return"SuspenseList";case z:return"Activity"}if(typeof a=="object")switch(a.$$typeof){case j:return"Portal";case S:return a.displayName||"Context";case A:return(a._context.displayName||"Context")+".Consumer";case M:var o=a.render;return a=a.displayName,a||(a=o.displayName||o.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case R:return o=a.displayName||null,o!==null?o:G(a.type)||"Memo";case D:o=a._payload,a=a._init;try{return G(a(o))}catch{}}return null}var X=Array.isArray,L=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H={pending:!1,data:null,method:null,action:null},V=[],W=-1;function $(a){return{current:a}}function B(a){0>W||(a.current=V[W],V[W]=null,W--)}function Y(a,o){W++,V[W]=a.current,a.current=o}var te=$(null),ae=$(null),ee=$(null),ie=$(null);function de(a,o){switch(Y(ee,o),Y(ae,a),Y(te,null),o.nodeType){case 9:case 11:a=(a=o.documentElement)&&(a=a.namespaceURI)?uj(a):0;break;default:if(a=o.tagName,o=o.namespaceURI)o=uj(o),a=dj(o,a);else switch(a){case"svg":a=1;break;case"math":a=2;break;default:a=0}}B(te),Y(te,a)}function xe(){B(te),B(ae),B(ee)}function Ae(a){a.memoizedState!==null&&Y(ie,a);var o=te.current,u=dj(o,a.type);o!==u&&(Y(ae,a),Y(te,u))}function me(a){ae.current===a&&(B(te),B(ae)),ie.current===a&&(B(ie),ec._currentValue=H)}var Pe,Re;function Ye(a){if(Pe===void 0)try{throw Error()}catch(u){var o=u.stack.trim().match(/\n( *(at )?)/);Pe=o&&o[1]||"",Re=-1<u.stack.indexOf(`
|
|
2
|
-
at`)?" (<anonymous>)":-1<u.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
-
`+Pe+a+Re}var Ie=!1;function oe(a,o){if(!a||Ie)return"";Ie=!0;var u=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var f={DetermineComponentFrameRoot:function(){try{if(o){var ge=function(){throw Error()};if(Object.defineProperty(ge.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ge,[])}catch(ce){var re=ce}Reflect.construct(a,[],ge)}else{try{ge.call()}catch(ce){re=ce}a.call(ge.prototype)}}else{try{throw Error()}catch(ce){re=ce}(ge=a())&&typeof ge.catch=="function"&&ge.catch(function(){})}}catch(ce){if(ce&&re&&typeof ce.stack=="string")return[ce.stack,re.stack]}return[null,null]}};f.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var v=Object.getOwnPropertyDescriptor(f.DetermineComponentFrameRoot,"name");v&&v.configurable&&Object.defineProperty(f.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var b=f.DetermineComponentFrameRoot(),T=b[0],P=b[1];if(T&&P){var Z=T.split(`
|
|
4
|
-
`),se=P.split(`
|
|
5
|
-
`);for(v=f=0;f<Z.length&&!Z[f].includes("DetermineComponentFrameRoot");)f++;for(;v<se.length&&!se[v].includes("DetermineComponentFrameRoot");)v++;if(f===Z.length||v===se.length)for(f=Z.length-1,v=se.length-1;1<=f&&0<=v&&Z[f]!==se[v];)v--;for(;1<=f&&0<=v;f--,v--)if(Z[f]!==se[v]){if(f!==1||v!==1)do if(f--,v--,0>v||Z[f]!==se[v]){var fe=`
|
|
6
|
-
`+Z[f].replace(" at new "," at ");return a.displayName&&fe.includes("<anonymous>")&&(fe=fe.replace("<anonymous>",a.displayName)),fe}while(1<=f&&0<=v);break}}}finally{Ie=!1,Error.prepareStackTrace=u}return(u=a?a.displayName||a.name:"")?Ye(u):""}function je(a,o){switch(a.tag){case 26:case 27:case 5:return Ye(a.type);case 16:return Ye("Lazy");case 13:return a.child!==o&&o!==null?Ye("Suspense Fallback"):Ye("Suspense");case 19:return Ye("SuspenseList");case 0:case 15:return oe(a.type,!1);case 11:return oe(a.type.render,!1);case 1:return oe(a.type,!0);case 31:return Ye("Activity");default:return""}}function Fe(a){try{var o="",u=null;do o+=je(a,u),u=a,a=a.return;while(a);return o}catch(f){return`
|
|
7
|
-
Error generating stack: `+f.message+`
|
|
8
|
-
`+f.stack}}var le=Object.prototype.hasOwnProperty,ve=e.unstable_scheduleCallback,ue=e.unstable_cancelCallback,Ce=e.unstable_shouldYield,be=e.unstable_requestPaint,we=e.unstable_now,Se=e.unstable_getCurrentPriorityLevel,He=e.unstable_ImmediatePriority,et=e.unstable_UserBlockingPriority,Be=e.unstable_NormalPriority,St=e.unstable_LowPriority,Dt=e.unstable_IdlePriority,Xt=e.log,Ee=e.unstable_setDisableYieldValue,Oe=null,Te=null;function tt(a){if(typeof Xt=="function"&&Ee(a),Te&&typeof Te.setStrictMode=="function")try{Te.setStrictMode(Oe,a)}catch{}}var at=Math.clz32?Math.clz32:Jt,it=Math.log,yt=Math.LN2;function Jt(a){return a>>>=0,a===0?32:31-(it(a)/yt|0)|0}var Pt=256,on=262144,ln=4194304;function _e(a){var o=a&42;if(o!==0)return o;switch(a&-a){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 a&261888;case 262144:case 524288:case 1048576:case 2097152:return a&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return a&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return a}}function jt(a,o,u){var f=a.pendingLanes;if(f===0)return 0;var v=0,b=a.suspendedLanes,T=a.pingedLanes;a=a.warmLanes;var P=f&134217727;return P!==0?(f=P&~b,f!==0?v=_e(f):(T&=P,T!==0?v=_e(T):u||(u=P&~a,u!==0&&(v=_e(u))))):(P=f&~b,P!==0?v=_e(P):T!==0?v=_e(T):u||(u=f&~a,u!==0&&(v=_e(u)))),v===0?0:o!==0&&o!==v&&(o&b)===0&&(b=v&-v,u=o&-o,b>=u||b===32&&(u&4194048)!==0)?o:v}function Wt(a,o){return(a.pendingLanes&~(a.suspendedLanes&~a.pingedLanes)&o)===0}function Fa(a,o){switch(a){case 1:case 2:case 4:case 8:case 64:return o+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 o+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 Ds(){var a=ln;return ln<<=1,(ln&62914560)===0&&(ln=4194304),a}function Q(a){for(var o=[],u=0;31>u;u++)o.push(a);return o}function ye(a,o){a.pendingLanes|=o,o!==268435456&&(a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0)}function Ne(a,o,u,f,v,b){var T=a.pendingLanes;a.pendingLanes=u,a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0,a.expiredLanes&=u,a.entangledLanes&=u,a.errorRecoveryDisabledLanes&=u,a.shellSuspendCounter=0;var P=a.entanglements,Z=a.expirationTimes,se=a.hiddenUpdates;for(u=T&~u;0<u;){var fe=31-at(u),ge=1<<fe;P[fe]=0,Z[fe]=-1;var re=se[fe];if(re!==null)for(se[fe]=null,fe=0;fe<re.length;fe++){var ce=re[fe];ce!==null&&(ce.lane&=-536870913)}u&=~ge}f!==0&&We(a,f,0),b!==0&&v===0&&a.tag!==0&&(a.suspendedLanes|=b&~(T&~o))}function We(a,o,u){a.pendingLanes|=o,a.suspendedLanes&=~o;var f=31-at(o);a.entangledLanes|=o,a.entanglements[f]=a.entanglements[f]|1073741824|u&261930}function Ge(a,o){var u=a.entangledLanes|=o;for(a=a.entanglements;u;){var f=31-at(u),v=1<<f;v&o|a[f]&o&&(a[f]|=o),u&=~v}}function vt(a,o){var u=o&-o;return u=(u&42)!==0?1:At(u),(u&(a.suspendedLanes|o))!==0?0:u}function At(a){switch(a){case 2:a=1;break;case 8:a=4;break;case 32:a=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:a=128;break;case 268435456:a=134217728;break;default:a=0}return a}function Qt(a){return a&=-a,2<a?8<a?(a&134217727)!==0?32:268435456:8:2}function Sn(){var a=F.p;return a!==0?a:(a=window.event,a===void 0?32:Oj(a.type))}function kn(a,o){var u=F.p;try{return F.p=a,o()}finally{F.p=u}}var qn=Math.random().toString(36).slice(2),xt="__reactFiber$"+qn,Zn="__reactProps$"+qn,_i="__reactContainer$"+qn,Ih="__reactEvents$"+qn,q2="__reactListeners$"+qn,Z2="__reactHandles$"+qn,Xx="__reactResources$"+qn,pl="__reactMarker$"+qn;function Oh(a){delete a[xt],delete a[Zn],delete a[Ih],delete a[q2],delete a[Z2]}function Ii(a){var o=a[xt];if(o)return o;for(var u=a.parentNode;u;){if(o=u[_i]||u[xt]){if(u=o.alternate,o.child!==null||u!==null&&u.child!==null)for(a=yj(a);a!==null;){if(u=a[xt])return u;a=yj(a)}return o}a=u,u=a.parentNode}return null}function Oi(a){if(a=a[xt]||a[_i]){var o=a.tag;if(o===5||o===6||o===13||o===31||o===26||o===27||o===3)return a}return null}function gl(a){var o=a.tag;if(o===5||o===26||o===27||o===6)return a.stateNode;throw Error(s(33))}function Di(a){var o=a[Xx];return o||(o=a[Xx]={hoistableStyles:new Map,hoistableScripts:new Map}),o}function wn(a){a[pl]=!0}var Jx=new Set,Qx={};function Fr(a,o){Pi(a,o),Pi(a+"Capture",o)}function Pi(a,o){for(Qx[a]=o,a=0;a<o.length;a++)Jx.add(o[a])}var W2=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]*$"),eb={},tb={};function Y2(a){return le.call(tb,a)?!0:le.call(eb,a)?!1:W2.test(a)?tb[a]=!0:(eb[a]=!0,!1)}function uu(a,o,u){if(Y2(o))if(u===null)a.removeAttribute(o);else{switch(typeof u){case"undefined":case"function":case"symbol":a.removeAttribute(o);return;case"boolean":var f=o.toLowerCase().slice(0,5);if(f!=="data-"&&f!=="aria-"){a.removeAttribute(o);return}}a.setAttribute(o,""+u)}}function du(a,o,u){if(u===null)a.removeAttribute(o);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":a.removeAttribute(o);return}a.setAttribute(o,""+u)}}function va(a,o,u,f){if(f===null)a.removeAttribute(u);else{switch(typeof f){case"undefined":case"function":case"symbol":case"boolean":a.removeAttribute(u);return}a.setAttributeNS(o,u,""+f)}}function vs(a){switch(typeof a){case"bigint":case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function nb(a){var o=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function G2(a,o,u){var f=Object.getOwnPropertyDescriptor(a.constructor.prototype,o);if(!a.hasOwnProperty(o)&&typeof f<"u"&&typeof f.get=="function"&&typeof f.set=="function"){var v=f.get,b=f.set;return Object.defineProperty(a,o,{configurable:!0,get:function(){return v.call(this)},set:function(T){u=""+T,b.call(this,T)}}),Object.defineProperty(a,o,{enumerable:f.enumerable}),{getValue:function(){return u},setValue:function(T){u=""+T},stopTracking:function(){a._valueTracker=null,delete a[o]}}}}function Dh(a){if(!a._valueTracker){var o=nb(a)?"checked":"value";a._valueTracker=G2(a,o,""+a[o])}}function sb(a){if(!a)return!1;var o=a._valueTracker;if(!o)return!0;var u=o.getValue(),f="";return a&&(f=nb(a)?a.checked?"true":"false":a.value),a=f,a!==u?(o.setValue(a),!0):!1}function fu(a){if(a=a||(typeof document<"u"?document:void 0),typeof a>"u")return null;try{return a.activeElement||a.body}catch{return a.body}}var K2=/[\n"\\]/g;function ys(a){return a.replace(K2,function(o){return"\\"+o.charCodeAt(0).toString(16)+" "})}function Ph(a,o,u,f,v,b,T,P){a.name="",T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?a.type=T:a.removeAttribute("type"),o!=null?T==="number"?(o===0&&a.value===""||a.value!=o)&&(a.value=""+vs(o)):a.value!==""+vs(o)&&(a.value=""+vs(o)):T!=="submit"&&T!=="reset"||a.removeAttribute("value"),o!=null?zh(a,T,vs(o)):u!=null?zh(a,T,vs(u)):f!=null&&a.removeAttribute("value"),v==null&&b!=null&&(a.defaultChecked=!!b),v!=null&&(a.checked=v&&typeof v!="function"&&typeof v!="symbol"),P!=null&&typeof P!="function"&&typeof P!="symbol"&&typeof P!="boolean"?a.name=""+vs(P):a.removeAttribute("name")}function ab(a,o,u,f,v,b,T,P){if(b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(a.type=b),o!=null||u!=null){if(!(b!=="submit"&&b!=="reset"||o!=null)){Dh(a);return}u=u!=null?""+vs(u):"",o=o!=null?""+vs(o):u,P||o===a.value||(a.value=o),a.defaultValue=o}f=f??v,f=typeof f!="function"&&typeof f!="symbol"&&!!f,a.checked=P?a.checked:!!f,a.defaultChecked=!!f,T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"&&(a.name=T),Dh(a)}function zh(a,o,u){o==="number"&&fu(a.ownerDocument)===a||a.defaultValue===""+u||(a.defaultValue=""+u)}function zi(a,o,u,f){if(a=a.options,o){o={};for(var v=0;v<u.length;v++)o["$"+u[v]]=!0;for(u=0;u<a.length;u++)v=o.hasOwnProperty("$"+a[u].value),a[u].selected!==v&&(a[u].selected=v),v&&f&&(a[u].defaultSelected=!0)}else{for(u=""+vs(u),o=null,v=0;v<a.length;v++){if(a[v].value===u){a[v].selected=!0,f&&(a[v].defaultSelected=!0);return}o!==null||a[v].disabled||(o=a[v])}o!==null&&(o.selected=!0)}}function rb(a,o,u){if(o!=null&&(o=""+vs(o),o!==a.value&&(a.value=o),u==null)){a.defaultValue!==o&&(a.defaultValue=o);return}a.defaultValue=u!=null?""+vs(u):""}function ib(a,o,u,f){if(o==null){if(f!=null){if(u!=null)throw Error(s(92));if(X(f)){if(1<f.length)throw Error(s(93));f=f[0]}u=f}u==null&&(u=""),o=u}u=vs(o),a.defaultValue=u,f=a.textContent,f===u&&f!==""&&f!==null&&(a.value=f),Dh(a)}function Li(a,o){if(o){var u=a.firstChild;if(u&&u===a.lastChild&&u.nodeType===3){u.nodeValue=o;return}}a.textContent=o}var X2=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 ob(a,o,u){var f=o.indexOf("--")===0;u==null||typeof u=="boolean"||u===""?f?a.setProperty(o,""):o==="float"?a.cssFloat="":a[o]="":f?a.setProperty(o,u):typeof u!="number"||u===0||X2.has(o)?o==="float"?a.cssFloat=u:a[o]=(""+u).trim():a[o]=u+"px"}function lb(a,o,u){if(o!=null&&typeof o!="object")throw Error(s(62));if(a=a.style,u!=null){for(var f in u)!u.hasOwnProperty(f)||o!=null&&o.hasOwnProperty(f)||(f.indexOf("--")===0?a.setProperty(f,""):f==="float"?a.cssFloat="":a[f]="");for(var v in o)f=o[v],o.hasOwnProperty(v)&&u[v]!==f&&ob(a,v,f)}else for(var b in o)o.hasOwnProperty(b)&&ob(a,b,o[b])}function Lh(a){if(a.indexOf("-")===-1)return!1;switch(a){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 J2=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"]]),Q2=/^[\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 hu(a){return Q2.test(""+a)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":a}function ya(){}var $h=null;function Uh(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var $i=null,Ui=null;function cb(a){var o=Oi(a);if(o&&(a=o.stateNode)){var u=a[Zn]||null;e:switch(a=o.stateNode,o.type){case"input":if(Ph(a,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name),o=u.name,u.type==="radio"&&o!=null){for(u=a;u.parentNode;)u=u.parentNode;for(u=u.querySelectorAll('input[name="'+ys(""+o)+'"][type="radio"]'),o=0;o<u.length;o++){var f=u[o];if(f!==a&&f.form===a.form){var v=f[Zn]||null;if(!v)throw Error(s(90));Ph(f,v.value,v.defaultValue,v.defaultValue,v.checked,v.defaultChecked,v.type,v.name)}}for(o=0;o<u.length;o++)f=u[o],f.form===a.form&&sb(f)}break e;case"textarea":rb(a,u.value,u.defaultValue);break e;case"select":o=u.value,o!=null&&zi(a,!!u.multiple,o,!1)}}}var Bh=!1;function ub(a,o,u){if(Bh)return a(o,u);Bh=!0;try{var f=a(o);return f}finally{if(Bh=!1,($i!==null||Ui!==null)&&(ed(),$i&&(o=$i,a=Ui,Ui=$i=null,cb(o),a)))for(o=0;o<a.length;o++)cb(a[o])}}function vl(a,o){var u=a.stateNode;if(u===null)return null;var f=u[Zn]||null;if(f===null)return null;u=f[o];e:switch(o){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(f=!f.disabled)||(a=a.type,f=!(a==="button"||a==="input"||a==="select"||a==="textarea")),a=!f;break e;default:a=!1}if(a)return null;if(u&&typeof u!="function")throw Error(s(231,o,typeof u));return u}var xa=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Vh=!1;if(xa)try{var yl={};Object.defineProperty(yl,"passive",{get:function(){Vh=!0}}),window.addEventListener("test",yl,yl),window.removeEventListener("test",yl,yl)}catch{Vh=!1}var Ha=null,Fh=null,mu=null;function db(){if(mu)return mu;var a,o=Fh,u=o.length,f,v="value"in Ha?Ha.value:Ha.textContent,b=v.length;for(a=0;a<u&&o[a]===v[a];a++);var T=u-a;for(f=1;f<=T&&o[u-f]===v[b-f];f++);return mu=v.slice(a,1<f?1-f:void 0)}function pu(a){var o=a.keyCode;return"charCode"in a?(a=a.charCode,a===0&&o===13&&(a=13)):a=o,a===10&&(a=13),32<=a||a===13?a:0}function gu(){return!0}function fb(){return!1}function Wn(a){function o(u,f,v,b,T){this._reactName=u,this._targetInst=v,this.type=f,this.nativeEvent=b,this.target=T,this.currentTarget=null;for(var P in a)a.hasOwnProperty(P)&&(u=a[P],this[P]=u?u(b):b[P]);return this.isDefaultPrevented=(b.defaultPrevented!=null?b.defaultPrevented:b.returnValue===!1)?gu:fb,this.isPropagationStopped=fb,this}return y(o.prototype,{preventDefault:function(){this.defaultPrevented=!0;var u=this.nativeEvent;u&&(u.preventDefault?u.preventDefault():typeof u.returnValue!="unknown"&&(u.returnValue=!1),this.isDefaultPrevented=gu)},stopPropagation:function(){var u=this.nativeEvent;u&&(u.stopPropagation?u.stopPropagation():typeof u.cancelBubble!="unknown"&&(u.cancelBubble=!0),this.isPropagationStopped=gu)},persist:function(){},isPersistent:gu}),o}var Hr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},vu=Wn(Hr),xl=y({},Hr,{view:0,detail:0}),e_=Wn(xl),Hh,qh,bl,yu=y({},xl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Wh,button:0,buttons:0,relatedTarget:function(a){return a.relatedTarget===void 0?a.fromElement===a.srcElement?a.toElement:a.fromElement:a.relatedTarget},movementX:function(a){return"movementX"in a?a.movementX:(a!==bl&&(bl&&a.type==="mousemove"?(Hh=a.screenX-bl.screenX,qh=a.screenY-bl.screenY):qh=Hh=0,bl=a),Hh)},movementY:function(a){return"movementY"in a?a.movementY:qh}}),hb=Wn(yu),t_=y({},yu,{dataTransfer:0}),n_=Wn(t_),s_=y({},xl,{relatedTarget:0}),Zh=Wn(s_),a_=y({},Hr,{animationName:0,elapsedTime:0,pseudoElement:0}),r_=Wn(a_),i_=y({},Hr,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),o_=Wn(i_),l_=y({},Hr,{data:0}),mb=Wn(l_),c_={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},u_={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"},d_={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function f_(a){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(a):(a=d_[a])?!!o[a]:!1}function Wh(){return f_}var h_=y({},xl,{key:function(a){if(a.key){var o=c_[a.key]||a.key;if(o!=="Unidentified")return o}return a.type==="keypress"?(a=pu(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?u_[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Wh,charCode:function(a){return a.type==="keypress"?pu(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?pu(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),m_=Wn(h_),p_=y({},yu,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),pb=Wn(p_),g_=y({},xl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Wh}),v_=Wn(g_),y_=y({},Hr,{propertyName:0,elapsedTime:0,pseudoElement:0}),x_=Wn(y_),b_=y({},yu,{deltaX:function(a){return"deltaX"in a?a.deltaX:"wheelDeltaX"in a?-a.wheelDeltaX:0},deltaY:function(a){return"deltaY"in a?a.deltaY:"wheelDeltaY"in a?-a.wheelDeltaY:"wheelDelta"in a?-a.wheelDelta:0},deltaZ:0,deltaMode:0}),w_=Wn(b_),j_=y({},Hr,{newState:0,oldState:0}),N_=Wn(j_),S_=[9,13,27,32],Yh=xa&&"CompositionEvent"in window,wl=null;xa&&"documentMode"in document&&(wl=document.documentMode);var k_=xa&&"TextEvent"in window&&!wl,gb=xa&&(!Yh||wl&&8<wl&&11>=wl),vb=" ",yb=!1;function xb(a,o){switch(a){case"keyup":return S_.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function bb(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var Bi=!1;function E_(a,o){switch(a){case"compositionend":return bb(o);case"keypress":return o.which!==32?null:(yb=!0,vb);case"textInput":return a=o.data,a===vb&&yb?null:a;default:return null}}function C_(a,o){if(Bi)return a==="compositionend"||!Yh&&xb(a,o)?(a=db(),mu=Fh=Ha=null,Bi=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1<o.char.length)return o.char;if(o.which)return String.fromCharCode(o.which)}return null;case"compositionend":return gb&&o.locale!=="ko"?null:o.data;default:return null}}var A_={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 wb(a){var o=a&&a.nodeName&&a.nodeName.toLowerCase();return o==="input"?!!A_[a.type]:o==="textarea"}function jb(a,o,u,f){$i?Ui?Ui.push(f):Ui=[f]:$i=f,o=od(o,"onChange"),0<o.length&&(u=new vu("onChange","change",null,u,f),a.push({event:u,listeners:o}))}var jl=null,Nl=null;function T_(a){aj(a,0)}function xu(a){var o=gl(a);if(sb(o))return a}function Nb(a,o){if(a==="change")return o}var Sb=!1;if(xa){var Gh;if(xa){var Kh="oninput"in document;if(!Kh){var kb=document.createElement("div");kb.setAttribute("oninput","return;"),Kh=typeof kb.oninput=="function"}Gh=Kh}else Gh=!1;Sb=Gh&&(!document.documentMode||9<document.documentMode)}function Eb(){jl&&(jl.detachEvent("onpropertychange",Cb),Nl=jl=null)}function Cb(a){if(a.propertyName==="value"&&xu(Nl)){var o=[];jb(o,Nl,a,Uh(a)),ub(T_,o)}}function M_(a,o,u){a==="focusin"?(Eb(),jl=o,Nl=u,jl.attachEvent("onpropertychange",Cb)):a==="focusout"&&Eb()}function R_(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return xu(Nl)}function __(a,o){if(a==="click")return xu(o)}function I_(a,o){if(a==="input"||a==="change")return xu(o)}function O_(a,o){return a===o&&(a!==0||1/a===1/o)||a!==a&&o!==o}var as=typeof Object.is=="function"?Object.is:O_;function Sl(a,o){if(as(a,o))return!0;if(typeof a!="object"||a===null||typeof o!="object"||o===null)return!1;var u=Object.keys(a),f=Object.keys(o);if(u.length!==f.length)return!1;for(f=0;f<u.length;f++){var v=u[f];if(!le.call(o,v)||!as(a[v],o[v]))return!1}return!0}function Ab(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function Tb(a,o){var u=Ab(a);a=0;for(var f;u;){if(u.nodeType===3){if(f=a+u.textContent.length,a<=o&&f>=o)return{node:u,offset:o-a};a=f}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=Ab(u)}}function Mb(a,o){return a&&o?a===o?!0:a&&a.nodeType===3?!1:o&&o.nodeType===3?Mb(a,o.parentNode):"contains"in a?a.contains(o):a.compareDocumentPosition?!!(a.compareDocumentPosition(o)&16):!1:!1}function Rb(a){a=a!=null&&a.ownerDocument!=null&&a.ownerDocument.defaultView!=null?a.ownerDocument.defaultView:window;for(var o=fu(a.document);o instanceof a.HTMLIFrameElement;){try{var u=typeof o.contentWindow.location.href=="string"}catch{u=!1}if(u)a=o.contentWindow;else break;o=fu(a.document)}return o}function Xh(a){var o=a&&a.nodeName&&a.nodeName.toLowerCase();return o&&(o==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||o==="textarea"||a.contentEditable==="true")}var D_=xa&&"documentMode"in document&&11>=document.documentMode,Vi=null,Jh=null,kl=null,Qh=!1;function _b(a,o,u){var f=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;Qh||Vi==null||Vi!==fu(f)||(f=Vi,"selectionStart"in f&&Xh(f)?f={start:f.selectionStart,end:f.selectionEnd}:(f=(f.ownerDocument&&f.ownerDocument.defaultView||window).getSelection(),f={anchorNode:f.anchorNode,anchorOffset:f.anchorOffset,focusNode:f.focusNode,focusOffset:f.focusOffset}),kl&&Sl(kl,f)||(kl=f,f=od(Jh,"onSelect"),0<f.length&&(o=new vu("onSelect","select",null,o,u),a.push({event:o,listeners:f}),o.target=Vi)))}function qr(a,o){var u={};return u[a.toLowerCase()]=o.toLowerCase(),u["Webkit"+a]="webkit"+o,u["Moz"+a]="moz"+o,u}var Fi={animationend:qr("Animation","AnimationEnd"),animationiteration:qr("Animation","AnimationIteration"),animationstart:qr("Animation","AnimationStart"),transitionrun:qr("Transition","TransitionRun"),transitionstart:qr("Transition","TransitionStart"),transitioncancel:qr("Transition","TransitionCancel"),transitionend:qr("Transition","TransitionEnd")},em={},Ib={};xa&&(Ib=document.createElement("div").style,"AnimationEvent"in window||(delete Fi.animationend.animation,delete Fi.animationiteration.animation,delete Fi.animationstart.animation),"TransitionEvent"in window||delete Fi.transitionend.transition);function Zr(a){if(em[a])return em[a];if(!Fi[a])return a;var o=Fi[a],u;for(u in o)if(o.hasOwnProperty(u)&&u in Ib)return em[a]=o[u];return a}var Ob=Zr("animationend"),Db=Zr("animationiteration"),Pb=Zr("animationstart"),P_=Zr("transitionrun"),z_=Zr("transitionstart"),L_=Zr("transitioncancel"),zb=Zr("transitionend"),Lb=new Map,tm="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(" ");tm.push("scrollEnd");function Ps(a,o){Lb.set(a,o),Fr(o,[a])}var bu=typeof reportError=="function"?reportError:function(a){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var o=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof a=="object"&&a!==null&&typeof a.message=="string"?String(a.message):String(a),error:a});if(!window.dispatchEvent(o))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",a);return}console.error(a)},xs=[],Hi=0,nm=0;function wu(){for(var a=Hi,o=nm=Hi=0;o<a;){var u=xs[o];xs[o++]=null;var f=xs[o];xs[o++]=null;var v=xs[o];xs[o++]=null;var b=xs[o];if(xs[o++]=null,f!==null&&v!==null){var T=f.pending;T===null?v.next=v:(v.next=T.next,T.next=v),f.pending=v}b!==0&&$b(u,v,b)}}function ju(a,o,u,f){xs[Hi++]=a,xs[Hi++]=o,xs[Hi++]=u,xs[Hi++]=f,nm|=f,a.lanes|=f,a=a.alternate,a!==null&&(a.lanes|=f)}function sm(a,o,u,f){return ju(a,o,u,f),Nu(a)}function Wr(a,o){return ju(a,null,null,o),Nu(a)}function $b(a,o,u){a.lanes|=u;var f=a.alternate;f!==null&&(f.lanes|=u);for(var v=!1,b=a.return;b!==null;)b.childLanes|=u,f=b.alternate,f!==null&&(f.childLanes|=u),b.tag===22&&(a=b.stateNode,a===null||a._visibility&1||(v=!0)),a=b,b=b.return;return a.tag===3?(b=a.stateNode,v&&o!==null&&(v=31-at(u),a=b.hiddenUpdates,f=a[v],f===null?a[v]=[o]:f.push(o),o.lane=u|536870912),b):null}function Nu(a){if(50<Wl)throw Wl=0,fp=null,Error(s(185));for(var o=a.return;o!==null;)a=o,o=a.return;return a.tag===3?a.stateNode:null}var qi={};function $_(a,o,u,f){this.tag=a,this.key=u,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=o,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=f,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function rs(a,o,u,f){return new $_(a,o,u,f)}function am(a){return a=a.prototype,!(!a||!a.isReactComponent)}function ba(a,o){var u=a.alternate;return u===null?(u=rs(a.tag,o,a.key,a.mode),u.elementType=a.elementType,u.type=a.type,u.stateNode=a.stateNode,u.alternate=a,a.alternate=u):(u.pendingProps=o,u.type=a.type,u.flags=0,u.subtreeFlags=0,u.deletions=null),u.flags=a.flags&65011712,u.childLanes=a.childLanes,u.lanes=a.lanes,u.child=a.child,u.memoizedProps=a.memoizedProps,u.memoizedState=a.memoizedState,u.updateQueue=a.updateQueue,o=a.dependencies,u.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},u.sibling=a.sibling,u.index=a.index,u.ref=a.ref,u.refCleanup=a.refCleanup,u}function Ub(a,o){a.flags&=65011714;var u=a.alternate;return u===null?(a.childLanes=0,a.lanes=o,a.child=null,a.subtreeFlags=0,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null,a.stateNode=null):(a.childLanes=u.childLanes,a.lanes=u.lanes,a.child=u.child,a.subtreeFlags=0,a.deletions=null,a.memoizedProps=u.memoizedProps,a.memoizedState=u.memoizedState,a.updateQueue=u.updateQueue,a.type=u.type,o=u.dependencies,a.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),a}function Su(a,o,u,f,v,b){var T=0;if(f=a,typeof a=="function")am(a)&&(T=1);else if(typeof a=="string")T=HI(a,u,te.current)?26:a==="html"||a==="head"||a==="body"?27:5;else e:switch(a){case z:return a=rs(31,u,o,v),a.elementType=z,a.lanes=b,a;case N:return Yr(u.children,v,b,o);case k:T=8,v|=24;break;case E:return a=rs(12,u,o,v|2),a.elementType=E,a.lanes=b,a;case C:return a=rs(13,u,o,v),a.elementType=C,a.lanes=b,a;case I:return a=rs(19,u,o,v),a.elementType=I,a.lanes=b,a;default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case S:T=10;break e;case A:T=9;break e;case M:T=11;break e;case R:T=14;break e;case D:T=16,f=null;break e}T=29,u=Error(s(130,a===null?"null":typeof a,"")),f=null}return o=rs(T,u,o,v),o.elementType=a,o.type=f,o.lanes=b,o}function Yr(a,o,u,f){return a=rs(7,a,f,o),a.lanes=u,a}function rm(a,o,u){return a=rs(6,a,null,o),a.lanes=u,a}function Bb(a){var o=rs(18,null,null,0);return o.stateNode=a,o}function im(a,o,u){return o=rs(4,a.children!==null?a.children:[],a.key,o),o.lanes=u,o.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},o}var Vb=new WeakMap;function bs(a,o){if(typeof a=="object"&&a!==null){var u=Vb.get(a);return u!==void 0?u:(o={value:a,source:o,stack:Fe(o)},Vb.set(a,o),o)}return{value:a,source:o,stack:Fe(o)}}var Zi=[],Wi=0,ku=null,El=0,ws=[],js=0,qa=null,Xs=1,Js="";function wa(a,o){Zi[Wi++]=El,Zi[Wi++]=ku,ku=a,El=o}function Fb(a,o,u){ws[js++]=Xs,ws[js++]=Js,ws[js++]=qa,qa=a;var f=Xs;a=Js;var v=32-at(f)-1;f&=~(1<<v),u+=1;var b=32-at(o)+v;if(30<b){var T=v-v%5;b=(f&(1<<T)-1).toString(32),f>>=T,v-=T,Xs=1<<32-at(o)+v|u<<v|f,Js=b+a}else Xs=1<<b|u<<v|f,Js=a}function om(a){a.return!==null&&(wa(a,1),Fb(a,1,0))}function lm(a){for(;a===ku;)ku=Zi[--Wi],Zi[Wi]=null,El=Zi[--Wi],Zi[Wi]=null;for(;a===qa;)qa=ws[--js],ws[js]=null,Js=ws[--js],ws[js]=null,Xs=ws[--js],ws[js]=null}function Hb(a,o){ws[js++]=Xs,ws[js++]=Js,ws[js++]=qa,Xs=o.id,Js=o.overflow,qa=a}var En=null,$t=null,mt=!1,Za=null,Ns=!1,cm=Error(s(519));function Wa(a){var o=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Cl(bs(o,a)),cm}function qb(a){var o=a.stateNode,u=a.type,f=a.memoizedProps;switch(o[xt]=a,o[Zn]=f,u){case"dialog":ct("cancel",o),ct("close",o);break;case"iframe":case"object":case"embed":ct("load",o);break;case"video":case"audio":for(u=0;u<Gl.length;u++)ct(Gl[u],o);break;case"source":ct("error",o);break;case"img":case"image":case"link":ct("error",o),ct("load",o);break;case"details":ct("toggle",o);break;case"input":ct("invalid",o),ab(o,f.value,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name,!0);break;case"select":ct("invalid",o);break;case"textarea":ct("invalid",o),ib(o,f.value,f.defaultValue,f.children)}u=f.children,typeof u!="string"&&typeof u!="number"&&typeof u!="bigint"||o.textContent===""+u||f.suppressHydrationWarning===!0||lj(o.textContent,u)?(f.popover!=null&&(ct("beforetoggle",o),ct("toggle",o)),f.onScroll!=null&&ct("scroll",o),f.onScrollEnd!=null&&ct("scrollend",o),f.onClick!=null&&(o.onclick=ya),o=!0):o=!1,o||Wa(a,!0)}function Zb(a){for(En=a.return;En;)switch(En.tag){case 5:case 31:case 13:Ns=!1;return;case 27:case 3:Ns=!0;return;default:En=En.return}}function Yi(a){if(a!==En)return!1;if(!mt)return Zb(a),mt=!0,!1;var o=a.tag,u;if((u=o!==3&&o!==27)&&((u=o===5)&&(u=a.type,u=!(u!=="form"&&u!=="button")||Cp(a.type,a.memoizedProps)),u=!u),u&&$t&&Wa(a),Zb(a),o===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(s(317));$t=vj(a)}else if(o===31){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(s(317));$t=vj(a)}else o===27?(o=$t,or(a.type)?(a=_p,_p=null,$t=a):$t=o):$t=En?ks(a.stateNode.nextSibling):null;return!0}function Gr(){$t=En=null,mt=!1}function um(){var a=Za;return a!==null&&(Xn===null?Xn=a:Xn.push.apply(Xn,a),Za=null),a}function Cl(a){Za===null?Za=[a]:Za.push(a)}var dm=$(null),Kr=null,ja=null;function Ya(a,o,u){Y(dm,o._currentValue),o._currentValue=u}function Na(a){a._currentValue=dm.current,B(dm)}function fm(a,o,u){for(;a!==null;){var f=a.alternate;if((a.childLanes&o)!==o?(a.childLanes|=o,f!==null&&(f.childLanes|=o)):f!==null&&(f.childLanes&o)!==o&&(f.childLanes|=o),a===u)break;a=a.return}}function hm(a,o,u,f){var v=a.child;for(v!==null&&(v.return=a);v!==null;){var b=v.dependencies;if(b!==null){var T=v.child;b=b.firstContext;e:for(;b!==null;){var P=b;b=v;for(var Z=0;Z<o.length;Z++)if(P.context===o[Z]){b.lanes|=u,P=b.alternate,P!==null&&(P.lanes|=u),fm(b.return,u,a),f||(T=null);break e}b=P.next}}else if(v.tag===18){if(T=v.return,T===null)throw Error(s(341));T.lanes|=u,b=T.alternate,b!==null&&(b.lanes|=u),fm(T,u,a),T=null}else T=v.child;if(T!==null)T.return=v;else for(T=v;T!==null;){if(T===a){T=null;break}if(v=T.sibling,v!==null){v.return=T.return,T=v;break}T=T.return}v=T}}function Gi(a,o,u,f){a=null;for(var v=o,b=!1;v!==null;){if(!b){if((v.flags&524288)!==0)b=!0;else if((v.flags&262144)!==0)break}if(v.tag===10){var T=v.alternate;if(T===null)throw Error(s(387));if(T=T.memoizedProps,T!==null){var P=v.type;as(v.pendingProps.value,T.value)||(a!==null?a.push(P):a=[P])}}else if(v===ie.current){if(T=v.alternate,T===null)throw Error(s(387));T.memoizedState.memoizedState!==v.memoizedState.memoizedState&&(a!==null?a.push(ec):a=[ec])}v=v.return}a!==null&&hm(o,a,u,f),o.flags|=262144}function Eu(a){for(a=a.firstContext;a!==null;){if(!as(a.context._currentValue,a.memoizedValue))return!0;a=a.next}return!1}function Xr(a){Kr=a,ja=null,a=a.dependencies,a!==null&&(a.firstContext=null)}function Cn(a){return Wb(Kr,a)}function Cu(a,o){return Kr===null&&Xr(a),Wb(a,o)}function Wb(a,o){var u=o._currentValue;if(o={context:o,memoizedValue:u,next:null},ja===null){if(a===null)throw Error(s(308));ja=o,a.dependencies={lanes:0,firstContext:o},a.flags|=524288}else ja=ja.next=o;return u}var U_=typeof AbortController<"u"?AbortController:function(){var a=[],o=this.signal={aborted:!1,addEventListener:function(u,f){a.push(f)}};this.abort=function(){o.aborted=!0,a.forEach(function(u){return u()})}},B_=e.unstable_scheduleCallback,V_=e.unstable_NormalPriority,hn={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function mm(){return{controller:new U_,data:new Map,refCount:0}}function Al(a){a.refCount--,a.refCount===0&&B_(V_,function(){a.controller.abort()})}var Tl=null,pm=0,Ki=0,Xi=null;function F_(a,o){if(Tl===null){var u=Tl=[];pm=0,Ki=yp(),Xi={status:"pending",value:void 0,then:function(f){u.push(f)}}}return pm++,o.then(Yb,Yb),o}function Yb(){if(--pm===0&&Tl!==null){Xi!==null&&(Xi.status="fulfilled");var a=Tl;Tl=null,Ki=0,Xi=null;for(var o=0;o<a.length;o++)(0,a[o])()}}function H_(a,o){var u=[],f={status:"pending",value:null,reason:null,then:function(v){u.push(v)}};return a.then(function(){f.status="fulfilled",f.value=o;for(var v=0;v<u.length;v++)(0,u[v])(o)},function(v){for(f.status="rejected",f.reason=v,v=0;v<u.length;v++)(0,u[v])(void 0)}),f}var Gb=L.S;L.S=function(a,o){_w=we(),typeof o=="object"&&o!==null&&typeof o.then=="function"&&F_(a,o),Gb!==null&&Gb(a,o)};var Jr=$(null);function gm(){var a=Jr.current;return a!==null?a:_t.pooledCache}function Au(a,o){o===null?Y(Jr,Jr.current):Y(Jr,o.pool)}function Kb(){var a=gm();return a===null?null:{parent:hn._currentValue,pool:a}}var Ji=Error(s(460)),vm=Error(s(474)),Tu=Error(s(542)),Mu={then:function(){}};function Xb(a){return a=a.status,a==="fulfilled"||a==="rejected"}function Jb(a,o,u){switch(u=a[u],u===void 0?a.push(o):u!==o&&(o.then(ya,ya),o=u),o.status){case"fulfilled":return o.value;case"rejected":throw a=o.reason,e0(a),a;default:if(typeof o.status=="string")o.then(ya,ya);else{if(a=_t,a!==null&&100<a.shellSuspendCounter)throw Error(s(482));a=o,a.status="pending",a.then(function(f){if(o.status==="pending"){var v=o;v.status="fulfilled",v.value=f}},function(f){if(o.status==="pending"){var v=o;v.status="rejected",v.reason=f}})}switch(o.status){case"fulfilled":return o.value;case"rejected":throw a=o.reason,e0(a),a}throw ei=o,Ji}}function Qr(a){try{var o=a._init;return o(a._payload)}catch(u){throw u!==null&&typeof u=="object"&&typeof u.then=="function"?(ei=u,Ji):u}}var ei=null;function Qb(){if(ei===null)throw Error(s(459));var a=ei;return ei=null,a}function e0(a){if(a===Ji||a===Tu)throw Error(s(483))}var Qi=null,Ml=0;function Ru(a){var o=Ml;return Ml+=1,Qi===null&&(Qi=[]),Jb(Qi,a,o)}function Rl(a,o){o=o.props.ref,a.ref=o!==void 0?o:null}function _u(a,o){throw o.$$typeof===x?Error(s(525)):(a=Object.prototype.toString.call(o),Error(s(31,a==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":a)))}function t0(a){function o(J,K){if(a){var ne=J.deletions;ne===null?(J.deletions=[K],J.flags|=16):ne.push(K)}}function u(J,K){if(!a)return null;for(;K!==null;)o(J,K),K=K.sibling;return null}function f(J){for(var K=new Map;J!==null;)J.key!==null?K.set(J.key,J):K.set(J.index,J),J=J.sibling;return K}function v(J,K){return J=ba(J,K),J.index=0,J.sibling=null,J}function b(J,K,ne){return J.index=ne,a?(ne=J.alternate,ne!==null?(ne=ne.index,ne<K?(J.flags|=67108866,K):ne):(J.flags|=67108866,K)):(J.flags|=1048576,K)}function T(J){return a&&J.alternate===null&&(J.flags|=67108866),J}function P(J,K,ne,pe){return K===null||K.tag!==6?(K=rm(ne,J.mode,pe),K.return=J,K):(K=v(K,ne),K.return=J,K)}function Z(J,K,ne,pe){var Ve=ne.type;return Ve===N?fe(J,K,ne.props.children,pe,ne.key):K!==null&&(K.elementType===Ve||typeof Ve=="object"&&Ve!==null&&Ve.$$typeof===D&&Qr(Ve)===K.type)?(K=v(K,ne.props),Rl(K,ne),K.return=J,K):(K=Su(ne.type,ne.key,ne.props,null,J.mode,pe),Rl(K,ne),K.return=J,K)}function se(J,K,ne,pe){return K===null||K.tag!==4||K.stateNode.containerInfo!==ne.containerInfo||K.stateNode.implementation!==ne.implementation?(K=im(ne,J.mode,pe),K.return=J,K):(K=v(K,ne.children||[]),K.return=J,K)}function fe(J,K,ne,pe,Ve){return K===null||K.tag!==7?(K=Yr(ne,J.mode,pe,Ve),K.return=J,K):(K=v(K,ne),K.return=J,K)}function ge(J,K,ne){if(typeof K=="string"&&K!==""||typeof K=="number"||typeof K=="bigint")return K=rm(""+K,J.mode,ne),K.return=J,K;if(typeof K=="object"&&K!==null){switch(K.$$typeof){case w:return ne=Su(K.type,K.key,K.props,null,J.mode,ne),Rl(ne,K),ne.return=J,ne;case j:return K=im(K,J.mode,ne),K.return=J,K;case D:return K=Qr(K),ge(J,K,ne)}if(X(K)||U(K))return K=Yr(K,J.mode,ne,null),K.return=J,K;if(typeof K.then=="function")return ge(J,Ru(K),ne);if(K.$$typeof===S)return ge(J,Cu(J,K),ne);_u(J,K)}return null}function re(J,K,ne,pe){var Ve=K!==null?K.key:null;if(typeof ne=="string"&&ne!==""||typeof ne=="number"||typeof ne=="bigint")return Ve!==null?null:P(J,K,""+ne,pe);if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case w:return ne.key===Ve?Z(J,K,ne,pe):null;case j:return ne.key===Ve?se(J,K,ne,pe):null;case D:return ne=Qr(ne),re(J,K,ne,pe)}if(X(ne)||U(ne))return Ve!==null?null:fe(J,K,ne,pe,null);if(typeof ne.then=="function")return re(J,K,Ru(ne),pe);if(ne.$$typeof===S)return re(J,K,Cu(J,ne),pe);_u(J,ne)}return null}function ce(J,K,ne,pe,Ve){if(typeof pe=="string"&&pe!==""||typeof pe=="number"||typeof pe=="bigint")return J=J.get(ne)||null,P(K,J,""+pe,Ve);if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case w:return J=J.get(pe.key===null?ne:pe.key)||null,Z(K,J,pe,Ve);case j:return J=J.get(pe.key===null?ne:pe.key)||null,se(K,J,pe,Ve);case D:return pe=Qr(pe),ce(J,K,ne,pe,Ve)}if(X(pe)||U(pe))return J=J.get(ne)||null,fe(K,J,pe,Ve,null);if(typeof pe.then=="function")return ce(J,K,ne,Ru(pe),Ve);if(pe.$$typeof===S)return ce(J,K,ne,Cu(K,pe),Ve);_u(K,pe)}return null}function ze(J,K,ne,pe){for(var Ve=null,bt=null,$e=K,rt=K=0,ft=null;$e!==null&&rt<ne.length;rt++){$e.index>rt?(ft=$e,$e=null):ft=$e.sibling;var wt=re(J,$e,ne[rt],pe);if(wt===null){$e===null&&($e=ft);break}a&&$e&&wt.alternate===null&&o(J,$e),K=b(wt,K,rt),bt===null?Ve=wt:bt.sibling=wt,bt=wt,$e=ft}if(rt===ne.length)return u(J,$e),mt&&wa(J,rt),Ve;if($e===null){for(;rt<ne.length;rt++)$e=ge(J,ne[rt],pe),$e!==null&&(K=b($e,K,rt),bt===null?Ve=$e:bt.sibling=$e,bt=$e);return mt&&wa(J,rt),Ve}for($e=f($e);rt<ne.length;rt++)ft=ce($e,J,rt,ne[rt],pe),ft!==null&&(a&&ft.alternate!==null&&$e.delete(ft.key===null?rt:ft.key),K=b(ft,K,rt),bt===null?Ve=ft:bt.sibling=ft,bt=ft);return a&&$e.forEach(function(fr){return o(J,fr)}),mt&&wa(J,rt),Ve}function qe(J,K,ne,pe){if(ne==null)throw Error(s(151));for(var Ve=null,bt=null,$e=K,rt=K=0,ft=null,wt=ne.next();$e!==null&&!wt.done;rt++,wt=ne.next()){$e.index>rt?(ft=$e,$e=null):ft=$e.sibling;var fr=re(J,$e,wt.value,pe);if(fr===null){$e===null&&($e=ft);break}a&&$e&&fr.alternate===null&&o(J,$e),K=b(fr,K,rt),bt===null?Ve=fr:bt.sibling=fr,bt=fr,$e=ft}if(wt.done)return u(J,$e),mt&&wa(J,rt),Ve;if($e===null){for(;!wt.done;rt++,wt=ne.next())wt=ge(J,wt.value,pe),wt!==null&&(K=b(wt,K,rt),bt===null?Ve=wt:bt.sibling=wt,bt=wt);return mt&&wa(J,rt),Ve}for($e=f($e);!wt.done;rt++,wt=ne.next())wt=ce($e,J,rt,wt.value,pe),wt!==null&&(a&&wt.alternate!==null&&$e.delete(wt.key===null?rt:wt.key),K=b(wt,K,rt),bt===null?Ve=wt:bt.sibling=wt,bt=wt);return a&&$e.forEach(function(tO){return o(J,tO)}),mt&&wa(J,rt),Ve}function Rt(J,K,ne,pe){if(typeof ne=="object"&&ne!==null&&ne.type===N&&ne.key===null&&(ne=ne.props.children),typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case w:e:{for(var Ve=ne.key;K!==null;){if(K.key===Ve){if(Ve=ne.type,Ve===N){if(K.tag===7){u(J,K.sibling),pe=v(K,ne.props.children),pe.return=J,J=pe;break e}}else if(K.elementType===Ve||typeof Ve=="object"&&Ve!==null&&Ve.$$typeof===D&&Qr(Ve)===K.type){u(J,K.sibling),pe=v(K,ne.props),Rl(pe,ne),pe.return=J,J=pe;break e}u(J,K);break}else o(J,K);K=K.sibling}ne.type===N?(pe=Yr(ne.props.children,J.mode,pe,ne.key),pe.return=J,J=pe):(pe=Su(ne.type,ne.key,ne.props,null,J.mode,pe),Rl(pe,ne),pe.return=J,J=pe)}return T(J);case j:e:{for(Ve=ne.key;K!==null;){if(K.key===Ve)if(K.tag===4&&K.stateNode.containerInfo===ne.containerInfo&&K.stateNode.implementation===ne.implementation){u(J,K.sibling),pe=v(K,ne.children||[]),pe.return=J,J=pe;break e}else{u(J,K);break}else o(J,K);K=K.sibling}pe=im(ne,J.mode,pe),pe.return=J,J=pe}return T(J);case D:return ne=Qr(ne),Rt(J,K,ne,pe)}if(X(ne))return ze(J,K,ne,pe);if(U(ne)){if(Ve=U(ne),typeof Ve!="function")throw Error(s(150));return ne=Ve.call(ne),qe(J,K,ne,pe)}if(typeof ne.then=="function")return Rt(J,K,Ru(ne),pe);if(ne.$$typeof===S)return Rt(J,K,Cu(J,ne),pe);_u(J,ne)}return typeof ne=="string"&&ne!==""||typeof ne=="number"||typeof ne=="bigint"?(ne=""+ne,K!==null&&K.tag===6?(u(J,K.sibling),pe=v(K,ne),pe.return=J,J=pe):(u(J,K),pe=rm(ne,J.mode,pe),pe.return=J,J=pe),T(J)):u(J,K)}return function(J,K,ne,pe){try{Ml=0;var Ve=Rt(J,K,ne,pe);return Qi=null,Ve}catch($e){if($e===Ji||$e===Tu)throw $e;var bt=rs(29,$e,null,J.mode);return bt.lanes=pe,bt.return=J,bt}}}var ti=t0(!0),n0=t0(!1),Ga=!1;function ym(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function xm(a,o){a=a.updateQueue,o.updateQueue===a&&(o.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,callbacks:null})}function Ka(a){return{lane:a,tag:0,payload:null,callback:null,next:null}}function Xa(a,o,u){var f=a.updateQueue;if(f===null)return null;if(f=f.shared,(Nt&2)!==0){var v=f.pending;return v===null?o.next=o:(o.next=v.next,v.next=o),f.pending=o,o=Nu(a),$b(a,null,u),o}return ju(a,f,o,u),Nu(a)}function _l(a,o,u){if(o=o.updateQueue,o!==null&&(o=o.shared,(u&4194048)!==0)){var f=o.lanes;f&=a.pendingLanes,u|=f,o.lanes=u,Ge(a,u)}}function bm(a,o){var u=a.updateQueue,f=a.alternate;if(f!==null&&(f=f.updateQueue,u===f)){var v=null,b=null;if(u=u.firstBaseUpdate,u!==null){do{var T={lane:u.lane,tag:u.tag,payload:u.payload,callback:null,next:null};b===null?v=b=T:b=b.next=T,u=u.next}while(u!==null);b===null?v=b=o:b=b.next=o}else v=b=o;u={baseState:f.baseState,firstBaseUpdate:v,lastBaseUpdate:b,shared:f.shared,callbacks:f.callbacks},a.updateQueue=u;return}a=u.lastBaseUpdate,a===null?u.firstBaseUpdate=o:a.next=o,u.lastBaseUpdate=o}var wm=!1;function Il(){if(wm){var a=Xi;if(a!==null)throw a}}function Ol(a,o,u,f){wm=!1;var v=a.updateQueue;Ga=!1;var b=v.firstBaseUpdate,T=v.lastBaseUpdate,P=v.shared.pending;if(P!==null){v.shared.pending=null;var Z=P,se=Z.next;Z.next=null,T===null?b=se:T.next=se,T=Z;var fe=a.alternate;fe!==null&&(fe=fe.updateQueue,P=fe.lastBaseUpdate,P!==T&&(P===null?fe.firstBaseUpdate=se:P.next=se,fe.lastBaseUpdate=Z))}if(b!==null){var ge=v.baseState;T=0,fe=se=Z=null,P=b;do{var re=P.lane&-536870913,ce=re!==P.lane;if(ce?(dt&re)===re:(f&re)===re){re!==0&&re===Ki&&(wm=!0),fe!==null&&(fe=fe.next={lane:0,tag:P.tag,payload:P.payload,callback:null,next:null});e:{var ze=a,qe=P;re=o;var Rt=u;switch(qe.tag){case 1:if(ze=qe.payload,typeof ze=="function"){ge=ze.call(Rt,ge,re);break e}ge=ze;break e;case 3:ze.flags=ze.flags&-65537|128;case 0:if(ze=qe.payload,re=typeof ze=="function"?ze.call(Rt,ge,re):ze,re==null)break e;ge=y({},ge,re);break e;case 2:Ga=!0}}re=P.callback,re!==null&&(a.flags|=64,ce&&(a.flags|=8192),ce=v.callbacks,ce===null?v.callbacks=[re]:ce.push(re))}else ce={lane:re,tag:P.tag,payload:P.payload,callback:P.callback,next:null},fe===null?(se=fe=ce,Z=ge):fe=fe.next=ce,T|=re;if(P=P.next,P===null){if(P=v.shared.pending,P===null)break;ce=P,P=ce.next,ce.next=null,v.lastBaseUpdate=ce,v.shared.pending=null}}while(!0);fe===null&&(Z=ge),v.baseState=Z,v.firstBaseUpdate=se,v.lastBaseUpdate=fe,b===null&&(v.shared.lanes=0),nr|=T,a.lanes=T,a.memoizedState=ge}}function s0(a,o){if(typeof a!="function")throw Error(s(191,a));a.call(o)}function a0(a,o){var u=a.callbacks;if(u!==null)for(a.callbacks=null,a=0;a<u.length;a++)s0(u[a],o)}var eo=$(null),Iu=$(0);function r0(a,o){a=_a,Y(Iu,a),Y(eo,o),_a=a|o.baseLanes}function jm(){Y(Iu,_a),Y(eo,eo.current)}function Nm(){_a=Iu.current,B(eo),B(Iu)}var is=$(null),Ss=null;function Ja(a){var o=a.alternate;Y(cn,cn.current&1),Y(is,a),Ss===null&&(o===null||eo.current!==null||o.memoizedState!==null)&&(Ss=a)}function Sm(a){Y(cn,cn.current),Y(is,a),Ss===null&&(Ss=a)}function i0(a){a.tag===22?(Y(cn,cn.current),Y(is,a),Ss===null&&(Ss=a)):Qa()}function Qa(){Y(cn,cn.current),Y(is,is.current)}function os(a){B(is),Ss===a&&(Ss=null),B(cn)}var cn=$(0);function Ou(a){for(var o=a;o!==null;){if(o.tag===13){var u=o.memoizedState;if(u!==null&&(u=u.dehydrated,u===null||Mp(u)||Rp(u)))return o}else if(o.tag===19&&(o.memoizedProps.revealOrder==="forwards"||o.memoizedProps.revealOrder==="backwards"||o.memoizedProps.revealOrder==="unstable_legacy-backwards"||o.memoizedProps.revealOrder==="together")){if((o.flags&128)!==0)return o}else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===a)break;for(;o.sibling===null;){if(o.return===null||o.return===a)return null;o=o.return}o.sibling.return=o.return,o=o.sibling}return null}var Sa=0,st=null,Tt=null,mn=null,Du=!1,to=!1,ni=!1,Pu=0,Dl=0,no=null,q_=0;function sn(){throw Error(s(321))}function km(a,o){if(o===null)return!1;for(var u=0;u<o.length&&u<a.length;u++)if(!as(a[u],o[u]))return!1;return!0}function Em(a,o,u,f,v,b){return Sa=b,st=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,L.H=a===null||a.memoizedState===null?F0:Bm,ni=!1,b=u(f,v),ni=!1,to&&(b=l0(o,u,f,v)),o0(a),b}function o0(a){L.H=Ll;var o=Tt!==null&&Tt.next!==null;if(Sa=0,mn=Tt=st=null,Du=!1,Dl=0,no=null,o)throw Error(s(300));a===null||pn||(a=a.dependencies,a!==null&&Eu(a)&&(pn=!0))}function l0(a,o,u,f){st=a;var v=0;do{if(to&&(no=null),Dl=0,to=!1,25<=v)throw Error(s(301));if(v+=1,mn=Tt=null,a.updateQueue!=null){var b=a.updateQueue;b.lastEffect=null,b.events=null,b.stores=null,b.memoCache!=null&&(b.memoCache.index=0)}L.H=H0,b=o(u,f)}while(to);return b}function Z_(){var a=L.H,o=a.useState()[0];return o=typeof o.then=="function"?Pl(o):o,a=a.useState()[0],(Tt!==null?Tt.memoizedState:null)!==a&&(st.flags|=1024),o}function Cm(){var a=Pu!==0;return Pu=0,a}function Am(a,o,u){o.updateQueue=a.updateQueue,o.flags&=-2053,a.lanes&=~u}function Tm(a){if(Du){for(a=a.memoizedState;a!==null;){var o=a.queue;o!==null&&(o.pending=null),a=a.next}Du=!1}Sa=0,mn=Tt=st=null,to=!1,Dl=Pu=0,no=null}function zn(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return mn===null?st.memoizedState=mn=a:mn=mn.next=a,mn}function un(){if(Tt===null){var a=st.alternate;a=a!==null?a.memoizedState:null}else a=Tt.next;var o=mn===null?st.memoizedState:mn.next;if(o!==null)mn=o,Tt=a;else{if(a===null)throw st.alternate===null?Error(s(467)):Error(s(310));Tt=a,a={memoizedState:Tt.memoizedState,baseState:Tt.baseState,baseQueue:Tt.baseQueue,queue:Tt.queue,next:null},mn===null?st.memoizedState=mn=a:mn=mn.next=a}return mn}function zu(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Pl(a){var o=Dl;return Dl+=1,no===null&&(no=[]),a=Jb(no,a,o),o=st,(mn===null?o.memoizedState:mn.next)===null&&(o=o.alternate,L.H=o===null||o.memoizedState===null?F0:Bm),a}function Lu(a){if(a!==null&&typeof a=="object"){if(typeof a.then=="function")return Pl(a);if(a.$$typeof===S)return Cn(a)}throw Error(s(438,String(a)))}function Mm(a){var o=null,u=st.updateQueue;if(u!==null&&(o=u.memoCache),o==null){var f=st.alternate;f!==null&&(f=f.updateQueue,f!==null&&(f=f.memoCache,f!=null&&(o={data:f.data.map(function(v){return v.slice()}),index:0})))}if(o==null&&(o={data:[],index:0}),u===null&&(u=zu(),st.updateQueue=u),u.memoCache=o,u=o.data[o.index],u===void 0)for(u=o.data[o.index]=Array(a),f=0;f<a;f++)u[f]=O;return o.index++,u}function ka(a,o){return typeof o=="function"?o(a):o}function $u(a){var o=un();return Rm(o,Tt,a)}function Rm(a,o,u){var f=a.queue;if(f===null)throw Error(s(311));f.lastRenderedReducer=u;var v=a.baseQueue,b=f.pending;if(b!==null){if(v!==null){var T=v.next;v.next=b.next,b.next=T}o.baseQueue=v=b,f.pending=null}if(b=a.baseState,v===null)a.memoizedState=b;else{o=v.next;var P=T=null,Z=null,se=o,fe=!1;do{var ge=se.lane&-536870913;if(ge!==se.lane?(dt&ge)===ge:(Sa&ge)===ge){var re=se.revertLane;if(re===0)Z!==null&&(Z=Z.next={lane:0,revertLane:0,gesture:null,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null}),ge===Ki&&(fe=!0);else if((Sa&re)===re){se=se.next,re===Ki&&(fe=!0);continue}else ge={lane:0,revertLane:se.revertLane,gesture:null,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null},Z===null?(P=Z=ge,T=b):Z=Z.next=ge,st.lanes|=re,nr|=re;ge=se.action,ni&&u(b,ge),b=se.hasEagerState?se.eagerState:u(b,ge)}else re={lane:ge,revertLane:se.revertLane,gesture:se.gesture,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null},Z===null?(P=Z=re,T=b):Z=Z.next=re,st.lanes|=ge,nr|=ge;se=se.next}while(se!==null&&se!==o);if(Z===null?T=b:Z.next=P,!as(b,a.memoizedState)&&(pn=!0,fe&&(u=Xi,u!==null)))throw u;a.memoizedState=b,a.baseState=T,a.baseQueue=Z,f.lastRenderedState=b}return v===null&&(f.lanes=0),[a.memoizedState,f.dispatch]}function _m(a){var o=un(),u=o.queue;if(u===null)throw Error(s(311));u.lastRenderedReducer=a;var f=u.dispatch,v=u.pending,b=o.memoizedState;if(v!==null){u.pending=null;var T=v=v.next;do b=a(b,T.action),T=T.next;while(T!==v);as(b,o.memoizedState)||(pn=!0),o.memoizedState=b,o.baseQueue===null&&(o.baseState=b),u.lastRenderedState=b}return[b,f]}function c0(a,o,u){var f=st,v=un(),b=mt;if(b){if(u===void 0)throw Error(s(407));u=u()}else u=o();var T=!as((Tt||v).memoizedState,u);if(T&&(v.memoizedState=u,pn=!0),v=v.queue,Dm(f0.bind(null,f,v,a),[a]),v.getSnapshot!==o||T||mn!==null&&mn.memoizedState.tag&1){if(f.flags|=2048,so(9,{destroy:void 0},d0.bind(null,f,v,u,o),null),_t===null)throw Error(s(349));b||(Sa&127)!==0||u0(f,o,u)}return u}function u0(a,o,u){a.flags|=16384,a={getSnapshot:o,value:u},o=st.updateQueue,o===null?(o=zu(),st.updateQueue=o,o.stores=[a]):(u=o.stores,u===null?o.stores=[a]:u.push(a))}function d0(a,o,u,f){o.value=u,o.getSnapshot=f,h0(o)&&m0(a)}function f0(a,o,u){return u(function(){h0(o)&&m0(a)})}function h0(a){var o=a.getSnapshot;a=a.value;try{var u=o();return!as(a,u)}catch{return!0}}function m0(a){var o=Wr(a,2);o!==null&&Jn(o,a,2)}function Im(a){var o=zn();if(typeof a=="function"){var u=a;if(a=u(),ni){tt(!0);try{u()}finally{tt(!1)}}}return o.memoizedState=o.baseState=a,o.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ka,lastRenderedState:a},o}function p0(a,o,u,f){return a.baseState=u,Rm(a,Tt,typeof f=="function"?f:ka)}function W_(a,o,u,f,v){if(Vu(a))throw Error(s(485));if(a=o.action,a!==null){var b={payload:v,action:a,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(T){b.listeners.push(T)}};L.T!==null?u(!0):b.isTransition=!1,f(b),u=o.pending,u===null?(b.next=o.pending=b,g0(o,b)):(b.next=u.next,o.pending=u.next=b)}}function g0(a,o){var u=o.action,f=o.payload,v=a.state;if(o.isTransition){var b=L.T,T={};L.T=T;try{var P=u(v,f),Z=L.S;Z!==null&&Z(T,P),v0(a,o,P)}catch(se){Om(a,o,se)}finally{b!==null&&T.types!==null&&(b.types=T.types),L.T=b}}else try{b=u(v,f),v0(a,o,b)}catch(se){Om(a,o,se)}}function v0(a,o,u){u!==null&&typeof u=="object"&&typeof u.then=="function"?u.then(function(f){y0(a,o,f)},function(f){return Om(a,o,f)}):y0(a,o,u)}function y0(a,o,u){o.status="fulfilled",o.value=u,x0(o),a.state=u,o=a.pending,o!==null&&(u=o.next,u===o?a.pending=null:(u=u.next,o.next=u,g0(a,u)))}function Om(a,o,u){var f=a.pending;if(a.pending=null,f!==null){f=f.next;do o.status="rejected",o.reason=u,x0(o),o=o.next;while(o!==f)}a.action=null}function x0(a){a=a.listeners;for(var o=0;o<a.length;o++)(0,a[o])()}function b0(a,o){return o}function w0(a,o){if(mt){var u=_t.formState;if(u!==null){e:{var f=st;if(mt){if($t){t:{for(var v=$t,b=Ns;v.nodeType!==8;){if(!b){v=null;break t}if(v=ks(v.nextSibling),v===null){v=null;break t}}b=v.data,v=b==="F!"||b==="F"?v:null}if(v){$t=ks(v.nextSibling),f=v.data==="F!";break e}}Wa(f)}f=!1}f&&(o=u[0])}}return u=zn(),u.memoizedState=u.baseState=o,f={pending:null,lanes:0,dispatch:null,lastRenderedReducer:b0,lastRenderedState:o},u.queue=f,u=U0.bind(null,st,f),f.dispatch=u,f=Im(!1),b=Um.bind(null,st,!1,f.queue),f=zn(),v={state:o,dispatch:null,action:a,pending:null},f.queue=v,u=W_.bind(null,st,v,b,u),v.dispatch=u,f.memoizedState=a,[o,u,!1]}function j0(a){var o=un();return N0(o,Tt,a)}function N0(a,o,u){if(o=Rm(a,o,b0)[0],a=$u(ka)[0],typeof o=="object"&&o!==null&&typeof o.then=="function")try{var f=Pl(o)}catch(T){throw T===Ji?Tu:T}else f=o;o=un();var v=o.queue,b=v.dispatch;return u!==o.memoizedState&&(st.flags|=2048,so(9,{destroy:void 0},Y_.bind(null,v,u),null)),[f,b,a]}function Y_(a,o){a.action=o}function S0(a){var o=un(),u=Tt;if(u!==null)return N0(o,u,a);un(),o=o.memoizedState,u=un();var f=u.queue.dispatch;return u.memoizedState=a,[o,f,!1]}function so(a,o,u,f){return a={tag:a,create:u,deps:f,inst:o,next:null},o=st.updateQueue,o===null&&(o=zu(),st.updateQueue=o),u=o.lastEffect,u===null?o.lastEffect=a.next=a:(f=u.next,u.next=a,a.next=f,o.lastEffect=a),a}function k0(){return un().memoizedState}function Uu(a,o,u,f){var v=zn();st.flags|=a,v.memoizedState=so(1|o,{destroy:void 0},u,f===void 0?null:f)}function Bu(a,o,u,f){var v=un();f=f===void 0?null:f;var b=v.memoizedState.inst;Tt!==null&&f!==null&&km(f,Tt.memoizedState.deps)?v.memoizedState=so(o,b,u,f):(st.flags|=a,v.memoizedState=so(1|o,b,u,f))}function E0(a,o){Uu(8390656,8,a,o)}function Dm(a,o){Bu(2048,8,a,o)}function G_(a){st.flags|=4;var o=st.updateQueue;if(o===null)o=zu(),st.updateQueue=o,o.events=[a];else{var u=o.events;u===null?o.events=[a]:u.push(a)}}function C0(a){var o=un().memoizedState;return G_({ref:o,nextImpl:a}),function(){if((Nt&2)!==0)throw Error(s(440));return o.impl.apply(void 0,arguments)}}function A0(a,o){return Bu(4,2,a,o)}function T0(a,o){return Bu(4,4,a,o)}function M0(a,o){if(typeof o=="function"){a=a();var u=o(a);return function(){typeof u=="function"?u():o(null)}}if(o!=null)return a=a(),o.current=a,function(){o.current=null}}function R0(a,o,u){u=u!=null?u.concat([a]):null,Bu(4,4,M0.bind(null,o,a),u)}function Pm(){}function _0(a,o){var u=un();o=o===void 0?null:o;var f=u.memoizedState;return o!==null&&km(o,f[1])?f[0]:(u.memoizedState=[a,o],a)}function I0(a,o){var u=un();o=o===void 0?null:o;var f=u.memoizedState;if(o!==null&&km(o,f[1]))return f[0];if(f=a(),ni){tt(!0);try{a()}finally{tt(!1)}}return u.memoizedState=[f,o],f}function zm(a,o,u){return u===void 0||(Sa&1073741824)!==0&&(dt&261930)===0?a.memoizedState=o:(a.memoizedState=u,a=Ow(),st.lanes|=a,nr|=a,u)}function O0(a,o,u,f){return as(u,o)?u:eo.current!==null?(a=zm(a,u,f),as(a,o)||(pn=!0),a):(Sa&42)===0||(Sa&1073741824)!==0&&(dt&261930)===0?(pn=!0,a.memoizedState=u):(a=Ow(),st.lanes|=a,nr|=a,o)}function D0(a,o,u,f,v){var b=F.p;F.p=b!==0&&8>b?b:8;var T=L.T,P={};L.T=P,Um(a,!1,o,u);try{var Z=v(),se=L.S;if(se!==null&&se(P,Z),Z!==null&&typeof Z=="object"&&typeof Z.then=="function"){var fe=H_(Z,f);zl(a,o,fe,us(a))}else zl(a,o,f,us(a))}catch(ge){zl(a,o,{then:function(){},status:"rejected",reason:ge},us())}finally{F.p=b,T!==null&&P.types!==null&&(T.types=P.types),L.T=T}}function K_(){}function Lm(a,o,u,f){if(a.tag!==5)throw Error(s(476));var v=P0(a).queue;D0(a,v,o,H,u===null?K_:function(){return z0(a),u(f)})}function P0(a){var o=a.memoizedState;if(o!==null)return o;o={memoizedState:H,baseState:H,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ka,lastRenderedState:H},next:null};var u={};return o.next={memoizedState:u,baseState:u,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ka,lastRenderedState:u},next:null},a.memoizedState=o,a=a.alternate,a!==null&&(a.memoizedState=o),o}function z0(a){var o=P0(a);o.next===null&&(o=a.alternate.memoizedState),zl(a,o.next.queue,{},us())}function $m(){return Cn(ec)}function L0(){return un().memoizedState}function $0(){return un().memoizedState}function X_(a){for(var o=a.return;o!==null;){switch(o.tag){case 24:case 3:var u=us();a=Ka(u);var f=Xa(o,a,u);f!==null&&(Jn(f,o,u),_l(f,o,u)),o={cache:mm()},a.payload=o;return}o=o.return}}function J_(a,o,u){var f=us();u={lane:f,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Vu(a)?B0(o,u):(u=sm(a,o,u,f),u!==null&&(Jn(u,a,f),V0(u,o,f)))}function U0(a,o,u){var f=us();zl(a,o,u,f)}function zl(a,o,u,f){var v={lane:f,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null};if(Vu(a))B0(o,v);else{var b=a.alternate;if(a.lanes===0&&(b===null||b.lanes===0)&&(b=o.lastRenderedReducer,b!==null))try{var T=o.lastRenderedState,P=b(T,u);if(v.hasEagerState=!0,v.eagerState=P,as(P,T))return ju(a,o,v,0),_t===null&&wu(),!1}catch{}if(u=sm(a,o,v,f),u!==null)return Jn(u,a,f),V0(u,o,f),!0}return!1}function Um(a,o,u,f){if(f={lane:2,revertLane:yp(),gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},Vu(a)){if(o)throw Error(s(479))}else o=sm(a,u,f,2),o!==null&&Jn(o,a,2)}function Vu(a){var o=a.alternate;return a===st||o!==null&&o===st}function B0(a,o){to=Du=!0;var u=a.pending;u===null?o.next=o:(o.next=u.next,u.next=o),a.pending=o}function V0(a,o,u){if((u&4194048)!==0){var f=o.lanes;f&=a.pendingLanes,u|=f,o.lanes=u,Ge(a,u)}}var Ll={readContext:Cn,use:Lu,useCallback:sn,useContext:sn,useEffect:sn,useImperativeHandle:sn,useLayoutEffect:sn,useInsertionEffect:sn,useMemo:sn,useReducer:sn,useRef:sn,useState:sn,useDebugValue:sn,useDeferredValue:sn,useTransition:sn,useSyncExternalStore:sn,useId:sn,useHostTransitionStatus:sn,useFormState:sn,useActionState:sn,useOptimistic:sn,useMemoCache:sn,useCacheRefresh:sn};Ll.useEffectEvent=sn;var F0={readContext:Cn,use:Lu,useCallback:function(a,o){return zn().memoizedState=[a,o===void 0?null:o],a},useContext:Cn,useEffect:E0,useImperativeHandle:function(a,o,u){u=u!=null?u.concat([a]):null,Uu(4194308,4,M0.bind(null,o,a),u)},useLayoutEffect:function(a,o){return Uu(4194308,4,a,o)},useInsertionEffect:function(a,o){Uu(4,2,a,o)},useMemo:function(a,o){var u=zn();o=o===void 0?null:o;var f=a();if(ni){tt(!0);try{a()}finally{tt(!1)}}return u.memoizedState=[f,o],f},useReducer:function(a,o,u){var f=zn();if(u!==void 0){var v=u(o);if(ni){tt(!0);try{u(o)}finally{tt(!1)}}}else v=o;return f.memoizedState=f.baseState=v,a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:v},f.queue=a,a=a.dispatch=J_.bind(null,st,a),[f.memoizedState,a]},useRef:function(a){var o=zn();return a={current:a},o.memoizedState=a},useState:function(a){a=Im(a);var o=a.queue,u=U0.bind(null,st,o);return o.dispatch=u,[a.memoizedState,u]},useDebugValue:Pm,useDeferredValue:function(a,o){var u=zn();return zm(u,a,o)},useTransition:function(){var a=Im(!1);return a=D0.bind(null,st,a.queue,!0,!1),zn().memoizedState=a,[!1,a]},useSyncExternalStore:function(a,o,u){var f=st,v=zn();if(mt){if(u===void 0)throw Error(s(407));u=u()}else{if(u=o(),_t===null)throw Error(s(349));(dt&127)!==0||u0(f,o,u)}v.memoizedState=u;var b={value:u,getSnapshot:o};return v.queue=b,E0(f0.bind(null,f,b,a),[a]),f.flags|=2048,so(9,{destroy:void 0},d0.bind(null,f,b,u,o),null),u},useId:function(){var a=zn(),o=_t.identifierPrefix;if(mt){var u=Js,f=Xs;u=(f&~(1<<32-at(f)-1)).toString(32)+u,o="_"+o+"R_"+u,u=Pu++,0<u&&(o+="H"+u.toString(32)),o+="_"}else u=q_++,o="_"+o+"r_"+u.toString(32)+"_";return a.memoizedState=o},useHostTransitionStatus:$m,useFormState:w0,useActionState:w0,useOptimistic:function(a){var o=zn();o.memoizedState=o.baseState=a;var u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return o.queue=u,o=Um.bind(null,st,!0,u),u.dispatch=o,[a,o]},useMemoCache:Mm,useCacheRefresh:function(){return zn().memoizedState=X_.bind(null,st)},useEffectEvent:function(a){var o=zn(),u={impl:a};return o.memoizedState=u,function(){if((Nt&2)!==0)throw Error(s(440));return u.impl.apply(void 0,arguments)}}},Bm={readContext:Cn,use:Lu,useCallback:_0,useContext:Cn,useEffect:Dm,useImperativeHandle:R0,useInsertionEffect:A0,useLayoutEffect:T0,useMemo:I0,useReducer:$u,useRef:k0,useState:function(){return $u(ka)},useDebugValue:Pm,useDeferredValue:function(a,o){var u=un();return O0(u,Tt.memoizedState,a,o)},useTransition:function(){var a=$u(ka)[0],o=un().memoizedState;return[typeof a=="boolean"?a:Pl(a),o]},useSyncExternalStore:c0,useId:L0,useHostTransitionStatus:$m,useFormState:j0,useActionState:j0,useOptimistic:function(a,o){var u=un();return p0(u,Tt,a,o)},useMemoCache:Mm,useCacheRefresh:$0};Bm.useEffectEvent=C0;var H0={readContext:Cn,use:Lu,useCallback:_0,useContext:Cn,useEffect:Dm,useImperativeHandle:R0,useInsertionEffect:A0,useLayoutEffect:T0,useMemo:I0,useReducer:_m,useRef:k0,useState:function(){return _m(ka)},useDebugValue:Pm,useDeferredValue:function(a,o){var u=un();return Tt===null?zm(u,a,o):O0(u,Tt.memoizedState,a,o)},useTransition:function(){var a=_m(ka)[0],o=un().memoizedState;return[typeof a=="boolean"?a:Pl(a),o]},useSyncExternalStore:c0,useId:L0,useHostTransitionStatus:$m,useFormState:S0,useActionState:S0,useOptimistic:function(a,o){var u=un();return Tt!==null?p0(u,Tt,a,o):(u.baseState=a,[a,u.queue.dispatch])},useMemoCache:Mm,useCacheRefresh:$0};H0.useEffectEvent=C0;function Vm(a,o,u,f){o=a.memoizedState,u=u(f,o),u=u==null?o:y({},o,u),a.memoizedState=u,a.lanes===0&&(a.updateQueue.baseState=u)}var Fm={enqueueSetState:function(a,o,u){a=a._reactInternals;var f=us(),v=Ka(f);v.payload=o,u!=null&&(v.callback=u),o=Xa(a,v,f),o!==null&&(Jn(o,a,f),_l(o,a,f))},enqueueReplaceState:function(a,o,u){a=a._reactInternals;var f=us(),v=Ka(f);v.tag=1,v.payload=o,u!=null&&(v.callback=u),o=Xa(a,v,f),o!==null&&(Jn(o,a,f),_l(o,a,f))},enqueueForceUpdate:function(a,o){a=a._reactInternals;var u=us(),f=Ka(u);f.tag=2,o!=null&&(f.callback=o),o=Xa(a,f,u),o!==null&&(Jn(o,a,u),_l(o,a,u))}};function q0(a,o,u,f,v,b,T){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(f,b,T):o.prototype&&o.prototype.isPureReactComponent?!Sl(u,f)||!Sl(v,b):!0}function Z0(a,o,u,f){a=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(u,f),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(u,f),o.state!==a&&Fm.enqueueReplaceState(o,o.state,null)}function si(a,o){var u=o;if("ref"in o){u={};for(var f in o)f!=="ref"&&(u[f]=o[f])}if(a=a.defaultProps){u===o&&(u=y({},u));for(var v in a)u[v]===void 0&&(u[v]=a[v])}return u}function W0(a){bu(a)}function Y0(a){console.error(a)}function G0(a){bu(a)}function Fu(a,o){try{var u=a.onUncaughtError;u(o.value,{componentStack:o.stack})}catch(f){setTimeout(function(){throw f})}}function K0(a,o,u){try{var f=a.onCaughtError;f(u.value,{componentStack:u.stack,errorBoundary:o.tag===1?o.stateNode:null})}catch(v){setTimeout(function(){throw v})}}function Hm(a,o,u){return u=Ka(u),u.tag=3,u.payload={element:null},u.callback=function(){Fu(a,o)},u}function X0(a){return a=Ka(a),a.tag=3,a}function J0(a,o,u,f){var v=u.type.getDerivedStateFromError;if(typeof v=="function"){var b=f.value;a.payload=function(){return v(b)},a.callback=function(){K0(o,u,f)}}var T=u.stateNode;T!==null&&typeof T.componentDidCatch=="function"&&(a.callback=function(){K0(o,u,f),typeof v!="function"&&(sr===null?sr=new Set([this]):sr.add(this));var P=f.stack;this.componentDidCatch(f.value,{componentStack:P!==null?P:""})})}function Q_(a,o,u,f,v){if(u.flags|=32768,f!==null&&typeof f=="object"&&typeof f.then=="function"){if(o=u.alternate,o!==null&&Gi(o,u,v,!0),u=is.current,u!==null){switch(u.tag){case 31:case 13:return Ss===null?td():u.alternate===null&&an===0&&(an=3),u.flags&=-257,u.flags|=65536,u.lanes=v,f===Mu?u.flags|=16384:(o=u.updateQueue,o===null?u.updateQueue=new Set([f]):o.add(f),pp(a,f,v)),!1;case 22:return u.flags|=65536,f===Mu?u.flags|=16384:(o=u.updateQueue,o===null?(o={transitions:null,markerInstances:null,retryQueue:new Set([f])},u.updateQueue=o):(u=o.retryQueue,u===null?o.retryQueue=new Set([f]):u.add(f)),pp(a,f,v)),!1}throw Error(s(435,u.tag))}return pp(a,f,v),td(),!1}if(mt)return o=is.current,o!==null?((o.flags&65536)===0&&(o.flags|=256),o.flags|=65536,o.lanes=v,f!==cm&&(a=Error(s(422),{cause:f}),Cl(bs(a,u)))):(f!==cm&&(o=Error(s(423),{cause:f}),Cl(bs(o,u))),a=a.current.alternate,a.flags|=65536,v&=-v,a.lanes|=v,f=bs(f,u),v=Hm(a.stateNode,f,v),bm(a,v),an!==4&&(an=2)),!1;var b=Error(s(520),{cause:f});if(b=bs(b,u),Zl===null?Zl=[b]:Zl.push(b),an!==4&&(an=2),o===null)return!0;f=bs(f,u),u=o;do{switch(u.tag){case 3:return u.flags|=65536,a=v&-v,u.lanes|=a,a=Hm(u.stateNode,f,a),bm(u,a),!1;case 1:if(o=u.type,b=u.stateNode,(u.flags&128)===0&&(typeof o.getDerivedStateFromError=="function"||b!==null&&typeof b.componentDidCatch=="function"&&(sr===null||!sr.has(b))))return u.flags|=65536,v&=-v,u.lanes|=v,v=X0(v),J0(v,a,u,f),bm(u,v),!1}u=u.return}while(u!==null);return!1}var qm=Error(s(461)),pn=!1;function An(a,o,u,f){o.child=a===null?n0(o,null,u,f):ti(o,a.child,u,f)}function Q0(a,o,u,f,v){u=u.render;var b=o.ref;if("ref"in f){var T={};for(var P in f)P!=="ref"&&(T[P]=f[P])}else T=f;return Xr(o),f=Em(a,o,u,T,b,v),P=Cm(),a!==null&&!pn?(Am(a,o,v),Ea(a,o,v)):(mt&&P&&om(o),o.flags|=1,An(a,o,f,v),o.child)}function ew(a,o,u,f,v){if(a===null){var b=u.type;return typeof b=="function"&&!am(b)&&b.defaultProps===void 0&&u.compare===null?(o.tag=15,o.type=b,tw(a,o,b,f,v)):(a=Su(u.type,null,f,o,o.mode,v),a.ref=o.ref,a.return=o,o.child=a)}if(b=a.child,!Qm(a,v)){var T=b.memoizedProps;if(u=u.compare,u=u!==null?u:Sl,u(T,f)&&a.ref===o.ref)return Ea(a,o,v)}return o.flags|=1,a=ba(b,f),a.ref=o.ref,a.return=o,o.child=a}function tw(a,o,u,f,v){if(a!==null){var b=a.memoizedProps;if(Sl(b,f)&&a.ref===o.ref)if(pn=!1,o.pendingProps=f=b,Qm(a,v))(a.flags&131072)!==0&&(pn=!0);else return o.lanes=a.lanes,Ea(a,o,v)}return Zm(a,o,u,f,v)}function nw(a,o,u,f){var v=f.children,b=a!==null?a.memoizedState:null;if(a===null&&o.stateNode===null&&(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),f.mode==="hidden"){if((o.flags&128)!==0){if(b=b!==null?b.baseLanes|u:u,a!==null){for(f=o.child=a.child,v=0;f!==null;)v=v|f.lanes|f.childLanes,f=f.sibling;f=v&~b}else f=0,o.child=null;return sw(a,o,b,u,f)}if((u&536870912)!==0)o.memoizedState={baseLanes:0,cachePool:null},a!==null&&Au(o,b!==null?b.cachePool:null),b!==null?r0(o,b):jm(),i0(o);else return f=o.lanes=536870912,sw(a,o,b!==null?b.baseLanes|u:u,u,f)}else b!==null?(Au(o,b.cachePool),r0(o,b),Qa(),o.memoizedState=null):(a!==null&&Au(o,null),jm(),Qa());return An(a,o,v,u),o.child}function $l(a,o){return a!==null&&a.tag===22||o.stateNode!==null||(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.sibling}function sw(a,o,u,f,v){var b=gm();return b=b===null?null:{parent:hn._currentValue,pool:b},o.memoizedState={baseLanes:u,cachePool:b},a!==null&&Au(o,null),jm(),i0(o),a!==null&&Gi(a,o,f,!0),o.childLanes=v,null}function Hu(a,o){return o=Zu({mode:o.mode,children:o.children},a.mode),o.ref=a.ref,a.child=o,o.return=a,o}function aw(a,o,u){return ti(o,a.child,null,u),a=Hu(o,o.pendingProps),a.flags|=2,os(o),o.memoizedState=null,a}function eI(a,o,u){var f=o.pendingProps,v=(o.flags&128)!==0;if(o.flags&=-129,a===null){if(mt){if(f.mode==="hidden")return a=Hu(o,f),o.lanes=536870912,$l(null,a);if(Sm(o),(a=$t)?(a=gj(a,Ns),a=a!==null&&a.data==="&"?a:null,a!==null&&(o.memoizedState={dehydrated:a,treeContext:qa!==null?{id:Xs,overflow:Js}:null,retryLane:536870912,hydrationErrors:null},u=Bb(a),u.return=o,o.child=u,En=o,$t=null)):a=null,a===null)throw Wa(o);return o.lanes=536870912,null}return Hu(o,f)}var b=a.memoizedState;if(b!==null){var T=b.dehydrated;if(Sm(o),v)if(o.flags&256)o.flags&=-257,o=aw(a,o,u);else if(o.memoizedState!==null)o.child=a.child,o.flags|=128,o=null;else throw Error(s(558));else if(pn||Gi(a,o,u,!1),v=(u&a.childLanes)!==0,pn||v){if(f=_t,f!==null&&(T=vt(f,u),T!==0&&T!==b.retryLane))throw b.retryLane=T,Wr(a,T),Jn(f,a,T),qm;td(),o=aw(a,o,u)}else a=b.treeContext,$t=ks(T.nextSibling),En=o,mt=!0,Za=null,Ns=!1,a!==null&&Hb(o,a),o=Hu(o,f),o.flags|=4096;return o}return a=ba(a.child,{mode:f.mode,children:f.children}),a.ref=o.ref,o.child=a,a.return=o,a}function qu(a,o){var u=o.ref;if(u===null)a!==null&&a.ref!==null&&(o.flags|=4194816);else{if(typeof u!="function"&&typeof u!="object")throw Error(s(284));(a===null||a.ref!==u)&&(o.flags|=4194816)}}function Zm(a,o,u,f,v){return Xr(o),u=Em(a,o,u,f,void 0,v),f=Cm(),a!==null&&!pn?(Am(a,o,v),Ea(a,o,v)):(mt&&f&&om(o),o.flags|=1,An(a,o,u,v),o.child)}function rw(a,o,u,f,v,b){return Xr(o),o.updateQueue=null,u=l0(o,f,u,v),o0(a),f=Cm(),a!==null&&!pn?(Am(a,o,b),Ea(a,o,b)):(mt&&f&&om(o),o.flags|=1,An(a,o,u,b),o.child)}function iw(a,o,u,f,v){if(Xr(o),o.stateNode===null){var b=qi,T=u.contextType;typeof T=="object"&&T!==null&&(b=Cn(T)),b=new u(f,b),o.memoizedState=b.state!==null&&b.state!==void 0?b.state:null,b.updater=Fm,o.stateNode=b,b._reactInternals=o,b=o.stateNode,b.props=f,b.state=o.memoizedState,b.refs={},ym(o),T=u.contextType,b.context=typeof T=="object"&&T!==null?Cn(T):qi,b.state=o.memoizedState,T=u.getDerivedStateFromProps,typeof T=="function"&&(Vm(o,u,T,f),b.state=o.memoizedState),typeof u.getDerivedStateFromProps=="function"||typeof b.getSnapshotBeforeUpdate=="function"||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(T=b.state,typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount(),T!==b.state&&Fm.enqueueReplaceState(b,b.state,null),Ol(o,f,b,v),Il(),b.state=o.memoizedState),typeof b.componentDidMount=="function"&&(o.flags|=4194308),f=!0}else if(a===null){b=o.stateNode;var P=o.memoizedProps,Z=si(u,P);b.props=Z;var se=b.context,fe=u.contextType;T=qi,typeof fe=="object"&&fe!==null&&(T=Cn(fe));var ge=u.getDerivedStateFromProps;fe=typeof ge=="function"||typeof b.getSnapshotBeforeUpdate=="function",P=o.pendingProps!==P,fe||typeof b.UNSAFE_componentWillReceiveProps!="function"&&typeof b.componentWillReceiveProps!="function"||(P||se!==T)&&Z0(o,b,f,T),Ga=!1;var re=o.memoizedState;b.state=re,Ol(o,f,b,v),Il(),se=o.memoizedState,P||re!==se||Ga?(typeof ge=="function"&&(Vm(o,u,ge,f),se=o.memoizedState),(Z=Ga||q0(o,u,Z,f,re,se,T))?(fe||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount()),typeof b.componentDidMount=="function"&&(o.flags|=4194308)):(typeof b.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=f,o.memoizedState=se),b.props=f,b.state=se,b.context=T,f=Z):(typeof b.componentDidMount=="function"&&(o.flags|=4194308),f=!1)}else{b=o.stateNode,xm(a,o),T=o.memoizedProps,fe=si(u,T),b.props=fe,ge=o.pendingProps,re=b.context,se=u.contextType,Z=qi,typeof se=="object"&&se!==null&&(Z=Cn(se)),P=u.getDerivedStateFromProps,(se=typeof P=="function"||typeof b.getSnapshotBeforeUpdate=="function")||typeof b.UNSAFE_componentWillReceiveProps!="function"&&typeof b.componentWillReceiveProps!="function"||(T!==ge||re!==Z)&&Z0(o,b,f,Z),Ga=!1,re=o.memoizedState,b.state=re,Ol(o,f,b,v),Il();var ce=o.memoizedState;T!==ge||re!==ce||Ga||a!==null&&a.dependencies!==null&&Eu(a.dependencies)?(typeof P=="function"&&(Vm(o,u,P,f),ce=o.memoizedState),(fe=Ga||q0(o,u,fe,f,re,ce,Z)||a!==null&&a.dependencies!==null&&Eu(a.dependencies))?(se||typeof b.UNSAFE_componentWillUpdate!="function"&&typeof b.componentWillUpdate!="function"||(typeof b.componentWillUpdate=="function"&&b.componentWillUpdate(f,ce,Z),typeof b.UNSAFE_componentWillUpdate=="function"&&b.UNSAFE_componentWillUpdate(f,ce,Z)),typeof b.componentDidUpdate=="function"&&(o.flags|=4),typeof b.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof b.componentDidUpdate!="function"||T===a.memoizedProps&&re===a.memoizedState||(o.flags|=4),typeof b.getSnapshotBeforeUpdate!="function"||T===a.memoizedProps&&re===a.memoizedState||(o.flags|=1024),o.memoizedProps=f,o.memoizedState=ce),b.props=f,b.state=ce,b.context=Z,f=fe):(typeof b.componentDidUpdate!="function"||T===a.memoizedProps&&re===a.memoizedState||(o.flags|=4),typeof b.getSnapshotBeforeUpdate!="function"||T===a.memoizedProps&&re===a.memoizedState||(o.flags|=1024),f=!1)}return b=f,qu(a,o),f=(o.flags&128)!==0,b||f?(b=o.stateNode,u=f&&typeof u.getDerivedStateFromError!="function"?null:b.render(),o.flags|=1,a!==null&&f?(o.child=ti(o,a.child,null,v),o.child=ti(o,null,u,v)):An(a,o,u,v),o.memoizedState=b.state,a=o.child):a=Ea(a,o,v),a}function ow(a,o,u,f){return Gr(),o.flags|=256,An(a,o,u,f),o.child}var Wm={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Ym(a){return{baseLanes:a,cachePool:Kb()}}function Gm(a,o,u){return a=a!==null?a.childLanes&~u:0,o&&(a|=cs),a}function lw(a,o,u){var f=o.pendingProps,v=!1,b=(o.flags&128)!==0,T;if((T=b)||(T=a!==null&&a.memoizedState===null?!1:(cn.current&2)!==0),T&&(v=!0,o.flags&=-129),T=(o.flags&32)!==0,o.flags&=-33,a===null){if(mt){if(v?Ja(o):Qa(),(a=$t)?(a=gj(a,Ns),a=a!==null&&a.data!=="&"?a:null,a!==null&&(o.memoizedState={dehydrated:a,treeContext:qa!==null?{id:Xs,overflow:Js}:null,retryLane:536870912,hydrationErrors:null},u=Bb(a),u.return=o,o.child=u,En=o,$t=null)):a=null,a===null)throw Wa(o);return Rp(a)?o.lanes=32:o.lanes=536870912,null}var P=f.children;return f=f.fallback,v?(Qa(),v=o.mode,P=Zu({mode:"hidden",children:P},v),f=Yr(f,v,u,null),P.return=o,f.return=o,P.sibling=f,o.child=P,f=o.child,f.memoizedState=Ym(u),f.childLanes=Gm(a,T,u),o.memoizedState=Wm,$l(null,f)):(Ja(o),Km(o,P))}var Z=a.memoizedState;if(Z!==null&&(P=Z.dehydrated,P!==null)){if(b)o.flags&256?(Ja(o),o.flags&=-257,o=Xm(a,o,u)):o.memoizedState!==null?(Qa(),o.child=a.child,o.flags|=128,o=null):(Qa(),P=f.fallback,v=o.mode,f=Zu({mode:"visible",children:f.children},v),P=Yr(P,v,u,null),P.flags|=2,f.return=o,P.return=o,f.sibling=P,o.child=f,ti(o,a.child,null,u),f=o.child,f.memoizedState=Ym(u),f.childLanes=Gm(a,T,u),o.memoizedState=Wm,o=$l(null,f));else if(Ja(o),Rp(P)){if(T=P.nextSibling&&P.nextSibling.dataset,T)var se=T.dgst;T=se,f=Error(s(419)),f.stack="",f.digest=T,Cl({value:f,source:null,stack:null}),o=Xm(a,o,u)}else if(pn||Gi(a,o,u,!1),T=(u&a.childLanes)!==0,pn||T){if(T=_t,T!==null&&(f=vt(T,u),f!==0&&f!==Z.retryLane))throw Z.retryLane=f,Wr(a,f),Jn(T,a,f),qm;Mp(P)||td(),o=Xm(a,o,u)}else Mp(P)?(o.flags|=192,o.child=a.child,o=null):(a=Z.treeContext,$t=ks(P.nextSibling),En=o,mt=!0,Za=null,Ns=!1,a!==null&&Hb(o,a),o=Km(o,f.children),o.flags|=4096);return o}return v?(Qa(),P=f.fallback,v=o.mode,Z=a.child,se=Z.sibling,f=ba(Z,{mode:"hidden",children:f.children}),f.subtreeFlags=Z.subtreeFlags&65011712,se!==null?P=ba(se,P):(P=Yr(P,v,u,null),P.flags|=2),P.return=o,f.return=o,f.sibling=P,o.child=f,$l(null,f),f=o.child,P=a.child.memoizedState,P===null?P=Ym(u):(v=P.cachePool,v!==null?(Z=hn._currentValue,v=v.parent!==Z?{parent:Z,pool:Z}:v):v=Kb(),P={baseLanes:P.baseLanes|u,cachePool:v}),f.memoizedState=P,f.childLanes=Gm(a,T,u),o.memoizedState=Wm,$l(a.child,f)):(Ja(o),u=a.child,a=u.sibling,u=ba(u,{mode:"visible",children:f.children}),u.return=o,u.sibling=null,a!==null&&(T=o.deletions,T===null?(o.deletions=[a],o.flags|=16):T.push(a)),o.child=u,o.memoizedState=null,u)}function Km(a,o){return o=Zu({mode:"visible",children:o},a.mode),o.return=a,a.child=o}function Zu(a,o){return a=rs(22,a,null,o),a.lanes=0,a}function Xm(a,o,u){return ti(o,a.child,null,u),a=Km(o,o.pendingProps.children),a.flags|=2,o.memoizedState=null,a}function cw(a,o,u){a.lanes|=o;var f=a.alternate;f!==null&&(f.lanes|=o),fm(a.return,o,u)}function Jm(a,o,u,f,v,b){var T=a.memoizedState;T===null?a.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:f,tail:u,tailMode:v,treeForkCount:b}:(T.isBackwards=o,T.rendering=null,T.renderingStartTime=0,T.last=f,T.tail=u,T.tailMode=v,T.treeForkCount=b)}function uw(a,o,u){var f=o.pendingProps,v=f.revealOrder,b=f.tail;f=f.children;var T=cn.current,P=(T&2)!==0;if(P?(T=T&1|2,o.flags|=128):T&=1,Y(cn,T),An(a,o,f,u),f=mt?El:0,!P&&a!==null&&(a.flags&128)!==0)e:for(a=o.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&cw(a,u,o);else if(a.tag===19)cw(a,u,o);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===o)break e;for(;a.sibling===null;){if(a.return===null||a.return===o)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}switch(v){case"forwards":for(u=o.child,v=null;u!==null;)a=u.alternate,a!==null&&Ou(a)===null&&(v=u),u=u.sibling;u=v,u===null?(v=o.child,o.child=null):(v=u.sibling,u.sibling=null),Jm(o,!1,v,u,b,f);break;case"backwards":case"unstable_legacy-backwards":for(u=null,v=o.child,o.child=null;v!==null;){if(a=v.alternate,a!==null&&Ou(a)===null){o.child=v;break}a=v.sibling,v.sibling=u,u=v,v=a}Jm(o,!0,u,null,b,f);break;case"together":Jm(o,!1,null,null,void 0,f);break;default:o.memoizedState=null}return o.child}function Ea(a,o,u){if(a!==null&&(o.dependencies=a.dependencies),nr|=o.lanes,(u&o.childLanes)===0)if(a!==null){if(Gi(a,o,u,!1),(u&o.childLanes)===0)return null}else return null;if(a!==null&&o.child!==a.child)throw Error(s(153));if(o.child!==null){for(a=o.child,u=ba(a,a.pendingProps),o.child=u,u.return=o;a.sibling!==null;)a=a.sibling,u=u.sibling=ba(a,a.pendingProps),u.return=o;u.sibling=null}return o.child}function Qm(a,o){return(a.lanes&o)!==0?!0:(a=a.dependencies,!!(a!==null&&Eu(a)))}function tI(a,o,u){switch(o.tag){case 3:de(o,o.stateNode.containerInfo),Ya(o,hn,a.memoizedState.cache),Gr();break;case 27:case 5:Ae(o);break;case 4:de(o,o.stateNode.containerInfo);break;case 10:Ya(o,o.type,o.memoizedProps.value);break;case 31:if(o.memoizedState!==null)return o.flags|=128,Sm(o),null;break;case 13:var f=o.memoizedState;if(f!==null)return f.dehydrated!==null?(Ja(o),o.flags|=128,null):(u&o.child.childLanes)!==0?lw(a,o,u):(Ja(o),a=Ea(a,o,u),a!==null?a.sibling:null);Ja(o);break;case 19:var v=(a.flags&128)!==0;if(f=(u&o.childLanes)!==0,f||(Gi(a,o,u,!1),f=(u&o.childLanes)!==0),v){if(f)return uw(a,o,u);o.flags|=128}if(v=o.memoizedState,v!==null&&(v.rendering=null,v.tail=null,v.lastEffect=null),Y(cn,cn.current),f)break;return null;case 22:return o.lanes=0,nw(a,o,u,o.pendingProps);case 24:Ya(o,hn,a.memoizedState.cache)}return Ea(a,o,u)}function dw(a,o,u){if(a!==null)if(a.memoizedProps!==o.pendingProps)pn=!0;else{if(!Qm(a,u)&&(o.flags&128)===0)return pn=!1,tI(a,o,u);pn=(a.flags&131072)!==0}else pn=!1,mt&&(o.flags&1048576)!==0&&Fb(o,El,o.index);switch(o.lanes=0,o.tag){case 16:e:{var f=o.pendingProps;if(a=Qr(o.elementType),o.type=a,typeof a=="function")am(a)?(f=si(a,f),o.tag=1,o=iw(null,o,a,f,u)):(o.tag=0,o=Zm(null,o,a,f,u));else{if(a!=null){var v=a.$$typeof;if(v===M){o.tag=11,o=Q0(null,o,a,f,u);break e}else if(v===R){o.tag=14,o=ew(null,o,a,f,u);break e}}throw o=G(a)||a,Error(s(306,o,""))}}return o;case 0:return Zm(a,o,o.type,o.pendingProps,u);case 1:return f=o.type,v=si(f,o.pendingProps),iw(a,o,f,v,u);case 3:e:{if(de(o,o.stateNode.containerInfo),a===null)throw Error(s(387));f=o.pendingProps;var b=o.memoizedState;v=b.element,xm(a,o),Ol(o,f,null,u);var T=o.memoizedState;if(f=T.cache,Ya(o,hn,f),f!==b.cache&&hm(o,[hn],u,!0),Il(),f=T.element,b.isDehydrated)if(b={element:f,isDehydrated:!1,cache:T.cache},o.updateQueue.baseState=b,o.memoizedState=b,o.flags&256){o=ow(a,o,f,u);break e}else if(f!==v){v=bs(Error(s(424)),o),Cl(v),o=ow(a,o,f,u);break e}else for(a=o.stateNode.containerInfo,a.nodeType===9?a=a.body:a=a.nodeName==="HTML"?a.ownerDocument.body:a,$t=ks(a.firstChild),En=o,mt=!0,Za=null,Ns=!0,u=n0(o,null,f,u),o.child=u;u;)u.flags=u.flags&-3|4096,u=u.sibling;else{if(Gr(),f===v){o=Ea(a,o,u);break e}An(a,o,f,u)}o=o.child}return o;case 26:return qu(a,o),a===null?(u=jj(o.type,null,o.pendingProps,null))?o.memoizedState=u:mt||(u=o.type,a=o.pendingProps,f=ld(ee.current).createElement(u),f[xt]=o,f[Zn]=a,Tn(f,u,a),wn(f),o.stateNode=f):o.memoizedState=jj(o.type,a.memoizedProps,o.pendingProps,a.memoizedState),null;case 27:return Ae(o),a===null&&mt&&(f=o.stateNode=xj(o.type,o.pendingProps,ee.current),En=o,Ns=!0,v=$t,or(o.type)?(_p=v,$t=ks(f.firstChild)):$t=v),An(a,o,o.pendingProps.children,u),qu(a,o),a===null&&(o.flags|=4194304),o.child;case 5:return a===null&&mt&&((v=f=$t)&&(f=RI(f,o.type,o.pendingProps,Ns),f!==null?(o.stateNode=f,En=o,$t=ks(f.firstChild),Ns=!1,v=!0):v=!1),v||Wa(o)),Ae(o),v=o.type,b=o.pendingProps,T=a!==null?a.memoizedProps:null,f=b.children,Cp(v,b)?f=null:T!==null&&Cp(v,T)&&(o.flags|=32),o.memoizedState!==null&&(v=Em(a,o,Z_,null,null,u),ec._currentValue=v),qu(a,o),An(a,o,f,u),o.child;case 6:return a===null&&mt&&((a=u=$t)&&(u=_I(u,o.pendingProps,Ns),u!==null?(o.stateNode=u,En=o,$t=null,a=!0):a=!1),a||Wa(o)),null;case 13:return lw(a,o,u);case 4:return de(o,o.stateNode.containerInfo),f=o.pendingProps,a===null?o.child=ti(o,null,f,u):An(a,o,f,u),o.child;case 11:return Q0(a,o,o.type,o.pendingProps,u);case 7:return An(a,o,o.pendingProps,u),o.child;case 8:return An(a,o,o.pendingProps.children,u),o.child;case 12:return An(a,o,o.pendingProps.children,u),o.child;case 10:return f=o.pendingProps,Ya(o,o.type,f.value),An(a,o,f.children,u),o.child;case 9:return v=o.type._context,f=o.pendingProps.children,Xr(o),v=Cn(v),f=f(v),o.flags|=1,An(a,o,f,u),o.child;case 14:return ew(a,o,o.type,o.pendingProps,u);case 15:return tw(a,o,o.type,o.pendingProps,u);case 19:return uw(a,o,u);case 31:return eI(a,o,u);case 22:return nw(a,o,u,o.pendingProps);case 24:return Xr(o),f=Cn(hn),a===null?(v=gm(),v===null&&(v=_t,b=mm(),v.pooledCache=b,b.refCount++,b!==null&&(v.pooledCacheLanes|=u),v=b),o.memoizedState={parent:f,cache:v},ym(o),Ya(o,hn,v)):((a.lanes&u)!==0&&(xm(a,o),Ol(o,null,null,u),Il()),v=a.memoizedState,b=o.memoizedState,v.parent!==f?(v={parent:f,cache:f},o.memoizedState=v,o.lanes===0&&(o.memoizedState=o.updateQueue.baseState=v),Ya(o,hn,f)):(f=b.cache,Ya(o,hn,f),f!==v.cache&&hm(o,[hn],u,!0))),An(a,o,o.pendingProps.children,u),o.child;case 29:throw o.pendingProps}throw Error(s(156,o.tag))}function Ca(a){a.flags|=4}function ep(a,o,u,f,v){if((o=(a.mode&32)!==0)&&(o=!1),o){if(a.flags|=16777216,(v&335544128)===v)if(a.stateNode.complete)a.flags|=8192;else if(Lw())a.flags|=8192;else throw ei=Mu,vm}else a.flags&=-16777217}function fw(a,o){if(o.type!=="stylesheet"||(o.state.loading&4)!==0)a.flags&=-16777217;else if(a.flags|=16777216,!Cj(o))if(Lw())a.flags|=8192;else throw ei=Mu,vm}function Wu(a,o){o!==null&&(a.flags|=4),a.flags&16384&&(o=a.tag!==22?Ds():536870912,a.lanes|=o,oo|=o)}function Ul(a,o){if(!mt)switch(a.tailMode){case"hidden":o=a.tail;for(var u=null;o!==null;)o.alternate!==null&&(u=o),o=o.sibling;u===null?a.tail=null:u.sibling=null;break;case"collapsed":u=a.tail;for(var f=null;u!==null;)u.alternate!==null&&(f=u),u=u.sibling;f===null?o||a.tail===null?a.tail=null:a.tail.sibling=null:f.sibling=null}}function Ut(a){var o=a.alternate!==null&&a.alternate.child===a.child,u=0,f=0;if(o)for(var v=a.child;v!==null;)u|=v.lanes|v.childLanes,f|=v.subtreeFlags&65011712,f|=v.flags&65011712,v.return=a,v=v.sibling;else for(v=a.child;v!==null;)u|=v.lanes|v.childLanes,f|=v.subtreeFlags,f|=v.flags,v.return=a,v=v.sibling;return a.subtreeFlags|=f,a.childLanes=u,o}function nI(a,o,u){var f=o.pendingProps;switch(lm(o),o.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ut(o),null;case 1:return Ut(o),null;case 3:return u=o.stateNode,f=null,a!==null&&(f=a.memoizedState.cache),o.memoizedState.cache!==f&&(o.flags|=2048),Na(hn),xe(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(a===null||a.child===null)&&(Yi(o)?Ca(o):a===null||a.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,um())),Ut(o),null;case 26:var v=o.type,b=o.memoizedState;return a===null?(Ca(o),b!==null?(Ut(o),fw(o,b)):(Ut(o),ep(o,v,null,f,u))):b?b!==a.memoizedState?(Ca(o),Ut(o),fw(o,b)):(Ut(o),o.flags&=-16777217):(a=a.memoizedProps,a!==f&&Ca(o),Ut(o),ep(o,v,a,f,u)),null;case 27:if(me(o),u=ee.current,v=o.type,a!==null&&o.stateNode!=null)a.memoizedProps!==f&&Ca(o);else{if(!f){if(o.stateNode===null)throw Error(s(166));return Ut(o),null}a=te.current,Yi(o)?qb(o):(a=xj(v,f,u),o.stateNode=a,Ca(o))}return Ut(o),null;case 5:if(me(o),v=o.type,a!==null&&o.stateNode!=null)a.memoizedProps!==f&&Ca(o);else{if(!f){if(o.stateNode===null)throw Error(s(166));return Ut(o),null}if(b=te.current,Yi(o))qb(o);else{var T=ld(ee.current);switch(b){case 1:b=T.createElementNS("http://www.w3.org/2000/svg",v);break;case 2:b=T.createElementNS("http://www.w3.org/1998/Math/MathML",v);break;default:switch(v){case"svg":b=T.createElementNS("http://www.w3.org/2000/svg",v);break;case"math":b=T.createElementNS("http://www.w3.org/1998/Math/MathML",v);break;case"script":b=T.createElement("div"),b.innerHTML="<script><\/script>",b=b.removeChild(b.firstChild);break;case"select":b=typeof f.is=="string"?T.createElement("select",{is:f.is}):T.createElement("select"),f.multiple?b.multiple=!0:f.size&&(b.size=f.size);break;default:b=typeof f.is=="string"?T.createElement(v,{is:f.is}):T.createElement(v)}}b[xt]=o,b[Zn]=f;e:for(T=o.child;T!==null;){if(T.tag===5||T.tag===6)b.appendChild(T.stateNode);else if(T.tag!==4&&T.tag!==27&&T.child!==null){T.child.return=T,T=T.child;continue}if(T===o)break e;for(;T.sibling===null;){if(T.return===null||T.return===o)break e;T=T.return}T.sibling.return=T.return,T=T.sibling}o.stateNode=b;e:switch(Tn(b,v,f),v){case"button":case"input":case"select":case"textarea":f=!!f.autoFocus;break e;case"img":f=!0;break e;default:f=!1}f&&Ca(o)}}return Ut(o),ep(o,o.type,a===null?null:a.memoizedProps,o.pendingProps,u),null;case 6:if(a&&o.stateNode!=null)a.memoizedProps!==f&&Ca(o);else{if(typeof f!="string"&&o.stateNode===null)throw Error(s(166));if(a=ee.current,Yi(o)){if(a=o.stateNode,u=o.memoizedProps,f=null,v=En,v!==null)switch(v.tag){case 27:case 5:f=v.memoizedProps}a[xt]=o,a=!!(a.nodeValue===u||f!==null&&f.suppressHydrationWarning===!0||lj(a.nodeValue,u)),a||Wa(o,!0)}else a=ld(a).createTextNode(f),a[xt]=o,o.stateNode=a}return Ut(o),null;case 31:if(u=o.memoizedState,a===null||a.memoizedState!==null){if(f=Yi(o),u!==null){if(a===null){if(!f)throw Error(s(318));if(a=o.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(s(557));a[xt]=o}else Gr(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Ut(o),a=!1}else u=um(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=u),a=!0;if(!a)return o.flags&256?(os(o),o):(os(o),null);if((o.flags&128)!==0)throw Error(s(558))}return Ut(o),null;case 13:if(f=o.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(v=Yi(o),f!==null&&f.dehydrated!==null){if(a===null){if(!v)throw Error(s(318));if(v=o.memoizedState,v=v!==null?v.dehydrated:null,!v)throw Error(s(317));v[xt]=o}else Gr(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Ut(o),v=!1}else v=um(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=v),v=!0;if(!v)return o.flags&256?(os(o),o):(os(o),null)}return os(o),(o.flags&128)!==0?(o.lanes=u,o):(u=f!==null,a=a!==null&&a.memoizedState!==null,u&&(f=o.child,v=null,f.alternate!==null&&f.alternate.memoizedState!==null&&f.alternate.memoizedState.cachePool!==null&&(v=f.alternate.memoizedState.cachePool.pool),b=null,f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(b=f.memoizedState.cachePool.pool),b!==v&&(f.flags|=2048)),u!==a&&u&&(o.child.flags|=8192),Wu(o,o.updateQueue),Ut(o),null);case 4:return xe(),a===null&&jp(o.stateNode.containerInfo),Ut(o),null;case 10:return Na(o.type),Ut(o),null;case 19:if(B(cn),f=o.memoizedState,f===null)return Ut(o),null;if(v=(o.flags&128)!==0,b=f.rendering,b===null)if(v)Ul(f,!1);else{if(an!==0||a!==null&&(a.flags&128)!==0)for(a=o.child;a!==null;){if(b=Ou(a),b!==null){for(o.flags|=128,Ul(f,!1),a=b.updateQueue,o.updateQueue=a,Wu(o,a),o.subtreeFlags=0,a=u,u=o.child;u!==null;)Ub(u,a),u=u.sibling;return Y(cn,cn.current&1|2),mt&&wa(o,f.treeForkCount),o.child}a=a.sibling}f.tail!==null&&we()>Ju&&(o.flags|=128,v=!0,Ul(f,!1),o.lanes=4194304)}else{if(!v)if(a=Ou(b),a!==null){if(o.flags|=128,v=!0,a=a.updateQueue,o.updateQueue=a,Wu(o,a),Ul(f,!0),f.tail===null&&f.tailMode==="hidden"&&!b.alternate&&!mt)return Ut(o),null}else 2*we()-f.renderingStartTime>Ju&&u!==536870912&&(o.flags|=128,v=!0,Ul(f,!1),o.lanes=4194304);f.isBackwards?(b.sibling=o.child,o.child=b):(a=f.last,a!==null?a.sibling=b:o.child=b,f.last=b)}return f.tail!==null?(a=f.tail,f.rendering=a,f.tail=a.sibling,f.renderingStartTime=we(),a.sibling=null,u=cn.current,Y(cn,v?u&1|2:u&1),mt&&wa(o,f.treeForkCount),a):(Ut(o),null);case 22:case 23:return os(o),Nm(),f=o.memoizedState!==null,a!==null?a.memoizedState!==null!==f&&(o.flags|=8192):f&&(o.flags|=8192),f?(u&536870912)!==0&&(o.flags&128)===0&&(Ut(o),o.subtreeFlags&6&&(o.flags|=8192)):Ut(o),u=o.updateQueue,u!==null&&Wu(o,u.retryQueue),u=null,a!==null&&a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),f=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(f=o.memoizedState.cachePool.pool),f!==u&&(o.flags|=2048),a!==null&&B(Jr),null;case 24:return u=null,a!==null&&(u=a.memoizedState.cache),o.memoizedState.cache!==u&&(o.flags|=2048),Na(hn),Ut(o),null;case 25:return null;case 30:return null}throw Error(s(156,o.tag))}function sI(a,o){switch(lm(o),o.tag){case 1:return a=o.flags,a&65536?(o.flags=a&-65537|128,o):null;case 3:return Na(hn),xe(),a=o.flags,(a&65536)!==0&&(a&128)===0?(o.flags=a&-65537|128,o):null;case 26:case 27:case 5:return me(o),null;case 31:if(o.memoizedState!==null){if(os(o),o.alternate===null)throw Error(s(340));Gr()}return a=o.flags,a&65536?(o.flags=a&-65537|128,o):null;case 13:if(os(o),a=o.memoizedState,a!==null&&a.dehydrated!==null){if(o.alternate===null)throw Error(s(340));Gr()}return a=o.flags,a&65536?(o.flags=a&-65537|128,o):null;case 19:return B(cn),null;case 4:return xe(),null;case 10:return Na(o.type),null;case 22:case 23:return os(o),Nm(),a!==null&&B(Jr),a=o.flags,a&65536?(o.flags=a&-65537|128,o):null;case 24:return Na(hn),null;case 25:return null;default:return null}}function hw(a,o){switch(lm(o),o.tag){case 3:Na(hn),xe();break;case 26:case 27:case 5:me(o);break;case 4:xe();break;case 31:o.memoizedState!==null&&os(o);break;case 13:os(o);break;case 19:B(cn);break;case 10:Na(o.type);break;case 22:case 23:os(o),Nm(),a!==null&&B(Jr);break;case 24:Na(hn)}}function Bl(a,o){try{var u=o.updateQueue,f=u!==null?u.lastEffect:null;if(f!==null){var v=f.next;u=v;do{if((u.tag&a)===a){f=void 0;var b=u.create,T=u.inst;f=b(),T.destroy=f}u=u.next}while(u!==v)}}catch(P){Et(o,o.return,P)}}function er(a,o,u){try{var f=o.updateQueue,v=f!==null?f.lastEffect:null;if(v!==null){var b=v.next;f=b;do{if((f.tag&a)===a){var T=f.inst,P=T.destroy;if(P!==void 0){T.destroy=void 0,v=o;var Z=u,se=P;try{se()}catch(fe){Et(v,Z,fe)}}}f=f.next}while(f!==b)}}catch(fe){Et(o,o.return,fe)}}function mw(a){var o=a.updateQueue;if(o!==null){var u=a.stateNode;try{a0(o,u)}catch(f){Et(a,a.return,f)}}}function pw(a,o,u){u.props=si(a.type,a.memoizedProps),u.state=a.memoizedState;try{u.componentWillUnmount()}catch(f){Et(a,o,f)}}function Vl(a,o){try{var u=a.ref;if(u!==null){switch(a.tag){case 26:case 27:case 5:var f=a.stateNode;break;case 30:f=a.stateNode;break;default:f=a.stateNode}typeof u=="function"?a.refCleanup=u(f):u.current=f}}catch(v){Et(a,o,v)}}function Qs(a,o){var u=a.ref,f=a.refCleanup;if(u!==null)if(typeof f=="function")try{f()}catch(v){Et(a,o,v)}finally{a.refCleanup=null,a=a.alternate,a!=null&&(a.refCleanup=null)}else if(typeof u=="function")try{u(null)}catch(v){Et(a,o,v)}else u.current=null}function gw(a){var o=a.type,u=a.memoizedProps,f=a.stateNode;try{e:switch(o){case"button":case"input":case"select":case"textarea":u.autoFocus&&f.focus();break e;case"img":u.src?f.src=u.src:u.srcSet&&(f.srcset=u.srcSet)}}catch(v){Et(a,a.return,v)}}function tp(a,o,u){try{var f=a.stateNode;kI(f,a.type,u,o),f[Zn]=o}catch(v){Et(a,a.return,v)}}function vw(a){return a.tag===5||a.tag===3||a.tag===26||a.tag===27&&or(a.type)||a.tag===4}function np(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||vw(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.tag===27&&or(a.type)||a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function sp(a,o,u){var f=a.tag;if(f===5||f===6)a=a.stateNode,o?(u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u).insertBefore(a,o):(o=u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u,o.appendChild(a),u=u._reactRootContainer,u!=null||o.onclick!==null||(o.onclick=ya));else if(f!==4&&(f===27&&or(a.type)&&(u=a.stateNode,o=null),a=a.child,a!==null))for(sp(a,o,u),a=a.sibling;a!==null;)sp(a,o,u),a=a.sibling}function Yu(a,o,u){var f=a.tag;if(f===5||f===6)a=a.stateNode,o?u.insertBefore(a,o):u.appendChild(a);else if(f!==4&&(f===27&&or(a.type)&&(u=a.stateNode),a=a.child,a!==null))for(Yu(a,o,u),a=a.sibling;a!==null;)Yu(a,o,u),a=a.sibling}function yw(a){var o=a.stateNode,u=a.memoizedProps;try{for(var f=a.type,v=o.attributes;v.length;)o.removeAttributeNode(v[0]);Tn(o,f,u),o[xt]=a,o[Zn]=u}catch(b){Et(a,a.return,b)}}var Aa=!1,gn=!1,ap=!1,xw=typeof WeakSet=="function"?WeakSet:Set,jn=null;function aI(a,o){if(a=a.containerInfo,kp=pd,a=Rb(a),Xh(a)){if("selectionStart"in a)var u={start:a.selectionStart,end:a.selectionEnd};else e:{u=(u=a.ownerDocument)&&u.defaultView||window;var f=u.getSelection&&u.getSelection();if(f&&f.rangeCount!==0){u=f.anchorNode;var v=f.anchorOffset,b=f.focusNode;f=f.focusOffset;try{u.nodeType,b.nodeType}catch{u=null;break e}var T=0,P=-1,Z=-1,se=0,fe=0,ge=a,re=null;t:for(;;){for(var ce;ge!==u||v!==0&&ge.nodeType!==3||(P=T+v),ge!==b||f!==0&&ge.nodeType!==3||(Z=T+f),ge.nodeType===3&&(T+=ge.nodeValue.length),(ce=ge.firstChild)!==null;)re=ge,ge=ce;for(;;){if(ge===a)break t;if(re===u&&++se===v&&(P=T),re===b&&++fe===f&&(Z=T),(ce=ge.nextSibling)!==null)break;ge=re,re=ge.parentNode}ge=ce}u=P===-1||Z===-1?null:{start:P,end:Z}}else u=null}u=u||{start:0,end:0}}else u=null;for(Ep={focusedElem:a,selectionRange:u},pd=!1,jn=o;jn!==null;)if(o=jn,a=o.child,(o.subtreeFlags&1028)!==0&&a!==null)a.return=o,jn=a;else for(;jn!==null;){switch(o=jn,b=o.alternate,a=o.flags,o.tag){case 0:if((a&4)!==0&&(a=o.updateQueue,a=a!==null?a.events:null,a!==null))for(u=0;u<a.length;u++)v=a[u],v.ref.impl=v.nextImpl;break;case 11:case 15:break;case 1:if((a&1024)!==0&&b!==null){a=void 0,u=o,v=b.memoizedProps,b=b.memoizedState,f=u.stateNode;try{var ze=si(u.type,v);a=f.getSnapshotBeforeUpdate(ze,b),f.__reactInternalSnapshotBeforeUpdate=a}catch(qe){Et(u,u.return,qe)}}break;case 3:if((a&1024)!==0){if(a=o.stateNode.containerInfo,u=a.nodeType,u===9)Tp(a);else if(u===1)switch(a.nodeName){case"HEAD":case"HTML":case"BODY":Tp(a);break;default:a.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((a&1024)!==0)throw Error(s(163))}if(a=o.sibling,a!==null){a.return=o.return,jn=a;break}jn=o.return}}function bw(a,o,u){var f=u.flags;switch(u.tag){case 0:case 11:case 15:Ma(a,u),f&4&&Bl(5,u);break;case 1:if(Ma(a,u),f&4)if(a=u.stateNode,o===null)try{a.componentDidMount()}catch(T){Et(u,u.return,T)}else{var v=si(u.type,o.memoizedProps);o=o.memoizedState;try{a.componentDidUpdate(v,o,a.__reactInternalSnapshotBeforeUpdate)}catch(T){Et(u,u.return,T)}}f&64&&mw(u),f&512&&Vl(u,u.return);break;case 3:if(Ma(a,u),f&64&&(a=u.updateQueue,a!==null)){if(o=null,u.child!==null)switch(u.child.tag){case 27:case 5:o=u.child.stateNode;break;case 1:o=u.child.stateNode}try{a0(a,o)}catch(T){Et(u,u.return,T)}}break;case 27:o===null&&f&4&&yw(u);case 26:case 5:Ma(a,u),o===null&&f&4&&gw(u),f&512&&Vl(u,u.return);break;case 12:Ma(a,u);break;case 31:Ma(a,u),f&4&&Nw(a,u);break;case 13:Ma(a,u),f&4&&Sw(a,u),f&64&&(a=u.memoizedState,a!==null&&(a=a.dehydrated,a!==null&&(u=hI.bind(null,u),II(a,u))));break;case 22:if(f=u.memoizedState!==null||Aa,!f){o=o!==null&&o.memoizedState!==null||gn,v=Aa;var b=gn;Aa=f,(gn=o)&&!b?Ra(a,u,(u.subtreeFlags&8772)!==0):Ma(a,u),Aa=v,gn=b}break;case 30:break;default:Ma(a,u)}}function ww(a){var o=a.alternate;o!==null&&(a.alternate=null,ww(o)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(o=a.stateNode,o!==null&&Oh(o)),a.stateNode=null,a.return=null,a.dependencies=null,a.memoizedProps=null,a.memoizedState=null,a.pendingProps=null,a.stateNode=null,a.updateQueue=null}var Yt=null,Yn=!1;function Ta(a,o,u){for(u=u.child;u!==null;)jw(a,o,u),u=u.sibling}function jw(a,o,u){if(Te&&typeof Te.onCommitFiberUnmount=="function")try{Te.onCommitFiberUnmount(Oe,u)}catch{}switch(u.tag){case 26:gn||Qs(u,o),Ta(a,o,u),u.memoizedState?u.memoizedState.count--:u.stateNode&&(u=u.stateNode,u.parentNode.removeChild(u));break;case 27:gn||Qs(u,o);var f=Yt,v=Yn;or(u.type)&&(Yt=u.stateNode,Yn=!1),Ta(a,o,u),Xl(u.stateNode),Yt=f,Yn=v;break;case 5:gn||Qs(u,o);case 6:if(f=Yt,v=Yn,Yt=null,Ta(a,o,u),Yt=f,Yn=v,Yt!==null)if(Yn)try{(Yt.nodeType===9?Yt.body:Yt.nodeName==="HTML"?Yt.ownerDocument.body:Yt).removeChild(u.stateNode)}catch(b){Et(u,o,b)}else try{Yt.removeChild(u.stateNode)}catch(b){Et(u,o,b)}break;case 18:Yt!==null&&(Yn?(a=Yt,mj(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,u.stateNode),go(a)):mj(Yt,u.stateNode));break;case 4:f=Yt,v=Yn,Yt=u.stateNode.containerInfo,Yn=!0,Ta(a,o,u),Yt=f,Yn=v;break;case 0:case 11:case 14:case 15:er(2,u,o),gn||er(4,u,o),Ta(a,o,u);break;case 1:gn||(Qs(u,o),f=u.stateNode,typeof f.componentWillUnmount=="function"&&pw(u,o,f)),Ta(a,o,u);break;case 21:Ta(a,o,u);break;case 22:gn=(f=gn)||u.memoizedState!==null,Ta(a,o,u),gn=f;break;default:Ta(a,o,u)}}function Nw(a,o){if(o.memoizedState===null&&(a=o.alternate,a!==null&&(a=a.memoizedState,a!==null))){a=a.dehydrated;try{go(a)}catch(u){Et(o,o.return,u)}}}function Sw(a,o){if(o.memoizedState===null&&(a=o.alternate,a!==null&&(a=a.memoizedState,a!==null&&(a=a.dehydrated,a!==null))))try{go(a)}catch(u){Et(o,o.return,u)}}function rI(a){switch(a.tag){case 31:case 13:case 19:var o=a.stateNode;return o===null&&(o=a.stateNode=new xw),o;case 22:return a=a.stateNode,o=a._retryCache,o===null&&(o=a._retryCache=new xw),o;default:throw Error(s(435,a.tag))}}function Gu(a,o){var u=rI(a);o.forEach(function(f){if(!u.has(f)){u.add(f);var v=mI.bind(null,a,f);f.then(v,v)}})}function Gn(a,o){var u=o.deletions;if(u!==null)for(var f=0;f<u.length;f++){var v=u[f],b=a,T=o,P=T;e:for(;P!==null;){switch(P.tag){case 27:if(or(P.type)){Yt=P.stateNode,Yn=!1;break e}break;case 5:Yt=P.stateNode,Yn=!1;break e;case 3:case 4:Yt=P.stateNode.containerInfo,Yn=!0;break e}P=P.return}if(Yt===null)throw Error(s(160));jw(b,T,v),Yt=null,Yn=!1,b=v.alternate,b!==null&&(b.return=null),v.return=null}if(o.subtreeFlags&13886)for(o=o.child;o!==null;)kw(o,a),o=o.sibling}var zs=null;function kw(a,o){var u=a.alternate,f=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:Gn(o,a),Kn(a),f&4&&(er(3,a,a.return),Bl(3,a),er(5,a,a.return));break;case 1:Gn(o,a),Kn(a),f&512&&(gn||u===null||Qs(u,u.return)),f&64&&Aa&&(a=a.updateQueue,a!==null&&(f=a.callbacks,f!==null&&(u=a.shared.hiddenCallbacks,a.shared.hiddenCallbacks=u===null?f:u.concat(f))));break;case 26:var v=zs;if(Gn(o,a),Kn(a),f&512&&(gn||u===null||Qs(u,u.return)),f&4){var b=u!==null?u.memoizedState:null;if(f=a.memoizedState,u===null)if(f===null)if(a.stateNode===null){e:{f=a.type,u=a.memoizedProps,v=v.ownerDocument||v;t:switch(f){case"title":b=v.getElementsByTagName("title")[0],(!b||b[pl]||b[xt]||b.namespaceURI==="http://www.w3.org/2000/svg"||b.hasAttribute("itemprop"))&&(b=v.createElement(f),v.head.insertBefore(b,v.querySelector("head > title"))),Tn(b,f,u),b[xt]=a,wn(b),f=b;break e;case"link":var T=kj("link","href",v).get(f+(u.href||""));if(T){for(var P=0;P<T.length;P++)if(b=T[P],b.getAttribute("href")===(u.href==null||u.href===""?null:u.href)&&b.getAttribute("rel")===(u.rel==null?null:u.rel)&&b.getAttribute("title")===(u.title==null?null:u.title)&&b.getAttribute("crossorigin")===(u.crossOrigin==null?null:u.crossOrigin)){T.splice(P,1);break t}}b=v.createElement(f),Tn(b,f,u),v.head.appendChild(b);break;case"meta":if(T=kj("meta","content",v).get(f+(u.content||""))){for(P=0;P<T.length;P++)if(b=T[P],b.getAttribute("content")===(u.content==null?null:""+u.content)&&b.getAttribute("name")===(u.name==null?null:u.name)&&b.getAttribute("property")===(u.property==null?null:u.property)&&b.getAttribute("http-equiv")===(u.httpEquiv==null?null:u.httpEquiv)&&b.getAttribute("charset")===(u.charSet==null?null:u.charSet)){T.splice(P,1);break t}}b=v.createElement(f),Tn(b,f,u),v.head.appendChild(b);break;default:throw Error(s(468,f))}b[xt]=a,wn(b),f=b}a.stateNode=f}else Ej(v,a.type,a.stateNode);else a.stateNode=Sj(v,f,a.memoizedProps);else b!==f?(b===null?u.stateNode!==null&&(u=u.stateNode,u.parentNode.removeChild(u)):b.count--,f===null?Ej(v,a.type,a.stateNode):Sj(v,f,a.memoizedProps)):f===null&&a.stateNode!==null&&tp(a,a.memoizedProps,u.memoizedProps)}break;case 27:Gn(o,a),Kn(a),f&512&&(gn||u===null||Qs(u,u.return)),u!==null&&f&4&&tp(a,a.memoizedProps,u.memoizedProps);break;case 5:if(Gn(o,a),Kn(a),f&512&&(gn||u===null||Qs(u,u.return)),a.flags&32){v=a.stateNode;try{Li(v,"")}catch(ze){Et(a,a.return,ze)}}f&4&&a.stateNode!=null&&(v=a.memoizedProps,tp(a,v,u!==null?u.memoizedProps:v)),f&1024&&(ap=!0);break;case 6:if(Gn(o,a),Kn(a),f&4){if(a.stateNode===null)throw Error(s(162));f=a.memoizedProps,u=a.stateNode;try{u.nodeValue=f}catch(ze){Et(a,a.return,ze)}}break;case 3:if(dd=null,v=zs,zs=cd(o.containerInfo),Gn(o,a),zs=v,Kn(a),f&4&&u!==null&&u.memoizedState.isDehydrated)try{go(o.containerInfo)}catch(ze){Et(a,a.return,ze)}ap&&(ap=!1,Ew(a));break;case 4:f=zs,zs=cd(a.stateNode.containerInfo),Gn(o,a),Kn(a),zs=f;break;case 12:Gn(o,a),Kn(a);break;case 31:Gn(o,a),Kn(a),f&4&&(f=a.updateQueue,f!==null&&(a.updateQueue=null,Gu(a,f)));break;case 13:Gn(o,a),Kn(a),a.child.flags&8192&&a.memoizedState!==null!=(u!==null&&u.memoizedState!==null)&&(Xu=we()),f&4&&(f=a.updateQueue,f!==null&&(a.updateQueue=null,Gu(a,f)));break;case 22:v=a.memoizedState!==null;var Z=u!==null&&u.memoizedState!==null,se=Aa,fe=gn;if(Aa=se||v,gn=fe||Z,Gn(o,a),gn=fe,Aa=se,Kn(a),f&8192)e:for(o=a.stateNode,o._visibility=v?o._visibility&-2:o._visibility|1,v&&(u===null||Z||Aa||gn||ai(a)),u=null,o=a;;){if(o.tag===5||o.tag===26){if(u===null){Z=u=o;try{if(b=Z.stateNode,v)T=b.style,typeof T.setProperty=="function"?T.setProperty("display","none","important"):T.display="none";else{P=Z.stateNode;var ge=Z.memoizedProps.style,re=ge!=null&&ge.hasOwnProperty("display")?ge.display:null;P.style.display=re==null||typeof re=="boolean"?"":(""+re).trim()}}catch(ze){Et(Z,Z.return,ze)}}}else if(o.tag===6){if(u===null){Z=o;try{Z.stateNode.nodeValue=v?"":Z.memoizedProps}catch(ze){Et(Z,Z.return,ze)}}}else if(o.tag===18){if(u===null){Z=o;try{var ce=Z.stateNode;v?pj(ce,!0):pj(Z.stateNode,!1)}catch(ze){Et(Z,Z.return,ze)}}}else if((o.tag!==22&&o.tag!==23||o.memoizedState===null||o===a)&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===a)break e;for(;o.sibling===null;){if(o.return===null||o.return===a)break e;u===o&&(u=null),o=o.return}u===o&&(u=null),o.sibling.return=o.return,o=o.sibling}f&4&&(f=a.updateQueue,f!==null&&(u=f.retryQueue,u!==null&&(f.retryQueue=null,Gu(a,u))));break;case 19:Gn(o,a),Kn(a),f&4&&(f=a.updateQueue,f!==null&&(a.updateQueue=null,Gu(a,f)));break;case 30:break;case 21:break;default:Gn(o,a),Kn(a)}}function Kn(a){var o=a.flags;if(o&2){try{for(var u,f=a.return;f!==null;){if(vw(f)){u=f;break}f=f.return}if(u==null)throw Error(s(160));switch(u.tag){case 27:var v=u.stateNode,b=np(a);Yu(a,b,v);break;case 5:var T=u.stateNode;u.flags&32&&(Li(T,""),u.flags&=-33);var P=np(a);Yu(a,P,T);break;case 3:case 4:var Z=u.stateNode.containerInfo,se=np(a);sp(a,se,Z);break;default:throw Error(s(161))}}catch(fe){Et(a,a.return,fe)}a.flags&=-3}o&4096&&(a.flags&=-4097)}function Ew(a){if(a.subtreeFlags&1024)for(a=a.child;a!==null;){var o=a;Ew(o),o.tag===5&&o.flags&1024&&o.stateNode.reset(),a=a.sibling}}function Ma(a,o){if(o.subtreeFlags&8772)for(o=o.child;o!==null;)bw(a,o.alternate,o),o=o.sibling}function ai(a){for(a=a.child;a!==null;){var o=a;switch(o.tag){case 0:case 11:case 14:case 15:er(4,o,o.return),ai(o);break;case 1:Qs(o,o.return);var u=o.stateNode;typeof u.componentWillUnmount=="function"&&pw(o,o.return,u),ai(o);break;case 27:Xl(o.stateNode);case 26:case 5:Qs(o,o.return),ai(o);break;case 22:o.memoizedState===null&&ai(o);break;case 30:ai(o);break;default:ai(o)}a=a.sibling}}function Ra(a,o,u){for(u=u&&(o.subtreeFlags&8772)!==0,o=o.child;o!==null;){var f=o.alternate,v=a,b=o,T=b.flags;switch(b.tag){case 0:case 11:case 15:Ra(v,b,u),Bl(4,b);break;case 1:if(Ra(v,b,u),f=b,v=f.stateNode,typeof v.componentDidMount=="function")try{v.componentDidMount()}catch(se){Et(f,f.return,se)}if(f=b,v=f.updateQueue,v!==null){var P=f.stateNode;try{var Z=v.shared.hiddenCallbacks;if(Z!==null)for(v.shared.hiddenCallbacks=null,v=0;v<Z.length;v++)s0(Z[v],P)}catch(se){Et(f,f.return,se)}}u&&T&64&&mw(b),Vl(b,b.return);break;case 27:yw(b);case 26:case 5:Ra(v,b,u),u&&f===null&&T&4&&gw(b),Vl(b,b.return);break;case 12:Ra(v,b,u);break;case 31:Ra(v,b,u),u&&T&4&&Nw(v,b);break;case 13:Ra(v,b,u),u&&T&4&&Sw(v,b);break;case 22:b.memoizedState===null&&Ra(v,b,u),Vl(b,b.return);break;case 30:break;default:Ra(v,b,u)}o=o.sibling}}function rp(a,o){var u=null;a!==null&&a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),a=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(a=o.memoizedState.cachePool.pool),a!==u&&(a!=null&&a.refCount++,u!=null&&Al(u))}function ip(a,o){a=null,o.alternate!==null&&(a=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==a&&(o.refCount++,a!=null&&Al(a))}function Ls(a,o,u,f){if(o.subtreeFlags&10256)for(o=o.child;o!==null;)Cw(a,o,u,f),o=o.sibling}function Cw(a,o,u,f){var v=o.flags;switch(o.tag){case 0:case 11:case 15:Ls(a,o,u,f),v&2048&&Bl(9,o);break;case 1:Ls(a,o,u,f);break;case 3:Ls(a,o,u,f),v&2048&&(a=null,o.alternate!==null&&(a=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==a&&(o.refCount++,a!=null&&Al(a)));break;case 12:if(v&2048){Ls(a,o,u,f),a=o.stateNode;try{var b=o.memoizedProps,T=b.id,P=b.onPostCommit;typeof P=="function"&&P(T,o.alternate===null?"mount":"update",a.passiveEffectDuration,-0)}catch(Z){Et(o,o.return,Z)}}else Ls(a,o,u,f);break;case 31:Ls(a,o,u,f);break;case 13:Ls(a,o,u,f);break;case 23:break;case 22:b=o.stateNode,T=o.alternate,o.memoizedState!==null?b._visibility&2?Ls(a,o,u,f):Fl(a,o):b._visibility&2?Ls(a,o,u,f):(b._visibility|=2,ao(a,o,u,f,(o.subtreeFlags&10256)!==0||!1)),v&2048&&rp(T,o);break;case 24:Ls(a,o,u,f),v&2048&&ip(o.alternate,o);break;default:Ls(a,o,u,f)}}function ao(a,o,u,f,v){for(v=v&&((o.subtreeFlags&10256)!==0||!1),o=o.child;o!==null;){var b=a,T=o,P=u,Z=f,se=T.flags;switch(T.tag){case 0:case 11:case 15:ao(b,T,P,Z,v),Bl(8,T);break;case 23:break;case 22:var fe=T.stateNode;T.memoizedState!==null?fe._visibility&2?ao(b,T,P,Z,v):Fl(b,T):(fe._visibility|=2,ao(b,T,P,Z,v)),v&&se&2048&&rp(T.alternate,T);break;case 24:ao(b,T,P,Z,v),v&&se&2048&&ip(T.alternate,T);break;default:ao(b,T,P,Z,v)}o=o.sibling}}function Fl(a,o){if(o.subtreeFlags&10256)for(o=o.child;o!==null;){var u=a,f=o,v=f.flags;switch(f.tag){case 22:Fl(u,f),v&2048&&rp(f.alternate,f);break;case 24:Fl(u,f),v&2048&&ip(f.alternate,f);break;default:Fl(u,f)}o=o.sibling}}var Hl=8192;function ro(a,o,u){if(a.subtreeFlags&Hl)for(a=a.child;a!==null;)Aw(a,o,u),a=a.sibling}function Aw(a,o,u){switch(a.tag){case 26:ro(a,o,u),a.flags&Hl&&a.memoizedState!==null&&qI(u,zs,a.memoizedState,a.memoizedProps);break;case 5:ro(a,o,u);break;case 3:case 4:var f=zs;zs=cd(a.stateNode.containerInfo),ro(a,o,u),zs=f;break;case 22:a.memoizedState===null&&(f=a.alternate,f!==null&&f.memoizedState!==null?(f=Hl,Hl=16777216,ro(a,o,u),Hl=f):ro(a,o,u));break;default:ro(a,o,u)}}function Tw(a){var o=a.alternate;if(o!==null&&(a=o.child,a!==null)){o.child=null;do o=a.sibling,a.sibling=null,a=o;while(a!==null)}}function ql(a){var o=a.deletions;if((a.flags&16)!==0){if(o!==null)for(var u=0;u<o.length;u++){var f=o[u];jn=f,Rw(f,a)}Tw(a)}if(a.subtreeFlags&10256)for(a=a.child;a!==null;)Mw(a),a=a.sibling}function Mw(a){switch(a.tag){case 0:case 11:case 15:ql(a),a.flags&2048&&er(9,a,a.return);break;case 3:ql(a);break;case 12:ql(a);break;case 22:var o=a.stateNode;a.memoizedState!==null&&o._visibility&2&&(a.return===null||a.return.tag!==13)?(o._visibility&=-3,Ku(a)):ql(a);break;default:ql(a)}}function Ku(a){var o=a.deletions;if((a.flags&16)!==0){if(o!==null)for(var u=0;u<o.length;u++){var f=o[u];jn=f,Rw(f,a)}Tw(a)}for(a=a.child;a!==null;){switch(o=a,o.tag){case 0:case 11:case 15:er(8,o,o.return),Ku(o);break;case 22:u=o.stateNode,u._visibility&2&&(u._visibility&=-3,Ku(o));break;default:Ku(o)}a=a.sibling}}function Rw(a,o){for(;jn!==null;){var u=jn;switch(u.tag){case 0:case 11:case 15:er(8,u,o);break;case 23:case 22:if(u.memoizedState!==null&&u.memoizedState.cachePool!==null){var f=u.memoizedState.cachePool.pool;f!=null&&f.refCount++}break;case 24:Al(u.memoizedState.cache)}if(f=u.child,f!==null)f.return=u,jn=f;else e:for(u=a;jn!==null;){f=jn;var v=f.sibling,b=f.return;if(ww(f),f===u){jn=null;break e}if(v!==null){v.return=b,jn=v;break e}jn=b}}}var iI={getCacheForType:function(a){var o=Cn(hn),u=o.data.get(a);return u===void 0&&(u=a(),o.data.set(a,u)),u},cacheSignal:function(){return Cn(hn).controller.signal}},oI=typeof WeakMap=="function"?WeakMap:Map,Nt=0,_t=null,lt=null,dt=0,kt=0,ls=null,tr=!1,io=!1,op=!1,_a=0,an=0,nr=0,ri=0,lp=0,cs=0,oo=0,Zl=null,Xn=null,cp=!1,Xu=0,_w=0,Ju=1/0,Qu=null,sr=null,xn=0,ar=null,lo=null,Ia=0,up=0,dp=null,Iw=null,Wl=0,fp=null;function us(){return(Nt&2)!==0&&dt!==0?dt&-dt:L.T!==null?yp():Sn()}function Ow(){if(cs===0)if((dt&536870912)===0||mt){var a=on;on<<=1,(on&3932160)===0&&(on=262144),cs=a}else cs=536870912;return a=is.current,a!==null&&(a.flags|=32),cs}function Jn(a,o,u){(a===_t&&(kt===2||kt===9)||a.cancelPendingCommit!==null)&&(co(a,0),rr(a,dt,cs,!1)),ye(a,u),((Nt&2)===0||a!==_t)&&(a===_t&&((Nt&2)===0&&(ri|=u),an===4&&rr(a,dt,cs,!1)),ea(a))}function Dw(a,o,u){if((Nt&6)!==0)throw Error(s(327));var f=!u&&(o&127)===0&&(o&a.expiredLanes)===0||Wt(a,o),v=f?uI(a,o):mp(a,o,!0),b=f;do{if(v===0){io&&!f&&rr(a,o,0,!1);break}else{if(u=a.current.alternate,b&&!lI(u)){v=mp(a,o,!1),b=!1;continue}if(v===2){if(b=o,a.errorRecoveryDisabledLanes&b)var T=0;else T=a.pendingLanes&-536870913,T=T!==0?T:T&536870912?536870912:0;if(T!==0){o=T;e:{var P=a;v=Zl;var Z=P.current.memoizedState.isDehydrated;if(Z&&(co(P,T).flags|=256),T=mp(P,T,!1),T!==2){if(op&&!Z){P.errorRecoveryDisabledLanes|=b,ri|=b,v=4;break e}b=Xn,Xn=v,b!==null&&(Xn===null?Xn=b:Xn.push.apply(Xn,b))}v=T}if(b=!1,v!==2)continue}}if(v===1){co(a,0),rr(a,o,0,!0);break}e:{switch(f=a,b=v,b){case 0:case 1:throw Error(s(345));case 4:if((o&4194048)!==o)break;case 6:rr(f,o,cs,!tr);break e;case 2:Xn=null;break;case 3:case 5:break;default:throw Error(s(329))}if((o&62914560)===o&&(v=Xu+300-we(),10<v)){if(rr(f,o,cs,!tr),jt(f,0,!0)!==0)break e;Ia=o,f.timeoutHandle=fj(Pw.bind(null,f,u,Xn,Qu,cp,o,cs,ri,oo,tr,b,"Throttled",-0,0),v);break e}Pw(f,u,Xn,Qu,cp,o,cs,ri,oo,tr,b,null,-0,0)}}break}while(!0);ea(a)}function Pw(a,o,u,f,v,b,T,P,Z,se,fe,ge,re,ce){if(a.timeoutHandle=-1,ge=o.subtreeFlags,ge&8192||(ge&16785408)===16785408){ge={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:ya},Aw(o,b,ge);var ze=(b&62914560)===b?Xu-we():(b&4194048)===b?_w-we():0;if(ze=ZI(ge,ze),ze!==null){Ia=b,a.cancelPendingCommit=ze(Hw.bind(null,a,o,b,u,f,v,T,P,Z,fe,ge,null,re,ce)),rr(a,b,T,!se);return}}Hw(a,o,b,u,f,v,T,P,Z)}function lI(a){for(var o=a;;){var u=o.tag;if((u===0||u===11||u===15)&&o.flags&16384&&(u=o.updateQueue,u!==null&&(u=u.stores,u!==null)))for(var f=0;f<u.length;f++){var v=u[f],b=v.getSnapshot;v=v.value;try{if(!as(b(),v))return!1}catch{return!1}}if(u=o.child,o.subtreeFlags&16384&&u!==null)u.return=o,o=u;else{if(o===a)break;for(;o.sibling===null;){if(o.return===null||o.return===a)return!0;o=o.return}o.sibling.return=o.return,o=o.sibling}}return!0}function rr(a,o,u,f){o&=~lp,o&=~ri,a.suspendedLanes|=o,a.pingedLanes&=~o,f&&(a.warmLanes|=o),f=a.expirationTimes;for(var v=o;0<v;){var b=31-at(v),T=1<<b;f[b]=-1,v&=~T}u!==0&&We(a,u,o)}function ed(){return(Nt&6)===0?(Yl(0),!1):!0}function hp(){if(lt!==null){if(kt===0)var a=lt.return;else a=lt,ja=Kr=null,Tm(a),Qi=null,Ml=0,a=lt;for(;a!==null;)hw(a.alternate,a),a=a.return;lt=null}}function co(a,o){var u=a.timeoutHandle;u!==-1&&(a.timeoutHandle=-1,AI(u)),u=a.cancelPendingCommit,u!==null&&(a.cancelPendingCommit=null,u()),Ia=0,hp(),_t=a,lt=u=ba(a.current,null),dt=o,kt=0,ls=null,tr=!1,io=Wt(a,o),op=!1,oo=cs=lp=ri=nr=an=0,Xn=Zl=null,cp=!1,(o&8)!==0&&(o|=o&32);var f=a.entangledLanes;if(f!==0)for(a=a.entanglements,f&=o;0<f;){var v=31-at(f),b=1<<v;o|=a[v],f&=~b}return _a=o,wu(),u}function zw(a,o){st=null,L.H=Ll,o===Ji||o===Tu?(o=Qb(),kt=3):o===vm?(o=Qb(),kt=4):kt=o===qm?8:o!==null&&typeof o=="object"&&typeof o.then=="function"?6:1,ls=o,lt===null&&(an=1,Fu(a,bs(o,a.current)))}function Lw(){var a=is.current;return a===null?!0:(dt&4194048)===dt?Ss===null:(dt&62914560)===dt||(dt&536870912)!==0?a===Ss:!1}function $w(){var a=L.H;return L.H=Ll,a===null?Ll:a}function Uw(){var a=L.A;return L.A=iI,a}function td(){an=4,tr||(dt&4194048)!==dt&&is.current!==null||(io=!0),(nr&134217727)===0&&(ri&134217727)===0||_t===null||rr(_t,dt,cs,!1)}function mp(a,o,u){var f=Nt;Nt|=2;var v=$w(),b=Uw();(_t!==a||dt!==o)&&(Qu=null,co(a,o)),o=!1;var T=an;e:do try{if(kt!==0&<!==null){var P=lt,Z=ls;switch(kt){case 8:hp(),T=6;break e;case 3:case 2:case 9:case 6:is.current===null&&(o=!0);var se=kt;if(kt=0,ls=null,uo(a,P,Z,se),u&&io){T=0;break e}break;default:se=kt,kt=0,ls=null,uo(a,P,Z,se)}}cI(),T=an;break}catch(fe){zw(a,fe)}while(!0);return o&&a.shellSuspendCounter++,ja=Kr=null,Nt=f,L.H=v,L.A=b,lt===null&&(_t=null,dt=0,wu()),T}function cI(){for(;lt!==null;)Bw(lt)}function uI(a,o){var u=Nt;Nt|=2;var f=$w(),v=Uw();_t!==a||dt!==o?(Qu=null,Ju=we()+500,co(a,o)):io=Wt(a,o);e:do try{if(kt!==0&<!==null){o=lt;var b=ls;t:switch(kt){case 1:kt=0,ls=null,uo(a,o,b,1);break;case 2:case 9:if(Xb(b)){kt=0,ls=null,Vw(o);break}o=function(){kt!==2&&kt!==9||_t!==a||(kt=7),ea(a)},b.then(o,o);break e;case 3:kt=7;break e;case 4:kt=5;break e;case 7:Xb(b)?(kt=0,ls=null,Vw(o)):(kt=0,ls=null,uo(a,o,b,7));break;case 5:var T=null;switch(lt.tag){case 26:T=lt.memoizedState;case 5:case 27:var P=lt;if(T?Cj(T):P.stateNode.complete){kt=0,ls=null;var Z=P.sibling;if(Z!==null)lt=Z;else{var se=P.return;se!==null?(lt=se,nd(se)):lt=null}break t}}kt=0,ls=null,uo(a,o,b,5);break;case 6:kt=0,ls=null,uo(a,o,b,6);break;case 8:hp(),an=6;break e;default:throw Error(s(462))}}dI();break}catch(fe){zw(a,fe)}while(!0);return ja=Kr=null,L.H=f,L.A=v,Nt=u,lt!==null?0:(_t=null,dt=0,wu(),an)}function dI(){for(;lt!==null&&!Ce();)Bw(lt)}function Bw(a){var o=dw(a.alternate,a,_a);a.memoizedProps=a.pendingProps,o===null?nd(a):lt=o}function Vw(a){var o=a,u=o.alternate;switch(o.tag){case 15:case 0:o=rw(u,o,o.pendingProps,o.type,void 0,dt);break;case 11:o=rw(u,o,o.pendingProps,o.type.render,o.ref,dt);break;case 5:Tm(o);default:hw(u,o),o=lt=Ub(o,_a),o=dw(u,o,_a)}a.memoizedProps=a.pendingProps,o===null?nd(a):lt=o}function uo(a,o,u,f){ja=Kr=null,Tm(o),Qi=null,Ml=0;var v=o.return;try{if(Q_(a,v,o,u,dt)){an=1,Fu(a,bs(u,a.current)),lt=null;return}}catch(b){if(v!==null)throw lt=v,b;an=1,Fu(a,bs(u,a.current)),lt=null;return}o.flags&32768?(mt||f===1?a=!0:io||(dt&536870912)!==0?a=!1:(tr=a=!0,(f===2||f===9||f===3||f===6)&&(f=is.current,f!==null&&f.tag===13&&(f.flags|=16384))),Fw(o,a)):nd(o)}function nd(a){var o=a;do{if((o.flags&32768)!==0){Fw(o,tr);return}a=o.return;var u=nI(o.alternate,o,_a);if(u!==null){lt=u;return}if(o=o.sibling,o!==null){lt=o;return}lt=o=a}while(o!==null);an===0&&(an=5)}function Fw(a,o){do{var u=sI(a.alternate,a);if(u!==null){u.flags&=32767,lt=u;return}if(u=a.return,u!==null&&(u.flags|=32768,u.subtreeFlags=0,u.deletions=null),!o&&(a=a.sibling,a!==null)){lt=a;return}lt=a=u}while(a!==null);an=6,lt=null}function Hw(a,o,u,f,v,b,T,P,Z){a.cancelPendingCommit=null;do sd();while(xn!==0);if((Nt&6)!==0)throw Error(s(327));if(o!==null){if(o===a.current)throw Error(s(177));if(b=o.lanes|o.childLanes,b|=nm,Ne(a,u,b,T,P,Z),a===_t&&(lt=_t=null,dt=0),lo=o,ar=a,Ia=u,up=b,dp=v,Iw=f,(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?(a.callbackNode=null,a.callbackPriority=0,pI(Be,function(){return Gw(),null})):(a.callbackNode=null,a.callbackPriority=0),f=(o.flags&13878)!==0,(o.subtreeFlags&13878)!==0||f){f=L.T,L.T=null,v=F.p,F.p=2,T=Nt,Nt|=4;try{aI(a,o,u)}finally{Nt=T,F.p=v,L.T=f}}xn=1,qw(),Zw(),Ww()}}function qw(){if(xn===1){xn=0;var a=ar,o=lo,u=(o.flags&13878)!==0;if((o.subtreeFlags&13878)!==0||u){u=L.T,L.T=null;var f=F.p;F.p=2;var v=Nt;Nt|=4;try{kw(o,a);var b=Ep,T=Rb(a.containerInfo),P=b.focusedElem,Z=b.selectionRange;if(T!==P&&P&&P.ownerDocument&&Mb(P.ownerDocument.documentElement,P)){if(Z!==null&&Xh(P)){var se=Z.start,fe=Z.end;if(fe===void 0&&(fe=se),"selectionStart"in P)P.selectionStart=se,P.selectionEnd=Math.min(fe,P.value.length);else{var ge=P.ownerDocument||document,re=ge&&ge.defaultView||window;if(re.getSelection){var ce=re.getSelection(),ze=P.textContent.length,qe=Math.min(Z.start,ze),Rt=Z.end===void 0?qe:Math.min(Z.end,ze);!ce.extend&&qe>Rt&&(T=Rt,Rt=qe,qe=T);var J=Tb(P,qe),K=Tb(P,Rt);if(J&&K&&(ce.rangeCount!==1||ce.anchorNode!==J.node||ce.anchorOffset!==J.offset||ce.focusNode!==K.node||ce.focusOffset!==K.offset)){var ne=ge.createRange();ne.setStart(J.node,J.offset),ce.removeAllRanges(),qe>Rt?(ce.addRange(ne),ce.extend(K.node,K.offset)):(ne.setEnd(K.node,K.offset),ce.addRange(ne))}}}}for(ge=[],ce=P;ce=ce.parentNode;)ce.nodeType===1&&ge.push({element:ce,left:ce.scrollLeft,top:ce.scrollTop});for(typeof P.focus=="function"&&P.focus(),P=0;P<ge.length;P++){var pe=ge[P];pe.element.scrollLeft=pe.left,pe.element.scrollTop=pe.top}}pd=!!kp,Ep=kp=null}finally{Nt=v,F.p=f,L.T=u}}a.current=o,xn=2}}function Zw(){if(xn===2){xn=0;var a=ar,o=lo,u=(o.flags&8772)!==0;if((o.subtreeFlags&8772)!==0||u){u=L.T,L.T=null;var f=F.p;F.p=2;var v=Nt;Nt|=4;try{bw(a,o.alternate,o)}finally{Nt=v,F.p=f,L.T=u}}xn=3}}function Ww(){if(xn===4||xn===3){xn=0,be();var a=ar,o=lo,u=Ia,f=Iw;(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?xn=5:(xn=0,lo=ar=null,Yw(a,a.pendingLanes));var v=a.pendingLanes;if(v===0&&(sr=null),Qt(u),o=o.stateNode,Te&&typeof Te.onCommitFiberRoot=="function")try{Te.onCommitFiberRoot(Oe,o,void 0,(o.current.flags&128)===128)}catch{}if(f!==null){o=L.T,v=F.p,F.p=2,L.T=null;try{for(var b=a.onRecoverableError,T=0;T<f.length;T++){var P=f[T];b(P.value,{componentStack:P.stack})}}finally{L.T=o,F.p=v}}(Ia&3)!==0&&sd(),ea(a),v=a.pendingLanes,(u&261930)!==0&&(v&42)!==0?a===fp?Wl++:(Wl=0,fp=a):Wl=0,Yl(0)}}function Yw(a,o){(a.pooledCacheLanes&=o)===0&&(o=a.pooledCache,o!=null&&(a.pooledCache=null,Al(o)))}function sd(){return qw(),Zw(),Ww(),Gw()}function Gw(){if(xn!==5)return!1;var a=ar,o=up;up=0;var u=Qt(Ia),f=L.T,v=F.p;try{F.p=32>u?32:u,L.T=null,u=dp,dp=null;var b=ar,T=Ia;if(xn=0,lo=ar=null,Ia=0,(Nt&6)!==0)throw Error(s(331));var P=Nt;if(Nt|=4,Mw(b.current),Cw(b,b.current,T,u),Nt=P,Yl(0,!1),Te&&typeof Te.onPostCommitFiberRoot=="function")try{Te.onPostCommitFiberRoot(Oe,b)}catch{}return!0}finally{F.p=v,L.T=f,Yw(a,o)}}function Kw(a,o,u){o=bs(u,o),o=Hm(a.stateNode,o,2),a=Xa(a,o,2),a!==null&&(ye(a,2),ea(a))}function Et(a,o,u){if(a.tag===3)Kw(a,a,u);else for(;o!==null;){if(o.tag===3){Kw(o,a,u);break}else if(o.tag===1){var f=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof f.componentDidCatch=="function"&&(sr===null||!sr.has(f))){a=bs(u,a),u=X0(2),f=Xa(o,u,2),f!==null&&(J0(u,f,o,a),ye(f,2),ea(f));break}}o=o.return}}function pp(a,o,u){var f=a.pingCache;if(f===null){f=a.pingCache=new oI;var v=new Set;f.set(o,v)}else v=f.get(o),v===void 0&&(v=new Set,f.set(o,v));v.has(u)||(op=!0,v.add(u),a=fI.bind(null,a,o,u),o.then(a,a))}function fI(a,o,u){var f=a.pingCache;f!==null&&f.delete(o),a.pingedLanes|=a.suspendedLanes&u,a.warmLanes&=~u,_t===a&&(dt&u)===u&&(an===4||an===3&&(dt&62914560)===dt&&300>we()-Xu?(Nt&2)===0&&co(a,0):lp|=u,oo===dt&&(oo=0)),ea(a)}function Xw(a,o){o===0&&(o=Ds()),a=Wr(a,o),a!==null&&(ye(a,o),ea(a))}function hI(a){var o=a.memoizedState,u=0;o!==null&&(u=o.retryLane),Xw(a,u)}function mI(a,o){var u=0;switch(a.tag){case 31:case 13:var f=a.stateNode,v=a.memoizedState;v!==null&&(u=v.retryLane);break;case 19:f=a.stateNode;break;case 22:f=a.stateNode._retryCache;break;default:throw Error(s(314))}f!==null&&f.delete(o),Xw(a,u)}function pI(a,o){return ve(a,o)}var ad=null,fo=null,gp=!1,rd=!1,vp=!1,ir=0;function ea(a){a!==fo&&a.next===null&&(fo===null?ad=fo=a:fo=fo.next=a),rd=!0,gp||(gp=!0,vI())}function Yl(a,o){if(!vp&&rd){vp=!0;do for(var u=!1,f=ad;f!==null;){if(a!==0){var v=f.pendingLanes;if(v===0)var b=0;else{var T=f.suspendedLanes,P=f.pingedLanes;b=(1<<31-at(42|a)+1)-1,b&=v&~(T&~P),b=b&201326741?b&201326741|1:b?b|2:0}b!==0&&(u=!0,tj(f,b))}else b=dt,b=jt(f,f===_t?b:0,f.cancelPendingCommit!==null||f.timeoutHandle!==-1),(b&3)===0||Wt(f,b)||(u=!0,tj(f,b));f=f.next}while(u);vp=!1}}function gI(){Jw()}function Jw(){rd=gp=!1;var a=0;ir!==0&&CI()&&(a=ir);for(var o=we(),u=null,f=ad;f!==null;){var v=f.next,b=Qw(f,o);b===0?(f.next=null,u===null?ad=v:u.next=v,v===null&&(fo=u)):(u=f,(a!==0||(b&3)!==0)&&(rd=!0)),f=v}xn!==0&&xn!==5||Yl(a),ir!==0&&(ir=0)}function Qw(a,o){for(var u=a.suspendedLanes,f=a.pingedLanes,v=a.expirationTimes,b=a.pendingLanes&-62914561;0<b;){var T=31-at(b),P=1<<T,Z=v[T];Z===-1?((P&u)===0||(P&f)!==0)&&(v[T]=Fa(P,o)):Z<=o&&(a.expiredLanes|=P),b&=~P}if(o=_t,u=dt,u=jt(a,a===o?u:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),f=a.callbackNode,u===0||a===o&&(kt===2||kt===9)||a.cancelPendingCommit!==null)return f!==null&&f!==null&&ue(f),a.callbackNode=null,a.callbackPriority=0;if((u&3)===0||Wt(a,u)){if(o=u&-u,o===a.callbackPriority)return o;switch(f!==null&&ue(f),Qt(u)){case 2:case 8:u=et;break;case 32:u=Be;break;case 268435456:u=Dt;break;default:u=Be}return f=ej.bind(null,a),u=ve(u,f),a.callbackPriority=o,a.callbackNode=u,o}return f!==null&&f!==null&&ue(f),a.callbackPriority=2,a.callbackNode=null,2}function ej(a,o){if(xn!==0&&xn!==5)return a.callbackNode=null,a.callbackPriority=0,null;var u=a.callbackNode;if(sd()&&a.callbackNode!==u)return null;var f=dt;return f=jt(a,a===_t?f:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),f===0?null:(Dw(a,f,o),Qw(a,we()),a.callbackNode!=null&&a.callbackNode===u?ej.bind(null,a):null)}function tj(a,o){if(sd())return null;Dw(a,o,!0)}function vI(){TI(function(){(Nt&6)!==0?ve(He,gI):Jw()})}function yp(){if(ir===0){var a=Ki;a===0&&(a=Pt,Pt<<=1,(Pt&261888)===0&&(Pt=256)),ir=a}return ir}function nj(a){return a==null||typeof a=="symbol"||typeof a=="boolean"?null:typeof a=="function"?a:hu(""+a)}function sj(a,o){var u=o.ownerDocument.createElement("input");return u.name=o.name,u.value=o.value,a.id&&u.setAttribute("form",a.id),o.parentNode.insertBefore(u,o),a=new FormData(a),u.parentNode.removeChild(u),a}function yI(a,o,u,f,v){if(o==="submit"&&u&&u.stateNode===v){var b=nj((v[Zn]||null).action),T=f.submitter;T&&(o=(o=T[Zn]||null)?nj(o.formAction):T.getAttribute("formAction"),o!==null&&(b=o,T=null));var P=new vu("action","action",null,f,v);a.push({event:P,listeners:[{instance:null,listener:function(){if(f.defaultPrevented){if(ir!==0){var Z=T?sj(v,T):new FormData(v);Lm(u,{pending:!0,data:Z,method:v.method,action:b},null,Z)}}else typeof b=="function"&&(P.preventDefault(),Z=T?sj(v,T):new FormData(v),Lm(u,{pending:!0,data:Z,method:v.method,action:b},b,Z))},currentTarget:v}]})}}for(var xp=0;xp<tm.length;xp++){var bp=tm[xp],xI=bp.toLowerCase(),bI=bp[0].toUpperCase()+bp.slice(1);Ps(xI,"on"+bI)}Ps(Ob,"onAnimationEnd"),Ps(Db,"onAnimationIteration"),Ps(Pb,"onAnimationStart"),Ps("dblclick","onDoubleClick"),Ps("focusin","onFocus"),Ps("focusout","onBlur"),Ps(P_,"onTransitionRun"),Ps(z_,"onTransitionStart"),Ps(L_,"onTransitionCancel"),Ps(zb,"onTransitionEnd"),Pi("onMouseEnter",["mouseout","mouseover"]),Pi("onMouseLeave",["mouseout","mouseover"]),Pi("onPointerEnter",["pointerout","pointerover"]),Pi("onPointerLeave",["pointerout","pointerover"]),Fr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Fr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Fr("onBeforeInput",["compositionend","keypress","textInput","paste"]),Fr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Fr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Fr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Gl="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(" "),wI=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Gl));function aj(a,o){o=(o&4)!==0;for(var u=0;u<a.length;u++){var f=a[u],v=f.event;f=f.listeners;e:{var b=void 0;if(o)for(var T=f.length-1;0<=T;T--){var P=f[T],Z=P.instance,se=P.currentTarget;if(P=P.listener,Z!==b&&v.isPropagationStopped())break e;b=P,v.currentTarget=se;try{b(v)}catch(fe){bu(fe)}v.currentTarget=null,b=Z}else for(T=0;T<f.length;T++){if(P=f[T],Z=P.instance,se=P.currentTarget,P=P.listener,Z!==b&&v.isPropagationStopped())break e;b=P,v.currentTarget=se;try{b(v)}catch(fe){bu(fe)}v.currentTarget=null,b=Z}}}}function ct(a,o){var u=o[Ih];u===void 0&&(u=o[Ih]=new Set);var f=a+"__bubble";u.has(f)||(rj(o,a,2,!1),u.add(f))}function wp(a,o,u){var f=0;o&&(f|=4),rj(u,a,f,o)}var id="_reactListening"+Math.random().toString(36).slice(2);function jp(a){if(!a[id]){a[id]=!0,Jx.forEach(function(u){u!=="selectionchange"&&(wI.has(u)||wp(u,!1,a),wp(u,!0,a))});var o=a.nodeType===9?a:a.ownerDocument;o===null||o[id]||(o[id]=!0,wp("selectionchange",!1,o))}}function rj(a,o,u,f){switch(Oj(o)){case 2:var v=GI;break;case 8:v=KI;break;default:v=zp}u=v.bind(null,o,u,a),v=void 0,!Vh||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(v=!0),f?v!==void 0?a.addEventListener(o,u,{capture:!0,passive:v}):a.addEventListener(o,u,!0):v!==void 0?a.addEventListener(o,u,{passive:v}):a.addEventListener(o,u,!1)}function Np(a,o,u,f,v){var b=f;if((o&1)===0&&(o&2)===0&&f!==null)e:for(;;){if(f===null)return;var T=f.tag;if(T===3||T===4){var P=f.stateNode.containerInfo;if(P===v)break;if(T===4)for(T=f.return;T!==null;){var Z=T.tag;if((Z===3||Z===4)&&T.stateNode.containerInfo===v)return;T=T.return}for(;P!==null;){if(T=Ii(P),T===null)return;if(Z=T.tag,Z===5||Z===6||Z===26||Z===27){f=b=T;continue e}P=P.parentNode}}f=f.return}ub(function(){var se=b,fe=Uh(u),ge=[];e:{var re=Lb.get(a);if(re!==void 0){var ce=vu,ze=a;switch(a){case"keypress":if(pu(u)===0)break e;case"keydown":case"keyup":ce=m_;break;case"focusin":ze="focus",ce=Zh;break;case"focusout":ze="blur",ce=Zh;break;case"beforeblur":case"afterblur":ce=Zh;break;case"click":if(u.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ce=hb;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ce=n_;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ce=v_;break;case Ob:case Db:case Pb:ce=r_;break;case zb:ce=x_;break;case"scroll":case"scrollend":ce=e_;break;case"wheel":ce=w_;break;case"copy":case"cut":case"paste":ce=o_;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ce=pb;break;case"toggle":case"beforetoggle":ce=N_}var qe=(o&4)!==0,Rt=!qe&&(a==="scroll"||a==="scrollend"),J=qe?re!==null?re+"Capture":null:re;qe=[];for(var K=se,ne;K!==null;){var pe=K;if(ne=pe.stateNode,pe=pe.tag,pe!==5&&pe!==26&&pe!==27||ne===null||J===null||(pe=vl(K,J),pe!=null&&qe.push(Kl(K,pe,ne))),Rt)break;K=K.return}0<qe.length&&(re=new ce(re,ze,null,u,fe),ge.push({event:re,listeners:qe}))}}if((o&7)===0){e:{if(re=a==="mouseover"||a==="pointerover",ce=a==="mouseout"||a==="pointerout",re&&u!==$h&&(ze=u.relatedTarget||u.fromElement)&&(Ii(ze)||ze[_i]))break e;if((ce||re)&&(re=fe.window===fe?fe:(re=fe.ownerDocument)?re.defaultView||re.parentWindow:window,ce?(ze=u.relatedTarget||u.toElement,ce=se,ze=ze?Ii(ze):null,ze!==null&&(Rt=l(ze),qe=ze.tag,ze!==Rt||qe!==5&&qe!==27&&qe!==6)&&(ze=null)):(ce=null,ze=se),ce!==ze)){if(qe=hb,pe="onMouseLeave",J="onMouseEnter",K="mouse",(a==="pointerout"||a==="pointerover")&&(qe=pb,pe="onPointerLeave",J="onPointerEnter",K="pointer"),Rt=ce==null?re:gl(ce),ne=ze==null?re:gl(ze),re=new qe(pe,K+"leave",ce,u,fe),re.target=Rt,re.relatedTarget=ne,pe=null,Ii(fe)===se&&(qe=new qe(J,K+"enter",ze,u,fe),qe.target=ne,qe.relatedTarget=Rt,pe=qe),Rt=pe,ce&&ze)t:{for(qe=jI,J=ce,K=ze,ne=0,pe=J;pe;pe=qe(pe))ne++;pe=0;for(var Ve=K;Ve;Ve=qe(Ve))pe++;for(;0<ne-pe;)J=qe(J),ne--;for(;0<pe-ne;)K=qe(K),pe--;for(;ne--;){if(J===K||K!==null&&J===K.alternate){qe=J;break t}J=qe(J),K=qe(K)}qe=null}else qe=null;ce!==null&&ij(ge,re,ce,qe,!1),ze!==null&&Rt!==null&&ij(ge,Rt,ze,qe,!0)}}e:{if(re=se?gl(se):window,ce=re.nodeName&&re.nodeName.toLowerCase(),ce==="select"||ce==="input"&&re.type==="file")var bt=Nb;else if(wb(re))if(Sb)bt=I_;else{bt=R_;var $e=M_}else ce=re.nodeName,!ce||ce.toLowerCase()!=="input"||re.type!=="checkbox"&&re.type!=="radio"?se&&Lh(se.elementType)&&(bt=Nb):bt=__;if(bt&&(bt=bt(a,se))){jb(ge,bt,u,fe);break e}$e&&$e(a,re,se),a==="focusout"&&se&&re.type==="number"&&se.memoizedProps.value!=null&&zh(re,"number",re.value)}switch($e=se?gl(se):window,a){case"focusin":(wb($e)||$e.contentEditable==="true")&&(Vi=$e,Jh=se,kl=null);break;case"focusout":kl=Jh=Vi=null;break;case"mousedown":Qh=!0;break;case"contextmenu":case"mouseup":case"dragend":Qh=!1,_b(ge,u,fe);break;case"selectionchange":if(D_)break;case"keydown":case"keyup":_b(ge,u,fe)}var rt;if(Yh)e:{switch(a){case"compositionstart":var ft="onCompositionStart";break e;case"compositionend":ft="onCompositionEnd";break e;case"compositionupdate":ft="onCompositionUpdate";break e}ft=void 0}else Bi?xb(a,u)&&(ft="onCompositionEnd"):a==="keydown"&&u.keyCode===229&&(ft="onCompositionStart");ft&&(gb&&u.locale!=="ko"&&(Bi||ft!=="onCompositionStart"?ft==="onCompositionEnd"&&Bi&&(rt=db()):(Ha=fe,Fh="value"in Ha?Ha.value:Ha.textContent,Bi=!0)),$e=od(se,ft),0<$e.length&&(ft=new mb(ft,a,null,u,fe),ge.push({event:ft,listeners:$e}),rt?ft.data=rt:(rt=bb(u),rt!==null&&(ft.data=rt)))),(rt=k_?E_(a,u):C_(a,u))&&(ft=od(se,"onBeforeInput"),0<ft.length&&($e=new mb("onBeforeInput","beforeinput",null,u,fe),ge.push({event:$e,listeners:ft}),$e.data=rt)),yI(ge,a,se,u,fe)}aj(ge,o)})}function Kl(a,o,u){return{instance:a,listener:o,currentTarget:u}}function od(a,o){for(var u=o+"Capture",f=[];a!==null;){var v=a,b=v.stateNode;if(v=v.tag,v!==5&&v!==26&&v!==27||b===null||(v=vl(a,u),v!=null&&f.unshift(Kl(a,v,b)),v=vl(a,o),v!=null&&f.push(Kl(a,v,b))),a.tag===3)return f;a=a.return}return[]}function jI(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5&&a.tag!==27);return a||null}function ij(a,o,u,f,v){for(var b=o._reactName,T=[];u!==null&&u!==f;){var P=u,Z=P.alternate,se=P.stateNode;if(P=P.tag,Z!==null&&Z===f)break;P!==5&&P!==26&&P!==27||se===null||(Z=se,v?(se=vl(u,b),se!=null&&T.unshift(Kl(u,se,Z))):v||(se=vl(u,b),se!=null&&T.push(Kl(u,se,Z)))),u=u.return}T.length!==0&&a.push({event:o,listeners:T})}var NI=/\r\n?/g,SI=/\u0000|\uFFFD/g;function oj(a){return(typeof a=="string"?a:""+a).replace(NI,`
|
|
9
|
-
`).replace(SI,"")}function lj(a,o){return o=oj(o),oj(a)===o}function Mt(a,o,u,f,v,b){switch(u){case"children":typeof f=="string"?o==="body"||o==="textarea"&&f===""||Li(a,f):(typeof f=="number"||typeof f=="bigint")&&o!=="body"&&Li(a,""+f);break;case"className":du(a,"class",f);break;case"tabIndex":du(a,"tabindex",f);break;case"dir":case"role":case"viewBox":case"width":case"height":du(a,u,f);break;case"style":lb(a,f,b);break;case"data":if(o!=="object"){du(a,"data",f);break}case"src":case"href":if(f===""&&(o!=="a"||u!=="href")){a.removeAttribute(u);break}if(f==null||typeof f=="function"||typeof f=="symbol"||typeof f=="boolean"){a.removeAttribute(u);break}f=hu(""+f),a.setAttribute(u,f);break;case"action":case"formAction":if(typeof f=="function"){a.setAttribute(u,"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 b=="function"&&(u==="formAction"?(o!=="input"&&Mt(a,o,"name",v.name,v,null),Mt(a,o,"formEncType",v.formEncType,v,null),Mt(a,o,"formMethod",v.formMethod,v,null),Mt(a,o,"formTarget",v.formTarget,v,null)):(Mt(a,o,"encType",v.encType,v,null),Mt(a,o,"method",v.method,v,null),Mt(a,o,"target",v.target,v,null)));if(f==null||typeof f=="symbol"||typeof f=="boolean"){a.removeAttribute(u);break}f=hu(""+f),a.setAttribute(u,f);break;case"onClick":f!=null&&(a.onclick=ya);break;case"onScroll":f!=null&&ct("scroll",a);break;case"onScrollEnd":f!=null&&ct("scrollend",a);break;case"dangerouslySetInnerHTML":if(f!=null){if(typeof f!="object"||!("__html"in f))throw Error(s(61));if(u=f.__html,u!=null){if(v.children!=null)throw Error(s(60));a.innerHTML=u}}break;case"multiple":a.multiple=f&&typeof f!="function"&&typeof f!="symbol";break;case"muted":a.muted=f&&typeof f!="function"&&typeof f!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(f==null||typeof f=="function"||typeof f=="boolean"||typeof f=="symbol"){a.removeAttribute("xlink:href");break}u=hu(""+f),a.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",u);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":f!=null&&typeof f!="function"&&typeof f!="symbol"?a.setAttribute(u,""+f):a.removeAttribute(u);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":f&&typeof f!="function"&&typeof f!="symbol"?a.setAttribute(u,""):a.removeAttribute(u);break;case"capture":case"download":f===!0?a.setAttribute(u,""):f!==!1&&f!=null&&typeof f!="function"&&typeof f!="symbol"?a.setAttribute(u,f):a.removeAttribute(u);break;case"cols":case"rows":case"size":case"span":f!=null&&typeof f!="function"&&typeof f!="symbol"&&!isNaN(f)&&1<=f?a.setAttribute(u,f):a.removeAttribute(u);break;case"rowSpan":case"start":f==null||typeof f=="function"||typeof f=="symbol"||isNaN(f)?a.removeAttribute(u):a.setAttribute(u,f);break;case"popover":ct("beforetoggle",a),ct("toggle",a),uu(a,"popover",f);break;case"xlinkActuate":va(a,"http://www.w3.org/1999/xlink","xlink:actuate",f);break;case"xlinkArcrole":va(a,"http://www.w3.org/1999/xlink","xlink:arcrole",f);break;case"xlinkRole":va(a,"http://www.w3.org/1999/xlink","xlink:role",f);break;case"xlinkShow":va(a,"http://www.w3.org/1999/xlink","xlink:show",f);break;case"xlinkTitle":va(a,"http://www.w3.org/1999/xlink","xlink:title",f);break;case"xlinkType":va(a,"http://www.w3.org/1999/xlink","xlink:type",f);break;case"xmlBase":va(a,"http://www.w3.org/XML/1998/namespace","xml:base",f);break;case"xmlLang":va(a,"http://www.w3.org/XML/1998/namespace","xml:lang",f);break;case"xmlSpace":va(a,"http://www.w3.org/XML/1998/namespace","xml:space",f);break;case"is":uu(a,"is",f);break;case"innerText":case"textContent":break;default:(!(2<u.length)||u[0]!=="o"&&u[0]!=="O"||u[1]!=="n"&&u[1]!=="N")&&(u=J2.get(u)||u,uu(a,u,f))}}function Sp(a,o,u,f,v,b){switch(u){case"style":lb(a,f,b);break;case"dangerouslySetInnerHTML":if(f!=null){if(typeof f!="object"||!("__html"in f))throw Error(s(61));if(u=f.__html,u!=null){if(v.children!=null)throw Error(s(60));a.innerHTML=u}}break;case"children":typeof f=="string"?Li(a,f):(typeof f=="number"||typeof f=="bigint")&&Li(a,""+f);break;case"onScroll":f!=null&&ct("scroll",a);break;case"onScrollEnd":f!=null&&ct("scrollend",a);break;case"onClick":f!=null&&(a.onclick=ya);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Qx.hasOwnProperty(u))e:{if(u[0]==="o"&&u[1]==="n"&&(v=u.endsWith("Capture"),o=u.slice(2,v?u.length-7:void 0),b=a[Zn]||null,b=b!=null?b[u]:null,typeof b=="function"&&a.removeEventListener(o,b,v),typeof f=="function")){typeof b!="function"&&b!==null&&(u in a?a[u]=null:a.hasAttribute(u)&&a.removeAttribute(u)),a.addEventListener(o,f,v);break e}u in a?a[u]=f:f===!0?a.setAttribute(u,""):uu(a,u,f)}}}function Tn(a,o,u){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ct("error",a),ct("load",a);var f=!1,v=!1,b;for(b in u)if(u.hasOwnProperty(b)){var T=u[b];if(T!=null)switch(b){case"src":f=!0;break;case"srcSet":v=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,o));default:Mt(a,o,b,T,u,null)}}v&&Mt(a,o,"srcSet",u.srcSet,u,null),f&&Mt(a,o,"src",u.src,u,null);return;case"input":ct("invalid",a);var P=b=T=v=null,Z=null,se=null;for(f in u)if(u.hasOwnProperty(f)){var fe=u[f];if(fe!=null)switch(f){case"name":v=fe;break;case"type":T=fe;break;case"checked":Z=fe;break;case"defaultChecked":se=fe;break;case"value":b=fe;break;case"defaultValue":P=fe;break;case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(s(137,o));break;default:Mt(a,o,f,fe,u,null)}}ab(a,b,P,Z,se,T,v,!1);return;case"select":ct("invalid",a),f=T=b=null;for(v in u)if(u.hasOwnProperty(v)&&(P=u[v],P!=null))switch(v){case"value":b=P;break;case"defaultValue":T=P;break;case"multiple":f=P;default:Mt(a,o,v,P,u,null)}o=b,u=T,a.multiple=!!f,o!=null?zi(a,!!f,o,!1):u!=null&&zi(a,!!f,u,!0);return;case"textarea":ct("invalid",a),b=v=f=null;for(T in u)if(u.hasOwnProperty(T)&&(P=u[T],P!=null))switch(T){case"value":f=P;break;case"defaultValue":v=P;break;case"children":b=P;break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(s(91));break;default:Mt(a,o,T,P,u,null)}ib(a,f,v,b);return;case"option":for(Z in u)u.hasOwnProperty(Z)&&(f=u[Z],f!=null)&&(Z==="selected"?a.selected=f&&typeof f!="function"&&typeof f!="symbol":Mt(a,o,Z,f,u,null));return;case"dialog":ct("beforetoggle",a),ct("toggle",a),ct("cancel",a),ct("close",a);break;case"iframe":case"object":ct("load",a);break;case"video":case"audio":for(f=0;f<Gl.length;f++)ct(Gl[f],a);break;case"image":ct("error",a),ct("load",a);break;case"details":ct("toggle",a);break;case"embed":case"source":case"link":ct("error",a),ct("load",a);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(se in u)if(u.hasOwnProperty(se)&&(f=u[se],f!=null))switch(se){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,o));default:Mt(a,o,se,f,u,null)}return;default:if(Lh(o)){for(fe in u)u.hasOwnProperty(fe)&&(f=u[fe],f!==void 0&&Sp(a,o,fe,f,u,void 0));return}}for(P in u)u.hasOwnProperty(P)&&(f=u[P],f!=null&&Mt(a,o,P,f,u,null))}function kI(a,o,u,f){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var v=null,b=null,T=null,P=null,Z=null,se=null,fe=null;for(ce in u){var ge=u[ce];if(u.hasOwnProperty(ce)&&ge!=null)switch(ce){case"checked":break;case"value":break;case"defaultValue":Z=ge;default:f.hasOwnProperty(ce)||Mt(a,o,ce,null,f,ge)}}for(var re in f){var ce=f[re];if(ge=u[re],f.hasOwnProperty(re)&&(ce!=null||ge!=null))switch(re){case"type":b=ce;break;case"name":v=ce;break;case"checked":se=ce;break;case"defaultChecked":fe=ce;break;case"value":T=ce;break;case"defaultValue":P=ce;break;case"children":case"dangerouslySetInnerHTML":if(ce!=null)throw Error(s(137,o));break;default:ce!==ge&&Mt(a,o,re,ce,f,ge)}}Ph(a,T,P,Z,se,fe,b,v);return;case"select":ce=T=P=re=null;for(b in u)if(Z=u[b],u.hasOwnProperty(b)&&Z!=null)switch(b){case"value":break;case"multiple":ce=Z;default:f.hasOwnProperty(b)||Mt(a,o,b,null,f,Z)}for(v in f)if(b=f[v],Z=u[v],f.hasOwnProperty(v)&&(b!=null||Z!=null))switch(v){case"value":re=b;break;case"defaultValue":P=b;break;case"multiple":T=b;default:b!==Z&&Mt(a,o,v,b,f,Z)}o=P,u=T,f=ce,re!=null?zi(a,!!u,re,!1):!!f!=!!u&&(o!=null?zi(a,!!u,o,!0):zi(a,!!u,u?[]:"",!1));return;case"textarea":ce=re=null;for(P in u)if(v=u[P],u.hasOwnProperty(P)&&v!=null&&!f.hasOwnProperty(P))switch(P){case"value":break;case"children":break;default:Mt(a,o,P,null,f,v)}for(T in f)if(v=f[T],b=u[T],f.hasOwnProperty(T)&&(v!=null||b!=null))switch(T){case"value":re=v;break;case"defaultValue":ce=v;break;case"children":break;case"dangerouslySetInnerHTML":if(v!=null)throw Error(s(91));break;default:v!==b&&Mt(a,o,T,v,f,b)}rb(a,re,ce);return;case"option":for(var ze in u)re=u[ze],u.hasOwnProperty(ze)&&re!=null&&!f.hasOwnProperty(ze)&&(ze==="selected"?a.selected=!1:Mt(a,o,ze,null,f,re));for(Z in f)re=f[Z],ce=u[Z],f.hasOwnProperty(Z)&&re!==ce&&(re!=null||ce!=null)&&(Z==="selected"?a.selected=re&&typeof re!="function"&&typeof re!="symbol":Mt(a,o,Z,re,f,ce));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 qe in u)re=u[qe],u.hasOwnProperty(qe)&&re!=null&&!f.hasOwnProperty(qe)&&Mt(a,o,qe,null,f,re);for(se in f)if(re=f[se],ce=u[se],f.hasOwnProperty(se)&&re!==ce&&(re!=null||ce!=null))switch(se){case"children":case"dangerouslySetInnerHTML":if(re!=null)throw Error(s(137,o));break;default:Mt(a,o,se,re,f,ce)}return;default:if(Lh(o)){for(var Rt in u)re=u[Rt],u.hasOwnProperty(Rt)&&re!==void 0&&!f.hasOwnProperty(Rt)&&Sp(a,o,Rt,void 0,f,re);for(fe in f)re=f[fe],ce=u[fe],!f.hasOwnProperty(fe)||re===ce||re===void 0&&ce===void 0||Sp(a,o,fe,re,f,ce);return}}for(var J in u)re=u[J],u.hasOwnProperty(J)&&re!=null&&!f.hasOwnProperty(J)&&Mt(a,o,J,null,f,re);for(ge in f)re=f[ge],ce=u[ge],!f.hasOwnProperty(ge)||re===ce||re==null&&ce==null||Mt(a,o,ge,re,f,ce)}function cj(a){switch(a){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function EI(){if(typeof performance.getEntriesByType=="function"){for(var a=0,o=0,u=performance.getEntriesByType("resource"),f=0;f<u.length;f++){var v=u[f],b=v.transferSize,T=v.initiatorType,P=v.duration;if(b&&P&&cj(T)){for(T=0,P=v.responseEnd,f+=1;f<u.length;f++){var Z=u[f],se=Z.startTime;if(se>P)break;var fe=Z.transferSize,ge=Z.initiatorType;fe&&cj(ge)&&(Z=Z.responseEnd,T+=fe*(Z<P?1:(P-se)/(Z-se)))}if(--f,o+=8*(b+T)/(v.duration/1e3),a++,10<a)break}}if(0<a)return o/a/1e6}return navigator.connection&&(a=navigator.connection.downlink,typeof a=="number")?a:5}var kp=null,Ep=null;function ld(a){return a.nodeType===9?a:a.ownerDocument}function uj(a){switch(a){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function dj(a,o){if(a===0)switch(o){case"svg":return 1;case"math":return 2;default:return 0}return a===1&&o==="foreignObject"?0:a}function Cp(a,o){return a==="textarea"||a==="noscript"||typeof o.children=="string"||typeof o.children=="number"||typeof o.children=="bigint"||typeof o.dangerouslySetInnerHTML=="object"&&o.dangerouslySetInnerHTML!==null&&o.dangerouslySetInnerHTML.__html!=null}var Ap=null;function CI(){var a=window.event;return a&&a.type==="popstate"?a===Ap?!1:(Ap=a,!0):(Ap=null,!1)}var fj=typeof setTimeout=="function"?setTimeout:void 0,AI=typeof clearTimeout=="function"?clearTimeout:void 0,hj=typeof Promise=="function"?Promise:void 0,TI=typeof queueMicrotask=="function"?queueMicrotask:typeof hj<"u"?function(a){return hj.resolve(null).then(a).catch(MI)}:fj;function MI(a){setTimeout(function(){throw a})}function or(a){return a==="head"}function mj(a,o){var u=o,f=0;do{var v=u.nextSibling;if(a.removeChild(u),v&&v.nodeType===8)if(u=v.data,u==="/$"||u==="/&"){if(f===0){a.removeChild(v),go(o);return}f--}else if(u==="$"||u==="$?"||u==="$~"||u==="$!"||u==="&")f++;else if(u==="html")Xl(a.ownerDocument.documentElement);else if(u==="head"){u=a.ownerDocument.head,Xl(u);for(var b=u.firstChild;b;){var T=b.nextSibling,P=b.nodeName;b[pl]||P==="SCRIPT"||P==="STYLE"||P==="LINK"&&b.rel.toLowerCase()==="stylesheet"||u.removeChild(b),b=T}}else u==="body"&&Xl(a.ownerDocument.body);u=v}while(u);go(o)}function pj(a,o){var u=a;a=0;do{var f=u.nextSibling;if(u.nodeType===1?o?(u._stashedDisplay=u.style.display,u.style.display="none"):(u.style.display=u._stashedDisplay||"",u.getAttribute("style")===""&&u.removeAttribute("style")):u.nodeType===3&&(o?(u._stashedText=u.nodeValue,u.nodeValue=""):u.nodeValue=u._stashedText||""),f&&f.nodeType===8)if(u=f.data,u==="/$"){if(a===0)break;a--}else u!=="$"&&u!=="$?"&&u!=="$~"&&u!=="$!"||a++;u=f}while(u)}function Tp(a){var o=a.firstChild;for(o&&o.nodeType===10&&(o=o.nextSibling);o;){var u=o;switch(o=o.nextSibling,u.nodeName){case"HTML":case"HEAD":case"BODY":Tp(u),Oh(u);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(u.rel.toLowerCase()==="stylesheet")continue}a.removeChild(u)}}function RI(a,o,u,f){for(;a.nodeType===1;){var v=u;if(a.nodeName.toLowerCase()!==o.toLowerCase()){if(!f&&(a.nodeName!=="INPUT"||a.type!=="hidden"))break}else if(f){if(!a[pl])switch(o){case"meta":if(!a.hasAttribute("itemprop"))break;return a;case"link":if(b=a.getAttribute("rel"),b==="stylesheet"&&a.hasAttribute("data-precedence"))break;if(b!==v.rel||a.getAttribute("href")!==(v.href==null||v.href===""?null:v.href)||a.getAttribute("crossorigin")!==(v.crossOrigin==null?null:v.crossOrigin)||a.getAttribute("title")!==(v.title==null?null:v.title))break;return a;case"style":if(a.hasAttribute("data-precedence"))break;return a;case"script":if(b=a.getAttribute("src"),(b!==(v.src==null?null:v.src)||a.getAttribute("type")!==(v.type==null?null:v.type)||a.getAttribute("crossorigin")!==(v.crossOrigin==null?null:v.crossOrigin))&&b&&a.hasAttribute("async")&&!a.hasAttribute("itemprop"))break;return a;default:return a}}else if(o==="input"&&a.type==="hidden"){var b=v.name==null?null:""+v.name;if(v.type==="hidden"&&a.getAttribute("name")===b)return a}else return a;if(a=ks(a.nextSibling),a===null)break}return null}function _I(a,o,u){if(o==="")return null;for(;a.nodeType!==3;)if((a.nodeType!==1||a.nodeName!=="INPUT"||a.type!=="hidden")&&!u||(a=ks(a.nextSibling),a===null))return null;return a}function gj(a,o){for(;a.nodeType!==8;)if((a.nodeType!==1||a.nodeName!=="INPUT"||a.type!=="hidden")&&!o||(a=ks(a.nextSibling),a===null))return null;return a}function Mp(a){return a.data==="$?"||a.data==="$~"}function Rp(a){return a.data==="$!"||a.data==="$?"&&a.ownerDocument.readyState!=="loading"}function II(a,o){var u=a.ownerDocument;if(a.data==="$~")a._reactRetry=o;else if(a.data!=="$?"||u.readyState!=="loading")o();else{var f=function(){o(),u.removeEventListener("DOMContentLoaded",f)};u.addEventListener("DOMContentLoaded",f),a._reactRetry=f}}function ks(a){for(;a!=null;a=a.nextSibling){var o=a.nodeType;if(o===1||o===3)break;if(o===8){if(o=a.data,o==="$"||o==="$!"||o==="$?"||o==="$~"||o==="&"||o==="F!"||o==="F")break;if(o==="/$"||o==="/&")return null}}return a}var _p=null;function vj(a){a=a.nextSibling;for(var o=0;a;){if(a.nodeType===8){var u=a.data;if(u==="/$"||u==="/&"){if(o===0)return ks(a.nextSibling);o--}else u!=="$"&&u!=="$!"&&u!=="$?"&&u!=="$~"&&u!=="&"||o++}a=a.nextSibling}return null}function yj(a){a=a.previousSibling;for(var o=0;a;){if(a.nodeType===8){var u=a.data;if(u==="$"||u==="$!"||u==="$?"||u==="$~"||u==="&"){if(o===0)return a;o--}else u!=="/$"&&u!=="/&"||o++}a=a.previousSibling}return null}function xj(a,o,u){switch(o=ld(u),a){case"html":if(a=o.documentElement,!a)throw Error(s(452));return a;case"head":if(a=o.head,!a)throw Error(s(453));return a;case"body":if(a=o.body,!a)throw Error(s(454));return a;default:throw Error(s(451))}}function Xl(a){for(var o=a.attributes;o.length;)a.removeAttributeNode(o[0]);Oh(a)}var Es=new Map,bj=new Set;function cd(a){return typeof a.getRootNode=="function"?a.getRootNode():a.nodeType===9?a:a.ownerDocument}var Oa=F.d;F.d={f:OI,r:DI,D:PI,C:zI,L:LI,m:$I,X:BI,S:UI,M:VI};function OI(){var a=Oa.f(),o=ed();return a||o}function DI(a){var o=Oi(a);o!==null&&o.tag===5&&o.type==="form"?z0(o):Oa.r(a)}var ho=typeof document>"u"?null:document;function wj(a,o,u){var f=ho;if(f&&typeof o=="string"&&o){var v=ys(o);v='link[rel="'+a+'"][href="'+v+'"]',typeof u=="string"&&(v+='[crossorigin="'+u+'"]'),bj.has(v)||(bj.add(v),a={rel:a,crossOrigin:u,href:o},f.querySelector(v)===null&&(o=f.createElement("link"),Tn(o,"link",a),wn(o),f.head.appendChild(o)))}}function PI(a){Oa.D(a),wj("dns-prefetch",a,null)}function zI(a,o){Oa.C(a,o),wj("preconnect",a,o)}function LI(a,o,u){Oa.L(a,o,u);var f=ho;if(f&&a&&o){var v='link[rel="preload"][as="'+ys(o)+'"]';o==="image"&&u&&u.imageSrcSet?(v+='[imagesrcset="'+ys(u.imageSrcSet)+'"]',typeof u.imageSizes=="string"&&(v+='[imagesizes="'+ys(u.imageSizes)+'"]')):v+='[href="'+ys(a)+'"]';var b=v;switch(o){case"style":b=mo(a);break;case"script":b=po(a)}Es.has(b)||(a=y({rel:"preload",href:o==="image"&&u&&u.imageSrcSet?void 0:a,as:o},u),Es.set(b,a),f.querySelector(v)!==null||o==="style"&&f.querySelector(Jl(b))||o==="script"&&f.querySelector(Ql(b))||(o=f.createElement("link"),Tn(o,"link",a),wn(o),f.head.appendChild(o)))}}function $I(a,o){Oa.m(a,o);var u=ho;if(u&&a){var f=o&&typeof o.as=="string"?o.as:"script",v='link[rel="modulepreload"][as="'+ys(f)+'"][href="'+ys(a)+'"]',b=v;switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":b=po(a)}if(!Es.has(b)&&(a=y({rel:"modulepreload",href:a},o),Es.set(b,a),u.querySelector(v)===null)){switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(u.querySelector(Ql(b)))return}f=u.createElement("link"),Tn(f,"link",a),wn(f),u.head.appendChild(f)}}}function UI(a,o,u){Oa.S(a,o,u);var f=ho;if(f&&a){var v=Di(f).hoistableStyles,b=mo(a);o=o||"default";var T=v.get(b);if(!T){var P={loading:0,preload:null};if(T=f.querySelector(Jl(b)))P.loading=5;else{a=y({rel:"stylesheet",href:a,"data-precedence":o},u),(u=Es.get(b))&&Ip(a,u);var Z=T=f.createElement("link");wn(Z),Tn(Z,"link",a),Z._p=new Promise(function(se,fe){Z.onload=se,Z.onerror=fe}),Z.addEventListener("load",function(){P.loading|=1}),Z.addEventListener("error",function(){P.loading|=2}),P.loading|=4,ud(T,o,f)}T={type:"stylesheet",instance:T,count:1,state:P},v.set(b,T)}}}function BI(a,o){Oa.X(a,o);var u=ho;if(u&&a){var f=Di(u).hoistableScripts,v=po(a),b=f.get(v);b||(b=u.querySelector(Ql(v)),b||(a=y({src:a,async:!0},o),(o=Es.get(v))&&Op(a,o),b=u.createElement("script"),wn(b),Tn(b,"link",a),u.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},f.set(v,b))}}function VI(a,o){Oa.M(a,o);var u=ho;if(u&&a){var f=Di(u).hoistableScripts,v=po(a),b=f.get(v);b||(b=u.querySelector(Ql(v)),b||(a=y({src:a,async:!0,type:"module"},o),(o=Es.get(v))&&Op(a,o),b=u.createElement("script"),wn(b),Tn(b,"link",a),u.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},f.set(v,b))}}function jj(a,o,u,f){var v=(v=ee.current)?cd(v):null;if(!v)throw Error(s(446));switch(a){case"meta":case"title":return null;case"style":return typeof u.precedence=="string"&&typeof u.href=="string"?(o=mo(u.href),u=Di(v).hoistableStyles,f=u.get(o),f||(f={type:"style",instance:null,count:0,state:null},u.set(o,f)),f):{type:"void",instance:null,count:0,state:null};case"link":if(u.rel==="stylesheet"&&typeof u.href=="string"&&typeof u.precedence=="string"){a=mo(u.href);var b=Di(v).hoistableStyles,T=b.get(a);if(T||(v=v.ownerDocument||v,T={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},b.set(a,T),(b=v.querySelector(Jl(a)))&&!b._p&&(T.instance=b,T.state.loading=5),Es.has(a)||(u={rel:"preload",as:"style",href:u.href,crossOrigin:u.crossOrigin,integrity:u.integrity,media:u.media,hrefLang:u.hrefLang,referrerPolicy:u.referrerPolicy},Es.set(a,u),b||FI(v,a,u,T.state))),o&&f===null)throw Error(s(528,""));return T}if(o&&f!==null)throw Error(s(529,""));return null;case"script":return o=u.async,u=u.src,typeof u=="string"&&o&&typeof o!="function"&&typeof o!="symbol"?(o=po(u),u=Di(v).hoistableScripts,f=u.get(o),f||(f={type:"script",instance:null,count:0,state:null},u.set(o,f)),f):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,a))}}function mo(a){return'href="'+ys(a)+'"'}function Jl(a){return'link[rel="stylesheet"]['+a+"]"}function Nj(a){return y({},a,{"data-precedence":a.precedence,precedence:null})}function FI(a,o,u,f){a.querySelector('link[rel="preload"][as="style"]['+o+"]")?f.loading=1:(o=a.createElement("link"),f.preload=o,o.addEventListener("load",function(){return f.loading|=1}),o.addEventListener("error",function(){return f.loading|=2}),Tn(o,"link",u),wn(o),a.head.appendChild(o))}function po(a){return'[src="'+ys(a)+'"]'}function Ql(a){return"script[async]"+a}function Sj(a,o,u){if(o.count++,o.instance===null)switch(o.type){case"style":var f=a.querySelector('style[data-href~="'+ys(u.href)+'"]');if(f)return o.instance=f,wn(f),f;var v=y({},u,{"data-href":u.href,"data-precedence":u.precedence,href:null,precedence:null});return f=(a.ownerDocument||a).createElement("style"),wn(f),Tn(f,"style",v),ud(f,u.precedence,a),o.instance=f;case"stylesheet":v=mo(u.href);var b=a.querySelector(Jl(v));if(b)return o.state.loading|=4,o.instance=b,wn(b),b;f=Nj(u),(v=Es.get(v))&&Ip(f,v),b=(a.ownerDocument||a).createElement("link"),wn(b);var T=b;return T._p=new Promise(function(P,Z){T.onload=P,T.onerror=Z}),Tn(b,"link",f),o.state.loading|=4,ud(b,u.precedence,a),o.instance=b;case"script":return b=po(u.src),(v=a.querySelector(Ql(b)))?(o.instance=v,wn(v),v):(f=u,(v=Es.get(b))&&(f=y({},u),Op(f,v)),a=a.ownerDocument||a,v=a.createElement("script"),wn(v),Tn(v,"link",f),a.head.appendChild(v),o.instance=v);case"void":return null;default:throw Error(s(443,o.type))}else o.type==="stylesheet"&&(o.state.loading&4)===0&&(f=o.instance,o.state.loading|=4,ud(f,u.precedence,a));return o.instance}function ud(a,o,u){for(var f=u.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),v=f.length?f[f.length-1]:null,b=v,T=0;T<f.length;T++){var P=f[T];if(P.dataset.precedence===o)b=P;else if(b!==v)break}b?b.parentNode.insertBefore(a,b.nextSibling):(o=u.nodeType===9?u.head:u,o.insertBefore(a,o.firstChild))}function Ip(a,o){a.crossOrigin==null&&(a.crossOrigin=o.crossOrigin),a.referrerPolicy==null&&(a.referrerPolicy=o.referrerPolicy),a.title==null&&(a.title=o.title)}function Op(a,o){a.crossOrigin==null&&(a.crossOrigin=o.crossOrigin),a.referrerPolicy==null&&(a.referrerPolicy=o.referrerPolicy),a.integrity==null&&(a.integrity=o.integrity)}var dd=null;function kj(a,o,u){if(dd===null){var f=new Map,v=dd=new Map;v.set(u,f)}else v=dd,f=v.get(u),f||(f=new Map,v.set(u,f));if(f.has(a))return f;for(f.set(a,null),u=u.getElementsByTagName(a),v=0;v<u.length;v++){var b=u[v];if(!(b[pl]||b[xt]||a==="link"&&b.getAttribute("rel")==="stylesheet")&&b.namespaceURI!=="http://www.w3.org/2000/svg"){var T=b.getAttribute(o)||"";T=a+T;var P=f.get(T);P?P.push(b):f.set(T,[b])}}return f}function Ej(a,o,u){a=a.ownerDocument||a,a.head.insertBefore(u,o==="title"?a.querySelector("head > title"):null)}function HI(a,o,u){if(u===1||o.itemProp!=null)return!1;switch(a){case"meta":case"title":return!0;case"style":if(typeof o.precedence!="string"||typeof o.href!="string"||o.href==="")break;return!0;case"link":if(typeof o.rel!="string"||typeof o.href!="string"||o.href===""||o.onLoad||o.onError)break;return o.rel==="stylesheet"?(a=o.disabled,typeof o.precedence=="string"&&a==null):!0;case"script":if(o.async&&typeof o.async!="function"&&typeof o.async!="symbol"&&!o.onLoad&&!o.onError&&o.src&&typeof o.src=="string")return!0}return!1}function Cj(a){return!(a.type==="stylesheet"&&(a.state.loading&3)===0)}function qI(a,o,u,f){if(u.type==="stylesheet"&&(typeof f.media!="string"||matchMedia(f.media).matches!==!1)&&(u.state.loading&4)===0){if(u.instance===null){var v=mo(f.href),b=o.querySelector(Jl(v));if(b){o=b._p,o!==null&&typeof o=="object"&&typeof o.then=="function"&&(a.count++,a=fd.bind(a),o.then(a,a)),u.state.loading|=4,u.instance=b,wn(b);return}b=o.ownerDocument||o,f=Nj(f),(v=Es.get(v))&&Ip(f,v),b=b.createElement("link"),wn(b);var T=b;T._p=new Promise(function(P,Z){T.onload=P,T.onerror=Z}),Tn(b,"link",f),u.instance=b}a.stylesheets===null&&(a.stylesheets=new Map),a.stylesheets.set(u,o),(o=u.state.preload)&&(u.state.loading&3)===0&&(a.count++,u=fd.bind(a),o.addEventListener("load",u),o.addEventListener("error",u))}}var Dp=0;function ZI(a,o){return a.stylesheets&&a.count===0&&md(a,a.stylesheets),0<a.count||0<a.imgCount?function(u){var f=setTimeout(function(){if(a.stylesheets&&md(a,a.stylesheets),a.unsuspend){var b=a.unsuspend;a.unsuspend=null,b()}},6e4+o);0<a.imgBytes&&Dp===0&&(Dp=62500*EI());var v=setTimeout(function(){if(a.waitingForImages=!1,a.count===0&&(a.stylesheets&&md(a,a.stylesheets),a.unsuspend)){var b=a.unsuspend;a.unsuspend=null,b()}},(a.imgBytes>Dp?50:800)+o);return a.unsuspend=u,function(){a.unsuspend=null,clearTimeout(f),clearTimeout(v)}}:null}function fd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)md(this,this.stylesheets);else if(this.unsuspend){var a=this.unsuspend;this.unsuspend=null,a()}}}var hd=null;function md(a,o){a.stylesheets=null,a.unsuspend!==null&&(a.count++,hd=new Map,o.forEach(WI,a),hd=null,fd.call(a))}function WI(a,o){if(!(o.state.loading&4)){var u=hd.get(a);if(u)var f=u.get(null);else{u=new Map,hd.set(a,u);for(var v=a.querySelectorAll("link[data-precedence],style[data-precedence]"),b=0;b<v.length;b++){var T=v[b];(T.nodeName==="LINK"||T.getAttribute("media")!=="not all")&&(u.set(T.dataset.precedence,T),f=T)}f&&u.set(null,f)}v=o.instance,T=v.getAttribute("data-precedence"),b=u.get(T)||f,b===f&&u.set(null,v),u.set(T,v),this.count++,f=fd.bind(this),v.addEventListener("load",f),v.addEventListener("error",f),b?b.parentNode.insertBefore(v,b.nextSibling):(a=a.nodeType===9?a.head:a,a.insertBefore(v,a.firstChild)),o.state.loading|=4}}var ec={$$typeof:S,Provider:null,Consumer:null,_currentValue:H,_currentValue2:H,_threadCount:0};function YI(a,o,u,f,v,b,T,P,Z){this.tag=1,this.containerInfo=a,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=Q(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Q(0),this.hiddenUpdates=Q(null),this.identifierPrefix=f,this.onUncaughtError=v,this.onCaughtError=b,this.onRecoverableError=T,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Z,this.incompleteTransitions=new Map}function Aj(a,o,u,f,v,b,T,P,Z,se,fe,ge){return a=new YI(a,o,u,T,Z,se,fe,ge,P),o=1,b===!0&&(o|=24),b=rs(3,null,null,o),a.current=b,b.stateNode=a,o=mm(),o.refCount++,a.pooledCache=o,o.refCount++,b.memoizedState={element:f,isDehydrated:u,cache:o},ym(b),a}function Tj(a){return a?(a=qi,a):qi}function Mj(a,o,u,f,v,b){v=Tj(v),f.context===null?f.context=v:f.pendingContext=v,f=Ka(o),f.payload={element:u},b=b===void 0?null:b,b!==null&&(f.callback=b),u=Xa(a,f,o),u!==null&&(Jn(u,a,o),_l(u,a,o))}function Rj(a,o){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var u=a.retryLane;a.retryLane=u!==0&&u<o?u:o}}function Pp(a,o){Rj(a,o),(a=a.alternate)&&Rj(a,o)}function _j(a){if(a.tag===13||a.tag===31){var o=Wr(a,67108864);o!==null&&Jn(o,a,67108864),Pp(a,67108864)}}function Ij(a){if(a.tag===13||a.tag===31){var o=us();o=At(o);var u=Wr(a,o);u!==null&&Jn(u,a,o),Pp(a,o)}}var pd=!0;function GI(a,o,u,f){var v=L.T;L.T=null;var b=F.p;try{F.p=2,zp(a,o,u,f)}finally{F.p=b,L.T=v}}function KI(a,o,u,f){var v=L.T;L.T=null;var b=F.p;try{F.p=8,zp(a,o,u,f)}finally{F.p=b,L.T=v}}function zp(a,o,u,f){if(pd){var v=Lp(f);if(v===null)Np(a,o,f,gd,u),Dj(a,f);else if(JI(v,a,o,u,f))f.stopPropagation();else if(Dj(a,f),o&4&&-1<XI.indexOf(a)){for(;v!==null;){var b=Oi(v);if(b!==null)switch(b.tag){case 3:if(b=b.stateNode,b.current.memoizedState.isDehydrated){var T=_e(b.pendingLanes);if(T!==0){var P=b;for(P.pendingLanes|=2,P.entangledLanes|=2;T;){var Z=1<<31-at(T);P.entanglements[1]|=Z,T&=~Z}ea(b),(Nt&6)===0&&(Ju=we()+500,Yl(0))}}break;case 31:case 13:P=Wr(b,2),P!==null&&Jn(P,b,2),ed(),Pp(b,2)}if(b=Lp(f),b===null&&Np(a,o,f,gd,u),b===v)break;v=b}v!==null&&f.stopPropagation()}else Np(a,o,f,null,u)}}function Lp(a){return a=Uh(a),$p(a)}var gd=null;function $p(a){if(gd=null,a=Ii(a),a!==null){var o=l(a);if(o===null)a=null;else{var u=o.tag;if(u===13){if(a=c(o),a!==null)return a;a=null}else if(u===31){if(a=d(o),a!==null)return a;a=null}else if(u===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;a=null}else o!==a&&(a=null)}}return gd=a,null}function Oj(a){switch(a){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(Se()){case He:return 2;case et:return 8;case Be:case St:return 32;case Dt:return 268435456;default:return 32}default:return 32}}var Up=!1,lr=null,cr=null,ur=null,tc=new Map,nc=new Map,dr=[],XI="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 Dj(a,o){switch(a){case"focusin":case"focusout":lr=null;break;case"dragenter":case"dragleave":cr=null;break;case"mouseover":case"mouseout":ur=null;break;case"pointerover":case"pointerout":tc.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":nc.delete(o.pointerId)}}function sc(a,o,u,f,v,b){return a===null||a.nativeEvent!==b?(a={blockedOn:o,domEventName:u,eventSystemFlags:f,nativeEvent:b,targetContainers:[v]},o!==null&&(o=Oi(o),o!==null&&_j(o)),a):(a.eventSystemFlags|=f,o=a.targetContainers,v!==null&&o.indexOf(v)===-1&&o.push(v),a)}function JI(a,o,u,f,v){switch(o){case"focusin":return lr=sc(lr,a,o,u,f,v),!0;case"dragenter":return cr=sc(cr,a,o,u,f,v),!0;case"mouseover":return ur=sc(ur,a,o,u,f,v),!0;case"pointerover":var b=v.pointerId;return tc.set(b,sc(tc.get(b)||null,a,o,u,f,v)),!0;case"gotpointercapture":return b=v.pointerId,nc.set(b,sc(nc.get(b)||null,a,o,u,f,v)),!0}return!1}function Pj(a){var o=Ii(a.target);if(o!==null){var u=l(o);if(u!==null){if(o=u.tag,o===13){if(o=c(u),o!==null){a.blockedOn=o,kn(a.priority,function(){Ij(u)});return}}else if(o===31){if(o=d(u),o!==null){a.blockedOn=o,kn(a.priority,function(){Ij(u)});return}}else if(o===3&&u.stateNode.current.memoizedState.isDehydrated){a.blockedOn=u.tag===3?u.stateNode.containerInfo:null;return}}}a.blockedOn=null}function vd(a){if(a.blockedOn!==null)return!1;for(var o=a.targetContainers;0<o.length;){var u=Lp(a.nativeEvent);if(u===null){u=a.nativeEvent;var f=new u.constructor(u.type,u);$h=f,u.target.dispatchEvent(f),$h=null}else return o=Oi(u),o!==null&&_j(o),a.blockedOn=u,!1;o.shift()}return!0}function zj(a,o,u){vd(a)&&u.delete(o)}function QI(){Up=!1,lr!==null&&vd(lr)&&(lr=null),cr!==null&&vd(cr)&&(cr=null),ur!==null&&vd(ur)&&(ur=null),tc.forEach(zj),nc.forEach(zj)}function yd(a,o){a.blockedOn===o&&(a.blockedOn=null,Up||(Up=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,QI)))}var xd=null;function Lj(a){xd!==a&&(xd=a,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){xd===a&&(xd=null);for(var o=0;o<a.length;o+=3){var u=a[o],f=a[o+1],v=a[o+2];if(typeof f!="function"){if($p(f||u)===null)continue;break}var b=Oi(u);b!==null&&(a.splice(o,3),o-=3,Lm(b,{pending:!0,data:v,method:u.method,action:f},f,v))}}))}function go(a){function o(Z){return yd(Z,a)}lr!==null&&yd(lr,a),cr!==null&&yd(cr,a),ur!==null&&yd(ur,a),tc.forEach(o),nc.forEach(o);for(var u=0;u<dr.length;u++){var f=dr[u];f.blockedOn===a&&(f.blockedOn=null)}for(;0<dr.length&&(u=dr[0],u.blockedOn===null);)Pj(u),u.blockedOn===null&&dr.shift();if(u=(a.ownerDocument||a).$$reactFormReplay,u!=null)for(f=0;f<u.length;f+=3){var v=u[f],b=u[f+1],T=v[Zn]||null;if(typeof b=="function")T||Lj(u);else if(T){var P=null;if(b&&b.hasAttribute("formAction")){if(v=b,T=b[Zn]||null)P=T.formAction;else if($p(v)!==null)continue}else P=T.action;typeof P=="function"?u[f+1]=P:(u.splice(f,3),f-=3),Lj(u)}}}function $j(){function a(b){b.canIntercept&&b.info==="react-transition"&&b.intercept({handler:function(){return new Promise(function(T){return v=T})},focusReset:"manual",scroll:"manual"})}function o(){v!==null&&(v(),v=null),f||setTimeout(u,20)}function u(){if(!f&&!navigation.transition){var b=navigation.currentEntry;b&&b.url!=null&&navigation.navigate(b.url,{state:b.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var f=!1,v=null;return navigation.addEventListener("navigate",a),navigation.addEventListener("navigatesuccess",o),navigation.addEventListener("navigateerror",o),setTimeout(u,100),function(){f=!0,navigation.removeEventListener("navigate",a),navigation.removeEventListener("navigatesuccess",o),navigation.removeEventListener("navigateerror",o),v!==null&&(v(),v=null)}}}function Bp(a){this._internalRoot=a}bd.prototype.render=Bp.prototype.render=function(a){var o=this._internalRoot;if(o===null)throw Error(s(409));var u=o.current,f=us();Mj(u,f,a,o,null,null)},bd.prototype.unmount=Bp.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var o=a.containerInfo;Mj(a.current,2,null,a,null,null),ed(),o[_i]=null}};function bd(a){this._internalRoot=a}bd.prototype.unstable_scheduleHydration=function(a){if(a){var o=Sn();a={blockedOn:null,target:a,priority:o};for(var u=0;u<dr.length&&o!==0&&o<dr[u].priority;u++);dr.splice(u,0,a),u===0&&Pj(a)}};var Uj=t.version;if(Uj!=="19.2.3")throw Error(s(527,Uj,"19.2.3"));F.findDOMNode=function(a){var o=a._reactInternals;if(o===void 0)throw typeof a.render=="function"?Error(s(188)):(a=Object.keys(a).join(","),Error(s(268,a)));return a=m(o),a=a!==null?p(a):null,a=a===null?null:a.stateNode,a};var eO={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:L,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var wd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!wd.isDisabled&&wd.supportsFiber)try{Oe=wd.inject(eO),Te=wd}catch{}}return rc.createRoot=function(a,o){if(!i(a))throw Error(s(299));var u=!1,f="",v=W0,b=Y0,T=G0;return o!=null&&(o.unstable_strictMode===!0&&(u=!0),o.identifierPrefix!==void 0&&(f=o.identifierPrefix),o.onUncaughtError!==void 0&&(v=o.onUncaughtError),o.onCaughtError!==void 0&&(b=o.onCaughtError),o.onRecoverableError!==void 0&&(T=o.onRecoverableError)),o=Aj(a,1,!1,null,null,u,f,null,v,b,T,$j),a[_i]=o.current,jp(a),new Bp(o)},rc.hydrateRoot=function(a,o,u){if(!i(a))throw Error(s(299));var f=!1,v="",b=W0,T=Y0,P=G0,Z=null;return u!=null&&(u.unstable_strictMode===!0&&(f=!0),u.identifierPrefix!==void 0&&(v=u.identifierPrefix),u.onUncaughtError!==void 0&&(b=u.onUncaughtError),u.onCaughtError!==void 0&&(T=u.onCaughtError),u.onRecoverableError!==void 0&&(P=u.onRecoverableError),u.formState!==void 0&&(Z=u.formState)),o=Aj(a,1,!0,o,u??null,f,v,Z,b,T,P,$j),o.context=Tj(null),u=o.current,f=us(),f=At(f),v=Ka(f),v.callback=null,Xa(u,v,f),u=f,o.current.lanes=u,ye(o,u),ea(o),a[_i]=o.current,jp(a),new bd(o)},rc.version="19.2.3",rc}var Kj;function uO(){if(Kj)return Hp.exports;Kj=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(),Hp.exports=cO(),Hp.exports}var dO=uO();const jE=(...e)=>e.filter((t,n,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===n).join(" ").trim();const fO=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const hO=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,s)=>s?s.toUpperCase():n.toLowerCase());const Xj=e=>{const t=hO(e);return t.charAt(0).toUpperCase()+t.slice(1)};var mO={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 pO=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const gO=g.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:i="",children:l,iconNode:c,...d},h)=>g.createElement("svg",{ref:h,...mO,width:t,height:t,stroke:e,strokeWidth:s?Number(n)*24/Number(t):n,className:jE("lucide",i),...!l&&!pO(d)&&{"aria-hidden":"true"},...d},[...c.map(([m,p])=>g.createElement(m,p)),...Array.isArray(l)?l:[l]]));const Ot=(e,t)=>{const n=g.forwardRef(({className:s,...i},l)=>g.createElement(gO,{ref:l,iconNode:t,className:jE(`lucide-${fO(Xj(e))}`,`lucide-${e}`,s),...i}));return n.displayName=Xj(e),n};const vO=[["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"}]],Jj=Ot("bot",vO);const yO=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],xO=Ot("check",yO);const bO=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],xy=Ot("chevron-down",bO);const wO=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],jO=Ot("chevron-right",wO);const NO=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],NE=Ot("chevron-up",NO);const SO=[["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"}]],SE=Ot("compass",SO);const kO=[["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"}]],EO=Ot("copy",kO);const CO=[["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"}]],AO=Ot("crosshair",CO);const TO=[["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"}]],MO=Ot("external-link",TO);const RO=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],zo=Ot("loader-circle",RO);const _O=[["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"}]],IO=Ot("map",_O);const OO=[["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"}]],DO=Ot("maximize-2",OO);const PO=[["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"}]],zO=Ot("mic",PO);const LO=[["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"}]],$O=Ot("pin-off",LO);const UO=[["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"}]],BO=Ot("pin",UO);const VO=[["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"}]],FO=Ot("radio",VO);const HO=[["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"}]],by=Ot("refresh-cw",HO);const qO=[["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"}]],Qj=Ot("rocket",qO);const ZO=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],WO=Ot("search",ZO);const YO=[["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"}]],ih=Ot("settings",YO);const GO=[["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"}]],KO=Ot("sliders-horizontal",GO);const XO=[["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"}]],JO=Ot("sparkles",XO);const QO=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],e1=Ot("square",QO);const e5=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],t5=Ot("terminal",e5);const n5=[["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"}]],s5=Ot("volume-2",n5);const a5=[["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"}]],r5=Ot("volume-x",a5);const i5=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],o5=Ot("x",i5),l5=g.createContext(null);function c5(){return g.useContext(l5)}function u5(e){const t=c5();return!t||e.startsWith("inst:")||e.startsWith("hudson.ws.")?e:`inst:${t.instanceId}:${e}`}function d5(e){try{const t=localStorage.getItem(e);if(t)return JSON.parse(t)}catch{}}function f5(e,t){try{localStorage.setItem(e,JSON.stringify(t)),window.dispatchEvent(new CustomEvent("hudson:saved",{detail:{key:e}}))}catch{}}const h5=()=>()=>{},m5=()=>!0,p5=()=>!1;function g5(){return g.useSyncExternalStore(h5,m5,p5)}function Hs(e,t){const n=g5(),s=u5(e),[i,l]=g.useState(t),c=g.useRef(!1);if(n&&!c.current){c.current=!0;const d=d5(s);d!==void 0&&l(d)}return g.useEffect(()=>{n&&f5(s,i)},[s,i,n]),[i,l]}var kE="vercel.ai.error",v5=Symbol.for(kE),t1,n1,fa=class EE extends(n1=Error,t1=v5,n1){constructor({name:t,message:n,cause:s}){super(n),this[t1]=!0,this.name=t,this.cause=s}static isInstance(t){return EE.hasMarker(t,kE)}static hasMarker(t,n){const s=Symbol.for(n);return t!=null&&typeof t=="object"&&s in t&&typeof t[s]=="boolean"&&t[s]===!0}};function CE(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var AE="AI_InvalidArgumentError",TE=`vercel.ai.error.${AE}`,y5=Symbol.for(TE),s1,a1,x5=class extends(a1=fa,s1=y5,a1){constructor({message:e,cause:t,argument:n}){super({name:AE,message:e,cause:t}),this[s1]=!0,this.argument=n}static isInstance(e){return fa.hasMarker(e,TE)}},ME="AI_JSONParseError",RE=`vercel.ai.error.${ME}`,b5=Symbol.for(RE),r1,i1,o1=class extends(i1=fa,r1=b5,i1){constructor({text:e,cause:t}){super({name:ME,message:`JSON parsing failed: Text: ${e}.
|
|
10
|
-
Error message: ${CE(t)}`,cause:t}),this[r1]=!0,this.text=e}static isInstance(e){return fa.hasMarker(e,RE)}},_E="AI_TypeValidationError",IE=`vercel.ai.error.${_E}`,w5=Symbol.for(IE),l1,c1,Qo=class rv extends(c1=fa,l1=w5,c1){constructor({value:t,cause:n,context:s}){let i="Type validation failed";if(s?.field&&(i+=` for ${s.field}`),s?.entityName||s?.entityId){i+=" (";const l=[];s.entityName&&l.push(s.entityName),s.entityId&&l.push(`id: "${s.entityId}"`),i+=l.join(", "),i+=")"}super({name:_E,message:`${i}: Value: ${JSON.stringify(t)}.
|
|
11
|
-
Error message: ${CE(n)}`,cause:n}),this[l1]=!0,this.value=t,this.context=s}static isInstance(t){return fa.hasMarker(t,IE)}static wrap({value:t,cause:n,context:s}){var i,l,c;return rv.isInstance(n)&&n.value===t&&((i=n.context)==null?void 0:i.field)===s?.field&&((l=n.context)==null?void 0:l.entityName)===s?.entityName&&((c=n.context)==null?void 0:c.entityId)===s?.entityId?n:new rv({value:t,cause:n,context:s})}};function he(e,t,n){function s(d,h){if(d._zod||Object.defineProperty(d,"_zod",{value:{def:h,constr:c,traits:new Set},enumerable:!1}),d._zod.traits.has(e))return;d._zod.traits.add(e),t(d,h);const m=c.prototype,p=Object.keys(m);for(let y=0;y<p.length;y++){const x=p[y];x in d||(d[x]=m[x].bind(d))}}const i=n?.Parent??Object;class l extends i{}Object.defineProperty(l,"name",{value:e});function c(d){var h;const m=n?.Parent?new l:this;s(m,d),(h=m._zod).deferred??(h.deferred=[]);for(const p of m._zod.deferred)p();return m}return Object.defineProperty(c,"init",{value:s}),Object.defineProperty(c,Symbol.hasInstance,{value:d=>n?.Parent&&d instanceof n.Parent?!0:d?._zod?.traits?.has(e)}),Object.defineProperty(c,"name",{value:e}),c}class Zo extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class OE extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const DE={};function Tr(e){return DE}function PE(e){const t=Object.values(e).filter(s=>typeof s=="number");return Object.entries(e).filter(([s,i])=>t.indexOf(+s)===-1).map(([s,i])=>i)}function iv(e,t){return typeof t=="bigint"?t.toString():t}function oh(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function wy(e){return e==null}function jy(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function j5(e,t){const n=(e.toString().split(".")[1]||"").length,s=t.toString();let i=(s.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(s)){const h=s.match(/\d?e-(\d?)/);h?.[1]&&(i=Number.parseInt(h[1]))}const l=n>i?n:i,c=Number.parseInt(e.toFixed(l).replace(".","")),d=Number.parseInt(t.toFixed(l).replace(".",""));return c%d/10**l}const u1=Symbol("evaluating");function pt(e,t,n){let s;Object.defineProperty(e,t,{get(){if(s!==u1)return s===void 0&&(s=u1,s=n()),s},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Ai(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Dr(...e){const t={};for(const n of e){const s=Object.getOwnPropertyDescriptors(n);Object.assign(t,s)}return Object.defineProperties({},t)}function d1(e){return JSON.stringify(e)}function N5(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const zE="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function _c(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const S5=oh(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function el(e){if(_c(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(_c(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function LE(e){return el(e)?{...e}:Array.isArray(e)?[...e]:e}const k5=new Set(["string","number","symbol"]);function tl(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Pr(e,t,n){const s=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(s._zod.parent=e),s}function Ue(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 E5(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const C5={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 A5(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const l=Dr(e._zod.def,{get shape(){const c={};for(const d in t){if(!(d in n.shape))throw new Error(`Unrecognized key: "${d}"`);t[d]&&(c[d]=n.shape[d])}return Ai(this,"shape",c),c},checks:[]});return Pr(e,l)}function T5(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const l=Dr(e._zod.def,{get shape(){const c={...e._zod.def.shape};for(const d in t){if(!(d in n.shape))throw new Error(`Unrecognized key: "${d}"`);t[d]&&delete c[d]}return Ai(this,"shape",c),c},checks:[]});return Pr(e,l)}function M5(e,t){if(!el(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const l=e._zod.def.shape;for(const c in t)if(Object.getOwnPropertyDescriptor(l,c)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=Dr(e._zod.def,{get shape(){const l={...e._zod.def.shape,...t};return Ai(this,"shape",l),l}});return Pr(e,i)}function R5(e,t){if(!el(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Dr(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return Ai(this,"shape",s),s}});return Pr(e,n)}function _5(e,t){const n=Dr(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t._zod.def.shape};return Ai(this,"shape",s),s},get catchall(){return t._zod.def.catchall},checks:[]});return Pr(e,n)}function I5(e,t,n){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const c=Dr(t._zod.def,{get shape(){const d=t._zod.def.shape,h={...d};if(n)for(const m in n){if(!(m in d))throw new Error(`Unrecognized key: "${m}"`);n[m]&&(h[m]=e?new e({type:"optional",innerType:d[m]}):d[m])}else for(const m in d)h[m]=e?new e({type:"optional",innerType:d[m]}):d[m];return Ai(this,"shape",h),h},checks:[]});return Pr(t,c)}function O5(e,t,n){const s=Dr(t._zod.def,{get shape(){const i=t._zod.def.shape,l={...i};if(n)for(const c in n){if(!(c in l))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(l[c]=new e({type:"nonoptional",innerType:i[c]}))}else for(const c in i)l[c]=new e({type:"nonoptional",innerType:i[c]});return Ai(this,"shape",l),l}});return Pr(t,s)}function Lo(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 $o(e,t){return t.map(n=>{var s;return(s=n).path??(s.path=[]),n.path.unshift(e),n})}function jd(e){return typeof e=="string"?e:e?.message}function Mr(e,t,n){const s={...e,path:e.path??[]};if(!e.message){const i=jd(e.inst?._zod.def?.error?.(e))??jd(t?.error?.(e))??jd(n.customError?.(e))??jd(n.localeError?.(e))??"Invalid input";s.message=i}return delete s.inst,delete s.continue,t?.reportInput||delete s.input,s}function Ny(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ic(...e){const[t,n,s]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:s}:{...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,iv,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},UE=he("$ZodError",$E),BE=he("$ZodError",$E,{Parent:Error});function D5(e,t=n=>n.message){const n={},s=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):s.push(t(i));return{formErrors:s,fieldErrors:n}}function P5(e,t=n=>n.message){const n={_errors:[]},s=i=>{for(const l of i.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(c=>s({issues:c}));else if(l.code==="invalid_key")s({issues:l.issues});else if(l.code==="invalid_element")s({issues:l.issues});else if(l.path.length===0)n._errors.push(t(l));else{let c=n,d=0;for(;d<l.path.length;){const h=l.path[d];d===l.path.length-1?(c[h]=c[h]||{_errors:[]},c[h]._errors.push(t(l))):c[h]=c[h]||{_errors:[]},c=c[h],d++}}};return s(e),n}const Sy=e=>(t,n,s,i)=>{const l=s?Object.assign(s,{async:!1}):{async:!1},c=t._zod.run({value:n,issues:[]},l);if(c instanceof Promise)throw new Zo;if(c.issues.length){const d=new(i?.Err??e)(c.issues.map(h=>Mr(h,l,Tr())));throw zE(d,i?.callee),d}return c.value},ky=e=>async(t,n,s,i)=>{const l=s?Object.assign(s,{async:!0}):{async:!0};let c=t._zod.run({value:n,issues:[]},l);if(c instanceof Promise&&(c=await c),c.issues.length){const d=new(i?.Err??e)(c.issues.map(h=>Mr(h,l,Tr())));throw zE(d,i?.callee),d}return c.value},lh=e=>(t,n,s)=>{const i=s?{...s,async:!1}:{async:!1},l=t._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw new Zo;return l.issues.length?{success:!1,error:new(e??UE)(l.issues.map(c=>Mr(c,i,Tr())))}:{success:!0,data:l.value}},z5=lh(BE),ch=e=>async(t,n,s)=>{const i=s?Object.assign(s,{async:!0}):{async:!0};let l=t._zod.run({value:n,issues:[]},i);return l instanceof Promise&&(l=await l),l.issues.length?{success:!1,error:new e(l.issues.map(c=>Mr(c,i,Tr())))}:{success:!0,data:l.value}},L5=ch(BE),$5=e=>(t,n,s)=>{const i=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return Sy(e)(t,n,i)},U5=e=>(t,n,s)=>Sy(e)(t,n,s),B5=e=>async(t,n,s)=>{const i=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return ky(e)(t,n,i)},V5=e=>async(t,n,s)=>ky(e)(t,n,s),F5=e=>(t,n,s)=>{const i=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return lh(e)(t,n,i)},H5=e=>(t,n,s)=>lh(e)(t,n,s),q5=e=>async(t,n,s)=>{const i=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return ch(e)(t,n,i)},Z5=e=>async(t,n,s)=>ch(e)(t,n,s),W5=/^[cC][^\s-]{8,}$/,Y5=/^[0-9a-z]+$/,G5=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,K5=/^[0-9a-vA-V]{20}$/,X5=/^[A-Za-z0-9]{27}$/,J5=/^[a-zA-Z0-9_-]{21}$/,Q5=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,eD=/^([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})$/,f1=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)$/,tD=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,nD="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function sD(){return new RegExp(nD,"u")}const aD=/^(?:(?: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])$/,rD=/^(([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}|:))$/,iD=/^((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])$/,oD=/^(([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])$/,lD=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,VE=/^[A-Za-z0-9_-]*$/,cD=/^\+[1-9]\d{6,14}$/,FE="(?:(?:\\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])))",uD=new RegExp(`^${FE}$`);function HE(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 dD(e){return new RegExp(`^${HE(e)}$`)}function fD(e){const t=HE({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const s=`${t}(?:${n.join("|")})`;return new RegExp(`^${FE}T(?:${s})$`)}const hD=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},mD=/^-?\d+$/,qE=/^-?\d+(?:\.\d+)?$/,pD=/^(?:true|false)$/i,gD=/^null$/i,vD=/^[^A-Z]*$/,yD=/^[^a-z]*$/,ss=he("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ZE={number:"number",bigint:"bigint",object:"date"},WE=he("$ZodCheckLessThan",(e,t)=>{ss.init(e,t);const n=ZE[typeof t.value];e._zod.onattach.push(s=>{const i=s._zod.bag,l=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<l&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=s=>{(t.inclusive?s.value<=t.value:s.value<t.value)||s.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),YE=he("$ZodCheckGreaterThan",(e,t)=>{ss.init(e,t);const n=ZE[typeof t.value];e._zod.onattach.push(s=>{const i=s._zod.bag,l=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>l&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=s=>{(t.inclusive?s.value>=t.value:s.value>t.value)||s.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),xD=he("$ZodCheckMultipleOf",(e,t)=>{ss.init(e,t),e._zod.onattach.push(n=>{var s;(s=n._zod.bag).multipleOf??(s.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):j5(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})}}),bD=he("$ZodCheckNumberFormat",(e,t)=>{ss.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),s=n?"int":"number",[i,l]=C5[t.format];e._zod.onattach.push(c=>{const d=c._zod.bag;d.format=t.format,d.minimum=i,d.maximum=l,n&&(d.pattern=mD)}),e._zod.check=c=>{const d=c.value;if(n){if(!Number.isInteger(d)){c.issues.push({expected:s,format:t.format,code:"invalid_type",continue:!1,input:d,inst:e});return}if(!Number.isSafeInteger(d)){d>0?c.issues.push({input:d,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:s,inclusive:!0,continue:!t.abort}):c.issues.push({input:d,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:s,inclusive:!0,continue:!t.abort});return}}d<i&&c.issues.push({origin:"number",input:d,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),d>l&&c.issues.push({origin:"number",input:d,code:"too_big",maximum:l,inclusive:!0,inst:e,continue:!t.abort})}}),wD=he("$ZodCheckMaxLength",(e,t)=>{var n;ss.init(e,t),(n=e._zod.def).when??(n.when=s=>{const i=s.value;return!wy(i)&&i.length!==void 0}),e._zod.onattach.push(s=>{const i=s._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(s._zod.bag.maximum=t.maximum)}),e._zod.check=s=>{const i=s.value;if(i.length<=t.maximum)return;const c=Ny(i);s.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),jD=he("$ZodCheckMinLength",(e,t)=>{var n;ss.init(e,t),(n=e._zod.def).when??(n.when=s=>{const i=s.value;return!wy(i)&&i.length!==void 0}),e._zod.onattach.push(s=>{const i=s._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(s._zod.bag.minimum=t.minimum)}),e._zod.check=s=>{const i=s.value;if(i.length>=t.minimum)return;const c=Ny(i);s.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),ND=he("$ZodCheckLengthEquals",(e,t)=>{var n;ss.init(e,t),(n=e._zod.def).when??(n.when=s=>{const i=s.value;return!wy(i)&&i.length!==void 0}),e._zod.onattach.push(s=>{const i=s._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=s=>{const i=s.value,l=i.length;if(l===t.length)return;const c=Ny(i),d=l>t.length;s.issues.push({origin:c,...d?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:s.value,inst:e,continue:!t.abort})}}),uh=he("$ZodCheckStringFormat",(e,t)=>{var n,s;ss.init(e,t),e._zod.onattach.push(i=>{const l=i._zod.bag;l.format=t.format,t.pattern&&(l.patterns??(l.patterns=new Set),l.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(s=e._zod).check??(s.check=()=>{})}),SD=he("$ZodCheckRegex",(e,t)=>{uh.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})}}),kD=he("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=vD),uh.init(e,t)}),ED=he("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=yD),uh.init(e,t)}),CD=he("$ZodCheckIncludes",(e,t)=>{ss.init(e,t);const n=tl(t.includes),s=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=s,e._zod.onattach.push(i=>{const l=i._zod.bag;l.patterns??(l.patterns=new Set),l.patterns.add(s)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),AD=he("$ZodCheckStartsWith",(e,t)=>{ss.init(e,t);const n=new RegExp(`^${tl(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=s=>{s.value.startsWith(t.prefix)||s.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:s.value,inst:e,continue:!t.abort})}}),TD=he("$ZodCheckEndsWith",(e,t)=>{ss.init(e,t);const n=new RegExp(`.*${tl(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=s=>{s.value.endsWith(t.suffix)||s.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:s.value,inst:e,continue:!t.abort})}}),MD=he("$ZodCheckOverwrite",(e,t)=>{ss.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class RD{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 s=t.split(`
|
|
12
|
-
`).filter(c=>c),i=Math.min(...s.map(c=>c.length-c.trimStart().length)),l=s.map(c=>c.slice(i)).map(c=>" ".repeat(this.indent*2)+c);for(const c of l)this.content.push(c)}compile(){const t=Function,n=this?.args,i=[...(this?.content??[""]).map(l=>` ${l}`)];return new t(...n,i.join(`
|
|
13
|
-
`))}}const _D={major:4,minor:3,patch:6},qt=he("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=_D;const s=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&s.unshift(e);for(const i of s)for(const l of i._zod.onattach)l(e);if(s.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const i=(c,d,h)=>{let m=Lo(c),p;for(const y of d){if(y._zod.def.when){if(!y._zod.def.when(c))continue}else if(m)continue;const x=c.issues.length,w=y._zod.check(c);if(w instanceof Promise&&h?.async===!1)throw new Zo;if(p||w instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await w,c.issues.length!==x&&(m||(m=Lo(c,x)))});else{if(c.issues.length===x)continue;m||(m=Lo(c,x))}}return p?p.then(()=>c):c},l=(c,d,h)=>{if(Lo(c))return c.aborted=!0,c;const m=i(d,s,h);if(m instanceof Promise){if(h.async===!1)throw new Zo;return m.then(p=>e._zod.parse(p,h))}return e._zod.parse(m,h)};e._zod.run=(c,d)=>{if(d.skipChecks)return e._zod.parse(c,d);if(d.direction==="backward"){const m=e._zod.parse({value:c.value,issues:[]},{...d,skipChecks:!0});return m instanceof Promise?m.then(p=>l(p,c,d)):l(m,c,d)}const h=e._zod.parse(c,d);if(h instanceof Promise){if(d.async===!1)throw new Zo;return h.then(m=>i(m,s,d))}return i(h,s,d)}}pt(e,"~standard",()=>({validate:i=>{try{const l=z5(e,i);return l.success?{value:l.data}:{issues:l.error?.issues}}catch{return L5(e,i).then(c=>c.success?{value:c.data}:{issues:c.error?.issues})}},vendor:"zod",version:1}))}),Ey=he("$ZodString",(e,t)=>{qt.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??hD(e._zod.bag),e._zod.parse=(n,s)=>{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}}),Gt=he("$ZodStringFormat",(e,t)=>{uh.init(e,t),Ey.init(e,t)}),ID=he("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=eD),Gt.init(e,t)}),OD=he("$ZodUUID",(e,t)=>{if(t.version){const s={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(s===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=f1(s))}else t.pattern??(t.pattern=f1());Gt.init(e,t)}),DD=he("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=tD),Gt.init(e,t)}),PD=he("$ZodURL",(e,t)=>{Gt.init(e,t),e._zod.check=n=>{try{const s=n.value.trim(),i=new URL(s);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.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(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.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=i.href:n.value=s;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),zD=he("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=sD()),Gt.init(e,t)}),LD=he("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=J5),Gt.init(e,t)}),$D=he("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=W5),Gt.init(e,t)}),UD=he("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Y5),Gt.init(e,t)}),BD=he("$ZodULID",(e,t)=>{t.pattern??(t.pattern=G5),Gt.init(e,t)}),VD=he("$ZodXID",(e,t)=>{t.pattern??(t.pattern=K5),Gt.init(e,t)}),FD=he("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=X5),Gt.init(e,t)}),HD=he("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=fD(t)),Gt.init(e,t)}),qD=he("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=uD),Gt.init(e,t)}),ZD=he("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=dD(t)),Gt.init(e,t)}),WD=he("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Q5),Gt.init(e,t)}),YD=he("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=aD),Gt.init(e,t),e._zod.bag.format="ipv4"}),GD=he("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=rD),Gt.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})}}}),KD=he("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=iD),Gt.init(e,t)}),XD=he("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=oD),Gt.init(e,t),e._zod.check=n=>{const s=n.value.split("/");try{if(s.length!==2)throw new Error;const[i,l]=s;if(!l)throw new Error;const c=Number(l);if(`${c}`!==l)throw new Error;if(c<0||c>128)throw new Error;new URL(`http://[${i}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function GE(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const JD=he("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=lD),Gt.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{GE(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function QD(e){if(!VE.test(e))return!1;const t=e.replace(/[-_]/g,s=>s==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return GE(n)}const eP=he("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=VE),Gt.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{QD(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),tP=he("$ZodE164",(e,t)=>{t.pattern??(t.pattern=cD),Gt.init(e,t)});function nP(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[s]=n;if(!s)return!1;const i=JSON.parse(atob(s));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const sP=he("$ZodJWT",(e,t)=>{Gt.init(e,t),e._zod.check=n=>{nP(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),KE=he("$ZodNumber",(e,t)=>{qt.init(e,t),e._zod.pattern=e._zod.bag.pattern??qE,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const l=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...l?{received:l}:{}}),n}}),aP=he("$ZodNumberFormat",(e,t)=>{bD.init(e,t),KE.init(e,t)}),rP=he("$ZodBoolean",(e,t)=>{qt.init(e,t),e._zod.pattern=pD,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),iP=he("$ZodNull",(e,t)=>{qt.init(e,t),e._zod.pattern=gD,e._zod.values=new Set([null]),e._zod.parse=(n,s)=>{const i=n.value;return i===null||n.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),n}}),oP=he("$ZodUnknown",(e,t)=>{qt.init(e,t),e._zod.parse=n=>n}),lP=he("$ZodNever",(e,t)=>{qt.init(e,t),e._zod.parse=(n,s)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function h1(e,t,n){e.issues.length&&t.issues.push(...$o(n,e.issues)),t.value[n]=e.value}const cP=he("$ZodArray",(e,t)=>{qt.init(e,t),e._zod.parse=(n,s)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const l=[];for(let c=0;c<i.length;c++){const d=i[c],h=t.element._zod.run({value:d,issues:[]},s);h instanceof Promise?l.push(h.then(m=>h1(m,n,c))):h1(h,n,c)}return l.length?Promise.all(l).then(()=>n):n}});function wf(e,t,n,s,i){if(e.issues.length){if(i&&!(n in s))return;t.issues.push(...$o(n,e.issues))}e.value===void 0?n in s&&(t.value[n]=void 0):t.value[n]=e.value}function XE(e){const t=Object.keys(e.shape);for(const s of t)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${s}": expected a Zod schema`);const n=E5(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function JE(e,t,n,s,i,l){const c=[],d=i.keySet,h=i.catchall._zod,m=h.def.type,p=h.optout==="optional";for(const y in t){if(d.has(y))continue;if(m==="never"){c.push(y);continue}const x=h.run({value:t[y],issues:[]},s);x instanceof Promise?e.push(x.then(w=>wf(w,n,y,t,p))):wf(x,n,y,t,p)}return c.length&&n.issues.push({code:"unrecognized_keys",keys:c,input:t,inst:l}),e.length?Promise.all(e).then(()=>n):n}const uP=he("$ZodObject",(e,t)=>{if(qt.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const d=t.shape;Object.defineProperty(t,"shape",{get:()=>{const h={...d};return Object.defineProperty(t,"shape",{value:h}),h}})}const s=oh(()=>XE(t));pt(e._zod,"propValues",()=>{const d=t.shape,h={};for(const m in d){const p=d[m]._zod;if(p.values){h[m]??(h[m]=new Set);for(const y of p.values)h[m].add(y)}}return h});const i=_c,l=t.catchall;let c;e._zod.parse=(d,h)=>{c??(c=s.value);const m=d.value;if(!i(m))return d.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),d;d.value={};const p=[],y=c.shape;for(const x of c.keys){const w=y[x],j=w._zod.optout==="optional",N=w._zod.run({value:m[x],issues:[]},h);N instanceof Promise?p.push(N.then(k=>wf(k,d,x,m,j))):wf(N,d,x,m,j)}return l?JE(p,m,d,h,s.value,e):p.length?Promise.all(p).then(()=>d):d}}),dP=he("$ZodObjectJIT",(e,t)=>{uP.init(e,t);const n=e._zod.parse,s=oh(()=>XE(t)),i=x=>{const w=new RD(["shape","payload","ctx"]),j=s.value,N=S=>{const M=d1(S);return`shape[${M}]._zod.run({ value: input[${M}], issues: [] }, ctx)`};w.write("const input = payload.value;");const k=Object.create(null);let E=0;for(const S of j.keys)k[S]=`key_${E++}`;w.write("const newResult = {};");for(const S of j.keys){const M=k[S],C=d1(S),R=x[S]?._zod?.optout==="optional";w.write(`const ${M} = ${N(S)};`),R?w.write(`
|
|
14
|
-
if (${M}.issues.length) {
|
|
15
|
-
if (${C} in input) {
|
|
16
|
-
payload.issues = payload.issues.concat(${M}.issues.map(iss => ({
|
|
17
|
-
...iss,
|
|
18
|
-
path: iss.path ? [${C}, ...iss.path] : [${C}]
|
|
19
|
-
})));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (${M}.value === undefined) {
|
|
24
|
-
if (${C} in input) {
|
|
25
|
-
newResult[${C}] = undefined;
|
|
26
|
-
}
|
|
27
|
-
} else {
|
|
28
|
-
newResult[${C}] = ${M}.value;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
`):w.write(`
|
|
32
|
-
if (${M}.issues.length) {
|
|
33
|
-
payload.issues = payload.issues.concat(${M}.issues.map(iss => ({
|
|
34
|
-
...iss,
|
|
35
|
-
path: iss.path ? [${C}, ...iss.path] : [${C}]
|
|
36
|
-
})));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (${M}.value === undefined) {
|
|
40
|
-
if (${C} in input) {
|
|
41
|
-
newResult[${C}] = undefined;
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
newResult[${C}] = ${M}.value;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
`)}w.write("payload.value = newResult;"),w.write("return payload;");const A=w.compile();return(S,M)=>A(x,S,M)};let l;const c=_c,d=!DE.jitless,m=d&&S5.value,p=t.catchall;let y;e._zod.parse=(x,w)=>{y??(y=s.value);const j=x.value;return c(j)?d&&m&&w?.async===!1&&w.jitless!==!0?(l||(l=i(t.shape)),x=l(x,w),p?JE([],j,x,w,y,e):x):n(x,w):(x.issues.push({expected:"object",code:"invalid_type",input:j,inst:e}),x)}});function m1(e,t,n,s){for(const l of e)if(l.issues.length===0)return t.value=l.value,t;const i=e.filter(l=>!Lo(l));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(l=>l.issues.map(c=>Mr(c,s,Tr())))}),t)}const QE=he("$ZodUnion",(e,t)=>{qt.init(e,t),pt(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),pt(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),pt(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),pt(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(l=>l._zod.pattern);return new RegExp(`^(${i.map(l=>jy(l.source)).join("|")})$`)}});const n=t.options.length===1,s=t.options[0]._zod.run;e._zod.parse=(i,l)=>{if(n)return s(i,l);let c=!1;const d=[];for(const h of t.options){const m=h._zod.run({value:i.value,issues:[]},l);if(m instanceof Promise)d.push(m),c=!0;else{if(m.issues.length===0)return m;d.push(m)}}return c?Promise.all(d).then(h=>m1(h,i,e,l)):m1(d,i,e,l)}}),fP=he("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,QE.init(e,t);const n=e._zod.parse;pt(e._zod,"propValues",()=>{const i={};for(const l of t.options){const c=l._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(l)}"`);for(const[d,h]of Object.entries(c)){i[d]||(i[d]=new Set);for(const m of h)i[d].add(m)}}return i});const s=oh(()=>{const i=t.options,l=new Map;for(const c of i){const d=c._zod.propValues?.[t.discriminator];if(!d||d.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(c)}"`);for(const h of d){if(l.has(h))throw new Error(`Duplicate discriminator value "${String(h)}"`);l.set(h,c)}}return l});e._zod.parse=(i,l)=>{const c=i.value;if(!_c(c))return i.issues.push({code:"invalid_type",expected:"object",input:c,inst:e}),i;const d=s.value.get(c?.[t.discriminator]);return d?d._zod.run(i,l):t.unionFallback?n(i,l):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:c,path:[t.discriminator],inst:e}),i)}}),hP=he("$ZodIntersection",(e,t)=>{qt.init(e,t),e._zod.parse=(n,s)=>{const i=n.value,l=t.left._zod.run({value:i,issues:[]},s),c=t.right._zod.run({value:i,issues:[]},s);return l instanceof Promise||c instanceof Promise?Promise.all([l,c]).then(([h,m])=>p1(n,h,m)):p1(n,l,c)}});function ov(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(el(e)&&el(t)){const n=Object.keys(t),s=Object.keys(e).filter(l=>n.indexOf(l)!==-1),i={...e,...t};for(const l of s){const c=ov(e[l],t[l]);if(!c.valid)return{valid:!1,mergeErrorPath:[l,...c.mergeErrorPath]};i[l]=c.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let s=0;s<e.length;s++){const i=e[s],l=t[s],c=ov(i,l);if(!c.valid)return{valid:!1,mergeErrorPath:[s,...c.mergeErrorPath]};n.push(c.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function p1(e,t,n){const s=new Map;let i;for(const d of t.issues)if(d.code==="unrecognized_keys"){i??(i=d);for(const h of d.keys)s.has(h)||s.set(h,{}),s.get(h).l=!0}else e.issues.push(d);for(const d of n.issues)if(d.code==="unrecognized_keys")for(const h of d.keys)s.has(h)||s.set(h,{}),s.get(h).r=!0;else e.issues.push(d);const l=[...s].filter(([,d])=>d.l&&d.r).map(([d])=>d);if(l.length&&i&&e.issues.push({...i,keys:l}),Lo(e))return e;const c=ov(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 mP=he("$ZodRecord",(e,t)=>{qt.init(e,t),e._zod.parse=(n,s)=>{const i=n.value;if(!el(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const l=[],c=t.keyType._zod.values;if(c){n.value={};const d=new Set;for(const m of c)if(typeof m=="string"||typeof m=="number"||typeof m=="symbol"){d.add(typeof m=="number"?m.toString():m);const p=t.valueType._zod.run({value:i[m],issues:[]},s);p instanceof Promise?l.push(p.then(y=>{y.issues.length&&n.issues.push(...$o(m,y.issues)),n.value[m]=y.value})):(p.issues.length&&n.issues.push(...$o(m,p.issues)),n.value[m]=p.value)}let h;for(const m in i)d.has(m)||(h=h??[],h.push(m));h&&h.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:h})}else{n.value={};for(const d of Reflect.ownKeys(i)){if(d==="__proto__")continue;let h=t.keyType._zod.run({value:d,issues:[]},s);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof d=="string"&&qE.test(d)&&h.issues.length){const y=t.keyType._zod.run({value:Number(d),issues:[]},s);if(y instanceof Promise)throw new Error("Async schemas not supported in object keys currently");y.issues.length===0&&(h=y)}if(h.issues.length){t.mode==="loose"?n.value[d]=i[d]:n.issues.push({code:"invalid_key",origin:"record",issues:h.issues.map(y=>Mr(y,s,Tr())),input:d,path:[d],inst:e});continue}const p=t.valueType._zod.run({value:i[d],issues:[]},s);p instanceof Promise?l.push(p.then(y=>{y.issues.length&&n.issues.push(...$o(d,y.issues)),n.value[h.value]=y.value})):(p.issues.length&&n.issues.push(...$o(d,p.issues)),n.value[h.value]=p.value)}}return l.length?Promise.all(l).then(()=>n):n}}),pP=he("$ZodEnum",(e,t)=>{qt.init(e,t);const n=PE(t.entries),s=new Set(n);e._zod.values=s,e._zod.pattern=new RegExp(`^(${n.filter(i=>k5.has(typeof i)).map(i=>typeof i=="string"?tl(i):i.toString()).join("|")})$`),e._zod.parse=(i,l)=>{const c=i.value;return s.has(c)||i.issues.push({code:"invalid_value",values:n,input:c,inst:e}),i}}),gP=he("$ZodLiteral",(e,t)=>{if(qt.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(s=>typeof s=="string"?tl(s):s?tl(s.toString()):String(s)).join("|")})$`),e._zod.parse=(s,i)=>{const l=s.value;return n.has(l)||s.issues.push({code:"invalid_value",values:t.values,input:l,inst:e}),s}}),vP=he("$ZodTransform",(e,t)=>{qt.init(e,t),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new OE(e.constructor.name);const i=t.transform(n.value,n);if(s.async)return(i instanceof Promise?i:Promise.resolve(i)).then(c=>(n.value=c,n));if(i instanceof Promise)throw new Zo;return n.value=i,n}});function g1(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const eC=he("$ZodOptional",(e,t)=>{qt.init(e,t),e._zod.optin="optional",e._zod.optout="optional",pt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),pt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${jy(n.source)})?$`):void 0}),e._zod.parse=(n,s)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(n,s);return i instanceof Promise?i.then(l=>g1(l,n.value)):g1(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,s)}}),yP=he("$ZodExactOptional",(e,t)=>{eC.init(e,t),pt(e._zod,"values",()=>t.innerType._zod.values),pt(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,s)=>t.innerType._zod.run(n,s)}),xP=he("$ZodNullable",(e,t)=>{qt.init(e,t),pt(e._zod,"optin",()=>t.innerType._zod.optin),pt(e._zod,"optout",()=>t.innerType._zod.optout),pt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${jy(n.source)}|null)$`):void 0}),pt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,s)=>n.value===null?n:t.innerType._zod.run(n,s)}),bP=he("$ZodDefault",(e,t)=>{qt.init(e,t),e._zod.optin="optional",pt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);if(n.value===void 0)return n.value=t.defaultValue,n;const i=t.innerType._zod.run(n,s);return i instanceof Promise?i.then(l=>v1(l,t)):v1(i,t)}});function v1(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const wP=he("$ZodPrefault",(e,t)=>{qt.init(e,t),e._zod.optin="optional",pt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>(s.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,s))}),jP=he("$ZodNonOptional",(e,t)=>{qt.init(e,t),pt(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(s=>s!==void 0)):void 0}),e._zod.parse=(n,s)=>{const i=t.innerType._zod.run(n,s);return i instanceof Promise?i.then(l=>y1(l,e)):y1(i,e)}});function y1(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 NP=he("$ZodCatch",(e,t)=>{qt.init(e,t),pt(e._zod,"optin",()=>t.innerType._zod.optin),pt(e._zod,"optout",()=>t.innerType._zod.optout),pt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const i=t.innerType._zod.run(n,s);return i instanceof Promise?i.then(l=>(n.value=l.value,l.issues.length&&(n.value=t.catchValue({...n,error:{issues:l.issues.map(c=>Mr(c,s,Tr()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(l=>Mr(l,s,Tr()))},input:n.value}),n.issues=[]),n)}}),SP=he("$ZodPipe",(e,t)=>{qt.init(e,t),pt(e._zod,"values",()=>t.in._zod.values),pt(e._zod,"optin",()=>t.in._zod.optin),pt(e._zod,"optout",()=>t.out._zod.optout),pt(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,s)=>{if(s.direction==="backward"){const l=t.out._zod.run(n,s);return l instanceof Promise?l.then(c=>Nd(c,t.in,s)):Nd(l,t.in,s)}const i=t.in._zod.run(n,s);return i instanceof Promise?i.then(l=>Nd(l,t.out,s)):Nd(i,t.out,s)}});function Nd(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const kP=he("$ZodReadonly",(e,t)=>{qt.init(e,t),pt(e._zod,"propValues",()=>t.innerType._zod.propValues),pt(e._zod,"values",()=>t.innerType._zod.values),pt(e._zod,"optin",()=>t.innerType?._zod?.optin),pt(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const i=t.innerType._zod.run(n,s);return i instanceof Promise?i.then(x1):x1(i)}});function x1(e){return e.value=Object.freeze(e.value),e}const EP=he("$ZodLazy",(e,t)=>{qt.init(e,t),pt(e._zod,"innerType",()=>t.getter()),pt(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),pt(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),pt(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),pt(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,s)=>e._zod.innerType._zod.run(n,s)}),CP=he("$ZodCustom",(e,t)=>{ss.init(e,t),qt.init(e,t),e._zod.parse=(n,s)=>n,e._zod.check=n=>{const s=n.value,i=t.fn(s);if(i instanceof Promise)return i.then(l=>b1(l,n,s,e));b1(i,n,s,e)}});function b1(e,t,n,s){if(!e){const i={code:"custom",input:n,inst:s,path:[...s._zod.def.path??[]],continue:!s._zod.def.abort};s._zod.def.params&&(i.params=s._zod.def.params),t.issues.push(Ic(i))}}var w1;class AP{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const s=n[0];return this._map.set(t,s),s&&typeof s=="object"&&"id"in s&&this._idmap.set(s.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 s={...this.get(n)??{}};delete s.id;const i={...s,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function TP(){return new AP}(w1=globalThis).__zod_globalRegistry??(w1.__zod_globalRegistry=TP());const hc=globalThis.__zod_globalRegistry;function MP(e,t){return new e({type:"string",...Ue(t)})}function RP(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Ue(t)})}function j1(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Ue(t)})}function _P(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Ue(t)})}function IP(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ue(t)})}function OP(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ue(t)})}function DP(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ue(t)})}function PP(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Ue(t)})}function zP(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Ue(t)})}function LP(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ue(t)})}function $P(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Ue(t)})}function UP(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ue(t)})}function BP(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Ue(t)})}function VP(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Ue(t)})}function FP(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ue(t)})}function HP(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ue(t)})}function qP(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ue(t)})}function ZP(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ue(t)})}function WP(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ue(t)})}function YP(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Ue(t)})}function GP(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Ue(t)})}function KP(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Ue(t)})}function XP(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Ue(t)})}function JP(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ue(t)})}function QP(e,t){return new e({type:"string",format:"date",check:"string_format",...Ue(t)})}function e4(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Ue(t)})}function t4(e,t){return new e({type:"string",format:"duration",check:"string_format",...Ue(t)})}function n4(e,t){return new e({type:"number",checks:[],...Ue(t)})}function s4(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Ue(t)})}function a4(e,t){return new e({type:"boolean",...Ue(t)})}function r4(e,t){return new e({type:"null",...Ue(t)})}function i4(e){return new e({type:"unknown"})}function o4(e,t){return new e({type:"never",...Ue(t)})}function N1(e,t){return new WE({check:"less_than",...Ue(t),value:e,inclusive:!1})}function Yp(e,t){return new WE({check:"less_than",...Ue(t),value:e,inclusive:!0})}function S1(e,t){return new YE({check:"greater_than",...Ue(t),value:e,inclusive:!1})}function Gp(e,t){return new YE({check:"greater_than",...Ue(t),value:e,inclusive:!0})}function k1(e,t){return new xD({check:"multiple_of",...Ue(t),value:e})}function tC(e,t){return new wD({check:"max_length",...Ue(t),maximum:e})}function jf(e,t){return new jD({check:"min_length",...Ue(t),minimum:e})}function nC(e,t){return new ND({check:"length_equals",...Ue(t),length:e})}function l4(e,t){return new SD({check:"string_format",format:"regex",...Ue(t),pattern:e})}function c4(e){return new kD({check:"string_format",format:"lowercase",...Ue(e)})}function u4(e){return new ED({check:"string_format",format:"uppercase",...Ue(e)})}function d4(e,t){return new CD({check:"string_format",format:"includes",...Ue(t),includes:e})}function f4(e,t){return new AD({check:"string_format",format:"starts_with",...Ue(t),prefix:e})}function h4(e,t){return new TD({check:"string_format",format:"ends_with",...Ue(t),suffix:e})}function il(e){return new MD({check:"overwrite",tx:e})}function m4(e){return il(t=>t.normalize(e))}function p4(){return il(e=>e.trim())}function g4(){return il(e=>e.toLowerCase())}function v4(){return il(e=>e.toUpperCase())}function y4(){return il(e=>N5(e))}function x4(e,t,n){return new e({type:"array",element:t,...Ue(n)})}function b4(e,t,n){const s=Ue(n);return s.abort??(s.abort=!0),new e({type:"custom",check:"custom",fn:t,...s})}function w4(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Ue(n)})}function j4(e){const t=N4(n=>(n.addIssue=s=>{if(typeof s=="string")n.issues.push(Ic(s,n.value,t._zod.def));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),n.issues.push(Ic(i))}},e(n.value,n)));return t}function N4(e,t){const n=new ss({check:"custom",...Ue(t)});return n._zod.check=e,n}function Nf(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??hc,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 Lt(e,t,n={path:[],schemaPath:[]}){var s;const i=e._zod.def,l=t.seen.get(e);if(l)return l.count++,n.schemaPath.includes(e)&&(l.cycle=n.path),l.schema;const c={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,c);const d=e._zod.toJSONSchema?.();if(d)c.schema=d;else{const p={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,c.schema,p);else{const x=c.schema,w=t.processors[i.type];if(!w)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);w(e,t,x,p)}const y=e._zod.parent;y&&(c.ref||(c.ref=y),Lt(y,t,p),t.seen.get(y).isParent=!0)}const h=t.metadataRegistry.get(e);return h&&Object.assign(c.schema,h),t.io==="input"&&$n(e)&&(delete c.schema.examples,delete c.schema.default),t.io==="input"&&c.schema._prefault&&((s=c.schema).default??(s.default=c.schema._prefault)),delete c.schema._prefault,t.seen.get(e).schema}function Sf(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=new Map;for(const c of e.seen.entries()){const d=e.metadataRegistry.get(c[0])?.id;if(d){const h=s.get(d);if(h&&h!==c[0])throw new Error(`Duplicate schema id "${d}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);s.set(d,c[0])}}const i=c=>{const d=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const y=e.external.registry.get(c[0])?.id,x=e.external.uri??(j=>j);if(y)return{ref:x(y)};const w=c[1].defId??c[1].schema.id??`schema${e.counter++}`;return c[1].defId=w,{defId:w,ref:`${x("__shared")}#/${d}/${w}`}}if(c[1]===n)return{ref:"#"};const m=`#/${d}/`,p=c[1].schema.id??`__schema${e.counter++}`;return{defId:p,ref:m+p}},l=c=>{if(c[1].schema.$ref)return;const d=c[1],{ref:h,defId:m}=i(c);d.def={...d.schema},m&&(d.defId=m);const p=d.schema;for(const y in p)delete p[y];p.$ref=h};if(e.cycles==="throw")for(const c of e.seen.entries()){const d=c[1];if(d.cycle)throw new Error(`Cycle detected: #/${d.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 d=c[1];if(t===c[0]){l(c);continue}if(e.external){const m=e.external.registry.get(c[0])?.id;if(t!==c[0]&&m){l(c);continue}}if(e.metadataRegistry.get(c[0])?.id){l(c);continue}if(d.cycle){l(c);continue}if(d.count>1&&e.reused==="ref"){l(c);continue}}}function kf(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=c=>{const d=e.seen.get(c);if(d.ref===null)return;const h=d.def??d.schema,m={...h},p=d.ref;if(d.ref=null,p){s(p);const x=e.seen.get(p),w=x.schema;if(w.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(h.allOf=h.allOf??[],h.allOf.push(w)):Object.assign(h,w),Object.assign(h,m),c._zod.parent===p)for(const N in h)N==="$ref"||N==="allOf"||N in m||delete h[N];if(w.$ref&&x.def)for(const N in h)N==="$ref"||N==="allOf"||N in x.def&&JSON.stringify(h[N])===JSON.stringify(x.def[N])&&delete h[N]}const y=c._zod.parent;if(y&&y!==p){s(y);const x=e.seen.get(y);if(x?.schema.$ref&&(h.$ref=x.schema.$ref,x.def))for(const w in h)w==="$ref"||w==="allOf"||w in x.def&&JSON.stringify(h[w])===JSON.stringify(x.def[w])&&delete h[w]}e.override({zodSchema:c,jsonSchema:h,path:d.path??[]})};for(const c of[...e.seen.entries()].reverse())s(c[0]);const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$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");i.$id=e.external.uri(c)}Object.assign(i,n.def??n.schema);const l=e.external?.defs??{};for(const c of e.seen.entries()){const d=c[1];d.def&&d.defId&&(l[d.defId]=d.def)}e.external||Object.keys(l).length>0&&(e.target==="draft-2020-12"?i.$defs=l:i.definitions=l);try{const c=JSON.parse(JSON.stringify(i));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ef(t,"input",e.processors),output:Ef(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function $n(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const s=e._zod.def;if(s.type==="transform")return!0;if(s.type==="array")return $n(s.element,n);if(s.type==="set")return $n(s.valueType,n);if(s.type==="lazy")return $n(s.getter(),n);if(s.type==="promise"||s.type==="optional"||s.type==="nonoptional"||s.type==="nullable"||s.type==="readonly"||s.type==="default"||s.type==="prefault")return $n(s.innerType,n);if(s.type==="intersection")return $n(s.left,n)||$n(s.right,n);if(s.type==="record"||s.type==="map")return $n(s.keyType,n)||$n(s.valueType,n);if(s.type==="pipe")return $n(s.in,n)||$n(s.out,n);if(s.type==="object"){for(const i in s.shape)if($n(s.shape[i],n))return!0;return!1}if(s.type==="union"){for(const i of s.options)if($n(i,n))return!0;return!1}if(s.type==="tuple"){for(const i of s.items)if($n(i,n))return!0;return!!(s.rest&&$n(s.rest,n))}return!1}const S4=(e,t={})=>n=>{const s=Nf({...n,processors:t});return Lt(e,s),Sf(s,e),kf(s,e)},Ef=(e,t,n={})=>s=>{const{libraryOptions:i,target:l}=s??{},c=Nf({...i??{},target:l,io:t,processors:n});return Lt(e,c),Sf(c,e),kf(c,e)},k4={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},sC=(e,t,n,s)=>{const i=n;i.type="string";const{minimum:l,maximum:c,format:d,patterns:h,contentEncoding:m}=e._zod.bag;if(typeof l=="number"&&(i.minLength=l),typeof c=="number"&&(i.maxLength=c),d&&(i.format=k4[d]??d,i.format===""&&delete i.format,d==="time"&&delete i.format),m&&(i.contentEncoding=m),h&&h.size>0){const p=[...h];p.length===1?i.pattern=p[0].source:p.length>1&&(i.allOf=[...p.map(y=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:y.source}))])}},aC=(e,t,n,s)=>{const i=n,{minimum:l,maximum:c,format:d,multipleOf:h,exclusiveMaximum:m,exclusiveMinimum:p}=e._zod.bag;typeof d=="string"&&d.includes("int")?i.type="integer":i.type="number",typeof p=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=p,i.exclusiveMinimum=!0):i.exclusiveMinimum=p),typeof l=="number"&&(i.minimum=l,typeof p=="number"&&t.target!=="draft-04"&&(p>=l?delete i.minimum:delete i.exclusiveMinimum)),typeof m=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=m,i.exclusiveMaximum=!0):i.exclusiveMaximum=m),typeof c=="number"&&(i.maximum=c,typeof m=="number"&&t.target!=="draft-04"&&(m<=c?delete i.maximum:delete i.exclusiveMaximum)),typeof h=="number"&&(i.multipleOf=h)},rC=(e,t,n,s)=>{n.type="boolean"},E4=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},C4=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},iC=(e,t,n,s)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},A4=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},T4=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},oC=(e,t,n,s)=>{n.not={}},M4=(e,t,n,s)=>{},lC=(e,t,n,s)=>{},R4=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},cC=(e,t,n,s)=>{const i=e._zod.def,l=PE(i.entries);l.every(c=>typeof c=="number")&&(n.type="number"),l.every(c=>typeof c=="string")&&(n.type="string"),n.enum=l},uC=(e,t,n,s)=>{const i=e._zod.def,l=[];for(const c of i.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");l.push(Number(c))}else l.push(c);if(l.length!==0)if(l.length===1){const c=l[0];n.type=c===null?"null":typeof c,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[c]:n.const=c}else l.every(c=>typeof c=="number")&&(n.type="number"),l.every(c=>typeof c=="string")&&(n.type="string"),l.every(c=>typeof c=="boolean")&&(n.type="boolean"),l.every(c=>c===null)&&(n.type="null"),n.enum=l},_4=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},I4=(e,t,n,s)=>{const i=n,l=e._zod.pattern;if(!l)throw new Error("Pattern not found in template literal");i.type="string",i.pattern=l.source},O4=(e,t,n,s)=>{const i=n,l={type:"string",format:"binary",contentEncoding:"binary"},{minimum:c,maximum:d,mime:h}=e._zod.bag;c!==void 0&&(l.minLength=c),d!==void 0&&(l.maxLength=d),h?h.length===1?(l.contentMediaType=h[0],Object.assign(i,l)):(Object.assign(i,l),i.anyOf=h.map(m=>({contentMediaType:m}))):Object.assign(i,l)},D4=(e,t,n,s)=>{n.type="boolean"},dC=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},P4=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},fC=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},z4=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},L4=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},hC=(e,t,n,s)=>{const i=n,l=e._zod.def,{minimum:c,maximum:d}=e._zod.bag;typeof c=="number"&&(i.minItems=c),typeof d=="number"&&(i.maxItems=d),i.type="array",i.items=Lt(l.element,t,{...s,path:[...s.path,"items"]})},mC=(e,t,n,s)=>{const i=n,l=e._zod.def;i.type="object",i.properties={};const c=l.shape;for(const m in c)i.properties[m]=Lt(c[m],t,{...s,path:[...s.path,"properties",m]});const d=new Set(Object.keys(c)),h=new Set([...d].filter(m=>{const p=l.shape[m]._zod;return t.io==="input"?p.optin===void 0:p.optout===void 0}));h.size>0&&(i.required=Array.from(h)),l.catchall?._zod.def.type==="never"?i.additionalProperties=!1:l.catchall?l.catchall&&(i.additionalProperties=Lt(l.catchall,t,{...s,path:[...s.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},pC=(e,t,n,s)=>{const i=e._zod.def,l=i.inclusive===!1,c=i.options.map((d,h)=>Lt(d,t,{...s,path:[...s.path,l?"oneOf":"anyOf",h]}));l?n.oneOf=c:n.anyOf=c},gC=(e,t,n,s)=>{const i=e._zod.def,l=Lt(i.left,t,{...s,path:[...s.path,"allOf",0]}),c=Lt(i.right,t,{...s,path:[...s.path,"allOf",1]}),d=m=>"allOf"in m&&Object.keys(m).length===1,h=[...d(l)?l.allOf:[l],...d(c)?c.allOf:[c]];n.allOf=h},$4=(e,t,n,s)=>{const i=n,l=e._zod.def;i.type="array";const c=t.target==="draft-2020-12"?"prefixItems":"items",d=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",h=l.items.map((x,w)=>Lt(x,t,{...s,path:[...s.path,c,w]})),m=l.rest?Lt(l.rest,t,{...s,path:[...s.path,d,...t.target==="openapi-3.0"?[l.items.length]:[]]}):null;t.target==="draft-2020-12"?(i.prefixItems=h,m&&(i.items=m)):t.target==="openapi-3.0"?(i.items={anyOf:h},m&&i.items.anyOf.push(m),i.minItems=h.length,m||(i.maxItems=h.length)):(i.items=h,m&&(i.additionalItems=m));const{minimum:p,maximum:y}=e._zod.bag;typeof p=="number"&&(i.minItems=p),typeof y=="number"&&(i.maxItems=y)},vC=(e,t,n,s)=>{const i=n,l=e._zod.def;i.type="object";const c=l.keyType,h=c._zod.bag?.patterns;if(l.mode==="loose"&&h&&h.size>0){const p=Lt(l.valueType,t,{...s,path:[...s.path,"patternProperties","*"]});i.patternProperties={};for(const y of h)i.patternProperties[y.source]=p}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Lt(l.keyType,t,{...s,path:[...s.path,"propertyNames"]})),i.additionalProperties=Lt(l.valueType,t,{...s,path:[...s.path,"additionalProperties"]});const m=c._zod.values;if(m){const p=[...m].filter(y=>typeof y=="string"||typeof y=="number");p.length>0&&(i.required=p)}},yC=(e,t,n,s)=>{const i=e._zod.def,l=Lt(i.innerType,t,s),c=t.seen.get(e);t.target==="openapi-3.0"?(c.ref=i.innerType,n.nullable=!0):n.anyOf=[l,{type:"null"}]},xC=(e,t,n,s)=>{const i=e._zod.def;Lt(i.innerType,t,s);const l=t.seen.get(e);l.ref=i.innerType},bC=(e,t,n,s)=>{const i=e._zod.def;Lt(i.innerType,t,s);const l=t.seen.get(e);l.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},wC=(e,t,n,s)=>{const i=e._zod.def;Lt(i.innerType,t,s);const l=t.seen.get(e);l.ref=i.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},jC=(e,t,n,s)=>{const i=e._zod.def;Lt(i.innerType,t,s);const l=t.seen.get(e);l.ref=i.innerType;let c;try{c=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=c},NC=(e,t,n,s)=>{const i=e._zod.def,l=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;Lt(l,t,s);const c=t.seen.get(e);c.ref=l},SC=(e,t,n,s)=>{const i=e._zod.def;Lt(i.innerType,t,s);const l=t.seen.get(e);l.ref=i.innerType,n.readOnly=!0},U4=(e,t,n,s)=>{const i=e._zod.def;Lt(i.innerType,t,s);const l=t.seen.get(e);l.ref=i.innerType},Cy=(e,t,n,s)=>{const i=e._zod.def;Lt(i.innerType,t,s);const l=t.seen.get(e);l.ref=i.innerType},kC=(e,t,n,s)=>{const i=e._zod.innerType;Lt(i,t,s);const l=t.seen.get(e);l.ref=i},E1={string:sC,number:aC,boolean:rC,bigint:E4,symbol:C4,null:iC,undefined:A4,void:T4,never:oC,any:M4,unknown:lC,date:R4,enum:cC,literal:uC,nan:_4,template_literal:I4,file:O4,success:D4,custom:dC,function:P4,transform:fC,map:z4,set:L4,array:hC,object:mC,union:pC,intersection:gC,tuple:$4,record:vC,nullable:yC,nonoptional:xC,default:bC,prefault:wC,catch:jC,pipe:NC,readonly:SC,promise:U4,optional:Cy,lazy:kC};function B4(e,t){if("_idmap"in e){const s=e,i=Nf({...t,processors:E1}),l={};for(const h of s._idmap.entries()){const[m,p]=h;Lt(p,i)}const c={},d={registry:s,uri:t?.uri,defs:l};i.external=d;for(const h of s._idmap.entries()){const[m,p]=h;Sf(i,p),c[m]=kf(i,p)}if(Object.keys(l).length>0){const h=i.target==="draft-2020-12"?"$defs":"definitions";c.__shared={[h]:l}}return{schemas:c}}const n=Nf({...t,processors:E1});return Lt(e,n),Sf(n,e),kf(n,e)}const V4=he("ZodISODateTime",(e,t)=>{HD.init(e,t),tn.init(e,t)});function F4(e){return JP(V4,e)}const H4=he("ZodISODate",(e,t)=>{qD.init(e,t),tn.init(e,t)});function q4(e){return QP(H4,e)}const Z4=he("ZodISOTime",(e,t)=>{ZD.init(e,t),tn.init(e,t)});function W4(e){return e4(Z4,e)}const Y4=he("ZodISODuration",(e,t)=>{WD.init(e,t),tn.init(e,t)});function G4(e){return t4(Y4,e)}const K4=(e,t)=>{UE.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>P5(e,n)},flatten:{value:n=>D5(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,iv,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,iv,2)}},isEmpty:{get(){return e.issues.length===0}}})},Os=he("ZodError",K4,{Parent:Error}),X4=Sy(Os),J4=ky(Os),Q4=lh(Os),EC=ch(Os),ez=$5(Os),tz=U5(Os),nz=B5(Os),sz=V5(Os),az=F5(Os),rz=H5(Os),iz=q5(Os),oz=Z5(Os),Zt=he("ZodType",(e,t)=>(qt.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ef(e,"input"),output:Ef(e,"output")}}),e.toJSONSchema=S4(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(Dr(t,{checks:[...t.checks??[],...n.map(s=>typeof s=="function"?{_zod:{check:s,def:{check:"custom"},onattach:[]}}:s)]}),{parent:!0}),e.with=e.check,e.clone=(n,s)=>Pr(e,n,s),e.brand=()=>e,e.register=((n,s)=>(n.add(e,s),e)),e.parse=(n,s)=>X4(e,n,s,{callee:e.parse}),e.safeParse=(n,s)=>Q4(e,n,s),e.parseAsync=async(n,s)=>J4(e,n,s,{callee:e.parseAsync}),e.safeParseAsync=async(n,s)=>EC(e,n,s),e.spa=e.safeParseAsync,e.encode=(n,s)=>ez(e,n,s),e.decode=(n,s)=>tz(e,n,s),e.encodeAsync=async(n,s)=>nz(e,n,s),e.decodeAsync=async(n,s)=>sz(e,n,s),e.safeEncode=(n,s)=>az(e,n,s),e.safeDecode=(n,s)=>rz(e,n,s),e.safeEncodeAsync=async(n,s)=>iz(e,n,s),e.safeDecodeAsync=async(n,s)=>oz(e,n,s),e.refine=(n,s)=>e.check(s3(n,s)),e.superRefine=n=>e.check(a3(n)),e.overwrite=n=>e.check(il(n)),e.optional=()=>T1(e),e.exactOptional=()=>Fz(e),e.nullable=()=>M1(e),e.nullish=()=>T1(M1(e)),e.nonoptional=n=>Gz(e,n),e.array=()=>ol(e),e.or=n=>Fn([e,n]),e.and=n=>zz(e,n),e.transform=n=>R1(e,Bz(n)),e.default=n=>Zz(e,n),e.prefault=n=>Yz(e,n),e.catch=n=>Xz(e,n),e.pipe=n=>R1(e,n),e.readonly=()=>e3(e),e.describe=n=>{const s=e.clone();return hc.add(s,{description:n}),s},Object.defineProperty(e,"description",{get(){return hc.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return hc.get(e);const s=e.clone();return hc.add(s,n[0]),s},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),CC=he("_ZodString",(e,t)=>{Ey.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(s,i,l)=>sC(e,s,i);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...s)=>e.check(l4(...s)),e.includes=(...s)=>e.check(d4(...s)),e.startsWith=(...s)=>e.check(f4(...s)),e.endsWith=(...s)=>e.check(h4(...s)),e.min=(...s)=>e.check(jf(...s)),e.max=(...s)=>e.check(tC(...s)),e.length=(...s)=>e.check(nC(...s)),e.nonempty=(...s)=>e.check(jf(1,...s)),e.lowercase=s=>e.check(c4(s)),e.uppercase=s=>e.check(u4(s)),e.trim=()=>e.check(p4()),e.normalize=(...s)=>e.check(m4(...s)),e.toLowerCase=()=>e.check(g4()),e.toUpperCase=()=>e.check(v4()),e.slugify=()=>e.check(y4())}),lz=he("ZodString",(e,t)=>{Ey.init(e,t),CC.init(e,t),e.email=n=>e.check(RP(cz,n)),e.url=n=>e.check(PP(uz,n)),e.jwt=n=>e.check(XP(kz,n)),e.emoji=n=>e.check(zP(dz,n)),e.guid=n=>e.check(j1(C1,n)),e.uuid=n=>e.check(_P(Sd,n)),e.uuidv4=n=>e.check(IP(Sd,n)),e.uuidv6=n=>e.check(OP(Sd,n)),e.uuidv7=n=>e.check(DP(Sd,n)),e.nanoid=n=>e.check(LP(fz,n)),e.guid=n=>e.check(j1(C1,n)),e.cuid=n=>e.check($P(hz,n)),e.cuid2=n=>e.check(UP(mz,n)),e.ulid=n=>e.check(BP(pz,n)),e.base64=n=>e.check(YP(jz,n)),e.base64url=n=>e.check(GP(Nz,n)),e.xid=n=>e.check(VP(gz,n)),e.ksuid=n=>e.check(FP(vz,n)),e.ipv4=n=>e.check(HP(yz,n)),e.ipv6=n=>e.check(qP(xz,n)),e.cidrv4=n=>e.check(ZP(bz,n)),e.cidrv6=n=>e.check(WP(wz,n)),e.e164=n=>e.check(KP(Sz,n)),e.datetime=n=>e.check(F4(n)),e.date=n=>e.check(q4(n)),e.time=n=>e.check(W4(n)),e.duration=n=>e.check(G4(n))});function Me(e){return MP(lz,e)}const tn=he("ZodStringFormat",(e,t)=>{Gt.init(e,t),CC.init(e,t)}),cz=he("ZodEmail",(e,t)=>{DD.init(e,t),tn.init(e,t)}),C1=he("ZodGUID",(e,t)=>{ID.init(e,t),tn.init(e,t)}),Sd=he("ZodUUID",(e,t)=>{OD.init(e,t),tn.init(e,t)}),uz=he("ZodURL",(e,t)=>{PD.init(e,t),tn.init(e,t)}),dz=he("ZodEmoji",(e,t)=>{zD.init(e,t),tn.init(e,t)}),fz=he("ZodNanoID",(e,t)=>{LD.init(e,t),tn.init(e,t)}),hz=he("ZodCUID",(e,t)=>{$D.init(e,t),tn.init(e,t)}),mz=he("ZodCUID2",(e,t)=>{UD.init(e,t),tn.init(e,t)}),pz=he("ZodULID",(e,t)=>{BD.init(e,t),tn.init(e,t)}),gz=he("ZodXID",(e,t)=>{VD.init(e,t),tn.init(e,t)}),vz=he("ZodKSUID",(e,t)=>{FD.init(e,t),tn.init(e,t)}),yz=he("ZodIPv4",(e,t)=>{YD.init(e,t),tn.init(e,t)}),xz=he("ZodIPv6",(e,t)=>{GD.init(e,t),tn.init(e,t)}),bz=he("ZodCIDRv4",(e,t)=>{KD.init(e,t),tn.init(e,t)}),wz=he("ZodCIDRv6",(e,t)=>{XD.init(e,t),tn.init(e,t)}),jz=he("ZodBase64",(e,t)=>{JD.init(e,t),tn.init(e,t)}),Nz=he("ZodBase64URL",(e,t)=>{eP.init(e,t),tn.init(e,t)}),Sz=he("ZodE164",(e,t)=>{tP.init(e,t),tn.init(e,t)}),kz=he("ZodJWT",(e,t)=>{sP.init(e,t),tn.init(e,t)}),AC=he("ZodNumber",(e,t)=>{KE.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(s,i,l)=>aC(e,s,i),e.gt=(s,i)=>e.check(S1(s,i)),e.gte=(s,i)=>e.check(Gp(s,i)),e.min=(s,i)=>e.check(Gp(s,i)),e.lt=(s,i)=>e.check(N1(s,i)),e.lte=(s,i)=>e.check(Yp(s,i)),e.max=(s,i)=>e.check(Yp(s,i)),e.int=s=>e.check(A1(s)),e.safe=s=>e.check(A1(s)),e.positive=s=>e.check(S1(0,s)),e.nonnegative=s=>e.check(Gp(0,s)),e.negative=s=>e.check(N1(0,s)),e.nonpositive=s=>e.check(Yp(0,s)),e.multipleOf=(s,i)=>e.check(k1(s,i)),e.step=(s,i)=>e.check(k1(s,i)),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 Ez(e){return n4(AC,e)}const Cz=he("ZodNumberFormat",(e,t)=>{aP.init(e,t),AC.init(e,t)});function A1(e){return s4(Cz,e)}const Az=he("ZodBoolean",(e,t)=>{rP.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>rC(e,n,s)});function Un(e){return a4(Az,e)}const Tz=he("ZodNull",(e,t)=>{iP.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>iC(e,n,s)});function Mz(e){return r4(Tz,e)}const Rz=he("ZodUnknown",(e,t)=>{oP.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>lC()});function ra(){return i4(Rz)}const _z=he("ZodNever",(e,t)=>{lP.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>oC(e,n,s)});function TC(e){return o4(_z,e)}const Iz=he("ZodArray",(e,t)=>{cP.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>hC(e,n,s,i),e.element=t.element,e.min=(n,s)=>e.check(jf(n,s)),e.nonempty=n=>e.check(jf(1,n)),e.max=(n,s)=>e.check(tC(n,s)),e.length=(n,s)=>e.check(nC(n,s)),e.unwrap=()=>e.element});function ol(e,t){return x4(Iz,e,t)}const MC=he("ZodObject",(e,t)=>{dP.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>mC(e,n,s,i),pt(e,"shape",()=>t.shape),e.keyof=()=>_C(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:ra()}),e.loose=()=>e.clone({...e._zod.def,catchall:ra()}),e.strict=()=>e.clone({...e._zod.def,catchall:TC()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>M5(e,n),e.safeExtend=n=>R5(e,n),e.merge=n=>_5(e,n),e.pick=n=>A5(e,n),e.omit=n=>T5(e,n),e.partial=(...n)=>I5(IC,e,n[0]),e.required=(...n)=>O5(OC,e,n[0])});function It(e,t){const n={type:"object",shape:e??{},...Ue(t)};return new MC(n)}function Bt(e,t){return new MC({type:"object",shape:e,catchall:TC(),...Ue(t)})}const RC=he("ZodUnion",(e,t)=>{QE.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>pC(e,n,s,i),e.options=t.options});function Fn(e,t){return new RC({type:"union",options:e,...Ue(t)})}const Oz=he("ZodDiscriminatedUnion",(e,t)=>{RC.init(e,t),fP.init(e,t)});function Dz(e,t,n){return new Oz({type:"union",options:t,discriminator:e,...Ue(n)})}const Pz=he("ZodIntersection",(e,t)=>{hP.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>gC(e,n,s,i)});function zz(e,t){return new Pz({type:"intersection",left:e,right:t})}const Lz=he("ZodRecord",(e,t)=>{mP.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>vC(e,n,s,i),e.keyType=t.keyType,e.valueType=t.valueType});function Oc(e,t,n){return new Lz({type:"record",keyType:e,valueType:t,...Ue(n)})}const lv=he("ZodEnum",(e,t)=>{pP.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(s,i,l)=>cC(e,s,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(s,i)=>{const l={};for(const c of s)if(n.has(c))l[c]=t.entries[c];else throw new Error(`Key ${c} not found in enum`);return new lv({...t,checks:[],...Ue(i),entries:l})},e.exclude=(s,i)=>{const l={...t.entries};for(const c of s)if(n.has(c))delete l[c];else throw new Error(`Key ${c} not found in enum`);return new lv({...t,checks:[],...Ue(i),entries:l})}});function _C(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(s=>[s,s])):e;return new lv({type:"enum",entries:n,...Ue(t)})}const $z=he("ZodLiteral",(e,t)=>{gP.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>uC(e,n,s),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 Ze(e,t){return new $z({type:"literal",values:Array.isArray(e)?e:[e],...Ue(t)})}const Uz=he("ZodTransform",(e,t)=>{vP.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>fC(e,n),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new OE(e.constructor.name);n.addIssue=l=>{if(typeof l=="string")n.issues.push(Ic(l,n.value,t));else{const c=l;c.fatal&&(c.continue=!1),c.code??(c.code="custom"),c.input??(c.input=n.value),c.inst??(c.inst=e),n.issues.push(Ic(c))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(l=>(n.value=l,n)):(n.value=i,n)}});function Bz(e){return new Uz({type:"transform",transform:e})}const IC=he("ZodOptional",(e,t)=>{eC.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Cy(e,n,s,i),e.unwrap=()=>e._zod.def.innerType});function T1(e){return new IC({type:"optional",innerType:e})}const Vz=he("ZodExactOptional",(e,t)=>{yP.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Cy(e,n,s,i),e.unwrap=()=>e._zod.def.innerType});function Fz(e){return new Vz({type:"optional",innerType:e})}const Hz=he("ZodNullable",(e,t)=>{xP.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>yC(e,n,s,i),e.unwrap=()=>e._zod.def.innerType});function M1(e){return new Hz({type:"nullable",innerType:e})}const qz=he("ZodDefault",(e,t)=>{bP.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>bC(e,n,s,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Zz(e,t){return new qz({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():LE(t)}})}const Wz=he("ZodPrefault",(e,t)=>{wP.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>wC(e,n,s,i),e.unwrap=()=>e._zod.def.innerType});function Yz(e,t){return new Wz({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():LE(t)}})}const OC=he("ZodNonOptional",(e,t)=>{jP.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>xC(e,n,s,i),e.unwrap=()=>e._zod.def.innerType});function Gz(e,t){return new OC({type:"nonoptional",innerType:e,...Ue(t)})}const Kz=he("ZodCatch",(e,t)=>{NP.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>jC(e,n,s,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Xz(e,t){return new Kz({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Jz=he("ZodPipe",(e,t)=>{SP.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>NC(e,n,s,i),e.in=t.in,e.out=t.out});function R1(e,t){return new Jz({type:"pipe",in:e,out:t})}const Qz=he("ZodReadonly",(e,t)=>{kP.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>SC(e,n,s,i),e.unwrap=()=>e._zod.def.innerType});function e3(e){return new Qz({type:"readonly",innerType:e})}const t3=he("ZodLazy",(e,t)=>{EP.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>kC(e,n,s,i),e.unwrap=()=>e._zod.def.getter()});function n3(e){return new t3({type:"lazy",getter:e})}const Ay=he("ZodCustom",(e,t)=>{CP.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>dC(e,n)});function DC(e,t){return b4(Ay,e??(()=>!0),t)}function s3(e,t={}){return w4(Ay,e,t)}function a3(e){return j4(e)}function Cf(e,t={}){const n=new Ay({type:"custom",check:"custom",fn:s=>s instanceof e,abort:!0,...Ue(t)});return n._zod.bag.Class=e,n._zod.check=s=>{s.value instanceof e||s.issues.push({code:"invalid_type",expected:e.name,input:s.value,inst:n,path:[...n._zod.def.path??[]]})},n}var Dc;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const l={};for(const c of i)l[c]=c;return l},e.getValidEnumValues=i=>{const l=e.objectKeys(i).filter(d=>typeof i[i[d]]!="number"),c={};for(const d of l)c[d]=i[d];return e.objectValues(c)},e.objectValues=i=>e.objectKeys(i).map(function(l){return i[l]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const l=[];for(const c in i)Object.prototype.hasOwnProperty.call(i,c)&&l.push(c);return l},e.find=(i,l)=>{for(const c of i)if(l(c))return c},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function s(i,l=" | "){return i.map(c=>typeof c=="string"?`'${c}'`:c).join(l)}e.joinValues=s,e.jsonStringifyReplacer=(i,l)=>typeof l=="bigint"?l.toString():l})(Dc||(Dc={}));var _1;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(_1||(_1={}));Dc.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);Dc.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 Af extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};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(l){return l.message},s={_errors:[]},i=l=>{for(const c of l.issues)if(c.code==="invalid_union")c.unionErrors.map(i);else if(c.code==="invalid_return_type")i(c.returnTypeError);else if(c.code==="invalid_arguments")i(c.argumentsError);else if(c.path.length===0)s._errors.push(n(c));else{let d=s,h=0;for(;h<c.path.length;){const m=c.path[h];h===c.path.length-1?(d[m]=d[m]||{_errors:[]},d[m]._errors.push(n(c))):d[m]=d[m]||{_errors:[]},d=d[m],h++}}};return i(this),s}static assert(t){if(!(t instanceof Af))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Dc.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n=Object.create(null),s=[];for(const i of this.issues)if(i.path.length>0){const l=i.path[0];n[l]=n[l]||[],n[l].push(t(i))}else s.push(t(i));return{formErrors:s,fieldErrors:n}}get formErrors(){return this.flatten()}}Af.create=e=>new Af(e);var I1;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(I1||(I1={}));var nt;(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"})(nt||(nt={}));class O1 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 D1=10,r3=13,ii=32;function Kp(e){}function i3(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=Kp,onError:n=Kp,onRetry:s=Kp,onComment:i}=e;let l="",c=!0,d,h="",m=0,p;function y(A){if(c){c=!1,x(A);return}const S=l===""?A:l+A;l=w(S)}function x(A){A.charCodeAt(0)===239&&A.charCodeAt(1)===187&&A.charCodeAt(2)===191&&(A=A.slice(3));const S=l===""?A:l+A;l=w(S)}function w(A){let S=0;if(A.indexOf("\r")===-1){let M=A.indexOf(`
|
|
50
|
-
`,S);for(;M!==-1;){if(S===M){m>0&&t({id:d,event:p,data:h}),d=void 0,h="",m=0,p=void 0,S=M+1,M=A.indexOf(`
|
|
51
|
-
`,S);continue}const C=A.charCodeAt(S);if(P1(A,S,C)){const I=A.charCodeAt(S+5)===ii?S+6:S+5,R=A.slice(I,M);if(m===0&&A.charCodeAt(M+1)===D1){t({id:d,event:p,data:R}),d=void 0,h="",p=void 0,S=M+2,M=A.indexOf(`
|
|
52
|
-
`,S);continue}h=m===0?R:`${h}
|
|
53
|
-
${R}`,m++}else z1(A,S,C)?p=A.slice(A.charCodeAt(S+6)===ii?S+7:S+6,M)||void 0:j(A,S,M);S=M+1,M=A.indexOf(`
|
|
54
|
-
`,S)}return A.slice(S)}for(;S<A.length;){const M=A.indexOf("\r",S),C=A.indexOf(`
|
|
55
|
-
`,S);let I=-1;if(M!==-1&&C!==-1?I=M<C?M:C:M!==-1?M===A.length-1?I=-1:I=M:C!==-1&&(I=C),I===-1)break;j(A,S,I),S=I+1,A.charCodeAt(S-1)===r3&&A.charCodeAt(S)===D1&&S++}return A.slice(S)}function j(A,S,M){if(S===M){k();return}const C=A.charCodeAt(S);if(P1(A,S,C)){const _=A.charCodeAt(S+5)===ii?S+6:S+5,U=A.slice(_,M);h=m===0?U:`${h}
|
|
56
|
-
${U}`,m++;return}if(z1(A,S,C)){p=A.slice(A.charCodeAt(S+6)===ii?S+7:S+6,M)||void 0;return}if(C===105&&A.charCodeAt(S+1)===100&&A.charCodeAt(S+2)===58){const _=A.slice(A.charCodeAt(S+3)===ii?S+4:S+3,M);d=_.includes("\0")?void 0:_;return}if(C===58){if(i){const _=A.slice(S,M);i(_.slice(A.charCodeAt(S+1)===ii?2:1))}return}const I=A.slice(S,M),R=I.indexOf(":");if(R===-1){N(I,"",I);return}const D=I.slice(0,R),z=I.charCodeAt(R+1)===ii?2:1,O=I.slice(R+z);N(D,O,I)}function N(A,S,M){switch(A){case"event":p=S||void 0;break;case"data":h=m===0?S:`${h}
|
|
57
|
-
${S}`,m++;break;case"id":d=S.includes("\0")?void 0:S;break;case"retry":/^\d+$/.test(S)?s(parseInt(S,10)):n(new O1(`Invalid \`retry\` value: "${S}"`,{type:"invalid-retry",value:S,line:M}));break;default:n(new O1(`Unknown field "${A.length>20?`${A.slice(0,20)}…`:A}"`,{type:"unknown-field",field:A,value:S,line:M}));break}}function k(){m>0&&t({id:d,event:p,data:h}),d=void 0,h="",m=0,p=void 0}function E(A={}){l&&A.consume&&j(l,0,l.length),c=!0,d=void 0,h="",m=0,p=void 0,l=""}return{feed:y,reset:E}}function P1(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 z1(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 o3 extends TransformStream{constructor({onError:t,onRetry:n,onComment:s}={}){let i;super({start(l){i=i3({onEvent:c=>{l.enqueue(c)},onError(c){t==="terminate"?l.error(c):typeof t=="function"&&t(c)},onRetry:n,onComment:s})},transform(l){i.feed(l)}})}}var Kc=({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:s="-"}={})=>{const i=()=>{const l=n.length,c=new Array(t);for(let d=0;d<t;d++)c[d]=n[Math.random()*l|0];return c.join("")};if(e==null)return i;if(n.includes(s))throw new x5({argument:"separator",message:`The separator "${s}" must not be part of the alphabet "${n}".`});return()=>`${e}${s}${i()}`},l3=Kc();function vo(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((n,s)=>{t[s.toLowerCase()]=n});else{Array.isArray(e)||(e=Object.entries(e));for(const[n,s]of e)s!=null&&(t[n.toLowerCase()]=s)}return t}var c3=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,u3=/"(?: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 L1(e){const t=JSON.parse(e);return t===null||typeof t!="object"||c3.test(e)===!1&&u3.test(e)===!1?t:d3(t)}function d3(e){let t=[e];for(;t.length;){const n=t;t=[];for(const s of n){if(Object.prototype.hasOwnProperty.call(s,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(s,"constructor")&&s.constructor!==null&&typeof s.constructor=="object"&&Object.prototype.hasOwnProperty.call(s.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const i in s){const l=s[i];l&&typeof l=="object"&&t.push(l)}}}return e}function f3(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return L1(e)}try{return L1(e)}finally{Error.stackTraceLimit=t}}function Ty(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 s of Object.keys(n))n[s]=oi(n[s])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(oi):oi(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(oi)),e.allOf!=null&&(e.allOf=e.allOf.map(oi)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(oi));const{definitions:t}=e;if(t!=null)for(const n of Object.keys(t))t[n]=oi(t[n]);return e}function oi(e){return typeof e=="boolean"?e:Ty(e)}var h3=Symbol("Let zodToJsonSchema decide on which parser to use"),$1={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"},m3=e=>typeof e=="string"?{...$1,name:e}:{...$1,...e};function ps(){return{}}function p3(e,t){var n,s,i;const l={type:"array"};return(n=e.type)!=null&&n._def&&((i=(s=e.type)==null?void 0:s._def)==null?void 0:i.typeName)!==nt.ZodAny&&(l.items=Ct(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(l.minItems=e.minLength.value),e.maxLength&&(l.maxItems=e.maxLength.value),e.exactLength&&(l.minItems=e.exactLength.value,l.maxItems=e.exactLength.value),l}function g3(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 v3(){return{type:"boolean"}}function PC(e,t){return Ct(e.type._def,t)}var y3=(e,t)=>Ct(e.innerType._def,t);function zC(e,t,n){const s=n??t.dateStrategy;if(Array.isArray(s))return{anyOf:s.map((i,l)=>zC(e,t,i))};switch(s){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return x3(e)}}var x3=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 b3(e,t){return{...Ct(e.innerType._def,t),default:e.defaultValue()}}function w3(e,t){return t.effectStrategy==="input"?Ct(e.schema._def,t):ps()}function j3(e){return{type:"string",enum:Array.from(e.values)}}var N3=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function S3(e,t){const n=[Ct(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),Ct(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(i=>!!i),s=[];return n.forEach(i=>{if(N3(i))s.push(...i.allOf);else{let l=i;if("additionalProperties"in i&&i.additionalProperties===!1){const{additionalProperties:c,...d}=i;l=d}s.push(l)}}),s.length?{allOf:s}:void 0}function k3(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 Xp=void 0,$s={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:()=>(Xp===void 0&&(Xp=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Xp),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 LC(e,t){const n={type:"string"};if(e.checks)for(const s of e.checks)switch(s.kind){case"min":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,s.value):s.value;break;case"max":n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,s.value):s.value;break;case"email":switch(t.emailStrategy){case"format:email":Us(n,"email",s.message,t);break;case"format:idn-email":Us(n,"idn-email",s.message,t);break;case"pattern:zod":Ln(n,$s.email,s.message,t);break}break;case"url":Us(n,"uri",s.message,t);break;case"uuid":Us(n,"uuid",s.message,t);break;case"regex":Ln(n,s.regex,s.message,t);break;case"cuid":Ln(n,$s.cuid,s.message,t);break;case"cuid2":Ln(n,$s.cuid2,s.message,t);break;case"startsWith":Ln(n,RegExp(`^${Jp(s.value,t)}`),s.message,t);break;case"endsWith":Ln(n,RegExp(`${Jp(s.value,t)}$`),s.message,t);break;case"datetime":Us(n,"date-time",s.message,t);break;case"date":Us(n,"date",s.message,t);break;case"time":Us(n,"time",s.message,t);break;case"duration":Us(n,"duration",s.message,t);break;case"length":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,s.value):s.value,n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,s.value):s.value;break;case"includes":{Ln(n,RegExp(Jp(s.value,t)),s.message,t);break}case"ip":{s.version!=="v6"&&Us(n,"ipv4",s.message,t),s.version!=="v4"&&Us(n,"ipv6",s.message,t);break}case"base64url":Ln(n,$s.base64url,s.message,t);break;case"jwt":Ln(n,$s.jwt,s.message,t);break;case"cidr":{s.version!=="v6"&&Ln(n,$s.ipv4Cidr,s.message,t),s.version!=="v4"&&Ln(n,$s.ipv6Cidr,s.message,t);break}case"emoji":Ln(n,$s.emoji(),s.message,t);break;case"ulid":{Ln(n,$s.ulid,s.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{Us(n,"binary",s.message,t);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{Ln(n,$s.base64,s.message,t);break}}break}case"nanoid":Ln(n,$s.nanoid,s.message,t)}return n}function Jp(e,t){return t.patternStrategy==="escape"?C3(e):e}var E3=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function C3(e){let t="";for(let n=0;n<e.length;n++)E3.has(e[n])||(t+="\\"),t+=e[n];return t}function Us(e,t,n,s){var i;e.format||(i=e.anyOf)!=null&&i.some(l=>l.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&s.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function Ln(e,t,n,s){var i;e.pattern||(i=e.allOf)!=null&&i.some(l=>l.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:U1(t,s),...n&&s.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=U1(t,s)}function U1(e,t){var n;if(!t.applyRegexFlags||!e.flags)return e.source;const s={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},i=s.i?e.source.toLowerCase():e.source;let l="",c=!1,d=!1,h=!1;for(let m=0;m<i.length;m++){if(c){l+=i[m],c=!1;continue}if(s.i){if(d){if(i[m].match(/[a-z]/)){h?(l+=i[m],l+=`${i[m-2]}-${i[m]}`.toUpperCase(),h=!1):i[m+1]==="-"&&((n=i[m+2])!=null&&n.match(/[a-z]/))?(l+=i[m],h=!0):l+=`${i[m]}${i[m].toUpperCase()}`;continue}}else if(i[m].match(/[a-z]/)){l+=`[${i[m]}${i[m].toUpperCase()}]`;continue}}if(s.m){if(i[m]==="^"){l+=`(^|(?<=[\r
|
|
58
|
-
]))`;continue}else if(i[m]==="$"){l+=`($|(?=[\r
|
|
59
|
-
]))`;continue}}if(s.s&&i[m]==="."){l+=d?`${i[m]}\r
|
|
60
|
-
`:`[${i[m]}\r
|
|
61
|
-
]`;continue}l+=i[m],i[m]==="\\"?c=!0:d&&i[m]==="]"?d=!1:!d&&i[m]==="["&&(d=!0)}try{new RegExp(l)}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 l}function $C(e,t){var n,s,i,l,c,d;const h={type:"object",additionalProperties:(n=Ct(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((s=e.keyType)==null?void 0:s._def.typeName)===nt.ZodString&&((i=e.keyType._def.checks)!=null&&i.length)){const{type:m,...p}=LC(e.keyType._def,t);return{...h,propertyNames:p}}else{if(((l=e.keyType)==null?void 0:l._def.typeName)===nt.ZodEnum)return{...h,propertyNames:{enum:e.keyType._def.values}};if(((c=e.keyType)==null?void 0:c._def.typeName)===nt.ZodBranded&&e.keyType._def.type._def.typeName===nt.ZodString&&((d=e.keyType._def.type._def.checks)!=null&&d.length)){const{type:m,...p}=PC(e.keyType._def,t);return{...h,propertyNames:p}}}return h}function A3(e,t){if(t.mapStrategy==="record")return $C(e,t);const n=Ct(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||ps(),s=Ct(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||ps();return{type:"array",maxItems:125,items:{type:"array",items:[n,s],minItems:2,maxItems:2}}}function T3(e){const t=e.values,s=Object.keys(e.values).filter(l=>typeof t[t[l]]!="number").map(l=>t[l]),i=Array.from(new Set(s.map(l=>typeof l)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:s}}function M3(){return{not:ps()}}function R3(){return{type:"null"}}var cv={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function _3(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(s=>s._def.typeName in cv&&(!s._def.checks||!s._def.checks.length))){const s=n.reduce((i,l)=>{const c=cv[l._def.typeName];return c&&!i.includes(c)?[...i,c]:i},[]);return{type:s.length>1?s:s[0]}}else if(n.every(s=>s._def.typeName==="ZodLiteral"&&!s.description)){const s=n.reduce((i,l)=>{const c=typeof l._def.value;switch(c){case"string":case"number":case"boolean":return[...i,c];case"bigint":return[...i,"integer"];case"object":if(l._def.value===null)return[...i,"null"];default:return i}},[]);if(s.length===n.length){const i=s.filter((l,c,d)=>d.indexOf(l)===c);return{type:i.length>1?i:i[0],enum:n.reduce((l,c)=>l.includes(c._def.value)?l:[...l,c._def.value],[])}}}else if(n.every(s=>s._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((s,i)=>[...s,...i._def.values.filter(l=>!s.includes(l))],[])};return I3(e,t)}var I3=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((s,i)=>Ct(s._def,{...t,currentPath:[...t.currentPath,"anyOf",`${i}`]})).filter(s=>!!s&&(!t.strictUnions||typeof s=="object"&&Object.keys(s).length>0));return n.length?{anyOf:n}:void 0};function O3(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[cv[e.innerType._def.typeName],"null"]};const n=Ct(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function D3(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 P3(e,t){const n={type:"object",properties:{}},s=[],i=e.shape();for(const c in i){let d=i[c];if(d===void 0||d._def===void 0)continue;const h=L3(d),m=Ct(d._def,{...t,currentPath:[...t.currentPath,"properties",c],propertyPath:[...t.currentPath,"properties",c]});m!==void 0&&(n.properties[c]=m,h||s.push(c))}s.length&&(n.required=s);const l=z3(e,t);return l!==void 0&&(n.additionalProperties=l),n}function z3(e,t){if(e.catchall._def.typeName!=="ZodNever")return Ct(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 L3(e){try{return e.isOptional()}catch{return!0}}var $3=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return Ct(e.innerType._def,t);const s=Ct(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return s?{anyOf:[{not:ps()},s]}:ps()},U3=(e,t)=>{if(t.pipeStrategy==="input")return Ct(e.in._def,t);if(t.pipeStrategy==="output")return Ct(e.out._def,t);const n=Ct(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),s=Ct(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,s].filter(i=>i!==void 0)}};function B3(e,t){return Ct(e.type._def,t)}function V3(e,t){const s={type:"array",uniqueItems:!0,items:Ct(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(s.minItems=e.minSize.value),e.maxSize&&(s.maxItems=e.maxSize.value),s}function F3(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,s)=>Ct(n._def,{...t,currentPath:[...t.currentPath,"items",`${s}`]})).reduce((n,s)=>s===void 0?n:[...n,s],[]),additionalItems:Ct(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,s)=>Ct(n._def,{...t,currentPath:[...t.currentPath,"items",`${s}`]})).reduce((n,s)=>s===void 0?n:[...n,s],[])}}function H3(){return{not:ps()}}function q3(){return ps()}var Z3=(e,t)=>Ct(e.innerType._def,t),W3=(e,t,n)=>{switch(t){case nt.ZodString:return LC(e,n);case nt.ZodNumber:return D3(e);case nt.ZodObject:return P3(e,n);case nt.ZodBigInt:return g3(e);case nt.ZodBoolean:return v3();case nt.ZodDate:return zC(e,n);case nt.ZodUndefined:return H3();case nt.ZodNull:return R3();case nt.ZodArray:return p3(e,n);case nt.ZodUnion:case nt.ZodDiscriminatedUnion:return _3(e,n);case nt.ZodIntersection:return S3(e,n);case nt.ZodTuple:return F3(e,n);case nt.ZodRecord:return $C(e,n);case nt.ZodLiteral:return k3(e);case nt.ZodEnum:return j3(e);case nt.ZodNativeEnum:return T3(e);case nt.ZodNullable:return O3(e,n);case nt.ZodOptional:return $3(e,n);case nt.ZodMap:return A3(e,n);case nt.ZodSet:return V3(e,n);case nt.ZodLazy:return()=>e.getter()._def;case nt.ZodPromise:return B3(e,n);case nt.ZodNaN:case nt.ZodNever:return M3();case nt.ZodEffects:return w3(e,n);case nt.ZodAny:return ps();case nt.ZodUnknown:return q3();case nt.ZodDefault:return b3(e,n);case nt.ZodBranded:return PC(e,n);case nt.ZodReadonly:return Z3(e,n);case nt.ZodCatch:return y3(e,n);case nt.ZodPipeline:return U3(e,n);case nt.ZodFunction:case nt.ZodVoid:case nt.ZodSymbol:return;default:return(s=>{})()}},Y3=(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 Ct(e,t,n=!1){var s;const i=t.seen.get(e);if(t.override){const h=(s=t.override)==null?void 0:s.call(t,e,t,i,n);if(h!==h3)return h}if(i&&!n){const h=G3(i,t);if(h!==void 0)return h}const l={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,l);const c=W3(e,e.typeName,t),d=typeof c=="function"?Ct(c(),t):c;if(d&&K3(e,t,d),t.postProcess){const h=t.postProcess(d,e,t);return l.jsonSchema=d,h}return l.jsonSchema=d,d}var G3=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:Y3(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((n,s)=>t.currentPath[s]===n)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),ps()):t.$refStrategy==="seen"?ps():void 0}},K3=(e,t,n)=>(e.description&&(n.description=e.description),n),X3=e=>{const t=m3(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(([s,i])=>[i._def,{def:i._def,path:[...t.basePath,t.definitionPath,s],jsonSchema:void 0}]))}},J3=(e,t)=>{var n;const s=X3(t);let i=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((m,[p,y])=>{var x;return{...m,[p]:(x=Ct(y._def,{...s,currentPath:[...s.basePath,s.definitionPath,p]},!0))!=null?x:ps()}},{}):void 0;const l=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,c=(n=Ct(e._def,l===void 0?s:{...s,currentPath:[...s.basePath,s.definitionPath,l]},!1))!=null?n:ps(),d=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;d!==void 0&&(c.title=d);const h=l===void 0?i?{...c,[s.definitionPath]:i}:c:{$ref:[...s.$refStrategy==="relative"?[]:s.basePath,s.definitionPath,l].join("/"),[s.definitionPath]:{...i,[l]:c}};return h.$schema="http://json-schema.org/draft-07/schema#",h},uv=Symbol.for("vercel.ai.schema");function Q3(e){let t;return()=>(t==null&&(t=e()),t)}function dh(e,{validate:t}={}){return{[uv]:!0,_type:void 0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function eL(e){return typeof e=="object"&&e!==null&&uv in e&&e[uv]===!0&&"jsonSchema"in e&&"validate"in e}function My(e){return e==null?dh({properties:{},additionalProperties:!1}):eL(e)?e:"~standard"in e?e["~standard"].vendor==="zod"?UC(e):tL(e):e()}function tL(e){return dh(()=>Ty(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 Qo({value:t,cause:n.issues})}}})}function nL(e,t){var n;const s=(n=void 0)!=null?n:!1;return dh(()=>J3(e,{$refStrategy:s?"root":"none"}),{validate:async i=>{const l=await e.safeParseAsync(i);return l.success?{success:!0,value:l.data}:{success:!1,error:l.error}}})}function sL(e,t){var n;const s=(n=void 0)!=null?n:!1;return dh(()=>Ty(B4(e,{target:"draft-7",io:"input",reused:s?"ref":"inline"})),{validate:async i=>{const l=await EC(e,i);return l.success?{success:!0,value:l.data}:{success:!1,error:l.error}}})}function aL(e){return"_zod"in e}function UC(e,t){return aL(e)?sL(e):nL(e)}async function B1({value:e,schema:t,context:n}){const s=await Pc({value:e,schema:t,context:n});if(!s.success)throw Qo.wrap({value:e,cause:s.error,context:n});return s.value}async function Pc({value:e,schema:t,context:n}){const s=My(t);try{if(s.validate==null)return{success:!0,value:e,rawValue:e};const i=await s.validate(e);return i.success?{success:!0,value:i.value,rawValue:e}:{success:!1,error:Qo.wrap({value:e,cause:i.error,context:n}),rawValue:e}}catch(i){return{success:!1,error:Qo.wrap({value:e,cause:i,context:n}),rawValue:e}}}async function Ni({text:e,schema:t}){try{const n=f3(e);return t==null?{success:!0,value:n,rawValue:n}:await Pc({value:n,schema:t})}catch(n){return{success:!1,error:o1.isInstance(n)?n:new o1({text:e,cause:n}),rawValue:void 0}}}function rL({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new o3).pipeThrough(new TransformStream({async transform({data:n},s){n!=="[DONE]"&&s.enqueue(await Ni({text:n,schema:t}))}}))}async function xr(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var iL=Object.defineProperty,oL=(e,t)=>{for(var n in t)iL(e,n,{get:t[n],enumerable:!0})},BC="AI_NoObjectGeneratedError",VC=`vercel.ai.error.${BC}`,lL=Symbol.for(VC),FC,Sr=class extends fa{constructor({message:e="No object generated.",cause:t,text:n,response:s,usage:i,finishReason:l}){super({name:BC,message:e,cause:t}),this[FC]=!0,this.text=n,this.response=s,this.usage=i,this.finishReason=l}static isInstance(e){return fa.hasMarker(e,VC)}};FC=lL;var HC="AI_UIMessageStreamError",qC=`vercel.ai.error.${HC}`,cL=Symbol.for(qC),ZC,yo=class extends fa{constructor({chunkType:e,chunkId:t,message:n}){super({name:HC,message:n}),this[ZC]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return fa.hasMarker(e,qC)}};ZC=cL;var WC=Fn([Me(),Cf(Uint8Array),Cf(ArrayBuffer),DC(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]),zc=n3(()=>Fn([Mz(),Me(),Ez(),Un(),Oc(Me(),zc.optional()),ol(zc)])),ut=Oc(Me(),Oc(Me(),zc.optional())),YC=It({type:Ze("text"),text:Me(),providerOptions:ut.optional()}),uL=It({type:Ze("image"),image:Fn([WC,Cf(URL)]),mediaType:Me().optional(),providerOptions:ut.optional()}),GC=It({type:Ze("file"),data:Fn([WC,Cf(URL)]),filename:Me().optional(),mediaType:Me(),providerOptions:ut.optional()}),dL=It({type:Ze("reasoning"),text:Me(),providerOptions:ut.optional()}),fL=It({type:Ze("tool-call"),toolCallId:Me(),toolName:Me(),input:ra(),providerOptions:ut.optional(),providerExecuted:Un().optional()}),hL=Dz("type",[It({type:Ze("text"),value:Me(),providerOptions:ut.optional()}),It({type:Ze("json"),value:zc,providerOptions:ut.optional()}),It({type:Ze("execution-denied"),reason:Me().optional(),providerOptions:ut.optional()}),It({type:Ze("error-text"),value:Me(),providerOptions:ut.optional()}),It({type:Ze("error-json"),value:zc,providerOptions:ut.optional()}),It({type:Ze("content"),value:ol(Fn([It({type:Ze("text"),text:Me(),providerOptions:ut.optional()}),It({type:Ze("media"),data:Me(),mediaType:Me()}),It({type:Ze("file-data"),data:Me(),mediaType:Me(),filename:Me().optional(),providerOptions:ut.optional()}),It({type:Ze("file-url"),url:Me(),providerOptions:ut.optional()}),It({type:Ze("file-id"),fileId:Fn([Me(),Oc(Me(),Me())]),providerOptions:ut.optional()}),It({type:Ze("image-data"),data:Me(),mediaType:Me(),providerOptions:ut.optional()}),It({type:Ze("image-url"),url:Me(),providerOptions:ut.optional()}),It({type:Ze("image-file-id"),fileId:Fn([Me(),Oc(Me(),Me())]),providerOptions:ut.optional()}),It({type:Ze("custom"),providerOptions:ut.optional()})]))})]),KC=It({type:Ze("tool-result"),toolCallId:Me(),toolName:Me(),output:hL,providerOptions:ut.optional()}),mL=It({type:Ze("tool-approval-request"),approvalId:Me(),toolCallId:Me()}),pL=It({type:Ze("tool-approval-response"),approvalId:Me(),approved:Un(),reason:Me().optional()}),gL=It({role:Ze("system"),content:Me(),providerOptions:ut.optional()}),vL=It({role:Ze("user"),content:Fn([Me(),ol(Fn([YC,uL,GC]))]),providerOptions:ut.optional()}),yL=It({role:Ze("assistant"),content:Fn([Me(),ol(Fn([YC,GC,dL,fL,KC,mL]))]),providerOptions:ut.optional()}),xL=It({role:Ze("tool"),content:ol(Fn([KC,pL])),providerOptions:ut.optional()});Fn([gL,vL,yL,xL]);function XC(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 s in t)if(Object.prototype.hasOwnProperty.call(t,s)){const i=t[s];if(i===void 0)continue;const l=s in e?e[s]:void 0,c=i!==null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),d=l!=null&&typeof l=="object"&&!Array.isArray(l)&&!(l instanceof Date)&&!(l instanceof RegExp);c&&d?n[s]=XC(l,i):n[s]=i}return n}var bL={};oL(bL,{array:()=>SL,choice:()=>kL,json:()=>EL,object:()=>NL,text:()=>jL});function wL(e){const t=["ROOT"];let n=-1,s=null;function i(h,m,p){switch(h){case'"':{n=m,t.pop(),t.push(p),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=m,s=m,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=m,t.pop(),t.push(p),t.push("INSIDE_NUMBER");break}case"{":{n=m,t.pop(),t.push(p),t.push("INSIDE_OBJECT_START");break}case"[":{n=m,t.pop(),t.push(p),t.push("INSIDE_ARRAY_START");break}}}function l(h,m){switch(h){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=m,t.pop();break}}}function c(h,m){switch(h){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=m,t.pop();break}}}for(let h=0;h<e.length;h++){const m=e[h];switch(t[t.length-1]){case"ROOT":i(m,h,"FINISH");break;case"INSIDE_OBJECT_START":{switch(m){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=h,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{m==='"'&&(t.pop(),t.push("INSIDE_OBJECT_KEY"));break}case"INSIDE_OBJECT_KEY":{m==='"'&&(t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY"));break}case"INSIDE_OBJECT_AFTER_KEY":{m===":"&&(t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE"));break}case"INSIDE_OBJECT_BEFORE_VALUE":{i(m,h,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{l(m,h);break}case"INSIDE_STRING":{switch(m){case'"':{t.pop(),n=h;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=h}break}case"INSIDE_ARRAY_START":{m==="]"?(n=h,t.pop()):(n=h,i(m,h,"INSIDE_ARRAY_AFTER_VALUE"));break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(m){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=h,t.pop();break}default:{n=h;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{i(m,h,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=h;break}case"INSIDE_NUMBER":{switch(m){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=h;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&c(m,h),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&l(m,h);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&l(m,h);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&c(m,h);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const y=e.substring(s,h+1);!"false".startsWith(y)&&!"true".startsWith(y)&&!"null".startsWith(y)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?l(m,h):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&c(m,h)):n=h;break}}}let d=e.slice(0,n+1);for(let h=t.length-1;h>=0;h--)switch(t[h]){case"INSIDE_STRING":{d+='"';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":{d+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{d+="]";break}case"INSIDE_LITERAL":{const p=e.substring(s,e.length);"true".startsWith(p)?d+="true".slice(p.length):"false".startsWith(p)?d+="false".slice(p.length):"null".startsWith(p)&&(d+="null".slice(p.length))}}return d}async function Xc(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await Ni({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await Ni({text:wL(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var jL=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),NL=({schema:e,name:t,description:n})=>{const s=My(e);return{name:"object",responseFormat:xr(s.jsonSchema).then(i=>({type:"json",schema:i,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:i},l){const c=await Ni({text:i});if(!c.success)throw new Sr({message:"No object generated: could not parse the response.",cause:c.error,text:i,response:l.response,usage:l.usage,finishReason:l.finishReason});const d=await Pc({value:c.value,schema:s});if(!d.success)throw new Sr({message:"No object generated: response did not match schema.",cause:d.error,text:i,response:l.response,usage:l.usage,finishReason:l.finishReason});return d.value},async parsePartialOutput({text:i}){const l=await Xc(i);switch(l.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:l.value}}},createElementStreamTransform(){}}},SL=({element:e,name:t,description:n})=>{const s=My(e);return{name:"array",responseFormat:xr(s.jsonSchema).then(i=>{const{$schema:l,...c}=i;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:i},l){const c=await Ni({text:i});if(!c.success)throw new Sr({message:"No object generated: could not parse the response.",cause:c.error,text:i,response:l.response,usage:l.usage,finishReason:l.finishReason});const d=c.value;if(d==null||typeof d!="object"||!("elements"in d)||!Array.isArray(d.elements))throw new Sr({message:"No object generated: response did not match schema.",cause:new Qo({value:d,cause:"response must be an object with an elements array"}),text:i,response:l.response,usage:l.usage,finishReason:l.finishReason});for(const h of d.elements){const m=await Pc({value:h,schema:s});if(!m.success)throw new Sr({message:"No object generated: response did not match schema.",cause:m.error,text:i,response:l.response,usage:l.usage,finishReason:l.finishReason})}return d.elements},async parsePartialOutput({text:i}){const l=await Xc(i);switch(l.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const c=l.value;if(c==null||typeof c!="object"||!("elements"in c)||!Array.isArray(c.elements))return;const d=l.state==="repaired-parse"&&c.elements.length>0?c.elements.slice(0,-1):c.elements,h=[];for(const m of d){const p=await Pc({value:m,schema:s});p.success&&h.push(p.value)}return{partial:h}}}},createElementStreamTransform(){let i=0;return new TransformStream({transform({partialOutput:l},c){if(l!=null)for(;i<l.length;i++)c.enqueue(l[i])}})}}},kL=({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:s},i){const l=await Ni({text:s});if(!l.success)throw new Sr({message:"No object generated: could not parse the response.",cause:l.error,text:s,response:i.response,usage:i.usage,finishReason:i.finishReason});const c=l.value;if(c==null||typeof c!="object"||!("result"in c)||typeof c.result!="string"||!e.includes(c.result))throw new Sr({message:"No object generated: response did not match schema.",cause:new Qo({value:c,cause:"response must be an object that contains a choice value."}),text:s,response:i.response,usage:i.usage,finishReason:i.finishReason});return c.result},async parsePartialOutput({text:s}){const i=await Xc(s);switch(i.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const l=i.value;if(l==null||typeof l!="object"||!("result"in l)||typeof l.result!="string")return;const c=e.filter(d=>d.startsWith(l.result));return i.state==="successful-parse"?c.includes(l.result)?{partial:l.result}:void 0:c.length===1?{partial:c[0]}:void 0}}},createElementStreamTransform(){}}),EL=({name:e,description:t}={})=>({name:"json",responseFormat:Promise.resolve({type:"json",...e!=null&&{name:e},...t!=null&&{description:t}}),async parseCompleteOutput({text:n},s){const i=await Ni({text:n});if(!i.success)throw new Sr({message:"No object generated: could not parse the response.",cause:i.error,text:n,response:s.response,usage:s.usage,finishReason:s.finishReason});return i.value},async parsePartialOutput({text:n}){const s=await Xc(n);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return s.value===void 0?void 0:{partial:s.value}}},createElementStreamTransform(){}});Kc({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 CL=Q3(()=>UC(Fn([Bt({type:Ze("text-start"),id:Me(),providerMetadata:ut.optional()}),Bt({type:Ze("text-delta"),id:Me(),delta:Me(),providerMetadata:ut.optional()}),Bt({type:Ze("text-end"),id:Me(),providerMetadata:ut.optional()}),Bt({type:Ze("error"),errorText:Me()}),Bt({type:Ze("tool-input-start"),toolCallId:Me(),toolName:Me(),providerExecuted:Un().optional(),providerMetadata:ut.optional(),dynamic:Un().optional(),title:Me().optional()}),Bt({type:Ze("tool-input-delta"),toolCallId:Me(),inputTextDelta:Me()}),Bt({type:Ze("tool-input-available"),toolCallId:Me(),toolName:Me(),input:ra(),providerExecuted:Un().optional(),providerMetadata:ut.optional(),dynamic:Un().optional(),title:Me().optional()}),Bt({type:Ze("tool-input-error"),toolCallId:Me(),toolName:Me(),input:ra(),providerExecuted:Un().optional(),providerMetadata:ut.optional(),dynamic:Un().optional(),errorText:Me(),title:Me().optional()}),Bt({type:Ze("tool-approval-request"),approvalId:Me(),toolCallId:Me()}),Bt({type:Ze("tool-output-available"),toolCallId:Me(),output:ra(),providerExecuted:Un().optional(),providerMetadata:ut.optional(),dynamic:Un().optional(),preliminary:Un().optional()}),Bt({type:Ze("tool-output-error"),toolCallId:Me(),errorText:Me(),providerExecuted:Un().optional(),providerMetadata:ut.optional(),dynamic:Un().optional()}),Bt({type:Ze("tool-output-denied"),toolCallId:Me()}),Bt({type:Ze("reasoning-start"),id:Me(),providerMetadata:ut.optional()}),Bt({type:Ze("reasoning-delta"),id:Me(),delta:Me(),providerMetadata:ut.optional()}),Bt({type:Ze("reasoning-end"),id:Me(),providerMetadata:ut.optional()}),Bt({type:Ze("source-url"),sourceId:Me(),url:Me(),title:Me().optional(),providerMetadata:ut.optional()}),Bt({type:Ze("source-document"),sourceId:Me(),mediaType:Me(),title:Me(),filename:Me().optional(),providerMetadata:ut.optional()}),Bt({type:Ze("file"),url:Me(),mediaType:Me(),providerMetadata:ut.optional()}),Bt({type:DC(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:Me().optional(),data:ra(),transient:Un().optional()}),Bt({type:Ze("start-step")}),Bt({type:Ze("finish-step")}),Bt({type:Ze("start"),messageId:Me().optional(),messageMetadata:ra().optional()}),Bt({type:Ze("finish"),finishReason:_C(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:ra().optional()}),Bt({type:Ze("abort"),reason:Me().optional()}),Bt({type:Ze("message-metadata"),messageMetadata:ra()})])));function AL(e){return e.type.startsWith("data-")}function dv(e){return e.type.startsWith("tool-")}function JC(e){return e.type==="dynamic-tool"}function Si(e){return dv(e)||JC(e)}function fv(e){return e.type.split("-").slice(1).join("-")}function QC(e){return JC(e)?e.toolName:fv(e)}function TL({lastMessage:e,messageId:t}){return{message:e?.role==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function ML({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:s,onError:i,onToolCall:l,onData:c}){return e.pipeThrough(new TransformStream({async transform(d,h){await s(async({state:m,write:p})=>{var y,x,w,j;function N(S){const C=m.message.parts.filter(Si).find(I=>I.toolCallId===S);if(C==null)throw new yo({chunkType:"tool-invocation",chunkId:S,message:`No tool invocation found for tool call ID "${S}".`});return C}function k(S){var M;const C=m.message.parts.find(D=>dv(D)&&D.toolCallId===S.toolCallId),I=S,R=C;if(C!=null){C.state=S.state,R.input=I.input,R.output=I.output,R.errorText=I.errorText,R.rawInput=I.rawInput,R.preliminary=I.preliminary,S.title!==void 0&&(R.title=S.title),R.providerExecuted=(M=I.providerExecuted)!=null?M:C.providerExecuted;const D=I.providerMetadata;if(D!=null)if(S.state==="output-available"||S.state==="output-error"){const z=C;z.resultProviderMetadata=D}else C.callProviderMetadata=D}else m.message.parts.push({type:`tool-${S.toolName}`,toolCallId:S.toolCallId,state:S.state,title:S.title,input:I.input,output:I.output,rawInput:I.rawInput,errorText:I.errorText,providerExecuted:I.providerExecuted,preliminary:I.preliminary,...I.providerMetadata!=null&&(S.state==="output-available"||S.state==="output-error")?{resultProviderMetadata:I.providerMetadata}:{},...I.providerMetadata!=null&&!(S.state==="output-available"||S.state==="output-error")?{callProviderMetadata:I.providerMetadata}:{}})}function E(S){var M,C;const I=m.message.parts.find(z=>z.type==="dynamic-tool"&&z.toolCallId===S.toolCallId),R=S,D=I;if(I!=null){I.state=S.state,D.toolName=S.toolName,D.input=R.input,D.output=R.output,D.errorText=R.errorText,D.rawInput=(M=R.rawInput)!=null?M:D.rawInput,D.preliminary=R.preliminary,S.title!==void 0&&(D.title=S.title),D.providerExecuted=(C=R.providerExecuted)!=null?C:I.providerExecuted;const z=R.providerMetadata;if(z!=null)if(S.state==="output-available"||S.state==="output-error"){const O=I;O.resultProviderMetadata=z}else I.callProviderMetadata=z}else m.message.parts.push({type:"dynamic-tool",toolName:S.toolName,toolCallId:S.toolCallId,state:S.state,input:R.input,output:R.output,errorText:R.errorText,preliminary:R.preliminary,providerExecuted:R.providerExecuted,title:S.title,...R.providerMetadata!=null&&(S.state==="output-available"||S.state==="output-error")?{resultProviderMetadata:R.providerMetadata}:{},...R.providerMetadata!=null&&!(S.state==="output-available"||S.state==="output-error")?{callProviderMetadata:R.providerMetadata}:{}})}async function A(S){if(S!=null){const M=m.message.metadata!=null?XC(m.message.metadata,S):S;t!=null&&await B1({value:M,schema:t,context:{field:"message.metadata",entityId:m.message.id}}),m.message.metadata=M}}switch(d.type){case"text-start":{const S={type:"text",text:"",providerMetadata:d.providerMetadata,state:"streaming"};m.activeTextParts[d.id]=S,m.message.parts.push(S),p();break}case"text-delta":{const S=m.activeTextParts[d.id];if(S==null)throw new yo({chunkType:"text-delta",chunkId:d.id,message:`Received text-delta for missing text part with ID "${d.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});S.text+=d.delta,S.providerMetadata=(y=d.providerMetadata)!=null?y:S.providerMetadata,p();break}case"text-end":{const S=m.activeTextParts[d.id];if(S==null)throw new yo({chunkType:"text-end",chunkId:d.id,message:`Received text-end for missing text part with ID "${d.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});S.state="done",S.providerMetadata=(x=d.providerMetadata)!=null?x:S.providerMetadata,delete m.activeTextParts[d.id],p();break}case"reasoning-start":{const S={type:"reasoning",text:"",providerMetadata:d.providerMetadata,state:"streaming"};m.activeReasoningParts[d.id]=S,m.message.parts.push(S),p();break}case"reasoning-delta":{const S=m.activeReasoningParts[d.id];if(S==null)throw new yo({chunkType:"reasoning-delta",chunkId:d.id,message:`Received reasoning-delta for missing reasoning part with ID "${d.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});S.text+=d.delta,S.providerMetadata=(w=d.providerMetadata)!=null?w:S.providerMetadata,p();break}case"reasoning-end":{const S=m.activeReasoningParts[d.id];if(S==null)throw new yo({chunkType:"reasoning-end",chunkId:d.id,message:`Received reasoning-end for missing reasoning part with ID "${d.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});S.providerMetadata=(j=d.providerMetadata)!=null?j:S.providerMetadata,S.state="done",delete m.activeReasoningParts[d.id],p();break}case"file":{m.message.parts.push({type:"file",mediaType:d.mediaType,url:d.url,...d.providerMetadata!=null?{providerMetadata:d.providerMetadata}:{}}),p();break}case"source-url":{m.message.parts.push({type:"source-url",sourceId:d.sourceId,url:d.url,title:d.title,providerMetadata:d.providerMetadata}),p();break}case"source-document":{m.message.parts.push({type:"source-document",sourceId:d.sourceId,mediaType:d.mediaType,title:d.title,filename:d.filename,providerMetadata:d.providerMetadata}),p();break}case"tool-input-start":{const S=m.message.parts.filter(dv);m.partialToolCalls[d.toolCallId]={text:"",toolName:d.toolName,index:S.length,dynamic:d.dynamic,title:d.title},d.dynamic?E({toolCallId:d.toolCallId,toolName:d.toolName,state:"input-streaming",input:void 0,providerExecuted:d.providerExecuted,title:d.title,providerMetadata:d.providerMetadata}):k({toolCallId:d.toolCallId,toolName:d.toolName,state:"input-streaming",input:void 0,providerExecuted:d.providerExecuted,title:d.title,providerMetadata:d.providerMetadata}),p();break}case"tool-input-delta":{const S=m.partialToolCalls[d.toolCallId];if(S==null)throw new yo({chunkType:"tool-input-delta",chunkId:d.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${d.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});S.text+=d.inputTextDelta;const{value:M}=await Xc(S.text);S.dynamic?E({toolCallId:d.toolCallId,toolName:S.toolName,state:"input-streaming",input:M,title:S.title}):k({toolCallId:d.toolCallId,toolName:S.toolName,state:"input-streaming",input:M,title:S.title}),p();break}case"tool-input-available":{d.dynamic?E({toolCallId:d.toolCallId,toolName:d.toolName,state:"input-available",input:d.input,providerExecuted:d.providerExecuted,providerMetadata:d.providerMetadata,title:d.title}):k({toolCallId:d.toolCallId,toolName:d.toolName,state:"input-available",input:d.input,providerExecuted:d.providerExecuted,providerMetadata:d.providerMetadata,title:d.title}),p(),l&&!d.providerExecuted&&await l({toolCall:d});break}case"tool-input-error":{const S=m.message.parts.filter(Si).find(C=>C.toolCallId===d.toolCallId);(S!=null?S.type==="dynamic-tool":!!d.dynamic)?E({toolCallId:d.toolCallId,toolName:d.toolName,state:"output-error",input:d.input,errorText:d.errorText,providerExecuted:d.providerExecuted,providerMetadata:d.providerMetadata}):k({toolCallId:d.toolCallId,toolName:d.toolName,state:"output-error",input:void 0,rawInput:d.input,errorText:d.errorText,providerExecuted:d.providerExecuted,providerMetadata:d.providerMetadata}),p();break}case"tool-approval-request":{const S=N(d.toolCallId);S.state="approval-requested",S.approval={id:d.approvalId},p();break}case"tool-output-denied":{const S=N(d.toolCallId);S.state="output-denied",p();break}case"tool-output-available":{const S=N(d.toolCallId);S.type==="dynamic-tool"?E({toolCallId:d.toolCallId,toolName:S.toolName,state:"output-available",input:S.input,output:d.output,preliminary:d.preliminary,providerExecuted:d.providerExecuted,providerMetadata:d.providerMetadata,title:S.title}):k({toolCallId:d.toolCallId,toolName:fv(S),state:"output-available",input:S.input,output:d.output,providerExecuted:d.providerExecuted,preliminary:d.preliminary,providerMetadata:d.providerMetadata,title:S.title}),p();break}case"tool-output-error":{const S=N(d.toolCallId);S.type==="dynamic-tool"?E({toolCallId:d.toolCallId,toolName:S.toolName,state:"output-error",input:S.input,errorText:d.errorText,providerExecuted:d.providerExecuted,providerMetadata:d.providerMetadata,title:S.title}):k({toolCallId:d.toolCallId,toolName:fv(S),state:"output-error",input:S.input,rawInput:S.rawInput,errorText:d.errorText,providerExecuted:d.providerExecuted,providerMetadata:d.providerMetadata,title:S.title}),p();break}case"start-step":{m.message.parts.push({type:"step-start"});break}case"finish-step":{m.activeTextParts={},m.activeReasoningParts={};break}case"start":{d.messageId!=null&&(m.message.id=d.messageId),await A(d.messageMetadata),(d.messageId!=null||d.messageMetadata!=null)&&p();break}case"finish":{d.finishReason!=null&&(m.finishReason=d.finishReason),await A(d.messageMetadata),d.messageMetadata!=null&&p();break}case"message-metadata":{await A(d.messageMetadata),d.messageMetadata!=null&&p();break}case"error":{i?.(new Error(d.errorText));break}default:if(AL(d)){if(n?.[d.type]!=null){const C=m.message.parts.findIndex(R=>"id"in R&&"data"in R&&R.id===d.id&&R.type===d.type),I=C>=0?C:m.message.parts.length;await B1({value:d.data,schema:n[d.type],context:{field:`message.parts[${I}].data`,entityName:d.type,entityId:d.id}})}const S=d;if(S.transient){c?.(S);break}const M=S.id!=null?m.message.parts.find(C=>S.type===C.type&&S.id===C.id):void 0;M!=null?M.data=S.data:m.message.parts.push(S),c?.(S),p()}}h.enqueue(d)})}}))}async function RL({stream:e,onError:t}){const n=e.getReader();try{for(;;){const{done:s}=await n.read();if(s)break}}catch(s){t?.(s)}finally{n.releaseLock()}}Kc({prefix:"aitxt",size:24});Kc({prefix:"aiobj",size:24});var _L=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(s){n(s)}}),this.processQueue()})}};Kc({prefix:"aiobj",size:24});async function IL(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:s}=t,i=await new Promise((l,c)=>{const d=new FileReader;d.onload=h=>{var m;l((m=h.target)==null?void 0:m.result)},d.onerror=h=>c(h),d.readAsDataURL(t)});return{type:"file",mediaType:s,filename:n,url:i}}))}var OL=class{constructor({api:e="/api/chat",credentials:t,headers:n,body:s,fetch:i,prepareSendMessagesRequest:l,prepareReconnectToStreamRequest:c}){this.api=e,this.credentials=t,this.headers=n,this.body=s,this.fetch=i,this.prepareSendMessagesRequest=l,this.prepareReconnectToStreamRequest=c}async sendMessages({abortSignal:e,...t}){var n,s,i,l,c;const d=await xr(this.body),h=await xr(this.headers),m=await xr(this.credentials),p={...vo(h),...vo(t.headers)},y=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...d,...t.body},headers:p,credentials:m,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),x=(s=y?.api)!=null?s:this.api,w=y?.headers!==void 0?vo(y.headers):p,j=y?.body!==void 0?y.body:{...d,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},N=(i=y?.credentials)!=null?i:m,E=await((l=this.fetch)!=null?l:globalThis.fetch)(x,{method:"POST",headers:{"Content-Type":"application/json",...w},body:JSON.stringify(j),credentials:N,signal:e});if(!E.ok)throw new Error((c=await E.text())!=null?c:"Failed to fetch the chat response.");if(!E.body)throw new Error("The response body is empty.");return this.processResponseStream(E.body)}async reconnectToStream(e){var t,n,s,i,l;const c=await xr(this.body),d=await xr(this.headers),h=await xr(this.credentials),m={...vo(d),...vo(e.headers)},p=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...c,...e.body},headers:m,credentials:h,requestMetadata:e.metadata})),y=(n=p?.api)!=null?n:`${this.api}/${e.chatId}/stream`,x=p?.headers!==void 0?vo(p.headers):m,w=(s=p?.credentials)!=null?s:h,N=await((i=this.fetch)!=null?i:globalThis.fetch)(y,{method:"GET",headers:x,credentials:w});if(N.status===204)return null;if(!N.ok)throw new Error((l=await N.text())!=null?l:"Failed to fetch the chat response.");if(!N.body)throw new Error("The response body is empty.");return this.processResponseStream(N.body)}},eA=class extends OL{constructor(e={}){super(e)}processResponseStream(e){return rL({stream:e,schema:CL}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},DL=class{constructor({generateId:e=l3,id:t=e(),transport:n=new eA,messageMetadataSchema:s,dataPartSchemas:i,state:l,onError:c,onToolCall:d,onFinish:h,onData:m,sendAutomaticallyWhen:p}){this.activeResponse=void 0,this.jobExecutor=new _L,this.sendMessage=async(y,x)=>{var w,j,N,k;if(y==null){await this.makeRequest({trigger:"submit-message",messageId:(w=this.lastMessage)==null?void 0:w.id,...x});return}let E;if("text"in y||"files"in y?E={parts:[...Array.isArray(y.files)?y.files:await IL(y.files),..."text"in y&&y.text!=null?[{type:"text",text:y.text}]:[]]}:E=y,y.messageId!=null){const A=this.state.messages.findIndex(S=>S.id===y.messageId);if(A===-1)throw new Error(`message with id ${y.messageId} not found`);if(this.state.messages[A].role!=="user")throw new Error(`message with id ${y.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,A+1),this.state.replaceMessage(A,{...E,id:y.messageId,role:(j=E.role)!=null?j:"user",metadata:y.metadata})}else this.state.pushMessage({...E,id:(N=E.id)!=null?N:this.generateId(),role:(k=E.role)!=null?k:"user",metadata:y.metadata});await this.makeRequest({trigger:"submit-message",messageId:y.messageId,...x})},this.regenerate=async({messageId:y,...x}={})=>{const w=y==null?this.state.messages.length-1:this.state.messages.findIndex(j=>j.id===y);if(w===-1)throw new Error(`message ${y} not found`);this.state.messages=this.state.messages.slice(0,this.messages[w].role==="assistant"?w:w+1),await this.makeRequest({trigger:"regenerate-message",messageId:y,...x})},this.resumeStream=async(y={})=>{await this.makeRequest({trigger:"resume-stream",...y})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:y,approved:x,reason:w,options:j})=>this.jobExecutor.run(async()=>{const N=this.state.messages,k=N[N.length-1],E=A=>Si(A)&&A.state==="approval-requested"&&A.approval.id===y?{...A,state:"approval-responded",approval:{id:y,approved:x,reason:w}}:A;this.state.replaceMessage(N.length-1,{...k,parts:k.parts.map(E)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(E)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(A=>{var S;A&&this.makeRequest({trigger:"submit-message",messageId:(S=this.lastMessage)==null?void 0:S.id,...j})})}),this.addToolOutput=async({state:y="output-available",toolCallId:x,output:w,errorText:j,options:N})=>this.jobExecutor.run(async()=>{const k=this.state.messages,E=k[k.length-1],A=S=>Si(S)&&S.toolCallId===x?{...S,state:y,output:w,errorText:j}:S;this.state.replaceMessage(k.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 M;S&&this.makeRequest({trigger:"submit-message",messageId:(M=this.lastMessage)==null?void 0:M.id,...N})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var y;this.status!=="streaming"&&this.status!=="submitted"||(y=this.activeResponse)!=null&&y.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=s,this.dataPartSchemas=i,this.state=l,this.onError=c,this.onToolCall=d,this.onFinish=h,this.onData=m,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:s,messageId:i}){var l,c,d;let h;if(e==="resume-stream")try{const w=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:s});if(w==null)return;h=w}catch(w){this.onError&&w instanceof Error&&this.onError(w),this.setStatus({status:"error",error:w});return}this.setStatus({status:"submitted",error:void 0});const m=this.lastMessage;let p=!1,y=!1,x=!1;try{const w={state:TL({lastMessage:this.state.snapshot(m),messageId:this.generateId()}),abortController:new AbortController};w.abortController.signal.addEventListener("abort",()=>{p=!0}),this.activeResponse=w;let j;e==="resume-stream"?j=h:j=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:w.abortController.signal,metadata:t,headers:n,body:s,trigger:e,messageId:i});const N=k=>this.jobExecutor.run(()=>k({state:w.state,write:()=>{var E;this.setStatus({status:"streaming"}),w.state.message.id===((E=this.lastMessage)==null?void 0:E.id)?this.state.replaceMessage(this.state.messages.length-1,w.state.message):this.state.pushMessage(w.state.message)}}));await RL({stream:ML({stream:j,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:N,onError:k=>{throw k}}),onError:k=>{throw k}}),this.setStatus({status:"ready"})}catch(w){if(p||w.name==="AbortError")return p=!0,this.setStatus({status:"ready"}),null;x=!0,w instanceof TypeError&&(w.message.toLowerCase().includes("fetch")||w.message.toLowerCase().includes("network"))&&(y=!0),this.onError&&w instanceof Error&&this.onError(w),this.setStatus({status:"error",error:w})}finally{try{(c=this.onFinish)==null||c.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:p,isDisconnect:y,isError:x,finishReason:(l=this.activeResponse)==null?void 0:l.state.finishReason})}catch(w){console.error(w)}this.activeResponse=void 0}!x&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:"submit-message",messageId:(d=this.lastMessage)==null?void 0:d.id,metadata:t,headers:n,body:s})}},Qp,V1;function PL(){if(V1)return Qp;V1=1;function e(t,n){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let s,i=0;return function(...c){clearTimeout(s);const d=Date.now(),h=d-i,m=n-h;m<=0?(i=d,t.apply(this,c)):s=setTimeout(()=>{i=Date.now(),t.apply(this,c)},m)}}return Qp=e,Qp}var zL=PL();const LL=xE(zL);var tA=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Vt=(e,t,n)=>(tA(e,t,"read from private field"),n?n.call(e):t.get(e)),sa=(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)},gr=(e,t,n,s)=>(tA(e,t,"write to private field"),t.set(e,n),n);function $L(e,t){return t!=null?LL(e,t):e}var Cs,tf,nf,mc,pc,gc,Ro,hv,mv,UL=class{constructor(e=[]){sa(this,Cs,void 0),sa(this,tf,"ready"),sa(this,nf,void 0),sa(this,mc,new Set),sa(this,pc,new Set),sa(this,gc,new Set),this.pushMessage=t=>{gr(this,Cs,Vt(this,Cs).concat(t)),Vt(this,Ro).call(this)},this.popMessage=()=>{gr(this,Cs,Vt(this,Cs).slice(0,-1)),Vt(this,Ro).call(this)},this.replaceMessage=(t,n)=>{gr(this,Cs,[...Vt(this,Cs).slice(0,t),this.snapshot(n),...Vt(this,Cs).slice(t+1)]),Vt(this,Ro).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const s=n?$L(t,n):t;return Vt(this,mc).add(s),()=>{Vt(this,mc).delete(s)}},this["~registerStatusCallback"]=t=>(Vt(this,pc).add(t),()=>{Vt(this,pc).delete(t)}),this["~registerErrorCallback"]=t=>(Vt(this,gc).add(t),()=>{Vt(this,gc).delete(t)}),sa(this,Ro,()=>{Vt(this,mc).forEach(t=>t())}),sa(this,hv,()=>{Vt(this,pc).forEach(t=>t())}),sa(this,mv,()=>{Vt(this,gc).forEach(t=>t())}),gr(this,Cs,e)}get status(){return Vt(this,tf)}set status(e){gr(this,tf,e),Vt(this,hv).call(this)}get error(){return Vt(this,nf)}set error(e){gr(this,nf,e),Vt(this,mv).call(this)}get messages(){return Vt(this,Cs)}set messages(e){gr(this,Cs,[...e]),Vt(this,Ro).call(this)}};Cs=new WeakMap;tf=new WeakMap;nf=new WeakMap;mc=new WeakMap;pc=new WeakMap;gc=new WeakMap;Ro=new WeakMap;hv=new WeakMap;mv=new WeakMap;var _o,F1=class extends DL{constructor({messages:e,...t}){const n=new UL(e);super({...t,state:n}),sa(this,_o,void 0),this["~registerMessagesCallback"]=(s,i)=>Vt(this,_o)["~registerMessagesCallback"](s,i),this["~registerStatusCallback"]=s=>Vt(this,_o)["~registerStatusCallback"](s),this["~registerErrorCallback"]=s=>Vt(this,_o)["~registerErrorCallback"](s),gr(this,_o,n)}};_o=new WeakMap;function BL({experimental_throttle:e,resume:t=!1,...n}={}){const s=g.useRef("chat"in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});"chat"in n||(s.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});const i={...n,onToolCall:x=>{var w,j;return(j=(w=s.current).onToolCall)==null?void 0:j.call(w,x)},onData:x=>{var w,j;return(j=(w=s.current).onData)==null?void 0:j.call(w,x)},onFinish:x=>{var w,j;return(j=(w=s.current).onFinish)==null?void 0:j.call(w,x)},onError:x=>{var w,j;return(j=(w=s.current).onError)==null?void 0:j.call(w,x)},sendAutomaticallyWhen:x=>{var w,j,N;return(N=(j=(w=s.current).sendAutomaticallyWhen)==null?void 0:j.call(w,x))!=null?N:!1}},l=g.useRef("chat"in n?n.chat:new F1(i));("chat"in n&&n.chat!==l.current||"id"in n&&l.current.id!==n.id)&&(l.current="chat"in n?n.chat:new F1(i));const d=g.useCallback(x=>l.current["~registerMessagesCallback"](x,e),[e,l.current.id]),h=g.useSyncExternalStore(d,()=>l.current.messages,()=>l.current.messages),m=g.useSyncExternalStore(l.current["~registerStatusCallback"],()=>l.current.status,()=>l.current.status),p=g.useSyncExternalStore(l.current["~registerErrorCallback"],()=>l.current.error,()=>l.current.error),y=g.useCallback(x=>{typeof x=="function"&&(x=x(l.current.messages)),l.current.messages=x},[l]);return g.useEffect(()=>{t&&l.current.resumeStream()},[t,l]),{id:l.current.id,messages:h,setMessages:y,sendMessage:l.current.sendMessage,regenerate:l.current.regenerate,clearError:l.current.clearError,stop:l.current.stop,error:p,resumeStream:l.current.resumeStream,status:m,addToolResult:l.current.addToolOutput,addToolOutput:l.current.addToolOutput,addToolApprovalResponse:l.current.addToolApprovalResponse}}function VL(e){const t={};for(const n of e.attachmentsRef.current??[])if(e.activeAttachmentsRef.current.has(n.label)){const s=n.content();s!==null&&(t[n.label.toLowerCase()]=s)}return{toolset:e.toolsetRef.current,context:{...e.contextRef.current,...t},mode:e.modeRef.current,sessionId:e.sessionIdRef.current,provider:e.providerRef.current,model:e.modelRef.current}}function FL(e,t){e.current?.(t)}function HL(e,t){e.current?.(t)}function qL(e){const t=new Set;for(const n of e??[])if(n.role==="assistant")for(const s of n.parts??[])s&&Si(s)&&t.add(s.toolCallId);return t}function ZL({toolset:e,chatId:t,initialMessages:n,context:s,onToolCall:i,mode:l,attachments:c,provider:d,model:h,sessionId:m,onSessionIdChange:p,onFinish:y,onError:x}){const w=g.useRef(i),j=g.useRef(y),N=g.useRef(x),k=g.useRef(m??crypto.randomUUID()),[E,A]=g.useState(new Set),S=g.useCallback(H=>{A(V=>{const W=new Set(V);return W.has(H)?W.delete(H):W.add(H),W})},[]),[M]=Hs("hudson.settings",{}),C=l??M.aiMode??"api",I=g.useRef(E),R=g.useRef(c),D=g.useRef(s),z=g.useRef(e),O=g.useRef(C),_=g.useRef(d),U=g.useRef(h);g.useEffect(()=>{w.current=i},[i]),g.useEffect(()=>{j.current=y},[y]),g.useEffect(()=>{N.current=x},[x]),g.useEffect(()=>{m&&m!==k.current&&(k.current=m)},[m]),g.useEffect(()=>{p?.(k.current)},[p]),g.useEffect(()=>{I.current=E},[E]),g.useEffect(()=>{R.current=c},[c]),g.useEffect(()=>{D.current=s},[s]),g.useEffect(()=>{z.current=e},[e]),g.useEffect(()=>{O.current=C},[C]),g.useEffect(()=>{_.current=d},[d]),g.useEffect(()=>{U.current=h},[h]);const q=g.useMemo(()=>new eA({api:"/api/ai/chat",body:()=>VL({activeAttachmentsRef:I,attachmentsRef:R,contextRef:D,toolsetRef:z,modeRef:O,sessionIdRef:k,providerRef:_,modelRef:U})}),[]),G=BL({id:t,messages:n,transport:q,onFinish:H=>FL(j,H),onError:H=>HL(N,H)}),X=g.useRef(qL(n)),L=g.useCallback(()=>{const H=crypto.randomUUID();k.current=H,p?.(H),X.current.clear(),G.setMessages([])},[G,p]),{messages:F}=G;return g.useEffect(()=>{if(w.current){for(const H of F)if(H.role==="assistant"){for(const V of H.parts??[])if(V&&Si(V)){if("state"in V&&V.state==="input-streaming")continue;const W=V.toolCallId;if(!X.current.has(W)){X.current.add(W);const $=QC(V);w.current?.($,V.input??{})}}}}},[F]),{messages:F,sendMessage:G.sendMessage,stop:G.stop,status:G.status,setMessages:G.setMessages,clearChat:L,error:G.error,mode:C,attachments:c??[],activeAttachments:E,toggleAttachment:S}}function WL({app:e,commands:t,state:n,provider:s,model:i,onFinish:l}){const c=g.useMemo(()=>(e.intents??[]).map(m=>({commandId:m.commandId,title:m.title,description:m.description,category:m.category,keywords:m.keywords,shortcut:m.shortcut,dangerous:m.dangerous,params:m.params?.map(p=>({name:p.name,description:p.description,type:p.type,optional:p.optional,enum:p.enum}))})),[e.intents]),d=g.useMemo(()=>({appId:e.id,appName:e.name,appDescription:e.description,intents:c,state:n}),[e.id,e.name,e.description,c,n]),h=g.useCallback(m=>{const p=t.find(y=>y.id===m);if(!p){console.warn(`[useAssistant] no command for id "${m}"`);return}p.action()},[t]);return ZL({toolset:"intents",context:d,provider:s,model:i,onFinish:l,onToolCall:(m,p)=>{if(m!=="dispatch")return;const y=p.commandId;typeof y=="string"&&h(y)}})}const YL="modulepreload",GL=function(e){return"/"+e},H1={},sf=function(t,n,s){let i=Promise.resolve();if(n&&n.length>0){let m=function(p){return Promise.all(p.map(y=>Promise.resolve(y).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};var c=m;document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),h=d?.nonce||d?.getAttribute("nonce");i=m(n.map(p=>{if(p=GL(p),p in H1)return;H1[p]=!0;const y=p.endsWith(".css"),x=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${x}`))return;const w=document.createElement("link");if(w.rel=y?"stylesheet":YL,y||(w.as="script"),w.crossOrigin="",w.href=p,h&&w.setAttribute("nonce",h),document.head.appendChild(w),y)return new Promise((j,N)=>{w.addEventListener("load",j),w.addEventListener("error",()=>N(new Error(`Unable to preload CSS for ${p}`)))})}))}function l(d){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=d,window.dispatchEvent(h),!h.defaultPrevented)throw d}return i.then(d=>{for(const h of d||[])h.status==="rejected"&&l(h.reason);return t().catch(l)})};async function KL(e){try{return(await e.capabilities())?.daemon?.running?"connected":"warming"}catch(t){if(t&&typeof t=="object"&&"code"in t){const n=t.code,s=String(t.message??"");if(n==="http_error")return s.includes("403")||s.toLowerCase().includes("origin not allowed")?"blocked-origin":"warming"}return"unreachable"}}const XL="audio/ogg;codecs=opus";function JL(){return typeof MediaRecorder>"u"?void 0:["audio/ogg;codecs=opus","audio/mp4;codecs=mp4a.40.2","audio/mp4","audio/webm;codecs=opus"].find(t=>MediaRecorder.isTypeSupported(t))}function eg(e){e?.getTracks().forEach(t=>t.stop())}function QL(e){return e.includes("wav")?"wav":e.includes("aac")||e.includes("mp4")?"aac":"opus"}function q1(e,t){return t||e.find(s=>s.type)?.type||XL}function Z1(e){const t=typeof window<"u"?window.location.origin:"this origin";if(e&&typeof e=="object"&&"code"in e&&"message"in e){const n=e;if(n.code==="network_error")return{status:"unavailable",message:"Vox Companion is not reachable on 127.0.0.1:43115. Install Vox.app, or launch it if it is already installed."};if(n.code==="http_error"){const s=n.message??"";return s.includes("Origin not allowed")||s.includes("403")?{status:"error",message:`Vox rejected this origin. Allowlist ${t} in Vox settings and try again.`}:{status:"error",message:"Vox returned an error while transcribing. Check Vox and try again."}}}if(e instanceof DOMException){if(e.name==="NotAllowedError")return{status:"error",message:"Microphone access was denied."};if(e.name==="NotFoundError")return{status:"error",message:"No microphone is available."}}return e instanceof Error?{status:"error",message:e.message}:{status:"error",message:"Voice capture failed."}}async function e$(){const t=(await sf(()=>import("./index-TVkH_WDG.js"),[])).createVoxdClient();return{probe:()=>t.probe(),transcribe:({audio:n,format:s,language:i,metadata:l})=>t.transcribe({audio:n,format:s,language:i,metadata:l}),probeAvailability:()=>KL(t)}}function t$(e){const{onTranscript:t,surface:n="hudson-assistant",metadata:s,language:i="en",transcribe:l,probe:c}=e,[d,h]=g.useState("idle"),[m,p]=g.useState(null),[y,x]=g.useState(null),w=g.useRef(null),j=g.useRef(null),N=g.useRef([]),k=g.useRef(t);k.current=t;const E=g.useRef(s);E.current=s;const A=g.useRef(null),S=g.useMemo(()=>typeof MediaRecorder<"u"&&typeof navigator<"u"&&!!navigator.mediaDevices?.getUserMedia,[]),M=g.useCallback(async()=>l?{probe:c??(async()=>!0),transcribe:l}:(A.current||(A.current=await e$()),A.current),[l,c]),C=g.useCallback(async(D,z)=>{if(eg(j.current),j.current=null,w.current=null,D.length===0){h("error"),p("No audio was captured.");return}h("transcribing"),p(null);try{const O=await M(),_=q1(D,z),q=(await O.transcribe({audio:new Blob(D,{type:_}),format:QL(_),language:i,metadata:{surface:n,...E.current}})).text.trim();if(!q)throw new Error("Transcription returned empty text.");x(q),h("ready"),k.current(q)}catch(O){const _=Z1(O);h(_.status),p(_.message)}},[M,i,n]),I=g.useCallback(async()=>{if(!(d==="recording"||d==="transcribing")){if(!S){h("error"),p("This browser cannot capture microphone audio.");return}p(null),x(null);try{const D=await M(),z=D.probeAvailability?await D.probeAvailability():await D.probe()?"connected":"unreachable";if(z==="blocked-origin"){const q=typeof window<"u"?window.location.origin:"this origin";h("error"),p(`Vox rejected this origin. Allowlist ${q} in Vox settings and try again.`);return}if(z==="warming"){h("unavailable"),p("Vox is starting up — try again in a moment.");return}if(z==="unreachable"){h("unavailable"),p("Vox Companion is not reachable on 127.0.0.1:43115. Install Vox.app, or launch it if it is already installed.");return}const O=await navigator.mediaDevices.getUserMedia({audio:!0}),_=JL(),U=_?new MediaRecorder(O,{mimeType:_}):new MediaRecorder(O);N.current=[],j.current=O,w.current=U,U.ondataavailable=q=>{q.data.size>0&&N.current.push(q.data)},U.onerror=()=>{eg(j.current),j.current=null,w.current=null,N.current=[],h("error"),p("Voice capture failed while recording.")},U.onstop=()=>{const q=[...N.current];N.current=[],C(q,q1(q,U.mimeType||_||""))},U.start(),h("recording")}catch(D){const z=Z1(D);h(z.status),p(z.message)}}},[C,M,S,d]),R=g.useCallback(()=>{const D=w.current;!D||D.state!=="recording"||(h("transcribing"),D.stop())},[]);return g.useEffect(()=>()=>{const D=w.current;if(D&&D.state==="recording")try{D.stop()}catch{}eg(j.current),j.current=null,w.current=null,N.current=[]},[]),{status:d,error:m,lastTranscript:y,start:I,stop:R,isSupported:S}}const n$={titleBarInset:0,dragRegionProps:{},onInteractiveMouseDown:void 0,isSSR:!0,apiBaseUrl:"",serviceApiUrl:""},s$=g.createContext(n$);function Jc(){return g.useContext(s$)}function a$(){return typeof document>"u"?"wav":document.createElement("audio").canPlayType('audio/mp4; codecs="mp4a.40.2"')?"aac":"wav"}function r$(){const{apiBaseUrl:e}=Jc(),[t,n]=g.useState("idle"),[s,i]=g.useState(null),l=g.useRef(null),c=g.useRef(null),d=g.useRef(0),h=g.useCallback(()=>{d.current+=1;const p=l.current;p&&(p.onended=null,p.onerror=null,p.pause(),l.current=null),c.current&&(URL.revokeObjectURL(c.current),c.current=null),n(y=>y==="speaking"||y==="synthesizing"?"idle":y)},[]),m=g.useCallback(async(p,y={})=>{if(!p||!p.trim())return;const x=d.current+1;d.current=x,n("synthesizing"),i(null);try{const w=await fetch(`${e}/v1/audio/speech`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:p,provider:y.provider,model:y.model,voice:y.voice||void 0,rate:y.rate,format:a$(),metadata:y.metadata})}),j=await w.json();if(!w.ok)throw new Error(j.error||`Speech synthesis failed (${w.status}).`);const N=j.audio?.base64??j.audioBase64,k=j.audio?.mimeType??j.mimeType??"audio/wav";if(!N)throw new Error("Speech synthesis returned no audio.");if(d.current!==x)return;l.current&&(l.current.pause(),l.current=null),c.current&&(URL.revokeObjectURL(c.current),c.current=null);const E=Uint8Array.from(atob(N),C=>C.charCodeAt(0)),A=new Blob([E],{type:k}),S=URL.createObjectURL(A),M=new Audio(S);l.current=M,c.current=S,n("speaking"),M.onended=()=>{l.current===M&&(l.current=null),c.current===S&&(URL.revokeObjectURL(S),c.current=null),n(C=>C==="speaking"?"idle":C)},M.onerror=()=>{l.current===M&&(l.current=null),c.current===S&&(URL.revokeObjectURL(S),c.current=null),n("error"),i("Reply audio could not be played in this browser.")},await M.play()}catch(w){if(d.current!==x)return;h(),n("error"),i(w instanceof Error?w.message:"Reply speech failed.")}},[e,h]);return g.useEffect(()=>()=>{const p=l.current;p&&(p.onended=null,p.onerror=null,p.pause()),c.current&&URL.revokeObjectURL(c.current),l.current=null,c.current=null},[]),{status:t,error:s,speak:m,stop:h,isPlaying:t==="synthesizing"||t==="speaking"}}const fh={panels:{statusBar:"bg-card/95 backdrop-blur-xl border-t border-border/40 shadow-[var(--hud-shadow-bar)] fixed bottom-0 left-0 right-0 z-[60]"},zIndex:{drawer:70},layout:{navHeight:48,statusBarHeight:28}},i$=fh.panels;g.createContext(null);const o$={autoSend:!0,speakReplies:!1,replyProvider:"system",replyModel:"system",replyVoice:"",replyRate:1,spokenReplyStyle:"adaptive",spokenReplyLongResponse:"invite",spokenReplyCodeResponse:"summary",spokenReplyMaxChars:720},l$=3,c$=6,u$=4,d$=320,f$=760,h$=480,m$={balanced:{spokenReplyStyle:"adaptive",spokenReplyLongResponse:"invite",spokenReplyCodeResponse:"summary",spokenReplyMaxChars:720}},ic=m$.balanced;function kr(e){return e.replace(/\s+/g," ").trim()}function nA(e){return e.replace(/<think>[\s\S]*?<\/think>/g," ")}function W1(e){return kr(e.replace(/```[\s\S]*?```/g," ").replace(/`([^`]+)`/g,"$1").replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/^#{1,6}\s+/gm,"").replace(/^\s*>\s?/gm,"").replace(/^\s*[-*+]\s+/gm,"").replace(/^\s*\d+\.\s+/gm,"").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/_([^_]+)_/g,"$1").replace(/~~([^~]+)~~/g,"$1").replace(/\|/g," ").replace(/\n{2,}/g,`
|
|
66
|
-
`).replace(/\n/g," "))}function p$(e){return kr(e).split(new RegExp("(?<=[.!?])\\s+")).map(t=>t.trim()).filter(Boolean)}function tg(e,t){if(e.length<=t)return e;const n=e.slice(0,t).trim(),s=n.lastIndexOf(" ");return(s>Math.floor(t*.6)?n.slice(0,s):n).replace(/[,:; -]+$/,"").trim()}function kd(e){return e&&(/[.!?]$/.test(e)?e:`${e}.`)}function sA(e,t,n){const s=p$(e);if(s.length===0)return kd(tg(kr(e),n));const i=[];for(const c of s){const d=kr([...i,c].join(" "));if(i.length>0&&d.length>n||(i.push(c),i.length>=t))break}if(i.length===0)return kd(tg(s[0]??e,n));const l=kr(i.join(" "));return l.length<=n?kd(l):kd(tg(l,n))}function g$(e){return typeof e=="string"?{...ic,spokenReplyStyle:e}:{spokenReplyStyle:e.spokenReplyStyle??ic.spokenReplyStyle,spokenReplyLongResponse:e.spokenReplyLongResponse??ic.spokenReplyLongResponse,spokenReplyCodeResponse:e.spokenReplyCodeResponse??ic.spokenReplyCodeResponse,spokenReplyMaxChars:e.spokenReplyMaxChars??ic.spokenReplyMaxChars}}function v$(e){switch(e){case"full":return{maxSentences:c$,maxChars:f$};case"adaptive":return{maxSentences:u$,maxChars:h$};default:return{maxSentences:l$,maxChars:d$}}}function y$(e){const t=nA(e),n=[...t.matchAll(/```[\s\S]*?```/g)],s=[...t.matchAll(/`[^`]+`/g)],i=t.replace(/```[\s\S]*?```/g," ").replace(/`([^`]+)`/g," $1 "),l=W1(t),c=W1(i),d=n.reduce((m,p)=>m+p[0].length,0)+s.reduce((m,p)=>m+p[0].length,0),h=n.length>0||s.length>=2||d>120&&d>l.length*.18||/(const|let|function|class|interface|return|import|export)\s+/.test(t)&&/[{}();]/.test(t);return{cleaned:l,proseOnly:c,codeHeavy:h}}function Ry(e,t){const{maxSentences:n,maxChars:s}=v$(t);return sA(e,n,s)}function pv(e){return sA(e,3,260)}function x$(e,t){switch(t.spokenReplyLongResponse){case"summary":return pv(e.cleaned);case"invite":{const n=pv(e.cleaned);return kr(`${n} The full details are in the written reply. We can talk through any part you want.`)}default:return Ry(e.cleaned,t.spokenReplyStyle)}}function b$(e,t){switch(t.spokenReplyCodeResponse){case"read":return Ry(e.cleaned,t.spokenReplyStyle);case"mention":return"I included code in the written reply. I can walk through the implementation if you want.";default:{const n=e.proseOnly||e.cleaned,s=n?pv(n):"";return s?kr(`${s} I also included code in the written reply. I can walk through the implementation if you want.`):"I included code in the written reply. I can walk through the implementation or focus on one piece if you want."}}}function w$(e){const t=(e.parts??[]).filter(n=>n.type==="text").map(n=>"text"in n?n.text??"":"").join("");return kr(nA(t))}function j$(e,t){const n=g$(t),s=y$(e);return s.cleaned?s.codeHeavy&&n.spokenReplyCodeResponse!=="read"?b$(s,n):s.cleaned.length>n.spokenReplyMaxChars&&n.spokenReplyLongResponse!=="verbatim"?x$(s,n):Ry(s.cleaned,n.spokenReplyStyle):""}function _y(e={}){const{url:t="ws://localhost:3600",systemPrompt:n,cwd:s,workspaceFiles:i,autoConnect:l=!1,sessionKey:c,orphanTTL:d,backend:h,tmuxSession:m,agent:p,provider:y,model:x}=e,w=c?`hudson.relay.${c}`:null,j=()=>{if(!w)return null;try{return localStorage.getItem(w)}catch{return null}},N=ie=>{if(w)try{ie?localStorage.setItem(w,ie):localStorage.removeItem(w)}catch{}},[k,E]=g.useState("disconnected"),[A,S]=g.useState(null),[M,C]=g.useState(null),[I,R]=g.useState(null),[D,z]=g.useState(s||"~"),O=g.useRef(null),_=g.useRef(null),U=g.useRef({cols:80,rows:24}),q=g.useRef(!1),G=g.useRef(D);G.current=D;const X=g.useRef(j()),L=g.useRef(null),F=g.useCallback(ie=>{const de=O.current;de&&de.readyState===WebSocket.OPEN&&de.send(JSON.stringify(ie))},[]),H=g.useCallback(()=>{_.current&&(clearTimeout(_.current),_.current=null);const ie=O.current;ie&&(ie.close(),O.current=null),q.current=!1,E("disconnected")},[]),V=g.useCallback(()=>{const ie=G.current;return{type:"session:init",cols:U.current.cols,rows:U.current.rows,...n?{systemPrompt:n}:{},...ie?{cwd:ie}:{},...i?{workspaceFiles:i}:{},...d?{orphanTTL:d}:{},...h?{backend:h}:{},...m?{tmuxSession:m}:{},...p?{agent:p}:{},...y?{provider:y}:{},...x?{model:x}:{}}},[n,i,d,h,m,p,y,x]),W=g.useCallback(()=>{q.current||(q.current=!0,X.current?F({type:"session:reconnect",sessionId:X.current,cols:U.current.cols,rows:U.current.rows}):F(V()))},[F,V]),$=g.useCallback(async()=>{O.current&&(O.current.close(),O.current=null),q.current=!1,E("connecting"),C(null),R(null);const ie=t.replace(/^ws(s?):\/\//,"http$1://");try{await fetch(`${ie}/health`,{signal:AbortSignal.timeout(2e3)})}catch{E("error"),C("Relay service is not running");return}const de=new WebSocket(t);O.current=de,de.onopen=()=>{W()},de.onmessage=xe=>{try{const Ae=JSON.parse(xe.data);switch(Ae.type){case"session:ready":X.current=Ae.sessionId,N(Ae.sessionId),S(Ae.sessionId),E("connected"),C(null),R(null);break;case"session:expired":{X.current=null,N(null),q.current=!1,L.current&&L.current("\x1B[2J\x1B[H"),F(V()),q.current=!0;break}case"session:error":E("error"),C(Ae.error||"Session failed to start");break;case"terminal:data":L.current&&Ae.data&&L.current(Ae.data);break;case"session:exit":X.current=null,N(null),S(null),R(Ae.exitCode??null),Ae.exitCode!==0?(E("error"),C(Ae.reason||`Process exited with code ${Ae.exitCode}`)):E("disconnected");break;case"session:detached":X.current=null,N(null),S(null);break}}catch{}},de.onclose=()=>{O.current=null,q.current=!1,E(xe=>xe==="error"?xe:"disconnected")},de.onerror=()=>{E("error"),C("Could not connect to relay")}},[t,W,F,n,i]),B=g.useCallback(ie=>{F({type:"terminal:input",data:ie})},[F]),Y=g.useCallback(ie=>{F({type:"terminal:input",data:ie+"\r"})},[F]),te=g.useCallback((ie,de)=>{U.current={cols:ie,rows:de},q.current&&F({type:"terminal:resize",cols:ie,rows:de})},[F]),ae=g.useCallback(ie=>{L.current=ie},[]);g.useEffect(()=>(l&&$(),()=>{H()}),[]);const ee=g.useCallback(()=>{if(H(),X.current=null,S(null),c)try{sessionStorage.removeItem(`hudson.relay.${c}`)}catch{}C(null),R(null),setTimeout(()=>$(),200)},[H,$,c]);return{status:k,sessionId:A,error:M,exitCode:I,cwd:D,setCwd:z,onData:ae,sendInput:B,sendLine:Y,resize:te,connect:$,disconnect:H,restart:ee}}const aA=(...e)=>e.filter((t,n,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===n).join(" ").trim();const N$=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const S$=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,s)=>s?s.toUpperCase():n.toLowerCase());const Y1=e=>{const t=S$(e);return t.charAt(0).toUpperCase()+t.slice(1)};var k$={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 E$=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const C$=g.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:i="",children:l,iconNode:c,...d},h)=>g.createElement("svg",{ref:h,...k$,width:t,height:t,stroke:e,strokeWidth:s?Number(n)*24/Number(t):n,className:aA("lucide",i),...!l&&!E$(d)&&{"aria-hidden":"true"},...d},[...c.map(([m,p])=>g.createElement(m,p)),...Array.isArray(l)?l:[l]]));const nn=(e,t)=>{const n=g.forwardRef(({className:s,...i},l)=>g.createElement(C$,{ref:l,iconNode:t,className:aA(`lucide-${N$(Y1(e))}`,`lucide-${e}`,s),...i}));return n.displayName=Y1(e),n};const A$=[["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"}]],T$=nn("circle-alert",A$);const M$=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],R$=nn("clock",M$);const _$=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],I$=nn("corner-down-left",_$);const O$=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],G1=nn("loader-circle",O$);const D$=[["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"}]],P$=nn("map",D$);const z$=[["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"}]],rA=nn("maximize-2",z$);const L$=[["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"}]],$$=nn("mic",L$);const U$=[["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"}]],B$=nn("minimize-2",U$);const V$=[["path",{d:"M5 12h14",key:"1ays0h"}]],F$=nn("minus",V$);const H$=[["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"}]],q$=nn("panel-left-close",H$);const Z$=[["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"}]],W$=nn("panel-left-open",Z$);const Y$=[["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"}]],G$=nn("panel-right-close",Y$);const K$=[["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"}]],X$=nn("panel-right-open",K$);const J$=[["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"}]],Q$=nn("paperclip",J$);const e6=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],t6=nn("plus",e6);const n6=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Iy=nn("search",n6);const s6=[["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"}]],a6=nn("sparkles",s6);const r6=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],iA=nn("square",r6);const i6=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],o6=nn("terminal",i6);const l6=[["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"}]],c6=nn("trash-2",l6);const u6=[["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"}]],d6=nn("volume-2",u6);const f6=[["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"}]],h6=nn("volume-x",f6);const m6=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],oA=nn("x",m6);function p6({chat:e,placeholder:t="Ask AI...",inputExtras:n,inputStatus:s,inputValue:i,onInputChange:l}){const{messages:c,sendMessage:d,stop:h,status:m,clearChat:p,error:y,attachments:x,activeAttachments:w,toggleAttachment:j}=e,[N,k]=g.useState(""),E=i!==void 0,A=E?i:N,S=O=>{E?l?.(O):k(O)},M=g.useRef(null),C=g.useRef(null),I=m==="streaming"||m==="submitted",R=x.length>0;g.useEffect(()=>{const O=M.current;O&&(O.scrollTop=O.scrollHeight)},[c]),g.useEffect(()=>{C.current?.focus()},[]);const D=O=>{O.preventDefault();const _=A.trim();!_||I||(S(""),d({text:_}))},z=O=>{O.stopPropagation(),O.key==="Enter"&&!O.shiftKey&&(O.preventDefault(),D(O))};return r.jsxs("div",{className:"flex flex-col h-full font-mono text-[12px]",children:[r.jsxs("div",{ref:M,className:"flex-1 overflow-y-auto frame-scrollbar p-3 space-y-3",children:[c.length===0&&r.jsx("div",{className:"text-neutral-500 text-center py-8 select-none",children:t}),c.map(O=>r.jsx("div",{className:`flex ${O.role==="user"?"justify-end":"justify-start"}`,children:r.jsx("div",{className:`max-w-[85%] rounded-lg px-3 py-2 whitespace-pre-wrap break-words leading-relaxed ${O.role==="user"?"bg-emerald-500/10 text-emerald-100 border border-emerald-500/20":"bg-neutral-800/50 text-neutral-200 border border-neutral-700/50"}`,children:(O.parts??[]).map((_,U)=>{if(!_)return null;if(_.type==="text")return r.jsx("span",{children:_.text},U);if(Si(_)){const q=QC(_),G=Object.entries(_.input??{}).map(([X,L])=>`${X}: ${JSON.stringify(L)}`).join(", ");return r.jsxs("div",{className:"text-[11px] text-cyan-400/70 mt-1 font-mono",children:[r.jsx("span",{className:"text-neutral-500",children:"↳ "}),q,"(",G,")"]},U)}return null})})},O.id)),I&&c[c.length-1]?.role!=="assistant"&&r.jsx("div",{className:"flex justify-start",children:r.jsx("div",{className:"bg-neutral-800/50 border border-neutral-700/50 rounded-lg px-3 py-2 text-neutral-400",children:r.jsx("span",{className:"animate-pulse",children:"..."})})})]}),y&&r.jsxs("div",{className:"px-3 py-2 bg-red-900/20 border-t border-red-500/30 text-red-400 text-[11px] flex items-center gap-2",children:[r.jsx(T$,{size:12}),r.jsx("span",{className:"truncate",children:y.message||"An error occurred"})]}),r.jsxs("div",{className:"px-3 py-2.5 border-t border-neutral-700/50 bg-neutral-900/50",children:[R&&r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(Q$,{size:11,className:"text-neutral-500 shrink-0"}),x.map(O=>{const _=w.has(O.label);return r.jsx("button",{type:"button",onClick:()=>j(O.label),className:`text-[10px] px-2 py-0.5 rounded-full border transition-colors ${_?"bg-cyan-500/15 text-cyan-300 border-cyan-500/40":"text-neutral-500 border-neutral-700 hover:text-neutral-300 hover:border-neutral-600"}`,children:O.label},O.label)}),w.size>0&&r.jsx("span",{className:"text-[10px] text-neutral-600 ml-1",children:"attached"})]}),r.jsxs("form",{onSubmit:D,className:"flex items-center gap-2 rounded-lg border border-neutral-700 bg-neutral-800/60 px-3 py-2 focus-within:border-emerald-500/40 transition-colors",children:[c.length>0&&r.jsx("button",{type:"button",onClick:()=>p(),className:"p-1 rounded text-neutral-500 hover:text-neutral-300 hover:bg-neutral-700 transition-colors",title:"Clear",children:r.jsx(c6,{size:12})}),r.jsx("input",{ref:C,type:"text",value:A,onChange:O=>S(O.target.value),onKeyDown:z,placeholder:t,className:"flex-1 bg-transparent outline-none text-neutral-100 placeholder:text-neutral-500 caret-emerald-400",disabled:I}),I?r.jsx("button",{type:"button",onClick:()=>h(),className:"p-1.5 rounded text-amber-400 hover:bg-amber-900/20 transition-colors",title:"Stop",children:r.jsx(iA,{size:12})}):r.jsx("button",{type:"submit",disabled:!A.trim(),className:"text-[11px] px-2 py-1 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/30 hover:bg-emerald-500/20 disabled:opacity-30 disabled:cursor-default transition-colors",children:"Send"})]})]})]})}const g6={background:"#1a1a1a",foreground:"#abb2bf",cursor:"#528bff",cursorAccent:"#1a1a1a",selectionBackground:"#3e4451",selectionForeground:"#abb2bf",black:"#1a1a1a",red:"#e06c75",green:"#98c379",yellow:"#e5c07b",blue:"#61afef",magenta:"#c678dd",cyan:"#56b6c2",white:"#abb2bf",brightBlack:"#5c6370",brightRed:"#e06c75",brightGreen:"#98c379",brightYellow:"#e5c07b",brightBlue:"#61afef",brightMagenta:"#c678dd",brightCyan:"#56b6c2",brightWhite:"#ffffff"},v6=`
|
|
67
|
-
.xterm { cursor: text; position: relative; user-select: none; -ms-user-select: none; -webkit-user-select: none; }
|
|
68
|
-
.xterm.focus, .xterm:focus { outline: none; }
|
|
69
|
-
.xterm .xterm-helpers { position: absolute; top: 0; z-index: 5; }
|
|
70
|
-
.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; }
|
|
71
|
-
.xterm .composition-view { background: #000; color: #FFF; display: none; position: absolute; white-space: nowrap; z-index: 1; }
|
|
72
|
-
.xterm .composition-view.active { display: block; }
|
|
73
|
-
.xterm .xterm-viewport { background-color: #000; overflow-y: scroll; cursor: default; position: absolute; right: 0; left: 0; top: 0; bottom: 0; }
|
|
74
|
-
.xterm .xterm-screen { position: relative; }
|
|
75
|
-
.xterm .xterm-screen canvas { position: absolute; left: 0; top: 0; }
|
|
76
|
-
.xterm-char-measure-element { display: inline-block; visibility: hidden; position: absolute; top: 0; left: -9999em; line-height: normal; }
|
|
77
|
-
.xterm.enable-mouse-events { cursor: default; }
|
|
78
|
-
.xterm.xterm-cursor-pointer, .xterm .xterm-cursor-pointer { cursor: pointer; }
|
|
79
|
-
.xterm.column-select.focus { cursor: crosshair; }
|
|
80
|
-
.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; }
|
|
81
|
-
.xterm .xterm-accessibility-tree:not(.debug) *::selection { color: transparent; }
|
|
82
|
-
.xterm .xterm-accessibility-tree { font-family: monospace; user-select: text; white-space: pre; }
|
|
83
|
-
.xterm .xterm-accessibility-tree > div { transform-origin: left; width: fit-content; }
|
|
84
|
-
.xterm .live-region { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
|
|
85
|
-
.xterm-dim { opacity: 1 !important; }
|
|
86
|
-
.xterm-underline-1 { text-decoration: underline; }
|
|
87
|
-
.xterm-underline-2 { text-decoration: double underline; }
|
|
88
|
-
.xterm-underline-3 { text-decoration: wavy underline; }
|
|
89
|
-
.xterm-underline-4 { text-decoration: dotted underline; }
|
|
90
|
-
.xterm-underline-5 { text-decoration: dashed underline; }
|
|
91
|
-
.xterm-overline { text-decoration: overline; }
|
|
92
|
-
.xterm-overline.xterm-underline-1 { text-decoration: overline underline; }
|
|
93
|
-
.xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }
|
|
94
|
-
.xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }
|
|
95
|
-
.xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }
|
|
96
|
-
.xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }
|
|
97
|
-
.xterm-strikethrough { text-decoration: line-through; }
|
|
98
|
-
.xterm-screen .xterm-decoration-container .xterm-decoration { z-index: 6; position: absolute; }
|
|
99
|
-
.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer { z-index: 7; }
|
|
100
|
-
.xterm-decoration-overview-ruler { z-index: 8; position: absolute; top: 0; right: 0; pointer-events: none; }
|
|
101
|
-
.xterm-decoration-top { z-index: 2; position: relative; }
|
|
102
|
-
.xterm .xterm-scrollable-element > .scrollbar { cursor: default; }
|
|
103
|
-
.xterm .xterm-scrollable-element > .scrollbar > .scra { cursor: pointer; font-size: 11px !important; }
|
|
104
|
-
.xterm .xterm-scrollable-element > .visible { opacity: 1; background: rgba(0,0,0,0); transition: opacity 100ms linear; z-index: 11; }
|
|
105
|
-
.xterm .xterm-scrollable-element > .invisible { opacity: 0; pointer-events: none; }
|
|
106
|
-
.xterm .xterm-scrollable-element > .invisible.fade { transition: opacity 800ms linear; }
|
|
107
|
-
.xterm .xterm-scrollable-element > .shadow { position: absolute; display: none; }
|
|
108
|
-
.xterm .xterm-scrollable-element > .shadow.top { display: block; top: 0; left: 3px; height: 3px; width: 100%; }
|
|
109
|
-
.xterm .xterm-scrollable-element > .shadow.left { display: block; top: 3px; left: 0; height: 100%; width: 3px; }
|
|
110
|
-
`;function y6(){if(typeof document>"u"||document.querySelector("[data-xterm-css]"))return;const e=document.createElement("style");e.setAttribute("data-xterm-css",""),e.textContent=v6,document.head.appendChild(e)}function x6(e){return new Promise((t,n)=>{const s=new FileReader;s.onload=()=>{const i=s.result;t(i.split(",")[1])},s.onerror=n,s.readAsDataURL(e)})}function Oy({relay:e,fontSize:t=12,fontFamily:n="'JetBrains Mono', 'Hack Nerd Font', monospace",configItems:s,onOpenSettings:i,onStartService:l}){const{status:c,error:d,exitCode:h,cwd:m,setCwd:p,sendInput:y,resize:x,onData:w,connect:j,disconnect:N}=e,[k,E]=g.useState(!1),{apiBaseUrl:A}=Jc(),S=g.useRef(null),M=g.useRef(null),C=g.useRef(null),I=g.useRef(null),[R,D]=g.useState(!1),[z,O]=g.useState(!1),_=g.useRef(0);g.useEffect(()=>{const B=S.current;if(!B)return;const Y=te=>{te.key===" "&&!te.metaKey&&!te.ctrlKey&&!te.altKey&&te.stopPropagation()};return B.addEventListener("keydown",Y),()=>B.removeEventListener("keydown",Y)},[]);const U=`${A}/api/relay/upload`,q=g.useCallback(async B=>{try{const Y=await x6(B),te=await fetch(U,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:B.name,data:Y})}),{path:ae}=await te.json();return ae||null}catch(Y){return console.error("File upload failed:",Y),null}},[U]);g.useEffect(()=>{const B=S.current;if(!B)return;const Y=async te=>{if(!te.clipboardData)return;const ae=Array.from(te.clipboardData.items).filter(ee=>ee.type.startsWith("image/"));if(ae.length!==0){te.preventDefault(),te.stopPropagation();for(const ee of ae){const ie=ee.getAsFile();if(!ie)continue;const de=await q(ie);de&&y(de)}}};return B.addEventListener("paste",Y),()=>B.removeEventListener("paste",Y)},[y,q]);const G=g.useCallback(B=>{B.preventDefault(),B.dataTransfer.dropEffect="copy"},[]),X=g.useCallback(B=>{B.preventDefault(),_.current++,B.dataTransfer.types.includes("Files")&&O(!0)},[]),L=g.useCallback(B=>{B.preventDefault(),_.current--,_.current===0&&O(!1)},[]),F=g.useCallback(async B=>{B.preventDefault(),_.current=0,O(!1);const Y=Array.from(B.dataTransfer.files).filter(te=>te.type.startsWith("image/"));if(Y.length!==0)for(const te of Y){const ae=await q(te);ae&&y(ae)}},[y,q]);g.useEffect(()=>{let B=!1,Y=null;async function te(){const[{Terminal:ae},{FitAddon:ee},ie]=await Promise.all([sf(()=>import("./xterm-B-qIQCd3.js"),[]),sf(()=>import("./addon-fit-DX4qG4td.js"),[]),sf(()=>import("./addon-webgl-DCtw1yLn.js"),[]).catch(()=>null)]);if(y6(),B||!M.current)return;Y=new ae({fontSize:t,fontFamily:n,theme:g6,cursorBlink:!0,cursorStyle:"bar",allowTransparency:!0,scrollback:5e3,convertEol:!1,allowProposedApi:!0});const de=new ee;if(Y.loadAddon(de),Y.open(M.current),ie)try{const xe=new ie.WebglAddon;xe.onContextLoss(()=>{xe.dispose()}),Y.loadAddon(xe)}catch{}try{de.fit()}catch{}C.current=Y,I.current=de,x(Y.cols,Y.rows),Y.onData(xe=>{y(xe)}),D(!0)}return te(),()=>{B=!0,Y&&(Y.dispose(),C.current=null,I.current=null)}},[]),g.useEffect(()=>{const B=C.current;if(B){B.options.fontSize=t,B.options.fontFamily=n;try{I.current?.fit()}catch{}}},[t,n]),g.useEffect(()=>{if(R)return w(B=>{C.current?.write(B)}),()=>{w(()=>{})}},[R,w]),g.useEffect(()=>{const B=M.current;if(!B||!R)return;const Y=new ResizeObserver(()=>{const te=I.current,ae=C.current;if(!(!te||!ae))try{te.fit(),x(ae.cols,ae.rows)}catch{}});return Y.observe(B),()=>Y.disconnect()},[R,x]),g.useEffect(()=>{c==="connected"&&C.current&&C.current.focus()},[c]);const H=g.useCallback(()=>{c==="connected"&&C.current&&C.current.focus()},[c]),V=c==="error"&&d==="Relay service is not running",W=g.useCallback(async()=>{if(l){E(!0);try{await l()&&setTimeout(()=>j(),500)}finally{E(!1)}}},[l,j]);let $=null;return V?$=r.jsxs("div",{className:"flex flex-col items-center gap-4 max-w-xs text-center px-4",children:[r.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/10 border border-amber-500/20 flex items-center justify-center",children:r.jsx("span",{className:"text-amber-400 text-[14px]",children:"!"})}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[12px] text-neutral-300 font-medium mb-1",children:"Relay service not running"}),r.jsx("div",{className:"text-[11px] text-neutral-500 leading-relaxed",children:l?"Start the relay service to open a terminal session.":"Start the relay service from the Workspace Manager."})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[l&&r.jsx("button",{type:"button",onClick:W,disabled:k,className:"text-[11px] px-4 py-1.5 rounded-full border border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10 transition-colors font-medium disabled:opacity-50",children:k?"Starting...":"Start Service"}),r.jsx("button",{type:"button",onClick:()=>j(),className:"text-[11px] px-3 py-1.5 rounded-full border border-neutral-700 text-neutral-400 hover:text-neutral-300 hover:bg-white/5 transition-colors",children:"Retry"}),i&&r.jsx("button",{type:"button",onClick:i,className:"text-[11px] px-3 py-1.5 rounded-full border border-neutral-700 text-neutral-400 hover:text-neutral-300 hover:bg-white/5 transition-colors",children:"Settings"})]})]}):c==="error"&&d?$=r.jsxs("div",{className:"flex flex-col items-center gap-3 max-w-md text-center px-4",children:[r.jsx("div",{className:"w-8 h-8 rounded-full bg-red-500/10 flex items-center justify-center",children:r.jsx("span",{className:"text-red-400 text-sm",children:"!"})}),r.jsx("span",{className:"text-red-400 text-[12px] font-medium",children:"Session failed"}),r.jsx("code",{className:"text-[11px] text-neutral-400 bg-neutral-800/80 px-3 py-2 rounded-md whitespace-pre-wrap leading-relaxed max-h-32 overflow-y-auto w-full text-left",children:d}),h!==null&&h!==0&&r.jsxs("span",{className:"text-[10px] text-neutral-600",children:["Exit code ",h]}),r.jsx("button",{type:"button",onClick:()=>j(),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"})]}):c==="disconnected"?$=r.jsxs("div",{className:"flex flex-col items-center gap-4 max-w-xs text-center px-4",children:[r.jsx("div",{className:"w-8 h-8 rounded-full bg-neutral-800 border border-neutral-700 flex items-center justify-center",children:r.jsx("span",{className:"text-neutral-500 text-[14px]",children:"▷"})}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[12px] text-neutral-300 font-medium mb-1",children:"Terminal relay disconnected"}),r.jsx("div",{className:"text-[11px] text-neutral-500 leading-relaxed",children:"Set working directory and connect."})]}),r.jsxs("form",{className:"w-full",onSubmit:B=>{B.preventDefault(),j()},children:[r.jsx("label",{className:"text-[10px] font-mono text-neutral-500 uppercase tracking-wider mb-1 block text-left",children:"Working Directory"}),r.jsx("input",{type:"text",value:m,onChange:B=>p(B.target.value),placeholder:"~/dev/my-project",className:"w-full bg-neutral-800/80 border border-neutral-700/50 rounded px-3 py-1.5 text-[11px] font-mono text-neutral-200 placeholder:text-neutral-600 outline-none focus:border-cyan-500/40 transition-colors",spellCheck:!1,autoComplete:"off"})]}),s&&s.length>0&&r.jsx("div",{className:"w-full grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-[10px] font-mono bg-neutral-800/60 border border-neutral-700/40 rounded-md px-3 py-2",children:s.map(B=>r.jsxs("div",{className:"contents",children:[r.jsx("span",{className:"text-neutral-500",children:B.label}),r.jsx("span",{className:"text-neutral-400 truncate text-left",children:B.value})]},B.label))}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{type:"button",onClick:()=>j(),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"}),i&&r.jsx("button",{type:"button",onClick:i,className:"text-[11px] px-3 py-1.5 rounded-full border border-neutral-700 text-neutral-400 hover:text-neutral-300 hover:bg-white/5 transition-colors",children:"Settings"})]})]}):c==="connecting"&&($=r.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[r.jsx("div",{className:"w-6 h-6 border-2 border-neutral-600 border-t-cyan-400 rounded-full animate-spin"}),r.jsx("span",{className:"text-[12px] text-neutral-400",children:"Connecting to relay..."}),r.jsx("button",{type:"button",onClick:()=>{N()},className:"text-[10px] px-3 py-1 rounded-full border border-neutral-700 text-neutral-500 hover:text-neutral-300 hover:bg-white/5 transition-colors",children:"Cancel"})]})),r.jsxs("div",{ref:S,className:"relative flex flex-col h-full overflow-hidden",onClick:H,onDragOver:G,onDragEnter:X,onDragLeave:L,onDrop:F,children:[$&&r.jsx("div",{className:"flex items-center justify-center h-full font-mono text-[12px] absolute inset-0 z-10 bg-neutral-900/90",children:$}),z&&r.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:r.jsx("span",{className:"text-cyan-400 font-mono text-sm",children:"Drop image to get path"})}),r.jsx("div",{ref:M,className:"flex-1 min-h-0 min-w-0 overflow-hidden",style:{visibility:$?"hidden":"visible",padding:"4px 8px"}})]})}function b6({app:e,commands:t,state:n,relayUrl:s="ws://localhost:3600",cwd:i,agent:l="pi",provider:c,model:d,backend:h="pty",tmuxSession:m,workspaceFiles:p,onOpenSettings:y,onStartService:x,voice:w,voiceEnabled:j=!0}){const[N,k]=Hs(`assistant.${e.id}.mode`,"relay"),[E,A]=g.useState(""),S=g.useMemo(()=>({...o$,...w}),[w]),[M,C]=Hs(`assistant.${e.id}.voice.speakReplies`,S.speakReplies),{serviceApiUrl:I}=Jc(),R=g.useMemo(()=>j6(e),[e]),D=_y({url:s,systemPrompt:R,cwd:i,workspaceFiles:p,sessionKey:`assistant-${e.id}`,backend:h,tmuxSession:m,agent:l,provider:l==="pi"?c:void 0,model:l==="pi"?d:void 0}),z=g.useCallback(async()=>{if(x)return x();try{return(await(await fetch(`${I}/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}},[x,I]),O=g.useMemo(()=>{const $=[{label:"Relay",value:s},{label:"Agent",value:l}];return i&&$.push({label:"CWD",value:i}),l==="pi"&&d&&$.push({label:"Model",value:d}),$},[s,l,i,d]),_=r$(),[U,q]=g.useState("text"),G=WL({app:e,commands:t,state:n,provider:c,model:d,onFinish:({message:$,isAbort:B,isDisconnect:Y,isError:te})=>{if(!j||!M||B||Y||te||$.role!=="assistant")return;const ae=w$($),ee=j$(ae,S);ee&&_.speak(ee,{provider:S.replyProvider,model:S.replyModel,voice:S.replyVoice||void 0,rate:S.replyRate,metadata:{surface:"hudson-assistant",appId:e.id,source:U}})}}),X=t$({surface:"hudson-assistant",metadata:{appId:e.id},onTranscript:$=>{const B=[E.trim(),$].filter(Boolean).join(" ");S.autoSend&&G.status!=="streaming"&&G.status!=="submitted"?(A(""),q("voice"),G.sendMessage({text:B})):A(B)}}),L=g.useCallback(()=>{X.status==="recording"?X.stop():X.start()},[X]),F=e.intents?.length??0,H=j,V=X.status==="transcribing",W=X.status==="recording";return r.jsxs("div",{className:"flex flex-col h-full",children:[r.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 border-b border-neutral-700/50 bg-neutral-900/50",children:[r.jsx(a6,{size:11,className:"text-cyan-400/60"}),r.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wider text-neutral-500",children:"Assistant"}),r.jsxs("span",{className:"text-[10px] font-mono text-neutral-600",children:["· ",e.name]}),r.jsx("div",{className:"flex-1"}),H&&N==="chat"&&r.jsx("button",{type:"button",onClick:()=>{M&&_.stop(),C(!M)},className:`p-1 rounded transition-colors ${M?"text-cyan-300 hover:text-cyan-200":"text-neutral-500 hover:text-neutral-300"}`,title:M?"Speaker on (click to mute)":"Speaker off (click to enable)",children:_.isPlaying?r.jsx(G1,{size:12,className:"animate-spin"}):M?r.jsx(d6,{size:12}):r.jsx(h6,{size:12})}),r.jsxs("div",{className:"flex items-center gap-1 rounded-full border border-neutral-700 p-0.5",children:[r.jsx(X1,{active:N==="relay",onClick:()=>k("relay"),children:"Relay"}),r.jsx(X1,{active:N==="chat",onClick:()=>k("chat"),children:"Chat"})]}),N==="relay"&&D.status==="connected"&&r.jsx("button",{type:"button",onClick:()=>D.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"}),N==="relay"&&D.status==="connected"&&r.jsx("button",{type:"button",onClick:()=>D.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"}),N==="relay"&&D.status!=="connected"&&D.status!=="connecting"&&r.jsx("button",{type:"button",onClick:()=>D.connect(),className:"text-[10px] px-2 py-0.5 rounded-full border text-emerald-400 border-emerald-500/30 hover:bg-emerald-500/10 transition-colors",children:"Connect"})]}),r.jsx("div",{className:"flex-1 min-h-0",children:N==="relay"?r.jsx(Oy,{relay:D,configItems:O,onOpenSettings:y,onStartService:z}):r.jsx(p6,{chat:G,placeholder:F===0?`Ask about ${e.name} — no intents declared, conversation only.`:`Ask ${e.name} to do something… (${F} intent${F===1?"":"s"})`,inputValue:E,onInputChange:$=>{U==="voice"&&$.length===0&&q("text"),A($)},inputExtras:H&&X.isSupported?r.jsx("button",{type:"button",onClick:L,disabled:V,className:`p-1 rounded transition-colors disabled:opacity-30 ${W?"bg-red-500/15 text-red-300 hover:bg-red-500/20":"text-neutral-500 hover:text-cyan-400"}`,title:W?"Stop recording":"Record voice prompt",children:V?r.jsx(G1,{size:12,className:"animate-spin"}):W?r.jsx(iA,{size:11}):r.jsx($$,{size:12})}):void 0,inputStatus:H?r.jsx(w6,{inputStatus:X.status,inputError:X.error,outputStatus:_.status,outputError:_.error}):void 0})})]})}function w6({inputStatus:e,inputError:t,outputStatus:n,outputError:s}){const i=K1(e)??K1(n),l=t??s;return!i&&!l?null:r.jsxs("div",{className:"flex items-center gap-2",children:[i&&r.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full border font-mono ${i.className}`,children:i.label}),l&&r.jsx("span",{className:"text-[10px] text-neutral-500 truncate flex-1",title:l,children:l})]})}function K1(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-emerald-500/20 bg-emerald-500/10 text-emerald-300"};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 X1({active:e,onClick:t,children:n}){return r.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-neutral-500 hover:text-neutral-300"}`,children:n})}function j6(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 s of n)t.push(`- ${s.title} — ${s.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(`
|
|
111
|
-
`)}typeof window<"u"&&localStorage.getItem("frame_sounds");function Dy(){const{titleBarInset:e}=Jc();return g.useMemo(()=>{const t=fh.layout.navHeight+e;return{navTotalHeight:t,panelTopOffset:t}},[e])}const lA=({panOffset:e,scale:t,onPan:n,onPanStart:s,onPanEnd:i,isPanLocked:l=!1,onClick:c,showGuides:d=!1,onGuidesChange:h,gridOpacity:m=1})=>{const[p,y]=g.useState(d),[x,w]=g.useState(!1),j=g.useRef(!1),N=g.useRef({x:0,y:0}),k=g.useRef({active:!1,startX:0,startY:0}),E=g.useRef(null),A=g.useRef(null),S=g.useRef(null),M=4,C=g.useRef({x:0,y:0}),I=g.useRef(0),R=g.useRef(!1);g.useEffect(()=>{y(d)},[d]);const D=g.useCallback(Y=>{const te=Y;return te?te.tagName==="INPUT"||te.tagName==="TEXTAREA"||te.isContentEditable:!1},[]),z=g.useCallback(Y=>{const te=Y;return te?!!te.closest('button, [role="button"], a, input, textarea, select, [data-interactive="true"]'):!1},[]),O=g.useCallback(Y=>{j.current=Y,w(Y)},[]);g.useEffect(()=>{const Y=ie=>{if(I.current=ie.buttons,k.current.active&&(ie.buttons&1)!==1&&(k.current.active=!1),j.current&&(ie.buttons&1)!==1){O(!1),k.current.active=!1,i?.(),document.body.style.cursor="";return}if(l&&j.current){O(!1),k.current.active=!1,i?.(),document.body.style.cursor="";return}const de=E.current?.getBoundingClientRect(),xe=de?ie.clientX-de.left:ie.clientX,Ae=de?ie.clientY-de.top:ie.clientY;if(C.current={x:xe,y:Ae},A.current&&(A.current.style.left=`${xe}px`),S.current&&(S.current.style.top=`${Ae}px`),k.current.active&&!j.current){const me=ie.clientX-k.current.startX,Pe=ie.clientY-k.current.startY;Math.hypot(me,Pe)>=M&&(k.current.active=!1,O(!0),R.current=!0,s?.(),N.current={x:ie.clientX,y:ie.clientY},document.body.style.cursor="grabbing")}j.current&&(n({x:(ie.clientX-N.current.x)/t,y:(ie.clientY-N.current.y)/t}),N.current={x:ie.clientX,y:ie.clientY})},te=ie=>{I.current=ie.buttons,k.current.active=!1,j.current&&(O(!1),i?.(),document.body.style.cursor="")},ae=ie=>{(ie.metaKey||ie.ctrlKey)&&ie.key==="\\"&&(ie.preventDefault(),y(de=>{const xe=!de;return h?.(xe),xe}))},ee=()=>{k.current.active=!1,te(new MouseEvent("mouseup"))};return window.addEventListener("mousemove",Y),window.addEventListener("mouseup",te),window.addEventListener("keydown",ae),window.addEventListener("blur",ee),document.addEventListener("visibilitychange",ee),()=>{window.removeEventListener("mousemove",Y),window.removeEventListener("mouseup",te),window.removeEventListener("keydown",ae),window.removeEventListener("blur",ee),document.removeEventListener("visibilitychange",ee)}},[n,i,s,t,D,z,l,O,h]),g.useEffect(()=>{!l||!j.current||(O(!1),i?.(),document.body.style.cursor="")},[l,i,O]);const _=Y=>{R.current=!1,!(l||Y.button!==0)&&(D(Y.target)||z(Y.target)||(I.current=Y.buttons,k.current={active:!0,startX:Y.clientX,startY:Y.clientY},Y.preventDefault()))},U=Y=>{!R.current&&c&&c(Y),R.current=!1},[q,G]=g.useState({w:0,h:0});g.useEffect(()=>{const Y=()=>G({w:window.innerWidth,h:window.innerHeight});return Y(),window.addEventListener("resize",Y),()=>window.removeEventListener("resize",Y)},[]);const X=Math.max(.4,Math.min(2,t)),L=100*X,F=20*X,H="var(--hud-canvas-dot-minor)",V="var(--hud-canvas-dot-major)",W="color-mix(in srgb, oklch(var(--accent)) 18%, transparent)",$=(q.w/2+e.x*t)%L,B=(q.h/2+e.y*t)%L;return r.jsxs("div",{ref:E,className:`absolute inset-0 z-0 overflow-hidden bg-background ${x?"cursor-grabbing":"cursor-grab"}`,onMouseDown:_,onClick:U,children:[r.jsx("div",{className:"absolute pointer-events-none",style:{inset:"-100px",opacity:.8*m,transition:"opacity 1s ease",backgroundImage:`radial-gradient(circle, ${H} 1px, transparent 1px)`,backgroundSize:`${F}px ${F}px`,backgroundPosition:`${$+100}px ${B+100}px`}}),r.jsx("div",{className:"absolute pointer-events-none",style:{inset:"-100px",opacity:.45*m,transition:"opacity 1s ease",backgroundImage:`radial-gradient(circle, ${V} 1.5px, transparent 1.5px)`,backgroundSize:`${L}px ${L}px`,backgroundPosition:`${$+100}px ${B+100}px`}}),p&&r.jsxs(r.Fragment,{children:[r.jsx("div",{ref:A,className:"absolute top-0 bottom-0 w-px pointer-events-none",style:{left:0,backgroundColor:W}}),r.jsx("div",{ref:S,className:"absolute left-0 right-0 h-px pointer-events-none",style:{top:0,backgroundColor:W}})]})]})},N6=({scale:e,onZoom:t,min:n=.2,max:s=3,step:i=.1})=>{const[l,c]=g.useState(!1),[d,h]=g.useState(""),m=g.useRef(null),p=g.useCallback(k=>Math.min(s,Math.max(n,k)),[n,s]),y=g.useCallback(()=>{t(p(e+i))},[e,i,t,p]),x=g.useCallback(()=>{t(p(e-i))},[e,i,t,p]),w=g.useCallback(()=>{h(Math.round(e*100).toString()),c(!0)},[e]),j=g.useCallback(()=>{c(!1);const k=parseInt(d,10);!isNaN(k)&&k>0&&t(p(k/100))},[d,t,p]),N=g.useCallback(k=>{k.key==="Enter"?j():k.key==="Escape"&&c(!1)},[j]);return g.useEffect(()=>{l&&m.current&&(m.current.focus(),m.current.select())},[l]),r.jsxs("div",{className:"pointer-events-auto flex flex-col items-center bg-card/95 backdrop-blur-xl border border-border/80 rounded-md shadow-[0_0_20px_rgba(0,0,0,0.6)] overflow-hidden",children:[r.jsx("button",{onClick:y,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:r.jsx(t6,{size:14})}),r.jsx("div",{className:"w-full border-t border-b border-border/60",children:l?r.jsx("input",{ref:m,type:"text",value:d,onChange:k=>h(k.target.value.replace(/[^0-9]/g,"")),onBlur:j,onKeyDown:N,className:"w-9 py-1.5 text-center text-[11px] font-mono text-foreground bg-background/60 outline-none tabular-nums"}):r.jsxs("button",{onClick:w,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),"%"]})}),r.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 out",children:r.jsx(F$,{size:14})})]})},S6={...bE};let J1=0;function k6(e,t="mui"){const[n,s]=g.useState(e),i=e||n;return g.useEffect(()=>{n==null&&(J1+=1,s(`${t}-${J1}`))},[n,t]),i}const Q1=S6.useId;function zr(e,t){if(Q1!==void 0){const n=Q1();return e??(t?`${t}-${n}`:n)}return k6(e,t)}function Ti(e,...t){const n=new URL(`https://base-ui.com/production-error/${e}`);return t.forEach(s=>n.searchParams.append("args[]",s)),`Base UI error #${e}; visit ${n} for the full message.`}const cA=g.createContext(void 0);function hh(e=!0){const t=g.useContext(cA);if(t===void 0&&!e)throw new Error(Ti(25));return t}const uA=g.createContext(void 0);function dA(e){const t=g.useContext(uA);if(t===void 0&&!e)throw new Error(Ti(33));return t}const Py=g.createContext(void 0);function ll(e){const t=g.useContext(Py);if(t===void 0&&!e)throw new Error(Ti(36));return t}const eN={};function Is(e,t){const n=g.useRef(eN);return n.current===eN&&(n.current=e(t)),n}function Lc(e,t,n,s){const i=Is(fA).current;return C6(i,e,t,n,s)&&hA(i,[e,t,n,s]),i.callback}function E6(e){const t=Is(fA).current;return A6(t,e)&&hA(t,e),t.callback}function fA(){return{callback:null,cleanup:null,refs:[]}}function C6(e,t,n,s,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==s||e.refs[3]!==i}function A6(e,t){return e.refs.length!==t.length||e.refs.some((n,s)=>n!==t[s])}function hA(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 s=Array(t.length).fill(null);for(let i=0;i<t.length;i+=1){const l=t[i];if(l!=null)switch(typeof l){case"function":{const c=l(n);typeof c=="function"&&(s[i]=c);break}case"object":{l.current=n;break}}}e.cleanup=()=>{for(let i=0;i<t.length;i+=1){const l=t[i];if(l!=null)switch(typeof l){case"function":{const c=s[i];typeof c=="function"?c():l(null);break}case"object":{l.current=null;break}}}}}}}const T6=parseInt(g.version,10);function zy(e){return T6>=e}function tN(e){if(!g.isValidElement(e))return null;const t=e,n=t.props;return(zy(19)?n?.ref:t.ref)??null}function gv(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function M6(e,t){const n={};for(const s in e){const i=e[s];if(t?.hasOwnProperty(s)){const l=t[s](i);l!=null&&Object.assign(n,l);continue}i===!0?n[`data-${s.toLowerCase()}`]="":i&&(n[`data-${s.toLowerCase()}`]=i.toString())}return n}function R6(e,t){return typeof e=="function"?e(t):e}function _6(e,t){return typeof e=="function"?e(t):e}const jc={};function mh(e,t,n,s,i){let l={...vv(e,jc)};return t&&(l=af(l,t)),n&&(l=af(l,n)),s&&(l=af(l,s)),l}function I6(e){if(e.length===0)return jc;if(e.length===1)return vv(e[0],jc);let t={...vv(e[0],jc)};for(let n=1;n<e.length;n+=1)t=af(t,e[n]);return t}function af(e,t){return mA(t)?t(e):O6(e,t)}function O6(e,t){if(!t)return e;for(const n in t){const s=t[n];switch(n){case"style":{e[n]=gv(e.style,s);break}case"className":{e[n]=pA(e.className,s);break}default:D6(n,s)?e[n]=P6(e[n],s):e[n]=s}}return e}function D6(e,t){const n=e.charCodeAt(0),s=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&s===110&&i>=65&&i<=90&&(typeof t=="function"||typeof t>"u")}function mA(e){return typeof e=="function"}function vv(e,t){return mA(e)?e(t):e??jc}function P6(e,t){return t?e?n=>{if(z6(n)){const i=n;yv(i);const l=t(i);return i.baseUIHandlerPrevented||e?.(i),l}const s=t(n);return e?.(n),s}:t:e}function yv(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function pA(e,t){return t?e?t+" "+e:t:e}function z6(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}function gA(){}const vA=Object.freeze([]),ts=Object.freeze({}),L6=500,$6={style:{transition:"none"}},U6="data-base-ui-click-trigger",B6={fallbackAxisSide:"none"},V6={clipPath:"inset(50%)",position:"fixed",top:0,left:0};function Lr(e,t,n={}){const s=t.render,i=F6(t,n);if(n.enabled===!1)return null;const l=n.state??ts;return H6(e,s,i,l)}function F6(e,t={}){const{className:n,style:s,render:i}=e,{state:l=ts,ref:c,props:d,stateAttributesMapping:h,enabled:m=!0}=t,p=m?R6(n,l):void 0,y=m?_6(s,l):void 0,x=m?M6(l,h):ts,w=m?gv(x,Array.isArray(d)?I6(d):d)??ts:ts;return typeof document<"u"&&(m?Array.isArray(c)?w.ref=E6([w.ref,tN(i),...c]):w.ref=Lc(w.ref,tN(i),c):Lc(null,null)),m?(p!==void 0&&(w.className=pA(w.className,p)),y!==void 0&&(w.style=gv(w.style,y)),w):ts}function H6(e,t,n,s){if(t){if(typeof t=="function")return t(n,s);const i=mh(n,t.props);return i.ref=n.ref,g.cloneElement(t,i)}return q6(e,n)}function q6(e,t){return g.createElement(e,t)}let Tf=(function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e})({});const Z6={[Tf.startingStyle]:""},W6={[Tf.endingStyle]:""},Y6={transitionStatus(e){return e==="starting"?Z6:e==="ending"?W6:null}};let Ly=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=Tf.startingStyle]="startingStyle",e[e.endingStyle=Tf.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e})({}),nN=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const G6={[nN.popupOpen]:"",[nN.pressed]:""},K6={[Ly.open]:""},X6={[Ly.closed]:""},J6={[Ly.anchorHidden]:""},Q6={open(e){return e?G6:null}},yA={open(e){return e?K6:X6},anchorHidden(e){return e?J6:null}},e8="none",Mf="trigger-press",xi="trigger-hover",sN="trigger-focus",$y="outside-press",xA="item-press",ph="focus-out",bA="escape-key",rf="list-navigation",t8="cancel-open",vc="sibling-open",n8="imperative-action",ng=bE[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],s8=ng&&ng!==g.useLayoutEffect?ng:e=>e();function Qe(e){const t=Is(a8).current;return t.next=e,s8(t.effect),t.trampoline}function a8(){const e={next:void 0,callback:r8,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function r8(){}function gh(){return typeof window<"u"}function $r(e){return Uy(e)?(e.nodeName||"").toLowerCase():"#document"}function In(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function pa(e){var t;return(t=(Uy(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Uy(e){return gh()?e instanceof Node||e instanceof In(e).Node:!1}function Ht(e){return gh()?e instanceof Element||e instanceof In(e).Element:!1}function dn(e){return gh()?e instanceof HTMLElement||e instanceof In(e).HTMLElement:!1}function xv(e){return!gh()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof In(e).ShadowRoot}const i8=new Set(["inline","contents"]);function Mi(e){const{overflow:t,overflowX:n,overflowY:s,display:i}=gs(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&!i8.has(i)}const o8=new Set(["table","td","th"]);function l8(e){return o8.has($r(e))}const c8=[":popover-open",":modal"];function vh(e){return c8.some(t=>{try{return e.matches(t)}catch{return!1}})}const u8=["transform","translate","scale","rotate","perspective"],d8=["transform","translate","scale","rotate","perspective","filter"],f8=["paint","layout","strict","content"];function By(e){const t=yh(),n=Ht(e)?gs(e):e;return u8.some(s=>n[s]?n[s]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||d8.some(s=>(n.willChange||"").includes(s))||f8.some(s=>(n.contain||"").includes(s))}function h8(e){let t=ha(e);for(;dn(t)&&!ca(t);){if(By(t))return t;if(vh(t))return null;t=ha(t)}return null}function yh(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const m8=new Set(["html","body","#document"]);function ca(e){return m8.has($r(e))}function gs(e){return In(e).getComputedStyle(e)}function xh(e){return Ht(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ha(e){if($r(e)==="html")return e;const t=e.assignedSlot||e.parentNode||xv(e)&&e.host||pa(e);return xv(t)?t.host:t}function wA(e){const t=ha(e);return ca(t)?e.ownerDocument?e.ownerDocument.body:e.body:dn(t)&&Mi(t)?t:wA(t)}function Er(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=wA(e),l=i===((s=e.ownerDocument)==null?void 0:s.body),c=In(i);if(l){const d=bv(c);return t.concat(c,c.visualViewport||[],Mi(i)?i:[],d&&n?Er(d):[])}return t.concat(i,Er(i,[],n))}function bv(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const p8=()=>{},Ke=typeof document<"u"?g.useLayoutEffect:p8,g8=g.createContext(void 0);function v8(e=!1){const t=g.useContext(g8);if(t===void 0&&!e)throw new Error(Ti(16));return t}function y8(e){const{focusableWhenDisabled:t,disabled:n,composite:s=!1,tabIndex:i=0,isNativeButton:l}=e,c=s&&t!==!1,d=s&&t===!1;return{props:g.useMemo(()=>{const m={onKeyDown(p){n&&t&&p.key!=="Tab"&&p.preventDefault()}};return s||(m.tabIndex=i,!l&&n&&(m.tabIndex=t?i:-1)),(l&&(t||c)||!l&&n)&&(m["aria-disabled"]=n),l&&(!t||d)&&(m.disabled=n),m},[s,n,t,c,d,l,i])}}function x8(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:s=0,native:i=!0}=e,l=g.useRef(null),c=v8(!0)!==void 0,d=Qe(()=>{const x=l.current;return!!(x?.tagName==="A"&&x?.href)}),{props:h}=y8({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:s,isNativeButton:i}),m=g.useCallback(()=>{const x=l.current;b8(x)&&c&&t&&h.disabled===void 0&&x.disabled&&(x.disabled=!1)},[t,h.disabled,c]);Ke(m,[m]);const p=g.useCallback((x={})=>{const{onClick:w,onMouseDown:j,onKeyUp:N,onKeyDown:k,onPointerDown:E,...A}=x;return mh({type:i?"button":void 0,onClick(M){if(t){M.preventDefault();return}w?.(M)},onMouseDown(M){t||j?.(M)},onKeyDown(M){if(t||(yv(M),k?.(M)),M.baseUIHandlerPrevented)return;const C=M.target===M.currentTarget&&!i&&!d()&&!t,I=M.key==="Enter",R=M.key===" ";C&&((R||I)&&M.preventDefault(),I&&w?.(M))},onKeyUp(M){t||(yv(M),N?.(M)),!M.baseUIHandlerPrevented&&M.target===M.currentTarget&&!i&&!t&&M.key===" "&&w?.(M)},onPointerDown(M){if(t){M.preventDefault();return}E?.(M)}},i?void 0:{role:"button"},h,A)},[t,h,i,d]),y=Qe(x=>{l.current=x,m()});return{getButtonProps:p,buttonRef:y}}function b8(e){return dn(e)&&e.tagName==="BUTTON"}const w8={type:"regular-item"};function j8(e){const{closeOnClick:t,disabled:n=!1,highlighted:s,id:i,store:l,nativeButton:c,itemMetadata:d,nodeId:h}=e,m=g.useRef(null),p=hh(!0),y=p!==void 0,{events:x}=l.useState("floatingTreeRoot"),{getButtonProps:w,buttonRef:j}=x8({disabled:n,focusableWhenDisabled:!0,native:c}),N=g.useCallback(E=>mh({id:i,role:"menuitem",tabIndex:s?0:-1,onMouseMove(A){h&&x.emit("itemhover",{nodeId:h,target:A.currentTarget})},onMouseEnter(){d.type==="submenu-trigger"&&d.setActive()},onKeyUp(A){A.key===" "&&l.context.typingRef.current&&A.preventBaseUIHandler()},onClick(A){t&&x.emit("close",{domEvent:A,reason:xA})},onMouseUp(A){if(p){const S=p.initialCursorPointRef.current;if(p.initialCursorPointRef.current=null,y&&S&&Math.abs(A.clientX-S.x)<=1&&Math.abs(A.clientY-S.y)<=1)return}m.current&&l.context.allowMouseUpTriggerRef.current&&(!y||A.button===2)&&d.type==="regular-item"&&m.current.click()}},E,w),[i,s,w,t,x,l,y,p,d,h]),k=Lc(m,j);return g.useMemo(()=>({getItemProps:N,itemRef:k}),[N,k])}const jA=g.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function N8(){return g.useContext(jA)}let S8=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function k8(e={}){const{label:t,metadata:n,textRef:s,indexGuessBehavior:i,index:l}=e,{register:c,unregister:d,subscribeMapChange:h,elementsRef:m,labelsRef:p,nextIndexRef:y}=N8(),x=g.useRef(-1),[w,j]=g.useState(l??(i===S8.GuessFromOrder?()=>{if(x.current===-1){const E=y.current;y.current+=1,x.current=E}return x.current}:-1)),N=g.useRef(null),k=g.useCallback(E=>{if(N.current=E,w!==-1&&E!==null&&(m.current[w]=E,p)){const A=t!==void 0;p.current[w]=A?t:s?.current?.textContent??E.textContent}},[w,m,p,t,s]);return Ke(()=>{if(l!=null)return;const E=N.current;if(E)return c(E,n),()=>{d(E)}},[l,c,d,n]),Ke(()=>{if(l==null)return h(E=>{const A=N.current?E.get(N.current)?.index:null;A!=null&&j(A)})},[l,h,j]),g.useMemo(()=>({ref:k,index:w}),[w,k])}function NA(e){return zr(e,"base-ui")}function yn(e,t,n,s){let i=!1,l=!1;const c=ts;return{reason:e,event:t??new Event("base-ui"),cancel(){i=!0},allowPropagation(){l=!0},get isCanceled(){return i},get isPropagationAllowed(){return l},trigger:n,...c}}var ki=wE();const E8=[];function SA(e){g.useEffect(e,E8)}const Ed=null;class C8{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=t=>{this.isScheduled=!1;const n=this.callbacks,s=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,s>0)for(let i=0;i<n.length;i+=1)n[i]?.(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 Cd=new C8;class oa{static create(){return new oa}static request(t){return Cd.request(t)}static cancel(t){return Cd.cancel(t)}currentId=Ed;request(t){this.cancel(),this.currentId=Cd.request(()=>{this.currentId=Ed,t()})}cancel=()=>{this.currentId!==Ed&&(Cd.cancel(this.currentId),this.currentId=Ed)};disposeEffect=()=>this.cancel}function Vy(){const e=Is(oa.create).current;return SA(e.disposeEffect),e}function A8(e,t=!1,n=!1){const[s,i]=g.useState(e&&t?"idle":void 0),[l,c]=g.useState(e);return e&&!l&&(c(!0),i("starting")),!e&&l&&s!=="ending"&&!n&&i("ending"),!e&&!l&&s==="ending"&&i(void 0),Ke(()=>{if(!e&&l&&s!=="ending"&&n){const d=oa.request(()=>{i("ending")});return()=>{oa.cancel(d)}}},[e,l,s,n]),Ke(()=>{if(!e||t)return;const d=oa.request(()=>{ki.flushSync(()=>{i(void 0)})});return()=>{oa.cancel(d)}},[t,e]),Ke(()=>{if(!e||!t)return;e&&l&&s!=="idle"&&i("starting");const d=oa.request(()=>{i("idle")});return()=>{oa.cancel(d)}},[t,e,l,i,s]),g.useMemo(()=>({mounted:l,setMounted:c,transitionStatus:s}),[l,s])}function Qn(e){const t=Is(T8,e).current;return t.next=e,Ke(t.effect),t}function T8(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}function ui(e){return e==null?e:"current"in e?e.current:e}function M8(e,t=!1,n=!0){const s=Vy();return Qe((i,l=null)=>{s.cancel();const c=ui(e);c!=null&&(typeof c.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED?i():s.request(()=>{function d(){c&&Promise.all(c.getAnimations().map(h=>h.finished)).then(()=>{l!=null&&l.aborted||ki.flushSync(i)}).catch(()=>{if(n){if(l!=null&&l.aborted)return;ki.flushSync(i)}else c.getAnimations().length>0&&c.getAnimations().some(h=>h.pending||h.playState!=="finished")&&d()})}t?s.request(d):d()}))})}function kA(e){const{enabled:t=!0,open:n,ref:s,onComplete:i}=e,l=Qn(n),c=Qe(i),d=M8(s,n);g.useEffect(()=>{t&&d(()=>{n===l.current&&c()})},[t,n,c,d,l])}const EA=g.createContext(void 0);function R8(){const e=g.useContext(EA);if(e===void 0)throw new Error(Ti(31));return e}const _8=g.forwardRef(function(t,n){const{render:s,className:i,...l}=t,[c,d]=g.useState(void 0),h=g.useMemo(()=>({setLabelId:d}),[d]),m=Lr("div",t,{ref:n,props:{role:"group","aria-labelledby":c,...l}});return r.jsx(EA.Provider,{value:h,children:m})}),I8=g.forwardRef(function(t,n){const{className:s,render:i,id:l,...c}=t,d=NA(l),{setLabelId:h}=R8();return Ke(()=>(h(d),()=>{h(void 0)}),[h,d]),Lr("div",t,{ref:n,props:{id:d,role:"presentation",...c}})}),O8=g.forwardRef(function(t,n){const{render:s,className:i,id:l,label:c,nativeButton:d=!1,disabled:h=!1,closeOnClick:m=!0,...p}=t,y=k8({label:c}),x=dA(!0),w=NA(l),{store:j}=ll(),N=j.useState("isActive",y.index),k=j.useState("itemProps"),{getItemProps:E,itemRef:A}=j8({closeOnClick:m,disabled:h,highlighted:N,id:w,store:j,nativeButton:d,nodeId:x?.nodeId,itemMetadata:w8}),S=g.useMemo(()=>({disabled:h,highlighted:N}),[h,N]);return Lr("div",t,{state:S,props:[k,p,E],ref:[A,n,y.ref]})}),oc=0;class nl{static create(){return new nl}currentId=oc;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=oc,n()},t)}isStarted(){return this.currentId!==oc}clear=()=>{this.currentId!==oc&&(clearTimeout(this.currentId),this.currentId=oc)};disposeEffect=()=>this.clear}function Ys(){const e=Is(nl.create).current;return SA(e.disposeEffect),e}const cl=typeof navigator<"u",sg=$8(),CA=B8(),AA=U8(),D8=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),P8=sg.platform==="MacIntel"&&sg.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(sg.platform),z8=cl&&/apple/i.test(navigator.vendor),wv=cl&&/android/i.test(CA)||/android/i.test(AA);cl&&CA.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const L8=AA.includes("jsdom/");function $8(){if(!cl)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 U8(){if(!cl)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "):navigator.userAgent}function B8(){if(!cl)return"";const e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??""}const jv="data-base-ui-focusable",TA="active",MA="selected",RA="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",Cr="ArrowLeft",Ar="ArrowRight",Fy="ArrowUp",Qc="ArrowDown";function wr(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Ft(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&xv(n)){let s=t;for(;s;){if(e===s)return!0;s=s.parentNode||s.host}}return!1}function es(e){return"composedPath"in e?e.composedPath()[0]:e.target}function Bs(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 V8(e){return e.matches("html,body")}function Rn(e){return e?.ownerDocument||document}function F8(e){return dn(e)&&e.matches(RA)}function Nv(e){return e?e.getAttribute("role")==="combobox"&&F8(e):!1}function Rf(e){return e?e.hasAttribute(jv)?e:e.querySelector(`[${jv}]`)||e:null}function Wo(e,t,n=!0){return e.filter(i=>i.parentId===t&&(!n||i.context?.open)).flatMap(i=>[i,...Wo(e,i.id,n)])}function aN(e,t){let n=[],s=e.find(i=>i.id===t)?.parentId;for(;s;){const i=e.find(l=>l.id===s);s=i?.parentId,i&&(n=n.concat(i))}return n}function _n(e){e.preventDefault(),e.stopPropagation()}function H8(e){return"nativeEvent"in e}function _A(e){return e.mozInputSource===0&&e.isTrusted?!0:wv&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function IA(e){return L8?!1:!wv&&e.width===0&&e.height===0||wv&&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 q8(e,t){const n=["mouse","pen"];return n.push("",void 0),n.includes(e)}function Z8(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const W8=["top","right","bottom","left"],sl=Math.min,ds=Math.max,_f=Math.round,Uo=Math.floor,ua=e=>({x:e,y:e}),Y8={left:"right",right:"left",bottom:"top",top:"bottom"},G8={start:"end",end:"start"};function Sv(e,t,n){return ds(e,sl(t,n))}function Ba(e,t){return typeof e=="function"?e(t):e}function ms(e){return e.split("-")[0]}function Ur(e){return e.split("-")[1]}function Hy(e){return e==="x"?"y":"x"}function qy(e){return e==="y"?"height":"width"}const K8=new Set(["top","bottom"]);function Ms(e){return K8.has(ms(e))?"y":"x"}function Zy(e){return Hy(Ms(e))}function X8(e,t,n){n===void 0&&(n=!1);const s=Ur(e),i=Zy(e),l=qy(i);let c=i==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[l]>t.floating[l]&&(c=If(c)),[c,If(c)]}function J8(e){const t=If(e);return[kv(e),t,kv(t)]}function kv(e){return e.replace(/start|end/g,t=>G8[t])}const rN=["left","right"],iN=["right","left"],Q8=["top","bottom"],eU=["bottom","top"];function tU(e,t,n){switch(e){case"top":case"bottom":return n?t?iN:rN:t?rN:iN;case"left":case"right":return t?Q8:eU;default:return[]}}function nU(e,t,n,s){const i=Ur(e);let l=tU(ms(e),n==="start",s);return i&&(l=l.map(c=>c+"-"+i),t&&(l=l.concat(l.map(kv)))),l}function If(e){return e.replace(/left|right|bottom|top/g,t=>Y8[t])}function sU(e){return{top:0,right:0,bottom:0,left:0,...e}}function OA(e){return typeof e!="number"?sU(e):{top:e,right:e,bottom:e,left:e}}function Of(e){const{x:t,y:n,width:s,height:i}=e;return{width:s,height:i,top:n,left:t,right:t+s,bottom:n+i,x:t,y:n}}function Ad(e,t,n){return Math.floor(e/t)!==n}function Nc(e,t){return t<0||t>=e.current.length}function ag(e,t){return Dn(e,{disabledIndices:t})}function oN(e,t){return Dn(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function Dn(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:s,amount:i=1}={}){let l=t;do l+=n?-i:i;while(l>=0&&l<=e.current.length-1&&Sc(e,l,s));return l}function aU(e,{event:t,orientation:n,loopFocus:s,rtl:i,cols:l,disabledIndices:c,minIndex:d,maxIndex:h,prevIndex:m,stopEvent:p=!1}){let y=m;const x=[],w={};let j=!1;{let E=null,A=-1;e.current.forEach((S,M)=>{if(S==null)return;const C=S.closest('[role="row"]');C&&(j=!0),(C!==E||A===-1)&&(E=C,A+=1,x[A]=[]),x[A].push(M),w[M]=A})}const N=j&&x.length>0&&x.some(E=>E.length!==l);function k(E){if(!N||m===-1)return;const A=w[m];if(A==null)return;const S=x[A].indexOf(m);let M=E==="up"?A-1:A+1;s&&(M<0?M=x.length-1:M>=x.length&&(M=0));const C=new Set;for(;M>=0&&M<x.length&&!C.has(M);){C.add(M);const I=x[M];if(I.length===0){M=E==="up"?M-1:M+1;continue}const R=Math.min(S,I.length-1);for(let D=R;D>=0;D-=1){const z=I[D];if(!Sc(e,z,c))return z}M=E==="up"?M-1:M+1,s&&(M<0?M=x.length-1:M>=x.length&&(M=0))}}if(t.key===Fy){const E=k("up");if(E!==void 0)p&&_n(t),y=E;else{if(p&&_n(t),m===-1)y=h;else if(y=Dn(e,{startingIndex:y,amount:l,decrement:!0,disabledIndices:c}),s&&(m-l<d||y<0)){const A=m%l,S=h%l,M=h-(S-A);S===A?y=h:y=S>A?M:M-l}Nc(e,y)&&(y=m)}}if(t.key===Qc){const E=k("down");E!==void 0?(p&&_n(t),y=E):(p&&_n(t),m===-1?y=d:(y=Dn(e,{startingIndex:m,amount:l,disabledIndices:c}),s&&m+l>h&&(y=Dn(e,{startingIndex:m%l-l,amount:l,disabledIndices:c}))),Nc(e,y)&&(y=m))}if(n==="both"){const E=Uo(m/l);t.key===(i?Cr:Ar)&&(p&&_n(t),m%l!==l-1?(y=Dn(e,{startingIndex:m,disabledIndices:c}),s&&Ad(y,l,E)&&(y=Dn(e,{startingIndex:m-m%l-1,disabledIndices:c}))):s&&(y=Dn(e,{startingIndex:m-m%l-1,disabledIndices:c})),Ad(y,l,E)&&(y=m)),t.key===(i?Ar:Cr)&&(p&&_n(t),m%l!==0?(y=Dn(e,{startingIndex:m,decrement:!0,disabledIndices:c}),s&&Ad(y,l,E)&&(y=Dn(e,{startingIndex:m+(l-m%l),decrement:!0,disabledIndices:c}))):s&&(y=Dn(e,{startingIndex:m+(l-m%l),decrement:!0,disabledIndices:c})),Ad(y,l,E)&&(y=m));const A=Uo(h/l)===E;Nc(e,y)&&(s&&A?y=t.key===(i?Ar:Cr)?h:Dn(e,{startingIndex:m-m%l-1,disabledIndices:c}):y=m)}return y}function rU(e,t,n){const s=[];let i=0;return e.forEach(({width:l,height:c},d)=>{let h=!1;for(n&&(i=0);!h;){const m=[];for(let p=0;p<l;p+=1)for(let y=0;y<c;y+=1)m.push(i+p+y*t);i%t+l<=t&&m.every(p=>s[p]==null)?(m.forEach(p=>{s[p]=d}),h=!0):i+=1}}),[...s]}function iU(e,t,n,s,i){if(e===-1)return-1;const l=n.indexOf(e),c=t[e];switch(i){case"tl":return l;case"tr":return c?l+c.width-1:l;case"bl":return c?l+(c.height-1)*s:l;case"br":return n.lastIndexOf(e);default:return-1}}function oU(e,t){return t.flatMap((n,s)=>e.includes(n)?[s]:[])}function Sc(e,t,n){if(typeof n=="function")return n(t);if(n)return n.includes(t);const s=e.current[t];return s?s.hasAttribute("disabled")||s.getAttribute("aria-disabled")==="true":!1}var lU=["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] *)"],Df=lU.join(","),DA=typeof Element>"u",al=DA?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Pf=!DA&&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},zf=function(t,n){var s;n===void 0&&(n=!0);var i=t==null||(s=t.getAttribute)===null||s===void 0?void 0:s.call(t,"inert"),l=i===""||i==="true",c=l||n&&t&&(typeof t.closest=="function"?t.closest("[inert]"):zf(t.parentNode));return c},cU=function(t){var n,s=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return s===""||s==="true"},PA=function(t,n,s){if(zf(t))return[];var i=Array.prototype.slice.apply(t.querySelectorAll(Df));return n&&al.call(t,Df)&&i.unshift(t),i=i.filter(s),i},Lf=function(t,n,s){for(var i=[],l=Array.from(t);l.length;){var c=l.shift();if(!zf(c,!1))if(c.tagName==="SLOT"){var d=c.assignedElements(),h=d.length?d:c.children,m=Lf(h,!0,s);s.flatten?i.push.apply(i,m):i.push({scopeParent:c,candidates:m})}else{var p=al.call(c,Df);p&&s.filter(c)&&(n||!t.includes(c))&&i.push(c);var y=c.shadowRoot||typeof s.getShadowRoot=="function"&&s.getShadowRoot(c),x=!zf(y,!1)&&(!s.shadowRootFilter||s.shadowRootFilter(c));if(y&&x){var w=Lf(y===!0?c.children:y.children,!0,s);s.flatten?i.push.apply(i,w):i.push({scopeParent:c,candidates:w})}else l.unshift.apply(l,c.children)}}return i},zA=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},LA=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||cU(t))&&!zA(t)?0:t.tabIndex},uU=function(t,n){var s=LA(t);return s<0&&n&&!zA(t)?0:s},dU=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},$A=function(t){return t.tagName==="INPUT"},fU=function(t){return $A(t)&&t.type==="hidden"},hU=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(s){return s.tagName==="SUMMARY"});return n},mU=function(t,n){for(var s=0;s<t.length;s++)if(t[s].checked&&t[s].form===n)return t[s]},pU=function(t){if(!t.name)return!0;var n=t.form||Pf(t),s=function(d){return n.querySelectorAll('input[type="radio"][name="'+d+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=s(window.CSS.escape(t.name));else try{i=s(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 l=mU(i,t.form);return!l||l===t},gU=function(t){return $A(t)&&t.type==="radio"},vU=function(t){return gU(t)&&!pU(t)},yU=function(t){var n,s=t&&Pf(t),i=(n=s)===null||n===void 0?void 0:n.host,l=!1;if(s&&s!==t){var c,d,h;for(l=!!((c=i)!==null&&c!==void 0&&(d=c.ownerDocument)!==null&&d!==void 0&&d.contains(i)||t!=null&&(h=t.ownerDocument)!==null&&h!==void 0&&h.contains(t));!l&&i;){var m,p,y;s=Pf(i),i=(m=s)===null||m===void 0?void 0:m.host,l=!!((p=i)!==null&&p!==void 0&&(y=p.ownerDocument)!==null&&y!==void 0&&y.contains(i))}}return l},lN=function(t){var n=t.getBoundingClientRect(),s=n.width,i=n.height;return s===0&&i===0},xU=function(t,n){var s=n.displayCheck,i=n.getShadowRoot;if(s==="full-native"&&"checkVisibility"in t){var l=t.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!l}if(getComputedStyle(t).visibility==="hidden")return!0;var c=al.call(t,"details>summary:first-of-type"),d=c?t.parentElement:t;if(al.call(d,"details:not([open]) *"))return!0;if(!s||s==="full"||s==="full-native"||s==="legacy-full"){if(typeof i=="function"){for(var h=t;t;){var m=t.parentElement,p=Pf(t);if(m&&!m.shadowRoot&&i(m)===!0)return lN(t);t.assignedSlot?t=t.assignedSlot:!m&&p!==t.ownerDocument?t=p.host:t=m}t=h}if(yU(t))return!t.getClientRects().length;if(s!=="legacy-full")return!0}else if(s==="non-zero-area")return lN(t);return!1},bU=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var n=t.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var s=0;s<n.children.length;s++){var i=n.children.item(s);if(i.tagName==="LEGEND")return al.call(n,"fieldset[disabled] *")?!0:!i.contains(t)}return!0}n=n.parentElement}return!1},Ev=function(t,n){return!(n.disabled||fU(n)||xU(n,t)||hU(n)||bU(n))},Cv=function(t,n){return!(vU(n)||LA(n)<0||!Ev(t,n))},wU=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},UA=function(t){var n=[],s=[];return t.forEach(function(i,l){var c=!!i.scopeParent,d=c?i.scopeParent:i,h=uU(d,c),m=c?UA(i.candidates):d;h===0?c?n.push.apply(n,m):n.push(d):s.push({documentOrder:l,tabIndex:h,item:i,isScope:c,content:m})}),s.sort(dU).reduce(function(i,l){return l.isScope?i.push.apply(i,l.content):i.push(l.content),i},[]).concat(n)},bh=function(t,n){n=n||{};var s;return n.getShadowRoot?s=Lf([t],n.includeContainer,{filter:Cv.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:wU}):s=PA(t,n.includeContainer,Cv.bind(null,n)),UA(s)},jU=function(t,n){n=n||{};var s;return n.getShadowRoot?s=Lf([t],n.includeContainer,{filter:Ev.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):s=PA(t,n.includeContainer,Ev.bind(null,n)),s},BA=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return al.call(t,Df)===!1?!1:Cv(n,t)};const eu=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function VA(e,t){const n=bh(e,eu()),s=n.length;if(s===0)return;const i=wr(Rn(e)),l=n.indexOf(i),c=l===-1?t===1?0:s-1:l+t;return n[c]}function FA(e){return VA(Rn(e).body,1)||e}function HA(e){return VA(Rn(e).body,-1)||e}function kc(e,t){const n=t||e.currentTarget,s=e.relatedTarget;return!s||!Ft(n,s)}function NU(e){bh(e,eu()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function cN(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{const s=n.dataset.tabindex;delete n.dataset.tabindex,s?n.setAttribute("tabindex",s):n.removeAttribute("tabindex")})}function qA(){const e=new Map;return{emit(t,n){e.get(t)?.forEach(s=>s(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 ZA{nodesRef={current:[]};events=qA();addNode(t){this.nodesRef.current.push(t)}removeNode(t){const n=this.nodesRef.current.findIndex(s=>s===t);n!==-1&&this.nodesRef.current.splice(n,1)}}const WA=g.createContext(null),YA=g.createContext(null),Br=()=>g.useContext(WA)?.id||null,ul=e=>{const t=g.useContext(YA);return e??t};function SU(e){const t=zr(),n=ul(e),s=Br();return Ke(()=>{if(!t)return;const i={id:t,parentId:s};return n?.addNode(i),()=>{n?.removeNode(i)}},[n,t,s]),t}function kU(e){const{children:t,id:n}=e,s=Br();return r.jsx(WA.Provider,{value:g.useMemo(()=>({id:n,parentId:s}),[n,s]),children:t})}function EU(e){const{children:t,externalTree:n}=e,s=Is(()=>n??new ZA).current;return r.jsx(YA.Provider,{value:s,children:t})}function $c(e){return`data-base-ui-${e}`}const GA={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 Ei(e){return e?.ownerDocument||document}const $f=g.forwardRef(function(t,n){const[s,i]=g.useState();Ke(()=>{z8&&i("button")},[]);const l={tabIndex:0,role:s};return r.jsx("span",{...t,ref:n,style:GA,"aria-hidden":s?void 0:!0,...l,"data-base-ui-focus-guard":""})});let uN=0;function of(e,t={}){const{preventScroll:n=!1,cancelPrevious:s=!0,sync:i=!1}=t;s&&cancelAnimationFrame(uN);const l=()=>e?.focus({preventScroll:n});i?l():uN=requestAnimationFrame(l)}const Yo={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function dN(e){return e==="inert"?Yo.inert:e==="aria-hidden"?Yo["aria-hidden"]:Yo.none}let Td=new WeakSet,Md={},rg=0;const KA=e=>e&&(e.host||KA(e.parentNode)),CU=(e,t)=>t.map(n=>{if(e.contains(n))return n;const s=KA(n);return e.contains(s)?s:null}).filter(n=>n!=null);function AU(e,t,n,s){const i="data-base-ui-inert",l=s?"inert":n?"aria-hidden":null,c=CU(t,e),d=new Set,h=new Set(c),m=[];Md[i]||(Md[i]=new WeakMap);const p=Md[i];c.forEach(y),x(t),d.clear();function y(w){!w||d.has(w)||(d.add(w),w.parentNode&&y(w.parentNode))}function x(w){!w||h.has(w)||[].forEach.call(w.children,j=>{if($r(j)!=="script")if(d.has(j))x(j);else{const N=l?j.getAttribute(l):null,k=N!==null&&N!=="false",E=dN(l),A=(E.get(j)||0)+1,S=(p.get(j)||0)+1;E.set(j,A),p.set(j,S),m.push(j),A===1&&k&&Td.add(j),S===1&&j.setAttribute(i,""),!k&&l&&j.setAttribute(l,l==="inert"?"":"true")}})}return rg+=1,()=>{m.forEach(w=>{const j=dN(l),k=(j.get(w)||0)-1,E=(p.get(w)||0)-1;j.set(w,k),p.set(w,E),k||(!Td.has(w)&&l&&w.removeAttribute(l),Td.delete(w)),E||w.removeAttribute(i)}),rg-=1,rg||(Yo.inert=new WeakMap,Yo["aria-hidden"]=new WeakMap,Yo.none=new WeakMap,Td=new WeakSet,Md={})}}function TU(e,t=!1,n=!1){const s=Rn(e[0]).body;return AU(e.concat(Array.from(s.querySelectorAll("[aria-live]"))),s,t,n)}const XA=g.createContext(null),JA=()=>g.useContext(XA),MU=$c("portal");function RU(e={}){const{ref:t,container:n,componentProps:s=ts,elementProps:i,elementState:l}=e,c=zr(),h=JA()?.portalNode,[m,p]=g.useState(null),[y,x]=g.useState(null),w=g.useRef(null);Ke(()=>{if(n===null){w.current&&(w.current=null,x(null),p(null));return}if(c==null)return;const k=(n&&(Uy(n)?n:n.current))??h??document.body;if(k==null){w.current&&(w.current=null,x(null),p(null));return}w.current!==k&&(w.current=k,x(null),p(k))},[n,h,c]);const j=Lr("div",s,{ref:[t,x],state:l,props:[{id:c,[MU]:""},i]});return{portalNode:y,portalSubtree:m&&j?ki.createPortal(j,m):null}}const _U=g.forwardRef(function(t,n){const{children:s,container:i,className:l,render:c,renderGuards:d,...h}=t,{portalNode:m,portalSubtree:p}=RU({container:i,ref:n,componentProps:t,elementProps:h}),y=g.useRef(null),x=g.useRef(null),w=g.useRef(null),j=g.useRef(null),[N,k]=g.useState(null),E=N?.modal,A=N?.open,S=typeof d=="boolean"?d:!!N&&!N.modal&&N.open&&!!m;g.useEffect(()=>{if(!m||E)return;function C(I){m&&kc(I)&&(I.type==="focusin"?cN:NU)(m)}return m.addEventListener("focusin",C,!0),m.addEventListener("focusout",C,!0),()=>{m.removeEventListener("focusin",C,!0),m.removeEventListener("focusout",C,!0)}},[m,E]),g.useEffect(()=>{!m||A||cN(m)},[A,m]);const M=g.useMemo(()=>({beforeOutsideRef:y,afterOutsideRef:x,beforeInsideRef:w,afterInsideRef:j,portalNode:m,setFocusManagerState:k}),[m]);return r.jsxs(g.Fragment,{children:[p,r.jsxs(XA.Provider,{value:M,children:[S&&m&&r.jsx($f,{"data-type":"outside",ref:y,onFocus:C=>{if(kc(C,m))w.current?.focus();else{const I=N?N.domReference:null;HA(I)?.focus()}}}),S&&m&&r.jsx("span",{"aria-owns":m.id,style:V6}),m&&ki.createPortal(s,m),S&&m&&r.jsx($f,{"data-type":"outside",ref:x,onFocus:C=>{if(kc(C,m))j.current?.focus();else{const I=N?N.domReference:null;FA(I)?.focus(),N?.closeOnFocusOut&&N?.onOpenChange(!1,yn(ph,C.nativeEvent))}}})]})]})});function IU(e,t){const n=In(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 fN=20;let jr=[];function Wy(){jr=jr.filter(e=>e.isConnected)}function OU(e){Wy(),e&&$r(e)!=="body"&&(jr.push(e),jr.length>fN&&(jr=jr.slice(-fN)))}function ig(){return Wy(),jr[jr.length-1]}function DU(e){if(!e)return null;const t=eu();return BA(e,t)?e:bh(e,t)[0]||e}function PU(e){return!e||!e.isConnected?!1:typeof e.checkVisibility=="function"?e.checkVisibility():gs(e).display!=="none"}function hN(e,t){if(!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const n=eu(),i=jU(e,n).filter(c=>{const d=c.getAttribute("data-tabindex")||"";return BA(c,n)||c.hasAttribute("data-tabindex")&&!d.startsWith("-")}),l=e.getAttribute("tabindex");t.current.includes("floating")||i.length===0?l!=="0"&&e.setAttribute("tabindex","0"):(l!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function zU(e){const{context:t,children:n,disabled:s=!1,order:i=["content"],initialFocus:l=!0,returnFocus:c=!0,restoreFocus:d=!1,modal:h=!0,closeOnFocusOut:m=!0,openInteractionType:p="",getInsideElements:y=()=>[],nextFocusableElement:x,previousFocusableElement:w,beforeContentFocusGuardRef:j,externalTree:N}=e,k="rootStore"in t?t.rootStore:t,E=k.useState("open"),A=k.useState("domReferenceElement"),S=k.useState("floatingElement"),{events:M,dataRef:C}=k.context,I=Qe(()=>C.current.floatingContext?.nodeId),R=Qe(y),D=l===!1,z=Nv(A)&&D,O=Qn(i),_=Qn(l),U=Qn(c),q=Qn(p),G=ul(N),X=JA(),L=g.useRef(null),F=g.useRef(null),H=g.useRef(!1),V=g.useRef(!1),W=g.useRef(!1),$=g.useRef(-1),B=g.useRef(""),Y=g.useRef(""),te=Ys(),ae=Ys(),ee=Vy(),ie=X!=null,de=Rf(S),xe=Qe((oe=de)=>oe?bh(oe,eu()):[]),Ae=Qe(oe=>{const je=xe(oe);return O.current.map(()=>je).filter(Boolean).flat()});g.useEffect(()=>{if(s||!h)return;function oe(Fe){Fe.key==="Tab"&&Ft(de,wr(Rn(de)))&&xe().length===0&&!z&&_n(Fe)}const je=Rn(de);return je.addEventListener("keydown",oe),()=>{je.removeEventListener("keydown",oe)}},[s,A,de,h,O,z,xe,Ae]),g.useEffect(()=>{if(s||!S)return;function oe(je){const Fe=es(je),ve=xe().indexOf(Fe);ve!==-1&&($.current=ve)}return S.addEventListener("focusin",oe),()=>{S.removeEventListener("focusin",oe)}},[s,S,xe]),g.useEffect(()=>{if(s||!E)return;const oe=Rn(de);function je(){W.current=!1}function Fe(ve){const ue=es(ve),Ce=Ft(S,ue)||Ft(A,ue)||Ft(X?.portalNode,ue);W.current=!Ce,Y.current=ve.pointerType||"keyboard"}function le(){Y.current="keyboard"}return oe.addEventListener("pointerdown",Fe,!0),oe.addEventListener("pointerup",je,!0),oe.addEventListener("pointercancel",je,!0),oe.addEventListener("keydown",le,!0),()=>{oe.removeEventListener("pointerdown",Fe,!0),oe.removeEventListener("pointerup",je,!0),oe.removeEventListener("pointercancel",je,!0),oe.removeEventListener("keydown",le,!0)}},[s,S,A,de,E,X]),g.useEffect(()=>{if(s||!m)return;function oe(){V.current=!0,ae.start(0,()=>{V.current=!1})}function je(ue){const Ce=ue.relatedTarget,be=ue.currentTarget,we=es(ue);queueMicrotask(()=>{const Se=I(),He=k.context.triggerElements,et=!(Ft(A,Ce)||Ft(S,Ce)||Ft(Ce,S)||Ft(X?.portalNode,Ce)||Ce!=null&&He.hasElement(Ce)||He.hasMatchingElement(Be=>Ft(Be,Ce))||Ce?.hasAttribute($c("focus-guard"))||G&&(Wo(G.nodesRef.current,Se).find(Be=>Ft(Be.context?.elements.floating,Ce)||Ft(Be.context?.elements.domReference,Ce))||aN(G.nodesRef.current,Se).find(Be=>[Be.context?.elements.floating,Rf(Be.context?.elements.floating)].includes(Ce)||Be.context?.elements.domReference===Ce)));if(be===A&&de&&hN(de,O),d&&be!==A&&!PU(we)&&wr(Rn(de))===Rn(de).body){if(dn(de)&&(de.focus(),d==="popup")){ee.request(()=>{de.focus()});return}const Be=$.current,St=xe(),Dt=St[Be]||St[St.length-1]||de;dn(Dt)&&Dt.focus()}if(C.current.insideReactTree){C.current.insideReactTree=!1;return}(z||!h)&&Ce&&et&&!V.current&&(z||Ce!==ig())&&(H.current=!0,k.setOpen(!1,yn(ph,ue)))})}function Fe(){W.current||(C.current.insideReactTree=!0,te.start(0,()=>{C.current.insideReactTree=!1}))}const le=dn(A)?A:null,ve=[];if(!(!S&&!le))return le&&(le.addEventListener("focusout",je),le.addEventListener("pointerdown",oe),ve.push(()=>{le.removeEventListener("focusout",je),le.removeEventListener("pointerdown",oe)})),S&&(S.addEventListener("focusout",je),X&&(S.addEventListener("focusout",Fe,!0),ve.push(()=>{S.removeEventListener("focusout",Fe,!0)})),ve.push(()=>{S.removeEventListener("focusout",je)})),()=>{ve.forEach(ue=>{ue()})}},[s,A,S,de,h,G,X,k,m,d,xe,z,I,O,C,te,ae,ee]);const me=g.useRef(null),Pe=g.useRef(null),Re=Lc(me,j,X?.beforeInsideRef),Ye=Lc(Pe,X?.afterInsideRef);g.useEffect(()=>{if(s||!S||!E)return;const oe=Array.from(X?.portalNode?.querySelectorAll(`[${$c("portal")}]`)||[]),Fe=(G?aN(G.nodesRef.current,I()):[]).find(ue=>Nv(ue.context?.elements.domReference||null))?.context?.elements.domReference,le=[S,Fe,...oe,...R(),L.current,F.current,me.current,Pe.current,X?.beforeOutsideRef.current,X?.afterOutsideRef.current,ui(w),ui(x),z?A:null].filter(ue=>ue!=null),ve=TU(le,h||z);return()=>{ve()}},[E,s,A,S,h,O,X,z,G,I,R,x,w]),Ke(()=>{if(!E||s||!dn(de))return;const oe=Rn(de),je=wr(oe);queueMicrotask(()=>{const Fe=Ae(de),le=_.current,ve=typeof le=="function"?le(q.current||""):le;if(ve===void 0||ve===!1)return;let ue;ve===!0||ve===null?ue=Fe[0]||de:ue=ui(ve),ue=ue||Fe[0]||de,!Ft(de,je)&&of(ue,{preventScroll:ue===de})})},[s,E,de,D,Ae,_,q]),Ke(()=>{if(s||!de)return;const oe=Rn(de),je=wr(oe);OU(je);function Fe(ue){if(ue.open||(B.current=IU(ue.nativeEvent,Y.current)),ue.reason===xi&&ue.nativeEvent.type==="mouseleave"&&(H.current=!0),ue.reason===$y)if(ue.nested)H.current=!1;else if(_A(ue.nativeEvent)||IA(ue.nativeEvent))H.current=!1;else{let Ce=!1;document.createElement("div").focus({get preventScroll(){return Ce=!0,!1}}),Ce?H.current=!1:H.current=!0}}M.on("openchange",Fe);const le=oe.createElement("span");le.setAttribute("tabindex","-1"),le.setAttribute("aria-hidden","true"),Object.assign(le.style,GA),ie&&A&&A.insertAdjacentElement("afterend",le);function ve(){const ue=U.current;let Ce=typeof ue=="function"?ue(B.current):ue;if(Ce===void 0||Ce===!1)return null;if(Ce===null&&(Ce=!0),typeof Ce=="boolean"){const we=A||ig();return we&&we.isConnected?we:le}const be=A||ig()||le;return ui(Ce)||be}return()=>{M.off("openchange",Fe);const ue=wr(oe),Ce=Ft(S,ue)||G&&Wo(G.nodesRef.current,I(),!1).some(we=>Ft(we.context?.elements.floating,ue)),be=ve();queueMicrotask(()=>{const we=DU(be),Se=typeof U.current!="boolean";U.current&&!H.current&&dn(we)&&(!(!Se&&we!==ue&&ue!==oe.body)||Ce)&&we.focus({preventScroll:!0}),le.remove()})}},[s,S,de,U,C,M,G,ie,A,I]),g.useEffect(()=>{queueMicrotask(()=>{H.current=!1})},[s]),g.useEffect(()=>{if(s||!E)return;function oe(Fe){es(Fe)?.closest(`[${U6}]`)&&(V.current=!0)}const je=Rn(de);return je.addEventListener("pointerdown",oe,!0),()=>{je.removeEventListener("pointerdown",oe,!0)}},[s,E,de]),Ke(()=>{if(!s&&X)return X.setFocusManagerState({modal:h,closeOnFocusOut:m,open:E,onOpenChange:k.setOpen,domReference:A}),()=>{X.setFocusManagerState(null)}},[s,X,h,E,k,m,A]),Ke(()=>{if(!(s||!de))return hN(de,O),()=>{queueMicrotask(Wy)}},[s,de,O]);const Ie=!s&&(h?!z:!0)&&(ie||h);return r.jsxs(g.Fragment,{children:[Ie&&r.jsx($f,{"data-type":"inside",ref:Re,onFocus:oe=>{if(h){const je=Ae();of(je[je.length-1])}else X?.portalNode&&(H.current=!1,kc(oe,X.portalNode)?FA(A)?.focus():ui(w??X.beforeOutsideRef)?.focus())}}),n,Ie&&r.jsx($f,{"data-type":"inside",ref:Ye,onFocus:oe=>{h?of(Ae()[0]):X?.portalNode&&(m&&(H.current=!0),kc(oe,X.portalNode)?HA(A)?.focus():ui(x??X.afterOutsideRef)?.focus())}})]})}function mN(e,t,n){let{reference:s,floating:i}=e;const l=Ms(t),c=Zy(t),d=qy(c),h=ms(t),m=l==="y",p=s.x+s.width/2-i.width/2,y=s.y+s.height/2-i.height/2,x=s[d]/2-i[d]/2;let w;switch(h){case"top":w={x:p,y:s.y-i.height};break;case"bottom":w={x:p,y:s.y+s.height};break;case"right":w={x:s.x+s.width,y};break;case"left":w={x:s.x-i.width,y};break;default:w={x:s.x,y:s.y}}switch(Ur(t)){case"start":w[c]-=x*(n&&m?-1:1);break;case"end":w[c]+=x*(n&&m?-1:1);break}return w}async function LU(e,t){var n;t===void 0&&(t={});const{x:s,y:i,platform:l,rects:c,elements:d,strategy:h}=e,{boundary:m="clippingAncestors",rootBoundary:p="viewport",elementContext:y="floating",altBoundary:x=!1,padding:w=0}=Ba(t,e),j=OA(w),k=d[x?y==="floating"?"reference":"floating":y],E=Of(await l.getClippingRect({element:(n=await(l.isElement==null?void 0:l.isElement(k)))==null||n?k:k.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(d.floating)),boundary:m,rootBoundary:p,strategy:h})),A=y==="floating"?{x:s,y:i,width:c.floating.width,height:c.floating.height}:c.reference,S=await(l.getOffsetParent==null?void 0:l.getOffsetParent(d.floating)),M=await(l.isElement==null?void 0:l.isElement(S))?await(l.getScale==null?void 0:l.getScale(S))||{x:1,y:1}:{x:1,y:1},C=Of(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:A,offsetParent:S,strategy:h}):A);return{top:(E.top-C.top+j.top)/M.y,bottom:(C.bottom-E.bottom+j.bottom)/M.y,left:(E.left-C.left+j.left)/M.x,right:(C.right-E.right+j.right)/M.x}}const $U=async(e,t,n)=>{const{placement:s="bottom",strategy:i="absolute",middleware:l=[],platform:c}=n,d=l.filter(Boolean),h=await(c.isRTL==null?void 0:c.isRTL(t));let m=await c.getElementRects({reference:e,floating:t,strategy:i}),{x:p,y}=mN(m,s,h),x=s,w={},j=0;for(let k=0;k<d.length;k++){var N;const{name:E,fn:A}=d[k],{x:S,y:M,data:C,reset:I}=await A({x:p,y,initialPlacement:s,placement:x,strategy:i,middlewareData:w,rects:m,platform:{...c,detectOverflow:(N=c.detectOverflow)!=null?N:LU},elements:{reference:e,floating:t}});p=S??p,y=M??y,w={...w,[E]:{...w[E],...C}},I&&j<=50&&(j++,typeof I=="object"&&(I.placement&&(x=I.placement),I.rects&&(m=I.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:i}):I.rects),{x:p,y}=mN(m,x,h)),k=-1)}return{x:p,y,placement:x,strategy:i,middlewareData:w}},UU=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:i,middlewareData:l,rects:c,initialPlacement:d,platform:h,elements:m}=t,{mainAxis:p=!0,crossAxis:y=!0,fallbackPlacements:x,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:j="none",flipAlignment:N=!0,...k}=Ba(e,t);if((n=l.arrow)!=null&&n.alignmentOffset)return{};const E=ms(i),A=Ms(d),S=ms(d)===d,M=await(h.isRTL==null?void 0:h.isRTL(m.floating)),C=x||(S||!N?[If(d)]:J8(d)),I=j!=="none";!x&&I&&C.push(...nU(d,N,j,M));const R=[d,...C],D=await h.detectOverflow(t,k),z=[];let O=((s=l.flip)==null?void 0:s.overflows)||[];if(p&&z.push(D[E]),y){const G=X8(i,c,M);z.push(D[G[0]],D[G[1]])}if(O=[...O,{placement:i,overflows:z}],!z.every(G=>G<=0)){var _,U;const G=(((_=l.flip)==null?void 0:_.index)||0)+1,X=R[G];if(X&&(!(y==="alignment"?A!==Ms(X):!1)||O.every(H=>Ms(H.placement)===A?H.overflows[0]>0:!0)))return{data:{index:G,overflows:O},reset:{placement:X}};let L=(U=O.filter(F=>F.overflows[0]<=0).sort((F,H)=>F.overflows[1]-H.overflows[1])[0])==null?void 0:U.placement;if(!L)switch(w){case"bestFit":{var q;const F=(q=O.filter(H=>{if(I){const V=Ms(H.placement);return V===A||V==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(V=>V>0).reduce((V,W)=>V+W,0)]).sort((H,V)=>H[1]-V[1])[0])==null?void 0:q[0];F&&(L=F);break}case"initialPlacement":L=d;break}if(i!==L)return{reset:{placement:L}}}return{}}}};function pN(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function gN(e){return W8.some(t=>e[t]>=0)}const BU=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:i="referenceHidden",...l}=Ba(e,t);switch(i){case"referenceHidden":{const c=await s.detectOverflow(t,{...l,elementContext:"reference"}),d=pN(c,n.reference);return{data:{referenceHiddenOffsets:d,referenceHidden:gN(d)}}}case"escaped":{const c=await s.detectOverflow(t,{...l,altBoundary:!0}),d=pN(c,n.floating);return{data:{escapedOffsets:d,escaped:gN(d)}}}default:return{}}}}},QA=new Set(["left","top"]);async function VU(e,t){const{placement:n,platform:s,elements:i}=e,l=await(s.isRTL==null?void 0:s.isRTL(i.floating)),c=ms(n),d=Ur(n),h=Ms(n)==="y",m=QA.has(c)?-1:1,p=l&&h?-1:1,y=Ba(t,e);let{mainAxis:x,crossAxis:w,alignmentAxis:j}=typeof y=="number"?{mainAxis:y,crossAxis:0,alignmentAxis:null}:{mainAxis:y.mainAxis||0,crossAxis:y.crossAxis||0,alignmentAxis:y.alignmentAxis};return d&&typeof j=="number"&&(w=d==="end"?j*-1:j),h?{x:w*p,y:x*m}:{x:x*m,y:w*p}}const FU=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:i,y:l,placement:c,middlewareData:d}=t,h=await VU(t,e);return c===((n=d.offset)==null?void 0:n.placement)&&(s=d.arrow)!=null&&s.alignmentOffset?{}:{x:i+h.x,y:l+h.y,data:{...h,placement:c}}}}},HU=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:i,platform:l}=t,{mainAxis:c=!0,crossAxis:d=!1,limiter:h={fn:E=>{let{x:A,y:S}=E;return{x:A,y:S}}},...m}=Ba(e,t),p={x:n,y:s},y=await l.detectOverflow(t,m),x=Ms(ms(i)),w=Hy(x);let j=p[w],N=p[x];if(c){const E=w==="y"?"top":"left",A=w==="y"?"bottom":"right",S=j+y[E],M=j-y[A];j=Sv(S,j,M)}if(d){const E=x==="y"?"top":"left",A=x==="y"?"bottom":"right",S=N+y[E],M=N-y[A];N=Sv(S,N,M)}const k=h.fn({...t,[w]:j,[x]:N});return{...k,data:{x:k.x-n,y:k.y-s,enabled:{[w]:c,[x]:d}}}}}},qU=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:i,rects:l,middlewareData:c}=t,{offset:d=0,mainAxis:h=!0,crossAxis:m=!0}=Ba(e,t),p={x:n,y:s},y=Ms(i),x=Hy(y);let w=p[x],j=p[y];const N=Ba(d,t),k=typeof N=="number"?{mainAxis:N,crossAxis:0}:{mainAxis:0,crossAxis:0,...N};if(h){const S=x==="y"?"height":"width",M=l.reference[x]-l.floating[S]+k.mainAxis,C=l.reference[x]+l.reference[S]-k.mainAxis;w<M?w=M:w>C&&(w=C)}if(m){var E,A;const S=x==="y"?"width":"height",M=QA.has(ms(i)),C=l.reference[y]-l.floating[S]+(M&&((E=c.offset)==null?void 0:E[y])||0)+(M?0:k.crossAxis),I=l.reference[y]+l.reference[S]+(M?0:((A=c.offset)==null?void 0:A[y])||0)-(M?k.crossAxis:0);j<C?j=C:j>I&&(j=I)}return{[x]:w,[y]:j}}}},ZU=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:i,rects:l,platform:c,elements:d}=t,{apply:h=()=>{},...m}=Ba(e,t),p=await c.detectOverflow(t,m),y=ms(i),x=Ur(i),w=Ms(i)==="y",{width:j,height:N}=l.floating;let k,E;y==="top"||y==="bottom"?(k=y,E=x===(await(c.isRTL==null?void 0:c.isRTL(d.floating))?"start":"end")?"left":"right"):(E=y,k=x==="end"?"top":"bottom");const A=N-p.top-p.bottom,S=j-p.left-p.right,M=sl(N-p[k],A),C=sl(j-p[E],S),I=!t.middlewareData.shift;let R=M,D=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(D=S),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(R=A),I&&!x){const O=ds(p.left,0),_=ds(p.right,0),U=ds(p.top,0),q=ds(p.bottom,0);w?D=j-2*(O!==0||_!==0?O+_:ds(p.left,p.right)):R=N-2*(U!==0||q!==0?U+q:ds(p.top,p.bottom))}await h({...t,availableWidth:D,availableHeight:R});const z=await c.getDimensions(d.floating);return j!==z.width||N!==z.height?{reset:{rects:!0}}:{}}}};function eT(e){const t=gs(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const i=dn(e),l=i?e.offsetWidth:n,c=i?e.offsetHeight:s,d=_f(n)!==l||_f(s)!==c;return d&&(n=l,s=c),{width:n,height:s,$:d}}function Yy(e){return Ht(e)?e:e.contextElement}function Go(e){const t=Yy(e);if(!dn(t))return ua(1);const n=t.getBoundingClientRect(),{width:s,height:i,$:l}=eT(t);let c=(l?_f(n.width):n.width)/s,d=(l?_f(n.height):n.height)/i;return(!c||!Number.isFinite(c))&&(c=1),(!d||!Number.isFinite(d))&&(d=1),{x:c,y:d}}const WU=ua(0);function tT(e){const t=In(e);return!yh()||!t.visualViewport?WU:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function YU(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==In(e)?!1:t}function Ci(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),l=Yy(e);let c=ua(1);t&&(s?Ht(s)&&(c=Go(s)):c=Go(e));const d=YU(l,n,s)?tT(l):ua(0);let h=(i.left+d.x)/c.x,m=(i.top+d.y)/c.y,p=i.width/c.x,y=i.height/c.y;if(l){const x=In(l),w=s&&Ht(s)?In(s):s;let j=x,N=bv(j);for(;N&&s&&w!==j;){const k=Go(N),E=N.getBoundingClientRect(),A=gs(N),S=E.left+(N.clientLeft+parseFloat(A.paddingLeft))*k.x,M=E.top+(N.clientTop+parseFloat(A.paddingTop))*k.y;h*=k.x,m*=k.y,p*=k.x,y*=k.y,h+=S,m+=M,j=In(N),N=bv(j)}}return Of({width:p,height:y,x:h,y:m})}function wh(e,t){const n=xh(e).scrollLeft;return t?t.left+n:Ci(pa(e)).left+n}function nT(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-wh(e,n),i=n.top+t.scrollTop;return{x:s,y:i}}function GU(e){let{elements:t,rect:n,offsetParent:s,strategy:i}=e;const l=i==="fixed",c=pa(s),d=t?vh(t.floating):!1;if(s===c||d&&l)return n;let h={scrollLeft:0,scrollTop:0},m=ua(1);const p=ua(0),y=dn(s);if((y||!y&&!l)&&(($r(s)!=="body"||Mi(c))&&(h=xh(s)),dn(s))){const w=Ci(s);m=Go(s),p.x=w.x+s.clientLeft,p.y=w.y+s.clientTop}const x=c&&!y&&!l?nT(c,h):ua(0);return{width:n.width*m.x,height:n.height*m.y,x:n.x*m.x-h.scrollLeft*m.x+p.x+x.x,y:n.y*m.y-h.scrollTop*m.y+p.y+x.y}}function KU(e){return Array.from(e.getClientRects())}function XU(e){const t=pa(e),n=xh(e),s=e.ownerDocument.body,i=ds(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),l=ds(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let c=-n.scrollLeft+wh(e);const d=-n.scrollTop;return gs(s).direction==="rtl"&&(c+=ds(t.clientWidth,s.clientWidth)-i),{width:i,height:l,x:c,y:d}}const vN=25;function JU(e,t){const n=In(e),s=pa(e),i=n.visualViewport;let l=s.clientWidth,c=s.clientHeight,d=0,h=0;if(i){l=i.width,c=i.height;const p=yh();(!p||p&&t==="fixed")&&(d=i.offsetLeft,h=i.offsetTop)}const m=wh(s);if(m<=0){const p=s.ownerDocument,y=p.body,x=getComputedStyle(y),w=p.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,j=Math.abs(s.clientWidth-y.clientWidth-w);j<=vN&&(l-=j)}else m<=vN&&(l+=m);return{width:l,height:c,x:d,y:h}}const QU=new Set(["absolute","fixed"]);function eB(e,t){const n=Ci(e,!0,t==="fixed"),s=n.top+e.clientTop,i=n.left+e.clientLeft,l=dn(e)?Go(e):ua(1),c=e.clientWidth*l.x,d=e.clientHeight*l.y,h=i*l.x,m=s*l.y;return{width:c,height:d,x:h,y:m}}function yN(e,t,n){let s;if(t==="viewport")s=JU(e,n);else if(t==="document")s=XU(pa(e));else if(Ht(t))s=eB(t,n);else{const i=tT(e);s={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Of(s)}function sT(e,t){const n=ha(e);return n===t||!Ht(n)||ca(n)?!1:gs(n).position==="fixed"||sT(n,t)}function tB(e,t){const n=t.get(e);if(n)return n;let s=Er(e,[],!1).filter(d=>Ht(d)&&$r(d)!=="body"),i=null;const l=gs(e).position==="fixed";let c=l?ha(e):e;for(;Ht(c)&&!ca(c);){const d=gs(c),h=By(c);!h&&d.position==="fixed"&&(i=null),(l?!h&&!i:!h&&d.position==="static"&&!!i&&QU.has(i.position)||Mi(c)&&!h&&sT(e,c))?s=s.filter(p=>p!==c):i=d,c=ha(c)}return t.set(e,s),s}function nB(e){let{element:t,boundary:n,rootBoundary:s,strategy:i}=e;const c=[...n==="clippingAncestors"?vh(t)?[]:tB(t,this._c):[].concat(n),s],d=c[0],h=c.reduce((m,p)=>{const y=yN(t,p,i);return m.top=ds(y.top,m.top),m.right=sl(y.right,m.right),m.bottom=sl(y.bottom,m.bottom),m.left=ds(y.left,m.left),m},yN(t,d,i));return{width:h.right-h.left,height:h.bottom-h.top,x:h.left,y:h.top}}function sB(e){const{width:t,height:n}=eT(e);return{width:t,height:n}}function aB(e,t,n){const s=dn(t),i=pa(t),l=n==="fixed",c=Ci(e,!0,l,t);let d={scrollLeft:0,scrollTop:0};const h=ua(0);function m(){h.x=wh(i)}if(s||!s&&!l)if(($r(t)!=="body"||Mi(i))&&(d=xh(t)),s){const w=Ci(t,!0,l,t);h.x=w.x+t.clientLeft,h.y=w.y+t.clientTop}else i&&m();l&&!s&&i&&m();const p=i&&!s&&!l?nT(i,d):ua(0),y=c.left+d.scrollLeft-h.x-p.x,x=c.top+d.scrollTop-h.y-p.y;return{x:y,y:x,width:c.width,height:c.height}}function og(e){return gs(e).position==="static"}function xN(e,t){if(!dn(e)||gs(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return pa(e)===n&&(n=n.ownerDocument.body),n}function aT(e,t){const n=In(e);if(vh(e))return n;if(!dn(e)){let i=ha(e);for(;i&&!ca(i);){if(Ht(i)&&!og(i))return i;i=ha(i)}return n}let s=xN(e,t);for(;s&&l8(s)&&og(s);)s=xN(s,t);return s&&ca(s)&&og(s)&&!By(s)?n:s||h8(e)||n}const rB=async function(e){const t=this.getOffsetParent||aT,n=this.getDimensions,s=await n(e.floating);return{reference:aB(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function iB(e){return gs(e).direction==="rtl"}const oB={convertOffsetParentRelativeRectToViewportRelativeRect:GU,getDocumentElement:pa,getClippingRect:nB,getOffsetParent:aT,getElementRects:rB,getClientRects:KU,getDimensions:sB,getScale:Go,isElement:Ht,isRTL:iB};function rT(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function lB(e,t){let n=null,s;const i=pa(e);function l(){var d;clearTimeout(s),(d=n)==null||d.disconnect(),n=null}function c(d,h){d===void 0&&(d=!1),h===void 0&&(h=1),l();const m=e.getBoundingClientRect(),{left:p,top:y,width:x,height:w}=m;if(d||t(),!x||!w)return;const j=Uo(y),N=Uo(i.clientWidth-(p+x)),k=Uo(i.clientHeight-(y+w)),E=Uo(p),S={rootMargin:-j+"px "+-N+"px "+-k+"px "+-E+"px",threshold:ds(0,sl(1,h))||1};let M=!0;function C(I){const R=I[0].intersectionRatio;if(R!==h){if(!M)return c();R?c(!1,R):s=setTimeout(()=>{c(!1,1e-7)},1e3)}R===1&&!rT(m,e.getBoundingClientRect())&&c(),M=!1}try{n=new IntersectionObserver(C,{...S,root:i.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return c(!0),l}function bN(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:i=!0,ancestorResize:l=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:d=typeof IntersectionObserver=="function",animationFrame:h=!1}=s,m=Yy(e),p=i||l?[...m?Er(m):[],...Er(t)]:[];p.forEach(E=>{i&&E.addEventListener("scroll",n,{passive:!0}),l&&E.addEventListener("resize",n)});const y=m&&d?lB(m,n):null;let x=-1,w=null;c&&(w=new ResizeObserver(E=>{let[A]=E;A&&A.target===m&&w&&(w.unobserve(t),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var S;(S=w)==null||S.observe(t)})),n()}),m&&!h&&w.observe(m),w.observe(t));let j,N=h?Ci(e):null;h&&k();function k(){const E=Ci(e);N&&!rT(N,E)&&n(),N=E,j=requestAnimationFrame(k)}return n(),()=>{var E;p.forEach(A=>{i&&A.removeEventListener("scroll",n),l&&A.removeEventListener("resize",n)}),y?.(),(E=w)==null||E.disconnect(),w=null,h&&cancelAnimationFrame(j)}}const cB=FU,uB=HU,dB=UU,fB=ZU,hB=BU,mB=qU,pB=(e,t,n)=>{const s=new Map,i={platform:oB,...n},l={...i.platform,_c:s};return $U(e,t,{...i,platform:l})};var gB=typeof document<"u",vB=function(){},lf=gB?g.useLayoutEffect:vB;function Uf(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,s,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!Uf(e[s],t[s]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,i[s]))return!1;for(s=n;s--!==0;){const l=i[s];if(!(l==="_owner"&&e.$$typeof)&&!Uf(e[l],t[l]))return!1}return!0}return e!==e&&t!==t}function iT(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function wN(e,t){const n=iT(e);return Math.round(t*n)/n}function lg(e){const t=g.useRef(e);return lf(()=>{t.current=e}),t}function yB(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:i,elements:{reference:l,floating:c}={},transform:d=!0,whileElementsMounted:h,open:m}=e,[p,y]=g.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[x,w]=g.useState(s);Uf(x,s)||w(s);const[j,N]=g.useState(null),[k,E]=g.useState(null),A=g.useCallback(H=>{H!==I.current&&(I.current=H,N(H))},[]),S=g.useCallback(H=>{H!==R.current&&(R.current=H,E(H))},[]),M=l||j,C=c||k,I=g.useRef(null),R=g.useRef(null),D=g.useRef(p),z=h!=null,O=lg(h),_=lg(i),U=lg(m),q=g.useCallback(()=>{if(!I.current||!R.current)return;const H={placement:t,strategy:n,middleware:x};_.current&&(H.platform=_.current),pB(I.current,R.current,H).then(V=>{const W={...V,isPositioned:U.current!==!1};G.current&&!Uf(D.current,W)&&(D.current=W,ki.flushSync(()=>{y(W)}))})},[x,t,n,_,U]);lf(()=>{m===!1&&D.current.isPositioned&&(D.current.isPositioned=!1,y(H=>({...H,isPositioned:!1})))},[m]);const G=g.useRef(!1);lf(()=>(G.current=!0,()=>{G.current=!1}),[]),lf(()=>{if(M&&(I.current=M),C&&(R.current=C),M&&C){if(O.current)return O.current(M,C,q);q()}},[M,C,q,O,z]);const X=g.useMemo(()=>({reference:I,floating:R,setReference:A,setFloating:S}),[A,S]),L=g.useMemo(()=>({reference:M,floating:C}),[M,C]),F=g.useMemo(()=>{const H={position:n,left:0,top:0};if(!L.floating)return H;const V=wN(L.floating,p.x),W=wN(L.floating,p.y);return d?{...H,transform:"translate("+V+"px, "+W+"px)",...iT(L.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:V,top:W}},[n,d,L.floating,p.x,p.y]);return g.useMemo(()=>({...p,update:q,refs:X,elements:L,floatingStyles:F}),[p,q,X,L,F])}const xB=(e,t)=>({...cB(e),options:[e,t]}),bB=(e,t)=>({...uB(e),options:[e,t]}),wB=(e,t)=>({...mB(e),options:[e,t]}),jB=(e,t)=>({...dB(e),options:[e,t]}),NB=(e,t)=>({...fB(e),options:[e,t]}),SB=(e,t)=>({...hB(e),options:[e,t]}),kB={intentional:"onClick",sloppy:"onPointerDown"};function EB(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function CB(e,t={}){const n="rootStore"in e?e.rootStore:e,s=n.useState("open"),i=n.useState("floatingElement"),l=n.useState("referenceElement"),c=n.useState("domReferenceElement"),{onOpenChange:d,dataRef:h}=n.context,{enabled:m=!0,escapeKey:p=!0,outsidePress:y=!0,outsidePressEvent:x="sloppy",referencePress:w=!1,referencePressEvent:j="sloppy",ancestorScroll:N=!1,bubbles:k,externalTree:E}=t,A=ul(E),S=Qe(typeof y=="function"?y:()=>!1),M=typeof y=="function"?S:y,C=g.useRef(!1),{escapeKey:I,outsidePress:R}=EB(k),D=g.useRef(null),z=Ys(),O=Ys(),_=Qe(()=>{O.clear(),h.current.insideReactTree=!1}),U=g.useRef(!1),q=g.useRef(""),G=Qe(me=>{q.current=me.pointerType}),X=Qe(()=>{const me=q.current,Pe=me==="pen"||!me?"mouse":me,Re=typeof x=="function"?x():x;return typeof Re=="string"?Re:Re[Pe]}),L=Qe(me=>{if(!s||!m||!p||me.key!=="Escape"||U.current)return;const Pe=h.current.floatingContext?.nodeId,Re=A?Wo(A.nodesRef.current,Pe):[];if(!I&&Re.length>0){let oe=!0;if(Re.forEach(je=>{je.context?.open&&!je.context.dataRef.current.__escapeKeyBubbles&&(oe=!1)}),!oe)return}const Ye=H8(me)?me.nativeEvent:me,Ie=yn(bA,Ye);n.setOpen(!1,Ie),!I&&!Ie.isPropagationAllowed&&me.stopPropagation()}),F=Qe(me=>{const Pe=X();return Pe==="intentional"&&me.type!=="click"||Pe==="sloppy"&&me.type==="click"}),H=Qe(()=>{h.current.insideReactTree=!0,O.start(0,_)}),V=Qe((me,Pe=!1)=>{if(F(me)){_();return}if(h.current.insideReactTree){_();return}if(X()==="intentional"&&Pe||typeof M=="function"&&!M(me))return;const Re=es(me),Ye=`[${$c("inert")}]`,Ie=Rn(n.select("floatingElement")).querySelectorAll(Ye),oe=n.context.triggerElements;if(Re&&(oe.hasElement(Re)||oe.hasMatchingElement(ue=>Ft(ue,Re))))return;let je=Ht(Re)?Re:null;for(;je&&!ca(je);){const ue=ha(je);if(ca(ue)||!Ht(ue))break;je=ue}if(Ie.length&&Ht(Re)&&!V8(Re)&&!Ft(Re,n.select("floatingElement"))&&Array.from(Ie).every(ue=>!Ft(je,ue)))return;if(dn(Re)&&!("touches"in me)){const ue=ca(Re),Ce=gs(Re),be=/auto|scroll/,we=ue||be.test(Ce.overflowX),Se=ue||be.test(Ce.overflowY),He=we&&Re.clientWidth>0&&Re.scrollWidth>Re.clientWidth,et=Se&&Re.clientHeight>0&&Re.scrollHeight>Re.clientHeight,Be=Ce.direction==="rtl",St=et&&(Be?me.offsetX<=Re.offsetWidth-Re.clientWidth:me.offsetX>Re.clientWidth),Dt=He&&me.offsetY>Re.clientHeight;if(St||Dt)return}const Fe=h.current.floatingContext?.nodeId,le=A&&Wo(A.nodesRef.current,Fe).some(ue=>Bs(me,ue.context?.elements.floating));if(Bs(me,n.select("floatingElement"))||Bs(me,n.select("domReferenceElement"))||le)return;const ve=A?Wo(A.nodesRef.current,Fe):[];if(ve.length>0){let ue=!0;if(ve.forEach(Ce=>{Ce.context?.open&&!Ce.context.dataRef.current.__outsidePressBubbles&&(ue=!1)}),!ue)return}n.setOpen(!1,yn($y,me)),_()}),W=Qe(me=>{X()!=="sloppy"||me.pointerType==="touch"||!n.select("open")||!m||Bs(me,n.select("floatingElement"))||Bs(me,n.select("domReferenceElement"))||V(me)}),$=Qe(me=>{if(X()!=="sloppy"||!n.select("open")||!m||Bs(me,n.select("floatingElement"))||Bs(me,n.select("domReferenceElement")))return;const Pe=me.touches[0];Pe&&(D.current={startTime:Date.now(),startX:Pe.clientX,startY:Pe.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},z.start(1e3,()=>{D.current&&(D.current.dismissOnTouchEnd=!1,D.current.dismissOnMouseDown=!1)}))}),B=Qe(me=>{const Pe=es(me);function Re(){$(me),Pe?.removeEventListener(me.type,Re)}Pe?.addEventListener(me.type,Re)}),Y=Qe(me=>{const Pe=C.current;if(C.current=!1,z.clear(),me.type==="mousedown"&&D.current&&!D.current.dismissOnMouseDown)return;const Re=es(me);function Ye(){me.type==="pointerdown"?W(me):V(me,Pe),Re?.removeEventListener(me.type,Ye)}Re?.addEventListener(me.type,Ye)}),te=Qe(me=>{if(X()!=="sloppy"||!D.current||Bs(me,n.select("floatingElement"))||Bs(me,n.select("domReferenceElement")))return;const Pe=me.touches[0];if(!Pe)return;const Re=Math.abs(Pe.clientX-D.current.startX),Ye=Math.abs(Pe.clientY-D.current.startY),Ie=Math.sqrt(Re*Re+Ye*Ye);Ie>5&&(D.current.dismissOnTouchEnd=!0),Ie>10&&(V(me),z.clear(),D.current=null)}),ae=Qe(me=>{const Pe=es(me);function Re(){te(me),Pe?.removeEventListener(me.type,Re)}Pe?.addEventListener(me.type,Re)}),ee=Qe(me=>{X()!=="sloppy"||!D.current||Bs(me,n.select("floatingElement"))||Bs(me,n.select("domReferenceElement"))||(D.current.dismissOnTouchEnd&&V(me),z.clear(),D.current=null)}),ie=Qe(me=>{const Pe=es(me);function Re(){ee(me),Pe?.removeEventListener(me.type,Re)}Pe?.addEventListener(me.type,Re)});g.useEffect(()=>{if(!s||!m)return;h.current.__escapeKeyBubbles=I,h.current.__outsidePressBubbles=R;const me=new nl;function Pe(je){n.setOpen(!1,yn(e8,je))}function Re(){me.clear(),U.current=!0}function Ye(){me.start(yh()?5:0,()=>{U.current=!1})}const Ie=Rn(i);Ie.addEventListener("pointerdown",G,!0),p&&(Ie.addEventListener("keydown",L),Ie.addEventListener("compositionstart",Re),Ie.addEventListener("compositionend",Ye)),M&&(Ie.addEventListener("click",Y,!0),Ie.addEventListener("pointerdown",Y,!0),Ie.addEventListener("touchstart",B,!0),Ie.addEventListener("touchmove",ae,!0),Ie.addEventListener("touchend",ie,!0),Ie.addEventListener("mousedown",Y,!0));let oe=[];return N&&(Ht(c)&&(oe=Er(c)),Ht(i)&&(oe=oe.concat(Er(i))),!Ht(l)&&l&&l.contextElement&&(oe=oe.concat(Er(l.contextElement)))),oe=oe.filter(je=>je!==Ie.defaultView?.visualViewport),oe.forEach(je=>{je.addEventListener("scroll",Pe,{passive:!0})}),()=>{Ie.removeEventListener("pointerdown",G,!0),p&&(Ie.removeEventListener("keydown",L),Ie.removeEventListener("compositionstart",Re),Ie.removeEventListener("compositionend",Ye)),M&&(Ie.removeEventListener("click",Y,!0),Ie.removeEventListener("pointerdown",Y,!0),Ie.removeEventListener("touchstart",B,!0),Ie.removeEventListener("touchmove",ae,!0),Ie.removeEventListener("touchend",ie,!0),Ie.removeEventListener("mousedown",Y,!0)),oe.forEach(je=>{je.removeEventListener("scroll",Pe)}),me.clear()}},[h,i,l,c,p,M,s,d,N,m,I,R,L,V,Y,W,B,ae,ie,G,n]),g.useEffect(_,[M,_]);const de=g.useMemo(()=>({onKeyDown:L,...w&&{[kB[j]]:me=>{n.setOpen(!1,yn(Mf,me.nativeEvent))},...j!=="intentional"&&{onClick(me){n.setOpen(!1,yn(Mf,me.nativeEvent))}}}}),[L,n,w,j]),xe=Qe(me=>{const Pe=es(me.nativeEvent);!Ft(n.select("floatingElement"),Pe)||me.button!==0||(C.current=!0)}),Ae=g.useMemo(()=>({onKeyDown:L,onPointerDown:xe,onMouseDown:xe,onMouseUp:xe,onClickCapture:H,onMouseDownCapture:H,onPointerDownCapture:H,onMouseUpCapture:H,onTouchEndCapture:H,onTouchMoveCapture:H}),[L,xe,H]);return g.useMemo(()=>m?{reference:de,floating:Ae,trigger:de}:{},[m,de,Ae])}var Bf=Symbol("NOT_FOUND");function AB(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function TB(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function MB(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(s=>typeof s=="function"?`function ${s.name||"unnamed"}()`:typeof s).join(", ");throw new TypeError(`${t}[${n}]`)}}var jN=e=>Array.isArray(e)?e:[e];function RB(e){const t=Array.isArray(e[0])?e[0]:e;return MB(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function _B(e,t){const n=[],{length:s}=e;for(let i=0;i<s;i++)n.push(e[i].apply(null,t));return n}function IB(e){let t;return{get(n){return t&&e(t.key,n)?t.value:Bf},put(n,s){t={key:n,value:s}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function OB(e,t){let n=[];function s(d){const h=n.findIndex(m=>t(d,m.key));if(h>-1){const m=n[h];return h>0&&(n.splice(h,1),n.unshift(m)),m.value}return Bf}function i(d,h){s(d)===Bf&&(n.unshift({key:d,value:h}),n.length>e&&n.pop())}function l(){return n}function c(){n=[]}return{get:s,put:i,getEntries:l,clear:c}}var DB=(e,t)=>e===t;function PB(e){return function(n,s){if(n===null||s===null||n.length!==s.length)return!1;const{length:i}=n;for(let l=0;l<i;l++)if(!e(n[l],s[l]))return!1;return!0}}function zB(e,t){const n=typeof t=="object"?t:{equalityCheck:t},{equalityCheck:s=DB,maxSize:i=1,resultEqualityCheck:l}=n,c=PB(s);let d=0;const h=i<=1?IB(c):OB(i,c);function m(){let p=h.get(arguments);if(p===Bf){if(p=e.apply(null,arguments),d++,l){const x=h.getEntries().find(w=>l(w.value,p));x&&(p=x.value,d!==0&&d--)}h.put(arguments,p)}return p}return m.clearCache=()=>{h.clear(),m.resetResultsCount()},m.resultsCount=()=>d,m.resetResultsCount=()=>{d=0},m}var LB=class{constructor(e){this.value=e}deref(){return this.value}},$B=typeof WeakRef<"u"?WeakRef:LB,UB=0,NN=1;function Rd(){return{s:UB,v:void 0,o:null,p:null}}function oT(e,t={}){let n=Rd();const{resultEqualityCheck:s}=t;let i,l=0;function c(){let d=n;const{length:h}=arguments;for(let y=0,x=h;y<x;y++){const w=arguments[y];if(typeof w=="function"||typeof w=="object"&&w!==null){let j=d.o;j===null&&(d.o=j=new WeakMap);const N=j.get(w);N===void 0?(d=Rd(),j.set(w,d)):d=N}else{let j=d.p;j===null&&(d.p=j=new Map);const N=j.get(w);N===void 0?(d=Rd(),j.set(w,d)):d=N}}const m=d;let p;if(d.s===NN)p=d.v;else if(p=e.apply(null,arguments),l++,s){const y=i?.deref?.()??i;y!=null&&s(y,p)&&(p=y,l!==0&&l--),i=typeof p=="object"&&p!==null||typeof p=="function"?new $B(p):p}return m.s=NN,m.v=p,p}return c.clearCache=()=>{n=Rd(),c.resetResultsCount()},c.resultsCount=()=>l,c.resetResultsCount=()=>{l=0},c}function lT(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,s=(...i)=>{let l=0,c=0,d,h={},m=i.pop();typeof m=="object"&&(h=m,m=i.pop()),AB(m,`createSelector expects an output function after the inputs, but received: [${typeof m}]`);const p={...n,...h},{memoize:y,memoizeOptions:x=[],argsMemoize:w=oT,argsMemoizeOptions:j=[]}=p,N=jN(x),k=jN(j),E=RB(i),A=y(function(){return l++,m.apply(null,arguments)},...N),S=w(function(){c++;const C=_B(E,arguments);return d=A.apply(null,C),d},...k);return Object.assign(S,{resultFunc:m,memoizedResultFunc:A,dependencies:E,dependencyRecomputations:()=>c,resetDependencyRecomputations:()=>{c=0},lastResult:()=>d,recomputations:()=>l,resetRecomputations:()=>{l=0},memoize:y,argsMemoize:w})};return Object.assign(s,{withTypes:()=>s}),s}var BB=lT(oT),VB=Object.assign((e,t=BB)=>{TB(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),s=n.map(l=>e[l]);return t(s,(...l)=>l.reduce((c,d,h)=>(c[n[h]]=d,c),{}))},{withTypes:()=>VB});lT({memoize:zB,memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const ot=(e,t,n,s,i,l,...c)=>{if(c.length>0)throw new Error(Ti(1));let d;if(e)d=e;else throw new Error("Missing arguments");return d};var cg={exports:{}},ug={};var SN;function FB(){if(SN)return ug;SN=1;var e=Gc();function t(y,x){return y===x&&(y!==0||1/y===1/x)||y!==y&&x!==x}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,i=e.useEffect,l=e.useLayoutEffect,c=e.useDebugValue;function d(y,x){var w=x(),j=s({inst:{value:w,getSnapshot:x}}),N=j[0].inst,k=j[1];return l(function(){N.value=w,N.getSnapshot=x,h(N)&&k({inst:N})},[y,w,x]),i(function(){return h(N)&&k({inst:N}),y(function(){h(N)&&k({inst:N})})},[y]),c(w),w}function h(y){var x=y.getSnapshot;y=y.value;try{var w=x();return!n(y,w)}catch{return!0}}function m(y,x){return x()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?m:d;return ug.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,ug}var kN;function cT(){return kN||(kN=1,cg.exports=FB()),cg.exports}var HB=cT(),dg={exports:{}},fg={};var EN;function qB(){if(EN)return fg;EN=1;var e=Gc(),t=cT();function n(m,p){return m===p&&(m!==0||1/m===1/p)||m!==m&&p!==p}var s=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,l=e.useRef,c=e.useEffect,d=e.useMemo,h=e.useDebugValue;return fg.useSyncExternalStoreWithSelector=function(m,p,y,x,w){var j=l(null);if(j.current===null){var N={hasValue:!1,value:null};j.current=N}else N=j.current;j=d(function(){function E(I){if(!A){if(A=!0,S=I,I=x(I),w!==void 0&&N.hasValue){var R=N.value;if(w(R,I))return M=R}return M=I}if(R=M,s(S,I))return R;var D=x(I);return w!==void 0&&w(R,D)?(S=I,R):(S=I,M=D)}var A=!1,S,M,C=y===void 0?null:y;return[function(){return E(p())},C===null?void 0:function(){return E(C())}]},[p,y,x,w]);var k=i(m,j[0],j[1]);return c(function(){N.hasValue=!0,N.value=k},[k]),h(k),k},fg}var CN;function ZB(){return CN||(CN=1,dg.exports=qB()),dg.exports}var WB=ZB();const YB=zy(19),GB=YB?XB:JB;function KB(e,t,n,s,i){return GB(e,t,n,s,i)}function XB(e,t,n,s,i){const l=g.useCallback(()=>t(e.getSnapshot(),n,s,i),[e,t,n,s,i]);return HB.useSyncExternalStore(e.subscribe,l,l)}function JB(e,t,n,s,i){return WB.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,l=>t(l,n,s,i))}class Ec{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 s of this.listeners){if(n!==this.updateTick)return;s(t)}}update(t){for(const n in t)if(!Object.is(this.state[n],t[n])){Ec.prototype.setState.call(this,{...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||Ec.prototype.setState.call(this,{...this.state,[t]:n})}notifyAll(){const t={...this.state};Ec.prototype.setState.call(this,t)}}class uT extends Ec{constructor(t,n={},s){super(t),this.context=n,this.selectors=s}controlledValues=new Map;useSyncedValue(t,n){g.useDebugValue(t),Ke(()=>{this.state[t]!==n&&this.set(t,n)},[t,n])}useSyncedValueWithCleanup(t,n){Ke(()=>(this.state[t]!==n&&this.set(t,n),()=>{this.set(t,void 0)}),[t,n])}useSyncedValues(t){const n=Object.values(t);Ke(()=>{this.update(t)},n)}useControlledProp(t,n,s){g.useDebugValue(t);const i=n!==void 0;this.controlledValues.has(t)||(this.controlledValues.set(t,i),!i&&!Object.is(this.state[t],s)&&super.setState({...this.state,[t]:s})),Ke(()=>{i&&!Object.is(this.state[t],n)&&super.setState({...this.state,[t]:n})},[t,n,s,i])}set(t,n){this.controlledValues.get(t)!==!0&&super.set(t,n)}update(t){const n={...t};for(const s in n)if(Object.hasOwn(n,s)&&this.controlledValues.get(s)===!0){delete n[s];continue}super.update(n)}setState(t){const n={...t};for(const s in n)if(Object.hasOwn(n,s)&&this.controlledValues.get(s)===!0){delete n[s];continue}super.setState({...this.state,...n})}select=(t,n,s,i)=>{const l=this.selectors[t];return l(this.state,n,s,i)};useState=(t,n,s,i)=>{g.useDebugValue(t);const l=this.selectors[t];return KB(this,l,n,s,i)};useContextCallback(t,n){g.useDebugValue(t);const s=Qe(n??gA);this.context[t]=s}useStateSetter(t){const n=g.useRef(void 0);return n.current===void 0&&(n.current=s=>{this.set(t,s)}),n.current}observe(t,n){let s;typeof t=="function"?s=t:s=this.selectors[t];let i=s(this.state);return n(i,i,this),this.subscribe(l=>{const c=s(l);if(!Object.is(i,c)){const d=i;i=c,n(c,d,this)}})}}const QB={open:ot(e=>e.open),domReferenceElement:ot(e=>e.domReferenceElement),referenceElement:ot(e=>e.positionReference??e.referenceElement),floatingElement:ot(e=>e.floatingElement),floatingId:ot(e=>e.floatingId)};class Gy extends uT{constructor(t){const{nested:n,noEmit:s,onOpenChange:i,triggerElements:l,...c}=t;super({...c,positionReference:c.referenceElement,domReferenceElement:c.referenceElement},{onOpenChange:i,dataRef:{current:{}},events:qA(),nested:n,noEmit:s,triggerElements:l},QB)}setOpen=(t,n)=>{if((!t||!this.state.open||Z8(n.event))&&(this.context.dataRef.current.openEvent=t?n.event:void 0),!this.context.noEmit){const s={open:t,reason:n.reason,nativeEvent:n.event,nested:this.context.nested,triggerElement:n.trigger};this.context.events.emit("openchange",s)}this.context.onOpenChange?.(t,n)}}function e9(e){const t=e.useState("open");Ke(()=>{if(t&&!e.select("activeTriggerId")&&e.context.triggerElements.size===1){const n=e.context.triggerElements.entries().next();if(!n.done){const[s,i]=n.value;e.update({activeTriggerId:s,activeTriggerElement:i})}}},[t,e])}function t9(e,t,n){const{mounted:s,setMounted:i,transitionStatus:l}=A8(e);t.useSyncedValues({mounted:s,transitionStatus:l});const c=Qe(()=>{i(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}),d=t.useState("preventUnmountingOnClose");return kA({enabled:!d,open:e,ref:t.context.popupRef,onComplete(){e||c()}}),{forceUnmount:c,transitionStatus:l}}class Ky{constructor(){this.elements=new Set,this.idMap=new Map}add(t,n){const s=this.idMap.get(t);s!==n&&(s!==void 0&&this.elements.delete(s),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 n9(){return new Gy({open:!1,floatingElement:null,referenceElement:null,triggerElements:new Ky,floatingId:"",nested:!1,noEmit:!1,onOpenChange:void 0})}function s9(){return{open:!1,mounted:!1,transitionStatus:"idle",floatingRootContext:n9(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,popupElement:null,positionerElement:null,activeTriggerProps:ts,inactiveTriggerProps:ts,popupProps:ts}}const a9={open:ot(e=>e.open),mounted:ot(e=>e.mounted),transitionStatus:ot(e=>e.transitionStatus),floatingRootContext:ot(e=>e.floatingRootContext),preventUnmountingOnClose:ot(e=>e.preventUnmountingOnClose),payload:ot(e=>e.payload),activeTriggerId:ot(e=>e.activeTriggerId),activeTriggerElement:ot(e=>e.mounted?e.activeTriggerElement:null),isTriggerActive:ot((e,t)=>t!==void 0&&e.activeTriggerId===t),isOpenedByTrigger:ot((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.open),isMountedByTrigger:ot((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.mounted),triggerProps:ot((e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps),popupProps:ot(e=>e.popupProps),popupElement:ot(e=>e.popupElement),positionerElement:ot(e=>e.positionerElement)};function r9(e){const{open:t=!1,onOpenChange:n,elements:s={}}=e,i=zr(),l=Br()!=null,c=Is(()=>new Gy({open:t,onOpenChange:n,referenceElement:s.reference??null,floatingElement:s.floating??null,triggerElements:s.triggers??new Ky,floatingId:i,nested:l,noEmit:e.noEmit||!1})).current;return Ke(()=>{const d={open:t,floatingId:i};s.reference!==void 0&&(d.referenceElement=s.reference,d.domReferenceElement=Ht(s.reference)?s.reference:null),s.floating!==void 0&&(d.floatingElement=s.floating),c.update(d)},[t,i,s.reference,s.floating,c]),c.context.onOpenChange=n,c.context.nested=l,c.context.noEmit=e.noEmit||!1,c}function i9(e={}){const{nodeId:t,externalTree:n}=e,s=r9(e),i=e.rootContext||s,l={reference:i.useState("referenceElement"),floating:i.useState("floatingElement"),domReference:i.useState("domReferenceElement")},[c,d]=g.useState(null),h=g.useRef(null),m=ul(n);Ke(()=>{l.domReference&&(h.current=l.domReference)},[l.domReference]);const p=yB({...e,elements:{...l,...c&&{reference:c}}}),y=g.useCallback(R=>{const D=Ht(R)?{getBoundingClientRect:()=>R.getBoundingClientRect(),getClientRects:()=>R.getClientRects(),contextElement:R}:R;d(D),p.refs.setReference(D)},[p.refs]),[x,w]=g.useState(null),[j,N]=g.useState(null);i.useSyncedValue("referenceElement",x),i.useSyncedValue("domReferenceElement",Ht(x)?x:null),i.useSyncedValue("floatingElement",j);const k=g.useCallback(R=>{(Ht(R)||R===null)&&(h.current=R,w(R)),(Ht(p.refs.reference.current)||p.refs.reference.current===null||R!==null&&!Ht(R))&&p.refs.setReference(R)},[p.refs,w]),E=g.useCallback(R=>{N(R),p.refs.setFloating(R)},[p.refs]),A=g.useMemo(()=>({...p.refs,setReference:k,setFloating:E,setPositionReference:y,domReference:h}),[p.refs,k,E,y]),S=g.useMemo(()=>({...p.elements,domReference:l.domReference}),[p.elements,l.domReference]),M=i.useState("open"),C=i.useState("floatingId"),I=g.useMemo(()=>({...p,dataRef:i.context.dataRef,open:M,onOpenChange:i.setOpen,events:i.context.events,floatingId:C,refs:A,elements:S,nodeId:t,rootStore:i}),[p,A,S,t,i,M,C]);return Ke(()=>{i.context.dataRef.current.floatingContext=I;const R=m?.nodesRef.current.find(D=>D.id===t);R&&(R.context=I)}),g.useMemo(()=>({...p,context:I,refs:A,elements:S,rootStore:i}),[p,A,S,I,i])}function o9(e){const{popupStore:t,noEmit:n=!1,treatPopupAsFloatingElement:s=!1,onOpenChange:i}=e,l=zr(),c=Br()!=null,d=t.useState("open"),h=t.useState("activeTriggerElement"),m=t.useState(s?"popupElement":"positionerElement"),p=t.context.triggerElements,y=Is(()=>new Gy({open:d,referenceElement:h,floatingElement:m,triggerElements:p,onOpenChange:i,floatingId:l,nested:c,noEmit:n})).current;return Ke(()=>{const x={open:d,floatingId:l,referenceElement:h,floatingElement:m};Ht(h)&&(x.domReferenceElement=h),y.update(x)},[d,l,h,m,y]),y.context.onOpenChange=i,y.context.nested=c,y.context.noEmit=n,y}const AN=$c("safe-polygon"),l9=`button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${RA}`;function c9(e){return e?!!e.closest(l9):!1}function u9(e){const t=g.useRef(void 0),n=g.useRef(!1),s=g.useRef(void 0),i=g.useRef(!0),l=g.useRef(!1),c=g.useRef(()=>{}),d=g.useRef(!1),h=Ys(),m=Ys(),p=g.useRef(void 0);return g.useMemo(()=>{const y=e.context.dataRef.current;return y.hoverInteractionState||(y.hoverInteractionState={pointerTypeRef:t,interactedInsideRef:n,handlerRef:s,blockMouseMoveRef:i,performedPointerEventsMutationRef:l,unbindMouseMoveRef:c,restTimeoutPendingRef:d,openChangeTimeout:h,restTimeout:m,handleCloseOptionsRef:p}),y.hoverInteractionState},[e,t,n,s,i,l,c,d,h,m,p])}const d9=new Set(["click","mousedown"]);function f9(e,t={}){const n="rootStore"in e?e.rootStore:e,s=n.useState("open"),i=n.useState("floatingElement"),l=n.useState("domReferenceElement"),{dataRef:c}=n.context,{enabled:d=!0,closeDelay:h=0,externalTree:m}=t,{pointerTypeRef:p,interactedInsideRef:y,handlerRef:x,performedPointerEventsMutationRef:w,unbindMouseMoveRef:j,restTimeoutPendingRef:N,openChangeTimeout:k,handleCloseOptionsRef:E}=u9(n),A=ul(m),S=Br(),M=Qe(()=>y.current?!0:c.current.openEvent?d9.has(c.current.openEvent.type):!1),C=Qe(()=>{const O=c.current.openEvent?.type;return O?.includes("mouse")&&O!=="mousedown"}),I=g.useCallback((O,_=!0)=>{const U=h9(h,p.current);U&&!x.current?k.start(U,()=>n.setOpen(!1,yn(xi,O))):_&&(k.clear(),n.setOpen(!1,yn(xi,O)))},[h,x,n,p,k]),R=Qe(()=>{j.current(),x.current=void 0}),D=Qe(()=>{if(w.current){const O=Rn(i).body;O.style.pointerEvents="",O.removeAttribute(AN),w.current=!1}}),z=Qe(O=>{const _=es(O);if(!c9(_)){y.current=!1;return}y.current=!0});Ke(()=>{s||(p.current=void 0,N.current=!1,y.current=!1,R(),D())},[s,p,N,y,R,D]),g.useEffect(()=>()=>{R()},[R]),g.useEffect(()=>D,[D]),Ke(()=>{if(d&&s&&E.current?.blockPointerEvents&&C()&&Ht(l)&&i){w.current=!0;const O=Rn(i).body;O.setAttribute(AN,"");const _=l,U=i,q=A?.nodesRef.current.find(G=>G.id===S)?.context?.elements.floating;return q&&(q.style.pointerEvents=""),O.style.pointerEvents="none",_.style.pointerEvents="auto",U.style.pointerEvents="auto",()=>{O.style.pointerEvents="",_.style.pointerEvents="",U.style.pointerEvents=""}}},[d,s,l,i,E,C,A,S,w]),g.useEffect(()=>{if(!d)return;function O(G){if(M()||!c.current.floatingContext)return;const X=n.context.triggerElements;G.relatedTarget&&X.hasElement(G.relatedTarget)||(D(),R(),M()||I(G))}function _(G){k.clear(),D(),x.current?.(G),R()}function U(G){M()||I(G,!1)}const q=i;return q&&(q.addEventListener("mouseleave",O),q.addEventListener("mouseenter",_),q.addEventListener("mouseleave",U),q.addEventListener("pointerdown",z,!0)),()=>{q&&(q.removeEventListener("mouseleave",O),q.removeEventListener("mouseenter",_),q.removeEventListener("mouseleave",U),q.removeEventListener("pointerdown",z,!0))}})}function h9(e,t){return t&&!q8(t)?0:typeof e=="function"?e():e}function m9(e=[]){const t=e.map(m=>m?.reference),n=e.map(m=>m?.floating),s=e.map(m=>m?.item),i=e.map(m=>m?.trigger),l=g.useCallback(m=>_d(m,e,"reference"),t),c=g.useCallback(m=>_d(m,e,"floating"),n),d=g.useCallback(m=>_d(m,e,"item"),s),h=g.useCallback(m=>_d(m,e,"trigger"),i);return g.useMemo(()=>({getReferenceProps:l,getFloatingProps:c,getItemProps:d,getTriggerProps:h}),[l,c,d,h])}function _d(e,t,n){const s=new Map,i=n==="item",l={};n==="floating"&&(l.tabIndex=-1,l[jv]="");for(const c in e)i&&e&&(c===TA||c===MA)||(l[c]=e[c]);for(let c=0;c<t.length;c+=1){let d;const h=t[c]?.[n];typeof h=="function"?d=e?h(e):null:d=h,d&&TN(l,d,i,s)}return TN(l,e,i,s),l}function TN(e,t,n,s){for(const i in t){const l=t[i];n&&(i===TA||i===MA)||(i.startsWith("on")?(s.has(i)||s.set(i,[]),typeof l=="function"&&(s.get(i)?.push(l),e[i]=(...c)=>s.get(i)?.map(d=>d(...c)).find(d=>d!==void 0))):e[i]=l)}}const p9="Escape";function jh(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Id(e,t){return jh(t,e===Fy||e===Qc,e===Cr||e===Ar)}function hg(e,t,n){return jh(t,e===Qc,n?e===Cr:e===Ar)||e==="Enter"||e===" "||e===""}function g9(e,t,n){return jh(t,n?e===Cr:e===Ar,e===Qc)}function v9(e,t,n,s){const i=n?e===Ar:e===Cr,l=e===Fy;return t==="both"||t==="horizontal"&&s&&s>1?e===p9:jh(t,i,l)}function y9(e,t){const n="rootStore"in e?e.rootStore:e,s=n.useState("open"),i=n.useState("floatingElement"),l=n.useState("domReferenceElement"),c=n.context.dataRef,{listRef:d,activeIndex:h,onNavigate:m=()=>{},enabled:p=!0,selectedIndex:y=null,allowEscape:x=!1,loopFocus:w=!1,nested:j=!1,rtl:N=!1,virtual:k=!1,focusItemOnOpen:E="auto",focusItemOnHover:A=!0,openOnArrowKeyDown:S=!0,disabledIndices:M=void 0,orientation:C="vertical",parentOrientation:I,cols:R=1,scrollItemIntoView:D=!0,itemSizes:z,dense:O=!1,id:_,resetOnPointerLeave:U=!0,externalTree:q}=t,G=Rf(i),X=Qn(G),L=Br(),F=ul(q);Ke(()=>{c.current.orientation=C},[c,C]);const H=Nv(l),V=g.useRef(E),W=g.useRef(y??-1),$=g.useRef(null),B=g.useRef(!0),Y=Qe(be=>{m(W.current===-1?null:W.current,be)}),te=g.useRef(Y),ae=g.useRef(!!i),ee=g.useRef(s),ie=g.useRef(!1),de=g.useRef(!1),xe=Qn(M),Ae=Qn(s),me=Qn(D),Pe=Qn(y),Re=Qn(U),Ye=Qe(()=>{function be(et){k?F?.events.emit("virtualfocus",et):of(et,{sync:ie.current,preventScroll:!0})}const we=d.current[W.current],Se=de.current;we&&be(we),(ie.current?et=>et():requestAnimationFrame)(()=>{const et=d.current[W.current]||we;if(!et)return;we||be(et);const Be=me.current;Be&&oe&&(Se||!B.current)&&et.scrollIntoView?.(typeof Be=="boolean"?{block:"nearest",inline:"nearest"}:Be)})});Ke(()=>{p&&(s&&i?(W.current=y??-1,V.current&&y!=null&&(de.current=!0,Y())):ae.current&&(W.current=-1,te.current()))},[p,s,i,y,Y]),Ke(()=>{if(p){if(!s){ie.current=!1;return}if(i)if(h==null){if(ie.current=!1,Pe.current!=null)return;if(ae.current&&(W.current=-1,Ye()),(!ee.current||!ae.current)&&V.current&&($.current!=null||V.current===!0&&$.current==null)){let be=0;const we=()=>{d.current[0]==null?(be<2&&(be?requestAnimationFrame:queueMicrotask)(we),be+=1):(W.current=$.current==null||hg($.current,C,N)||j?ag(d):oN(d),$.current=null,Y())};we()}}else Nc(d,h)||(W.current=h,Ye(),de.current=!1)}},[p,s,i,h,Pe,j,d,C,N,Y,Ye,xe]),Ke(()=>{if(!p||i||!F||k||!ae.current)return;const be=F.nodesRef.current,we=be.find(et=>et.id===L)?.context?.elements.floating,Se=wr(Rn(i)),He=be.some(et=>et.context&&Ft(et.context.elements.floating,Se));we&&!He&&B.current&&we.focus({preventScroll:!0})},[p,i,F,L,k]),Ke(()=>{te.current=Y,ee.current=s,ae.current=!!i}),Ke(()=>{s||($.current=null,V.current=E)},[s,E]);const Ie=h!=null,oe=g.useMemo(()=>{function be(Se){if(!Ae.current)return;const He=d.current.indexOf(Se.currentTarget);He!==-1&&W.current!==He&&(W.current=He,Y(Se))}return{onFocus(Se){ie.current=!0,be(Se)},onClick:({currentTarget:Se})=>Se.focus({preventScroll:!0}),onMouseMove(Se){ie.current=!0,de.current=!1,A&&be(Se)},onPointerLeave(Se){if(!Ae.current||!B.current||Se.pointerType==="touch")return;ie.current=!0;const He=Se.relatedTarget;!A||d.current.includes(He)||Re.current&&(W.current=-1,Y(Se),k||X.current?.focus({preventScroll:!0}))}}},[Ae,X,A,d,Y,Re,k]),je=g.useCallback(()=>I??F?.nodesRef.current.find(be=>be.id===L)?.context?.dataRef?.current.orientation,[L,F,I]),Fe=Qe(be=>{if(B.current=!1,ie.current=!0,be.which===229||!Ae.current&&be.currentTarget===X.current)return;if(j&&v9(be.key,C,N,R)){Id(be.key,je())||_n(be),n.setOpen(!1,yn(rf,be.nativeEvent)),dn(l)&&(k?F?.events.emit("virtualfocus",l):l.focus());return}const we=W.current,Se=ag(d,M),He=oN(d,M);if(H||(be.key==="Home"&&(_n(be),W.current=Se,Y(be)),be.key==="End"&&(_n(be),W.current=He,Y(be))),R>1){const et=z||Array.from({length:d.current.length},()=>({width:1,height:1})),Be=rU(et,R,O),St=Be.findIndex(Ee=>Ee!=null&&!Sc(d,Ee,M)),Dt=Be.reduce((Ee,Oe,Te)=>Oe!=null&&!Sc(d,Oe,M)?Te:Ee,-1),Xt=Be[aU({current:Be.map(Ee=>Ee!=null?d.current[Ee]:null)},{event:be,orientation:C,loopFocus:w,rtl:N,cols:R,disabledIndices:oU([...(typeof M!="function"?M:null)||d.current.map((Ee,Oe)=>Sc(d,Oe,M)?Oe:void 0),void 0],Be),minIndex:St,maxIndex:Dt,prevIndex:iU(W.current>He?Se:W.current,et,Be,R,be.key===Qc?"bl":be.key===(N?Cr:Ar)?"tr":"tl"),stopEvent:!0})];if(Xt!=null&&(W.current=Xt,Y(be)),C==="both")return}if(Id(be.key,C)){if(_n(be),s&&!k&&wr(be.currentTarget.ownerDocument)===be.currentTarget){W.current=hg(be.key,C,N)?Se:He,Y(be);return}hg(be.key,C,N)?w?we>=He?x&&we!==d.current.length?W.current=-1:(ie.current=!1,W.current=Se):W.current=Dn(d,{startingIndex:we,disabledIndices:M}):W.current=Math.min(He,Dn(d,{startingIndex:we,disabledIndices:M})):w?we<=Se?x&&we!==-1?W.current=d.current.length:(ie.current=!1,W.current=He):W.current=Dn(d,{startingIndex:we,decrement:!0,disabledIndices:M}):W.current=Math.max(Se,Dn(d,{startingIndex:we,decrement:!0,disabledIndices:M})),Nc(d,W.current)&&(W.current=-1),Y(be)}}),le=g.useMemo(()=>k&&s&&Ie&&{"aria-activedescendant":`${_}-${h}`},[k,s,Ie,_,h]),ve=g.useMemo(()=>({"aria-orientation":C==="both"?void 0:C,...H?{}:le,onKeyDown(be){if(be.key==="Tab"&&be.shiftKey&&s&&!k){const we=es(be.nativeEvent);if(we&&!Ft(X.current,we))return;_n(be),n.setOpen(!1,yn(ph,be.nativeEvent)),dn(l)&&l.focus();return}Fe(be)},onPointerMove(){B.current=!0}}),[le,Fe,X,C,H,n,s,k,l]),ue=g.useMemo(()=>{function be(Se){E==="auto"&&_A(Se.nativeEvent)&&(V.current=!k)}function we(Se){V.current=E,E==="auto"&&IA(Se.nativeEvent)&&(V.current=!0)}return{onKeyDown(Se){const He=n.select("open");B.current=!1;const et=Se.key.startsWith("Arrow"),Be=g9(Se.key,je(),N),St=Id(Se.key,C),Dt=(j?Be:St)||Se.key==="Enter"||Se.key.trim()==="";if(k&&He)return Fe(Se);if(!(!He&&!S&&et)){if(Dt){const Xt=Id(Se.key,je());$.current=j&&Xt?null:Se.key}if(j){Be&&(_n(Se),He?(W.current=ag(d,xe.current),Y(Se)):n.setOpen(!0,yn(rf,Se.nativeEvent,Se.currentTarget)));return}St&&(Pe.current!=null&&(W.current=Pe.current),_n(Se),!He&&S?n.setOpen(!0,yn(rf,Se.nativeEvent,Se.currentTarget)):Fe(Se),He&&Y(Se))}},onFocus(Se){n.select("open")&&!k&&(W.current=-1,Y(Se))},onPointerDown:we,onPointerEnter:we,onMouseDown:be,onClick:be}},[Fe,xe,E,d,j,Y,n,S,C,je,N,Pe,k]),Ce=g.useMemo(()=>({...le,...ue}),[le,ue]);return g.useMemo(()=>p?{reference:Ce,floating:ve,item:oe,trigger:ue}:{},[p,Ce,ve,ue,oe])}const x9=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function b9(e,t={}){const n="rootStore"in e?e.rootStore:e,s=n.useState("open"),i=n.useState("floatingId"),l=n.useState("domReferenceElement"),c=n.useState("floatingElement"),{enabled:d=!0,role:h="dialog"}=t,m=zr(),p=l?.id||m,y=g.useMemo(()=>Rf(c)?.id||i,[c,i]),x=x9.get(h)??h,j=Br()!=null,N=g.useMemo(()=>x==="tooltip"||h==="label"?ts:{"aria-haspopup":x==="alertdialog"?"dialog":x,"aria-expanded":"false",...x==="listbox"&&{role:"combobox"},...x==="menu"&&j&&{role:"menuitem"},...h==="select"&&{"aria-autocomplete":"none"},...h==="combobox"&&{"aria-autocomplete":"list"}},[x,j,h]),k=g.useMemo(()=>x==="tooltip"||h==="label"?{[`aria-${h==="label"?"labelledby":"describedby"}`]:s?y:void 0}:{...N,"aria-expanded":s?"true":"false","aria-controls":s?y:void 0,...x==="menu"&&{id:p}},[x,y,s,p,h,N]),E=g.useMemo(()=>{const S={id:y,...x&&{role:x}};return x==="tooltip"||h==="label"?S:{...S,...x==="menu"&&{"aria-labelledby":p}}},[x,y,p,h]),A=g.useCallback(({active:S,selected:M})=>{const C={role:"option",...S&&{id:`${y}-fui-option`}};switch(h){case"select":case"combobox":return{...C,"aria-selected":M}}return{}},[y,h]);return g.useMemo(()=>d?{reference:k,floating:E,item:A,trigger:N}:{},[d,k,E,N,A])}function w9(e,t){const n="rootStore"in e?e.rootStore:e,s=n.useState("open"),i=n.context.dataRef,{listRef:l,activeIndex:c,onMatch:d,onTypingChange:h,enabled:m=!0,findMatch:p=null,resetMs:y=750,ignoreKeys:x=vA,selectedIndex:w=null}=t,j=Ys(),N=g.useRef(""),k=g.useRef(w??c??-1),E=g.useRef(null);Ke(()=>{s&&(j.clear(),E.current=null,N.current="")},[s,j]),Ke(()=>{s&&N.current===""&&(k.current=w??c??-1)},[s,w,c]);const A=Qe(I=>{I?i.current.typing||(i.current.typing=I,h?.(I)):i.current.typing&&(i.current.typing=I,h?.(I))}),S=Qe(I=>{function R(U,q,G){const X=p?p(q,G):q.find(L=>L?.toLocaleLowerCase().indexOf(G.toLocaleLowerCase())===0);return X?U.indexOf(X):-1}const D=l.current;if(N.current.length>0&&N.current[0]!==" "&&(R(D,D,N.current)===-1?A(!1):I.key===" "&&_n(I)),D==null||x.includes(I.key)||I.key.length!==1||I.ctrlKey||I.metaKey||I.altKey)return;s&&I.key!==" "&&(_n(I),A(!0)),D.every(U=>U?U[0]?.toLocaleLowerCase()!==U[1]?.toLocaleLowerCase():!0)&&N.current===I.key&&(N.current="",k.current=E.current),N.current+=I.key,j.start(y,()=>{N.current="",k.current=E.current,A(!1)});const O=k.current,_=R(D,[...D.slice((O||0)+1),...D.slice(0,(O||0)+1)],N.current);_!==-1?(d?.(_),E.current=_):I.key!==" "&&(N.current="",A(!1))}),M=g.useMemo(()=>({onKeyDown:S}),[S]),C=g.useMemo(()=>({onKeyDown:S,onKeyUp(I){I.key===" "&&A(!1)}}),[S,A]);return g.useMemo(()=>m?{reference:M,floating:C}:{},[m,M,C])}const j9=g.createContext(void 0);function N9(e){return g.useContext(j9)}const dT="ArrowUp",fT="ArrowDown",hT="ArrowLeft",mT="ArrowRight",pT="Home",gT="End",S9=new Set([hT,mT]),k9=new Set([dT,fT]),E9=new Set([...S9,...k9]);[...E9];const C9=new Set([dT,fT,hT,mT,pT,gT]);function A9(e){return e==="starting"?$6:ts}const T9={...yA,...Y6},M9=g.forwardRef(function(t,n){const{render:s,className:i,finalFocus:l,...c}=t,{store:d}=ll(),{side:h,align:m}=dA(),p=N9()!=null,y=d.useState("open"),x=d.useState("transitionStatus"),w=d.useState("popupProps"),j=d.useState("mounted"),N=d.useState("instantType"),k=d.useState("activeTriggerElement"),E=d.useState("parent"),A=d.useState("lastOpenChangeReason"),S=d.useState("rootId"),M=d.useState("floatingRootContext"),C=d.useState("floatingTreeRoot"),I=d.useState("closeDelay"),R=d.useState("activeTriggerElement");kA({open:y,ref:d.context.popupRef,onComplete(){y&&d.context.onOpenChangeComplete?.(!0)}}),g.useEffect(()=>{function q(G){d.setOpen(!1,yn(G.reason,G.domEvent))}return C.events.on("close",q),()=>{C.events.off("close",q)}},[C.events,d]);const D=d.useState("hoverEnabled"),z=d.useState("disabled");f9(M,{enabled:D&&!z&&E.type!=="context-menu"&&E.type!=="menubar",closeDelay:I});const O=g.useMemo(()=>({transitionStatus:x,side:h,align:m,open:y,nested:E.type==="menu",instant:N}),[x,h,m,y,E.type,N]),_=Lr("div",t,{state:O,ref:[n,d.context.popupRef],stateAttributesMapping:T9,props:[w,{onKeyDown(q){p&&C9.has(q.key)&&q.stopPropagation()}},A9(x),c,{"data-rootownerid":S}]});let U=E.type===void 0||E.type==="context-menu";return(k||E.type==="menubar"&&A!==$y)&&(U=!0),r.jsx(zU,{context:M,modal:!1,disabled:!j,returnFocus:l===void 0?U:l,initialFocus:E.type!=="menu",restoreFocus:!0,externalTree:E.type!=="menubar"?C:void 0,previousFocusableElement:R,nextFocusableElement:E.type===void 0?d.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:E.type===void 0?d.context.beforeContentFocusGuardRef:void 0,children:_})}),vT=g.createContext(void 0);function R9(){const e=g.useContext(vT);if(e===void 0)throw new Error(Ti(32));return e}const _9=g.forwardRef(function(t,n){const{keepMounted:s=!1,...i}=t,{store:l}=ll();return l.useState("mounted")||s?r.jsx(vT.Provider,{value:s,children:r.jsx(_U,{ref:n,...i})}):null});function I9(e){return zy(19)?e:e?"true":void 0}const O9=g.createContext(void 0);function yT(){return g.useContext(O9)?.direction??"ltr"}const D9=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:i,rects:l,platform:c,elements:d,middlewareData:h}=t,{element:m,padding:p=0,offsetParent:y="real"}=Ba(e,t)||{};if(m==null)return{};const x=OA(p),w={x:n,y:s},j=Zy(i),N=qy(j),k=await c.getDimensions(m),E=j==="y",A=E?"top":"left",S=E?"bottom":"right",M=E?"clientHeight":"clientWidth",C=l.reference[N]+l.reference[j]-w[j]-l.floating[N],I=w[j]-l.reference[j],R=y==="real"?await c.getOffsetParent?.(m):d.floating;let D=d.floating[M]||l.floating[N];(!D||!await c.isElement?.(R))&&(D=d.floating[M]||l.floating[N]);const z=C/2-I/2,O=D/2-k[N]/2-1,_=Math.min(x[A],O),U=Math.min(x[S],O),q=_,G=D-k[N]-U,X=D/2-k[N]/2+z,L=Sv(q,X,G),F=!h.arrow&&Ur(i)!=null&&X!==L&&l.reference[N]/2-(X<q?_:U)-k[N]/2<0,H=F?X<q?X-q:X-G:0;return{[j]:w[j]+H,data:{[j]:L,centerOffset:X-L-H,...F&&{alignmentOffset:H}},reset:F}}}),P9=(e,t)=>({...D9(e),options:[e,t]}),z9={name:"hide",async fn(e){const{width:t,height:n,x:s,y:i}=e.rects.reference,l=t===0&&n===0&&s===0&&i===0;return{data:{referenceHidden:(await SB().fn(e)).data?.referenceHidden||l}}}},L9={sideX:"left",sideY:"top"};function xT(e,t,n){const s=e==="inline-start"||e==="inline-end";return{top:"top",right:s?n?"inline-start":"inline-end":"right",bottom:"bottom",left:s?n?"inline-end":"inline-start":"left"}[t]}function MN(e,t,n){const{rects:s,placement:i}=e;return{side:xT(t,ms(i),n),align:Ur(i)||"center",anchor:{width:s.reference.width,height:s.reference.height},positioner:{width:s.floating.width,height:s.floating.height}}}function $9(e){const{anchor:t,positionMethod:n="absolute",side:s="bottom",sideOffset:i=0,align:l="center",alignOffset:c=0,collisionBoundary:d,collisionPadding:h=5,sticky:m=!1,arrowPadding:p=5,disableAnchorTracking:y=!1,keepMounted:x=!1,floatingRootContext:w,mounted:j,collisionAvoidance:N,shiftCrossAxis:k=!1,nodeId:E,adaptiveOrigin:A,lazyFlip:S=!1,externalTree:M}=e,[C,I]=g.useState(null);!j&&C!==null&&I(null);const R=N.side||"flip",D=N.align||"flip",z=N.fallbackAxisSide||"end",O=typeof t=="function"?t:void 0,_=Qe(O),U=O?_:t,q=Qn(t),X=yT()==="rtl",L=C||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":X?"left":"right","inline-start":X?"right":"left"}[s],F=l==="center"?L:`${L}-${l}`;let H=h;const V=1,W=s==="bottom"?V:0,$=s==="top"?V:0,B=s==="right"?V:0,Y=s==="left"?V:0;typeof H=="number"?H={top:H+W,right:H+Y,bottom:H+$,left:H+B}:H&&(H={top:(H.top||0)+W,right:(H.right||0)+Y,bottom:(H.bottom||0)+$,left:(H.left||0)+B});const te={boundary:d==="clipping-ancestors"?"clippingAncestors":d,padding:H},ae=g.useRef(null),ee=Qn(i),ie=Qn(c),Ae=[xB(it=>{const yt=MN(it,s,X),Jt=typeof ee.current=="function"?ee.current(yt):ee.current,Pt=typeof ie.current=="function"?ie.current(yt):ie.current;return{mainAxis:Jt,crossAxis:Pt,alignmentAxis:Pt}},[typeof i!="function"?i:0,typeof c!="function"?c:0,X,s])],me=D==="none"&&R!=="shift",Pe=!me&&(m||k||R==="shift"),Re=R==="none"?null:jB({...te,padding:{top:H.top+V,right:H.right+V,bottom:H.bottom+V,left:H.left+V},mainAxis:!k&&R==="flip",crossAxis:D==="flip"?"alignment":!1,fallbackAxisSideDirection:z}),Ye=me?null:bB(it=>{const yt=Ei(it.elements.floating).documentElement;return{...te,rootBoundary:k?{x:0,y:0,width:yt.clientWidth,height:yt.clientHeight}:void 0,mainAxis:D!=="none",crossAxis:Pe,limiter:m||k?void 0:wB(Jt=>{if(!ae.current)return{};const{width:Pt,height:on}=ae.current.getBoundingClientRect(),ln=Ms(ms(Jt.placement)),_e=ln==="y"?Pt:on,jt=ln==="y"?H.left+H.right:H.top+H.bottom;return{offset:_e/2+jt/2}})}},[te,m,k,H,D]);R==="shift"||D==="shift"||l==="center"?Ae.push(Ye,Re):Ae.push(Re,Ye),Ae.push(NB({...te,apply({elements:{floating:it},rects:{reference:yt},availableWidth:Jt,availableHeight:Pt}){Object.entries({"--available-width":`${Jt}px`,"--available-height":`${Pt}px`,"--anchor-width":`${yt.width}px`,"--anchor-height":`${yt.height}px`}).forEach(([on,ln])=>{it.style.setProperty(on,ln)})}}),P9(()=>({element:ae.current||document.createElement("div"),padding:p,offsetParent:"floating"}),[p]),{name:"transformOrigin",fn(it){const{elements:yt,middlewareData:Jt,placement:Pt,rects:on,y:ln}=it,_e=ms(Pt),jt=Ms(_e),Wt=ae.current,Fa=Jt.arrow?.x||0,Ds=Jt.arrow?.y||0,Q=Wt?.clientWidth||0,ye=Wt?.clientHeight||0,Ne=Fa+Q/2,We=Ds+ye/2,Ge=Math.abs(Jt.shift?.y||0),vt=on.reference.height/2,At=typeof i=="function"?i(MN(it,s,X)):i,Qt=Ge>At,Sn={top:`${Ne}px calc(100% + ${At}px)`,bottom:`${Ne}px ${-At}px`,left:`calc(100% + ${At}px) ${We}px`,right:`${-At}px ${We}px`}[_e],kn=`${Ne}px ${on.reference.y+vt-ln}px`;return yt.floating.style.setProperty("--transform-origin",Pe&&jt==="y"&&Qt?kn:Sn),{}}},z9,A),Ke(()=>{!j&&w&&w.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[j,w]);const Ie=g.useMemo(()=>({elementResize:!y&&typeof ResizeObserver<"u",layoutShift:!y&&typeof IntersectionObserver<"u"}),[y]),{refs:oe,elements:je,x:Fe,y:le,middlewareData:ve,update:ue,placement:Ce,context:be,isPositioned:we,floatingStyles:Se}=i9({rootContext:w,placement:F,middleware:Ae,strategy:n,whileElementsMounted:x?void 0:(...it)=>bN(...it,Ie),nodeId:E,externalTree:M}),{sideX:He,sideY:et}=ve.adaptiveOrigin||L9,Be=we?n:"fixed",St=g.useMemo(()=>A?{position:Be,[He]:Fe,[et]:le}:{position:Be,...Se},[A,Be,He,Fe,et,le,Se]),Dt=g.useRef(null);Ke(()=>{if(!j)return;const it=q.current,yt=typeof it=="function"?it():it,Pt=(RN(yt)?yt.current:yt)||null||null;Pt!==Dt.current&&(oe.setPositionReference(Pt),Dt.current=Pt)},[j,oe,U,q]),g.useEffect(()=>{if(!j)return;const it=q.current;typeof it!="function"&&RN(it)&&it.current!==Dt.current&&(oe.setPositionReference(it.current),Dt.current=it.current)},[j,oe,U,q]),g.useEffect(()=>{if(x&&j&&je.domReference&&je.floating)return bN(je.domReference,je.floating,ue,Ie)},[x,j,je,ue,Ie]);const Xt=ms(Ce),Ee=xT(s,Xt,X),Oe=Ur(Ce)||"center",Te=!!ve.hide?.referenceHidden;Ke(()=>{S&&j&&we&&I(Xt)},[S,j,we,Xt]);const tt=g.useMemo(()=>({position:"absolute",top:ve.arrow?.y,left:ve.arrow?.x}),[ve.arrow]),at=ve.arrow?.centerOffset!==0;return g.useMemo(()=>({positionerStyles:St,arrowStyles:tt,arrowRef:ae,arrowUncentered:at,side:Ee,align:Oe,physicalSide:Xt,anchorHidden:Te,refs:oe,context:be,isPositioned:we,update:ue}),[St,tt,ae,at,Ee,Oe,Xt,Te,oe,be,we,ue])}function RN(e){return e!=null&&"current"in e}function U9(e){const{children:t,elementsRef:n,labelsRef:s,onMapChange:i}=e,l=Qe(i),c=g.useRef(0),d=Is(V9).current,h=Is(B9).current,[m,p]=g.useState(0),y=g.useRef(m),x=Qe((E,A)=>{h.set(E,A??null),y.current+=1,p(y.current)}),w=Qe(E=>{h.delete(E),y.current+=1,p(y.current)}),j=g.useMemo(()=>{const E=new Map;return Array.from(h.keys()).filter(S=>S.isConnected).sort(F9).forEach((S,M)=>{const C=h.get(S)??{};E.set(S,{...C,index:M})}),E},[h,m]);Ke(()=>{if(typeof MutationObserver!="function"||j.size===0)return;const E=new MutationObserver(A=>{const S=new Set,M=C=>S.has(C)?S.delete(C):S.add(C);A.forEach(C=>{C.removedNodes.forEach(M),C.addedNodes.forEach(M)}),S.size===0&&(y.current+=1,p(y.current))});return j.forEach((A,S)=>{S.parentElement&&E.observe(S.parentElement,{childList:!0})}),()=>{E.disconnect()}},[j]),Ke(()=>{y.current===m&&(n.current.length!==j.size&&(n.current.length=j.size),s&&s.current.length!==j.size&&(s.current.length=j.size),c.current=j.size),l(j)},[l,j,n,s,m]),Ke(()=>()=>{n.current=[]},[n]),Ke(()=>()=>{s&&(s.current=[])},[s]);const N=Qe(E=>(d.add(E),()=>{d.delete(E)}));Ke(()=>{d.forEach(E=>E(j))},[d,j]);const k=g.useMemo(()=>({register:x,unregister:w,subscribeMapChange:N,elementsRef:n,labelsRef:s,nextIndexRef:c}),[x,w,N,n,s,c]);return r.jsx(jA.Provider,{value:k,children:t})}function B9(){return new Map}function V9(){return new Set}function F9(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 H9=g.forwardRef(function(t,n){const{cutout:s,...i}=t;let l;if(s){const c=s?.getBoundingClientRect();l=`polygon(
|
|
112
|
-
0% 0%,
|
|
113
|
-
100% 0%,
|
|
114
|
-
100% 100%,
|
|
115
|
-
0% 100%,
|
|
116
|
-
0% 0%,
|
|
117
|
-
${c.left}px ${c.top}px,
|
|
118
|
-
${c.left}px ${c.bottom}px,
|
|
119
|
-
${c.right}px ${c.bottom}px,
|
|
120
|
-
${c.right}px ${c.top}px,
|
|
121
|
-
${c.left}px ${c.top}px
|
|
122
|
-
)`}return r.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...i,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:l}})}),q9=g.forwardRef(function(t,n){const{anchor:s,positionMethod:i="absolute",className:l,render:c,side:d,align:h,sideOffset:m=0,alignOffset:p=0,collisionBoundary:y="clipping-ancestors",collisionPadding:x=5,arrowPadding:w=5,sticky:j=!1,disableAnchorTracking:N=!1,collisionAvoidance:k=B6,...E}=t,{store:A}=ll(),S=R9(),M=hh(!0),C=A.useState("parent"),I=A.useState("floatingRootContext"),R=A.useState("floatingTreeRoot"),D=A.useState("mounted"),z=A.useState("open"),O=A.useState("modal"),_=A.useState("activeTriggerElement"),U=A.useState("lastOpenChangeReason"),q=A.useState("floatingNodeId"),G=A.useState("floatingParentNodeId");let X=s,L=m,F=p,H=h;C.type==="context-menu"&&(X=s??C.context?.anchor,H=H??"start",!d&&H!=="center"&&(F=t.alignOffset??2,L=t.sideOffset??-5));let V=d,W=H;C.type==="menu"?(V=V??"inline-end",W=W??"start"):C.type==="menubar"&&(V=V??"bottom",W=W??"start");const $=C.type==="context-menu",B=$9({anchor:X,floatingRootContext:I,positionMethod:M?"fixed":i,mounted:D,side:V,sideOffset:L,align:W,alignOffset:F,arrowPadding:$?0:w,collisionBoundary:y,collisionPadding:x,sticky:j,nodeId:q,keepMounted:S,disableAnchorTracking:N,collisionAvoidance:k,shiftCrossAxis:$,externalTree:R}),Y=g.useMemo(()=>{const xe={};return z||(xe.pointerEvents="none"),{role:"presentation",hidden:!D,style:{...B.positionerStyles,...xe}}},[z,D,B.positionerStyles]);g.useEffect(()=>{function xe(Ae){Ae.open?(Ae.parentNodeId===q&&A.set("hoverEnabled",!1),Ae.nodeId!==q&&Ae.parentNodeId===A.select("floatingParentNodeId")&&A.setOpen(!1,yn(vc))):Ae.parentNodeId===q&&Ae.reason!==vc&&A.set("hoverEnabled",!0)}return R.events.on("menuopenchange",xe),()=>{R.events.off("menuopenchange",xe)}},[A,R.events,q]),g.useEffect(()=>{if(A.select("floatingParentNodeId")==null)return;function xe(Ae){if(Ae.open||Ae.nodeId!==A.select("floatingParentNodeId"))return;const me=Ae.reason??vc;A.setOpen(!1,yn(me))}return R.events.on("menuopenchange",xe),()=>{R.events.off("menuopenchange",xe)}},[R.events,A]),g.useEffect(()=>{function xe(Ae){!z||Ae.nodeId!==A.select("floatingParentNodeId")||Ae.target&&_&&_!==Ae.target&&A.setOpen(!1,yn(vc))}return R.events.on("itemhover",xe),()=>{R.events.off("itemhover",xe)}},[R.events,z,_,A]),g.useEffect(()=>{const xe={open:z,nodeId:q,parentNodeId:G,reason:A.select("lastOpenChangeReason")};R.events.emit("menuopenchange",xe)},[R.events,z,A,q,G]);const te=g.useMemo(()=>({open:z,side:B.side,align:B.align,anchorHidden:B.anchorHidden,nested:C.type==="menu"}),[z,B.side,B.align,B.anchorHidden,C.type]),ae=g.useMemo(()=>({side:B.side,align:B.align,arrowRef:B.arrowRef,arrowUncentered:B.arrowUncentered,arrowStyles:B.arrowStyles,nodeId:B.context.nodeId}),[B.side,B.align,B.arrowRef,B.arrowUncentered,B.arrowStyles,B.context.nodeId]),ee=Lr("div",t,{state:te,stateAttributesMapping:yA,ref:[n,A.useStateSetter("positionerElement")],props:[Y,E]}),ie=D&&C.type!=="menu"&&(C.type!=="menubar"&&O&&U!==xi||C.type==="menubar"&&C.context.modal);let de=null;return C.type==="menubar"?de=C.context.contentElement:C.type===void 0&&(de=_),r.jsxs(uA.Provider,{value:ae,children:[ie&&r.jsx(H9,{ref:C.type==="context-menu"||C.type==="nested-context-menu"?C.context.internalBackdropRef:null,inert:I9(!z),cutout:de}),r.jsx(kU,{id:q,children:r.jsx(U9,{elementsRef:A.context.itemDomElements,labelsRef:A.context.itemLabels,children:ee})})]})});let _N={},IN={},ON="";function Z9(e){if(typeof document>"u")return!1;const t=Ei(e);return In(t).innerWidth-t.documentElement.clientWidth>0}function W9(e){const t=Ei(e),n=t.documentElement,s=t.body,i=Mi(n)?n:s,l=i.style.overflow;return i.style.overflow="hidden",()=>{i.style.overflow=l}}function Y9(e){const t=Ei(e),n=t.documentElement,s=t.body,i=In(n);let l=0,c=0;const d=oa.create(),h=typeof CSS<"u"&&CSS.supports?.("scrollbar-gutter","stable");if(D8&&(i.visualViewport?.scale??1)!==1)return()=>{};function m(){const x=i.getComputedStyle(n),w=i.getComputedStyle(s),k=(x.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";l=n.scrollTop,c=n.scrollLeft,_N={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},ON=n.style.scrollBehavior,IN={position:s.style.position,height:s.style.height,width:s.style.width,boxSizing:s.style.boxSizing,overflowY:s.style.overflowY,overflowX:s.style.overflowX,scrollBehavior:s.style.scrollBehavior};const E=n.scrollHeight>n.clientHeight,A=n.scrollWidth>n.clientWidth,S=x.overflowY==="scroll"||w.overflowY==="scroll",M=x.overflowX==="scroll"||w.overflowX==="scroll",C=Math.max(0,i.innerWidth-n.clientWidth),I=Math.max(0,i.innerHeight-n.clientHeight),R=parseFloat(w.marginTop)+parseFloat(w.marginBottom),D=parseFloat(w.marginLeft)+parseFloat(w.marginRight),z=Mi(n)?n:s;if(h){n.style.scrollbarGutter=k,z.style.overflowY="hidden",z.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:k,overflowY:"hidden",overflowX:"hidden"}),(E||S)&&(n.style.overflowY="scroll"),(A||M)&&(n.style.overflowX="scroll"),Object.assign(s.style,{position:"relative",height:R||I?`calc(100dvh - ${R+I}px)`:"100dvh",width:D||C?`calc(100vw - ${D+C}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),s.scrollTop=l,s.scrollLeft=c,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function p(){Object.assign(n.style,_N),Object.assign(s.style,IN),h||(n.scrollTop=l,n.scrollLeft=c,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=ON)}function y(){p(),d.request(m)}return m(),i.addEventListener("resize",y),()=>{d.cancel(),p(),typeof i.removeEventListener=="function"&&i.removeEventListener("resize",y)}}class G9{lockCount=0;restore=null;timeoutLock=nl.create();timeoutUnlock=nl.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 s=Ei(t).documentElement,i=In(s).getComputedStyle(s).overflowY;if(i==="hidden"||i==="clip"){this.restore=gA;return}const l=P8||!Z9(t);this.restore=l?W9(t):Y9(t)}}const K9=new G9;function X9(e=!0,t=null){Ke(()=>{if(e)return K9.acquire(t)},[e,t])}const J9=g.createContext(null);function Q9(e){return g.useContext(J9)}function eV(e){const t=g.useRef(""),n=g.useCallback(i=>{i.defaultPrevented||(t.current=i.pointerType,e(i,i.pointerType))},[e]);return{onClick:g.useCallback(i=>{if(i.detail===0){e(i,"keyboard");return}"pointerType"in i&&e(i,i.pointerType),e(i,t.current),t.current=""},[e]),onPointerDown:n}}function tV(e){const[t,n]=g.useState(null),s=Qe((d,h)=>{e||n(h)}),i=g.useCallback(()=>{n(null)},[]),{onClick:l,onPointerDown:c}=eV(s);return g.useMemo(()=>({openMethod:t,reset:i,triggerProps:{onClick:l,onPointerDown:c}}),[t,i,l,c])}const nV={...a9,disabled:ot(e=>e.parent.type==="menubar"&&e.parent.context.disabled||e.disabled),modal:ot(e=>(e.parent.type===void 0||e.parent.type==="context-menu")&&(e.modal??!0)),allowMouseEnter:ot(e=>e.parent.type==="menu"?e.parent.store.select("allowMouseEnter"):e.allowMouseEnter),stickIfOpen:ot(e=>e.stickIfOpen),parent:ot(e=>e.parent),rootId:ot(e=>e.parent.type==="menu"?e.parent.store.select("rootId"):e.parent.type!==void 0?e.parent.context.rootId:e.rootId),activeIndex:ot(e=>e.activeIndex),isActive:ot((e,t)=>e.activeIndex===t),hoverEnabled:ot(e=>e.hoverEnabled),instantType:ot(e=>e.instantType),lastOpenChangeReason:ot(e=>e.openChangeReason),floatingTreeRoot:ot(e=>e.parent.type==="menu"?e.parent.store.select("floatingTreeRoot"):e.floatingTreeRoot),floatingNodeId:ot(e=>e.floatingNodeId),floatingParentNodeId:ot(e=>e.floatingParentNodeId),itemProps:ot(e=>e.itemProps),closeDelay:ot(e=>e.closeDelay),keyboardEventRelay:ot(e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type==="menu")return e.parent.store.select("keyboardEventRelay")})};class Xy extends uT{constructor(t){super({...sV(),...t},{positionerRef:g.createRef(),popupRef:g.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:g.createRef(),beforeContentFocusGuardRef:g.createRef(),onOpenChangeComplete:void 0,triggerElements:new Ky},nV),this.observe(ot(n=>n.allowMouseEnter),(n,s)=>{this.state.parent.type==="menu"&&n!==s&&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 Is(()=>t??new Xy(n)).current}unsubscribeParentListener=null}function sV(){return{...s9(),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 ZA,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:ts,keyboardEventRelay:void 0,closeDelay:0}}const aV=g.createContext(void 0);function rV(){return g.useContext(aV)}function iV(e){const{children:t,open:n,onOpenChange:s,onOpenChangeComplete:i,defaultOpen:l=!1,disabled:c=!1,modal:d,loopFocus:h=!0,orientation:m="vertical",actionsRef:p,closeParentOnEsc:y=!0,handle:x,triggerId:w,defaultTriggerId:j=null,highlightItemOnHover:N=!0}=e,k=hh(!0),E=ll(!0),A=Q9(),S=rV(),M=g.useMemo(()=>S&&E?{type:"menu",store:E.store}:A?{type:"menubar",context:A}:k&&!E?{type:"context-menu",context:k}:{type:void 0},[k,E,A,S]),C=Xy.useStore(x?.store,{parent:M}),I=C.useState("floatingTreeRoot"),R=SU(I),D=Br();Ke(()=>{k&&!E?C.update({parent:{type:"context-menu",context:k},floatingNodeId:R,floatingParentNodeId:D}):E&&C.update({floatingNodeId:R,floatingParentNodeId:D})},[k,E,R,D,C]),C.useControlledProp("open",n,l),C.useControlledProp("activeTriggerId",w,j),C.useContextCallback("onOpenChangeComplete",i);const z=C.useState("open"),O=C.useState("activeTriggerElement"),_=C.useState("positionerElement"),U=C.useState("hoverEnabled"),q=C.useState("modal"),G=C.useState("disabled"),X=C.useState("lastOpenChangeReason"),L=C.useState("parent"),F=C.useState("activeIndex"),H=C.useState("payload"),V=C.useState("floatingParentNodeId"),W=g.useRef(null),$=V!=null;let B;C.useSyncedValues({disabled:c,modal:L.type===void 0?d:void 0,rootId:zr()});const{openMethod:Y,triggerProps:te,reset:ae}=tV(z);e9(C);const{forceUnmount:ee}=t9(z,C,()=>{C.update({allowMouseEnter:!1,stickIfOpen:!0}),ae()}),ie=g.useRef(L.type!=="context-menu"),de=Ys();g.useEffect(()=>{if(z||(W.current=null),L.type==="context-menu"){if(!z){de.clear(),ie.current=!1;return}de.start(500,()=>{ie.current=!0})}},[de,z,L.type]),X9(z&&q&&X!==xi&&Y!=="touch",_),Ke(()=>{!z&&!U&&C.set("hoverEnabled",!0)},[z,U,C]);const xe=g.useRef(!0),Ae=Ys(),me=Qe((Te,tt)=>{const at=tt.reason;if(z===Te&&tt.trigger===O||(tt.preventUnmountOnClose=()=>{C.set("preventUnmountingOnClose",!0)},!Te&&tt.trigger==null&&(tt.trigger=O??void 0),s?.(Te,tt),tt.isCanceled))return;const it={open:Te,nativeEvent:tt.event,reason:tt.reason,nested:$};B?.emit("openchange",it);const yt=tt.event;if(Te===!1&&yt?.type==="click"&&yt.pointerType==="touch"&&!xe.current)return;if(!Te&&F!==null){const ln=C.context.itemDomElements.current[F];queueMicrotask(()=>{ln?.setAttribute("tabindex","-1")})}Te&&at===sN?(xe.current=!1,Ae.start(300,()=>{xe.current=!0})):(xe.current=!0,Ae.clear());const Jt=(at===Mf||at===xA)&&yt.detail===0&&yt?.isTrusted,Pt=!Te&&(at===bA||at==null);function on(){const ln={open:Te,openChangeReason:at};W.current=tt.event??null;const _e=tt.trigger?.id??null;(_e||Te)&&(ln.activeTriggerId=_e,ln.activeTriggerElement=tt.trigger??null),C.update(ln)}at===xi?ki.flushSync(on):on(),L.type==="menubar"&&(at===sN||at===ph||at===xi||at===rf||at===vc)?C.set("instantType","group"):Jt||Pt?C.set("instantType",Jt?"click":"dismiss"):C.set("instantType",void 0)}),Pe=g.useCallback(Te=>{const tt=yn(Te);return tt.preventUnmountOnClose=()=>{C.set("preventUnmountingOnClose",!0)},tt},[C]),Re=g.useCallback(()=>{C.setOpen(!1,Pe(n8))},[C,Pe]);g.useImperativeHandle(p,()=>({unmount:ee,close:Re}),[ee,Re]);let Ye;L.type==="context-menu"&&(Ye=L.context),g.useImperativeHandle(Ye?.positionerRef,()=>_,[_]),g.useImperativeHandle(Ye?.actionsRef,()=>({setOpen:me}),[me]);const Ie=o9({popupStore:C,onOpenChange:me});B=Ie.context.events,g.useEffect(()=>{const Te=({open:tt,eventDetails:at})=>me(tt,at);return B.on("setOpen",Te),()=>{B?.off("setOpen",Te)}},[B,me]);const oe=CB(Ie,{enabled:!G,bubbles:y&&L.type==="menu",outsidePress(){return L.type!=="context-menu"||W.current?.type==="contextmenu"?!0:ie.current},externalTree:$?I:void 0}),je=b9(Ie,{role:"menu"}),Fe=yT(),le=g.useCallback(Te=>{C.select("activeIndex")!==Te&&C.set("activeIndex",Te)},[C]),ve=y9(Ie,{enabled:!G,listRef:C.context.itemDomElements,activeIndex:F,nested:L.type!==void 0,loopFocus:h,orientation:m,parentOrientation:L.type==="menubar"?L.context.orientation:void 0,rtl:Fe==="rtl",disabledIndices:vA,onNavigate:le,openOnArrowKeyDown:L.type!=="context-menu",externalTree:$?I:void 0,focusItemOnHover:N}),ue=g.useCallback(Te=>{C.context.typingRef.current=Te},[C]),Ce=w9(Ie,{listRef:C.context.itemLabels,activeIndex:F,resetMs:L6,onMatch:Te=>{z&&Te!==F&&C.set("activeIndex",Te)},onTypingChange:ue}),{getReferenceProps:be,getFloatingProps:we,getItemProps:Se,getTriggerProps:He}=m9([oe,je,ve,Ce]),et=g.useMemo(()=>{const Te=mh(be(),{onMouseEnter(){C.set("hoverEnabled",!0)},onMouseMove(){C.set("allowMouseEnter",!0)}},te);return delete Te.role,Te},[be,C,te]),Be=g.useMemo(()=>{const Te=He();if(!Te)return Te;const{role:tt,["aria-controls"]:at,...it}=Te;return it},[He]),St=Vy(),Dt=g.useMemo(()=>we({onMouseEnter(){L.type==="menu"&&St.request(()=>C.set("hoverEnabled",!1))},onMouseMove(){C.set("allowMouseEnter",!0)},onClick(){C.select("hoverEnabled")&&C.set("hoverEnabled",!1)},onKeyDown(Te){const tt=C.select("keyboardEventRelay");tt&&!Te.isPropagationStopped()&&tt(Te)}}),[we,L.type,St,C]),Xt=g.useMemo(()=>Se(),[Se]);C.useSyncedValues({floatingRootContext:Ie,activeTriggerProps:et,inactiveTriggerProps:Be,popupProps:Dt,itemProps:Xt});const Ee=g.useMemo(()=>({store:C,parent:M}),[C,M]),Oe=r.jsx(Py.Provider,{value:Ee,children:typeof t=="function"?t({payload:H}):t});return L.type===void 0||L.type==="context-menu"?r.jsx(EU,{externalTree:I,children:Oe}):Oe}function bT(e){if(dn(e)&&e.hasAttribute("data-rootownerid"))return e.getAttribute("data-rootownerid")??void 0;if(!ca(e))return bT(ha(e))}const oV=g.forwardRef(function(t,n){const{className:s,render:i,orientation:l="horizontal",...c}=t,d=g.useMemo(()=>({orientation:l}),[l]);return Lr("div",t,{state:d,ref:n,props:[{role:"separator","aria-orientation":l},c]})});function lV(e){const[t,n]=g.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),s=g.useRef(null),i=g.useRef(null),l=g.useRef(null),c=g.useRef(null),d=g.useRef(!0),h=g.useRef(null),m=zr(),p=g.useMemo(()=>({anchor:t,setAnchor:n,actionsRef:l,backdropRef:s,internalBackdropRef:i,positionerRef:c,allowMouseUpTriggerRef:d,initialCursorPointRef:h,rootId:m}),[t,m]);return r.jsx(cA.Provider,{value:p,children:r.jsx(Py.Provider,{value:void 0,children:r.jsx(iV,{...e})})})}const DN=500,cV=g.forwardRef(function(t,n){const{render:s,className:i,...l}=t,{setAnchor:c,actionsRef:d,internalBackdropRef:h,backdropRef:m,positionerRef:p,allowMouseUpTriggerRef:y,initialCursorPointRef:x,rootId:w}=hh(!1),{store:j}=ll(!1),N=j.useState("open"),k=g.useRef(null),E=g.useRef(null),A=Ys(),S=Ys(),M=g.useRef(!1);function C(U,q,G){const X=G.type.startsWith("touch");x.current={x:U,y:q},c({getBoundingClientRect(){return DOMRect.fromRect({width:X?10:0,height:X?10:0,x:U,y:q})}}),M.current=!1,d.current?.setOpen(!0,yn(Mf,G)),S.start(DN,()=>{M.current=!0})}function I(U){y.current=!0,_n(U),C(U.clientX,U.clientY,U.nativeEvent),Ei(k.current).addEventListener("mouseup",G=>{if(y.current=!1,!M.current)return;S.clear(),M.current=!1;const X=es(G);Ft(p.current,X)||w&&X&&bT(X)===w||d.current?.setOpen(!1,yn(t8,G))},{once:!0})}function R(U){if(y.current=!1,U.touches.length===1){U.stopPropagation();const q=U.touches[0];E.current={x:q.clientX,y:q.clientY},A.start(DN,()=>{E.current&&C(E.current.x,E.current.y,U.nativeEvent)})}}function D(U){if(A.isStarted()&&E.current&&U.touches.length===1){const q=U.touches[0],G=10,X=Math.abs(q.clientX-E.current.x),L=Math.abs(q.clientY-E.current.y);(X>G||L>G)&&A.clear()}}function z(){A.clear(),E.current=null}g.useEffect(()=>{function U(G){const L=es(G);(Ft(k.current,L)||Ft(h.current,L)||Ft(m.current,L))&&G.preventDefault()}const q=Ei(k.current);return q.addEventListener("contextmenu",U),()=>{q.removeEventListener("contextmenu",U)}},[m,h]);const O=g.useMemo(()=>({open:N}),[N]);return Lr("div",t,{state:O,ref:[k,n],props:[{onContextMenu:I,onTouchStart:R,onTouchMove:D,onTouchEnd:z,onTouchCancel:z,style:{WebkitTouchCallout:"none"}},l],stateAttributesMapping:Q6})}),Jy=g.createContext({});function Qy(e){const t=g.useRef(null);return t.current===null&&(t.current=e()),t.current}const wT=typeof window<"u",jT=wT?g.useLayoutEffect:g.useEffect,Nh=g.createContext(null);function ex(e,t){e.indexOf(t)===-1&&e.push(t)}function Vf(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const ma=(e,t,n)=>n>t?t:n<e?e:n;let tx=()=>{};const Va={},NT=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function ST(e){return typeof e=="object"&&e!==null}const kT=e=>/^0[^.\s]+$/u.test(e);function ET(e){let t;return()=>(t===void 0&&(t=e()),t)}const _s=e=>e,uV=(e,t)=>n=>t(e(n)),tu=(...e)=>e.reduce(uV),Uc=(e,t,n)=>{const s=t-e;return s===0?1:(n-e)/s};class nx{constructor(){this.subscriptions=[]}add(t){return ex(this.subscriptions,t),()=>Vf(this.subscriptions,t)}notify(t,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](t,n,s);else for(let l=0;l<i;l++){const c=this.subscriptions[l];c&&c(t,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Zs=e=>e*1e3,Rs=e=>e/1e3;function CT(e,t){return t?e*(1e3/t):0}const AT=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,dV=1e-7,fV=12;function hV(e,t,n,s,i){let l,c,d=0;do c=t+(n-t)/2,l=AT(c,s,i)-e,l>0?n=c:t=c;while(Math.abs(l)>dV&&++d<fV);return c}function nu(e,t,n,s){if(e===t&&n===s)return _s;const i=l=>hV(l,0,1,e,n);return l=>l===0||l===1?l:AT(i(l),t,s)}const TT=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,MT=e=>t=>1-e(1-t),RT=nu(.33,1.53,.69,.99),sx=MT(RT),_T=TT(sx),IT=e=>(e*=2)<1?.5*sx(e):.5*(2-Math.pow(2,-10*(e-1))),ax=e=>1-Math.sin(Math.acos(e)),OT=MT(ax),DT=TT(ax),mV=nu(.42,0,1,1),pV=nu(0,0,.58,1),PT=nu(.42,0,.58,1),gV=e=>Array.isArray(e)&&typeof e[0]!="number",zT=e=>Array.isArray(e)&&typeof e[0]=="number",vV={linear:_s,easeIn:mV,easeInOut:PT,easeOut:pV,circIn:ax,circInOut:DT,circOut:OT,backIn:sx,backInOut:_T,backOut:RT,anticipate:IT},yV=e=>typeof e=="string",PN=e=>{if(zT(e)){tx(e.length===4);const[t,n,s,i]=e;return nu(t,n,s,i)}else if(yV(e))return vV[e];return e},Od=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function xV(e,t){let n=new Set,s=new Set,i=!1,l=!1;const c=new WeakSet;let d={delta:0,timestamp:0,isProcessing:!1};function h(p){c.has(p)&&(m.schedule(p),e()),p(d)}const m={schedule:(p,y=!1,x=!1)=>{const j=x&&i?n:s;return y&&c.add(p),j.has(p)||j.add(p),p},cancel:p=>{s.delete(p),c.delete(p)},process:p=>{if(d=p,i){l=!0;return}i=!0,[n,s]=[s,n],n.forEach(h),n.clear(),i=!1,l&&(l=!1,m.process(p))}};return m}const bV=40;function LT(e,t){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},l=()=>n=!0,c=Od.reduce((S,M)=>(S[M]=xV(l),S),{}),{setup:d,read:h,resolveKeyframes:m,preUpdate:p,update:y,preRender:x,render:w,postRender:j}=c,N=()=>{const S=Va.useManualTiming?i.timestamp:performance.now();n=!1,Va.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(S-i.timestamp,bV),1)),i.timestamp=S,i.isProcessing=!0,d.process(i),h.process(i),m.process(i),p.process(i),y.process(i),x.process(i),w.process(i),j.process(i),i.isProcessing=!1,n&&t&&(s=!1,e(N))},k=()=>{n=!0,s=!0,i.isProcessing||e(N)};return{schedule:Od.reduce((S,M)=>{const C=c[M];return S[M]=(I,R=!1,D=!1)=>(n||k(),C.schedule(I,R,D)),S},{}),cancel:S=>{for(let M=0;M<Od.length;M++)c[Od[M]].cancel(S)},state:i,steps:c}}const{schedule:zt,cancel:Rr,state:Mn,steps:mg}=LT(typeof requestAnimationFrame<"u"?requestAnimationFrame:_s,!0);let cf;function wV(){cf=void 0}const Bn={now:()=>(cf===void 0&&Bn.set(Mn.isProcessing||Va.useManualTiming?Mn.timestamp:performance.now()),cf),set:e=>{cf=e,queueMicrotask(wV)}},$T=e=>t=>typeof t=="string"&&t.startsWith(e),UT=$T("--"),jV=$T("var(--"),rx=e=>jV(e)?NV.test(e.split("/*")[0].trim()):!1,NV=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function zN(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const dl={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Bc={...dl,transform:e=>ma(0,1,e)},Dd={...dl,default:1},Cc=e=>Math.round(e*1e5)/1e5,ix=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function SV(e){return e==null}const kV=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,ox=(e,t)=>n=>!!(typeof n=="string"&&kV.test(n)&&n.startsWith(e)||t&&!SV(n)&&Object.prototype.hasOwnProperty.call(n,t)),BT=(e,t,n)=>s=>{if(typeof s!="string")return s;const[i,l,c,d]=s.match(ix);return{[e]:parseFloat(i),[t]:parseFloat(l),[n]:parseFloat(c),alpha:d!==void 0?parseFloat(d):1}},EV=e=>ma(0,255,e),pg={...dl,transform:e=>Math.round(EV(e))},gi={test:ox("rgb","red"),parse:BT("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+pg.transform(e)+", "+pg.transform(t)+", "+pg.transform(n)+", "+Cc(Bc.transform(s))+")"};function CV(e){let t="",n="",s="",i="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),s=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),s=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,s+=s,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:i?parseInt(i,16)/255:1}}const Av={test:ox("#"),parse:CV,transform:gi.transform},su=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),vr=su("deg"),da=su("%"),Le=su("px"),AV=su("vh"),TV=su("vw"),LN={...da,parse:e=>da.parse(e)/100,transform:e=>da.transform(e*100)},Bo={test:ox("hsl","hue"),parse:BT("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+da.transform(Cc(t))+", "+da.transform(Cc(n))+", "+Cc(Bc.transform(s))+")"},vn={test:e=>gi.test(e)||Av.test(e)||Bo.test(e),parse:e=>gi.test(e)?gi.parse(e):Bo.test(e)?Bo.parse(e):Av.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?gi.transform(e):Bo.transform(e),getAnimatableNone:e=>{const t=vn.parse(e);return t.alpha=0,vn.transform(t)}},MV=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function RV(e){return isNaN(e)&&typeof e=="string"&&(e.match(ix)?.length||0)+(e.match(MV)?.length||0)>0}const VT="number",FT="color",_V="var",IV="var(",$N="${}",OV=/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 Vc(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},i=[];let l=0;const d=t.replace(OV,h=>(vn.test(h)?(s.color.push(l),i.push(FT),n.push(vn.parse(h))):h.startsWith(IV)?(s.var.push(l),i.push(_V),n.push(h)):(s.number.push(l),i.push(VT),n.push(parseFloat(h))),++l,$N)).split($N);return{values:n,split:d,indexes:s,types:i}}function HT(e){return Vc(e).values}function qT(e){const{split:t,types:n}=Vc(e),s=t.length;return i=>{let l="";for(let c=0;c<s;c++)if(l+=t[c],i[c]!==void 0){const d=n[c];d===VT?l+=Cc(i[c]):d===FT?l+=vn.transform(i[c]):l+=i[c]}return l}}const DV=e=>typeof e=="number"?0:vn.test(e)?vn.getAnimatableNone(e):e;function PV(e){const t=HT(e);return qT(e)(t.map(DV))}const Ws={test:RV,parse:HT,createTransformer:qT,getAnimatableNone:PV};function gg(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 zV({hue:e,saturation:t,lightness:n,alpha:s}){e/=360,t/=100,n/=100;let i=0,l=0,c=0;if(!t)i=l=c=n;else{const d=n<.5?n*(1+t):n+t-n*t,h=2*n-d;i=gg(h,d,e+1/3),l=gg(h,d,e),c=gg(h,d,e-1/3)}return{red:Math.round(i*255),green:Math.round(l*255),blue:Math.round(c*255),alpha:s}}function Ff(e,t){return n=>n>0?t:e}const en=(e,t,n)=>e+(t-e)*n,vg=(e,t,n)=>{const s=e*e,i=n*(t*t-s)+s;return i<0?0:Math.sqrt(i)},LV=[Av,gi,Bo],$V=e=>LV.find(t=>t.test(e));function UN(e){const t=$V(e);if(!t)return!1;let n=t.parse(e);return t===Bo&&(n=zV(n)),n}const BN=(e,t)=>{const n=UN(e),s=UN(t);if(!n||!s)return Ff(e,t);const i={...n};return l=>(i.red=vg(n.red,s.red,l),i.green=vg(n.green,s.green,l),i.blue=vg(n.blue,s.blue,l),i.alpha=en(n.alpha,s.alpha,l),gi.transform(i))},Tv=new Set(["none","hidden"]);function UV(e,t){return Tv.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function BV(e,t){return n=>en(e,t,n)}function lx(e){return typeof e=="number"?BV:typeof e=="string"?rx(e)?Ff:vn.test(e)?BN:HV:Array.isArray(e)?ZT:typeof e=="object"?vn.test(e)?BN:VV:Ff}function ZT(e,t){const n=[...e],s=n.length,i=e.map((l,c)=>lx(l)(l,t[c]));return l=>{for(let c=0;c<s;c++)n[c]=i[c](l);return n}}function VV(e,t){const n={...e,...t},s={};for(const i in n)e[i]!==void 0&&t[i]!==void 0&&(s[i]=lx(e[i])(e[i],t[i]));return i=>{for(const l in s)n[l]=s[l](i);return n}}function FV(e,t){const n=[],s={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){const l=t.types[i],c=e.indexes[l][s[l]],d=e.values[c]??0;n[i]=d,s[l]++}return n}const HV=(e,t)=>{const n=Ws.createTransformer(t),s=Vc(e),i=Vc(t);return s.indexes.var.length===i.indexes.var.length&&s.indexes.color.length===i.indexes.color.length&&s.indexes.number.length>=i.indexes.number.length?Tv.has(e)&&!i.values.length||Tv.has(t)&&!s.values.length?UV(e,t):tu(ZT(FV(s,i),i.values),n):Ff(e,t)};function WT(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?en(e,t,n):lx(e)(e,t)}const qV=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>zt.update(t,n),stop:()=>Rr(t),now:()=>Mn.isProcessing?Mn.timestamp:Bn.now()}},YT=(e,t,n=10)=>{let s="";const i=Math.max(Math.round(t/n),2);for(let l=0;l<i;l++)s+=Math.round(e(l/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},Hf=2e4;function cx(e){let t=0;const n=50;let s=e.next(t);for(;!s.done&&t<Hf;)t+=n,s=e.next(t);return t>=Hf?1/0:t}function ZV(e,t=100,n){const s=n({...e,keyframes:[0,t]}),i=Math.min(cx(s),Hf);return{type:"keyframes",ease:l=>s.next(i*l).value/t,duration:Rs(i)}}const WV=5;function GT(e,t,n){const s=Math.max(t-WV,0);return CT(n-e(s),t-s)}const rn={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},yg=.001;function YV({duration:e=rn.duration,bounce:t=rn.bounce,velocity:n=rn.velocity,mass:s=rn.mass}){let i,l,c=1-t;c=ma(rn.minDamping,rn.maxDamping,c),e=ma(rn.minDuration,rn.maxDuration,Rs(e)),c<1?(i=m=>{const p=m*c,y=p*e,x=p-n,w=Mv(m,c),j=Math.exp(-y);return yg-x/w*j},l=m=>{const y=m*c*e,x=y*n+n,w=Math.pow(c,2)*Math.pow(m,2)*e,j=Math.exp(-y),N=Mv(Math.pow(m,2),c);return(-i(m)+yg>0?-1:1)*((x-w)*j)/N}):(i=m=>{const p=Math.exp(-m*e),y=(m-n)*e+1;return-yg+p*y},l=m=>{const p=Math.exp(-m*e),y=(n-m)*(e*e);return p*y});const d=5/e,h=KV(i,l,d);if(e=Zs(e),isNaN(h))return{stiffness:rn.stiffness,damping:rn.damping,duration:e};{const m=Math.pow(h,2)*s;return{stiffness:m,damping:c*2*Math.sqrt(s*m),duration:e}}}const GV=12;function KV(e,t,n){let s=n;for(let i=1;i<GV;i++)s=s-e(s)/t(s);return s}function Mv(e,t){return e*Math.sqrt(1-t*t)}const XV=["duration","bounce"],JV=["stiffness","damping","mass"];function VN(e,t){return t.some(n=>e[n]!==void 0)}function QV(e){let t={velocity:rn.velocity,stiffness:rn.stiffness,damping:rn.damping,mass:rn.mass,isResolvedFromDuration:!1,...e};if(!VN(e,JV)&&VN(e,XV))if(t.velocity=0,e.visualDuration){const n=e.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,l=2*ma(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:rn.mass,stiffness:i,damping:l}}else{const n=YV({...e,velocity:0});t={...t,...n,mass:rn.mass},t.isResolvedFromDuration=!0}return t}function qf(e=rn.visualDuration,t=rn.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:s,restDelta:i}=n;const l=n.keyframes[0],c=n.keyframes[n.keyframes.length-1],d={done:!1,value:l},{stiffness:h,damping:m,mass:p,duration:y,velocity:x,isResolvedFromDuration:w}=QV({...n,velocity:-Rs(n.velocity||0)}),j=x||0,N=m/(2*Math.sqrt(h*p)),k=c-l,E=Rs(Math.sqrt(h/p)),A=Math.abs(k)<5;s||(s=A?rn.restSpeed.granular:rn.restSpeed.default),i||(i=A?rn.restDelta.granular:rn.restDelta.default);let S;if(N<1){const C=Mv(E,N);S=I=>{const R=Math.exp(-N*E*I);return c-R*((j+N*E*k)/C*Math.sin(C*I)+k*Math.cos(C*I))}}else if(N===1)S=C=>c-Math.exp(-E*C)*(k+(j+E*k)*C);else{const C=E*Math.sqrt(N*N-1);S=I=>{const R=Math.exp(-N*E*I),D=Math.min(C*I,300);return c-R*((j+N*E*k)*Math.sinh(D)+C*k*Math.cosh(D))/C}}const M={calculatedDuration:w&&y||null,next:C=>{const I=S(C);if(w)d.done=C>=y;else{let R=C===0?j:0;N<1&&(R=C===0?Zs(j):GT(S,C,I));const D=Math.abs(R)<=s,z=Math.abs(c-I)<=i;d.done=D&&z}return d.value=d.done?c:I,d},toString:()=>{const C=Math.min(cx(M),Hf),I=YT(R=>M.next(C*R).value,C,30);return C+"ms "+I},toTransition:()=>{}};return M}qf.applyToOptions=e=>{const t=ZV(e,100,qf);return e.ease=t.ease,e.duration=Zs(t.duration),e.type="keyframes",e};function Rv({keyframes:e,velocity:t=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:l=500,modifyTarget:c,min:d,max:h,restDelta:m=.5,restSpeed:p}){const y=e[0],x={done:!1,value:y},w=D=>d!==void 0&&D<d||h!==void 0&&D>h,j=D=>d===void 0?h:h===void 0||Math.abs(d-D)<Math.abs(h-D)?d:h;let N=n*t;const k=y+N,E=c===void 0?k:c(k);E!==k&&(N=E-y);const A=D=>-N*Math.exp(-D/s),S=D=>E+A(D),M=D=>{const z=A(D),O=S(D);x.done=Math.abs(z)<=m,x.value=x.done?E:O};let C,I;const R=D=>{w(x.value)&&(C=D,I=qf({keyframes:[x.value,j(x.value)],velocity:GT(S,D,x.value),damping:i,stiffness:l,restDelta:m,restSpeed:p}))};return R(0),{calculatedDuration:null,next:D=>{let z=!1;return!I&&C===void 0&&(z=!0,M(D),R(D)),C!==void 0&&D>=C?I.next(D-C):(!z&&M(D),x)}}}function e7(e,t,n){const s=[],i=n||Va.mix||WT,l=e.length-1;for(let c=0;c<l;c++){let d=i(e[c],e[c+1]);if(t){const h=Array.isArray(t)?t[c]||_s:t;d=tu(h,d)}s.push(d)}return s}function t7(e,t,{clamp:n=!0,ease:s,mixer:i}={}){const l=e.length;if(tx(l===t.length),l===1)return()=>t[0];if(l===2&&t[0]===t[1])return()=>t[1];const c=e[0]===e[1];e[0]>e[l-1]&&(e=[...e].reverse(),t=[...t].reverse());const d=e7(t,s,i),h=d.length,m=p=>{if(c&&p<e[0])return t[0];let y=0;if(h>1)for(;y<e.length-2&&!(p<e[y+1]);y++);const x=Uc(e[y],e[y+1],p);return d[y](x)};return n?p=>m(ma(e[0],e[l-1],p)):m}function n7(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const i=Uc(0,t,s);e.push(en(n,1,i))}}function s7(e){const t=[0];return n7(t,e.length-1),t}function a7(e,t){return e.map(n=>n*t)}function r7(e,t){return e.map(()=>t||PT).splice(0,e.length-1)}function Ac({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const i=gV(s)?s.map(PN):PN(s),l={done:!1,value:t[0]},c=a7(n&&n.length===t.length?n:s7(t),e),d=t7(c,t,{ease:Array.isArray(i)?i:r7(t,i)});return{calculatedDuration:e,next:h=>(l.value=d(h),l.done=h>=e,l)}}const i7=e=>e!==null;function ux(e,{repeat:t,repeatType:n="loop"},s,i=1){const l=e.filter(i7),d=i<0||t&&n!=="loop"&&t%2===1?0:l.length-1;return!d||s===void 0?l[d]:s}const o7={decay:Rv,inertia:Rv,tween:Ac,keyframes:Ac,spring:qf};function KT(e){typeof e.type=="string"&&(e.type=o7[e.type])}class dx{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 l7=e=>e/100;class fx extends dx{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==Bn.now()&&this.tick(Bn.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;KT(t);const{type:n=Ac,repeat:s=0,repeatDelay:i=0,repeatType:l,velocity:c=0}=t;let{keyframes:d}=t;const h=n||Ac;h!==Ac&&typeof d[0]!="number"&&(this.mixKeyframes=tu(l7,WT(d[0],d[1])),d=[0,100]);const m=h({...t,keyframes:d});l==="mirror"&&(this.mirroredGenerator=h({...t,keyframes:[...d].reverse(),velocity:-c})),m.calculatedDuration===null&&(m.calculatedDuration=cx(m));const{calculatedDuration:p}=m;this.calculatedDuration=p,this.resolvedDuration=p+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=m}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:s,totalDuration:i,mixKeyframes:l,mirroredGenerator:c,resolvedDuration:d,calculatedDuration:h}=this;if(this.startTime===null)return s.next(0);const{delay:m=0,keyframes:p,repeat:y,repeatType:x,repeatDelay:w,type:j,onUpdate:N,finalKeyframe:k}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-i/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const E=this.currentTime-m*(this.playbackSpeed>=0?1:-1),A=this.playbackSpeed>=0?E<0:E>i;this.currentTime=Math.max(E,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let S=this.currentTime,M=s;if(y){const D=Math.min(this.currentTime,i)/d;let z=Math.floor(D),O=D%1;!O&&D>=1&&(O=1),O===1&&z--,z=Math.min(z,y+1),z%2&&(x==="reverse"?(O=1-O,w&&(O-=w/d)):x==="mirror"&&(M=c)),S=ma(0,1,O)*d}const C=A?{done:!1,value:p[0]}:M.next(S);l&&(C.value=l(C.value));let{done:I}=C;!A&&h!==null&&(I=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const R=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&I);return R&&j!==Rv&&(C.value=ux(p,this.options,k,this.speed)),N&&N(C.value),R&&this.finish(),C}then(t,n){return this.finished.then(t,n)}get duration(){return Rs(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Rs(t)}get time(){return Rs(this.currentTime)}set time(t){t=Zs(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?.start(!1)}get speed(){return this.playbackSpeed}set speed(t){this.updateTime(Bn.now());const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=Rs(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=qV,startTime:n}=this.options;this.driver||(this.driver=t(i=>this.tick(i))),this.options.onPlay?.();const s=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=s):this.holdTime!==null?this.startTime=s-this.holdTime:this.startTime||(this.startTime=n??s),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(Bn.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 c7(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const vi=e=>e*180/Math.PI,_v=e=>{const t=vi(Math.atan2(e[1],e[0]));return Iv(t)},u7={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:_v,rotateZ:_v,skewX:e=>vi(Math.atan(e[1])),skewY:e=>vi(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Iv=e=>(e=e%360,e<0&&(e+=360),e),FN=_v,HN=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),qN=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),d7={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:HN,scaleY:qN,scale:e=>(HN(e)+qN(e))/2,rotateX:e=>Iv(vi(Math.atan2(e[6],e[5]))),rotateY:e=>Iv(vi(Math.atan2(-e[2],e[0]))),rotateZ:FN,rotate:FN,skewX:e=>vi(Math.atan(e[4])),skewY:e=>vi(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Ov(e){return e.includes("scale")?1:0}function Dv(e,t){if(!e||e==="none")return Ov(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=d7,i=n;else{const d=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=u7,i=d}if(!i)return Ov(t);const l=s[t],c=i[1].split(",").map(h7);return typeof l=="function"?l(c):c[l]}const f7=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Dv(n,t)};function h7(e){return parseFloat(e.trim())}const fl=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],hl=new Set(fl),ZN=e=>e===dl||e===Le,m7=new Set(["x","y","z"]),p7=fl.filter(e=>!m7.has(e));function g7(e){const t=[];return p7.forEach(n=>{const s=e.getValue(n);s!==void 0&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}const Nr={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-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})=>Dv(t,"x"),y:(e,{transform:t})=>Dv(t,"y")};Nr.translateX=Nr.x;Nr.translateY=Nr.y;const bi=new Set;let Pv=!1,zv=!1,Lv=!1;function XT(){if(zv){const e=Array.from(bi).filter(s=>s.needsMeasurement),t=new Set(e.map(s=>s.element)),n=new Map;t.forEach(s=>{const i=g7(s);i.length&&(n.set(s,i),s.render())}),e.forEach(s=>s.measureInitialState()),t.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([l,c])=>{s.getValue(l)?.set(c)})}),e.forEach(s=>s.measureEndState()),e.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}zv=!1,Pv=!1,bi.forEach(e=>e.complete(Lv)),bi.clear()}function JT(){bi.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(zv=!0)})}function v7(){Lv=!0,JT(),XT(),Lv=!1}class hx{constructor(t,n,s,i,l,c=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=s,this.motionValue=i,this.element=l,this.isAsync=c}scheduleResolve(){this.state="scheduled",this.isAsync?(bi.add(this),Pv||(Pv=!0,zt.read(JT),zt.resolveKeyframes(XT))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:s,motionValue:i}=this;if(t[0]===null){const l=i?.get(),c=t[t.length-1];if(l!==void 0)t[0]=l;else if(s&&n){const d=s.readValue(n,c);d!=null&&(t[0]=d)}t[0]===void 0&&(t[0]=c),i&&l===void 0&&i.set(t[0])}c7(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),bi.delete(this)}cancel(){this.state==="scheduled"&&(bi.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const y7=e=>e.startsWith("--");function x7(e,t,n){y7(t)?e.style.setProperty(t,n):e.style[t]=n}const b7={};function QT(e,t){const n=ET(e);return()=>b7[t]??n()}const w7=QT(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),eM=QT(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),yc=([e,t,n,s])=>`cubic-bezier(${e}, ${t}, ${n}, ${s})`,WN={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:yc([0,.65,.55,1]),circOut:yc([.55,0,1,.45]),backIn:yc([.31,.01,.66,-.59]),backOut:yc([.33,1.53,.69,.99])};function tM(e,t){if(e)return typeof e=="function"?eM()?YT(e,t):"ease-out":zT(e)?yc(e):Array.isArray(e)?e.map(n=>tM(n,t)||WN.easeOut):WN[e]}function j7(e,t,n,{delay:s=0,duration:i=300,repeat:l=0,repeatType:c="loop",ease:d="easeOut",times:h}={},m=void 0){const p={[t]:n};h&&(p.offset=h);const y=tM(d,i);Array.isArray(y)&&(p.easing=y);const x={delay:s,duration:i,easing:Array.isArray(y)?"linear":y,fill:"both",iterations:l+1,direction:c==="reverse"?"alternate":"normal"};return m&&(x.pseudoElement=m),e.animate(p,x)}function nM(e){return typeof e=="function"&&"applyToOptions"in e}function N7({type:e,...t}){return nM(e)&&eM()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class sM extends dx{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:n,name:s,keyframes:i,pseudoElement:l,allowFlatten:c=!1,finalKeyframe:d,onComplete:h}=t;this.isPseudoElement=!!l,this.allowFlatten=c,this.options=t,tx(typeof t.type!="string");const m=N7(t);this.animation=j7(n,s,i,m,l),m.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!l){const p=ux(i,this.options,d,this.speed);this.updateMotionValue?this.updateMotionValue(p):x7(n,s,p),this.animation.cancel()}h?.(),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 Rs(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Rs(t)}get time(){return Rs(Number(this.animation.currentTime)||0)}set time(t){this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Zs(t)}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,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,t&&w7()?(this.animation.timeline=t,_s):n(this)}}const aM={anticipate:IT,backInOut:_T,circInOut:DT};function S7(e){return e in aM}function k7(e){typeof e.ease=="string"&&S7(e.ease)&&(e.ease=aM[e.ease])}const xg=10;class E7 extends sM{constructor(t){k7(t),KT(t),super(t),t.startTime!==void 0&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:s,onComplete:i,element:l,...c}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const d=new fx({...c,autoplay:!1}),h=Math.max(xg,Bn.now()-this.startTime),m=ma(0,xg,h-xg);n.setWithVelocity(d.sample(Math.max(0,h-m)).value,d.sample(h).value,m),d.stop()}}const YN=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Ws.test(e)||e==="0")&&!e.startsWith("url("));function C7(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 A7(e,t,n,s){const i=e[0];if(i===null)return!1;if(t==="display"||t==="visibility")return!0;const l=e[e.length-1],c=YN(i,t),d=YN(l,t);return!c||!d?!1:C7(e)||(n==="spring"||nM(n))&&s}function $v(e){e.duration=0,e.type="keyframes"}const T7=new Set(["opacity","clipPath","filter","transform"]),M7=ET(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function R7(e){const{motionValue:t,name:n,repeatDelay:s,repeatType:i,damping:l,type:c}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:h,transformTemplate:m}=t.owner.getProps();return M7()&&n&&T7.has(n)&&(n!=="transform"||!m)&&!h&&!s&&i!=="mirror"&&l!==0&&c!=="inertia"}const _7=40;class I7 extends dx{constructor({autoplay:t=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:l=0,repeatType:c="loop",keyframes:d,name:h,motionValue:m,element:p,...y}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Bn.now();const x={autoplay:t,delay:n,type:s,repeat:i,repeatDelay:l,repeatType:c,name:h,motionValue:m,element:p,...y},w=p?.KeyframeResolver||hx;this.keyframeResolver=new w(d,(j,N,k)=>this.onKeyframesResolved(j,N,x,!k),h,m,p),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,n,s,i){this.keyframeResolver=void 0;const{name:l,type:c,velocity:d,delay:h,isHandoff:m,onUpdate:p}=s;this.resolvedAt=Bn.now(),A7(t,l,c,d)||((Va.instantAnimations||!h)&&p?.(ux(t,s,n)),t[0]=t[t.length-1],$v(s),s.repeat=0);const x={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>_7?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:t},w=!m&&R7(x),j=x.motionValue?.owner?.current,N=w?new E7({...x,element:j}):new fx(x);N.finished.then(()=>{this.notifyFinished()}).catch(_s),this.pendingTimeline&&(this.stopTimeline=N.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=N}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(),v7()),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 rM(e,t,n,s=0,i=1){const l=Array.from(e).sort((m,p)=>m.sortNodePosition(p)).indexOf(t),c=e.size,d=(c-1)*s;return typeof n=="function"?n(l,c):i===1?l*s:d-l*s}const O7=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function D7(e){const t=O7.exec(e);if(!t)return[,];const[,n,s,i]=t;return[`--${n??s}`,i]}function iM(e,t,n=1){const[s,i]=D7(e);if(!s)return;const l=window.getComputedStyle(t).getPropertyValue(s);if(l){const c=l.trim();return NT(c)?parseFloat(c):c}return rx(i)?iM(i,t,n+1):i}const P7={type:"spring",stiffness:500,damping:25,restSpeed:10},z7=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),L7={type:"keyframes",duration:.8},$7={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},U7=(e,{keyframes:t})=>t.length>2?L7:hl.has(e)?e.startsWith("scale")?z7(t[1]):P7:$7,B7=e=>e!==null;function V7(e,{repeat:t,repeatType:n="loop"},s){const i=e.filter(B7),l=t&&n!=="loop"&&t%2===1?0:i.length-1;return i[l]}function oM(e,t){if(e?.inherit&&t){const{inherit:n,...s}=e;return{...t,...s}}return e}function mx(e,t){const n=e?.[t]??e?.default??e;return n!==e?oM(n,e):n}function F7({when:e,delay:t,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:l,repeatType:c,repeatDelay:d,from:h,elapsed:m,...p}){return!!Object.keys(p).length}const px=(e,t,n,s={},i,l)=>c=>{const d=mx(s,e)||{},h=d.delay||s.delay||0;let{elapsed:m=0}=s;m=m-Zs(h);const p={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...d,delay:-m,onUpdate:x=>{t.set(x),d.onUpdate&&d.onUpdate(x)},onComplete:()=>{c(),d.onComplete&&d.onComplete()},name:e,motionValue:t,element:l?void 0:i};F7(d)||Object.assign(p,U7(e,p)),p.duration&&(p.duration=Zs(p.duration)),p.repeatDelay&&(p.repeatDelay=Zs(p.repeatDelay)),p.from!==void 0&&(p.keyframes[0]=p.from);let y=!1;if((p.type===!1||p.duration===0&&!p.repeatDelay)&&($v(p),p.delay===0&&(y=!0)),(Va.instantAnimations||Va.skipAnimations||i?.shouldSkipAnimations)&&(y=!0,$v(p),p.delay=0),p.allowFlatten=!d.type&&!d.ease,y&&!l&&t.get()!==void 0){const x=V7(p.keyframes,d);if(x!==void 0){zt.update(()=>{p.onUpdate(x),p.onComplete()});return}}return d.isSync?new fx(p):new I7(p)};function GN(e){const t=[{},{}];return e?.values.forEach((n,s)=>{t[0][s]=n.get(),t[1][s]=n.getVelocity()}),t}function gx(e,t,n,s){if(typeof t=="function"){const[i,l]=GN(s);t=t(n!==void 0?n:e.custom,i,l)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[i,l]=GN(s);t=t(n!==void 0?n:e.custom,i,l)}return t}function Ko(e,t,n){const s=e.getProps();return gx(s,t,n!==void 0?n:s.custom,e)}const lM=new Set(["width","height","top","left","right","bottom",...fl]),KN=30,H7=e=>!isNaN(parseFloat(e));class q7{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=Bn.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const l of this.dependents)l.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Bn.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=H7(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 nx);const s=this.events[t].add(n);return t==="change"?()=>{s(),zt.read(()=>{this.events.change.getSize()||this.stop()})}:s}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,s){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-s}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=Bn.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>KN)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,KN);return CT(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 rl(e,t){return new q7(e,t)}const Uv=e=>Array.isArray(e);function Z7(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,rl(n))}function W7(e){return Uv(e)?e[e.length-1]||0:e}function Y7(e,t){const n=Ko(e,t);let{transitionEnd:s={},transition:i={},...l}=n||{};l={...l,...s};for(const c in l){const d=W7(l[c]);Z7(e,c,d)}}const Pn=e=>!!(e&&e.getVelocity);function G7(e){return!!(Pn(e)&&e.add)}function Bv(e,t){const n=e.getValue("willChange");if(G7(n))return n.add(t);if(!n&&Va.WillChange){const s=new Va.WillChange("auto");e.addValue("willChange",s),s.add(t)}}function vx(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const K7="framerAppearId",cM="data-"+vx(K7);function uM(e){return e.props[cM]}function X7({protectedKeys:e,needsAnimating:t},n){const s=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,s}function dM(e,t,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:l,transitionEnd:c,...d}=t;const h=e.getDefaultTransition();l=l?oM(l,h):h;const m=l?.reduceMotion;s&&(l=s);const p=[],y=i&&e.animationState&&e.animationState.getState()[i];for(const x in d){const w=e.getValue(x,e.latestValues[x]??null),j=d[x];if(j===void 0||y&&X7(y,x))continue;const N={delay:n,...mx(l||{},x)},k=w.get();if(k!==void 0&&!w.isAnimating&&!Array.isArray(j)&&j===k&&!N.velocity)continue;let E=!1;if(window.MotionHandoffAnimation){const M=uM(e);if(M){const C=window.MotionHandoffAnimation(M,x,zt);C!==null&&(N.startTime=C,E=!0)}}Bv(e,x);const A=m??e.shouldReduceMotion;w.start(px(x,w,j,A&&lM.has(x)?{type:!1}:N,e,E));const S=w.animation;S&&p.push(S)}if(c){const x=()=>zt.update(()=>{c&&Y7(e,c)});p.length?Promise.all(p).then(x):x()}return p}function Vv(e,t,n={}){const s=Ko(e,t,n.type==="exit"?e.presenceContext?.custom:void 0);let{transition:i=e.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const l=s?()=>Promise.all(dM(e,s,n)):()=>Promise.resolve(),c=e.variantChildren&&e.variantChildren.size?(h=0)=>{const{delayChildren:m=0,staggerChildren:p,staggerDirection:y}=i;return J7(e,t,h,m,p,y,n)}:()=>Promise.resolve(),{when:d}=i;if(d){const[h,m]=d==="beforeChildren"?[l,c]:[c,l];return h().then(()=>m())}else return Promise.all([l(),c(n.delay)])}function J7(e,t,n=0,s=0,i=0,l=1,c){const d=[];for(const h of e.variantChildren)h.notify("AnimationStart",t),d.push(Vv(h,t,{...c,delay:n+(typeof s=="function"?0:s)+rM(e.variantChildren,h,s,i,l)}).then(()=>h.notify("AnimationComplete",t)));return Promise.all(d)}function Q7(e,t,n={}){e.notify("AnimationStart",t);let s;if(Array.isArray(t)){const i=t.map(l=>Vv(e,l,n));s=Promise.all(i)}else if(typeof t=="string")s=Vv(e,t,n);else{const i=typeof t=="function"?Ko(e,t,n.custom):t;s=Promise.all(dM(e,i,n))}return s.then(()=>{e.notify("AnimationComplete",t)})}const eF={test:e=>e==="auto",parse:e=>e},fM=e=>t=>t.test(e),hM=[dl,Le,da,vr,TV,AV,eF],XN=e=>hM.find(fM(e));function tF(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||kT(e):!0}const nF=new Set(["brightness","contrast","saturate","opacity"]);function sF(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[s]=n.match(ix)||[];if(!s)return e;const i=n.replace(s,"");let l=nF.has(t)?1:0;return s!==n&&(l*=100),t+"("+l+i+")"}const aF=/\b([a-z-]*)\(.*?\)/gu,Fv={...Ws,getAnimatableNone:e=>{const t=e.match(aF);return t?t.map(sF).join(" "):e}},Hv={...Ws,getAnimatableNone:e=>{const t=Ws.parse(e);return Ws.createTransformer(e)(t.map(s=>typeof s=="number"?0:typeof s=="object"?{...s,alpha:1}:s))}},JN={...dl,transform:Math.round},rF={rotate:vr,rotateX:vr,rotateY:vr,rotateZ:vr,scale:Dd,scaleX:Dd,scaleY:Dd,scaleZ:Dd,skew:vr,skewX:vr,skewY:vr,distance:Le,translateX:Le,translateY:Le,translateZ:Le,x:Le,y:Le,z:Le,perspective:Le,transformPerspective:Le,opacity:Bc,originX:LN,originY:LN,originZ:Le},yx={borderWidth:Le,borderTopWidth:Le,borderRightWidth:Le,borderBottomWidth:Le,borderLeftWidth:Le,borderRadius:Le,borderTopLeftRadius:Le,borderTopRightRadius:Le,borderBottomRightRadius:Le,borderBottomLeftRadius:Le,width:Le,maxWidth:Le,height:Le,maxHeight:Le,top:Le,right:Le,bottom:Le,left:Le,inset:Le,insetBlock:Le,insetBlockStart:Le,insetBlockEnd:Le,insetInline:Le,insetInlineStart:Le,insetInlineEnd:Le,padding:Le,paddingTop:Le,paddingRight:Le,paddingBottom:Le,paddingLeft:Le,paddingBlock:Le,paddingBlockStart:Le,paddingBlockEnd:Le,paddingInline:Le,paddingInlineStart:Le,paddingInlineEnd:Le,margin:Le,marginTop:Le,marginRight:Le,marginBottom:Le,marginLeft:Le,marginBlock:Le,marginBlockStart:Le,marginBlockEnd:Le,marginInline:Le,marginInlineStart:Le,marginInlineEnd:Le,fontSize:Le,backgroundPositionX:Le,backgroundPositionY:Le,...rF,zIndex:JN,fillOpacity:Bc,strokeOpacity:Bc,numOctaves:JN},iF={...yx,color:vn,backgroundColor:vn,outlineColor:vn,fill:vn,stroke:vn,borderColor:vn,borderTopColor:vn,borderRightColor:vn,borderBottomColor:vn,borderLeftColor:vn,filter:Fv,WebkitFilter:Fv,mask:Hv,WebkitMask:Hv},mM=e=>iF[e],oF=new Set([Fv,Hv]);function pM(e,t){let n=mM(e);return oF.has(n)||(n=Ws),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const lF=new Set(["auto","none","0"]);function cF(e,t,n){let s=0,i;for(;s<e.length&&!i;){const l=e[s];typeof l=="string"&&!lF.has(l)&&Vc(l).values.length&&(i=e[s]),s++}if(i&&n)for(const l of t)e[l]=pM(n,i)}class uF extends hx{constructor(t,n,s,i,l){super(t,n,s,i,l,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let p=0;p<t.length;p++){let y=t[p];if(typeof y=="string"&&(y=y.trim(),rx(y))){const x=iM(y,n.current);x!==void 0&&(t[p]=x),p===t.length-1&&(this.finalKeyframe=y)}}if(this.resolveNoneKeyframes(),!lM.has(s)||t.length!==2)return;const[i,l]=t,c=XN(i),d=XN(l),h=zN(i),m=zN(l);if(h!==m&&Nr[s]){this.needsMeasurement=!0;return}if(c!==d)if(ZN(c)&&ZN(d))for(let p=0;p<t.length;p++){const y=t[p];typeof y=="string"&&(t[p]=parseFloat(y))}else Nr[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,s=[];for(let i=0;i<t.length;i++)(t[i]===null||tF(t[i]))&&s.push(i);s.length&&cF(t,s,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:s}=this;if(!t||!t.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Nr[s](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&t.getValue(s,i).jump(i,!1)}measureEndState(){const{element:t,name:n,unresolvedKeyframes:s}=this;if(!t||!t.current)return;const i=t.getValue(n);i&&i.jump(this.measuredOrigin,!1);const l=s.length-1,c=s[l];s[l]=Nr[n](t.measureViewportBox(),window.getComputedStyle(t.current)),c!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=c),this.removedTransforms?.length&&this.removedTransforms.forEach(([d,h])=>{t.getValue(d).set(h)}),this.resolveNoneKeyframes()}}const dF=new Set(["opacity","clipPath","filter","transform"]);function gM(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){let s=document;const i=n?.[e]??s.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(s=>s!=null)}const vM=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function qv(e){return ST(e)&&"offsetHeight"in e}const{schedule:xx}=LT(queueMicrotask,!1),Fs={x:!1,y:!1};function yM(){return Fs.x||Fs.y}function fF(e){return e==="x"||e==="y"?Fs[e]?null:(Fs[e]=!0,()=>{Fs[e]=!1}):Fs.x||Fs.y?null:(Fs.x=Fs.y=!0,()=>{Fs.x=Fs.y=!1})}function xM(e,t){const n=gM(e),s=new AbortController,i={passive:!0,...t,signal:s.signal};return[n,i,()=>s.abort()]}function hF(e){return!(e.pointerType==="touch"||yM())}function mF(e,t,n={}){const[s,i,l]=xM(e,n);return s.forEach(c=>{let d=!1,h=!1,m;const p=()=>{c.removeEventListener("pointerleave",j)},y=k=>{m&&(m(k),m=void 0),p()},x=k=>{d=!1,window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x),h&&(h=!1,y(k))},w=()=>{d=!0,window.addEventListener("pointerup",x,i),window.addEventListener("pointercancel",x,i)},j=k=>{if(k.pointerType!=="touch"){if(d){h=!0;return}y(k)}},N=k=>{if(!hF(k))return;h=!1;const E=t(c,k);typeof E=="function"&&(m=E,c.addEventListener("pointerleave",j,i))};c.addEventListener("pointerenter",N,i),c.addEventListener("pointerdown",w,i)}),l}const bM=(e,t)=>t?e===t?!0:bM(e,t.parentElement):!1,bx=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,pF=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function gF(e){return pF.has(e.tagName)||e.isContentEditable===!0}const vF=new Set(["INPUT","SELECT","TEXTAREA"]);function yF(e){return vF.has(e.tagName)||e.isContentEditable===!0}const uf=new WeakSet;function QN(e){return t=>{t.key==="Enter"&&e(t)}}function bg(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const xF=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=QN(()=>{if(uf.has(n))return;bg(n,"down");const i=QN(()=>{bg(n,"up")}),l=()=>bg(n,"cancel");n.addEventListener("keyup",i,t),n.addEventListener("blur",l,t)});n.addEventListener("keydown",s,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),t)};function eS(e){return bx(e)&&!yM()}const tS=new WeakSet;function bF(e,t,n={}){const[s,i,l]=xM(e,n),c=d=>{const h=d.currentTarget;if(!eS(d)||tS.has(d))return;uf.add(h),n.stopPropagation&&tS.add(d);const m=t(h,d),p=(w,j)=>{window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",x),uf.has(h)&&uf.delete(h),eS(w)&&typeof m=="function"&&m(w,{success:j})},y=w=>{p(w,h===window||h===document||n.useGlobalTarget||bM(h,w.target))},x=w=>{p(w,!1)};window.addEventListener("pointerup",y,i),window.addEventListener("pointercancel",x,i)};return s.forEach(d=>{(n.useGlobalTarget?window:d).addEventListener("pointerdown",c,i),qv(d)&&(d.addEventListener("focus",m=>xF(m,i)),!gF(d)&&!d.hasAttribute("tabindex")&&(d.tabIndex=0))}),l}function wx(e){return ST(e)&&"ownerSVGElement"in e}const df=new WeakMap;let ff;const wM=(e,t,n)=>(s,i)=>i&&i[0]?i[0][e+"Size"]:wx(s)&&"getBBox"in s?s.getBBox()[t]:s[n],wF=wM("inline","width","offsetWidth"),jF=wM("block","height","offsetHeight");function NF({target:e,borderBoxSize:t}){df.get(e)?.forEach(n=>{n(e,{get width(){return wF(e,t)},get height(){return jF(e,t)}})})}function SF(e){e.forEach(NF)}function kF(){typeof ResizeObserver>"u"||(ff=new ResizeObserver(SF))}function EF(e,t){ff||kF();const n=gM(e);return n.forEach(s=>{let i=df.get(s);i||(i=new Set,df.set(s,i)),i.add(t),ff?.observe(s)}),()=>{n.forEach(s=>{const i=df.get(s);i?.delete(t),i?.size||ff?.unobserve(s)})}}const hf=new Set;let Vo;function CF(){Vo=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};hf.forEach(t=>t(e))},window.addEventListener("resize",Vo)}function AF(e){return hf.add(e),Vo||CF(),()=>{hf.delete(e),!hf.size&&typeof Vo=="function"&&(window.removeEventListener("resize",Vo),Vo=void 0)}}function nS(e,t){return typeof e=="function"?AF(e):EF(e,t)}function TF(e){return wx(e)&&e.tagName==="svg"}const MF=[...hM,vn,Ws],RF=e=>MF.find(fM(e)),sS=()=>({translate:0,scale:1,origin:0,originPoint:0}),Fo=()=>({x:sS(),y:sS()}),aS=()=>({min:0,max:0}),bn=()=>({x:aS(),y:aS()}),_F=new WeakMap;function Sh(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function Fc(e){return typeof e=="string"||Array.isArray(e)}const jx=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Nx=["initial",...jx];function kh(e){return Sh(e.animate)||Nx.some(t=>Fc(e[t]))}function jM(e){return!!(kh(e)||e.variants)}function IF(e,t,n){for(const s in t){const i=t[s],l=n[s];if(Pn(i))e.addValue(s,i);else if(Pn(l))e.addValue(s,rl(i,{owner:e}));else if(l!==i)if(e.hasValue(s)){const c=e.getValue(s);c.liveStyle===!0?c.jump(i):c.hasAnimated||c.set(i)}else{const c=e.getStaticValue(s);e.addValue(s,rl(c!==void 0?c:i,{owner:e}))}}for(const s in n)t[s]===void 0&&e.removeValue(s);return t}const Zv={current:null},NM={current:!1},OF=typeof window<"u";function DF(){if(NM.current=!0,!!OF)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>Zv.current=e.matches;e.addEventListener("change",t),t()}else Zv.current=!1}const rS=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Zf={};function SM(e){Zf=e}function PF(){return Zf}class zF{scrapeMotionValuesFromProps(t,n,s){return{}}constructor({parent:t,props:n,presenceContext:s,reducedMotionConfig:i,skipAnimations:l,blockInitialAnimation:c,visualState:d},h={}){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=hx,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 w=Bn.now();this.renderScheduledAt<w&&(this.renderScheduledAt=w,zt.render(this.render,!1,!0))};const{latestValues:m,renderState:p}=d;this.latestValues=m,this.baseTarget={...m},this.initialValues=n.initial?{...m}:{},this.renderState=p,this.parent=t,this.props=n,this.presenceContext=s,this.depth=t?t.depth+1:0,this.reducedMotionConfig=i,this.skipAnimationsConfig=l,this.options=h,this.blockInitialAnimation=!!c,this.isControllingVariants=kh(n),this.isVariantNode=jM(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:y,...x}=this.scrapeMotionValuesFromProps(n,{},this);for(const w in x){const j=x[w];m[w]!==void 0&&Pn(j)&&j.set(m[w])}}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,_F.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,s)=>this.bindToMotionValue(s,n)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(NM.current||DF(),this.shouldReduceMotion=Zv.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(),Rr(this.notifyUpdate),Rr(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&&dF.has(t)&&this.current instanceof HTMLElement){const{factory:c,keyframes:d,times:h,ease:m,duration:p}=n.accelerate,y=new sM({element:this.current,name:t,keyframes:d,times:h,ease:m,duration:Zs(p)}),x=c(y);this.valueSubscriptions.set(t,()=>{x(),y.cancel()});return}const s=hl.has(t);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",c=>{this.latestValues[t]=c,this.props.onUpdate&&zt.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let l;typeof window<"u"&&window.MotionCheckAppearSync&&(l=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{i(),l&&l(),n.owner&&n.stop()})}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 Zf){const n=Zf[t];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[t]&&i&&s(this.props)&&(this.features[t]=new i(this)),this.features[t]){const l=this.features[t];l.isMounted?l.update():(l.mount(),l.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):bn()}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 s=0;s<rS.length;s++){const i=rS[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const l="on"+i,c=t[l];c&&(this.propEventSubscriptions[i]=this.on(i,c))}this.prevMotionValues=IF(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 s=this.values.get(t);n!==s&&(s&&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 s=this.values.get(t);return s===void 0&&n!==void 0&&(s=rl(n===null?void 0:n,{owner:this}),this.addValue(t,s)),s}readValue(t,n){let s=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return s!=null&&(typeof s=="string"&&(NT(s)||kT(s))?s=parseFloat(s):!RF(s)&&Ws.test(n)&&(s=pM(t,n)),this.setBaseTarget(t,Pn(s)?s.get():s)),Pn(s)?s.get():s}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const l=gx(this.props,n,this.presenceContext?.custom);l&&(s=l[t])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,t);return i!==void 0&&!Pn(i)?i:this.initialValues[t]!==void 0&&s===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new nx),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){xx.render(this.render)}}class kM extends zF{constructor(){super(...arguments),this.KeyframeResolver=uF}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){const s=t.style;return s?s[n]:void 0}removeValueFromRenderState(t,{vars:n,style:s}){delete n[t],delete s[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;Pn(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class Vr{constructor(t){this.isMounted=!1,this.node=t}update(){}}function EM({top:e,left:t,right:n,bottom:s}){return{x:{min:t,max:n},y:{min:e,max:s}}}function LF({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function $F(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),s=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function wg(e){return e===void 0||e===1}function Wv({scale:e,scaleX:t,scaleY:n}){return!wg(e)||!wg(t)||!wg(n)}function di(e){return Wv(e)||CM(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function CM(e){return iS(e.x)||iS(e.y)}function iS(e){return e&&e!=="0%"}function Wf(e,t,n){const s=e-n,i=t*s;return n+i}function oS(e,t,n,s,i){return i!==void 0&&(e=Wf(e,i,s)),Wf(e,n,s)+t}function Yv(e,t=0,n=1,s,i){e.min=oS(e.min,t,n,s,i),e.max=oS(e.max,t,n,s,i)}function AM(e,{x:t,y:n}){Yv(e.x,t.translate,t.scale,t.originPoint),Yv(e.y,n.translate,n.scale,n.originPoint)}const lS=.999999999999,cS=1.0000000000001;function UF(e,t,n,s=!1){const i=n.length;if(!i)return;t.x=t.y=1;let l,c;for(let d=0;d<i;d++){l=n[d],c=l.projectionDelta;const{visualElement:h}=l.options;h&&h.props.style&&h.props.style.display==="contents"||(s&&l.options.layoutScroll&&l.scroll&&l!==l.root&&qo(e,{x:-l.scroll.offset.x,y:-l.scroll.offset.y}),c&&(t.x*=c.x.scale,t.y*=c.y.scale,AM(e,c)),s&&di(l.latestValues)&&qo(e,l.latestValues))}t.x<cS&&t.x>lS&&(t.x=1),t.y<cS&&t.y>lS&&(t.y=1)}function Ho(e,t){e.min=e.min+t,e.max=e.max+t}function uS(e,t,n,s,i=.5){const l=en(e.min,e.max,i);Yv(e,t,n,l,s)}function qo(e,t){uS(e.x,t.x,t.scaleX,t.scale,t.originX),uS(e.y,t.y,t.scaleY,t.scale,t.originY)}function TM(e,t){return EM($F(e.getBoundingClientRect(),t))}function BF(e,t,n){const s=TM(e,n),{scroll:i}=t;return i&&(Ho(s.x,i.offset.x),Ho(s.y,i.offset.y)),s}const VF={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},FF=fl.length;function HF(e,t,n){let s="",i=!0;for(let l=0;l<FF;l++){const c=fl[l],d=e[c];if(d===void 0)continue;let h=!0;if(typeof d=="number")h=d===(c.startsWith("scale")?1:0);else{const m=parseFloat(d);h=c.startsWith("scale")?m===1:m===0}if(!h||n){const m=vM(d,yx[c]);if(!h){i=!1;const p=VF[c]||c;s+=`${p}(${m}) `}n&&(t[c]=m)}}return s=s.trim(),n?s=n(t,i?"":s):i&&(s="none"),s}function Sx(e,t,n){const{style:s,vars:i,transformOrigin:l}=e;let c=!1,d=!1;for(const h in t){const m=t[h];if(hl.has(h)){c=!0;continue}else if(UT(h)){i[h]=m;continue}else{const p=vM(m,yx[h]);h.startsWith("origin")?(d=!0,l[h]=p):s[h]=p}}if(t.transform||(c||n?s.transform=HF(t,e.transform,n):s.transform&&(s.transform="none")),d){const{originX:h="50%",originY:m="50%",originZ:p=0}=l;s.transformOrigin=`${h} ${m} ${p}`}}function MM(e,{style:t,vars:n},s,i){const l=e.style;let c;for(c in t)l[c]=t[c];i?.applyProjectionStyles(l,s);for(c in n)l.setProperty(c,n[c])}function dS(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const lc={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(Le.test(e))e=parseFloat(e);else return e;const n=dS(e,t.target.x),s=dS(e,t.target.y);return`${n}% ${s}%`}},qF={correct:(e,{treeScale:t,projectionDelta:n})=>{const s=e,i=Ws.parse(e);if(i.length>5)return s;const l=Ws.createTransformer(e),c=typeof i[0]!="number"?1:0,d=n.x.scale*t.x,h=n.y.scale*t.y;i[0+c]/=d,i[1+c]/=h;const m=en(d,h,.5);return typeof i[2+c]=="number"&&(i[2+c]/=m),typeof i[3+c]=="number"&&(i[3+c]/=m),l(i)}},Gv={borderRadius:{...lc,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:lc,borderTopRightRadius:lc,borderBottomLeftRadius:lc,borderBottomRightRadius:lc,boxShadow:qF};function RM(e,{layout:t,layoutId:n}){return hl.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!Gv[e]||e==="opacity")}function kx(e,t,n){const s=e.style,i=t?.style,l={};if(!s)return l;for(const c in s)(Pn(s[c])||i&&Pn(i[c])||RM(c,e)||n?.getValue(c)?.liveStyle!==void 0)&&(l[c]=s[c]);return l}function ZF(e){return window.getComputedStyle(e)}class WF extends kM{constructor(){super(...arguments),this.type="html",this.renderInstance=MM}readValueFromInstance(t,n){if(hl.has(n))return this.projection?.isProjecting?Ov(n):f7(t,n);{const s=ZF(t),i=(UT(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(t,{transformPagePoint:n}){return TM(t,n)}build(t,n,s){Sx(t,n,s.transformTemplate)}scrapeMotionValuesFromProps(t,n,s){return kx(t,n,s)}}const YF={offset:"stroke-dashoffset",array:"stroke-dasharray"},GF={offset:"strokeDashoffset",array:"strokeDasharray"};function KF(e,t,n=1,s=0,i=!0){e.pathLength=1;const l=i?YF:GF;e[l.offset]=`${-s}`,e[l.array]=`${t} ${n}`}const XF=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function _M(e,{attrX:t,attrY:n,attrScale:s,pathLength:i,pathSpacing:l=1,pathOffset:c=0,...d},h,m,p){if(Sx(e,d,m),h){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:y,style:x}=e;y.transform&&(x.transform=y.transform,delete y.transform),(x.transform||y.transformOrigin)&&(x.transformOrigin=y.transformOrigin??"50% 50%",delete y.transformOrigin),x.transform&&(x.transformBox=p?.transformBox??"fill-box",delete y.transformBox);for(const w of XF)y[w]!==void 0&&(x[w]=y[w],delete y[w]);t!==void 0&&(y.x=t),n!==void 0&&(y.y=n),s!==void 0&&(y.scale=s),i!==void 0&&KF(y,i,l,c,!1)}const IM=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"]),OM=e=>typeof e=="string"&&e.toLowerCase()==="svg";function JF(e,t,n,s){MM(e,t,void 0,s);for(const i in t.attrs)e.setAttribute(IM.has(i)?i:vx(i),t.attrs[i])}function DM(e,t,n){const s=kx(e,t,n);for(const i in e)if(Pn(e[i])||Pn(t[i])){const l=fl.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[l]=e[i]}return s}class QF extends kM{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=bn}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(hl.has(n)){const s=mM(n);return s&&s.default||0}return n=IM.has(n)?n:vx(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,s){return DM(t,n,s)}build(t,n,s){_M(t,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(t,n,s,i){JF(t,n,s,i)}mount(t){this.isSVGTag=OM(t.tagName),super.mount(t)}}const eH=Nx.length;function PM(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?PM(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<eH;n++){const s=Nx[n],i=e.props[s];(Fc(i)||i===!1)&&(t[s]=i)}return t}function zM(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let s=0;s<n;s++)if(t[s]!==e[s])return!1;return!0}const tH=[...jx].reverse(),nH=jx.length;function sH(e){return t=>Promise.all(t.map(({animation:n,options:s})=>Q7(e,n,s)))}function aH(e){let t=sH(e),n=fS(),s=!0;const i=h=>(m,p)=>{const y=Ko(e,p,h==="exit"?e.presenceContext?.custom:void 0);if(y){const{transition:x,transitionEnd:w,...j}=y;m={...m,...j,...w}}return m};function l(h){t=h(e)}function c(h){const{props:m}=e,p=PM(e.parent)||{},y=[],x=new Set;let w={},j=1/0;for(let k=0;k<nH;k++){const E=tH[k],A=n[E],S=m[E]!==void 0?m[E]:p[E],M=Fc(S),C=E===h?A.isActive:null;C===!1&&(j=k);let I=S===p[E]&&S!==m[E]&&M;if(I&&s&&e.manuallyAnimateOnMount&&(I=!1),A.protectedKeys={...w},!A.isActive&&C===null||!S&&!A.prevProp||Sh(S)||typeof S=="boolean")continue;if(E==="exit"&&A.isActive&&C!==!0){A.prevResolvedValues&&(w={...w,...A.prevResolvedValues});continue}const R=rH(A.prevProp,S);let D=R||E===h&&A.isActive&&!I&&M||k>j&&M,z=!1;const O=Array.isArray(S)?S:[S];let _=O.reduce(i(E),{});C===!1&&(_={});const{prevResolvedValues:U={}}=A,q={...U,..._},G=F=>{D=!0,x.has(F)&&(z=!0,x.delete(F)),A.needsAnimating[F]=!0;const H=e.getValue(F);H&&(H.liveStyle=!1)};for(const F in q){const H=_[F],V=U[F];if(w.hasOwnProperty(F))continue;let W=!1;Uv(H)&&Uv(V)?W=!zM(H,V):W=H!==V,W?H!=null?G(F):x.add(F):H!==void 0&&x.has(F)?G(F):A.protectedKeys[F]=!0}A.prevProp=S,A.prevResolvedValues=_,A.isActive&&(w={...w,..._}),s&&e.blockInitialAnimation&&(D=!1);const X=I&&R;D&&(!X||z)&&y.push(...O.map(F=>{const H={type:E};if(typeof F=="string"&&s&&!X&&e.manuallyAnimateOnMount&&e.parent){const{parent:V}=e,W=Ko(V,F);if(V.enteringChildren&&W){const{delayChildren:$}=W.transition||{};H.delay=rM(V.enteringChildren,e,$)}}return{animation:F,options:H}}))}if(x.size){const k={};if(typeof m.initial!="boolean"){const E=Ko(e,Array.isArray(m.initial)?m.initial[0]:m.initial);E&&E.transition&&(k.transition=E.transition)}x.forEach(E=>{const A=e.getBaseTarget(E),S=e.getValue(E);S&&(S.liveStyle=!0),k[E]=A??null}),y.push({animation:k})}let N=!!y.length;return s&&(m.initial===!1||m.initial===m.animate)&&!e.manuallyAnimateOnMount&&(N=!1),s=!1,N?t(y):Promise.resolve()}function d(h,m){if(n[h].isActive===m)return Promise.resolve();e.variantChildren?.forEach(y=>y.animationState?.setActive(h,m)),n[h].isActive=m;const p=c(h);for(const y in n)n[y].protectedKeys={};return p}return{animateChanges:c,setActive:d,setAnimateFunction:l,getState:()=>n,reset:()=>{n=fS()}}}function rH(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!zM(t,e):!1}function li(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function fS(){return{animate:li(!0),whileInView:li(),whileHover:li(),whileTap:li(),whileDrag:li(),whileFocus:li(),exit:li()}}function hS(e,t){e.min=t.min,e.max=t.max}function Vs(e,t){hS(e.x,t.x),hS(e.y,t.y)}function mS(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const LM=1e-4,iH=1-LM,oH=1+LM,$M=.01,lH=0-$M,cH=0+$M;function Vn(e){return e.max-e.min}function uH(e,t,n){return Math.abs(e-t)<=n}function pS(e,t,n,s=.5){e.origin=s,e.originPoint=en(t.min,t.max,e.origin),e.scale=Vn(n)/Vn(t),e.translate=en(n.min,n.max,e.origin)-e.originPoint,(e.scale>=iH&&e.scale<=oH||isNaN(e.scale))&&(e.scale=1),(e.translate>=lH&&e.translate<=cH||isNaN(e.translate))&&(e.translate=0)}function Tc(e,t,n,s){pS(e.x,t.x,n.x,s?s.originX:void 0),pS(e.y,t.y,n.y,s?s.originY:void 0)}function gS(e,t,n){e.min=n.min+t.min,e.max=e.min+Vn(t)}function dH(e,t,n){gS(e.x,t.x,n.x),gS(e.y,t.y,n.y)}function vS(e,t,n){e.min=t.min-n.min,e.max=e.min+Vn(t)}function Yf(e,t,n){vS(e.x,t.x,n.x),vS(e.y,t.y,n.y)}function yS(e,t,n,s,i){return e-=t,e=Wf(e,1/n,s),i!==void 0&&(e=Wf(e,1/i,s)),e}function fH(e,t=0,n=1,s=.5,i,l=e,c=e){if(da.test(t)&&(t=parseFloat(t),t=en(c.min,c.max,t/100)-c.min),typeof t!="number")return;let d=en(l.min,l.max,s);e===l&&(d-=t),e.min=yS(e.min,t,n,d,i),e.max=yS(e.max,t,n,d,i)}function xS(e,t,[n,s,i],l,c){fH(e,t[n],t[s],t[i],t.scale,l,c)}const hH=["x","scaleX","originX"],mH=["y","scaleY","originY"];function bS(e,t,n,s){xS(e.x,t,hH,n?n.x:void 0,s?s.x:void 0),xS(e.y,t,mH,n?n.y:void 0,s?s.y:void 0)}function wS(e){return e.translate===0&&e.scale===1}function UM(e){return wS(e.x)&&wS(e.y)}function jS(e,t){return e.min===t.min&&e.max===t.max}function pH(e,t){return jS(e.x,t.x)&&jS(e.y,t.y)}function NS(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function BM(e,t){return NS(e.x,t.x)&&NS(e.y,t.y)}function SS(e){return Vn(e.x)/Vn(e.y)}function kS(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function aa(e){return[e("x"),e("y")]}function gH(e,t,n){let s="";const i=e.x.translate/t.x,l=e.y.translate/t.y,c=n?.z||0;if((i||l||c)&&(s=`translate3d(${i}px, ${l}px, ${c}px) `),(t.x!==1||t.y!==1)&&(s+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:m,rotate:p,rotateX:y,rotateY:x,skewX:w,skewY:j}=n;m&&(s=`perspective(${m}px) ${s}`),p&&(s+=`rotate(${p}deg) `),y&&(s+=`rotateX(${y}deg) `),x&&(s+=`rotateY(${x}deg) `),w&&(s+=`skewX(${w}deg) `),j&&(s+=`skewY(${j}deg) `)}const d=e.x.scale*t.x,h=e.y.scale*t.y;return(d!==1||h!==1)&&(s+=`scale(${d}, ${h})`),s||"none"}const VM=["TopLeft","TopRight","BottomLeft","BottomRight"],vH=VM.length,ES=e=>typeof e=="string"?parseFloat(e):e,CS=e=>typeof e=="number"||Le.test(e);function yH(e,t,n,s,i,l){i?(e.opacity=en(0,n.opacity??1,xH(s)),e.opacityExit=en(t.opacity??1,0,bH(s))):l&&(e.opacity=en(t.opacity??1,n.opacity??1,s));for(let c=0;c<vH;c++){const d=`border${VM[c]}Radius`;let h=AS(t,d),m=AS(n,d);if(h===void 0&&m===void 0)continue;h||(h=0),m||(m=0),h===0||m===0||CS(h)===CS(m)?(e[d]=Math.max(en(ES(h),ES(m),s),0),(da.test(m)||da.test(h))&&(e[d]+="%")):e[d]=m}(t.rotate||n.rotate)&&(e.rotate=en(t.rotate||0,n.rotate||0,s))}function AS(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const xH=FM(0,.5,OT),bH=FM(.5,.95,_s);function FM(e,t,n){return s=>s<e?0:s>t?1:n(Uc(e,t,s))}function wH(e,t,n){const s=Pn(e)?e:rl(e);return s.start(px("",s,t,n)),s.animation}function Hc(e,t,n,s={passive:!0}){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n)}const jH=(e,t)=>e.depth-t.depth;class NH{constructor(){this.children=[],this.isDirty=!1}add(t){ex(this.children,t),this.isDirty=!0}remove(t){Vf(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(jH),this.isDirty=!1,this.children.forEach(t)}}function SH(e,t){const n=Bn.now(),s=({timestamp:i})=>{const l=i-n;l>=t&&(Rr(s),e(l-t))};return zt.setup(s,!0),()=>Rr(s)}function mf(e){return Pn(e)?e.get():e}class kH{constructor(){this.members=[]}add(t){ex(this.members,t);for(let n=this.members.length-1;n>=0;n--){const s=this.members[n];if(s===t||s===this.lead||s===this.prevLead)continue;const i=s.instance;i&&i.isConnected===!1&&s.isPresent!==!1&&!s.snapshot&&Vf(this.members,s)}t.scheduleRender()}remove(t){if(Vf(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){const n=this.members.findIndex(i=>t===i);if(n===0)return!1;let s;for(let i=n;i>=0;i--){const l=this.members[i],c=l.instance;if(l.isPresent!==!1&&(!c||c.isConnected!==!1)){s=l;break}}return s?(this.promote(s),!0):!1}promote(t,n){const s=this.lead;if(t!==s&&(this.prevLead=s,this.lead=t,t.show(),s)){s.instance&&s.scheduleRender(),t.scheduleRender();const i=s.options.layoutDependency,l=t.options.layoutDependency;if(!(i!==void 0&&l!==void 0&&i===l)){const h=s.instance;h&&h.isConnected===!1&&!s.snapshot||(t.resumeFrom=s,n&&(t.resumeFrom.preserveOpacity=!0),s.snapshot&&(t.snapshot=s.snapshot,t.snapshot.latestValues=s.animationValues||s.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0))}const{crossfade:d}=t.options;d===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:s}=t;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}const pf={hasAnimatedSinceResize:!0,hasEverUpdated:!1},jg=["","X","Y","Z"],EH=1e3;let CH=0;function Ng(e,t,n,s){const{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),s&&(s[e]=0))}function HM(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=uM(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:l}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",zt,!(i||l))}const{parent:s}=e;s&&!s.hasCheckedOptimisedAppear&&HM(s)}function qM({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(c={},d=t?.()){this.id=CH++,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(MH),this.nodes.forEach(OH),this.nodes.forEach(DH),this.nodes.forEach(RH)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=c,this.root=d?d.root||d:this,this.path=d?[...d.path,d]:[],this.parent=d,this.depth=d?d.depth+1:0;for(let h=0;h<this.path.length;h++)this.path[h].shouldResetTransform=!0;this.root===this&&(this.nodes=new NH)}addEventListener(c,d){return this.eventHandlers.has(c)||this.eventHandlers.set(c,new nx),this.eventHandlers.get(c).add(d)}notifyListeners(c,...d){const h=this.eventHandlers.get(c);h&&h.notify(...d)}hasListeners(c){return this.eventHandlers.has(c)}mount(c){if(this.instance)return;this.isSVG=wx(c)&&!TF(c),this.instance=c;const{layoutId:d,layout:h,visualElement:m}=this.options;if(m&&!m.current&&m.mount(c),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(h||d)&&(this.isLayoutDirty=!0),e){let p,y=0;const x=()=>this.root.updateBlockedByResize=!1;zt.read(()=>{y=window.innerWidth}),e(c,()=>{const w=window.innerWidth;w!==y&&(y=w,this.root.updateBlockedByResize=!0,p&&p(),p=SH(x,250),pf.hasAnimatedSinceResize&&(pf.hasAnimatedSinceResize=!1,this.nodes.forEach(RS)))})}d&&this.root.registerSharedNode(d,this),this.options.animate!==!1&&m&&(d||h)&&this.addEventListener("didUpdate",({delta:p,hasLayoutChanged:y,hasRelativeLayoutChanged:x,layout:w})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const j=this.options.transition||m.getDefaultTransition()||UH,{onLayoutAnimationStart:N,onLayoutAnimationComplete:k}=m.getProps(),E=!this.targetLayout||!BM(this.targetLayout,w),A=!y&&x;if(this.options.layoutRoot||this.resumeFrom||A||y&&(E||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const S={...mx(j,"layout"),onPlay:N,onComplete:k};(m.shouldReduceMotion||this.options.layoutRoot)&&(S.delay=0,S.type=!1),this.startAnimation(S),this.setAnimationOrigin(p,A)}else y||RS(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=w})}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(),Rr(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(PH),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&&HM(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let p=0;p<this.path.length;p++){const y=this.path[p];y.shouldResetTransform=!0,y.updateScroll("snapshot"),y.options.layoutRoot&&y.willUpdate(!1)}const{layoutId:d,layout:h}=this.options;if(d===void 0&&!h)return;const m=this.getTransformTemplate();this.prevTransformTemplateValue=m?m(this.latestValues,""):void 0,this.updateSnapshot(),c&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(TS);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(MS);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(IH),this.nodes.forEach(AH),this.nodes.forEach(TH)):this.nodes.forEach(MS),this.clearAllSnapshots();const d=Bn.now();Mn.delta=ma(0,1e3/60,d-Mn.timestamp),Mn.timestamp=d,Mn.isProcessing=!0,mg.update.process(Mn),mg.preRender.process(Mn),mg.render.process(Mn),Mn.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,xx.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(_H),this.sharedNodes.forEach(zH)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,zt.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){zt.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Vn(this.snapshot.measuredBox.x)&&!Vn(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 h=0;h<this.path.length;h++)this.path[h].updateScroll();const c=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected=bn(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:d}=this.options;d&&d.notify("LayoutMeasure",this.layout.layoutBox,c?c.layoutBox:void 0)}updateScroll(c="measure"){let d=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===c&&(d=!1),d&&this.instance){const h=s(this.instance);this.scroll={animationId:this.root.animationId,phase:c,isRoot:h,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:h}}}resetTransform(){if(!i)return;const c=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,d=this.projectionDelta&&!UM(this.projectionDelta),h=this.getTransformTemplate(),m=h?h(this.latestValues,""):void 0,p=m!==this.prevTransformTemplateValue;c&&this.instance&&(d||di(this.latestValues)||p)&&(i(this.instance,m),this.shouldResetTransform=!1,this.scheduleRender())}measure(c=!0){const d=this.measurePageBox();let h=this.removeElementScroll(d);return c&&(h=this.removeTransform(h)),BH(h),{animationId:this.root.animationId,measuredBox:d,layoutBox:h,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:c}=this.options;if(!c)return bn();const d=c.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(VH))){const{scroll:m}=this.root;m&&(Ho(d.x,m.offset.x),Ho(d.y,m.offset.y))}return d}removeElementScroll(c){const d=bn();if(Vs(d,c),this.scroll?.wasRoot)return d;for(let h=0;h<this.path.length;h++){const m=this.path[h],{scroll:p,options:y}=m;m!==this.root&&p&&y.layoutScroll&&(p.wasRoot&&Vs(d,c),Ho(d.x,p.offset.x),Ho(d.y,p.offset.y))}return d}applyTransform(c,d=!1){const h=bn();Vs(h,c);for(let m=0;m<this.path.length;m++){const p=this.path[m];!d&&p.options.layoutScroll&&p.scroll&&p!==p.root&&qo(h,{x:-p.scroll.offset.x,y:-p.scroll.offset.y}),di(p.latestValues)&&qo(h,p.latestValues)}return di(this.latestValues)&&qo(h,this.latestValues),h}removeTransform(c){const d=bn();Vs(d,c);for(let h=0;h<this.path.length;h++){const m=this.path[h];if(!m.instance||!di(m.latestValues))continue;Wv(m.latestValues)&&m.updateSnapshot();const p=bn(),y=m.measurePageBox();Vs(p,y),bS(d,m.latestValues,m.snapshot?m.snapshot.layoutBox:void 0,p)}return di(this.latestValues)&&bS(d,this.latestValues),d}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!==Mn.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(c=!1){const d=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=d.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=d.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=d.isSharedProjectionDirty);const h=!!this.resumingFrom||this!==d;if(!(c||h&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:p,layoutId:y}=this.options;if(!this.layout||!(p||y))return;this.resolvedRelativeTargetAt=Mn.timestamp;const x=this.getClosestProjectingParent();x&&this.linkedParentVersion!==x.layoutVersion&&!x.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(x&&x.layout?this.createRelativeTarget(x,this.layout.layoutBox,x.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=bn(),this.targetWithTransforms=bn()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),dH(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Vs(this.target,this.layout.layoutBox),AM(this.target,this.targetDelta)):Vs(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,x&&!!x.resumingFrom==!!this.resumingFrom&&!x.options.layoutScroll&&x.target&&this.animationProgress!==1?this.createRelativeTarget(x,this.target,x.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||Wv(this.parent.latestValues)||CM(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,d,h){this.relativeParent=c,this.linkedParentVersion=c.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=bn(),this.relativeTargetOrigin=bn(),Yf(this.relativeTargetOrigin,d,h),Vs(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){const c=this.getLead(),d=!!this.resumingFrom||this!==c;let h=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(h=!1),d&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(h=!1),this.resolvedRelativeTargetAt===Mn.timestamp&&(h=!1),h)return;const{layout:m,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||!(m||p))return;Vs(this.layoutCorrected,this.layout.layoutBox);const y=this.treeScale.x,x=this.treeScale.y;UF(this.layoutCorrected,this.treeScale,this.path,d),c.layout&&!c.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(c.target=c.layout.layoutBox,c.targetWithTransforms=bn());const{target:w}=c;if(!w){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(mS(this.prevProjectionDelta.x,this.projectionDelta.x),mS(this.prevProjectionDelta.y,this.projectionDelta.y)),Tc(this.projectionDelta,this.layoutCorrected,w,this.latestValues),(this.treeScale.x!==y||this.treeScale.y!==x||!kS(this.projectionDelta.x,this.prevProjectionDelta.x)||!kS(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",w))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(c=!0){if(this.options.visualElement?.scheduleRender(),c){const d=this.getStack();d&&d.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Fo(),this.projectionDelta=Fo(),this.projectionDeltaWithTransform=Fo()}setAnimationOrigin(c,d=!1){const h=this.snapshot,m=h?h.latestValues:{},p={...this.latestValues},y=Fo();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!d;const x=bn(),w=h?h.source:void 0,j=this.layout?this.layout.source:void 0,N=w!==j,k=this.getStack(),E=!k||k.members.length<=1,A=!!(N&&!E&&this.options.crossfade===!0&&!this.path.some($H));this.animationProgress=0;let S;this.mixTargetDelta=M=>{const C=M/1e3;_S(y.x,c.x,C),_S(y.y,c.y,C),this.setTargetDelta(y),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Yf(x,this.layout.layoutBox,this.relativeParent.layout.layoutBox),LH(this.relativeTarget,this.relativeTargetOrigin,x,C),S&&pH(this.relativeTarget,S)&&(this.isProjectionDirty=!1),S||(S=bn()),Vs(S,this.relativeTarget)),N&&(this.animationValues=p,yH(p,m,this.latestValues,C,A,E)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=C},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(c){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Rr(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=zt.update(()=>{pf.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=rl(0)),this.motionValue.jump(0,!1),this.currentAnimation=wH(this.motionValue,[0,1e3],{...c,velocity:0,isSync:!0,onUpdate:d=>{this.mixTargetDelta(d),c.onUpdate&&c.onUpdate(d)},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(EH),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const c=this.getLead();let{targetWithTransforms:d,target:h,layout:m,latestValues:p}=c;if(!(!d||!h||!m)){if(this!==c&&this.layout&&m&&ZM(this.options.animationType,this.layout.layoutBox,m.layoutBox)){h=this.target||bn();const y=Vn(this.layout.layoutBox.x);h.x.min=c.target.x.min,h.x.max=h.x.min+y;const x=Vn(this.layout.layoutBox.y);h.y.min=c.target.y.min,h.y.max=h.y.min+x}Vs(d,h),qo(d,p),Tc(this.projectionDeltaWithTransform,this.layoutCorrected,d,p)}}registerSharedNode(c,d){this.sharedNodes.has(c)||this.sharedNodes.set(c,new kH),this.sharedNodes.get(c).add(d);const m=d.options.initialPromotionConfig;d.promote({transition:m?m.transition:void 0,preserveFollowOpacity:m&&m.shouldPreserveFollowOpacity?m.shouldPreserveFollowOpacity(d):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:d,preserveFollowOpacity:h}={}){const m=this.getStack();m&&m.promote(this,h),c&&(this.projectionDelta=void 0,this.needsReset=!0),d&&this.setOptions({transition:d})}relegate(){const c=this.getStack();return c?c.relegate(this):!1}resetSkewAndRotation(){const{visualElement:c}=this.options;if(!c)return;let d=!1;const{latestValues:h}=c;if((h.z||h.rotate||h.rotateX||h.rotateY||h.rotateZ||h.skewX||h.skewY)&&(d=!0),!d)return;const m={};h.z&&Ng("z",c,m,this.animationValues);for(let p=0;p<jg.length;p++)Ng(`rotate${jg[p]}`,c,m,this.animationValues),Ng(`skew${jg[p]}`,c,m,this.animationValues);c.render();for(const p in m)c.setStaticValue(p,m[p]),this.animationValues&&(this.animationValues[p]=m[p]);c.scheduleRender()}applyProjectionStyles(c,d){if(!this.instance||this.isSVG)return;if(!this.isVisible){c.visibility="hidden";return}const h=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,c.visibility="",c.opacity="",c.pointerEvents=mf(d?.pointerEvents)||"",c.transform=h?h(this.latestValues,""):"none";return}const m=this.getLead();if(!this.projectionDelta||!this.layout||!m.target){this.options.layoutId&&(c.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,c.pointerEvents=mf(d?.pointerEvents)||""),this.hasProjected&&!di(this.latestValues)&&(c.transform=h?h({},""):"none",this.hasProjected=!1);return}c.visibility="";const p=m.animationValues||m.latestValues;this.applyTransformsToTarget();let y=gH(this.projectionDeltaWithTransform,this.treeScale,p);h&&(y=h(p,y)),c.transform=y;const{x,y:w}=this.projectionDelta;c.transformOrigin=`${x.origin*100}% ${w.origin*100}% 0`,m.animationValues?c.opacity=m===this?p.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:p.opacityExit:c.opacity=m===this?p.opacity!==void 0?p.opacity:"":p.opacityExit!==void 0?p.opacityExit:0;for(const j in Gv){if(p[j]===void 0)continue;const{correct:N,applyTo:k,isCSSVariable:E}=Gv[j],A=y==="none"?p[j]:N(p[j],m);if(k){const S=k.length;for(let M=0;M<S;M++)c[k[M]]=A}else E?this.options.visualElement.renderState.vars[j]=A:c[j]=A}this.options.layoutId&&(c.pointerEvents=m===this?mf(d?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(c=>c.currentAnimation?.stop()),this.root.nodes.forEach(TS),this.root.sharedNodes.clear()}}}function AH(e){e.updateLayout()}function TH(e){const t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=e.layout,{animationType:i}=e.options,l=t.source!==e.layout.source;i==="size"?aa(p=>{const y=l?t.measuredBox[p]:t.layoutBox[p],x=Vn(y);y.min=n[p].min,y.max=y.min+x}):ZM(i,t.layoutBox,n)&&aa(p=>{const y=l?t.measuredBox[p]:t.layoutBox[p],x=Vn(n[p]);y.max=y.min+x,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[p].max=e.relativeTarget[p].min+x)});const c=Fo();Tc(c,n,t.layoutBox);const d=Fo();l?Tc(d,e.applyTransform(s,!0),t.measuredBox):Tc(d,n,t.layoutBox);const h=!UM(c);let m=!1;if(!e.resumeFrom){const p=e.getClosestProjectingParent();if(p&&!p.resumeFrom){const{snapshot:y,layout:x}=p;if(y&&x){const w=bn();Yf(w,t.layoutBox,y.layoutBox);const j=bn();Yf(j,n,x.layoutBox),BM(w,j)||(m=!0),p.options.layoutRoot&&(e.relativeTarget=j,e.relativeTargetOrigin=w,e.relativeParent=p)}}}e.notifyListeners("didUpdate",{layout:n,snapshot:t,delta:d,layoutDelta:c,hasLayoutChanged:h,hasRelativeLayoutChanged:m})}else if(e.isLead()){const{onExitComplete:n}=e.options;n&&n()}e.options.transition=void 0}function MH(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 RH(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function _H(e){e.clearSnapshot()}function TS(e){e.clearMeasurements()}function MS(e){e.isLayoutDirty=!1}function IH(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function RS(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function OH(e){e.resolveTargetDelta()}function DH(e){e.calcProjection()}function PH(e){e.resetSkewAndRotation()}function zH(e){e.removeLeadSnapshot()}function _S(e,t,n){e.translate=en(t.translate,0,n),e.scale=en(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function IS(e,t,n,s){e.min=en(t.min,n.min,s),e.max=en(t.max,n.max,s)}function LH(e,t,n,s){IS(e.x,t.x,n.x,s),IS(e.y,t.y,n.y,s)}function $H(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const UH={duration:.45,ease:[.4,0,.1,1]},OS=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),DS=OS("applewebkit/")&&!OS("chrome/")?Math.round:_s;function PS(e){e.min=DS(e.min),e.max=DS(e.max)}function BH(e){PS(e.x),PS(e.y)}function ZM(e,t,n){return e==="position"||e==="preserve-aspect"&&!uH(SS(t),SS(n),.2)}function VH(e){return e!==e.root&&e.scroll?.wasRoot}const FH=qM({attachResizeListener:(e,t)=>Hc(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),Sg={current:void 0},WM=qM({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Sg.current){const e=new FH({});e.mount(window),e.setOptions({layoutScroll:!0}),Sg.current=e}return Sg.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),Ex=g.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function zS(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function HH(...e){return t=>{let n=!1;const s=e.map(i=>{const l=zS(i,t);return!n&&typeof l=="function"&&(n=!0),l});if(n)return()=>{for(let i=0;i<s.length;i++){const l=s[i];typeof l=="function"?l():zS(e[i],null)}}}}function qH(...e){return g.useCallback(HH(...e),e)}class ZH extends g.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const s=n.offsetParent,i=qv(s)&&s.offsetWidth||0,l=qv(s)&&s.offsetHeight||0,c=this.props.sizeRef.current;c.height=n.offsetHeight||0,c.width=n.offsetWidth||0,c.top=n.offsetTop,c.left=n.offsetLeft,c.right=i-c.width-c.left,c.bottom=l-c.height-c.top}return null}componentDidUpdate(){}render(){return this.props.children}}function WH({children:e,isPresent:t,anchorX:n,anchorY:s,root:i,pop:l}){const c=g.useId(),d=g.useRef(null),h=g.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0}),{nonce:m}=g.useContext(Ex),p=e.props?.ref??e?.ref,y=qH(d,p);return g.useInsertionEffect(()=>{const{width:x,height:w,top:j,left:N,right:k,bottom:E}=h.current;if(t||l===!1||!d.current||!x||!w)return;const A=n==="left"?`left: ${N}`:`right: ${k}`,S=s==="bottom"?`bottom: ${E}`:`top: ${j}`;d.current.dataset.motionPopId=c;const M=document.createElement("style");m&&(M.nonce=m);const C=i??document.head;return C.appendChild(M),M.sheet&&M.sheet.insertRule(`
|
|
123
|
-
[data-motion-pop-id="${c}"] {
|
|
124
|
-
position: absolute !important;
|
|
125
|
-
width: ${x}px !important;
|
|
126
|
-
height: ${w}px !important;
|
|
127
|
-
${A}px !important;
|
|
128
|
-
${S}px !important;
|
|
129
|
-
}
|
|
130
|
-
`),()=>{C.contains(M)&&C.removeChild(M)}},[t]),r.jsx(ZH,{isPresent:t,childRef:d,sizeRef:h,pop:l,children:l===!1?e:g.cloneElement(e,{ref:y})})}const YH=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:l,mode:c,anchorX:d,anchorY:h,root:m})=>{const p=Qy(GH),y=g.useId();let x=!0,w=g.useMemo(()=>(x=!1,{id:y,initial:t,isPresent:n,custom:i,onExitComplete:j=>{p.set(j,!0);for(const N of p.values())if(!N)return;s&&s()},register:j=>(p.set(j,!1),()=>p.delete(j))}),[n,p,s]);return l&&x&&(w={...w}),g.useMemo(()=>{p.forEach((j,N)=>p.set(N,!1))},[n]),g.useEffect(()=>{!n&&!p.size&&s&&s()},[n]),e=r.jsx(WH,{pop:c==="popLayout",isPresent:n,anchorX:d,anchorY:h,root:m,children:e}),r.jsx(Nh.Provider,{value:w,children:e})};function GH(){return new Map}function YM(e=!0){const t=g.useContext(Nh);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=t,l=g.useId();g.useEffect(()=>{if(e)return i(l)},[e]);const c=g.useCallback(()=>e&&s&&s(l),[l,s,e]);return!n&&s?[!1,c]:[!0]}const Pd=e=>e.key||"";function LS(e){const t=[];return g.Children.forEach(e,n=>{g.isValidElement(n)&&t.push(n)}),t}const KH=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:l="sync",propagate:c=!1,anchorX:d="left",anchorY:h="top",root:m})=>{const[p,y]=YM(c),x=g.useMemo(()=>LS(e),[e]),w=c&&!p?[]:x.map(Pd),j=g.useRef(!0),N=g.useRef(x),k=Qy(()=>new Map),E=g.useRef(new Set),[A,S]=g.useState(x),[M,C]=g.useState(x);jT(()=>{j.current=!1,N.current=x;for(let D=0;D<M.length;D++){const z=Pd(M[D]);w.includes(z)?(k.delete(z),E.current.delete(z)):k.get(z)!==!0&&k.set(z,!1)}},[M,w.length,w.join("-")]);const I=[];if(x!==A){let D=[...x];for(let z=0;z<M.length;z++){const O=M[z],_=Pd(O);w.includes(_)||(D.splice(z,0,O),I.push(O))}return l==="wait"&&I.length&&(D=I),C(LS(D)),S(x),null}const{forceRender:R}=g.useContext(Jy);return r.jsx(r.Fragment,{children:M.map(D=>{const z=Pd(D),O=c&&!p?!1:x===M||w.includes(z),_=()=>{if(E.current.has(z))return;if(E.current.add(z),k.has(z))k.set(z,!0);else return;let U=!0;k.forEach(q=>{q||(U=!1)}),U&&(R?.(),C(N.current),c&&y?.(),s&&s())};return r.jsx(YH,{isPresent:O,initial:!j.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:l,root:m,onExitComplete:O?void 0:_,anchorX:d,anchorY:h,children:D},z)})})},GM=g.createContext({strict:!1}),$S={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 US=!1;function XH(){if(US)return;const e={};for(const t in $S)e[t]={isEnabled:n=>$S[t].some(s=>!!n[s])};SM(e),US=!0}function KM(){return XH(),PF()}function JH(e){const t=KM();for(const n in e)t[n]={...t[n],...e[n]};SM(t)}const QH=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 Gf(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||QH.has(e)}let XM=e=>!Gf(e);function eq(e){typeof e=="function"&&(XM=t=>t.startsWith("on")?!Gf(t):e(t))}try{eq(require("@emotion/is-prop-valid").default)}catch{}function tq(e,t,n){const s={};for(const i in e)i==="values"&&typeof e.values=="object"||(XM(i)||n===!0&&Gf(i)||!t&&!Gf(i)||e.draggable&&i.startsWith("onDrag"))&&(s[i]=e[i]);return s}const Eh=g.createContext({});function nq(e,t){if(kh(e)){const{initial:n,animate:s}=e;return{initial:n===!1||Fc(n)?n:void 0,animate:Fc(s)?s:void 0}}return e.inherit!==!1?t:{}}function sq(e){const{initial:t,animate:n}=nq(e,g.useContext(Eh));return g.useMemo(()=>({initial:t,animate:n}),[BS(t),BS(n)])}function BS(e){return Array.isArray(e)?e.join(" "):e}const Cx=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function JM(e,t,n){for(const s in t)!Pn(t[s])&&!RM(s,n)&&(e[s]=t[s])}function aq({transformTemplate:e},t){return g.useMemo(()=>{const n=Cx();return Sx(n,t,e),Object.assign({},n.vars,n.style)},[t])}function rq(e,t){const n=e.style||{},s={};return JM(s,n,e),Object.assign(s,aq(e,t)),s}function iq(e,t){const n={},s=rq(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.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=s,n}const QM=()=>({...Cx(),attrs:{}});function oq(e,t,n,s){const i=g.useMemo(()=>{const l=QM();return _M(l,t,OM(s),e.transformTemplate,e.style),{...l.attrs,style:{...l.style}}},[t]);if(e.style){const l={};JM(l,e.style,e),i.style={...l,...i.style}}return i}const lq=["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 Ax(e){return typeof e!="string"||e.includes("-")?!1:!!(lq.indexOf(e)>-1||/[A-Z]/u.test(e))}function cq(e,t,n,{latestValues:s},i,l=!1,c){const h=(c??Ax(e)?oq:iq)(t,s,i,e),m=tq(t,typeof e=="string",l),p=e!==g.Fragment?{...m,...h,ref:n}:{},{children:y}=t,x=g.useMemo(()=>Pn(y)?y.get():y,[y]);return g.createElement(e,{...p,children:x})}function uq({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,i){return{latestValues:dq(n,s,i,e),renderState:t()}}function dq(e,t,n,s){const i={},l=s(e,{});for(const x in l)i[x]=mf(l[x]);let{initial:c,animate:d}=e;const h=kh(e),m=jM(e);t&&m&&!h&&e.inherit!==!1&&(c===void 0&&(c=t.initial),d===void 0&&(d=t.animate));let p=n?n.initial===!1:!1;p=p||c===!1;const y=p?d:c;if(y&&typeof y!="boolean"&&!Sh(y)){const x=Array.isArray(y)?y:[y];for(let w=0;w<x.length;w++){const j=gx(e,x[w]);if(j){const{transitionEnd:N,transition:k,...E}=j;for(const A in E){let S=E[A];if(Array.isArray(S)){const M=p?S.length-1:0;S=S[M]}S!==null&&(i[A]=S)}for(const A in N)i[A]=N[A]}}}return i}const eR=e=>(t,n)=>{const s=g.useContext(Eh),i=g.useContext(Nh),l=()=>uq(e,t,s,i);return n?l():Qy(l)},fq=eR({scrapeMotionValuesFromProps:kx,createRenderState:Cx}),hq=eR({scrapeMotionValuesFromProps:DM,createRenderState:QM}),mq=Symbol.for("motionComponentSymbol");function pq(e,t,n){const s=g.useRef(n);g.useInsertionEffect(()=>{s.current=n});const i=g.useRef(null);return g.useCallback(l=>{l&&e.onMount?.(l),t&&(l?t.mount(l):t.unmount());const c=s.current;if(typeof c=="function")if(l){const d=c(l);typeof d=="function"&&(i.current=d)}else i.current?(i.current(),i.current=null):c(l);else c&&(c.current=l)},[t])}const tR=g.createContext({});function Io(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function gq(e,t,n,s,i,l){const{visualElement:c}=g.useContext(Eh),d=g.useContext(GM),h=g.useContext(Nh),m=g.useContext(Ex),p=m.reducedMotion,y=m.skipAnimations,x=g.useRef(null),w=g.useRef(!1);s=s||d.renderer,!x.current&&s&&(x.current=s(e,{visualState:t,parent:c,props:n,presenceContext:h,blockInitialAnimation:h?h.initial===!1:!1,reducedMotionConfig:p,skipAnimations:y,isSVG:l}),w.current&&x.current&&(x.current.manuallyAnimateOnMount=!0));const j=x.current,N=g.useContext(tR);j&&!j.projection&&i&&(j.type==="html"||j.type==="svg")&&vq(x.current,n,i,N);const k=g.useRef(!1);g.useInsertionEffect(()=>{j&&k.current&&j.update(n,h)});const E=n[cM],A=g.useRef(!!E&&!window.MotionHandoffIsComplete?.(E)&&window.MotionHasOptimisedAnimation?.(E));return jT(()=>{w.current=!0,j&&(k.current=!0,window.MotionIsMounted=!0,j.updateFeatures(),j.scheduleRenderMicrotask(),A.current&&j.animationState&&j.animationState.animateChanges())}),g.useEffect(()=>{j&&(!A.current&&j.animationState&&j.animationState.animateChanges(),A.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(E)}),A.current=!1),j.enteringChildren=void 0)}),j}function vq(e,t,n,s){const{layoutId:i,layout:l,drag:c,dragConstraints:d,layoutScroll:h,layoutRoot:m,layoutCrossfade:p}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:nR(e.parent)),e.projection.setOptions({layoutId:i,layout:l,alwaysMeasureLayout:!!c||d&&Io(d),visualElement:e,animationType:typeof l=="string"?l:"both",initialPromotionConfig:s,crossfade:p,layoutScroll:h,layoutRoot:m})}function nR(e){if(e)return e.options.allowProjection!==!1?e.projection:nR(e.parent)}function kg(e,{forwardMotionProps:t=!1,type:n}={},s,i){s&&JH(s);const l=n?n==="svg":Ax(e),c=l?hq:fq;function d(m,p){let y;const x={...g.useContext(Ex),...m,layoutId:yq(m)},{isStatic:w}=x,j=sq(m),N=c(m,w);if(!w&&wT){xq();const k=bq(x);y=k.MeasureLayout,j.visualElement=gq(e,N,x,i,k.ProjectionNode,l)}return r.jsxs(Eh.Provider,{value:j,children:[y&&j.visualElement?r.jsx(y,{visualElement:j.visualElement,...x}):null,cq(e,m,pq(N,j.visualElement,p),N,w,t,l)]})}d.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const h=g.forwardRef(d);return h[mq]=e,h}function yq({layoutId:e}){const t=g.useContext(Jy).id;return t&&e!==void 0?t+"-"+e:e}function xq(e,t){g.useContext(GM).strict}function bq(e){const t=KM(),{drag:n,layout:s}=t;if(!n&&!s)return{};const i={...n,...s};return{MeasureLayout:n?.isEnabled(e)||s?.isEnabled(e)?i.MeasureLayout:void 0,ProjectionNode:i.ProjectionNode}}function wq(e,t){if(typeof Proxy>"u")return kg;const n=new Map,s=(l,c)=>kg(l,c,e,t),i=(l,c)=>s(l,c);return new Proxy(i,{get:(l,c)=>c==="create"?s:(n.has(c)||n.set(c,kg(c,void 0,e,t)),n.get(c))})}const jq=(e,t)=>t.isSVG??Ax(e)?new QF(t):new WF(t,{allowProjection:e!==g.Fragment});class Nq extends Vr{constructor(t){super(t),t.animationState||(t.animationState=aH(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Sh(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 Sq=0;class kq extends Vr{constructor(){super(...arguments),this.id=Sq++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===s)return;const i=this.node.animationState.setActive("exit",!t);n&&!t&&i.then(()=>{n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const Eq={animation:{Feature:Nq},exit:{Feature:kq}};function au(e){return{point:{x:e.pageX,y:e.pageY}}}const Cq=e=>t=>bx(t)&&e(t,au(t));function Mc(e,t,n,s){return Hc(e,t,Cq(n),s)}const sR=({current:e})=>e?e.ownerDocument.defaultView:null,VS=(e,t)=>Math.abs(e-t);function Aq(e,t){const n=VS(e.x,t.x),s=VS(e.y,t.y);return Math.sqrt(n**2+s**2)}const FS=new Set(["auto","scroll"]);class aR{constructor(t,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:l=!1,distanceThreshold:c=3,element:d}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=w=>{this.handleScroll(w.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const w=Cg(this.lastMoveEventInfo,this.history),j=this.startEvent!==null,N=Aq(w.offset,{x:0,y:0})>=this.distanceThreshold;if(!j&&!N)return;const{point:k}=w,{timestamp:E}=Mn;this.history.push({...k,timestamp:E});const{onStart:A,onMove:S}=this.handlers;j||(A&&A(this.lastMoveEvent,w),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,w)},this.handlePointerMove=(w,j)=>{this.lastMoveEvent=w,this.lastMoveEventInfo=Eg(j,this.transformPagePoint),zt.update(this.updatePoint,!0)},this.handlePointerUp=(w,j)=>{this.end();const{onEnd:N,onSessionEnd:k,resumeAnimation:E}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&E&&E(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const A=Cg(w.type==="pointercancel"?this.lastMoveEventInfo:Eg(j,this.transformPagePoint),this.history);this.startEvent&&N&&N(w,A),k&&k(w,A)},!bx(t))return;this.dragSnapToOrigin=l,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=c,this.contextWindow=i||window;const h=au(t),m=Eg(h,this.transformPagePoint),{point:p}=m,{timestamp:y}=Mn;this.history=[{...p,timestamp:y}];const{onSessionStart:x}=n;x&&x(t,Cg(m,this.history)),this.removeListeners=tu(Mc(this.contextWindow,"pointermove",this.handlePointerMove),Mc(this.contextWindow,"pointerup",this.handlePointerUp),Mc(this.contextWindow,"pointercancel",this.handlePointerUp)),d&&this.startScrollTracking(d)}startScrollTracking(t){let n=t.parentElement;for(;n;){const s=getComputedStyle(n);(FS.has(s.overflowX)||FS.has(s.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 s=t===window,i=s?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},l={x:i.x-n.x,y:i.y-n.y};l.x===0&&l.y===0||(s?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=l.x,this.lastMoveEventInfo.point.y+=l.y):this.history.length>0&&(this.history[0].x-=l.x,this.history[0].y-=l.y),this.scrollPositions.set(t,i),zt.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Rr(this.updatePoint)}}function Eg(e,t){return t?{point:t(e.point)}:e}function HS(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Cg({point:e},t){return{point:e,delta:HS(e,rR(t)),offset:HS(e,Tq(t)),velocity:Mq(t,.1)}}function Tq(e){return e[0]}function rR(e){return e[e.length-1]}function Mq(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const i=rR(e);for(;n>=0&&(s=e[n],!(i.timestamp-s.timestamp>Zs(t)));)n--;if(!s)return{x:0,y:0};s===e[0]&&e.length>2&&i.timestamp-s.timestamp>Zs(t)*2&&(s=e[1]);const l=Rs(i.timestamp-s.timestamp);if(l===0)return{x:0,y:0};const c={x:(i.x-s.x)/l,y:(i.y-s.y)/l};return c.x===1/0&&(c.x=0),c.y===1/0&&(c.y=0),c}function Rq(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?en(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?en(n,e,s.max):Math.min(e,n)),e}function qS(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 _q(e,{top:t,left:n,bottom:s,right:i}){return{x:qS(e.x,n,i),y:qS(e.y,t,s)}}function ZS(e,t){let n=t.min-e.min,s=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,s]=[s,n]),{min:n,max:s}}function Iq(e,t){return{x:ZS(e.x,t.x),y:ZS(e.y,t.y)}}function Oq(e,t){let n=.5;const s=Vn(e),i=Vn(t);return i>s?n=Uc(t.min,t.max-s,e.min):s>i&&(n=Uc(e.min,e.max-i,t.min)),ma(0,1,n)}function Dq(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 Kv=.35;function Pq(e=Kv){return e===!1?e=0:e===!0&&(e=Kv),{x:WS(e,"left","right"),y:WS(e,"top","bottom")}}function WS(e,t,n){return{min:YS(e,t),max:YS(e,n)}}function YS(e,t){return typeof e=="number"?e:e[t]||0}const zq=new WeakMap;class Lq{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=bn(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const l=y=>{n&&this.snapToCursor(au(y).point),this.stopAnimation()},c=(y,x)=>{const{drag:w,dragPropagation:j,onDragStart:N}=this.getProps();if(w&&!j&&(this.openDragLock&&this.openDragLock(),this.openDragLock=fF(w),!this.openDragLock))return;this.latestPointerEvent=y,this.latestPanInfo=x,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),aa(E=>{let A=this.getAxisMotionValue(E).get()||0;if(da.test(A)){const{projection:S}=this.visualElement;if(S&&S.layout){const M=S.layout.layoutBox[E];M&&(A=Vn(M)*(parseFloat(A)/100))}}this.originPoint[E]=A}),N&&zt.update(()=>N(y,x),!1,!0),Bv(this.visualElement,"transform");const{animationState:k}=this.visualElement;k&&k.setActive("whileDrag",!0)},d=(y,x)=>{this.latestPointerEvent=y,this.latestPanInfo=x;const{dragPropagation:w,dragDirectionLock:j,onDirectionLock:N,onDrag:k}=this.getProps();if(!w&&!this.openDragLock)return;const{offset:E}=x;if(j&&this.currentDirection===null){this.currentDirection=Uq(E),this.currentDirection!==null&&N&&N(this.currentDirection);return}this.updateAxis("x",x.point,E),this.updateAxis("y",x.point,E),this.visualElement.render(),k&&zt.update(()=>k(y,x),!1,!0)},h=(y,x)=>{this.latestPointerEvent=y,this.latestPanInfo=x,this.stop(y,x),this.latestPointerEvent=null,this.latestPanInfo=null},m=()=>{const{dragSnapToOrigin:y}=this.getProps();(y||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:p}=this.getProps();this.panSession=new aR(t,{onSessionStart:l,onStart:c,onMove:d,onSessionEnd:h,resumeAnimation:m},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,distanceThreshold:s,contextWindow:sR(this.visualElement),element:this.visualElement.current})}stop(t,n){const s=t||this.latestPointerEvent,i=n||this.latestPanInfo,l=this.isDragging;if(this.cancel(),!l||!i||!s)return;const{velocity:c}=i;this.startAnimation(c);const{onDragEnd:d}=this.getProps();d&&zt.postRender(()=>d(s,i))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:s}=this.getProps();!s&&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,s){const{drag:i}=this.getProps();if(!s||!zd(t,i,this.currentDirection))return;const l=this.getAxisMotionValue(t);let c=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(c=Rq(c,this.constraints[t],this.elastic[t])),l.set(c)}resolveConstraints(){const{dragConstraints:t,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;t&&Io(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=_q(s.layoutBox,t):this.constraints=!1,this.elastic=Pq(n),i!==this.constraints&&!Io(t)&&s&&this.constraints&&!this.hasMutatedConstraints&&aa(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=Dq(s.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Io(t))return!1;const s=t.current,{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const l=BF(s,i.root,this.visualElement.getTransformPagePoint());let c=Iq(i.layout.layoutBox,l);if(n){const d=n(LF(c));this.hasMutatedConstraints=!!d,d&&(c=EM(d))}return c}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:l,dragSnapToOrigin:c,onDragTransitionEnd:d}=this.getProps(),h=this.constraints||{},m=aa(p=>{if(!zd(p,n,this.currentDirection))return;let y=h&&h[p]||{};c&&(y={min:0,max:0});const x=i?200:1e6,w=i?40:1e7,j={type:"inertia",velocity:s?t[p]:0,bounceStiffness:x,bounceDamping:w,timeConstant:750,restDelta:1,restSpeed:10,...l,...y};return this.startAxisValueAnimation(p,j)});return Promise.all(m).then(d)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return Bv(this.visualElement,t),s.start(px(t,s,0,n,this.visualElement,!1))}stopAnimation(){aa(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,s=this.visualElement.getProps(),i=s[n];return i||this.visualElement.getValue(t,(s.initial?s.initial[t]:void 0)||0)}snapToCursor(t){aa(n=>{const{drag:s}=this.getProps();if(!zd(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,l=this.getAxisMotionValue(n);if(i&&i.layout){const{min:c,max:d}=i.layout.layoutBox[n],h=l.get()||0;l.set(t[n]-en(c,d,.5)+h)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Io(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};aa(c=>{const d=this.getAxisMotionValue(c);if(d&&this.constraints!==!1){const h=d.get();i[c]=Oq({min:h,max:h},this.constraints[c])}});const{transformTemplate:l}=this.visualElement.getProps();this.visualElement.current.style.transform=l?l({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.constraints=!1,this.resolveConstraints(),aa(c=>{if(!zd(c,t,null))return;const d=this.getAxisMotionValue(c),{min:h,max:m}=this.constraints[c];d.set(en(h,m,i[c]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;zq.set(this.visualElement,this);const t=this.visualElement.current,n=Mc(t,"pointerdown",m=>{const{drag:p,dragListener:y=!0}=this.getProps(),x=m.target,w=x!==t&&yF(x);p&&y&&!w&&this.start(m)});let s;const i=()=>{const{dragConstraints:m}=this.getProps();Io(m)&&m.current&&(this.constraints=this.resolveRefConstraints(),s||(s=$q(t,m.current,()=>this.scalePositionWithinConstraints())))},{projection:l}=this.visualElement,c=l.addEventListener("measure",i);l&&!l.layout&&(l.root&&l.root.updateScroll(),l.updateLayout()),zt.read(i);const d=Hc(window,"resize",()=>this.scalePositionWithinConstraints()),h=l.addEventListener("didUpdate",(({delta:m,hasLayoutChanged:p})=>{this.isDragging&&p&&(aa(y=>{const x=this.getAxisMotionValue(y);x&&(this.originPoint[y]+=m[y].translate,x.set(x.get()+m[y].translate))}),this.visualElement.render())}));return()=>{d(),n(),c(),h&&h(),s&&s()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:l=!1,dragElastic:c=Kv,dragMomentum:d=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:l,dragElastic:c,dragMomentum:d}}}function GS(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function $q(e,t,n){const s=nS(e,GS(n)),i=nS(t,GS(n));return()=>{s(),i()}}function zd(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Uq(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class Bq extends Vr{constructor(t){super(t),this.removeGroupControls=_s,this.removeListeners=_s,this.controls=new Lq(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||_s}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 Ag=e=>(t,n)=>{e&&zt.update(()=>e(t,n),!1,!0)};class Vq extends Vr{constructor(){super(...arguments),this.removePointerDownListener=_s}onPointerDown(t){this.session=new aR(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:sR(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:Ag(t),onStart:Ag(n),onMove:Ag(s),onEnd:(l,c)=>{delete this.session,i&&zt.postRender(()=>i(l,c))}}}mount(){this.removePointerDownListener=Mc(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 Tg=!1;class Fq extends g.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:l}=t;l&&(n.group&&n.group.add(l),s&&s.register&&i&&s.register(l),Tg&&l.root.didUpdate(),l.addEventListener("animationComplete",()=>{this.safeToRemove()}),l.setOptions({...l.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),pf.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:i,isPresent:l}=this.props,{projection:c}=s;return c&&(c.isPresent=l,t.layoutDependency!==n&&c.setOptions({...c.options,layoutDependency:n}),Tg=!0,i||t.layoutDependency!==n||n===void 0||t.isPresent!==l?c.willUpdate():this.safeToRemove(),t.isPresent!==l&&(l?c.promote():c.relegate()||zt.postRender(()=>{const d=c.getStack();(!d||!d.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),xx.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=t;Tg=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),s&&s.deregister&&s.deregister(i))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function iR(e){const[t,n]=YM(),s=g.useContext(Jy);return r.jsx(Fq,{...e,layoutGroup:s,switchLayoutGroup:g.useContext(tR),isPresent:t,safeToRemove:n})}const Hq={pan:{Feature:Vq},drag:{Feature:Bq,ProjectionNode:WM,MeasureLayout:iR}};function KS(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,l=s[i];l&&zt.postRender(()=>l(t,au(t)))}class qq extends Vr{mount(){const{current:t}=this.node;t&&(this.unmount=mF(t,(n,s)=>(KS(this.node,s,"Start"),i=>KS(this.node,i,"End"))))}unmount(){}}class Zq extends Vr{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=tu(Hc(this.node.current,"focus",()=>this.onFocus()),Hc(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function XS(e,t,n){const{props:s}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),l=s[i];l&&zt.postRender(()=>l(t,au(t)))}class Wq extends Vr{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:s}=this.node.props;this.unmount=bF(t,(i,l)=>(XS(this.node,l,"Start"),(c,{success:d})=>XS(this.node,c,d?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:s?.tap===!1})}unmount(){}}const Xv=new WeakMap,Mg=new WeakMap,Yq=e=>{const t=Xv.get(e.target);t&&t(e)},Gq=e=>{e.forEach(Yq)};function Kq({root:e,...t}){const n=e||document;Mg.has(n)||Mg.set(n,{});const s=Mg.get(n),i=JSON.stringify(t);return s[i]||(s[i]=new IntersectionObserver(Gq,{root:e,...t})),s[i]}function Xq(e,t,n){const s=Kq(t);return Xv.set(e,n),s.observe(e),()=>{Xv.delete(e),s.unobserve(e)}}const Jq={some:0,all:1};class Qq extends Vr{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:l}=t,c={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:Jq[i]},d=h=>{const{isIntersecting:m}=h;if(this.isInView===m||(this.isInView=m,l&&!m&&this.hasEnteredView))return;m&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",m);const{onViewportEnter:p,onViewportLeave:y}=this.node.getProps(),x=m?p:y;x&&x(h)};return Xq(this.node.current,c,d)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(eZ(t,n))&&this.startObserver()}unmount(){}}function eZ({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const tZ={inView:{Feature:Qq},tap:{Feature:Wq},focus:{Feature:Zq},hover:{Feature:qq}},nZ={layout:{ProjectionNode:WM,MeasureLayout:iR}},sZ={...Eq,...tZ,...Hq,...nZ},aZ=wq(sZ,jq);function rZ(e){return"type"in e&&e.type==="separator"}function iZ(e){return"type"in e&&e.type==="group"}function JS({item:e}){return r.jsxs(O8,{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&&r.jsx("span",{className:"w-4 h-4 flex items-center justify-center text-muted-foreground",children:e.icon}),r.jsx("span",{className:"flex-1",children:e.label}),e.shortcut&&r.jsx("span",{className:"text-muted-foreground text-[10px] ml-4 tracking-wider",children:e.shortcut})]})}const oR=Po.forwardRef(({items:e},t)=>r.jsx(aZ.div,{ref:t,initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.1,ease:"easeOut"},children:r.jsx(M9,{className:"bg-popover/95 backdrop-blur-xl border border-border/60 rounded-lg shadow-2xl py-1 min-w-[180px] z-[200] outline-none",children:e.map((n,s)=>rZ(n)?r.jsx(oV,{className:"h-px bg-border/60 my-1"},`sep-${s}`):iZ(n)?r.jsxs(_8,{children:[r.jsx(I8,{className:"px-3 py-1 text-[10px] font-mono uppercase tracking-widest text-muted-foreground",children:n.label}),n.items.map(i=>r.jsx(JS,{item:i},i.id))]},`grp-${s}`):r.jsx(JS,{item:n},n.id))})}));oR.displayName="PopupContent";function oZ({items:e,children:t}){return e.length===0?r.jsx(r.Fragment,{children:t}):r.jsxs(lV,{children:[r.jsx(cV,{render:r.jsx("div",{style:{display:"contents"}}),children:t}),r.jsx(_9,{children:r.jsx(q9,{className:"z-[200]",sideOffset:4,children:r.jsx(KH,{children:r.jsx(oR,{items:e})})})})]})}const QS=()=>{},lZ={x:0,y:0},cZ=({children:e,hud:t,mode:n="canvas",panOffset:s=lZ,scale:i=1,onPan:l=QS,onZoom:c=QS,onPanStart:d,onPanEnd:h,isTransitioning:m=!1,onViewportChange:p,onCanvasClick:y,canvasProps:x,zoomSensitivity:w,zoomControlsRightOffset:j,canvasContextMenuItems:N})=>{const k=g.useRef(null),E=g.useRef(i);E.current=i;const A=g.useRef(c);A.current=c;const S=g.useRef(l);S.current=l;const M=g.useRef(d);M.current=d;const C=g.useRef(h);C.current=h;const I=g.useRef(w);I.current=w;const[R,D]=g.useState(!1),z=g.useRef(!1),[O,_]=g.useState(!1),U=g.useRef(!1),q=g.useRef({x:0,y:0}),G=g.useRef(L=>{const F=L.target||document.activeElement;if(!F)return!1;const H=F.tagName;return!!(H==="INPUT"||H==="TEXTAREA"||F.isContentEditable||F.closest?.(".xterm"))});g.useEffect(()=>{if(n!=="canvas")return;const L=V=>{V.key!==" "||V.repeat||G.current(V)||m||(V.preventDefault(),z.current=!0,D(!0))},F=V=>{V.key===" "&&z.current&&(z.current=!1,D(!1),U.current&&(U.current=!1,_(!1),C.current?.()))},H=()=>{z.current&&(z.current=!1,D(!1),U.current&&(U.current=!1,_(!1),C.current?.()))};return window.addEventListener("keydown",L),window.addEventListener("keyup",F),window.addEventListener("blur",H),()=>{window.removeEventListener("keydown",L),window.removeEventListener("keyup",F),window.removeEventListener("blur",H)}},[n,m]);const X=g.useCallback(L=>{L.button===0&&(L.preventDefault(),U.current=!0,_(!0),q.current={x:L.clientX,y:L.clientY},M.current?.())},[]);return g.useEffect(()=>{if(!R)return;const L=H=>{if(!U.current)return;const V=(H.clientX-q.current.x)/E.current,W=(H.clientY-q.current.y)/E.current;q.current={x:H.clientX,y:H.clientY},S.current({x:V,y:W})},F=()=>{U.current&&(U.current=!1,_(!1),C.current?.())};return window.addEventListener("mousemove",L),window.addEventListener("mouseup",F),()=>{window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",F)}},[R]),g.useEffect(()=>{if(n!=="canvas")return;const L=F=>{if(F.ctrlKey||F.metaKey){F.preventDefault();const H=E.current,V=-F.deltaY*.001*(I.current??1),W=Math.min(Math.max(.2,H+V),3);E.current=W,A.current(W)}};return window.addEventListener("wheel",L,{passive:!1}),()=>window.removeEventListener("wheel",L)},[n]),g.useEffect(()=>{if(!p)return;let L=null;const F=()=>{L&&cancelAnimationFrame(L),L=requestAnimationFrame(()=>{p({width:window.innerWidth,height:window.innerHeight})})};return F(),window.addEventListener("resize",F),()=>{window.removeEventListener("resize",F),L&&cancelAnimationFrame(L)}},[p]),n==="panel"?r.jsxs("div",{ref:k,className:"fixed inset-0 bg-background text-foreground overflow-hidden font-sans select-none z-0",children:[r.jsx("div",{className:"absolute inset-0 z-10 overflow-auto frame-scrollbar",children:e}),r.jsx("div",{className:"fixed inset-0 z-50 pointer-events-none overflow-hidden",children:t})]}):r.jsxs("div",{ref:k,className:"fixed inset-0 bg-background text-foreground overflow-hidden font-sans select-none z-0",children:[r.jsx(oZ,{items:N??[],children:r.jsx(lA,{panOffset:s,scale:i,onPan:l,onPanStart:d,onPanEnd:h,isPanLocked:m,onClick:y,showGuides:x?.showGuides,onGuidesChange:x?.onGuidesChange,gridOpacity:x?.gridOpacity})}),r.jsx("div",{className:"absolute z-10 pointer-events-none",style:{left:"50%",top:"50%",zoom:i},children:r.jsx("div",{style:{position:"absolute",left:s.x,top:s.y},children:e})}),R&&r.jsx("div",{className:`fixed inset-0 z-20 ${O?"cursor-grabbing":"cursor-grab"}`,onMouseDown:X}),r.jsx("div",{className:"fixed bottom-[36px] z-30",style:{right:(j??280)+16},children:r.jsx(N6,{scale:i,onZoom:L=>c(L)})}),r.jsx("div",{className:"fixed inset-0 z-50 pointer-events-none overflow-hidden",children:t})]})},xo=4e3,uZ=Po.forwardRef(({pan:e,zoom:t,viewportSize:n,height:s,onClick:i,children:l},c)=>{const[d,h]=Po.useState(0),m=g.useRef(null),p=Po.useCallback(A=>{m.current=A,typeof c=="function"?c(A):c&&(c.current=A)},[c]);Po.useEffect(()=>{const A=m.current;if(!A)return;const S=new ResizeObserver(([M])=>h(M.contentRect.width));return S.observe(A),()=>S.disconnect()},[]);const y=d||260,x=n.width/t/xo*y,w=n.height/t/xo*s,j=(-e.x+xo/2)/xo*y,N=(-e.y+xo/2)/xo*s,k=j-x/2,E=N-w/2;return r.jsxs("div",{ref:p,className:"relative cursor-crosshair overflow-hidden",style:{height:`${s}px`},onClick:i,children:[r.jsx("div",{className:"absolute inset-0 opacity-30",style:{backgroundImage:"radial-gradient(circle, var(--hud-canvas-dot-major) 0.5px, transparent 0.5px)",backgroundSize:"14px 14px"}}),r.jsx("div",{className:"absolute top-1/2 left-0 right-0 h-px bg-border/60"}),r.jsx("div",{className:"absolute left-1/2 top-0 bottom-0 w-px bg-border/60"}),r.jsxs("div",{className:"absolute border border-accent/50 bg-accent/10 rounded-[1px] transition-all duration-75 ease-out",style:{left:`${k}px`,top:`${E}px`,width:`${Math.max(x,4)}px`,height:`${Math.max(w,4)}px`},children:[r.jsx("div",{className:"absolute -top-[1px] -left-[1px] w-[3px] h-[3px] bg-accent rounded-full"}),r.jsx("div",{className:"absolute -top-[1px] -right-[1px] w-[3px] h-[3px] bg-accent rounded-full"}),r.jsx("div",{className:"absolute -bottom-[1px] -left-[1px] w-[3px] h-[3px] bg-accent rounded-full"}),r.jsx("div",{className:"absolute -bottom-[1px] -right-[1px] w-[3px] h-[3px] bg-accent rounded-full"})]}),l]})});uZ.displayName="MinimapCanvas";const dZ=({title:e,subtitle:t,center:n,actions:s,onTitleClick:i,search:l})=>{const{dragRegionProps:c,onInteractiveMouseDown:d}=Jc(),{navTotalHeight:h}=Dy(),m=l&&l.value&&l.value.length>0;return r.jsx("div",{"data-frame-panel":"navigation",className:"fixed top-0 left-0 right-0 z-50 pointer-events-auto",...c,children:r.jsxs("div",{className:"bg-background/95 backdrop-blur-xl border-b border-border/80 shadow-[var(--hud-shadow-nav)] flex items-end px-4",style:{height:h},children:[r.jsx("div",{className:"absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-foreground/8 to-transparent"}),r.jsxs("div",{className:"absolute left-4 bottom-0 h-12 z-10 flex items-center gap-3 select-none",onMouseDown:d,children:[r.jsx("button",{onClick:i,className:"text-[22px] font-bold text-foreground tracking-[0.25em] font-mono leading-none bg-transparent border-none cursor-pointer focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none rounded",children:e}),t&&r.jsx("span",{className:"text-xs font-mono text-muted-foreground",children:t})]}),n&&r.jsx("div",{className:"flex-1 flex justify-center h-12 items-center",onMouseDown:d,children:n}),r.jsxs("div",{className:"absolute right-4 bottom-0 h-12 z-10 flex items-center gap-3",onMouseDown:d,children:[s,l&&r.jsxs("div",{className:"relative w-[220px] 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:ring-1 focus-within:ring-ring/30 focus-within:bg-card transition-all duration-200",children:[r.jsx(Iy,{size:11,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),r.jsx("input",{type:"text",value:l.value,onChange:p=>l.onChange(p.target.value),placeholder:l.placeholder??"Search...",className:`
|
|
131
|
-
w-full h-7 pl-5 pr-6 bg-transparent text-[12px] font-mono tracking-wider
|
|
132
|
-
placeholder:text-muted-foreground text-foreground
|
|
133
|
-
focus:outline-none transition-all duration-200
|
|
134
|
-
${m?"text-accent":""}
|
|
135
|
-
`}),m&&r.jsx("button",{onClick:()=>l.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:r.jsx(oA,{size:12})})]})]})]})})},ek=({side:e,title:t,icon:n,isCollapsed:s=!1,onToggleCollapse:i,headerActions:l,footer:c,style:d,width:h,onResizeStart:m,children:p})=>{if(s){const E=e==="left"?W$:X$;return r.jsx("button",{onClick:i,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 border-border/80 hover:border-accent/60 backdrop-blur-xl shadow-[0_0_20px_rgba(0,0,0,0.5),inset_0_1px_0_rgba(255,255,255,0.08)] hover:shadow-[0_0_30px_rgba(16,185,129,0.2),inset_0_1px_0_rgba(255,255,255,0.1)] 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`,title:`Expand ${t||"panel"}`,children:r.jsx(E,{size:14,className:"text-muted-foreground group-hover:text-accent transition-colors",strokeWidth:1.5})})}const y=e==="left"?q$:G$,{panelTopOffset:x}=Dy(),N=`bg-card/95 backdrop-blur-xl border border-border/80 shadow-[0_0_30px_rgba(0,0,0,0.8),inset_0_1px_0_rgba(255,255,255,0.08)] fixed bottom-[28px] z-40 rounded-none border-t-0 overflow-hidden ${e==="left"?"border-l-0 border-r-0":"border-r-0 border-l-0"}`,k={...d,position:"fixed",top:x,left:e==="left"?0:void 0,right:e==="right"?0:void 0,width:`${h||280}px`};return r.jsxs("div",{"data-frame-panel":e==="left"?"manifest":"inspector",className:`${N} pointer-events-none select-none font-mono text-[11px] flex flex-col`,style:k,children:[m&&r.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:m,children:[r.jsx("div",{className:`absolute top-0 bottom-0 ${e==="left"?"right-0":"left-0"} w-px bg-border/80 group-hover:bg-accent/50 transition-colors`}),r.jsxs("div",{className:"flex flex-col gap-[3px] opacity-0 group-hover:opacity-100 transition-opacity",children:[r.jsx("div",{className:"w-[3px] h-[3px] rounded-full bg-muted-foreground/70 group-hover:bg-accent/70"}),r.jsx("div",{className:"w-[3px] h-[3px] rounded-full bg-muted-foreground/70 group-hover:bg-accent/70"}),r.jsx("div",{className:"w-[3px] h-[3px] rounded-full bg-muted-foreground/70 group-hover:bg-accent/70"})]})]}),!m&&r.jsx("div",{className:`absolute top-0 ${e==="left"?"right-0":"left-0"} bottom-0 w-px bg-border/80`}),r.jsx("div",{className:"absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-foreground/12 to-transparent z-10"}),r.jsxs("div",{className:"pointer-events-auto flex-1 flex flex-col overflow-hidden",children:[t&&r.jsx("div",{className:"shrink-0 p-4 border-b border-border/60",children:r.jsxs("div",{className:"flex items-center justify-between text-foreground text-[12px]",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[n&&r.jsx("span",{className:"text-muted-foreground",children:n}),r.jsx("span",{className:"tracking-widest font-bold uppercase",children:t})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[l,i&&r.jsx("button",{onClick:i,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:r.jsx(y,{size:12})})]})]})}),r.jsx("div",{className:"flex-1 overflow-y-auto frame-scrollbar",children:p}),c&&r.jsx("div",{className:"shrink-0",children:c})]})]})},fZ={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"}},hZ=({left:e,viewport:t,right:n,isMinimapCollapsed:s=!1,onExpandMinimap:i,status:l={label:"READY",color:"emerald"},onToggleTerminal:c,isTerminalOpen:d=!1})=>{const[h,m]=g.useState(new Date),[p,y]=g.useState(!1),[x,w]=g.useState(!1);g.useEffect(()=>{w(!0);const k=setInterval(()=>m(new Date),1e3);return()=>clearInterval(k)},[]);const j=fZ[l.color],N=async()=>{if(!t)return;const k=`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(k),y(!0),setTimeout(()=>y(!1),1500)}catch{}};return r.jsxs("div",{"data-frame-panel":"status-bar",className:`${i$.statusBar} h-7 flex items-center justify-between px-3 select-none font-mono text-[12px] text-foreground pointer-events-auto`,children:[r.jsxs("div",{className:"flex items-center gap-4",children:[s&&i&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 px-2 py-0.5 rounded bg-muted/60 border border-border/70 hover:bg-muted transition-colors text-muted-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",title:"Expand minimap",children:[r.jsx(P$,{size:10}),r.jsx("span",{className:"text-[11px] font-bold",children:"MAP"}),r.jsx(rA,{size:8,className:"opacity-60"})]}),r.jsx("div",{className:"h-3 w-px bg-border"})]}),r.jsxs("div",{className:`flex items-center gap-2 ${j.text}`,children:[r.jsxs("div",{className:"relative flex h-2 w-2",children:[r.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full ${j.ping} opacity-75`}),r.jsx("span",{className:`relative inline-flex rounded-full h-2 w-2 ${j.dot}`})]}),r.jsx("span",{className:"font-bold tracking-wider",children:l.label})]}),e&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"h-3 w-px bg-border"}),e]})]}),t&&r.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 flex items-center gap-3 opacity-70 hover:opacity-100 transition-opacity",children:r.jsxs("button",{onClick:N,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:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"text-muted-foreground",children:"PAN:"}),r.jsxs("span",{className:`tabular-nums ${p?"text-accent":""}`,children:[t.pan.x.toFixed(0),",",t.pan.y.toFixed(0)]})]}),r.jsx("div",{className:"h-3 w-px bg-border"}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"text-muted-foreground",children:"SIZE:"}),r.jsxs("span",{className:`tabular-nums ${p?"text-accent":""}`,children:[t.canvasSize?.w??1024,"x",t.canvasSize?.h??1024]})]}),r.jsx("div",{className:"h-3 w-px bg-border"}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"text-muted-foreground",children:"ZOOM:"}),r.jsxs("span",{className:`tabular-nums ${p?"text-accent":""}`,children:[(t.zoom*100).toFixed(0),"%"]})]})]})}),r.jsxs("div",{className:"flex items-center gap-4",children:[n,n&&r.jsx("div",{className:"h-3 w-px bg-border"}),c&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{onClick:c,className:`flex items-center gap-1.5 px-2 py-1 rounded transition-all focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none ${d?"bg-accent/10 text-accent border border-accent/30":"text-muted-foreground hover:text-foreground hover:bg-muted/70 border border-transparent"}`,title:"Toggle Terminal (Ctrl+`)",children:[r.jsxs("span",{className:"text-[12px]",children:[">","_"]}),r.jsx("span",{className:"uppercase text-[11px] font-semibold tracking-wider",children:"Console"})]}),r.jsx("div",{className:"h-3 w-px bg-border"})]}),r.jsxs("div",{className:"flex items-center gap-1.5 text-foreground min-w-[60px] justify-end",children:[r.jsx(R$,{size:11,className:"text-muted-foreground"}),r.jsx("span",{children:x?h.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"--:--"})]})]})]})},mZ=({onOpenCommandPalette:e,extraControls:t})=>r.jsx("div",{className:"select-none font-mono text-[12px] border-t border-border/60",children:r.jsxs("div",{className:"px-3 py-2 flex items-center justify-between",children:[r.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:[r.jsx(Iy,{size:10}),r.jsx("span",{className:"tracking-widest font-bold uppercase",children:"Command Palette"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[t,r.jsx("kbd",{className:"text-[11px] text-muted-foreground font-mono",children:"⌘K"})]})]})}),{statusBarHeight:Ld}=fh.layout,tk=120,pZ=({isOpen:e,onClose:t,onToggleMaximize:n,isMaximized:s=!1,height:i=320,onHeightChange:l,title:c,headerActions:d,children:h})=>{const m=g.useRef(!1),p=g.useRef(null),y=g.useCallback(w=>{if(!l)return;w.preventDefault(),m.current=!0;const j=w.clientY,N=i;p.current&&(p.current.style.transition="none");const k=A=>{const S=j-A.clientY,M=window.innerHeight-Ld,C=Math.max(tk,Math.min(M,N+S));p.current&&(p.current.style.height=`${C}px`)},E=A=>{m.current=!1,document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",E),p.current&&(p.current.style.transition="");const S=j-A.clientY,M=window.innerHeight-Ld;l(Math.max(tk,Math.min(M,N+S)))};document.addEventListener("mousemove",k),document.addEventListener("mouseup",E)},[i,l]),x=s?`calc(100vh - ${Ld}px)`:`${i}px`;return r.jsxs("div",{ref:p,className:`
|
|
136
|
-
fixed left-0 right-0 shadow-[0_-10px_40px_rgba(0,0,0,0.8)] flex flex-col border-t border-border
|
|
137
|
-
bg-card/95 backdrop-blur-xl
|
|
138
|
-
${e?"translate-y-0 opacity-100 pointer-events-auto":"translate-y-full opacity-0 pointer-events-none"}
|
|
139
|
-
transition-all duration-300 ease-in-out
|
|
140
|
-
`,style:{bottom:Ld,height:x,zIndex:fh.zIndex.drawer},children:[r.jsxs("div",{className:"h-9 bg-card/80 border-b border-border flex items-center justify-between px-3 shrink-0 select-none backdrop-blur-sm",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[c||r.jsxs("div",{className:"flex items-center gap-2 text-accent",children:[r.jsx(o6,{size:14}),r.jsx("span",{className:"text-xs font-bold tracking-widest font-mono",children:"TERMINAL"})]}),d]}),r.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:y,children:r.jsx("div",{className:"w-16 h-1 rounded-full bg-border group-hover:bg-muted-foreground transition-colors"})}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:n,className:"p-1.5 rounded hover:bg-accent/10 text-muted-foreground hover:text-foreground transition-colors",title:s?"Restore":"Maximize",children:s?r.jsx(B$,{size:14}):r.jsx(rA,{size:14})}),r.jsx("button",{onClick:t,className:"p-1.5 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors",title:"Close",children:r.jsx(oA,{size:14})})]})]}),r.jsx("div",{className:"flex-1 relative overflow-hidden flex flex-col bg-transparent",children:h})]})},gZ=({isOpen:e,onClose:t,commands:n})=>{const[s,i]=g.useState(""),[l,c]=g.useState(0),d=g.useRef(null),h=g.useRef(null),m=n.filter(y=>y.label.toLowerCase().includes(s.toLowerCase()));g.useEffect(()=>{e&&(setTimeout(()=>d.current?.focus(),10),i(""),c(0))},[e]),g.useEffect(()=>{c(0)},[s]),g.useEffect(()=>{h.current?.scrollIntoView({behavior:"smooth",block:"nearest"})},[l]);const p=y=>{if((y.key==="ArrowDown"||y.key==="ArrowUp")&&m.length===0){y.preventDefault();return}y.key==="ArrowDown"?(y.preventDefault(),c(x=>(x+1)%m.length)):y.key==="ArrowUp"?(y.preventDefault(),c(x=>(x-1+m.length)%m.length)):y.key==="Enter"?(y.preventDefault(),m[l]&&(m[l].action(),t())):y.key==="Escape"&&t()};return e?r.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:r.jsxs("div",{className:"w-[640px] max-w-[90vw] bg-popover border border-border shadow-2xl rounded-lg overflow-hidden flex flex-col animate-in fade-in zoom-in-95 duration-100",onClick:y=>y.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center px-4 py-3 border-b border-border gap-3 focus-within:ring-2 focus-within:ring-ring focus-within:outline-none",children:[r.jsx(Iy,{className:"text-muted-foreground",size:18}),r.jsx("input",{ref:d,className:"flex-1 bg-transparent border-none outline-none text-popover-foreground placeholder:text-muted-foreground font-mono text-sm",placeholder:"Type a command or search...",value:s,onChange:y=>i(y.target.value),onKeyDown:p,autoFocus:!0}),r.jsx("div",{className:"px-1.5 py-0.5 rounded bg-muted border border-border text-[12px] text-muted-foreground font-mono",children:"ESC"})]}),r.jsxs("div",{className:"max-h-[300px] overflow-y-auto py-2 relative",children:[r.jsx("div",{className:"pb-2",children:m.length===0?r.jsx("div",{className:"px-4 py-8 text-center text-muted-foreground text-xs font-mono",children:"No matching commands"}):m.map((y,x)=>r.jsxs("div",{ref:x===l?h: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 ${x===l?"bg-accent/10 border-l-2 border-accent":"border-l-2 border-transparent hover:bg-muted/70"}`,onClick:()=>{y.action(),t()},onMouseEnter:()=>c(x),children:[y.icon&&r.jsx("div",{className:`${x===l?"text-accent":"text-muted-foreground"}`,children:y.icon}),r.jsx("div",{className:"flex-1",children:r.jsx("div",{className:`text-sm ${x===l?"text-accent":"text-popover-foreground"}`,children:y.label})}),y.shortcut&&r.jsx("div",{className:"text-[12px] font-mono text-muted-foreground bg-muted px-1.5 py-0.5 rounded border border-border",children:y.shortcut}),x===l&&r.jsx(I$,{size:14,className:"text-accent ml-2"})]},y.id))}),m.length>6&&r.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-8 bg-gradient-to-t from-popover to-transparent pointer-events-none"})]}),r.jsxs("div",{className:"px-4 py-1.5 bg-card/90 backdrop-blur-sm border-t border-border flex justify-between items-center text-[12px] text-muted-foreground font-mono relative z-10",children:[r.jsx("span",{children:"Command Palette"}),r.jsxs("span",{children:[m.length," matches"]})]})]})}):null},lR=g.createContext(null),cR=g.createContext(null);function vZ({children:e}){const[t,n]=g.useState(null);return r.jsx(lR.Provider,{value:t,children:r.jsx(cR.Provider,{value:n,children:e})})}function yZ(){return g.useContext(lR)}function xZ(e){const t=g.useContext(cR);g.useEffect(()=>{if(t)return t(e),()=>{t(n=>n?.id===e?.id?null:n)}},[e,t])}const Rg=new Map;function _g(e){if(e)return JSON.parse(e)}function bZ(e){return e?JSON.stringify([...new Headers(e).entries()].sort(([t],[n])=>t.localeCompare(n))):""}function wZ(e,t){return`${(t?.method??"GET").toUpperCase()}:${e}:${bZ(t?.headers)}`}async function nk(e,t){const n=await fetch(e,{...t,headers:{...t?.headers??{},...t?.body?{"content-type":"application/json"}:{}}});if(!n.ok){const s=await n.text();let i=s||`HTTP ${n.status}`;try{const l=JSON.parse(s);l?.error&&(i=l.error)}catch{}throw new Error(i)}return await n.text()}async function ke(e,t){if(!((t?.method??"GET").toUpperCase()==="GET"&&!t?.body))return _g(await nk(e,t));const i=wZ(e,t),l=Rg.get(i);if(l)return _g(await l);const c=nk(e,t);Rg.set(i,c);try{return _g(await c)}finally{Rg.delete(i)}}function ru(){return!(typeof window>"u"||new URLSearchParams(window.location.search).has("no-ops"))}function jZ(e){switch(e){case"profile":case"observe":case"message":return e;default:return}}function NZ(e){switch(e){case"command":return"command";case"warroom":return"command";case"control":case"mission":return"mission";case"conduct":case"conductor":return"conductor";case"plan":case"agents":case"tail":case"atop":return e;default:return}}function SZ(e){switch(e){case"tail":case"session":case"chat":case"work":return e;default:return}}function sk(e){switch(e){case"command":return"command";case"mission":return"control";case"conductor":return"conduct";default:return e}}function kZ(e){return e.searchParams.has("no-ops")?!1:typeof window>"u"?!0:ru()}function EZ(e){const t=new URL(e.toString()),n=t.pathname.replace(/^\/+/,"").split("/").filter(Boolean),s=t.searchParams.get("compose")==="ask"?"ask":void 0,i=jZ(t.searchParams.get("tab"));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{view:"agents",agentId:decodeURIComponent(n[1]),conversationId:decodeURIComponent(n[3]),tab:i??"message"};if(n[0]==="agents"&&n[1]){const l=decodeURIComponent(n[1]);return i==="message"?{view:"agents",agentId:l,conversationId:Nn(l),tab:"message"}:{view:"agents",agentId:l,...i?{tab:i}:{}}}if(n[0]==="agents")return{view:"agents"};if(n[0]==="fleet")return{view:"fleet"};if(n[0]==="c"&&n[1])return{view:"conversation",conversationId:decodeURIComponent(n[1]),...s?{composeMode:s}:{}};if(n[0]==="sessions"&&n[1])return{view:"sessions",sessionId:decodeURIComponent(n[1])};if(n[0]==="conversations")return{view:"conversations"};if(n[0]==="sessions")return{view:"sessions"};if(n[0]==="channels"&&n[1])return{view:"channels",channelId:decodeURIComponent(n[1])};if(n[0]==="channels")return{view:"channels"};if(n[0]==="mesh")return{view:"mesh"};if(n[0]==="broker")return{view:"broker"};if(n[0]==="activity")return{view:"activity"};if(n[0]==="work"&&n[1])return{view:"work",workId:decodeURIComponent(n[1])};if(n[0]==="follow"){const l=SZ(t.searchParams.get("view")),c={view:"follow",...l?{preferredView:l}:{}},d=n[1],h=n[2]?decodeURIComponent(n[2]):"";d==="flight"&&h&&(c.flightId=h),d==="invocation"&&h&&(c.invocationId=h),d==="conversation"&&h&&(c.conversationId=h),d==="work"&&h&&(c.workId=h),d==="session"&&h&&(c.sessionId=h),d==="agent"&&h&&(c.targetAgentId=h);const m=t.searchParams.get("flightId"),p=t.searchParams.get("invocationId"),y=t.searchParams.get("conversationId"),x=t.searchParams.get("workId"),w=t.searchParams.get("sessionId"),j=t.searchParams.get("targetAgentId");return m&&(c.flightId=m),p&&(c.invocationId=p),y&&(c.conversationId=y),x&&(c.workId=x),w&&(c.sessionId=w),j&&(c.targetAgentId=j),c}if(n[0]==="settings")return{view:"settings"};if(n[0]==="terminal")return{view:"terminal",...n[1]?{agentId:decodeURIComponent(n[1])}:{}};if(n[0]==="ops"){if(!kZ(t))return{view:"inbox"};const l=NZ(n[1]);if(l){const c=l==="tail"?t.searchParams.get("q")?.trim():"";return{view:"ops",mode:l,...c?{tailQuery:c}:{}}}return{view:"ops"}}return{view:"inbox"}}function Ig(){return EZ(window.location.href)}function CZ(e){switch(e.view){case"inbox":return"/";case"conversation":{const t=new URLSearchParams;e.composeMode==="ask"&&t.set("compose","ask");const n=t.toString();return`/c/${encodeURIComponent(e.conversationId)}${n?`?${n}`:""}`}case"agent-info":return`/agent/${encodeURIComponent(e.conversationId)}`;case"agents":{const t=new URLSearchParams,n=!!e.agentId&&!!e.conversationId&&e.conversationId===Nn(e.agentId),s=n?"profile":e.conversationId?"message":"profile";n?t.set("tab",e.tab??"message"):e.tab&&e.tab!==s&&t.set("tab",e.tab);const i=t.toString();return`${e.agentId?n?`/agents/${encodeURIComponent(e.agentId)}`:e.conversationId?`/agents/${encodeURIComponent(e.agentId)}/c/${encodeURIComponent(e.conversationId)}`:`/agents/${encodeURIComponent(e.agentId)}`:"/agents"}${i?`?${i}`:""}`}case"fleet":return"/fleet";case"conversations":return"/conversations";case"sessions":return e.sessionId?`/sessions/${encodeURIComponent(e.sessionId)}`:"/sessions";case"channels":return e.channelId?`/channels/${encodeURIComponent(e.channelId)}`:"/channels";case"mesh":return"/mesh";case"broker":return"/broker";case"activity":return"/activity";case"work":return`/work/${encodeURIComponent(e.workId)}`;case"settings":return"/settings";case"ops":return e.mode?e.mode==="tail"&&e.tailQuery?`/ops/${sk(e.mode)}?q=${encodeURIComponent(e.tailQuery)}`:`/ops/${sk(e.mode)}`:"/ops";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.agentId?`/terminal/${encodeURIComponent(e.agentId)}`:"/terminal"}}function Og(e){switch(e.view){case"conversation":return`conv:${e.conversationId}`;case"agent-info":return`agent-info:${e.conversationId}`;case"agents":return e.conversationId?`agent-conv:${e.conversationId}:${e.tab??"message"}`:e.agentId?`agent:${e.agentId}:${e.tab??"profile"}`:"agents";case"sessions":return e.sessionId?`session:${e.sessionId}`:"sessions";case"channels":return e.channelId?`channel:${e.channelId}`:"channels";case"work":return`work:${e.workId}`;case"ops":return`ops:${e.mode??"plan"}:${e.tailQuery??""}`;case"follow":return`follow:${e.flightId??e.invocationId??e.conversationId??e.workId??e.sessionId??e.targetAgentId??""}:${e.preferredView??""}`;default:return e.view}}function AZ(){const[e,t]=g.useState(Ig),n=g.useRef({});g.useEffect(()=>{const i=()=>{const l=Ig();t(l),requestAnimationFrame(()=>{window.scrollTo(0,n.current[Og(l)]??0)})};return window.addEventListener("popstate",i),()=>window.removeEventListener("popstate",i)},[]);const s=g.useCallback(i=>{const l=i.view==="ops"&&!ru()?{view:"inbox"}:i;n.current[Og(Ig())]=window.scrollY,window.history.pushState(null,"",CZ(l)),t(l),requestAnimationFrame(()=>{window.scrollTo(0,n.current[Og(l)]??0)})},[]);return{route:e,navigate:s}}function uR(e){const t=e.match(/^dm\.operator\.(.+)$/);return t?t[1]:null}function Nn(e){return`dm.operator.${e}`}const TZ=["hello","node.upserted","actor.registered","agent.registered","agent.endpoint.upserted","conversation.upserted","binding.upserted","message.posted","invocation.requested","flight.updated","delivery.planned","delivery.attempted","delivery.state.changed","collaboration.upserted","collaboration.event.appended","scout.dispatched"],wi=new Set;let Rc=null,La=null,Kf=0;function MZ(e){try{return JSON.parse(e)}catch{return{kind:"unknown"}}}function dR(){Rc?.close(),Rc=null}function RZ(){if(La||wi.size===0)return;Kf++;const e=Math.min(3e3*2**(Kf-1),6e4);La=setTimeout(()=>{La=null,wi.size>0&&fR()},e)}function _Z(e){for(const t of[...wi])t(e)}function fR(){if(Rc||wi.size===0)return;const e=new EventSource("/api/events");Rc=e;const t=n=>{_Z(MZ(n.data))};e.onopen=()=>{Kf=0},e.onmessage=t;for(const n of TZ)e.addEventListener(n,t);e.onerror=()=>{Rc===e?dR():e.close(),RZ()}}function IZ(e){return wi.add(e),La&&(clearTimeout(La),La=null),fR(),()=>{wi.delete(e),!(wi.size>0)&&(La&&(clearTimeout(La),La=null),Kf=0,dR())}}function Kt(e){const t=g.useRef(e);t.current=e,g.useEffect(()=>IZ(n=>{t.current(n)}),[])}function Xe(e){return e==="working"?"working":!e||e==="offline"?"offline":"available"}function _r(e){return Xe(e)!=="offline"}function Hn(e){switch(Xe(e)){case"working":return"Working";case"available":return"Available";default:return"Offline"}}const Ch="ranger.main.mini",OZ=new Set([Ch,"ranger","@ranger"]),DZ=new Set(["plan","conductor","conduct","warroom","command","mission","control","agents","tail","atop"]),PZ=new Set(["available","working","active","idle","waiting","registered"]);function Tx(e){return[e.id,e.name,e.handle??"",e.selector??"",e.role??""].map(n=>n.trim().toLowerCase()).some(n=>OZ.has(n)||n==="ranger"||n.startsWith("ranger.")||n.includes(".ranger.")||n.includes(" ranger"))}function zZ(e){return PZ.has(e.state?.trim().toLowerCase()??"")}function ak(e){if(!Tx(e))return Number.NEGATIVE_INFINITY;let t=0;return zZ(e)&&(t+=100),e.handle?.trim().toLowerCase()==="ranger"&&(t+=20),e.selector?.trim().toLowerCase()==="@ranger"&&(t+=20),e.role?.trim().toLowerCase()==="ranger"&&(t+=10),e.id===Ch&&(t+=1),t}function LZ(e){return e.filter(Tx).sort((t,n)=>{const s=ak(n)-ak(t);return s!==0?s:(n.updatedAt??0)-(t.updatedAt??0)})[0]??null}function $Z(e){return LZ(e)?.id??Ch}function UZ(e){return Nn(e)}function hR(e,t=Ch){const n=e.trim().toLowerCase(),s=t.trim().toLowerCase();return n===s||n==="ranger"||n.startsWith("ranger.")||n.includes(".ranger.")}function BZ(e){const t=[],n=/```(?:scout-ui|scout-ui-action|ranger-ui)\s*([\s\S]*?)```/gi;let s;for(;(s=n.exec(e))!==null;){const i=VZ(s[1]??"");t.push(...i)}return t}function VZ(e){const t=e.trim();if(!t)return[];try{const n=JSON.parse(t);return(Array.isArray(n)?n:[n]).map(i=>mR(i)).filter(i=>!!i)}catch{return[]}}function mR(e){if(!e||typeof e!="object")return null;const t=e,n=t.scoutUi??t.scout_ui??t.rangerUi??t.ranger_ui;if(n)return mR(n);const s=typeof t.type=="string"?t.type:typeof t.action=="string"?t.action:"",i=typeof t.reason=="string"?t.reason:void 0;if(s==="open-ranger"||s==="open_ranger"){const c=t.mode==="tell"?"tell":t.mode==="ask"?"ask":void 0;return{type:"open-ranger",...c?{mode:c}:{},...i?{reason:i}:{}}}if(s==="refresh")return{type:"refresh",...i?{reason:i}:{}};if(s!=="navigate"&&s!=="open")return null;const l=FZ(t.route??t);return l?{type:"navigate",route:l,...i?{reason:i}:{}}:null}function FZ(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 s=typeof t.mode=="string"&&DZ.has(t.mode)?HZ(t.mode):void 0;return{view:"ops",...s?{mode:s}:{}}}default:return null}}function HZ(e){switch(e){case"command":return"command";case"warroom":return"command";case"control":case"mission":return"mission";case"conduct":case"conductor":return"conductor";case"plan":case"agents":case"tail":case"atop":return e;default:return}}const pR={current:null,setMenu:null};function Mx(){return g.useCallback((e,t)=>{e.preventDefault(),e.stopPropagation(),pR.setMenu?.({position:{x:e.clientX,y:e.clientY},items:t})},[])}function qZ({children:e}){const[t,n]=g.useState(null),s=g.useRef(null);pR.setMenu=n;const i=g.useCallback(()=>n(null),[]);return g.useEffect(()=>{if(!t)return;const l=()=>i(),c=h=>{h.key==="Escape"&&i()},d=()=>i();return window.addEventListener("mousedown",l,!0),window.addEventListener("keydown",c),window.addEventListener("scroll",d,!0),window.addEventListener("contextmenu",i,!0),()=>{window.removeEventListener("mousedown",l,!0),window.removeEventListener("keydown",c),window.removeEventListener("scroll",d,!0),window.removeEventListener("contextmenu",i,!0)}},[t,i]),g.useEffect(()=>{if(!t||!s.current)return;const l=s.current,c=l.getBoundingClientRect(),d=window.innerWidth,h=window.innerHeight;let m=t.position.x,p=t.position.y;m+c.width>d-8&&(m=d-c.width-8),p+c.height>h-8&&(p=h-c.height-8),m<8&&(m=8),p<8&&(p=8),l.style.left=`${m}px`,l.style.top=`${p}px`},[t]),t?r.jsxs(r.Fragment,{children:[e,r.jsx("div",{ref:s,className:"s-context-menu",style:{left:t.position.x,top:t.position.y},role:"menu",onMouseDown:l=>l.stopPropagation(),children:t.items.map((l,c)=>l.kind==="separator"?r.jsx("div",{className:"s-context-menu-sep",role:"separator"},c):r.jsxs("button",{type:"button",className:"s-context-menu-item",role:"menuitem",onClick:()=>{l.onSelect(),i()},children:[r.jsx("span",{className:"s-context-menu-label",children:l.label}),l.shortcut&&r.jsx("span",{className:"s-context-menu-shortcut",children:l.shortcut})]},c))})]}):r.jsx(r.Fragment,{children:e})}const ZZ=[195,125,300,45,355,210];function rk(e){return`oklch(0.80 0.14 ${e})`}function WZ(e){return`oklch(0.18 0.08 ${e})`}function ji({label:e,right:t}){return r.jsxs("div",{className:"s-settings-section-rule",children:[r.jsx("span",{className:"s-settings-section-label",children:e}),r.jsx("span",{className:"s-settings-section-line"}),t&&r.jsx("span",{className:"s-settings-section-right",children:t})]})}function As({label:e,hint:t,children:n}){return r.jsxs("div",{className:"s-settings-field",children:[r.jsx("label",{className:"s-settings-field-label",children:e}),n,t&&r.jsx("span",{className:"s-settings-field-hint",children:t})]})}function Oo({value:e,onChange:t,mono:n}){return r.jsx("input",{className:`s-settings-input${n?" s-settings-input--mono":""}`,value:e,onChange:s=>t(s.target.value)})}function YZ({value:e,onChange:t,rows:n=3}){return r.jsx("textarea",{className:"s-settings-textarea",value:e,onChange:s=>t(s.target.value),rows:n})}function GZ({value:e,onChange:t,min:n,max:s,step:i=1,unit:l=""}){return r.jsxs("div",{className:"s-settings-slider-wrap",children:[r.jsx("input",{type:"range",min:n,max:s,step:i,value:e,onChange:c=>t(Number(c.target.value))}),r.jsxs("span",{className:"s-settings-slider-value",children:[e," ",l]})]})}function $d({value:e,onChange:t,options:n,stacked:s,columns:i}){return r.jsx("div",{className:s?"s-settings-option-stacked":"s-settings-option-grid",style:s?void 0:{gridTemplateColumns:`repeat(${i??n.length}, 1fr)`},children:n.map(l=>r.jsxs("button",{className:`s-settings-option-btn${e===l.id?" s-settings-option-btn--active":""}`,onClick:()=>t(l.id),children:[r.jsx("span",{className:"s-settings-option-label",children:l.label}),r.jsx("span",{className:"s-settings-option-sub",children:l.sub})]},l.id))})}function KZ({profile:e,update:t}){return r.jsxs("div",{className:"s-settings-col-gap",children:[r.jsx(ji,{label:"Identity",right:"visible to every agent"}),r.jsxs("div",{className:"s-settings-identity-card",children:[r.jsx("span",{className:"s-settings-identity-dot",style:{background:rk(e.hue),color:WZ(e.hue)},children:(e.name||"?")[0].toUpperCase()}),r.jsxs("div",{style:{flex:1},children:[r.jsx("div",{className:"s-settings-identity-name",children:e.name||"Unnamed"}),r.jsxs("div",{className:"s-settings-identity-meta",children:[e.handle||"@you"," · ",e.pronouns||"—"," · operator"]})]}),r.jsxs("div",{className:"s-settings-hue-wrap",children:[r.jsx("span",{className:"s-settings-field-label",children:"Identity hue"}),r.jsx("div",{className:"s-settings-hue-row",children:ZZ.map(n=>r.jsx("button",{onClick:()=>t({hue:n}),className:`s-settings-hue-dot${e.hue===n?" s-settings-hue-dot--active":""}`,style:{background:rk(n)}},n))})]})]}),r.jsx(As,{label:"Display name",hint:"Shown when agents address you.",children:r.jsx(Oo,{value:e.name,onChange:n=>t({name:n})})}),r.jsx(As,{label:"Handle",hint:"Used in @mentions across threads.",children:r.jsx(Oo,{value:e.handle,onChange:n=>t({handle:n}),mono:!0})}),r.jsx(As,{label:"Pronouns",children:r.jsx(Oo,{value:e.pronouns,onChange:n=>t({pronouns:n})})}),r.jsx(ji,{label:"How agents understand you",right:"shipped as system prompt context"}),r.jsx(As,{label:"Operator bio",hint:"How you want to be worked with. Agents read this before asking you things.",children:r.jsx(YZ,{value:e.bio,onChange:n=>t({bio:n}),rows:4})}),r.jsxs("div",{className:"s-settings-two-col",children:[r.jsx(As,{label:"Timezone",children:r.jsx(Oo,{value:e.timezone,onChange:n=>t({timezone:n}),mono:!0})}),r.jsx(As,{label:"Working hours",children:r.jsx(Oo,{value:e.workingHours,onChange:n=>t({workingHours:n}),mono:!0})})]})]})}function XZ({profile:e,update:t}){return r.jsxs("div",{className:"s-settings-col-gap",children:[r.jsx(ji,{label:"Interrupt policy"}),r.jsx(As,{label:"When agents can ping you directly",hint:"Blocking-only means only asks that truly stall work. Others get batched.",children:r.jsx($d,{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"}]})}),r.jsxs("div",{className:"s-settings-two-col",children:[r.jsx(As,{label:"Batch window (min)",children:r.jsx(GZ,{value:e.batchWindow,min:5,max:60,step:5,onChange:n=>t({batchWindow:n}),unit:"min"})}),r.jsx(As,{label:"Quiet hours",children:r.jsx(Oo,{value:e.quietHours,onChange:n=>t({quietHours:n}),mono:!0})})]}),r.jsx(ji,{label:"Where to reach you"}),r.jsx(As,{label:"Preferred channel",children:r.jsx($d,{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"}]})}),r.jsx(ji,{label:"Tone calibration",right:"how agents write to you"}),r.jsxs("div",{className:"s-settings-two-col",children:[r.jsx(As,{label:"Verbosity",children:r.jsx($d,{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"}]})}),r.jsx(As,{label:"Tone",children:r.jsx($d,{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"}]})})]})]})}const JZ={desktop:"◻",mobile:"▯",tablet:"▭"};function QZ({device:e}){const t=e.status==="this-device"?"var(--accent)":e.status==="online"?"var(--green)":"var(--dim)";return r.jsxs("div",{className:"s-settings-device-row",children:[r.jsx("span",{className:"s-settings-device-icon",children:JZ[e.kind]??"□"}),r.jsxs("div",{children:[r.jsx("div",{className:"s-settings-device-name",children:e.name}),r.jsxs("div",{className:"s-settings-device-meta",children:[e.kind," · via ",e.relay," · ",e.lastSeen]})]}),r.jsxs("span",{className:"s-settings-device-status",style:{color:t},children:["●"," ",e.status==="this-device"?"this device":e.status]}),r.jsx("button",{className:"s-btn",disabled:e.status==="this-device",children:e.status==="this-device"?"—":"Unpair"})]})}function eW({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 s=n.fingerprint===e.connectedPeerFingerprint;t.push({id:n.fingerprint,name:n.name??"Paired device",kind:"mobile",status:s?"online":"offline",relay:"tailscale",lastSeen:n.lastSeenLabel??"—"})}return r.jsxs("div",{className:"s-settings-col-gap",children:[r.jsx(ji,{label:`Paired devices · ${t.length}`}),r.jsx("div",{className:"s-settings-col-gap",style:{gap:10},children:t.map(n=>r.jsx(QZ,{device:n},n.id))}),r.jsx(ji,{label:"Relay"}),r.jsxs("div",{className:"s-settings-relay-card",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"s-settings-relay-title",children:["Relay · ",r.jsxs("span",{className:"s-settings-device-status",style:{color:e?.isRunning?"var(--green)":"var(--dim)"},children:["●"," ",e?.isRunning?"connected":"offline"]})]}),r.jsxs("div",{className:"s-settings-relay-meta",children:[e?.relay??"not configured"," · tailscale"]}),r.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."})]}),r.jsx("button",{className:"s-btn",children:"Configure"})]})]})}const tW=[{id:"operator",label:"Operator",sub:"identity · bio · hours"},{id:"comms",label:"Communication",sub:"how agents reach you"},{id:"devices",label:"Paired devices",sub:"relay · connected"}],nW={operator:"Operator identity",comms:"Communication",devices:"Paired devices"},sW={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 aW({open:e,onClose:t}){const{refreshOnboarding:n}=ht(),[s,i]=g.useState("operator"),[l,c]=g.useState(sW),[d,h]=g.useState(null),[m,p]=g.useState(!1),y=g.useRef(null),x=g.useCallback(async()=>{try{const N=ke("/api/user"),k=Promise.race([ke("/api/pairing-state"),new Promise((S,M)=>setTimeout(()=>M(new Error("timeout")),3e3))]),[E,A]=await Promise.allSettled([N,k]);E.status==="fulfilled"&&c(E.value),A.status==="fulfilled"&&h(A.value)}finally{p(!0)}},[]);g.useEffect(()=>{e&&x()},[e,x]),g.useEffect(()=>{if(!e)return;const N=k=>{k.key==="Escape"&&t()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e,t]);const w=g.useCallback(N=>{y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{ke("/api/user",{method:"POST",body:JSON.stringify(N)}).then(()=>n()).catch(()=>{})},400)},[n]),j=g.useCallback(N=>{c(k=>{const E={...k,...N};return w(E),E})},[w]);return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:`s-settings-scrim ${e?"s-settings-scrim--open":"s-settings-scrim--closed"}`,onClick:t}),r.jsxs("div",{className:`s-settings-drawer ${e?"s-settings-drawer--open":"s-settings-drawer--closed"}`,children:[r.jsxs("div",{className:"s-settings-header",children:[r.jsxs("div",{className:"s-settings-header-title",children:["⚙"," SETTINGS"]}),r.jsx("span",{className:"s-settings-header-sep",children:"/"}),r.jsx("span",{className:"s-settings-header-section",children:nW[s]}),r.jsx("span",{style:{flex:1}}),r.jsx("span",{className:"s-settings-header-hint",children:"ESC to close"}),r.jsx("button",{className:"s-settings-close",onClick:t,children:"×"})]}),r.jsx("nav",{className:"s-settings-rail",children:tW.map(N=>r.jsxs("button",{onClick:()=>i(N.id),className:`s-settings-rail-btn${s===N.id?" s-settings-rail-btn--active":""}`,children:[r.jsx("span",{className:"s-settings-rail-label",children:N.label}),r.jsx("span",{className:"s-settings-rail-sub",children:N.sub})]},N.id))}),r.jsx("main",{className:"s-settings-content",children:m?r.jsxs(r.Fragment,{children:[s==="operator"&&r.jsx(KZ,{profile:l,update:j}),s==="comms"&&r.jsx(XZ,{profile:l,update:j}),s==="devices"&&r.jsx(eW,{pairing:d})]}):r.jsx("div",{style:{color:"var(--dim)",fontFamily:"var(--font-mono)",fontSize:12},children:"Loading..."})}),r.jsxs("div",{className:"s-settings-footer",children:[r.jsxs("span",{className:"s-settings-footer-sync",children:["●"," synced"]}),r.jsx("span",{children:"·"}),r.jsx("span",{children:"changes apply instantly to every agent in your fleet"}),r.jsx("span",{style:{flex:1}}),r.jsx("button",{className:"s-btn",onClick:t,children:"Done"})]})]})]})}const gR=g.createContext(null),rW=["hello","node.upserted","actor.registered","agent.registered","agent.endpoint.upserted","invocation.requested","flight.updated","delivery.state.changed","scout.dispatched"],iW=new Set(rW),oW=15e3,lW={"--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)","--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":"'Instrument Serif', 'Spectral', Georgia, serif","--hud-font-accent-title":"var(--hud-font-sans)"},cW={"--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)","--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":"'Instrument Serif', 'Spectral', Georgia, serif","--hud-font-accent-title":"var(--hud-font-sans)"};function ht(){const e=g.useContext(gR);if(!e)throw new Error("useScout must be used inside ScoutProvider");return e}function uW({children:e,initialTheme:t="dark"}){const{route:n,navigate:s}=AZ(),[i,l]=g.useState([]),[c,d]=g.useState(null),[h,m]=g.useState(!1),p=g.useCallback(()=>m(!0),[]),[y,x]=g.useState(!1),[w,j]=g.useState(null),N=g.useCallback(()=>x(!0),[]),k=g.useCallback(()=>x(!1),[]),E=g.useCallback(q=>{j(q)},[]),A=g.useCallback(()=>j(null),[]),S=t==="light"?cW:lW,M=g.useMemo(()=>$Z(i),[i]),C=g.useMemo(()=>UZ(M),[M]),I=g.useRef(null),R=g.useCallback(async()=>{if(I.current)return I.current;const q=(async()=>{const G=await ke("/api/agents").catch(()=>null);G&&l(G)})();I.current=q;try{await q}finally{I.current=null}},[]),D=g.useCallback(async()=>{try{const q=await ke("/api/onboarding/state");d(q)}catch{d({hasLocalConfig:!0,hasProjectConfig:!0,hasOperatorName:!0,localConfigPath:null,projectRoot:null,currentDirectory:null,operatorName:null,operatorNameSuggestion:null})}},[]);g.useEffect(()=>{R(),D()},[R,D]),g.useEffect(()=>{const q=()=>{document.visibilityState!=="hidden"&&R()},G=window.setInterval(q,oW);return window.addEventListener("focus",q),document.addEventListener("visibilitychange",q),()=>{window.clearInterval(G),window.removeEventListener("focus",q),document.removeEventListener("visibilitychange",q)}},[R]);const z=g.useMemo(()=>i.filter(q=>_r(q.state)).length,[i]),O=g.useCallback(q=>{switch(q.type){case"navigate":s(q.route);break;case"open-ranger":s({view:"conversation",conversationId:C,...q.mode==="ask"?{composeMode:"ask"}:{}});break;case"refresh":R();break}},[s,C,R]),_=g.useRef({rangerAgentId:M,applyRangerUiAction:O});_.current={rangerAgentId:M,applyRangerUiAction:O},Kt(q=>{iW.has(q.kind)&&R();const G=q.kind==="message.posted"&&q.payload&&typeof q.payload=="object"?q.payload.message:null;if(!G||typeof G!="object")return;const X=G,L=typeof X.actorId=="string"?X.actorId:"",F=typeof X.body=="string"?X.body:"";if(!(!L||!F||!hR(L,_.current.rangerAgentId)))for(const H of BZ(F))_.current.applyRangerUiAction(H)}),g.useEffect(()=>{const q=G=>{const X=G.detail,L=X&&typeof X=="object"&&"type"in X?X:null;L&&_.current.applyRangerUiAction(L)};return window.addEventListener("scout:ranger-ui-action",q),window.scoutRanger={applyUiAction:G=>_.current.applyRangerUiAction(G),navigate:G=>_.current.applyRangerUiAction({type:"navigate",route:G})},()=>{window.removeEventListener("scout:ranger-ui-action",q),window.scoutRanger?.applyUiAction&&delete window.scoutRanger}},[]);const U=g.useMemo(()=>({route:n,navigate:s,agents:i,onlineCount:z,reload:R,onboarding:c,refreshOnboarding:D,onboardingSkipped:h,skipOnboarding:p,settingsOpen:y,openSettings:N,closeSettings:k,rangerAgentId:M,rangerConversationId:C,applyRangerUiAction:O,selectedBrokerAttempt:w,inspectBrokerAttempt:E,clearBrokerAttempt:A}),[n,s,i,z,R,c,D,h,p,y,N,k,M,C,O,w,E,A]);return r.jsx(gR.Provider,{value:U,children:r.jsx("div",{"data-scout-theme":t,"data-scout-theme-mode":t,style:{...S},children:r.jsxs(qZ,{children:[e,r.jsx(aW,{open:y,onClose:k})]})})})}function dW(){const{navigate:e,agents:t,reload:n,openSettings:s,rangerConversationId:i,applyRangerUiAction:l}=ht(),c=ru(),d=g.useCallback(async()=>{try{const m=await ke("/api/ask",{method:"POST",body:JSON.stringify({conversationId:i,body:"What's the state of things? Give me a terse ops summary, the biggest risk, and the next action you recommend."})});e({view:"conversation",conversationId:m.conversationId??i,composeMode:"ask"})}catch{e({view:"conversation",conversationId:i,composeMode:"ask"})}},[e,i]),h=g.useCallback(async m=>{await ke(`/api/agents/${encodeURIComponent(m)}/interrupt`,{method:"POST",body:JSON.stringify({})})},[]);return g.useMemo(()=>{const m=[{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:"Go to Fleet",action:()=>e({view:"fleet"}),shortcut:"Cmd+3"},{id:"nav:conversations",label:"Go to Conversations",action:()=>e({view:"conversations"})},{id:"nav:sessions",label:"Go to Sessions",action:()=>e({view:"sessions"}),shortcut:"Cmd+4"},{id:"nav:channels",label:"Go to Channels",action:()=>e({view:"channels"}),shortcut:"Cmd+5"},{id:"nav:activity",label:"Go to Activity",action:()=>e({view:"activity"}),shortcut:"Cmd+6"},{id:"nav:mesh",label:"Go to Mesh",action:()=>e({view:"mesh"}),shortcut:"Cmd+7"},...c?[{id:"nav:ops",label:"Go to Ops",action:()=>e({view:"ops"}),shortcut:"Cmd+8"}]:[],{id:"nav:settings",label:"Open Settings",action:()=>s(),shortcut:"Cmd+,"},{id:"ranger:open",label:"Open Ranger",action:()=>e({view:"conversation",conversationId:i,composeMode:"ask"})},{id:"ranger:state",label:"Ask Ranger for State",action:()=>{d()}},{id:"ranger:ops-tail",label:"Ranger: Open Ops Tail",action:()=>l({type:"navigate",route:{view:"ops",mode:"tail"}})},{id:"nav:pair",label:"Pair Device",action:()=>s()},{id:"scout:reload",label:"Reload Agents",action:()=>{n()}}];for(const p of t)m.push({id:`scout:open:${p.id}`,label:`Open ${p.name}`,action:()=>e({view:"conversation",conversationId:Nn(p.id)})}),m.push({id:`scout:send:${p.id}`,label:`Tell ${p.name}`,action:()=>e({view:"conversation",conversationId:Nn(p.id)})}),m.push({id:`scout:ask:${p.id}`,label:`Ask ${p.name}`,action:()=>e({view:"conversation",conversationId:Nn(p.id),composeMode:"ask"})}),m.push({id:`scout:interrupt:${p.id}`,label:`Interrupt ${p.name}`,action:()=>{h(p.id)}});return m},[t,l,d,h,e,c,i,n,s])}function vR(){const{onlineCount:e}=ht(),[t,n]=g.useState(null),s=g.useRef(0),i=g.useCallback(async()=>{const l=++s.current;try{const c=await ke("/api/mesh");if(l!==s.current)return;n(c)}catch{if(l!==s.current)return;n(null)}},[]);return g.useEffect(()=>{i();const l=setInterval(()=>{i()},15e3);return()=>clearInterval(l)},[i]),{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(c=>c.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"}}}function fW(){return vR().status}const hW={inbox:"Fleet",conversation:"Conversation","agent-info":"Agent",agents:"Agents",fleet:"Fleet",conversations:"Conversations",sessions:"Sessions",channels:"Channels",activity:"Activity",mesh:"Mesh",broker:"Broker",settings:"Settings",work:"Work",ops:"Ops"};function mW(){const{route:e,navigate:t}=ht(),n=ru(),s=[{label:"Fleet",view:"inbox"},{label:"Agents",view:"agents"},{label:"Conversations",view:"conversations"},{label:"Sessions",view:"sessions"},{label:"Channels",view:"channels"},{label:"Mesh",view:"mesh"},{label:"Broker",view:"broker"},...n?[{label:"Ops",view:"ops"}]:[]],i=e.view==="fleet"||e.view==="activity"?"inbox":e.view==="conversation"||e.view==="agent-info"?"agents":e.view==="conversations"?"conversations":e.view==="work"?n?"ops":"inbox":e.view==="channels"?"channels":e.view,l=e.view==="conversation"||e.view==="agent-info"||e.view==="work"?hW[e.view]??e.view:null;return g.createElement("div",{className:"scout-nav-tabs"},s.map(({label:c,view:d})=>g.createElement("button",{key:d,className:`scout-nav-tab${i===d?" active":""}`,onClick:()=>t({view:d})},c)),l&&g.createElement("span",{className:"scout-nav-slash"},"/"),l&&g.createElement("span",{className:"scout-nav-crumb"},l))}function pW(){const{openSettings:e,navigate:t,rangerConversationId:n}=ht();return g.createElement("div",{className:"scout-nav-actions"},g.createElement("button",{onClick:()=>t({view:"conversation",conversationId:n,composeMode:"ask"}),className:"scout-nav-action scout-nav-action--ranger"},"Ranger"),g.createElement("button",{onClick:()=>e(),className:"scout-nav-action scout-nav-action--settings",title:"Settings"},g.createElement(ih,{size:12,strokeWidth:1.6,"aria-hidden":!0}),g.createElement("span",null,"Settings")))}function gW(){return"panel"}function vW(){const{onboarding:e,onboardingSkipped:t,skipOnboarding:n}=ht();if(!e)return null;if(t)return{active:!1,dismissible:!0};const s=!e.hasLocalConfig,i=!e.hasProjectConfig,l=!e.hasOperatorName;return{active:s||l||i,dismissible:!0,onDismiss:n}}const Ud=240,yW=900,xW=.45,bW=500;function ik(e){return Math.min(yW,Math.max(bW,Math.floor(e*xW)))}function wW({app:e,assistant:t=!0}){return r.jsx(e.Provider,{children:r.jsx(vZ,{children:r.jsx(NW,{app:e,assistantEnabled:t})})})}function jW({statusBar:e}){const t=e.mesh.color==="amber"?"text-amber-400":e.mesh.color==="red"?"text-red-400":"text-neutral-100";return r.jsxs("div",{className:"flex items-center gap-3 font-mono text-[12px]",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsxs("span",{className:"text-neutral-500",children:[e.activeAgents.label,":"]}),r.jsx("span",{className:"text-neutral-100",children:e.activeAgents.count})]}),r.jsx("div",{className:"h-3 w-px bg-neutral-700"}),r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsxs("span",{className:"text-neutral-500",children:[e.mesh.label,":"]}),r.jsx("span",{className:t,children:e.mesh.value})]})]})}function NW({app:e,assistantEnabled:t}){const{navTotalHeight:n}=Dy(),s=e.hooks.useCommands(),i=e.hooks.useSearch?.()??null,l=e.hooks.useNavCenter?.()??null,c=e.hooks.useNavActions?.()??null,d=e.hooks.useLayoutMode?.()??e.mode,h=e.hooks.useActiveToolHint?.()??null,m=e.hooks.useTakeover?.()??null,p=m?.active===!0,y=p&&m?.dismissible===!0,x=m?.onDismiss,w=e.slots.Takeover,j=vR(),N=yZ(),[k,E]=Hs(`appshell.${e.id}.left`,!1),[A,S]=Hs(`appshell.${e.id}.right`,!1),[M,C]=Hs(`appshell.${e.id}.rightOverlay`,!1),[I,R]=Hs(`appshell.${e.id}.leftW`,260),[D,z]=Hs(`appshell.${e.id}.rightW`,280),[O,_]=Hs("openscout.ops.minimap.collapsed",!1),[U,q]=g.useState(()=>ik(typeof window<"u"?window.innerWidth:1280));g.useEffect(()=>{const Ee=()=>q(ik(window.innerWidth));return Ee(),window.addEventListener("resize",Ee),()=>window.removeEventListener("resize",Ee)},[]),g.useEffect(()=>{R(Ee=>Math.min(U,Math.max(Ud,Ee))),z(Ee=>Math.min(U,Math.max(Ud,Ee)))},[U,R,z]);const[G,X]=g.useState({x:0,y:0}),[L,F]=g.useState(1),H=g.useCallback(Ee=>{X(Oe=>({x:Oe.x+Ee.x,y:Oe.y+Ee.y}))},[]),V=g.useCallback(Ee=>{F(Ee)},[]),[W,$]=g.useState(!1),[B,Y]=g.useState(!1),[te,ae]=Hs(`appshell.${e.id}.termH`,320),ee=!!e.slots.Terminal,ie=g.useMemo(()=>{const Ee=[];return ee&&Ee.push("terminal"),t&&Ee.push("assistant"),Ee},[ee,t]),de=ie[0]??"terminal",[xe,Ae]=Hs(`appshell.${e.id}.drawerTab`,de),me=ie.includes(xe)?xe:de,[Pe,Re]=g.useState(!1),[Ye,Ie]=g.useState(new Set),oe=g.useCallback(Ee=>{Ie(Oe=>{const Te=new Set(Oe);return Te.has(Ee)?Te.delete(Ee):Te.add(Ee),Te})},[]),je=g.useCallback(Ee=>Oe=>{Oe.preventDefault();const Te=Oe.clientX,tt=Ee==="left"?I:D,at=Ee==="left"?R:z,it=Ee==="left"?1:-1,yt=Pt=>{const on=(Pt.clientX-Te)*it;at(Math.max(Ud,Math.min(U,tt+on)))},Jt=()=>{document.removeEventListener("mousemove",yt),document.removeEventListener("mouseup",Jt)};document.addEventListener("mousemove",yt),document.addEventListener("mouseup",Jt)},[I,D,R,z,U]),Fe=g.useMemo(()=>{const Ee=[{id:"shell:toggle-left",label:"Toggle Left Panel",shortcut:"Cmd+[",action:()=>E(Oe=>!Oe)},{id:"shell:toggle-right",label:"Toggle Right Panel",shortcut:"Cmd+]",action:()=>S(Oe=>!Oe)},{id:"shell:toggle-right-overlay",label:"Toggle Inspector Overlay",shortcut:"Cmd+Shift+]",action:()=>C(Oe=>!Oe)},{id:"shell:toggle-terminal",label:"Toggle Terminal",shortcut:"Ctrl+`",action:()=>$(Oe=>!Oe)}];return t&&Ee.push({id:"shell:toggle-assistant",label:"Toggle Assistant",shortcut:"Cmd+J",action:()=>{Ae("assistant"),$(Oe=>!Oe||xe!=="assistant")}}),Ee},[t,xe,Ae,E,S,C]),le=g.useMemo(()=>[...s,...Fe],[s,Fe]);g.useEffect(()=>{const Ee=Oe=>{p||((Oe.metaKey||Oe.ctrlKey)&&Oe.key==="k"&&(Oe.preventDefault(),Re(!0)),(Oe.metaKey||Oe.ctrlKey)&&Oe.key==="["&&(Oe.preventDefault(),E(Te=>!Te)),(Oe.metaKey||Oe.ctrlKey)&&Oe.key==="]"&&(Oe.preventDefault(),Oe.shiftKey?C(Te=>!Te):S(Te=>!Te)),Oe.ctrlKey&&Oe.key==="`"&&(Oe.preventDefault(),$(Te=>!Te)),t&&(Oe.metaKey||Oe.ctrlKey)&&Oe.key==="j"&&(Oe.preventDefault(),Ae("assistant"),$(Te=>!(Te&&me==="assistant"))))};return window.addEventListener("keydown",Ee),()=>window.removeEventListener("keydown",Ee)},[t,me,Ae,E,S,C,p]),g.useEffect(()=>{const Ee=()=>{Ae("terminal"),$(!0),ae(Oe=>Oe>window.innerHeight*.8?420:Oe)};return window.addEventListener("scout:open-terminal",Ee),()=>window.removeEventListener("scout:open-terminal",Ee)},[Ae,ae]),g.useEffect(()=>{const Ee=Oe=>{const Te=Oe.detail,tt=typeof Te?.width=="number"?Te.width:420;S(!1),z(at=>Math.max(at,Math.min(U,Math.max(Ud,tt))))};return window.addEventListener("scout:set-inspector-width",Ee),()=>window.removeEventListener("scout:set-inspector-width",Ee)},[S,z,U]);const ve=e.slots.Inspector,ue=e.slots.RightPanel,Ce=e.tools&&e.tools.length>0,be=r.jsxs(r.Fragment,{children:[ve&&r.jsx(ve,{}),!ve&&ue&&r.jsx(ue,{}),Ce&&r.jsx("div",{className:"border-t border-neutral-700/50",children:e.tools.map(Ee=>{const Oe=Ye.has(Ee.id);return r.jsxs("div",{children:[r.jsxs("button",{onClick:()=>oe(Ee.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 ${h===Ee.id?"text-emerald-400":"text-neutral-300"}`,children:[Oe?r.jsx(xy,{size:10}):r.jsx(jO,{size:10}),r.jsx("span",{className:"text-neutral-400",children:Ee.icon}),r.jsx("span",{className:"font-bold",children:Ee.name})]}),Oe&&r.jsx("div",{className:"px-4 pb-3",children:r.jsx(Ee.Component,{})})]},Ee.id)})})]}),we=r.jsx(mZ,{onOpenCommandPalette:()=>Re(!0)}),Se=g.useMemo(()=>({isCollapsed:O,onToggleCollapse:()=>_(Ee=>!Ee)}),[O,_]),He=N?r.jsx("div",{className:`scout-canvas-minimap-shell${O?" scout-canvas-minimap-shell--collapsed":""}`,children:N.render(Se)}):null,et=N?r.jsx("div",{className:`scout-canvas-minimap-shell scout-canvas-minimap-shell--floating${O?" scout-canvas-minimap-shell--collapsed":""}`,children:N.render(Se)}):null,Be=g.useRef(null),St=g.useRef(null);g.useEffect(()=>{const Ee=Be.current;Ee&&(p?Ee.setAttribute("inert",""):Ee.removeAttribute("inert"))},[p]),g.useEffect(()=>{if(!p)return;const Ee=St.current;if(Ee&&(Ee.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")??Ee).focus(),!y)return;const Oe=Te=>{Te.key==="Escape"&&(Te.preventDefault(),x?.())};return window.addEventListener("keydown",Oe),()=>window.removeEventListener("keydown",Oe)},[p,y,x]);const Dt=A||M?0:D,Xt=d==="panel"?{position:"absolute",top:n,bottom:28,left:k?0:I,right:Dt,overflow:"auto",transition:"left 200ms ease, right 200ms ease"}:{};return r.jsxs(r.Fragment,{children:[r.jsx("div",{ref:Be,"aria-hidden":p?!0:void 0,style:{display:"contents"},children:r.jsx(cZ,{mode:d,panOffset:G,scale:L,onPan:H,onZoom:V,hud:r.jsxs(r.Fragment,{children:[r.jsx(dZ,{title:e.name.toUpperCase(),search:i??void 0,center:l,actions:c}),r.jsx(ek,{side:"left",title:e.leftPanel?.title??"Navigation",icon:e.leftPanel?.icon,isCollapsed:k,onToggleCollapse:()=>E(!k),width:I,onResizeStart:je("left"),footer:k?void 0:He,headerActions:e.leftPanel?.headerActions&&r.jsx(e.leftPanel.headerActions,{}),children:e.slots.LeftPanel&&r.jsx(e.slots.LeftPanel,{})}),k?et:null,r.jsx(ek,{side:"right",title:e.rightPanel?.title??"Inspector",icon:e.rightPanel?.icon,isCollapsed:A,onToggleCollapse:()=>S(!A),width:D,onResizeStart:je("right"),style:M?{backgroundColor:"rgba(13, 14, 16, 0.72)",backdropFilter:"blur(24px) saturate(140%)",WebkitBackdropFilter:"blur(24px) saturate(140%)",boxShadow:"-18px 0 48px -12px rgba(0,0,0,0.7), inset 1px 0 0 0 rgba(255,255,255,0.06)"}:void 0,footer:we,headerActions:r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:()=>C(Ee=>!Ee),title:M?"Pin inspector (push content)":"Float inspector (overlay content)","aria-label":M?"Pin inspector":"Float inspector",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:M?r.jsx($O,{size:12}):r.jsx(BO,{size:12})}),e.rightPanel?.headerActions&&r.jsx(e.rightPanel.headerActions,{})]}),children:be}),r.jsx(hZ,{status:j.status,left:r.jsx(jW,{statusBar:j}),onToggleTerminal:()=>$(Ee=>!Ee),isTerminalOpen:W}),r.jsx("div",{className:"pointer-events-none",style:{position:"fixed",left:k?0:I,right:Dt,bottom:0,top:0,zIndex:45,transition:"left 200ms ease, right 200ms ease",transform:"translateZ(0)"},children:r.jsxs(pZ,{isOpen:W,onClose:()=>$(!1),onToggleMaximize:()=>Y(Ee=>!Ee),isMaximized:B,height:Math.min(te,window.innerHeight*.8),onHeightChange:Ee=>ae(Math.min(Ee,window.innerHeight*.8)),title:r.jsx(SW,{tabs:ie,active:me,onSelect:Ae}),children:[W&&me==="terminal"&&(e.slots.Terminal?r.jsx(e.slots.Terminal,{}):r.jsx("div",{className:"p-4 font-mono text-[12px] text-neutral-400",children:"No terminal content"})),W&&me==="assistant"&&r.jsx(b6,{app:e,commands:s})]})}),r.jsx(gZ,{isOpen:Pe,onClose:()=>Re(!1),commands:le})]}),children:r.jsx("div",{style:Xt,className:"frame-scrollbar",children:r.jsx(e.slots.Content,{})})})}),p&&w?r.jsx("div",{ref:St,tabIndex:-1,role:"dialog","aria-modal":"true",style:{position:"fixed",inset:0,zIndex:80,outline:"none"},children:r.jsx(w,{})}):null]})}function SW({tabs:e,active:t,onSelect:n}){return e.length===0?null:r.jsx("div",{className:"flex items-center gap-0.5",children:e.map(s=>{const i=s===t,l=s==="terminal"?t5:JO,c=s==="terminal"?"TERMINAL":"ASSISTANT",d=s==="terminal"?"text-emerald-400":"text-cyan-400";return r.jsxs("button",{type:"button",onClick:()=>n(s),className:`flex items-center gap-1.5 px-2.5 py-1 rounded text-xs font-bold tracking-widest font-mono transition-colors ${i?`${d} bg-white/[0.04]`:"text-neutral-500 hover:text-neutral-300"}`,children:[r.jsx(l,{size:13}),r.jsx("span",{children:c})]},s)})})}const ok=["#6366f1","#8b5cf6","#0ea5e9","#14b8a6","#f59e0b","#ef4444","#ec4899","#10b981"];function gt(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return ok[Math.abs(t)%ok.length]}function Gs(e){switch(Xe(e)){case"working":return"var(--green)";case"available":return"var(--accent)";default:return"var(--dim)"}}const kW={workspace:"workspace",worktree:"workspace",branch:"workspace",profile:"profile",persona:"profile",harness:"harness",runtime:"harness",model:"model",node:"node",host:"node"};function EW(e){return e.trim().replace(/^@+/,"").replace(/[.,!?;)\]]+$/,"")}function qs(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}const CW="scout";function AW(e){return kW[qs(e)]??null}function yR(e){const t=qs(e.definitionId),n=e.workspaceQualifier?qs(e.workspaceQualifier):void 0,s=e.profile?qs(e.profile):void 0,i=e.harness?qs(e.harness):void 0,l=e.model?qs(e.model):void 0,c=e.nodeQualifier?qs(e.nodeQualifier):void 0;return t?{definitionId:t,...n?{workspaceQualifier:n}:{},...s?{profile:s}:{},...i?{harness:i}:{},...l?{model:l}:{},...c?{nodeQualifier:c}:{}}:null}function xR(e){const t=e.split(".").filter(Boolean),n=t.shift();if(!n)return null;const s={definitionId:n},i=[];for(const l of t){if(l.includes(":")){const[c,d=""]=l.split(":",2),h=AW(c),m=qs(d);if(!h||!m)return null;h==="workspace"?s.workspaceQualifier=m:h==="profile"?s.profile=m:h==="harness"?s.harness=m:h==="model"?s.model=m:h==="node"&&(s.nodeQualifier=m);continue}i.push(l)}if(i.length===1){const l=qs(i[0]);if(!l)return null;s.workspaceQualifier=l}else if(i.length===2){const l=qs(i[0]),c=qs(i[1]);if(!l||!c)return null;s.workspaceQualifier||(s.workspaceQualifier=l),s.nodeQualifier||(s.nodeQualifier=c)}else if(i.length>2)return null;return bR(s,{raw:e})}function TW(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 s=Math.min(...[t,n].filter(h=>h>=0)),i=e.slice(0,s);if(!i)return null;const l=xR(i);if(!l)return null;const c=t>=0?e.slice(t+1,n>=0?n:e.length):"",d=n>=0?e.slice(n+1):"";return t>=0&&!c||n>=0&&!d||c.includes("#")||c.includes("?")||d.includes("#")||d.includes("?")||l.harness&&c||l.model&&d?null:bR({definitionId:l.definitionId,nodeQualifier:l.nodeQualifier,workspaceQualifier:l.workspaceQualifier,profile:l.profile,harness:c||l.harness,model:d||l.model},{raw:e})}function MW(e){const t=EW(e);return!t||t.includes("@")?null:t.includes("#")||t.includes("?")?TW(t):xR(t)}function lk(e,t={}){const n=yR(e);if(!n)return t.includeSigil===!1?"":"@";const i=[`${t.includeSigil===!1?"":"@"}${n.definitionId}`];return n.workspaceQualifier&&i.push(n.workspaceQualifier),n.profile&&i.push(`profile:${n.profile}`),n.harness&&i.push(`harness:${n.harness}`),n.model&&i.push(`model:${n.model}`),n.nodeQualifier&&i.push(`node:${n.nodeQualifier}`),i.join(".")}function bR(e,t={}){const n=yR(e);return n?{raw:t.raw??lk(n,{includeSigil:!1}),label:lk(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 RW(e){return _W(e).parsed}function _W(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,s=[];for(const i of t){const l=i[2]??"",c=MW(l);if(!c){l&&s.push(`@${l}`);continue}n.set(c.label,c)}return{parsed:Array.from(n.values()),unparsed:Array.from(new Set(s))}}function IW(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 s=[];let i=e;const l=/@([a-z0-9][a-z0-9._/:-]*)/i;for(;i.length>0;){const c=l.exec(i);if(!c||c.index===void 0){s.push({kind:"text",value:i});break}c.index>0&&s.push({kind:"text",value:i.slice(0,c.index)});const d=c[0],h=d.toLowerCase(),m=n.get(h);m?s.push({kind:"mention",identity:m}):s.push({kind:"text",value:d}),i=i.slice(c.index+d.length)}return s}function OW(e,t){const n=[],s=/`([^`\n]+)`|\*\*(.+?)\*\*|\*([^*\s][^*]*?)\*|\[([^\]\n]+)\]\(([^)\s]+)\)/g;let i=0,l,c=0;for(;(l=s.exec(e))!==null;)l.index>i&&n.push(r.jsx("span",{children:e.slice(i,l.index)},`${t}-${c++}`)),l[1]!==void 0?n.push(r.jsx("code",{className:"s-inline-code",children:l[1]},`${t}-${c++}`)):l[2]!==void 0?n.push(r.jsx("strong",{children:l[2]},`${t}-${c++}`)):l[3]!==void 0?n.push(r.jsx("em",{children:l[3]},`${t}-${c++}`)):l[4]!==void 0&&l[5]!==void 0&&DW(l[5])?n.push(r.jsx("a",{href:l[5],target:"_blank",rel:"noreferrer",children:l[4]},`${t}-${c++}`)):n.push(r.jsx("span",{children:l[0]},`${t}-${c++}`)),i=l.index+l[0].length;return i<e.length&&n.push(r.jsx("span",{children:e.slice(i)},`${t}-${c++}`)),n.length>0?n:[r.jsx("span",{children:e},t)]}function DW(e){return/^(?:https?:\/\/|mailto:|\/|#)/iu.test(e)}function fs(e){if(!e)return e??"";const t=RW(e);return IW(e,t).flatMap((s,i)=>{if(s.kind==="text")return OW(s.value,i*100);const{identity:l}=s,d=l.definitionId===CW?"var(--accent)":gt(l.definitionId);return r.jsx("span",{className:"s-mention",style:{"--mention-color":d},children:l.label},i)})}function De(e){const t=e<1e12?e*1e3:e,n=Math.floor((Date.now()-t)/1e3);return n<5?"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 la(e){return new Date(e<1e12?e*1e3:e).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"})}const PW={"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"},zW={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 wR(e){return PW[e]??e.replace(/[._]/g," ")}function LW(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 $W(e){return(e??"system").charAt(0).toUpperCase()}function jR(e){return e.length<=14?e:`${e.slice(0,8)}...${e.slice(-4)}`}function UW(e){if(!e)return null;const t=e.split("/").filter(Boolean);return t[t.length-1]??e}function BW(e){return`${e.actorName??"system"} ${wR(e.kind)}`}function VW(e){return e.workspaceRoot?`Recorded from ${e.workspaceRoot}.`:e.conversationId?`Linked to thread ${jR(e.conversationId)}.`:"No additional detail was captured for this event."}function FW({navigate:e}){const[t,n]=g.useState([]),[s,i]=g.useState(null),[l,c]=g.useState(!0),[d,h]=g.useState(!1),[m,p]=g.useState(null),[y,x]=g.useState(null),w=g.useRef([]),j=g.useRef(0),N=g.useRef(null),k=Mx();g.useEffect(()=>{w.current=t},[t]);const E=g.useCallback(async(I="initial")=>{const R=++j.current;!(w.current.length>0)&&I!=="background"?(c(!0),p(null)):h(!0);try{const z=await ke("/api/activity");if(R!==j.current)return;n(z),p(null),x(Date.now()),i(O=>z.some(_=>_.id===O)?O:null)}catch(z){if(R!==j.current)return;p(z instanceof Error?z.message:String(z))}finally{R===j.current&&(c(!1),h(!1))}},[]),A=g.useCallback(()=>{N.current||(N.current=setTimeout(()=>{N.current=null,E("background")},250))},[E]);g.useEffect(()=>(E("initial"),()=>{N.current&&clearTimeout(N.current)}),[E]),Kt(A);const S=g.useMemo(()=>{const I=new Set(t.map(D=>D.actorName??"system")),R=new Set(t.map(D=>D.conversationId).filter(D=>!!D));return[{label:"Events",value:`${t.length}`,detail:t.length>0?`Latest ${De(t[0].ts)}`:"Waiting for records"},{label:"Actors",value:`${I.size}`,detail:I.size>0?"Distinct event owners":"No actors yet"},{label:"Threads",value:`${R.size}`,detail:R.size>0?"Conversation-linked records":"No linked threads"}]},[t]),M=!l&&t.length===0&&!!m,C=!l&&t.length===0&&!m;return r.jsxs("div",{className:"sys-surface-page",children:[r.jsxs("div",{className:"sys-page-head",children:[r.jsxs("div",{className:"sys-page-title-group",children:[r.jsx("h2",{className:"sys-page-title",children:"Activity"}),r.jsx("p",{className:"sys-page-subtitle",children:"Broker events, task execution, and collaboration handoffs."})]}),r.jsxs("div",{className:"sys-page-actions",children:[r.jsx("div",{className:"sys-sync-note",children:l?"Loading audit ledger...":m&&t.length>0?`Showing last confirmed snapshot from ${y?De(y):"earlier"}`:y?`Updated ${De(y)}`:"Waiting for first snapshot"}),r.jsx("button",{type:"button",className:"s-btn",disabled:l||d,onClick:()=>{E("manual")},children:d?"Refreshing...":"Refresh"})]})]}),r.jsx("div",{className:"sys-stat-grid",children:S.map(I=>r.jsxs("div",{className:"sys-stat-card",children:[r.jsx("span",{className:"sys-stat-label",children:I.label}),r.jsx("strong",{className:"sys-stat-value",children:I.value}),r.jsx("span",{className:"sys-stat-detail",children:I.detail})]},I.label))}),m&&t.length>0&&r.jsxs("div",{className:"sys-banner sys-banner-warning",children:[r.jsx("strong",{children:"Refresh failed."}),r.jsx("span",{children:m})]}),l&&t.length===0&&r.jsxs("div",{className:"sys-panel sys-state-card",children:[r.jsx("h3",{className:"sys-state-title",children:"Loading activity"}),r.jsx("p",{className:"sys-state-body",children:"Pulling the latest records from the broker database."})]}),M&&r.jsxs("div",{className:"sys-panel sys-state-card sys-state-card-error",children:[r.jsx("h3",{className:"sys-state-title",children:"Activity is unavailable"}),r.jsx("p",{className:"sys-state-body",children:m}),r.jsx("div",{className:"sys-inline-actions",children:r.jsx("button",{type:"button",className:"s-btn",onClick:()=>{E("manual")},children:"Try again"})})]}),C&&r.jsxs("div",{className:"sys-panel sys-state-card",children:[r.jsx("h3",{className:"sys-state-title",children:"No activity yet"}),r.jsx("p",{className:"sys-state-body",children:"Events appear here after agents register, send messages, or advance work."})]}),t.length>0&&r.jsx("div",{className:"sys-audit-list",children:t.map(I=>{const R=s===I.id,D=LW(I.kind),z=zW[D],O=UW(I.workspaceRoot),_=I.summary&&I.summary!==I.title?I.summary:VW(I);return r.jsxs("article",{className:`sys-audit-entry${R?" sys-audit-entry-expanded":""}`,onContextMenu:U=>{const q=window.getSelection()?.toString().trim(),G=[];q&&(G.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>navigator.clipboard.writeText(q)}),G.push({kind:"separator"}));const X=I.title??I.summary??"";X&&G.push({kind:"action",label:"Copy Details",onSelect:()=>navigator.clipboard.writeText(X)}),I.actorName&&G.push({kind:"action",label:"Copy Actor",onSelect:()=>navigator.clipboard.writeText(I.actorName)}),G.push({kind:"action",label:"Copy Event ID",onSelect:()=>navigator.clipboard.writeText(I.id)}),I.conversationId&&(G.push({kind:"separator"}),G.push({kind:"action",label:"Open Thread",onSelect:()=>e({view:"conversation",conversationId:I.conversationId})})),k(U,G)},children:[r.jsxs("button",{type:"button",className:"sys-audit-toggle","aria-expanded":R,onClick:()=>i(R?null:I.id),children:[r.jsxs("div",{className:"sys-audit-stamp",children:[r.jsx("span",{className:"sys-audit-time",children:De(I.ts)}),r.jsx("span",{className:"sys-audit-date",children:la(I.ts)})]}),r.jsx("div",{className:`sys-audit-marker sys-audit-marker-${z.tone}`,children:r.jsx("span",{})}),r.jsxs("div",{className:"sys-audit-body",children:[r.jsxs("div",{className:"sys-audit-topline",children:[r.jsx("span",{className:"sys-audit-category",children:z.label}),r.jsx("span",{className:"sys-audit-kind",children:wR(I.kind)})]}),r.jsx("h3",{className:"sys-audit-title",children:fs(I.title??BW(I))}),r.jsx("p",{className:"sys-audit-summary",children:fs(_)}),r.jsxs("div",{className:"sys-audit-meta",children:[r.jsxs("span",{className:"sys-audit-meta-item",children:[r.jsx("span",{className:"sys-audit-avatar",style:{background:gt(I.actorName??"system")},children:$W(I.actorName)}),I.actorName??"system"]}),O&&r.jsxs("span",{className:"sys-audit-meta-item",children:["Workspace ",O]}),I.conversationId&&r.jsxs("span",{className:"sys-audit-meta-item",children:["Thread ",jR(I.conversationId)]})]})]}),r.jsx("div",{className:"sys-audit-expand",children:R?"Close":"Details"})]}),R&&r.jsxs("div",{className:"sys-audit-details",children:[r.jsxs("div",{className:"sys-detail-grid",children:[r.jsxs("div",{className:"sys-detail-card",children:[r.jsx("span",{className:"sys-detail-label",children:"Event"}),r.jsx("code",{className:"sys-detail-value",children:I.kind})]}),r.jsxs("div",{className:"sys-detail-card",children:[r.jsx("span",{className:"sys-detail-label",children:"Recorded"}),r.jsx("span",{className:"sys-detail-value",children:la(I.ts)})]}),r.jsxs("div",{className:"sys-detail-card",children:[r.jsx("span",{className:"sys-detail-label",children:"Actor"}),r.jsx("span",{className:"sys-detail-value",children:I.actorName??"system"})]}),r.jsxs("div",{className:"sys-detail-card",children:[r.jsx("span",{className:"sys-detail-label",children:"Workspace"}),r.jsx("span",{className:"sys-detail-value",children:I.workspaceRoot??"Not attached"})]}),r.jsxs("div",{className:"sys-detail-card",children:[r.jsx("span",{className:"sys-detail-label",children:"Thread"}),r.jsx("span",{className:"sys-detail-value",children:I.conversationId??"Not attached"})]}),r.jsxs("div",{className:"sys-detail-card",children:[r.jsx("span",{className:"sys-detail-label",children:"Record id"}),r.jsx("code",{className:"sys-detail-value",children:I.id})]})]}),I.conversationId&&r.jsx("div",{className:"sys-inline-actions",children:r.jsx("button",{type:"button",className:"s-btn s-btn-sm",onClick:()=>e({view:"conversation",conversationId:I.conversationId}),children:"Open thread"})})]})]},I.id)})})]})}function Ir(e){const t=e?.trim();if(!t)return null;const[n]=t.split(".");return n?.trim()||t}function HW(e){const t=e.handle?.trim().replace(/^@+/,"");if(t)return`@${t}`;const n=e.selector?.trim();if(n)return n;const s=Ir(e.id);return s?`@${s}`:null}function qW(e){return e.name?.trim()||e.agentName?.trim()||Ir(e.id)||e.title?.trim()||"Conversation"}function Dg(e){return e?e.replace(/_/g," "):null}function ZW({values:e}){return r.jsx("span",{className:"s-agent-token-list",children:e.map(t=>r.jsx("span",{className:"s-agent-token",children:t},t))})}function Bd({title:e,items:t}){return t.length===0?null:r.jsxs("section",{className:"s-agent-profile-card",children:[r.jsx("div",{className:"s-agent-profile-card-header",children:r.jsx("div",{className:"s-agent-profile-card-title",children:e})}),r.jsx("div",{className:"s-agent-meta-card-body",children:t.map(n=>r.jsxs("div",{className:"s-agent-meta-row",children:[r.jsx("span",{className:"s-agent-meta-label",children:n.label}),r.jsx("span",{className:"s-agent-meta-value",children:n.value})]},n.label))})]})}function WW({conversationId:e,navigate:t}){const{agents:n}=ht(),[s,i]=g.useState(null),[l,c]=g.useState(null),d=uR(e),h=g.useCallback(async()=>{c(null);try{const k=await ke(`/api/session/${encodeURIComponent(e)}`).catch(()=>null);i(k)}catch(k){c(k instanceof Error?k.message:String(k)),i(null)}},[e]);g.useEffect(()=>{h()},[h]),Kt(()=>{h()});const m=s?.agentId??d,p=g.useMemo(()=>m?n.find(k=>k.id===m)??null:null,[n,m]);if(!p)return r.jsxs("div",{children:[r.jsx("button",{type:"button",className:"s-back",onClick:()=>t({view:"conversation",conversationId:e}),children:"← Back"}),l&&r.jsx("p",{className:"s-error",children:l}),r.jsx("div",{className:"s-empty",children:r.jsx("p",{children:"Agent not found"})})]});const y=HW(p),x=[{label:"System ID",value:p.id},{label:"Class",value:Dg(p.agentClass)??"—"},...p.role?[{label:"Role",value:p.role}]:[],...p.selector&&p.selector!==y?[{label:"Selector",value:p.selector}]:[]],w=[...p.project?[{label:"Project",value:p.project}]:[],...p.branch?[{label:"Branch",value:p.branch}]:[],...p.projectRoot?[{label:"Path",value:p.projectRoot}]:[],...p.cwd?[{label:"Working dir",value:p.cwd}]:[]],j=[...p.harness?[{label:"Harness",value:p.harness}]:[],...p.model?[{label:"Model",value:p.model}]:[],...p.transport?[{label:"Transport",value:Dg(p.transport)??p.transport}]:[],...p.wakePolicy?[{label:"Wake policy",value:Dg(p.wakePolicy)??p.wakePolicy}]:[],...p.capabilities.length>0?[{label:"Capabilities",value:r.jsx(ZW,{values:p.capabilities})}]:[]],N=[{label:"Thread ID",value:e},...s?.workspaceRoot?[{label:"Workspace",value:s.workspaceRoot}]:[],...s?.currentBranch?[{label:"Session branch",value:s.currentBranch}]:[],...s?.messageCount!=null?[{label:"Messages",value:String(s.messageCount)}]:[],...s?.lastMessageAt?[{label:"Last message",value:la(s.lastMessageAt)}]:[],...p.harnessSessionId?[{label:"Harness session",value:p.harnessSessionId}]:[],...p.harnessLogPath?[{label:"Harness log",value:p.harnessLogPath}]:[]];return r.jsxs("div",{className:"s-agent-profile-page",children:[r.jsxs("div",{className:"s-agent-profile-page-topbar",children:[r.jsx("button",{type:"button",className:"s-back",onClick:()=>t({view:"conversation",conversationId:e}),children:"← Conversation"}),r.jsx("button",{type:"button",className:"s-btn",onClick:()=>t({view:"agents",agentId:p.id}),children:"Open in Agents"})]}),l&&r.jsx("p",{className:"s-error",children:l}),r.jsxs("section",{className:"s-agent-profile-hero",children:[r.jsx("div",{className:"s-agent-profile-hero-main",children:r.jsxs("div",{className:"s-agent-profile-hero-title-row",children:[r.jsx("div",{className:"s-avatar s-agent-profile-hero-avatar",style:{background:gt(p.name)},children:p.name[0].toUpperCase()}),r.jsxs("div",{className:"s-agent-profile-hero-copy",children:[r.jsxs("div",{className:"s-agent-casefile-title-meta",children:[r.jsx("span",{className:"s-agent-casefile-record",children:y??Ir(p.id)??p.id}),r.jsxs("span",{className:`s-agent-state-chip s-agent-state-chip-${Xe(p.state)}`,children:[r.jsx("span",{className:"s-dot",style:{background:Gs(p.state)}}),Hn(p.state)]})]}),r.jsx("h1",{className:"s-agent-profile-hero-title",children:p.name}),r.jsxs("p",{className:"s-agent-profile-hero-context",children:[s?.title?`Conversation: ${s.title}.`:"Attached to the current conversation.",p.updatedAt?` Updated ${De(p.updatedAt)}.`:""]})]})]})}),r.jsx("div",{className:"s-agent-profile-hero-actions",children:r.jsx("button",{type:"button",className:"s-btn s-btn-primary",onClick:()=>t({view:"conversation",conversationId:e}),children:"Open conversation"})})]}),r.jsxs("div",{className:"s-agent-profile-grid",children:[r.jsx(Bd,{title:"Identity",items:x}),r.jsx(Bd,{title:"Workspace",items:w}),r.jsx(Bd,{title:"Runtime",items:j}),r.jsx(Bd,{title:"Conversation context",items:N})]})]})}function YW(e){return e.attention==="interrupt"?"failed":e.state==="done"?"completed":e.attention==="badge"||e.state==="waiting"||e.state==="review"?"updated":"working"}function GW(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 KW(e){switch(e){case"badge":return"Needs attention";case"interrupt":return"Blocked";default:return null}}function ck({items:e,navigate:t,emptyTitle:n,emptyDetail:s}){if(e.length===0){const i=[{titleWidth:"56%",metaWidths:["18%","14%","16%"],summaryWidth:"74%"},{titleWidth:"48%",metaWidths:["16%","20%","12%"],summaryWidth:"62%"}];return r.jsxs("div",{className:"s-work-empty-state",children:[r.jsxs("div",{className:"s-work-empty-copy",children:[r.jsx("p",{className:"s-work-empty-kicker",children:"Quiet for now"}),r.jsx("p",{className:"s-work-empty-title",children:n}),s&&r.jsx("p",{className:"s-work-empty-detail",children:s})]}),r.jsx("div",{className:"s-work-empty-skeleton","aria-hidden":"true",children:i.map((l,c)=>r.jsxs("div",{className:"s-work-empty-row",children:[r.jsxs("div",{className:"s-work-empty-row-header",children:[r.jsx("span",{className:"s-work-empty-line s-work-empty-line-title",style:{width:l.titleWidth}}),r.jsx("span",{className:"s-work-empty-pill"})]}),r.jsx("div",{className:"s-work-empty-row-meta",children:l.metaWidths.map(d=>r.jsx("span",{className:"s-work-empty-line s-work-empty-line-meta",style:{width:d}},d))}),r.jsx("span",{className:"s-work-empty-line s-work-empty-line-summary",style:{width:l.summaryWidth}})]},c))})]})}return r.jsx("div",{className:"s-work-list",children:e.map(i=>{const l=!!i.id||!!i.conversationId,c=KW(i.attention),d=i.ownerName??i.ownerId??"Unassigned",h=i.id?()=>t({view:"work",workId:i.id}):i.conversationId?()=>t({view:"conversation",conversationId:i.conversationId}):void 0;return r.jsxs("div",{className:`s-work-row${l?" s-work-row-clickable":""}`,onClick:h,children:[r.jsxs("div",{className:"s-work-row-header",children:[r.jsxs("div",{className:"s-work-row-title-wrap",children:[r.jsx("span",{className:"s-work-row-title",children:i.title}),i.priority&&r.jsx("span",{className:"s-badge",children:i.priority})]}),r.jsx("span",{className:`s-pill s-pill-${YW(i)}`,children:i.currentPhase})]}),r.jsxs("div",{className:"s-work-row-meta",children:[r.jsx("span",{children:d}),r.jsx("span",{children:GW(i.state)}),i.activeChildWorkCount>0&&r.jsxs("span",{children:[i.activeChildWorkCount," child",i.activeChildWorkCount===1?"":"ren"]}),i.activeFlightCount>0&&r.jsxs("span",{children:[i.activeFlightCount," flight",i.activeFlightCount===1?"":"s"]}),c&&r.jsx("span",{children:c}),r.jsx("span",{children:De(i.lastMeaningfulAt)})]}),i.lastMeaningfulSummary&&r.jsx("p",{className:"s-work-row-summary",children:fs(i.lastMeaningfulSummary)})]},i.id)})})}const NR="/api",XW=`${NR}/health`,JW=`${NR}/terminal/run`,SR="/ws/terminal",QW=`${SR}/health`,eY="/ws/hmr";function tY(e,t){if(typeof e!="string")return t;const n=e.trim();return n&&`${n.startsWith("/")?"":"/"}${n}`.replace(/\/{2,}/g,"/").replace(/\/+$/g,"")||t}const nY={healthPath:XW,terminalRunPath:JW,terminalRelayPath:SR,terminalRelayHealthPath:QW,viteHmrPath:eY};function kR(){return typeof window>"u"?null:window.__OPENSCOUT_WEB_BOOTSTRAP__??null}function sY(){const e=kR()?.theme;return typeof e=="string"?e:null}function iu(e){return tY(kR()?.routes?.[e],nY[e])}function ER(){const e=iu("terminalRelayPath");return typeof window>"u"?`ws://localhost:3200${e}`:`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${e}`}function CR(){const e=iu("terminalRelayHealthPath");return typeof window>"u"?`http://localhost:3200${e}`:`${window.location.protocol}//${window.location.host}${e}`}function aY(e){return e.kind==="direct"}function Xo(e){return e.kind==="channel"||e.kind==="group_direct"||e.id.startsWith("channel.")}function Or(e){return e.title&&e.title!==e.id?e.title:e.id.startsWith("channel.")?e.id.replace(/^channel\./,""):e.agentName??e.id}function rY(e){return e.id.startsWith("channel.")?e.id.replace(/^channel\./,""):Or(e)}const Jv=/^```([a-z0-9_-]+)?\s*$/iu,AR=/^(#{1,6})\s+(.+)$/u,iY=/^(?:-{3,}|\*{3,}|_{3,})$/u,oY=/^\s*[-*]\s+(.+)$/u,lY=/^\s*\d+[.)]\s+(.+)$/u,cY=/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?$/u;function uY(e){const t=e.replace(/\r\n?/gu,`
|
|
141
|
-
`).trim();return t?t.replace(/([^\n])\s+---\s+(?=(?:#{1,6}\s|\*\*|[A-Z0-9]))/gu,`$1
|
|
142
|
-
|
|
143
|
-
---
|
|
144
|
-
|
|
145
|
-
`).replace(/([^\n])\s+(#{1,6}\s+)/gu,`$1
|
|
146
|
-
|
|
147
|
-
$2`).replace(/\n{3,}/gu,`
|
|
148
|
-
|
|
149
|
-
`):""}function TR(e){return e.trim().length===0}function dY(e){return AR.test(e.trim())}function MR(e){return iY.test(e.trim())}function Qv(e){return e.match(oY)?.[1]?.trim()??null}function ey(e){return e.match(lY)?.[1]?.trim()??null}function fY(e){return Qv(e)!==null||ey(e)!==null}function uk(e){return e.trim().replace(/^\|/u,"").replace(/\|$/u,"").split("|").map(n=>n.trim())}function RR(e,t){const n=e[t]?.trim(),s=e[t+1]?.trim();return!!(n&&s&&n.includes("|")&&cY.test(s))}function hY(e,t){const n=e[t]??"",s=n.trim();return!!(TR(n)||Jv.test(s)||dY(n)||MR(n)||fY(n)||s.startsWith(">")||RR(e,t))}function mY(e){const t=uY(e);if(!t)return[];const n=t.split(`
|
|
150
|
-
`),s=[];let i=0;for(;i<n.length;){const l=n[i]??"",c=l.trim();if(!c){i+=1;continue}const d=c.match(Jv);if(d){const x=[];for(i+=1;i<n.length&&!Jv.test(n[i].trim());)x.push(n[i]),i+=1;i<n.length&&(i+=1),s.push({type:"code",language:d[1]??null,text:x.join(`
|
|
151
|
-
`)});continue}if(MR(l)){s.push({type:"hr"}),i+=1;continue}const h=c.match(AR);if(h){s.push({type:"heading",depth:h[1].length,text:h[2].trim()}),i+=1;continue}if(RR(n,i)){const x=uk(n[i]);i+=2;const w=[];for(;i<n.length&&n[i].includes("|")&&!TR(n[i]);)w.push(uk(n[i])),i+=1;s.push({type:"table",headers:x,rows:w});continue}const m=Qv(l),p=ey(l);if(m!==null||p!==null){const x=p!==null,w=[];for(;i<n.length;){const j=x?ey(n[i]):Qv(n[i]);if(j===null)break;w.push(j),i+=1}s.push({type:"list",ordered:x,items:w});continue}if(c.startsWith(">")){const x=[];for(;i<n.length&&n[i].trim().startsWith(">");)x.push(n[i].trim().replace(/^>\s?/u,"")),i+=1;s.push({type:"blockquote",text:x.join(`
|
|
152
|
-
`).trim()});continue}const y=[];for(;i<n.length&&!hY(n,i);)y.push(n[i].trimEnd()),i+=1;s.push({type:"paragraph",text:y.join(`
|
|
153
|
-
`).trim()})}return s}function pY(e,t){const n=Math.min(6,Math.max(2,e.depth+1));return r.jsx("div",{role:"heading","aria-level":n,className:`s-message-markup-heading s-message-markup-heading-${e.depth}`,children:fs(e.text)},t)}function gY(e,t){return r.jsx("div",{className:"s-message-markup-table-wrap",children:r.jsxs("table",{className:"s-message-markup-table",children:[r.jsx("thead",{children:r.jsx("tr",{children:e.headers.map((n,s)=>r.jsx("th",{children:fs(n)},`${t}:h:${s}`))})}),r.jsx("tbody",{children:e.rows.map((n,s)=>r.jsx("tr",{children:e.headers.map((i,l)=>r.jsx("td",{children:fs(n[l]??"")},`${t}:c:${s}:${l}`))},`${t}:r:${s}`))})]})},t)}function vY(e,t){switch(e.type){case"paragraph":return r.jsx("p",{className:"s-message-markup-paragraph",children:fs(e.text)},t);case"heading":return pY(e,t);case"hr":return r.jsx("hr",{className:"s-message-markup-rule"},t);case"list":return e.ordered?r.jsx("ol",{className:"s-message-markup-list",children:e.items.map((n,s)=>r.jsx("li",{children:fs(n)},`${t}:${s}`))},t):r.jsx("ul",{className:"s-message-markup-list",children:e.items.map((n,s)=>r.jsx("li",{children:fs(n)},`${t}:${s}`))},t);case"blockquote":return r.jsx("blockquote",{className:"s-message-markup-quote",children:fs(e.text)},t);case"code":return r.jsx("pre",{className:"s-message-markup-code",children:r.jsx("code",{children:e.text})},t);case"table":return gY(e,t)}}function Rx({text:e,className:t}){const n=mY(e??"");return n.length===0?e??"":r.jsx("div",{className:["s-message-markup",t].filter(Boolean).join(" "),children:n.map(vY)})}const _R="scout:sessions:lastViewed";function Ah(){if(typeof localStorage>"u")return{};try{const e=localStorage.getItem(_R);if(!e)return{};const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function _x(e,t=Date.now()){const n=Ah();n[e]=t;try{localStorage.setItem(_R,JSON.stringify(n))}catch{}return n}function IR(e,t,n){return e?e>(n[t]??0):!1}async function yY(e){await fetch(iu("terminalRunPath"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e})})}const ty=new Set(["completed","failed","cancelled"]),xY={direct:"Direct message",channel:"Channel",group_direct:"Group",thread:"Thread"},dk=[{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 OR(e,t){if(t<=0)return!0;const n=e[t-1];return!n||/\s/.test(n)}function bY(e,t){if(t===0)return null;let n=t-1;for(;n>=0;){const i=e[n];if(i==="/")break;if(!i||/\s/.test(i))return null;n-=1}if(n<0||e[n]!=="/"||!OR(e,n))return null;const s=e.slice(n+1,t);return/[^a-zA-Z0-9_-]/.test(s)?null:{start:n,query:s}}function wY(e,t){if(t===0)return null;let n=t-1;for(;n>=0;){const i=e[n];if(i==="@")break;if(!i||/\s/.test(i))return null;n-=1}if(n<0||e[n]!=="@"||!OR(e,n))return null;const s=e.slice(n+1,t);return/[^a-zA-Z0-9._/:-]/.test(s)?null:{start:n,query:s}}function ns(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?null:e<1e12?e*1e3:e}function jY(e){if(!e)return null;const t=e.replace(/[\\/]+$/,"");return t?t.split(/[\\/]/).filter(Boolean).at(-1)??t:null}function NY(e){return e.kind==="direct"&&e.agentName?e.agentName:e.kind==="direct"&&e.agentId?Ir(e.agentId)??e.agentId:e.title.replace(/\s*<>\s*/g," · ")}function Pg(e){const t=ns(e);return t===null?"":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(t)}function SY(e,t){const n=ns(e),s=ns(t);if(n===null||s===null)return!1;const i=new Date(n),l=new Date(s);return i.getFullYear()===l.getFullYear()&&i.getMonth()===l.getMonth()&&i.getDate()===l.getDate()}function fk(e){const t=ns(e);if(t===null)return"";const n=new Date(t),s=new Date,i=new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime(),l=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),c=1440*60*1e3;return l===i?"Today":l===i-c?"Yesterday":new Intl.DateTimeFormat(void 0,{weekday:"short",month:"short",day:"numeric"}).format(t)}function kY(e){switch(e){case"status":return"Status";case"system":return"System";case"scout.dispatch":return"Dispatch";default:return null}}function Vd(e){return[...e].sort((t,n)=>(ns(t.createdAt)??0)-(ns(n.createdAt)??0))}function EY(e){return e.filter(t=>!ty.has(t.state)).sort((t,n)=>(ns(n.startedAt)??0)-(ns(t.startedAt)??0))[0]??null}function hk(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 CY(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 ny(e,t){if(e.class==="operator")return!0;const n=e.actorName?.toLowerCase()??"";return n===t.toLowerCase()||n==="operator"||n==="you"}function AY(e,t){return e.reduce((n,s)=>{if(ny(s,t))return n;const i=ns(s.createdAt);return i===null?n:n===null||i>n?i:n},null)}function TY(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 MY(e){const{agentName:t,agentState:n,sending:s,currentFlight:i,showWorkingTurn:l}=e;if(s&&!i)return{label:"Sending",detail:`Handing your message to ${t}.`,tone:"pending",showStrip:!0,showTyping:!1};if(i&&l){const c=i.summary?.trim()||TY(t,i.state);switch(i.state){case"queued":return{label:"Queued",detail:c,tone:"pending",showStrip:!0,showTyping:!0};case"waking":return{label:"Coming online",detail:c,tone:"working",showStrip:!0,showTyping:!0};case"waiting":return{label:"Thinking",detail:c,tone:"working",showStrip:!0,showTyping:!0};default:return{label:"Working",detail:c,tone:"working",showStrip:!0,showTyping:!0}}}return _r(n)?{label:"Available",detail:`${t} is connected.`,tone:"idle",showStrip:!1,showTyping:!1}:{label:"Offline",detail:`${t} is offline right now. Sending a message will wake it up.`,tone:"offline",showStrip:!0,showTyping:!1}}function RY(e,t){switch(e.tone){case"pending":return"var(--accent)";case"working":return"var(--green)";case"offline":return"var(--dim)";default:return Gs(t)}}function _Y(){return r.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:[r.jsx("path",{d:"m3 11 18-8-8 18-2.8-7.2L3 11Z"}),r.jsx("path",{d:"M10.2 13.8 21 3"})]})}function IY(){return r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:r.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})}function OY(e){if(!e)return null;if(e.kind==="direct")return e.agentName??Ir(e.agentId)??null;const t=e.participantIds.filter(n=>n!=="operator");return t.length===0?null:t.map(n=>Ir(n)??n).join(", ")}function Ix({conversationId:e,initialComposeMode:t,initialDraft:n,navigate:s,embedded:i}){const{agents:l}=ht(),[c,d]=g.useState(null),[h,m]=g.useState([]),[p,y]=g.useState(null),[x,w]=g.useState([]),[j,N]=g.useState(null),k=g.useRef(null),E=g.useRef(null),A=g.useRef(new Set),S=g.useRef(null),M=g.useRef(0),C=g.useRef(null);g.useEffect(()=>{e.startsWith("channel.")&&s({view:"channels",channelId:e})},[e,s]);const I=uR(e),R=c?.agentId??I,D=c?.kind==="direct"||I!==null,z=g.useMemo(()=>R?l.find(Q=>Q.id===R)??null:null,[l,R]),[O,_]=g.useState([]),[U,q]=g.useState(new Set),[G]=g.useState(()=>Ah());g.useEffect(()=>{ke("/api/conversations").then(Q=>_(Q.sort((ye,Ne)=>(Ne.lastMessageAt??0)-(ye.lastMessageAt??0)))).catch(()=>{}),ke("/api/fleet").then(Q=>{const ye=new Set;for(const Ne of Q.needsAttention)Ne.conversationId&&ye.add(Ne.conversationId),Ne.agentId&&ye.add(Ne.agentId);for(const Ne of Q.activeAsks)Ne.status==="needs_attention"&&Ne.conversationId&&ye.add(Ne.conversationId);q(ye)}).catch(()=>{})},[]),g.useEffect(()=>{const Q=O.find(ye=>ye.id===e);Q&&Xo(Q)&&s({view:"channels",channelId:e})},[e,s,O]);const X=g.useCallback(async()=>{N(null);try{const Q=await ke(`/api/session/${encodeURIComponent(e)}`).catch(()=>null);d(Q);const ye=Q?.agentId??I,Ne=Q?.kind==="direct"&&ye&&ye.startsWith("local-session-agent-")?Nn(ye):e;if(Ne!==e){s({view:"conversation",conversationId:Ne,...t?{composeMode:t}:{}});return}const[We,Ge]=await Promise.all([ke(`/api/messages?conversationId=${encodeURIComponent(Ne)}&limit=300`),ke(`/api/flights?conversationId=${encodeURIComponent(Ne)}`)]);m(Vd(We)),w(Ge),A.current=new Set(Ge.map(vt=>vt.invocationId)),y(EY(Ge))}catch(Q){N(Q instanceof Error?Q.message:String(Q))}},[e,t,I,s]);g.useEffect(()=>{X()},[X]);const[L,F]=g.useState(null),[H,V]=g.useState(!1);g.useEffect(()=>{if(!R)return;let Q=!1;return ke(`/api/agents/${encodeURIComponent(R)}/session-catalog`).then(ye=>{Q||F(ye)}).catch(()=>{}),()=>{Q=!0}},[R]),g.useEffect(()=>{S.current=p},[p]);const[W,$]=g.useState(()=>n??""),[B,Y]=g.useState(!1),[te,ae]=g.useState("operator"),[ee,ie]=g.useState({open:!1,query:"",triggerStart:-1,index:0}),[de,xe]=g.useState({open:!1,query:"",triggerStart:-1,index:0}),[Ae,me]=g.useState(null),[Pe,Re]=g.useState(t==="ask"?"ask":"tell");g.useEffect(()=>{Re(D&&t==="ask"?"ask":"tell")},[e,t,D]),g.useEffect(()=>{if(!n)return;const Q=`${e}:${n}`;C.current!==Q&&(C.current=Q,$(n),requestAnimationFrame(()=>E.current?.focus()))},[e,n]);const Ye=g.useMemo(()=>{const Q=new Set,ye=[];for(const Ne of l){const We=Ne.handle?.trim().replace(/^@+/,"")??Ir(Ne.id)??Ne.id;if(!We)continue;const Ge=We.toLowerCase();Q.has(Ge)||(Q.add(Ge),ye.push({id:Ne.id,label:We,name:Ne.name??We,handle:We}))}return ye.sort((Ne,We)=>Ne.handle.localeCompare(We.handle))},[l]),Ie=g.useMemo(()=>{if(!ee.open)return[];const Q=ee.query.toLowerCase();return Q?dk.filter(ye=>ye.command.toLowerCase().startsWith("/"+Q)||ye.command.toLowerCase().includes(Q)):dk},[ee.open,ee.query]),oe=g.useMemo(()=>{if(!de.open)return[];const Q=de.query.toLowerCase();return Q?Ye.filter(ye=>ye.handle.toLowerCase().includes(Q)||ye.name.toLowerCase().includes(Q)).slice(0,8):Ye.slice(0,8)},[de.open,de.query,Ye]),je=g.useCallback(()=>{ie(Q=>Q.open?{...Q,open:!1}:Q),xe(Q=>Q.open?{...Q,open:!1}:Q)},[]),Fe=g.useCallback((Q,ye)=>{const Ne=bY(Q,ye);ie(Ne?Ge=>({open:!0,query:Ne.query,triggerStart:Ne.start,index:Ge.open&&Ge.triggerStart===Ne.start?Ge.index:0}):Ge=>Ge.open?{...Ge,open:!1}:Ge);const We=wY(Q,ye);xe(We?Ge=>({open:!0,query:We.query,triggerStart:We.start,index:Ge.open&&Ge.triggerStart===We.start?Ge.index:0}):Ge=>Ge.open?{...Ge,open:!1}:Ge)},[]),le=g.useCallback(Q=>{const ye=E.current,Ne=ee.triggerStart;if(Ne<0)return;const We=ye?.selectionStart??W.length,Ge=W.slice(0,Ne),vt=W.slice(We),At=Q.insert,Qt=`${Ge}${At}${vt}`;$(Qt),ie(Sn=>({...Sn,open:!1})),requestAnimationFrame(()=>{const Sn=E.current;if(!Sn)return;const kn=Ge.length+At.length;Sn.focus(),Sn.setSelectionRange(kn,kn)})},[W,ee.triggerStart]),ve=g.useCallback(Q=>{const ye=E.current,Ne=de.triggerStart;if(Ne<0)return;const We=ye?.selectionStart??W.length,Ge=W.slice(0,Ne),vt=W.slice(We),At=vt.length===0||!vt.startsWith(" "),Qt=`@${Q.handle}${At?" ":""}`,Sn=`${Ge}${Qt}${vt}`;$(Sn),xe(kn=>({...kn,open:!1})),requestAnimationFrame(()=>{const kn=E.current;if(!kn)return;const qn=Ge.length+Qt.length;kn.focus(),kn.setSelectionRange(qn,qn)})},[W,de.triggerStart]);g.useEffect(()=>{const Q=E.current;if(!Q)return;Q.style.height="0px";const ye=Math.min(Math.max(Q.scrollHeight,40),160);Q.style.height=`${ye}px`,Q.style.overflowY=Q.scrollHeight>ye?"auto":"hidden"},[W]),g.useEffect(()=>{ke("/api/user").then(Q=>ae(Q.name)).catch(()=>{})},[]);const ue=g.useMemo(()=>AY(h,te),[h,te]);g.useEffect(()=>{Ae===null||ue===null||ue>=Ae&&me(null)},[Ae,ue]);const Ce=g.useMemo(()=>!p||ty.has(p.state)?!1:(ns(p.startedAt)??Ae??Date.now())>=(ue??0),[Ae,p,ue]),be=B||Ae!==null||Ce,we=qW({name:z?.name,agentName:c?.agentName,id:R,title:c?.title}),Se=g.useMemo(()=>MY({agentName:we,agentState:z?.state??null,sending:B,currentFlight:p,showWorkingTurn:Ce}),[z?.state,we,p,B,Ce]),He=c?NY(c):we,et=c?.kind?xY[c.kind]??c.kind:"Conversation";OY(c);const Be=jY(c?.workspaceRoot),St=c?.lastMessageAt??h[h.length-1]?.createdAt??null,Dt=[Be?{label:Be,title:c?.workspaceRoot??void 0}:null,c?.currentBranch?{label:c.currentBranch,title:c.currentBranch}:null,z?.harness??c?.harness?{label:z?.harness??c?.harness??"",title:void 0}:null].filter(Q=>!!Q),Xt=c?c.participantIds.length:D?2:1,Ee=g.useMemo(()=>(!U.has(e)&&!(R&&U.has(R)),null),[e,R,U]);Kt(g.useCallback(Q=>{if(Q.kind==="message.posted"){const ye=Q.payload?.message;if(!ye||ye.conversationId!==e)return;const Ne=ye.actorId===R,We={id:ye.id,conversationId:ye.conversationId,actorName:Ne?we:te,body:ye.body,createdAt:ye.createdAt,class:Ne?ye.class:"operator"};if(m(Ge=>{if(Ge.some(vt=>vt.id===ye.id))return Ge;if(!Ne){const vt=Ge.findIndex(At=>At.id.startsWith("optimistic-")&&At.body===ye.body&&Math.abs((ns(At.createdAt)??0)-(ns(ye.createdAt)??0))<=6e4);if(vt!==-1){const At=[...Ge];return At[vt]=We,Vd(At)}}return Vd([...Ge,We])}),Ne){const Ge=ns(ye.createdAt)??Date.now();me(vt=>vt===null||Ge<vt?vt:null),y(vt=>{if(!vt)return vt;const At=ns(vt.startedAt)??0;return Ge>=At?null:vt})}return}if(Q.kind==="invocation.requested"){const ye=Q.payload?.invocation;if(!ye||ye.targetAgentId!==R||ye.conversationId!==e)return;A.current.add(ye.id),me(Ne=>Ne??Date.now());return}if(Q.kind==="flight.updated"){const ye=Q.payload?.flight;if(!ye||ye.targetAgentId!==R||!(A.current.has(ye.invocationId)||S.current?.id===ye.id))return;if(ty.has(ye.state)){y(We=>We?.id===ye.id?null:We),X();return}A.current.add(ye.invocationId),y(hk(ye,e,R??""));return}Q.kind!=="agent.endpoint.upserted"&&Q.kind==="unknown"&&X()},[R,we,e,X,te])),g.useEffect(()=>{if(!be)return;const Q=setInterval(()=>{X()},5e3);return()=>clearInterval(Q)},[be,X]),g.useEffect(()=>{const Q=()=>{if(document.visibilityState!=="visible")return;const ye=Date.now();ye-M.current<1e3||(M.current=ye,X())};return window.addEventListener("focus",Q),document.addEventListener("visibilitychange",Q),()=>{window.removeEventListener("focus",Q),document.removeEventListener("visibilitychange",Q)}},[X]);const Oe=h.length+(Se.showTyping?1:0),Te=g.useRef(0),tt=g.useRef(!1);g.useEffect(()=>{if(Oe>Te.current){const Q=tt.current?"smooth":"instant";k.current?.scrollIntoView({behavior:Q}),tt.current=!0}Te.current=Oe},[Oe]);const[,at]=g.useState(0);g.useEffect(()=>{const Q=setInterval(()=>at(ye=>ye+1),15e3);return()=>clearInterval(Q)},[]);const it=async(Q,ye)=>{const Ne=Q.trim();if(!Ne||B)return;const We=ye?.forceMode??Pe,Ge=D?be?"steer":We:"tell",vt=Date.now(),At={id:`optimistic-${vt}`,conversationId:e,actorName:te,body:Ne,createdAt:vt,class:"operator"};Y(!0),me(vt),N(null),m(Qt=>Vd([...Qt,At]));try{const Qt=await ke(Ge==="ask"?"/api/ask":"/api/send",{method:"POST",body:JSON.stringify({body:Ne,conversationId:e})});Qt.flight&&(A.current.add(Qt.flight.invocationId),y(hk(Qt.flight,e,R??"")))}catch(Qt){m(Sn=>Sn.filter(kn=>kn.id!==At.id)),me(null),N(Qt instanceof Error?Qt.message:String(Qt))}finally{Y(!1)}},yt=async()=>{const Q=W.trim();Q&&($(""),await it(Q))},Jt=async()=>{if(R)try{await ke("/api/agents/"+encodeURIComponent(R)+"/interrupt",{method:"POST",body:JSON.stringify({})})}catch{}},Pt=Se.tone==="working"||Se.tone==="pending",on=D?be?"steer":Pe:"tell",ln=D?"Reply — or type / to route, @ to mention an agent, ? to ask a question":`Message ${we}...`,_e=!W.trim()&&Pt,jt=Mx(),Wt=g.useCallback((Q,ye)=>{const Ne=window.getSelection()?.toString().trim(),We=[];Ne&&(We.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>navigator.clipboard.writeText(Ne)}),We.push({kind:"separator"})),We.push({kind:"action",label:"Copy Message",onSelect:()=>navigator.clipboard.writeText(ye.body)}),ye.actorName&&!ny(ye,te)&&We.push({kind:"action",label:"Copy Agent ID",onSelect:()=>navigator.clipboard.writeText(ye.actorName??"")}),We.push({kind:"separator"}),We.push({kind:"action",label:"Copy Message ID",onSelect:()=>navigator.clipboard.writeText(ye.id)}),jt(Q,We)},[te,jt]),Fa=async(Q,ye)=>{const Ne=`@${ye.agentId} `,We=W.trim();if(We){$(""),await it(`${Ne}${We}`,{forceMode:"tell"});return}$(Ne),E.current?.focus()},Ds=g.useMemo(()=>c?c.participantIds.filter(Q=>Q!=="operator").slice(0,4).map(Q=>{const ye=l.find(Ne=>Ne.id===Q);return{id:Q,name:ye?.name??Q}}):[],[c,l]);return r.jsx("div",{className:`s-thread-layout${i?" s-thread-layout--embedded":""}`,children:r.jsxs("div",{className:"s-thread-center",children:[!i&&r.jsxs("div",{className:"s-thread-center-header",onClick:()=>D?s({view:"agent-info",conversationId:e}):void 0,style:D?{cursor:"pointer"}:void 0,onContextMenu:Q=>{const ye=[{kind:"action",label:"Copy Title",onSelect:()=>navigator.clipboard.writeText(He)}];R&&ye.push({kind:"action",label:"Copy Agent ID",onSelect:()=>navigator.clipboard.writeText(R)}),ye.push({kind:"action",label:"Copy Conversation ID",onSelect:()=>navigator.clipboard.writeText(e)}),jt(Q,ye)},children:[r.jsxs("div",{className:"s-thread-center-header-info",children:[r.jsx("span",{className:"s-thread-center-header-name",children:He}),r.jsxs("div",{className:"s-thread-center-header-eyebrow",children:[r.jsx("span",{className:"s-thread-center-header-kicker",children:et}),St&&r.jsx("span",{className:"s-thread-center-header-time",title:Pg(St),children:De(St)})]})]}),r.jsxs("div",{className:"s-thread-center-header-right",children:[Dt.length>0&&r.jsx("div",{className:"s-thread-center-header-chips",children:Dt.map((Q,ye)=>r.jsx("span",{className:"s-thread-center-chip",title:Q.title,children:Q.label},`${Q.label}-${ye}`))}),Ds.length>0&&r.jsxs("div",{className:"s-thread-center-avatars",children:[Ds.map(Q=>r.jsx("div",{className:"s-ops-avatar",style:{"--size":"22px",background:gt(Q.name)},title:Q.name,children:Q.name[0]?.toUpperCase()??"?"},Q.id)),r.jsx("span",{className:"s-thread-center-participant-count",children:Xt})]})]})]}),Ee&&r.jsxs("div",{className:"s-thread-pinned-ask",children:[r.jsx("div",{className:"s-thread-pinned-ask-label",children:"Pinned ask · Awaiting operator"}),r.jsx("div",{className:"s-thread-pinned-ask-body",children:Ee.task}),r.jsxs("div",{className:"s-thread-pinned-ask-routing",children:[r.jsx("span",{children:Ee.agentName??Ir(Ee.agentId)??Ee.agentId}),r.jsx("span",{className:"s-thread-pinned-ask-routing-arrow",children:"→"}),r.jsx("span",{children:"You"})]}),r.jsxs("div",{className:"s-thread-pinned-ask-actions",children:[r.jsx("button",{type:"button",className:"s-ops-btn s-ops-btn--primary",onClick:()=>{E.current?.focus()},children:"Answer"}),r.jsx("button",{type:"button",className:"s-ops-btn",children:"Defer"}),r.jsx("button",{type:"button",className:"s-ops-btn",children:"Route"})]}),r.jsx("div",{className:"s-thread-pinned-ask-strip"})]}),Se.showStrip&&r.jsxs("div",{className:`s-thread-status s-thread-status--${Se.tone}`,"aria-live":"polite",children:[r.jsx("span",{className:"s-thread-status-dot",style:{background:RY(Se,z?.state??null)}}),r.jsxs("div",{className:"s-thread-status-copy",children:[r.jsx("span",{className:"s-thread-status-label",children:Se.label}),r.jsx("span",{className:"s-thread-status-detail",children:Se.detail})]})]}),!i&&D&&z&&(z.harnessSessionId||z.harnessLogPath||L?.activeSessionId)&&r.jsxs("details",{className:"s-thread-meta-disclosure",children:[r.jsx("summary",{className:"s-thread-meta-toggle",children:"Session details"}),r.jsxs("div",{className:"s-thread-meta-block",children:[L?.activeSessionId&&r.jsxs("div",{className:"s-thread-meta-row",children:[r.jsx("span",{className:"s-thread-meta-row-label",children:"Session ID"}),r.jsx("span",{className:"s-thread-meta-row-value s-thread-meta-row-value--accent",title:L.activeSessionId,children:L.activeSessionId.slice(0,8)})]}),L?.resumeCommand&&r.jsxs("div",{className:"s-thread-meta-row",children:[r.jsx("span",{className:"s-thread-meta-row-label",children:"Takeover"}),r.jsx("span",{className:"s-thread-meta-row-value",children:r.jsx("button",{type:"button",className:"s-thread-meta-takeover-btn",title:L.resumeCommand,onClick:()=>{yY(L.resumeCommand).then(()=>s({view:"terminal",agentId:R??void 0})),V(!0)},children:H?"Going…":`Takeover — ${L.resumeCommand}`})})]}),z.harnessSessionId&&r.jsxs("div",{className:"s-thread-meta-row",children:[r.jsx("span",{className:"s-thread-meta-row-label",children:"Harness Session"}),r.jsx("span",{className:"s-thread-meta-row-value",children:z.harnessSessionId})]}),z.harnessLogPath&&r.jsxs("div",{className:"s-thread-meta-row",children:[r.jsx("span",{className:"s-thread-meta-row-label",children:"Harness Log"}),r.jsx("span",{className:"s-thread-meta-row-value",children:z.harnessLogPath})]})]})]}),j&&r.jsx("p",{className:"s-thread-error",children:j}),r.jsxs("div",{className:"s-thread-feed",children:[r.jsx("div",{className:"s-thread-feed-spacer"}),h.length===0?r.jsxs("div",{className:"s-thread-empty",children:[r.jsx("div",{className:"s-thread-empty-glyph","aria-hidden":"true",children:D?"@":"#"}),r.jsx("p",{children:He}),r.jsx("p",{children:D?"No messages yet. Use Tell for quick updates or Ask to create owned work with a reply.":"No messages yet. Start the thread below."}),(Be||c?.currentBranch)&&r.jsxs("div",{className:"s-thread-empty-chips",children:[Be&&r.jsx("span",{className:"s-thread-empty-chip",children:Be}),c?.currentBranch&&r.jsx("span",{className:"s-thread-empty-chip",children:c.currentBranch})]})]}):h.map((Q,ye)=>{const Ne=ny(Q,te),We=CY(Q),Ge=We?"scout.dispatch":Q.class,vt=kY(Ge),At=Ge==="status",Qt=ye===0||!SY(h[ye-1]?.createdAt,Q.createdAt),Sn=Pg(Q.createdAt),kn=!Ne&&Q.actorName?l.find(xt=>xt.name===Q.actorName)??null:null,qn=Ne?te.toLowerCase():kn?.handle??null;return r.jsxs("div",{className:["s-thread-feed-block",Ne&&"s-thread-feed-block--you",Qt&&"s-thread-feed-block--full-width"].filter(Boolean).join(" "),children:[Qt&&r.jsxs("div",{className:"s-thread-day-divider","aria-label":fk(Q.createdAt),children:[r.jsx("span",{className:"s-thread-day-line","aria-hidden":"true"}),r.jsx("span",{className:"s-thread-day-label",children:fk(Q.createdAt)}),r.jsx("span",{className:"s-thread-day-line","aria-hidden":"true"})]}),r.jsx("article",{id:`msg-${Q.id}`,className:["s-thread-msg",Ne&&"s-thread-msg--you",At&&"s-thread-msg--tool"].filter(Boolean).join(" "),"data-class":Ge,onContextMenu:xt=>Wt(xt,Q),children:r.jsxs("div",{className:"s-thread-msg-card s-thread-msg-card--avatar-row",children:[r.jsx("div",{className:"s-ops-avatar s-thread-msg-avatar",style:{"--size":"28px",background:gt(Ne?te:Q.actorName??"?")},children:(Ne?te[0]:Q.actorName?.[0]??"?").toUpperCase()}),r.jsxs("div",{className:"s-thread-msg-card-content",children:[r.jsxs("div",{className:"s-thread-msg-header",children:[r.jsxs("div",{className:"s-thread-msg-meta",children:[r.jsx("span",{className:"s-thread-msg-actor",children:Ne?te:Q.actorName}),qn&&r.jsxs("span",{className:"s-thread-msg-handle",children:["@",qn]}),vt&&r.jsx("span",{className:"s-thread-msg-kind",children:vt})]}),r.jsx("span",{className:"s-thread-msg-time",title:Sn,children:De(Q.createdAt)}),r.jsx("button",{type:"button",className:"s-thread-msg-permalink","aria-label":"Copy link to message",title:"Copy link to message",onClick:()=>{const xt=`${window.location.origin}${window.location.pathname}#msg-${Q.id}`;navigator.clipboard.writeText(xt)},children:r.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:[r.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"}),r.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"})]})})]}),r.jsx("div",{className:"s-thread-msg-body",title:Sn,children:r.jsx(Rx,{text:Q.body})}),We&&We.candidates.length>0&&r.jsx("div",{className:"s-thread-dispatch",children:We.candidates.map(xt=>r.jsxs("button",{type:"button",className:"s-thread-dispatch-tile",onClick:()=>{Fa(We,xt)},children:[r.jsxs("span",{className:"s-thread-dispatch-tile-id",children:["@",xt.agentId]}),r.jsx("span",{className:"s-thread-dispatch-tile-state",children:xt.endpointState}),r.jsx("span",{className:"s-thread-dispatch-tile-meta",children:[xt.workspace,xt.node,xt.projectRoot].filter(Boolean).join(" · ")||xt.displayName})]},xt.agentId))})]})]})})]},Q.id)}),Se.showTyping&&r.jsx("div",{className:"s-thread-feed-block",children:r.jsx("div",{className:"s-thread-msg","aria-live":"polite",children:r.jsxs("div",{className:"s-thread-msg-card s-thread-msg-working-card s-thread-msg-card--avatar-row",children:[r.jsx("div",{className:"s-ops-avatar s-thread-msg-avatar",style:{"--size":"28px",background:gt(we)},children:we[0]?.toUpperCase()??"?"}),r.jsxs("div",{className:"s-thread-msg-card-content",children:[r.jsxs("div",{className:"s-thread-msg-header",children:[r.jsxs("div",{className:"s-thread-msg-meta",children:[r.jsx("span",{className:"s-thread-msg-actor",children:we}),r.jsx("span",{className:"s-thread-msg-kind",children:"Live"})]}),r.jsx("span",{className:"s-thread-msg-time",title:p?.startedAt?Pg(p.startedAt):"now",children:p?.startedAt?De(p.startedAt):"now"})]}),r.jsxs("div",{className:"s-thread-msg-working-body",children:[r.jsxs("span",{className:"s-thread-typing-indicator","aria-hidden":"true",children:[r.jsx("span",{className:"s-thread-typing-dot"}),r.jsx("span",{className:"s-thread-typing-dot"}),r.jsx("span",{className:"s-thread-typing-dot"})]}),r.jsx("span",{className:"s-thread-msg-working-copy",children:Se.detail})]})]})]})})}),r.jsx("div",{ref:k})]}),Se.showTyping&&r.jsxs("div",{className:"s-thread-presence-line",children:[r.jsx("div",{className:"s-thread-presence-line-avatars",children:r.jsx("div",{className:"s-ops-avatar",style:{"--size":"20px",background:gt(we)},children:we[0]?.toUpperCase()??"?"})}),r.jsxs("span",{className:"s-thread-presence-line-label",children:[we," is ",Se.label.toLowerCase(),"..."]}),r.jsx("div",{className:"s-thread-presence-strip"})]}),r.jsx("form",{className:"s-thread-compose",onSubmit:Q=>{Q.preventDefault(),yt()},children:r.jsxs("div",{className:"s-thread-compose-shell",children:[ee.open&&Ie.length>0&&r.jsxs("div",{className:"s-thread-compose-suggest",role:"listbox","aria-label":"Slash commands",children:[r.jsx("div",{className:"s-thread-compose-suggest-label",children:"Slash commands"}),Ie.map((Q,ye)=>r.jsxs("button",{type:"button",role:"option","aria-selected":ye===ee.index,className:["s-thread-compose-suggest-item",ye===ee.index&&"s-thread-compose-suggest-item--active"].filter(Boolean).join(" "),onMouseDown:Ne=>{Ne.preventDefault(),le(Q)},onMouseEnter:()=>ie(Ne=>({...Ne,index:ye})),children:[r.jsx("span",{className:"s-thread-compose-suggest-cmd",children:Q.label}),r.jsx("span",{className:"s-thread-compose-suggest-desc",children:Q.description})]},Q.command))]}),de.open&&oe.length>0&&r.jsxs("div",{className:"s-thread-compose-suggest",role:"listbox","aria-label":"Mention agents",children:[r.jsx("div",{className:"s-thread-compose-suggest-label",children:"Mention agent"}),oe.map((Q,ye)=>r.jsxs("button",{type:"button",role:"option","aria-selected":ye===de.index,className:["s-thread-compose-suggest-item",ye===de.index&&"s-thread-compose-suggest-item--active"].filter(Boolean).join(" "),onMouseDown:Ne=>{Ne.preventDefault(),ve(Q)},onMouseEnter:()=>xe(Ne=>({...Ne,index:ye})),children:[r.jsx("span",{className:"s-ops-avatar s-thread-compose-suggest-avatar",style:{"--size":"20px",background:gt(Q.name)},children:Q.name[0]?.toUpperCase()??"?"}),r.jsxs("span",{className:"s-thread-compose-suggest-cmd",children:["@",Q.handle]}),r.jsx("span",{className:"s-thread-compose-suggest-desc",children:Q.name})]},Q.id))]}),r.jsxs("div",{className:"s-thread-compose-row",children:[r.jsx("textarea",{ref:E,className:"s-thread-compose-input",placeholder:ln,value:W,onChange:Q=>{const ye=Q.target.value;$(ye),Fe(ye,Q.target.selectionStart)},onSelect:Q=>{const ye=Q.currentTarget;Fe(ye.value,ye.selectionStart)},onBlur:()=>{setTimeout(je,120)},onKeyDown:Q=>{if(ee.open&&Ie.length>0||de.open&&oe.length>0){if(Q.key==="ArrowDown"){Q.preventDefault(),ee.open?ie(Ne=>({...Ne,index:(Ne.index+1)%Ie.length})):de.open&&xe(Ne=>({...Ne,index:(Ne.index+1)%oe.length}));return}if(Q.key==="ArrowUp"){Q.preventDefault(),ee.open?ie(Ne=>({...Ne,index:(Ne.index-1+Ie.length)%Ie.length})):de.open&&xe(Ne=>({...Ne,index:(Ne.index-1+oe.length)%oe.length}));return}if(Q.key==="Escape"){Q.preventDefault(),je();return}if(Q.key==="Enter"||Q.key==="Tab"){if(Q.shiftKey)return;if(Q.preventDefault(),ee.open){const Ne=Ie[ee.index]??Ie[0];Ne&&le(Ne)}else if(de.open){const Ne=oe[de.index]??oe[0];Ne&&ve(Ne)}return}}Q.key!=="Enter"||Q.shiftKey||Q.nativeEvent.isComposing||(Q.preventDefault(),!B&&W.trim()&&yt())},rows:1}),_e?r.jsx("button",{type:"button",className:"s-thread-compose-send s-thread-compose-send--stop",onClick:()=>{Jt()},"aria-label":"Stop agent",children:r.jsx(IY,{})}):r.jsx("button",{type:"submit",className:"s-thread-compose-send",disabled:B||!W.trim(),"aria-label":on==="ask"?"Ask agent":on==="steer"?"Steer agent":D?"Tell agent":"Send message",children:r.jsx(_Y,{})})]})]})})]})})}async function DY(e){await fetch(iu("terminalRunPath"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e})})}const DR={think:"var(--dim)",tool:"var(--accent)",ask:"var(--amber)",message:"var(--muted)",note:"var(--green)",system:"var(--dim)",boot:"var(--dim)"},PY={read:"◎",edit:"✎",bash:"$",grep:"⌕",write:"✎",think:"∿"},zY=20,PR=new Intl.NumberFormat("en-US"),LY=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1});function $Y(e){const t=Math.floor(e/60),n=Math.floor(e%60);return`${String(t).padStart(2,"0")}:${String(n).padStart(2,"0")}`}function mk(e,t){return e>=Math.max(0,t-zY)}function cc(e){return typeof e!="number"||!Number.isFinite(e)?null:PR.format(e)}function hr(e){return typeof e!="number"||!Number.isFinite(e)?"—":Math.abs(e)<1e3?PR.format(e):LY.format(e).toLowerCase()}function UY(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),s=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h ${s}m`:s>=10||i===0?`${s}m`:`${s}m ${i}s`}function pk(e){return!!e&&Object.keys(e).length>0}function zg(e){return e.filter(t=>!!t)}function BY({event:e}){return r.jsxs("div",{children:[r.jsx("div",{className:"s-observe-think-label",children:"thinking"}),r.jsxs("div",{className:"s-observe-think-text",children:["“",e.text,"”",e.live&&r.jsx("span",{className:"s-observe-cursor"})]})]})}function VY({event:e}){const t=PY[e.tool??""]??"▸",n=!!(e.result||e.diff||e.stream);return r.jsxs("div",{className:"s-observe-tool",children:[r.jsxs("div",{className:`s-observe-tool-header${n?" s-observe-tool-header--has-body":""}`,children:[r.jsx("span",{className:"s-observe-tool-glyph",children:t}),r.jsxs("span",{className:"s-observe-tool-cmd",children:[r.jsx("span",{className:"s-observe-tool-cmd-name",children:e.tool})," ",e.arg]})]}),e.result&&r.jsx("div",{className:"s-observe-tool-result",children:Object.entries(e.result).map(([s,i])=>`${s}: ${i}`).join(" · ")}),e.diff&&r.jsxs("div",{className:"s-observe-tool-diff",children:[r.jsxs("div",{className:"s-observe-tool-diff-stats",children:[r.jsxs("span",{className:"s-observe-tool-diff-add",children:["+",e.diff.add]}),e.diff.del>0&&r.jsxs(r.Fragment,{children:[" ",r.jsxs("span",{className:"s-observe-tool-diff-del",children:["−",e.diff.del]})]})]}),r.jsx("pre",{className:"s-observe-tool-diff-preview",children:e.diff.preview})]}),e.stream&&r.jsx("pre",{className:"s-observe-tool-stream",children:e.stream.join(`
|
|
154
|
-
`)})]})}function FY({event:e}){const t=e.to==="human"?"you":e.to??"?";return r.jsxs("div",{className:"s-observe-ask",children:[r.jsxs("div",{className:"s-observe-ask-label",children:["↗ ask → ",t]}),r.jsxs("div",{className:"s-observe-ask-text",children:["“",e.text,"”"]}),e.answer&&r.jsxs("div",{className:"s-observe-ask-answer",children:[r.jsxs("span",{className:"s-observe-ask-answer-meta",children:["↳ @",e.to??"you"," · +",(e.answerT??e.t)-e.t,"s"]}),r.jsx("div",{className:"s-observe-ask-answer-text",children:e.answer})]})]})}function HY({event:e}){const t=e.to==="human"?"you":e.to??"?";return r.jsxs("div",{children:[r.jsxs("div",{className:"s-observe-message-label",children:["→ message → ",t]}),r.jsx("div",{className:"s-observe-message-text",children:r.jsx(Rx,{text:e.text})})]})}function qY({event:e}){return r.jsxs("div",{className:"s-observe-note",children:[r.jsx("span",{className:"s-observe-note-icon",children:"✓"}),r.jsx("span",{className:"s-observe-note-text",children:e.text})]})}function ZY({event:e}){return r.jsxs("div",{className:"s-observe-system",children:[r.jsx("span",{className:"s-observe-system-arrow",children:"▸ "}),e.text,e.detail&&r.jsx("div",{className:"s-observe-system-detail",children:e.detail})]})}function WY({isFollowing:e,isLive:t,onToggle:n}){return r.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?r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:[r.jsx("rect",{x:"1.5",y:"1",width:"3",height:"8",rx:"1"}),r.jsx("rect",{x:"5.5",y:"1",width:"3",height:"8",rx:"1"})]}):r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:r.jsx("path",{d:"M2 1.5l7 3.5-7 3.5V1.5z"})}),r.jsx("span",{children:e?t?"Live":"Following":"Follow"})]})}function YY({event:e,prevT:t}){const n=e.t-t,s=DR[e.kind]??"var(--dim)";return r.jsxs("div",{className:"s-observe-row",children:[n>15&&r.jsxs("div",{className:"s-observe-row-gap",children:["+",n,"s"]}),r.jsx("div",{className:"s-observe-row-time",children:$Y(e.t)}),r.jsx("span",{className:"s-observe-row-bead",style:{background:s}}),e.kind==="think"&&r.jsx(BY,{event:e}),e.kind==="tool"&&r.jsx(VY,{event:e}),e.kind==="ask"&&r.jsx(FY,{event:e}),e.kind==="message"&&r.jsx(HY,{event:e}),e.kind==="note"&&r.jsx(qY,{event:e}),(e.kind==="system"||e.kind==="boot")&&r.jsx(ZY,{event:e})]})}function GY({events:e,followEnd:t}){const n=g.useRef(null),s=g.useRef(t);return g.useLayoutEffect(()=>{if(!t){s.current=!1;return}const i=!s.current;s.current=!0,n.current?.scrollIntoView({behavior:i?"instant":"smooth"})},[e.length,t]),r.jsxs("div",{className:"s-observe-stream",children:[r.jsx("div",{className:"s-observe-spine"}),e.map((i,l)=>r.jsx(YY,{event:i,prevT:l>0?e[l-1].t:0},i.id)),r.jsx("div",{ref:n})]})}function KY({data:e,cursor:t}){const i=e.length;if(i<2)return null;const l=276/(i-1),c=e.map((h,m)=>`${m===0?"M":"L"} ${(m*l).toFixed(1)} ${((1-h)*44).toFixed(1)}`).join(" "),d=t*276;return r.jsxs("svg",{viewBox:"0 0 276 44",style:{width:"100%",height:44,display:"block"},children:[r.jsx("defs",{children:r.jsxs("linearGradient",{id:"observeCtxFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[r.jsx("stop",{offset:"0%",stopColor:"var(--accent)",stopOpacity:.25}),r.jsx("stop",{offset:"100%",stopColor:"var(--accent)",stopOpacity:0})]})}),r.jsx("path",{d:`${c} L 276 44 L 0 44 Z`,fill:"url(#observeCtxFill)"}),r.jsx("path",{d:c,fill:"none",stroke:"var(--accent)",strokeWidth:1.2}),r.jsx("line",{x1:d,y1:0,x2:d,y2:44,stroke:"var(--accent)",strokeWidth:1,opacity:.6,strokeDasharray:"2 3"})]})}function XY({state:e}){const t=e==="created"?"var(--green)":e==="modified"?"var(--accent)":"var(--dim)",n=e==="created"?"+":e==="modified"?"~":"◎";return r.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 Da({label:e,value:t,detail:n}){return r.jsxs("div",{className:"s-observe-stat",children:[r.jsx("div",{className:"s-observe-stat-label",children:e}),r.jsx("div",{className:"s-observe-stat-value",children:t}),n&&r.jsx("div",{className:"s-observe-stat-detail",children:n})]})}function Lg({rows:e}){return e.length===0?null:r.jsx("div",{className:"s-observe-detail-list",children:e.map(t=>r.jsxs("div",{className:"s-observe-detail-row",children:[r.jsx("div",{className:"s-observe-detail-label",children:t.label}),r.jsx("div",{className:`s-observe-detail-value s-observe-detail-value--${t.tone??"default"}${t.wrap?" s-observe-detail-value--wrap":""}`,title:t.title,children:t.value})]},t.label))})}function JY({events:e,duration:t,cursor:n,onCursor:s}){const i=g.useRef(null),l=g.useCallback(c=>{const d=i.current.getBoundingClientRect(),h=c.clientX-d.left;s(Math.max(0,Math.min(t,h/d.width*t)))},[t,s]);return r.jsx("div",{className:"s-observe-track-wrap",children:r.jsxs("div",{ref:i,className:"s-observe-track",onClick:l,children:[e.map(c=>{const d=c.kind==="tool"?6:c.kind==="think"?4:5;return r.jsx("span",{className:"s-observe-track-tick",style:{left:`${c.t/t*100}%`,top:d===6?-2:-1,height:d,background:DR[c.kind]??"var(--dim)"}},c.id)}),r.jsx("div",{className:"s-observe-track-played",style:{width:`${n/t*100}%`}}),r.jsx("span",{className:"s-observe-track-cursor",style:{left:`${n/t*100}%`}})]})})}function gk(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 QY(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 eG({catalog:e,sessionId:t,agentId:n}){const{navigate:s}=ht(),[i,l]=g.useState(!1),c=e.sessions.find(y=>y.id===e.activeSessionId),d=e.sessions.filter(y=>y.id!==e.activeSessionId&&y.endedAt).sort((y,x)=>(x.endedAt??0)-(y.endedAt??0)).slice(0,5),h=e.activeSessionId??t,m=h?h.slice(0,8):null,p=g.useCallback(()=>{e.resumeCommand&&(DY(e.resumeCommand).then(()=>{s({view:"terminal",agentId:n})}),l(!0))},[e.resumeCommand,s,n]);return r.jsxs("div",{className:"s-observe-session-header",children:[r.jsx("div",{className:"s-observe-session-active",children:r.jsxs("div",{className:"s-observe-session-row",children:[m&&r.jsx("span",{className:"s-observe-session-id",title:h??void 0,children:m}),c&&r.jsxs("span",{className:"s-observe-session-time",children:["started ",gk(c.startedAt)]}),e.resumeCommand&&r.jsx("button",{className:"s-observe-takeover-btn",onClick:p,title:e.resumeCommand,children:i?"Sent":"Takeover"})]})}),d.length>0&&r.jsxs("div",{className:"s-observe-session-history",children:[r.jsxs("div",{className:"s-observe-session-history-label",children:[e.sessions.length," session",e.sessions.length!==1?"s":""," total"]}),d.map(y=>r.jsxs("div",{className:"s-observe-session-past",children:[r.jsx("span",{className:"s-observe-session-id",children:y.id.slice(0,8)}),r.jsxs("span",{className:"s-observe-session-time",children:[gk(y.startedAt),y.endedAt?` · ${QY(y.startedAt,y.endedAt)}`:""]})]},y.id))]})]})}const tG={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 Ox({data:e,agentId:t,sessionId:n}){const s=e??tG,{events:i,files:l,contextUsage:c}=s,d=s.live===!0,[h,m]=g.useState(null);g.useEffect(()=>{if(!t)return;let ae=!1;return ke(`/api/agents/${encodeURIComponent(t)}/session-catalog`).then(ee=>{ae||m(ee)}).catch(()=>{}),()=>{ae=!0}},[t]);const p=i.length>0?i[i.length-1].t+30:60,[y,x]=g.useState(p),[w,j]=g.useState(!1),[N,k]=g.useState(1),[E,A]=g.useState(!0),S=g.useRef(p);g.useEffect(()=>{x(ae=>{const ee=S.current;S.current=p;const ie=mk(ae,ee);return ae>p||ie&&E?p:ae})},[p,E]),g.useEffect(()=>{if(!w)return;const ae=setInterval(()=>{x(ee=>{const ie=ee+N;return ie>=p?(j(!1),p):ie})},100);return()=>clearInterval(ae)},[w,p,N]);const M=i.filter(ae=>ae.t<=y),I=mk(y,p)&&E,R=d&&I,D=g.useCallback(()=>{I?A(!1):(x(p),A(!0))},[I,p]),z=s.metadata,O=z?.session,_=z?.usage,U=i.filter(ae=>ae.kind==="tool").length,q=i.filter(ae=>ae.kind==="think").length,G=i.filter(ae=>ae.kind==="ask").length,X=i.filter(ae=>ae.kind==="tool"&&ae.tool==="read").length,L=i.filter(ae=>ae.kind==="tool"&&(ae.tool==="edit"||ae.tool==="write")).length,F=i.length>0?i[i.length-1].t:0,H=c&&c.length>0?Math.round((c[c.length-1]??0)*100):null,V=[{label:"Input",value:_?.inputTokens},{label:"Output",value:_?.outputTokens},{label:"Cache hit",value:_?.cacheReadInputTokens},{label:"Cache write",value:_?.cacheCreationInputTokens},{label:"Total",value:_?.totalTokens},{label:"Reasoning",value:_?.reasoningOutputTokens}].filter(ae=>typeof ae.value=="number"),W=zg([typeof _?.assistantMessages=="number"?{label:"Assistant msgs",value:cc(_.assistantMessages)??"0",tone:"accent"}:null,typeof _?.webSearchRequests=="number"?{label:"Web search",value:cc(_.webSearchRequests)??"0"}:null,typeof _?.webFetchRequests=="number"?{label:"Web fetch",value:cc(_.webFetchRequests)??"0"}:null,_?.serviceTier?{label:"Service tier",value:_.serviceTier,tone:"good"}:null,_?.speed?{label:"Speed",value:_.speed}:null,_?.planType?{label:"Plan",value:_.planType}:null]),$=zg([typeof _?.contextWindowTokens=="number"?{label:"Model window",value:`${cc(_.contextWindowTokens)} tokens`,title:cc(_.contextWindowTokens)??void 0,tone:"accent"}:null,H!==null?{label:"Derived load",value:`${H}%`,tone:H>=80?"warn":"default"}:null]),B=zg([O?.model?{label:"Model",value:O.model,tone:"accent"}:null,O?.adapterType?{label:"Adapter",value:O.adapterType}:null,O?.gitBranch?{label:"Branch",value:O.gitBranch}:null,O?.cwd?{label:"Workspace",value:O.cwd,title:O.cwd,wrap:!0}:null,O?.entrypoint?{label:"Entrypoint",value:O.entrypoint}:null,O?.cliVersion?{label:"CLI",value:O.cliVersion}:null,O?.permissionMode?{label:"Permissions",value:O.permissionMode}:null,O?.approvalPolicy?{label:"Approval",value:O.approvalPolicy}:null,O?.sandbox?{label:"Sandbox",value:O.sandbox}:null,O?.userType?{label:"User type",value:O.userType}:null,O?.originator?{label:"Originator",value:O.originator}:null,O?.modelProvider?{label:"Provider",value:O.modelProvider}:null,O?.effort?{label:"Effort",value:O.effort}:null,O?.timezone?{label:"Timezone",value:O.timezone}:null,O?.externalSessionId?{label:"External session",value:O.externalSessionId,title:O.externalSessionId,wrap:!0}:null,O?.threadId?{label:"Thread",value:O.threadId,title:O.threadId,wrap:!0}:null,O?.threadPath?{label:"Thread path",value:O.threadPath,title:O.threadPath,wrap:!0}:null,O?.source?{label:"Runtime source",value:O.source}:null]),Y=pk(_),te=pk(O);return r.jsxs("div",{className:"s-observe",children:[r.jsxs("main",{className:"s-observe-main",children:[r.jsx("div",{className:"s-observe-live-sticky",children:r.jsx(WY,{isFollowing:I,isLive:R,onToggle:D})}),r.jsx(GY,{events:M,followEnd:I})]}),r.jsxs("aside",{className:"s-observe-rail",children:[h&&h.sessions.length>0&&r.jsxs("div",{children:[r.jsx("div",{className:"s-observe-rail-label",children:"Session"}),r.jsx(eG,{catalog:h,sessionId:n??null,agentId:t})]}),r.jsxs("div",{children:[r.jsx("div",{className:"s-observe-rail-label",children:"Trace stats"}),r.jsxs("div",{className:"s-observe-stats",children:[r.jsx(Da,{label:"Turns",value:hr(O?.turnCount??0)}),r.jsx(Da,{label:"Tools",value:hr(U)}),r.jsx(Da,{label:"Thinks",value:hr(q)}),r.jsx(Da,{label:"Asks",value:hr(G)}),r.jsx(Da,{label:"Reads",value:hr(X)}),r.jsx(Da,{label:"Edits",value:hr(L)}),r.jsx(Da,{label:"Files",value:hr(l.length)}),r.jsx(Da,{label:"Window",value:UY(F)})]})]}),r.jsxs("div",{children:[r.jsx("div",{className:"s-observe-rail-label",children:"Context window"}),r.jsx(Lg,{rows:$}),c&&c.length>=2?r.jsxs(r.Fragment,{children:[r.jsx(KY,{data:c,cursor:y/p}),r.jsx("div",{className:"s-observe-ctx-detail",children:"Sparkline shows derived session load across the observed trace."})]}):$.length===0?r.jsx("div",{className:"s-observe-ctx-detail",children:"Unavailable for this session"}):r.jsx("div",{className:"s-observe-ctx-detail",children:"Exact window metadata is available, but no derived load trace was captured."})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"s-observe-rail-label",children:["Files touched · ",l.length]}),r.jsx("div",{className:"s-observe-files",children:l.map(ae=>r.jsxs("div",{className:`s-observe-file${ae.lastT<=y?" s-observe-file--visible":" s-observe-file--hidden"}`,children:[r.jsx(XY,{state:ae.state}),r.jsx("span",{className:"s-observe-file-path",children:ae.path}),r.jsxs("span",{className:"s-observe-file-touches",children:["×",ae.touches]})]},ae.path))})]}),r.jsxs("div",{children:[r.jsx("div",{className:"s-observe-rail-label",children:"Usage"}),V.length>0&&r.jsx("div",{className:"s-observe-stats s-observe-stats--usage",children:V.map(ae=>r.jsx(Da,{label:ae.label,value:hr(ae.value)},ae.label))}),W.length>0?r.jsx(Lg,{rows:W}):Y?null:r.jsx("div",{className:"s-observe-ctx-detail",children:"Unavailable for this session"})]}),r.jsxs("div",{children:[r.jsx("div",{className:"s-observe-rail-label",children:"Metadata"}),B.length>0?r.jsx(Lg,{rows:B}):te?null:r.jsx("div",{className:"s-observe-ctx-detail",children:"Unavailable for this session"})]})]}),r.jsxs("footer",{className:"s-observe-scrubber",children:[r.jsx("button",{className:"s-observe-play-btn",onClick:()=>j(!w),children:w?"❚❚":"▶"}),r.jsx("button",{className:"s-observe-rewind-btn",onClick:()=>{x(0),j(!1)},children:"⏮"}),r.jsx(JY,{events:i,duration:p,cursor:y,onCursor:x}),r.jsx("div",{className:"s-observe-speed-group",children:[.5,1,2,4].map(ae=>r.jsxs("button",{className:`s-observe-speed-btn${N===ae?" s-observe-speed-btn--active":""}`,onClick:()=>k(ae),children:[ae,"×"]},ae))})]})]})}async function nG(e){await fetch(iu("terminalRunPath"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e})})}function sG(e,t){if(t.filter(i=>i.name===e.name).length<=1)return{name:e.name,qualifier:null};const s=e.project??e.branch??e.id.replace(/^.*\./,"");return{name:e.name,qualifier:s}}function qc(e){if(!e)return null;const t=e.replace(/_/g," ");return t.toLowerCase()==="relay agent"?"agent":t}function aG(e){const t=[...e].filter(i=>i.kind==="direct"&&!!i.agentId).sort((i,l)=>(l.lastMessageAt??0)-(i.lastMessageAt??0)),n=new Map,s=new Map;for(const i of t)n.has(i.agentId)||(n.set(i.agentId,i.id),s.set(i.agentId,i));return{conversationByAgentId:n,sessionByAgentId:s}}function rG(e,t){if(!t)return null;const n=e.find(i=>i.id===t);if(n)return n;const s=t.split(".")[0];return s?[...e].filter(i=>i.handle===s||i.id.startsWith(`${s}.`)).sort((i,l)=>(l.updatedAt??0)-(i.updatedAt??0))[0]??null:null}function iG({catalog:e,agentId:t}){const{navigate:n}=ht(),[s,i]=g.useState(!1),l=e.activeSessionId?.slice(0,8)??null,c=e.sessions.find(h=>h.id===e.activeSessionId),d=()=>{e.resumeCommand&&(nG(e.resumeCommand).then(()=>n({view:"terminal",agentId:t})),i(!0))};return r.jsxs("div",{className:"s-profile-facet",children:[r.jsx("div",{className:"s-profile-facet-label",children:"Session"}),r.jsxs("div",{className:"s-profile-facet-value s-profile-facet-value--mono",title:e.activeSessionId??void 0,children:[l,e.resumeCommand&&r.jsx("button",{type:"button",className:"s-profile-facet-action",onClick:d,title:e.resumeCommand,children:s?"Going…":"Takeover"})]}),c&&r.jsxs("div",{className:"s-profile-facet-detail",children:[e.sessions.length," session",e.sessions.length!==1?"s":""," · started ",De(c.startedAt)]})]})}function oG({agent:e,fleet:t,navigate:n}){const s=g.useMemo(()=>t?t.activity.filter(l=>l.agentId===e.id||l.actorId===e.id).slice(0,6):[],[t,e.id]),i=g.useMemo(()=>t?t.recentCompleted.filter(l=>l.agentId===e.id).slice(0,4):[],[t,e.id]);return s.length===0&&i.length===0?r.jsxs("div",{className:"s-profile-activity-empty",children:[r.jsx("div",{className:"s-profile-activity-empty-title",children:"Quiet for now"}),r.jsx("div",{className:"s-profile-activity-empty-detail",children:"Activity will appear here as this agent works, receives asks, and completes tasks."})]}):r.jsxs("div",{className:"s-profile-activity-feed",children:[i.map(l=>r.jsxs("div",{className:"s-profile-activity-row",onClick:()=>{l.conversationId&&n({view:"agents",agentId:e.id,conversationId:l.conversationId})},children:[r.jsx("div",{className:"s-profile-activity-dot s-profile-activity-dot--done"}),r.jsxs("div",{className:"s-profile-activity-body",children:[r.jsx("div",{className:"s-profile-activity-title",children:l.summary??l.task}),r.jsxs("div",{className:"s-profile-activity-meta",children:[l.status==="completed"?"completed":l.status,l.completedAt&&` · ${De(l.completedAt)}`]})]})]},l.invocationId)),s.map(l=>r.jsxs("div",{className:"s-profile-activity-row",onClick:()=>{l.conversationId&&n({view:"agents",agentId:e.id,conversationId:l.conversationId})},children:[r.jsx("div",{className:"s-profile-activity-dot"}),r.jsxs("div",{className:"s-profile-activity-body",children:[r.jsx("div",{className:"s-profile-activity-title",children:l.title??l.summary??l.kind}),r.jsxs("div",{className:"s-profile-activity-meta",children:[l.kind.replace(/_/g," "),l.actorName&&` · ${l.actorName}`,` · ${De(l.ts)}`]})]})]},l.id))]})}function xc({label:e,right:t,rightClassName:n}){return r.jsxs("div",{className:"s-profile-section-rule",children:[r.jsx("span",{className:"s-profile-section-rule-label",children:e}),r.jsx("span",{className:"s-profile-section-rule-line"}),t&&r.jsx("span",{className:`s-profile-section-rule-right${n?` ${n}`:""}`,children:t})]})}function lG({messages:e,navigate:t,conversationId:n,agentId:s}){const i=e.slice(-8).reverse();return i.length===0?null:r.jsxs("div",{className:"s-profile-signals",children:[r.jsx(xc,{label:"Recent signal",right:"last 1h"}),r.jsx("div",{className:"s-profile-signal-list",children:i.map(l=>{const d=l.class==="ask"||l.body?.toLowerCase().startsWith("@")?"ASK":"MESSAGE";return r.jsxs("div",{className:"s-profile-signal",onClick:()=>{n&&t({view:"agents",agentId:s,conversationId:n})},children:[r.jsx("div",{className:"s-profile-signal-avatar",style:{background:gt(l.actorName??"?")},children:(l.actorName??"?")[0].toUpperCase()}),r.jsxs("div",{className:"s-profile-signal-body",children:[r.jsxs("div",{className:"s-profile-signal-header",children:[r.jsx("span",{className:"s-profile-signal-kind",children:d}),r.jsx("span",{className:"s-profile-signal-sep",children:"·"}),r.jsx("span",{className:"s-profile-signal-routing",children:l.actorName}),r.jsx("span",{className:"s-profile-signal-time",children:De(l.createdAt)})]}),r.jsx("div",{className:"s-profile-signal-text",children:l.body})]})]},l.id)})})]})}function cG({agent:e,allAgents:t,session:n,conversationId:s,navigate:i,activeTab:l}){const{name:c,qualifier:d}=sG(e,t),[h,m]=g.useState([]),[p,y]=g.useState([]),[x,w]=g.useState(null),[j,N]=g.useState(null),[k,E]=g.useState(!1),[A,S]=g.useState(null),M=Xe(e.state),C=Mx(),I=g.useCallback(async()=>{const[V,W]=await Promise.allSettled([ke(`/api/work?agentId=${encodeURIComponent(e.id)}`),ke("/api/fleet")]);V.status==="fulfilled"&&m(V.value),W.status==="fulfilled"&&w(W.value)},[e.id]),R=g.useCallback(async()=>{if(!s){y([]);return}try{const V=await ke(`/api/messages?conversationId=${encodeURIComponent(s)}&limit=20`);y(V)}catch{y([])}},[s]),D=g.useCallback(async()=>{E(!0);try{const V=await ke(`/api/agents/${encodeURIComponent(e.id)}/observe`);N(V)}catch{N({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{E(!1)}},[e.id]);g.useEffect(()=>{I(),R(),ke(`/api/agents/${encodeURIComponent(e.id)}/session-catalog`).then(S).catch(()=>{})},[I,R,e.id]),g.useEffect(()=>{N(null),E(!1)},[e.id]),g.useEffect(()=>{l==="observe"&&D()},[l,D]),Kt(()=>{I(),R(),l==="observe"&&D()}),g.useEffect(()=>{if(l!=="observe"||!j?.data.live)return;const V=setInterval(()=>{D()},2500);return()=>clearInterval(V)},[l,j?.data.live,D]);const z=h.find(V=>V.state==="working"||V.state==="review"),O=h.filter(V=>V.state==="working"||V.state==="review"||V.state==="waiting"),_=h.filter(V=>V.state==="done").slice(0,5),U=qc(e.role)??qc(e.agentClass),q=e.harness,G=[U,q].filter(Boolean).filter((V,W,$)=>$.indexOf(V)===W),X=g.useMemo(()=>t.filter(V=>V.project===e.project).length,[t,e.project]),L=z?.currentPhase==="review"?85:z?.currentPhase==="working"?50:20,F=[{key:"profile",label:"Profile"},{key:"observe",label:"Observe"},{key:"message",label:"Message",disabled:!s}],H=V=>{i({view:"agents",agentId:e.id,...s?{conversationId:s}:{},tab:V})};return r.jsxs("div",{className:`s-profile-center${l!=="profile"?" s-profile-center--tabbed":""}`,children:[r.jsx("button",{type:"button",className:"s-back s-profile-mobile-back",onClick:()=>i({view:"agents"}),children:"← All agents"}),r.jsx("section",{className:"s-profile-identity",onContextMenu:V=>{const W=window.getSelection()?.toString().trim(),$=[];W&&($.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>navigator.clipboard.writeText(W)}),$.push({kind:"separator"})),$.push({kind:"action",label:"Copy Agent Name",onSelect:()=>navigator.clipboard.writeText(c)}),$.push({kind:"action",label:"Copy Agent ID",onSelect:()=>navigator.clipboard.writeText(e.id)}),e.handle&&$.push({kind:"action",label:`Copy @${e.handle}`,onSelect:()=>navigator.clipboard.writeText(`@${e.handle}`)}),C(V,$)},children:r.jsxs("div",{className:"s-profile-identity-top",children:[r.jsxs("div",{className:"s-profile-identity-avatar-wrap",children:[r.jsx("div",{className:"s-profile-identity-avatar",style:{background:gt(e.name)},children:e.name[0].toUpperCase()}),r.jsx("span",{className:`s-profile-identity-pulse s-profile-identity-pulse--${M}`,style:{background:Gs(e.state)}})]}),r.jsxs("div",{className:"s-profile-identity-copy",children:[G.length>0&&r.jsx("div",{className:"s-profile-identity-eyebrow",children:G.join(" · ")}),r.jsxs("h1",{className:"s-profile-identity-name",children:[c,d&&r.jsx("span",{className:"s-profile-identity-name-qualifier",children:d}),e.handle&&r.jsxs("span",{className:"s-profile-identity-name-handle",children:["@",e.handle]})]}),r.jsx("div",{className:"s-profile-identity-state-row",children:r.jsxs("span",{className:"s-profile-identity-state",children:[r.jsx("span",{className:`s-profile-identity-state-dot${M==="working"?" s-profile-identity-state-dot--pulse":""}`,style:{background:Gs(e.state)}}),r.jsx("span",{className:"s-profile-identity-state-label",children:Hn(e.state)}),e.updatedAt&&r.jsxs("span",{className:"s-profile-identity-state-detail",children:["— ",De(e.updatedAt)]})]})})]}),r.jsx("nav",{className:"s-profile-tabs",children:F.map(V=>r.jsx("button",{type:"button",className:`s-profile-tab${l===V.key?" s-profile-tab--active":""}`,disabled:V.disabled,onClick:()=>H(V.key),children:V.label},V.key))})]})}),l==="profile"&&r.jsxs("div",{className:"s-profile-tab-content",children:[(e.project||e.branch||e.cwd||A?.activeSessionId)&&r.jsxs("div",{className:"s-profile-facets",children:[e.project&&r.jsxs("div",{className:"s-profile-facet",children:[r.jsx("div",{className:"s-profile-facet-label",children:"Workspace"}),r.jsx("div",{className:"s-profile-facet-value",children:e.project}),X>1&&r.jsxs("div",{className:"s-profile-facet-detail",children:[X," teammates"]})]}),(e.branch||e.projectRoot)&&r.jsxs("div",{className:"s-profile-facet",children:[r.jsx("div",{className:"s-profile-facet-label",children:"Repo / Branch"}),r.jsx("div",{className:"s-profile-facet-value",children:e.projectRoot?e.projectRoot.split("/").pop():e.project??"—"}),e.branch&&r.jsxs("div",{className:"s-profile-facet-detail",children:[r.jsx("span",{className:"s-profile-facet-accent",children:"⎇"})," ",e.branch]})]}),e.cwd&&r.jsxs("div",{className:"s-profile-facet",children:[r.jsx("div",{className:"s-profile-facet-label",children:"Working Dir"}),r.jsx("div",{className:"s-profile-facet-value",children:e.cwd.startsWith("/Users/")?"~/"+e.cwd.split("/").slice(3).join("/"):e.cwd}),e.updatedAt&&r.jsxs("div",{className:"s-profile-facet-detail",children:["uptime ",De(e.updatedAt)]})]}),A?.activeSessionId&&r.jsx(iG,{catalog:A,agentId:e.id})]}),z&&M==="working"&&r.jsxs(r.Fragment,{children:[r.jsx(xc,{label:"Current task",right:`${L}% · live`}),r.jsxs("div",{className:"s-profile-task",children:[r.jsx("div",{className:"s-profile-task-title",children:z.title}),z.lastMeaningfulSummary&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"s-profile-task-progress",children:r.jsx("div",{className:"s-profile-task-progress-bar",style:{width:`${L}%`}})}),r.jsxs("div",{className:"s-profile-task-action",children:[r.jsx("span",{className:"s-profile-task-action-chevron",children:"›"}),r.jsx("span",{children:z.lastMeaningfulSummary}),r.jsx("span",{className:"s-profile-task-cursor"})]})]}),r.jsxs("div",{className:"s-profile-task-meta",children:[r.jsx("span",{children:z.currentPhase}),r.jsx("span",{children:De(z.lastMeaningfulAt)})]})]})]}),O.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(xc,{label:"Active work",right:`${O.length} in flight`}),r.jsx("div",{className:"s-profile-work",children:r.jsx(ck,{items:O,navigate:i,emptyTitle:"Nothing in flight"})})]}),_.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(xc,{label:O.length>0?"Recently completed":"Recent work",right:`${_.length}`}),r.jsx("div",{className:"s-profile-work",children:r.jsx(ck,{items:_,navigate:i,emptyTitle:""})})]}),r.jsx(xc,{label:"Activity"}),r.jsx("div",{className:"s-profile-work",children:r.jsx(oG,{agent:e,fleet:x,navigate:i})}),r.jsx(lG,{messages:p,navigate:i,conversationId:s,agentId:e.id})]}),l==="observe"&&r.jsx("div",{className:"s-profile-tab-conversation",children:k&&!j?r.jsxs("div",{className:"s-profile-activity-empty",children:[r.jsx("div",{className:"s-profile-activity-empty-title",children:"Loading trace"}),r.jsx("div",{className:"s-profile-activity-empty-detail",children:"Resolving the best available live or history-backed session stream for this agent."})]}):r.jsx(Ox,{data:j?.data,agentId:e.id,sessionId:j?.sessionId})}),l==="message"&&s&&r.jsx("div",{className:"s-profile-tab-conversation",children:r.jsx(Ix,{conversationId:s,navigate:i,embedded:!0})})]})}function uG({navigate:e,selectedAgentId:t,conversationId:n,tab:s}){const{agents:i}=ht(),[l,c]=g.useState([]),d=g.useCallback(async()=>{const x=await ke("/api/conversations").catch(()=>null);x&&c(x)},[]);g.useEffect(()=>{d()},[d]),Kt(()=>{d()});const h=rG(i,t),m=!!(t&&h&&h.id!==t),{conversationByAgentId:p,sessionByAgentId:y}=aG(l);if(g.useEffect(()=>{if(!t||!h||!m)return;const x=Nn(t),w=n===x?h.conversationId:n;e({view:"agents",agentId:h.id,...w?{conversationId:w}:{},...s?{tab:s}:{}})},[n,s,e,h,t,m]),h){const x=m&&t?Nn(t):null,w=n===x?h.conversationId:n??p.get(h.id)??h.conversationId??null,j=s??(n?"message":"profile");return r.jsx(cG,{agent:h,allAgents:i,session:y.get(h.id)??null,conversationId:w,navigate:e,activeTab:j})}return r.jsx(fG,{agents:i,sessionByAgentId:y,conversationByAgentId:p,navigate:e})}const zR="—";function dG(e){const t=new Map;for(const s of e){const i=s.project??"Unscoped",l=t.get(i)??[];l.push(s),t.set(i,l)}const n=[];for(const[s,i]of t){const l=i.find(p=>p.projectRoot)?.projectRoot??null,c=new Map;for(const p of i){const y=p.branch??zR,x=c.get(y)??[];x.push(p),c.set(y,x)}const d=Array.from(c.entries()).map(([p,y])=>{const x=y.filter(sy).length;return{name:p,agents:y,online:x,kind:x>0?"active":"idle"}}),h=new Set(["main","master","trunk"]);d.sort((p,y)=>{const x=h.has(p.name),w=h.has(y.name);return x!==w?x?-1:1:p.name.localeCompare(y.name)});for(const p of d)p.agents.sort((y,x)=>y.name.localeCompare(x.name));const m=i.reduce((p,y)=>{const x=y.updatedAt;return x&&(p===null||x>p)?x:p},null);n.push({key:s,name:s,path:l,branches:d,totalAgents:i.length,totalOnline:i.filter(sy).length,lastActivityAt:m})}return n.sort((s,i)=>s.name.localeCompare(i.name)),n}function fG({agents:e,sessionByAgentId:t,conversationByAgentId:n,navigate:s}){if(e.length===0)return r.jsx("div",{className:"s-profile-center",style:{height:"100%"},children:r.jsxs("div",{className:"s-profile-empty",children:[r.jsx("h2",{className:"s-profile-empty-title",children:"No agents yet"}),r.jsx("p",{className:"s-profile-empty-copy",children:"Spawn an agent from a workspace, harness, branch, and model to see it land here."})]})});const i=g.useMemo(()=>dG(e),[e]),l=e.filter(sy).length,[c,d]=g.useState("cards");return r.jsxs("div",{className:"s-agents-library",children:[r.jsxs("header",{className:"s-agents-library-head",children:[r.jsxs("div",{className:"s-agents-library-title-row",children:[r.jsx("h2",{className:"s-agents-library-title",children:"Agents"}),r.jsxs("span",{className:"s-agents-library-count",children:[l," online · ",e.length," total · ",i.length," ",i.length===1?"repo":"repos"]})]}),r.jsx("div",{className:"s-agents-library-view",role:"tablist","aria-label":"Agent view",children:["pills","rows","cards"].map(h=>r.jsx("button",{type:"button",role:"tab","aria-selected":c===h,className:"s-agents-library-view-btn","data-active":c===h?"true":void 0,onClick:()=>d(h),children:h},h))})]}),r.jsx("div",{className:"s-agents-library-repos",children:i.map(h=>r.jsx(hG,{repo:h,sessionByAgentId:t,conversationByAgentId:n,navigate:s,viewMode:c},h.key))})]})}function hG({repo:e,sessionByAgentId:t,conversationByAgentId:n,navigate:s,viewMode:i}){const[l,c]=g.useState(()=>e.branches[0]?.name??zR),d=e.branches.find(h=>h.name===l)??e.branches[0];return r.jsxs("section",{className:"s-repo-card",children:[r.jsxs("header",{className:"s-repo-card-head",children:[r.jsxs("div",{className:"s-repo-card-identity",children:[r.jsx("h3",{className:"s-repo-card-name",children:e.name}),e.path&&r.jsx("span",{className:"s-repo-card-path",children:e.path})]}),r.jsx("div",{className:"s-repo-card-meta",children:e.lastActivityAt&&r.jsx("span",{children:De(e.lastActivityAt)})})]}),r.jsx("div",{className:"s-repo-card-tabs",role:"tablist","aria-label":"Branches",children:e.branches.map(h=>r.jsxs("button",{type:"button",role:"tab","aria-selected":d?.name===h.name,className:"s-repo-card-tab","data-kind":h.kind,"data-active":d?.name===h.name?"true":void 0,onClick:()=>c(h.name),children:[r.jsx("span",{className:"s-repo-card-tab-name",children:h.name}),h.kind==="unmonitored"?r.jsx("span",{className:"s-repo-card-tab-glyph","aria-hidden":"true",children:"+"}):r.jsx("span",{className:"s-repo-card-tab-count",children:h.online>0?`${h.online}/${h.agents.length}`:`${h.agents.length}`})]},h.name))}),r.jsx("div",{className:"s-repo-card-body",children:d&&d.agents.length>0?r.jsx(mG,{agents:d.agents,sessionByAgentId:t,conversationByAgentId:n,navigate:s,viewMode:i}):r.jsxs("div",{className:"s-repo-card-empty",children:["No agent on ",r.jsx("strong",{children:d?.name}),". Spawn one to start."]})})]})}function sy(e){return Xe(e.state)!=="offline"}function mG({agents:e,sessionByAgentId:t,conversationByAgentId:n,navigate:s,viewMode:i}){const l=c=>()=>{const d=n.get(c.id);s({view:"agents",agentId:c.id,...d?{conversationId:d}:{}})};return i==="rows"?r.jsx("div",{className:"s-agent-rows",children:e.map(c=>r.jsx(pG,{agent:c,session:t.get(c.id)??null,onClick:l(c)},c.id))}):i==="cards"?r.jsx("div",{className:"s-agent-grid",children:e.map(c=>r.jsx(gG,{agent:c,session:t.get(c.id)??null,onClick:l(c)},c.id))}):r.jsx("div",{className:"s-agent-log",children:e.map(c=>r.jsx(vG,{agent:c,session:t.get(c.id)??null,onClick:l(c)},c.id))})}function pG({agent:e,session:t,onClick:n}){const s=Xe(e.state),i=Hn(e.state),l=t?.lastMessageAt??e.updatedAt??null,c=t?.preview??null,d=qc(e.harness);return r.jsxs("button",{type:"button",className:"s-agent-row","data-state":s,onClick:n,title:i,children:[r.jsx("span",{className:"s-agent-row-name",children:e.name}),r.jsx("span",{className:"s-agent-row-preview",children:c??r.jsx("span",{className:"s-agent-row-preview-quiet",children:i.toLowerCase()})}),d&&r.jsx("span",{className:"s-agent-row-harness",children:d}),l&&r.jsx("span",{className:"s-agent-row-time",children:De(l)})]})}function gG({agent:e,session:t,onClick:n}){const s=Xe(e.state),i=Hn(e.state),l=t?.lastMessageAt??e.updatedAt??null,c=t?.preview??null,d=[e.harness,e.branch,e.agentClass].map(qc).filter(h=>!!h);return r.jsxs("button",{type:"button",className:"s-agent-card","data-state":s,onClick:n,title:i,children:[r.jsxs("div",{className:"s-agent-card-row",children:[r.jsx("span",{className:"s-agent-card-name",children:e.name}),l&&r.jsx("span",{className:"s-agent-card-time",children:De(l)})]}),r.jsx("div",{className:"s-agent-card-preview",children:c??r.jsx("span",{className:"s-agent-card-preview-quiet",children:i})}),d.length>0&&r.jsx("div",{className:"s-agent-card-topo",children:d.map((h,m)=>r.jsx("span",{className:"s-agent-card-topo-chip",children:h},`${h}-${m}`))})]})}function vG({agent:e,session:t,onClick:n}){const s=Xe(e.state),i=Hn(e.state),l=t?.lastMessageAt??e.updatedAt??null,c=t?.preview??null,d=qc(e.harness),h=[`${e.name} · ${i}`,d?`harness: ${d}`:null,c?`preview: ${c}`:null].filter(Boolean);return r.jsxs("button",{type:"button",className:"s-agent-log-row","data-state":s,onClick:n,title:h.join(`
|
|
155
|
-
`),children:[r.jsx("span",{className:"s-agent-log-time",children:l?De(l):"—"}),r.jsx("span",{className:"s-agent-log-name",children:e.name}),r.jsx("span",{className:"s-agent-log-msg",children:c??r.jsx("span",{className:"s-agent-log-msg-quiet",children:i.toLowerCase()})})]})}const vk={attempts:"Dispatch",dialogue:"Dialogue",failed_queries:"Failed queries",failed_deliveries:"Failed deliveries"};function ay(e){return e?e.length<=18?e:`${e.slice(0,10)}...${e.slice(-5)}`:"none"}function yG(e){return`${Math.round(e*100)}%`}function xG(e,t){return e==="success"||t==="sent"||t==="acknowledged"||t==="completed"?"success":e==="failed_query"||e==="failed_delivery"||t==="failed"||t==="cancelled"?"failed":t==="running"||t==="accepted"||t==="deferred"||t==="pending"?"working":"neutral"}function LR(e){switch(e){case"success":return"sent";case"failed_query":return"query";case"failed_delivery":return"delivery";default:return"attempt"}}function bG({navigate:e}){const{selectedBrokerAttempt:t,inspectBrokerAttempt:n}=ht(),[s,i]=g.useState(null),[l,c]=g.useState("attempts"),[d,h]=g.useState(!0),[m,p]=g.useState(!1),[y,x]=g.useState(null),w=g.useRef(null),j=g.useRef(0),N=g.useRef(null),k=g.useCallback(async(C="initial")=>{const I=++j.current;!w.current&&C!=="background"?(h(!0),x(null)):p(!0);try{const R=await ke("/api/broker?limit=160");if(I!==j.current)return;w.current=R,i(R),x(null)}catch(R){if(I!==j.current)return;x(R instanceof Error?R.message:String(R))}finally{I===j.current&&(h(!1),p(!1))}},[]),E=g.useCallback(()=>{N.current||(N.current=setTimeout(()=>{N.current=null,k("background")},250))},[k]);g.useEffect(()=>(k("initial"),()=>{N.current&&clearTimeout(N.current)}),[k]),Kt(C=>{(C.kind==="message.posted"||C.kind==="delivery.planned"||C.kind==="delivery.attempted"||C.kind==="delivery.state.changed"||C.kind==="scout.dispatched")&&E()});const A=g.useMemo(()=>{if(!s)return[];switch(l){case"failed_queries":return s.failedQueries;case"failed_deliveries":return s.failedDeliveries;case"dialogue":return s.dialogue;default:return s.attempts}},[l,s]),S=g.useMemo(()=>!s||!t?null:s.attempts.find(C=>C.id===t.id)??s.failedQueries.find(C=>C.id===t.id)??s.failedDeliveries.find(C=>C.id===t.id)??null,[s,t]);g.useEffect(()=>{S&&S!==t&&n(S)},[n,S,t]);const M=s?[{label:"Dispatch",value:String(s.totals.successfulDispatches),detail:`${s.rates.messagesPerHour}/hour chatter`},{label:"Failed queries",value:String(s.totals.failedQueries),detail:`${s.rates.failedQueriesPerHour}/hour`},{label:"Failed deliveries",value:String(s.totals.failedDeliveries+s.totals.failedDeliveryAttempts),detail:`${s.rates.failedDeliveriesPerHour}/hour`},{label:"Failure rate",value:yG(s.rates.failureRate),detail:`${s.totals.deliveryAttempts} delivery attempts`}]:[];return r.jsxs("div",{className:"sys-surface-page sys-surface-page-wide",children:[r.jsxs("div",{className:"sys-page-head",children:[r.jsxs("div",{className:"sys-page-title-group",children:[r.jsx("h2",{className:"sys-page-title",children:"Broker"}),r.jsx("p",{className:"sys-page-subtitle",children:"Dispatch success, failed queries, delivery failures, and broker dialogue."})]}),r.jsxs("div",{className:"sys-page-actions",children:[r.jsx("div",{className:"sys-sync-note",children:d?"Loading broker ledger...":s?`Updated ${De(s.generatedAt)}`:"Waiting for broker data"}),r.jsx("button",{type:"button",className:"s-btn",disabled:d||m,onClick:()=>{k("manual")},children:m?"Refreshing...":"Refresh"})]})]}),s&&r.jsx("div",{className:"sys-stat-grid",children:M.map(C=>r.jsxs("div",{className:"sys-stat-card",children:[r.jsx("span",{className:"sys-stat-label",children:C.label}),r.jsx("strong",{className:"sys-stat-value",children:C.value}),r.jsx("span",{className:"sys-stat-detail",children:C.detail})]},C.label))}),y&&r.jsxs("div",{className:"sys-banner sys-banner-warning",children:[r.jsx("strong",{children:"Refresh failed."}),r.jsx("span",{children:y})]}),d&&!s&&r.jsxs("div",{className:"sys-panel sys-state-card",children:[r.jsx("h3",{className:"sys-state-title",children:"Loading broker"}),r.jsx("p",{className:"sys-state-body",children:"Reading the broker database snapshot."})]}),!d&&!s&&!y&&r.jsxs("div",{className:"sys-panel sys-state-card",children:[r.jsx("h3",{className:"sys-state-title",children:"No broker data"}),r.jsx("p",{className:"sys-state-body",children:"No broker records are available yet."})]}),s&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"sys-tab-row",role:"tablist","aria-label":"Broker diagnostics",children:Object.keys(vk).map(C=>r.jsx("button",{type:"button",role:"tab","aria-selected":l===C,className:`sys-tab${l===C?" sys-tab-active":""}`,onClick:()=>c(C),children:vk[C]},C))}),l==="dialogue"?r.jsx(kG,{items:A,navigate:e}):r.jsx(wG,{attempts:A,navigate:e,selectedAttemptId:t?.id??null,onInspect:n})]})]})}function wG({attempts:e,navigate:t,selectedAttemptId:n,onInspect:s}){return e.length===0?r.jsxs("div",{className:"sys-panel sys-state-card",children:[r.jsx("h3",{className:"sys-state-title",children:"No records"}),r.jsx("p",{className:"sys-state-body",children:"This broker slice is empty for the selected window."})]}):r.jsx("div",{className:"sys-audit-list",children:e.map(i=>{const l=xG(i.kind,i.status),c=()=>{s(i),window.dispatchEvent(new CustomEvent("scout:set-inspector-width",{detail:{width:420}}))};return r.jsxs("article",{className:`sys-broker-row${n===i.id?" sys-broker-row-selected":""}`,tabIndex:0,"aria-label":`Inspect ${i.detail}`,onClick:c,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),c())},children:[r.jsxs("div",{className:"sys-broker-row-main",children:[r.jsxs("div",{className:"sys-broker-row-head",children:[r.jsx("span",{className:`sys-chip sys-chip-${l}`,children:LR(i.kind)}),r.jsx("span",{className:"sys-broker-status",children:i.status}),r.jsx("span",{className:"sys-broker-time",children:De(i.ts)})]}),r.jsx("h3",{className:"sys-broker-title",children:i.detail}),r.jsxs("div",{className:"sys-broker-meta",children:[r.jsxs("span",{children:["from ",i.actorName??"unknown"]}),r.jsxs("span",{children:["to ",i.target??"none"]}),r.jsxs("span",{children:["route ",i.route??"none"]})]})]}),r.jsxs("div",{className:"sys-broker-row-side",children:[r.jsx("code",{children:ay(i.messageId??i.deliveryId??i.invocationId??i.id)}),i.conversationId&&r.jsx("button",{type:"button",className:"s-btn s-btn-sm",onClick:d=>{d.stopPropagation(),t({view:"conversation",conversationId:i.conversationId})},children:"Open thread"})]})]},i.id)})})}function jG(e){return[{label:"Status",value:e.status},{label:"Kind",value:LR(e.kind)},{label:"Time",value:la(e.ts)},{label:"Actor",value:e.actorName},{label:"Target",value:e.target},{label:"Route",value:e.route},{label:"Conversation",value:e.conversationId},{label:"Message",value:e.messageId},{label:"Delivery",value:e.deliveryId},{label:"Invocation",value:e.invocationId}].filter(t=>t.value)}function NG(e){return!e||Object.keys(e).length===0?"{}":JSON.stringify(e,null,2)}function SG({attempt:e,navigate:t,onClose:n}){const s=jG(e);return r.jsxs("aside",{className:"sys-panel sys-broker-inspector","aria-label":"Broker route inspector",children:[r.jsxs("div",{className:"sys-broker-inspector-head",children:[r.jsxs("div",{children:[r.jsx("div",{className:"sys-kicker",children:"Inspector"}),r.jsx("h3",{className:"sys-state-title",children:e.detail})]}),r.jsxs("div",{className:"sys-inline-actions",children:[e.conversationId&&r.jsx("button",{type:"button",className:"s-btn s-btn-sm",onClick:()=>t({view:"conversation",conversationId:e.conversationId}),children:"Open thread"}),r.jsx("button",{type:"button",className:"s-btn s-btn-sm",onClick:n,children:"Close"})]})]}),r.jsx("div",{className:"sys-detail-grid sys-broker-inspector-grid",children:s.map(i=>r.jsxs("div",{className:"sys-detail-card",children:[r.jsx("span",{className:"sys-detail-label",children:i.label}),r.jsx("code",{className:"sys-detail-value",children:i.value})]},i.label))}),r.jsxs("div",{className:"sys-broker-metadata",children:[r.jsx("span",{className:"sys-detail-label",children:"Metadata"}),r.jsx("pre",{children:NG(e.metadata)})]})]})}function kG({items:e,navigate:t}){return e.length===0?r.jsxs("div",{className:"sys-panel sys-state-card",children:[r.jsx("h3",{className:"sys-state-title",children:"No dialogue"}),r.jsx("p",{className:"sys-state-body",children:"No messages were recorded in the selected window."})]}):r.jsx("div",{className:"sys-audit-list",children:e.map(n=>r.jsxs("article",{className:"sys-broker-row",children:[r.jsxs("div",{className:"sys-broker-row-main",children:[r.jsxs("div",{className:"sys-broker-row-head",children:[r.jsx("span",{className:"sys-chip sys-chip-neutral",children:n.class}),r.jsx("span",{className:"sys-broker-status",children:n.actorName??"unknown"}),r.jsx("span",{className:"sys-broker-time",children:la(n.ts)})]}),r.jsx("h3",{className:"sys-broker-title",children:n.body}),r.jsx("div",{className:"sys-broker-meta",children:r.jsxs("span",{children:["thread ",ay(n.conversationId)]})})]}),r.jsxs("div",{className:"sys-broker-row-side",children:[r.jsx("code",{children:ay(n.id)}),r.jsx("button",{type:"button",className:"s-btn s-btn-sm",onClick:()=>t({view:"conversation",conversationId:n.conversationId}),children:"Open thread"})]})]},n.id))})}function yk(e){return[...e].sort((t,n)=>t.createdAt-n.createdAt)}function EG(e,t){if(!e||!t)return!1;const n=new Date(e),s=new Date(t);return n.getFullYear()===s.getFullYear()&&n.getMonth()===s.getMonth()&&n.getDate()===s.getDate()}function CG(e){const t=new Date(e),n=new Date,s=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),i=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),l=Math.round((s-i)/864e5);return l===0?"Today":l===1?"Yesterday":t.toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"})}function AG({channel:e,agents:t,messageCount:n}){const s=g.useMemo(()=>e.participantIds.map(c=>{if(c==="operator")return{id:"operator",name:"You",handle:"operator",state:"available"};const d=t.find(h=>h.id===c);return d?{id:d.id,name:d.name,handle:d.handle??d.id,state:Xe(d.state)}:{id:c,name:c,handle:c,state:"offline"}}),[e.participantIds,t]),i=s.filter(c=>c.state!=="offline"),l=s.filter(c=>c.state==="offline");return r.jsxs("aside",{className:"ch-sidebar",children:[r.jsxs("section",{className:"ch-sidebar-section",children:[r.jsx("div",{className:"ch-sidebar-section-label",children:"Channel"}),r.jsxs("div",{className:"ch-sidebar-info",children:[r.jsxs("div",{className:"ch-sidebar-info-name",children:[r.jsx("span",{className:"ch-sidebar-info-hash",children:"#"}),r.jsx("span",{className:"ch-sidebar-info-title",children:Or(e)})]}),r.jsx("div",{className:"ch-sidebar-info-id",children:e.id}),r.jsxs("div",{className:"ch-sidebar-stats",children:[r.jsxs("span",{className:"ch-sidebar-stat",children:[r.jsx("span",{className:"ch-sidebar-stat-value",children:n}),r.jsx("span",{className:"ch-sidebar-stat-label",children:"messages"})]}),r.jsxs("span",{className:"ch-sidebar-stat",children:[r.jsx("span",{className:"ch-sidebar-stat-value",children:s.length}),r.jsx("span",{className:"ch-sidebar-stat-label",children:"members"})]})]})]})]}),r.jsxs("section",{className:"ch-sidebar-section",children:[r.jsxs("div",{className:"ch-sidebar-section-label",children:["Members",i.length>0&&r.jsxs("span",{className:"ch-sidebar-online-badge",children:[i.length," online"]})]}),r.jsx("div",{className:"ch-sidebar-members",children:[...i,...l].map(c=>r.jsxs("div",{className:"ch-sidebar-member",children:[r.jsxs("div",{className:"ch-sidebar-member-avatar-wrap",children:[r.jsx("div",{className:"ch-sidebar-member-avatar",style:{background:gt(c.name)},children:c.name[0]?.toUpperCase()??"?"}),r.jsx("span",{className:"ch-sidebar-member-dot",style:{background:Gs(c.state)}})]}),r.jsxs("div",{className:"ch-sidebar-member-info",children:[r.jsx("span",{className:"ch-sidebar-member-name",children:c.name}),r.jsxs("span",{className:"ch-sidebar-member-handle",children:["@",c.handle]})]}),c.state==="working"&&r.jsx("span",{className:"ch-sidebar-member-state",children:"working"})]},c.id))})]})]})}function TG({channelId:e,channelName:t,agents:n,operatorName:s,onMessageCountChange:i}){const[l,c]=g.useState([]),[d,h]=g.useState(""),[m,p]=g.useState(!1),[y,x]=g.useState(null),w=g.useRef(null),j=g.useRef(null),N=g.useRef(0),k=g.useRef(!1),E=g.useCallback(async()=>{try{const M=await ke(`/api/messages?conversationId=${encodeURIComponent(e)}&limit=300`),C=yk(M);c(C),_x(e),C.length!==N.current&&(N.current=C.length,i(C.length))}catch{}},[e,i]);g.useEffect(()=>{E()},[E]),Kt(M=>{M.kind==="message.posted"&&M.payload?.conversationId===e&&E()}),g.useEffect(()=>{if(l.length===0)return;const M=k.current?"smooth":"instant";w.current?.scrollIntoView({behavior:M}),k.current=!0},[l.length]);const A=async()=>{const M=d.trim();if(!M||m)return;p(!0),h(""),x(null);const C={id:`optimistic-${Date.now()}`,conversationId:e,actorName:s,body:M,createdAt:Date.now(),class:"operator"};c(I=>yk([...I,C]));try{await ke("/api/send",{method:"POST",body:JSON.stringify({body:M,conversationId:e})})}catch(I){c(R=>R.filter(D=>D.id!==C.id)),x(I instanceof Error?I.message:"Failed to send")}finally{p(!1)}},S=M=>{M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),A())};return r.jsxs("div",{className:"ch-feed-shell",children:[r.jsxs("div",{className:"ch-feed",children:[r.jsx("div",{className:"ch-feed-spacer"}),l.length===0&&r.jsxs("div",{className:"ch-empty-feed",children:[r.jsx("div",{className:"ch-empty-feed-hash",children:"#"}),r.jsxs("p",{className:"ch-empty-feed-title",children:["Welcome to #",t]}),r.jsx("p",{className:"ch-empty-feed-sub",children:"This is the beginning of the channel. Be the first to post."})]}),l.map((M,C)=>{const I=M.actorName===s||M.class==="operator",R=C===0||!EG(l[C-1]?.createdAt,M.createdAt),D=C===0||l[C-1]?.actorName!==M.actorName||R,z=la(M.createdAt),O=!I&&M.actorName?n.find(q=>q.name===M.actorName)??null:null,_=I?s.toLowerCase():O?.handle??null,U=gt(I?s:M.actorName??"?");return r.jsxs("div",{className:"ch-msg-group",children:[R&&r.jsxs("div",{className:"s-thread-day-divider",children:[r.jsx("span",{className:"s-thread-day-line"}),r.jsx("span",{className:"s-thread-day-label",children:CG(M.createdAt)}),r.jsx("span",{className:"s-thread-day-line"})]}),r.jsxs("article",{id:`msg-${M.id}`,className:["ch-msg",D&&"ch-msg--with-avatar"].filter(Boolean).join(" "),children:[D?r.jsx("div",{className:"ch-msg-avatar",style:{background:U},children:(I?s[0]:M.actorName?.[0]??"?").toUpperCase()}):r.jsx("div",{className:"ch-msg-avatar-gap",children:r.jsx("span",{className:"ch-msg-inline-time",title:z,children:De(M.createdAt)})}),r.jsxs("div",{className:"ch-msg-content",children:[D&&r.jsxs("div",{className:"ch-msg-header",children:[r.jsx("span",{className:"ch-msg-author",style:{color:U},children:I?s:M.actorName}),_&&r.jsxs("span",{className:"ch-msg-handle",children:["@",_]}),r.jsx("span",{className:"ch-msg-time",title:z,children:De(M.createdAt)})]}),r.jsx("div",{className:"ch-msg-body",children:r.jsx(Rx,{text:M.body})})]})]})]},M.id)}),r.jsx("div",{ref:w})]}),y&&r.jsx("div",{className:"ch-compose-error",children:y}),r.jsx("div",{className:"ch-compose-wrap",children:r.jsxs("form",{className:"ch-compose",onSubmit:M=>{M.preventDefault(),A()},children:[r.jsx("textarea",{ref:j,className:"ch-compose-input",placeholder:`Message #${t}…`,value:d,rows:1,onChange:M=>h(M.target.value),onKeyDown:S,disabled:m}),r.jsx("button",{type:"submit",className:"ch-compose-send",disabled:!d.trim()||m,"aria-label":"Send message",children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8"}),r.jsx("polyline",{points:"8 2 14 8 8 14"})]})})]})})]})}const MG=[{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 RG({count:e}){return r.jsxs("div",{className:"ch-overview",children:[r.jsxs("div",{className:"ch-overview-header",children:[r.jsx("div",{className:"ch-overview-hash",children:"#"}),r.jsxs("div",{className:"ch-overview-heading",children:[r.jsx("h2",{className:"ch-overview-title",children:"Channels"}),r.jsx("p",{className:"ch-overview-tagline",children:"Shared spaces where agents and operators coordinate over a common thread."})]})]}),r.jsxs("div",{className:"ch-overview-body",children:[r.jsxs("div",{className:"ch-overview-block",children:[r.jsx("div",{className:"ch-overview-block-label",children:"How it works"}),r.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 ",r.jsx("code",{className:"ch-overview-code",children:"channel.*"})," address and the broker creates it automatically. Agents, bridges, and operators all share the same thread."]})]}),r.jsxs("div",{className:"ch-overview-block",children:[r.jsx("div",{className:"ch-overview-block-label",children:e===0?"Start your first channel":`${e} channel${e!==1?"s":""} — pick one from the left`}),r.jsx("div",{className:"ch-overview-examples",children:MG.map(t=>r.jsxs("div",{className:"ch-overview-example",children:[r.jsxs("span",{className:"ch-overview-example-name",children:[r.jsx("span",{className:"ch-overview-example-hash",children:"#"}),t.slug]}),r.jsx("span",{className:"ch-overview-example-desc",children:t.description})]},t.slug))}),e===0&&r.jsxs("div",{className:"ch-overview-hint",children:["From any agent: ",r.jsx("code",{className:"ch-overview-code",children:'send --to channel.releases "deploy ready"'})]})]})]})]})}function _G({channelId:e,navigate:t}){const{agents:n}=ht(),[s,i]=g.useState([]),[l,c]=g.useState("operator"),[d,h]=g.useState(0),m=g.useMemo(()=>s.filter(Xo),[s]),p=e?m.find(x=>x.id===e)??null:null,y=g.useCallback(async()=>{const x=await ke("/api/conversations").catch(()=>[]);i(x)},[]);return g.useEffect(()=>{y()},[y]),g.useEffect(()=>{ke("/api/user").then(x=>{x?.name&&c(x.name)}).catch(()=>{})},[]),Kt(x=>{(x.kind==="message.posted"||x.kind==="conversation.upserted")&&y()}),r.jsx("div",{className:"ch-screen",children:p?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"ch-center-header",children:[r.jsxs("div",{className:"ch-center-header-left",children:[r.jsx("span",{className:"ch-center-hash",children:"#"}),r.jsx("span",{className:"ch-center-title",children:Or(p)}),r.jsx("span",{className:"ch-center-slug",children:rY(p)})]}),r.jsx("div",{className:"ch-center-header-right",children:p.participantIds.length>0&&r.jsxs("div",{className:"ch-center-member-stack",children:[p.participantIds.slice(0,4).map(x=>{const j=n.find(N=>N.id===x)?.name??x;return r.jsx("div",{className:"ch-center-member-pip",style:{background:gt(j)},title:j,children:j[0]?.toUpperCase()??"?"},x)}),p.participantIds.length>4&&r.jsxs("span",{className:"ch-center-member-overflow",children:["+",p.participantIds.length-4]})]})})]}),r.jsxs("div",{className:"ch-body",children:[r.jsx(TG,{channelId:e,channelName:Or(p),agents:n,operatorName:l,onMessageCountChange:h},e),r.jsx(AG,{channel:p,agents:n,messageCount:d})]})]}):r.jsx(RG,{count:m.length})})}const xk=["direct","channel","group_direct","thread","system"],IG={direct:"Direct messages",channel:"Channels",group_direct:"Group DMs",thread:"Threads",system:"System"};function bk(e){const t=xk.indexOf(e);return t===-1?xk.length:t}function OG(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 DG({navigate:e}){const[t,n]=g.useState([]),[s,i]=g.useState(!0),[l,c]=g.useState(null),[d,h]=g.useState(""),m=g.useCallback(async()=>{try{const x=await ke("/api/conversations");n(x),c(null)}catch(x){c(x instanceof Error?x.message:"Failed to load conversations")}finally{i(!1)}},[]);g.useEffect(()=>{m()},[m]),Kt(x=>{(x.kind==="message.posted"||x.kind==="conversation.upserted"||x.kind==="agent.endpoint.upserted")&&m()});const p=g.useMemo(()=>{const x=d.trim().toLowerCase();return x?t.filter(w=>[w.title,w.kind,w.agentName??"",w.preview??"",w.workspaceRoot??"",...w.participantIds].some(j=>j.toLowerCase().includes(x))):t},[t,d]),y=g.useMemo(()=>{const x=new Map;for(const w of p){const j=x.get(w.kind)??[];j.push(w),x.set(w.kind,j)}return[...x.entries()].sort((w,j)=>bk(w[0])-bk(j[0])).map(([w,j])=>({key:w,label:IG[w]??w,items:j}))},[p]);return r.jsxs("div",{className:"s-conversations",children:[r.jsxs("div",{className:"s-conversations__hero",children:[r.jsxs("div",{children:[r.jsx("div",{className:"s-conversations__eyebrow",children:"Playground"}),r.jsx("h1",{children:"Conversations"}),r.jsx("p",{children:"Unified, normalized conversation summaries from the broker service — no direct web DB reads in this view."})]}),r.jsx("button",{type:"button",className:"s-conversations__refresh",onClick:()=>{i(!0),m()},children:"Refresh"})]}),r.jsxs("div",{className:"s-conversations__toolbar",children:[r.jsx("input",{type:"text",className:"s-conversations__search",placeholder:"Filter conversations…",value:d,onChange:x=>h(x.target.value)}),r.jsxs("div",{className:"s-conversations__meta",children:[r.jsxs("span",{children:[p.length," shown"]}),r.jsxs("span",{children:[t.length," total"]})]})]}),l?r.jsx("div",{className:"s-conversations__state s-conversations__state--error",children:l}):null,!l&&s?r.jsx("div",{className:"s-conversations__state",children:"Loading conversations…"}):null,!s&&!l&&y.length===0?r.jsx("div",{className:"s-conversations__state",children:"No conversations yet."}):null,r.jsx("div",{className:"s-conversations__sections",children:y.map(x=>r.jsxs("section",{className:"s-conversations__section",children:[r.jsxs("div",{className:"s-conversations__section-header",children:[r.jsx("h2",{children:x.label}),r.jsx("span",{children:x.items.length})]}),r.jsx("div",{className:"s-conversations__list",children:x.items.map(w=>r.jsxs("button",{type:"button",className:"s-conversations__row",onClick:()=>e({view:"conversation",conversationId:w.id}),children:[r.jsxs("div",{className:"s-conversations__row-main",children:[r.jsxs("div",{className:"s-conversations__row-titleline",children:[r.jsx("strong",{children:w.title}),r.jsx("span",{className:`s-conversations__kind s-conversations__kind--${w.kind.replace(/_/g,"-")}`,children:w.kind})]}),r.jsx("div",{className:"s-conversations__row-sub",children:OG(w)}),r.jsx("div",{className:"s-conversations__row-preview",children:w.preview?.trim()||"No preview yet"})]}),r.jsxs("div",{className:"s-conversations__row-side",children:[r.jsxs("span",{children:[w.messageCount," msg"]}),r.jsx("span",{children:w.lastMessageAt?De(w.lastMessageAt):"—"})]})]},w.id))})]},x.key))})]})}function bo(...e){return e.find(t=>t&&t.trim().length>0)?.trim()??null}function wk(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"?{view:"ops",mode:"tail",...e.sessionId?{tailQuery:e.sessionId}:{}}: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?{view:"ops",mode:"tail"}:{view:"inbox"}}function PG(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 zG({route:e,navigate:t}){const[n,s]=g.useState(null),i=g.useMemo(()=>PG(e),[e]);return g.useEffect(()=>{let l=!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 d=c.toString(),h=d?await ke(`/api/follow?${d}`):i;if(l)return;t(wk({flightId:bo(h.flightId,i.flightId),invocationId:bo(h.invocationId,i.invocationId),conversationId:bo(h.conversationId,i.conversationId),workId:bo(h.workId,i.workId),sessionId:bo(h.sessionId,i.sessionId),targetAgentId:bo(h.targetAgentId,i.targetAgentId)},e.preferredView))}catch(d){if(l)return;s(d instanceof Error?d.message:String(d)),t(wk(i,e.preferredView))}})(),()=>{l=!0}},[i,t,e]),r.jsx("div",{className:"s-sessions-screen s-inbox-thread-redesign",children:r.jsx("section",{className:"s-thread-overview",children:r.jsxs("div",{className:"s-thread-overview-copy",children:[r.jsxs("div",{className:"s-sessions-header s-thread-overview-heading",children:[r.jsx("h2",{className:"s-page-title",children:"Follow"}),r.jsx("span",{className:"s-meta s-tabular",children:e.preferredView??"auto"})]}),r.jsx("p",{className:"s-thread-overview-summary",children:n?"Opening the closest available Scout view.":"Resolving Scout context..."})]})})})}function LG(e){return e<5?"Still up":e<12?"Good morning":e<18?"Good afternoon":"Good evening"}function wo(e){return e.status==="fulfilled"?null:e.reason instanceof Error?e.reason.message:String(e.reason)}function $G(e){if(e.kind==="flight_updated"&&/\breplied\.?$/i.test(e.title??""))return 0;const t=(e.title??e.summary??"").trim().toLowerCase();if(/^(kk|k|ok|okay|ping|pong|thanks|thank you)\.?$/.test(t))return 0;switch(e.kind){case"ask_failed":return 110;case"handoff_sent":return 100;case"collaboration_event":return 95;case"agent_message":return 90;case"status_message":return 85;case"ask_working":return 75;case"ask_opened":return 70;case"message_posted":return 60;case"invocation_recorded":return 30;case"flight_updated":return 20;default:return 50}}function UG(e){const t=(e.title??e.summary??"").trim().toLowerCase();return`${e.conversationId??"global"}:${t}`}function BG(e){switch(e){case"ask_opened":return"ask";case"handoff_sent":return"handoff";case"collaboration_event":return"work";case"agent_message":return"message";case"status_message":return"status";case"ask_failed":return"failed";case"ask_working":return"working";case"invocation_recorded":return"recorded";case"flight_updated":return"flight";default:return e.replace(/_/g," ")}}function VG(e,t=12){const n=e.map(l=>({item:l,rank:$G(l)})).filter(({rank:l})=>l>0).sort((l,c)=>{const d=c.item.ts-l.item.ts;return Math.abs(d)>3e4?d:c.rank-l.rank}),s=[],i=new Set;for(const{item:l}of n){const c=UG(l);if(!i.has(c)&&(i.add(c),s.push(l),s.length>=t))break}return s.sort((l,c)=>c.ts-l.ts)}function jk({navigate:e}){const{agents:t,onboarding:n,reload:s}=ht(),[i,l]=g.useState([]),[c,d]=g.useState([]),[h,m]=g.useState(null),[p,y]=g.useState(null),[x,w]=g.useState([]),[j,N]=g.useState("trailing 7d"),[k,E]=g.useState("3h buckets"),[A,S]=g.useState(!0),[M,C]=g.useState(!1),[I,R]=g.useState(null),[D,z]=g.useState(null),O=g.useRef(null),_=g.useRef(0),U=g.useRef(0),q=g.useRef(null);g.useEffect(()=>{q.current=h},[h]);const G=g.useCallback(async(oe="initial")=>{const je=++_.current;!(q.current!==null)&&oe!=="background"?(S(!0),R(null)):C(!0);const[le,ve,ue,Ce,be,we]=await Promise.allSettled([ke("/api/activity"),ke("/api/conversations"),ke("/api/fleet"),ke("/api/operator-attention"),ke("/api/heartrate"),s()]);if(je!==_.current)return;le.status==="fulfilled"&&l(le.value),ve.status==="fulfilled"&&d([...ve.value].sort((He,et)=>(et.lastMessageAt??0)-(He.lastMessageAt??0))),ue.status==="fulfilled"&&(q.current=ue.value,m(ue.value)),Ce.status==="fulfilled"&&y(Ce.value),be.status==="fulfilled"&&(w(be.value.buckets),N(be.value.windowLabel),E(be.value.bucketLabel??""));const Se=[wo(le),wo(ve),wo(ue),wo(Ce),wo(be),wo(we)].filter(He=>!!He);R(Se[0]??null),Se.length<5&&z(Date.now()),S(!1),C(!1)},[s]),X=g.useCallback(()=>{O.current||(O.current=setTimeout(()=>{O.current=null,G("background")},250))},[G]);g.useEffect(()=>(G(),()=>{O.current&&clearTimeout(O.current)}),[G]),Kt(X),g.useEffect(()=>{const oe=setInterval(()=>{document.visibilityState==="visible"&&G("background")},15e3);return()=>clearInterval(oe)},[G]),g.useEffect(()=>{const oe=()=>{if(document.visibilityState!=="visible")return;const je=Date.now();je-U.current<1e3||(U.current=je,G("background"))};return window.addEventListener("focus",oe),document.addEventListener("visibilitychange",oe),()=>{window.removeEventListener("focus",oe),document.removeEventListener("visibilitychange",oe)}},[G]);const L=g.useMemo(()=>t.filter(oe=>Xe(oe.state)==="working"),[t]),F=g.useMemo(()=>t.filter(oe=>Xe(oe.state)==="available"),[t]),H=g.useMemo(()=>t.filter(oe=>Xe(oe.state)==="offline"),[t]),V=g.useMemo(()=>[...h?.activeAsks??[],...h?.recentCompleted??[]].filter(oe=>oe.status==="needs_attention"||oe.status==="failed"),[h]),W=g.useMemo(()=>(h?.activeAsks??[]).filter(oe=>oe.status==="queued"||oe.status==="working"),[h]),$=g.useMemo(()=>h?.needsAttention??[],[h]),B=g.useMemo(()=>{const oe=new Map;for(const je of W){const Fe=oe.get(je.agentId);(!Fe||je.updatedAt>Fe.updatedAt)&&oe.set(je.agentId,je)}return oe},[W]),Y=g.useMemo(()=>W.filter(oe=>!L.some(je=>je.id===oe.agentId)),[L,W]),te=V.length+$.length,ae=p?.items??[],ee=p?.totals.all??te,ie=g.useMemo(()=>{const oe=[...V.map(je=>je.updatedAt),...$.map(je=>je.updatedAt),...ae.map(je=>je.updatedAt)];return oe.length>0?Math.min(...oe):null},[ae,V,$]),de=g.useMemo(()=>VG(i),[i]),xe=de.length===0?"quiet":`latest ${de.length} signal${de.length===1?"":"s"}`,Ae=new Date,me=LG(Ae.getHours()),Pe=ru(),Re=n?.operatorName?.trim()||n?.operatorNameSuggestion?.trim()||"operator",Ye=g.useMemo(()=>{const oe=[];return L.length>0&&oe.push(`${L.length} agent${L.length===1?" is":"s are"} working now`),F.length>0&&oe.push(`${F.length} agent${F.length===1?" is":"s are"} available`),ee>0&&oe.push(`${ee} thing${ee===1?"":"s"} need${ee===1?"s":""} you`),oe.length===0&&t.length>0&&oe.push(`${t.length} agent${t.length===1?" is":"s are"} registered`),oe.length===0&&oe.push("no agents are connected yet"),oe},[L,F,ee,t]),Ie=A?"syncing":I?`sync issue · ${D?De(D):"waiting"}`:D?`updated ${De(D)}`:"waiting";return r.jsx("div",{className:"s-fleet-home",children:r.jsxs("div",{className:"s-fleet-home-inner",children:[r.jsxs("div",{className:"s-hero",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"s-eyebrow",style:{marginBottom:12},children:["Fleet briefing ·"," ",Ae.toLocaleDateString([],{weekday:"long",month:"short",day:"numeric"}),r.jsx("span",{className:`s-fleet-sync-note${I?" s-fleet-sync-note--error":""}`,children:Ie})]}),r.jsxs("h1",{className:"s-hero-greeting",children:[me,", ",r.jsxs("em",{children:[Re,"."]})]}),r.jsxs("p",{className:"s-hero-narrative",children:[Ye.map((oe,je)=>r.jsxs("span",{children:[je>0&&", ",oe.includes("need")?r.jsx("span",{className:"s-hero-warn",children:oe}):r.jsx("strong",{children:oe})]},je)),"."]}),r.jsxs("div",{className:"s-hero-actions",children:[ee>0&&r.jsxs("button",{className:"s-btn-fleet s-btn-fleet--primary",onClick:()=>{document.getElementById("home-needs-you")?.scrollIntoView({behavior:"smooth",block:"start"})},children:["Clear queue · ",ee]}),Pe&&r.jsx("button",{className:"s-btn-fleet",onClick:()=>e({view:"ops"}),children:"Open ops center"}),r.jsx("button",{className:"s-btn-fleet",onClick:()=>e({view:"sessions"}),children:"Jump to thread"}),r.jsxs("button",{type:"button",className:"s-btn-fleet s-btn-fleet--icon",disabled:A||M,onClick:()=>{G("manual")},children:[r.jsx(by,{"aria-hidden":"true",size:12,strokeWidth:2,className:M?"s-refresh-spin":void 0}),r.jsx("span",{children:M?"Refreshing":"Refresh"})]})]})]}),r.jsxs("div",{className:"s-heartrate-card",children:[r.jsxs("div",{className:"s-heartrate-header",children:[r.jsx("span",{className:"s-eyebrow",children:"Fleet heart-rate"}),r.jsx("span",{style:{flex:1}}),r.jsxs("span",{className:"s-heartrate-live",children:["● ",j,k?` · ${k}`:""]})]}),r.jsx(HG,{buckets:x}),r.jsxs("div",{className:"s-heartrate-stats",children:[r.jsx($g,{label:"Active",value:L.length,color:"var(--green)"}),r.jsx($g,{label:"Waiting",value:F.length,color:"var(--amber)"}),r.jsx($g,{label:"Offline",value:H.length,color:"var(--dim)"})]})]})]}),r.jsxs("div",{className:"s-fleet-section",id:"home-needs-you",children:[r.jsx(Ug,{label:`Needs you · ${ee}`,right:ee>0&&ie!==null?r.jsxs("span",{style:{color:"var(--amber)"},children:["oldest ",De(ie)]}):"clear"}),ae.length>0?r.jsx(ZG,{items:ae,navigate:e,onResolved:oe=>y(oe)}):V.length>0&&r.jsx("div",{className:"s-ask-grid",children:V.slice(0,4).map(oe=>r.jsx(KG,{ask:oe,agents:t,navigate:e,operatorName:Re,pending:!0},oe.invocationId))}),ae.length===0&&$.length>0&&r.jsx("div",{className:"s-attention-list",children:$.map(oe=>r.jsx(XG,{item:oe,navigate:e},oe.recordId))}),ee===0&&r.jsx(qG,{agents:t,activeCount:L.length,waitingCount:F.length,offlineCount:H.length,navigate:e})]}),(L.length>0||Y.length>0)&&r.jsxs("div",{className:"s-fleet-section",children:[r.jsx(Ug,{label:`What's moving · ${L.length+Y.length}`,right:r.jsx("button",{className:"s-link-btn",onClick:()=>e({view:"mesh"}),children:"open mesh ↗"})}),L.length>0&&r.jsx("div",{className:"s-now-grid",style:{gridTemplateColumns:`repeat(${Math.min(L.length,3)}, 1fr)`},children:L.map(oe=>r.jsx(JG,{agent:oe,ask:B.get(oe.id)??null,navigate:e},oe.id))}),Y.length>0&&r.jsx("div",{className:"s-moving-ask-list",children:Y.map(oe=>r.jsx(QG,{ask:oe,navigate:e},oe.invocationId))})]}),de.length>0&&r.jsxs("div",{className:"s-fleet-section",children:[r.jsx(Ug,{label:"Since you were away",right:xe}),r.jsx(eK,{items:de,agents:t,navigate:e})]})]})})}function FG(e){if(e.length===0)return"";if(e.length===1)return`M ${e[0].x.toFixed(1)} ${e[0].y.toFixed(1)}`;const t=[`M ${e[0].x.toFixed(1)} ${e[0].y.toFixed(1)}`];for(let n=0;n<e.length-1;n++){const s=e[Math.max(0,n-1)],i=e[n],l=e[n+1],c=e[Math.min(e.length-1,n+2)],d={x:i.x+(l.x-s.x)/6,y:i.y+(l.y-s.y)/6},h={x:l.x-(c.x-i.x)/6,y:l.y-(c.y-i.y)/6};t.push(`C ${d.x.toFixed(1)} ${d.y.toFixed(1)}, ${h.x.toFixed(1)} ${h.y.toFixed(1)}, ${l.x.toFixed(1)} ${l.y.toFixed(1)}`)}return t.join(" ")}function HG({buckets:e}){const c=e.length;if(c<2||e.every(x=>x.count===0))return r.jsxs("svg",{viewBox:"0 0 372 82",style:{width:"100%",height:82,display:"block"},children:[r.jsx("line",{x1:"0",y1:60,x2:372,y2:60,stroke:"var(--border)"}),r.jsx("text",{x:372/2,y:82/2-4,textAnchor:"middle",fill:"var(--dim)",fontSize:"14",letterSpacing:"0.3em",children:"zzz"}),r.jsx("text",{x:372/2,y:82/2+12,textAnchor:"middle",fill:"var(--dim)",fontSize:"10",fontFamily:"var(--hud-font-mono)",opacity:"0.7",children:"nothing to report"})]});const h=372/(c-1),m=e.map((x,w)=>({x:w*h,y:60-Math.max(0,Math.min(1,x.value))*54})),p=FG(m),y=`${p} L 372 60 L 0 60 Z`;return r.jsxs("svg",{viewBox:"0 0 372 82",style:{width:"100%",height:82,display:"block"},children:[r.jsx("defs",{children:r.jsxs("linearGradient",{id:"hrFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[r.jsx("stop",{offset:"0%",stopColor:"var(--accent)",stopOpacity:"0.28"}),r.jsx("stop",{offset:"100%",stopColor:"var(--accent)",stopOpacity:"0"})]})}),r.jsx("line",{x1:"0",y1:6,x2:372,y2:6,stroke:"var(--border)",opacity:"0.18"}),r.jsx("line",{x1:"0",y1:66/2,x2:372,y2:66/2,stroke:"var(--border)",opacity:"0.25"}),r.jsx("line",{x1:"0",y1:60,x2:372,y2:60,stroke:"var(--border)"}),r.jsx("path",{d:y,fill:"url(#hrFill)"}),r.jsx("path",{d:p,fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round"}),r.jsx("circle",{cx:m[c-1].x,cy:m[c-1].y,r:"3.5",fill:"var(--accent)"}),r.jsx("text",{x:"0",y:77,fill:"var(--dim)",fontSize:"9",fontFamily:"var(--font-mono)",children:"7d ago"}),r.jsx("text",{x:372/2,y:77,textAnchor:"middle",fill:"var(--dim)",fontSize:"9",fontFamily:"var(--font-mono)",children:"3d"}),r.jsx("text",{x:372,y:77,textAnchor:"end",fill:"var(--dim)",fontSize:"9",fontFamily:"var(--font-mono)",children:"now"})]})}function $g({label:e,value:t,color:n}){return r.jsxs("div",{className:"s-stat",children:[r.jsxs("div",{className:"s-stat-label",children:[r.jsx("span",{className:"s-stat-dot",style:{background:n}}),r.jsx("span",{className:"s-eyebrow",children:e})]}),r.jsx("span",{className:"s-stat-value",children:t})]})}function Ug({label:e,right:t}){return r.jsxs("div",{className:"s-section-rule",children:[r.jsx("span",{className:"s-eyebrow",children:e}),r.jsx("span",{className:"s-section-rule-line"}),t&&r.jsx("span",{className:"s-section-rule-right",children:t})]})}function qG({agents:e,activeCount:t,waitingCount:n,offlineCount:s,navigate:i}){const l=g.useMemo(()=>{const c=d=>{switch(Xe(d.state)){case"working":return 0;case"available":return 1;default:return 2}};return[...e].sort((d,h)=>{const m=c(d)-c(h);return m!==0?m:(h.updatedAt??0)-(d.updatedAt??0)}).slice(0,8)},[e]);return r.jsxs("div",{className:"s-fleet-clear",children:[r.jsxs("div",{className:"s-fleet-clear-head",children:[r.jsxs("div",{children:[r.jsx("span",{className:"s-eyebrow",children:"Fleet overview"}),r.jsx("div",{className:"s-fleet-clear-title",children:e.length===0?"No agents registered":`${e.length} agent${e.length===1?"":"s"} registered`})]}),r.jsx("button",{className:"s-link-btn",onClick:()=>i({view:"agents"}),children:"open agents"})]}),r.jsxs("div",{className:"s-fleet-clear-metrics",children:[r.jsx(Bg,{label:"Working",value:t,color:"var(--green)"}),r.jsx(Bg,{label:"Available",value:n,color:"var(--accent)"}),r.jsx(Bg,{label:"Offline",value:s,color:"var(--dim)"})]}),l.length>0?r.jsx("div",{className:"s-fleet-roster",children:l.map(c=>{const d=Xe(c.state),h=c.handle?`@${c.handle}`:c.selector??c.id,m=c.role??c.agentClass,p={view:"agents",agentId:c.id,conversationId:c.conversationId||Nn(c.id),tab:d==="offline"?"profile":"observe"};return r.jsxs("button",{className:"s-fleet-roster-row",onClick:()=>i(p),children:[r.jsx("span",{className:"s-fleet-roster-dot",style:{background:Gs(c.state)}}),r.jsx("span",{className:"s-fleet-roster-name",children:c.name}),r.jsxs("span",{className:"s-fleet-roster-meta",children:[h," · ",m]}),r.jsx("span",{className:"s-fleet-roster-state",children:d}),r.jsx("span",{className:"s-fleet-roster-time",children:c.updatedAt?De(c.updatedAt):"no heartbeat"})]},c.id)})}):r.jsx("div",{className:"s-fleet-clear-empty",children:"No roster entries."})]})}function Bg({label:e,value:t,color:n}){return r.jsxs("div",{className:"s-fleet-metric",children:[r.jsx("span",{className:"s-fleet-metric-dot",style:{background:n}}),r.jsx("span",{className:"s-eyebrow",children:e}),r.jsx("span",{className:"s-fleet-metric-value",children:t})]})}function ZG({items:e,navigate:t,onResolved:n}){return r.jsxs("div",{className:"s-operator-queue",children:[r.jsxs("div",{className:"s-operator-queue-head",children:[r.jsxs("div",{children:[r.jsx("div",{className:"s-operator-queue-title",children:"Operator queue"}),r.jsx("div",{className:"s-operator-queue-subtitle",children:"Permissions, questions, and setup blockers in one place."})]}),r.jsx("div",{className:"s-operator-queue-count",children:e.length})]}),r.jsx("div",{className:"s-operator-queue-list",children:e.map(s=>r.jsx(GG,{item:s,navigate:t,onResolved:n},s.id))})]})}function WG(e){switch(e){case"critical":return"blocked";case"warning":return"needs input";default:return"review"}}function YG(e){const t=e.actions.find(n=>n.route)?.route;return t||(e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.agentId?{view:"agents",agentId:e.agentId}:null)}function GG({item:e,navigate:t,onResolved:n}){const[s,i]=g.useState(null),[l,c]=g.useState(!1),[d,h]=g.useState(null),m=YG(e),p=e.actions.find(N=>N.kind==="copy"&&N.value),y=e.actions.find(N=>N.kind==="approve"),x=e.actions.find(N=>N.kind==="deny"),w=async N=>{if(!(!e.approval&&!e.permissionRequest)){i(N),h(null);try{const k=e.permissionRequest?await ke("/api/operator-attention/permissions/decide",{method:"POST",body:JSON.stringify({id:e.permissionRequest.id,decision:N==="approve"?"allow":"deny"})}):await ke("/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:N})});n(k)}catch(k){h(k instanceof Error?k.message:String(k))}finally{i(null)}}},j=()=>{p?.value&&navigator.clipboard.writeText(p.value).then(()=>{c(!0),window.setTimeout(()=>c(!1),1400)})};return r.jsxs("div",{className:`s-operator-card s-operator-card--${e.severity}`,children:[r.jsxs("div",{className:"s-operator-card-main",children:[r.jsxs("div",{className:"s-operator-card-top",children:[r.jsx("span",{className:"s-eyebrow",children:e.sourceLabel}),r.jsx("span",{className:"s-operator-card-severity",children:WG(e.severity)}),r.jsx("span",{className:"s-operator-card-age",children:De(e.updatedAt)})]}),r.jsx("div",{className:"s-operator-card-title",children:e.title}),e.summary&&r.jsx("div",{className:"s-operator-card-summary",children:e.summary}),e.detail&&r.jsx("div",{className:"s-operator-card-detail",children:e.detail}),e.agentName&&r.jsx("div",{className:"s-operator-card-meta",children:e.agentName}),d&&r.jsx("div",{className:"s-operator-card-error",children:d})]}),r.jsxs("div",{className:"s-operator-card-actions",children:[y&&r.jsxs("button",{type:"button",className:"s-icon-btn s-icon-btn--primary",disabled:!!s,title:"Approve",onClick:()=>{w("approve")},children:[r.jsx(xO,{size:14,"aria-hidden":"true"}),r.jsx("span",{children:s==="approve"?"Approving":y.label})]}),x&&r.jsxs("button",{type:"button",className:"s-icon-btn",disabled:!!s,title:"Deny",onClick:()=>{w("deny")},children:[r.jsx(o5,{size:14,"aria-hidden":"true"}),r.jsx("span",{children:s==="deny"?"Denying":x.label})]}),p&&r.jsxs("button",{type:"button",className:"s-icon-btn",title:"Copy fix",onClick:j,children:[r.jsx(EO,{size:14,"aria-hidden":"true"}),r.jsx("span",{children:l?"Copied":p.label})]}),e.actions.some(N=>N.kind==="configure")&&r.jsxs("button",{type:"button",className:"s-icon-btn",title:"Open settings",onClick:()=>t({view:"settings"}),children:[r.jsx(ih,{size:14,"aria-hidden":"true"}),r.jsx("span",{children:"Settings"})]}),m&&r.jsxs("button",{type:"button",className:"s-icon-btn",title:"Open source",onClick:()=>t(m),children:[r.jsx(MO,{size:14,"aria-hidden":"true"}),r.jsx("span",{children:"Open"})]})]})]})}function KG({ask:e,agents:t,navigate:n,operatorName:s,pending:i}){const c=t.find(h=>h.id===e.agentId)?.name??e.agentName??e.agentId,d=e.conversationId?{view:"conversation",conversationId:e.conversationId}:{view:"agents",agentId:e.agentId};return r.jsxs("div",{className:`s-ask-block${i?" s-ask-block--pending":""}`,style:{cursor:"pointer"},onClick:()=>n(d),children:[r.jsxs("div",{className:"s-ask-header",children:[r.jsx("span",{className:"s-eyebrow s-ask-label",children:i?"◌ ASK — ATTENTION":"● ASK"}),r.jsx("span",{style:{flex:1}}),r.jsx("span",{className:"s-eyebrow",children:De(e.updatedAt)})]}),r.jsxs("div",{className:"s-ask-body",children:[r.jsx("div",{className:"s-avatar s-avatar-sm",style:{background:gt(c)},children:c[0]?.toUpperCase()??"?"}),r.jsxs("div",{className:"s-ask-body-copy",children:[r.jsxs("div",{className:"s-ask-route",children:[r.jsx("span",{className:"s-ask-route-name",children:c}),r.jsx("span",{children:" → "}),r.jsx("span",{style:{color:"var(--accent)"},children:s})]}),r.jsxs("div",{className:"s-ask-text",children:['"',e.summary??e.task,'"']})]})]}),i&&r.jsxs("div",{className:"s-ask-actions",children:[r.jsx("button",{className:"s-btn-fleet s-btn-fleet--primary",children:"Answer"}),r.jsx("button",{className:"s-btn-fleet",children:"Defer"}),r.jsx("button",{className:"s-btn-fleet",children:"Route…"}),r.jsx("span",{className:"s-ask-thinking",children:r.jsx("span",{className:"s-thinking-strip"})})]})]})}function XG({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,s=e.kind==="question"?"question":e.state.replace(/_/g," "),i=e.acceptanceState!=="none"?e.acceptanceState.replace(/_/g," "):e.kind==="question"?"awaiting answer":"your move",l=e.kind==="question"?"answer":e.state==="review"?"review":e.acceptanceState==="pending"?"acknowledge":"open work";return r.jsxs("div",{className:`s-attention-row${n?" s-attention-row--clickable":""}`,onClick:n?()=>t(n):void 0,children:[r.jsx("div",{className:"s-attention-row-title",children:e.title}),r.jsxs("div",{className:"s-attention-row-meta",children:[r.jsx("span",{className:"s-eyebrow",children:e.kind==="work_item"?"WORK ITEM":"QUESTION"}),e.agentName&&r.jsx("span",{children:e.agentName}),r.jsx("span",{children:s}),r.jsx("span",{style:{color:"var(--amber)"},children:i}),r.jsx("span",{style:{marginLeft:"auto"},children:De(e.updatedAt)}),n&&r.jsxs("span",{className:"s-attention-row-action",children:[l," ↗"]})]}),e.summary&&r.jsx("p",{className:"s-attention-row-summary",children:e.summary})]})}function JG({agent:e,ask:t,navigate:n}){const s=e.handle?`@${e.handle}`:e.id,i=e.role??e.agentClass,l=e.branch??"main",c=Nn(e.id),d=t?.summary??t?.task??e.cwd??`Working in ${e.project??"workspace"}`;return r.jsxs("div",{className:"s-now-card",onClick:()=>n({view:"agents",agentId:e.id,conversationId:c,tab:"observe"}),children:[r.jsxs("div",{className:"s-now-card-head",children:[r.jsx("div",{className:"s-avatar s-avatar-sm",style:{background:gt(e.name)},children:e.name[0]?.toUpperCase()??"?"}),r.jsxs("div",{className:"s-now-card-copy",children:[r.jsx("div",{className:"s-now-card-name",children:e.name}),r.jsxs("div",{className:"s-now-card-meta",children:[s," · ",i]})]}),r.jsx("span",{className:"s-now-card-live",children:"● live"})]}),r.jsx("div",{className:"s-now-card-task",children:d}),r.jsxs("div",{className:"s-now-card-ticker",children:[r.jsx("span",{className:"s-now-card-ticker-prompt",children:"›"}),r.jsx("span",{className:"s-now-card-ticker-text",children:t?`${t.statusLabel} · ${t.harness??e.harness??"agent"}`:"working"}),r.jsx("span",{className:"s-now-card-cursor"})]}),r.jsxs("div",{className:"s-now-card-footer",children:[r.jsx("span",{children:e.updatedAt?`updated ${De(e.updatedAt)}`:"active"}),r.jsx("span",{children:l})]})]})}function QG({ask:e,navigate:t}){const n=e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.collaborationRecordId?{view:"work",workId:e.collaborationRecordId}:{view:"agents",agentId:e.agentId};return r.jsxs("button",{className:"s-moving-ask-row",onClick:()=>t(n),children:[r.jsx("span",{className:"s-moving-ask-agent",children:e.agentName??e.agentId}),r.jsx("span",{className:"s-moving-ask-title",children:e.summary??e.task}),r.jsx("span",{className:"s-moving-ask-state",children:e.statusLabel}),r.jsx("span",{className:"s-moving-ask-time",children:De(e.updatedAt)})]})}function eK({items:e,agents:t,navigate:n}){const s=[...e].sort((c,d)=>d.ts-c.ts),i={ask_opened:"?",ask_failed:"!",ask_working:"…",handoff_sent:"→",collaboration_event:"◆",agent_message:"·",status_message:"·",message_posted:"·",invocation_recorded:"⌘",flight_updated:"⌘","collaboration.ask":"?","message.sent":"·","message.received":"·","flight.started":"⌘","flight.completed":"⌘","agent.online":"→","agent.offline":"→","agent.registered":"→","collaboration.answer":"↳"},l={ask_opened:"var(--amber)",ask_failed:"var(--red)",ask_working:"var(--amber)",handoff_sent:"var(--accent)",collaboration_event:"var(--green)",agent_message:"var(--dim)",status_message:"var(--muted)",message_posted:"var(--dim)",invocation_recorded:"var(--muted)",flight_updated:"var(--green)","collaboration.ask":"var(--amber)","collaboration.answer":"var(--accent)","message.sent":"var(--dim)","message.received":"var(--dim)","flight.started":"var(--muted)","flight.completed":"var(--green)","agent.online":"var(--accent)","agent.offline":"var(--dim)","agent.registered":"var(--accent)"};return r.jsxs("div",{className:"s-timeline",children:[r.jsx("div",{className:"s-timeline-spine"}),s.map(c=>{const d=c.actorName??"system",h=l[c.kind]??"var(--dim)",m=i[c.kind]??"·",p=BG(c.kind),y=c.conversationId?{view:"conversation",conversationId:c.conversationId}:null;return r.jsxs("div",{className:"s-timeline-row",style:{cursor:y?"pointer":void 0},onClick:y?()=>n(y):void 0,children:[r.jsx("div",{className:"s-timeline-bead",style:{background:h}}),r.jsx("span",{className:"s-timeline-time",children:De(c.ts)}),r.jsxs("div",{className:"s-timeline-actors",children:[r.jsx("span",{className:"s-timeline-kind-mark",style:{color:h},children:m}),r.jsx("div",{className:"s-avatar",style:{width:18,height:18,fontSize:9,background:gt(d)},children:d[0]?.toUpperCase()??"?"}),r.jsx("span",{className:"s-timeline-handle",children:d})]}),r.jsx("span",{className:"s-timeline-text",children:c.title??c.summary??""}),r.jsx("span",{className:"s-timeline-kind",children:p})]},c.id)})]})}let hs={mode:"map",selectedId:null,selectedType:null,meshSnapshot:null,probeCache:{}};const ry=new Set;function Th(){for(const e of ry)e()}function iy(e){hs.mode!==e&&(hs={...hs,mode:e},Th())}function Jo(e,t){hs.selectedId===e&&hs.selectedType===t||(hs={...hs,selectedId:e,selectedType:t},Th())}function oy(e){hs={...hs,meshSnapshot:e},Th()}function Vg(e,t){hs={...hs,probeCache:{...hs.probeCache,[e]:t}},Th()}function tK(e){return ry.add(e),()=>{ry.delete(e)}}function nK(){return hs}function Mh(){return g.useSyncExternalStore(tK,nK)}function sK(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:s,my:i,cx:l,cy:c}=t,d=(s-l)/e.scale-e.pan.x,h=(i-c)/e.scale-e.pan.y;return{scale:n,pan:{x:(s-l)/n-d,y:(i-c)/n-h}}}return e}function fi(e){return e?e.replace(/^https?:\/\//,"").split("/")[0].split(":")[0].split(".")[0]||e.slice(0,8):""}function $R(e){return e.split("/")[0]}function aK(e,t,n=130,s=90){if(t===0)return[];const l=Math.abs(e.x)<10&&Math.abs(e.y)<10?0:Math.atan2(e.y,e.x),c=s*Math.PI/180;return Array.from({length:t},(d,h)=>{const m=t===1?0:h/(t-1)-.5,p=l+m*c;return{x:e.x+Math.round(n*Math.cos(p)),y:e.y+Math.round(n*Math.sin(p))}})}function rK(e){const t=e.localNode?.id,n=[],s=[];e.localNode&&n.push({id:e.localNode.id,label:fi(e.localNode.hostName)||e.localNode.name,sublabel:"this node",kind:"local",online:e.health.reachable,discoverable:e.identity.discoverable});const i=Object.values(e.nodes),l=i.filter(d=>d.id!==t),c=new Set(i.flatMap(d=>[fi(d.hostName),fi(d.brokerUrl)]).filter(Boolean));for(const d of l)n.push({id:d.id,label:fi(d.hostName)||d.name||d.id.slice(0,8),sublabel:d.advertiseScope==="mesh"?"mesh peer":"local only",kind:"mesh",online:d.advertiseScope==="mesh"}),t&&s.push({fromId:t,toId:d.id,transport:"mesh",online:d.advertiseScope==="mesh"});for(const d of e.tailscale.peers){const h=fi(d.hostName)||fi(d.name);if(h&&c.has(h))continue;const m=`tailnet:${d.id}`;n.push({id:m,label:h||"tailnet",sublabel:"tailnet only",kind:"tailnet",online:d.online}),t&&s.push({fromId:t,toId:m,transport:"tailnet",online:d.online})}return{nodes:n,edges:s}}function iK(e){const t=new Map,n=e.find(p=>p.kind==="local");n&&t.set(n.id,{x:0,y:0});const s=e.filter(p=>p.kind==="mesh"),i=e.filter(p=>p.kind==="tailnet"),l=s.length>0&&i.length>0,c=170,d=l?260:170;s.forEach((p,y)=>{const x=y/s.length*Math.PI*2-Math.PI/2;t.set(p.id,{x:Math.round(c*Math.cos(x)),y:Math.round(c*Math.sin(x))})});const h=l?Math.PI/Math.max(i.length,1):0;return i.forEach((p,y)=>{const x=y/Math.max(i.length,1)*Math.PI*2-Math.PI/2+h;t.set(p.id,{x:Math.round(d*Math.cos(x)),y:Math.round(d*Math.sin(x))})}),s.length>0||i.length>0||t.set("__placeholder",{x:200,y:0}),t}function oK({node:e,isSelected:t}){const n=e.kind==="local";let s="mesh-card";n?s+=" mesh-card--local":e.kind==="mesh"?s+=e.online?" mesh-card--mesh-online":" mesh-card--mesh-offline":s+=e.online?" mesh-card--tailnet-online":" mesh-card--tailnet-offline",t&&(s+=" mesh-card--selected");let i="mesh-card-dot";return n?i+=" mesh-card-dot--local":e.kind==="mesh"?i+=e.online?" mesh-card-dot--green":" mesh-card-dot--dim":i+=e.online?" mesh-card-dot--sky":" mesh-card-dot--dim",r.jsxs("div",{className:s,"data-interactive":"true",children:[r.jsx("span",{className:i}),r.jsxs("div",{className:"mesh-card-body",children:[r.jsx("span",{className:"mesh-card-name",children:e.label}),r.jsx("span",{className:"mesh-card-sub",children:e.sublabel})]})]})}function lK({agent:e,pos:t,index:n}){const s=e.state==="working"?"working":e.state==="available"?"available":"offline";return r.jsx("div",{style:{position:"absolute",left:t.x,top:t.y,transform:"translate(-50%, -50%)",pointerEvents:"none",animationName:"meshAgentPopIn",animationDuration:"0.4s",animationTimingFunction:"cubic-bezier(0.34, 1.56, 0.64, 1)",animationDelay:`${n*55}ms`,animationFillMode:"both"},children:r.jsxs("div",{className:"mesh-agent-sub",children:[r.jsx("span",{className:`mesh-agent-sub-dot mesh-agent-sub-dot--${s}`}),r.jsx("span",{className:"mesh-agent-sub-name",children:e.title})]})})}function cK({selectedId:e,mesh:t,agents:n,positions:s,probeEntry:i}){const l=s.get(e);if(!l)return null;const c=t.localNode?.id===e,d=e.startsWith("tailnet:"),h=d?e.slice(8):null,m=h?t.tailscale.peers.find(j=>j.id===h):null,p=!c&&!d?t.nodes[e]:null,y=m?.addresses?.[0]?$R(m.addresses[0]):null,x=c?[...new Set(n.flatMap(j=>j.capabilities??[]))].slice(0,6):[],w=c?[...n].sort((j,N)=>{const k={working:0,available:1};return(k[Xe(j.state)]??2)-(k[Xe(N.state)]??2)}).slice(0,5):[];return r.jsxs("div",{className:"mesh-node-detail",style:{position:"absolute",left:l.x+78,top:l.y,transform:"translate(0, -50%)"},children:[c&&r.jsxs(r.Fragment,{children:[w.length>0&&r.jsxs("div",{className:"mesh-detail-section",children:[r.jsx("div",{className:"mesh-detail-label",children:"agents"}),w.map(j=>{const N=Xe(j.state);return r.jsxs("div",{className:"mesh-detail-agent",children:[r.jsx("span",{className:`mesh-detail-dot mesh-detail-dot--${N}`}),r.jsx("div",{className:"mesh-detail-agent-body",children:r.jsx("span",{className:"mesh-detail-agent-name",children:j.handle??j.name})}),r.jsx("span",{className:`mesh-detail-agent-state mesh-detail-agent-state--${N}`,children:N})]},j.id)})]}),w.length===0&&r.jsxs("div",{className:"mesh-detail-section",children:[r.jsx("div",{className:"mesh-detail-label",children:"agents"}),r.jsx("div",{className:"mesh-detail-empty",children:"none running"})]}),x.length>0&&r.jsxs("div",{className:"mesh-detail-section",children:[r.jsx("div",{className:"mesh-detail-label",children:"capabilities"}),r.jsx("div",{className:"mesh-detail-caps",children:x.map(j=>r.jsx("span",{className:"mesh-detail-cap",children:j},j))})]})]}),p&&r.jsxs("div",{className:"mesh-detail-section",children:[r.jsx("div",{className:"mesh-detail-label",children:"broker"}),p.brokerUrl&&r.jsxs("div",{className:"mesh-detail-row",children:[r.jsx("span",{className:"mesh-detail-key",children:"url"}),r.jsx("code",{className:"mesh-detail-val",children:fi(p.brokerUrl)})]}),r.jsxs("div",{className:"mesh-detail-row",children:[r.jsx("span",{className:"mesh-detail-key",children:"scope"}),r.jsx("span",{className:"mesh-detail-val",children:p.advertiseScope==="mesh"?"announced":"local only"})]}),p.lastSeenAt&&r.jsxs("div",{className:"mesh-detail-row",children:[r.jsx("span",{className:"mesh-detail-key",children:"last seen"}),r.jsx("span",{className:"mesh-detail-val",children:De(p.lastSeenAt)})]})]}),m&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"mesh-detail-section",children:[r.jsx("div",{className:"mesh-detail-label",children:"tailnet peer"}),y&&r.jsxs("div",{className:"mesh-detail-row",children:[r.jsx("span",{className:"mesh-detail-key",children:"address"}),r.jsx("code",{className:"mesh-detail-val",children:y})]}),m.os&&r.jsxs("div",{className:"mesh-detail-row",children:[r.jsx("span",{className:"mesh-detail-key",children:"platform"}),r.jsx("span",{className:"mesh-detail-val",children:m.os})]})]}),(!i||i.status==="loading")&&r.jsx("div",{className:"mesh-detail-section",children:r.jsx("div",{className:"mesh-detail-empty",children:"Connecting to broker…"})}),i?.status==="error"&&r.jsx("div",{className:"mesh-detail-section",children:r.jsx("div",{className:"mesh-detail-empty",children:i.result?.error??"Broker unreachable"})}),i?.status==="done"&&i.result?.node?.capabilities?.length&&r.jsxs("div",{className:"mesh-detail-section",children:[r.jsx("div",{className:"mesh-detail-label",children:"capabilities"}),r.jsx("div",{className:"mesh-detail-caps",children:i.result.node.capabilities.map(j=>r.jsx("span",{className:"mesh-detail-cap",children:j},j))})]}),i?.status==="done"&&i.result?.home&&r.jsx("div",{className:"mesh-detail-section",children:r.jsxs("div",{className:"mesh-detail-empty",style:{fontStyle:"normal",opacity:.5},children:[i.result.home.agents.length," agent",i.result.home.agents.length!==1?"s":""," ↗"]})})]})]})}function Nk({mesh:e,agents:t=[]}){const n=g.useRef(null),[s,i]=g.useState({w:0,h:0}),[l,c]=g.useReducer(sK,{pan:{x:0,y:0},scale:1}),{selectedId:d,probeCache:h}=Mh(),m=g.useRef({});g.useEffect(()=>{m.current=h},[h]),g.useLayoutEffect(()=>{const C=n.current;if(!C)return;const I=()=>i({w:C.clientWidth,h:C.clientHeight});I();const R=new ResizeObserver(I);return R.observe(C),()=>R.disconnect()},[]),g.useLayoutEffect(()=>{const C=n.current;if(!C)return;const I=R=>{R.preventDefault();const D=R.deltaY<0?1.12:1/1.12,z=C.getBoundingClientRect();c({type:"zoom",factor:D,mx:R.clientX-z.left,my:R.clientY-z.top,cx:z.width/2,cy:z.height/2})};return C.addEventListener("wheel",I,{passive:!1}),()=>C.removeEventListener("wheel",I)},[]),g.useEffect(()=>{if(!d?.startsWith("tailnet:"))return;const C=m.current[d];if(C&&C.status!=="loading"&&Date.now()-C.fetchedAt<3e4)return;const I=d.slice(8),R=e.tailscale.peers.find(z=>z.id===I),D=R?.addresses?.[0]?$R(R.addresses[0]):null;D&&(Vg(d,{status:"loading",result:null,fetchedAt:Date.now()}),(async()=>{try{const z=await ke("/api/mesh/tailnet-probe",{method:"POST",body:JSON.stringify({ip:D})});Vg(d,{status:z.reachable?"done":"error",result:z,fetchedAt:Date.now()})}catch(z){Vg(d,{status:"error",result:{reachable:!1,home:null,node:null,error:z instanceof Error?z.message:String(z)},fetchedAt:Date.now()})}})())},[d,e]);const{nodes:p,edges:y}=rK(e),x=iK(p),w=p.some(C=>C.kind!=="local"),{pan:j,scale:N}=l,k=s.w/2,E=s.h/2,A=g.useCallback(C=>{C!=="__placeholder"&&Jo(d===C?null:C,d===C?null:"node")},[d]),S=d?h[d]??null:null,M=[];if(d?.startsWith("tailnet:")&&S?.status==="done"&&S.result?.home?.agents?.length){const C=x.get(d)??{x:0,y:0},I=S.result.home.agents,R=aK(C,I.length,135,90);I.forEach((D,z)=>{M.push({agent:D,pos:R[z]})})}return r.jsxs("div",{ref:n,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[s.w>0&&r.jsx(lA,{panOffset:j,scale:N,onPan:C=>c({type:"pan",delta:C}),gridOpacity:.7}),r.jsxs("div",{style:{position:"absolute",left:0,top:0,width:0,height:0,transform:`translate(${k}px, ${E}px) translate(${j.x*N}px, ${j.y*N}px) scale(${N})`,transformOrigin:"0 0",pointerEvents:"none"},children:[r.jsxs("svg",{style:{position:"absolute",overflow:"visible",left:0,top:0,width:0,height:0},fill:"none",children:[y.map(C=>{const I=x.get(C.fromId),R=x.get(C.toId);if(!I||!R)return null;const D=C.transport==="mesh"?C.online?"#4ade80":"#3f3f46":C.online?"#38bdf8":"#27272a";return r.jsx("line",{x1:I.x,y1:I.y,x2:R.x,y2:R.y,stroke:D,strokeWidth:C.transport==="mesh"?1.5:1,strokeDasharray:C.transport==="tailnet"?"6 4":void 0,opacity:C.online?.45:.15},`${C.fromId}-${C.toId}`)}),!w&&(()=>{const C=p.find(D=>D.kind==="local"),I=C?x.get(C.id):void 0,R=x.get("__placeholder");return!I||!R?null:r.jsx("line",{x1:I.x,y1:I.y,x2:R.x,y2:R.y,stroke:"#3f3f46",strokeWidth:1,strokeDasharray:"4 4",opacity:.2})})(),d&&(()=>{const C=x.get(d);return C?r.jsx("line",{x1:C.x+10,y1:C.y,x2:C.x+74,y2:C.y,stroke:"rgba(255,255,255,0.1)",strokeWidth:1}):null})(),M.map(({agent:C,pos:I})=>{const R=d?x.get(d):null;return R?r.jsx("line",{x1:R.x,y1:R.y,x2:I.x,y2:I.y,stroke:"rgba(56, 189, 248, 0.18)",strokeWidth:1,strokeDasharray:"3 4"},`fan-line-${C.id}`):null})]}),p.map(C=>{const I=x.get(C.id);return I?r.jsx("div",{style:{position:"absolute",left:I.x,top:I.y,transform:"translate(-50%, -50%)",pointerEvents:"all"},onClick:()=>A(C.id),children:r.jsx(oK,{node:C,isSelected:d===C.id})},C.id):null}),M.map(({agent:C,pos:I},R)=>r.jsx(lK,{agent:C,pos:I,index:R},C.id)),d&&r.jsx(cK,{selectedId:d,mesh:e,agents:t,positions:x,probeEntry:S}),!w&&(()=>{const C=x.get("__placeholder");return C?r.jsx("div",{style:{position:"absolute",left:C.x,top:C.y,transform:"translate(-50%, -50%)",pointerEvents:"none"},children:r.jsx("div",{className:"mesh-card mesh-card--placeholder",children:r.jsx("span",{className:"mesh-card-name",style:{opacity:.35},children:"no peers"})})}):null})()]}),r.jsx("div",{className:"mesh-canvas-hint",children:"scroll to zoom · drag to pan"})]})}function uK(e){const t=e.hostName?.trim();if(t&&t.toLowerCase()!=="localhost")return t;const n=e.dnsName?.trim().replace(/\.$/,"");return n?n.split(".")[0]??n:e.name}function dK(e){return e==="mesh"?"Announced to mesh":e==="local"?"Local only":e||"Not advertised"}function fK(e){return!e.health.reachable||e.issues.some(t=>t.severity==="error")?"danger":e.issues.length>0?"warning":"success"}function hK(e){return e.health.reachable?e.issues.some(t=>t.severity==="error")?"Degraded":e.issues.length>0?"Needs attention":"Healthy":"Broker unreachable"}const Sk={working:0,available:1,offline:2};function mK(){const{agents:e,navigate:t}=ht();if(e.length===0)return r.jsxs("div",{className:"sys-list-empty",children:[r.jsx("h3",{children:"No agents registered"}),r.jsx("p",{children:"Agents connected to this broker will appear here."})]});const n=[...e].sort((s,i)=>{const l=Sk[Xe(s.state)]??3,c=Sk[Xe(i.state)]??3;return l!==c?l-c:(i.updatedAt??0)-(s.updatedAt??0)});return r.jsx("div",{className:"mesh-agent-table",children:n.map(s=>{const i=Xe(s.state);return r.jsxs("button",{type:"button",className:"mesh-agent-row",onClick:()=>t({view:"agents",agentId:s.id}),children:[r.jsx("span",{className:`mesh-agent-dot mesh-agent-dot--${i}`,style:{background:Gs(s.state)}}),r.jsx("span",{className:"mesh-agent-name",children:s.handle??s.name}),r.jsxs("span",{className:"mesh-agent-project",children:[s.project??"—",s.branch?` · ${s.branch}`:""]}),r.jsx("span",{className:`mesh-agent-state mesh-agent-state--${i}`,children:i}),r.jsx("span",{className:"mesh-agent-time",children:s.updatedAt?De(s.updatedAt):""})]},s.id)})})}function pK({mode:e,mesh:t,tone:n,statusLabel:s,loading:i,refreshing:l,error:c,lastLoadedAt:d,onRefresh:h}){return r.jsxs("div",{className:"mesh-hud",children:[r.jsxs("div",{className:"mesh-hud-left",children:[r.jsx("span",{className:"mesh-hud-title",children:"Mesh"}),r.jsxs("div",{className:"mesh-mode-toggle",children:[r.jsx("button",{type:"button",className:`mesh-mode-btn${e==="map"?" mesh-mode-btn--active":""}`,onClick:()=>iy("map"),children:"Map"}),r.jsx("button",{type:"button",className:`mesh-mode-btn${e==="fleet"?" mesh-mode-btn--active":""}`,onClick:()=>iy("fleet"),children:"Fleet"})]})]}),r.jsxs("div",{className:"mesh-hud-right",children:[t&&r.jsx("span",{className:`sys-chip sys-chip-${n}`,children:s}),t?.tailscale.available&&!t.tailscale.running&&r.jsx("span",{className:"sys-chip sys-chip-warning",children:"Tailnet stopped"}),r.jsx("span",{className:"mesh-hud-sync",children:i?"Loading…":c&&t?`Stale — ${d?De(d):"unknown"}`:d?De(d):"—"}),r.jsx("button",{type:"button",className:"s-btn",disabled:i||l,onClick:h,children:l?"Refreshing…":"Refresh"})]})]})}function gK({navigate:e}){const[t,n]=g.useState(null),[s,i]=g.useState(!0),[l,c]=g.useState(!1),[d,h]=g.useState(!1),[m,p]=g.useState(null),[y,x]=g.useState(null),{mode:w}=Mh(),{agents:j}=ht(),N=g.useRef(null),k=g.useRef(0);g.useEffect(()=>{N.current=t},[t]);const E=g.useCallback(async(_="initial")=>{const U=++k.current;!(N.current!==null)&&_!=="background"?(i(!0),p(null)):c(!0);try{const G=await ke("/api/mesh");if(U!==k.current)return;n(G),oy(G),p(null),x(Date.now())}catch(G){if(U!==k.current)return;p(G instanceof Error?G.message:String(G))}finally{U===k.current&&(i(!1),c(!1))}},[]);g.useEffect(()=>{E("initial")},[E]),g.useEffect(()=>{const _=setInterval(()=>{E("background")},1e4);return()=>clearInterval(_)},[E]);const A=g.useCallback(async()=>{h(!0);try{const _=await ke("/api/mesh/tailscale",{method:"POST",body:JSON.stringify({action:"open_app"})});n(_),oy(_),N.current=_,p(null),x(Date.now())}finally{h(!1)}},[]),S=t?fK(t):"warning",M=t?hK(t):"Loading",C=t?Object.values(t.nodes):[],I=t?.localNode?.id,R=t?.localNode?.hostName?.toLowerCase(),D=C.filter(_=>_.id!==I),z=(t?.tailscale.peers??[]).filter(_=>{const U=_.hostName?.toLowerCase();return!U||U==="localhost"?!0:!(R&&(U===R||U.startsWith(`${R.split(".")[0]}.`)))}),O={mode:w,mesh:t,tone:S,statusLabel:M,loading:s,refreshing:l,error:m,lastLoadedAt:y,onRefresh:()=>{E("manual")}};return w==="map"?r.jsxs("div",{className:"mesh-map-canvas",children:[t&&r.jsx(Nk,{mesh:t,agents:j}),s&&!t&&r.jsx("div",{className:"mesh-canvas-center",children:r.jsx("p",{className:"mesh-canvas-center-label",children:"Loading mesh…"})}),!s&&!t&&m&&r.jsxs("div",{className:"mesh-canvas-center",children:[r.jsx("p",{className:"mesh-canvas-center-label",children:m}),r.jsx("button",{type:"button",className:"s-btn",onClick:()=>{E("manual")},children:"Try again"})]}),m&&t&&r.jsx("div",{className:"mesh-hud-banner",children:"Mesh refresh failed — showing stale data"}),t?.tailscale.available&&!t.tailscale.running&&r.jsxs("div",{className:"mesh-hud-banner mesh-hud-banner--warning",children:["Tailscale is stopped."," ",r.jsx("button",{type:"button",className:"s-btn",disabled:d,onClick:()=>{A()},children:d?"Opening…":"Open Tailscale"})]}),r.jsx(pK,{...O})]}):r.jsxs("div",{className:"sys-surface-page",children:[r.jsxs("div",{className:"sys-page-head",children:[r.jsx("div",{className:"sys-page-title-group",children:r.jsx("h2",{className:"sys-page-title",children:"Mesh"})}),r.jsxs("div",{className:"sys-page-actions",children:[r.jsxs("div",{className:"mesh-mode-toggle",children:[r.jsx("button",{type:"button",className:"mesh-mode-btn",onClick:()=>iy("map"),children:"Map"}),r.jsx("button",{type:"button",className:"mesh-mode-btn mesh-mode-btn--active",children:"Fleet"})]}),t&&r.jsx("span",{className:`sys-chip sys-chip-${S}`,children:M}),r.jsx("div",{className:"sys-sync-note",children:s?"Loading…":y?`Confirmed ${De(y)}`:"—"}),r.jsx("button",{type:"button",className:"s-btn",disabled:s||l,onClick:()=>{E("manual")},children:l?"Refreshing…":"Refresh"})]})]}),m&&t&&r.jsxs("div",{className:"sys-banner sys-banner-warning",children:[r.jsx("strong",{children:"Mesh refresh failed."}),r.jsx("span",{children:m})]}),s&&!t&&r.jsxs("div",{className:"sys-panel sys-state-card",children:[r.jsx("h3",{className:"sys-state-title",children:"Loading mesh status"}),r.jsx("p",{className:"sys-state-body",children:"Inspecting broker reachability and peer discovery inputs."})]}),!s&&!t&&m&&r.jsxs("div",{className:"sys-panel sys-state-card sys-state-card-error",children:[r.jsx("h3",{className:"sys-state-title",children:"Mesh status is unavailable"}),r.jsx("p",{className:"sys-state-body",children:m}),r.jsx("div",{className:"sys-inline-actions",children:r.jsx("button",{type:"button",className:"s-btn",onClick:()=>{E("manual")},children:"Try again"})})]}),t&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"mesh-fleet-mini",children:r.jsx(Nk,{mesh:t,agents:j})}),r.jsxs("section",{className:"sys-panel",children:[r.jsx("div",{className:"sys-section-head",children:r.jsxs("div",{children:[r.jsx("h3",{className:"sys-section-title",children:"Agents"}),r.jsx("p",{className:"sys-section-subtitle",children:"All agents registered with this broker."})]})}),r.jsx(mK,{})]}),r.jsxs("section",{className:"sys-panel",children:[r.jsx("div",{className:"sys-section-head",children:r.jsxs("div",{children:[r.jsx("h3",{className:"sys-section-title",children:"Discovered peers"}),r.jsxs("p",{className:"sys-section-subtitle",children:["Remote brokers registered in ",t.meshId??"this mesh","."]})]})}),D.length===0?r.jsxs("div",{className:"sys-list-empty",children:[r.jsx("h3",{children:"No remote brokers discovered"}),r.jsx("p",{children:"This can be normal on a single-node setup. If you expect peers, check mesh health in the inspector."})]}):r.jsx("div",{className:"sys-list-grid",children:D.map(_=>r.jsxs("article",{className:"sys-list-card",children:[r.jsxs("div",{className:"sys-list-card-head",children:[r.jsx("h3",{className:"sys-list-card-title",children:_.name}),r.jsx("span",{className:`sys-chip sys-chip-${_.advertiseScope==="mesh"?"success":"neutral"}`,children:dK(_.advertiseScope)})]}),r.jsxs("div",{className:"sys-list-card-detail",children:[r.jsx("span",{className:"sys-detail-label",children:"Node id"}),r.jsx("code",{className:"sys-detail-value",children:_.id})]}),_.brokerUrl&&r.jsxs("div",{className:"sys-list-card-detail",children:[r.jsx("span",{className:"sys-detail-label",children:"Broker"}),r.jsx("code",{className:"sys-detail-value",children:_.brokerUrl})]}),r.jsxs("div",{className:"sys-list-card-detail",children:[r.jsx("span",{className:"sys-detail-label",children:"Last seen"}),r.jsx("span",{className:"sys-detail-value",children:_.lastSeenAt?De(_.lastSeenAt):"Recently registered"})]})]},_.id))})]}),r.jsxs("section",{className:"sys-panel",children:[r.jsx("div",{className:"sys-section-head",children:r.jsxs("div",{children:[r.jsx("h3",{className:"sys-section-title",children:"Tailnet"}),r.jsx("p",{className:"sys-section-subtitle",children:"External Tailscale peers visible from this machine."})]})}),z.length===0?r.jsxs("div",{className:"sys-list-empty",children:[r.jsx("h3",{children:"No external tailnet peers"}),r.jsx("p",{children:t.tailscale.available?t.tailscale.running?"Only this host is visible in the current tailnet snapshot.":"Tailscale is installed but currently stopped.":"Tailscale peers were not detected on this machine."})]}):r.jsx("div",{className:"sys-list-grid",children:z.map(_=>r.jsxs("article",{className:"sys-list-card",children:[r.jsxs("div",{className:"sys-list-card-head",children:[r.jsx("h3",{className:"sys-list-card-title",children:uK(_)}),r.jsx("span",{className:`sys-chip sys-chip-${_.online?"success":"failed"}`,children:_.online?"Online":"Offline"})]}),r.jsxs("div",{className:"sys-list-card-detail",children:[r.jsx("span",{className:"sys-detail-label",children:"Address"}),r.jsx("code",{className:"sys-detail-value",children:_.addresses?.[0]??"Unavailable"})]}),r.jsxs("div",{className:"sys-list-card-detail",children:[r.jsx("span",{className:"sys-detail-label",children:"Platform"}),r.jsx("span",{className:"sys-detail-value",children:_.os??"Unknown"})]})]},_.id))})]}),t.tailscale.available&&!t.tailscale.running&&r.jsxs("div",{className:"sys-banner sys-banner-warning",children:[r.jsx("strong",{children:"Tailscale is stopped."}),r.jsx("span",{children:t.tailscale.health[0]??"This machine is showing cached Tailnet peers, but the local Tailscale backend is not running."}),r.jsxs("div",{className:"sys-inline-actions",children:[r.jsx("button",{type:"button",className:"s-btn",disabled:d,onClick:()=>{A()},children:d?"Opening Tailscale…":"Open Tailscale"}),r.jsx("button",{type:"button",className:"s-btn",disabled:d||l,onClick:()=>{E("manual")},children:l?"Refreshing…":"Refresh status"})]})]})]})]})}const kk=48,Ek=720;function vK(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 s={};for(const[i,l]of Object.entries(n))typeof l=="number"&&Number.isFinite(l)&&l>0&&(s[i]=l);return s}catch{return null}}function Fg(e,t){if(e&&!(typeof window>"u"))try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function UR({storageKey:e,columns:t}){const n=g.useMemo(()=>{const x=vK(e)??{},w={};for(const j of t)w[j.key]=x[j.key]??j.defaultWidth;return w},[e,t]),[s,i]=g.useState(n);g.useEffect(()=>{i(x=>{let w=!1;const j={...x};for(const N of t)j[N.key]==null&&(j[N.key]=N.defaultWidth,w=!0);return w?j:x})},[t]);const l=g.useMemo(()=>{const x=new Map;for(const w of t)x.set(w.key,w);return x},[t]),c=g.useRef(null),d=g.useCallback(x=>{const w=c.current;if(!w)return;const j=x.clientX-w.startX,N=Math.min(w.max,Math.max(w.min,w.startWidth+j));i(k=>k[w.key]===N?k:{...k,[w.key]:N})},[]),h=g.useCallback(()=>{c.current&&(c.current=null,document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h),i(x=>(Fg(e,x),x)))},[d,e]);g.useEffect(()=>()=>{window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h)},[d,h]);const m=g.useCallback(x=>{const w=s[x],j=l.get(x),N=j?.minWidth??kk,k=j?.maxWidth??Ek;return{style:{width:w,minWidth:N,maxWidth:k},"data-resize-key":x}},[s,l]),p=g.useCallback(x=>({onPointerDown:k=>{if(k.button!==0)return;k.preventDefault(),k.stopPropagation();const E=l.get(x),A=E?.minWidth??kk,S=E?.maxWidth??Ek,M=s[x]??E?.defaultWidth??A;c.current={key:x,startX:k.clientX,startWidth:M,min:A,max:S},document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("pointermove",d),window.addEventListener("pointerup",h),window.addEventListener("pointercancel",h)},onClick:k=>{k.stopPropagation()},onDoubleClick:k=>{k.preventDefault(),k.stopPropagation();const E=l.get(x);E&&i(A=>{const S={...A,[x]:E.defaultWidth};return Fg(e,S),S})},role:"separator","aria-orientation":"vertical","aria-label":"Resize column",className:"s-resize-handle"}),[s,l,d,h,e]),y=g.useCallback(()=>{i(()=>{const x={};for(const w of t)x[w.key]=w.defaultWidth;return Fg(e,x),x})},[t,e]);return{widths:s,getColumnProps:m,getResizeHandleProps:p,resetAll:y}}var yK=Object.create,BR=Object.defineProperty,xK=Object.getOwnPropertyDescriptor,VR=Object.getOwnPropertyNames,bK=Object.getPrototypeOf,wK=Object.prototype.hasOwnProperty,ga=(e,t)=>function(){return t||(0,e[VR(e)[0]])((t={exports:{}}).exports,t),t.exports},jK=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(var i=VR(t),l=0,c=i.length,d;l<c;l++)d=i[l],!wK.call(e,d)&&d!==n&&BR(e,d,{get:(h=>t[h]).bind(null,d),enumerable:!(s=xK(t,d))||s.enumerable});return e},fn=(e,t,n)=>(n=e!=null?yK(bK(e)):{},jK(BR(n,"default",{value:e,enumerable:!0}),e)),FR=ga({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e,t){function n(s){"@babel/helpers - typeof";return t.exports=n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(i){return typeof i}:function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},t.exports.__esModule=!0,t.exports.default=t.exports,n(s)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),NK=ga({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e,t){var n=FR().default;function s(i,l){if(n(i)!="object"||!i)return i;var c=i[Symbol.toPrimitive];if(c!==void 0){var d=c.call(i,l||"default");if(n(d)!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(l==="string"?String:Number)(i)}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports}}),SK=ga({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e,t){var n=FR().default,s=NK();function i(l){var c=s(l,"string");return n(c)=="symbol"?c:c+""}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}}),Ri=ga({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e,t){var n=SK();function s(i,l,c){return(l=n(l))in i?Object.defineProperty(i,l,{value:c,enumerable:!0,configurable:!0,writable:!0}):i[l]=c,i}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports}}),Ks=ga({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e,t){var n=Ri();function s(l,c){var d=Object.keys(l);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(l);c&&(h=h.filter(function(m){return Object.getOwnPropertyDescriptor(l,m).enumerable})),d.push.apply(d,h)}return d}function i(l){for(var c=1;c<arguments.length;c++){var d=arguments[c]!=null?arguments[c]:{};c%2?s(Object(d),!0).forEach(function(h){n(l,h,d[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(d)):s(Object(d)).forEach(function(h){Object.defineProperty(l,h,Object.getOwnPropertyDescriptor(d,h))})}return l}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}});function ou(e){const t={subscribe(n){let s=null,i=!1,l=!1,c=!1;function d(){if(s===null){c=!0;return}l||(l=!0,typeof s=="function"?s():s&&s.unsubscribe())}return s=e({next(h){var m;i||(m=n.next)===null||m===void 0||m.call(n,h)},error(h){var m;i||(i=!0,(m=n.error)===null||m===void 0||m.call(n,h),d())},complete(){var h;i||(i=!0,(h=n.complete)===null||h===void 0||h.call(n),d())}}),c&&d(),{unsubscribe:d}},pipe(...n){return n.reduce(kK,t)}};return t}function kK(e,t){return t(e)}function EK(e){const t=new AbortController;return new Promise((s,i)=>{let l=!1;function c(){l||(l=!0,d.unsubscribe())}t.signal.addEventListener("abort",()=>{i(t.signal.reason)});const d=e.subscribe({next(h){l=!0,s(h),c()},error(h){i(h)},complete(){t.abort(),c()}})})}function CK(e){return t=>{let n=0,s=null;const i=[];function l(){s||(s=t.subscribe({next(d){for(const m of i){var h;(h=m.next)===null||h===void 0||h.call(m,d)}},error(d){for(const m of i){var h;(h=m.error)===null||h===void 0||h.call(m,d)}},complete(){for(const h of i){var d;(d=h.complete)===null||d===void 0||d.call(h)}}}))}function c(){if(n===0&&s){const d=s;s=null,d.unsubscribe()}}return ou(d=>(n++,i.push(d),l(),{unsubscribe(){n--,c();const h=i.findIndex(m=>m===d);h>-1&&i.splice(h,1)}}))}}function HR(e){let t=e;const n=[],s=c=>{t!==void 0&&c.next(t),n.push(c)},i=c=>{n.splice(n.indexOf(c),1)},l=ou(c=>(s(c),()=>{i(c)}));return l.next=c=>{if(t!==c){t=c;for(const d of n)d.next(c)}},l.get=()=>t,l}function AK(e){return ou(t=>{function n(i=0,l=e.op){const c=e.links[i];if(!c)throw new Error("No more links to execute - did you forget to add an ending link?");return c({op:l,next(h){return n(i+1,h)}})}return n().subscribe(t)})}function Zc(e){return!!e&&!Array.isArray(e)&&typeof e=="object"}function TK(){return Object.create(null)}const Ck=e=>e();function Ak(e=0){return new Promise(t=>setTimeout(t,e))}var MK=Object.create,qR=Object.defineProperty,RK=Object.getOwnPropertyDescriptor,ZR=Object.getOwnPropertyNames,_K=Object.getPrototypeOf,IK=Object.prototype.hasOwnProperty,lu=(e,t)=>function(){return t||(0,e[ZR(e)[0]])((t={exports:{}}).exports,t),t.exports},OK=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(var i=ZR(t),l=0,c=i.length,d;l<c;l++)d=i[l],!IK.call(e,d)&&d!==n&&qR(e,d,{get:(h=>t[h]).bind(null,d),enumerable:!(s=RK(t,d))||s.enumerable});return e},Rh=(e,t,n)=>(n=e!=null?MK(_K(e)):{},OK(qR(n,"default",{value:e,enumerable:!0}),e));const WR=()=>{},Tk=e=>{Object.freeze&&Object.freeze(e)};function YR(e,t,n){var s;const i=t.join(".");return(s=n[i])!==null&&s!==void 0||(n[i]=new Proxy(WR,{get(l,c){if(!(typeof c!="string"||c==="then"))return YR(e,[...t,c],n)},apply(l,c,d){const h=t[t.length-1];let m={args:d,path:t};return h==="call"?m={args:d.length>=2?[d[1]]:[],path:t.slice(0,-1)}:h==="apply"&&(m={args:d.length>=2?d[1]:[],path:t.slice(0,-1)}),Tk(m.args),Tk(m.path),e(m)}})),n[i]}const DK=e=>YR(e,[],TK()),PK=e=>new Proxy(WR,{get(t,n){if(n!=="then")return e(n)}});var GR=lu({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e,t){function n(s){"@babel/helpers - typeof";return t.exports=n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(i){return typeof i}:function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},t.exports.__esModule=!0,t.exports.default=t.exports,n(s)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),zK=lu({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e,t){var n=GR().default;function s(i,l){if(n(i)!="object"||!i)return i;var c=i[Symbol.toPrimitive];if(c!==void 0){var d=c.call(i,l||"default");if(n(d)!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(l==="string"?String:Number)(i)}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports}}),LK=lu({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e,t){var n=GR().default,s=zK();function i(l){var c=s(l,"string");return n(c)=="symbol"?c:c+""}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}}),KR=lu({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e,t){var n=LK();function s(i,l,c){return(l=n(l))in i?Object.defineProperty(i,l,{value:c,enumerable:!0,configurable:!0,writable:!0}):i[l]=c,i}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports}}),Dx=lu({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e,t){var n=KR();function s(l,c){var d=Object.keys(l);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(l);c&&(h=h.filter(function(m){return Object.getOwnPropertyDescriptor(l,m).enumerable})),d.push.apply(d,h)}return d}function i(l){for(var c=1;c<arguments.length;c++){var d=arguments[c]!=null?arguments[c]:{};c%2?s(Object(d),!0).forEach(function(h){n(l,h,d[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(d)):s(Object(d)).forEach(function(h){Object.defineProperty(l,h,Object.getOwnPropertyDescriptor(d,h))})}return l}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}});Rh(Dx());Rh(KR());var Fd=Rh(Dx());function $K(e,t){if("error"in e){const s=t.deserialize(e.error);return{ok:!1,error:(0,Fd.default)((0,Fd.default)({},e),{},{error:s})}}return{ok:!0,result:(0,Fd.default)((0,Fd.default)({},e.result),(!e.result.type||e.result.type==="data")&&{type:"data",data:t.deserialize(e.result.data)})}}var Hg=class extends Error{constructor(){super("Unable to transform response from server")}};function UK(e,t){let n;try{n=$K(e,t)}catch{throw new Hg}if(!n.ok&&(!Zc(n.error.error)||typeof n.error.error.code!="number"))throw new Hg;if(n.ok&&!Zc(n.result))throw new Hg;return n}Rh(Dx());var Hd=fn(Ri()),jo=fn(Ks());function BK(e){return e instanceof mi}function VK(e){return Zc(e)&&Zc(e.error)&&typeof e.error.code=="number"&&typeof e.error.message=="string"}function FK(e,t){return typeof e=="string"?e:Zc(e)&&typeof e.message=="string"?e.message:t}var mi=class gf extends Error{constructor(t,n){var s,i;const l=n?.cause;super(t,{cause:l}),(0,Hd.default)(this,"cause",void 0),(0,Hd.default)(this,"shape",void 0),(0,Hd.default)(this,"data",void 0),(0,Hd.default)(this,"meta",void 0),this.meta=n?.meta,this.cause=l,this.shape=n==null||(s=n.result)===null||s===void 0?void 0:s.error,this.data=n==null||(i=n.result)===null||i===void 0?void 0:i.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,gf.prototype)}static from(t,n={}){const s=t;return BK(s)?(n.meta&&(s.meta=(0,jo.default)((0,jo.default)({},s.meta),n.meta)),s):VK(s)?new gf(s.error.message,(0,jo.default)((0,jo.default)({},n),{},{result:s,cause:n.cause})):new gf(FK(s,"Unknown error"),(0,jo.default)((0,jo.default)({},n),{},{cause:s}))}};function HK(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}}}fn(Ks());fn(Ks());fn(Ks());fn(Ks());const qK={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)}},ZK={enabled:!1,closeMs:0},WK={enabled:!1,pongTimeoutMs:1e3,intervalMs:5e3},YK=e=>e===0?0:Math.min(1e3*2**e,3e4),XR=(e,...t)=>typeof e=="function"?e(...t):e;var GK=fn(Ri()),No=class JR extends Error{constructor(t){super(t.message,{cause:t.cause}),this.name="TRPCWebSocketClosedError",Object.setPrototypeOf(this,JR.prototype)}},KK=class{constructor(e,t){this.onTimeout=e,this.timeoutMs=t,(0,GK.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 QR(){let e,t;return{promise:new Promise((s,i)=>{e=s,t=i}),resolve:e,reject:t}}async function XK(e){const t=await XR(e.url);if(!e.connectionParams)return t;const s=`${t.includes("?")?"&":"?"}connectionParams=1`;return t+s}async function JK(e,t){const n={method:"connectionParams",data:await XR(e)};return t.encode(n)}var Mk=fn(Ri()),QK=class{constructor(){(0,Mk.default)(this,"outgoingRequests",new Array),(0,Mk.default)(this,"pendingRequests",{})}register(e,t){const{promise:n,resolve:s}=QR();return this.outgoingRequests.push({id:String(e.id),message:e,end:n,callbacks:{next:t.next,complete:()=>{t.complete(),s()},error:i=>{t.error(i),s()}}}),()=>{this.delete(e.id),t.complete(),s()}}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}},yr=fn(Ri());function eX(e){const{promise:t,resolve:n,reject:s}=QR();return e.addEventListener("open",()=>{e.removeEventListener("error",s),n()}),e.addEventListener("error",s),t}function tX(e,{intervalMs:t,pongTimeoutMs:n}){let s,i;function l(){s=setTimeout(()=>{e.send("PING"),i=setTimeout(()=>{e.close()},n)},t)}function c(){clearTimeout(s),l()}function d(){clearTimeout(i),c()}e.addEventListener("open",l),e.addEventListener("message",({data:h})=>{clearTimeout(s),l(),h==="PONG"&&d()}),e.addEventListener("close",()=>{clearTimeout(s),clearTimeout(i)})}var e2=class ly{constructor(t){var n;if((0,yr.default)(this,"id",++ly.connectCount),(0,yr.default)(this,"WebSocketPonyfill",void 0),(0,yr.default)(this,"urlOptions",void 0),(0,yr.default)(this,"keepAliveOpts",void 0),(0,yr.default)(this,"encoder",void 0),(0,yr.default)(this,"wsObservable",HR(null)),(0,yr.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=++ly.connectCount;const n=XK(t.urlOptions).then(s=>new t.WebSocketPonyfill(s));t.openPromise=n.then(async s=>{t.ws=s,s.binaryType="arraybuffer",s.addEventListener("message",function({data:i}){i==="PING"&&this.send("PONG")}),t.keepAliveOpts.enabled&&tX(s,t.keepAliveOpts),s.addEventListener("close",()=>{t.ws===s&&(t.ws=null)}),await eX(s),t.urlOptions.connectionParams&&s.send(await JK(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,yr.default)(e2,"connectCount",0);function nX(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 ta=fn(Ri()),So=fn(Ks()),sX=class{constructor(e){var t,n;(0,ta.default)(this,"connectionState",void 0),(0,ta.default)(this,"allowReconnect",!1),(0,ta.default)(this,"requestManager",new QK),(0,ta.default)(this,"activeConnection",void 0),(0,ta.default)(this,"reconnectRetryDelay",void 0),(0,ta.default)(this,"inactivityTimeout",void 0),(0,ta.default)(this,"callbacks",void 0),(0,ta.default)(this,"lazyMode",void 0),(0,ta.default)(this,"encoder",void 0),(0,ta.default)(this,"reconnecting",null),this.encoder=(t=e.experimental_encoder)!==null&&t!==void 0?t:qK,this.callbacks={onOpen:e.onOpen,onClose:e.onClose,onError:e.onError};const s=(0,So.default)((0,So.default)({},ZK),e.lazy);this.inactivityTimeout=new KK(()=>{if(this.requestManager.hasOutgoingRequests()||this.requestManager.hasPendingRequests()){this.inactivityTimeout.reset();return}this.close().catch(()=>null)},s.closeMs),this.activeConnection=new e2({WebSocketPonyfill:e.WebSocket,urlOptions:e,keepAlive:(0,So.default)((0,So.default)({},WK),e.keepAlive),encoder:this.encoder}),this.activeConnection.wsObservable.subscribe({next:i=>{i&&this.setupWebSocketListeners(i)}}),this.reconnectRetryDelay=(n=e.retryDelayMs)!==null&&n!==void 0?n:YK,this.lazyMode=s.enabled,this.connectionState=HR({type:"state",state:s.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 No({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(mi.from(new No({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:s,signal:i},transformer:l,lastEventId:c}){return ou(d=>{const h=this.batchSend({id:e,method:t,params:{input:l.input.serialize(s),path:n,lastEventId:c}},(0,So.default)((0,So.default)({},d),{},{next(m){const p=UK(m,l.output);if(!p.ok){d.error(mi.from(p.error));return}d.next({result:p.result})}}));return()=>{h(),t==="subscription"&&this.activeConnection.isOpen()&&this.send({id:e,method:"subscription.stop"}),i?.removeEventListener("abort",h)}})}get connection(){return nX(this.activeConnection)}reconnect(e){var t=this;if(this.connectionState.next({type:"state",state:"connecting",error:mi.from(e)}),this.reconnecting)return;const n=async s=>{try{await Ak(t.reconnectRetryDelay(s)),t.allowReconnect&&(await t.activeConnection.close(),await t.activeConnection.open(),t.requestManager.hasPendingRequests()&&t.send(t.requestManager.getPendingRequests().map(({message:i})=>i))),t.reconnecting=null}catch{await n(s+1)}};this.reconnecting=n(0)}setupWebSocketListeners(e){var t=this;const n=s=>{const i=this.requestManager.getPendingRequests();for(const{message:l,callbacks:c}of i)l.method!=="subscription"&&(c.error(mi.from(s??new No({message:"WebSocket closed",cause:s}))),this.requestManager.delete(l.id))};e.addEventListener("open",()=>{Ck(async()=>{var s,i;t.lazyMode&&t.inactivityTimeout.start(),(s=(i=t.callbacks).onOpen)===null||s===void 0||s.call(i),t.connectionState.next({type:"state",state:"pending",error:null})}).catch(s=>{e.close(3e3),n(s)})}),e.addEventListener("message",({data:s})=>{if(this.inactivityTimeout.reset(),["PING","PONG"].includes(s))return;const i=this.encoder.decode(s);if("method"in i){this.handleIncomingRequest(i);return}this.handleResponseMessage(i)}),e.addEventListener("close",s=>{var i,l;n(s),(i=(l=this.callbacks).onClose)===null||i===void 0||i.call(l,s),(!this.lazyMode||this.requestManager.hasPendingSubscriptions())&&this.reconnect(new No({message:"WebSocket closed",cause:s}))}),e.addEventListener("error",s=>{var i,l;n(s),(i=(l=this.callbacks).onError)===null||i===void 0||i.call(l,s),this.reconnect(new No({message:"WebSocket closed",cause:s}))})}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 No({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(),Ck(async()=>{n.activeConnection.isOpen()||await n.open(),await Ak(0),n.requestManager.hasOutgoingRequests()&&n.send(n.requestManager.flush().map(({message:s})=>s))}).catch(s=>{this.requestManager.delete(e.id),t.error(mi.from(s))}),this.requestManager.register(e,t)}};function aX(e){return new sX(e)}function rX(e){const{client:t}=e,n=HK(e.transformer);return()=>({op:s})=>ou(i=>{const l=s.type==="subscription"?t.connectionState.subscribe({next(d){i.next({result:d,context:s.context})}}):null,c=t.request({op:s,transformer:n}).subscribe(i);return()=>{c.unsubscribe(),l?.unsubscribe()}})}var qg=fn(Ri()),Rk=fn(Ks()),iX=class{constructor(e){(0,qg.default)(this,"links",void 0),(0,qg.default)(this,"runtime",void 0),(0,qg.default)(this,"requestId",void 0),this.requestId=0,this.runtime={},this.links=e.links.map(t=>t(this.runtime))}$request(e){var t;return AK({links:this.links,op:(0,Rk.default)((0,Rk.default)({},e),{},{context:(t=e.context)!==null&&t!==void 0?t:{},id:++this.requestId})}).pipe(CK())}async requestAsPromise(e){var t=this;try{const n=t.$request(e);return(await EK(n)).result.data}catch(n){throw mi.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(i){switch(i.result.type){case"state":{var l;(l=n.onConnectionStateChange)===null||l===void 0||l.call(n,i.result);break}case"started":{var c;(c=n.onStarted)===null||c===void 0||c.call(n,{context:i.context});break}case"stopped":{var d;(d=n.onStopped)===null||d===void 0||d.call(n);break}case"data":case void 0:{var h;(h=n.onData)===null||h===void 0||h.call(n,i.result.data);break}}},error(i){var l;(l=n.onError)===null||l===void 0||l.call(n,i)},complete(){var i;(i=n.onComplete)===null||i===void 0||i.call(n)}})}};const oX=Symbol.for("trpc_untypedClient"),lX={query:"query",mutate:"mutation",subscribe:"subscription"},cX=e=>lX[e];function uX(e){const t=DK(({path:n,args:s})=>{const i=[...n],l=cX(i.pop()),c=i.join(".");return e[l](c,...s)});return PK(n=>n===oX?e:t[n])}function dX(e){const t=new iX(e);return uX(t)}fn(Ks());fn(Ks());var fX=ga({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(e,t){function n(i){var l,c,d,h=2;for(typeof Symbol<"u"&&(c=Symbol.asyncIterator,d=Symbol.iterator);h--;){if(c&&(l=i[c])!=null)return l.call(i);if(d&&(l=i[d])!=null)return new s(l.call(i));c="@@asyncIterator",d="@@iterator"}throw new TypeError("Object is not async iterable")}function s(i){function l(c){if(Object(c)!==c)return Promise.reject(new TypeError(c+" is not an object."));var d=c.done;return Promise.resolve(c.value).then(function(h){return{value:h,done:d}})}return s=function(d){this.s=d,this.n=d.next},s.prototype={s:null,n:null,next:function(){return l(this.n.apply(this.s,arguments))},return:function(d){var h=this.s.return;return h===void 0?Promise.resolve({value:d,done:!0}):l(h.apply(this.s,arguments))},throw:function(d){var h=this.s.return;return h===void 0?Promise.reject(d):l(h.apply(this.s,arguments))}},new s(i)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}});fn(fX());fn(Ks());var hX=ga({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(e,t){function n(){var s=typeof SuppressedError=="function"?SuppressedError:function(d,h){var m=Error();return m.name="SuppressedError",m.error=d,m.suppressed=h,m},i={},l=[];function c(d,h){if(h!=null){if(Object(h)!==h)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(d)var m=h[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(m===void 0&&(m=h[Symbol.dispose||Symbol.for("Symbol.dispose")],d))var p=m;if(typeof m!="function")throw new TypeError("Object is not disposable.");p&&(m=function(){try{p.call(h)}catch(x){return Promise.reject(x)}}),l.push({v:h,d:m,a:d})}else d&&l.push({d:h,a:d});return h}return{e:i,u:c.bind(null,!1),a:c.bind(null,!0),d:function(){var h,m=this.e,p=0;function y(){for(;h=l.pop();)try{if(!h.a&&p===1)return p=0,l.push(h),Promise.resolve().then(y);if(h.d){var w=h.d.call(h.v);if(h.a)return p|=2,Promise.resolve(w).then(y,x)}else p|=1}catch(j){return x(j)}if(p===1)return m!==i?Promise.reject(m):Promise.resolve();if(m!==i)throw m}function x(w){return m=m!==i?new s(w,m):w,y()}return y()}}}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),t2=ga({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(e,t){function n(s,i){this.v=s,this.k=i}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),mX=ga({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(e,t){var n=t2();function s(i){return new n(i,0)}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports}}),pX=ga({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(e,t){var n=t2();function s(l){return function(){return new i(l.apply(this,arguments))}}function i(l){var c,d;function h(p,y){try{var x=l[p](y),w=x.value,j=w instanceof n;Promise.resolve(j?w.v:w).then(function(N){if(j){var k=p==="return"?"return":"next";if(!w.k||N.done)return h(k,N);N=l[k](N).value}m(x.done?"return":"normal",N)},function(N){h("throw",N)})}catch(N){m("throw",N)}}function m(p,y){switch(p){case"return":c.resolve({value:y,done:!0});break;case"throw":c.reject(y);break;default:c.resolve({value:y,done:!1})}(c=c.next)?h(c.key,c.arg):d=null}this._invoke=function(p,y){return new Promise(function(x,w){var j={key:p,arg:y,resolve:x,reject:w,next:null};d?d=d.next=j:(c=d=j,h(p,y))})},typeof l.return!="function"&&(this.return=void 0)}i.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},i.prototype.next=function(l){return this._invoke("next",l)},i.prototype.throw=function(l){return this._invoke("throw",l)},i.prototype.return=function(l){return this._invoke("return",l)},t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports}});fn(hX());fn(mX());fn(pX());fn(Ks());const vf=new Set;let Zg=null,_k=null,Xf=null;function gX(){return`ws://${typeof window<"u"?window.location.hostname:"127.0.0.1"}:65535/trpc`}function vX(e){for(const t of[...vf])t(e)}function yX(){Xf||(Zg||(Zg=aX({url:gX()}),_k=dX({links:[rX({client:Zg})]})),Xf=_k.tail.events.subscribe(void 0,{onData:e=>{const t=e.data;t&&vX(t)}}))}function xX(){Xf?.unsubscribe(),Xf=null}function cu(e){const t=g.useRef(e);t.current=e,g.useEffect(()=>{const n=s=>t.current(s);return vf.add(n),yX(),()=>{vf.delete(n),vf.size===0&&xX()}},[])}const Ik=[{key:"status",label:"status",cls:"s-atop-col-status",defaultWidth:96,minWidth:70},{key:"session",label:"session",cls:"s-atop-col-agent",defaultWidth:168,minWidth:110,maxWidth:280},{key:"project",label:"project",cls:"s-atop-col-project",defaultWidth:200,minWidth:96,maxWidth:360},{key:"updated",label:"updated",cls:"s-atop-col-last",defaultWidth:86,minWidth:64},{key:"size",label:"size",cls:"s-atop-col-runtime",defaultWidth:80,minWidth:64},{key:"path",label:"path",defaultWidth:360,minWidth:160,maxWidth:800}],bX=1e4,wX=500,Ok=1e3,jX=6e4;function Dk(e){const t=e?.trim();if(!t)return null;const n=n2(t);return n.endsWith(".jsonl")?n.slice(0,-6):n}function n2(e){const t=e.replace(/[\\/]+$/,"");return t.split(/[\\/]/).filter(Boolean).at(-1)??t}function NX(e){const n=e.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean);return n.pop(),n.at(-1)??""}function Pk(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function SX(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 kX(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 EX(e){return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(e))}function CX(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 zk(e){return`${e.source}\0${e.cwd??""}`}function AX(e){return`${e.source}\0${e.cwd??""}`}function TX(e,t,n){if(!e?.transcripts?.length)return[];const s=new Map;for(const l of t){const c=s.get(l.sessionId);(!c||l.ts>c.ts)&&s.set(l.sessionId,l)}const i=new Map;for(const l of e.processes){if(!l.cwd)continue;const c=i.get(zk(l));(!c||l.pid<c.pid)&&i.set(zk(l),l)}return e.transcripts.map(l=>{const c=Dk(l.sessionId)??Dk(l.transcriptPath);if(!c)return null;const d=l.sessionId?s.get(l.sessionId)??null:null,h=i.get(AX(l))??null,m=Math.max(l.mtimeMs,d?.ts??0),p=!!h||n-m<=jX,y=l.project?.trim()||(l.cwd?n2(l.cwd):NX(l.transcriptPath))||"unknown";return{refId:c,source:l.source||"unknown",project:y,cwd:l.cwd,transcriptPath:l.transcriptPath,sessionId:l.sessionId,mtimeMs:l.mtimeMs,size:l.size,status:p?"run":"idle",statusLabel:p?"active":"idle",lastEvent:d,process:h}}).filter(l=>l!==null).sort((l,c)=>{const d=Math.max(l.mtimeMs,l.lastEvent?.ts??0);return Math.max(c.mtimeMs,c.lastEvent?.ts??0)-d||l.project.localeCompare(c.project)})}function MX({navigate:e}){const[t,n]=g.useState(null),[s,i]=g.useState([]),[l,c]=g.useState(""),[d,h]=g.useState("all"),[m,p]=g.useState(0),[y,x]=g.useState(null),[w,j]=g.useState(Date.now()),N=g.useRef(null),k=g.useCallback(async()=>{x(null);try{n(await ke("/api/tail/discover"))}catch(z){x(z instanceof Error?z.message:String(z))}},[]);g.useEffect(()=>{k();const z=setInterval(()=>{k()},bX);return()=>clearInterval(z)},[k]),g.useEffect(()=>{let z=!1;return(async()=>{try{const O=await ke(`/api/tail/recent?limit=${wX}`);z||i(O.events??[])}catch{}})(),()=>{z=!0}},[]),cu(z=>{i(O=>O.length>=Ok?[...O.slice(O.length-Ok+1),z]:[...O,z])}),g.useEffect(()=>{const z=setInterval(()=>j(Date.now()),15e3);return()=>clearInterval(z)},[]);const E=g.useMemo(()=>TX(t,s,w),[t,s,w]),A=g.useMemo(()=>[...new Set(E.map(z=>z.source))].sort(),[E]),S=g.useMemo(()=>E.filter(z=>(d==="all"||z.source===d)&&CX(z,l.trim())),[E,d,l]);g.useEffect(()=>{m>=S.length&&p(Math.max(0,S.length-1))},[S.length,m]);const M=g.useCallback(z=>{z&&e({view:"sessions",sessionId:z.refId})},[e]);g.useEffect(()=>{const z=O=>{const _=O.target,U=_ instanceof HTMLInputElement||_ instanceof HTMLTextAreaElement||(_?.isContentEditable??!1);if(O.key==="/"&&!U){O.preventDefault(),N.current?.focus();return}if(U){O.key==="Escape"&&_===N.current&&(c(""),N.current?.blur());return}if(O.key==="ArrowDown"||O.key==="j"){O.preventDefault(),p(q=>S.length===0?0:Math.min(S.length-1,q+1));return}if(O.key==="ArrowUp"||O.key==="k"){O.preventDefault(),p(q=>Math.max(0,q-1));return}(O.key==="Enter"||O.key==="o")&&(O.preventDefault(),M(S[m]))};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[S,m,M]);const C=E.filter(z=>z.status==="run").length,I=t?.totals.transcripts??t?.transcripts?.length??0,{getColumnProps:R,getResizeHandleProps:D}=UR({storageKey:"openscout.sessions.cols",columns:Ik});return r.jsxs("div",{className:"s-atop",children:[r.jsxs("div",{className:"s-atop-summary",children:[r.jsxs("div",{className:"s-atop-summary-cell",children:[r.jsxs("div",{className:"s-atop-summary-num",children:[r.jsx("strong",{children:E.length}),r.jsxs("span",{className:"s-atop-summary-of",children:["of ",I]})]}),r.jsx("div",{className:"s-atop-summary-lbl",children:"raw sessions"})]}),r.jsxs("div",{className:"s-atop-summary-cell",children:[r.jsx("div",{className:"s-atop-summary-num",children:r.jsx("strong",{children:C})}),r.jsx("div",{className:"s-atop-summary-lbl",children:"active"})]}),r.jsxs("div",{className:"s-atop-summary-cell s-atop-summary-cell--breakdown",children:[r.jsx("div",{className:"s-atop-summary-row",children:A.length===0?r.jsx("span",{className:"s-atop-chip s-atop-chip--mute",children:"no sources"}):A.map(z=>r.jsx("span",{className:`s-atop-chip s-atop-chip--harness s-atop-chip--harness-${Pk(z)}`,children:z},z))}),r.jsx("div",{className:"s-atop-summary-lbl",children:"sources"})]}),r.jsxs("div",{className:"s-atop-summary-cell s-atop-summary-cell--rate",children:[r.jsx("div",{className:"s-atop-summary-num",children:r.jsx("strong",{children:S.length})}),r.jsx("div",{className:"s-atop-summary-lbl",children:"visible"})]})]}),r.jsxs("div",{className:"s-atop-fbar",children:[r.jsxs("label",{className:"s-atop-search",children:[r.jsx("span",{className:"s-atop-search-prompt",children:"/"}),r.jsx("input",{ref:N,className:"s-atop-search-input",placeholder:"filter sessions",value:l,onChange:z=>c(z.target.value)}),r.jsx("kbd",{className:"s-atop-search-kbd",children:"/"})]}),r.jsx("span",{className:"s-atop-fbar-label",children:"source"}),r.jsxs("button",{type:"button",className:`s-atop-pill${d==="all"?" s-atop-pill--on":""}`,onClick:()=>h("all"),children:["all",r.jsx("span",{className:"s-atop-pill-ct",children:E.length})]}),A.map(z=>r.jsxs("button",{type:"button",className:`s-atop-pill${d===z?" s-atop-pill--on":""}`,onClick:()=>h(z),children:[z,r.jsx("span",{className:"s-atop-pill-ct",children:E.filter(O=>O.source===z).length})]},z)),r.jsx("div",{className:"s-atop-fbar-spacer"})]}),r.jsx("div",{className:"s-atop-table-wrap",children:r.jsxs("table",{className:"s-atop-table",children:[r.jsx("thead",{children:r.jsx("tr",{children:Ik.map(z=>r.jsxs("th",{className:z.cls,...R(z.key),children:[z.label,r.jsx("span",{...D(z.key)})]},z.key))})}),r.jsx("tbody",{children:y?r.jsx("tr",{className:"s-atop-empty-row",children:r.jsx("td",{colSpan:6,children:r.jsxs("div",{className:"s-atop-empty",children:[r.jsx("div",{className:"s-atop-empty-title",children:"Discovery failed"}),r.jsx("div",{children:y})]})})}):S.length===0?r.jsx("tr",{className:"s-atop-empty-row",children:r.jsx("td",{colSpan:6,children:r.jsxs("div",{className:"s-atop-empty",children:[r.jsx("div",{className:"s-atop-empty-title",children:"No raw sessions"}),r.jsx("div",{children:l?"No sessions match the current filter.":"No transcript sessions were discovered."})]})})}):S.map((z,O)=>r.jsxs("tr",{className:`s-atop-row${O===m?" s-atop-row--selected":""}`,tabIndex:0,onClick:()=>M(z),onMouseEnter:()=>p(O),children:[r.jsx("td",{className:"s-atop-col-status",children:r.jsxs("span",{className:`s-atop-status s-atop-status--${z.status}`,children:[r.jsx("span",{className:"s-atop-status-dot","aria-hidden":"true"}),z.statusLabel]})}),r.jsx("td",{className:"s-atop-col-agent",title:z.sessionId??z.refId,children:r.jsxs("div",{className:"s-atop-agent-cell",children:[r.jsx("span",{className:`s-atop-chip s-atop-chip--harness s-atop-chip--harness-${Pk(z.source)}`,children:z.source}),r.jsx("span",{className:"s-atop-agent-id",children:z.refId.slice(0,8)})]})}),r.jsx("td",{className:"s-atop-col-project",title:z.cwd??z.project,children:z.project}),r.jsx("td",{className:"s-atop-col-last",title:EX(z.mtimeMs),children:kX(Math.max(z.mtimeMs,z.lastEvent?.ts??0),w)}),r.jsx("td",{className:"s-atop-col-runtime",children:SX(z.size)}),r.jsx("td",{title:z.transcriptPath,children:z.cwd??z.transcriptPath})]},`${z.source}:${z.transcriptPath}`))})]})}),r.jsxs("div",{className:"s-atop-keys",children:[r.jsxs("span",{children:[r.jsx("kbd",{children:"/"}),"filter"]}),r.jsxs("span",{children:[r.jsx("kbd",{children:"j/k"}),"select"]}),r.jsxs("span",{children:[r.jsx("kbd",{children:"enter"}),"open"]}),r.jsx("span",{className:"s-atop-keys-spacer"}),r.jsxs("span",{className:"s-atop-keys-count",children:[r.jsx("strong",{children:S.length})," sessions"]})]})]})}function qd(e){const t=e?.trim()??"",n=t.split(/[\\/]/).filter(Boolean).at(-1)??t;return n.endsWith(".jsonl")?n.slice(0,-6):n}function RX({sessionRef:e,navigate:t}){const[n,s]=g.useState(null),[i,l]=g.useState(!0),[c,d]=g.useState(null),h=g.useRef(null),m=g.useCallback(async()=>{d(null);try{const p=await ke(`/api/session-ref/${encodeURIComponent(e)}`);s(p)}catch(p){s(null),d(p instanceof Error?p.message:String(p))}finally{l(!1)}},[e]);return g.useEffect(()=>{l(!0),m()},[m]),Kt(()=>{m()}),cu(p=>{const y=qd(p.sessionId),x=qd(e),w=n?.kind==="observe"?qd(n.observe.sessionId??n.observe.refId):"",j=n?.kind==="observe"?qd(n.observe.data.metadata?.session?.externalSessionId):"";y!==x&&(!w||y!==w)&&(!j||y!==j)||(h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{h.current=null,m()},150))}),g.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]),n?.kind==="conversation"?r.jsx(Ix,{conversationId:n.conversationId,navigate:t}):n?.kind==="observe"?r.jsx(Ox,{data:n.observe.data,agentId:n.observe.agentId??n.session?.agentId??void 0,sessionId:n.observe.sessionId??n.observe.refId}):i?r.jsx("div",{className:"s-sessions-screen s-inbox-thread-redesign",children:r.jsx("section",{className:"s-thread-overview",children:r.jsxs("div",{className:"s-thread-overview-copy",children:[r.jsxs("div",{className:"s-sessions-header s-thread-overview-heading",children:[r.jsx("h2",{className:"s-page-title",children:"Session"}),r.jsx("span",{className:"s-meta s-tabular",children:e.slice(0,8)})]}),r.jsxs("p",{className:"s-thread-overview-summary s-session-ref-loading",children:[r.jsx("span",{className:"s-session-ref-loading-dot"}),r.jsx("span",{className:"s-session-ref-loading-dot"}),r.jsx("span",{className:"s-session-ref-loading-dot"}),"Resolving session reference"]})]})})}):r.jsx("div",{className:"s-sessions-screen s-inbox-thread-redesign",children:r.jsx("section",{className:"s-thread-overview",children:r.jsxs("div",{className:"s-thread-overview-copy",children:[r.jsxs("div",{className:"s-sessions-header s-thread-overview-heading",children:[r.jsx("h2",{className:"s-page-title",children:"Session not found"}),r.jsx("span",{className:"s-meta s-tabular",children:e.slice(0,8)})]}),r.jsx("p",{className:"s-thread-overview-summary",children:"This session may have ended or the archive is not available on this machine."}),c&&r.jsx("p",{className:"s-session-ref-error-detail",children:c}),r.jsx("div",{className:"s-session-ref-nav-hint",children:r.jsx("button",{type:"button",className:"s-back",onClick:()=>t({view:"sessions"}),children:"← Back to sessions"})})]})})})}var pi=(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))(pi||{});const _X=[0,1],s2=[1,0],a2=[2,3],r2=[3,2],IX={L:_X,M:s2,Q:a2,H:r2},OX=/^\d*$/,DX=/^[A-Z0-9 $%*+./:-]*$/,Wg="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Px=1,zx=40,Lk=3,PX=3,Zd=40,zX=10,i2=[[-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]],o2=[[-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 LX{constructor(t,n,s,i){if(this.version=t,this.ecc=n,t<Px||t>zx)throw new RangeError("Version value out of range");if(i<-1||i>7)throw new RangeError("Mask value out of range");this.size=t*4+17;const l=Array.from({length:this.size}).fill(!1);for(let d=0;d<this.size;d++)this.modules.push(l.slice()),this.types.push(l.map(()=>0));this.drawFunctionPatterns();const c=this.addEccAndInterleave(s);if(this.drawCodewords(c),i===-1){let d=1e9;for(let h=0;h<8;h++){this.applyMask(h),this.drawFormatBits(h);const m=this.getPenaltyScore();m<d&&(i=h,d=m),this.applyMask(h)}}this.mask=i,this.applyMask(i),this.drawFormatBits(i)}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 s=0;s<this.size;s++)this.setFunctionModule(6,s,s%2===0,pi.Timing),this.setFunctionModule(s,6,s%2===0,pi.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 s=0;s<n;s++)for(let i=0;i<n;i++)s===0&&i===0||s===0&&i===n-1||s===n-1&&i===0||this.drawAlignmentPattern(t[s],t[i]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){const n=this.ecc[1]<<3|t;let s=n;for(let l=0;l<10;l++)s=s<<1^(s>>>9)*1335;const i=(n<<10|s)^21522;for(let l=0;l<=5;l++)this.setFunctionModule(8,l,Pa(i,l));this.setFunctionModule(8,7,Pa(i,6)),this.setFunctionModule(8,8,Pa(i,7)),this.setFunctionModule(7,8,Pa(i,8));for(let l=9;l<15;l++)this.setFunctionModule(14-l,8,Pa(i,l));for(let l=0;l<8;l++)this.setFunctionModule(this.size-1-l,8,Pa(i,l));for(let l=8;l<15;l++)this.setFunctionModule(8,this.size-15+l,Pa(i,l));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let s=0;s<12;s++)t=t<<1^(t>>>11)*7973;const n=this.version<<12|t;for(let s=0;s<18;s++){const i=Pa(n,s),l=this.size-11+s%3,c=Math.floor(s/3);this.setFunctionModule(l,c,i),this.setFunctionModule(c,l,i)}}drawFinderPattern(t,n){for(let s=-4;s<=4;s++)for(let i=-4;i<=4;i++){const l=Math.max(Math.abs(i),Math.abs(s)),c=t+i,d=n+s;c>=0&&c<this.size&&d>=0&&d<this.size&&this.setFunctionModule(c,d,l!==2&&l!==4,pi.Position)}}drawAlignmentPattern(t,n){for(let s=-2;s<=2;s++)for(let i=-2;i<=2;i++)this.setFunctionModule(t+i,n+s,Math.max(Math.abs(i),Math.abs(s))!==1,pi.Alignment)}setFunctionModule(t,n,s,i=pi.Function){this.modules[n][t]=s,this.types[n][t]=i}addEccAndInterleave(t){const n=this.version,s=this.ecc;if(t.length!==yf(n,s))throw new RangeError("Invalid argument");const i=o2[s[0]][n],l=i2[s[0]][n],c=Math.floor(cy(n)/8),d=i-c%i,h=Math.floor(c/i),m=[],p=WX(l);for(let x=0,w=0;x<i;x++){const j=t.slice(w,w+h-l+(x<d?0:1));w+=j.length;const N=YX(j,p);x<d&&j.push(0),m.push(j.concat(N))}const y=[];for(let x=0;x<m[0].length;x++)m.forEach((w,j)=>{(x!==h-l||j>=d)&&y.push(w[x])});return y}drawCodewords(t){if(t.length!==Math.floor(cy(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let s=this.size-1;s>=1;s-=2){s===6&&(s=5);for(let i=0;i<this.size;i++)for(let l=0;l<2;l++){const c=s-l,h=(s+1&2)===0?this.size-1-i:i;!this.types[h][c]&&n<t.length*8&&(this.modules[h][c]=Pa(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 s=0;s<this.size;s++){let i;switch(t){case 0:i=(s+n)%2===0;break;case 1:i=n%2===0;break;case 2:i=s%3===0;break;case 3:i=(s+n)%3===0;break;case 4:i=(Math.floor(s/3)+Math.floor(n/2))%2===0;break;case 5:i=s*n%2+s*n%3===0;break;case 6:i=(s*n%2+s*n%3)%2===0;break;case 7:i=((s+n)%2+s*n%3)%2===0;break;default:throw new Error("Unreachable")}!this.types[n][s]&&i&&(this.modules[n][s]=!this.modules[n][s])}}getPenaltyScore(){let t=0;for(let l=0;l<this.size;l++){let c=!1,d=0;const h=[0,0,0,0,0,0,0];for(let m=0;m<this.size;m++)this.modules[l][m]===c?(d++,d===5?t+=Lk:d>5&&t++):(this.finderPenaltyAddHistory(d,h),c||(t+=this.finderPenaltyCountPatterns(h)*Zd),c=this.modules[l][m],d=1);t+=this.finderPenaltyTerminateAndCount(c,d,h)*Zd}for(let l=0;l<this.size;l++){let c=!1,d=0;const h=[0,0,0,0,0,0,0];for(let m=0;m<this.size;m++)this.modules[m][l]===c?(d++,d===5?t+=Lk:d>5&&t++):(this.finderPenaltyAddHistory(d,h),c||(t+=this.finderPenaltyCountPatterns(h)*Zd),c=this.modules[m][l],d=1);t+=this.finderPenaltyTerminateAndCount(c,d,h)*Zd}for(let l=0;l<this.size-1;l++)for(let c=0;c<this.size-1;c++){const d=this.modules[l][c];d===this.modules[l][c+1]&&d===this.modules[l+1][c]&&d===this.modules[l+1][c+1]&&(t+=PX)}let n=0;for(const l of this.modules)n=l.reduce((c,d)=>c+(d?1:0),n);const s=this.size*this.size,i=Math.ceil(Math.abs(n*20-s*10)/s)-1;return t+=i*zX,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,s=[6];for(let i=this.size-7;s.length<t;i-=n)s.splice(1,0,i);return s}}finderPenaltyCountPatterns(t){const n=t[1],s=n>0&&t[2]===n&&t[3]===n*3&&t[4]===n&&t[5]===n;return(s&&t[0]>=n*4&&t[6]>=n?1:0)+(s&&t[6]>=n*4&&t[0]>=n?1:0)}finderPenaltyTerminateAndCount(t,n,s){return t&&(this.finderPenaltyAddHistory(n,s),n=0),n+=this.size,this.finderPenaltyAddHistory(n,s),this.finderPenaltyCountPatterns(s)}finderPenaltyAddHistory(t,n){n[0]===0&&(t+=this.size),n.pop(),n.unshift(t)}}function Ua(e,t,n){if(t<0||t>31||e>>>t)throw new RangeError("Value out of range");for(let s=t-1;s>=0;s--)n.push(e>>>s&1)}function Pa(e,t){return(e>>>t&1)!==0}class Lx{constructor(t,n,s){if(this.mode=t,this.numChars=n,this.bitData=s,n<0)throw new RangeError("Invalid argument");this.bitData=s.slice()}getData(){return this.bitData.slice()}}const $X=[1,10,12,14],UX=[2,9,11,13],BX=[4,8,16,16];function l2(e,t){return e[Math.floor((t+7)/17)+1]}function c2(e){const t=[];for(const n of e)Ua(n,8,t);return new Lx(BX,e.length,t)}function VX(e){if(!u2(e))throw new RangeError("String contains non-numeric characters");const t=[];for(let n=0;n<e.length;){const s=Math.min(e.length-n,3);Ua(Number.parseInt(e.substring(n,n+s),10),s*3+1,t),n+=s}return new Lx($X,e.length,t)}function FX(e){if(!d2(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 s=Wg.indexOf(e.charAt(n))*45;s+=Wg.indexOf(e.charAt(n+1)),Ua(s,11,t)}return n<e.length&&Ua(Wg.indexOf(e.charAt(n)),6,t),new Lx(UX,e.length,t)}function HX(e){return e===""?[]:u2(e)?[VX(e)]:d2(e)?[FX(e)]:[c2(ZX(e))]}function u2(e){return OX.test(e)}function d2(e){return DX.test(e)}function qX(e,t){let n=0;for(const s of e){const i=l2(s.mode,t);if(s.numChars>=1<<i)return Number.POSITIVE_INFINITY;n+=4+i+s.bitData.length}return n}function ZX(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 cy(e){if(e<Px||e>zx)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 yf(e,t){return Math.floor(cy(e)/8)-i2[t[0]][e]*o2[t[0]][e]}function WX(e){if(e<1||e>255)throw new RangeError("Degree out of range");const t=[];for(let s=0;s<e-1;s++)t.push(0);t.push(1);let n=1;for(let s=0;s<e;s++){for(let i=0;i<t.length;i++)t[i]=uy(t[i],n),i+1<t.length&&(t[i]^=t[i+1]);n=uy(n,2)}return t}function YX(e,t){const n=t.map(s=>0);for(const s of e){const i=s^n.shift();n.push(0),t.forEach((l,c)=>n[c]^=uy(l,i))}return n}function uy(e,t){if(e>>>8||t>>>8)throw new RangeError("Byte out of range");let n=0;for(let s=7;s>=0;s--)n=n<<1^(n>>>7)*285,n^=(t>>>s&1)*e;return n}function GX(e,t,n=1,s=40,i=-1,l=!0){if(!(Px<=n&&n<=s&&s<=zx)||i<-1||i>7)throw new RangeError("Invalid value");let c,d;for(c=n;;c++){const y=yf(c,t)*8,x=qX(e,c);if(x<=y){d=x;break}if(c>=s)throw new RangeError("Data too long")}for(const y of[s2,a2,r2])l&&d<=yf(c,y)*8&&(t=y);const h=[];for(const y of e){Ua(y.mode[0],4,h),Ua(y.numChars,l2(y.mode,c),h);for(const x of y.getData())h.push(x)}const m=yf(c,t)*8;Ua(0,Math.min(4,m-h.length),h),Ua(0,(8-h.length%8)%8,h);for(let y=236;h.length<m;y^=253)Ua(y,8,h);const p=Array.from({length:Math.ceil(h.length/8)},()=>0);return h.forEach((y,x)=>p[x>>>3]|=y<<7-(x&7)),new LX(c,t,p,i)}function KX(e,t){const{ecc:n="L",boostEcc:s=!1,minVersion:i=1,maxVersion:l=40,maskPattern:c=-1,border:d=1}=t||{},h=typeof e=="string"?HX(e):Array.isArray(e)?[c2(e)]:void 0;if(!h)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);const m=GX(h,IX[n],i,l,c,s),p=XX({version:m.version,maskPattern:m.mask,size:m.size,data:m.modules,types:m.types},d);return t?.invert&&(p.data=p.data.map(y=>y.map(x=>!x))),t?.onEncoded?.(p),p}function XX(e,t=1){if(!t)return e;const{size:n}=e,s=n+t*2;e.size=s,e.data.forEach(l=>{for(let c=0;c<t;c++)l.unshift(!1),l.push(!1)});for(let l=0;l<t;l++)e.data.unshift(Array.from({length:s},c=>!1)),e.data.push(Array.from({length:s},c=>!1));const i=pi.Border;e.types.forEach(l=>{for(let c=0;c<t;c++)l.unshift(i),l.push(i)});for(let l=0;l<t;l++)e.types.unshift(Array.from({length:s},c=>i)),e.types.push(Array.from({length:s},c=>i));return e}function $k(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function JX(e,t={}){const n=KX(e,t),{pixelSize:s=10,whiteColor:i="white",blackColor:l="black"}=t,c=n.size*s,d=n.size*s;let h=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${d} ${c}">`;const m=[];for(let p=0;p<n.size;p++)for(let y=0;y<n.size;y++){const x=y*s,w=p*s;n.data[p][y]&&m.push(`M${x},${w}h${s}v${s}h-${s}z`)}return h+=`<rect fill="${$k(i)}" width="${d}" height="${c}"/>`,h+=`<path fill="${$k(l)}" d="${m.join("")}"/>`,h+="</svg>",h}function QX(e){return e?e.replace(/^wss?:\/\//,"").replace(/:\d+$/,""):null}function Uk(e){return e?e.length<=18?e:`${e.slice(0,10)}...${e.slice(-6)}`:null}function eJ(e){return e?e.status==="paired"||e.status==="connected"?"success":e.status==="error"||e.status==="closed"?"danger":"warning":"warning"}function tJ(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 s=Math.floor(n/60),i=n%60;return i>0?`${s}m ${i}s`:`${s}m`}function Bk({value:e}){const[t,n]=g.useState(!1),s=g.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})},[e]);return r.jsx("button",{type:"button",className:"sys-copy-btn",onClick:s,title:"Copy",children:t?r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}):r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),r.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})}function nJ({navigate:e}){const[t,n]=g.useState(null),[s,i]=g.useState(""),[l,c]=g.useState(""),[d,h]=g.useState(!0),[m,p]=g.useState(!1),[y,x]=g.useState(!1),[w,j]=g.useState(null),[N,k]=g.useState(null),[E,A]=g.useState(null),[S,M]=g.useState(null),[C,I]=g.useState(()=>Date.now()),[R,D]=g.useState(null),z=g.useRef(null),O=g.useRef(0),_=g.useRef(null);g.useEffect(()=>{z.current=t},[t]),g.useEffect(()=>{_.current=w},[w]);const U=g.useCallback(async(ee="initial")=>{if(ee==="background"&&_.current)return;const ie=++O.current;!(z.current!==null)&&ee!=="background"?(h(!0),k(null)):p(!0);try{const xe=await ke(ee==="manual"?"/api/pairing-state/refresh":"/api/pairing-state");if(ie!==O.current)return;n(xe),k(null),M(Date.now())}catch(xe){if(ie!==O.current)return;k(xe instanceof Error?xe.message:String(xe))}finally{ie===O.current&&(h(!1),p(!1))}},[]),q=g.useCallback(async()=>{try{const ee=await ke("/api/user");c(ee.name),i(ee.name),A(null)}catch(ee){A(ee instanceof Error?ee.message:String(ee))}},[]),G=g.useRef(!1);g.useEffect(()=>{U("initial"),q()},[U,q]),g.useEffect(()=>{const ee=setInterval(()=>{U("background")},1e4);return()=>clearInterval(ee)},[U]),g.useEffect(()=>{if(!t?.pairing?.expiresAt)return;I(Date.now());const ee=setInterval(()=>{I(Date.now())},1e3);return()=>clearInterval(ee)},[t?.pairing?.expiresAt]);const X=g.useCallback(async()=>{x(!0),A(null);try{const ee=await ke("/api/user",{method:"POST",body:JSON.stringify({name:s})});c(ee.name),i(ee.name)}catch(ee){A(ee instanceof Error?ee.message:String(ee))}finally{x(!1)}},[s]),L=g.useCallback(async ee=>{const ie=++O.current;j(ee),k(null);try{const de=await ke("/api/pairing/control",{method:"POST",body:JSON.stringify({action:ee})});if(ie!==O.current)return;n(de),M(Date.now())}catch(de){if(ie!==O.current)return;k(de instanceof Error?de.message:String(de))}finally{ie===O.current&&j(null)}},[]);g.useEffect(()=>{!t||t.isRunning||G.current||(G.current=!0,L("start"))},[t,L]);const F=g.useCallback(async ee=>{D(ee);try{await ke(`/api/pairing/peers/${encodeURIComponent(ee)}`,{method:"DELETE"}),U("manual")}catch{}finally{D(null)}},[U]),H=g.useMemo(()=>{const ee=t?.pairing?.qrValue?.trim();return ee?JX(ee,{border:2,ecc:"M",pixelSize:8}):null},[t?.pairing?.qrValue]),V=QX(t?.pairing?.relay??t?.relay??null),W=tJ(t?.pairing?.expiresAt,C),B=(t?.trustedPeers.find(ee=>ee.fingerprint===t.connectedPeerFingerprint)??null)?.name??Uk(t?.connectedPeerFingerprint??null),Y=eJ(t),te=s.trim()!==l,ae=!d&&!t&&!!N;return r.jsxs("div",{className:"sys-surface-page sys-settings-page",children:[r.jsxs("div",{className:"sys-page-head",children:[r.jsxs("div",{className:"sys-page-title-group",children:[r.jsx("h2",{className:"sys-page-title",children:"Settings"}),r.jsx("p",{className:"sys-page-subtitle",children:"Identity, pairing, and trusted devices."})]}),r.jsxs("div",{className:"sys-page-actions",children:[t&&r.jsx("span",{className:`sys-chip sys-chip-${Y}`,children:t.statusLabel}),r.jsx("div",{className:"sys-sync-note",children:d?"Loading...":N&&t?`Snapshot from ${S?De(S):"earlier"}`:S?`Updated ${De(S)}`:""}),r.jsx("button",{type:"button",className:"s-btn",disabled:d||m||!!w,onClick:()=>{U("manual")},children:m?"Refreshing...":"Refresh"})]})]}),N&&t&&r.jsxs("div",{className:"sys-banner sys-banner-warning",children:[r.jsx("strong",{children:"Refresh failed."}),r.jsx("span",{children:N})]}),E&&r.jsxs("div",{className:"sys-banner sys-banner-warning",children:[r.jsx("strong",{children:"Identity error."}),r.jsx("span",{children:E})]}),d&&!t&&r.jsxs("div",{className:"sys-panel sys-state-card",children:[r.jsx("h3",{className:"sys-state-title",children:"Loading settings"}),r.jsx("p",{className:"sys-state-body",children:"Checking relay status and trusted peers."})]}),ae&&r.jsxs("div",{className:"sys-panel sys-state-card sys-state-card-error",children:[r.jsx("h3",{className:"sys-state-title",children:"Pairing unavailable"}),r.jsx("p",{className:"sys-state-body",children:N}),r.jsx("div",{className:"sys-inline-actions",children:r.jsx("button",{type:"button",className:"s-btn",onClick:()=>{U("manual")},children:"Try again"})})]}),r.jsxs("div",{className:"sys-settings-hero",children:[r.jsx("div",{className:"sys-settings-qr-col",children:H?r.jsxs("div",{className:"sys-settings-qr-frame",children:[r.jsx("div",{className:"s-qr",dangerouslySetInnerHTML:{__html:H}}),W&&r.jsxs("span",{className:"sys-settings-qr-expires",children:["Expires in ",W]})]}):r.jsx("div",{className:"sys-settings-qr-empty",children:r.jsx("span",{className:"sys-settings-qr-empty-label",children:"Generating QR..."})})}),r.jsxs("div",{className:"sys-settings-info-col",children:[r.jsxs("div",{className:"sys-input-row",children:[r.jsx("input",{className:"sys-input",type:"text",placeholder:"Your name",value:s,onChange:ee=>i(ee.target.value),onKeyDown:ee=>{ee.key==="Enter"&&te&&!y&&X()}}),r.jsx("button",{type:"button",className:"s-btn s-btn-primary",disabled:!te||y,onClick:()=>{X()},children:y?"Saving...":"Save"})]}),r.jsxs("div",{className:"sys-settings-kv-list",children:[t?.identityFingerprint&&r.jsxs("div",{className:"sys-settings-kv",children:[r.jsx("span",{className:"sys-settings-kv-label",children:"Fingerprint"}),r.jsxs("span",{className:"sys-settings-kv-value",children:[r.jsx("code",{children:t.identityFingerprint}),r.jsx(Bk,{value:t.identityFingerprint})]})]}),V&&r.jsxs("div",{className:"sys-settings-kv",children:[r.jsx("span",{className:"sys-settings-kv-label",children:"Relay"}),r.jsxs("span",{className:"sys-settings-kv-value",children:[r.jsx("code",{children:V}),r.jsx(Bk,{value:V})]})]}),t?.statusDetail&&r.jsxs("div",{className:"sys-settings-kv",children:[r.jsx("span",{className:"sys-settings-kv-label",children:"Status"}),r.jsx("span",{className:"sys-settings-kv-value sys-settings-kv-nowrap",children:t.statusDetail})]}),B&&r.jsxs("div",{className:"sys-settings-kv",children:[r.jsx("span",{className:"sys-settings-kv-label",children:"Connected"}),r.jsx("span",{className:"sys-settings-kv-value",children:B})]}),t?.secure&&r.jsxs("div",{className:"sys-settings-kv",children:[r.jsx("span",{className:"sys-settings-kv-label",children:"Security"}),r.jsx("span",{className:"sys-settings-kv-value",children:r.jsx("span",{className:"sys-chip sys-chip-success",children:"Noise XX"})})]})]}),t&&r.jsx("div",{className:"sys-inline-actions sys-settings-controls",children:t.isRunning?r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:"s-btn",disabled:!!w,onClick:()=>{L("restart")},children:w==="restart"?"Restarting...":"Restart"}),r.jsx("button",{type:"button",className:"s-btn",disabled:!!w,onClick:()=>{L("stop")},children:w==="stop"?"Stopping...":"Stop"})]}):r.jsx("button",{type:"button",className:"s-btn s-btn-primary",disabled:!!w,onClick:()=>{L("start")},children:w==="start"?"Starting...":"Start pairing"})})]})]}),t&&r.jsxs("section",{className:"sys-settings-peers",children:[r.jsx("div",{className:"sys-section-head",children:r.jsxs("div",{children:[r.jsx("h3",{className:"sys-section-title",children:"Trusted peers"}),r.jsxs("p",{className:"sys-section-subtitle",children:[t.trustedPeers.length," device",t.trustedPeers.length!==1?"s":""," paired with this broker."]})]})}),t.trustedPeers.length===0?r.jsxs("div",{className:"sys-list-empty",children:[r.jsx("h3",{children:"No trusted peers"}),r.jsx("p",{children:"Devices appear here after completing pairing."})]}):r.jsxs("table",{className:"sys-peers-table",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Device"}),r.jsx("th",{children:"Fingerprint"}),r.jsx("th",{children:"Paired"}),r.jsx("th",{children:"Last seen"}),r.jsx("th",{})]})}),r.jsx("tbody",{children:t.trustedPeers.map(ee=>{const ie=ee.fingerprint===t.connectedPeerFingerprint;return r.jsxs("tr",{className:ie?"sys-peers-row-connected":"",children:[r.jsx("td",{children:r.jsxs("span",{className:"sys-peers-name",children:[ee.name??Uk(ee.fingerprint)??"Peer",ie&&r.jsx("span",{className:"sys-chip sys-chip-success sys-peers-badge",children:"Connected"})]})}),r.jsx("td",{children:r.jsx("code",{className:"sys-peers-fp",children:ee.fingerprint})}),r.jsx("td",{children:ee.pairedAtLabel??"—"}),r.jsx("td",{children:ee.lastSeenLabel??"—"}),r.jsx("td",{children:r.jsx("button",{type:"button",className:"sys-peers-remove",disabled:R===ee.fingerprint,onClick:()=>{F(ee.fingerprint)},title:"Remove peer",children:R===ee.fingerprint?"...":"Remove"})})]},ee.fingerprint)})})]})]})]})}const sJ=2500,aJ=1e4;function f2(e){const[t,n]=g.useState({}),s=g.useRef(!0),i=g.useRef(!1),l=g.useRef(!1),c=e.map(m=>m.id.trim()).filter(m=>m.length>0).join(","),d=e.some(m=>Xe(m.state)==="working")?sJ:aJ,h=g.useCallback(async()=>{if(e.length===0){n({});return}if(i.current){l.current=!0;return}i.current=!0;try{const m=c?`?ids=${encodeURIComponent(c)}`:"",p=await ke(`/api/observe/agents${m}`);if(!s.current)return;n(y=>{const x={};for(const w of e)x[w.id]=y[w.id];for(const w of p){const{agentId:j,...N}=w;x[j]=N}return x})}finally{i.current=!1,l.current&&(l.current=!1,h())}},[c,e]);return g.useEffect(()=>{if(s.current=!0,e.length===0)return n({}),()=>{s.current=!1};h();const m=setInterval(()=>{h()},d);return()=>{s.current=!1,clearInterval(m)}},[e.length,h,d]),t}function br(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 bc=340,Jf=220,ko=16,rJ=48,iJ=36,Vk=28,Wd=40,h2=180,m2=140;function oJ(e){const t=lJ(e);if(t.length===0)return{groups:[],canvasW:0,canvasH:0};const n=Math.max(1,Math.round(Math.sqrt(t.length*1.4))),s=[],i=new Array(n).fill(Wd),l=Array.from({length:n},(h,m)=>Wd+m*(bc*2+ko+rJ));for(const h of t){const m=i.indexOf(Math.min(...i)),p=l[m],y=i[m],x=Math.min(2,h.agents.length),w=Math.ceil(h.agents.length/x),j=x*bc+(x-1)*ko,N=Vk+w*Jf+(w-1)*ko,k=h.agents.map((E,A)=>{const S=A%x,M=Math.floor(A/x);return{agentId:E.id,x:p+S*(bc+ko),y:y+Vk+M*(Jf+ko)}});s.push({label:h.label,x:p,y,w:j,h:N,tiles:k}),i[m]=y+N+iJ}const c=Math.max(...l.map((h,m)=>h+bc*2+ko))+Wd,d=Math.max(...i)+Wd;return{groups:s,canvasW:c,canvasH:d}}function lJ(e){const t={working:0,available:1,offline:2},n=[...e].sort((l,c)=>{const d=t[Xe(l.state)]??1,h=t[Xe(c.state)]??1;return d!==h?d-h:l.name.localeCompare(c.name)}),s=new Map;for(const l of n){const c=l.project??"unassigned";s.has(c)||s.set(c,[]),s.get(c).push(l)}const i=[];for(const[l,c]of s)i.push({label:l,agents:c});return i.sort((l,c)=>c.agents.length-l.agents.length),i}function cJ(e){switch(e.kind){case"tool":return`$ ${br(e)}`;case"think":return`~ ${br(e)}`;case"ask":return`↗ ${br(e)}`;case"message":return`→ ${br(e)}`;case"note":return`+ ${br(e)}`;case"system":case"boot":return`▸ ${br(e)}`}}function p2(e,t,n){const s=n?.events.slice(-8).map(cJ).filter(Boolean)??[];return s.length>0?s:Xe(e.state)==="offline"?["No session trace available"]:["Waiting for session trace…",...t?[`task: ${t}`]:[]]}function uJ(e){switch(Xe(e)){case"working":return"var(--green)";case"available":return"var(--accent)";default:return"var(--dim)"}}function dJ({color:e,data:t}){const n=t??[];if(n.length<2)return r.jsx("div",{style:{width:80,height:16,display:"flex",alignItems:"center",color:"var(--dim)",fontSize:10,letterSpacing:"0.08em",textTransform:"uppercase"},children:"No ctx"});const s=n.map((i,l)=>`${l/(n.length-1)*100},${20-i*18-1}`).join(" ");return r.jsx("svg",{viewBox:"0 0 100 20",preserveAspectRatio:"none",style:{width:80,height:16},children:r.jsx("polyline",{points:s,fill:"none",stroke:e,strokeWidth:"1"})})}function fJ({navigate:e,agents:t}){const[n,s]=g.useState(null),[i,l]=g.useState(null),c=f2(t),d=g.useCallback(async O=>{await ke(`/api/agents/${encodeURIComponent(O)}/interrupt`,{method:"POST",body:JSON.stringify({})})},[]),h=g.useRef(null),[m,p]=g.useState({w:0,h:0}),[y,x]=g.useState({x:0,y:0}),[w,j]=g.useState(1),N=g.useRef(!1),k=g.useRef({x:0,y:0,panX:0,panY:0});g.useEffect(()=>{const O=h.current;if(!O)return;const _=new ResizeObserver(([U])=>{const{width:q,height:G}=U.contentRect;p({w:q,h:G})});return _.observe(O),()=>_.disconnect()},[]);const E=g.useCallback(async()=>{try{l(await ke("/api/fleet"))}catch{}},[]);g.useEffect(()=>{E()},[E]),Kt(()=>{E()});const A=g.useMemo(()=>{const O={};for(const _ of i?.activeAsks??[])O[_.agentId]={agentId:_.agentId,task:_.task,summary:_.summary??null};return O},[i]),S=g.useMemo(()=>oJ(t),[t]);g.useEffect(()=>{if(S.canvasW===0||m.w===0)return;const O=Math.min(1,m.w/S.canvasW,m.h/S.canvasH),_=Math.max(.15,Math.min(1,O*.92));x({x:(m.w-S.canvasW*_)/2,y:Math.max(8,(m.h-S.canvasH*_)/2)}),j(_)},[S,m]);const M=g.useCallback(O=>{O.target.closest(".s-conductor-tile")||(N.current=!0,k.current={x:O.clientX,y:O.clientY,panX:y.x,panY:y.y})},[y]),C=g.useCallback(O=>{N.current&&x({x:k.current.panX+(O.clientX-k.current.x),y:k.current.panY+(O.clientY-k.current.y)})},[]),I=g.useCallback(()=>{N.current=!1},[]);g.useEffect(()=>{const O=h.current;if(!O)return;const _=U=>{U.preventDefault();const q=O.getBoundingClientRect(),G=U.clientX-q.left,X=U.clientY-q.top,L=U.deltaY>0?.92:1.08,F=Math.max(.2,Math.min(2,w*L)),H=F/w;x(V=>({x:G-(G-V.x)*H,y:X-(X-V.y)*H})),j(F)};return O.addEventListener("wheel",_,{passive:!1}),()=>O.removeEventListener("wheel",_)},[w]);const R=n?t.find(O=>O.id===n):null;g.useEffect(()=>{if(!R)return;const O=_=>{_.key==="Escape"&&s(null)};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[R]);const D=g.useCallback(O=>{const _=h.current;if(!_)return;const U=O.currentTarget.getBoundingClientRect(),q=O.clientX-U.left,G=O.clientY-U.top,X=Math.min(h2/S.canvasW,m2/S.canvasH),L=q/X,F=G/X,H=_.clientWidth,V=_.clientHeight;x({x:H/2-L*w,y:V/2-F*w})},[S,w]),z=g.useMemo(()=>{const O={};for(const _ of S.groups)for(const U of _.tiles)O[U.agentId]={x:U.x,y:U.y};return O},[S]);return r.jsxs("div",{className:"s-conductor",children:[r.jsxs("div",{className:"s-conductor-bar",children:[r.jsxs("span",{className:"s-conductor-bar-label",children:[t.length," agent",t.length!==1?"s":""," ·"," ",S.groups.length," workspace",S.groups.length!==1?"s":""]}),r.jsxs("div",{className:"s-conductor-hotkeys",children:[r.jsxs("span",{className:"s-conductor-hotkey",children:[r.jsx("kbd",{children:"F"})," Freeze all"]}),r.jsxs("span",{className:"s-conductor-hotkey",children:[r.jsx("kbd",{children:"B"})," Broadcast"]}),r.jsxs("span",{className:"s-conductor-hotkey",children:[r.jsx("kbd",{children:"R"})," Route ask"]})]})]}),r.jsxs("div",{ref:h,className:"s-conductor-viewport",onMouseDown:M,onMouseMove:C,onMouseUp:I,onMouseLeave:I,children:[r.jsxs("div",{className:"s-conductor-canvas",style:{transform:`translate(${y.x}px, ${y.y}px) scale(${w})`},children:[S.groups.map(O=>r.jsx("div",{className:"s-conductor-group-label",style:{left:O.x,top:O.y},children:O.label},O.label)),t.map(O=>{const _=z[O.id];return _?r.jsx(pJ,{agent:O,task:A[O.id]??null,observe:c[O.id]?.data??null,x:_.x,y:_.y,onClick:()=>s(O.id)},O.id):null})]}),r.jsx(hJ,{layout:S,agents:t,pan:y,zoom:w,viewportRef:h,onClick:D})]}),R&&r.jsx(mJ,{agent:R,task:A[R.id]??null,observe:c[R.id]?.data??null,onClose:()=>s(null),onTell:()=>{s(null),e({view:"conversation",conversationId:Nn(R.id),composeMode:"tell"})},onAsk:()=>{s(null),e({view:"conversation",conversationId:Nn(R.id),composeMode:"ask"})},onFreeze:Xe(R.state)==="working"?()=>{s(null),d(R.id)}:void 0,onOpenProfile:()=>{s(null),e({view:"agents",agentId:R.id})}})]})}function hJ({layout:e,agents:t,pan:n,zoom:s,viewportRef:i,onClick:l}){if(e.canvasW===0||t.length===0)return null;const c=Math.min(h2/e.canvasW,m2/e.canvasH),d=e.canvasW*c,h=e.canvasH*c,m=i.current,p=m?.clientWidth??0,y=m?.clientHeight??0,x=-n.x/s*c,w=-n.y/s*c,j=p/s*c,N=y/s*c;return r.jsxs("div",{className:"s-conductor-minimap",style:{width:d,height:h,opacity:.85},onClick:l,children:[e.groups.map(k=>r.jsx("div",{className:"s-conductor-minimap-group",style:{left:k.x*c,top:k.y*c},children:k.label},k.label)),e.groups.flatMap(k=>k.tiles.map(E=>{const A=t.find(S=>S.id===E.agentId);return r.jsx("div",{className:"s-conductor-minimap-tile",style:{left:E.x*c,top:E.y*c,width:bc*c,height:Jf*c,background:A?gt(A.name):"var(--dim)",opacity:A&&Xe(A.state)==="working"?.8:.35}},E.agentId)})),r.jsx("div",{className:"s-conductor-minimap-viewport",style:{left:Math.max(0,x),top:Math.max(0,w),width:Math.min(j,d),height:Math.min(N,h)}})]})}function mJ({agent:e,task:t,observe:n,onClose:s,onTell:i,onAsk:l,onFreeze:c,onOpenProfile:d}){const h=p2(e,t?.summary??null,n);return r.jsx("div",{className:"s-conductor-overlay",onClick:s,children:r.jsxs("div",{className:"s-conductor-overlay-panel",onClick:m=>m.stopPropagation(),children:[r.jsxs("div",{className:"s-conductor-overlay-header",children:[r.jsx("div",{className:"s-ops-avatar",style:{"--size":"32px",background:gt(e.name)},children:e.name[0]?.toUpperCase()}),r.jsxs("div",{children:[r.jsxs("div",{style:{fontSize:16,fontWeight:500},children:[e.name," ",r.jsx("span",{style:{color:"var(--dim)",fontSize:12},children:e.handle?`@${e.handle}`:""})]}),r.jsxs("div",{className:"s-conductor-tile-meta",children:[e.project??"—"," · ",e.branch??"main"]})]}),r.jsx("span",{style:{flex:1}}),r.jsx("button",{className:"s-ops-btn",onClick:s,children:"ESC"})]}),r.jsxs("div",{className:"s-conductor-overlay-body",children:[r.jsx("div",{className:"s-conductor-overlay-task",children:t?.task??"No active task"}),r.jsxs("div",{className:"s-conductor-overlay-detail",children:["› ",t?.summary??Hn(e.state)]}),r.jsxs("div",{className:"s-conductor-terminal",style:{height:"auto",minHeight:160},children:[h.map((m,p)=>r.jsx("div",{className:`s-conductor-terminal-line${m.startsWith("$")?" s-conductor-terminal-line--cmd":""}${m.startsWith("→")||m.startsWith("+")?" s-conductor-terminal-line--result":""}`,children:m},p)),Xe(e.state)==="working"&&r.jsx("span",{className:"s-conductor-terminal-cursor"})]})]}),r.jsxs("div",{className:"s-conductor-overlay-footer",children:[r.jsx("button",{className:"s-ops-btn s-ops-btn--primary",onClick:i,children:"Send instruction"}),r.jsx("button",{className:"s-ops-btn",onClick:c,disabled:!c,children:"Freeze"}),r.jsx("button",{className:"s-ops-btn",onClick:l,children:"Route ask"}),r.jsx("span",{style:{flex:1}}),r.jsx("button",{className:"s-ops-btn",onClick:d,children:"Open profile ↗"})]})]})})}function pJ({agent:e,task:t,observe:n,x:s,y:i,onClick:l}){const c=gt(e.name),d=uJ(e.state),h=Hn(e.state).toUpperCase(),m=p2(e,t?.summary??null,n),p=Xe(e.state)==="working",y=n?.events[n.events.length-1],x=y?br(y):t?.summary??Hn(e.state);return r.jsxs("div",{className:"s-conductor-tile",style:{left:s,top:i,height:Jf},onClick:w=>{w.stopPropagation(),l()},children:[r.jsxs("div",{className:"s-conductor-tile-identity",children:[r.jsx("div",{className:"s-ops-avatar",style:{"--size":"24px",background:c},children:e.name[0]?.toUpperCase()}),r.jsxs("div",{className:"s-conductor-tile-identity-copy",children:[r.jsxs("div",{className:"s-conductor-tile-name",children:[e.name,r.jsx("span",{className:"s-conductor-tile-handle",children:e.handle?`@${e.handle}`:""})]}),r.jsxs("div",{className:"s-conductor-tile-meta",children:[e.project??"—"," · ",e.branch??"main"]})]}),r.jsx("span",{className:"s-ops-state-chip",style:{color:d},children:h})]}),r.jsx("div",{className:"s-conductor-tile-task",children:t?.task??"No active task"}),r.jsxs("div",{className:"s-conductor-terminal",children:[m.slice(-4).map((w,j)=>r.jsx("div",{className:`s-conductor-terminal-line${w.startsWith("$")?" s-conductor-terminal-line--cmd":""}${w.startsWith("→")||w.startsWith("+")?" s-conductor-terminal-line--result":""}`,style:{opacity:(j+1)/Math.min(4,m.length)},children:w},j)),p&&r.jsx("span",{className:"s-conductor-terminal-cursor"})]}),r.jsxs("div",{className:"s-conductor-tile-footer",children:[r.jsx(dJ,{color:c,data:n?.contextUsage}),r.jsx("span",{className:"s-conductor-tile-detail",children:x}),p&&r.jsx("span",{className:"s-conductor-terminal-cursor"})]})]})}const wc=420,Qf=320,Eo=20,gJ=48,vJ=36,Fk=28,Yd=40,yJ=244,xJ=160,g2=2*6e4,Hk=[{label:"15m",value:15*6e4},{label:"1h",value:60*6e4},{label:"24h",value:1440*6e4}],v2="scout_mc_vp";function bJ(e){try{localStorage.setItem(v2,JSON.stringify(e))}catch{}}function wJ(){try{const e=localStorage.getItem(v2);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 jJ(e){const t=NJ(e);if(t.length===0)return{groups:[],canvasW:0,canvasH:0};const n=Math.max(1,Math.round(Math.sqrt(t.length*1.2))),s=[],i=new Array(n).fill(Yd),l=Array.from({length:n},(h,m)=>Yd+m*(wc*2+Eo+gJ));for(const h of t){const m=i.indexOf(Math.min(...i)),p=l[m],y=i[m],x=Math.min(2,h.subjects.length),w=Math.ceil(h.subjects.length/x),j=x*wc+(x-1)*Eo,N=Fk+w*Qf+(w-1)*Eo,k=h.subjects.map((E,A)=>({agentId:E.id,x:p+A%x*(wc+Eo),y:y+Fk+Math.floor(A/x)*(Qf+Eo)}));s.push({label:h.label,x:p,y,w:j,h:N,tiles:k}),i[m]=y+N+vJ}const c=Math.max(...l.map(h=>h+wc*2+Eo))+Yd,d=Math.max(...i)+Yd;return{groups:s,canvasW:c,canvasH:d}}function NJ(e){const t=[...e].sort((i,l)=>i.stateRank!==l.stateRank?i.stateRank-l.stateRank:i.name.localeCompare(l.name)),n=new Map;for(const i of t)n.has(i.group)||n.set(i.group,[]),n.get(i.group).push(i);const s=[];for(const[i,l]of n)s.push({label:i,subjects:l});return s.sort((i,l)=>l.subjects.length-i.subjects.length),s}function SJ(e){const t={working:0,available:1,offline:2},n=Xe(e.state);return{id:e.id,name:e.name,group:e.project??"unassigned",stateRank:t[n]??1}}function kJ(e){return{id:e.id,name:e.agent.name,group:`native ${e.transcript.source}`,stateRank:e.current?0:1}}function EJ(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 CJ(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 AJ(e,t,n){return Math.max(n.get(e.id)??0,t?.updatedAt??0,Xe(e.state)==="working"?e.updatedAt??0:0)}function TJ(e,t,n,s){return Xe(e.state)==="working"||t?.data.live===!0||n>0&&s-n<=g2}function MJ(e){return e?e.replace(/\.jsonl$/u,"").slice(0,8):"session"}function RJ(e){return e?`${e[0]?.toUpperCase()}${e.slice(1)}`:"Native"}function _J(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 eh(e){const t=e.sessionId?.trim()||"session";return`native:${e.source}:${t}:${_J(e.transcriptPath)}`}function IJ(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"}}function OJ(e,t,n){const s=t.slice(-12),i=s.map((l,c)=>({id:l.id,t:c,kind:IJ(l.kind),text:l.summary,tool:l.kind==="tool"||l.kind==="tool-result"?l.source:void 0,detail:`${l.source} · ${l.harness}`,live:n&&c===s.length-1}));return{events:i.length>0?i:[{id:`${eh(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 DJ(e,t,n){return{id:eh(e),name:`${RJ(e.source)} · ${e.project}`,handle:MJ(e.sessionId),agentClass:"native-session",harness:e.source,state:n?"working":"available",projectRoot:e.cwd,cwd:e.cwd,updatedAt:t,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:eh(e)}}const PJ={think:"var(--dim)",tool:"var(--accent)",ask:"var(--amber)",message:"var(--muted)",note:"var(--green)",system:"var(--dim)",boot:"var(--dim)"},zJ={think:"think",tool:"tool",ask:"ask",message:"msg",note:"note",system:"sys",boot:"boot"};function LJ({navigate:e,agents:t}){const[n,s]=g.useState(null),[i,l]=g.useState("all"),[c,d]=g.useState("all"),[h,m]=g.useState(Hk[1].value),[p,y]=g.useState([]),[x,w]=g.useState(null),[j,N]=g.useState([]),[k,E]=g.useState(Date.now()),A=f2(t);cu(le=>{N(ve=>ve.length>=500?[...ve.slice(ve.length-499),le]:[...ve,le])}),g.useEffect(()=>{const le=setInterval(()=>E(Date.now()),1e4);return()=>clearInterval(le)},[]),g.useEffect(()=>{let le=!1;const ve=async()=>{try{const[Ce,be,we]=await Promise.allSettled([ke("/api/conversations"),ke("/api/tail/discover"),ke("/api/tail/recent?limit=500")]);if(le)return;Ce.status==="fulfilled"?y(Ce.value):y([]),be.status==="fulfilled"&&w(be.value),we.status==="fulfilled"&&N(we.value.events??[])}catch{le||(y([]),w(null))}};ve();const ue=setInterval(()=>{ve()},1e4);return()=>{le=!0,clearInterval(ue)}},[]);const S=g.useRef(null),[M,C]=g.useState({w:0,h:0}),[I,R]=g.useState({x:0,y:0}),[D,z]=g.useState(1),[O,_]=g.useState(!1),U=g.useRef(!1),q=g.useRef({x:0,y:0,panX:0,panY:0}),G=g.useRef(!1);g.useEffect(()=>{const le=S.current;if(!le)return;const ve=new ResizeObserver(([ue])=>{C({w:ue.contentRect.width,h:ue.contentRect.height})});return ve.observe(le),()=>ve.disconnect()},[]);const X=g.useMemo(()=>EJ(p),[p]),L=g.useMemo(()=>CJ(p),[p]),F=g.useMemo(()=>{const le=new Map;for(const ve of t){const ue=A[ve.id],Ce=AJ(ve,ue,L),be=TJ(ve,ue,Ce,k);le.set(ve.id,{lastActiveAt:Ce,current:be,recent:be||Ce>0&&k-Ce<=h})}return le},[t,k,A,h,L]),H=g.useMemo(()=>{const le=new Set(t.map(ue=>ue.harnessSessionId?.trim()).filter(ue=>!!ue)),ve=new Map;for(const ue of j){const Ce=ve.get(ue.sessionId)??[];Ce.push(ue),ve.set(ue.sessionId,Ce)}return(x?.transcripts??[]).filter(ue=>ue.harness!=="scout-managed").filter(ue=>{const Ce=ue.sessionId?.trim();return!Ce||!le.has(Ce)}).slice(0,80).map(ue=>{const Ce=ue.sessionId?ve.get(ue.sessionId)??[]:[],be=Math.max(0,...Ce.map(Be=>Be.ts)),we=Math.max(be,ue.mtimeMs),Se=we>0&&k-we<=g2,He=Se||we>0&&k-we<=h,et=OJ(ue,Ce,Se);return{id:eh(ue),transcript:ue,events:Ce,agent:DJ(ue,we,Se),observe:et,lastActiveAt:we,current:Se,recent:He}})},[t,k,h,x?.transcripts,j]),V=g.useMemo(()=>c==="native"?[]:i==="all"?t:t.filter(le=>{const ve=F.get(le.id);return i==="active"?ve?.current:ve?.recent}),[F,i,t,c]),W=g.useMemo(()=>c==="scout"?[]:i==="all"?H:H.filter(le=>i==="active"?le.current:le.recent),[i,H,c]),$=g.useMemo(()=>[...V.map(SJ),...W.map(kJ)],[V,W]),B=g.useMemo(()=>jJ($),[$]),Y=g.useRef([]),te=g.useCallback((le=!0)=>{if(B.canvasW===0||M.w===0)return;Y.current.forEach(clearTimeout);const ve=Math.min(1,M.w/B.canvasW,M.h/B.canvasH),ue=Math.max(.15,Math.min(1,ve*.92));_(!1),z(ue),R({x:(M.w-B.canvasW*ue)/2,y:Math.max(8,(M.h-B.canvasH*ue)/2)});const Ce=setTimeout(()=>{_(!0);const we=le?wJ():null;we?(R(we.pan),z(we.zoom)):(R({x:24,y:24}),z(.55))},700),be=setTimeout(()=>_(!1),1700);Y.current=[Ce,be]},[B,M]),ae=g.useCallback(()=>{if(B.canvasW===0||M.w===0)return;Y.current.forEach(clearTimeout);const le=Math.min(1,M.w/B.canvasW,M.h/B.canvasH),ve=Math.max(.15,Math.min(1,le*.92));_(!0),z(ve),R({x:(M.w-B.canvasW*ve)/2,y:Math.max(8,(M.h-B.canvasH*ve)/2)});const ue=setTimeout(()=>_(!1),500);Y.current=[ue]},[B,M]);g.useEffect(()=>{B.canvasW===0||M.w===0||G.current||(G.current=!0,te(!0))},[B,M,te]),g.useEffect(()=>{const le=setInterval(()=>{bJ({pan:I,zoom:D})},3e4);return()=>clearInterval(le)},[I,D]);const ee=g.useCallback(le=>{le.target.closest(".s-mission-tile")||(U.current=!0,q.current={x:le.clientX,y:le.clientY,panX:I.x,panY:I.y})},[I]),ie=g.useCallback(le=>{U.current&&R({x:q.current.panX+(le.clientX-q.current.x),y:q.current.panY+(le.clientY-q.current.y)})},[]),de=g.useCallback(()=>{U.current=!1},[]);g.useEffect(()=>{const le=S.current;if(!le)return;const ve=ue=>{ue.preventDefault();const Ce=le.getBoundingClientRect(),be=ue.clientX-Ce.left,we=ue.clientY-Ce.top,Se=ue.deltaY>0?.92:1.08,He=Math.max(.2,Math.min(2,D*Se)),et=He/D;R(Be=>({x:be-(be-Be.x)*et,y:we-(we-Be.y)*et})),z(He)};return le.addEventListener("wheel",ve,{passive:!1}),()=>le.removeEventListener("wheel",ve)},[D]);const xe=n?t.find(le=>le.id===n):null;g.useEffect(()=>{const le=ve=>{ve.target.tagName==="INPUT"||ve.target.tagName==="TEXTAREA"||(ve.key==="Escape"&&s(null),(ve.key==="h"||ve.key==="H")&&te(!1))};return window.addEventListener("keydown",le),()=>window.removeEventListener("keydown",le)},[xe,te]);const Ae=g.useCallback(le=>{const ve=S.current;ve&&R({x:ve.clientWidth/2-le.x*D,y:ve.clientHeight/2-le.y*D})},[D]),me=g.useMemo(()=>{const le={};for(const ve of B.groups)for(const ue of ve.tiles)le[ue.agentId]={x:ue.x,y:ue.y};return le},[B]),Pe=V.filter(le=>F.get(le.id)?.current).length+W.filter(le=>le.current).length,Re=(c==="native"?0:t.filter(le=>F.get(le.id)?.recent).length)+(c==="scout"?0:H.filter(le=>le.recent).length),Ye=V.reduce((le,ve)=>le+(X.get(ve.id)??0),0)+W.length,Ie=V.length+W.length,oe=t.length+H.length,je=g.useMemo(()=>[...V,...W.map(le=>le.agent)],[V,W]),Fe=g.useMemo(()=>Ie>0?{id:"ops-control",render:({isCollapsed:le,onToggleCollapse:ve})=>r.jsx(UJ,{layout:B,agents:je,pan:I,zoom:D,viewportRef:S,isCollapsed:le,onToggleCollapse:ve,onFitAll:ae,onHome:()=>te(!1),onClick:Ae})}:null,[ae,B,je,Ae,I,te,Ie,D]);return xZ(Fe),r.jsxs("div",{className:"s-mission",children:[r.jsxs("div",{className:"s-mission-bar",children:[r.jsxs("span",{className:"s-mission-bar-label",children:[Ie,"/",oe," tile",oe!==1?"s":""," ·"," ",Ye," session",Ye!==1?"s":""," ·"," ",B.groups.length," workspace",B.groups.length!==1?"s":""]}),Pe>0&&r.jsxs("span",{className:"s-mission-bar-live",children:[r.jsx("span",{className:"s-mission-bar-live-dot"}),Pe," active"]}),r.jsxs("div",{className:"s-mission-controls",role:"group","aria-label":"Agent activity filter",children:[r.jsx("button",{type:"button",className:`s-mission-filter${i==="all"?" s-mission-filter--active":""}`,onClick:()=>l("all"),children:"All"}),r.jsx("button",{type:"button",className:`s-mission-filter${i==="active"?" s-mission-filter--active":""}`,onClick:()=>l("active"),children:"Active now"}),r.jsxs("button",{type:"button",className:`s-mission-filter${i==="recent"?" s-mission-filter--active":""}`,onClick:()=>l("recent"),children:["Recent ",Re]})]}),r.jsxs("div",{className:"s-mission-controls",role:"group","aria-label":"Session source filter",children:[r.jsx("button",{type:"button",className:`s-mission-filter${c==="all"?" s-mission-filter--active":""}`,onClick:()=>d("all"),children:"All sources"}),r.jsx("button",{type:"button",className:`s-mission-filter${c==="scout"?" s-mission-filter--active":""}`,onClick:()=>d("scout"),children:"Scout"}),r.jsxs("button",{type:"button",className:`s-mission-filter${c==="native"?" s-mission-filter--active":""}`,onClick:()=>d("native"),children:["Native ",H.length]})]}),i==="recent"&&r.jsx("div",{className:"s-mission-controls",role:"group","aria-label":"Recent activity window",children:Hk.map(le=>r.jsx("button",{type:"button",className:`s-mission-filter s-mission-filter--compact${h===le.value?" s-mission-filter--active":""}`,onClick:()=>m(le.value),children:le.label},le.value))}),r.jsxs("div",{className:"s-mission-hotkeys",children:[r.jsxs("button",{className:"s-mission-hotkey s-mission-hotkey--btn",onClick:()=>te(!1),title:"Reset to overview",children:[r.jsx("kbd",{children:"H"})," Home"]}),r.jsxs("span",{className:"s-mission-hotkey",children:[r.jsx("kbd",{children:"Esc"})," Close focus"]})]})]}),r.jsx("div",{ref:S,className:"s-mission-viewport",onMouseDown:ee,onMouseMove:ie,onMouseUp:de,onMouseLeave:de,children:oe===0?r.jsxs("div",{className:"s-mission-empty",children:[r.jsx("div",{className:"s-mission-empty-title",children:"No agents connected"}),r.jsx("div",{className:"s-mission-empty-sub",children:"Agents appear here as they join the mesh."}),r.jsx("div",{className:"s-mission-empty-hint",children:r.jsx("code",{children:"scout watch --as myagent"})})]}):Ie===0?r.jsxs("div",{className:"s-mission-empty",children:[r.jsx("div",{className:"s-mission-empty-title",children:"No matching sessions"}),r.jsx("div",{className:"s-mission-empty-sub",children:"Try another activity filter or recent window."})]}):r.jsxs("div",{className:"s-mission-canvas",style:{transform:`translate(${I.x}px, ${I.y}px) scale(${D})`,transition:O?"transform 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94)":"none"},children:[B.groups.map(le=>r.jsx("div",{className:"s-mission-group-label",style:{left:le.x,top:le.y},children:le.label},le.label)),V.map(le=>{const ve=me[le.id];if(!ve)return null;const ue=A[le.id];return r.jsx(qk,{agent:le,observe:ue?.data??null,x:ve.x,y:ve.y,onClick:()=>s(le.id)},le.id)}),W.map(le=>{const ve=me[le.id];return ve?r.jsx(qk,{agent:le.agent,observe:le.observe,x:ve.x,y:ve.y,onClick:()=>e({view:"ops",mode:"tail"})},le.id):null})]})}),xe&&r.jsx($J,{agent:xe,observe:A[xe.id]?.data??null,onClose:()=>s(null),onTell:()=>{s(null),e({view:"conversation",conversationId:Nn(xe.id),composeMode:"tell"})},onAsk:()=>{s(null),e({view:"conversation",conversationId:Nn(xe.id),composeMode:"ask"})},onProfile:()=>{s(null),e({view:"agents",agentId:xe.id})}})]})}function qk({agent:e,observe:t,x:n,y:s,onClick:i}){const l=g.useRef(null),c=Xe(e.state),d=gt(e.name),h=t?.events??[],m=h.slice(-8),p=t?.live===!0,y=h.some(k=>k.kind==="ask"&&!k.answer),x=t?.contextUsage,w=x&&x.length>0?Math.round(x[x.length-1]*100):null,j=h.filter(k=>k.kind==="tool").length,N=h.filter(k=>k.kind==="tool"&&k.tool==="edit").length;return g.useEffect(()=>{l.current&&(l.current.scrollTop=l.current.scrollHeight)},[h.length]),r.jsxs("div",{className:`s-mission-tile${c==="working"?" s-mission-tile--working":""}${y?" s-mission-tile--asking":""}`,style:{left:n,top:s,height:Qf},onClick:k=>{k.stopPropagation(),i()},children:[r.jsxs("div",{className:"s-mission-tile-header",children:[r.jsx("div",{className:"s-ops-avatar",style:{"--size":"22px",background:d},children:e.name[0]?.toUpperCase()}),r.jsxs("div",{className:"s-mission-tile-identity",children:[r.jsxs("div",{className:"s-mission-tile-name",children:[e.name,r.jsx("span",{className:"s-mission-tile-handle",children:e.handle?`@${e.handle}`:""})]}),r.jsxs("div",{className:"s-mission-tile-meta",children:[e.project??"—"," · ",e.branch??"main"]})]}),r.jsx("span",{className:"s-ops-state-chip",style:{color:BJ(c)},children:Hn(e.state).toUpperCase()})]}),r.jsx("div",{className:"s-mission-tile-stream",ref:l,children:m.length===0?r.jsx("div",{className:"s-mission-tile-stream-inner",children:r.jsxs("div",{className:"s-mission-evt",children:[r.jsx("span",{className:"s-mission-evt-bead",style:{background:"var(--dim)"}}),r.jsx("span",{className:"s-mission-evt-text",style:{color:"var(--dim)"},children:c==="offline"?"No session data":"Waiting for events…"})]})}):r.jsx("div",{className:"s-mission-tile-stream-inner",children:m.map(k=>r.jsxs("div",{className:"s-mission-evt",children:[r.jsx("span",{className:"s-mission-evt-bead",style:{background:PJ[k.kind]??"var(--dim)"}}),r.jsx("span",{className:"s-mission-evt-kind",children:zJ[k.kind]??k.kind}),r.jsxs("span",{className:`s-mission-evt-text s-mission-evt-text--${k.kind}`,children:[br(k),k.live&&r.jsx("span",{className:"s-observe-cursor"})]})]},k.id))})}),r.jsxs("div",{className:"s-mission-tile-footer",children:[w!==null&&r.jsx("div",{className:"s-mission-tile-ctx",title:`Context: ${w}%`,children:r.jsx("div",{className:"s-mission-tile-ctx-fill",style:{width:`${w}%`}})}),r.jsxs("div",{className:"s-mission-tile-stats",children:[j>0&&r.jsxs("span",{children:[j," tools"]}),N>0&&r.jsxs("span",{children:[N," edits"]})]}),p&&r.jsxs("span",{className:"s-mission-tile-live",children:[r.jsx("span",{className:"s-mission-tile-live-dot"}),"LIVE"]})]})]})}function $J({agent:e,observe:t,onClose:n,onTell:s,onAsk:i,onProfile:l}){const c=gt(e.name);return r.jsx("div",{className:"s-mission-overlay",onClick:n,children:r.jsxs("div",{onClick:d=>d.stopPropagation(),style:{display:"contents"},children:[r.jsxs("div",{className:"s-mission-overlay-header",children:[r.jsx("div",{className:"s-ops-avatar",style:{"--size":"28px",background:c},children:e.name[0]?.toUpperCase()}),r.jsxs("div",{children:[r.jsxs("div",{className:"s-mission-overlay-name",children:[e.name," ",r.jsx("span",{style:{color:"var(--dim)",fontSize:11},children:e.handle?`@${e.handle}`:""})]}),r.jsxs("div",{className:"s-mission-overlay-meta",children:[e.project??"—"," · ",e.branch??"main"," · ",Hn(e.state)]})]}),r.jsxs("div",{className:"s-mission-overlay-actions",children:[r.jsx("button",{className:"s-ops-btn s-ops-btn--primary",onClick:s,children:"Tell"}),r.jsx("button",{className:"s-ops-btn",onClick:i,children:"Ask"}),r.jsx("button",{className:"s-ops-btn",onClick:l,children:"Profile ↗"}),r.jsx("button",{className:"s-ops-btn",onClick:n,children:"ESC"})]})]}),r.jsx("div",{className:"s-mission-overlay-body",children:r.jsx(Ox,{data:t??void 0,agentId:e.id})})]})})}function UJ({layout:e,agents:t,pan:n,zoom:s,viewportRef:i,isCollapsed:l,onToggleCollapse:c,onFitAll:d,onHome:h,onClick:m}){const p=g.useRef(null),[y,x]=g.useState(0);if(g.useEffect(()=>{const O=p.current;if(!O)return;const _=()=>x(O.getBoundingClientRect().width);_();const U=new ResizeObserver(_);return U.observe(O),()=>U.disconnect()},[]),e.canvasW===0)return null;const w=y||yJ,j=Math.min(w/e.canvasW,xJ/e.canvasH),N=e.canvasW*j,k=e.canvasH*j,E=Math.max(0,(w-N)/2),A=i.current,S=A?.clientWidth??0,M=A?.clientHeight??0,C=-n.x/s*j,I=-n.y/s*j,R=S/s*j,D=M/s*j,z=g.useCallback(O=>{const _=O.currentTarget.getBoundingClientRect(),U=Math.max(0,Math.min(N,O.clientX-_.left-E)),q=Math.max(0,Math.min(k,O.clientY-_.top));m({x:U/j,y:q/j})},[E,k,j,N,m]);return l?r.jsx("div",{className:"s-mission-minimap s-mission-minimap--collapsed",children:r.jsxs("div",{className:"s-mission-minimap-header",children:[r.jsxs("span",{className:"s-mission-minimap-title",children:[r.jsx("span",{className:"s-mission-minimap-title-mark","aria-hidden":!0}),"MAP"]}),r.jsx("button",{type:"button",className:"s-mission-minimap-action",title:"Expand map","aria-label":"Expand map",onClick:c,children:r.jsx(NE,{size:12,strokeWidth:1.5})})]})}):r.jsxs("div",{className:"s-mission-minimap",children:[r.jsxs("div",{className:"s-mission-minimap-header",children:[r.jsxs("span",{className:"s-mission-minimap-title",children:[r.jsx("span",{className:"s-mission-minimap-title-mark","aria-hidden":!0}),"MAP"]}),r.jsxs("div",{className:"s-mission-minimap-actions",children:[r.jsx("button",{type:"button",className:"s-mission-minimap-action",title:"Fit all","aria-label":"Fit all",onClick:d,children:r.jsx(DO,{size:12,strokeWidth:1.5})}),r.jsx("button",{type:"button",className:"s-mission-minimap-action",title:"Recenter","aria-label":"Recenter",onClick:h,children:r.jsx(AO,{size:12,strokeWidth:1.5})}),r.jsx("button",{type:"button",className:"s-mission-minimap-action",title:"Minimize map","aria-label":"Minimize map",onClick:c,children:r.jsx(xy,{size:12,strokeWidth:1.5})})]})]}),r.jsxs("div",{ref:p,className:"s-mission-minimap-canvas",style:{height:k},onClick:z,children:[e.groups.flatMap(O=>O.tiles.map(_=>{const U=t.find(q=>q.id===_.agentId);return r.jsx("div",{className:"s-mission-minimap-tile",style:{left:E+_.x*j,top:_.y*j,width:wc*j,height:Qf*j,background:U?gt(U.name):"var(--dim)",opacity:U&&Xe(U.state)==="working"?.8:.35}},_.agentId)})),r.jsx("div",{className:"s-mission-minimap-viewport",style:{left:E+Math.max(0,C),top:Math.max(0,I),width:Math.min(R,N),height:Math.min(D,k)}})]})]})}function BJ(e){switch(e){case"working":return"var(--green)";case"available":return"var(--accent)";default:return"var(--dim)"}}const VJ=["openai","codex","codex_app_server"],FJ=["anthropic","claude","claude-code","claude_stream_json"],ci={"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}},HJ={"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 qJ(e){const t=e.provider?.trim().toLowerCase()??"",n=e.adapterType?.trim().toLowerCase()??"",s=y2(e.model)??"",i=[t,n].filter(Boolean);return i.some(l=>VJ.some(c=>l.includes(c)))?"openai":i.some(l=>FJ.some(c=>l.includes(c)))?"anthropic":s.startsWith("gpt-")||s.startsWith("o")||s.includes("codex")?"openai":s.startsWith("claude-")?"anthropic":"unknown"}function y2(e){return e?e.trim().toLowerCase().replace(/^(openai|anthropic)\//,"").replace(/_/g,"-").replace(/-\d{8}$/,""):null}function ZJ(e){const t=mr(e?.inputTokens),n=mr(e?.cacheReadInputTokens),s=mr(e?.cacheCreationInputTokens),i=mr(e?.outputTokens),l=mr(e?.reasoningOutputTokens),c=[t,i].reduce((h,m)=>h+(m??0),0),d=mr(e?.totalTokens)??(c||null);return{input:t,uncachedInput:t==null?null:Math.max(0,t-(n??0)-(s??0)),cachedInput:n,cacheWrite:s,output:i,reasoningOutput:l,total:d,webSearchRequests:mr(e?.webSearchRequests),webFetchRequests:mr(e?.webFetchRequests)}}function WJ(e){const t=qJ(e),n=y2(e.model),s=ZJ(e.usage),i=YJ(t,n),l=GJ(e);if(!i.rateCard)return{provider:t,model:n,rateCard:null,rateCardSource:"unknown",capturedAt:e.capturedAt??Date.now(),usage:s,lineItems:[],totalUsd:null,billedTotalUsd:null,billingMode:l,subscriptionWindows:e.subscriptionWindows??[]};const c=i.rateCard,d=s.uncachedInput??s.input??0,h=s.cachedInput??0,m=s.cacheWrite??0,p=s.output??0,y=s.webSearchRequests??0,x=[Gd("input","Input",d,c.inputPerM,l),Gd("cached_input","Cached input",h,c.cachedInputPerM??c.inputPerM,l),Gd("cache_write","Cache write",m,c.cacheWritePerM??c.inputPerM,l),Gd("output","Output",p,c.outputPerM,l),{key:"web_search",label:"Web search",quantity:y,unit:"requests",rate:c.webSearchPer1K??0,billedRate:l==="subscription"?0:c.webSearchPer1K??0,costUsd:y/1e3*(c.webSearchPer1K??0),billedCostUsd:l==="subscription"?0:y/1e3*(c.webSearchPer1K??0)}].filter(w=>w.quantity>0);return{provider:t,model:n,rateCard:c,rateCardSource:i.source,capturedAt:e.capturedAt??Date.now(),usage:s,lineItems:x,totalUsd:x.reduce((w,j)=>w+j.costUsd,0),billedTotalUsd:x.reduce((w,j)=>w+j.billedCostUsd,0),billingMode:l,subscriptionWindows:e.subscriptionWindows??[]}}function YJ(e,t){if(e==="unknown")return{rateCard:null,source:"unknown"};const n=t?`${e}:${t}`:null;if(n&&ci[n])return{rateCard:ci[n],source:"exact"};const s=t?HJ[t]:null;if(s&&ci[s])return{rateCard:ci[s],source:"alias"};if(e==="anthropic"){if(t?.includes("opus"))return{rateCard:ci["anthropic:claude-opus-4.5"],source:"provider-default"};if(t?.includes("haiku"))return{rateCard:ci["anthropic:claude-haiku-4.5"],source:"provider-default"};if(t?.includes("sonnet")||!t)return{rateCard:ci["anthropic:claude-sonnet-4.5"],source:"provider-default"}}return{rateCard:null,source:"unknown"}}function Gd(e,t,n,s,i){const l=i==="subscription"?0:s;return{key:e,label:t,quantity:n,unit:"tokens",rate:s,billedRate:l,costUsd:n/1e6*s,billedCostUsd:n/1e6*l}}function mr(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function GJ(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 dy=1440*6e4,KJ=90*6e4;function Zk(e){if(!e)return null;const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function uc(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 Wk(e){return e==null?"—":e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(2)}s`}function Kd(e){return e==null?"$—":e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function XJ(e,t){if(!e)return null;const n=e.data.events.filter(i=>i.kind==="message"||i.kind==="tool").filter(i=>t-i.t<=KJ).sort((i,l)=>i.t-l.t);if(n.length<2)return null;const s=[];for(let i=1;i<n.length;i+=1){const l=n[i].t-n[i-1].t;l>0&&l<12e4&&s.push(l)}return s.length===0?null:Math.round(s.reduce((i,l)=>i+l,0)/s.length)}function JJ(e,t){const n=new Array(24).fill(0),s=t-dy;for(const i of e){if(i.ts<s||i.ts>t)continue;const l=Math.min(23,Math.max(0,Math.floor((i.ts-s)/dy*n.length)));n[l]+=1}return n}function QJ({values:e,warn:t=!1}){const i=Math.max(1,...e),l=e.map((c,d)=>{const h=d/Math.max(1,e.length-1)*92,m=22-c/i*19-1.5;return`${h.toFixed(1)},${m.toFixed(1)}`}).join(" ");return r.jsx("svg",{className:`s-ops-agents-spark${t?" s-ops-agents-spark--warn":""}`,viewBox:"0 0 92 22","aria-hidden":"true",children:r.jsx("polyline",{points:l,fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function eQ(e){return e.transport??Zk(e.cwd)??Zk(e.projectRoot)??"local"}function tQ(e){return e.project??e.role??e.agentClass??"Unassigned"}function nQ(e,t,n,s,i,l){const c=t.filter(w=>w.agentId===e.id),d=c.filter(w=>{const j=w.lastMessageAt??0;return j>0&&l-j<=dy}),h=n.filter(w=>w.actorName===e.name||w.conversationId===e.conversationId),m=i.get(e.id),p=m?.data.metadata?.session?.model??null,y=m?.data.metadata?.session?.modelProvider??null,x=WJ({adapterType:m?.data.metadata?.session?.adapterType,capturedAt:m?.updatedAt??l,model:p,provider:y,usage:m?.data.metadata?.usage});return{agent:e,team:tQ(e),machine:eQ(e),model:p,provider:y,state:Xe(e.state),activeFlights:s.filter(w=>w.agentId===e.id).length,sessions24h:d.length,throughput:JJ(h,l),avgLatencyMs:XJ(m,l),usage:x.usage,cost:x,errors:s.filter(w=>w.agentId===e.id&&(w.status==="failed"||w.status==="needs_attention")).length,lastActiveAt:Math.max(0,...c.map(w=>w.lastMessageAt??0),...h.map(w=>w.ts),e.updatedAt??0)||null}}function sQ({navigate:e,agents:t}){const[n,s]=g.useState(null),[i,l]=g.useState([]),[c,d]=g.useState([]),[h,m]=g.useState([]),[p,y]=g.useState(""),[x,w]=g.useState(()=>Date.now()),j=g.useCallback(async()=>{const _=t.map(L=>L.id).join(","),[U,q,G,X]=await Promise.allSettled([ke("/api/fleet"),ke("/api/conversations"),ke("/api/activity"),_?ke(`/api/observe/agents?ids=${encodeURIComponent(_)}`):Promise.resolve([])]);U.status==="fulfilled"&&s(U.value),q.status==="fulfilled"&&l(q.value),G.status==="fulfilled"&&d(G.value),X.status==="fulfilled"&&m(X.value),w(Date.now())},[t]);g.useEffect(()=>{j()},[j]),Kt(()=>{j()}),g.useEffect(()=>{const _=setInterval(()=>w(Date.now()),1e3);return()=>clearInterval(_)},[]);const N=g.useMemo(()=>new Map(h.map(_=>[_.agentId,_])),[h]),k=g.useMemo(()=>{const _=n?.activeAsks??[];return t.map(U=>nQ(U,i,c,_,N,x)).sort((U,q)=>{const G={working:0,available:1,offline:2},X=G[U.state]-G[q.state];return X!==0?X:(q.lastActiveAt??0)-(U.lastActiveAt??0)})},[c,t,n?.activeAsks,x,N,i]),E=g.useMemo(()=>{const _=p.trim().toLowerCase();return _?k.filter(U=>`${U.agent.name} ${U.team} ${U.machine} ${U.agent.handle??""} ${U.agent.harness??""}`.toLowerCase().includes(_)):k},[p,k]),A=k.filter(_=>_.state==="working").length,S=k.filter(_=>_.state!=="offline").length,M=k.reduce((_,U)=>_+(U.usage.total??0),0),C=k.some(_=>_.cost.totalUsd!=null)?k.reduce((_,U)=>_+(U.cost.totalUsd??0),0):null,I=k.some(_=>_.cost.billedTotalUsd!=null)?k.reduce((_,U)=>_+(U.cost.billedTotalUsd??0),0):null,R=(()=>{const _=k.map(U=>U.avgLatencyMs).filter(U=>U!=null);return _.length===0?null:Math.round(_.reduce((U,q)=>U+q,0)/_.length)})(),D=k.reduce((_,U)=>_+U.errors,0),z=g.useMemo(()=>{const _=new Map;for(const U of k)_.set(U.team,(_.get(U.team)??0)+1);return[..._.entries()].sort((U,q)=>q[1]-U[1]).slice(0,6)},[k]),O=g.useMemo(()=>{const _=new Map;for(const U of k)_.set(U.machine,(_.get(U.machine)??0)+1);return[..._.entries()].sort((U,q)=>q[1]-U[1]).slice(0,7)},[k]);return r.jsxs("div",{className:"s-ops-agents",children:[r.jsxs("aside",{className:"s-ops-agents-rail",children:[r.jsxs("div",{className:"s-ops-agents-brand",children:[r.jsx("div",{className:"s-ops-agents-mark",children:"sc"}),r.jsxs("div",{children:[r.jsx("div",{className:"s-ops-agents-brand-name",children:"agentctl"}),r.jsx("div",{className:"s-ops-agents-brand-sub",children:"ops console"})]})]}),r.jsxs("div",{className:"s-ops-agents-rail-group",children:[r.jsx("div",{className:"s-ops-agents-rail-heading",children:"Fleet"}),r.jsxs("button",{className:"s-ops-agents-rail-row",type:"button",children:["Overview ",r.jsx("span",{children:t.length})]}),r.jsxs("button",{className:"s-ops-agents-rail-row s-ops-agents-rail-row--active",type:"button",children:["Agents ",r.jsx("span",{children:S})]}),r.jsxs("button",{className:"s-ops-agents-rail-row",type:"button",children:["Sessions ",r.jsx("span",{children:i.length})]}),r.jsxs("button",{className:"s-ops-agents-rail-row",type:"button",children:["Alerts ",r.jsx("span",{children:D})]})]}),r.jsxs("div",{className:"s-ops-agents-rail-group",children:[r.jsx("div",{className:"s-ops-agents-rail-heading",children:"Teams"}),z.map(([_,U])=>r.jsxs("button",{className:"s-ops-agents-rail-row",type:"button",children:[_,r.jsx("span",{children:U})]},_))]}),r.jsxs("div",{className:"s-ops-agents-rail-group",children:[r.jsx("div",{className:"s-ops-agents-rail-heading",children:"Machines"}),O.map(([_,U])=>r.jsxs("button",{className:"s-ops-agents-rail-row",type:"button",children:[_,r.jsx("span",{children:U})]},_))]})]}),r.jsxs("main",{className:"s-ops-agents-main",children:[r.jsxs("div",{className:"s-ops-agents-toolbar",children:[r.jsxs("div",{className:"s-ops-agents-breadcrumb",children:["Fleet ",r.jsx("span",{children:"/"})," Agents"]}),r.jsxs("div",{className:"s-ops-agents-live",children:[r.jsx("span",{className:"s-ops-agents-live-dot"}),S," active"]}),r.jsxs("div",{className:"s-ops-agents-search",children:[r.jsx(WO,{size:13}),r.jsx("input",{value:p,onChange:_=>y(_.target.value),placeholder:"Search agents, teams, machines..."})]}),r.jsx("button",{className:"s-ops-agents-icon-btn",type:"button",title:"Filters",children:r.jsx(KO,{size:14})})]}),r.jsx("section",{className:"s-ops-agents-hero",children:r.jsxs("div",{children:[r.jsx("div",{className:"s-ops-agents-kicker",children:"Agents"}),r.jsx("h1",{children:"All agents"}),r.jsx("p",{children:"Every registered agent across the local fleet, sorted by live status."})]})}),r.jsxs("section",{className:"s-ops-agents-stats",children:[r.jsx(Xd,{label:"Running",value:String(A),sub:`of ${t.length} total`}),r.jsx(Xd,{label:"Tokens",value:uc(M||null),sub:C==null?"usage metadata pending":`${Kd(C)} API equiv`}),r.jsx(Xd,{label:"Avg latency",value:Wk(R),sub:"recent observe events"}),r.jsx(Xd,{label:"Billed",value:Kd(I),sub:"subscription usage can mark this down"})]}),r.jsxs("section",{className:"s-ops-agents-table-panel",children:[r.jsxs("div",{className:"s-ops-agents-table-title",children:["Agents ",r.jsx("span",{children:E.length})]}),r.jsx("div",{className:"s-ops-agents-table-wrap",children:r.jsxs("table",{className:"s-ops-agents-table",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Agent"}),r.jsx("th",{children:"Team"}),r.jsx("th",{children:"Machine"}),r.jsx("th",{children:"Active"}),r.jsx("th",{children:"24h sessions"}),r.jsx("th",{children:"Throughput"}),r.jsx("th",{children:"Avg latency"}),r.jsx("th",{children:"Input"}),r.jsx("th",{children:"Cache read"}),r.jsx("th",{children:"Cache write"}),r.jsx("th",{children:"Output"}),r.jsx("th",{children:"API equiv"}),r.jsx("th",{children:"Billed"}),r.jsx("th",{children:"Errors"}),r.jsx("th",{children:"Last active"})]})}),r.jsxs("tbody",{children:[E.map(_=>r.jsxs("tr",{onClick:()=>e({view:"agents",agentId:_.agent.id}),children:[r.jsx("td",{children:r.jsxs("div",{className:"s-ops-agents-agent-cell",children:[r.jsx("span",{className:`s-ops-agents-status s-ops-agents-status--${_.state}`}),r.jsxs("span",{children:[r.jsx("strong",{children:_.agent.name}),r.jsx("small",{children:Hn(_.agent.state)})]})]})}),r.jsx("td",{children:_.team}),r.jsx("td",{children:_.machine}),r.jsx("td",{className:"s-ops-agents-num",children:_.activeFlights}),r.jsx("td",{className:"s-ops-agents-num",children:_.sessions24h}),r.jsx("td",{children:r.jsx(QJ,{values:_.throughput,warn:_.errors>0})}),r.jsx("td",{className:"s-ops-agents-num",children:Wk(_.avgLatencyMs)}),r.jsx("td",{className:"s-ops-agents-num",children:uc(_.usage.uncachedInput??_.usage.input)}),r.jsx("td",{className:"s-ops-agents-num",children:uc(_.usage.cachedInput)}),r.jsx("td",{className:"s-ops-agents-num",children:uc(_.usage.cacheWrite)}),r.jsx("td",{className:"s-ops-agents-num",children:uc(_.usage.output)}),r.jsx("td",{className:`s-ops-agents-num${_.cost.rateCardSource==="unknown"?" s-ops-agents-num--dim":""}`,children:Kd(_.cost.totalUsd)}),r.jsx("td",{className:`s-ops-agents-num${_.cost.billingMode==="subscription"?" s-ops-agents-num--covered":""}`,children:Kd(_.cost.billedTotalUsd)}),r.jsx("td",{className:`s-ops-agents-num${_.errors>0?" s-ops-agents-num--warn":""}`,children:_.errors}),r.jsx("td",{className:"s-ops-agents-last",children:_.lastActiveAt?De(_.lastActiveAt):"—"})]},_.agent.id)),E.length===0&&r.jsx("tr",{children:r.jsx("td",{colSpan:15,className:"s-ops-agents-empty",children:"No agents match the current search."})})]})]})})]})]})]})}function Xd({label:e,value:t,sub:n,tone:s="default"}){return r.jsxs("div",{className:`s-ops-agents-metric s-ops-agents-metric--${s}`,children:[r.jsx("div",{className:"s-ops-agents-metric-label",children:e}),r.jsx("div",{className:"s-ops-agents-metric-value",children:t}),r.jsx("div",{className:"s-ops-agents-metric-sub",children:n})]})}const $x={proposed:{label:"PROPOSED",icon:"◌",color:"var(--dim)"},committed:{label:"COMMITTED",icon:"◐",color:"var(--accent)"},inflight:{label:"IN FLIGHT",icon:"◉",color:"var(--green)"},done:{label:"DONE",icon:"●",color:"var(--muted)"},stuck:{label:"STUCK",icon:"▲",color:"var(--amber)"}};function Ux(e){const t=[e];return e.children&&e.children.forEach(n=>t.push(...Ux(n))),t}function x2(e,t){if(e.id===t)return e;if(!e.children)return null;for(const n of e.children){const s=x2(n,t);if(s)return s}return null}function Yk(e,t){return Ux(e).filter(n=>n.kind==="task"&&n.assigneeId===t).length}function b2(e){switch(e){case"done":return 1;case"inflight":return .7;case"committed":return .32;case"stuck":return .18;default:return .1}}function aQ(e){return(e.currentPhase||e.state).replace(/\s+/g," ")}function rQ(e){return e.state==="done"?"done":e.attention==="interrupt"||e.attention==="badge"||e.state==="waiting"||e.state==="review"?"stuck":e.state==="working"||e.activeFlightCount>0||e.currentPhase==="Working"||e.currentPhase==="Waking"?"inflight":"committed"}function iQ(e){switch(e.status){case"working":return"inflight";case"completed":return"done";case"needs_attention":case"failed":return"stuck";default:return"committed"}}function w2(e,t){return typeof e!="number"||!Number.isFinite(e)?null:Math.max(0,Math.round((t-e)/6e4))}function oQ(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 Bx(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.collaborationRecordId?{view:"work",workId:e.collaborationRecordId}:{view:"agents",agentId:e.agentId}}function lQ(e,t){const n=rQ(e),s=e.lastMeaningfulSummary??e.summary??null;return{id:`work:${e.id}`,kind:"task",title:e.title,summary:e.summary??e.lastMeaningfulSummary??null,state:n,assigneeId:e.ownerId??e.nextMoveOwnerId,detail:s,why:e.summary??`Current phase: ${aQ(e)}`,progress:b2(n),stuckMins:n==="stuck"?w2(e.lastMeaningfulAt,t):null,updatedAt:e.lastMeaningfulAt,route:{view:"work",workId:e.id}}}function cQ(e,t){const n=iQ(e);return{id:`ask:${e.invocationId}`,kind:"task",title:e.task,summary:e.summary,state:n,assigneeId:e.agentId,detail:e.summary??e.statusLabel,why:`Ask status: ${e.statusLabel}`,progress:b2(n),stuckMins:n==="stuck"?w2(e.updatedAt,t):null,updatedAt:e.updatedAt,route:Bx(e)}}function uQ(e,t,n){const s=[];for(const i of e.slice(0,4))s.push({id:`risk:attention:${i.recordId}`,title:i.title,detail:i.summary??(i.kind==="question"?"Waiting on an answer or decision.":"Waiting on the next operator move."),severity:i.kind==="question"?"high":"med"});for(const i of n){if(s.length>=4)break;i.attention==="interrupt"&&s.push({id:`risk:work:${i.id}`,title:i.title,detail:i.lastMeaningfulSummary??"Latest flight failed or the work item is blocked.",severity:"high"})}for(const i of t){if(s.length>=4)break;i.status==="failed"&&s.push({id:`risk:ask:${i.invocationId}`,title:i.task,detail:i.summary??"The delegated ask reported a failure state.",severity:"high"})}return s}const j2=10080*6e4,N2=720*6e4,th={blocked:{label:"Blocked",color:"var(--amber)"},active:{label:"Active",color:"var(--green)"},queued:{label:"Queued",color:"var(--accent)"},complete:{label:"Complete",color:"var(--muted)"},needs_review:{label:"Review",color:"var(--amber)"}};function dQ(e){return e==="done"||e==="cancelled"}function fQ(e,t){const n=[e,...t];return n.some(s=>s.attention!=="silent"||s.state==="waiting"||s.state==="review")?"blocked":n.some(s=>s.state==="working"||s.activeFlightCount>0)?"active":n.every(s=>dQ(s.state))?e.acceptanceState==="pending"?"needs_review":"complete":"queued"}function hQ(e){return e.status==="failed"||e.status==="needs_attention"?"blocked":e.status==="working"?"active":e.status==="queued"?"queued":"needs_review"}function mQ(e,t,n){const s=[e,...t],i=Math.max(...s.map(m=>m.lastMeaningfulAt||m.updatedAt||m.createdAt)),l=s.some(m=>m.attention!=="silent"||m.state==="waiting"||m.state==="review"),c=s.some(m=>m.state==="working"||m.activeFlightCount>0),d=s.every(m=>m.state==="done"),h=s.some(m=>m.state==="open");return l?{state:"blocked",label:"Needs operator check",summary:"A child item is waiting, in review, or marked for attention.",detail:"Completion cannot be trusted until the blocking state is resolved."}:c?{state:"in_progress",label:"Still moving",summary:"At least one item or flight is still active.",detail:"The plan should stay in the ongoing set."}:d?n-i>N2?{state:"needs_review",label:"Done, needs freshness check",summary:"The plan is marked done, but the last meaningful update is no longer fresh.",detail:"Ask the owner to confirm whether the completion state is still accurate."}:{state:"verified",label:"Recently completed",summary:"All visible items are marked done with a recent meaningful update.",detail:"This looks current from the available collaboration state."}:h?{state:"not_started",label:"Queued",summary:"The plan has open work but no active execution signal yet.",detail:"It is ready to be picked up or clarified."}:{state:"needs_review",label:"Needs review",summary:"The plan is in a terminal or quiet state without enough signal to verify completion.",detail:"Use the owner review path before treating this as closed."}}function pQ(e,t){if(e.status==="failed"||e.status==="needs_attention")return{state:"blocked",label:"Needs operator check",summary:e.summary??"The ask is blocked or failed.",detail:"Completion cannot be trusted until the ask is resolved."};if(e.status==="queued"||e.status==="working")return{state:"in_progress",label:e.status==="queued"?"Queued":"Still moving",summary:e.summary??e.task,detail:"The ask has not reported a terminal result yet."};const n=e.completedAt??e.updatedAt;return t-n>N2?{state:"needs_review",label:"Completed, needs freshness check",summary:e.summary??e.task,detail:"The completion is older than the review window."}:{state:"verified",label:"Recently completed",summary:e.summary??e.task,detail:"The ask completed recently."}}function S2(e,t){return(t.get(e.id)??[]).flatMap(s=>[s,...S2(s,t)])}function k2(e,t,n){const s=(t.get(e.id)??[]).sort((l,c)=>c.lastMeaningfulAt-l.lastMeaningfulAt).map(l=>k2(l,t,n));return{...lQ(e,n),children:s.length>0?s:void 0}}function gQ(e){const t=e.map(n=>n.progress).filter(n=>typeof n=="number");return t.length===0?0:t.reduce((n,s)=>n+s,0)/t.length}function vQ(e,t){const n=new Set;for(const s of e){const i=s.ownerId?t[s.ownerId]:null,l=s.nextMoveOwnerId?t[s.nextMoveOwnerId]:null;i?.harness&&n.add(i.harness),l?.harness&&n.add(l.harness)}return[...n].sort()}function yQ(e,t,n,s){const i=S2(e,t),l=k2(e,t,s),c=Ux(l).filter(x=>x.kind==="task"),d=fQ(e,i),h=mQ(e,i,s),m=l.children&&l.children.length>0?l.children:[l],p={...l,id:`plan:${e.id}`,kind:"mission",badge:`${c.length} item${c.length===1?"":"s"}`,progress:c.length>0?gQ(c):l.progress,children:m},y=[e,...i];return{id:`work:${e.id}`,source:"work",title:e.title,summary:e.summary??e.lastMeaningfulSummary,status:d,createdAt:e.createdAt,updatedAt:Math.max(...y.map(x=>x.lastMeaningfulAt||x.updatedAt||x.createdAt)),ownerId:e.ownerId??e.nextMoveOwnerId,ownerName:e.ownerName??e.nextMoveOwnerName,harnesses:vQ(y,n),root:p,leafNodes:c,route:{view:"work",workId:e.id},completion:h}}function xQ(e,t){const n=cQ(e,t),s={...n,id:`plan:ask:${e.invocationId}`,kind:"mission",badge:e.statusLabel,children:[n]};return{id:`ask:${e.invocationId}`,source:"ask",title:e.task,summary:e.summary,status:hQ(e),createdAt:e.startedAt??e.updatedAt,updatedAt:e.updatedAt,ownerId:e.agentId,ownerName:e.agentName??e.agentId,harnesses:e.harness?[e.harness]:[],root:s,leafNodes:[n],route:Bx(e),completion:pQ(e,t)}}function bQ(e){return new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function wQ(e){const t=e.leafNodes.slice(0,6).map(i=>`- ${$x[i.state].label}: ${i.title}`).join(`
|
|
156
|
-
`),n=e.leafNodes.length>6?`
|
|
157
|
-
- ${e.leafNodes.length-6} more item${e.leafNodes.length-6===1?"":"s"}`:"",s=`${t||"- No visible child items"}${n}`;return["Can you evaluate completion for this plan and update the collaboration state if needed?","",`Plan: ${e.title}`,`Current status: ${th[e.status].label}`,`Completion signal: ${e.completion.label}`,`Last visible update: ${bQ(e.updatedAt)}`,"",e.completion.summary,e.completion.detail,"","Visible items:",s,"","Please check whether this is actually done, what remains, and whether the plan record is stale."].join(`
|
|
158
|
-
`)}function jQ(e){const t=new Map;for(const n of e)if(n.status==="fulfilled")for(const s of n.value)t.set(s.id,s);return[...t.values()]}function NQ(e,t,n){return t==="all"?!0:t==="ongoing"?e.status!=="complete":n-Math.max(e.createdAt,e.updatedAt)<=j2}function SQ(e,t){const n={blocked:0,active:1,queued:2,needs_review:3,complete:4},s=n[e.status]-n[t.status];return s!==0?s:t.updatedAt-e.updatedAt}function kQ({navigate:e,agents:t}){const[n,s]=g.useState(null),[i,l]=g.useState([]),[c,d]=g.useState(null),[h,m]=g.useState(null),[p,y]=g.useState("plan"),[x,w]=g.useState("ongoing"),[j,N]=g.useState(()=>Date.now()),[k,E]=g.useState("loading"),[A,S]=g.useState(null),M=g.useRef(0),C=g.useCallback(async()=>{const _=++M.current,[U,q,G]=await Promise.allSettled([ke("/api/fleet"),ke("/api/work?limit=250"),ke("/api/work?active=false&limit=250")]);if(_!==M.current)return;U.status==="fulfilled"&&s(U.value),(q.status==="fulfilled"||G.status==="fulfilled")&&l(jQ([q,G]));const X=[U.status==="rejected"?`fleet: ${U.reason instanceof Error?U.reason.message:String(U.reason)}`:null,q.status==="rejected"?`active work: ${q.reason instanceof Error?q.reason.message:String(q.reason)}`:null,G.status==="rejected"?`recent work: ${G.reason instanceof Error?G.reason.message:String(G.reason)}`:null].filter(L=>!!L);S(X.length>0?X.join(" · "):null),E("ready"),N(Date.now())},[]);g.useEffect(()=>{C()},[C]),Kt(()=>{C()}),g.useEffect(()=>{const _=setInterval(()=>N(Date.now()),15e3);return()=>clearInterval(_)},[]);const I=g.useMemo(()=>Object.fromEntries(t.map(_=>[_.id,_])),[t]),R=g.useMemo(()=>{const _=new Map(i.map(W=>[W.id,W])),U=new Map;for(const W of i)if(W.parentId&&_.has(W.parentId)){const $=U.get(W.parentId)??[];$.push(W),U.set(W.parentId,$)}const G=i.filter(W=>!W.parentId||!_.has(W.parentId)).map(W=>yQ(W,U,I,j)),X=new Set(i.map(W=>W.id)),L=[...n?.activeAsks??[],...n?.recentCompleted??[]].filter(W=>!W.collaborationRecordId||!X.has(W.collaborationRecordId)).map(W=>xQ(W,j)),F=[...G,...L].sort(SQ),H=F.filter(W=>NQ(W,x,j)),V=new Set;for(const W of F)W.harnesses.forEach($=>V.add($));return{records:F,visibleRecords:H,risks:uQ(n?.needsAttention??[],n?.activeAsks??[],i),recentCompleted:(n?.recentCompleted??[]).slice(0,4),pendingAttention:n?.needsAttention??[],harnesses:[...V].sort(),counts:{ongoing:F.filter(W=>W.status!=="complete").length,recent:F.filter(W=>j-Math.max(W.createdAt,W.updatedAt)<=j2).length,review:F.filter(W=>W.completion.state==="needs_review").length,blocked:F.filter(W=>W.status==="blocked").length}}},[I,x,n,j,i]),D=g.useMemo(()=>R.records.find(_=>_.id===c)??R.visibleRecords[0]??R.records[0]??null,[R.records,R.visibleRecords,c]),z=h&&D?x2(D.root,h):null,O=k==="loading"&&R.records.length===0;return g.useEffect(()=>{const _=R.visibleRecords[0]?.id??R.records[0]?.id??null;(!c||!R.records.some(U=>U.id===c))&&d(_)},[R.records,R.visibleRecords,c]),g.useEffect(()=>{if(!D){h!==null&&m(null);return}z||m(D.root.id)},[h,z,D]),r.jsx("div",{className:"s-plan",children:r.jsxs("div",{className:"s-plan-inner s-plan-inner--registry",children:[r.jsxs("div",{className:"s-plan-banner",children:[r.jsx("span",{className:"s-plan-banner-badge",children:"Plans"}),r.jsx("span",{className:"s-plan-banner-meta",children:O?"loading plan registry...":`${R.records.length} record${R.records.length===1?"":"s"} · ${R.counts.ongoing} ongoing · ${R.counts.recent} recent · ${R.counts.review} review · ${R.harnesses.length||"no"} harness${R.harnesses.length===1?"":"es"}`}),A&&r.jsxs("span",{className:"s-plan-banner-meta s-plan-banner-meta--error",children:["partial data · ",A]}),r.jsx("span",{style:{flex:1}}),n&&r.jsxs("span",{className:"s-plan-banner-meta",children:["updated ",De(n.generatedAt)]}),r.jsx("button",{className:"s-ops-btn",onClick:()=>e({view:"fleet"}),children:"Open fleet"}),r.jsx("button",{className:"s-ops-btn",onClick:()=>e({view:"sessions"}),children:"Sessions"})]}),r.jsxs("div",{className:"s-plan-col",children:[r.jsx("div",{className:"s-ops-eyebrow",children:"Plan index"}),r.jsx("div",{className:"s-plan-filterbar",children:["ongoing","recent","all"].map(_=>r.jsx("button",{type:"button",className:`s-plan-tree-toggle-btn${x===_?" s-plan-tree-toggle-btn--active":""}`,onClick:()=>w(_),children:_},_))}),r.jsx("div",{className:"s-plan-record-list",children:R.visibleRecords.length===0?r.jsxs("div",{className:"s-plan-change-card",children:[r.jsx("div",{className:"s-plan-change-summary",children:O?"Loading plan registry":A&&R.records.length===0?"Plan data did not load":"No matching plan records"}),r.jsx("div",{className:"s-plan-change-why",children:O?"Fetching collaboration records, active asks, and recent finishes.":A&&R.records.length===0?A:R.records.length===0?"No collaboration records or recent asks are available yet.":"Switch filters to inspect older or completed records."})]}):R.visibleRecords.map(_=>r.jsx(EQ,{record:_,selected:_.id===D?.id,onSelect:()=>{d(_.id),m(_.root.id)}},_.id))}),r.jsx("div",{className:"s-ops-eyebrow",style:{marginTop:24},children:"Risks · watch"}),R.risks.length===0?r.jsxs("div",{className:"s-plan-change-card",children:[r.jsx("div",{className:"s-plan-change-summary",children:"No active blockers"}),r.jsx("div",{className:"s-plan-change-why",children:"The queue is clear of explicit questions, failed asks, and blocked work items."})]}):R.risks.map(_=>r.jsx(_Q,{risk:_},_.id))]}),r.jsxs("div",{className:"s-plan-col",style:{padding:"20px 16px 40px"},children:[D&&r.jsxs("div",{className:"s-plan-readonly-head",children:[r.jsxs("div",{children:[r.jsx("div",{className:"s-ops-eyebrow",children:"Read-only plan"}),r.jsx("h1",{className:"s-plan-title",children:D.title}),r.jsx("p",{className:"s-plan-goal",children:D.summary??D.completion.summary})]}),r.jsx("span",{className:"s-ops-state-chip",style:{color:th[D.status].color},children:th[D.status].label})]}),r.jsxs("div",{className:"s-plan-tree-header",children:[r.jsx("div",{className:"s-ops-eyebrow",style:{marginBottom:0},children:"Execution tree"}),r.jsxs("span",{className:"s-plan-tree-stats",children:[D?.leafNodes.length??0," item",(D?.leafNodes.length??0)===1?"":"s"," · created ",D?De(D.createdAt):"never"," · updated ",D?De(D.updatedAt):"never"]}),r.jsx("div",{className:"s-plan-tree-toggle",children:["plan","live"].map(_=>r.jsx("button",{className:`s-plan-tree-toggle-btn${p===_?" s-plan-tree-toggle-btn--active":""}`,onClick:()=>y(_),children:_},_))})]}),D?r.jsx(E2,{node:D.root,depth:0,mode:p,selected:h??D.root.id,setSelected:m,agentsById:I,nowMs:j}):r.jsxs("div",{className:"s-plan-change-card",children:[r.jsx("div",{className:"s-plan-change-summary",children:O?"Loading plan registry":"No plan records yet"}),r.jsx("div",{className:"s-plan-change-why",children:O?"Resolving the latest collaboration state.":"Collaboration records and asks will appear here as they are created."})]})]}),r.jsxs("div",{className:"s-plan-col",style:{display:"flex",flexDirection:"column",gap:24},children:[D&&r.jsx(CQ,{record:D,navigate:e}),z&&r.jsxs("div",{children:[r.jsx("div",{className:"s-ops-eyebrow",children:"Selected node"}),r.jsx(IQ,{node:z,agentsById:I,navigate:e})]}),D&&r.jsxs("div",{children:[r.jsx("div",{className:"s-ops-eyebrow",children:"Agents on plan"}),t.filter(_=>Yk(D.root,_.id)>0).length===0?r.jsxs("div",{className:"s-plan-change-card",children:[r.jsx("div",{className:"s-plan-change-summary",children:"No assigned owner"}),r.jsx("div",{className:"s-plan-change-why",children:"This record has no visible owner in the current fleet roster."})]}):t.map(_=>{const U=Yk(D.root,_.id);return U===0?null:r.jsxs("div",{className:"s-plan-agent-row",children:[r.jsx("div",{className:"s-ops-avatar",style:{"--size":"22px",background:gt(_.name)},children:_.name[0]?.toUpperCase()}),r.jsxs("div",{className:"s-plan-agent-row-copy",children:[r.jsx("div",{className:"s-plan-agent-row-name",children:_.name}),r.jsxs("div",{className:"s-plan-agent-row-tasks",children:[U," item",U===1?"":"s"," · ",_.harness??"unknown harness"]})]})]},_.id)})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"s-ops-eyebrow",children:["Attention · ",R.pendingAttention.length]}),R.pendingAttention.length===0?r.jsxs("div",{className:"s-plan-change-card",children:[r.jsx("div",{className:"s-plan-change-summary",children:"Nothing is waiting on you"}),r.jsx("div",{className:"s-plan-change-why",children:"Questions, reviews, and blocked work items will show up here as soon as operator input is required."})]}):R.pendingAttention.slice(0,3).map(_=>r.jsx(MQ,{item:_,navigate:e},_.recordId))]}),r.jsxs("div",{children:[r.jsxs("div",{className:"s-ops-eyebrow",children:["Recent finishes · ",R.recentCompleted.length]}),R.recentCompleted.length===0?r.jsxs("div",{className:"s-plan-change-card",children:[r.jsx("div",{className:"s-plan-change-summary",children:"No recent completions"}),r.jsx("div",{className:"s-plan-change-why",children:"Completed asks will land here so you can review what just finished without leaving the plan view."})]}):R.recentCompleted.map(_=>r.jsx(RQ,{ask:_,navigate:e},_.invocationId))]})]})]})})}function EQ({record:e,selected:t,onSelect:n}){const s=th[e.status];return r.jsxs("button",{type:"button",className:`s-plan-record${t?" s-plan-record--selected":""}`,onClick:n,children:[r.jsxs("div",{className:"s-plan-record-top",children:[r.jsx("span",{className:"s-plan-change-kind",style:{color:s.color},children:s.label}),r.jsx("span",{className:"s-plan-record-source",children:e.source}),r.jsx("span",{className:"s-plan-record-time",children:De(e.updatedAt)})]}),r.jsx("div",{className:"s-plan-record-title",children:e.title}),r.jsx("div",{className:"s-plan-record-summary",children:e.summary??e.completion.summary}),r.jsxs("div",{className:"s-plan-record-foot",children:[r.jsxs("span",{children:[e.leafNodes.length," item",e.leafNodes.length===1?"":"s"]}),r.jsx("span",{children:e.ownerName??e.ownerId??"unassigned"}),r.jsx("span",{children:e.harnesses.length>0?e.harnesses.join(", "):"unknown harness"})]})]})}function CQ({record:e,navigate:t}){const n=e.completion.state==="verified"?"var(--green)":e.completion.state==="blocked"||e.completion.state==="needs_review"?"var(--amber)":"var(--accent)";return r.jsxs("div",{className:"s-plan-detail s-plan-completion",children:[r.jsx("div",{className:"s-ops-eyebrow",children:"Completion"}),r.jsxs("div",{className:"s-plan-detail-header",children:[r.jsx("span",{className:"s-ops-state-chip",style:{color:n},children:e.completion.label}),r.jsxs("span",{className:"s-plan-record-time",children:["updated ",De(e.updatedAt)]})]}),r.jsx("div",{className:"s-plan-detail-title",children:e.completion.summary}),r.jsx("div",{className:"s-plan-detail-why",children:e.completion.detail}),r.jsxs("div",{className:"s-plan-detail-actions",children:[e.route&&r.jsx("button",{className:"s-ops-btn s-ops-btn--primary",onClick:()=>t(e.route),children:"Open editor"}),e.ownerId&&r.jsx("button",{className:"s-ops-btn",onClick:()=>t({view:"conversation",conversationId:Nn(e.ownerId),composeMode:"ask",composeDraft:wQ(e)}),children:"Evaluate with owner"})]})]})}function E2({node:e,depth:t,mode:n,selected:s,setSelected:i,agentsById:l,nowMs:c}){const d=e.children&&e.children.length>0;return r.jsxs("div",{children:[r.jsx(AQ,{node:e,depth:t,mode:n,selected:s===e.id,onClick:()=>i(e.id),agentsById:l,nowMs:c}),d&&r.jsx("div",{className:t===0?void 0:"s-plan-node-children",children:e.children.map(h=>r.jsx(E2,{node:h,depth:t+1,mode:n,selected:s,setSelected:i,agentsById:l,nowMs:c},h.id))})]})}function AQ({node:e,depth:t,mode:n,selected:s,onClick:i,agentsById:l,nowMs:c}){const d=$x[e.state],h=e.assigneeId?l[e.assigneeId]:null,m=e.kind==="mission",p=e.kind==="phase",y=m?"mission":p?"phase":"task";return r.jsxs("div",{className:`s-plan-node s-plan-node--${y}${s?" s-plan-node--selected":""}`,onClick:i,children:[!m&&r.jsx("span",{className:"s-plan-node-icon",style:{color:d.color},children:d.icon}),r.jsxs("div",{className:"s-plan-node-title-wrap",children:[r.jsx("div",{className:"s-plan-node-title-row",style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:r.jsx("span",{className:`s-plan-node-title s-plan-node-title--${y}${e.state==="done"?" s-plan-node-title--done":""}`,children:e.title})}),r.jsx("div",{className:`s-plan-node-payload${n==="live"?" s-plan-node-payload--live":""}`,children:n==="plan"?r.jsx("span",{children:e.why??e.summary??"—"}):r.jsx(TQ,{node:e,nowMs:c})})]}),!m&&r.jsx("div",{className:"s-plan-node-assignee",children:h?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"s-ops-avatar",style:{"--size":"18px",background:gt(h.name)},children:h.name[0]?.toUpperCase()}),r.jsx("span",{className:"s-plan-node-assignee-handle",children:h.handle?`@${h.handle}`:h.name})]}):r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10.5,color:"var(--dim)"},children:"unassigned"})}),!m&&r.jsxs("div",{className:"s-plan-node-right",children:[r.jsx("div",{className:"s-plan-confidence-bar",children:r.jsx("div",{className:"s-plan-confidence-bar-fill",style:{width:`${(e.progress??0)*100}%`,background:d.color}})}),r.jsx("span",{className:"s-ops-state-chip",style:{color:d.color},children:d.label})]}),m&&r.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:10.5,color:"var(--dim)",letterSpacing:"0.08em"},children:e.badge??"LIVE"})]})}function TQ({node:e,nowMs:t}){return e.state==="done"?r.jsxs("span",{style:{opacity:.55},children:["✓ completed ",e.updatedAt?De(e.updatedAt):"recently"]}):e.state==="stuck"?r.jsxs("span",{style:{color:"var(--amber)"},children:["▲ ",e.detail??"blocked",e.stuckMins?` · ${e.stuckMins}m`:""]}):e.state==="inflight"?r.jsxs("span",{children:["› ",e.detail??"working",e.updatedAt?` · ${De(e.updatedAt)}`:""]}):e.state==="committed"?r.jsxs("span",{children:["◐ ",e.detail??"queued",e.updatedAt?` · ${De(e.updatedAt)}`:""]}):r.jsxs("span",{style:{opacity:.55},children:["◌ waiting for first live signal ",e.updatedAt?De(e.updatedAt):""]})}function MQ({item:e,navigate:t}){const n=oQ(e);return r.jsxs("div",{className:"s-plan-change-card",children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[r.jsx("span",{className:"s-plan-change-kind",style:{color:"var(--amber)"},children:e.kind==="question"?"question":"work item"}),r.jsx("span",{style:{flex:1}}),r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--dim)"},children:De(e.updatedAt)})]}),r.jsx("div",{className:"s-plan-change-summary",children:e.title}),r.jsx("div",{className:"s-plan-change-why",children:e.summary??`${e.state.replace(/_/g," ")} · ${e.acceptanceState.replace(/_/g," ")}`}),n&&r.jsx("div",{className:"s-plan-change-actions",children:r.jsx("button",{className:"s-ops-btn s-ops-btn--primary",style:{flex:1},onClick:()=>t(n),children:"Open item"})})]})}function RQ({ask:e,navigate:t}){const n=Bx(e);return r.jsxs("div",{className:"s-plan-change-card s-plan-change-card--accepted",children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[r.jsx("span",{className:"s-plan-change-kind",style:{color:"var(--green)"},children:e.status}),r.jsx("span",{style:{flex:1}}),r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--dim)"},children:De(e.completedAt??e.updatedAt)})]}),r.jsx("div",{className:"s-plan-change-summary",children:e.summary??e.task}),r.jsxs("div",{className:"s-plan-change-why",children:[e.agentName??e.agentId," · ",e.task]}),n&&r.jsx("div",{className:"s-plan-change-actions",children:r.jsx("button",{className:"s-ops-btn",style:{flex:1},onClick:()=>t(n),children:"Open thread"})})]})}function _Q({risk:e}){return r.jsxs("div",{className:"s-plan-risk",children:[r.jsx("span",{className:`s-plan-risk-icon s-plan-risk-icon--${e.severity}`,children:"▲"}),r.jsxs("div",{children:[r.jsx("div",{className:"s-plan-risk-title",children:e.title}),r.jsx("div",{className:"s-plan-risk-detail",children:e.detail})]})]})}function IQ({node:e,agentsById:t,navigate:n}){const s=$x[e.state],i=e.assigneeId?t[e.assigneeId]:null;return r.jsxs("div",{className:"s-plan-detail",children:[r.jsxs("div",{className:"s-plan-detail-header",children:[r.jsx("span",{style:{color:s.color},children:s.icon}),r.jsx("span",{className:"s-ops-state-chip",style:{color:s.color,fontSize:10},children:s.label})]}),r.jsx("div",{className:"s-plan-detail-title",children:e.title}),(e.summary||e.detail||e.why)&&r.jsx("div",{className:"s-plan-detail-why",children:e.summary??e.detail??e.why}),i&&r.jsxs("div",{className:"s-plan-detail-assignee",children:[r.jsx("div",{className:"s-ops-avatar",style:{"--size":"22px",background:gt(i.name)},children:i.name[0]?.toUpperCase()}),r.jsxs("div",{style:{flex:1},children:[r.jsx("div",{style:{fontSize:12.5},children:i.name}),r.jsxs("div",{style:{fontSize:10.5,color:"var(--dim)",fontFamily:"var(--font-mono)"},children:[i.project??"—"," · ",i.branch??"main"]})]})]}),r.jsxs("div",{className:"s-plan-detail-actions",children:[e.route&&r.jsx("button",{className:"s-ops-btn s-ops-btn--primary",onClick:()=>n(e.route),children:"Open item"}),i&&r.jsx("button",{className:"s-ops-btn",onClick:()=>n({view:"conversation",conversationId:Nn(i.id),composeMode:"tell"}),children:"Tell owner"}),i&&r.jsx("button",{className:"s-ops-btn",onClick:()=>n({view:"conversation",conversationId:Nn(i.id),composeMode:"ask"}),children:"Ask owner"})]})]})}const Gk=4e3,OQ=500,DQ=5e3,PQ=5e3,zQ=6e4,nh={"scout-managed":"scout","hudson-managed":"hudson",unattributed:"native"},Vx={tool:"working",run:"active",idle:"idle"};function fy(e){const t=e.split(/\s+/)[0]??"",n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function LQ(e,t=60){const n=e.split(/\s+/);if(n.length===0)return e;n[0]=fy(n[0]);const s=n.join(" ");return s.length<=t?s:s.slice(0,t-1)+"…"}function $Q(e){for(const t of e){const n=fy(t.command);if(n&&!(n==="sh"||n==="zsh"||n==="bash"||n==="login"))return n}return e[0]?.command?fy(e[0].command):"—"}function UQ(e){const t=e.match(/^(?:(\d+)-)?(?:(\d+):)?(\d+):(\d+)$/);if(!t){const d=e.match(/^(\d+)$/);return d?Number.parseInt(d[1],10):0}const[,n,s,i,l]=t;let c=Number.parseInt(l,10)+Number.parseInt(i,10)*60;return s&&(c+=Number.parseInt(s,10)*3600),n&&(c+=Number.parseInt(n,10)*86400),c}function C2(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 s=Math.floor(e/3600),i=Math.floor(e%3600/60);return`${s}h${String(i).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 A2(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 BQ(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 hy(e){return e?e.slice(0,8):"—"}function T2(e){return e?.trim().toLowerCase()||"unknown"}function VQ(e){return T2(e).replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function Fx(e){return`s-atop-chip s-atop-chip--harness s-atop-chip--harness-${VQ(e)}`}const FQ=/permission-mode/i;function HQ(e){return e.kind!=="system"?!1:FQ.test(e.summary)}function M2(e){return e.kind==="assistant"}function qQ(e,t,n){if(!e)return[];const s=new Map;for(const i of t){let l=s.get(i.pid);l||(l={firstEventAt:i.ts,lastEventAt:i.ts,lastKind:i.kind,lastSummary:i.summary,reqCount:0,toolCount:0,permCount:0,eventCount:0,sessionId:i.sessionId||null,model:null,tokIn:null,tokOut:null,cacheReadIn:null,cacheWriteIn:null},s.set(i.pid,l)),i.ts<l.firstEventAt&&(l.firstEventAt=i.ts),i.ts>=l.lastEventAt&&(l.lastEventAt=i.ts,l.lastKind=i.kind,l.lastSummary=i.summary),l.eventCount++,i.kind==="tool"&&l.toolCount++,M2(i)&&l.reqCount++,HQ(i)&&l.permCount++,i.sessionId&&!l.sessionId&&(l.sessionId=i.sessionId)}return e.processes.map(i=>{const l=s.get(i.pid);let c="idle";l&&n-l.lastEventAt<PQ&&(c=l.lastKind==="tool"?"tool":"run");const d=UQ(i.etime),h=l?.firstEventAt??null,m=l&&l.firstEventAt<l.lastEventAt?Math.min(Math.max(0,Math.round((l.lastEventAt-l.firstEventAt)/1e3)),d||Number.POSITIVE_INFINITY):0;return{pid:i.pid,ppid:i.ppid,sessionId:l?.sessionId??null,harness:T2(i.source),attribution:i.harness,project:i.cwd?ZQ(i.cwd):"(unknown)",cwd:i.cwd??"",command:i.command,parentLabel:$Q(i.parentChain??[]),procRuntimeSec:d,procEtime:i.etime,sessionStartAt:h,sessionRuntimeSec:m,status:c,lastEventAt:l?.lastEventAt??null,lastEventKind:l?.lastKind??null,lastSummary:l?.lastSummary??null,reqCount:l?.reqCount??0,toolCount:l?.toolCount??0,permCount:l?.permCount??0,eventCount:l?.eventCount??0,model:l?.model??null,tokIn:l?.tokIn??null,tokOut:l?.tokOut??null,cacheReadIn:l?.cacheReadIn??null,cacheWriteIn:l?.cacheWriteIn??null}})}function Wc(e){if(e.cacheReadIn==null||e.tokIn==null)return null;const t=e.cacheReadIn+e.tokIn;return t===0?null:e.cacheReadIn/t}function hi(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 R2(e){return e==null?"—":`${Math.round(e*100)}%`}function ZQ(e){if(!e)return"";const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function WQ(e,t,n){const s=n-zQ;let i=0;for(const d of t)M2(d)&&d.ts>=s&&i++;const l={total:e.length,running:0,tooling:0,idle:0,harnesses:[],reqsPerMin:i},c=new Map;for(const d of e)d.status==="tool"?(l.tooling++,l.running++):d.status==="run"?l.running++:l.idle++,c.set(d.harness,(c.get(d.harness)??0)+1);return l.harnesses=[...c.entries()].map(([d,h])=>({harness:d,count:h})).sort((d,h)=>h.count-d.count||d.harness.localeCompare(h.harness)),l}const sh={tool:0,run:1,idle:2};function Co(e){return e??-1}function YQ(e,t,n,s){switch(n){case"status":return(sh[e.status]-sh[t.status])*s;case"agent":{const i=e.harness.localeCompare(t.harness);return i!==0?i*s:(e.sessionId??"").localeCompare(t.sessionId??"")*s}case"project":return e.project.localeCompare(t.project)*s;case"reqs":return(e.reqCount-t.reqCount)*s;case"tokIn":return(Co(e.tokIn)-Co(t.tokIn))*s;case"tokOut":return(Co(e.tokOut)-Co(t.tokOut))*s;case"cache":return(Co(Wc(e))-Co(Wc(t)))*s;case"tools":return(e.toolCount-t.toolCount)*s;case"perms":return(e.permCount-t.permCount)*s;case"last":{const i=e.lastEventAt??0,l=t.lastEventAt??0;return(i-l)*s}case"runtime":return(e.sessionRuntimeSec-t.sessionRuntimeSec)*s}}function Kk({values:e,color:t}){if(e.length<2)return r.jsx("svg",{className:"s-atop-spark",width:88,height:18,viewBox:"0 0 88 18"});const i=Math.max(1,...e),l=88/(e.length-1),c=e.map((d,h)=>`${(h*l).toFixed(1)},${(18-d/i*18).toFixed(1)}`).join(" ");return r.jsx("svg",{className:"s-atop-spark",width:88,height:18,viewBox:"0 0 88 18",children:r.jsx("polyline",{fill:"none",stroke:t,strokeWidth:"1.25",points:c})})}function GQ(){const[e,t]=g.useState([]),[n,s]=g.useState(null),[i,l]=g.useState(()=>Date.now()),[c,d]=g.useState(""),[h,m]=g.useState(()=>new Set),[p,y]=g.useState(()=>new Set),[x,w]=g.useState("status"),[j,N]=g.useState(1),[k,E]=g.useState(null),A=g.useRef([]),S=g.useRef([]),[M,C]=g.useState([]),[I,R]=g.useState([]),D=g.useCallback($=>{t(B=>B.length>=Gk?[...B.slice(B.length-Gk+1),$]:[...B,$])},[]);cu(D),g.useEffect(()=>{let $=!1;return(async()=>{try{const B=await ke(`/api/tail/recent?limit=${OQ}`);$||t(B.events??[])}catch{}})(),()=>{$=!0}},[]);const z=g.useCallback(async()=>{try{const $=await ke("/api/tail/discover");s($)}catch{}},[]);g.useEffect(()=>{z();const $=setInterval(()=>{z()},DQ);return()=>clearInterval($)},[z]),g.useEffect(()=>{const $=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval($)},[]);const O=g.useMemo(()=>qQ(n,e,i),[n,e,i]),_=g.useMemo(()=>WQ(O,e,i),[O,e,i]);g.useEffect(()=>{A.current=[...A.current,_.running].slice(-24),S.current=[...S.current,_.tooling].slice(-24),C(A.current),R(S.current)},[_.running,_.tooling]);const U=g.useMemo(()=>{const $=new Set;return O.forEach(B=>$.add(B.harness)),[...$]},[O]),q=g.useMemo(()=>{const $=new Set;return O.forEach(B=>$.add(B.status)),[...$]},[O]),G=g.useMemo(()=>{const $=c.trim().toLowerCase();return O.filter(Y=>{if(h.size>0&&!h.has(Y.harness)||p.size>0&&!p.has(Y.status))return!1;if(!$)return!0;const te=nh[Y.attribution];return`${Y.pid} ${Y.project} ${Y.command} ${Y.harness} ${Y.attribution} ${te} ${Y.sessionId??""} ${Y.lastSummary??""}`.toLowerCase().includes($)}).slice().sort((Y,te)=>{const ae=sh[Y.status]-sh[te.status];return ae!==0&&x!=="status"?ae:YQ(Y,te,x,j)})},[O,c,h,p,x,j]);g.useEffect(()=>{k!=null&&(O.some($=>$.pid===k)||E(null))},[O,k]),g.useEffect(()=>{const $=B=>{const Y=B.target,te=Y instanceof HTMLInputElement||Y instanceof HTMLTextAreaElement||(Y?.isContentEditable??!1);if(B.key==="Escape"&&k!=null){B.preventDefault(),E(null);return}if(!te&&(B.key==="j"||B.key==="k")){if(G.length===0)return;B.preventDefault();const ae=G.findIndex(ie=>ie.pid===k),ee=B.key==="j"?G[Math.min(G.length-1,ae<0?0:ae+1)]:G[Math.max(0,ae<0?0:ae-1)];ee&&E(ee.pid)}};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[G,k]);const X=$=>{x===$?N(B=>B===1?-1:1):(w($),N($==="project"||$==="agent"?1:-1))},L=$=>{m(B=>{const Y=new Set(B);return Y.has($)?Y.delete($):Y.add($),Y})},F=$=>{y(B=>{const Y=new Set(B);return Y.has($)?Y.delete($):Y.add($),Y})},H=g.useMemo(()=>k!=null?O.find($=>$.pid===k)??null:null,[O,k]),V=g.useMemo(()=>k!=null?n?.processes.find($=>$.pid===k)??null:null,[n,k]),W=g.useMemo(()=>k==null?[]:e.filter($=>$.pid===k).slice(-40),[e,k]);return r.jsxs("div",{className:"s-atop",children:[r.jsx(KQ,{summary:_,runHistory:M,toolHistory:I}),r.jsx(XQ,{search:c,onSearch:d,harnessOptions:U,harnessFilter:h,onToggleHarness:L,statusOptions:q,statusFilter:p,onToggleStatus:F,summary:_}),r.jsx(QQ,{rows:G,sortKey:x,sortDir:j,onSort:X,selectedPid:k,onSelect:E,now:i}),r.jsx(eee,{shown:G.length,total:O.length,hasSelection:k!=null}),H&&r.jsx(tee,{row:H,process:V,events:W,now:i,onClose:()=>E(null)})]})}function KQ({summary:e,runHistory:t,toolHistory:n}){return r.jsxs("div",{className:"s-atop-summary",children:[r.jsxs("div",{className:"s-atop-summary-cell s-atop-summary-cell--primary",children:[r.jsxs("div",{className:"s-atop-summary-num",children:[r.jsx("strong",{children:e.running}),r.jsxs("span",{className:"s-atop-summary-of",children:["/ ",e.total]})]}),r.jsx("span",{className:"s-atop-summary-lbl",children:"active"}),r.jsx(Kk,{values:t,color:"var(--green)"})]}),r.jsxs("div",{className:"s-atop-summary-cell",children:[r.jsx("div",{className:"s-atop-summary-num",children:r.jsx("strong",{children:e.tooling})}),r.jsx("span",{className:"s-atop-summary-lbl",children:"working"}),r.jsx(Kk,{values:n,color:"var(--accent)"})]}),r.jsxs("div",{className:"s-atop-summary-cell",children:[r.jsx("div",{className:"s-atop-summary-num",children:r.jsx("strong",{children:e.idle})}),r.jsx("span",{className:"s-atop-summary-lbl",children:"idle"})]}),r.jsxs("div",{className:"s-atop-summary-cell s-atop-summary-cell--breakdown",children:[r.jsx("span",{className:"s-atop-summary-lbl",children:"harness"}),r.jsx("div",{className:"s-atop-summary-row",children:e.harnesses.length>0?e.harnesses.slice(0,4).map(s=>r.jsxs("span",{className:Fx(s.harness),children:[s.harness," ",s.count]},s.harness)):r.jsx("span",{className:"s-atop-chip s-atop-chip--mute",children:"none"})})]}),r.jsx("div",{className:"s-atop-summary-spacer"}),r.jsxs("div",{className:"s-atop-summary-cell s-atop-summary-cell--rate",children:[r.jsxs("div",{className:"s-atop-summary-num",children:[r.jsx("strong",{children:e.reqsPerMin}),r.jsx("span",{className:"s-atop-summary-of",children:"/ min"})]}),r.jsx("span",{className:"s-atop-summary-lbl",children:"requests"})]})]})}function XQ({search:e,onSearch:t,harnessOptions:n,harnessFilter:s,onToggleHarness:i,statusOptions:l,statusFilter:c,onToggleStatus:d,summary:h}){const m=x=>h.harnesses.find(w=>w.harness===x)?.count??0,p=x=>x==="tool"?h.tooling:x==="run"?h.running-h.tooling:h.idle,y=g.useRef(null);return g.useEffect(()=>{const x=w=>{if(w.key!=="/")return;const j=w.target;j instanceof HTMLInputElement||j instanceof HTMLTextAreaElement||(j?.isContentEditable??!1)||(w.preventDefault(),y.current?.focus())};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[]),r.jsxs("div",{className:"s-atop-fbar",children:[r.jsxs("div",{className:"s-atop-search",children:[r.jsx("span",{className:"s-atop-search-prompt",children:"▸"}),r.jsx("input",{ref:y,className:"s-atop-search-input",value:e,onChange:x=>t(x.target.value),placeholder:"filter by pid · project · command · summary",spellCheck:!1}),r.jsx("span",{className:"s-atop-search-kbd",children:"/"})]}),n.length>1&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"s-atop-fbar-label",children:"harness"}),n.map(x=>{const w=s.has(x);return r.jsxs("button",{className:`s-atop-pill s-atop-pill--harness${w?" s-atop-pill--on":""}`,onClick:()=>i(x),children:[x,r.jsx("span",{className:"s-atop-pill-ct",children:m(x)})]},x)})]}),l.length>1&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"s-atop-fbar-label",children:"status"}),["tool","run","idle"].filter(x=>l.includes(x)).map(x=>{const w=c.has(x);return r.jsxs("button",{className:`s-atop-pill s-atop-pill--status-${x}${w?" s-atop-pill--on":""}`,onClick:()=>d(x),children:[Vx[x],r.jsx("span",{className:"s-atop-pill-ct",children:p(x)})]},x)})]}),r.jsx("div",{className:"s-atop-fbar-spacer"})]})}const Yg=[{key:"status",label:"Status",cls:"s-atop-col-status",defaultWidth:96,minWidth:70},{key:"agent",label:"Agent",cls:"s-atop-col-agent",tip:"Harness · short session id",defaultWidth:168,minWidth:110},{key:"project",label:"Project",cls:"s-atop-col-project",defaultWidth:200,minWidth:96,maxWidth:480},{key:"reqs",label:"Reqs",cls:"s-atop-col-num",tip:"Model invocations (assistant turns) for this session",defaultWidth:64,minWidth:56},{key:"tokIn",label:"Tok ↓",cls:"s-atop-col-num",tip:"Input tokens — populated when backend emits usage",defaultWidth:64,minWidth:56},{key:"tokOut",label:"Tok ↑",cls:"s-atop-col-num",tip:"Output tokens — populated when backend emits usage",defaultWidth:64,minWidth:56},{key:"cache",label:"Cache",cls:"s-atop-col-num",tip:"Cache hit rate — populated when backend emits usage",defaultWidth:64,minWidth:56},{key:"tools",label:"Tools",cls:"s-atop-col-num",defaultWidth:64,minWidth:56},{key:"perms",label:"Perms",cls:"s-atop-col-num",tip:"Permission requests — heuristic count of permission-mode events",defaultWidth:64,minWidth:56},{key:"last",label:"Last",cls:"s-atop-col-last",defaultWidth:86,minWidth:64},{key:"runtime",label:"Runtime",cls:"s-atop-col-runtime",tip:"Session duration (active period in current buffer)",defaultWidth:80,minWidth:64}];function dc({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 r.jsx("td",{className:n,children:hi(e)})}function JQ({value:e}){const t=e==null?"s-atop-col-num s-atop-col-num--dim":"s-atop-col-num";return r.jsx("td",{className:t,children:R2(e)})}function QQ({rows:e,sortKey:t,sortDir:n,onSort:s,selectedPid:i,onSelect:l,now:c}){const{getColumnProps:d,getResizeHandleProps:h}=UR({storageKey:"openscout.atop.cols",columns:Yg});return r.jsx("div",{className:"s-atop-table-wrap",children:r.jsxs("table",{className:"s-atop-table",children:[r.jsx("thead",{children:r.jsx("tr",{children:Yg.map(m=>r.jsxs("th",{className:`${m.cls??""}${t===m.key?" s-atop-th--sorted":""}`,onClick:()=>s(m.key),title:m.tip,...d(m.key),children:[m.label,t===m.key&&r.jsx("span",{className:"s-atop-th-arrow",children:n===1?"↑":"↓"}),r.jsx("span",{...h(m.key)})]},m.key))})}),r.jsx("tbody",{children:e.length===0?r.jsx("tr",{className:"s-atop-empty-row",children:r.jsx("td",{colSpan:Yg.length,children:r.jsxs("div",{className:"s-atop-empty",children:[r.jsx("span",{className:"s-atop-empty-title",children:"no agents match"}),r.jsx("span",{children:"adjust filters or start a session to populate"})]})})}):e.map(m=>r.jsxs("tr",{className:`s-atop-row${i===m.pid?" s-atop-row--selected":""}`,onClick:()=>l(m.pid),children:[r.jsx("td",{className:"s-atop-col-status",children:r.jsxs("span",{className:`s-atop-status s-atop-status--${m.status}`,children:[r.jsx("span",{className:"s-atop-status-dot"}),Vx[m.status]]})}),r.jsx("td",{className:"s-atop-col-agent",children:r.jsxs("div",{className:"s-atop-agent-cell",children:[r.jsx("span",{className:Fx(m.harness),title:`origin: ${nh[m.attribution]}`,children:m.harness}),r.jsx("span",{className:"s-atop-agent-id",title:m.sessionId??`pid ${m.pid}`,children:hy(m.sessionId)})]})}),r.jsx("td",{className:"s-atop-col-project",title:m.cwd,children:m.project}),r.jsx(dc,{value:m.reqCount||null}),r.jsx(dc,{value:m.tokIn}),r.jsx(dc,{value:m.tokOut}),r.jsx(JQ,{value:Wc(m)}),r.jsx(dc,{value:m.toolCount||null}),r.jsx(dc,{value:m.permCount||null,accent:m.permCount>0?"amber":void 0}),r.jsx("td",{className:"s-atop-col-last",children:A2(m.lastEventAt,c)}),r.jsx("td",{className:"s-atop-col-runtime",children:C2(m.sessionRuntimeSec)})]},m.pid))})]})})}function eee({shown:e,total:t,hasSelection:n}){return r.jsxs("div",{className:"s-atop-keys",children:[r.jsxs("span",{className:"s-atop-keys-count",children:[r.jsx("strong",{children:e})," / ",t," agents"]}),r.jsx("span",{className:"s-atop-keys-spacer"}),r.jsxs("span",{children:[r.jsx("kbd",{children:"/"})," filter"]}),r.jsxs("span",{children:[r.jsx("kbd",{children:"j"}),"/",r.jsx("kbd",{children:"k"})," select"]}),r.jsxs("span",{children:[r.jsx("kbd",{children:"click"})," drill in"]}),n&&r.jsxs("span",{children:[r.jsx("kbd",{children:"esc"})," close"]})]})}function tee({row:e,process:t,events:n,now:s,onClose:i}){const l=g.useMemo(()=>{const d={};for(const p of n){if(p.kind!=="tool")continue;const y=p.summary.match(/^([a-z_][a-z0-9_]*)/i),x=y?y[1]:"(tool)";d[x]=(d[x]??0)+1}const h=Object.entries(d).sort((p,y)=>y[1]-p[1]).slice(0,6),m=Math.max(1,...h.map(p=>p[1]));return h.map(([p,y])=>({name:p,count:y,frac:y/m}))},[n]),c=n.slice(-40).reverse();return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"s-atop-drawer-bg",onClick:i}),r.jsxs("aside",{className:"s-atop-drawer",role:"dialog","aria-label":`Agent ${e.pid}`,children:[r.jsxs("header",{className:"s-atop-drawer-head",children:[r.jsxs("div",{className:"s-atop-drawer-head-meta",children:[r.jsxs("span",{className:`s-atop-status s-atop-status--${e.status}`,children:[r.jsx("span",{className:"s-atop-status-dot"}),Vx[e.status]]}),r.jsxs("span",{className:"s-atop-drawer-pid",children:["pid ",e.pid]}),r.jsx("span",{className:Fx(e.harness),title:`origin: ${nh[e.attribution]}`,children:e.harness}),r.jsxs("span",{className:"s-atop-drawer-session",children:["session ",hy(e.sessionId)]})]}),r.jsx("h2",{className:"s-atop-drawer-title",children:e.project}),r.jsxs("p",{className:"s-atop-drawer-sub",children:["session ",hy(e.sessionId)," · runtime ",C2(e.sessionRuntimeSec)," · last activity ",A2(e.lastEventAt,s)]}),r.jsx("button",{className:"s-atop-drawer-close",onClick:i,"aria-label":"Close",children:"✕"})]}),r.jsxs("div",{className:"s-atop-drawer-body",children:[r.jsxs("section",{children:[r.jsx("h3",{className:"s-atop-drawer-h3",children:"Activity"}),r.jsxs("div",{className:"s-atop-metrics",children:[r.jsx(pr,{label:"Requests",value:hi(e.reqCount||null)}),r.jsx(pr,{label:"Tools",value:hi(e.toolCount||null)}),r.jsx(pr,{label:"Permissions",value:hi(e.permCount||null),accent:e.permCount>0?"amber":void 0}),r.jsx(pr,{label:"Tok in",value:hi(e.tokIn),dim:e.tokIn==null}),r.jsx(pr,{label:"Tok out",value:hi(e.tokOut),dim:e.tokOut==null}),r.jsx(pr,{label:"Cache hit",value:R2(Wc(e)),dim:Wc(e)==null}),r.jsx(pr,{label:"Model",value:e.model??"—",dim:e.model==null}),r.jsx(pr,{label:"Events",value:hi(e.eventCount||null)})]})]}),l.length>0&&r.jsxs("section",{children:[r.jsx("h3",{className:"s-atop-drawer-h3",children:"Tool calls"}),r.jsx("ul",{className:"s-atop-histo",children:l.map(d=>r.jsxs("li",{children:[r.jsx("span",{className:"s-atop-histo-name",children:d.name}),r.jsx("span",{className:"s-atop-histo-bar",children:r.jsx("span",{className:"s-atop-histo-fill",style:{width:`${(d.frac*100).toFixed(1)}%`}})}),r.jsx("span",{className:"s-atop-histo-count",children:d.count})]},d.name))})]}),r.jsxs("section",{children:[r.jsxs("h3",{className:"s-atop-drawer-h3",children:["Recent activity",r.jsxs("span",{className:"s-atop-drawer-h3-aside",children:[n.length," buffered"]})]}),c.length===0?r.jsx("div",{className:"s-atop-peek-empty",children:"no events buffered for this agent yet"}):r.jsx("ol",{className:"s-atop-peek",children:c.map(d=>r.jsxs("li",{className:`s-atop-peek-row s-atop-peek-row--${d.kind}`,children:[r.jsx("span",{className:"s-atop-peek-time",children:BQ(d.ts)}),r.jsx("span",{className:"s-atop-peek-kind",children:d.kind}),r.jsx("span",{className:"s-atop-peek-text",children:d.summary})]},d.id))})]}),r.jsxs("section",{className:"s-atop-drawer-section--secondary",children:[r.jsx("h3",{className:"s-atop-drawer-h3",children:"Process"}),r.jsx("code",{className:"s-atop-codeblock",children:e.command}),r.jsxs("dl",{className:"s-atop-kvs",children:[r.jsx("dt",{children:"PID"}),r.jsx("dd",{children:e.pid}),r.jsx("dt",{children:"Parent"}),r.jsxs("dd",{children:[e.parentLabel," (ppid ",e.ppid,")"]}),r.jsx("dt",{children:"Process etime"}),r.jsx("dd",{children:e.procEtime}),r.jsx("dt",{children:"Origin"}),r.jsx("dd",{children:nh[e.attribution]}),r.jsx("dt",{children:"CWD"}),r.jsx("dd",{children:e.cwd||"(none)"})]}),t?.parentChain&&t.parentChain.length>0&&r.jsx("ol",{className:"s-atop-chain",children:t.parentChain.map(d=>r.jsxs("li",{children:[r.jsx("span",{className:"s-atop-chain-pid",children:d.pid}),r.jsx("span",{className:"s-atop-chain-cmd",children:LQ(d.command,80)})]},d.pid))})]})]})]})]})}function pr({label:e,value:t,dim:n,accent:s}){const i=`s-atop-metric${n?" s-atop-metric--dim":""}${s?` s-atop-metric--${s}`:""}`;return r.jsxs("div",{className:i,children:[r.jsx("span",{className:"s-atop-metric-lbl",children:e}),r.jsx("span",{className:"s-atop-metric-val",children:t})]})}const nee=e=>e==="right"?"railOccupantRight":"railOccupantBottom";function see(e,t,n,s){g.useEffect(()=>{if(!n||typeof window>"u"||typeof document>"u")return;const i=nee(e),l=document.body.dataset[i];document.body.dataset[i]=t,window.dispatchEvent(new CustomEvent("hudson:rail:claim",{detail:{owner:t,side:e}})),l&&l!==t&&window.dispatchEvent(new CustomEvent("hudson:rail:preempted",{detail:{owner:l,side:e,by:t}}));const c=h=>{const m=h.detail;m&&m.side===e&&m.owner!==t&&s?.()},d=h=>{const m=h.detail;m&&m.side===e&&m.owner===t&&s?.()};return window.addEventListener("hudson:rail:claim",c),window.addEventListener("hudson:rail:preempted",d),()=>{window.removeEventListener("hudson:rail:claim",c),window.removeEventListener("hudson:rail:preempted",d),document.body.dataset[i]===t&&delete document.body.dataset[i],window.dispatchEvent(new CustomEvent("hudson:rail:release",{detail:{owner:t,side:e}}))}},[e,t,n,s])}const aee=620,ree=360,iee=280,oee=900,lee=720,Xk=["a[href]","button:not([disabled])","textarea:not([disabled])","input:not([disabled])","select:not([disabled])","[tabindex]:not([tabindex='-1'])"].join(", ");function cee({open:e,onClose:t,side:n="right",owner:s,defaultSize:i,minSize:l=iee,maxSize:c,resizable:d=!1,backdrop:h=!0,scrollLock:m=!1,focusTrap:p=!1,ariaLabel:y,className:x,children:w}){const j=i??(n==="right"?aee:ree),N=c??(n==="right"?oee:lee),[k,E]=g.useState(j),[A,S]=g.useState(!1),M=g.useRef(null),C=g.useRef(null),I=g.useCallback(()=>t(),[t]);see(n,s,e,I),g.useEffect(()=>{if(!e)return;const z=O=>{O.key==="Escape"&&(O.preventDefault(),I())};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[e,I]),g.useEffect(()=>{if(!e||!m)return;const z=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=z}},[e,m]),g.useEffect(()=>{if(!e)return;C.current=document.activeElement;const z=M.current;return z?((z.querySelector(Xk)??z).focus(),()=>{C.current?.focus?.()}):void 0},[e]),g.useEffect(()=>{if(!A)return;const z=_=>{if(n==="right"){const U=window.innerWidth-_.clientX;E(Math.min(N,Math.max(l,U)))}else{const U=window.innerHeight-_.clientY;E(Math.min(N,Math.max(l,U)))}},O=()=>S(!1);return window.addEventListener("pointermove",z),window.addEventListener("pointerup",O),window.addEventListener("pointercancel",O),()=>{window.removeEventListener("pointermove",z),window.removeEventListener("pointerup",O),window.removeEventListener("pointercancel",O)}},[A,n,l,N]);const R=z=>{if(!p||z.key!=="Tab")return;const O=M.current;if(!O)return;const _=Array.from(O.querySelectorAll(Xk));if(_.length===0){z.preventDefault(),O.focus();return}const U=_[0],q=_[_.length-1],G=document.activeElement;z.shiftKey?(G===U||!O.contains(G))&&(z.preventDefault(),q.focus()):G===q&&(z.preventDefault(),U.focus())};if(!e)return null;const D=n==="right"?{width:k}:{height:k};return r.jsxs(r.Fragment,{children:[h&&r.jsx("div",{className:"s-slide-backdrop","data-side":n,onClick:I,"aria-hidden":"true"}),r.jsxs("aside",{ref:M,className:`s-slide s-slide--${n}${A?" s-slide--resizing":""}${x?` ${x}`:""}`,role:"dialog","aria-modal":"true","aria-label":y,tabIndex:-1,onKeyDown:R,style:D,children:[d&&r.jsx("div",{className:`s-slide-resize s-slide-resize--${n}`,onPointerDown:z=>{z.preventDefault(),S(!0)},role:"separator","aria-orientation":n==="right"?"vertical":"horizontal","aria-label":"Resize panel"}),w]})]})}const Jk=5e3,uee=500,Qk=5e3,dee=3e4,_2={user:">",assistant:"<",tool:"*","tool-result":"=",system:"~",other:"·"},Hx={"scout-managed":"scout","hudson-managed":"hudson",unattributed:"native"},I2={"scout-managed":"s-tail-chip--origin-scout","hudson-managed":"s-tail-chip--origin-hudson",unattributed:"s-tail-chip--origin-native"};function qx(e){return e?.trim().toLowerCase()||"unknown"}function fee(e,t){const n=new Map,s=e?.transcripts?.length?e.transcripts:e?.processes.length?e.processes:t;for(const i of s){const l=qx(i.source);n.set(l,(n.get(l)??0)+1)}return[...n.entries()].map(([i,l])=>({source:i,count:l})).sort((i,l)=>l.count-i.count||i.source.localeCompare(l.source))}function hee(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),s=String(t.getMinutes()).padStart(2,"0"),i=String(t.getSeconds()).padStart(2,"0"),l=String(t.getMilliseconds()).padStart(3,"0");return`${n}:${s}:${i}.${l}`}function mee(e){return e?(e.split(":")[0]??e).slice(0,8):"—"}function pee(e,t){if(!t)return!0;const n=Hx[e.harness];return`${e.summary} ${e.project} ${e.sessionId} ${e.source} ${e.harness} ${n}`.toLowerCase().includes(t.toLowerCase())}function gee({navigate:e,initialFilter:t}={}){const[n,s]=g.useState([]),[i,l]=g.useState(null),[c,d]=g.useState(t??""),[h,m]=g.useState(!!t),[p,y]=g.useState(!1),[x,w]=g.useState(0),[j,N]=g.useState(0),[k,E]=g.useState(null),A=g.useRef(null),S=g.useRef(null),M=g.useRef(!0),C=g.useRef([]),I=g.useCallback(L=>{C.current.push(Date.now()),s(F=>F.length>=Jk?[...F.slice(F.length-Jk+1),L]:[...F,L])},[]);cu(I),g.useEffect(()=>{d(t??""),m(!!t)},[t]),g.useEffect(()=>{let L=!1;return(async()=>{try{const F=await ke(`/api/tail/recent?limit=${uee}`);L||s(F.events??[])}catch{}})(),()=>{L=!0}},[]);const R=g.useCallback(async()=>{try{const L=await ke("/api/tail/discover");l(L)}catch{}},[]);g.useEffect(()=>{R();const L=setInterval(()=>{R()},dee);return()=>clearInterval(L)},[R]),g.useEffect(()=>{const L=setInterval(()=>{const H=Date.now()-Qk,V=C.current.filter(W=>W>=H);C.current=V,N(V.length/(Qk/1e3))},1e3);return()=>clearInterval(L)},[]);const D=g.useMemo(()=>c?n.filter(L=>pee(L,c)):n,[n,c]);g.useLayoutEffect(()=>{const L=A.current;if(L){if(p){w(F=>F+1);return}L.scrollTop=L.scrollHeight}},[D,p]);const z=g.useCallback(()=>{const L=A.current;if(!L)return;const H=L.scrollHeight-L.scrollTop-L.clientHeight<24;M.current=H,H?(y(!1),w(0)):p||y(!0)},[p]),O=g.useCallback(L=>{d(L),m(!0),requestAnimationFrame(()=>S.current?.focus())},[]),_=g.useCallback(L=>{!L||!e||e({view:"sessions",sessionId:L})},[e]),U=g.useCallback(()=>{const L=A.current;L&&(L.scrollTop=L.scrollHeight,y(!1),w(0))},[]);g.useEffect(()=>{const L=F=>{const H=F.target,V=H instanceof HTMLInputElement||H instanceof HTMLTextAreaElement||(H?.isContentEditable??!1);if(F.key==="/"&&!V){F.preventDefault(),m(!0),requestAnimationFrame(()=>S.current?.focus());return}if(F.key==="Escape"&&h&&document.activeElement===S.current){F.preventDefault(),m(!1),S.current?.blur(),d("");return}(F.key==="g"||F.key==="G")&&!V&&(F.preventDefault(),U())};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[h,U]);const q=i?.totals,G=q?.transcripts??i?.transcripts?.length??0,X=g.useMemo(()=>fee(i,n),[i,n]);return r.jsxs("div",{className:"s-tail",children:[r.jsxs("div",{className:"s-tail-status",children:[r.jsxs("span",{className:"s-tail-status-cell",children:[r.jsx("span",{className:"s-tail-rate-pulse"}),r.jsx("strong",{children:G})," log",G===1?"":"s"]}),r.jsxs("span",{className:"s-tail-status-cell",children:[r.jsx("strong",{children:q?.total??0})," proc",(q?.total??0)===1?"":"s"]}),r.jsxs("span",{className:"s-tail-status-cell",children:[r.jsx("strong",{children:j.toFixed(1)})," lines/s"]}),r.jsxs("span",{className:"s-tail-status-cell s-tail-status-cell--harnesses",children:[r.jsx("span",{children:"harness"}),r.jsx("span",{className:"s-tail-status-inline",children:X.length>0?X.slice(0,4).map(L=>r.jsxs("span",{children:[r.jsx("strong",{children:L.count})," ",L.source]},L.source)):r.jsx("strong",{children:"none"})})]}),r.jsx("span",{className:"s-tail-status-spacer"}),p&&r.jsx("span",{className:"s-tail-status-paused",children:"paused"})]}),h&&r.jsxs("div",{className:"s-tail-filter",children:[r.jsx("span",{className:"s-tail-filter-prompt",children:"/"}),r.jsx("input",{ref:S,className:"s-tail-filter-input",value:c,placeholder:"substring across summary · project · session",onChange:L=>d(L.target.value),onKeyDown:L=>{L.key==="Enter"&&(L.preventDefault(),S.current?.blur())},autoFocus:!0,spellCheck:!1}),r.jsx("span",{className:"s-tail-filter-hint",children:"esc to clear"})]}),r.jsxs("div",{className:"s-tail-body",ref:A,onScroll:z,children:[D.length===0?r.jsxs("div",{className:"s-tail-empty",children:[r.jsxs("span",{className:"s-tail-empty-title",children:["Waiting for events",r.jsx("span",{className:"s-tail-empty-cursor","aria-hidden":"true"})]}),r.jsx("span",{className:"s-tail-empty-body",children:c?r.jsxs(r.Fragment,{children:["no events match filter ",r.jsx("strong",{children:c})]}):G?r.jsxs(r.Fragment,{children:["watching ",G," transcript",G===1?"":"s"," · no events yet"]}):r.jsx(r.Fragment,{children:"agent tool calls, messages, and system events stream here"})}),!G&&!c&&r.jsxs("span",{className:"s-tail-empty-hint",children:["Start a session to see traffic",r.jsx("span",{className:"s-tail-empty-hint-sep",children:" · "}),r.jsx("code",{children:"scout watch --tail"})]})]}):D.map(L=>r.jsx(vee,{event:L,selected:k?.id===L.id,onSelect:E,onProjectClick:O,onSessionClick:_},L.id)),p&&x>0&&r.jsxs("div",{className:"s-tail-divider",onClick:U,role:"button",children:["── paused · ",x," new · click or press G to jump back to live ──"]})]}),r.jsxs("div",{className:"s-tail-keys",children:[r.jsxs("span",{children:[r.jsx("kbd",{children:"j"}),"/",r.jsx("kbd",{children:"k"})," scroll"]}),r.jsxs("span",{children:[r.jsx("kbd",{children:"/"})," filter"]}),r.jsxs("span",{children:[r.jsx("kbd",{children:"G"})," jump live"]}),r.jsxs("span",{children:[r.jsx("kbd",{children:"esc"})," close filter"]}),r.jsx("span",{className:"s-tail-keys-spacer"}),r.jsxs("span",{children:[D.length," / ",n.length," lines buffered"]})]}),k&&r.jsx(bee,{event:k,onClose:()=>E(null),onProjectClick:O,onSessionClick:_})]})}function vee({event:e,selected:t,onSelect:n,onProjectClick:s,onSessionClick:i}){const l=I2[e.harness],c=Hx[e.harness],d=qx(e.source);return r.jsxs("div",{className:`s-tail-row s-tail-row--${e.kind}${t?" s-tail-row--selected":""}`,role:"button",tabIndex:0,onClick:()=>n(e),onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),n(e))},children:[r.jsx("span",{className:"s-tail-cell-time",children:hee(e.ts)}),r.jsx("span",{className:"s-tail-gutter",children:"│"}),r.jsx("span",{className:"s-tail-chip s-tail-chip--harness",children:d}),r.jsx("span",{className:`s-tail-chip ${l}`,title:`origin: ${c}`,children:c}),r.jsxs("span",{className:"s-tail-cell-context",children:[r.jsx(ah,{className:"s-tail-link s-tail-link--project",onClick:s?()=>s(e.project):void 0,title:`Filter to ${e.project}`,children:r.jsx("strong",{children:e.project})})," · ",r.jsx(ah,{className:"s-tail-link s-tail-link--session",onClick:i&&e.sessionId?()=>i(e.sessionId):void 0,title:e.sessionId?`Open session ${e.sessionId}`:void 0,children:mee(e.sessionId)})," · ",r.jsx("span",{className:"s-tail-cell-pid",title:e.pid>0?`pid ${e.pid}`:"file-backed log",children:e.pid>0?e.pid:"log"})]}),r.jsx("span",{className:`s-tail-glyph s-tail-glyph--${e.kind}`,children:_2[e.kind]}),r.jsx("span",{className:"s-tail-summary",children:e.summary})]})}function ah({className:e,onClick:t,title:n,children:s}){return t?r.jsx("span",{className:`${e} s-tail-link--active`,role:"link",tabIndex:0,title:n,onClick:i=>{i.stopPropagation(),t()},onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),i.stopPropagation(),t())},children:s}):r.jsx("span",{className:e,title:n,children:s})}function yee(e){const t=new Date(e),n=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0"),l=String(t.getHours()).padStart(2,"0"),c=String(t.getMinutes()).padStart(2,"0"),d=String(t.getSeconds()).padStart(2,"0"),h=String(t.getMilliseconds()).padStart(3,"0");return`${n}-${s}-${i} ${l}:${c}:${d}.${h}`}function xf(e){return(JSON.stringify(e,null,2)??"undefined").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/("(?:\\.|[^"\\])*"\s*:)|("(?:\\.|[^"\\])*")|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g,(s,i,l,c,d)=>i?`<span class="s-tail-jk">${i}</span>`:l?`<span class="s-tail-js">${l}</span>`:c?`<span class="s-tail-jl">${c}</span>`:d?`<span class="s-tail-jn">${d}</span>`:s)}function xee(e){if(!e||typeof e!="object")return null;const t=e,s=t.message?.content??t.content;return Array.isArray(s)?s:typeof s=="string"?[{type:"text",text:s}]:null}function bee({event:e,onClose:t,onProjectClick:n,onSessionClick:s}){const[i,l]=g.useState(!0),c=I2[e.harness],d=Hx[e.harness],h=qx(e.source),m=xee(e.raw);return r.jsxs(cee,{open:!0,onClose:t,side:"right",owner:"openscout.tail",resizable:!0,defaultSize:620,minSize:400,maxSize:960,ariaLabel:"Tail event detail",children:[r.jsxs("div",{className:"s-slide-header s-tail-sheet-header",children:[r.jsx("span",{className:`s-tail-glyph s-tail-glyph--${e.kind}`,children:_2[e.kind]}),r.jsx("span",{className:"s-tail-sheet-kind",children:e.kind}),r.jsx("span",{className:"s-tail-chip s-tail-chip--harness",children:h}),r.jsx("span",{className:`s-tail-chip ${c}`,title:`origin: ${d}`,children:d}),r.jsx("span",{className:"s-slide-spacer"}),r.jsx("span",{className:"s-tail-sheet-time",children:yee(e.ts)}),r.jsx("button",{type:"button",className:"s-slide-close",onClick:t,"aria-label":"Close",children:"×"})]}),r.jsxs("div",{className:"s-slide-body s-tail-sheet-body",children:[r.jsx("section",{className:"s-tail-sheet-section",children:r.jsxs("div",{className:"s-tail-sheet-grid",children:[r.jsx("span",{className:"s-tail-sheet-key",children:"project"}),r.jsx("span",{className:"s-tail-sheet-val",children:r.jsx(ah,{className:"s-tail-link s-tail-link--project",onClick:n?()=>n(e.project):void 0,title:`Filter to ${e.project}`,children:e.project})}),r.jsx("span",{className:"s-tail-sheet-key",children:"cwd"}),r.jsx("span",{className:"s-tail-sheet-val s-tail-sheet-val--mono",children:e.cwd||"—"}),r.jsx("span",{className:"s-tail-sheet-key",children:"session"}),r.jsx("span",{className:"s-tail-sheet-val s-tail-sheet-val--mono",children:r.jsx(ah,{className:"s-tail-link s-tail-link--session",onClick:s&&e.sessionId?()=>s(e.sessionId):void 0,title:e.sessionId?`Open session ${e.sessionId}`:void 0,children:e.sessionId||"—"})}),r.jsx("span",{className:"s-tail-sheet-key",children:"harness"}),r.jsx("span",{className:"s-tail-sheet-val s-tail-sheet-val--mono",children:h}),r.jsx("span",{className:"s-tail-sheet-key",children:"origin"}),r.jsx("span",{className:"s-tail-sheet-val s-tail-sheet-val--mono",children:d}),r.jsx("span",{className:"s-tail-sheet-key",children:"pid"}),r.jsxs("span",{className:"s-tail-sheet-val s-tail-sheet-val--mono",children:[e.pid,e.parentPid!=null?` ← ${e.parentPid}`:""]})]})}),r.jsxs("section",{className:"s-tail-sheet-section",children:[r.jsx("h4",{className:"s-tail-sheet-h",children:"summary"}),r.jsx("div",{className:"s-tail-sheet-summary",children:e.summary})]}),m&&m.length>0&&r.jsxs("section",{className:"s-tail-sheet-section",children:[r.jsx("h4",{className:"s-tail-sheet-h",children:"content"}),m.map((p,y)=>r.jsx(wee,{block:p},y))]}),r.jsxs("section",{className:"s-tail-sheet-section",children:[r.jsxs("button",{type:"button",className:"s-tail-sheet-toggle",onClick:()=>l(p=>!p),children:[i?"▾":"▸"," raw event"]}),i&&r.jsx("pre",{className:"s-tail-sheet-json",dangerouslySetInnerHTML:{__html:xf(e.raw??e)}})]})]})]})}function wee({block:e}){if(e.type==="text"){const t=e.text??"";return r.jsx("div",{className:"s-tail-sheet-text",children:t})}if(e.type==="tool_use"){const t=e;return r.jsxs("div",{className:"s-tail-sheet-block s-tail-sheet-block--tool",children:[r.jsxs("div",{className:"s-tail-sheet-block-head",children:[r.jsx("span",{className:"s-tail-glyph s-tail-glyph--tool",children:"*"}),r.jsx("span",{className:"s-tail-sheet-block-title",children:t.name??"tool_use"})]}),r.jsx("pre",{className:"s-tail-sheet-json",dangerouslySetInnerHTML:{__html:xf(t.input??{})}})]})}if(e.type==="tool_result"){const t=e,n=typeof t.content=="string";return r.jsxs("div",{className:`s-tail-sheet-block s-tail-sheet-block--tool-result${t.is_error?" s-tail-sheet-block--err":""}`,children:[r.jsxs("div",{className:"s-tail-sheet-block-head",children:[r.jsx("span",{className:"s-tail-glyph s-tail-glyph--tool-result",children:"="}),r.jsxs("span",{className:"s-tail-sheet-block-title",children:["tool_result",t.is_error?" · error":""]})]}),n?r.jsx("pre",{className:"s-tail-sheet-pre",children:t.content}):r.jsx("pre",{className:"s-tail-sheet-json",dangerouslySetInnerHTML:{__html:xf(t.content??{})}})]})}return r.jsxs("div",{className:"s-tail-sheet-block",children:[r.jsxs("div",{className:"s-tail-sheet-block-head",children:[r.jsx("span",{className:"s-tail-glyph s-tail-glyph--other",children:"·"}),r.jsx("span",{className:"s-tail-sheet-block-title",children:e.type})]}),r.jsx("pre",{className:"s-tail-sheet-json",dangerouslySetInnerHTML:{__html:xf(e)}})]})}const jee=15*6e4,Nee=1440*6e4,Zx=30*6e4,O2=1440*6e4,See=Zx,kee=[{label:"30m",value:Zx},{label:"4h",value:240*6e4},{label:"24h",value:O2}],yi="operator",$a="broker";function D2(e,t){return typeof e.updatedAt=="number"&&Number.isFinite(e.updatedAt)&&e.updatedAt>0&&e.updatedAt<=t&&t-e.updatedAt<=Nee}function Eee(e,t){return Xe(e.state)!=="offline"&&D2(e,t)&&t-(e.updatedAt??t)>jee}function _h(e){return e.replace(/[._]/g," ")}function Wx(e,t=84){const n=(e??"").replace(/\s+/g," ").trim();return n?n.length>t?`${n.slice(0,t-1)}...`:n:"No summary available"}function Cee(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function ml(e,t){if(!e||!Number.isFinite(e))return"unknown";const n=Math.max(0,Math.floor((t-e)/1e3));if(n<60)return`${n}s`;const s=Math.floor(n/60);if(s<60)return`${s}m`;const i=Math.floor(s/60);return i<48?`${i}h`:`${Math.floor(i/24)}d`}function za(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 my(e){return e===1?"1 cue":`${e} cues`}function Aee(e){const t=Math.max(1,Math.round(e/6e4));return Math.min(O2,Math.max(Zx,t*6e4))}function Tee(e){const t=e.trim().toLowerCase().match(/^(\d+(?:\.\d+)?)\s*(m|min|mins|minute|minutes|h|hr|hrs|hour|hours|d|day|days)?$/);if(!t)return null;const n=Number(t[1]);if(!Number.isFinite(n)||n<=0)return null;const s=t[2]??"m",i=s.startsWith("d")?1440*6e4:s.startsWith("h")?60*6e4:6e4;return Aee(n*i)}function rh(e){switch(e){case"critical":return 0;case"warning":return 1;default:return 2}}function Gg(e,t){const n=rh(e.severity)-rh(t.severity);return n!==0?n:e.updatedAt-t.updatedAt}function eE(e,t){const n=rh(e.severity)-rh(t.severity);return n!==0?n:t.updatedAt-e.updatedAt}function Mee(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:null}function P2(e){return"actorId"in e?e.actorId:null}function z2(e){return"agentId"in e?e.agentId:null}function Yc(e,t){if(e===yi)return"Operator";if(e===$a)return"Broker";const n=t.get(e);return n?n.name:e.replace(/\.mini$/,"").replace(/[._-]+/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function tE(e){return e.replace(/^@/,"").toLowerCase().replace(/[^a-z0-9]+/g,"")}function Ree(e,t){if(!e)return null;const n=e.match(/@([a-zA-Z0-9][a-zA-Z0-9._-]+)/)?.[1];if(!n)return null;const s=tE(n);return t.find(l=>[l.id,l.name,l.handle??"",l.selector??""].some(c=>tE(c)===s))?.id??null}function _ee(e,t){const n=e.conversationId;return!n||!n.startsWith("dm.")?null:n.startsWith("dm.operator.")?yi:t&&n.startsWith(`dm.${t}.`)?n.slice(`dm.${t}.`.length)||null:t&&n.endsWith(`.${t}`)&&n.slice(3,-`.${t}`.length)||null}function Iee(e,t){const n=P2(e),s=e.kind,i=Ree(e.title??e.summary,t),l=_ee(e,n);if(s==="ask_replied"||s==="flight_updated")return yi;if(i&&i!==n)return i;if(l&&l!==n)return l;const c=z2(e);return c&&c!==n?c:$a}function Oee(e){return P2(e)??z2(e)??$a}function Dee(e,t){const n=new Map(t.map(w=>[w.id,w])),s=new Map,i=e.slice(0,48).map((w,j)=>{const N=Oee(w),k=Iee(w,t);return s.set(N,(s.get(N)??0)+1),s.set(k,(s.get(k)??0)+1),{id:w.id,fromId:N,toId:k,kind:w.kind,label:Wx(w.title??w.summary,92),ts:w.ts,route:Mee(w)}}),l=[...s.entries()].filter(([w])=>w!==yi&&w!==$a).sort((w,j)=>j[1]-w[1]).slice(0,18).map(([w])=>w),c=new Set([yi,$a,...l]),d=1e3,h=620,m=[{id:yi,label:"Operator",detail:"command",kind:"operator",x:118,y:h/2,state:"online",weight:s.get(yi)??0,route:null},{id:$a,label:"Broker",detail:"message fabric",kind:"broker",x:492,y:h/2,state:"mesh",weight:s.get($a)??0,route:{view:"fleet"}}];l.forEach((w,j)=>{const N=n.get(w),k=Math.max(1,l.length),E=-Math.PI*.62+j/Math.max(1,k-1)*Math.PI*1.24,A=j%2===0?250:315,S=630+Math.cos(E)*A,M=h/2+Math.sin(E)*235;m.push({id:w,label:Yc(w,n),detail:N?.project??N?.role??N?.agentClass??"agent endpoint",kind:N?"agent":"external",x:Math.max(250,Math.min(d-70,S)),y:Math.max(70,Math.min(h-70,M)),state:N?Hn(N.state):"External",weight:s.get(w)??0,route:N?{view:"agents",agentId:N.id}:null})});const p=new Map(m.map(w=>[w.id,w])),y=i.filter(w=>c.has(w.fromId)||c.has(w.toId)).slice(0,26).map(w=>{const j=p.get(w.fromId)??p.get($a),N=p.get(w.toId)??p.get($a);return{...w,from:j,to:N}}),x=[...t.reduce((w,j)=>{const N=j.project??j.role??j.agentClass??"unassigned";return w.set(N,(w.get(N)??0)+1),w},new Map)].sort((w,j)=>j[1]-w[1]).slice(0,6).map(([w,j])=>({name:w,count:j}));return{nodes:m,edges:i,visibleEdges:y,projects:x,messageRate:e.length}}function Pee(e){switch(e.view){case"work":return`work:${e.workId}`;case"conversation":return`conversation:${e.conversationId}`;case"agents":return`agent:${e.agentId??""}`;default:return e.view}}function zee(e){return e.kind==="question"?"Answer":e.state==="review"?"Review":e.acceptanceState==="pending"?"Acknowledge":"Open work"}function Lee(e){return e.kind==="question"?e.conversationId?{label:"Answer",route:{view:"conversation",conversationId:e.conversationId}}:e.recordId?{label:"Open question",route:{view:"work",workId:e.recordId}}:null:e.recordId?{label:zee(e),route:{view:"work",workId:e.recordId}}:e.conversationId?{label:"Open conversation",route:{view:"conversation",conversationId:e.conversationId}}:e.agentId?{label:"Open agent",route:{view:"agents",agentId:e.agentId}}:null}function $ee(e){const t=[],n=Lee(e);n&&t.push(n);const s=new Set(t.map(i=>Pee(i.route)));if(e.recordId&&!s.has(`work:${e.recordId}`)&&(t.push({label:e.kind==="question"?"Open question":"Open work",route:{view:"work",workId:e.recordId}}),s.add(`work:${e.recordId}`)),e.conversationId){const i=`conversation:${e.conversationId}`;s.has(i)||(t.push({label:"Open conversation",route:{view:"conversation",conversationId:e.conversationId}}),s.add(i))}if(e.agentId){const i=`agent:${e.agentId}`;s.has(i)||t.push({label:"Open agent",route:{view:"agents",agentId:e.agentId}})}return t}function Uee(e){const t=[];return e.collaborationRecordId&&t.push({label:"Open work",route:{view:"work",workId:e.collaborationRecordId}}),e.conversationId&&t.push({label:"Open conversation",route:{view:"conversation",conversationId:e.conversationId}}),t.push({label:"Open agent",route:{view:"agents",agentId:e.agentId}}),t}function Bee(e){const t=e.kind==="question",n=$ee(e);return{source:"attention",item:e,key:`attention:${e.recordId}`,lane:"attention",severity:t?"critical":"warning",pill:t?"Needs answer":"Needs input",title:e.title||"Unresolved work",summary:Wx(e.summary,140),agentId:e.agentId,agentName:e.agentName,updatedAt:e.updatedAt,startedAt:null,completedAt:null,actions:n,meta:[e.agentName??"Unassigned",_h(e.kind),e.state,e.acceptanceState]}}function Vee(e){return e.status==="failed"?"failed":e.status==="completed"?"done":"running"}function Fee(e){return e.status==="failed"||e.attention==="interrupt"?"critical":e.attention==="badge"||e.status==="needs_attention"?"warning":"info"}function nE(e){return{source:"ask",item:e,key:`ask:${e.invocationId}`,lane:Vee(e),severity:Fee(e),pill:e.statusLabel,title:e.task||"Delegated ask",summary:Wx(e.summary,140),agentId:e.agentId,agentName:e.agentName??e.agentId,updatedAt:e.updatedAt,startedAt:e.startedAt,completedAt:e.completedAt,actions:Uee(e),meta:[e.agentName??e.agentId,e.harness??"unknown harness",e.transport??"unknown transport"]}}function Hee(e){const t=(e?.needsAttention??[]).map(Bee),n=(e?.activeAsks??[]).map(nE),s=(e?.recentCompleted??[]).map(nE);return[...t,...n,...s]}function qee(e,t){return e.map(n=>{const s=Xe(n.state),i=Eee(n,t),l=D2(n,t),c=i||s==="offline"&&l?"warning":"info",d=i&&s!=="offline"?"Stale":Hn(n.state),h=i?0:s==="working"?1:s==="available"?2:l?3:4;return{key:n.id,name:n.name,state:d,detail:`${n.project??n.role??n.agentClass} / updated ${ml(n.updatedAt,t)} ago`,route:{view:"agents",agentId:n.id},severity:c,rank:h,updatedAt:n.updatedAt}}).sort((n,s)=>n.rank-s.rank||(s.updatedAt??0)-(n.updatedAt??0)||n.name.localeCompare(s.name))}function Zee(e,t){const n=["s-warroom-attention-item",`s-warroom-attention-item--${e.severity}`];return t&&n.push("s-warroom-attention-item--selected"),n.join(" ")}function Wee(e,t=!1){const n=["s-warroom-kpi"];return e&&n.push("s-warroom-kpi--warn"),t&&n.push("s-warroom-kpi--hot"),n.join(" ")}function Yee({navigate:e,agents:t}){const[n,s]=g.useState(null),[i,l]=g.useState([]),[c,d]=g.useState(null),[h,m]=g.useState(null),[p,y]=g.useState("item"),[x,w]=g.useState(!1),[j,N]=g.useState(See),[k,E]=g.useState(()=>Date.now()),A=g.useCallback(async()=>{try{const V=await ke("/api/fleet");s(V),V.activity.length>0?l([]):l(await ke("/api/activity"))}catch{const V=await Promise.allSettled([ke("/api/activity")]);V[0].status==="fulfilled"&&l(V[0].value)}E(Date.now())},[]);g.useEffect(()=>{A()},[A]),Kt(()=>{A()}),g.useEffect(()=>{const V=setInterval(()=>E(Date.now()),1e3);return()=>clearInterval(V)},[]);const S=g.useMemo(()=>n?.activity.length?n.activity:i,[i,n?.activity]),M=g.useMemo(()=>{const V=k-j;return S.filter(W=>W.ts>=V&&W.ts<=k)},[S,j,k]),C=g.useMemo(()=>Dee(M,t),[M,t]),I=C.messageRate,R=g.useMemo(()=>Hee(n),[n]),D=g.useMemo(()=>R.filter(V=>V.source==="attention"&&V.actions.length>0).sort(Gg),[R]),z=g.useMemo(()=>({attention:R.filter(V=>V.lane==="attention").sort(Gg),running:R.filter(V=>V.lane==="running").sort(eE),failed:R.filter(V=>V.lane==="failed").sort(Gg),done:R.filter(V=>V.lane==="done").sort(eE).slice(0,8)}),[R]);g.useEffect(()=>{const V=D[0]?.key??z.running[0]?.key??z.done[0]?.key??null;if(!V){c!==null&&d(null);return}(!(c&&R.some($=>$.key===c))||!x)&&(d(V),x||y("item"))},[x,R,z.done,z.running,D,c]);const O=g.useMemo(()=>R.find(V=>V.key===c)??D[0]??z.running[0]??z.done[0]??null,[R,z.done,z.running,D,c]),_=t.filter(V=>Xe(V.state)!=="offline").length,U=D.filter(V=>V.severity!=="info").length,q=D.filter(V=>V.severity==="critical").length,G=g.useMemo(()=>qee(t,k),[t,k]),X=g.useMemo(()=>new Map(C.nodes.map(V=>[V.id,V.label])),[C.nodes]),L=g.useMemo(()=>C.edges.find(V=>V.id===h)??null,[C.edges,h]),F=n?`${ml(n.generatedAt,k)} ago`:"loading",H=p==="flow"?L?_h(L.kind):"No selection":O?O.pill:"No selection";return r.jsxs("div",{className:"s-warroom",children:[r.jsxs("header",{className:"s-warroom-command",children:[r.jsxs("div",{className:"s-warroom-command-main",children:[r.jsx("div",{className:"s-warroom-title",children:"Command"}),r.jsx("div",{className:"s-warroom-subtitle",children:"Live fleet attention, message flow, and handoffs."}),r.jsxs("div",{className:"s-warroom-statusline",children:["Freshness ",F," / Local time ",Cee(k)]})]}),r.jsxs("div",{className:"s-warroom-kpis",children:[r.jsx(Kg,{label:"Action needed",value:String(U),detail:my(D.length),warn:U>0,hot:q>0}),r.jsx(Kg,{label:"Online",value:`${_}/${t.length}`,detail:"agents",warn:_<t.length}),r.jsx(Kg,{label:"Messages",value:String(I),detail:`last ${za(j)}`})]})]}),r.jsxs("div",{className:"s-warroom-layout",children:[r.jsxs("aside",{className:"s-warroom-queue",children:[r.jsx(Xg,{title:"State",meta:D.length===0?"clear":my(D.length)}),r.jsx(Gee,{queueItems:D,selectedKey:O?.key??null,nowMs:k,navigate:e,onSelect:V=>{w(!0),d(V),y("item")}})]}),r.jsxs("main",{className:"s-warroom-board",children:[r.jsx(Xg,{title:"Message Topology",meta:`${C.visibleEdges.length} visible flows / ${za(j)}`}),r.jsx(Xee,{network:C,nowMs:k,flowWindowMs:j,selectedFlowId:p==="flow"?L?.id??null:null,navigate:e,onFlowWindowChange:N,onSelectFlow:V=>{w(!0),m(V),y("flow")}})]}),r.jsxs("aside",{className:"s-warroom-inspector",children:[r.jsx(Xg,{title:"Inspector",meta:H}),p==="flow"?L?r.jsx(Qee,{edge:L,nodeLabels:X,nowMs:k,navigate:e}):r.jsx("div",{className:"s-warroom-empty",children:"Select a message flow to inspect."}):O?r.jsx(ete,{item:O,nowMs:k,navigate:e}):r.jsx("div",{className:"s-warroom-empty",children:"Select an item to inspect."}),r.jsxs("section",{className:"s-warroom-inspector-card",children:[r.jsx("div",{className:"s-warroom-inspector-title",children:"Agent health"}),r.jsx("div",{className:"s-warroom-health",children:G.slice(0,8).map(V=>r.jsxs("button",{type:"button",className:"s-warroom-health-row",onClick:()=>e(V.route),children:[r.jsx("span",{className:"s-warroom-dot"}),r.jsx("span",{children:V.name}),r.jsx("span",{children:V.state}),r.jsx("span",{children:V.detail})]},V.key))})]})]})]})]})}function Kg({label:e,value:t,detail:n,warn:s=!1,hot:i=!1}){return r.jsxs("div",{className:Wee(s,i),children:[r.jsx("div",{className:"s-warroom-kpi-label",children:e}),r.jsx("div",{className:"s-warroom-kpi-value",children:t}),r.jsx("div",{className:"s-warroom-kpi-detail",children:n})]})}function Xg({title:e,meta:t}){return r.jsxs("div",{className:"s-warroom-section-head",children:[r.jsx("div",{className:"s-warroom-section-title",children:e}),r.jsx("div",{className:"s-warroom-section-meta",children:t})]})}function Gee({queueItems:e,selectedKey:t,nowMs:n,navigate:s,onSelect:i}){return r.jsxs("div",{className:"s-warroom-command-stack",children:[r.jsxs("div",{className:"s-warroom-readiness",children:[r.jsx("div",{className:"s-warroom-readiness-mark",children:e.length===0?"CLEAR":"ACTION"}),r.jsx("div",{className:"s-warroom-readiness-body",children:e.length===0?"No action items are blocking the fleet. The topology remains the primary signal.":"Operator action is available for each cue below."})]}),e.length>0&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"s-warroom-section-head s-warroom-section-head--tight",children:[r.jsx("div",{className:"s-warroom-section-title",children:"Attention Cue"}),r.jsx("div",{className:"s-warroom-section-meta",children:my(e.length)})]}),r.jsx("div",{className:"s-warroom-queue-list",children:e.slice(0,4).map(l=>r.jsx(Kee,{item:l,nowMs:n,selected:l.key===t,navigate:s,onSelect:()=>i(l.key)},l.key))})]})]})}function Kee({item:e,nowMs:t,selected:n,navigate:s,onSelect:i}){const l=e.actions[0];return l?r.jsxs("div",{className:Zee(e,n),children:[r.jsxs("button",{type:"button",className:"s-warroom-attention-item-main",onClick:i,children:[r.jsxs("div",{className:"s-warroom-attention-item-top",children:[r.jsx("span",{className:"s-warroom-pill",children:e.pill}),r.jsxs("span",{className:"s-warroom-age",children:[ml(e.updatedAt,t)," ago"]})]}),r.jsx("div",{className:"s-warroom-attention-item-title",children:e.title}),r.jsx("div",{className:"s-warroom-attention-item-summary",children:e.summary}),r.jsx("div",{className:"s-warroom-attention-item-meta",children:e.meta.filter(Boolean).map((c,d)=>r.jsx("span",{children:c},`${e.key}:meta:${d}`))})]}),r.jsx("button",{type:"button",className:"s-warroom-attention-item-primary",onClick:()=>s(l.route),children:l.label})]}):null}function Xee({network:e,nowMs:t,flowWindowMs:n,selectedFlowId:s,navigate:i,onFlowWindowChange:l,onSelectFlow:c}){const d=new Set(e.visibleEdges.map(j=>j.id)),h=new Map(e.nodes.map(j=>[j.id,j.label])),m=e.nodes,p=e.visibleEdges[0]??null,[y,x]=g.useState(za(n));g.useEffect(()=>{x(za(n))},[n]);const w=(j=y)=>{const N=Tee(j);if(!N){x(za(n));return}l(N)};return r.jsxs("div",{className:"s-warroom-topology",children:[r.jsxs("div",{className:"s-warroom-windowbar",children:[r.jsxs("div",{className:"s-warroom-windowbar-copy",children:[r.jsx("span",{children:"Flow window"}),r.jsxs("strong",{children:["Last ",za(n)]})]}),r.jsxs("div",{className:"s-warroom-window-controls",children:[r.jsx("div",{className:"s-warroom-window-tabs","aria-label":"Message flow window presets",children:kee.map(j=>r.jsx("button",{type:"button",className:`s-warroom-window-tab${j.value===n?" s-warroom-window-tab--active":""}`,onClick:()=>l(j.value),children:j.label},j.value))}),r.jsxs("form",{className:"s-warroom-window-custom",onSubmit:j=>{j.preventDefault(),w()},children:[r.jsx("label",{htmlFor:"s-warroom-window-custom-input",children:"Custom"}),r.jsx("input",{id:"s-warroom-window-custom-input","aria-label":"Custom message flow window",value:y,onChange:j=>x(j.currentTarget.value),onBlur:j=>w(j.currentTarget.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),w(j.currentTarget.value),j.currentTarget.blur()),j.key==="Escape"&&(j.preventDefault(),x(za(n)),j.currentTarget.blur())},spellCheck:!1})]})]})]}),r.jsxs("div",{className:"s-warroom-map",children:[r.jsxs("svg",{className:"s-warroom-map-svg",viewBox:"0 0 1000 620",role:"img","aria-label":"Live message topology",children:[r.jsxs("defs",{children:[r.jsxs("radialGradient",{id:"warroomNodeGlow",cx:"50%",cy:"50%",r:"50%",children:[r.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:"0.32"}),r.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:"0"})]}),r.jsxs("filter",{id:"warroomPacketGlow",x:"-60%",y:"-60%",width:"220%",height:"220%",children:[r.jsx("feGaussianBlur",{stdDeviation:"3",result:"blur"}),r.jsxs("feMerge",{children:[r.jsx("feMergeNode",{in:"blur"}),r.jsx("feMergeNode",{in:"SourceGraphic"})]})]})]}),r.jsxs("g",{className:"s-warroom-map-grid","aria-hidden":"true",children:[Array.from({length:13}).map((j,N)=>r.jsx("line",{x1:N*84,y1:"0",x2:N*84,y2:"620"},`v-${N}`)),Array.from({length:8}).map((j,N)=>r.jsx("line",{x1:"0",y1:N*88,x2:"1000",y2:N*88},`h-${N}`))]}),r.jsx("g",{className:"s-warroom-map-projects",children:e.projects.map((j,N)=>r.jsxs("g",{transform:`translate(${760+N%2*100}, ${72+Math.floor(N/2)*38})`,children:[r.jsx("rect",{width:"86",height:"22",rx:"4"}),r.jsx("text",{x:"8",y:"14",children:j.name.slice(0,12)}),r.jsx("text",{x:"72",y:"14",textAnchor:"end",children:j.count})]},j.name))}),r.jsx("g",{className:"s-warroom-map-links",children:e.visibleEdges.map((j,N)=>r.jsx("line",{x1:j.from.x,y1:j.from.y,x2:j.to.x,y2:j.to.y,opacity:Math.max(.18,.72-N*.02)},`${j.id}:line:${N}`))}),r.jsx("g",{className:"s-warroom-map-packets",filter:"url(#warroomPacketGlow)",children:e.visibleEdges.slice(0,18).map((j,N)=>{const k=`M ${j.from.x} ${j.from.y} L ${j.to.x} ${j.to.y}`;return r.jsxs("g",{children:[r.jsx("circle",{className:"s-warroom-packet",r:N<5?4.2:3.2,children:r.jsx("animateMotion",{dur:`${4.2+N%5*.42}s`,begin:`${-(N*.33)}s`,repeatCount:"indefinite",path:k})}),N<7&&r.jsx("circle",{className:"s-warroom-packet s-warroom-packet--ghost",r:"8",children:r.jsx("animateMotion",{dur:`${4.2+N%5*.42}s`,begin:`${-(N*.33)}s`,repeatCount:"indefinite",path:k})})]},`${j.id}:packet:${N}`)})}),r.jsx("g",{className:"s-warroom-map-nodes",children:m.map(j=>{const N=!!j.route;return r.jsxs("g",{className:`s-warroom-map-node s-warroom-map-node--${j.kind}${N?" s-warroom-map-node--actionable":""}`,transform:`translate(${j.x}, ${j.y})`,role:N?"button":void 0,tabIndex:N?0:void 0,onClick:j.route?()=>i(j.route):void 0,onKeyDown:j.route?k=>{k.key!=="Enter"&&k.key!==" "||(k.preventDefault(),i(j.route))}:void 0,children:[r.jsx("title",{children:j.route?`Open ${j.label}`:j.label}),r.jsx("circle",{className:"s-warroom-map-node-glow",r:22+Math.min(16,j.weight*2)}),r.jsx("circle",{className:"s-warroom-map-node-core",r:j.kind==="operator"||j.kind==="broker"?20:15,fill:gt(j.label)}),r.jsx("text",{className:"s-warroom-map-node-initial",y:"4",textAnchor:"middle",children:j.label[0]?.toUpperCase()}),r.jsx("text",{className:"s-warroom-map-node-label",y:j.kind==="agent"||j.kind==="external"?33:40,textAnchor:"middle",children:j.label}),r.jsx("text",{className:"s-warroom-map-node-detail",y:j.kind==="agent"||j.kind==="external"?47:54,textAnchor:"middle",children:j.detail})]},j.id)})})]}),r.jsxs("div",{className:"s-warroom-map-caption",children:[r.jsxs("span",{children:[e.nodes.length," nodes"]}),r.jsxs("span",{children:[e.edges.length," messages / ",za(n)]}),r.jsxs("span",{children:["latest ",p?ml(p.ts,t):"none"," ago"]})]})]}),r.jsxs("div",{className:"s-warroom-flow-ledger",children:[r.jsxs("div",{className:"s-warroom-flow-ledger-head",children:[r.jsx("span",{children:"Window message flow"}),r.jsxs("span",{children:[e.visibleEdges.length," routes"]})]}),r.jsx("div",{className:"s-warroom-flow-list",children:e.edges.length===0?r.jsxs("div",{className:"s-warroom-empty",children:["No messages in the last ",za(n),"."]}):e.edges.slice(0,10).map(j=>r.jsx(Jee,{edge:j,active:d.has(j.id),selected:j.id===s,nodeLabels:h,onSelect:()=>c(j.id)},j.id))})]})]})}function Jee({edge:e,active:t,selected:n,nodeLabels:s,onSelect:i}){const l=r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"s-warroom-flow-route",children:[s.get(e.fromId)??Yc(e.fromId,new Map)," ",r.jsx("span",{children:"→"})," ",s.get(e.toId)??Yc(e.toId,new Map)]}),r.jsx("span",{className:"s-warroom-flow-kind",children:_h(e.kind)}),r.jsx("span",{className:"s-warroom-flow-title",children:e.label})]});return r.jsx("button",{type:"button",className:`s-warroom-flow-row${t?" s-warroom-flow-row--active":""}${n?" s-warroom-flow-row--selected":""}`,onClick:i,children:l})}function Qee({edge:e,nodeLabels:t,nowMs:n,navigate:s}){const i=t.get(e.fromId)??Yc(e.fromId,new Map),l=t.get(e.toId)??Yc(e.toId,new Map);return r.jsxs("section",{className:"s-warroom-inspector-card",children:[r.jsxs("div",{className:"s-warroom-inspector-title",children:[i," ","->"," ",l]}),r.jsxs("div",{className:"s-warroom-inspector-meta",children:[r.jsx("span",{children:_h(e.kind)}),r.jsxs("span",{children:[ml(e.ts,n)," ago"]})]}),r.jsx("div",{className:"s-warroom-inspector-body",children:e.label}),r.jsx("div",{className:"s-warroom-actions",children:e.route?r.jsx("button",{type:"button",className:"s-warroom-action",onClick:()=>s(e.route),children:"Open conversation"}):r.jsx("span",{className:"s-warroom-empty",children:"No route available."})})]})}function ete({item:e,nowMs:t,navigate:n}){return r.jsxs("section",{className:"s-warroom-inspector-card",children:[r.jsx("div",{className:"s-warroom-inspector-title",children:e.title}),r.jsxs("div",{className:"s-warroom-inspector-meta",children:[e.pill," / updated ",ml(e.updatedAt,t)," ago"]}),r.jsx("div",{className:"s-warroom-inspector-body",children:e.summary}),r.jsx("div",{className:"s-warroom-inspector-meta",children:e.meta.filter(Boolean).map((s,i)=>r.jsx("span",{children:s},`${e.key}:inspector-meta:${i}`))}),r.jsx("div",{className:"s-warroom-actions",children:e.actions.length===0?r.jsx("span",{className:"s-warroom-empty",children:"No route available."}):e.actions.map(s=>r.jsx("button",{type:"button",className:"s-warroom-action",onClick:()=>n(s.route),children:s.label},s.label))})]})}const tte=[{id:"command",label:"Command"},{id:"mission",label:"Control"},{id:"plan",label:"Plan"},{id:"conductor",label:"Conduct"},{id:"tail",label:"Tail"},{id:"atop",label:"Atop"},{id:"agents",label:"Agents"}];function nte({navigate:e,mode:t="command",tailQuery:n}){const{agents:s}=ht();return r.jsxs("div",{className:"s-ops",children:[r.jsxs("div",{className:"s-ops-header",children:[r.jsx("span",{className:"s-ops-header-title",children:"Ops"}),r.jsx("div",{className:"s-ops-tabs",children:tte.map(i=>r.jsx("button",{className:`s-ops-tab${t===i.id?" s-ops-tab--active":""}`,onClick:()=>e({view:"ops",mode:i.id}),children:i.label},i.id))})]}),r.jsxs("div",{className:"s-ops-body",children:[t==="mission"&&r.jsx(LJ,{navigate:e,agents:s}),t==="agents"&&r.jsx(sQ,{navigate:e,agents:s}),t==="plan"&&r.jsx(kQ,{navigate:e,agents:s}),t==="conductor"&&r.jsx(fJ,{navigate:e,agents:s}),t==="command"&&r.jsx(Yee,{navigate:e,agents:s}),t==="tail"&&r.jsx(gee,{navigate:e,initialFilter:n}),t==="atop"&&r.jsx(GQ,{})]})]})}function ste({agentId:e,navigate:t}){const{agents:n}=ht(),s=e?n.find(d=>d.id===e):null,i=s?gt(s.name):"var(--accent)",l=_y({url:ER(),healthUrl:CR(),autoConnect:!0,sessionKey:e?`scout-takeover-${e}`:"scout-takeover"}),c=()=>{t(e?{view:"agents",agentId:e}:{view:"inbox"})};return r.jsxs("div",{className:"s-term",children:[r.jsxs("div",{className:"s-term-bar",children:[r.jsx("button",{className:"s-term-back",onClick:c,children:"← Back"}),s&&r.jsxs("div",{className:"s-term-agent",children:[r.jsx("div",{className:"s-ops-avatar",style:{"--size":"18px",background:i},children:s.name[0]?.toUpperCase()}),r.jsx("span",{className:"s-term-agent-name",children:s.name}),s.handle&&r.jsxs("span",{className:"s-term-agent-handle",children:["@",s.handle]})]}),r.jsx("span",{className:"s-term-label",children:"TAKEOVER"}),r.jsxs("div",{className:"s-term-status",children:[r.jsx("span",{className:`s-term-dot${l.status==="connected"?" s-term-dot--live":l.status==="connecting"?" s-term-dot--connecting":""}`}),l.status==="connected"?"LIVE":l.status==="connecting"?"CONNECTING":"OFFLINE"]})]}),r.jsx("div",{className:"s-term-body",children:r.jsx(Oy,{relay:l,fontSize:13,quiet:!0})})]})}function ate(e){return e.attention==="interrupt"?"failed":e.state==="done"?"completed":e.attention==="badge"||e.state==="waiting"||e.state==="review"?"updated":"working"}function Jg(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 rte(e){switch(e){case"badge":return"Needs attention";case"interrupt":return"Blocked";default:return null}}function ite(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 sE(e){return e.kind==="message"?"message":e.kind==="flight_started"?"flight":e.kind==="flight_completed"?e.detailKind?.includes("fail")?"alert":"done":e.detailKind?.includes("interrupt")||e.detailKind?.includes("block")?"alert":"system"}function Qg({title:e,items:t}){return t.length===0?null:r.jsxs("section",{className:"s-work-fact-card",children:[r.jsx("div",{className:"s-work-fact-card-header",children:r.jsx("div",{className:"s-work-fact-card-title",children:e})}),r.jsx("div",{className:"s-work-fact-card-body",children:t.map(n=>r.jsxs("div",{className:"s-work-fact-row",children:[r.jsx("span",{className:"s-work-fact-label",children:n.label}),r.jsx("span",{className:"s-work-fact-value",children:n.value})]},n.label))})]})}function aE({label:e,value:t,onClick:n}){return r.jsxs("button",{type:"button",className:"s-work-action-row",onClick:n,children:[r.jsx("span",{className:"s-work-action-row-label",children:e}),r.jsx("span",{className:"s-work-action-row-value",children:t})]})}function ote(e){const t=e.split(".");return t[t.length-1]||e}function lte({workId:e,navigate:t}){const[n,s]=g.useState(null),[i,l]=g.useState(null),[c,d]=g.useState(!1),h=g.useCallback(async()=>{l(null);try{const N=await ke(`/api/work/${encodeURIComponent(e)}`);s(N)}catch(N){l(N instanceof Error?N.message:String(N)),s(null)}finally{d(!0)}},[e]);if(g.useEffect(()=>{d(!1),h()},[h]),Kt(()=>{h()}),!c)return r.jsxs("div",{children:[r.jsx("button",{type:"button",className:"s-back",onClick:()=>t({view:"inbox"}),children:"← Back"}),r.jsx("div",{className:"s-empty",children:r.jsx("p",{children:"Loading…"})})]});if(!n)return r.jsxs("div",{className:"s-work-not-found",children:[r.jsx("button",{type:"button",className:"s-back",onClick:()=>t({view:"inbox"}),children:"← Back to inbox"}),r.jsxs("div",{className:"s-work-not-found-body",children:[r.jsx("div",{className:"s-work-not-found-glyph","aria-hidden":"true",children:"□"}),r.jsx("h2",{className:"s-work-not-found-title",children:"Work item not found"}),r.jsx("p",{className:"s-work-not-found-sub",children:"This work item may have been removed or does not exist on this broker."}),i&&r.jsx("p",{className:"s-work-not-found-detail",children:i})]})]});const m=rte(n.attention),p=n.ownerName??n.ownerId??"Unassigned",y=n.nextMoveOwnerName??n.nextMoveOwnerId??"—",x=[{label:"State",value:Jg(n.state)},{label:"Acceptance",value:n.acceptanceState.replace(/_/g," ")},{label:"Phase",value:n.currentPhase},...m?[{label:"Attention",value:m}]:[]],w=[{label:"Owner",value:p},{label:"Next move",value:y},...n.priority?[{label:"Priority",value:n.priority}]:[],{label:"Conversation",value:n.conversationId?"Attached":"None"}],j=[{label:"Case ID",value:n.id},{label:"Created",value:la(n.createdAt)},{label:"Updated",value:la(n.updatedAt)},{label:"Last activity",value:la(n.lastMeaningfulAt)}];return r.jsxs("div",{className:"s-work-detail s-work-casefile",children:[r.jsxs("div",{className:"s-work-casefile-topbar",children:[r.jsx("button",{type:"button",className:"s-back",onClick:()=>t({view:"inbox"}),children:"← Back"}),r.jsxs("span",{className:"s-work-casefile-record",children:["Case ",ote(n.id)]})]}),i&&r.jsx("p",{className:"s-error",children:i}),r.jsx("section",{className:"s-work-casefile-hero",children:r.jsxs("div",{className:"s-work-casefile-hero-main",children:[r.jsxs("div",{className:"s-work-casefile-title-row",children:[r.jsx("h1",{className:"s-work-casefile-title",children:n.title}),r.jsx("span",{className:`s-pill s-pill-${ate(n)}`,children:n.currentPhase})]}),n.lastMeaningfulSummary&&r.jsx("div",{className:"s-work-casefile-summary",children:fs(n.lastMeaningfulSummary)}),r.jsxs("div",{className:"s-work-casefile-meta",children:[r.jsxs("span",{children:["Updated ",De(n.updatedAt)]}),r.jsx("span",{children:p}),r.jsx("span",{children:Jg(n.state)}),m&&r.jsx("span",{children:m}),n.priority&&r.jsxs("span",{children:["Priority ",n.priority]})]})]})}),r.jsxs("div",{className:"s-work-casefile-layout",children:[r.jsxs("div",{className:"s-work-casefile-main",children:[r.jsxs("section",{className:"s-work-casefile-section",children:[r.jsx("div",{className:"s-agent-section-heading",children:r.jsx("h2",{className:"s-agent-section-title",children:"Case facts"})}),r.jsxs("div",{className:"s-work-fact-grid",children:[r.jsx(Qg,{title:"Status",items:x}),r.jsx(Qg,{title:"Assignment",items:w})]})]}),n.activeFlights.length>0&&r.jsxs("section",{className:"s-work-casefile-section",children:[r.jsx("div",{className:"s-agent-section-heading",children:r.jsx("h2",{className:"s-agent-section-title",children:"Flights"})}),r.jsx("div",{className:"s-work-flight-list",children:n.activeFlights.map(N=>r.jsxs("button",{type:"button",className:"s-work-flight-card",onClick:N.conversationId?()=>t({view:"conversation",conversationId:N.conversationId}):void 0,disabled:!N.conversationId,children:[r.jsxs("div",{className:"s-work-flight-card-header",children:[r.jsx("span",{className:"s-work-flight-card-title",children:N.agentName??N.agentId}),r.jsx("span",{className:"s-pill s-pill-working",children:N.state})]}),r.jsxs("div",{className:"s-work-flight-card-meta",children:[r.jsx("span",{children:N.startedAt?`Started ${De(N.startedAt)}`:"Start time unavailable"}),N.completedAt&&r.jsxs("span",{children:["Completed ",De(N.completedAt)]})]}),N.summary&&r.jsx("div",{className:"s-work-flight-card-copy",children:N.summary})]},N.id))})]}),n.childWork.length>0&&r.jsxs("section",{className:"s-work-casefile-section",children:[r.jsx("div",{className:"s-agent-section-heading",children:r.jsx("h2",{className:"s-agent-section-title",children:"Child work"})}),r.jsx("div",{className:"s-work-related-list",children:n.childWork.map(N=>r.jsxs("button",{type:"button",className:"s-work-related-card",onClick:()=>t({view:"work",workId:N.id}),children:[r.jsxs("div",{className:"s-work-related-card-header",children:[r.jsx("span",{className:"s-work-related-card-title",children:N.title}),r.jsx("span",{className:`s-pill s-pill-${N.attention==="interrupt"?"failed":"updated"}`,children:N.currentPhase})]}),r.jsxs("div",{className:"s-work-related-card-meta",children:[r.jsx("span",{children:N.ownerName??N.ownerId??"Unassigned"}),r.jsx("span",{children:Jg(N.state)}),r.jsx("span",{children:De(N.lastMeaningfulAt)})]}),N.lastMeaningfulSummary&&r.jsx("div",{className:"s-work-related-card-copy",children:fs(N.lastMeaningfulSummary)})]},N.id))})]}),r.jsxs("section",{className:"s-work-casefile-section",children:[r.jsx("div",{className:"s-agent-section-heading",children:r.jsx("h2",{className:"s-agent-section-title",children:"Timeline"})}),n.timeline.length===0?r.jsxs("div",{className:"s-empty",children:[r.jsx("p",{children:"No activity yet."}),r.jsx("p",{children:"Timeline events will appear once the case receives messages or coordination updates."})]}):r.jsx("div",{className:"s-work-timeline",children:n.timeline.map(N=>r.jsxs("button",{type:"button",className:`s-work-timeline-entry${N.conversationId?" s-work-timeline-entry-clickable":""}`,onClick:N.conversationId?()=>t({view:"conversation",conversationId:N.conversationId}):void 0,disabled:!N.conversationId,children:[r.jsx("span",{className:`s-work-timeline-marker s-work-timeline-marker-${sE(N)}`}),r.jsxs("div",{className:"s-work-timeline-content",children:[r.jsxs("div",{className:"s-work-timeline-header",children:[r.jsx("span",{className:"s-work-timeline-time",children:De(N.at)}),r.jsx("span",{className:`s-work-timeline-kind s-work-timeline-kind-${sE(N)}`,children:ite(N)})]}),r.jsx("div",{className:"s-work-timeline-actor",children:N.actorName??"system"}),N.title&&r.jsx("div",{className:"s-work-timeline-title",children:N.title}),N.summary&&r.jsx("div",{className:"s-work-timeline-summary",children:fs(N.summary)}),r.jsx("div",{className:"s-work-timeline-stamp",children:la(N.at)})]})]},N.id))})]})]}),r.jsxs("aside",{className:"s-work-casefile-side",children:[r.jsx(Qg,{title:"Record",items:j}),r.jsxs("section",{className:"s-work-fact-card",children:[r.jsx("div",{className:"s-work-fact-card-header",children:r.jsx("div",{className:"s-work-fact-card-title",children:"Links"})}),r.jsxs("div",{className:"s-work-action-list",children:[n.conversationId?r.jsx(aE,{label:"Conversation",value:"Open thread",onClick:()=>t({view:"conversation",conversationId:n.conversationId})}):r.jsx("div",{className:"s-work-action-list-empty",children:"No conversation attached."}),n.parentId&&n.parentTitle?r.jsx(aE,{label:"Parent",value:n.parentTitle,onClick:()=>t({view:"work",workId:n.parentId})}):r.jsx("div",{className:"s-work-action-list-empty",children:"No parent work item."})]})]})]})]})]})}function cte(){const{route:e,navigate:t}=ht();return r.jsx(ute,{children:dte(e,t)})}function ute({children:e}){return r.jsx("div",{style:{background:"var(--bg)",color:"var(--ink)",minHeight:"100%",height:"100%",display:"flex",flexDirection:"column"},children:e})}function dte(e,t){switch(e.view){case"conversation":return r.jsx(Ix,{conversationId:e.conversationId,initialComposeMode:e.composeMode,initialDraft:e.composeDraft,navigate:t});case"agent-info":return r.jsx(WW,{conversationId:e.conversationId,navigate:t});case"settings":return r.jsx(nJ,{navigate:t});case"agents":return r.jsx(uG,{navigate:t,selectedAgentId:e.agentId,conversationId:e.conversationId,tab:e.tab});case"fleet":return r.jsx(jk,{navigate:t});case"conversations":return r.jsx(DG,{navigate:t});case"sessions":return e.sessionId?r.jsx(RX,{sessionRef:e.sessionId,navigate:t}):r.jsx(MX,{navigate:t});case"channels":return r.jsx(_G,{channelId:e.channelId,navigate:t});case"mesh":return r.jsx(gK,{navigate:t});case"broker":return r.jsx(bG,{navigate:t});case"activity":return r.jsx(FW,{navigate:t});case"ops":return r.jsx(nte,{navigate:t,mode:e.mode,tailQuery:e.tailQuery});case"terminal":return r.jsx(ste,{agentId:e.agentId,navigate:t});case"work":return r.jsx(lte,{workId:e.workId,navigate:t});case"follow":return r.jsx(zG,{route:e,navigate:t});default:return r.jsx(jk,{navigate:t})}}function fte(){const{route:e,agents:t,navigate:n}=ht();if(e.view!=="agents")return null;const s=e.agentId?t.find(i=>i.id===e.agentId)??null:null;if(!s){const i=t.filter(l=>_r(l.state)).length;return r.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[r.jsx(ia,{label:"Total",value:`${t.length}`}),r.jsx(ia,{label:"Working",value:`${i}`}),r.jsx(ia,{label:"Available",value:`${t.length-i}`}),r.jsx("div",{className:"mt-2 text-[10px] font-mono uppercase tracking-[0.15em] leading-relaxed text-[var(--scout-chrome-ink-ghost)]",children:"Select an agent from the roster to see its context here."})]})}return r.jsx(hte,{agent:s,agents:t,navigate:n})}function hte({agent:e,agents:t,navigate:n}){const s=_r(e.state),[i,l]=g.useState(null),c=g.useCallback(async()=>{const d=await ke("/api/fleet").catch(()=>null);d&&l(d)},[]);return g.useEffect(()=>{c()},[c]),Kt(()=>{c()}),r.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[r.jsxs("div",{className:"flex items-center gap-3 border-b border-[var(--scout-chrome-border-soft)] pb-3",children:[r.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:gt(e.name)},children:[e.name[0]?.toUpperCase()??"?",s&&r.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:Gs(e.state),opacity:Xe(e.state)==="working"?.85:.6}})]}),r.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[r.jsx("span",{className:"truncate text-[13px] text-[var(--scout-chrome-ink-strong)]",children:e.name}),e.handle&&r.jsxs("span",{className:"text-[10px] font-mono text-cyan-400/70",children:["@",e.handle]})]})]}),r.jsxs(Do,{label:"State",children:[r.jsxs("div",{className:"flex items-baseline gap-2",children:[r.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:Gs(e.state),opacity:s?1:.4}}),r.jsx("span",{className:"text-[12px] capitalize text-[var(--scout-chrome-ink)]",children:Hn(e.state)})]}),e.updatedAt&&r.jsxs("div",{className:"mt-1 text-[10px] font-mono text-[var(--scout-chrome-ink-faint)]",children:["Updated ",De(e.updatedAt)]})]}),r.jsx(Do,{label:"Presence",children:r.jsx(mte,{focusAgent:e,agents:t,navigate:n})}),i&&r.jsx(pte,{asks:i.activeAsks,agentId:e.id,navigate:n}),r.jsxs(Do,{label:"Identity",children:[r.jsx(ia,{label:"Class",value:e.agentClass}),e.role&&r.jsx(ia,{label:"Role",value:e.role}),e.harness&&r.jsx(ia,{label:"Harness",value:e.harness}),e.transport&&r.jsx(ia,{label:"Transport",value:e.transport})]}),(e.project||e.branch||e.cwd)&&r.jsxs(Do,{label:"Project",children:[e.project&&r.jsx(ia,{label:"Name",value:e.project}),e.branch&&r.jsx(ia,{label:"Branch",value:e.branch}),e.cwd&&r.jsx(ia,{label:"Cwd",value:e.cwd})]}),e.capabilities.length>0&&r.jsx(Do,{label:`Capabilities · ${e.capabilities.length}`,children:r.jsx("div",{className:"flex flex-wrap gap-1",children:e.capabilities.map(d=>r.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:d},d))})})]})}function mte({focusAgent:e,agents:t,navigate:n}){const h=t.filter(p=>p.id!==e.id).slice(0,8),m=g.useMemo(()=>{const p=[{agent:e,x:120,y:90,focused:!0}];return h.forEach((y,x)=>{const w=2*Math.PI*x/Math.max(h.length,1)-Math.PI/2;p.push({agent:y,x:120+68*Math.cos(w),y:90+68*Math.sin(w),focused:!1})}),p},[e,h,120,90,68]);return r.jsxs("svg",{viewBox:"0 0 240 180",className:"w-full block",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("defs",{children:r.jsxs("radialGradient",{id:"inspMeshGlow",cx:"50%",cy:"50%",r:"50%",children:[r.jsx("stop",{offset:"0%",stopColor:"var(--accent)",stopOpacity:"0.06"}),r.jsx("stop",{offset:"100%",stopColor:"var(--accent)",stopOpacity:"0"})]})}),r.jsx("circle",{cx:120,cy:90,r:82,fill:"url(#inspMeshGlow)"}),r.jsx("circle",{cx:120,cy:90,r:68,fill:"none",stroke:"var(--border)",strokeDasharray:"2 4"}),m.slice(1).map((p,y)=>r.jsxs("g",{children:[r.jsx("line",{x1:120,y1:90,x2:p.x,y2:p.y,stroke:"var(--accent)",strokeWidth:1,opacity:.6}),r.jsx("circle",{r:2,fill:"var(--accent)",children:r.jsx("animateMotion",{dur:`${2+y*.3}s`,repeatCount:"indefinite",path:`M 120,90 L ${p.x},${p.y}`})})]},`e-${p.agent.id}`)),m.map(p=>{const y=Xe(p.agent.state),x=y==="working"||y==="available",w=p.focused?14:9;return r.jsxs("g",{style:{cursor:"pointer"},onClick:()=>n({view:"agents",agentId:p.agent.id}),children:[x&&r.jsxs("circle",{cx:p.x,cy:p.y,r:w+5,fill:"none",stroke:gt(p.agent.name),strokeWidth:.8,opacity:.3,children:[r.jsx("animate",{attributeName:"r",values:`${w};${w+8};${w}`,dur:"2.5s",repeatCount:"indefinite"}),r.jsx("animate",{attributeName:"opacity",values:"0.3;0;0.3",dur:"2.5s",repeatCount:"indefinite"})]}),r.jsx("circle",{cx:p.x,cy:p.y,r:w,fill:gt(p.agent.name),stroke:p.focused?"var(--accent)":"var(--surface)",strokeWidth:p.focused?1.5:1}),r.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()}),r.jsx("text",{x:p.x,y:p.y+w+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)})]})}function pte({asks:e,agentId:t,navigate:n}){const s=e.filter(i=>i.agentId===t&&(i.status==="needs_attention"||i.status==="queued"));return s.length===0?null:r.jsx(Do,{label:`Incoming asks · ${s.length}`,children:r.jsx("div",{className:"flex flex-col gap-2",children:s.map(i=>r.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:()=>{i.conversationId&&n({view:"agents",agentId:t,conversationId:i.conversationId})},children:[r.jsx("div",{className:"text-[9px] font-mono uppercase tracking-[0.12em] text-amber-500/80 mb-1",children:"awaiting"}),r.jsx("div",{className:"line-clamp-2 text-[11px] leading-relaxed text-[var(--scout-chrome-ink)]",children:i.summary??i.task}),r.jsxs("div",{className:"mt-1.5 text-[9px] font-mono text-[var(--scout-chrome-ink-ghost)]",children:[i.harness??"operator"," → ",i.agentName??"agent"]})]},i.invocationId))})})}function Do({label:e,children:t}){return r.jsxs("div",{className:"flex flex-col",children:[r.jsx("div",{className:"mb-1.5 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),t]})}function ia({label:e,value:t}){return r.jsxs("div",{className:"flex items-baseline justify-between py-0.5 gap-2",children:[r.jsx("span",{className:"shrink-0 text-[10px] font-mono uppercase tracking-wider text-[var(--scout-chrome-ink-faint)]",children:e}),r.jsx("span",{className:"truncate text-[11px] font-mono text-[var(--scout-chrome-ink)]",children:t})]})}function gte(){const{agents:e,navigate:t}=ht();if(e.length===0)return r.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:[r.jsx("div",{className:"mb-1 uppercase tracking-[0.15em]",children:"No agents"}),r.jsx("div",{children:"Connect an agent to see your roster here."})]});const n=e.filter(i=>_r(i.state)),s=e.filter(i=>!_r(i.state));return r.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[n.length>0&&r.jsx(rE,{label:"Online",count:n.length,children:n.map(i=>r.jsx(iE,{agent:i,navigate:t},i.id))}),s.length>0&&r.jsx(rE,{label:"Standby",count:s.length,children:s.map(i=>r.jsx(iE,{agent:i,navigate:t,dim:!0},i.id))})]})}function rE({label:e,count:t,children:n}){return r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"flex items-baseline justify-between mb-1.5",children:[r.jsx("span",{className:"text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),r.jsx("span",{className:"text-[9px] font-mono tabular-nums text-[var(--scout-chrome-ink-ghost)]",children:t})]}),r.jsx("div",{className:"flex flex-col gap-0.5",children:n})]})}function iE({agent:e,navigate:t,dim:n}){const s=_r(e.state);return r.jsxs("button",{onClick:()=>t({view:"agents",agentId:e.id}),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:[r.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:gt(e.name)},children:[e.name[0]?.toUpperCase()??"?",s&&r.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)]"})]}),r.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[r.jsx("span",{className:"truncate text-[12px] text-[var(--scout-chrome-ink)] transition-colors group-hover:text-[var(--scout-chrome-ink-strong)]",children:e.name}),r.jsx("span",{className:"truncate text-[10px] font-mono text-[var(--scout-chrome-ink-faint)]",children:Hn(e.state)})]}),e.updatedAt&&r.jsx("span",{className:"shrink-0 text-[9px] font-mono tabular-nums text-[var(--scout-chrome-ink-ghost)]",children:De(e.updatedAt)})]})}function vte(){const{route:e}=ht(),[t,n]=g.useState([]),s=g.useCallback(async()=>{try{n(await ke("/api/sessions"))}catch{}},[]);if(g.useEffect(()=>{s()},[s]),Kt(()=>{s()}),e.view!=="sessions")return null;const i=e.sessionId?t.find(l=>l.id===e.sessionId)??null:null;if(!i){const l=new Set(t.map(d=>d.kind)),c=t.filter(d=>d.currentBranch).length;return r.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[r.jsx(na,{label:"Total",value:`${t.length}`}),r.jsx(na,{label:"Kinds",value:`${l.size}`}),r.jsx(na,{label:"Branched",value:`${c}`}),r.jsx("div",{className:"mt-2 text-[10px] font-mono uppercase tracking-[0.15em] leading-relaxed text-[var(--scout-chrome-ink-ghost)]",children:"Select a session from the list to see its context here."})]})}return r.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[r.jsxs("div",{className:"border-b border-[var(--scout-chrome-border-soft)] pb-3",children:[r.jsx("div",{className:"text-[13px] leading-snug text-[var(--scout-chrome-ink-strong)]",children:i.title}),r.jsx("div",{className:"text-[10px] font-mono uppercase tracking-wider text-cyan-400/70 mt-1",children:i.kind})]}),i.agentName&&r.jsxs(Jd,{label:"Agent",children:[r.jsx(na,{label:"Name",value:i.agentName}),i.harness&&r.jsx(na,{label:"Harness",value:i.harness})]}),(i.currentBranch||i.workspaceRoot)&&r.jsxs(Jd,{label:"Workspace",children:[i.currentBranch&&r.jsx(na,{label:"Branch",value:i.currentBranch}),i.workspaceRoot&&r.jsx(na,{label:"Root",value:i.workspaceRoot})]}),r.jsxs(Jd,{label:"Activity",children:[r.jsx(na,{label:"Messages",value:`${i.messageCount}`}),i.lastMessageAt&&r.jsx(na,{label:"Last",value:De(i.lastMessageAt)}),i.participantIds.length>0&&r.jsx(na,{label:"Participants",value:`${i.participantIds.length}`})]}),i.preview&&r.jsx(Jd,{label:"Preview",children:r.jsxs("div",{className:"text-[11px] italic leading-relaxed text-[var(--scout-chrome-ink-soft)]",children:['"',i.preview,'"']})})]})}function Jd({label:e,children:t}){return r.jsxs("div",{className:"flex flex-col",children:[r.jsx("div",{className:"mb-1.5 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),t]})}function na({label:e,value:t}){return r.jsxs("div",{className:"flex items-baseline justify-between py-0.5 gap-2",children:[r.jsx("span",{className:"shrink-0 text-[10px] font-mono uppercase tracking-wider text-[var(--scout-chrome-ink-faint)]",children:e}),r.jsx("span",{className:"truncate text-[11px] font-mono text-[var(--scout-chrome-ink)]",children:t})]})}function yte(){const{route:e}=ht(),t=e.view==="work"?e.workId:null,[n,s]=g.useState(null),i=g.useCallback(async()=>{if(!t){s(null);return}try{s(await ke(`/api/work/${encodeURIComponent(t)}`))}catch{s(null)}},[t]);if(g.useEffect(()=>{i()},[i]),Kt(()=>{t&&i()}),e.view!=="work")return null;if(!n)return r.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 l=bte(n.state);return r.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[r.jsxs("div",{className:"border-b border-[var(--scout-chrome-border-soft)] pb-3",children:[r.jsxs("div",{className:"text-[9px] font-mono uppercase tracking-[0.15em] text-cyan-400/70 mb-1",children:["Case ",xte(n.id)]}),r.jsx("div",{className:"text-[13px] leading-snug text-[var(--scout-chrome-ink-strong)]",children:n.title})]}),r.jsxs(Qd,{label:"State",children:[r.jsxs("div",{className:"flex items-baseline gap-2",children:[r.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${l.dot}`}),r.jsx("span",{className:`text-[12px] capitalize ${l.text}`,children:n.state.replace(/_/g," ")})]}),r.jsxs("div",{className:"mt-1 text-[10px] font-mono text-[var(--scout-chrome-ink-faint)]",children:["Phase · ",n.currentPhase]})]}),r.jsxs(Qd,{label:"Ownership",children:[n.ownerName&&r.jsx(Ao,{label:"Owner",value:n.ownerName}),n.nextMoveOwnerName&&r.jsx(Ao,{label:"Next move",value:n.nextMoveOwnerName}),n.priority&&r.jsx(Ao,{label:"Priority",value:n.priority})]}),r.jsxs(Qd,{label:"Activity",children:[r.jsx(Ao,{label:"Children",value:`${n.activeChildWorkCount}`}),r.jsx(Ao,{label:"Flights",value:`${n.activeFlightCount}`}),n.lastMeaningfulAt&&r.jsx(Ao,{label:"Last update",value:De(n.lastMeaningfulAt)})]}),n.attention!=="silent"&&r.jsx("div",{className:`text-[10px] font-mono uppercase tracking-wider px-2 py-1 rounded-sm ${n.attention==="interrupt"?"text-red-300/90 bg-red-500/10 border border-red-500/20":"text-amber-300/90 bg-amber-500/10 border border-amber-500/20"}`,children:n.attention==="interrupt"?"Interrupt":"Needs attention"}),n.lastMeaningfulSummary&&r.jsx(Qd,{label:"Latest",children:r.jsx("div",{className:"text-[11px] italic leading-relaxed text-[var(--scout-chrome-ink-soft)]",children:n.lastMeaningfulSummary})})]})}function xte(e){return e.length>10?`${e.slice(0,8)}…`:e}function bte(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 Qd({label:e,children:t}){return r.jsxs("div",{className:"flex flex-col",children:[r.jsx("div",{className:"mb-1.5 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),t]})}function Ao({label:e,value:t}){return r.jsxs("div",{className:"flex items-baseline justify-between py-0.5 gap-2",children:[r.jsx("span",{className:"shrink-0 text-[10px] font-mono uppercase tracking-wider text-[var(--scout-chrome-ink-faint)]",children:e}),r.jsx("span",{className:"truncate text-[11px] font-mono text-[var(--scout-chrome-ink)]",children:t})]})}function wte(e){return e?e.replace(/^https?:\/\//,"").split("/")[0]??e:"Unavailable"}function jte(e){return e.split("/")[0]}function Nte(){const{meshSnapshot:e,selectedId:t,selectedType:n,probeCache:s}=Mh(),[i,l]=g.useState(!1),c=g.useCallback(async()=>{l(!0);try{const m=await ke("/api/mesh/announce",{method:"POST",body:"{}"});oy(m)}finally{l(!1)}},[]);if(!e)return r.jsx("div",{className:"sys-inspector-empty",children:r.jsx("p",{children:"Loading mesh…"})});if(t?.startsWith("tailnet:")&&n==="node"){const m=t.slice(8),p=e.tailscale.peers.find(j=>j.id===m),y=s[t]??null,x=p?.addresses?.[0]?jte(p.addresses[0]):null,w=p?.hostName?.split(".")[0]??p?.hostName??"Tailnet peer";return r.jsxs("div",{className:"sys-inspector-content",children:[r.jsxs("div",{className:"sys-inspector-head",children:[r.jsx("h3",{className:"sys-inspector-title",children:w}),r.jsx("span",{className:`sys-chip sys-chip-${p?.online?"success":"failed"}`,children:p?.online?"Online":"Offline"})]}),r.jsxs("div",{className:"sys-detail-grid",children:[x&&r.jsxs("div",{className:"sys-detail-card",children:[r.jsx("span",{className:"sys-detail-label",children:"Address"}),r.jsx("code",{className:"sys-detail-value",children:x})]}),p?.os&&r.jsxs("div",{className:"sys-detail-card",children:[r.jsx("span",{className:"sys-detail-label",children:"Platform"}),r.jsx("span",{className:"sys-detail-value",children:p.os})]}),y?.result?.node?.meshId&&r.jsxs("div",{className:"sys-detail-card",children:[r.jsx("span",{className:"sys-detail-label",children:"Mesh ID"}),r.jsxs("code",{className:"sys-detail-value",children:[y.result.node.meshId.slice(0,14),"…"]})]}),y?.result?.node?.name&&r.jsxs("div",{className:"sys-detail-card",children:[r.jsx("span",{className:"sys-detail-label",children:"Node name"}),r.jsx("span",{className:"sys-detail-value",children:y.result.node.name})]})]}),(!y||y.status==="loading")&&r.jsx("div",{className:"sys-banner sys-banner-muted",style:{marginTop:8},children:r.jsx("span",{children:"Connecting to Scout broker…"})}),y?.status==="error"&&r.jsxs("div",{className:"sys-banner sys-banner-warning",style:{marginTop:8},children:[r.jsx("strong",{children:"Broker unreachable."}),r.jsx("span",{children:y.result?.error??"Could not reach the remote broker."})]}),y?.status==="done"&&y.result?.node?.capabilities?.length&&r.jsxs("div",{style:{marginTop:10},children:[r.jsx("div",{className:"sys-inspector-section-label",children:"Capabilities"}),r.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:y.result.node.capabilities.map(j=>r.jsx("span",{className:"sys-chip sys-chip-neutral",children:j},j))})]}),y?.status==="done"&&y.result?.home&&r.jsxs("div",{style:{marginTop:14},children:[r.jsxs("div",{className:"sys-inspector-section-label",children:["Agents — ",y.result.home.agents.length," registered"]}),y.result.home.agents.length===0?r.jsx("div",{className:"sys-list-empty",style:{marginTop:4},children:r.jsx("p",{children:"No agents registered on this broker."})}):r.jsx("div",{className:"mesh-agent-table",style:{marginTop:4},children:y.result.home.agents.map(j=>{const N=j.state==="working"?"working":j.state==="available"?"available":"offline";return r.jsxs("div",{className:"mesh-detail-agent",style:{padding:"4px 0"},children:[r.jsx("span",{className:`mesh-detail-dot mesh-detail-dot--${N}`}),r.jsxs("div",{className:"mesh-detail-agent-body",children:[r.jsx("span",{className:"mesh-detail-agent-name",style:{fontSize:12},children:j.title}),j.activeTask&&r.jsx("span",{className:"mesh-detail-agent-task",children:j.activeTask})]}),r.jsx("span",{className:`mesh-detail-agent-state mesh-detail-agent-state--${N}`,children:j.statusLabel||N})]},j.id)})})]}),r.jsx("button",{type:"button",className:"s-btn",style:{marginTop:14},onClick:()=>Jo(null,null),children:"Clear selection"})]})}if(t&&n==="node"){const p=Object.values(e.nodes).find(x=>x.id===t)??(e.localNode?.id===t?e.localNode:null),y=e.localNode?.id===t;return p?r.jsxs("div",{className:"sys-inspector-content",children:[r.jsxs("div",{className:"sys-inspector-head",children:[r.jsx("h3",{className:"sys-inspector-title",children:p.hostName?.split(".")[0]??p.name??"Node"}),y&&r.jsx("span",{className:"sys-chip sys-chip-neutral",children:"this broker"})]}),r.jsxs("div",{className:"sys-detail-grid",children:[r.jsxs("div",{className:"sys-detail-card",children:[r.jsx("span",{className:"sys-detail-label",children:"Node ID"}),r.jsxs("code",{className:"sys-detail-value",children:[p.id.slice(0,16),"…"]})]}),p.brokerUrl&&r.jsxs("div",{className:"sys-detail-card",children:[r.jsx("span",{className:"sys-detail-label",children:"Broker URL"}),r.jsx("code",{className:"sys-detail-value",children:wte(p.brokerUrl)})]}),p.hostName&&r.jsxs("div",{className:"sys-detail-card",children:[r.jsx("span",{className:"sys-detail-label",children:"Host"}),r.jsx("span",{className:"sys-detail-value",children:p.hostName})]}),!y&&"lastSeenAt"in p&&typeof p.lastSeenAt=="number"&&r.jsxs("div",{className:"sys-detail-card",children:[r.jsx("span",{className:"sys-detail-label",children:"Last seen"}),r.jsx("span",{className:"sys-detail-value",children:De(p.lastSeenAt)})]}),!y&&r.jsxs("div",{className:"sys-detail-card",children:[r.jsx("span",{className:"sys-detail-label",children:"Scope"}),r.jsx("span",{className:"sys-detail-value",children:p.advertiseScope==="mesh"?"Announced to mesh":"Local only"})]})]}),y&&e.issues.length>0&&r.jsx("div",{className:"sys-issue-grid",style:{marginTop:12},children:e.issues.map((x,w)=>r.jsxs("article",{className:`sys-issue-card sys-issue-card-${x.severity==="error"?"error":"warning"}`,children:[r.jsx("div",{className:"sys-issue-head",children:r.jsx("h3",{className:"sys-issue-title",children:x.title})}),r.jsx("p",{className:"sys-issue-body",children:x.summary}),x.actionCommand&&r.jsx("div",{className:"sys-issue-action",children:r.jsx("code",{className:"sys-code-inline",children:x.actionCommand})})]},w))}),r.jsx("button",{type:"button",className:"s-btn",style:{marginTop:12},onClick:()=>Jo(null,null),children:"Clear selection"})]}):r.jsxs("div",{className:"sys-inspector-empty",children:[r.jsx("p",{children:"Node not found."}),r.jsx("button",{type:"button",className:"s-btn",onClick:()=>Jo(null,null),children:"Clear"})]})}const d=e,h=d.issues.length>0||d.warnings.length>0;return r.jsxs("div",{className:"sys-inspector-content",children:[r.jsxs("div",{className:"sys-inspector-head",children:[r.jsx("h3",{className:"sys-inspector-title",children:"This broker"}),r.jsx("span",{className:`sys-chip sys-chip-${d.identity.discoverable?"success":"warning"}`,children:d.identity.discoverable?"Discoverable":"Not discoverable"})]}),r.jsxs("div",{className:"sys-detail-grid",children:[r.jsxs("div",{className:"sys-detail-card",children:[r.jsx("span",{className:"sys-detail-label",children:"Name"}),r.jsx("span",{className:"sys-detail-value",children:d.identity.name??d.localNode?.name??"—"})]}),r.jsxs("div",{className:"sys-detail-card",children:[r.jsx("span",{className:"sys-detail-label",children:"Mode"}),r.jsx("span",{className:"sys-detail-value",children:d.identity.modeLabel})]}),r.jsxs("div",{className:"sys-detail-card",children:[r.jsx("span",{className:"sys-detail-label",children:"Mesh ID"}),r.jsx("code",{className:"sys-detail-value",children:d.identity.meshId??"Unassigned"})]}),r.jsxs("div",{className:"sys-detail-card",children:[r.jsx("span",{className:"sys-detail-label",children:"Announced As"}),r.jsx("code",{className:"sys-detail-value",children:d.identity.announceUrl??"Not announced"})]})]}),r.jsxs("div",{className:`sys-banner ${d.identity.discoverable?"sys-banner-success":"sys-banner-muted"}`,style:{marginTop:8},children:[r.jsx("strong",{children:"How peers find you."}),r.jsx("span",{children:d.identity.discoveryDetail})]}),!d.identity.discoverable&&d.health.reachable&&r.jsx("div",{className:"sys-inline-actions",style:{marginTop:12},children:r.jsx("button",{type:"button",className:"s-btn",disabled:i,onClick:()=>{c()},children:i?"Announcing…":"Announce on mesh"})}),h&&r.jsxs("div",{style:{marginTop:12},children:[r.jsx("div",{className:"sys-inspector-section-label",children:"Health notices"}),r.jsx("div",{className:"sys-issue-grid",children:d.issues.map((m,p)=>r.jsxs("article",{className:`sys-issue-card sys-issue-card-${m.severity==="error"?"error":"warning"}`,children:[r.jsx("div",{className:"sys-issue-head",children:r.jsx("h3",{className:"sys-issue-title",children:m.title})}),r.jsx("p",{className:"sys-issue-body",children:m.summary}),m.actionCommand&&r.jsx("div",{className:"sys-issue-action",children:r.jsx("code",{className:"sys-code-inline",children:m.actionCommand})})]},p))})]}),!h&&r.jsxs("div",{className:"sys-list-empty",style:{marginTop:12},children:[r.jsx("h3",{children:"No active mesh warnings"}),r.jsx("p",{children:"The broker is reachable and discovery inputs look healthy."})]})]})}const py="openscout:persistent-state-change";function Ste(e,t){typeof window>"u"||window.dispatchEvent(new CustomEvent(py,{detail:{key:e,value:t}}))}function oE(e){try{return window.localStorage.getItem(e)}catch{return null}}function L2(e,t){try{window.localStorage.setItem(e,t)}catch{}Ste(e,t)}function $2(e){const[t,n]=g.useState(()=>typeof window>"u"?null:oE(e));return g.useEffect(()=>{n(oE(e));const s=l=>{const c=l.detail;!c||c.key!==e||n(c.value)},i=l=>{l.key===e&&n(l.newValue)};return window.addEventListener(py,s),window.addEventListener("storage",i),()=>{window.removeEventListener(py,s),window.removeEventListener("storage",i)}},[e]),t}function gy(e,t){const n=$2(e),s=n===null?t:n==="true",i=g.useCallback(l=>{L2(e,l?"true":"false")},[e]);return[s,i]}function kte(e,t){const n=$2(e),s=n===null?Number.NaN:Number(n),i=Number.isFinite(s)?s:t,l=g.useCallback(c=>{L2(e,String(c))},[e]);return[i,l]}const Ete=43115,Cte=2e3,Ate=500;function Tte(e){return new Mte(e)}class Mte{base;clientId;probeTimeout;pollInterval;_state="unknown";constructor(t){if(t?.baseUrl)this.base=t.baseUrl.replace(/\/$/,"");else{const n=t?.port??Ete;this.base=`http://127.0.0.1:${n}`}this.clientId=t?.clientId??"vox-web",this.probeTimeout=t?.probeTimeout??Cte,this.pollInterval=t?.pollInterval??Ate}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,format:s,language:i,timestamps:l,metadata:c}=t,d=new FormData;if(n instanceof Blob){const m=s??Ite(n.type)??"wav";d.append("audio",n,`audio.${m}`)}else{const m=s??"wav",p=new Blob([n],{type:Ote(m)});d.append("audio",p,`audio.${m}`)}return s&&d.append("format",s),i&&d.append("language",i),l&&d.append("timestamps","true"),d.append("metadata",JSON.stringify(this.withClientMetadata(c))),(await this.fetch("/transcribe",{method:"POST",body:d})).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 Rte(t=>this.openLiveSession(t),t=>this.stopLiveSession(t),t=>this.cancelLiveSession(t))}async getLiveSessionStatus(){const s=(await(await this.fetch("/live")).json()).session;return!s||typeof s!="object"?null:{sessionId:String(s.sessionId??""),connectionId:String(s.connectionId??""),clientId:String(s.clientId??""),modelId:String(s.modelId??""),startedAt:String(s.startedAt??""),state:String(s.state??"error")}}async stopLiveSession(t){const s=await(await this.fetch("/live/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{sessionId:t}:{})})).json();return{stopped:!!s.stopped,sessionId:String(s.sessionId??t??"")}}async cancelLiveSession(t){const s=await(await this.fetch("/live/cancel",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{sessionId:t}:{})})).json();return{cancelled:!!s.cancelled,sessionId:String(s.sessionId??t??"")}}launch(){window.location.href="vox://launch"}openSettings(){window.location.href="vox://settings"}async waitForJob(t){for(let s=0;s<600;s++){const i=await this.getJob(t);if(i.status==="completed"){if(!i.result?.alignment)throw new Ts("Job completed but no alignment result","no_result");return i.result.alignment}if(i.status==="failed")throw new Ts(i.error??"Job failed","job_failed");await _te(this.pollInterval)}throw new Ts("Job timed out","timeout")}async openLiveSession(t){return this.fetch("/live",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:this.clientId,modelId:t?.modelId??"parakeet:v3"})})}withClientMetadata(t){const n=t?{...t}:{};return n.clientId==null&&n.surface==null&&(n.clientId=this.clientId),n}async fetch(t,n){const{timeout:s,...i}=n??{},l=new AbortController,c=s?setTimeout(()=>l.abort(),s):void 0;try{const d=await globalThis.fetch(`${this.base}${t}`,{...i,signal:l.signal});if(!d.ok){const h=await d.text().catch(()=>"");throw new Ts(`${d.status} ${d.statusText}: ${h}`,"http_error")}return d}catch(d){throw d instanceof Ts?d:new Ts(d instanceof Error?d.message:"Companion unreachable","network_error")}finally{c&&clearTimeout(c)}}}class Ts extends Error{code;constructor(t,n){super(t),this.code=n,this.name="VoxDError"}}class Rte{open;stopRequest;cancelRequest;sessionId=null;runPromise=null;finalEvent=null;stateListeners=new Set;partialListeners=new Set;finalListeners=new Set;errorListeners=new Set;constructor(t,n,s){this.open=t,this.stopRequest=n,this.cancelRequest=s}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 Ts("Live session stream did not include a response body.","protocol_error");let s=null;await Dte(n.body,l=>{if(typeof l.error=="string"&&l.error)throw new Ts(l.error,"live_session_error");if(typeof l.event=="string"){this.handleEvent(l.event,lE(l.data));return}l.result&&typeof l.result=="object"&&(s=lE(l.result))});const i=this.finalEvent??this.parseResult(s);if(!i)throw new Ts("Live session ended without a final result.","protocol_error");return i}catch(n){const s=n instanceof Error?n:new Error(String(n));throw this.emitError(s),s}}handleEvent(t,n){switch(t){case"session.state":{const s={sessionId:String(n.sessionId??this.sessionId??""),state:String(n.state??"error"),previous:n.previous??null,reason:typeof n.reason=="string"?n.reason:void 0};s.sessionId&&(this.sessionId=s.sessionId);for(const i of this.stateListeners)i(s);break}case"session.partial":{const s={sessionId:String(n.sessionId??this.sessionId??""),text:String(n.text??"")};s.sessionId&&(this.sessionId=s.sessionId);for(const i of this.partialListeners)i(s);break}case"session.final":{const s=this.parseResult(n);if(!s)return;this.finalEvent=s,this.sessionId=s.sessionId||this.sessionId;for(const i of this.finalListeners)i(s);break}}}parseResult(t){if(!t)return null;if(t.cancelled)throw new Ts(`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:zte(t.metrics)?t.metrics:void 0}}emitError(t){for(const n of this.errorListeners)n(t)}}function _te(e){return new Promise(t=>setTimeout(t,e))}function Ite(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 Ote(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 Dte(e,t){const n=e.getReader(),s=new TextDecoder;let i="";try{for(;;){const{value:c,done:d}=await n.read();if(d)break;i+=s.decode(c,{stream:!0}),i=Pte(i,t)}i+=s.decode();const l=i.trim();l&&t(U2(l))}finally{n.releaseLock()}}function Pte(e,t){let n=e;for(;;){const s=n.indexOf(`
|
|
159
|
-
`);if(s===-1)return n;const i=n.slice(0,s).trim();n=n.slice(s+1),i&&t(U2(i))}}function U2(e){try{return JSON.parse(e)}catch{throw new Ts("Live session stream returned invalid JSON.","protocol_error")}}function lE(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function zte(e){return!!(e&&typeof e=="object")}const Lte="http://127.0.0.1:43115",$te="openscout-web";class ef{constructor(t=Lte){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=hE(n),!1}}launch(t={}){window.location.href=uE("launch",{source:t.source,returnTo:t.returnTo??fE(),context:dE(t.context)})}openSettings(t={}){window.location.href=uE("settings",{source:t.source,returnTo:t.returnTo??fE(),context:dE(t.context)})}async startLive(t={}){const n=this.client.createLiveSession();let s=null;Fte(n,t,l=>{s=l});const i=n.start({modelId:"parakeet:v3"}).then(l=>(s??=B2(l),s)).catch(l=>{throw new Error(hE(l))});return{get sessionId(){return n.id},result:i,stop:async()=>{await n.stop()},cancel:async()=>{await n.cancel().catch(()=>{})}}}createClient(t=1200){return Tte({baseUrl:this.baseUrl,clientId:$te,probeTimeout:t})}}function cE(){const e=new Error("Speech stopped.");return e.name="AbortError",e}function Ute(e){return e instanceof Error&&e.name==="AbortError"}async function Bte(e,t={}){const n=await fetch("/api/voice/speak",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:e}),signal:t.signal});if(!n.ok){const c=await n.text().catch(()=>"");try{const d=JSON.parse(c);throw new Error(d.error??`Voice returned HTTP ${n.status}`)}catch(d){throw d instanceof SyntaxError?new Error(c||`Voice returned HTTP ${n.status}`):d}}const s=await n.json();if(t.signal?.aborted)throw cE();const i=new Audio(`data:${s.contentType};base64,${s.audioBase64}`),l=()=>{i.pause(),i.currentTime=0};t.signal?.addEventListener("abort",l,{once:!0}),await i.play();try{return await new Promise((c,d)=>{const h=()=>{i.removeEventListener("ended",m),i.removeEventListener("error",p),t.signal?.removeEventListener("abort",y)},m=()=>{h(),c()},p=()=>{h(),d(new Error("Vox audio playback failed."))},y=()=>{h(),d(cE())};if(t.signal?.aborted){y();return}i.addEventListener("ended",m,{once:!0}),i.addEventListener("error",p,{once:!0}),t.signal?.addEventListener("abort",y,{once:!0})}),s}finally{t.signal?.removeEventListener("abort",l)}}function Vte(e){const t=new AbortController;return{promise:Bte(e,{signal:t.signal}),stop:()=>t.abort()}}function Fte(e,t,n){e.onState(s=>t.onState?.(s.state)),e.onPartial(s=>t.onPartial?.(s.text)),e.onFinal(s=>{const i=B2(s);n(i),t.onFinal?.(i)})}function B2(e){return{sessionId:e.sessionId,text:e.text.trim(),durationMs:e.durationMs}}function uE(e,t){const n=new URLSearchParams;for(const[i,l]of Object.entries(t))l&&n.set(i,l);const s=n.toString();return s?`vox://${e}?${s}`:`vox://${e}`}function dE(e){if(e)return JSON.stringify(e)}function fE(){try{return window.location.origin}catch{return}}function hE(e){const t=e instanceof Error?e.message:String(e);return e instanceof Ts&&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."}const Hte="What's the state of things? Give me a terse ops summary, the biggest risk, and the next action you recommend.";function qte({height:e}={}){const{agents:t,rangerAgentId:n,rangerConversationId:s,applyRangerUiAction:i,reload:l}=ht(),c=g.useMemo(()=>t.find(_e=>_e.id===n)??t.find(Tx)??null,[t,n]),[d,h]=gy("openscout.ranger.collapsed",!1),[m,p]=g.useState(""),[y,x]=g.useState(!1),[w,j]=g.useState(null),[N,k]=g.useState(null),[E,A]=g.useState(null),[S,M]=g.useState("probing"),[C,I]=gy("openscout.ranger.voiceReplies",!1),[R,D]=g.useState(!1),[z,O]=g.useState(null),[_,U]=g.useState(""),[q,G]=g.useState(!1),[X,L]=g.useState(null),[F,H]=g.useState(null),[V,W]=g.useState(null),[$,B]=g.useState(!1),[Y,te]=g.useState(null),[ae,ee]=g.useState(!1),[ie,de]=g.useState(!1),[xe,Ae]=g.useState(!1),[me,Pe]=g.useState(null),[Re,Ye]=g.useState(null),[Ie,oe]=g.useState(""),[je,Fe]=g.useState(""),le=g.useRef(null),ve=g.useRef(null),ue=g.useRef(null),Ce=g.useRef(C);Ce.current=C;const be=g.useCallback(()=>{ue.current?.stop(),ue.current=null,G(!1)},[]);g.useEffect(()=>()=>be(),[be]);const we=g.useCallback(async()=>{try{const _e=await ke(`/api/agents/${encodeURIComponent(n)}/session-catalog`);te(_e)}catch{te(null)}},[n]);g.useEffect(()=>{we()},[we]);const Se=g.useCallback(async()=>{de(!0),Pe(null);try{const _e=await ke(`/api/agents/${encodeURIComponent(n)}/config`);oe(_e.model??""),Fe(_e.systemPrompt),Ye(null)}catch(_e){Pe(_e instanceof Error?_e.message:"Could not load Ranger settings.")}finally{de(!1)}},[n]);g.useEffect(()=>{$&&Se()},[Se,$]);const He=g.useCallback(async()=>{Ae(!0),Pe(null),Ye(null);try{const _e=await ke(`/api/agents/${encodeURIComponent(n)}/config`,{method:"POST",body:JSON.stringify({model:Ie,systemPrompt:je,restart:!0})});oe(_e.config.model??""),Fe(_e.config.systemPrompt),Ye(_e.restarted?"Saved and restarted":"Saved"),await l(),await we()}catch(_e){Pe(_e instanceof Error?_e.message:"Could not save Ranger settings.")}finally{Ae(!1)}},[we,Ie,je,n,l]),et=g.useCallback(async()=>{ee(!0),j(null),W("Starting fresh Ranger session"),be();try{const _e=await ke(`/api/agents/${encodeURIComponent(n)}/session/reset`,{method:"POST"});te(_e.catalog),L(null),H(null),W("Fresh Ranger session ready"),await l()}catch(_e){W(null),j(_e instanceof Error?_e.message:"Could not start a fresh Ranger session.")}finally{ee(!1)}},[n,l,be]),Be=g.useCallback(async()=>{const _e=le.current??new ef;le.current=_e,M("probing");const jt=await _e.probe();return k(jt),A(jt?null:_e.lastUnavailableReason??"Vox Companion is not reachable."),M("idle"),jt},[]);g.useEffect(()=>{Be()},[Be]);const St=g.useCallback(()=>{const _e=le.current??new ef;le.current=_e,j(null),M("launching"),_e.launch({source:"openscout",context:mE()}),window.setTimeout(()=>{Be()},2400)},[Be]),Dt=g.useCallback(()=>{const _e=le.current??new ef;le.current=_e,_e.openSettings({source:"openscout",context:mE()})},[]),Xt=g.useCallback(async _e=>{const jt=_e.trim();if(!(!jt||y)){x(!0),j(null),L(jt),H(null),W("Sending to Ranger");try{await ke("/api/ask",{method:"POST",body:JSON.stringify({body:jt,conversationId:s})}),p(""),W("Waiting for Ranger")}catch(Wt){W(null),j(Wt instanceof Error?Wt.message:"Could not ask Ranger.")}finally{x(!1)}}},[s,y]),Ee=g.useCallback(async()=>{if(R)return;const _e=le.current??new ef;if(le.current=_e,j(null),U(""),O("starting"),N!==!0&&!await Be()){O(null);return}try{const jt=await _e.startLive({onState:O,onPartial:U});ve.current=jt,D(!0);const Wt=await jt.result;D(!1),ve.current=null,U(""),O("done"),Wt.text&&await Xt(Wt.text)}catch(jt){D(!1),ve.current=null,O("error"),j(jt instanceof Error?jt.message:"Vox recording failed.")}},[Xt,Be,R,N]),Oe=g.useCallback(async()=>{O("processing"),await ve.current?.stop()},[]),Te=g.useCallback(async()=>{await ve.current?.cancel(),ve.current=null,D(!1),U(""),O(null)},[]);Kt(_e=>{if(_e.kind!=="message.posted")return;const jt=_e.payload&&typeof _e.payload=="object"?_e.payload.message:null;if(!jt||typeof jt!="object")return;const Wt=jt,Fa=typeof Wt.conversationId=="string"?Wt.conversationId:"";if(Fa&&Fa!==s||typeof Wt.actorId!="string"||!hR(Wt.actorId,n)||typeof Wt.body!="string"||!Wt.body.trim())return;const Ds=Zte(Wt.body);if(!Ds||(H(Ds),W("Ranger replied"),!Ce.current))return;be();const Q=Vte(Ds);ue.current=Q,G(!0),Q.promise.catch(ye=>{Ute(ye)||j(ye instanceof Error?ye.message:"Vox speech failed.")}).finally(()=>{ue.current===Q&&(ue.current=null,G(!1))})});const tt=R?z==="processing"?"Sending":"Stop":S==="probing"?"Checking Vox":S==="launching"?"Opening Vox":N===!1?"Launch Vox":"Start Talking",at=c?c.state??"registered":"default target",it=Y?.activeSessionId??null,yt=Y?.sessions.find(_e=>_e.id===it)??null,Jt=yt?.startedAt?new Date(yt.startedAt).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):null,Pt=yt?.model??yt?.harness??null;if(d)return r.jsxs("section",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-[var(--scout-chrome-border-soft)] bg-black/10 px-4 py-2",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(Jj,{size:12,className:"text-lime-300"}),r.jsx("span",{className:"font-mono text-[10px] font-bold uppercase tracking-[0.18em] text-[var(--scout-chrome-ink-strong)]",children:"Ranger"}),r.jsxs("span",{className:"truncate font-mono text-[10px] text-[var(--scout-chrome-ink-faint)]",children:["· ",at,it?` · ${it.slice(0,8)}`:""]})]}),r.jsx("button",{type:"button",title:"Expand Ranger","aria-label":"Expand Ranger",onClick:()=>h(!1),className:"shrink-0 rounded border border-[var(--scout-chrome-border-soft)] p-1 text-[var(--scout-chrome-ink-faint)] transition-colors hover:bg-[var(--scout-chrome-hover)] hover:text-[var(--scout-chrome-ink)]",children:r.jsx(NE,{size:12})})]});const on=e===void 0?"flex max-h-[60vh] shrink-0 flex-col gap-3 overflow-y-auto border-t border-[var(--scout-chrome-border-soft)] p-4":"flex shrink-0 flex-col gap-3 overflow-y-auto border-t border-[var(--scout-chrome-border-soft)] p-4",ln=e===void 0?void 0:{height:`${e}px`};return r.jsxs("section",{className:on,style:ln,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Jj,{size:14,className:"text-lime-300"}),r.jsx("h2",{className:"font-mono text-[10px] font-bold uppercase tracking-[0.18em] text-[var(--scout-chrome-ink-strong)]",children:"Ranger"})]}),r.jsxs("p",{className:"mt-1 truncate font-mono text-[10px] text-[var(--scout-chrome-ink-faint)]",children:[c?.name??n," · ",at,c?.model?` · ${c.model}`:"",it?` · session ${it.slice(0,8)}`:""]})]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[r.jsx("button",{type:"button",title:"Ranger settings",onClick:()=>B(_e=>!_e),className:`rounded border p-1.5 transition-colors ${$?"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:r.jsx(ih,{size:13})}),r.jsx("button",{type:"button",title:"Minimize Ranger","aria-label":"Minimize Ranger",onClick:()=>h(!0),className:"rounded border border-[var(--scout-chrome-border-soft)] p-1.5 text-[var(--scout-chrome-ink-faint)] transition-colors hover:bg-[var(--scout-chrome-hover)] hover:text-[var(--scout-chrome-ink)]",children:r.jsx(xy,{size:13})})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[r.jsx(fc,{icon:r.jsx(FO,{size:13}),label:"State",onClick:()=>{Xt(Hte)},disabled:y}),r.jsx(fc,{icon:r.jsx(IO,{size:13}),label:"Ops Tail",onClick:()=>i({type:"navigate",route:{view:"ops",mode:"tail"}})}),r.jsx(fc,{icon:r.jsx(SE,{size:13}),label:"Fleet",onClick:()=>i({type:"navigate",route:{view:"fleet"}})}),r.jsx(fc,{icon:C?r.jsx(s5,{size:13}):r.jsx(r5,{size:13}),label:C?"Replies On":"Replies Off",onClick:()=>{const _e=!C;I(_e),_e||be()}}),r.jsx(fc,{icon:ae?r.jsx(zo,{size:13,className:"animate-spin"}):r.jsx(by,{size:13}),label:"New Session",onClick:()=>{et()},disabled:ae||y})]}),it&&r.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] text-[var(--scout-chrome-ink-faint)]",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("span",{className:"uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-ghost)]",children:"Current Session"}),r.jsx("span",{className:"ml-2 text-lime-200",title:it,children:it.slice(0,8)}),Jt?r.jsxs("span",{className:"ml-2",children:["started ",Jt]}):null,Pt?r.jsx("span",{className:"ml-2",children:Pt}):null]}),Y&&Y.sessions.length>1?r.jsxs("span",{className:"shrink-0 text-[var(--scout-chrome-ink-ghost)]",children:[Y.sessions.length-1," older"]}):null]}),$&&r.jsx("div",{className:"rounded border border-[var(--scout-chrome-border-soft)] bg-black/10 p-3",children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsxs("label",{className:"flex flex-col gap-1 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:["Model",r.jsx("input",{value:Ie,onChange:_e=>oe(_e.target.value),placeholder:"gpt-5.4-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:ie||xe})]}),r.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",r.jsx("textarea",{value:je,onChange:_e=>Fe(_e.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:ie||xe})]}),me&&r.jsx("div",{className:"font-mono text-[10px] leading-relaxed text-red-300",children:me}),Re&&r.jsx("div",{className:"font-mono text-[10px] leading-relaxed text-lime-200",children:Re}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{type:"button",onClick:()=>{He()},disabled:ie||xe||!je.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:[(ie||xe)&&r.jsx(zo,{size:13,className:"animate-spin"}),xe?"Saving":"Save"]}),r.jsx("button",{type:"button",onClick:()=>{Se()},disabled:ie||xe,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"})]})]})}),N===!1&&r.jsx(Wte,{issue:E,probeState:S,onLaunch:St,onRetry:()=>{Be()},onSettings:Dt}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs("button",{type:"button",onClick:()=>{if(N===!1){St();return}R?Oe():Ee()},className:`flex flex-1 items-center justify-center gap-2 rounded border px-2.5 py-2 font-mono text-[10px] uppercase tracking-[0.12em] transition-colors ${R?"border-lime-300/50 bg-lime-300/10 text-lime-200":"border-[var(--scout-chrome-border-soft)] text-[var(--scout-chrome-ink)] hover:bg-[var(--scout-chrome-hover)]"}`,disabled:y||z==="processing"||S==="probing",children:[z==="processing"||S==="probing"?r.jsx(zo,{size:13,className:"animate-spin"}):R?r.jsx(e1,{size:12,className:"fill-current"}):r.jsx(zO,{size:13}),tt]}),R&&r.jsx("button",{type:"button",onClick:()=>{Te()},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)]",children:"Discard"})]}),(_||q)&&r.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:[r.jsx("span",{className:"min-w-0 truncate",children:q?"Speaking Ranger reply…":_}),q&&r.jsx("button",{type:"button",title:"Stop spoken reply",onClick:be,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:r.jsx(e1,{size:11,className:"fill-current"})})]}),(X||F||V)&&r.jsxs("div",{className:"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:[V&&r.jsx("div",{className:"mb-1 uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-ghost)]",children:V}),X&&r.jsxs("p",{className:"line-clamp-3",children:[r.jsx("span",{className:"text-[var(--scout-chrome-ink-soft)]",children:"You: "}),X]}),F?r.jsxs("p",{className:"mt-1 line-clamp-4",children:[r.jsx("span",{className:"text-lime-200",children:"Ranger: "}),F]}):V==="Waiting for Ranger"?r.jsx("p",{className:"mt-1 text-[var(--scout-chrome-ink-ghost)]",children:"Waiting in the sidebar..."}):null]}),r.jsxs("form",{className:"flex flex-col gap-2",onSubmit:_e=>{_e.preventDefault(),Xt(m)},children:[r.jsx("textarea",{value:m,onChange:_e=>p(_e.target.value),placeholder:"Ask Ranger to inspect state or move the UI…",rows:3,className:"w-full resize-none rounded border border-[var(--scout-chrome-border-soft)] bg-black/10 px-2.5 py-2 font-mono text-[11px] leading-relaxed text-[var(--scout-chrome-ink)] placeholder:text-[var(--scout-chrome-ink-ghost)]"}),r.jsxs("button",{type:"submit",disabled:!m.trim()||y,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:[y&&r.jsx(zo,{size:13,className:"animate-spin"}),"Ask Ranger"]})]}),w&&r.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:w})]})}function Zte(e){return e.replace(/```(?:scout-ui|scout-ui-action|ranger-ui)\s*[\s\S]*?```/gi,"").trim()}function mE(){return{requesterName:"OpenScout",productName:"Scout Audio",headline:"Turn on local voice for Ranger",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 fc({icon:e,label:t,onClick:n,disabled:s}){return r.jsxs("button",{type:"button",onClick:n,disabled:s,className:"flex items-center justify-center gap-1.5 rounded border border-[var(--scout-chrome-border-soft)] px-2 py-1.5 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink)] transition-colors hover:bg-[var(--scout-chrome-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:[e,t]})}function Wte({issue:e,probeState:t,onLaunch:n,onRetry:s,onSettings:i}){const l=t==="probing"||t==="launching";return r.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:[r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Qj,{size:14,className:"mt-0.5 shrink-0 text-lime-300"}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"uppercase tracking-[0.14em] text-lime-200",children:"Connect Vox"}),r.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&&r.jsx("p",{className:"mt-2 break-words leading-relaxed text-[var(--scout-chrome-ink-ghost)]",children:e})]})]}),r.jsxs("div",{className:"mt-3 grid grid-cols-3 gap-2",children:[r.jsx(ev,{icon:t==="launching"?r.jsx(zo,{size:12,className:"animate-spin"}):r.jsx(Qj,{size:12}),label:t==="launching"?"Opening":"Launch",onClick:n,disabled:t==="probing",title:"Open Vox"}),r.jsx(ev,{icon:t==="probing"?r.jsx(zo,{size:12,className:"animate-spin"}):r.jsx(by,{size:12}),label:"Retry",onClick:s,disabled:l,title:"Check Vox again"}),r.jsx(ev,{icon:r.jsx(ih,{size:12}),label:"Settings",onClick:i,disabled:t==="probing",title:"Open Vox settings"})]})]})}function ev({icon:e,label:t,onClick:n,disabled:s,title:i}){return r.jsxs("button",{type:"button",title:i,onClick:n,disabled:s,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 Yte({onResizeStart:e}){const t=g.useCallback(n=>{n.preventDefault(),e(n)},[e]);return r.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:[r.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)]"}),r.jsxs("div",{className:"flex flex-row gap-[3px] opacity-0 transition-opacity group-hover:opacity-100",children:[r.jsx("div",{className:"h-[3px] w-[3px] rounded-full bg-[var(--scout-chrome-ink-faint)]"}),r.jsx("div",{className:"h-[3px] w-[3px] rounded-full bg-[var(--scout-chrome-ink-faint)]"}),r.jsx("div",{className:"h-[3px] w-[3px] rounded-full bg-[var(--scout-chrome-ink-faint)]"})]})]})}const pE=180,Gte=.7,Kte=320;function tv(e,t){const n=Math.max(pE,Math.floor(t*Gte));return Math.min(n,Math.max(pE,Math.round(e)))}function Xte(){const{route:e,navigate:t,selectedBrokerAttempt:n,clearBrokerAttempt:s}=ht(),[i]=gy("openscout.ranger.collapsed",!1),[l,c]=kte("openscout.ranger.height",Kte),d=g.useRef(null),[h,m]=g.useState(0);g.useLayoutEffect(()=>{const w=d.current;if(!w)return;m(w.getBoundingClientRect().height);const j=new ResizeObserver(N=>{const k=N[0];k&&m(k.contentRect.height)});return j.observe(w),()=>j.disconnect()},[]),g.useEffect(()=>{if(h<=0)return;const w=tv(l,h);w!==l&&c(w)},[h,l,c]);const p=g.useCallback(w=>{const j=w.clientY,N=l,k=d.current?.getBoundingClientRect().height??h,E=S=>{const M=S.clientY-j;c(tv(N-M,k))},A=()=>{document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",A),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",E),document.addEventListener("mouseup",A)},[h,l,c]);let y=null;switch(e.view){case"inbox":case"fleet":y=r.jsx(gte,{});break;case"agents":case"agent-info":y=r.jsx(fte,{});break;case"sessions":case"conversation":y=r.jsx(vte,{});break;case"work":y=r.jsx(yte,{});break;case"mesh":y=r.jsx(Nte,{});break;case"ops":y=null;break;case"broker":y=n?r.jsx(SG,{attempt:n,navigate:t,onClose:s}):r.jsx(Jte,{});break;default:y=null}const x=h>0?tv(l,h):l;return r.jsxs("div",{ref:d,className:"flex h-full flex-col overflow-hidden",children:[r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:y}),!i&&r.jsx(Yte,{onResizeStart:p}),r.jsx(qte,{height:i?void 0:x})]})}function Jte(){return r.jsxs("div",{className:"sys-broker-right-empty",children:[r.jsx("div",{className:"sys-kicker",children:"Broker"}),r.jsx("p",{children:"Select any broker ledger row to inspect route metadata here."})]})}function Qte(){const{route:e,navigate:t}=ht(),[n,s]=g.useState([]),[i,l]=g.useState(()=>Ah()),[c,d]=g.useState(""),h=e.view==="channels"?e.channelId:void 0,m=g.useCallback(async()=>{const w=await ke("/api/conversations").catch(()=>[]);s(w)},[]);g.useEffect(()=>{m()},[m]),Kt(w=>{(w.kind==="message.posted"||w.kind==="conversation.upserted")&&m()});const p=g.useMemo(()=>n.filter(Xo).sort((w,j)=>(j.lastMessageAt??0)-(w.lastMessageAt??0)),[n]),y=c?p.filter(w=>Or(w).toLowerCase().includes(c.toLowerCase())):p,x=w=>{l(_x(w)),t({view:"channels",channelId:w})};return r.jsxs("div",{className:"ctx-panel",children:[r.jsx("div",{className:"ctx-panel-search",children:r.jsx("input",{type:"text",className:"ctx-panel-search-input",placeholder:"Filter channels…",value:c,onChange:w=>d(w.target.value)})}),r.jsx("div",{className:"ctx-panel-list ctx-panel-list--scroll",children:y.length===0?r.jsx("div",{className:"ctx-panel-empty",children:c?"No match":p.length===0?"No channels yet":"No channels"}):y.map(w=>{const j=w.id===h,N=IR(w.lastMessageAt,w.id,i),k=Or(w);return r.jsxs("button",{type:"button",className:["ctx-panel-item",j&&"ctx-panel-item--active",N&&"ctx-panel-item--unread"].filter(Boolean).join(" "),onClick:()=>x(w.id),children:[r.jsx("div",{className:"ctx-panel-hash",children:"#"}),r.jsxs("div",{className:"ctx-panel-body",children:[r.jsx("span",{className:"ctx-panel-name",children:k}),w.preview&&r.jsx("span",{className:"ctx-panel-preview",children:w.preview})]}),r.jsxs("div",{className:"ctx-panel-trailing",children:[w.lastMessageAt&&r.jsx("span",{className:"ctx-panel-time",children:De(w.lastMessageAt)}),N&&r.jsx("span",{className:"ctx-panel-dot"})]})]},w.id)})})]})}function ene(){const{route:e,navigate:t}=ht(),[n,s]=g.useState([]),[i,l]=g.useState(()=>Ah()),[c,d]=g.useState("all"),[h,m]=g.useState(""),p=e.view==="conversation"||e.view==="agent-info"||e.view==="agents"?e.conversationId:void 0,y=g.useCallback(async()=>{const j=await ke("/api/conversations").catch(()=>[]);s(j)},[]);g.useEffect(()=>{y()},[y]),Kt(j=>{(j.kind==="message.posted"||j.kind==="conversation.upserted")&&y()});const x=g.useMemo(()=>{let j=n;if(c==="dm"?j=j.filter(aY):c==="channel"&&(j=j.filter(Xo)),h){const N=h.toLowerCase();j=j.filter(k=>Or(k).toLowerCase().includes(N)||k.id.toLowerCase().includes(N))}return[...j].sort((N,k)=>(k.lastMessageAt??0)-(N.lastMessageAt??0))},[n,c,h]),w=j=>{l(_x(j.id)),Xo(j)?t({view:"channels",channelId:j.id}):t({view:"conversation",conversationId:j.id})};return r.jsxs("div",{className:"ctx-panel",children:[r.jsx("div",{className:"ctx-panel-tabs",children:["all","dm","channel"].map(j=>r.jsx("button",{type:"button",className:["ctx-panel-tab",c===j&&"ctx-panel-tab--active"].filter(Boolean).join(" "),onClick:()=>d(j),children:j==="all"?"All":j==="dm"?"DMs":"Channels"},j))}),r.jsx("div",{className:"ctx-panel-search",children:r.jsx("input",{type:"text",className:"ctx-panel-search-input",placeholder:"Filter…",value:h,onChange:j=>m(j.target.value)})}),r.jsx("div",{className:"ctx-panel-list ctx-panel-list--scroll",children:x.length===0?r.jsx("div",{className:"ctx-panel-empty",children:h?"No match":"Nothing yet"}):x.map(j=>{const N=j.id===p,k=IR(j.lastMessageAt,j.id,i),E=Or(j),A=Xo(j);return r.jsxs("button",{type:"button",className:["ctx-panel-item",N&&"ctx-panel-item--active",k&&"ctx-panel-item--unread"].filter(Boolean).join(" "),onClick:()=>w(j),children:[A?r.jsx("div",{className:"ctx-panel-hash",children:"#"}):r.jsx("div",{className:"ctx-panel-avatar",style:{background:gt(j.agentName??E)},children:E[0]?.toUpperCase()??"?"}),r.jsxs("div",{className:"ctx-panel-body",children:[r.jsx("span",{className:"ctx-panel-name",children:E}),j.preview&&r.jsx("span",{className:"ctx-panel-preview",children:j.preview})]}),r.jsxs("div",{className:"ctx-panel-trailing",children:[j.lastMessageAt&&r.jsx("span",{className:"ctx-panel-time",children:De(j.lastMessageAt)}),k&&r.jsx("span",{className:"ctx-panel-dot"})]})]},j.id)})})]})}function tne(){const{navigate:e}=ht(),[t,n]=g.useState(null),s=g.useCallback(async()=>{const h=await ke("/api/fleet").catch(()=>null);n(h)},[]);g.useEffect(()=>{s()},[s]),Kt(h=>{(h.kind==="message.posted"||h.kind==="flight.updated"||h.kind==="collaboration.event.appended")&&s()});const i=t?.needsAttention??[],l=(t?.activeAsks??[]).filter(h=>h.status!=="needs_attention"),c=h=>{h.conversationId&&e({view:"conversation",conversationId:h.conversationId})},d=h=>{h.conversationId&&e({view:"conversation",conversationId:h.conversationId})};return r.jsxs("div",{className:"ctx-panel",children:[r.jsxs("section",{className:"ctx-panel-section",children:[r.jsxs("div",{className:"ctx-panel-section-label",children:["Needs you",i.length>0&&r.jsx("span",{className:"ctx-panel-count",children:i.length})]}),i.length===0?r.jsx("div",{className:"ctx-panel-empty",children:"All clear"}):r.jsx("div",{className:"ctx-panel-list",children:i.map(h=>r.jsxs("button",{type:"button",className:"ctx-panel-item ctx-panel-item--attention",onClick:()=>d(h),children:[r.jsx("div",{className:"ctx-panel-avatar",style:{background:gt(h.agentName??h.agentId??h.title)},children:(h.agentName??h.agentId??"?")[0]?.toUpperCase()}),r.jsxs("div",{className:"ctx-panel-body",children:[r.jsx("span",{className:"ctx-panel-name",children:h.title}),r.jsxs("span",{className:"ctx-panel-sub",children:[h.agentName??h.agentId??"—"," · ",De(h.updatedAt)]})]})]},h.recordId))})]}),r.jsxs("section",{className:"ctx-panel-section",children:[r.jsxs("div",{className:"ctx-panel-section-label",children:["Active",l.length>0&&r.jsx("span",{className:"ctx-panel-count",children:l.length})]}),l.length===0?r.jsx("div",{className:"ctx-panel-empty",children:"No active asks"}):r.jsx("div",{className:"ctx-panel-list",children:l.slice(0,12).map(h=>r.jsxs("button",{type:"button",className:"ctx-panel-item",onClick:()=>c(h),children:[r.jsx("div",{className:"ctx-panel-avatar",style:{background:gt(h.agentName??h.agentId)},children:(h.agentName??h.agentId)[0]?.toUpperCase()}),r.jsxs("div",{className:"ctx-panel-body",children:[r.jsx("span",{className:"ctx-panel-name",children:h.task}),r.jsxs("span",{className:"ctx-panel-sub",children:[h.agentName??h.agentId," · ",h.statusLabel]})]})]},h.invocationId))})]})]})}const nne={mesh:"Mesh nodes will appear here",broker:"Broker diagnostics are in the main pane",activity:"Filters will appear here",ops:"Ops modes will appear here",work:"Work tree will appear here",settings:"Sections will appear here",terminal:"Terminal sessions will appear here",sessions:"Use the screen to browse"};function sne(){const{agents:e,route:t,navigate:n}=ht(),s=g.useMemo(()=>e.filter(l=>_r(l.state)).length,[e]),i=nne[t.view]??"Nothing to navigate here";return r.jsxs("div",{className:"ctx-panel ctx-panel--empty",children:[r.jsx("div",{className:"ctx-panel-empty-state",children:r.jsx("div",{className:"ctx-panel-empty-hint",children:i})}),r.jsxs("button",{type:"button",className:"ctx-panel-roster-button",onClick:()=>n({view:"agents"}),children:[r.jsx("span",{className:"ctx-panel-roster-label",children:"Agents"}),r.jsxs("span",{className:"ctx-panel-roster-count",children:[r.jsx("span",{className:"ctx-panel-roster-online-dot"}),s," online · ",e.length," total"]})]})]})}function ane(){const{meshSnapshot:e,selectedId:t,selectedType:n}=Mh();if(!e)return r.jsx("div",{className:"ctx-panel ctx-panel--empty",children:r.jsx("div",{className:"ctx-panel-empty-state",children:r.jsx("div",{className:"ctx-panel-empty-hint",children:"Loading mesh status…"})})});const s=Object.values(e.nodes),i=e.localNode?.id,l=e.localNode,c=s.filter(m=>m.id!==i),d=m=>(m??"").replace(/^https?:\/\//,"").split("/")[0].split(":")[0].split(".")[0].toLowerCase(),h=e.tailscale.peers.filter(m=>!s.some(p=>d(p.hostName)===d(m.hostName)||d(p.brokerUrl)===d(m.addresses?.[0])));return r.jsxs("div",{className:"ctx-panel",children:[r.jsx("div",{className:"mesh-left-section-label",children:"NODES"}),l&&r.jsxs("button",{type:"button",className:`mesh-left-node-row${t===l.id&&n==="node"?" mesh-left-node-row--active":""}`,onClick:()=>Jo(t===l.id?null:l.id,t===l.id?null:"node"),children:[r.jsx("span",{className:"mesh-left-node-dot mesh-left-node-dot--online"}),r.jsxs("span",{className:"mesh-left-node-body",children:[r.jsx("span",{className:"mesh-left-node-name",children:l.hostName?.split(".")[0]??l.name??"this broker"}),r.jsx("span",{className:"mesh-left-node-sub",children:"this node"})]})]}),c.map(m=>r.jsxs("button",{type:"button",className:`mesh-left-node-row${t===m.id&&n==="node"?" mesh-left-node-row--active":""}`,onClick:()=>Jo(t===m.id?null:m.id,t===m.id?null:"node"),children:[r.jsx("span",{className:`mesh-left-node-dot${m.advertiseScope==="mesh"?" mesh-left-node-dot--online":" mesh-left-node-dot--muted"}`}),r.jsxs("span",{className:"mesh-left-node-body",children:[r.jsx("span",{className:"mesh-left-node-name",children:m.hostName?.split(".")[0]??m.name??m.id.slice(0,8)}),r.jsxs("span",{className:"mesh-left-node-sub",children:[m.advertiseScope==="mesh"?"mesh peer":"local only",m.lastSeenAt?` · ${De(m.lastSeenAt)}`:""]})]})]},m.id)),h.slice(0,5).map(m=>r.jsxs("button",{type:"button",className:"mesh-left-node-row mesh-left-node-row--dim",disabled:!0,children:[r.jsx("span",{className:`mesh-left-node-dot${m.online?" mesh-left-node-dot--tailnet":" mesh-left-node-dot--offline"}`}),r.jsxs("span",{className:"mesh-left-node-body",children:[r.jsx("span",{className:"mesh-left-node-name",children:m.hostName?.split(".")[0]??m.name??"tailnet peer"}),r.jsx("span",{className:"mesh-left-node-sub",children:"tailnet only"})]})]},m.id)),c.length===0&&h.length===0&&r.jsx("div",{className:"mesh-left-empty",children:"No remote peers discovered"})]})}const To={working:0,available:1,offline:2};function rne(e){return e.project?e.project.toLowerCase():"other"}function ine(e){const t=new Map;for(const s of e){const i=rne(s),l=t.get(i);l?l.push(s):t.set(i,[s])}const n=[];for(const[s,i]of t){i.sort((d,h)=>{const m=(To[Xe(d.state)]??9)-(To[Xe(h.state)]??9);return m!==0?m:(h.updatedAt??0)-(d.updatedAt??0)});const l=i.reduce((d,h)=>{const m=Xe(h.state);return(To[m]??9)<(To[d]??9)?m:d},"offline"),c=Math.max(...i.map(d=>d.updatedAt??0));n.push({key:s,label:s,agents:i,bestState:l,latestUpdate:c})}return n.sort((s,i)=>{const l=(To[s.bestState]??9)-(To[i.bestState]??9);return l!==0?l:i.latestUpdate-s.latestUpdate}),n}function one(e){return e.trim().toLowerCase()}function lne(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 cne(e,t){return t?lne(e).some(n=>n.toLowerCase().includes(t)):!0}function Mo(e,t){return t?[e.harnessSessionId,e.conversationId].find(s=>s?.toLowerCase().includes(t))??null:null}function nv(e,t,n={}){e({view:"agents",agentId:t.id,...n.observe?{conversationId:t.conversationId,tab:"observe"}:{}})}function une(){const{route:e}=ht();switch(e.view){case"agents":case"agent-info":return r.jsx(dne,{});case"channels":return r.jsx(Qte,{});case"conversation":return r.jsx(ene,{});case"inbox":case"fleet":return r.jsx(tne,{});case"mesh":return r.jsx(ane,{});default:return r.jsx(sne,{})}}function dne(){const{agents:e,route:t,navigate:n}=ht(),[s,i]=g.useState(()=>new Set),[l,c]=g.useState(""),d=one(l),h=d.length>0,m=g.useMemo(()=>e.filter(j=>cne(j,d)),[e,d]),p=g.useMemo(()=>ine(m),[m]),y=m[0]??null,x=t.view==="agents"?t.agentId:void 0,w=j=>{i(N=>{const k=new Set(N);return k.has(j)?k.delete(j):k.add(j),k})};return r.jsxs("div",{className:"s-left-roster",children:[r.jsx("div",{className:"s-left-roster-search s-search",children:r.jsx("input",{type:"text",className:"s-search-input",placeholder:"Search agents or session IDs…",value:l,onChange:j=>c(j.target.value),onKeyDown:j=>{j.key==="Escape"&&(l?c(""):j.target.blur()),j.key==="Enter"&&y&&nv(n,y,{observe:!!Mo(y,d)})}})}),r.jsx("div",{style:{flex:1,overflow:"auto"},children:e.length===0?r.jsx("div",{className:"s-left-roster-empty",children:"No agents registered"}):m.length===0?r.jsx("div",{className:"s-left-roster-empty",children:"No agents match this session or agent search."}):p.map(j=>{const N=j.agents.length===1,k=h||s.has(j.key),E=N?j.agents[0]:null,A=j.agents.some(M=>M.id===x),S=E?Mo(E,d):null;return r.jsxs("div",{className:"s-left-roster-parent",children:[r.jsxs("button",{className:`s-left-roster-row${A&&(N||!k)?" s-left-roster-row--active":""}`,onClick:()=>{N?nv(n,E,{observe:!!S}):w(j.key)},children:[r.jsxs("span",{className:"s-left-roster-avatar-wrap",children:[r.jsx("span",{className:"s-left-roster-avatar",style:{background:gt(j.label)},children:j.label[0].toUpperCase()}),r.jsx("span",{className:`s-left-roster-dot s-left-roster-dot--${j.bestState}`,style:{background:Gs(j.bestState==="working"?"working":j.bestState==="available"?"available":null)}})]}),r.jsxs("span",{className:"s-left-roster-body",children:[r.jsx("span",{className:"s-left-roster-name",children:j.label}),N&&S?r.jsxs("span",{className:"s-left-roster-sub",title:S,children:["session · ",S]}):N&&(E.project||E.branch)&&r.jsxs("span",{className:"s-left-roster-sub",children:[E.name,E.branch?` · ${E.branch}`:""]}),!N&&!k&&r.jsxs("span",{className:"s-left-roster-sub",children:[j.agents.length," agents"]})]}),!N&&r.jsx("span",{className:"s-left-roster-ct",children:k?"▾":"▸"}),N&&E.updatedAt&&r.jsx("span",{className:"s-left-roster-time",children:De(E.updatedAt)})]}),!N&&k&&r.jsx("div",{className:"s-left-roster-instances",children:j.agents.map(M=>r.jsxs("button",{className:`s-left-roster-instance${M.id===x?" s-left-roster-instance--active":""}`,onClick:()=>nv(n,M,{observe:!!Mo(M,d)}),title:Mo(M,d)??void 0,children:[r.jsx("span",{className:`s-left-roster-instance-dot s-left-roster-dot--${Xe(M.state)}`,style:{background:Gs(M.state)}}),r.jsxs("span",{className:"s-left-roster-instance-label",children:[M.name,M.branch?` · ${M.branch}`:"",Mo(M,d)?` · ${Mo(M,d)}`:""]}),M.updatedAt&&r.jsx("span",{className:"s-left-roster-time",children:De(M.updatedAt)})]},M.id))})]},j.key)})})]})}function fne(){const e=_y({url:ER(),healthUrl:CR(),autoConnect:!0,sessionKey:"scout-terminal"});return r.jsx("div",{style:{height:"100%",background:"#0d0d0d",overflow:"hidden"},children:r.jsx(Oy,{relay:e,fontSize:13})})}function hne(){const{onboarding:e}=ht();return e?e.hasLocalConfig?e.hasOperatorName?e.hasProjectConfig?null:r.jsx(sv,{children:r.jsx(gne,{})}):r.jsx(sv,{children:r.jsx(pne,{})}):r.jsx(sv,{children:r.jsx(mne,{})}):null}function sv({children:e}){return r.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",overflow:"auto",background:"var(--bg)",color:"var(--ink)"},children:r.jsx("div",{style:{width:"100%",maxWidth:720,padding:"80px 72px",display:"flex",flexDirection:"column",gap:40},children:e})})}function Yx({eyebrow:e,title:t,description:n}){return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[r.jsx("div",{style:vne,children:e}),r.jsx("div",{style:yne,children:t}),r.jsx("div",{style:xne,children:n})]})}function Gx({primary:e,onPrimary:t,primaryDisabled:n,busy:s}){const{skipOnboarding:i}=ht();return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:24,paddingTop:8},children:[r.jsx("button",{type:"button",onClick:t,disabled:n||s,style:{...wne,opacity:n||s?.5:1,cursor:n||s?"default":"pointer"},children:s?"Working…":e}),r.jsx("button",{type:"button",onClick:i,style:jne,onMouseEnter:l=>{l.currentTarget.style.color="rgba(255,255,255,0.8)"},onMouseLeave:l=>{l.currentTarget.style.color="rgba(255,255,255,0.45)"},children:"Skip for now"})]})}function Kx({message:e}){return e?r.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 mne(){const{onboarding:e,refreshOnboarding:t}=ht(),[n,s]=g.useState(!1),[i,l]=g.useState(null),c=async()=>{s(!0),l(null);try{await ke("/api/onboarding/init",{method:"POST",body:"{}"}),await t()}catch(d){l(d instanceof Error?d.message:String(d))}finally{s(!1)}};return r.jsxs(r.Fragment,{children:[r.jsx(Yx,{eyebrow:"First-run setup",title:"Welcome to Scout",description:r.jsxs(r.Fragment,{children:["Scout needs a local config before it can talk to the broker, the web app, and paired devices. This writes"," ",r.jsx("code",{style:yy,children:"~/.openscout/config.json"})," with sensible defaults — you can edit it any time."]})}),r.jsxs("ul",{style:Nne,children:[r.jsx(gE,{label:"Local config (~/.openscout/config.json)",done:!1,hint:"missing"}),r.jsx(gE,{label:".openscout/project.json in a repo",done:!!e?.hasProjectConfig,hint:e?.hasProjectConfig?e.projectRoot??void 0:"checked after setup"})]}),r.jsx(Kx,{message:i}),r.jsx(Gx,{primary:"Initialize Scout",onPrimary:()=>{c()},busy:n})]})}function pne(){const{onboarding:e,refreshOnboarding:t}=ht(),n=e?.operatorNameSuggestion??"",[s,i]=g.useState(n),[l,c]=g.useState(!1),[d,h]=g.useState(null);g.useEffect(()=>{!s&&n&&i(n)},[n,s]);const m=async()=>{const p=s.trim();if(!p){h("Name is required.");return}c(!0),h(null);try{await ke("/api/user",{method:"POST",body:JSON.stringify({name:p})}),await t()}catch(y){h(y instanceof Error?y.message:String(y))}finally{c(!1)}};return r.jsxs(r.Fragment,{children:[r.jsx(Yx,{eyebrow:"Step 1 of 2",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."}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[r.jsx("label",{style:bf,children:"Your name"}),r.jsx("input",{autoFocus:!0,value:s,onChange:p=>{i(p.target.value),h(null)},onKeyDown:p=>{p.key==="Enter"&&m()},placeholder:n||"Operator",style:vy}),n?r.jsx("div",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",fontFamily:"var(--hud-font-mono)"},children:"Prefilled from your machine."}):null]}),r.jsx(Kx,{message:d}),r.jsx(Gx,{primary:"Continue",onPrimary:()=>{m()},busy:l,primaryDisabled:!s.trim()})]})}function gne(){const{onboarding:e,refreshOnboarding:t}=ht(),n=e?.currentDirectory??"",[s,i]=g.useState([n||"~/dev"]),[l,c]=g.useState(n),[d,h]=g.useState("claude"),[m,p]=g.useState(!1),[y,x]=g.useState(null),w=(E,A)=>{i(S=>S.map((M,C)=>C===E?A:M))},j=()=>i(E=>[...E,""]),N=E=>i(A=>A.filter((S,M)=>M!==E)),k=async()=>{const E=s.map(S=>S.trim()).filter(Boolean),A=l.trim();if(!A){x("Pick where Scout should anchor this context.");return}p(!0),x(null);try{await ke("/api/onboarding/project",{method:"POST",body:JSON.stringify({contextRoot:A,sourceRoots:E,defaultHarness:d})}),await t()}catch(S){x(S instanceof Error?S.message:String(S))}finally{p(!1)}};return r.jsxs(r.Fragment,{children:[r.jsx(Yx,{eyebrow:"Step 2 of 2",title:"Where do your repos live?",description:r.jsxs(r.Fragment,{children:["Scout scans these folders for projects and anchors this context at"," ",r.jsx("code",{style:yy,children:"<context>/.openscout/project.json"}),"."]})}),r.jsxs("div",{style:av,children:[r.jsx("label",{style:bf,children:"Scan folders"}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[s.map((E,A)=>r.jsxs("div",{style:{display:"flex",gap:8},children:[r.jsx("input",{value:E,onChange:S=>w(A,S.target.value),placeholder:A===0?"~/dev":"Add another folder",style:{...vy,flex:1}}),r.jsx("button",{type:"button",onClick:()=>N(A),disabled:s.length<=1,style:{...vE,opacity:s.length<=1?.4:1,cursor:s.length<=1?"default":"pointer"},"aria-label":`Remove folder ${A+1}`,children:"−"})]},A)),r.jsx("button",{type:"button",onClick:j,style:{...vE,alignSelf:"flex-start"},children:"+ Add folder"})]})]}),r.jsxs("div",{style:av,children:[r.jsx("label",{style:bf,children:"Context root"}),r.jsx("input",{value:l,onChange:E=>c(E.target.value),placeholder:"~/dev",style:vy}),r.jsxs("div",{style:bne,children:["Scout writes ",r.jsx("code",{style:yy,children:".openscout/project.json"})," ","inside this folder."]})]}),r.jsxs("div",{style:av,children:[r.jsx("label",{style:bf,children:"Default harness"}),r.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:["claude","codex"].map(E=>{const A=d===E;return r.jsxs("button",{type:"button",onClick:()=>h(E),style:{...Sne,borderColor:A?"var(--accent, #2dd4bf)":"rgba(255,255,255,0.12)",backgroundColor:A?"rgba(45,212,191,0.08)":"rgba(255,255,255,0.02)"},children:[r.jsx("div",{style:{fontSize:15,fontWeight:600,textTransform:"capitalize"},children:E}),r.jsx("div",{style:{fontSize:12,color:"rgba(255,255,255,0.55)",marginTop:6,lineHeight:1.5},children:E==="claude"?"Anthropic Claude Code — local CLI agent.":"OpenAI Codex — cloud agentic sandbox."})]},E)})})]}),r.jsx(Kx,{message:y}),r.jsx(Gx,{primary:"Create project",onPrimary:()=>{k()},busy:m,primaryDisabled:!l.trim()})]})}function gE({label:e,done:t,hint:n}){return r.jsxs("li",{style:{display:"flex",alignItems:"flex-start",gap:16},children:[r.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?"✓":"•"}),r.jsxs("div",{style:{minWidth:0},children:[r.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?r.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 vne={fontSize:11,fontFamily:"var(--hud-font-mono)",textTransform:"uppercase",letterSpacing:"0.18em",color:"rgba(255,255,255,0.4)"},yne={fontSize:36,fontWeight:600,letterSpacing:"-0.01em",lineHeight:1.15},xne={fontSize:15,lineHeight:1.75,color:"rgba(255,255,255,0.6)",maxWidth:580},av={display:"flex",flexDirection:"column",gap:10},bf={fontSize:11,fontFamily:"var(--hud-font-mono)",textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255,255,255,0.5)"},vy={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"},bne={fontSize:12,color:"rgba(255,255,255,0.45)",lineHeight:1.6},yy={fontFamily:"var(--hud-font-mono)",fontSize:12,padding:"2px 6px",borderRadius:4,backgroundColor:"rgba(255,255,255,0.06)"},wne={fontSize:13,fontWeight:600,padding:"12px 24px",borderRadius:10,backgroundColor:"var(--accent, #2dd4bf)",color:"#0b0d12",border:"none",transition:"opacity 0.15s ease"},vE={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"},jne={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"},Nne={display:"flex",flexDirection:"column",gap:20,margin:0,padding:0,listStyle:"none"},Sne={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"},kne=[{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:"Go to Fleet",description:"Navigate to the fleet overview with agent status summary",category:"navigation",keywords:["fleet","overview","status"],shortcut:"Cmd+3"},{commandId:"nav:conversations",title:"Go to Conversations",description:"Navigate to the unified conversations playground backed by the normalized conversations service",category:"navigation",keywords:["conversations","comms","chat","threads"]},{commandId:"nav:sessions",title:"Go to Sessions",description:"Navigate to the sessions list showing all active conversations",category:"navigation",keywords:["sessions","conversations","threads"],shortcut:"Cmd+4"},{commandId:"nav:channels",title:"Go to Channels",description:"Navigate to the channels browser for group conversations",category:"navigation",keywords:["channels","channel","group","broadcast"],shortcut:"Cmd+5"},{commandId:"nav:activity",title:"Go to Activity",description:"Navigate to the activity feed showing recent events",category:"navigation",keywords:["activity","feed","events","log"],shortcut:"Cmd+6"},{commandId:"nav:mesh",title:"Go to Mesh",description:"Navigate to the mesh network view showing nodes and topology",category:"navigation",keywords:["mesh","network","nodes","peers","topology"],shortcut:"Cmd+7"},{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: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 V2(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:g.createElement(SE,{size:14,strokeWidth:1.2}),Provider:({children:n})=>g.createElement(uW,{initialTheme:t},n),leftPanel:{title:"Navigation"},rightPanel:{title:"Context"},slots:{Content:cte,LeftPanel:une,Inspector:Xte,Takeover:hne,Terminal:fne},intents:kne,hooks:{useCommands:dW,useStatus:fW,useNavCenter:mW,useNavActions:pW,useLayoutMode:gW,useTakeover:vW}}}V2();function yE(e){return e==="dark"||e==="light"?e:null}function Ene(){if(typeof window>"u")return"dark";const e=yE(sY());if(e)return e;const t=yE(new URLSearchParams(window.location.search).get("theme"));return t||"dark"}function Cne(e){typeof document>"u"||(document.documentElement.dataset.scoutThemeMode=e,document.documentElement.style.colorScheme=e)}const F2=document.getElementById("root");if(!F2)throw new Error("missing #root");const H2=Ene();Cne(H2);dO.createRoot(F2).render(r.jsx(g.StrictMode,{children:r.jsx(wW,{app:V2({initialTheme:H2})})}));
|